Skip to content

Commit d1cd996

Browse files
committed
feat: use junk value in the definition of conditionally complete linear order (#6571)
Currently, in a conditionally complete linear order, the supremum of an unbounded set hasn't any specific property. However, in all instances in mathlib, all unbounded sets have the same supremum. This PR adds this requirement in mathlib. This will be convenient to remove boundedness assumptions in measurability statements.
1 parent 704efa4 commit d1cd996

6 files changed

Lines changed: 135 additions & 8 deletions

File tree

Mathlib/Algebra/Tropical/Lattice.lean

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,20 @@ instance instConditionallyCompleteLatticeTropical [ConditionallyCompleteLattice
7272
csInf_le (untrop_monotone.map_bddBelow hs) (Set.mem_image_of_mem untrop hx) }
7373

7474
instance [ConditionallyCompleteLinearOrder R] : ConditionallyCompleteLinearOrder (Tropical R) :=
75-
{ instConditionallyCompleteLatticeTropical, Tropical.instLinearOrderTropical with }
75+
{ instConditionallyCompleteLatticeTropical, Tropical.instLinearOrderTropical with
76+
csSup_of_not_bddAbove := by
77+
intro s hs
78+
have : Set.range untrop = (Set.univ : Set R) := Equiv.range_eq_univ tropEquiv.symm
79+
simp [sSup, this]
80+
apply csSup_of_not_bddAbove
81+
contrapose! hs
82+
change BddAbove (tropOrderIso.symm '' s) at hs
83+
exact tropOrderIso.symm.bddAbove_image.1 hs
84+
csInf_of_not_bddBelow := by
85+
intro s hs
86+
have : Set.range untrop = (Set.univ : Set R) := Equiv.range_eq_univ tropEquiv.symm
87+
simp [sInf, this]
88+
apply csInf_of_not_bddBelow
89+
contrapose! hs
90+
change BddBelow (tropOrderIso.symm '' s) at hs
91+
exact tropOrderIso.symm.bddBelow_image.1 hs }

Mathlib/Data/Int/ConditionallyCompleteOrder.lean

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ instance : ConditionallyCompleteLinearOrder ℤ :=
5555
have : s.Nonempty ∧ BddBelow s := ⟨hs, ⟨n, hns⟩⟩
5656
-- Porting note: this was `rw [dif_pos this]`
5757
simp only [this, and_self, dite_true, ge_iff_le]
58-
exact hns (leastOfBdd _ (Classical.choose_spec this.2) _).2.1 }
58+
exact hns (leastOfBdd _ (Classical.choose_spec this.2) _).2.1
59+
csSup_of_not_bddAbove := fun s hs ↦ by simp [hs]
60+
csInf_of_not_bddBelow := fun s hs ↦ by simp [hs] }
5961

6062
namespace Int
6163

Mathlib/Data/Nat/Lattice.lean

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,15 @@ noncomputable instance : ConditionallyCompleteLinearOrderBot ℕ :=
132132
simp only [sSup_def, Set.mem_empty_iff_false, forall_const, forall_prop_of_false,
133133
not_false_iff, exists_const]
134134
apply bot_unique (Nat.find_min' _ _)
135-
trivial }
135+
trivial
136+
csSup_of_not_bddAbove := by
137+
intro s hs
138+
simp only [mem_univ, forall_true_left, sSup]
139+
rw [dif_neg, dif_neg]
140+
· simp only [not_exists, not_forall, not_le]
141+
exact fun n ↦ ⟨n+1, lt.base n⟩
142+
· exact hs
143+
csInf_of_not_bddBelow := fun s hs ↦ by simp at hs }
136144

137145
theorem sSup_mem {s : Set ℕ} (h₁ : s.Nonempty) (h₂ : BddAbove s) : sSup s ∈ s :=
138146
let ⟨k, hk⟩ := h₂

