The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V02. Numbers

Mathlib.Data.ENat.Basic

109 declarations and 23 deprecated aliases. Mathlib docs · Source

instance instOneENat E0 #

One ℕ∞

instance instLinearOrderENat E0 #

LinearOrder ℕ∞

instance instSubENat E0 #

Sub ℕ∞

instance instOrderBotENat E0 #

OrderBot ℕ∞

instance instAddENat E0 #

Add ℕ∞

instance instPreorderENat E0 #

Preorder ℕ∞

instance instLEENat E0 #

LE ℕ∞

instance instWellFoundedLTENat E0 #

WellFoundedLT ℕ∞

instance instZeroENat E0 #

Zero ℕ∞

instance instNontrivialENat E0 #

Nontrivial ℕ∞

instance instOrderTopENat E0 #

OrderTop ℕ∞

instance instLTENat E0 #

LT ℕ∞

instance instZeroLEOneClassENat E0 #

ZeroLEOneClass ℕ∞

instance instBotENat E0 #

Bot ℕ∞

theorem ENat.some_eq_natCast E0 #

WithTop.some = Nat.cast

Lemmas about WithTop expect (and can output) WithTop.some but the normal form for coercion ℕ → ℕ∞ is Nat.cast.

theorem ENat.natCast_inj E1 #

∀ {a b : ℕ}, ↑a = ↑b ↔ a = b

theorem ENat.natCast_zero E1 #

↑0 = 0

theorem ENat.natCast_one E1 #

↑1 = 1

theorem ENat.natCast_add E1 #

∀ (m n : ℕ), ↑(m + n) = ↑m + ↑n

theorem ENat.natCast_sub E0 #

∀ (m n : ℕ), ↑(m - n) = ↑m - ↑n

theorem ENat.ofNat_eq_natCast_ofNat E1 #

∀ (n : ℕ) [inst : n.AtLeastTwo], OfNat.ofNat n = ↑(OfNat.ofNat n)

Nat.cast_ofNat specialised to ℕ∞, so that basify can register the numeral as an operation; the generic lemma is stated over a variable type and carries no usable head symbol.

theorem ENat.natCast_lt_top E0 #

∀ (n : ℕ), ↑n < ⊤

def ENat.lift E1 #

(x : ℕ∞) → x < ⊤ → ℕ

Convert a ℕ∞ to a ℕ using a proof that it is not infinite.

theorem ENat.natCast_lift E0 #

∀ (x : ℕ∞) (h : x < ⊤), ↑(x.lift h) = x

theorem ENat.lift_natCast E0 #

∀ (n : ℕ), (↑n).lift ⋯ = n

theorem ENat.lift_lt_iff E0 #

∀ {x : ℕ∞} {h : x < ⊤} {n : ℕ}, x.lift h < n ↔ x < ↑n

theorem ENat.lift_le_iff E0 #

∀ {x : ℕ∞} {h : x < ⊤} {n : ℕ}, x.lift h ≤ n ↔ x ≤ ↑n

theorem ENat.lt_lift_iff E0 #

∀ {x : ℕ} {n : ℕ∞} {h : n < ⊤}, x < n.lift h ↔ ↑x < n

theorem ENat.le_lift_iff E0 #

∀ {x : ℕ} {n : ℕ∞} {h : n < ⊤}, x ≤ n.lift h ↔ ↑x ≤ n

theorem ENat.lift_zero E0 #

ENat.lift 0 ⋯ = 0

theorem ENat.lift_one E0 #

ENat.lift 1 ⋯ = 1

theorem ENat.lift_ofNat E0 #

∀ (n : ℕ) [inst : n.AtLeastTwo], (OfNat.ofNat n).lift ⋯ = OfNat.ofNat n

theorem ENat.add_lt_top E0 #

∀ {a b : ℕ∞}, a + b < ⊤ ↔ a < ⊤ ∧ b < ⊤

theorem ENat.add_eq_top E0 #

∀ {a b : ℕ∞}, a + b = ⊤ ↔ a = ⊤ ∨ b = ⊤

instance ENat.canLift E0 #

CanLift ℕ∞ ℕ Nat.cast fun x ↦ x ≠ ⊤

instance ENat.instWellFoundedRelation E0 #

WellFoundedRelation ℕ∞

def ENat.toNat E1 #

ℕ∞ → ℕ

Conversion of ℕ∞ to ℕ sending ∞ to 0.

theorem ENat.toNat_natCast E0 #

∀ (n : ℕ), (↑n).toNat = n

