@@ -733,15 +733,23 @@ lemma zpow_zero_pos {α : Type*} [Semifield α] [PartialOrder α] [IsStrictOrder
733733
734734/-- The `positivity` extension which identifies expressions of the form `a / b`,
735735such that `positivity` successfully recognises both `a` and `b`. -/
736- @ [positivity _ / _] meta def evalDiv : PositivityExt where eval {u α} zα pα e := do
736+ @ [positivity _ / _] meta def evalDiv : PositivityExt where eval {u α} zα pα? e := do
737737 let .app (.app (f : Q($α → $α → $α)) (a : Q($α))) (b : Q($α)) ← withReducible (whnf e)
738738 | throwError "not /"
739739 let _e_eq : $e =Q $f $a $b := ⟨⟩
740+ trace[Tactic.positivity.zeroness] "evalDiv: { a} divided by { b} "
741+ let _a ← synthInstanceQ q(Semifield $α)
742+ let ⟨_f_eq⟩ ← withDefault <| withNewMCtxDepth <| assertDefEqQ q($f) q(HDiv.hDiv)
743+ let some pα := pα? |
744+ match ← core zα pα? a, ← core zα pα? b with
745+ | .nonzero pa, .nonzero pb =>
746+ let _a ← synthInstanceQ q(GroupWithZero $α)
747+ assumeInstancesCommute
748+ pure (.nonzero q(div_ne_zero $pa $pb))
749+ | _, _ => pure .none
740750 let _a ← synthInstanceQ q(GroupWithZero $α)
741- let _a ← synthInstanceQ q(PartialOrder $α)
742751 let _a ← synthInstanceQ q(PosMulReflectLT $α)
743752 assumeInstancesCommute
744- let ⟨_f_eq⟩ ← withDefault <| withNewMCtxDepth <| assertDefEqQ q($f) q(HDiv.hDiv)
745753 let ra ← core zα pα a; let rb ← core zα pα b
746754 match ra, rb with
747755 | .positive pa, .positive pb => pure (.positive q(div_pos $pa $pb))
@@ -756,25 +764,38 @@ such that `positivity` successfully recognises both `a` and `b`. -/
756764/-- The `positivity` extension which identifies expressions of the form `a⁻¹`,
757765such that `positivity` successfully recognises `a`. -/
758766@ [positivity _⁻¹]
759- meta def evalInv : PositivityExt where eval {u α} zα pα e := do
767+ meta def evalInv : PositivityExt where eval {u α} zα pα? e := do
760768 let .app (f : Q($α → $α)) (a : Q($α)) ← withReducible (whnf e) | throwError "not ⁻¹"
761769 let _e_eq : $e =Q $f $a := ⟨⟩
770+ let _a ← synthInstanceQ q(Semifield $α)
771+ let ⟨_f_eq⟩ ← withDefault <| withNewMCtxDepth <| assertDefEqQ q($f) q(Inv.inv)
772+ let some _ := pα? |
773+ match ← core zα pα? a with
774+ | .nonzero pa =>
775+ let _a ← synthInstanceQ q(GroupWithZero $α)
776+ assumeInstancesCommute
777+ pure (.nonzero q(inv_ne_zero $pa))
778+ | _ => pure .none
762779 let _a ← synthInstanceQ q(GroupWithZero $α)
763780 let _a ← synthInstanceQ q(PartialOrder $α)
764781 let _a ← synthInstanceQ q(PosMulReflectLT $α)
765782 assumeInstancesCommute
766- let ⟨_f_eq⟩ ← withDefault <| withNewMCtxDepth <| assertDefEqQ q($f) q(Inv.inv)
767- let ra ← core zα pα a
783+ let ra ← core zα pα? a
768784 match ra with
769- | .positive pa => pure (.positive q(inv_pos_of_pos $pa))
770- | .nonnegative pa => pure (.nonnegative q(inv_nonneg_of_nonneg $pa))
785+ | .positive pa =>
786+ assumeInstancesCommute
787+ pure (.positive q(inv_pos_of_pos $pa))
788+ | .nonnegative pa =>
789+ assumeInstancesCommute
790+ pure (.nonnegative q(inv_nonneg_of_nonneg $pa))
771791 | .nonzero pa => pure (.nonzero q(inv_ne_zero $pa))
772792 | .none => pure .none
773793
774794/-- The `positivity` extension which identifies expressions of the form `a ^ (0:ℤ)`. -/
775795@ [positivity _ ^ (0 : ℤ), Pow.pow _ (0 : ℤ)]
776- meta def evalPowZeroInt : PositivityExt where eval {u α} _zα _pα e := do
796+ meta def evalPowZeroInt : PositivityExt where eval {u α} _zα pα? e := do
777797 let .app (.app _ (a : Q($α))) _ ← withReducible (whnf e) | throwError "not ^"
798+ let some _ := pα? | pure .none
778799 let _a ← synthInstanceQ q(Semifield $α)
779800 let _a ← synthInstanceQ q(LinearOrder $α)
780801 let _a ← synthInstanceQ q(IsStrictOrderedRing $α)
0 commit comments