Mathlib/Data/Real/Basic.lean

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,9 @@ noncomputable instance : ConditionallyCompleteLinearOrder ℝ :=
761761
le_csSup := fun s a hs ha => (Real.isLUB_sSup s ⟨a, ha⟩ hs).1 ha
762762
csSup_le := fun s a hs ha => (Real.isLUB_sSup s hs ⟨a, ha⟩).2 ha
763763
csInf_le := fun s a hs ha => (Real.is_glb_sInf s ⟨a, ha⟩ hs).1 ha
764-
le_csInf := fun s a hs ha => (Real.is_glb_sInf s hs ⟨a, ha⟩).2 ha }
764+
le_csInf := fun s a hs ha => (Real.is_glb_sInf s hs ⟨a, ha⟩).2 ha
765+
csSup_of_not_bddAbove := fun s hs ↦ by simp [hs, sSup_def]
766+
csInf_of_not_bddBelow := fun s hs ↦ by simp [hs, sInf_def, sSup_def] }
765767

766768
theorem lt_sInf_add_pos {s : Set ℝ} (h : s.Nonempty) {ε : ℝ} (hε : 0 < ε) :
767769
∃ a ∈ s, a < sInf s + ε :=

Mathlib/Order/CompleteLatticeIntervals.lean

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,40 @@ attribute [local instance] subsetSupSet
9696

9797
attribute [local instance] subsetInfSet
9898

99+
lemma sSup_subtype_eq_sSup_univ_of_not_bddAbove {s : Set α} [Inhabited s]
100+
(t : Set s) (ht : ¬BddAbove t) : sSup t = sSup univ := by
101+
have A : ∀ (u : Set s), ¬BddAbove u → BddAbove (Subtype.val '' u) →
102+
sSup ((↑) '' u : Set α) ∉ s := by
103+
intro u hu Hu
104+
contrapose! hu
105+
refine ⟨⟨_, hu⟩, ?_⟩
106+
rintro ⟨x, xs⟩ hx
107+
simp only [Subtype.mk_le_mk]
108+
apply le_csSup Hu
109+
exact ⟨⟨x, xs⟩, hx, rfl⟩
110+
by_cases Ht : BddAbove ((↑) '' t : Set α)
111+
· have I1 : sSup ((↑) '' t : Set α) ∉ s := A t ht Ht
112+
have I2 : sSup ((↑) '' (univ : Set s) : Set α) ∉ s := by
113+
apply A
114+
· contrapose! ht; exact ht.mono (subset_univ _)
115+
· refine ⟨sSup ((↑) '' t : Set α), ?_⟩
116+
rintro - ⟨⟨x, hx⟩, -, rfl⟩
117+
simp [BddAbove, not_nonempty_iff_eq_empty] at ht
118+
have : ⟨x, hx⟩ ∉ upperBounds t := by simp [ht]
119+
obtain ⟨⟨y, ys⟩, yt, hy⟩ : ∃ y, y ∈ t ∧ { val := x, property := hx } < y :=
120+
by simpa only [Subtype.mk_le_mk, not_forall, not_le, exists_prop, exists_and_right,
121+
mem_upperBounds]
122+
refine le_trans (le_of_lt hy) ?_
123+
exact le_csSup Ht ⟨⟨y, ys⟩, yt, rfl⟩
124+
simp only [sSup, I1, I2, dite_false]
125+
· have I : ¬BddAbove ((↑) '' (univ : Set s) : Set α) := by
126+
contrapose! Ht; exact Ht.mono (image_subset Subtype.val (subset_univ _))
127+
have X : sSup ((↑) '' t : Set α) = sSup (univ : Set α) :=
128+
ConditionallyCompleteLinearOrder.csSup_of_not_bddAbove _ Ht
129+
have Y : sSup ((↑) '' (univ : Set s) : Set α) = sSup (univ : Set α) :=
130+
ConditionallyCompleteLinearOrder.csSup_of_not_bddAbove _ I
131+
simp only [sSup, X, Y]
132+
99133
/-- For a nonempty subset of a conditionally complete linear order to be a conditionally complete
100134
linear order, it suffices that it contain the `sSup` of all its nonempty bounded-above subsets, and
101135
the `sInf` of all its nonempty bounded-below subsets.
@@ -124,7 +158,9 @@ noncomputable def subsetConditionallyCompleteLinearOrder [Inhabited s]
124158
csInf_le := by
125159
rintro t c h_bdd hct
126160
rw [← Subtype.coe_le_coe, ← subset_sInf_of_within s (h_Inf ⟨c, hct⟩ h_bdd)]
127-
exact (Subtype.mono_coe s).csInf_image_le hct h_bdd }
161+
exact (Subtype.mono_coe s).csInf_image_le hct h_bdd
162+
csSup_of_not_bddAbove := sSup_subtype_eq_sSup_univ_of_not_bddAbove
163+
csInf_of_not_bddBelow := @sSup_subtype_eq_sSup_univ_of_not_bddAbove αᵒᵈ _ _ _ }
128164
#align subset_conditionally_complete_linear_order subsetConditionallyCompleteLinearOrder
129165

