Countable sets #
A set is countable if there exists an encoding of the set into the natural numbers.
An encoding is an injection with a partial inverse, which can be viewed as a
constructive analogue of countability. (For the most part, theorems about
countable
will be classical and encodable
will be constructive.)
theorem
set.countable_iff_exists_injective
{α : Type u}
{s : set α} :
s.countable ↔ ∃ (f : ↥s → ℕ), function.injective f
theorem
set.countable_iff_exists_inj_on
{α : Type u}
{s : set α} :
s.countable ↔ ∃ (f : α → ℕ), set.inj_on f s
A set s : set α
is countable if and only if there exists a function α → ℕ
injective
on s
.
theorem
set.countable_iff_exists_surjective_to_subtype
{α : Type u}
{s : set α}
(hs : s.nonempty) :
s.countable ↔ ∃ (f : ℕ → ↥s), function.surjective f
A non-empty set is countable iff there exists a surjection from the natural numbers onto the subtype induced by the set.
Convert countable s
to encodable s
(noncomputable).
Equations
theorem
set.maps_to.countable_of_inj_on
{α : Type u}
{β : Type v}
{s : set α}
{t : set β}
{f : α → β}
(hf : set.maps_to f s t)
(hf' : set.inj_on f s)
(ht : t.countable) :
theorem
set.countable.preimage_of_inj_on
{α : Type u}
{β : Type v}
{s : set β}
(hs : s.countable)
{f : α → β}
(hf : set.inj_on f (f ⁻¹' s)) :
@[protected]
theorem
set.countable.preimage
{α : Type u}
{β : Type v}
{s : set β}
(hs : s.countable)
{f : α → β}
(hf : function.injective f) :
theorem
set.countable_of_injective_of_countable_image
{α : Type u}
{β : Type v}
{s : set α}
{f : α → β}
(hf : set.inj_on f s)
(hs : (f '' s).countable) :
theorem
set.countable_Union_Prop
{β : Type v}
{p : Prop}
{t : p → set β}
(ht : ∀ (h : p), (t h).countable) :
(⋃ (h : p), t h).countable
theorem
set.countable.image2
{α : Type u}
{β : Type v}
{γ : Type w}
{s : set α}
{t : set β}
(hs : s.countable)
(ht : t.countable)
(f : α → β → γ) :
(set.image2 f s t).countable
noncomputable
def
set.enumerate_countable
{α : Type u}
{s : set α}
(h : s.countable)
(default : α) :
ℕ → α
Enumerate elements in a countable set.
Equations
- set.enumerate_countable h default = λ (n : ℕ), set.enumerate_countable._match_1 default (encodable.decode ↥s n)
- set.enumerate_countable._match_1 default (some y) = ↑y
- set.enumerate_countable._match_1 default none = default
theorem
set.subset_range_enumerate
{α : Type u}
{s : set α}
(h : s.countable)
(default : α) :
s ⊆ set.range (set.enumerate_countable h default)