The positive natural numbers #
This file contains the definitions, and basic results.
Most algebraic facts are deferred to Data.PNat.Basic, as they need more imports.
ℕ+ is the type of positive natural numbers. It is defined as a subtype,
and the VM representation of ℕ+ is the same as ℕ because the proof
is not stored.
Equations
- «termℕ+» = Lean.ParserDescr.node `termℕ+ 1024 (Lean.ParserDescr.symbol "ℕ+")
Instances For
Equations
- instOnePNat = { one := { val := 1, property := Nat.zero_lt_one } }
Equations
- instReprPNat = { reprPrec := fun n n' => reprPrec (↑n) n' }
Convert a natural number to a positive natural number. The
positivity assumption is inferred by dec_trivial.
Equations
- Nat.toPNat n = { val := n, property := h }
Instances For
Write a successor as an element of ℕ+.
Equations
- Nat.succPNat n = { val := Nat.succ n, property := (_ : 0 < Nat.succ n) }
Instances For
Convert a natural number to a PNat. n+1 is mapped to itself,
and 0 becomes 1.
Equations
- Nat.toPNat' n = Nat.succPNat (Nat.pred n)
Instances For
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.
Equations
- PNat.instInhabitedPNat = { default := 1 }
Equations
- PNat.instWellFoundedRelationPNat = measure fun a => ↑a
Strong induction on ℕ+.
Equations
- PNat.strongInductionOn n x = x n fun a x => PNat.strongInductionOn a x
Instances For
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.
Equations
Instances For
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.
Equations
- PNat.modDiv m k = PNat.modDivAux k (↑m % ↑k) (↑m / ↑k)
Instances For
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.
Equations
- PNat.div m k = (PNat.modDiv m k).snd