Skip to content

Commit

Permalink
feat: cardinality of a set with a countable cover (#6351)
Browse files Browse the repository at this point in the history
Assume that a set `t` is eventually covered by a countable family of sets, all with
cardinality `≤ a`. Then `t` itself has cardinality at most `a`.
  • Loading branch information
sgouezel committed Aug 10, 2023
1 parent 4ae3f82 commit 76efa47
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 0 deletions.
1 change: 1 addition & 0 deletions Mathlib.lean
Expand Up @@ -2906,6 +2906,7 @@ import Mathlib.RingTheory.ZMod
import Mathlib.SetTheory.Cardinal.Basic
import Mathlib.SetTheory.Cardinal.Cofinality
import Mathlib.SetTheory.Cardinal.Continuum
import Mathlib.SetTheory.Cardinal.CountableCover
import Mathlib.SetTheory.Cardinal.Divisibility
import Mathlib.SetTheory.Cardinal.Finite
import Mathlib.SetTheory.Cardinal.Ordinal
Expand Down
34 changes: 34 additions & 0 deletions Mathlib/SetTheory/Cardinal/Basic.lean
Expand Up @@ -293,6 +293,15 @@ theorem mk_set_le (s : Set α) : #s ≤ #α :=
mk_subtype_le s
#align cardinal.mk_set_le Cardinal.mk_set_le

@[simp]
lemma mk_preimage_down {s : Set α} : #(ULift.down.{v} ⁻¹' s) = lift.{v} (#s) := by
rw [← mk_uLift, Cardinal.eq]
constructor
let f : ULift.down ⁻¹' s → ULift s := fun x ↦ ULift.up (restrictPreimage s ULift.down x)
have : Function.Bijective f :=
ULift.up_bijective.comp (restrictPreimage_bijective _ (ULift.down_bijective))
exact Equiv.ofBijective f this

theorem out_embedding {c c' : Cardinal} : c ≤ c' ↔ Nonempty (c.out ↪ c'.out) := by
trans
· rw [← Quotient.out_eq c, ← Quotient.out_eq c']
Expand Down Expand Up @@ -2112,6 +2121,11 @@ theorem mk_range_eq_of_injective {α : Type u} {β : Type v} {f : α → β} (hf
lift_mk_eq'.mpr ⟨(Equiv.ofInjective f hf).symm⟩
#align cardinal.mk_range_eq_of_injective Cardinal.mk_range_eq_of_injective

lemma lift_mk_le_lift_mk_of_injective {α : Type u} {β : Type v} {f : α → β} (hf : Injective f) :
Cardinal.lift.{v} (#α) ≤ Cardinal.lift.{u} (#β) := by
rw [← Cardinal.mk_range_eq_of_injective hf]
exact Cardinal.lift_le.2 (Cardinal.mk_set_le _)

theorem mk_range_eq_lift {α : Type u} {β : Type v} {f : α → β} (hf : Injective f) :
lift.{max u w} #(range f) = lift.{max v w} #α :=
lift_mk_eq.{v,u,w}.mpr ⟨(Equiv.ofInjective f hf).symm⟩
Expand Down Expand Up @@ -2207,6 +2221,17 @@ theorem mk_le_mk_of_subset {α} {s t : Set α} (h : s ⊆ t) : #s ≤ #t :=
⟨Set.embeddingOfSubset s t h⟩
#align cardinal.mk_le_mk_of_subset Cardinal.mk_le_mk_of_subset

theorem mk_le_iff_forall_finset_subset_card_le {α : Type u} {n : ℕ} {t : Set α} :
#t ≤ n ↔ ∀ s : Finset α, (s : Set α) ⊆ t → s.card ≤ n := by
refine ⟨fun H s hs ↦ by simpa using (mk_le_mk_of_subset hs).trans H, fun H ↦ ?_⟩
apply card_le_of (fun s ↦ ?_)
let u : Finset α := s.image Subtype.val
have : u.card = s.card :=
Finset.card_image_of_injOn (injOn_of_injective Subtype.coe_injective _)
rw [← this]
apply H
simp only [Finset.coe_image, image_subset_iff, Subtype.coe_preimage_self, subset_univ]

theorem mk_subtype_mono {p q : α → Prop} (h : ∀ x, p x → q x) :
#{ x // p x } ≤ #{ x // q x } :=
⟨embeddingOfSubset _ _ h⟩
Expand Down Expand Up @@ -2413,6 +2438,15 @@ theorem powerlt_zero {a : Cardinal} : a ^< 0 = 0 := by
exact Subtype.isEmpty_of_false fun x => mem_Iio.not.mpr (Cardinal.zero_le x).not_lt
#align cardinal.powerlt_zero Cardinal.powerlt_zero

/-- The cardinality of a nontrivial module over a ring is at least the cardinality of the ring if
there are no zero divisors (for instance if the ring is a field) -/
theorem mk_le_of_module (R : Type u) (E : Type v)
[AddCommGroup E] [Ring R] [Module R E] [Nontrivial E] [NoZeroSMulDivisors R E] :
Cardinal.lift.{v} (#R) ≤ Cardinal.lift.{u} (#E) := by
obtain ⟨x, hx⟩ : ∃ (x : E), x ≠ 0 := exists_ne 0
have : Injective (fun k ↦ k • x) := smul_left_injective R hx
exact lift_mk_le_lift_mk_of_injective this

end Cardinal

-- namespace Tactic
Expand Down
96 changes: 96 additions & 0 deletions Mathlib/SetTheory/Cardinal/CountableCover.lean
@@ -0,0 +1,96 @@
/-
Copyright (c) 2023 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.SetTheory.Cardinal.Ordinal
import Mathlib.Order.Filter.Basic

/-!
# Cardinality of a set with a countable cover
Assume that a set `t` is eventually covered by a countable family of sets, all with
cardinality `≤ a`. Then `t` itself has cardinality at most `a`. This is proved in
`Cardinal.mk_subtype_le_of_countable_eventually_mem`.
Versions are also given when `t = univ`, and with `= a` instead of `≤ a`.
-/

open Set Order Filter
open scoped Cardinal

namespace Cardinal

/-- If a set `t` is eventually covered by a countable family of sets, all with cardinality at
most `a`, then the cardinality of `t` is also bounded by `a`.
Supersed by `mk_le_of_countable_eventually_mem` which does not assume
that the indexing set lives in the same universe. -/
lemma mk_subtype_le_of_countable_eventually_mem_aux {α ι : Type u} {a : Cardinal}
[Countable ι] {f : ι → Set α} {l : Filter ι} [NeBot l]
{t : Set α} (ht : ∀ x ∈ t, ∀ᶠ i in l, x ∈ f i)
(h'f : ∀ i, #(f i) ≤ a) : #t ≤ a := by
rcases lt_or_le a ℵ₀ with ha|ha
/- case `a` finite. In this case, it suffices to show that any finite subset `s` of `t` has
cardinality at most `a`. For this, we pick `i` such that `f i` contains all the points in `s`,
and apply the assumption that the cardinality of `f i` is at most `a`. -/
· obtain ⟨n, rfl⟩ : ∃ (n : ℕ), a = n := lt_aleph0.1 ha
apply mk_le_iff_forall_finset_subset_card_le.2 (fun s hs ↦ ?_)
have A : ∀ x ∈ s, ∀ᶠ i in l, x ∈ f i := fun x hx ↦ ht x (hs hx)
have B : ∀ᶠ i in l, ∀ x ∈ s, x ∈ f i := (s.eventually_all).2 A
rcases B.exists with ⟨i, hi⟩
have : ∀ i, Fintype (f i) := fun i ↦ (lt_aleph0_iff_fintype.1 ((h'f i).trans_lt ha)).some
let u : Finset α := (f i).toFinset
have I1 : s.card ≤ u.card := by
have : s ⊆ u := fun x hx ↦ by simpa only [Set.mem_toFinset] using hi x hx
exact Finset.card_le_of_subset this
have I2: (u.card : Cardinal) ≤ n := by
convert h'f i; simp only [Set.toFinset_card, mk_fintype]
exact I1.trans (Nat.cast_le.1 I2)
-- case `a` infinite:
· have : t ⊆ ⋃ i, f i := by
intro x hx
obtain ⟨i, hi⟩ : ∃ i, x ∈ f i := (ht x hx).exists
exact mem_iUnion_of_mem i hi
calc #t ≤ #(⋃ i, f i) := mk_le_mk_of_subset this
_ ≤ sum (fun i ↦ #(f i)) := mk_iUnion_le_sum_mk
_ ≤ sum (fun _ ↦ a) := sum_le_sum _ _ h'f
_ = #ι * a := by simp
_ ≤ ℵ₀ * a := mul_le_mul_right' mk_le_aleph0 a
_ = a := aleph0_mul_eq ha

/-- If a set `t` is eventually covered by a countable family of sets, all with cardinality at
most `a`, then the cardinality of `t` is also bounded by `a`. -/
lemma mk_subtype_le_of_countable_eventually_mem {α : Type u} {ι : Type v} {a : Cardinal}
[Countable ι] {f : ι → Set α} {l : Filter ι} [NeBot l]
{t : Set α} (ht : ∀ x ∈ t, ∀ᶠ i in l, x ∈ f i)
(h'f : ∀ i, #(f i) ≤ a) : #t ≤ a := by
let g : ULift.{u, v} ι → Set (ULift.{v, u} α) := (ULift.down ⁻¹' ·) ∘ f ∘ ULift.down
suffices #(ULift.down.{v} ⁻¹' t) ≤ Cardinal.lift.{v, u} a by simpa
let l' : Filter (ULift.{u} ι) := Filter.map ULift.up l
have : NeBot l' := map_neBot
apply mk_subtype_le_of_countable_eventually_mem_aux (ι := ULift.{u} ι) (l := l') (f := g)
· intro x hx
simpa only [Function.comp_apply, mem_preimage, eventually_map] using ht _ hx
· intro i
simpa using h'f i.down

/-- If a space is eventually covered by a countable family of sets, all with cardinality at
most `a`, then the cardinality of the space is also bounded by `a`. -/
lemma mk_le_of_countable_eventually_mem {α : Type u} {ι : Type v} {a : Cardinal}
[Countable ι] {f : ι → Set α} {l : Filter ι} [NeBot l] (ht : ∀ x, ∀ᶠ i in l, x ∈ f i)
(h'f : ∀ i, #(f i) ≤ a) : #α ≤ a := by
rw [← mk_univ]
exact mk_subtype_le_of_countable_eventually_mem (l := l) (fun x _ ↦ ht x) h'f

/-- If a space is eventually covered by a countable family of sets, all with cardinality `a`,
then the cardinality of the space is also `a`. -/
lemma mk_of_countable_eventually_mem {α : Type u} {ι : Type v} {a : Cardinal}
[Countable ι] {f : ι → Set α} {l : Filter ι} [NeBot l] (ht : ∀ x, ∀ᶠ i in l, x ∈ f i)
(h'f : ∀ i, #(f i) = a) : #α = a := by
apply le_antisymm
· apply mk_le_of_countable_eventually_mem ht (fun i ↦ (h'f i).le)
· obtain ⟨i⟩ : Nonempty ι := nonempty_of_neBot l
rw [← (h'f i)]
exact mk_set_le (f i)

end Cardinal

0 comments on commit 76efa47

Please sign in to comment.