Skip to content

Commit

Permalink
refactor(set_theory/ordinal/basic): ordinal.mininfi (#14707)
Browse files Browse the repository at this point in the history
We ditch `ordinal.min` (which is really just `infi`). Apart from this, we add some missing theorems on conditionally complete lattices with a bottom element.
  • Loading branch information
vihdzp committed Jul 25, 2022
1 parent 5ed2c72 commit a1ce53c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 67 deletions.
9 changes: 9 additions & 0 deletions src/order/conditionally_complete_lattice.lean
Expand Up @@ -642,6 +642,8 @@ le_is_glb_iff (is_least_Inf hs).is_glb

lemma Inf_mem (hs : s.nonempty) : Inf s ∈ s := (is_least_Inf hs).1

lemma infi_mem [nonempty ι] (f : ι → α) : infi f ∈ range f := Inf_mem (range_nonempty f)

lemma monotone_on.map_Inf {β : Type*} [conditionally_complete_lattice β] {f : α → β}
(hf : monotone_on f s) (hs : s.nonempty) : f (Inf s) = Inf (f '' s) :=
(hf.map_is_least (is_least_Inf hs)).cInf_eq.symm
Expand Down Expand Up @@ -697,9 +699,16 @@ theorem le_cInf_iff'' {s : set α} {a : α} (ne : s.nonempty) :
a ≤ Inf s ↔ ∀ (b : α), b ∈ s → a ≤ b :=
le_cInf_iff ⟨⊥, λ a _, bot_le⟩ ne

theorem le_cinfi_iff' [nonempty ι] {f : ι → α} {a : α} :
a ≤ infi f ↔ ∀ i, a ≤ f i :=
le_cinfi_iff ⟨⊥, λ a _, bot_le⟩

theorem cInf_le' {s : set α} {a : α} (h : a ∈ s) : Inf s ≤ a :=
cInf_le ⟨⊥, λ a _, bot_le⟩ h

theorem cinfi_le' (f : ι → α) (i : ι) : infi f ≤ f i :=
cinfi_le ⟨⊥, λ a _, bot_le⟩ _

lemma exists_lt_of_lt_cSup' {s : set α} {a : α} (h : a < Sup s) : ∃ b ∈ s, a < b :=
by { contrapose! h, exact cSup_le' h }

Expand Down
105 changes: 38 additions & 67 deletions src/set_theory/ordinal/basic.lean
Expand Up @@ -39,7 +39,6 @@ initial segment (or, equivalently, in any way). This total order is well founded
we only introduce it and prove its basic properties to deduce the fact that the order on ordinals
is total (and well founded).
* `succ o` is the successor of the ordinal `o`.
* `ordinal.min`: the minimal element of a nonempty indexed family of ordinals
* `cardinal.ord c`: when `c` is a cardinal, `ord c` is the smallest ordinal with this cardinality.
It is the canonical way to represent a cardinal with an ordinal.
Expand Down Expand Up @@ -84,6 +83,9 @@ def well_ordering_rel : σ → σ → Prop := embedding_to_cardinal ⁻¹'o (<)
instance well_ordering_rel.is_well_order : is_well_order σ well_ordering_rel :=
(rel_embedding.preimage _ _).is_well_order

instance is_well_order.subtype_nonempty : nonempty {r // is_well_order σ r} :=
⟨⟨well_ordering_rel, infer_instance⟩⟩

end well_ordering_thm

/-! ### Definition of ordinals -/
Expand Down Expand Up @@ -680,6 +682,24 @@ instance : linear_order ordinal :=

instance : is_well_order ordinal (<) := ⟨lt_wf⟩

instance : conditionally_complete_linear_order_bot ordinal :=
is_well_order.conditionally_complete_linear_order_bot _

@[simp] lemma bot_eq_zero : (⊥ : ordinal) = 0 := rfl

@[simp] lemma max_zero_left : ∀ a : ordinal, max 0 a = a := max_bot_left
@[simp] lemma max_zero_right : ∀ a : ordinal, max a 0 = a := max_bot_right
@[simp] lemma max_eq_zero {a b : ordinal} : max a b = 0 ↔ a = 0 ∧ b = 0 := max_eq_bot

protected theorem not_lt_zero (o : ordinal) : ¬ o < 0 :=
not_lt_bot

theorem eq_zero_or_pos : ∀ a : ordinal, a = 00 < a :=
eq_bot_or_bot_lt

@[simp] theorem Inf_empty : Inf (∅ : set ordinal) = 0 :=
dif_neg not_nonempty_empty

private theorem succ_le_iff' {a b : ordinal} : a + 1 ≤ b ↔ a < b :=
⟨lt_of_lt_of_le (induction_on a $ λ α r _, ⟨⟨⟨⟨λ x, sum.inl x, λ _ _, sum.inl.inj⟩,
λ _ _, sum.lex_inl_inl⟩,
Expand Down Expand Up @@ -815,46 +835,6 @@ theorem lift.principal_seg_top' :
lift.principal_seg.{u (u+1)}.top = @type ordinal (<) _ :=
by simp only [lift.principal_seg_top, univ_id]

/-! ### Minimum -/

/-- The minimal element of a nonempty family of ordinals -/
def min {ι} (I : nonempty ι) (f : ι → ordinal) : ordinal :=
lt_wf.min (set.range f) (let ⟨i⟩ := I in ⟨_, set.mem_range_self i⟩)

theorem min_eq {ι} (I) (f : ι → ordinal) : ∃ i, min I f = f i :=
let ⟨i, e⟩ := lt_wf.min_mem (set.range f) _ in ⟨i, e.symm⟩

theorem min_le {ι I} (f : ι → ordinal) (i) : min I f ≤ f i :=
le_of_not_gt $ lt_wf.not_lt_min (set.range f) _ (set.mem_range_self i)

theorem le_min {ι I} {f : ι → ordinal} {a} : a ≤ min I f ↔ ∀ i, a ≤ f i :=
⟨λ h i, le_trans h (min_le _ _),
λ h, let ⟨i, e⟩ := min_eq I f in e.symm ▸ h i⟩

@[simp] theorem lift_min {ι} (I) (f : ι → ordinal) : lift (min I f) = min I (lift ∘ f) :=
le_antisymm (le_min.2 $ λ a, lift_le.2 $ min_le _ a) $
let ⟨i, e⟩ := min_eq I (lift ∘ f) in
by rw e; exact lift_le.2 (le_min.2 $ λ j, lift_le.1 $
by have := min_le (lift ∘ f) j; rwa e at this)

instance : conditionally_complete_linear_order_bot ordinal :=
is_well_order.conditionally_complete_linear_order_bot _

@[simp] lemma bot_eq_zero : (⊥ : ordinal) = 0 := rfl

@[simp] lemma max_zero_left : ∀ a : ordinal, max 0 a = a := max_bot_left
@[simp] lemma max_zero_right : ∀ a : ordinal, max a 0 = a := max_bot_right
@[simp] lemma max_eq_zero {a b : ordinal} : max a b = 0 ↔ a = 0 ∧ b = 0 := max_eq_bot

protected theorem not_lt_zero (o : ordinal) : ¬ o < 0 :=
not_lt_bot

theorem eq_zero_or_pos : ∀ a : ordinal, a = 00 < a :=
eq_bot_or_bot_lt

@[simp] theorem Inf_empty : Inf (∅ : set ordinal) = 0 :=
dif_neg not_nonempty_empty

end ordinal

/-! ### Representing a cardinal with an ordinal -/
Expand All @@ -868,36 +848,27 @@ open ordinal
/-- The ordinal corresponding to a cardinal `c` is the least ordinal
whose cardinal is `c`. For the order-embedding version, see `ord.order_embedding`. -/
def ord (c : cardinal) : ordinal :=
let F := λ α : Type u, ⨅ r : {r // is_well_order α r}, @type α r.1 r.2 in
quot.lift_on c F
begin
let ι := λ α, {r // is_well_order α r},
have : Π α, ι α := λ α, ⟨well_ordering_rel, by apply_instance⟩,
let F := λ α, ordinal.min ⟨this _⟩ (λ i:ι α, ⟦⟨α, i.1, i.2⟩⟧),
refine quot.lift_on c F _,
suffices : ∀ {α β}, α ≈ β → F α ≤ F β,
from λ α β h, le_antisymm (this h) (this (setoid.symm h)),
intros α β h, cases h with f, refine ordinal.le_min.2 (λ i, _),
haveI := @rel_embedding.is_well_order _ _
(f ⁻¹'o i.1) _ ↑(rel_iso.preimage f i.1) i.2,
rw ← show type (f ⁻¹'o i.1) = ⟦⟨β, i.1, i.2⟩⟧, from
quot.sound ⟨rel_iso.preimage f i.1⟩,
exact ordinal.min_le (λ i:ι α, ⟦⟨α, i.1, i.2⟩⟧) ⟨_, _⟩
from λ α β h, (this h).antisymm (this (setoid.symm h)),
rintros α β ⟨f⟩,
refine le_cinfi_iff'.2 (λ i, _),
haveI := @rel_embedding.is_well_order _ _ (f ⁻¹'o i.1) _ ↑(rel_iso.preimage f i.1) i.2,
exact (cinfi_le' _ (subtype.mk (⇑f ⁻¹'o i.val)
(@rel_embedding.is_well_order _ _ _ _ ↑(rel_iso.preimage f i.1) i.2))).trans_eq
(quot.sound ⟨rel_iso.preimage f i.1⟩)
end

lemma ord_eq_min (α : Type u) : ord (#α) =
@ordinal.min {r // is_well_order α r} ⟨⟨well_ordering_rel, by apply_instance⟩⟩
(λ i, ⟦⟨α, i.1, i.2⟩⟧) := rfl

theorem ord_eq (α) : ∃ (r : α → α → Prop) [wo : is_well_order α r],
ord (#α) = @type α r wo :=
let ⟨⟨r, wo⟩, h⟩ := @ordinal.min_eq {r // is_well_order α r}
⟨⟨well_ordering_rel, by apply_instance⟩⟩
(λ i:{r // is_well_order α r}, ⟦⟨α, i.1, i.2⟩⟧) in
⟨r, wo, h⟩

theorem ord_le_type (r : α → α → Prop) [is_well_order α r] : ord (#α) ≤ ordinal.type r :=
@ordinal.min_le {r // is_well_order α r}
⟨⟨well_ordering_rel, by apply_instance⟩⟩
(λ i:{r // is_well_order α r}, ⟦⟨α, i.1, i.2⟩⟧) ⟨r, _⟩
lemma ord_eq_Inf (α : Type u) : ord (#α) = ⨅ r : {r // is_well_order α r}, @type α r.1 r.2 :=
rfl

theorem ord_eq (α) : ∃ (r : α → α → Prop) [wo : is_well_order α r], ord (#α) = @type α r wo :=
let ⟨r, wo⟩ := infi_mem (λ r : {r // is_well_order α r}, @type α r.1 r.2) in ⟨r.1, r.2, wo.symm⟩

theorem ord_le_type (r : α → α → Prop) [h : is_well_order α r] : ord (#α) ≤ type r :=
cinfi_le' _ (subtype.mk r h)

theorem ord_le {c o} : ord c ≤ o ↔ c ≤ o.card :=
induction_on c $ λ α, ordinal.induction_on o $ λ β s _,
Expand Down

0 comments on commit a1ce53c

Please sign in to comment.