The positive natural numbers #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
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.
Instances for pnat
- pnat.linear_order
- pnat.has_one
- coe_pnat_nat
- pnat.has_repr
- pnat.inhabited
- pnat.has_well_founded
- nat.can_lift_pnat
- int.can_lift_pnat
- pnat.add_left_cancel_semigroup
- pnat.add_right_cancel_semigroup
- pnat.add_comm_semigroup
- pnat.linear_ordered_cancel_comm_monoid
- pnat.has_add
- pnat.has_mul
- pnat.distrib
- pnat.has_lt.lt.is_well_order
- pnat.has_le.le.covariant_class
- pnat.has_lt.lt.covariant_class
- pnat.has_le.le.contravariant_class
- pnat.has_lt.lt.contravariant_class
- pnat.order_bot
- pnat.has_sub
- pnat.encodable
- pnat.countable
- denumerable.pnat
- pnat.locally_finite_order
Equations
- pnat.has_one = {one := ⟨1, nat.zero_lt_one⟩}
Equations
- coe_pnat_nat = {coe := subtype.val (λ (n : ℕ), 0 < n)}
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.inhabited = {default := 1}
Equations
- pnat.has_well_founded = {r := has_lt.lt (preorder.to_has_lt ℕ+), wf := pnat.has_well_founded._proof_1}
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
- k.mod_div_aux (r + 1) q = (⟨r + 1, _⟩, q)
- k.mod_div_aux 0 q = (k, q.pred)
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
.
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
.