Skip to content

Commit 360da6f

Browse files
Garmelonmathlib-nightly-testing[bot]kim-emmathlib4-botRob23oba
committed
chore: bump toolchain to v4.32.0-rc1 (#40732)
Co-authored-by: mathlib-nightly-testing[bot] <mathlib-nightly-testing[bot]@users.noreply.github.com> Co-authored-by: Kim Morrison <kim@tqft.net> Co-authored-by: mathlib4-bot <github-mathlib4-bot@leanprover.zulipchat.com> Co-authored-by: Joscha <joscha@plugh.de> Co-authored-by: Rob23oba <robin.arnez@web.de> Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Julia Markus Himmel <2065352+TwoFX@users.noreply.github.com> Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
1 parent e81046e commit 360da6f

128 files changed

Lines changed: 756 additions & 749 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Counterexamples/DirectSumIsInternal.lean

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ theorem withSign.isCompl : IsCompl ℤ≥0 ℤ≤0 := by
5656
· exact Submodule.mem_sup_left (mem_withSign_one.mpr hp)
5757
· exact Submodule.mem_sup_right (mem_withSign_neg_one.mpr hn)
5858

59-
lemma withSign.independent : iSupIndep withSign := by
60-
apply (iSupIndep_pair UnitsInt.one_ne_neg_one _).mpr withSign.isCompl.disjoint
59+
set_option linter.defProp false in
60+
def withSign.independent : iSupIndep withSign := by
61+
apply
62+
(iSupIndep_pair UnitsInt.one_ne_neg_one _).mpr withSign.isCompl.disjoint
6163
intro i
6264
fin_cases i <;> simp
6365

Mathlib/Algebra/Category/Grp/Basic.lean

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,19 +600,24 @@ instance CommGrpCat.forget_reflects_isos : (forget CommGrpCat.{u}).ReflectsIsomo
600600
-- note: in the following definitions, there is a problem with `@[to_additive]`
601601
-- as the `Category` instance is not found on the additive variant
602602
-- this variant is then renamed with an `Aux` suffix
603-
603+
set_option linter.checkUnivs false in
604604
/-- An alias for `GrpCat.{max u v}`, to deal around unification issues. -/
605605
@[to_additive (attr := nolint checkUnivs) GrpMaxAux
606606
/-- An alias for `AddGrpCat.{max u v}`, to deal around unification issues. -/]
607607
abbrev GrpMax.{u1, u2} := GrpCat.{max u1 u2}
608+
609+
set_option linter.checkUnivs false in
608610
/-- An alias for `AddGrpCat.{max u v}`, to deal around unification issues. -/
609611
@[nolint checkUnivs]
610612
abbrev AddGrpMax.{u1, u2} := AddGrpCat.{max u1 u2}
611613

614+
set_option linter.checkUnivs false in
612615
/-- An alias for `CommGrpCat.{max u v}`, to deal around unification issues. -/
613616
@[to_additive (attr := nolint checkUnivs) AddCommGrpMaxAux
614617
/-- An alias for `AddCommGrpCat.{max u v}`, to deal around unification issues. -/]
615618
abbrev CommGrpMax.{u1, u2} := CommGrpCat.{max u1 u2}
619+
620+
set_option linter.checkUnivs false in
616621
/-- An alias for `AddCommGrpCat.{max u v}`, to deal around unification issues. -/
617622
@[nolint checkUnivs]
618623
abbrev AddCommGrpMax.{u1, u2} := AddCommGrpCat.{max u1 u2}

Mathlib/Algebra/Module/Presentation/Basic.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ namespace Module
4848

4949
variable (A : Type u) [Ring A]
5050

51+
set_option linter.checkUnivs false in
5152
/-- Given a ring `A`, this structure involves a family of elements (indexed by a type `R`)
5253
in a free module `G →₀ A`. This allows to define an `A`-module by generators and relations,
5354
see `Relations.Quotient`. -/
@@ -488,6 +489,7 @@ end Relations
488489

489490
variable (M : Type v) [AddCommGroup M] [Module A M]
490491

492+
set_option linter.checkUnivs false in
491493
/-- Given an `A`-module `M`, a term in this type is a presentation by `M` by
492494
generators and relations. -/
493495
@[nolint checkUnivs]

Mathlib/Algebra/Order/AbsoluteValue/Basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,8 @@ open Lean Meta Mathlib Meta Positivity Qq in
416416
For performance reasons, we only attempt to apply this when `abv` is a variable.
417417
If it is an explicit function, e.g. `|_|` or `‖_‖`, another extension should apply. -/
418418
@[positivity _]
419-
meta def Mathlib.Meta.Positivity.evalAbv : PositivityExt where eval {_ _α} _zα pα? e := do
420-
let some _ := pα? | pure .none
419+
meta def Mathlib.Meta.Positivity.evalAbv : PositivityExt where eval {_ _α} _zα pα? e :=
420+
match pα? with | none => pure .none | some _ => do
421421
let (.app f a) ← whnfR e | throwError "not abv ·"
422422
if !f.getAppFn.isFVar then
423423
throwError "abv: function is not a variable"

Mathlib/Algebra/Order/Algebra.lean

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,13 @@ open Lean Meta Qq Function
9595

9696
/-- Extension for `algebraMap`. -/
9797
@[positivity algebraMap _ _ _]
98-
meta def evalAlgebraMap : PositivityExt where eval {u β} _zβ pβ? e := do
98+
meta def evalAlgebraMap : PositivityExt where eval {u β} _zβ pβ? e :=
99+
match pβ? with | none => pure .none | some _ => do
99100
let ~q(@algebraMap $α _ $instα $instβ $instαβ $a) := e | throwError "not `algebraMap`"
100-
let pα ← try? <| synthInstanceQ q(PartialOrder $α)
101-
match ← core q(inferInstance) a with
101+
let some pα ← try? <| synthInstanceQ q(PartialOrder $α) | pure .none
102+
match ← core q(inferInstance) (some pα) a with
102103
| .positive pa =>
103-
let some _ := pβ? | pure .none
104104
let _instαSemiring ← synthInstanceQ q(Semiring $α)
105-
let _instαPartialOrder ← synthInstanceQ q(PartialOrder $α)
106105
try
107106
let _instβSemiring ← synthInstanceQ q(Semiring $β)
108107
let _instβPartialOrder ← synthInstanceQ q(PartialOrder $β)
@@ -118,9 +117,7 @@ meta def evalAlgebraMap : PositivityExt where eval {u β} _zβ pβ? e := do
118117
assertInstancesCommute
119118
return .nonnegative q(algebraMap_nonneg $β <| le_of_lt $pa)
120119
| .nonnegative pa =>
121-
let some _ := pβ? | pure .none
122120
let _instαSemiring ← synthInstanceQ q(CommSemiring $α)
123-
let _instαPartialOrder ← synthInstanceQ q(PartialOrder $α)
124121
let _instβSemiring ← synthInstanceQ q(Semiring $β)
125122
let _instβPartialOrder ← synthInstanceQ q(PartialOrder $β)
126123
let _instβIsOrderedRing ← synthInstanceQ q(IsOrderedRing $β)

Mathlib/Algebra/Order/BigOperators/Expect.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,22 +220,22 @@ open scoped BigOperators
220220
attribute [local instance] monadLiftOptionMetaM in
221221
/-- Positivity extension for `Finset.expect`. -/
222222
@[positivity Finset.expect _ _]
223-
meta def evalFinsetExpect : PositivityExt where eval {u α} zα pα? e := do
224-
let some pα := pα? | pure .none
223+
meta def evalFinsetExpect : PositivityExt where eval {u α} zα pα? e :=
224+
match pα? with | none => pure .none | some pα => do
225225
match e with
226226
| ~q(@Finset.expect $ι _ $instα $instmod $s $f) =>
227227
let i : Q($ι) ← mkFreshExprMVarQ q($ι) .syntheticOpaque
228228
have body : Q($α) := .betaRev f #[i]
229229
let rbody ← core zα pα body
230-
let p_pos : Option Q(0 < $e) ← (do
230+
let p_pos : Option Q(0 < $e) ← do
231231
let .positive pbody := rbody | pure none -- Fail if the body is not provably positive
232232
let some ps ← proveFinsetNonempty s | pure none
233233
let .some pα' ← trySynthInstanceQ q(IsOrderedCancelAddMonoid $α) | pure none
234234
let .some instαordsmul ← trySynthInstanceQ q(PosSMulStrictMono ℚ≥0 $α) | pure none
235235
assumeInstancesCommute
236236
let pr : Q(∀ i, 0 < $f i) ← mkLambdaFVars #[i] pbody
237-
return some
238-
q(@expect_pos $ι $α $instα $pα $pα' $instmod $instαordsmul $s $f (fun i _ ↦ $pr i) $ps))
237+
pure <| some
238+
q(@expect_pos $ι $α $instα $pα $pα' $instmod $instαordsmul $s $f (fun i _ ↦ $pr i) $ps)
239239
-- Try to show that the sum is positive
240240
if let some p_pos := p_pos then
241241
return .positive p_pos

Mathlib/Algebra/Order/BigOperators/Ring/Finset.lean

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,16 +225,16 @@ example (s : Finset ℕ) (f : ℕ → ℤ) (hf : ∀ n, 0 ≤ f n) : 0 ≤ s.pro
225225
because `compareHyp` can't look for assumptions behind binders.
226226
-/
227227
@[positivity Finset.prod _ _]
228-
meta def evalFinsetProd : PositivityExt where eval {u α} zα pα? e := do
228+
meta def evalFinsetProd : PositivityExt where eval {u α} zα pα? e :=
229+
match pα? with | none => pure .none | some pα => do
229230
match e with
230231
| ~q(@Finset.prod $ι _ $instα $s $f) =>
231-
let some pα := pα? | pure .none
232232
let i : Q($ι) ← mkFreshExprMVarQ q($ι) .syntheticOpaque
233233
have body : Q($α) := Expr.betaRev f #[i]
234234
let rbody ← core zα pα body
235235
let _instαmon ← synthInstanceQ q(CommMonoidWithZero $α)
236236
-- Try to show that the product is positive
237-
let p_pos : Option Q(0 < $e) := do
237+
let p_pos : Option Q(0 < $e) ← do
238238
let .positive pbody := rbody | pure none -- Fail if the body is not provably positive
239239
-- TODO(https://github.com/leanprover-community/quote4/issues/38):
240240
-- We must name the following, else `assertInstancesCommute` loops.
@@ -243,19 +243,19 @@ meta def evalFinsetProd : PositivityExt where eval {u α} zα pα? e := do
243243
let .some _instαnontriv ← trySynthInstanceQ q(Nontrivial $α) | pure none
244244
assertInstancesCommute
245245
let pr : Q(∀ i, 0 < $f i) ← mkLambdaFVars #[i] pbody (binderInfoForMVars := .default)
246-
return some q(prod_pos fun i _ ↦ $pr i)
246+
pure <| some q(prod_pos fun i _ ↦ $pr i)
247247
if let some p_pos := p_pos then return .positive p_pos
248248
-- Try to show that the product is nonnegative
249-
let p_nonneg : Option Q(0 ≤ $e) := do
249+
let p_nonneg : Option Q(0 ≤ $e) ← do
250250
let some pbody := rbody.toNonneg
251-
| return none -- Fail if the body is not provably nonnegative
251+
| pure none -- Fail if the body is not provably nonnegative
252252
let pr : Q(∀ i, 0 ≤ $f i) ← mkLambdaFVars #[i] pbody (binderInfoForMVars := .default)
253253
-- TODO(https://github.com/leanprover-community/quote4/issues/38):
254254
-- We must name the following, else `assertInstancesCommute` loops.
255255
let .some _instαzeroone ← trySynthInstanceQ q(ZeroLEOneClass $α) | pure none
256256
let .some _instαposmul ← trySynthInstanceQ q(PosMulMono $α) | pure none
257257
assertInstancesCommute
258-
return some q(prod_nonneg fun i _ ↦ $pr i)
258+
pure <| some q(prod_nonneg fun i _ ↦ $pr i)
259259
if let some p_nonneg := p_nonneg then return .nonnegative p_nonneg
260260
-- Fall back to showing that the product is nonzero
261261
let pbody ← rbody.toNonzero

Mathlib/Algebra/Order/Field/Basic.lean

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -740,26 +740,28 @@ such that `positivity` successfully recognises both `a` and `b`. -/
740740
trace[Tactic.positivity.zeroness] "evalDiv: {a} divided by {b}"
741741
let _a ← synthInstanceQ q(Semifield $α)
742742
let ⟨_f_eq⟩ ← withDefault <| withNewMCtxDepth <| assertDefEqQ q($f) q(HDiv.hDiv)
743-
let some pα := pα? |
743+
match (dependent := true) pα? with
744+
| none =>
744745
match ← core zα pα? a, ← core zα pα? b with
745746
| .nonzero pa, .nonzero pb =>
746747
let _a ← synthInstanceQ q(GroupWithZero $α)
747748
assumeInstancesCommute
748749
pure (.nonzero q(div_ne_zero $pa $pb))
749750
| _, _ => pure .none
750-
let _a ← synthInstanceQ q(GroupWithZero $α)
751-
let _a ← synthInstanceQ q(PosMulReflectLT $α)
752-
assumeInstancesCommute
753-
let ra ← core zα pα a; let rb ← core zα pα b
754-
match ra, rb with
755-
| .positive pa, .positive pb => pure (.positive q(div_pos $pa $pb))
756-
| .positive pa, .nonnegative pb => pure (.nonnegative q(div_nonneg_of_pos_of_nonneg $pa $pb))
757-
| .nonnegative pa, .positive pb => pure (.nonnegative q(div_nonneg_of_nonneg_of_pos $pa $pb))
758-
| .nonnegative pa, .nonnegative pb => pure (.nonnegative q(div_nonneg $pa $pb))
759-
| .positive pa, .nonzero pb => pure (.nonzero q(div_ne_zero_of_pos_of_ne_zero $pa $pb))
760-
| .nonzero pa, .positive pb => pure (.nonzero q(div_ne_zero_of_ne_zero_of_pos $pa $pb))
761-
| .nonzero pa, .nonzero pb => pure (.nonzero q(div_ne_zero $pa $pb))
762-
| _, _ => pure .none
751+
| some pα =>
752+
let _a ← synthInstanceQ q(GroupWithZero $α)
753+
let _a ← synthInstanceQ q(PosMulReflectLT $α)
754+
assumeInstancesCommute
755+
let ra ← core zα pα a; let rb ← core zα pα b
756+
match ra, rb with
757+
| .positive pa, .positive pb => pure (.positive q(div_pos $pa $pb))
758+
| .positive pa, .nonnegative pb => pure (.nonnegative q(div_nonneg_of_pos_of_nonneg $pa $pb))
759+
| .nonnegative pa, .positive pb => pure (.nonnegative q(div_nonneg_of_nonneg_of_pos $pa $pb))
760+
| .nonnegative pa, .nonnegative pb => pure (.nonnegative q(div_nonneg $pa $pb))
761+
| .positive pa, .nonzero pb => pure (.nonzero q(div_ne_zero_of_pos_of_ne_zero $pa $pb))
762+
| .nonzero pa, .positive pb => pure (.nonzero q(div_ne_zero_of_ne_zero_of_pos $pa $pb))
763+
| .nonzero pa, .nonzero pb => pure (.nonzero q(div_ne_zero $pa $pb))
764+
| _, _ => pure .none
763765

764766
/-- The `positivity` extension which identifies expressions of the form `a⁻¹`,
765767
such that `positivity` successfully recognises `a`. -/
@@ -769,33 +771,35 @@ meta def evalInv : PositivityExt where eval {u α} zα pα? e := do
769771
let _e_eq : $e =Q $f $a := ⟨⟩
770772
let _a ← synthInstanceQ q(Semifield $α)
771773
let ⟨_f_eq⟩ ← withDefault <| withNewMCtxDepth <| assertDefEqQ q($f) q(Inv.inv)
772-
let some _ := pα? |
774+
match (dependent := true) pα? with
775+
| none =>
773776
match ← core zα pα? a with
774777
| .nonzero pa =>
775778
let _a ← synthInstanceQ q(GroupWithZero $α)
776779
assumeInstancesCommute
777780
pure (.nonzero q(inv_ne_zero $pa))
778781
| _ => pure .none
779-
let _a ← synthInstanceQ q(GroupWithZero $α)
780-
let _a ← synthInstanceQ q(PartialOrder $α)
781-
let _a ← synthInstanceQ q(PosMulReflectLT $α)
782-
assumeInstancesCommute
783-
let ra ← core zα pα? a
784-
match ra with
785-
| .positive pa =>
782+
| some pα =>
783+
let _a ← synthInstanceQ q(GroupWithZero $α)
784+
let _a ← synthInstanceQ q(PartialOrder $α)
785+
let _a ← synthInstanceQ q(PosMulReflectLT $α)
786786
assumeInstancesCommute
787-
pure (.positive q(inv_pos_of_pos $pa))
788-
| .nonnegative pa =>
789-
assumeInstancesCommute
790-
pure (.nonnegative q(inv_nonneg_of_nonneg $pa))
791-
| .nonzero pa => pure (.nonzero q(inv_ne_zero $pa))
792-
| .none => pure .none
787+
let ra ← core zα (some pα) a
788+
match ra with
789+
| .positive pa =>
790+
assumeInstancesCommute
791+
pure (.positive q(inv_pos_of_pos $pa))
792+
| .nonnegative pa =>
793+
assumeInstancesCommute
794+
pure (.nonnegative q(inv_nonneg_of_nonneg $pa))
795+
| .nonzero pa => pure (.nonzero q(inv_ne_zero $pa))
796+
| .none => pure .none
793797

794798
/-- The `positivity` extension which identifies expressions of the form `a ^ (0:ℤ)`. -/
795799
@[positivity _ ^ (0 : ℤ), Pow.pow _ (0 : ℤ)]
796-
meta def evalPowZeroInt : PositivityExt where eval {u α} _zα pα? e := do
800+
meta def evalPowZeroInt : PositivityExt where eval {u α} _zα pα? e :=
801+
match pα? with | none => pure .none | some _ => do
797802
let .app (.app _ (a : Q($α))) _ ← withReducible (whnf e) | throwError "not ^"
798-
let some _ := pα? | pure .none
799803
let _a ← synthInstanceQ q(Semifield $α)
800804
let _a ← synthInstanceQ q(LinearOrder $α)
801805
let _a ← synthInstanceQ q(IsStrictOrderedRing $α)

Mathlib/Algebra/Order/Field/Power.lean

Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -125,69 +125,71 @@ such that `positivity` successfully recognises both `a` and `b`. -/
125125
@[positivity _ ^ (_ : ℤ), Pow.pow _ (_ : ℤ)]
126126
meta def evalZPow : PositivityExt where eval {u α} zα pα? e := do
127127
let .app (.app _ (a : Q($α))) (b : Q(ℤ)) ← withReducible (whnf e) | throwError "not ^"
128-
let some pα := pα? |
128+
match (dependent := true) pα? with
129+
| none =>
129130
match ← core zα pα? a with
130131
| .nonzero pa =>
131132
let _a ← synthInstanceQ q(GroupWithZero $α)
132133
assumeInstancesCommute
133134
haveI' : $e =Q $a ^ $b := ⟨⟩
134135
pure (.nonzero q(zpow_ne_zero $b $pa))
135136
| _ => pure .none
136-
let result ← catchNone do
137-
let _a ← synthInstanceQ q(Field $α)
138-
let _a ← synthInstanceQ q(LinearOrder $α)
139-
let _a ← synthInstanceQ q(IsStrictOrderedRing $α)
140-
assumeInstancesCommute
141-
match ← whnfR b with
142-
| .app (.app (.app (.const `OfNat.ofNat _) _) (.lit (Literal.natVal n))) _ =>
143-
guard (n % 2 = 0)
144-
have m : Q(ℕ) := mkRawNatLit (n / 2)
145-
haveI' : $b =Q $m + $m := ⟨⟩
146-
haveI' : $e =Q $a ^ $b := ⟨⟩
147-
pure (.nonnegative q(Even.zpow_nonneg (Even.add_self _) $a))
148-
| .app (.app (.app (.const `Neg.neg _) _) _) b' =>
149-
let b' ← whnfR b'
150-
let .true := b'.isAppOfArity ``OfNat.ofNat 3 | throwError "not a ^ -n where n is a literal"
151-
let some n := (b'.getRevArg! 1).rawNatLit? | throwError "not a ^ -n where n is a literal"
152-
guard (n % 2 = 0)
153-
have m : Q(ℕ) := mkRawNatLit (n / 2)
154-
haveI' : $b =Q (-$m) + (-$m) := ⟨⟩
155-
haveI' : $e =Q $a ^ $b := ⟨⟩
156-
pure (.nonnegative q(Even.zpow_nonneg (Even.add_self _) $a))
157-
| _ => throwError "not a ^ n where n is a literal or a negated literal"
158-
orElse result do
159-
let ra ← core zα pα a
160-
let ofNonneg (pa : Q(0 ≤ $a))
161-
(_oα : Q(Semifield $α)) (_oα : Q(LinearOrder $α)) (_oα : Q(IsStrictOrderedRing $α)) :
162-
MetaM (Strictness zα e pα) := do
163-
haveI' : $e =Q $a ^ $b := ⟨⟩
164-
assumeInstancesCommute
165-
pure (.nonnegative q(zpow_nonneg $pa $b))
166-
let ofNonzero (pa : Q($a ≠ 0)) (_oα : Q(GroupWithZero $α)) : MetaM (Strictness zα e pα) := do
167-
haveI' : $e =Q $a ^ $b := ⟨⟩
168-
let _a ← synthInstanceQ q(GroupWithZero $α)
137+
| some pα =>
138+
let result ← catchNone do
139+
let _a ← synthInstanceQ q(Field $α)
140+
let _a ← synthInstanceQ q(LinearOrder $α)
141+
let _a ← synthInstanceQ q(IsStrictOrderedRing $α)
169142
assumeInstancesCommute
170-
pure (.nonzero q(zpow_ne_zero $b $pa))
171-
match ra with
172-
| .positive pa =>
173-
try
174-
let _a ← synthInstanceQ q(Semifield $α)
175-
let _a ← synthInstanceQ q(LinearOrder $α)
176-
let _a ← synthInstanceQ q(IsStrictOrderedRing $α)
143+
match ← whnfR b with
144+
| .app (.app (.app (.const `OfNat.ofNat _) _) (.lit (Literal.natVal n))) _ =>
145+
guard (n % 2 = 0)
146+
have m : Q(ℕ) := mkRawNatLit (n / 2)
147+
haveI' : $b =Q $m + $m := ⟨⟩
148+
haveI' : $e =Q $a ^ $b := ⟨⟩
149+
pure (.nonnegative q(Even.zpow_nonneg (Even.add_self _) $a))
150+
| .app (.app (.app (.const `Neg.neg _) _) _) b' =>
151+
let b' ← whnfR b'
152+
let .true := b'.isAppOfArity ``OfNat.ofNat 3 | throwError "not a ^ -n where n is a literal"
153+
let some n := (b'.getRevArg! 1).rawNatLit? | throwError "not a ^ -n where n is a literal"
154+
guard (n % 2 = 0)
155+
have m : Q(ℕ) := mkRawNatLit (n / 2)
156+
haveI' : $b =Q (-$m) + (-$m) := ⟨⟩
157+
haveI' : $e =Q $a ^ $b := ⟨⟩
158+
pure (.nonnegative q(Even.zpow_nonneg (Even.add_self _) $a))
159+
| _ => throwError "not a ^ n where n is a literal or a negated literal"
160+
orElse result do
161+
let ra ← core zα pα a
162+
let ofNonneg (pa : Q(0 ≤ $a))
163+
(_oα : Q(Semifield $α)) (_oα : Q(LinearOrder $α)) (_oα : Q(IsStrictOrderedRing $α)) :
164+
MetaM (Strictness zα e pα) := do
165+
haveI' : $e =Q $a ^ $b := ⟨⟩
177166
assumeInstancesCommute
167+
pure (.nonnegative q(zpow_nonneg $pa $b))
168+
let ofNonzero (pa : Q($a ≠ 0)) (_oα : Q(GroupWithZero $α)) : MetaM (Strictness zα e pα) := do
178169
haveI' : $e =Q $a ^ $b := ⟨⟩
179-
pure (.positive q(zpow_pos $pa $b))
180-
catch e : Exception =>
181-
trace[Tactic.positivity.failure] "{e.toMessageData}"
182-
let sα ← synthInstanceQ q(Semifield $α)
183-
let oα ← synthInstanceQ q(LinearOrder $α)
184-
let iα ← synthInstanceQ q(IsStrictOrderedRing $α)
185-
orElse (← catchNone (ofNonneg q(le_of_lt $pa) sα oα iα))
186-
(ofNonzero q(ne_of_gt $pa) q(inferInstance))
187-
| .nonnegative pa =>
188-
ofNonneg pa (← synthInstanceQ (_ : Q(Type u)))
189-
(← synthInstanceQ (_ : Q(Type u))) (← synthInstanceQ (_ : Q(Prop)))
190-
| .nonzero pa => ofNonzero pa (← synthInstanceQ (_ : Q(Type u)))
191-
| .none => pure .none
170+
let _a ← synthInstanceQ q(GroupWithZero $α)
171+
assumeInstancesCommute
172+
pure (.nonzero q(zpow_ne_zero $b $pa))
173+
match ra with
174+
| .positive pa =>
175+
try
176+
let _a ← synthInstanceQ q(Semifield $α)
177+
let _a ← synthInstanceQ q(LinearOrder $α)
178+
let _a ← synthInstanceQ q(IsStrictOrderedRing $α)
179+
assumeInstancesCommute
180+
haveI' : $e =Q $a ^ $b := ⟨⟩
181+
pure (.positive q(zpow_pos $pa $b))
182+
catch e : Exception =>
183+
trace[Tactic.positivity.failure] "{e.toMessageData}"
184+
let sα ← synthInstanceQ q(Semifield $α)
185+
let oα ← synthInstanceQ q(LinearOrder $α)
186+
let iα ← synthInstanceQ q(IsStrictOrderedRing $α)
187+
orElse (← catchNone (ofNonneg q(le_of_lt $pa) sα oα iα))
188+
(ofNonzero q(ne_of_gt $pa) q(inferInstance))
189+
| .nonnegative pa =>
190+
ofNonneg pa (← synthInstanceQ (_ : Q(Type u)))
191+
(← synthInstanceQ (_ : Q(Type u))) (← synthInstanceQ (_ : Q(Prop)))
192+
| .nonzero pa => ofNonzero pa (← synthInstanceQ (_ : Q(Type u)))
193+
| .none => pure .none
192194

193195
end Mathlib.Meta.Positivity

0 commit comments

Comments
 (0)