Skip to content

Commit 3f56d9a

Browse files
committed
feat(Order/ConditionallyCompleteLattice): Generalize and add cbiSup/cbiInf theorems (leanprover-community#37526)
Generalize some theorems concerning cbiSup (`⨆ i, ⨆ h : p i, f i h`) by removing superfluous `Nonempty` typeclasses and parameters. It would be nice to also remove the `BoundedAbove` typeclass, but this can only be done with linear orders because junk values of lattices are not currently specified[0]. [0]: https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Moving.20.60csSup.60.20junk.20into.20.60ConditionallyCompleteLattice.60/near/583143345 In the absence of that, we provide the theorem `cbiSup_of_not_bddAbove` defining the junk values of `cbiSup` in the linear order case. Add theorem `cbiSup_id`, showing that `⨆ i ∈ s, i = sSup s`. Add theorem `cbiSup_eq_of_forall_not` as a counterpart to `cbiSup_eq_of_forall` when the condition is never true, and a corollary `cbiSup_empty` for the obvious empty set case. Use the new theorems to shorten the proof of `cbiSup_eq_of_not_forall`. Give proper names to the prime versions of `ciSup_subtype` and `ciInf_subtype`. Moves: - `ciSup_subtype'` -> `cbiSup_eq_ciSup_subtype` - `ciInf_subtype'` -> `cbiInf_eq_ciInf_subtype` - `ciSup_subtype''` -> `ciSup_subtype_fun` - `ciInf_subtype''` -> `ciInf_subtype_fun` Co-authored-by: SabrinaJewson <sejewson@gmail.com>
1 parent 5a1c5fc commit 3f56d9a

3 files changed

Lines changed: 73 additions & 60 deletions

File tree

Mathlib/Order/ConditionallyCompleteLattice/Indexed.lean

Lines changed: 61 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,12 @@ lemma Set.Ici_ciSup [Nonempty ι] {f : ι → α} (hf : BddAbove (range f)) :
259259
Ici (⨆ i, f i) = ⋂ i, Ici (f i) :=
260260
Iic_ciInf (α := αᵒᵈ) hf
261261

262-
theorem ciSup_subtype [Nonempty ι] {p : ι → Prop} [Nonempty (Subtype p)] {f : Subtype p → α}
262+
theorem ciSup_subtype {p : ι → Prop} {f : Subtype p → α}
263263
(hf : BddAbove (Set.range f)) (hf' : sSup ∅ ≤ iSup f) :
264264
iSup f = ⨆ (i) (h : p i), f ⟨i, h⟩ := by
265+
cases isEmpty_or_nonempty (Subtype p)
266+
· rw [iSup_of_empty', cbiSup_eq_of_forall_not fun i h ↦ isEmptyElim (⟨i, h⟩ : Subtype p)]
267+
have : Nonempty ι := (nonempty_subtype.mp ‹_›).nonempty
265268
classical
266269
refine le_antisymm (ciSup_le ?_) ?_
267270
· intro ⟨i, h⟩
@@ -277,49 +280,66 @@ theorem ciSup_subtype [Nonempty ι] {p : ι → Prop} [Nonempty (Subtype p)] {f
277280
· exact le_ciSup hf ?_
278281
· exact hf'
279282

280-
theorem ciInf_subtype [Nonempty ι] {p : ι → Prop} [Nonempty (Subtype p)] {f : Subtype p → α}
283+
theorem ciInf_subtype {p : ι → Prop} {f : Subtype p → α}
281284
(hf : BddBelow (Set.range f)) (hf' : iInf f ≤ sInf ∅) :
282285
iInf f = ⨅ (i) (h : p i), f ⟨i, h⟩ :=
283286
ciSup_subtype (α := αᵒᵈ) hf hf'
284287

285-
theorem ciSup_subtype' [Nonempty ι] {p : ι → Prop} [Nonempty (Subtype p)] {f : ∀ i, p i → α}
288+
theorem cbiSup_eq_ciSup_subtype {p : ι → Prop} {f : ∀ i, p i → α}
286289
(hf : BddAbove (Set.range (fun i : Subtype p ↦ f i i.prop)))
287290
(hf' : sSup ∅ ≤ ⨆ (i : Subtype p), f i i.prop) :
288291
⨆ (i) (h), f i h = ⨆ x : Subtype p, f x x.property :=
289292
(ciSup_subtype (f := fun x => f x.val x.property) hf hf').symm
290293

291-
theorem ciInf_subtype' [Nonempty ι] {p : ι → Prop} [Nonempty (Subtype p)] {f : ∀ i, p i → α}
294+
@[deprecated (since := "2026-04-04")] alias ciSup_subtype' := cbiSup_eq_ciSup_subtype
295+
296+
theorem cbiInf_eq_ciInf_subtype {p : ι → Prop} {f : ∀ i, p i → α}
292297
(hf : BddBelow (Set.range (fun i : Subtype p ↦ f i i.prop)))
293298
(hf' : ⨅ (i : Subtype p), f i i.prop ≤ sInf ∅) :
294299
⨅ (i) (h), f i h = ⨅ x : Subtype p, f x x.property :=
295300
(ciInf_subtype (f := fun x => f x.val x.property) hf hf').symm
296301

297-
theorem ciSup_subtype'' {ι} [Nonempty ι] {s : Set ι} (hs : s.Nonempty) {f : ι → α}
302+
@[deprecated (since := "2026-04-04")] alias ciInf_subtype' := cbiInf_eq_ciInf_subtype
303+
304+
theorem ciSup_subtype_fun {ι} {s : Set ι} {f : ι → α}
298305
(hf : BddAbove (Set.range fun i : s ↦ f i)) (hf' : sSup ∅ ≤ ⨆ i : s, f i) :
299306
⨆ i : s, f i = ⨆ (t : ι) (_ : t ∈ s), f t :=
300-
haveI : Nonempty s := Set.Nonempty.to_subtype hs
301307
ciSup_subtype hf hf'
302308

303-
theorem ciInf_subtype'' {ι} [Nonempty ι] {s : Set ι} (hs : s.Nonempty) {f : ι → α}
309+
@[deprecated (since := "2026-04-04")] alias ciSup_subtype'' := ciSup_subtype_fun
310+
311+
theorem ciInf_subtype_fun {ι} {s : Set ι} {f : ι → α}
304312
(hf : BddBelow (Set.range fun i : s ↦ f i)) (hf' : ⨅ i : s, f i ≤ sInf ∅) :
305313
⨅ i : s, f i = ⨅ (t : ι) (_ : t ∈ s), f t :=
306-
haveI : Nonempty s := Set.Nonempty.to_subtype hs
307314
ciInf_subtype hf hf'
308315

309-
theorem csSup_image [Nonempty β] {s : Set β} (hs : s.Nonempty) {f : β → α}
316+
@[deprecated (since := "2026-04-04")] alias ciInf_subtype'' := ciInf_subtype_fun
317+
318+
theorem csSup_image {s : Set β} {f : β → α}
310319
(hf : BddAbove (Set.range fun i : s ↦ f i)) (hf' : sSup ∅ ≤ ⨆ i : s, f i) :
311320
sSup (f '' s) = ⨆ a ∈ s, f a := by
312-
rw [← ciSup_subtype'' hs hf hf', iSup, Set.image_eq_range]
321+
rw [← ciSup_subtype_fun hf hf', iSup, Set.image_eq_range]
313322

314-
theorem csInf_image [Nonempty β] {s : Set β} (hs : s.Nonempty) {f : β → α}
323+
theorem csInf_image {s : Set β} {f : β → α}
315324
(hf : BddBelow (Set.range fun i : s ↦ f i)) (hf' : ⨅ i : s, f i ≤ sInf ∅) :
316325
sInf (f '' s) = ⨅ a ∈ s, f a :=
317-
csSup_image (α := αᵒᵈ) hs hf hf'
326+
csSup_image (α := αᵒᵈ) hf hf'
327+
328+
theorem cbiSup_id {s : Set α} (hs : BddAbove s) (h : sSup ∅ ≤ sSup s) : ⨆ i ∈ s, i = sSup s := by
329+
rw [← csSup_image (Subtype.range_coe ▸ hs), Set.image_id']
330+
· convert h
331+
rw [← sSup_range, Subtype.range_coe]
318332

319-
lemma ciSup_image {α ι ι' : Type*} [ConditionallyCompleteLattice α] [Nonempty ι] [Nonempty ι']
320-
{s : Set ι} (hs : s.Nonempty) {f : ι → ι'} {g : ι' → α}
333+
theorem cbiInf_id {s : Set α} (hs : BddBelow s) (h : sInf s ≤ sInf ∅) : ⨅ i ∈ s, i = sInf s := by
334+
rw [← csInf_image (Subtype.range_coe ▸ hs), Set.image_id']
335+
· convert h
336+
rw [← sInf_range, Subtype.range_coe]
337+
338+
lemma ciSup_image {ι ι' : Type*} {s : Set ι} {f : ι → ι'} {g : ι' → α}
321339
(hf : BddAbove (Set.range fun i : s ↦ g (f i))) (hg' : sSup ∅ ≤ ⨆ i : s, g (f i)) :
322340
⨆ i ∈ (f '' s), g i = ⨆ x ∈ s, g (f x) := by
341+
rcases s.eq_empty_or_nonempty with (rfl | hs)
342+
· rw [Set.image_empty, cbiSup_empty, cbiSup_empty]
323343
have hg : BddAbove (Set.range fun i : f '' s ↦ g i) := by
324344
simpa [bddAbove_def] using hf
325345
have hf' : sSup ∅ ≤ ⨆ i : f '' s, g i := by
@@ -333,13 +353,12 @@ lemma ciSup_image {α ι ι' : Type*} [ConditionallyCompleteLattice α] [Nonempt
333353
rw [← ht]
334354
refine le_ciSup_set ?_ t.prop
335355
simpa [bddAbove_def] using hf
336-
rw [← csSup_image (by simpa using hs) hg hf', ← csSup_image hs hf hg', ← Set.image_comp, comp_def]
356+
rw [← csSup_image hg hf', ← csSup_image hf hg', ← Set.image_comp, comp_def]
337357

338-
lemma ciInf_image {α ι ι' : Type*} [ConditionallyCompleteLattice α] [Nonempty ι] [Nonempty ι']
339-
{s : Set ι} (hs : s.Nonempty) {f : ι → ι'} {g : ι' → α}
358+
lemma ciInf_image {ι ι' : Type*} {s : Set ι} {f : ι → ι'} {g : ι' → α}
340359
(hf : BddBelow (Set.range fun i : s ↦ g (f i))) (hg' : ⨅ i : s, g (f i) ≤ sInf ∅) :
341360
⨅ i ∈ (f '' s), g i = ⨅ x ∈ s, g (f x) :=
342-
ciSup_image (α := αᵒᵈ) hs hf hg'
361+
ciSup_image (α := αᵒᵈ) hf hg'
343362

344363
end ConditionallyCompleteLattice
345364

@@ -368,46 +387,32 @@ theorem ciInf_lt_iff [Nonempty ι] {f : ι → α} (hb : BddBelow (range f)) :
368387
iInf f < a ↔ ∃ i, f i < a := by
369388
simpa only [mem_range, exists_exists_eq_and] using csInf_lt_iff hb (range_nonempty _)
370389

390+
theorem cbiSup_of_not_bddAbove {p : ι → Prop} {f : ∀ i, p i → α}
391+
(h : ¬BddAbove (range fun i : Subtype p ↦ f i i.prop)) :
392+
⨆ (i : ι), ⨆ (h : p i), f i h = sSup ∅ :=
393+
ciSup_of_not_bddAbove fun ⟨u, hu⟩ ↦ h ⟨u, fun _ ⟨x, hx⟩ ↦ hx ▸ hu ⟨x, ciSup_pos x.prop⟩⟩
394+
395+
theorem cbiInf_of_not_bddBelow {p : ι → Prop} {f : ∀ i, p i → α}
396+
(h : ¬BddBelow (range fun i : Subtype p ↦ f i i.prop)) :
397+
⨅ (i : ι), ⨅ (h : p i), f i h = sInf ∅ :=
398+
ciInf_of_not_bddBelow fun ⟨u, hu⟩ ↦ h ⟨u, fun _ ⟨x, hx⟩ ↦ hx ▸ hu ⟨x, ciInf_pos x.prop⟩⟩
399+
371400
theorem cbiSup_eq_of_not_forall {p : ι → Prop} {f : Subtype p → α} (hp : ¬ (∀ i, p i)) :
372401
⨆ (i) (h : p i), f ⟨i, h⟩ = iSup f ⊔ sSup ∅ := by
373-
classical
374-
rcases not_forall.1 hp with ⟨i₀, hi₀⟩
375-
have : Nonempty ι := ⟨i₀⟩
376-
simp only [ciSup_eq_ite]
377-
by_cases H : BddAbove (range f)
378-
· have B : BddAbove (range fun i ↦ if h : p i then f ⟨i, h⟩ else sSup ∅) := by
379-
rcases H with ⟨c, hc⟩
380-
refine ⟨c ⊔ sSup ∅, ?_⟩
381-
rintro - ⟨i, rfl⟩
382-
by_cases hi : p i
383-
· simp only [hi, dite_true, le_sup_iff, hc (mem_range_self _), true_or]
384-
· simp only [hi, dite_false, le_sup_right]
385-
apply le_antisymm
386-
· apply ciSup_le (fun i ↦ ?_)
387-
by_cases hi : p i
388-
· simp only [hi, dite_true, le_sup_iff]
389-
left
390-
exact le_ciSup H _
391-
· simp [hi]
392-
· apply sup_le
393-
· rcases isEmpty_or_nonempty (Subtype p) with hp | hp
394-
· rw [iSup_of_empty']
395-
convert le_ciSup B i₀
396-
simp [hi₀]
397-
· apply ciSup_le
398-
rintro ⟨i, hi⟩
399-
convert le_ciSup B i
400-
simp [hi]
401-
· convert le_ciSup B i₀
402-
simp [hi₀]
403-
· have : iSup f = sSup (∅ : Set α) := csSup_of_not_bddAbove H
404-
simp only [this, le_refl, sup_of_le_left]
405-
apply csSup_of_not_bddAbove
406-
contrapose! H
407-
apply H.mono
408-
rintro - ⟨i, rfl⟩
409-
convert mem_range_self i.1
410-
simp [i.2]
402+
rcases le_or_gt (sSup ∅) (iSup f) with le|gt
403+
· rw [max_eq_left le]
404+
by_cases bdd : BddAbove (range f)
405+
· rw [← ciSup_subtype bdd le]
406+
· rw [ciSup_of_not_bddAbove bdd, cbiSup_of_not_bddAbove bdd]
407+
have ⟨i, hi⟩ := not_forall.mp hp
408+
have : Nonempty ι := ⟨i⟩
409+
have bdd : BddAbove (range f) := not_not.mp fun h ↦ gt.ne (ciSup_of_not_bddAbove h)
410+
rw [max_eq_right gt.le]
411+
refine ciSup_eq_of_forall_le_of_forall_lt_exists_gt (fun j ↦ ?_) ?_
412+
· by_cases hj : p j
413+
· exact ((ciSup_pos hj).trans_le (le_ciSup bdd ⟨j, hj⟩)).trans gt.le
414+
· exact (ciSup_neg hj).le
415+
· exact fun w hw ↦ ⟨i, hw.trans_eq (ciSup_neg hi).symm⟩
411416

412417
theorem cbiInf_eq_of_not_forall {p : ι → Prop} {f : Subtype p → α} (hp : ¬ (∀ i, p i)) :
413418
⨅ (i) (h : p i), f ⟨i, h⟩ = iInf f ⊓ sInf ∅ :=

Mathlib/Order/ConditionallyCompletePartialOrder/Indexed.lean

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,18 @@ theorem cbiSup_eq_of_forall {p : ι → Prop} {f : Subtype p → α} (hp : ∀ i
119119
· rintro - ⟨i, rfl⟩
120120
simp
121121

122+
@[to_dual]
123+
lemma cbiSup_eq_of_forall_not {p : ι → Prop} {f : ∀ i, p i → α} (hp : ∀ i, ¬p i) :
124+
⨆ (i) (h : p i), f i h = sSup ∅ := by
125+
cases isEmpty_or_nonempty ι
126+
· rw [iSup_of_empty']
127+
· have (i : ι) : IsEmpty (p i) := ⟨hp i⟩
128+
simp only [iSup_of_empty', ciSup_const]
129+
130+
@[to_dual]
131+
theorem cbiSup_empty {f : β → α} : ⨆ i ∈ (∅ : Set β), f i = sSup ∅ :=
132+
cbiSup_eq_of_forall_not Set.notMem_empty
133+
122134
/-- Introduction rule to prove that `b` is the supremum of `f`: it suffices to check that `b`
123135
is larger than `f i` for all `i`, and that this is not the case of any `w<b`.
124136
See `iSup_eq_of_forall_le_of_forall_lt_exists_gt` for a version in complete lattices. -/

scripts/nolints_prime_decls.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,6 @@ ChartedSpaceCore.open_source'
593593
CharTwo.neg_eq'
594594
ciInf_le'
595595
ciInf_le_of_le'
596-
ciInf_subtype'
597-
ciInf_subtype''
598596
CircleDeg1Lift.tendsto_translation_number'
599597
CircleDeg1Lift.tendsto_translation_number₀'
600598
CircleDeg1Lift.translationNumber_conj_eq'
@@ -605,8 +603,6 @@ ciSup_le'
605603
ciSup_le_iff'
606604
ciSup_mono'
607605
ciSup_or'
608-
ciSup_subtype'
609-
ciSup_subtype''
610606
Classical.choose_eq'
611607
CliffordAlgebra.instAlgebra'
612608
CliffordAlgebra.star_def'

0 commit comments

Comments
 (0)