Documentation

Mathlib.Data.Nat.PartENat

Natural numbers with infinity #

The natural numbers and an extra top element ⊤. This implementation uses Part ℕ as an implementation. This version is deprecated, use ℕ∞ instead.

Main definitions #

The following instances are defined:

There is no additive analogue of MonoidWithZero; if there were then PartENat could be an AddMonoidWithTop.

Implementation details #

PartENat is defined to be Part ℕ.

+ and ≤ are defined on PartENat, but there is an issue with * because it's not clear what 0 * ⊤ should be. mul is hence left undefined. Similarly ⊤ - ⊤ is ambiguous so there is no - defined on PartENat.

Before the open scoped Classical line, various proofs are made with decidability assumptions. This can cause issues -- see for example the non-simp lemma toWithTopZero proved by rfl, followed by @[simp] lemma toWithTopZero' whose proof uses convert.

Deprecation #

As it appears this has been unused since 2018, we are now deprecating it. If ENat does not serve your purposes, please raise this on the community Zulip.

Tags #

PartENat, ℕ∞

@[deprecated ENat (since := "2025-09-01")]

Type of natural numbers with infinity (⊤)

Equations
Instances For

    The computable embedding ℕ → PartENat.

    This coincides with the coercion coe : ℕ → PartENat, see PartENat.some_eq_natCast.

    Equations
    Instances For
      Equations
      Equations
      Equations
      @[simp]
      theorem PartENat.dom_some (x : ℕ) :
      (↑x).Dom
      Equations
      • One or more equations did not get rendered due to their size.
      Equations
      • One or more equations did not get rendered due to their size.
      theorem PartENat.some_eq_natCast (n : ℕ) :
      ↑n = ↑n
      theorem PartENat.natCast_inj {x y : ℕ} :
      ↑x = ↑y ↔ x = y

      Alias of Nat.cast_inj specialized to PartENat

      @[simp]
      theorem PartENat.dom_natCast (x : ℕ) :
      (↑x).Dom
      @[simp]
      @[simp]
      Equations
      Equations
      theorem PartENat.le_def (x y : PartENat) :
      x ≤ y ↔ ∃ (h : y.Dom → x.Dom), ∀ (hy : y.Dom), x.get ⋯ ≤ y.get hy
      theorem PartENat.casesOn' {P : PartENat → Prop} (a : PartENat) :
      P ⊤ → (∀ (n : ℕ), P ↑n) → P a
      theorem PartENat.casesOn {P : PartENat → Prop} (a : PartENat) :
      P ⊤ → (∀ (n : ℕ), P ↑n) → P a
      @[simp]
      theorem PartENat.natCast_get {x : PartENat} (h : x.Dom) :
      ↑(x.get h) = x
      @[simp]
      theorem PartENat.get_natCast' (x : ℕ) (h : (↑x).Dom) :
      (↑x).get h = x
      theorem PartENat.get_natCast {x : ℕ} :
      (↑x).get ⋯ = x
      theorem PartENat.coe_add_get {x : ℕ} {y : PartENat} (h : (↑x + y).Dom) :
      (↑x + y).get h = x + y.get ⋯
      @[simp]
      theorem PartENat.get_add {x y : PartENat} (h : (x + y).Dom) :
      (x + y).get h = x.get ⋯ + y.get ⋯
      @[simp]
      theorem PartENat.get_zero (h : Part.Dom 0) :
      Part.get 0 h = 0
      @[simp]
      theorem PartENat.get_one (h : Part.Dom 1) :
      Part.get 1 h = 1
      @[simp]
      theorem PartENat.get_eq_iff_eq_some {a : PartENat} {ha : a.Dom} {b : ℕ} :
      a.get ha = b ↔ a = ↑b
      theorem PartENat.get_eq_iff_eq_coe {a : PartENat} {ha : a.Dom} {b : ℕ} :
      a.get ha = b ↔ a = ↑b
      theorem PartENat.dom_of_le_of_dom {x y : PartENat} :
      x ≤ y → y.Dom → x.Dom
      theorem PartENat.dom_of_le_some {x : PartENat} {y : ℕ} (h : x ≤ ↑y) :
      x.Dom
      theorem PartENat.dom_of_le_natCast {x : PartENat} {y : ℕ} (h : x ≤ ↑y) :
      x.Dom
      Equations
      Equations
      • One or more equations did not get rendered due to their size.
      theorem PartENat.lt_def (x y : PartENat) :
      x < y ↔ ∃ (hx : x.Dom), ∀ (hy : y.Dom), x.get hx < y.get hy
      Equations
      • One or more equations did not get rendered due to their size.
      theorem PartENat.coe_le_coe {x y : ℕ} :
      ↑x ≤ ↑y ↔ x ≤ y

      Alias of Nat.cast_le specialized to PartENat

      theorem PartENat.coe_lt_coe {x y : ℕ} :
      ↑x < ↑y ↔ x < y

      Alias of Nat.cast_lt specialized to PartENat

      @[simp]
      theorem PartENat.get_le_get {x y : PartENat} {hx : x.Dom} {hy : y.Dom} :
      x.get hx ≤ y.get hy ↔ x ≤ y
      theorem PartENat.le_coe_iff (x : PartENat) (n : ℕ) :
      x ≤ ↑n ↔ ∃ (h : x.Dom), x.get h ≤ n
      theorem PartENat.lt_coe_iff (x : PartENat) (n : ℕ) :
      x < ↑n ↔ ∃ (h : x.Dom), x.get h < n
      theorem PartENat.coe_le_iff (n : ℕ) (x : PartENat) :
      ↑n ≤ x ↔ ∀ (h : x.Dom), n ≤ x.get h
      theorem PartENat.coe_lt_iff (n : ℕ) (x : PartENat) :
      ↑n < x ↔ ∀ (h : x.Dom), n < x.get h
      theorem PartENat.dom_of_lt {x y : PartENat} :
      x < y → x.Dom
      @[simp]
      theorem PartENat.natCast_lt_top (x : ℕ) :
      ↑x < ⊤
      @[simp]
      @[simp]
      @[simp]
      theorem PartENat.natCast_ne_top (x : ℕ) :
      ↑x ≠ ⊤
      @[simp]
      theorem PartENat.ne_top_iff {x : PartENat} :
      x ≠ ⊤ ↔ ∃ (n : ℕ), x = ↑n
      theorem PartENat.ne_top_of_lt {x y : PartENat} (h : x < y) :
      theorem PartENat.eq_top_iff_forall_lt (x : PartENat) :
      x = ⊤ ↔ ∀ (n : ℕ), ↑n < x
      theorem PartENat.eq_top_iff_forall_le (x : PartENat) :
      x = ⊤ ↔ ∀ (n : ℕ), ↑n ≤ x
      instance PartENat.isTotal :
      IsTotal PartENat fun (x1 x2 : PartENat) => x1 ≤ x2
      noncomputable instance PartENat.linearOrder :
      Equations
      • One or more equations did not get rendered due to their size.
      noncomputable instance PartENat.lattice :
      Equations
      theorem PartENat.eq_natCast_sub_of_add_eq_natCast {x y : PartENat} {n : ℕ} (h : x + y = ↑n) :
      x = ↑(n - y.get ⋯)
      theorem PartENat.add_lt_add_right {x y z : PartENat} (h : x < y) (hz : z ≠ ⊤) :
      x + z < y + z
      theorem PartENat.add_lt_add_iff_right {x y z : PartENat} (hz : z ≠ ⊤) :
      x + z < y + z ↔ x < y
      theorem PartENat.add_lt_add_iff_left {x y z : PartENat} (hz : z ≠ ⊤) :
      z + x < z + y ↔ x < y
      theorem PartENat.lt_add_iff_pos_right {x y : PartENat} (hx : x ≠ ⊤) :
      x < x + y ↔ 0 < y
      theorem PartENat.lt_add_one {x : PartENat} (hx : x ≠ ⊤) :
      x < x + 1
      theorem PartENat.le_of_lt_add_one {x y : PartENat} (h : x < y + 1) :
      x ≤ y
      theorem PartENat.add_one_le_of_lt {x y : PartENat} (h : x < y) :
      x + 1 ≤ y
      theorem PartENat.add_one_le_iff_lt {x y : PartENat} (hx : x ≠ ⊤) :
      x + 1 ≤ y ↔ x < y
      theorem PartENat.coe_succ_le_iff {n : ℕ} {e : PartENat} :
      ↑n.succ ≤ e ↔ ↑n < e
      theorem PartENat.lt_add_one_iff_lt {x y : PartENat} (hx : x ≠ ⊤) :
      x < y + 1 ↔ x ≤ y
      theorem PartENat.lt_coe_succ_iff_le {x : PartENat} {n : ℕ} (hx : x ≠ ⊤) :
      x < ↑n.succ ↔ x ≤ ↑n
      theorem PartENat.add_right_cancel_iff {a b c : PartENat} (hc : c ≠ ⊤) :
      a + c = b + c ↔ a = b
      theorem PartENat.add_left_cancel_iff {a b c : PartENat} (ha : a ≠ ⊤) :
      a + b = a + c ↔ b = c

      Computably converts a PartENat to a ℕ∞.

      Equations
      Instances For
        theorem PartENat.toWithTop_some (n : ℕ) :
        (↑n).toWithTop = ↑n
        theorem PartENat.toWithTop_natCast (n : ℕ) {x✝ : Decidable (↑n).Dom} :
        (↑n).toWithTop = ↑n
        @[simp]
        theorem PartENat.toWithTop_natCast' (n : ℕ) {x✝ : Decidable (↑n).Dom} :
        (↑n).toWithTop = ↑n
        @[simp]

        Coercion from ℕ∞ to PartENat.

        Equations
        Instances For
          @[simp]
          @[simp]
          theorem PartENat.ofENat_coe (n : ℕ) :
          ↑↑n = ↑n
          @[simp]
          theorem PartENat.ofENat_zero :
          ↑0 = 0
          @[simp]
          theorem PartENat.ofENat_one :
          ↑1 = 1
          @[simp]
          theorem PartENat.toWithTop_ofENat (n : ℕ∞) {x✝ : Decidable (↑n).Dom} :
          (↑n).toWithTop = n
          @[simp]
          theorem PartENat.ofENat_toWithTop (x : PartENat) {x✝ : Decidable x.Dom} :
          ↑x.toWithTop = x
          @[simp]
          theorem PartENat.ofENat_le {x y : ℕ∞} :
          ↑x ≤ ↑y ↔ x ≤ y
          @[simp]
          theorem PartENat.ofENat_lt {x y : ℕ∞} :
          ↑x < ↑y ↔ x < y

          Equiv between PartENat and ℕ∞ (for the order isomorphism see withTopOrderIso).

          Equations
          Instances For

            toWithTop induces an order isomorphism between PartENat and ℕ∞.

            Equations
            Instances For

              toWithTop induces an additive monoid isomorphism between PartENat and ℕ∞.

              Equations
              Instances For
                theorem PartENat.lt_wf :
                WellFounded fun (x1 x2 : PartENat) => x1 < x2

                The smallest PartENat satisfying a (decidable) predicate P : ℕ → Prop

                Equations
                Instances For
                  @[simp]
                  theorem PartENat.find_get (P : ℕ → Prop) [DecidablePred P] (h : (find P).Dom) :
                  (find P).get h = Nat.find h
                  theorem PartENat.find_dom (P : ℕ → Prop) [DecidablePred P] (h : ∃ (n : ℕ), P n) :
                  (find P).Dom
                  theorem PartENat.lt_find (P : ℕ → Prop) [DecidablePred P] (n : ℕ) (h : ∀ m ≤ n, ¬P m) :
                  ↑n < find P
                  theorem PartENat.lt_find_iff (P : ℕ → Prop) [DecidablePred P] (n : ℕ) :
                  ↑n < find P ↔ ∀ m ≤ n, ¬P m
                  theorem PartENat.find_le (P : ℕ → Prop) [DecidablePred P] (n : ℕ) (h : P n) :
                  find P ≤ ↑n
                  theorem PartENat.find_eq_top_iff (P : ℕ → Prop) [DecidablePred P] :
                  find P = ⊤ ↔ ∀ (n : ℕ), ¬P n
                  Equations
                  • One or more equations did not get rendered due to their size.
                  Equations
                  • One or more equations did not get rendered due to their size.