# Documentation

Mathlib.Logic.Denumerable

# 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.

class Denumerable (α : Type u_3) extends :
Type u_3
• encode : α
• decode :
• encodek : ∀ (a : α),
• decode_inv : ∀ (n : ), a,

decode and encode are inverses.

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

Instances
theorem Denumerable.decode_isSome (α : Type u_3) [] (n : ) :
def Denumerable.ofNat (α : Type u_3) [] (n : ) :
α

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

Instances For
@[simp]
theorem Denumerable.decode_eq_ofNat (α : Type u_3) [] (n : ) :
@[simp]
theorem Denumerable.ofNat_of_decode {α : Type u_1} [] {n : } {b : α} (h : ) :
= b
@[simp]
theorem Denumerable.encode_ofNat {α : Type u_1} [] (n : ) :
@[simp]
theorem Denumerable.ofNat_encode {α : Type u_1} [] (a : α) :
def Denumerable.eqv (α : Type u_3) [] :
α

A denumerable type is equivalent to ℕ.

Instances For
instance Denumerable.instInfinite {α : Type u_1} [] :
def Denumerable.mk' {α : Type u_3} (e : α ) :

A type equivalent to ℕ is denumerable.

Instances For
def Denumerable.ofEquiv (α : Type u_3) {β : Type u_4} [] (e : β α) :

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

Instances For
@[simp]
theorem Denumerable.ofEquiv_ofNat (α : Type u_3) {β : Type u_4} [] (e : β α) (n : ) :
= e.symm ()
def Denumerable.equiv₂ (α : Type u_3) (β : Type u_4) [] [] :
α β

All denumerable types are equivalent.

Instances For
@[simp]
theorem Denumerable.ofNat_nat (n : ) :
instance Denumerable.option {α : Type u_1} [] :

If α is denumerable, then so is Option α.

instance Denumerable.sum {α : Type u_1} {β : Type u_2} [] [] :

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

instance Denumerable.sigma {α : Type u_1} [] {γ : αType u_3} [(a : α) → Denumerable (γ a)] :

A denumerable collection of denumerable types is denumerable.

@[simp]
theorem Denumerable.sigma_ofNat_val {α : Type u_1} [] {γ : αType u_3} [(a : α) → Denumerable (γ a)] (n : ) :
= { fst := Denumerable.ofNat α ().fst, snd := Denumerable.ofNat (γ (Denumerable.ofNat α ().fst)) ().snd }
instance Denumerable.prod {α : Type u_1} {β : Type u_2} [] [] :
Denumerable (α × β)

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

theorem Denumerable.prod_ofNat_val {α : Type u_1} {β : Type u_2} [] [] (n : ) :
Denumerable.ofNat (α × β) n = (Denumerable.ofNat α ().fst, Denumerable.ofNat β ().snd)
instance Denumerable.ulift {α : Type u_1} [] :

The lift of a denumerable type is denumerable.

instance Denumerable.plift {α : Type u_1} [] :

The lift of a denumerable type is denumerable.

def Denumerable.pair {α : Type u_1} [] :
α × α α

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

Instances For

### Subsets of ℕ#

theorem Nat.Subtype.exists_succ {s : } [Infinite s] (x : s) :
n, x + n + 1 s
def Nat.Subtype.succ {s : } [Infinite s] [DecidablePred fun x => x s] (x : s) :
s

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

Instances For
theorem Nat.Subtype.succ_le_of_lt {s : } [Infinite s] [DecidablePred fun x => x s] {x : s} {y : s} (h : y < x) :
theorem Nat.Subtype.le_succ_of_forall_lt_le {s : } [Infinite s] [DecidablePred fun x => x s] {x : s} {y : s} (h : ∀ (z : s), z < xz y) :
theorem Nat.Subtype.lt_succ_self {s : } [Infinite s] [DecidablePred fun x => x s] (x : s) :
theorem Nat.Subtype.lt_succ_iff_le {s : } [Infinite s] [DecidablePred fun x => x s] {x : s} {y : s} :
x y
def Nat.Subtype.ofNat (s : ) [DecidablePred fun x => x s] [Infinite s] :
s

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

Equations
Instances For
theorem Nat.Subtype.ofNat_surjective_aux {s : } [Infinite s] [DecidablePred fun x => x s] {x : } (hx : x s) :
n, = { val := x, property := hx }
theorem Nat.Subtype.ofNat_surjective {s : } [Infinite s] [DecidablePred fun x => x s] :
@[simp]
theorem Nat.Subtype.ofNat_range {s : } [Infinite s] [DecidablePred fun x => x s] :
= Set.univ
@[simp]
theorem Nat.Subtype.coe_comp_ofNat_range {s : } [Infinite s] [DecidablePred fun x => x s] :
Set.range (Subtype.val ) = s
def Nat.Subtype.denumerable (s : ) [DecidablePred fun x => x s] [Infinite s] :

Any infinite set of naturals is denumerable.

Instances For

An infinite encodable type is denumerable.

Instances For
theorem nonempty_denumerable (α : Type u_3) [] [] :

See also nonempty_encodable, nonempty_fintype.

instance nonempty_equiv_of_countable {α : Type u_1} {β : Type u_2} [] [] [] [] :
Nonempty (α β)