filename
stringlengths
5
42
content
stringlengths
15
319k
Real.lean
/- Copyright (c) 2025 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.MeasureTheory.Measure.Typeclasses.Probability import Mathlib.MeasureTheory.Measure.Typeclasses.SFinite /-! # Measures as real-valued functions Given a measure `μ`, we have defined `μ.real` as the function sending a set `s` to `(μ s).toReal`. In this file, we develop a basic API around this notion. We essentially copy relevant lemmas from the files `MeasureSpaceDef.lean`, `NullMeasurable.lean` and `MeasureSpace.lean`, and adapt them by replacing in their name `measure` with `measureReal`. Many lemmas require an assumption that some set has finite measure. These assumptions are written in the form `(h : μ s ≠ ∞ := by finiteness)`, where `finiteness` is a tactic for goals of the form `≠ ∞`. There are certainly many missing lemmas. The missing ones should be added as they are needed. There are no lemmas on infinite sums, as summability issues are really more painful with reals than nonnegative extended reals. They should probably be added in the long run. -/ open MeasureTheory Measure Set open scoped ENNReal NNReal Function symmDiff namespace MeasureTheory variable {α β ι : Type*} {_ : MeasurableSpace α} {μ : Measure α} {s s₁ s₂ s₃ t t₁ t₂ u : Set α} theorem measureReal_eq_zero_iff (h : μ s ≠ ∞ := by finiteness) : μ.real s = 0 ↔ μ s = 0 := by rw [Measure.real, ENNReal.toReal_eq_zero_iff] exact or_iff_left h theorem measureReal_ne_zero_iff (h : μ s ≠ ∞ := by finiteness) : μ.real s ≠ 0 ↔ μ s ≠ 0 := by simp [measureReal_eq_zero_iff, h] @[simp] theorem measureReal_zero : (0 : Measure α).real = 0 := rfl theorem measureReal_zero_apply (s : Set α) : (0 : Measure α).real s = 0 := rfl @[simp] theorem measureReal_nonneg : 0 ≤ μ.real s := ENNReal.toReal_nonneg @[simp] theorem measureReal_empty : μ.real ∅ = 0 := by simp [Measure.real] @[simp] theorem measureReal_univ_eq_one [IsProbabilityMeasure μ] : μ.real Set.univ = 1 := by simp [Measure.real] @[simp] theorem measureReal_univ_pos [IsFiniteMeasure μ] [NeZero μ] : 0 < μ.real Set.univ := ENNReal.toReal_pos (NeZero.ne (μ Set.univ)) (measure_ne_top μ univ) theorem measureReal_univ_ne_zero [IsFiniteMeasure μ] [NeZero μ] : μ.real Set.univ ≠ 0 := measureReal_univ_pos.ne' @[simp] theorem ofReal_measureReal (h : μ s ≠ ∞ := by finiteness) : ENNReal.ofReal (μ.real s) = μ s := by simp [measureReal_def, h] theorem nonempty_of_measureReal_ne_zero (h : μ.real s ≠ 0) : s.Nonempty := nonempty_iff_ne_empty.2 fun h' ↦ h <| h'.symm ▸ measureReal_empty @[simp] theorem measureReal_ennreal_smul_apply (c : ℝ≥0∞) : (c • μ).real s = c.toReal * μ.real s := by simp [Measure.real] @[simp] theorem measureReal_nnreal_smul_apply (c : ℝ≥0) : (c • μ).real s = c * μ.real s := by simp [measureReal_def] theorem map_measureReal_apply [MeasurableSpace β] {f : α → β} (hf : Measurable f) {s : Set β} (hs : MeasurableSet s) : (μ.map f).real s = μ.real (f ⁻¹' s) := by simp_rw [measureReal_def, map_apply hf hs] @[gcongr] theorem measureReal_mono (h : s₁ ⊆ s₂) (h₂ : μ s₂ ≠ ∞ := by finiteness) : μ.real s₁ ≤ μ.real s₂ := ENNReal.toReal_mono h₂ (measure_mono h) theorem measureReal_eq_measureReal_iff {m : MeasurableSpace β} {ν : Measure β} {t : Set β} (h₁ : μ s ≠ ∞ := by finiteness) (h₂ : ν t ≠ ∞ := by finiteness) : μ.real s = ν.real t ↔ μ s = ν t := by simp [measureReal_def, ENNReal.toReal_eq_toReal_iff' h₁ h₂] theorem measureReal_restrict_apply₀ (ht : NullMeasurableSet t (μ.restrict s)) : (μ.restrict s).real t = μ.real (t ∩ s) := by simp only [measureReal_def, restrict_apply₀ ht] @[simp] theorem measureReal_restrict_apply (ht : MeasurableSet t) : (μ.restrict s).real t = μ.real (t ∩ s) := by simp only [measureReal_def, restrict_apply ht] theorem measureReal_restrict_apply_univ (s : Set α) : (μ.restrict s).real univ = μ.real s := by simp @[simp] theorem measureReal_restrict_apply' (hs : MeasurableSet s) : (μ.restrict s).real t = μ.real (t ∩ s) := by simp only [measureReal_def, restrict_apply' hs] theorem measureReal_restrict_apply₀' (hs : NullMeasurableSet s μ) : μ.restrict s t = μ (t ∩ s) := by simp only [restrict_apply₀' hs] @[simp] theorem measureReal_restrict_apply_self (s : Set α) : (μ.restrict s).real s = μ.real s := by simp [measureReal_def] theorem measureReal_mono_null (h : s₁ ⊆ s₂) (h₂ : μ.real s₂ = 0) (h'₂ : μ s₂ ≠ ∞ := by finiteness) : μ.real s₁ = 0 := by rw [measureReal_eq_zero_iff h'₂] at h₂ simp [Measure.real, measure_mono_null h h₂] theorem measureReal_le_measureReal_union_left (h : μ t ≠ ∞ := by finiteness) : μ.real s ≤ μ.real (s ∪ t) := by rcases eq_top_or_lt_top (μ s) with hs | hs · simp [Measure.real, hs] · exact measureReal_mono subset_union_left (measure_union_lt_top hs h.lt_top).ne theorem measureReal_le_measureReal_union_right (h : μ s ≠ ∞ := by finiteness) : μ.real t ≤ μ.real (s ∪ t) := by rw [union_comm] exact measureReal_le_measureReal_union_left h theorem measureReal_union_le (s₁ s₂ : Set α) : μ.real (s₁ ∪ s₂) ≤ μ.real s₁ + μ.real s₂ := by rcases eq_top_or_lt_top (μ (s₁ ∪ s₂)) with h | h · simp only [Measure.real, h, ENNReal.toReal_top] exact add_nonneg ENNReal.toReal_nonneg ENNReal.toReal_nonneg · have A : μ s₁ ≠ ∞ := measure_ne_top_of_subset subset_union_left h.ne have B : μ s₂ ≠ ∞ := measure_ne_top_of_subset subset_union_right h.ne simp only [Measure.real, ← ENNReal.toReal_add A B] exact ENNReal.toReal_mono (by simp [A, B]) (measure_union_le _ _) theorem measureReal_biUnion_finset_le (s : Finset β) (f : β → Set α) : μ.real (⋃ b ∈ s, f b) ≤ ∑ p ∈ s, μ.real (f p) := by classical induction s using Finset.induction_on with | empty => simp | insert _ _ hx IH => simp only [hx, Finset.mem_insert, iUnion_iUnion_eq_or_left, not_false_eq_true, Finset.sum_insert] exact (measureReal_union_le _ _).trans (by gcongr) theorem measureReal_iUnion_fintype_le [Fintype β] (f : β → Set α) : μ.real (⋃ b, f b) ≤ ∑ p, μ.real (f p) := by convert measureReal_biUnion_finset_le Finset.univ f simp theorem measureReal_iUnion_fintype [Fintype β] {f : β → Set α} (hn : Pairwise (Disjoint on f)) (h : ∀ i, MeasurableSet (f i)) (h' : ∀ i, μ (f i) ≠ ∞ := by finiteness) : μ.real (⋃ b, f b) = ∑ p, μ.real (f p) := by simp_rw [measureReal_def, measure_iUnion hn h, tsum_fintype, ENNReal.toReal_sum (fun i _hi ↦ h' i)] theorem measureReal_union_null (h₁ : μ.real s₁ = 0) (h₂ : μ.real s₂ = 0) : μ.real (s₁ ∪ s₂) = 0 := le_antisymm ((measureReal_union_le s₁ s₂).trans (by simp [h₁, h₂])) measureReal_nonneg @[simp] theorem measureReal_union_null_iff (h₁ : μ s₁ ≠ ∞ := by finiteness) (h₂ : μ s₂ ≠ ∞ := by finiteness) : μ.real (s₁ ∪ s₂) = 0 ↔ μ.real s₁ = 0 ∧ μ.real s₂ = 0 := ⟨fun h ↦ ⟨measureReal_mono_null subset_union_left h (measure_union_ne_top h₁ h₂), measureReal_mono_null subset_union_right h (measure_union_ne_top h₁ h₂)⟩, fun h ↦ measureReal_union_null h.1 h.2⟩ /-- If two sets are equal modulo a set of measure zero, then `μ.real s = μ.real t`. -/ theorem measureReal_congr (H : s =ᵐ[μ] t) : μ.real s = μ.real t := by simp [Measure.real, measure_congr H] theorem measureReal_inter_add_diff₀ (ht : NullMeasurableSet t μ) (h : μ s ≠ ∞ := by finiteness) : μ.real (s ∩ t) + μ.real (s \ t) = μ.real s := by simp only [measureReal_def] rw [← ENNReal.toReal_add, measure_inter_add_diff₀ s ht] · exact measure_ne_top_of_subset inter_subset_left h · exact measure_ne_top_of_subset diff_subset h theorem measureReal_union_add_inter₀ (ht : NullMeasurableSet t μ) (h₁ : μ s ≠ ∞ := by finiteness) (h₂ : μ t ≠ ∞ := by finiteness) : μ.real (s ∪ t) + μ.real (s ∩ t) = μ.real s + μ.real t := by have : μ (s ∪ t) ≠ ∞ := ((measure_union_le _ _).trans_lt (ENNReal.add_lt_top.2 ⟨h₁.lt_top, h₂.lt_top⟩ )).ne rw [← measureReal_inter_add_diff₀ ht this, Set.union_inter_cancel_right, union_diff_right, ← measureReal_inter_add_diff₀ ht h₁] ac_rfl theorem measureReal_union_add_inter₀' (hs : NullMeasurableSet s μ) (h₁ : μ s ≠ ∞ := by finiteness) (h₂ : μ t ≠ ∞ := by finiteness) : μ.real (s ∪ t) + μ.real (s ∩ t) = μ.real s + μ.real t := by rw [union_comm, inter_comm, measureReal_union_add_inter₀ hs h₂ h₁, add_comm] theorem measureReal_union₀ (ht : NullMeasurableSet t μ) (hd : AEDisjoint μ s t) (h₁ : μ s ≠ ∞ := by finiteness) (h₂ : μ t ≠ ∞ := by finiteness) : μ.real (s ∪ t) = μ.real s + μ.real t := by simp only [Measure.real] rw [measure_union₀ ht hd, ENNReal.toReal_add h₁ h₂] theorem measureReal_union₀' (hs : NullMeasurableSet s μ) (hd : AEDisjoint μ s t) (h₁ : μ s ≠ ∞ := by finiteness) (h₂ : μ t ≠ ∞ := by finiteness) : μ.real (s ∪ t) = μ.real s + μ.real t := by rw [union_comm, measureReal_union₀ hs (AEDisjoint.symm hd) h₂ h₁, add_comm] theorem measureReal_add_measureReal_compl₀ [IsFiniteMeasure μ] (hs : NullMeasurableSet s μ) : μ.real s + μ.real sᶜ = μ.real univ := by rw [← measureReal_union₀' hs aedisjoint_compl_right, union_compl_self] theorem measureReal_add_measureReal_compl [IsFiniteMeasure μ] (h : MeasurableSet s) : μ.real s + μ.real sᶜ = μ.real univ := measureReal_add_measureReal_compl₀ h.nullMeasurableSet theorem measureReal_union (hd : Disjoint s₁ s₂) (h : MeasurableSet s₂) (h₁ : μ s₁ ≠ ∞ := by finiteness) (h₂ : μ s₂ ≠ ∞ := by finiteness) : μ.real (s₁ ∪ s₂) = μ.real s₁ + μ.real s₂ := measureReal_union₀ h.nullMeasurableSet hd.aedisjoint h₁ h₂ theorem measureReal_union' (hd : Disjoint s₁ s₂) (h : MeasurableSet s₁) (h₁ : μ s₁ ≠ ∞ := by finiteness) (h₂ : μ s₂ ≠ ∞ := by finiteness) : μ.real (s₁ ∪ s₂) = μ.real s₁ + μ.real s₂ := measureReal_union₀' h.nullMeasurableSet hd.aedisjoint h₁ h₂ theorem measureReal_inter_add_diff (ht : MeasurableSet t) (h : μ s ≠ ∞ := by finiteness) : μ.real (s ∩ t) + μ.real (s \ t) = μ.real s := by simp only [Measure.real] rw [← ENNReal.toReal_add, measure_inter_add_diff _ ht] · exact measure_ne_top_of_subset inter_subset_left h · exact measure_ne_top_of_subset diff_subset h theorem measureReal_diff_add_inter (ht : MeasurableSet t) (h : μ s ≠ ∞ := by finiteness) : μ.real (s \ t) + μ.real (s ∩ t) = μ.real s := (add_comm _ _).trans (measureReal_inter_add_diff ht h) theorem measureReal_union_add_inter (ht : MeasurableSet t) (h₁ : μ s ≠ ∞ := by finiteness) (h₂ : μ t ≠ ∞ := by finiteness) : μ.real (s ∪ t) + μ.real (s ∩ t) = μ.real s + μ.real t := measureReal_union_add_inter₀ ht.nullMeasurableSet h₁ h₂ theorem measureReal_union_add_inter' (hs : MeasurableSet s) (h₁ : μ s ≠ ∞ := by finiteness) (h₂ : μ t ≠ ∞ := by finiteness) : μ.real (s ∪ t) + μ.real (s ∩ t) = μ.real s + μ.real t := measureReal_union_add_inter₀' hs.nullMeasurableSet h₁ h₂ lemma measureReal_symmDiff_eq (hs : MeasurableSet s) (ht : MeasurableSet t) (h₁ : μ s ≠ ∞ := by finiteness) (h₂ : μ t ≠ ∞ := by finiteness) : μ.real (s ∆ t) = μ.real (s \ t) + μ.real (t \ s) := by simp only [Measure.real] rw [← ENNReal.toReal_add, measure_symmDiff_eq hs.nullMeasurableSet ht.nullMeasurableSet] · exact measure_ne_top_of_subset diff_subset h₁ · exact measure_ne_top_of_subset diff_subset h₂ lemma measureReal_symmDiff_le (u : Set α) (h₁ : μ s ≠ ∞ := by finiteness) (h₂ : μ t ≠ ∞ := by finiteness) : μ.real (s ∆ u) ≤ μ.real (s ∆ t) + μ.real (t ∆ u) := by rcases eq_top_or_lt_top (μ u) with hu | hu · simp only [measureReal_def, measure_symmDiff_eq_top h₁ hu, ENNReal.toReal_top] exact add_nonneg ENNReal.toReal_nonneg ENNReal.toReal_nonneg · exact le_trans (measureReal_mono (symmDiff_triangle s t u) (measure_union_ne_top (measure_symmDiff_ne_top h₁ h₂) (measure_symmDiff_ne_top h₂ hu.ne))) (measureReal_union_le (s ∆ t) (t ∆ u)) theorem measureReal_biUnion_finset₀ {s : Finset ι} {f : ι → Set α} (hd : Set.Pairwise (↑s) (AEDisjoint μ on f)) (hm : ∀ b ∈ s, NullMeasurableSet (f b) μ) (h : ∀ b ∈ s, μ (f b) ≠ ∞ := by finiteness) : μ.real (⋃ b ∈ s, f b) = ∑ p ∈ s, μ.real (f p) := by simp only [measureReal_def, measure_biUnion_finset₀ hd hm, ENNReal.toReal_sum h] theorem measureReal_biUnion_finset {s : Finset ι} {f : ι → Set α} (hd : PairwiseDisjoint (↑s) f) (hm : ∀ b ∈ s, MeasurableSet (f b)) (h : ∀ b ∈ s, μ (f b) ≠ ∞ := by finiteness) : μ.real (⋃ b ∈ s, f b) = ∑ p ∈ s, μ.real (f p) := measureReal_biUnion_finset₀ hd.aedisjoint (fun b hb ↦ (hm b hb).nullMeasurableSet) h /-- If `s` is a `Finset`, then the measure of its preimage can be found as the sum of measures of the fibers `f ⁻¹' {y}`. -/ theorem sum_measureReal_preimage_singleton (s : Finset β) {f : α → β} (hf : ∀ y ∈ s, MeasurableSet (f ⁻¹' {y})) (h : ∀ a ∈ s, μ (f ⁻¹' {a}) ≠ ∞ := by finiteness) : (∑ b ∈ s, μ.real (f ⁻¹' {b})) = μ.real (f ⁻¹' s) := by simp only [measureReal_def, ← sum_measure_preimage_singleton s hf, ENNReal.toReal_sum h] /-- If `s` is a `Finset`, then the sums of the real measures of the singletons in the set is the real measure of the set. -/ @[simp] theorem sum_measureReal_singleton [MeasurableSingletonClass α] [SigmaFinite μ] (s : Finset α) : (∑ b ∈ s, μ.real {b}) = μ.real s := by simp [measureReal_def, ← ENNReal.toReal_sum (fun _ _ ↦ ne_of_lt measure_singleton_lt_top)] theorem measureReal_diff_null' (h : μ.real (s₁ ∩ s₂) = 0) (h' : μ s₁ ≠ ∞ := by finiteness) : μ.real (s₁ \ s₂) = μ.real s₁ := by simp only [measureReal_def] rw [measure_diff_null'] exact (measureReal_eq_zero_iff (measure_ne_top_of_subset inter_subset_left h')).1 h theorem measureReal_diff_null (h : μ.real s₂ = 0) (h' : μ s₂ ≠ ∞ := by finiteness) : μ.real (s₁ \ s₂) = μ.real s₁ := by rcases eq_top_or_lt_top (μ s₁) with H | H · simp [measureReal_def, H, measure_diff_eq_top H h'] · exact measureReal_diff_null' (measureReal_mono_null inter_subset_right h h') H.ne theorem measureReal_add_diff (hs : MeasurableSet s) (h₁ : μ s ≠ ∞ := by finiteness) (h₂ : μ t ≠ ∞ := by finiteness) : μ.real s + μ.real (t \ s) = μ.real (s ∪ t) := by rw [← measureReal_union' (@disjoint_sdiff_right _ s t) hs h₁ (measure_ne_top_of_subset diff_subset h₂), union_diff_self] theorem measureReal_diff' (hm : MeasurableSet t) (h₁ : μ s ≠ ∞ := by finiteness) (h₂ : μ t ≠ ∞ := by finiteness) : μ.real (s \ t) = μ.real (s ∪ t) - μ.real t := by rw [union_comm, ← measureReal_add_diff hm h₂ h₁] ring theorem measureReal_diff (h : s₂ ⊆ s₁) (h₂ : MeasurableSet s₂) (h₁ : μ s₁ ≠ ∞ := by finiteness) : μ.real (s₁ \ s₂) = μ.real s₁ - μ.real s₂ := by rw [measureReal_diff' h₂ h₁ (measure_ne_top_of_subset h h₁), union_eq_self_of_subset_right h] theorem le_measureReal_diff (h : μ s₂ ≠ ∞ := by finiteness) : μ.real s₁ - μ.real s₂ ≤ μ.real (s₁ \ s₂) := by simp only [tsub_le_iff_left] calc μ.real s₁ ≤ μ.real (s₂ ∪ s₁) := measureReal_le_measureReal_union_right h _ = μ.real (s₂ ∪ s₁ \ s₂) := congr_arg μ.real union_diff_self.symm _ ≤ μ.real s₂ + μ.real (s₁ \ s₂) := measureReal_union_le _ _ theorem measureReal_diff_lt_of_lt_add (hs : MeasurableSet s) (hst : s ⊆ t) (ε : ℝ) (h : μ.real t < μ.real s + ε) (ht' : μ t ≠ ∞ := by finiteness) : μ.real (t \ s) < ε := by rw [measureReal_diff hst hs ht']; linarith theorem measureReal_diff_le_iff_le_add (hs : MeasurableSet s) (hst : s ⊆ t) (ε : ℝ) (ht' : μ t ≠ ∞ := by finiteness) : μ.real (t \ s) ≤ ε ↔ μ.real t ≤ μ.real s + ε := by rw [measureReal_diff hst hs ht', tsub_le_iff_left] theorem measureReal_eq_measureReal_of_null_diff (hst : s ⊆ t) (h_nulldiff : μ.real (t \ s) = 0) (h : μ (t \ s) ≠ ∞ := by finiteness) : μ.real s = μ.real t := by rw [measureReal_eq_zero_iff h] at h_nulldiff simp [measureReal_def, measure_eq_measure_of_null_diff hst h_nulldiff] theorem measureReal_eq_measureReal_of_between_null_diff (h12 : s₁ ⊆ s₂) (h23 : s₂ ⊆ s₃) (h_nulldiff : μ.real (s₃ \ s₁) = 0) (h' : μ (s₃ \ s₁) ≠ ∞ := by finiteness) : μ.real s₁ = μ.real s₂ ∧ μ.real s₂ = μ.real s₃ := by have A : μ s₁ = μ s₂ ∧ μ s₂ = μ s₃ := measure_eq_measure_of_between_null_diff h12 h23 ((measureReal_eq_zero_iff h').1 h_nulldiff) simp [measureReal_def, A.1, A.2] theorem measureReal_eq_measureReal_smaller_of_between_null_diff (h12 : s₁ ⊆ s₂) (h23 : s₂ ⊆ s₃) (h_nulldiff : μ.real (s₃ \ s₁) = 0) (h' : μ (s₃ \ s₁) ≠ ∞ := by finiteness) : μ.real s₁ = μ.real s₂ := (measureReal_eq_measureReal_of_between_null_diff h12 h23 h_nulldiff h').1 theorem measureReal_eq_measureReal_larger_of_between_null_diff (h12 : s₁ ⊆ s₂) (h23 : s₂ ⊆ s₃) (h_nulldiff : μ.real (s₃ \ s₁) = 0) (h' : μ (s₃ \ s₁) ≠ ∞ := by finiteness) : μ.real s₂ = μ.real s₃ := (measureReal_eq_measureReal_of_between_null_diff h12 h23 h_nulldiff h').2 theorem measureReal_compl [IsFiniteMeasure μ] (h₁ : MeasurableSet s) : μ.real sᶜ = μ.real univ - μ.real s := by rw [compl_eq_univ_diff] exact measureReal_diff (subset_univ s) h₁ theorem measureReal_union_congr_of_subset (hs : s₁ ⊆ s₂) (hsμ : μ.real s₂ ≤ μ.real s₁) (ht : t₁ ⊆ t₂) (htμ : μ.real t₂ ≤ μ.real t₁) (h₁ : μ s₂ ≠ ∞ := by finiteness) (h₂ : μ t₂ ≠ ∞ := by finiteness) : μ.real (s₁ ∪ t₁) = μ.real (s₂ ∪ t₂) := by simp only [measureReal_def] rw [measure_union_congr_of_subset hs _ ht] · exact (ENNReal.toReal_le_toReal h₂ (measure_ne_top_of_subset ht h₂)).1 htμ · exact (ENNReal.toReal_le_toReal h₁ (measure_ne_top_of_subset hs h₁)).1 hsμ theorem sum_measureReal_le_measureReal_univ [IsFiniteMeasure μ] {s : Finset ι} {t : ι → Set α} (h : ∀ i ∈ s, MeasurableSet (t i)) (H : Set.PairwiseDisjoint (↑s) t) : (∑ i ∈ s, μ.real (t i)) ≤ μ.real univ := by simp only [measureReal_def] rw [← ENNReal.toReal_sum (fun i hi ↦ measure_ne_top _ _)] apply ENNReal.toReal_mono (measure_ne_top _ _) exact sum_measure_le_measure_univ (fun i mi ↦ (h i mi).nullMeasurableSet) H.aedisjoint theorem measureReal_add_apply {μ₁ μ₂ : Measure α} (h₁ : μ₁ s ≠ ∞ := by finiteness) (h₂ : μ₂ s ≠ ∞ := by finiteness) : (μ₁ + μ₂).real s = μ₁.real s + μ₂.real s := by simp only [measureReal_def, add_apply, ENNReal.toReal_add h₁ h₂] /-- Pigeonhole principle for measure spaces: if `s` is a `Finset` and `∑ i ∈ s, μ.real (t i) > μ.real univ`, then one of the intersections `t i ∩ t j` is not empty. -/ theorem exists_nonempty_inter_of_measureReal_univ_lt_sum_measureReal [IsFiniteMeasure μ] {s : Finset ι} {t : ι → Set α} (h : ∀ i ∈ s, MeasurableSet (t i)) (H : μ.real univ < ∑ i ∈ s, μ.real (t i)) : ∃ i ∈ s, ∃ j ∈ s, ∃ _h : i ≠ j, (t i ∩ t j).Nonempty := by apply exists_nonempty_inter_of_measure_univ_lt_sum_measure μ (fun i mi ↦ (h i mi).nullMeasurableSet) simp only [Measure.real] at H apply (ENNReal.toReal_lt_toReal (measure_ne_top _ _) _).1 · convert H rw [ENNReal.toReal_sum (fun i hi ↦ measure_ne_top _ _)] · exact (ENNReal.sum_lt_top.mpr (fun i hi ↦ measure_lt_top ..)).ne /-- If two sets `s` and `t` are included in a set `u` of finite measure, and `μ.real s + μ.real t > μ.real u`, then `s` intersects `t`. Version assuming that `t` is measurable. -/ theorem nonempty_inter_of_measureReal_lt_add (ht : MeasurableSet t) (h's : s ⊆ u) (h't : t ⊆ u) (h : μ.real u < μ.real s + μ.real t) (hu : μ u ≠ ∞ := by finiteness) : (s ∩ t).Nonempty := by apply nonempty_inter_of_measure_lt_add μ ht h's h't ?_ apply (ENNReal.toReal_lt_toReal hu _).1 · rw [ENNReal.toReal_add (measure_ne_top_of_subset h's hu) (measure_ne_top_of_subset h't hu)] exact h · exact ENNReal.add_ne_top.2 ⟨measure_ne_top_of_subset h's hu, measure_ne_top_of_subset h't hu⟩ /-- If two sets `s` and `t` are included in a set `u` of finite measure, and `μ.real s + μ.real t > μ.real u`, then `s` intersects `t`. Version assuming that `s` is measurable. -/ theorem nonempty_inter_of_measureReal_lt_add' (hs : MeasurableSet s) (h's : s ⊆ u) (h't : t ⊆ u) (h : μ.real u < μ.real s + μ.real t) (hu : μ u ≠ ∞ := by finiteness) : (s ∩ t).Nonempty := by rw [add_comm] at h rw [inter_comm] exact nonempty_inter_of_measureReal_lt_add hs h't h's h hu end MeasureTheory namespace Mathlib.Meta.Positivity open Lean Meta Qq Function /-- Extension for the `positivity` tactic: applications of `μ.real` are nonnegative. -/ @[positivity MeasureTheory.Measure.real _ _] def evalMeasureReal : PositivityExt where eval {_ _} _zα _pα e := do let .app (.app _ a) b ← whnfR e | throwError "not measureReal" let p ← mkAppOptM ``MeasureTheory.measureReal_nonneg #[none, none, a, b] pure (.nonnegative p) end Mathlib.Meta.Positivity
IdealOperations.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Ideal /-! # Ideal operations for Lie algebras Given a Lie module `M` over a Lie algebra `L`, there is a natural action of the Lie ideals of `L` on the Lie submodules of `M`. In the special case that `M = L` with the adjoint action, this provides a pairing of Lie ideals which is especially important. For example, it can be used to define solvability / nilpotency of a Lie algebra via the derived / lower-central series. ## Main definitions * `LieSubmodule.hasBracket` * `LieSubmodule.lieIdeal_oper_eq_linear_span` * `LieIdeal.map_bracket_le` * `LieIdeal.comap_bracket_le` ## Notation Given a Lie module `M` over a Lie algebra `L`, together with a Lie submodule `N ⊆ M` and a Lie ideal `I ⊆ L`, we introduce the notation `⁅I, N⁆` for the Lie submodule of `M` corresponding to the action defined in this file. ## Tags lie algebra, ideal operation -/ universe u v w w₁ w₂ namespace LieSubmodule variable {R : Type u} {L : Type v} {M : Type w} {M₂ : Type w₁} variable [CommRing R] [LieRing L] variable [AddCommGroup M] [Module R M] [LieRingModule L M] variable [AddCommGroup M₂] [Module R M₂] [LieRingModule L M₂] variable (N N' : LieSubmodule R L M) (N₂ : LieSubmodule R L M₂) variable (f : M →ₗ⁅R,L⁆ M₂) section LieIdealOperations theorem map_comap_le : map f (comap f N₂) ≤ N₂ := (N₂ : Set M₂).image_preimage_subset f theorem map_comap_eq (hf : N₂ ≤ f.range) : map f (comap f N₂) = N₂ := by rw [SetLike.ext'_iff] exact Set.image_preimage_eq_of_subset hf theorem le_comap_map : N ≤ comap f (map f N) := (N : Set M).subset_preimage_image f theorem comap_map_eq (hf : f.ker = ⊥) : comap f (map f N) = N := by rw [SetLike.ext'_iff] exact (N : Set M).preimage_image_eq (f.ker_eq_bot.mp hf) @[simp] theorem map_comap_incl : map N.incl (comap N.incl N') = N ⊓ N' := by rw [← toSubmodule_inj] exact (N : Submodule R M).map_comap_subtype N' variable [LieAlgebra R L] [LieModule R L M₂] (I J : LieIdeal R L) /-- Given a Lie module `M` over a Lie algebra `L`, the set of Lie ideals of `L` acts on the set of submodules of `M`. -/ instance hasBracket : Bracket (LieIdeal R L) (LieSubmodule R L M) := ⟨fun I N => lieSpan R L { ⁅(x : L), (n : M)⁆ | (x : I) (n : N) }⟩ theorem lieIdeal_oper_eq_span : ⁅I, N⁆ = lieSpan R L { ⁅(x : L), (n : M)⁆ | (x : I) (n : N) } := rfl /-- See also `LieSubmodule.lieIdeal_oper_eq_linear_span'` and `LieSubmodule.lieIdeal_oper_eq_tensor_map_range`. -/ theorem lieIdeal_oper_eq_linear_span [LieModule R L M] : (↑⁅I, N⁆ : Submodule R M) = Submodule.span R { ⁅(x : L), (n : M)⁆ | (x : I) (n : N) } := by apply le_antisymm · let s := { ⁅(x : L), (n : M)⁆ | (x : I) (n : N) } have aux : ∀ (y : L), ∀ m' ∈ Submodule.span R s, ⁅y, m'⁆ ∈ Submodule.span R s := by intro y m' hm' refine Submodule.span_induction (R := R) (M := M) (s := s) (p := fun m' _ ↦ ⁅y, m'⁆ ∈ Submodule.span R s) ?_ ?_ ?_ ?_ hm' · rintro m'' ⟨x, n, hm''⟩; rw [← hm'', leibniz_lie] refine Submodule.add_mem _ ?_ ?_ <;> apply Submodule.subset_span · use ⟨⁅y, ↑x⁆, I.lie_mem x.property⟩, n · use x, ⟨⁅y, ↑n⁆, N.lie_mem n.property⟩ · simp only [lie_zero, Submodule.zero_mem] · intro m₁ m₂ _ _ hm₁ hm₂; rw [lie_add]; exact Submodule.add_mem _ hm₁ hm₂ · intro t m'' _ hm''; rw [lie_smul]; exact Submodule.smul_mem _ t hm'' change _ ≤ ({ Submodule.span R s with lie_mem := fun hm' => aux _ _ hm' } : LieSubmodule R L M) rw [lieIdeal_oper_eq_span, lieSpan_le] exact Submodule.subset_span · rw [lieIdeal_oper_eq_span]; apply submodule_span_le_lieSpan theorem lieIdeal_oper_eq_linear_span' [LieModule R L M] : (↑⁅I, N⁆ : Submodule R M) = Submodule.span R { ⁅x, n⁆ | (x ∈ I) (n ∈ N) } := by rw [lieIdeal_oper_eq_linear_span] congr ext m constructor · rintro ⟨⟨x, hx⟩, ⟨n, hn⟩, rfl⟩ exact ⟨x, hx, n, hn, rfl⟩ · rintro ⟨x, hx, n, hn, rfl⟩ exact ⟨⟨x, hx⟩, ⟨n, hn⟩, rfl⟩ theorem lie_le_iff : ⁅I, N⁆ ≤ N' ↔ ∀ x ∈ I, ∀ m ∈ N, ⁅x, m⁆ ∈ N' := by rw [lieIdeal_oper_eq_span, LieSubmodule.lieSpan_le] refine ⟨fun h x hx m hm => h ⟨⟨x, hx⟩, ⟨m, hm⟩, rfl⟩, ?_⟩ rintro h _ ⟨⟨x, hx⟩, ⟨m, hm⟩, rfl⟩ exact h x hx m hm variable {N I} in theorem lie_coe_mem_lie (x : I) (m : N) : ⁅(x : L), (m : M)⁆ ∈ ⁅I, N⁆ := by rw [lieIdeal_oper_eq_span]; apply subset_lieSpan; use x, m variable {N I} in theorem lie_mem_lie {x : L} {m : M} (hx : x ∈ I) (hm : m ∈ N) : ⁅x, m⁆ ∈ ⁅I, N⁆ := lie_coe_mem_lie ⟨x, hx⟩ ⟨m, hm⟩ theorem lie_comm : ⁅I, J⁆ = ⁅J, I⁆ := by suffices ∀ I J : LieIdeal R L, ⁅I, J⁆ ≤ ⁅J, I⁆ by exact le_antisymm (this I J) (this J I) clear! I J; intro I J rw [lieIdeal_oper_eq_span, lieSpan_le]; rintro x ⟨y, z, h⟩; rw [← h] rw [← lie_skew, ← lie_neg, ← LieSubmodule.coe_neg] apply lie_coe_mem_lie theorem lie_le_right : ⁅I, N⁆ ≤ N := by rw [lieIdeal_oper_eq_span, lieSpan_le]; rintro m ⟨x, n, hn⟩; rw [← hn] exact N.lie_mem n.property theorem lie_le_left : ⁅I, J⁆ ≤ I := by rw [lie_comm]; exact lie_le_right I J theorem lie_le_inf : ⁅I, J⁆ ≤ I ⊓ J := by rw [le_inf_iff]; exact ⟨lie_le_left I J, lie_le_right J I⟩ @[simp] theorem lie_bot : ⁅I, (⊥ : LieSubmodule R L M)⁆ = ⊥ := by rw [eq_bot_iff]; apply lie_le_right @[simp] theorem bot_lie : ⁅(⊥ : LieIdeal R L), N⁆ = ⊥ := by suffices ⁅(⊥ : LieIdeal R L), N⁆ ≤ ⊥ by exact le_bot_iff.mp this rw [lieIdeal_oper_eq_span, lieSpan_le]; rintro m ⟨⟨x, hx⟩, n, hn⟩; rw [← hn] change x ∈ (⊥ : LieIdeal R L) at hx; rw [mem_bot] at hx; simp [hx] theorem lie_eq_bot_iff : ⁅I, N⁆ = ⊥ ↔ ∀ x ∈ I, ∀ m ∈ N, ⁅(x : L), m⁆ = 0 := by rw [lieIdeal_oper_eq_span, LieSubmodule.lieSpan_eq_bot_iff] refine ⟨fun h x hx m hm => h ⁅x, m⁆ ⟨⟨x, hx⟩, ⟨m, hm⟩, rfl⟩, ?_⟩ rintro h - ⟨⟨x, hx⟩, ⟨⟨n, hn⟩, rfl⟩⟩ exact h x hx n hn variable {I J N N'} in theorem mono_lie (h₁ : I ≤ J) (h₂ : N ≤ N') : ⁅I, N⁆ ≤ ⁅J, N'⁆ := by intro m h rw [lieIdeal_oper_eq_span, mem_lieSpan] at h; rw [lieIdeal_oper_eq_span, mem_lieSpan] intro N hN; apply h; rintro m' ⟨⟨x, hx⟩, ⟨n, hn⟩, hm⟩; rw [← hm]; apply hN use ⟨x, h₁ hx⟩, ⟨n, h₂ hn⟩ variable {I J} in theorem mono_lie_left (h : I ≤ J) : ⁅I, N⁆ ≤ ⁅J, N⁆ := mono_lie h (le_refl N) variable {N N'} in theorem mono_lie_right (h : N ≤ N') : ⁅I, N⁆ ≤ ⁅I, N'⁆ := mono_lie (le_refl I) h @[simp] theorem lie_sup : ⁅I, N ⊔ N'⁆ = ⁅I, N⁆ ⊔ ⁅I, N'⁆ := by have h : ⁅I, N⁆ ⊔ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ := by rw [sup_le_iff]; constructor <;> apply mono_lie_right <;> [exact le_sup_left; exact le_sup_right] suffices ⁅I, N ⊔ N'⁆ ≤ ⁅I, N⁆ ⊔ ⁅I, N'⁆ by exact le_antisymm this h rw [lieIdeal_oper_eq_span, lieSpan_le] rintro m ⟨x, ⟨n, hn⟩, h⟩ simp only [SetLike.mem_coe] rw [LieSubmodule.mem_sup] at hn ⊢ rcases hn with ⟨n₁, hn₁, n₂, hn₂, hn'⟩ use ⁅(x : L), (⟨n₁, hn₁⟩ : N)⁆; constructor; · apply lie_coe_mem_lie use ⁅(x : L), (⟨n₂, hn₂⟩ : N')⁆; constructor; · apply lie_coe_mem_lie simp [← h, ← hn'] @[simp] theorem sup_lie : ⁅I ⊔ J, N⁆ = ⁅I, N⁆ ⊔ ⁅J, N⁆ := by have h : ⁅I, N⁆ ⊔ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ := by rw [sup_le_iff]; constructor <;> apply mono_lie_left <;> [exact le_sup_left; exact le_sup_right] suffices ⁅I ⊔ J, N⁆ ≤ ⁅I, N⁆ ⊔ ⁅J, N⁆ by exact le_antisymm this h rw [lieIdeal_oper_eq_span, lieSpan_le] rintro m ⟨⟨x, hx⟩, n, h⟩ simp only [SetLike.mem_coe] rw [LieSubmodule.mem_sup] at hx ⊢ rcases hx with ⟨x₁, hx₁, x₂, hx₂, hx'⟩ use ⁅((⟨x₁, hx₁⟩ : I) : L), (n : N)⁆; constructor; · apply lie_coe_mem_lie use ⁅((⟨x₂, hx₂⟩ : J) : L), (n : N)⁆; constructor; · apply lie_coe_mem_lie simp [← h, ← hx'] theorem lie_inf : ⁅I, N ⊓ N'⁆ ≤ ⁅I, N⁆ ⊓ ⁅I, N'⁆ := by rw [le_inf_iff]; constructor <;> apply mono_lie_right <;> [exact inf_le_left; exact inf_le_right] theorem inf_lie : ⁅I ⊓ J, N⁆ ≤ ⁅I, N⁆ ⊓ ⁅J, N⁆ := by rw [le_inf_iff]; constructor <;> apply mono_lie_left <;> [exact inf_le_left; exact inf_le_right] theorem map_bracket_eq [LieModule R L M] : map f ⁅I, N⁆ = ⁅I, map f N⁆ := by rw [← toSubmodule_inj, toSubmodule_map, lieIdeal_oper_eq_linear_span, lieIdeal_oper_eq_linear_span, Submodule.map_span] congr ext m simp theorem comap_bracket_eq [LieModule R L M] (hf₁ : f.ker = ⊥) (hf₂ : N₂ ≤ f.range) : comap f ⁅I, N₂⁆ = ⁅I, comap f N₂⁆ := by conv_lhs => rw [← map_comap_eq N₂ f hf₂] rw [← map_bracket_eq, comap_map_eq _ f hf₁] end LieIdealOperations end LieSubmodule namespace LieIdeal open LieAlgebra variable {R : Type u} {L : Type v} {L' : Type w₂} variable [CommRing R] [LieRing L] [LieAlgebra R L] [LieRing L'] [LieAlgebra R L'] variable (f : L →ₗ⁅R⁆ L') (I : LieIdeal R L) (J : LieIdeal R L') /-- Note that the inequality can be strict; e.g., the inclusion of an Abelian subalgebra of a simple algebra. -/ theorem map_bracket_le {I₁ I₂ : LieIdeal R L} : map f ⁅I₁, I₂⁆ ≤ ⁅map f I₁, map f I₂⁆ := by rw [map_le_iff_le_comap, LieSubmodule.lieIdeal_oper_eq_span, LieSubmodule.lieSpan_le] intro x hx obtain ⟨⟨y₁, hy₁⟩, ⟨y₂, hy₂⟩, hx⟩ := hx rw [← hx] let fy₁ : ↥(map f I₁) := ⟨f y₁, mem_map hy₁⟩ let fy₂ : ↥(map f I₂) := ⟨f y₂, mem_map hy₂⟩ change _ ∈ comap f ⁅map f I₁, map f I₂⁆ simp only [mem_comap, LieHom.map_lie] exact LieSubmodule.lie_coe_mem_lie fy₁ fy₂ theorem map_bracket_eq {I₁ I₂ : LieIdeal R L} (h : Function.Surjective f) : map f ⁅I₁, I₂⁆ = ⁅map f I₁, map f I₂⁆ := by suffices ⁅map f I₁, map f I₂⁆ ≤ map f ⁅I₁, I₂⁆ by exact le_antisymm (map_bracket_le f) this rw [← LieSubmodule.toSubmodule_le_toSubmodule, coe_map_of_surjective h, LieSubmodule.lieIdeal_oper_eq_linear_span, LieSubmodule.lieIdeal_oper_eq_linear_span, LinearMap.map_span] apply Submodule.span_mono rintro x ⟨⟨z₁, h₁⟩, ⟨z₂, h₂⟩, rfl⟩ obtain ⟨y₁, rfl⟩ := mem_map_of_surjective h h₁ obtain ⟨y₂, rfl⟩ := mem_map_of_surjective h h₂ exact ⟨⁅(y₁ : L), (y₂ : L)⁆, ⟨y₁, y₂, rfl⟩, by apply f.map_lie⟩ theorem comap_bracket_le {J₁ J₂ : LieIdeal R L'} : ⁅comap f J₁, comap f J₂⁆ ≤ comap f ⁅J₁, J₂⁆ := by rw [← map_le_iff_le_comap] exact le_trans (map_bracket_le f) (LieSubmodule.mono_lie map_comap_le map_comap_le) variable {f} theorem map_comap_incl {I₁ I₂ : LieIdeal R L} : map I₁.incl (comap I₁.incl I₂) = I₁ ⊓ I₂ := by conv_rhs => rw [← I₁.incl_idealRange] rw [← map_comap_eq] exact I₁.incl_isIdealMorphism theorem comap_bracket_eq {J₁ J₂ : LieIdeal R L'} (h : f.IsIdealMorphism) : comap f ⁅f.idealRange ⊓ J₁, f.idealRange ⊓ J₂⁆ = ⁅comap f J₁, comap f J₂⁆ ⊔ f.ker := by rw [← LieSubmodule.toSubmodule_inj, comap_toSubmodule, LieSubmodule.sup_toSubmodule, f.ker_toSubmodule, ← Submodule.comap_map_eq, LieSubmodule.lieIdeal_oper_eq_linear_span, LieSubmodule.lieIdeal_oper_eq_linear_span, LinearMap.map_span] congr ext simp_all only [Subtype.exists, LieSubmodule.mem_inf, LieHom.mem_idealRange_iff, exists_prop, Set.mem_setOf_eq, LieHom.coe_toLinearMap, mem_comap, exists_exists_and_exists_and_eq_and, LieHom.map_lie] grind theorem map_comap_bracket_eq {J₁ J₂ : LieIdeal R L'} (h : f.IsIdealMorphism) : map f ⁅comap f J₁, comap f J₂⁆ = ⁅f.idealRange ⊓ J₁, f.idealRange ⊓ J₂⁆ := by rw [← map_sup_ker_eq_map, ← comap_bracket_eq h, map_comap_eq h, inf_eq_right] exact le_trans (LieSubmodule.lie_le_left _ _) inf_le_left theorem comap_bracket_incl {I₁ I₂ : LieIdeal R L} : ⁅comap I.incl I₁, comap I.incl I₂⁆ = comap I.incl ⁅I ⊓ I₁, I ⊓ I₂⁆ := by conv_rhs => congr next => skip rw [← I.incl_idealRange] rw [comap_bracket_eq] · simp only [ker_incl, sup_bot_eq] · exact I.incl_isIdealMorphism /-- This is a very useful result; it allows us to use the fact that inclusion distributes over the Lie bracket operation on ideals, subject to the conditions shown. -/ theorem comap_bracket_incl_of_le {I₁ I₂ : LieIdeal R L} (h₁ : I₁ ≤ I) (h₂ : I₂ ≤ I) : ⁅comap I.incl I₁, comap I.incl I₂⁆ = comap I.incl ⁅I₁, I₂⁆ := by rw [comap_bracket_incl]; rw [← inf_eq_right] at h₁ h₂; rw [h₁, h₂] end LieIdeal
UnitBall.lean
/- Copyright (c) 2022 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov, Heather Macbeth -/ import Mathlib.Analysis.Normed.Field.Lemmas import Mathlib.Analysis.Normed.Group.BallSphere /-! # Algebraic structures on unit balls and spheres In this file we define algebraic structures (`Semigroup`, `CommSemigroup`, `Monoid`, `CommMonoid`, `Group`, `CommGroup`) on `Metric.ball (0 : 𝕜) 1`, `Metric.closedBall (0 : 𝕜) 1`, and `Metric.sphere (0 : 𝕜) 1`. In each case we use the weakest possible typeclass assumption on `𝕜`, from `NonUnitalSeminormedRing` to `NormedField`. -/ open Set Metric variable {𝕜 : Type*} /-! ### Algebraic structures on `Metric.ball 0 1` -/ /-- Unit ball in a non-unital seminormed ring as a bundled `Subsemigroup`. -/ def Subsemigroup.unitBall (𝕜 : Type*) [NonUnitalSeminormedRing 𝕜] : Subsemigroup 𝕜 where carrier := ball (0 : 𝕜) 1 mul_mem' hx hy := by rw [mem_ball_zero_iff] at * exact (norm_mul_le _ _).trans_lt (mul_lt_one_of_nonneg_of_lt_one_left (norm_nonneg _) hx hy.le) instance Metric.unitBall.instSemigroup [NonUnitalSeminormedRing 𝕜] : Semigroup (ball (0 : 𝕜) 1) := MulMemClass.toSemigroup (Subsemigroup.unitBall 𝕜) instance Metric.unitBall.instContinuousMul [NonUnitalSeminormedRing 𝕜] : ContinuousMul (ball (0 : 𝕜) 1) := (Subsemigroup.unitBall 𝕜).continuousMul instance Metric.unitBall.instCommSemigroup [SeminormedCommRing 𝕜] : CommSemigroup (ball (0 : 𝕜) 1) := MulMemClass.toCommSemigroup (Subsemigroup.unitBall 𝕜) instance Metric.unitBall.instHasDistribNeg [NonUnitalSeminormedRing 𝕜] : HasDistribNeg (ball (0 : 𝕜) 1) := Subtype.coe_injective.hasDistribNeg ((↑) : ball (0 : 𝕜) 1 → 𝕜) (fun _ => rfl) fun _ _ => rfl @[simp, norm_cast] protected theorem Metric.unitBall.coe_mul [NonUnitalSeminormedRing 𝕜] (x y : ball (0 : 𝕜) 1) : ↑(x * y) = (x * y : 𝕜) := rfl @[deprecated (since := "2025-04-18")] alias coe_mul_unitBall := Metric.unitBall.coe_mul instance Metric.unitBall.instZero [Zero 𝕜] [PseudoMetricSpace 𝕜] : Zero (ball (0 : 𝕜) 1) := ⟨⟨0, by simp⟩⟩ @[simp, norm_cast] protected theorem Metric.unitBall.coe_zero [Zero 𝕜] [PseudoMetricSpace 𝕜] : ((0 : ball (0 : 𝕜) 1) : 𝕜) = 0 := rfl @[simp, norm_cast] protected theorem Metric.unitBall.coe_eq_zero [Zero 𝕜] [PseudoMetricSpace 𝕜] {a : ball (0 : 𝕜) 1} : (a : 𝕜) = 0 ↔ a = 0 := Subtype.val_injective.eq_iff' unitBall.coe_zero instance Metric.unitBall.instSemigroupWithZero [NonUnitalSeminormedRing 𝕜] : SemigroupWithZero (ball (0 : 𝕜) 1) where zero_mul _ := Subtype.eq <| zero_mul _ mul_zero _ := Subtype.eq <| mul_zero _ instance Metric.unitBall.instIsLeftCancelMulZero [NonUnitalSeminormedRing 𝕜] [IsLeftCancelMulZero 𝕜] : IsLeftCancelMulZero (ball (0 : 𝕜) 1) := Subtype.val_injective.isLeftCancelMulZero _ rfl fun _ _ ↦ rfl instance Metric.unitBall.instIsRightCancelMulZero [NonUnitalSeminormedRing 𝕜] [IsRightCancelMulZero 𝕜] : IsRightCancelMulZero (ball (0 : 𝕜) 1) := Subtype.val_injective.isRightCancelMulZero _ rfl fun _ _ ↦ rfl instance Metric.unitBall.instIsCancelMulZero [NonUnitalSeminormedRing 𝕜] [IsCancelMulZero 𝕜] : IsCancelMulZero (ball (0 : 𝕜) 1) where /-! ### Algebraic instances for `Metric.closedBall 0 1` -/ /-- Closed unit ball in a non-unital seminormed ring as a bundled `Subsemigroup`. -/ def Subsemigroup.unitClosedBall (𝕜 : Type*) [NonUnitalSeminormedRing 𝕜] : Subsemigroup 𝕜 where carrier := closedBall 0 1 mul_mem' hx hy := by rw [mem_closedBall_zero_iff] at * exact (norm_mul_le _ _).trans (mul_le_one₀ hx (norm_nonneg _) hy) instance Metric.unitClosedBall.instSemigroup [NonUnitalSeminormedRing 𝕜] : Semigroup (closedBall (0 : 𝕜) 1) := MulMemClass.toSemigroup (Subsemigroup.unitClosedBall 𝕜) instance Metric.unitClosedBall.instHasDistribNeg [NonUnitalSeminormedRing 𝕜] : HasDistribNeg (closedBall (0 : 𝕜) 1) := Subtype.coe_injective.hasDistribNeg ((↑) : closedBall (0 : 𝕜) 1 → 𝕜) (fun _ => rfl) fun _ _ => rfl instance Metric.unitClosedBall.instContinuousMul [NonUnitalSeminormedRing 𝕜] : ContinuousMul (closedBall (0 : 𝕜) 1) := (Subsemigroup.unitClosedBall 𝕜).continuousMul @[simp, norm_cast] protected theorem Metric.unitClosedBall.coe_mul [NonUnitalSeminormedRing 𝕜] (x y : closedBall (0 : 𝕜) 1) : ↑(x * y) = (x * y : 𝕜) := rfl @[deprecated (since := "2025-04-18")] alias coe_mul_unitClosedBall := Metric.unitClosedBall.coe_mul instance Metric.unitClosedBall.instZero [Zero 𝕜] [PseudoMetricSpace 𝕜] : Zero (closedBall (0 : 𝕜) 1) where zero := ⟨0, by simp⟩ @[simp, norm_cast] protected lemma Metric.unitClosedBall.coe_zero [Zero 𝕜] [PseudoMetricSpace 𝕜] : ((0 : closedBall (0 : 𝕜) 1) : 𝕜) = 0 := rfl @[simp, norm_cast] protected lemma Metric.unitClosedBall.coe_eq_zero [Zero 𝕜] [PseudoMetricSpace 𝕜] {a : closedBall (0 : 𝕜) 1} : (a : 𝕜) = 0 ↔ a = 0 := Subtype.val_injective.eq_iff' unitClosedBall.coe_zero instance Metric.unitClosedBall.instSemigroupWithZero [NonUnitalSeminormedRing 𝕜] : SemigroupWithZero (closedBall (0 : 𝕜) 1) where zero_mul _ := Subtype.eq <| zero_mul _ mul_zero _ := Subtype.eq <| mul_zero _ /-- Closed unit ball in a seminormed ring as a bundled `Submonoid`. -/ def Submonoid.unitClosedBall (𝕜 : Type*) [SeminormedRing 𝕜] [NormOneClass 𝕜] : Submonoid 𝕜 := { Subsemigroup.unitClosedBall 𝕜 with carrier := closedBall 0 1 one_mem' := mem_closedBall_zero_iff.2 norm_one.le } instance Metric.unitClosedBall.instMonoid [SeminormedRing 𝕜] [NormOneClass 𝕜] : Monoid (closedBall (0 : 𝕜) 1) := SubmonoidClass.toMonoid (Submonoid.unitClosedBall 𝕜) instance Metric.unitClosedBall.instCommMonoid [SeminormedCommRing 𝕜] [NormOneClass 𝕜] : CommMonoid (closedBall (0 : 𝕜) 1) := SubmonoidClass.toCommMonoid (Submonoid.unitClosedBall 𝕜) @[simp, norm_cast] protected theorem Metric.unitClosedBall.coe_one [SeminormedRing 𝕜] [NormOneClass 𝕜] : ((1 : closedBall (0 : 𝕜) 1) : 𝕜) = 1 := rfl @[deprecated (since := "2025-04-18")] alias coe_one_unitClosedBall := Metric.unitClosedBall.coe_one @[simp, norm_cast] protected theorem Metric.unitClosedBall.coe_eq_one [SeminormedRing 𝕜] [NormOneClass 𝕜] {a : closedBall (0 : 𝕜) 1} : (a : 𝕜) = 1 ↔ a = 1 := Subtype.val_injective.eq_iff' unitClosedBall.coe_one @[simp, norm_cast] protected theorem Metric.unitClosedBall.coe_pow [SeminormedRing 𝕜] [NormOneClass 𝕜] (x : closedBall (0 : 𝕜) 1) (n : ℕ) : ↑(x ^ n) = (x : 𝕜) ^ n := rfl @[deprecated (since := "2025-04-18")] alias coe_pow_unitClosedBall := Metric.unitClosedBall.coe_pow instance Metric.unitClosedBall.instMonoidWithZero [SeminormedRing 𝕜] [NormOneClass 𝕜] : MonoidWithZero (closedBall (0 : 𝕜) 1) where instance Metric.unitClosedBall.instCancelMonoidWithZero [SeminormedRing 𝕜] [IsCancelMulZero 𝕜] [NormOneClass 𝕜] : CancelMonoidWithZero (closedBall (0 : 𝕜) 1) where toIsCancelMulZero := Subtype.val_injective.isCancelMulZero _ rfl fun _ _ ↦ rfl /-! ### Algebraic instances on the unit sphere -/ /-- Unit sphere in a seminormed ring (with strictly multiplicative norm) as a bundled `Submonoid`. -/ @[simps] def Submonoid.unitSphere (𝕜 : Type*) [SeminormedRing 𝕜] [NormMulClass 𝕜] [NormOneClass 𝕜] : Submonoid 𝕜 where carrier := sphere (0 : 𝕜) 1 mul_mem' hx hy := by rw [mem_sphere_zero_iff_norm] at * simp [*] one_mem' := mem_sphere_zero_iff_norm.2 norm_one instance Metric.unitSphere.instInv [NormedDivisionRing 𝕜] : Inv (sphere (0 : 𝕜) 1) where inv x := ⟨x⁻¹, mem_sphere_zero_iff_norm.2 <| by rw [norm_inv, mem_sphere_zero_iff_norm.1 x.coe_prop, inv_one]⟩ @[simp, norm_cast] theorem Metric.unitSphere.coe_inv [NormedDivisionRing 𝕜] (x : sphere (0 : 𝕜) 1) : ↑x⁻¹ = (x⁻¹ : 𝕜) := rfl @[deprecated (since := "2025-04-18")] alias coe_inv_unitSphere := Metric.unitSphere.coe_inv instance Metric.unitSphere.instDiv [NormedDivisionRing 𝕜] : Div (sphere (0 : 𝕜) 1) where div x y := .mk (x / y) <| mem_sphere_zero_iff_norm.2 <| by rw [norm_div, mem_sphere_zero_iff_norm.1 x.2, mem_sphere_zero_iff_norm.1 y.coe_prop, div_one] @[simp, norm_cast] protected theorem Metric.unitSphere.coe_div [NormedDivisionRing 𝕜] (x y : sphere (0 : 𝕜) 1) : ↑(x / y) = (x / y : 𝕜) := rfl @[deprecated (since := "2025-04-18")] alias coe_div_unitSphere := Metric.unitSphere.coe_div instance Metric.unitSphere.instZPow [NormedDivisionRing 𝕜] : Pow (sphere (0 : 𝕜) 1) ℤ where pow x n := .mk ((x : 𝕜) ^ n) <| by rw [mem_sphere_zero_iff_norm, norm_zpow, mem_sphere_zero_iff_norm.1 x.coe_prop, one_zpow] @[simp, norm_cast] theorem Metric.unitSphere.coe_zpow [NormedDivisionRing 𝕜] (x : sphere (0 : 𝕜) 1) (n : ℤ) : ↑(x ^ n) = (x : 𝕜) ^ n := rfl @[deprecated (since := "2025-04-18")] alias coe_zpow_unitSphere := Metric.unitSphere.coe_zpow instance Metric.unitSphere.instMonoid [SeminormedRing 𝕜] [NormMulClass 𝕜] [NormOneClass 𝕜] : Monoid (sphere (0 : 𝕜) 1) := SubmonoidClass.toMonoid (Submonoid.unitSphere 𝕜) instance Metric.unitSphere.instCommMonoid [SeminormedCommRing 𝕜] [NormMulClass 𝕜] [NormOneClass 𝕜] : CommMonoid (sphere (0 : 𝕜) 1) := SubmonoidClass.toCommMonoid (Submonoid.unitSphere 𝕜) @[simp, norm_cast] protected theorem Metric.unitSphere.coe_one [SeminormedRing 𝕜] [NormMulClass 𝕜] [NormOneClass 𝕜] : ((1 : sphere (0 : 𝕜) 1) : 𝕜) = 1 := rfl @[deprecated (since := "2025-04-18")] alias coe_one_unitSphere := Metric.unitSphere.coe_one @[simp, norm_cast] theorem Metric.unitSphere.coe_mul [SeminormedRing 𝕜] [NormMulClass 𝕜] [NormOneClass 𝕜] (x y : sphere (0 : 𝕜) 1) : ↑(x * y) = (x * y : 𝕜) := rfl @[deprecated (since := "2025-04-18")] alias coe_mul_unitSphere := Metric.unitSphere.coe_mul @[simp, norm_cast] theorem Metric.unitSphere.coe_pow [SeminormedRing 𝕜] [NormMulClass 𝕜] [NormOneClass 𝕜] (x : sphere (0 : 𝕜) 1) (n : ℕ) : ↑(x ^ n) = (x : 𝕜) ^ n := rfl @[deprecated (since := "2025-04-18")] alias coe_pow_unitSphere := Metric.unitSphere.coe_pow /-- Monoid homomorphism from the unit sphere in a normed division ring to the group of units. -/ def unitSphereToUnits (𝕜 : Type*) [NormedDivisionRing 𝕜] : sphere (0 : 𝕜) 1 →* Units 𝕜 := Units.liftRight (Submonoid.unitSphere 𝕜).subtype (fun x => Units.mk0 x <| ne_zero_of_mem_unit_sphere _) fun _x => rfl @[simp] theorem unitSphereToUnits_apply_coe [NormedDivisionRing 𝕜] (x : sphere (0 : 𝕜) 1) : (unitSphereToUnits 𝕜 x : 𝕜) = x := rfl theorem unitSphereToUnits_injective [NormedDivisionRing 𝕜] : Function.Injective (unitSphereToUnits 𝕜) := fun x y h => Subtype.eq <| by convert congr_arg Units.val h instance Metric.unitSphere.instGroup [NormedDivisionRing 𝕜] : Group (sphere (0 : 𝕜) 1) := unitSphereToUnits_injective.group (unitSphereToUnits 𝕜) (Units.ext rfl) (fun _x _y => Units.ext rfl) (fun _x => Units.ext rfl) (fun _x _y => Units.ext <| div_eq_mul_inv _ _) (fun x n => Units.ext (Units.val_pow_eq_pow_val (unitSphereToUnits 𝕜 x) n).symm) fun x n => Units.ext (Units.val_zpow_eq_zpow_val (unitSphereToUnits 𝕜 x) n).symm instance Metric.sphere.instHasDistribNeg [SeminormedRing 𝕜] [NormMulClass 𝕜] [NormOneClass 𝕜] : HasDistribNeg (sphere (0 : 𝕜) 1) := Subtype.coe_injective.hasDistribNeg ((↑) : sphere (0 : 𝕜) 1 → 𝕜) (fun _ => rfl) fun _ _ => rfl instance Metric.sphere.instContinuousMul [SeminormedRing 𝕜] [NormMulClass 𝕜] [NormOneClass 𝕜] : ContinuousMul (sphere (0 : 𝕜) 1) := (Submonoid.unitSphere 𝕜).continuousMul instance Metric.sphere.instIsTopologicalGroup [NormedDivisionRing 𝕜] : IsTopologicalGroup (sphere (0 : 𝕜) 1) where continuous_inv := (continuous_subtype_val.inv₀ ne_zero_of_mem_unit_sphere).subtype_mk _ instance Metric.sphere.instCommGroup [NormedField 𝕜] : CommGroup (sphere (0 : 𝕜) 1) where
Basic.lean
/- Copyright (c) 2024 Paul Reichert. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Paul Reichert -/ import Mathlib.CategoryTheory.Abelian.GrothendieckAxioms.Basic import Mathlib.CategoryTheory.Abelian.Subobject import Mathlib.CategoryTheory.Abelian.Transfer import Mathlib.CategoryTheory.Adjunction.AdjointFunctorTheorems import Mathlib.CategoryTheory.Limits.HasLimits /-! # Grothendieck categories This file defines Grothendieck categories and proves basic facts about them. ## Definitions A Grothendieck category according to the Stacks project is an abelian category provided that it has `AB5` and a separator. However, this definition is not invariant under equivalences of categories. Therefore, if `C` is an abelian category, the class `IsGrothendieckAbelian.{w} C` has a weaker definition that is also satisfied for categories that are merely equivalent to a Grothendieck category in the former strict sense. ## Theorems The invariance under equivalences of categories is established in `IsGrothendieckAbelian.of_equivalence`. In particular, `ShrinkHoms.isGrothendieckAbelian C` shows that `ShrinkHoms C` satisfies our definition of a Grothendieck category after shrinking its hom sets, which coincides with the strict definition in this case. Relevant implications of `IsGrothendieckAbelian` are established in `IsGrothendieckAbelian.hasLimits` and `IsGrothendieckAbelian.hasColimits`. ## References * [Stacks: Grothendieck's AB conditions](https://stacks.math.columbia.edu/tag/079A) -/ namespace CategoryTheory open Limits universe w v u w₂ v₂ u₂ variable (C : Type u) [Category.{v} C] (D : Type u₂) [Category.{v₂} D] /-- If `C` is an abelian category, we shall say that it satisfies `IsGrothendieckAbelian.{w} C` if it is locally small (relative to `w`), has exact filtered colimits of size `w` (AB5) and has a separator. If `[Category.{v} C]` and `w = v`, this means that `C` satisfies `AB5` and has a separator; general results about Grothendieck abelian categories can be reduced to this case using the instance `ShrinkHoms.isGrothendieckAbelian` below. The introduction of the auxiliary universe `w` shall be needed for certain applications to categories of sheaves. That the present definition still preserves essential properties of Grothendieck categories is ensured by `IsGrothendieckAbelian.of_equivalence`, which shows that every instance for `C` implies an instance for `ShrinkHoms C` with hom sets in `Type w`. -/ @[stacks 079B, pp_with_univ] class IsGrothendieckAbelian [Abelian C] : Prop where locallySmall : LocallySmall.{w} C := by infer_instance hasFilteredColimitsOfSize : HasFilteredColimitsOfSize.{w, w} C := by infer_instance ab5OfSize : AB5OfSize.{w, w} C := by infer_instance hasSeparator : HasSeparator C := by infer_instance attribute [instance] IsGrothendieckAbelian.locallySmall IsGrothendieckAbelian.hasFilteredColimitsOfSize IsGrothendieckAbelian.ab5OfSize IsGrothendieckAbelian.hasSeparator variable {C} {D} in theorem IsGrothendieckAbelian.of_equivalence [Abelian C] [Abelian D] [IsGrothendieckAbelian.{w} C] (α : C ≌ D) : IsGrothendieckAbelian.{w} D := by have hasFilteredColimits : HasFilteredColimitsOfSize.{w, w, v₂, u₂} D := ⟨fun _ _ _ => Adjunction.hasColimitsOfShape_of_equivalence α.inverse⟩ refine ⟨?_, hasFilteredColimits, ?_, ?_⟩ · exact locallySmall_of_faithful α.inverse · refine ⟨fun _ _ _ => ?_⟩ exact HasExactColimitsOfShape.of_codomain_equivalence _ α · exact HasSeparator.of_equivalence α instance ShrinkHoms.isGrothendieckAbelian [Abelian C] [IsGrothendieckAbelian.{w} C] : IsGrothendieckAbelian.{w, w} (ShrinkHoms C) := IsGrothendieckAbelian.of_equivalence <| ShrinkHoms.equivalence C section Instances variable [Abelian C] [IsGrothendieckAbelian.{w} C] instance IsGrothendieckAbelian.hasColimits : HasColimitsOfSize.{w, w} C := has_colimits_of_finite_and_filtered instance IsGrothendieckAbelian.hasLimits : HasLimitsOfSize.{w, w} C := have : HasLimits.{w, u} (ShrinkHoms C) := hasLimits_of_hasColimits_of_hasSeparator Adjunction.has_limits_of_equivalence (ShrinkHoms.equivalence C |>.functor) instance IsGrothendieckAbelian.wellPowered : WellPowered.{w} C := wellPowered_of_equiv.{w} (ShrinkHoms.equivalence.{w} C).symm instance IsGrothendieckAbelian.ab4OfSize : AB4OfSize.{w} C := by have : HasFiniteBiproducts C := HasFiniteBiproducts.of_hasFiniteProducts apply AB4.of_AB5 end Instances end CategoryTheory
Order.lean
/- Copyright (c) 2022 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Topology.Sets.Closeds /-! # Clopen upper sets In this file we define the type of clopen upper sets. -/ open Set TopologicalSpace variable {α : Type*} [TopologicalSpace α] [LE α] /-! ### Compact open sets -/ /-- The type of clopen upper sets of a topological space. -/ structure ClopenUpperSet (α : Type*) [TopologicalSpace α] [LE α] extends Clopens α where upper' : IsUpperSet carrier namespace ClopenUpperSet instance : SetLike (ClopenUpperSet α) α where coe s := s.carrier coe_injective' s t h := by obtain ⟨⟨_, _⟩, _⟩ := s obtain ⟨⟨_, _⟩, _⟩ := t congr /-- See Note [custom simps projection]. -/ def Simps.coe (s : ClopenUpperSet α) : Set α := s initialize_simps_projections ClopenUpperSet (carrier → coe, as_prefix coe) theorem upper (s : ClopenUpperSet α) : IsUpperSet (s : Set α) := s.upper' theorem isClopen (s : ClopenUpperSet α) : IsClopen (s : Set α) := s.isClopen' /-- Reinterpret an upper clopen as an upper set. -/ @[simps] def toUpperSet (s : ClopenUpperSet α) : UpperSet α := ⟨s, s.upper⟩ @[ext] protected theorem ext {s t : ClopenUpperSet α} (h : (s : Set α) = t) : s = t := SetLike.ext' h @[simp] theorem coe_mk (s : Clopens α) (h) : (mk s h : Set α) = s := rfl instance : Max (ClopenUpperSet α) := ⟨fun s t => ⟨s.toClopens ⊔ t.toClopens, s.upper.union t.upper⟩⟩ instance : Min (ClopenUpperSet α) := ⟨fun s t => ⟨s.toClopens ⊓ t.toClopens, s.upper.inter t.upper⟩⟩ instance : Top (ClopenUpperSet α) := ⟨⟨⊤, isUpperSet_univ⟩⟩ instance : Bot (ClopenUpperSet α) := ⟨⟨⊥, isUpperSet_empty⟩⟩ instance : Lattice (ClopenUpperSet α) := SetLike.coe_injective.lattice _ (fun _ _ => rfl) fun _ _ => rfl instance : BoundedOrder (ClopenUpperSet α) := BoundedOrder.lift ((↑) : _ → Set α) (fun _ _ => id) rfl rfl @[simp] theorem coe_sup (s t : ClopenUpperSet α) : (↑(s ⊔ t) : Set α) = ↑s ∪ ↑t := rfl @[simp] theorem coe_inf (s t : ClopenUpperSet α) : (↑(s ⊓ t) : Set α) = ↑s ∩ ↑t := rfl @[simp] theorem coe_top : (↑(⊤ : ClopenUpperSet α) : Set α) = univ := rfl @[simp] theorem coe_bot : (↑(⊥ : ClopenUpperSet α) : Set α) = ∅ := rfl instance : Inhabited (ClopenUpperSet α) := ⟨⊥⟩ end ClopenUpperSet