Skip to content

Commit a8fbd15

Browse files
committed
chore: use IsLUB IsGLB in ConditionallyCompleteLattice (#35774)
Also, some docstrings in `Order.ConditionallyCompleteLattice.Defs` are outdated (they still use Lean3 structure notation). #36671 is an orthogonal PR to fix this.
1 parent 595196b commit a8fbd15

File tree

8 files changed

+125
-191
lines changed

8 files changed

+125
-191
lines changed

Mathlib/Algebra/Tropical/Lattice.lean

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,11 @@ instance [SupSet R] : SupSet (Tropical R) where sSup s := trop (sSup (untrop ''
5555
instance [InfSet R] : InfSet (Tropical R) where sInf s := trop (sInf (untrop '' s))
5656

5757
instance instConditionallyCompleteLatticeTropical [ConditionallyCompleteLattice R] :
58-
ConditionallyCompleteLattice (Tropical R) :=
59-
{ instLatticeTropical with
60-
le_csSup := fun _s _x hs hx ↦
61-
le_csSup (untrop_monotone.map_bddAbove hs) (Set.mem_image_of_mem untrop hx)
62-
csSup_le := fun _s _x hs hx ↦
63-
csSup_le (hs.image untrop) (untrop_monotone.mem_upperBounds_image hx)
64-
le_csInf := fun _s _x hs hx ↦
65-
le_csInf (hs.image untrop) (untrop_monotone.mem_lowerBounds_image hx)
66-
csInf_le := fun _s _x hs hx ↦
67-
csInf_le (untrop_monotone.map_bddBelow hs) (Set.mem_image_of_mem untrop hx) }
58+
ConditionallyCompleteLattice (Tropical R) where
59+
isLUB_csSup _ hn hb :=
60+
.of_image untrop_le_iff <| isLUB_csSup (hn.image _) (untrop_monotone.map_bddAbove hb)
61+
isGLB_csInf _ hn hb :=
62+
.of_image untrop_le_iff <| isGLB_csInf (hn.image _) (untrop_monotone.map_bddBelow hb)
6863

6964
instance [ConditionallyCompleteLinearOrder R] : ConditionallyCompleteLinearOrder (Tropical R) :=
7065
{ instConditionallyCompleteLatticeTropical, Tropical.instLinearOrderTropical with

Mathlib/Data/Int/ConditionallyCompleteOrder.lean

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,12 @@ instance instConditionallyCompleteLinearOrder : ConditionallyCompleteLinearOrder
3434
if h : s.Nonempty ∧ BddBelow s then
3535
leastOfBdd (Classical.choose h.2) (Classical.choose_spec h.2) h.1
3636
else 0
37-
le_csSup s n hs hns := by
38-
have : s.Nonempty ∧ BddAbove s := ⟨⟨n, hns⟩, hs⟩
39-
simp only [dif_pos this]
40-
exact (greatestOfBdd _ _ _).2.2 n hns
41-
csSup_le s n hs hns := by
42-
have : s.Nonempty ∧ BddAbove s := ⟨hs, ⟨n, hns⟩⟩
43-
simp only [dif_pos this]
44-
exact hns (greatestOfBdd _ (Classical.choose_spec this.2) _).2.1
45-
csInf_le s n hs hns := by
46-
have : s.Nonempty ∧ BddBelow s := ⟨⟨n, hns⟩, hs⟩
47-
simp only [dif_pos this]
48-
exact (leastOfBdd _ _ _).2.2 n hns
49-
le_csInf s n hs hns := by
50-
have : s.Nonempty ∧ BddBelow s := ⟨hs, ⟨n, hns⟩⟩
51-
simp only [dif_pos this]
52-
exact hns (leastOfBdd _ (Classical.choose_spec this.2) _).2.1
37+
isLUB_csSup _ hn hb := by
38+
rw [dif_pos ⟨hn, hb⟩]
39+
exact (isGreatest_coe_greatestOfBdd ..).isLUB
40+
isGLB_csInf _ hn hb := by
41+
rw [dif_pos ⟨hn, hb⟩]
42+
exact (isLeast_coe_leastOfBdd ..).isGLB
5343
csSup_of_not_bddAbove := fun s hs ↦ by simp [hs]
5444
csInf_of_not_bddBelow := fun s hs ↦ by simp [hs]
5545

Mathlib/Data/Nat/Lattice.lean

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,8 @@ open scoped Classical in
130130
noncomputable instance : ConditionallyCompleteLinearOrderBot ℕ :=
131131
{ (inferInstance : OrderBot ℕ), (LinearOrder.toLattice : Lattice ℕ),
132132
(inferInstance : LinearOrder ℕ) with
133-
le_csSup := fun s a hb ha ↦ by rw [sSup_def hb]; revert a ha; exact @Nat.find_spec _ _ hb
134-
csSup_le := fun s a _ ha ↦ by rw [sSup_def ⟨a, ha⟩]; exact Nat.find_min' _ ha
135-
le_csInf := fun s a hs hb ↦ by
136-
rw [sInf_def hs]; exact hb (@Nat.find_spec (fun n ↦ n ∈ s) _ _)
137-
csInf_le := fun s a _ ha ↦ by rw [sInf_def ⟨a, ha⟩]; exact Nat.find_min' _ ha
133+
isLUB_csSup _ hn hb := sSup_def hb ▸ Nat.isLeast_find hb
134+
isGLB_csInf _ hn hb := sInf_def hn ▸ (Nat.isLeast_find hn).isGLB
138135
csSup_empty := by
139136
simp only [sSup_def, Set.mem_empty_iff_false, forall_const, forall_prop_of_false,
140137
not_false_iff, exists_const]

Mathlib/Data/Real/Archimedean.lean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,8 @@ protected theorem isGLB_sInf (h₁ : s.Nonempty) (h₂ : BddBelow s) : IsGLB s (
137137
noncomputable instance : ConditionallyCompleteLinearOrder ℝ where
138138
__ := Real.linearOrder
139139
__ := Real.lattice
140-
le_csSup s a hs ha := (Real.isLUB_sSup ⟨a, ha⟩ hs).1 ha
141-
csSup_le s a hs ha := (Real.isLUB_sSup hs ⟨a, ha⟩).2 ha
142-
csInf_le s a hs ha := (Real.isGLB_sInf ⟨a, ha⟩ hs).1 ha
143-
le_csInf s a hs ha := (Real.isGLB_sInf hs ⟨a, ha⟩).2 ha
140+
isLUB_csSup _ := Real.isLUB_sSup
141+
isGLB_csInf _ := Real.isGLB_sInf
144142
csSup_of_not_bddAbove s hs := by simp [hs, sSup_def]
145143
csInf_of_not_bddBelow s hs := by simp [hs, sInf_def, sSup_def]
146144

Mathlib/Order/CompleteLatticeIntervals.lean

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,12 @@ noncomputable abbrev subsetConditionallyCompleteLinearOrder [Inhabited s]
127127
(h_Inf : ∀ {t : Set s} (_ : t.Nonempty) (_h_bdd : BddBelow t), sInf ((↑) '' t : Set α) ∈ s) :
128128
ConditionallyCompleteLinearOrder s :=
129129
{ subsetSupSet s, subsetInfSet s, DistribLattice.toLattice, (inferInstance : LinearOrder s) with
130-
le_csSup := by
131-
rintro t c h_bdd hct
132-
rw [← Subtype.coe_le_coe, ← subset_sSup_of_within s ⟨c, hct⟩ h_bdd (h_Sup ⟨c, hct⟩ h_bdd)]
133-
exact (Subtype.mono_coe _).le_csSup_image hct h_bdd
134-
csSup_le := by
135-
rintro t B ht hB
136-
rw [← Subtype.coe_le_coe, ← subset_sSup_of_within s ht ⟨B, hB⟩ (h_Sup ht ⟨B, hB⟩)]
137-
exact (Subtype.mono_coe (· ∈ s)).csSup_image_le ht hB
138-
le_csInf := by
139-
intro t B ht hB
140-
rw [← Subtype.coe_le_coe, ← subset_sInf_of_within s ht ⟨B, hB⟩ (h_Inf ht ⟨B, hB⟩)]
141-
exact (Subtype.mono_coe (· ∈ s)).le_csInf_image ht hB
142-
csInf_le := by
143-
rintro t c h_bdd hct
144-
rw [← Subtype.coe_le_coe, ← subset_sInf_of_within s ⟨c, hct⟩ h_bdd (h_Inf ⟨c, hct⟩ h_bdd)]
145-
exact (Subtype.mono_coe (· ∈ s)).csInf_image_le hct h_bdd
130+
isLUB_csSup t ht h_bdd := .of_image Subtype.coe_le_coe <| by
131+
rw [← subset_sSup_of_within s ht h_bdd (h_Sup ht h_bdd)]
132+
exact isLUB_csSup (ht.image _) ((Subtype.mono_coe _).map_bddAbove h_bdd)
133+
isGLB_csInf t ht h_bdd := .of_image Subtype.coe_le_coe <| by
134+
rw [← subset_sInf_of_within s ht h_bdd (h_Inf ht h_bdd)]
135+
exact isGLB_csInf (ht.image _) ((Subtype.mono_coe _).map_bddBelow h_bdd)
146136
csSup_of_not_bddAbove := fun t ht ↦ by simp [ht]
147137
csInf_of_not_bddBelow := fun t ht ↦ by simp [ht] }
148138

Mathlib/Order/ConditionallyCompleteLattice/Basic.lean

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,8 @@ attribute [instance 100] ConditionallyCompleteLinearOrderBot.toOrderBot
147147
on the properties of sInf and sSup in a complete lattice. -/
148148
instance (priority := 100) CompleteLattice.toConditionallyCompleteLattice [CompleteLattice α] :
149149
ConditionallyCompleteLattice α where
150-
le_csSup := by intros; apply le_sSup; assumption
151-
csSup_le := by intros; apply sSup_le; assumption
152-
csInf_le := by intros; apply sInf_le; assumption
153-
le_csInf := by intros; apply le_sInf; assumption
150+
isLUB_csSup _ _ _ := isLUB_sSup _
151+
isGLB_csInf _ _ _ := isGLB_sInf _
154152

155153
-- see Note [lower instance priority]
156154
instance (priority := 100) CompleteLinearOrder.toConditionallyCompleteLinearOrderBot {α : Type*}
@@ -165,10 +163,8 @@ namespace OrderDual
165163

166164
instance instConditionallyCompleteLattice (α : Type*) [ConditionallyCompleteLattice α] :
167165
ConditionallyCompleteLattice αᵒᵈ where
168-
le_csSup := ConditionallyCompleteLattice.csInf_le (α := α)
169-
csSup_le := ConditionallyCompleteLattice.le_csInf (α := α)
170-
le_csInf := ConditionallyCompleteLattice.csSup_le (α := α)
171-
csInf_le := ConditionallyCompleteLattice.le_csSup (α := α)
166+
isLUB_csSup := ConditionallyCompleteLattice.isGLB_csInf (α := α)
167+
isGLB_csInf := ConditionallyCompleteLattice.isLUB_csSup (α := α)
172168

173169
instance (α : Type*) [ConditionallyCompleteLinearOrder α] :
174170
ConditionallyCompleteLinearOrder αᵒᵈ where
@@ -183,17 +179,23 @@ section ConditionallyCompleteLattice
183179

184180
variable [ConditionallyCompleteLattice α] {s t : Set α} {a b : α}
185181

182+
theorem isLUB_csSup (hn : s.Nonempty) (hb : BddAbove s) : IsLUB s (sSup s) :=
183+
ConditionallyCompleteLattice.isLUB_csSup _ hn hb
184+
185+
theorem isGLB_csInf (hn : s.Nonempty) (hb : BddBelow s) : IsGLB s (sInf s) :=
186+
ConditionallyCompleteLattice.isGLB_csInf _ hn hb
187+
186188
theorem le_csSup (h₁ : BddAbove s) (h₂ : a ∈ s) : a ≤ sSup s :=
187-
ConditionallyCompleteLattice.le_csSup s a h₁ h₂
189+
(isLUB_csSup (nonempty_of_mem h₂) h₁).1 h₂
188190

189191
theorem csSup_le (h₁ : s.Nonempty) (h₂ : ∀ b ∈ s, b ≤ a) : sSup s ≤ a :=
190-
ConditionallyCompleteLattice.csSup_le s a h₁ h₂
192+
(isLUB_csSup h₁ ⟨a, h₂⟩).2 h₂
191193

192194
theorem csInf_le (h₁ : BddBelow s) (h₂ : a ∈ s) : sInf s ≤ a :=
193-
ConditionallyCompleteLattice.csInf_le s a h₁ h₂
195+
(isGLB_csInf (nonempty_of_mem h₂) h₁).1 h₂
194196

195197
theorem le_csInf (h₁ : s.Nonempty) (h₂ : ∀ b ∈ s, a ≤ b) : a ≤ sInf s :=
196-
ConditionallyCompleteLattice.le_csInf s a h₁ h₂
198+
(isGLB_csInf h₁ ⟨a, h₂⟩).2 h₂
197199

198200
theorem le_csSup_of_le (hs : BddAbove s) (hb : b ∈ s) (h : a ≤ b) : a ≤ sSup s :=
199201
le_trans h (le_csSup hs hb)
@@ -216,12 +218,6 @@ theorem le_csSup_iff (h : BddAbove s) (hs : s.Nonempty) :
216218
theorem csInf_le_iff (h : BddBelow s) (hs : s.Nonempty) : sInf s ≤ a ↔ ∀ b ∈ lowerBounds s, b ≤ a :=
217219
fun h _ hb => le_trans (le_csInf hs hb) h, fun hb => hb _ fun _ => csInf_le h⟩
218220

219-
theorem isLUB_csSup (ne : s.Nonempty) (H : BddAbove s) : IsLUB s (sSup s) :=
220-
fun _ => le_csSup H, fun _ => csSup_le ne⟩
221-
222-
theorem isGLB_csInf (ne : s.Nonempty) (H : BddBelow s) : IsGLB s (sInf s) :=
223-
fun _ => csInf_le H, fun _ => le_csInf ne⟩
224-
225221
theorem IsLUB.csSup_eq (H : IsLUB s a) (ne : s.Nonempty) : sSup s = a :=
226222
(isLUB_csSup ne ⟨a, H.1⟩).unique H
227223

@@ -230,8 +226,8 @@ theorem IsGLB.csInf_eq (H : IsGLB s a) (ne : s.Nonempty) : sInf s = a :=
230226

231227
instance (priority := 100) ConditionallyCompleteLattice.toConditionallyCompletePartialOrder :
232228
ConditionallyCompletePartialOrder α where
233-
isGLB_csInf_of_directed _ _ non bdd := isGLB_csInf non bdd
234-
isLUB_csSup_of_directed _ _ non bdd := isLUB_csSup non bdd
229+
isGLB_csInf_of_directed _ _ := isGLB_csInf _
230+
isLUB_csSup_of_directed _ _ := isLUB_csSup _
235231

236232
theorem subset_Icc_csInf_csSup (hb : BddBelow s) (ha : BddAbove s) : s ⊆ Icc (sInf s) (sSup s) :=
237233
fun _ hx => ⟨csInf_le hb hx, le_csSup ha hx⟩
@@ -386,14 +382,12 @@ end ConditionallyCompleteLattice
386382

387383
instance Pi.conditionallyCompleteLattice {ι : Type*} {α : ι → Type*}
388384
[∀ i, ConditionallyCompleteLattice (α i)] : ConditionallyCompleteLattice (∀ i, α i) where
389-
le_csSup := fun _ f ⟨g, hg⟩ hf i =>
390-
le_csSup ⟨g i, Set.forall_mem_range.2 fun ⟨_, hf'⟩ => hg hf' i⟩ ⟨⟨f, hf⟩, rfl⟩
391-
csSup_le s _ hs hf i :=
392-
(csSup_le (by have := hs.to_subtype; apply range_nonempty)) fun _ ⟨⟨_, hg⟩, hb⟩ => hb ▸ hf hg i
393-
csInf_le := fun _ f ⟨g, hg⟩ hf i =>
394-
csInf_le ⟨g i, Set.forall_mem_range.2 fun ⟨_, hf'⟩ => hg hf' i⟩ ⟨⟨f, hf⟩, rfl⟩
395-
le_csInf s _ hs hf i :=
396-
(le_csInf (by have := hs.to_subtype; apply range_nonempty)) fun _ ⟨⟨_, hg⟩, hb⟩ => hb ▸ hf hg i
385+
isLUB_csSup _ hn hb := isLUB_pi.mpr fun _ ↦ by
386+
rw [sSup_apply_eq_sSup_image]
387+
exact isLUB_csSup (image_nonempty.mpr hn) ((monotone_eval _).map_bddAbove hb)
388+
isGLB_csInf _ hn hb := isGLB_pi.mpr fun _ ↦ by
389+
rw [sInf_apply_eq_sInf_image]
390+
exact isGLB_csInf (image_nonempty.mpr hn) ((monotone_eval _).map_bddBelow hb)
397391

398392
section ConditionallyCompleteLinearOrder
399393

@@ -872,19 +866,15 @@ This result can be used to show that the extended reals `[-∞, ∞]` are a comp
872866
gives a conditionally complete lattice -/
873867
noncomputable instance WithTop.conditionallyCompleteLattice {α : Type*}
874868
[ConditionallyCompleteLattice α] : ConditionallyCompleteLattice (WithTop α) where
875-
le_csSup _ a _ haS := (WithTop.isLUB_sSup' ⟨a, haS⟩).1 haS
876-
csSup_le _ _ hS haS := (WithTop.isLUB_sSup' hS).2 haS
877-
csInf_le _ _ hS haS := (WithTop.isGLB_sInf' hS).1 haS
878-
le_csInf _ a _ haS := (WithTop.isGLB_sInf' ⟨a, haS⟩).2 haS
869+
isLUB_csSup _ hS _ := WithTop.isLUB_sSup' hS
870+
isGLB_csInf _ _ hS := WithTop.isGLB_sInf' hS
879871

880872
/-- Adding a bottom element to a conditionally complete lattice
881873
gives a conditionally complete lattice -/
882874
noncomputable instance WithBot.conditionallyCompleteLattice {α : Type*}
883875
[ConditionallyCompleteLattice α] : ConditionallyCompleteLattice (WithBot α) where
884-
le_csSup := (WithTop.conditionallyCompleteLattice (α := αᵒᵈ)).csInf_le
885-
csSup_le := (WithTop.conditionallyCompleteLattice (α := αᵒᵈ)).le_csInf
886-
csInf_le := (WithTop.conditionallyCompleteLattice (α := αᵒᵈ)).le_csSup
887-
le_csInf := (WithTop.conditionallyCompleteLattice (α := αᵒᵈ)).csSup_le
876+
isLUB_csSup := (WithTop.conditionallyCompleteLattice (α := αᵒᵈ)).isGLB_csInf
877+
isGLB_csInf := (WithTop.conditionallyCompleteLattice (α := αᵒᵈ)).isLUB_csSup
888878

889879
noncomputable instance [CompleteLattice α] : CompleteLattice (WithBot α) where
890880
isLUB_sSup s := ⟨fun _ ↦ le_csSup (OrderTop.bddAbove _), fun _ hsa ↦

0 commit comments

Comments
 (0)