Skip to content

Commit 85654c3

Browse files
committed
chore: dualize ConditionallyCompleteLattice/Indexed
1 parent 1c97f0e commit 85654c3

3 files changed

Lines changed: 95 additions & 242 deletions

File tree

Mathlib/Order/ConditionallyCompleteLattice/Basic.lean

Lines changed: 30 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,18 @@ Extension of `sSup` and `sInf` from a preorder `α` to `WithTop α` and `WithBot
4646
variable [Preorder α]
4747

4848
open Classical in
49+
@[to_dual]
4950
noncomputable instance WithTop.instSupSet [SupSet α] :
5051
SupSet (WithTop α) :=
5152
fun S =>
5253
if ⊤ ∈ S thenelse if BddAbove ((fun (a : α) ↦ ↑a) ⁻¹' S : Set α) then
5354
↑(sSup ((fun (a : α) ↦ (a : WithTop α)) ⁻¹' S : Set α)) else ⊤⟩
5455

5556
open Classical in
57+
@[to_dual]
5658
noncomputable instance WithTop.instInfSet [InfSet α] : InfSet (WithTop α) :=
5759
fun S => if S ⊆ {⊤} ∨ ¬BddBelow S thenelse ↑(sInf ((fun (a : α) ↦ ↑a) ⁻¹' S : Set α))⟩
5860

59-
noncomputable instance WithBot.instSupSet [SupSet α] : SupSet (WithBot α) :=
60-
⟨(WithTop.instInfSet (α := αᵒᵈ)).sInf⟩
61-
62-
noncomputable instance WithBot.instInfSet [InfSet α] :
63-
InfSet (WithBot α) :=
64-
⟨(WithTop.instSupSet (α := αᵒᵈ)).sSup⟩
65-
6661
theorem WithTop.sSup_eq [SupSet α] {s : Set (WithTop α)} (hs : ⊤ ∉ s)
6762
(hs' : BddAbove ((↑) ⁻¹' s : Set α)) : sSup s = ↑(sSup ((↑) ⁻¹' s) : α) :=
6863
(if_neg hs).trans <| if_pos hs'
@@ -79,10 +74,11 @@ theorem WithBot.sSup_eq [SupSet α] {s : Set (WithBot α)} (hs : ¬s ⊆ {⊥})
7974
sSup s = ↑(sSup ((↑) ⁻¹' s) : α) :=
8075
WithTop.sInf_eq (α := αᵒᵈ) hs h's
8176

82-
@[simp]
77+
@[to_dual (attr := simp)]
8378
theorem WithTop.sInf_empty [InfSet α] : sInf (∅ : Set (WithTop α)) = ⊤ :=
8479
if_pos <| by simp
8580

81+
@[to_dual (attr := norm_cast)]
8682
theorem WithTop.coe_sInf' [InfSet α] {s : Set α} (hs : s.Nonempty) (h's : BddBelow s) :
8783
↑(sInf s) = (sInf ((fun (a : α) ↦ ↑a) '' s) : WithTop α) := by
8884
classical
@@ -95,6 +91,7 @@ theorem WithTop.coe_sInf' [InfSet α] {s : Set α} (hs : s.Nonempty) (h's : BddB
9591
· rw [preimage_image_eq]
9692
exact Option.some_injective _
9793

94+
@[to_dual (attr := norm_cast)]
9895
theorem WithTop.coe_sSup' [SupSet α] {s : Set α} (hs : BddAbove s) :
9996
↑(sSup s) = (sSup ((fun (a : α) ↦ ↑a) '' s) : WithTop α) := by
10097
classical
@@ -103,24 +100,10 @@ theorem WithTop.coe_sSup' [SupSet α] {s : Set α} (hs : BddAbove s) :
103100
· exact Option.some_injective _
104101
· rintro ⟨x, _, ⟨⟩⟩
105102

106-
@[simp]
107-
theorem WithBot.sSup_empty [SupSet α] : sSup (∅ : Set (WithBot α)) = ⊥ :=
108-
WithTop.sInf_empty (α := αᵒᵈ)
109-
110103
theorem WithBot.sInf_empty (α : Type*) [CompleteLattice α] : (sInf ∅ : WithBot α) = ⊤ := by
111104
rw [WithBot.sInf_eq (by simp) (OrderBot.bddBelow _), Set.preimage_empty, _root_.sInf_empty,
112105
WithBot.coe_top]
113106

114-
@[norm_cast]
115-
theorem WithBot.coe_sSup' [SupSet α] {s : Set α} (hs : s.Nonempty) (h's : BddAbove s) :
116-
↑(sSup s) = (sSup ((fun (a : α) ↦ ↑a) '' s) : WithBot α) :=
117-
WithTop.coe_sInf' (α := αᵒᵈ) hs h's
118-
119-
@[norm_cast]
120-
theorem WithBot.coe_sInf' [InfSet α] {s : Set α} (hs : BddBelow s) :
121-
↑(sInf s) = (sInf ((fun (a : α) ↦ ↑a) '' s) : WithBot α) :=
122-
WithTop.coe_sSup' (α := αᵒᵈ) hs
123-
124107
end
125108

126109
instance ConditionallyCompleteLinearOrder.toLinearOrder [h : ConditionallyCompleteLinearOrder α] :
@@ -253,35 +236,29 @@ theorem notMem_of_csSup_lt {x : α} {s : Set α} (h : sSup s < x) (hs : BddAbove
253236
/-- Introduction rule to prove that `b` is the supremum of `s`: it suffices to check that `b`
254237
is larger than all elements of `s`, and that this is not the case of any `w<b`.
255238
See `sSup_eq_of_forall_le_of_forall_lt_exists_gt` for a version in complete lattices. -/
239+
@[to_dual csInf_eq_of_forall_ge_of_forall_gt_exists_lt /-- Introduction rule to prove that `b` is
240+
the infimum of `s`: it suffices to check that `b` is smaller than all elements of `s`, and that this
241+
is not the case of any `w>b`. See `sInf_eq_of_forall_ge_of_forall_gt_exists_lt` for a version in
242+
complete lattices. -/]
256243
theorem csSup_eq_of_forall_le_of_forall_lt_exists_gt (hs : s.Nonempty) (H : ∀ a ∈ s, a ≤ b)
257244
(H' : ∀ w, w < b → ∃ a ∈ s, w < a) : sSup s = b :=
258245
(eq_of_le_of_not_lt (csSup_le hs H)) fun hb =>
259246
let ⟨_, ha, ha'⟩ := H' _ hb
260247
lt_irrefl _ <| ha'.trans_le <| le_csSup ⟨b, H⟩ ha
261248

262-
/-- Introduction rule to prove that `b` is the infimum of `s`: it suffices to check that `b`
263-
is smaller than all elements of `s`, and that this is not the case of any `w>b`.
264-
See `sInf_eq_of_forall_ge_of_forall_gt_exists_lt` for a version in complete lattices. -/
265-
theorem csInf_eq_of_forall_ge_of_forall_gt_exists_lt :
266-
s.Nonempty → (∀ a ∈ s, b ≤ a) → (∀ w, b < w → ∃ a ∈ s, a < w) → sInf s = b :=
267-
csSup_eq_of_forall_le_of_forall_lt_exists_gt (α := αᵒᵈ)
268-
269249
/-- `b < sSup s` when there is an element `a` in `s` with `b < a`, when `s` is bounded above.
270250
This is essentially an iff, except that the assumptions for the two implications are
271251
slightly different (one needs boundedness above for one direction, nonemptiness and linear
272252
order for the other one), so we formulate separately the two implications, contrary to
273253
the `CompleteLattice` case. -/
254+
@[to_dual csInf_lt_of_lt /-- `sInf s < b` when there is an element `a` in `s` with `a < b`, when
255+
`s` is bounded below. This is essentially an iff, except that the assumptions for the two
256+
implications are slightly different (one needs boundedness below for one direction, nonemptiness
257+
and linear order for the other one), so we formulate separately the two implications, contrary to
258+
the `CompleteLattice` case. -/]
274259
theorem lt_csSup_of_lt (hs : BddAbove s) (ha : a ∈ s) (h : b < a) : b < sSup s :=
275260
lt_of_lt_of_le h (le_csSup hs ha)
276261

277-
/-- `sInf s < b` when there is an element `a` in `s` with `a < b`, when `s` is bounded below.
278-
This is essentially an iff, except that the assumptions for the two implications are
279-
slightly different (one needs boundedness below for one direction, nonemptiness and linear
280-
order for the other one), so we formulate separately the two implications, contrary to
281-
the `CompleteLattice` case. -/
282-
theorem csInf_lt_of_lt : BddBelow s → a ∈ s → a < b → sInf s < b :=
283-
lt_csSup_of_lt (α := αᵒᵈ)
284-
285262
/-- If all elements of a nonempty set `s` are less than or equal to all elements
286263
of a nonempty set `t`, then there exists an element between these sets. -/
287264
theorem exists_between_of_forall_le (sne : s.Nonempty) (tne : t.Nonempty)
@@ -390,49 +367,38 @@ variable [ConditionallyCompleteLinearOrder α] {f : ι → α} {s : Set α} {a b
390367

391368
/-- When `b < sSup s`, there is an element `a` in `s` with `b < a`, if `s` is nonempty and the order
392369
is a linear order. -/
370+
@[to_dual exists_lt_of_csInf_lt /-- When `sInf s < b`, there is an element `a` in `s` with `a < b`,
371+
if `s` is nonempty and the order is a linear order. -/]
393372
theorem exists_lt_of_lt_csSup (hs : s.Nonempty) (hb : b < sSup s) : ∃ a ∈ s, b < a := by
394373
contrapose! hb
395374
exact csSup_le hs hb
396375

397-
/-- When `sInf s < b`, there is an element `a` in `s` with `a < b`, if `s` is nonempty and the order
398-
is a linear order. -/
399-
theorem exists_lt_of_csInf_lt (hs : s.Nonempty) (hb : sInf s < b) : ∃ a ∈ s, a < b :=
400-
exists_lt_of_lt_csSup (α := αᵒᵈ) hs hb
401-
376+
@[to_dual csInf_lt_iff]
402377
theorem lt_csSup_iff (hb : BddAbove s) (hs : s.Nonempty) : a < sSup s ↔ ∃ b ∈ s, a < b :=
403378
lt_isLUB_iff <| isLUB_csSup hs hb
404379

405-
theorem csInf_lt_iff (hb : BddBelow s) (hs : s.Nonempty) : sInf s < a ↔ ∃ b ∈ s, b < a :=
406-
isGLB_lt_iff <| isGLB_csInf hs hb
407-
408-
@[simp] lemma csSup_of_not_bddAbove (hs : ¬BddAbove s) : sSup s = sSup ∅ :=
380+
@[to_dual (attr := simp)]
381+
lemma csSup_of_not_bddAbove (hs : ¬BddAbove s) : sSup s = sSup ∅ :=
409382
ConditionallyCompleteLinearOrder.csSup_of_not_bddAbove s hs
410383

411-
@[simp] lemma ciSup_of_not_bddAbove (hf : ¬BddAbove (range f)) : ⨆ i, f i = sSup ∅ :=
384+
@[to_dual (attr := simp)]
385+
lemma ciSup_of_not_bddAbove (hf : ¬BddAbove (range f)) : ⨆ i, f i = sSup ∅ :=
412386
csSup_of_not_bddAbove hf
413387

388+
@[to_dual]
414389
lemma csSup_eq_univ_of_not_bddAbove (hs : ¬BddAbove s) : sSup s = sSup univ := by
415390
rw [csSup_of_not_bddAbove hs, csSup_of_not_bddAbove (s := univ)]
416391
contrapose hs
417392
exact hs.mono (subset_univ _)
418393

394+
@[to_dual]
419395
lemma ciSup_eq_univ_of_not_bddAbove (hf : ¬BddAbove (range f)) : ⨆ i, f i = sSup univ :=
420396
csSup_eq_univ_of_not_bddAbove hf
421397

422-
@[simp] lemma csInf_of_not_bddBelow (hs : ¬BddBelow s) : sInf s = sInf ∅ :=
423-
ConditionallyCompleteLinearOrder.csInf_of_not_bddBelow s hs
424-
425-
@[simp] lemma ciInf_of_not_bddBelow (hf : ¬BddBelow (range f)) : ⨅ i, f i = sInf ∅ :=
426-
csInf_of_not_bddBelow hf
427-
428-
lemma csInf_eq_univ_of_not_bddBelow (hs : ¬BddBelow s) : sInf s = sInf univ :=
429-
csSup_eq_univ_of_not_bddAbove (α := αᵒᵈ) hs
430-
431-
lemma ciInf_eq_univ_of_not_bddBelow (hf : ¬BddBelow (range f)) : ⨅ i, f i = sInf univ :=
432-
csInf_eq_univ_of_not_bddBelow hf
433-
434398
/-- When every element of a set `s` is bounded by an element of a set `t`, and conversely, then
435399
`s` and `t` have the same supremum. This holds even when the sets may be empty or unbounded. -/
400+
@[to_dual /-- When every element of a set `s` is bounded by an element of a set `t`, and conversely,
401+
then `s` and `t` have the same infimum. This holds even when the sets may be empty or unbounded. -/]
436402
theorem csSup_eq_csSup_of_forall_exists_le {s t : Set α}
437403
(hs : ∀ x ∈ s, ∃ y ∈ t, x ≤ y) (ht : ∀ y ∈ t, ∃ x ∈ s, y ≤ x) :
438404
sSup s = sSup t := by
@@ -464,13 +430,6 @@ theorem csSup_eq_csSup_of_forall_exists_le {s t : Set α}
464430
exact hyx.trans (le_csSup Bs xs)
465431
· simp [csSup_of_not_bddAbove, (not_or.1 B).1, (not_or.1 B).2]
466432

467-
/-- When every element of a set `s` is bounded by an element of a set `t`, and conversely, then
468-
`s` and `t` have the same infimum. This holds even when the sets may be empty or unbounded. -/
469-
theorem csInf_eq_csInf_of_forall_exists_le {s t : Set α}
470-
(hs : ∀ x ∈ s, ∃ y ∈ t, y ≤ x) (ht : ∀ y ∈ t, ∃ x ∈ s, x ≤ y) :
471-
sInf s = sInf t :=
472-
csSup_eq_csSup_of_forall_exists_le (α := αᵒᵈ) hs ht
473-
474433
lemma sSup_iUnion_Iic (f : ι → α) : sSup (⋃ (i : ι), Iic (f i)) = ⨆ i, f i := by
475434
apply csSup_eq_csSup_of_forall_exists_le
476435
· rintro x ⟨-, ⟨i, rfl⟩, hi⟩
@@ -481,12 +440,10 @@ lemma sSup_iUnion_Iic (f : ι → α) : sSup (⋃ (i : ι), Iic (f i)) = ⨆ i,
481440
lemma sInf_iUnion_Ici (f : ι → α) : sInf (⋃ (i : ι), Ici (f i)) = ⨅ i, f i :=
482441
sSup_iUnion_Iic (α := αᵒᵈ) f
483442

443+
@[to_dual]
484444
theorem csInf_eq_bot_of_bot_mem [OrderBot α] {s : Set α} (hs : ⊥ ∈ s) : sInf s = ⊥ :=
485445
eq_bot_iff.2 <| csInf_le (OrderBot.bddBelow s) hs
486446

487-
theorem csSup_eq_top_of_top_mem [OrderTop α] {s : Set α} (hs : ⊤ ∈ s) : sSup s = ⊤ :=
488-
csInf_eq_bot_of_bot_mem (α := αᵒᵈ) hs
489-
490447
open Function
491448

492449
variable [WellFoundedLT α]
@@ -596,6 +553,8 @@ variable [ConditionallyCompleteLinearOrderBot α]
596553

597554
/-- The `sSup` of a non-empty set is its least upper bound for a conditionally
598555
complete lattice with a top. -/
556+
@[to_dual /-- The `sInf` of a non-empty set is its greatest lower bound for a conditionally
557+
complete lattice with a bottom. -/]
599558
theorem isLUB_sSup' {β : Type*} [ConditionallyCompleteLattice β] {s : Set (WithTop β)}
600559
(hs : s.Nonempty) : IsLUB s (sSup s) := by
601560
classical
@@ -638,6 +597,8 @@ theorem isLUB_sSup (s : Set (WithTop α)) : IsLUB s (sSup s) := by
638597

639598
/-- The `sInf` of a bounded-below set is its greatest lower bound for a conditionally
640599
complete lattice with a top. -/
600+
@[to_dual /-- The `sSup` of a bounded-above set is its lowest upper bound for a conditionally
601+
complete lattice with a bottom. -/]
641602
theorem isGLB_sInf' {β : Type*} [ConditionallyCompleteLattice β] {s : Set (WithTop β)}
642603
(hs : BddBelow s) : IsGLB s (sInf s) := by
643604
classical

Mathlib/Order/ConditionallyCompleteLattice/Defs.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ class ConditionallyCompleteLinearOrder (α : Type*)
8181
compare_eq_compareOfLessAndEq : ∀ a b, compare a b = compareOfLessAndEq a b := by
8282
compareOfLessAndEq_rfl
8383

84+
attribute [to_dual existing] ConditionallyCompleteLinearOrder.csSup_of_not_bddAbove
85+
8486
/-- A conditionally complete linear order with `Bot` is a linear order with least element, in which
8587
every nonempty subset which is bounded above has a supremum, and every nonempty subset (necessarily
8688
bounded below) has an infimum. A typical example is the natural numbers.

0 commit comments

Comments
 (0)