doc-next-gen

Mathlib.Data.PNat.Basic

Module docstring

{"# The positive natural numbers

This file develops the type ℕ+ or PNat, the subtype of natural numbers that are positive. It is defined in Data.PNat.Defs, but most of the development is deferred to here so that Data.PNat.Defs can have very few imports. "}

PNat.instCommMonoid instance
: CommMonoid ℕ+
Full source
instance instCommMonoid : CommMonoid ℕ+ := Positive.commMonoid
Positive Natural Numbers as a Commutative Monoid
Informal description
The positive natural numbers $\mathbb{N}^+$ form a commutative monoid under multiplication.
PNat.instWellFoundedLT instance
: WellFoundedLT ℕ+
Full source
instance instWellFoundedLT : WellFoundedLT ℕ+ := WellFoundedRelation.isWellFounded
Well-foundedness of the Order on Positive Natural Numbers
Informal description
The positive natural numbers $\mathbb{N}^+$ are well-founded with respect to the standard order relation $<$.
PNat.one_add_natPred theorem
(n : ℕ+) : 1 + n.natPred = n
Full source
@[simp]
theorem one_add_natPred (n : ℕ+) : 1 + n.natPred = n := by
  rw [natPred, add_tsub_cancel_iff_le.mpr <| show 1 ≤ (n : ) from n.2]
Predecessor Identity for Positive Natural Numbers: $1 + (n - 1) = n$
Informal description
For any positive natural number $n$, the sum of $1$ and the predecessor of $n$ (as a natural number) equals $n$, i.e., $1 + (n - 1) = n$.
PNat.natPred_add_one theorem
(n : ℕ+) : n.natPred + 1 = n
Full source
@[simp]
theorem natPred_add_one (n : ℕ+) : n.natPred + 1 = n :=
  (add_comm _ _).trans n.one_add_natPred
Predecessor Identity for Positive Natural Numbers: $(n - 1) + 1 = n$
Informal description
For any positive natural number $n$, the sum of the predecessor of $n$ (as a natural number) and $1$ equals $n$, i.e., $(n - 1) + 1 = n$.
PNat.natPred_strictMono theorem
: StrictMono natPred
Full source
@[mono]
theorem natPred_strictMono : StrictMono natPred := fun m _ h => Nat.pred_lt_pred m.2.ne' h
Strict Monotonicity of the Predecessor Function on Positive Natural Numbers
Informal description
The predecessor function $\operatorname{natPred} : \mathbb{N}^+ \to \mathbb{N}$, defined by $\operatorname{natPred}(n) = n - 1$, is strictly monotone. That is, for any positive natural numbers $m$ and $n$, if $m < n$ then $\operatorname{natPred}(m) < \operatorname{natPred}(n)$.
PNat.natPred_monotone theorem
: Monotone natPred
Full source
@[mono]
theorem natPred_monotone : Monotone natPred :=
  natPred_strictMono.monotone
Monotonicity of the Predecessor Function on Positive Natural Numbers
Informal description
The predecessor function $\operatorname{natPred} : \mathbb{N}^+ \to \mathbb{N}$, defined by $\operatorname{natPred}(n) = n - 1$, is monotone. That is, for any positive natural numbers $m$ and $n$, if $m \leq n$ then $\operatorname{natPred}(m) \leq \operatorname{natPred}(n)$.
PNat.natPred_injective theorem
: Function.Injective natPred
Full source
theorem natPred_injective : Function.Injective natPred :=
  natPred_strictMono.injective
Injectivity of the Predecessor Function on Positive Natural Numbers
Informal description
The predecessor function $\operatorname{natPred} : \mathbb{N}^+ \to \mathbb{N}$, defined by $\operatorname{natPred}(n) = n - 1$, is injective. That is, for any positive natural numbers $m$ and $n$, if $\operatorname{natPred}(m) = \operatorname{natPred}(n)$, then $m = n$.
PNat.natPred_lt_natPred theorem
{m n : ℕ+} : m.natPred < n.natPred ↔ m < n
Full source
@[simp]
theorem natPred_lt_natPred {m n : ℕ+} : m.natPred < n.natPred ↔ m < n :=
  natPred_strictMono.lt_iff_lt
Predecessor Strictly Preserves Order in Positive Natural Numbers
Informal description
For any two positive natural numbers $m$ and $n$, the predecessor of $m$ is strictly less than the predecessor of $n$ if and only if $m$ is strictly less than $n$.
PNat.natPred_le_natPred theorem
{m n : ℕ+} : m.natPred ≤ n.natPred ↔ m ≤ n
Full source
@[simp]
theorem natPred_le_natPred {m n : ℕ+} : m.natPred ≤ n.natPred ↔ m ≤ n :=
  natPred_strictMono.le_iff_le
Predecessor Order Preserves Inequality in Positive Natural Numbers
Informal description
For any two positive natural numbers $m$ and $n$, the predecessor of $m$ is less than or equal to the predecessor of $n$ if and only if $m$ is less than or equal to $n$.
PNat.natPred_inj theorem
{m n : ℕ+} : m.natPred = n.natPred ↔ m = n
Full source
@[simp]
theorem natPred_inj {m n : ℕ+} : m.natPred = n.natPred ↔ m = n :=
  natPred_injective.eq_iff
Injectivity of Predecessor Function for Positive Natural Numbers
Informal description
For any two positive natural numbers $m$ and $n$, the equality of their predecessors as natural numbers, $m.\mathrm{natPred} = n.\mathrm{natPred}$, holds if and only if $m = n$.
PNat.val_ofNat theorem
(n : ℕ) [NeZero n] : ((ofNat(n) : ℕ+) : ℕ) = OfNat.ofNat n
Full source
@[simp, norm_cast]
lemma val_ofNat (n : ) [NeZero n] :
    ((ofNat(n) : ℕ+) : ) = OfNat.ofNat n :=
  rfl
Canonical Embedding of Nonzero Natural Numbers Preserves Value
Informal description
For any nonzero natural number $n$, the underlying natural number value of the positive natural number constructed from $n$ via `ofNat` is equal to $n$ itself.
PNat.mk_ofNat theorem
(n : ℕ) (h : 0 < n) : @Eq ℕ+ (⟨ofNat(n), h⟩ : ℕ+) (haveI : NeZero n := ⟨h.ne'⟩; OfNat.ofNat n)
Full source
@[simp]
lemma mk_ofNat (n : ) (h : 0 < n) :
    @Eq ℕ+ (⟨ofNat(n), h⟩ : ℕ+) (haveI : NeZero n := ⟨h.ne'⟩; OfNat.ofNat n) :=
  rfl
Equality of Constructed and Canonical Positive Natural Numbers
Informal description
For any natural number $n$ with $0 < n$, the positive natural number constructed as $\langle n, h\rangle$ (where $h$ is the proof that $0 < n$) is equal to the canonical positive natural number obtained by interpreting $n$ as a positive natural number via the `OfNat` instance.
Nat.succPNat_strictMono theorem
: StrictMono succPNat
Full source
@[mono]
theorem succPNat_strictMono : StrictMono succPNat := fun _ _ => Nat.succ_lt_succ
Strict Monotonicity of Successor Function on Positive Natural Numbers
Informal description
The function `succPNat : ℕ → ℕ+` that maps a natural number to its successor (as a positive natural number) is strictly monotone. That is, for any natural numbers $m$ and $n$, if $m < n$ then $(m + 1) < (n + 1)$ as positive natural numbers.
Nat.succPNat_mono theorem
: Monotone succPNat
Full source
@[mono]
theorem succPNat_mono : Monotone succPNat :=
  succPNat_strictMono.monotone
Monotonicity of Successor Function on Positive Natural Numbers
Informal description
The function that maps a natural number $n$ to its successor $n + 1$ as a positive natural number is monotone. That is, for any natural numbers $m$ and $n$, if $m \leq n$ then $(m + 1) \leq (n + 1)$ as positive natural numbers.
Nat.succPNat_lt_succPNat theorem
{m n : ℕ} : m.succPNat < n.succPNat ↔ m < n
Full source
@[simp]
theorem succPNat_lt_succPNat {m n : } : m.succPNat < n.succPNat ↔ m < n :=
  succPNat_strictMono.lt_iff_lt
Order Preservation of Successor Function on Positive Natural Numbers: $m + 1 < n + 1 \leftrightarrow m < n$
Informal description
For any natural numbers $m$ and $n$, the positive natural number $m + 1$ is strictly less than the positive natural number $n + 1$ if and only if $m < n$.
Nat.succPNat_le_succPNat theorem
{m n : ℕ} : m.succPNat ≤ n.succPNat ↔ m ≤ n
Full source
@[simp]
theorem succPNat_le_succPNat {m n : } : m.succPNat ≤ n.succPNat ↔ m ≤ n :=
  succPNat_strictMono.le_iff_le
Order Preservation of Successor Function on Positive Natural Numbers
Informal description
For any natural numbers $m$ and $n$, the successor of $m$ as a positive natural number is less than or equal to the successor of $n$ as a positive natural number if and only if $m \leq n$.
Nat.succPNat_injective theorem
: Function.Injective succPNat
Full source
theorem succPNat_injective : Function.Injective succPNat :=
  succPNat_strictMono.injective
Injectivity of Successor Function on Positive Natural Numbers
Informal description
The function that maps a natural number $n$ to its successor $n + 1$ as a positive natural number is injective. That is, for any natural numbers $m$ and $n$, if $m + 1 = n + 1$ as positive natural numbers, then $m = n$.
Nat.succPNat_inj theorem
{n m : ℕ} : succPNat n = succPNat m ↔ n = m
Full source
@[simp]
theorem succPNat_inj {n m : } : succPNatsuccPNat n = succPNat m ↔ n = m :=
  succPNat_injective.eq_iff
Injectivity of Successor Function on Positive Natural Numbers: $(n + 1 : \mathbb{N}^+) = (m + 1 : \mathbb{N}^+) \leftrightarrow n = m$
Informal description
For any natural numbers $n$ and $m$, the successor of $n$ as a positive natural number equals the successor of $m$ as a positive natural number if and only if $n = m$. That is, $(n + 1 : \mathbb{N}^+) = (m + 1 : \mathbb{N}^+) \leftrightarrow n = m$.
PNat.coe_inj theorem
{m n : ℕ+} : (m : ℕ) = n ↔ m = n
Full source
/-- 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.
-/
@[simp, norm_cast]
theorem coe_inj {m n : ℕ+} : (m : ℕ) = n ↔ m = n :=
  SetCoe.ext_iff
Injective Correspondence Between Positive Natural Numbers and Their Underlying Natural Numbers
Informal description
For any two positive natural numbers $m$ and $n$, the underlying natural numbers are equal if and only if $m$ and $n$ themselves are equal. That is, $(m : \mathbb{N}) = (n : \mathbb{N}) \leftrightarrow m = n$.
PNat.add_coe theorem
(m n : ℕ+) : ((m + n : ℕ+) : ℕ) = m + n
Full source
@[simp, norm_cast]
theorem add_coe (m n : ℕ+) : ((m + n : ℕ+) : ) = m + n :=
  rfl
Sum of Positive Natural Numbers Corresponds to Sum of Underlying Natural Numbers
Informal description
For any two positive natural numbers $m$ and $n$, the underlying natural number corresponding to their sum in $\mathbb{N}^+$ is equal to the sum of their underlying natural numbers. That is, $(m + n : \mathbb{N}^+) = m + n$ as natural numbers.
PNat.coeAddHom definition
: AddHom ℕ+ ℕ
Full source
/-- `coe` promoted to an `AddHom`, that is, a morphism which preserves addition. -/
@[simps]
def coeAddHom : AddHom ℕ+  where
  toFun := (↑)
  map_add' := add_coe
Additive homomorphism from positive natural numbers to natural numbers
Informal description
The additive homomorphism that maps a positive natural number \( n \) to its underlying natural number, preserving addition. That is, for any \( m, n \in \mathbb{N}^+ \), the image of their sum under this homomorphism is equal to the sum of their images.
PNat.addLeftMono instance
: AddLeftMono ℕ+
Full source
instance addLeftMono : AddLeftMono ℕ+ :=
  Positive.addLeftMono
Monotonicity of Addition on Positive Natural Numbers
Informal description
For any positive natural numbers $m, n \in \mathbb{N}^+$, the function $m \mapsto m + n$ is monotone. That is, if $m_1 \leq m_2$, then $m_1 + n \leq m_2 + n$.
PNat.addLeftStrictMono instance
: AddLeftStrictMono ℕ+
Full source
instance addLeftStrictMono : AddLeftStrictMono ℕ+ :=
  Positive.addLeftStrictMono
Strict Monotonicity of Addition on Positive Natural Numbers
Informal description
For any positive natural number $n$, the function $m \mapsto n + m$ is strictly increasing on $\mathbb{N}^+$.
PNat.addLeftReflectLE instance
: AddLeftReflectLE ℕ+
Full source
instance addLeftReflectLE : AddLeftReflectLE ℕ+ :=
  Positive.addLeftReflectLE
Addition reflects order in positive natural numbers
Informal description
For any positive natural numbers $a, b, c \in \mathbb{N}^+$, if $a + b \leq a + c$ then $b \leq c$.
PNat.addLeftReflectLT instance
: AddLeftReflectLT ℕ+
Full source
instance addLeftReflectLT : AddLeftReflectLT ℕ+ :=
  Positive.addLeftReflectLT
Addition Reflects Strict Order on Positive Natural Numbers
Informal description
For any positive natural numbers $a$, $b$, and $c$, if $a + c < b + c$, then $a < b$.
OrderIso.pnatIsoNat definition
: ℕ+ ≃o ℕ
Full source
/-- The order isomorphism between ℕ and ℕ+ given by `succ`. -/
@[simps! -fullyApplied apply]
def _root_.OrderIso.pnatIsoNat : ℕ+ℕ+ ≃o ℕ where
  toEquiv := Equiv.pnatEquivNat
  map_rel_iff' := natPred_le_natPred
Order isomorphism between positive and natural numbers via successor
Informal description
The order isomorphism between the positive natural numbers $\mathbb{N}^+$ and the natural numbers $\mathbb{N}$ is given by the successor function, where: - The forward map sends a positive natural number $n$ to its predecessor $n - 1$ (as a natural number) - The inverse map sends a natural number $n$ to its successor $n + 1$ (as a positive natural number) This bijection preserves the order relation, meaning for any $m, n \in \mathbb{N}^+$, we have $m \leq n$ if and only if $m-1 \leq n-1$.
OrderIso.pnatIsoNat_symm_apply theorem
: OrderIso.pnatIsoNat.symm = Nat.succPNat
Full source
@[simp]
theorem _root_.OrderIso.pnatIsoNat_symm_apply : OrderIso.pnatIsoNat.symm = Nat.succPNat :=
  rfl
Inverse of positive-natural isomorphism is successor function ($(\mathbb{N}^+ \simeq_o \mathbb{N})^{-1} = \text{succ}$)
Informal description
The inverse of the order isomorphism between positive natural numbers and natural numbers (via the predecessor map) is equal to the successor function on natural numbers (viewed as a map to positive natural numbers). That is, for the order isomorphism $\mathbb{N}^+ \simeq_o \mathbb{N}$ defined by $n \mapsto n-1$, its inverse is exactly the function $n \mapsto n+1$ (where $n \in \mathbb{N}$ and $n+1 \in \mathbb{N}^+$).
PNat.lt_add_one_iff theorem
: ∀ {a b : ℕ+}, a < b + 1 ↔ a ≤ b
Full source
theorem lt_add_one_iff : ∀ {a b : ℕ+}, a < b + 1 ↔ a ≤ b := Nat.lt_add_one_iff
Inequality relation between $a$ and $b+1$ in positive natural numbers
Informal description
For any positive natural numbers $a$ and $b$, the inequality $a < b + 1$ holds if and only if $a \leq b$.
PNat.add_one_le_iff theorem
: ∀ {a b : ℕ+}, a + 1 ≤ b ↔ a < b
Full source
theorem add_one_le_iff : ∀ {a b : ℕ+}, a + 1 ≤ b ↔ a < b := Nat.add_one_le_iff
Inequality Relating Successor and Order in Positive Natural Numbers: $a + 1 \leq b \leftrightarrow a < b$
Informal description
For any positive natural numbers $a$ and $b$, the inequality $a + 1 \leq b$ holds if and only if $a < b$.
PNat.instOrderBot instance
: OrderBot ℕ+
Full source
instance instOrderBot : OrderBot ℕ+ where
  bot := 1
  bot_le a := a.property
Positive Natural Numbers as an Order with Bottom Element 1
Informal description
The positive natural numbers $\mathbb{N}^+$ form an order with a bottom element, where the bottom element is $1$.
PNat.bot_eq_one theorem
: (⊥ : ℕ+) = 1
Full source
@[simp]
theorem bot_eq_one : ( : ℕ+) = 1 :=
  rfl
Bottom Element of Positive Natural Numbers is One
Informal description
The bottom element of the positive natural numbers $\mathbb{N}^+$ is equal to $1$, i.e., $\bot = 1$.
PNat.caseStrongInductionOn definition
{p : ℕ+ → Sort*} (a : ℕ+) (hz : p 1) (hi : ∀ n, (∀ m, m ≤ n → p m) → p (n + 1)) : p a
Full source
/-- Strong induction on `ℕ+`, with `n = 1` treated separately. -/
def caseStrongInductionOn {p : ℕ+ → Sort*} (a : ℕ+) (hz : p 1)
    (hi : ∀ n, (∀ m, m ≤ n → p m) → p (n + 1)) : p a := by
  apply strongInductionOn a
  rintro ⟨k, kprop⟩ hk
  rcases k with - | k
  · exact (lt_irrefl 0 kprop).elim
  rcases k with - | k
  · exact hz
  exact hi ⟨k.succ, Nat.succ_pos _⟩ fun m hm => hk _ (Nat.lt_succ_iff.2 hm)
Strong induction on positive natural numbers with separate base case
Informal description
For any predicate $p$ on positive natural numbers and any positive natural number $a$, if $p(1)$ holds and for every $n \in \mathbb{N}^+$ the implication $(\forall m \leq n, p(m)) \to p(n + 1)$ holds, then $p(a)$ holds. This is a variant of strong induction where the base case is treated separately and the induction step assumes the property holds for all $m \leq n$.
PNat.recOn definition
(n : ℕ+) {p : ℕ+ → Sort*} (one : p 1) (succ : ∀ n, p n → p (n + 1)) : p n
Full source
/-- An induction principle for `ℕ+`: it takes values in `Sort*`, so it applies also to Types,
not only to `Prop`. -/
@[elab_as_elim, induction_eliminator]
def recOn (n : ℕ+) {p : ℕ+ → Sort*} (one : p 1) (succ : ∀ n, p n → p (n + 1)) : p n := by
  rcases n with ⟨n, h⟩
  induction n with
  | zero => exact absurd h (by decide)
  | succ n IH =>
    rcases n with - | n
    · exact one
    · exact succ _ (IH n.succ_pos)
Recursion principle for positive natural numbers
Informal description
The recursion principle for positive natural numbers. Given a predicate $p : \mathbb{N}^+ \to \text{Sort}*$, a base case $p(1)$, and a step function that for any $n : \mathbb{N}^+$ and proof of $p(n)$ produces a proof of $p(n+1)$, we can construct a proof of $p(a)$ for any positive natural number $a$.
PNat.recOn_one theorem
{p} (one succ) : @PNat.recOn 1 p one succ = one
Full source
@[simp]
theorem recOn_one {p} (one succ) : @PNat.recOn 1 p one succ = one :=
  rfl
Recursion on 1 for positive natural numbers yields the base case
Informal description
For any predicate $p : \mathbb{N}^+ \to \text{Sort}*$ and any terms `one` and `succ`, the recursion principle `PNat.recOn` applied to the positive natural number $1$ with base case `one` and step function `succ` evaluates to `one`.
PNat.recOn_succ theorem
(n : ℕ+) {p : ℕ+ → Sort*} (one succ) : @PNat.recOn (n + 1) p one succ = succ n (@PNat.recOn n p one succ)
Full source
@[simp]
theorem recOn_succ (n : ℕ+) {p : ℕ+ → Sort*} (one succ) :
    @PNat.recOn (n + 1) p one succ = succ n (@PNat.recOn n p one succ) := by
  obtain ⟨n, h⟩ := n
  cases n <;> [exact absurd h (by decide); rfl]
Recursion Step for Positive Natural Numbers: $\text{recOn}(n+1) = \text{succ}(n, \text{recOn}(n))$
Informal description
For any positive natural number $n$ and predicate $p : \mathbb{N}^+ \to \text{Sort}*$, the recursion principle applied to $n+1$ with base case `one` and step function `succ` equals the step function applied to $n$ and the recursion principle applied to $n$ with the same base case and step function. That is, the recursive evaluation satisfies $\text{recOn}(n+1, p, \text{one}, \text{succ}) = \text{succ}(n, \text{recOn}(n, p, \text{one}, \text{succ}))$.
PNat.ofNat_le_ofNat theorem
{m n : ℕ} [NeZero m] [NeZero n] : (ofNat(m) : ℕ+) ≤ ofNat(n) ↔ OfNat.ofNat m ≤ OfNat.ofNat n
Full source
@[simp]
theorem ofNat_le_ofNat {m n : } [NeZero m] [NeZero n] :
    (ofNat(m) : ℕ+) ≤ ofNat(n) ↔ OfNat.ofNat m ≤ OfNat.ofNat n :=
  .rfl
Order Preservation of Positive Natural Number Casting: $(m : \mathbb{N}^+) \leq (n : \mathbb{N}^+) \leftrightarrow m \leq n$
Informal description
For any nonzero natural numbers $m$ and $n$, the inequality $(m : \mathbb{N}^+) \leq (n : \mathbb{N}^+)$ holds if and only if $m \leq n$ as natural numbers.
PNat.ofNat_lt_ofNat theorem
{m n : ℕ} [NeZero m] [NeZero n] : (ofNat(m) : ℕ+) < ofNat(n) ↔ OfNat.ofNat m < OfNat.ofNat n
Full source
@[simp]
theorem ofNat_lt_ofNat {m n : } [NeZero m] [NeZero n] :
    (ofNat(m) : ℕ+) < ofNat(n) ↔ OfNat.ofNat m < OfNat.ofNat n :=
  .rfl
Order Preservation of Positive Natural Numbers via Canonical Embedding
Informal description
For any two nonzero natural numbers $m$ and $n$, the positive natural number corresponding to $m$ is less than the positive natural number corresponding to $n$ if and only if $m < n$ as natural numbers.
PNat.ofNat_inj theorem
{m n : ℕ} [NeZero m] [NeZero n] : (ofNat(m) : ℕ+) = ofNat(n) ↔ OfNat.ofNat m = OfNat.ofNat n
Full source
@[simp]
theorem ofNat_inj {m n : } [NeZero m] [NeZero n] :
    (ofNat(m) : ℕ+) = ofNat(n) ↔ OfNat.ofNat m = OfNat.ofNat n :=
  Subtype.mk_eq_mk
Injective Correspondence Between Nonzero Natural Numbers and Positive Natural Numbers
Informal description
For any two nonzero natural numbers $m$ and $n$, the corresponding positive natural numbers $\mathtt{ofNat}(m)$ and $\mathtt{ofNat}(n)$ are equal if and only if $m = n$.
PNat.mul_coe theorem
(m n : ℕ+) : ((m * n : ℕ+) : ℕ) = m * n
Full source
@[simp, norm_cast]
theorem mul_coe (m n : ℕ+) : ((m * n : ℕ+) : ) = m * n :=
  rfl
Product of Positive Natural Numbers Commutes with Canonical Embedding
Informal description
For any two positive natural numbers $m$ and $n$, the underlying natural number of their product $m * n$ in $\mathbb{N}^+$ is equal to the product of their underlying natural numbers, i.e., $(m * n : \mathbb{N}) = (m : \mathbb{N}) * (n : \mathbb{N})$.
PNat.coeMonoidHom definition
: ℕ+ →* ℕ
Full source
/-- `PNat.coe` promoted to a `MonoidHom`. -/
def coeMonoidHom : ℕ+ℕ+ →* ℕ where
  toFun := Coe.coe
  map_one' := one_coe
  map_mul' := mul_coe
Canonical monoid homomorphism from positive to natural numbers
Informal description
The monoid homomorphism from the positive natural numbers $\mathbb{N}^+$ to the natural numbers $\mathbb{N}$ that maps each positive natural number to its underlying natural number value. This homomorphism preserves the multiplicative identity and the multiplication operation, i.e., it satisfies $f(1) = 1$ and $f(m * n) = f(m) * f(n)$ for all $m, n \in \mathbb{N}^+$.
PNat.coe_coeMonoidHom theorem
: (coeMonoidHom : ℕ+ → ℕ) = Coe.coe
Full source
@[simp]
theorem coe_coeMonoidHom : (coeMonoidHom : ℕ+) = Coe.coe :=
  rfl
Monoid Homomorphism Coincides with Coercion for Positive Natural Numbers
Informal description
The canonical monoid homomorphism from the positive natural numbers $\mathbb{N}^+$ to the natural numbers $\mathbb{N}$ coincides with the coercion function, i.e., $\text{coeMonoidHom} = \text{Coe.coe}$.
PNat.le_one_iff theorem
{n : ℕ+} : n ≤ 1 ↔ n = 1
Full source
@[simp]
theorem le_one_iff {n : ℕ+} : n ≤ 1 ↔ n = 1 :=
  le_bot_iff
Characterization of the Bottom Element in Positive Natural Numbers: $n \leq 1 \leftrightarrow n = 1$
Informal description
For any positive natural number $n$, the inequality $n \leq 1$ holds if and only if $n = 1$.
PNat.lt_add_left theorem
(n m : ℕ+) : n < m + n
Full source
theorem lt_add_left (n m : ℕ+) : n < m + n :=
  lt_add_of_pos_left _ m.2
Strict inequality under left addition in positive natural numbers
Informal description
For any positive natural numbers $n$ and $m$, we have $n < m + n$.
PNat.lt_add_right theorem
(n m : ℕ+) : n < n + m
Full source
theorem lt_add_right (n m : ℕ+) : n < n + m :=
  (lt_add_left n m).trans_eq (add_comm _ _)
Strict inequality under right addition in positive natural numbers
Informal description
For any positive natural numbers $n$ and $m$, we have $n < n + m$.
PNat.pow_coe theorem
(m : ℕ+) (n : ℕ) : ↑(m ^ n) = (m : ℕ) ^ n
Full source
@[simp, norm_cast]
theorem pow_coe (m : ℕ+) (n : ) : ↑(m ^ n) = (m : ) ^ n :=
  rfl
Exponentiation Commutes with Canonical Embedding from $\mathbb{N}^+$ to $\mathbb{N}$
Informal description
For any positive natural number $m \in \mathbb{N}^+$ and any natural number $n \in \mathbb{N}$, the underlying natural number of $m^n$ is equal to $(m)^n$, where the exponentiation is performed in $\mathbb{N}^+$ on the left and in $\mathbb{N}$ on the right.
PNat.one_lt_of_lt theorem
{a b : ℕ+} (hab : a < b) : 1 < b
Full source
/-- b is greater one if any a is less than b -/
theorem one_lt_of_lt {a b : ℕ+} (hab : a < b) : 1 < b := bot_le.trans_lt hab
If $a < b$ in positive naturals, then $b > 1$
Informal description
For any positive natural numbers $a$ and $b$, if $a < b$, then $1 < b$.
PNat.add_one theorem
(a : ℕ+) : a + 1 = succPNat a
Full source
theorem add_one (a : ℕ+) : a + 1 = succPNat a := rfl
Addition of One Equals Successor in Positive Natural Numbers
Informal description
For any positive natural number $a$, the sum of $a$ and $1$ is equal to the successor of $a$ in the type of positive natural numbers, i.e., $a + 1 = \text{succPNat}(a)$.
PNat.lt_succ_self theorem
(a : ℕ+) : a < succPNat a
Full source
theorem lt_succ_self (a : ℕ+) : a < succPNat a := lt.base a
Positive natural numbers are less than their successors
Informal description
For any positive natural number $a$, we have $a < a + 1$, where $a + 1$ is represented as the successor of $a$ in the type of positive natural numbers.
PNat.instSub instance
: Sub ℕ+
Full source
/-- Subtraction a - b is defined in the obvious way when
  a > b, and by a - b = 1 if a ≤ b.
-/
instance instSub : Sub ℕ+ :=
  ⟨fun a b => toPNat' (a - b : ℕ)⟩
Subtraction on Positive Natural Numbers
Informal description
The positive natural numbers $\mathbb{N}^+$ are equipped with a subtraction operation defined as follows: for $a, b \in \mathbb{N}^+$, if $a > b$ then $a - b$ is their usual subtraction as natural numbers, otherwise $a - b = 1$.
PNat.sub_coe theorem
(a b : ℕ+) : ((a - b : ℕ+) : ℕ) = ite (b < a) (a - b : ℕ) 1
Full source
theorem sub_coe (a b : ℕ+) : ((a - b : ℕ+) : ) = ite (b < a) (a - b : ) 1 := by
  change (toPNat' _ : ) = ite _ _ _
  split_ifs with h
  · exact toPNat'_coe (tsub_pos_of_lt h)
  · rw [tsub_eq_zero_iff_le.mpr (le_of_not_gt h : (a : ) ≤ b)]
    rfl
Underlying Natural Number of Positive Natural Subtraction
Informal description
For any two positive natural numbers $a$ and $b$, the underlying natural number of their difference $a - b$ (as positive natural numbers) is equal to the natural number difference $a - b$ if $b < a$, and $1$ otherwise. In symbols: $(a - b : \mathbb{N}^+)_{\mathbb{N}} = \begin{cases} a - b & \text{if } b < a \\ 1 & \text{otherwise} \end{cases}$
PNat.sub_le theorem
(a b : ℕ+) : a - b ≤ a
Full source
theorem sub_le (a b : ℕ+) : a - b ≤ a := by
  rw [← coe_le_coe, sub_coe]
  split_ifs with h
  · exact Nat.sub_le a b
  · exact a.2
Subtraction Bounded by Minuend in Positive Natural Numbers
Informal description
For any two positive natural numbers $a$ and $b$, the difference $a - b$ (as defined in $\mathbb{N}^+$) is less than or equal to $a$.
PNat.le_sub_one_of_lt theorem
{a b : ℕ+} (hab : a < b) : a ≤ b - (1 : ℕ+)
Full source
theorem le_sub_one_of_lt {a b : ℕ+} (hab : a < b) : a ≤ b - (1 : ℕ+) := by
  rw [← coe_le_coe, sub_coe]
  split_ifs with h
  · exact Nat.le_pred_of_lt hab
  · exact hab.le.trans (le_of_not_lt h)
Subtraction of One Preserves Order in Positive Natural Numbers
Informal description
For any two positive natural numbers $a$ and $b$ such that $a < b$, it holds that $a \leq b - 1$.
PNat.add_sub_of_lt theorem
{a b : ℕ+} : a < b → a + (b - a) = b
Full source
theorem add_sub_of_lt {a b : ℕ+} : a < b → a + (b - a) = b :=
  fun h =>
    PNat.eq <| by
      rw [add_coe, sub_coe, if_pos h]
      exact add_tsub_cancel_of_le h.le
Addition-Subtraction Identity for Positive Natural Numbers under Strict Inequality
Informal description
For any two positive natural numbers $a$ and $b$ such that $a < b$, the sum of $a$ and the difference $b - a$ equals $b$, i.e., $a + (b - a) = b$.
PNat.sub_add_of_lt theorem
{a b : ℕ+} (h : b < a) : a - b + b = a
Full source
theorem sub_add_of_lt {a b : ℕ+} (h : b < a) : a - b + b = a := by
  rw [add_comm, add_sub_of_lt h]
Subtraction-Additive Cancellation for Positive Natural Numbers under Strict Inequality
Informal description
For any two positive natural numbers $a$ and $b$ such that $b < a$, the sum of the difference $a - b$ and $b$ equals $a$, i.e., $(a - b) + b = a$.
PNat.add_sub theorem
{a b : ℕ+} : a + b - b = a
Full source
@[simp]
theorem add_sub {a b : ℕ+} : a + b - b = a :=
  add_right_cancel (sub_add_of_lt (lt_add_left _ _))
Subtraction Cancellation for Positive Natural Numbers: $(a + b) - b = a$
Informal description
For any positive natural numbers $a$ and $b$, the difference $(a + b) - b$ equals $a$.
PNat.exists_eq_succ_of_ne_one theorem
: ∀ {n : ℕ+} (_ : n ≠ 1), ∃ k : ℕ+, n = k + 1
Full source
/-- If `n : ℕ+` is different from `1`, then it is the successor of some `k : ℕ+`. -/
theorem exists_eq_succ_of_ne_one : ∀ {n : ℕ+} (_ : n ≠ 1), ∃ k : ℕ+, n = k + 1
  | ⟨1, _⟩, h₁ => False.elim <| h₁ rfl
  | ⟨n + 2, _⟩, _ => ⟨⟨n + 1, by simp⟩, rfl⟩
Decomposition of Positive Natural Numbers Greater Than One as Successors
Informal description
For any positive natural number $n \neq 1$, there exists a positive natural number $k$ such that $n = k + 1$.
PNat.modDivAux_spec theorem
: ∀ (k : ℕ+) (r q : ℕ) (_ : ¬(r = 0 ∧ q = 0)), ((modDivAux k r q).1 : ℕ) + k * (modDivAux k r q).2 = r + k * q
Full source
/-- Lemmas with div, dvd and mod operations -/
theorem modDivAux_spec :
    ∀ (k : ℕ+) (r q : ) (_ : ¬(r = 0 ∧ q = 0)),
      ((modDivAux k r q).1 : ) + k * (modDivAux k r q).2 = r + k * q
  | _, 0, 0, h => (h ⟨rfl, rfl⟩).elim
  | k, 0, q + 1, _ => by
    change (k : ) + (k : ) * (q + 1).pred = 0 + (k : ) * (q + 1)
    rw [Nat.pred_succ, Nat.mul_succ, zero_add, add_comm]
  | _, _ + 1, _, _ => rfl
Specification of the Modified Division Auxiliary Function for Positive Natural Numbers
Informal description
For any positive natural number $k$ and natural numbers $r, q$ (not both zero), the auxiliary function `modDivAux` satisfies the equation: $$(\text{modDivAux}\ k\ r\ q).1 + k \cdot (\text{modDivAux}\ k\ r\ q).2 = r + k \cdot q$$ where $(\text{modDivAux}\ k\ r\ q).1$ is the remainder (as a positive natural number) and $(\text{modDivAux}\ k\ r\ q).2$ is the quotient (as a natural number).
PNat.mod_add_div theorem
(m k : ℕ+) : (mod m k + k * div m k : ℕ) = m
Full source
theorem mod_add_div (m k : ℕ+) : (mod m k + k * div m k : ) = m := by
  let h₀ := Nat.mod_add_div (m : ) (k : )
  have : ¬((m : ℕ) % (k : ℕ) = 0 ∧ (m : ℕ) / (k : ℕ) = 0) := by
    rintro ⟨hr, hq⟩
    rw [hr, hq, mul_zero, zero_add] at h₀
    exact (m.ne_zero h₀.symm).elim
  have := modDivAux_spec k ((m : ) % (k : )) ((m : ) / (k : )) this
  exact this.trans h₀
Modified Division Identity for Positive Natural Numbers: $(m \bmod k) + k \cdot (m \div k) = m$
Informal description
For any positive natural numbers $m$ and $k$, the sum of the positive remainder $m \bmod k$ and the product $k \cdot (m \div k)$ equals $m$, i.e., $$(m \bmod k) + k \cdot (m \div k) = m.$$
PNat.div_add_mod theorem
(m k : ℕ+) : (k * div m k + mod m k : ℕ) = m
Full source
theorem div_add_mod (m k : ℕ+) : (k * div m k + mod m k : ) = m :=
  (add_comm _ _).trans (mod_add_div _ _)
Division Identity for Positive Natural Numbers: $k \cdot (m \div k) + (m \bmod k) = m$
Informal description
For any positive natural numbers $m$ and $k$, the sum of the product $k \cdot (m \div k)$ and the positive remainder $m \bmod k$ equals $m$, i.e., $$k \cdot (m \div k) + (m \bmod k) = m.$$
PNat.mod_add_div' theorem
(m k : ℕ+) : (mod m k + div m k * k : ℕ) = m
Full source
theorem mod_add_div' (m k : ℕ+) : (mod m k + div m k * k : ) = m := by
  rw [mul_comm]
  exact mod_add_div _ _
Modified Division Identity for Positive Natural Numbers: $(m \bmod k) + (m \div k) \cdot k = m$
Informal description
For any positive natural numbers $m$ and $k$, the sum of the positive remainder $m \bmod k$ and the product $(m \div k) \cdot k$ equals $m$, i.e., $$(m \bmod k) + (m \div k) \cdot k = m.$$
PNat.div_add_mod' theorem
(m k : ℕ+) : (div m k * k + mod m k : ℕ) = m
Full source
theorem div_add_mod' (m k : ℕ+) : (div m k * k + mod m k : ) = m := by
  rw [mul_comm]
  exact div_add_mod _ _
Division Identity for Positive Natural Numbers: $(m \div k) \cdot k + (m \bmod k) = m$
Informal description
For any positive natural numbers $m$ and $k$, the sum of the product $(m \div k) \cdot k$ and the positive remainder $m \bmod k$ equals $m$, i.e., $$(m \div k) \cdot k + (m \bmod k) = m.$$
PNat.mod_le theorem
(m k : ℕ+) : mod m k ≤ m ∧ mod m k ≤ k
Full source
theorem mod_le (m k : ℕ+) : modmod m k ≤ m ∧ mod m k ≤ k := by
  change (mod m k : ℕ) ≤ (m : ℕ) ∧ (mod m k : ℕ) ≤ (k : ℕ)
  rw [mod_coe]
  split_ifs with h
  · have hm : (m : ) > 0 := m.pos
    rw [← Nat.mod_add_div (m : ) (k : ), h, zero_add] at hm ⊢
    by_cases h₁ : (m : ℕ) / (k : ℕ) = 0
    · rw [h₁, mul_zero] at hm
      exact (lt_irrefl _ hm).elim
    · let h₂ : (k : ) * 1 ≤ k * (m / k) :=
        Nat.mul_le_mul_left (k : ) (Nat.succ_le_of_lt (Nat.pos_of_ne_zero h₁))
      rw [mul_one] at h₂
      exact ⟨h₂, le_refl (k : ℕ)⟩
  · exact ⟨Nat.mod_le (m : ℕ) (k : ℕ), (Nat.mod_lt (m : ℕ) k.pos).le⟩
Bounds on Modified Remainder for Positive Natural Numbers
Informal description
For any positive natural numbers $m$ and $k$, the modified remainder $\mathrm{mod}\, m\, k$ satisfies both $\mathrm{mod}\, m\, k \leq m$ and $\mathrm{mod}\, m\, k \leq k$.
PNat.dvd_iff theorem
{k m : ℕ+} : k ∣ m ↔ (k : ℕ) ∣ (m : ℕ)
Full source
theorem dvd_iff {k m : ℕ+} : k ∣ mk ∣ m ↔ (k : ℕ) ∣ (m : ℕ) := by
  constructor <;> intro h
  · rcases h with ⟨_, rfl⟩
    apply dvd_mul_right
  · rcases h with ⟨a, h⟩
    obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (n := a) <| by
      rintro rfl
      simp only [mul_zero, ne_zero] at h
    use ⟨n.succ, n.succ_pos⟩
    rw [← coe_inj, h, mul_coe, mk_coe]
Divisibility Correspondence Between Positive Natural Numbers and Their Underlying Natural Numbers
Informal description
For any two positive natural numbers $k$ and $m$, $k$ divides $m$ if and only if the underlying natural number of $k$ divides the underlying natural number of $m$. That is, $k \mid m \leftrightarrow (k : \mathbb{N}) \mid (m : \mathbb{N})$.
PNat.dvd_iff' theorem
{k m : ℕ+} : k ∣ m ↔ mod m k = k
Full source
theorem dvd_iff' {k m : ℕ+} : k ∣ mk ∣ m ↔ mod m k = k := by
  rw [dvd_iff]
  rw [Nat.dvd_iff_mod_eq_zero]; constructor
  · intro h
    apply PNat.eq
    rw [mod_coe, if_pos h]
  · intro h
    by_cases h' : (m : ℕ) % (k : ℕ) = 0
    · exact h'
    · replace h : (mod m k : ) = (k : ) := congr_arg _ h
      rw [mod_coe, if_neg h'] at h
      exact ((Nat.mod_lt (m : ) k.pos).ne h).elim
Divisibility Criterion via Modified Remainder: $k \mid m \leftrightarrow \mathrm{mod}\, m\, k = k$
Informal description
For any two positive natural numbers $k$ and $m$, $k$ divides $m$ if and only if the modified remainder $\mathrm{mod}\, m\, k$ equals $k$.
PNat.le_of_dvd theorem
{m n : ℕ+} : m ∣ n → m ≤ n
Full source
theorem le_of_dvd {m n : ℕ+} : m ∣ n → m ≤ n := by
  rw [dvd_iff']
  intro h
  rw [← h]
  apply (mod_le n m).left
Divisibility Implies Ordering in Positive Natural Numbers
Informal description
For any two positive natural numbers $m$ and $n$, if $m$ divides $n$, then $m$ is less than or equal to $n$.
PNat.mul_div_exact theorem
{m k : ℕ+} (h : k ∣ m) : k * divExact m k = m
Full source
theorem mul_div_exact {m k : ℕ+} (h : k ∣ m) : k * divExact m k = m := by
  apply PNat.eq; rw [mul_coe]
  change (k : ) * (div m k).succ = m
  rw [← div_add_mod m k, dvd_iff'.mp h, Nat.mul_succ]
Exact Division Property for Positive Natural Numbers: $k \cdot (m \div_{\text{exact}} k) = m$
Informal description
For any positive natural numbers $m$ and $k$ such that $k$ divides $m$, the product of $k$ and the exact division $\mathrm{divExact}\, m\, k$ equals $m$, i.e., $$k \cdot \mathrm{divExact}\, m\, k = m.$$
PNat.dvd_antisymm theorem
{m n : ℕ+} : m ∣ n → n ∣ m → m = n
Full source
theorem dvd_antisymm {m n : ℕ+} : m ∣ nn ∣ m → m = n := fun hmn hnm =>
  (le_of_dvd hmn).antisymm (le_of_dvd hnm)
Antisymmetry of Divisibility for Positive Natural Numbers
Informal description
For any two positive natural numbers $m$ and $n$, if $m$ divides $n$ and $n$ divides $m$, then $m = n$.
PNat.pos_of_div_pos theorem
{n : ℕ+} {a : ℕ} (h : a ∣ n) : 0 < a
Full source
theorem pos_of_div_pos {n : ℕ+} {a : } (h : a ∣ n) : 0 < a := by
  apply pos_iff_ne_zero.2
  intro hzero
  rw [hzero] at h
  exact PNat.ne_zero n (eq_zero_of_zero_dvd h)
Positivity of Divisors of Positive Natural Numbers
Informal description
For any positive natural number $n$ and any natural number $a$ that divides $n$, we have $0 < a$.