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.
Equations
- instPNatLinearOrder = Subtype.instLinearOrder fun (n : ℕ) => 0 < n
Equations
- instOfNatPNatOfNeZeroNat n = { ofNat := ⟨n, ⋯⟩ }
Equations
- PNat.instWellFoundedRelation = measure fun (a : ℕ+) => ↑a
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
.
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
.
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
- m.div k = (m.modDiv k).snd
Instances For
If h : k | m
, then k * (div_exact m k) = m
. Note that this is not equal to m / k
.
Equations
- m.divExact k = ⟨(m.div k).succ, ⋯⟩