theorem ENat.toNat_zero E0 #

ENat.toNat 0 = 0

theorem ENat.toNat_one E0 #

ENat.toNat 1 = 1

theorem ENat.toNat_ofNat E0 #

∀ (n : ℕ) [inst : n.AtLeastTwo], (OfNat.ofNat n).toNat = n

theorem ENat.toNat_top E0 #

⊤.toNat = 0

theorem ENat.toNat_eq_zero E0 #

∀ {n : ℕ∞}, n.toNat = 0 ↔ n = 0 ∨ n = ⊤

theorem ENat.toNat_pos E1 #

∀ {n : ℕ∞}, n ≠ 0 → n ≠ ⊤ → 0 < n.toNat

theorem ENat.lift_eq_toNat_of_lt_top E1 #

∀ {x : ℕ∞} (hx : x < ⊤), x.lift hx = x.toNat

theorem ENat.recTopCoe_zero E0 #

∀ {C : ℕ∞ → Sort u_1} (d : C ⊤) (f : (a : ℕ) → C ↑a), ENat.recTopCoe d f 0 = f 0

theorem ENat.recTopCoe_one E0 #

∀ {C : ℕ∞ → Sort u_1} (d : C ⊤) (f : (a : ℕ) → C ↑a), ENat.recTopCoe d f 1 = f 1

theorem ENat.recTopCoe_ofNat E0 #

∀ {C : ℕ∞ → Sort u_1} (d : C ⊤) (f : (a : ℕ) → C ↑a) (x : ℕ) [inst : x.AtLeastTwo],
  ENat.recTopCoe d f (OfNat.ofNat x) = f (OfNat.ofNat x)

theorem ENat.top_ne_natCast E0 #

∀ (a : ℕ), ⊤ ≠ ↑a

theorem ENat.top_ne_ofNat E0 #

∀ (a : ℕ) [inst : a.AtLeastTwo], ⊤ ≠ OfNat.ofNat a

theorem ENat.top_ne_zero E0 #

⊤ ≠ 0

theorem ENat.top_ne_one E0 #

⊤ ≠ 1

theorem ENat.natCast_ne_top E0 #

∀ (a : ℕ), ↑a ≠ ⊤

theorem ENat.ofNat_ne_top E0 #

∀ (a : ℕ) [inst : a.AtLeastTwo], OfNat.ofNat a ≠ ⊤

theorem ENat.zero_ne_top E0 #

0 ≠ ⊤

theorem ENat.one_ne_top E0 #

1 ≠ ⊤

theorem ENat.top_sub_natCast E0 #

∀ (a : ℕ), ⊤ - ↑a = ⊤

theorem ENat.top_sub_one E0 #

⊤ - 1 = ⊤

theorem ENat.top_sub_ofNat E0 #

∀ (a : ℕ) [inst : a.AtLeastTwo], ⊤ - OfNat.ofNat a = ⊤

theorem ENat.top_pos E0 #

0 < ⊤

theorem ENat.one_lt_top E0 #

1 < ⊤

theorem ENat.sub_top E0 #

∀ (a : ℕ∞), a - ⊤ = 0

theorem ENat.natCast_toNat_eq_self E0 #

∀ {n : ℕ∞}, ↑n.toNat = n ↔ n ≠ ⊤

theorem ENat.natCast_toNat E1 #

∀ {n : ℕ∞}, n ≠ ⊤ → ↑n.toNat = n

Alias of the reverse direction of ENat.natCast_toNat_eq_self.

theorem ENat.le_natCast_toNat_self_iff E0 #

∀ {n : ℕ∞}, n ≤ ↑n.toNat ↔ n ≠ ⊤

theorem ENat.toNat_eq_iff_eq_natCast E0 #

∀ (n : ℕ∞) (m : ℕ) [NeZero m], n.toNat = m ↔ n = ↑m

theorem ENat.toNat_eq_iff E0 #

∀ {m : ℕ∞} {n : ℕ}, n ≠ 0 → (m.toNat = n ↔ m = ↑n)

theorem ENat.natCast_toNat_le_self E1 #

∀ (n : ℕ∞), ↑n.toNat ≤ n

theorem ENat.toNat_add E1 #

∀ {m n : ℕ∞}, m ≠ ⊤ → n ≠ ⊤ → (m + n).toNat = m.toNat + n.toNat

theorem ENat.toNat_sub E1 #

