Skip to content

Commit d19a0ce

Browse files
committed
chore: fix junk value for sInf on WithTop (#13717)
As pointed out in https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/Definition.20of.20.60WithTop.2EinstInfSet.60/near/443609808, the current choice of junk value for `sInf s` when `s : Set (WithTop α)` is not bounded below does not coincide with `sInf ∅`. This makes it impossible to get a `ConditionallyCompleteLinearOrder` structure on `WithTop α` as we require the junk values to coincide. This PR fixes the choice of junk value for `sInf s` when `s : Set (WithTop α)` is not bounded below, making it equal to `⊤ = sInf ∅`.
1 parent e5c264c commit d19a0ce

File tree

3 files changed

+53
-38
lines changed

3 files changed

+53
-38
lines changed

Mathlib/Data/ENNReal/Basic.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,8 @@ theorem coe_sSup {s : Set ℝ≥0} : BddAbove s → (↑(sSup s) : ℝ≥0∞) =
753753
WithTop.coe_sSup
754754
#align ennreal.coe_Sup ENNReal.coe_sSup
755755

756-
theorem coe_sInf {s : Set ℝ≥0} : s.Nonempty (↑(sInf s) : ℝ≥0∞) = ⨅ a ∈ s, ↑a :=
757-
WithTop.coe_sInf
756+
theorem coe_sInf {s : Set ℝ≥0} (hs : s.Nonempty) : (↑(sInf s) : ℝ≥0∞) = ⨅ a ∈ s, ↑a :=
757+
WithTop.coe_sInf hs (OrderBot.bddBelow s)
758758
#align ennreal.coe_Inf ENNReal.coe_sInf
759759

760760
theorem coe_iSup {ι : Sort*} {f : ι → ℝ≥0} (hf : BddAbove (range f)) :
@@ -764,7 +764,7 @@ theorem coe_iSup {ι : Sort*} {f : ι → ℝ≥0} (hf : BddAbove (range f)) :
764764

765765
@[norm_cast]
766766
theorem coe_iInf {ι : Sort*} [Nonempty ι] (f : ι → ℝ≥0) : (↑(iInf f) : ℝ≥0∞) = ⨅ a, ↑(f a) :=
767-
WithTop.coe_iInf f
767+
WithTop.coe_iInf (OrderBot.bddBelow _)
768768
#align ennreal.coe_infi ENNReal.coe_iInf
769769

770770
theorem coe_mem_upperBounds {s : Set ℝ≥0} :

Mathlib/Data/ENat/Lattice.lean

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ lemma iInf_coe_ne_top : ⨅ i, (f i : ℕ∞) ≠ ⊤ ↔ Nonempty ι := by
3636
lemma iInf_coe_lt_top : ⨅ i, (f i : ℕ∞) < ⊤ ↔ Nonempty ι := WithTop.iInf_coe_lt_top
3737

3838
lemma coe_sSup : BddAbove s → ↑(sSup s) = ⨆ a ∈ s, (a : ℕ∞) := WithTop.coe_sSup
39-
lemma coe_sInf : s.Nonempty → ↑(sInf s) = ⨅ a ∈ s, (a : ℕ∞) := WithTop.coe_sInf
39+
40+
lemma coe_sInf (hs : s.Nonempty) : ↑(sInf s) = ⨅ a ∈ s, (a : ℕ∞) :=
41+
WithTop.coe_sInf hs (OrderBot.bddBelow s)
42+
4043
lemma coe_iSup : BddAbove (range f) → ↑(⨆ i, f i) = ⨆ i, (f i : ℕ∞) := WithTop.coe_iSup _
41-
@[norm_cast] lemma coe_iInf [Nonempty ι] : ↑(⨅ i, f i) = ⨅ i, (f i : ℕ∞) := WithTop.coe_iInf _
44+
45+
@[norm_cast] lemma coe_iInf [Nonempty ι] : ↑(⨅ i, f i) = ⨅ i, (f i : ℕ∞) :=
46+
WithTop.coe_iInf (OrderBot.bddBelow _)
4247

4348
end ENat

Mathlib/Order/ConditionallyCompleteLattice/Basic.lean

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -42,74 +42,78 @@ section
4242
Extension of `sSup` and `sInf` from a preorder `α` to `WithTop α` and `WithBot α`
4343
-/
4444

45+
variable [Preorder α]
4546

4647
open scoped Classical
4748

48-
noncomputable instance WithTop.instSupSet {α : Type*} [Preorder α] [SupSet α] :
49+
noncomputable instance WithTop.instSupSet [SupSet α] :
4950
SupSet (WithTop α) :=
5051
fun S =>
5152
if ⊤ ∈ S thenelse if BddAbove ((fun (a : α) ↦ ↑a) ⁻¹' S : Set α) then
5253
↑(sSup ((fun (a : α) ↦ (a : WithTop α)) ⁻¹' S : Set α)) else ⊤⟩
5354

54-
noncomputable instance WithTop.instInfSet {α : Type*} [InfSet α] : InfSet (WithTop α) :=
55-
fun S => if S ⊆ {⊤} thenelse ↑(sInf ((fun (a : α) ↦ ↑a) ⁻¹' S : Set α))⟩
55+
noncomputable instance WithTop.instInfSet [InfSet α] : InfSet (WithTop α) :=
56+
fun S => if S ⊆ {⊤} ∨ ¬BddBelow S thenelse ↑(sInf ((fun (a : α) ↦ ↑a) ⁻¹' S : Set α))⟩
5657

57-
noncomputable instance WithBot.instSupSet {α : Type*} [SupSet α] : SupSet (WithBot α) :=
58+
noncomputable instance WithBot.instSupSet [SupSet α] : SupSet (WithBot α) :=
5859
⟨(WithTop.instInfSet (α := αᵒᵈ)).sInf⟩
5960

60-
noncomputable instance WithBot.instInfSet {α : Type*} [Preorder α] [InfSet α] :
61+
noncomputable instance WithBot.instInfSet [InfSet α] :
6162
InfSet (WithBot α) :=
6263
⟨(WithTop.instSupSet (α := αᵒᵈ)).sSup⟩
6364

64-
theorem WithTop.sSup_eq [Preorder α] [SupSet α] {s : Set (WithTop α)} (hs : ⊤ ∉ s)
65+
theorem WithTop.sSup_eq [SupSet α] {s : Set (WithTop α)} (hs : ⊤ ∉ s)
6566
(hs' : BddAbove ((↑) ⁻¹' s : Set α)) : sSup s = ↑(sSup ((↑) ⁻¹' s) : α) :=
6667
(if_neg hs).trans <| if_pos hs'
6768
#align with_top.Sup_eq WithTop.sSup_eq
6869

69-
theorem WithTop.sInf_eq [InfSet α] {s : Set (WithTop α)} (hs : ¬s ⊆ {⊤}) :
70+
theorem WithTop.sInf_eq [InfSet α] {s : Set (WithTop α)} (hs : ¬s ⊆ {⊤}) (h's : BddBelow s) :
7071
sInf s = ↑(sInf ((↑) ⁻¹' s) : α) :=
71-
if_neg hs
72+
if_neg <| by simp [hs, h's]
7273
#align with_top.Inf_eq WithTop.sInf_eq
7374

74-
theorem WithBot.sInf_eq [Preorder α] [InfSet α] {s : Set (WithBot α)} (hs : ⊥ ∉ s)
75+
theorem WithBot.sInf_eq [InfSet α] {s : Set (WithBot α)} (hs : ⊥ ∉ s)
7576
(hs' : BddBelow ((↑) ⁻¹' s : Set α)) : sInf s = ↑(sInf ((↑) ⁻¹' s) : α) :=
7677
(if_neg hs).trans <| if_pos hs'
7778
#align with_bot.Inf_eq WithBot.sInf_eq
7879

79-
theorem WithBot.sSup_eq [SupSet α] {s : Set (WithBot α)} (hs : ¬s ⊆ {⊥}) :
80+
theorem WithBot.sSup_eq [SupSet α] {s : Set (WithBot α)} (hs : ¬s ⊆ {⊥}) (h's : BddAbove s) :
8081
sSup s = ↑(sSup ((↑) ⁻¹' s) : α) :=
81-
if_neg hs
82+
WithTop.sInf_eq (α := αᵒᵈ) hs h's
8283
#align with_bot.Sup_eq WithBot.sSup_eq
8384

8485
@[simp]
85-
theorem WithTop.sInf_empty {α : Type*} [InfSet α] : sInf (∅ : Set (WithTop α)) = ⊤ :=
86-
if_pos <| Set.empty_subset _
86+
theorem WithTop.sInf_empty [InfSet α] : sInf (∅ : Set (WithTop α)) = ⊤ :=
87+
if_pos <| by simp
8788
#align with_top.cInf_empty WithTop.sInf_empty
8889

8990
@[simp]
90-
theorem WithTop.iInf_empty {α : Type*} [IsEmpty ι] [InfSet α] (f : ι → WithTop α) :
91+
theorem WithTop.iInf_empty [IsEmpty ι] [InfSet α] (f : ι → WithTop α) :
9192
⨅ i, f i = ⊤ := by rw [iInf, range_eq_empty, WithTop.sInf_empty]
9293
#align with_top.cinfi_empty WithTop.iInf_empty
9394

94-
theorem WithTop.coe_sInf' [InfSet α] {s : Set α} (hs : s.Nonempty) :
95+
theorem WithTop.coe_sInf' [InfSet α] {s : Set α} (hs : s.Nonempty) (h's : BddBelow s) :
9596
↑(sInf s) = (sInf ((fun (a : α) ↦ ↑a) '' s) : WithTop α) := by
9697
obtain ⟨x, hx⟩ := hs
9798
change _ = ite _ _ _
9899
split_ifs with h
99-
· cases h (mem_image_of_mem _ hx)
100+
· rcases h with h1 | h2
101+
· cases h1 (mem_image_of_mem _ hx)
102+
· exact (h2 (Monotone.map_bddBelow coe_mono h's)).elim
100103
· rw [preimage_image_eq]
101104
exact Option.some_injective _
102105
#align with_top.coe_Inf' WithTop.coe_sInf'
103106

104107
-- Porting note: the mathlib3 proof uses `range_comp` in the opposite direction and
105108
-- does not need `rfl`.
106109
@[norm_cast]
107-
theorem WithTop.coe_iInf [Nonempty ι] [InfSet α] (f : ι → α) :
110+
theorem WithTop.coe_iInf [Nonempty ι] [InfSet α] {f : ι → α} (hf : BddBelow (range f)) :
108111
↑(⨅ i, f i) = (⨅ i, f i : WithTop α) := by
109-
rw [iInf, iInf, WithTop.coe_sInf' (range_nonempty f), ← range_comp]; rfl
112+
rw [iInf, iInf, WithTop.coe_sInf' (range_nonempty f) hf, ← range_comp]
113+
rfl
110114
#align with_top.coe_infi WithTop.coe_iInf
111115

112-
theorem WithTop.coe_sSup' [Preorder α] [SupSet α] {s : Set α} (hs : BddAbove s) :
116+
theorem WithTop.coe_sSup' [SupSet α] {s : Set α} (hs : BddAbove s) :
113117
↑(sSup s) = (sSup ((fun (a : α) ↦ ↑a) '' s) : WithTop α) := by
114118
change _ = ite _ _ _
115119
rw [if_neg, preimage_image_eq, if_pos hs]
@@ -120,42 +124,44 @@ theorem WithTop.coe_sSup' [Preorder α] [SupSet α] {s : Set α} (hs : BddAbove
120124
-- Porting note: the mathlib3 proof uses `range_comp` in the opposite direction and
121125
-- does not need `rfl`.
122126
@[norm_cast]
123-
theorem WithTop.coe_iSup [Preorder α] [SupSet α] (f : ι → α) (h : BddAbove (Set.range f)) :
127+
theorem WithTop.coe_iSup [SupSet α] (f : ι → α) (h : BddAbove (Set.range f)) :
124128
↑(⨆ i, f i) = (⨆ i, f i : WithTop α) := by
125129
rw [iSup, iSup, WithTop.coe_sSup' h, ← range_comp]; rfl
126130
#align with_top.coe_supr WithTop.coe_iSup
127131

128132
@[simp]
129-
theorem WithBot.csSup_empty {α : Type*} [SupSet α] : sSup (∅ : Set (WithBot α)) = ⊥ :=
130-
if_pos <| Set.empty_subset _
131-
#align with_bot.cSup_empty WithBot.csSup_empty
133+
theorem WithBot.sSup_empty [SupSet α] : sSup (∅ : Set (WithBot α)) = ⊥ :=
134+
WithTop.sInf_empty (α := αᵒᵈ)
135+
#align with_bot.cSup_empty WithBot.sSup_empty
136+
137+
@[deprecated (since := "2024-06-10")] alias WithBot.csSup_empty := WithBot.sSup_empty
132138

133139
@[simp]
134-
theorem WithBot.ciSup_empty {α : Type*} [IsEmpty ι] [SupSet α] (f : ι → WithBot α) :
140+
theorem WithBot.ciSup_empty [IsEmpty ι] [SupSet α] (f : ι → WithBot α) :
135141
⨆ i, f i = ⊥ :=
136142
WithTop.iInf_empty (α := αᵒᵈ) _
137143
#align with_bot.csupr_empty WithBot.ciSup_empty
138144

139145
@[norm_cast]
140-
theorem WithBot.coe_sSup' [SupSet α] {s : Set α} (hs : s.Nonempty) :
146+
theorem WithBot.coe_sSup' [SupSet α] {s : Set α} (hs : s.Nonempty) (h's : BddAbove s) :
141147
↑(sSup s) = (sSup ((fun (a : α) ↦ ↑a) '' s) : WithBot α) :=
142-
WithTop.coe_sInf' (α := αᵒᵈ) hs
148+
WithTop.coe_sInf' (α := αᵒᵈ) hs h's
143149
#align with_bot.coe_Sup' WithBot.coe_sSup'
144150

145151
@[norm_cast]
146-
theorem WithBot.coe_iSup [Nonempty ι] [SupSet α] (f : ι → α) :
152+
theorem WithBot.coe_iSup [Nonempty ι] [SupSet α] {f : ι → α} (hf : BddAbove (range f)) :
147153
↑(⨆ i, f i) = (⨆ i, f i : WithBot α) :=
148-
WithTop.coe_iInf (α := αᵒᵈ) _
154+
WithTop.coe_iInf (α := αᵒᵈ) hf
149155
#align with_bot.coe_supr WithBot.coe_iSup
150156

151157
@[norm_cast]
152-
theorem WithBot.coe_sInf' [Preorder α] [InfSet α] {s : Set α} (hs : BddBelow s) :
158+
theorem WithBot.coe_sInf' [InfSet α] {s : Set α} (hs : BddBelow s) :
153159
↑(sInf s) = (sInf ((fun (a : α) ↦ ↑a) '' s) : WithBot α) :=
154160
WithTop.coe_sSup' (α := αᵒᵈ) hs
155161
#align with_bot.coe_Inf' WithBot.coe_sInf'
156162

157163
@[norm_cast]
158-
theorem WithBot.coe_iInf [Preorder α] [InfSet α] (f : ι → α) (h : BddBelow (Set.range f)) :
164+
theorem WithBot.coe_iInf [InfSet α] (f : ι → α) (h : BddBelow (Set.range f)) :
159165
↑(⨅ i, f i) = (⨅ i, f i : WithBot α) :=
160166
WithTop.coe_iSup (α := αᵒᵈ) _ h
161167
#align with_bot.coe_infi WithBot.coe_iInf
@@ -1335,6 +1341,7 @@ theorem isGLB_sInf' {β : Type*} [ConditionallyCompleteLattice β] {s : Set (Wit
13351341
(hs : BddBelow s) : IsGLB s (sInf s) := by
13361342
constructor
13371343
· show ite _ _ _ ∈ _
1344+
simp only [hs, not_true_eq_false, or_false]
13381345
split_ifs with h
13391346
· intro a ha
13401347
exact top_le_iff.2 (Set.mem_singleton_iff.1 (h ha))
@@ -1351,6 +1358,7 @@ theorem isGLB_sInf' {β : Type*} [ConditionallyCompleteLattice β] {s : Set (Wit
13511358
intro c hc
13521359
exact coe_le_coe.1 (hb hc)
13531360
· show ite _ _ _ ∈ _
1361+
simp only [hs, not_true_eq_false, or_false]
13541362
split_ifs with h
13551363
· intro _ _
13561364
exact le_top
@@ -1397,8 +1405,9 @@ theorem coe_sSup {s : Set α} (hb : BddAbove s) : ↑(sSup s) = (⨆ a ∈ s,
13971405

13981406
/-- A version of `WithTop.coe_sInf'` with a more convenient but less general statement. -/
13991407
@[norm_cast]
1400-
theorem coe_sInf {s : Set α} (hs : s.Nonempty) : ↑(sInf s) = (⨅ a ∈ s, ↑a : WithTop α) := by
1401-
rw [coe_sInf' hs, sInf_image]
1408+
theorem coe_sInf {s : Set α} (hs : s.Nonempty) (h's : BddBelow s) :
1409+
↑(sInf s) = (⨅ a ∈ s, ↑a : WithTop α) := by
1410+
rw [coe_sInf' hs h's, sInf_image]
14021411
#align with_top.coe_Inf WithTop.coe_sInf
14031412

14041413
end WithTop
@@ -1658,7 +1667,7 @@ noncomputable instance WithTop.WithBot.completeLattice {α : Type*}
16581667
-- Porting note: previous proof relied on convert unfolding
16591668
-- the definition of ⊥
16601669
apply congr_arg
1661-
simp only [h, preimage_empty, WithBot.csSup_empty]
1670+
simp only [h, preimage_empty, WithBot.sSup_empty]
16621671
· exfalso
16631672
apply h₂
16641673
use ⊥
@@ -1667,6 +1676,7 @@ noncomputable instance WithTop.WithBot.completeLattice {α : Type*}
16671676
· exact (WithTop.isLUB_sSup' h).2 ha
16681677
sInf_le := fun S a haS =>
16691678
show ite _ _ _ ≤ a by
1679+
simp only [OrderBot.bddBelow, not_true_eq_false, or_false]
16701680
split_ifs with h₁
16711681
· cases' a with a
16721682
· exact le_rfl

0 commit comments

Comments
 (0)