Skip to content

Commit

Permalink
feat: More complete lattice WithTop lemmas (#6947)
Browse files Browse the repository at this point in the history
and corresponding lemmas for `ℕ∞`.

Also fix implicitness of `iff` lemmas.
  • Loading branch information
YaelDillies committed Sep 4, 2023
1 parent 05474e3 commit 1cf05bb
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 27 deletions.
3 changes: 1 addition & 2 deletions Mathlib/Analysis/NormedSpace/BanachSteinhaus.lean
Expand Up @@ -47,8 +47,7 @@ theorem banach_steinhaus_iSup_nnnorm {ι : Type*} [CompleteSpace E] {g : ι →
(h : ∀ x, (⨆ i, ↑‖g i x‖₊) < ∞) : (⨆ i, ↑‖g i‖₊) < ∞ := by
rw [show ((⨆ i, ↑‖g i‖₊) < ∞) ↔ _ from (NormedSpace.equicontinuous_TFAE g).out 8 2]
refine (norm_withSeminorms 𝕜₂ F).banach_steinhaus (fun _ x ↦ ?_)
simpa [← NNReal.bddAbove_coe, ← Set.range_comp] using
(WithTop.iSup_coe_lt_top (fun i ↦ ‖g i x‖₊)).mp (h x)
simpa [← NNReal.bddAbove_coe, ← Set.range_comp] using ENNReal.iSup_coe_lt_top.1 (h x)
#align banach_steinhaus_supr_nnnorm banach_steinhaus_iSup_nnnorm

open Topology
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Analysis/NormedSpace/OperatorNorm.lean
Expand Up @@ -2066,7 +2066,7 @@ protected theorem NormedSpace.equicontinuous_TFAE : List.TFAE
tfae_have 68
· simp_rw [bddAbove_def, Set.forall_range_iff]
tfae_have 89
· rw [ENNReal.iSup_coe_lt_top (fun i ↦ ‖f i‖₊), ← NNReal.bddAbove_coe, ← Set.range_comp]
· rw [ENNReal.iSup_coe_lt_top, ← NNReal.bddAbove_coe, ← Set.range_comp]
rfl
-- `3 ↔ 4` is the interesting part of the result. It is essentially a combination of
-- `WithSeminorms.uniformEquicontinuous_iff_exists_continuous_seminorm` which turns
Expand Down
24 changes: 16 additions & 8 deletions Mathlib/Data/ENat/Lattice.lean
Expand Up @@ -17,19 +17,27 @@ We also restate some lemmas about `WithTop` for `ENat` to have versions that use
of `WithTop.some`.
-/

open Set

-- porting notes: was `deriving instance` but "default handlers have not been implemented yet"
-- porting notes: `noncomputable` through 'Nat.instConditionallyCompleteLinearOrderBotNat'
noncomputable instance : CompleteLinearOrder ENat :=
inferInstanceAs (CompleteLinearOrder (WithTop ℕ))

namespace ENat

variable {ι : Sort*} {f : ι → ℕ}

lemma iSup_coe_lt_top : (⨆ x, ↑(f x) : ℕ∞) < ⊤ ↔ BddAbove (Set.range f) :=
WithTop.iSup_coe_lt_top f

theorem coe_iSup (h : BddAbove (Set.range f)) : ↑(⨆ i, f i) = (⨆ i, f i : ℕ∞) :=
WithTop.coe_iSup _ h
variable {ι : Sort*} {f : ι → ℕ} {s : Set ℕ}

lemma iSup_coe_eq_top : ⨆ i, (f i : ℕ∞) = ⊤ ↔ ¬ BddAbove (range f) := WithTop.iSup_coe_eq_top
lemma iSup_coe_ne_top : ⨆ i, (f i : ℕ∞) ≠ ⊤ ↔ BddAbove (range f) := iSup_coe_eq_top.not_left
lemma iSup_coe_lt_top : ⨆ i, (f i : ℕ∞) < ⊤ ↔ BddAbove (range f) := WithTop.iSup_coe_lt_top
lemma iInf_coe_eq_top : ⨅ i, (f i : ℕ∞) = ⊤ ↔ IsEmpty ι := WithTop.iInf_coe_eq_top
lemma iInf_coe_ne_top : ⨅ i, (f i : ℕ∞) ≠ ⊤ ↔ Nonempty ι :=
by rw [Ne.def, iInf_coe_eq_top, not_isEmpty_iff]
lemma iInf_coe_lt_top : ⨅ i, (f i : ℕ∞) < ⊤ ↔ Nonempty ι := WithTop.iInf_coe_lt_top

lemma coe_sSup : BddAbove s → ↑(sSup s) = ⨆ a ∈ s, (a : ℕ∞) := WithTop.coe_sSup
lemma coe_sInf : s.Nonempty → ↑(sInf s) = ⨅ a ∈ s, (a : ℕ∞) := WithTop.coe_sInf
lemma coe_iSup : BddAbove (range f) → ↑(⨆ i, f i) = ⨆ i, (f i : ℕ∞) := WithTop.coe_iSup _
@[norm_cast] lemma coe_iInf [Nonempty ι] : ↑(⨅ i, f i) = ⨅ i, (f i : ℕ∞) := WithTop.coe_iInf _

end ENat
16 changes: 6 additions & 10 deletions Mathlib/Data/Real/ENNReal.lean
Expand Up @@ -950,6 +950,7 @@ theorem abs_toReal {x : ℝ≥0∞} : |x.toReal| = x.toReal := by cases x <;> si
end Order

section CompleteLattice
variable {ι : Sort*} {f : ι → ℝ≥0}

theorem coe_sSup {s : Set ℝ≥0} : BddAbove s → (↑(sSup s) : ℝ≥0∞) = ⨆ a ∈ s, ↑a :=
WithTop.coe_sSup
Expand All @@ -974,13 +975,10 @@ theorem coe_mem_upperBounds {s : Set ℝ≥0} :
simp (config := { contextual := true }) [upperBounds, ball_image_iff, -mem_image, *]
#align ennreal.coe_mem_upper_bounds ENNReal.coe_mem_upperBounds

theorem iSup_coe_eq_top {ι : Sort*} (f : ι → ℝ≥0) :
⨆ x, (f x : ℝ≥0∞) = ⊤ ↔ ¬BddAbove (Set.range f) :=
WithTop.iSup_coe_eq_top f

theorem iSup_coe_lt_top {ι : Sort*} (f : ι → ℝ≥0) :
⨆ x, (f x : ℝ≥0∞) < ⊤ ↔ BddAbove (Set.range f) :=
WithTop.iSup_coe_lt_top f
lemma iSup_coe_eq_top : ⨆ i, (f i : ℝ≥0∞) = ⊤ ↔ ¬ BddAbove (range f) := WithTop.iSup_coe_eq_top
lemma iSup_coe_lt_top : ⨆ i, (f i : ℝ≥0∞) < ⊤ ↔ BddAbove (range f) := WithTop.iSup_coe_lt_top
lemma iInf_coe_eq_top : ⨅ i, (f i : ℝ≥0∞) = ⊤ ↔ IsEmpty ι := WithTop.iInf_coe_eq_top
lemma iInf_coe_lt_top : ⨅ i, (f i : ℝ≥0∞) < ⊤ ↔ Nonempty ι := WithTop.iInf_coe_lt_top

end CompleteLattice

Expand Down Expand Up @@ -2417,9 +2415,7 @@ theorem toNNReal_iSup (hf : ∀ i, f i ≠ ∞) : (iSup f).toNNReal = ⨆ i, (f
simp_rw [toNNReal_coe]
by_cases h : BddAbove (range f)
· rw [← coe_iSup h, toNNReal_coe]
· -- porting note: middle lemma now needs `erw` as `ENNReal` does not reduce to `WithTop NNReal`
-- https://github.com/leanprover-community/mathlib4/issues/5164
erw [NNReal.iSup_of_not_bddAbove h, (WithTop.iSup_coe_eq_top f).mpr h, top_toNNReal]
· rw [NNReal.iSup_of_not_bddAbove h, iSup_coe_eq_top.2 h, top_toNNReal]
#align ennreal.to_nnreal_supr ENNReal.toNNReal_iSup

theorem toNNReal_sSup (s : Set ℝ≥0∞) (hs : ∀ r ∈ s, r ≠ ∞) :
Expand Down
6 changes: 6 additions & 0 deletions Mathlib/Data/Sigma/Basic.lean
Expand Up @@ -103,6 +103,12 @@ theorem «exists» {p : (Σa, β a) → Prop} : (∃ x, p x) ↔ ∃ a b, p ⟨a
fun ⟨⟨a, b⟩, h⟩ ↦ ⟨a, b, h⟩, fun ⟨a, b, h⟩ ↦ ⟨⟨a, b⟩, h⟩⟩
#align sigma.exists Sigma.exists

lemma exists' {p : ∀ a, β a → Prop} : (∃ a b, p a b) ↔ ∃ x : Σ a, β a, p x.1 x.2 :=
(Sigma.exists (p := λ x ↦ p x.1 x.2)).symm

lemma forall' {p : ∀ a, β a → Prop} : (∀ a b, p a b) ↔ ∀ x : Σ a, β a, p x.1 x.2 :=
(Sigma.forall (p := λ x ↦ p x.1 x.2)).symm

/-- Map the left and right components of a sigma -/
def map (f₁ : α₁ → α₂) (f₂ : ∀ a, β₁ a → β₂ (f₁ a)) (x : Sigma β₁) : Sigma β₂ :=
⟨f₁ x.1, f₂ x.1 x.2
Expand Down
14 changes: 14 additions & 0 deletions Mathlib/Order/CompleteLattice.lean
Expand Up @@ -1545,6 +1545,14 @@ theorem iInf_sigma {p : β → Type*} {f : Sigma p → α} : ⨅ x, f x = ⨅ (i
@iSup_sigma αᵒᵈ _ _ _ _
#align infi_sigma iInf_sigma

lemma iSup_sigma' {κ : β → Type*} (f : ∀ i, κ i → α) :
(⨆ i, ⨆ j, f i j) = ⨆ x : Σ i, κ i, f x.1 x.2 :=
(iSup_sigma (f := λ x ↦ f x.1 x.2)).symm

lemma iInf_sigma' {κ : β → Type*} (f : ∀ i, κ i → α) :
(⨅ i, ⨅ j, f i j) = ⨅ x : Σ i, κ i, f x.1 x.2 :=
(iInf_sigma (f := λ x ↦ f x.1 x.2)).symm

theorem iSup_prod {f : β × γ → α} : ⨆ x, f x = ⨆ (i) (j), f (i, j) :=
eq_of_forall_ge_iff fun c => by simp only [iSup_le_iff, Prod.forall]
#align supr_prod iSup_prod
Expand All @@ -1553,6 +1561,12 @@ theorem iInf_prod {f : β × γ → α} : ⨅ x, f x = ⨅ (i) (j), f (i, j) :=
@iSup_prod αᵒᵈ _ _ _ _
#align infi_prod iInf_prod

lemma iSup_prod' (f : β → γ → α) : (⨆ i, ⨆ j, f i j) = ⨆ x : β × γ, f x.1 x.2 :=
(iSup_prod (f := λ x ↦ f x.1 x.2)).symm

lemma iInf_prod' (f : β → γ → α) : (⨅ i, ⨅ j, f i j) = ⨅ x : β × γ, f x.1 x.2 :=
(iInf_prod (f := λ x ↦ f x.1 x.2)).symm

theorem biSup_prod {f : β × γ → α} {s : Set β} {t : Set γ} :
⨆ x ∈ s ×ˢ t, f x = ⨆ (a ∈ s) (b ∈ t), f (a, b) := by
simp_rw [iSup_prod, mem_prod, iSup_and]
Expand Down
17 changes: 12 additions & 5 deletions Mathlib/Order/ConditionallyCompleteLattice/Basic.lean
Expand Up @@ -1593,8 +1593,10 @@ noncomputable instance WithBot.WithTop.completeLinearOrder {α : Type*}
{ WithBot.WithTop.completeLattice, WithBot.linearOrder with }
#align with_bot.with_top.complete_linear_order WithBot.WithTop.completeLinearOrder

theorem WithTop.iSup_coe_eq_top {ι : Sort*} {α : Type*} [ConditionallyCompleteLinearOrderBot α]
(f : ι → α) : ⨆ x, (f x : WithTop α) = ⊤ ↔ ¬BddAbove (Set.range f) := by
namespace WithTop
variable [ConditionallyCompleteLinearOrderBot α] {f : ι → α}

lemma iSup_coe_eq_top : ⨆ x, (f x : WithTop α) = ⊤ ↔ ¬BddAbove (range f) := by
rw [iSup_eq_top, not_bddAbove_iff]
refine' ⟨fun hf r => _, fun hf a ha => _⟩
· rcases hf r (WithTop.coe_lt_top r) with ⟨i, hi⟩
Expand All @@ -1603,11 +1605,16 @@ theorem WithTop.iSup_coe_eq_top {ι : Sort*} {α : Type*} [ConditionallyComplete
exact ⟨i, by simpa only [WithTop.coe_untop _ ha.ne] using WithTop.coe_lt_coe.mpr hi⟩
#align with_top.supr_coe_eq_top WithTop.iSup_coe_eq_top

theorem WithTop.iSup_coe_lt_top {ι : Sort*} {α : Type*} [ConditionallyCompleteLinearOrderBot α]
(f : ι → α) : ⨆ x, (f x : WithTop α) < ⊤ ↔ BddAbove (Set.range f) :=
lt_top_iff_ne_top.trans <| (WithTop.iSup_coe_eq_top f).not.trans not_not
lemma iSup_coe_lt_top : ⨆ x, (f x : WithTop α) < ⊤ ↔ BddAbove (range f) :=
lt_top_iff_ne_top.trans iSup_coe_eq_top.not_left
#align with_top.supr_coe_lt_top WithTop.iSup_coe_lt_top

lemma iInf_coe_eq_top : ⨅ x, (f x : WithTop α) = ⊤ ↔ IsEmpty ι := by simp [isEmpty_iff]

lemma iInf_coe_lt_top : ⨅ i, (f i : WithTop α) < ⊤ ↔ Nonempty ι := by
rw [lt_top_iff_ne_top, Ne.def, iInf_coe_eq_top, not_isEmpty_iff]

end WithTop
end WithTopBot

-- Guard against import creep
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Order/Height.lean
Expand Up @@ -95,7 +95,7 @@ theorem exists_chain_of_le_chainHeight {n : ℕ} (hn : ↑n ≤ s.chainHeight) :
cases' (le_top : s.chainHeight ≤ ⊤).eq_or_lt with ha ha <;>
rw [chainHeight_eq_iSup_subtype] at ha
· obtain ⟨_, ⟨⟨l, h₁, h₂⟩, rfl⟩, h₃⟩ :=
not_bddAbove_iff'.mp ((WithTop.iSup_coe_eq_top _).mp ha) n
not_bddAbove_iff'.mp (WithTop.iSup_coe_eq_top.1 ha) n
exact ⟨l.take n, ⟨h₁.take _, fun x h ↦ h₂ _ <| take_subset _ _ h⟩,
(l.length_take n).trans <| min_eq_left <| le_of_not_ge h₃⟩
· rw [ENat.iSup_coe_lt_top] at ha
Expand Down

0 comments on commit 1cf05bb

Please sign in to comment.