forked from leanprover-community/mathlib4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSchroederBernstein.lean
More file actions
158 lines (132 loc) · 6.2 KB
/
SchroederBernstein.lean
File metadata and controls
158 lines (132 loc) · 6.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro
-/
module
public import Mathlib.Data.Set.Piecewise
public import Mathlib.Order.FixedPoints
public import Mathlib.Order.Zorn
/-!
# Schröder-Bernstein theorem, well-ordering of cardinals
This file proves the Schröder-Bernstein theorem (see `schroeder_bernstein`), the well-ordering of
cardinals (see `min_injective`) and the totality of their order (see `total`).
## Notes
Cardinals are naturally ordered by `α ≤ β ↔ ∃ f : a → β, Injective f`:
* `schroeder_bernstein` states that, given injections `α → β` and `β → α`, one can get a
bijection `α → β`. This corresponds to the antisymmetry of the order.
* The order is also well-founded: any nonempty set of cardinals has a minimal element.
`min_injective` states that by saying that there exists an element of the set that injects into
all others.
Cardinals are defined and further developed in the folder `SetTheory.Cardinal`.
-/
public section
open Set Function
universe u v
namespace Function
namespace Embedding
section antisymm
variable {α : Type u} {β : Type v}
/-- **The Schröder-Bernstein Theorem**:
Given injections `α → β` and `β → α` that satisfy a pointwise property `R`, we can get a bijection
`α → β` that satisfies that same pointwise property. -/
theorem schroeder_bernstein_of_rel {f : α → β} {g : β → α} (hf : Function.Injective f)
(hg : Function.Injective g) (R : α → β → Prop) (hp₁ : ∀ a : α, R a (f a))
(hp₂ : ∀ b : β, R (g b) b) :
∃ h : α → β, Bijective h ∧ ∀ a : α, R a (h a) := by
classical
rcases isEmpty_or_nonempty β with hβ | hβ
· have : IsEmpty α := Function.isEmpty f
exact ⟨_, ((Equiv.equivEmpty α).trans (Equiv.equivEmpty β).symm).bijective, by simp⟩
set F : Set α →o Set α :=
{ toFun := fun s => (g '' (f '' s)ᶜ)ᶜ
monotone' := fun s t hst => by dsimp at hst ⊢; gcongr }
set s : Set α := F.lfp
have hs : (g '' (f '' s)ᶜ)ᶜ = s := F.map_lfp
have hns : g '' (f '' s)ᶜ = sᶜ := compl_injective (by simp [hs])
set g' := invFun g
have g'g : LeftInverse g' g := leftInverse_invFun hg
have hg'ns : g' '' sᶜ = (f '' s)ᶜ := by rw [← hns, g'g.image_image]
set h : α → β := s.piecewise f g'
have : Surjective h := by rw [← range_eq_univ, range_piecewise, hg'ns, union_compl_self]
have : Injective h := by
refine (injective_piecewise_iff _).2 ⟨hf.injOn, ?_, ?_⟩
· intro x hx y hy hxy
obtain ⟨x', _, rfl⟩ : x ∈ g '' (f '' s)ᶜ := by rwa [hns]
obtain ⟨y', _, rfl⟩ : y ∈ g '' (f '' s)ᶜ := by rwa [hns]
rw [g'g _, g'g _] at hxy
rw [hxy]
· intro x hx y hy hxy
obtain ⟨y', hy', rfl⟩ : y ∈ g '' (f '' s)ᶜ := by rwa [hns]
rw [g'g _] at hxy
exact hy' ⟨x, hx, hxy⟩
refine ⟨h, ⟨‹Injective h›, ‹Surjective h›⟩, fun a ↦ ?_⟩
simp only [h, Set.piecewise, g']
split
· exact hp₁ a
· have : g (invFun g a) = a := by
have : a ∈ g '' (f '' s)ᶜ := by grind
obtain ⟨x, _, hx⟩ := mem_image _ _ _ |>.mp this
exact Function.invFun_eq ⟨x, hx⟩
grind
/-- **The Schröder-Bernstein Theorem**:
Given injections `α → β` and `β → α`, we can get a bijection `α → β`. -/
theorem schroeder_bernstein {f : α → β} {g : β → α} (hf : Function.Injective f)
(hg : Function.Injective g) : ∃ h : α → β, Bijective h := by
obtain ⟨f, hf, _⟩ := schroeder_bernstein_of_rel hf hg (fun x y ↦ True) (by simp) (by simp)
exact ⟨f, hf⟩
/-- **The Schröder-Bernstein Theorem**: Given embeddings `α ↪ β` and `β ↪ α`, there exists an
equivalence `α ≃ β`. -/
theorem antisymm : (α ↪ β) → (β ↪ α) → Nonempty (α ≃ β)
| ⟨_, h₁⟩, ⟨_, h₂⟩ =>
let ⟨f, hf⟩ := schroeder_bernstein h₁ h₂
⟨Equiv.ofBijective f hf⟩
end antisymm
section Wo
variable {ι : Type u} (β : ι → Type v)
/-- `sets β` -/
private abbrev sets :=
{ s : Set (∀ i, β i) | ∀ i : ι, s.InjOn fun x => x i }
/-- The cardinals are well-ordered. We express it here by the fact that in any set of cardinals
there is an element that injects into the others.
See `Cardinal.conditionallyCompleteLinearOrderBot` for (one of) the lattice instances. -/
theorem min_injective [I : Nonempty ι] : ∃ i, Nonempty (∀ j, β i ↪ β j) :=
let ⟨s, hs⟩ := show ∃ s, Maximal (· ∈ sets β) s by
refine zorn_subset _ fun c hc hcc ↦
⟨⋃₀ c, fun i x ⟨p, hpc, hxp⟩ y ⟨q, hqc, hyq⟩ hi ↦ ?_, fun _ ↦ subset_sUnion_of_mem⟩
exact (hcc.total hpc hqc).elim (fun h ↦ hc hqc i (h hxp) hyq hi)
fun h ↦ hc hpc i hxp (h hyq) hi
let ⟨i, e⟩ :=
show ∃ i, Surjective fun x : s => x.val i from
Classical.by_contradiction fun h =>
have h : ∀ i, ∃ y, ∀ x ∈ s, (x : ∀ i, β i) i ≠ y := by
simpa [Surjective] using h
let ⟨f, hf⟩ := Classical.axiom_of_choice h
have : f ∈ s :=
have : insert f s ∈ sets β := fun i x hx y hy => by
rcases hx with hx | hx <;> rcases hy with hy | hy; · simp [hx, hy]
· subst x
exact fun e => (hf i y hy e.symm).elim
· subst y
exact fun e => (hf i x hx e).elim
· exact hs.prop i hx hy
hs.eq_of_subset this (subset_insert _ _) ▸ mem_insert ..
let ⟨i⟩ := I
hf i f this rfl
⟨i, ⟨fun j => ⟨s.restrict (fun x => x j) ∘ surjInv e,
((hs.1 j).injective).comp (injective_surjInv _)⟩⟩⟩
end Wo
/-- The cardinals are totally ordered. See
`Cardinal.conditionallyCompleteLinearOrderBot` for (one of) the lattice
instance. -/
theorem total (α : Type u) (β : Type v) : Nonempty (α ↪ β) ∨ Nonempty (β ↪ α) :=
match @min_injective Bool (fun b => cond b (ULift α) (ULift.{max u v, v} β)) ⟨true⟩
with
| ⟨true, ⟨h⟩⟩ =>
let ⟨f, hf⟩ := h false
Or.inl ⟨Embedding.congr Equiv.ulift Equiv.ulift ⟨f, hf⟩⟩
| ⟨false, ⟨h⟩⟩ =>
let ⟨f, hf⟩ := h true
Or.inr ⟨Embedding.congr Equiv.ulift Equiv.ulift ⟨f, hf⟩⟩
end Embedding
end Function