Module docstring
{"# 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.
"}
{"# 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.
"}
instOnePNat
instance
: One ℕ+
instance : One ℕ+ :=
⟨⟨1, Nat.zero_lt_one⟩⟩
instOfNatPNatOfNeZeroNat
instance
(n : ℕ) [NeZero n] : OfNat ℕ+ n
PNat.mk_coe
theorem
(n h) : (PNat.val (⟨n, h⟩ : ℕ+) : ℕ) = n
PNat.natPred
definition
(i : ℕ+) : ℕ
PNat.natPred_eq_pred
theorem
{n : ℕ} (h : 0 < n) : natPred (⟨n, h⟩ : ℕ+) = n.pred
Nat.succPNat
definition
(n : ℕ) : ℕ+
/-- Write a successor as an element of `ℕ+`. -/
def succPNat (n : ℕ) : ℕ+ :=
⟨succ n, succ_pos n⟩
Nat.succPNat_coe
theorem
(n : ℕ) : (succPNat n : ℕ) = succ n
Nat.natPred_succPNat
theorem
(n : ℕ) : n.succPNat.natPred = n
@[simp]
theorem natPred_succPNat (n : ℕ) : n.succPNat.natPred = n :=
rfl
PNat.succPNat_natPred
theorem
(n : ℕ+) : n.natPred.succPNat = n
@[simp]
theorem _root_.PNat.succPNat_natPred (n : ℕ+) : n.natPred.succPNat = n :=
Subtype.eq <| succ_pred_eq_of_pos n.2
Nat.toPNat'
definition
(n : ℕ) : ℕ+
Nat.toPNat'_zero
theorem
: Nat.toPNat' 0 = 1
@[simp]
theorem toPNat'_zero : Nat.toPNat' 0 = 1 := rfl
Nat.toPNat'_coe
theorem
: ∀ n : ℕ, (toPNat' n : ℕ) = ite (0 < n) n 1
PNat.mk_le_mk
theorem
(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 mk_le_mk (n k : ℕ) (hn : 0 < n) (hk : 0 < k) : (⟨n, hn⟩ : ℕ+) ≤ ⟨k, hk⟩ ↔ n ≤ k := by simp
PNat.mk_lt_mk
theorem
(n k : ℕ) (hn : 0 < n) (hk : 0 < k) : (⟨n, hn⟩ : ℕ+) < ⟨k, hk⟩ ↔ n < k
theorem mk_lt_mk (n k : ℕ) (hn : 0 < n) (hk : 0 < k) : (⟨n, hn⟩ : ℕ+) < ⟨k, hk⟩ ↔ n < k := by simp
PNat.coe_le_coe
theorem
(n k : ℕ+) : (n : ℕ) ≤ k ↔ n ≤ k
@[simp, norm_cast]
theorem coe_le_coe (n k : ℕ+) : (n : ℕ) ≤ k ↔ n ≤ k :=
Iff.rfl
PNat.coe_lt_coe
theorem
(n k : ℕ+) : (n : ℕ) < k ↔ n < k
@[simp, norm_cast]
theorem coe_lt_coe (n k : ℕ+) : (n : ℕ) < k ↔ n < k :=
Iff.rfl
PNat.pos
theorem
(n : ℕ+) : 0 < (n : ℕ)
PNat.eq
theorem
{m n : ℕ+} : (m : ℕ) = n → m = n
theorem eq {m n : ℕ+} : (m : ℕ) = n → m = n :=
Subtype.eq
PNat.coe_injective
theorem
: Function.Injective PNat.val
theorem coe_injective : Function.Injective PNat.val :=
Subtype.coe_injective
PNat.ne_zero
theorem
(n : ℕ+) : (n : ℕ) ≠ 0
@[simp]
theorem ne_zero (n : ℕ+) : (n : ℕ) ≠ 0 :=
n.2.ne'
NeZero.pnat
instance
{a : ℕ+} : NeZero (a : ℕ)
instance _root_.NeZero.pnat {a : ℕ+} : NeZero (a : ℕ) :=
⟨a.ne_zero⟩
PNat.toPNat'_coe
theorem
{n : ℕ} : 0 < n → (n.toPNat' : ℕ) = n
theorem toPNat'_coe {n : ℕ} : 0 < n → (n.toPNat' : ℕ) = n :=
succ_pred_eq_of_pos
PNat.coe_toPNat'
theorem
(n : ℕ+) : (n : ℕ).toPNat' = n
@[simp]
theorem coe_toPNat' (n : ℕ+) : (n : ℕ).toPNat' = n :=
eq (toPNat'_coe n.pos)
PNat.one_le
theorem
(n : ℕ+) : (1 : ℕ+) ≤ n
PNat.not_lt_one
theorem
(n : ℕ+) : ¬n < 1
@[simp]
theorem not_lt_one (n : ℕ+) : ¬n < 1 :=
not_lt_of_le n.one_le
PNat.instInhabited
instance
: Inhabited ℕ+
PNat.mk_one
theorem
{h} : (⟨1, h⟩ : ℕ+) = (1 : ℕ+)
PNat.one_coe
theorem
: ((1 : ℕ+) : ℕ) = 1
PNat.coe_eq_one_iff
theorem
{m : ℕ+} : (m : ℕ) = 1 ↔ m = 1
@[simp, norm_cast]
theorem coe_eq_one_iff {m : ℕ+} : (m : ℕ) = 1 ↔ m = 1 :=
Subtype.coe_injective.eq_iff' one_coe
PNat.instWellFoundedRelation
instance
: WellFoundedRelation ℕ+
PNat.strongInductionOn
definition
{p : ℕ+ → Sort*} (n : ℕ+) : (∀ k, (∀ m, m < k → p m) → p k) → p n
/-- Strong induction on `ℕ+`. -/
def strongInductionOn {p : ℕ+ → Sort*} (n : ℕ+) : (∀ k, (∀ m, m < k → p m) → p k) → p n
| IH => IH _ fun a _ => strongInductionOn a IH
termination_by n.1
PNat.modDivAux
definition
: ℕ+ → ℕ → ℕ → ℕ+ × ℕ
/-- 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 modDivAux : ℕ+ → ℕ → ℕ → ℕ+ℕ+ × ℕ
| k, 0, q => ⟨k, q.pred⟩
| _, r + 1, q => ⟨⟨r + 1, Nat.succ_pos r⟩, q⟩
PNat.modDiv
definition
(m k : ℕ+) : ℕ+ × ℕ
/-- `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 modDiv (m k : ℕ+) : ℕ+ℕ+ × ℕ :=
modDivAux k ((m : ℕ) % (k : ℕ)) ((m : ℕ) / (k : ℕ))
PNat.mod
definition
(m k : ℕ+) : ℕ+
PNat.div
definition
(m k : ℕ+) : ℕ
/-- 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`.
-/
def div (m k : ℕ+) : ℕ :=
(modDiv m k).2
PNat.mod_coe
theorem
(m k : ℕ+) : (mod m k : ℕ) = ite ((m : ℕ) % (k : ℕ) = 0) (k : ℕ) ((m : ℕ) % (k : ℕ))
PNat.div_coe
theorem
(m k : ℕ+) : (div m k : ℕ) = ite ((m : ℕ) % (k : ℕ) = 0) ((m : ℕ) / (k : ℕ)).pred ((m : ℕ) / (k : ℕ))
PNat.divExact
definition
(m k : ℕ+) : ℕ+
/-- If `h : k | m`, then `k * (div_exact m k) = m`. Note that this is not equal to `m / k`. -/
def divExact (m k : ℕ+) : ℕ+ :=
⟨(div m k).succ, Nat.succ_pos _⟩
Nat.canLiftPNat
instance
: CanLift ℕ ℕ+ (↑) (fun n => 0 < n)
instance Nat.canLiftPNat : CanLift ℕ ℕ+ (↑) (fun n => 0 < n) :=
⟨fun n hn => ⟨Nat.toPNat' n, PNat.toPNat'_coe hn⟩⟩
Int.canLiftPNat
instance
: CanLift ℤ ℕ+ (↑) ((0 < ·))
instance Int.canLiftPNat : CanLift ℤ ℕ+ (↑) ((0 < ·)) :=
⟨fun n hn =>
⟨Nat.toPNat' (Int.natAbs n), by
rw [Nat.toPNat'_coe, if_pos (Int.natAbs_pos.2 hn.ne'),
Int.natAbs_of_nonneg hn.le]⟩⟩