doc-next-gen

Mathlib.Data.Set.Countable

Module docstring

{"# Countable sets

In this file we define Set.Countable s as Countable s and prove basic properties of this definition.

Note that this definition does not provide a computable encoding. For a noncomputable conversion to Encodable s, use Set.Countable.nonempty_encodable.

Keywords

sets, countable set "}

Set.Countable definition
(s : Set α) : Prop
Full source
/-- A set `s` is countable if the corresponding subtype is countable,
i.e., there exists an injective map `f : s → ℕ`.

Note that this is an abbreviation, so `hs : Set.Countable s` in the proof context
is the same as an instance `Countable s`.
For a constructive version, see `Encodable`.
-/
protected def Countable (s : Set α) : Prop := Countable s
Countable set
Informal description
A set \( s \) is called *countable* if there exists an injective function \( f : s \to \mathbb{N} \). This is equivalent to saying that the subtype corresponding to \( s \) is countable.
Set.countable_coe_iff theorem
{s : Set α} : Countable s ↔ s.Countable
Full source
@[simp]
theorem countable_coe_iff {s : Set α} : CountableCountable s ↔ s.Countable := .rfl
Equivalence of Countable Typeclass and Set Countability Predicate
Informal description
For any set $s$ of type $\alpha$, the set $s$ is countable (in the sense of the `Countable` typeclass) if and only if $s$ satisfies the `Set.Countable` predicate.
Set.to_countable theorem
(s : Set α) [Countable s] : s.Countable
Full source
/-- Prove `Set.Countable` from a `Countable` instance on the subtype. -/
theorem to_countable (s : Set α) [Countable s] : s.Countable := ‹_›
Countability of Set from Countable Subtype
Informal description
For any set $s$ of type $\alpha$, if the subtype corresponding to $s$ is countable, then $s$ is a countable set.
Set.countable_iff_exists_injOn theorem
{s : Set α} : s.Countable ↔ ∃ f : α → ℕ, InjOn f s
Full source
/-- A set `s : Set α` is countable if and only if there exists a function `α → ℕ` injective
on `s`. -/
theorem countable_iff_exists_injOn {s : Set α} : s.Countable ↔ ∃ f : α → ℕ, InjOn f s :=
  Set.countable_iff_exists_injective.trans exists_injOn_iff_injective.symm
Characterization of Countable Sets via Partial Injections to Natural Numbers
Informal description
A set $s$ in a type $\alpha$ is countable if and only if there exists a function $f : \alpha \to \mathbb{N}$ that is injective when restricted to $s$.
Set.Countable.toEncodable definition
{s : Set α} (hs : s.Countable) : Encodable s
Full source
/-- Convert `Set.Countable s` to `Encodable s` (noncomputable). -/
protected def Countable.toEncodable {s : Set α} (hs : s.Countable) : Encodable s :=
  Classical.choice hs.nonempty_encodable
Noncomputable encodable structure on a countable set
Informal description
Given a countable set \( s \), this noncomputable function produces an encodable structure on \( s \), i.e., it provides an encoding function \( \text{encode} : s \to \mathbb{N} \) and a partial inverse \( \text{decode} : \mathbb{N} \to \text{Option } s \).
Set.enumerateCountable definition
{s : Set α} (h : s.Countable) (default : α) : ℕ → α
Full source
/-- Noncomputably enumerate elements in a set. The `default` value is used to extend the domain to
all of `ℕ`. -/
def enumerateCountable {s : Set α} (h : s.Countable) (default : α) :  → α := fun n =>
  match @Encodable.decode s h.toEncodable n with
  | some y => y
  | none => default
Noncomputable enumeration of a countable set with default value
Informal description
Given a countable set \( s \) in a type \( \alpha \) and a default element `default` of \( \alpha \), the function `Set.enumerateCountable` noncomputably enumerates the elements of \( s \) by mapping each natural number \( n \) to the corresponding element of \( s \) if it exists (using the encoding provided by `h.toEncodable`), and to `default` otherwise. The resulting sequence satisfies: 1. \( s \) is a subset of the range of this enumeration (modulo the default value) 2. The range of this enumeration is contained in \( s \) union the default value.
Set.subset_range_enumerate theorem
{s : Set α} (h : s.Countable) (default : α) : s ⊆ range (enumerateCountable h default)
Full source
theorem subset_range_enumerate {s : Set α} (h : s.Countable) (default : α) :
    s ⊆ range (enumerateCountable h default) := fun x hx =>
  ⟨@Encodable.encode s h.toEncodable ⟨x, hx⟩, by
    letI := h.toEncodable
    simp [enumerateCountable, Encodable.encodek]⟩
Countable Set is Subset of its Enumeration Range
Informal description
For any countable set $s$ in a type $\alpha$ and any default element $\text{default} \in \alpha$, the set $s$ is a subset of the range of the enumeration function $\text{enumerateCountable}\ h\ \text{default} : \mathbb{N} \to \alpha$.
Set.range_enumerateCountable_subset theorem
{s : Set α} (h : s.Countable) (default : α) : range (enumerateCountable h default) ⊆ insert default s
Full source
lemma range_enumerateCountable_subset {s : Set α} (h : s.Countable) (default : α) :
    rangerange (enumerateCountable h default) ⊆ insert default s := by
  refine range_subset_iff.mpr (fun n ↦ ?_)
  rw [enumerateCountable]
  match @decode s (Countable.toEncodable h) n with
  | none => exact mem_insert _ _
  | some val => simp
Range of Countable Enumeration is Subset of Set Union Default Element
Informal description
For any countable set $s$ in a type $\alpha$ and any default element $\mathrm{default} \in \alpha$, the range of the enumeration function $\mathrm{enumerateCountable}\ h\ \mathrm{default}$ is contained in the set $s$ union $\{\mathrm{default}\}$.
Set.range_enumerateCountable_of_mem theorem
{s : Set α} (h : s.Countable) {default : α} (h_mem : default ∈ s) : range (enumerateCountable h default) = s
Full source
lemma range_enumerateCountable_of_mem {s : Set α} (h : s.Countable) {default : α}
    (h_mem : default ∈ s) :
    range (enumerateCountable h default) = s :=
  subset_antisymm ((range_enumerateCountable_subset h _).trans_eq (insert_eq_of_mem h_mem))
    (subset_range_enumerate h default)
Range of Countable Enumeration Equals Set When Default is in Set
Informal description
For any countable set $s$ in a type $\alpha$ and any default element $\mathrm{default} \in s$, the range of the enumeration function $\mathrm{enumerateCountable}\ h\ \mathrm{default}$ is equal to $s$.
Set.enumerateCountable_mem theorem
{s : Set α} (h : s.Countable) {default : α} (h_mem : default ∈ s) (n : ℕ) : enumerateCountable h default n ∈ s
Full source
lemma enumerateCountable_mem {s : Set α} (h : s.Countable) {default : α} (h_mem : default ∈ s)
    (n : ) :
    enumerateCountableenumerateCountable h default n ∈ s := by
  convert mem_range_self n
  exact (range_enumerateCountable_of_mem h h_mem).symm
All Enumerated Elements Belong to Countable Set When Default Does
Informal description
For any countable set $s$ in a type $\alpha$, if the default element $\mathrm{default}$ belongs to $s$, then for every natural number $n$, the $n$-th element of the enumeration $\mathrm{enumerateCountable}\ h\ \mathrm{default}$ is also in $s$.
Set.Countable.mono theorem
{s₁ s₂ : Set α} (h : s₁ ⊆ s₂) (hs : s₂.Countable) : s₁.Countable
Full source
theorem Countable.mono {s₁ s₂ : Set α} (h : s₁ ⊆ s₂) (hs : s₂.Countable) : s₁.Countable :=
  have := hs.to_subtype; (inclusion_injective h).countable
Countability is Preserved Under Subsets
Informal description
For any two sets $s_1$ and $s_2$ in a type $\alpha$, if $s_1$ is a subset of $s_2$ (i.e., $s_1 \subseteq s_2$) and $s_2$ is countable, then $s_1$ is also countable.
Set.countable_range theorem
[Countable ι] (f : ι → β) : (range f).Countable
Full source
theorem countable_range [Countable ι] (f : ι → β) : (range f).Countable :=
  surjective_onto_range.countable.to_set
Countability of the Range of a Function from a Countable Domain
Informal description
For any countable type $\iota$ and any function $f \colon \iota \to \beta$, the range of $f$ is a countable set.
Set.countable_iff_exists_subset_range theorem
[Nonempty α] {s : Set α} : s.Countable ↔ ∃ f : ℕ → α, s ⊆ range f
Full source
theorem countable_iff_exists_subset_range [Nonempty α] {s : Set α} :
    s.Countable ↔ ∃ f : ℕ → α, s ⊆ range f :=
  ⟨fun h => by
    inhabit α
    exact ⟨enumerateCountable h default, subset_range_enumerate _ _⟩, fun ⟨f, hsf⟩ =>
    (countable_range f).mono hsf⟩
Characterization of Countable Sets via Functions from Natural Numbers
Informal description
For a nonempty type $\alpha$ and a set $s \subseteq \alpha$, the set $s$ is countable if and only if there exists a function $f \colon \mathbb{N} \to \alpha$ such that $s$ is a subset of the range of $f$.
Set.countable_iff_exists_surjective theorem
{s : Set α} (hs : s.Nonempty) : s.Countable ↔ ∃ f : ℕ → s, Surjective f
Full source
/-- A non-empty set is countable iff there exists a surjection from the
natural numbers onto the subtype induced by the set.
-/
protected theorem countable_iff_exists_surjective {s : Set α} (hs : s.Nonempty) :
    s.Countable ↔ ∃ f : ℕ → s, Surjective f :=
  @countable_iff_exists_surjective s hs.to_subtype
Characterization of Countable Sets via Surjections from Natural Numbers
Informal description
A non-empty set $s$ in a type $\alpha$ is countable if and only if there exists a surjective function $f \colon \mathbb{N} \to s$.
Set.countable_univ theorem
[Countable α] : (univ : Set α).Countable
Full source
theorem countable_univ [Countable α] : (univ : Set α).Countable :=
  to_countable univ
Countability of the Universal Set for Countable Types
Informal description
If the type $\alpha$ is countable, then the universal set $\text{univ} : \text{Set } \alpha$ is countable.
Set.Countable.exists_eq_range theorem
{s : Set α} (hc : s.Countable) (hs : s.Nonempty) : ∃ f : ℕ → α, s = range f
Full source
/-- If `s : Set α` is a nonempty countable set, then there exists a map
`f : ℕ → α` such that `s = range f`. -/
theorem Countable.exists_eq_range {s : Set α} (hc : s.Countable) (hs : s.Nonempty) :
    ∃ f : ℕ → α, s = range f := by
  rcases hc.exists_surjective hs with ⟨f, hf⟩
  refine ⟨(↑) ∘ f, ?_⟩
  rw [hf.range_comp, Subtype.range_coe]
Countable Set as Range of a Function from Naturals
Informal description
For any nonempty countable set $s \subseteq \alpha$, there exists a function $f \colon \mathbb{N} \to \alpha$ such that $s$ is equal to the range of $f$, i.e., $s = \{f(n) \mid n \in \mathbb{N}\}$.
Set.countable_empty theorem
: (∅ : Set α).Countable
Full source
@[simp] theorem countable_empty : ( : Set α).Countable := to_countable _
Countability of the Empty Set
Informal description
The empty set $\emptyset$ is countable.
Set.countable_singleton theorem
(a : α) : ({ a } : Set α).Countable
Full source
@[simp] theorem countable_singleton (a : α) : ({a} : Set α).Countable := to_countable _
Countability of Singleton Sets
Informal description
For any element $a$ of type $\alpha$, the singleton set $\{a\}$ is countable.
Set.Countable.image theorem
{s : Set α} (hs : s.Countable) (f : α → β) : (f '' s).Countable
Full source
theorem Countable.image {s : Set α} (hs : s.Countable) (f : α → β) : (f '' s).Countable := by
  rw [image_eq_range]
  have := hs.to_subtype
  apply countable_range
Countability of Image under Function from Countable Set
Informal description
For any countable set $s \subseteq \alpha$ and any function $f : \alpha \to \beta$, the image $f(s)$ is countable.
Set.MapsTo.countable_of_injOn theorem
{s : Set α} {t : Set β} {f : α → β} (hf : MapsTo f s t) (hf' : InjOn f s) (ht : t.Countable) : s.Countable
Full source
theorem MapsTo.countable_of_injOn {s : Set α} {t : Set β} {f : α → β} (hf : MapsTo f s t)
    (hf' : InjOn f s) (ht : t.Countable) : s.Countable :=
  have := ht.to_subtype
  have : Injective (hf.restrict f s t) := (injOn_iff_injective.1 hf').codRestrict _
  this.countable
Countability of Domain via Injective Mapping to Countable Codomain
Informal description
Let $s$ be a set in $\alpha$ and $t$ a set in $\beta$. Given a function $f : \alpha \to \beta$ such that $f$ maps $s$ into $t$ (i.e., $f(s) \subseteq t$), if $f$ is injective on $s$ and $t$ is countable, then $s$ is also countable.
Set.Countable.preimage_of_injOn theorem
{s : Set β} (hs : s.Countable) {f : α → β} (hf : InjOn f (f ⁻¹' s)) : (f ⁻¹' s).Countable
Full source
theorem Countable.preimage_of_injOn {s : Set β} (hs : s.Countable) {f : α → β}
    (hf : InjOn f (f ⁻¹' s)) : (f ⁻¹' s).Countable :=
  (mapsTo_preimage f s).countable_of_injOn hf hs
Countability of Preimage under Injective Restriction
Informal description
Let $s$ be a countable subset of $\beta$ and $f : \alpha \to \beta$ a function. If $f$ is injective on the preimage $f^{-1}(s)$, then the preimage $f^{-1}(s)$ is countable.
Set.Countable.preimage theorem
{s : Set β} (hs : s.Countable) {f : α → β} (hf : Injective f) : (f ⁻¹' s).Countable
Full source
protected theorem Countable.preimage {s : Set β} (hs : s.Countable) {f : α → β} (hf : Injective f) :
    (f ⁻¹' s).Countable :=
  hs.preimage_of_injOn hf.injOn
Countability of Preimage under Injective Function
Informal description
Let $s$ be a countable subset of $\beta$ and $f : \alpha \to \beta$ an injective function. Then the preimage $f^{-1}(s)$ is countable.
Set.exists_seq_iSup_eq_top_iff_countable theorem
[CompleteLattice α] {p : α → Prop} (h : ∃ x, p x) : (∃ s : ℕ → α, (∀ n, p (s n)) ∧ ⨆ n, s n = ⊤) ↔ ∃ S : Set α, S.Countable ∧ (∀ s ∈ S, p s) ∧ sSup S = ⊤
Full source
theorem exists_seq_iSup_eq_top_iff_countable [CompleteLattice α] {p : α → Prop} (h : ∃ x, p x) :
    (∃ s : ℕ → α, (∀ n, p (s n)) ∧ ⨆ n, s n = ⊤) ↔
      ∃ S : Set α, S.Countable ∧ (∀ s ∈ S, p s) ∧ sSup S = ⊤ := by
  constructor
  · rintro ⟨s, hps, hs⟩
    refine ⟨range s, countable_range s, forall_mem_range.2 hps, ?_⟩
    rwa [sSup_range]
  · rintro ⟨S, hSc, hps, hS⟩
    rcases eq_empty_or_nonempty S with (rfl | hne)
    · rw [sSup_empty] at hS
      haveI := subsingleton_of_bot_eq_top hS
      rcases h with ⟨x, hx⟩
      exact ⟨fun _ => x, fun _ => hx, Subsingleton.elim _ _⟩
    · rcases (Set.countable_iff_exists_surjective hne).1 hSc with ⟨s, hs⟩
      refine ⟨fun n => s n, fun n => hps _ (s n).coe_prop, ?_⟩
      rwa [hs.iSup_comp, ← sSup_eq_iSup']
Characterization of Countable Suprema in Complete Lattices
Informal description
Let $\alpha$ be a complete lattice and $p$ a predicate on $\alpha$ such that there exists some $x \in \alpha$ satisfying $p(x)$. Then the following are equivalent: 1. There exists a sequence $(s_n)_{n \in \mathbb{N}}$ in $\alpha$ such that $p(s_n)$ holds for all $n$ and $\sup_{n} s_n = \top$. 2. There exists a countable subset $S \subseteq \alpha$ such that $p(s)$ holds for all $s \in S$ and $\sup S = \top$.
Set.exists_seq_cover_iff_countable theorem
{p : Set α → Prop} (h : ∃ s, p s) : (∃ s : ℕ → Set α, (∀ n, p (s n)) ∧ ⋃ n, s n = univ) ↔ ∃ S : Set (Set α), S.Countable ∧ (∀ s ∈ S, p s) ∧ ⋃₀ S = univ
Full source
theorem exists_seq_cover_iff_countable {p : Set α → Prop} (h : ∃ s, p s) :
    (∃ s : ℕ → Set α, (∀ n, p (s n)) ∧ ⋃ n, s n = univ) ↔
      ∃ S : Set (Set α), S.Countable ∧ (∀ s ∈ S, p s) ∧ ⋃₀ S = univ :=
  exists_seq_iSup_eq_top_iff_countable h
Characterization of Countable Covers via Sequences
Informal description
Let $p$ be a predicate on subsets of a type $\alpha$ such that there exists some subset $s \subseteq \alpha$ satisfying $p(s)$. Then the following are equivalent: 1. There exists a sequence $(s_n)_{n \in \mathbb{N}}$ of subsets of $\alpha$ such that $p(s_n)$ holds for all $n$ and $\bigcup_{n} s_n = \alpha$. 2. There exists a countable family $S$ of subsets of $\alpha$ such that $p(s)$ holds for all $s \in S$ and $\bigcup S = \alpha$.
Set.countable_of_injective_of_countable_image theorem
{s : Set α} {f : α → β} (hf : InjOn f s) (hs : (f '' s).Countable) : s.Countable
Full source
theorem countable_of_injective_of_countable_image {s : Set α} {f : α → β} (hf : InjOn f s)
    (hs : (f '' s).Countable) : s.Countable :=
  (mapsTo_image _ _).countable_of_injOn hf hs
Countability via injective image
Informal description
Let $s$ be a set in $\alpha$ and $f : \alpha \to \beta$ a function. If $f$ is injective on $s$ and the image $f(s)$ is countable, then $s$ is countable.
Set.countable_iUnion theorem
{t : ι → Set α} [Countable ι] (ht : ∀ i, (t i).Countable) : (⋃ i, t i).Countable
Full source
theorem countable_iUnion {t : ι → Set α} [Countable ι] (ht : ∀ i, (t i).Countable) :
    (⋃ i, t i).Countable := by
  have := fun i ↦ (ht i).to_subtype
  rw [iUnion_eq_range_psigma]
  apply countable_range
Countability of Union of Countable Sets over Countable Index
Informal description
Let $\{t_i\}_{i \in \iota}$ be a family of sets indexed by a countable type $\iota$. If each set $t_i$ is countable, then their union $\bigcup_{i \in \iota} t_i$ is also countable.
Set.countable_iUnion_iff theorem
[Countable ι] {t : ι → Set α} : (⋃ i, t i).Countable ↔ ∀ i, (t i).Countable
Full source
@[simp]
theorem countable_iUnion_iff [Countable ι] {t : ι → Set α} :
    (⋃ i, t i).Countable ↔ ∀ i, (t i).Countable :=
  ⟨fun h _ => h.mono <| subset_iUnion _ _, countable_iUnion⟩
Countability of Union of Sets over Countable Index is Equivalent to Countability of Each Set
Informal description
Let $\{t_i\}_{i \in \iota}$ be a family of sets indexed by a countable type $\iota$. Then the union $\bigcup_{i \in \iota} t_i$ is countable if and only if each set $t_i$ is countable.
Set.Countable.biUnion_iff theorem
{s : Set α} {t : ∀ a ∈ s, Set β} (hs : s.Countable) : (⋃ a ∈ s, t a ‹_›).Countable ↔ ∀ a (ha : a ∈ s), (t a ha).Countable
Full source
theorem Countable.biUnion_iff {s : Set α} {t : ∀ a ∈ s, Set β} (hs : s.Countable) :
    (⋃ a ∈ s, t a ‹_›).Countable ↔ ∀ a (ha : a ∈ s), (t a ha).Countable := by
  have := hs.to_subtype
  rw [biUnion_eq_iUnion, countable_iUnion_iff, SetCoe.forall']
Countability of Union over Countable Index Set is Equivalent to Countability of Each Fiber
Informal description
Let $s$ be a countable set in a type $\alpha$, and for each $a \in s$, let $t_a$ be a set in a type $\beta$. Then the union $\bigcup_{a \in s} t_a$ is countable if and only if for every $a \in s$, the set $t_a$ is countable.
Set.Countable.sUnion_iff theorem
{s : Set (Set α)} (hs : s.Countable) : (⋃₀ s).Countable ↔ ∀ a ∈ s, a.Countable
Full source
theorem Countable.sUnion_iff {s : Set (Set α)} (hs : s.Countable) :
    (⋃₀ s).Countable ↔ ∀ a ∈ s, a.Countable := by rw [sUnion_eq_biUnion, hs.biUnion_iff]
Countability of Union of Countable Family is Equivalent to Countability of Each Member
Informal description
Let $s$ be a countable family of sets in a type $\alpha$. Then the union $\bigcup_{a \in s} a$ is countable if and only if every set $a \in s$ is countable.
Set.Countable.union theorem
{s t : Set α} (hs : s.Countable) (ht : t.Countable) : (s ∪ t).Countable
Full source
theorem Countable.union {s t : Set α} (hs : s.Countable) (ht : t.Countable) : (s ∪ t).Countable :=
  countable_union.2 ⟨hs, ht⟩
Countability of Union of Countable Sets
Informal description
For any two sets $s$ and $t$ in a type $\alpha$, if $s$ is countable and $t$ is countable, then their union $s \cup t$ is countable.
Set.Countable.of_diff theorem
{s t : Set α} (h : (s \ t).Countable) (ht : t.Countable) : s.Countable
Full source
theorem Countable.of_diff {s t : Set α} (h : (s \ t).Countable) (ht : t.Countable) : s.Countable :=
  (h.union ht).mono (subset_diff_union _ _)
Countability of Set via Difference and Countable Subset
Informal description
For any two sets $s$ and $t$ in a type $\alpha$, if the set difference $s \setminus t$ is countable and $t$ is countable, then $s$ is countable.
Set.countable_insert theorem
{s : Set α} {a : α} : (insert a s).Countable ↔ s.Countable
Full source
@[simp]
theorem countable_insert {s : Set α} {a : α} : (insert a s).Countable ↔ s.Countable := by
  simp only [insert_eq, countable_union, countable_singleton, true_and]
Countability of Set Insertion: $\{a\} \cup s$ is countable iff $s$ is countable
Informal description
For any set $s$ and element $a$, the set obtained by inserting $a$ into $s$ is countable if and only if $s$ itself is countable.
Set.Countable.insert theorem
{s : Set α} (a : α) (h : s.Countable) : (insert a s).Countable
Full source
protected theorem Countable.insert {s : Set α} (a : α) (h : s.Countable) : (insert a s).Countable :=
  countable_insert.2 h
Countability is preserved under insertion of an element
Informal description
For any set $s$ and element $a$, if $s$ is countable, then the set obtained by inserting $a$ into $s$ is also countable.
Set.Finite.countable theorem
{s : Set α} (hs : s.Finite) : s.Countable
Full source
theorem Finite.countable {s : Set α} (hs : s.Finite) : s.Countable :=
  have := hs.to_subtype; s.to_countable
Finite sets are countable
Informal description
For any finite set $s$ of type $\alpha$, the set $s$ is countable.
Set.Countable.of_subsingleton theorem
[Subsingleton α] (s : Set α) : s.Countable
Full source
@[nontriviality]
theorem Countable.of_subsingleton [Subsingleton α] (s : Set α) : s.Countable :=
  (Finite.of_subsingleton s).countable
Countability of Subsets of a Subsingleton Type
Informal description
For any type $\alpha$ that is a subsingleton (i.e., all elements are equal), any subset $s$ of $\alpha$ is countable.
Set.Subsingleton.countable theorem
{s : Set α} (hs : s.Subsingleton) : s.Countable
Full source
theorem Subsingleton.countable {s : Set α} (hs : s.Subsingleton) : s.Countable :=
  hs.finite.countable
Countability of Subsingleton Sets
Informal description
For any set $s$ in a type $\alpha$, if $s$ is a subsingleton (i.e., contains at most one element), then $s$ is countable.
Set.countable_isTop theorem
(α : Type*) [PartialOrder α] : {x : α | IsTop x}.Countable
Full source
theorem countable_isTop (α : Type*) [PartialOrder α] : { x : α | IsTop x }.Countable :=
  (finite_isTop α).countable
Countability of Top Elements in a Partial Order
Informal description
For any type $\alpha$ equipped with a partial order, the set $\{x \in \alpha \mid x \text{ is a top element}\}$ is countable, where a top element is an element that is greater than or equal to all other elements in $\alpha$.
Set.countable_isBot theorem
(α : Type*) [PartialOrder α] : {x : α | IsBot x}.Countable
Full source
theorem countable_isBot (α : Type*) [PartialOrder α] : { x : α | IsBot x }.Countable :=
  (finite_isBot α).countable
Countability of Bottom Elements in a Partial Order
Informal description
For any type $\alpha$ equipped with a partial order, the set of bottom elements (i.e., elements that are less than or equal to all other elements in $\alpha$) is countable.
Set.countable_setOf_finite_subset theorem
{s : Set α} (hs : s.Countable) : {t | Set.Finite t ∧ t ⊆ s}.Countable
Full source
/-- The set of finite subsets of a countable set is countable. -/
theorem countable_setOf_finite_subset {s : Set α} (hs : s.Countable) :
    { t | Set.Finite t ∧ t ⊆ s }.Countable := by
  have := hs.to_subtype
  refine (countable_range fun t : Finset s => Subtype.valSubtype.val '' (t : Set s)).mono ?_
  rintro t ⟨ht, hts⟩
  lift t to Set s using hts
  lift t to Finset s using ht.of_finite_image Subtype.val_injective.injOn
  exact mem_range_self _
Countability of Finite Subsets of a Countable Set
Informal description
For any countable set $s \subseteq \alpha$, the collection of all finite subsets of $s$ is countable.
Set.countable_univ_pi theorem
{π : α → Type*} [Finite α] {s : ∀ a, Set (π a)} (hs : ∀ a, (s a).Countable) : (pi univ s).Countable
Full source
theorem countable_univ_pi {π : α → Type*} [Finite α] {s : ∀ a, Set (π a)}
    (hs : ∀ a, (s a).Countable) : (pi univ s).Countable :=
  have := fun a ↦ (hs a).to_subtype; .of_equiv _ (Equiv.Set.univPi s).symm
Countability of Product of Countable Sets over Finite Index Type
Informal description
Let $\alpha$ be a finite type and for each $a \in \alpha$, let $s(a)$ be a countable subset of $\pi(a)$. Then the product set $\prod_{a \in \alpha} s(a)$ is countable.
Set.countable_pi theorem
{π : α → Type*} [Finite α] {s : ∀ a, Set (π a)} (hs : ∀ a, (s a).Countable) : {f : ∀ a, π a | ∀ a, f a ∈ s a}.Countable
Full source
theorem countable_pi {π : α → Type*} [Finite α] {s : ∀ a, Set (π a)} (hs : ∀ a, (s a).Countable) :
    { f : ∀ a, π a | ∀ a, f a ∈ s a }.Countable := by
  simpa only [← mem_univ_pi] using countable_univ_pi hs
Countability of Function Space with Countable Codomains over Finite Index Type
Informal description
Let $\alpha$ be a finite type and for each $a \in \alpha$, let $s(a)$ be a countable subset of $\pi(a)$. Then the set of functions $\{f : \prod_{a \in \alpha} \pi(a) \mid \forall a, f(a) \in s(a)\}$ is countable.
Set.Countable.prod theorem
{s : Set α} {t : Set β} (hs : s.Countable) (ht : t.Countable) : Set.Countable (s ×ˢ t)
Full source
protected theorem Countable.prod {s : Set α} {t : Set β} (hs : s.Countable) (ht : t.Countable) :
    Set.Countable (s ×ˢ t) :=
  have := hs.to_subtype; have := ht.to_subtype; .of_equiv _ <| (Equiv.Set.prod _ _).symm
Countability of Cartesian Product of Countable Sets
Informal description
For any countable sets $s \subseteq \alpha$ and $t \subseteq \beta$, the Cartesian product $s \times t$ is also countable.
Set.Countable.image2 theorem
{s : Set α} {t : Set β} (hs : s.Countable) (ht : t.Countable) (f : α → β → γ) : (image2 f s t).Countable
Full source
theorem Countable.image2 {s : Set α} {t : Set β} (hs : s.Countable) (ht : t.Countable)
    (f : α → β → γ) : (image2 f s t).Countable := by
  rw [← image_prod]
  exact (hs.prod ht).image _
Countability of Image under Binary Function from Countable Sets
Informal description
For any countable sets $s \subseteq \alpha$ and $t \subseteq \beta$, and any function $f : \alpha \to \beta \to \gamma$, the image of $f$ on $s \times t$ (denoted as $f(s,t) := \{f(a,b) \mid a \in s, b \in t\}$) is countable.
Set.countable_setOf_nonempty_of_disjoint theorem
{f : β → Set α} (hf : Pairwise (Disjoint on f)) {s : Set α} (h'f : ∀ t, f t ⊆ s) (hs : s.Countable) : Set.Countable {t | (f t).Nonempty}
Full source
/-- If a family of disjoint sets is included in a countable set, then only countably many of
them are nonempty. -/
theorem countable_setOf_nonempty_of_disjoint {f : β → Set α}
    (hf : Pairwise (DisjointDisjoint on f)) {s : Set α} (h'f : ∀ t, f t ⊆ s) (hs : s.Countable) :
    Set.Countable {t | (f t).Nonempty} := by
  rw [← Set.countable_coe_iff] at hs ⊢
  have : ∀ t : {t // (f t).Nonempty}, ∃ x : s, x.1 ∈ f t := by
    rintro ⟨t, ⟨x, hx⟩⟩
    exact ⟨⟨x, (h'f t hx)⟩, hx⟩
  choose F hF using this
  have A : Injective F := by
    rintro ⟨t, ht⟩ ⟨t', ht'⟩ htt'
    have A : (f t ∩ f t').Nonempty := by
      refine ⟨F ⟨t, ht⟩, hF ⟨t, _⟩, ?_⟩
      rw [htt']
      exact hF ⟨t', _⟩
    simp only [Subtype.mk.injEq]
    by_contra H
    exact not_disjoint_iff_nonempty_inter.2 A (hf H)
  exact Injective.countable A
Countability of Nonempty Members in a Disjoint Family of Subsets of a Countable Set
Informal description
Let $\{f(t)\}_{t \in \beta}$ be a family of pairwise disjoint sets in $\alpha$, each contained in a countable set $s \subseteq \alpha$. Then the set $\{t \in \beta \mid f(t) \text{ is nonempty}\}$ is countable.
Finset.countable_toSet theorem
(s : Finset α) : Set.Countable (↑s : Set α)
Full source
theorem Finset.countable_toSet (s : Finset α) : Set.Countable (↑s : Set α) :=
  s.finite_toSet.countable
Countability of the Underlying Set of a Finset
Informal description
For any finset $s$ of type $\alpha$, the underlying set of $s$ is countable.