130166
section OrdConnected

Mathlib/Order/ConditionallyCompleteLattice/Basic.lean

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ class ConditionallyCompleteLinearOrder (α : Type*) extends ConditionallyComplet
201201
/-- In a `ConditionallyCompleteLinearOrder`, we assume the order relations are all decidable. -/
202202
decidableLT : DecidableRel (· < · : α → α → Prop) :=
203203
@decidableLTOfDecidableLE _ _ decidableLE
204+
/-- If a set is not bounded above, its supremum is by convention `Sup univ`. -/
205+
csSup_of_not_bddAbove : ∀ s, ¬BddAbove s → sSup s = sSup (univ : Set α)
206+
/-- If a set is not bounded below, its infimum is by convention `Inf univ`. -/
207+
csInf_of_not_bddBelow : ∀ s, ¬BddBelow s → sInf s = sInf (univ : Set α)
204208
#align conditionally_complete_linear_order ConditionallyCompleteLinearOrder
205209

206210
instance (α : Type*) [ConditionallyCompleteLinearOrder α] : LinearOrder α :=
@@ -256,7 +260,10 @@ instance (priority := 100) CompleteLattice.toConditionallyCompleteLattice [Compl
256260
-- see Note [lower instance priority]
257261
instance (priority := 100) CompleteLinearOrder.toConditionallyCompleteLinearOrderBot {α : Type*}
258262
[h : CompleteLinearOrder α] : ConditionallyCompleteLinearOrderBot α :=
259-
{ CompleteLattice.toConditionallyCompleteLattice, h with csSup_empty := sSup_empty }
263+
{ CompleteLattice.toConditionallyCompleteLattice, h with
264+
csSup_empty := sSup_empty
265+
csSup_of_not_bddAbove := fun s H ↦ (H (OrderTop.bddAbove s)).elim
266+
csInf_of_not_bddBelow := fun s H ↦ (H (OrderBot.bddBelow s)).elim }
260267
#align complete_linear_order.to_conditionally_complete_linear_order_bot CompleteLinearOrder.toConditionallyCompleteLinearOrderBot
261268

262269
section
@@ -285,7 +292,15 @@ noncomputable def IsWellOrder.conditionallyCompleteLinearOrderBot (α : Type*)
285292
have h's : (upperBounds s).Nonempty := ⟨a, has⟩
286293
simp only [h's, dif_pos]
287294
simpa using h.wf.not_lt_min _ h's has
288-
csSup_empty := by simpa using eq_bot_iff.2 (not_lt.1 <| h.wf.not_lt_min _ _ <| mem_univ ⊥) }
295+
csSup_empty := by simpa using eq_bot_iff.2 (not_lt.1 <| h.wf.not_lt_min _ _ <| mem_univ ⊥)
296+
csSup_of_not_bddAbove := by
297+
intro s H
298+
have A : ¬(BddAbove (univ : Set α)) := by
299+
contrapose! H; exact H.mono (subset_univ _)
300+
have B : ¬((upperBounds s).Nonempty) := H
301+
have C : ¬((upperBounds (univ : Set α)).Nonempty) := A
302+
simp [sSup, B, C]
303+
csInf_of_not_bddBelow := fun s H ↦ (H (OrderBot.bddBelow s)).elim }
289304
#align is_well_order.conditionally_complete_linear_order_bot IsWellOrder.conditionallyCompleteLinearOrderBot
290305

291306
end
@@ -301,7 +316,9 @@ instance instConditionallyCompleteLatticeOrderDual (α : Type*) [ConditionallyCo
301316
csInf_le := @ConditionallyCompleteLattice.le_csSup α _ }
302317

