Documentation

Mathlib.Data.PNat.Defs

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.

@[implicit_reducible]
Equations
  • One or more equations did not get rendered due to their size.
@[implicit_reducible]
instance instOnePNat :
Equations
@[implicit_reducible]
Equations
@[simp]
theorem PNat.mk_coe (n : ℕ) (h : 0 < n) :
↑⟨n, h⟩ = n
def PNat.natPred (i : ℕ+) :

Predecessor of a ℕ+, as a ℕ.

Equations
Instances For
    @[simp]
    theorem PNat.natPred_eq_pred {n : ℕ} (h : 0 < n) :
    def Nat.toPNat (n : ℕ) (h : 0 < n := by decide) :

    Convert a natural number to a positive natural number. The positivity assumption is inferred by dec_trivial.

    Equations
    Instances For
      def Nat.succPNat (n : ℕ) :

      Write a successor as an element of ℕ+.

      Equations
      Instances For
        @[simp]
        theorem Nat.succPNat_coe (n : ℕ) :
        ↑n.succPNat = n.succ
        @[simp]
        def Nat.toPNat' (n : ℕ) :

        Convert a natural number to a PNat. n+1 is mapped to itself, and 0 becomes 1.

        Equations
        Instances For
          @[simp]
          @[simp]
          theorem Nat.toPNat'_coe (n : ℕ) :
          ↑n.toPNat' = if 0 < n then n else 1
          theorem PNat.mk_le_mk (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 PNat.mk_lt_mk (n k : ℕ) (hn : 0 < n) (hk : 0 < k) :
          ⟨n, hn⟩ < ⟨k, hk⟩ ↔ n < k
          @[simp]
          theorem PNat.coe_le_coe (n k : ℕ+) :
          ↑n ≤ ↑k ↔ n ≤ k
          @[simp]
          theorem PNat.coe_lt_coe (n k : ℕ+) :
          ↑n < ↑k ↔ n < k
          @[simp]
          theorem PNat.pos (n : ℕ+) :
          0 < ↑n
          theorem PNat.eq {m n : ℕ+} :
          ↑m = ↑n → m = n
          @[simp]
          theorem PNat.ne_zero (n : ℕ+) :
          ↑n ≠ 0
          instance NeZero.pnat {a : ℕ+} :
          NeZero ↑a
          theorem PNat.toPNat'_coe {n : ℕ} :
          0 < n → ↑n.toPNat' = n
          @[simp]
          theorem PNat.coe_toPNat' (n : ℕ+) :
          (↑n).toPNat' = n
          @[simp]
          theorem PNat.one_le (n : ℕ+) :
          1 ≤ n
          @[simp]
          theorem PNat.not_lt_one (n : ℕ+) :
          ¬n < 1
          @[implicit_reducible]
          Equations
          @[simp]
          theorem PNat.mk_one {h : 0 < 1} :
          ⟨1, h⟩ = 1
          theorem PNat.one_coe :
          ↑1 = 1
          @[simp]
          theorem PNat.coe_eq_one_iff {m : ℕ+} :
          ↑m = 1 ↔ m = 1
          @[irreducible]
          def PNat.strongInductionOn {p : ℕ+ → Sort u_1} (n : ℕ+) :
          ((k : ℕ+) → ((m : ℕ+) → m < k → p m) → p k) → p n

          Strong induction on ℕ+.

          Equations
          Instances For
            def PNat.modDivAux :
            ℕ+ → ℕ → ℕ → ℕ+ × ℕ

            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
              def PNat.modDiv (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.

              Equations
              Instances For
                def PNat.mod (m k : ℕ+) :

                We define m % k in the same way as for ℕ except that when m = n * k we take m % k = k This ensures that m % k is always positive.

                Equations
                Instances For
                  def PNat.div (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.

                  Equations
                  Instances For
                    theorem PNat.mod_coe (m k : ℕ+) :
                    ↑(m.mod k) = if ↑m % ↑k = 0 then ↑k else ↑m % ↑k
                    theorem PNat.div_coe (m k : ℕ+) :
                    m.div k = if ↑m % ↑k = 0 then (↑m / ↑k).pred else ↑m / ↑k
                    def PNat.divExact (m k : ℕ+) :

                    If h : k | m, then k * (div_exact m k) = m. Note that this is not equal to m / k.

                    Equations
                    Instances For
                      instance Nat.canLiftPNat :
                      CanLift ℕ ℕ+ PNat.val fun (n : ℕ) => 0 < n
                      instance Int.canLiftPNat :
                      CanLift ℤ ℕ+ (fun (x : ℕ+) => ↑↑x) fun (x : ℤ) => 0 < x