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 / V03. Sets, finite structures and big operators

Mathlib.Basic.Denumerable

50 declarations. Mathlib docs · Source

Denumerable types

This file defines denumerable (countably infinite) types as a typeclass extending Encodable. This is used to provide explicit encode/decode functions from and to ℕ, with the information that those functions are inverses of each other.

Implementation notes

This property already has a name, namely α ≃ ℕ, but here we are interested in using it as a typeclass.

Subsets of ℕ

theorem Nat.Subtype.succ.congr_simp E1 #

∀ {s : Set ℕ} [inst : Infinite ↑s] [inst_1 : DecidablePred fun x ↦ x ∈ s] (x x_1 : ↑s),
  x = x_1 → Nat.Subtype.succ x = Nat.Subtype.succ x_1

theorem Nat.Subtype.ofNat.match_1.congr_eq_2 E1 #

∀ (motive : ℕ → Sort u_1) (x : ℕ) (h_1 : Unit → motive 0) (h_2 : (n : ℕ) → motive n.succ) (n : ℕ),
  x = n.succ →
    (match x with
      | 0 => h_1 ()
      | n.succ => h_2 n) ≍
      h_2 n

theorem Nat.Subtype.ofNat.congr_simp E1 #

∀ (s : Set ℕ) [inst : DecidablePred fun x ↦ x ∈ s] [inst_1 : Infinite ↑s] (a a_1 : ℕ),
  a = a_1 → Nat.Subtype.ofNat s a = Nat.Subtype.ofNat s a_1

theorem Nat.Subtype.ofNat.match_1.congr_eq_1 E1 #

∀ (motive : ℕ → Sort u_1) (x : ℕ) (h_1 : Unit → motive 0) (h_2 : (n : ℕ) → motive n.succ),
  x = 0 →
    (match x with
      | 0 => h_1 ()
      | n.succ => h_2 n) ≍
      h_1 ()

def Denumerable.ctorIdx E1 #

{α : Type u_3} → Denumerable α → ℕ

class Denumerable E1 #

Type u_3 → Type u_3

A denumerable type is (constructively) bijective with ℕ. Typeclass equivalent of α ≃ ℕ.

ctor Denumerable.mk E0 #

{α : Type u_3} →
  [toEncodable : Encodable α] → (∀ (n : ℕ), ∃ a ∈ Encodable.decode n, Encodable.encode a = n) → Denumerable α

instance Denumerable.toEncodable E0 #

{α : Type u_3} → [self : Denumerable α] → Encodable α

theorem Denumerable.decode_inv E1 #

∀ {α : Type u_3} [self : Denumerable α] (n : ℕ), ∃ a ∈ Encodable.decode n, Encodable.encode a = n

decode and encode are inverses.

theorem Denumerable.decode_isSome E1 #

∀ (α : Type u_3) [inst : Denumerable α] (n : ℕ), (Encodable.decode n).isSome = true

def Denumerable.ofNat E1 #

(α : Type u_3) → [Denumerable α] → ℕ → α

Returns the n-th element of α indexed by the decoding.

theorem Denumerable.decode_eq_ofNat E0 #

∀ (α : Type u_3) [inst : Denumerable α] (n : ℕ), Encodable.decode n = some (Denumerable.ofNat α n)

theorem Denumerable.ofNat_of_decode E1 #

∀ {α : Type u_1} [inst : Denumerable α] {n : ℕ} {b : α}, Encodable.decode n = some b → Denumerable.ofNat α n = b

theorem Denumerable.encode_ofNat E0 #

∀ {α : Type u_1} [inst : Denumerable α] (n : ℕ), Encodable.encode (Denumerable.ofNat α n) = n

theorem Denumerable.ofNat_encode E0 #

∀ {α : Type u_1} [inst : Denumerable α] (a : α), Denumerable.ofNat α (Encodable.encode a) = a

def Denumerable.eqv E1 #

(α : Type u_3) → [Denumerable α] → α ≃ ℕ

A denumerable type is equivalent to ℕ.

instance Denumerable.instInfinite E0 #

∀ {α : Type u_1} [Denumerable α], Infinite α

def Denumerable.mk' E1 #

{α : Type u_3} → α ≃ ℕ → Denumerable α

A type equivalent to ℕ is denumerable.

def Denumerable.ofEquiv E1 #

(α : Type u_3) → {β : Type u_4} → [Denumerable α] → β ≃ α → Denumerable β

Denumerability is conserved by equivalences. This is transitivity of equivalence the denumerable way.

theorem Denumerable.ofEquiv_ofNat E0 #

∀ (α : Type u_3) {β : Type u_4} [inst : Denumerable α] (e : β ≃ α) (n : ℕ),
  Denumerable.ofNat β n = e.symm (Denumerable.ofNat α n)

def Denumerable.equiv₂ E1 #

(α : Type u_3) → (β : Type u_4) → [Denumerable α] → [Denumerable β] → α ≃ β

All denumerable types are equivalent.

instance Denumerable.nat E0 #

Denumerable ℕ

theorem Denumerable.ofNat_nat E0 #

∀ (n : ℕ), Denumerable.ofNat ℕ n = n

instance Denumerable.option E0 #

{α : Type u_1} → [Denumerable α] → Denumerable (Option α)

If α is denumerable, then so is Option α.

instance Denumerable.sum E0 #

{α : Type u_1} → {β : Type u_2} → [Denumerable α] → [Denumerable β] → Denumerable (α ⊕ β)

If α and β are denumerable, then so is their sum.

instance Denumerable.sigma E0 #