303318
instance (α : Type*) [ConditionallyCompleteLinearOrder α] : ConditionallyCompleteLinearOrder αᵒᵈ :=
304-
{ instConditionallyCompleteLatticeOrderDual α, OrderDual.instLinearOrder α with }
319+
{ instConditionallyCompleteLatticeOrderDual α, OrderDual.instLinearOrder α with
320+
csSup_of_not_bddAbove := @ConditionallyCompleteLinearOrder.csInf_of_not_bddBelow α _
321+
csInf_of_not_bddBelow := @ConditionallyCompleteLinearOrder.csSup_of_not_bddAbove α _ }
305322

306323
end OrderDual
307324

@@ -961,6 +978,52 @@ theorem exists_lt_of_ciInf_lt [Nonempty ι] {f : ι → α} (h : iInf f < a) :
961978
@exists_lt_of_lt_ciSup αᵒᵈ _ _ _ _ _ h
962979
#align exists_lt_of_cinfi_lt exists_lt_of_ciInf_lt
963980

981+
theorem csSup_of_not_bddAbove {s : Set α} (hs : ¬BddAbove s) : sSup s = sSup univ :=
982+
ConditionallyCompleteLinearOrder.csSup_of_not_bddAbove s hs
983+
984+
theorem csInf_of_not_bddBelow {s : Set α} (hs : ¬BddBelow s) : sInf s = sInf univ :=
985+
ConditionallyCompleteLinearOrder.csInf_of_not_bddBelow s hs
986+
987+
/-- When every element of a set `s` is bounded by an element of a set `t`, and conversely, then
988+
`s` and `t` have the same supremum. This holds even when the sets may be empty or unbounded. -/
989+
theorem csSup_eq_csSup_of_forall_exists_le {s t : Set α}
990+
(hs : ∀ x ∈ s, ∃ y ∈ t, x ≤ y) (ht : ∀ y ∈ t, ∃ x ∈ s, y ≤ x) :
991+
sSup s = sSup t := by
992+
rcases eq_empty_or_nonempty s with rfl|s_ne
993+
· have : t = ∅ := eq_empty_of_forall_not_mem (fun y yt ↦ by simpa using ht y yt)
994+
rw [this]
995+
rcases eq_empty_or_nonempty t with rfl|t_ne
996+
· have : s = ∅ := eq_empty_of_forall_not_mem (fun x xs ↦ by simpa using hs x xs)
997+
rw [this]
998+
by_cases B : BddAbove s ∨ BddAbove t
999+
· have Bs : BddAbove s := by
1000+
rcases B with hB|⟨b, hb⟩
1001+
· exact hB
1002+
· refine ⟨b, fun x hx ↦ ?_⟩
1003+
rcases hs x hx with ⟨y, hy, hxy⟩
1004+
exact hxy.trans (hb hy)
1005+
have Bt : BddAbove t := by
1006+
rcases B with ⟨b, hb⟩|hB
1007+
· refine ⟨b, fun y hy ↦ ?_⟩
1008+
rcases ht y hy with ⟨x, hx, hyx⟩
1009+
exact hyx.trans (hb hx)
1010+
· exact hB
1011+
apply le_antisymm
1012+
· apply csSup_le s_ne (fun x hx ↦ ?_)
1013+
rcases hs x hx with ⟨y, yt, hxy⟩
1014+
exact hxy.trans (le_csSup Bt yt)
1015+
· apply csSup_le t_ne (fun y hy ↦ ?_)
1016+
rcases ht y hy with ⟨x, xs, hyx⟩
1017+
exact hyx.trans (le_csSup Bs xs)
1018+
· simp [csSup_of_not_bddAbove, (not_or.1 B).1, (not_or.1 B).2]
1019+
1020+
/-- When every element of a set `s` is bounded by an element of a set `t`, and conversely, then
1021+
`s` and `t` have the same supremum. This holds even when the sets may be empty or unbounded. -/
1022+
theorem csInf_eq_csInf_of_forall_exists_le {s t : Set α}
1023+
(hs : ∀ x ∈ s, ∃ y ∈ t, y ≤ x) (ht : ∀ y ∈ t, ∃ x ∈ s, x ≤ y) :
1024+
sInf s = sInf t :=
1025+
@csSup_eq_csSup_of_forall_exists_le αᵒᵈ _ s t hs ht
1026+
9641027
open Function
9651028

9661029
variable [IsWellOrder α (· < ·)]

0 commit comments

Comments
 (0)