The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V02. Numbers

Mathlib.Data.PNat.Defs

41 declarations and 2 deprecated aliases. Mathlib docs · Source

instance instLinearOrderPNat E0 #

LinearOrder ℕ+

instance instOnePNat E0 #

One ℕ+

instance instOfNatPNatOfNeZeroNat E0 #

(n : ℕ) → [NeZero n] → OfNat ℕ+ n

theorem PNat.mk_coe E0 #

∀ (n : ℕ) (h : 0 < n), ↑⟨n, h⟩ = n

def PNat.natPred E1 #

ℕ+ → ℕ

Predecessor of a ℕ+, as a ℕ.

theorem PNat.natPred_eq_pred E0 #

∀ {n : ℕ} (h : 0 < n), PNat.natPred ⟨n, h⟩ = n.pred

def Nat.toPNat E1 #

(n : ℕ) → autoParam (0 < n) Nat.toPNat._auto_1 → ℕ+

Convert a natural number to a positive natural number. The positivity assumption is inferred by dec_trivial.

def Nat.succPNat E1 #

ℕ → ℕ+

Write a successor as an element of ℕ+.

theorem Nat.succPNat_coe E0 #

∀ (n : ℕ), ↑n.succPNat = n.succ

theorem Nat.natPred_succPNat E0 #

∀ (n : ℕ), n.succPNat.natPred = n

theorem PNat.succPNat_natPred E0 #

∀ (n : ℕ+), n.natPred.succPNat = n

def Nat.toPNat' E1 #

ℕ → ℕ+

Convert a natural number to a PNat. n+1 is mapped to itself, and 0 becomes 1.

theorem Nat.toPNat'_zero E0 #

Nat.toPNat' 0 = 1

theorem Nat.toPNat'_coe E0 #

∀ (n : ℕ), ↑n.toPNat' = if 0 < n then n else 1

theorem PNat.mk_le_mk E0 #

∀ (n k : ℕ) (hn : 0 < n) (hk : 0 < k), ⟨n, hn⟩ ≤ ⟨k, hk⟩ ↔ n ≤ k

We now define a long list of structures on ℕ+ induced by similar structures on ℕ. Most of these behave in a completely obvious way, but there are a few things to be said about subtraction, division and powers.

theorem PNat.mk_lt_mk E0 #

∀ (n k : ℕ) (hn : 0 < n) (hk : 0 < k), ⟨n, hn⟩ < ⟨k, hk⟩ ↔ n < k

theorem PNat.coe_le_coe E0 #

∀ (n k : ℕ+), ↑n ≤ ↑k ↔ n ≤ k

theorem PNat.coe_lt_coe E0 #

∀ (n k : ℕ+), ↑n < ↑k ↔ n < k

theorem PNat.pos E0 #

∀ (n : ℕ+), 0 < ↑n

theorem PNat.eq E1 #

∀ {m n : ℕ+}, ↑m = ↑n → m = n

theorem PNat.coe_injective E0 #

Function.Injective PNat.val

theorem PNat.ne_zero E0 #

∀ (n : ℕ+), ↑n ≠ 0

instance NeZero.pnat E0 #

∀ {a : ℕ+}, NeZero ↑a

theorem PNat.toPNat'_coe E0 #

∀ {n : ℕ}, 0 < n → ↑n.toPNat' = n

theorem PNat.coe_toPNat' E0 #

∀ (n : ℕ+), (↑n).toPNat' = n

instance PNat.instInhabited E0 #

Inhabited ℕ+

theorem PNat.mk_one E0 #

∀ {h : 0 < 1}, ⟨1, h⟩ = 1

theorem PNat.one_coe E0 #

↑1 = 1

theorem PNat.coe_eq_one_iff E0 #

∀ {m : ℕ+}, ↑m = 1 ↔ m = 1

instance PNat.instWellFoundedRelation E0 #

WellFoundedRelation ℕ+

def PNat.strongInductionOn E1 #

{p : ℕ+ → Sort u_1} → (n : ℕ+) → ((k : ℕ+) → ((m : ℕ+) → m < k → p m) → p k) → p n

Strong induction on ℕ+.

def PNat.modDivAux E0 #

ℕ+ → ℕ → ℕ → ℕ+ × ℕ

We define m % k and m / k in the same way as for ℕ except that when m = n * k we take m % k = k and m / k = n - 1. This ensures that m % k is always positive and m = (m % k) + k * (m / k) in all cases. Later we define a function div_exact which gives the usual m / k in the case where k divides m.

def PNat.modDiv E1 #

ℕ+ → ℕ+ → ℕ+ × ℕ

mod_div m k = (m % k, m / k). We define m % k and m / k in the same way as for ℕ except that when m = n * k we take m % k = k and m / k = n - 1. This ensures that m % k is always positive and m = (m % k) + k * (m / k) in all cases. Later we define a function div_exact which gives the usual m / k in the case where k divides m.

def PNat.mod E1 #

ℕ+ → ℕ+ → ℕ+

We define m % k in the same way as for ℕ except that when m = n * k we take m % k = k This ensures that m % k is always positive.

def PNat.div E1 #

ℕ+ → ℕ+ → ℕ

We define m / k in the same way as for ℕ except that when m = n * k we take m / k = n - 1. This ensures that m = (m % k) + k * (m / k) in all cases. Later we define a function div_exact which gives the usual m / k in the case where k divides m.

theorem PNat.mod_coe E0 #

∀ (m k : ℕ+), ↑(m.mod k) = if ↑m % ↑k = 0 then ↑k else ↑m % ↑k

theorem PNat.div_coe E0 #

∀ (m k : ℕ+), m.div k = if ↑m % ↑k = 0 then (↑m / ↑k).pred else ↑m / ↑k

def PNat.divExact E1 #

ℕ+ → ℕ+ → ℕ+

If h : k | m, then k * (div_exact m k) = m. Note that this is not equal to m / k.

instance Nat.canLiftPNat E0 #

CanLift ℕ ℕ+ PNat.val fun n ↦ 0 < n

instance Int.canLiftPNat E0 #

CanLift ℤ ℕ+ (fun x ↦ ↑↑x) fun x ↦ 0 < x

def PNat.recToPNat E1 #

{C : ℕ+ → Sort u_1} → ((n : ℕ) → 0 < n → C n.toPNat') → (t : ℕ+) → C t

A Subtype.mk-free eliminator for ℕ+, exposing the underlying natural and its positivity. See NNReal.recToNNReal for why basify needs this shape.

Deprecated aliases

NameNew nameSince
PNat.not_lt_one2026-05-07
PNat.one_le2026-05-07