{α : Type u_1} → [Denumerable α] → {γ : α → Type u_3} → [(a : α) → Denumerable (γ a)] → Denumerable (Sigma γ)

A denumerable collection of denumerable types is denumerable.

theorem Denumerable.sigma_ofNat_val E0 #

∀ {α : Type u_1} [inst : Denumerable α] {γ : α → Type u_3} [inst_1 : (a : α) → Denumerable (γ a)] (n : ℕ),
  Denumerable.ofNat (Sigma γ) n =
    ⟨Denumerable.ofNat α (Nat.unpair n).1,
      Denumerable.ofNat (γ (Denumerable.ofNat α (Nat.unpair n).1)) (Nat.unpair n).2⟩

instance Denumerable.prod E0 #

{α : Type u_1} → {β : Type u_2} → [Denumerable α] → [Denumerable β] → Denumerable (α × β)

If α and β are denumerable, then so is their product.

theorem Denumerable.prod_ofNat_val E0 #

∀ {α : Type u_1} {β : Type u_2} [inst : Denumerable α] [inst_1 : Denumerable β] (n : ℕ),
  Denumerable.ofNat (α × β) n = (Denumerable.ofNat α (Nat.unpair n).1, Denumerable.ofNat β (Nat.unpair n).2)

theorem Denumerable.prod_nat_ofNat E0 #

Denumerable.ofNat (ℕ × ℕ) = Nat.unpair

instance Denumerable.int E0 #

Denumerable ℤ

instance Denumerable.pnat E0 #

Denumerable ℕ+

instance Denumerable.ulift E0 #

{α : Type u_1} → [Denumerable α] → Denumerable (ULift.{u_3, u_1} α)

The lift of a denumerable type is denumerable.

instance Denumerable.plift E0 #

{α : Type u_1} → [Denumerable α] → Denumerable (PLift α)

The lift of a denumerable type is denumerable.

def Denumerable.pair E1 #

{α : Type u_1} → [Denumerable α] → α × α ≃ α

If α is denumerable, then α × α and α are equivalent.

theorem Nat.Subtype.exists_succ E1 #

∀ {s : Set ℕ} [Infinite ↑s] (x : ↑s), ∃ n, ↑x + n + 1 ∈ s

def Nat.Subtype.succ E1 #

{s : Set ℕ} → [Infinite ↑s] → [DecidablePred fun x ↦ x ∈ s] → ↑s → ↑s

Returns the next natural in a set, according to the usual ordering of ℕ.

theorem Nat.Subtype.succ_le_of_lt E1 #

∀ {s : Set ℕ} [inst : Infinite ↑s] [inst_1 : DecidablePred fun x ↦ x ∈ s] {x y : ↑s}, y < x → Nat.Subtype.succ y ≤ x

theorem Nat.Subtype.le_succ_of_forall_lt_le E1 #

∀ {s : Set ℕ} [inst : Infinite ↑s] [inst_1 : DecidablePred fun x ↦ x ∈ s] {x y : ↑s},
  (∀ z < x, z ≤ y) → x ≤ Nat.Subtype.succ y

theorem Nat.Subtype.lt_succ_self E1 #

∀ {s : Set ℕ} [inst : Infinite ↑s] [inst_1 : DecidablePred fun x ↦ x ∈ s] (x : ↑s), x < Nat.Subtype.succ x

theorem Nat.Subtype.lt_succ_iff_le E1 #

∀ {s : Set ℕ} [inst : Infinite ↑s] [inst_1 : DecidablePred fun x ↦ x ∈ s] {x y : ↑s}, x < Nat.Subtype.succ y ↔ x ≤ y

def Nat.Subtype.ofNat E1 #

(s : Set ℕ) → [DecidablePred fun x ↦ x ∈ s] → [Infinite ↑s] → ℕ → ↑s

Returns the n-th element of a set, according to the usual ordering of ℕ.

theorem Nat.Subtype.ofNat_surjective E1 #

∀ {s : Set ℕ} [inst : Infinite ↑s] [inst_1 : DecidablePred fun x ↦ x ∈ s], Function.Surjective (Nat.Subtype.ofNat s)

theorem Nat.Subtype.ofNat_range E0 #

∀ {s : Set ℕ} [inst : Infinite ↑s] [inst_1 : DecidablePred fun x ↦ x ∈ s], Set.range (Nat.Subtype.ofNat s) = Set.univ

theorem Nat.Subtype.coe_comp_ofNat_range E0 #

∀ {s : Set ℕ} [inst : Infinite ↑s] [inst_1 : DecidablePred fun x ↦ x ∈ s],
  Set.range (Subtype.val ∘ Nat.Subtype.ofNat s) = s

def Nat.Subtype.denumerable E1 #

(s : Set ℕ) → [DecidablePred fun x ↦ x ∈ s] → [Infinite ↑s] → Denumerable ↑s

Any infinite set of naturals is denumerable.

def Denumerable.ofEncodableOfInfinite E1 #

(α : Type u_3) → [Encodable α] → [Infinite α] → Denumerable α

An infinite encodable type is denumerable.

theorem nonempty_denumerable E1 #

∀ (α : Type u_3) [Countable α] [Infinite α], Nonempty (Denumerable α)

See also nonempty_encodable, nonempty_fintype.

theorem nonempty_denumerable_iff E0 #

∀ {α : Type u_3}, Nonempty (Denumerable α) ↔ Countable α ∧ Infinite α

instance nonempty_equiv_of_countable E0 #

∀ {α : Type u_1} {β : Type u_2} [Countable α] [Infinite α] [Countable β] [Infinite β], Nonempty (α ≃ β)