Skip to content

Commit f136a3c

Browse files
committed
feat(Mathlib/Tactic/Positivity/Basic): positivity extension for ℕ+(PNat) (#13229)
The positivity extention to prove the positivity of `ℕ+`(`PNat`): ```lean example (n : ℕ+) : 0 < (↑n : ℕ) := by positivity ```
1 parent 03f9995 commit f136a3c

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Mathlib/Tactic/Positivity/Basic.lean

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Mathlib.Data.NNRat.Defs
1010
import Mathlib.Algebra.Order.Ring.Int
1111
import Mathlib.Data.Nat.Factorial.Basic
1212
import Mathlib.Data.Rat.Order
13+
import Mathlib.Data.PNat.Defs
1314
import Mathlib.Tactic.Positivity.Core
1415
import Qq
1516

@@ -404,6 +405,15 @@ def evalNatSucc : PositivityExt where eval {u α} _zα _pα e := do
404405
pure (.positive q(Nat.succ_pos $a))
405406
| _, _, _ => throwError "not Nat.succ"
406407

408+
/-- Extension for `PNat.val`. -/
409+
@[positivity PNat.val _]
410+
def evalPNatVal : PositivityExt where eval {u α} _zα _pα e := do
411+
match u, α, e with
412+
| 0, ~q(ℕ), ~q(PNat.val $a) =>
413+
assertInstancesCommute
414+
pure (.positive q(PNat.pos $a))
415+
| _, _, _ => throwError "not PNat.val"
416+
407417
/-- Extension for `Nat.factorial`. -/
408418
@[positivity Nat.factorial _]
409419
def evalFactorial : PositivityExt where eval {u α} _ _ e := do

scripts/noshake.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@
227227
["Mathlib.Algebra.GroupPower.Order",
228228
"Mathlib.Algebra.Order.Group.PosPart",
229229
"Mathlib.Data.Int.CharZero",
230-
"Mathlib.Data.Nat.Factorial.Basic"],
230+
"Mathlib.Data.Nat.Factorial.Basic",
231+
"Mathlib.Data.PNat.Defs"],
231232
"Mathlib.Tactic.NormNum.Ineq":
232233
["Mathlib.Algebra.Order.Field.Defs", "Mathlib.Algebra.Order.Monoid.WithTop"],
233234
"Mathlib.Tactic.NormNum.BigOperators": ["Mathlib.Data.List.FinRange"],

test/positivity.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ example : 0 ≤ max (-3 : ℤ) 5 := by positivity
282282
-- [OrderedSMul α β] {a : α} (ha : 0 < a) {b : β} (hb : 0 < b) : 0 ≤ a • b := by positivity
283283

284284
example (n : ℕ) : 0 < n.succ := by positivity
285+
example (n : ℕ+) : 0 < (↑n : ℕ) := by positivity
285286
example (n : ℕ) : 0 < n ! := by positivity
286287
example (n k : ℕ) : 0 < (n+1).ascFactorial k := by positivity
287288

0 commit comments

Comments
 (0)