∀ {n : ℕ∞}, n ≠ ⊤ → ∀ (m : ℕ∞), (m - n).toNat = m.toNat - n.toNat

theorem ENat.add_le_add_iff_left E1 #

∀ {m n k : ℕ∞}, k ≠ ⊤ → (k + n ≤ k + m ↔ n ≤ m)

theorem ENat.add_le_add_iff_right E1 #

∀ {m n k : ℕ∞}, k ≠ ⊤ → (n + k ≤ m + k ↔ n ≤ m)

theorem ENat.le_natCast_iff E0 #

∀ {n : ℕ∞} {k : ℕ}, n ≤ ↑k ↔ ∃ n₀, n = ↑n₀ ∧ n₀ ≤ k

theorem ENat.add_lt_add_iff_right E1 #

∀ {m n k : ℕ∞}, k ≠ ⊤ → (n + k < m + k ↔ n < m)

theorem ENat.add_lt_add_iff_left E1 #

∀ {m n k : ℕ∞}, k ≠ ⊤ → (k + n < k + m ↔ n < m)

theorem ENat.add_lt_add E1 #

∀ {a b c d : ℕ∞}, a < c → b < d → a + b < c + d

theorem ENat.add_lt_add_of_le_of_lt E1 #

∀ {a b c d : ℕ∞}, a ≠ ⊤ → a ≤ b → c < d → a + c < b + d

theorem ENat.add_lt_add_of_lt_of_le E1 #

∀ {a b c d : ℕ∞}, c ≠ ⊤ → a < b → c ≤ d → a + c < b + d

theorem ENat.natCast_lt_natCast E1 #

∀ {n m : ℕ}, ↑n < ↑m ↔ n < m

theorem ENat.natCast_le_natCast E1 #

∀ {n m : ℕ}, ↑n ≤ ↑m ↔ n ≤ m

theorem ENat.toNat_le_of_le_natCast E1 #

∀ {m : ℕ∞} {n : ℕ}, m ≤ ↑n → m.toNat ≤ n

theorem ENat.toNat_le_toNat E1 #

∀ {m n : ℕ∞}, m ≤ n → n ≠ ⊤ → m.toNat ≤ n.toNat

theorem ENat.nat_induction E1 #

∀ {motive : ℕ∞ → Prop} (a : ℕ∞),
  motive 0 → (∀ (n : ℕ), motive ↑n → motive ↑n.succ) → ((∀ (n : ℕ), motive ↑n) → motive ⊤) → motive a

theorem ENat.ne_top_iff_exists E1 #

∀ {n : ℕ∞}, n ≠ ⊤ ↔ ∃ m, ↑m = n

theorem ENat.forall_ne_top E1 #

∀ {p : ℕ∞ → Prop}, (∀ (x : ℕ∞), x ≠ ⊤ → p x) ↔ ∀ (x : ℕ), p ↑x

theorem ENat.exists_ne_top E1 #

∀ {p : ℕ∞ → Prop}, (∃ x, x ≠ ⊤ ∧ p x) ↔ ∃ x, p ↑x

theorem ENat.forall_natCast_le_iff_le E1 #

∀ {m n : ℕ∞}, (∀ (a : ℕ), ↑a ≤ m → ↑a ≤ n) ↔ m ≤ n

Version of WithTop.forall_natCast_le_iff_le using Nat.cast rather than WithTop.some.

theorem ENat.exists_nat_gt E1 #

∀ {n : ℕ∞}, n ≠ ⊤ → ∃ m, n < ↑m

theorem ENat.sub_eq_top_iff E0 #

∀ {a b : ℕ∞}, a - b = ⊤ ↔ a = ⊤ ∧ b ≠ ⊤

theorem ENat.sub_ne_top_iff E0 #

∀ {a b : ℕ∞}, a - b ≠ ⊤ ↔ a ≠ ⊤ ∨ b = ⊤

theorem ENat.addLECancellable_iff_ne_top E0 #

∀ {a : ℕ∞}, AddLECancellable a ↔ a ≠ ⊤

theorem ENat.addLECancellable_of_ne_top E1 #

∀ {a : ℕ∞}, a ≠ ⊤ → AddLECancellable a

theorem ENat.addLECancellable_of_lt_top E1 #

∀ {a : ℕ∞}, a < ⊤ → AddLECancellable a

theorem ENat.addLECancellable_natCast E1 #

∀ (a : ℕ), AddLECancellable ↑a

def ENat.map E1 #

{α : Type u_1} → (ℕ → α) → ℕ∞ → WithTop α

