Skip to content

Commit aeefd81

Browse files
committed
refactor: Let positivity handle ENNReal-valued ofNat (#17212)
The meta code was looking for `StrictOrderedSemiring` instead of the weaker `OrderedSemiring` + `Nontrivial`, which is enough. From LeanAPAP
1 parent 7a0b691 commit aeefd81

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Mathlib/Tactic/Positivity/Core.lean

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ variable {A : Type*} {e : A}
122122
lemma lt_of_le_of_ne' {a b : A} [PartialOrder A] :
123123
(a : A) ≤ b → b ≠ a → a < b := fun h₁ h₂ => lt_of_le_of_ne h₁ h₂.symm
124124

125-
lemma pos_of_isNat {n : ℕ} [StrictOrderedSemiring A]
125+
lemma pos_of_isNat {n : ℕ} [OrderedSemiring A] [Nontrivial A]
126126
(h : NormNum.IsNat e n) (w : Nat.ble 1 n = true) : 0 < (e : A) := by
127127
rw [NormNum.IsNat.to_eq h rfl]
128128
apply Nat.cast_pos.2
@@ -184,11 +184,12 @@ def normNumPositivity (e : Q($α)) : MetaM (Strictness zα pα e) := catchNone d
184184
| .isBool .. => failure
185185
| .isNat _ lit p =>
186186
if 0 < lit.natLit! then
187-
let _a ← synthInstanceQ q(StrictOrderedSemiring $α)
187+
let _a ← synthInstanceQ q(OrderedSemiring $α)
188+
let _a ← synthInstanceQ q(Nontrivial $α)
188189
assumeInstancesCommute
189190
have p : Q(NormNum.IsNat $e $lit) := p
190191
haveI' p' : Nat.ble 1 $lit =Q true := ⟨⟩
191-
pure (.positive q(@pos_of_isNat $α _ _ _ $p $p'))
192+
pure (.positive q(@pos_of_isNat $α _ _ _ _ $p $p'))
192193
else
193194
let _a ← synthInstanceQ q(OrderedSemiring $α)
194195
assumeInstancesCommute

test/positivity.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ example : 0 ≤ 3 := by positivity
2323

2424
example : 0 < 3 := by positivity
2525

26+
example : (0 : ℝ≥0∞) < 1 := by positivity
27+
example : (0 : ℝ≥0∞) < 2 := by positivity
28+
2629
/- ## Goals working directly from a hypothesis -/
2730
-- set_option trace.Meta.debug true
2831
-- sudo set_option trace.Tactic.positivity true

0 commit comments

Comments
 (0)