Specialization of WithTop.map to ENat.

theorem ENat.map_top E0 #

∀ {α : Type u_1} (f : ℕ → α), ENat.map f ⊤ = ⊤

theorem ENat.map_natCast E0 #

∀ {α : Type u_1} (f : ℕ → α) (a : ℕ), ENat.map f ↑a = ↑(f a)

theorem ENat.map_zero E0 #

∀ {α : Type u_1} (f : ℕ → α), ENat.map f 0 = ↑(f 0)

theorem ENat.map_one E0 #

∀ {α : Type u_1} (f : ℕ → α), ENat.map f 1 = ↑(f 1)

theorem ENat.map_ofNat E0 #

∀ {α : Type u_1} (f : ℕ → α) (n : ℕ) [inst : n.AtLeastTwo], ENat.map f (OfNat.ofNat n) = ↑(f n)

theorem ENat.map_eq_top_iff E0 #

∀ {n : ℕ∞} {α : Type u_1} {f : ℕ → α}, ENat.map f n = ⊤ ↔ n = ⊤

theorem ENat.strictMono_map_iff E0 #

∀ {α : Type u_1} {f : ℕ → α} [inst : Preorder α], StrictMono (ENat.map f) ↔ StrictMono f

theorem ENat.monotone_map_iff E0 #

∀ {α : Type u_1} {f : ℕ → α} [inst : Preorder α], Monotone (ENat.map f) ↔ Monotone f

theorem ENat.map_add E0 #

∀ {β : Type u_2} {F : Type u_3} [inst : Add β] [inst_1 : FunLike F ℕ β] [AddHomClass F ℕ β] (f : F) (a b : ℕ∞),
  ENat.map (⇑f) (a + b) = ENat.map (⇑f) a + ENat.map (⇑f) b

def OneHom.ENatMap E1 #

{N : Type u_2} → [inst : One N] → OneHom ℕ N → OneHom ℕ∞ (WithTop N)

A version of ENat.map for OneHoms.

def ZeroHom.ENatMap E1 #

{N : Type u_2} → [inst : Zero N] → ZeroHom ℕ N → ZeroHom ℕ∞ (WithTop N)

A version of ENat.map for ZeroHoms.

def AddHom.ENatMap E1 #

{N : Type u_2} → [inst : Add N] → (ℕ →ₙ+ N) → ℕ∞ →ₙ+ WithTop N

A version of WithTop.map for AddHoms.

theorem AddHom.ENatMap_apply E0 #

∀ {N : Type u_2} [inst : Add N] (f : ℕ →ₙ+ N), ⇑f.ENatMap = ENat.map ⇑f

theorem ENat.WithBot.coe_eq_natCast E0 #

∀ (n : ℕ), ↑↑n = ↑n

Deprecated aliases

NameNew nameSince
ENat.addLECancellable_coeENat.addLECancellable_natCast2026-07-17
ENat.coe_addENat.natCast_add2026-07-17
ENat.coe_injENat.natCast_inj2026-07-17
ENat.coe_le_coeENat.natCast_le_natCast2026-07-17
ENat.coe_liftENat.natCast_lift2026-07-17
ENat.coe_lt_coeENat.natCast_lt_natCast2026-07-17
ENat.coe_lt_topENat.natCast_lt_top2026-07-17
ENat.coe_ne_topENat.natCast_ne_top2026-07-17
ENat.coe_oneENat.natCast_one2026-07-17
ENat.coe_subENat.natCast_sub2026-07-17
ENat.coe_toNatENat.natCast_toNat2026-07-17
ENat.coe_toNat_eq_selfENat.natCast_toNat_eq_self2026-07-17
ENat.coe_toNat_le_selfENat.natCast_toNat_le_self2026-07-17
ENat.coe_zeroENat.natCast_zero2026-07-17
ENat.le_coe_iffENat.le_natCast_iff2026-07-17
ENat.lift_coeENat.lift_natCast2026-07-17
ENat.map_coeENat.map_natCast2026-07-17
ENat.some_eq_coeENat.some_eq_natCast2026-07-17
ENat.toNat_coeENat.toNat_natCast2026-07-17
ENat.toNat_eq_iff_eq_coeENat.toNat_eq_iff_eq_natCast2026-07-17
ENat.toNat_le_of_le_coeENat.toNat_le_of_le_natCast2026-07-17
ENat.top_ne_coeENat.top_ne_natCast2026-07-17
ENat.top_sub_coeENat.top_sub_natCast2026-07-17