source
stringlengths
17
118
lean4
stringlengths
0
335k
.lake/packages/mathlib/Mathlib/Topology/Separation/Lemmas.lean
import Mathlib.Topology.GDelta.MetrizableSpace import Mathlib.Topology.Separation.CompletelyRegular import Mathlib.Topology.Separation.Profinite /-! # Further separation lemmas -/ variable {X : Type*} namespace CompletelyRegularSpace variable [TopologicalSpace X] [T35Space X] theorem totallySeparatedSpace_of_cardinalMk_lt_continuum (h : Cardinal.mk X < Cardinal.continuum) : TotallySeparatedSpace X := totallySeparatedSpace_of_t0_of_basis_clopen <| CompletelyRegularSpace.isTopologicalBasis_clopens_of_cardinalMk_lt_continuum h instance [Countable X] : TotallySeparatedSpace X := totallySeparatedSpace_of_cardinalMk_lt_continuum <| (Cardinal.mk_le_aleph0_iff.mpr inferInstance).trans_lt Cardinal.aleph0_lt_continuum protected lemma _root_.Set.Countable.totallySeparatedSpace {s : Set X} (h : s.Countable) : TotallySeparatedSpace s := have : _root_.Countable s := h inferInstanceAs (TotallySeparatedSpace s) end CompletelyRegularSpace /-- Countable subsets of metric spaces are totally disconnected. -/ theorem Set.Countable.isTotallyDisconnected [MetricSpace X] {s : Set X} (hs : s.Countable) : IsTotallyDisconnected s := by rw [← totallyDisconnectedSpace_subtype_iff] have : Countable s := hs infer_instance
.lake/packages/mathlib/Mathlib/Topology/Separation/LinearUpperLowerSetTopology.lean
import Mathlib.Topology.Order.UpperLowerSetTopology import Mathlib.Topology.Separation.Regular /-! # Linear upper or lower sets topologies are completely normal -/ open Set Topology.IsUpperSet instance (priority := low) {α : Type*} [TopologicalSpace α] [LinearOrder α] [Topology.IsUpperSet α] : CompletelyNormalSpace α where completely_normal s t hcst hsct := by obtain (rfl | ⟨a, ha⟩) := s.eq_empty_or_nonempty case inl => simp obtain (rfl | ⟨b, hb⟩) := t.eq_empty_or_nonempty case inl => simp exfalso grewrite [← singleton_subset_iff.mpr ha, ← singleton_subset_iff.mpr hb] at hcst hsct conv at hcst => equals a < b => simp conv at hsct => equals b < a => simp exact lt_asymm hcst hsct instance (priority := low) {α : Type*} [TopologicalSpace α] [LinearOrder α] [Topology.IsLowerSet α] : CompletelyNormalSpace α := inferInstanceAs (CompletelyNormalSpace αᵒᵈ) instance : CompletelyNormalSpace Prop := inferInstance
.lake/packages/mathlib/Mathlib/Topology/Separation/Basic.lean
import Mathlib.Algebra.Notation.Support import Mathlib.Topology.Inseparable import Mathlib.Topology.Piecewise import Mathlib.Topology.Separation.SeparatedNhds import Mathlib.Topology.Compactness.LocallyCompact import Mathlib.Topology.Bases import Mathlib.Tactic.StacksAttribute /-! # Separation properties of topological spaces This file defines some of the weaker separation axioms (under the Kolmogorov classification), notably T₀, R₀, T₁ and R₁ spaces. For T₂ (Hausdorff) spaces and other stronger conditions, see the file `Mathlib/Topology/Separation/Hausdorff.lean`. ## Main definitions * `SeparatedNhds`: Two `Set`s are separated by neighbourhoods if they are contained in disjoint open sets. * `HasSeparatingCover`: A set has a countable cover that can be used with `hasSeparatingCovers_iff_separatedNhds` to witness when two `Set`s have `SeparatedNhds`. * `T0Space`: A T₀/Kolmogorov space is a space where, for every two points `x ≠ y`, there is an open set that contains one, but not the other. * `R0Space`: An R₀ space (sometimes called a *symmetric space*) is a topological space such that the `Specializes` relation is symmetric. * `T1Space`: A T₁/Fréchet space is a space where every singleton set is closed. This is equivalent to, for every pair `x ≠ y`, there existing an open set containing `x` but not `y` (`t1Space_iff_exists_open` shows that these conditions are equivalent.) T₁ iff T₀ and R₀. * `R1Space`: An R₁/preregular space is a space where any two topologically distinguishable points have disjoint neighbourhoods. R₁ implies R₀. Note that `mathlib` adopts the modern convention that `m ≤ n` if and only if `T_m → T_n`, but occasionally the literature swaps definitions for e.g. T₃ and regular. ## Main results ### T₀ spaces * `IsClosed.exists_closed_singleton`: Given a closed set `S` in a compact T₀ space, there is some `x ∈ S` such that `{x}` is closed. * `exists_isOpen_singleton_of_isOpen_finite`: Given an open finite set `S` in a T₀ space, there is some `x ∈ S` such that `{x}` is open. ### T₁ spaces * `isClosedMap_const`: The constant map is a closed map. * `Finite.instDiscreteTopology`: A finite T₁ space must have the discrete topology. ## References * <https://en.wikipedia.org/wiki/Separation_axiom> * [Willard's *General Topology*][zbMATH02107988] -/ open Function Set Filter Topology TopologicalSpace universe u v variable {X : Type*} {Y : Type*} [TopologicalSpace X] section Separation /-- A T₀ space, also known as a Kolmogorov space, is a topological space such that for every pair `x ≠ y`, there is an open set containing one but not the other. We formulate the definition in terms of the `Inseparable` relation. -/ @[stacks 004X "(2)"] class T0Space (X : Type u) [TopologicalSpace X] : Prop where /-- Two inseparable points in a T₀ space are equal. -/ t0 : ∀ ⦃x y : X⦄, Inseparable x y → x = y theorem t0Space_iff_inseparable (X : Type u) [TopologicalSpace X] : T0Space X ↔ ∀ x y : X, Inseparable x y → x = y := ⟨fun ⟨h⟩ => h, fun h => ⟨h⟩⟩ theorem t0Space_iff_not_inseparable (X : Type u) [TopologicalSpace X] : T0Space X ↔ Pairwise fun x y : X => ¬Inseparable x y := by simp only [t0Space_iff_inseparable, Ne, not_imp_not, Pairwise] theorem Inseparable.eq [T0Space X] {x y : X} (h : Inseparable x y) : x = y := T0Space.t0 h /-- A topology inducing map from a T₀ space is injective. -/ protected theorem Topology.IsInducing.injective [TopologicalSpace Y] [T0Space X] {f : X → Y} (hf : IsInducing f) : Injective f := fun _ _ h => (hf.inseparable_iff.1 <| .of_eq h).eq /-- A topology inducing map from a T₀ space is a topological embedding. -/ protected theorem Topology.IsInducing.isEmbedding [TopologicalSpace Y] [T0Space X] {f : X → Y} (hf : IsInducing f) : IsEmbedding f := ⟨hf, hf.injective⟩ lemma isEmbedding_iff_isInducing [TopologicalSpace Y] [T0Space X] {f : X → Y} : IsEmbedding f ↔ IsInducing f := ⟨IsEmbedding.isInducing, IsInducing.isEmbedding⟩ theorem t0Space_iff_nhds_injective (X : Type u) [TopologicalSpace X] : T0Space X ↔ Injective (𝓝 : X → Filter X) := t0Space_iff_inseparable X theorem nhds_injective [T0Space X] : Injective (𝓝 : X → Filter X) := (t0Space_iff_nhds_injective X).1 ‹_› theorem inseparable_iff_eq [T0Space X] {x y : X} : Inseparable x y ↔ x = y := nhds_injective.eq_iff @[simp] theorem nhds_eq_nhds_iff [T0Space X] {a b : X} : 𝓝 a = 𝓝 b ↔ a = b := nhds_injective.eq_iff @[simp] theorem inseparable_eq_eq [T0Space X] : Inseparable = @Eq X := funext₂ fun _ _ => propext inseparable_iff_eq theorem TopologicalSpace.IsTopologicalBasis.inseparable_iff {b : Set (Set X)} (hb : IsTopologicalBasis b) {x y : X} : Inseparable x y ↔ ∀ s ∈ b, (x ∈ s ↔ y ∈ s) := ⟨fun h _ hs ↦ inseparable_iff_forall_isOpen.1 h _ (hb.isOpen hs), fun h ↦ hb.nhds_hasBasis.eq_of_same_basis <| by convert hb.nhds_hasBasis using 2 exact and_congr_right (h _)⟩ theorem TopologicalSpace.IsTopologicalBasis.eq_iff [T0Space X] {b : Set (Set X)} (hb : IsTopologicalBasis b) {x y : X} : x = y ↔ ∀ s ∈ b, (x ∈ s ↔ y ∈ s) := inseparable_iff_eq.symm.trans hb.inseparable_iff theorem t0Space_iff_exists_isOpen_xor'_mem (X : Type u) [TopologicalSpace X] : T0Space X ↔ Pairwise fun x y => ∃ U : Set X, IsOpen U ∧ Xor' (x ∈ U) (y ∈ U) := by simp only [t0Space_iff_not_inseparable, xor_iff_not_iff, not_forall, exists_prop, inseparable_iff_forall_isOpen, Pairwise] theorem exists_isOpen_xor'_mem [T0Space X] {x y : X} (h : x ≠ y) : ∃ U : Set X, IsOpen U ∧ Xor' (x ∈ U) (y ∈ U) := (t0Space_iff_exists_isOpen_xor'_mem X).1 ‹_› h /-- Specialization forms a partial order on a t0 topological space. -/ def specializationOrder (X) [TopologicalSpace X] [T0Space X] : PartialOrder X := { specializationPreorder X, PartialOrder.lift (OrderDual.toDual ∘ 𝓝) nhds_injective with } instance SeparationQuotient.instT0Space : T0Space (SeparationQuotient X) := ⟨fun x y => Quotient.inductionOn₂' x y fun _ _ h => SeparationQuotient.mk_eq_mk.2 <| SeparationQuotient.isInducing_mk.inseparable_iff.1 h⟩ theorem minimal_nonempty_closed_subsingleton [T0Space X] {s : Set X} (hs : IsClosed s) (hmin : ∀ t, t ⊆ s → t.Nonempty → IsClosed t → t = s) : s.Subsingleton := by refine fun x hx y hy => of_not_not fun hxy => ?_ rcases exists_isOpen_xor'_mem hxy with ⟨U, hUo, hU⟩ wlog h : x ∈ U ∧ y ∉ U · refine this hs hmin y hy x hx (Ne.symm hxy) U hUo hU.symm (hU.resolve_left h) obtain ⟨hxU, hyU⟩ := h have : s \ U = s := hmin (s \ U) diff_subset ⟨y, hy, hyU⟩ (hs.sdiff hUo) exact (this.symm.subset hx).2 hxU theorem minimal_nonempty_closed_eq_singleton [T0Space X] {s : Set X} (hs : IsClosed s) (hne : s.Nonempty) (hmin : ∀ t, t ⊆ s → t.Nonempty → IsClosed t → t = s) : ∃ x, s = {x} := exists_eq_singleton_iff_nonempty_subsingleton.2 ⟨hne, minimal_nonempty_closed_subsingleton hs hmin⟩ /-- Given a closed set `S` in a compact T₀ space, there is some `x ∈ S` such that `{x}` is closed. -/ theorem IsClosed.exists_closed_singleton [T0Space X] [CompactSpace X] {S : Set X} (hS : IsClosed S) (hne : S.Nonempty) : ∃ x : X, x ∈ S ∧ IsClosed ({x} : Set X) := by obtain ⟨V, Vsub, Vne, Vcls, hV⟩ := hS.exists_minimal_nonempty_closed_subset hne rcases minimal_nonempty_closed_eq_singleton Vcls Vne hV with ⟨x, rfl⟩ exact ⟨x, Vsub (mem_singleton x), Vcls⟩ theorem minimal_nonempty_open_subsingleton [T0Space X] {s : Set X} (hs : IsOpen s) (hmin : ∀ t, t ⊆ s → t.Nonempty → IsOpen t → t = s) : s.Subsingleton := by refine fun x hx y hy => of_not_not fun hxy => ?_ rcases exists_isOpen_xor'_mem hxy with ⟨U, hUo, hU⟩ wlog h : x ∈ U ∧ y ∉ U · exact this hs hmin y hy x hx (Ne.symm hxy) U hUo hU.symm (hU.resolve_left h) obtain ⟨hxU, hyU⟩ := h have : s ∩ U = s := hmin (s ∩ U) inter_subset_left ⟨x, hx, hxU⟩ (hs.inter hUo) exact hyU (this.symm.subset hy).2 theorem minimal_nonempty_open_eq_singleton [T0Space X] {s : Set X} (hs : IsOpen s) (hne : s.Nonempty) (hmin : ∀ t, t ⊆ s → t.Nonempty → IsOpen t → t = s) : ∃ x, s = {x} := exists_eq_singleton_iff_nonempty_subsingleton.2 ⟨hne, minimal_nonempty_open_subsingleton hs hmin⟩ /-- Given an open finite set `S` in a T₀ space, there is some `x ∈ S` such that `{x}` is open. -/ theorem exists_isOpen_singleton_of_isOpen_finite [T0Space X] {s : Set X} (hfin : s.Finite) (hne : s.Nonempty) (ho : IsOpen s) : ∃ x ∈ s, IsOpen ({x} : Set X) := by lift s to Finset X using hfin induction s using Finset.strongInductionOn rename_i s ihs rcases em (∃ t, t ⊂ s ∧ t.Nonempty ∧ IsOpen (t : Set X)) with (⟨t, hts, htne, hto⟩ | ht) · rcases ihs t hts htne hto with ⟨x, hxt, hxo⟩ exact ⟨x, hts.1 hxt, hxo⟩ · -- Porting note: was `rcases minimal_nonempty_open_eq_singleton ho hne _ with ⟨x, hx⟩` -- https://github.com/leanprover-community/batteries/issues/116 rsuffices ⟨x, hx⟩ : ∃ x, (s : Set X) = {x} · exact ⟨x, hx.symm ▸ rfl, hx ▸ ho⟩ refine minimal_nonempty_open_eq_singleton ho hne ?_ refine fun t hts htne hto => of_not_not fun hts' => ht ?_ lift t to Finset X using s.finite_toSet.subset hts exact ⟨t, ssubset_iff_subset_ne.2 ⟨hts, mt Finset.coe_inj.2 hts'⟩, htne, hto⟩ theorem exists_open_singleton_of_finite [T0Space X] [Finite X] [Nonempty X] : ∃ x : X, IsOpen ({x} : Set X) := let ⟨x, _, h⟩ := exists_isOpen_singleton_of_isOpen_finite (Set.toFinite _) univ_nonempty isOpen_univ ⟨x, h⟩ theorem t0Space_of_injective_of_continuous [TopologicalSpace Y] {f : X → Y} (hf : Function.Injective f) (hf' : Continuous f) [T0Space Y] : T0Space X := ⟨fun _ _ h => hf <| (h.map hf').eq⟩ protected theorem Topology.IsEmbedding.t0Space [TopologicalSpace Y] [T0Space Y] {f : X → Y} (hf : IsEmbedding f) : T0Space X := t0Space_of_injective_of_continuous hf.injective hf.continuous protected theorem Homeomorph.t0Space [TopologicalSpace Y] [T0Space X] (h : X ≃ₜ Y) : T0Space Y := h.symm.isEmbedding.t0Space @[stacks 0B31 "part 1"] instance Subtype.t0Space [T0Space X] {p : X → Prop} : T0Space (Subtype p) := IsEmbedding.subtypeVal.t0Space theorem t0Space_iff_or_notMem_closure (X : Type u) [TopologicalSpace X] : T0Space X ↔ Pairwise fun a b : X => a ∉ closure ({b} : Set X) ∨ b ∉ closure ({a} : Set X) := by simp only [t0Space_iff_not_inseparable, inseparable_iff_mem_closure, not_and_or] @[deprecated (since := "2025-05-23")] alias t0Space_iff_or_not_mem_closure := t0Space_iff_or_notMem_closure instance Prod.instT0Space [TopologicalSpace Y] [T0Space X] [T0Space Y] : T0Space (X × Y) := ⟨fun _ _ h => Prod.ext (h.map continuous_fst).eq (h.map continuous_snd).eq⟩ instance Pi.instT0Space {ι : Type*} {X : ι → Type*} [∀ i, TopologicalSpace (X i)] [∀ i, T0Space (X i)] : T0Space (∀ i, X i) := ⟨fun _ _ h => funext fun i => (h.map (continuous_apply i)).eq⟩ instance ULift.instT0Space [T0Space X] : T0Space (ULift X) := IsEmbedding.uliftDown.t0Space theorem T0Space.of_cover (h : ∀ x y, Inseparable x y → ∃ s : Set X, x ∈ s ∧ y ∈ s ∧ T0Space s) : T0Space X := by refine ⟨fun x y hxy => ?_⟩ rcases h x y hxy with ⟨s, hxs, hys, hs⟩ lift x to s using hxs; lift y to s using hys rw [← subtype_inseparable_iff] at hxy exact congr_arg Subtype.val hxy.eq theorem T0Space.of_open_cover (h : ∀ x, ∃ s : Set X, x ∈ s ∧ IsOpen s ∧ T0Space s) : T0Space X := T0Space.of_cover fun x _ hxy => let ⟨s, hxs, hso, hs⟩ := h x ⟨s, hxs, (hxy.mem_open_iff hso).1 hxs, hs⟩ /-- A topological space is called an R₀ space, if `Specializes` relation is symmetric. In other words, given two points `x y : X`, if every neighborhood of `y` contains `x`, then every neighborhood of `x` contains `y`. -/ @[mk_iff] class R0Space (X : Type u) [TopologicalSpace X] : Prop where /-- In an R₀ space, the `Specializes` relation is symmetric. -/ specializes_symmetric : Symmetric (Specializes : X → X → Prop) export R0Space (specializes_symmetric) section R0Space variable [R0Space X] {x y : X} /-- In an R₀ space, the `Specializes` relation is symmetric, dot notation version. -/ theorem Specializes.symm (h : x ⤳ y) : y ⤳ x := specializes_symmetric h /-- In an R₀ space, the `Specializes` relation is symmetric, `Iff` version. -/ theorem specializes_comm : x ⤳ y ↔ y ⤳ x := ⟨Specializes.symm, Specializes.symm⟩ /-- In an R₀ space, `Specializes` is equivalent to `Inseparable`. -/ theorem specializes_iff_inseparable : x ⤳ y ↔ Inseparable x y := ⟨fun h ↦ h.antisymm h.symm, Inseparable.specializes⟩ /-- In an R₀ space, `Specializes` implies `Inseparable`. -/ alias ⟨Specializes.inseparable, _⟩ := specializes_iff_inseparable theorem Topology.IsInducing.r0Space [TopologicalSpace Y] {f : Y → X} (hf : IsInducing f) : R0Space Y where specializes_symmetric a b := by simpa only [← hf.specializes_iff] using Specializes.symm instance {p : X → Prop} : R0Space {x // p x} := IsInducing.subtypeVal.r0Space instance [TopologicalSpace Y] [R0Space Y] : R0Space (X × Y) where specializes_symmetric _ _ h := h.fst.symm.prod h.snd.symm instance {ι : Type*} {X : ι → Type*} [∀ i, TopologicalSpace (X i)] [∀ i, R0Space (X i)] : R0Space (∀ i, X i) where specializes_symmetric _ _ h := specializes_pi.2 fun i ↦ (specializes_pi.1 h i).symm lemma R0Space.closure_singleton (x : X) : closure {x} = (𝓝 x).ker := by ext; simp [ker_nhds_eq_specializes, ← specializes_iff_mem_closure, specializes_comm] /-- In an R₀ space, the closure of a singleton is a compact set. -/ theorem isCompact_closure_singleton : IsCompact (closure {x}) := by refine isCompact_of_finite_subcover fun U hUo hxU ↦ ?_ obtain ⟨i, hi⟩ : ∃ i, x ∈ U i := mem_iUnion.1 <| hxU <| subset_closure rfl refine ⟨{i}, fun y hy ↦ ?_⟩ rw [← specializes_iff_mem_closure, specializes_comm] at hy simpa using hy.mem_open (hUo i) hi theorem Filter.coclosedCompact_le_cofinite : coclosedCompact X ≤ cofinite := le_cofinite_iff_compl_singleton_mem.2 fun _ ↦ compl_mem_coclosedCompact.2 isCompact_closure_singleton variable (X) in /-- In an R₀ space, relatively compact sets form a bornology. Its cobounded filter is `Filter.coclosedCompact`. See also `Bornology.inCompact` the bornology of sets contained in a compact set. -/ def Bornology.relativelyCompact : Bornology X where cobounded := Filter.coclosedCompact X le_cofinite := Filter.coclosedCompact_le_cofinite theorem Bornology.relativelyCompact.isBounded_iff {s : Set X} : @Bornology.IsBounded _ (Bornology.relativelyCompact X) s ↔ IsCompact (closure s) := compl_mem_coclosedCompact /-- In an R₀ space, the closure of a finite set is a compact set. -/ theorem Set.Finite.isCompact_closure {s : Set X} (hs : s.Finite) : IsCompact (closure s) := let _ : Bornology X := .relativelyCompact X Bornology.relativelyCompact.isBounded_iff.1 hs.isBounded end R0Space /-- A T₁ space, also known as a Fréchet space, is a topological space where every singleton set is closed. Equivalently, for every pair `x ≠ y`, there is an open set containing `x` and not `y`. -/ class T1Space (X : Type u) [TopologicalSpace X] : Prop where /-- A singleton in a T₁ space is a closed set. -/ t1 : ∀ x, IsClosed ({x} : Set X) theorem isClosed_singleton [T1Space X] {x : X} : IsClosed ({x} : Set X) := T1Space.t1 x theorem isOpen_compl_singleton [T1Space X] {x : X} : IsOpen ({x}ᶜ : Set X) := isClosed_singleton.isOpen_compl theorem isOpen_ne [T1Space X] {x : X} : IsOpen { y | y ≠ x } := isOpen_compl_singleton @[to_additive] theorem Continuous.isOpen_mulSupport [T1Space X] [One X] [TopologicalSpace Y] {f : Y → X} (hf : Continuous f) : IsOpen (mulSupport f) := isOpen_ne.preimage hf theorem Ne.nhdsWithin_compl_singleton [T1Space X] {x y : X} (h : x ≠ y) : 𝓝[{y}ᶜ] x = 𝓝 x := isOpen_ne.nhdsWithin_eq h theorem Ne.nhdsWithin_diff_singleton [T1Space X] {x y : X} (h : x ≠ y) (s : Set X) : 𝓝[s \ {y}] x = 𝓝[s] x := by rw [diff_eq, inter_comm, nhdsWithin_inter_of_mem] exact mem_nhdsWithin_of_mem_nhds (isOpen_ne.mem_nhds h) lemma nhdsWithin_compl_singleton_le [T1Space X] (x y : X) : 𝓝[{x}ᶜ] x ≤ 𝓝[{y}ᶜ] x := by rcases eq_or_ne x y with rfl | hy · exact Eq.le rfl · rw [Ne.nhdsWithin_compl_singleton hy] exact nhdsWithin_le_nhds theorem isOpen_setOf_eventually_nhdsWithin [T1Space X] {p : X → Prop} : IsOpen { x | ∀ᶠ y in 𝓝[≠] x, p y } := by refine isOpen_iff_mem_nhds.mpr fun a ha => ?_ filter_upwards [eventually_nhds_nhdsWithin.mpr ha] with b hb rcases eq_or_ne a b with rfl | h · exact hb · rw [h.symm.nhdsWithin_compl_singleton] at hb exact hb.filter_mono nhdsWithin_le_nhds @[simp] protected lemma Set.Finite.isClosed [T1Space X] {s : Set X} (hs : s.Finite) : IsClosed s := by rw [← biUnion_of_singleton s] exact hs.isClosed_biUnion fun i _ => isClosed_singleton theorem TopologicalSpace.IsTopologicalBasis.exists_mem_of_ne [T1Space X] {b : Set (Set X)} (hb : IsTopologicalBasis b) {x y : X} (h : x ≠ y) : ∃ a ∈ b, x ∈ a ∧ y ∉ a := by rcases hb.isOpen_iff.1 isOpen_ne x h with ⟨a, ab, xa, ha⟩ exact ⟨a, ab, xa, fun h => ha h rfl⟩ protected theorem Finset.isClosed [T1Space X] (s : Finset X) : IsClosed (s : Set X) := s.finite_toSet.isClosed theorem t1Space_TFAE (X : Type u) [TopologicalSpace X] : List.TFAE [T1Space X, ∀ x, IsClosed ({ x } : Set X), ∀ x, IsOpen ({ x }ᶜ : Set X), Continuous (@CofiniteTopology.of X), ∀ ⦃x y : X⦄, x ≠ y → {y}ᶜ ∈ 𝓝 x, ∀ ⦃x y : X⦄, x ≠ y → ∃ s ∈ 𝓝 x, y ∉ s, ∀ ⦃x y : X⦄, x ≠ y → ∃ U : Set X, IsOpen U ∧ x ∈ U ∧ y ∉ U, ∀ ⦃x y : X⦄, x ≠ y → Disjoint (𝓝 x) (pure y), ∀ ⦃x y : X⦄, x ≠ y → Disjoint (pure x) (𝓝 y), ∀ ⦃x y : X⦄, x ⤳ y → x = y, T0Space X ∧ R0Space X] := by tfae_have 1 ↔ 2 := ⟨fun h => h.1, fun h => ⟨h⟩⟩ tfae_have 2 ↔ 3 := by simp only [isOpen_compl_iff] tfae_have 5 ↔ 3 := by refine forall_swap.trans ?_ simp only [isOpen_iff_mem_nhds, mem_compl_iff, mem_singleton_iff] tfae_have 5 ↔ 6 := by simp only [← subset_compl_singleton_iff, exists_mem_subset_iff] tfae_have 5 ↔ 7 := by simp only [(nhds_basis_opens _).mem_iff, subset_compl_singleton_iff, and_assoc, and_left_comm] tfae_have 5 ↔ 8 := by simp only [← principal_singleton, disjoint_principal_right] tfae_have 8 ↔ 9 := forall_swap.trans (by simp only [disjoint_comm, ne_comm]) tfae_have 1 → 4 := by simp only [continuous_def, CofiniteTopology.isOpen_iff'] rintro H s (rfl | hs) exacts [isOpen_empty, compl_compl s ▸ (@Set.Finite.isClosed _ _ H _ hs).isOpen_compl] tfae_have 4 → 2 := fun h x => (CofiniteTopology.isClosed_iff.2 <| Or.inr (finite_singleton _)).preimage h tfae_have 2 ↔ 10 := by simp only [← closure_subset_iff_isClosed, specializes_iff_mem_closure, subset_def, mem_singleton_iff, eq_comm] tfae_have 10 ↔ 11 := ⟨fun h => ⟨⟨fun _ _ h₂ => h h₂.specializes⟩, ⟨fun _ _ h₂ => specializes_of_eq (h h₂).symm⟩⟩, fun ⟨_, _⟩ _ _ h => (h.antisymm h.symm).eq⟩ tfae_finish theorem t1Space_iff_continuous_cofinite_of : T1Space X ↔ Continuous (@CofiniteTopology.of X) := (t1Space_TFAE X).out 0 3 theorem CofiniteTopology.continuous_of [T1Space X] : Continuous (@CofiniteTopology.of X) := t1Space_iff_continuous_cofinite_of.mp ‹_› theorem t1Space_iff_exists_open : T1Space X ↔ Pairwise fun x y => ∃ U : Set X, IsOpen U ∧ x ∈ U ∧ y ∉ U := (t1Space_TFAE X).out 0 6 theorem t1Space_iff_disjoint_pure_nhds : T1Space X ↔ ∀ ⦃x y : X⦄, x ≠ y → Disjoint (pure x) (𝓝 y) := (t1Space_TFAE X).out 0 8 theorem t1Space_iff_disjoint_nhds_pure : T1Space X ↔ ∀ ⦃x y : X⦄, x ≠ y → Disjoint (𝓝 x) (pure y) := (t1Space_TFAE X).out 0 7 theorem t1Space_iff_specializes_imp_eq : T1Space X ↔ ∀ ⦃x y : X⦄, x ⤳ y → x = y := (t1Space_TFAE X).out 0 9 theorem t1Space_iff_t0Space_and_r0Space : T1Space X ↔ T0Space X ∧ R0Space X := (t1Space_TFAE X).out 0 10 theorem disjoint_pure_nhds [T1Space X] {x y : X} (h : x ≠ y) : Disjoint (pure x) (𝓝 y) := t1Space_iff_disjoint_pure_nhds.mp ‹_› h theorem disjoint_nhds_pure [T1Space X] {x y : X} (h : x ≠ y) : Disjoint (𝓝 x) (pure y) := t1Space_iff_disjoint_nhds_pure.mp ‹_› h theorem Specializes.eq [T1Space X] {x y : X} (h : x ⤳ y) : x = y := t1Space_iff_specializes_imp_eq.1 ‹_› h theorem specializes_iff_eq [T1Space X] {x y : X} : x ⤳ y ↔ x = y := ⟨Specializes.eq, fun h => h ▸ specializes_rfl⟩ @[simp] theorem specializes_eq_eq [T1Space X] : (· ⤳ ·) = @Eq X := funext₂ fun _ _ => propext specializes_iff_eq @[simp] theorem pure_le_nhds_iff [T1Space X] {a b : X} : pure a ≤ 𝓝 b ↔ a = b := specializes_iff_pure.symm.trans specializes_iff_eq @[simp] theorem nhds_le_nhds_iff [T1Space X] {a b : X} : 𝓝 a ≤ 𝓝 b ↔ a = b := specializes_iff_eq instance (priority := 100) [T1Space X] : R0Space X := (t1Space_iff_t0Space_and_r0Space.mp ‹T1Space X›).right instance : T1Space (CofiniteTopology X) := t1Space_iff_continuous_cofinite_of.mpr continuous_id instance (priority := 80) [T0Space X] [R0Space X] : T1Space X := t1Space_iff_t0Space_and_r0Space.mpr ⟨‹T0Space X›, ‹R0Space X›⟩ theorem t1Space_antitone {X} : Antitone (@T1Space X) := fun a _ h _ => @T1Space.mk _ a fun x => (T1Space.t1 x).mono h theorem continuousWithinAt_update_of_ne [T1Space X] [DecidableEq X] [TopologicalSpace Y] {f : X → Y} {s : Set X} {x x' : X} {y : Y} (hne : x' ≠ x) : ContinuousWithinAt (Function.update f x y) s x' ↔ ContinuousWithinAt f s x' := EventuallyEq.congr_continuousWithinAt (mem_nhdsWithin_of_mem_nhds <| mem_of_superset (isOpen_ne.mem_nhds hne) fun _y' hy' => Function.update_of_ne hy' _ _) (Function.update_of_ne hne ..) theorem continuousAt_update_of_ne [T1Space X] [DecidableEq X] [TopologicalSpace Y] {f : X → Y} {x x' : X} {y : Y} (hne : x' ≠ x) : ContinuousAt (Function.update f x y) x' ↔ ContinuousAt f x' := by simp only [← continuousWithinAt_univ, continuousWithinAt_update_of_ne hne] theorem continuousOn_update_iff [T1Space X] [DecidableEq X] [TopologicalSpace Y] {f : X → Y} {s : Set X} {x : X} {y : Y} : ContinuousOn (Function.update f x y) s ↔ ContinuousOn f (s \ {x}) ∧ (x ∈ s → Tendsto f (𝓝[s \ {x}] x) (𝓝 y)) := by rw [ContinuousOn, ← and_forall_ne x, and_comm] refine and_congr ⟨fun H z hz => ?_, fun H z hzx hzs => ?_⟩ (forall_congr' fun _ => ?_) · specialize H z hz.2 hz.1 rw [continuousWithinAt_update_of_ne hz.2] at H exact H.mono diff_subset · rw [continuousWithinAt_update_of_ne hzx] refine (H z ⟨hzs, hzx⟩).mono_of_mem_nhdsWithin (inter_mem_nhdsWithin _ ?_) exact isOpen_ne.mem_nhds hzx · exact continuousWithinAt_update_same theorem t1Space_of_injective_of_continuous [TopologicalSpace Y] {f : X → Y} (hf : Function.Injective f) (hf' : Continuous f) [T1Space Y] : T1Space X := t1Space_iff_specializes_imp_eq.2 fun _ _ h => hf (h.map hf').eq protected theorem Topology.IsEmbedding.t1Space [TopologicalSpace Y] [T1Space Y] {f : X → Y} (hf : IsEmbedding f) : T1Space X := t1Space_of_injective_of_continuous hf.injective hf.continuous protected theorem Homeomorph.t1Space [TopologicalSpace Y] [T1Space X] (h : X ≃ₜ Y) : T1Space Y := h.symm.isEmbedding.t1Space instance Subtype.t1Space {X : Type u} [TopologicalSpace X] [T1Space X] {p : X → Prop} : T1Space (Subtype p) := IsEmbedding.subtypeVal.t1Space instance [TopologicalSpace Y] [T1Space X] [T1Space Y] : T1Space (X × Y) := ⟨fun ⟨a, b⟩ => @singleton_prod_singleton _ _ a b ▸ isClosed_singleton.prod isClosed_singleton⟩ instance {ι : Type*} {X : ι → Type*} [∀ i, TopologicalSpace (X i)] [∀ i, T1Space (X i)] : T1Space (∀ i, X i) := ⟨fun f => univ_pi_singleton f ▸ isClosed_set_pi fun _ _ => isClosed_singleton⟩ instance ULift.instT1Space [T1Space X] : T1Space (ULift X) := IsEmbedding.uliftDown.t1Space -- see Note [lower instance priority] instance (priority := 100) T1Space.t0Space [T1Space X] : T0Space X := (t1Space_iff_t0Space_and_r0Space.mp ‹T1Space X›).left @[simp] theorem compl_singleton_mem_nhds_iff [T1Space X] {x y : X} : {x}ᶜ ∈ 𝓝 y ↔ y ≠ x := isOpen_compl_singleton.mem_nhds_iff theorem compl_singleton_mem_nhds [T1Space X] {x y : X} (h : y ≠ x) : {x}ᶜ ∈ 𝓝 y := compl_singleton_mem_nhds_iff.mpr h theorem closure_singleton [T1Space X] {x : X} : closure ({x} : Set X) = {x} := isClosed_singleton.closure_eq lemma Set.Subsingleton.isClosed [T1Space X] {s : Set X} (hs : s.Subsingleton) : IsClosed s := by rcases hs.eq_empty_or_singleton with rfl | ⟨x, rfl⟩ · exact isClosed_empty · exact isClosed_singleton theorem Set.Subsingleton.closure_eq [T1Space X] {s : Set X} (hs : s.Subsingleton) : closure s = s := hs.isClosed.closure_eq theorem Set.Subsingleton.closure [T1Space X] {s : Set X} (hs : s.Subsingleton) : (closure s).Subsingleton := by rwa [hs.closure_eq] @[simp] theorem subsingleton_closure [T1Space X] {s : Set X} : (closure s).Subsingleton ↔ s.Subsingleton := ⟨fun h => h.anti subset_closure, fun h => h.closure⟩ theorem isClosedMap_const {X Y} [TopologicalSpace X] [TopologicalSpace Y] [T1Space Y] {y : Y} : IsClosedMap (Function.const X y) := IsClosedMap.of_nonempty fun s _ h2s => by simp_rw [const, h2s.image_const, isClosed_singleton] lemma isClosedMap_prodMk_left [TopologicalSpace Y] [T1Space X] (x : X) : IsClosedMap (fun y : Y ↦ Prod.mk x y) := fun _K hK ↦ Set.singleton_prod ▸ isClosed_singleton.prod hK lemma isClosedMap_prodMk_right [TopologicalSpace Y] [T1Space Y] (y : Y) : IsClosedMap (fun x : X ↦ Prod.mk x y) := fun _K hK ↦ Set.prod_singleton ▸ hK.prod isClosed_singleton theorem nhdsWithin_insert_of_ne [T1Space X] {x y : X} {s : Set X} (hxy : x ≠ y) : 𝓝[insert y s] x = 𝓝[s] x := by refine le_antisymm (Filter.le_def.2 fun t ht => ?_) (nhdsWithin_mono x <| subset_insert y s) obtain ⟨o, ho, hxo, host⟩ := mem_nhdsWithin.mp ht refine mem_nhdsWithin.mpr ⟨o \ {y}, ho.sdiff isClosed_singleton, ⟨hxo, hxy⟩, ?_⟩ rw [inter_insert_of_notMem <| notMem_diff_of_mem (mem_singleton y)] exact (inter_subset_inter diff_subset Subset.rfl).trans host /-- If `t` is a subset of `s`, except for one point, then `insert x s` is a neighborhood of `x` within `t`. -/ theorem insert_mem_nhdsWithin_of_subset_insert [T1Space X] {x y : X} {s t : Set X} (hu : t ⊆ insert y s) : insert x s ∈ 𝓝[t] x := by rcases eq_or_ne x y with (rfl | h) · exact mem_of_superset self_mem_nhdsWithin hu refine nhdsWithin_mono x hu ?_ rw [nhdsWithin_insert_of_ne h] exact mem_of_superset self_mem_nhdsWithin (subset_insert x s) lemma eventuallyEq_insert [T1Space X] {s t : Set X} {x y : X} (h : s =ᶠ[𝓝[{y}ᶜ] x] t) : (insert x s : Set X) =ᶠ[𝓝 x] (insert x t : Set X) := by simp_rw [eventuallyEq_set] at h ⊢ simp_rw [← union_singleton, ← nhdsWithin_univ, ← compl_union_self {x}, nhdsWithin_union, eventually_sup, nhdsWithin_singleton, eventually_pure, union_singleton, mem_insert_iff, true_or, and_true] filter_upwards [nhdsWithin_compl_singleton_le x y h] with y using or_congr (Iff.rfl) @[simp] theorem ker_nhds [T1Space X] (x : X) : (𝓝 x).ker = {x} := by simp [ker_nhds_eq_specializes] theorem biInter_basis_nhds [T1Space X] {ι : Sort*} {p : ι → Prop} {s : ι → Set X} {x : X} (h : (𝓝 x).HasBasis p s) : ⋂ (i) (_ : p i), s i = {x} := by rw [← h.ker, ker_nhds] @[simp] theorem compl_singleton_mem_nhdsSet_iff [T1Space X] {x : X} {s : Set X} : {x}ᶜ ∈ 𝓝ˢ s ↔ x ∉ s := by rw [isOpen_compl_singleton.mem_nhdsSet, subset_compl_singleton_iff] @[simp] theorem nhdsSet_le_iff [T1Space X] {s t : Set X} : 𝓝ˢ s ≤ 𝓝ˢ t ↔ s ⊆ t := by refine ⟨?_, fun h => monotone_nhdsSet h⟩ simp_rw [Filter.le_def]; intro h x hx specialize h {x}ᶜ simp_rw [compl_singleton_mem_nhdsSet_iff] at h by_contra hxt exact h hxt hx @[simp] theorem nhdsSet_inj_iff [T1Space X] {s t : Set X} : 𝓝ˢ s = 𝓝ˢ t ↔ s = t := by simp_rw [le_antisymm_iff] exact and_congr nhdsSet_le_iff nhdsSet_le_iff theorem injective_nhdsSet [T1Space X] : Function.Injective (𝓝ˢ : Set X → Filter X) := fun _ _ hst => nhdsSet_inj_iff.mp hst theorem strictMono_nhdsSet [T1Space X] : StrictMono (𝓝ˢ : Set X → Filter X) := monotone_nhdsSet.strictMono_of_injective injective_nhdsSet @[simp] theorem nhds_le_nhdsSet_iff [T1Space X] {s : Set X} {x : X} : 𝓝 x ≤ 𝓝ˢ s ↔ x ∈ s := by rw [← nhdsSet_singleton, nhdsSet_le_iff, singleton_subset_iff] /-- Removing a non-isolated point from a dense set, one still obtains a dense set. -/ theorem Dense.diff_singleton [T1Space X] {s : Set X} (hs : Dense s) (x : X) [NeBot (𝓝[≠] x)] : Dense (s \ {x}) := hs.inter_of_isOpen_right (dense_compl_singleton x) isOpen_compl_singleton /-- Removing a finset from a dense set in a space without isolated points, one still obtains a dense set. -/ theorem Dense.diff_finset [T1Space X] [∀ x : X, NeBot (𝓝[≠] x)] {s : Set X} (hs : Dense s) (t : Finset X) : Dense (s \ t) := by classical induction t using Finset.induction_on with | empty => simpa using hs | insert _ _ _ ih => rw [Finset.coe_insert, ← union_singleton, ← diff_diff] exact ih.diff_singleton _ /-- Removing a finite set from a dense set in a space without isolated points, one still obtains a dense set. -/ theorem Dense.diff_finite [T1Space X] [∀ x : X, NeBot (𝓝[≠] x)] {s : Set X} (hs : Dense s) {t : Set X} (ht : t.Finite) : Dense (s \ t) := by convert hs.diff_finset ht.toFinset exact (Finite.coe_toFinset _).symm /-- If a function to a `T1Space` tends to some limit `y` at some point `x`, then necessarily `y = f x`. -/ theorem eq_of_tendsto_nhds [TopologicalSpace Y] [T1Space Y] {f : X → Y} {x : X} {y : Y} (h : Tendsto f (𝓝 x) (𝓝 y)) : f x = y := by_contra fun hfa : f x ≠ y => have fact₁ : {f x}ᶜ ∈ 𝓝 y := compl_singleton_mem_nhds hfa.symm have fact₂ : Tendsto f (pure x) (𝓝 y) := h.comp (tendsto_id'.2 <| pure_le_nhds x) fact₂ fact₁ (Eq.refl <| f x) theorem Filter.Tendsto.eventually_ne {X} [TopologicalSpace Y] [T1Space Y] {g : X → Y} {l : Filter X} {b₁ b₂ : Y} (hg : Tendsto g l (𝓝 b₁)) (hb : b₁ ≠ b₂) : ∀ᶠ z in l, g z ≠ b₂ := hg.eventually (isOpen_compl_singleton.eventually_mem hb) theorem ContinuousAt.eventually_ne [TopologicalSpace Y] [T1Space Y] {g : X → Y} {x : X} {y : Y} (hg1 : ContinuousAt g x) (hg2 : g x ≠ y) : ∀ᶠ z in 𝓝 x, g z ≠ y := hg1.tendsto.eventually_ne hg2 theorem eventually_ne_nhds [T1Space X] {a b : X} (h : a ≠ b) : ∀ᶠ x in 𝓝 a, x ≠ b := IsOpen.eventually_mem isOpen_ne h theorem eventually_ne_nhdsWithin [T1Space X] {a b : X} {s : Set X} (h : a ≠ b) : ∀ᶠ x in 𝓝[s] a, x ≠ b := Filter.Eventually.filter_mono nhdsWithin_le_nhds <| eventually_ne_nhds h theorem continuousWithinAt_insert [TopologicalSpace Y] [T1Space X] {x y : X} {s : Set X} {f : X → Y} : ContinuousWithinAt f (insert y s) x ↔ ContinuousWithinAt f s x := by rcases eq_or_ne x y with (rfl | h) · exact continuousWithinAt_insert_self simp_rw [ContinuousWithinAt, nhdsWithin_insert_of_ne h] alias ⟨ContinuousWithinAt.of_insert, ContinuousWithinAt.insert'⟩ := continuousWithinAt_insert /-- See also `continuousWithinAt_diff_self` for the case `y = x` but not requiring `T1Space`. -/ theorem continuousWithinAt_diff_singleton [TopologicalSpace Y] [T1Space X] {x y : X} {s : Set X} {f : X → Y} : ContinuousWithinAt f (s \ {y}) x ↔ ContinuousWithinAt f s x := by rw [← continuousWithinAt_insert, insert_diff_singleton, continuousWithinAt_insert] /-- If two sets coincide locally around `x`, except maybe at `y`, then it is equivalent to be continuous at `x` within one set or the other. -/ theorem continuousWithinAt_congr_set' [TopologicalSpace Y] [T1Space X] {x : X} {s t : Set X} {f : X → Y} (y : X) (h : s =ᶠ[𝓝[{y}ᶜ] x] t) : ContinuousWithinAt f s x ↔ ContinuousWithinAt f t x := by rw [← continuousWithinAt_insert_self (s := s), ← continuousWithinAt_insert_self (s := t)] exact continuousWithinAt_congr_set (eventuallyEq_insert h) theorem ContinuousWithinAt.eq_const_of_mem_closure [TopologicalSpace Y] [T1Space Y] {f : X → Y} {s : Set X} {x : X} {c : Y} (h : ContinuousWithinAt f s x) (hx : x ∈ closure s) (ht : ∀ y ∈ s, f y = c) : f x = c := by rw [← Set.mem_singleton_iff, ← closure_singleton] exact h.mem_closure hx ht @[deprecated (since := "2025-08-22")] alias ContinousWithinAt.eq_const_of_mem_closure := ContinuousWithinAt.eq_const_of_mem_closure theorem ContinuousWithinAt.eqOn_const_closure [TopologicalSpace Y] [T1Space Y] {f : X → Y} {s : Set X} {c : Y} (h : ∀ x ∈ closure s, ContinuousWithinAt f s x) (ht : s.EqOn f (fun _ ↦ c)) : (closure s).EqOn f (fun _ ↦ c) := by intro x hx apply ContinuousWithinAt.eq_const_of_mem_closure (h x hx) hx ht /-- To prove a function to a `T1Space` is continuous at some point `x`, it suffices to prove that `f` admits *some* limit at `x`. -/ theorem continuousAt_of_tendsto_nhds [TopologicalSpace Y] [T1Space Y] {f : X → Y} {x : X} {y : Y} (h : Tendsto f (𝓝 x) (𝓝 y)) : ContinuousAt f x := by rwa [ContinuousAt, eq_of_tendsto_nhds h] @[simp] theorem tendsto_const_nhds_iff [T1Space X] {l : Filter Y} [NeBot l] {c d : X} : Tendsto (fun _ => c) l (𝓝 d) ↔ c = d := by simp_rw [Tendsto, Filter.map_const, pure_le_nhds_iff] /-- A point with a finite neighborhood has to be isolated. -/ theorem isOpen_singleton_of_finite_mem_nhds [T1Space X] (x : X) {s : Set X} (hs : s ∈ 𝓝 x) (hsf : s.Finite) : IsOpen ({x} : Set X) := by have A : {x} ⊆ s := by simp only [singleton_subset_iff, mem_of_mem_nhds hs] have B : IsClosed (s \ {x}) := (hsf.subset diff_subset).isClosed have C : (s \ {x})ᶜ ∈ 𝓝 x := B.isOpen_compl.mem_nhds fun h => h.2 rfl have D : {x} ∈ 𝓝 x := by simpa only [← diff_eq, diff_diff_cancel_left A] using inter_mem hs C rwa [← mem_interior_iff_mem_nhds, ← singleton_subset_iff, subset_interior_iff_isOpen] at D /-- If the punctured neighborhoods of a point form a nontrivial filter, then any neighborhood is infinite. -/ theorem infinite_of_mem_nhds {X} [TopologicalSpace X] [T1Space X] (x : X) [hx : NeBot (𝓝[≠] x)] {s : Set X} (hs : s ∈ 𝓝 x) : Set.Infinite s := by refine fun hsf => hx.1 ?_ rw [← isOpen_singleton_iff_punctured_nhds] exact isOpen_singleton_of_finite_mem_nhds x hs hsf instance Finite.instDiscreteTopology [T1Space X] [Finite X] : DiscreteTopology X := discreteTopology_iff_forall_isClosed.mpr (· |>.toFinite.isClosed) theorem Set.Finite.continuousOn [T1Space X] [TopologicalSpace Y] {s : Set X} (hs : s.Finite) (f : X → Y) : ContinuousOn f s := by rw [continuousOn_iff_continuous_restrict] have : Finite s := hs fun_prop theorem SeparationQuotient.t1Space_iff : T1Space (SeparationQuotient X) ↔ R0Space X := by rw [r0Space_iff, ((t1Space_TFAE (SeparationQuotient X)).out 0 9 :)] constructor · intro h x y xspecy rw [← IsInducing.specializes_iff isInducing_mk, h xspecy] at * · -- TODO is there are better way to do this, -- so the case split produces `SeparationQuotient.mk` directly, rather than `Quot.mk`? -- Currently we need the `change` statement to recover this. rintro h ⟨x⟩ ⟨y⟩ sxspecsy change mk _ = mk _ have xspecy : x ⤳ y := isInducing_mk.specializes_iff.mp sxspecsy have yspecx : y ⤳ x := h xspecy rw [mk_eq_mk, inseparable_iff_specializes_and] exact ⟨xspecy, yspecx⟩ lemma isClosed_inter_singleton [T1Space X] {A : Set X} {a : X} : IsClosed (A ∩ {a}) := Subsingleton.inter_singleton.isClosed lemma isClosed_singleton_inter [T1Space X] {A : Set X} {a : X} : IsClosed ({a} ∩ A) := Subsingleton.singleton_inter.isClosed theorem singleton_mem_nhdsWithin_of_mem_discrete {s : Set X} [DiscreteTopology s] {x : X} (hx : x ∈ s) : {x} ∈ 𝓝[s] x := by have : ({⟨x, hx⟩} : Set s) ∈ 𝓝 (⟨x, hx⟩ : s) := by simp [nhds_discrete] simpa only [nhdsWithin_eq_map_subtype_coe hx, image_singleton] using @image_mem_map _ _ _ ((↑) : s → X) _ this /-- The neighbourhoods filter of `x` within `s`, under the discrete topology, is equal to the pure `x` filter (which is the principal filter at the singleton `{x}`.) -/ theorem nhdsWithin_of_mem_discrete {s : Set X} [DiscreteTopology s] {x : X} (hx : x ∈ s) : 𝓝[s] x = pure x := le_antisymm (le_pure_iff.2 <| singleton_mem_nhdsWithin_of_mem_discrete hx) (pure_le_nhdsWithin hx) theorem Filter.HasBasis.exists_inter_eq_singleton_of_mem_discrete {ι : Type*} {p : ι → Prop} {t : ι → Set X} {s : Set X} [DiscreteTopology s] {x : X} (hb : (𝓝 x).HasBasis p t) (hx : x ∈ s) : ∃ i, p i ∧ t i ∩ s = {x} := by rcases (nhdsWithin_hasBasis hb s).mem_iff.1 (singleton_mem_nhdsWithin_of_mem_discrete hx) with ⟨i, hi, hix⟩ exact ⟨i, hi, hix.antisymm <| singleton_subset_iff.2 ⟨mem_of_mem_nhds <| hb.mem_of_mem hi, hx⟩⟩ /-- A point `x` in a discrete subset `s` of a topological space admits a neighbourhood that only meets `s` at `x`. -/ theorem nhds_inter_eq_singleton_of_mem_discrete {s : Set X} [DiscreteTopology s] {x : X} (hx : x ∈ s) : ∃ U ∈ 𝓝 x, U ∩ s = {x} := by simpa using (𝓝 x).basis_sets.exists_inter_eq_singleton_of_mem_discrete hx /-- Let `x` be a point in a discrete subset `s` of a topological space, then there exists an open set that only meets `s` at `x`. -/ theorem isOpen_inter_eq_singleton_of_mem_discrete {s : Set X} [DiscreteTopology s] {x : X} (hx : x ∈ s) : ∃ U : Set X, IsOpen U ∧ U ∩ s = {x} := by obtain ⟨U, hU_nhds, hU_inter⟩ := nhds_inter_eq_singleton_of_mem_discrete hx obtain ⟨t, ht_sub, ht_open, ht_x⟩ := mem_nhds_iff.mp hU_nhds refine ⟨t, ht_open, Set.Subset.antisymm ?_ ?_⟩ · exact hU_inter ▸ Set.inter_subset_inter_left s ht_sub · rw [Set.subset_inter_iff, Set.singleton_subset_iff, Set.singleton_subset_iff] exact ⟨ht_x, hx⟩ /-- For point `x` in a discrete subset `s` of a topological space, there is a set `U` such that 1. `U` is a punctured neighborhood of `x` (i.e. `U ∪ {x}` is a neighbourhood of `x`), 2. `U` is disjoint from `s`. -/ theorem disjoint_nhdsWithin_of_mem_discrete {s : Set X} [DiscreteTopology s] {x : X} (hx : x ∈ s) : ∃ U ∈ 𝓝[≠] x, Disjoint U s := let ⟨V, h, h'⟩ := nhds_inter_eq_singleton_of_mem_discrete hx ⟨{x}ᶜ ∩ V, inter_mem_nhdsWithin _ h, disjoint_iff_inter_eq_empty.mpr (by rw [inter_assoc, h', compl_inter_self])⟩ theorem isClosedEmbedding_update {ι : Type*} {β : ι → Type*} [DecidableEq ι] [(i : ι) → TopologicalSpace (β i)] (x : (i : ι) → β i) (i : ι) [(i : ι) → T1Space (β i)] : IsClosedEmbedding (update x i) := by refine .of_continuous_injective_isClosedMap (continuous_const.update i continuous_id) (update_injective x i) fun s hs ↦ ?_ rw [update_image] apply isClosed_set_pi simp [forall_update_iff, hs] lemma nhdsNE_le_cofinite {α : Type*} [TopologicalSpace α] [T1Space α] (a : α) : 𝓝[≠] a ≤ cofinite := by refine le_cofinite_iff_compl_singleton_mem.mpr fun x ↦ ?_ rcases eq_or_ne a x with rfl | hx exacts [self_mem_nhdsWithin, eventually_ne_nhdsWithin hx] lemma Function.update_eventuallyEq_nhdsNE {α β : Type*} [TopologicalSpace α] [T1Space α] [DecidableEq α] (f : α → β) (a a' : α) (b : β) : Function.update f a b =ᶠ[𝓝[≠] a'] f := (Function.update_eventuallyEq_cofinite f a b).filter_mono (nhdsNE_le_cofinite a') /-! ### R₁ (preregular) spaces -/ section R1Space /-- A topological space is called a *preregular* (a.k.a. R₁) space, if any two topologically distinguishable points have disjoint neighbourhoods. -/ @[mk_iff r1Space_iff_specializes_or_disjoint_nhds] class R1Space (X : Type*) [TopologicalSpace X] : Prop where specializes_or_disjoint_nhds (x y : X) : Specializes x y ∨ Disjoint (𝓝 x) (𝓝 y) export R1Space (specializes_or_disjoint_nhds) variable [R1Space X] {x y : X} instance (priority := 100) : R0Space X where specializes_symmetric _ _ h := (specializes_or_disjoint_nhds _ _).resolve_right <| fun hd ↦ h.not_disjoint hd.symm theorem disjoint_nhds_nhds_iff_not_specializes : Disjoint (𝓝 x) (𝓝 y) ↔ ¬x ⤳ y := ⟨fun hd hspec ↦ hspec.not_disjoint hd, (specializes_or_disjoint_nhds _ _).resolve_left⟩ theorem specializes_iff_not_disjoint : x ⤳ y ↔ ¬Disjoint (𝓝 x) (𝓝 y) := disjoint_nhds_nhds_iff_not_specializes.not_left.symm theorem disjoint_nhds_nhds_iff_not_inseparable : Disjoint (𝓝 x) (𝓝 y) ↔ ¬Inseparable x y := by rw [disjoint_nhds_nhds_iff_not_specializes, specializes_iff_inseparable] theorem r1Space_iff_inseparable_or_disjoint_nhds {X : Type*} [TopologicalSpace X] : R1Space X ↔ ∀ x y : X, Inseparable x y ∨ Disjoint (𝓝 x) (𝓝 y) := ⟨fun _h x y ↦ (specializes_or_disjoint_nhds x y).imp_left Specializes.inseparable, fun h ↦ ⟨fun x y ↦ (h x y).imp_left Inseparable.specializes⟩⟩ theorem Inseparable.of_nhds_neBot {x y : X} (h : NeBot (𝓝 x ⊓ 𝓝 y)) : Inseparable x y := (r1Space_iff_inseparable_or_disjoint_nhds.mp ‹_› _ _).resolve_right fun h' => h.ne h'.eq_bot theorem r1_separation {x y : X} (h : ¬Inseparable x y) : ∃ u v : Set X, IsOpen u ∧ IsOpen v ∧ x ∈ u ∧ y ∈ v ∧ Disjoint u v := by rw [← disjoint_nhds_nhds_iff_not_inseparable, (nhds_basis_opens x).disjoint_iff (nhds_basis_opens y)] at h obtain ⟨u, ⟨hxu, hu⟩, v, ⟨hyv, hv⟩, huv⟩ := h exact ⟨u, v, hu, hv, hxu, hyv, huv⟩ /-- Limits are unique up to separability. A weaker version of `tendsto_nhds_unique` for `R1Space`. -/ theorem tendsto_nhds_unique_inseparable {f : Y → X} {l : Filter Y} {a b : X} [NeBot l] (ha : Tendsto f l (𝓝 a)) (hb : Tendsto f l (𝓝 b)) : Inseparable a b := .of_nhds_neBot <| neBot_of_le <| le_inf ha hb theorem isClosed_setOf_specializes : IsClosed { p : X × X | p.1 ⤳ p.2 } := by simp only [← isOpen_compl_iff, compl_setOf, ← disjoint_nhds_nhds_iff_not_specializes, isOpen_setOf_disjoint_nhds_nhds] theorem isClosed_setOf_inseparable : IsClosed { p : X × X | Inseparable p.1 p.2 } := by simp only [← specializes_iff_inseparable, isClosed_setOf_specializes] /-- In an R₁ space, a point belongs to the closure of a compact set `K` if and only if it is topologically inseparable from some point of `K`. -/ theorem IsCompact.mem_closure_iff_exists_inseparable {K : Set X} (hK : IsCompact K) : y ∈ closure K ↔ ∃ x ∈ K, Inseparable x y := by refine ⟨fun hy ↦ ?_, fun ⟨x, hxK, hxy⟩ ↦ (hxy.mem_closed_iff isClosed_closure).1 <| subset_closure hxK⟩ contrapose! hy have : Disjoint (𝓝 y) (𝓝ˢ K) := hK.disjoint_nhdsSet_right.2 fun x hx ↦ (disjoint_nhds_nhds_iff_not_inseparable.2 (hy x hx)).symm simpa only [disjoint_iff, notMem_closure_iff_nhdsWithin_eq_bot] using this.mono_right principal_le_nhdsSet theorem IsCompact.closure_eq_biUnion_inseparable {K : Set X} (hK : IsCompact K) : closure K = ⋃ x ∈ K, {y | Inseparable x y} := by ext; simp [hK.mem_closure_iff_exists_inseparable] /-- In an R₁ space, the closure of a compact set is the union of the closures of its points. -/ theorem IsCompact.closure_eq_biUnion_closure_singleton {K : Set X} (hK : IsCompact K) : closure K = ⋃ x ∈ K, closure {x} := by simp only [hK.closure_eq_biUnion_inseparable, ← specializes_iff_inseparable, specializes_iff_mem_closure, setOf_mem_eq] /-- In an R₁ space, if a compact set `K` is contained in an open set `U`, then its closure is also contained in `U`. -/ theorem IsCompact.closure_subset_of_isOpen {K : Set X} (hK : IsCompact K) {U : Set X} (hU : IsOpen U) (hKU : K ⊆ U) : closure K ⊆ U := by rw [hK.closure_eq_biUnion_inseparable, iUnion₂_subset_iff] exact fun x hx y hxy ↦ (hxy.mem_open_iff hU).1 (hKU hx) /-- The closure of a compact set in an R₁ space is a compact set. -/ protected theorem IsCompact.closure {K : Set X} (hK : IsCompact K) : IsCompact (closure K) := by refine isCompact_of_finite_subcover fun U hUo hKU ↦ ?_ rcases hK.elim_finite_subcover U hUo (subset_closure.trans hKU) with ⟨t, ht⟩ exact ⟨t, hK.closure_subset_of_isOpen (isOpen_biUnion fun _ _ ↦ hUo _) ht⟩ theorem IsCompact.closure_of_subset {s K : Set X} (hK : IsCompact K) (h : s ⊆ K) : IsCompact (closure s) := hK.closure.of_isClosed_subset isClosed_closure (closure_mono h) @[simp] theorem exists_isCompact_superset_iff {s : Set X} : (∃ K, IsCompact K ∧ s ⊆ K) ↔ IsCompact (closure s) := ⟨fun ⟨_K, hK, hsK⟩ => hK.closure_of_subset hsK, fun h => ⟨closure s, h, subset_closure⟩⟩ /-- If `K` and `L` are disjoint compact sets in an R₁ topological space and `L` is also closed, then `K` and `L` have disjoint neighborhoods. -/ theorem SeparatedNhds.of_isCompact_isCompact_isClosed {K L : Set X} (hK : IsCompact K) (hL : IsCompact L) (h'L : IsClosed L) (hd : Disjoint K L) : SeparatedNhds K L := by simp_rw [separatedNhds_iff_disjoint, hK.disjoint_nhdsSet_left, hL.disjoint_nhdsSet_right, disjoint_nhds_nhds_iff_not_inseparable] intro x hx y hy h exact absurd ((h.mem_closed_iff h'L).2 hy) <| disjoint_left.1 hd hx /-- If a compact set is covered by two open sets, then we can cover it by two compact subsets. -/ theorem IsCompact.binary_compact_cover {K U V : Set X} (hK : IsCompact K) (hU : IsOpen U) (hV : IsOpen V) (h2K : K ⊆ U ∪ V) : ∃ K₁ K₂ : Set X, IsCompact K₁ ∧ IsCompact K₂ ∧ K₁ ⊆ U ∧ K₂ ⊆ V ∧ K = K₁ ∪ K₂ := by have hK' : IsCompact (closure K) := hK.closure have : SeparatedNhds (closure K \ U) (closure K \ V) := by apply SeparatedNhds.of_isCompact_isCompact_isClosed (hK'.diff hU) (hK'.diff hV) (isClosed_closure.sdiff hV) rw [disjoint_iff_inter_eq_empty, diff_inter_diff, diff_eq_empty] exact hK.closure_subset_of_isOpen (hU.union hV) h2K have : SeparatedNhds (K \ U) (K \ V) := this.mono (diff_subset_diff_left (subset_closure)) (diff_subset_diff_left (subset_closure)) rcases this with ⟨O₁, O₂, h1O₁, h1O₂, h2O₁, h2O₂, hO⟩ exact ⟨K \ O₁, K \ O₂, hK.diff h1O₁, hK.diff h1O₂, diff_subset_comm.mp h2O₁, diff_subset_comm.mp h2O₂, by rw [← diff_inter, hO.inter_eq, diff_empty]⟩ /-- For every finite open cover `Uᵢ` of a compact set, there exists a compact cover `Kᵢ ⊆ Uᵢ`. -/ theorem IsCompact.finite_compact_cover {s : Set X} (hs : IsCompact s) {ι : Type*} (t : Finset ι) (U : ι → Set X) (hU : ∀ i ∈ t, IsOpen (U i)) (hsC : s ⊆ ⋃ i ∈ t, U i) : ∃ K : ι → Set X, (∀ i, IsCompact (K i)) ∧ (∀ i, K i ⊆ U i) ∧ s = ⋃ i ∈ t, K i := by classical induction t using Finset.induction generalizing U s with | empty => refine ⟨fun _ => ∅, fun _ => isCompact_empty, fun i => empty_subset _, ?_⟩ simpa only [subset_empty_iff, Finset.notMem_empty, iUnion_false, iUnion_empty] using hsC | insert x t hx ih => simp only [Finset.set_biUnion_insert] at hsC simp only [Finset.forall_mem_insert] at hU have hU' : ∀ i ∈ t, IsOpen (U i) := fun i hi => hU.2 i hi rcases hs.binary_compact_cover hU.1 (isOpen_biUnion hU') hsC with ⟨K₁, K₂, h1K₁, h1K₂, h2K₁, h2K₂, hK⟩ rcases ih h1K₂ U hU' h2K₂ with ⟨K, h1K, h2K, h3K⟩ refine ⟨update K x K₁, ?_, ?_, ?_⟩ · intro i rcases eq_or_ne i x with rfl | hi · simp only [update_self, h1K₁] · simp only [update_of_ne hi, h1K] · intro i rcases eq_or_ne i x with rfl | hi · simp only [update_self, h2K₁] · simp only [update_of_ne hi, h2K] · simp only [Finset.set_biUnion_insert_update _ hx, hK, h3K] theorem R1Space.of_continuous_specializes_imp [TopologicalSpace Y] {f : Y → X} (hc : Continuous f) (hspec : ∀ x y, f x ⤳ f y → x ⤳ y) : R1Space Y where specializes_or_disjoint_nhds x y := (specializes_or_disjoint_nhds (f x) (f y)).imp (hspec x y) <| ((hc.tendsto _).disjoint · (hc.tendsto _)) theorem Topology.IsInducing.r1Space [TopologicalSpace Y] {f : Y → X} (hf : IsInducing f) : R1Space Y := .of_continuous_specializes_imp hf.continuous fun _ _ ↦ hf.specializes_iff.1 protected theorem R1Space.induced (f : Y → X) : @R1Space Y (.induced f ‹_›) := @IsInducing.r1Space _ _ _ _ (.induced f _) f (.induced f) instance (p : X → Prop) : R1Space (Subtype p) := .induced _ protected theorem R1Space.sInf {X : Type*} {T : Set (TopologicalSpace X)} (hT : ∀ t ∈ T, @R1Space X t) : @R1Space X (sInf T) := by let _ := sInf T refine ⟨fun x y ↦ ?_⟩ simp only [Specializes, nhds_sInf] by_cases! hTd : ∃ t ∈ T, Disjoint (@nhds X t x) (@nhds X t y) · rcases hTd with ⟨t, htT, htd⟩ exact .inr <| htd.mono (iInf₂_le t htT) (iInf₂_le t htT) · exact .inl <| iInf₂_mono fun t ht ↦ ((hT t ht).1 x y).resolve_right (hTd t ht) protected theorem R1Space.iInf {ι X : Type*} {t : ι → TopologicalSpace X} (ht : ∀ i, @R1Space X (t i)) : @R1Space X (iInf t) := .sInf <| forall_mem_range.2 ht protected theorem R1Space.inf {X : Type*} {t₁ t₂ : TopologicalSpace X} (h₁ : @R1Space X t₁) (h₂ : @R1Space X t₂) : @R1Space X (t₁ ⊓ t₂) := by rw [inf_eq_iInf] apply R1Space.iInf simp [*] instance [TopologicalSpace Y] [R1Space Y] : R1Space (X × Y) := .inf (.induced _) (.induced _) instance {ι : Type*} {X : ι → Type*} [∀ i, TopologicalSpace (X i)] [∀ i, R1Space (X i)] : R1Space (∀ i, X i) := .iInf fun _ ↦ .induced _ theorem exists_mem_nhds_isCompact_mapsTo_of_isCompact_mem_nhds {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] [R1Space Y] {f : X → Y} {x : X} {K : Set X} {s : Set Y} (hf : Continuous f) (hs : s ∈ 𝓝 (f x)) (hKc : IsCompact K) (hKx : K ∈ 𝓝 x) : ∃ L ∈ 𝓝 x, IsCompact L ∧ MapsTo f L s := by have hc : IsCompact (f '' K \ interior s) := (hKc.image hf).diff isOpen_interior obtain ⟨U, V, Uo, Vo, hxU, hV, hd⟩ : SeparatedNhds {f x} (f '' K \ interior s) := by simp_rw [separatedNhds_iff_disjoint, nhdsSet_singleton, hc.disjoint_nhdsSet_right, disjoint_nhds_nhds_iff_not_inseparable] rintro y ⟨-, hys⟩ hxy refine hys <| (hxy.mem_open_iff isOpen_interior).1 ?_ rwa [mem_interior_iff_mem_nhds] refine ⟨K \ f ⁻¹' V, diff_mem hKx ?_, hKc.diff <| Vo.preimage hf, fun y hy ↦ ?_⟩ · filter_upwards [hf.continuousAt <| Uo.mem_nhds (hxU rfl)] with x hx using Set.disjoint_left.1 hd hx · by_contra hys exact hy.2 (hV ⟨mem_image_of_mem _ hy.1, notMem_subset interior_subset hys⟩) instance (priority := 900) {X Y : Type*} [TopologicalSpace X] [WeaklyLocallyCompactSpace X] [TopologicalSpace Y] [R1Space Y] : LocallyCompactPair X Y where exists_mem_nhds_isCompact_mapsTo hf hs := let ⟨_K, hKc, hKx⟩ := exists_compact_mem_nhds _ exists_mem_nhds_isCompact_mapsTo_of_isCompact_mem_nhds hf hs hKc hKx /-- If a point in an R₁ space has a compact neighborhood, then it has a basis of compact closed neighborhoods. -/ theorem IsCompact.isCompact_isClosed_basis_nhds {x : X} {L : Set X} (hLc : IsCompact L) (hxL : L ∈ 𝓝 x) : (𝓝 x).HasBasis (fun K ↦ K ∈ 𝓝 x ∧ IsCompact K ∧ IsClosed K) (·) := hasBasis_self.2 fun _U hU ↦ let ⟨K, hKx, hKc, hKU⟩ := exists_mem_nhds_isCompact_mapsTo_of_isCompact_mem_nhds continuous_id (interior_mem_nhds.2 hU) hLc hxL ⟨closure K, mem_of_superset hKx subset_closure, ⟨hKc.closure, isClosed_closure⟩, (hKc.closure_subset_of_isOpen isOpen_interior hKU).trans interior_subset⟩ /-- In an R₁ space, the filters `coclosedCompact` and `cocompact` are equal. -/ @[simp] theorem Filter.coclosedCompact_eq_cocompact : coclosedCompact X = cocompact X := by refine le_antisymm ?_ cocompact_le_coclosedCompact rw [hasBasis_coclosedCompact.le_basis_iff hasBasis_cocompact] exact fun K hK ↦ ⟨closure K, ⟨isClosed_closure, hK.closure⟩, compl_subset_compl.2 subset_closure⟩ /-- In an R₁ space, the bornologies `relativelyCompact` and `inCompact` are equal. -/ @[simp] theorem Bornology.relativelyCompact_eq_inCompact : Bornology.relativelyCompact X = Bornology.inCompact X := Bornology.ext _ _ Filter.coclosedCompact_eq_cocompact /-! ### Lemmas about a weakly locally compact R₁ space In fact, a space with these properties is locally compact and regular. Some lemmas are formulated using the latter assumptions below. -/ variable [WeaklyLocallyCompactSpace X] /-- In a (weakly) locally compact R₁ space, compact closed neighborhoods of a point `x` form a basis of neighborhoods of `x`. -/ theorem isCompact_isClosed_basis_nhds (x : X) : (𝓝 x).HasBasis (fun K => K ∈ 𝓝 x ∧ IsCompact K ∧ IsClosed K) (·) := let ⟨_L, hLc, hLx⟩ := exists_compact_mem_nhds x hLc.isCompact_isClosed_basis_nhds hLx /-- In a (weakly) locally compact R₁ space, each point admits a compact closed neighborhood. -/ theorem exists_mem_nhds_isCompact_isClosed (x : X) : ∃ K ∈ 𝓝 x, IsCompact K ∧ IsClosed K := (isCompact_isClosed_basis_nhds x).ex_mem -- see Note [lower instance priority] /-- A weakly locally compact R₁ space is locally compact. -/ instance (priority := 80) WeaklyLocallyCompactSpace.locallyCompactSpace : LocallyCompactSpace X := .of_hasBasis isCompact_isClosed_basis_nhds fun _ _ ⟨_, h, _⟩ ↦ h /-- In a weakly locally compact R₁ space, every compact set has an open neighborhood with compact closure. -/ theorem exists_isOpen_superset_and_isCompact_closure {K : Set X} (hK : IsCompact K) : ∃ V, IsOpen V ∧ K ⊆ V ∧ IsCompact (closure V) := by rcases exists_compact_superset hK with ⟨K', hK', hKK'⟩ exact ⟨interior K', isOpen_interior, hKK', hK'.closure_of_subset interior_subset⟩ /-- In a weakly locally compact R₁ space, every point has an open neighborhood with compact closure. -/ theorem exists_isOpen_mem_isCompact_closure (x : X) : ∃ U : Set X, IsOpen U ∧ x ∈ U ∧ IsCompact (closure U) := by simpa only [singleton_subset_iff] using exists_isOpen_superset_and_isCompact_closure isCompact_singleton end R1Space end Separation
.lake/packages/mathlib/Mathlib/Topology/Separation/AlexandrovDiscrete.lean
import Mathlib.Topology.Separation.Basic import Mathlib.Topology.AlexandrovDiscrete /-! # T1 Alexandrov-discrete topology is discrete -/ open Filter variable {X : Type*} [TopologicalSpace X] @[simp] lemma nhdsKer_eq_of_t1Space [T1Space X] (s : Set X) : nhdsKer s = s := by ext; simp [mem_nhdsKer_iff_specializes] instance (priority := low) [AlexandrovDiscrete X] [T1Space X] : DiscreteTopology X := by simp [discreteTopology_iff_nhds, ← principal_nhdsKer_singleton]
.lake/packages/mathlib/Mathlib/Topology/Separation/Hausdorff.lean
import Mathlib.Topology.Compactness.SigmaCompact import Mathlib.Topology.Irreducible import Mathlib.Topology.Separation.Basic /-! # T₂ and T₂.₅ spaces. This file defines the T₂ (Hausdorff) condition, which is the most commonly-used among the various separation axioms, and the related T₂.₅ condition. ## Main definitions * `T2Space`: A T₂/Hausdorff space is a space where, for every two points `x ≠ y`, there is two disjoint open sets, one containing `x`, and the other `y`. T₂ implies T₁ and R₁. * `T25Space`: A T₂.₅/Urysohn space is a space where, for every two points `x ≠ y`, there is two open sets, one containing `x`, and the other `y`, whose closures are disjoint. T₂.₅ implies T₂. See `Mathlib/Topology/Separation/Regular.lean` for regular, T₃, etc. spaces; and `Mathlib/Topology/Separation/GDelta.lean` for the definitions of `PerfectlyNormalSpace` and `T6Space`. Note that `mathlib` adopts the modern convention that `m ≤ n` if and only if `T_m → T_n`, but occasionally the literature swaps definitions for e.g. T₃ and regular. ## Main results ### T₂ spaces * `t2_iff_nhds`: A space is T₂ iff the neighbourhoods of distinct points generate the bottom filter. * `t2_iff_isClosed_diagonal`: A space is T₂ iff the `diagonal` of `X` (that is, the set of all points of the form `(a, a) : X × X`) is closed under the product topology. * `separatedNhds_of_finset_finset`: Any two disjoint finsets are `SeparatedNhds`. * Most topological constructions preserve Hausdorffness; these results are part of the typeclass inference system (e.g. `Topology.IsEmbedding.t2Space`) * `Set.EqOn.closure`: If two functions are equal on some set `s`, they are equal on its closure. * `IsCompact.isClosed`: All compact sets are closed. * `WeaklyLocallyCompactSpace.locallyCompactSpace`: If a topological space is both weakly locally compact (i.e., each point has a compact neighbourhood) and is T₂, then it is locally compact. * `totallySeparatedSpace_of_t1_of_basis_clopen`: If `X` has a clopen basis, then it is a `TotallySeparatedSpace`. * `loc_compact_t2_tot_disc_iff_tot_sep`: A locally compact T₂ space is totally disconnected iff it is totally separated. * `T2Quotient`: the largest T2 quotient of a given topological space. If the space is also compact: * `normalOfCompactT2`: A compact T₂ space is a `NormalSpace`. * `connectedComponent_eq_iInter_isClopen`: The connected component of a point is the intersection of all its clopen neighbourhoods. * `compact_t2_tot_disc_iff_tot_sep`: Being a `TotallyDisconnectedSpace` is equivalent to being a `TotallySeparatedSpace`. * `ConnectedComponents.t2`: `ConnectedComponents X` is T₂ for `X` T₂ and compact. ## References * <https://en.wikipedia.org/wiki/Separation_axiom> * [Willard's *General Topology*][zbMATH02107988] -/ open Function Set Filter Topology TopologicalSpace universe u v variable {X : Type*} {Y : Type*} [TopologicalSpace X] section Separation /-- A T₂ space, also known as a Hausdorff space, is one in which for every `x ≠ y` there exists disjoint open sets around `x` and `y`. This is the most widely used of the separation axioms. -/ @[mk_iff] class T2Space (X : Type u) [TopologicalSpace X] : Prop where /-- Every two points in a Hausdorff space admit disjoint open neighbourhoods. -/ t2 : Pairwise fun x y => ∃ u v : Set X, IsOpen u ∧ IsOpen v ∧ x ∈ u ∧ y ∈ v ∧ Disjoint u v /-- Two different points can be separated by open sets. -/ theorem t2_separation [T2Space X] {x y : X} (h : x ≠ y) : ∃ u v : Set X, IsOpen u ∧ IsOpen v ∧ x ∈ u ∧ y ∈ v ∧ Disjoint u v := T2Space.t2 h -- todo: use this as a definition? theorem t2Space_iff_disjoint_nhds : T2Space X ↔ Pairwise fun x y : X => Disjoint (𝓝 x) (𝓝 y) := by refine (t2Space_iff X).trans (forall₃_congr fun x y _ => ?_) simp only [(nhds_basis_opens x).disjoint_iff (nhds_basis_opens y), ← exists_and_left, and_assoc, and_comm, and_left_comm] @[simp] theorem disjoint_nhds_nhds [T2Space X] {x y : X} : Disjoint (𝓝 x) (𝓝 y) ↔ x ≠ y := ⟨fun hd he => by simp [he, nhds_neBot.ne] at hd, (t2Space_iff_disjoint_nhds.mp ‹_› ·)⟩ theorem pairwise_disjoint_nhds [T2Space X] : Pairwise (Disjoint on (𝓝 : X → Filter X)) := fun _ _ => disjoint_nhds_nhds.2 protected theorem Set.pairwiseDisjoint_nhds [T2Space X] (s : Set X) : s.PairwiseDisjoint 𝓝 := pairwise_disjoint_nhds.set_pairwise s /-- Points of a finite set can be separated by open sets from each other. -/ theorem Set.Finite.t2_separation [T2Space X] {s : Set X} (hs : s.Finite) : ∃ U : X → Set X, (∀ x, x ∈ U x ∧ IsOpen (U x)) ∧ s.PairwiseDisjoint U := s.pairwiseDisjoint_nhds.exists_mem_filter_basis hs nhds_basis_opens -- see Note [lower instance priority] instance (priority := 100) T2Space.t1Space [T2Space X] : T1Space X := t1Space_iff_disjoint_pure_nhds.mpr fun _ _ hne => (disjoint_nhds_nhds.2 hne).mono_left <| pure_le_nhds _ -- see Note [lower instance priority] instance (priority := 100) T2Space.r1Space [T2Space X] : R1Space X := ⟨fun x y ↦ (eq_or_ne x y).imp specializes_of_eq disjoint_nhds_nhds.2⟩ theorem SeparationQuotient.t2Space_iff : T2Space (SeparationQuotient X) ↔ R1Space X := by simp only [t2Space_iff_disjoint_nhds, Pairwise, surjective_mk.forall₂, ne_eq, mk_eq_mk, r1Space_iff_inseparable_or_disjoint_nhds, ← disjoint_comap_iff surjective_mk, comap_mk_nhds_mk, ← or_iff_not_imp_left] instance SeparationQuotient.t2Space [R1Space X] : T2Space (SeparationQuotient X) := t2Space_iff.2 ‹_› instance (priority := 80) [R1Space X] [T0Space X] : T2Space X := t2Space_iff_disjoint_nhds.2 fun _x _y hne ↦ disjoint_nhds_nhds_iff_not_inseparable.2 fun hxy ↦ hne hxy.eq theorem R1Space.t2Space_iff_t0Space [R1Space X] : T2Space X ↔ T0Space X := by constructor <;> intro <;> infer_instance /-- A space is T₂ iff the neighbourhoods of distinct points generate the bottom filter. -/ theorem t2_iff_nhds : T2Space X ↔ ∀ {x y : X}, NeBot (𝓝 x ⊓ 𝓝 y) → x = y := by simp only [t2Space_iff_disjoint_nhds, disjoint_iff, neBot_iff, Ne, not_imp_comm, Pairwise] theorem eq_of_nhds_neBot [T2Space X] {x y : X} (h : NeBot (𝓝 x ⊓ 𝓝 y)) : x = y := t2_iff_nhds.mp ‹_› h theorem t2Space_iff_nhds : T2Space X ↔ Pairwise fun x y : X => ∃ U ∈ 𝓝 x, ∃ V ∈ 𝓝 y, Disjoint U V := by simp only [t2Space_iff_disjoint_nhds, Filter.disjoint_iff, Pairwise] theorem t2_separation_nhds [T2Space X] {x y : X} (h : x ≠ y) : ∃ u v, u ∈ 𝓝 x ∧ v ∈ 𝓝 y ∧ Disjoint u v := let ⟨u, v, open_u, open_v, x_in, y_in, huv⟩ := t2_separation h ⟨u, v, open_u.mem_nhds x_in, open_v.mem_nhds y_in, huv⟩ theorem t2_separation_compact_nhds [LocallyCompactSpace X] [T2Space X] {x y : X} (h : x ≠ y) : ∃ u v, u ∈ 𝓝 x ∧ v ∈ 𝓝 y ∧ IsCompact u ∧ IsCompact v ∧ Disjoint u v := by simpa only [exists_prop, ← exists_and_left, and_comm, and_assoc, and_left_comm] using ((compact_basis_nhds x).disjoint_iff (compact_basis_nhds y)).1 (disjoint_nhds_nhds.2 h) theorem t2_iff_ultrafilter : T2Space X ↔ ∀ {x y : X} (f : Ultrafilter X), ↑f ≤ 𝓝 x → ↑f ≤ 𝓝 y → x = y := t2_iff_nhds.trans <| by simp only [← exists_ultrafilter_iff, and_imp, le_inf_iff, exists_imp] theorem t2_iff_isClosed_diagonal : T2Space X ↔ IsClosed (diagonal X) := by simp only [t2Space_iff_disjoint_nhds, ← isOpen_compl_iff, isOpen_iff_mem_nhds, Prod.forall, nhds_prod_eq, compl_diagonal_mem_prod, mem_compl_iff, mem_diagonal_iff, Pairwise] theorem isClosed_diagonal [T2Space X] : IsClosed (diagonal X) := t2_iff_isClosed_diagonal.mp ‹_› theorem tendsto_nhds_unique [T2Space X] {f : Y → X} {l : Filter Y} {a b : X} [NeBot l] (ha : Tendsto f l (𝓝 a)) (hb : Tendsto f l (𝓝 b)) : a = b := (tendsto_nhds_unique_inseparable ha hb).eq theorem tendsto_nhds_unique' [T2Space X] {f : Y → X} {l : Filter Y} {a b : X} (_ : NeBot l) (ha : Tendsto f l (𝓝 a)) (hb : Tendsto f l (𝓝 b)) : a = b := tendsto_nhds_unique ha hb theorem tendsto_nhds_unique_of_eventuallyEq [T2Space X] {f g : Y → X} {l : Filter Y} {a b : X} [NeBot l] (ha : Tendsto f l (𝓝 a)) (hb : Tendsto g l (𝓝 b)) (hfg : f =ᶠ[l] g) : a = b := tendsto_nhds_unique (ha.congr' hfg) hb theorem tendsto_nhds_unique_of_frequently_eq [T2Space X] {f g : Y → X} {l : Filter Y} {a b : X} (ha : Tendsto f l (𝓝 a)) (hb : Tendsto g l (𝓝 b)) (hfg : ∃ᶠ x in l, f x = g x) : a = b := have : ∃ᶠ z : X × X in 𝓝 (a, b), z.1 = z.2 := (ha.prodMk_nhds hb).frequently hfg not_not.1 fun hne => this (isClosed_diagonal.isOpen_compl.mem_nhds hne) /-- If `s` and `t` are compact sets in a T₂ space, then the set neighborhoods filter of `s ∩ t` is the infimum of set neighborhoods filters for `s` and `t`. For general sets, only the `≤` inequality holds, see `nhdsSet_inter_le`. -/ theorem IsCompact.nhdsSet_inter_eq [T2Space X] {s t : Set X} (hs : IsCompact s) (ht : IsCompact t) : 𝓝ˢ (s ∩ t) = 𝓝ˢ s ⊓ 𝓝ˢ t := by refine le_antisymm (nhdsSet_inter_le _ _) ?_ simp_rw [hs.nhdsSet_inf_eq_biSup, ht.inf_nhdsSet_eq_biSup, nhdsSet, sSup_image] refine iSup₂_le fun x hxs ↦ iSup₂_le fun y hyt ↦ ?_ rcases eq_or_ne x y with (rfl | hne) · exact le_iSup₂_of_le x ⟨hxs, hyt⟩ (inf_idem _).le · exact (disjoint_nhds_nhds.mpr hne).eq_bot ▸ bot_le /-- In a `T2Space X`, for a compact set `t` and a point `x` outside `t`, there are open sets `U`, `V` that separate `t` and `x`. -/ lemma IsCompact.separation_of_notMem {X : Type u_1} [TopologicalSpace X] [T2Space X] {x : X} {t : Set X} (H1 : IsCompact t) (H2 : x ∉ t) : ∃ (U : Set X), ∃ (V : Set X), IsOpen U ∧ IsOpen V ∧ t ⊆ U ∧ x ∈ V ∧ Disjoint U V := by simpa [SeparatedNhds] using SeparatedNhds.of_isCompact_isCompact_isClosed H1 isCompact_singleton isClosed_singleton <| disjoint_singleton_right.mpr H2 @[deprecated (since := "2025-05-23")] alias IsCompact.separation_of_not_mem := IsCompact.separation_of_notMem /-- In a `T2Space X`, for a compact set `t` and a point `x` outside `t`, `𝓝ˢ t` and `𝓝 x` are disjoint. -/ lemma IsCompact.disjoint_nhdsSet_nhds {X : Type u_1} [TopologicalSpace X] [T2Space X] {x : X} {t : Set X} (H1 : IsCompact t) (H2 : x ∉ t) : Disjoint (𝓝ˢ t) (𝓝 x) := by simpa using SeparatedNhds.disjoint_nhdsSet <| .of_isCompact_isCompact_isClosed H1 isCompact_singleton isClosed_singleton <| disjoint_singleton_right.mpr H2 /-- If a function `f` is - injective on a compact set `s`; - continuous at every point of this set; - injective on a neighborhood of each point of this set, then it is injective on a neighborhood of this set. -/ theorem Set.InjOn.exists_mem_nhdsSet {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] [T2Space Y] {f : X → Y} {s : Set X} (inj : InjOn f s) (sc : IsCompact s) (fc : ∀ x ∈ s, ContinuousAt f x) (loc : ∀ x ∈ s, ∃ u ∈ 𝓝 x, InjOn f u) : ∃ t ∈ 𝓝ˢ s, InjOn f t := by have : ∀ x ∈ s ×ˢ s, ∀ᶠ y in 𝓝 x, f y.1 = f y.2 → y.1 = y.2 := fun (x, y) ⟨hx, hy⟩ ↦ by rcases eq_or_ne x y with rfl | hne · rcases loc x hx with ⟨u, hu, hf⟩ exact Filter.mem_of_superset (prod_mem_nhds hu hu) <| forall_prod_set.2 hf · suffices ∀ᶠ z in 𝓝 (x, y), f z.1 ≠ f z.2 from this.mono fun _ hne h ↦ absurd h hne refine (fc x hx).prodMap' (fc y hy) <| isClosed_diagonal.isOpen_compl.mem_nhds ?_ exact inj.ne hx hy hne rw [← eventually_nhdsSet_iff_forall, sc.nhdsSet_prod_eq sc] at this exact eventually_prod_self_iff.1 this /-- If a function `f` is - injective on a compact set `s`; - continuous at every point of this set; - injective on a neighborhood of each point of this set, then it is injective on an open neighborhood of this set. -/ theorem Set.InjOn.exists_isOpen_superset {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] [T2Space Y] {f : X → Y} {s : Set X} (inj : InjOn f s) (sc : IsCompact s) (fc : ∀ x ∈ s, ContinuousAt f x) (loc : ∀ x ∈ s, ∃ u ∈ 𝓝 x, InjOn f u) : ∃ t, IsOpen t ∧ s ⊆ t ∧ InjOn f t := let ⟨_t, hst, ht⟩ := inj.exists_mem_nhdsSet sc fc loc let ⟨u, huo, hsu, hut⟩ := mem_nhdsSet_iff_exists.1 hst ⟨u, huo, hsu, ht.mono hut⟩ section limUnder variable [T2Space X] {f : Filter X} /-! ### Properties of `lim` and `limUnder` In this section we use explicit `Nonempty X` instances for `lim` and `limUnder`. This way the lemmas are useful without a `Nonempty X` instance. -/ theorem lim_eq {x : X} [NeBot f] (h : f ≤ 𝓝 x) : @lim _ _ ⟨x⟩ f = x := tendsto_nhds_unique (le_nhds_lim ⟨x, h⟩) h theorem lim_eq_iff [NeBot f] (h : ∃ x : X, f ≤ 𝓝 x) {x} : @lim _ _ ⟨x⟩ f = x ↔ f ≤ 𝓝 x := ⟨fun c => c ▸ le_nhds_lim h, lim_eq⟩ theorem Ultrafilter.lim_eq_iff_le_nhds [CompactSpace X] {x : X} {F : Ultrafilter X} : F.lim = x ↔ ↑F ≤ 𝓝 x := ⟨fun h => h ▸ F.le_nhds_lim, lim_eq⟩ theorem isOpen_iff_ultrafilter' [CompactSpace X] (U : Set X) : IsOpen U ↔ ∀ F : Ultrafilter X, F.lim ∈ U → U ∈ F.1 := by rw [isOpen_iff_ultrafilter] refine ⟨fun h F hF => h F.lim hF F F.le_nhds_lim, ?_⟩ intro cond x hx f h rw [← Ultrafilter.lim_eq_iff_le_nhds.2 h] at hx exact cond _ hx theorem Filter.Tendsto.limUnder_eq {x : X} {f : Filter Y} [NeBot f] {g : Y → X} (h : Tendsto g f (𝓝 x)) : @limUnder _ _ _ ⟨x⟩ f g = x := lim_eq h theorem Filter.limUnder_eq_iff {f : Filter Y} [NeBot f] {g : Y → X} (h : ∃ x, Tendsto g f (𝓝 x)) {x} : @limUnder _ _ _ ⟨x⟩ f g = x ↔ Tendsto g f (𝓝 x) := ⟨fun c => c ▸ tendsto_nhds_limUnder h, Filter.Tendsto.limUnder_eq⟩ theorem Continuous.limUnder_eq [TopologicalSpace Y] {f : Y → X} (h : Continuous f) (y : Y) : @limUnder _ _ _ ⟨f y⟩ (𝓝 y) f = f y := (h.tendsto y).limUnder_eq @[simp] theorem lim_nhds (x : X) : @lim _ _ ⟨x⟩ (𝓝 x) = x := lim_eq le_rfl @[simp] theorem limUnder_nhds_id (x : X) : @limUnder _ _ _ ⟨x⟩ (𝓝 x) id = x := lim_nhds x @[simp] theorem lim_nhdsWithin {x : X} {s : Set X} (h : x ∈ closure s) : @lim _ _ ⟨x⟩ (𝓝[s] x) = x := haveI : NeBot (𝓝[s] x) := mem_closure_iff_clusterPt.1 h lim_eq inf_le_left @[simp] theorem limUnder_nhdsWithin_id {x : X} {s : Set X} (h : x ∈ closure s) : @limUnder _ _ _ ⟨x⟩ (𝓝[s] x) id = x := lim_nhdsWithin h end limUnder /-! ### `T2Space` constructions We use two lemmas to prove that various standard constructions generate Hausdorff spaces from Hausdorff spaces: * `separated_by_continuous` says that two points `x y : X` can be separated by open neighborhoods provided that there exists a continuous map `f : X → Y` with a Hausdorff codomain such that `f x ≠ f y`. We use this lemma to prove that topological spaces defined using `induced` are Hausdorff spaces. * `separated_by_isOpenEmbedding` says that for an open embedding `f : X → Y` of a Hausdorff space `X`, the images of two distinct points `x y : X`, `x ≠ y` can be separated by open neighborhoods. We use this lemma to prove that topological spaces defined using `coinduced` are Hausdorff spaces. -/ -- see Note [lower instance priority] instance (priority := 100) DiscreteTopology.toT2Space [DiscreteTopology X] : T2Space X := ⟨fun x y h => ⟨{x}, {y}, isOpen_discrete _, isOpen_discrete _, rfl, rfl, disjoint_singleton.2 h⟩⟩ theorem separated_by_continuous [TopologicalSpace Y] [T2Space Y] {f : X → Y} (hf : Continuous f) {x y : X} (h : f x ≠ f y) : ∃ u v : Set X, IsOpen u ∧ IsOpen v ∧ x ∈ u ∧ y ∈ v ∧ Disjoint u v := let ⟨u, v, uo, vo, xu, yv, uv⟩ := t2_separation h ⟨f ⁻¹' u, f ⁻¹' v, uo.preimage hf, vo.preimage hf, xu, yv, uv.preimage _⟩ theorem separated_by_isOpenEmbedding [TopologicalSpace Y] [T2Space X] {f : X → Y} (hf : IsOpenEmbedding f) {x y : X} (h : x ≠ y) : ∃ u v : Set Y, IsOpen u ∧ IsOpen v ∧ f x ∈ u ∧ f y ∈ v ∧ Disjoint u v := let ⟨u, v, uo, vo, xu, yv, uv⟩ := t2_separation h ⟨f '' u, f '' v, hf.isOpenMap _ uo, hf.isOpenMap _ vo, mem_image_of_mem _ xu, mem_image_of_mem _ yv, disjoint_image_of_injective hf.injective uv⟩ instance {p : X → Prop} [T2Space X] : T2Space (Subtype p) := inferInstance instance Prod.t2Space [T2Space X] [TopologicalSpace Y] [T2Space Y] : T2Space (X × Y) := inferInstance /-- If the codomain of an injective continuous function is a Hausdorff space, then so is its domain. -/ theorem T2Space.of_injective_continuous [TopologicalSpace Y] [T2Space Y] {f : X → Y} (hinj : Injective f) (hc : Continuous f) : T2Space X := ⟨fun _ _ h => separated_by_continuous hc (hinj.ne h)⟩ /-- If the codomain of a topological embedding is a Hausdorff space, then so is its domain. See also `T2Space.of_continuous_injective`. -/ theorem Topology.IsEmbedding.t2Space [TopologicalSpace Y] [T2Space Y] {f : X → Y} (hf : IsEmbedding f) : T2Space X := .of_injective_continuous hf.injective hf.continuous protected theorem Homeomorph.t2Space [TopologicalSpace Y] [T2Space X] (h : X ≃ₜ Y) : T2Space Y := h.symm.isEmbedding.t2Space instance ULift.instT2Space [T2Space X] : T2Space (ULift X) := IsEmbedding.uliftDown.t2Space instance [T2Space X] [TopologicalSpace Y] [T2Space Y] : T2Space (X ⊕ Y) := by constructor rintro (x | x) (y | y) h · exact separated_by_isOpenEmbedding .inl <| ne_of_apply_ne _ h · exact separated_by_continuous continuous_isLeft <| by simp · exact separated_by_continuous continuous_isLeft <| by simp · exact separated_by_isOpenEmbedding .inr <| ne_of_apply_ne _ h instance Pi.t2Space {Y : X → Type v} [∀ a, TopologicalSpace (Y a)] [∀ a, T2Space (Y a)] : T2Space (∀ a, Y a) := inferInstance instance Sigma.t2Space {ι} {X : ι → Type*} [∀ i, TopologicalSpace (X i)] [∀ a, T2Space (X a)] : T2Space (Σ i, X i) := by constructor rintro ⟨i, x⟩ ⟨j, y⟩ neq rcases eq_or_ne i j with (rfl | h) · replace neq : x ≠ y := ne_of_apply_ne _ neq exact separated_by_isOpenEmbedding .sigmaMk neq · let _ := (⊥ : TopologicalSpace ι); have : DiscreteTopology ι := ⟨rfl⟩ exact separated_by_continuous (continuous_def.2 fun u _ => isOpen_sigma_fst_preimage u) h section variable (X) /-- The smallest equivalence relation on a topological space giving a T2 quotient. -/ def t2Setoid : Setoid X := sInf {s | T2Space (Quotient s)} /-- The largest T2 quotient of a topological space. This construction is left-adjoint to the inclusion of T2 spaces into all topological spaces. -/ def T2Quotient := Quotient (t2Setoid X) @[deprecated (since := "2025-05-15")] alias t2Quotient := T2Quotient namespace T2Quotient variable {X} instance : TopologicalSpace (T2Quotient X) := inferInstanceAs <| TopologicalSpace (Quotient _) /-- The map from a topological space to its largest T2 quotient. -/ def mk : X → T2Quotient X := Quotient.mk (t2Setoid X) lemma mk_eq {x y : X} : mk x = mk y ↔ ∀ s : Setoid X, T2Space (Quotient s) → s x y := Setoid.quotient_mk_sInf_eq variable (X) lemma surjective_mk : Surjective (mk : X → T2Quotient X) := Quotient.mk_surjective lemma continuous_mk : Continuous (mk : X → T2Quotient X) := continuous_quotient_mk' variable {X} @[elab_as_elim] protected lemma inductionOn {motive : T2Quotient X → Prop} (q : T2Quotient X) (h : ∀ x, motive (T2Quotient.mk x)) : motive q := Quotient.inductionOn q h @[elab_as_elim] protected lemma inductionOn₂ [TopologicalSpace Y] {motive : T2Quotient X → T2Quotient Y → Prop} (q : T2Quotient X) (q' : T2Quotient Y) (h : ∀ x y, motive (mk x) (mk y)) : motive q q' := Quotient.inductionOn₂ q q' h /-- The largest T2 quotient of a topological space is indeed T2. -/ instance : T2Space (T2Quotient X) := by rw [t2Space_iff] rintro ⟨x⟩ ⟨y⟩ (h : ¬ T2Quotient.mk x = T2Quotient.mk y) obtain ⟨s, hs, hsxy⟩ : ∃ s, T2Space (Quotient s) ∧ Quotient.mk s x ≠ Quotient.mk s y := by simpa [T2Quotient.mk_eq] using h exact separated_by_continuous (continuous_map_sInf (by exact hs)) hsxy lemma compatible {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] [T2Space Y] {f : X → Y} (hf : Continuous f) : letI _ := t2Setoid X ∀ (a b : X), a ≈ b → f a = f b := by change t2Setoid X ≤ Setoid.ker f exact sInf_le <| .of_injective_continuous (Setoid.kerLift_injective _) (hf.quotient_lift fun _ _ ↦ id) /-- The universal property of the largest T2 quotient of a topological space `X`: any continuous map from `X` to a T2 space `Y` uniquely factors through `T2Quotient X`. This declaration builds the factored map. Its continuity is `T2Quotient.continuous_lift`, the fact that it indeed factors the original map is `T2Quotient.lift_mk` and uniqueness is `T2Quotient.unique_lift`. -/ def lift {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] [T2Space Y] {f : X → Y} (hf : Continuous f) : T2Quotient X → Y := Quotient.lift f (T2Quotient.compatible hf) lemma continuous_lift {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] [T2Space Y] {f : X → Y} (hf : Continuous f) : Continuous (T2Quotient.lift hf) := continuous_coinduced_dom.mpr hf @[simp] lemma lift_mk {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] [T2Space Y] {f : X → Y} (hf : Continuous f) (x : X) : lift hf (mk x) = f x := Quotient.lift_mk (s := t2Setoid X) f (T2Quotient.compatible hf) x lemma unique_lift {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] [T2Space Y] {f : X → Y} (hf : Continuous f) {g : T2Quotient X → Y} (hfg : g ∘ mk = f) : g = lift hf := by apply surjective_mk X |>.right_cancellable |>.mp <| funext _ simp [← hfg] end T2Quotient end variable {Z : Type*} [TopologicalSpace Y] [TopologicalSpace Z] theorem isClosed_eq [T2Space X] {f g : Y → X} (hf : Continuous f) (hg : Continuous g) : IsClosed { y : Y | f y = g y } := continuous_iff_isClosed.mp (hf.prodMk hg) _ isClosed_diagonal /-- If functions `f` and `g` are continuous on a closed set `s`, then the set of points `x ∈ s` such that `f x = g x` is a closed set. -/ protected theorem IsClosed.isClosed_eq [T2Space Y] {f g : X → Y} {s : Set X} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed {x ∈ s | f x = g x} := (hf.prodMk hg).preimage_isClosed_of_isClosed hs isClosed_diagonal theorem isOpen_ne_fun [T2Space X] {f g : Y → X} (hf : Continuous f) (hg : Continuous g) : IsOpen { y : Y | f y ≠ g y } := isOpen_compl_iff.mpr <| isClosed_eq hf hg /-- If two continuous maps are equal on `s`, then they are equal on the closure of `s`. See also `Set.EqOn.of_subset_closure` for a more general version. -/ protected theorem Set.EqOn.closure [T2Space X] {s : Set Y} {f g : Y → X} (h : EqOn f g s) (hf : Continuous f) (hg : Continuous g) : EqOn f g (closure s) := closure_minimal h (isClosed_eq hf hg) /-- If two continuous functions are equal on a dense set, then they are equal. -/ theorem Continuous.ext_on [T2Space X] {s : Set Y} (hs : Dense s) {f g : Y → X} (hf : Continuous f) (hg : Continuous g) (h : EqOn f g s) : f = g := funext fun x => h.closure hf hg (hs x) theorem eqOn_closure₂' [T2Space Z] {s : Set X} {t : Set Y} {f g : X → Y → Z} (h : ∀ x ∈ s, ∀ y ∈ t, f x y = g x y) (hf₁ : ∀ x, Continuous (f x)) (hf₂ : ∀ y, Continuous fun x => f x y) (hg₁ : ∀ x, Continuous (g x)) (hg₂ : ∀ y, Continuous fun x => g x y) : ∀ x ∈ closure s, ∀ y ∈ closure t, f x y = g x y := suffices closure s ⊆ ⋂ y ∈ closure t, { x | f x y = g x y } by simpa only [subset_def, mem_iInter] (closure_minimal fun x hx => mem_iInter₂.2 <| Set.EqOn.closure (h x hx) (hf₁ _) (hg₁ _)) <| isClosed_biInter fun _ _ => isClosed_eq (hf₂ _) (hg₂ _) theorem eqOn_closure₂ [T2Space Z] {s : Set X} {t : Set Y} {f g : X → Y → Z} (h : ∀ x ∈ s, ∀ y ∈ t, f x y = g x y) (hf : Continuous (uncurry f)) (hg : Continuous (uncurry g)) : ∀ x ∈ closure s, ∀ y ∈ closure t, f x y = g x y := eqOn_closure₂' h hf.uncurry_left hf.uncurry_right hg.uncurry_left hg.uncurry_right /-- If `f x = g x` for all `x ∈ s` and `f`, `g` are continuous on `t`, `s ⊆ t ⊆ closure s`, then `f x = g x` for all `x ∈ t`. See also `Set.EqOn.closure`. -/ theorem Set.EqOn.of_subset_closure [T2Space Y] {s t : Set X} {f g : X → Y} (h : EqOn f g s) (hf : ContinuousOn f t) (hg : ContinuousOn g t) (hst : s ⊆ t) (hts : t ⊆ closure s) : EqOn f g t := by intro x hx have : (𝓝[s] x).NeBot := mem_closure_iff_clusterPt.mp (hts hx) exact tendsto_nhds_unique_of_eventuallyEq ((hf x hx).mono_left <| nhdsWithin_mono _ hst) ((hg x hx).mono_left <| nhdsWithin_mono _ hst) (h.eventuallyEq_of_mem self_mem_nhdsWithin) theorem Function.LeftInverse.isClosed_range [T2Space X] {f : X → Y} {g : Y → X} (h : Function.LeftInverse f g) (hf : Continuous f) (hg : Continuous g) : IsClosed (range g) := have : EqOn (g ∘ f) id (closure <| range g) := h.rightInvOn_range.eqOn.closure (hg.comp hf) continuous_id isClosed_of_closure_subset fun x hx => ⟨f x, this hx⟩ theorem Function.LeftInverse.isClosedEmbedding [T2Space X] {f : X → Y} {g : Y → X} (h : Function.LeftInverse f g) (hf : Continuous f) (hg : Continuous g) : IsClosedEmbedding g := ⟨.of_leftInverse h hf hg, h.isClosed_range hf hg⟩ theorem SeparatedNhds.of_isCompact_isCompact [T2Space X] {s t : Set X} (hs : IsCompact s) (ht : IsCompact t) (hst : Disjoint s t) : SeparatedNhds s t := by simp only [SeparatedNhds, prod_subset_compl_diagonal_iff_disjoint.symm] at hst ⊢ exact generalized_tube_lemma hs ht isClosed_diagonal.isOpen_compl hst /-- In a `T2Space X`, for disjoint closed sets `s t` such that `closure sᶜ` is compact, there are neighbourhoods that separate `s` and `t`. -/ lemma SeparatedNhds.of_isClosed_isCompact_closure_compl_isClosed [T2Space X] {s : Set X} {t : Set X} (H1 : IsClosed s) (H2 : IsCompact (closure sᶜ)) (H3 : IsClosed t) (H4 : Disjoint s t) : SeparatedNhds s t := by -- Since `t` is a closed subset of the compact set `closure sᶜ`, it is compact. have ht : IsCompact t := .of_isClosed_subset H2 H3 <| H4.subset_compl_left.trans subset_closure -- we split `s` into its frontier and its interior. rw [← diff_union_of_subset (interior_subset (s := s))] -- since `t ⊆ sᶜ`, which is open, and `interior s` is open, we have -- `SeparatedNhds (interior s) t`, which leaves us only with the frontier. refine .union_left ?_ ⟨interior s, sᶜ, isOpen_interior, H1.isOpen_compl, le_rfl, H4.subset_compl_left, disjoint_compl_right.mono_left interior_subset⟩ -- Since the frontier of `s` is compact (as it is a subset of `closure sᶜ`), we simply apply -- `SeparatedNhds_of_isCompact_isCompact`. rw [← H1.frontier_eq, frontier_eq_closure_inter_closure, H1.closure_eq] refine .of_isCompact_isCompact ?_ ht (disjoint_of_subset_left inter_subset_left H4) exact H2.of_isClosed_subset (H1.inter isClosed_closure) inter_subset_right section SeparatedFinset theorem SeparatedNhds.of_finset_finset [T2Space X] (s t : Finset X) (h : Disjoint s t) : SeparatedNhds (s : Set X) t := .of_isCompact_isCompact s.finite_toSet.isCompact t.finite_toSet.isCompact <| mod_cast h theorem SeparatedNhds.of_singleton_finset [T2Space X] {x : X} {s : Finset X} (h : x ∉ s) : SeparatedNhds ({x} : Set X) s := mod_cast .of_finset_finset {x} s (Finset.disjoint_singleton_left.mpr h) end SeparatedFinset /-- In a `T2Space`, every compact set is closed. -/ @[aesop 50% apply, grind ←] theorem IsCompact.isClosed [T2Space X] {s : Set X} (hs : IsCompact s) : IsClosed s := isClosed_iff_forall_filter.2 fun _x _f _ hfs hfx => let ⟨_y, hy, hfy⟩ := hs.exists_clusterPt hfs mem_of_eq_of_mem (eq_of_nhds_neBot (hfy.mono hfx).neBot).symm hy theorem IsCompact.preimage_continuous [CompactSpace X] [T2Space Y] {f : X → Y} {s : Set Y} (hs : IsCompact s) (hf : Continuous f) : IsCompact (f ⁻¹' s) := (hs.isClosed.preimage hf).isCompact lemma Pi.isCompact_iff {ι : Type*} {X : ι → Type*} [∀ i, TopologicalSpace (X i)] [∀ i, T2Space (X i)] {s : Set (Π i, X i)} : IsCompact s ↔ IsClosed s ∧ ∀ i, IsCompact (eval i '' s) := by constructor <;> intro H · exact ⟨H.isClosed, fun i ↦ H.image <| continuous_apply i⟩ · exact IsCompact.of_isClosed_subset (isCompact_univ_pi H.2) H.1 (subset_pi_eval_image univ s) lemma Pi.isCompact_closure_iff {ι : Type*} {X : ι → Type*} [∀ i, TopologicalSpace (X i)] [∀ i, T2Space (X i)] {s : Set (Π i, X i)} : IsCompact (closure s) ↔ ∀ i, IsCompact (closure <| eval i '' s) := by simp_rw [← exists_isCompact_superset_iff, Pi.exists_compact_superset_iff, image_subset_iff] /-- If `V : ι → Set X` is a decreasing family of compact sets then any neighborhood of `⋂ i, V i` contains some `V i`. This is a version of `exists_subset_nhds_of_isCompact'` where we don't need to assume each `V i` closed because it follows from compactness since `X` is assumed to be Hausdorff. -/ theorem exists_subset_nhds_of_isCompact [T2Space X] {ι : Type*} [Nonempty ι] {V : ι → Set X} (hV : Directed (· ⊇ ·) V) (hV_cpct : ∀ i, IsCompact (V i)) {U : Set X} (hU : ∀ x ∈ ⋂ i, V i, U ∈ 𝓝 x) : ∃ i, V i ⊆ U := exists_subset_nhds_of_isCompact' hV hV_cpct (fun i => (hV_cpct i).isClosed) hU theorem CompactExhaustion.isClosed [T2Space X] (K : CompactExhaustion X) (n : ℕ) : IsClosed (K n) := (K.isCompact n).isClosed theorem IsCompact.inter [T2Space X] {s t : Set X} (hs : IsCompact s) (ht : IsCompact t) : IsCompact (s ∩ t) := hs.inter_right <| ht.isClosed theorem image_closure_of_isCompact [T2Space Y] {s : Set X} (hs : IsCompact (closure s)) {f : X → Y} (hf : ContinuousOn f (closure s)) : f '' closure s = closure (f '' s) := Subset.antisymm hf.image_closure <| closure_minimal (image_mono subset_closure) (hs.image_of_continuousOn hf).isClosed /-- Two continuous maps into a Hausdorff space agree at a point iff they agree in a neighborhood. -/ theorem ContinuousAt.ne_iff_eventually_ne [T2Space Y] {x : X} {f g : X → Y} (hf : ContinuousAt f x) (hg : ContinuousAt g x) : f x ≠ g x ↔ ∀ᶠ x in 𝓝 x, f x ≠ g x := by constructor <;> intro hfg · obtain ⟨Uf, Ug, h₁U, h₂U, h₃U, h₄U, h₅U⟩ := t2_separation hfg rw [Set.disjoint_iff_inter_eq_empty] at h₅U filter_upwards [inter_mem (hf.preimage_mem_nhds (IsOpen.mem_nhds h₁U h₃U)) (hg.preimage_mem_nhds (IsOpen.mem_nhds h₂U h₄U))] intro x hx simp only [Set.mem_inter_iff, Set.mem_preimage] at hx by_contra H rw [H] at hx have : g x ∈ Uf ∩ Ug := hx simp [h₅U] at this · obtain ⟨t, h₁t, h₂t, h₃t⟩ := eventually_nhds_iff.1 hfg exact h₁t x h₃t /-- **Local identity principle** for continuous maps: Two continuous maps into a Hausdorff space agree in a punctured neighborhood of a non-isolated point iff they agree in a neighborhood. -/ theorem ContinuousAt.eventuallyEq_nhds_iff_eventuallyEq_nhdsNE [T2Space Y] {x : X} {f g : X → Y} (hf : ContinuousAt f x) (hg : ContinuousAt g x) [(𝓝[≠] x).NeBot] : f =ᶠ[𝓝[≠] x] g ↔ f =ᶠ[𝓝 x] g := by constructor <;> intro hfg · apply eventuallyEq_nhds_of_eventuallyEq_nhdsNE hfg by_contra hCon obtain ⟨a, ha⟩ : {x | f x ≠ g x ∧ f x = g x}.Nonempty := by have h₁ := (eventually_nhdsWithin_of_eventually_nhds ((hf.ne_iff_eventually_ne hg).1 hCon)).and hfg have h₂ : ∅ ∉ 𝓝[≠] x := by exact empty_notMem (𝓝[≠] x) simp_all simp at ha · exact hfg.filter_mono nhdsWithin_le_nhds @[deprecated (since := "2025-05-22")] alias ContinuousAt.eventuallyEq_nhd_iff_eventuallyEq_nhdNE := ContinuousAt.eventuallyEq_nhds_iff_eventuallyEq_nhdsNE /-- A continuous map from a compact space to a Hausdorff space is a closed map. -/ protected theorem Continuous.isClosedMap [CompactSpace X] [T2Space Y] {f : X → Y} (h : Continuous f) : IsClosedMap f := fun _s hs => (hs.isCompact.image h).isClosed /-- A continuous injective map from a compact space to a Hausdorff space is a closed embedding. -/ theorem Continuous.isClosedEmbedding [CompactSpace X] [T2Space Y] {f : X → Y} (h : Continuous f) (hf : Function.Injective f) : IsClosedEmbedding f := .of_continuous_injective_isClosedMap h hf h.isClosedMap /-- A continuous surjective map from a compact space to a Hausdorff space is a quotient map. -/ theorem IsQuotientMap.of_surjective_continuous [CompactSpace X] [T2Space Y] {f : X → Y} (hsurj : Surjective f) (hcont : Continuous f) : IsQuotientMap f := hcont.isClosedMap.isQuotientMap hcont hsurj theorem isPreirreducible_iff_forall_mem_subset_closure_singleton [R1Space X] {S : Set X} : IsPreirreducible S ↔ ∀ x ∈ S, S ⊆ closure {x} := by constructor · intro h x hx y hy by_contra e obtain ⟨U, V, hU, hV, hxU, hyV, h'⟩ := r1_separation fun h => e h.specializes.mem_closure exact ((h U V hU hV ⟨x, hx, hxU⟩ ⟨y, hy, hyV⟩).mono inter_subset_right).not_disjoint h' · intro h u v hu hv ⟨x, hxs, hxu⟩ ⟨y, hys, hyv⟩ exact ⟨x, hxs, hxu, (specializes_iff_mem_closure.mpr (h x hxs hys)).mem_open hv hyv⟩ theorem isPreirreducible_iff_subsingleton [T2Space X] {S : Set X} : IsPreirreducible S ↔ S.Subsingleton := by simp [isPreirreducible_iff_forall_mem_subset_closure_singleton, Set.Subsingleton, eq_comm] -- todo: use `alias` + `attribute [protected]` once we get `attribute [protected]` protected lemma IsPreirreducible.subsingleton [T2Space X] {S : Set X} (h : IsPreirreducible S) : S.Subsingleton := isPreirreducible_iff_subsingleton.1 h theorem isIrreducible_iff_singleton [T2Space X] {S : Set X} : IsIrreducible S ↔ ∃ x, S = {x} := by rw [IsIrreducible, isPreirreducible_iff_subsingleton, exists_eq_singleton_iff_nonempty_subsingleton] /-- There does not exist a nontrivial preirreducible T₂ space. -/ theorem not_preirreducible_nontrivial_t2 (X) [TopologicalSpace X] [PreirreducibleSpace X] [Nontrivial X] [T2Space X] : False := (PreirreducibleSpace.isPreirreducible_univ (X := X)).subsingleton.not_nontrivial nontrivial_univ theorem t2Space_antitone {X : Type*} : Antitone (@T2Space X) := fun inst₁ inst₂ h_top h_t2 ↦ @T2Space.of_injective_continuous _ _ inst₁ inst₂ h_t2 _ Function.injective_id <| continuous_id_of_le h_top end Separation
.lake/packages/mathlib/Mathlib/Topology/Separation/Profinite.lean
import Mathlib.Topology.Separation.Regular import Mathlib.Topology.Connected.TotallyDisconnected /-! # Separation properties: profinite spaces -/ open Function Set Filter Topology TopologicalSpace universe u v variable {X : Type*} {Y : Type*} [TopologicalSpace X] section Profinite /-- A T0 space with a clopen basis is totally separated. -/ theorem totallySeparatedSpace_of_t0_of_basis_clopen [T0Space X] (h : IsTopologicalBasis { s : Set X | IsClopen s }) : TotallySeparatedSpace X := by constructor rintro x - y - hxy choose U hU using exists_isOpen_xor'_mem hxy obtain ⟨hU₀, hU₁⟩ := hU rcases hU₁ with hx | hy · choose V hV using h.isOpen_iff.mp hU₀ x hx.1 exact ⟨V, Vᶜ, hV.1.isOpen, hV.1.compl.isOpen, hV.2.1, notMem_subset hV.2.2 hx.2, (union_compl_self V).superset, disjoint_compl_right⟩ · choose V hV using h.isOpen_iff.mp hU₀ y hy.1 exact ⟨Vᶜ, V, hV.1.compl.isOpen, hV.1.isOpen, notMem_subset hV.2.2 hy.2, hV.2.1, (union_comm _ _ ▸ union_compl_self V).superset, disjoint_compl_left⟩ @[deprecated (since := "2025-09-11")] alias totallySeparatedSpace_of_t1_of_basis_clopen := totallySeparatedSpace_of_t0_of_basis_clopen variable [T2Space X] [CompactSpace X] [TotallyDisconnectedSpace X] theorem nhds_basis_clopen (x : X) : (𝓝 x).HasBasis (fun s : Set X => x ∈ s ∧ IsClopen s) id := ⟨fun U => by constructor · have hx : connectedComponent x = {x} := totallyDisconnectedSpace_iff_connectedComponent_singleton.mp ‹_› x rw [connectedComponent_eq_iInter_isClopen] at hx intro hU let N := { s // IsClopen s ∧ x ∈ s } rsuffices ⟨⟨s, hs, hs'⟩, hs''⟩ : ∃ s : N, s.val ⊆ U · exact ⟨s, ⟨hs', hs⟩, hs''⟩ haveI : Nonempty N := ⟨⟨univ, isClopen_univ, mem_univ x⟩⟩ have hNcl : ∀ s : N, IsClosed s.val := fun s => s.property.1.1 have hdir : Directed Superset fun s : N => s.val := by rintro ⟨s, hs, hxs⟩ ⟨t, ht, hxt⟩ exact ⟨⟨s ∩ t, hs.inter ht, ⟨hxs, hxt⟩⟩, inter_subset_left, inter_subset_right⟩ have h_nhds : ∀ y ∈ ⋂ s : N, s.val, U ∈ 𝓝 y := fun y y_in => by rw [hx, mem_singleton_iff] at y_in rwa [y_in] exact exists_subset_nhds_of_compactSpace hdir hNcl h_nhds · rintro ⟨V, ⟨hxV, -, V_op⟩, hUV : V ⊆ U⟩ rw [mem_nhds_iff] exact ⟨V, hUV, V_op, hxV⟩⟩ theorem isTopologicalBasis_isClopen : IsTopologicalBasis { s : Set X | IsClopen s } := by apply isTopologicalBasis_of_isOpen_of_nhds fun U (hU : IsClopen U) => hU.2 intro x U hxU U_op have : U ∈ 𝓝 x := IsOpen.mem_nhds U_op hxU rcases (nhds_basis_clopen x).mem_iff.mp this with ⟨V, ⟨hxV, hV⟩, hVU : V ⊆ U⟩ use V tauto /-- Every member of an open set in a compact Hausdorff totally disconnected space is contained in a clopen set contained in the open set. -/ theorem compact_exists_isClopen_in_isOpen {x : X} {U : Set X} (is_open : IsOpen U) (memU : x ∈ U) : ∃ V : Set X, IsClopen V ∧ x ∈ V ∧ V ⊆ U := isTopologicalBasis_isClopen.mem_nhds_iff.1 (is_open.mem_nhds memU) end Profinite section LocallyCompact variable {H : Type*} [TopologicalSpace H] [LocallyCompactSpace H] [T2Space H] /-- A locally compact Hausdorff totally disconnected space has a basis with clopen elements. -/ theorem loc_compact_Haus_tot_disc_of_zero_dim [TotallyDisconnectedSpace H] : IsTopologicalBasis { s : Set H | IsClopen s } := by refine isTopologicalBasis_of_isOpen_of_nhds (fun u hu => hu.2) fun x U memU hU => ?_ obtain ⟨s, comp, xs, sU⟩ := exists_compact_subset hU memU let u : Set s := ((↑) : s → H) ⁻¹' interior s have u_open_in_s : IsOpen u := isOpen_interior.preimage continuous_subtype_val lift x to s using interior_subset xs haveI : CompactSpace s := isCompact_iff_compactSpace.1 comp obtain ⟨V : Set s, VisClopen, Vx, V_sub⟩ := compact_exists_isClopen_in_isOpen u_open_in_s xs have VisClopen' : IsClopen (((↑) : s → H) '' V) := by refine ⟨comp.isClosed.isClosedEmbedding_subtypeVal.isClosed_iff_image_isClosed.1 VisClopen.1, ?_⟩ let v : Set u := ((↑) : u → s) ⁻¹' V have : ((↑) : u → H) = ((↑) : s → H) ∘ ((↑) : u → s) := rfl have f0 : IsEmbedding ((↑) : u → H) := IsEmbedding.subtypeVal.comp IsEmbedding.subtypeVal have f1 : IsOpenEmbedding ((↑) : u → H) := by refine ⟨f0, ?_⟩ · have : Set.range ((↑) : u → H) = interior s := by rw [this, Set.range_comp, Subtype.range_coe, Subtype.image_preimage_coe] apply Set.inter_eq_self_of_subset_right interior_subset rw [this] apply isOpen_interior have f2 : IsOpen v := VisClopen.2.preimage continuous_subtype_val have f3 : ((↑) : s → H) '' V = ((↑) : u → H) '' v := by rw [this, image_comp, Subtype.image_preimage_coe, inter_eq_self_of_subset_right V_sub] rw [f3] apply f1.isOpenMap v f2 use (↑) '' V, VisClopen', by simp [Vx], Subset.trans (by simp) sU /-- A locally compact Hausdorff space is totally disconnected if and only if it is totally separated. -/ theorem loc_compact_t2_tot_disc_iff_tot_sep : TotallyDisconnectedSpace H ↔ TotallySeparatedSpace H := by constructor · intro h exact totallySeparatedSpace_of_t0_of_basis_clopen loc_compact_Haus_tot_disc_of_zero_dim apply TotallySeparatedSpace.totallyDisconnectedSpace /-- A totally disconnected compact Hausdorff space is totally separated. -/ instance (priority := 100) [TotallyDisconnectedSpace H] : TotallySeparatedSpace H := loc_compact_t2_tot_disc_iff_tot_sep.mp inferInstance end LocallyCompact
.lake/packages/mathlib/Mathlib/Topology/Separation/CompletelyRegular.lean
import Mathlib.Topology.UrysohnsLemma import Mathlib.Topology.UnitInterval import Mathlib.Topology.Compactification.StoneCech import Mathlib.Topology.Order.Lattice import Mathlib.Analysis.Real.Cardinality /-! # Completely regular topological spaces. This file defines `CompletelyRegularSpace` and `T35Space`. ## Main definitions * `CompletelyRegularSpace`: A completely regular space `X` is such that each closed set `K ⊆ X` and a point `x ∈ Kᶜ`, there is a continuous function `f` from `X` to the unit interval, so that `f x = 0` and `f k = 1` for all `k ∈ K`. A completely regular space is a regular space, and a normal space is a completely regular space. * `T35Space`: A T₃.₅ space is a completely regular space that is also T₀. A T₃.₅ space is a T₃ space and a T₄ space is a T₃.₅ space. ## Main results ### Completely regular spaces * `CompletelyRegularSpace.regularSpace`: A completely regular space is a regular space. * `NormalSpace.completelyRegularSpace`: A normal R0 space is a completely regular space. ### T₃.₅ spaces * `T35Space.instT3Space`: A T₃.₅ space is a T₃ space. * `T4Space.instT35Space`: A T₄ space is a T₃.₅ space. ## Implementation notes The present definition `CompletelyRegularSpace` is a slight modification of the one given in [russell1974]. There it's assumed that any point `x ∈ Kᶜ` is separated from the closed set `K` by a continuous *real*-valued function `f` (as opposed to `f` being unit-interval-valued). This can be converted to the present definition by replacing a real-valued `f` by `h ∘ g ∘ f`, with `g : x ↦ max(x, 0)` and `h : x ↦ min(x, 1)`. Some sources (e.g. [russell1974]) also assume that a completely regular space is T₁. Here a completely regular space that is also T₁ is called a T₃.₅ space. ## References * [Russell C. Walker, *The Stone-Čech Compactification*][russell1974] -/ universe u v noncomputable section open Set Topology Filter unitInterval variable {X : Type u} [TopologicalSpace X] /-- A space is completely regular if points can be separated from closed sets via continuous functions to the unit interval. -/ @[mk_iff] class CompletelyRegularSpace (X : Type u) [TopologicalSpace X] : Prop where completely_regular : ∀ (x : X), ∀ K : Set X, IsClosed K → x ∉ K → ∃ f : X → I, Continuous f ∧ f x = 0 ∧ EqOn f 1 K lemma completelyRegularSpace_iff_isOpen : CompletelyRegularSpace X ↔ ∀ (x : X), ∀ K : Set X, IsOpen K → x ∈ K → ∃ f : X → I, Continuous f ∧ f x = 0 ∧ EqOn f 1 Kᶜ := by conv_lhs => tactic => simp_rw +singlePass [completelyRegularSpace_iff, compl_surjective.forall, isClosed_compl_iff, mem_compl_iff, not_not] lemma CompletelyRegularSpace.completely_regular_isOpen [CompletelyRegularSpace X] : ∀ (x : X), ∀ K : Set X, IsOpen K → x ∈ K → ∃ f : X → I, Continuous f ∧ f x = 0 ∧ EqOn f 1 Kᶜ := completelyRegularSpace_iff_isOpen.mp inferInstance instance CompletelyRegularSpace.instRegularSpace [CompletelyRegularSpace X] : RegularSpace X := by rw [regularSpace_iff] intro s a hs ha obtain ⟨f, cf, hf, hhf⟩ := CompletelyRegularSpace.completely_regular a s hs ha apply disjoint_of_map (f := f) apply Disjoint.mono (cf.tendsto_nhdsSet_nhds hhf) cf.continuousAt exact disjoint_nhds_nhds.mpr (hf.symm ▸ zero_ne_one).symm instance NormalSpace.instCompletelyRegularSpace [NormalSpace X] [R0Space X] : CompletelyRegularSpace X := by rw [completelyRegularSpace_iff] intro x K hK hx have cx : IsClosed (closure {x}) := isClosed_closure have d : Disjoint (closure {x}) K := by rw [Set.disjoint_iff] intro a ⟨hax, haK⟩ exact hx ((specializes_iff_mem_closure.mpr hax).symm.mem_closed hK haK) let ⟨⟨f, cf⟩, hfx, hfK, hficc⟩ := exists_continuous_zero_one_of_isClosed cx hK d let g : X → I := fun x => ⟨f x, hficc x⟩ have cg : Continuous g := cf.subtype_mk hficc have hgx : g x = 0 := Subtype.ext (hfx (subset_closure (mem_singleton x))) have hgK : EqOn g 1 K := fun k hk => Subtype.ext (hfK hk) exact ⟨g, cg, hgx, hgK⟩ lemma Topology.IsInducing.completelyRegularSpace {Y : Type v} [TopologicalSpace Y] [CompletelyRegularSpace Y] {f : X → Y} (hf : IsInducing f) : CompletelyRegularSpace X where completely_regular x K hK hxK := by rw [hf.isClosed_iff] at hK obtain ⟨K, hK, rfl⟩ := hK rw [mem_preimage] at hxK obtain ⟨g, hcf, egfx, hgK⟩ := CompletelyRegularSpace.completely_regular _ _ hK hxK refine ⟨g ∘ f, hcf.comp hf.continuous, egfx, ?_⟩ conv => arg 2; equals (1 : Y → ↥I) ∘ f => rfl exact hgK.comp_right <| mapsTo_preimage _ _ instance {p : X → Prop} [CompletelyRegularSpace X] : CompletelyRegularSpace (Subtype p) := Topology.IsInducing.subtypeVal.completelyRegularSpace lemma completelyRegularSpace_induced {X Y : Type*} {t : TopologicalSpace Y} (ht : @CompletelyRegularSpace Y t) (f : X → Y) : @CompletelyRegularSpace X (t.induced f) := @IsInducing.completelyRegularSpace _ (t.induced f) _ t _ _ (IsInducing.induced f) lemma completelyRegularSpace_iInf {ι X : Type*} {t : ι → TopologicalSpace X} (ht : ∀ i, @CompletelyRegularSpace X (t i)) : @CompletelyRegularSpace X (⨅ i, t i) := by letI := (⨅ i, t i) -- register this as default topological space to reduce `@`s rw [completelyRegularSpace_iff_isOpen] intro x K hK hxK simp_rw [← hK.mem_nhds_iff, nhds_iInf, mem_iInf, exists_finite_iff_finset, Finset.coe_sort_coe] at hxK; clear hK obtain ⟨I', V, hV, rfl⟩ := hxK simp only [mem_nhds_iff] at hV choose U hUV hU hxU using hV replace hU := fun (i : ↥I') => @CompletelyRegularSpace.completely_regular_isOpen _ (t i) (ht i) x (U i) (hU i) (hxU i) clear hxU choose fs hfs hxfs hfsU using hU use I'.attach.sup fs constructorm* _ ∧ _ · solve_by_elim [Continuous.finset_sup, continuous_iInf_dom] · simpa [show (0 : ↥I) = ⊥ from rfl] using hxfs · simp only [EqOn, Pi.one_apply, show (1 : ↥I) = ⊤ from rfl] at hfsU ⊢ conv => equals ∀ x i, x ∈ (V i)ᶜ → ∃ b, fs b x = ⊤ => simp [Finset.sup_eq_top_iff] intro x i hxi specialize hfsU i (by tauto_set) exists i lemma completelyRegularSpace_inf {X : Type*} {t₁ t₂ : TopologicalSpace X} (ht₁ : @CompletelyRegularSpace X t₁) (ht₂ : @CompletelyRegularSpace X t₂) : @CompletelyRegularSpace X (t₁ ⊓ t₂) := by rw [inf_eq_iInf]; apply completelyRegularSpace_iInf; simp [*] instance {ι : Type*} {X : ι → Type*} [t : Π (i : ι), TopologicalSpace (X i)] [ht : Π (i : ι), CompletelyRegularSpace (X i)] : CompletelyRegularSpace (Π i, X i) := completelyRegularSpace_iInf (fun i => completelyRegularSpace_induced (ht i) _) instance {X Y : Type*} [tX : TopologicalSpace X] [tY : TopologicalSpace Y] [htX : CompletelyRegularSpace X] [htY : CompletelyRegularSpace Y] : CompletelyRegularSpace (X × Y) := completelyRegularSpace_inf (completelyRegularSpace_induced htX _) ((completelyRegularSpace_induced htY _)) lemma isInducing_stoneCechUnit [CompletelyRegularSpace X] : IsInducing (stoneCechUnit : X → StoneCech X) := by rw [isInducing_iff_nhds] intro x apply le_antisymm · rw [← map_le_iff_le_comap]; exact continuous_stoneCechUnit.continuousAt · simp_rw [le_nhds_iff, ((nhds_basis_opens _).comap _).mem_iff, and_assoc] intro U hxU hU obtain ⟨f, hf, efx, hfU⟩ := CompletelyRegularSpace.completely_regular_isOpen x U hU hxU conv at hfU => equals Uᶜ ⊆ f ⁻¹' {1} => simp [EqOn, subset_def] rw [← compl_subset_comm, ← preimage_compl, ← stoneCechExtend_extends hf, preimage_comp] at hfU refine ⟨stoneCechExtend hf ⁻¹' {1}ᶜ, ?_, isOpen_compl_singleton.preimage (continuous_stoneCechExtend hf), hfU⟩ rw [mem_preimage, stoneCechExtend_stoneCechUnit, efx, mem_compl_iff, mem_singleton_iff] simp lemma isDenseInducing_stoneCechUnit [CompletelyRegularSpace X] : IsDenseInducing (stoneCechUnit : X → StoneCech X) where toIsInducing := isInducing_stoneCechUnit dense := denseRange_stoneCechUnit lemma completelyRegularSpace_iff_isInducing_stoneCechUnit : CompletelyRegularSpace X ↔ IsInducing (stoneCechUnit : X → StoneCech X) where mp _ := isInducing_stoneCechUnit mpr hs := hs.completelyRegularSpace open TopologicalSpace Cardinal in theorem CompletelyRegularSpace.isTopologicalBasis_clopens_of_cardinalMk_lt_continuum [CompletelyRegularSpace X] (hX : Cardinal.mk X < continuum) : IsTopologicalBasis {s : Set X | IsClopen s} := by refine isTopologicalBasis_of_isOpen_of_nhds (fun x s ↦ IsClopen.isOpen s) (fun x s hxs hs ↦ ?_) choose f hf using completely_regular_isOpen x s hs hxs obtain ⟨hfc, hf₀, hf₁⟩ := hf let R := Set.range f have hR : lift.{u, 0} (Cardinal.mk R) < lift.{0, u} continuum := by simpa [R] using mk_range_le_lift.trans_lt (lift_strictMono hX) rw [lift_continuum, ← lift_continuum.{u, 0}, lift_lt, ← mk_Icc_real zero_lt_one, ← unitInterval] at hR obtain ⟨r, hr⟩ : ∃ r : I, r ∈ Rᶜ := compl_nonempty_of_mk_lt_mk hR have hr' : ∀ (x : X), f x ≠ r := by simpa [R] using hr have hrclopen : f ⁻¹' Iio r = f ⁻¹' Iic r := by ext; simp [le_iff_lt_or_eq, hr'] refine ⟨f ⁻¹' Iio r, ⟨hrclopen ▸ isClosed_Iic.preimage hfc, isOpen_Iio.preimage hfc⟩, ?_, ?_⟩ · simp [hf₀, hrclopen] · refine preimage_subset_iff.mpr (fun x ↦ ?_) contrapose!; intro hxs simpa [hf₁ hxs] using le_one' /-- A T₃.₅ space is a completely regular space that is also T₀. -/ @[mk_iff] class T35Space (X : Type u) [TopologicalSpace X] : Prop extends T0Space X, CompletelyRegularSpace X instance T35Space.instT3space [T35Space X] : T3Space X where instance T4Space.instT35Space [T4Space X] : T35Space X where lemma Topology.IsEmbedding.t35Space {Y : Type v} [TopologicalSpace Y] [T35Space Y] {f : X → Y} (hf : IsEmbedding f) : T35Space X := @T35Space.mk _ _ hf.t0Space hf.isInducing.completelyRegularSpace instance {p : X → Prop} [T35Space X] : T35Space (Subtype p) where instance {ι : Type*} {X : ι → Type*} [t : Π (i : ι), TopologicalSpace (X i)] [ht : Π (i : ι), T35Space (X i)] : T35Space (Π i, X i) where instance {X Y : Type*} [tX : TopologicalSpace X] [tY : TopologicalSpace Y] [htX : T35Space X] [htY : T35Space Y] : T35Space (X × Y) where lemma separatesPoints_continuous_of_t35Space [T35Space X] : SeparatesPoints {f : X → ℝ | Continuous f} := by intro x y x_ne_y obtain ⟨f, f_cont, f_zero, f_one⟩ := CompletelyRegularSpace.completely_regular x {y} isClosed_singleton x_ne_y exact ⟨fun x ↦ f x, continuous_subtype_val.comp f_cont, by simp_all⟩ lemma separatesPoints_continuous_of_t35Space_Icc [T35Space X] : SeparatesPoints {f : X → I | Continuous f} := by intro x y x_ne_y obtain ⟨f, f_cont, f_zero, f_one⟩ := CompletelyRegularSpace.completely_regular x {y} isClosed_singleton x_ne_y exact ⟨f, f_cont, by simp_all⟩ lemma injective_stoneCechUnit_of_t35Space [T35Space X] : Function.Injective (stoneCechUnit : X → StoneCech X) := by intro a b hab contrapose hab obtain ⟨f, fc, fab⟩ := separatesPoints_continuous_of_t35Space_Icc hab exact fun q ↦ fab (eq_if_stoneCechUnit_eq fc q) lemma isEmbedding_stoneCechUnit [T35Space X] : IsEmbedding (stoneCechUnit : X → StoneCech X) where toIsInducing := isInducing_stoneCechUnit injective := injective_stoneCechUnit_of_t35Space lemma isDenseEmbedding_stoneCechUnit [T35Space X] : IsDenseEmbedding (stoneCechUnit : X → StoneCech X) where toIsDenseInducing := isDenseInducing_stoneCechUnit injective := injective_stoneCechUnit_of_t35Space lemma t35Space_iff_isEmbedding_stoneCechUnit : T35Space X ↔ IsEmbedding (stoneCechUnit : X → StoneCech X) where mp _ := isEmbedding_stoneCechUnit mpr hs := hs.t35Space
.lake/packages/mathlib/Mathlib/Topology/Separation/DisjointCover.lean
import Mathlib.Algebra.Notation.Indicator import Mathlib.Data.Fintype.BigOperators import Mathlib.Order.Disjointed import Mathlib.Topology.Separation.Profinite import Mathlib.Topology.Sets.Closeds import Mathlib.Topology.Sets.OpenCover /-! # Disjoint covers of profinite spaces We prove various results about covering profinite spaces by disjoint clopens, including * `TopologicalSpace.IsOpenCover.exists_finite_nonempty_disjoint_clopen_cover`: any open cover of a profinite space can be refined to a finite cover by pairwise disjoint nonempty clopens. * `ContinuousMap.exists_finite_approximation_of_mem_nhds_diagonal`: if `f : X → V` is continuous with `X` profinite, and `S` is a neighbourhood of the diagonal in `V × V`, then `f` can be `S`-approximated by a function factoring through `Fin n` for some `n`. -/ open Set TopologicalSpace open scoped Function Finset Topology namespace TopologicalSpace.IsOpenCover variable {ι X : Type*} [TopologicalSpace X] [TotallyDisconnectedSpace X] [T2Space X] [CompactSpace X] {U : ι → Opens X} /-- Any open cover of a profinite space can be refined to a finite cover by clopens. -/ lemma exists_finite_clopen_cover (hU : IsOpenCover U) : ∃ (n : ℕ) (V : Fin n → Clopens X), (∀ j, ∃ i, (V j : Set X) ⊆ U i) ∧ univ ⊆ ⋃ j, (V j : Set X) := by -- Choose an index `r x` for each point in `X` such that `∀ x, x ∈ U (r x)`. choose r hr using hU.exists_mem -- Choose a clopen neighbourhood `V x` of each `x` contained in `U (r x)`. choose V hV hVx hVU using fun x ↦ compact_exists_isClopen_in_isOpen (U _).isOpen (hr x) -- Apply compactness to extract a finite subset of the `V`s which covers `X`. obtain ⟨t, ht⟩ : ∃ t, univ ⊆ ⋃ i ∈ t, V i := isCompact_univ.elim_finite_subcover V (fun x ↦ (hV x).2) (fun x _ ↦ mem_iUnion.mpr ⟨x, hVx x⟩) -- Biject it noncanonically with `Fin n` for some `n`. refine ⟨_, fun j ↦ ⟨_, hV (t.equivFin.symm j)⟩, fun j ↦ ⟨_, hVU _⟩, fun x hx ↦ ?_⟩ obtain ⟨m, hm, hm'⟩ := mem_iUnion₂.mp (ht hx) exact Set.mem_iUnion_of_mem (t.equivFin ⟨m, hm⟩) (by simpa) /-- Any open cover of a profinite space can be refined to a finite cover by pairwise disjoint nonempty clopens. -/ lemma exists_finite_nonempty_disjoint_clopen_cover (hU : IsOpenCover U) : ∃ (n : ℕ) (W : Fin n → Clopens X), (∀ j, W j ≠ ⊥ ∧ ∃ i, (W j : Set X) ⊆ U i) ∧ (univ : Set X) ⊆ ⋃ j, ↑(W j) ∧ Pairwise (Disjoint on W) := by classical obtain ⟨n, V, hVle, hVun⟩ := hU.exists_finite_clopen_cover obtain ⟨W, hWle, hWun, hWd⟩ := Fintype.exists_disjointed_le V simp only [← SetLike.coe_set_eq, Clopens.coe_finset_sup, Finset.mem_univ, iUnion_true] at hWun let t : Finset (Fin n) := {j | W j ≠ ⊥} refine ⟨#t, fun k ↦ W (t.equivFin.symm k), fun k ↦ ⟨?_, ?_⟩, fun x hx ↦ ?_, ?_⟩ · exact (Finset.mem_filter.mp (t.equivFin.symm k).2).2 · exact match hVle (t.equivFin.symm k) with | ⟨i, hi⟩ => ⟨i, subset_trans (hWle _) hi⟩ · obtain ⟨j, hj⟩ := mem_iUnion.mp <| (hWun ▸ hVun) hx have : W j ≠ ⊥ := by simpa [← SetLike.coe_ne_coe, ← Set.nonempty_iff_ne_empty] using ⟨x, hj⟩ exact mem_iUnion.mpr ⟨t.equivFin ⟨j, Finset.mem_filter.mpr ⟨Finset.mem_univ _, this⟩⟩, by simpa⟩ · exact hWd.comp_of_injective <| Subtype.val_injective.comp t.equivFin.symm.injective end TopologicalSpace.IsOpenCover namespace TopologicalSpace variable {X : Type*} [TopologicalSpace X] {S : Set (X × X)} /-- If `S` is any neighbourhood of the diagonal in a topological space `X`, any point of `X` has an open neighbourhood `U` such that `U ×ˢ U ⊆ S`. -/ lemma exists_open_prod_subset_of_mem_nhds_diagonal (hS : S ∈ nhdsSet (diagonal X)) (x : X) : ∃ U : Set X, IsOpen U ∧ x ∈ U ∧ U ×ˢ U ⊆ S := by have : S ∈ 𝓝 (x, x) := mem_nhdsSet_iff_forall.mp hS _ rfl obtain ⟨u, v, huo, hux, hvo, hvx, H⟩ := by rwa [mem_nhds_prod_iff'] at this exact ⟨_, huo.inter hvo, ⟨hux, hvx⟩, fun p hp ↦ H ⟨hp.1.1, hp.2.2⟩⟩ variable [CompactSpace X] /-- If `S` is any neighbourhood of the diagonal in a compact topological space `X`, then there exists a finite cover of `X` by opens `U i` such that `U i ×ˢ U i ⊆ S` for all `i`. That the indexing set is a finset of `X` is an artifact of the proof; it could be any finite type. -/ lemma exists_finite_open_cover_prod_subset_of_mem_nhds_diagonal_of_compact (hS : S ∈ nhdsSet (diagonal X)) : ∃ (t : Finset X) (U : t → Opens X), IsOpenCover U ∧ ∀ i, (U i : Set X) ×ˢ U i ⊆ S := by choose U hUo hUx hUp using exists_open_prod_subset_of_mem_nhds_diagonal hS obtain ⟨t, ht⟩ := isCompact_univ.elim_finite_subcover _ hUo (fun x _ ↦ mem_iUnion.mpr ⟨_, hUx x⟩) refine ⟨t, fun i ↦ ⟨_, hUo i⟩, .of_sets _ ?_, (hUp ·)⟩ simpa [iUnion_subtype, ← univ_subset_iff] using ht variable [TotallyDisconnectedSpace X] [T2Space X] /-- If `S` is any neighbourhood of the diagonal in a profinite topological space `X`, then there exists a finite cover of `X` by disjoint nonempty clopens `U i` with `U i ×ˢ U i ⊆ S` for all `i`. -/ private lemma exists_finite_disjoint_nonempty_clopen_cover_of_mem_nhds_diagonal_of_profinite (hS : S ∈ nhdsSet (diagonal X)) : ∃ (n : ℕ) (D : Fin n → Clopens X), (∀ i, D i ≠ ⊥) ∧ (∀ i, ∀ y ∈ D i, ∀ z ∈ D i, (y, z) ∈ S) ∧ (univ : Set X) ⊆ ⋃ i, D i ∧ Pairwise (Disjoint on D) := by obtain ⟨t, U, hUc, hUS⟩ := exists_finite_open_cover_prod_subset_of_mem_nhds_diagonal_of_compact hS -- Now refine it to a disjoint covering. obtain ⟨n, W, hW₁, hW₂, hW₃⟩ := hUc.exists_finite_nonempty_disjoint_clopen_cover refine ⟨n, W, fun j ↦ (hW₁ j).1, fun j y hy z hz ↦ ?_, hW₂, hW₃⟩ exact match (hW₁ j).2 with | ⟨i, hi⟩ => hUS i ⟨hi hy, hi hz⟩ end TopologicalSpace namespace ContinuousMap variable {X V : Type*} [TopologicalSpace X] [TopologicalSpace V] [TotallyDisconnectedSpace X] [T2Space X] [CompactSpace X] {S : Set (V × V)} (f : C(X, V)) /-- For any continuous function `f : X → V`, with `X` profinite, and `S` a neighbourhood of the diagonal in `V × V`, there exists a finite cover of `X` by pairwise-disjoint nonempty clopens, on each of which `f` varies within `S`. -/ lemma exists_disjoint_nonempty_clopen_cover_of_mem_nhds_diagonal (hS : S ∈ nhdsSet (diagonal V)) : ∃ (n : ℕ) (D : Fin n → Clopens X), (∀ i, D i ≠ ⊥) ∧ (∀ i, ∀ y ∈ D i, ∀ z ∈ D i, (f y, f z) ∈ S) ∧ (univ : Set X) ⊆ ⋃ i, D i ∧ Pairwise (Disjoint on D) := by have : (f.prodMap f) ⁻¹' S ∈ nhdsSet (diagonal X) := by rw [mem_nhdsSet_iff_forall] at hS ⊢ rintro ⟨x, y⟩ (rfl : x = y) exact (map_continuous _).continuousAt.preimage_mem_nhds (hS _ rfl) exact exists_finite_disjoint_nonempty_clopen_cover_of_mem_nhds_diagonal_of_profinite this /-- For any continuous function `f : X → V`, with `X` profinite, and `S` a neighbourhood of the diagonal in `V × V`, the function `f` can be `S`-approximated by a function factoring through `Fin n`, for some `n`. -/ lemma exists_finite_approximation_of_mem_nhds_diagonal (hS : S ∈ nhdsSet (diagonal V)) : ∃ (n : ℕ) (g : X → Fin n) (h : Fin n → V), Continuous g ∧ ∀ x, (f x, h (g x)) ∈ S := by obtain ⟨n, E, hEne, hES, hEuniv, hEdis⟩ := exists_disjoint_nonempty_clopen_cover_of_mem_nhds_diagonal f hS have h_uniq (x) : ∃! i, x ∈ E i := by refine match mem_iUnion.mp (hEuniv <| mem_univ x) with | ⟨i, hi⟩ => ⟨i, hi, fun j hj ↦ hEdis.eq ?_⟩ simpa [← Clopens.coe_disjoint, not_disjoint_iff] using ⟨x, hj, hi⟩ choose g hg hg' using h_uniq -- for each `x`, `g x` is the unique `i` such that `x ∈ E i` have h_ex (i) : ∃ x, x ∈ E i := by simpa [← SetLike.coe_set_eq, ← nonempty_iff_ne_empty] using hEne i choose r hr using h_ex -- for each `i`, choose an `r i ∈ E i` refine ⟨n, g, f ∘ r, continuous_discrete_rng.mpr fun j ↦ ?_, fun x ↦ (hES _) _ (hg _) _ (hr _)⟩ convert (E j).isOpen exact Set.ext fun x ↦ ⟨fun hj ↦ hj ▸ hg x, fun hx ↦ (hg' _ _ hx).symm⟩ /-- If `f` is a continuous map from a profinite space to a topological space with a commutative monoid structure, then we can approximate `f` by finite products of indicator functions of clopen sets. (Note no compatibility is assumed between the monoid structure on `V` and the topology.) -/ @[to_additive /-- If `f` is a continuous map from a profinite space to a topological space with a commutative additive monoid structure, then we can approximate `f` by finite sums of indicator functions of clopen sets. (Note no compatibility is assumed between the monoid structure on `V` and the topology.) -/] lemma exists_finite_sum_const_mulIndicator_approximation_of_mem_nhds_diagonal [CommMonoid V] (hS : S ∈ nhdsSet (diagonal V)) : ∃ (n : ℕ) (U : Fin n → Clopens X) (v : Fin n → V), ∀ x, (f x, ∏ n, mulIndicator (U n) (fun _ ↦ v n) x) ∈ S := by obtain ⟨n, g, h, hg, hgh⟩ := exists_finite_approximation_of_mem_nhds_diagonal f hS refine ⟨n, fun i ↦ ⟨_, (isClopen_discrete {i}).preimage hg⟩, h, fun x ↦ ?_⟩ convert hgh x exact (Fintype.prod_eq_single _ fun i hi ↦ mulIndicator_of_notMem hi.symm _).trans (mulIndicator_of_mem rfl _) end ContinuousMap
.lake/packages/mathlib/Mathlib/Topology/Separation/Connected.lean
import Mathlib.Topology.Separation.Basic import Mathlib.Topology.Connected.TotallyDisconnected /-! # Interaction of separation properties with connectedness properties -/ variable {X : Type*} [TopologicalSpace X] open Filter Set open scoped Topology -- see Note [lower instance priority] instance (priority := 100) TotallyDisconnectedSpace.t1Space [h : TotallyDisconnectedSpace X] : T1Space X := by rw [((t1Space_TFAE X).out 0 1 :)] intro x rw [← totallyDisconnectedSpace_iff_connectedComponent_singleton.mp h x] exact isClosed_connectedComponent theorem PreconnectedSpace.trivial_of_discrete [PreconnectedSpace X] [DiscreteTopology X] : Subsingleton X := by by_contra! h rcases h with ⟨x, y, hxy⟩ rw [Ne, ← mem_singleton_iff, (isClopen_discrete _).eq_univ <| singleton_nonempty y] at hxy exact hxy (mem_univ x) theorem IsPreconnected.infinite_of_nontrivial [T1Space X] {s : Set X} (h : IsPreconnected s) (hs : s.Nontrivial) : s.Infinite := by refine mt (fun hf => (subsingleton_coe s).mp ?_) (not_subsingleton_iff.mpr hs) haveI := @Finite.instDiscreteTopology s _ _ hf.to_subtype exact @PreconnectedSpace.trivial_of_discrete _ _ (Subtype.preconnectedSpace h) _ theorem PreconnectedSpace.infinite [PreconnectedSpace X] [Nontrivial X] [T1Space X] : Infinite X := infinite_univ_iff.mp <| isPreconnected_univ.infinite_of_nontrivial nontrivial_univ /-- A non-trivial connected T1 space has no isolated points. -/ instance (priority := 100) ConnectedSpace.neBot_nhdsWithin_compl_of_nontrivial_of_t1space [ConnectedSpace X] [Nontrivial X] [T1Space X] (x : X) : NeBot (𝓝[≠] x) := by by_contra contra rw [not_neBot, ← isOpen_singleton_iff_punctured_nhds] at contra replace contra := nonempty_inter isOpen_compl_singleton contra (compl_union_self _) (Set.nonempty_compl_of_nontrivial _) (singleton_nonempty _) simp [compl_inter_self {x}] at contra
.lake/packages/mathlib/Mathlib/Topology/Separation/NotNormal.lean
import Mathlib.Analysis.Real.Cardinality import Mathlib.Topology.TietzeExtension /-! # Not normal topological spaces In this file we prove (see `IsClosed.not_normal_of_continuum_le_mk`) that a separable space with a discrete subspace of cardinality continuum is not a normal topological space. -/ open Set Function Cardinal Topology TopologicalSpace universe u variable {X : Type u} [TopologicalSpace X] [SeparableSpace X] /-- Let `s` be a closed set in a separable normal space. If the induced topology on `s` is discrete, then `s` has cardinality less than continuum. The proof follows https://en.wikipedia.org/wiki/Moore_plane#Proof_that_the_Moore_plane_is_not_normal -/ theorem IsClosed.mk_lt_continuum [NormalSpace X] {s : Set X} (hs : IsClosed s) [DiscreteTopology s] : #s < 𝔠 := by -- Proof by contradiction: assume `𝔠 ≤ #s` by_contra! h -- Choose a countable dense set `t : Set X` rcases exists_countable_dense X with ⟨t, htc, htd⟩ haveI := htc.to_subtype -- To obtain a contradiction, we will prove `2 ^ 𝔠 ≤ 𝔠`. refine (Cardinal.cantor 𝔠).not_ge ?_ calc -- Any function `s → ℝ` is continuous, hence `2 ^ 𝔠 ≤ #C(s, ℝ)` 2 ^ 𝔠 ≤ #C(s, ℝ) := by rw [ContinuousMap.equivFnOfDiscrete.cardinal_eq, mk_arrow, mk_real, lift_continuum, lift_uzero] exact (power_le_power_left two_ne_zero h).trans (power_le_power_right (nat_lt_continuum 2).le) -- By the Tietze Extension Theorem, any function `f : C(s, ℝ)` can be extended to `C(X, ℝ)`, -- hence `#C(s, ℝ) ≤ #C(X, ℝ)` _ ≤ #C(X, ℝ) := by choose f hf using ContinuousMap.exists_restrict_eq (Y := ℝ) hs have hfi : Injective f := LeftInverse.injective hf exact mk_le_of_injective hfi -- Since `t` is dense, restriction `C(X, ℝ) → C(t, ℝ)` is injective, hence `#C(X, ℝ) ≤ #C(t, ℝ)` _ ≤ #C(t, ℝ) := mk_le_of_injective <| ContinuousMap.injective_restrict htd _ ≤ #(t → ℝ) := mk_le_of_injective DFunLike.coe_injective -- Since `t` is countable, we have `#(t → ℝ) ≤ 𝔠` _ ≤ 𝔠 := by rw [mk_arrow, mk_real, lift_uzero, lift_continuum, continuum, ← power_mul] exact power_le_power_left two_ne_zero mk_le_aleph0 /-- Let `s` be a closed set in a separable space. If the induced topology on `s` is discrete and `s` has cardinality at least continuum, then the ambient space is not a normal space. -/ theorem IsClosed.not_normal_of_continuum_le_mk {s : Set X} (hs : IsClosed s) [DiscreteTopology s] (hmk : 𝔠 ≤ #s) : ¬NormalSpace X := fun _ ↦ hs.mk_lt_continuum.not_ge hmk
.lake/packages/mathlib/Mathlib/Topology/FiberBundle/IsHomeomorphicTrivialBundle.lean
import Mathlib.Topology.Constructions.SumProd /-! # Maps equivariantly-homeomorphic to projection in a product This file contains the definition `IsHomeomorphicTrivialFiberBundle F p`, a Prop saying that a map `p : Z → B` between topological spaces is a "trivial fiber bundle" in the sense that there exists a homeomorphism `h : Z ≃ₜ B × F` such that `proj x = (h x).1`. This is an abstraction which is occasionally convenient in showing that a map is open, a quotient map, etc. This material was formerly linked to the main definition of fiber bundles, but after a series of refactors, there is no longer a direct connection. -/ open Topology variable {B : Type*} (F : Type*) {Z : Type*} [TopologicalSpace B] [TopologicalSpace F] [TopologicalSpace Z] /-- A trivial fiber bundle with fiber `F` over a base `B` is a space `Z` projecting on `B` for which there exists a homeomorphism to `B × F` that sends `proj` to `Prod.fst`. -/ def IsHomeomorphicTrivialFiberBundle (proj : Z → B) : Prop := ∃ e : Z ≃ₜ B × F, ∀ x, (e x).1 = proj x namespace IsHomeomorphicTrivialFiberBundle variable {F} {proj : Z → B} protected theorem proj_eq (h : IsHomeomorphicTrivialFiberBundle F proj) : ∃ e : Z ≃ₜ B × F, proj = Prod.fst ∘ e := ⟨h.choose, (funext h.choose_spec).symm⟩ /-- The projection from a trivial fiber bundle to its base is surjective. -/ protected theorem surjective_proj [Nonempty F] (h : IsHomeomorphicTrivialFiberBundle F proj) : Function.Surjective proj := by obtain ⟨e, rfl⟩ := h.proj_eq exact Prod.fst_surjective.comp e.surjective /-- The projection from a trivial fiber bundle to its base is continuous. -/ protected theorem continuous_proj (h : IsHomeomorphicTrivialFiberBundle F proj) : Continuous proj := by obtain ⟨e, rfl⟩ := h.proj_eq; exact continuous_fst.comp e.continuous /-- The projection from a trivial fiber bundle to its base is open. -/ protected theorem isOpenMap_proj (h : IsHomeomorphicTrivialFiberBundle F proj) : IsOpenMap proj := by obtain ⟨e, rfl⟩ := h.proj_eq; exact isOpenMap_fst.comp e.isOpenMap /-- The projection from a trivial fiber bundle to its base is open. -/ protected theorem isQuotientMap_proj [Nonempty F] (h : IsHomeomorphicTrivialFiberBundle F proj) : IsQuotientMap proj := h.isOpenMap_proj.isQuotientMap h.continuous_proj h.surjective_proj end IsHomeomorphicTrivialFiberBundle /-- The first projection in a product is a trivial fiber bundle. -/ theorem isHomeomorphicTrivialFiberBundle_fst : IsHomeomorphicTrivialFiberBundle F (Prod.fst : B × F → B) := ⟨Homeomorph.refl _, fun _x => rfl⟩ /-- The second projection in a product is a trivial fiber bundle. -/ theorem isHomeomorphicTrivialFiberBundle_snd : IsHomeomorphicTrivialFiberBundle F (Prod.snd : F × B → B) := ⟨Homeomorph.prodComm _ _, fun _x => rfl⟩
.lake/packages/mathlib/Mathlib/Topology/FiberBundle/Basic.lean
import Mathlib.Topology.FiberBundle.Trivialization import Mathlib.Topology.Order.LeftRightNhds /-! # Fiber bundles Mathematically, a (topological) fiber bundle with fiber `F` over a base `B` is a space projecting on `B` for which the fibers are all homeomorphic to `F`, such that the local situation around each point is a direct product. In our formalism, a fiber bundle is by definition the type `Bundle.TotalSpace F E` where `E : B → Type*` is a function associating to `x : B` the fiber over `x`. This type `Bundle.TotalSpace F E` is a type of pairs `⟨proj : B, snd : E proj⟩`. To have a fiber bundle structure on `Bundle.TotalSpace F E`, one should additionally have the following data: * `F` should be a topological space; * There should be a topology on `Bundle.TotalSpace F E`, for which the projection to `B` is a fiber bundle with fiber `F` (in particular, each fiber `E x` is homeomorphic to `F`); * For each `x`, the fiber `E x` should be a topological space, and the injection from `E x` to `Bundle.TotalSpace F E` should be an embedding; * There should be a distinguished set of bundle trivializations, the "trivialization atlas" * There should be a choice of bundle trivialization at each point, which belongs to this atlas. If all these conditions are satisfied, we register the typeclass `FiberBundle F E`. It is in general nontrivial to construct a fiber bundle. A way is to start from the knowledge of how changes of local trivializations act on the fiber. From this, one can construct the total space of the bundle and its topology by a suitable gluing construction. The main content of this file is an implementation of this construction: starting from an object of type `FiberBundleCore` registering the trivialization changes, one gets the corresponding fiber bundle and projection. Similarly we implement the object `FiberPrebundle` which allows to define a topological fiber bundle from trivializations given as partial equivalences with minimum additional properties. ## Main definitions ### Basic definitions * `FiberBundle F E` : Structure saying that `E : B → Type*` is a fiber bundle with fiber `F`. ### Construction of a bundle from trivializations * `Bundle.TotalSpace F E` is the type of pairs `(proj : B, snd : E proj)`. We can use the extra argument `F` to construct topology on the total space. * `FiberBundleCore ι B F` : structure registering how changes of coordinates act on the fiber `F` above open subsets of `B`, where local trivializations are indexed by `ι`. Let `Z : FiberBundleCore ι B F`. Then we define * `Z.Fiber x` : the fiber above `x`, homeomorphic to `F` (and defeq to `F` as a type). * `Z.TotalSpace` : the total space of `Z`, defined as `Bundle.TotalSpace F Z.Fiber` with a custom topology. * `Z.proj` : projection from `Z.TotalSpace` to `B`. It is continuous. * `Z.localTriv i` : for `i : ι`, bundle trivialization above the set `Z.baseSet i`, which is an open set in `B`. * `FiberPrebundle F E` : structure registering a cover of prebundle trivializations and requiring that the relative transition maps are open partial homeomorphisms. * `FiberPrebundle.totalSpaceTopology a` : natural topology of the total space, making the prebundle into a bundle. ## Implementation notes ### Data vs mixins For both fiber and vector bundles, one faces a choice: should the definition state the *existence* of local trivializations (a propositional typeclass), or specify a fixed atlas of trivializations (a typeclass containing data)? In their initial mathlib implementations, both fiber and vector bundles were defined propositionally. For vector bundles, this turns out to be mathematically wrong: in infinite dimension, the transition function between two trivializations is not automatically continuous as a map from the base `B` to the endomorphisms `F →L[R] F` of the fiber (considered with the operator-norm topology), and so the definition needs to be modified by restricting consideration to a family of trivializations (constituting the data) which are all mutually-compatible in this sense. The PRs https://github.com/leanprover-community/mathlib/pull/13052 and https://github.com/leanprover-community/mathlib/pull/13175 implemented this change. There is still the choice about whether to hold this data at the level of fiber bundles or of vector bundles. As of PR https://github.com/leanprover-community/mathlib/pull/17505, the data is all held in `FiberBundle`, with `VectorBundle` a (propositional) mixin stating fiberwise-linearity. This allows bundles to carry instances of typeclasses in which the scalar field, `R`, does not appear as a parameter. Notably, we would like a vector bundle over `R` with fiber `F` over base `B` to be a `ChartedSpace (B × F)`, with the trivializations providing the charts. This would be a dangerous instance for typeclass inference, because `R` does not appear as a parameter in `ChartedSpace (B × F)`. But if the data of the trivializations is held in `FiberBundle`, then a fiber bundle with fiber `F` over base `B` can be a `ChartedSpace (B × F)`, and this is safe for typeclass inference. We expect that this choice of definition will also streamline constructions of fiber bundles with similar underlying structure (e.g., the same bundle being both a real and complex vector bundle). ### Core construction A fiber bundle with fiber `F` over a base `B` is a family of spaces isomorphic to `F`, indexed by `B`, which is locally trivial in the following sense: there is a covering of `B` by open sets such that, on each such open set `s`, the bundle is isomorphic to `s × F`. To construct a fiber bundle formally, the main data is what happens when one changes trivializations from `s × F` to `s' × F` on `s ∩ s'`: one should get a family of homeomorphisms of `F`, depending continuously on the base point, satisfying basic compatibility conditions (cocycle property). Useful classes of bundles can then be specified by requiring that these homeomorphisms of `F` belong to some subgroup, preserving some structure (the "structure group of the bundle"): then these structures are inherited by the fibers of the bundle. Given such trivialization change data (encoded below in a structure called `FiberBundleCore`), one can construct the fiber bundle. The intrinsic canonical mathematical construction is the following. The fiber above `x` is the disjoint union of `F` over all trivializations, modulo the gluing identifications: one gets a fiber which is isomorphic to `F`, but non-canonically (each choice of one of the trivializations around `x` gives such an isomorphism). Given a trivialization over a set `s`, one gets an isomorphism between `s × F` and `proj^{-1} s`, by using the identification corresponding to this trivialization. One chooses the topology on the bundle that makes all of these into homeomorphisms. For the practical implementation, it turns out to be more convenient to avoid completely the gluing and quotienting construction above, and to declare above each `x` that the fiber is `F`, but thinking that it corresponds to the `F` coming from the choice of one trivialization around `x`. This has several practical advantages: * without any work, one gets a topological space structure on the fiber. And if `F` has more structure it is inherited for free by the fiber. * In the case of the tangent bundle of manifolds, this implies that on vector spaces the derivative (from `F` to `F`) and the manifold derivative (from `TangentSpace I x` to `TangentSpace I' (f x)`) are equal. A drawback is that some silly constructions will typecheck: in the case of the tangent bundle, one can add two vectors in different tangent spaces (as they both are elements of `F` from the point of view of Lean). To solve this, one could mark the tangent space as irreducible, but then one would lose the identification of the tangent space to `F` with `F`. There is however a big advantage of this situation: even if Lean cannot check that two basepoints are defeq, it will accept the fact that the tangent spaces are the same. For instance, if two maps `f` and `g` are locally inverse to each other, one can express that the composition of their derivatives is the identity of `TangentSpace I x`. One could fear issues as this composition goes from `TangentSpace I x` to `TangentSpace I (g (f x))` (which should be the same, but should not be obvious to Lean as it does not know that `g (f x) = x`). As these types are the same to Lean (equal to `F`), there are in fact no dependent type difficulties here! For this construction of a fiber bundle from a `FiberBundleCore`, we should thus choose for each `x` one specific trivialization around it. We include this choice in the definition of the `FiberBundleCore`, as it makes some constructions more functorial and it is a nice way to say that the trivializations cover the whole space `B`. With this definition, the type of the fiber bundle space constructed from the core data is `Bundle.TotalSpace F (fun b : B ↦ F)`, but the topology is not the product one, in general. We also take the indexing type (indexing all the trivializations) as a parameter to the fiber bundle core: it could always be taken as a subtype of all the maps from open subsets of `B` to continuous maps of `F`, but in practice it will sometimes be something else. For instance, on a manifold, one will use the set of charts as a good parameterization for the trivializations of the tangent bundle. Or for the pullback of a `FiberBundleCore`, the indexing type will be the same as for the initial bundle. ## Tags Fiber bundle, topological bundle, structure group -/ variable {ι B F X : Type*} [TopologicalSpace X] open TopologicalSpace Filter Set Bundle Topology /-! ### General definition of fiber bundles -/ section FiberBundle variable (F) variable [TopologicalSpace B] [TopologicalSpace F] (E : B → Type*) [TopologicalSpace (TotalSpace F E)] [∀ b, TopologicalSpace (E b)] /-- A (topological) fiber bundle with fiber `F` over a base `B` is a space projecting on `B` for which the fibers are all homeomorphic to `F`, such that the local situation around each point is a direct product. -/ class FiberBundle where totalSpaceMk_isInducing' : ∀ b : B, IsInducing (@TotalSpace.mk B F E b) trivializationAtlas' : Set (Trivialization F (π F E)) trivializationAt' : B → Trivialization F (π F E) mem_baseSet_trivializationAt' : ∀ b : B, b ∈ (trivializationAt' b).baseSet trivialization_mem_atlas' : ∀ b : B, trivializationAt' b ∈ trivializationAtlas' namespace FiberBundle variable [FiberBundle F E] (b : B) theorem totalSpaceMk_isInducing : IsInducing (@TotalSpace.mk B F E b) := totalSpaceMk_isInducing' b /-- Atlas of a fiber bundle. -/ abbrev trivializationAtlas : Set (Trivialization F (π F E)) := trivializationAtlas' /-- Trivialization of a fiber bundle at a point. -/ abbrev trivializationAt : Trivialization F (π F E) := trivializationAt' b theorem mem_baseSet_trivializationAt : b ∈ (trivializationAt F E b).baseSet := mem_baseSet_trivializationAt' b theorem trivialization_mem_atlas : trivializationAt F E b ∈ trivializationAtlas F E := trivialization_mem_atlas' b end FiberBundle export FiberBundle (totalSpaceMk_isInducing trivializationAtlas trivializationAt mem_baseSet_trivializationAt trivialization_mem_atlas) variable {F} variable {E} /-- Given a type `E` equipped with a fiber bundle structure, this is a `Prop` typeclass for trivializations of `E`, expressing that a trivialization is in the designated atlas for the bundle. This is needed because lemmas about the linearity of trivializations or the continuity (as functions to `F →L[R] F`, where `F` is the model fiber) of the transition functions are only expected to hold for trivializations in the designated atlas. -/ @[mk_iff] class MemTrivializationAtlas [FiberBundle F E] (e : Trivialization F (π F E)) : Prop where out : e ∈ trivializationAtlas F E instance [FiberBundle F E] (b : B) : MemTrivializationAtlas (trivializationAt F E b) where out := trivialization_mem_atlas F E b namespace FiberBundle variable (F) variable [FiberBundle F E] theorem map_proj_nhds (x : TotalSpace F E) : map (π F E) (𝓝 x) = 𝓝 x.proj := (trivializationAt F E x.proj).map_proj_nhds <| (trivializationAt F E x.proj).mem_source.2 <| mem_baseSet_trivializationAt F E x.proj variable (E) /-- The projection from a fiber bundle to its base is continuous. -/ @[continuity] theorem continuous_proj : Continuous (π F E) := continuous_iff_continuousAt.2 fun x => (map_proj_nhds F x).le /-- The projection from a fiber bundle to its base is an open map. -/ theorem isOpenMap_proj : IsOpenMap (π F E) := IsOpenMap.of_nhds_le fun x => (map_proj_nhds F x).ge /-- The projection from a fiber bundle with a nonempty fiber to its base is a surjective map. -/ theorem surjective_proj [Nonempty F] : Function.Surjective (π F E) := fun b => let ⟨p, _, hpb⟩ := (trivializationAt F E b).proj_surjOn_baseSet (mem_baseSet_trivializationAt F E b) ⟨p, hpb⟩ /-- The projection from a fiber bundle with a nonempty fiber to its base is a quotient map. -/ theorem isQuotientMap_proj [Nonempty F] : IsQuotientMap (π F E) := (isOpenMap_proj F E).isQuotientMap (continuous_proj F E) (surjective_proj F E) theorem continuous_totalSpaceMk (x : B) : Continuous (@TotalSpace.mk B F E x) := (totalSpaceMk_isInducing F E x).continuous theorem totalSpaceMk_isEmbedding (x : B) : IsEmbedding (@TotalSpace.mk B F E x) := ⟨totalSpaceMk_isInducing F E x, TotalSpace.mk_injective x⟩ theorem totalSpaceMk_isClosedEmbedding [T1Space B] (x : B) : IsClosedEmbedding (@TotalSpace.mk B F E x) := ⟨totalSpaceMk_isEmbedding F E x, by rw [TotalSpace.range_mk] exact isClosed_singleton.preimage <| continuous_proj F E⟩ variable {E F} @[simp, mfld_simps] theorem mem_trivializationAt_proj_source {x : TotalSpace F E} : x ∈ (trivializationAt F E x.proj).source := (Trivialization.mem_source _).mpr <| mem_baseSet_trivializationAt F E x.proj theorem trivializationAt_proj_fst {x : TotalSpace F E} : ((trivializationAt F E x.proj) x).1 = x.proj := Trivialization.coe_fst' _ <| mem_baseSet_trivializationAt F E x.proj variable (F) open Trivialization /-- Characterization of continuous functions (at a point, within a set) into a fiber bundle. -/ theorem continuousWithinAt_totalSpace (f : X → TotalSpace F E) {s : Set X} {x₀ : X} : ContinuousWithinAt f s x₀ ↔ ContinuousWithinAt (fun x => (f x).proj) s x₀ ∧ ContinuousWithinAt (fun x => ((trivializationAt F E (f x₀).proj) (f x)).2) s x₀ := (trivializationAt F E (f x₀).proj).tendsto_nhds_iff mem_trivializationAt_proj_source /-- Characterization of continuous functions (at a point) into a fiber bundle. -/ theorem continuousAt_totalSpace (f : X → TotalSpace F E) {x₀ : X} : ContinuousAt f x₀ ↔ ContinuousAt (fun x => (f x).proj) x₀ ∧ ContinuousAt (fun x => ((trivializationAt F E (f x₀).proj) (f x)).2) x₀ := (trivializationAt F E (f x₀).proj).tendsto_nhds_iff mem_trivializationAt_proj_source end FiberBundle variable (F) variable (E) /-- If `E` is a fiber bundle over a conditionally complete linear order, then it is trivial over any closed interval. -/ theorem FiberBundle.exists_trivialization_Icc_subset [ConditionallyCompleteLinearOrder B] [OrderTopology B] [FiberBundle F E] (a b : B) : ∃ e : Trivialization F (π F E), Icc a b ⊆ e.baseSet := by obtain ⟨ea, hea⟩ : ∃ ea : Trivialization F (π F E), a ∈ ea.baseSet := ⟨trivializationAt F E a, mem_baseSet_trivializationAt F E a⟩ -- If `a < b`, then `[a, b] = ∅`, and the statement is trivial rcases lt_or_ge b a with _ | hab · exact ⟨ea, by simp [*]⟩ /- Let `s` be the set of points `x ∈ [a, b]` such that `E` is trivializable over `[a, x]`. We need to show that `b ∈ s`. Let `c = Sup s`. We will show that `c ∈ s` and `c = b`. -/ set s : Set B := { x ∈ Icc a b | ∃ e : Trivialization F (π F E), Icc a x ⊆ e.baseSet } have ha : a ∈ s := ⟨left_mem_Icc.2 hab, ea, by simp [hea]⟩ have sne : s.Nonempty := ⟨a, ha⟩ have hsb : b ∈ upperBounds s := fun x hx => hx.1.2 have sbd : BddAbove s := ⟨b, hsb⟩ set c := sSup s have hsc : IsLUB s c := isLUB_csSup sne sbd have hc : c ∈ Icc a b := ⟨hsc.1 ha, hsc.2 hsb⟩ obtain ⟨-, ec : Trivialization F (π F E), hec : Icc a c ⊆ ec.baseSet⟩ : c ∈ s := by rcases hc.1.eq_or_lt with heq | hlt · rwa [← heq] refine ⟨hc, ?_⟩ /- In order to show that `c ∈ s`, consider a trivialization `ec` of `proj` over a neighborhood of `c`. Its base set includes `(c', c]` for some `c' ∈ [a, c)`. -/ obtain ⟨ec, hc⟩ : ∃ ec : Trivialization F (π F E), c ∈ ec.baseSet := ⟨trivializationAt F E c, mem_baseSet_trivializationAt F E c⟩ obtain ⟨c', hc', hc'e⟩ : ∃ c' ∈ Ico a c, Ioc c' c ⊆ ec.baseSet := (mem_nhdsLE_iff_exists_mem_Ico_Ioc_subset hlt).1 (mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds ec.open_baseSet hc) /- Since `c' < c = Sup s`, there exists `d ∈ s ∩ (c', c]`. Let `ead` be a trivialization of `proj` over `[a, d]`. Then we can glue `ead` and `ec` into a trivialization over `[a, c]`. -/ obtain ⟨d, ⟨hdab, ead, had⟩, hd⟩ : ∃ d ∈ s, d ∈ Ioc c' c := hsc.exists_between hc'.2 refine ⟨ead.piecewiseLe ec d (had ⟨hdab.1, le_rfl⟩) (hc'e hd), subset_ite.2 ?_⟩ exact ⟨fun x hx => had ⟨hx.1.1, hx.2⟩, fun x hx => hc'e ⟨hd.1.trans (not_le.1 hx.2), hx.1.2⟩⟩ /- So, `c ∈ s`. Let `ec` be a trivialization of `proj` over `[a, c]`. If `c = b`, then we are done. Otherwise we show that `proj` can be trivialized over a larger interval `[a, d]`, `d ∈ (c, b]`, hence `c` is not an upper bound of `s`. -/ rcases hc.2.eq_or_lt with heq | hlt · exact ⟨ec, heq ▸ hec⟩ rsuffices ⟨d, hdcb, hd⟩ : ∃ d ∈ Ioc c b, ∃ e : Trivialization F (π F E), Icc a d ⊆ e.baseSet · exact ((hsc.1 ⟨⟨hc.1.trans hdcb.1.le, hdcb.2⟩, hd⟩).not_gt hdcb.1).elim /- Since the base set of `ec` is open, it includes `[c, d)` (hence, `[a, d)`) for some `d ∈ (c, b]`. -/ obtain ⟨d, hdcb, hd⟩ : ∃ d ∈ Ioc c b, Ico c d ⊆ ec.baseSet := (mem_nhdsGE_iff_exists_mem_Ioc_Ico_subset hlt).1 (mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds ec.open_baseSet (hec ⟨hc.1, le_rfl⟩)) have had : Ico a d ⊆ ec.baseSet := Ico_subset_Icc_union_Ico.trans (union_subset hec hd) by_cases he : Disjoint (Iio d) (Ioi c) · /- If `(c, d) = ∅`, then let `ed` be a trivialization of `proj` over a neighborhood of `d`. Then the disjoint union of `ec` restricted to `(-∞, d)` and `ed` restricted to `(c, ∞)` is a trivialization over `[a, d]`. -/ obtain ⟨ed, hed⟩ : ∃ ed : Trivialization F (π F E), d ∈ ed.baseSet := ⟨trivializationAt F E d, mem_baseSet_trivializationAt F E d⟩ refine ⟨d, hdcb, (ec.restrOpen (Iio d) isOpen_Iio).disjointUnion (ed.restrOpen (Ioi c) isOpen_Ioi) (he.mono inter_subset_right inter_subset_right), fun x hx => ?_⟩ rcases hx.2.eq_or_lt with (rfl | hxd) exacts [Or.inr ⟨hed, hdcb.1⟩, Or.inl ⟨had ⟨hx.1, hxd⟩, hxd⟩] · /- If `(c, d)` is nonempty, then take `d' ∈ (c, d)`. Since the base set of `ec` includes `[a, d)`, it includes `[a, d'] ⊆ [a, d)` as well. -/ rw [disjoint_left] at he push_neg at he rcases he with ⟨d', hdd' : d' < d, hd'c⟩ exact ⟨d', ⟨hd'c, hdd'.le.trans hdcb.2⟩, ec, (Icc_subset_Ico_right hdd').trans had⟩ end FiberBundle /-! ### Core construction for constructing fiber bundles -/ /-- Core data defining a locally trivial bundle with fiber `F` over a topological space `B`. Note that "bundle" is used in its mathematical sense. This is the (computer science) bundled version, i.e., all the relevant data is contained in the following structure. A family of local trivializations is indexed by a type `ι`, on open subsets `baseSet i` for each `i : ι`. Trivialization changes from `i` to `j` are given by continuous maps `coordChange i j` from `baseSet i ∩ baseSet j` to the set of homeomorphisms of `F`, but we express them as maps `B → F → F` and require continuity on `(baseSet i ∩ baseSet j) × F` to avoid the topology on the space of continuous maps on `F`. -/ structure FiberBundleCore (ι : Type*) (B : Type*) [TopologicalSpace B] (F : Type*) [TopologicalSpace F] where baseSet : ι → Set B isOpen_baseSet : ∀ i, IsOpen (baseSet i) indexAt : B → ι mem_baseSet_at : ∀ x, x ∈ baseSet (indexAt x) coordChange : ι → ι → B → F → F coordChange_self : ∀ i, ∀ x ∈ baseSet i, ∀ v, coordChange i i x v = v continuousOn_coordChange : ∀ i j, ContinuousOn (fun p : B × F => coordChange i j p.1 p.2) ((baseSet i ∩ baseSet j) ×ˢ univ) coordChange_comp : ∀ i j k, ∀ x ∈ baseSet i ∩ baseSet j ∩ baseSet k, ∀ v, (coordChange j k x) (coordChange i j x v) = coordChange i k x v namespace FiberBundleCore variable [TopologicalSpace B] [TopologicalSpace F] (Z : FiberBundleCore ι B F) /-- The index set of a fiber bundle core, as a convenience function for dot notation -/ @[nolint unusedArguments] def Index (_Z : FiberBundleCore ι B F) := ι /-- The base space of a fiber bundle core, as a convenience function for dot notation -/ @[nolint unusedArguments, reducible] def Base (_Z : FiberBundleCore ι B F) := B /-- The fiber of a fiber bundle core, as a convenience function for dot notation and typeclass inference -/ @[nolint unusedArguments] def Fiber (_ : FiberBundleCore ι B F) (_x : B) := F instance topologicalSpaceFiber (x : B) : TopologicalSpace (Z.Fiber x) := ‹_› /-- The total space of the fiber bundle, as a convenience function for dot notation. It is by definition equal to `Bundle.TotalSpace F Z.Fiber`. -/ abbrev TotalSpace := Bundle.TotalSpace F Z.Fiber /-- The projection from the total space of a fiber bundle core, on its base. -/ @[reducible, simp, mfld_simps] def proj : Z.TotalSpace → B := Bundle.TotalSpace.proj /-- Local homeomorphism version of the trivialization change. -/ def trivChange (i j : ι) : OpenPartialHomeomorph (B × F) (B × F) where source := (Z.baseSet i ∩ Z.baseSet j) ×ˢ univ target := (Z.baseSet i ∩ Z.baseSet j) ×ˢ univ toFun p := ⟨p.1, Z.coordChange i j p.1 p.2⟩ invFun p := ⟨p.1, Z.coordChange j i p.1 p.2⟩ map_source' p hp := by simpa using hp map_target' p hp := by simpa using hp left_inv' := by rintro ⟨x, v⟩ hx simp only [prodMk_mem_set_prod_eq, mem_inter_iff, and_true, mem_univ] at hx dsimp only rw [coordChange_comp, Z.coordChange_self] exacts [hx.1, ⟨⟨hx.1, hx.2⟩, hx.1⟩] right_inv' := by rintro ⟨x, v⟩ hx simp only [prodMk_mem_set_prod_eq, mem_inter_iff, and_true, mem_univ] at hx dsimp only rw [Z.coordChange_comp, Z.coordChange_self] · exact hx.2 · simp [hx] open_source := ((Z.isOpen_baseSet i).inter (Z.isOpen_baseSet j)).prod isOpen_univ open_target := ((Z.isOpen_baseSet i).inter (Z.isOpen_baseSet j)).prod isOpen_univ continuousOn_toFun := continuous_fst.continuousOn.prodMk (Z.continuousOn_coordChange i j) continuousOn_invFun := by simpa [inter_comm] using continuous_fst.continuousOn.prodMk (Z.continuousOn_coordChange j i) @[simp, mfld_simps] theorem mem_trivChange_source (i j : ι) (p : B × F) : p ∈ (Z.trivChange i j).source ↔ p.1 ∈ Z.baseSet i ∩ Z.baseSet j := by rw [trivChange, mem_prod] simp /-- Associate to a trivialization index `i : ι` the corresponding trivialization, i.e., a bijection between `proj ⁻¹ (baseSet i)` and `baseSet i × F`. As the fiber above `x` is `F` but read in the chart with index `index_at x`, the trivialization in the fiber above x is by definition the coordinate change from i to `index_at x`, so it depends on `x`. The local trivialization will ultimately be an open partial homeomorphism. For now, we only introduce the partial equivalence version, denoted with a prime. In further developments, avoid this auxiliary version, and use `Z.local_triv` instead. -/ def localTrivAsPartialEquiv (i : ι) : PartialEquiv Z.TotalSpace (B × F) where source := Z.proj ⁻¹' Z.baseSet i target := Z.baseSet i ×ˢ univ invFun p := ⟨p.1, Z.coordChange i (Z.indexAt p.1) p.1 p.2⟩ toFun p := ⟨p.1, Z.coordChange (Z.indexAt p.1) i p.1 p.2⟩ map_source' p hp := by simpa only [Set.mem_preimage, and_true, Set.mem_univ, Set.prodMk_mem_set_prod_eq] using hp map_target' p hp := by simpa only [Set.mem_preimage, and_true, Set.mem_univ, Set.mem_prod] using hp left_inv' := by rintro ⟨x, v⟩ hx replace hx : x ∈ Z.baseSet i := hx dsimp only rw [Z.coordChange_comp, Z.coordChange_self] <;> apply_rules [mem_baseSet_at, mem_inter] right_inv' := by rintro ⟨x, v⟩ hx simp only [prodMk_mem_set_prod_eq, and_true, mem_univ] at hx dsimp only rw [Z.coordChange_comp, Z.coordChange_self] exacts [hx, ⟨⟨hx, Z.mem_baseSet_at _⟩, hx⟩] variable (i : ι) theorem mem_localTrivAsPartialEquiv_source (p : Z.TotalSpace) : p ∈ (Z.localTrivAsPartialEquiv i).source ↔ p.1 ∈ Z.baseSet i := Iff.rfl theorem mem_localTrivAsPartialEquiv_target (p : B × F) : p ∈ (Z.localTrivAsPartialEquiv i).target ↔ p.1 ∈ Z.baseSet i := by rw [localTrivAsPartialEquiv, mem_prod] simp only [and_true, mem_univ] theorem localTrivAsPartialEquiv_apply (p : Z.TotalSpace) : (Z.localTrivAsPartialEquiv i) p = ⟨p.1, Z.coordChange (Z.indexAt p.1) i p.1 p.2⟩ := rfl /-- The composition of two local trivializations is the trivialization change Z.triv_change i j. -/ theorem localTrivAsPartialEquiv_trans (i j : ι) : (Z.localTrivAsPartialEquiv i).symm.trans (Z.localTrivAsPartialEquiv j) ≈ (Z.trivChange i j).toPartialEquiv := by constructor · ext x simp only [mem_localTrivAsPartialEquiv_target, mfld_simps] rfl · rintro ⟨x, v⟩ hx simp only [trivChange, localTrivAsPartialEquiv, PartialEquiv.symm, Prod.mk_inj, prodMk_mem_set_prod_eq, PartialEquiv.trans_source, mem_inter_iff, mem_preimage, proj, mem_univ, (· ∘ ·), PartialEquiv.coe_trans] at hx ⊢ simp only [Z.coordChange_comp, hx, mem_inter_iff, and_self_iff, mem_baseSet_at] /-- Topological structure on the total space of a fiber bundle created from core, designed so that all the local trivialization are continuous. -/ instance toTopologicalSpace : TopologicalSpace (Bundle.TotalSpace F Z.Fiber) := TopologicalSpace.generateFrom <| ⋃ (i : ι) (s : Set (B × F)) (_ : IsOpen s), {(Z.localTrivAsPartialEquiv i).source ∩ Z.localTrivAsPartialEquiv i ⁻¹' s} variable (b : B) (a : F) theorem open_source' (i : ι) : IsOpen (Z.localTrivAsPartialEquiv i).source := by apply TopologicalSpace.GenerateOpen.basic simp only [exists_prop, mem_iUnion, mem_singleton_iff] refine ⟨i, Z.baseSet i ×ˢ univ, (Z.isOpen_baseSet i).prod isOpen_univ, ?_⟩ ext p simp only [localTrivAsPartialEquiv_apply, prodMk_mem_set_prod_eq, mem_inter_iff, and_self_iff, mem_localTrivAsPartialEquiv_source, and_true, mem_univ, mem_preimage] /-- Extended version of the local trivialization of a fiber bundle constructed from core, registering additionally in its type that it is a local bundle trivialization. -/ def localTriv (i : ι) : Trivialization F Z.proj where baseSet := Z.baseSet i open_baseSet := Z.isOpen_baseSet i source_eq := rfl target_eq := rfl proj_toFun p _ := by simp only [mfld_simps] rfl open_source := Z.open_source' i open_target := (Z.isOpen_baseSet i).prod isOpen_univ continuousOn_toFun := by rw [continuousOn_open_iff (Z.open_source' i)] intro s s_open apply TopologicalSpace.GenerateOpen.basic simp only [exists_prop, mem_iUnion, mem_singleton_iff] exact ⟨i, s, s_open, rfl⟩ continuousOn_invFun := by refine continuousOn_isOpen_of_generateFrom fun t ht ↦ ?_ simp only [exists_prop, mem_iUnion, mem_singleton_iff] at ht obtain ⟨j, s, s_open, ts⟩ : ∃ j s, IsOpen s ∧ t = (localTrivAsPartialEquiv Z j).source ∩ localTrivAsPartialEquiv Z j ⁻¹' s := ht rw [ts] simp only [preimage_inter] let e := Z.localTrivAsPartialEquiv i let e' := Z.localTrivAsPartialEquiv j let f := e.symm.trans e' have : IsOpen (f.source ∩ f ⁻¹' s) := by rw [PartialEquiv.EqOnSource.source_inter_preimage_eq (Z.localTrivAsPartialEquiv_trans i j)] exact (continuousOn_open_iff (Z.trivChange i j).open_source).1 (Z.trivChange i j).continuousOn _ s_open convert this using 1 dsimp [f, PartialEquiv.trans_source] rw [← preimage_comp, inter_assoc] toPartialEquiv := Z.localTrivAsPartialEquiv i /-- Preferred local trivialization of a fiber bundle constructed from core, at a given point, as a bundle trivialization -/ def localTrivAt (b : B) : Trivialization F (π F Z.Fiber) := Z.localTriv (Z.indexAt b) @[simp, mfld_simps] theorem localTrivAt_def (b : B) : Z.localTriv (Z.indexAt b) = Z.localTrivAt b := rfl theorem localTrivAt_snd (b : B) (p) : (Z.localTrivAt b p).2 = Z.coordChange (Z.indexAt p.1) (Z.indexAt b) p.1 p.2 := rfl /-- If an element of `F` is invariant under all coordinate changes, then one can define a corresponding section of the fiber bundle, which is continuous. This applies in particular to the zero section of a vector bundle. Another example (not yet defined) would be the identity section of the endomorphism bundle of a vector bundle. -/ theorem continuous_const_section (v : F) (h : ∀ i j, ∀ x ∈ Z.baseSet i ∩ Z.baseSet j, Z.coordChange i j x v = v) : Continuous (show B → Z.TotalSpace from fun x => ⟨x, v⟩) := by refine continuous_iff_continuousAt.2 fun x => ?_ have A : Z.baseSet (Z.indexAt x) ∈ 𝓝 x := IsOpen.mem_nhds (Z.isOpen_baseSet (Z.indexAt x)) (Z.mem_baseSet_at x) refine ((Z.localTrivAt x).toOpenPartialHomeomorph.continuousAt_iff_continuousAt_comp_left ?_).2 ?_ · exact A · apply continuousAt_id.prodMk simp only [mfld_simps] have : ContinuousOn (fun _ : B => v) (Z.baseSet (Z.indexAt x)) := continuousOn_const refine (this.congr fun y hy ↦ ?_).continuousAt A exact h _ _ _ ⟨mem_baseSet_at _ _, hy⟩ @[simp, mfld_simps] theorem localTrivAsPartialEquiv_coe : ⇑(Z.localTrivAsPartialEquiv i) = Z.localTriv i := rfl @[simp, mfld_simps] theorem localTrivAsPartialEquiv_source : (Z.localTrivAsPartialEquiv i).source = (Z.localTriv i).source := rfl @[simp, mfld_simps] theorem localTrivAsPartialEquiv_target : (Z.localTrivAsPartialEquiv i).target = (Z.localTriv i).target := rfl @[simp, mfld_simps] theorem localTrivAsPartialEquiv_symm : (Z.localTrivAsPartialEquiv i).symm = (Z.localTriv i).toPartialEquiv.symm := rfl @[simp, mfld_simps] theorem baseSet_at : Z.baseSet i = (Z.localTriv i).baseSet := rfl @[simp, mfld_simps] theorem localTriv_apply (p : Z.TotalSpace) : (Z.localTriv i) p = ⟨p.1, Z.coordChange (Z.indexAt p.1) i p.1 p.2⟩ := rfl @[simp, mfld_simps] theorem localTrivAt_apply (p : Z.TotalSpace) : (Z.localTrivAt p.1) p = ⟨p.1, p.2⟩ := by rw [localTrivAt, localTriv_apply, coordChange_self] exact Z.mem_baseSet_at p.1 @[simp, mfld_simps] theorem localTrivAt_apply_mk (b : B) (a : F) : (Z.localTrivAt b) ⟨b, a⟩ = ⟨b, a⟩ := Z.localTrivAt_apply _ @[simp, mfld_simps] theorem mem_localTriv_source (p : Z.TotalSpace) : p ∈ (Z.localTriv i).source ↔ p.1 ∈ (Z.localTriv i).baseSet := Iff.rfl @[simp, mfld_simps] theorem mem_localTrivAt_source (p : Z.TotalSpace) (b : B) : p ∈ (Z.localTrivAt b).source ↔ p.1 ∈ (Z.localTrivAt b).baseSet := Iff.rfl @[simp, mfld_simps] theorem mem_localTriv_target (p : B × F) : p ∈ (Z.localTriv i).target ↔ p.1 ∈ (Z.localTriv i).baseSet := Trivialization.mem_target _ @[simp, mfld_simps] theorem mem_localTrivAt_target (p : B × F) (b : B) : p ∈ (Z.localTrivAt b).target ↔ p.1 ∈ (Z.localTrivAt b).baseSet := Trivialization.mem_target _ @[simp, mfld_simps] theorem localTriv_symm_apply (p : B × F) : (Z.localTriv i).toOpenPartialHomeomorph.symm p = ⟨p.1, Z.coordChange i (Z.indexAt p.1) p.1 p.2⟩ := rfl @[simp, mfld_simps] theorem mem_localTrivAt_baseSet (b : B) : b ∈ (Z.localTrivAt b).baseSet := by rw [localTrivAt, ← baseSet_at] exact Z.mem_baseSet_at b theorem mk_mem_localTrivAt_source : (⟨b, a⟩ : Z.TotalSpace) ∈ (Z.localTrivAt b).source := by simp only [mfld_simps] /-- A fiber bundle constructed from core is indeed a fiber bundle. -/ instance fiberBundle : FiberBundle F Z.Fiber where totalSpaceMk_isInducing' b := isInducing_iff_nhds.2 fun x ↦ by rw [(Z.localTrivAt b).nhds_eq_comap_inf_principal (mk_mem_localTrivAt_source _ _ _), comap_inf, comap_principal, comap_comap] simp only [Function.comp_def, localTrivAt_apply_mk, Trivialization.coe_coe, ← (isEmbedding_prodMkRight b).nhds_eq_comap] convert_to 𝓝 x = 𝓝 x ⊓ 𝓟 univ · congr exact eq_univ_of_forall (mk_mem_localTrivAt_source Z _) · rw [principal_univ, inf_top_eq] trivializationAtlas' := Set.range Z.localTriv trivializationAt' := Z.localTrivAt mem_baseSet_trivializationAt' := Z.mem_baseSet_at trivialization_mem_atlas' b := ⟨Z.indexAt b, rfl⟩ /-- The inclusion of a fiber into the total space is a continuous map. -/ @[continuity] theorem continuous_totalSpaceMk (b : B) : Continuous (TotalSpace.mk b : Z.Fiber b → Bundle.TotalSpace F Z.Fiber) := FiberBundle.continuous_totalSpaceMk F Z.Fiber b /-- The projection on the base of a fiber bundle created from core is continuous -/ nonrec theorem continuous_proj : Continuous Z.proj := FiberBundle.continuous_proj F Z.Fiber /-- The projection on the base of a fiber bundle created from core is an open map -/ nonrec theorem isOpenMap_proj : IsOpenMap Z.proj := FiberBundle.isOpenMap_proj F Z.Fiber end FiberBundleCore /-! ### Prebundle construction for constructing fiber bundles -/ variable (F) variable (E : B → Type*) [TopologicalSpace B] [TopologicalSpace F] [∀ x, TopologicalSpace (E x)] /-- This structure permits to define a fiber bundle when trivializations are given as local equivalences but there is not yet a topology on the total space. The total space is hence given a topology in such a way that there is a fiber bundle structure for which the partial equivalences are also open partial homeomorphisms and hence local trivializations. -/ structure FiberPrebundle where pretrivializationAtlas : Set (Pretrivialization F (π F E)) pretrivializationAt : B → Pretrivialization F (π F E) mem_base_pretrivializationAt : ∀ x : B, x ∈ (pretrivializationAt x).baseSet pretrivialization_mem_atlas : ∀ x : B, pretrivializationAt x ∈ pretrivializationAtlas continuous_trivChange : ∀ e, e ∈ pretrivializationAtlas → ∀ e', e' ∈ pretrivializationAtlas → ContinuousOn (e ∘ e'.toPartialEquiv.symm) (e'.target ∩ e'.toPartialEquiv.symm ⁻¹' e.source) totalSpaceMk_isInducing : ∀ b : B, IsInducing (pretrivializationAt b ∘ TotalSpace.mk b) namespace FiberPrebundle variable {F E} variable (a : FiberPrebundle F E) {e : Pretrivialization F (π F E)} /-- Topology on the total space that will make the prebundle into a bundle. -/ def totalSpaceTopology (a : FiberPrebundle F E) : TopologicalSpace (TotalSpace F E) := ⨆ (e : Pretrivialization F (π F E)) (_ : e ∈ a.pretrivializationAtlas), coinduced e.setSymm instTopologicalSpaceSubtype theorem continuous_symm_of_mem_pretrivializationAtlas (he : e ∈ a.pretrivializationAtlas) : @ContinuousOn _ _ _ a.totalSpaceTopology e.toPartialEquiv.symm e.target := by refine fun z H U h => preimage_nhdsWithin_coinduced' H (le_def.1 (nhds_mono ?_) U h) exact le_iSup₂ (α := TopologicalSpace (TotalSpace F E)) e he theorem isOpen_source (e : Pretrivialization F (π F E)) : IsOpen[a.totalSpaceTopology] e.source := by refine isOpen_iSup_iff.mpr fun e' => isOpen_iSup_iff.mpr fun _ => ?_ refine isOpen_coinduced.mpr (isOpen_induced_iff.mpr ⟨e.target, e.open_target, ?_⟩) ext ⟨x, hx⟩ simp only [mem_preimage, Pretrivialization.setSymm, restrict, e.mem_target, e.mem_source, e'.proj_symm_apply hx] theorem isOpen_target_of_mem_pretrivializationAtlas_inter (e e' : Pretrivialization F (π F E)) (he' : e' ∈ a.pretrivializationAtlas) : IsOpen (e'.toPartialEquiv.target ∩ e'.toPartialEquiv.symm ⁻¹' e.source) := by letI := a.totalSpaceTopology obtain ⟨u, hu1, hu2⟩ := continuousOn_iff'.mp (a.continuous_symm_of_mem_pretrivializationAtlas he') e.source (a.isOpen_source e) rw [inter_comm, hu2] exact hu1.inter e'.open_target /-- Promotion from a `Pretrivialization` to a `Trivialization`. -/ def trivializationOfMemPretrivializationAtlas (he : e ∈ a.pretrivializationAtlas) : @Trivialization B F _ _ _ a.totalSpaceTopology (π F E) := let _ := a.totalSpaceTopology { e with open_source := a.isOpen_source e, continuousOn_toFun := by refine continuousOn_iff'.mpr fun s hs => ⟨e ⁻¹' s ∩ e.source, isOpen_iSup_iff.mpr fun e' => ?_, by rw [inter_assoc, inter_self]; rfl⟩ refine isOpen_iSup_iff.mpr fun he' => ?_ rw [isOpen_coinduced, isOpen_induced_iff] obtain ⟨u, hu1, hu2⟩ := continuousOn_iff'.mp (a.continuous_trivChange _ he _ he') s hs have hu3 := congr_arg (fun s => (fun x : e'.target => (x : B × F)) ⁻¹' s) hu2 simp only [Subtype.coe_preimage_self, preimage_inter, univ_inter] at hu3 refine ⟨u ∩ e'.toPartialEquiv.target ∩ e'.toPartialEquiv.symm ⁻¹' e.source, ?_, by simp only [preimage_inter, inter_univ, Subtype.coe_preimage_self, hu3.symm]; rfl⟩ rw [inter_assoc] exact hu1.inter (a.isOpen_target_of_mem_pretrivializationAtlas_inter e e' he') continuousOn_invFun := a.continuous_symm_of_mem_pretrivializationAtlas he } theorem mem_pretrivializationAt_source (b : B) (x : E b) : ⟨b, x⟩ ∈ (a.pretrivializationAt b).source := by simp only [(a.pretrivializationAt b).source_eq, mem_preimage] exact a.mem_base_pretrivializationAt b @[simp] theorem totalSpaceMk_preimage_source (b : B) : TotalSpace.mk b ⁻¹' (a.pretrivializationAt b).source = univ := eq_univ_of_forall (a.mem_pretrivializationAt_source b) @[continuity] theorem continuous_totalSpaceMk (b : B) : Continuous[_, a.totalSpaceTopology] (TotalSpace.mk b) := by letI := a.totalSpaceTopology let e := a.trivializationOfMemPretrivializationAtlas (a.pretrivialization_mem_atlas b) rw [e.toOpenPartialHomeomorph.continuous_iff_continuous_comp_left (a.totalSpaceMk_preimage_source b)] exact continuous_iff_le_induced.2 (a.totalSpaceMk_isInducing b).eq_induced.le theorem inducing_totalSpaceMk_of_inducing_comp (b : B) (h : IsInducing (a.pretrivializationAt b ∘ TotalSpace.mk b)) : @IsInducing _ _ _ a.totalSpaceTopology (TotalSpace.mk b) := by letI := a.totalSpaceTopology rw [← restrict_comp_codRestrict (a.mem_pretrivializationAt_source b)] at h apply IsInducing.of_codRestrict (a.mem_pretrivializationAt_source b) refine h.of_comp ?_ (continuousOn_iff_continuous_restrict.mp (a.trivializationOfMemPretrivializationAtlas (a.pretrivialization_mem_atlas b)).continuousOn) exact (a.continuous_totalSpaceMk b).codRestrict (a.mem_pretrivializationAt_source b) /-- Make a `FiberBundle` from a `FiberPrebundle`. Concretely this means that, given a `FiberPrebundle` structure for a sigma-type `E` -- which consists of a number of "pretrivializations" identifying parts of `E` with product spaces `U × F` -- one establishes that for the topology constructed on the sigma-type using `FiberPrebundle.totalSpaceTopology`, these "pretrivializations" are actually "trivializations" (i.e., homeomorphisms with respect to the constructed topology). -/ def toFiberBundle : @FiberBundle B F _ _ E a.totalSpaceTopology _ := let _ := a.totalSpaceTopology { totalSpaceMk_isInducing' := fun b ↦ a.inducing_totalSpaceMk_of_inducing_comp b (a.totalSpaceMk_isInducing b) trivializationAtlas' := { e | ∃ (e₀ : _) (he₀ : e₀ ∈ a.pretrivializationAtlas), e = a.trivializationOfMemPretrivializationAtlas he₀ }, trivializationAt' := fun x ↦ a.trivializationOfMemPretrivializationAtlas (a.pretrivialization_mem_atlas x), mem_baseSet_trivializationAt' := a.mem_base_pretrivializationAt trivialization_mem_atlas' := fun x ↦ ⟨_, a.pretrivialization_mem_atlas x, rfl⟩ } theorem continuous_proj : @Continuous _ _ a.totalSpaceTopology _ (π F E) := by letI := a.totalSpaceTopology letI := a.toFiberBundle exact FiberBundle.continuous_proj F E instance {e₀} (he₀ : e₀ ∈ a.pretrivializationAtlas) : (letI := a.totalSpaceTopology; letI := a.toFiberBundle MemTrivializationAtlas (a.trivializationOfMemPretrivializationAtlas he₀)) := letI := a.totalSpaceTopology; letI := a.toFiberBundle; ⟨e₀, he₀, rfl⟩ /-- For a fiber bundle `E` over `B` constructed using the `FiberPrebundle` mechanism, continuity of a function `TotalSpace F E → X` on an open set `s` can be checked by precomposing at each point with the pretrivialization used for the construction at that point. -/ theorem continuousOn_of_comp_right {X : Type*} [TopologicalSpace X] {f : TotalSpace F E → X} {s : Set B} (hs : IsOpen s) (hf : ∀ b ∈ s, ContinuousOn (f ∘ (a.pretrivializationAt b).toPartialEquiv.symm) ((s ∩ (a.pretrivializationAt b).baseSet) ×ˢ (Set.univ : Set F))) : @ContinuousOn _ _ a.totalSpaceTopology _ f (π F E ⁻¹' s) := by letI := a.totalSpaceTopology intro z hz let e : Trivialization F (π F E) := a.trivializationOfMemPretrivializationAtlas (a.pretrivialization_mem_atlas z.proj) refine (e.continuousAt_of_comp_right ?_ ((hf z.proj hz).continuousAt (IsOpen.mem_nhds ?_ ?_))).continuousWithinAt · exact a.mem_base_pretrivializationAt z.proj · exact (hs.inter (a.pretrivializationAt z.proj).open_baseSet).prod isOpen_univ refine ⟨?_, mem_univ _⟩ rw [e.coe_fst] · exact ⟨hz, a.mem_base_pretrivializationAt z.proj⟩ · rw [e.mem_source] exact a.mem_base_pretrivializationAt z.proj end FiberPrebundle
.lake/packages/mathlib/Mathlib/Topology/FiberBundle/Constructions.lean
import Mathlib.Topology.FiberBundle.Basic /-! # Standard constructions on fiber bundles This file contains several standard constructions on fiber bundles: * `Bundle.Trivial.fiberBundle 𝕜 B F`: the trivial fiber bundle with model fiber `F` over the base `B` * `FiberBundle.prod`: for fiber bundles `E₁` and `E₂` over a common base, a fiber bundle structure on their fiberwise product `E₁ ×ᵇ E₂` (the notation stands for `fun x ↦ E₁ x × E₂ x`). * `FiberBundle.pullback`: for a fiber bundle `E` over `B`, a fiber bundle structure on its pullback `f *ᵖ E` by a map `f : B' → B` (the notation is a type synonym for `E ∘ f`). ## Tags fiber bundle, fibre bundle, fiberwise product, pullback -/ open Bundle Filter Set TopologicalSpace Topology /-! ### The trivial bundle -/ namespace Bundle namespace Trivial variable (B : Type*) (F : Type*) -- TODO: use `TotalSpace.toProd` instance topologicalSpace [t₁ : TopologicalSpace B] [t₂ : TopologicalSpace F] : TopologicalSpace (TotalSpace F (Trivial B F)) := induced TotalSpace.proj t₁ ⊓ induced (TotalSpace.trivialSnd B F) t₂ variable [TopologicalSpace B] [TopologicalSpace F] theorem isInducing_toProd : IsInducing (TotalSpace.toProd B F) := ⟨by simp only [instTopologicalSpaceProd, induced_inf, induced_compose]; rfl⟩ /-- Homeomorphism between the total space of the trivial bundle and the Cartesian product. -/ @[simps!] def homeomorphProd : TotalSpace F (Trivial B F) ≃ₜ B × F := (TotalSpace.toProd _ _).toHomeomorphOfIsInducing (isInducing_toProd B F) /-- Local trivialization for trivial bundle. -/ @[simps!] def trivialization : Trivialization F (π F (Bundle.Trivial B F)) where toOpenPartialHomeomorph := (homeomorphProd B F).toOpenPartialHomeomorph baseSet := univ open_baseSet := isOpen_univ source_eq := rfl target_eq := univ_prod_univ.symm proj_toFun _ _ := rfl @[simp] lemma trivialization_symm_apply [Zero F] (b : B) (f : F) : (trivialization B F).symm b f = f := by simp [trivialization, homeomorphProd, TotalSpace.toProd, Trivialization.symm, Pretrivialization.symm, Trivialization.toPretrivialization] @[simp] lemma toOpenPartialHomeomorph_trivialization_symm_apply (v : B × F) : (trivialization B F).toOpenPartialHomeomorph.symm v = ⟨v.1, v.2⟩ := rfl /-- Fiber bundle instance on the trivial bundle. -/ @[simps] instance fiberBundle : FiberBundle F (Bundle.Trivial B F) where trivializationAtlas' := {trivialization B F} trivializationAt' _ := trivialization B F mem_baseSet_trivializationAt' := mem_univ trivialization_mem_atlas' _ := mem_singleton _ totalSpaceMk_isInducing' _ := (homeomorphProd B F).symm.isInducing.comp (isInducing_const_prod.2 .id) theorem eq_trivialization (e : Trivialization F (π F (Bundle.Trivial B F))) [i : MemTrivializationAtlas e] : e = trivialization B F := i.out end Trivial end Bundle /-! ### Fibrewise product of two bundles -/ section Prod variable {B : Type*} section Defs variable (F₁ : Type*) (E₁ : B → Type*) (F₂ : Type*) (E₂ : B → Type*) variable [TopologicalSpace (TotalSpace F₁ E₁)] [TopologicalSpace (TotalSpace F₂ E₂)] /-- Equip the total space of the fiberwise product of two fiber bundles `E₁`, `E₂` with the induced topology from the diagonal embedding into `TotalSpace F₁ E₁ × TotalSpace F₂ E₂`. -/ instance FiberBundle.Prod.topologicalSpace : TopologicalSpace (TotalSpace (F₁ × F₂) (E₁ ×ᵇ E₂)) := TopologicalSpace.induced (fun p ↦ ((⟨p.1, p.2.1⟩ : TotalSpace F₁ E₁), (⟨p.1, p.2.2⟩ : TotalSpace F₂ E₂))) inferInstance /-- The diagonal map from the total space of the fiberwise product of two fiber bundles `E₁`, `E₂` into `TotalSpace F₁ E₁ × TotalSpace F₂ E₂` is an inducing map. -/ theorem FiberBundle.Prod.isInducing_diag : IsInducing (fun p ↦ (⟨p.1, p.2.1⟩, ⟨p.1, p.2.2⟩) : TotalSpace (F₁ × F₂) (E₁ ×ᵇ E₂) → TotalSpace F₁ E₁ × TotalSpace F₂ E₂) := ⟨rfl⟩ end Defs open FiberBundle variable [TopologicalSpace B] (F₁ : Type*) [TopologicalSpace F₁] (E₁ : B → Type*) [TopologicalSpace (TotalSpace F₁ E₁)] (F₂ : Type*) [TopologicalSpace F₂] (E₂ : B → Type*) [TopologicalSpace (TotalSpace F₂ E₂)] namespace Trivialization variable {F₁ E₁ F₂ E₂} variable (e₁ : Trivialization F₁ (π F₁ E₁)) (e₂ : Trivialization F₂ (π F₂ E₂)) /-- Given trivializations `e₁`, `e₂` for fiber bundles `E₁`, `E₂` over a base `B`, the forward function for the construction `Trivialization.prod`, the induced trivialization for the fiberwise product of `E₁` and `E₂`. -/ def Prod.toFun' : TotalSpace (F₁ × F₂) (E₁ ×ᵇ E₂) → B × F₁ × F₂ := fun p ↦ ⟨p.1, (e₁ ⟨p.1, p.2.1⟩).2, (e₂ ⟨p.1, p.2.2⟩).2⟩ variable {e₁ e₂} theorem Prod.continuous_to_fun : ContinuousOn (Prod.toFun' e₁ e₂) (π (F₁ × F₂) (E₁ ×ᵇ E₂) ⁻¹' (e₁.baseSet ∩ e₂.baseSet)) := by let f₁ : TotalSpace (F₁ × F₂) (E₁ ×ᵇ E₂) → TotalSpace F₁ E₁ × TotalSpace F₂ E₂ := fun p ↦ ((⟨p.1, p.2.1⟩ : TotalSpace F₁ E₁), (⟨p.1, p.2.2⟩ : TotalSpace F₂ E₂)) let f₂ : TotalSpace F₁ E₁ × TotalSpace F₂ E₂ → (B × F₁) × B × F₂ := fun p ↦ ⟨e₁ p.1, e₂ p.2⟩ let f₃ : (B × F₁) × B × F₂ → B × F₁ × F₂ := fun p ↦ ⟨p.1.1, p.1.2, p.2.2⟩ have hf₁ : Continuous f₁ := (Prod.isInducing_diag F₁ E₁ F₂ E₂).continuous have hf₂ : ContinuousOn f₂ (e₁.source ×ˢ e₂.source) := e₁.toOpenPartialHomeomorph.continuousOn.prodMap e₂.toOpenPartialHomeomorph.continuousOn have hf₃ : Continuous f₃ := by fun_prop refine ((hf₃.comp_continuousOn hf₂).comp hf₁.continuousOn ?_).congr ?_ · rw [e₁.source_eq, e₂.source_eq] exact mapsTo_preimage _ _ rintro ⟨b, v₁, v₂⟩ ⟨hb₁, _⟩ simp only [f₁, f₂, f₃, Prod.toFun', Prod.mk_inj, Function.comp_apply, and_true] rw [e₁.coe_fst] rw [e₁.source_eq, mem_preimage] exact hb₁ variable (e₁ e₂) [∀ x, Zero (E₁ x)] [∀ x, Zero (E₂ x)] /-- Given trivializations `e₁`, `e₂` for fiber bundles `E₁`, `E₂` over a base `B`, the inverse function for the construction `Trivialization.prod`, the induced trivialization for the fiberwise product of `E₁` and `E₂`. -/ noncomputable def Prod.invFun' (p : B × F₁ × F₂) : TotalSpace (F₁ × F₂) (E₁ ×ᵇ E₂) := ⟨p.1, e₁.symm p.1 p.2.1, e₂.symm p.1 p.2.2⟩ variable {e₁ e₂} theorem Prod.left_inv {x : TotalSpace (F₁ × F₂) (E₁ ×ᵇ E₂)} (h : x ∈ π (F₁ × F₂) (E₁ ×ᵇ E₂) ⁻¹' (e₁.baseSet ∩ e₂.baseSet)) : Prod.invFun' e₁ e₂ (Prod.toFun' e₁ e₂ x) = x := by obtain ⟨x, v₁, v₂⟩ := x obtain ⟨h₁ : x ∈ e₁.baseSet, h₂ : x ∈ e₂.baseSet⟩ := h simp only [Prod.toFun', Prod.invFun', symm_apply_apply_mk, h₁, h₂] theorem Prod.right_inv {x : B × F₁ × F₂} (h : x ∈ (e₁.baseSet ∩ e₂.baseSet) ×ˢ (univ : Set (F₁ × F₂))) : Prod.toFun' e₁ e₂ (Prod.invFun' e₁ e₂ x) = x := by obtain ⟨x, w₁, w₂⟩ := x obtain ⟨⟨h₁ : x ∈ e₁.baseSet, h₂ : x ∈ e₂.baseSet⟩, -⟩ := h simp only [Prod.toFun', Prod.invFun', apply_mk_symm, h₁, h₂] theorem Prod.continuous_inv_fun : ContinuousOn (Prod.invFun' e₁ e₂) ((e₁.baseSet ∩ e₂.baseSet) ×ˢ univ) := by rw [(Prod.isInducing_diag F₁ E₁ F₂ E₂).continuousOn_iff] have H₁ : Continuous fun p : B × F₁ × F₂ ↦ ((p.1, p.2.1), (p.1, p.2.2)) := by fun_prop refine (e₁.continuousOn_symm.prodMap e₂.continuousOn_symm).comp H₁.continuousOn ?_ exact fun x h ↦ ⟨⟨h.1.1, mem_univ _⟩, ⟨h.1.2, mem_univ _⟩⟩ variable (e₁ e₂) /-- Given trivializations `e₁`, `e₂` for bundle types `E₁`, `E₂` over a base `B`, the induced trivialization for the fiberwise product of `E₁` and `E₂`, whose base set is `e₁.baseSet ∩ e₂.baseSet`. -/ @[simps!] noncomputable def prod : Trivialization (F₁ × F₂) (π (F₁ × F₂) (E₁ ×ᵇ E₂)) where toFun := Prod.toFun' e₁ e₂ invFun := Prod.invFun' e₁ e₂ source := π (F₁ × F₂) (E₁ ×ᵇ E₂) ⁻¹' (e₁.baseSet ∩ e₂.baseSet) target := (e₁.baseSet ∩ e₂.baseSet) ×ˢ Set.univ map_source' _ h := ⟨h, Set.mem_univ _⟩ map_target' _ h := h.1 left_inv' _ := Prod.left_inv right_inv' _ := Prod.right_inv open_source := by convert (e₁.open_source.prod e₂.open_source).preimage (FiberBundle.Prod.isInducing_diag F₁ E₁ F₂ E₂).continuous ext x simp only [Trivialization.source_eq, mfld_simps] open_target := (e₁.open_baseSet.inter e₂.open_baseSet).prod isOpen_univ continuousOn_toFun := Prod.continuous_to_fun continuousOn_invFun := Prod.continuous_inv_fun baseSet := e₁.baseSet ∩ e₂.baseSet open_baseSet := e₁.open_baseSet.inter e₂.open_baseSet source_eq := rfl target_eq := rfl proj_toFun _ _ := rfl @[deprecated (since := "2025-06-19")] alias baseSet_prod := prod_baseSet theorem prod_symm_apply (x : B) (w₁ : F₁) (w₂ : F₂) : (prod e₁ e₂).toPartialEquiv.symm (x, w₁, w₂) = ⟨x, e₁.symm x w₁, e₂.symm x w₂⟩ := rfl end Trivialization open Trivialization variable [∀ x, Zero (E₁ x)] [∀ x, Zero (E₂ x)] [∀ x : B, TopologicalSpace (E₁ x)] [∀ x : B, TopologicalSpace (E₂ x)] [FiberBundle F₁ E₁] [FiberBundle F₂ E₂] /-- The product of two fiber bundles is a fiber bundle. -/ @[simps] noncomputable instance FiberBundle.prod : FiberBundle (F₁ × F₂) (E₁ ×ᵇ E₂) where totalSpaceMk_isInducing' b := by rw [← (Prod.isInducing_diag F₁ E₁ F₂ E₂).of_comp_iff] exact (totalSpaceMk_isInducing F₁ E₁ b).prodMap (totalSpaceMk_isInducing F₂ E₂ b) trivializationAtlas' := { e | ∃ (e₁ : Trivialization F₁ (π F₁ E₁)) (e₂ : Trivialization F₂ (π F₂ E₂)) (_ : MemTrivializationAtlas e₁) (_ : MemTrivializationAtlas e₂), e = Trivialization.prod e₁ e₂ } trivializationAt' b := (trivializationAt F₁ E₁ b).prod (trivializationAt F₂ E₂ b) mem_baseSet_trivializationAt' b := ⟨mem_baseSet_trivializationAt F₁ E₁ b, mem_baseSet_trivializationAt F₂ E₂ b⟩ trivialization_mem_atlas' b := ⟨trivializationAt F₁ E₁ b, trivializationAt F₂ E₂ b, inferInstance, inferInstance, rfl⟩ instance {e₁ : Trivialization F₁ (π F₁ E₁)} {e₂ : Trivialization F₂ (π F₂ E₂)} [MemTrivializationAtlas e₁] [MemTrivializationAtlas e₂] : MemTrivializationAtlas (e₁.prod e₂ : Trivialization (F₁ × F₂) (π (F₁ × F₂) (E₁ ×ᵇ E₂))) where out := ⟨e₁, e₂, inferInstance, inferInstance, rfl⟩ end Prod /-! ### Pullbacks of fiber bundles -/ section universe u v w₁ w₂ U variable {B : Type u} (F : Type v) (E : B → Type w₁) {B' : Type w₂} (f : B' → B) instance [∀ x : B, TopologicalSpace (E x)] : ∀ x : B', TopologicalSpace ((f *ᵖ E) x) := inferInstanceAs (∀ x, TopologicalSpace (E (f x))) variable [TopologicalSpace B'] [TopologicalSpace (TotalSpace F E)] /-- Definition of `Pullback.TotalSpace.topologicalSpace`, which we make irreducible. -/ irreducible_def pullbackTopology : TopologicalSpace (TotalSpace F (f *ᵖ E)) := induced TotalSpace.proj ‹TopologicalSpace B'› ⊓ induced (Pullback.lift f) ‹TopologicalSpace (TotalSpace F E)› /-- The topology on the total space of a pullback bundle is the coarsest topology for which both the projections to the base and the map to the original bundle are continuous. -/ instance Pullback.TotalSpace.topologicalSpace : TopologicalSpace (TotalSpace F (f *ᵖ E)) := pullbackTopology F E f theorem Pullback.continuous_proj (f : B' → B) : Continuous (π F (f *ᵖ E)) := by rw [continuous_iff_le_induced, Pullback.TotalSpace.topologicalSpace, pullbackTopology_def] exact inf_le_left theorem Pullback.continuous_lift (f : B' → B) : Continuous (@Pullback.lift B F E B' f) := by rw [continuous_iff_le_induced, Pullback.TotalSpace.topologicalSpace, pullbackTopology_def] exact inf_le_right theorem inducing_pullbackTotalSpaceEmbedding (f : B' → B) : IsInducing (@pullbackTotalSpaceEmbedding B F E B' f) := by constructor simp_rw [instTopologicalSpaceProd, induced_inf, induced_compose, Pullback.TotalSpace.topologicalSpace, pullbackTopology_def] rfl section FiberBundle variable [TopologicalSpace F] [TopologicalSpace B] theorem Pullback.continuous_totalSpaceMk [∀ x, TopologicalSpace (E x)] [FiberBundle F E] {f : B' → B} {x : B'} : Continuous (@TotalSpace.mk _ F (f *ᵖ E) x) := by simp only [continuous_iff_le_induced, Pullback.TotalSpace.topologicalSpace, induced_compose, induced_inf, Function.comp_def, induced_const, top_inf_eq, pullbackTopology_def] exact (FiberBundle.totalSpaceMk_isInducing F E (f x)).eq_induced.le variable {E F} variable [∀ _b, Zero (E _b)] {K : Type U} [FunLike K B' B] [ContinuousMapClass K B' B] /-- A fiber bundle trivialization can be pulled back to a trivialization on the pullback bundle. -/ @[simps] noncomputable def Trivialization.pullback (e : Trivialization F (π F E)) (f : K) : Trivialization F (π F ((f : B' → B) *ᵖ E)) where toFun z := (z.proj, (e (Pullback.lift f z)).2) invFun y := @TotalSpace.mk _ F (f *ᵖ E) y.1 (e.symm (f y.1) y.2) source := Pullback.lift f ⁻¹' e.source baseSet := f ⁻¹' e.baseSet target := (f ⁻¹' e.baseSet) ×ˢ univ map_source' x h := by simp_rw [e.source_eq, mem_preimage, Pullback.lift_proj] at h simp_rw [prodMk_mem_set_prod_eq, mem_univ, and_true, mem_preimage, h] map_target' y h := by rw [mem_prod, mem_preimage] at h simp_rw [e.source_eq, mem_preimage, Pullback.lift_proj, h.1] left_inv' x h := by simp_rw [mem_preimage, e.mem_source, Pullback.lift_proj] at h simp_rw [Pullback.lift, e.symm_apply_apply_mk h] right_inv' x h := by simp_rw [mem_prod, mem_preimage, mem_univ, and_true] at h simp_rw [Pullback.lift_mk, e.apply_mk_symm h] open_source := by simp_rw [e.source_eq, ← preimage_comp] exact e.open_baseSet.preimage ((map_continuous f).comp <| Pullback.continuous_proj F E f) open_target := ((map_continuous f).isOpen_preimage _ e.open_baseSet).prod isOpen_univ open_baseSet := (map_continuous f).isOpen_preimage _ e.open_baseSet continuousOn_toFun := (Pullback.continuous_proj F E f).continuousOn.prodMk (continuous_snd.comp_continuousOn <| e.continuousOn.comp (Pullback.continuous_lift F E f).continuousOn Subset.rfl) continuousOn_invFun := by simp_rw [(inducing_pullbackTotalSpaceEmbedding F E f).continuousOn_iff, Function.comp_def, pullbackTotalSpaceEmbedding] exact continuousOn_fst.prodMk (e.continuousOn_symm.comp ((map_continuous f).prodMap continuous_id).continuousOn Subset.rfl) source_eq := by rw [e.source_eq] rfl target_eq := rfl proj_toFun _ _ := rfl @[simps] noncomputable instance FiberBundle.pullback [∀ x, TopologicalSpace (E x)] [FiberBundle F E] (f : K) : FiberBundle F ((f : B' → B) *ᵖ E) where totalSpaceMk_isInducing' x := (totalSpaceMk_isInducing F E (f x)).of_comp (Pullback.continuous_totalSpaceMk F E) (Pullback.continuous_lift F E f) trivializationAtlas' := { ef | ∃ (e : Trivialization F (π F E)) (_ : MemTrivializationAtlas e), ef = e.pullback f } trivializationAt' x := (trivializationAt F E (f x)).pullback f mem_baseSet_trivializationAt' x := mem_baseSet_trivializationAt F E (f x) trivialization_mem_atlas' x := ⟨trivializationAt F E (f x), inferInstance, rfl⟩ end FiberBundle end
.lake/packages/mathlib/Mathlib/Topology/FiberBundle/Trivialization.lean
import Mathlib.Data.Bundle import Mathlib.Data.Set.Image import Mathlib.Topology.CompactOpen import Mathlib.Topology.OpenPartialHomeomorph import Mathlib.Topology.Order.Basic /-! # Trivializations ## Main definitions ### Basic definitions * `Trivialization F p` : structure extending open partial homeomorphisms, defining a local trivialization of a topological space `Z` with projection `p` and fiber `F`. * `Pretrivialization F proj` : trivialization as a partial equivalence, mainly used when the topology on the total space has not yet been defined. ### Operations on bundles We provide the following operations on `Trivialization`s. * `Trivialization.compHomeomorph`: given a local trivialization `e` of a fiber bundle `p : Z → B` and a homeomorphism `h : Z' ≃ₜ Z`, returns a local trivialization of the fiber bundle `p ∘ h`. ## Implementation notes Previously, in mathlib, there was a structure `topological_vector_bundle.trivialization` which extended another structure `topological_fiber_bundle.trivialization` by a linearity hypothesis. As of PR https://github.com/leanprover-community/mathlib3/pull/17359, we have changed this to a single structure `Trivialization` (no namespace), together with a mixin class `Trivialization.IsLinear`. This permits all the *data* of a vector bundle to be held at the level of fiber bundles, so that the same trivializations can underlie an object's structure as (say) a vector bundle over `ℂ` and as a vector bundle over `ℝ`, as well as its structure simply as a fiber bundle. This might be a little surprising, given the general trend of the library to ever-increased bundling. But in this case the typical motivation for more bundling does not apply: there is no algebraic or order structure on the whole type of linear (say) trivializations of a bundle. Indeed, since trivializations only have meaning on their base sets (taking junk values outside), the type of linear trivializations is not even particularly well-behaved. -/ open TopologicalSpace Filter Set Bundle Function open scoped Topology variable {B : Type*} (F : Type*) {E : B → Type*} variable {Z : Type*} [TopologicalSpace B] [TopologicalSpace F] {proj : Z → B} /-- This structure contains the information left for a local trivialization (which is implemented below as `Trivialization F proj`) if the total space has not been given a topology, but we have a topology on both the fiber and the base space. Through the construction `topological_fiber_prebundle F proj` it will be possible to promote a `Pretrivialization F proj` to a `Trivialization F proj`. -/ structure Pretrivialization (proj : Z → B) extends PartialEquiv Z (B × F) where open_target : IsOpen target /-- The domain of the local trivialisation (i.e., a subset of the bundle `Z`'s base): outside of it, the pretrivialisation returns a junk value -/ baseSet : Set B open_baseSet : IsOpen baseSet source_eq : source = proj ⁻¹' baseSet target_eq : target = baseSet ×ˢ univ proj_toFun : ∀ p ∈ source, (toFun p).1 = proj p namespace Pretrivialization variable {F} variable (e : Pretrivialization F proj) {x : Z} /-- Coercion of a pretrivialization to a function. We don't use `e.toFun` in the `CoeFun` instance because it is actually `e.toPartialEquiv.toFun`, so `simp` will apply lemmas about `toPartialEquiv`. While we may want to switch to this behavior later, doing it mid-port will break a lot of proofs. -/ @[coe] def toFun' : Z → (B × F) := e.toFun instance : CoeFun (Pretrivialization F proj) fun _ => Z → B × F := ⟨toFun'⟩ @[ext] lemma ext' (e e' : Pretrivialization F proj) (h₁ : e.toPartialEquiv = e'.toPartialEquiv) (h₂ : e.baseSet = e'.baseSet) : e = e' := by cases e; cases e'; congr -- TODO: move `ext` here? lemma ext {e e' : Pretrivialization F proj} (h₁ : ∀ x, e x = e' x) (h₂ : ∀ x, e.toPartialEquiv.symm x = e'.toPartialEquiv.symm x) (h₃ : e.baseSet = e'.baseSet) : e = e' := by ext1 <;> [ext1; exact h₃] · apply h₁ · apply h₂ · rw [e.source_eq, e'.source_eq, h₃] /-- If the fiber is nonempty, then the projection also is. -/ lemma toPartialEquiv_injective [Nonempty F] : Injective (toPartialEquiv : Pretrivialization F proj → PartialEquiv Z (B × F)) := by refine fun e e' h ↦ ext' _ _ h ?_ simpa only [fst_image_prod, univ_nonempty, target_eq] using congr_arg (Prod.fst '' PartialEquiv.target ·) h @[simp, mfld_simps] theorem coe_coe : ⇑e.toPartialEquiv = e := rfl @[simp, mfld_simps] theorem coe_fst (ex : x ∈ e.source) : (e x).1 = proj x := e.proj_toFun x ex theorem mem_source : x ∈ e.source ↔ proj x ∈ e.baseSet := by rw [e.source_eq, mem_preimage] theorem coe_fst' (ex : proj x ∈ e.baseSet) : (e x).1 = proj x := e.coe_fst (e.mem_source.2 ex) protected theorem eqOn : EqOn (Prod.fst ∘ e) proj e.source := fun _ hx => e.coe_fst hx theorem mk_proj_snd (ex : x ∈ e.source) : (proj x, (e x).2) = e x := Prod.ext (e.coe_fst ex).symm rfl theorem mk_proj_snd' (ex : proj x ∈ e.baseSet) : (proj x, (e x).2) = e x := Prod.ext (e.coe_fst' ex).symm rfl /-- Composition of inverse and coercion from the subtype of the target. -/ def setSymm : e.target → Z := e.target.restrict e.toPartialEquiv.symm theorem mem_target {x : B × F} : x ∈ e.target ↔ x.1 ∈ e.baseSet := by rw [e.target_eq, prod_univ, mem_preimage] theorem proj_symm_apply {x : B × F} (hx : x ∈ e.target) : proj (e.toPartialEquiv.symm x) = x.1 := by have := (e.coe_fst (e.map_target hx)).symm rwa [← e.coe_coe, e.right_inv hx] at this theorem proj_symm_apply' {b : B} {x : F} (hx : b ∈ e.baseSet) : proj (e.toPartialEquiv.symm (b, x)) = b := e.proj_symm_apply (e.mem_target.2 hx) theorem proj_surjOn_baseSet [Nonempty F] : Set.SurjOn proj e.source e.baseSet := fun b hb => let ⟨y⟩ := ‹Nonempty F› ⟨e.toPartialEquiv.symm (b, y), e.toPartialEquiv.map_target <| e.mem_target.2 hb, e.proj_symm_apply' hb⟩ theorem apply_symm_apply {x : B × F} (hx : x ∈ e.target) : e (e.toPartialEquiv.symm x) = x := e.toPartialEquiv.right_inv hx theorem apply_symm_apply' {b : B} {x : F} (hx : b ∈ e.baseSet) : e (e.toPartialEquiv.symm (b, x)) = (b, x) := e.apply_symm_apply (e.mem_target.2 hx) theorem symm_apply_apply {x : Z} (hx : x ∈ e.source) : e.toPartialEquiv.symm (e x) = x := e.toPartialEquiv.left_inv hx @[simp, mfld_simps] theorem symm_apply_mk_proj {x : Z} (ex : x ∈ e.source) : e.toPartialEquiv.symm (proj x, (e x).2) = x := by rw [← e.coe_fst ex, ← e.coe_coe, e.left_inv ex] @[simp, mfld_simps] theorem preimage_symm_proj_baseSet : e.toPartialEquiv.symm ⁻¹' (proj ⁻¹' e.baseSet) ∩ e.target = e.target := by refine inter_eq_right.mpr fun x hx => ?_ simp only [mem_preimage, e.proj_symm_apply hx] exact e.mem_target.mp hx @[simp, mfld_simps] theorem preimage_symm_proj_inter (s : Set B) : e.toPartialEquiv.symm ⁻¹' (proj ⁻¹' s) ∩ e.baseSet ×ˢ univ = (s ∩ e.baseSet) ×ˢ univ := by ext ⟨x, y⟩ suffices x ∈ e.baseSet → (proj (e.toPartialEquiv.symm (x, y)) ∈ s ↔ x ∈ s) by simpa only [prodMk_mem_set_prod_eq, mem_inter_iff, and_true, mem_univ, and_congr_left_iff] intro h rw [e.proj_symm_apply' h] theorem target_inter_preimage_symm_source_eq (e f : Pretrivialization F proj) : f.target ∩ f.toPartialEquiv.symm ⁻¹' e.source = (e.baseSet ∩ f.baseSet) ×ˢ univ := by rw [inter_comm, f.target_eq, e.source_eq, f.preimage_symm_proj_inter] theorem trans_source (e f : Pretrivialization F proj) : (f.toPartialEquiv.symm.trans e.toPartialEquiv).source = (e.baseSet ∩ f.baseSet) ×ˢ univ := by rw [PartialEquiv.trans_source, PartialEquiv.symm_source, e.target_inter_preimage_symm_source_eq] theorem symm_trans_symm (e e' : Pretrivialization F proj) : (e.toPartialEquiv.symm.trans e'.toPartialEquiv).symm = e'.toPartialEquiv.symm.trans e.toPartialEquiv := by rw [PartialEquiv.trans_symm_eq_symm_trans_symm, PartialEquiv.symm_symm] theorem symm_trans_source_eq (e e' : Pretrivialization F proj) : (e.toPartialEquiv.symm.trans e'.toPartialEquiv).source = (e.baseSet ∩ e'.baseSet) ×ˢ univ := by rw [PartialEquiv.trans_source, e'.source_eq, PartialEquiv.symm_source, e.target_eq, inter_comm, e.preimage_symm_proj_inter, inter_comm] theorem symm_trans_target_eq (e e' : Pretrivialization F proj) : (e.toPartialEquiv.symm.trans e'.toPartialEquiv).target = (e.baseSet ∩ e'.baseSet) ×ˢ univ := by rw [← PartialEquiv.symm_source, symm_trans_symm, symm_trans_source_eq, inter_comm] variable (e' : Pretrivialization F (π F E)) {b : B} {y : E b} @[simp] theorem coe_mem_source : ↑y ∈ e'.source ↔ b ∈ e'.baseSet := e'.mem_source @[mfld_simps] theorem coe_coe_fst (hb : b ∈ e'.baseSet) : (e' y).1 = b := by simp [hb] theorem mk_mem_target {x : B} {y : F} : (x, y) ∈ e'.target ↔ x ∈ e'.baseSet := e'.mem_target theorem symm_coe_proj {x : B} {y : F} (e' : Pretrivialization F (π F E)) (h : x ∈ e'.baseSet) : (e'.toPartialEquiv.symm (x, y)).1 = x := e'.proj_symm_apply' h section Zero variable [∀ x, Zero (E x)] open Classical in /-- A fiberwise inverse to `e`. This is the function `F → E b` that induces a local inverse `B × F → TotalSpace F E` of `e` on `e.baseSet`. It is defined to be `0` outside `e.baseSet`. -/ protected noncomputable def symm (e : Pretrivialization F (π F E)) (b : B) (y : F) : E b := if hb : b ∈ e.baseSet then cast (congr_arg E (e.proj_symm_apply' hb)) (e.toPartialEquiv.symm (b, y)).2 else 0 theorem symm_apply (e : Pretrivialization F (π F E)) {b : B} (hb : b ∈ e.baseSet) (y : F) : e.symm b y = cast (congr_arg E (e.symm_coe_proj hb)) (e.toPartialEquiv.symm (b, y)).2 := dif_pos hb theorem symm_apply_of_notMem (e : Pretrivialization F (π F E)) {b : B} (hb : b ∉ e.baseSet) (y : F) : e.symm b y = 0 := dif_neg hb @[deprecated (since := "2025-05-23")] alias symm_apply_of_not_mem := symm_apply_of_notMem theorem coe_symm_of_notMem (e : Pretrivialization F (π F E)) {b : B} (hb : b ∉ e.baseSet) : (e.symm b : F → E b) = 0 := funext fun _ => dif_neg hb @[deprecated (since := "2025-05-23")] alias coe_symm_of_not_mem := coe_symm_of_notMem theorem mk_symm (e : Pretrivialization F (π F E)) {b : B} (hb : b ∈ e.baseSet) (y : F) : TotalSpace.mk b (e.symm b y) = e.toPartialEquiv.symm (b, y) := by simp only [e.symm_apply hb, TotalSpace.mk_cast (e.proj_symm_apply' hb), TotalSpace.eta] theorem symm_proj_apply (e : Pretrivialization F (π F E)) (z : TotalSpace F E) (hz : z.proj ∈ e.baseSet) : e.symm z.proj (e z).2 = z.2 := by rw [e.symm_apply hz, cast_eq_iff_heq, e.mk_proj_snd' hz, e.symm_apply_apply (e.mem_source.mpr hz)] theorem symm_apply_apply_mk (e : Pretrivialization F (π F E)) {b : B} (hb : b ∈ e.baseSet) (y : E b) : e.symm b (e ⟨b, y⟩).2 = y := e.symm_proj_apply ⟨b, y⟩ hb @[simp] theorem apply_mk_symm (e : Pretrivialization F (π F E)) {b : B} (hb : b ∈ e.baseSet) (y : F) : e ⟨b, e.symm b y⟩ = (b, y) := by rw [e.mk_symm hb, e.apply_symm_apply (e.mk_mem_target.mpr hb)] end Zero end Pretrivialization variable [TopologicalSpace Z] [TopologicalSpace (TotalSpace F E)] /-- A structure extending open partial homeomorphisms, defining a local trivialization of a projection `proj : Z → B` with fiber `F`, as an open partial homeomorphism between `Z` and `B × F` defined between two sets of the form `proj ⁻¹' baseSet` and `baseSet × F`, acting trivially on the first coordinate. -/ structure Trivialization (proj : Z → B) extends OpenPartialHomeomorph Z (B × F) where /-- The domain of the local trivialisation (i.e., a subset of the bundle `Z`'s base): outside of it, the pretrivialisation returns a junk value -/ baseSet : Set B open_baseSet : IsOpen baseSet source_eq : source = proj ⁻¹' baseSet target_eq : target = baseSet ×ˢ univ proj_toFun : ∀ p ∈ source, (toOpenPartialHomeomorph p).1 = proj p namespace Trivialization variable {F} variable (e : Trivialization F proj) {x : Z} @[ext] lemma ext' (e e' : Trivialization F proj) (h₁ : e.toOpenPartialHomeomorph = e'.toOpenPartialHomeomorph) (h₂ : e.baseSet = e'.baseSet) : e = e' := by cases e; cases e'; congr /-- Coercion of a trivialization to a function. We don't use `e.toFun` in the `CoeFun` instance because it is actually `e.toPartialEquiv.toFun`, so `simp` will apply lemmas about `toPartialEquiv`. While we may want to switch to this behavior later, doing it mid-port will break a lot of proofs. -/ @[coe] def toFun' : Z → (B × F) := e.toFun /-- Natural identification as a `Pretrivialization`. -/ def toPretrivialization : Pretrivialization F proj := { e with } instance : CoeFun (Trivialization F proj) fun _ => Z → B × F := ⟨toFun'⟩ instance : Coe (Trivialization F proj) (Pretrivialization F proj) := ⟨toPretrivialization⟩ /-- See Note [custom simps projection] -/ def Simps.apply (proj : Z → B) (e : Trivialization F proj) : Z → B × F := e /-- See Note [custom simps projection] -/ noncomputable def Simps.symm_apply (proj : Z → B) (e : Trivialization F proj) : B × F → Z := e.toOpenPartialHomeomorph.symm initialize_simps_projections Trivialization (toFun → apply, invFun → symm_apply) theorem toPretrivialization_injective : Function.Injective fun e : Trivialization F proj => e.toPretrivialization := fun e e' h => by ext1 exacts [OpenPartialHomeomorph.toPartialEquiv_injective (congr_arg Pretrivialization.toPartialEquiv h), congr_arg Pretrivialization.baseSet h] @[simp, mfld_simps] theorem coe_coe : ⇑e.toOpenPartialHomeomorph = e := rfl @[simp, mfld_simps] theorem coe_fst (ex : x ∈ e.source) : (e x).1 = proj x := e.proj_toFun x ex protected theorem eqOn : EqOn (Prod.fst ∘ e) proj e.source := fun _x hx => e.coe_fst hx theorem mem_source : x ∈ e.source ↔ proj x ∈ e.baseSet := by rw [e.source_eq, mem_preimage] theorem coe_fst' (ex : proj x ∈ e.baseSet) : (e x).1 = proj x := e.coe_fst (e.mem_source.2 ex) theorem mk_proj_snd (ex : x ∈ e.source) : (proj x, (e x).2) = e x := Prod.ext (e.coe_fst ex).symm rfl theorem mk_proj_snd' (ex : proj x ∈ e.baseSet) : (proj x, (e x).2) = e x := Prod.ext (e.coe_fst' ex).symm rfl theorem source_inter_preimage_target_inter (s : Set (B × F)) : e.source ∩ e ⁻¹' (e.target ∩ s) = e.source ∩ e ⁻¹' s := e.toOpenPartialHomeomorph.source_inter_preimage_target_inter s @[simp, mfld_simps] theorem coe_mk (e : OpenPartialHomeomorph Z (B × F)) (i j k l m) (x : Z) : (Trivialization.mk e i j k l m : Trivialization F proj) x = e x := rfl theorem mem_target {x : B × F} : x ∈ e.target ↔ x.1 ∈ e.baseSet := e.toPretrivialization.mem_target theorem map_target {x : B × F} (hx : x ∈ e.target) : e.toOpenPartialHomeomorph.symm x ∈ e.source := e.toOpenPartialHomeomorph.map_target hx theorem proj_symm_apply {x : B × F} (hx : x ∈ e.target) : proj (e.toOpenPartialHomeomorph.symm x) = x.1 := e.toPretrivialization.proj_symm_apply hx theorem proj_symm_apply' {b : B} {x : F} (hx : b ∈ e.baseSet) : proj (e.toOpenPartialHomeomorph.symm (b, x)) = b := e.toPretrivialization.proj_symm_apply' hx theorem proj_surjOn_baseSet [Nonempty F] : Set.SurjOn proj e.source e.baseSet := e.toPretrivialization.proj_surjOn_baseSet theorem apply_symm_apply {x : B × F} (hx : x ∈ e.target) : e (e.toOpenPartialHomeomorph.symm x) = x := e.toOpenPartialHomeomorph.right_inv hx theorem apply_symm_apply' {b : B} {x : F} (hx : b ∈ e.baseSet) : e (e.toOpenPartialHomeomorph.symm (b, x)) = (b, x) := e.toPretrivialization.apply_symm_apply' hx @[simp, mfld_simps] theorem symm_apply_mk_proj (ex : x ∈ e.source) : e.toOpenPartialHomeomorph.symm (proj x, (e x).2) = x := e.toPretrivialization.symm_apply_mk_proj ex theorem symm_trans_source_eq (e e' : Trivialization F proj) : (e.toPartialEquiv.symm.trans e'.toPartialEquiv).source = (e.baseSet ∩ e'.baseSet) ×ˢ univ := Pretrivialization.symm_trans_source_eq e.toPretrivialization e' theorem symm_trans_target_eq (e e' : Trivialization F proj) : (e.toPartialEquiv.symm.trans e'.toPartialEquiv).target = (e.baseSet ∩ e'.baseSet) ×ˢ univ := Pretrivialization.symm_trans_target_eq e.toPretrivialization e' theorem coe_fst_eventuallyEq_proj (ex : x ∈ e.source) : Prod.fst ∘ e =ᶠ[𝓝 x] proj := mem_nhds_iff.2 ⟨e.source, fun _y hy => e.coe_fst hy, e.open_source, ex⟩ theorem coe_fst_eventuallyEq_proj' (ex : proj x ∈ e.baseSet) : Prod.fst ∘ e =ᶠ[𝓝 x] proj := e.coe_fst_eventuallyEq_proj (e.mem_source.2 ex) theorem map_proj_nhds (ex : x ∈ e.source) : map proj (𝓝 x) = 𝓝 (proj x) := by rw [← e.coe_fst ex, ← map_congr (e.coe_fst_eventuallyEq_proj ex), ← map_map, ← e.coe_coe, e.map_nhds_eq ex, map_fst_nhds] theorem preimage_subset_source {s : Set B} (hb : s ⊆ e.baseSet) : proj ⁻¹' s ⊆ e.source := fun _p hp => e.mem_source.mpr (hb hp) theorem image_preimage_eq_prod_univ {s : Set B} (hb : s ⊆ e.baseSet) : e '' (proj ⁻¹' s) = s ×ˢ univ := Subset.antisymm (image_subset_iff.mpr fun p hp => ⟨(e.proj_toFun p (e.preimage_subset_source hb hp)).symm ▸ hp, trivial⟩) fun p hp => let hp' : p ∈ e.target := e.mem_target.mpr (hb hp.1) ⟨e.invFun p, mem_preimage.mpr ((e.proj_symm_apply hp').symm ▸ hp.1), e.apply_symm_apply hp'⟩ theorem tendsto_nhds_iff {α : Type*} {l : Filter α} {f : α → Z} {z : Z} (hz : z ∈ e.source) : Tendsto f l (𝓝 z) ↔ Tendsto (proj ∘ f) l (𝓝 (proj z)) ∧ Tendsto (fun x ↦ (e (f x)).2) l (𝓝 (e z).2) := by rw [e.nhds_eq_comap_inf_principal hz, tendsto_inf, tendsto_comap_iff, Prod.tendsto_iff, coe_coe, tendsto_principal, coe_fst _ hz] by_cases hl : ∀ᶠ x in l, f x ∈ e.source · simp only [hl, and_true] refine (tendsto_congr' ?_).and Iff.rfl exact hl.mono fun x ↦ e.coe_fst · simp only [hl, and_false, false_iff, not_and] rw [e.source_eq] at hl hz exact fun h _ ↦ hl <| h <| e.open_baseSet.mem_nhds hz theorem nhds_eq_inf_comap {z : Z} (hz : z ∈ e.source) : 𝓝 z = comap proj (𝓝 (proj z)) ⊓ comap (Prod.snd ∘ e) (𝓝 (e z).2) := by refine eq_of_forall_le_iff fun l ↦ ?_ rw [le_inf_iff, ← tendsto_iff_comap, ← tendsto_iff_comap] exact e.tendsto_nhds_iff hz /-- The preimage of a subset of the base set is homeomorphic to the product with the fiber. -/ def preimageHomeomorph {s : Set B} (hb : s ⊆ e.baseSet) : proj ⁻¹' s ≃ₜ s × F := (e.toOpenPartialHomeomorph.homeomorphOfImageSubsetSource (e.preimage_subset_source hb) (e.image_preimage_eq_prod_univ hb)).trans ((Homeomorph.Set.prod s univ).trans ((Homeomorph.refl s).prodCongr (Homeomorph.Set.univ F))) @[simp] theorem preimageHomeomorph_apply {s : Set B} (hb : s ⊆ e.baseSet) (p : proj ⁻¹' s) : e.preimageHomeomorph hb p = (⟨proj p, p.2⟩, (e p).2) := Prod.ext (Subtype.ext (e.proj_toFun p (e.mem_source.mpr (hb p.2)))) rfl /-- Auxiliary definition to avoid looping in `dsimp` with `Trivialization.preimageHomeomorph_symm_apply`. -/ protected def preimageHomeomorph_symm_apply.aux {s : Set B} (hb : s ⊆ e.baseSet) := (e.preimageHomeomorph hb).symm @[simp] theorem preimageHomeomorph_symm_apply {s : Set B} (hb : s ⊆ e.baseSet) (p : s × F) : (e.preimageHomeomorph hb).symm p = ⟨e.symm (p.1, p.2), ((preimageHomeomorph_symm_apply.aux e hb) p).2⟩ := rfl /-- The source is homeomorphic to the product of the base set with the fiber. -/ def sourceHomeomorphBaseSetProd : e.source ≃ₜ e.baseSet × F := (Homeomorph.setCongr e.source_eq).trans (e.preimageHomeomorph subset_rfl) @[simp] theorem sourceHomeomorphBaseSetProd_apply (p : e.source) : e.sourceHomeomorphBaseSetProd p = (⟨proj p, e.mem_source.mp p.2⟩, (e p).2) := e.preimageHomeomorph_apply subset_rfl ⟨p, e.mem_source.mp p.2⟩ /-- Auxiliary definition to avoid looping in `dsimp` with `Trivialization.sourceHomeomorphBaseSetProd_symm_apply`. -/ protected def sourceHomeomorphBaseSetProd_symm_apply.aux := e.sourceHomeomorphBaseSetProd.symm @[simp] theorem sourceHomeomorphBaseSetProd_symm_apply (p : e.baseSet × F) : e.sourceHomeomorphBaseSetProd.symm p = ⟨e.symm (p.1, p.2), (sourceHomeomorphBaseSetProd_symm_apply.aux e p).2⟩ := rfl /-- Each fiber of a trivialization is homeomorphic to the specified fiber. -/ def preimageSingletonHomeomorph {b : B} (hb : b ∈ e.baseSet) : proj ⁻¹' {b} ≃ₜ F := .trans (e.preimageHomeomorph (Set.singleton_subset_iff.mpr hb)) <| .trans (.prodCongr (Homeomorph.homeomorphOfUnique ({b} : Set B) PUnit.{1}) (Homeomorph.refl F)) (Homeomorph.punitProd F) @[simp] theorem preimageSingletonHomeomorph_apply {b : B} (hb : b ∈ e.baseSet) (p : proj ⁻¹' {b}) : e.preimageSingletonHomeomorph hb p = (e p).2 := rfl @[simp] theorem preimageSingletonHomeomorph_symm_apply {b : B} (hb : b ∈ e.baseSet) (p : F) : (e.preimageSingletonHomeomorph hb).symm p = ⟨e.symm (b, p), by rw [mem_preimage, e.proj_symm_apply' hb, mem_singleton_iff]⟩ := rfl /-- In the domain of a bundle trivialization, the projection is continuous -/ theorem continuousAt_proj (ex : x ∈ e.source) : ContinuousAt proj x := (e.map_proj_nhds ex).le theorem continuousOn_proj : ContinuousOn proj e.source := continuousOn_of_forall_continuousAt fun _ ↦ e.continuousAt_proj /-- Composition of a `Trivialization` and a `Homeomorph`. -/ protected def compHomeomorph {Z' : Type*} [TopologicalSpace Z'] (h : Z' ≃ₜ Z) : Trivialization F (proj ∘ h) where toOpenPartialHomeomorph := h.toOpenPartialHomeomorph.trans e.toOpenPartialHomeomorph baseSet := e.baseSet open_baseSet := e.open_baseSet source_eq := by simp [source_eq, preimage_preimage, Function.comp_def] target_eq := by simp [target_eq] proj_toFun p hp := by have hp : h p ∈ e.source := by simpa using hp simp [hp] /-- Read off the continuity of a function `f : Z → X` at `z : Z` by transferring via a trivialization of `Z` containing `z`. -/ theorem continuousAt_of_comp_right {X : Type*} [TopologicalSpace X] {f : Z → X} {z : Z} (e : Trivialization F proj) (he : proj z ∈ e.baseSet) (hf : ContinuousAt (f ∘ e.toPartialEquiv.symm) (e z)) : ContinuousAt f z := by have hez : z ∈ e.toPartialEquiv.symm.target := by rw [PartialEquiv.symm_target, e.mem_source] exact he rwa [e.toOpenPartialHomeomorph.symm.continuousAt_iff_continuousAt_comp_right hez, OpenPartialHomeomorph.symm_symm] /-- Read off the continuity of a function `f : X → Z` at `x : X` by transferring via a trivialization of `Z` containing `f x`. -/ theorem continuousAt_of_comp_left {X : Type*} [TopologicalSpace X] {f : X → Z} {x : X} (e : Trivialization F proj) (hf_proj : ContinuousAt (proj ∘ f) x) (he : proj (f x) ∈ e.baseSet) (hf : ContinuousAt (e ∘ f) x) : ContinuousAt f x := by rw [e.continuousAt_iff_continuousAt_comp_left] · exact hf rw [e.source_eq, ← preimage_comp] exact hf_proj.preimage_mem_nhds (e.open_baseSet.mem_nhds he) variable (e' : Trivialization F (π F E)) {b : B} {y : E b} protected theorem continuousOn : ContinuousOn e' e'.source := e'.continuousOn_toFun theorem coe_mem_source : ↑y ∈ e'.source ↔ b ∈ e'.baseSet := e'.mem_source @[simp, mfld_simps] theorem coe_coe_fst (hb : b ∈ e'.baseSet) : (e' y).1 = b := e'.coe_fst (e'.mem_source.2 hb) theorem mk_mem_target {y : F} : (b, y) ∈ e'.target ↔ b ∈ e'.baseSet := e'.toPretrivialization.mem_target theorem symm_apply_apply {x : TotalSpace F E} (hx : x ∈ e'.source) : e'.toOpenPartialHomeomorph.symm (e' x) = x := e'.toPartialEquiv.left_inv hx @[simp, mfld_simps] theorem symm_coe_proj {x : B} {y : F} (e : Trivialization F (π F E)) (h : x ∈ e.baseSet) : (e.toOpenPartialHomeomorph.symm (x, y)).1 = x := e.proj_symm_apply' h section Zero variable [∀ x, Zero (E x)] /-- A fiberwise inverse to `e'`. The function `F → E x` that induces a local inverse `B × F → TotalSpace F E` of `e'` on `e'.baseSet`. It is defined to be `0` outside `e'.baseSet`. -/ protected noncomputable def symm (e : Trivialization F (π F E)) (b : B) (y : F) : E b := e.toPretrivialization.symm b y theorem symm_apply (e : Trivialization F (π F E)) {b : B} (hb : b ∈ e.baseSet) (y : F) : e.symm b y = cast (congr_arg E (e.symm_coe_proj hb)) (e.toOpenPartialHomeomorph.symm (b, y)).2 := dif_pos hb theorem symm_apply_of_notMem (e : Trivialization F (π F E)) {b : B} (hb : b ∉ e.baseSet) (y : F) : e.symm b y = 0 := dif_neg hb @[deprecated (since := "2025-05-23")] alias symm_apply_of_not_mem := symm_apply_of_notMem theorem mk_symm (e : Trivialization F (π F E)) {b : B} (hb : b ∈ e.baseSet) (y : F) : TotalSpace.mk b (e.symm b y) = e.toOpenPartialHomeomorph.symm (b, y) := e.toPretrivialization.mk_symm hb y theorem symm_proj_apply (e : Trivialization F (π F E)) (z : TotalSpace F E) (hz : z.proj ∈ e.baseSet) : e.symm z.proj (e z).2 = z.2 := e.toPretrivialization.symm_proj_apply z hz theorem symm_apply_apply_mk (e : Trivialization F (π F E)) {b : B} (hb : b ∈ e.baseSet) (y : E b) : e.symm b (e ⟨b, y⟩).2 = y := e.symm_proj_apply ⟨b, y⟩ hb @[simp, mfld_simps] theorem apply_mk_symm (e : Trivialization F (π F E)) {b : B} (hb : b ∈ e.baseSet) (y : F) : e ⟨b, e.symm b y⟩ = (b, y) := e.toPretrivialization.apply_mk_symm hb y theorem continuousOn_symm (e : Trivialization F (π F E)) : ContinuousOn (fun z : B × F => TotalSpace.mk' F z.1 (e.symm z.1 z.2)) (e.baseSet ×ˢ univ) := by have : ∀ z ∈ e.baseSet ×ˢ (univ : Set F), TotalSpace.mk z.1 (e.symm z.1 z.2) = e.toOpenPartialHomeomorph.symm z := by rintro x ⟨hx : x.1 ∈ e.baseSet, _⟩ rw [e.mk_symm hx] refine ContinuousOn.congr ?_ this rw [← e.target_eq] exact e.toOpenPartialHomeomorph.continuousOn_symm end Zero /-- If `e` is a `Trivialization` of `proj : Z → B` with fiber `F` and `h` is a homeomorphism `F ≃ₜ F'`, then `e.trans_fiber_homeomorph h` is the trivialization of `proj` with the fiber `F'` that sends `p : Z` to `((e p).1, h (e p).2)`. -/ def transFiberHomeomorph {F' : Type*} [TopologicalSpace F'] (e : Trivialization F proj) (h : F ≃ₜ F') : Trivialization F' proj where toOpenPartialHomeomorph := e.toOpenPartialHomeomorph.transHomeomorph <| (Homeomorph.refl _).prodCongr h baseSet := e.baseSet open_baseSet := e.open_baseSet source_eq := e.source_eq target_eq := by simp [target_eq, prod_univ, preimage_preimage] proj_toFun := e.proj_toFun @[simp] theorem transFiberHomeomorph_apply {F' : Type*} [TopologicalSpace F'] (e : Trivialization F proj) (h : F ≃ₜ F') (x : Z) : e.transFiberHomeomorph h x = ((e x).1, h (e x).2) := rfl /-- Coordinate transformation in the fiber induced by a pair of bundle trivializations. See also `Trivialization.coordChangeHomeomorph` for a version bundled as `F ≃ₜ F`. -/ def coordChange (e₁ e₂ : Trivialization F proj) (b : B) (x : F) : F := (e₂ <| e₁.toOpenPartialHomeomorph.symm (b, x)).2 theorem mk_coordChange (e₁ e₂ : Trivialization F proj) {b : B} (h₁ : b ∈ e₁.baseSet) (h₂ : b ∈ e₂.baseSet) (x : F) : (b, e₁.coordChange e₂ b x) = e₂ (e₁.toOpenPartialHomeomorph.symm (b, x)) := by refine Prod.ext ?_ rfl rw [e₂.coe_fst', ← e₁.coe_fst', e₁.apply_symm_apply' h₁] · rwa [e₁.proj_symm_apply' h₁] · rwa [e₁.proj_symm_apply' h₁] theorem coordChange_apply_snd (e₁ e₂ : Trivialization F proj) {p : Z} (h : proj p ∈ e₁.baseSet) : e₁.coordChange e₂ (proj p) (e₁ p).snd = (e₂ p).snd := by rw [coordChange, e₁.symm_apply_mk_proj (e₁.mem_source.2 h)] theorem coordChange_same_apply (e : Trivialization F proj) {b : B} (h : b ∈ e.baseSet) (x : F) : e.coordChange e b x = x := by rw [coordChange, e.apply_symm_apply' h] theorem coordChange_same (e : Trivialization F proj) {b : B} (h : b ∈ e.baseSet) : e.coordChange e b = id := funext <| e.coordChange_same_apply h theorem coordChange_coordChange (e₁ e₂ e₃ : Trivialization F proj) {b : B} (h₁ : b ∈ e₁.baseSet) (h₂ : b ∈ e₂.baseSet) (x : F) : e₂.coordChange e₃ b (e₁.coordChange e₂ b x) = e₁.coordChange e₃ b x := by rw [coordChange, e₁.mk_coordChange _ h₁ h₂, ← e₂.coe_coe, e₂.left_inv, coordChange] rwa [e₂.mem_source, e₁.proj_symm_apply' h₁] theorem continuous_coordChange (e₁ e₂ : Trivialization F proj) {b : B} (h₁ : b ∈ e₁.baseSet) (h₂ : b ∈ e₂.baseSet) : Continuous (e₁.coordChange e₂ b) := by refine continuous_snd.comp (e₂.toOpenPartialHomeomorph.continuousOn.comp_continuous (e₁.toOpenPartialHomeomorph.continuousOn_symm.comp_continuous ?_ ?_) ?_) · fun_prop · exact fun x => e₁.mem_target.2 h₁ · intro x rwa [e₂.mem_source, e₁.proj_symm_apply' h₁] /-- Coordinate transformation in the fiber induced by a pair of bundle trivializations, as a homeomorphism. -/ protected def coordChangeHomeomorph (e₁ e₂ : Trivialization F proj) {b : B} (h₁ : b ∈ e₁.baseSet) (h₂ : b ∈ e₂.baseSet) : F ≃ₜ F where toFun := e₁.coordChange e₂ b invFun := e₂.coordChange e₁ b left_inv x := by simp only [*, coordChange_coordChange, coordChange_same_apply] right_inv x := by simp only [*, coordChange_coordChange, coordChange_same_apply] continuous_toFun := e₁.continuous_coordChange e₂ h₁ h₂ continuous_invFun := e₂.continuous_coordChange e₁ h₂ h₁ @[simp] theorem coordChangeHomeomorph_coe (e₁ e₂ : Trivialization F proj) {b : B} (h₁ : b ∈ e₁.baseSet) (h₂ : b ∈ e₂.baseSet) : ⇑(e₁.coordChangeHomeomorph e₂ h₁ h₂) = e₁.coordChange e₂ b := rfl theorem isImage_preimage_prod (e : Trivialization F proj) (s : Set B) : e.toOpenPartialHomeomorph.IsImage (proj ⁻¹' s) (s ×ˢ univ) := fun x hx => by simp [hx] /-- Restrict a `Trivialization` to an open set in the base. -/ protected def restrOpen (e : Trivialization F proj) (s : Set B) (hs : IsOpen s) : Trivialization F proj where toOpenPartialHomeomorph := ((e.isImage_preimage_prod s).symm.restr (IsOpen.inter e.open_target (hs.prod isOpen_univ))).symm baseSet := e.baseSet ∩ s open_baseSet := IsOpen.inter e.open_baseSet hs source_eq := by simp [source_eq] target_eq := by simp [target_eq, prod_univ] proj_toFun p hp := e.proj_toFun p hp.1 section Piecewise theorem frontier_preimage (e : Trivialization F proj) (s : Set B) : e.source ∩ frontier (proj ⁻¹' s) = proj ⁻¹' (e.baseSet ∩ frontier s) := by rw [← (e.isImage_preimage_prod s).frontier.preimage_eq, frontier_prod_univ_eq, (e.isImage_preimage_prod _).preimage_eq, e.source_eq, preimage_inter] open Classical in /-- Given two bundle trivializations `e`, `e'` of `proj : Z → B` and a set `s : Set B` such that the base sets of `e` and `e'` intersect `frontier s` on the same set and `e p = e' p` whenever `proj p ∈ e.baseSet ∩ frontier s`, `e.piecewise e' s Hs Heq` is the bundle trivialization over `Set.ite s e.baseSet e'.baseSet` that is equal to `e` on `proj ⁻¹ s` and is equal to `e'` otherwise. -/ noncomputable def piecewise (e e' : Trivialization F proj) (s : Set B) (Hs : e.baseSet ∩ frontier s = e'.baseSet ∩ frontier s) (Heq : EqOn e e' <| proj ⁻¹' (e.baseSet ∩ frontier s)) : Trivialization F proj where toOpenPartialHomeomorph := e.toOpenPartialHomeomorph.piecewise e'.toOpenPartialHomeomorph (proj ⁻¹' s) (s ×ˢ univ) (e.isImage_preimage_prod s) (e'.isImage_preimage_prod s) (by rw [e.frontier_preimage, e'.frontier_preimage, Hs]) (by rwa [e.frontier_preimage]) baseSet := s.ite e.baseSet e'.baseSet open_baseSet := e.open_baseSet.ite e'.open_baseSet Hs source_eq := by simp [source_eq] target_eq := by simp [target_eq, prod_univ] proj_toFun p := by rintro (⟨he, hs⟩ | ⟨he, hs⟩) <;> simp [*] /-- Given two bundle trivializations `e`, `e'` of a topological fiber bundle `proj : Z → B` over a linearly ordered base `B` and a point `a ∈ e.baseSet ∩ e'.baseSet` such that `e` equals `e'` on `proj ⁻¹' {a}`, `e.piecewise_le_of_eq e' a He He' Heq` is the bundle trivialization over `Set.ite (Iic a) e.baseSet e'.baseSet` that is equal to `e` on points `p` such that `proj p ≤ a` and is equal to `e'` otherwise. -/ noncomputable def piecewiseLeOfEq [LinearOrder B] [OrderTopology B] (e e' : Trivialization F proj) (a : B) (He : a ∈ e.baseSet) (He' : a ∈ e'.baseSet) (Heq : ∀ p, proj p = a → e p = e' p) : Trivialization F proj := e.piecewise e' (Iic a) (Set.ext fun x => and_congr_left_iff.2 fun hx => by obtain rfl : x = a := mem_singleton_iff.1 (frontier_Iic_subset _ hx) simp [He, He']) fun p hp => Heq p <| frontier_Iic_subset _ hp.2 /-- Given two bundle trivializations `e`, `e'` of a topological fiber bundle `proj : Z → B` over a linearly ordered base `B` and a point `a ∈ e.baseSet ∩ e'.baseSet`, `e.piecewise_le e' a He He'` is the bundle trivialization over `Set.ite (Iic a) e.baseSet e'.baseSet` that is equal to `e` on points `p` such that `proj p ≤ a` and is equal to `((e' p).1, h (e' p).2)` otherwise, where `h = e'.coord_change_homeomorph e _ _` is the homeomorphism of the fiber such that `h (e' p).2 = (e p).2` whenever `e p = a`. -/ noncomputable def piecewiseLe [LinearOrder B] [OrderTopology B] (e e' : Trivialization F proj) (a : B) (He : a ∈ e.baseSet) (He' : a ∈ e'.baseSet) : Trivialization F proj := e.piecewiseLeOfEq (e'.transFiberHomeomorph (e'.coordChangeHomeomorph e He' He)) a He He' <| by rintro p rfl ext1 · simp [e.coe_fst', e'.coe_fst', *] · simp [coordChange_apply_snd, *] open Classical in /-- Given two bundle trivializations `e`, `e'` over disjoint sets, `e.disjoint_union e' H` is the bundle trivialization over the union of the base sets that agrees with `e` and `e'` over their base sets. -/ noncomputable def disjointUnion (e e' : Trivialization F proj) (H : Disjoint e.baseSet e'.baseSet) : Trivialization F proj where toOpenPartialHomeomorph := e.toOpenPartialHomeomorph.disjointUnion e'.toOpenPartialHomeomorph (by rw [e.source_eq, e'.source_eq] exact H.preimage _) (by rw [e.target_eq, e'.target_eq, disjoint_iff_inf_le] intro x hx exact H.le_bot ⟨hx.1.1, hx.2.1⟩) baseSet := e.baseSet ∪ e'.baseSet open_baseSet := IsOpen.union e.open_baseSet e'.open_baseSet source_eq := congr_arg₂ (· ∪ ·) e.source_eq e'.source_eq target_eq := (congr_arg₂ (· ∪ ·) e.target_eq e'.target_eq).trans union_prod.symm proj_toFun := by rintro p (hp | hp') · change (e.source.piecewise e e' p).1 = proj p rw [piecewise_eq_of_mem, e.coe_fst] <;> exact hp · change (e.source.piecewise e e' p).1 = proj p rw [piecewise_eq_of_notMem, e'.coe_fst hp'] simp only [source_eq] at hp' ⊢ exact fun h => H.le_bot ⟨h, hp'⟩ end Piecewise section Lift /-- The local lifting through a Trivialization `T` from the base to the leaf containing `z`. -/ def lift (T : Trivialization F proj) (z : Z) (b : B) : Z := T.invFun (b, (T z).2) variable {T : Trivialization F proj} {z : Z} {b : B} @[simp] theorem lift_self (he : proj z ∈ T.baseSet) : T.lift z (proj z) = z := symm_apply_mk_proj _ <| T.mem_source.2 he theorem proj_lift (hx : b ∈ T.baseSet) : proj (T.lift z b) = b := T.proj_symm_apply <| T.mem_target.2 hx /-- The restriction of `lift` to the source and base set of `T`, as a bundled continuous map. -/ def liftCM (T : Trivialization F proj) : C(T.source × T.baseSet, T.source) where toFun ex := ⟨T.lift ex.1 ex.2, T.map_target (by simp [mem_target])⟩ continuous_toFun := by apply Continuous.subtype_mk refine T.continuousOn_invFun.comp_continuous ?_ (by simp [mem_target]) refine .prodMk (by fun_prop) (.snd ?_) exact T.continuousOn_toFun.comp_continuous (by fun_prop) (by simp) variable {ι : Type*} [TopologicalSpace ι] [LocallyCompactPair ι T.baseSet] {γ : C(ι, T.baseSet)} {i : ι} {e : T.source} /-- Extension of `liftCM` to continuous maps taking values in `T.baseSet` (local version of homotopy lifting) -/ def clift (T : Trivialization F proj) [LocallyCompactPair ι T.baseSet] : C(T.source × C(ι, T.baseSet), C(ι, T.source)) := by let Ψ : C((T.source × C(ι, T.baseSet)) × ι, C(ι, T.baseSet) × ι) := ⟨fun eγt => (eγt.1.2, eγt.2), by fun_prop⟩ refine ContinuousMap.curry <| T.liftCM.comp <| ⟨fun eγt => ⟨eγt.1.1, eγt.1.2 eγt.2⟩, ?_⟩ simpa using ⟨by fun_prop, ContinuousEval.continuous_eval.comp Ψ.continuous⟩ @[simp] theorem clift_self (h : proj e.1 = γ i) : T.clift (e, γ) i = e := by have : proj e ∈ T.baseSet := by simp [h] simp [clift, liftCM, ← h, lift_self, this] theorem proj_clift : proj (T.clift (e, γ) i) = γ i := by simp [clift, liftCM, proj_lift] end Lift end Trivialization
.lake/packages/mathlib/Mathlib/Topology/Instances/CantorSet.lean
import Mathlib.Analysis.Real.OfDigits import Mathlib.Data.Stream.Init import Mathlib.Topology.Algebra.GroupWithZero import Mathlib.Topology.Algebra.Ring.Real import Mathlib.Tactic.FinCases import Mathlib.Tactic.Field /-! # Ternary Cantor Set This file defines the Cantor ternary set and proves a few properties. ## Main Definitions * `preCantorSet n`: The order `n` pre-Cantor set, defined inductively as the union of the images under the functions `(· / 3)` and `((2 + ·) / 3)`, with `preCantorSet 0 := Set.Icc 0 1`, i.e. `preCantorSet 0` is the unit interval [0,1]. * `cantorSet`: The ternary Cantor set, defined as the intersection of all pre-Cantor sets. * `cantorToTernary`: given a number `x` in the Cantor set, returns its ternary representation `(d₀, d₁, ...)` consisting only of digits `0` and `2`, such that `x = 0.d₀d₁...` (see `ofDigits_cantorToTernary`). * `ofDigits_zero_two_sequence_mem_cantorSet`: any such sequence corresponds to a number in the Cantor set. * `ofDigits_zero_two_sequence_unique`: such a representation is unique. -/ /-- The order `n` pre-Cantor set, defined starting from `[0, 1]` and successively removing the middle third of each interval. Formally, the order `n + 1` pre-Cantor set is the union of the images under the functions `(· / 3)` and `((2 + ·) / 3)` of `preCantorSet n`. -/ def preCantorSet : ℕ → Set ℝ | 0 => Set.Icc 0 1 | n + 1 => (· / 3) '' preCantorSet n ∪ (fun x ↦ (2 + x) / 3) '' preCantorSet n @[simp] lemma preCantorSet_zero : preCantorSet 0 = Set.Icc 0 1 := rfl @[simp] lemma preCantorSet_succ (n : ℕ) : preCantorSet (n + 1) = (· / 3) '' preCantorSet n ∪ (fun x ↦ (2 + x) / 3) '' preCantorSet n := rfl /-- The Cantor set is the subset of the unit interval obtained as the intersection of all pre-Cantor sets. This means that the Cantor set is obtained by iteratively removing the open middle third of each subinterval, starting from the unit interval `[0, 1]`. -/ def cantorSet : Set ℝ := ⋂ n, preCantorSet n /-! ## Simple Properties -/ lemma quarters_mem_preCantorSet (n : ℕ) : 1 / 4 ∈ preCantorSet n ∧ 3 / 4 ∈ preCantorSet n := by induction n with | zero => simp only [preCantorSet_zero] refine ⟨⟨ ?_, ?_⟩, ?_, ?_⟩ <;> norm_num | succ n ih => apply And.intro · -- goal: 1 / 4 ∈ preCantorSet (n + 1) -- follows by the inductive hypothesis, since 3 / 4 ∈ preCantorSet n exact Or.inl ⟨3 / 4, ih.2, by norm_num⟩ · -- goal: 3 / 4 ∈ preCantorSet (n + 1) -- follows by the inductive hypothesis, since 1 / 4 ∈ preCantorSet n exact Or.inr ⟨1 / 4, ih.1, by norm_num⟩ lemma quarter_mem_preCantorSet (n : ℕ) : 1 / 4 ∈ preCantorSet n := (quarters_mem_preCantorSet n).1 theorem quarter_mem_cantorSet : 1 / 4 ∈ cantorSet := Set.mem_iInter.mpr quarter_mem_preCantorSet lemma zero_mem_preCantorSet (n : ℕ) : 0 ∈ preCantorSet n := by induction n with | zero => simp [preCantorSet] | succ n ih => exact Or.inl ⟨0, ih, by simp only [zero_div]⟩ theorem zero_mem_cantorSet : 0 ∈ cantorSet := by simp [cantorSet, zero_mem_preCantorSet] theorem preCantorSet_antitone : Antitone preCantorSet := by apply antitone_nat_of_succ_le intro m simp only [Set.le_eq_subset, preCantorSet_succ, Set.union_subset_iff] induction m with | zero => simp only [preCantorSet_zero] constructor <;> intro x <;> simp only [Set.mem_image, Set.mem_Icc, forall_exists_index, and_imp] <;> intro y _ _ _ <;> constructor <;> linarith | succ m ih => grind [preCantorSet_succ, Set.image_union] lemma preCantorSet_subset_unitInterval {n : ℕ} : preCantorSet n ⊆ Set.Icc 0 1 := by rw [← preCantorSet_zero] exact preCantorSet_antitone (by simp) /-- The ternary Cantor set is a subset of [0,1]. -/ lemma cantorSet_subset_unitInterval : cantorSet ⊆ Set.Icc 0 1 := Set.iInter_subset _ 0 /-- The ternary Cantor set satisfies the equation `C = C / 3 ∪ (2 / 3 + C / 3)`. -/ theorem cantorSet_eq_union_halves : cantorSet = (· / 3) '' cantorSet ∪ (fun x ↦ (2 + x) / 3) '' cantorSet := by simp only [cantorSet] rw [Set.image_iInter, Set.image_iInter] rotate_left · exact (mulRight_bijective₀ 3⁻¹ (by simp)).comp (AddGroup.addLeft_bijective 2) · exact mulRight_bijective₀ 3⁻¹ (by simp) simp_rw [← Function.comp_def, ← Set.iInter_union_of_antitone (Set.monotone_image.comp_antitone preCantorSet_antitone) (Set.monotone_image.comp_antitone preCantorSet_antitone), Function.comp_def, ← preCantorSet_succ] exact (preCantorSet_antitone.iInter_nat_add _).symm /-- The preCantor sets are closed. -/ lemma isClosed_preCantorSet (n : ℕ) : IsClosed (preCantorSet n) := by let f := Homeomorph.mulLeft₀ (1 / 3 : ℝ) (by simp) let g := (Homeomorph.addLeft (2 : ℝ)).trans f induction n with | zero => exact isClosed_Icc | succ n ih => refine IsClosed.union ?_ ?_ · simpa [f, div_eq_inv_mul] using f.isClosedEmbedding.isClosed_iff_image_isClosed.mp ih · simpa [g, f, div_eq_inv_mul] using g.isClosedEmbedding.isClosed_iff_image_isClosed.mp ih /-- The ternary Cantor set is closed. -/ lemma isClosed_cantorSet : IsClosed cantorSet := isClosed_iInter isClosed_preCantorSet /-- The ternary Cantor set is compact. -/ lemma isCompact_cantorSet : IsCompact cantorSet := isCompact_Icc.of_isClosed_subset isClosed_cantorSet cantorSet_subset_unitInterval /-! ## The Cantor set as the set of 0–2 numbers in the ternary system. -/ section ternary02 open Real /-- If `x = 0.d₀d₁...` in base-3 (ternary), and none of the digits `dᵢ` is `1`, then `x` belongs to the Cantor set. -/ theorem ofDigits_zero_two_sequence_mem_cantorSet {a : ℕ → Fin 3} (h : ∀ n, a n ≠ 1) : ofDigits a ∈ cantorSet := by simp only [cantorSet, Set.mem_iInter] intro i induction i generalizing a with | zero => simp only [preCantorSet_zero, Set.mem_Icc] exact ⟨ofDigits_nonneg a, ofDigits_le_one a⟩ | succ i ih => simp only [preCantorSet, Set.mem_union, Set.mem_image, ← exists_or] use ofDigits (fun i ↦ a (i + 1)) have : (ofDigits fun i ↦ a (i + 1)) ∈ preCantorSet i := ih (by solve_by_elim) simp only [this, ofDigits_eq_sum_add_ofDigits a 1, Finset.range_one, ofDigitsTerm, Nat.cast_ofNat, Finset.sum_singleton, zero_add, pow_one, true_and, field] specialize h 0 generalize a 0 = x at h fin_cases x <;> simp at ⊢ h /-- If two base-3 representations using only digits `0` and `2` define the same number, then the sequences must be equal. This uniqueness fails for general base-3 representations (e.g. `0.1000... = 0.0222...`). -/ theorem ofDigits_zero_two_sequence_unique {a b : ℕ → Fin 3} (ha : ∀ n, a n ≠ 1) (hb : ∀ n, b n ≠ 1) (h : ofDigits a = ofDigits b) : a = b := by by_contra! h rw [Function.ne_iff] at h let n0 := Nat.find h have h1 (n) (hn : n < n0) : a n = b n := by simpa using Nat.find_min h hn have h2 : a n0 ≠ b n0 := by simpa using Nat.find_spec h generalize n0 = n1 at h1 h2 clear h n0 wlog h3 : a n1 = 0 ∧ b n1 = 2 generalizing a b · exact this hb ha h.symm (fun n hn ↦ (h1 n hn).symm) h2.symm (by grind) obtain ⟨h3, h4⟩ := h3 clear h2 have : ∑ x ∈ Finset.range n1, ofDigitsTerm a x = ∑ x ∈ Finset.range n1, ofDigitsTerm b x := by apply Finset.sum_congr rfl grind [ofDigitsTerm] rw [ofDigits_eq_sum_add_ofDigits a (n1 + 1), ofDigits_eq_sum_add_ofDigits b (n1 + 1), Finset.sum_range_succ, Finset.sum_range_succ, this] at h replace h : ofDigitsTerm a n1 + (3⁻¹ ^ n1 * ofDigits fun i ↦ a (1 + n1 + i)) * (1 / 3) = (3⁻¹ ^ n1 * ofDigits fun i ↦ b (1 + n1 + i)) * (1 / 3) + ofDigitsTerm b n1 := by ring_nf at h linarith simp only [ofDigitsTerm, h3, Fin.isValue, Fin.coe_ofNat_eq_mod, Nat.zero_mod, CharP.cast_eq_zero, Nat.cast_ofNat, pow_succ, mul_inv_rev, zero_mul, inv_pow, one_div, zero_add, h4, Nat.mod_succ] at h replace h : (ofDigits fun i ↦ a (1 + n1 + i)) * 3⁻¹ = (ofDigits fun i ↦ b (1 + n1 + i)) * 3⁻¹ + 2 * 3⁻¹ := by rw [← mul_right_inj' (show ((3 : ℝ) ^ n1)⁻¹ ≠ 0 by positivity)] linarith linarith [ofDigits_nonneg (fun i ↦ b (1 + n1 + i)), ofDigits_le_one (fun i ↦ a (1 + n1 + i))] /-- Given `x ∈ [0, 1/3] ∪ [2/3, 1]` (i.e. a level of the Cantor set), this function rescales the interval containing `x` back to `[0, 1]`. Used to iteratively extract the ternary representation of `x`. -/ noncomputable def cantorStep (x : ℝ) : ℝ := if x ∈ Set.Icc 0 (1/3) then 3 * x else 3 * x - 2 theorem cantorStep_mem_cantorSet {x : ℝ} (hx : x ∈ cantorSet) : cantorStep x ∈ cantorSet := by simp only [cantorStep] obtain ⟨y, hy, rfl | rfl⟩ : ∃ y ∈ cantorSet, y / 3 = x ∨ (2 + y) / 3 = x := by rw [cantorSet_eq_union_halves] at hx grind all_goals have := cantorSet_subset_unitInterval hy simp only [Set.mem_Icc] at this ⊢ field_simp grind /-- The infinite sequence obtained by repeatedly applying `cantorStep` to `x`. -/ noncomputable def cantorSequence (x : ℝ) : Stream' ℝ := Stream'.iterate cantorStep x theorem cantorSequence_mem_cantorSet {x : ℝ} (hx : x ∈ cantorSet) (n : ℕ) : (cantorSequence x).get n ∈ cantorSet := by induction n with | zero => simpa [cantorSequence] | succ n ih => exact cantorStep_mem_cantorSet ih /-- Points of the Cantor set correspond to infinite paths in the full binary tree. at each level `n`, the set `preCantorSet (n + 1)` splits each interval in `preCantorSet n` into two parts. Given `x ∈ cantorSet`, the point `x` lies in one of the intervals of `preCantorSet n`. This function tracks which of the two intervals in `preCantorSet (n + 1)` contains `x` at each step, producing the corresponding path as a stream of booleans. -/ noncomputable def cantorToBinary (x : ℝ) : Stream' Bool := (cantorSequence x).map fun x ↦ if x ∈ Set.Icc 0 (1/3) then false else true /-- Given `x` in the Cantor set, return its ternary representation `(d₀, d₁, …)` using only digits `0` and `2`, such that `x = 0.d₀d₁...` in base-3. -/ noncomputable def cantorToTernary (x : ℝ) : Stream' (Fin 3) := (cantorToBinary x).map (cond · 2 0) theorem ofDigits_bool_to_fin_three_mem_cantorSet (f : ℕ → Bool) : ofDigits (fun i ↦ cond (f i) (2 : Fin 3) 0) ∈ cantorSet := ofDigits_zero_two_sequence_mem_cantorSet (by grind) theorem cantorToTernary_ne_one {x : ℝ} {n : ℕ} : (cantorToTernary x).get n ≠ 1 := by grind [cantorToTernary, Fin.isValue, Stream'.get_map] theorem cantorSequence_get_succ (x : ℝ) (n : ℕ) : (cantorSequence x).get (n + 1) = 3 * ((cantorSequence x).get n - 3^n * ofDigitsTerm (cantorToTernary x).get n) := by simp only [cantorSequence, ofDigitsTerm, cantorToTernary, cantorToBinary, Set.mem_Icc, Bool.if_true_right, Bool.or_false, Stream'.get_map, Bool.cond_not, Bool.cond_decide, Stream'.get_succ_iterate', cantorStep] split_ifs <;> simp field theorem cantorSequence_eq_self_sub_sum_cantorToTernary (x : ℝ) (n : ℕ) : (cantorSequence x).get n = (x - ∑ i ∈ Finset.range n, ofDigitsTerm (cantorToTernary x).get i) * 3^n := by induction n with | zero => simp [cantorSequence] | succ n ih => rw [cantorSequence_get_succ, ih, Finset.sum_range_succ]; ring theorem ofDigits_cantorToTernary_sum_le {x : ℝ} (hx : x ∈ cantorSet) {n : ℕ} : ∑ i ∈ Finset.range n, ofDigitsTerm (cantorToTernary x) i ≤ x := by have h_mem := cantorSequence_mem_cantorSet hx n rw [cantorSequence_eq_self_sub_sum_cantorToTernary x n] at h_mem apply cantorSet_subset_unitInterval at h_mem simp only [Set.mem_Icc] at h_mem simpa using h_mem.left theorem le_ofDigits_cantorToTernary_sum {x : ℝ} (hx : x ∈ cantorSet) {n : ℕ} : x - (3⁻¹ : ℝ)^n ≤ ∑ i ∈ Finset.range n, ofDigitsTerm (cantorToTernary x) i := by have h_mem := cantorSequence_mem_cantorSet hx n rw [cantorSequence_eq_self_sub_sum_cantorToTernary x n] at h_mem apply cantorSet_subset_unitInterval at h_mem simp only [Set.mem_Icc] at h_mem rw [← mul_le_mul_iff_left₀ (show 0 < (3 : ℝ)^n by positivity), sub_mul, inv_pow, inv_mul_cancel₀ (by simp)] linarith! theorem ofDigits_cantorToTernary {x : ℝ} (hx : x ∈ cantorSet) : ofDigits (cantorToTernary x).get = x := by simp only [ofDigits] rw [HasSum.tsum_eq] rw [hasSum_iff_tendsto_nat_of_summable_norm] swap · simpa only [norm_of_nonneg ofDigitsTerm_nonneg] using summable_ofDigitsTerm apply tendsto_of_tendsto_of_tendsto_of_le_of_le (g := fun n ↦ x - (3⁻¹ : ℝ)^n) (h := fun _ ↦ x) · rw [← tendsto_sub_nhds_zero_iff] simp only [sub_sub_cancel_left] rw [show 0 = -(0 : ℝ) by simp] exact (tendsto_pow_atTop_nhds_zero_of_abs_lt_one (by norm_num)).neg · exact tendsto_const_nhds · exact fun _ ↦ le_ofDigits_cantorToTernary_sum hx · exact fun _ ↦ ofDigits_cantorToTernary_sum_le hx theorem cantorSet_eq_zero_two_ofDigits : cantorSet = {x | ∃ a : ℕ → Fin 3, (∀ i, a i ≠ 1) ∧ ofDigits a = x} := by ext x refine ⟨fun h ↦ ?_, fun ⟨a, ha⟩ ↦ ?_⟩ · use cantorToTernary x exact ⟨fun _ ↦ cantorToTernary_ne_one, ofDigits_cantorToTernary h⟩ · rw [← ha.right] exact ofDigits_zero_two_sequence_mem_cantorSet ha.left end ternary02 /-! ## The Cantor set is homeomorphic to `ℕ → Bool` -/ open Real /-- Canonical bijection between the Cantor set and infinite binary tree. -/ noncomputable def cantorSetEquivNatToBool : cantorSet ≃ (ℕ → Bool) where toFun := fun ⟨x, h⟩ ↦ (cantorToBinary x).get invFun (y : ℕ → Bool) := ⟨ofDigits (fun i ↦ cond (y i) 2 0), ofDigits_bool_to_fin_three_mem_cantorSet y⟩ left_inv := by intro ⟨x, hx⟩ simp only [Fin.isValue, Subtype.mk.injEq] exact ofDigits_cantorToTernary hx right_inv := by intro y simp only [Fin.isValue] set x := @ofDigits 3 (fun i ↦ cond (y i) 2 0) have := ofDigits_cantorToTernary (ofDigits_bool_to_fin_three_mem_cantorSet y) apply ofDigits_zero_two_sequence_unique at this rotate_left · exact fun n ↦ cantorToTernary_ne_one · grind ext n apply congrFun (a := n) at this grind [cantorToTernary, Stream'.get_map] /-- Canonical homeomorphism between the Cantor set and `ℕ → Bool`. -/ noncomputable def cantorSetHomeomorphNatToBool : cantorSet ≃ₜ (ℕ → Bool) := Homeomorph.symm <| Continuous.homeoOfEquivCompactToT2 (f := cantorSetEquivNatToBool.symm) (Continuous.subtype_mk (Continuous.comp continuous_ofDigits (by fun_prop)) _) /-- The Cantor space is homeomorphic to a countable product of copies of itself. -/ def cantorSpaceHomeomorphNatToCantorSpace : (ℕ → Bool) ≃ₜ (ℕ → ℕ → Bool) := (Homeomorph.piCongrLeft Nat.pairEquiv.symm).trans Homeomorph.piCurry
.lake/packages/mathlib/Mathlib/Topology/Instances/Int.lean
import Mathlib.Data.Int.Interval import Mathlib.Data.Int.ConditionallyCompleteOrder import Mathlib.Topology.Instances.Discrete import Mathlib.Topology.MetricSpace.Bounded import Mathlib.Order.Filter.AtTopBot.Archimedean import Mathlib.Topology.MetricSpace.Basic import Mathlib.Topology.Order.Bornology /-! # Topology on the integers The structure of a metric space on `ℤ` is introduced in this file, induced from `ℝ`. -/ noncomputable section open Filter Metric Set Topology namespace Int instance : Dist ℤ := ⟨fun x y => dist (x : ℝ) y⟩ theorem dist_eq (x y : ℤ) : dist x y = |(x : ℝ) - y| := rfl theorem dist_eq' (m n : ℤ) : dist m n = |m - n| := by rw [dist_eq]; norm_cast @[norm_cast, simp] theorem dist_cast_real (x y : ℤ) : dist (x : ℝ) y = dist x y := rfl theorem pairwise_one_le_dist : Pairwise fun m n : ℤ => 1 ≤ dist m n := by intro m n hne rw [dist_eq]; norm_cast; rwa [← zero_add (1 : ℤ), Int.add_one_le_iff, abs_pos, sub_ne_zero] theorem isUniformEmbedding_coe_real : IsUniformEmbedding ((↑) : ℤ → ℝ) := isUniformEmbedding_bot_of_pairwise_le_dist zero_lt_one pairwise_one_le_dist theorem isClosedEmbedding_coe_real : IsClosedEmbedding ((↑) : ℤ → ℝ) := isClosedEmbedding_of_pairwise_le_dist zero_lt_one pairwise_one_le_dist instance : MetricSpace ℤ := Int.isUniformEmbedding_coe_real.comapMetricSpace _ theorem preimage_ball (x : ℤ) (r : ℝ) : (↑) ⁻¹' ball (x : ℝ) r = ball x r := rfl theorem preimage_closedBall (x : ℤ) (r : ℝ) : (↑) ⁻¹' closedBall (x : ℝ) r = closedBall x r := rfl theorem ball_eq_Ioo (x : ℤ) (r : ℝ) : ball x r = Ioo ⌊↑x - r⌋ ⌈↑x + r⌉ := by rw [← preimage_ball, Real.ball_eq_Ioo, preimage_Ioo] theorem closedBall_eq_Icc (x : ℤ) (r : ℝ) : closedBall x r = Icc ⌈↑x - r⌉ ⌊↑x + r⌋ := by rw [← preimage_closedBall, Real.closedBall_eq_Icc, preimage_Icc] instance : ProperSpace ℤ := ⟨fun x r => by rw [closedBall_eq_Icc] exact (Set.finite_Icc _ _).isCompact⟩ instance : IsOrderBornology ℤ := .of_isCompactIcc 0 (by simp [Int.closedBall_eq_Icc]) (by simp [Int.closedBall_eq_Icc]) @[simp] theorem cobounded_eq : Bornology.cobounded ℤ = atBot ⊔ atTop := by simp_rw [← comap_dist_right_atTop (0 : ℤ), dist_eq', sub_zero, ← comap_abs_atTop, ← @Int.comap_cast_atTop ℝ, comap_comap]; rfl @[simp] theorem cofinite_eq : (cofinite : Filter ℤ) = atBot ⊔ atTop := by rw [← cocompact_eq_cofinite, cocompact_eq_atBot_atTop] end Int
.lake/packages/mathlib/Mathlib/Topology/Instances/Sign.lean
import Mathlib.Data.Sign.Defs import Mathlib.Topology.Order.Basic /-! # Topology on `SignType` This file gives `SignType` the discrete topology, and proves continuity results for `SignType.sign` in an `OrderTopology`. -/ instance : TopologicalSpace SignType := ⊥ instance : DiscreteTopology SignType := ⟨rfl⟩ variable {α : Type*} [Zero α] [TopologicalSpace α] section PartialOrder variable [PartialOrder α] [DecidableLT α] [OrderTopology α] theorem continuousAt_sign_of_pos {a : α} (h : 0 < a) : ContinuousAt SignType.sign a := by refine (continuousAt_const : ContinuousAt (fun _ => (1 : SignType)) a).congr ?_ rw [Filter.EventuallyEq, eventually_nhds_iff] exact ⟨{ x | 0 < x }, fun x hx => (sign_pos hx).symm, isOpen_lt' 0, h⟩ theorem continuousAt_sign_of_neg {a : α} (h : a < 0) : ContinuousAt SignType.sign a := by refine (continuousAt_const : ContinuousAt (fun x => (-1 : SignType)) a).congr ?_ rw [Filter.EventuallyEq, eventually_nhds_iff] exact ⟨{ x | x < 0 }, fun x hx => (sign_neg hx).symm, isOpen_gt' 0, h⟩ end PartialOrder section LinearOrder variable [LinearOrder α] [OrderTopology α] theorem continuousAt_sign_of_ne_zero {a : α} (h : a ≠ 0) : ContinuousAt SignType.sign a := by rcases h.lt_or_gt with (h_neg | h_pos) · exact continuousAt_sign_of_neg h_neg · exact continuousAt_sign_of_pos h_pos end LinearOrder
.lake/packages/mathlib/Mathlib/Topology/Instances/Matrix.lean
import Mathlib.Topology.Algebra.InfiniteSum.Basic import Mathlib.Topology.Algebra.Group.Pointwise import Mathlib.Topology.Algebra.Ring.Basic import Mathlib.Topology.Algebra.Star import Mathlib.LinearAlgebra.Matrix.NonsingularInverse import Mathlib.LinearAlgebra.Matrix.GeneralLinearGroup.FinTwo import Mathlib.LinearAlgebra.Matrix.Trace /-! # Topological properties of matrices This file is a place to collect topological results about matrices. ## Main definitions: * `Matrix.topologicalRing`: square matrices form a topological ring ## Main results * Sets of matrices: * `IsOpen.matrix`: the set of finite matrices with entries in an open set is itself an open set. * `IsCompact.matrix`: the set of matrices with entries in a compact set is itself a compact set. * Continuity: * `Continuous.matrix_det`: the determinant is continuous over a topological ring. * `Continuous.matrix_adjugate`: the adjugate is continuous over a topological ring. * Infinite sums * `Matrix.transpose_tsum`: transpose commutes with infinite sums * `Matrix.diagonal_tsum`: diagonal commutes with infinite sums * `Matrix.blockDiagonal_tsum`: block diagonal commutes with infinite sums * `Matrix.blockDiagonal'_tsum`: non-uniform block diagonal commutes with infinite sums -/ open Matrix variable {X α l m n p S R : Type*} {m' n' : l → Type*} instance [TopologicalSpace R] : TopologicalSpace (Matrix m n R) := Pi.topologicalSpace instance [TopologicalSpace R] [T2Space R] : T2Space (Matrix m n R) := Pi.t2Space /-- The topology on finite matrices over a discrete space is discrete. -/ instance [TopologicalSpace R] [Finite m] [Finite n] [DiscreteTopology R] : DiscreteTopology (Matrix m n R) := Pi.discreteTopology section Set theorem IsOpen.matrix [Finite m] [Finite n] [TopologicalSpace R] {S : Set R} (hS : IsOpen S) : IsOpen (S.matrix : Set (Matrix m n R)) := Set.matrix_eq_pi ▸ (isOpen_set_pi Set.finite_univ fun _ _ => isOpen_set_pi Set.finite_univ fun _ _ => hS).preimage continuous_id theorem IsCompact.matrix [TopologicalSpace R] {S : Set R} (hS : IsCompact S) : IsCompact (S.matrix : Set (Matrix m n R)) := isCompact_pi_infinite fun _ => isCompact_pi_infinite fun _ => hS end Set /-! ### Lemmas about continuity of operations -/ section Continuity variable [TopologicalSpace X] [TopologicalSpace R] instance [SMul α R] [ContinuousConstSMul α R] : ContinuousConstSMul α (Matrix m n R) := inferInstanceAs (ContinuousConstSMul α (m → n → R)) instance [TopologicalSpace α] [SMul α R] [ContinuousSMul α R] : ContinuousSMul α (Matrix m n R) := inferInstanceAs (ContinuousSMul α (m → n → R)) instance [Add R] [ContinuousAdd R] : ContinuousAdd (Matrix m n R) := Pi.continuousAdd instance [Neg R] [ContinuousNeg R] : ContinuousNeg (Matrix m n R) := Pi.continuousNeg instance [AddGroup R] [IsTopologicalAddGroup R] : IsTopologicalAddGroup (Matrix m n R) := Pi.topologicalAddGroup /-- To show a function into matrices is continuous it suffices to show the coefficients of the resulting matrix are continuous -/ @[continuity] theorem continuous_matrix [TopologicalSpace α] {f : α → Matrix m n R} (h : ∀ i j, Continuous fun a => f a i j) : Continuous f := continuous_pi fun _ => continuous_pi fun _ => h _ _ theorem Continuous.matrix_elem {A : X → Matrix m n R} (hA : Continuous A) (i : m) (j : n) : Continuous fun x => A x i j := (continuous_apply_apply i j).comp hA @[continuity, fun_prop] theorem Continuous.matrix_map [TopologicalSpace S] {A : X → Matrix m n S} {f : S → R} (hA : Continuous A) (hf : Continuous f) : Continuous fun x => (A x).map f := continuous_matrix fun _ _ => hf.comp <| hA.matrix_elem _ _ @[continuity, fun_prop] theorem Continuous.matrix_transpose {A : X → Matrix m n R} (hA : Continuous A) : Continuous fun x => (A x)ᵀ := continuous_matrix fun i j => hA.matrix_elem j i @[continuity, fun_prop] theorem Continuous.matrix_conjTranspose [Star R] [ContinuousStar R] {A : X → Matrix m n R} (hA : Continuous A) : Continuous fun x => (A x)ᴴ := hA.matrix_transpose.matrix_map continuous_star instance [Star R] [ContinuousStar R] : ContinuousStar (Matrix m m R) := ⟨continuous_id.matrix_conjTranspose⟩ @[continuity, fun_prop] theorem Continuous.matrix_replicateCol {ι : Type*} {A : X → n → R} (hA : Continuous A) : Continuous fun x => replicateCol ι (A x) := continuous_matrix fun i _ => (continuous_apply i).comp hA @[continuity, fun_prop] theorem Continuous.matrix_replicateRow {ι : Type*} {A : X → n → R} (hA : Continuous A) : Continuous fun x => replicateRow ι (A x) := continuous_matrix fun _ _ => (continuous_apply _).comp hA @[continuity, fun_prop] theorem Continuous.matrix_diagonal [Zero R] [DecidableEq n] {A : X → n → R} (hA : Continuous A) : Continuous fun x => diagonal (A x) := continuous_matrix fun i _ => ((continuous_apply i).comp hA).if_const _ continuous_zero @[continuity, fun_prop] protected theorem Continuous.dotProduct [Fintype n] [Mul R] [AddCommMonoid R] [ContinuousAdd R] [ContinuousMul R] {A : X → n → R} {B : X → n → R} (hA : Continuous A) (hB : Continuous B) : Continuous fun x => A x ⬝ᵥ B x := by dsimp only [dotProduct] fun_prop @[deprecated (since := "2025-05-09")] alias Continuous.matrix_dotProduct := Continuous.dotProduct /-- For square matrices the usual `continuous_mul` can be used. -/ @[continuity, fun_prop] theorem Continuous.matrix_mul [Fintype n] [Mul R] [AddCommMonoid R] [ContinuousAdd R] [ContinuousMul R] {A : X → Matrix m n R} {B : X → Matrix n p R} (hA : Continuous A) (hB : Continuous B) : Continuous fun x => A x * B x := continuous_matrix fun _ _ => continuous_finset_sum _ fun _ _ => (hA.matrix_elem _ _).mul (hB.matrix_elem _ _) instance [Fintype n] [Mul R] [AddCommMonoid R] [ContinuousAdd R] [ContinuousMul R] : ContinuousMul (Matrix n n R) := ⟨continuous_fst.matrix_mul continuous_snd⟩ instance [Fintype n] [NonUnitalNonAssocSemiring R] [IsTopologicalSemiring R] : IsTopologicalSemiring (Matrix n n R) where instance Matrix.topologicalRing [Fintype n] [NonUnitalNonAssocRing R] [IsTopologicalRing R] : IsTopologicalRing (Matrix n n R) where @[continuity, fun_prop] theorem Continuous.matrix_vecMulVec [Mul R] [ContinuousMul R] {A : X → m → R} {B : X → n → R} (hA : Continuous A) (hB : Continuous B) : Continuous fun x => vecMulVec (A x) (B x) := continuous_matrix fun _ _ => ((continuous_apply _).comp hA).mul ((continuous_apply _).comp hB) @[continuity, fun_prop] theorem Continuous.matrix_mulVec [NonUnitalNonAssocSemiring R] [ContinuousAdd R] [ContinuousMul R] [Fintype n] {A : X → Matrix m n R} {B : X → n → R} (hA : Continuous A) (hB : Continuous B) : Continuous fun x => A x *ᵥ B x := continuous_pi fun i => ((continuous_apply i).comp hA).dotProduct hB @[continuity, fun_prop] theorem Continuous.matrix_vecMul [NonUnitalNonAssocSemiring R] [ContinuousAdd R] [ContinuousMul R] [Fintype m] {A : X → m → R} {B : X → Matrix m n R} (hA : Continuous A) (hB : Continuous B) : Continuous fun x => A x ᵥ* B x := continuous_pi fun _i => hA.dotProduct <| continuous_pi fun _j => hB.matrix_elem _ _ @[continuity, fun_prop] theorem Continuous.matrix_submatrix {A : X → Matrix l n R} (hA : Continuous A) (e₁ : m → l) (e₂ : p → n) : Continuous fun x => (A x).submatrix e₁ e₂ := continuous_matrix fun _i _j => hA.matrix_elem _ _ @[continuity, fun_prop] theorem Continuous.matrix_reindex {A : X → Matrix l n R} (hA : Continuous A) (e₁ : l ≃ m) (e₂ : n ≃ p) : Continuous fun x => reindex e₁ e₂ (A x) := hA.matrix_submatrix _ _ @[continuity, fun_prop] theorem Continuous.matrix_diag {A : X → Matrix n n R} (hA : Continuous A) : Continuous fun x => Matrix.diag (A x) := continuous_pi fun _ => hA.matrix_elem _ _ -- note this doesn't elaborate well from the above theorem continuous_matrix_diag : Continuous (Matrix.diag : Matrix n n R → n → R) := show Continuous fun x : Matrix n n R => Matrix.diag x from continuous_id.matrix_diag @[continuity, fun_prop] theorem Continuous.matrix_trace [Fintype n] [AddCommMonoid R] [ContinuousAdd R] {A : X → Matrix n n R} (hA : Continuous A) : Continuous fun x => trace (A x) := continuous_finset_sum _ fun _ _ => hA.matrix_elem _ _ @[continuity, fun_prop] theorem Continuous.matrix_det [Fintype n] [DecidableEq n] [CommRing R] [IsTopologicalRing R] {A : X → Matrix n n R} (hA : Continuous A) : Continuous fun x => (A x).det := by simp_rw [Matrix.det_apply] refine continuous_finset_sum _ fun l _ => Continuous.const_smul ?_ _ exact continuous_finset_prod _ fun l _ => hA.matrix_elem _ _ @[continuity, fun_prop] theorem Continuous.matrix_updateCol [DecidableEq n] (i : n) {A : X → Matrix m n R} {B : X → m → R} (hA : Continuous A) (hB : Continuous B) : Continuous fun x => (A x).updateCol i (B x) := continuous_matrix fun _j k => (continuous_apply k).comp <| ((continuous_apply _).comp hA).update i ((continuous_apply _).comp hB) @[continuity, fun_prop] theorem Continuous.matrix_updateRow [DecidableEq m] (i : m) {A : X → Matrix m n R} {B : X → n → R} (hA : Continuous A) (hB : Continuous B) : Continuous fun x => (A x).updateRow i (B x) := hA.update i hB @[continuity, fun_prop] theorem Continuous.matrix_cramer [Fintype n] [DecidableEq n] [CommRing R] [IsTopologicalRing R] {A : X → Matrix n n R} {B : X → n → R} (hA : Continuous A) (hB : Continuous B) : Continuous fun x => cramer (A x) (B x) := continuous_pi fun _ => (hA.matrix_updateCol _ hB).matrix_det @[continuity, fun_prop] theorem Continuous.matrix_adjugate [Fintype n] [DecidableEq n] [CommRing R] [IsTopologicalRing R] {A : X → Matrix n n R} (hA : Continuous A) : Continuous fun x => (A x).adjugate := continuous_matrix fun _j k => (hA.matrix_transpose.matrix_updateCol k continuous_const).matrix_det /-- When `Ring.inverse` is continuous at the determinant (such as in a `NormedRing`, or a topological field), so is `Matrix.inv`. -/ theorem continuousAt_matrix_inv [Fintype n] [DecidableEq n] [CommRing R] [IsTopologicalRing R] (A : Matrix n n R) (h : ContinuousAt Ring.inverse A.det) : ContinuousAt Inv.inv A := (h.comp continuous_id.matrix_det.continuousAt).smul continuous_id.matrix_adjugate.continuousAt namespace Topology variable {m n R S : Type*} [TopologicalSpace R] [TopologicalSpace S] {f : R → S} lemma IsInducing.matrix_map (hf : IsInducing f) : IsInducing (map · f : Matrix m n R → Matrix m n S) := IsInducing.piMap fun _ : m ↦ (IsInducing.piMap fun _ : n ↦ hf) lemma IsEmbedding.matrix_map (hf : IsEmbedding f) : IsEmbedding (map · f : Matrix m n R → Matrix m n S) := IsEmbedding.piMap fun _ : m ↦ (IsEmbedding.piMap fun _ : n ↦ hf) lemma IsClosedEmbedding.matrix_map (hf : IsClosedEmbedding f) : IsClosedEmbedding (map · f : Matrix m n R → Matrix m n S) := IsClosedEmbedding.piMap fun _ : m ↦ (IsClosedEmbedding.piMap fun _ : n ↦ hf) lemma IsOpenEmbedding.matrix_map [Finite m] [Finite n] (hf : IsOpenEmbedding f) : IsOpenEmbedding (map · f : Matrix m n R → Matrix m n S) := IsOpenEmbedding.piMap fun _ : m ↦ (IsOpenEmbedding.piMap fun _ : n ↦ hf) end Topology -- lemmas about functions in `Data/Matrix/Block.lean` section BlockMatrices @[continuity, fun_prop] theorem Continuous.matrix_fromBlocks {A : X → Matrix n l R} {B : X → Matrix n m R} {C : X → Matrix p l R} {D : X → Matrix p m R} (hA : Continuous A) (hB : Continuous B) (hC : Continuous C) (hD : Continuous D) : Continuous fun x => Matrix.fromBlocks (A x) (B x) (C x) (D x) := continuous_matrix <| by rintro (i | i) (j | j) <;> refine Continuous.matrix_elem ?_ i j <;> assumption @[continuity, fun_prop] theorem Continuous.matrix_blockDiagonal [Zero R] [DecidableEq p] {A : X → p → Matrix m n R} (hA : Continuous A) : Continuous fun x => blockDiagonal (A x) := continuous_matrix fun ⟨i₁, i₂⟩ ⟨j₁, _j₂⟩ => (((continuous_apply i₂).comp hA).matrix_elem i₁ j₁).if_const _ continuous_zero @[continuity, fun_prop] theorem Continuous.matrix_blockDiag {A : X → Matrix (m × p) (n × p) R} (hA : Continuous A) : Continuous fun x => blockDiag (A x) := continuous_pi fun _i => continuous_matrix fun _j _k => hA.matrix_elem _ _ @[continuity, fun_prop] theorem Continuous.matrix_blockDiagonal' [Zero R] [DecidableEq l] {A : X → ∀ i, Matrix (m' i) (n' i) R} (hA : Continuous A) : Continuous fun x => blockDiagonal' (A x) := continuous_matrix fun ⟨i₁, i₂⟩ ⟨j₁, j₂⟩ => by dsimp only [blockDiagonal'_apply'] split_ifs with h · subst h exact ((continuous_apply i₁).comp hA).matrix_elem i₂ j₂ · exact continuous_const @[continuity, fun_prop] theorem Continuous.matrix_blockDiag' {A : X → Matrix (Σ i, m' i) (Σ i, n' i) R} (hA : Continuous A) : Continuous fun x => blockDiag' (A x) := continuous_pi fun _i => continuous_matrix fun _j _k => hA.matrix_elem _ _ end BlockMatrices end Continuity /-! ### Lemmas about infinite sums -/ section tsum variable [AddCommMonoid R] [TopologicalSpace R] {L : SummationFilter X} theorem HasSum.matrix_transpose {f : X → Matrix m n R} {a : Matrix m n R} (hf : HasSum f a L) : HasSum (fun x => (f x)ᵀ) aᵀ L := (hf.map (Matrix.transposeAddEquiv m n R) continuous_id.matrix_transpose :) theorem Summable.matrix_transpose {f : X → Matrix m n R} (hf : Summable f L) : Summable (fun x => (f x)ᵀ) L := hf.hasSum.matrix_transpose.summable @[simp] theorem summable_matrix_transpose {f : X → Matrix m n R} : (Summable (fun x => (f x)ᵀ) L) ↔ Summable f L := Summable.map_iff_of_equiv (Matrix.transposeAddEquiv m n R) continuous_id.matrix_transpose continuous_id.matrix_transpose theorem Matrix.transpose_tsum [T2Space R] {f : X → Matrix m n R} : (∑'[L] x, f x)ᵀ = ∑'[L] x, (f x)ᵀ := Function.LeftInverse.map_tsum f (g := transposeAddEquiv m n R) continuous_id.matrix_transpose continuous_id.matrix_transpose transpose_transpose theorem HasSum.matrix_conjTranspose [StarAddMonoid R] [ContinuousStar R] {f : X → Matrix m n R} {a : Matrix m n R} (hf : HasSum f a L) : HasSum (fun x => (f x)ᴴ) aᴴ L := (hf.map (Matrix.conjTransposeAddEquiv m n R) continuous_id.matrix_conjTranspose :) theorem Summable.matrix_conjTranspose [StarAddMonoid R] [ContinuousStar R] {f : X → Matrix m n R} (hf : Summable f L) : Summable (fun x => (f x)ᴴ) L := hf.hasSum.matrix_conjTranspose.summable @[simp] theorem summable_matrix_conjTranspose [StarAddMonoid R] [ContinuousStar R] {f : X → Matrix m n R} : (Summable (fun x => (f x)ᴴ) L) ↔ Summable f L := Summable.map_iff_of_equiv (Matrix.conjTransposeAddEquiv m n R) continuous_id.matrix_conjTranspose continuous_id.matrix_conjTranspose theorem Matrix.conjTranspose_tsum [StarAddMonoid R] [ContinuousStar R] [T2Space R] {f : X → Matrix m n R} : (∑'[L] x, f x)ᴴ = ∑'[L] x, (f x)ᴴ := Function.LeftInverse.map_tsum f (g := conjTransposeAddEquiv m n R) continuous_id.matrix_conjTranspose continuous_id.matrix_conjTranspose conjTranspose_conjTranspose theorem HasSum.matrix_diagonal [DecidableEq n] {f : X → n → R} {a : n → R} (hf : HasSum f a L) : HasSum (fun x => diagonal (f x)) (diagonal a) L := hf.map (diagonalAddMonoidHom n R) continuous_id.matrix_diagonal theorem Summable.matrix_diagonal [DecidableEq n] {f : X → n → R} (hf : Summable f L) : Summable (fun x => diagonal (f x)) L := hf.hasSum.matrix_diagonal.summable @[simp] theorem summable_matrix_diagonal [DecidableEq n] {f : X → n → R} : (Summable (fun x => diagonal (f x)) L) ↔ Summable f L := Summable.map_iff_of_leftInverse (Matrix.diagonalAddMonoidHom n R) (Matrix.diagAddMonoidHom n R) continuous_id.matrix_diagonal continuous_matrix_diag fun A => diag_diagonal A theorem Matrix.diagonal_tsum [DecidableEq n] [T2Space R] {f : X → n → R} : diagonal (∑'[L] x, f x) = ∑'[L] x, diagonal (f x) := Function.LeftInverse.map_tsum f (g := diagonalAddMonoidHom n R) continuous_id.matrix_diagonal continuous_matrix_diag diag_diagonal theorem HasSum.matrix_diag {f : X → Matrix n n R} {a : Matrix n n R} (hf : HasSum f a L) : HasSum (fun x => diag (f x)) (diag a) L := hf.map (diagAddMonoidHom n R) continuous_matrix_diag theorem Summable.matrix_diag {f : X → Matrix n n R} (hf : Summable f L) : Summable (fun x => diag (f x)) L := hf.hasSum.matrix_diag.summable section BlockMatrices theorem HasSum.matrix_blockDiagonal [DecidableEq p] {f : X → p → Matrix m n R} {a : p → Matrix m n R} (hf : HasSum f a L) : HasSum (fun x => blockDiagonal (f x)) (blockDiagonal a) L := hf.map (blockDiagonalAddMonoidHom m n p R) continuous_id.matrix_blockDiagonal theorem Summable.matrix_blockDiagonal [DecidableEq p] {f : X → p → Matrix m n R} (hf : Summable f L) : Summable (fun x => blockDiagonal (f x)) L := hf.hasSum.matrix_blockDiagonal.summable theorem summable_matrix_blockDiagonal [DecidableEq p] {f : X → p → Matrix m n R} : (Summable (fun x => blockDiagonal (f x)) L) ↔ Summable f L := Summable.map_iff_of_leftInverse (blockDiagonalAddMonoidHom m n p R) (blockDiagAddMonoidHom m n p R) continuous_id.matrix_blockDiagonal continuous_id.matrix_blockDiag fun A => blockDiag_blockDiagonal A theorem Matrix.blockDiagonal_tsum [DecidableEq p] [T2Space R] {f : X → p → Matrix m n R} : blockDiagonal (∑'[L] x, f x) = ∑'[L] x, blockDiagonal (f x) := Function.LeftInverse.map_tsum (g := blockDiagonalAddMonoidHom m n p R) f continuous_id.matrix_blockDiagonal continuous_id.matrix_blockDiag blockDiag_blockDiagonal theorem HasSum.matrix_blockDiag {f : X → Matrix (m × p) (n × p) R} {a : Matrix (m × p) (n × p) R} (hf : HasSum f a L) : HasSum (fun x => blockDiag (f x)) (blockDiag a) L := (hf.map (blockDiagAddMonoidHom m n p R) <| Continuous.matrix_blockDiag continuous_id :) theorem Summable.matrix_blockDiag {f : X → Matrix (m × p) (n × p) R} (hf : Summable f L) : Summable (fun x => blockDiag (f x)) L := hf.hasSum.matrix_blockDiag.summable theorem HasSum.matrix_blockDiagonal' [DecidableEq l] {f : X → ∀ i, Matrix (m' i) (n' i) R} {a : ∀ i, Matrix (m' i) (n' i) R} (hf : HasSum f a L) : HasSum (fun x => blockDiagonal' (f x)) (blockDiagonal' a) L := hf.map (blockDiagonal'AddMonoidHom m' n' R) continuous_id.matrix_blockDiagonal' theorem Summable.matrix_blockDiagonal' [DecidableEq l] {f : X → ∀ i, Matrix (m' i) (n' i) R} (hf : Summable f L) : Summable (fun x => blockDiagonal' (f x)) L := hf.hasSum.matrix_blockDiagonal'.summable theorem summable_matrix_blockDiagonal' [DecidableEq l] {f : X → ∀ i, Matrix (m' i) (n' i) R} : (Summable (fun x => blockDiagonal' (f x)) L) ↔ Summable f L := Summable.map_iff_of_leftInverse (blockDiagonal'AddMonoidHom m' n' R) (blockDiag'AddMonoidHom m' n' R) continuous_id.matrix_blockDiagonal' continuous_id.matrix_blockDiag' fun A => blockDiag'_blockDiagonal' A theorem Matrix.blockDiagonal'_tsum [DecidableEq l] [T2Space R] {f : X → ∀ i, Matrix (m' i) (n' i) R} : blockDiagonal' (∑'[L] x, f x) = ∑'[L] x, blockDiagonal' (f x) := Function.LeftInverse.map_tsum (g := blockDiagonal'AddMonoidHom m' n' R) f continuous_id.matrix_blockDiagonal' continuous_id.matrix_blockDiag' blockDiag'_blockDiagonal' theorem HasSum.matrix_blockDiag' {f : X → Matrix (Σ i, m' i) (Σ i, n' i) R} {a : Matrix (Σ i, m' i) (Σ i, n' i) R} (hf : HasSum f a L) : HasSum (fun x => blockDiag' (f x)) (blockDiag' a) L := hf.map (blockDiag'AddMonoidHom m' n' R) continuous_id.matrix_blockDiag' theorem Summable.matrix_blockDiag' {f : X → Matrix (Σ i, m' i) (Σ i, n' i) R} (hf : Summable f L) : Summable (fun x => blockDiag' (f x)) L := hf.hasSum.matrix_blockDiag'.summable end BlockMatrices end tsum /-! ### Lemmas about matrix groups -/ section MatrixGroups variable [Fintype n] [DecidableEq n] [CommRing R] [TopologicalSpace R] [IsTopologicalRing R] namespace Matrix.GeneralLinearGroup /-- The determinant is continuous as a map from the general linear group to the units. -/ @[continuity, fun_prop] protected lemma continuous_det : Continuous (det : GL n R → Rˣ) := by simp_rw [Units.continuous_iff, ← map_inv] constructor <;> fun_prop @[continuity, fun_prop] lemma continuous_upperRightHom {R : Type*} [Ring R] [TopologicalSpace R] [IsTopologicalRing R] : Continuous (upperRightHom (R := R)) := by simp only [continuous_induced_rng, Function.comp_def, upperRightHom_apply, Units.embedProduct_apply, Units.inv_mk, continuous_prodMk, MulOpposite.unop_op] constructor <;> · refine continuous_matrix fun i j ↦ ?_ fin_cases i <;> fin_cases j <;> simp [continuous_const, continuous_neg, continuous_id'] end Matrix.GeneralLinearGroup namespace Matrix.SpecialLinearGroup local notation "SL" => SpecialLinearGroup omit [IsTopologicalRing R] in instance : TopologicalSpace (SpecialLinearGroup n R) := instTopologicalSpaceSubtype /-- If `R` is a commutative ring with the discrete topology, then `SL(n, R)` has the discrete topology. -/ instance [DiscreteTopology R] : DiscreteTopology (SL n R) := instDiscreteTopologySubtype /-- The special linear group over a topological ring is a topological group. -/ instance topologicalGroup : IsTopologicalGroup (SL n R) where continuous_inv := by simpa [continuous_induced_rng] using continuous_induced_dom.matrix_adjugate continuous_mul := by simpa only [continuous_induced_rng] using (continuous_induced_dom.comp continuous_fst).mul (continuous_induced_dom.comp continuous_snd) section toGL -- results on the map from `SL` to `GL` /-- The natural map from `SL n A` to `GL n A` is continuous. -/ lemma continuous_toGL : Continuous (toGL : SL n R → GL n R) := by simp_rw [Units.continuous_iff, ← map_inv] constructor <;> fun_prop /-- The natural map from `SL n A` to `GL n A` is inducing, i.e. the topology on `SL n A` is the pullback of the topology from `GL n A`. -/ lemma isInducing_toGL : Topology.IsInducing (toGL : SL n R → GL n R) := .of_comp continuous_toGL Units.continuous_val (Topology.IsInducing.induced _) /-- The natural map from `SL n A` in `GL n A` is an embedding, i.e. it is an injection and the topology on `SL n A` coincides with the subspace topology from `GL n A`. -/ lemma isEmbedding_toGL : Topology.IsEmbedding (toGL : SL n R → GL n R) := ⟨isInducing_toGL, toGL_injective⟩ theorem range_toGL {A : Type*} [CommRing A] : Set.range (toGL : SL n A → GL n A) = GeneralLinearGroup.det ⁻¹' {1} := by ext x simpa [Units.ext_iff] using ⟨fun ⟨y, hy⟩ ↦ by simp [← hy], fun hx ↦ ⟨⟨x, hx⟩, rfl⟩⟩ /-- The natural inclusion of `SL n A` in `GL n A` is a closed embedding. -/ lemma isClosedEmbedding_toGL [T0Space R] : Topology.IsClosedEmbedding (toGL : SL n R → GL n R) := ⟨isEmbedding_toGL, by simpa [range_toGL] using isClosed_singleton.preimage <| by fun_prop⟩ end toGL section mapGL variable {n : Type*} [Fintype n] [DecidableEq n] {A B : Type*} [CommRing A] [CommRing B] [Algebra A B] [TopologicalSpace A] [TopologicalSpace B] [IsTopologicalRing B] lemma isInducing_mapGL (h : Topology.IsInducing (algebraMap A B)) : Topology.IsInducing (mapGL B : SL n A → GL n B) := by -- TODO: add `IsInducing.units_map` and deduce `IsInducing.generalLinearGroup_map` refine isInducing_toGL.comp ?_ refine .of_comp ?_ continuous_induced_dom (h.matrix_map.comp (Topology.IsInducing.induced _)) rw [continuous_induced_rng] exact continuous_subtype_val.matrix_map h.continuous lemma isEmbedding_mapGL (h : Topology.IsEmbedding (algebraMap A B)) : Topology.IsEmbedding (mapGL B : SL n A → GL n B) := haveI : FaithfulSMul A B := (faithfulSMul_iff_algebraMap_injective _ _).mpr h.2 ⟨isInducing_mapGL h.isInducing, mapGL_injective⟩ end mapGL end Matrix.SpecialLinearGroup end MatrixGroups
.lake/packages/mathlib/Mathlib/Topology/Instances/Discrete.lean
import Mathlib.Topology.Order.Basic import Mathlib.Order.SuccPred.LinearLocallyFinite /-! # Instances related to the discrete topology We prove that the discrete topology is * first-countable, * second-countable for an encodable type, * equal to the order topology in linear orders which are also `PredOrder` and `SuccOrder`, * metrizable. When importing this file and `Data.Nat.SuccPred`, the instances `SecondCountableTopology ℕ` and `OrderTopology ℕ` become available. -/ open Order Set TopologicalSpace Filter variable {α : Type*} [TopologicalSpace α] instance (priority := 100) DiscreteTopology.firstCountableTopology [DiscreteTopology α] : FirstCountableTopology α where nhds_generated_countable := by rw [nhds_discrete]; exact isCountablyGenerated_pure instance (priority := 100) DiscreteTopology.secondCountableTopology_of_countable [hd : DiscreteTopology α] [Countable α] : SecondCountableTopology α := haveI : ∀ i : α, SecondCountableTopology (↥({i} : Set α)) := fun i => { is_open_generated_countable := ⟨{univ}, countable_singleton _, by simp only [eq_iff_true_of_subsingleton]⟩ } secondCountableTopology_of_countable_cover (fun _ ↦ isOpen_discrete _) (iUnion_of_singleton α) theorem LinearOrder.bot_topologicalSpace_eq_generateFrom {α} [LinearOrder α] [PredOrder α] [SuccOrder α] : (⊥ : TopologicalSpace α) = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } := by let _ := Preorder.topology α have : OrderTopology α := ⟨rfl⟩ exact DiscreteTopology.of_predOrder_succOrder.eq_bot.symm theorem discreteTopology_iff_orderTopology_of_pred_succ [LinearOrder α] [PredOrder α] [SuccOrder α] : DiscreteTopology α ↔ OrderTopology α := by refine ⟨fun h ↦ ⟨?_⟩, fun h ↦ .of_predOrder_succOrder⟩ rw [h.eq_bot, LinearOrder.bot_topologicalSpace_eq_generateFrom] instance OrderTopology.of_discreteTopology [LinearOrder α] [PredOrder α] [SuccOrder α] [DiscreteTopology α] : OrderTopology α := discreteTopology_iff_orderTopology_of_pred_succ.mp ‹_› instance OrderTopology.of_linearLocallyFinite [LinearOrder α] [LocallyFiniteOrder α] [DiscreteTopology α] : OrderTopology α := haveI := LinearLocallyFiniteOrder.succOrder α haveI := LinearLocallyFiniteOrder.predOrder α inferInstance
.lake/packages/mathlib/Mathlib/Topology/Instances/Rat.lean
import Mathlib.Algebra.Algebra.Rat import Mathlib.Algebra.Module.Rat import Mathlib.Data.NNRat.Order import Mathlib.Topology.Algebra.Order.Archimedean import Mathlib.Topology.Algebra.Ring.Real import Mathlib.Topology.Instances.Nat /-! # Topology on the rational numbers The structure of a metric space on `ℚ` is introduced in this file, induced from `ℝ`. -/ open Filter Metric Set Topology namespace Rat instance : MetricSpace ℚ := MetricSpace.induced (↑) Rat.cast_injective Real.metricSpace theorem dist_eq (x y : ℚ) : dist x y = |(x : ℝ) - y| := rfl @[norm_cast, simp] theorem dist_cast (x y : ℚ) : dist (x : ℝ) y = dist x y := rfl theorem uniformContinuous_coe_real : UniformContinuous ((↑) : ℚ → ℝ) := uniformContinuous_comap theorem isUniformEmbedding_coe_real : IsUniformEmbedding ((↑) : ℚ → ℝ) := isUniformEmbedding_comap Rat.cast_injective theorem isDenseEmbedding_coe_real : IsDenseEmbedding ((↑) : ℚ → ℝ) := isUniformEmbedding_coe_real.isDenseEmbedding Rat.denseRange_cast theorem isEmbedding_coe_real : IsEmbedding ((↑) : ℚ → ℝ) := isDenseEmbedding_coe_real.isEmbedding theorem continuous_coe_real : Continuous ((↑) : ℚ → ℝ) := uniformContinuous_coe_real.continuous end Rat @[norm_cast, simp] theorem Nat.dist_cast_rat (x y : ℕ) : dist (x : ℚ) y = dist x y := by rw [← Nat.dist_cast_real, ← Rat.dist_cast]; congr theorem Nat.isUniformEmbedding_coe_rat : IsUniformEmbedding ((↑) : ℕ → ℚ) := isUniformEmbedding_bot_of_pairwise_le_dist zero_lt_one <| by simpa using Nat.pairwise_one_le_dist theorem Nat.isClosedEmbedding_coe_rat : IsClosedEmbedding ((↑) : ℕ → ℚ) := isClosedEmbedding_of_pairwise_le_dist zero_lt_one <| by simpa using Nat.pairwise_one_le_dist @[norm_cast, simp] theorem Int.dist_cast_rat (x y : ℤ) : dist (x : ℚ) y = dist x y := by rw [← Int.dist_cast_real, ← Rat.dist_cast]; congr theorem Int.isUniformEmbedding_coe_rat : IsUniformEmbedding ((↑) : ℤ → ℚ) := isUniformEmbedding_bot_of_pairwise_le_dist zero_lt_one <| by simpa using Int.pairwise_one_le_dist theorem Int.isClosedEmbedding_coe_rat : IsClosedEmbedding ((↑) : ℤ → ℚ) := isClosedEmbedding_of_pairwise_le_dist zero_lt_one <| by simpa using Int.pairwise_one_le_dist namespace Rat instance : NoncompactSpace ℚ := Int.isClosedEmbedding_coe_rat.noncompactSpace theorem uniformContinuous_add : UniformContinuous fun p : ℚ × ℚ => p.1 + p.2 := Rat.isUniformEmbedding_coe_real.isUniformInducing.uniformContinuous_iff.2 <| by simp only [Function.comp_def, Rat.cast_add] exact Real.uniformContinuous_add.comp (Rat.uniformContinuous_coe_real.prodMap Rat.uniformContinuous_coe_real) theorem uniformContinuous_neg : UniformContinuous (@Neg.neg ℚ _) := Metric.uniformContinuous_iff.2 fun ε ε0 => ⟨_, ε0, fun _ _ h => by simpa only [abs_sub_comm, dist_eq, cast_neg, neg_sub_neg] using h⟩ instance : IsUniformAddGroup ℚ := IsUniformAddGroup.mk' Rat.uniformContinuous_add Rat.uniformContinuous_neg instance : IsTopologicalAddGroup ℚ := inferInstance instance : OrderTopology ℚ := induced_orderTopology _ Rat.cast_lt exists_rat_btwn theorem uniformContinuous_abs : UniformContinuous (abs : ℚ → ℚ) := Metric.uniformContinuous_iff.2 fun ε ε0 => ⟨ε, ε0, fun _ _ h => lt_of_le_of_lt (by simpa [Rat.dist_eq] using abs_abs_sub_abs_le_abs_sub _ _) h⟩ instance : IsTopologicalRing ℚ := inferInstance nonrec theorem totallyBounded_Icc (a b : ℚ) : TotallyBounded (Icc a b) := by simpa only [preimage_cast_Icc] using totallyBounded_preimage Rat.isUniformEmbedding_coe_real.isUniformInducing (totallyBounded_Icc (a : ℝ) b) end Rat namespace NNRat instance : MetricSpace ℚ≥0 := Subtype.metricSpace set_option linter.style.commandStart false in @[simp ←, push_cast] lemma dist_eq (p q : ℚ≥0) : dist p q = dist (p : ℚ) (q : ℚ) := rfl set_option linter.style.commandStart false in @[simp ←, push_cast] lemma nndist_eq (p q : ℚ≥0) : nndist p q = nndist (p : ℚ) (q : ℚ) := rfl instance : IsTopologicalSemiring ℚ≥0 where toContinuousAdd := continuousAdd_induced Nonneg.coeRingHom toContinuousMul := continuousMul_induced Nonneg.coeRingHom instance : ContinuousSub ℚ≥0 := ⟨((continuous_subtype_val.fst'.sub continuous_subtype_val.snd').max continuous_const).subtype_mk _⟩ instance : OrderTopology ℚ≥0 := orderTopology_of_ordConnected (t := Set.Ici 0) instance : ContinuousInv₀ ℚ≥0 := inferInstance -- Special case of `IsBoundedSMul.continuousSMul` but this shortcut instance reduces dependencies instance : ContinuousSMul ℚ ℝ where continuous_smul := continuous_induced_dom.fst'.smul (M := ℝ) (X := ℝ) continuous_snd instance {R : Type*} [TopologicalSpace R] [MulAction ℚ R] [MulAction ℚ≥0 R] [IsScalarTower ℚ≥0 ℚ R] [ContinuousSMul ℚ R] : ContinuousSMul ℚ≥0 R where continuous_smul := by conv in _ • _ => rw [← NNRat.cast_smul_eq_nnqsmul ℚ] fun_prop instance : ContinuousSMul ℚ≥0 NNReal where continuous_smul := Continuous.subtype_mk (by fun_prop) _ end NNRat
.lake/packages/mathlib/Mathlib/Topology/Instances/RealVectorSpace.lean
import Mathlib.Topology.Algebra.Module.Equiv import Mathlib.Topology.Instances.Rat import Mathlib.Algebra.Module.Rat /-! # Continuous additive maps are `ℝ`-linear In this file we prove that a continuous map `f : E →+ F` between two topological vector spaces over `ℝ` is `ℝ`-linear -/ variable {E : Type*} [AddCommGroup E] [Module ℝ E] [TopologicalSpace E] [ContinuousSMul ℝ E] {F : Type*} [AddCommGroup F] [Module ℝ F] [TopologicalSpace F] [ContinuousSMul ℝ F] [T2Space F] /-- A continuous additive map between two vector spaces over `ℝ` is `ℝ`-linear. -/ theorem map_real_smul {G} [FunLike G E F] [AddMonoidHomClass G E F] (f : G) (hf : Continuous f) (c : ℝ) (x : E) : f (c • x) = c • f x := suffices (fun c : ℝ => f (c • x)) = fun c : ℝ => c • f x from congr_fun this c Rat.isDenseEmbedding_coe_real.dense.equalizer (hf.comp <| continuous_id.smul continuous_const) (continuous_id.smul continuous_const) (funext fun r => map_ratCast_smul f ℝ ℝ r x) namespace AddMonoidHom /-- Reinterpret a continuous additive homomorphism between two real vector spaces as a continuous real-linear map. -/ def toRealLinearMap (f : E →+ F) (hf : Continuous f) : E →L[ℝ] F := ⟨{ toFun := f map_add' := f.map_add map_smul' := map_real_smul f hf }, hf⟩ @[simp] theorem coe_toRealLinearMap (f : E →+ F) (hf : Continuous f) : ⇑(f.toRealLinearMap hf) = f := rfl end AddMonoidHom /-- Reinterpret a continuous additive equivalence between two real vector spaces as a continuous real-linear map. -/ def AddEquiv.toRealLinearEquiv (e : E ≃+ F) (h₁ : Continuous e) (h₂ : Continuous e.symm) : E ≃L[ℝ] F := { e, e.toAddMonoidHom.toRealLinearMap h₁ with } /-- A topological group carries at most one structure of a topological `ℝ`-module, so for any topological `ℝ`-algebra `A` (e.g. `A = ℂ`) and any topological group that is both a topological `ℝ`-module and a topological `A`-module, these structures agree. -/ instance (priority := 900) Real.isScalarTower [T2Space E] {A : Type*} [TopologicalSpace A] [Ring A] [Algebra ℝ A] [Module A E] [ContinuousSMul ℝ A] [ContinuousSMul A E] : IsScalarTower ℝ A E := ⟨fun r x y => map_real_smul ((smulAddHom A E).flip y) (continuous_id.smul continuous_const) r x⟩
.lake/packages/mathlib/Mathlib/Topology/Instances/Nat.lean
import Mathlib.Data.Nat.Lattice import Mathlib.Topology.Instances.Int /-! # Topology on the natural numbers The structure of a metric space on `ℕ` is introduced in this file, induced from `ℝ`. -/ noncomputable section open Filter Metric Set Topology namespace Nat noncomputable instance : Dist ℕ := ⟨fun x y => dist (x : ℝ) y⟩ theorem dist_eq (x y : ℕ) : dist x y = |(x : ℝ) - y| := rfl theorem dist_coe_int (x y : ℕ) : dist (x : ℤ) (y : ℤ) = dist x y := rfl @[norm_cast, simp] theorem dist_cast_real (x y : ℕ) : dist (x : ℝ) y = dist x y := rfl theorem pairwise_one_le_dist : Pairwise fun m n : ℕ => 1 ≤ dist m n := fun _ _ hne => Int.pairwise_one_le_dist <| mod_cast hne theorem isUniformEmbedding_coe_real : IsUniformEmbedding ((↑) : ℕ → ℝ) := isUniformEmbedding_bot_of_pairwise_le_dist zero_lt_one pairwise_one_le_dist theorem isClosedEmbedding_coe_real : IsClosedEmbedding ((↑) : ℕ → ℝ) := isClosedEmbedding_of_pairwise_le_dist zero_lt_one pairwise_one_le_dist instance : MetricSpace ℕ := Nat.isUniformEmbedding_coe_real.comapMetricSpace _ theorem preimage_ball (x : ℕ) (r : ℝ) : (↑) ⁻¹' ball (x : ℝ) r = ball x r := rfl theorem preimage_closedBall (x : ℕ) (r : ℝ) : (↑) ⁻¹' closedBall (x : ℝ) r = closedBall x r := rfl theorem closedBall_eq_Icc (x : ℕ) (r : ℝ) : closedBall x r = Icc ⌈↑x - r⌉₊ ⌊↑x + r⌋₊ := by rcases le_or_gt 0 r with (hr | hr) · rw [← preimage_closedBall, Real.closedBall_eq_Icc, preimage_Icc] positivity · rw [closedBall_eq_empty.2 hr, Icc_eq_empty_of_lt] calc ⌊(x : ℝ) + r⌋₊ ≤ ⌊(x : ℝ)⌋₊ := floor_mono <| by linarith _ < ⌈↑x - r⌉₊ := by rw [floor_natCast, Nat.lt_ceil] linarith instance : ProperSpace ℕ := ⟨fun x r => by rw [closedBall_eq_Icc] exact (Set.finite_Icc _ _).isCompact⟩ instance : IsOrderBornology ℕ := .of_isCompactIcc 0 (by simp) (by simp [Nat.closedBall_eq_Icc]) instance : NoncompactSpace ℕ := noncompactSpace_of_neBot <| by simp only [Filter.cocompact_eq_cofinite, Filter.cofinite_neBot] end Nat
.lake/packages/mathlib/Mathlib/Topology/Instances/ENat.lean
import Mathlib.Data.ENat.Basic import Mathlib.Topology.Instances.Discrete import Mathlib.Order.Interval.Set.WithBotTop import Mathlib.Order.Filter.Pointwise import Mathlib.Topology.Algebra.Monoid.Defs /-! # Topology on extended natural numbers -/ open Filter Set Topology namespace ENat /-- Topology on `ℕ∞`. Note: this is different from the `EMetricSpace` topology. The `EMetricSpace` topology has `IsOpen {∞}`, but all neighborhoods of `∞` in `ℕ∞` contain infinite intervals. -/ instance : TopologicalSpace ℕ∞ := Preorder.topology ℕ∞ instance : OrderTopology ℕ∞ := ⟨rfl⟩ @[simp] theorem range_natCast : range ((↑) : ℕ → ℕ∞) = Iio ⊤ := WithTop.range_coe theorem isEmbedding_natCast : IsEmbedding ((↑) : ℕ → ℕ∞) := Nat.strictMono_cast.isEmbedding_of_ordConnected <| range_natCast ▸ ordConnected_Iio theorem isOpenEmbedding_natCast : IsOpenEmbedding ((↑) : ℕ → ℕ∞) := ⟨isEmbedding_natCast, range_natCast ▸ isOpen_Iio⟩ theorem nhds_natCast (n : ℕ) : 𝓝 (n : ℕ∞) = pure (n : ℕ∞) := by simp [← isOpenEmbedding_natCast.map_nhds_eq] @[simp] protected theorem nhds_eq_pure {n : ℕ∞} (h : n ≠ ⊤) : 𝓝 n = pure n := by lift n to ℕ using h simp [nhds_natCast] theorem isOpen_singleton {x : ℕ∞} (hx : x ≠ ⊤) : IsOpen {x} := by rw [isOpen_singleton_iff_nhds_eq_pure, ENat.nhds_eq_pure hx] theorem mem_nhds_iff {x : ℕ∞} {s : Set ℕ∞} (hx : x ≠ ⊤) : s ∈ 𝓝 x ↔ x ∈ s := by simp [hx] theorem mem_nhds_natCast_iff (n : ℕ) {s : Set ℕ∞} : s ∈ 𝓝 (n : ℕ∞) ↔ (n : ℕ∞) ∈ s := mem_nhds_iff (coe_ne_top _) theorem tendsto_nhds_top_iff_natCast_lt {α : Type*} {l : Filter α} {f : α → ℕ∞} : Tendsto f l (𝓝 ⊤) ↔ ∀ n : ℕ, ∀ᶠ a in l, n < f a := by simp_rw [nhds_top_order, lt_top_iff_ne_top, tendsto_iInf, tendsto_principal, ENat.forall_ne_top, mem_Ioi] instance : ContinuousAdd ℕ∞ := by refine ⟨continuous_iff_continuousAt.2 fun (a, b) ↦ ?_⟩ match a, b with | ⊤, _ => exact tendsto_nhds_top_mono' continuousAt_fst fun p ↦ le_add_right le_rfl | (a : ℕ), ⊤ => exact tendsto_nhds_top_mono' continuousAt_snd fun p ↦ le_add_left le_rfl | (a : ℕ), (b : ℕ) => simp [ContinuousAt, nhds_prod_eq, tendsto_pure_nhds] instance : ContinuousMul ℕ∞ where continuous_mul := have key (a : ℕ∞) : ContinuousAt (· * ·).uncurry (a, ⊤) := by rcases (zero_le a).eq_or_lt with rfl | ha · simp [ContinuousAt, nhds_prod_eq] · simp only [ContinuousAt, Function.uncurry, mul_top ha.ne'] refine tendsto_nhds_top_mono continuousAt_snd ?_ filter_upwards [continuousAt_fst (lt_mem_nhds ha)] with (x, y) (hx : 0 < x) exact le_mul_of_one_le_left (zero_le y) (Order.one_le_iff_pos.2 hx) continuous_iff_continuousAt.2 <| Prod.forall.2 fun | (a : ℕ∞), ⊤ => key a | ⊤, (b : ℕ∞) => ((key b).comp_of_eq (continuous_swap.tendsto (⊤, b)) rfl).congr <| .of_forall fun _ ↦ mul_comm .. | (a : ℕ), (b : ℕ) => by simp [ContinuousAt, nhds_prod_eq, tendsto_pure_nhds] protected theorem continuousAt_sub {a b : ℕ∞} (h : a ≠ ⊤ ∨ b ≠ ⊤) : ContinuousAt (· - ·).uncurry (a, b) := by match a, b, h with | (a : ℕ), (b : ℕ), _ => simp [ContinuousAt, nhds_prod_eq] | (a : ℕ), ⊤, _ => suffices ∀ᶠ b in 𝓝 ⊤, (a - b : ℕ∞) = 0 by simpa [ContinuousAt, nhds_prod_eq, tsub_eq_zero_of_le] filter_upwards [le_mem_nhds (WithTop.coe_lt_top a)] with b using tsub_eq_zero_of_le | ⊤, (b : ℕ), _ => suffices ∀ n : ℕ, ∀ᶠ a : ℕ∞ in 𝓝 ⊤, b + n < a by simpa [ContinuousAt, nhds_prod_eq, (· ∘ ·), lt_tsub_iff_left, tendsto_nhds_top_iff_natCast_lt] exact fun n ↦ lt_mem_nhds <| WithTop.coe_lt_top (b + n) end ENat theorem Filter.Tendsto.enatSub {α : Type*} {l : Filter α} {f g : α → ℕ∞} {a b : ℕ∞} (hf : Tendsto f l (𝓝 a)) (hg : Tendsto g l (𝓝 b)) (h : a ≠ ⊤ ∨ b ≠ ⊤) : Tendsto (fun x ↦ f x - g x) l (𝓝 (a - b)) := (ENat.continuousAt_sub h).tendsto.comp (hf.prodMk_nhds hg) variable {X : Type*} [TopologicalSpace X] {f g : X → ℕ∞} {s : Set X} {x : X} nonrec theorem ContinuousWithinAt.enatSub (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : f x ≠ ⊤ ∨ g x ≠ ⊤) : ContinuousWithinAt (fun x ↦ f x - g x) s x := hf.enatSub hg h nonrec theorem ContinuousAt.enatSub (hf : ContinuousAt f x) (hg : ContinuousAt g x) (h : f x ≠ ⊤ ∨ g x ≠ ⊤) : ContinuousAt (fun x ↦ f x - g x) x := hf.enatSub hg h nonrec theorem ContinuousOn.enatSub (hf : ContinuousOn f s) (hg : ContinuousOn g s) (h : ∀ x ∈ s, f x ≠ ⊤ ∨ g x ≠ ⊤) : ContinuousOn (fun x ↦ f x - g x) s := fun x hx ↦ (hf x hx).enatSub (hg x hx) (h x hx) nonrec theorem Continuous.enatSub (hf : Continuous f) (hg : Continuous g) (h : ∀ x, f x ≠ ⊤ ∨ g x ≠ ⊤) : Continuous (fun x ↦ f x - g x) := continuous_iff_continuousAt.2 fun x ↦ hf.continuousAt.enatSub hg.continuousAt (h x)
.lake/packages/mathlib/Mathlib/Topology/Instances/RatLemmas.lean
import Mathlib.Topology.Instances.Irrational import Mathlib.Topology.Instances.Rat import Mathlib.Topology.Compactification.OnePoint.Basic import Mathlib.Topology.Metrizable.Uniformity /-! # Additional lemmas about the topology on rational numbers The structure of a metric space on `ℚ` (`Rat.MetricSpace`) is introduced elsewhere, induced from `ℝ`. In this file we prove some properties of this topological space and its one-point compactification. ## Main statements - `Rat.TotallyDisconnectedSpace`: `ℚ` is a totally disconnected space; - `Rat.not_countably_generated_nhds_infty_opc`: the filter of neighbourhoods of infinity in `OnePoint ℚ` is not countably generated. ## Notation - `ℚ∞` is used as a local notation for `OnePoint ℚ` -/ open Set Metric Filter TopologicalSpace open Topology OnePoint local notation "ℚ∞" => OnePoint ℚ namespace Rat variable {p : ℚ} {s : Set ℚ} theorem interior_compact_eq_empty (hs : IsCompact s) : interior s = ∅ := isDenseEmbedding_coe_real.isDenseInducing.interior_compact_eq_empty dense_irrational hs theorem dense_compl_compact (hs : IsCompact s) : Dense sᶜ := interior_eq_empty_iff_dense_compl.1 (interior_compact_eq_empty hs) instance cocompact_inf_nhds_neBot : NeBot (cocompact ℚ ⊓ 𝓝 p) := by refine (hasBasis_cocompact.inf (nhds_basis_opens _)).neBot_iff.2 ?_ rintro ⟨s, o⟩ ⟨hs, hpo, ho⟩; rw [inter_comm] exact (dense_compl_compact hs).inter_open_nonempty _ ho ⟨p, hpo⟩ theorem not_countably_generated_cocompact : ¬IsCountablyGenerated (cocompact ℚ) := by intro H rcases exists_seq_tendsto (cocompact ℚ ⊓ 𝓝 0) with ⟨x, hx⟩ rw [tendsto_inf] at hx; rcases hx with ⟨hxc, hx0⟩ obtain ⟨n, hn⟩ : ∃ n : ℕ, x n ∉ insert (0 : ℚ) (range x) := (hxc.eventually hx0.isCompact_insert_range.compl_mem_cocompact).exists exact hn (Or.inr ⟨n, rfl⟩) theorem not_countably_generated_nhds_infty_opc : ¬IsCountablyGenerated (𝓝 (∞ : ℚ∞)) := by intro have : IsCountablyGenerated (comap (OnePoint.some : ℚ → ℚ∞) (𝓝 ∞)) := by infer_instance rw [OnePoint.comap_coe_nhds_infty, coclosedCompact_eq_cocompact] at this exact not_countably_generated_cocompact this theorem not_firstCountableTopology_opc : ¬FirstCountableTopology ℚ∞ := by intro exact not_countably_generated_nhds_infty_opc inferInstance theorem not_secondCountableTopology_opc : ¬SecondCountableTopology ℚ∞ := by intro exact not_firstCountableTopology_opc inferInstance instance : TotallyDisconnectedSpace ℚ := by clear p s refine ⟨fun s hsu hs x hx y hy => ?_⟩; clear hsu by_contra! H : x ≠ y wlog hlt : x < y · apply this s hs y hy x hx H.symm <| H.lt_or_gt.resolve_left hlt rcases exists_irrational_btwn (Rat.cast_lt.2 hlt) with ⟨z, hz, hxz, hzy⟩ have := hs.image _ continuous_coe_real.continuousOn rw [isPreconnected_iff_ordConnected] at this have : z ∈ Rat.cast '' s := this.out (mem_image_of_mem _ hx) (mem_image_of_mem _ hy) ⟨hxz.le, hzy.le⟩ exact hz (image_subset_range _ _ this) end Rat
.lake/packages/mathlib/Mathlib/Topology/Instances/PNat.lean
import Mathlib.Topology.Instances.Nat /-! # Topology on the positive natural numbers The structure of a metric space on `ℕ+` is introduced in this file, induced from `ℝ`. -/ noncomputable section open Metric namespace PNat instance : MetricSpace ℕ+ := inferInstanceAs (MetricSpace { n : ℕ // 0 < n }) theorem dist_eq (x y : ℕ+) : dist x y = |(↑x : ℝ) - ↑y| := rfl @[simp, norm_cast] theorem dist_coe (x y : ℕ+) : dist (↑x : ℕ) (↑y : ℕ) = dist x y := rfl theorem isUniformEmbedding_coe : IsUniformEmbedding ((↑) : ℕ+ → ℕ) := isUniformEmbedding_subtype_val instance : DiscreteTopology ℕ+ := inferInstanceAs (DiscreteTopology { n : ℕ // 0 < n }) instance : ProperSpace ℕ+ where isCompact_closedBall n r := by change IsCompact (((↑) : ℕ+ → ℕ) ⁻¹' closedBall (↑n : ℕ) r) rw [Nat.closedBall_eq_Icc] exact ((Set.finite_Icc _ _).preimage PNat.coe_injective.injOn).isCompact instance : NoncompactSpace ℕ+ := noncompactSpace_of_neBot <| by simp only [Filter.cocompact_eq_cofinite, Filter.cofinite_neBot] end PNat
.lake/packages/mathlib/Mathlib/Topology/Instances/ZMultiples.lean
import Mathlib.Algebra.Group.Subgroup.ZPowers.Lemmas import Mathlib.Algebra.Module.Submodule.Lattice import Mathlib.Topology.Algebra.IsUniformGroup.Basic import Mathlib.Topology.Algebra.Ring.Real import Mathlib.Topology.Metrizable.Basic /-! The subgroup "multiples of `a`" (`zmultiples a`) is a discrete subgroup of `ℝ`, i.e. its intersection with compact sets is finite. -/ noncomputable section open Filter Int Metric Set TopologicalSpace Bornology open scoped Topology Uniformity Interval universe u v w variable {α : Type u} {β : Type v} {γ : Type w} namespace Int open Metric /-- This is a special case of `NormedSpace.discreteTopology_zmultiples`. It exists only to simplify dependencies. -/ instance {a : ℝ} : DiscreteTopology (AddSubgroup.zmultiples a) := by rcases eq_or_ne a 0 with (rfl | ha) · rw [AddSubgroup.zmultiples_zero_eq_bot] exact Subsingleton.discreteTopology (α := (⊥ : Submodule ℤ ℝ)) rw [discreteTopology_iff_isOpen_singleton_zero, isOpen_induced_iff] refine ⟨ball 0 |a|, isOpen_ball, ?_⟩ ext ⟨x, hx⟩ obtain ⟨k, rfl⟩ := AddSubgroup.mem_zmultiples_iff.mp hx simp [ha, Real.dist_eq, abs_mul, (by norm_cast : |(k : ℝ)| < 1 ↔ |k| < 1)] /-- Under the coercion from `ℤ` to `ℝ`, inverse images of compact sets are finite. -/ theorem tendsto_coe_cofinite : Tendsto ((↑) : ℤ → ℝ) cofinite (cocompact ℝ) := by apply (castAddHom ℝ).tendsto_coe_cofinite_of_discrete cast_injective rw [range_castAddHom] infer_instance /-- For nonzero `a`, the "multiples of `a`" map `zmultiplesHom` from `ℤ` to `ℝ` is discrete, i.e. inverse images of compact sets are finite. -/ theorem tendsto_zmultiplesHom_cofinite {a : ℝ} (ha : a ≠ 0) : Tendsto (zmultiplesHom ℝ a) cofinite (cocompact ℝ) := by apply (zmultiplesHom ℝ a).tendsto_coe_cofinite_of_discrete <| smul_left_injective ℤ ha rw [AddSubgroup.range_zmultiplesHom] infer_instance end Int namespace AddSubgroup /-- The subgroup "multiples of `a`" (`zmultiples a`) is a discrete subgroup of `ℝ`, i.e. its intersection with compact sets is finite. -/ theorem tendsto_zmultiples_subtype_cofinite (a : ℝ) : Tendsto (zmultiples a).subtype cofinite (cocompact ℝ) := (zmultiples a).tendsto_coe_cofinite_of_discrete end AddSubgroup
.lake/packages/mathlib/Mathlib/Topology/Instances/Shrink.lean
import Mathlib.Logic.Small.Defs import Mathlib.Topology.Defs.Induced import Mathlib.Topology.Homeomorph.Defs /-! # Topological space structure on `Shrink X` -/ universe v u namespace Shrink noncomputable instance (X : Type u) [TopologicalSpace X] [Small.{v} X] : TopologicalSpace (Shrink.{v} X) := .coinduced (equivShrink X) inferInstance /-- `equivShrink` as a homeomorphism. -/ @[simps toEquiv] noncomputable def homeomorph (X : Type u) [TopologicalSpace X] [Small.{v} X] : X ≃ₜ Shrink.{v} X where __ := equivShrink X continuous_toFun := continuous_coinduced_rng continuous_invFun := by convert continuous_induced_dom simp only [Equiv.invFun_as_coe, Equiv.induced_symm] rfl end Shrink
.lake/packages/mathlib/Mathlib/Topology/Instances/Complex.lean
import Mathlib.Analysis.Complex.Basic import Mathlib.FieldTheory.IntermediateField.Basic import Mathlib.LinearAlgebra.Complex.FiniteDimensional import Mathlib.LinearAlgebra.FiniteDimensional.Lemmas import Mathlib.Topology.Algebra.Field import Mathlib.Topology.Algebra.UniformRing /-! # Some results about the topology of ℂ -/ section ComplexSubfield open Complex Set open ComplexConjugate /-- The only closed subfields of `ℂ` are `ℝ` and `ℂ`. -/ theorem Complex.subfield_eq_of_closed {K : Subfield ℂ} (hc : IsClosed (K : Set ℂ)) : K = ofRealHom.fieldRange ∨ K = ⊤ := by suffices range (ofReal : ℝ → ℂ) ⊆ K by rw [range_subset_iff, ← coe_algebraMap] at this have := (Subalgebra.isSimpleOrder_of_finrank finrank_real_complex).eq_bot_or_eq_top (Subfield.toIntermediateField K this).toSubalgebra simp_rw [← SetLike.coe_set_eq, IntermediateField.coe_toSubalgebra] at this ⊢ exact this suffices range (ofReal : ℝ → ℂ) ⊆ closure (Set.range ((ofReal : ℝ → ℂ) ∘ ((↑) : ℚ → ℝ))) by refine subset_trans this ?_ rw [← IsClosed.closure_eq hc] apply closure_mono rintro _ ⟨_, rfl⟩ simp only [Function.comp_apply, ofReal_ratCast, SetLike.mem_coe, SubfieldClass.ratCast_mem] nth_rw 1 [range_comp] refine subset_trans ?_ (image_closure_subset_closure_image continuous_ofReal) rw [DenseRange.closure_range Rat.isDenseEmbedding_coe_real.dense] simp only [image_univ] rfl /-- Let `K` a subfield of `ℂ` and let `ψ : K →+* ℂ` a ring homomorphism. Assume that `ψ` is uniform continuous, then `ψ` is either the inclusion map or the composition of the inclusion map with the complex conjugation. -/ theorem Complex.uniformContinuous_ringHom_eq_id_or_conj (K : Subfield ℂ) {ψ : K →+* ℂ} (hc : UniformContinuous ψ) : ψ.toFun = K.subtype ∨ ψ.toFun = conj ∘ K.subtype := by letI : IsTopologicalDivisionRing ℂ := IsTopologicalDivisionRing.mk letI : IsTopologicalRing K.topologicalClosure := Subring.instIsTopologicalRing K.topologicalClosure.toSubring set ι : K → K.topologicalClosure := ⇑(Subfield.inclusion K.le_topologicalClosure) have ui : IsUniformInducing ι := ⟨by rw [uniformity_subtype, uniformity_subtype, Filter.comap_comap] congr ⟩ let di := ui.isDenseInducing (?_ : DenseRange ι) · -- extψ : closure(K) →+* ℂ is the extension of ψ : K →+* ℂ let extψ := IsDenseInducing.extendRingHom ui di.dense hc haveI hψ := (uniformContinuous_uniformly_extend ui di.dense hc).continuous rcases Complex.subfield_eq_of_closed (Subfield.isClosed_topologicalClosure K) with h | h · left let j := RingEquiv.subfieldCongr h -- ψ₁ is the continuous ring hom `ℝ →+* ℂ` constructed from `j : closure (K) ≃+* ℝ` -- and `extψ : closure (K) →+* ℂ` let ψ₁ := RingHom.comp extψ (RingHom.comp j.symm.toRingHom ofRealHom.rangeRestrict) -- Porting note: was `by continuity!` and was used inline have hψ₁ : Continuous ψ₁ := by simpa only [RingHom.coe_comp] using hψ.comp ((continuous_algebraMap ℝ ℂ).subtype_mk _) ext1 x rsuffices ⟨r, hr⟩ : ∃ r : ℝ, ofRealHom.rangeRestrict r = j (ι x) · have := RingHom.congr_fun (ringHom_eq_ofReal_of_continuous hψ₁) r rw [RingHom.comp_apply, RingHom.comp_apply] at this -- In `this`, the `DFunLike.coe` thinks it is applying a `(ℝ →+* ↥ofRealHom.fieldRange)`, -- while in `hr`, we have a `(ℝ →+* ↥ofRealHom.range)`. -- We could add a `@[simp]` lemma fixing this, but it breaks later steps of the proof. erw [hr] at this rw [RingEquiv.toRingHom_eq_coe] at this convert this using 1 · exact (IsDenseInducing.extend_eq di hc.continuous _).symm · rw [← ofRealHom.coe_rangeRestrict, hr] rfl obtain ⟨r, hr⟩ := SetLike.coe_mem (j (ι x)) exact ⟨r, Subtype.ext hr⟩ · -- ψ₁ is the continuous ring hom `ℂ →+* ℂ` constructed from `closure (K) ≃+* ℂ` -- and `extψ : closure (K) →+* ℂ` let ψ₁ := RingHom.comp extψ (RingHom.comp (RingEquiv.subfieldCongr h).symm.toRingHom (@Subfield.topEquiv ℂ _).symm.toRingHom) -- Porting note: was `by continuity!` and was used inline have hψ₁ : Continuous ψ₁ := by simpa only [RingHom.coe_comp] using hψ.comp (continuous_id.subtype_mk _) rcases ringHom_eq_id_or_conj_of_continuous hψ₁ with h | h · left ext1 z convert RingHom.congr_fun h z using 1 exact (IsDenseInducing.extend_eq di hc.continuous z).symm · right ext1 z convert RingHom.congr_fun h z using 1 exact (IsDenseInducing.extend_eq di hc.continuous z).symm · let j : { x // x ∈ closure (id '' { x | (K : Set ℂ) x }) } → (K.topologicalClosure : Set ℂ) := fun x => ⟨x, by convert x.prop simp only [id, Set.image_id'] rfl ⟩ convert DenseRange.comp (Function.Surjective.denseRange _) (IsDenseEmbedding.id.subtype (K : Set ℂ)).dense (by fun_prop : Continuous j) rintro ⟨y, hy⟩ use ⟨y, by convert hy simp only [id, Set.image_id'] rfl ⟩ end ComplexSubfield
.lake/packages/mathlib/Mathlib/Topology/Instances/Irrational.lean
import Mathlib.Data.Rat.Encodable import Mathlib.NumberTheory.Real.Irrational import Mathlib.Topology.Separation.GDelta import Mathlib.Topology.Instances.Real.Lemmas /-! # Topology of irrational numbers In this file we prove the following theorems: * `IsGδ.setOf_irrational`, `dense_irrational`, `eventually_residual_irrational`: irrational numbers form a dense Gδ set; * `Irrational.eventually_forall_le_dist_cast_div`, `Irrational.eventually_forall_le_dist_cast_div_of_denom_le`; `Irrational.eventually_forall_le_dist_cast_rat_of_denom_le`: a sufficiently small neighborhood of an irrational number is disjoint with the set of rational numbers with bounded denominator. We also provide `OrderTopology`, `NoMinOrder`, `NoMaxOrder`, and `DenselyOrdered` instances for `{x // Irrational x}`. ## Tags irrational, residual -/ open Set Filter Metric open Filter Topology protected theorem IsGδ.setOf_irrational : IsGδ { x | Irrational x } := (countable_range _).isGδ_compl theorem dense_irrational : Dense { x : ℝ | Irrational x } := by refine Real.isTopologicalBasis_Ioo_rat.dense_iff.2 ?_ simp only [mem_iUnion, mem_singleton_iff, exists_prop, forall_exists_index, and_imp] rintro _ a b hlt rfl _ rw [inter_comm] exact exists_irrational_btwn (Rat.cast_lt.2 hlt) theorem eventually_residual_irrational : ∀ᶠ x in residual ℝ, Irrational x := residual_of_dense_Gδ .setOf_irrational dense_irrational namespace Irrational variable {x : ℝ} instance : OrderTopology { x // Irrational x } := induced_orderTopology _ Iff.rfl <| @fun _ _ hlt => let ⟨z, hz, hxz, hzy⟩ := exists_irrational_btwn hlt ⟨⟨z, hz⟩, hxz, hzy⟩ instance : NoMaxOrder { x // Irrational x } := ⟨fun ⟨x, hx⟩ => ⟨⟨x + (1 : ℕ), hx.add_natCast 1⟩, by simp⟩⟩ instance : NoMinOrder { x // Irrational x } := ⟨fun ⟨x, hx⟩ => ⟨⟨x - (1 : ℕ), hx.sub_natCast 1⟩, by simp⟩⟩ instance : DenselyOrdered { x // Irrational x } := ⟨fun _ _ hlt => let ⟨z, hz, hxz, hzy⟩ := exists_irrational_btwn hlt ⟨⟨z, hz⟩, hxz, hzy⟩⟩ theorem eventually_forall_le_dist_cast_div (hx : Irrational x) (n : ℕ) : ∀ᶠ ε : ℝ in 𝓝 0, ∀ m : ℤ, ε ≤ dist x (m / n) := by have A : IsClosed (range (fun m => (n : ℝ)⁻¹ * m : ℤ → ℝ)) := ((isClosedMap_smul₀ (n⁻¹ : ℝ)).comp Int.isClosedEmbedding_coe_real.isClosedMap).isClosed_range have B : x ∉ range (fun m => (n : ℝ)⁻¹ * m : ℤ → ℝ) := by rintro ⟨m, rfl⟩ simp at hx rcases Metric.mem_nhds_iff.1 (A.isOpen_compl.mem_nhds B) with ⟨ε, ε0, hε⟩ refine (ge_mem_nhds ε0).mono fun δ hδ m => not_lt.1 fun hlt => ?_ rw [dist_comm] at hlt refine hε (ball_subset_ball hδ hlt) ⟨m, ?_⟩ simp [div_eq_inv_mul] theorem eventually_forall_le_dist_cast_div_of_denom_le (hx : Irrational x) (n : ℕ) : ∀ᶠ ε : ℝ in 𝓝 0, ∀ k ≤ n, ∀ (m : ℤ), ε ≤ dist x (m / k) := (finite_le_nat n).eventually_all.2 fun k _ => hx.eventually_forall_le_dist_cast_div k theorem eventually_forall_le_dist_cast_rat_of_den_le (hx : Irrational x) (n : ℕ) : ∀ᶠ ε : ℝ in 𝓝 0, ∀ r : ℚ, r.den ≤ n → ε ≤ dist x r := (hx.eventually_forall_le_dist_cast_div_of_denom_le n).mono fun ε H r hr => by simpa only [Rat.cast_def] using H r.den hr r.num end Irrational
.lake/packages/mathlib/Mathlib/Topology/Instances/ZMod.lean
import Mathlib.Topology.Order import Mathlib.Data.ZMod.Defs /-! # Topology on `ZMod N` We equip `ZMod N` with the discrete topology. -/ namespace ZMod variable {N : ℕ} /-- The discrete topology (every set is open). -/ instance : TopologicalSpace (ZMod N) := ⊥ instance : DiscreteTopology (ZMod N) := ⟨rfl⟩ end ZMod
.lake/packages/mathlib/Mathlib/Topology/Instances/TrivSqZeroExt.lean
import Mathlib.Algebra.TrivSqZeroExt import Mathlib.Topology.Algebra.InfiniteSum.Basic import Mathlib.Topology.Algebra.IsUniformGroup.Constructions import Mathlib.Topology.Algebra.Module.LinearMapPiProd /-! # Topology on `TrivSqZeroExt R M` The type `TrivSqZeroExt R M` inherits the topology from `R × M`. Note that this is not the topology induced by the seminorm on the dual numbers suggested by [this Math.SE answer](https://math.stackexchange.com/a/1056378/1896), which instead induces the topology pulled back through the projection map `TrivSqZeroExt.fst : tsze R M → R`. Obviously, that topology is not Hausdorff and using it would result in `exp` converging to more than one value. ## Main results * `TrivSqZeroExt.topologicalRing`: the ring operations are continuous -/ open Topology variable {α S R M : Type*} local notation "tsze" => TrivSqZeroExt namespace TrivSqZeroExt section Topology variable [TopologicalSpace R] [TopologicalSpace M] instance instTopologicalSpace : TopologicalSpace (tsze R M) := TopologicalSpace.induced fst ‹_› ⊓ TopologicalSpace.induced snd ‹_› instance [T2Space R] [T2Space M] : T2Space (tsze R M) := Prod.t2Space theorem nhds_def (x : tsze R M) : 𝓝 x = 𝓝 x.fst ×ˢ 𝓝 x.snd := nhds_prod_eq theorem nhds_inl [Zero M] (x : R) : 𝓝 (inl x : tsze R M) = 𝓝 x ×ˢ 𝓝 0 := nhds_def _ theorem nhds_inr [Zero R] (m : M) : 𝓝 (inr m : tsze R M) = 𝓝 0 ×ˢ 𝓝 m := nhds_def _ nonrec theorem continuous_fst : Continuous (fst : tsze R M → R) := continuous_fst nonrec theorem continuous_snd : Continuous (snd : tsze R M → M) := continuous_snd theorem continuous_inl [Zero M] : Continuous (inl : R → tsze R M) := continuous_id.prodMk continuous_const theorem continuous_inr [Zero R] : Continuous (inr : M → tsze R M) := continuous_const.prodMk continuous_id theorem IsEmbedding.inl [Zero M] : IsEmbedding (inl : R → tsze R M) := .of_comp continuous_inl continuous_fst .id theorem IsEmbedding.inr [Zero R] : IsEmbedding (inr : M → tsze R M) := .of_comp continuous_inr continuous_snd .id variable (R M) /-- `TrivSqZeroExt.fst` as a continuous linear map. -/ @[simps] def fstCLM [CommSemiring R] [AddCommMonoid M] [Module R M] : StrongDual R (tsze R M) := { ContinuousLinearMap.fst R R M with toFun := fst } /-- `TrivSqZeroExt.snd` as a continuous linear map. -/ @[simps] def sndCLM [CommSemiring R] [AddCommMonoid M] [Module R M] : tsze R M →L[R] M := { ContinuousLinearMap.snd R R M with toFun := snd cont := continuous_snd } /-- `TrivSqZeroExt.inl` as a continuous linear map. -/ @[simps] def inlCLM [CommSemiring R] [AddCommMonoid M] [Module R M] : R →L[R] tsze R M := { ContinuousLinearMap.inl R R M with toFun := inl } /-- `TrivSqZeroExt.inr` as a continuous linear map. -/ @[simps] def inrCLM [CommSemiring R] [AddCommMonoid M] [Module R M] : M →L[R] tsze R M := { ContinuousLinearMap.inr R R M with toFun := inr } variable {R M} instance [Add R] [Add M] [ContinuousAdd R] [ContinuousAdd M] : ContinuousAdd (tsze R M) := Prod.continuousAdd instance [Mul R] [Add M] [SMul R M] [SMul Rᵐᵒᵖ M] [ContinuousMul R] [ContinuousSMul R M] [ContinuousSMul Rᵐᵒᵖ M] [ContinuousAdd M] : ContinuousMul (tsze R M) := ⟨((continuous_fst.comp continuous_fst).mul (continuous_fst.comp continuous_snd)).prodMk <| ((continuous_fst.comp continuous_fst).smul (continuous_snd.comp continuous_snd)).add ((MulOpposite.continuous_op.comp <| continuous_fst.comp <| continuous_snd).smul (continuous_snd.comp continuous_fst))⟩ instance [Neg R] [Neg M] [ContinuousNeg R] [ContinuousNeg M] : ContinuousNeg (tsze R M) := Prod.continuousNeg /-- This is not an instance due to complaints by the `fails_quickly` linter. At any rate, we only really care about the `IsTopologicalRing` instance below. -/ theorem topologicalSemiring [Semiring R] [AddCommMonoid M] [Module R M] [Module Rᵐᵒᵖ M] [IsTopologicalSemiring R] [ContinuousAdd M] [ContinuousSMul R M] [ContinuousSMul Rᵐᵒᵖ M] : IsTopologicalSemiring (tsze R M) := { } instance [Ring R] [AddCommGroup M] [Module R M] [Module Rᵐᵒᵖ M] [IsTopologicalRing R] [IsTopologicalAddGroup M] [ContinuousSMul R M] [ContinuousSMul Rᵐᵒᵖ M] : IsTopologicalRing (tsze R M) where instance [SMul S R] [SMul S M] [ContinuousConstSMul S R] [ContinuousConstSMul S M] : ContinuousConstSMul S (tsze R M) := Prod.continuousConstSMul instance [TopologicalSpace S] [SMul S R] [SMul S M] [ContinuousSMul S R] [ContinuousSMul S M] : ContinuousSMul S (tsze R M) := Prod.continuousSMul variable (M) theorem hasSum_inl [AddCommMonoid R] [AddCommMonoid M] {f : α → R} {a : R} (h : HasSum f a) : HasSum (fun x ↦ inl (f x)) (inl a : tsze R M) := h.map (⟨⟨inl, inl_zero _⟩, inl_add _⟩ : R →+ tsze R M) continuous_inl theorem hasSum_inr [AddCommMonoid R] [AddCommMonoid M] {f : α → M} {a : M} (h : HasSum f a) : HasSum (fun x ↦ inr (f x)) (inr a : tsze R M) := h.map (⟨⟨inr, inr_zero _⟩, inr_add _⟩ : M →+ tsze R M) continuous_inr theorem hasSum_fst [AddCommMonoid R] [AddCommMonoid M] {f : α → tsze R M} {a : tsze R M} (h : HasSum f a) : HasSum (fun x ↦ fst (f x)) (fst a) := h.map (⟨⟨fst, fst_zero⟩, fst_add⟩ : tsze R M →+ R) continuous_fst theorem hasSum_snd [AddCommMonoid R] [AddCommMonoid M] {f : α → tsze R M} {a : tsze R M} (h : HasSum f a) : HasSum (fun x ↦ snd (f x)) (snd a) := h.map (⟨⟨snd, snd_zero⟩, snd_add⟩ : tsze R M →+ M) continuous_snd end Topology section Uniformity variable [UniformSpace R] [UniformSpace M] instance instUniformSpace : UniformSpace (tsze R M) where toTopologicalSpace := instTopologicalSpace __ := instUniformSpaceProd instance [CompleteSpace R] [CompleteSpace M] : CompleteSpace (tsze R M) := inferInstanceAs <| CompleteSpace (R × M) instance [AddGroup R] [AddGroup M] [IsUniformAddGroup R] [IsUniformAddGroup M] : IsUniformAddGroup (tsze R M) := inferInstanceAs <| IsUniformAddGroup (R × M) open Uniformity theorem uniformity_def : 𝓤 (tsze R M) = ((𝓤 R).comap fun p => (p.1.fst, p.2.fst)) ⊓ ((𝓤 M).comap fun p => (p.1.snd, p.2.snd)) := rfl nonrec theorem uniformContinuous_fst : UniformContinuous (fst : tsze R M → R) := uniformContinuous_fst nonrec theorem uniformContinuous_snd : UniformContinuous (snd : tsze R M → M) := uniformContinuous_snd theorem uniformContinuous_inl [Zero M] : UniformContinuous (inl : R → tsze R M) := uniformContinuous_id.prodMk uniformContinuous_const theorem uniformContinuous_inr [Zero R] : UniformContinuous (inr : M → tsze R M) := uniformContinuous_const.prodMk uniformContinuous_id end Uniformity end TrivSqZeroExt
.lake/packages/mathlib/Mathlib/Topology/Instances/NNReal/Lemmas.lean
import Mathlib.Data.NNReal.Basic import Mathlib.Topology.Algebra.InfiniteSum.Order import Mathlib.Topology.Algebra.InfiniteSum.Ring import Mathlib.Topology.Algebra.Ring.Real import Mathlib.Topology.ContinuousMap.Basic /-! # Topology on `ℝ≥0` The basic lemmas for the natural topology on `ℝ≥0` . ## Main statements Various mathematically trivial lemmas are proved about the compatibility of limits and sums in `ℝ≥0` and `ℝ`. For example * `tendsto_coe {f : Filter α} {m : α → ℝ≥0} {x : ℝ≥0} : Filter.Tendsto (fun a, (m a : ℝ)) f (𝓝 (x : ℝ)) ↔ Filter.Tendsto m f (𝓝 x)` says that the limit of a filter along a map to `ℝ≥0` is the same in `ℝ` and `ℝ≥0`, and * `coe_tsum {f : α → ℝ≥0} : ((∑'a, f a) : ℝ) = (∑'a, (f a : ℝ))` says that says that a sum of elements in `ℝ≥0` is the same in `ℝ` and `ℝ≥0`. Similarly, some mathematically trivial lemmas about infinite sums are proved, a few of which rely on the fact that subtraction is continuous. -/ noncomputable section open Filter Metric Set TopologicalSpace Topology variable {ι : Sort*} {n : ℕ} namespace NNReal variable {α : Type*} {L : SummationFilter α} section coe lemma isOpen_Ico_zero {x : NNReal} : IsOpen (Set.Ico 0 x) := Ico_bot (a := x) ▸ isOpen_Iio open Filter Finset @[fun_prop] theorem _root_.continuous_real_toNNReal : Continuous Real.toNNReal := (continuous_id.max continuous_const).subtype_mk _ /-- `Real.toNNReal` bundled as a continuous map for convenience. -/ @[simps -fullyApplied] noncomputable def _root_.ContinuousMap.realToNNReal : C(ℝ, ℝ≥0) := .mk Real.toNNReal continuous_real_toNNReal lemma _root_.ContinuousOn.ofReal_map_toNNReal {f : ℝ≥0 → ℝ≥0} {s : Set ℝ} {t : Set ℝ≥0} (hf : ContinuousOn f t) (h : Set.MapsTo Real.toNNReal s t) : ContinuousOn (fun x ↦ f x.toNNReal : ℝ → ℝ) s := continuous_subtype_val.comp_continuousOn <| hf.comp continuous_real_toNNReal.continuousOn h @[simp, norm_cast] theorem tendsto_coe {f : Filter α} {m : α → ℝ≥0} {x : ℝ≥0} : Tendsto (fun a => (m a : ℝ)) f (𝓝 (x : ℝ)) ↔ Tendsto m f (𝓝 x) := tendsto_subtype_rng.symm theorem tendsto_coe' {f : Filter α} [NeBot f] {m : α → ℝ≥0} {x : ℝ} : Tendsto (fun a => m a : α → ℝ) f (𝓝 x) ↔ ∃ hx : 0 ≤ x, Tendsto m f (𝓝 ⟨x, hx⟩) := ⟨fun h => ⟨ge_of_tendsto' h fun c => (m c).2, tendsto_coe.1 h⟩, fun ⟨_, hm⟩ => tendsto_coe.2 hm⟩ @[simp] theorem map_coe_atTop : map toReal atTop = atTop := map_val_Ici_atTop 0 @[simp] theorem comap_coe_atTop : comap toReal atTop = atTop := (atTop_Ici_eq 0).symm @[simp, norm_cast] theorem tendsto_coe_atTop {f : Filter α} {m : α → ℝ≥0} : Tendsto (fun a => (m a : ℝ)) f atTop ↔ Tendsto m f atTop := tendsto_Ici_atTop.symm theorem _root_.tendsto_real_toNNReal {f : Filter α} {m : α → ℝ} {x : ℝ} (h : Tendsto m f (𝓝 x)) : Tendsto (fun a => Real.toNNReal (m a)) f (𝓝 (Real.toNNReal x)) := (continuous_real_toNNReal.tendsto _).comp h @[simp] theorem _root_.Real.map_toNNReal_atTop : map Real.toNNReal atTop = atTop := by rw [← map_coe_atTop, Function.LeftInverse.filter_map @Real.toNNReal_coe] theorem _root_.tendsto_real_toNNReal_atTop : Tendsto Real.toNNReal atTop atTop := Real.map_toNNReal_atTop.le @[simp] theorem _root_.Real.comap_toNNReal_atTop : comap Real.toNNReal atTop = atTop := by refine le_antisymm ?_ tendsto_real_toNNReal_atTop.le_comap refine (atTop_basis_Ioi' 0).ge_iff.2 fun a ha ↦ ?_ filter_upwards [preimage_mem_comap (Ioi_mem_atTop a.toNNReal)] with x hx exact (Real.toNNReal_lt_toNNReal_iff_of_nonneg ha.le).1 hx @[simp] theorem _root_.Real.tendsto_toNNReal_atTop_iff {l : Filter α} {f : α → ℝ} : Tendsto (fun x ↦ (f x).toNNReal) l atTop ↔ Tendsto f l atTop := by rw [← Real.comap_toNNReal_atTop, tendsto_comap_iff, Function.comp_def] theorem _root_.Real.tendsto_toNNReal_atTop : Tendsto Real.toNNReal atTop atTop := Real.tendsto_toNNReal_atTop_iff.2 tendsto_id theorem nhds_zero : 𝓝 (0 : ℝ≥0) = ⨅ (a : ℝ≥0) (_ : a ≠ 0), 𝓟 (Iio a) := nhds_bot_order.trans <| by simp only [bot_lt_iff_ne_bot]; rfl theorem nhds_zero_basis : (𝓝 (0 : ℝ≥0)).HasBasis (fun a : ℝ≥0 => 0 < a) fun a => Iio a := nhds_bot_basis @[norm_cast] theorem hasSum_coe {f : α → ℝ≥0} {r : ℝ≥0} : HasSum (fun a => (f a : ℝ)) (r : ℝ) L ↔ HasSum f r L := by simp only [HasSum, ← coe_sum, tendsto_coe] protected theorem _root_.HasSum.toNNReal {f : α → ℝ} {y : ℝ} (hf₀ : ∀ n, 0 ≤ f n) (hy : HasSum f y L) : HasSum (fun x => Real.toNNReal (f x)) y.toNNReal L := by rcases L.neBot_or_eq_bot with _ | hL · lift y to ℝ≥0 using hy.nonneg hf₀ lift f to α → ℝ≥0 using hf₀ simpa [hasSum_coe] using hy · simp [HasSum, hL] theorem hasSum_real_toNNReal_of_nonneg {f : α → ℝ} (hf_nonneg : ∀ n, 0 ≤ f n) (hf : Summable f L) : HasSum (fun n => Real.toNNReal (f n)) (Real.toNNReal (∑'[L] n, f n)) L := hf.hasSum.toNNReal hf_nonneg @[norm_cast] theorem summable_coe {f : α → ℝ≥0} : (Summable (fun a => (f a : ℝ)) L) ↔ Summable f L := by rcases L.neBot_or_eq_bot with _ | hL · constructor · exact fun ⟨a, ha⟩ => ⟨⟨a, ha.nonneg fun x => (f x).2⟩, hasSum_coe.1 ha⟩ · exact fun ⟨a, ha⟩ => ⟨a.1, hasSum_coe.2 ha⟩ · simp [Summable, HasSum, hL] theorem summable_mk {f : α → ℝ} (hf : ∀ n, 0 ≤ f n) : Summable (fun n ↦ ⟨f n, hf n⟩ : α → ℝ≥0) L ↔ Summable f L := Iff.symm <| summable_coe (f := fun x => ⟨f x, hf x⟩) @[norm_cast] theorem coe_tsum {f : α → ℝ≥0} : ↑(∑'[L] a, f a) = ∑'[L] a, (f a : ℝ) := Function.LeftInverse.map_tsum (g := NNReal.toRealHom) f NNReal.continuous_coe continuous_real_toNNReal (fun x ↦ by simp) theorem coe_tsum_of_nonneg {f : α → ℝ} (hf₁ : ∀ n, 0 ≤ f n) : (⟨∑'[L] n, f n, tsum_nonneg hf₁⟩ : ℝ≥0) = (∑'[L] n, ⟨f n, hf₁ n⟩ : ℝ≥0) := NNReal.eq <| Eq.symm <| coe_tsum (f := fun x => ⟨f x, hf₁ x⟩) nonrec theorem tsum_mul_left (a : ℝ≥0) (f : α → ℝ≥0) : ∑'[L] x, a * f x = a * ∑'[L] x, f x := NNReal.eq <| by simp only [coe_tsum, NNReal.coe_mul, tsum_mul_left] nonrec theorem tsum_mul_right (f : α → ℝ≥0) (a : ℝ≥0) : ∑'[L] x, f x * a = (∑'[L] x, f x) * a := NNReal.eq <| by simp only [coe_tsum, NNReal.coe_mul, tsum_mul_right] theorem summable_comp_injective {β : Type*} {f : α → ℝ≥0} (hf : Summable f) {i : β → α} (hi : Function.Injective i) : Summable (f ∘ i) := by rw [← summable_coe] at hf ⊢ exact hf.comp_injective hi theorem summable_nat_add (f : ℕ → ℝ≥0) (hf : Summable f) (k : ℕ) : Summable fun i => f (i + k) := summable_comp_injective hf <| add_left_injective k nonrec theorem summable_nat_add_iff {f : ℕ → ℝ≥0} (k : ℕ) : (Summable fun i => f (i + k)) ↔ Summable f := by rw [← summable_coe, ← summable_coe] exact @summable_nat_add_iff ℝ _ _ _ (fun i => (f i : ℝ)) k nonrec theorem hasSum_nat_add_iff {f : ℕ → ℝ≥0} (k : ℕ) {a : ℝ≥0} : HasSum (fun n => f (n + k)) a ↔ HasSum f (a + ∑ i ∈ range k, f i) := by rw [← hasSum_coe, hasSum_nat_add_iff (f := fun n => toReal (f n)) k]; norm_cast theorem sum_add_tsum_nat_add {f : ℕ → ℝ≥0} (k : ℕ) (hf : Summable f) : ∑' i, f i = (∑ i ∈ range k, f i) + ∑' i, f (i + k) := (((summable_nat_add_iff k).2 hf).sum_add_tsum_nat_add').symm theorem iInf_real_pos_eq_iInf_nnreal_pos [CompleteLattice α] {f : ℝ → α} : ⨅ (n : ℝ) (_ : 0 < n), f n = ⨅ (n : ℝ≥0) (_ : 0 < n), f n := le_antisymm (iInf_mono' fun r => ⟨r, le_rfl⟩) (iInf₂_mono' fun r hr => ⟨⟨r, hr.le⟩, hr, le_rfl⟩) end coe theorem tendsto_cofinite_zero_of_summable {α} {f : α → ℝ≥0} (hf : Summable f) : Tendsto f cofinite (𝓝 0) := by simp only [← summable_coe, ← tendsto_coe] at hf ⊢ exact hf.tendsto_cofinite_zero theorem tendsto_atTop_zero_of_summable {f : ℕ → ℝ≥0} (hf : Summable f) : Tendsto f atTop (𝓝 0) := by rw [← Nat.cofinite_eq_atTop] exact tendsto_cofinite_zero_of_summable hf /-- The sum over the complement of a finset tends to `0` when the finset grows to cover the whole space. This does not need a summability assumption, as otherwise all sums are zero. -/ nonrec theorem tendsto_tsum_compl_atTop_zero {α : Type*} (f : α → ℝ≥0) : Tendsto (fun s : Finset α => ∑' b : { x // x ∉ s }, f b) atTop (𝓝 0) := by simp_rw [← tendsto_coe, coe_tsum, NNReal.coe_zero] exact tendsto_tsum_compl_atTop_zero fun a : α => (f a : ℝ) /-- `x ↦ x ^ n` as an order isomorphism of `ℝ≥0`. -/ def powOrderIso (n : ℕ) (hn : n ≠ 0) : ℝ≥0 ≃o ℝ≥0 := StrictMono.orderIsoOfSurjective (fun x ↦ x ^ n) (fun x y h => pow_left_strictMonoOn₀ hn (zero_le x) (zero_le y) h) <| (continuous_id.pow _).surjective (tendsto_pow_atTop hn) <| by simpa [OrderBot.atBot_eq, pos_iff_ne_zero] section Monotone /-- A monotone, bounded above sequence `f : ℕ → ℝ` has a finite limit. -/ theorem _root_.Real.tendsto_of_bddAbove_monotone {f : ℕ → ℝ} (h_bdd : BddAbove (Set.range f)) (h_mon : Monotone f) : ∃ r : ℝ, Tendsto f atTop (𝓝 r) := by obtain ⟨B, hB⟩ := Real.exists_isLUB (Set.range_nonempty f) h_bdd exact ⟨B, tendsto_atTop_isLUB h_mon hB⟩ /-- An antitone, bounded below sequence `f : ℕ → ℝ` has a finite limit. -/ theorem _root_.Real.tendsto_of_bddBelow_antitone {f : ℕ → ℝ} (h_bdd : BddBelow (Set.range f)) (h_ant : Antitone f) : ∃ r : ℝ, Tendsto f atTop (𝓝 r) := by obtain ⟨B, hB⟩ := Real.exists_isGLB (Set.range_nonempty f) h_bdd exact ⟨B, tendsto_atTop_isGLB h_ant hB⟩ /-- An antitone sequence `f : ℕ → ℝ≥0` has a finite limit. -/ theorem tendsto_of_antitone {f : ℕ → ℝ≥0} (h_ant : Antitone f) : ∃ r : ℝ≥0, Tendsto f atTop (𝓝 r) := by have h_bdd_0 : (0 : ℝ) ∈ lowerBounds (Set.range fun n : ℕ => (f n : ℝ)) := by rintro r ⟨n, hn⟩ simp_rw [← hn] exact NNReal.coe_nonneg _ obtain ⟨L, hL⟩ := Real.tendsto_of_bddBelow_antitone ⟨0, h_bdd_0⟩ h_ant have hL0 : 0 ≤ L := haveI h_glb : IsGLB (Set.range fun n => (f n : ℝ)) L := isGLB_of_tendsto_atTop h_ant hL (le_isGLB_iff h_glb).mpr h_bdd_0 exact ⟨⟨L, hL0⟩, NNReal.tendsto_coe.mp hL⟩ end Monotone lemma iSup_pow_of_ne_zero (hn : n ≠ 0) (f : ι → ℝ≥0) : (⨆ i, f i) ^ n = ⨆ i, f i ^ n := (NNReal.powOrderIso n hn).map_ciSup' _ lemma iSup_pow [Nonempty ι] (f : ι → ℝ≥0) (n : ℕ) : (⨆ i, f i) ^ n = ⨆ i, f i ^ n := by by_cases hn : n = 0 · simp [hn] · exact iSup_pow_of_ne_zero hn _ end NNReal namespace ENNReal attribute [simp] ENNReal.top_pow /-- `x ↦ x ^ n` as an order isomorphism of `ℝ≥0∞`. See also `ENNReal.orderIsoRpow`. -/ def powOrderIso (n : ℕ) (hn : n ≠ 0) : ℝ≥0∞ ≃o ℝ≥0∞ := (NNReal.powOrderIso n hn).withTopCongr.copy (· ^ n) _ (by cases n; (· cases hn rfl); · ext (_ | _) <;> rfl) rfl lemma iSup_pow_of_ne_zero (hn : n ≠ 0) (f : ι → ℝ≥0∞) : (⨆ i, f i) ^ n = ⨆ i, f i ^ n := (powOrderIso n hn).map_iSup _ lemma iSup_pow [Nonempty ι] (f : ι → ℝ≥0∞) (n : ℕ) : (⨆ i, f i) ^ n = ⨆ i, f i ^ n := by by_cases hn : n = 0 · simp [hn] · exact iSup_pow_of_ne_zero hn _ lemma iSup₂_pow_of_ne_zero {κ : ι → Sort*} (f : (i : ι) → κ i → ℝ≥0∞) {n : ℕ} (hn : n ≠ 0) : (⨆ i, ⨆ j, f i j) ^ n = ⨆ i, ⨆ j, f i j ^ n := (powOrderIso n hn).map_iSup₂ f end ENNReal open NNReal in lemma Real.iSup_pow [Nonempty ι] {f : ι → ℝ} (hf : ∀ i, 0 ≤ f i) (n : ℕ) : (⨆ i, f i) ^ n = ⨆ i, f i ^ n := by lift f to ι → ℝ≥0 using hf; dsimp; exact mod_cast NNReal.iSup_pow f n lemma Real.iSup_pow_of_ne_zero {f : ι → ℝ} (hf : ∀ i, 0 ≤ f i) (hn : n ≠ 0) : (⨆ i, f i) ^ n = ⨆ i, f i ^ n := by cases isEmpty_or_nonempty ι · simp [hn] · exact iSup_pow hf _
.lake/packages/mathlib/Mathlib/Topology/Instances/Real/Lemmas.lean
import Mathlib.Algebra.Field.Periodic import Mathlib.Algebra.Field.Subfield.Basic import Mathlib.Topology.Algebra.Order.Archimedean import Mathlib.Topology.Algebra.Ring.Real /-! # Topological properties of ℝ -/ assert_not_exists UniformOnFun noncomputable section open Filter Int Metric Set TopologicalSpace Bornology open scoped Topology Uniformity Interval universe u v w variable {α : Type u} {β : Type v} {γ : Type w} theorem Real.isTopologicalBasis_Ioo_rat : @IsTopologicalBasis ℝ _ (⋃ (a : ℚ) (b : ℚ) (_ : a < b), {Ioo (a : ℝ) b}) := isTopologicalBasis_of_isOpen_of_nhds (by simp +contextual [isOpen_Ioo]) fun a _ hav hv => let ⟨_, _, ⟨hl, hu⟩, h⟩ := mem_nhds_iff_exists_Ioo_subset.mp (IsOpen.mem_nhds hv hav) let ⟨q, hlq, hqa⟩ := exists_rat_btwn hl let ⟨p, hap, hpu⟩ := exists_rat_btwn hu ⟨Ioo q p, by simp only [mem_iUnion] exact ⟨q, p, Rat.cast_lt.1 <| hqa.trans hap, rfl⟩, ⟨hqa, hap⟩, fun _ ⟨hqa', ha'p⟩ => h ⟨hlq.trans hqa', ha'p.trans hpu⟩⟩ @[simp] theorem Real.cobounded_eq : cobounded ℝ = atBot ⊔ atTop := by simp only [← comap_dist_right_atTop (0 : ℝ), Real.dist_eq, sub_zero, comap_abs_atTop] /- TODO(Mario): Prove that these are uniform isomorphisms instead of uniform embeddings lemma uniform_embedding_add_rat {r : ℚ} : uniform_embedding (fun p : ℚ => p + r) := _ lemma uniform_embedding_mul_rat {q : ℚ} (hq : q ≠ 0) : uniform_embedding ((*) q) := _ -/ theorem Real.mem_closure_iff {s : Set ℝ} {x : ℝ} : x ∈ closure s ↔ ∀ ε > 0, ∃ y ∈ s, |y - x| < ε := by simp [mem_closure_iff_nhds_basis nhds_basis_ball, Real.dist_eq] theorem Real.uniformContinuous_inv (s : Set ℝ) {r : ℝ} (r0 : 0 < r) (H : ∀ x ∈ s, r ≤ |x|) : UniformContinuous fun p : s => p.1⁻¹ := Metric.uniformContinuous_iff.2 fun _ε ε0 => let ⟨δ, δ0, Hδ⟩ := rat_inv_continuous_lemma abs ε0 r0 ⟨δ, δ0, fun {a b} h => Hδ (H _ a.2) (H _ b.2) h⟩ theorem Real.uniformContinuous_abs : UniformContinuous (abs : ℝ → ℝ) := Metric.uniformContinuous_iff.2 fun ε ε0 => ⟨ε, ε0, fun _ _ ↦ lt_of_le_of_lt (abs_abs_sub_abs_le_abs_sub _ _)⟩ theorem Real.continuous_inv : Continuous fun a : { r : ℝ // r ≠ 0 } => a.val⁻¹ := continuousOn_inv₀.restrict theorem Real.uniformContinuous_mul (s : Set (ℝ × ℝ)) {r₁ r₂ : ℝ} (H : ∀ x ∈ s, |(x : ℝ × ℝ).1| < r₁ ∧ |x.2| < r₂) : UniformContinuous fun p : s => p.1.1 * p.1.2 := Metric.uniformContinuous_iff.2 fun _ε ε0 => let ⟨δ, δ0, Hδ⟩ := rat_mul_continuous_lemma abs ε0 ⟨δ, δ0, fun {a b} h => let ⟨h₁, h₂⟩ := max_lt_iff.1 h Hδ (H _ a.2).1 (H _ b.2).2 h₁ h₂⟩ theorem Real.totallyBounded_ball (x ε : ℝ) : TotallyBounded (ball x ε) := by rw [Real.ball_eq_Ioo]; apply totallyBounded_Ioo theorem Real.subfield_eq_of_closed {K : Subfield ℝ} (hc : IsClosed (K : Set ℝ)) : K = ⊤ := by rw [SetLike.ext'_iff, Subfield.coe_top, ← hc.closure_eq] refine Rat.denseRange_cast.mono ?_ |>.closure_eq rintro - ⟨_, rfl⟩ exact SubfieldClass.ratCast_mem K _ theorem Real.exists_seq_rat_strictMono_tendsto (x : ℝ) : ∃ u : ℕ → ℚ, StrictMono u ∧ (∀ n, u n < x) ∧ Tendsto (u · : ℕ → ℝ) atTop (𝓝 x) := Rat.denseRange_cast.exists_seq_strictMono_tendsto Rat.cast_strictMono.monotone x theorem Real.exists_seq_rat_strictAnti_tendsto (x : ℝ) : ∃ u : ℕ → ℚ, StrictAnti u ∧ (∀ n, x < u n) ∧ Tendsto (u · : ℕ → ℝ) atTop (𝓝 x) := Rat.denseRange_cast.exists_seq_strictAnti_tendsto Rat.cast_strictMono.monotone x section theorem closure_ordConnected_inter_rat {s : Set ℝ} (conn : s.OrdConnected) (nt : s.Nontrivial) : closure (s ∩ .range Rat.cast) = closure s := (closure_mono inter_subset_left).antisymm <| isClosed_closure.closure_subset_iff.mpr fun x hx ↦ Real.mem_closure_iff.mpr fun ε ε_pos ↦ by have ⟨z, hz, ne⟩ := nt.exists_ne x refine ne.lt_or_gt.elim (fun lt ↦ ?_) fun lt ↦ ?_ · have ⟨q, h₁, h₂⟩ := exists_rat_btwn (max_lt lt (sub_lt_self x ε_pos)) rw [max_lt_iff] at h₁ refine ⟨q, ⟨conn.out hz hx ⟨h₁.1.le, h₂.le⟩, q, rfl⟩, ?_⟩ simpa only [abs_sub_comm, abs_of_pos (sub_pos.mpr h₂), sub_lt_comm] using h₁.2 · have ⟨q, h₁, h₂⟩ := exists_rat_btwn (lt_min lt (lt_add_of_pos_right x ε_pos)) rw [lt_min_iff] at h₂ refine ⟨q, ⟨conn.out hx hz ⟨h₁.le, h₂.1.le⟩, q, rfl⟩, ?_⟩ simpa only [abs_of_pos (sub_pos.2 h₁), sub_lt_iff_lt_add'] using h₂.2 theorem closure_of_rat_image_lt {q : ℚ} : closure (((↑) : ℚ → ℝ) '' { x | q < x }) = { r | ↑q ≤ r } := by convert closure_ordConnected_inter_rat (ordConnected_Ioi (a := (q : ℝ))) _ using 1 · congr!; aesop · exact (closure_Ioi _).symm · exact ⟨q + 1, show (q : ℝ) < _ by linarith, q + 2, show (q : ℝ) < _ by linarith, by simp⟩ /- TODO(Mario): Put these back only if needed later lemma closure_of_rat_image_le_eq {q : ℚ} : closure ((coe : ℚ → ℝ) '' {x | q ≤ x}) = {r | ↑q ≤ r} := _ lemma closure_of_rat_image_le_le_eq {a b : ℚ} (hab : a ≤ b) : closure (of_rat '' {q:ℚ | a ≤ q ∧ q ≤ b}) = {r:ℝ | of_rat a ≤ r ∧ r ≤ of_rat b} := _ -/ end section Periodic namespace Function /-- A continuous, periodic function has compact range. -/ theorem Periodic.compact_of_continuous [TopologicalSpace α] {f : ℝ → α} {c : ℝ} (hp : Periodic f c) (hc : c ≠ 0) (hf : Continuous f) : IsCompact (range f) := by rw [← hp.image_uIcc hc 0] exact isCompact_uIcc.image hf /-- A continuous, periodic function is bounded. -/ theorem Periodic.isBounded_of_continuous [PseudoMetricSpace α] {f : ℝ → α} {c : ℝ} (hp : Periodic f c) (hc : c ≠ 0) (hf : Continuous f) : IsBounded (range f) := (hp.compact_of_continuous hc hf).isBounded end Function end Periodic
.lake/packages/mathlib/Mathlib/Topology/Instances/ENNReal/Lemmas.lean
import Mathlib.Algebra.BigOperators.Intervals import Mathlib.Data.ENNReal.BigOperators import Mathlib.Tactic.Bound import Mathlib.Topology.Order.LiminfLimsup import Mathlib.Topology.EMetricSpace.Lipschitz import Mathlib.Topology.Instances.NNReal.Lemmas import Mathlib.Topology.MetricSpace.Pseudo.Real import Mathlib.Topology.MetricSpace.ProperSpace.Real import Mathlib.Topology.Metrizable.Uniformity /-! # Topology on extended non-negative reals -/ noncomputable section open Filter Function Metric Set Topology open scoped Finset ENNReal NNReal variable {α : Type*} {β : Type*} {γ : Type*} namespace ENNReal variable {a b : ℝ≥0∞} {r : ℝ≥0} {x : ℝ≥0∞} {ε : ℝ≥0∞} section TopologicalSpace open TopologicalSpace theorem isOpen_ne_top : IsOpen { a : ℝ≥0∞ | a ≠ ∞ } := isOpen_ne theorem isOpen_Ico_zero : IsOpen (Ico 0 b) := by rw [ENNReal.Ico_eq_Iio] exact isOpen_Iio theorem coe_range_mem_nhds : range ((↑) : ℝ≥0 → ℝ≥0∞) ∈ 𝓝 (r : ℝ≥0∞) := IsOpen.mem_nhds isOpenEmbedding_coe.isOpen_range <| mem_range_self _ @[fun_prop] theorem continuous_coe : Continuous ((↑) : ℝ≥0 → ℝ≥0∞) := isEmbedding_coe.continuous lemma tendsto_coe_toNNReal {a : ℝ≥0∞} (ha : a ≠ ⊤) : Tendsto (↑) (𝓝 a.toNNReal) (𝓝 a) := by nth_rewrite 2 [← coe_toNNReal ha] exact continuous_coe.tendsto _ theorem continuous_coe_iff {α} [TopologicalSpace α] {f : α → ℝ≥0} : (Continuous fun a => (f a : ℝ≥0∞)) ↔ Continuous f := isEmbedding_coe.continuous_iff.symm theorem nhds_coe {r : ℝ≥0} : 𝓝 (r : ℝ≥0∞) = (𝓝 r).map (↑) := (isOpenEmbedding_coe.map_nhds_eq r).symm theorem tendsto_nhds_coe_iff {α : Type*} {l : Filter α} {x : ℝ≥0} {f : ℝ≥0∞ → α} : Tendsto f (𝓝 ↑x) l ↔ Tendsto (f ∘ (↑) : ℝ≥0 → α) (𝓝 x) l := by rw [nhds_coe, tendsto_map'_iff] theorem continuousAt_coe_iff {α : Type*} [TopologicalSpace α] {x : ℝ≥0} {f : ℝ≥0∞ → α} : ContinuousAt f ↑x ↔ ContinuousAt (f ∘ (↑) : ℝ≥0 → α) x := tendsto_nhds_coe_iff theorem continuous_ofReal : Continuous ENNReal.ofReal := (continuous_coe_iff.2 continuous_id).comp continuous_real_toNNReal theorem tendsto_ofReal {f : Filter α} {m : α → ℝ} {a : ℝ} (h : Tendsto m f (𝓝 a)) : Tendsto (fun a => ENNReal.ofReal (m a)) f (𝓝 (ENNReal.ofReal a)) := (continuous_ofReal.tendsto a).comp h theorem tendsto_toNNReal {a : ℝ≥0∞} (ha : a ≠ ∞) : Tendsto ENNReal.toNNReal (𝓝 a) (𝓝 a.toNNReal) := by lift a to ℝ≥0 using ha rw [nhds_coe, tendsto_map'_iff] exact tendsto_id theorem tendsto_toNNReal_iff {f : α → ℝ≥0∞} {u : Filter α} (ha : a ≠ ∞) (hf : ∀ x, f x ≠ ∞) : Tendsto (ENNReal.toNNReal ∘ f) u (𝓝 (a.toNNReal)) ↔ Tendsto f u (𝓝 a) := by refine ⟨fun h => ?_, fun h => (ENNReal.tendsto_toNNReal ha).comp h⟩ rw [← coe_comp_toNNReal_comp hf] exact (tendsto_coe_toNNReal ha).comp h theorem tendsto_toNNReal_iff' {f : α → ℝ≥0∞} {u : Filter α} {a : ℝ≥0} (hf : ∀ x, f x ≠ ∞) : Tendsto (ENNReal.toNNReal ∘ f) u (𝓝 a) ↔ Tendsto f u (𝓝 a) := by rw [← toNNReal_coe a] exact tendsto_toNNReal_iff coe_ne_top hf theorem eventuallyEq_of_toReal_eventuallyEq {l : Filter α} {f g : α → ℝ≥0∞} (hfi : ∀ᶠ x in l, f x ≠ ∞) (hgi : ∀ᶠ x in l, g x ≠ ∞) (hfg : (fun x => (f x).toReal) =ᶠ[l] fun x => (g x).toReal) : f =ᶠ[l] g := by filter_upwards [hfi, hgi, hfg] with _ hfx hgx _ rwa [← ENNReal.toReal_eq_toReal_iff' hfx hgx] theorem continuousOn_toNNReal : ContinuousOn ENNReal.toNNReal { a | a ≠ ∞ } := fun _a ha => ContinuousAt.continuousWithinAt (tendsto_toNNReal ha) theorem tendsto_toReal {a : ℝ≥0∞} (ha : a ≠ ∞) : Tendsto ENNReal.toReal (𝓝 a) (𝓝 a.toReal) := NNReal.tendsto_coe.2 <| tendsto_toNNReal ha lemma continuousOn_toReal : ContinuousOn ENNReal.toReal { a | a ≠ ∞ } := NNReal.continuous_coe.comp_continuousOn continuousOn_toNNReal lemma continuousAt_toReal (hx : x ≠ ∞) : ContinuousAt ENNReal.toReal x := continuousOn_toReal.continuousAt (isOpen_ne_top.mem_nhds_iff.mpr hx) /-- The set of finite `ℝ≥0∞` numbers is homeomorphic to `ℝ≥0`. -/ def neTopHomeomorphNNReal : { a | a ≠ ∞ } ≃ₜ ℝ≥0 where toEquiv := neTopEquivNNReal continuous_toFun := continuousOn_iff_continuous_restrict.1 continuousOn_toNNReal continuous_invFun := continuous_coe.subtype_mk _ /-- The set of finite `ℝ≥0∞` numbers is homeomorphic to `ℝ≥0`. -/ def ltTopHomeomorphNNReal : { a | a < ∞ } ≃ₜ ℝ≥0 := by refine (Homeomorph.setCongr ?_).trans neTopHomeomorphNNReal simp only [lt_top_iff_ne_top] theorem nhds_top : 𝓝 ∞ = ⨅ (a) (_ : a ≠ ∞), 𝓟 (Ioi a) := nhds_top_order.trans <| by simp [lt_top_iff_ne_top, Ioi] theorem nhds_top' : 𝓝 ∞ = ⨅ r : ℝ≥0, 𝓟 (Ioi ↑r) := nhds_top.trans <| iInf_ne_top _ theorem nhds_top_basis : (𝓝 ∞).HasBasis (fun a => a < ∞) fun a => Ioi a := _root_.nhds_top_basis theorem tendsto_nhds_top_iff_nnreal {m : α → ℝ≥0∞} {f : Filter α} : Tendsto m f (𝓝 ∞) ↔ ∀ x : ℝ≥0, ∀ᶠ a in f, ↑x < m a := by simp only [nhds_top', tendsto_iInf, tendsto_principal, mem_Ioi] theorem tendsto_nhds_top_iff_nat {m : α → ℝ≥0∞} {f : Filter α} : Tendsto m f (𝓝 ∞) ↔ ∀ n : ℕ, ∀ᶠ a in f, ↑n < m a := tendsto_nhds_top_iff_nnreal.trans ⟨fun h n => by simpa only [ENNReal.coe_natCast] using h n, fun h x => let ⟨n, hn⟩ := exists_nat_gt x (h n).mono fun _ => lt_trans <| by rwa [← ENNReal.coe_natCast, coe_lt_coe]⟩ theorem tendsto_nhds_top {m : α → ℝ≥0∞} {f : Filter α} (h : ∀ n : ℕ, ∀ᶠ a in f, ↑n < m a) : Tendsto m f (𝓝 ∞) := tendsto_nhds_top_iff_nat.2 h theorem tendsto_nat_nhds_top : Tendsto (fun n : ℕ => ↑n) atTop (𝓝 ∞) := tendsto_nhds_top fun n => mem_atTop_sets.2 ⟨n + 1, fun _m hm => mem_setOf.2 <| Nat.cast_lt.2 <| Nat.lt_of_succ_le hm⟩ @[simp, norm_cast] theorem tendsto_coe_nhds_top {f : α → ℝ≥0} {l : Filter α} : Tendsto (fun x => (f x : ℝ≥0∞)) l (𝓝 ∞) ↔ Tendsto f l atTop := by rw [tendsto_nhds_top_iff_nnreal, atTop_basis_Ioi.tendsto_right_iff]; simp @[simp] theorem tendsto_ofReal_nhds_top {f : α → ℝ} {l : Filter α} : Tendsto (fun x ↦ ENNReal.ofReal (f x)) l (𝓝 ∞) ↔ Tendsto f l atTop := tendsto_coe_nhds_top.trans Real.tendsto_toNNReal_atTop_iff theorem tendsto_ofReal_atTop : Tendsto ENNReal.ofReal atTop (𝓝 ∞) := tendsto_ofReal_nhds_top.2 tendsto_id theorem nhds_zero : 𝓝 (0 : ℝ≥0∞) = ⨅ (a) (_ : a ≠ 0), 𝓟 (Iio a) := nhds_bot_order.trans <| by simp [pos_iff_ne_zero, Iio] theorem nhds_zero_basis : (𝓝 (0 : ℝ≥0∞)).HasBasis (fun a : ℝ≥0∞ => 0 < a) fun a => Iio a := nhds_bot_basis theorem nhds_zero_basis_Iic : (𝓝 (0 : ℝ≥0∞)).HasBasis (fun a : ℝ≥0∞ => 0 < a) Iic := nhds_bot_basis_Iic -- TODO: add a TC for `≠ ∞`? @[instance] theorem nhdsGT_coe_neBot {r : ℝ≥0} : (𝓝[>] (r : ℝ≥0∞)).NeBot := nhdsGT_neBot_of_exists_gt ⟨∞, ENNReal.coe_lt_top⟩ @[instance] theorem nhdsGT_zero_neBot : (𝓝[>] (0 : ℝ≥0∞)).NeBot := nhdsGT_coe_neBot @[instance] theorem nhdsGT_one_neBot : (𝓝[>] (1 : ℝ≥0∞)).NeBot := nhdsGT_coe_neBot @[instance] theorem nhdsGT_nat_neBot (n : ℕ) : (𝓝[>] (n : ℝ≥0∞)).NeBot := nhdsGT_coe_neBot @[instance] theorem nhdsGT_ofNat_neBot (n : ℕ) [n.AtLeastTwo] : (𝓝[>] (OfNat.ofNat n : ℝ≥0∞)).NeBot := nhdsGT_coe_neBot @[instance] theorem nhdsLT_neBot [NeZero x] : (𝓝[<] x).NeBot := nhdsWithin_Iio_self_neBot' ⟨0, NeZero.pos x⟩ /-- Closed intervals `Set.Icc (x - ε) (x + ε)`, `ε ≠ 0`, form a basis of neighborhoods of an extended nonnegative real number `x ≠ ∞`. We use `Set.Icc` instead of `Set.Ioo` because this way the statement works for `x = 0`. -/ theorem hasBasis_nhds_of_ne_top' (xt : x ≠ ∞) : (𝓝 x).HasBasis (· ≠ 0) (fun ε => Icc (x - ε) (x + ε)) := by rcases (zero_le x).eq_or_lt with rfl | x0 · simp_rw [zero_tsub, zero_add, ← bot_eq_zero, Icc_bot, ← bot_lt_iff_ne_bot] exact nhds_bot_basis_Iic · refine (nhds_basis_Ioo' ⟨_, x0⟩ ⟨_, xt.lt_top⟩).to_hasBasis ?_ fun ε ε0 => ?_ · rintro ⟨a, b⟩ ⟨ha, hb⟩ rcases exists_between (tsub_pos_of_lt ha) with ⟨ε, ε0, hε⟩ rcases lt_iff_exists_add_pos_lt.1 hb with ⟨δ, δ0, hδ⟩ refine ⟨min ε δ, (lt_min ε0 (coe_pos.2 δ0)).ne', Icc_subset_Ioo ?_ ?_⟩ · exact lt_tsub_comm.2 ((min_le_left _ _).trans_lt hε) · grw [min_le_right] exact hδ · exact ⟨(x - ε, x + ε), ⟨ENNReal.sub_lt_self xt x0.ne' ε0, lt_add_right xt ε0⟩, Ioo_subset_Icc_self⟩ theorem hasBasis_nhds_of_ne_top (xt : x ≠ ∞) : (𝓝 x).HasBasis (0 < ·) (fun ε => Icc (x - ε) (x + ε)) := by simpa only [pos_iff_ne_zero] using hasBasis_nhds_of_ne_top' xt theorem Icc_mem_nhds (xt : x ≠ ∞) (ε0 : ε ≠ 0) : Icc (x - ε) (x + ε) ∈ 𝓝 x := (hasBasis_nhds_of_ne_top' xt).mem_of_mem ε0 theorem nhds_of_ne_top (xt : x ≠ ∞) : 𝓝 x = ⨅ ε > 0, 𝓟 (Icc (x - ε) (x + ε)) := (hasBasis_nhds_of_ne_top xt).eq_biInf theorem biInf_le_nhds : ∀ x : ℝ≥0∞, ⨅ ε > 0, 𝓟 (Icc (x - ε) (x + ε)) ≤ 𝓝 x | ∞ => iInf₂_le_of_le 1 one_pos <| by simpa only [← coe_one, top_sub_coe, top_add, Icc_self, principal_singleton] using pure_le_nhds _ | (x : ℝ≥0) => (nhds_of_ne_top coe_ne_top).ge protected theorem tendsto_nhds_of_Icc {f : Filter α} {u : α → ℝ≥0∞} {a : ℝ≥0∞} (h : ∀ ε > 0, ∀ᶠ x in f, u x ∈ Icc (a - ε) (a + ε)) : Tendsto u f (𝓝 a) := by refine Tendsto.mono_right ?_ (biInf_le_nhds _) simpa only [tendsto_iInf, tendsto_principal] /-- Characterization of neighborhoods for `ℝ≥0∞` numbers. See also `tendsto_order` for a version with strict inequalities. -/ protected theorem tendsto_nhds {f : Filter α} {u : α → ℝ≥0∞} {a : ℝ≥0∞} (ha : a ≠ ∞) : Tendsto u f (𝓝 a) ↔ ∀ ε > 0, ∀ᶠ x in f, u x ∈ Icc (a - ε) (a + ε) := by simp only [nhds_of_ne_top ha, tendsto_iInf, tendsto_principal] protected theorem tendsto_nhds_zero {f : Filter α} {u : α → ℝ≥0∞} : Tendsto u f (𝓝 0) ↔ ∀ ε > 0, ∀ᶠ x in f, u x ≤ ε := nhds_zero_basis_Iic.tendsto_right_iff theorem tendsto_const_sub_nhds_zero_iff {l : Filter α} {f : α → ℝ≥0∞} {a : ℝ≥0∞} (ha : a ≠ ∞) (hfa : ∀ n, f n ≤ a) : Tendsto (fun n ↦ a - f n) l (𝓝 0) ↔ Tendsto (fun n ↦ f n) l (𝓝 a) := by rw [ENNReal.tendsto_nhds_zero, ENNReal.tendsto_nhds ha] refine ⟨fun h ε hε ↦ ?_, fun h ε hε ↦ ?_⟩ · filter_upwards [h ε hε] with n hn refine ⟨?_, (hfa n).trans (le_add_right le_rfl)⟩ rw [tsub_le_iff_right] at hn ⊢ rwa [add_comm] · filter_upwards [h ε hε] with n hn have hN_left := hn.1 rw [tsub_le_iff_right] at hN_left ⊢ rwa [add_comm] protected theorem tendsto_atTop [Nonempty β] [SemilatticeSup β] {f : β → ℝ≥0∞} {a : ℝ≥0∞} (ha : a ≠ ∞) : Tendsto f atTop (𝓝 a) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, f n ∈ Icc (a - ε) (a + ε) := .trans (atTop_basis.tendsto_iff (hasBasis_nhds_of_ne_top ha)) (by simp only [true_and]; rfl) protected theorem tendsto_atTop_zero [Nonempty β] [SemilatticeSup β] {f : β → ℝ≥0∞} : Tendsto f atTop (𝓝 0) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, f n ≤ ε := .trans (atTop_basis.tendsto_iff nhds_zero_basis_Iic) (by simp only [true_and]; rfl) theorem tendsto_atTop_zero_iff_le_of_antitone {β : Type*} [Nonempty β] [SemilatticeSup β] {f : β → ℝ≥0∞} (hf : Antitone f) : Filter.Tendsto f Filter.atTop (𝓝 0) ↔ ∀ ε, 0 < ε → ∃ n : β, f n ≤ ε := by rw [ENNReal.tendsto_atTop_zero] refine ⟨fun h ↦ fun ε hε ↦ ?_, fun h ↦ fun ε hε ↦ ?_⟩ · obtain ⟨n, hn⟩ := h ε hε exact ⟨n, hn n le_rfl⟩ · obtain ⟨n, hn⟩ := h ε hε exact ⟨n, fun m hm ↦ (hf hm).trans hn⟩ theorem tendsto_atTop_zero_iff_lt_of_antitone {β : Type*} [Nonempty β] [SemilatticeSup β] {f : β → ℝ≥0∞} (hf : Antitone f) : Filter.Tendsto f Filter.atTop (𝓝 0) ↔ ∀ ε, 0 < ε → ∃ n : β, f n < ε := by rw [ENNReal.tendsto_atTop_zero_iff_le_of_antitone hf] constructor <;> intro h ε hε · obtain ⟨n, hn⟩ := h (min 1 (ε / 2)) (lt_min_iff.mpr ⟨zero_lt_one, (ENNReal.div_pos_iff.mpr ⟨ne_of_gt hε, ENNReal.ofNat_ne_top⟩)⟩) · refine ⟨n, hn.trans_lt ?_⟩ by_cases hε_top : ε = ∞ · rw [hε_top] exact (min_le_left _ _).trans_lt ENNReal.one_lt_top refine (min_le_right _ _).trans_lt ?_ rw [ENNReal.div_lt_iff (Or.inr hε.ne') (Or.inr hε_top)] conv_lhs => rw [← mul_one ε] rw [ENNReal.mul_lt_mul_left hε.ne' hε_top] simp · obtain ⟨n, hn⟩ := h ε hε exact ⟨n, hn.le⟩ theorem tendsto_sub : ∀ {a b : ℝ≥0∞}, (a ≠ ∞ ∨ b ≠ ∞) → Tendsto (fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 - p.2) (𝓝 (a, b)) (𝓝 (a - b)) | ∞, ∞, h => by simp only [ne_eq, not_true_eq_false, or_self] at h | ∞, (b : ℝ≥0), _ => by rw [top_sub_coe, tendsto_nhds_top_iff_nnreal] refine fun x => ((lt_mem_nhds <| @coe_lt_top (b + 1 + x)).prod_nhds (ge_mem_nhds <| coe_lt_coe.2 <| lt_add_one b)).mono fun y hy => ?_ grw [lt_tsub_iff_left, hy.2] exact hy.1 | (a : ℝ≥0), ∞, _ => by rw [sub_top] refine (tendsto_pure.2 ?_).mono_right (pure_le_nhds _) exact ((gt_mem_nhds <| coe_lt_coe.2 <| lt_add_one a).prod_nhds (lt_mem_nhds <| @coe_lt_top (a + 1))).mono fun x hx => tsub_eq_zero_iff_le.2 (hx.1.trans hx.2).le | (a : ℝ≥0), (b : ℝ≥0), _ => by simp only [nhds_coe_coe, tendsto_map'_iff, ← ENNReal.coe_sub, Function.comp_def, tendsto_coe] exact continuous_sub.tendsto (a, b) protected theorem Tendsto.sub {f : Filter α} {ma : α → ℝ≥0∞} {mb : α → ℝ≥0∞} {a b : ℝ≥0∞} (hma : Tendsto ma f (𝓝 a)) (hmb : Tendsto mb f (𝓝 b)) (h : a ≠ ∞ ∨ b ≠ ∞) : Tendsto (fun a => ma a - mb a) f (𝓝 (a - b)) := show Tendsto ((fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 - p.2) ∘ fun a => (ma a, mb a)) f (𝓝 (a - b)) from Tendsto.comp (ENNReal.tendsto_sub h) (hma.prodMk_nhds hmb) protected theorem tendsto_mul (ha : a ≠ 0 ∨ b ≠ ∞) (hb : b ≠ 0 ∨ a ≠ ∞) : Tendsto (fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 * p.2) (𝓝 (a, b)) (𝓝 (a * b)) := by have ht : ∀ b : ℝ≥0∞, b ≠ 0 → Tendsto (fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 * p.2) (𝓝 (∞, b)) (𝓝 ∞) := fun b hb => by refine tendsto_nhds_top_iff_nnreal.2 fun n => ?_ rcases lt_iff_exists_nnreal_btwn.1 (pos_iff_ne_zero.2 hb) with ⟨ε, hε, hεb⟩ have : ∀ᶠ c : ℝ≥0∞ × ℝ≥0∞ in 𝓝 (∞, b), ↑n / ↑ε < c.1 ∧ ↑ε < c.2 := (lt_mem_nhds <| div_lt_top coe_ne_top hε.ne').prod_nhds (lt_mem_nhds hεb) refine this.mono fun c hc => ?_ exact (ENNReal.div_mul_cancel hε.ne' coe_ne_top).symm.trans_lt (mul_lt_mul hc.1 hc.2) induction a with | top => simp only [ne_eq, or_false, not_true_eq_false] at hb; simp [ht b hb, top_mul hb] | coe a => induction b with | top => simp only [ne_eq, or_false, not_true_eq_false] at ha simpa [Function.comp_def, mul_comm, mul_top ha] using (ht a ha).comp (continuous_swap.tendsto (ofNNReal a, ∞)) | coe b => simp only [nhds_coe_coe, ← coe_mul, tendsto_coe, tendsto_map'_iff, Function.comp_def, tendsto_mul] protected theorem Tendsto.mul {f : Filter α} {ma : α → ℝ≥0∞} {mb : α → ℝ≥0∞} {a b : ℝ≥0∞} (hma : Tendsto ma f (𝓝 a)) (ha : a ≠ 0 ∨ b ≠ ∞) (hmb : Tendsto mb f (𝓝 b)) (hb : b ≠ 0 ∨ a ≠ ∞) : Tendsto (fun a => ma a * mb a) f (𝓝 (a * b)) := show Tendsto ((fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 * p.2) ∘ fun a => (ma a, mb a)) f (𝓝 (a * b)) from Tendsto.comp (ENNReal.tendsto_mul ha hb) (hma.prodMk_nhds hmb) theorem _root_.ContinuousOn.ennreal_mul [TopologicalSpace α] {f g : α → ℝ≥0∞} {s : Set α} (hf : ContinuousOn f s) (hg : ContinuousOn g s) (h₁ : ∀ x ∈ s, f x ≠ 0 ∨ g x ≠ ∞) (h₂ : ∀ x ∈ s, g x ≠ 0 ∨ f x ≠ ∞) : ContinuousOn (fun x => f x * g x) s := fun x hx => ENNReal.Tendsto.mul (hf x hx) (h₁ x hx) (hg x hx) (h₂ x hx) theorem _root_.Continuous.ennreal_mul [TopologicalSpace α] {f g : α → ℝ≥0∞} (hf : Continuous f) (hg : Continuous g) (h₁ : ∀ x, f x ≠ 0 ∨ g x ≠ ∞) (h₂ : ∀ x, g x ≠ 0 ∨ f x ≠ ∞) : Continuous fun x => f x * g x := continuous_iff_continuousAt.2 fun x => ENNReal.Tendsto.mul hf.continuousAt (h₁ x) hg.continuousAt (h₂ x) protected theorem Tendsto.const_mul {f : Filter α} {m : α → ℝ≥0∞} {a b : ℝ≥0∞} (hm : Tendsto m f (𝓝 b)) (hb : b ≠ 0 ∨ a ≠ ∞) : Tendsto (fun b => a * m b) f (𝓝 (a * b)) := by_cases (fun (this : a = 0) => by simp [this, tendsto_const_nhds]) fun ha : a ≠ 0 => ENNReal.Tendsto.mul tendsto_const_nhds (Or.inl ha) hm hb protected theorem Tendsto.mul_const {f : Filter α} {m : α → ℝ≥0∞} {a b : ℝ≥0∞} (hm : Tendsto m f (𝓝 a)) (ha : a ≠ 0 ∨ b ≠ ∞) : Tendsto (fun x => m x * b) f (𝓝 (a * b)) := by simpa only [mul_comm] using ENNReal.Tendsto.const_mul hm ha theorem tendsto_finset_prod_of_ne_top {ι : Type*} {f : ι → α → ℝ≥0∞} {x : Filter α} {a : ι → ℝ≥0∞} (s : Finset ι) (h : ∀ i ∈ s, Tendsto (f i) x (𝓝 (a i))) (h' : ∀ i ∈ s, a i ≠ ∞) : Tendsto (fun b => ∏ c ∈ s, f c b) x (𝓝 (∏ c ∈ s, a c)) := by classical induction s using Finset.induction with | empty => simp [tendsto_const_nhds] | insert _ _ has IH => simp only [Finset.prod_insert has] apply Tendsto.mul (h _ (Finset.mem_insert_self _ _)) · right exact prod_ne_top fun i hi => h' _ (Finset.mem_insert_of_mem hi) · exact IH (fun i hi => h _ (Finset.mem_insert_of_mem hi)) fun i hi => h' _ (Finset.mem_insert_of_mem hi) · exact Or.inr (h' _ (Finset.mem_insert_self _ _)) protected theorem continuousAt_const_mul {a b : ℝ≥0∞} (h : a ≠ ∞ ∨ b ≠ 0) : ContinuousAt (a * ·) b := Tendsto.const_mul tendsto_id h.symm protected theorem continuousAt_mul_const {a b : ℝ≥0∞} (h : a ≠ ∞ ∨ b ≠ 0) : ContinuousAt (fun x => x * a) b := Tendsto.mul_const tendsto_id h.symm @[fun_prop] protected theorem continuous_const_mul {a : ℝ≥0∞} (ha : a ≠ ∞) : Continuous (a * ·) := continuous_iff_continuousAt.2 fun _ => ENNReal.continuousAt_const_mul (Or.inl ha) @[fun_prop] protected theorem continuous_mul_const {a : ℝ≥0∞} (ha : a ≠ ∞) : Continuous fun x => x * a := continuous_iff_continuousAt.2 fun _ => ENNReal.continuousAt_mul_const (Or.inl ha) @[fun_prop] protected theorem continuous_div_const (c : ℝ≥0∞) (c_ne_zero : c ≠ 0) : Continuous fun x : ℝ≥0∞ => x / c := ENNReal.continuous_mul_const <| ENNReal.inv_ne_top.2 c_ne_zero @[continuity, fun_prop] protected theorem continuous_pow (n : ℕ) : Continuous fun a : ℝ≥0∞ => a ^ n := by induction n with | zero => simp [continuous_const] | succ n IH => simp_rw [pow_add, pow_one, continuous_iff_continuousAt] intro x refine ENNReal.Tendsto.mul (IH.tendsto _) ?_ tendsto_id ?_ <;> by_cases H : x = 0 · simp only [H, zero_ne_top, Ne, or_true, not_false_iff] · exact Or.inl fun h => H (eq_zero_of_pow_eq_zero h) · simp only [H, pow_eq_top_iff, zero_ne_top, false_or, not_true, Ne, not_false_iff, false_and] · simp only [H, true_or, Ne, not_false_iff] theorem continuousOn_sub : ContinuousOn (fun p : ℝ≥0∞ × ℝ≥0∞ => p.fst - p.snd) { p : ℝ≥0∞ × ℝ≥0∞ | p ≠ ⟨∞, ∞⟩ } := by rw [ContinuousOn] rintro ⟨x, y⟩ hp simp only [Ne, Set.mem_setOf_eq, Prod.mk_inj] at hp exact tendsto_nhdsWithin_of_tendsto_nhds (tendsto_sub (not_and_or.mp hp)) theorem continuous_sub_left {a : ℝ≥0∞} (a_ne_top : a ≠ ∞) : Continuous (a - ·) := by change Continuous (Function.uncurry Sub.sub ∘ (a, ·)) refine continuousOn_sub.comp_continuous (.prodMk_right a) fun x => ?_ simp only [a_ne_top, Ne, mem_setOf_eq, Prod.mk_inj, false_and, not_false_iff] theorem continuous_nnreal_sub {a : ℝ≥0} : Continuous fun x : ℝ≥0∞ => (a : ℝ≥0∞) - x := continuous_sub_left coe_ne_top theorem continuousOn_sub_left (a : ℝ≥0∞) : ContinuousOn (a - ·) { x : ℝ≥0∞ | x ≠ ∞ } := by rw [show (fun x => a - x) = (fun p : ℝ≥0∞ × ℝ≥0∞ => p.fst - p.snd) ∘ fun x => ⟨a, x⟩ by rfl] apply continuousOn_sub.comp (by fun_prop) rintro _ h (_ | _) exact h none_eq_top theorem continuous_sub_right (a : ℝ≥0∞) : Continuous fun x : ℝ≥0∞ => x - a := by by_cases a_infty : a = ∞ · simp [a_infty, continuous_const, tsub_eq_zero_of_le] · rw [show (fun x => x - a) = (fun p : ℝ≥0∞ × ℝ≥0∞ => p.fst - p.snd) ∘ fun x => ⟨x, a⟩ by rfl] apply continuousOn_sub.comp_continuous (by fun_prop) intro x simp only [a_infty, Ne, mem_setOf_eq, Prod.mk_inj, and_false, not_false_iff] protected theorem Tendsto.pow {f : Filter α} {m : α → ℝ≥0∞} {a : ℝ≥0∞} {n : ℕ} (hm : Tendsto m f (𝓝 a)) : Tendsto (fun x => m x ^ n) f (𝓝 (a ^ n)) := ((ENNReal.continuous_pow n).tendsto a).comp hm theorem le_of_forall_lt_one_mul_le {x y : ℝ≥0∞} (h : ∀ a < 1, a * x ≤ y) : x ≤ y := by have : Tendsto (· * x) (𝓝[<] 1) (𝓝 (1 * x)) := (ENNReal.continuousAt_mul_const (Or.inr one_ne_zero)).mono_left inf_le_left rw [one_mul] at this exact le_of_tendsto this (eventually_nhdsWithin_iff.2 <| Eventually.of_forall h) theorem inv_limsup {ι : Sort _} {x : ι → ℝ≥0∞} {l : Filter ι} : (limsup x l)⁻¹ = liminf (fun i => (x i)⁻¹) l := OrderIso.invENNReal.limsup_apply theorem inv_liminf {ι : Sort _} {x : ι → ℝ≥0∞} {l : Filter ι} : (liminf x l)⁻¹ = limsup (fun i => (x i)⁻¹) l := OrderIso.invENNReal.liminf_apply @[fun_prop] protected theorem continuous_zpow : ∀ n : ℤ, Continuous (· ^ n : ℝ≥0∞ → ℝ≥0∞) | (n : ℕ) => mod_cast ENNReal.continuous_pow n | .negSucc n => by simpa using (ENNReal.continuous_pow _).inv @[simp] -- TODO: generalize to `[InvolutiveInv _] [ContinuousInv _]` protected theorem tendsto_inv_iff {f : Filter α} {m : α → ℝ≥0∞} {a : ℝ≥0∞} : Tendsto (fun x => (m x)⁻¹) f (𝓝 a⁻¹) ↔ Tendsto m f (𝓝 a) := ⟨fun h => by simpa only [inv_inv] using Tendsto.inv h, Tendsto.inv⟩ protected theorem Tendsto.div {f : Filter α} {ma : α → ℝ≥0∞} {mb : α → ℝ≥0∞} {a b : ℝ≥0∞} (hma : Tendsto ma f (𝓝 a)) (ha : a ≠ 0 ∨ b ≠ 0) (hmb : Tendsto mb f (𝓝 b)) (hb : b ≠ ∞ ∨ a ≠ ∞) : Tendsto (fun a => ma a / mb a) f (𝓝 (a / b)) := by apply Tendsto.mul hma _ (ENNReal.tendsto_inv_iff.2 hmb) _ <;> simp [ha, hb] protected theorem Tendsto.const_div {f : Filter α} {m : α → ℝ≥0∞} {a b : ℝ≥0∞} (hm : Tendsto m f (𝓝 b)) (hb : b ≠ ∞ ∨ a ≠ ∞) : Tendsto (fun b => a / m b) f (𝓝 (a / b)) := by apply Tendsto.const_mul (ENNReal.tendsto_inv_iff.2 hm) simp [hb] protected theorem Tendsto.div_const {f : Filter α} {m : α → ℝ≥0∞} {a b : ℝ≥0∞} (hm : Tendsto m f (𝓝 a)) (ha : a ≠ 0 ∨ b ≠ 0) : Tendsto (fun x => m x / b) f (𝓝 (a / b)) := by apply Tendsto.mul_const hm simp [ha] protected theorem tendsto_inv_nat_nhds_zero : Tendsto (fun n : ℕ => (n : ℝ≥0∞)⁻¹) atTop (𝓝 0) := ENNReal.inv_top ▸ ENNReal.tendsto_inv_iff.2 tendsto_nat_nhds_top protected theorem tendsto_coe_sub {b : ℝ≥0∞} : Tendsto (fun b : ℝ≥0∞ => ↑r - b) (𝓝 b) (𝓝 (↑r - b)) := continuous_nnreal_sub.tendsto _ theorem exists_countable_dense_no_zero_top : ∃ s : Set ℝ≥0∞, s.Countable ∧ Dense s ∧ 0 ∉ s ∧ ∞ ∉ s := by obtain ⟨s, s_count, s_dense, hs⟩ : ∃ s : Set ℝ≥0∞, s.Countable ∧ Dense s ∧ (∀ x, IsBot x → x ∉ s) ∧ ∀ x, IsTop x → x ∉ s := exists_countable_dense_no_bot_top ℝ≥0∞ exact ⟨s, s_count, s_dense, fun h => hs.1 0 (by simp) h, fun h => hs.2 ∞ (by simp) h⟩ end TopologicalSpace section Liminf theorem exists_frequently_lt_of_liminf_ne_top {ι : Type*} {l : Filter ι} {x : ι → ℝ} (hx : liminf (fun n => (Real.nnabs (x n) : ℝ≥0∞)) l ≠ ∞) : ∃ R, ∃ᶠ n in l, x n < R := by by_contra h simp_rw [not_exists, not_frequently, not_lt] at h refine hx (ENNReal.eq_top_of_forall_nnreal_le fun r => le_limsInf_of_le (by isBoundedDefault) ?_) simp only [eventually_map, ENNReal.coe_le_coe] filter_upwards [h r] with i hi using hi.trans (le_abs_self (x i)) theorem exists_frequently_lt_of_liminf_ne_top' {ι : Type*} {l : Filter ι} {x : ι → ℝ} (hx : liminf (fun n => (Real.nnabs (x n) : ℝ≥0∞)) l ≠ ∞) : ∃ R, ∃ᶠ n in l, R < x n := by by_contra h simp_rw [not_exists, not_frequently, not_lt] at h refine hx (ENNReal.eq_top_of_forall_nnreal_le fun r => le_limsInf_of_le (by isBoundedDefault) ?_) simp only [eventually_map, ENNReal.coe_le_coe] filter_upwards [h (-r)] with i hi using (le_neg.1 hi).trans (neg_le_abs _) theorem exists_upcrossings_of_not_bounded_under {ι : Type*} {l : Filter ι} {x : ι → ℝ} (hf : liminf (fun i => (Real.nnabs (x i) : ℝ≥0∞)) l ≠ ∞) (hbdd : ¬IsBoundedUnder (· ≤ ·) l fun i => |x i|) : ∃ a b : ℚ, a < b ∧ (∃ᶠ i in l, x i < a) ∧ ∃ᶠ i in l, ↑b < x i := by rw [isBoundedUnder_le_abs, not_and_or] at hbdd obtain hbdd | hbdd := hbdd · obtain ⟨R, hR⟩ := exists_frequently_lt_of_liminf_ne_top hf obtain ⟨q, hq⟩ := exists_rat_gt R refine ⟨q, q + 1, (lt_add_iff_pos_right _).2 zero_lt_one, ?_, ?_⟩ · refine fun hcon => hR ?_ filter_upwards [hcon] with x hx using not_lt.2 (lt_of_lt_of_le hq (not_lt.1 hx)).le · simp only [IsBoundedUnder, IsBounded, eventually_map, not_exists] at hbdd refine fun hcon => hbdd ↑(q + 1) ?_ filter_upwards [hcon] with x hx using not_lt.1 hx · obtain ⟨R, hR⟩ := exists_frequently_lt_of_liminf_ne_top' hf obtain ⟨q, hq⟩ := exists_rat_lt R refine ⟨q - 1, q, (sub_lt_self_iff _).2 zero_lt_one, ?_, ?_⟩ · simp only [IsBoundedUnder, IsBounded, eventually_map, not_exists] at hbdd refine fun hcon => hbdd ↑(q - 1) ?_ filter_upwards [hcon] with x hx using not_lt.1 hx · refine fun hcon => hR ?_ filter_upwards [hcon] with x hx using not_lt.2 ((not_lt.1 hx).trans hq.le) end Liminf section tsum variable {f g : α → ℝ≥0∞} @[norm_cast] protected theorem hasSum_coe {f : α → ℝ≥0} {r : ℝ≥0} : HasSum (fun a => (f a : ℝ≥0∞)) ↑r ↔ HasSum f r := by simp only [HasSum, ← coe_finset_sum, tendsto_coe] protected theorem tsum_coe_eq {f : α → ℝ≥0} (h : HasSum f r) : (∑' a, (f a : ℝ≥0∞)) = r := (ENNReal.hasSum_coe.2 h).tsum_eq protected theorem coe_tsum {f : α → ℝ≥0} : Summable f → ↑(tsum f) = ∑' a, (f a : ℝ≥0∞) | ⟨r, hr⟩ => by rw [hr.tsum_eq, ENNReal.tsum_coe_eq hr] protected theorem hasSum : HasSum f (⨆ s : Finset α, ∑ a ∈ s, f a) := tendsto_atTop_iSup fun _ _ => Finset.sum_le_sum_of_subset @[simp] protected theorem summable : Summable f := ⟨_, ENNReal.hasSum⟩ macro_rules | `(tactic| gcongr_discharger) => `(tactic| apply ENNReal.summable) theorem tsum_coe_ne_top_iff_summable {f : β → ℝ≥0} : (∑' b, (f b : ℝ≥0∞)) ≠ ∞ ↔ Summable f := by refine ⟨fun h => ?_, fun h => ENNReal.coe_tsum h ▸ ENNReal.coe_ne_top⟩ lift ∑' b, (f b : ℝ≥0∞) to ℝ≥0 using h with a ha refine ⟨a, ENNReal.hasSum_coe.1 ?_⟩ rw [ha] exact ENNReal.summable.hasSum protected theorem tsum_eq_iSup_sum : ∑' a, f a = ⨆ s : Finset α, ∑ a ∈ s, f a := ENNReal.hasSum.tsum_eq protected theorem tsum_eq_iSup_sum' {ι : Type*} (s : ι → Finset α) (hs : ∀ t, ∃ i, t ⊆ s i) : ∑' a, f a = ⨆ i, ∑ a ∈ s i, f a := by rw [ENNReal.tsum_eq_iSup_sum] symm change ⨆ i : ι, (fun t : Finset α => ∑ a ∈ t, f a) (s i) = ⨆ s : Finset α, ∑ a ∈ s, f a exact (Finset.sum_mono_set f).iSup_comp_eq hs protected theorem tsum_sigma {β : α → Type*} (f : ∀ a, β a → ℝ≥0∞) : ∑' p : Σ a, β a, f p.1 p.2 = ∑' (a) (b), f a b := ENNReal.summable.tsum_sigma' fun _ => ENNReal.summable protected theorem tsum_sigma' {β : α → Type*} (f : (Σ a, β a) → ℝ≥0∞) : ∑' p : Σ a, β a, f p = ∑' (a) (b), f ⟨a, b⟩ := ENNReal.summable.tsum_sigma' fun _ => ENNReal.summable protected theorem tsum_biUnion' {ι : Type*} {S : Set ι} {f : α → ENNReal} {t : ι → Set α} (h : S.PairwiseDisjoint t) : ∑' x : ⋃ i ∈ S, t i, f x = ∑' (i : S), ∑' (x : t i), f x := by simp [← ENNReal.tsum_sigma, ← (Set.biUnionEqSigmaOfDisjoint h).tsum_eq] protected theorem tsum_biUnion {ι : Type*} {f : α → ENNReal} {t : ι → Set α} (h : Set.univ.PairwiseDisjoint t) : ∑' x : ⋃ i, t i, f x = ∑' (i) (x : t i), f x := by nth_rw 2 [← tsum_univ] rw [← ENNReal.tsum_biUnion' h, Set.biUnion_univ] protected theorem tsum_prod {f : α → β → ℝ≥0∞} : ∑' p : α × β, f p.1 p.2 = ∑' (a) (b), f a b := ENNReal.summable.tsum_prod' fun _ => ENNReal.summable protected theorem tsum_prod' {f : α × β → ℝ≥0∞} : ∑' p : α × β, f p = ∑' (a) (b), f (a, b) := ENNReal.summable.tsum_prod' fun _ => ENNReal.summable protected theorem tsum_comm {f : α → β → ℝ≥0∞} : ∑' a, ∑' b, f a b = ∑' b, ∑' a, f a b := ENNReal.summable.tsum_comm' (fun _ => ENNReal.summable) fun _ => ENNReal.summable protected theorem tsum_add : ∑' a, (f a + g a) = ∑' a, f a + ∑' a, g a := ENNReal.summable.tsum_add ENNReal.summable protected lemma sum_add_tsum_compl {ι : Type*} (s : Finset ι) (f : ι → ℝ≥0∞) : ∑ i ∈ s, f i + ∑' i : ↥(s : Set ι)ᶜ, f i = ∑' i, f i := by rw [tsum_subtype, sum_eq_tsum_indicator] simp [← ENNReal.tsum_add] protected theorem tsum_le_tsum (h : ∀ a, f a ≤ g a) : ∑' a, f a ≤ ∑' a, g a := ENNReal.summable.tsum_le_tsum h ENNReal.summable protected theorem sum_le_tsum {f : α → ℝ≥0∞} (s : Finset α) : ∑ x ∈ s, f x ≤ ∑' x, f x := ENNReal.summable.sum_le_tsum s (fun _ _ => zero_le _) protected theorem tsum_eq_iSup_nat' {f : ℕ → ℝ≥0∞} {N : ℕ → ℕ} (hN : Tendsto N atTop atTop) : ∑' i : ℕ, f i = ⨆ i : ℕ, ∑ a ∈ Finset.range (N i), f a := ENNReal.tsum_eq_iSup_sum' _ fun t => let ⟨n, hn⟩ := t.exists_nat_subset_range let ⟨k, _, hk⟩ := exists_le_of_tendsto_atTop hN 0 n ⟨k, Finset.Subset.trans hn (Finset.range_mono hk)⟩ protected theorem tsum_eq_iSup_nat {f : ℕ → ℝ≥0∞} : ∑' i : ℕ, f i = ⨆ i : ℕ, ∑ a ∈ Finset.range i, f a := ENNReal.tsum_eq_iSup_sum' _ Finset.exists_nat_subset_range protected theorem tsum_eq_liminf_sum_nat {f : ℕ → ℝ≥0∞} : ∑' i, f i = liminf (fun n => ∑ i ∈ Finset.range n, f i) atTop := ENNReal.summable.hasSum.tendsto_sum_nat.liminf_eq.symm protected theorem tsum_eq_limsup_sum_nat {f : ℕ → ℝ≥0∞} : ∑' i, f i = limsup (fun n => ∑ i ∈ Finset.range n, f i) atTop := ENNReal.summable.hasSum.tendsto_sum_nat.limsup_eq.symm protected theorem le_tsum (a : α) : f a ≤ ∑' a, f a := ENNReal.summable.le_tsum' a @[simp] protected theorem tsum_eq_zero : ∑' i, f i = 0 ↔ ∀ i, f i = 0 := ENNReal.summable.tsum_eq_zero_iff protected theorem tsum_eq_top_of_eq_top : (∃ a, f a = ∞) → ∑' a, f a = ∞ | ⟨a, ha⟩ => top_unique <| ha ▸ ENNReal.le_tsum a protected theorem lt_top_of_tsum_ne_top {a : α → ℝ≥0∞} (tsum_ne_top : ∑' i, a i ≠ ∞) (j : α) : a j < ∞ := by contrapose! tsum_ne_top with h exact ENNReal.tsum_eq_top_of_eq_top ⟨j, top_unique h⟩ @[simp] protected theorem tsum_top [Nonempty α] : ∑' _ : α, ∞ = ∞ := let ⟨a⟩ := ‹Nonempty α› ENNReal.tsum_eq_top_of_eq_top ⟨a, rfl⟩ theorem tsum_const_eq_top_of_ne_zero {α : Type*} [Infinite α] {c : ℝ≥0∞} (hc : c ≠ 0) : ∑' _ : α, c = ∞ := by have A : Tendsto (fun n : ℕ => (n : ℝ≥0∞) * c) atTop (𝓝 (∞ * c)) := by apply ENNReal.Tendsto.mul_const tendsto_nat_nhds_top simp only [true_or, top_ne_zero, Ne, not_false_iff] have B : ∀ n : ℕ, (n : ℝ≥0∞) * c ≤ ∑' _ : α, c := fun n => by rcases Infinite.exists_subset_card_eq α n with ⟨s, hs⟩ simpa [hs] using @ENNReal.sum_le_tsum α (fun _ => c) s simpa [hc] using le_of_tendsto' A B protected theorem ne_top_of_tsum_ne_top (h : ∑' a, f a ≠ ∞) (a : α) : f a ≠ ∞ := fun ha => h <| ENNReal.tsum_eq_top_of_eq_top ⟨a, ha⟩ protected theorem tsum_mul_left : ∑' i, a * f i = a * ∑' i, f i := by by_cases hf : ∀ i, f i = 0 · simp [hf] · rw [← ENNReal.tsum_eq_zero] at hf have : Tendsto (fun s : Finset α => ∑ j ∈ s, a * f j) atTop (𝓝 (a * ∑' i, f i)) := by simp only [← Finset.mul_sum] exact ENNReal.Tendsto.const_mul ENNReal.summable.hasSum (Or.inl hf) exact HasSum.tsum_eq this protected theorem tsum_mul_right : ∑' i, f i * a = (∑' i, f i) * a := by simp [mul_comm, ENNReal.tsum_mul_left] protected theorem tsum_const_smul {R} [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] (a : R) : ∑' i, a • f i = a • ∑' i, f i := by simpa only [smul_one_mul] using @ENNReal.tsum_mul_left _ (a • (1 : ℝ≥0∞)) _ @[simp] theorem tsum_iSup_eq {α : Type*} (a : α) {f : α → ℝ≥0∞} : (∑' b : α, ⨆ _ : a = b, f b) = f a := (tsum_eq_single a fun _ h => by simp [h.symm]).trans <| by simp theorem hasSum_iff_tendsto_nat {f : ℕ → ℝ≥0∞} (r : ℝ≥0∞) : HasSum f r ↔ Tendsto (fun n : ℕ => ∑ i ∈ Finset.range n, f i) atTop (𝓝 r) := by refine ⟨HasSum.tendsto_sum_nat, fun h => ?_⟩ rw [← iSup_eq_of_tendsto _ h, ← ENNReal.tsum_eq_iSup_nat] · exact ENNReal.summable.hasSum · exact fun s t hst => Finset.sum_le_sum_of_subset (Finset.range_subset_range.2 hst) theorem tendsto_nat_tsum (f : ℕ → ℝ≥0∞) : Tendsto (fun n : ℕ => ∑ i ∈ Finset.range n, f i) atTop (𝓝 (∑' n, f n)) := by rw [← hasSum_iff_tendsto_nat] exact ENNReal.summable.hasSum theorem toNNReal_apply_of_tsum_ne_top {α : Type*} {f : α → ℝ≥0∞} (hf : ∑' i, f i ≠ ∞) (x : α) : (((ENNReal.toNNReal ∘ f) x : ℝ≥0) : ℝ≥0∞) = f x := coe_toNNReal <| ENNReal.ne_top_of_tsum_ne_top hf _ theorem summable_toNNReal_of_tsum_ne_top {α : Type*} {f : α → ℝ≥0∞} (hf : ∑' i, f i ≠ ∞) : Summable (ENNReal.toNNReal ∘ f) := by simpa only [← tsum_coe_ne_top_iff_summable, toNNReal_apply_of_tsum_ne_top hf] using hf theorem tendsto_cofinite_zero_of_tsum_ne_top {α} {f : α → ℝ≥0∞} (hf : ∑' x, f x ≠ ∞) : Tendsto f cofinite (𝓝 0) := by have f_ne_top : ∀ n, f n ≠ ∞ := ENNReal.ne_top_of_tsum_ne_top hf have h_f_coe : f = fun n => ((f n).toNNReal : ENNReal) := funext fun n => (coe_toNNReal (f_ne_top n)).symm rw [h_f_coe, ← @coe_zero, tendsto_coe] exact NNReal.tendsto_cofinite_zero_of_summable (summable_toNNReal_of_tsum_ne_top hf) theorem tendsto_atTop_zero_of_tsum_ne_top {f : ℕ → ℝ≥0∞} (hf : ∑' x, f x ≠ ∞) : Tendsto f atTop (𝓝 0) := by rw [← Nat.cofinite_eq_atTop] exact tendsto_cofinite_zero_of_tsum_ne_top hf /-- The sum over the complement of a finset tends to `0` when the finset grows to cover the whole space. This does not need a summability assumption, as otherwise all sums are zero. -/ theorem tendsto_tsum_compl_atTop_zero {α : Type*} {f : α → ℝ≥0∞} (hf : ∑' x, f x ≠ ∞) : Tendsto (fun s : Finset α => ∑' b : { x // x ∉ s }, f b) atTop (𝓝 0) := by lift f to α → ℝ≥0 using ENNReal.ne_top_of_tsum_ne_top hf convert ENNReal.tendsto_coe.2 (NNReal.tendsto_tsum_compl_atTop_zero f) rw [ENNReal.coe_tsum] exact NNReal.summable_comp_injective (tsum_coe_ne_top_iff_summable.1 hf) Subtype.coe_injective protected theorem tsum_apply {ι α : Type*} {f : ι → α → ℝ≥0∞} {x : α} : (∑' i, f i) x = ∑' i, f i x := tsum_apply <| Pi.summable.mpr fun _ => ENNReal.summable theorem tsum_sub {f : ℕ → ℝ≥0∞} {g : ℕ → ℝ≥0∞} (h₁ : ∑' i, g i ≠ ∞) (h₂ : g ≤ f) : ∑' i, (f i - g i) = ∑' i, f i - ∑' i, g i := have : ∀ i, f i - g i + g i = f i := fun i => tsub_add_cancel_of_le (h₂ i) ENNReal.eq_sub_of_add_eq h₁ <| by simp only [← ENNReal.tsum_add, this] theorem tsum_comp_le_tsum_of_injective {f : α → β} (hf : Injective f) (g : β → ℝ≥0∞) : ∑' x, g (f x) ≤ ∑' y, g y := ENNReal.summable.tsum_le_tsum_of_inj f hf (fun _ _ => zero_le _) (fun _ => le_rfl) ENNReal.summable theorem tsum_le_tsum_comp_of_surjective {f : α → β} (hf : Surjective f) (g : β → ℝ≥0∞) : ∑' y, g y ≤ ∑' x, g (f x) := calc ∑' y, g y = ∑' y, g (f (surjInv hf y)) := by simp only [surjInv_eq hf] _ ≤ ∑' x, g (f x) := tsum_comp_le_tsum_of_injective (injective_surjInv hf) _ theorem tsum_mono_subtype (f : α → ℝ≥0∞) {s t : Set α} (h : s ⊆ t) : ∑' x : s, f x ≤ ∑' x : t, f x := tsum_comp_le_tsum_of_injective (inclusion_injective h) _ theorem tsum_iUnion_le_tsum {ι : Type*} (f : α → ℝ≥0∞) (t : ι → Set α) : ∑' x : ⋃ i, t i, f x ≤ ∑' i, ∑' x : t i, f x := calc ∑' x : ⋃ i, t i, f x ≤ ∑' x : Σ i, t i, f x.2 := tsum_le_tsum_comp_of_surjective (sigmaToiUnion_surjective t) _ _ = ∑' i, ∑' x : t i, f x := ENNReal.tsum_sigma' _ theorem tsum_biUnion_le_tsum {ι : Type*} (f : α → ℝ≥0∞) (s : Set ι) (t : ι → Set α) : ∑' x : ⋃ i ∈ s, t i, f x ≤ ∑' i : s, ∑' x : t i, f x := calc ∑' x : ⋃ i ∈ s, t i, f x = ∑' x : ⋃ i : s, t i, f x := tsum_congr_set_coe _ <| by simp _ ≤ ∑' i : s, ∑' x : t i, f x := tsum_iUnion_le_tsum _ _ theorem tsum_biUnion_le {ι : Type*} (f : α → ℝ≥0∞) (s : Finset ι) (t : ι → Set α) : ∑' x : ⋃ i ∈ s, t i, f x ≤ ∑ i ∈ s, ∑' x : t i, f x := (tsum_biUnion_le_tsum f s t).trans_eq (Finset.tsum_subtype s fun i => ∑' x : t i, f x) theorem tsum_iUnion_le {ι : Type*} [Fintype ι] (f : α → ℝ≥0∞) (t : ι → Set α) : ∑' x : ⋃ i, t i, f x ≤ ∑ i, ∑' x : t i, f x := by rw [← tsum_fintype (L := SummationFilter.unconditional _)] exact tsum_iUnion_le_tsum f t theorem tsum_union_le (f : α → ℝ≥0∞) (s t : Set α) : ∑' x : ↑(s ∪ t), f x ≤ ∑' x : s, f x + ∑' x : t, f x := calc ∑' x : ↑(s ∪ t), f x = ∑' x : ⋃ b, cond b s t, f x := tsum_congr_set_coe _ union_eq_iUnion _ ≤ _ := by simpa using tsum_iUnion_le f (cond · s t) open Classical in theorem tsum_eq_add_tsum_ite {f : β → ℝ≥0∞} (b : β) : ∑' x, f x = f b + ∑' x, ite (x = b) 0 (f x) := ENNReal.summable.tsum_eq_add_tsum_ite' b theorem tsum_add_one_eq_top {f : ℕ → ℝ≥0∞} (hf : ∑' n, f n = ∞) (hf0 : f 0 ≠ ∞) : ∑' n, f (n + 1) = ∞ := by rw [tsum_eq_zero_add' ENNReal.summable, add_eq_top] at hf exact hf.resolve_left hf0 /-- A sum of extended nonnegative reals which is finite can have only finitely many terms above any positive threshold. -/ theorem finite_const_le_of_tsum_ne_top {ι : Type*} {a : ι → ℝ≥0∞} (tsum_ne_top : ∑' i, a i ≠ ∞) {ε : ℝ≥0∞} (ε_ne_zero : ε ≠ 0) : { i : ι | ε ≤ a i }.Finite := by by_contra h have := Infinite.to_subtype h refine tsum_ne_top (top_unique ?_) calc ∞ = ∑' _ : { i | ε ≤ a i }, ε := (tsum_const_eq_top_of_ne_zero ε_ne_zero).symm _ ≤ ∑' i, a i := ENNReal.summable.tsum_le_tsum_of_inj (↑) Subtype.val_injective (fun _ _ => zero_le _) (fun i => i.2) ENNReal.summable /-- Markov's inequality for `Finset.card` and `tsum` in `ℝ≥0∞`. -/ theorem finset_card_const_le_le_of_tsum_le {ι : Type*} {a : ι → ℝ≥0∞} {c : ℝ≥0∞} (c_ne_top : c ≠ ∞) (tsum_le_c : ∑' i, a i ≤ c) {ε : ℝ≥0∞} (ε_ne_zero : ε ≠ 0) : ∃ hf : { i : ι | ε ≤ a i }.Finite, #hf.toFinset ≤ c / ε := by have hf : { i : ι | ε ≤ a i }.Finite := finite_const_le_of_tsum_ne_top (ne_top_of_le_ne_top c_ne_top tsum_le_c) ε_ne_zero refine ⟨hf, (ENNReal.le_div_iff_mul_le (.inl ε_ne_zero) (.inr c_ne_top)).2 ?_⟩ calc #hf.toFinset * ε = ∑ _i ∈ hf.toFinset, ε := by rw [Finset.sum_const, nsmul_eq_mul] _ ≤ ∑ i ∈ hf.toFinset, a i := Finset.sum_le_sum fun i => hf.mem_toFinset.1 _ ≤ ∑' i, a i := ENNReal.sum_le_tsum _ _ ≤ c := tsum_le_c theorem tsum_fiberwise (f : β → ℝ≥0∞) (g : β → γ) : ∑' x, ∑' b : g ⁻¹' {x}, f b = ∑' i, f i := by apply HasSum.tsum_eq let equiv := Equiv.sigmaFiberEquiv g apply (equiv.hasSum_iff.mpr ENNReal.summable.hasSum).sigma exact fun _ ↦ ENNReal.summable.hasSum_iff.mpr rfl end tsum theorem tendsto_toReal_iff {ι} {fi : Filter ι} {f : ι → ℝ≥0∞} (hf : ∀ i, f i ≠ ∞) {x : ℝ≥0∞} (hx : x ≠ ∞) : Tendsto (fun n => (f n).toReal) fi (𝓝 x.toReal) ↔ Tendsto f fi (𝓝 x) := by lift f to ι → ℝ≥0 using hf lift x to ℝ≥0 using hx simp [tendsto_coe] theorem tsum_coe_ne_top_iff_summable_coe {f : α → ℝ≥0} : (∑' a, (f a : ℝ≥0∞)) ≠ ∞ ↔ Summable fun a => (f a : ℝ) := by rw [NNReal.summable_coe] exact tsum_coe_ne_top_iff_summable theorem tsum_coe_eq_top_iff_not_summable_coe {f : α → ℝ≥0} : (∑' a, (f a : ℝ≥0∞)) = ∞ ↔ ¬Summable fun a => (f a : ℝ) := tsum_coe_ne_top_iff_summable_coe.not_right theorem hasSum_toReal {f : α → ℝ≥0∞} (hsum : ∑' x, f x ≠ ∞) : HasSum (fun x => (f x).toReal) (∑' x, (f x).toReal) := by lift f to α → ℝ≥0 using ENNReal.ne_top_of_tsum_ne_top hsum simp only [coe_toReal, ← NNReal.coe_tsum, NNReal.hasSum_coe] exact (tsum_coe_ne_top_iff_summable.1 hsum).hasSum theorem summable_toReal {f : α → ℝ≥0∞} (hsum : ∑' x, f x ≠ ∞) : Summable fun x => (f x).toReal := (hasSum_toReal hsum).summable end ENNReal namespace NNReal theorem tsum_eq_toNNReal_tsum {f : β → ℝ≥0} : ∑' b, f b = (∑' b, (f b : ℝ≥0∞)).toNNReal := by by_cases h : Summable f · rw [← ENNReal.coe_tsum h, ENNReal.toNNReal_coe] · have A := tsum_eq_zero_of_not_summable h simp only [← ENNReal.tsum_coe_ne_top_iff_summable, Classical.not_not] at h simp only [h, ENNReal.toNNReal_top, A] /-- Comparison test of convergence of `ℝ≥0`-valued series. -/ theorem exists_le_hasSum_of_le {f g : β → ℝ≥0} {r : ℝ≥0} (hgf : ∀ b, g b ≤ f b) (hfr : HasSum f r) : ∃ p ≤ r, HasSum g p := have : (∑' b, (g b : ℝ≥0∞)) ≤ r := by refine hasSum_le (fun b => ?_) ENNReal.summable.hasSum (ENNReal.hasSum_coe.2 hfr) exact ENNReal.coe_le_coe.2 (hgf _) let ⟨p, Eq, hpr⟩ := ENNReal.le_coe_iff.1 this ⟨p, hpr, ENNReal.hasSum_coe.1 <| Eq ▸ ENNReal.summable.hasSum⟩ /-- Comparison test of convergence of `ℝ≥0`-valued series. -/ theorem summable_of_le {f g : β → ℝ≥0} (hgf : ∀ b, g b ≤ f b) : Summable f → Summable g | ⟨_r, hfr⟩ => let ⟨_p, _, hp⟩ := exists_le_hasSum_of_le hgf hfr hp.summable /-- Summable non-negative functions have countable support -/ theorem _root_.Summable.countable_support_nnreal (f : α → ℝ≥0) (h : Summable f) : f.support.Countable := by rw [← NNReal.summable_coe] at h simpa [support] using h.countable_support /-- A series of non-negative real numbers converges to `r` in the sense of `HasSum` if and only if the sequence of partial sum converges to `r`. -/ theorem hasSum_iff_tendsto_nat {f : ℕ → ℝ≥0} {r : ℝ≥0} : HasSum f r ↔ Tendsto (fun n : ℕ => ∑ i ∈ Finset.range n, f i) atTop (𝓝 r) := by rw [← ENNReal.hasSum_coe, ENNReal.hasSum_iff_tendsto_nat] simp only [← ENNReal.coe_finset_sum] exact ENNReal.tendsto_coe theorem not_summable_iff_tendsto_nat_atTop {f : ℕ → ℝ≥0} : ¬Summable f ↔ Tendsto (fun n : ℕ => ∑ i ∈ Finset.range n, f i) atTop atTop := by constructor · intro h refine ((tendsto_of_monotone ?_).resolve_right h).comp ?_ exacts [Finset.sum_mono_set _, tendsto_finset_range] · rintro hnat ⟨r, hr⟩ exact not_tendsto_nhds_of_tendsto_atTop hnat _ (hasSum_iff_tendsto_nat.1 hr) theorem summable_iff_not_tendsto_nat_atTop {f : ℕ → ℝ≥0} : Summable f ↔ ¬Tendsto (fun n : ℕ => ∑ i ∈ Finset.range n, f i) atTop atTop := by rw [← not_iff_not, Classical.not_not, not_summable_iff_tendsto_nat_atTop] theorem summable_of_sum_range_le {f : ℕ → ℝ≥0} {c : ℝ≥0} (h : ∀ n, ∑ i ∈ Finset.range n, f i ≤ c) : Summable f := by refine summable_iff_not_tendsto_nat_atTop.2 fun H => ?_ rcases exists_lt_of_tendsto_atTop H 0 c with ⟨n, -, hn⟩ exact lt_irrefl _ (hn.trans_le (h n)) theorem tsum_le_of_sum_range_le {f : ℕ → ℝ≥0} {c : ℝ≥0} (h : ∀ n, ∑ i ∈ Finset.range n, f i ≤ c) : ∑' n, f n ≤ c := (summable_of_sum_range_le h).tsum_le_of_sum_range_le h theorem tsum_comp_le_tsum_of_inj {β : Type*} {f : α → ℝ≥0} (hf : Summable f) {i : β → α} (hi : Function.Injective i) : (∑' x, f (i x)) ≤ ∑' x, f x := (summable_comp_injective hf hi).tsum_le_tsum_of_inj i hi (fun _ _ => zero_le _) (fun _ => le_rfl) hf theorem summable_sigma {β : α → Type*} {f : (Σ x, β x) → ℝ≥0} : Summable f ↔ (∀ x, Summable fun y => f ⟨x, y⟩) ∧ Summable fun x => ∑' y, f ⟨x, y⟩ := by constructor · simp only [← NNReal.summable_coe, NNReal.coe_tsum] exact fun h => ⟨h.sigma_factor, h.sigma⟩ · rintro ⟨h₁, h₂⟩ simpa only [← ENNReal.tsum_coe_ne_top_iff_summable, ENNReal.tsum_sigma', ENNReal.coe_tsum (h₁ _)] using h₂ theorem indicator_summable {f : α → ℝ≥0} (hf : Summable f) (s : Set α) : Summable (s.indicator f) := by classical refine NNReal.summable_of_le (fun a => le_trans (le_of_eq (s.indicator_apply f a)) ?_) hf split_ifs · exact le_refl (f a) · exact zero_le_coe theorem tsum_indicator_ne_zero {f : α → ℝ≥0} (hf : Summable f) {s : Set α} (h : ∃ a ∈ s, f a ≠ 0) : (∑' x, (s.indicator f) x) ≠ 0 := fun h' => let ⟨a, ha, hap⟩ := h hap ((Set.indicator_apply_eq_self.mpr (absurd ha)).symm.trans ((indicator_summable hf s).tsum_eq_zero_iff.1 h' a)) open Finset /-- For `f : ℕ → ℝ≥0`, then `∑' k, f (k + i)` tends to zero. This does not require a summability assumption on `f`, as otherwise all sums are zero. -/ theorem tendsto_sum_nat_add (f : ℕ → ℝ≥0) : Tendsto (fun i => ∑' k, f (k + i)) atTop (𝓝 0) := by rw [← tendsto_coe] convert _root_.tendsto_sum_nat_add fun i => (f i : ℝ) norm_cast nonrec theorem hasSum_lt {f g : α → ℝ≥0} {sf sg : ℝ≥0} {i : α} (h : ∀ a : α, f a ≤ g a) (hi : f i < g i) (hf : HasSum f sf) (hg : HasSum g sg) : sf < sg := by have A : ∀ a : α, (f a : ℝ) ≤ g a := fun a => NNReal.coe_le_coe.2 (h a) have : (sf : ℝ) < sg := hasSum_lt A (NNReal.coe_lt_coe.2 hi) (hasSum_coe.2 hf) (hasSum_coe.2 hg) exact NNReal.coe_lt_coe.1 this @[mono] theorem hasSum_strict_mono {f g : α → ℝ≥0} {sf sg : ℝ≥0} (hf : HasSum f sf) (hg : HasSum g sg) (h : f < g) : sf < sg := let ⟨hle, _i, hi⟩ := Pi.lt_def.mp h hasSum_lt hle hi hf hg theorem tsum_lt_tsum {f g : α → ℝ≥0} {i : α} (h : ∀ a : α, f a ≤ g a) (hi : f i < g i) (hg : Summable g) : ∑' n, f n < ∑' n, g n := hasSum_lt h hi (summable_of_le h hg).hasSum hg.hasSum @[mono] theorem tsum_strict_mono {f g : α → ℝ≥0} (hg : Summable g) (h : f < g) : ∑' n, f n < ∑' n, g n := let ⟨hle, _i, hi⟩ := Pi.lt_def.mp h tsum_lt_tsum hle hi hg theorem tsum_pos {g : α → ℝ≥0} (hg : Summable g) (i : α) (hi : 0 < g i) : 0 < ∑' b, g b := by simpa using tsum_lt_tsum (fun a => zero_le _) hi hg open Classical in theorem tsum_eq_add_tsum_ite {f : α → ℝ≥0} (hf : Summable f) (i : α) : ∑' x, f x = f i + ∑' x, ite (x = i) 0 (f x) := by refine (NNReal.summable_of_le (fun i' => ?_) hf).tsum_eq_add_tsum_ite' i rw [Function.update_apply] split_ifs <;> simp only [zero_le', le_rfl] end NNReal namespace ENNReal theorem tsum_toNNReal_eq {f : α → ℝ≥0∞} (hf : ∀ a, f a ≠ ∞) : (∑' a, f a).toNNReal = ∑' a, (f a).toNNReal := (congr_arg ENNReal.toNNReal (tsum_congr fun x => (coe_toNNReal (hf x)).symm)).trans NNReal.tsum_eq_toNNReal_tsum.symm theorem tsum_toReal_eq {f : α → ℝ≥0∞} (hf : ∀ a, f a ≠ ∞) : (∑' a, f a).toReal = ∑' a, (f a).toReal := by simp only [ENNReal.toReal, tsum_toNNReal_eq hf, NNReal.coe_tsum] theorem tendsto_sum_nat_add (f : ℕ → ℝ≥0∞) (hf : ∑' i, f i ≠ ∞) : Tendsto (fun i => ∑' k, f (k + i)) atTop (𝓝 0) := by lift f to ℕ → ℝ≥0 using ENNReal.ne_top_of_tsum_ne_top hf replace hf : Summable f := tsum_coe_ne_top_iff_summable.1 hf simp only [← ENNReal.coe_tsum, NNReal.summable_nat_add _ hf, ← ENNReal.coe_zero] exact mod_cast NNReal.tendsto_sum_nat_add f theorem tsum_le_of_sum_range_le {f : ℕ → ℝ≥0∞} {c : ℝ≥0∞} (h : ∀ n, ∑ i ∈ Finset.range n, f i ≤ c) : ∑' n, f n ≤ c := ENNReal.summable.tsum_le_of_sum_range_le h theorem hasSum_lt {f g : α → ℝ≥0∞} {sf sg : ℝ≥0∞} {i : α} (h : ∀ a : α, f a ≤ g a) (hi : f i < g i) (hsf : sf ≠ ∞) (hf : HasSum f sf) (hg : HasSum g sg) : sf < sg := by by_cases hsg : sg = ∞ · exact hsg.symm ▸ lt_of_le_of_ne le_top hsf · have hg' : ∀ x, g x ≠ ∞ := ENNReal.ne_top_of_tsum_ne_top (hg.tsum_eq.symm ▸ hsg) lift f to α → ℝ≥0 using fun x => ne_of_lt (lt_of_le_of_lt (h x) <| lt_of_le_of_ne le_top (hg' x)) lift g to α → ℝ≥0 using hg' lift sf to ℝ≥0 using hsf lift sg to ℝ≥0 using hsg simp only [coe_le_coe, coe_lt_coe] at h hi ⊢ exact NNReal.hasSum_lt h hi (ENNReal.hasSum_coe.1 hf) (ENNReal.hasSum_coe.1 hg) theorem tsum_lt_tsum {f g : α → ℝ≥0∞} {i : α} (hfi : tsum f ≠ ∞) (h : ∀ a : α, f a ≤ g a) (hi : f i < g i) : ∑' x, f x < ∑' x, g x := hasSum_lt h hi hfi ENNReal.summable.hasSum ENNReal.summable.hasSum end ENNReal theorem tsum_comp_le_tsum_of_inj {β : Type*} {f : α → ℝ} (hf : Summable f) (hn : ∀ a, 0 ≤ f a) {i : β → α} (hi : Function.Injective i) : tsum (f ∘ i) ≤ tsum f := by lift f to α → ℝ≥0 using hn rw [NNReal.summable_coe] at hf simpa only [Function.comp_def, ← NNReal.coe_tsum] using NNReal.tsum_comp_le_tsum_of_inj hf hi /-- Comparison test of convergence of series of non-negative real numbers. -/ theorem Summable.of_nonneg_of_le {f g : β → ℝ} (hg : ∀ b, 0 ≤ g b) (hgf : ∀ b, g b ≤ f b) (hf : Summable f) : Summable g := by lift f to β → ℝ≥0 using fun b => (hg b).trans (hgf b) lift g to β → ℝ≥0 using hg rw [NNReal.summable_coe] at hf ⊢ exact NNReal.summable_of_le (fun b => NNReal.coe_le_coe.1 (hgf b)) hf theorem Summable.toNNReal {f : α → ℝ} (hf : Summable f) : Summable fun n => (f n).toNNReal := by apply NNReal.summable_coe.1 refine .of_nonneg_of_le (fun n => NNReal.coe_nonneg _) (fun n => ?_) hf.abs simp only [le_abs_self, Real.coe_toNNReal', max_le_iff, abs_nonneg, and_self_iff] lemma Summable.tsum_ofReal_lt_top {f : α → ℝ} (hf : Summable f) : ∑' i, .ofReal (f i) < ∞ := by unfold ENNReal.ofReal rw [lt_top_iff_ne_top, ENNReal.tsum_coe_ne_top_iff_summable] exact hf.toNNReal lemma Summable.tsum_ofReal_ne_top {f : α → ℝ} (hf : Summable f) : ∑' i, .ofReal (f i) ≠ ∞ := hf.tsum_ofReal_lt_top.ne /-- Finitely summable non-negative functions have countable support -/ theorem _root_.Summable.countable_support_ennreal {f : α → ℝ≥0∞} (h : ∑' (i : α), f i ≠ ∞) : f.support.Countable := by lift f to α → ℝ≥0 using ENNReal.ne_top_of_tsum_ne_top h simpa [support] using (ENNReal.tsum_coe_ne_top_iff_summable.1 h).countable_support_nnreal /-- A series of non-negative real numbers converges to `r` in the sense of `HasSum` if and only if the sequence of partial sum converges to `r`. -/ theorem hasSum_iff_tendsto_nat_of_nonneg {f : ℕ → ℝ} (hf : ∀ i, 0 ≤ f i) (r : ℝ) : HasSum f r ↔ Tendsto (fun n : ℕ => ∑ i ∈ Finset.range n, f i) atTop (𝓝 r) := by lift f to ℕ → ℝ≥0 using hf simp only [HasSum, ← NNReal.coe_sum, NNReal.tendsto_coe'] exact exists_congr fun hr => NNReal.hasSum_iff_tendsto_nat theorem ENNReal.ofReal_tsum_of_nonneg {f : α → ℝ} (hf_nonneg : ∀ n, 0 ≤ f n) (hf : Summable f) : ENNReal.ofReal (∑' n, f n) = ∑' n, ENNReal.ofReal (f n) := by simp_rw [ENNReal.ofReal, ENNReal.tsum_coe_eq (NNReal.hasSum_real_toNNReal_of_nonneg hf_nonneg hf)] section variable [EMetricSpace β] open ENNReal Filter EMetric /-- In an emetric ball, the distance between points is everywhere finite -/ theorem edist_ne_top_of_mem_ball {a : β} {r : ℝ≥0∞} (x y : ball a r) : edist x.1 y.1 ≠ ∞ := ne_of_lt <| calc edist x y ≤ edist a x + edist a y := edist_triangle_left x.1 y.1 a _ < r + r := by rw [edist_comm a x, edist_comm a y]; exact ENNReal.add_lt_add x.2 y.2 _ ≤ ∞ := le_top /-- Each ball in an extended metric space gives us a metric space, as the edist is everywhere finite. -/ def metricSpaceEMetricBall (a : β) (r : ℝ≥0∞) : MetricSpace (ball a r) := EMetricSpace.toMetricSpace edist_ne_top_of_mem_ball theorem nhds_eq_nhds_emetric_ball (a x : β) (r : ℝ≥0∞) (h : x ∈ ball a r) : 𝓝 x = map ((↑) : ball a r → β) (𝓝 ⟨x, h⟩) := (map_nhds_subtype_coe_eq_nhds _ <| IsOpen.mem_nhds EMetric.isOpen_ball h).symm end section variable [PseudoEMetricSpace α] open EMetric theorem tendsto_iff_edist_tendsto_0 {l : Filter β} {f : β → α} {y : α} : Tendsto f l (𝓝 y) ↔ Tendsto (fun x => edist (f x) y) l (𝓝 0) := by simp only [EMetric.nhds_basis_eball.tendsto_right_iff, EMetric.mem_ball, @tendsto_order ℝ≥0∞ β _ _, forall_prop_of_false ENNReal.not_lt_zero, forall_const, true_and] /-- Yet another metric characterization of Cauchy sequences on integers. This one is often the most efficient. -/ theorem EMetric.cauchySeq_iff_le_tendsto_0 [Nonempty β] [SemilatticeSup β] {s : β → α} : CauchySeq s ↔ ∃ b : β → ℝ≥0∞, (∀ n m N : β, N ≤ n → N ≤ m → edist (s n) (s m) ≤ b N) ∧ Tendsto b atTop (𝓝 0) := EMetric.cauchySeq_iff.trans <| by constructor · intro hs /- `s` is Cauchy sequence. Let `b n` be the diameter of the set `s '' Set.Ici n`. -/ refine ⟨fun N => EMetric.diam (s '' Ici N), fun n m N hn hm => ?_, ?_⟩ -- Prove that it bounds the distances of points in the Cauchy sequence · exact EMetric.edist_le_diam_of_mem (mem_image_of_mem _ hn) (mem_image_of_mem _ hm) -- Prove that it tends to `0`, by using the Cauchy property of `s` · refine ENNReal.tendsto_nhds_zero.2 fun ε ε0 => ?_ rcases hs ε ε0 with ⟨N, hN⟩ refine (eventually_ge_atTop N).mono fun n hn => EMetric.diam_le ?_ rintro _ ⟨k, hk, rfl⟩ _ ⟨l, hl, rfl⟩ exact (hN _ (hn.trans hk) _ (hn.trans hl)).le · rintro ⟨b, ⟨b_bound, b_lim⟩⟩ ε εpos have : ∀ᶠ n in atTop, b n < ε := b_lim.eventually (gt_mem_nhds εpos) rcases this.exists with ⟨N, hN⟩ refine ⟨N, fun m hm n hn => ?_⟩ calc edist (s m) (s n) ≤ b N := b_bound m n N hm hn _ < ε := hN theorem continuous_of_le_add_edist {f : α → ℝ≥0∞} (C : ℝ≥0∞) (hC : C ≠ ∞) (h : ∀ x y, f x ≤ f y + C * edist x y) : Continuous f := by refine continuous_iff_continuousAt.2 fun x => ENNReal.tendsto_nhds_of_Icc fun ε ε0 => ?_ rcases ENNReal.exists_nnreal_pos_mul_lt hC ε0.ne' with ⟨δ, δ0, hδ⟩ rw [mul_comm] at hδ filter_upwards [EMetric.closedBall_mem_nhds x (ENNReal.coe_pos.2 δ0)] with y hy refine ⟨tsub_le_iff_right.2 <| (h x y).trans ?_, (h y x).trans ?_⟩ <;> grw [← hδ.le] <;> gcongr exacts [EMetric.mem_closedBall'.1 hy, EMetric.mem_closedBall.1 hy] theorem continuous_edist : Continuous fun p : α × α => edist p.1 p.2 := by apply continuous_of_le_add_edist 2 (by decide) rintro ⟨x, y⟩ ⟨x', y'⟩ calc edist x y ≤ edist x x' + edist x' y' + edist y' y := edist_triangle4 _ _ _ _ _ = edist x' y' + (edist x x' + edist y y') := by simp only [edist_comm]; ac_rfl _ ≤ edist x' y' + (edist (x, y) (x', y') + edist (x, y) (x', y')) := by gcongr <;> apply_rules [le_max_left, le_max_right] _ = edist x' y' + 2 * edist (x, y) (x', y') := by rw [← mul_two, mul_comm] @[continuity, fun_prop] theorem Continuous.edist [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : Continuous fun b => edist (f b) (g b) := continuous_edist.comp (hf.prodMk hg :) theorem Filter.Tendsto.edist {f g : β → α} {x : Filter β} {a b : α} (hf : Tendsto f x (𝓝 a)) (hg : Tendsto g x (𝓝 b)) : Tendsto (fun x => edist (f x) (g x)) x (𝓝 (edist a b)) := (continuous_edist.tendsto (a, b)).comp (hf.prodMk_nhds hg) /-- If the extended distance between consecutive points of a sequence is estimated by a summable series of `NNReal`s, then the original sequence is a Cauchy sequence. -/ theorem cauchySeq_of_edist_le_of_summable {f : ℕ → α} (d : ℕ → ℝ≥0) (hf : ∀ n, edist (f n) (f n.succ) ≤ d n) (hd : Summable d) : CauchySeq f := by refine EMetric.cauchySeq_iff_NNReal.2 fun ε εpos ↦ ?_ -- Actually we need partial sums of `d` to be a Cauchy sequence. replace hd : CauchySeq fun n : ℕ ↦ ∑ x ∈ Finset.range n, d x := let ⟨_, H⟩ := hd H.tendsto_sum_nat.cauchySeq -- Now we take the same `N` as in one of the definitions of a Cauchy sequence. refine (Metric.cauchySeq_iff'.1 hd ε (NNReal.coe_pos.2 εpos)).imp fun N hN n hn ↦ ?_ specialize hN n hn -- We simplify the known inequality. rw [dist_nndist, NNReal.nndist_eq, ← Finset.sum_range_add_sum_Ico _ hn, add_tsub_cancel_left, NNReal.coe_lt_coe, max_lt_iff] at hN rw [edist_comm] -- Then use `hf` to simplify the goal to the same form. refine lt_of_le_of_lt (edist_le_Ico_sum_of_edist_le hn fun _ _ ↦ hf _) ?_ exact mod_cast hN.1 theorem cauchySeq_of_edist_le_of_tsum_ne_top {f : ℕ → α} (d : ℕ → ℝ≥0∞) (hf : ∀ n, edist (f n) (f n.succ) ≤ d n) (hd : tsum d ≠ ∞) : CauchySeq f := by lift d to ℕ → NNReal using fun i => ENNReal.ne_top_of_tsum_ne_top hd i rw [ENNReal.tsum_coe_ne_top_iff_summable] at hd exact cauchySeq_of_edist_le_of_summable d hf hd theorem EMetric.isClosed_closedBall {a : α} {r : ℝ≥0∞} : IsClosed (closedBall a r) := isClosed_le (continuous_id.edist continuous_const) continuous_const @[simp] theorem EMetric.diam_closure (s : Set α) : diam (closure s) = diam s := by refine le_antisymm (diam_le fun x hx y hy => ?_) (diam_mono subset_closure) have : edist x y ∈ closure (Iic (diam s)) := map_mem_closure₂ continuous_edist hx hy fun x hx y hy => edist_le_diam_of_mem hx hy rwa [closure_Iic] at this @[simp] theorem Metric.diam_closure {α : Type*} [PseudoMetricSpace α] (s : Set α) : Metric.diam (closure s) = diam s := by simp only [Metric.diam, EMetric.diam_closure] theorem isClosed_setOf_lipschitzOnWith {α β} [PseudoEMetricSpace α] [PseudoEMetricSpace β] (K : ℝ≥0) (s : Set α) : IsClosed { f : α → β | LipschitzOnWith K f s } := by simp only [LipschitzOnWith, setOf_forall] refine isClosed_biInter fun x _ => isClosed_biInter fun y _ => isClosed_le ?_ ?_ exacts [.edist (continuous_apply x) (continuous_apply y), continuous_const] theorem isClosed_setOf_lipschitzWith {α β} [PseudoEMetricSpace α] [PseudoEMetricSpace β] (K : ℝ≥0) : IsClosed { f : α → β | LipschitzWith K f } := by simp only [← lipschitzOnWith_univ, isClosed_setOf_lipschitzOnWith] namespace Real /-- For a bounded set `s : Set ℝ`, its `EMetric.diam` is equal to `sSup s - sInf s` reinterpreted as `ℝ≥0∞`. -/ theorem ediam_eq {s : Set ℝ} (h : Bornology.IsBounded s) : EMetric.diam s = ENNReal.ofReal (sSup s - sInf s) := by rcases eq_empty_or_nonempty s with (rfl | hne) · simp refine le_antisymm (Metric.ediam_le_of_forall_dist_le fun x hx y hy => ?_) ?_ · exact Real.dist_le_of_mem_Icc (h.subset_Icc_sInf_sSup hx) (h.subset_Icc_sInf_sSup hy) · apply ENNReal.ofReal_le_of_le_toReal rw [← Metric.diam, ← Metric.diam_closure] calc sSup s - sInf s ≤ dist (sSup s) (sInf s) := le_abs_self _ _ ≤ Metric.diam (closure s) := dist_le_diam_of_mem h.closure (csSup_mem_closure hne h.bddAbove) (csInf_mem_closure hne h.bddBelow) /-- For a bounded set `s : Set ℝ`, its `Metric.diam` is equal to `sSup s - sInf s`. -/ theorem diam_eq {s : Set ℝ} (h : Bornology.IsBounded s) : Metric.diam s = sSup s - sInf s := by rw [Metric.diam, Real.ediam_eq h, ENNReal.toReal_ofReal] exact sub_nonneg.2 (Real.sInf_le_sSup s h.bddBelow h.bddAbove) @[simp] theorem ediam_Ioo (a b : ℝ) : EMetric.diam (Ioo a b) = ENNReal.ofReal (b - a) := by rcases le_or_gt b a with (h | h) · simp [h] · rw [Real.ediam_eq (isBounded_Ioo _ _), csSup_Ioo h, csInf_Ioo h] @[simp] theorem ediam_Icc (a b : ℝ) : EMetric.diam (Icc a b) = ENNReal.ofReal (b - a) := by rcases le_or_gt a b with (h | h) · rw [Real.ediam_eq (isBounded_Icc _ _), csSup_Icc h, csInf_Icc h] · simp [h, h.le] @[simp] theorem ediam_Ico (a b : ℝ) : EMetric.diam (Ico a b) = ENNReal.ofReal (b - a) := le_antisymm (ediam_Icc a b ▸ diam_mono Ico_subset_Icc_self) (ediam_Ioo a b ▸ diam_mono Ioo_subset_Ico_self) @[simp] theorem ediam_Ioc (a b : ℝ) : EMetric.diam (Ioc a b) = ENNReal.ofReal (b - a) := le_antisymm (ediam_Icc a b ▸ diam_mono Ioc_subset_Icc_self) (ediam_Ioo a b ▸ diam_mono Ioo_subset_Ioc_self) theorem diam_Icc {a b : ℝ} (h : a ≤ b) : Metric.diam (Icc a b) = b - a := by simp [Metric.diam, ENNReal.toReal_ofReal (sub_nonneg.2 h)] theorem diam_Ico {a b : ℝ} (h : a ≤ b) : Metric.diam (Ico a b) = b - a := by simp [Metric.diam, ENNReal.toReal_ofReal (sub_nonneg.2 h)] theorem diam_Ioc {a b : ℝ} (h : a ≤ b) : Metric.diam (Ioc a b) = b - a := by simp [Metric.diam, ENNReal.toReal_ofReal (sub_nonneg.2 h)] theorem diam_Ioo {a b : ℝ} (h : a ≤ b) : Metric.diam (Ioo a b) = b - a := by simp [Metric.diam, ENNReal.toReal_ofReal (sub_nonneg.2 h)] end Real /-- If `edist (f n) (f (n+1))` is bounded above by a function `d : ℕ → ℝ≥0∞`, then the distance from `f n` to the limit is bounded by `∑'_{k=n}^∞ d k`. -/ theorem edist_le_tsum_of_edist_le_of_tendsto {f : ℕ → α} (d : ℕ → ℝ≥0∞) (hf : ∀ n, edist (f n) (f n.succ) ≤ d n) {a : α} (ha : Tendsto f atTop (𝓝 a)) (n : ℕ) : edist (f n) a ≤ ∑' m, d (n + m) := by refine le_of_tendsto (tendsto_const_nhds.edist ha) (mem_atTop_sets.2 ⟨n, fun m hnm => ?_⟩) change edist _ _ ≤ _ refine le_trans (edist_le_Ico_sum_of_edist_le hnm fun _ _ => hf _) ?_ rw [Finset.sum_Ico_eq_sum_range] exact ENNReal.summable.sum_le_tsum _ (fun _ _ => zero_le _) /-- If `edist (f n) (f (n+1))` is bounded above by a function `d : ℕ → ℝ≥0∞`, then the distance from `f 0` to the limit is bounded by `∑'_{k=0}^∞ d k`. -/ theorem edist_le_tsum_of_edist_le_of_tendsto₀ {f : ℕ → α} (d : ℕ → ℝ≥0∞) (hf : ∀ n, edist (f n) (f n.succ) ≤ d n) {a : α} (ha : Tendsto f atTop (𝓝 a)) : edist (f 0) a ≤ ∑' m, d m := by simpa using edist_le_tsum_of_edist_le_of_tendsto d hf ha 0 end namespace ENNReal section truncateToReal /-- With truncation level `t`, the truncated cast `ℝ≥0∞ → ℝ` is given by `x ↦ (min t x).toReal`. Unlike `ENNReal.toReal`, this cast is continuous and monotone when `t ≠ ∞`. -/ noncomputable def truncateToReal (t x : ℝ≥0∞) : ℝ := (min t x).toReal lemma truncateToReal_eq_toReal {t x : ℝ≥0∞} (t_ne_top : t ≠ ∞) (x_le : x ≤ t) : truncateToReal t x = x.toReal := by have x_lt_top : x < ∞ := lt_of_le_of_lt x_le t_ne_top.lt_top have obs : min t x ≠ ∞ := by simp_all only [ne_eq, min_eq_top, false_and, not_false_eq_true] exact (ENNReal.toReal_eq_toReal_iff' obs x_lt_top.ne).mpr (min_eq_right x_le) lemma truncateToReal_le {t : ℝ≥0∞} (t_ne_top : t ≠ ∞) {x : ℝ≥0∞} : truncateToReal t x ≤ t.toReal := by rw [truncateToReal] gcongr exacts [t_ne_top, min_le_left t x] lemma truncateToReal_nonneg {t x : ℝ≥0∞} : 0 ≤ truncateToReal t x := toReal_nonneg /-- The truncated cast `ENNReal.truncateToReal t : ℝ≥0∞ → ℝ` is monotone when `t ≠ ∞`. -/ lemma monotone_truncateToReal {t : ℝ≥0∞} (t_ne_top : t ≠ ∞) : Monotone (truncateToReal t) := by intro x y x_le_y simp only [truncateToReal] gcongr exact ne_top_of_le_ne_top t_ne_top (min_le_left _ _) /-- The truncated cast `ENNReal.truncateToReal t : ℝ≥0∞ → ℝ` is continuous when `t ≠ ∞`. -/ @[fun_prop] lemma continuous_truncateToReal {t : ℝ≥0∞} (t_ne_top : t ≠ ∞) : Continuous (truncateToReal t) := by apply continuousOn_toReal.comp_continuous (by fun_prop) simp [t_ne_top] end truncateToReal section LimsupLiminf variable {ι : Type*} {f : Filter ι} {u v : ι → ℝ≥0∞} lemma limsup_sub_const (F : Filter ι) (f : ι → ℝ≥0∞) (c : ℝ≥0∞) : Filter.limsup (fun i ↦ f i - c) F = Filter.limsup f F - c := by rcases F.eq_or_neBot with rfl | _ · simp only [limsup_bot, bot_eq_zero', zero_le, tsub_eq_zero_of_le] · exact (Monotone.map_limsSup_of_continuousAt (F := F.map f) (f := fun (x : ℝ≥0∞) ↦ x - c) (fun _ _ h ↦ tsub_le_tsub_right h c) (continuous_sub_right c).continuousAt).symm lemma liminf_sub_const (F : Filter ι) [NeBot F] (f : ι → ℝ≥0∞) (c : ℝ≥0∞) : Filter.liminf (fun i ↦ f i - c) F = Filter.liminf f F - c := (Monotone.map_limsInf_of_continuousAt (F := F.map f) (f := fun (x : ℝ≥0∞) ↦ x - c) (fun _ _ h ↦ tsub_le_tsub_right h c) (continuous_sub_right c).continuousAt).symm lemma limsup_const_sub (F : Filter ι) (f : ι → ℝ≥0∞) {c : ℝ≥0∞} (c_ne_top : c ≠ ∞) : Filter.limsup (fun i ↦ c - f i) F = c - Filter.liminf f F := by rcases F.eq_or_neBot with rfl | _ · simp only [limsup_bot, bot_eq_zero', liminf_bot, le_top, tsub_eq_zero_of_le] · exact (Antitone.map_limsInf_of_continuousAt (F := F.map f) (f := fun (x : ℝ≥0∞) ↦ c - x) (fun _ _ h ↦ tsub_le_tsub_left h c) (continuous_sub_left c_ne_top).continuousAt).symm lemma liminf_const_sub (F : Filter ι) [NeBot F] (f : ι → ℝ≥0∞) {c : ℝ≥0∞} (c_ne_top : c ≠ ∞) : Filter.liminf (fun i ↦ c - f i) F = c - Filter.limsup f F := (Antitone.map_limsSup_of_continuousAt (F := F.map f) (f := fun (x : ℝ≥0∞) ↦ c - x) (fun _ _ h ↦ tsub_le_tsub_left h c) (continuous_sub_left c_ne_top).continuousAt).symm lemma le_limsup_mul : limsup u f * liminf v f ≤ limsup (u * v) f := mul_le_of_forall_lt fun a a_u b b_v ↦ (le_limsup_iff).2 fun c c_ab ↦ Frequently.mono (Frequently.and_eventually ((frequently_lt_of_lt_limsup) a_u) ((eventually_lt_of_lt_liminf) b_v)) fun _ ab_x ↦ c_ab.trans (mul_lt_mul ab_x.1 ab_x.2) /-- See also `ENNReal.limsup_mul_le`. -/ lemma limsup_mul_le' (h : limsup u f ≠ 0 ∨ limsup v f ≠ ∞) (h' : limsup u f ≠ ∞ ∨ limsup v f ≠ 0) : limsup (u * v) f ≤ limsup u f * limsup v f := by refine le_mul_of_forall_lt h h' fun a a_u b b_v ↦ (limsup_le_iff).2 fun c c_ab ↦ ?_ filter_upwards [eventually_lt_of_limsup_lt a_u, eventually_lt_of_limsup_lt b_v] with x a_x b_x exact (mul_lt_mul a_x b_x).trans c_ab lemma le_liminf_mul : liminf u f * liminf v f ≤ liminf (u * v) f := by refine mul_le_of_forall_lt fun a a_u b b_v ↦ (le_liminf_iff).2 fun c c_ab ↦ ?_ filter_upwards [eventually_lt_of_lt_liminf a_u, eventually_lt_of_lt_liminf b_v] with x a_x b_x exact c_ab.trans (mul_lt_mul a_x b_x) lemma liminf_mul_le (h : limsup u f ≠ 0 ∨ liminf v f ≠ ∞) (h' : limsup u f ≠ ∞ ∨ liminf v f ≠ 0) : liminf (u * v) f ≤ limsup u f * liminf v f := le_mul_of_forall_lt h h' fun a a_u b b_v ↦ (liminf_le_iff).2 fun c c_ab ↦ Frequently.mono (((frequently_lt_of_liminf_lt) b_v).and_eventually ((eventually_lt_of_limsup_lt) a_u)) fun _ ab_x ↦ (mul_lt_mul ab_x.2 ab_x.1).trans c_ab /-- If `u : ι → ℝ≥0∞` is bounded, then we have `liminf (toReal ∘ u) = toReal (liminf u)`. -/ lemma liminf_toReal_eq [NeBot f] {b : ℝ≥0∞} (b_ne_top : b ≠ ∞) (le_b : ∀ᶠ i in f, u i ≤ b) : f.liminf (fun i ↦ (u i).toReal) = (f.liminf u).toReal := by have liminf_le : f.liminf u ≤ b := by apply liminf_le_of_le ⟨0, by simp⟩ intro y h obtain ⟨i, hi⟩ := (Eventually.and h le_b).exists exact hi.1.trans hi.2 have aux : ∀ᶠ i in f, (u i).toReal = ENNReal.truncateToReal b (u i) := by filter_upwards [le_b] with i i_le_b simp only [truncateToReal_eq_toReal b_ne_top i_le_b] have aux' : (f.liminf u).toReal = ENNReal.truncateToReal b (f.liminf u) := by rw [truncateToReal_eq_toReal b_ne_top liminf_le] simp_rw [liminf_congr aux, aux'] have key := Monotone.map_liminf_of_continuousAt (F := f) (monotone_truncateToReal b_ne_top) u (continuous_truncateToReal b_ne_top).continuousAt (IsBoundedUnder.isCoboundedUnder_ge ⟨b, by simpa only [eventually_map] using le_b⟩) ⟨0, Eventually.of_forall (by simp)⟩ rw [key] rfl /-- If `u : ι → ℝ≥0∞` is bounded, then we have `liminf (toReal ∘ u) = toReal (liminf u)`. -/ lemma limsup_toReal_eq [NeBot f] {b : ℝ≥0∞} (b_ne_top : b ≠ ∞) (le_b : ∀ᶠ i in f, u i ≤ b) : f.limsup (fun i ↦ (u i).toReal) = (f.limsup u).toReal := by have aux : ∀ᶠ i in f, (u i).toReal = ENNReal.truncateToReal b (u i) := by filter_upwards [le_b] with i i_le_b simp only [truncateToReal_eq_toReal b_ne_top i_le_b] have aux' : (f.limsup u).toReal = ENNReal.truncateToReal b (f.limsup u) := by rw [truncateToReal_eq_toReal b_ne_top (limsup_le_of_le ⟨0, by simp⟩ le_b)] simp_rw [limsup_congr aux, aux'] have key := Monotone.map_limsup_of_continuousAt (F := f) (monotone_truncateToReal b_ne_top) u (continuous_truncateToReal b_ne_top).continuousAt ⟨b, by simpa only [eventually_map] using le_b⟩ (IsBoundedUnder.isCoboundedUnder_le ⟨0, Eventually.of_forall (by simp)⟩) rw [key] rfl @[simp, norm_cast] lemma ofNNReal_limsup {u : ι → ℝ≥0} (hf : f.IsBoundedUnder (· ≤ ·) u) : limsup u f = limsup (fun i ↦ (u i : ℝ≥0∞)) f := by refine eq_of_forall_nnreal_le_iff fun r ↦ ?_ rw [coe_le_coe, le_limsup_iff, le_limsup_iff] simp [forall_ennreal] @[simp, norm_cast] lemma ofNNReal_liminf {u : ι → ℝ≥0} (hf : f.IsCoboundedUnder (· ≥ ·) u) : liminf u f = liminf (fun i ↦ (u i : ℝ≥0∞)) f := by refine eq_of_forall_nnreal_le_iff fun r ↦ ?_ rw [coe_le_coe, le_liminf_iff, le_liminf_iff] simp [forall_ennreal] theorem liminf_add_of_right_tendsto_zero {u : Filter ι} {g : ι → ℝ≥0∞} (hg : u.Tendsto g (𝓝 0)) (f : ι → ℝ≥0∞) : u.liminf (f + g) = u.liminf f := by refine le_antisymm ?_ <| liminf_le_liminf <| .of_forall <| by simp refine liminf_le_of_le (by isBoundedDefault) fun b hb ↦ ?_ rw [Filter.le_liminf_iff'] rintro a hab filter_upwards [hb, ENNReal.tendsto_nhds_zero.1 hg _ <| lt_min (tsub_pos_of_lt hab) one_pos] with i hfg hg exact ENNReal.le_of_add_le_add_right (hg.trans_lt <| by simp).ne <| (add_le_of_le_tsub_left_of_le hab.le <| hg.trans <| min_le_left ..).trans hfg theorem liminf_add_of_left_tendsto_zero {u : Filter ι} {f : ι → ℝ≥0∞} (hf : u.Tendsto f (𝓝 0)) (g : ι → ℝ≥0∞) : u.liminf (f + g) = u.liminf g := by rw [add_comm, liminf_add_of_right_tendsto_zero hf] theorem limsup_add_of_right_tendsto_zero {u : Filter ι} {g : ι → ℝ≥0∞} (hg : u.Tendsto g (𝓝 0)) (f : ι → ℝ≥0∞) : u.limsup (f + g) = u.limsup f := by refine le_antisymm ?_ <| limsup_le_limsup <| .of_forall <| by simp refine le_limsup_of_le (by isBoundedDefault) fun b hb ↦ ?_ rw [Filter.limsup_le_iff'] rintro a hba filter_upwards [hb, ENNReal.tendsto_nhds_zero.1 hg _ <| tsub_pos_of_lt hba] with i hf hg calc f i + g i _ ≤ b + g i := by gcongr _ ≤ a := add_le_of_le_tsub_left_of_le hba.le hg theorem limsup_add_of_left_tendsto_zero {u : Filter ι} {f : ι → ℝ≥0∞} (hf : u.Tendsto f (𝓝 0)) (g : ι → ℝ≥0∞) : u.limsup (f + g) = u.limsup g := by rw [add_comm, limsup_add_of_right_tendsto_zero hf] end LimsupLiminf end ENNReal -- namespace
.lake/packages/mathlib/Mathlib/Topology/Instances/AddCircle/Defs.lean
import Mathlib.Algebra.Order.ToIntervalMod import Mathlib.Algebra.Ring.AddAut import Mathlib.Data.Nat.Totient import Mathlib.GroupTheory.Divisible import Mathlib.Topology.Algebra.IsUniformGroup.Basic import Mathlib.Topology.Algebra.Order.Field import Mathlib.Topology.IsLocalHomeomorph import Mathlib.Topology.Order.T5 /-! # The additive circle We define the additive circle `AddCircle p` as the quotient `𝕜 ⧸ (ℤ ∙ p)` for some period `p : 𝕜`. See also `Circle` and `Real.angle`. For the normed group structure on `AddCircle`, see `AddCircle.NormedAddCommGroup` in a later file. ## Main definitions and results: * `AddCircle`: the additive circle `𝕜 ⧸ (ℤ ∙ p)` for some period `p : 𝕜` * `UnitAddCircle`: the special case `ℝ ⧸ ℤ` * `AddCircle.equivAddCircle`: the rescaling equivalence `AddCircle p ≃+ AddCircle q` * `AddCircle.equivIco` and `AddCircle.equivIoc`: the natural equivalences `AddCircle p ≃ Ico a (a + p)` and `AddCircle p ≃ Ioc a (a + p)` * `AddCircle.addOrderOf_div_of_gcd_eq_one`: rational points have finite order * `AddCircle.exists_gcd_eq_one_of_isOfFinAddOrder`: finite-order points are rational * `AddCircle.homeoIccQuot`: the natural topological equivalence between `AddCircle p` and `Icc a (a + p)` with its endpoints identified. * `AddCircle.liftIco_continuous` and `AddCircle.liftIoc_continuous`: if `f : ℝ → B` is continuous, and `f a = f (a + p)` for some `a`, then there is a continuous function `AddCircle p → B` which agrees with `f` on `Icc a (a + p)`. ## Implementation notes: Although the most important case is `𝕜 = ℝ` we wish to support other types of scalars, such as the rational circle `AddCircle (1 : ℚ)`, and so we set things up more generally. ## TODO * Link with periodicity * Lie group structure * Exponential equivalence to `Circle` -/ noncomputable section open AddCommGroup Set Function AddSubgroup TopologicalSpace open Topology variable {𝕜 B : Type*} section Continuity variable [AddCommGroup 𝕜] [LinearOrder 𝕜] [IsOrderedAddMonoid 𝕜] [Archimedean 𝕜] [TopologicalSpace 𝕜] [OrderTopology 𝕜] {p : 𝕜} (hp : 0 < p) (a x : 𝕜) theorem continuous_right_toIcoMod : ContinuousWithinAt (toIcoMod hp a) (Ici x) x := by intro s h rw [Filter.mem_map, mem_nhdsWithin_iff_exists_mem_nhds_inter] haveI : Nontrivial 𝕜 := ⟨⟨0, p, hp.ne⟩⟩ simp_rw [mem_nhds_iff_exists_Ioo_subset] at h ⊢ obtain ⟨l, u, hxI, hIs⟩ := h let d := toIcoDiv hp a x • p have hd := toIcoMod_mem_Ico hp a x simp_rw [subset_def, mem_inter_iff] refine ⟨_, ⟨l + d, min (a + p) u + d, ?_, fun x => id⟩, fun y => ?_⟩ <;> simp_rw [← sub_mem_Ioo_iff_left, mem_Ioo, lt_min_iff] · exact ⟨hxI.1, hd.2, hxI.2⟩ · rintro ⟨h, h'⟩ apply hIs rw [← toIcoMod_sub_zsmul, (toIcoMod_eq_self _).2] exacts [⟨h.1, h.2.2⟩, ⟨hd.1.trans (sub_le_sub_right h' _), h.2.1⟩] theorem continuous_left_toIocMod : ContinuousWithinAt (toIocMod hp a) (Iic x) x := by rw [(funext fun y => Eq.trans (by rw [neg_neg]) <| toIocMod_neg _ _ _ : toIocMod hp a = (fun x => p - x) ∘ toIcoMod hp (-a) ∘ Neg.neg)] exact (continuous_sub_left _).continuousAt.comp_continuousWithinAt <| (continuous_right_toIcoMod _ _ _).comp continuous_neg.continuousWithinAt fun y => neg_le_neg variable {x} theorem toIcoMod_eventuallyEq_toIocMod (hx : (x : 𝕜 ⧸ zmultiples p) ≠ a) : toIcoMod hp a =ᶠ[𝓝 x] toIocMod hp a := IsOpen.mem_nhds (by rw [Ico_eq_locus_Ioc_eq_iUnion_Ioo] exact isOpen_iUnion fun i => isOpen_Ioo) <| (not_modEq_iff_toIcoMod_eq_toIocMod hp).1 <| not_modEq_iff_ne_mod_zmultiples.2 hx.symm theorem continuousAt_toIcoMod (hx : (x : 𝕜 ⧸ zmultiples p) ≠ a) : ContinuousAt (toIcoMod hp a) x := let h := toIcoMod_eventuallyEq_toIocMod hp a hx continuousAt_iff_continuous_left_right.2 <| ⟨(continuous_left_toIocMod hp a x).congr_of_eventuallyEq (h.filter_mono nhdsWithin_le_nhds) h.eq_of_nhds, continuous_right_toIcoMod hp a x⟩ theorem continuousAt_toIocMod (hx : (x : 𝕜 ⧸ zmultiples p) ≠ a) : ContinuousAt (toIocMod hp a) x := let h := toIcoMod_eventuallyEq_toIocMod hp a hx continuousAt_iff_continuous_left_right.2 <| ⟨continuous_left_toIocMod hp a x, (continuous_right_toIcoMod hp a x).congr_of_eventuallyEq (h.symm.filter_mono nhdsWithin_le_nhds) h.symm.eq_of_nhds⟩ end Continuity /-- The "additive circle": `𝕜 ⧸ (ℤ ∙ p)`. See also `Circle` and `Real.angle`. -/ abbrev AddCircle [AddCommGroup 𝕜] (p : 𝕜) := 𝕜 ⧸ zmultiples p namespace AddCircle section LinearOrderedAddCommGroup variable [AddCommGroup 𝕜] (p : 𝕜) theorem coe_nsmul {n : ℕ} {x : 𝕜} : (↑(n • x) : AddCircle p) = n • (x : AddCircle p) := rfl theorem coe_zsmul {n : ℤ} {x : 𝕜} : (↑(n • x) : AddCircle p) = n • (x : AddCircle p) := rfl theorem coe_add (x y : 𝕜) : (↑(x + y) : AddCircle p) = (x : AddCircle p) + (y : AddCircle p) := rfl theorem coe_sub (x y : 𝕜) : (↑(x - y) : AddCircle p) = (x : AddCircle p) - (y : AddCircle p) := rfl theorem coe_neg {x : 𝕜} : (↑(-x) : AddCircle p) = -(x : AddCircle p) := rfl @[norm_cast] theorem coe_zero : ↑(0 : 𝕜) = (0 : AddCircle p) := rfl theorem coe_eq_zero_iff {x : 𝕜} : (x : AddCircle p) = 0 ↔ ∃ n : ℤ, n • p = x := by simp [AddSubgroup.mem_zmultiples_iff] theorem coe_period : (p : AddCircle p) = 0 := (QuotientAddGroup.eq_zero_iff p).2 <| mem_zmultiples p theorem coe_add_period (x : 𝕜) : ((x + p : 𝕜) : AddCircle p) = x := by rw [coe_add, ← eq_sub_iff_add_eq', sub_self, coe_period] @[continuity, nolint unusedArguments] protected theorem continuous_mk' [TopologicalSpace 𝕜] : Continuous (QuotientAddGroup.mk' (zmultiples p) : 𝕜 → AddCircle p) := continuous_coinduced_rng variable [LinearOrder 𝕜] [IsOrderedAddMonoid 𝕜] theorem coe_eq_zero_of_pos_iff (hp : 0 < p) {x : 𝕜} (hx : 0 < x) : (x : AddCircle p) = 0 ↔ ∃ n : ℕ, n • p = x := by rw [coe_eq_zero_iff] constructor <;> rintro ⟨n, rfl⟩ · replace hx : 0 < n := by contrapose! hx simpa only [← neg_nonneg, ← zsmul_neg, zsmul_neg'] using zsmul_nonneg hp.le (neg_nonneg.2 hx) exact ⟨n.toNat, by rw [← natCast_zsmul, Int.toNat_of_nonneg hx.le]⟩ · exact ⟨(n : ℤ), by simp⟩ variable [hp : Fact (0 < p)] (a : 𝕜) [Archimedean 𝕜] /-- The equivalence between `AddCircle p` and the half-open interval `[a, a + p)`, whose inverse is the natural quotient map. -/ def equivIco : AddCircle p ≃ Ico a (a + p) := QuotientAddGroup.equivIcoMod hp.out a /-- The equivalence between `AddCircle p` and the half-open interval `(a, a + p]`, whose inverse is the natural quotient map. -/ def equivIoc : AddCircle p ≃ Ioc a (a + p) := QuotientAddGroup.equivIocMod hp.out a /-- Given a function on `𝕜`, return the unique function on `AddCircle p` agreeing with `f` on `[a, a + p)`. -/ def liftIco (f : 𝕜 → B) : AddCircle p → B := restrict _ f ∘ AddCircle.equivIco p a /-- Given a function on `𝕜`, return the unique function on `AddCircle p` agreeing with `f` on `(a, a + p]`. -/ def liftIoc (f : 𝕜 → B) : AddCircle p → B := restrict _ f ∘ AddCircle.equivIoc p a variable {p a} theorem equivIco_coe_eq {x : 𝕜} (hx : x ∈ Ico a (a + p)) : (equivIco p a) x = ⟨x, hx⟩ := by rw [Equiv.apply_eq_iff_eq_symm_apply, equivIco, QuotientAddGroup.equivIcoMod_symm_apply] theorem equivIoc_coe_eq {x : 𝕜} (hx : x ∈ Ioc a (a + p)) : (equivIoc p a) x = ⟨x, hx⟩ := by rw [Equiv.apply_eq_iff_eq_symm_apply, equivIoc, QuotientAddGroup.equivIocMod_symm_apply] theorem coe_eq_coe_iff_of_mem_Ico {x y : 𝕜} (hx : x ∈ Ico a (a + p)) (hy : y ∈ Ico a (a + p)) : (x : AddCircle p) = y ↔ x = y := by refine ⟨fun h => ?_, by tauto⟩ suffices (⟨x, hx⟩ : Ico a (a + p)) = ⟨y, hy⟩ by exact Subtype.mk.inj this apply_fun equivIco p a at h rw [← (equivIco p a).right_inv ⟨x, hx⟩, ← (equivIco p a).right_inv ⟨y, hy⟩] exact h theorem liftIco_coe_apply {f : 𝕜 → B} {x : 𝕜} (hx : x ∈ Ico a (a + p)) : liftIco p a f ↑x = f x := by simp [liftIco, equivIco_coe_eq hx] theorem liftIoc_coe_apply {f : 𝕜 → B} {x : 𝕜} (hx : x ∈ Ioc a (a + p)) : liftIoc p a f ↑x = f x := by simp [liftIoc, equivIoc_coe_eq hx] lemma liftIco_comp_apply {α β : Type*} {f : 𝕜 → α} {g : α → β} {a : 𝕜} {x : AddCircle p} : liftIco p a (g ∘ f) x = g (liftIco p a f x) := rfl lemma liftIoc_comp_apply {α β : Type*} {f : 𝕜 → α} {g : α → β} {a : 𝕜} {x : AddCircle p} : liftIoc p a (g ∘ f) x = g (liftIoc p a f x) := rfl lemma eq_coe_Ico (a : AddCircle p) : ∃ b, b ∈ Ico 0 p ∧ ↑b = a := by let b := QuotientAddGroup.equivIcoMod hp.out 0 a exact ⟨b.1, by simpa only [zero_add] using b.2, (QuotientAddGroup.equivIcoMod hp.out 0).symm_apply_apply a⟩ lemma coe_eq_zero_iff_of_mem_Ico (ha : a ∈ Ico 0 p) : (a : AddCircle p) = 0 ↔ a = 0 := by have h0 : 0 ∈ Ico 0 (0 + p) := by simpa [zero_add, left_mem_Ico] using hp.out have ha' : a ∈ Ico 0 (0 + p) := by rwa [zero_add] rw [← AddCircle.coe_eq_coe_iff_of_mem_Ico ha' h0, QuotientAddGroup.mk_zero] variable (p a) section Continuity variable [TopologicalSpace 𝕜] @[continuity] theorem continuous_equivIco_symm : Continuous (equivIco p a).symm := continuous_quotient_mk'.comp continuous_subtype_val @[continuity] theorem continuous_equivIoc_symm : Continuous (equivIoc p a).symm := continuous_quotient_mk'.comp continuous_subtype_val variable [OrderTopology 𝕜] {x : AddCircle p} theorem continuousAt_equivIco (hx : x ≠ a) : ContinuousAt (equivIco p a) x := by induction x using QuotientAddGroup.induction_on rw [ContinuousAt, Filter.Tendsto, QuotientAddGroup.nhds_eq, Filter.map_map] exact (continuousAt_toIcoMod hp.out a hx).codRestrict _ theorem continuousAt_equivIoc (hx : x ≠ a) : ContinuousAt (equivIoc p a) x := by induction x using QuotientAddGroup.induction_on rw [ContinuousAt, Filter.Tendsto, QuotientAddGroup.nhds_eq, Filter.map_map] exact (continuousAt_toIocMod hp.out a hx).codRestrict _ /-- The quotient map `𝕜 → AddCircle p` as an open partial homeomorphism. -/ @[simps] def openPartialHomeomorphCoe [DiscreteTopology (zmultiples p)] : OpenPartialHomeomorph 𝕜 (AddCircle p) where toFun := (↑) invFun := fun x ↦ equivIco p a x source := Ioo a (a + p) target := {↑a}ᶜ map_source' := by intro x hx hx' exact hx.1.ne' ((coe_eq_coe_iff_of_mem_Ico (Ioo_subset_Ico_self hx) (left_mem_Ico.mpr (lt_add_of_pos_right a hp.out))).mp hx') map_target' := by intro x hx exact (eq_left_or_mem_Ioo_of_mem_Ico (equivIco p a x).2).resolve_left (hx ∘ ((equivIco p a).symm_apply_apply x).symm.trans ∘ congrArg _) left_inv' := fun x hx ↦ congrArg _ ((equivIco p a).apply_symm_apply ⟨x, Ioo_subset_Ico_self hx⟩) right_inv' := fun x _ ↦ (equivIco p a).symm_apply_apply x open_source := isOpen_Ioo open_target := isOpen_compl_singleton continuousOn_toFun := (AddCircle.continuous_mk' p).continuousOn continuousOn_invFun := by exact continuousOn_of_forall_continuousAt (fun _ ↦ continuousAt_subtype_val.comp ∘ continuousAt_equivIco p a) @[deprecated (since := "2025-08-29")] noncomputable alias partialHomeomorphCoe := openPartialHomeomorphCoe lemma isLocalHomeomorph_coe [DiscreteTopology (zmultiples p)] [DenselyOrdered 𝕜] : IsLocalHomeomorph ((↑) : 𝕜 → AddCircle p) := by intro a obtain ⟨b, hb1, hb2⟩ := exists_between (sub_lt_self a hp.out) exact ⟨openPartialHomeomorphCoe p b, ⟨hb2, lt_add_of_sub_right_lt hb1⟩, rfl⟩ end Continuity /-- The image of the closed-open interval `[a, a + p)` under the quotient map `𝕜 → AddCircle p` is the entire space. -/ @[simp] theorem coe_image_Ico_eq : ((↑) : 𝕜 → AddCircle p) '' Ico a (a + p) = univ := by rw [image_eq_range] exact (equivIco p a).symm.range_eq_univ /-- The image of the closed-open interval `[a, a + p)` under the quotient map `𝕜 → AddCircle p` is the entire space. -/ @[simp] theorem coe_image_Ioc_eq : ((↑) : 𝕜 → AddCircle p) '' Ioc a (a + p) = univ := by rw [image_eq_range] exact (equivIoc p a).symm.range_eq_univ /-- The image of the closed interval `[0, p]` under the quotient map `𝕜 → AddCircle p` is the entire space. -/ @[simp] theorem coe_image_Icc_eq : ((↑) : 𝕜 → AddCircle p) '' Icc a (a + p) = univ := eq_top_mono (image_mono Ico_subset_Icc_self) <| coe_image_Ico_eq _ _ /-- If functions on AddCircle agree on the image of the interval `[a, a + p)` then they are equal -/ lemma Ico_ext {α : Type*} {f g : AddCircle p → α} (a : 𝕜) (h : ∀ x ∈ Ico a (a + p), f x = g x) : f = g := by rw [← Set.eqOn_univ, ← coe_image_Ico_eq p a] rintro - ⟨x, hx, rfl⟩ exact h x hx /-- If functions on AddCircle agree on the image of the interval `(a, a + p]` then they are equal -/ lemma Ioc_ext {α : Type*} {f g : AddCircle p → α} (a : 𝕜) (h : ∀ x ∈ Ioc a (a + p), f x = g x) : f = g := by rw [← Set.eqOn_univ, ← coe_image_Ioc_eq p a] rintro - ⟨x, hx, rfl⟩ exact h x hx end LinearOrderedAddCommGroup section LinearOrderedField variable [Field 𝕜] (p q : 𝕜) /-- The rescaling equivalence between additive circles with different periods. -/ def equivAddCircle (hp : p ≠ 0) (hq : q ≠ 0) : AddCircle p ≃+ AddCircle q := QuotientAddGroup.congr _ _ (AddAut.mulRight <| (Units.mk0 p hp)⁻¹ * Units.mk0 q hq) <| by rw [AddMonoidHom.map_zmultiples, AddMonoidHom.coe_coe, AddAut.mulRight_apply, Units.val_mul, Units.val_mk0, Units.val_inv_eq_inv_val, Units.val_mk0, mul_inv_cancel_left₀ hp] @[simp] theorem equivAddCircle_apply_mk (hp : p ≠ 0) (hq : q ≠ 0) (x : 𝕜) : equivAddCircle p q hp hq (x : 𝕜) = (x * (p⁻¹ * q) : 𝕜) := rfl @[simp] theorem equivAddCircle_symm_apply_mk (hp : p ≠ 0) (hq : q ≠ 0) (x : 𝕜) : (equivAddCircle p q hp hq).symm (x : 𝕜) = (x * (q⁻¹ * p) : 𝕜) := rfl section variable [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜] [TopologicalSpace 𝕜] [OrderTopology 𝕜] /-- The rescaling homeomorphism between additive circles with different periods. -/ def homeomorphAddCircle (hp : p ≠ 0) (hq : q ≠ 0) : AddCircle p ≃ₜ AddCircle q := ⟨equivAddCircle p q hp hq, (continuous_quotient_mk'.comp (continuous_mul_right (p⁻¹ * q))).quotient_lift _, (continuous_quotient_mk'.comp (continuous_mul_right (q⁻¹ * p))).quotient_lift _⟩ @[simp] theorem homeomorphAddCircle_apply_mk (hp : p ≠ 0) (hq : q ≠ 0) (x : 𝕜) : homeomorphAddCircle p q hp hq (x : 𝕜) = (x * (p⁻¹ * q) : 𝕜) := rfl @[simp] theorem homeomorphAddCircle_symm_apply_mk (hp : p ≠ 0) (hq : q ≠ 0) (x : 𝕜) : (homeomorphAddCircle p q hp hq).symm (x : 𝕜) = (x * (q⁻¹ * p) : 𝕜) := rfl end lemma natCast_div_mul_eq_nsmul (r : 𝕜) (m : ℕ) : (↑(↑m / q * r) : AddCircle p) = m • (r / q : AddCircle p) := by rw [mul_comm_div, ← nsmul_eq_mul, coe_nsmul] lemma intCast_div_mul_eq_zsmul (r : 𝕜) (m : ℤ) : (↑(↑m / q * r) : AddCircle p) = m • (r / q : AddCircle p) := by rw [mul_comm_div, ← zsmul_eq_mul, coe_zsmul] variable [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜] [hp : Fact (0 < p)] section FloorRing variable [FloorRing 𝕜] @[simp] theorem coe_equivIco_mk_apply (x : 𝕜) : (equivIco p 0 <| QuotientAddGroup.mk x : 𝕜) = Int.fract (x / p) * p := toIcoMod_eq_fract_mul _ x instance : DivisibleBy (AddCircle p) ℤ where div x n := (↑((n : 𝕜)⁻¹ * (equivIco p 0 x : 𝕜)) : AddCircle p) div_zero x := by simp div_cancel {n} x hn := by replace hn : (n : 𝕜) ≠ 0 := by norm_cast change n • QuotientAddGroup.mk' _ ((n : 𝕜)⁻¹ * ↑(equivIco p 0 x)) = x rw [← map_zsmul, ← smul_mul_assoc, zsmul_eq_mul, mul_inv_cancel₀ hn, one_mul] exact (equivIco p 0).symm_apply_apply x omit [IsStrictOrderedRing 𝕜] in @[simp] lemma coe_fract (x : 𝕜) : (↑(Int.fract x) : AddCircle (1 : 𝕜)) = x := by simp [← Int.self_sub_floor] end FloorRing section FiniteOrderPoints variable {p} theorem addOrderOf_period_div {n : ℕ} (h : 0 < n) : addOrderOf ((p / n : 𝕜) : AddCircle p) = n := by rw [addOrderOf_eq_iff h] replace h : 0 < (n : 𝕜) := Nat.cast_pos.2 h refine ⟨?_, fun m hn h0 => ?_⟩ <;> simp only [Ne, ← coe_nsmul, nsmul_eq_mul] · rw [mul_div_cancel₀ _ h.ne', coe_period] rw [coe_eq_zero_of_pos_iff p hp.out (mul_pos (Nat.cast_pos.2 h0) <| div_pos hp.out h)] rintro ⟨k, hk⟩ rw [mul_div, eq_div_iff h.ne', nsmul_eq_mul, mul_right_comm, ← Nat.cast_mul, (mul_left_injective₀ hp.out.ne').eq_iff, Nat.cast_inj, mul_comm] at hk exact (Nat.le_of_dvd h0 ⟨_, hk.symm⟩).not_gt hn variable (p) in theorem gcd_mul_addOrderOf_div_eq {n : ℕ} (m : ℕ) (hn : 0 < n) : m.gcd n * addOrderOf (↑(↑m / ↑n * p) : AddCircle p) = n := by rw [natCast_div_mul_eq_nsmul, IsOfFinAddOrder.addOrderOf_nsmul] · rw [addOrderOf_period_div hn, Nat.gcd_comm, Nat.mul_div_cancel'] exact n.gcd_dvd_left m · rwa [← addOrderOf_pos_iff, addOrderOf_period_div hn] theorem addOrderOf_div_of_gcd_eq_one {m n : ℕ} (hn : 0 < n) (h : m.gcd n = 1) : addOrderOf (↑(↑m / ↑n * p) : AddCircle p) = n := by convert gcd_mul_addOrderOf_div_eq p m hn rw [h, one_mul] theorem addOrderOf_div_of_gcd_eq_one' {m : ℤ} {n : ℕ} (hn : 0 < n) (h : m.natAbs.gcd n = 1) : addOrderOf (↑(↑m / ↑n * p) : AddCircle p) = n := by cases m · simp only [Int.ofNat_eq_coe, Int.cast_natCast, Int.natAbs_natCast] at h ⊢ exact addOrderOf_div_of_gcd_eq_one hn h · simp only [Int.cast_negSucc, neg_div, neg_mul, coe_neg, addOrderOf_neg] exact addOrderOf_div_of_gcd_eq_one hn h theorem addOrderOf_coe_rat {q : ℚ} : addOrderOf (↑(↑q * p) : AddCircle p) = q.den := by have : (↑(q.den : ℤ) : 𝕜) ≠ 0 := by norm_cast exact q.pos.ne.symm rw [← q.num_divInt_den, Rat.cast_divInt_of_ne_zero _ this, Int.cast_natCast, Rat.num_divInt_den, addOrderOf_div_of_gcd_eq_one' q.pos q.reduced] theorem nsmul_eq_zero_iff {u : AddCircle p} {n : ℕ} (h : 0 < n) : n • u = 0 ↔ ∃ m < n, ↑(↑m / ↑n * p) = u := by refine ⟨QuotientAddGroup.induction_on u fun k hk ↦ ?_, ?_⟩ · rw [← addOrderOf_dvd_iff_nsmul_eq_zero] rintro ⟨m, -, rfl⟩ constructor; rw [mul_comm, eq_comm] exact gcd_mul_addOrderOf_div_eq p m h rw [← coe_nsmul, coe_eq_zero_iff] at hk obtain ⟨a, ha⟩ := hk refine ⟨a.natMod n, Int.natMod_lt h.ne', ?_⟩ have h0 : (n : 𝕜) ≠ 0 := Nat.cast_ne_zero.2 h.ne' rw [nsmul_eq_mul, mul_comm, ← div_eq_iff h0, ← a.ediv_mul_add_emod n, add_smul, add_div, zsmul_eq_mul, Int.cast_mul, Int.cast_natCast, mul_assoc, ← mul_div, mul_comm _ p, mul_div_cancel_right₀ p h0] at ha rw [← ha, coe_add, ← Int.cast_natCast, Int.natMod, Int.toNat_of_nonneg, zsmul_eq_mul, mul_div_right_comm, eq_comm, add_eq_right, ←zsmul_eq_mul, coe_zsmul, coe_period, smul_zero] exact Int.emod_nonneg _ (by exact_mod_cast h.ne') theorem addOrderOf_eq_pos_iff {u : AddCircle p} {n : ℕ} (h : 0 < n) : addOrderOf u = n ↔ ∃ m < n, m.gcd n = 1 ∧ ↑(↑m / ↑n * p) = u := by refine ⟨QuotientAddGroup.induction_on u ?_, ?_⟩ · rintro ⟨m, -, h₁, rfl⟩ exact addOrderOf_div_of_gcd_eq_one h h₁ rintro k rfl obtain ⟨m, hm, hk⟩ := (nsmul_eq_zero_iff h).mp (addOrderOf_nsmul_eq_zero (k : AddCircle p)) refine ⟨m, hm, mul_right_cancel₀ h.ne' ?_, hk⟩ convert gcd_mul_addOrderOf_div_eq p m h using 1 · rw [hk] · apply one_mul theorem exists_gcd_eq_one_of_isOfFinAddOrder {u : AddCircle p} (h : IsOfFinAddOrder u) : ∃ m : ℕ, m.gcd (addOrderOf u) = 1 ∧ m < addOrderOf u ∧ ↑((m : 𝕜) / addOrderOf u * p) = u := let ⟨m, hl, hg, he⟩ := (addOrderOf_eq_pos_iff h.addOrderOf_pos).1 rfl ⟨m, hg, hl, he⟩ lemma not_isOfFinAddOrder_iff_forall_rat_ne_div {a : 𝕜} : ¬ IsOfFinAddOrder (a : AddCircle p) ↔ ∀ q : ℚ, (q : 𝕜) ≠ a / p := by simp +contextual [← QuotientAddGroup.mk_zsmul, mul_comm (Int.cast _), mem_zmultiples_iff, eq_div_iff (Fact.out : 0 < p).ne', isOfFinAddOrder_iff_zsmul_eq_zero, Rat.forall, div_eq_iff, div_mul_eq_mul_div] grind lemma isOfFinAddOrder_iff_exists_rat_eq_div {a : 𝕜} : IsOfFinAddOrder (a : AddCircle p) ↔ ∃ q : ℚ, (q : 𝕜) = a / p := by simpa using not_isOfFinAddOrder_iff_forall_rat_ne_div.not_right @[deprecated not_isOfFinAddOrder_iff_forall_rat_ne_div (since := "2025-08-13")] theorem addOrderOf_coe_eq_zero_iff_forall_rat_ne_div {a : 𝕜} : addOrderOf (a : AddCircle p) = 0 ↔ ∀ q : ℚ, (q : 𝕜) ≠ a / p := by simp [not_isOfFinAddOrder_iff_forall_rat_ne_div] variable (p) /-- The natural bijection between points of order `n` and natural numbers less than and coprime to `n`. The inverse of the map sends `m ↦ (m/n * p : AddCircle p)` where `m` is coprime to `n` and satisfies `0 ≤ m < n`. -/ def setAddOrderOfEquiv {n : ℕ} (hn : 0 < n) : { u : AddCircle p | addOrderOf u = n } ≃ { m | m < n ∧ m.gcd n = 1 } := Equiv.symm <| Equiv.ofBijective (fun m => ⟨↑((m : 𝕜) / n * p), addOrderOf_div_of_gcd_eq_one hn m.prop.2⟩) (by refine ⟨fun m₁ m₂ h => Subtype.ext ?_, fun u => ?_⟩ · simp_rw [Subtype.mk_eq_mk, natCast_div_mul_eq_nsmul] at h refine nsmul_injOn_Iio_addOrderOf ?_ ?_ h <;> rw [addOrderOf_period_div hn] exacts [m₁.2.1, m₂.2.1] · obtain ⟨m, hmn, hg, he⟩ := (addOrderOf_eq_pos_iff hn).mp u.2 exact ⟨⟨m, hmn, hg⟩, Subtype.ext he⟩) @[simp] theorem card_addOrderOf_eq_totient {n : ℕ} : Nat.card { u : AddCircle p // addOrderOf u = n } = n.totient := by rcases n.eq_zero_or_pos with (rfl | hn) · simp only [Nat.totient_zero, addOrderOf_eq_zero_iff] rcases em (∃ u : AddCircle p, ¬IsOfFinAddOrder u) with (⟨u, hu⟩ | h) · have : Infinite { u : AddCircle p // ¬IsOfFinAddOrder u } := by rw [← coe_setOf, infinite_coe_iff] exact infinite_not_isOfFinAddOrder hu exact Nat.card_eq_zero_of_infinite · have : IsEmpty { u : AddCircle p // ¬IsOfFinAddOrder u } := by simpa [isEmpty_subtype] using h exact Nat.card_of_isEmpty · rw [← coe_setOf, Nat.card_congr (setAddOrderOfEquiv p hn), n.totient_eq_card_lt_and_coprime] simp only [Nat.gcd_comm] theorem finite_setOf_addOrderOf_eq {n : ℕ} (hn : 0 < n) : {u : AddCircle p | addOrderOf u = n}.Finite := finite_coe_iff.mp <| Nat.finite_of_card_ne_zero <| by simp [hn.ne'] theorem finite_torsion {n : ℕ} (hn : 0 < n) : { u : AddCircle p | n • u = 0 }.Finite := by convert Set.finite_range (fun m : Fin n ↦ (↑(↑m / ↑n * p) : AddCircle p)) simp_rw [nsmul_eq_zero_iff hn, range, Fin.exists_iff, exists_prop] end FiniteOrderPoints end LinearOrderedField end AddCircle section IdentifyIccEnds /-! This section proves that for any `a`, the natural map from `[a, a + p] ⊂ 𝕜` to `AddCircle p` gives an identification of `AddCircle p`, as a topological space, with the quotient of `[a, a + p]` by the equivalence relation identifying the endpoints. -/ namespace AddCircle variable [AddCommGroup 𝕜] [LinearOrder 𝕜] [IsOrderedAddMonoid 𝕜] (p a : 𝕜) [hp : Fact (0 < p)] local notation "𝕋" => AddCircle p /-- The relation identifying the endpoints of `Icc a (a + p)`. -/ inductive EndpointIdent : Icc a (a + p) → Icc a (a + p) → Prop | mk : EndpointIdent ⟨a, left_mem_Icc.mpr <| le_add_of_nonneg_right hp.out.le⟩ ⟨a + p, right_mem_Icc.mpr <| le_add_of_nonneg_right hp.out.le⟩ variable [Archimedean 𝕜] /-- The equivalence between `AddCircle p` and the quotient of `[a, a + p]` by the relation identifying the endpoints. -/ def equivIccQuot : 𝕋 ≃ Quot (EndpointIdent p a) where toFun x := Quot.mk _ <| inclusion Ico_subset_Icc_self (equivIco _ _ x) invFun x := Quot.liftOn x (↑) <| by rintro _ _ ⟨_⟩ exact (coe_add_period p a).symm left_inv := (equivIco p a).symm_apply_apply right_inv := Quot.ind <| by rintro ⟨x, hx⟩ rcases ne_or_eq x (a + p) with (h | rfl) · revert x dsimp only intro x hx h congr ext1 apply congr_arg Subtype.val ((equivIco p a).right_inv ⟨x, hx.1, hx.2.lt_of_ne h⟩) · rw [← Quot.sound EndpointIdent.mk] dsimp only congr ext1 apply congr_arg Subtype.val ((equivIco p a).right_inv ⟨a, le_refl a, lt_add_of_pos_right a hp.out⟩) theorem equivIccQuot_comp_mk_eq_toIcoMod : equivIccQuot p a ∘ Quotient.mk'' = fun x => Quot.mk _ ⟨toIcoMod hp.out a x, Ico_subset_Icc_self <| toIcoMod_mem_Ico _ _ x⟩ := rfl theorem equivIccQuot_comp_mk_eq_toIocMod : equivIccQuot p a ∘ Quotient.mk'' = fun x => Quot.mk _ ⟨toIocMod hp.out a x, Ioc_subset_Icc_self <| toIocMod_mem_Ioc _ _ x⟩ := by rw [equivIccQuot_comp_mk_eq_toIcoMod] funext x by_cases h : a ≡ x [PMOD p] · simp_rw [(modEq_iff_toIcoMod_eq_left hp.out).1 h, (modEq_iff_toIocMod_eq_right hp.out).1 h] exact Quot.sound EndpointIdent.mk · simp_rw [(not_modEq_iff_toIcoMod_eq_toIocMod hp.out).1 h] /-- The natural map from `[a, a + p] ⊂ 𝕜` with endpoints identified to `𝕜 / ℤ • p`, as a homeomorphism of topological spaces. -/ def homeoIccQuot [TopologicalSpace 𝕜] [OrderTopology 𝕜] : 𝕋 ≃ₜ Quot (EndpointIdent p a) where toEquiv := equivIccQuot p a continuous_toFun := by simp_rw [isQuotientMap_quotient_mk'.continuous_iff, continuous_iff_continuousAt, continuousAt_iff_continuous_left_right] intro x; constructor on_goal 1 => erw [equivIccQuot_comp_mk_eq_toIocMod] on_goal 2 => erw [equivIccQuot_comp_mk_eq_toIcoMod] all_goals apply continuous_quot_mk.continuousAt.comp_continuousWithinAt rw [IsInducing.subtypeVal.continuousWithinAt_iff] · apply continuous_left_toIocMod · apply continuous_right_toIcoMod continuous_invFun := continuous_quot_lift _ ((AddCircle.continuous_mk' p).comp continuous_subtype_val) /-! We now show that a continuous function on `[a, a + p]` satisfying `f a = f (a + p)` is the pullback of a continuous function on `AddCircle p`, by first showing that various lifts are equivalent. -/ variable {p a} theorem liftIoc_eq_liftIco {f : 𝕜 → B} (hf : f a = f (a + p)) : liftIoc p a f = liftIco p a f := by ext q obtain ⟨x, hx, rfl⟩ := by simpa only [mem_image] using coe_image_Ico_eq p a ▸ mem_univ q rw [liftIco_coe_apply hx] obtain (⟨rfl, -⟩ | h) := by rwa [mem_Ico, le_iff_eq_or_lt, or_and_right] at hx · rw [← coe_add_period, liftIoc_coe_apply (by simp [hp.out]), hf] · exact liftIoc_coe_apply ⟨h.1, h.2.le⟩ theorem liftIco_eq_lift_Icc {f : 𝕜 → B} (h : f a = f (a + p)) : liftIco p a f = Quot.lift (restrict (Icc a <| a + p) f) (by rintro _ _ ⟨_⟩ exact h) ∘ equivIccQuot p a := rfl theorem liftIoc_eq_lift_Icc {f : 𝕜 → B} (h : f a = f (a + p)) : liftIoc p a f = Quot.lift (restrict (Icc a <| a + p) f) (by rintro _ _ ⟨_⟩ exact h) ∘ equivIccQuot p a := by rw [← liftIco_eq_lift_Icc h] exact liftIoc_eq_liftIco h theorem liftIco_zero_coe_apply {f : 𝕜 → B} {x : 𝕜} (hx : x ∈ Ico 0 p) : liftIco p 0 f ↑x = f x := liftIco_coe_apply (by rwa [zero_add]) theorem liftIoc_zero_coe_apply {f : 𝕜 → B} {x : 𝕜} (hx : x ∈ Ioc 0 p) : liftIoc p 0 f ↑x = f x := liftIoc_coe_apply (by rwa [zero_add]) variable [TopologicalSpace 𝕜] [OrderTopology 𝕜] theorem liftIco_continuous [TopologicalSpace B] {f : 𝕜 → B} (hf : f a = f (a + p)) (hc : ContinuousOn f <| Icc a (a + p)) : Continuous (liftIco p a f) := by rw [liftIco_eq_lift_Icc hf] refine Continuous.comp ?_ (homeoIccQuot p a).continuous_toFun exact continuous_coinduced_dom.mpr (continuousOn_iff_continuous_restrict.mp hc) theorem liftIco_zero_continuous [TopologicalSpace B] {f : 𝕜 → B} (hf : f 0 = f p) (hc : ContinuousOn f <| Icc 0 p) : Continuous (liftIco p 0 f) := liftIco_continuous (by rwa [zero_add] : f 0 = f (0 + p)) (by rwa [zero_add]) theorem liftIoc_continuous [TopologicalSpace B] {f : 𝕜 → B} (hf : f a = f (a + p)) (hc : ContinuousOn f <| Icc a (a + p)) : Continuous (liftIoc p a f) := by rw [liftIoc_eq_lift_Icc hf] refine Continuous.comp ?_ (homeoIccQuot p a).continuous_toFun exact continuous_coinduced_dom.mpr (continuousOn_iff_continuous_restrict.mp hc) theorem liftIoc_zero_continuous [TopologicalSpace B] {f : 𝕜 → B} (hf : f 0 = f p) (hc : ContinuousOn f <| Icc 0 p) : Continuous (liftIoc p 0 f) := liftIoc_continuous (by rwa [zero_add] : f 0 = f (0 + p)) (by rwa [zero_add]) end AddCircle end IdentifyIccEnds
.lake/packages/mathlib/Mathlib/Topology/Instances/AddCircle/DenseSubgroup.lean
import Mathlib.NumberTheory.Real.Irrational import Mathlib.Topology.Instances.AddCircle.Defs import Mathlib.Topology.Algebra.Order.Archimedean /-! # Irrational rotation is minimal In this file we prove that the multiples of an irrational element of an `AddCircle` are dense. Moreover, an additive subgroup of the circle is dense iff it is not generated by a single element of finite additive order. -/ open Set Filter open scoped Pointwise Topology /-- The additive subgroup of real numbers generated by `a` and `b` is dense iff `a / b` is an irrational number. Here we rely on the fact that `a / 0 = 0` in Mathlib, so we don't need to add `b ≠ 0` as an assumption. -/ theorem dense_addSubgroupClosure_pair_iff {a b : ℝ} : Dense (AddSubgroup.closure {a, b} : Set ℝ) ↔ Irrational (a / b) := by rcases eq_or_ne b 0 with rfl | hb · rw [pair_comm] simpa [← AddSubgroup.zmultiples_eq_closure] using not_denseRange_zsmul constructor · rintro hd ⟨r, hr⟩ refine not_denseRange_zsmul (a := b / r.den) <| hd.mono ?_ rw [← AddSubgroup.coe_zmultiples, SetLike.coe_subset_coe, AddSubgroup.closure_le, AddSubgroup.coe_zmultiples, pair_subset_iff] refine ⟨⟨r.num, ?_⟩, r.den, ?_⟩ · simp [field, mul_div_left_comm _ b, ← Rat.cast_def, hr] · simp [field] · intro h contrapose! h rcases (AddSubgroup.dense_or_cyclic _).resolve_left h with ⟨c, hc⟩ have : {a, b} ⊆ range (· • c : ℤ → ℝ) := by rw [← AddSubgroup.coe_zmultiples, AddSubgroup.zmultiples_eq_closure, ← hc] apply AddSubgroup.subset_closure rcases pair_subset_iff.1 this with ⟨⟨m, rfl⟩, n, rfl⟩ simp_all [mul_div_mul_right] namespace AddCircle /-- The multiples of a number `a` are dense on a circle of length `p` iff `a / p` is irrational. -/ theorem denseRange_zsmul_coe_iff {a p : ℝ} : DenseRange (· • a : ℤ → AddCircle p) ↔ Irrational (a / p) := by rw [← dense_addSubgroupClosure_pair_iff, DenseRange, ← QuotientAddGroup.dense_preimage_mk, ← QuotientAddGroup.coe_mk', ← AddSubgroup.coe_zmultiples, ← AddSubgroup.coe_comap, ← AddMonoidHom.map_zmultiples, AddSubgroup.comap_map_eq, QuotientAddGroup.ker_mk', AddSubgroup.zmultiples_eq_closure, AddSubgroup.zmultiples_eq_closure, ← AddSubgroup.closure_union, insert_eq] /-- The multiples of a number `a` are dense on a circle of length `p > 0` iff `a` has infinite additive order. -/ theorem denseRange_zsmul_iff {p : ℝ} [Fact (0 < p)] {a : AddCircle p} : DenseRange (· • a : ℤ → AddCircle p) ↔ addOrderOf a = 0 := by rcases QuotientAddGroup.mk_surjective a with ⟨a, rfl⟩ simp [denseRange_zsmul_coe_iff, isOfFinAddOrder_iff_exists_rat_eq_div, Irrational] /-- A subgroup of the circle `ℝ⧸pℤ`, `p > 0`, is dense iff it is not generated by a single element of finite additive order. -/ theorem dense_addSubgroup_iff_ne_zmultiples {p : ℝ} [Fact (0 < p)] {s : AddSubgroup (AddCircle p)} : Dense (s : Set (AddCircle p)) ↔ ∀ a, addOrderOf a ≠ 0 → s ≠ .zmultiples a := by constructor · rintro hd a ha rfl rw [AddSubgroup.coe_zmultiples, ← DenseRange, denseRange_zsmul_iff] at hd exact ha hd · intro h contrapose! h obtain ⟨a, rfl⟩ : ∃ a, s = .zmultiples a := by rw [← QuotientAddGroup.dense_preimage_mk, ← QuotientAddGroup.coe_mk', ← AddSubgroup.coe_comap, xor_iff_not_iff'.1 (AddSubgroup.dense_xor'_cyclic _)] at h rcases h with ⟨a, ha⟩ use a rw [← QuotientAddGroup.coe_mk', ← AddMonoidHom.map_zmultiples, ← ha, AddSubgroup.map_comap_eq_self_of_surjective] exact Quot.mk_surjective exact ⟨a, denseRange_zsmul_iff.not.mp h, rfl⟩ end AddCircle
.lake/packages/mathlib/Mathlib/Topology/Instances/AddCircle/Real.lean
import Mathlib.Topology.Connected.PathConnected import Mathlib.Topology.Instances.AddCircle.Defs import Mathlib.Topology.Instances.ZMultiples /-! # The additive circle over `ℝ` Results specific to the additive circle over `ℝ`. -/ noncomputable section open AddCommGroup Set Function AddSubgroup TopologicalSpace Topology namespace AddCircle variable (p : ℝ) instance pathConnectedSpace : PathConnectedSpace <| AddCircle p := (inferInstance : PathConnectedSpace (Quotient _)) /-- The "additive circle" `ℝ ⧸ (ℤ ∙ p)` is compact. -/ instance compactSpace [Fact (0 < p)] : CompactSpace <| AddCircle p := by rw [← isCompact_univ_iff, ← coe_image_Icc_eq p 0] exact isCompact_Icc.image (AddCircle.continuous_mk' p) /-- The action on `ℝ` by right multiplication of its the subgroup `zmultiples p` (the multiples of `p:ℝ`) is properly discontinuous. -/ instance : ProperlyDiscontinuousVAdd (zmultiples p).op ℝ := (zmultiples p).properlyDiscontinuousVAdd_opposite_of_tendsto_cofinite (AddSubgroup.tendsto_zmultiples_subtype_cofinite p) end AddCircle section UnitAddCircle /-- The unit circle `ℝ ⧸ ℤ`. -/ abbrev UnitAddCircle := AddCircle (1 : ℝ) end UnitAddCircle namespace ZMod variable {N : ℕ} [NeZero N] /-- The `AddMonoidHom` from `ZMod N` to `ℝ / ℤ` sending `j mod N` to `j / N mod 1`. -/ noncomputable def toAddCircle : ZMod N →+ UnitAddCircle := lift N ⟨AddMonoidHom.mk' (fun j ↦ ↑(j / N : ℝ)) (by simp [add_div]), by simp [div_self (NeZero.ne _)]⟩ lemma toAddCircle_intCast (j : ℤ) : toAddCircle (j : ZMod N) = ↑(j / N : ℝ) := by simp [toAddCircle] lemma toAddCircle_natCast (j : ℕ) : toAddCircle (j : ZMod N) = ↑(j / N : ℝ) := by simpa using toAddCircle_intCast (N := N) j /-- Explicit formula for `toCircle j`. Note that this is "evil" because it uses `ZMod.val`. Where possible, it is recommended to lift `j` to `ℤ` and use `toAddCircle_intCast` instead. -/ lemma toAddCircle_apply (j : ZMod N) : toAddCircle j = ↑(j.val / N : ℝ) := by rw [← toAddCircle_natCast, natCast_zmod_val] variable (N) in lemma toAddCircle_injective : Function.Injective (toAddCircle : ZMod N → _) := by intro x y hxy have : (0 : ℝ) < N := Nat.cast_pos.mpr (NeZero.pos _) rwa [toAddCircle_apply, toAddCircle_apply, AddCircle.coe_eq_coe_iff_of_mem_Ico, div_left_inj' this.ne', Nat.cast_inj, (val_injective N).eq_iff] at hxy <;> exact ⟨by positivity, by simpa only [zero_add, div_lt_one this, Nat.cast_lt] using val_lt _⟩ @[simp] lemma toAddCircle_inj {j k : ZMod N} : toAddCircle j = toAddCircle k ↔ j = k := (toAddCircle_injective N).eq_iff @[simp] lemma toAddCircle_eq_zero {j : ZMod N} : toAddCircle j = 0 ↔ j = 0 := map_eq_zero_iff _ (toAddCircle_injective N) end ZMod
.lake/packages/mathlib/Mathlib/Topology/Instances/EReal/Lemmas.lean
import Mathlib.Data.EReal.Inv import Mathlib.Topology.Semicontinuous /-! # Topological structure on `EReal` We prove basic properties of the topology on `EReal`. ## Main results * `Real.toEReal : ℝ → EReal` is an open embedding * `ENNReal.toEReal : ℝ≥0∞ → EReal` is a closed embedding * The addition on `EReal` is continuous except at `(⊥, ⊤)` and at `(⊤, ⊥)`. * Negation is a homeomorphism on `EReal`. ## Implementation Most proofs are adapted from the corresponding proofs on `ℝ≥0∞`. -/ noncomputable section open Set Filter Metric TopologicalSpace Topology open scoped ENNReal variable {α : Type*} [TopologicalSpace α] namespace EReal /-! ### Real coercion -/ theorem isEmbedding_coe : IsEmbedding ((↑) : ℝ → EReal) := coe_strictMono.isEmbedding_of_ordConnected <| by rw [range_coe_eq_Ioo]; exact ordConnected_Ioo theorem isOpenEmbedding_coe : IsOpenEmbedding ((↑) : ℝ → EReal) := ⟨isEmbedding_coe, by simp only [range_coe_eq_Ioo, isOpen_Ioo]⟩ @[norm_cast] theorem tendsto_coe {α : Type*} {f : Filter α} {m : α → ℝ} {a : ℝ} : Tendsto (fun a => (m a : EReal)) f (𝓝 ↑a) ↔ Tendsto m f (𝓝 a) := isEmbedding_coe.tendsto_nhds_iff.symm theorem _root_.continuous_coe_real_ereal : Continuous ((↑) : ℝ → EReal) := isEmbedding_coe.continuous theorem continuous_coe_iff {f : α → ℝ} : (Continuous fun a => (f a : EReal)) ↔ Continuous f := isEmbedding_coe.continuous_iff.symm theorem nhds_coe {r : ℝ} : 𝓝 (r : EReal) = (𝓝 r).map (↑) := (isOpenEmbedding_coe.map_nhds_eq r).symm theorem nhds_coe_coe {r p : ℝ} : 𝓝 ((r : EReal), (p : EReal)) = (𝓝 (r, p)).map fun p : ℝ × ℝ => (↑p.1, ↑p.2) := ((isOpenEmbedding_coe.prodMap isOpenEmbedding_coe).map_nhds_eq (r, p)).symm theorem tendsto_toReal {a : EReal} (ha : a ≠ ⊤) (h'a : a ≠ ⊥) : Tendsto EReal.toReal (𝓝 a) (𝓝 a.toReal) := by lift a to ℝ using ⟨ha, h'a⟩ rw [nhds_coe, tendsto_map'_iff] exact tendsto_id theorem continuousOn_toReal : ContinuousOn EReal.toReal ({⊥, ⊤}ᶜ : Set EReal) := fun _a ha => ContinuousAt.continuousWithinAt (tendsto_toReal (mt Or.inr ha) (mt Or.inl ha)) /-- The set of finite `EReal` numbers is homeomorphic to `ℝ`. -/ def neBotTopHomeomorphReal : ({⊥, ⊤}ᶜ : Set EReal) ≃ₜ ℝ where toEquiv := neTopBotEquivReal continuous_toFun := continuousOn_iff_continuous_restrict.1 continuousOn_toReal continuous_invFun := continuous_coe_real_ereal.subtype_mk _ /-! ### ENNReal coercion -/ theorem isEmbedding_coe_ennreal : IsEmbedding ((↑) : ℝ≥0∞ → EReal) := coe_ennreal_strictMono.isEmbedding_of_ordConnected <| by rw [range_coe_ennreal]; exact ordConnected_Ici theorem isClosedEmbedding_coe_ennreal : IsClosedEmbedding ((↑) : ℝ≥0∞ → EReal) := ⟨isEmbedding_coe_ennreal, by rw [range_coe_ennreal]; exact isClosed_Ici⟩ @[norm_cast] theorem tendsto_coe_ennreal {α : Type*} {f : Filter α} {m : α → ℝ≥0∞} {a : ℝ≥0∞} : Tendsto (fun a => (m a : EReal)) f (𝓝 ↑a) ↔ Tendsto m f (𝓝 a) := isEmbedding_coe_ennreal.tendsto_nhds_iff.symm theorem _root_.continuous_coe_ennreal_ereal : Continuous ((↑) : ℝ≥0∞ → EReal) := isEmbedding_coe_ennreal.continuous theorem continuous_coe_ennreal_iff {f : α → ℝ≥0∞} : (Continuous fun a => (f a : EReal)) ↔ Continuous f := isEmbedding_coe_ennreal.continuous_iff.symm /-! ### Neighborhoods of infinity -/ theorem nhds_top : 𝓝 (⊤ : EReal) = ⨅ (a) (_ : a ≠ ⊤), 𝓟 (Ioi a) := nhds_top_order.trans <| by simp only [lt_top_iff_ne_top] nonrec theorem nhds_top_basis : (𝓝 (⊤ : EReal)).HasBasis (fun _ : ℝ ↦ True) (Ioi ·) := by refine (nhds_top_basis (α := EReal)).to_hasBasis (fun x hx => ?_) fun _ _ ↦ ⟨_, coe_lt_top _, Subset.rfl⟩ rcases exists_rat_btwn_of_lt hx with ⟨y, hxy, -⟩ exact ⟨_, trivial, Ioi_subset_Ioi hxy.le⟩ theorem nhds_top' : 𝓝 (⊤ : EReal) = ⨅ a : ℝ, 𝓟 (Ioi ↑a) := nhds_top_basis.eq_iInf theorem mem_nhds_top_iff {s : Set EReal} : s ∈ 𝓝 (⊤ : EReal) ↔ ∃ y : ℝ, Ioi (y : EReal) ⊆ s := nhds_top_basis.mem_iff.trans <| by simp only [true_and] theorem tendsto_nhds_top_iff_real {α : Type*} {m : α → EReal} {f : Filter α} : Tendsto m f (𝓝 ⊤) ↔ ∀ x : ℝ, ∀ᶠ a in f, ↑x < m a := nhds_top_basis.tendsto_right_iff.trans <| by simp only [true_implies, mem_Ioi] theorem nhds_bot : 𝓝 (⊥ : EReal) = ⨅ (a) (_ : a ≠ ⊥), 𝓟 (Iio a) := nhds_bot_order.trans <| by simp only [bot_lt_iff_ne_bot] theorem nhds_bot_basis : (𝓝 (⊥ : EReal)).HasBasis (fun _ : ℝ ↦ True) (Iio ·) := by refine (_root_.nhds_bot_basis (α := EReal)).to_hasBasis (fun x hx => ?_) fun _ _ ↦ ⟨_, bot_lt_coe _, Subset.rfl⟩ rcases exists_rat_btwn_of_lt hx with ⟨y, -, hxy⟩ exact ⟨_, trivial, Iio_subset_Iio hxy.le⟩ theorem nhds_bot' : 𝓝 (⊥ : EReal) = ⨅ a : ℝ, 𝓟 (Iio ↑a) := nhds_bot_basis.eq_iInf theorem mem_nhds_bot_iff {s : Set EReal} : s ∈ 𝓝 (⊥ : EReal) ↔ ∃ y : ℝ, Iio (y : EReal) ⊆ s := nhds_bot_basis.mem_iff.trans <| by simp only [true_and] theorem tendsto_nhds_bot_iff_real {α : Type*} {m : α → EReal} {f : Filter α} : Tendsto m f (𝓝 ⊥) ↔ ∀ x : ℝ, ∀ᶠ a in f, m a < x := nhds_bot_basis.tendsto_right_iff.trans <| by simp only [true_implies, mem_Iio] lemma nhdsWithin_top : 𝓝[≠] (⊤ : EReal) = (atTop).map Real.toEReal := by apply (nhdsWithin_hasBasis nhds_top_basis_Ici _).ext (atTop_basis.map Real.toEReal) · simp only [EReal.image_coe_Ici, true_and] intro x hx by_cases hx_bot : x = ⊥ · simp [hx_bot] lift x to ℝ using ⟨hx.ne_top, hx_bot⟩ refine ⟨x, fun x ⟨h1, h2⟩ ↦ ?_⟩ simp [h1, h2.ne_top] · simp only [EReal.image_coe_Ici, true_implies] refine fun x ↦ ⟨x, ⟨EReal.coe_lt_top x, fun x ⟨(h1 : _ ≤ x), h2⟩ ↦ ?_⟩⟩ simp [h1, Ne.lt_top' fun a ↦ h2 a.symm] lemma nhdsWithin_bot : 𝓝[≠] (⊥ : EReal) = (atBot).map Real.toEReal := by apply (nhdsWithin_hasBasis nhds_bot_basis_Iic _).ext (atBot_basis.map Real.toEReal) · simp only [EReal.image_coe_Iic, true_and] intro x hx by_cases hx_top : x = ⊤ · simp [hx_top] lift x to ℝ using ⟨hx_top, hx.ne_bot⟩ refine ⟨x, fun x ⟨h1, h2⟩ ↦ ?_⟩ simp [h2, h1.ne_bot] · simp only [EReal.image_coe_Iic, true_implies] refine fun x ↦ ⟨x, ⟨EReal.bot_lt_coe x, fun x ⟨(h1 : x ≤ _), h2⟩ ↦ ?_⟩⟩ simp [h1, Ne.bot_lt' fun a ↦ h2 a.symm] omit [TopologicalSpace α] in @[simp] lemma tendsto_coe_nhds_top_iff {f : α → ℝ} {l : Filter α} : Tendsto (fun x ↦ Real.toEReal (f x)) l (𝓝 ⊤) ↔ Tendsto f l atTop := by rw [tendsto_nhds_top_iff_real, atTop_basis_Ioi.tendsto_right_iff]; simp lemma tendsto_coe_atTop : Tendsto Real.toEReal atTop (𝓝 ⊤) := tendsto_coe_nhds_top_iff.2 tendsto_id omit [TopologicalSpace α] in @[simp] lemma tendsto_coe_nhds_bot_iff {f : α → ℝ} {l : Filter α} : Tendsto (fun x ↦ Real.toEReal (f x)) l (𝓝 ⊥) ↔ Tendsto f l atBot := by rw [tendsto_nhds_bot_iff_real, atBot_basis_Iio.tendsto_right_iff]; simp lemma tendsto_coe_atBot : Tendsto Real.toEReal atBot (𝓝 ⊥) := tendsto_coe_nhds_bot_iff.2 tendsto_id lemma tendsto_toReal_atTop : Tendsto EReal.toReal (𝓝[≠] ⊤) atTop := by rw [nhdsWithin_top, tendsto_map'_iff] exact tendsto_id lemma tendsto_toReal_atBot : Tendsto EReal.toReal (𝓝[≠] ⊥) atBot := by rw [nhdsWithin_bot, tendsto_map'_iff] exact tendsto_id /-! ### toENNReal -/ lemma continuous_toENNReal : Continuous EReal.toENNReal := by refine continuous_iff_continuousAt.mpr fun x ↦ ?_ by_cases h_top : x = ⊤ · simp only [ContinuousAt, h_top, toENNReal_top] refine ENNReal.tendsto_nhds_top fun n ↦ ?_ filter_upwards [eventually_gt_nhds (coe_lt_top n)] with y hy exact toENNReal_coe (x := n) ▸ toENNReal_lt_toENNReal (coe_ennreal_nonneg _) hy refine ContinuousOn.continuousAt ?_ (compl_singleton_mem_nhds_iff.mpr h_top) refine (continuousOn_of_forall_continuousAt fun x hx ↦ ?_).congr (fun _ h ↦ toENNReal_of_ne_top h) by_cases h_bot : x = ⊥ · refine tendsto_nhds_of_eventually_eq ?_ rw [h_bot, nhds_bot_basis.eventually_iff] simpa [toReal_bot, ENNReal.ofReal_zero, ENNReal.ofReal_eq_zero, true_and] using ⟨0, fun _ hx ↦ toReal_nonpos hx.le⟩ refine ENNReal.continuous_ofReal.continuousAt.comp' <| continuousOn_toReal.continuousAt <| (toFinite _).isClosed.compl_mem_nhds ?_ simp_all only [mem_compl_iff, mem_singleton_iff, mem_insert_iff, or_self, not_false_eq_true] @[fun_prop] lemma _root_.Continuous.ereal_toENNReal {α : Type*} [TopologicalSpace α] {f : α → EReal} (hf : Continuous f) : Continuous fun x => (f x).toENNReal := continuous_toENNReal.comp hf @[fun_prop] lemma _root_.ContinuousOn.ereal_toENNReal {α : Type*} [TopologicalSpace α] {s : Set α} {f : α → EReal} (hf : ContinuousOn f s) : ContinuousOn (fun x => (f x).toENNReal) s := continuous_toENNReal.comp_continuousOn hf @[fun_prop] lemma _root_.ContinuousWithinAt.ereal_toENNReal {α : Type*} [TopologicalSpace α] {f : α → EReal} {s : Set α} {x : α} (hf : ContinuousWithinAt f s x) : ContinuousWithinAt (fun x => (f x).toENNReal) s x := continuous_toENNReal.continuousAt.comp_continuousWithinAt hf @[fun_prop] lemma _root_.ContinuousAt.ereal_toENNReal {α : Type*} [TopologicalSpace α] {f : α → EReal} {x : α} (hf : ContinuousAt f x) : ContinuousAt (fun x => (f x).toENNReal) x := continuous_toENNReal.continuousAt.comp hf /-! ### Infs and Sups -/ variable {α : Type*} {u v : α → EReal} lemma add_iInf_le_iInf_add : (⨅ x, u x) + ⨅ x, v x ≤ ⨅ x, (u + v) x := le_iInf fun i ↦ add_le_add (iInf_le u i) (iInf_le v i) lemma iSup_add_le_add_iSup : ⨆ x, (u + v) x ≤ (⨆ x, u x) + ⨆ x, v x := iSup_le fun i ↦ add_le_add (le_iSup u i) (le_iSup v i) /-! ### Liminfs and Limsups -/ section LimInfSup variable {α : Type*} {f : Filter α} {u v : α → EReal} lemma liminf_neg : liminf (-v) f = -limsup v f := EReal.negOrderIso.limsup_apply.symm lemma limsup_neg : limsup (-v) f = -liminf v f := EReal.negOrderIso.liminf_apply.symm lemma le_liminf_add : (liminf u f) + (liminf v f) ≤ liminf (u + v) f := by refine add_le_of_forall_lt fun a a_u b b_v ↦ (le_liminf_iff).2 fun c c_ab ↦ ?_ filter_upwards [eventually_lt_of_lt_liminf a_u, eventually_lt_of_lt_liminf b_v] with x a_x b_x exact c_ab.trans (add_lt_add a_x b_x) lemma limsup_add_le (h : limsup u f ≠ ⊥ ∨ limsup v f ≠ ⊤) (h' : limsup u f ≠ ⊤ ∨ limsup v f ≠ ⊥) : limsup (u + v) f ≤ (limsup u f) + (limsup v f) := by refine le_add_of_forall_gt h h' fun a a_u b b_v ↦ (limsup_le_iff).2 fun c c_ab ↦ ?_ filter_upwards [eventually_lt_of_limsup_lt a_u, eventually_lt_of_limsup_lt b_v] with x a_x b_x exact (add_lt_add a_x b_x).trans c_ab lemma le_limsup_add : (limsup u f) + (liminf v f) ≤ limsup (u + v) f := add_le_of_forall_lt fun _ a_u _ b_v ↦ (le_limsup_iff).2 fun _ c_ab ↦ (((frequently_lt_of_lt_limsup) a_u).and_eventually ((eventually_lt_of_lt_liminf) b_v)).mono fun _ ab_x ↦ c_ab.trans (add_lt_add ab_x.1 ab_x.2) lemma liminf_add_le (h : limsup u f ≠ ⊥ ∨ liminf v f ≠ ⊤) (h' : limsup u f ≠ ⊤ ∨ liminf v f ≠ ⊥) : liminf (u + v) f ≤ (limsup u f) + (liminf v f) := le_add_of_forall_gt h h' fun _ a_u _ b_v ↦ (liminf_le_iff).2 fun _ c_ab ↦ (((frequently_lt_of_liminf_lt) b_v).and_eventually ((eventually_lt_of_limsup_lt) a_u)).mono fun _ ab_x ↦ (add_lt_add ab_x.2 ab_x.1).trans c_ab lemma limsup_add_bot_of_ne_top (h : limsup u f = ⊥) (h' : limsup v f ≠ ⊤) : limsup (u + v) f = ⊥ := by apply le_bot_iff.1 ((limsup_add_le (.inr h') _).trans _) · rw [h]; exact .inl bot_ne_top · rw [h, bot_add] lemma limsup_add_le_of_le {a b : EReal} (ha : limsup u f < a) (hb : limsup v f ≤ b) : limsup (u + v) f ≤ a + b := by rcases eq_top_or_lt_top b with rfl | h · rw [add_top_of_ne_bot ha.ne_bot]; exact le_top · exact (limsup_add_le (.inr (hb.trans_lt h).ne) (.inl ha.ne_top)).trans (add_le_add ha.le hb) lemma liminf_add_gt_of_gt {a b : EReal} (ha : a < liminf u f) (hb : b < liminf v f) : a + b < liminf (u + v) f := (add_lt_add ha hb).trans_le le_liminf_add lemma liminf_add_top_of_ne_bot (h : liminf u f = ⊤) (h' : liminf v f ≠ ⊥) : liminf (u + v) f = ⊤ := by apply top_le_iff.1 (le_trans _ le_liminf_add) rw [h, top_add_of_ne_bot h'] lemma le_limsup_mul (hu : ∃ᶠ x in f, 0 ≤ u x) (hv : 0 ≤ᶠ[f] v) : limsup u f * liminf v f ≤ limsup (u * v) f := by rcases f.eq_or_neBot with rfl | _ · rw [limsup_bot, limsup_bot, liminf_bot, bot_mul_top] have u0 : 0 ≤ limsup u f := le_limsup_of_frequently_le hu have uv0 : 0 ≤ limsup (u * v) f := le_limsup_of_frequently_le <| (hu.and_eventually hv).mono fun _ ⟨hu, hv⟩ ↦ mul_nonneg hu hv refine mul_le_of_forall_lt_of_nonneg u0 uv0 fun a ha b hb ↦ (le_limsup_iff).2 fun c c_ab ↦ ?_ refine (((frequently_lt_of_lt_limsup) (mem_Ioo.1 ha).2).and_eventually <| (eventually_lt_of_lt_liminf (mem_Ioo.1 hb).2).and <| hv).mono fun x ⟨xa, ⟨xb, vx⟩⟩ ↦ ?_ exact c_ab.trans_le (mul_le_mul xa.le xb.le (mem_Ioo.1 hb).1.le ((mem_Ioo.1 ha).1.le.trans xa.le)) lemma limsup_mul_le (hu : ∃ᶠ x in f, 0 ≤ u x) (hv : 0 ≤ᶠ[f] v) (h₁ : limsup u f ≠ 0 ∨ limsup v f ≠ ⊤) (h₂ : limsup u f ≠ ⊤ ∨ limsup v f ≠ 0) : limsup (u * v) f ≤ limsup u f * limsup v f := by rcases f.eq_or_neBot with rfl | _ · rw [limsup_bot]; exact bot_le have u_0 : 0 ≤ limsup u f := le_limsup_of_frequently_le hu replace h₁ : 0 < limsup u f ∨ limsup v f ≠ ⊤ := h₁.imp_left fun h ↦ lt_of_le_of_ne u_0 h.symm replace h₂ : limsup u f ≠ ⊤ ∨ 0 < limsup v f := h₂.imp_right fun h ↦ lt_of_le_of_ne (le_limsup_of_frequently_le hv.frequently) h.symm refine le_mul_of_forall_lt h₁ h₂ fun a a_u b b_v ↦ (limsup_le_iff).2 fun c c_ab ↦ ?_ filter_upwards [eventually_lt_of_limsup_lt a_u, eventually_lt_of_limsup_lt b_v, hv] with x x_a x_b v_0 apply lt_of_le_of_lt _ c_ab rcases lt_or_ge (u x) 0 with hux | hux · apply (mul_nonpos_iff.2 (.inr ⟨hux.le, v_0⟩)).trans exact mul_nonneg (u_0.trans a_u.le) (v_0.trans x_b.le) · exact mul_le_mul x_a.le x_b.le v_0 (hux.trans x_a.le) lemma le_liminf_mul (hu : 0 ≤ᶠ[f] u) (hv : 0 ≤ᶠ[f] v) : liminf u f * liminf v f ≤ liminf (u * v) f := by apply mul_le_of_forall_lt_of_nonneg ((le_liminf_of_le) hu) <| (le_liminf_of_le) ((hu.and hv).mono fun x ⟨u0, v0⟩ ↦ mul_nonneg u0 v0) refine fun a ha b hb ↦ (le_liminf_iff).2 fun c c_ab ↦ ?_ filter_upwards [eventually_lt_of_lt_liminf (mem_Ioo.1 ha).2, eventually_lt_of_lt_liminf (mem_Ioo.1 hb).2] with x xa xb exact c_ab.trans_le (mul_le_mul xa.le xb.le (mem_Ioo.1 hb).1.le ((mem_Ioo.1 ha).1.le.trans xa.le)) lemma liminf_mul_le [NeBot f] (hu : 0 ≤ᶠ[f] u) (hv : 0 ≤ᶠ[f] v) (h₁ : limsup u f ≠ 0 ∨ liminf v f ≠ ⊤) (h₂ : limsup u f ≠ ⊤ ∨ liminf v f ≠ 0) : liminf (u * v) f ≤ limsup u f * liminf v f := by replace h₁ : 0 < limsup u f ∨ liminf v f ≠ ⊤ := by refine h₁.imp_left fun h ↦ lt_of_le_of_ne ?_ h.symm exact le_of_eq_of_le (limsup_const 0).symm (limsup_le_limsup hu) replace h₂ : limsup u f ≠ ⊤ ∨ 0 < liminf v f := by refine h₂.imp_right fun h ↦ lt_of_le_of_ne ?_ h.symm exact le_of_eq_of_le (liminf_const 0).symm (liminf_le_liminf hv) refine le_mul_of_forall_lt h₁ h₂ fun a a_u b b_v ↦ (liminf_le_iff).2 fun c c_ab ↦ ?_ refine (((frequently_lt_of_liminf_lt) b_v).and_eventually <| (eventually_lt_of_limsup_lt a_u).and <| hu.and hv).mono fun x ⟨x_v, x_u, u_0, v_0⟩ ↦ ?_ exact (mul_le_mul x_u.le x_v.le v_0 (u_0.trans x_u.le)).trans_lt c_ab end LimInfSup /-! ### Continuity of addition -/ theorem continuousAt_add_coe_coe (a b : ℝ) : ContinuousAt (fun p : EReal × EReal => p.1 + p.2) (a, b) := by simp only [ContinuousAt, nhds_coe_coe, ← coe_add, tendsto_map'_iff, Function.comp_def, tendsto_coe, tendsto_add] theorem continuousAt_add_top_coe (a : ℝ) : ContinuousAt (fun p : EReal × EReal => p.1 + p.2) (⊤, a) := by simp only [ContinuousAt, tendsto_nhds_top_iff_real, top_add_coe] refine fun r ↦ ((lt_mem_nhds (coe_lt_top (r - (a - 1)))).prod_nhds (lt_mem_nhds <| EReal.coe_lt_coe_iff.2 <| sub_one_lt _)).mono fun _ h ↦ ?_ simpa only [← coe_add, _root_.sub_add_cancel] using add_lt_add h.1 h.2 theorem continuousAt_add_coe_top (a : ℝ) : ContinuousAt (fun p : EReal × EReal => p.1 + p.2) (a, ⊤) := by simpa only [add_comm, Function.comp_def, ContinuousAt, Prod.swap] using Tendsto.comp (continuousAt_add_top_coe a) (continuous_swap.tendsto ((a : EReal), ⊤)) theorem continuousAt_add_top_top : ContinuousAt (fun p : EReal × EReal => p.1 + p.2) (⊤, ⊤) := by simp only [ContinuousAt, tendsto_nhds_top_iff_real, top_add_top] refine fun r ↦ ((lt_mem_nhds (coe_lt_top 0)).prod_nhds (lt_mem_nhds <| coe_lt_top r)).mono fun _ h ↦ ?_ simpa only [coe_zero, zero_add] using add_lt_add h.1 h.2 theorem continuousAt_add_bot_coe (a : ℝ) : ContinuousAt (fun p : EReal × EReal => p.1 + p.2) (⊥, a) := by simp only [ContinuousAt, tendsto_nhds_bot_iff_real, bot_add] refine fun r ↦ ((gt_mem_nhds (bot_lt_coe (r - (a + 1)))).prod_nhds (gt_mem_nhds <| EReal.coe_lt_coe_iff.2 <| lt_add_one _)).mono fun _ h ↦ ?_ simpa only [← coe_add, _root_.sub_add_cancel] using add_lt_add h.1 h.2 theorem continuousAt_add_coe_bot (a : ℝ) : ContinuousAt (fun p : EReal × EReal => p.1 + p.2) (a, ⊥) := by simpa only [add_comm, Function.comp_def, ContinuousAt, Prod.swap] using Tendsto.comp (continuousAt_add_bot_coe a) (continuous_swap.tendsto ((a : EReal), ⊥)) theorem continuousAt_add_bot_bot : ContinuousAt (fun p : EReal × EReal => p.1 + p.2) (⊥, ⊥) := by simp only [ContinuousAt, tendsto_nhds_bot_iff_real, bot_add] refine fun r ↦ ((gt_mem_nhds (bot_lt_coe 0)).prod_nhds (gt_mem_nhds <| bot_lt_coe r)).mono fun _ h ↦ ?_ simpa only [coe_zero, zero_add] using add_lt_add h.1 h.2 /-- The addition on `EReal` is continuous except where it doesn't make sense (i.e., at `(⊥, ⊤)` and at `(⊤, ⊥)`). -/ theorem continuousAt_add {p : EReal × EReal} (h : p.1 ≠ ⊤ ∨ p.2 ≠ ⊥) (h' : p.1 ≠ ⊥ ∨ p.2 ≠ ⊤) : ContinuousAt (fun p : EReal × EReal => p.1 + p.2) p := by rcases p with ⟨x, y⟩ induction x <;> induction y · exact continuousAt_add_bot_bot · exact continuousAt_add_bot_coe _ · simp at h' · exact continuousAt_add_coe_bot _ · exact continuousAt_add_coe_coe _ _ · exact continuousAt_add_coe_top _ · simp at h · exact continuousAt_add_top_coe _ · exact continuousAt_add_top_top lemma lowerSemicontinuous_add : LowerSemicontinuous fun p : EReal × EReal ↦ p.1 + p.2 := by intro x y by_cases hx₁ : x.1 = ⊥ · simp [hx₁] by_cases hx₂ : x.2 = ⊥ · simp [hx₂] · exact continuousAt_add (.inr hx₂) (.inl hx₁) |>.lowerSemicontinuousAt _ /-! ### Continuity of multiplication -/ /- Outside of indeterminacies `(0, ±∞)` and `(±∞, 0)`, the multiplication on `EReal` is continuous. There are many different cases to consider, so we first prove some special cases and leverage as much as possible the symmetries of the multiplication. -/ private lemma continuousAt_mul_swap {a b : EReal} (h : ContinuousAt (fun p : EReal × EReal ↦ p.1 * p.2) (a, b)) : ContinuousAt (fun p : EReal × EReal ↦ p.1 * p.2) (b, a) := by convert h.comp continuous_swap.continuousAt (x := (b, a)) simp [mul_comm] private lemma continuousAt_mul_symm1 {a b : EReal} (h : ContinuousAt (fun p : EReal × EReal ↦ p.1 * p.2) (a, b)) : ContinuousAt (fun p : EReal × EReal ↦ p.1 * p.2) (-a, b) := by have : (fun p : EReal × EReal ↦ p.1 * p.2) = (fun x : EReal ↦ -x) ∘ (fun p : EReal × EReal ↦ p.1 * p.2) ∘ (fun p : EReal × EReal ↦ (-p.1, p.2)) := by ext p simp rw [this] apply ContinuousAt.comp (Continuous.continuousAt continuous_neg) <| ContinuousAt.comp _ (ContinuousAt.prodMap (Continuous.continuousAt continuous_neg) (Continuous.continuousAt continuous_id)) simp [h] private lemma continuousAt_mul_symm2 {a b : EReal} (h : ContinuousAt (fun p : EReal × EReal ↦ p.1 * p.2) (a, b)) : ContinuousAt (fun p : EReal × EReal ↦ p.1 * p.2) (a, -b) := continuousAt_mul_swap (continuousAt_mul_symm1 (continuousAt_mul_swap h)) private lemma continuousAt_mul_symm3 {a b : EReal} (h : ContinuousAt (fun p : EReal × EReal ↦ p.1 * p.2) (a, b)) : ContinuousAt (fun p : EReal × EReal ↦ p.1 * p.2) (-a, -b) := continuousAt_mul_symm1 (continuousAt_mul_symm2 h) private lemma continuousAt_mul_coe_coe (a b : ℝ) : ContinuousAt (fun p : EReal × EReal ↦ p.1 * p.2) (a, b) := by simp [ContinuousAt, EReal.nhds_coe_coe, ← EReal.coe_mul, Filter.tendsto_map'_iff, Function.comp_def, EReal.tendsto_coe, tendsto_mul] private lemma continuousAt_mul_top_top : ContinuousAt (fun p : EReal × EReal ↦ p.1 * p.2) (⊤, ⊤) := by simp only [ContinuousAt, EReal.top_mul_top, EReal.tendsto_nhds_top_iff_real] intro x rw [_root_.eventually_nhds_iff] use (Set.Ioi ((max x 0) : EReal)) ×ˢ (Set.Ioi 1) split_ands · intro p p_in_prod simp only [Set.mem_prod, Set.mem_Ioi, max_lt_iff] at p_in_prod rcases p_in_prod with ⟨⟨p1_gt_x, p1_pos⟩, p2_gt_1⟩ have := mul_le_mul_of_nonneg_left (le_of_lt p2_gt_1) (le_of_lt p1_pos) rw [mul_one p.1] at this exact lt_of_lt_of_le p1_gt_x this · exact IsOpen.prod isOpen_Ioi isOpen_Ioi · simp · rw [Set.mem_Ioi, ← EReal.coe_one]; exact EReal.coe_lt_top 1 private lemma continuousAt_mul_top_pos {a : ℝ} (h : 0 < a) : ContinuousAt (fun p : EReal × EReal ↦ p.1 * p.2) (⊤, a) := by simp only [ContinuousAt, EReal.top_mul_coe_of_pos h, EReal.tendsto_nhds_top_iff_real] intro x rw [_root_.eventually_nhds_iff] use (Set.Ioi ((2 * (max (x + 1) 0) / a : ℝ) : EReal)) ×ˢ (Set.Ioi ((a / 2 : ℝ) : EReal)) split_ands · intro p p_in_prod simp only [Set.mem_prod, Set.mem_Ioi] at p_in_prod rcases p_in_prod with ⟨p1_gt, p2_gt⟩ have p1_pos : 0 < p.1 := by apply lt_of_le_of_lt _ p1_gt rw [EReal.coe_nonneg] apply mul_nonneg _ (le_of_lt (inv_pos_of_pos h)) simp only [Nat.ofNat_pos, mul_nonneg_iff_of_pos_left, le_max_iff, le_refl, or_true] have a2_pos : 0 < ((a / 2 : ℝ) : EReal) := by rw [EReal.coe_pos]; linarith have lock := mul_le_mul_of_nonneg_right (le_of_lt p1_gt) (le_of_lt a2_pos) have key := mul_le_mul_of_nonneg_left (le_of_lt p2_gt) (le_of_lt p1_pos) replace lock := le_trans lock key apply lt_of_lt_of_le _ lock rw [← EReal.coe_mul, EReal.coe_lt_coe_iff, _root_.div_mul_div_comm, mul_comm, ← _root_.div_mul_div_comm, mul_div_right_comm] simp only [ne_eq, Ne.symm (ne_of_lt h), not_false_eq_true, _root_.div_self, OfNat.ofNat_ne_zero, one_mul, lt_max_iff, lt_add_iff_pos_right, zero_lt_one, true_or] · exact IsOpen.prod isOpen_Ioi isOpen_Ioi · simp · simp [h] private lemma continuousAt_mul_top_ne_zero {a : ℝ} (h : a ≠ 0) : ContinuousAt (fun p : EReal × EReal ↦ p.1 * p.2) (⊤, a) := by rcases lt_or_gt_of_ne h with a_neg | a_pos · exact neg_neg a ▸ continuousAt_mul_symm2 (continuousAt_mul_top_pos (neg_pos.2 a_neg)) · exact continuousAt_mul_top_pos a_pos /-- The multiplication on `EReal` is continuous except at indeterminacies (i.e. whenever one value is zero and the other infinite). -/ theorem continuousAt_mul {p : EReal × EReal} (h₁ : p.1 ≠ 0 ∨ p.2 ≠ ⊥) (h₂ : p.1 ≠ 0 ∨ p.2 ≠ ⊤) (h₃ : p.1 ≠ ⊥ ∨ p.2 ≠ 0) (h₄ : p.1 ≠ ⊤ ∨ p.2 ≠ 0) : ContinuousAt (fun p : EReal × EReal ↦ p.1 * p.2) p := by rcases p with ⟨x, y⟩ induction x <;> induction y · exact continuousAt_mul_symm3 continuousAt_mul_top_top · simp only [ne_eq, not_true_eq_false, EReal.coe_eq_zero, false_or] at h₃ exact continuousAt_mul_symm1 (continuousAt_mul_top_ne_zero h₃) · exact EReal.neg_top ▸ continuousAt_mul_symm1 continuousAt_mul_top_top · simp only [ne_eq, EReal.coe_eq_zero, not_true_eq_false, or_false] at h₁ exact continuousAt_mul_symm2 (continuousAt_mul_swap (continuousAt_mul_top_ne_zero h₁)) · exact continuousAt_mul_coe_coe _ _ · simp only [ne_eq, EReal.coe_eq_zero, not_true_eq_false, or_false] at h₂ exact continuousAt_mul_swap (continuousAt_mul_top_ne_zero h₂) · exact continuousAt_mul_symm2 continuousAt_mul_top_top · simp only [ne_eq, not_true_eq_false, EReal.coe_eq_zero, false_or] at h₄ exact continuousAt_mul_top_ne_zero h₄ · exact continuousAt_mul_top_top variable {a b : EReal} protected theorem tendsto_mul (h₁ : a ≠ 0 ∨ b ≠ ⊥) (h₂ : a ≠ 0 ∨ b ≠ ⊤) (h₃ : a ≠ ⊥ ∨ b ≠ 0) (h₄ : a ≠ ⊤ ∨ b ≠ 0) : Tendsto (fun p : EReal × EReal ↦ p.1 * p.2) (𝓝 (a, b)) (𝓝 (a * b)) := (continuousAt_mul h₁ h₂ h₃ h₄).tendsto protected theorem Tendsto.mul {f : Filter α} {ma : α → EReal} {mb : α → EReal} {a b : EReal} (hma : Tendsto ma f (𝓝 a)) (hmb : Tendsto mb f (𝓝 b)) (h₁ : a ≠ 0 ∨ b ≠ ⊥) (h₂ : a ≠ 0 ∨ b ≠ ⊤) (h₃ : a ≠ ⊥ ∨ b ≠ 0) (h₄ : a ≠ ⊤ ∨ b ≠ 0) : Tendsto (fun x ↦ ma x * mb x) f (𝓝 (a * b)) := (EReal.tendsto_mul h₁ h₂ h₃ h₄).comp (hma.prodMk_nhds hmb) protected theorem Tendsto.const_mul {f : Filter α} {m : α → EReal} {a b : EReal} (hm : Tendsto m f (𝓝 b)) (h₁ : a ≠ ⊥ ∨ b ≠ 0) (h₂ : a ≠ ⊤ ∨ b ≠ 0) : Tendsto (fun b ↦ a * m b) f (𝓝 (a * b)) := by_cases (fun (this : a = 0) => by simp [this, tendsto_const_nhds]) fun ha : a ≠ 0 => EReal.Tendsto.mul tendsto_const_nhds hm (Or.inl ha) (Or.inl ha) h₁ h₂ protected theorem Tendsto.mul_const {f : Filter α} {m : α → EReal} {a b : EReal} (hm : Tendsto m f (𝓝 a)) (h₁ : a ≠ 0 ∨ b ≠ ⊥) (h₂ : a ≠ 0 ∨ b ≠ ⊤) : Tendsto (fun x ↦ m x * b) f (𝓝 (a * b)) := by simpa only [mul_comm] using EReal.Tendsto.const_mul hm h₁.symm h₂.symm end EReal
.lake/packages/mathlib/Mathlib/Topology/Convenient/GeneratedBy.lean
import Mathlib.Topology.ContinuousMap.Basic /-! # The topology that is generated by a family of topological spaces Let `X : ι → Type u` be a family of topological spaces. Let `Y` be a topological space. We introduce a type synonym `WithGeneratedByTopology X Y` for `Y`. This type is endowed with the `X`-generated topology, which is coinduced by all continuous maps `X i → Y`. When the bijection `WithGeneratedByTopology X Y ≃ Y` is an homeomorphism, we say that `Y` is `X`-generated (typeclass `IsGeneratedBy X Y`). ## TODO (@joelriou) * Redefine compactly generated spaces and delta generated spaces using these definitions * Define the category of `X`-generated spaces and show that it is coreflective in `TopCat` * Show that under suitable assumptions, the category of `X`-generated spaces is a closed cartesian monoidal category. ## References * [Rainer M. Vogt, *Convenient categories of topological spaces for homotopy theory*][vogt-1971] * [Martín Escardó, Jimmie Lawson and Alex Simpson, *Comparing Cartesian closed categories of (core) compactly generated spaces*][escardo-lawson-simpson-2004] -/ universe v v' t u open Topology variable {ι : Type t} (X : ι → Type u) [∀ i, TopologicalSpace (X i)] {Y : Type v} [tY : TopologicalSpace Y] {Z : Type v'} [TopologicalSpace Z] namespace TopologicalSpace /-- Given a family of topological spaces `X i`, the `X`-generated topology on a topological space `Y` is the topology that is coinduced by all continuous maps `X i → Y`. -/ def generatedBy : TopologicalSpace Y := ⨆ (i : ι) (f : C(X i, Y)), coinduced f inferInstance end TopologicalSpace variable {X} namespace Topology /-- Given a family of topological spaces `X i`, and a topological space `Y`, this is a type synonym for `Y` which we endow with the `X`-generated topology. -/ @[nolint unusedArguments] def WithGeneratedByTopology (X : ι → Type u) [∀ i, TopologicalSpace (X i)] (Y : Type v) [TopologicalSpace Y] := Y namespace WithGeneratedByTopology /-- The obvious bijection `WithGeneratedByTopology X Y ≃ Y`, where the source is endowed with the `X`-generated topology. See `continuous_equiv` for the continuity of `equiv`. The inverse map `equiv.symm` is continuous iff `Y` is `X`-generated, see `isGeneratedBy_iff`. -/ def equiv : WithGeneratedByTopology X Y ≃ Y := Equiv.refl _ instance {Y : Type v} [TopologicalSpace Y] : TopologicalSpace (WithGeneratedByTopology X Y) := .generatedBy X (Y := Y) lemma isOpen_iff {U : Set (WithGeneratedByTopology X Y)} : IsOpen U ↔ ∀ ⦃i : ι⦄ (f : C(X i, Y)), IsOpen (f ⁻¹' (equiv.symm ⁻¹' U)) := by simp [isOpen_iSup_iff, isOpen_coinduced, equiv, Equiv.refl] lemma isClosed_iff {U : Set (WithGeneratedByTopology X Y)} : IsClosed U ↔ ∀ ⦃i : ι⦄ (f : C(X i, Y)), IsClosed (f ⁻¹' (equiv.symm ⁻¹' U)) := by simp [isClosed_iSup_iff, isClosed_coinduced, equiv, Equiv.refl] lemma continuous_from_iff (g : WithGeneratedByTopology X Y → Z) : Continuous g ↔ ∀ ⦃i : ι⦄ (f : C(X i, Y)), Continuous (g ∘ equiv.symm ∘ f : X i → Z) := by simp only [continuous_iSup_dom] exact forall_congr' (fun i ↦ forall_congr' (fun f ↦ (by rw [continuous_coinduced_dom]; simp [equiv, Equiv.refl]))) @[continuity, fun_prop] lemma continuous_equiv : Continuous (equiv (X := X) (Y := Y)) := by rw [continuous_def] intro U hU rw [isOpen_iff] intro i f exact f.continuous.isOpen_preimage _ hU end WithGeneratedByTopology end Topology variable {tY} in lemma TopologicalSpace.generatedBy_le : generatedBy X ≤ tY := fun U hU ↦ WithGeneratedByTopology.continuous_equiv.isOpen_preimage U hU omit tY in lemma TopologicalSpace.generatedBy_mono {t₁ t₂ : TopologicalSpace Y} (h : t₁ ≤ t₂) : t₁.generatedBy X ≤ t₂.generatedBy X := iSup₂_le fun i f ↦ le_iSup₂_of_le i ⟨f, continuous_le_rng h @f.2⟩ le_rfl namespace Topology variable (X Y) in /-- Given a family of topological spaces `X i`, we say that a topological space is `X`-generated (`IsGeneratedBy X Y`) when the topology on `Y` is the `X`-generated topology, i.e. when the identity is an homeomorphism `WithGeneratedByTopology X Y ≃ₜ Y` (see `IsGeneratedBy.homeomorph`). -/ @[mk_iff] class IsGeneratedBy : Prop where continuous_equiv_symm : Continuous (WithGeneratedByTopology.equiv (X := X) (Y := Y)).symm namespace IsGeneratedBy attribute [continuity] continuous_equiv_symm section variable {tY} lemma le_generatedBy [IsGeneratedBy X Y] : tY ≤ .generatedBy X := fun U hU ↦ continuous_equiv_symm.isOpen_preimage U hU lemma generatedBy_eq [IsGeneratedBy X Y] : .generatedBy X = tY := le_antisymm TopologicalSpace.generatedBy_le le_generatedBy lemma iff_le_generatedBy : IsGeneratedBy X Y ↔ tY ≤ .generatedBy X := ⟨fun _ ↦ le_generatedBy, fun h ↦ ⟨by rwa [continuous_def]⟩⟩ end section variable [IsGeneratedBy X Y] /-- The homeomorphism `WithGeneratedByTopology X Y ≃ₜ Y` when `Y` is `X`-generated. -/ def homeomorph [IsGeneratedBy X Y] : WithGeneratedByTopology X Y ≃ₜ Y where toEquiv := WithGeneratedByTopology.equiv continuous_toFun := by continuity continuous_invFun := by continuity @[simp] lemma homeomorph_coe : ⇑(homeomorph (X := X) (Y := Y)) = WithGeneratedByTopology.equiv := rfl @[simp] lemma homeomorph_symm_coe : ⇑(homeomorph (X := X) (Y := Y)).symm = WithGeneratedByTopology.equiv.symm := rfl variable (X) lemma isOpen_iff {U : Set Y} : IsOpen U ↔ ∀ ⦃i : ι⦄ (f : C(X i, Y)), IsOpen (f ⁻¹' U) := by simp [← (homeomorph (X := X)).isQuotientMap.isOpen_preimage, WithGeneratedByTopology.isOpen_iff] lemma isClosed_iff {U : Set Y} : IsClosed U ↔ ∀ ⦃i : ι⦄ (f : C(X i, Y)), IsClosed (f ⁻¹' U) := by simp [← (homeomorph (X := X)).isQuotientMap.isClosed_preimage, WithGeneratedByTopology.isClosed_iff] lemma continuous_iff (g : Y → Z) : Continuous g ↔ ∀ ⦃i : ι⦄ (f : C(X i, Y)), Continuous (g ∘ f) := by rw [(homeomorph (X := X)).isQuotientMap.continuous_iff, WithGeneratedByTopology.continuous_from_iff] simp [Function.comp_assoc g, ← Function.comp_assoc WithGeneratedByTopology.equiv] lemma equiv_symm_comp_continuous_iff (g : Y → Z) : Continuous ((WithGeneratedByTopology.equiv (X := X)).symm ∘ g) ↔ Continuous g := by refine ⟨fun hg ↦ WithGeneratedByTopology.continuous_equiv.comp hg, fun hg ↦ ?_⟩ rw [continuous_iff (X := X)] intro i f rw [continuous_def] intro U hU rw [WithGeneratedByTopology.isOpen_iff] at hU exact hU (ContinuousMap.comp ⟨g, hg⟩ f) end instance (i : ι) : IsGeneratedBy X (X i) where continuous_equiv_symm := by rw [continuous_def] intro U hU rw [WithGeneratedByTopology.isOpen_iff] at hU exact hU ⟨_, continuous_id⟩ instance : IsGeneratedBy X (WithGeneratedByTopology X Y) where continuous_equiv_symm := by rw [continuous_def] intro U hU rw [WithGeneratedByTopology.isOpen_iff] at hU ⊢ intro i f refine hU ⟨WithGeneratedByTopology.equiv.symm ∘ f, ?_⟩ rw [continuous_iff X] intro j g rw [Function.comp_assoc, equiv_symm_comp_continuous_iff] continuity instance : IsGeneratedBy X (PUnit.{v + 1}) := by rw [iff_le_generatedBy] exact Eq.le (by subsingleton) omit [TopologicalSpace Z] /-- Any topology coinduced by an `X`-generated topology is `X`-generated. -/ protected lemma coinduced [IsGeneratedBy X Y] (f : Y → Z) : IsGeneratedBy X (tY := tY.coinduced f) := by let _ := tY.coinduced f refine iff_le_generatedBy.2 ?_ exact ((equiv_symm_comp_continuous_iff (X := X) f).2 continuous_coinduced_rng).coinduced_le /-- Suprema of `X`-generated topologies are `X`-generated. -/ protected lemma iSup {Y : Type*} {κ : Sort*} {t : κ → TopologicalSpace Y} (h : ∀ k, IsGeneratedBy X (tY := t k)) : @IsGeneratedBy _ X _ Y (⨆ k, t k) := iff_le_generatedBy.2 <| iSup_le_iff.2 fun k ↦ (h k).le_generatedBy.trans <| TopologicalSpace.generatedBy_mono <| le_iSup t k /-- Suprema of `X`-generated topologies are `X`-generated. -/ protected lemma sup {Y : Type*} {t₁ t₂ : TopologicalSpace Y} (h₁ : IsGeneratedBy X (tY := t₁)) (h₂ : @IsGeneratedBy _ X _ Y t₂) : IsGeneratedBy X (tY := t₁ ⊔ t₂) := by rw [sup_eq_iSup] exact .iSup <| Bool.forall_bool.2 ⟨h₂, h₁⟩ end IsGeneratedBy lemma IsQuotientMap.isGeneratedBy {f : Y → Z} (hf : IsQuotientMap f) [IsGeneratedBy X Y] : IsGeneratedBy X Z := hf.eq_coinduced ▸ IsGeneratedBy.coinduced f end Topology /-- Quotients of `X`-generated spaces are `X`-generated. -/ instance Quot.isGeneratedBy [IsGeneratedBy X Y] {r : Y → Y → Prop} : IsGeneratedBy X (Quot r) := isQuotientMap_quot_mk.isGeneratedBy /-- Quotients of `X`-generated spaces are `X`-generated. -/ instance Quotient.isGeneratedBy [IsGeneratedBy X Y] {s : Setoid Y} : IsGeneratedBy X (Quotient s) := isQuotientMap_quotient_mk'.isGeneratedBy /-- Disjoint unions of `X`-generated spaces are `X`-generated. -/ instance Sum.isGeneratedBy [IsGeneratedBy X Y] [IsGeneratedBy X Z] : IsGeneratedBy X (Y ⊕ Z) := IsGeneratedBy.sup (.coinduced Sum.inl) (.coinduced Sum.inr) /-- Disjoint unions of `X`-generated spaces are `X`-generated. -/ instance Sigma.isGeneratedBy {κ : Type*} {Y : κ → Type*} [∀ k, TopologicalSpace (Y k)] [∀ k, IsGeneratedBy X (Y k)] : IsGeneratedBy X (Σ k, Y k) := .iSup fun _ ↦ .coinduced _
.lake/packages/mathlib/Mathlib/Topology/Compactness/CompactlyGeneratedSpace.lean
import Mathlib.Topology.Category.CompHaus.Basic import Mathlib.Topology.Compactification.OnePoint.Basic /-! # Compactly generated topological spaces This file defines compactly generated topological spaces. A compactly generated space is a space `X` whose topology is coinduced by continuous maps from compact Hausdorff spaces to `X`. In such a space, a set `s` is closed (resp. open) if and only if for all compact Hausdorff space `K` and `f : K → X` continuous, `f ⁻¹' s` is closed (resp. open) in `K`. We provide two definitions. `UCompactlyGeneratedSpace.{u} X` corresponds to the type class where the compact Hausdorff spaces are taken in an arbitrary universe `u`, and should therefore always be used with an explicit universe parameter. It is intended for categorical purposes. `CompactlyGeneratedSpace X` corresponds to the case where compact Hausdorff spaces are taken in the same universe as `X`, and is intended for topological purposes. We prove basic properties and instances, and prove that a `SequentialSpace` is compactly generated, as well as a Hausdorff `WeaklyLocallyCompactSpace`. ## Main definitions * `UCompactlyGeneratedSpace.{u} X`: the topology of `X` is coinduced by continuous maps coming from compact Hausdorff spaces in universe `u`. * `CompactlyGeneratedSpace X`: the topology of `X` is coinduced by continuous maps coming from compact Hausdorff spaces in the same universe as `X`. ## References * <https://en.wikipedia.org/wiki/Compactly_generated_space> * <https://ncatlab.org/nlab/files/StricklandCGHWSpaces.pdf> ## Tags compactly generated space -/ universe u v w x open TopologicalSpace Filter Topology Set section UCompactlyGeneratedSpace variable {X : Type w} {Y : Type x} /-- The compactly generated topology on a topological space `X`. This is the finest topology which makes all maps from compact Hausdorff spaces to `X`, which are continuous for the original topology, continuous. Note: this definition should be used with an explicit universe parameter `u` for the size of the compact Hausdorff spaces mapping to `X`. -/ def TopologicalSpace.compactlyGenerated (X : Type w) [TopologicalSpace X] : TopologicalSpace X := let f : (Σ (i : (S : CompHaus.{u}) × C(S, X)), i.fst) → X := fun ⟨⟨_, i⟩, s⟩ ↦ i s coinduced f inferInstance lemma continuous_from_compactlyGenerated [TopologicalSpace X] [t : TopologicalSpace Y] (f : X → Y) (h : ∀ (S : CompHaus.{u}) (g : C(S, X)), Continuous (f ∘ g)) : Continuous[compactlyGenerated.{u} X, t] f := by rw [continuous_coinduced_dom] continuity /-- A topological space `X` is compactly generated if its topology is finer than (and thus equal to) the compactly generated topology, i.e. it is coinduced by the continuous maps from compact Hausdorff spaces to `X`. This version includes an explicit universe parameter `u` which should always be specified. It is intended for categorical purposes. See `CompactlyGeneratedSpace` for the version without this parameter, intended for topological purposes. -/ class UCompactlyGeneratedSpace (X : Type v) [t : TopologicalSpace X] : Prop where /-- The topology of `X` is finer than the compactly generated topology. -/ le_compactlyGenerated : t ≤ compactlyGenerated.{u} X lemma eq_compactlyGenerated [t : TopologicalSpace X] [UCompactlyGeneratedSpace.{u} X] : t = compactlyGenerated.{u} X := by apply le_antisymm · exact UCompactlyGeneratedSpace.le_compactlyGenerated · simp only [compactlyGenerated, ← continuous_iff_coinduced_le, continuous_sigma_iff, Sigma.forall] exact fun S f ↦ f.2 instance (X : Type v) [t : TopologicalSpace X] [DiscreteTopology X] : UCompactlyGeneratedSpace.{u} X where le_compactlyGenerated := by rw [DiscreteTopology.eq_bot (t := t)] exact bot_le /- The unused variable linter flags `[tY : TopologicalSpace Y]`, but we want to use this as a named argument, so we need to disable the linter. -/ set_option linter.unusedVariables false in /-- Let `f : X → Y`. Suppose that to prove that `f` is continuous, it suffices to show that for every compact Hausdorff space `K` and every continuous map `g : K → X`, `f ∘ g` is continuous. Then `X` is compactly generated. -/ lemma uCompactlyGeneratedSpace_of_continuous_maps [t : TopologicalSpace X] (h : ∀ {Y : Type w} [tY : TopologicalSpace Y] (f : X → Y), (∀ (S : CompHaus.{u}) (g : C(S, X)), Continuous (f ∘ g)) → Continuous f) : UCompactlyGeneratedSpace.{u} X where le_compactlyGenerated := by suffices Continuous[t, compactlyGenerated.{u} X] (id : X → X) by rwa [← continuous_id_iff_le] apply h (tY := compactlyGenerated.{u} X) intro S g let f : (Σ (i : (T : CompHaus.{u}) × C(T, X)), i.fst) → X := fun ⟨⟨_, i⟩, s⟩ ↦ i s suffices ∀ (i : (T : CompHaus.{u}) × C(T, X)), Continuous[inferInstance, compactlyGenerated X] (fun (a : i.fst) ↦ f ⟨i, a⟩) from this ⟨S, g⟩ rw [← @continuous_sigma_iff] apply continuous_coinduced_rng variable [tX : TopologicalSpace X] [tY : TopologicalSpace Y] /-- If `X` is compactly generated, to prove that `f : X → Y` is continuous it is enough to show that for every compact Hausdorff space `K` and every continuous map `g : K → X`, `f ∘ g` is continuous. -/ lemma continuous_from_uCompactlyGeneratedSpace [UCompactlyGeneratedSpace.{u} X] (f : X → Y) (h : ∀ (S : CompHaus.{u}) (g : C(S, X)), Continuous (f ∘ g)) : Continuous f := by apply continuous_le_dom UCompactlyGeneratedSpace.le_compactlyGenerated exact continuous_from_compactlyGenerated f h /-- A topological space `X` is compactly generated if a set `s` is closed when `f ⁻¹' s` is closed for every continuous map `f : K → X`, where `K` is compact Hausdorff. -/ theorem uCompactlyGeneratedSpace_of_isClosed (h : ∀ (s : Set X), (∀ (S : CompHaus.{u}) (f : C(S, X)), IsClosed (f ⁻¹' s)) → IsClosed s) : UCompactlyGeneratedSpace.{u} X := uCompactlyGeneratedSpace_of_continuous_maps fun _ h' ↦ continuous_iff_isClosed.2 fun _ hs ↦ h _ fun S g ↦ hs.preimage (h' S g) /-- A topological space `X` is compactly generated if a set `s` is open when `f ⁻¹' s` is open for every continuous map `f : K → X`, where `K` is compact Hausdorff. -/ theorem uCompactlyGeneratedSpace_of_isOpen (h : ∀ (s : Set X), (∀ (S : CompHaus.{u}) (f : C(S, X)), IsOpen (f ⁻¹' s)) → IsOpen s) : UCompactlyGeneratedSpace.{u} X := uCompactlyGeneratedSpace_of_continuous_maps fun _ h' ↦ continuous_def.2 fun _ hs ↦ h _ fun S g ↦ hs.preimage (h' S g) /-- In a compactly generated space `X`, a set `s` is closed when `f ⁻¹' s` is closed for every continuous map `f : K → X`, where `K` is compact Hausdorff. -/ theorem UCompactlyGeneratedSpace.isClosed [UCompactlyGeneratedSpace.{u} X] {s : Set X} (hs : ∀ (S : CompHaus.{u}) (f : C(S, X)), IsClosed (f ⁻¹' s)) : IsClosed s := by rw [eq_compactlyGenerated (X := X), TopologicalSpace.compactlyGenerated, isClosed_coinduced, isClosed_sigma_iff] exact fun ⟨S, f⟩ ↦ hs S f /-- In a compactly generated space `X`, a set `s` is open when `f ⁻¹' s` is open for every continuous map `f : K → X`, where `K` is compact Hausdorff. -/ theorem UCompactlyGeneratedSpace.isOpen [UCompactlyGeneratedSpace.{u} X] {s : Set X} (hs : ∀ (S : CompHaus.{u}) (f : C(S, X)), IsOpen (f ⁻¹' s)) : IsOpen s := by rw [eq_compactlyGenerated (X := X), TopologicalSpace.compactlyGenerated, isOpen_coinduced, isOpen_sigma_iff] exact fun ⟨S, f⟩ ↦ hs S f /-- If the topology of `X` is coinduced by a continuous function whose domain is compactly generated, then so is `X`. -/ theorem uCompactlyGeneratedSpace_of_coinduced [UCompactlyGeneratedSpace.{u} X] {f : X → Y} (hf : Continuous f) (ht : tY = coinduced f tX) : UCompactlyGeneratedSpace.{u} Y := by refine uCompactlyGeneratedSpace_of_isClosed fun s h ↦ ?_ rw [ht, isClosed_coinduced] exact UCompactlyGeneratedSpace.isClosed fun _ ⟨g, hg⟩ ↦ h _ ⟨_, hf.comp hg⟩ /-- The quotient of a compactly generated space is compactly generated. -/ instance {S : Setoid X} [UCompactlyGeneratedSpace.{u} X] : UCompactlyGeneratedSpace.{u} (Quotient S) := uCompactlyGeneratedSpace_of_coinduced continuous_quotient_mk' rfl /-- The sum of two compactly generated spaces is compactly generated. -/ instance [UCompactlyGeneratedSpace.{u} X] [UCompactlyGeneratedSpace.{v} Y] : UCompactlyGeneratedSpace.{max u v} (X ⊕ Y) := by refine uCompactlyGeneratedSpace_of_isClosed fun s h ↦ isClosed_sum_iff.2 ⟨?_, ?_⟩ all_goals refine UCompactlyGeneratedSpace.isClosed fun S ⟨f, hf⟩ ↦ ?_ · let g : ULift.{v} S → X ⊕ Y := Sum.inl ∘ f ∘ ULift.down have hg : Continuous g := continuous_inl.comp <| hf.comp continuous_uliftDown exact (h (CompHaus.of (ULift.{v} S)) ⟨g, hg⟩).preimage continuous_uliftUp · let g : ULift.{u} S → X ⊕ Y := Sum.inr ∘ f ∘ ULift.down have hg : Continuous g := continuous_inr.comp <| hf.comp continuous_uliftDown exact (h (CompHaus.of (ULift.{u} S)) ⟨g, hg⟩).preimage continuous_uliftUp /-- The sigma type associated to a family of compactly generated spaces is compactly generated. -/ instance {ι : Type v} {X : ι → Type w} [∀ i, TopologicalSpace (X i)] [∀ i, UCompactlyGeneratedSpace.{u} (X i)] : UCompactlyGeneratedSpace.{u} (Σ i, X i) := uCompactlyGeneratedSpace_of_isClosed fun _ h ↦ isClosed_sigma_iff.2 fun i ↦ UCompactlyGeneratedSpace.isClosed fun S ⟨f, hf⟩ ↦ h S ⟨Sigma.mk i ∘ f, continuous_sigmaMk.comp hf⟩ open OnePoint in /-- A sequential space is compactly generated. The proof is taken from <https://ncatlab.org/nlab/files/StricklandCGHWSpaces.pdf>, Proposition 1.6. -/ instance (priority := 100) [SequentialSpace X] : UCompactlyGeneratedSpace.{u} X := by refine uCompactlyGeneratedSpace_of_isClosed fun s h ↦ SequentialSpace.isClosed_of_seq _ fun u p hu hup ↦ ?_ let g : ULift.{u} (OnePoint ℕ) → X := (continuousMapMkNat u p hup) ∘ ULift.down change ULift.up ∞ ∈ g ⁻¹' s have : Filter.Tendsto (@OnePoint.some ℕ) Filter.atTop (𝓝 ∞) := by rw [← Nat.cofinite_eq_atTop, ← cocompact_eq_cofinite, ← coclosedCompact_eq_cocompact] exact tendsto_coe_infty apply IsClosed.mem_of_tendsto _ ((continuous_uliftUp.tendsto ∞).comp this) · simp only [Function.comp_apply, mem_preimage, eventually_atTop, ge_iff_le] exact ⟨0, fun b _ ↦ hu b⟩ · exact h (CompHaus.of (ULift.{u} (OnePoint ℕ))) ⟨g, by fun_prop⟩ end UCompactlyGeneratedSpace section CompactlyGeneratedSpace variable {X : Type u} {Y : Type v} [TopologicalSpace X] [TopologicalSpace Y] /-- A topological space `X` is compactly generated if its topology is finer than (and thus equal to) the compactly generated topology, i.e. it is coinduced by the continuous maps from compact Hausdorff spaces to `X`. In this version, intended for topological purposes, the compact spaces are taken in the same universe as `X`. See `UCompactlyGeneratedSpace` for a version with an explicit universe parameter, intended for categorical purposes. -/ abbrev CompactlyGeneratedSpace (X : Type u) [TopologicalSpace X] : Prop := UCompactlyGeneratedSpace.{u} X /-- If `X` is compactly generated, to prove that `f : X → Y` is continuous it is enough to show that for every compact Hausdorff space `K` and every continuous map `g : K → X`, `f ∘ g` is continuous. -/ lemma continuous_from_compactlyGeneratedSpace [CompactlyGeneratedSpace X] (f : X → Y) (h : ∀ (K : Type u) [TopologicalSpace K], [CompactSpace K] → [T2Space K] → (∀ g : K → X, Continuous g → Continuous (f ∘ g))) : Continuous f := continuous_from_uCompactlyGeneratedSpace f fun K ⟨g, hg⟩ ↦ h K g hg /-- Let `f : X → Y`. Suppose that to prove that `f` is continuous, it suffices to show that for every compact Hausdorff space `K` and every continuous map `g : K → X`, `f ∘ g` is continuous. Then `X` is compactly generated. -/ lemma compactlyGeneratedSpace_of_continuous_maps (h : ∀ {Y : Type u} [TopologicalSpace Y] (f : X → Y), (∀ (K : Type u) [TopologicalSpace K], [CompactSpace K] → [T2Space K] → (∀ g : K → X, Continuous g → Continuous (f ∘ g))) → Continuous f) : CompactlyGeneratedSpace X := uCompactlyGeneratedSpace_of_continuous_maps fun f h' ↦ h f fun K _ _ _ g hg ↦ h' (CompHaus.of K) ⟨g, hg⟩ /-- A topological space `X` is compactly generated if a set `s` is closed when `f ⁻¹' s` is closed for every continuous map `f : K → X`, where `K` is compact Hausdorff. -/ theorem compactlyGeneratedSpace_of_isClosed (h : ∀ (s : Set X), (∀ (K : Type u) [TopologicalSpace K], [CompactSpace K] → [T2Space K] → ∀ (f : K → X), Continuous f → IsClosed (f ⁻¹' s)) → IsClosed s) : CompactlyGeneratedSpace X := uCompactlyGeneratedSpace_of_isClosed fun s h' ↦ h s fun K _ _ _ f hf ↦ h' (CompHaus.of K) ⟨f, hf⟩ /-- In a compactly generated space `X`, a set `s` is closed when `f ⁻¹' s` is closed for every continuous map `f : K → X`, where `K` is compact Hausdorff. -/ theorem CompactlyGeneratedSpace.isClosed' [CompactlyGeneratedSpace X] {s : Set X} (hs : ∀ (K : Type u) [TopologicalSpace K], [CompactSpace K] → [T2Space K] → ∀ (f : K → X), Continuous f → IsClosed (f ⁻¹' s)) : IsClosed s := UCompactlyGeneratedSpace.isClosed fun S ⟨f, hf⟩ ↦ hs S f hf /-- In a compactly generated space `X`, a set `s` is closed when `s ∩ K` is closed for every compact set `K`. -/ theorem CompactlyGeneratedSpace.isClosed [CompactlyGeneratedSpace X] {s : Set X} (hs : ∀ ⦃K⦄, IsCompact K → IsClosed (s ∩ K)) : IsClosed s := by refine isClosed' fun K _ _ _ f hf ↦ ?_ rw [← Set.preimage_inter_range] exact (hs (isCompact_range hf)).preimage hf /-- A topological space `X` is compactly generated if a set `s` is open when `f ⁻¹' s` is open for every continuous map `f : K → X`, where `K` is compact Hausdorff. -/ theorem compactlyGeneratedSpace_of_isOpen (h : ∀ (s : Set X), (∀ (K : Type u) [TopologicalSpace K], [CompactSpace K] → [T2Space K] → ∀ (f : K → X), Continuous f → IsOpen (f ⁻¹' s)) → IsOpen s) : CompactlyGeneratedSpace X := uCompactlyGeneratedSpace_of_isOpen fun s h' ↦ h s fun K _ _ _ f hf ↦ h' (CompHaus.of K) ⟨f, hf⟩ /-- In a compactly generated space `X`, a set `s` is open when `f ⁻¹' s` is open for every continuous map `f : K → X`, where `K` is compact Hausdorff. -/ theorem CompactlyGeneratedSpace.isOpen' [CompactlyGeneratedSpace X] {s : Set X} (hs : ∀ (K : Type u) [TopologicalSpace K], [CompactSpace K] → [T2Space K] → ∀ (f : K → X), Continuous f → IsOpen (f ⁻¹' s)) : IsOpen s := UCompactlyGeneratedSpace.isOpen fun S ⟨f, hf⟩ ↦ hs S f hf /-- In a compactly generated space `X`, a set `s` is open when `s ∩ K` is closed for every open set `K`. -/ theorem CompactlyGeneratedSpace.isOpen [CompactlyGeneratedSpace X] {s : Set X} (hs : ∀ ⦃K⦄, IsCompact K → IsOpen (s ∩ K)) : IsOpen s := by refine isOpen' fun K _ _ _ f hf ↦ ?_ rw [← Set.preimage_inter_range] exact (hs (isCompact_range hf)).preimage hf /-- If the topology of `X` is coinduced by a continuous function whose domain is compactly generated, then so is `X`. -/ theorem compactlyGeneratedSpace_of_coinduced {X : Type u} [tX : TopologicalSpace X] {Y : Type u} [tY : TopologicalSpace Y] [CompactlyGeneratedSpace X] {f : X → Y} (hf : Continuous f) (ht : tY = coinduced f tX) : CompactlyGeneratedSpace Y := uCompactlyGeneratedSpace_of_coinduced hf ht /-- The sigma type associated to a family of compactly generated spaces is compactly generated. -/ instance {ι : Type u} {X : ι → Type v} [∀ i, TopologicalSpace (X i)] [∀ i, CompactlyGeneratedSpace (X i)] : CompactlyGeneratedSpace (Σ i, X i) := by refine compactlyGeneratedSpace_of_isClosed fun s h ↦ isClosed_sigma_iff.2 fun i ↦ CompactlyGeneratedSpace.isClosed' fun K _ _ _ f hf ↦ ?_ let g : ULift.{u} K → (Σ i, X i) := Sigma.mk i ∘ f ∘ ULift.down have hg : Continuous g := continuous_sigmaMk.comp <| hf.comp continuous_uliftDown exact (h _ g hg).preimage continuous_uliftUp variable [T2Space X] theorem CompactlyGeneratedSpace.isClosed_iff_of_t2 [CompactlyGeneratedSpace X] (s : Set X) : IsClosed s ↔ ∀ ⦃K⦄, IsCompact K → IsClosed (s ∩ K) where mp hs _ hK := hs.inter hK.isClosed mpr := CompactlyGeneratedSpace.isClosed /-- Let `s ⊆ X`. Suppose that `X` is Hausdorff, and that to prove that `s` is closed, it suffices to show that for every compact set `K ⊆ X`, `s ∩ K` is closed. Then `X` is compactly generated. -/ theorem compactlyGeneratedSpace_of_isClosed_of_t2 (h : ∀ s, (∀ (K : Set X), IsCompact K → IsClosed (s ∩ K)) → IsClosed s) : CompactlyGeneratedSpace X := by refine compactlyGeneratedSpace_of_isClosed fun s hs ↦ h s fun K hK ↦ ?_ rw [Set.inter_comm, ← Subtype.image_preimage_coe] apply hK.isClosed.isClosedMap_subtype_val have : CompactSpace ↑K := isCompact_iff_compactSpace.1 hK exact hs _ Subtype.val continuous_subtype_val open scoped Set.Notation in /-- Let `s ⊆ X`. Suppose that `X` is Hausdorff, and that to prove that `s` is open, it suffices to show that for every compact set `K ⊆ X`, `s ∩ K` is open in `K`. Then `X` is compactly generated. -/ theorem compactlyGeneratedSpace_of_isOpen_of_t2 (h : ∀ s, (∀ (K : Set X), IsCompact K → IsOpen (K ↓∩ s)) → IsOpen s) : CompactlyGeneratedSpace X := by refine compactlyGeneratedSpace_of_isOpen fun s hs ↦ h s fun K hK ↦ ?_ have : CompactSpace ↑K := isCompact_iff_compactSpace.1 hK exact hs _ Subtype.val continuous_subtype_val /-- A Hausdorff and weakly locally compact space is compactly generated. -/ instance (priority := 100) [WeaklyLocallyCompactSpace X] : CompactlyGeneratedSpace X := by refine compactlyGeneratedSpace_of_isClosed_of_t2 fun s h ↦ ?_ rw [isClosed_iff_forall_filter] intro x ℱ hℱ₁ hℱ₂ hℱ₃ rcases exists_compact_mem_nhds x with ⟨K, hK, K_mem⟩ exact Set.mem_of_mem_inter_left <| isClosed_iff_forall_filter.1 (h _ hK) x ℱ hℱ₁ (Filter.inf_principal ▸ le_inf hℱ₂ (le_trans hℱ₃ <| Filter.le_principal_iff.2 K_mem)) hℱ₃ /-- Every compactly generated space is a compactly coherent space. -/ instance to_compactlyCoherentSpace [CompactlyGeneratedSpace X] : CompactlyCoherentSpace X := CompactlyCoherentSpace.of_isOpen_forall_compactSpace fun _ h ↦ CompactlyGeneratedSpace.isOpen' fun K _ _ _ f hf ↦ h K f hf /-- A compactly coherent space that is Hausdorff is compactly generated. -/ instance of_compactlyCoherentSpace_of_t2 [T2Space X] [CompactlyCoherentSpace X] : CompactlyGeneratedSpace X := by apply compactlyGeneratedSpace_of_isClosed_of_t2 intro s hs rw [CompactlyCoherentSpace.isClosed_iff] intro K hK rw [← Subtype.preimage_coe_inter_self] exact (hs K hK).preimage_val end CompactlyGeneratedSpace
.lake/packages/mathlib/Mathlib/Topology/Compactness/Exterior.lean
import Mathlib.Topology.Compactness.NhdsKer deprecated_module (since := "2025-07-09")
.lake/packages/mathlib/Mathlib/Topology/Compactness/HilbertCubeEmbedding.lean
import Mathlib.Topology.UnitInterval /-! # Every compact metric space can be embedded into the Hilbert cube. In this file we prove `exists_closed_embedding_to_hilbert`: every compact metric space can be embedded into the Hilbert cube (`ℕ → unitInterval`). -/ /-- Every compact metric space can be embedded into the Hilbert cube. -/ theorem exists_closed_embedding_to_hilbert_cube (X : Type*) [MetricSpace X] [CompactSpace X] : ∃ f : X → (ℕ → unitInterval), Topology.IsClosedEmbedding f := by obtain _ | _ := subsingleton_or_nontrivial X · use Function.const _ 0 exact continuous_const.isClosedEmbedding <| Function.injective_of_subsingleton _ let s := TopologicalSpace.denseSeq X have s_dense : DenseRange s := TopologicalSpace.denseRange_denseSeq X let diam := Metric.diam (Set.univ : Set X) have dist_le_diam : ∀ x y, dist x y ≤ diam := fun x y ↦ Metric.dist_le_diam_of_mem isCompact_univ.isBounded trivial trivial have diam_pos : 0 < diam := Metric.diam_pos (by rwa [Set.nontrivial_univ_iff]) isCompact_univ.isBounded let f : X → (ℕ → unitInterval) := fun x i => ⟨dist x (s i) / diam, by positivity, div_le_one_of_le₀ (dist_le_diam _ _) Metric.diam_nonneg⟩ use f apply Continuous.isClosedEmbedding · fun_prop intro x y hxy simp only [f] at hxy suffices dist x y = 0 from eq_of_dist_eq_zero this suffices dist x = dist y from dist_self y ▸ congrFun this y apply s_dense.equalizer (by fun_prop) (by fun_prop) ext i rw [← div_left_inj' diam_pos.ne'] exact congr(((↑) : unitInterval → ℝ) ($hxy i))
.lake/packages/mathlib/Mathlib/Topology/Compactness/CompactlyCoherentSpace.lean
import Mathlib.Topology.Coherent import Mathlib.Topology.Compactness.Compact /-! # Compactly coherent spaces and the k-ification In this file we will define compactly coherent spaces and prove basic properties about them. This is a weaker version of `CompactlyGeneratedSpace`. These notions agree on Hausdorff spaces. They are both referred to as compactly generated spaces in the literature. ## Main definitions * `CompactlyCoherentSpace`: A compactly coherent space is a topological space in which a set `A` is open iff for every compact set `B`, the intersection `A ∩ B` is open in `B`. ## Main results * `CompactlyCoherentSpace.of_weaklyLocallyCompactSpace`: every weakly locally compact space is a compactly coherent space. * `CompactlyCoherentSpace.of_sequentialSpace`: every sequential space is a compactly coherent space. ## References * [J. Munkres, *Topology*][Munkres2000] * <https://en.wikipedia.org/wiki/Compactly_generated_space> -/ noncomputable section open Set Set.Notation Topology /-! ### Compactly coherent spaces-/ /-- A space is a compactly coherent space if the topology is generated by the compact sets. -/ class CompactlyCoherentSpace (X : Type*) [TopologicalSpace X] : Prop where /-- A space is a compactly coherent space if the topology is generated by the compact sets. -/ isCoherentWith : IsCoherentWith (X := X) {K | IsCompact K} namespace CompactlyCoherentSpace universe u variable {X : Type u} [TopologicalSpace X] /-- A set `A` in a compactly coherent space is open iff for every compact set `K`, the intersection `K ∩ A` is open in `K`. -/ lemma isOpen_iff [CompactlyCoherentSpace X] {A : Set X} : IsOpen A ↔ ∀ K, IsCompact K → IsOpen (K ↓∩ A) := IsCoherentWith.isOpen_iff isCoherentWith /-- A set `A` in a compactly coherent space is closed iff for every compact set `K`, the intersection `K ∩ A` is closed in `K`. -/ lemma isClosed_iff [CompactlyCoherentSpace X] (A : Set X) : IsClosed A ↔ ∀ K, IsCompact K → IsClosed (K ↓∩ A) := IsCoherentWith.isClosed_iff isCoherentWith /-- If every set `A` is open if for every compact `K` the intersection `K ∩ A` is open in `K`, then the space is a compactly coherent space. -/ lemma of_isOpen (h : ∀ (A : Set X), (∀ K, IsCompact K → IsOpen (K ↓∩ A)) → IsOpen A) : CompactlyCoherentSpace X where isCoherentWith := {isOpen_of_forall_induced := h} /-- If every set `A` is closed if for every compact `K` the intersection `K ∩ A` is closed in `K`, then the space is a compactly coherent space. -/ lemma of_isClosed (h : ∀ (A : Set X), (∀ K, IsCompact K → IsClosed (K ↓∩ A)) → IsClosed A) : CompactlyCoherentSpace X where isCoherentWith := IsCoherentWith.of_isClosed h /-- Every weakly locally compact space is a compactly coherent space. -/ instance of_weaklyLocallyCompactSpace [WeaklyLocallyCompactSpace X] : CompactlyCoherentSpace X where isCoherentWith := IsCoherentWith.of_nhds exists_compact_mem_nhds @[deprecated (since := "2025-05-30")] alias _root_.Topology.IsCoherentWith.isCompact_of_weaklyLocallyCompact := of_weaklyLocallyCompactSpace /-- Every sequential space is a compactly coherent space. -/ instance of_sequentialSpace [SequentialSpace X] : CompactlyCoherentSpace X where isCoherentWith := IsCoherentWith.of_seq fun _u _x hux ↦ hux.isCompact_insert_range @[deprecated (since := "2025-05-30")] alias _root_.Topology.IsCoherentWith.isCompact_of_seq := of_sequentialSpace /-- In a compactly coherent space `X`, a set `s` is open iff `f ⁻¹' s` is open for every continuous map from a compact space. -/ lemma isOpen_iff_forall_compactSpace [CompactlyCoherentSpace X] (s : Set X) : IsOpen s ↔ ∀ (K : Type u) [TopologicalSpace K] [CompactSpace K], ∀ (f : K → X), Continuous f → IsOpen (f ⁻¹' s) := by refine ⟨fun hs _ _ _ _ hf ↦ hs.preimage hf, fun hs ↦ isOpen_iff |>.mpr ?_⟩ intro K hK have : CompactSpace K := isCompact_iff_compactSpace.mp hK exact hs K Subtype.val continuous_subtype_val /-- A topological space `X` is compactly coherent if a set `s` is open when `f ⁻¹' s?` is open for every continuous map `f : K → X`, where `K` is compact. -/ lemma of_isOpen_forall_compactSpace (h : ∀ (s : Set X), (∀ (K : Type u) [TopologicalSpace K], [CompactSpace K] → ∀ (f : K → X), Continuous f → IsOpen (f ⁻¹' s)) → IsOpen s) : CompactlyCoherentSpace X := by refine of_isOpen fun A hA ↦ h A fun K _ _ f hf ↦ ?_ specialize hA (range f) (isCompact_range hf) have := hA.preimage (hf.codRestrict mem_range_self) rwa [← preimage_comp] at this end CompactlyCoherentSpace
.lake/packages/mathlib/Mathlib/Topology/Compactness/Bases.lean
import Mathlib.Topology.Bases import Mathlib.Topology.Compactness.Compact /-! # Topological bases in compact sets and compact spaces -/ open Set TopologicalSpace variable {X ι : Type*} [TopologicalSpace X] lemma eq_finite_iUnion_of_isTopologicalBasis_of_isCompact_open (b : ι → Set X) (hb : IsTopologicalBasis (Set.range b)) (U : Set X) (hUc : IsCompact U) (hUo : IsOpen U) : ∃ s : Set ι, s.Finite ∧ U = ⋃ i ∈ s, b i := by obtain ⟨Y, f, e, hf⟩ := hb.open_eq_iUnion hUo choose f' hf' using hf have : b ∘ f' = f := funext hf' subst this obtain ⟨t, ht⟩ := hUc.elim_finite_subcover (b ∘ f') (fun i => hb.isOpen (Set.mem_range_self _)) (by rw [e]) classical refine ⟨t.image f', Set.toFinite _, le_antisymm ?_ ?_⟩ · refine Set.Subset.trans ht ?_ simp only [Set.iUnion_subset_iff] intro i hi simpa using subset_iUnion₂ (s := fun i _ => b (f' i)) i hi · apply Set.iUnion₂_subset rintro i hi obtain ⟨j, -, rfl⟩ := Finset.mem_image.mp hi rw [e] exact Set.subset_iUnion (b ∘ f') j lemma eq_sUnion_finset_of_isTopologicalBasis_of_isCompact_open (b : Set (Set X)) (hb : IsTopologicalBasis b) (U : Set X) (hUc : IsCompact U) (hUo : IsOpen U) : ∃ s : Finset b, U = (s : Set b).sUnion := by have hb' : b = range (fun i ↦ i : b → Set X) := by simp rw [hb'] at hb choose s hs hU using eq_finite_iUnion_of_isTopologicalBasis_of_isCompact_open _ hb U hUc hUo have : Finite s := hs let _ : Fintype s := Fintype.ofFinite _ use s.toFinset simp [hU] /-- If `X` has a basis consisting of compact opens, then an open set in `X` is compact open iff it is a finite union of some elements in the basis -/ theorem isCompact_open_iff_eq_finite_iUnion_of_isTopologicalBasis (b : ι → Set X) (hb : IsTopologicalBasis (Set.range b)) (hb' : ∀ i, IsCompact (b i)) (U : Set X) : IsCompact U ∧ IsOpen U ↔ ∃ s : Set ι, s.Finite ∧ U = ⋃ i ∈ s, b i := by constructor · exact fun ⟨h₁, h₂⟩ ↦ eq_finite_iUnion_of_isTopologicalBasis_of_isCompact_open _ hb U h₁ h₂ · rintro ⟨s, hs, rfl⟩ constructor · exact hs.isCompact_biUnion fun i _ => hb' i · exact isOpen_biUnion fun i _ => hb.isOpen (Set.mem_range_self _)
.lake/packages/mathlib/Mathlib/Topology/Compactness/DeltaGeneratedSpace.lean
import Mathlib.Analysis.LocallyConvex.WithSeminorms /-! # Delta-generated topological spaces This file defines delta-generated spaces, as topological spaces whose topology is coinduced by all maps from Euclidean spaces into them. This is the strongest topological property that holds for all CW-complexes and is closed under quotients and disjoint unions; every delta-generated space is locally path-connected, sequential and in particular compactly generated. See https://ncatlab.org/nlab/show/Delta-generated+topological+space. Adapted from `Mathlib/Topology/Compactness/CompactlyGeneratedSpace.lean`. ## TODO * All locally path-connected first-countable spaces are delta-generated - in particular, all normed spaces and convex subsets thereof, like the standard simplices and the unit interval. * Delta-generated spaces are equivalently generated by the simplices Δⁿ. * Delta-generated spaces are equivalently generated by the unit interval I. -/ variable {X Y : Type*} [tX : TopologicalSpace X] [tY : TopologicalSpace Y] open TopologicalSpace Topology /-- The topology coinduced by all maps from ℝⁿ into a space. -/ def TopologicalSpace.deltaGenerated (X : Type*) [TopologicalSpace X] : TopologicalSpace X := ⨆ f : (n : ℕ) × C(((Fin n) → ℝ), X), coinduced f.2 inferInstance /-- The delta-generated topology is also coinduced by a single map out of a sigma type. -/ lemma deltaGenerated_eq_coinduced : deltaGenerated X = coinduced (fun x : (f : (n : ℕ) × C(Fin n → ℝ, X)) × (Fin f.1 → ℝ) ↦ x.1.2 x.2) inferInstance := by rw [deltaGenerated, instTopologicalSpaceSigma, coinduced_iSup]; rfl /-- The delta-generated topology is at least as fine as the original one. -/ lemma deltaGenerated_le : deltaGenerated X ≤ tX := iSup_le_iff.mpr fun f ↦ f.2.continuous.coinduced_le /-- A set is open in `deltaGenerated X` iff all its preimages under continuous functions ℝⁿ → X are open. -/ lemma isOpen_deltaGenerated_iff {u : Set X} : IsOpen[deltaGenerated X] u ↔ ∀ n (p : C(Fin n → ℝ, X)), IsOpen (p ⁻¹' u) := by simp_rw [deltaGenerated, isOpen_iSup_iff, isOpen_coinduced, Sigma.forall] /-- A map from ℝⁿ to X is continuous iff it is continuous regarding the delta-generated topology on X. Outside of this file, use the more general `continuous_to_deltaGenerated` instead. -/ private lemma continuous_euclidean_to_deltaGenerated {n : ℕ} {f : (Fin n → ℝ) → X} : Continuous[_, deltaGenerated X] f ↔ Continuous f := by simp_rw [continuous_iff_coinduced_le] refine ⟨fun h ↦ h.trans deltaGenerated_le, fun h ↦ ?_⟩ simp_rw [deltaGenerated] exact le_iSup_of_le (i := ⟨n, f, continuous_iff_coinduced_le.mpr h⟩) le_rfl /-- `deltaGenerated` is idempotent as a function `TopologicalSpace X → TopologicalSpace X`. -/ lemma deltaGenerated_deltaGenerated_eq : @deltaGenerated X (deltaGenerated X) = deltaGenerated X := by ext u; simp_rw [isOpen_deltaGenerated_iff]; refine forall_congr' fun n ↦ ?_ -- somewhat awkward because `ContinuousMap` doesn't play well with multiple topologies. refine ⟨fun h p ↦ h <| @ContinuousMap.mk _ _ _ (_) p ?_, fun h p ↦ h ⟨p, ?_⟩⟩ · exact continuous_euclidean_to_deltaGenerated.mpr p.2 · exact continuous_euclidean_to_deltaGenerated.mp <| @ContinuousMap.continuous_toFun _ _ _ (_) p /-- A space is delta-generated if its topology is equal to the delta-generated topology, i.e. coinduced by all continuous maps ℝⁿ → X. Since the delta-generated topology is always finer than the original one, it suffices to show that it is also coarser. -/ class DeltaGeneratedSpace (X : Type*) [t : TopologicalSpace X] : Prop where le_deltaGenerated : t ≤ deltaGenerated X lemma eq_deltaGenerated [DeltaGeneratedSpace X] : tX = deltaGenerated X := eq_of_le_of_ge DeltaGeneratedSpace.le_deltaGenerated deltaGenerated_le /-- A subset of a delta-generated space is open iff its preimage is open for every continuous map from ℝⁿ to X. -/ lemma DeltaGeneratedSpace.isOpen_iff [DeltaGeneratedSpace X] {u : Set X} : IsOpen u ↔ ∀ (n : ℕ) (p : ContinuousMap ((Fin n) → ℝ) X), IsOpen (p ⁻¹' u) := by nth_rewrite 1 [eq_deltaGenerated (X := X)]; exact isOpen_deltaGenerated_iff /-- A map out of a delta-generated space is continuous iff it preserves continuity of maps from ℝⁿ into X. -/ lemma DeltaGeneratedSpace.continuous_iff [DeltaGeneratedSpace X] {f : X → Y} : Continuous f ↔ ∀ (n : ℕ) (p : C(((Fin n) → ℝ), X)), Continuous (f ∘ p) := by simp_rw [continuous_iff_coinduced_le] nth_rewrite 1 [eq_deltaGenerated (X := X), deltaGenerated] simp [coinduced_compose, Sigma.forall] /-- A map out of a delta-generated space is continuous iff it is continuous with respect to the delta-generated topology on the codomain. -/ lemma continuous_to_deltaGenerated [DeltaGeneratedSpace X] {f : X → Y} : Continuous[_, deltaGenerated Y] f ↔ Continuous f := by simp_rw [DeltaGeneratedSpace.continuous_iff, continuous_euclidean_to_deltaGenerated] /-- The delta-generated topology on `X` does in fact turn `X` into a delta-generated space. -/ lemma deltaGeneratedSpace_deltaGenerated {X : Type*} {t : TopologicalSpace X} : @DeltaGeneratedSpace X (@deltaGenerated X t) := by let _ := @deltaGenerated X t; constructor; rw [@deltaGenerated_deltaGenerated_eq X t] lemma deltaGenerated_mono {X : Type*} {t₁ t₂ : TopologicalSpace X} (h : t₁ ≤ t₂) : @deltaGenerated X t₁ ≤ @deltaGenerated X t₂ := by rw [← continuous_id_iff_le, @continuous_to_deltaGenerated _ _ (@deltaGenerated X t₁) t₂ deltaGeneratedSpace_deltaGenerated id] exact continuous_id_iff_le.2 <| (@deltaGenerated_le X t₁).trans h namespace DeltaGeneratedSpace /-- Type synonym to be equipped with the delta-generated topology. -/ def of (X : Type*) := X instance : TopologicalSpace (of X) := deltaGenerated X instance : DeltaGeneratedSpace (of X) := deltaGeneratedSpace_deltaGenerated /-- The natural map from `DeltaGeneratedSpace.of X` to `X`. -/ def counit : (of X) → X := id lemma continuous_counit : Continuous (counit : _ → X) := by rw [continuous_iff_coinduced_le]; exact deltaGenerated_le /-- Delta-generated spaces are locally path-connected. -/ instance [DeltaGeneratedSpace X] : LocPathConnectedSpace X := by rw [eq_deltaGenerated (X := X), deltaGenerated_eq_coinduced] exact LocPathConnectedSpace.coinduced _ /-- Delta-generated spaces are sequential. -/ instance [DeltaGeneratedSpace X] : SequentialSpace X := by rw [eq_deltaGenerated (X := X)] exact SequentialSpace.iSup fun p ↦ SequentialSpace.coinduced p.2 end DeltaGeneratedSpace omit tY in /-- Any topology coinduced by a delta-generated topology is delta-generated. -/ lemma DeltaGeneratedSpace.coinduced [DeltaGeneratedSpace X] (f : X → Y) : @DeltaGeneratedSpace Y (tX.coinduced f) := let _ := tX.coinduced f ⟨(continuous_to_deltaGenerated.2 continuous_coinduced_rng).coinduced_le⟩ /-- Suprema of delta-generated topologies are delta-generated. -/ protected lemma DeltaGeneratedSpace.iSup {X : Type*} {ι : Sort*} {t : ι → TopologicalSpace X} (h : ∀ i, @DeltaGeneratedSpace X (t i)) : @DeltaGeneratedSpace X (⨆ i, t i) := let _ := ⨆ i, t i ⟨iSup_le_iff.2 fun i ↦ (h i).le_deltaGenerated.trans <| deltaGenerated_mono <| le_iSup t i⟩ /-- Suprema of delta-generated topologies are delta-generated. -/ protected lemma DeltaGeneratedSpace.sup {X : Type*} {t₁ t₂ : TopologicalSpace X} (h₁ : @DeltaGeneratedSpace X t₁) (h₂ : @DeltaGeneratedSpace X t₂) : @DeltaGeneratedSpace X (t₁ ⊔ t₂) := by rw [sup_eq_iSup] exact .iSup <| Bool.forall_bool.2 ⟨h₂, h₁⟩ /-- Quotients of delta-generated spaces are delta-generated. -/ lemma Topology.IsQuotientMap.deltaGeneratedSpace [DeltaGeneratedSpace X] {f : X → Y} (h : IsQuotientMap f) : DeltaGeneratedSpace Y := h.2 ▸ DeltaGeneratedSpace.coinduced f /-- Quotients of delta-generated spaces are delta-generated. -/ instance Quot.deltaGeneratedSpace [DeltaGeneratedSpace X] {r : X → X → Prop} : DeltaGeneratedSpace (Quot r) := isQuotientMap_quot_mk.deltaGeneratedSpace /-- Quotients of delta-generated spaces are delta-generated. -/ instance Quotient.deltaGeneratedSpace [DeltaGeneratedSpace X] {s : Setoid X} : DeltaGeneratedSpace (Quotient s) := isQuotientMap_quotient_mk'.deltaGeneratedSpace /-- Disjoint unions of delta-generated spaces are delta-generated. -/ instance Sum.deltaGeneratedSpace [DeltaGeneratedSpace X] [DeltaGeneratedSpace Y] : DeltaGeneratedSpace (X ⊕ Y) := DeltaGeneratedSpace.sup (.coinduced Sum.inl) (.coinduced Sum.inr) /-- Disjoint unions of delta-generated spaces are delta-generated. -/ instance Sigma.deltaGeneratedSpace {ι : Type*} {X : ι → Type*} [∀ i, TopologicalSpace (X i)] [∀ i, DeltaGeneratedSpace (X i)] : DeltaGeneratedSpace (Σ i, X i) := .iSup fun _ ↦ .coinduced _
.lake/packages/mathlib/Mathlib/Topology/Compactness/Compact.lean
import Mathlib.Order.Filter.Tendsto import Mathlib.Data.Set.Accumulate import Mathlib.Topology.Bornology.Basic import Mathlib.Topology.ContinuousOn import Mathlib.Topology.Ultrafilter import Mathlib.Topology.Defs.Ultrafilter /-! # Compact sets and compact spaces ## Main results * `isCompact_univ_pi`: **Tychonov's theorem** - an arbitrary product of compact sets is compact. * `isCompact_generateFrom`: **Alexander's subbasis theorem** - suppose `X` is a topological space with a subbasis `S` and `s` is a subset of `X`, then `s` is compact if for any open cover of `s` with all elements taken from `S`, there is a finite subcover. -/ open Set Filter Topology TopologicalSpace Function universe u v variable {X : Type u} {Y : Type v} {ι : Type*} variable [TopologicalSpace X] [TopologicalSpace Y] {s t : Set X} {f : X → Y} -- compact sets section Compact lemma IsCompact.exists_clusterPt (hs : IsCompact s) {f : Filter X} [NeBot f] (hf : f ≤ 𝓟 s) : ∃ x ∈ s, ClusterPt x f := hs hf lemma IsCompact.exists_mapClusterPt {ι : Type*} (hs : IsCompact s) {f : Filter ι} [NeBot f] {u : ι → X} (hf : Filter.map u f ≤ 𝓟 s) : ∃ x ∈ s, MapClusterPt x f u := hs hf lemma IsCompact.exists_clusterPt_of_frequently {l : Filter X} (hs : IsCompact s) (hl : ∃ᶠ x in l, x ∈ s) : ∃ a ∈ s, ClusterPt a l := let ⟨a, has, ha⟩ := @hs _ (frequently_mem_iff_neBot.mp hl) inf_le_right ⟨a, has, ha.mono inf_le_left⟩ lemma IsCompact.exists_mapClusterPt_of_frequently {l : Filter ι} {f : ι → X} (hs : IsCompact s) (hf : ∃ᶠ x in l, f x ∈ s) : ∃ a ∈ s, MapClusterPt a l f := hs.exists_clusterPt_of_frequently hf /-- The complement to a compact set belongs to a filter `f` if it belongs to each filter `𝓝 x ⊓ f`, `x ∈ s`. -/ theorem IsCompact.compl_mem_sets (hs : IsCompact s) {f : Filter X} (hf : ∀ x ∈ s, sᶜ ∈ 𝓝 x ⊓ f) : sᶜ ∈ f := by contrapose! hf simp only [notMem_iff_inf_principal_compl, compl_compl, inf_assoc] at hf ⊢ exact @hs _ hf inf_le_right /-- The complement to a compact set belongs to a filter `f` if each `x ∈ s` has a neighborhood `t` within `s` such that `tᶜ` belongs to `f`. -/ theorem IsCompact.compl_mem_sets_of_nhdsWithin (hs : IsCompact s) {f : Filter X} (hf : ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, tᶜ ∈ f) : sᶜ ∈ f := by refine hs.compl_mem_sets fun x hx => ?_ rcases hf x hx with ⟨t, ht, hst⟩ replace ht := mem_inf_principal.1 ht apply mem_inf_of_inter ht hst rintro x ⟨h₁, h₂⟩ hs exact h₂ (h₁ hs) /-- If `p : Set X → Prop` is stable under restriction and union, and each point `x` of a compact set `s` has a neighborhood `t` within `s` such that `p t`, then `p s` holds. -/ @[elab_as_elim] theorem IsCompact.induction_on (hs : IsCompact s) {p : Set X → Prop} (he : p ∅) (hmono : ∀ ⦃s t⦄, s ⊆ t → p t → p s) (hunion : ∀ ⦃s t⦄, p s → p t → p (s ∪ t)) (hnhds : ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, p t) : p s := by let f : Filter X := comk p he (fun _t ht _s hsub ↦ hmono hsub ht) (fun _s hs _t ht ↦ hunion hs ht) have : sᶜ ∈ f := hs.compl_mem_sets_of_nhdsWithin (by simpa [f] using hnhds) rwa [← compl_compl s] /-- The intersection of a compact set and a closed set is a compact set. -/ theorem IsCompact.inter_right (hs : IsCompact s) (ht : IsClosed t) : IsCompact (s ∩ t) := by intro f hnf hstf obtain ⟨x, hsx, hx⟩ : ∃ x ∈ s, ClusterPt x f := hs (le_trans hstf (le_principal_iff.2 inter_subset_left)) have : x ∈ t := ht.mem_of_nhdsWithin_neBot <| hx.mono <| le_trans hstf (le_principal_iff.2 inter_subset_right) exact ⟨x, ⟨hsx, this⟩, hx⟩ /-- The intersection of a closed set and a compact set is a compact set. -/ theorem IsCompact.inter_left (ht : IsCompact t) (hs : IsClosed s) : IsCompact (s ∩ t) := inter_comm t s ▸ ht.inter_right hs /-- The set difference of a compact set and an open set is a compact set. -/ theorem IsCompact.diff (hs : IsCompact s) (ht : IsOpen t) : IsCompact (s \ t) := hs.inter_right (isClosed_compl_iff.mpr ht) /-- A closed subset of a compact set is a compact set. -/ theorem IsCompact.of_isClosed_subset (hs : IsCompact s) (ht : IsClosed t) (h : t ⊆ s) : IsCompact t := inter_eq_self_of_subset_right h ▸ hs.inter_right ht theorem IsCompact.image_of_continuousOn {f : X → Y} (hs : IsCompact s) (hf : ContinuousOn f s) : IsCompact (f '' s) := by intro l lne ls have : NeBot (l.comap f ⊓ 𝓟 s) := comap_inf_principal_neBot_of_image_mem lne (le_principal_iff.1 ls) obtain ⟨x, hxs, hx⟩ : ∃ x ∈ s, ClusterPt x (l.comap f ⊓ 𝓟 s) := @hs _ this inf_le_right haveI := hx.neBot use f x, mem_image_of_mem f hxs have : Tendsto f (𝓝 x ⊓ (comap f l ⊓ 𝓟 s)) (𝓝 (f x) ⊓ l) := by convert (hf x hxs).inf (@tendsto_comap _ _ f l) using 1 rw [nhdsWithin] ac_rfl exact this.neBot theorem IsCompact.image {f : X → Y} (hs : IsCompact s) (hf : Continuous f) : IsCompact (f '' s) := hs.image_of_continuousOn hf.continuousOn theorem IsCompact.adherence_nhdset {f : Filter X} (hs : IsCompact s) (hf₂ : f ≤ 𝓟 s) (ht₁ : IsOpen t) (ht₂ : ∀ x ∈ s, ClusterPt x f → x ∈ t) : t ∈ f := Classical.by_cases mem_of_eq_bot fun (this : f ⊓ 𝓟 tᶜ ≠ ⊥) => let ⟨x, hx, (hfx : ClusterPt x <| f ⊓ 𝓟 tᶜ)⟩ := @hs _ ⟨this⟩ <| inf_le_of_left_le hf₂ have : x ∈ t := ht₂ x hx hfx.of_inf_left have : tᶜ ∩ t ∈ 𝓝[tᶜ] x := inter_mem_nhdsWithin _ (IsOpen.mem_nhds ht₁ this) have A : 𝓝[tᶜ] x = ⊥ := empty_mem_iff_bot.1 <| compl_inter_self t ▸ this have : 𝓝[tᶜ] x ≠ ⊥ := hfx.of_inf_right.ne absurd A this theorem isCompact_iff_ultrafilter_le_nhds : IsCompact s ↔ ∀ f : Ultrafilter X, ↑f ≤ 𝓟 s → ∃ x ∈ s, ↑f ≤ 𝓝 x := by refine (forall_neBot_le_iff ?_).trans ?_ · rintro f g hle ⟨x, hxs, hxf⟩ exact ⟨x, hxs, hxf.mono hle⟩ · simp only [Ultrafilter.clusterPt_iff] alias ⟨IsCompact.ultrafilter_le_nhds, _⟩ := isCompact_iff_ultrafilter_le_nhds theorem isCompact_iff_ultrafilter_le_nhds' : IsCompact s ↔ ∀ f : Ultrafilter X, s ∈ f → ∃ x ∈ s, ↑f ≤ 𝓝 x := by simp only [isCompact_iff_ultrafilter_le_nhds, le_principal_iff, Ultrafilter.mem_coe] alias ⟨IsCompact.ultrafilter_le_nhds', _⟩ := isCompact_iff_ultrafilter_le_nhds' /-- If a compact set belongs to a filter and this filter has a unique cluster point `y` in this set, then the filter is less than or equal to `𝓝 y`. -/ lemma IsCompact.le_nhds_of_unique_clusterPt (hs : IsCompact s) {l : Filter X} {y : X} (hmem : s ∈ l) (h : ∀ x ∈ s, ClusterPt x l → x = y) : l ≤ 𝓝 y := by refine le_iff_ultrafilter.2 fun f hf ↦ ?_ rcases hs.ultrafilter_le_nhds' f (hf hmem) with ⟨x, hxs, hx⟩ convert ← hx exact h x hxs (.mono (.of_le_nhds hx) hf) /-- If values of `f : Y → X` belong to a compact set `s` eventually along a filter `l` and `y` is a unique `MapClusterPt` for `f` along `l` in `s`, then `f` tends to `𝓝 y` along `l`. -/ lemma IsCompact.tendsto_nhds_of_unique_mapClusterPt {Y} {l : Filter Y} {y : X} {f : Y → X} (hs : IsCompact s) (hmem : ∀ᶠ x in l, f x ∈ s) (h : ∀ x ∈ s, MapClusterPt x l f → x = y) : Tendsto f l (𝓝 y) := hs.le_nhds_of_unique_clusterPt (mem_map.2 hmem) h /-- For every open directed cover of a compact set, there exists a single element of the cover which itself includes the set. -/ theorem IsCompact.elim_directed_cover {ι : Type v} [hι : Nonempty ι] (hs : IsCompact s) (U : ι → Set X) (hUo : ∀ i, IsOpen (U i)) (hsU : s ⊆ ⋃ i, U i) (hdU : Directed (· ⊆ ·) U) : ∃ i, s ⊆ U i := hι.elim fun i₀ => IsCompact.induction_on hs ⟨i₀, empty_subset _⟩ (fun _ _ hs ⟨i, hi⟩ => ⟨i, hs.trans hi⟩) (fun _ _ ⟨i, hi⟩ ⟨j, hj⟩ => let ⟨k, hki, hkj⟩ := hdU i j ⟨k, union_subset (Subset.trans hi hki) (Subset.trans hj hkj)⟩) fun _x hx => let ⟨i, hi⟩ := mem_iUnion.1 (hsU hx) ⟨U i, mem_nhdsWithin_of_mem_nhds (IsOpen.mem_nhds (hUo i) hi), i, Subset.refl _⟩ /-- For every open cover of a compact set, there exists a finite subcover. -/ theorem IsCompact.elim_finite_subcover {ι : Type v} (hs : IsCompact s) (U : ι → Set X) (hUo : ∀ i, IsOpen (U i)) (hsU : s ⊆ ⋃ i, U i) : ∃ t : Finset ι, s ⊆ ⋃ i ∈ t, U i := hs.elim_directed_cover _ (fun _ => isOpen_biUnion fun i _ => hUo i) (iUnion_eq_iUnion_finset U ▸ hsU) (directed_of_isDirected_le fun _ _ h => biUnion_subset_biUnion_left h) lemma IsCompact.elim_nhds_subcover_nhdsSet' (hs : IsCompact s) (U : ∀ x ∈ s, Set X) (hU : ∀ x hx, U x hx ∈ 𝓝 x) : ∃ t : Finset s, (⋃ x ∈ t, U x.1 x.2) ∈ 𝓝ˢ s := by rcases hs.elim_finite_subcover (fun x : s ↦ interior (U x x.2)) (fun _ ↦ isOpen_interior) fun x hx ↦ mem_iUnion.2 ⟨⟨x, hx⟩, mem_interior_iff_mem_nhds.2 <| hU _ _⟩ with ⟨t, hst⟩ refine ⟨t, mem_nhdsSet_iff_forall.2 fun x hx ↦ ?_⟩ rcases mem_iUnion₂.1 (hst hx) with ⟨y, hyt, hy⟩ refine mem_of_superset ?_ (subset_biUnion_of_mem hyt) exact mem_interior_iff_mem_nhds.1 hy lemma IsCompact.elim_nhds_subcover_nhdsSet (hs : IsCompact s) {U : X → Set X} (hU : ∀ x ∈ s, U x ∈ 𝓝 x) : ∃ t : Finset X, (∀ x ∈ t, x ∈ s) ∧ (⋃ x ∈ t, U x) ∈ 𝓝ˢ s := by let ⟨t, ht⟩ := hs.elim_nhds_subcover_nhdsSet' (fun x _ => U x) hU classical exact ⟨t.image (↑), fun x hx => let ⟨y, _, hyx⟩ := Finset.mem_image.1 hx hyx ▸ y.2, by rwa [Finset.set_biUnion_finset_image]⟩ theorem IsCompact.elim_nhds_subcover' (hs : IsCompact s) (U : ∀ x ∈ s, Set X) (hU : ∀ x (hx : x ∈ s), U x ‹x ∈ s› ∈ 𝓝 x) : ∃ t : Finset s, s ⊆ ⋃ x ∈ t, U (x : s) x.2 := (hs.elim_nhds_subcover_nhdsSet' U hU).imp fun _ ↦ subset_of_mem_nhdsSet theorem IsCompact.elim_nhds_subcover (hs : IsCompact s) (U : X → Set X) (hU : ∀ x ∈ s, U x ∈ 𝓝 x) : ∃ t : Finset X, (∀ x ∈ t, x ∈ s) ∧ s ⊆ ⋃ x ∈ t, U x := (hs.elim_nhds_subcover_nhdsSet hU).imp fun _ h ↦ h.imp_right subset_of_mem_nhdsSet theorem IsCompact.elim_nhdsWithin_subcover' (hs : IsCompact s) (U : ∀ x ∈ s, Set X) (hU : ∀ x (hx : x ∈ s), U x hx ∈ 𝓝[s] x) : ∃ t : Finset s, s ⊆ ⋃ x ∈ t, U x x.2 := by choose V V_nhds hV using fun x hx => mem_nhdsWithin_iff_exists_mem_nhds_inter.1 (hU x hx) refine (hs.elim_nhds_subcover' V V_nhds).imp fun t ht => subset_trans ?_ (iUnion₂_mono fun x _ => hV x x.2) simpa [← iUnion_inter, ← iUnion_coe_set] theorem IsCompact.elim_nhdsWithin_subcover (hs : IsCompact s) (U : X → Set X) (hU : ∀ x ∈ s, U x ∈ 𝓝[s] x) : ∃ t : Finset X, (∀ x ∈ t, x ∈ s) ∧ s ⊆ ⋃ x ∈ t, U x := by choose! V V_nhds hV using fun x hx => mem_nhdsWithin_iff_exists_mem_nhds_inter.1 (hU x hx) refine (hs.elim_nhds_subcover V V_nhds).imp fun t ⟨t_sub_s, ht⟩ => ⟨t_sub_s, subset_trans ?_ (iUnion₂_mono fun x hx => hV x (t_sub_s x hx))⟩ simpa [← iUnion_inter] /-- The neighborhood filter of a compact set is disjoint with a filter `l` if and only if the neighborhood filter of each point of this set is disjoint with `l`. -/ theorem IsCompact.disjoint_nhdsSet_left {l : Filter X} (hs : IsCompact s) : Disjoint (𝓝ˢ s) l ↔ ∀ x ∈ s, Disjoint (𝓝 x) l := by refine ⟨fun h x hx => h.mono_left <| nhds_le_nhdsSet hx, fun H => ?_⟩ choose! U hxU hUl using fun x hx => (nhds_basis_opens x).disjoint_iff_left.1 (H x hx) choose hxU hUo using hxU rcases hs.elim_nhds_subcover U fun x hx => (hUo x hx).mem_nhds (hxU x hx) with ⟨t, hts, hst⟩ refine (hasBasis_nhdsSet _).disjoint_iff_left.2 ⟨⋃ x ∈ t, U x, ⟨isOpen_biUnion fun x hx => hUo x (hts x hx), hst⟩, ?_⟩ rw [compl_iUnion₂, biInter_finset_mem] exact fun x hx => hUl x (hts x hx) /-- A filter `l` is disjoint with the neighborhood filter of a compact set if and only if it is disjoint with the neighborhood filter of each point of this set. -/ theorem IsCompact.disjoint_nhdsSet_right {l : Filter X} (hs : IsCompact s) : Disjoint l (𝓝ˢ s) ↔ ∀ x ∈ s, Disjoint l (𝓝 x) := by simpa only [disjoint_comm] using hs.disjoint_nhdsSet_left -- TODO: reformulate using `Disjoint` /-- For every directed family of closed sets whose intersection avoids a compact set, there exists a single element of the family which itself avoids this compact set. -/ theorem IsCompact.elim_directed_family_closed {ι : Type v} [Nonempty ι] (hs : IsCompact s) (t : ι → Set X) (htc : ∀ i, IsClosed (t i)) (hst : (s ∩ ⋂ i, t i) = ∅) (hdt : Directed (· ⊇ ·) t) : ∃ i : ι, s ∩ t i = ∅ := let ⟨t, ht⟩ := hs.elim_directed_cover (compl ∘ t) (fun i => (htc i).isOpen_compl) (by simpa only [subset_def, not_forall, eq_empty_iff_forall_notMem, mem_iUnion, exists_prop, mem_inter_iff, not_and, mem_iInter, mem_compl_iff] using hst) (hdt.mono_comp _ fun _ _ => compl_subset_compl.mpr) ⟨t, by simpa only [subset_def, not_forall, eq_empty_iff_forall_notMem, mem_iUnion, exists_prop, mem_inter_iff, not_and, mem_iInter, mem_compl_iff] using ht⟩ -- TODO: reformulate using `Disjoint` /-- For every family of closed sets whose intersection avoids a compact set, there exists a finite subfamily whose intersection avoids this compact set. -/ theorem IsCompact.elim_finite_subfamily_closed {ι : Type v} (hs : IsCompact s) (t : ι → Set X) (htc : ∀ i, IsClosed (t i)) (hst : (s ∩ ⋂ i, t i) = ∅) : ∃ u : Finset ι, (s ∩ ⋂ i ∈ u, t i) = ∅ := hs.elim_directed_family_closed _ (fun _ ↦ isClosed_biInter fun _ _ ↦ htc _) (by rwa [← iInter_eq_iInter_finset]) (directed_of_isDirected_le fun _ _ h ↦ biInter_subset_biInter_left h) /-- To show that a compact set intersects the intersection of a family of closed sets, it is sufficient to show that it intersects every finite subfamily. -/ theorem IsCompact.inter_iInter_nonempty {ι : Type v} (hs : IsCompact s) (t : ι → Set X) (htc : ∀ i, IsClosed (t i)) (hst : ∀ u : Finset ι, (s ∩ ⋂ i ∈ u, t i).Nonempty) : (s ∩ ⋂ i, t i).Nonempty := by contrapose! hst exact hs.elim_finite_subfamily_closed t htc hst /-- Cantor's intersection theorem for `iInter`: the intersection of a directed family of nonempty compact closed sets is nonempty. -/ theorem IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed {ι : Type v} [hι : Nonempty ι] (t : ι → Set X) (htd : Directed (· ⊇ ·) t) (htn : ∀ i, (t i).Nonempty) (htc : ∀ i, IsCompact (t i)) (htcl : ∀ i, IsClosed (t i)) : (⋂ i, t i).Nonempty := by let i₀ := hι.some suffices (t i₀ ∩ ⋂ i, t i).Nonempty by rwa [inter_eq_right.mpr (iInter_subset _ i₀)] at this simp only [nonempty_iff_ne_empty] at htn ⊢ apply mt ((htc i₀).elim_directed_family_closed t htcl) push_neg simp only [← nonempty_iff_ne_empty] at htn ⊢ refine ⟨htd, fun i => ?_⟩ rcases htd i₀ i with ⟨j, hji₀, hji⟩ exact (htn j).mono (subset_inter hji₀ hji) /-- Cantor's intersection theorem for `sInter`: the intersection of a directed family of nonempty compact closed sets is nonempty. -/ theorem IsCompact.nonempty_sInter_of_directed_nonempty_isCompact_isClosed {S : Set (Set X)} [hS : Nonempty S] (hSd : DirectedOn (· ⊇ ·) S) (hSn : ∀ U ∈ S, U.Nonempty) (hSc : ∀ U ∈ S, IsCompact U) (hScl : ∀ U ∈ S, IsClosed U) : (⋂₀ S).Nonempty := by rw [sInter_eq_iInter] exact IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed _ (DirectedOn.directed_val hSd) (fun i ↦ hSn i i.2) (fun i ↦ hSc i i.2) (fun i ↦ hScl i i.2) /-- Cantor's intersection theorem for sequences indexed by `ℕ`: the intersection of a decreasing sequence of nonempty compact closed sets is nonempty. -/ theorem IsCompact.nonempty_iInter_of_sequence_nonempty_isCompact_isClosed (t : ℕ → Set X) (htd : ∀ i, t (i + 1) ⊆ t i) (htn : ∀ i, (t i).Nonempty) (ht0 : IsCompact (t 0)) (htcl : ∀ i, IsClosed (t i)) : (⋂ i, t i).Nonempty := have tmono : Antitone t := antitone_nat_of_succ_le htd have htd : Directed (· ⊇ ·) t := tmono.directed_ge have : ∀ i, t i ⊆ t 0 := fun i => tmono <| Nat.zero_le i have htc : ∀ i, IsCompact (t i) := fun i => ht0.of_isClosed_subset (htcl i) (this i) IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed t htd htn htc htcl /-- For every open cover of a compact set, there exists a finite subcover. -/ theorem IsCompact.elim_finite_subcover_image {b : Set ι} {c : ι → Set X} (hs : IsCompact s) (hc₁ : ∀ i ∈ b, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i ∈ b, c i) : ∃ b', b' ⊆ b ∧ Set.Finite b' ∧ s ⊆ ⋃ i ∈ b', c i := by simp only [Subtype.forall', biUnion_eq_iUnion] at hc₁ hc₂ rcases hs.elim_finite_subcover (fun i => c i : b → Set X) hc₁ hc₂ with ⟨d, hd⟩ refine ⟨Subtype.val '' (d : Set b), ?_, d.finite_toSet.image _, ?_⟩ · simp · rwa [biUnion_image] /-- A set `s` is compact if for every open cover of `s`, there exists a finite subcover. -/ theorem isCompact_of_finite_subcover (h : ∀ {ι : Type u} (U : ι → Set X), (∀ i, IsOpen (U i)) → (s ⊆ ⋃ i, U i) → ∃ t : Finset ι, s ⊆ ⋃ i ∈ t, U i) : IsCompact s := fun f hf hfs => by contrapose! h simp only [ClusterPt, not_neBot, ← disjoint_iff, SetCoe.forall', (nhds_basis_opens _).disjoint_iff_left] at h choose U hU hUf using h refine ⟨s, U, fun x => (hU x).2, fun x hx => mem_iUnion.2 ⟨⟨x, hx⟩, (hU _).1⟩, fun t ht => ?_⟩ refine compl_notMem (le_principal_iff.1 hfs) ?_ refine mem_of_superset ((biInter_finset_mem t).2 fun x _ => hUf x) ?_ rw [subset_compl_comm, compl_iInter₂] simpa only [compl_compl] -- TODO: reformulate using `Disjoint` /-- A set `s` is compact if for every family of closed sets whose intersection avoids `s`, there exists a finite subfamily whose intersection avoids `s`. -/ theorem isCompact_of_finite_subfamily_closed (h : ∀ {ι : Type u} (t : ι → Set X), (∀ i, IsClosed (t i)) → (s ∩ ⋂ i, t i) = ∅ → ∃ u : Finset ι, (s ∩ ⋂ i ∈ u, t i) = ∅) : IsCompact s := isCompact_of_finite_subcover fun U hUo hsU => by rw [← disjoint_compl_right_iff_subset, compl_iUnion, disjoint_iff] at hsU rcases h (fun i => (U i)ᶜ) (fun i => (hUo _).isClosed_compl) hsU with ⟨t, ht⟩ refine ⟨t, ?_⟩ rwa [← disjoint_compl_right_iff_subset, compl_iUnion₂, disjoint_iff] /-- A set `s` is compact if and only if for every open cover of `s`, there exists a finite subcover. -/ theorem isCompact_iff_finite_subcover : IsCompact s ↔ ∀ {ι : Type u} (U : ι → Set X), (∀ i, IsOpen (U i)) → (s ⊆ ⋃ i, U i) → ∃ t : Finset ι, s ⊆ ⋃ i ∈ t, U i := ⟨fun hs => hs.elim_finite_subcover, isCompact_of_finite_subcover⟩ /-- A set `s` is compact if and only if for every family of closed sets whose intersection avoids `s`, there exists a finite subfamily whose intersection avoids `s`. -/ theorem isCompact_iff_finite_subfamily_closed : IsCompact s ↔ ∀ {ι : Type u} (t : ι → Set X), (∀ i, IsClosed (t i)) → (s ∩ ⋂ i, t i) = ∅ → ∃ u : Finset ι, (s ∩ ⋂ i ∈ u, t i) = ∅ := ⟨fun hs => hs.elim_finite_subfamily_closed, isCompact_of_finite_subfamily_closed⟩ /-- If `s : Set (X × Y)` belongs to `𝓝 x ×ˢ l` for all `x` from a compact set `K`, then it belongs to `(𝓝ˢ K) ×ˢ l`, i.e., there exist an open `U ⊇ K` and `t ∈ l` such that `U ×ˢ t ⊆ s`. -/ theorem IsCompact.mem_nhdsSet_prod_of_forall {K : Set X} {Y} {l : Filter Y} {s : Set (X × Y)} (hK : IsCompact K) (hs : ∀ x ∈ K, s ∈ 𝓝 x ×ˢ l) : s ∈ (𝓝ˢ K) ×ˢ l := by refine hK.induction_on (by simp) (fun t t' ht hs ↦ ?_) (fun t t' ht ht' ↦ ?_) fun x hx ↦ ?_ · exact prod_mono (nhdsSet_mono ht) le_rfl hs · simp [sup_prod, *] · rcases ((nhds_basis_opens _).prod l.basis_sets).mem_iff.1 (hs x hx) with ⟨⟨u, v⟩, ⟨⟨hx, huo⟩, hv⟩, hs⟩ refine ⟨u, nhdsWithin_le_nhds (huo.mem_nhds hx), mem_of_superset ?_ hs⟩ exact prod_mem_prod (huo.mem_nhdsSet.2 Subset.rfl) hv theorem IsCompact.nhdsSet_prod_eq_biSup {K : Set X} (hK : IsCompact K) {Y} (l : Filter Y) : (𝓝ˢ K) ×ˢ l = ⨆ x ∈ K, 𝓝 x ×ˢ l := le_antisymm (fun s hs ↦ hK.mem_nhdsSet_prod_of_forall <| by simpa using hs) (iSup₂_le fun _ hx ↦ prod_mono (nhds_le_nhdsSet hx) le_rfl) theorem IsCompact.prod_nhdsSet_eq_biSup {K : Set Y} (hK : IsCompact K) {X} (l : Filter X) : l ×ˢ (𝓝ˢ K) = ⨆ y ∈ K, l ×ˢ 𝓝 y := by simp only [prod_comm (f := l), hK.nhdsSet_prod_eq_biSup, map_iSup] /-- If `s : Set (X × Y)` belongs to `l ×ˢ 𝓝 y` for all `y` from a compact set `K`, then it belongs to `l ×ˢ (𝓝ˢ K)`, i.e., there exist `t ∈ l` and an open `U ⊇ K` such that `t ×ˢ U ⊆ s`. -/ theorem IsCompact.mem_prod_nhdsSet_of_forall {K : Set Y} {X} {l : Filter X} {s : Set (X × Y)} (hK : IsCompact K) (hs : ∀ y ∈ K, s ∈ l ×ˢ 𝓝 y) : s ∈ l ×ˢ 𝓝ˢ K := (hK.prod_nhdsSet_eq_biSup l).symm ▸ by simpa using hs -- TODO: Is there a way to prove directly the `inf` version and then deduce the `Prod` one ? -- That would seem a bit more natural. theorem IsCompact.nhdsSet_inf_eq_biSup {K : Set X} (hK : IsCompact K) (l : Filter X) : (𝓝ˢ K) ⊓ l = ⨆ x ∈ K, 𝓝 x ⊓ l := by have : ∀ f : Filter X, f ⊓ l = comap (fun x ↦ (x, x)) (f ×ˢ l) := fun f ↦ by simpa only [comap_prod] using congrArg₂ (· ⊓ ·) comap_id.symm comap_id.symm simp_rw [this, ← comap_iSup, hK.nhdsSet_prod_eq_biSup] theorem IsCompact.inf_nhdsSet_eq_biSup {K : Set X} (hK : IsCompact K) (l : Filter X) : l ⊓ (𝓝ˢ K) = ⨆ x ∈ K, l ⊓ 𝓝 x := by simp only [inf_comm l, hK.nhdsSet_inf_eq_biSup] /-- If `s : Set X` belongs to `𝓝 x ⊓ l` for all `x` from a compact set `K`, then it belongs to `(𝓝ˢ K) ⊓ l`, i.e., there exist an open `U ⊇ K` and `T ∈ l` such that `U ∩ T ⊆ s`. -/ theorem IsCompact.mem_nhdsSet_inf_of_forall {K : Set X} {l : Filter X} {s : Set X} (hK : IsCompact K) (hs : ∀ x ∈ K, s ∈ 𝓝 x ⊓ l) : s ∈ (𝓝ˢ K) ⊓ l := (hK.nhdsSet_inf_eq_biSup l).symm ▸ by simpa using hs /-- If `s : Set S` belongs to `l ⊓ 𝓝 x` for all `x` from a compact set `K`, then it belongs to `l ⊓ (𝓝ˢ K)`, i.e., there exist `T ∈ l` and an open `U ⊇ K` such that `T ∩ U ⊆ s`. -/ theorem IsCompact.mem_inf_nhdsSet_of_forall {K : Set X} {l : Filter X} {s : Set X} (hK : IsCompact K) (hs : ∀ y ∈ K, s ∈ l ⊓ 𝓝 y) : s ∈ l ⊓ 𝓝ˢ K := (hK.inf_nhdsSet_eq_biSup l).symm ▸ by simpa using hs /-- To show that `∀ y ∈ K, P x y` holds for `x` close enough to `x₀` when `K` is compact, it is sufficient to show that for all `y₀ ∈ K` there `P x y` holds for `(x, y)` close enough to `(x₀, y₀)`. Provided for backwards compatibility, see `IsCompact.mem_prod_nhdsSet_of_forall` for a stronger statement. -/ theorem IsCompact.eventually_forall_of_forall_eventually {x₀ : X} {K : Set Y} (hK : IsCompact K) {P : X → Y → Prop} (hP : ∀ y ∈ K, ∀ᶠ z : X × Y in 𝓝 (x₀, y), P z.1 z.2) : ∀ᶠ x in 𝓝 x₀, ∀ y ∈ K, P x y := by simp only [nhds_prod_eq, ← eventually_iSup, ← hK.prod_nhdsSet_eq_biSup] at hP exact hP.curry.mono fun _ h ↦ h.self_of_nhdsSet theorem isCompact_empty : IsCompact (∅ : Set X) := fun _f hnf hsf => Not.elim hnf.ne <| empty_mem_iff_bot.1 <| le_principal_iff.1 hsf theorem isCompact_singleton {x : X} : IsCompact ({x} : Set X) := fun _ hf hfa => ⟨x, rfl, ClusterPt.of_le_nhds' (hfa.trans <| by simpa only [principal_singleton] using pure_le_nhds x) hf⟩ theorem Set.Subsingleton.isCompact (hs : s.Subsingleton) : IsCompact s := Subsingleton.induction_on hs isCompact_empty fun _ => isCompact_singleton theorem Set.Finite.isCompact_biUnion {s : Set ι} {f : ι → Set X} (hs : s.Finite) (hf : ∀ i ∈ s, IsCompact (f i)) : IsCompact (⋃ i ∈ s, f i) := isCompact_iff_ultrafilter_le_nhds'.2 fun l hl => by rw [Ultrafilter.finite_biUnion_mem_iff hs] at hl rcases hl with ⟨i, his, hi⟩ rcases (hf i his).ultrafilter_le_nhds _ (le_principal_iff.2 hi) with ⟨x, hxi, hlx⟩ exact ⟨x, mem_iUnion₂.2 ⟨i, his, hxi⟩, hlx⟩ theorem Finset.isCompact_biUnion (s : Finset ι) {f : ι → Set X} (hf : ∀ i ∈ s, IsCompact (f i)) : IsCompact (⋃ i ∈ s, f i) := s.finite_toSet.isCompact_biUnion hf theorem isCompact_accumulate {K : ℕ → Set X} (hK : ∀ n, IsCompact (K n)) (n : ℕ) : IsCompact (Accumulate K n) := (finite_le_nat n).isCompact_biUnion fun k _ => hK k theorem Set.Finite.isCompact_sUnion {S : Set (Set X)} (hf : S.Finite) (hc : ∀ s ∈ S, IsCompact s) : IsCompact (⋃₀ S) := by rw [sUnion_eq_biUnion]; exact hf.isCompact_biUnion hc theorem isCompact_iUnion {ι : Sort*} {f : ι → Set X} [Finite ι] (h : ∀ i, IsCompact (f i)) : IsCompact (⋃ i, f i) := (finite_range f).isCompact_sUnion <| forall_mem_range.2 h @[simp] theorem Set.Finite.isCompact (hs : s.Finite) : IsCompact s := biUnion_of_singleton s ▸ hs.isCompact_biUnion fun _ _ => isCompact_singleton @[simp] theorem Set.sUnion_isCompact_eq_univ : ⋃₀ {(s : Set X) | IsCompact s} = univ := eq_univ_of_forall <| fun x ↦ ⟨{x}, by simp⟩ theorem IsCompact.finite_of_discrete [DiscreteTopology X] (hs : IsCompact s) : s.Finite := by have : ∀ x : X, ({x} : Set X) ∈ 𝓝 x := by simp [nhds_discrete] rcases hs.elim_nhds_subcover (fun x => {x}) fun x _ => this x with ⟨t, _, hst⟩ simp only [← t.set_biUnion_coe, biUnion_of_singleton] at hst exact t.finite_toSet.subset hst theorem isCompact_iff_finite [DiscreteTopology X] : IsCompact s ↔ s.Finite := ⟨fun h => h.finite_of_discrete, fun h => h.isCompact⟩ theorem IsCompact.union (hs : IsCompact s) (ht : IsCompact t) : IsCompact (s ∪ t) := by rw [union_eq_iUnion]; exact isCompact_iUnion fun b => by cases b <;> assumption protected theorem IsCompact.insert (hs : IsCompact s) (a) : IsCompact (insert a s) := isCompact_singleton.union hs -- TODO: reformulate using `𝓝ˢ` /-- If `V : ι → Set X` is a decreasing family of closed compact sets then any neighborhood of `⋂ i, V i` contains some `V i`. We assume each `V i` is compact *and* closed because `X` is not assumed to be Hausdorff. See `exists_subset_nhds_of_compact` for version assuming this. -/ theorem exists_subset_nhds_of_isCompact' [Nonempty ι] {V : ι → Set X} (hV : Directed (· ⊇ ·) V) (hV_cpct : ∀ i, IsCompact (V i)) (hV_closed : ∀ i, IsClosed (V i)) {U : Set X} (hU : ∀ x ∈ ⋂ i, V i, U ∈ 𝓝 x) : ∃ i, V i ⊆ U := by obtain ⟨W, hsubW, W_op, hWU⟩ := exists_open_set_nhds hU suffices ∃ i, V i ⊆ W from this.imp fun i hi => hi.trans hWU by_contra! H replace H : ∀ i, (V i ∩ Wᶜ).Nonempty := fun i => Set.inter_compl_nonempty_iff.mpr (H i) have : (⋂ i, V i ∩ Wᶜ).Nonempty := by refine IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed _ (fun i j => ?_) H (fun i => (hV_cpct i).inter_right W_op.isClosed_compl) fun i => (hV_closed i).inter W_op.isClosed_compl rcases hV i j with ⟨k, hki, hkj⟩ refine ⟨k, ⟨fun x => ?_, fun x => ?_⟩⟩ <;> simp only [and_imp, mem_inter_iff, mem_compl_iff] <;> tauto have : ¬⋂ i : ι, V i ⊆ W := by simpa [← iInter_inter, inter_compl_nonempty_iff] contradiction omit [TopologicalSpace X] in /-- **Alexander's subbasis theorem**. Suppose `X` is a topological space with a subbasis `S` and `s` is a subset of `X`. Then `s` is compact if for any open cover of `s` with all elements taken from `S`, there is a finite subcover. -/ theorem isCompact_generateFrom [T : TopologicalSpace X] {S : Set (Set X)} (hTS : T = generateFrom S) {s : Set X} (h : ∀ P ⊆ S, s ⊆ ⋃₀ P → ∃ Q ⊆ P, Q.Finite ∧ s ⊆ ⋃₀ Q) : IsCompact s := by rw [isCompact_iff_ultrafilter_le_nhds', hTS] intro F hsF by_contra hF have hSF : ∀ x ∈ s, ∃ t, x ∈ t ∧ t ∈ S ∧ t ∉ F := by simpa [nhds_generateFrom] using hF choose! U hxU hSU hUF using hSF obtain ⟨Q, hQU, hQ, hsQ⟩ := h (U '' s) (by simpa [Set.subset_def]) (fun x hx ↦ Set.mem_sUnion_of_mem (hxU _ hx) (by aesop)) have : ∀ s ∈ Q, s ∉ F := fun s hsQ ↦ (hQU hsQ).choose_spec.2 ▸ hUF _ (hQU hsQ).choose_spec.1 have hQF : ⋂₀ (compl '' Q) ∈ F.sets := by simpa [Filter.biInter_mem hQ, F.compl_mem_iff_notMem] have : ⋃₀ Q ∉ F := by simpa [-Set.sInter_image, ← Set.compl_sUnion, hsQ, F.compl_mem_iff_notMem] using hQF exact this (F.mem_of_superset hsF hsQ) namespace Filter theorem hasBasis_cocompact : (cocompact X).HasBasis IsCompact compl := hasBasis_biInf_principal' (fun s hs t ht => ⟨s ∪ t, hs.union ht, compl_subset_compl.2 subset_union_left, compl_subset_compl.2 subset_union_right⟩) ⟨∅, isCompact_empty⟩ theorem mem_cocompact : s ∈ cocompact X ↔ ∃ t, IsCompact t ∧ tᶜ ⊆ s := hasBasis_cocompact.mem_iff theorem mem_cocompact' : s ∈ cocompact X ↔ ∃ t, IsCompact t ∧ sᶜ ⊆ t := mem_cocompact.trans <| exists_congr fun _ => and_congr_right fun _ => compl_subset_comm theorem _root_.IsCompact.compl_mem_cocompact (hs : IsCompact s) : sᶜ ∈ Filter.cocompact X := hasBasis_cocompact.mem_of_mem hs theorem cocompact_le_cofinite : cocompact X ≤ cofinite := fun s hs => compl_compl s ▸ hs.isCompact.compl_mem_cocompact theorem cocompact_eq_cofinite (X : Type*) [TopologicalSpace X] [DiscreteTopology X] : cocompact X = cofinite := by simp only [cocompact, hasBasis_cofinite.eq_biInf, isCompact_iff_finite] /-- A filter is disjoint from the cocompact filter if and only if it contains a compact set. -/ theorem disjoint_cocompact_left (f : Filter X) : Disjoint (Filter.cocompact X) f ↔ ∃ K ∈ f, IsCompact K := by simp_rw [hasBasis_cocompact.disjoint_iff_left, compl_compl] tauto /-- A filter is disjoint from the cocompact filter if and only if it contains a compact set. -/ theorem disjoint_cocompact_right (f : Filter X) : Disjoint f (Filter.cocompact X) ↔ ∃ K ∈ f, IsCompact K := by simp_rw [hasBasis_cocompact.disjoint_iff_right, compl_compl] tauto theorem Tendsto.isCompact_insert_range_of_cocompact {f : X → Y} {y} (hf : Tendsto f (cocompact X) (𝓝 y)) (hfc : Continuous f) : IsCompact (insert y (range f)) := by intro l hne hle by_cases hy : ClusterPt y l · exact ⟨y, Or.inl rfl, hy⟩ simp only [clusterPt_iff_nonempty, not_forall, ← not_disjoint_iff_nonempty_inter, not_not] at hy rcases hy with ⟨s, hsy, t, htl, hd⟩ rcases mem_cocompact.1 (hf hsy) with ⟨K, hKc, hKs⟩ have : f '' K ∈ l := by filter_upwards [htl, le_principal_iff.1 hle] with y hyt hyf rcases hyf with (rfl | ⟨x, rfl⟩) exacts [(hd.le_bot ⟨mem_of_mem_nhds hsy, hyt⟩).elim, mem_image_of_mem _ (not_not.1 fun hxK => hd.le_bot ⟨hKs hxK, hyt⟩)] rcases hKc.image hfc (le_principal_iff.2 this) with ⟨y, hy, hyl⟩ exact ⟨y, Or.inr <| image_subset_range _ _ hy, hyl⟩ theorem Tendsto.isCompact_insert_range_of_cofinite {f : ι → X} {x} (hf : Tendsto f cofinite (𝓝 x)) : IsCompact (insert x (range f)) := by letI : TopologicalSpace ι := ⊥; haveI h : DiscreteTopology ι := ⟨rfl⟩ rw [← cocompact_eq_cofinite ι] at hf exact hf.isCompact_insert_range_of_cocompact continuous_of_discreteTopology theorem Tendsto.isCompact_insert_range {f : ℕ → X} {x} (hf : Tendsto f atTop (𝓝 x)) : IsCompact (insert x (range f)) := Filter.Tendsto.isCompact_insert_range_of_cofinite <| Nat.cofinite_eq_atTop.symm ▸ hf theorem hasBasis_coclosedCompact : (Filter.coclosedCompact X).HasBasis (fun s => IsClosed s ∧ IsCompact s) compl := by simp only [Filter.coclosedCompact, iInf_and'] refine hasBasis_biInf_principal' ?_ ⟨∅, isClosed_empty, isCompact_empty⟩ rintro s ⟨hs₁, hs₂⟩ t ⟨ht₁, ht₂⟩ exact ⟨s ∪ t, ⟨⟨hs₁.union ht₁, hs₂.union ht₂⟩, compl_subset_compl.2 subset_union_left, compl_subset_compl.2 subset_union_right⟩⟩ /-- A set belongs to `coclosedCompact` if and only if the closure of its complement is compact. -/ theorem mem_coclosedCompact_iff : s ∈ coclosedCompact X ↔ IsCompact (closure sᶜ) := by refine hasBasis_coclosedCompact.mem_iff.trans ⟨?_, fun h ↦ ?_⟩ · rintro ⟨t, ⟨htcl, htco⟩, hst⟩ exact htco.of_isClosed_subset isClosed_closure <| closure_minimal (compl_subset_comm.2 hst) htcl · exact ⟨closure sᶜ, ⟨isClosed_closure, h⟩, compl_subset_comm.2 subset_closure⟩ /-- Complement of a set belongs to `coclosedCompact` if and only if its closure is compact. -/ theorem compl_mem_coclosedCompact : sᶜ ∈ coclosedCompact X ↔ IsCompact (closure s) := by rw [mem_coclosedCompact_iff, compl_compl] theorem cocompact_le_coclosedCompact : cocompact X ≤ coclosedCompact X := iInf_mono fun _ => le_iInf fun _ => le_rfl end Filter theorem IsCompact.compl_mem_coclosedCompact_of_isClosed (hs : IsCompact s) (hs' : IsClosed s) : sᶜ ∈ Filter.coclosedCompact X := hasBasis_coclosedCompact.mem_of_mem ⟨hs', hs⟩ namespace Bornology variable (X) in /-- Sets that are contained in a compact set form a bornology. Its `cobounded` filter is `Filter.cocompact`. See also `Bornology.relativelyCompact` the bornology of sets with compact closure. -/ def inCompact : Bornology X where cobounded := Filter.cocompact X le_cofinite := Filter.cocompact_le_cofinite theorem inCompact.isBounded_iff : @IsBounded _ (inCompact X) s ↔ ∃ t, IsCompact t ∧ s ⊆ t := by change sᶜ ∈ Filter.cocompact X ↔ _ rw [Filter.mem_cocompact] simp end Bornology /-- If `s` and `t` are compact sets, then the set neighborhoods filter of `s ×ˢ t` is the product of set neighborhoods filters for `s` and `t`. For general sets, only the `≤` inequality holds, see `nhdsSet_prod_le`. -/ theorem IsCompact.nhdsSet_prod_eq {t : Set Y} (hs : IsCompact s) (ht : IsCompact t) : 𝓝ˢ (s ×ˢ t) = 𝓝ˢ s ×ˢ 𝓝ˢ t := by simp_rw [hs.nhdsSet_prod_eq_biSup, ht.prod_nhdsSet_eq_biSup, nhdsSet, sSup_image, biSup_prod, nhds_prod_eq] theorem nhdsSet_prod_le_of_disjoint_cocompact {f : Filter Y} (hs : IsCompact s) (hf : Disjoint f (Filter.cocompact Y)) : 𝓝ˢ s ×ˢ f ≤ 𝓝ˢ (s ×ˢ Set.univ) := by obtain ⟨K, hKf, hK⟩ := (disjoint_cocompact_right f).mp hf calc 𝓝ˢ s ×ˢ f _ ≤ 𝓝ˢ s ×ˢ 𝓟 K := Filter.prod_mono_right _ (Filter.le_principal_iff.mpr hKf) _ ≤ 𝓝ˢ s ×ˢ 𝓝ˢ K := Filter.prod_mono_right _ principal_le_nhdsSet _ = 𝓝ˢ (s ×ˢ K) := (hs.nhdsSet_prod_eq hK).symm _ ≤ 𝓝ˢ (s ×ˢ Set.univ) := nhdsSet_mono (prod_mono_right le_top) theorem prod_nhdsSet_le_of_disjoint_cocompact {t : Set Y} {f : Filter X} (ht : IsCompact t) (hf : Disjoint f (Filter.cocompact X)) : f ×ˢ 𝓝ˢ t ≤ 𝓝ˢ (Set.univ ×ˢ t) := by obtain ⟨K, hKf, hK⟩ := (disjoint_cocompact_right f).mp hf calc f ×ˢ 𝓝ˢ t _ ≤ (𝓟 K) ×ˢ 𝓝ˢ t := Filter.prod_mono_left _ (Filter.le_principal_iff.mpr hKf) _ ≤ 𝓝ˢ K ×ˢ 𝓝ˢ t := Filter.prod_mono_left _ principal_le_nhdsSet _ = 𝓝ˢ (K ×ˢ t) := (hK.nhdsSet_prod_eq ht).symm _ ≤ 𝓝ˢ (Set.univ ×ˢ t) := nhdsSet_mono (prod_mono_left le_top) theorem nhds_prod_le_of_disjoint_cocompact {f : Filter Y} (x : X) (hf : Disjoint f (Filter.cocompact Y)) : 𝓝 x ×ˢ f ≤ 𝓝ˢ ({x} ×ˢ Set.univ) := by simpa using nhdsSet_prod_le_of_disjoint_cocompact isCompact_singleton hf theorem prod_nhds_le_of_disjoint_cocompact {f : Filter X} (y : Y) (hf : Disjoint f (Filter.cocompact X)) : f ×ˢ 𝓝 y ≤ 𝓝ˢ (Set.univ ×ˢ {y}) := by simpa using prod_nhdsSet_le_of_disjoint_cocompact isCompact_singleton hf /-- If `s` and `t` are compact sets and `n` is an open neighborhood of `s × t`, then there exist open neighborhoods `u ⊇ s` and `v ⊇ t` such that `u × v ⊆ n`. See also `IsCompact.nhdsSet_prod_eq`. -/ theorem generalized_tube_lemma (hs : IsCompact s) {t : Set Y} (ht : IsCompact t) {n : Set (X × Y)} (hn : IsOpen n) (hp : s ×ˢ t ⊆ n) : ∃ (u : Set X) (v : Set Y), IsOpen u ∧ IsOpen v ∧ s ⊆ u ∧ t ⊆ v ∧ u ×ˢ v ⊆ n := by rw [← hn.mem_nhdsSet, hs.nhdsSet_prod_eq ht, ((hasBasis_nhdsSet _).prod (hasBasis_nhdsSet _)).mem_iff] at hp rcases hp with ⟨⟨u, v⟩, ⟨⟨huo, hsu⟩, hvo, htv⟩, hn⟩ exact ⟨u, v, huo, hvo, hsu, htv, hn⟩ -- see Note [lower instance priority] instance (priority := 10) Subsingleton.compactSpace [Subsingleton X] : CompactSpace X := ⟨subsingleton_univ.isCompact⟩ theorem isCompact_univ_iff : IsCompact (univ : Set X) ↔ CompactSpace X := ⟨fun h => ⟨h⟩, fun h => h.1⟩ theorem isCompact_univ [h : CompactSpace X] : IsCompact (univ : Set X) := h.isCompact_univ theorem exists_clusterPt_of_compactSpace [CompactSpace X] (f : Filter X) [NeBot f] : ∃ x, ClusterPt x f := by simpa using isCompact_univ (show f ≤ 𝓟 univ by simp) nonrec theorem Ultrafilter.le_nhds_lim [CompactSpace X] (F : Ultrafilter X) : ↑F ≤ 𝓝 F.lim := by rcases isCompact_univ.ultrafilter_le_nhds F (by simp) with ⟨x, -, h⟩ exact le_nhds_lim ⟨x, h⟩ theorem CompactSpace.elim_nhds_subcover [CompactSpace X] (U : X → Set X) (hU : ∀ x, U x ∈ 𝓝 x) : ∃ t : Finset X, ⋃ x ∈ t, U x = ⊤ := by obtain ⟨t, -, s⟩ := IsCompact.elim_nhds_subcover isCompact_univ U fun x _ => hU x exact ⟨t, top_unique s⟩ theorem compactSpace_of_finite_subfamily_closed (h : ∀ {ι : Type u} (t : ι → Set X), (∀ i, IsClosed (t i)) → ⋂ i, t i = ∅ → ∃ u : Finset ι, ⋂ i ∈ u, t i = ∅) : CompactSpace X where isCompact_univ := isCompact_of_finite_subfamily_closed fun t => by simpa using h t /-- Given a family of closed sets `t i` in a compact space, if they satisfy the Finite Intersection Property, then the intersection of all `t i` is nonempty. -/ lemma CompactSpace.iInter_nonempty {ι : Type v} [CompactSpace X] {t : ι → Set X} (htc : ∀ i, IsClosed (t i)) (hst : ∀ s : Finset ι, (⋂ i ∈ s, t i).Nonempty) : (⋂ i, t i).Nonempty := by simpa using IsCompact.inter_iInter_nonempty isCompact_univ t htc (by simpa using hst) omit [TopologicalSpace X] in /-- The `CompactSpace` version of **Alexander's subbasis theorem**. If `X` is a topological space with a subbasis `S`, then `X` is compact if for any open cover of `X` all of whose elements belong to `S`, there is a finite subcover. -/ theorem compactSpace_generateFrom [T : TopologicalSpace X] {S : Set (Set X)} (hTS : T = generateFrom S) (h : ∀ P ⊆ S, ⋃₀ P = univ → ∃ Q ⊆ P, Q.Finite ∧ ⋃₀ Q = univ) : CompactSpace X := by rw [← isCompact_univ_iff] exact isCompact_generateFrom hTS <| by simpa theorem IsClosed.isCompact [CompactSpace X] (h : IsClosed s) : IsCompact s := isCompact_univ.of_isClosed_subset h (subset_univ _) /-- If a filter has a unique cluster point `y` in a compact topological space, then the filter is less than or equal to `𝓝 y`. -/ lemma le_nhds_of_unique_clusterPt [CompactSpace X] {l : Filter X} {y : X} (h : ∀ x, ClusterPt x l → x = y) : l ≤ 𝓝 y := isCompact_univ.le_nhds_of_unique_clusterPt univ_mem fun x _ ↦ h x /-- If `y` is a unique `MapClusterPt` for `f` along `l` and the codomain of `f` is a compact space, then `f` tends to `𝓝 y` along `l`. -/ lemma tendsto_nhds_of_unique_mapClusterPt [CompactSpace X] {Y} {l : Filter Y} {y : X} {f : Y → X} (h : ∀ x, MapClusterPt x l f → x = y) : Tendsto f l (𝓝 y) := le_nhds_of_unique_clusterPt h lemma noncompact_univ (X : Type*) [TopologicalSpace X] [NoncompactSpace X] : ¬IsCompact (univ : Set X) := NoncompactSpace.noncompact_univ theorem IsCompact.ne_univ [NoncompactSpace X] (hs : IsCompact s) : s ≠ univ := fun h => noncompact_univ X (h ▸ hs) instance [NoncompactSpace X] : NeBot (Filter.cocompact X) := by refine Filter.hasBasis_cocompact.neBot_iff.2 fun hs => ?_ contrapose hs; rw [not_nonempty_iff_eq_empty, compl_empty_iff] at hs rw [hs]; exact noncompact_univ X @[simp] theorem Filter.cocompact_eq_bot [CompactSpace X] : Filter.cocompact X = ⊥ := Filter.hasBasis_cocompact.eq_bot_iff.mpr ⟨Set.univ, isCompact_univ, Set.compl_univ⟩ instance [NoncompactSpace X] : NeBot (Filter.coclosedCompact X) := neBot_of_le Filter.cocompact_le_coclosedCompact theorem noncompactSpace_of_neBot (_ : NeBot (Filter.cocompact X)) : NoncompactSpace X := ⟨fun h' => (Filter.nonempty_of_mem h'.compl_mem_cocompact).ne_empty compl_univ⟩ theorem Filter.cocompact_neBot_iff : NeBot (Filter.cocompact X) ↔ NoncompactSpace X := ⟨noncompactSpace_of_neBot, fun _ => inferInstance⟩ theorem not_compactSpace_iff : ¬CompactSpace X ↔ NoncompactSpace X := ⟨fun h₁ => ⟨fun h₂ => h₁ ⟨h₂⟩⟩, fun ⟨h₁⟩ ⟨h₂⟩ => h₁ h₂⟩ instance : NoncompactSpace ℤ := noncompactSpace_of_neBot <| by simp only [Filter.cocompact_eq_cofinite, Filter.cofinite_neBot] -- Note: We can't make this into an instance because it loops with `Finite.compactSpace`. /-- A compact discrete space is finite. -/ theorem finite_of_compact_of_discrete [CompactSpace X] [DiscreteTopology X] : Finite X := Finite.of_finite_univ <| isCompact_univ.finite_of_discrete lemma Set.Infinite.exists_accPt_cofinite_inf_principal_of_subset_isCompact {K : Set X} (hs : s.Infinite) (hK : IsCompact K) (hsub : s ⊆ K) : ∃ x ∈ K, AccPt x (cofinite ⊓ 𝓟 s) := (@hK _ hs.cofinite_inf_principal_neBot (inf_le_right.trans <| principal_mono.2 hsub)).imp fun x hx ↦ by rwa [accPt_iff_clusterPt, inf_comm, inf_right_comm, (finite_singleton _).cofinite_inf_principal_compl] lemma Set.Infinite.exists_accPt_of_subset_isCompact {K : Set X} (hs : s.Infinite) (hK : IsCompact K) (hsub : s ⊆ K) : ∃ x ∈ K, AccPt x (𝓟 s) := let ⟨x, hxK, hx⟩ := hs.exists_accPt_cofinite_inf_principal_of_subset_isCompact hK hsub ⟨x, hxK, hx.mono inf_le_right⟩ lemma Set.Infinite.exists_accPt_cofinite_inf_principal [CompactSpace X] (hs : s.Infinite) : ∃ x, AccPt x (cofinite ⊓ 𝓟 s) := by simpa only [mem_univ, true_and] using hs.exists_accPt_cofinite_inf_principal_of_subset_isCompact isCompact_univ s.subset_univ lemma Set.Infinite.exists_accPt_principal [CompactSpace X] (hs : s.Infinite) : ∃ x, AccPt x (𝓟 s) := hs.exists_accPt_cofinite_inf_principal.imp fun _x hx ↦ hx.mono inf_le_right theorem exists_nhds_ne_neBot (X : Type*) [TopologicalSpace X] [CompactSpace X] [Infinite X] : ∃ z : X, (𝓝[≠] z).NeBot := by simpa [AccPt] using (@infinite_univ X _).exists_accPt_principal theorem finite_cover_nhds_interior [CompactSpace X] {U : X → Set X} (hU : ∀ x, U x ∈ 𝓝 x) : ∃ t : Finset X, ⋃ x ∈ t, interior (U x) = univ := let ⟨t, ht⟩ := isCompact_univ.elim_finite_subcover (fun x => interior (U x)) (fun _ => isOpen_interior) fun x _ => mem_iUnion.2 ⟨x, mem_interior_iff_mem_nhds.2 (hU x)⟩ ⟨t, univ_subset_iff.1 ht⟩ theorem finite_cover_nhds [CompactSpace X] {U : X → Set X} (hU : ∀ x, U x ∈ 𝓝 x) : ∃ t : Finset X, ⋃ x ∈ t, U x = univ := let ⟨t, ht⟩ := finite_cover_nhds_interior hU ⟨t, univ_subset_iff.1 <| ht.symm.subset.trans <| iUnion₂_mono fun _ _ => interior_subset⟩ /-- The comap of the cocompact filter on `Y` by a continuous function `f : X → Y` is less than or equal to the cocompact filter on `X`. This is a reformulation of the fact that images of compact sets are compact. -/ theorem Filter.comap_cocompact_le {f : X → Y} (hf : Continuous f) : (Filter.cocompact Y).comap f ≤ Filter.cocompact X := by rw [(Filter.hasBasis_cocompact.comap f).le_basis_iff Filter.hasBasis_cocompact] intro t ht refine ⟨f '' t, ht.image hf, ?_⟩ simpa using t.subset_preimage_image f /-- If a filter is disjoint from the cocompact filter, so is its image under any continuous function. -/ theorem disjoint_map_cocompact {g : X → Y} {f : Filter X} (hg : Continuous g) (hf : Disjoint f (Filter.cocompact X)) : Disjoint (map g f) (Filter.cocompact Y) := by rw [← Filter.disjoint_comap_iff_map, disjoint_iff_inf_le] calc f ⊓ (comap g (cocompact Y)) _ ≤ f ⊓ Filter.cocompact X := inf_le_inf_left f (Filter.comap_cocompact_le hg) _ = ⊥ := disjoint_iff.mp hf theorem isCompact_range [CompactSpace X] {f : X → Y} (hf : Continuous f) : IsCompact (range f) := by rw [← image_univ]; exact isCompact_univ.image hf theorem isCompact_diagonal [CompactSpace X] : IsCompact (diagonal X) := @range_diag X ▸ isCompact_range (continuous_id.prodMk continuous_id) theorem exists_subset_nhds_of_compactSpace [CompactSpace X] [Nonempty ι] {V : ι → Set X} (hV : Directed (· ⊇ ·) V) (hV_closed : ∀ i, IsClosed (V i)) {U : Set X} (hU : ∀ x ∈ ⋂ i, V i, U ∈ 𝓝 x) : ∃ i, V i ⊆ U := exists_subset_nhds_of_isCompact' hV (fun i => (hV_closed i).isCompact) hV_closed hU /-- If `f : X → Y` is an inducing map, the image `f '' s` of a set `s` is compact if and only if `s` is compact. -/ theorem Topology.IsInducing.isCompact_iff {f : X → Y} (hf : IsInducing f) : IsCompact s ↔ IsCompact (f '' s) := by refine ⟨fun hs => hs.image hf.continuous, fun hs F F_ne_bot F_le => ?_⟩ obtain ⟨_, ⟨x, x_in : x ∈ s, rfl⟩, hx : ClusterPt (f x) (map f F)⟩ := hs ((map_mono F_le).trans_eq map_principal) exact ⟨x, x_in, hf.mapClusterPt_iff.1 hx⟩ /-- If `f : X → Y` is an embedding, the image `f '' s` of a set `s` is compact if and only if `s` is compact. -/ theorem Topology.IsEmbedding.isCompact_iff {f : X → Y} (hf : IsEmbedding f) : IsCompact s ↔ IsCompact (f '' s) := hf.isInducing.isCompact_iff /-- The preimage of a compact set under an inducing map is a compact set. -/ theorem Topology.IsInducing.isCompact_preimage (hf : IsInducing f) (hf' : IsClosed (range f)) {K : Set Y} (hK : IsCompact K) : IsCompact (f ⁻¹' K) := by replace hK := hK.inter_right hf' rwa [hf.isCompact_iff, image_preimage_eq_inter_range] lemma Topology.IsInducing.isCompact_preimage_iff {f : X → Y} (hf : IsInducing f) {K : Set Y} (Kf : K ⊆ range f) : IsCompact (f ⁻¹' K) ↔ IsCompact K := by rw [hf.isCompact_iff, image_preimage_eq_of_subset Kf] /-- The preimage of a compact set in the image of an inducing map is compact. -/ lemma Topology.IsInducing.isCompact_preimage' (hf : IsInducing f) {K : Set Y} (hK : IsCompact K) (Kf : K ⊆ range f) : IsCompact (f ⁻¹' K) := (hf.isCompact_preimage_iff Kf).2 hK /-- The preimage of a compact set under a closed embedding is a compact set. -/ theorem Topology.IsClosedEmbedding.isCompact_preimage (hf : IsClosedEmbedding f) {K : Set Y} (hK : IsCompact K) : IsCompact (f ⁻¹' K) := hf.isInducing.isCompact_preimage (hf.isClosed_range) hK /-- A closed embedding is proper, i.e., inverse images of compact sets are contained in compacts. Moreover, the preimage of a compact set is compact, see `IsClosedEmbedding.isCompact_preimage`. -/ theorem Topology.IsClosedEmbedding.tendsto_cocompact (hf : IsClosedEmbedding f) : Tendsto f (Filter.cocompact X) (Filter.cocompact Y) := Filter.hasBasis_cocompact.tendsto_right_iff.mpr fun _K hK => (hf.isCompact_preimage hK).compl_mem_cocompact /-- Sets of subtype are compact iff the image under a coercion is. -/ theorem Subtype.isCompact_iff {p : X → Prop} {s : Set { x // p x }} : IsCompact s ↔ IsCompact ((↑) '' s : Set X) := IsEmbedding.subtypeVal.isCompact_iff theorem isCompact_iff_isCompact_univ : IsCompact s ↔ IsCompact (univ : Set s) := by rw [Subtype.isCompact_iff, image_univ, Subtype.range_coe] theorem isCompact_iff_compactSpace : IsCompact s ↔ CompactSpace s := isCompact_iff_isCompact_univ.trans isCompact_univ_iff theorem IsCompact.finite (hs : IsCompact s) (hs' : DiscreteTopology s) : s.Finite := finite_coe_iff.mp (@finite_of_compact_of_discrete _ _ (isCompact_iff_compactSpace.mp hs) hs') theorem exists_nhds_ne_inf_principal_neBot (hs : IsCompact s) (hs' : s.Infinite) : ∃ z ∈ s, (𝓝[≠] z ⊓ 𝓟 s).NeBot := hs'.exists_accPt_of_subset_isCompact hs Subset.rfl protected theorem Topology.IsClosedEmbedding.noncompactSpace [NoncompactSpace X] {f : X → Y} (hf : IsClosedEmbedding f) : NoncompactSpace Y := noncompactSpace_of_neBot hf.tendsto_cocompact.neBot protected theorem Topology.IsClosedEmbedding.compactSpace [h : CompactSpace Y] {f : X → Y} (hf : IsClosedEmbedding f) : CompactSpace X := ⟨by rw [hf.isInducing.isCompact_iff, image_univ]; exact hf.isClosed_range.isCompact⟩ theorem IsCompact.prod {t : Set Y} (hs : IsCompact s) (ht : IsCompact t) : IsCompact (s ×ˢ t) := by rw [isCompact_iff_ultrafilter_le_nhds'] at hs ht ⊢ intro f hfs obtain ⟨x : X, sx : x ∈ s, hx : map Prod.fst f.1 ≤ 𝓝 x⟩ := hs (f.map Prod.fst) (mem_map.2 <| mem_of_superset hfs fun x => And.left) obtain ⟨y : Y, ty : y ∈ t, hy : map Prod.snd f.1 ≤ 𝓝 y⟩ := ht (f.map Prod.snd) (mem_map.2 <| mem_of_superset hfs fun x => And.right) rw [map_le_iff_le_comap] at hx hy refine ⟨⟨x, y⟩, ⟨sx, ty⟩, ?_⟩ rw [nhds_prod_eq]; exact le_inf hx hy /-- Finite topological spaces are compact. -/ instance (priority := 100) Finite.compactSpace [Finite X] : CompactSpace X where isCompact_univ := finite_univ.isCompact instance ULift.compactSpace [CompactSpace X] : CompactSpace (ULift.{v} X) := IsClosedEmbedding.uliftDown.compactSpace /-- The product of two compact spaces is compact. -/ instance [CompactSpace X] [CompactSpace Y] : CompactSpace (X × Y) := ⟨by rw [← univ_prod_univ]; exact isCompact_univ.prod isCompact_univ⟩ /-- The disjoint union of two compact spaces is compact. -/ instance [CompactSpace X] [CompactSpace Y] : CompactSpace (X ⊕ Y) := ⟨by rw [← range_inl_union_range_inr] exact (isCompact_range continuous_inl).union (isCompact_range continuous_inr)⟩ instance {X : ι → Type*} [Finite ι] [∀ i, TopologicalSpace (X i)] [∀ i, CompactSpace (X i)] : CompactSpace (Σ i, X i) := by refine ⟨?_⟩ rw [Sigma.univ] exact isCompact_iUnion fun i => isCompact_range continuous_sigmaMk lemma Set.isCompact_sigma {X : ι → Type*} [∀ i, TopologicalSpace (X i)] {s : Set ι} {t : ∀ i, Set (X i)} (hs : s.Finite) (ht : ∀ i ∈ s, IsCompact (t i)) : IsCompact (s.sigma t) := by rw [Set.sigma_eq_biUnion] exact hs.isCompact_biUnion fun i hi ↦ (ht i hi).image continuous_sigmaMk lemma IsCompact.sigma_exists_finite_sigma_eq {X : ι → Type*} [∀ i, TopologicalSpace (X i)] (u : Set (Σ i, X i)) (hu : IsCompact u) : ∃ (s : Set ι) (t : ∀ i, Set (X i)), s.Finite ∧ (∀ i, IsCompact (t i)) ∧ s.sigma t = u := by obtain ⟨s, hs⟩ := hu.elim_finite_subcover (fun i : ι ↦ Sigma.mk i '' (Sigma.mk i ⁻¹' Set.univ)) (fun i ↦ isOpenMap_sigmaMk _ <| isOpen_univ.preimage continuous_sigmaMk) fun x hx ↦ (by simp) use s, fun i ↦ Sigma.mk i ⁻¹' u, s.finite_toSet, fun i ↦ ?_, ?_ · exact Topology.IsClosedEmbedding.sigmaMk.isCompact_preimage hu · ext x simp only [Set.mem_sigma_iff, Finset.mem_coe, Set.mem_preimage, and_iff_right_iff_imp] intro hx obtain ⟨i, hi⟩ := Set.mem_iUnion.mp (hs hx) simp_all /-- The coproduct of the cocompact filters on two topological spaces is the cocompact filter on their product. -/ theorem Filter.coprod_cocompact : (Filter.cocompact X).coprod (Filter.cocompact Y) = Filter.cocompact (X × Y) := by apply le_antisymm · exact sup_le (comap_cocompact_le continuous_fst) (comap_cocompact_le continuous_snd) · refine (hasBasis_cocompact.coprod hasBasis_cocompact).ge_iff.2 fun K hK ↦ ?_ rw [← univ_prod, ← prod_univ, ← compl_prod_eq_union] exact (hK.1.prod hK.2).compl_mem_cocompact theorem Prod.noncompactSpace_iff : NoncompactSpace (X × Y) ↔ NoncompactSpace X ∧ Nonempty Y ∨ Nonempty X ∧ NoncompactSpace Y := by simp [← Filter.cocompact_neBot_iff, ← Filter.coprod_cocompact, Filter.coprod_neBot_iff] -- See Note [lower instance priority] instance (priority := 100) Prod.noncompactSpace_left [NoncompactSpace X] [Nonempty Y] : NoncompactSpace (X × Y) := Prod.noncompactSpace_iff.2 (Or.inl ⟨‹_›, ‹_›⟩) -- See Note [lower instance priority] instance (priority := 100) Prod.noncompactSpace_right [Nonempty X] [NoncompactSpace Y] : NoncompactSpace (X × Y) := Prod.noncompactSpace_iff.2 (Or.inr ⟨‹_›, ‹_›⟩) section Tychonoff variable {X : ι → Type*} [∀ i, TopologicalSpace (X i)] /-- **Tychonoff's theorem**: product of compact sets is compact. -/ theorem isCompact_pi_infinite {s : ∀ i, Set (X i)} : (∀ i, IsCompact (s i)) → IsCompact { x : ∀ i, X i | ∀ i, x i ∈ s i } := by simp only [isCompact_iff_ultrafilter_le_nhds, nhds_pi, le_pi, le_principal_iff] intro h f hfs have : ∀ i : ι, ∃ x, x ∈ s i ∧ Tendsto (Function.eval i) f (𝓝 x) := by refine fun i => h i (f.map _) (mem_map.2 ?_) exact mem_of_superset hfs fun x hx => hx i choose x hx using this exact ⟨x, fun i => (hx i).left, fun i => (hx i).right⟩ /-- **Tychonoff's theorem** formulated using `Set.pi`: product of compact sets is compact. -/ theorem isCompact_univ_pi {s : ∀ i, Set (X i)} (h : ∀ i, IsCompact (s i)) : IsCompact (pi univ s) := by convert isCompact_pi_infinite h simp only [← mem_univ_pi, setOf_mem_eq] instance Pi.compactSpace [∀ i, CompactSpace (X i)] : CompactSpace (∀ i, X i) := ⟨by rw [← pi_univ univ]; exact isCompact_univ_pi fun i => isCompact_univ⟩ instance Function.compactSpace [CompactSpace Y] : CompactSpace (ι → Y) := Pi.compactSpace lemma Pi.isCompact_iff_of_isClosed {s : Set (Π i, X i)} (hs : IsClosed s) : IsCompact s ↔ ∀ i, IsCompact (eval i '' s) := by constructor <;> intro H · exact fun i ↦ H.image <| continuous_apply i · exact IsCompact.of_isClosed_subset (isCompact_univ_pi H) hs (subset_pi_eval_image univ s) protected lemma Pi.exists_compact_superset_iff {s : Set (Π i, X i)} : (∃ K, IsCompact K ∧ s ⊆ K) ↔ ∀ i, ∃ Ki, IsCompact Ki ∧ s ⊆ eval i ⁻¹' Ki := by constructor · intro ⟨K, hK, hsK⟩ i exact ⟨eval i '' K, hK.image <| continuous_apply i, hsK.trans <| K.subset_preimage_image _⟩ · intro H choose K hK hsK using H exact ⟨pi univ K, isCompact_univ_pi hK, fun _ hx i _ ↦ hsK i hx⟩ /-- **Tychonoff's theorem** formulated in terms of filters: `Filter.cocompact` on an indexed product type `Π d, X d` the `Filter.coprodᵢ` of filters `Filter.cocompact` on `X d`. -/ theorem Filter.coprodᵢ_cocompact {X : ι → Type*} [∀ d, TopologicalSpace (X d)] : (Filter.coprodᵢ fun d => Filter.cocompact (X d)) = Filter.cocompact (∀ d, X d) := by refine le_antisymm (iSup_le fun i => Filter.comap_cocompact_le (continuous_apply i)) ?_ refine compl_surjective.forall.2 fun s H => ?_ simp only [compl_mem_coprodᵢ, Filter.mem_cocompact, compl_subset_compl, image_subset_iff] at H ⊢ choose K hKc htK using H exact ⟨Set.pi univ K, isCompact_univ_pi hKc, fun f hf i _ => htK i hf⟩ end Tychonoff instance Quot.compactSpace {r : X → X → Prop} [CompactSpace X] : CompactSpace (Quot r) := ⟨by rw [← range_quot_mk] exact isCompact_range continuous_quot_mk⟩ instance Quotient.compactSpace {s : Setoid X} [CompactSpace X] : CompactSpace (Quotient s) := Quot.compactSpace theorem IsClosed.exists_minimal_nonempty_closed_subset [CompactSpace X] {S : Set X} (hS : IsClosed S) (hne : S.Nonempty) : ∃ V : Set X, V ⊆ S ∧ V.Nonempty ∧ IsClosed V ∧ ∀ V' : Set X, V' ⊆ V → V'.Nonempty → IsClosed V' → V' = V := by let opens := { U : Set X | Sᶜ ⊆ U ∧ IsOpen U ∧ Uᶜ.Nonempty } obtain ⟨U, h⟩ := zorn_subset opens fun c hc hz => by by_cases hcne : c.Nonempty · obtain ⟨U₀, hU₀⟩ := hcne haveI : Nonempty { U // U ∈ c } := ⟨⟨U₀, hU₀⟩⟩ obtain ⟨U₀compl, -, -⟩ := hc hU₀ use ⋃₀ c refine ⟨⟨?_, ?_, ?_⟩, fun U hU _ hx => ⟨U, hU, hx⟩⟩ · exact fun _ hx => ⟨U₀, hU₀, U₀compl hx⟩ · exact isOpen_sUnion fun _ h => (hc h).2.1 · convert_to (⋂ U : { U // U ∈ c }, U.1ᶜ).Nonempty · ext simp only [not_exists, not_and, Set.mem_iInter, Subtype.forall, mem_compl_iff, mem_sUnion] apply IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed · rintro ⟨U, hU⟩ ⟨U', hU'⟩ obtain ⟨V, hVc, hVU, hVU'⟩ := hz.directedOn U hU U' hU' exact ⟨⟨V, hVc⟩, Set.compl_subset_compl.mpr hVU, Set.compl_subset_compl.mpr hVU'⟩ · exact fun U => (hc U.2).2.2 · exact fun U => (hc U.2).2.1.isClosed_compl.isCompact · exact fun U => (hc U.2).2.1.isClosed_compl · use Sᶜ refine ⟨⟨Set.Subset.refl _, isOpen_compl_iff.mpr hS, ?_⟩, fun U Uc => (hcne ⟨U, Uc⟩).elim⟩ rw [compl_compl] exact hne obtain ⟨Uc, Uo, Ucne⟩ := h.prop refine ⟨Uᶜ, Set.compl_subset_comm.mp Uc, Ucne, Uo.isClosed_compl, ?_⟩ intro V' V'sub V'ne V'cls have : V'ᶜ = U := by refine h.eq_of_ge ⟨?_, isOpen_compl_iff.mpr V'cls, ?_⟩ (subset_compl_comm.2 V'sub) · exact Set.Subset.trans Uc (Set.subset_compl_comm.mp V'sub) · simp only [compl_compl, V'ne] rw [← this, compl_compl] end Compact
.lake/packages/mathlib/Mathlib/Topology/Compactness/SigmaCompact.lean
import Mathlib.Topology.Bases import Mathlib.Topology.Compactness.LocallyCompact import Mathlib.Topology.Compactness.LocallyFinite /-! # Sigma-compactness in topological spaces ## Main definitions * `IsSigmaCompact`: a set that is the union of countably many compact sets. * `SigmaCompactSpace X`: `X` is a σ-compact topological space; i.e., is the union of a countable collection of compact subspaces. -/ open Set Filter Topology TopologicalSpace universe u v variable {X : Type*} {Y : Type*} {ι : Type*} variable [TopologicalSpace X] [TopologicalSpace Y] {s t : Set X} /-- A subset `s ⊆ X` is called **σ-compact** if it is the union of countably many compact sets. -/ def IsSigmaCompact (s : Set X) : Prop := ∃ K : ℕ → Set X, (∀ n, IsCompact (K n)) ∧ ⋃ n, K n = s /-- Compact sets are σ-compact. -/ lemma IsCompact.isSigmaCompact {s : Set X} (hs : IsCompact s) : IsSigmaCompact s := ⟨fun _ => s, fun _ => hs, iUnion_const _⟩ /-- The empty set is σ-compact. -/ @[simp] lemma isSigmaCompact_empty : IsSigmaCompact (∅ : Set X) := IsCompact.isSigmaCompact isCompact_empty /-- Countable unions of compact sets are σ-compact. -/ lemma isSigmaCompact_iUnion_of_isCompact [hι : Countable ι] (s : ι → Set X) (hcomp : ∀ i, IsCompact (s i)) : IsSigmaCompact (⋃ i, s i) := by rcases isEmpty_or_nonempty ι · simp only [iUnion_of_empty, isSigmaCompact_empty] · -- If ι is non-empty, choose a surjection f : ℕ → ι, this yields a map ℕ → Set X. obtain ⟨f, hf⟩ := countable_iff_exists_surjective.mp hι exact ⟨s ∘ f, fun n ↦ hcomp (f n), Function.Surjective.iUnion_comp hf _⟩ /-- Countable unions of compact sets are σ-compact. -/ lemma isSigmaCompact_sUnion_of_isCompact {S : Set (Set X)} (hc : Set.Countable S) (hcomp : ∀ (s : Set X), s ∈ S → IsCompact s) : IsSigmaCompact (⋃₀ S) := by have : Countable S := countable_coe_iff.mpr hc rw [sUnion_eq_iUnion] apply isSigmaCompact_iUnion_of_isCompact _ (fun ⟨s, hs⟩ ↦ hcomp s hs) /-- Countable unions of σ-compact sets are σ-compact. -/ lemma isSigmaCompact_iUnion [Countable ι] (s : ι → Set X) (hcomp : ∀ i, IsSigmaCompact (s i)) : IsSigmaCompact (⋃ i, s i) := by -- Choose a decomposition s_i = ⋃ K_i,j for each i. choose K hcomp hcov using fun i ↦ hcomp i -- Then, we have a countable union of countable unions of compact sets, i.e. countably many. have := calc ⋃ i, s i _ = ⋃ i, ⋃ n, (K i n) := by simp_rw [hcov] _ = ⋃ (i) (n : ℕ), (K.uncurry ⟨i, n⟩) := by rw [Function.uncurry_def] _ = ⋃ x, K.uncurry x := by rw [← iUnion_prod'] rw [this] exact isSigmaCompact_iUnion_of_isCompact K.uncurry fun x ↦ (hcomp x.1 x.2) /-- Countable unions of σ-compact sets are σ-compact. -/ lemma isSigmaCompact_sUnion (S : Set (Set X)) (hc : Set.Countable S) (hcomp : ∀ s : S, IsSigmaCompact s (X := X)) : IsSigmaCompact (⋃₀ S) := by have : Countable S := countable_coe_iff.mpr hc apply sUnion_eq_iUnion.symm ▸ isSigmaCompact_iUnion _ hcomp /-- Countable unions of σ-compact sets are σ-compact. -/ lemma isSigmaCompact_biUnion {s : Set ι} {S : ι → Set X} (hc : Set.Countable s) (hcomp : ∀ (i : ι), i ∈ s → IsSigmaCompact (S i)) : IsSigmaCompact (⋃ (i : ι) (_ : i ∈ s), S i) := by have : Countable ↑s := countable_coe_iff.mpr hc rw [biUnion_eq_iUnion] exact isSigmaCompact_iUnion _ (fun ⟨i', hi'⟩ ↦ hcomp i' hi') /-- A closed subset of a σ-compact set is σ-compact. -/ lemma IsSigmaCompact.of_isClosed_subset {s t : Set X} (ht : IsSigmaCompact t) (hs : IsClosed s) (h : s ⊆ t) : IsSigmaCompact s := by rcases ht with ⟨K, hcompact, hcov⟩ refine ⟨(fun n ↦ s ∩ (K n)), fun n ↦ (hcompact n).inter_left hs, ?_⟩ rw [← inter_iUnion, hcov] exact inter_eq_left.mpr h /-- If `s` is σ-compact and `f` is continuous on `s`, `f(s)` is σ-compact. -/ lemma IsSigmaCompact.image_of_continuousOn {f : X → Y} {s : Set X} (hs : IsSigmaCompact s) (hf : ContinuousOn f s) : IsSigmaCompact (f '' s) := by rcases hs with ⟨K, hcompact, hcov⟩ refine ⟨fun n ↦ f '' K n, ?_, hcov.symm ▸ image_iUnion.symm⟩ exact fun n ↦ (hcompact n).image_of_continuousOn (hf.mono (hcov.symm ▸ subset_iUnion K n)) /-- If `s` is σ-compact and `f` continuous, `f(s)` is σ-compact. -/ lemma IsSigmaCompact.image {f : X → Y} (hf : Continuous f) {s : Set X} (hs : IsSigmaCompact s) : IsSigmaCompact (f '' s) := hs.image_of_continuousOn hf.continuousOn /-- If `f : X → Y` is an inducing map, the image `f '' s` of a set `s` is σ-compact if and only `s` is σ-compact. -/ lemma Topology.IsInducing.isSigmaCompact_iff {f : X → Y} {s : Set X} (hf : IsInducing f) : IsSigmaCompact s ↔ IsSigmaCompact (f '' s) := by constructor · exact fun h ↦ h.image hf.continuous · rintro ⟨L, hcomp, hcov⟩ -- Suppose f(s) is σ-compact; we want to show s is σ-compact. -- Write f(s) as a union of compact sets L n, so s = ⋃ K n with K n := f⁻¹(L n) ∩ s. -- Since f is inducing, each K n is compact iff L n is. refine ⟨fun n ↦ f ⁻¹' (L n) ∩ s, ?_, ?_⟩ · intro n have : f '' (f ⁻¹' (L n) ∩ s) = L n := by rw [image_preimage_inter, inter_eq_left.mpr] exact (subset_iUnion _ n).trans hcov.le apply hf.isCompact_iff.mpr (this.symm ▸ (hcomp n)) · calc ⋃ n, f ⁻¹' L n ∩ s _ = f ⁻¹' (⋃ n, L n) ∩ s := by rw [preimage_iUnion, iUnion_inter] _ = f ⁻¹' (f '' s) ∩ s := by rw [hcov] _ = s := inter_eq_right.mpr (subset_preimage_image _ _) /-- If `f : X → Y` is an embedding, the image `f '' s` of a set `s` is σ-compact if and only `s` is σ-compact. -/ lemma Topology.IsEmbedding.isSigmaCompact_iff {f : X → Y} {s : Set X} (hf : IsEmbedding f) : IsSigmaCompact s ↔ IsSigmaCompact (f '' s) := hf.isInducing.isSigmaCompact_iff /-- Sets of subtype are σ-compact iff the image under a coercion is. -/ lemma Subtype.isSigmaCompact_iff {p : X → Prop} {s : Set { a // p a }} : IsSigmaCompact s ↔ IsSigmaCompact ((↑) '' s : Set X) := IsEmbedding.subtypeVal.isSigmaCompact_iff /-- A σ-compact space is a space that is the union of a countable collection of compact subspaces. Note that a locally compact separable T₂ space need not be σ-compact. The sequence can be extracted using `compactCovering`. -/ class SigmaCompactSpace (X : Type*) [TopologicalSpace X] : Prop where /-- In a σ-compact space, `Set.univ` is a σ-compact set. -/ isSigmaCompact_univ : IsSigmaCompact (univ : Set X) /-- A topological space is σ-compact iff `univ` is σ-compact. -/ lemma isSigmaCompact_univ_iff : IsSigmaCompact (univ : Set X) ↔ SigmaCompactSpace X := ⟨fun h => ⟨h⟩, fun h => h.1⟩ /-- In a σ-compact space, `univ` is σ-compact. -/ lemma isSigmaCompact_univ [h : SigmaCompactSpace X] : IsSigmaCompact (univ : Set X) := isSigmaCompact_univ_iff.mpr h /-- A topological space is σ-compact iff there exists a countable collection of compact subspaces that cover the entire space. -/ lemma SigmaCompactSpace_iff_exists_compact_covering : SigmaCompactSpace X ↔ ∃ K : ℕ → Set X, (∀ n, IsCompact (K n)) ∧ ⋃ n, K n = univ := by rw [← isSigmaCompact_univ_iff, IsSigmaCompact] lemma SigmaCompactSpace.exists_compact_covering [h : SigmaCompactSpace X] : ∃ K : ℕ → Set X, (∀ n, IsCompact (K n)) ∧ ⋃ n, K n = univ := SigmaCompactSpace_iff_exists_compact_covering.mp h /-- If `X` is σ-compact, `im f` is σ-compact. -/ lemma isSigmaCompact_range {f : X → Y} (hf : Continuous f) [SigmaCompactSpace X] : IsSigmaCompact (range f) := image_univ ▸ isSigmaCompact_univ.image hf /-- A subset `s` is σ-compact iff `s` (with the subspace topology) is a σ-compact space. -/ lemma isSigmaCompact_iff_isSigmaCompact_univ {s : Set X} : IsSigmaCompact s ↔ IsSigmaCompact (univ : Set s) := by rw [Subtype.isSigmaCompact_iff, image_univ, Subtype.range_coe] lemma isSigmaCompact_iff_sigmaCompactSpace {s : Set X} : IsSigmaCompact s ↔ SigmaCompactSpace s := isSigmaCompact_iff_isSigmaCompact_univ.trans isSigmaCompact_univ_iff -- see Note [lower instance priority] instance (priority := 200) CompactSpace.sigmaCompact [CompactSpace X] : SigmaCompactSpace X := ⟨⟨fun _ => univ, fun _ => isCompact_univ, iUnion_const _⟩⟩ theorem SigmaCompactSpace.of_countable (S : Set (Set X)) (Hc : S.Countable) (Hcomp : ∀ s ∈ S, IsCompact s) (HU : ⋃₀ S = univ) : SigmaCompactSpace X := ⟨(exists_seq_cover_iff_countable ⟨_, isCompact_empty⟩).2 ⟨S, Hc, Hcomp, HU⟩⟩ -- see Note [lower instance priority] instance (priority := 100) sigmaCompactSpace_of_locallyCompact_secondCountable [LocallyCompactSpace X] [SecondCountableTopology X] : SigmaCompactSpace X := by choose K hKc hxK using fun x : X => exists_compact_mem_nhds x rcases countable_cover_nhds hxK with ⟨s, hsc, hsU⟩ refine SigmaCompactSpace.of_countable _ (hsc.image K) (forall_mem_image.2 fun x _ => hKc x) ?_ rwa [sUnion_image] section variable (X) variable [SigmaCompactSpace X] open SigmaCompactSpace /-- A choice of compact covering for a `σ`-compact space, chosen to be monotone. -/ def compactCovering : ℕ → Set X := Accumulate exists_compact_covering.choose theorem isCompact_compactCovering (n : ℕ) : IsCompact (compactCovering X n) := isCompact_accumulate (Classical.choose_spec SigmaCompactSpace.exists_compact_covering).1 n theorem iUnion_compactCovering : ⋃ n, compactCovering X n = univ := by rw [compactCovering, iUnion_accumulate] exact (Classical.choose_spec SigmaCompactSpace.exists_compact_covering).2 theorem iUnion_closure_compactCovering : ⋃ n, closure (compactCovering X n) = univ := eq_top_mono (iUnion_mono fun _ ↦ subset_closure) (iUnion_compactCovering X) @[mono, gcongr] theorem compactCovering_subset ⦃m n : ℕ⦄ (h : m ≤ n) : compactCovering X m ⊆ compactCovering X n := monotone_accumulate h variable {X} theorem exists_mem_compactCovering (x : X) : ∃ n, x ∈ compactCovering X n := iUnion_eq_univ_iff.mp (iUnion_compactCovering X) x instance [SigmaCompactSpace Y] : SigmaCompactSpace (X × Y) := ⟨⟨fun n => compactCovering X n ×ˢ compactCovering Y n, fun _ => (isCompact_compactCovering _ _).prod (isCompact_compactCovering _ _), by simp only [iUnion_prod_of_monotone (compactCovering_subset X) (compactCovering_subset Y), iUnion_compactCovering, univ_prod_univ]⟩⟩ instance [Finite ι] {X : ι → Type*} [∀ i, TopologicalSpace (X i)] [∀ i, SigmaCompactSpace (X i)] : SigmaCompactSpace (∀ i, X i) := by refine ⟨⟨fun n => Set.pi univ fun i => compactCovering (X i) n, fun n => isCompact_univ_pi fun i => isCompact_compactCovering (X i) _, ?_⟩⟩ rw [iUnion_univ_pi_of_monotone] · simp only [iUnion_compactCovering, pi_univ] · exact fun i => compactCovering_subset (X i) instance [SigmaCompactSpace Y] : SigmaCompactSpace (X ⊕ Y) := ⟨⟨fun n => Sum.inl '' compactCovering X n ∪ Sum.inr '' compactCovering Y n, fun n => ((isCompact_compactCovering X n).image continuous_inl).union ((isCompact_compactCovering Y n).image continuous_inr), by simp only [iUnion_union_distrib, ← image_iUnion, iUnion_compactCovering, image_univ, range_inl_union_range_inr]⟩⟩ instance [Countable ι] {X : ι → Type*} [∀ i, TopologicalSpace (X i)] [∀ i, SigmaCompactSpace (X i)] : SigmaCompactSpace (Σ i, X i) := by cases isEmpty_or_nonempty ι · infer_instance · rcases exists_surjective_nat ι with ⟨f, hf⟩ refine ⟨⟨fun n => ⋃ k ≤ n, Sigma.mk (f k) '' compactCovering (X (f k)) n, fun n => ?_, ?_⟩⟩ · refine (finite_le_nat _).isCompact_biUnion fun k _ => ?_ exact (isCompact_compactCovering _ _).image continuous_sigmaMk · simp only [iUnion_eq_univ_iff, Sigma.forall, mem_iUnion, hf.forall] intro k y rcases exists_mem_compactCovering y with ⟨n, hn⟩ refine ⟨max k n, k, le_max_left _ _, mem_image_of_mem _ ?_⟩ exact compactCovering_subset _ (le_max_right _ _) hn protected lemma Topology.IsClosedEmbedding.sigmaCompactSpace {e : Y → X} (he : IsClosedEmbedding e) : SigmaCompactSpace Y := ⟨⟨fun n => e ⁻¹' compactCovering X n, fun _ => he.isCompact_preimage (isCompact_compactCovering _ _), by rw [← preimage_iUnion, iUnion_compactCovering, preimage_univ]⟩⟩ theorem IsClosed.sigmaCompactSpace {s : Set X} (hs : IsClosed s) : SigmaCompactSpace s := hs.isClosedEmbedding_subtypeVal.sigmaCompactSpace instance [SigmaCompactSpace Y] : SigmaCompactSpace (ULift.{u} Y) := IsClosedEmbedding.uliftDown.sigmaCompactSpace /-- If `X` is a `σ`-compact space, then a locally finite family of nonempty sets of `X` can have only countably many elements, `Set.Countable` version. -/ protected theorem LocallyFinite.countable_univ {f : ι → Set X} (hf : LocallyFinite f) (hne : ∀ i, (f i).Nonempty) : (univ : Set ι).Countable := by have := fun n => hf.finite_nonempty_inter_compact (isCompact_compactCovering X n) refine (countable_iUnion fun n => (this n).countable).mono fun i _ => ?_ rcases hne i with ⟨x, hx⟩ rcases iUnion_eq_univ_iff.1 (iUnion_compactCovering X) x with ⟨n, hn⟩ exact mem_iUnion.2 ⟨n, x, hx, hn⟩ /-- If `f : ι → Set X` is a locally finite covering of a σ-compact topological space by nonempty sets, then the index type `ι` is encodable. -/ protected noncomputable def LocallyFinite.encodable {ι : Type*} {f : ι → Set X} (hf : LocallyFinite f) (hne : ∀ i, (f i).Nonempty) : Encodable ι := @Encodable.ofEquiv _ _ (hf.countable_univ hne).toEncodable (Equiv.Set.univ _).symm /-- In a topological space with sigma compact topology, if `f` is a function that sends each point `x` of a closed set `s` to a neighborhood of `x` within `s`, then for some countable set `t ⊆ s`, the neighborhoods `f x`, `x ∈ t`, cover the whole set `s`. -/ theorem countable_cover_nhdsWithin_of_sigmaCompact {f : X → Set X} {s : Set X} (hs : IsClosed s) (hf : ∀ x ∈ s, f x ∈ 𝓝[s] x) : ∃ t ⊆ s, t.Countable ∧ s ⊆ ⋃ x ∈ t, f x := by simp only [nhdsWithin, mem_inf_principal] at hf choose t ht hsub using fun n => ((isCompact_compactCovering X n).inter_right hs).elim_nhds_subcover _ fun x hx => hf x hx.right refine ⟨⋃ n, (t n : Set X), iUnion_subset fun n x hx => (ht n x hx).2, countable_iUnion fun n => (t n).countable_toSet, fun x hx => mem_iUnion₂.2 ?_⟩ rcases exists_mem_compactCovering x with ⟨n, hn⟩ rcases mem_iUnion₂.1 (hsub n ⟨hn, hx⟩) with ⟨y, hyt : y ∈ t n, hyf : x ∈ s → x ∈ f y⟩ exact ⟨y, mem_iUnion.2 ⟨n, hyt⟩, hyf hx⟩ /-- In a topological space with sigma compact topology, if `f` is a function that sends each point `x` to a neighborhood of `x`, then for some countable set `s`, the neighborhoods `f x`, `x ∈ s`, cover the whole space. -/ theorem countable_cover_nhds_of_sigmaCompact {f : X → Set X} (hf : ∀ x, f x ∈ 𝓝 x) : ∃ s : Set X, s.Countable ∧ ⋃ x ∈ s, f x = univ := by simp only [← nhdsWithin_univ] at hf rcases countable_cover_nhdsWithin_of_sigmaCompact isClosed_univ fun x _ => hf x with ⟨s, -, hsc, hsU⟩ exact ⟨s, hsc, univ_subset_iff.1 hsU⟩ end /-- An [exhaustion by compact sets](https://en.wikipedia.org/wiki/Exhaustion_by_compact_sets) of a topological space is a sequence of compact sets `K n` such that `K n ⊆ interior (K (n + 1))` and `⋃ n, K n = univ`. If `X` is a locally compact sigma compact space, then `CompactExhaustion.choice X` provides a choice of an exhaustion by compact sets. This choice is also available as `(default : CompactExhaustion X)`. -/ structure CompactExhaustion (X : Type*) [TopologicalSpace X] where /-- The sequence of compact sets that form a compact exhaustion. -/ toFun : ℕ → Set X /-- The sets in the compact exhaustion are in fact compact. -/ isCompact' : ∀ n, IsCompact (toFun n) /-- The sets in the compact exhaustion form a sequence: each set is contained in the interior of the next. -/ subset_interior_succ' : ∀ n, toFun n ⊆ interior (toFun (n + 1)) /-- The union of all sets in a compact exhaustion equals the entire space. -/ iUnion_eq' : ⋃ n, toFun n = univ namespace CompactExhaustion instance : FunLike (CompactExhaustion X) ℕ (Set X) where coe := toFun coe_injective' | ⟨_, _, _, _⟩, ⟨_, _, _, _⟩, rfl => rfl instance : RelHomClass (CompactExhaustion X) LE.le HasSubset.Subset where map_rel f _ _ h := monotone_nat_of_le_succ (fun n ↦ (f.subset_interior_succ' n).trans interior_subset) h variable (K : CompactExhaustion X) @[simp] theorem toFun_eq_coe : K.toFun = K := rfl protected theorem isCompact (n : ℕ) : IsCompact (K n) := K.isCompact' n theorem subset_interior_succ (n : ℕ) : K n ⊆ interior (K (n + 1)) := K.subset_interior_succ' n @[mono] protected theorem subset ⦃m n : ℕ⦄ (h : m ≤ n) : K m ⊆ K n := OrderHomClass.mono K h theorem subset_succ (n : ℕ) : K n ⊆ K (n + 1) := K.subset n.le_succ theorem subset_interior ⦃m n : ℕ⦄ (h : m < n) : K m ⊆ interior (K n) := Subset.trans (K.subset_interior_succ m) <| interior_mono <| K.subset h theorem iUnion_eq : ⋃ n, K n = univ := K.iUnion_eq' theorem exists_mem (x : X) : ∃ n, x ∈ K n := iUnion_eq_univ_iff.1 K.iUnion_eq x theorem exists_mem_nhds (x : X) : ∃ n, K n ∈ 𝓝 x := by rcases K.exists_mem x with ⟨n, hn⟩ exact ⟨n + 1, mem_interior_iff_mem_nhds.mp <| K.subset_interior_succ n hn⟩ /-- A compact exhaustion eventually covers any compact set. -/ theorem exists_superset_of_isCompact {s : Set X} (hs : IsCompact s) : ∃ n, s ⊆ K n := by suffices ∃ n, s ⊆ interior (K n) from this.imp fun _ ↦ (Subset.trans · interior_subset) refine hs.elim_directed_cover (interior ∘ K) (fun _ ↦ isOpen_interior) ?_ ?_ · intro x _ rcases K.exists_mem x with ⟨k, hk⟩ exact mem_iUnion.2 ⟨k + 1, K.subset_interior_succ _ hk⟩ · exact Monotone.directed_le fun _ _ h ↦ interior_mono <| K.subset h open Classical in /-- The minimal `n` such that `x ∈ K n`. -/ protected noncomputable def find (x : X) : ℕ := Nat.find (K.exists_mem x) theorem mem_find (x : X) : x ∈ K (K.find x) := by classical exact Nat.find_spec (K.exists_mem x) theorem mem_iff_find_le {x : X} {n : ℕ} : x ∈ K n ↔ K.find x ≤ n := by classical exact ⟨fun h => Nat.find_min' (K.exists_mem x) h, fun h => K.subset h <| K.mem_find x⟩ /-- Prepend the empty set to a compact exhaustion `K n`. -/ def shiftr : CompactExhaustion X where toFun n := Nat.casesOn n ∅ K isCompact' n := Nat.casesOn n isCompact_empty K.isCompact subset_interior_succ' n := Nat.casesOn n (empty_subset _) K.subset_interior_succ iUnion_eq' := iUnion_eq_univ_iff.2 fun x => ⟨K.find x + 1, K.mem_find x⟩ @[simp] theorem find_shiftr (x : X) : K.shiftr.find x = K.find x + 1 := by classical exact Nat.find_comp_succ _ _ (notMem_empty _) theorem mem_diff_shiftr_find (x : X) : x ∈ K.shiftr (K.find x + 1) \ K.shiftr (K.find x) := ⟨K.mem_find _, mt K.shiftr.mem_iff_find_le.1 <| by simp only [find_shiftr, not_le, Nat.lt_succ_self]⟩ /-- A choice of an [exhaustion by compact sets](https://en.wikipedia.org/wiki/Exhaustion_by_compact_sets) of a weakly locally compact σ-compact space. -/ noncomputable def choice (X : Type*) [TopologicalSpace X] [WeaklyLocallyCompactSpace X] [SigmaCompactSpace X] : CompactExhaustion X := by apply Classical.choice let K : ℕ → { s : Set X // IsCompact s } := fun n => Nat.recOn n ⟨∅, isCompact_empty⟩ fun n s => ⟨(exists_compact_superset s.2).choose ∪ compactCovering X n, (exists_compact_superset s.2).choose_spec.1.union (isCompact_compactCovering _ _)⟩ refine ⟨⟨fun n ↦ (K n).1, fun n => (K n).2, fun n ↦ ?_, ?_⟩⟩ · exact Subset.trans (exists_compact_superset (K n).2).choose_spec.2 (interior_mono subset_union_left) · refine univ_subset_iff.1 (iUnion_compactCovering X ▸ ?_) exact iUnion_mono' fun n => ⟨n + 1, subset_union_right⟩ noncomputable instance [SigmaCompactSpace X] [WeaklyLocallyCompactSpace X] : Inhabited (CompactExhaustion X) := ⟨CompactExhaustion.choice X⟩ end CompactExhaustion
.lake/packages/mathlib/Mathlib/Topology/Compactness/PseudometrizableLindelof.lean
import Mathlib.Topology.Metrizable.Basic import Mathlib.Topology.Compactness.Lindelof /-! # Second-countability of pseudometrizable Lindelöf spaces Factored out from `Mathlib/Topology/Compactness/Lindelof.lean` to avoid circular dependencies. -/ variable {X : Type*} [TopologicalSpace X] open Set Filter Topology TopologicalSpace instance SecondCountableTopology.ofPseudoMetrizableSpaceLindelofSpace [PseudoMetrizableSpace X] [LindelofSpace X] : SecondCountableTopology X := by letI : PseudoMetricSpace X := TopologicalSpace.pseudoMetrizableSpacePseudoMetric X have h_dense (ε) (hpos : 0 < ε) : ∃ s : Set X, s.Countable ∧ ∀ x, ∃ y ∈ s, dist x y ≤ ε := by let U := fun (z : X) ↦ Metric.ball z ε obtain ⟨t, hct, huniv⟩ := LindelofSpace.elim_nhds_subcover U (fun _ ↦ (Metric.isOpen_ball).mem_nhds (Metric.mem_ball_self hpos)) refine ⟨t, hct, fun z ↦ ?_⟩ obtain ⟨y, ht, hzy⟩ : ∃ y ∈ t, z ∈ U y := exists_set_mem_of_union_eq_top t (fun i ↦ U i) huniv z exact ⟨y, ht, (Metric.mem_ball.mp hzy).le⟩ exact Metric.secondCountable_of_almost_dense_set h_dense
.lake/packages/mathlib/Mathlib/Topology/Compactness/Paracompact.lean
import Mathlib.Data.Option.Basic import Mathlib.Topology.Separation.Regular /-! # Paracompact topological spaces A topological space `X` is said to be paracompact if every open covering of `X` admits a locally finite refinement. The definition requires that each set of the new covering is a subset of one of the sets of the initial covering. However, one can ensure that each open covering `s : ι → Set X` admits a *precise* locally finite refinement, i.e., an open covering `t : ι → Set X` with the same index set such that `∀ i, t i ⊆ s i`, see lemma `precise_refinement`. We also provide a convenience lemma `precise_refinement_set` that deals with open coverings of a closed subset of `X` instead of the whole space. We also prove the following facts. * Every compact space is paracompact, see instance `paracompact_of_compact`. * A locally compact sigma compact Hausdorff space is paracompact, see instance `paracompact_of_locallyCompact_sigmaCompact`. Moreover, we can choose a locally finite refinement with sets in a given collection of filter bases of `𝓝 x`, `x : X`, see `refinement_of_locallyCompact_sigmaCompact_of_nhds_basis`. For example, in a proper metric space every open covering `⋃ i, s i` admits a refinement `⋃ i, Metric.ball (c i) (r i)`. * Every paracompact Hausdorff space is normal. This statement is not an instance to avoid loops in the instance graph. * Every `EMetricSpace` is a paracompact space, see instance `EMetric.instParacompactSpace` in `Topology/EMetricSpace/Paracompact`. ## TODO Prove (some of) [Michael's theorems](https://ncatlab.org/nlab/show/Michael%27s+theorem). ## Tags compact space, paracompact space, locally finite covering -/ open Set Filter Function open Filter Topology universe u v w /-- A topological space is called paracompact, if every open covering of this space admits a locally finite refinement. We use the same universe for all types in the definition to avoid creating a class like `ParacompactSpace.{u v}`. Due to lemma `precise_refinement` below, every open covering `s : α → Set X` indexed on `α : Type v` has a *precise* locally finite refinement, i.e., a locally finite refinement `t : α → Set X` indexed on the same type such that each `∀ i, t i ⊆ s i`. -/ class ParacompactSpace (X : Type v) [TopologicalSpace X] : Prop where /-- Every open cover of a paracompact space assumes a locally finite refinement. -/ locallyFinite_refinement : ∀ (α : Type v) (s : α → Set X), (∀ a, IsOpen (s a)) → (⋃ a, s a = univ) → ∃ (β : Type v) (t : β → Set X), (∀ b, IsOpen (t b)) ∧ (⋃ b, t b = univ) ∧ LocallyFinite t ∧ ∀ b, ∃ a, t b ⊆ s a variable {ι : Type u} {X : Type v} {Y : Type w} [TopologicalSpace X] [TopologicalSpace Y] /-- Any open cover of a paracompact space has a locally finite *precise* refinement, that is, one indexed on the same type with each open set contained in the corresponding original one. -/ theorem precise_refinement [ParacompactSpace X] (u : ι → Set X) (uo : ∀ a, IsOpen (u a)) (uc : ⋃ i, u i = univ) : ∃ v : ι → Set X, (∀ a, IsOpen (v a)) ∧ ⋃ i, v i = univ ∧ LocallyFinite v ∧ ∀ a, v a ⊆ u a := by -- Apply definition to `range u`, then turn existence quantifiers into functions using `choose` have := ParacompactSpace.locallyFinite_refinement (range u) (fun r ↦ (r : Set X)) (forall_subtype_range_iff.2 uo) (by rwa [← sUnion_range, Subtype.range_coe]) simp only [exists_subtype_range_iff, iUnion_eq_univ_iff] at this choose α t hto hXt htf ind hind using this choose t_inv ht_inv using hXt choose U hxU hU using htf -- Send each `i` to the union of `t a` over `a ∈ ind ⁻¹' {i}` refine ⟨fun i ↦ ⋃ (a : α) (_ : ind a = i), t a, ?_, ?_, ?_, ?_⟩ · exact fun a ↦ isOpen_iUnion fun a ↦ isOpen_iUnion fun _ ↦ hto a · simp only [eq_univ_iff_forall, mem_iUnion] exact fun x ↦ ⟨ind (t_inv x), _, rfl, ht_inv _⟩ · refine fun x ↦ ⟨U x, hxU x, ((hU x).image ind).subset ?_⟩ simp only [subset_def, mem_iUnion, mem_setOf_eq, Set.Nonempty, mem_inter_iff] rintro i ⟨y, ⟨a, rfl, hya⟩, hyU⟩ exact mem_image_of_mem _ ⟨y, hya, hyU⟩ · simp only [subset_def, mem_iUnion] rintro i x ⟨a, rfl, hxa⟩ exact hind _ hxa /-- In a paracompact space, every open covering of a closed set admits a locally finite refinement indexed by the same type. -/ theorem precise_refinement_set [ParacompactSpace X] {s : Set X} (hs : IsClosed s) (u : ι → Set X) (uo : ∀ i, IsOpen (u i)) (us : s ⊆ ⋃ i, u i) : ∃ v : ι → Set X, (∀ i, IsOpen (v i)) ∧ (s ⊆ ⋃ i, v i) ∧ LocallyFinite v ∧ ∀ i, v i ⊆ u i := by have uc : (iUnion fun i => Option.elim' sᶜ u i) = univ := by apply Subset.antisymm (subset_univ _) · simp_rw [← compl_union_self s, Option.elim', iUnion_option] apply union_subset_union_right sᶜ us rcases precise_refinement (Option.elim' sᶜ u) (Option.forall.2 ⟨isOpen_compl_iff.2 hs, uo⟩) uc with ⟨v, vo, vc, vf, vu⟩ refine ⟨v ∘ some, fun i ↦ vo _, ?_, vf.comp_injective (Option.some_injective _), fun i ↦ vu _⟩ · simp only [iUnion_option, ← compl_subset_iff_union] at vc exact Subset.trans (subset_compl_comm.1 <| vu Option.none) vc theorem ParacompactSpace.of_hasBasis {ι : X → Sort*} {p : ∀ x, ι x → Prop} {s : ∀ x, ι x → Set X} (hb : ∀ x, (𝓝 x).HasBasis (p x) (s x)) (h : ∀ f : (x : X) → ι x, (∀ x, p x (f x)) → ∃ (β : Type u) (t : β → Set X), (∀ b, IsOpen (t b)) ∧ (⋃ b, t b) = univ ∧ LocallyFinite t ∧ ∀ b, ∃ x, t b ⊆ s x (f x)) : ParacompactSpace X where locallyFinite_refinement α S ho hu := by have := fun x ↦ (iUnion_eq_univ_iff.1 hu x).imp fun a ha ↦ (hb _).mem_iff.1 ((ho a).mem_nhds ha) choose a f hp hsub using this rcases h f hp with ⟨β, t, hto, ht, htf, hts⟩ refine ⟨range t, Subtype.val, forall_subtype_range_iff.2 hto, ?_, htf.on_range, forall_subtype_range_iff.2 fun b ↦ ?_⟩ · rwa [iUnion_subtype, biUnion_range] · rcases hts b with ⟨x, hx⟩ exact ⟨_, hx.trans (hsub _)⟩ theorem Topology.IsClosedEmbedding.paracompactSpace [ParacompactSpace Y] {e : X → Y} (he : IsClosedEmbedding e) : ParacompactSpace X where locallyFinite_refinement α s ho hu := by choose U hUo hU using fun a ↦ he.isOpen_iff.1 (ho a) simp only [← hU] at hu ⊢ have heU : range e ⊆ ⋃ i, U i := by simpa only [range_subset_iff, mem_iUnion, iUnion_eq_univ_iff] using hu rcases precise_refinement_set he.isClosed_range U hUo heU with ⟨V, hVo, heV, hVf, hVU⟩ refine ⟨α, fun a ↦ e ⁻¹' (V a), fun a ↦ (hVo a).preimage he.continuous, ?_, hVf.preimage_continuous he.continuous, fun a ↦ ⟨a, preimage_mono (hVU a)⟩⟩ simpa only [range_subset_iff, mem_iUnion, iUnion_eq_univ_iff] using heV theorem Homeomorph.paracompactSpace_iff (e : X ≃ₜ Y) : ParacompactSpace X ↔ ParacompactSpace Y := ⟨fun _ ↦ e.symm.isClosedEmbedding.paracompactSpace, fun _ ↦ e.isClosedEmbedding.paracompactSpace⟩ /-- The product of a compact space and a paracompact space is a paracompact space. The formalization is based on https://dantopology.wordpress.com/2009/10/24/compact-x-paracompact-is-paracompact/ with some minor modifications. This version assumes that `X` in `X × Y` is compact and `Y` is paracompact, see next lemma for the other case. -/ instance (priority := 200) [CompactSpace X] [ParacompactSpace Y] : ParacompactSpace (X × Y) where locallyFinite_refinement α s ho hu := by have : ∀ (x : X) (y : Y), ∃ (a : α) (U : Set X) (V : Set Y), IsOpen U ∧ IsOpen V ∧ x ∈ U ∧ y ∈ V ∧ U ×ˢ V ⊆ s a := fun x y ↦ (iUnion_eq_univ_iff.1 hu (x, y)).imp fun a ha ↦ isOpen_prod_iff.1 (ho a) x y ha choose a U V hUo hVo hxU hyV hUV using this choose T hT using fun y ↦ CompactSpace.elim_nhds_subcover (U · y) fun x ↦ (hUo x y).mem_nhds (hxU x y) set W : Y → Set Y := fun y ↦ ⋂ x ∈ T y, V x y have hWo : ∀ y, IsOpen (W y) := fun y ↦ isOpen_biInter_finset fun _ _ ↦ hVo _ _ have hW : ∀ y, y ∈ W y := fun _ ↦ mem_iInter₂.2 fun _ _ ↦ hyV _ _ rcases precise_refinement W hWo (iUnion_eq_univ_iff.2 fun y ↦ ⟨y, hW y⟩) with ⟨E, hEo, hE, hEf, hEA⟩ refine ⟨Σ y, T y, fun z ↦ U z.2.1 z.1 ×ˢ E z.1, fun _ ↦ (hUo _ _).prod (hEo _), iUnion_eq_univ_iff.2 fun (x, y) ↦ ?_, fun (x, y) ↦ ?_, fun ⟨y, x, hx⟩ ↦ ?_⟩ · rcases iUnion_eq_univ_iff.1 hE y with ⟨b, hb⟩ rcases iUnion₂_eq_univ_iff.1 (hT b) x with ⟨a, ha, hx⟩ exact ⟨⟨b, a, ha⟩, hx, hb⟩ · rcases hEf y with ⟨t, ht, htf⟩ refine ⟨univ ×ˢ t, prod_mem_nhds univ_mem ht, ?_⟩ refine (htf.biUnion fun y _ ↦ finite_range (Sigma.mk y)).subset ?_ rintro ⟨b, a, ha⟩ ⟨⟨c, d⟩, ⟨-, hd : d ∈ E b⟩, -, hdt : d ∈ t⟩ exact mem_iUnion₂.2 ⟨b, ⟨d, hd, hdt⟩, mem_range_self _⟩ · refine ⟨a x y, (Set.prod_mono Subset.rfl ?_).trans (hUV x y)⟩ exact (hEA _).trans (iInter₂_subset x hx) instance (priority := 200) [ParacompactSpace X] [CompactSpace Y] : ParacompactSpace (X × Y) := (Homeomorph.prodComm X Y).paracompactSpace_iff.2 inferInstance -- See note [lower instance priority] /-- A compact space is paracompact. -/ instance (priority := 100) paracompact_of_compact [CompactSpace X] : ParacompactSpace X := by -- the proof is trivial: we choose a finite subcover using compactness, and use it refine ⟨fun ι s ho hu ↦ ?_⟩ rcases isCompact_univ.elim_finite_subcover _ ho hu.ge with ⟨T, hT⟩ refine ⟨(T : Set ι), fun t ↦ s t, fun t ↦ ho _, ?_, locallyFinite_of_finite _, fun t ↦ ⟨t, Subset.rfl⟩⟩ simpa only [iUnion_coe_set, ← univ_subset_iff] /-- Let `X` be a locally compact sigma compact Hausdorff topological space, let `s` be a closed set in `X`. Suppose that for each `x ∈ s` the sets `B x : ι x → Set X` with the predicate `p x : ι x → Prop` form a basis of the filter `𝓝 x`. Then there exists a locally finite covering `fun i ↦ B (c i) (r i)` of `s` such that all “centers” `c i` belong to `s` and each `r i` satisfies `p (c i)`. The notation is inspired by the case `B x r = Metric.ball x r` but the theorem applies to `nhds_basis_opens` as well. If the covering must be subordinate to some open covering of `s`, then the user should use a basis obtained by `Filter.HasBasis.restrict_subset` or a similar lemma, see the proof of `paracompact_of_locallyCompact_sigmaCompact` for an example. The formalization is based on two [ncatlab](https://ncatlab.org/) proofs: * [locally compact and sigma compact spaces are paracompact](https://ncatlab.org/nlab/show/locally+compact+and+sigma-compact+spaces+are+paracompact); * [open cover of smooth manifold admits locally finite refinement by closed balls](https://ncatlab.org/nlab/show/partition+of+unity#ExistenceOnSmoothManifolds). See also `refinement_of_locallyCompact_sigmaCompact_of_nhds_basis` for a version of this lemma dealing with a covering of the whole space. In most cases (namely, if `B c r ∪ B c r'` is again a set of the form `B c r''`) it is possible to choose `α = X`. This fact is not yet formalized in `mathlib`. -/ theorem refinement_of_locallyCompact_sigmaCompact_of_nhds_basis_set [WeaklyLocallyCompactSpace X] [SigmaCompactSpace X] [T2Space X] {ι : X → Type u} {p : ∀ x, ι x → Prop} {B : ∀ x, ι x → Set X} {s : Set X} (hs : IsClosed s) (hB : ∀ x ∈ s, (𝓝 x).HasBasis (p x) (B x)) : ∃ (α : Type v) (c : α → X) (r : ∀ a, ι (c a)), (∀ a, c a ∈ s ∧ p (c a) (r a)) ∧ (s ⊆ ⋃ a, B (c a) (r a)) ∧ LocallyFinite fun a ↦ B (c a) (r a) := by classical -- For technical reasons we prepend two empty sets to the sequence `CompactExhaustion.choice X` set K' : CompactExhaustion X := CompactExhaustion.choice X set K : CompactExhaustion X := K'.shiftr.shiftr set Kdiff := fun n ↦ K (n + 1) \ interior (K n) -- Now we restate some properties of `CompactExhaustion` for `K`/`Kdiff` have hKcov : ∀ x, x ∈ Kdiff (K'.find x + 1) := fun x ↦ by simpa only [K'.find_shiftr] using diff_subset_diff_right interior_subset (K'.shiftr.mem_diff_shiftr_find x) have Kdiffc : ∀ n, IsCompact (Kdiff n ∩ s) := fun n ↦ ((K.isCompact _).diff isOpen_interior).inter_right hs -- Next we choose a finite covering `B (c n i) (r n i)` of each -- `Kdiff (n + 1) ∩ s` such that `B (c n i) (r n i) ∩ s` is disjoint with `K n` have : ∀ (n) (x : ↑(Kdiff (n + 1) ∩ s)), (K n)ᶜ ∈ 𝓝 (x : X) := fun n x ↦ (K.isClosed n).compl_mem_nhds fun hx' ↦ x.2.1.2 <| K.subset_interior_succ _ hx' choose! r hrp hr using fun n (x : ↑(Kdiff (n + 1) ∩ s)) ↦ (hB x x.2.2).mem_iff.1 (this n x) have hxr : ∀ (n x) (hx : x ∈ Kdiff (n + 1) ∩ s), B x (r n ⟨x, hx⟩) ∈ 𝓝 x := fun n x hx ↦ (hB x hx.2).mem_of_mem (hrp _ ⟨x, hx⟩) choose T hT using fun n ↦ (Kdiffc (n + 1)).elim_nhds_subcover' _ (hxr n) set T' : ∀ n, Set ↑(Kdiff (n + 1) ∩ s) := fun n ↦ T n -- Finally, we take the union of all these coverings refine ⟨Σ n, T' n, fun a ↦ a.2, fun a ↦ r a.1 a.2, ?_, ?_, ?_⟩ · rintro ⟨n, x, hx⟩ exact ⟨x.2.2, hrp _ _⟩ · refine fun x hx ↦ mem_iUnion.2 ?_ rcases mem_iUnion₂.1 (hT _ ⟨hKcov x, hx⟩) with ⟨⟨c, hc⟩, hcT, hcx⟩ exact ⟨⟨_, ⟨c, hc⟩, hcT⟩, hcx⟩ · intro x refine ⟨interior (K (K'.find x + 3)), IsOpen.mem_nhds isOpen_interior (K.subset_interior_succ _ (hKcov x).1), ?_⟩ have : (⋃ k ≤ K'.find x + 2, range (Sigma.mk k) : Set (Σ n, T' n)).Finite := (finite_le_nat _).biUnion fun k _ ↦ finite_range _ apply this.subset rintro ⟨k, c, hc⟩ simp only [mem_iUnion, mem_setOf_eq, Subtype.coe_mk] rintro ⟨x, hxB : x ∈ B c (r k c), hxK⟩ refine ⟨k, ?_, ⟨c, hc⟩, rfl⟩ have := (mem_compl_iff _ _).1 (hr k c hxB) contrapose! this with hnk exact K.subset hnk (interior_subset hxK) /-- Let `X` be a locally compact sigma compact Hausdorff topological space. Suppose that for each `x` the sets `B x : ι x → Set X` with the predicate `p x : ι x → Prop` form a basis of the filter `𝓝 x`. Then there exists a locally finite covering `fun i ↦ B (c i) (r i)` of `X` such that each `r i` satisfies `p (c i)`. The notation is inspired by the case `B x r = Metric.ball x r` but the theorem applies to `nhds_basis_opens` as well. If the covering must be subordinate to some open covering of `s`, then the user should use a basis obtained by `Filter.HasBasis.restrict_subset` or a similar lemma, see the proof of `paracompact_of_locallyCompact_sigmaCompact` for an example. The formalization is based on two [ncatlab](https://ncatlab.org/) proofs: * [locally compact and sigma compact spaces are paracompact](https://ncatlab.org/nlab/show/locally+compact+and+sigma-compact+spaces+are+paracompact); * [open cover of smooth manifold admits locally finite refinement by closed balls](https://ncatlab.org/nlab/show/partition+of+unity#ExistenceOnSmoothManifolds). See also `refinement_of_locallyCompact_sigmaCompact_of_nhds_basis_set` for a version of this lemma dealing with a covering of a closed set. In most cases (namely, if `B c r ∪ B c r'` is again a set of the form `B c r''`) it is possible to choose `α = X`. This fact is not yet formalized in `mathlib`. -/ theorem refinement_of_locallyCompact_sigmaCompact_of_nhds_basis [WeaklyLocallyCompactSpace X] [SigmaCompactSpace X] [T2Space X] {ι : X → Type u} {p : ∀ x, ι x → Prop} {B : ∀ x, ι x → Set X} (hB : ∀ x, (𝓝 x).HasBasis (p x) (B x)) : ∃ (α : Type v) (c : α → X) (r : ∀ a, ι (c a)), (∀ a, p (c a) (r a)) ∧ ⋃ a, B (c a) (r a) = univ ∧ LocallyFinite fun a ↦ B (c a) (r a) := let ⟨α, c, r, hp, hU, hfin⟩ := refinement_of_locallyCompact_sigmaCompact_of_nhds_basis_set isClosed_univ fun x _ ↦ hB x ⟨α, c, r, fun a ↦ (hp a).2, univ_subset_iff.1 hU, hfin⟩ -- See note [lower instance priority] /-- A locally compact sigma compact Hausdorff space is paracompact. See also `refinement_of_locallyCompact_sigmaCompact_of_nhds_basis` for a more precise statement. -/ instance (priority := 100) paracompact_of_locallyCompact_sigmaCompact [WeaklyLocallyCompactSpace X] [SigmaCompactSpace X] [T2Space X] : ParacompactSpace X := by refine ⟨fun α s ho hc ↦ ?_⟩ choose i hi using iUnion_eq_univ_iff.1 hc have : ∀ x : X, (𝓝 x).HasBasis (fun t : Set X ↦ (x ∈ t ∧ IsOpen t) ∧ t ⊆ s (i x)) id := fun x : X ↦ (nhds_basis_opens x).restrict_subset (IsOpen.mem_nhds (ho (i x)) (hi x)) rcases refinement_of_locallyCompact_sigmaCompact_of_nhds_basis this with ⟨β, c, t, hto, htc, htf⟩ exact ⟨β, t, fun x ↦ (hto x).1.2, htc, htf, fun b ↦ ⟨i <| c b, (hto b).2⟩⟩ /-- **Dieudonné's theorem**: a paracompact Hausdorff space is normal. Formalization is based on the proof at [ncatlab](https://ncatlab.org/nlab/show/paracompact+Hausdorff+spaces+are+normal). -/ instance (priority := 100) T4Space.of_paracompactSpace_t2Space [T2Space X] [ParacompactSpace X] : T4Space X := by -- First we show how to go from points to a set on one side. have : ∀ s t : Set X, IsClosed s → (∀ x ∈ s, ∃ u v, IsOpen u ∧ IsOpen v ∧ x ∈ u ∧ t ⊆ v ∧ Disjoint u v) → ∃ u v, IsOpen u ∧ IsOpen v ∧ s ⊆ u ∧ t ⊆ v ∧ Disjoint u v := fun s t hs H ↦ by /- For each `x ∈ s` we choose open disjoint `u x ∋ x` and `v x ⊇ t`. The sets `u x` form an open covering of `s`. We choose a locally finite refinement `u' : s → Set X`, then `⋃ i, u' i` and `(closure (⋃ i, u' i))ᶜ` are disjoint open neighborhoods of `s` and `t`. -/ choose u v hu hv hxu htv huv using SetCoe.forall'.1 H rcases precise_refinement_set hs u hu fun x hx ↦ mem_iUnion.2 ⟨⟨x, hx⟩, hxu _⟩ with ⟨u', hu'o, hcov', hu'fin, hsub⟩ refine ⟨⋃ i, u' i, (closure (⋃ i, u' i))ᶜ, isOpen_iUnion hu'o, isClosed_closure.isOpen_compl, hcov', ?_, disjoint_compl_right.mono le_rfl (compl_le_compl subset_closure)⟩ rw [hu'fin.closure_iUnion, compl_iUnion, subset_iInter_iff] refine fun i x hxt hxu ↦ absurd (htv i hxt) (closure_minimal ?_ (isClosed_compl_iff.2 <| hv _) hxu) exact fun y hyu hyv ↦ (huv i).le_bot ⟨hsub _ hyu, hyv⟩ -- Now we apply the lemma twice: first to `s` and `t`, then to `t` and each point of `s`. refine { normal := fun s t hs ht hst ↦ this s t hs fun x hx ↦ ?_ } rcases this t {x} ht fun y hy ↦ (by simp_rw [singleton_subset_iff] exact t2_separation (hst.symm.ne_of_mem hy hx)) with ⟨v, u, hv, hu, htv, hxu, huv⟩ exact ⟨u, v, hu, hv, singleton_subset_iff.1 hxu, htv, huv.symm⟩
.lake/packages/mathlib/Mathlib/Topology/Compactness/Lindelof.lean
import Mathlib.Topology.Bases import Mathlib.Order.Filter.CountableInter import Mathlib.Topology.Compactness.SigmaCompact /-! # Lindelöf sets and Lindelöf spaces ## Main definitions We define the following properties for sets in a topological space: * `IsLindelof s`: Two definitions are possible here. The more standard definition is that every open cover that contains `s` contains a countable subcover. We choose for the equivalent definition where we require that every nontrivial filter on `s` with the countable intersection property has a clusterpoint. Equivalence is established in `isLindelof_iff_countable_subcover`. * `LindelofSpace X`: `X` is Lindelöf if it is Lindelöf as a set. * `NonLindelofSpace`: a space that is not a Lindëlof space, e.g. the Long Line. ## Main results * `isLindelof_iff_countable_subcover`: A set is Lindelöf iff every open cover has a countable subcover. ## Implementation details * This API is mainly based on the API for IsCompact and follows notation and style as much as possible. -/ open Set Filter Topology TopologicalSpace universe u v variable {X : Type u} {Y : Type v} {ι : Type*} variable [TopologicalSpace X] [TopologicalSpace Y] {s t : Set X} section Lindelof /-- A set `s` is Lindelöf if every nontrivial filter `f` with the countable intersection property that contains `s`, has a clusterpoint in `s`. The filter-free definition is given by `isLindelof_iff_countable_subcover`. -/ def IsLindelof (s : Set X) := ∀ ⦃f⦄ [NeBot f] [CountableInterFilter f], f ≤ 𝓟 s → ∃ x ∈ s, ClusterPt x f /-- The complement to a Lindelöf set belongs to a filter `f` with the countable intersection property if it belongs to each filter `𝓝 x ⊓ f`, `x ∈ s`. -/ theorem IsLindelof.compl_mem_sets (hs : IsLindelof s) {f : Filter X} [CountableInterFilter f] (hf : ∀ x ∈ s, sᶜ ∈ 𝓝 x ⊓ f) : sᶜ ∈ f := by contrapose! hf simp only [notMem_iff_inf_principal_compl, compl_compl, inf_assoc] at hf ⊢ exact hs inf_le_right /-- The complement to a Lindelöf set belongs to a filter `f` with the countable intersection property if each `x ∈ s` has a neighborhood `t` within `s` such that `tᶜ` belongs to `f`. -/ theorem IsLindelof.compl_mem_sets_of_nhdsWithin (hs : IsLindelof s) {f : Filter X} [CountableInterFilter f] (hf : ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, tᶜ ∈ f) : sᶜ ∈ f := by refine hs.compl_mem_sets fun x hx ↦ ?_ rw [← disjoint_principal_right, disjoint_right_comm, (basis_sets _).disjoint_iff_left] exact hf x hx /-- If `p : Set X → Prop` is stable under restriction and union, and each point `x` of a Lindelöf set `s` has a neighborhood `t` within `s` such that `p t`, then `p s` holds. -/ @[elab_as_elim] theorem IsLindelof.induction_on (hs : IsLindelof s) {p : Set X → Prop} (hmono : ∀ ⦃s t⦄, s ⊆ t → p t → p s) (hcountable_union : ∀ (S : Set (Set X)), S.Countable → (∀ s ∈ S, p s) → p (⋃₀ S)) (hnhds : ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, p t) : p s := by let f : Filter X := ofCountableUnion p hcountable_union (fun t ht _ hsub ↦ hmono hsub ht) have : sᶜ ∈ f := hs.compl_mem_sets_of_nhdsWithin (by simpa [f] using hnhds) rwa [← compl_compl s] /-- The intersection of a Lindelöf set and a closed set is a Lindelöf set. -/ theorem IsLindelof.inter_right (hs : IsLindelof s) (ht : IsClosed t) : IsLindelof (s ∩ t) := by intro f hnf _ hstf rw [← inf_principal, le_inf_iff] at hstf obtain ⟨x, hsx, hx⟩ : ∃ x ∈ s, ClusterPt x f := hs hstf.1 have hxt : x ∈ t := ht.mem_of_nhdsWithin_neBot <| hx.mono hstf.2 exact ⟨x, ⟨hsx, hxt⟩, hx⟩ /-- The intersection of a closed set and a Lindelöf set is a Lindelöf set. -/ theorem IsLindelof.inter_left (ht : IsLindelof t) (hs : IsClosed s) : IsLindelof (s ∩ t) := inter_comm t s ▸ ht.inter_right hs /-- The set difference of a Lindelöf set and an open set is a Lindelöf set. -/ theorem IsLindelof.diff (hs : IsLindelof s) (ht : IsOpen t) : IsLindelof (s \ t) := hs.inter_right (isClosed_compl_iff.mpr ht) /-- A closed subset of a Lindelöf set is a Lindelöf set. -/ theorem IsLindelof.of_isClosed_subset (hs : IsLindelof s) (ht : IsClosed t) (h : t ⊆ s) : IsLindelof t := inter_eq_self_of_subset_right h ▸ hs.inter_right ht /-- A continuous image of a Lindelöf set is a Lindelöf set. -/ theorem IsLindelof.image_of_continuousOn {f : X → Y} (hs : IsLindelof s) (hf : ContinuousOn f s) : IsLindelof (f '' s) := by intro l lne _ ls have : NeBot (l.comap f ⊓ 𝓟 s) := comap_inf_principal_neBot_of_image_mem lne (le_principal_iff.1 ls) obtain ⟨x, hxs, hx⟩ : ∃ x ∈ s, ClusterPt x (l.comap f ⊓ 𝓟 s) := @hs _ this _ inf_le_right haveI := hx.neBot use f x, mem_image_of_mem f hxs have : Tendsto f (𝓝 x ⊓ (comap f l ⊓ 𝓟 s)) (𝓝 (f x) ⊓ l) := by convert (hf x hxs).inf (@tendsto_comap _ _ f l) using 1 rw [nhdsWithin] ac_rfl exact this.neBot /-- A continuous image of a Lindelöf set is a Lindelöf set within the codomain. -/ theorem IsLindelof.image {f : X → Y} (hs : IsLindelof s) (hf : Continuous f) : IsLindelof (f '' s) := hs.image_of_continuousOn hf.continuousOn /-- A filter with the countable intersection property that is finer than the principal filter on a Lindelöf set `s` contains any open set that contains all clusterpoints of `s`. -/ theorem IsLindelof.adherence_nhdset {f : Filter X} [CountableInterFilter f] (hs : IsLindelof s) (hf₂ : f ≤ 𝓟 s) (ht₁ : IsOpen t) (ht₂ : ∀ x ∈ s, ClusterPt x f → x ∈ t) : t ∈ f := (eq_or_neBot _).casesOn mem_of_eq_bot fun _ ↦ let ⟨x, hx, hfx⟩ := @hs (f ⊓ 𝓟 tᶜ) _ _ <| inf_le_of_left_le hf₂ have : x ∈ t := ht₂ x hx hfx.of_inf_left have : tᶜ ∩ t ∈ 𝓝[tᶜ] x := inter_mem_nhdsWithin _ (ht₁.mem_nhds this) have A : 𝓝[tᶜ] x = ⊥ := empty_mem_iff_bot.1 <| compl_inter_self t ▸ this have : 𝓝[tᶜ] x ≠ ⊥ := hfx.of_inf_right.ne absurd A this /-- For every open cover of a Lindelöf set, there exists a countable subcover. -/ theorem IsLindelof.elim_countable_subcover {ι : Type v} (hs : IsLindelof s) (U : ι → Set X) (hUo : ∀ i, IsOpen (U i)) (hsU : s ⊆ ⋃ i, U i) : ∃ r : Set ι, r.Countable ∧ (s ⊆ ⋃ i ∈ r, U i) := by have hmono : ∀ ⦃s t : Set X⦄, s ⊆ t → (∃ r : Set ι, r.Countable ∧ t ⊆ ⋃ i ∈ r, U i) → (∃ r : Set ι, r.Countable ∧ s ⊆ ⋃ i ∈ r, U i) := by intro _ _ hst ⟨r, ⟨hrcountable, hsub⟩⟩ exact ⟨r, hrcountable, Subset.trans hst hsub⟩ have hcountable_union : ∀ (S : Set (Set X)), S.Countable → (∀ s ∈ S, ∃ r : Set ι, r.Countable ∧ (s ⊆ ⋃ i ∈ r, U i)) → ∃ r : Set ι, r.Countable ∧ (⋃₀ S ⊆ ⋃ i ∈ r, U i) := by intro S hS hsr choose! r hr using hsr refine ⟨⋃ s ∈ S, r s, hS.biUnion_iff.mpr (fun s hs ↦ (hr s hs).1), ?_⟩ refine sUnion_subset ?h.right.h simp only [mem_iUnion, exists_prop, iUnion_exists, biUnion_and'] exact fun i is x hx ↦ mem_biUnion is ((hr i is).2 hx) have h_nhds : ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, ∃ r : Set ι, r.Countable ∧ (t ⊆ ⋃ i ∈ r, U i) := by intro x hx let ⟨i, hi⟩ := mem_iUnion.1 (hsU hx) refine ⟨U i, mem_nhdsWithin_of_mem_nhds ((hUo i).mem_nhds hi), {i}, by simp, ?_⟩ simp only [mem_singleton_iff, iUnion_iUnion_eq_left] exact Subset.refl _ exact hs.induction_on hmono hcountable_union h_nhds theorem IsLindelof.elim_nhds_subcover' (hs : IsLindelof s) (U : ∀ x ∈ s, Set X) (hU : ∀ x (hx : x ∈ s), U x ‹x ∈ s› ∈ 𝓝 x) : ∃ t : Set s, t.Countable ∧ s ⊆ ⋃ x ∈ t, U (x : s) x.2 := by have := hs.elim_countable_subcover (fun x : s ↦ interior (U x x.2)) (fun _ ↦ isOpen_interior) fun x hx ↦ mem_iUnion.2 ⟨⟨x, hx⟩, mem_interior_iff_mem_nhds.2 <| hU _ _⟩ rcases this with ⟨r, ⟨hr, hs⟩⟩ use r, hr apply Subset.trans hs apply iUnion₂_subset intro i hi apply Subset.trans interior_subset exact subset_iUnion_of_subset i (subset_iUnion_of_subset hi (Subset.refl _)) theorem IsLindelof.elim_nhds_subcover (hs : IsLindelof s) (U : X → Set X) (hU : ∀ x ∈ s, U x ∈ 𝓝 x) : ∃ t : Set X, t.Countable ∧ (∀ x ∈ t, x ∈ s) ∧ s ⊆ ⋃ x ∈ t, U x := by let ⟨t, ⟨htc, htsub⟩⟩ := hs.elim_nhds_subcover' (fun x _ ↦ U x) hU refine ⟨↑t, Countable.image htc Subtype.val, ?_⟩ constructor · intro _ simp only [mem_image, Subtype.exists, exists_and_right, exists_eq_right, forall_exists_index] tauto · have : ⋃ x ∈ t, U ↑x = ⋃ x ∈ Subtype.val '' t, U x := biUnion_image.symm rwa [← this] /-- For every nonempty open cover of a Lindelöf set, there exists a subcover indexed by ℕ. -/ theorem IsLindelof.indexed_countable_subcover {ι : Type v} [Nonempty ι] (hs : IsLindelof s) (U : ι → Set X) (hUo : ∀ i, IsOpen (U i)) (hsU : s ⊆ ⋃ i, U i) : ∃ f : ℕ → ι, s ⊆ ⋃ n, U (f n) := by obtain ⟨c, ⟨c_count, c_cov⟩⟩ := hs.elim_countable_subcover U hUo hsU rcases c.eq_empty_or_nonempty with rfl | c_nonempty · simp only [mem_empty_iff_false, iUnion_of_empty, iUnion_empty] at c_cov simp only [subset_eq_empty c_cov rfl, empty_subset, exists_const] obtain ⟨f, f_surj⟩ := (Set.countable_iff_exists_surjective c_nonempty).mp c_count refine ⟨fun x ↦ f x, c_cov.trans <| iUnion₂_subset_iff.mpr (?_ : ∀ i ∈ c, U i ⊆ ⋃ n, U (f n))⟩ intro x hx obtain ⟨n, hn⟩ := f_surj ⟨x, hx⟩ exact subset_iUnion_of_subset n <| subset_of_eq (by rw [hn]) /-- The neighborhood filter of a Lindelöf set is disjoint with a filter `l` with the countable intersection property if and only if the neighborhood filter of each point of this set is disjoint with `l`. -/ theorem IsLindelof.disjoint_nhdsSet_left {l : Filter X} [CountableInterFilter l] (hs : IsLindelof s) : Disjoint (𝓝ˢ s) l ↔ ∀ x ∈ s, Disjoint (𝓝 x) l := by refine ⟨fun h x hx ↦ h.mono_left <| nhds_le_nhdsSet hx, fun H ↦ ?_⟩ choose! U hxU hUl using fun x hx ↦ (nhds_basis_opens x).disjoint_iff_left.1 (H x hx) choose hxU hUo using hxU rcases hs.elim_nhds_subcover U fun x hx ↦ (hUo x hx).mem_nhds (hxU x hx) with ⟨t, htc, hts, hst⟩ refine (hasBasis_nhdsSet _).disjoint_iff_left.2 ⟨⋃ x ∈ t, U x, ⟨isOpen_biUnion fun x hx ↦ hUo x (hts x hx), hst⟩, ?_⟩ rw [compl_iUnion₂] exact (countable_bInter_mem htc).mpr (fun i hi ↦ hUl _ (hts _ hi)) /-- A filter `l` with the countable intersection property is disjoint with the neighborhood filter of a Lindelöf set if and only if it is disjoint with the neighborhood filter of each point of this set. -/ theorem IsLindelof.disjoint_nhdsSet_right {l : Filter X} [CountableInterFilter l] (hs : IsLindelof s) : Disjoint l (𝓝ˢ s) ↔ ∀ x ∈ s, Disjoint l (𝓝 x) := by simpa only [disjoint_comm] using hs.disjoint_nhdsSet_left /-- For every family of closed sets whose intersection avoids a Lindelöf set, there exists a countable subfamily whose intersection avoids this Lindelöf set. -/ theorem IsLindelof.elim_countable_subfamily_closed {ι : Type v} (hs : IsLindelof s) (t : ι → Set X) (htc : ∀ i, IsClosed (t i)) (hst : (s ∩ ⋂ i, t i) = ∅) : ∃ u : Set ι, u.Countable ∧ (s ∩ ⋂ i ∈ u, t i) = ∅ := by let U := tᶜ have hUo : ∀ i, IsOpen (U i) := by simp only [U, Pi.compl_apply, isOpen_compl_iff]; exact htc have hsU : s ⊆ ⋃ i, U i := by simp only [U, Pi.compl_apply] rw [← compl_iInter] apply disjoint_compl_left_iff_subset.mp simp only [compl_iInter, compl_iUnion, compl_compl] apply Disjoint.symm exact disjoint_iff_inter_eq_empty.mpr hst rcases hs.elim_countable_subcover U hUo hsU with ⟨u, ⟨hucount, husub⟩⟩ use u, hucount rw [← disjoint_compl_left_iff_subset] at husub simp only [U, Pi.compl_apply, compl_iUnion, compl_compl] at husub exact disjoint_iff_inter_eq_empty.mp (Disjoint.symm husub) /-- To show that a Lindelöf set intersects the intersection of a family of closed sets, it is sufficient to show that it intersects every countable subfamily. -/ theorem IsLindelof.inter_iInter_nonempty {ι : Type v} (hs : IsLindelof s) (t : ι → Set X) (htc : ∀ i, IsClosed (t i)) (hst : ∀ u : Set ι, u.Countable ∧ (s ∩ ⋂ i ∈ u, t i).Nonempty) : (s ∩ ⋂ i, t i).Nonempty := by contrapose! hst rcases hs.elim_countable_subfamily_closed t htc hst with ⟨u, ⟨_, husub⟩⟩ exact ⟨u, fun _ ↦ husub⟩ /-- For every open cover of a Lindelöf set, there exists a countable subcover. -/ theorem IsLindelof.elim_countable_subcover_image {b : Set ι} {c : ι → Set X} (hs : IsLindelof s) (hc₁ : ∀ i ∈ b, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i ∈ b, c i) : ∃ b', b' ⊆ b ∧ Set.Countable b' ∧ s ⊆ ⋃ i ∈ b', c i := by simp only [Subtype.forall', biUnion_eq_iUnion] at hc₁ hc₂ rcases hs.elim_countable_subcover (fun i ↦ c i : b → Set X) hc₁ hc₂ with ⟨d, hd⟩ refine ⟨Subtype.val '' d, by simp, Countable.image hd.1 Subtype.val, ?_⟩ rw [biUnion_image] exact hd.2 /-- A set `s` is Lindelöf if for every open cover of `s`, there exists a countable subcover. -/ theorem isLindelof_of_countable_subcover (h : ∀ {ι : Type u} (U : ι → Set X), (∀ i, IsOpen (U i)) → (s ⊆ ⋃ i, U i) → ∃ t : Set ι, t.Countable ∧ s ⊆ ⋃ i ∈ t, U i) : IsLindelof s := fun f hf hfs ↦ by contrapose! h simp only [ClusterPt, not_neBot, ← disjoint_iff, SetCoe.forall', (nhds_basis_opens _).disjoint_iff_left] at h choose fsub U hU hUf using h refine ⟨s, U, fun x ↦ (hU x).2, fun x hx ↦ mem_iUnion.2 ⟨⟨x, hx⟩, (hU _).1 ⟩, ?_⟩ intro t ht h have uinf := f.sets_of_superset (le_principal_iff.1 fsub) h have uninf : ⋂ i ∈ t, (U i)ᶜ ∈ f := (countable_bInter_mem ht).mpr (fun _ _ ↦ hUf _) rw [← compl_iUnion₂] at uninf have uninf := compl_notMem uninf simp only [compl_compl] at uninf contradiction /-- A set `s` is Lindelöf if for every family of closed sets whose intersection avoids `s`, there exists a countable subfamily whose intersection avoids `s`. -/ theorem isLindelof_of_countable_subfamily_closed (h : ∀ {ι : Type u} (t : ι → Set X), (∀ i, IsClosed (t i)) → (s ∩ ⋂ i, t i) = ∅ → ∃ u : Set ι, u.Countable ∧ (s ∩ ⋂ i ∈ u, t i) = ∅) : IsLindelof s := isLindelof_of_countable_subcover fun U hUo hsU ↦ by rw [← disjoint_compl_right_iff_subset, compl_iUnion, disjoint_iff] at hsU rcases h (fun i ↦ (U i)ᶜ) (fun i ↦ (hUo _).isClosed_compl) hsU with ⟨t, ht⟩ refine ⟨t, ?_⟩ rwa [← disjoint_compl_right_iff_subset, compl_iUnion₂, disjoint_iff] /-- A set `s` is Lindelöf if and only if for every open cover of `s`, there exists a countable subcover. -/ theorem isLindelof_iff_countable_subcover : IsLindelof s ↔ ∀ {ι : Type u} (U : ι → Set X), (∀ i, IsOpen (U i)) → (s ⊆ ⋃ i, U i) → ∃ t : Set ι, t.Countable ∧ s ⊆ ⋃ i ∈ t, U i := ⟨fun hs ↦ hs.elim_countable_subcover, isLindelof_of_countable_subcover⟩ /-- A set `s` is Lindelöf if and only if for every family of closed sets whose intersection avoids `s`, there exists a countable subfamily whose intersection avoids `s`. -/ theorem isLindelof_iff_countable_subfamily_closed : IsLindelof s ↔ ∀ {ι : Type u} (t : ι → Set X), (∀ i, IsClosed (t i)) → (s ∩ ⋂ i, t i) = ∅ → ∃ u : Set ι, u.Countable ∧ (s ∩ ⋂ i ∈ u, t i) = ∅ := ⟨fun hs ↦ hs.elim_countable_subfamily_closed, isLindelof_of_countable_subfamily_closed⟩ /-- The empty set is a Lindelof set. -/ @[simp] theorem isLindelof_empty : IsLindelof (∅ : Set X) := fun _f hnf _ hsf ↦ Not.elim hnf.ne <| empty_mem_iff_bot.1 <| le_principal_iff.1 hsf /-- A singleton set is a Lindelof set. -/ @[simp] theorem isLindelof_singleton {x : X} : IsLindelof ({x} : Set X) := fun _ hf _ hfa ↦ ⟨x, rfl, ClusterPt.of_le_nhds' (hfa.trans <| by simpa only [principal_singleton] using pure_le_nhds x) hf⟩ theorem Set.Subsingleton.isLindelof (hs : s.Subsingleton) : IsLindelof s := Subsingleton.induction_on hs isLindelof_empty fun _ ↦ isLindelof_singleton theorem Set.Countable.isLindelof_biUnion {s : Set ι} {f : ι → Set X} (hs : s.Countable) (hf : ∀ i ∈ s, IsLindelof (f i)) : IsLindelof (⋃ i ∈ s, f i) := by apply isLindelof_of_countable_subcover intro i U hU hUcover have hiU : ∀ i ∈ s, f i ⊆ ⋃ i, U i := fun _ is ↦ _root_.subset_trans (subset_biUnion_of_mem is) hUcover have iSets := fun i is ↦ (hf i is).elim_countable_subcover U hU (hiU i is) choose! r hr using iSets use ⋃ i ∈ s, r i constructor · refine (Countable.biUnion_iff hs).mpr ?h.left.a exact fun s hs ↦ (hr s hs).1 · refine iUnion₂_subset ?h.right.h intro i is simp only [mem_iUnion, exists_prop, iUnion_exists, biUnion_and'] intro x hx exact mem_biUnion is ((hr i is).2 hx) theorem Set.Finite.isLindelof_biUnion {s : Set ι} {f : ι → Set X} (hs : s.Finite) (hf : ∀ i ∈ s, IsLindelof (f i)) : IsLindelof (⋃ i ∈ s, f i) := Set.Countable.isLindelof_biUnion (countable hs) hf theorem Finset.isLindelof_biUnion (s : Finset ι) {f : ι → Set X} (hf : ∀ i ∈ s, IsLindelof (f i)) : IsLindelof (⋃ i ∈ s, f i) := s.finite_toSet.isLindelof_biUnion hf theorem isLindelof_accumulate {K : ℕ → Set X} (hK : ∀ n, IsLindelof (K n)) (n : ℕ) : IsLindelof (Accumulate K n) := (finite_le_nat n).isLindelof_biUnion fun k _ => hK k theorem Set.Countable.isLindelof_sUnion {S : Set (Set X)} (hf : S.Countable) (hc : ∀ s ∈ S, IsLindelof s) : IsLindelof (⋃₀ S) := by rw [sUnion_eq_biUnion]; exact hf.isLindelof_biUnion hc theorem Set.Finite.isLindelof_sUnion {S : Set (Set X)} (hf : S.Finite) (hc : ∀ s ∈ S, IsLindelof s) : IsLindelof (⋃₀ S) := by rw [sUnion_eq_biUnion]; exact hf.isLindelof_biUnion hc theorem isLindelof_iUnion {ι : Sort*} {f : ι → Set X} [Countable ι] (h : ∀ i, IsLindelof (f i)) : IsLindelof (⋃ i, f i) := (countable_range f).isLindelof_sUnion <| forall_mem_range.2 h theorem Set.Countable.isLindelof (hs : s.Countable) : IsLindelof s := biUnion_of_singleton s ▸ hs.isLindelof_biUnion fun _ _ => isLindelof_singleton theorem Set.Finite.isLindelof (hs : s.Finite) : IsLindelof s := biUnion_of_singleton s ▸ hs.isLindelof_biUnion fun _ _ => isLindelof_singleton theorem IsLindelof.countable_of_discrete [DiscreteTopology X] (hs : IsLindelof s) : s.Countable := by have : ∀ x : X, ({x} : Set X) ∈ 𝓝 x := by simp [nhds_discrete] rcases hs.elim_nhds_subcover (fun x => {x}) fun x _ => this x with ⟨t, ht, _, hssubt⟩ rw [biUnion_of_singleton] at hssubt exact ht.mono hssubt theorem isLindelof_iff_countable [DiscreteTopology X] : IsLindelof s ↔ s.Countable := ⟨fun h => h.countable_of_discrete, fun h => h.isLindelof⟩ theorem IsLindelof.union (hs : IsLindelof s) (ht : IsLindelof t) : IsLindelof (s ∪ t) := by rw [union_eq_iUnion]; exact isLindelof_iUnion fun b => by cases b <;> assumption protected theorem IsLindelof.insert (hs : IsLindelof s) (a) : IsLindelof (insert a s) := isLindelof_singleton.union hs /-- If `X` has a basis consisting of compact opens, then an open set in `X` is compact open iff it is a finite union of some elements in the basis -/ theorem isLindelof_open_iff_eq_countable_iUnion_of_isTopologicalBasis (b : ι → Set X) (hb : IsTopologicalBasis (Set.range b)) (hb' : ∀ i, IsLindelof (b i)) (U : Set X) : IsLindelof U ∧ IsOpen U ↔ ∃ s : Set ι, s.Countable ∧ U = ⋃ i ∈ s, b i := by constructor · rintro ⟨h₁, h₂⟩ obtain ⟨Y, f, rfl, hf⟩ := hb.open_eq_iUnion h₂ choose f' hf' using hf have : b ∘ f' = f := funext hf' subst this obtain ⟨t, ht⟩ := h₁.elim_countable_subcover (b ∘ f') (fun i => hb.isOpen (Set.mem_range_self _)) Subset.rfl refine ⟨t.image f', Countable.image (ht.1) f', le_antisymm ?_ ?_⟩ · refine Set.Subset.trans ht.2 ?_ simp only [Set.iUnion_subset_iff] intro i hi rw [← Set.iUnion_subtype (fun x : ι => x ∈ t.image f') fun i => b i.1] exact Set.subset_iUnion (fun i : t.image f' => b i) ⟨_, mem_image_of_mem _ hi⟩ · apply Set.iUnion₂_subset rintro i hi obtain ⟨j, -, rfl⟩ := (mem_image ..).mp hi exact Set.subset_iUnion (b ∘ f') j · rintro ⟨s, hs, rfl⟩ constructor · exact hs.isLindelof_biUnion fun i _ => hb' i · exact isOpen_biUnion fun i _ => hb.isOpen (Set.mem_range_self _) /-- `Filter.coLindelof` is the filter generated by complements to Lindelöf sets. -/ def Filter.coLindelof (X : Type*) [TopologicalSpace X] : Filter X := --`Filter.coLindelof` is the filter generated by complements to Lindelöf sets. ⨅ (s : Set X) (_ : IsLindelof s), 𝓟 sᶜ theorem hasBasis_coLindelof : (coLindelof X).HasBasis IsLindelof compl := hasBasis_biInf_principal' (fun s hs t ht => ⟨s ∪ t, hs.union ht, compl_subset_compl.2 subset_union_left, compl_subset_compl.2 subset_union_right⟩) ⟨∅, isLindelof_empty⟩ theorem mem_coLindelof : s ∈ coLindelof X ↔ ∃ t, IsLindelof t ∧ tᶜ ⊆ s := hasBasis_coLindelof.mem_iff theorem mem_coLindelof' : s ∈ coLindelof X ↔ ∃ t, IsLindelof t ∧ sᶜ ⊆ t := mem_coLindelof.trans <| exists_congr fun _ => and_congr_right fun _ => compl_subset_comm theorem _root_.IsLindelof.compl_mem_coLindelof (hs : IsLindelof s) : sᶜ ∈ coLindelof X := hasBasis_coLindelof.mem_of_mem hs theorem coLindelof_le_cofinite : coLindelof X ≤ cofinite := fun s hs => compl_compl s ▸ hs.isLindelof.compl_mem_coLindelof theorem Tendsto.isLindelof_insert_range_of_coLindelof {f : X → Y} {y} (hf : Tendsto f (coLindelof X) (𝓝 y)) (hfc : Continuous f) : IsLindelof (insert y (range f)) := by intro l hne _ hle by_cases hy : ClusterPt y l · exact ⟨y, Or.inl rfl, hy⟩ simp only [clusterPt_iff_nonempty, not_forall, ← not_disjoint_iff_nonempty_inter, not_not] at hy rcases hy with ⟨s, hsy, t, htl, hd⟩ rcases mem_coLindelof.1 (hf hsy) with ⟨K, hKc, hKs⟩ have : f '' K ∈ l := by filter_upwards [htl, le_principal_iff.1 hle] with y hyt hyf rcases hyf with (rfl | ⟨x, rfl⟩) exacts [(hd.le_bot ⟨mem_of_mem_nhds hsy, hyt⟩).elim, mem_image_of_mem _ (not_not.1 fun hxK => hd.le_bot ⟨hKs hxK, hyt⟩)] rcases hKc.image hfc (le_principal_iff.2 this) with ⟨y, hy, hyl⟩ exact ⟨y, Or.inr <| image_subset_range _ _ hy, hyl⟩ /-- `Filter.coclosedLindelof` is the filter generated by complements to closed Lindelof sets. -/ def Filter.coclosedLindelof (X : Type*) [TopologicalSpace X] : Filter X := -- `Filter.coclosedLindelof` is the filter generated by complements to closed Lindelof sets. ⨅ (s : Set X) (_ : IsClosed s) (_ : IsLindelof s), 𝓟 sᶜ theorem hasBasis_coclosedLindelof : (Filter.coclosedLindelof X).HasBasis (fun s => IsClosed s ∧ IsLindelof s) compl := by simp only [Filter.coclosedLindelof, iInf_and'] refine hasBasis_biInf_principal' ?_ ⟨∅, isClosed_empty, isLindelof_empty⟩ rintro s ⟨hs₁, hs₂⟩ t ⟨ht₁, ht₂⟩ exact ⟨s ∪ t, ⟨⟨hs₁.union ht₁, hs₂.union ht₂⟩, compl_subset_compl.2 subset_union_left, compl_subset_compl.2 subset_union_right⟩⟩ theorem mem_coclosedLindelof : s ∈ coclosedLindelof X ↔ ∃ t, IsClosed t ∧ IsLindelof t ∧ tᶜ ⊆ s := by simp only [hasBasis_coclosedLindelof.mem_iff, and_assoc] theorem mem_coclosed_Lindelof' : s ∈ coclosedLindelof X ↔ ∃ t, IsClosed t ∧ IsLindelof t ∧ sᶜ ⊆ t := by simp only [mem_coclosedLindelof, compl_subset_comm] theorem coLindelof_le_coclosedLindelof : coLindelof X ≤ coclosedLindelof X := iInf_mono fun _ => le_iInf fun _ => le_rfl theorem IsLindeof.compl_mem_coclosedLindelof_of_isClosed (hs : IsLindelof s) (hs' : IsClosed s) : sᶜ ∈ Filter.coclosedLindelof X := hasBasis_coclosedLindelof.mem_of_mem ⟨hs', hs⟩ /-- X is a Lindelöf space iff every open cover has a countable subcover. -/ class LindelofSpace (X : Type*) [TopologicalSpace X] : Prop where /-- In a Lindelöf space, `Set.univ` is a Lindelöf set. -/ isLindelof_univ : IsLindelof (univ : Set X) instance (priority := 10) Subsingleton.lindelofSpace [Subsingleton X] : LindelofSpace X := ⟨subsingleton_univ.isLindelof⟩ theorem isLindelof_univ_iff : IsLindelof (univ : Set X) ↔ LindelofSpace X := ⟨fun h => ⟨h⟩, fun h => h.1⟩ theorem isLindelof_univ [h : LindelofSpace X] : IsLindelof (univ : Set X) := h.isLindelof_univ theorem cluster_point_of_Lindelof [LindelofSpace X] (f : Filter X) [NeBot f] [CountableInterFilter f] : ∃ x, ClusterPt x f := by simpa using isLindelof_univ (show f ≤ 𝓟 univ by simp) theorem LindelofSpace.elim_nhds_subcover [LindelofSpace X] (U : X → Set X) (hU : ∀ x, U x ∈ 𝓝 x) : ∃ t : Set X, t.Countable ∧ ⋃ x ∈ t, U x = univ := by obtain ⟨t, tc, -, s⟩ := IsLindelof.elim_nhds_subcover isLindelof_univ U fun x _ => hU x use t, tc apply top_unique s theorem lindelofSpace_of_countable_subfamily_closed (h : ∀ {ι : Type u} (t : ι → Set X), (∀ i, IsClosed (t i)) → ⋂ i, t i = ∅ → ∃ u : Set ι, u.Countable ∧ ⋂ i ∈ u, t i = ∅) : LindelofSpace X where isLindelof_univ := isLindelof_of_countable_subfamily_closed fun t => by simpa using h t theorem IsClosed.isLindelof [LindelofSpace X] (h : IsClosed s) : IsLindelof s := isLindelof_univ.of_isClosed_subset h (subset_univ _) /-- A compact set `s` is Lindelöf. -/ theorem IsCompact.isLindelof (hs : IsCompact s) : IsLindelof s := by tauto /-- A σ-compact set `s` is Lindelöf -/ theorem IsSigmaCompact.isLindelof (hs : IsSigmaCompact s) : IsLindelof s := by rw [IsSigmaCompact] at hs rcases hs with ⟨K, ⟨hc, huniv⟩⟩ rw [← huniv] have hl : ∀ n, IsLindelof (K n) := fun n ↦ IsCompact.isLindelof (hc n) exact isLindelof_iUnion hl /-- A compact space `X` is Lindelöf. -/ instance (priority := 100) [CompactSpace X] : LindelofSpace X := { isLindelof_univ := isCompact_univ.isLindelof} /-- A sigma-compact space `X` is Lindelöf. -/ instance (priority := 100) [SigmaCompactSpace X] : LindelofSpace X := { isLindelof_univ := isSigmaCompact_univ.isLindelof} /-- `X` is a non-Lindelöf topological space if it is not a Lindelöf space. -/ class NonLindelofSpace (X : Type*) [TopologicalSpace X] : Prop where /-- In a non-Lindelöf space, `Set.univ` is not a Lindelöf set. -/ nonLindelof_univ : ¬IsLindelof (univ : Set X) lemma nonLindelof_univ (X : Type*) [TopologicalSpace X] [NonLindelofSpace X] : ¬IsLindelof (univ : Set X) := NonLindelofSpace.nonLindelof_univ theorem IsLindelof.ne_univ [NonLindelofSpace X] (hs : IsLindelof s) : s ≠ univ := fun h ↦ nonLindelof_univ X (h ▸ hs) instance [NonLindelofSpace X] : NeBot (Filter.coLindelof X) := by refine hasBasis_coLindelof.neBot_iff.2 fun {s} hs => ?_ contrapose hs rw [not_nonempty_iff_eq_empty, compl_empty_iff] at hs rw [hs] exact nonLindelof_univ X @[simp] theorem Filter.coLindelof_eq_bot [LindelofSpace X] : Filter.coLindelof X = ⊥ := hasBasis_coLindelof.eq_bot_iff.mpr ⟨Set.univ, isLindelof_univ, Set.compl_univ⟩ instance [NonLindelofSpace X] : NeBot (Filter.coclosedLindelof X) := neBot_of_le coLindelof_le_coclosedLindelof theorem nonLindelofSpace_of_neBot (_ : NeBot (Filter.coLindelof X)) : NonLindelofSpace X := ⟨fun h' => (Filter.nonempty_of_mem h'.compl_mem_coLindelof).ne_empty compl_univ⟩ theorem Filter.coLindelof_neBot_iff : NeBot (Filter.coLindelof X) ↔ NonLindelofSpace X := ⟨nonLindelofSpace_of_neBot, fun _ => inferInstance⟩ theorem not_LindelofSpace_iff : ¬LindelofSpace X ↔ NonLindelofSpace X := ⟨fun h₁ => ⟨fun h₂ => h₁ ⟨h₂⟩⟩, fun ⟨h₁⟩ ⟨h₂⟩ => h₁ h₂⟩ theorem countable_of_Lindelof_of_discrete [LindelofSpace X] [DiscreteTopology X] : Countable X := countable_univ_iff.mp isLindelof_univ.countable_of_discrete theorem countable_cover_nhds_interior [LindelofSpace X] {U : X → Set X} (hU : ∀ x, U x ∈ 𝓝 x) : ∃ t : Set X, t.Countable ∧ ⋃ x ∈ t, interior (U x) = univ := let ⟨t, ht⟩ := isLindelof_univ.elim_countable_subcover (fun x => interior (U x)) (fun _ => isOpen_interior) fun x _ => mem_iUnion.2 ⟨x, mem_interior_iff_mem_nhds.2 (hU x)⟩ ⟨t, ⟨ht.1, univ_subset_iff.1 ht.2⟩⟩ theorem countable_cover_nhds [LindelofSpace X] {U : X → Set X} (hU : ∀ x, U x ∈ 𝓝 x) : ∃ t : Set X, t.Countable ∧ ⋃ x ∈ t, U x = univ := let ⟨t, ht⟩ := countable_cover_nhds_interior hU ⟨t, ⟨ht.1, univ_subset_iff.1 <| ht.2.symm.subset.trans <| iUnion₂_mono fun _ _ => interior_subset⟩⟩ /-- The comap of the coLindelöf filter on `Y` by a continuous function `f : X → Y` is less than or equal to the coLindelöf filter on `X`. This is a reformulation of the fact that images of Lindelöf sets are Lindelöf. -/ theorem Filter.comap_coLindelof_le {f : X → Y} (hf : Continuous f) : (Filter.coLindelof Y).comap f ≤ Filter.coLindelof X := by rw [(hasBasis_coLindelof.comap f).le_basis_iff hasBasis_coLindelof] intro t ht refine ⟨f '' t, ht.image hf, ?_⟩ simpa using t.subset_preimage_image f theorem isLindelof_range [LindelofSpace X] {f : X → Y} (hf : Continuous f) : IsLindelof (range f) := by rw [← image_univ]; exact isLindelof_univ.image hf theorem isLindelof_diagonal [LindelofSpace X] : IsLindelof (diagonal X) := @range_diag X ▸ isLindelof_range (continuous_id.prodMk continuous_id) /-- If `f : X → Y` is an inducing map, the image `f '' s` of a set `s` is Lindelöf if and only if `s` is compact. -/ theorem Topology.IsInducing.isLindelof_iff {f : X → Y} (hf : IsInducing f) : IsLindelof s ↔ IsLindelof (f '' s) := by refine ⟨fun hs => hs.image hf.continuous, fun hs F F_ne_bot _ F_le => ?_⟩ obtain ⟨_, ⟨x, x_in : x ∈ s, rfl⟩, hx : ClusterPt (f x) (map f F)⟩ := hs ((map_mono F_le).trans_eq map_principal) exact ⟨x, x_in, hf.mapClusterPt_iff.1 hx⟩ /-- If `f : X → Y` is an embedding, the image `f '' s` of a set `s` is Lindelöf if and only if `s` is Lindelöf. -/ theorem Topology.IsEmbedding.isLindelof_iff {f : X → Y} (hf : IsEmbedding f) : IsLindelof s ↔ IsLindelof (f '' s) := hf.isInducing.isLindelof_iff /-- The preimage of a Lindelöf set under an inducing map is a Lindelöf set. -/ theorem Topology.IsInducing.isLindelof_preimage {f : X → Y} (hf : IsInducing f) (hf' : IsClosed (range f)) {K : Set Y} (hK : IsLindelof K) : IsLindelof (f ⁻¹' K) := by replace hK := hK.inter_right hf' rwa [hf.isLindelof_iff, image_preimage_eq_inter_range] /-- The preimage of a Lindelöf set under a closed embedding is a Lindelöf set. -/ theorem Topology.IsClosedEmbedding.isLindelof_preimage {f : X → Y} (hf : IsClosedEmbedding f) {K : Set Y} (hK : IsLindelof K) : IsLindelof (f ⁻¹' K) := hf.isInducing.isLindelof_preimage (hf.isClosed_range) hK /-- A closed embedding is proper, i.e., inverse images of Lindelöf sets are contained in Lindelöf. Moreover, the preimage of a Lindelöf set is Lindelöf, see `Topology.IsClosedEmbedding.isLindelof_preimage`. -/ theorem Topology.IsClosedEmbedding.tendsto_coLindelof {f : X → Y} (hf : IsClosedEmbedding f) : Tendsto f (Filter.coLindelof X) (Filter.coLindelof Y) := hasBasis_coLindelof.tendsto_right_iff.mpr fun _K hK => (hf.isLindelof_preimage hK).compl_mem_coLindelof /-- Sets of subtype are Lindelöf iff the image under a coercion is. -/ theorem Subtype.isLindelof_iff {p : X → Prop} {s : Set { x // p x }} : IsLindelof s ↔ IsLindelof ((↑) '' s : Set X) := IsEmbedding.subtypeVal.isLindelof_iff theorem isLindelof_iff_isLindelof_univ : IsLindelof s ↔ IsLindelof (univ : Set s) := by rw [Subtype.isLindelof_iff, image_univ, Subtype.range_coe] theorem isLindelof_iff_LindelofSpace : IsLindelof s ↔ LindelofSpace s := isLindelof_iff_isLindelof_univ.trans isLindelof_univ_iff lemma IsLindelof.of_coe [LindelofSpace s] : IsLindelof s := isLindelof_iff_LindelofSpace.mpr ‹_› theorem IsLindelof.countable (hs : IsLindelof s) (hs' : DiscreteTopology s) : s.Countable := countable_coe_iff.mp (@countable_of_Lindelof_of_discrete _ _ (isLindelof_iff_LindelofSpace.mp hs) hs') protected theorem Topology.IsClosedEmbedding.nonLindelofSpace [NonLindelofSpace X] {f : X → Y} (hf : IsClosedEmbedding f) : NonLindelofSpace Y := nonLindelofSpace_of_neBot hf.tendsto_coLindelof.neBot protected theorem Topology.IsClosedEmbedding.LindelofSpace [h : LindelofSpace Y] {f : X → Y} (hf : IsClosedEmbedding f) : LindelofSpace X := ⟨by rw [hf.isInducing.isLindelof_iff, image_univ]; exact hf.isClosed_range.isLindelof⟩ /-- Countable topological spaces are Lindelof. -/ instance (priority := 100) Countable.LindelofSpace [Countable X] : LindelofSpace X where isLindelof_univ := countable_univ.isLindelof /-- The disjoint union of two Lindelöf spaces is Lindelöf. -/ instance [LindelofSpace X] [LindelofSpace Y] : LindelofSpace (X ⊕ Y) where isLindelof_univ := by rw [← range_inl_union_range_inr] exact (isLindelof_range continuous_inl).union (isLindelof_range continuous_inr) instance {X : ι → Type*} [Countable ι] [∀ i, TopologicalSpace (X i)] [∀ i, LindelofSpace (X i)] : LindelofSpace (Σ i, X i) where isLindelof_univ := by rw [Sigma.univ] exact isLindelof_iUnion fun i => isLindelof_range continuous_sigmaMk instance Quot.LindelofSpace {r : X → X → Prop} [LindelofSpace X] : LindelofSpace (Quot r) where isLindelof_univ := by rw [← range_quot_mk] exact isLindelof_range continuous_quot_mk instance Quotient.LindelofSpace {s : Setoid X} [LindelofSpace X] : LindelofSpace (Quotient s) := Quot.LindelofSpace /-- A continuous image of a Lindelöf set is a Lindelöf set within the codomain. -/ theorem LindelofSpace.of_continuous_surjective {f : X → Y} [LindelofSpace X] (hf : Continuous f) (hsur : Function.Surjective f) : LindelofSpace Y where isLindelof_univ := by rw [← Set.image_univ_of_surjective hsur] exact IsLindelof.image (isLindelof_univ_iff.mpr ‹_›) hf /-- A set `s` is Hereditarily Lindelöf if every subset is a Lindelof set. We require this only for open sets in the definition, and then conclude that this holds for all sets by ADD. -/ def IsHereditarilyLindelof (s : Set X) := ∀ t ⊆ s, IsLindelof t /-- Type class for Hereditarily Lindelöf spaces. -/ class HereditarilyLindelofSpace (X : Type*) [TopologicalSpace X] : Prop where /-- In a Hereditarily Lindelöf space, `Set.univ` is a Hereditarily Lindelöf set. -/ isHereditarilyLindelof_univ : IsHereditarilyLindelof (univ : Set X) lemma IsHereditarilyLindelof.isLindelof_subset (hs : IsHereditarilyLindelof s) (ht : t ⊆ s) : IsLindelof t := hs t ht lemma IsHereditarilyLindelof.isLindelof (hs : IsHereditarilyLindelof s) : IsLindelof s := hs.isLindelof_subset Subset.rfl instance (priority := 100) HereditarilyLindelof.to_Lindelof [HereditarilyLindelofSpace X] : LindelofSpace X where isLindelof_univ := HereditarilyLindelofSpace.isHereditarilyLindelof_univ.isLindelof theorem HereditarilyLindelof_LindelofSets [HereditarilyLindelofSpace X] (s : Set X) : IsLindelof s := by apply HereditarilyLindelofSpace.isHereditarilyLindelof_univ exact subset_univ s instance (priority := 100) SecondCountableTopology.toHereditarilyLindelof [SecondCountableTopology X] : HereditarilyLindelofSpace X where isHereditarilyLindelof_univ t _ _ := by apply isLindelof_iff_countable_subcover.mpr intro ι U hι hcover have := @isOpen_iUnion_countable X _ _ ι U hι rcases this with ⟨t, ⟨htc, htu⟩⟩ use t, htc exact subset_of_subset_of_eq hcover (id htu.symm) lemma eq_open_union_countable [HereditarilyLindelofSpace X] {ι : Type u} (U : ι → Set X) (h : ∀ i, IsOpen (U i)) : ∃ t : Set ι, t.Countable ∧ ⋃ i∈t, U i = ⋃ i, U i := by have : IsLindelof (⋃ i, U i) := HereditarilyLindelof_LindelofSets (⋃ i, U i) rcases isLindelof_iff_countable_subcover.mp this U h (Eq.subset rfl) with ⟨t, ⟨htc, htu⟩⟩ use t, htc apply eq_of_subset_of_subset (iUnion₂_subset_iUnion (fun i ↦ i ∈ t) fun i ↦ U i) htu instance HereditarilyLindelof.lindelofSpace_subtype [HereditarilyLindelofSpace X] (p : X → Prop) : LindelofSpace {x // p x} := by apply isLindelof_iff_LindelofSpace.mp exact HereditarilyLindelof_LindelofSets fun x ↦ p x end Lindelof
.lake/packages/mathlib/Mathlib/Topology/Compactness/LocallyCompact.lean
import Mathlib.Topology.Compactness.Compact /-! # Locally compact spaces This file contains basic results about locally compact spaces. -/ open Set Filter Topology TopologicalSpace variable {X : Type*} {Y : Type*} {ι : Type*} variable [TopologicalSpace X] [TopologicalSpace Y] {s t : Set X} instance [WeaklyLocallyCompactSpace X] [WeaklyLocallyCompactSpace Y] : WeaklyLocallyCompactSpace (X × Y) where exists_compact_mem_nhds x := let ⟨s₁, hc₁, h₁⟩ := exists_compact_mem_nhds x.1 let ⟨s₂, hc₂, h₂⟩ := exists_compact_mem_nhds x.2 ⟨s₁ ×ˢ s₂, hc₁.prod hc₂, prod_mem_nhds h₁ h₂⟩ instance {ι : Type*} [Finite ι] {X : ι → Type*} [(i : ι) → TopologicalSpace (X i)] [(i : ι) → WeaklyLocallyCompactSpace (X i)] : WeaklyLocallyCompactSpace ((i : ι) → X i) where exists_compact_mem_nhds f := by choose s hsc hs using fun i ↦ exists_compact_mem_nhds (f i) exact ⟨pi univ s, isCompact_univ_pi hsc, set_pi_mem_nhds univ.toFinite fun i _ ↦ hs i⟩ instance (priority := 100) [CompactSpace X] : WeaklyLocallyCompactSpace X where exists_compact_mem_nhds _ := ⟨univ, isCompact_univ, univ_mem⟩ protected theorem Topology.IsClosedEmbedding.weaklyLocallyCompactSpace [WeaklyLocallyCompactSpace Y] {f : X → Y} (hf : IsClosedEmbedding f) : WeaklyLocallyCompactSpace X where exists_compact_mem_nhds x := let ⟨K, hK, hKx⟩ := exists_compact_mem_nhds (f x) ⟨f ⁻¹' K, hf.isCompact_preimage hK, hf.continuous.continuousAt hKx⟩ protected theorem IsClosed.weaklyLocallyCompactSpace [WeaklyLocallyCompactSpace X] {s : Set X} (hs : IsClosed s) : WeaklyLocallyCompactSpace s := hs.isClosedEmbedding_subtypeVal.weaklyLocallyCompactSpace theorem IsOpenQuotientMap.weaklyLocallyCompactSpace [WeaklyLocallyCompactSpace X] {f : X → Y} (hf : IsOpenQuotientMap f) : WeaklyLocallyCompactSpace Y where exists_compact_mem_nhds := by refine hf.surjective.forall.2 fun x ↦ ?_ rcases exists_compact_mem_nhds x with ⟨K, hKc, hKx⟩ exact ⟨f '' K, hKc.image hf.continuous, hf.isOpenMap.image_mem_nhds hKx⟩ /-- In a weakly locally compact space, every compact set is contained in the interior of a compact set. -/ theorem exists_compact_superset [WeaklyLocallyCompactSpace X] {K : Set X} (hK : IsCompact K) : ∃ K', IsCompact K' ∧ K ⊆ interior K' := by choose s hc hmem using fun x : X ↦ exists_compact_mem_nhds x rcases hK.elim_nhds_subcover _ fun x _ ↦ interior_mem_nhds.2 (hmem x) with ⟨I, -, hIK⟩ refine ⟨⋃ x ∈ I, s x, I.isCompact_biUnion fun _ _ ↦ hc _, hIK.trans ?_⟩ exact iUnion₂_subset fun x hx ↦ interior_mono <| subset_iUnion₂ (s := fun x _ ↦ s x) x hx /-- In a weakly locally compact space, the filters `𝓝 x` and `cocompact X` are disjoint for all `X`. -/ theorem disjoint_nhds_cocompact [WeaklyLocallyCompactSpace X] (x : X) : Disjoint (𝓝 x) (cocompact X) := let ⟨_, hc, hx⟩ := exists_compact_mem_nhds x disjoint_of_disjoint_of_mem disjoint_compl_right hx hc.compl_mem_cocompact theorem compact_basis_nhds [LocallyCompactSpace X] (x : X) : (𝓝 x).HasBasis (fun s => s ∈ 𝓝 x ∧ IsCompact s) fun s => s := hasBasis_self.2 <| by simpa only [and_comm] using LocallyCompactSpace.local_compact_nhds x theorem local_compact_nhds [LocallyCompactSpace X] {x : X} {n : Set X} (h : n ∈ 𝓝 x) : ∃ s ∈ 𝓝 x, s ⊆ n ∧ IsCompact s := LocallyCompactSpace.local_compact_nhds _ _ h theorem LocallyCompactSpace.of_hasBasis {ι : X → Type*} {p : ∀ x, ι x → Prop} {s : ∀ x, ι x → Set X} (h : ∀ x, (𝓝 x).HasBasis (p x) (s x)) (hc : ∀ x i, p x i → IsCompact (s x i)) : LocallyCompactSpace X := ⟨fun x _t ht => let ⟨i, hp, ht⟩ := (h x).mem_iff.1 ht ⟨s x i, (h x).mem_of_mem hp, ht, hc x i hp⟩⟩ instance Prod.locallyCompactSpace (X : Type*) (Y : Type*) [TopologicalSpace X] [TopologicalSpace Y] [LocallyCompactSpace X] [LocallyCompactSpace Y] : LocallyCompactSpace (X × Y) := have := fun x : X × Y => (compact_basis_nhds x.1).prod_nhds' (compact_basis_nhds x.2) .of_hasBasis this fun _ _ ⟨⟨_, h₁⟩, _, h₂⟩ => h₁.prod h₂ section Pi variable {X : ι → Type*} [∀ i, TopologicalSpace (X i)] [∀ i, LocallyCompactSpace (X i)] /-- In general it suffices that all but finitely many of the spaces are compact, but that's not straightforward to state and use. -/ instance Pi.locallyCompactSpace_of_finite [Finite ι] : LocallyCompactSpace (∀ i, X i) := ⟨fun t n hn => by rw [nhds_pi, Filter.mem_pi] at hn obtain ⟨s, -, n', hn', hsub⟩ := hn choose n'' hn'' hsub' hc using fun i => LocallyCompactSpace.local_compact_nhds (t i) (n' i) (hn' i) refine ⟨(Set.univ : Set ι).pi n'', ?_, subset_trans (fun _ h => ?_) hsub, isCompact_univ_pi hc⟩ · exact (set_pi_mem_nhds_iff (@Set.finite_univ ι _) _).mpr fun i _ => hn'' i · exact fun i _ => hsub' i (h i trivial)⟩ /-- For spaces that are not Hausdorff. -/ instance Pi.locallyCompactSpace [∀ i, CompactSpace (X i)] : LocallyCompactSpace (∀ i, X i) := ⟨fun t n hn => by rw [nhds_pi, Filter.mem_pi] at hn obtain ⟨s, hs, n', hn', hsub⟩ := hn choose n'' hn'' hsub' hc using fun i => LocallyCompactSpace.local_compact_nhds (t i) (n' i) (hn' i) refine ⟨s.pi n'', ?_, subset_trans (fun _ => ?_) hsub, ?_⟩ · exact (set_pi_mem_nhds_iff hs _).mpr fun i _ => hn'' i · exact forall₂_imp fun i _ hi' => hsub' i hi' · classical rw [← Set.univ_pi_ite] refine isCompact_univ_pi fun i => ?_ by_cases h : i ∈ s · rw [if_pos h] exact hc i · rw [if_neg h] exact CompactSpace.isCompact_univ⟩ instance Function.locallyCompactSpace_of_finite [Finite ι] [LocallyCompactSpace Y] : LocallyCompactSpace (ι → Y) := Pi.locallyCompactSpace_of_finite instance Function.locallyCompactSpace [LocallyCompactSpace Y] [CompactSpace Y] : LocallyCompactSpace (ι → Y) := Pi.locallyCompactSpace end Pi instance (priority := 900) [LocallyCompactSpace X] : LocallyCompactPair X Y where exists_mem_nhds_isCompact_mapsTo hf hs := let ⟨K, hKx, hKs, hKc⟩ := local_compact_nhds (hf.continuousAt hs); ⟨K, hKx, hKc, hKs⟩ instance (priority := 100) [LocallyCompactSpace X] : WeaklyLocallyCompactSpace X where exists_compact_mem_nhds (x : X) := let ⟨K, hx, _, hKc⟩ := local_compact_nhds (x := x) univ_mem; ⟨K, hKc, hx⟩ /-- A reformulation of the definition of locally compact space: In a locally compact space, every open set containing `x` has a compact subset containing `x` in its interior. -/ theorem exists_compact_subset [LocallyCompactSpace X] {x : X} {U : Set X} (hU : IsOpen U) (hx : x ∈ U) : ∃ K : Set X, IsCompact K ∧ x ∈ interior K ∧ K ⊆ U := by rcases LocallyCompactSpace.local_compact_nhds x U (hU.mem_nhds hx) with ⟨K, h1K, h2K, h3K⟩ exact ⟨K, h3K, mem_interior_iff_mem_nhds.2 h1K, h2K⟩ /-- If `f : X → Y` is a continuous map in a locally compact pair of topological spaces, `K : set X` is a compact set, and `U` is an open neighbourhood of `f '' K`, then there exists a compact neighbourhood `L` of `K` such that `f` maps `L` to `U`. This is a generalization of `exists_mem_nhds_isCompact_mapsTo`. -/ lemma exists_mem_nhdsSet_isCompact_mapsTo [LocallyCompactPair X Y] {f : X → Y} {K : Set X} {U : Set Y} (hf : Continuous f) (hK : IsCompact K) (hU : IsOpen U) (hKU : MapsTo f K U) : ∃ L ∈ 𝓝ˢ K, IsCompact L ∧ MapsTo f L U := by choose! V hxV hVc hVU using fun x (hx : x ∈ K) ↦ exists_mem_nhds_isCompact_mapsTo hf (hU.mem_nhds (hKU hx)) rcases hK.elim_nhds_subcover_nhdsSet hxV with ⟨s, hsK, hKs⟩ exact ⟨_, hKs, s.isCompact_biUnion fun x hx ↦ hVc x (hsK x hx), mapsTo_iUnion₂.2 fun x hx ↦ hVU x (hsK x hx)⟩ /-- In a locally compact space, for every containment `K ⊆ U` of a compact set `K` in an open set `U`, there is a compact neighborhood `L` such that `K ⊆ L ⊆ U`: equivalently, there is a compact `L` such that `K ⊆ interior L` and `L ⊆ U`. See also `exists_compact_closed_between`, in which one guarantees additionally that `L` is closed if the space is regular. -/ theorem exists_compact_between [LocallyCompactSpace X] {K U : Set X} (hK : IsCompact K) (hU : IsOpen U) (h_KU : K ⊆ U) : ∃ L, IsCompact L ∧ K ⊆ interior L ∧ L ⊆ U := let ⟨L, hKL, hL, hLU⟩ := exists_mem_nhdsSet_isCompact_mapsTo continuous_id hK hU h_KU ⟨L, hL, subset_interior_iff_mem_nhdsSet.2 hKL, hLU⟩ theorem IsOpenQuotientMap.locallyCompactSpace [LocallyCompactSpace X] {f : X → Y} (hf : IsOpenQuotientMap f) : LocallyCompactSpace Y where local_compact_nhds := by refine hf.surjective.forall.2 fun x U hU ↦ ?_ rcases local_compact_nhds (hf.continuous.continuousAt hU) with ⟨K, hKx, hKU, hKc⟩ exact ⟨f '' K, hf.isOpenMap.image_mem_nhds hKx, image_subset_iff.2 hKU, hKc.image hf.continuous⟩ /-- If `f` is a topology inducing map with a locally compact codomain and a locally closed range, then the domain of `f` is a locally compact space. -/ theorem Topology.IsInducing.locallyCompactSpace [LocallyCompactSpace Y] {f : X → Y} (hf : IsInducing f) (h : IsLocallyClosed (range f)) : LocallyCompactSpace X := by rcases h with ⟨U, Z, hU, hZ, hUZ⟩ have (x : X) : (𝓝 x).HasBasis (fun s ↦ (s ∈ 𝓝 (f x) ∧ IsCompact s) ∧ s ⊆ U) (fun s ↦ f ⁻¹' (s ∩ Z)) := by have H : U ∈ 𝓝 (f x) := hU.mem_nhds (hUZ.subset <| mem_range_self _).1 rw [hf.nhds_eq_comap, ← comap_nhdsWithin_range, hUZ, nhdsWithin_inter_of_mem (nhdsWithin_le_nhds H)] exact (nhdsWithin_hasBasis ((compact_basis_nhds (f x)).restrict_subset H) _).comap _ refine .of_hasBasis this fun x s ⟨⟨_, hs⟩, hsU⟩ ↦ ?_ rw [hf.isCompact_preimage_iff] exacts [hs.inter_right hZ, hUZ ▸ by gcongr] protected theorem Topology.IsClosedEmbedding.locallyCompactSpace [LocallyCompactSpace Y] {f : X → Y} (hf : IsClosedEmbedding f) : LocallyCompactSpace X := hf.isInducing.locallyCompactSpace hf.isClosed_range.isLocallyClosed protected theorem Topology.IsOpenEmbedding.locallyCompactSpace [LocallyCompactSpace Y] {f : X → Y} (hf : IsOpenEmbedding f) : LocallyCompactSpace X := hf.isInducing.locallyCompactSpace hf.isOpen_range.isLocallyClosed protected theorem IsLocallyClosed.locallyCompactSpace [LocallyCompactSpace X] {s : Set X} (hs : IsLocallyClosed s) : LocallyCompactSpace s := IsEmbedding.subtypeVal.locallyCompactSpace <| by rwa [Subtype.range_val] protected theorem IsClosed.locallyCompactSpace [LocallyCompactSpace X] {s : Set X} (hs : IsClosed s) : LocallyCompactSpace s := hs.isLocallyClosed.locallyCompactSpace protected theorem IsOpen.locallyCompactSpace [LocallyCompactSpace X] {s : Set X} (hs : IsOpen s) : LocallyCompactSpace s := hs.isLocallyClosed.locallyCompactSpace
.lake/packages/mathlib/Mathlib/Topology/Compactness/NhdsKer.lean
import Mathlib.Tactic.Peel import Mathlib.Topology.Compactness.Compact import Mathlib.Topology.NhdsKer /-! # Compactness of the neighborhoods kernel of a set In this file we prove that the neighborhoods kernel of a set (defined as the intersection of all of its neighborhoods) is a compact set if and only if the original set is a compact set. -/ variable {X : Type*} [TopologicalSpace X] {s : Set X} theorem IsCompact.nhdsKer_iff : IsCompact (nhdsKer s) ↔ IsCompact s := by simp only [isCompact_iff_finite_subcover] peel with ι U hUo simp only [(isOpen_iUnion hUo).nhdsKer_subset, (isOpen_iUnion fun i ↦ isOpen_iUnion fun _ ↦ hUo i).nhdsKer_subset] @[deprecated (since := "2025-07-09")] alias IsCompact.exterior_iff := IsCompact.nhdsKer_iff protected alias ⟨IsCompact.of_nhdsKer, IsCompact.nhdsKer⟩ := IsCompact.nhdsKer_iff @[deprecated (since := "2025-07-09")] alias IsCompact.of_exterior := IsCompact.of_nhdsKer @[deprecated (since := "2025-07-09")] alias IsCompact.exterior := IsCompact.nhdsKer
.lake/packages/mathlib/Mathlib/Topology/Compactness/LocallyFinite.lean
import Mathlib.Topology.LocallyFinite import Mathlib.Topology.Compactness.Compact /-! # Compact sets and compact spaces and locally finite functions -/ open Set variable {X ι : Type*} [TopologicalSpace X] {s : Set X} namespace LocallyFinite /-- If `s` is a compact set in a topological space `X` and `f : ι → Set X` is a locally finite family of sets, then `f i ∩ s` is nonempty only for a finitely many `i`. -/ theorem finite_nonempty_inter_compact {f : ι → Set X} (hf : LocallyFinite f) (hs : IsCompact s) : { i | (f i ∩ s).Nonempty }.Finite := by choose U hxU hUf using hf rcases hs.elim_nhds_subcover U fun x _ => hxU x with ⟨t, -, hsU⟩ refine (t.finite_toSet.biUnion fun x _ => hUf x).subset ?_ rintro i ⟨x, hx⟩ rcases mem_iUnion₂.1 (hsU hx.2) with ⟨c, hct, hcx⟩ exact mem_biUnion hct ⟨x, hx.1, hcx⟩ /-- If `X` is a compact space, then a locally finite family of sets of `X` can have only finitely many nonempty elements. -/ theorem finite_nonempty_of_compact [CompactSpace X] {f : ι → Set X} (hf : LocallyFinite f) : { i | (f i).Nonempty }.Finite := by simpa only [inter_univ] using hf.finite_nonempty_inter_compact isCompact_univ /-- If `X` is a compact space, then a locally finite family of nonempty sets of `X` can have only finitely many elements, `Set.Finite` version. -/ theorem finite_of_compact [CompactSpace X] {f : ι → Set X} (hf : LocallyFinite f) (hne : ∀ i, (f i).Nonempty) : (univ : Set ι).Finite := by simpa only [hne] using hf.finite_nonempty_of_compact /-- If `X` is a compact space, then a locally finite family of nonempty sets of `X` can have only finitely many elements, `Fintype` version. -/ noncomputable def fintypeOfCompact [CompactSpace X] {f : ι → Set X} (hf : LocallyFinite f) (hne : ∀ i, (f i).Nonempty) : Fintype ι := fintypeOfFiniteUniv (hf.finite_of_compact hne) end LocallyFinite
.lake/packages/mathlib/Mathlib/Topology/Baire/BaireMeasurable.lean
import Mathlib.Topology.LocallyClosed import Mathlib.MeasureTheory.MeasurableSpace.EventuallyMeasurable import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic /-! # Baire category and Baire measurable sets This file defines some of the basic notions of Baire category and Baire measurable sets. ## Main definitions First, we define the notation `=ᵇ`. This denotes eventual equality with respect to the filter of `residual` sets in a topological space. A set `s` in a topological space `α` is called a `BaireMeasurableSet` or said to have the *property of Baire* if it satisfies either of the following equivalent conditions: * There is a *Borel* set `u` such that `s =ᵇ u`. (This is our definition) * There is an *open* set `u` such that `s =ᵇ u`. (See `BaireMeasurableSet.residual_eq_open`) -/ variable (α : Type*) {β : Type*} [TopologicalSpace α] [TopologicalSpace β] open Topology /-- Notation for `=ᶠ[residual _]`. That is, eventual equality with respect to the filter of residual sets. -/ scoped[Topology] notation:50 f " =ᵇ " g:50 => Filter.EventuallyEq (residual _) f g /-- Notation to say that a property of points in a topological space holds almost everywhere in the sense of Baire category. That is, on a residual set. -/ scoped[Topology] notation3 "∀ᵇ " (...) ", " r:(scoped p => Filter.Eventually p <| residual _) => r /-- Notation to say that a property of points in a topological space holds on a nonmeager set. -/ scoped[Topology] notation3 "∃ᵇ " (...) ", " r:(scoped p => Filter.Frequently p <| residual _) => r variable {α} theorem coborder_mem_residual {s : Set α} (hs : IsLocallyClosed s) : coborder s ∈ residual α := residual_of_dense_open hs.isOpen_coborder dense_coborder theorem closure_residualEq {s : Set α} (hs : IsLocallyClosed s) : closure s =ᵇ s := by rw [Filter.eventuallyEq_set] filter_upwards [coborder_mem_residual hs] with x hx nth_rewrite 2 [← closure_inter_coborder (s := s)] simp [hx] /-- We say a set is a `BaireMeasurableSet` if it differs from some Borel set by a meager set. This forms a σ-algebra. It is equivalent, and a more standard definition, to say that the set differs from some *open* set by a meager set. See `BaireMeasurableSet.iff_residualEq_isOpen` -/ def BaireMeasurableSet (s : Set α) : Prop := @MeasurableSet _ (eventuallyMeasurableSpace (borel _) (residual _)) s variable {s t : Set α} namespace BaireMeasurableSet theorem of_mem_residual (h : s ∈ residual _) : BaireMeasurableSet s := eventuallyMeasurableSet_of_mem_filter (α := α) h theorem _root_.MeasurableSet.baireMeasurableSet [MeasurableSpace α] [BorelSpace α] (h : MeasurableSet s) : BaireMeasurableSet s := by borelize α exact h.eventuallyMeasurableSet theorem _root_.IsOpen.baireMeasurableSet (h : IsOpen s) : BaireMeasurableSet s := by borelize α exact h.measurableSet.baireMeasurableSet theorem compl (h : BaireMeasurableSet s) : BaireMeasurableSet sᶜ := MeasurableSet.compl h theorem of_compl (h : BaireMeasurableSet sᶜ) : BaireMeasurableSet s := MeasurableSet.of_compl h theorem _root_.IsMeagre.baireMeasurableSet (h : IsMeagre s) : BaireMeasurableSet s := (of_mem_residual h).of_compl theorem iUnion {ι : Sort*} [Countable ι] {s : ι → Set α} (h : ∀ i, BaireMeasurableSet (s i)) : BaireMeasurableSet (⋃ i, s i) := MeasurableSet.iUnion h theorem biUnion {ι : Type*} {s : ι → Set α} {t : Set ι} (ht : t.Countable) (h : ∀ i ∈ t, BaireMeasurableSet (s i)) : BaireMeasurableSet (⋃ i ∈ t, s i) := MeasurableSet.biUnion ht h theorem sUnion {s : Set (Set α)} (hs : s.Countable) (h : ∀ t ∈ s, BaireMeasurableSet t) : BaireMeasurableSet (⋃₀ s) := MeasurableSet.sUnion hs h theorem iInter {ι : Sort*} [Countable ι] {s : ι → Set α} (h : ∀ i, BaireMeasurableSet (s i)) : BaireMeasurableSet (⋂ i, s i) := MeasurableSet.iInter h theorem biInter {ι : Type*} {s : ι → Set α} {t : Set ι} (ht : t.Countable) (h : ∀ i ∈ t, BaireMeasurableSet (s i)) : BaireMeasurableSet (⋂ i ∈ t, s i) := MeasurableSet.biInter ht h theorem sInter {s : Set (Set α)} (hs : s.Countable) (h : ∀ t ∈ s, BaireMeasurableSet t) : BaireMeasurableSet (⋂₀ s) := MeasurableSet.sInter hs h theorem union (hs : BaireMeasurableSet s) (ht : BaireMeasurableSet t) : BaireMeasurableSet (s ∪ t) := MeasurableSet.union hs ht theorem inter (hs : BaireMeasurableSet s) (ht : BaireMeasurableSet t) : BaireMeasurableSet (s ∩ t) := MeasurableSet.inter hs ht theorem diff (hs : BaireMeasurableSet s) (ht : BaireMeasurableSet t) : BaireMeasurableSet (s \ t) := MeasurableSet.diff hs ht theorem congr (hs : BaireMeasurableSet s) (h : s =ᵇ t) : BaireMeasurableSet t := EventuallyMeasurableSet.congr (α := α) hs h.symm end BaireMeasurableSet open Filter /-- Any Borel set differs from some open set by a meager set. -/ theorem MeasurableSet.residualEq_isOpen [MeasurableSpace α] [BorelSpace α] (h : MeasurableSet s) : ∃ u : Set α, IsOpen u ∧ s =ᵇ u := by induction s, h using MeasurableSet.induction_on_open with | isOpen U hU => exact ⟨U, hU, .rfl⟩ | compl s _ ihs => obtain ⟨U, Uo, hsU⟩ := ihs use (closure U)ᶜ, isClosed_closure.isOpen_compl exact .compl <| hsU.trans <| .symm <| closure_residualEq Uo.isLocallyClosed | iUnion f _ _ ihf => choose u uo su using ihf exact ⟨⋃ i, u i, isOpen_iUnion uo, EventuallyEq.countable_iUnion su⟩ /-- Any `BaireMeasurableSet` differs from some open set by a meager set. -/ theorem BaireMeasurableSet.residualEq_isOpen (h : BaireMeasurableSet s) : ∃ u : Set α, (IsOpen u) ∧ s =ᵇ u := by borelize α rcases h with ⟨t, ht, hst⟩ rcases ht.residualEq_isOpen with ⟨u, hu, htu⟩ exact ⟨u, hu, hst.trans htu⟩ /-- A set is Baire measurable if and only if it differs from some open set by a meager set. -/ theorem BaireMeasurableSet.iff_residualEq_isOpen : BaireMeasurableSet s ↔ ∃ u : Set α, (IsOpen u) ∧ s =ᵇ u := ⟨fun h => h.residualEq_isOpen, fun ⟨_, uo, ueq⟩ => uo.baireMeasurableSet.congr ueq.symm⟩ section Map open Set variable {f : α → β} theorem tendsto_residual_of_isOpenMap (hc : Continuous f) (ho : IsOpenMap f) : Tendsto f (residual α) (residual β) := by apply le_countableGenerate_iff_of_countableInterFilter.mpr rintro t ⟨ht, htd⟩ exact residual_of_dense_open (ht.preimage hc) (htd.preimage ho) /-- The preimage of a meager set under a continuous open map is meager. -/ theorem IsMeagre.preimage_of_isOpenMap (hc : Continuous f) (ho : IsOpenMap f) {s : Set β} (h : IsMeagre s) : IsMeagre (f ⁻¹' s) := tendsto_residual_of_isOpenMap hc ho h /-- The preimage of a `BaireMeasurableSet` under a continuous open map is Baire measurable. -/ theorem BaireMeasurableSet.preimage (hc : Continuous f) (ho : IsOpenMap f) {s : Set β} (h : BaireMeasurableSet s) : BaireMeasurableSet (f ⁻¹' s) := by rcases h with ⟨u, hu, hsu⟩ refine ⟨f ⁻¹' u, ?_, hsu.filter_mono <| tendsto_residual_of_isOpenMap hc ho⟩ borelize α β exact hc.measurable hu theorem Homeomorph.residual_map_eq (h : α ≃ₜ β) : (residual α).map h = residual β := by refine le_antisymm (tendsto_residual_of_isOpenMap h.continuous h.isOpenMap) (le_map ?_) simp_rw [← preimage_symm] exact tendsto_residual_of_isOpenMap h.symm.continuous h.symm.isOpenMap end Map
.lake/packages/mathlib/Mathlib/Topology/Baire/Lemmas.lean
import Mathlib.Topology.GDelta.Basic /-! # Baire spaces A topological space is called a *Baire space* if a countable intersection of dense open subsets is dense. Baire theorems say that all completely metrizable spaces and all locally compact regular spaces are Baire spaces. We prove the theorems in `Mathlib/Topology/Baire/CompleteMetrizable` and `Mathlib/Topology/Baire/LocallyCompactRegular`. In this file we prove various corollaries of Baire theorems. The good concept underlying the theorems is that of a Gδ set, i.e., a countable intersection of open sets. Then Baire theorem can also be formulated as the fact that a countable intersection of dense Gδ sets is a dense Gδ set. We deduce this version from Baire property. We also prove the important consequence that, if the space is covered by a countable union of closed sets, then the union of their interiors is dense. We also prove that in Baire spaces, the `residual` sets are exactly those containing a dense Gδ set. -/ noncomputable section open scoped Topology open Filter Set TopologicalSpace variable {X α : Type*} {ι : Sort*} section BaireTheorem variable [TopologicalSpace X] [BaireSpace X] /-- Definition of a Baire space. -/ theorem dense_iInter_of_isOpen_nat {f : ℕ → Set X} (ho : ∀ n, IsOpen (f n)) (hd : ∀ n, Dense (f n)) : Dense (⋂ n, f n) := BaireSpace.baire_property f ho hd /-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with ⋂₀. -/ theorem dense_sInter_of_isOpen {S : Set (Set X)} (ho : ∀ s ∈ S, IsOpen s) (hS : S.Countable) (hd : ∀ s ∈ S, Dense s) : Dense (⋂₀ S) := by rcases S.eq_empty_or_nonempty with h | h · simp [h] · rcases hS.exists_eq_range h with ⟨f, rfl⟩ exact dense_iInter_of_isOpen_nat (forall_mem_range.1 ho) (forall_mem_range.1 hd) /-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with an index set which is a countable set in any type. -/ theorem dense_biInter_of_isOpen {S : Set α} {f : α → Set X} (ho : ∀ s ∈ S, IsOpen (f s)) (hS : S.Countable) (hd : ∀ s ∈ S, Dense (f s)) : Dense (⋂ s ∈ S, f s) := by rw [← sInter_image] refine dense_sInter_of_isOpen ?_ (hS.image _) ?_ <;> rwa [forall_mem_image] /-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with an index set which is a countable type. -/ theorem dense_iInter_of_isOpen [Countable ι] {f : ι → Set X} (ho : ∀ i, IsOpen (f i)) (hd : ∀ i, Dense (f i)) : Dense (⋂ s, f s) := dense_sInter_of_isOpen (forall_mem_range.2 ho) (countable_range _) (forall_mem_range.2 hd) /-- A set is residual (comeagre) if and only if it includes a dense `Gδ` set. -/ theorem mem_residual {s : Set X} : s ∈ residual X ↔ ∃ t ⊆ s, IsGδ t ∧ Dense t := by constructor · rw [mem_residual_iff] rintro ⟨S, hSo, hSd, Sct, Ss⟩ refine ⟨_, Ss, ⟨_, fun t ht => hSo _ ht, Sct, rfl⟩, ?_⟩ exact dense_sInter_of_isOpen hSo Sct hSd rintro ⟨t, ts, ho, hd⟩ exact mem_of_superset (residual_of_dense_Gδ ho hd) ts /-- A property holds on a residual (comeagre) set if and only if it holds on some dense `Gδ` set. -/ theorem eventually_residual {p : X → Prop} : (∀ᶠ x in residual X, p x) ↔ ∃ t : Set X, IsGδ t ∧ Dense t ∧ ∀ x ∈ t, p x := by simp only [Filter.Eventually, mem_residual, subset_def, mem_setOf_eq] tauto theorem dense_of_mem_residual {s : Set X} (hs : s ∈ residual X) : Dense s := let ⟨_, hts, _, hd⟩ := mem_residual.1 hs hd.mono hts /-- In a Baire space, every nonempty open set is non‐meagre, that is, it cannot be written as a countable union of nowhere‐dense sets. -/ theorem not_isMeagre_of_isOpen {s : Set X} (hs : IsOpen s) (hne : s.Nonempty) : ¬ IsMeagre s := by intro h obtain ⟨x, hx, hxc⟩ := (dense_of_mem_residual (by rwa [IsMeagre] at h)).inter_open_nonempty s hs hne exact hxc hx /-- Baire theorem: a countable intersection of dense Gδ sets is dense. Formulated here with ⋂₀. -/ theorem dense_sInter_of_Gδ {S : Set (Set X)} (ho : ∀ s ∈ S, IsGδ s) (hS : S.Countable) (hd : ∀ s ∈ S, Dense s) : Dense (⋂₀ S) := dense_of_mem_residual ((countable_sInter_mem hS).mpr (fun _ hs => residual_of_dense_Gδ (ho _ hs) (hd _ hs))) /-- Baire theorem: a countable intersection of dense Gδ sets is dense. Formulated here with an index set which is a countable type. -/ theorem dense_iInter_of_Gδ [Countable ι] {f : ι → Set X} (ho : ∀ s, IsGδ (f s)) (hd : ∀ s, Dense (f s)) : Dense (⋂ s, f s) := dense_sInter_of_Gδ (forall_mem_range.2 ‹_›) (countable_range _) (forall_mem_range.2 ‹_›) /-- Baire theorem: a countable intersection of dense Gδ sets is dense. Formulated here with an index set which is a countable set in any type. -/ theorem dense_biInter_of_Gδ {S : Set α} {f : ∀ x ∈ S, Set X} (ho : ∀ s (H : s ∈ S), IsGδ (f s H)) (hS : S.Countable) (hd : ∀ s (H : s ∈ S), Dense (f s H)) : Dense (⋂ s ∈ S, f s ‹_›) := by rw [biInter_eq_iInter] haveI := hS.to_subtype exact dense_iInter_of_Gδ (fun s => ho s s.2) fun s => hd s s.2 /-- Baire theorem: the intersection of two dense Gδ sets is dense. -/ theorem Dense.inter_of_Gδ {s t : Set X} (hs : IsGδ s) (ht : IsGδ t) (hsc : Dense s) (htc : Dense t) : Dense (s ∩ t) := by rw [inter_eq_iInter] apply dense_iInter_of_Gδ <;> simp [Bool.forall_bool, *] /-- If a countable family of closed sets cover a dense `Gδ` set, then the union of their interiors is dense. Formulated here with `⋃`. -/ theorem IsGδ.dense_iUnion_interior_of_closed [Countable ι] {s : Set X} (hs : IsGδ s) (hd : Dense s) {f : ι → Set X} (hc : ∀ i, IsClosed (f i)) (hU : s ⊆ ⋃ i, f i) : Dense (⋃ i, interior (f i)) := by let g i := (frontier (f i))ᶜ have hgo : ∀ i, IsOpen (g i) := fun i => isClosed_frontier.isOpen_compl have hgd : Dense (⋂ i, g i) := by refine dense_iInter_of_isOpen hgo fun i x => ?_ rw [closure_compl, interior_frontier (hc _)] exact id refine (hd.inter_of_Gδ hs (.iInter_of_isOpen fun i => (hgo i)) hgd).mono ?_ rintro x ⟨hxs, hxg⟩ rw [mem_iInter] at hxg rcases mem_iUnion.1 (hU hxs) with ⟨i, hi⟩ exact mem_iUnion.2 ⟨i, self_diff_frontier (f i) ▸ ⟨hi, hxg _⟩⟩ /-- If a countable family of closed sets cover a dense `Gδ` set, then the union of their interiors is dense. Formulated here with a union over a countable set in any type. -/ theorem IsGδ.dense_biUnion_interior_of_closed {t : Set α} {s : Set X} (hs : IsGδ s) (hd : Dense s) (ht : t.Countable) {f : α → Set X} (hc : ∀ i ∈ t, IsClosed (f i)) (hU : s ⊆ ⋃ i ∈ t, f i) : Dense (⋃ i ∈ t, interior (f i)) := by haveI := ht.to_subtype simp only [biUnion_eq_iUnion, SetCoe.forall'] at * exact hs.dense_iUnion_interior_of_closed hd hc hU /-- If a countable family of closed sets cover a dense `Gδ` set, then the union of their interiors is dense. Formulated here with `⋃₀`. -/ theorem IsGδ.dense_sUnion_interior_of_closed {T : Set (Set X)} {s : Set X} (hs : IsGδ s) (hd : Dense s) (hc : T.Countable) (hc' : ∀ t ∈ T, IsClosed t) (hU : s ⊆ ⋃₀ T) : Dense (⋃ t ∈ T, interior t) := hs.dense_biUnion_interior_of_closed hd hc hc' <| by rwa [← sUnion_eq_biUnion] /-- Baire theorem: if countably many closed sets cover the whole space, then their interiors are dense. Formulated here with an index set which is a countable set in any type. -/ theorem dense_biUnion_interior_of_closed {S : Set α} {f : α → Set X} (hc : ∀ s ∈ S, IsClosed (f s)) (hS : S.Countable) (hU : ⋃ s ∈ S, f s = univ) : Dense (⋃ s ∈ S, interior (f s)) := IsGδ.univ.dense_biUnion_interior_of_closed dense_univ hS hc hU.ge /-- Baire theorem: if countably many closed sets cover the whole space, then their interiors are dense. Formulated here with `⋃₀`. -/ theorem dense_sUnion_interior_of_closed {S : Set (Set X)} (hc : ∀ s ∈ S, IsClosed s) (hS : S.Countable) (hU : ⋃₀ S = univ) : Dense (⋃ s ∈ S, interior s) := IsGδ.univ.dense_sUnion_interior_of_closed dense_univ hS hc hU.ge /-- Baire theorem: if countably many closed sets cover the whole space, then their interiors are dense. Formulated here with an index set which is a countable type. -/ theorem dense_iUnion_interior_of_closed [Countable ι] {f : ι → Set X} (hc : ∀ i, IsClosed (f i)) (hU : ⋃ i, f i = univ) : Dense (⋃ i, interior (f i)) := IsGδ.univ.dense_iUnion_interior_of_closed dense_univ hc hU.ge variable [Nonempty X] /-- One of the most useful consequences of Baire theorem: if a countable union of closed sets covers the space, then one of the sets has nonempty interior. -/ theorem nonempty_interior_of_iUnion_of_closed [Countable ι] {f : ι → Set X} (hc : ∀ i, IsClosed (f i)) (hU : ⋃ i, f i = univ) : ∃ i, (interior <| f i).Nonempty := by simpa using (dense_iUnion_interior_of_closed hc hU).nonempty /-- In a nonempty Baire space, any dense `Gδ` set is not meagre. -/ theorem not_isMeagre_of_isGδ_of_dense {s : Set X} (hs : IsGδ s) (hd : Dense s) : ¬ IsMeagre s := by intro h rcases (mem_residual).1 h with ⟨t, hts, htG, hd'⟩ rcases (hd.inter_of_Gδ hs htG hd').nonempty with ⟨x, hx₁, hx₂⟩ exact hts hx₂ hx₁ /-- In a nonempty Baire space, a residual set is not meagre. -/ theorem not_isMeagre_of_mem_residual {s : Set X} (hs : s ∈ residual X) : ¬ IsMeagre s := by rcases (mem_residual (X := X)).1 hs with ⟨t, ht_sub, htGδ, ht_dense⟩ intro hs_meagre exact not_isMeagre_of_isGδ_of_dense (X := X) htGδ ht_dense (hs_meagre.mono ht_sub) end BaireTheorem
.lake/packages/mathlib/Mathlib/Topology/Baire/LocallyCompactRegular.lean
import Mathlib.Topology.Sets.Compacts /-! # Second Baire theorem In this file we prove that a locally compact regular topological space has Baire property. -/ open TopologicalSpace Set /-- **Second Baire theorem**: locally compact R₁ spaces are Baire. -/ instance (priority := 100) BaireSpace.of_t2Space_locallyCompactSpace {X : Type*} [TopologicalSpace X] [R1Space X] [LocallyCompactSpace X] : BaireSpace X := by constructor intro f ho hd /- To prove that an intersection of open dense subsets is dense, prove that its intersection with any open neighbourhood `U` is dense. Define recursively a decreasing sequence `K` of compact neighbourhoods: start with some compact neighbourhood inside `U`, then at each step, take its interior, intersect with `f n`, then choose a compact neighbourhood inside the intersection. -/ rw [dense_iff_inter_open] intro U U_open U_nonempty -- Choose an antitone sequence of positive compacts such that `closure (K 0) ⊆ U` -- and `closure (K (n + 1)) ⊆ f n` for all `n` obtain ⟨K, hK_anti, hKf, hKU⟩ : ∃ K : ℕ → PositiveCompacts X, (∀ n, K (n + 1) ≤ K n) ∧ (∀ n, closure ↑(K (n + 1)) ⊆ f n) ∧ closure ↑(K 0) ⊆ U := by rcases U_open.exists_positiveCompacts_closure_subset U_nonempty with ⟨K₀, hK₀⟩ have : ∀ (n) (K : PositiveCompacts X), ∃ K' : PositiveCompacts X, closure ↑K' ⊆ f n ∩ interior K := by refine fun n K ↦ ((ho n).inter isOpen_interior).exists_positiveCompacts_closure_subset ?_ rw [inter_comm] exact (hd n).inter_open_nonempty _ isOpen_interior K.interior_nonempty choose K_next hK_next using this -- The next two lines are faster than a single `refine`. use Nat.rec K₀ K_next refine ⟨fun n ↦ ?_, fun n ↦ (hK_next n _).trans inter_subset_left, hK₀⟩ exact subset_closure.trans <| (hK_next _ _).trans <| inter_subset_right.trans interior_subset -- Prove that ̀`⋂ n : ℕ, closure (K n)` is inside `U ∩ ⋂ n : ℕ, f n`. have hK_subset : (⋂ n, closure (K n) : Set X) ⊆ U ∩ ⋂ n, f n := fun x hx ↦ by simp only [mem_iInter, mem_inter_iff] at hx ⊢ exact ⟨hKU <| hx 0, fun n ↦ hKf n <| hx (n + 1)⟩ /- Prove that `⋂ n : ℕ, closure (K n)` is not empty, as an intersection of a decreasing sequence of nonempty compact closed subsets. -/ have hK_nonempty : (⋂ n, closure (K n) : Set X).Nonempty := IsCompact.nonempty_iInter_of_sequence_nonempty_isCompact_isClosed _ (fun n => closure_mono <| hK_anti n) (fun n => (K n).nonempty.closure) (K 0).isCompact.closure fun n => isClosed_closure exact hK_nonempty.mono hK_subset
.lake/packages/mathlib/Mathlib/Topology/Baire/CompleteMetrizable.lean
import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Tactic.Finiteness import Mathlib.Topology.Metrizable.Uniformity /-! # First Baire theorem In this file we prove that a completely metrizable topological space is a Baire space. Since `Mathlib` does not have the notion of a completely metrizable topological space yet, we state it for a complete uniform space with countably generated uniformity filter. -/ open Filter EMetric Set open scoped Topology Uniformity ENNReal variable {X : Type*} [UniformSpace X] [CompleteSpace X] [(𝓤 X).IsCountablyGenerated] /-- **First Baire theorem**: a completely metrizable topological space has Baire property. Since `Mathlib` does not have the notion of a completely metrizable topological space yet, we state it for a complete uniform space with countably generated uniformity filter. -/ instance (priority := 100) BaireSpace.of_pseudoEMetricSpace_completeSpace : BaireSpace X := by let _ := UniformSpace.pseudoMetricSpace X refine ⟨fun f ho hd => ?_⟩ let B : ℕ → ℝ≥0∞ := fun n => 1 / 2 ^ n have Bpos : ∀ n, 0 < B n := fun n ↦ ENNReal.div_pos one_ne_zero <| by finiteness /- Translate the density assumption into two functions `center` and `radius` associating to any n, x, δ, δpos a center and a positive radius such that `closedBall center radius` is included both in `f n` and in `closedBall x δ`. We can also require `radius ≤ (1/2)^(n+1)`, to ensure we get a Cauchy sequence later. -/ have : ∀ n x δ, δ ≠ 0 → ∃ y r, 0 < r ∧ r ≤ B (n + 1) ∧ closedBall y r ⊆ closedBall x δ ∩ f n := by intro n x δ δpos have : x ∈ closure (f n) := hd n x rcases EMetric.mem_closure_iff.1 this (δ / 2) (ENNReal.half_pos δpos) with ⟨y, ys, xy⟩ rw [edist_comm] at xy obtain ⟨r, rpos, hr⟩ : ∃ r > 0, closedBall y r ⊆ f n := nhds_basis_closed_eball.mem_iff.1 (isOpen_iff_mem_nhds.1 (ho n) y ys) refine ⟨y, min (min (δ / 2) r) (B (n + 1)), ?_, ?_, fun z hz => ⟨?_, ?_⟩⟩ · show 0 < min (min (δ / 2) r) (B (n + 1)) exact lt_min (lt_min (ENNReal.half_pos δpos) rpos) (Bpos (n + 1)) · show min (min (δ / 2) r) (B (n + 1)) ≤ B (n + 1) exact min_le_right _ _ · show z ∈ closedBall x δ calc edist z x ≤ edist z y + edist y x := edist_triangle _ _ _ _ ≤ min (min (δ / 2) r) (B (n + 1)) + δ / 2 := add_le_add hz (le_of_lt xy) _ ≤ δ / 2 + δ / 2 := (add_le_add (le_trans (min_le_left _ _) (min_le_left _ _)) le_rfl) _ = δ := ENNReal.add_halves δ show z ∈ f n exact hr (calc edist z y ≤ min (min (δ / 2) r) (B (n + 1)) := hz _ ≤ r := le_trans (min_le_left _ _) (min_le_right _ _)) choose! center radius Hpos HB Hball using this refine fun x => (mem_closure_iff_nhds_basis nhds_basis_closed_eball).2 fun ε εpos => ?_ /- `ε` is positive. We have to find a point in the ball of radius `ε` around `x` belonging to all `f n`. For this, we construct inductively a sequence `F n = (c n, r n)` such that the closed ball `closedBall (c n) (r n)` is included in the previous ball and in `f n`, and such that `r n` is small enough to ensure that `c n` is a Cauchy sequence. Then `c n` converges to a limit which belongs to all the `f n`. -/ let F : ℕ → X × ℝ≥0∞ := fun n => Nat.recOn n (Prod.mk x (min ε (B 0))) fun n p => Prod.mk (center n p.1 p.2) (radius n p.1 p.2) let c : ℕ → X := fun n => (F n).1 let r : ℕ → ℝ≥0∞ := fun n => (F n).2 have rpos : ∀ n, 0 < r n := by intro n induction n with | zero => exact lt_min εpos (Bpos 0) | succ n hn => exact Hpos n (c n) (r n) hn.ne' have r0 : ∀ n, r n ≠ 0 := fun n => (rpos n).ne' have rB : ∀ n, r n ≤ B n := by intro n cases n with | zero => exact min_le_right _ _ | succ n => exact HB n (c n) (r n) (r0 n) have incl : ∀ n, closedBall (c (n + 1)) (r (n + 1)) ⊆ closedBall (c n) (r n) ∩ f n := fun n => Hball n (c n) (r n) (r0 n) have cdist : ∀ n, edist (c n) (c (n + 1)) ≤ B n := by intro n rw [edist_comm] have A : c (n + 1) ∈ closedBall (c (n + 1)) (r (n + 1)) := mem_closedBall_self have I := calc closedBall (c (n + 1)) (r (n + 1)) ⊆ closedBall (c n) (r n) := Subset.trans (incl n) inter_subset_left _ ⊆ closedBall (c n) (B n) := closedBall_subset_closedBall (rB n) exact I A have : CauchySeq c := cauchySeq_of_edist_le_geometric_two _ ENNReal.one_ne_top cdist -- as the sequence `c n` is Cauchy in a complete space, it converges to a limit `y`. rcases cauchySeq_tendsto_of_complete this with ⟨y, ylim⟩ -- this point `y` will be the desired point. We will check that it belongs to all -- `f n` and to `ball x ε`. use y simp only [Set.mem_iInter] have I : ∀ n, ∀ m ≥ n, closedBall (c m) (r m) ⊆ closedBall (c n) (r n) := by intro n refine Nat.le_induction ?_ fun m _ h => ?_ · exact Subset.refl _ · exact Subset.trans (incl m) (Subset.trans inter_subset_left h) have yball : ∀ n, y ∈ closedBall (c n) (r n) := by intro n refine isClosed_closedBall.mem_of_tendsto ylim ?_ refine (Filter.eventually_ge_atTop n).mono fun m hm => ?_ exact I n m hm mem_closedBall_self constructor · show ∀ n, y ∈ f n intro n have : closedBall (c (n + 1)) (r (n + 1)) ⊆ f n := Subset.trans (incl n) inter_subset_right exact this (yball (n + 1)) change edist y x ≤ ε exact le_trans (yball 0) (min_le_left _ _)
.lake/packages/mathlib/Mathlib/Topology/Metrizable/CompletelyMetrizable.lean
import Mathlib.Topology.MetricSpace.Gluing import Mathlib.Topology.Metrizable.Uniformity /-! # Completely metrizable spaces A topological space is completely metrizable if one can endow it with a `MetricSpace` structure which makes it complete and gives the same topology. This typeclass allows to state theorems which do not require a `MetricSpace` structure to make sense without introducing such a structure. It is in particular useful in measure theory, where one often assumes that a space is a `PolishSpace`, i.e. a separable and completely metrizable space. Sometimes the separability hypothesis is not needed and the right assumption is then `IsCompletelyMetrizableSpace`. ## Main definition * `IsCompletelyMetrizableSpace X`: A topological space is completely metrizable if there exists a metric space structure compatible with the topology which makes the space complete. To endow such a space with a compatible distance, use `letI := upgradeIsCompletelyMetrizable X`. ## Implementation note Given a `IsCompletelyMetrizableSpace X` instance, one may want to endow `X` with a complete metric. This can be done by writing `letI := upgradeIsCompletelyMetrizable X`, which will endow `X` with an `UpgradedIsCompletelyMetrizableSpace X` instance. This class is a convenience class and no instance should be registered for it. -/ open Filter Function Set Topology variable {X Y : Type*} namespace TopologicalSpace /-- A topological space is completely metrizable if there exists a metric space structure compatible with the topology which makes the space complete. To endow such a space with a compatible distance, use `letI := upgradeIsCompletelyMetrizable X`. -/ class IsCompletelyMetrizableSpace (X : Type*) [t : TopologicalSpace X] : Prop where complete : ∃ m : MetricSpace X, m.toUniformSpace.toTopologicalSpace = t ∧ @CompleteSpace X m.toUniformSpace instance (priority := 100) _root_.MetricSpace.toIsCompletelyMetrizableSpace [MetricSpace X] [CompleteSpace X] : IsCompletelyMetrizableSpace X := ⟨⟨‹_›, rfl, ‹_›⟩⟩ /-- A convenience class, for a completely metrizable space endowed with a complete metric. No instance of this class should be registered: It should be used as `letI := upgradeIsCompletelyMetrizable X` to endow a completely metrizable space with a complete metric. -/ class UpgradedIsCompletelyMetrizableSpace (X : Type*) extends MetricSpace X, CompleteSpace X open scoped Uniformity in instance (priority := 100) IsCompletelyMetrizableSpace.of_completeSpace_metrizable [UniformSpace X] [CompleteSpace X] [(𝓤 X).IsCountablyGenerated] [T0Space X] : IsCompletelyMetrizableSpace X where complete := ⟨UniformSpace.metricSpace X, rfl, ‹_›⟩ /-- Construct on a completely metrizable space a metric (compatible with the topology) which is complete. -/ noncomputable def completelyMetrizableMetric (X : Type*) [TopologicalSpace X] [h : IsCompletelyMetrizableSpace X] : MetricSpace X := h.complete.choose.replaceTopology h.complete.choose_spec.1.symm theorem complete_completelyMetrizableMetric (X : Type*) [ht : TopologicalSpace X] [h : IsCompletelyMetrizableSpace X] : @CompleteSpace X (completelyMetrizableMetric X).toUniformSpace := by convert h.complete.choose_spec.2 exact MetricSpace.replaceTopology_eq _ _ /-- This definition endows a completely metrizable space with a complete metric. Use it as: `letI := upgradeIsCompletelyMetrizable X`. -/ noncomputable def upgradeIsCompletelyMetrizable (X : Type*) [TopologicalSpace X] [IsCompletelyMetrizableSpace X] : UpgradedIsCompletelyMetrizableSpace X := letI := completelyMetrizableMetric X { complete_completelyMetrizableMetric X with } namespace IsCompletelyMetrizableSpace /-- Note: the priority is set to 90 to ensure that this instance is only applied after `EMetricSpace.metrizableSpace`. This prevents unnecessary attempts to infer completeness. -/ instance (priority := 90) MetrizableSpace [TopologicalSpace X] [IsCompletelyMetrizableSpace X] : MetrizableSpace X := by letI := upgradeIsCompletelyMetrizable X infer_instance /-- A countable product of completely metrizable spaces is completely metrizable. -/ instance pi_countable {ι : Type*} [Countable ι] {X : ι → Type*} [∀ i, TopologicalSpace (X i)] [∀ i, IsCompletelyMetrizableSpace (X i)] : IsCompletelyMetrizableSpace (Π i, X i) := by letI := fun i ↦ upgradeIsCompletelyMetrizable (X i) infer_instance /-- A disjoint union of completely metrizable spaces is completely metrizable. -/ instance sigma {ι : Type*} {X : ι → Type*} [∀ n, TopologicalSpace (X n)] [∀ n, IsCompletelyMetrizableSpace (X n)] : IsCompletelyMetrizableSpace (Σ n, X n) := letI := fun n ↦ upgradeIsCompletelyMetrizable (X n) letI : MetricSpace (Σ n, X n) := Metric.Sigma.metricSpace haveI : CompleteSpace (Σ n, X n) := Metric.Sigma.completeSpace inferInstance /-- The product of two completely metrizable spaces is completely metrizable. -/ instance prod [TopologicalSpace X] [IsCompletelyMetrizableSpace X] [TopologicalSpace Y] [IsCompletelyMetrizableSpace Y] : IsCompletelyMetrizableSpace (X × Y) := letI := upgradeIsCompletelyMetrizable X letI := upgradeIsCompletelyMetrizable Y inferInstance /-- The disjoint union of two completely metrizable spaces is completely metrizable. -/ instance sum [TopologicalSpace X] [IsCompletelyMetrizableSpace X] [TopologicalSpace Y] [IsCompletelyMetrizableSpace Y] : IsCompletelyMetrizableSpace (X ⊕ Y) := letI := upgradeIsCompletelyMetrizable X letI := upgradeIsCompletelyMetrizable Y inferInstance /-- Given a closed embedding into a completely metrizable space, the source space is also completely metrizable. -/ theorem _root_.Topology.IsClosedEmbedding.IsCompletelyMetrizableSpace [TopologicalSpace X] [TopologicalSpace Y] [IsCompletelyMetrizableSpace Y] {f : X → Y} (hf : IsClosedEmbedding f) : IsCompletelyMetrizableSpace X := by letI := upgradeIsCompletelyMetrizable Y letI : MetricSpace X := hf.isEmbedding.comapMetricSpace f have : CompleteSpace X := by rw [completeSpace_iff_isComplete_range hf.isEmbedding.to_isometry.isUniformInducing] exact hf.isClosed_range.isComplete infer_instance /-- Any discrete space is completely metrizable. -/ instance (priority := 50) discrete [TopologicalSpace X] [DiscreteTopology X] : IsCompletelyMetrizableSpace X := by classical let m : MetricSpace X := { dist x y := if x = y then 0 else 1 dist_self x := by simp dist_comm x y := by obtain h | h := eq_or_ne x y · simp [h] · simp [h, h.symm] dist_triangle x y z := by by_cases x = y <;> by_cases x = z <;> by_cases y = z <;> simp_all eq_of_dist_eq_zero := by simp } refine ⟨m, ?_, ?_⟩ · rw [DiscreteTopology.eq_bot (α := X)] refine eq_bot_of_singletons_open fun x ↦ ?_ convert @Metric.isOpen_ball _ _ x 1 refine subset_antisymm (singleton_subset_iff.2 (Metric.mem_ball_self (by simp))) fun y hy ↦ ?_ simp only [Metric.mem_ball, mem_singleton_iff] at * by_contra change (if y = x then 0 else 1) < 1 at hy simp_all · refine Metric.complete_of_cauchySeq_tendsto fun u hu ↦ ?_ rw [Metric.cauchySeq_iff'] at hu obtain ⟨N, hN⟩ := hu 1 (by simp) refine ⟨u N, @tendsto_atTop_of_eventually_const X UniformSpace.toTopologicalSpace (u N) _ _ _ N fun n hn ↦ ?_⟩ specialize hN n hn by_contra change (if u n = u N then 0 else 1) < 1 at hN simp_all /-- A closed subset of a completely metrizable space is also completely metrizable. -/ theorem _root_.IsClosed.isCompletelyMetrizableSpace [TopologicalSpace X] [IsCompletelyMetrizableSpace X] {s : Set X} (hs : IsClosed s) : IsCompletelyMetrizableSpace s := hs.isClosedEmbedding_subtypeVal.IsCompletelyMetrizableSpace instance univ [TopologicalSpace X] [IsCompletelyMetrizableSpace X] : IsCompletelyMetrizableSpace (univ : Set X) := isClosed_univ.isCompletelyMetrizableSpace end IsCompletelyMetrizableSpace end TopologicalSpace
.lake/packages/mathlib/Mathlib/Topology/Metrizable/Basic.lean
import Mathlib.Topology.MetricSpace.Basic /-! # Metrizability of a T₃ topological space with second countable topology In this file we define metrizable topological spaces, i.e., topological spaces for which there exists a metric space structure that generates the same topology. -/ open Filter Set Metric Topology namespace TopologicalSpace variable {ι X Y : Type*} {A : ι → Type*} [TopologicalSpace X] [TopologicalSpace Y] [Finite ι] [∀ i, TopologicalSpace (A i)] /-- A topological space is *pseudo metrizable* if there exists a pseudo metric space structure compatible with the topology. To endow such a space with a compatible distance, use `letI : PseudoMetricSpace X := TopologicalSpace.pseudoMetrizableSpacePseudoMetric X`. -/ class PseudoMetrizableSpace (X : Type*) [t : TopologicalSpace X] : Prop where exists_pseudo_metric : ∃ m : PseudoMetricSpace X, m.toUniformSpace.toTopologicalSpace = t instance (priority := 100) _root_.PseudoMetricSpace.toPseudoMetrizableSpace {X : Type*} [m : PseudoMetricSpace X] : PseudoMetrizableSpace X := ⟨⟨m, rfl⟩⟩ /-- Construct on a metrizable space a metric compatible with the topology. -/ noncomputable def pseudoMetrizableSpacePseudoMetric (X : Type*) [TopologicalSpace X] [h : PseudoMetrizableSpace X] : PseudoMetricSpace X := h.exists_pseudo_metric.choose.replaceTopology h.exists_pseudo_metric.choose_spec.symm instance pseudoMetrizableSpace_prod [PseudoMetrizableSpace X] [PseudoMetrizableSpace Y] : PseudoMetrizableSpace (X × Y) := letI : PseudoMetricSpace X := pseudoMetrizableSpacePseudoMetric X letI : PseudoMetricSpace Y := pseudoMetrizableSpacePseudoMetric Y inferInstance /-- Given an inducing map of a topological space into a pseudo metrizable space, the source space is also pseudo metrizable. -/ theorem _root_.Topology.IsInducing.pseudoMetrizableSpace [PseudoMetrizableSpace Y] {f : X → Y} (hf : IsInducing f) : PseudoMetrizableSpace X := letI : PseudoMetricSpace Y := pseudoMetrizableSpacePseudoMetric Y ⟨⟨hf.comapPseudoMetricSpace, rfl⟩⟩ /-- Every pseudo-metrizable space is first countable. -/ instance (priority := 100) PseudoMetrizableSpace.firstCountableTopology [h : PseudoMetrizableSpace X] : FirstCountableTopology X := by rcases h with ⟨_, hm⟩ rw [← hm] exact @UniformSpace.firstCountableTopology X PseudoMetricSpace.toUniformSpace EMetric.instIsCountablyGeneratedUniformity instance PseudoMetrizableSpace.subtype [PseudoMetrizableSpace X] (s : Set X) : PseudoMetrizableSpace s := IsInducing.subtypeVal.pseudoMetrizableSpace instance pseudoMetrizableSpace_pi [∀ i, PseudoMetrizableSpace (A i)] : PseudoMetrizableSpace (∀ i, A i) := by cases nonempty_fintype ι letI := fun i => pseudoMetrizableSpacePseudoMetric (A i) infer_instance /-- A topological space is metrizable if there exists a metric space structure compatible with the topology. To endow such a space with a compatible distance, use `letI : MetricSpace X := TopologicalSpace.metrizableSpaceMetric X`. -/ class MetrizableSpace (X : Type*) [t : TopologicalSpace X] : Prop where exists_metric : ∃ m : MetricSpace X, m.toUniformSpace.toTopologicalSpace = t instance (priority := 100) _root_.MetricSpace.toMetrizableSpace {X : Type*} [m : MetricSpace X] : MetrizableSpace X := ⟨⟨m, rfl⟩⟩ instance (priority := 100) MetrizableSpace.toPseudoMetrizableSpace [h : MetrizableSpace X] : PseudoMetrizableSpace X := let ⟨m, hm⟩ := h.1 ⟨⟨m.toPseudoMetricSpace, hm⟩⟩ instance (priority := 100) PseudoMetrizableSpace.toMetrizableSpace [T0Space X] [h : PseudoMetrizableSpace X] : MetrizableSpace X := letI := pseudoMetrizableSpacePseudoMetric X ⟨.ofT0PseudoMetricSpace X, rfl⟩ /-- Construct on a metrizable space a metric compatible with the topology. -/ noncomputable def metrizableSpaceMetric (X : Type*) [TopologicalSpace X] [h : MetrizableSpace X] : MetricSpace X := h.exists_metric.choose.replaceTopology h.exists_metric.choose_spec.symm instance (priority := 100) t2Space_of_metrizableSpace [MetrizableSpace X] : T2Space X := letI : MetricSpace X := metrizableSpaceMetric X inferInstance instance metrizableSpace_prod [MetrizableSpace X] [MetrizableSpace Y] : MetrizableSpace (X × Y) := letI : MetricSpace X := metrizableSpaceMetric X letI : MetricSpace Y := metrizableSpaceMetric Y inferInstance /-- Given an embedding of a topological space into a metrizable space, the source space is also metrizable. -/ theorem _root_.Topology.IsEmbedding.metrizableSpace [MetrizableSpace Y] {f : X → Y} (hf : IsEmbedding f) : MetrizableSpace X := letI : MetricSpace Y := metrizableSpaceMetric Y ⟨⟨hf.comapMetricSpace f, rfl⟩⟩ instance MetrizableSpace.subtype [MetrizableSpace X] (s : Set X) : MetrizableSpace s := IsEmbedding.subtypeVal.metrizableSpace instance metrizableSpace_pi [∀ i, MetrizableSpace (A i)] : MetrizableSpace (∀ i, A i) := by cases nonempty_fintype ι letI := fun i => metrizableSpaceMetric (A i) infer_instance theorem IsSeparable.secondCountableTopology [PseudoMetrizableSpace X] {s : Set X} (hs : IsSeparable s) : SecondCountableTopology s := by letI := pseudoMetrizableSpacePseudoMetric X have := hs.separableSpace exact UniformSpace.secondCountable_of_separable s instance (X : Type*) [TopologicalSpace X] [c : CompactSpace X] [MetrizableSpace X] : SecondCountableTopology X := by obtain ⟨_, h⟩ := MetrizableSpace.exists_metric (X := X) rw [← h] at c ⊢ infer_instance end TopologicalSpace
.lake/packages/mathlib/Mathlib/Topology/Metrizable/ContinuousMap.lean
import Mathlib.Topology.Metrizable.Uniformity import Mathlib.Topology.UniformSpace.CompactConvergence /-! # Metrizability of `C(X, Y)` If `X` is a weakly locally compact σ-compact space and `Y` is a (pseudo)metrizable space, then `C(X, Y)` is a (pseudo)metrizable space. -/ open TopologicalSpace namespace ContinuousMap variable {X Y : Type*} [TopologicalSpace X] [WeaklyLocallyCompactSpace X] [SigmaCompactSpace X] [TopologicalSpace Y] instance [PseudoMetrizableSpace Y] : PseudoMetrizableSpace C(X, Y) := let _ := pseudoMetrizableSpacePseudoMetric Y inferInstance instance [MetrizableSpace Y] : MetrizableSpace C(X, Y) := let _ := metrizableSpaceMetric Y UniformSpace.metrizableSpace end ContinuousMap
.lake/packages/mathlib/Mathlib/Topology/Metrizable/Uniformity.lean
import Mathlib.Data.Nat.Lattice import Mathlib.Data.NNReal.Basic import Mathlib.Topology.Metrizable.Basic /-! # Metrizable uniform spaces In this file we prove that a uniform space with countably generated uniformity filter is pseudometrizable: there exists a `PseudoMetricSpace` structure that generates the same uniformity. The proof follows [Sergey Melikhov, Metrizable uniform spaces][melikhov2011]. ## Main definitions * `PseudoMetricSpace.ofPreNNDist`: given a function `d : X → X → ℝ≥0` such that `d x x = 0` and `d x y = d y x` for all `x y : X`, constructs the maximal pseudo metric space structure such that `NNDist x y ≤ d x y` for all `x y : X`. * `UniformSpace.pseudoMetricSpace`: given a uniform space `X` with countably generated `𝓤 X`, constructs a `PseudoMetricSpace X` instance that is compatible with the uniform space structure. * `UniformSpace.metricSpace`: given a T₀ uniform space `X` with countably generated `𝓤 X`, constructs a `MetricSpace X` instance that is compatible with the uniform space structure. ## Main statements * `UniformSpace.metrizable_uniformity`: if `X` is a uniform space with countably generated `𝓤 X`, then there exists a `PseudoMetricSpace` structure that is compatible with this `UniformSpace` structure. Use `UniformSpace.pseudoMetricSpace` or `UniformSpace.metricSpace` instead. * `UniformSpace.pseudoMetrizableSpace`: a uniform space with countably generated `𝓤 X` is pseudo metrizable. * `UniformSpace.metrizableSpace`: a T₀ uniform space with countably generated `𝓤 X` is metrizable. This is not an instance to avoid loops. ## Tags metrizable space, uniform space -/ open Set Function Metric List Filter open scoped NNReal SetRel Uniformity variable {X : Type*} namespace PseudoMetricSpace /-- The maximal pseudo metric space structure on `X` such that `dist x y ≤ d x y` for all `x y`, where `d : X → X → ℝ≥0` is a function such that `d x x = 0` and `d x y = d y x` for all `x`, `y`. -/ noncomputable def ofPreNNDist (d : X → X → ℝ≥0) (dist_self : ∀ x, d x x = 0) (dist_comm : ∀ x y, d x y = d y x) : PseudoMetricSpace X where dist x y := ↑(⨅ l : List X, ((x::l).zipWith d (l ++ [y])).sum : ℝ≥0) dist_self x := NNReal.coe_eq_zero.2 <| nonpos_iff_eq_zero.1 <| (ciInf_le (OrderBot.bddBelow _) []).trans_eq <| by simp [dist_self] dist_comm x y := NNReal.coe_inj.2 <| by refine reverse_surjective.iInf_congr _ fun l ↦ ?_ rw [← sum_reverse, reverse_zipWith, reverse_append, reverse_reverse, reverse_singleton, singleton_append, reverse_cons, reverse_reverse, zipWith_comm_of_comm dist_comm] simp only [length, length_append] dist_triangle x y z := by rw [← NNReal.coe_add, NNReal.coe_le_coe] refine NNReal.le_iInf_add_iInf fun lxy lyz ↦ ?_ calc ⨅ l, (zipWith d (x::l) (l ++ [z])).sum ≤ (zipWith d (x::lxy ++ y::lyz) ((lxy ++ y::lyz) ++ [z])).sum := ciInf_le (OrderBot.bddBelow _) (lxy ++ y::lyz) _ = (zipWith d (x::lxy) (lxy ++ [y])).sum + (zipWith d (y::lyz) (lyz ++ [z])).sum := by rw [← sum_append, ← zipWith_append, cons_append, ← @singleton_append _ y, append_assoc, append_assoc, append_assoc] rw [length_cons, length_append, length_singleton] theorem dist_ofPreNNDist (d : X → X → ℝ≥0) (dist_self : ∀ x, d x x = 0) (dist_comm : ∀ x y, d x y = d y x) (x y : X) : @dist X (@PseudoMetricSpace.toDist X (PseudoMetricSpace.ofPreNNDist d dist_self dist_comm)) x y = ↑(⨅ l : List X, ((x::l).zipWith d (l ++ [y])).sum : ℝ≥0) := rfl theorem dist_ofPreNNDist_le (d : X → X → ℝ≥0) (dist_self : ∀ x, d x x = 0) (dist_comm : ∀ x y, d x y = d y x) (x y : X) : @dist X (@PseudoMetricSpace.toDist X (PseudoMetricSpace.ofPreNNDist d dist_self dist_comm)) x y ≤ d x y := NNReal.coe_le_coe.2 <| (ciInf_le (OrderBot.bddBelow _) []).trans_eq <| by simp /-- Consider a function `d : X → X → ℝ≥0` such that `d x x = 0` and `d x y = d y x` for all `x`, `y`. Let `dist` be the largest pseudometric distance such that `dist x y ≤ d x y`, see `PseudoMetricSpace.ofPreNNDist`. Suppose that `d` satisfies the following triangle-like inequality: `d x₁ x₄ ≤ 2 * max (d x₁ x₂, d x₂ x₃, d x₃ x₄)`. Then `d x y ≤ 2 * dist x y` for all `x`, `y`. -/ theorem le_two_mul_dist_ofPreNNDist (d : X → X → ℝ≥0) (dist_self : ∀ x, d x x = 0) (dist_comm : ∀ x y, d x y = d y x) (hd : ∀ x₁ x₂ x₃ x₄, d x₁ x₄ ≤ 2 * max (d x₁ x₂) (max (d x₂ x₃) (d x₃ x₄))) (x y : X) : ↑(d x y) ≤ 2 * @dist X (@PseudoMetricSpace.toDist X (PseudoMetricSpace.ofPreNNDist d dist_self dist_comm)) x y := by /- We need to show that `d x y` is at most twice the sum `L` of `d xᵢ xᵢ₊₁` over a path `x₀=x, ..., xₙ=y`. We prove it by induction on the length `n` of the sequence. Find an edge that splits the path into two parts of almost equal length: both `d x₀ x₁ + ... + d xₖ₋₁ xₖ` and `d xₖ₊₁ xₖ₊₂ + ... + d xₙ₋₁ xₙ` are less than or equal to `L / 2`. Then `d x₀ xₖ ≤ L`, `d xₖ xₖ₊₁ ≤ L`, and `d xₖ₊₁ xₙ ≤ L`, thus `d x₀ xₙ ≤ 2 * L`. -/ rw [dist_ofPreNNDist, ← NNReal.coe_two, ← NNReal.coe_mul, NNReal.mul_iInf, NNReal.coe_le_coe] refine le_ciInf fun l => ?_ have hd₀_trans : Transitive fun x y => d x y = 0 := by intro a b c hab hbc rw [← nonpos_iff_eq_zero] simpa only [nonpos_iff_eq_zero, hab, hbc, dist_self c, max_self, mul_zero] using hd a b c c haveI : IsTrans X fun x y => d x y = 0 := ⟨hd₀_trans⟩ suffices ∀ n, length l = n → d x y ≤ 2 * (zipWith d (x :: l) (l ++ [y])).sum by exact this _ rfl intro n hn induction n using Nat.strong_induction_on generalizing x y l with | h n ihn => simp only at ihn subst n set L := zipWith d (x::l) (l ++ [y]) have hL_len : length L = length l + 1 := by simp [L] rcases eq_or_ne (d x y) 0 with hd₀ | hd₀ · simp only [hd₀, zero_le] rsuffices ⟨z, z', hxz, hzz', hz'y⟩ : ∃ z z' : X, d x z ≤ L.sum ∧ d z z' ≤ L.sum ∧ d z' y ≤ L.sum · grw [hd x z z' y, max_le hxz (max_le hzz' hz'y)] set s : Set ℕ := { m : ℕ | 2 * (take m L).sum ≤ L.sum } have hs₀ : 0 ∈ s := by simp [s] have hsne : s.Nonempty := ⟨0, hs₀⟩ obtain ⟨M, hMl, hMs⟩ : ∃ M ≤ length l, IsGreatest s M := by have hs_ub : length l ∈ upperBounds s := by intro m hm rw [← not_lt, Nat.lt_iff_add_one_le, ← hL_len] intro hLm rw [mem_setOf_eq, take_of_length_le hLm, two_mul, add_le_iff_nonpos_left, nonpos_iff_eq_zero, sum_eq_zero_iff, ← forall_iff_forall_mem, forall_zipWith, ← isChain_cons_append_singleton_iff_forall₂] at hm <;> [skip; simp] exact hd₀ (hm.rel_cons (mem_append.2 <| Or.inr <| mem_singleton_self _)) have hs_bdd : BddAbove s := ⟨length l, hs_ub⟩ exact ⟨sSup s, csSup_le hsne hs_ub, ⟨Nat.sSup_mem hsne hs_bdd, fun k => le_csSup hs_bdd⟩⟩ have hM_lt : M < length L := by rwa [hL_len, Nat.lt_succ_iff] have hM_ltx : M < length (x::l) := lt_length_left_of_zipWith hM_lt have hM_lty : M < length (l ++ [y]) := lt_length_right_of_zipWith hM_lt refine ⟨(x::l)[M], (l ++ [y])[M], ?_, ?_, ?_⟩ · cases M with | zero => simp [dist_self] | succ M => rw [Nat.succ_le_iff] at hMl have hMl' : length (take M l) = M := length_take.trans (min_eq_left hMl.le) refine (ihn _ hMl _ _ _ hMl').trans ?_ convert hMs.1.out rw [take_zipWith, take, take_succ, getElem?_append_left hMl, getElem?_eq_getElem hMl, ← Option.coe_def, Option.toList_some, take_append_of_le_length hMl.le, getElem_cons_succ] · exact single_le_sum (fun x _ => zero_le x) _ (mem_iff_get.2 ⟨⟨M, hM_lt⟩, getElem_zipWith⟩) · rcases hMl.eq_or_lt with (rfl | hMl) · simp only [getElem_append_right le_rfl, getElem_singleton, dist_self, zero_le] rw [getElem_append_left hMl] have hlen : length (drop (M + 1) l) = length l - (M + 1) := length_drop have hlen_lt : length l - (M + 1) < length l := Nat.sub_lt_of_pos_le M.succ_pos hMl refine (ihn _ hlen_lt _ y _ hlen).trans ?_ rw [cons_getElem_drop_succ] have hMs' : L.sum ≤ 2 * (L.take (M + 1)).sum := not_lt.1 fun h => (hMs.2 h.le).not_gt M.lt_succ_self rw [← sum_take_add_sum_drop L (M + 1), two_mul, add_le_add_iff_left, ← add_le_add_iff_right, sum_take_add_sum_drop, ← two_mul] at hMs' convert hMs' rwa [drop_zipWith, drop, drop_append_of_le_length] end PseudoMetricSpace /-- If `X` is a uniform space with countably generated uniformity filter, there exists a `PseudoMetricSpace` structure compatible with the `UniformSpace` structure. Use `UniformSpace.pseudoMetricSpace` or `UniformSpace.metricSpace` instead. -/ protected theorem UniformSpace.metrizable_uniformity (X : Type*) [UniformSpace X] [IsCountablyGenerated (𝓤 X)] : ∃ I : PseudoMetricSpace X, I.toUniformSpace = ‹_› := by classical /- Choose a fast decreasing antitone basis `U : ℕ → SetRel X X` of the uniformity filter `𝓤 X`. Define `d x y : ℝ≥0` to be `(1 / 2) ^ n`, where `n` is the minimal index of `U n` that separates `x` and `y`: `(x, y) ∉ U n`, or `0` if `x` is not separated from `y`. This function satisfies the assumptions of `PseudoMetricSpace.ofPreNNDist` and `PseudoMetricSpace.le_two_mul_dist_ofPreNNDist`, hence the distance given by the former pseudo metric space structure is Lipschitz equivalent to the `d`. Thus the uniformities generated by `d` and `dist` are equal. Since the former uniformity is equal to `𝓤 X`, the latter is equal to `𝓤 X` as well. -/ obtain ⟨U, hU_symm, hU_comp, hB⟩ : ∃ U : ℕ → SetRel X X, (∀ n, (U n).IsSymm) ∧ (∀ ⦃m n⦄, m < n → U n ○ (U n ○ U n) ⊆ U m) ∧ (𝓤 X).HasAntitoneBasis U := by rcases UniformSpace.has_seq_basis X with ⟨V, hB, hV_symm⟩ rcases hB.subbasis_with_rel fun m => hB.tendsto_smallSets.eventually (eventually_uniformity_iterate_comp_subset (hB.mem m) 2) with ⟨φ, -, hφ_comp, hφB⟩ exact ⟨V ∘ φ, fun n => hV_symm _, hφ_comp, hφB⟩ set d : X → X → ℝ≥0 := fun x y => if h : ∃ n, (x, y) ∉ U n then (1 / 2) ^ Nat.find h else 0 have hd₀ : ∀ {x y}, d x y = 0 ↔ Inseparable x y := by intro x y refine Iff.trans ?_ hB.inseparable_iff_uniformity.symm simp only [d, true_imp_iff] split_ifs with h · simp [h, pow_eq_zero_iff'] · simpa only [not_exists, Classical.not_not, eq_self_iff_true, true_iff] using h have hd_symm x y : d x y = d y x := by simp only [d, (U _).comm] have hr : (1 / 2 : ℝ≥0) ∈ Ioo (0 : ℝ≥0) 1 := ⟨half_pos one_pos, NNReal.half_lt_self one_ne_zero⟩ letI I := PseudoMetricSpace.ofPreNNDist d (fun x => hd₀.2 rfl) hd_symm have hdist_le : ∀ x y, dist x y ≤ d x y := PseudoMetricSpace.dist_ofPreNNDist_le _ _ _ have hle_d : ∀ {x y : X} {n : ℕ}, (1 / 2) ^ n ≤ d x y ↔ (x, y) ∉ U n := by intro x y n dsimp only [d] split_ifs with h · rw [(pow_right_strictAnti₀ hr.1 hr.2).le_iff_ge, Nat.find_le_iff] exact ⟨fun ⟨m, hmn, hm⟩ hn => hm (hB.antitone hmn hn), fun h => ⟨n, le_rfl, h⟩⟩ · push_neg at h simp only [h, not_true, (pow_pos hr.1 _).not_ge] have hd_le : ∀ x y, ↑(d x y) ≤ 2 * dist x y := by refine PseudoMetricSpace.le_two_mul_dist_ofPreNNDist _ _ _ fun x₁ x₂ x₃ x₄ => ?_ by_cases H : ∃ n, (x₁, x₄) ∉ U n · refine (dif_pos H).trans_le ?_ rw [← div_le_iff₀' zero_lt_two, ← mul_one_div (_ ^ _), ← pow_succ] simp only [le_max_iff, hle_d, ← not_and_or] rintro ⟨h₁₂, h₂₃, h₃₄⟩ refine Nat.find_spec H (hU_comp (lt_add_one <| Nat.find H) ?_) exact ⟨x₂, h₁₂, x₃, h₂₃, h₃₄⟩ · exact (dif_neg H).trans_le (zero_le _) -- Porting note: without the next line, `uniformity_basis_dist_pow` ends up introducing some -- `Subtype.val` applications instead of `NNReal.toReal`. rw [mem_Ioo, ← NNReal.coe_lt_coe, ← NNReal.coe_lt_coe] at hr refine ⟨I, UniformSpace.ext <| (uniformity_basis_dist_pow hr.1 hr.2).ext hB.toHasBasis ?_ ?_⟩ · refine fun n hn => ⟨n, hn, fun x hx => (hdist_le _ _).trans_lt ?_⟩ rwa [← NNReal.coe_pow, NNReal.coe_lt_coe, ← not_le, hle_d, Classical.not_not] · refine fun n _ => ⟨n + 1, trivial, fun x hx => ?_⟩ rw [mem_setOf_eq] at hx contrapose! hx refine le_trans ?_ ((div_le_iff₀' zero_lt_two).2 (hd_le x.1 x.2)) rwa [← NNReal.coe_two, ← NNReal.coe_div, ← NNReal.coe_pow, NNReal.coe_le_coe, pow_succ, mul_one_div, div_le_iff₀ zero_lt_two, div_mul_cancel₀ _ two_ne_zero, hle_d] /-- A `PseudoMetricSpace` instance compatible with a given `UniformSpace` structure. -/ protected noncomputable def UniformSpace.pseudoMetricSpace (X : Type*) [UniformSpace X] [IsCountablyGenerated (𝓤 X)] : PseudoMetricSpace X := (UniformSpace.metrizable_uniformity X).choose.replaceUniformity <| congr_arg _ (UniformSpace.metrizable_uniformity X).choose_spec.symm /-- A `MetricSpace` instance compatible with a given `UniformSpace` structure. -/ protected noncomputable def UniformSpace.metricSpace (X : Type*) [UniformSpace X] [IsCountablyGenerated (𝓤 X)] [T0Space X] : MetricSpace X := @MetricSpace.ofT0PseudoMetricSpace X (UniformSpace.pseudoMetricSpace X) _ /-- A uniform space with countably generated `𝓤 X` is pseudo metrizable. -/ instance (priority := 100) UniformSpace.pseudoMetrizableSpace [UniformSpace X] [IsCountablyGenerated (𝓤 X)] : TopologicalSpace.PseudoMetrizableSpace X := by letI := UniformSpace.pseudoMetricSpace X infer_instance /-- A T₀ uniform space with countably generated `𝓤 X` is metrizable. This is not an instance to avoid loops. -/ theorem UniformSpace.metrizableSpace [UniformSpace X] [IsCountablyGenerated (𝓤 X)] [T0Space X] : TopologicalSpace.MetrizableSpace X := by letI := UniformSpace.metricSpace X infer_instance /-- A totally bounded set is separable in countably generated uniform spaces. This can be obtained from the more general `EMetric.subset_countable_closure_of_almost_dense_set`. -/ lemma TotallyBounded.isSeparable [UniformSpace X] [i : IsCountablyGenerated (𝓤 X)] {s : Set X} (h : TotallyBounded s) : TopologicalSpace.IsSeparable s := by letI := (UniformSpace.pseudoMetricSpace (X := X)).toPseudoEMetricSpace rw [EMetric.totallyBounded_iff] at h have h' : ∀ ε > 0, ∃ t, Set.Countable t ∧ s ⊆ ⋃ y ∈ t, EMetric.closedBall y ε := by intro ε hε obtain ⟨t, ht⟩ := h ε hε refine ⟨t, ht.1.countable, subset_trans ht.2 ?_⟩ gcongr exact EMetric.ball_subset_closedBall obtain ⟨t, _, htc, hts⟩ := EMetric.subset_countable_closure_of_almost_dense_set s h' exact ⟨t, htc, hts⟩ variable {α : Type*} open TopologicalSpace instance (priority := 100) DiscreteTopology.metrizableSpace [TopologicalSpace α] [DiscreteTopology α] : MetrizableSpace α := by obtain rfl := DiscreteTopology.eq_bot (α := α) exact @UniformSpace.metrizableSpace α ⊥ (isCountablyGenerated_principal _) _ instance (priority := 100) PseudoEMetricSpace.pseudoMetrizableSpace [PseudoEMetricSpace α] : PseudoMetrizableSpace α := inferInstance instance (priority := 100) EMetricSpace.metrizableSpace [EMetricSpace α] : MetrizableSpace α := inferInstance
.lake/packages/mathlib/Mathlib/Topology/Metrizable/Urysohn.lean
import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Topology.UrysohnsLemma import Mathlib.Topology.Metrizable.Basic import Mathlib.Topology.ContinuousMap.Bounded.Basic /-! # Urysohn's Metrization Theorem In this file we prove Urysohn's Metrization Theorem: a T₃ topological space with second countable topology `X` is metrizable. First we prove that `X` can be embedded into `l^∞`, then use this embedding to pull back the metric space structure. ## Implementation notes We use `ℕ →ᵇ ℝ`, not `lpSpace` for `l^∞` to avoid heavy imports. -/ open Filter Metric Set Topology open scoped BoundedContinuousFunction namespace TopologicalSpace section RegularSpace variable (X : Type*) [TopologicalSpace X] [RegularSpace X] [SecondCountableTopology X] /-- For a regular topological space with second countable topology, there exists an inducing map to `l^∞ = ℕ →ᵇ ℝ`. -/ theorem exists_isInducing_l_infty : ∃ f : X → ℕ →ᵇ ℝ, IsInducing f := by -- Choose a countable basis, and consider the set `s` of pairs of set `(U, V)` such that `U ∈ B`, -- `V ∈ B`, and `closure U ⊆ V`. rcases exists_countable_basis X with ⟨B, hBc, -, hB⟩ let s : Set (Set X × Set X) := { UV ∈ B ×ˢ B | closure UV.1 ⊆ UV.2 } -- `s` is a countable set. haveI : Encodable s := ((hBc.prod hBc).mono inter_subset_left).toEncodable -- We don't have the space of bounded (possibly discontinuous) functions, so we equip `s` -- with the discrete topology and deal with `s →ᵇ ℝ` instead. letI : TopologicalSpace s := ⊥ haveI : DiscreteTopology s := ⟨rfl⟩ rsuffices ⟨f, hf⟩ : ∃ f : X → s →ᵇ ℝ, IsInducing f · exact ⟨fun x => (f x).extend (Encodable.encode' s) 0, (BoundedContinuousFunction.isometry_extend (Encodable.encode' s) (0 : ℕ →ᵇ ℝ)).isEmbedding.isInducing.comp hf⟩ have hd : ∀ UV : s, Disjoint (closure UV.1.1) UV.1.2ᶜ := fun UV => disjoint_compl_right.mono_right (compl_subset_compl.2 UV.2.2) -- Choose a sequence of `εₙ > 0`, `n : s`, that is bounded above by `1` and tends to zero -- along the `cofinite` filter. obtain ⟨ε, ε01, hε⟩ : ∃ ε : s → ℝ, (∀ UV, ε UV ∈ Ioc (0 : ℝ) 1) ∧ Tendsto ε cofinite (𝓝 0) := by rcases posSumOfEncodable zero_lt_one s with ⟨ε, ε0, c, hεc, hc1⟩ refine ⟨ε, fun UV => ⟨ε0 UV, ?_⟩, hεc.summable.tendsto_cofinite_zero⟩ exact (le_hasSum hεc UV fun _ _ => (ε0 _).le).trans hc1 /- For each `UV = (U, V) ∈ s` we use Urysohn's lemma to choose a function `f UV` that is equal to zero on `U` and is equal to `ε UV` on the complement to `V`. -/ have : ∀ UV : s, ∃ f : C(X, ℝ), EqOn f 0 UV.1.1 ∧ EqOn f (fun _ => ε UV) UV.1.2ᶜ ∧ ∀ x, f x ∈ Icc 0 (ε UV) := by intro UV rcases exists_continuous_zero_one_of_isClosed isClosed_closure (hB.isOpen UV.2.1.2).isClosed_compl (hd UV) with ⟨f, hf₀, hf₁, hf01⟩ exact ⟨ε UV • f, fun x hx => by simp [hf₀ (subset_closure hx)], fun x hx => by simp [hf₁ hx], fun x => ⟨mul_nonneg (ε01 _).1.le (hf01 _).1, mul_le_of_le_one_right (ε01 _).1.le (hf01 _).2⟩⟩ choose f hf0 hfε hf0ε using this have hf01 : ∀ UV x, f UV x ∈ Icc (0 : ℝ) 1 := fun UV x => Icc_subset_Icc_right (ε01 _).2 (hf0ε _ _) -- The embedding is given by `F x UV = f UV x`. set F : X → s →ᵇ ℝ := fun x => ⟨⟨fun UV => f UV x, continuous_of_discreteTopology⟩, 1, fun UV₁ UV₂ => Real.dist_le_of_mem_Icc_01 (hf01 _ _) (hf01 _ _)⟩ have hF : ∀ x UV, F x UV = f UV x := fun _ _ => rfl refine ⟨F, isInducing_iff_nhds.2 fun x => le_antisymm ?_ ?_⟩ · /- First we prove that `F` is continuous. Given `δ > 0`, consider the set `T` of `(U, V) ∈ s` such that `ε (U, V) ≥ δ`. Since `ε` tends to zero, `T` is finite. Since each `f` is continuous, we can choose a neighborhood such that `dist (F y (U, V)) (F x (U, V)) ≤ δ` for any `(U, V) ∈ T`. For `(U, V) ∉ T`, the same inequality is true because both `F y (U, V)` and `F x (U, V)` belong to the interval `[0, ε (U, V)]`. -/ refine (nhds_basis_closedBall.comap _).ge_iff.2 fun δ δ0 => ?_ have h_fin : { UV : s | δ ≤ ε UV }.Finite := by simpa only [← not_lt] using hε (gt_mem_nhds δ0) have : ∀ᶠ y in 𝓝 x, ∀ UV, δ ≤ ε UV → dist (F y UV) (F x UV) ≤ δ := by refine (eventually_all_finite h_fin).2 fun UV _ => ?_ exact (f UV).continuous.tendsto x (closedBall_mem_nhds _ δ0) refine this.mono fun y hy => (BoundedContinuousFunction.dist_le δ0.le).2 fun UV => ?_ rcases le_total δ (ε UV) with hle | hle exacts [hy _ hle, (Real.dist_le_of_mem_Icc (hf0ε _ _) (hf0ε _ _)).trans (by rwa [sub_zero])] · /- Finally, we prove that each neighborhood `V` of `x : X` includes a preimage of a neighborhood of `F x` under `F`. Without loss of generality, `V` belongs to `B`. Choose `U ∈ B` such that `x ∈ V` and `closure V ⊆ U`. Then the preimage of the `(ε (U, V))`-neighborhood of `F x` is included by `V`. -/ refine ((nhds_basis_ball.comap _).le_basis_iff hB.nhds_hasBasis).2 ?_ rintro V ⟨hVB, hxV⟩ rcases hB.exists_closure_subset (hB.mem_nhds hVB hxV) with ⟨U, hUB, hxU, hUV⟩ set UV : ↥s := ⟨(U, V), ⟨hUB, hVB⟩, hUV⟩ refine ⟨ε UV, (ε01 UV).1, fun y (hy : dist (F y) (F x) < ε UV) => ?_⟩ replace hy : dist (F y UV) (F x UV) < ε UV := (BoundedContinuousFunction.dist_coe_le_dist _).trans_lt hy contrapose! hy rw [hF, hF, hfε UV hy, hf0 UV hxU, Pi.zero_apply, dist_zero_right] exact le_abs_self _ /-- *Urysohn's metrization theorem* (Tychonoff's version): a regular topological space with second countable topology `X` is metrizable, i.e., there exists a pseudometric space structure that generates the same topology. -/ instance (priority := 90) PseudoMetrizableSpace.of_regularSpace_secondCountableTopology : PseudoMetrizableSpace X := let ⟨_, hf⟩ := exists_isInducing_l_infty X hf.pseudoMetrizableSpace end RegularSpace variable (X : Type*) [TopologicalSpace X] [T3Space X] [SecondCountableTopology X] /-- A T₃ topological space with second countable topology can be embedded into `l^∞ = ℕ →ᵇ ℝ`. -/ theorem exists_embedding_l_infty : ∃ f : X → ℕ →ᵇ ℝ, IsEmbedding f := let ⟨f, hf⟩ := exists_isInducing_l_infty X; ⟨f, hf.isEmbedding⟩ /-- *Urysohn's metrization theorem* (Tychonoff's version): a T₃ topological space with second countable topology `X` is metrizable, i.e., there exists a metric space structure that generates the same topology. -/ instance (priority := 90) metrizableSpace_of_t3_secondCountable : MetrizableSpace X := let ⟨_, hf⟩ := exists_embedding_l_infty X hf.metrizableSpace end TopologicalSpace
.lake/packages/mathlib/Mathlib/Topology/Metrizable/Real.lean
import Mathlib.Topology.Metrizable.Basic import Mathlib.Topology.Order.MonotoneContinuity import Mathlib.Topology.Order.Real /-! # `ENNReal` is metrizable ## Implementation details This file currently only contains results on `ENNReal` but is named `Real.lean` to make it clear we can accept more `(E)(NN)Real` results. -/ namespace ENNReal open NNReal TopologicalSpace instance : MetrizableSpace ENNReal := orderIsoUnitIntervalBirational.toHomeomorph.isEmbedding.metrizableSpace end ENNReal
.lake/packages/mathlib/Mathlib/Topology/Algebra/GroupCompletion.lean
import Mathlib.Topology.Algebra.UniformMulAction import Mathlib.Topology.UniformSpace.Completion import Mathlib.Topology.Algebra.Group.Pointwise /-! # Completion of topological groups: This file endows the completion of a topological abelian group with a group structure. More precisely the instance `UniformSpace.Completion.addGroup` builds an abelian group structure on the completion of an abelian group endowed with a compatible uniform structure. Then the instance `UniformSpace.Completion.isUniformAddGroup` proves this group structure is compatible with the completed uniform structure. The compatibility condition is `IsUniformAddGroup`. ## Main declarations: Beyond the instances explained above (that don't have to be explicitly invoked), the main constructions deal with continuous group morphisms. * `AddMonoidHom.extension`: extends a continuous group morphism from `G` to a complete separated group `H` to `Completion G`. * `AddMonoidHom.completion`: promotes a continuous group morphism from `G` to `H` into a continuous group morphism from `Completion G` to `Completion H`. -/ noncomputable section variable {M R α β : Type*} section Group open UniformSpace CauchyFilter Filter Set variable [UniformSpace α] instance [Zero α] : Zero (Completion α) := ⟨(0 : α)⟩ instance [Neg α] : Neg (Completion α) := ⟨Completion.map (fun a ↦ -a : α → α)⟩ instance [Add α] : Add (Completion α) := ⟨Completion.map₂ (· + ·)⟩ instance [Sub α] : Sub (Completion α) := ⟨Completion.map₂ Sub.sub⟩ @[norm_cast] theorem UniformSpace.Completion.coe_zero [Zero α] : ((0 : α) : Completion α) = 0 := rfl @[simp] lemma UniformSpace.Completion.coe_eq_zero_iff [Zero α] [T0Space α] {x : α} : (x : Completion α) = 0 ↔ x = 0 := Completion.coe_inj end Group namespace UniformSpace.Completion open UniformSpace section Zero instance [UniformSpace α] [MonoidWithZero M] [Zero α] [MulActionWithZero M α] [UniformContinuousConstSMul M α] : MulActionWithZero M (Completion α) := { (inferInstance : MulAction M <| Completion α) with smul_zero := fun r ↦ by rw [← coe_zero, ← coe_smul, MulActionWithZero.smul_zero r] zero_smul := ext' (continuous_const_smul _) continuous_const fun a ↦ by rw [← coe_smul, zero_smul, coe_zero] } end Zero section IsUniformAddGroup variable [UniformSpace α] [AddGroup α] [IsUniformAddGroup α] @[norm_cast] theorem coe_neg (a : α) : ((-a : α) : Completion α) = -a := (map_coe uniformContinuous_neg a).symm @[norm_cast] theorem coe_sub (a b : α) : ((a - b : α) : Completion α) = a - b := (map₂_coe_coe a b Sub.sub uniformContinuous_sub).symm @[norm_cast] theorem coe_add (a b : α) : ((a + b : α) : Completion α) = a + b := (map₂_coe_coe a b (· + ·) uniformContinuous_add).symm instance : AddMonoid (Completion α) := { (inferInstance : Zero <| Completion α), (inferInstance : Add <| Completion α) with zero_add := fun a ↦ Completion.induction_on a (isClosed_eq (continuous_map₂ continuous_const continuous_id) continuous_id) fun a ↦ show 0 + (a : Completion α) = a by rw [← coe_zero, ← coe_add, zero_add] add_zero := fun a ↦ Completion.induction_on a (isClosed_eq (continuous_map₂ continuous_id continuous_const) continuous_id) fun a ↦ show (a : Completion α) + 0 = a by rw [← coe_zero, ← coe_add, add_zero] add_assoc := fun a b c ↦ Completion.induction_on₃ a b c (isClosed_eq (continuous_map₂ (continuous_map₂ continuous_fst (continuous_fst.comp continuous_snd)) (continuous_snd.comp continuous_snd)) (continuous_map₂ continuous_fst (continuous_map₂ (continuous_fst.comp continuous_snd) (continuous_snd.comp continuous_snd)))) fun a b c ↦ show (a : Completion α) + b + c = a + (b + c) by repeat' rw_mod_cast [add_assoc] nsmul := (· • ·) nsmul_zero := fun a ↦ Completion.induction_on a (isClosed_eq continuous_map continuous_const) fun a ↦ show 0 • (a : Completion α) = 0 by rw [← coe_smul, ← coe_zero, zero_smul] nsmul_succ := fun n a ↦ Completion.induction_on a (isClosed_eq continuous_map <| continuous_map₂ continuous_map continuous_id) fun a ↦ show (n + 1) • (a : Completion α) = n • (a : Completion α) + (a : Completion α) by rw [← coe_smul, succ_nsmul, coe_add, coe_smul] } instance : SubNegMonoid (Completion α) := { (inferInstance : AddMonoid <| Completion α), (inferInstance : Neg <| Completion α), (inferInstance : Sub <| Completion α) with sub_eq_add_neg := fun a b ↦ Completion.induction_on₂ a b (isClosed_eq (continuous_map₂ continuous_fst continuous_snd) (continuous_map₂ continuous_fst (Completion.continuous_map.comp continuous_snd))) fun a b ↦ mod_cast congr_arg ((↑) : α → Completion α) (sub_eq_add_neg a b) zsmul := (· • ·) zsmul_zero' := fun a ↦ Completion.induction_on a (isClosed_eq continuous_map continuous_const) fun a ↦ show (0 : ℤ) • (a : Completion α) = 0 by rw [← coe_smul, ← coe_zero, zero_smul] zsmul_succ' := fun n a ↦ Completion.induction_on a (isClosed_eq continuous_map <| continuous_map₂ continuous_map continuous_id) fun a ↦ show (n.succ : ℤ) • (a : Completion α) = _ by rw [← coe_smul, show (n.succ : ℤ) • a = (n : ℤ) • a + a from SubNegMonoid.zsmul_succ' n a, coe_add, coe_smul] zsmul_neg' := fun n a ↦ Completion.induction_on a (isClosed_eq continuous_map <| Completion.continuous_map.comp continuous_map) fun a ↦ show (Int.negSucc n) • (a : Completion α) = _ by rw [← coe_smul, show (Int.negSucc n) • a = -((n.succ : ℤ) • a) from SubNegMonoid.zsmul_neg' n a, coe_neg, coe_smul] } instance addGroup : AddGroup (Completion α) := { (inferInstance : SubNegMonoid <| Completion α) with neg_add_cancel := fun a ↦ Completion.induction_on a (isClosed_eq (continuous_map₂ Completion.continuous_map continuous_id) continuous_const) fun a ↦ show -(a : Completion α) + a = 0 by rw_mod_cast [neg_add_cancel] rfl } instance isUniformAddGroup : IsUniformAddGroup (Completion α) := ⟨uniformContinuous_map₂ Sub.sub⟩ instance {M} [Monoid M] [DistribMulAction M α] [UniformContinuousConstSMul M α] : DistribMulAction M (Completion α) := { (inferInstance : MulAction M <| Completion α) with smul_add := fun r x y ↦ induction_on₂ x y (isClosed_eq ((continuous_fst.add continuous_snd).const_smul _) ((continuous_fst.const_smul _).add (continuous_snd.const_smul _))) fun a b ↦ by simp only [← coe_add, ← coe_smul, smul_add] smul_zero := fun r ↦ by rw [← coe_zero, ← coe_smul, smul_zero r] } /-- The map from a group to its completion as a group hom. -/ @[simps] def toCompl : α →+ Completion α where toFun := (↑) map_add' := coe_add map_zero' := coe_zero theorem continuous_toCompl : Continuous (toCompl : α → Completion α) := continuous_coe α variable (α) in theorem isDenseInducing_toCompl : IsDenseInducing (toCompl : α → Completion α) := isDenseInducing_coe end IsUniformAddGroup section UniformAddCommGroup variable [UniformSpace α] [AddCommGroup α] [IsUniformAddGroup α] instance instAddCommGroup : AddCommGroup (Completion α) := { (inferInstance : AddGroup <| Completion α) with add_comm := fun a b ↦ Completion.induction_on₂ a b (isClosed_eq (continuous_map₂ continuous_fst continuous_snd) (continuous_map₂ continuous_snd continuous_fst)) fun x y ↦ by change (x : Completion α) + ↑y = ↑y + ↑x rw [← coe_add, ← coe_add, add_comm] } instance instModule [Semiring R] [Module R α] [UniformContinuousConstSMul R α] : Module R (Completion α) := { (inferInstance : DistribMulAction R <| Completion α), (inferInstance : MulActionWithZero R <| Completion α) with add_smul := fun a b ↦ ext' (continuous_const_smul _) ((continuous_const_smul _).add (continuous_const_smul _)) fun x ↦ by rw [← coe_smul, add_smul, coe_add, coe_smul, coe_smul] } end UniformAddCommGroup end UniformSpace.Completion section AddMonoidHom variable [UniformSpace α] [AddGroup α] [IsUniformAddGroup α] [UniformSpace β] [AddGroup β] [IsUniformAddGroup β] open UniformSpace UniformSpace.Completion /-- Extension to the completion of a continuous group hom. -/ def AddMonoidHom.extension [CompleteSpace β] [T0Space β] (f : α →+ β) (hf : Continuous f) : Completion α →+ β := have hf : UniformContinuous f := uniformContinuous_addMonoidHom_of_continuous hf { toFun := Completion.extension f map_zero' := by rw [← coe_zero, extension_coe hf, f.map_zero] map_add' := fun a b ↦ Completion.induction_on₂ a b (isClosed_eq (continuous_extension.comp continuous_add) ((continuous_extension.comp continuous_fst).add (continuous_extension.comp continuous_snd))) fun a b ↦ show Completion.extension f _ = Completion.extension f _ + Completion.extension f _ by rw_mod_cast [extension_coe hf, extension_coe hf, extension_coe hf, f.map_add] } theorem AddMonoidHom.extension_coe [CompleteSpace β] [T0Space β] (f : α →+ β) (hf : Continuous f) (a : α) : f.extension hf a = f a := UniformSpace.Completion.extension_coe (uniformContinuous_addMonoidHom_of_continuous hf) a @[continuity] theorem AddMonoidHom.continuous_extension [CompleteSpace β] [T0Space β] (f : α →+ β) (hf : Continuous f) : Continuous (f.extension hf) := UniformSpace.Completion.continuous_extension /-- Completion of a continuous group hom, as a group hom. -/ def AddMonoidHom.completion (f : α →+ β) (hf : Continuous f) : Completion α →+ Completion β := (toCompl.comp f).extension (continuous_toCompl.comp hf) @[continuity] theorem AddMonoidHom.continuous_completion (f : α →+ β) (hf : Continuous f) : Continuous (AddMonoidHom.completion f hf : Completion α → Completion β) := continuous_map theorem AddMonoidHom.completion_coe (f : α →+ β) (hf : Continuous f) (a : α) : AddMonoidHom.completion f hf a = f a := map_coe (uniformContinuous_addMonoidHom_of_continuous hf) a theorem AddMonoidHom.completion_zero : AddMonoidHom.completion (0 : α →+ β) continuous_const = 0 := by ext x refine Completion.induction_on x ?_ ?_ · apply isClosed_eq (AddMonoidHom.continuous_completion (0 : α →+ β) continuous_const) exact continuous_const · simp [(0 : α →+ β).completion_coe continuous_const, coe_zero] theorem AddMonoidHom.completion_add {γ : Type*} [AddCommGroup γ] [UniformSpace γ] [IsUniformAddGroup γ] (f g : α →+ γ) (hf : Continuous f) (hg : Continuous g) : AddMonoidHom.completion (f + g) (hf.add hg) = AddMonoidHom.completion f hf + AddMonoidHom.completion g hg := by have hfg := hf.add hg ext x refine Completion.induction_on x ?_ ?_ · exact isClosed_eq ((f + g).continuous_completion hfg) ((f.continuous_completion hf).add (g.continuous_completion hg)) · simp [(f + g).completion_coe hfg, coe_add, f.completion_coe hf, g.completion_coe hg] end AddMonoidHom
.lake/packages/mathlib/Mathlib/Topology/Algebra/RestrictedProduct.lean
import Mathlib.Topology.Algebra.RestrictedProduct.Basic import Mathlib.Topology.Algebra.RestrictedProduct.TopologicalSpace deprecated_module (since := "2025-06-11")
.lake/packages/mathlib/Mathlib/Topology/Algebra/ClopenNhdofOne.lean
import Mathlib.GroupTheory.Index import Mathlib.Topology.Algebra.Group.ClosedSubgroup import Mathlib.Topology.Algebra.OpenSubgroup import Mathlib.Topology.Separation.Profinite import Mathlib.Topology.Separation.Connected /-! # Existence of an open normal subgroup in any clopen neighborhood of the neutral element This file proves the lemma `IsTopologicalGroup.exist_openNormalSubgroup_sub_clopen_nhds_of_one`, which states that in a compact topological group, for any clopen neighborhood of 1, there exists an open normal subgroup contained within it. This file is split out from the file `OpenSubgroup` because it needs more imports. -/ namespace IsTopologicalGroup theorem exist_openNormalSubgroup_sub_clopen_nhds_of_one {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] [CompactSpace G] {W : Set G} (WClopen : IsClopen W) (einW : 1 ∈ W) : ∃ H : OpenNormalSubgroup G, (H : Set G) ⊆ W := by rcases exist_openSubgroup_sub_clopen_nhds_of_one WClopen einW with ⟨H, hH⟩ have : Subgroup.FiniteIndex H.toSubgroup := H.finiteIndex_of_finite_quotient use { toSubgroup := Subgroup.normalCore H isOpen' := Subgroup.isOpen_of_isClosed_of_finiteIndex _ (H.normalCore_isClosed H.isClosed) } exact fun _ b ↦ hH (H.normalCore_le b) @[deprecated (since := "2025-05-22")] alias exist_openNormalSubgroup_sub_clopen_nhd_of_one := exist_openNormalSubgroup_sub_clopen_nhds_of_one end IsTopologicalGroup namespace ProfiniteGrp theorem exist_openNormalSubgroup_sub_open_nhds_of_one {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] [CompactSpace G] [TotallyDisconnectedSpace G] {U : Set G} (UOpen : IsOpen U) (einU : 1 ∈ U) : ∃ H : OpenNormalSubgroup G, (H : Set G) ⊆ U := by rcases ((Filter.HasBasis.mem_iff' ((nhds_basis_clopen (1 : G))) U).mp <| mem_nhds_iff.mpr (by use U)) with ⟨W, hW, h⟩ rcases IsTopologicalGroup.exist_openNormalSubgroup_sub_clopen_nhds_of_one hW.2 hW.1 with ⟨H, hH⟩ exact ⟨H, fun _ a ↦ h (hH a)⟩ @[deprecated (since := "2025-05-22")] alias exist_openNormalSubgroup_sub_open_nhd_of_one := exist_openNormalSubgroup_sub_open_nhds_of_one end ProfiniteGrp
.lake/packages/mathlib/Mathlib/Topology/Algebra/Monoid.lean
import Mathlib.Algebra.BigOperators.Finprod import Mathlib.Algebra.BigOperators.Pi import Mathlib.Algebra.Group.Submonoid.Basic import Mathlib.Algebra.Group.ULift import Mathlib.Order.Filter.Pointwise import Mathlib.Topology.Algebra.MulAction import Mathlib.Topology.ContinuousMap.Defs import Mathlib.Topology.Algebra.Monoid.Defs /-! # Theory of topological monoids In this file we define mixin classes `ContinuousMul` and `ContinuousAdd`. While in many applications the underlying type is a monoid (multiplicative or additive), we do not require this in the definitions. -/ universe u v open Set Filter TopologicalSpace Topology open scoped Topology Pointwise variable {ι α M N X : Type*} [TopologicalSpace X] @[to_additive (attr := continuity, fun_prop)] theorem continuous_one [TopologicalSpace M] [One M] : Continuous (1 : X → M) := @continuous_const _ _ _ _ 1 section ContinuousMul variable [TopologicalSpace M] [Mul M] [ContinuousMul M] @[to_additive] instance : ContinuousMul Mᵒᵈ := ‹ContinuousMul M› @[to_additive] instance : ContinuousMul (ULift.{u} M) := by constructor apply continuous_uliftUp.comp exact continuous_mul.comp₂ (continuous_uliftDown.comp continuous_fst) (continuous_uliftDown.comp continuous_snd) @[to_additive] instance ContinuousMul.to_continuousSMul : ContinuousSMul M M := ⟨continuous_mul⟩ @[to_additive] instance ContinuousMul.to_continuousSMul_op : ContinuousSMul Mᵐᵒᵖ M := ⟨show Continuous ((fun p : M × M => p.1 * p.2) ∘ Prod.swap ∘ Prod.map MulOpposite.unop id) from continuous_mul.comp <| continuous_swap.comp <| Continuous.prodMap MulOpposite.continuous_unop continuous_id⟩ @[to_additive] theorem ContinuousMul.induced {α : Type*} {β : Type*} {F : Type*} [FunLike F α β] [Mul α] [Mul β] [MulHomClass F α β] [tβ : TopologicalSpace β] [ContinuousMul β] (f : F) : @ContinuousMul α (tβ.induced f) _ := by let tα := tβ.induced f refine ⟨continuous_induced_rng.2 ?_⟩ simp only [Function.comp_def, map_mul] fun_prop @[to_additive (attr := continuity)] theorem continuous_mul_left (a : M) : Continuous fun b : M => a * b := continuous_const.mul continuous_id @[to_additive (attr := continuity)] theorem continuous_mul_right (a : M) : Continuous fun b : M => b * a := continuous_id.mul continuous_const @[to_additive] theorem tendsto_mul {a b : M} : Tendsto (fun p : M × M => p.fst * p.snd) (𝓝 (a, b)) (𝓝 (a * b)) := continuous_iff_continuousAt.mp ContinuousMul.continuous_mul (a, b) @[to_additive] theorem Filter.Tendsto.const_mul (b : M) {c : M} {f : α → M} {l : Filter α} (h : Tendsto (fun k : α => f k) l (𝓝 c)) : Tendsto (fun k : α => b * f k) l (𝓝 (b * c)) := tendsto_const_nhds.mul h @[to_additive] theorem Filter.Tendsto.mul_const (b : M) {c : M} {f : α → M} {l : Filter α} (h : Tendsto (fun k : α => f k) l (𝓝 c)) : Tendsto (fun k : α => f k * b) l (𝓝 (c * b)) := h.mul tendsto_const_nhds @[to_additive] theorem le_nhds_mul (a b : M) : 𝓝 a * 𝓝 b ≤ 𝓝 (a * b) := by rw [← map₂_mul, ← map_uncurry_prod, ← nhds_prod_eq] exact continuous_mul.tendsto _ @[to_additive (attr := simp)] theorem nhds_one_mul_nhds {M} [MulOneClass M] [TopologicalSpace M] [ContinuousMul M] (a : M) : 𝓝 (1 : M) * 𝓝 a = 𝓝 a := ((le_nhds_mul _ _).trans_eq <| congr_arg _ (one_mul a)).antisymm <| le_mul_of_one_le_left' <| pure_le_nhds 1 @[to_additive (attr := simp)] theorem nhds_mul_nhds_one {M} [MulOneClass M] [TopologicalSpace M] [ContinuousMul M] (a : M) : 𝓝 a * 𝓝 1 = 𝓝 a := ((le_nhds_mul _ _).trans_eq <| congr_arg _ (mul_one a)).antisymm <| le_mul_of_one_le_right' <| pure_le_nhds 1 section tendsto_nhds variable {𝕜 : Type*} [Preorder 𝕜] [Zero 𝕜] [Mul 𝕜] [TopologicalSpace 𝕜] [ContinuousMul 𝕜] {l : Filter α} {f : α → 𝕜} {b c : 𝕜} (hb : 0 < b) include hb theorem Filter.TendstoNhdsWithinIoi.const_mul [PosMulStrictMono 𝕜] (h : Tendsto f l (𝓝[>] c)) : Tendsto (fun a => b * f a) l (𝓝[>] (b * c)) := tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ ((tendsto_nhds_of_tendsto_nhdsWithin h).const_mul b) <| (tendsto_nhdsWithin_iff.mp h).2.mono fun _ _ => by rw [Set.mem_Ioi] at *; gcongr; assumption theorem Filter.TendstoNhdsWithinIio.const_mul [PosMulStrictMono 𝕜] (h : Tendsto f l (𝓝[<] c)) : Tendsto (fun a => b * f a) l (𝓝[<] (b * c)) := tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ ((tendsto_nhds_of_tendsto_nhdsWithin h).const_mul b) <| (tendsto_nhdsWithin_iff.mp h).2.mono fun _ _ => by rw [Set.mem_Iio] at *; gcongr; assumption theorem Filter.TendstoNhdsWithinIoi.mul_const [MulPosStrictMono 𝕜] (h : Tendsto f l (𝓝[>] c)) : Tendsto (fun a => f a * b) l (𝓝[>] (c * b)) := tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ ((tendsto_nhds_of_tendsto_nhdsWithin h).mul_const b) <| (tendsto_nhdsWithin_iff.mp h).2.mono fun _ _ => by rw [Set.mem_Ioi] at *; gcongr; assumption theorem Filter.TendstoNhdsWithinIio.mul_const [MulPosStrictMono 𝕜] (h : Tendsto f l (𝓝[<] c)) : Tendsto (fun a => f a * b) l (𝓝[<] (c * b)) := tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ ((tendsto_nhds_of_tendsto_nhdsWithin h).mul_const b) <| (tendsto_nhdsWithin_iff.mp h).2.mono fun _ _ => by rw [Set.mem_Iio] at *; gcongr; assumption end tendsto_nhds @[to_additive] protected theorem Specializes.mul {a b c d : M} (hab : a ⤳ b) (hcd : c ⤳ d) : (a * c) ⤳ (b * d) := hab.smul hcd @[to_additive] protected theorem Inseparable.mul {a b c d : M} (hab : Inseparable a b) (hcd : Inseparable c d) : Inseparable (a * c) (b * d) := hab.smul hcd @[to_additive] protected theorem Specializes.pow {M : Type*} [Monoid M] [TopologicalSpace M] [ContinuousMul M] {a b : M} (h : a ⤳ b) (n : ℕ) : (a ^ n) ⤳ (b ^ n) := Nat.recOn n (by simp only [pow_zero, specializes_rfl]) fun _ ihn ↦ by simpa only [pow_succ] using ihn.mul h @[to_additive] protected theorem Inseparable.pow {M : Type*} [Monoid M] [TopologicalSpace M] [ContinuousMul M] {a b : M} (h : Inseparable a b) (n : ℕ) : Inseparable (a ^ n) (b ^ n) := (h.specializes.pow n).antisymm (h.specializes'.pow n) /-- Construct a unit from limits of units and their inverses. -/ @[to_additive (attr := simps) /-- Construct an additive unit from limits of additive units and their negatives. -/] def Filter.Tendsto.units [TopologicalSpace N] [Monoid N] [ContinuousMul N] [T2Space N] {f : ι → Nˣ} {r₁ r₂ : N} {l : Filter ι} [l.NeBot] (h₁ : Tendsto (fun x => ↑(f x)) l (𝓝 r₁)) (h₂ : Tendsto (fun x => ↑(f x)⁻¹) l (𝓝 r₂)) : Nˣ where val := r₁ inv := r₂ val_inv := by symm simpa using h₁.mul h₂ inv_val := by symm simpa using h₂.mul h₁ @[to_additive] instance Prod.continuousMul [TopologicalSpace N] [Mul N] [ContinuousMul N] : ContinuousMul (M × N) := ⟨by apply Continuous.prodMk <;> fun_prop⟩ @[to_additive] instance Pi.continuousMul {C : ι → Type*} [∀ i, TopologicalSpace (C i)] [∀ i, Mul (C i)] [∀ i, ContinuousMul (C i)] : ContinuousMul (∀ i, C i) where continuous_mul := continuous_pi fun i => (continuous_apply i).fst'.mul (continuous_apply i).snd' /-- A version of `Pi.continuousMul` for non-dependent functions. It is needed because sometimes Lean 3 fails to use `Pi.continuousMul` for non-dependent functions. -/ @[to_additive /-- A version of `Pi.continuousAdd` for non-dependent functions. It is needed because sometimes Lean fails to use `Pi.continuousAdd` for non-dependent functions. -/] instance Pi.continuousMul' : ContinuousMul (ι → M) := Pi.continuousMul @[to_additive] instance (priority := 100) continuousMul_of_discreteTopology [TopologicalSpace N] [Mul N] [DiscreteTopology N] : ContinuousMul N := ⟨continuous_of_discreteTopology⟩ open Filter open Function @[to_additive] theorem ContinuousMul.of_nhds_one {M : Type u} [Monoid M] [TopologicalSpace M] (hmul : Tendsto (uncurry ((· * ·) : M → M → M)) (𝓝 1 ×ˢ 𝓝 1) <| 𝓝 1) (hleft : ∀ x₀ : M, 𝓝 x₀ = map (fun x => x₀ * x) (𝓝 1)) (hright : ∀ x₀ : M, 𝓝 x₀ = map (fun x => x * x₀) (𝓝 1)) : ContinuousMul M := ⟨by rw [continuous_iff_continuousAt] rintro ⟨x₀, y₀⟩ have key : (fun p : M × M => x₀ * p.1 * (p.2 * y₀)) = ((fun x => x₀ * x) ∘ fun x => x * y₀) ∘ uncurry (· * ·) := by ext p simp [uncurry, mul_assoc] have key₂ : ((fun x => x₀ * x) ∘ fun x => y₀ * x) = fun x => x₀ * y₀ * x := by ext x simp [mul_assoc] calc map (uncurry (· * ·)) (𝓝 (x₀, y₀)) = map (uncurry (· * ·)) (𝓝 x₀ ×ˢ 𝓝 y₀) := by rw [nhds_prod_eq] _ = map (fun p : M × M => x₀ * p.1 * (p.2 * y₀)) (𝓝 1 ×ˢ 𝓝 1) := by unfold uncurry rw [hleft x₀, hright y₀, prod_map_map_eq, Filter.map_map, Function.comp_def] _ = map ((fun x => x₀ * x) ∘ fun x => x * y₀) (map (uncurry (· * ·)) (𝓝 1 ×ˢ 𝓝 1)) := by rw [key, ← Filter.map_map] _ ≤ map ((fun x : M => x₀ * x) ∘ fun x => x * y₀) (𝓝 1) := map_mono hmul _ = 𝓝 (x₀ * y₀) := by rw [← Filter.map_map, ← hright, hleft y₀, Filter.map_map, key₂, ← hleft]⟩ @[to_additive] theorem continuousMul_of_comm_of_nhds_one (M : Type u) [CommMonoid M] [TopologicalSpace M] (hmul : Tendsto (uncurry ((· * ·) : M → M → M)) (𝓝 1 ×ˢ 𝓝 1) (𝓝 1)) (hleft : ∀ x₀ : M, 𝓝 x₀ = map (fun x => x₀ * x) (𝓝 1)) : ContinuousMul M := by apply ContinuousMul.of_nhds_one hmul hleft intro x₀ simp_rw [mul_comm, hleft x₀] end ContinuousMul section PointwiseLimits variable (M₁ M₂ : Type*) [TopologicalSpace M₂] [T2Space M₂] @[to_additive] theorem isClosed_setOf_map_one [One M₁] [One M₂] : IsClosed { f : M₁ → M₂ | f 1 = 1 } := isClosed_eq (continuous_apply 1) continuous_const @[to_additive] theorem isClosed_setOf_map_mul [Mul M₁] [Mul M₂] [ContinuousMul M₂] : IsClosed { f : M₁ → M₂ | ∀ x y, f (x * y) = f x * f y } := by simp only [setOf_forall] exact isClosed_iInter fun x ↦ isClosed_iInter fun y ↦ isClosed_eq (continuous_apply _) (by fun_prop) section Semigroup variable {M₁ M₂} [Mul M₁] [Mul M₂] [ContinuousMul M₂] {F : Type*} [FunLike F M₁ M₂] [MulHomClass F M₁ M₂] {l : Filter α} /-- Construct a bundled semigroup homomorphism `M₁ →ₙ* M₂` from a function `f` and a proof that it belongs to the closure of the range of the coercion from `M₁ →ₙ* M₂` (or another type of bundled homomorphisms that has a `MulHomClass` instance) to `M₁ → M₂`. -/ @[to_additive (attr := simps -fullyApplied) /-- Construct a bundled additive semigroup homomorphism `M₁ →ₙ+ M₂` from a function `f` and a proof that it belongs to the closure of the range of the coercion from `M₁ →ₙ+ M₂` (or another type of bundled homomorphisms that has an `AddHomClass` instance) to `M₁ → M₂`. -/] def mulHomOfMemClosureRangeCoe (f : M₁ → M₂) (hf : f ∈ closure (range fun (f : F) (x : M₁) => f x)) : M₁ →ₙ* M₂ where toFun := f map_mul' := (isClosed_setOf_map_mul M₁ M₂).closure_subset_iff.2 (range_subset_iff.2 map_mul) hf /-- Construct a bundled semigroup homomorphism from a pointwise limit of semigroup homomorphisms. -/ @[to_additive (attr := simps! -fullyApplied) /-- Construct a bundled additive semigroup homomorphism from a pointwise limit of additive semigroup homomorphisms -/] def mulHomOfTendsto (f : M₁ → M₂) (g : α → F) [l.NeBot] (h : Tendsto (fun a x => g a x) l (𝓝 f)) : M₁ →ₙ* M₂ := mulHomOfMemClosureRangeCoe f <| mem_closure_of_tendsto h <| Eventually.of_forall fun _ => mem_range_self _ variable (M₁ M₂) @[to_additive] theorem MulHom.isClosed_range_coe : IsClosed (Set.range ((↑) : (M₁ →ₙ* M₂) → M₁ → M₂)) := isClosed_of_closure_subset fun f hf => ⟨mulHomOfMemClosureRangeCoe f hf, rfl⟩ end Semigroup section Monoid variable {M₁ M₂} [MulOneClass M₁] [MulOneClass M₂] [ContinuousMul M₂] {F : Type*} [FunLike F M₁ M₂] [MonoidHomClass F M₁ M₂] {l : Filter α} /-- Construct a bundled monoid homomorphism `M₁ →* M₂` from a function `f` and a proof that it belongs to the closure of the range of the coercion from `M₁ →* M₂` (or another type of bundled homomorphisms that has a `MonoidHomClass` instance) to `M₁ → M₂`. -/ @[to_additive (attr := simps -fullyApplied) /-- Construct a bundled additive monoid homomorphism `M₁ →+ M₂` from a function `f` and a proof that it belongs to the closure of the range of the coercion from `M₁ →+ M₂` (or another type of bundled homomorphisms that has an `AddMonoidHomClass` instance) to `M₁ → M₂`. -/] def monoidHomOfMemClosureRangeCoe (f : M₁ → M₂) (hf : f ∈ closure (range fun (f : F) (x : M₁) => f x)) : M₁ →* M₂ where toFun := f map_one' := (isClosed_setOf_map_one M₁ M₂).closure_subset_iff.2 (range_subset_iff.2 map_one) hf map_mul' := (isClosed_setOf_map_mul M₁ M₂).closure_subset_iff.2 (range_subset_iff.2 map_mul) hf /-- Construct a bundled monoid homomorphism from a pointwise limit of monoid homomorphisms. -/ @[to_additive (attr := simps! -fullyApplied) /-- Construct a bundled additive monoid homomorphism from a pointwise limit of additive monoid homomorphisms -/] def monoidHomOfTendsto (f : M₁ → M₂) (g : α → F) [l.NeBot] (h : Tendsto (fun a x => g a x) l (𝓝 f)) : M₁ →* M₂ := monoidHomOfMemClosureRangeCoe f <| mem_closure_of_tendsto h <| Eventually.of_forall fun _ => mem_range_self _ variable (M₁ M₂) @[to_additive] theorem MonoidHom.isClosed_range_coe : IsClosed (Set.range ((↑) : (M₁ →* M₂) → M₁ → M₂)) := isClosed_of_closure_subset fun f hf => ⟨monoidHomOfMemClosureRangeCoe f hf, rfl⟩ end Monoid end PointwiseLimits @[to_additive] theorem Topology.IsInducing.continuousMul {M N F : Type*} [Mul M] [Mul N] [FunLike F M N] [MulHomClass F M N] [TopologicalSpace M] [TopologicalSpace N] [ContinuousMul N] (f : F) (hf : IsInducing f) : ContinuousMul M := ⟨(hf.continuousSMul hf.continuous (map_mul f _ _)).1⟩ @[to_additive] theorem continuousMul_induced {M N F : Type*} [Mul M] [Mul N] [FunLike F M N] [MulHomClass F M N] [TopologicalSpace N] [ContinuousMul N] (f : F) : @ContinuousMul M (induced f ‹_›) _ := letI := induced f ‹_› IsInducing.continuousMul f ⟨rfl⟩ @[to_additive] instance Subsemigroup.continuousMul [TopologicalSpace M] [Semigroup M] [ContinuousMul M] (S : Subsemigroup M) : ContinuousMul S := IsInducing.continuousMul ({ toFun := (↑), map_mul' := fun _ _ => rfl} : MulHom S M) ⟨rfl⟩ @[to_additive] instance Submonoid.continuousMul [TopologicalSpace M] [Monoid M] [ContinuousMul M] (S : Submonoid M) : ContinuousMul S := S.toSubsemigroup.continuousMul section MulZeroClass open Filter variable {α β : Type*} variable [TopologicalSpace M] [MulZeroClass M] [ContinuousMul M] theorem exists_mem_nhds_zero_mul_subset {K U : Set M} (hK : IsCompact K) (hU : U ∈ 𝓝 0) : ∃ V ∈ 𝓝 0, K * V ⊆ U := by refine hK.induction_on ?_ ?_ ?_ ?_ · exact ⟨univ, by simp⟩ · rintro s t hst ⟨V, hV, hV'⟩ exact ⟨V, hV, (mul_subset_mul_right hst).trans hV'⟩ · rintro s t ⟨V, V_in, hV'⟩ ⟨W, W_in, hW'⟩ use V ∩ W, inter_mem V_in W_in rw [union_mul] exact union_subset ((mul_subset_mul_left V.inter_subset_left).trans hV') ((mul_subset_mul_left V.inter_subset_right).trans hW') · intro x hx have := tendsto_mul (show U ∈ 𝓝 (x * 0) by simpa using hU) rw [nhds_prod_eq, mem_map, mem_prod_iff] at this rcases this with ⟨t, ht, s, hs, h⟩ rw [← image_subset_iff, image_mul_prod] at h exact ⟨t, mem_nhdsWithin_of_mem_nhds ht, s, hs, h⟩ /-- Let `M` be a topological space with a continuous multiplication operation and a `0`. Let `l` be a filter on `M` which is disjoint from the cocompact filter. Then, the multiplication map `M × M → M` tends to zero on the filter product `𝓝 0 ×ˢ l`. -/ theorem tendsto_mul_nhds_zero_prod_of_disjoint_cocompact {l : Filter M} (hl : Disjoint l (cocompact M)) : Tendsto (fun x : M × M ↦ x.1 * x.2) (𝓝 0 ×ˢ l) (𝓝 0) := calc map (fun x : M × M ↦ x.1 * x.2) (𝓝 0 ×ˢ l) _ ≤ map (fun x : M × M ↦ x.1 * x.2) (𝓝ˢ ({0} ×ˢ Set.univ)) := map_mono <| nhds_prod_le_of_disjoint_cocompact 0 hl _ ≤ 𝓝 0 := continuous_mul.tendsto_nhdsSet_nhds fun _ ⟨hx, _⟩ ↦ mul_eq_zero_of_left hx _ /-- Let `M` be a topological space with a continuous multiplication operation and a `0`. Let `l` be a filter on `M` which is disjoint from the cocompact filter. Then, the multiplication map `M × M → M` tends to zero on the filter product `l ×ˢ 𝓝 0`. -/ theorem tendsto_mul_prod_nhds_zero_of_disjoint_cocompact {l : Filter M} (hl : Disjoint l (cocompact M)) : Tendsto (fun x : M × M ↦ x.1 * x.2) (l ×ˢ 𝓝 0) (𝓝 0) := calc map (fun x : M × M ↦ x.1 * x.2) (l ×ˢ 𝓝 0) _ ≤ map (fun x : M × M ↦ x.1 * x.2) (𝓝ˢ (Set.univ ×ˢ {0})) := map_mono <| prod_nhds_le_of_disjoint_cocompact 0 hl _ ≤ 𝓝 0 := continuous_mul.tendsto_nhdsSet_nhds fun _ ⟨_, hx⟩ ↦ mul_eq_zero_of_right _ hx /-- Let `M` be a topological space with a continuous multiplication operation and a `0`. Let `l` be a filter on `M × M` which is disjoint from the cocompact filter. Then, the multiplication map `M × M → M` tends to zero on `(𝓝 0).coprod (𝓝 0) ⊓ l`. -/ theorem tendsto_mul_coprod_nhds_zero_inf_of_disjoint_cocompact {l : Filter (M × M)} (hl : Disjoint l (cocompact (M × M))) : Tendsto (fun x : M × M ↦ x.1 * x.2) ((𝓝 0).coprod (𝓝 0) ⊓ l) (𝓝 0) := by have := calc (𝓝 0).coprod (𝓝 0) ⊓ l _ ≤ (𝓝 0).coprod (𝓝 0) ⊓ map Prod.fst l ×ˢ map Prod.snd l := inf_le_inf_left _ le_prod_map_fst_snd _ ≤ 𝓝 0 ×ˢ map Prod.snd l ⊔ map Prod.fst l ×ˢ 𝓝 0 := coprod_inf_prod_le _ _ _ _ apply (Tendsto.sup _ _).mono_left this · apply tendsto_mul_nhds_zero_prod_of_disjoint_cocompact exact disjoint_map_cocompact continuous_snd hl · apply tendsto_mul_prod_nhds_zero_of_disjoint_cocompact exact disjoint_map_cocompact continuous_fst hl /-- Let `M` be a topological space with a continuous multiplication operation and a `0`. Let `l` be a filter on `M × M` which is both disjoint from the cocompact filter and less than or equal to `(𝓝 0).coprod (𝓝 0)`. Then the multiplication map `M × M → M` tends to zero on `l`. -/ theorem tendsto_mul_nhds_zero_of_disjoint_cocompact {l : Filter (M × M)} (hl : Disjoint l (cocompact (M × M))) (h'l : l ≤ (𝓝 0).coprod (𝓝 0)) : Tendsto (fun x : M × M ↦ x.1 * x.2) l (𝓝 0) := by simpa [inf_eq_right.mpr h'l] using tendsto_mul_coprod_nhds_zero_inf_of_disjoint_cocompact hl /-- Let `M` be a topological space with a continuous multiplication operation and a `0`. Let `f : α → M` and `g : α → M` be functions. If `f` tends to zero on a filter `l` and the image of `l` under `g` is disjoint from the cocompact filter on `M`, then `fun x : α ↦ f x * g x` also tends to zero on `l`. -/ theorem Tendsto.tendsto_mul_zero_of_disjoint_cocompact_right {f g : α → M} {l : Filter α} (hf : Tendsto f l (𝓝 0)) (hg : Disjoint (map g l) (cocompact M)) : Tendsto (fun x ↦ f x * g x) l (𝓝 0) := tendsto_mul_nhds_zero_prod_of_disjoint_cocompact hg |>.comp (hf.prodMk tendsto_map) /-- Let `M` be a topological space with a continuous multiplication operation and a `0`. Let `f : α → M` and `g : α → M` be functions. If `g` tends to zero on a filter `l` and the image of `l` under `f` is disjoint from the cocompact filter on `M`, then `fun x : α ↦ f x * g x` also tends to zero on `l`. -/ theorem Tendsto.tendsto_mul_zero_of_disjoint_cocompact_left {f g : α → M} {l : Filter α} (hf : Disjoint (map f l) (cocompact M)) (hg : Tendsto g l (𝓝 0)) : Tendsto (fun x ↦ f x * g x) l (𝓝 0) := tendsto_mul_prod_nhds_zero_of_disjoint_cocompact hf |>.comp (tendsto_map.prodMk hg) /-- If `f : α → M` and `g : β → M` are continuous and both tend to zero on the cocompact filter, then `fun i : α × β ↦ f i.1 * g i.2` also tends to zero on the cocompact filter. -/ theorem tendsto_mul_cocompact_nhds_zero [TopologicalSpace α] [TopologicalSpace β] {f : α → M} {g : β → M} (f_cont : Continuous f) (g_cont : Continuous g) (hf : Tendsto f (cocompact α) (𝓝 0)) (hg : Tendsto g (cocompact β) (𝓝 0)) : Tendsto (fun i : α × β ↦ f i.1 * g i.2) (cocompact (α × β)) (𝓝 0) := by set l : Filter (M × M) := map (Prod.map f g) (cocompact (α × β)) with l_def set K : Set (M × M) := (insert 0 (range f)) ×ˢ (insert 0 (range g)) have K_compact : IsCompact K := .prod (hf.isCompact_insert_range_of_cocompact f_cont) (hg.isCompact_insert_range_of_cocompact g_cont) have K_mem_l : K ∈ l := eventually_map.mpr <| .of_forall fun ⟨x, y⟩ ↦ ⟨mem_insert_of_mem _ (mem_range_self _), mem_insert_of_mem _ (mem_range_self _)⟩ have l_compact : Disjoint l (cocompact (M × M)) := by rw [disjoint_cocompact_right] exact ⟨K, K_mem_l, K_compact⟩ have l_le_coprod : l ≤ (𝓝 0).coprod (𝓝 0) := by rw [l_def, ← coprod_cocompact] exact hf.prodMap_coprod hg exact tendsto_mul_nhds_zero_of_disjoint_cocompact l_compact l_le_coprod |>.comp tendsto_map /-- If `f : α → M` and `g : β → M` both tend to zero on the cofinite filter, then so does `fun i : α × β ↦ f i.1 * g i.2`. -/ theorem tendsto_mul_cofinite_nhds_zero {f : α → M} {g : β → M} (hf : Tendsto f cofinite (𝓝 0)) (hg : Tendsto g cofinite (𝓝 0)) : Tendsto (fun i : α × β ↦ f i.1 * g i.2) cofinite (𝓝 0) := by letI : TopologicalSpace α := ⊥ haveI : DiscreteTopology α := discreteTopology_bot α letI : TopologicalSpace β := ⊥ haveI : DiscreteTopology β := discreteTopology_bot β rw [← cocompact_eq_cofinite] at * exact tendsto_mul_cocompact_nhds_zero continuous_of_discreteTopology continuous_of_discreteTopology hf hg end MulZeroClass section GroupWithZero lemma GroupWithZero.isOpen_singleton_zero [GroupWithZero M] [TopologicalSpace M] [ContinuousMul M] [CompactSpace M] [T1Space M] : IsOpen {(0 : M)} := by obtain ⟨U, hU, h0U, h1U⟩ := t1Space_iff_exists_open.mp ‹_› zero_ne_one obtain ⟨W, hW, hW'⟩ := exists_mem_nhds_zero_mul_subset isCompact_univ (hU.mem_nhds h0U) by_cases H : ∃ x ≠ 0, x ∈ W · obtain ⟨x, hx, hxW⟩ := H cases h1U (hW' (by simpa [hx] using Set.mul_mem_mul (Set.mem_univ x⁻¹) hxW)) · obtain rfl : W = {0} := subset_antisymm (by simpa [not_imp_not] using H) (by simpa using mem_of_mem_nhds hW) simpa [isOpen_iff_mem_nhds] end GroupWithZero section MulOneClass variable [TopologicalSpace M] [MulOneClass M] [ContinuousMul M] @[to_additive exists_open_nhds_zero_half] theorem exists_open_nhds_one_split {s : Set M} (hs : s ∈ 𝓝 (1 : M)) : ∃ V : Set M, IsOpen V ∧ (1 : M) ∈ V ∧ ∀ v ∈ V, ∀ w ∈ V, v * w ∈ s := by have : (fun a : M × M => a.1 * a.2) ⁻¹' s ∈ 𝓝 ((1, 1) : M × M) := tendsto_mul (by simpa only [one_mul] using hs) simpa only [prod_subset_iff] using exists_nhds_square this @[to_additive exists_nhds_zero_half] theorem exists_nhds_one_split {s : Set M} (hs : s ∈ 𝓝 (1 : M)) : ∃ V ∈ 𝓝 (1 : M), ∀ v ∈ V, ∀ w ∈ V, v * w ∈ s := let ⟨V, Vo, V1, hV⟩ := exists_open_nhds_one_split hs ⟨V, IsOpen.mem_nhds Vo V1, hV⟩ /-- Given a neighborhood `U` of `1` there is an open neighborhood `V` of `1` such that `V * V ⊆ U`. -/ @[to_additive /-- Given an open neighborhood `U` of `0` there is an open neighborhood `V` of `0` such that `V + V ⊆ U`. -/] theorem exists_open_nhds_one_mul_subset {U : Set M} (hU : U ∈ 𝓝 (1 : M)) : ∃ V : Set M, IsOpen V ∧ (1 : M) ∈ V ∧ V * V ⊆ U := by simpa only [mul_subset_iff] using exists_open_nhds_one_split hU @[to_additive] theorem Filter.HasBasis.mul_self {p : ι → Prop} {s : ι → Set M} (h : (𝓝 1).HasBasis p s) : (𝓝 1).HasBasis p fun i => s i * s i := by rw [← nhds_mul_nhds_one, ← map₂_mul, ← map_uncurry_prod] simpa only [← image_mul_prod] using h.prod_self.map _ end MulOneClass section ContinuousMul section Semigroup variable [TopologicalSpace M] [Semigroup M] [ContinuousMul M] @[to_additive] theorem Subsemigroup.top_closure_mul_self_subset (s : Subsemigroup M) : _root_.closure (s : Set M) * _root_.closure s ⊆ _root_.closure s := image2_subset_iff.2 fun _ hx _ hy => map_mem_closure₂ continuous_mul hx hy fun _ ha _ hb => s.mul_mem ha hb /-- The (topological-space) closure of a subsemigroup of a space `M` with `ContinuousMul` is itself a subsemigroup. -/ @[to_additive /-- The (topological-space) closure of an additive submonoid of a space `M` with `ContinuousAdd` is itself an additive submonoid. -/] def Subsemigroup.topologicalClosure (s : Subsemigroup M) : Subsemigroup M where carrier := _root_.closure (s : Set M) mul_mem' ha hb := s.top_closure_mul_self_subset ⟨_, ha, _, hb, rfl⟩ @[to_additive] theorem Subsemigroup.coe_topologicalClosure (s : Subsemigroup M) : (s.topologicalClosure : Set M) = _root_.closure (s : Set M) := rfl @[to_additive] theorem Subsemigroup.le_topologicalClosure (s : Subsemigroup M) : s ≤ s.topologicalClosure := _root_.subset_closure @[to_additive] theorem Subsemigroup.isClosed_topologicalClosure (s : Subsemigroup M) : IsClosed (s.topologicalClosure : Set M) := isClosed_closure @[to_additive] theorem Subsemigroup.topologicalClosure_minimal (s : Subsemigroup M) {t : Subsemigroup M} (h : s ≤ t) (ht : IsClosed (t : Set M)) : s.topologicalClosure ≤ t := closure_minimal h ht /-- If a subsemigroup of a topological semigroup is commutative, then so is its topological closure. See note [reducible non-instances] -/ @[to_additive /-- If a submonoid of an additive topological monoid is commutative, then so is its topological closure. See note [reducible non-instances] -/] abbrev Subsemigroup.commSemigroupTopologicalClosure [T2Space M] (s : Subsemigroup M) (hs : ∀ x y : s, x * y = y * x) : CommSemigroup s.topologicalClosure := { MulMemClass.toSemigroup s.topologicalClosure with mul_comm := have : ∀ x ∈ s, ∀ y ∈ s, x * y = y * x := fun x hx y hy => congr_arg Subtype.val (hs ⟨x, hx⟩ ⟨y, hy⟩) fun ⟨x, hx⟩ ⟨y, hy⟩ => Subtype.ext <| eqOn_closure₂ this continuous_mul (continuous_snd.mul continuous_fst) x hx y hy } @[to_additive] theorem IsCompact.mul {s t : Set M} (hs : IsCompact s) (ht : IsCompact t) : IsCompact (s * t) := by rw [← image_mul_prod] exact (hs.prod ht).image continuous_mul end Semigroup variable [TopologicalSpace M] [Monoid M] [ContinuousMul M] @[to_additive] theorem Submonoid.top_closure_mul_self_subset (s : Submonoid M) : _root_.closure (s : Set M) * _root_.closure s ⊆ _root_.closure s := image2_subset_iff.2 fun _ hx _ hy => map_mem_closure₂ continuous_mul hx hy fun _ ha _ hb => s.mul_mem ha hb @[to_additive] theorem Submonoid.top_closure_mul_self_eq (s : Submonoid M) : _root_.closure (s : Set M) * _root_.closure s = _root_.closure s := Subset.antisymm s.top_closure_mul_self_subset fun x hx => ⟨x, hx, 1, _root_.subset_closure s.one_mem, mul_one _⟩ /-- The (topological-space) closure of a submonoid of a space `M` with `ContinuousMul` is itself a submonoid. -/ @[to_additive /-- The (topological-space) closure of an additive submonoid of a space `M` with `ContinuousAdd` is itself an additive submonoid. -/] def Submonoid.topologicalClosure (s : Submonoid M) : Submonoid M where carrier := _root_.closure (s : Set M) one_mem' := _root_.subset_closure s.one_mem mul_mem' ha hb := s.top_closure_mul_self_subset ⟨_, ha, _, hb, rfl⟩ @[to_additive] theorem Submonoid.coe_topologicalClosure (s : Submonoid M) : (s.topologicalClosure : Set M) = _root_.closure (s : Set M) := rfl @[to_additive] theorem Submonoid.le_topologicalClosure (s : Submonoid M) : s ≤ s.topologicalClosure := _root_.subset_closure @[to_additive] theorem Submonoid.isClosed_topologicalClosure (s : Submonoid M) : IsClosed (s.topologicalClosure : Set M) := isClosed_closure @[to_additive] theorem Submonoid.topologicalClosure_minimal (s : Submonoid M) {t : Submonoid M} (h : s ≤ t) (ht : IsClosed (t : Set M)) : s.topologicalClosure ≤ t := closure_minimal h ht /-- If a submonoid of a topological monoid is commutative, then so is its topological closure. -/ @[to_additive /-- If a submonoid of an additive topological monoid is commutative, then so is its topological closure. See note [reducible non-instances]. -/] abbrev Submonoid.commMonoidTopologicalClosure [T2Space M] (s : Submonoid M) (hs : ∀ x y : s, x * y = y * x) : CommMonoid s.topologicalClosure := { s.topologicalClosure.toMonoid, s.toSubsemigroup.commSemigroupTopologicalClosure hs with } @[to_additive exists_nhds_zero_quarter] theorem exists_nhds_one_split4 {u : Set M} (hu : u ∈ 𝓝 (1 : M)) : ∃ V ∈ 𝓝 (1 : M), ∀ {v w s t}, v ∈ V → w ∈ V → s ∈ V → t ∈ V → v * w * s * t ∈ u := by rcases exists_nhds_one_split hu with ⟨W, W1, h⟩ rcases exists_nhds_one_split W1 with ⟨V, V1, h'⟩ use V, V1 intro v w s t v_in w_in s_in t_in simpa only [mul_assoc] using h _ (h' v v_in w w_in) _ (h' s s_in t t_in) @[to_additive] theorem tendsto_list_prod {f : ι → α → M} {x : Filter α} {a : ι → M} : ∀ l : List ι, (∀ i ∈ l, Tendsto (f i) x (𝓝 (a i))) → Tendsto (fun b => (l.map fun c => f c b).prod) x (𝓝 (l.map a).prod) | [], _ => by simp [tendsto_const_nhds] | f::l, h => by simp only [List.map_cons, List.prod_cons] exact (h f List.mem_cons_self).mul (tendsto_list_prod l fun c hc => h c (List.mem_cons_of_mem _ hc)) @[to_additive (attr := continuity, fun_prop)] theorem continuous_list_prod {f : ι → X → M} (l : List ι) (h : ∀ i ∈ l, Continuous (f i)) : Continuous fun a => (l.map fun i => f i a).prod := continuous_iff_continuousAt.2 fun x => tendsto_list_prod l fun c hc => continuous_iff_continuousAt.1 (h c hc) x @[to_additive] theorem continuousOn_list_prod {f : ι → X → M} (l : List ι) {t : Set X} (h : ∀ i ∈ l, ContinuousOn (f i) t) : ContinuousOn (fun a => (l.map fun i => f i a).prod) t := by intro x hx rw [continuousWithinAt_iff_continuousAt_restrict _ hx] refine tendsto_list_prod _ fun i hi => ?_ specialize h i hi x hx rw [continuousWithinAt_iff_continuousAt_restrict _ hx] at h exact h @[to_additive (attr := continuity)] theorem continuous_pow : ∀ n : ℕ, Continuous fun a : M => a ^ n | 0 => by simpa using continuous_const | k + 1 => by simp only [pow_succ'] exact continuous_id.mul (continuous_pow _) instance AddMonoid.continuousConstSMul_nat {A} [AddMonoid A] [TopologicalSpace A] [ContinuousAdd A] : ContinuousConstSMul ℕ A := ⟨continuous_nsmul⟩ instance AddMonoid.continuousSMul_nat {A} [AddMonoid A] [TopologicalSpace A] [ContinuousAdd A] : ContinuousSMul ℕ A := ⟨continuous_prod_of_discrete_left.mpr continuous_nsmul⟩ -- We register `Continuous.pow` as a `continuity` lemma with low penalty (so -- `continuity` will try it before other `continuity` lemmas). This is a -- workaround for goals of the form `Continuous fun x => x ^ 2`, where -- `continuity` applies `Continuous.mul` since the goal is defeq to -- `Continuous fun x => x * x`. -- -- To properly fix this, we should make sure that `continuity` applies its -- lemmas with reducible transparency, preventing the unfolding of `^`. But this -- is quite an invasive change. @[to_additive (attr := aesop safe -100 (rule_sets := [Continuous]), fun_prop)] theorem Continuous.pow {f : X → M} (h : Continuous f) (n : ℕ) : Continuous fun b => f b ^ n := (continuous_pow n).comp h @[to_additive] theorem continuousOn_pow {s : Set M} (n : ℕ) : ContinuousOn (fun (x : M) => x ^ n) s := (continuous_pow n).continuousOn @[to_additive] theorem continuousAt_pow (x : M) (n : ℕ) : ContinuousAt (fun (x : M) => x ^ n) x := (continuous_pow n).continuousAt @[to_additive] theorem Filter.Tendsto.pow {l : Filter α} {f : α → M} {x : M} (hf : Tendsto f l (𝓝 x)) (n : ℕ) : Tendsto (fun x => f x ^ n) l (𝓝 (x ^ n)) := (continuousAt_pow _ _).tendsto.comp hf @[to_additive] theorem ContinuousWithinAt.pow {f : X → M} {x : X} {s : Set X} (hf : ContinuousWithinAt f s x) (n : ℕ) : ContinuousWithinAt (fun x => f x ^ n) s x := Filter.Tendsto.pow hf n @[to_additive (attr := fun_prop)] theorem ContinuousAt.pow {f : X → M} {x : X} (hf : ContinuousAt f x) (n : ℕ) : ContinuousAt (fun x => f x ^ n) x := Filter.Tendsto.pow hf n @[to_additive (attr := fun_prop)] theorem ContinuousOn.pow {f : X → M} {s : Set X} (hf : ContinuousOn f s) (n : ℕ) : ContinuousOn (fun x => f x ^ n) s := fun x hx => (hf x hx).pow n /-- Left-multiplication by a left-invertible element of a topological monoid is proper, i.e., inverse images of compact sets are compact. -/ theorem Filter.tendsto_cocompact_mul_left {a b : M} (ha : b * a = 1) : Filter.Tendsto (fun x : M => a * x) (Filter.cocompact M) (Filter.cocompact M) := by refine Filter.Tendsto.of_tendsto_comp ?_ (Filter.comap_cocompact_le (continuous_mul_left b)) convert Filter.tendsto_id ext x simp [← mul_assoc, ha] /-- Right-multiplication by a right-invertible element of a topological monoid is proper, i.e., inverse images of compact sets are compact. -/ theorem Filter.tendsto_cocompact_mul_right {a b : M} (ha : a * b = 1) : Filter.Tendsto (fun x : M => x * a) (Filter.cocompact M) (Filter.cocompact M) := by refine Filter.Tendsto.of_tendsto_comp ?_ (Filter.comap_cocompact_le (continuous_mul_right b)) simp only [comp_mul_right, ha, mul_one] exact Filter.tendsto_id /-- If `R` acts on `A` via `A`, then continuous multiplication implies continuous scalar multiplication by constants. Notably, this instances applies when `R = A`, or when `[Algebra R A]` is available. -/ @[to_additive /-- If `R` acts on `A` via `A`, then continuous addition implies continuous affine addition by constants. -/] instance (priority := 100) IsScalarTower.continuousConstSMul {R A : Type*} [Monoid A] [SMul R A] [IsScalarTower R A A] [TopologicalSpace A] [ContinuousMul A] : ContinuousConstSMul R A where continuous_const_smul q := by simp +singlePass only [← smul_one_mul q (_ : A)] exact continuous_const.mul continuous_id /-- If the action of `R` on `A` commutes with left-multiplication, then continuous multiplication implies continuous scalar multiplication by constants. Notably, this instances applies when `R = Aᵐᵒᵖ`. -/ @[to_additive /-- If the action of `R` on `A` commutes with left-addition, then continuous addition implies continuous affine addition by constants. Notably, this instances applies when `R = Aᵃᵒᵖ`. -/] instance (priority := 100) SMulCommClass.continuousConstSMul {R A : Type*} [Monoid A] [SMul R A] [SMulCommClass R A A] [TopologicalSpace A] [ContinuousMul A] : ContinuousConstSMul R A where continuous_const_smul q := by simp +singlePass only [← mul_smul_one q (_ : A)] exact continuous_id.mul continuous_const end ContinuousMul namespace MulOpposite /-- If multiplication is continuous in `α`, then it also is in `αᵐᵒᵖ`. -/ @[to_additive /-- If addition is continuous in `α`, then it also is in `αᵃᵒᵖ`. -/] instance [TopologicalSpace α] [Mul α] [ContinuousMul α] : ContinuousMul αᵐᵒᵖ := ⟨continuous_op.comp (continuous_unop.snd'.mul continuous_unop.fst')⟩ end MulOpposite namespace Units open MulOpposite variable [TopologicalSpace α] [Monoid α] [ContinuousMul α] /-- If multiplication on a monoid is continuous, then multiplication on the units of the monoid, with respect to the induced topology, is continuous. Inversion is also continuous, but we register this in a later file, `Topology.Algebra.Group`, because the predicate `ContinuousInv` has not yet been defined. -/ @[to_additive /-- If addition on an additive monoid is continuous, then addition on the additive units of the monoid, with respect to the induced topology, is continuous. Negation is also continuous, but we register this in a later file, `Topology.Algebra.Group`, because the predicate `ContinuousNeg` has not yet been defined. -/] instance : ContinuousMul αˣ := isInducing_embedProduct.continuousMul (embedProduct α) end Units @[to_additive (attr := fun_prop)] theorem Continuous.units_map [Monoid M] [Monoid N] [TopologicalSpace M] [TopologicalSpace N] (f : M →* N) (hf : Continuous f) : Continuous (Units.map f) := Units.continuous_iff.2 ⟨hf.comp Units.continuous_val, hf.comp Units.continuous_coe_inv⟩ section variable [TopologicalSpace M] [CommMonoid M] @[to_additive] theorem Submonoid.mem_nhds_one (S : Submonoid M) (oS : IsOpen (S : Set M)) : (S : Set M) ∈ 𝓝 (1 : M) := IsOpen.mem_nhds oS S.one_mem variable [ContinuousMul M] @[to_additive] theorem tendsto_multiset_prod {f : ι → α → M} {x : Filter α} {a : ι → M} (s : Multiset ι) : (∀ i ∈ s, Tendsto (f i) x (𝓝 (a i))) → Tendsto (fun b => (s.map fun c => f c b).prod) x (𝓝 (s.map a).prod) := by rcases s with ⟨l⟩ simpa using tendsto_list_prod l @[to_additive] theorem tendsto_finset_prod {f : ι → α → M} {x : Filter α} {a : ι → M} (s : Finset ι) : (∀ i ∈ s, Tendsto (f i) x (𝓝 (a i))) → Tendsto (fun b => ∏ c ∈ s, f c b) x (𝓝 (∏ c ∈ s, a c)) := tendsto_multiset_prod _ @[to_additive (attr := continuity, fun_prop)] theorem continuous_multiset_prod {f : ι → X → M} (s : Multiset ι) : (∀ i ∈ s, Continuous (f i)) → Continuous fun a => (s.map fun i => f i a).prod := by rcases s with ⟨l⟩ simpa using continuous_list_prod l @[to_additive] theorem continuousOn_multiset_prod {f : ι → X → M} (s : Multiset ι) {t : Set X} : (∀ i ∈ s, ContinuousOn (f i) t) → ContinuousOn (fun a => (s.map fun i => f i a).prod) t := by rcases s with ⟨l⟩ simpa using continuousOn_list_prod l @[to_additive (attr := continuity, fun_prop)] theorem continuous_finset_prod {f : ι → X → M} (s : Finset ι) : (∀ i ∈ s, Continuous (f i)) → Continuous fun a => ∏ i ∈ s, f i a := continuous_multiset_prod _ @[to_additive] theorem continuousOn_finset_prod {f : ι → X → M} (s : Finset ι) {t : Set X} : (∀ i ∈ s, ContinuousOn (f i) t) → ContinuousOn (fun a => ∏ i ∈ s, f i a) t := continuousOn_multiset_prod _ @[to_additive] theorem eventuallyEq_prod {X M : Type*} [CommMonoid M] {s : Finset ι} {l : Filter X} {f g : ι → X → M} (hs : ∀ i ∈ s, f i =ᶠ[l] g i) : ∏ i ∈ s, f i =ᶠ[l] ∏ i ∈ s, g i := by replace hs : ∀ᶠ x in l, ∀ i ∈ s, f i x = g i x := by rwa [eventually_all_finset] filter_upwards [hs] with x hx simp only [Finset.prod_apply, Finset.prod_congr rfl hx] open Function @[to_additive] theorem LocallyFinite.exists_finset_mulSupport {M : Type*} [One M] {f : ι → X → M} (hf : LocallyFinite fun i => mulSupport <| f i) (x₀ : X) : ∃ I : Finset ι, ∀ᶠ x in 𝓝 x₀, (mulSupport fun i => f i x) ⊆ I := by rcases hf x₀ with ⟨U, hxU, hUf⟩ refine ⟨hUf.toFinset, mem_of_superset hxU fun y hy i hi => ?_⟩ rw [hUf.coe_toFinset] exact ⟨y, hi, hy⟩ @[to_additive] theorem finprod_eventually_eq_prod {M : Type*} [CommMonoid M] {f : ι → X → M} (hf : LocallyFinite fun i => mulSupport (f i)) (x : X) : ∃ s : Finset ι, ∀ᶠ y in 𝓝 x, ∏ᶠ i, f i y = ∏ i ∈ s, f i y := let ⟨I, hI⟩ := hf.exists_finset_mulSupport x ⟨I, hI.mono fun _ hy => finprod_eq_prod_of_mulSupport_subset _ fun _ hi => hy hi⟩ @[to_additive] theorem continuous_finprod {f : ι → X → M} (hc : ∀ i, Continuous (f i)) (hf : LocallyFinite fun i => mulSupport (f i)) : Continuous fun x => ∏ᶠ i, f i x := by refine continuous_iff_continuousAt.2 fun x => ?_ rcases finprod_eventually_eq_prod hf x with ⟨s, hs⟩ refine ContinuousAt.congr ?_ (EventuallyEq.symm hs) exact tendsto_finset_prod _ fun i _ => (hc i).continuousAt @[to_additive] theorem continuous_finprod_cond {f : ι → X → M} {p : ι → Prop} (hc : ∀ i, p i → Continuous (f i)) (hf : LocallyFinite fun i => mulSupport (f i)) : Continuous fun x => ∏ᶠ (i) (_ : p i), f i x := by simp only [← finprod_subtype_eq_finprod_cond] exact continuous_finprod (fun i => hc i i.2) (hf.comp_injective Subtype.coe_injective) end instance [TopologicalSpace M] [Mul M] [ContinuousMul M] : ContinuousAdd (Additive M) where continuous_add := @continuous_mul M _ _ _ instance [TopologicalSpace M] [Add M] [ContinuousAdd M] : ContinuousMul (Multiplicative M) where continuous_mul := @continuous_add M _ _ _ section LatticeOps variable {ι' : Sort*} [Mul M] @[to_additive] theorem continuousMul_sInf {ts : Set (TopologicalSpace M)} (h : ∀ t ∈ ts, @ContinuousMul M t _) : @ContinuousMul M (sInf ts) _ := letI := sInf ts { continuous_mul := continuous_sInf_rng.2 fun t ht => continuous_sInf_dom₂ ht ht (@ContinuousMul.continuous_mul M t _ (h t ht)) } @[to_additive] theorem continuousMul_iInf {ts : ι' → TopologicalSpace M} (h' : ∀ i, @ContinuousMul M (ts i) _) : @ContinuousMul M (⨅ i, ts i) _ := by rw [← sInf_range] exact continuousMul_sInf (Set.forall_mem_range.mpr h') @[to_additive] theorem continuousMul_inf {t₁ t₂ : TopologicalSpace M} (h₁ : @ContinuousMul M t₁ _) (h₂ : @ContinuousMul M t₂ _) : @ContinuousMul M (t₁ ⊓ t₂) _ := by rw [inf_eq_iInf] refine continuousMul_iInf fun b => ?_ cases b <;> assumption end LatticeOps namespace ContinuousMap variable [Mul X] [ContinuousMul X] /-- The continuous map `fun y => y * x` -/ @[to_additive /-- The continuous map `fun y => y + x` -/] protected def mulRight (x : X) : C(X, X) := mk _ (continuous_mul_right x) @[to_additive (attr := simp)] theorem coe_mulRight (x : X) : ⇑(ContinuousMap.mulRight x) = fun y => y * x := rfl /-- The continuous map `fun y => x * y` -/ @[to_additive /-- The continuous map `fun y => x + y` -/] protected def mulLeft (x : X) : C(X, X) := mk _ (continuous_mul_left x) @[to_additive (attr := simp)] theorem coe_mulLeft (x : X) : ⇑(ContinuousMap.mulLeft x) = fun y => x * y := rfl end ContinuousMap
.lake/packages/mathlib/Mathlib/Topology/Algebra/PontryaginDual.lean
import Mathlib.Analysis.SpecialFunctions.Complex.Circle import Mathlib.Topology.Algebra.Group.CompactOpen /-! # Pontryagin dual This file defines the Pontryagin dual of a topological group. The Pontryagin dual of a topological group `A` is the topological group of continuous homomorphisms `A →* Circle` with the compact-open topology. For example, `ℤ` and `Circle` are Pontryagin duals of each other. This is an example of Pontryagin duality, which states that a locally compact abelian topological group is canonically isomorphic to its double dual. ## Main definitions * `PontryaginDual A`: The group of continuous homomorphisms `A →* Circle`. -/ open Pointwise Function variable (A B C G H : Type*) [Monoid A] [Monoid B] [Monoid C] [CommGroup G] [Group H] [TopologicalSpace A] [TopologicalSpace B] [TopologicalSpace C] [TopologicalSpace G] [TopologicalSpace H] [IsTopologicalGroup G] [IsTopologicalGroup H] noncomputable section /-- The Pontryagin dual of `A` is the group of continuous homomorphism `A → Circle`. -/ def PontryaginDual := A →ₜ* Circle deriving TopologicalSpace instance [LocallyCompactSpace H] : LocallyCompactSpace (PontryaginDual H) := by let Vn : ℕ → Set Circle := fun n ↦ Circle.exp '' { x | |x| < Real.pi / 2 ^ (n + 1)} have hVn : ∀ n x, x ∈ Vn n ↔ |Complex.arg x| < Real.pi / 2 ^ (n + 1) := by refine fun n x ↦ ⟨?_, fun hx ↦ ⟨Complex.arg x, hx, Circle.exp_arg x⟩⟩ rintro ⟨t, ht : |t| < _, rfl⟩ have ht' := ht.trans_le (div_le_self Real.pi_nonneg (one_le_pow₀ one_le_two)) rwa [Circle.arg_exp (neg_lt_of_abs_lt ht') (lt_of_abs_lt ht').le] refine ContinuousMonoidHom.locallyCompactSpace_of_hasBasis Vn ?_ ?_ · intro n x h1 h2 rw [hVn] at h1 h2 ⊢ rwa [Circle.coe_mul, Complex.arg_mul x.coe_ne_zero x.coe_ne_zero, ← two_mul, abs_mul, abs_two, ← lt_div_iff₀' two_pos, div_div, ← pow_succ] at h2 apply Set.Ioo_subset_Ioc_self rw [← two_mul, Set.mem_Ioo, ← abs_lt, abs_mul, abs_two, ← lt_div_iff₀' two_pos] refine h1.trans_le ?_ gcongr exact le_self_pow₀ one_le_two n.succ_ne_zero · rw [← Circle.exp_zero, ← isLocalHomeomorph_circleExp.map_nhds_eq 0] refine ((nhds_basis_zero_abs_lt ℝ).to_hasBasis (fun x hx ↦ ⟨Nat.ceil (Real.pi / x), trivial, fun t ht ↦ ?_⟩) fun k _ ↦ ⟨Real.pi / 2 ^ (k + 1), by positivity, le_rfl⟩).map Circle.exp rw [Set.mem_setOf_eq] at ht ⊢ refine lt_of_lt_of_le ht ?_ rw [div_le_iff₀' (pow_pos two_pos _), ← div_le_iff₀ hx] refine (Nat.le_ceil (Real.pi / x)).trans ?_ exact_mod_cast (Nat.le_succ _).trans Nat.lt_two_pow_self.le variable {A B C G} namespace PontryaginDual open ContinuousMonoidHom deriving instance T2Space, CommGroup, IsTopologicalGroup, Inhabited, FunLike, ContinuousMapClass, MonoidHomClass, [DiscreteTopology A] → CompactSpace _ for PontryaginDual A /-- A discrete monoid has compact Pontryagin dual. -/ add_decl_doc instLocallyCompactSpacePontryaginDual /-- `PontryaginDual` is a contravariant functor. -/ def map (f : A →ₜ* B) : (PontryaginDual B) →ₜ* (PontryaginDual A) := f.compLeft Circle @[simp] theorem map_apply (f : A →ₜ* B) (x : PontryaginDual B) (y : A) : map f x y = x (f y) := rfl @[simp] theorem map_one : map (1 : A →ₜ* B) = 1 := ext fun x => ext (fun _y => OneHomClass.map_one x) @[simp] theorem map_comp (g : B →ₜ* C) (f : A →ₜ* B) : map (comp g f) = ContinuousMonoidHom.comp (map f) (map g) := ext fun _x => ext fun _y => rfl @[simp] nonrec theorem map_mul (f g : A →ₜ* G) : map (f * g) = map f * map g := ext fun x => ext fun y => map_mul x (f y) (g y) variable (A B C G) /-- `ContinuousMonoidHom.dual` as a `ContinuousMonoidHom`. -/ def mapHom [LocallyCompactSpace G] : (A →ₜ* G) →ₜ* ((PontryaginDual G) →ₜ* (PontryaginDual A)) where toFun := map map_one' := map_one map_mul' := map_mul continuous_toFun := continuous_of_continuous_uncurry _ continuous_comp end PontryaginDual
.lake/packages/mathlib/Mathlib/Topology/Algebra/Indicator.lean
import Mathlib.Algebra.Notation.Indicator import Mathlib.Topology.Piecewise import Mathlib.Topology.Clopen /-! # Continuity of indicator functions -/ open Set open scoped Topology variable {α β : Type*} [TopologicalSpace α] [TopologicalSpace β] {f : α → β} {s : Set α} [One β] @[to_additive] lemma continuous_mulIndicator (hs : ∀ a ∈ frontier s, f a = 1) (hf : ContinuousOn f (closure s)) : Continuous (mulIndicator s f) := by classical exact continuous_piecewise hs hf continuousOn_const @[to_additive] protected lemma Continuous.mulIndicator (hs : ∀ a ∈ frontier s, f a = 1) (hf : Continuous f) : Continuous (mulIndicator s f) := by classical exact hf.piecewise hs continuous_const @[to_additive] theorem ContinuousOn.continuousAt_mulIndicator (hf : ContinuousOn f (interior s)) {x : α} (hx : x ∉ frontier s) : ContinuousAt (s.mulIndicator f) x := by rw [← Set.mem_compl_iff, compl_frontier_eq_union_interior] at hx obtain h | h := hx · have hs : interior s ∈ 𝓝 x := mem_interior_iff_mem_nhds.mp (by rwa [interior_interior]) exact ContinuousAt.congr (hf.continuousAt hs) <| Filter.eventuallyEq_iff_exists_mem.mpr ⟨interior s, hs, Set.eqOn_mulIndicator.symm.mono interior_subset⟩ · exact ContinuousAt.congr continuousAt_const <| Filter.eventuallyEq_iff_exists_mem.mpr ⟨sᶜ, mem_interior_iff_mem_nhds.mp h, Set.eqOn_mulIndicator'.symm⟩ @[to_additive] lemma IsClopen.continuous_mulIndicator (hs : IsClopen s) (hf : Continuous f) : Continuous (s.mulIndicator f) := hf.mulIndicator (by simp [isClopen_iff_frontier_eq_empty.mp hs])
.lake/packages/mathlib/Mathlib/Topology/Algebra/UniformFilterBasis.lean
import Mathlib.Topology.Algebra.FilterBasis import Mathlib.Topology.Algebra.IsUniformGroup.Defs /-! # Uniform properties of neighborhood bases in topological algebra This file contains properties of filter bases on algebraic structures that also require the theory of uniform spaces. The only result so far is a characterization of Cauchy filters in topological groups. -/ open uniformity Filter open Filter namespace AddGroupFilterBasis variable {G : Type*} [AddCommGroup G] (B : AddGroupFilterBasis G) /-- The uniform space structure associated to an abelian group filter basis via the associated topological abelian group structure. -/ protected def uniformSpace : UniformSpace G := @IsTopologicalAddGroup.rightUniformSpace G _ B.topology B.isTopologicalAddGroup /-- The uniform space structure associated to an abelian group filter basis via the associated topological abelian group structure is compatible with its group structure. -/ protected theorem isUniformAddGroup : @IsUniformAddGroup G B.uniformSpace _ := @isUniformAddGroup_of_addCommGroup G _ B.topology B.isTopologicalAddGroup theorem cauchy_iff {F : Filter G} : @Cauchy G B.uniformSpace F ↔ F.NeBot ∧ ∀ U ∈ B, ∃ M ∈ F, ∀ᵉ (x ∈ M) (y ∈ M), y - x ∈ U := by letI := B.uniformSpace haveI := B.isUniformAddGroup suffices F ×ˢ F ≤ uniformity G ↔ ∀ U ∈ B, ∃ M ∈ F, ∀ᵉ (x ∈ M) (y ∈ M), y - x ∈ U by constructor <;> rintro ⟨h', h⟩ <;> refine ⟨h', ?_⟩ <;> [rwa [← this]; rwa [this]] rw [uniformity_eq_comap_nhds_zero G, ← map_le_iff_le_comap] change Tendsto _ _ _ ↔ _ simp [(basis_sets F).prod_self.tendsto_iff B.nhds_zero_hasBasis, @forall_swap (_ ∈ _) G] end AddGroupFilterBasis
.lake/packages/mathlib/Mathlib/Topology/Algebra/OpenSubgroup.lean
import Mathlib.Algebra.Module.Submodule.Lattice import Mathlib.RingTheory.Ideal.Defs import Mathlib.Topology.Algebra.Group.Quotient import Mathlib.Topology.Algebra.Ring.Basic import Mathlib.Topology.Sets.Opens /-! # Open subgroups of a topological group This file builds the lattice `OpenSubgroup G` of open subgroups in a topological group `G`, and its additive version `OpenAddSubgroup`. This lattice has a top element, the subgroup of all elements, but no bottom element in general. The trivial subgroup which is the natural candidate bottom has no reason to be open (this happens only in discrete groups). Note that this notion is especially relevant in a non-archimedean context, for instance for `p`-adic groups. ## Main declarations * `OpenSubgroup.isClosed`: An open subgroup is automatically closed. * `Subgroup.isOpen_mono`: A subgroup containing an open subgroup is open. There are also versions for additive groups, submodules and ideals. * `OpenSubgroup.comap`: Open subgroups can be pulled back by a continuous group morphism. ## TODO * Prove that the identity component of a locally path connected group is an open subgroup. Up to now this file is really geared towards non-archimedean algebra, not Lie groups. -/ open TopologicalSpace Topology Function /-- The type of open subgroups of a topological additive group. -/ structure OpenAddSubgroup (G : Type*) [AddGroup G] [TopologicalSpace G] extends AddSubgroup G where isOpen' : IsOpen carrier /-- The type of open subgroups of a topological group. -/ @[to_additive] structure OpenSubgroup (G : Type*) [Group G] [TopologicalSpace G] extends Subgroup G where isOpen' : IsOpen carrier /-- Reinterpret an `OpenSubgroup` as a `Subgroup`. -/ add_decl_doc OpenSubgroup.toSubgroup /-- Reinterpret an `OpenAddSubgroup` as an `AddSubgroup`. -/ add_decl_doc OpenAddSubgroup.toAddSubgroup attribute [coe] OpenSubgroup.toSubgroup OpenAddSubgroup.toAddSubgroup namespace OpenSubgroup variable {G : Type*} [Group G] [TopologicalSpace G] variable {U V : OpenSubgroup G} {g : G} @[to_additive] instance hasCoeSubgroup : CoeTC (OpenSubgroup G) (Subgroup G) := ⟨toSubgroup⟩ @[to_additive] theorem toSubgroup_injective : Injective ((↑) : OpenSubgroup G → Subgroup G) | ⟨_, _⟩, ⟨_, _⟩, rfl => rfl @[to_additive] instance : SetLike (OpenSubgroup G) G where coe U := U.1 coe_injective' _ _ h := toSubgroup_injective <| SetLike.ext' h @[to_additive] instance : SubgroupClass (OpenSubgroup G) G where mul_mem := Subsemigroup.mul_mem' _ one_mem U := U.one_mem' inv_mem := Subgroup.inv_mem' _ /-- Coercion from `OpenSubgroup G` to `Opens G`. -/ @[to_additive (attr := coe) /-- Coercion from `OpenAddSubgroup G` to `Opens G`. -/] def toOpens (U : OpenSubgroup G) : Opens G := ⟨U, U.isOpen'⟩ @[to_additive] instance hasCoeOpens : CoeTC (OpenSubgroup G) (Opens G) := ⟨toOpens⟩ @[to_additive (attr := simp, norm_cast)] theorem coe_toOpens : ((U : Opens G) : Set G) = U := rfl @[to_additive (attr := simp, norm_cast)] theorem coe_toSubgroup : ((U : Subgroup G) : Set G) = U := rfl @[to_additive (attr := simp, norm_cast)] theorem mem_toOpens : g ∈ (U : Opens G) ↔ g ∈ U := Iff.rfl @[to_additive (attr := simp, norm_cast)] theorem mem_toSubgroup : g ∈ (U : Subgroup G) ↔ g ∈ U := Iff.rfl @[to_additive (attr := ext)] theorem ext (h : ∀ x, x ∈ U ↔ x ∈ V) : U = V := SetLike.ext h variable (U) @[to_additive] protected theorem isOpen : IsOpen (U : Set G) := U.isOpen' @[to_additive] theorem mem_nhds_one : (U : Set G) ∈ 𝓝 (1 : G) := U.isOpen.mem_nhds U.one_mem variable {U} @[to_additive] instance : Top (OpenSubgroup G) := ⟨⟨⊤, isOpen_univ⟩⟩ @[to_additive (attr := simp)] theorem mem_top (x : G) : x ∈ (⊤ : OpenSubgroup G) := trivial @[to_additive (attr := simp, norm_cast)] theorem coe_top : ((⊤ : OpenSubgroup G) : Set G) = Set.univ := rfl @[to_additive (attr := simp, norm_cast)] theorem toSubgroup_top : ((⊤ : OpenSubgroup G) : Subgroup G) = ⊤ := rfl @[to_additive (attr := simp, norm_cast)] theorem toOpens_top : ((⊤ : OpenSubgroup G) : Opens G) = ⊤ := rfl @[to_additive] instance : Inhabited (OpenSubgroup G) := ⟨⊤⟩ @[to_additive] theorem isClosed [ContinuousMul G] (U : OpenSubgroup G) : IsClosed (U : Set G) := by have := QuotientGroup.discreteTopology U.isOpen exact QuotientGroup.t1Space_iff.mp inferInstance @[to_additive] theorem isClopen [ContinuousMul G] (U : OpenSubgroup G) : IsClopen (U : Set G) := ⟨U.isClosed, U.isOpen⟩ section variable {H : Type*} [Group H] [TopologicalSpace H] /-- The product of two open subgroups as an open subgroup of the product group. -/ @[to_additive prod /-- The product of two open subgroups as an open subgroup of the product group. -/] def prod (U : OpenSubgroup G) (V : OpenSubgroup H) : OpenSubgroup (G × H) := ⟨.prod U V, U.isOpen.prod V.isOpen⟩ @[to_additive (attr := simp, norm_cast) coe_prod] theorem coe_prod (U : OpenSubgroup G) (V : OpenSubgroup H) : (U.prod V : Set (G × H)) = (U : Set G) ×ˢ (V : Set H) := rfl @[to_additive (attr := simp, norm_cast) toAddSubgroup_prod] theorem toSubgroup_prod (U : OpenSubgroup G) (V : OpenSubgroup H) : (U.prod V : Subgroup (G × H)) = (U : Subgroup G).prod V := rfl end @[to_additive] instance instInfOpenSubgroup : Min (OpenSubgroup G) := ⟨fun U V ↦ ⟨U ⊓ V, U.isOpen.inter V.isOpen⟩⟩ @[to_additive (attr := simp, norm_cast)] theorem coe_inf : (↑(U ⊓ V) : Set G) = (U : Set G) ∩ V := rfl @[to_additive (attr := simp, norm_cast)] theorem toSubgroup_inf : (↑(U ⊓ V) : Subgroup G) = ↑U ⊓ ↑V := rfl @[to_additive (attr := simp, norm_cast)] theorem toOpens_inf : (↑(U ⊓ V) : Opens G) = ↑U ⊓ ↑V := rfl @[to_additive (attr := simp)] theorem mem_inf {x} : x ∈ U ⊓ V ↔ x ∈ U ∧ x ∈ V := Iff.rfl @[to_additive] instance instPartialOrderOpenSubgroup : PartialOrder (OpenSubgroup G) := inferInstance -- We override `toPartialorder` to get better `le` @[to_additive] instance instSemilatticeInfOpenSubgroup : SemilatticeInf (OpenSubgroup G) := { SetLike.coe_injective.semilatticeInf ((↑) : OpenSubgroup G → Set G) fun _ _ ↦ rfl with toPartialOrder := instPartialOrderOpenSubgroup } @[to_additive] instance : OrderTop (OpenSubgroup G) where le_top _ := Set.subset_univ _ @[to_additive (attr := simp, norm_cast)] theorem toSubgroup_le : (U : Subgroup G) ≤ (V : Subgroup G) ↔ U ≤ V := Iff.rfl variable {N : Type*} [Group N] [TopologicalSpace N] /-- The preimage of an `OpenSubgroup` along a continuous `Monoid` homomorphism is an `OpenSubgroup`. -/ @[to_additive /-- The preimage of an `OpenAddSubgroup` along a continuous `AddMonoid` homomorphism is an `OpenAddSubgroup`. -/] def comap (f : G →* N) (hf : Continuous f) (H : OpenSubgroup N) : OpenSubgroup G := ⟨.comap f H, H.isOpen.preimage hf⟩ @[to_additive (attr := simp, norm_cast)] theorem coe_comap (H : OpenSubgroup N) (f : G →* N) (hf : Continuous f) : (H.comap f hf : Set G) = f ⁻¹' H := rfl @[to_additive (attr := simp, norm_cast)] theorem toSubgroup_comap (H : OpenSubgroup N) (f : G →* N) (hf : Continuous f) : (H.comap f hf : Subgroup G) = (H : Subgroup N).comap f := rfl @[to_additive (attr := simp)] theorem mem_comap {H : OpenSubgroup N} {f : G →* N} {hf : Continuous f} {x : G} : x ∈ H.comap f hf ↔ f x ∈ H := Iff.rfl @[to_additive] theorem comap_comap {P : Type*} [Group P] [TopologicalSpace P] (K : OpenSubgroup P) (f₂ : N →* P) (hf₂ : Continuous f₂) (f₁ : G →* N) (hf₁ : Continuous f₁) : (K.comap f₂ hf₂).comap f₁ hf₁ = K.comap (f₂.comp f₁) (hf₂.comp hf₁) := rfl end OpenSubgroup namespace Subgroup variable {G : Type*} [Group G] [TopologicalSpace G] @[to_additive] theorem isOpen_of_mem_nhds [ContinuousMul G] (H : Subgroup G) {g : G} (hg : (H : Set G) ∈ 𝓝 g) : IsOpen (H : Set G) := by refine isOpen_iff_mem_nhds.2 fun x hx ↦ ?_ have hg' : g ∈ H := SetLike.mem_coe.1 (mem_of_mem_nhds hg) have : Filter.Tendsto (fun y ↦ y * (x⁻¹ * g)) (𝓝 x) (𝓝 g) := (continuous_id.mul continuous_const).tendsto' _ _ (mul_inv_cancel_left _ _) simpa only [SetLike.mem_coe, Filter.mem_map', H.mul_mem_cancel_right (H.mul_mem (H.inv_mem hx) hg')] using this hg @[to_additive] theorem isOpen_mono [ContinuousMul G] {H₁ H₂ : Subgroup G} (h : H₁ ≤ H₂) (h₁ : IsOpen (H₁ : Set G)) : IsOpen (H₂ : Set G) := isOpen_of_mem_nhds _ <| Filter.mem_of_superset (h₁.mem_nhds <| one_mem H₁) h @[to_additive] theorem isOpen_of_openSubgroup [ContinuousMul G] (H : Subgroup G) {U : OpenSubgroup G} (h : ↑U ≤ H) : IsOpen (H : Set G) := isOpen_mono h U.isOpen /-- If a subgroup of a topological group has `1` in its interior, then it is open. -/ @[to_additive /-- If a subgroup of an additive topological group has `0` in its interior, then it is open. -/] theorem isOpen_of_one_mem_interior [ContinuousMul G] (H : Subgroup G) (h_1_int : (1 : G) ∈ interior (H : Set G)) : IsOpen (H : Set G) := isOpen_of_mem_nhds H <| mem_interior_iff_mem_nhds.1 h_1_int @[to_additive] lemma isClosed_of_isOpen [ContinuousMul G] (U : Subgroup G) (h : IsOpen (U : Set G)) : IsClosed (U : Set G) := OpenSubgroup.isClosed ⟨U, h⟩ @[to_additive] lemma subgroupOf_isOpen (U K : Subgroup G) (h : IsOpen (K : Set G)) : IsOpen (K.subgroupOf U : Set U) := Continuous.isOpen_preimage (continuous_iff_le_induced.mpr fun _ ↦ id) _ h @[to_additive (attr := deprecated QuotientGroup.discreteTopology (since := "2025-10-09"))] lemma discreteTopology [ContinuousMul G] (U : Subgroup G) (h : IsOpen (U : Set G)) : DiscreteTopology (G ⧸ U) := QuotientGroup.discreteTopology h @[to_additive] instance [ContinuousMul G] (U : OpenSubgroup G) : DiscreteTopology (G ⧸ U.toSubgroup) := QuotientGroup.discreteTopology U.isOpen @[to_additive] lemma quotient_finite_of_isOpen [ContinuousMul G] [CompactSpace G] (U : Subgroup G) (h : IsOpen (U : Set G)) : Finite (G ⧸ U) := have : DiscreteTopology (G ⧸ U) := QuotientGroup.discreteTopology h finite_of_compact_of_discrete @[to_additive] instance [ContinuousMul G] [CompactSpace G] (U : OpenSubgroup G) : Finite (G ⧸ U.toSubgroup) := quotient_finite_of_isOpen U.toSubgroup U.isOpen @[to_additive] lemma quotient_finite_of_isOpen' [IsTopologicalGroup G] [CompactSpace G] (U : Subgroup G) (K : Subgroup U) (hUopen : IsOpen (U : Set G)) (hKopen : IsOpen (K : Set U)) : Finite (U ⧸ K) := have : CompactSpace U := isCompact_iff_compactSpace.mp <| IsClosed.isCompact <| U.isClosed_of_isOpen hUopen K.quotient_finite_of_isOpen hKopen @[to_additive] instance [IsTopologicalGroup G] [CompactSpace G] (U : OpenSubgroup G) (K : OpenSubgroup U) : Finite (U ⧸ K.toSubgroup) := quotient_finite_of_isOpen' U.toSubgroup K.toSubgroup U.isOpen K.isOpen end Subgroup namespace OpenSubgroup variable {G : Type*} [Group G] [TopologicalSpace G] [ContinuousMul G] @[to_additive] instance : Max (OpenSubgroup G) := ⟨fun U V ↦ ⟨U ⊔ V, Subgroup.isOpen_mono (le_sup_left : U.1 ≤ U.1 ⊔ V.1) U.isOpen⟩⟩ @[to_additive (attr := simp, norm_cast)] theorem toSubgroup_sup (U V : OpenSubgroup G) : (↑(U ⊔ V) : Subgroup G) = ↑U ⊔ ↑V := rfl -- We override `toPartialorder` to get better `le` @[to_additive] instance : Lattice (OpenSubgroup G) := { instSemilatticeInfOpenSubgroup, toSubgroup_injective.semilatticeSup ((↑) : OpenSubgroup G → Subgroup G) fun _ _ ↦ rfl with toPartialOrder := instPartialOrderOpenSubgroup } end OpenSubgroup namespace Submodule open OpenAddSubgroup variable {R : Type*} {M : Type*} [CommRing R] variable [AddCommGroup M] [TopologicalSpace M] [IsTopologicalAddGroup M] [Module R M] theorem isOpen_mono {U P : Submodule R M} (h : U ≤ P) (hU : IsOpen (U : Set M)) : IsOpen (P : Set M) := @AddSubgroup.isOpen_mono M _ _ _ U.toAddSubgroup P.toAddSubgroup h hU end Submodule namespace Ideal variable {R : Type*} [CommRing R] variable [TopologicalSpace R] [IsTopologicalRing R] theorem isOpen_of_isOpen_subideal {U I : Ideal R} (h : U ≤ I) (hU : IsOpen (U : Set R)) : IsOpen (I : Set R) := @Submodule.isOpen_mono R R _ _ _ _ Semiring.toModule _ _ h hU end Ideal /-! ### Open normal subgroups of a topological group This section builds the lattice `OpenNormalSubgroup G` of open subgroups in a topological group `G`, and its additive version `OpenNormalAddSubgroup`. -/ section universe u /-- The type of open normal subgroups of a topological group. -/ @[ext] structure OpenNormalSubgroup (G : Type u) [Group G] [TopologicalSpace G] extends OpenSubgroup G where isNormal' : toSubgroup.Normal := by infer_instance /-- The type of open normal subgroups of a topological additive group. -/ @[ext] structure OpenNormalAddSubgroup (G : Type u) [AddGroup G] [TopologicalSpace G] extends OpenAddSubgroup G where isNormal' : toAddSubgroup.Normal := by infer_instance attribute [to_additive] OpenNormalSubgroup namespace OpenNormalSubgroup variable {G : Type u} [Group G] [TopologicalSpace G] @[to_additive] instance (H : OpenNormalSubgroup G) : H.toSubgroup.Normal := H.isNormal' @[to_additive] theorem toSubgroup_injective : Function.Injective (fun H ↦ H.toOpenSubgroup.toSubgroup : OpenNormalSubgroup G → Subgroup G) := fun A B h ↦ by ext dsimp at h rw [h] @[to_additive] instance : SetLike (OpenNormalSubgroup G) G where coe U := U.1 coe_injective' _ _ h := toSubgroup_injective <| SetLike.ext' h @[to_additive] instance : SubgroupClass (OpenNormalSubgroup G) G where mul_mem := Subsemigroup.mul_mem' _ one_mem U := U.one_mem' inv_mem := Subgroup.inv_mem' _ @[to_additive] instance : Coe (OpenNormalSubgroup G) (Subgroup G) where coe H := H.toOpenSubgroup.toSubgroup @[to_additive] instance instPartialOrderOpenNormalSubgroup : PartialOrder (OpenNormalSubgroup G) := inferInstance @[to_additive] instance instInfOpenNormalSubgroup : Min (OpenNormalSubgroup G) := ⟨fun U V ↦ ⟨U.toOpenSubgroup ⊓ V.toOpenSubgroup, Subgroup.normal_inf_normal U.toSubgroup V.toSubgroup⟩⟩ @[to_additive] instance instSemilatticeInfOpenNormalSubgroup : SemilatticeInf (OpenNormalSubgroup G) := SetLike.coe_injective.semilatticeInf ((↑) : OpenNormalSubgroup G → Set G) fun _ _ ↦ rfl @[to_additive] instance [ContinuousMul G] : Max (OpenNormalSubgroup G) := ⟨fun U V ↦ ⟨U.toOpenSubgroup ⊔ V.toOpenSubgroup, Subgroup.sup_normal U.toOpenSubgroup.1 V.toOpenSubgroup.1⟩⟩ @[to_additive] instance instSemilatticeSupOpenNormalSubgroup [ContinuousMul G] : SemilatticeSup (OpenNormalSubgroup G) := toSubgroup_injective.semilatticeSup _ (fun _ _ ↦ rfl) @[to_additive] instance [ContinuousMul G] : Lattice (OpenNormalSubgroup G) := { instSemilatticeInfOpenNormalSubgroup, instSemilatticeSupOpenNormalSubgroup with toPartialOrder := instPartialOrderOpenNormalSubgroup} end OpenNormalSubgroup end /-! ### Existence of an open subgroup in any clopen neighborhood of the neutral element This section proves the lemma `IsTopologicalGroup.exist_openSubgroup_sub_clopen_nhds_of_one`, which states that in a compact topological group, for any clopen neighborhood of 1, there exists an open subgroup contained within it. -/ open scoped Pointwise variable {G : Type*} [TopologicalSpace G] structure IsTopologicalAddGroup.addNegClosureNhd (T W : Set G) [AddGroup G] : Prop where nhds : T ∈ 𝓝 0 neg : -T = T isOpen : IsOpen T add : W + T ⊆ W /-- For a set `W`, `T` is a neighborhood of `1` which is open, stable under inverse and satisfies `T * W ⊆ W`. -/ @[to_additive /-- For a set `W`, `T` is a neighborhood of `0` which is open, stable under negation and satisfies `T + W ⊆ W`. -/] structure IsTopologicalGroup.mulInvClosureNhd (T W : Set G) [Group G] : Prop where nhds : T ∈ 𝓝 1 inv : T⁻¹ = T isOpen : IsOpen T mul : W * T ⊆ W namespace IsTopologicalGroup variable [Group G] [IsTopologicalGroup G] [CompactSpace G] open Set Filter @[to_additive] lemma exist_mul_closure_nhds {W : Set G} (WClopen : IsClopen W) : ∃ T ∈ 𝓝 (1 : G), W * T ⊆ W := by apply WClopen.isClosed.isCompact.induction_on (p := fun S ↦ ∃ T ∈ 𝓝 (1 : G), S * T ⊆ W) ⟨Set.univ, by simp only [univ_mem, empty_mul, empty_subset, and_self]⟩ (fun _ _ huv ⟨T, hT, mem⟩ ↦ ⟨T, hT, (mul_subset_mul_right huv).trans mem⟩) fun U V ⟨T₁, hT₁, mem1⟩ ⟨T₂, hT₂, mem2⟩ ↦ ⟨T₁ ∩ T₂, inter_mem hT₁ hT₂, by rw [union_mul] exact union_subset (mul_subset_mul_left inter_subset_left |>.trans mem1) (mul_subset_mul_left inter_subset_right |>.trans mem2) ⟩ intro x memW have : (x, 1) ∈ (fun p ↦ p.1 * p.2) ⁻¹' W := by simp [memW] rcases isOpen_prod_iff.mp (continuous_mul.isOpen_preimage W <| WClopen.2) x 1 this with ⟨U, V, Uopen, Vopen, xmemU, onememV, prodsub⟩ have h6 : U * V ⊆ W := mul_subset_iff.mpr (fun _ hx _ hy ↦ prodsub (mk_mem_prod hx hy)) exact ⟨U ∩ W, ⟨U, Uopen.mem_nhds xmemU, W, fun _ a ↦ a, rfl⟩, V, IsOpen.mem_nhds Vopen onememV, fun _ a ↦ h6 ((mul_subset_mul_right inter_subset_left) a)⟩ @[deprecated (since := "2025-05-22")] alias exist_mul_closure_nhd := exist_mul_closure_nhds @[deprecated (since := "2025-05-22")] alias _root_.IsTopologicalAddGroup.exist_add_closure_nhd := IsTopologicalAddGroup.exist_add_closure_nhds @[to_additive] lemma exists_mulInvClosureNhd {W : Set G} (WClopen : IsClopen W) : ∃ T, mulInvClosureNhd T W := by rcases exist_mul_closure_nhds WClopen with ⟨S, Smemnhds, mulclose⟩ rcases mem_nhds_iff.mp Smemnhds with ⟨U, UsubS, Uopen, onememU⟩ use U ∩ U⁻¹ constructor · simp [Uopen.mem_nhds onememU, inv_mem_nhds_one] · simp [inter_comm] · exact Uopen.inter Uopen.inv · exact fun a ha ↦ mulclose (mul_subset_mul_left UsubS (mul_subset_mul_left inter_subset_left ha)) @[to_additive] theorem exist_openSubgroup_sub_clopen_nhds_of_one {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] [CompactSpace G] {W : Set G} (WClopen : IsClopen W) (einW : 1 ∈ W) : ∃ H : OpenSubgroup G, (H : Set G) ⊆ W := by rcases exists_mulInvClosureNhd WClopen with ⟨V, hV⟩ let S : Subgroup G := { carrier := ⋃ n, V ^ (n + 1) mul_mem' := fun ha hb ↦ by rcases mem_iUnion.mp ha with ⟨k, hk⟩ rcases mem_iUnion.mp hb with ⟨l, hl⟩ apply mem_iUnion.mpr use k + 1 + l rw [add_assoc, pow_add] exact Set.mul_mem_mul hk hl one_mem' := by apply mem_iUnion.mpr use 0 simp [mem_of_mem_nhds hV.nhds] inv_mem' := fun ha ↦ by rcases mem_iUnion.mp ha with ⟨k, hk⟩ apply mem_iUnion.mpr use k rw [← hV.inv] simpa only [inv_pow, Set.mem_inv, inv_inv] using hk } have : IsOpen (⋃ n, V ^ (n + 1)) := by refine isOpen_iUnion (fun n ↦ ?_) rw [pow_succ] exact hV.isOpen.mul_left use ⟨S, this⟩ have mulVpow (n : ℕ) : W * V ^ (n + 1) ⊆ W := by induction n with | zero => simp [hV.mul] | succ n ih => rw [pow_succ, ← mul_assoc] exact (Set.mul_subset_mul_right ih).trans hV.mul have (n : ℕ) : V ^ (n + 1) ⊆ W * V ^ (n + 1) := by intro x xin rw [Set.mem_mul] use 1, einW, x, xin rw [one_mul] apply iUnion_subset fun i _ a ↦ mulVpow i (this i a) @[deprecated (since := "2025-05-22")] alias exist_openSubgroup_sub_clopen_nhd_of_one := exist_openSubgroup_sub_clopen_nhds_of_one @[deprecated (since := "2025-05-22")] alias _root_.IsTopologicalAddGroup.exist_openAddSubgroup_sub_clopen_nhd_of_zero := IsTopologicalAddGroup.exist_openAddSubgroup_sub_clopen_nhds_of_zero end IsTopologicalGroup
.lake/packages/mathlib/Mathlib/Topology/Algebra/Support.lean
import Mathlib.Algebra.GroupWithZero.Indicator import Mathlib.Algebra.Module.Basic import Mathlib.Algebra.Order.Group.Unbundled.Abs import Mathlib.Topology.Homeomorph.Defs import Mathlib.Topology.Separation.Hausdorff /-! # The topological support of a function In this file we define the topological support of a function `f`, `tsupport f`, as the closure of the support of `f`. Furthermore, we say that `f` has compact support if the topological support of `f` is compact. ## Main definitions * `mulTSupport` & `tsupport` * `HasCompactMulSupport` & `HasCompactSupport` ## TODO The definitions have been put in the root namespace following many other topological definitions, like `Embedding`. Since then, `Embedding` was renamed to `Topology.IsEmbedding`, so it might be worth reconsidering namespacing the definitions here. -/ open Function Set Filter Topology variable {X α α' β γ δ M R : Type*} section One variable [One α] [TopologicalSpace X] /-- The topological support of a function is the closure of its support, i.e. the closure of the set of all elements where the function is not equal to 1. -/ @[to_additive /-- The topological support of a function is the closure of its support. i.e. the closure of the set of all elements where the function is nonzero. -/] def mulTSupport (f : X → α) : Set X := closure (mulSupport f) @[to_additive] theorem subset_mulTSupport (f : X → α) : mulSupport f ⊆ mulTSupport f := subset_closure @[to_additive] theorem isClosed_mulTSupport (f : X → α) : IsClosed (mulTSupport f) := isClosed_closure @[to_additive] theorem mulTSupport_eq_empty_iff {f : X → α} : mulTSupport f = ∅ ↔ f = 1 := by rw [mulTSupport, closure_empty_iff, mulSupport_eq_empty_iff] @[to_additive] theorem image_eq_one_of_notMem_mulTSupport {f : X → α} {x : X} (hx : x ∉ mulTSupport f) : f x = 1 := mulSupport_subset_iff'.mp (subset_mulTSupport f) x hx @[deprecated (since := "2025-05-24")] alias image_eq_zero_of_nmem_tsupport := image_eq_zero_of_notMem_tsupport @[to_additive existing, deprecated (since := "2025-05-24")] alias image_eq_one_of_nmem_mulTSupport := image_eq_one_of_notMem_mulTSupport @[to_additive] theorem range_subset_insert_image_mulTSupport (f : X → α) : range f ⊆ insert 1 (f '' mulTSupport f) := by grw [← subset_mulTSupport f]; exact range_subset_insert_image_mulSupport f @[to_additive] theorem range_eq_image_mulTSupport_or (f : X → α) : range f = f '' mulTSupport f ∨ range f = insert 1 (f '' mulTSupport f) := (wcovBy_insert _ _).eq_or_eq (image_subset_range _ _) (range_subset_insert_image_mulTSupport f) theorem tsupport_mul_subset_left {α : Type*} [MulZeroClass α] {f g : X → α} : (tsupport fun x => f x * g x) ⊆ tsupport f := closure_mono (support_mul_subset_left _ _) theorem tsupport_mul_subset_right {α : Type*} [MulZeroClass α] {f g : X → α} : (tsupport fun x => f x * g x) ⊆ tsupport g := closure_mono (support_mul_subset_right _ _) end One theorem tsupport_smul_subset_left {M α} [TopologicalSpace X] [Zero M] [Zero α] [SMulWithZero M α] (f : X → M) (g : X → α) : (tsupport fun x => f x • g x) ⊆ tsupport f := closure_mono <| support_smul_subset_left f g theorem tsupport_smul_subset_right {M α} [TopologicalSpace X] [Zero α] [SMulZeroClass M α] (f : X → M) (g : X → α) : (tsupport fun x => f x • g x) ⊆ tsupport g := closure_mono <| support_smul_subset_right f g @[to_additive] theorem mulTSupport_mul [TopologicalSpace X] [MulOneClass α] {f g : X → α} : (mulTSupport fun x ↦ f x * g x) ⊆ mulTSupport f ∪ mulTSupport g := closure_minimal ((mulSupport_mul f g).trans (union_subset_union (subset_mulTSupport _) (subset_mulTSupport _))) (isClosed_closure.union isClosed_closure) section variable [TopologicalSpace α] variable [One β] variable {f : α → β} {x : α} @[to_additive] theorem notMem_mulTSupport_iff_eventuallyEq : x ∉ mulTSupport f ↔ f =ᶠ[𝓝 x] 1 := by simp_rw [mulTSupport, mem_closure_iff_nhds, not_forall, not_nonempty_iff_eq_empty, exists_prop, ← disjoint_iff_inter_eq_empty, disjoint_mulSupport_iff, eventuallyEq_iff_exists_mem] @[deprecated (since := "2025-05-23")] alias not_mem_tsupport_iff_eventuallyEq := notMem_tsupport_iff_eventuallyEq @[to_additive existing, deprecated (since := "2025-05-23")] alias not_mem_mulTSupport_iff_eventuallyEq := notMem_mulTSupport_iff_eventuallyEq @[to_additive] theorem continuous_of_mulTSupport [TopologicalSpace β] {f : α → β} (hf : ∀ x ∈ mulTSupport f, ContinuousAt f x) : Continuous f := continuous_iff_continuousAt.2 fun x => (em _).elim (hf x) fun hx => (@continuousAt_const _ _ _ _ _ 1).congr (notMem_mulTSupport_iff_eventuallyEq.mp hx).symm @[to_additive] lemma ContinuousOn.continuous_of_mulTSupport_subset [TopologicalSpace β] {f : α → β} {s : Set α} (hs : ContinuousOn f s) (h's : IsOpen s) (h''s : mulTSupport f ⊆ s) : Continuous f := continuous_of_mulTSupport fun _ hx ↦ h's.continuousOn_iff.mp hs <| h''s hx end /-! ## Functions with compact support -/ section CompactSupport variable [TopologicalSpace α] [TopologicalSpace α'] [One β] [One γ] [One δ] {g : β → γ} {f : α → β} {f₂ : α → γ} {m : β → γ → δ} /-- A function `f` *has compact multiplicative support* or is *compactly supported* if the closure of the multiplicative support of `f` is compact. In a T₂ space this is equivalent to `f` being equal to `1` outside a compact set. -/ @[to_additive /-- A function `f` *has compact support* or is *compactly supported* if the closure of the support of `f` is compact. In a T₂ space this is equivalent to `f` being equal to `0` outside a compact set. -/] def HasCompactMulSupport (f : α → β) : Prop := IsCompact (mulTSupport f) @[to_additive] theorem hasCompactMulSupport_def : HasCompactMulSupport f ↔ IsCompact (closure (mulSupport f)) := by rfl @[to_additive] theorem exists_compact_iff_hasCompactMulSupport [R1Space α] : (∃ K : Set α, IsCompact K ∧ ∀ x, x ∉ K → f x = 1) ↔ HasCompactMulSupport f := by simp_rw [← notMem_mulSupport, ← mem_compl_iff, ← subset_def, compl_subset_compl, hasCompactMulSupport_def, exists_isCompact_superset_iff] namespace HasCompactMulSupport variable {K : Set α} @[to_additive] theorem intro [R1Space α] (hK : IsCompact K) (hfK : ∀ x, x ∉ K → f x = 1) : HasCompactMulSupport f := exists_compact_iff_hasCompactMulSupport.mp ⟨K, hK, hfK⟩ @[to_additive] theorem intro' (hK : IsCompact K) (h'K : IsClosed K) (hfK : ∀ x, x ∉ K → f x = 1) : HasCompactMulSupport f := by have : mulTSupport f ⊆ K := by rw [← h'K.closure_eq] apply closure_mono (mulSupport_subset_iff'.2 hfK) exact IsCompact.of_isClosed_subset hK ( isClosed_mulTSupport f) this @[to_additive] theorem of_mulSupport_subset_isCompact [R1Space α] (hK : IsCompact K) (h : mulSupport f ⊆ K) : HasCompactMulSupport f := hK.closure_of_subset h @[to_additive] theorem isCompact (hf : HasCompactMulSupport f) : IsCompact (mulTSupport f) := hf @[to_additive] theorem _root_.hasCompactMulSupport_iff_eventuallyEq : HasCompactMulSupport f ↔ f =ᶠ[coclosedCompact α] 1 := mem_coclosedCompact_iff.symm @[to_additive] theorem _root_.isCompact_range_of_mulSupport_subset_isCompact [TopologicalSpace β] (hf : Continuous f) (hk : IsCompact K) (h'f : mulSupport f ⊆ K) : IsCompact (range f) := by rcases range_eq_image_or_of_mulSupport_subset h'f with h2 | h2 <;> rw [h2] exacts [hk.image hf, (hk.image hf).insert 1] @[to_additive] theorem isCompact_range [TopologicalSpace β] (h : HasCompactMulSupport f) (hf : Continuous f) : IsCompact (range f) := isCompact_range_of_mulSupport_subset_isCompact hf h (subset_mulTSupport f) @[to_additive] theorem mono' {f' : α → γ} (hf : HasCompactMulSupport f) (hff' : mulSupport f' ⊆ mulTSupport f) : HasCompactMulSupport f' := IsCompact.of_isClosed_subset hf isClosed_closure <| closure_minimal hff' isClosed_closure @[to_additive] theorem mono {f' : α → γ} (hf : HasCompactMulSupport f) (hff' : mulSupport f' ⊆ mulSupport f) : HasCompactMulSupport f' := hf.mono' <| hff'.trans subset_closure @[to_additive] theorem comp_left (hf : HasCompactMulSupport f) (hg : g 1 = 1) : HasCompactMulSupport (g ∘ f) := hf.mono <| mulSupport_comp_subset hg f @[to_additive] theorem _root_.hasCompactMulSupport_comp_left (hg : ∀ {x}, g x = 1 ↔ x = 1) : HasCompactMulSupport (g ∘ f) ↔ HasCompactMulSupport f := by simp_rw [hasCompactMulSupport_def, mulSupport_comp_eq g (@hg) f] @[to_additive] theorem comp_isClosedEmbedding (hf : HasCompactMulSupport f) {g : α' → α} (hg : IsClosedEmbedding g) : HasCompactMulSupport (f ∘ g) := by rw [hasCompactMulSupport_def, Function.mulSupport_comp_eq_preimage] refine IsCompact.of_isClosed_subset (hg.isCompact_preimage hf) isClosed_closure ?_ rw [hg.isEmbedding.closure_eq_preimage_closure_image] exact preimage_mono (closure_mono <| image_preimage_subset _ _) @[to_additive] theorem comp₂_left (hf : HasCompactMulSupport f) (hf₂ : HasCompactMulSupport f₂) (hm : m 1 1 = 1) : HasCompactMulSupport fun x => m (f x) (f₂ x) := by rw [hasCompactMulSupport_iff_eventuallyEq] at hf hf₂ ⊢ filter_upwards [hf, hf₂] with x hx hx₂ simp_rw [hx, hx₂, Pi.one_apply, hm] @[to_additive] lemma isCompact_preimage [TopologicalSpace β] {K : Set β} (h'f : HasCompactMulSupport f) (hf : Continuous f) (hk : IsClosed K) (h'k : 1 ∉ K) : IsCompact (f ⁻¹' K) := by apply IsCompact.of_isClosed_subset h'f (hk.preimage hf) (fun x hx ↦ ?_) apply subset_mulTSupport aesop variable [T2Space α'] section variable (hf : HasCompactMulSupport f) {g : α → α'} (cont : Continuous g) include hf cont @[to_additive] theorem mulTSupport_extend_one_subset : mulTSupport (g.extend f 1) ⊆ g '' mulTSupport f := (hf.image cont).isClosed.closure_subset_iff.mpr <| mulSupport_extend_one_subset.trans (image_mono subset_closure) @[to_additive] theorem extend_one : HasCompactMulSupport (g.extend f 1) := HasCompactMulSupport.of_mulSupport_subset_isCompact (hf.image cont) (subset_closure.trans <| hf.mulTSupport_extend_one_subset cont) @[to_additive] theorem mulTSupport_extend_one (inj : g.Injective) : mulTSupport (g.extend f 1) = g '' mulTSupport f := (hf.mulTSupport_extend_one_subset cont).antisymm <| (image_closure_subset_closure_image cont).trans (closure_mono (mulSupport_extend_one inj).superset) end @[to_additive] theorem continuous_extend_one [TopologicalSpace β] {U : Set α'} (hU : IsOpen U) {f : U → β} (cont : Continuous f) (supp : HasCompactMulSupport f) : Continuous (Subtype.val.extend f 1) := continuous_of_mulTSupport fun x h ↦ by rw [show x = ↑(⟨x, Subtype.coe_image_subset _ _ (supp.mulTSupport_extend_one_subset continuous_subtype_val h)⟩ : U) by rfl, ← (hU.isOpenEmbedding_subtypeVal).continuousAt_iff, extend_comp Subtype.val_injective] exact cont.continuousAt /-- If `f` has compact multiplicative support, then `f` tends to 1 at infinity. -/ @[to_additive /-- If `f` has compact support, then `f` tends to zero at infinity. -/] theorem is_one_at_infty {f : α → γ} [TopologicalSpace γ] (h : HasCompactMulSupport f) : Tendsto f (cocompact α) (𝓝 1) := by intro N hN rw [mem_map, mem_cocompact'] refine ⟨mulTSupport f, h.isCompact, ?_⟩ rw [compl_subset_comm] intro v hv rw [mem_preimage, image_eq_one_of_notMem_mulTSupport hv] exact mem_of_mem_nhds hN end HasCompactMulSupport section Compact variable [CompactSpace α] /-- In a compact space `α`, any function has compact support. -/ @[to_additive] theorem HasCompactMulSupport.of_compactSpace (f : α → γ) : HasCompactMulSupport f := IsCompact.of_isClosed_subset isCompact_univ (isClosed_mulTSupport f) (Set.subset_univ (mulTSupport f)) end Compact end CompactSupport /-! ## Functions with compact support: algebraic operations -/ section CompactSupport2 section Monoid variable [TopologicalSpace α] [MulOneClass β] variable {f f' : α → β} @[to_additive] theorem HasCompactMulSupport.mul (hf : HasCompactMulSupport f) (hf' : HasCompactMulSupport f') : HasCompactMulSupport (f * f') := hf.comp₂_left hf' (mul_one 1) @[to_additive, simp] protected lemma HasCompactMulSupport.one {α β : Type*} [TopologicalSpace α] [One β] : HasCompactMulSupport (1 : α → β) := by simp [HasCompactMulSupport, mulTSupport] end Monoid section DivisionMonoid @[to_additive] protected lemma HasCompactMulSupport.inv {α β : Type*} [TopologicalSpace α] [DivisionMonoid β] {f : α → β} (hf : HasCompactMulSupport f) : HasCompactMulSupport (f⁻¹) := by simpa only [HasCompactMulSupport, mulTSupport, mulSupport_inv] using hf @[deprecated (since := "2025-07-31")] alias HasCompactSupport.neg' := HasCompactSupport.neg @[deprecated (since := "2025-07-31")] alias HasCompactMulSupport.inv' := HasCompactMulSupport.inv @[to_additive] theorem HasCompactSupport.div {α β : Type*} [TopologicalSpace α] [DivisionMonoid β] {f f' : α → β} (hf : HasCompactMulSupport f) (hf' : HasCompactMulSupport f') : HasCompactMulSupport (f / f') := div_eq_mul_inv f f' ▸ hf.mul hf'.inv end DivisionMonoid section SMulZeroClass variable [TopologicalSpace α] [Zero M] [SMulZeroClass R M] variable {f : α → R} {f' : α → M} theorem HasCompactSupport.smul_left (hf : HasCompactSupport f') : HasCompactSupport (f • f') := by rw [hasCompactSupport_iff_eventuallyEq] at hf ⊢ exact hf.mono fun x hx => by simp_rw [Pi.smul_apply', hx, Pi.zero_apply, smul_zero] end SMulZeroClass section SMulWithZero variable [TopologicalSpace α] [Zero R] [Zero M] [SMulWithZero R M] variable {f : α → R} {f' : α → M} theorem HasCompactSupport.smul_right (hf : HasCompactSupport f) : HasCompactSupport (f • f') := by rw [hasCompactSupport_iff_eventuallyEq] at hf ⊢ exact hf.mono fun x hx => by simp_rw [Pi.smul_apply', hx, Pi.zero_apply, zero_smul] end SMulWithZero section MulZeroClass variable [TopologicalSpace α] [MulZeroClass β] variable {f f' : α → β} theorem HasCompactSupport.mul_right (hf : HasCompactSupport f) : HasCompactSupport (f * f') := by rw [hasCompactSupport_iff_eventuallyEq] at hf ⊢ exact hf.mono fun x hx => by simp_rw [Pi.mul_apply, hx, Pi.zero_apply, zero_mul] theorem HasCompactSupport.mul_left (hf : HasCompactSupport f') : HasCompactSupport (f * f') := by rw [hasCompactSupport_iff_eventuallyEq] at hf ⊢ exact hf.mono fun x hx => by simp_rw [Pi.mul_apply, hx, Pi.zero_apply, mul_zero] end MulZeroClass section OrderedAddGroup variable [TopologicalSpace α] [AddGroup β] [Lattice β] [AddLeftMono β] protected theorem HasCompactSupport.abs {f : α → β} (hf : HasCompactSupport f) : HasCompactSupport |f| := hf.comp_left (g := abs) abs_zero end OrderedAddGroup end CompactSupport2 section LocallyFinite variable {ι : Type*} [TopologicalSpace X] -- TODO: reformulate for any locally finite family of sets /-- If a family of functions `f` has locally-finite multiplicative support, subordinate to a family of open sets, then for any point we can find a neighbourhood on which only finitely-many members of `f` are not equal to 1. -/ @[to_additive /-- If a family of functions `f` has locally-finite support, subordinate to a family of open sets, then for any point we can find a neighbourhood on which only finitely-many members of `f` are non-zero. -/] theorem LocallyFinite.exists_finset_nhds_mulSupport_subset {U : ι → Set X} [One R] {f : ι → X → R} (hlf : LocallyFinite fun i => mulSupport (f i)) (hso : ∀ i, mulTSupport (f i) ⊆ U i) (ho : ∀ i, IsOpen (U i)) (x : X) : ∃ (is : Finset ι), ∃ n, n ∈ 𝓝 x ∧ (n ⊆ ⋂ i ∈ is, U i) ∧ ∀ z ∈ n, (mulSupport fun i => f i z) ⊆ is := by obtain ⟨n, hn, hnf⟩ := hlf x classical let is := {i ∈ hnf.toFinset | x ∈ U i} let js := {j ∈ hnf.toFinset | x ∉ U j} refine ⟨is, (n ∩ ⋂ j ∈ js, (mulTSupport (f j))ᶜ) ∩ ⋂ i ∈ is, U i, inter_mem (inter_mem hn ?_) ?_, inter_subset_right, fun z hz => ?_⟩ · exact (biInter_finset_mem js).mpr fun j hj => IsClosed.compl_mem_nhds (isClosed_mulTSupport _) (Set.notMem_subset (hso j) (Finset.mem_filter.mp hj).2) · exact (biInter_finset_mem is).mpr fun i hi => (ho i).mem_nhds (Finset.mem_filter.mp hi).2 · have hzn : z ∈ n := by rw [inter_assoc] at hz exact mem_of_mem_inter_left hz replace hz := mem_of_mem_inter_right (mem_of_mem_inter_left hz) simp only [js, Finset.mem_filter, Finite.mem_toFinset, mem_setOf_eq, mem_iInter, and_imp] at hz suffices (mulSupport fun i => f i z) ⊆ hnf.toFinset by refine hnf.toFinset.subset_coe_filter_of_subset_forall _ this fun i hi => ?_ specialize hz i ⟨z, ⟨hi, hzn⟩⟩ contrapose hz simp [hz, subset_mulTSupport (f i) hi] intro i hi simp only [Finite.coe_toFinset, mem_setOf_eq] exact ⟨z, ⟨hi, hzn⟩⟩ @[deprecated (since := "2025-05-22")] alias LocallyFinite.exists_finset_nhd_mulSupport_subset := LocallyFinite.exists_finset_nhds_mulSupport_subset @[deprecated (since := "2025-05-22")] alias LocallyFinite.exists_finset_nhd_support_subset := LocallyFinite.exists_finset_nhds_support_subset @[to_additive] theorem locallyFinite_mulSupport_iff [One M] {f : ι → X → M} : (LocallyFinite fun i ↦ mulSupport <| f i) ↔ LocallyFinite fun i ↦ mulTSupport <| f i := ⟨LocallyFinite.closure, fun H ↦ H.subset fun _ ↦ subset_closure⟩ theorem LocallyFinite.smul_left [Zero R] [Zero M] [SMulWithZero R M] {s : ι → X → R} (h : LocallyFinite fun i ↦ support <| s i) (f : ι → X → M) : LocallyFinite fun i ↦ support <| s i • f i := h.subset fun i x ↦ mt <| fun h ↦ by rw [Pi.smul_apply', h, zero_smul] theorem LocallyFinite.smul_right [Zero M] [SMulZeroClass R M] {f : ι → X → M} (h : LocallyFinite fun i ↦ support <| f i) (s : ι → X → R) : LocallyFinite fun i ↦ support <| s i • f i := h.subset fun i x ↦ mt <| fun h ↦ by rw [Pi.smul_apply', h, smul_zero] end LocallyFinite section Homeomorph variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] @[to_additive] theorem HasCompactMulSupport.comp_homeomorph {M} [One M] {f : Y → M} (hf : HasCompactMulSupport f) (φ : X ≃ₜ Y) : HasCompactMulSupport (f ∘ φ) := hf.comp_isClosedEmbedding φ.isClosedEmbedding end Homeomorph
.lake/packages/mathlib/Mathlib/Topology/Algebra/UniformRing.lean
import Mathlib.Algebra.Algebra.Defs import Mathlib.Algebra.Module.Submodule.Lattice import Mathlib.Algebra.Ring.TransferInstance import Mathlib.Topology.Algebra.GroupCompletion import Mathlib.Topology.Algebra.Ring.Ideal import Mathlib.Topology.Algebra.IsUniformGroup.Basic /-! # Completion of topological rings: This file endows the completion of a topological ring with a ring structure. More precisely, the instance `UniformSpace.Completion.ring` builds a ring structure on the completion of a ring endowed with a compatible uniform structure in the sense of `IsUniformAddGroup`. There is also a commutative version when the original ring is commutative. Moreover, if a topological ring is an algebra over a commutative semiring, then so is its `UniformSpace.Completion`. The last part of the file builds a ring structure on the biggest separated quotient of a ring. ## Main declarations: Beyond the instances explained above (that don't have to be explicitly invoked), the main constructions deal with continuous ring morphisms. * `UniformSpace.Completion.extensionHom`: extends a continuous ring morphism from `R` to a complete separated group `S` to `Completion R`. * `UniformSpace.Completion.mapRingHom`: promotes a continuous ring morphism from `R` to `S` into a continuous ring morphism from `Completion R` to `Completion S`. TODO: Generalise the results here from the concrete `Completion` to any `AbstractCompletion`. -/ noncomputable section universe u namespace UniformSpace.Completion open IsDenseInducing UniformSpace Function section one_and_mul variable (α : Type*) [Ring α] [UniformSpace α] instance one : One (Completion α) := ⟨(1 : α)⟩ instance mul : Mul (Completion α) := ⟨curry <| (isDenseInducing_coe.prodMap isDenseInducing_coe).extend ((↑) ∘ uncurry (· * ·))⟩ @[norm_cast] theorem coe_one : ((1 : α) : Completion α) = 1 := rfl @[simp] lemma coe_eq_one_iff [T0Space α] {x : α} : (x : Completion α) = 1 ↔ x = 1 := Completion.coe_inj end one_and_mul variable {α : Type*} [Ring α] [UniformSpace α] [IsTopologicalRing α] @[norm_cast] theorem coe_mul (a b : α) : ((a * b : α) : Completion α) = a * b := ((isDenseInducing_coe.prodMap isDenseInducing_coe).extend_eq ((continuous_coe α).comp (@continuous_mul α _ _ _)) (a, b)).symm variable [IsUniformAddGroup α] instance : ContinuousMul (Completion α) where continuous_mul := by let m := (AddMonoidHom.mul : α →+ α →+ α).compr₂ toCompl have : Continuous fun p : α × α => m p.1 p.2 := (continuous_coe α).comp continuous_mul have di : IsDenseInducing (toCompl : α → Completion α) := isDenseInducing_coe exact (di.extend_Z_bilin di this :) instance ring : Ring (Completion α) := { AddMonoidWithOne.unary, (inferInstanceAs (AddCommGroup (Completion α))), (inferInstanceAs (Mul (Completion α))), (inferInstanceAs (One (Completion α))) with zero_mul := fun a => Completion.induction_on a (isClosed_eq (continuous_const.mul continuous_id) continuous_const) fun a => by rw [← coe_zero, ← coe_mul, zero_mul] mul_zero := fun a => Completion.induction_on a (isClosed_eq (continuous_id.mul continuous_const) continuous_const) fun a => by rw [← coe_zero, ← coe_mul, mul_zero] one_mul := fun a => Completion.induction_on a (isClosed_eq (continuous_const.mul continuous_id) continuous_id) fun a => by rw [← coe_one, ← coe_mul, one_mul] mul_one := fun a => Completion.induction_on a (isClosed_eq (continuous_id.mul continuous_const) continuous_id) fun a => by rw [← coe_one, ← coe_mul, mul_one] mul_assoc := fun a b c => Completion.induction_on₃ a b c (isClosed_eq ((continuous_fst.mul (continuous_fst.comp continuous_snd)).mul (continuous_snd.comp continuous_snd)) (continuous_fst.mul ((continuous_fst.comp continuous_snd).mul (continuous_snd.comp continuous_snd)))) fun a b c => by rw [← coe_mul, ← coe_mul, ← coe_mul, ← coe_mul, mul_assoc] left_distrib := fun a b c => Completion.induction_on₃ a b c (isClosed_eq (continuous_fst.mul (Continuous.add (continuous_fst.comp continuous_snd) (continuous_snd.comp continuous_snd))) (Continuous.add (continuous_fst.mul (continuous_fst.comp continuous_snd)) (continuous_fst.mul (continuous_snd.comp continuous_snd)))) fun a b c => by rw [← coe_add, ← coe_mul, ← coe_mul, ← coe_mul, ← coe_add, mul_add] right_distrib := fun a b c => Completion.induction_on₃ a b c (isClosed_eq ((Continuous.add continuous_fst (continuous_fst.comp continuous_snd)).mul (continuous_snd.comp continuous_snd)) (Continuous.add (continuous_fst.mul (continuous_snd.comp continuous_snd)) ((continuous_fst.comp continuous_snd).mul (continuous_snd.comp continuous_snd)))) fun a b c => by rw [← coe_add, ← coe_mul, ← coe_mul, ← coe_mul, ← coe_add, add_mul] } /-- The map from a uniform ring to its completion, as a ring homomorphism. -/ def coeRingHom : α →+* Completion α where toFun := (↑) map_one' := coe_one α map_zero' := coe_zero map_add' := coe_add map_mul' := coe_mul theorem continuous_coeRingHom : Continuous (coeRingHom : α → Completion α) := continuous_coe α variable {β : Type u} [UniformSpace β] [Ring β] [IsUniformAddGroup β] [IsTopologicalRing β] (f : α →+* β) (hf : Continuous f) /-- The completion extension as a ring morphism. -/ def extensionHom [CompleteSpace β] [T0Space β] : Completion α →+* β := have hf' : Continuous (f : α →+ β) := hf -- helping the elaborator have hf : UniformContinuous f := uniformContinuous_addMonoidHom_of_continuous hf' { toFun := Completion.extension f map_zero' := by simp_rw [← coe_zero, extension_coe hf, f.map_zero] map_add' := fun a b => Completion.induction_on₂ a b (isClosed_eq (continuous_extension.comp continuous_add) ((continuous_extension.comp continuous_fst).add (continuous_extension.comp continuous_snd))) fun a b => by simp_rw [← coe_add, extension_coe hf, f.map_add] map_one' := by rw [← coe_one, extension_coe hf, f.map_one] map_mul' := fun a b => Completion.induction_on₂ a b (isClosed_eq (continuous_extension.comp continuous_mul) ((continuous_extension.comp continuous_fst).mul (continuous_extension.comp continuous_snd))) fun a b => by simp_rw [← coe_mul, extension_coe hf, f.map_mul] } theorem extensionHom_coe [CompleteSpace β] [T0Space β] (a : α) : Completion.extensionHom f hf a = f a := by simp only [Completion.extensionHom, RingHom.coe_mk, MonoidHom.coe_mk, OneHom.coe_mk, UniformSpace.Completion.extension_coe <| uniformContinuous_addMonoidHom_of_continuous hf] instance topologicalRing : IsTopologicalRing (Completion α) where continuous_add := continuous_add continuous_mul := continuous_mul /-- The completion map as a ring morphism. -/ def mapRingHom (hf : Continuous f) : Completion α →+* Completion β := extensionHom (coeRingHom.comp f) (continuous_coeRingHom.comp hf) theorem mapRingHom_apply {x : UniformSpace.Completion α} : UniformSpace.Completion.mapRingHom f hf x = UniformSpace.Completion.map f x := rfl variable {f} theorem mapRingHom_coe (hf : UniformContinuous f) (a : α) : mapRingHom f hf.continuous a = f a := by rw [mapRingHom_apply, map_coe hf] section Algebra variable (A : Type*) [Ring A] [UniformSpace A] [IsUniformAddGroup A] [IsTopologicalRing A] (R : Type*) [CommSemiring R] [Algebra R A] [UniformContinuousConstSMul R A] @[simp] theorem map_smul_eq_mul_coe (r : R) : Completion.map (r • ·) = ((algebraMap R A r : Completion A) * ·) := by ext x refine Completion.induction_on x ?_ fun a => ?_ · exact isClosed_eq Completion.continuous_map (continuous_mul_left _) · simp_rw [map_coe (uniformContinuous_const_smul r) a, Algebra.smul_def, coe_mul] instance algebra : Algebra R (Completion A) where algebraMap := (UniformSpace.Completion.coeRingHom : A →+* Completion A).comp (algebraMap R A) commutes' := fun r x => Completion.induction_on x (isClosed_eq (continuous_mul_left _) (continuous_mul_right _)) fun a => by simpa only [coe_mul] using congr_arg ((↑) : A → Completion A) (Algebra.commutes r a) smul_def' := fun r x => congr_fun (map_smul_eq_mul_coe A R r) x theorem algebraMap_def (r : R) : algebraMap R (Completion A) r = (algebraMap R A r : Completion A) := rfl end Algebra section CommRing variable (R : Type*) [CommRing R] [UniformSpace R] [IsUniformAddGroup R] [IsTopologicalRing R] instance commRing : CommRing (Completion R) := { Completion.ring with mul_comm := fun a b => Completion.induction_on₂ a b (isClosed_eq (continuous_fst.mul continuous_snd) (continuous_snd.mul continuous_fst)) fun a b => by rw [← coe_mul, ← coe_mul, mul_comm] } /-- A shortcut instance for the common case -/ instance algebra' : Algebra R (Completion R) := by infer_instance end CommRing end UniformSpace.Completion namespace UniformSpace variable {α : Type*} -- TODO: move (some of) these results to the file about topological rings theorem inseparableSetoid_ring (α) [Ring α] [TopologicalSpace α] [IsTopologicalRing α] : inseparableSetoid α = Submodule.quotientRel (Ideal.closure ⊥) := Setoid.ext fun x y => addGroup_inseparable_iff.trans <| .trans (by rfl) (Submodule.quotientRel_def _).symm /-- Given a topological ring `α` equipped with a uniform structure that makes subtraction uniformly continuous, get an homeomorphism between the separated quotient of `α` and the quotient ring corresponding to the closure of zero. -/ def sepQuotHomeomorphRingQuot (α) [CommRing α] [TopologicalSpace α] [IsTopologicalRing α] : SeparationQuotient α ≃ₜ α ⧸ (⊥ : Ideal α).closure where toEquiv := Quotient.congrRight fun x y => by rw [inseparableSetoid_ring] continuous_toFun := continuous_id.quotient_map' <| by rw [inseparableSetoid_ring]; exact fun _ _ ↦ id continuous_invFun := continuous_id.quotient_map' <| by rw [inseparableSetoid_ring]; exact fun _ _ ↦ id instance commRing [CommRing α] [TopologicalSpace α] [IsTopologicalRing α] : CommRing (SeparationQuotient α) := (sepQuotHomeomorphRingQuot _).commRing /-- Given a topological ring `α` equipped with a uniform structure that makes subtraction uniformly continuous, get an equivalence between the separated quotient of `α` and the quotient ring corresponding to the closure of zero. -/ def sepQuotRingEquivRingQuot (α) [CommRing α] [TopologicalSpace α] [IsTopologicalRing α] : SeparationQuotient α ≃+* α ⧸ (⊥ : Ideal α).closure := (sepQuotHomeomorphRingQuot _).ringEquiv instance topologicalRing [CommRing α] [TopologicalSpace α] [IsTopologicalRing α] : IsTopologicalRing (SeparationQuotient α) where toContinuousAdd := (sepQuotHomeomorphRingQuot α).isInducing.continuousAdd (sepQuotRingEquivRingQuot α) toContinuousMul := (sepQuotHomeomorphRingQuot α).isInducing.continuousMul (sepQuotRingEquivRingQuot α) toContinuousNeg := (sepQuotHomeomorphRingQuot α).isInducing.continuousNeg <| map_neg (sepQuotRingEquivRingQuot α) end UniformSpace section UniformExtension variable {α : Type*} [UniformSpace α] [Semiring α] variable {β : Type*} [UniformSpace β] [Semiring β] [IsTopologicalSemiring β] variable {γ : Type*} [UniformSpace γ] [Semiring γ] [IsTopologicalSemiring γ] variable [T2Space γ] [CompleteSpace γ] /-- The dense inducing extension as a ring homomorphism. -/ noncomputable def IsDenseInducing.extendRingHom {i : α →+* β} {f : α →+* γ} (ue : IsUniformInducing i) (dr : DenseRange i) (hf : UniformContinuous f) : β →+* γ where toFun := (ue.isDenseInducing dr).extend f map_one' := by convert IsDenseInducing.extend_eq (ue.isDenseInducing dr) hf.continuous 1 exacts [i.map_one.symm, f.map_one.symm] map_zero' := by convert IsDenseInducing.extend_eq (ue.isDenseInducing dr) hf.continuous 0 <;> simp only [map_zero] map_add' := by have h := (uniformContinuous_uniformly_extend ue dr hf).continuous refine fun x y => DenseRange.induction_on₂ dr ?_ (fun a b => ?_) x y · exact isClosed_eq (Continuous.comp h continuous_add) ((h.comp continuous_fst).add (h.comp continuous_snd)) · simp_rw [← i.map_add, IsDenseInducing.extend_eq (ue.isDenseInducing dr) hf.continuous _, ← f.map_add] map_mul' := by have h := (uniformContinuous_uniformly_extend ue dr hf).continuous refine fun x y => DenseRange.induction_on₂ dr ?_ (fun a b => ?_) x y · exact isClosed_eq (Continuous.comp h continuous_mul) ((h.comp continuous_fst).mul (h.comp continuous_snd)) · simp_rw [← i.map_mul, IsDenseInducing.extend_eq (ue.isDenseInducing dr) hf.continuous _, ← f.map_mul] end UniformExtension
.lake/packages/mathlib/Mathlib/Topology/Algebra/Star.lean
import Mathlib.Topology.Algebra.Constructions import Mathlib.Topology.ContinuousMap.Defs import Mathlib.Algebra.Star.Basic /-! # Continuity of `star` This file defines the `ContinuousStar` typeclass, along with instances on `Pi`, `Prod`, `MulOpposite`, and `Units`. -/ open Filter Topology /-- Basic hypothesis to talk about a topological space with a continuous `star` operator. -/ class ContinuousStar (R : Type*) [TopologicalSpace R] [Star R] : Prop where /-- The `star` operator is continuous. -/ continuous_star : Continuous (star : R → R) export ContinuousStar (continuous_star) section Continuity variable {α R : Type*} [TopologicalSpace R] [Star R] [ContinuousStar R] theorem continuousOn_star {s : Set R} : ContinuousOn star s := continuous_star.continuousOn theorem continuousWithinAt_star {s : Set R} {x : R} : ContinuousWithinAt star s x := continuous_star.continuousWithinAt theorem continuousAt_star {x : R} : ContinuousAt star x := continuous_star.continuousAt theorem tendsto_star (a : R) : Tendsto star (𝓝 a) (𝓝 (star a)) := continuousAt_star theorem Filter.Tendsto.star {f : α → R} {l : Filter α} {y : R} (h : Tendsto f l (𝓝 y)) : Tendsto (fun x => star (f x)) l (𝓝 (star y)) := (continuous_star.tendsto y).comp h variable [TopologicalSpace α] {f : α → R} {s : Set α} {x : α} @[continuity, fun_prop] theorem Continuous.star (hf : Continuous f) : Continuous fun x => star (f x) := continuous_star.comp hf @[fun_prop] theorem ContinuousAt.star (hf : ContinuousAt f x) : ContinuousAt (fun x => star (f x)) x := continuousAt_star.comp hf @[fun_prop] theorem ContinuousOn.star (hf : ContinuousOn f s) : ContinuousOn (fun x => star (f x)) s := continuous_star.comp_continuousOn hf theorem ContinuousWithinAt.star (hf : ContinuousWithinAt f s x) : ContinuousWithinAt (fun x => star (f x)) s x := Filter.Tendsto.star hf /-- The star operation bundled as a continuous map. -/ @[simps] def starContinuousMap : C(R, R) := ⟨star, continuous_star⟩ end Continuity section Instances variable {R S ι : Type*} instance [Star R] [Star S] [TopologicalSpace R] [TopologicalSpace S] [ContinuousStar R] [ContinuousStar S] : ContinuousStar (R × S) := ⟨(continuous_star.comp continuous_fst).prodMk (continuous_star.comp continuous_snd)⟩ instance {C : ι → Type*} [∀ i, TopologicalSpace (C i)] [∀ i, Star (C i)] [∀ i, ContinuousStar (C i)] : ContinuousStar (∀ i, C i) where continuous_star := continuous_pi fun i => Continuous.star (continuous_apply i) instance [Star R] [TopologicalSpace R] [ContinuousStar R] : ContinuousStar Rᵐᵒᵖ := ⟨MulOpposite.continuous_op.comp <| MulOpposite.continuous_unop.star⟩ instance [Monoid R] [StarMul R] [TopologicalSpace R] [ContinuousStar R] : ContinuousStar Rˣ := ⟨continuous_induced_rng.2 Units.continuous_embedProduct.star⟩ end Instances
.lake/packages/mathlib/Mathlib/Topology/Algebra/ConstMulAction.lean
import Mathlib.Algebra.Group.Pointwise.Set.Lattice import Mathlib.Algebra.GroupWithZero.Action.Pointwise.Set import Mathlib.Algebra.Module.ULift import Mathlib.GroupTheory.GroupAction.Defs import Mathlib.Topology.Algebra.Constructions import Mathlib.Topology.Algebra.Support /-! # Monoid actions continuous in the second variable In this file we define class `ContinuousConstSMul`. We say `ContinuousConstSMul Γ T` if `Γ` acts on `T` and for each `γ`, the map `x ↦ γ • x` is continuous. (This differs from `ContinuousSMul`, which requires simultaneous continuity in both variables.) ## Main definitions * `ContinuousConstSMul Γ T` : typeclass saying that the map `x ↦ γ • x` is continuous on `T`; * `ProperlyDiscontinuousSMul`: says that the scalar multiplication `(•) : Γ → T → T` is properly discontinuous, that is, for any pair of compact sets `K, L` in `T`, only finitely many `γ:Γ` move `K` to have nontrivial intersection with `L`. * `Homeomorph.smul`: scalar multiplication by an element of a group `Γ` acting on `T` is a homeomorphism of `T`. *`Homeomorph.smulOfNeZero`: if a group with zero `G₀` (e.g., a field) acts on `X` and `c : G₀` is a nonzero element of `G₀`, then scalar multiplication by `c` is a homeomorphism of `X`; * `Homeomorph.smul`: scalar multiplication by an element of a group `G` acting on `X` is a homeomorphism of `X`. ## Main results * `isOpenMap_quotient_mk'_mul` : The quotient map by a group action is open. * `t2Space_of_properlyDiscontinuousSMul_of_t2Space` : The quotient by a discontinuous group action of a locally compact t2 space is t2. ## Tags Hausdorff, discrete group, properly discontinuous, quotient space -/ assert_not_exists IsOrderedRing open Topology Pointwise Filter Set TopologicalSpace /-- Class `ContinuousConstSMul Γ T` says that the scalar multiplication `(•) : Γ → T → T` is continuous in the second argument. We use the same class for all kinds of multiplicative actions, including (semi)modules and algebras. Note that both `ContinuousConstSMul α α` and `ContinuousConstSMul αᵐᵒᵖ α` are weaker versions of `ContinuousMul α`. -/ class ContinuousConstSMul (Γ : Type*) (T : Type*) [TopologicalSpace T] [SMul Γ T] : Prop where /-- The scalar multiplication `(•) : Γ → T → T` is continuous in the second argument. -/ continuous_const_smul : ∀ γ : Γ, Continuous fun x : T => γ • x /-- Class `ContinuousConstVAdd Γ T` says that the additive action `(+ᵥ) : Γ → T → T` is continuous in the second argument. We use the same class for all kinds of additive actions, including (semi)modules and algebras. Note that both `ContinuousConstVAdd α α` and `ContinuousConstVAdd αᵐᵒᵖ α` are weaker versions of `ContinuousVAdd α`. -/ class ContinuousConstVAdd (Γ : Type*) (T : Type*) [TopologicalSpace T] [VAdd Γ T] : Prop where /-- The additive action `(+ᵥ) : Γ → T → T` is continuous in the second argument. -/ continuous_const_vadd : ∀ γ : Γ, Continuous fun x : T => γ +ᵥ x attribute [to_additive] ContinuousConstSMul export ContinuousConstSMul (continuous_const_smul) export ContinuousConstVAdd (continuous_const_vadd) variable {M α β : Type*} section SMul variable [TopologicalSpace α] [SMul M α] [ContinuousConstSMul M α] @[to_additive] instance : ContinuousConstSMul (ULift M) α := ⟨fun γ ↦ continuous_const_smul (ULift.down γ)⟩ @[to_additive] theorem Filter.Tendsto.const_smul {f : β → α} {l : Filter β} {a : α} (hf : Tendsto f l (𝓝 a)) (c : M) : Tendsto (fun x => c • f x) l (𝓝 (c • a)) := ((continuous_const_smul _).tendsto _).comp hf variable [TopologicalSpace β] {g : β → α} {b : β} {s : Set β} @[to_additive] nonrec theorem ContinuousWithinAt.const_smul (hg : ContinuousWithinAt g s b) (c : M) : ContinuousWithinAt (fun x => c • g x) s b := hg.const_smul c @[to_additive (attr := fun_prop)] nonrec theorem ContinuousAt.const_smul (hg : ContinuousAt g b) (c : M) : ContinuousAt (fun x => c • g x) b := hg.const_smul c @[to_additive (attr := fun_prop)] theorem ContinuousOn.const_smul (hg : ContinuousOn g s) (c : M) : ContinuousOn (fun x => c • g x) s := fun x hx => (hg x hx).const_smul c @[to_additive (attr := continuity, fun_prop)] theorem Continuous.const_smul (hg : Continuous g) (c : M) : Continuous fun x => c • g x := (continuous_const_smul _).comp hg /-- If a scalar is central, then its right action is continuous when its left action is. -/ @[to_additive /-- If an additive action is central, then its right action is continuous when its left action is. -/] instance ContinuousConstSMul.op [SMul Mᵐᵒᵖ α] [IsCentralScalar M α] : ContinuousConstSMul Mᵐᵒᵖ α := ⟨MulOpposite.rec' fun c => by simpa only [op_smul_eq_smul] using continuous_const_smul c⟩ @[to_additive] instance MulOpposite.continuousConstSMul : ContinuousConstSMul M αᵐᵒᵖ := ⟨fun c => MulOpposite.continuous_op.comp <| MulOpposite.continuous_unop.const_smul c⟩ @[to_additive] instance : ContinuousConstSMul M αᵒᵈ := ‹ContinuousConstSMul M α› @[to_additive] instance OrderDual.continuousConstSMul' : ContinuousConstSMul Mᵒᵈ α := ‹ContinuousConstSMul M α› @[to_additive] instance Prod.continuousConstSMul [SMul M β] [ContinuousConstSMul M β] : ContinuousConstSMul M (α × β) := ⟨fun _ => (continuous_fst.const_smul _).prodMk (continuous_snd.const_smul _)⟩ @[to_additive] instance {ι : Type*} {γ : ι → Type*} [∀ i, TopologicalSpace (γ i)] [∀ i, SMul M (γ i)] [∀ i, ContinuousConstSMul M (γ i)] : ContinuousConstSMul M (∀ i, γ i) := ⟨fun _ => continuous_pi fun i => (continuous_apply i).const_smul _⟩ @[to_additive] theorem IsCompact.smul {α β} [SMul α β] [TopologicalSpace β] [ContinuousConstSMul α β] (a : α) {s : Set β} (hs : IsCompact s) : IsCompact (a • s) := hs.image (continuous_id.const_smul a) @[to_additive] theorem Specializes.const_smul {x y : α} (h : x ⤳ y) (c : M) : (c • x) ⤳ (c • y) := h.map (continuous_const_smul c) @[to_additive] theorem Inseparable.const_smul {x y : α} (h : Inseparable x y) (c : M) : Inseparable (c • x) (c • y) := h.map (continuous_const_smul c) @[to_additive] theorem Topology.IsInducing.continuousConstSMul {N β : Type*} [SMul N β] [TopologicalSpace β] {g : β → α} (hg : IsInducing g) (f : N → M) (hf : ∀ {c : N} {x : β}, g (c • x) = f c • g x) : ContinuousConstSMul N β where continuous_const_smul c := by simpa only [Function.comp_def, hf, hg.continuous_iff] using hg.continuous.const_smul (f c) @[to_additive] theorem smul_closure_subset (c : M) (s : Set α) : c • closure s ⊆ closure (c • s) := ((Set.mapsTo_image _ _).closure <| continuous_const_smul c).image_subset @[to_additive] theorem set_smul_closure_subset (s : Set M) (t : Set α) : s • closure t ⊆ closure (s • t) := by simp only [← iUnion_smul_set] exact iUnion₂_subset fun c hc ↦ (smul_closure_subset c t).trans <| closure_mono <| subset_biUnion_of_mem (u := (· • t)) hc theorem isClosed_setOf_map_smul {N : Type*} (α β) [SMul M α] [SMul N β] [TopologicalSpace β] [T2Space β] [ContinuousConstSMul N β] (σ : M → N) : IsClosed { f : α → β | ∀ c x, f (c • x) = σ c • f x } := by simp only [Set.setOf_forall] exact isClosed_iInter fun c => isClosed_iInter fun x => isClosed_eq (continuous_apply _) ((continuous_apply _).const_smul _) end SMul section Monoid variable [TopologicalSpace α] variable [Monoid M] [MulAction M α] [ContinuousConstSMul M α] @[to_additive] instance Units.continuousConstSMul : ContinuousConstSMul Mˣ α where continuous_const_smul m := continuous_const_smul (m : M) @[to_additive] theorem smul_closure_orbit_subset (c : M) (x : α) : c • closure (MulAction.orbit M x) ⊆ closure (MulAction.orbit M x) := (smul_closure_subset c _).trans <| closure_mono <| MulAction.smul_orbit_subset _ _ end Monoid section Group variable {G : Type*} [TopologicalSpace α] [Group G] [MulAction G α] [ContinuousConstSMul G α] @[to_additive] theorem tendsto_const_smul_iff {f : β → α} {l : Filter β} {a : α} (c : G) : Tendsto (fun x => c • f x) l (𝓝 <| c • a) ↔ Tendsto f l (𝓝 a) := ⟨fun h => by simpa only [inv_smul_smul] using h.const_smul c⁻¹, fun h => h.const_smul _⟩ variable [TopologicalSpace β] {f : β → α} {b : β} {s : Set β} @[to_additive] theorem continuousWithinAt_const_smul_iff (c : G) : ContinuousWithinAt (fun x => c • f x) s b ↔ ContinuousWithinAt f s b := tendsto_const_smul_iff c @[to_additive] theorem continuousOn_const_smul_iff (c : G) : ContinuousOn (fun x => c • f x) s ↔ ContinuousOn f s := forall₂_congr fun _ _ => continuousWithinAt_const_smul_iff c @[to_additive] theorem continuousAt_const_smul_iff (c : G) : ContinuousAt (fun x => c • f x) b ↔ ContinuousAt f b := tendsto_const_smul_iff c @[to_additive] theorem continuous_const_smul_iff (c : G) : (Continuous fun x => c • f x) ↔ Continuous f := by simp only [continuous_iff_continuousAt, continuousAt_const_smul_iff] /-- The homeomorphism given by scalar multiplication by a given element of a group `Γ` acting on `T` is a homeomorphism from `T` to itself. -/ @[to_additive (attr := simps!)] def Homeomorph.smul (γ : G) : α ≃ₜ α where toEquiv := MulAction.toPerm γ continuous_toFun := continuous_const_smul γ continuous_invFun := continuous_const_smul γ⁻¹ /-- The homeomorphism given by affine-addition by an element of an additive group `Γ` acting on `T` is a homeomorphism from `T` to itself. -/ add_decl_doc Homeomorph.vadd @[to_additive] theorem isOpenMap_smul (c : G) : IsOpenMap fun x : α => c • x := (Homeomorph.smul c).isOpenMap @[to_additive] theorem IsOpen.smul {s : Set α} (hs : IsOpen s) (c : G) : IsOpen (c • s) := isOpenMap_smul c s hs @[to_additive] theorem isClosedMap_smul (c : G) : IsClosedMap fun x : α => c • x := (Homeomorph.smul c).isClosedMap @[to_additive] theorem IsClosed.smul {s : Set α} (hs : IsClosed s) (c : G) : IsClosed (c • s) := isClosedMap_smul c s hs @[to_additive] theorem closure_smul (c : G) (s : Set α) : closure (c • s) = c • closure s := ((Homeomorph.smul c).image_closure s).symm @[to_additive] theorem Dense.smul (c : G) {s : Set α} (hs : Dense s) : Dense (c • s) := by rw [dense_iff_closure_eq] at hs ⊢; rw [closure_smul, hs, smul_set_univ] @[to_additive] theorem interior_smul (c : G) (s : Set α) : interior (c • s) = c • interior s := ((Homeomorph.smul c).image_interior s).symm @[to_additive] theorem IsOpen.smul_left {s : Set G} {t : Set α} (ht : IsOpen t) : IsOpen (s • t) := by rw [← iUnion_smul_set] exact isOpen_biUnion fun a _ => ht.smul _ @[to_additive] theorem subset_interior_smul_right {s : Set G} {t : Set α} : s • interior t ⊆ interior (s • t) := interior_maximal (Set.smul_subset_smul_left interior_subset) isOpen_interior.smul_left @[to_additive (attr := simp)] theorem smul_mem_nhds_smul_iff {t : Set α} (g : G) {a : α} : g • t ∈ 𝓝 (g • a) ↔ t ∈ 𝓝 a := (Homeomorph.smul g).isOpenEmbedding.image_mem_nhds @[to_additive] alias ⟨_, smul_mem_nhds_smul⟩ := smul_mem_nhds_smul_iff @[to_additive (attr := simp)] theorem smul_mem_nhds_self [TopologicalSpace G] [ContinuousConstSMul G G] {g : G} {s : Set G} : g • s ∈ 𝓝 g ↔ s ∈ 𝓝 1 := by rw [← smul_mem_nhds_smul_iff g⁻¹]; simp namespace MulAction.IsPretransitive variable (G) @[to_additive] lemma t1Space_iff (x : α) [IsPretransitive G α] : T1Space α ↔ IsClosed {x} := by refine ⟨fun H ↦ isClosed_singleton, fun hx ↦ ⟨fun y ↦ ?_⟩⟩ rcases MulAction.exists_smul_eq G x y with ⟨g, rfl⟩ rw [← image_singleton, image_smul] exact hx.smul _ @[to_additive] lemma discreteTopology_iff (x : α) [IsPretransitive G α] : DiscreteTopology α ↔ IsOpen {x} := by rw [discreteTopology_iff_isOpen_singleton] refine ⟨fun H ↦ H _, fun hx y ↦ ?_⟩ rcases MulAction.exists_smul_eq G x y with ⟨g, rfl⟩ rw [← image_singleton, image_smul] exact hx.smul _ end MulAction.IsPretransitive end Group section GroupWithZero variable {G₀ : Type*} [TopologicalSpace α] [GroupWithZero G₀] [MulAction G₀ α] [ContinuousConstSMul G₀ α] theorem tendsto_const_smul_iff₀ {f : β → α} {l : Filter β} {a : α} {c : G₀} (hc : c ≠ 0) : Tendsto (fun x => c • f x) l (𝓝 <| c • a) ↔ Tendsto f l (𝓝 a) := tendsto_const_smul_iff (Units.mk0 c hc) variable [TopologicalSpace β] {f : β → α} {b : β} {c : G₀} {s : Set β} theorem continuousWithinAt_const_smul_iff₀ (hc : c ≠ 0) : ContinuousWithinAt (fun x => c • f x) s b ↔ ContinuousWithinAt f s b := tendsto_const_smul_iff (Units.mk0 c hc) theorem continuousOn_const_smul_iff₀ (hc : c ≠ 0) : ContinuousOn (fun x => c • f x) s ↔ ContinuousOn f s := continuousOn_const_smul_iff (Units.mk0 c hc) theorem continuousAt_const_smul_iff₀ (hc : c ≠ 0) : ContinuousAt (fun x => c • f x) b ↔ ContinuousAt f b := continuousAt_const_smul_iff (Units.mk0 c hc) theorem continuous_const_smul_iff₀ (hc : c ≠ 0) : (Continuous fun x => c • f x) ↔ Continuous f := continuous_const_smul_iff (Units.mk0 c hc) /-- Scalar multiplication by a non-zero element of a group with zero acting on `α` is a homeomorphism from `α` onto itself. -/ @[simps! -fullyApplied apply] protected def Homeomorph.smulOfNeZero (c : G₀) (hc : c ≠ 0) : α ≃ₜ α := Homeomorph.smul (Units.mk0 c hc) @[simp] theorem Homeomorph.smulOfNeZero_symm_apply {c : G₀} (hc : c ≠ 0) : ⇑(Homeomorph.smulOfNeZero c hc).symm = (c⁻¹ • · : α → α) := rfl theorem isOpenMap_smul₀ {c : G₀} (hc : c ≠ 0) : IsOpenMap fun x : α => c • x := (Homeomorph.smulOfNeZero c hc).isOpenMap theorem IsOpen.smul₀ {c : G₀} {s : Set α} (hs : IsOpen s) (hc : c ≠ 0) : IsOpen (c • s) := isOpenMap_smul₀ hc s hs theorem interior_smul₀ {c : G₀} (hc : c ≠ 0) (s : Set α) : interior (c • s) = c • interior s := ((Homeomorph.smulOfNeZero c hc).image_interior s).symm theorem closure_smul₀' {c : G₀} (hc : c ≠ 0) (s : Set α) : closure (c • s) = c • closure s := ((Homeomorph.smulOfNeZero c hc).image_closure s).symm theorem closure_smul₀ {E} [Zero E] [MulActionWithZero G₀ E] [TopologicalSpace E] [T1Space E] [ContinuousConstSMul G₀ E] (c : G₀) (s : Set E) : closure (c • s) = c • closure s := by rcases eq_or_ne c 0 with (rfl | hc) · rcases eq_empty_or_nonempty s with (rfl | hs) · simp · rw [zero_smul_set hs, zero_smul_set hs.closure] exact closure_singleton · exact closure_smul₀' hc s /-- `smul` is a closed map in the second argument. The lemma that `smul` is a closed map in the first argument (for a normed space over a complete normed field) is `isClosedMap_smul_left` in `Analysis.Normed.Module.FiniteDimension`. -/ theorem isClosedMap_smul_of_ne_zero {c : G₀} (hc : c ≠ 0) : IsClosedMap fun x : α => c • x := (Homeomorph.smulOfNeZero c hc).isClosedMap theorem IsClosed.smul_of_ne_zero {c : G₀} {s : Set α} (hs : IsClosed s) (hc : c ≠ 0) : IsClosed (c • s) := isClosedMap_smul_of_ne_zero hc s hs /-- `smul` is a closed map in the second argument. The lemma that `smul` is a closed map in the first argument (for a normed space over a complete normed field) is `isClosedMap_smul_left` in `Analysis.Normed.Module.FiniteDimension`. -/ theorem isClosedMap_smul₀ {E : Type*} [Zero E] [MulActionWithZero G₀ E] [TopologicalSpace E] [T1Space E] [ContinuousConstSMul G₀ E] (c : G₀) : IsClosedMap fun x : E => c • x := by rcases eq_or_ne c 0 with (rfl | hne) · simp only [zero_smul] exact isClosedMap_const · exact (Homeomorph.smulOfNeZero c hne).isClosedMap theorem IsClosed.smul₀ {E : Type*} [Zero E] [MulActionWithZero G₀ E] [TopologicalSpace E] [T1Space E] [ContinuousConstSMul G₀ E] (c : G₀) {s : Set E} (hs : IsClosed s) : IsClosed (c • s) := isClosedMap_smul₀ c s hs theorem HasCompactMulSupport.comp_smul {β : Type*} [One β] {f : α → β} (h : HasCompactMulSupport f) {c : G₀} (hc : c ≠ 0) : HasCompactMulSupport fun x => f (c • x) := h.comp_homeomorph (Homeomorph.smulOfNeZero c hc) theorem HasCompactSupport.comp_smul {β : Type*} [Zero β] {f : α → β} (h : HasCompactSupport f) {c : G₀} (hc : c ≠ 0) : HasCompactSupport fun x => f (c • x) := h.comp_homeomorph (Homeomorph.smulOfNeZero c hc) end GroupWithZero namespace IsUnit variable [Monoid M] [TopologicalSpace α] [MulAction M α] [ContinuousConstSMul M α] nonrec theorem tendsto_const_smul_iff {f : β → α} {l : Filter β} {a : α} {c : M} (hc : IsUnit c) : Tendsto (fun x => c • f x) l (𝓝 <| c • a) ↔ Tendsto f l (𝓝 a) := tendsto_const_smul_iff hc.unit variable [TopologicalSpace β] {f : β → α} {b : β} {c : M} {s : Set β} nonrec theorem continuousWithinAt_const_smul_iff (hc : IsUnit c) : ContinuousWithinAt (fun x => c • f x) s b ↔ ContinuousWithinAt f s b := continuousWithinAt_const_smul_iff hc.unit nonrec theorem continuousOn_const_smul_iff (hc : IsUnit c) : ContinuousOn (fun x => c • f x) s ↔ ContinuousOn f s := continuousOn_const_smul_iff hc.unit nonrec theorem continuousAt_const_smul_iff (hc : IsUnit c) : ContinuousAt (fun x => c • f x) b ↔ ContinuousAt f b := continuousAt_const_smul_iff hc.unit nonrec theorem continuous_const_smul_iff (hc : IsUnit c) : (Continuous fun x => c • f x) ↔ Continuous f := continuous_const_smul_iff hc.unit nonrec theorem isOpenMap_smul (hc : IsUnit c) : IsOpenMap fun x : α => c • x := isOpenMap_smul hc.unit nonrec theorem isClosedMap_smul (hc : IsUnit c) : IsClosedMap fun x : α => c • x := isClosedMap_smul hc.unit nonrec theorem smul_mem_nhds_smul_iff (hc : IsUnit c) {s : Set α} {a : α} : c • s ∈ 𝓝 (c • a) ↔ s ∈ 𝓝 a := smul_mem_nhds_smul_iff hc.unit end IsUnit -- TODO: use `Set.Nonempty` /-- Class `ProperlyDiscontinuousSMul Γ T` says that the scalar multiplication `(•) : Γ → T → T` is properly discontinuous, that is, for any pair of compact sets `K, L` in `T`, only finitely many `γ:Γ` move `K` to have nontrivial intersection with `L`. -/ class ProperlyDiscontinuousSMul (Γ : Type*) (T : Type*) [TopologicalSpace T] [SMul Γ T] : Prop where /-- Given two compact sets `K` and `L`, `γ • K ∩ L` is nonempty for finitely many `γ`. -/ finite_disjoint_inter_image : ∀ {K L : Set T}, IsCompact K → IsCompact L → Set.Finite { γ : Γ | (γ • ·) '' K ∩ L ≠ ∅ } /-- Class `ProperlyDiscontinuousVAdd Γ T` says that the additive action `(+ᵥ) : Γ → T → T` is properly discontinuous, that is, for any pair of compact sets `K, L` in `T`, only finitely many `γ:Γ` move `K` to have nontrivial intersection with `L`. -/ class ProperlyDiscontinuousVAdd (Γ : Type*) (T : Type*) [TopologicalSpace T] [VAdd Γ T] : Prop where /-- Given two compact sets `K` and `L`, `γ +ᵥ K ∩ L` is nonempty for finitely many `γ`. -/ finite_disjoint_inter_image : ∀ {K L : Set T}, IsCompact K → IsCompact L → Set.Finite { γ : Γ | (γ +ᵥ ·) '' K ∩ L ≠ ∅ } attribute [to_additive] ProperlyDiscontinuousSMul variable {Γ : Type*} [Group Γ] {T : Type*} [TopologicalSpace T] [MulAction Γ T] /-- A finite group action is always properly discontinuous. -/ @[to_additive /-- A finite group action is always properly discontinuous. -/] instance (priority := 100) Finite.to_properlyDiscontinuousSMul [Finite Γ] : ProperlyDiscontinuousSMul Γ T where finite_disjoint_inter_image _ _ := Set.toFinite _ export ProperlyDiscontinuousSMul (finite_disjoint_inter_image) export ProperlyDiscontinuousVAdd (finite_disjoint_inter_image) /-- The quotient map by a group action is open, i.e. the quotient by a group action is an open quotient. -/ @[to_additive /-- The quotient map by a group action is open, i.e. the quotient by a group action is an open quotient. -/] theorem isOpenMap_quotient_mk'_mul [ContinuousConstSMul Γ T] : letI := MulAction.orbitRel Γ T IsOpenMap (Quotient.mk' : T → Quotient (MulAction.orbitRel Γ T)) := fun U hU => by rw [isOpen_coinduced, MulAction.quotient_preimage_image_eq_union_mul U] exact isOpen_iUnion fun γ => isOpenMap_smul γ U hU @[to_additive] theorem MulAction.isOpenQuotientMap_quotientMk [ContinuousConstSMul Γ T] : IsOpenQuotientMap (Quotient.mk (MulAction.orbitRel Γ T)) := ⟨Quot.mk_surjective, continuous_quot_mk, isOpenMap_quotient_mk'_mul⟩ /-- The quotient by a discontinuous group action of a locally compact t2 space is t2. -/ @[to_additive /-- The quotient by a discontinuous group action of a locally compact t2 space is t2. -/] instance (priority := 100) t2Space_of_properlyDiscontinuousSMul_of_t2Space [T2Space T] [LocallyCompactSpace T] [ContinuousConstSMul Γ T] [ProperlyDiscontinuousSMul Γ T] : T2Space (Quotient (MulAction.orbitRel Γ T)) := by letI := MulAction.orbitRel Γ T set Q := Quotient (MulAction.orbitRel Γ T) rw [t2Space_iff_nhds] let f : T → Q := Quotient.mk' have f_op : IsOpenMap f := isOpenMap_quotient_mk'_mul rintro ⟨x₀⟩ ⟨y₀⟩ (hxy : f x₀ ≠ f y₀) change ∃ U ∈ 𝓝 (f x₀), ∃ V ∈ 𝓝 (f y₀), _ have hγx₀y₀ : ∀ γ : Γ, γ • x₀ ≠ y₀ := not_exists.mp (mt Quotient.sound hxy.symm :) obtain ⟨K₀, hK₀, K₀_in⟩ := exists_compact_mem_nhds x₀ obtain ⟨L₀, hL₀, L₀_in⟩ := exists_compact_mem_nhds y₀ let bad_Γ_set := { γ : Γ | (γ • ·) '' K₀ ∩ L₀ ≠ ∅ } have bad_Γ_finite : bad_Γ_set.Finite := finite_disjoint_inter_image (Γ := Γ) hK₀ hL₀ choose u v hu hv u_v_disjoint using fun γ => t2_separation_nhds (hγx₀y₀ γ) let U₀₀ := ⋂ γ ∈ bad_Γ_set, (γ • ·) ⁻¹' u γ let U₀ := U₀₀ ∩ K₀ let V₀₀ := ⋂ γ ∈ bad_Γ_set, v γ let V₀ := V₀₀ ∩ L₀ have U_nhds : f '' U₀ ∈ 𝓝 (f x₀) := by refine f_op.image_mem_nhds (inter_mem ((biInter_mem bad_Γ_finite).mpr fun γ _ => ?_) K₀_in) exact (continuous_const_smul _).continuousAt (hu γ) have V_nhds : f '' V₀ ∈ 𝓝 (f y₀) := f_op.image_mem_nhds (inter_mem ((biInter_mem bad_Γ_finite).mpr fun γ _ => hv γ) L₀_in) refine ⟨f '' U₀, U_nhds, f '' V₀, V_nhds, MulAction.disjoint_image_image_iff.2 ?_⟩ rintro x ⟨x_in_U₀₀, x_in_K₀⟩ γ by_cases H : γ ∈ bad_Γ_set · exact fun h => (u_v_disjoint γ).le_bot ⟨mem_iInter₂.mp x_in_U₀₀ γ H, mem_iInter₂.mp h.1 γ H⟩ · rintro ⟨-, h'⟩ simp only [bad_Γ_set, image_smul, Classical.not_not, mem_setOf_eq, Ne] at H exact eq_empty_iff_forall_notMem.mp H (γ • x) ⟨mem_image_of_mem _ x_in_K₀, h'⟩ /-- The quotient of a second countable space by a group action is second countable. -/ @[to_additive /-- The quotient of a second countable space by an additive group action is second countable. -/] theorem ContinuousConstSMul.secondCountableTopology [SecondCountableTopology T] [ContinuousConstSMul Γ T] : SecondCountableTopology (Quotient (MulAction.orbitRel Γ T)) := TopologicalSpace.Quotient.secondCountableTopology isOpenMap_quotient_mk'_mul section nhds section MulAction variable {G₀ : Type*} [GroupWithZero G₀] [MulAction G₀ α] [TopologicalSpace α] [ContinuousConstSMul G₀ α] /-- Scalar multiplication by a nonzero scalar preserves neighborhoods. -/ theorem smul_mem_nhds_smul_iff₀ {c : G₀} {s : Set α} {x : α} (hc : c ≠ 0) : c • s ∈ 𝓝 (c • x : α) ↔ s ∈ 𝓝 x := smul_mem_nhds_smul_iff (Units.mk0 c hc) alias ⟨_, smul_mem_nhds_smul₀⟩ := smul_mem_nhds_smul_iff₀ end MulAction section DistribMulAction variable {G₀ : Type*} [GroupWithZero G₀] [AddMonoid α] [DistribMulAction G₀ α] [TopologicalSpace α] [ContinuousConstSMul G₀ α] theorem set_smul_mem_nhds_zero_iff {s : Set α} {c : G₀} (hc : c ≠ 0) : c • s ∈ 𝓝 (0 : α) ↔ s ∈ 𝓝 (0 : α) := by refine Iff.trans ?_ (smul_mem_nhds_smul_iff₀ hc) rw [smul_zero] end DistribMulAction end nhds
.lake/packages/mathlib/Mathlib/Topology/Algebra/AffineSubspace.lean
import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic import Mathlib.Topology.Algebra.ContinuousAffineMap import Mathlib.Topology.Algebra.Group.AddTorsor /-! # Topology of affine subspaces. This file defines the embedding map from an affine subspace to the ambient space as a continuous affine map. ## Main definitions * `AffineSubspace.subtypeA` is `AffineSubspace.subtype` as a `ContinuousAffineMap`. -/ namespace AffineSubspace variable {R V P : Type*} [Ring R] [AddCommGroup V] [Module R V] [TopologicalSpace P] [AddTorsor V P] /-- Embedding of an affine subspace to the ambient space, as a continuous affine map. -/ def subtypeA (s : AffineSubspace R P) [Nonempty s] : s →ᴬ[R] P where toAffineMap := s.subtype cont := continuous_subtype_val @[simp] lemma coe_subtypeA (s : AffineSubspace R P) [Nonempty s] : ⇑s.subtypeA = Subtype.val := rfl @[simp] lemma subtypeA_toAffineMap (s : AffineSubspace R P) [Nonempty s] : s.subtypeA.toAffineMap = s.subtype := rfl variable [TopologicalSpace V] [IsTopologicalAddTorsor P] instance {s : AffineSubspace R P} [Nonempty s] : IsTopologicalAddTorsor s where continuous_vadd := by rw [Topology.IsEmbedding.subtypeVal.continuous_iff] fun_prop continuous_vsub := by rw [Topology.IsEmbedding.subtypeVal.continuous_iff] fun_prop theorem isClosed_direction_iff [T1Space V] (s : AffineSubspace R P) : IsClosed (s.direction : Set V) ↔ IsClosed (s : Set P) := by rcases s.eq_bot_or_nonempty with (rfl | ⟨x, hx⟩); · simp rw [← (Homeomorph.vaddConst x).symm.isClosed_image, AffineSubspace.coe_direction_eq_vsub_set_right hx] simp only [Homeomorph.vaddConst_symm_apply] end AffineSubspace
.lake/packages/mathlib/Mathlib/Topology/Algebra/TopologicallyNilpotent.lean
import Mathlib.Topology.Algebra.LinearTopology import Mathlib.RingTheory.Ideal.Basic import Mathlib.RingTheory.Nilpotent.Defs /-! # Topologically nilpotent elements Let `M` be a monoid with zero `M`, endowed with a topology. * `IsTopologicallyNilpotent a` says that `a : M` is *topologically nilpotent*, i.e., its powers converge to zero. * `IsTopologicallyNilpotent.map`: The image of a topologically nilpotent element under a continuous morphism of monoids with zero endowed with a topology is topologically nilpotent. * `IsTopologicallyNilpotent.zero`: `0` is topologically nilpotent. Let `R` be a commutative ring with a linear topology. * `IsTopologicallyNilpotent.mul_left`: if `a : R` is topologically nilpotent, then `a*b` is topologically nilpotent. * `IsTopologicallyNilpotent.mul_right`: if `a : R` is topologically nilpotent, then `a * b` is topologically nilpotent. * `IsTopologicallyNilpotent.add`: if `a b : R` are topologically nilpotent, then `a + b` is topologically nilpotent. These lemmas are actually deduced from their analogues for commuting elements of rings. -/ open Filter open scoped Topology /-- An element is topologically nilpotent if its powers converge to `0`. -/ def IsTopologicallyNilpotent {R : Type*} [MonoidWithZero R] [TopologicalSpace R] (a : R) : Prop := Tendsto (a ^ ·) atTop (𝓝 0) namespace IsTopologicallyNilpotent section MonoidWithZero variable {R S : Type*} [TopologicalSpace R] [MonoidWithZero R] [MonoidWithZero S] [TopologicalSpace S] /-- The image of a topologically nilpotent element under a continuous morphism is topologically nilpotent -/ theorem map {F : Type*} [FunLike F R S] [MonoidWithZeroHomClass F R S] {φ : F} (hφ : Continuous φ) {a : R} (ha : IsTopologicallyNilpotent a) : IsTopologicallyNilpotent (φ a) := by unfold IsTopologicallyNilpotent at ha ⊢ simp_rw [← map_pow] exact (map_zero φ ▸ hφ.tendsto 0).comp ha /-- `0` is topologically nilpotent -/ theorem zero : IsTopologicallyNilpotent (0 : R) := tendsto_atTop_of_eventually_const (i₀ := 1) (fun _ hi => by rw [zero_pow (Nat.ne_zero_iff_zero_lt.mpr hi)]) theorem _root_.IsNilpotent.isTopologicallyNilpotent {a : R} (ha : IsNilpotent a) : IsTopologicallyNilpotent a := by obtain ⟨n, hn⟩ := ha apply tendsto_atTop_of_eventually_const (i₀ := n) intro i hi rw [← Nat.add_sub_of_le hi, pow_add, hn, zero_mul] theorem exists_pow_mem_of_mem_nhds {a : R} (ha : IsTopologicallyNilpotent a) {v : Set R} (hv : v ∈ 𝓝 0) : ∃ n, a ^ n ∈ v := (ha.eventually_mem hv).exists end MonoidWithZero section Ring variable {R : Type*} [TopologicalSpace R] [Ring R] /-- If `a` and `b` commute and `a` is topologically nilpotent, then `a * b` is topologically nilpotent. -/ theorem mul_right_of_commute [IsLinearTopology Rᵐᵒᵖ R] {a b : R} (ha : IsTopologicallyNilpotent a) (hab : Commute a b) : IsTopologicallyNilpotent (a * b) := by simp_rw [IsTopologicallyNilpotent, hab.mul_pow] exact IsLinearTopology.tendsto_mul_zero_of_left _ _ ha /-- If `a` and `b` commute and `b` is topologically nilpotent, then `a * b` is topologically nilpotent. -/ theorem mul_left_of_commute [IsLinearTopology R R] {a b : R} (hb : IsTopologicallyNilpotent b) (hab : Commute a b) : IsTopologicallyNilpotent (a * b) := by simp_rw [IsTopologicallyNilpotent, hab.mul_pow] exact IsLinearTopology.tendsto_mul_zero_of_right _ _ hb /-- If `a` and `b` are topologically nilpotent and commute, then `a + b` is topologically nilpotent. -/ theorem add_of_commute [IsLinearTopology R R] {a b : R} (ha : IsTopologicallyNilpotent a) (hb : IsTopologicallyNilpotent b) (h : Commute a b) : IsTopologicallyNilpotent (a + b) := by simp only [IsTopologicallyNilpotent, atTop_basis.tendsto_iff IsLinearTopology.hasBasis_ideal, true_and] intro I I_mem_nhds obtain ⟨na, ha⟩ := ha.exists_pow_mem_of_mem_nhds I_mem_nhds obtain ⟨nb, hb⟩ := hb.exists_pow_mem_of_mem_nhds I_mem_nhds exact ⟨na + nb, fun m hm ↦ I.add_pow_mem_of_pow_mem_of_le_of_commute ha hb (le_trans hm (Nat.le_add_right _ _)) h⟩ end Ring section CommRing variable {R : Type*} [TopologicalSpace R] [CommRing R] [IsLinearTopology R R] /-- If `a` is topologically nilpotent, then `a * b` is topologically nilpotent. -/ theorem mul_right {a : R} (ha : IsTopologicallyNilpotent a) (b : R) : IsTopologicallyNilpotent (a * b) := ha.mul_right_of_commute (Commute.all ..) /-- If `b` is topologically nilpotent, then `a * b` is topologically nilpotent. -/ theorem mul_left (a : R) {b : R} (hb : IsTopologicallyNilpotent b) : IsTopologicallyNilpotent (a * b) := hb.mul_left_of_commute (Commute.all ..) /-- If `a` and `b` are topologically nilpotent, then `a + b` is topologically nilpotent. -/ theorem add {a b : R} (ha : IsTopologicallyNilpotent a) (hb : IsTopologicallyNilpotent b) : IsTopologicallyNilpotent (a + b) := ha.add_of_commute hb (Commute.all ..) variable (R) in /-- The topological nilradical of a ring with a linear topology -/ @[simps] def _root_.topologicalNilradical : Ideal R where carrier := {a | IsTopologicallyNilpotent a} add_mem' := add zero_mem' := zero smul_mem' := mul_left theorem mem_topologicalNilradical_iff {a : R} : a ∈ topologicalNilradical R ↔ IsTopologicallyNilpotent a := by simp [topologicalNilradical] end CommRing end IsTopologicallyNilpotent
.lake/packages/mathlib/Mathlib/Topology/Algebra/ProperConstSMul.lean
import Mathlib.Topology.Algebra.ConstMulAction import Mathlib.Topology.Maps.Proper.Basic /-! # Actions by proper maps In this file we define `ProperConstSMul M X` to be a mixin `Prop`-value class stating that `(c • ·)` is a proper map for all `c`. Note that this is **not** the same as a proper action (not yet in `Mathlib`) which requires `(c, x) ↦ (c • x, x)` to be a proper map. We also provide 4 instances: - for a continuous action on a compact Hausdorff space, - and for a continuous group action on a general space; - for the action on `X × Y`; - for the action on `∀ i, X i`. -/ /-- A mixin typeclass saying that the `(c +ᵥ ·)` is a proper map for all `c`. Note that this is **not** the same as a proper additive action (not yet in `Mathlib`). -/ class ProperConstVAdd (M X : Type*) [VAdd M X] [TopologicalSpace X] : Prop where /-- `(c +ᵥ ·)` is a proper map. -/ isProperMap_vadd (c : M) : IsProperMap ((c +ᵥ ·) : X → X) /-- A mixin typeclass saying that `(c • ·)` is a proper map for all `c`. Note that this is **not** the same as a proper multiplicative action (not yet in `Mathlib`). -/ @[to_additive] class ProperConstSMul (M X : Type*) [SMul M X] [TopologicalSpace X] : Prop where /-- `(c • ·)` is a proper map. -/ isProperMap_smul (c : M) : IsProperMap ((c • ·) : X → X) /-- `(c • ·)` is a proper map. -/ @[to_additive /-- `(c +ᵥ ·)` is a proper map. -/] theorem isProperMap_smul {M : Type*} (c : M) (X : Type*) [SMul M X] [TopologicalSpace X] [h : ProperConstSMul M X] : IsProperMap ((c • ·) : X → X) := h.1 c /-- The preimage of a compact set under `(c • ·)` is a compact set. -/ @[to_additive /-- The preimage of a compact set under `(c +ᵥ ·)` is a compact set. -/] theorem IsCompact.preimage_smul {M X : Type*} [SMul M X] [TopologicalSpace X] [ProperConstSMul M X] {s : Set X} (hs : IsCompact s) (c : M) : IsCompact ((c • ·) ⁻¹' s) := (isProperMap_smul c X).isCompact_preimage hs @[to_additive] instance (priority := 100) {M X : Type*} [SMul M X] [TopologicalSpace X] [ContinuousConstSMul M X] [T2Space X] [CompactSpace X] : ProperConstSMul M X := ⟨fun c ↦ (continuous_const_smul c).isProperMap⟩ @[to_additive] instance (priority := 100) {G X : Type*} [Group G] [MulAction G X] [TopologicalSpace X] [ContinuousConstSMul G X] : ProperConstSMul G X := ⟨fun c ↦ (Homeomorph.smul c).isProperMap⟩ instance {M X Y : Type*} [SMul M X] [TopologicalSpace X] [ProperConstSMul M X] [SMul M Y] [TopologicalSpace Y] [ProperConstSMul M Y] : ProperConstSMul M (X × Y) := ⟨fun c ↦ (isProperMap_smul c X).prodMap (isProperMap_smul c Y)⟩ instance {M ι : Type*} {X : ι → Type*} [∀ i, SMul M (X i)] [∀ i, TopologicalSpace (X i)] [∀ i, ProperConstSMul M (X i)] : ProperConstSMul M (∀ i, X i) := ⟨fun c ↦ .pi_map fun i ↦ isProperMap_smul c (X i)⟩
.lake/packages/mathlib/Mathlib/Topology/Algebra/IntermediateField.lean
import Mathlib.FieldTheory.IntermediateField.Adjoin.Defs import Mathlib.Topology.Algebra.Field /-! # Continuous actions related to intermediate fields In this file we define the instances related to continuous actions of intermediate fields. The topology on intermediate fields is already defined in earlier file `Mathlib/Topology/Algebra/Field.lean` as the subspace topology. -/ variable {K L : Type*} [Field K] [Field L] [Algebra K L] [TopologicalSpace L] [IsTopologicalRing L] variable (X : Type*) [TopologicalSpace X] [MulAction L X] [ContinuousSMul L X] variable (M : IntermediateField K L) instance IntermediateField.continuousSMul (M : IntermediateField K L) : ContinuousSMul M X := M.toSubfield.continuousSMul X instance IntermediateField.botContinuousSMul (M : IntermediateField K L) : ContinuousSMul (⊥ : IntermediateField K L) M := Topology.IsInducing.continuousSMul (X := L) (N := (⊥ : IntermediateField K L)) (Y := M) (M := (⊥ : IntermediateField K L)) Topology.IsInducing.subtypeVal continuous_id rfl
.lake/packages/mathlib/Mathlib/Topology/Algebra/ContinuousMonoidHom.lean
import Mathlib.Algebra.Group.Equiv.Basic import Mathlib.Topology.Algebra.Group.Defs /-! # Continuous Monoid Homs This file defines the space of continuous homomorphisms between two topological groups. ## Main definitions * `ContinuousMonoidHom A B`: The continuous homomorphisms `A →* B`. * `ContinuousAddMonoidHom A B`: The continuous additive homomorphisms `A →+ B`. -/ assert_not_exists ContinuousLinearMap assert_not_exists ContinuousLinearEquiv section open Function Topology variable (F A B C D E : Type*) variable [Monoid A] [Monoid B] [Monoid C] [Monoid D] variable [TopologicalSpace A] [TopologicalSpace B] [TopologicalSpace C] [TopologicalSpace D] /-- The type of continuous additive monoid homomorphisms from `A` to `B`. When possible, instead of parametrizing results over `(f : ContinuousAddMonoidHom A B)`, you should parametrize over `(F : Type*) [FunLike F A B] [ContinuousMapClass F A B] [AddMonoidHomClass F A B] (f : F)`. When you extend this structure, make sure to extend `ContinuousMapClass` and/or `AddMonoidHomClass`, if needed. -/ structure ContinuousAddMonoidHom (A B : Type*) [AddMonoid A] [AddMonoid B] [TopologicalSpace A] [TopologicalSpace B] extends A →+ B, C(A, B) /-- The type of continuous monoid homomorphisms from `A` to `B`. When possible, instead of parametrizing results over `(f : ContinuousMonoidHom A B)`, you should parametrize over `(F : Type*) [FunLike F A B] [ContinuousMapClass F A B] [MonoidHomClass F A B] (f : F)`. When you extend this structure, make sure to extend `ContinuousMapClass` and/or `MonoidHomClass`, if needed. -/ @[to_additive /-- The type of continuous additive monoid homomorphisms from `A` to `B`. -/] structure ContinuousMonoidHom extends A →* B, C(A, B) /-- Reinterpret a `ContinuousMonoidHom` as a `MonoidHom`. -/ add_decl_doc ContinuousMonoidHom.toMonoidHom /-- Reinterpret a `ContinuousAddMonoidHom` as an `AddMonoidHom`. -/ add_decl_doc ContinuousAddMonoidHom.toAddMonoidHom /-- Reinterpret a `ContinuousMonoidHom` as a `ContinuousMap`. -/ add_decl_doc ContinuousMonoidHom.toContinuousMap /-- Reinterpret a `ContinuousAddMonoidHom` as a `ContinuousMap`. -/ add_decl_doc ContinuousAddMonoidHom.toContinuousMap namespace ContinuousMonoidHom /-- The type of continuous monoid homomorphisms from `A` to `B`.-/ infixr:25 " →ₜ+ " => ContinuousAddMonoidHom /-- The type of continuous monoid homomorphisms from `A` to `B`.-/ infixr:25 " →ₜ* " => ContinuousMonoidHom variable {A B C D E} @[to_additive] instance instFunLike : FunLike (A →ₜ* B) A B where coe f := f.toFun coe_injective' f g h := by obtain ⟨⟨⟨_, _⟩, _⟩, _⟩ := f obtain ⟨⟨⟨_, _⟩, _⟩, _⟩ := g congr @[to_additive] instance instMonoidHomClass : MonoidHomClass (A →ₜ* B) A B where map_mul f := f.map_mul' map_one f := f.map_one' @[to_additive] instance instContinuousMapClass : ContinuousMapClass (A →ₜ* B) A B where map_continuous f := f.continuous_toFun @[to_additive (attr := simp)] lemma coe_toMonoidHom (f : A →ₜ* B) : f.toMonoidHom = f := rfl @[to_additive (attr := simp)] lemma coe_toContinuousMap (f : A →ₜ* B) : f.toContinuousMap = f := rfl section variable {F : Type*} [FunLike F A B] /-- Turn an element of a type `F` satisfying `MonoidHomClass F A B` and `ContinuousMapClass F A B` into a`ContinuousMonoidHom`. This is declared as the default coercion from `F` to `(A →ₜ* B)`. -/ @[to_additive (attr := coe) /-- Turn an element of a type `F` satisfying `AddMonoidHomClass F A B` and `ContinuousMapClass F A B` into a`ContinuousAddMonoidHom`. This is declared as the default coercion from `F` to `ContinuousAddMonoidHom A B`. -/] def toContinuousMonoidHom [MonoidHomClass F A B] [ContinuousMapClass F A B] (f : F) : A →ₜ* B := { MonoidHomClass.toMonoidHom f with } /-- Any type satisfying `MonoidHomClass` and `ContinuousMapClass` can be cast into `ContinuousMonoidHom` via `ContinuousMonoidHom.toContinuousMonoidHom`. -/ @[to_additive /-- Any type satisfying `AddMonoidHomClass` and `ContinuousMapClass` can be cast into `ContinuousAddMonoidHom` via `ContinuousAddMonoidHom.toContinuousAddMonoidHom`. -/] instance [MonoidHomClass F A B] [ContinuousMapClass F A B] : CoeOut F (A →ₜ* B) := ⟨ContinuousMonoidHom.toContinuousMonoidHom⟩ @[to_additive (attr := simp)] lemma coe_coe [MonoidHomClass F A B] [ContinuousMapClass F A B] (f : F) : ⇑(f : A →ₜ* B) = f := rfl @[to_additive (attr := simp, norm_cast)] lemma toMonoidHom_toContinuousMonoidHom [MonoidHomClass F A B] [ContinuousMapClass F A B] (f : F) : ((f : A →ₜ* B) : A →* B) = f := rfl @[to_additive (attr := simp, norm_cast)] lemma toContinuousMap_toContinuousMonoidHom [MonoidHomClass F A B] [ContinuousMapClass F A B] (f : F) : ((f : A →ₜ* B) : C(A, B)) = f := rfl end @[to_additive (attr := ext)] theorem ext {f g : A →ₜ* B} (h : ∀ x, f x = g x) : f = g := DFunLike.ext _ _ h @[to_additive] theorem toContinuousMap_injective : Injective (toContinuousMap : _ → C(A, B)) := fun f g h => ext <| by convert DFunLike.ext_iff.1 h /-- Composition of two continuous homomorphisms. -/ @[to_additive (attr := simps!) /-- Composition of two continuous homomorphisms. -/] def comp (g : B →ₜ* C) (f : A →ₜ* B) : A →ₜ* C := ⟨g.toMonoidHom.comp f.toMonoidHom, (map_continuous g).comp (map_continuous f)⟩ @[to_additive (attr := simp)] lemma coe_comp (g : ContinuousMonoidHom B C) (f : ContinuousMonoidHom A B) : ⇑(g.comp f) = ⇑g ∘ ⇑f := rfl /-- Product of two continuous homomorphisms on the same space. -/ @[to_additive (attr := simps!) prod /-- Product of two continuous homomorphisms on the same space. -/] def prod (f : A →ₜ* B) (g : A →ₜ* C) : A →ₜ* (B × C) := ⟨f.toMonoidHom.prod g.toMonoidHom, f.continuous_toFun.prodMk g.continuous_toFun⟩ /-- Product of two continuous homomorphisms on different spaces. -/ @[to_additive (attr := simps!) prodMap /-- Product of two continuous homomorphisms on different spaces. -/] def prodMap (f : A →ₜ* C) (g : B →ₜ* D) : (A × B) →ₜ* (C × D) := ⟨f.toMonoidHom.prodMap g.toMonoidHom, f.continuous_toFun.prodMap g.continuous_toFun⟩ variable (A B C D E) /-- The trivial continuous homomorphism. -/ @[to_additive (attr := simps!) /-- The trivial continuous homomorphism. -/] instance : One (A →ₜ* B) where one := ⟨1, continuous_const⟩ @[to_additive (attr := simp)] lemma coe_one : ⇑(1 : A →ₜ* B) = 1 := rfl @[to_additive] instance : Inhabited (A →ₜ* B) := ⟨1⟩ /-- The identity continuous homomorphism. -/ @[to_additive (attr := simps!) /-- The identity continuous homomorphism. -/] def id : A →ₜ* A := ⟨.id A, continuous_id⟩ @[to_additive (attr := simp)] lemma coe_id : ⇑(ContinuousMonoidHom.id A) = _root_.id := rfl /-- The continuous homomorphism given by projection onto the first factor. -/ @[to_additive (attr := simps!) /-- The continuous homomorphism given by projection onto the first factor. -/] def fst : (A × B) →ₜ* A := ⟨MonoidHom.fst A B, continuous_fst⟩ /-- The continuous homomorphism given by projection onto the second factor. -/ @[to_additive (attr := simps!) /-- The continuous homomorphism given by projection onto the second factor. -/] def snd : (A × B) →ₜ* B := ⟨MonoidHom.snd A B, continuous_snd⟩ /-- The continuous homomorphism given by inclusion of the first factor. -/ @[to_additive (attr := simps!) /-- The continuous homomorphism given by inclusion of the first factor. -/] def inl : A →ₜ* (A × B) := prod (id A) 1 /-- The continuous homomorphism given by inclusion of the second factor. -/ @[to_additive (attr := simps!) /-- The continuous homomorphism given by inclusion of the second factor. -/] def inr : B →ₜ* (A × B) := prod 1 (id B) /-- The continuous homomorphism given by the diagonal embedding. -/ @[to_additive (attr := simps!) /-- The continuous homomorphism given by the diagonal embedding. -/] def diag : A →ₜ* (A × A) := prod (id A) (id A) /-- The continuous homomorphism given by swapping components. -/ @[to_additive (attr := simps!) /-- The continuous homomorphism given by swapping components. -/] def swap : (A × B) →ₜ* (B × A) := prod (snd A B) (fst A B) section CommMonoid variable [CommMonoid E] [TopologicalSpace E] [ContinuousMul E] /-- The continuous homomorphism given by multiplication. -/ @[to_additive (attr := simps!) /-- The continuous homomorphism given by addition. -/] def mul : (E × E) →ₜ* E := ⟨mulMonoidHom, continuous_mul⟩ variable {A B C D E} @[to_additive] instance : CommMonoid (A →ₜ* E) where mul f g := (mul E).comp (f.prod g) mul_comm f g := ext fun x => mul_comm (f x) (g x) mul_assoc f g h := ext fun x => mul_assoc (f x) (g x) (h x) one_mul f := ext fun x => one_mul (f x) mul_one f := ext fun x => mul_one (f x) /-- Coproduct of two continuous homomorphisms to the same space. -/ @[to_additive (attr := simps!) /-- Coproduct of two continuous homomorphisms to the same space. -/] def coprod (f : ContinuousMonoidHom A E) (g : ContinuousMonoidHom B E) : ContinuousMonoidHom (A × B) E := (mul E).comp (f.prodMap g) end CommMonoid section CommGroup variable [CommGroup E] [TopologicalSpace E] [IsTopologicalGroup E] /-- The continuous homomorphism given by inversion. -/ @[to_additive (attr := simps!) /-- The continuous homomorphism given by negation. -/] def inv : ContinuousMonoidHom E E := ⟨invMonoidHom, continuous_inv⟩ @[to_additive] instance : CommGroup (ContinuousMonoidHom A E) where __ : CommMonoid (ContinuousMonoidHom A E) := inferInstance inv f := (inv E).comp f inv_mul_cancel f := ext fun x => inv_mul_cancel (f x) div f g := .comp ⟨divMonoidHom, continuous_div'⟩ (f.prod g) div_eq_mul_inv f g := ext fun x => div_eq_mul_inv (f x) (g x) end CommGroup /-- For `f : F` where `F` is a class of continuous monoid hom, this yields an element `ContinuousMonoidHom A B`. -/ @[to_additive /-- For `f : F` where `F` is a class of continuous additive monoid hom, this yields an element `ContinuousAddMonoidHom A B`. -/] def ofClass (F : Type*) [FunLike F A B] [ContinuousMapClass F A B] [MonoidHomClass F A B] (f : F) : (ContinuousMonoidHom A B) := toContinuousMonoidHom f end ContinuousMonoidHom end section /-! ### Continuous MulEquiv This section defines the space of continuous isomorphisms between two topological groups. -/ universe u v variable (G : Type u) [TopologicalSpace G] (H : Type v) [TopologicalSpace H] /-- The structure of two-sided continuous isomorphisms between additive groups. Note that both the map and its inverse have to be continuous. -/ structure ContinuousAddEquiv [Add G] [Add H] extends G ≃+ H, G ≃ₜ H /-- The structure of two-sided continuous isomorphisms between groups. Note that both the map and its inverse have to be continuous. -/ @[to_additive /-- The structure of two-sided continuous isomorphisms between additive groups. Note that both the map and its inverse have to be continuous. -/] structure ContinuousMulEquiv [Mul G] [Mul H] extends G ≃* H, G ≃ₜ H /-- The homeomorphism induced from a two-sided continuous isomorphism of groups. -/ add_decl_doc ContinuousMulEquiv.toHomeomorph /-- The homeomorphism induced from a two-sided continuous isomorphism additive groups. -/ add_decl_doc ContinuousAddEquiv.toHomeomorph @[inherit_doc] infixl:25 " ≃ₜ* " => ContinuousMulEquiv @[inherit_doc] infixl:25 " ≃ₜ+ " => ContinuousAddEquiv section namespace ContinuousMulEquiv variable {M N : Type*} [TopologicalSpace M] [TopologicalSpace N] [Mul M] [Mul N] section coe @[to_additive] instance : EquivLike (M ≃ₜ* N) M N where coe f := f.toFun inv f := f.invFun left_inv f := f.left_inv right_inv f := f.right_inv coe_injective' f g h₁ h₂ := by cases f cases g congr exact MulEquiv.ext_iff.mpr (congrFun h₁) @[to_additive] instance : MulEquivClass (M ≃ₜ* N) M N where map_mul f := f.map_mul' @[to_additive] instance : HomeomorphClass (M ≃ₜ* N) M N where map_continuous f := f.continuous_toFun inv_continuous f := f.continuous_invFun /-- Two continuous multiplicative isomorphisms agree if they are defined by the same underlying function. -/ @[to_additive (attr := ext) /-- Two continuous additive isomorphisms agree if they are defined by the same underlying function. -/] theorem ext {f g : M ≃ₜ* N} (h : ∀ x, f x = g x) : f = g := DFunLike.ext f g h @[to_additive (attr := simp)] theorem coe_mk (f : M ≃* N) (hf1 hf2) : ⇑(mk f hf1 hf2) = f := rfl @[to_additive] theorem toEquiv_eq_coe (f : M ≃ₜ* N) : f.toEquiv = f := rfl @[to_additive (attr := simp)] theorem toMulEquiv_eq_coe (f : M ≃ₜ* N) : f.toMulEquiv = f := rfl @[to_additive] theorem toHomeomorph_eq_coe (f : M ≃ₜ* N) : f.toHomeomorph = f := rfl /-- Makes a continuous multiplicative isomorphism from a homeomorphism which preserves multiplication. -/ @[to_additive /-- Makes an continuous additive isomorphism from a homeomorphism which preserves addition. -/] def mk' (f : M ≃ₜ N) (h : ∀ x y, f (x * y) = f x * f y) : M ≃ₜ* N := ⟨⟨f.toEquiv,h⟩, f.continuous_toFun, f.continuous_invFun⟩ set_option linter.docPrime false in -- This is about `ContinuousMulEquiv.mk'` @[simp] lemma coe_mk' (f : M ≃ₜ N) (h : ∀ x y, f (x * y) = f x * f y) : ⇑(mk' f h) = f := rfl end coe section bijective @[to_additive] protected theorem bijective (e : M ≃ₜ* N) : Function.Bijective e := EquivLike.bijective e @[to_additive] protected theorem injective (e : M ≃ₜ* N) : Function.Injective e := EquivLike.injective e @[to_additive] protected theorem surjective (e : M ≃ₜ* N) : Function.Surjective e := EquivLike.surjective e @[to_additive] theorem apply_eq_iff_eq (e : M ≃ₜ* N) {x y : M} : e x = e y ↔ x = y := e.injective.eq_iff end bijective section refl variable (M) /-- The identity map is a continuous multiplicative isomorphism. -/ @[to_additive (attr := refl) /-- The identity map is a continuous additive isomorphism. -/] def refl : M ≃ₜ* M := { MulEquiv.refl _ with continuous_toFun := by dsimp; fun_prop continuous_invFun := by dsimp; fun_prop } @[to_additive] instance : Inhabited (M ≃ₜ* M) := ⟨ContinuousMulEquiv.refl M⟩ @[to_additive (attr := simp, norm_cast)] theorem coe_refl : ↑(refl M) = id := rfl @[to_additive (attr := simp)] theorem refl_apply (m : M) : refl M m = m := rfl end refl section symm /-- The inverse of a ContinuousMulEquiv. -/ @[to_additive (attr := symm) /-- The inverse of a ContinuousAddEquiv. -/] def symm (cme : M ≃ₜ* N) : N ≃ₜ* M := { cme.toMulEquiv.symm with continuous_toFun := cme.continuous_invFun continuous_invFun := cme.continuous_toFun } /-- See Note [custom simps projection] -/ @[to_additive /-- See Note [custom simps projection] -/] def Simps.symm_apply [Mul G] [Mul H] (e : G ≃ₜ* H) : H → G := e.symm initialize_simps_projections ContinuousMulEquiv (toFun → apply, invFun → symm_apply) initialize_simps_projections ContinuousAddEquiv (toFun → apply, invFun → symm_apply) @[to_additive] theorem invFun_eq_symm {f : M ≃ₜ* N} : f.invFun = f.symm := rfl @[to_additive (attr := simp)] theorem coe_toHomeomorph_symm (f : M ≃ₜ* N) : (f : M ≃ₜ N).symm = (f.symm : N ≃ₜ M) := rfl @[to_additive (attr := simp)] theorem equivLike_inv_eq_symm (f : M ≃ₜ* N) : EquivLike.inv f = f.symm := rfl @[to_additive (attr := simp)] theorem symm_symm (f : M ≃ₜ* N) : f.symm.symm = f := rfl @[to_additive] theorem symm_bijective : Function.Bijective (symm : M ≃ₜ* N → _) := Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩ /-- `e.symm` is a right inverse of `e`, written as `e (e.symm y) = y`. -/ @[to_additive (attr := simp) /-- `e.symm` is a right inverse of `e`, written as `e (e.symm y) = y`. -/] theorem apply_symm_apply (e : M ≃ₜ* N) (y : N) : e (e.symm y) = y := e.toEquiv.apply_symm_apply y /-- `e.symm` is a left inverse of `e`, written as `e.symm (e y) = y`. -/ @[to_additive (attr := simp) /-- `e.symm` is a left inverse of `e`, written as `e.symm (e y) = y`. -/] theorem symm_apply_apply (e : M ≃ₜ* N) (x : M) : e.symm (e x) = x := e.toEquiv.symm_apply_apply x @[to_additive (attr := simp)] theorem symm_comp_self (e : M ≃ₜ* N) : e.symm ∘ e = id := funext e.symm_apply_apply @[to_additive (attr := simp)] theorem self_comp_symm (e : M ≃ₜ* N) : e ∘ e.symm = id := funext e.apply_symm_apply @[to_additive] theorem apply_eq_iff_symm_apply (e : M ≃ₜ* N) {x : M} {y : N} : e x = y ↔ x = e.symm y := e.toEquiv.apply_eq_iff_eq_symm_apply @[to_additive] theorem symm_apply_eq (e : M ≃ₜ* N) {x y} : e.symm x = y ↔ x = e y := e.toEquiv.symm_apply_eq @[to_additive] theorem eq_symm_apply (e : M ≃ₜ* N) {x y} : y = e.symm x ↔ e y = x := e.toEquiv.eq_symm_apply @[to_additive] theorem eq_comp_symm {α : Type*} (e : M ≃ₜ* N) (f : N → α) (g : M → α) : f = g ∘ e.symm ↔ f ∘ e = g := e.toEquiv.eq_comp_symm f g @[to_additive] theorem comp_symm_eq {α : Type*} (e : M ≃ₜ* N) (f : N → α) (g : M → α) : g ∘ e.symm = f ↔ g = f ∘ e := e.toEquiv.comp_symm_eq f g @[to_additive] theorem eq_symm_comp {α : Type*} (e : M ≃ₜ* N) (f : α → M) (g : α → N) : f = e.symm ∘ g ↔ e ∘ f = g := e.toEquiv.eq_symm_comp f g @[to_additive] theorem symm_comp_eq {α : Type*} (e : M ≃ₜ* N) (f : α → M) (g : α → N) : e.symm ∘ g = f ↔ g = e ∘ f := e.toEquiv.symm_comp_eq f g end symm section trans variable {L : Type*} [Mul L] [TopologicalSpace L] /-- The composition of two ContinuousMulEquiv. -/ @[to_additive /-- The composition of two ContinuousAddEquiv. -/] def trans (cme1 : M ≃ₜ* N) (cme2 : N ≃ₜ* L) : M ≃ₜ* L where __ := cme1.toMulEquiv.trans cme2.toMulEquiv continuous_toFun := by convert Continuous.comp cme2.continuous_toFun cme1.continuous_toFun continuous_invFun := by convert Continuous.comp cme1.continuous_invFun cme2.continuous_invFun @[to_additive (attr := simp)] theorem coe_trans (e₁ : M ≃ₜ* N) (e₂ : N ≃ₜ* L) : ↑(e₁.trans e₂) = e₂ ∘ e₁ := rfl @[to_additive (attr := simp)] theorem trans_apply (e₁ : M ≃ₜ* N) (e₂ : N ≃ₜ* L) (m : M) : e₁.trans e₂ m = e₂ (e₁ m) := rfl @[to_additive (attr := simp)] theorem symm_trans_apply (e₁ : M ≃ₜ* N) (e₂ : N ≃ₜ* L) (l : L) : (e₁.trans e₂).symm l = e₁.symm (e₂.symm l) := rfl @[to_additive (attr := simp)] theorem symm_trans_self (e : M ≃ₜ* N) : e.symm.trans e = refl N := DFunLike.ext _ _ e.apply_symm_apply @[to_additive (attr := simp)] theorem self_trans_symm (e : M ≃ₜ* N) : e.trans e.symm = refl M := DFunLike.ext _ _ e.symm_apply_apply end trans section unique /-- The `MulEquiv` between two monoids with a unique element. -/ @[to_additive /-- The `AddEquiv` between two `AddMonoid`s with a unique element. -/] def ofUnique {M N} [Unique M] [Unique N] [Mul M] [Mul N] [TopologicalSpace M] [TopologicalSpace N] : M ≃ₜ* N where __ := MulEquiv.ofUnique continuous_toFun := by continuity continuous_invFun := by continuity /-- There is a unique monoid homomorphism between two monoids with a unique element. -/ @[to_additive /-- There is a unique additive monoid homomorphism between two additive monoids with a unique element. -/] instance {M N} [Unique M] [Unique N] [Mul M] [Mul N] [TopologicalSpace M] [TopologicalSpace N] : Unique (M ≃ₜ* N) where default := ofUnique uniq _ := ext fun _ ↦ Subsingleton.elim _ _ end unique end ContinuousMulEquiv namespace MulEquiv variable {G H} [Mul G] [Mul H] (e : G ≃* H) (he : ∀ s, IsOpen (e ⁻¹' s) ↔ IsOpen s) include he /-- A `MulEquiv` that respects open sets is a `ContinuousMulEquiv`. -/ @[to_additive (attr := simps apply symm_apply) /-- An `AddEquiv` that respects open sets is a `ContinuousAddEquiv`. -/] def toContinuousMulEquiv : G ≃ₜ* H where toFun := e invFun := e.symm __ := e __ := e.toEquiv.toHomeomorph he variable {e} @[to_additive, simp] lemma toMulEquiv_toContinuousMulEquiv : (e.toContinuousMulEquiv he : G ≃* H) = e := rfl @[to_additive, simp] lemma toHomeomorph_toContinuousMulEquiv : (e.toContinuousMulEquiv he : G ≃ₜ H) = e.toHomeomorph he := rfl @[to_additive] lemma symm_toContinuousMulEquiv : (e.toContinuousMulEquiv he).symm = e.symm.toContinuousMulEquiv (fun s ↦ by convert (he _).symm; exact (e.preimage_symm_preimage s).symm) := rfl end MulEquiv end end
.lake/packages/mathlib/Mathlib/Topology/Algebra/WithZeroTopology.lean
import Mathlib.Algebra.Order.GroupWithZero.Canonical import Mathlib.Topology.Algebra.GroupWithZero import Mathlib.Topology.Order.OrderClosed import Mathlib.Topology.Separation.Regular /-! # The topology on linearly ordered commutative groups with zero Let `Γ₀` be a linearly ordered commutative group to which we have adjoined a zero element. Then `Γ₀` may naturally be endowed with a topology that turns `Γ₀` into a topological monoid. Neighborhoods of zero are sets containing `{ γ | γ < γ₀ }` for some invertible element `γ₀` and every invertible element is open. In particular the topology is the following: "a subset `U ⊆ Γ₀` is open if `0 ∉ U` or if there is an invertible `γ₀ ∈ Γ₀` such that `{ γ | γ < γ₀ } ⊆ U`", see `WithZeroTopology.isOpen_iff`. We prove this topology is ordered and T₅ (in addition to be compatible with the monoid structure). All this is useful to extend a valuation to a completion. This is an abstract version of how the absolute value (resp. `p`-adic absolute value) on `ℚ` is extended to `ℝ` (resp. `ℚₚ`). ## Implementation notes This topology is defined as a scoped instance since it may not be the desired topology on a linearly ordered commutative group with zero. You can locally activate this topology using `open WithZeroTopology`. -/ open Topology Filter TopologicalSpace Filter Set Function namespace WithZeroTopology variable {α Γ₀ : Type*} [LinearOrderedCommGroupWithZero Γ₀] {γ γ₁ γ₂ : Γ₀} {l : Filter α} {f : α → Γ₀} /-- The topology on a linearly ordered commutative group with a zero element adjoined. A subset U is open if 0 ∉ U or if there is an invertible element γ₀ such that {γ | γ < γ₀} ⊆ U. -/ scoped instance (priority := 100) topologicalSpace : TopologicalSpace Γ₀ := nhdsAdjoint 0 <| ⨅ γ ≠ 0, 𝓟 (Iio γ) theorem nhds_eq_update : (𝓝 : Γ₀ → Filter Γ₀) = update pure 0 (⨅ γ ≠ 0, 𝓟 (Iio γ)) := by rw [nhds_nhdsAdjoint, sup_of_le_right] exact le_iInf₂ fun γ hγ ↦ le_principal_iff.2 <| zero_lt_iff.2 hγ /-! ### Neighbourhoods of zero -/ theorem nhds_zero : 𝓝 (0 : Γ₀) = ⨅ γ ≠ 0, 𝓟 (Iio γ) := by rw [nhds_eq_update, update_self] /-- In a linearly ordered group with zero element adjoined, `U` is a neighbourhood of `0` if and only if there exists a nonzero element `γ₀` such that `Iio γ₀ ⊆ U`. -/ theorem hasBasis_nhds_zero : (𝓝 (0 : Γ₀)).HasBasis (fun γ : Γ₀ => γ ≠ 0) Iio := by rw [nhds_zero] refine hasBasis_biInf_principal ?_ ⟨1, one_ne_zero⟩ exact directedOn_iff_directed.2 (Monotone.directed_ge fun a b hab => Iio_subset_Iio hab) theorem Iio_mem_nhds_zero (hγ : γ ≠ 0) : Iio γ ∈ 𝓝 (0 : Γ₀) := hasBasis_nhds_zero.mem_of_mem hγ /-- If `γ` is an invertible element of a linearly ordered group with zero element adjoined, then `Iio (γ : Γ₀)` is a neighbourhood of `0`. -/ theorem nhds_zero_of_units (γ : Γ₀ˣ) : Iio ↑γ ∈ 𝓝 (0 : Γ₀) := Iio_mem_nhds_zero γ.ne_zero theorem tendsto_zero : Tendsto f l (𝓝 (0 : Γ₀)) ↔ ∀ (γ₀) (_ : γ₀ ≠ 0), ∀ᶠ x in l, f x < γ₀ := by simp [nhds_zero] /-! ### Neighbourhoods of non-zero elements -/ /-- The neighbourhood filter of a nonzero element consists of all sets containing that element. -/ @[simp] theorem nhds_of_ne_zero {γ : Γ₀} (h₀ : γ ≠ 0) : 𝓝 γ = pure γ := nhds_nhdsAdjoint_of_ne _ h₀ /-- The neighbourhood filter of an invertible element consists of all sets containing that element. -/ theorem nhds_coe_units (γ : Γ₀ˣ) : 𝓝 (γ : Γ₀) = pure (γ : Γ₀) := nhds_of_ne_zero γ.ne_zero /-- If `γ` is an invertible element of a linearly ordered group with zero element adjoined, then `{γ}` is a neighbourhood of `γ`. -/ theorem singleton_mem_nhds_of_units (γ : Γ₀ˣ) : ({↑γ} : Set Γ₀) ∈ 𝓝 (γ : Γ₀) := by simp /-- If `γ` is a nonzero element of a linearly ordered group with zero element adjoined, then `{γ}` is a neighbourhood of `γ`. -/ theorem singleton_mem_nhds_of_ne_zero (h : γ ≠ 0) : ({γ} : Set Γ₀) ∈ 𝓝 (γ : Γ₀) := by simp [h] theorem hasBasis_nhds_of_ne_zero {x : Γ₀} (h : x ≠ 0) : HasBasis (𝓝 x) (fun _ : Unit => True) fun _ => {x} := by rw [nhds_of_ne_zero h] exact hasBasis_pure _ theorem hasBasis_nhds_units (γ : Γ₀ˣ) : HasBasis (𝓝 (γ : Γ₀)) (fun _ : Unit => True) fun _ => {↑γ} := hasBasis_nhds_of_ne_zero γ.ne_zero theorem tendsto_of_ne_zero {γ : Γ₀} (h : γ ≠ 0) : Tendsto f l (𝓝 γ) ↔ ∀ᶠ x in l, f x = γ := by rw [nhds_of_ne_zero h, tendsto_pure] theorem tendsto_units {γ₀ : Γ₀ˣ} : Tendsto f l (𝓝 (γ₀ : Γ₀)) ↔ ∀ᶠ x in l, f x = γ₀ := tendsto_of_ne_zero γ₀.ne_zero theorem Iio_mem_nhds (h : γ₁ < γ₂) : Iio γ₂ ∈ 𝓝 γ₁ := by rcases eq_or_ne γ₁ 0 with (rfl | h₀) <;> simp [*, h.ne', Iio_mem_nhds_zero] /-! ### Open/closed sets -/ theorem isOpen_iff {s : Set Γ₀} : IsOpen s ↔ (0 : Γ₀) ∉ s ∨ ∃ γ, γ ≠ 0 ∧ Iio γ ⊆ s := by rw [isOpen_iff_mem_nhds, ← and_forall_ne (0 : Γ₀)] simp +contextual [nhds_of_ne_zero, imp_iff_not_or, hasBasis_nhds_zero.mem_iff] theorem isClosed_iff {s : Set Γ₀} : IsClosed s ↔ (0 : Γ₀) ∈ s ∨ ∃ γ, γ ≠ 0 ∧ s ⊆ Ici γ := by simp only [← isOpen_compl_iff, isOpen_iff, mem_compl_iff, not_not, ← compl_Ici, compl_subset_compl] theorem isOpen_Iio {a : Γ₀} : IsOpen (Iio a) := isOpen_iff.mpr <| imp_iff_not_or.mp fun ha => ⟨a, ne_of_gt ha, Subset.rfl⟩ /-! ### Instances -/ /-- The topology on a linearly ordered group with zero element adjoined is compatible with the order structure: the set `{p : Γ₀ × Γ₀ | p.1 ≤ p.2}` is closed. -/ @[nolint defLemma] scoped instance (priority := 100) orderClosedTopology : OrderClosedTopology Γ₀ where isClosed_le' := by simp only [← isOpen_compl_iff, compl_setOf, not_le, isOpen_iff_mem_nhds] rintro ⟨a, b⟩ (hab : b < a) rw [nhds_prod_eq, nhds_of_ne_zero (zero_le'.trans_lt hab).ne', pure_prod] exact Iio_mem_nhds hab /-- The topology on a linearly ordered group with zero element adjoined is T₅. -/ @[nolint defLemma] scoped instance (priority := 100) t5Space : T5Space Γ₀ where completely_normal := fun s t h₁ h₂ => by by_cases hs : 0 ∈ s · have ht : 0 ∉ t := fun ht => disjoint_left.1 h₁ (subset_closure hs) ht rwa [(isOpen_iff.2 (.inl ht)).nhdsSet_eq, disjoint_nhdsSet_principal] · rwa [(isOpen_iff.2 (.inl hs)).nhdsSet_eq, disjoint_principal_nhdsSet] /-- The topology on a linearly ordered group with zero element adjoined makes it a topological monoid. -/ @[nolint defLemma] scoped instance (priority := 100) : ContinuousMul Γ₀ where continuous_mul := by simp only [continuous_iff_continuousAt, ContinuousAt] rintro ⟨x, y⟩ wlog hle : x ≤ y generalizing x y · have := (this y x (le_of_not_ge hle)).comp (continuous_swap.tendsto (x, y)) simpa only [mul_comm, Function.comp_def, Prod.swap] using this rcases eq_or_ne x 0 with (rfl | hx) <;> [rcases eq_or_ne y 0 with (rfl | hy); skip] · rw [zero_mul] refine ((hasBasis_nhds_zero.prod_nhds hasBasis_nhds_zero).tendsto_iff hasBasis_nhds_zero).2 fun γ hγ => ⟨(γ, 1), ⟨hγ, one_ne_zero⟩, ?_⟩ rintro ⟨x, y⟩ ⟨hx : x < γ, hy : y < 1⟩ exact (mul_lt_mul'' hx hy zero_le' zero_le').trans_eq (mul_one γ) · rw [zero_mul, nhds_prod_eq, nhds_of_ne_zero hy, prod_pure, tendsto_map'_iff] refine (hasBasis_nhds_zero.tendsto_iff hasBasis_nhds_zero).2 fun γ hγ => ?_ refine ⟨γ / y, div_ne_zero hγ hy, fun x hx => ?_⟩ calc x * y < γ / y * y := mul_lt_mul_of_pos_right hx (zero_lt_iff.2 hy) _ = γ := div_mul_cancel₀ _ hy · have hy : y ≠ 0 := ((zero_lt_iff.mpr hx).trans_le hle).ne' rw [nhds_prod_eq, nhds_of_ne_zero hx, nhds_of_ne_zero hy, prod_pure_pure] exact pure_le_nhds (x * y) @[nolint defLemma] scoped instance (priority := 100) : ContinuousInv₀ Γ₀ := ⟨fun γ h => by rw [ContinuousAt, nhds_of_ne_zero h] exact pure_le_nhds γ⁻¹⟩ end WithZeroTopology
.lake/packages/mathlib/Mathlib/Topology/Algebra/StarSubalgebra.lean
import Mathlib.Algebra.Star.Subalgebra import Mathlib.Topology.Algebra.Algebra import Mathlib.Topology.Algebra.Star /-! # Topological star (sub)algebras A topological star algebra over a topological semiring `R` is a topological semiring with a compatible continuous scalar multiplication by elements of `R` and a continuous star operation. We reuse typeclass `ContinuousSMul` for topological algebras. ## Results This is just a minimal stub for now! The topological closure of a star subalgebra is still a star subalgebra, which as a star algebra is a topological star algebra. -/ open Topology namespace StarSubalgebra section TopologicalStarAlgebra variable {R A B : Type*} [CommSemiring R] [StarRing R] variable [TopologicalSpace A] [Semiring A] [Algebra R A] [StarRing A] [StarModule R A] instance [IsTopologicalSemiring A] (s : StarSubalgebra R A) : IsTopologicalSemiring s := s.toSubalgebra.topologicalSemiring /-- The `StarSubalgebra.inclusion` of a star subalgebra is an embedding. -/ lemma isEmbedding_inclusion {S₁ S₂ : StarSubalgebra R A} (h : S₁ ≤ S₂) : IsEmbedding (inclusion h) where eq_induced := Eq.symm induced_compose injective := Subtype.map_injective h Function.injective_id /-- The `StarSubalgebra.inclusion` of a closed star subalgebra is a `IsClosedEmbedding`. -/ theorem isClosedEmbedding_inclusion {S₁ S₂ : StarSubalgebra R A} (h : S₁ ≤ S₂) (hS₁ : IsClosed (S₁ : Set A)) : IsClosedEmbedding (inclusion h) := { IsEmbedding.inclusion h with isClosed_range := isClosed_induced_iff.2 ⟨S₁, hS₁, by convert (Set.range_subtype_map id _).symm · rw [Set.image_id]; rfl · intro _ h' apply h h' ⟩ } variable [IsTopologicalSemiring A] [ContinuousStar A] variable [TopologicalSpace B] [Semiring B] [Algebra R B] [StarRing B] /-- The closure of a star subalgebra in a topological star algebra as a star subalgebra. -/ def topologicalClosure (s : StarSubalgebra R A) : StarSubalgebra R A := { s.toSubalgebra.topologicalClosure with carrier := closure (s : Set A) star_mem' := fun ha => map_mem_closure continuous_star ha fun x => (star_mem : x ∈ s → star x ∈ s) } theorem topologicalClosure_toSubalgebra_comm (s : StarSubalgebra R A) : s.topologicalClosure.toSubalgebra = s.toSubalgebra.topologicalClosure := SetLike.coe_injective rfl @[simp] theorem topologicalClosure_coe (s : StarSubalgebra R A) : (s.topologicalClosure : Set A) = closure (s : Set A) := rfl theorem le_topologicalClosure (s : StarSubalgebra R A) : s ≤ s.topologicalClosure := subset_closure theorem isClosed_topologicalClosure (s : StarSubalgebra R A) : IsClosed (s.topologicalClosure : Set A) := isClosed_closure instance {A : Type*} [UniformSpace A] [CompleteSpace A] [Semiring A] [StarRing A] [IsTopologicalSemiring A] [ContinuousStar A] [Algebra R A] [StarModule R A] {S : StarSubalgebra R A} : CompleteSpace S.topologicalClosure := isClosed_closure.completeSpace_coe theorem topologicalClosure_minimal {s t : StarSubalgebra R A} (h : s ≤ t) (ht : IsClosed (t : Set A)) : s.topologicalClosure ≤ t := closure_minimal h ht theorem topologicalClosure_mono : Monotone (topologicalClosure : _ → StarSubalgebra R A) := fun _ S₂ h => topologicalClosure_minimal (h.trans <| le_topologicalClosure S₂) (isClosed_topologicalClosure S₂) theorem topologicalClosure_map_le [StarModule R B] [IsTopologicalSemiring B] [ContinuousStar B] (s : StarSubalgebra R A) (φ : A →⋆ₐ[R] B) (hφ : IsClosedMap φ) : (map φ s).topologicalClosure ≤ map φ s.topologicalClosure := hφ.closure_image_subset _ theorem map_topologicalClosure_le [StarModule R B] [IsTopologicalSemiring B] [ContinuousStar B] (s : StarSubalgebra R A) (φ : A →⋆ₐ[R] B) (hφ : Continuous φ) : map φ s.topologicalClosure ≤ (map φ s).topologicalClosure := image_closure_subset_closure_image hφ theorem topologicalClosure_map [StarModule R B] [IsTopologicalSemiring B] [ContinuousStar B] (s : StarSubalgebra R A) (φ : A →⋆ₐ[R] B) (hφ : IsClosedMap φ) (hφ' : Continuous φ) : (map φ s).topologicalClosure = map φ s.topologicalClosure := SetLike.coe_injective <| hφ.closure_image_eq_of_continuous hφ' _ variable (R) in open StarAlgebra in lemma topologicalClosure_adjoin_le_centralizer_centralizer [T2Space A] (s : Set A) : (adjoin R s).topologicalClosure ≤ centralizer R (centralizer R s) := topologicalClosure_minimal (adjoin_le_centralizer_centralizer R s) (Set.isClosed_centralizer _) theorem _root_.Subalgebra.topologicalClosure_star_comm (s : Subalgebra R A) : (star s).topologicalClosure = star s.topologicalClosure := by suffices ∀ t : Subalgebra R A, (star t).topologicalClosure ≤ star t.topologicalClosure from le_antisymm (this s) (by simpa only [star_star] using Subalgebra.star_mono (this (star s))) exact fun t => (star t).topologicalClosure_minimal (Subalgebra.star_mono subset_closure) (isClosed_closure.preimage continuous_star) /-- If a star subalgebra of a topological star algebra is commutative, then so is its topological closure. See note [reducible non-instances]. -/ abbrev commSemiringTopologicalClosure [T2Space A] (s : StarSubalgebra R A) (hs : ∀ x y : s, x * y = y * x) : CommSemiring s.topologicalClosure := s.toSubalgebra.commSemiringTopologicalClosure hs /-- If a star subalgebra of a topological star algebra is commutative, then so is its topological closure. See note [reducible non-instances]. -/ abbrev commRingTopologicalClosure {R A} [CommRing R] [StarRing R] [TopologicalSpace A] [Ring A] [Algebra R A] [StarRing A] [StarModule R A] [IsTopologicalRing A] [ContinuousStar A] [T2Space A] (s : StarSubalgebra R A) (hs : ∀ x y : s, x * y = y * x) : CommRing s.topologicalClosure := s.toSubalgebra.commRingTopologicalClosure hs /-- Continuous `StarAlgHom`s from the topological closure of a `StarSubalgebra` whose compositions with the `StarSubalgebra.inclusion` map agree are, in fact, equal. -/ theorem _root_.StarAlgHom.ext_topologicalClosure [T2Space B] {S : StarSubalgebra R A} {φ ψ : S.topologicalClosure →⋆ₐ[R] B} (hφ : Continuous φ) (hψ : Continuous ψ) (h : φ.comp (inclusion (le_topologicalClosure S)) = ψ.comp (inclusion (le_topologicalClosure S))) : φ = ψ := by rw [DFunLike.ext'_iff] have : DenseRange (Set.inclusion (le_topologicalClosure S)) := by simp [-SetLike.coe_sort_coe] refine Continuous.ext_on this hφ hψ ?_ rintro _ ⟨x, rfl⟩ simpa only using DFunLike.congr_fun h x theorem _root_.StarAlgHomClass.ext_topologicalClosure [T2Space B] {F : Type*} {S : StarSubalgebra R A} [FunLike F S.topologicalClosure B] [AlgHomClass F R S.topologicalClosure B] [StarHomClass F S.topologicalClosure B] {φ ψ : F} (hφ : Continuous φ) (hψ : Continuous ψ) (h : ∀ x : S, φ (inclusion (le_topologicalClosure S) x) = ψ ((inclusion (le_topologicalClosure S)) x)) : φ = ψ := by have : (φ : S.topologicalClosure →⋆ₐ[R] B) = (ψ : S.topologicalClosure →⋆ₐ[R] B) := by refine StarAlgHom.ext_topologicalClosure (R := R) (A := A) (B := B) hφ hψ (StarAlgHom.ext ?_) simpa only [StarAlgHom.coe_comp, StarAlgHom.coe_coe] using h rw [DFunLike.ext'_iff, ← StarAlgHom.coe_coe] apply congrArg _ this end TopologicalStarAlgebra end StarSubalgebra section Elemental namespace StarAlgebra open StarSubalgebra variable (R : Type*) {A B : Type*} [CommSemiring R] [StarRing R] variable [TopologicalSpace A] [Semiring A] [StarRing A] [IsTopologicalSemiring A] variable [ContinuousStar A] [Algebra R A] [StarModule R A] variable [TopologicalSpace B] [Semiring B] [StarRing B] [Algebra R B] /-- The topological closure of the star subalgebra generated by a single element. -/ def elemental (x : A) : StarSubalgebra R A := (adjoin R ({x} : Set A)).topologicalClosure namespace elemental @[simp, aesop safe (rule_sets := [SetLike])] theorem self_mem (x : A) : x ∈ elemental R x := le_topologicalClosure _ (self_mem_adjoin_singleton R x) @[simp, aesop safe (rule_sets := [SetLike])] theorem star_self_mem (x : A) : star x ∈ elemental R x := star_mem <| self_mem R x /-- The `elemental` star subalgebra generated by a normal element is commutative. -/ instance [T2Space A] {x : A} [IsStarNormal x] : CommSemiring (elemental R x) := StarSubalgebra.commSemiringTopologicalClosure _ mul_comm /-- The `elemental` generated by a normal element is commutative. -/ instance {R A} [CommRing R] [StarRing R] [TopologicalSpace A] [Ring A] [Algebra R A] [StarRing A] [StarModule R A] [IsTopologicalRing A] [ContinuousStar A] [T2Space A] {x : A} [IsStarNormal x] : CommRing (elemental R x) := StarSubalgebra.commRingTopologicalClosure _ mul_comm theorem isClosed (x : A) : IsClosed (elemental R x : Set A) := isClosed_closure instance {A : Type*} [UniformSpace A] [CompleteSpace A] [Semiring A] [StarRing A] [IsTopologicalSemiring A] [ContinuousStar A] [Algebra R A] [StarModule R A] (x : A) : CompleteSpace (elemental R x) := isClosed_closure.completeSpace_coe variable {R} in theorem le_of_mem {S : StarSubalgebra R A} (hS : IsClosed (S : Set A)) {x : A} (hx : x ∈ S) : elemental R x ≤ S := topologicalClosure_minimal (adjoin_le <| Set.singleton_subset_iff.2 hx) hS variable {R} in theorem le_iff_mem {x : A} {s : StarSubalgebra R A} (hs : IsClosed (s : Set A)) : elemental R x ≤ s ↔ x ∈ s := ⟨fun h ↦ h (self_mem R x), fun h ↦ le_of_mem hs h⟩ /-- The coercion from an elemental algebra to the full algebra as a `IsClosedEmbedding`. -/ theorem isClosedEmbedding_coe (x : A) : IsClosedEmbedding ((↑) : elemental R x → A) where eq_induced := rfl injective := Subtype.coe_injective isClosed_range := by simpa using isClosed R x lemma le_centralizer_centralizer [T2Space A] (x : A) : elemental R x ≤ centralizer R (centralizer R {x}) := topologicalClosure_adjoin_le_centralizer_centralizer .. @[elab_as_elim] theorem induction_on {x y : A} (hy : y ∈ elemental R x) {P : (u : A) → u ∈ elemental R x → Prop} (self : P x (self_mem R x)) (star_self : P (star x) (star_self_mem R x)) (algebraMap : ∀ r, P (algebraMap R A r) (_root_.algebraMap_mem _ r)) (add : ∀ u hu v hv, P u hu → P v hv → P (u + v) (add_mem hu hv)) (mul : ∀ u hu v hv, P u hu → P v hv → P (u * v) (mul_mem hu hv)) (closure : ∀ s : Set A, (hs : s ⊆ elemental R x) → (∀ u, (hu : u ∈ s) → P u (hs hu)) → ∀ v, (hv : v ∈ closure s) → P v (closure_minimal hs (isClosed R x) hv)) : P y hy := by apply closure (adjoin R {x} : Set A) subset_closure (fun y hy ↦ ?_) y hy rw [SetLike.mem_coe, ← mem_toSubalgebra, adjoin_toSubalgebra] at hy induction hy using Algebra.adjoin_induction with | mem u hu => obtain ((rfl : u = x) | (hu : star u = x)) := by simpa using hu · exact self · simp_rw [← hu, star_star] at star_self exact star_self | algebraMap r => exact algebraMap r | add u v hu_mem hv_mem hu hv => exact add u (subset_closure hu_mem) v (subset_closure hv_mem) (hu hu_mem) (hv hv_mem) | mul u v hu_mem hv_mem hu hv => exact mul u (subset_closure hu_mem) v (subset_closure hv_mem) (hu hu_mem) (hv hv_mem) theorem starAlgHomClass_ext [T2Space B] {F : Type*} {a : A} [FunLike F (elemental R a) B] [AlgHomClass F R _ B] [StarHomClass F _ B] {φ ψ : F} (hφ : Continuous φ) (hψ : Continuous ψ) (h : φ ⟨a, self_mem R a⟩ = ψ ⟨a, self_mem R a⟩) : φ = ψ := by refine StarAlgHomClass.ext_topologicalClosure hφ hψ fun x => ?_ refine adjoin_induction_subtype x ?_ ?_ ?_ ?_ ?_ exacts [fun y hy => by simpa only [Set.mem_singleton_iff.mp hy] using h, fun r => by simp only [AlgHomClass.commutes], fun x y hx hy => by simp only [map_add, hx, hy], fun x y hx hy => by simp only [map_mul, hx, hy], fun x hx => by simp only [map_star, hx]] end elemental end StarAlgebra end Elemental
.lake/packages/mathlib/Mathlib/Topology/Algebra/UniformConvergence.lean
import Mathlib.Topology.Algebra.UniformMulAction import Mathlib.Algebra.Module.Pi import Mathlib.Topology.UniformSpace.UniformConvergenceTopology /-! # Algebraic facts about the topology of uniform convergence This file contains algebraic compatibility results about the uniform structure of uniform convergence / `𝔖`-convergence. They will mostly be useful for defining strong topologies on the space of continuous linear maps between two topological vector spaces. ## Main statements * `UniformFun.uniform_group` : if `G` is a uniform group, then `α →ᵤ G` a uniform group * `UniformOnFun.uniform_group` : if `G` is a uniform group, then for any `𝔖 : Set (Set α)`, `α →ᵤ[𝔖] G` a uniform group. ## Implementation notes Like in `Mathlib/Topology/UniformSpace/UniformConvergenceTopology.lean`, we use the type aliases `UniformFun` (denoted `α →ᵤ β`) and `UniformOnFun` (denoted `α →ᵤ[𝔖] β`) for functions from `α` to `β` endowed with the structures of uniform convergence and `𝔖`-convergence. ## References * [N. Bourbaki, *General Topology, Chapter X*][bourbaki1966] * [N. Bourbaki, *Topological Vector Spaces*][bourbaki1987] ## Tags uniform convergence, strong dual -/ open Filter open scoped Topology Pointwise UniformConvergence Uniformity section AlgebraicInstances variable {α β ι R : Type*} {𝔖 : Set <| Set α} {x : α} @[to_additive] instance [One β] : One (α →ᵤ β) := Pi.instOne @[to_additive (attr := simp)] lemma UniformFun.toFun_one [One β] : toFun (1 : α →ᵤ β) = 1 := rfl @[to_additive (attr := simp)] lemma UniformFun.ofFun_one [One β] : ofFun (1 : α → β) = 1 := rfl @[to_additive] instance [One β] : One (α →ᵤ[𝔖] β) := Pi.instOne @[to_additive (attr := simp)] lemma UniformOnFun.toFun_one [One β] : toFun 𝔖 (1 : α →ᵤ[𝔖] β) = 1 := rfl @[to_additive (attr := simp)] lemma UniformOnFun.one_apply [One β] : ofFun 𝔖 (1 : α → β) = 1 := rfl @[to_additive] instance [Mul β] : Mul (α →ᵤ β) := Pi.instMul @[to_additive (attr := simp)] lemma UniformFun.toFun_mul [Mul β] (f g : α →ᵤ β) : toFun (f * g) = toFun f * toFun g := rfl @[to_additive (attr := simp)] lemma UniformFun.ofFun_mul [Mul β] (f g : α → β) : ofFun (f * g) = ofFun f * ofFun g := rfl @[to_additive] instance [Mul β] : Mul (α →ᵤ[𝔖] β) := Pi.instMul @[to_additive (attr := simp)] lemma UniformOnFun.toFun_mul [Mul β] (f g : α →ᵤ[𝔖] β) : toFun 𝔖 (f * g) = toFun 𝔖 f * toFun 𝔖 g := rfl @[to_additive (attr := simp)] lemma UniformOnFun.ofFun_mul [Mul β] (f g : α → β) : ofFun 𝔖 (f * g) = ofFun 𝔖 f * ofFun 𝔖 g := rfl @[to_additive] instance [Inv β] : Inv (α →ᵤ β) := Pi.instInv @[to_additive (attr := simp)] lemma UniformFun.toFun_inv [Inv β] (f : α →ᵤ β) : toFun (f⁻¹) = (toFun f)⁻¹ := rfl @[to_additive (attr := simp)] lemma UniformFun.ofFun_inv [Inv β] (f : α → β) : ofFun (f⁻¹) = (ofFun f)⁻¹ := rfl @[to_additive] instance [Inv β] : Inv (α →ᵤ[𝔖] β) := Pi.instInv @[to_additive (attr := simp)] lemma UniformOnFun.toFun_inv [Inv β] (f : α →ᵤ[𝔖] β) : toFun 𝔖 (f⁻¹) = (toFun 𝔖 f)⁻¹ := rfl @[to_additive (attr := simp)] lemma UniformOnFun.ofFun_inv [Inv β] (f : α → β) : ofFun 𝔖 (f⁻¹) = (ofFun 𝔖 f)⁻¹ := rfl @[to_additive] instance [Div β] : Div (α →ᵤ β) := Pi.instDiv @[to_additive (attr := simp)] lemma UniformFun.toFun_div [Div β] (f g : α →ᵤ β) : toFun (f / g) = toFun f / toFun g := rfl @[to_additive (attr := simp)] lemma UniformFun.ofFun_div [Div β] (f g : α → β) : ofFun (f / g) = ofFun f / ofFun g := rfl @[to_additive] instance [Div β] : Div (α →ᵤ[𝔖] β) := Pi.instDiv @[to_additive (attr := simp)] lemma UniformOnFun.toFun_div [Div β] (f g : α →ᵤ[𝔖] β) : toFun 𝔖 (f / g) = toFun 𝔖 f / toFun 𝔖 g := rfl @[to_additive (attr := simp)] lemma UniformOnFun.ofFun_div [Div β] (f g : α → β) : ofFun 𝔖 (f / g) = ofFun 𝔖 f / ofFun 𝔖 g := rfl @[to_additive] instance [Monoid β] : Monoid (α →ᵤ β) := Pi.monoid @[to_additive] instance [Monoid β] : Monoid (α →ᵤ[𝔖] β) := Pi.monoid @[to_additive] instance [CommMonoid β] : CommMonoid (α →ᵤ β) := Pi.commMonoid @[to_additive] instance [CommMonoid β] : CommMonoid (α →ᵤ[𝔖] β) := Pi.commMonoid @[to_additive] instance [Group β] : Group (α →ᵤ β) := Pi.group @[to_additive] instance [Group β] : Group (α →ᵤ[𝔖] β) := Pi.group @[to_additive] instance [CommGroup β] : CommGroup (α →ᵤ β) := Pi.commGroup @[to_additive] instance [CommGroup β] : CommGroup (α →ᵤ[𝔖] β) := Pi.commGroup instance {M : Type*} [SMul M β] : SMul M (α →ᵤ β) := Pi.instSMul @[simp] lemma UniformFun.toFun_smul {M : Type*} [SMul M β] (c : M) (f : α →ᵤ β) : toFun (c • f) = c • toFun f := rfl @[simp] lemma UniformFun.ofFun_smul {M : Type*} [SMul M β] (c : M) (f : α → β) : ofFun (c • f) = c • ofFun f := rfl instance {M : Type*} [SMul M β] : SMul M (α →ᵤ[𝔖] β) := Pi.instSMul @[simp] lemma UniformOnFun.toFun_smul {M : Type*} [SMul M β] (c : M) (f : α →ᵤ[𝔖] β) : toFun 𝔖 (c • f) = c • toFun 𝔖 f := rfl @[simp] lemma UniformOnFun.ofFun_smul {M : Type*} [SMul M β] (c : M) (f : α → β) : ofFun 𝔖 (c • f) = c • ofFun 𝔖 f := rfl instance {M N : Type*} [SMul M N] [SMul M β] [SMul N β] [IsScalarTower M N β] : IsScalarTower M N (α →ᵤ β) := Pi.isScalarTower instance {M N : Type*} [SMul M N] [SMul M β] [SMul N β] [IsScalarTower M N β] : IsScalarTower M N (α →ᵤ[𝔖] β) := Pi.isScalarTower instance {M N : Type*} [SMul M β] [SMul N β] [SMulCommClass M N β] : SMulCommClass M N (α →ᵤ β) := Pi.smulCommClass instance {M N : Type*} [SMul M β] [SMul N β] [SMulCommClass M N β] : SMulCommClass M N (α →ᵤ[𝔖] β) := Pi.smulCommClass instance {M : Type*} [Monoid M] [MulAction M β] : MulAction M (α →ᵤ β) := Pi.mulAction _ instance {M : Type*} [Monoid M] [MulAction M β] : MulAction M (α →ᵤ[𝔖] β) := Pi.mulAction _ instance {M : Type*} [Monoid M] [AddMonoid β] [DistribMulAction M β] : DistribMulAction M (α →ᵤ β) := Pi.distribMulAction _ instance {M : Type*} [Monoid M] [AddMonoid β] [DistribMulAction M β] : DistribMulAction M (α →ᵤ[𝔖] β) := Pi.distribMulAction _ instance [Semiring R] [AddCommMonoid β] [Module R β] : Module R (α →ᵤ β) := Pi.module _ _ _ instance [Semiring R] [AddCommMonoid β] [Module R β] : Module R (α →ᵤ[𝔖] β) := Pi.module _ _ _ end AlgebraicInstances section Group variable {α G ι : Type*} [Group G] {𝔖 : Set <| Set α} [UniformSpace G] [IsUniformGroup G] /-- If `G` is a uniform group, then `α →ᵤ G` is a uniform group as well. -/ @[to_additive /-- If `G` is a uniform additive group, then `α →ᵤ G` is a uniform additive group as well. -/] instance : IsUniformGroup (α →ᵤ G) := ⟨(-- Since `(/) : G × G → G` is uniformly continuous, -- `UniformFun.postcomp_uniformContinuous` tells us that -- `((/) ∘ —) : (α →ᵤ G × G) → (α →ᵤ G)` is uniformly continuous too. By precomposing with -- `UniformFun.uniformEquivProdArrow`, this gives that -- `(/) : (α →ᵤ G) × (α →ᵤ G) → (α →ᵤ G)` is also uniformly continuous UniformFun.postcomp_uniformContinuous uniformContinuous_div).comp UniformFun.uniformEquivProdArrow.symm.uniformContinuous⟩ @[to_additive] protected theorem UniformFun.hasBasis_nhds_one_of_basis {p : ι → Prop} {b : ι → Set G} (h : (𝓝 1 : Filter G).HasBasis p b) : (𝓝 1 : Filter (α →ᵤ G)).HasBasis p fun i => { f : α →ᵤ G | ∀ x, toFun f x ∈ b i } := by convert UniformFun.hasBasis_nhds_of_basis α _ (1 : α →ᵤ G) h.uniformity_of_nhds_one simp @[to_additive] protected theorem UniformFun.hasBasis_nhds_one : (𝓝 1 : Filter (α →ᵤ G)).HasBasis (fun V : Set G => V ∈ (𝓝 1 : Filter G)) fun V => { f : α → G | ∀ x, f x ∈ V } := UniformFun.hasBasis_nhds_one_of_basis (basis_sets _) /-- Let `𝔖 : Set (Set α)`. If `G` is a uniform group, then `α →ᵤ[𝔖] G` is a uniform group as well. -/ @[to_additive /-- Let `𝔖 : Set (Set α)`. If `G` is a uniform additive group, then `α →ᵤ[𝔖] G` is a uniform additive group as well. -/] instance : IsUniformGroup (α →ᵤ[𝔖] G) := ⟨(-- Since `(/) : G × G → G` is uniformly continuous, -- `UniformOnFun.postcomp_uniformContinuous` tells us that -- `((/) ∘ —) : (α →ᵤ[𝔖] G × G) → (α →ᵤ[𝔖] G)` is uniformly continuous too. By precomposing with -- `UniformOnFun.uniformEquivProdArrow`, this gives that -- `(/) : (α →ᵤ[𝔖] G) × (α →ᵤ[𝔖] G) → (α →ᵤ[𝔖] G)` is also uniformly continuous UniformOnFun.postcomp_uniformContinuous uniformContinuous_div).comp UniformOnFun.uniformEquivProdArrow.symm.uniformContinuous⟩ @[to_additive] protected theorem UniformOnFun.hasBasis_nhds_one_of_basis (𝔖 : Set <| Set α) (h𝔖₁ : 𝔖.Nonempty) (h𝔖₂ : DirectedOn (· ⊆ ·) 𝔖) {p : ι → Prop} {b : ι → Set G} (h : (𝓝 1 : Filter G).HasBasis p b) : (𝓝 1 : Filter (α →ᵤ[𝔖] G)).HasBasis (fun Si : Set α × ι => Si.1 ∈ 𝔖 ∧ p Si.2) fun Si => { f : α →ᵤ[𝔖] G | ∀ x ∈ Si.1, toFun 𝔖 f x ∈ b Si.2 } := by convert UniformOnFun.hasBasis_nhds_of_basis α _ 𝔖 (1 : α →ᵤ[𝔖] G) h𝔖₁ h𝔖₂ <| h.uniformity_of_nhds_one_swapped simp [UniformOnFun.gen] @[to_additive] protected theorem UniformOnFun.hasBasis_nhds_one (𝔖 : Set <| Set α) (h𝔖₁ : 𝔖.Nonempty) (h𝔖₂ : DirectedOn (· ⊆ ·) 𝔖) : (𝓝 1 : Filter (α →ᵤ[𝔖] G)).HasBasis (fun SV : Set α × Set G => SV.1 ∈ 𝔖 ∧ SV.2 ∈ (𝓝 1 : Filter G)) fun SV => { f : α →ᵤ[𝔖] G | ∀ x ∈ SV.1, f x ∈ SV.2 } := UniformOnFun.hasBasis_nhds_one_of_basis 𝔖 h𝔖₁ h𝔖₂ (basis_sets _) @[to_additive (attr := simp)] lemma UniformOnFun.ofFun_prod {β : Type*} [CommMonoid β] {f : ι → α → β} (I : Finset ι) : ofFun 𝔖 (∏ i ∈ I, f i) = ∏ i ∈ I, ofFun 𝔖 (f i) := rfl @[to_additive (attr := simp)] lemma UniformOnFun.toFun_prod {β : Type*} [CommMonoid β] {f : ι → α → β} (I : Finset ι) : toFun 𝔖 (∏ i ∈ I, f i) = ∏ i ∈ I, toFun 𝔖 (f i) := rfl @[to_additive (attr := simp)] lemma UniformFun.ofFun_prod {β : Type*} [CommMonoid β] {f : ι → α → β} (I : Finset ι) : ofFun (∏ i ∈ I, f i) = ∏ i ∈ I, ofFun (f i) := rfl @[to_additive (attr := simp)] lemma UniformFun.toFun_prod {β : Type*} [CommMonoid β] {f : ι → α → β} (I : Finset ι) : toFun (∏ i ∈ I, f i) = ∏ i ∈ I, toFun (f i) := rfl end Group section ConstSMul variable (M α X : Type*) [SMul M X] [UniformSpace X] [UniformContinuousConstSMul M X] instance UniformFun.uniformContinuousConstSMul : UniformContinuousConstSMul M (α →ᵤ X) where uniformContinuous_const_smul c := UniformFun.postcomp_uniformContinuous <| uniformContinuous_const_smul c instance UniformFunOn.uniformContinuousConstSMul {𝔖 : Set (Set α)} : UniformContinuousConstSMul M (α →ᵤ[𝔖] X) where uniformContinuous_const_smul c := UniformOnFun.postcomp_uniformContinuous <| uniformContinuous_const_smul c end ConstSMul
.lake/packages/mathlib/Mathlib/Topology/Algebra/Constructions.lean
import Mathlib.Topology.Separation.Hausdorff import Mathlib.Topology.Homeomorph.Lemmas /-! # Topological space structure on the opposite monoid and on the units group In this file we define `TopologicalSpace` structure on `Mᵐᵒᵖ`, `Mᵃᵒᵖ`, `Mˣ`, and `AddUnits M`. This file does not import definitions of a topological monoid and/or a continuous multiplicative action, so we postpone the proofs of `HasContinuousMul Mᵐᵒᵖ` etc. till we have these definitions. ## Tags topological space, opposite monoid, units -/ variable {M N X : Type*} open Filter Topology namespace MulOpposite /-- Put the same topological space structure on the opposite monoid as on the original space. -/ @[to_additive /-- Put the same topological space structure on the opposite monoid as on the original space. -/] instance instTopologicalSpaceMulOpposite [TopologicalSpace M] : TopologicalSpace Mᵐᵒᵖ := TopologicalSpace.induced (unop : Mᵐᵒᵖ → M) ‹_› variable [TopologicalSpace M] @[to_additive (attr := continuity, fun_prop)] theorem continuous_unop : Continuous (unop : Mᵐᵒᵖ → M) := continuous_induced_dom @[to_additive (attr := continuity, fun_prop)] theorem continuous_op : Continuous (op : M → Mᵐᵒᵖ) := continuous_induced_rng.2 continuous_id /-- `MulOpposite.op` as a homeomorphism. -/ @[to_additive (attr := simps!) /-- `AddOpposite.op` as a homeomorphism. -/] def opHomeomorph : M ≃ₜ Mᵐᵒᵖ where toEquiv := opEquiv continuous_toFun := continuous_op continuous_invFun := continuous_unop @[to_additive] instance instT2Space [T2Space M] : T2Space Mᵐᵒᵖ := opHomeomorph.t2Space @[to_additive] instance instDiscreteTopology [DiscreteTopology M] : DiscreteTopology Mᵐᵒᵖ := opHomeomorph.symm.isEmbedding.discreteTopology @[to_additive] instance instCompactSpace [CompactSpace M] : CompactSpace Mᵐᵒᵖ := opHomeomorph.compactSpace @[to_additive] instance instWeaklyLocallyCompactSpace [WeaklyLocallyCompactSpace M] : WeaklyLocallyCompactSpace Mᵐᵒᵖ := opHomeomorph.symm.isClosedEmbedding.weaklyLocallyCompactSpace @[to_additive] instance instLocallyCompactSpace [LocallyCompactSpace M] : LocallyCompactSpace Mᵐᵒᵖ := opHomeomorph.symm.isClosedEmbedding.locallyCompactSpace @[to_additive (attr := simp)] theorem map_op_nhds (x : M) : map (op : M → Mᵐᵒᵖ) (𝓝 x) = 𝓝 (op x) := opHomeomorph.map_nhds_eq x @[to_additive (attr := simp)] theorem map_unop_nhds (x : Mᵐᵒᵖ) : map (unop : Mᵐᵒᵖ → M) (𝓝 x) = 𝓝 (unop x) := opHomeomorph.symm.map_nhds_eq x @[to_additive (attr := simp)] theorem comap_op_nhds (x : Mᵐᵒᵖ) : comap (op : M → Mᵐᵒᵖ) (𝓝 x) = 𝓝 (unop x) := opHomeomorph.comap_nhds_eq x @[to_additive (attr := simp)] theorem comap_unop_nhds (x : M) : comap (unop : Mᵐᵒᵖ → M) (𝓝 x) = 𝓝 (op x) := opHomeomorph.symm.comap_nhds_eq x end MulOpposite namespace Units open MulOpposite variable [TopologicalSpace M] [Monoid M] [TopologicalSpace N] [Monoid N] [TopologicalSpace X] /-- The units of a monoid are equipped with a topology, via the embedding into `M × M`. -/ @[to_additive /-- The additive units of a monoid are equipped with a topology, via the embedding into `M × M`. -/] instance instTopologicalSpaceUnits : TopologicalSpace Mˣ := TopologicalSpace.induced (embedProduct M) inferInstance @[to_additive] theorem isInducing_embedProduct : IsInducing (embedProduct M) := ⟨rfl⟩ @[to_additive] theorem isEmbedding_embedProduct : IsEmbedding (embedProduct M) := ⟨isInducing_embedProduct, embedProduct_injective M⟩ @[to_additive] instance instT2Space [T2Space M] : T2Space Mˣ := isEmbedding_embedProduct.t2Space @[to_additive] instance instDiscreteTopology [DiscreteTopology M] : DiscreteTopology Mˣ := isEmbedding_embedProduct.discreteTopology @[to_additive] lemma topology_eq_inf : instTopologicalSpaceUnits = .induced (val : Mˣ → M) ‹_› ⊓ .induced (fun u ↦ ↑u⁻¹ : Mˣ → M) ‹_› := by simp only [isInducing_embedProduct.1, instTopologicalSpaceProd, induced_inf, instTopologicalSpaceMulOpposite, induced_compose]; rfl /-- An auxiliary lemma that can be used to prove that coercion `Mˣ → M` is a topological embedding. Use `Units.isEmbedding_val₀`, `Units.isEmbedding_val`, or `toUnits_homeomorph` instead. -/ @[to_additive /-- An auxiliary lemma that can be used to prove that coercion `AddUnits M → M` is a topological embedding. Use `AddUnits.isEmbedding_val` or `toAddUnits_homeomorph` instead. -/] lemma isEmbedding_val_mk' {M : Type*} [Monoid M] [TopologicalSpace M] {f : M → M} (hc : ContinuousOn f {x : M | IsUnit x}) (hf : ∀ u : Mˣ, f u.1 = ↑u⁻¹) : IsEmbedding (val : Mˣ → M) := by refine ⟨⟨?_⟩, val_injective⟩ rw [topology_eq_inf, inf_eq_left, ← continuous_iff_le_induced, @continuous_iff_continuousAt _ _ (.induced _ _)] intro u s hs simp only [← hf, nhds_induced, Filter.mem_map] at hs ⊢ exact ⟨_, mem_inf_principal.1 (hc u u.isUnit hs), fun u' hu' ↦ hu' u'.isUnit⟩ /-- An auxiliary lemma that can be used to prove that coercion `Mˣ → M` is a topological embedding. Use `Units.isEmbedding_val₀`, `Units.isEmbedding_val`, or `toUnits_homeomorph` instead. -/ @[to_additive /-- An auxiliary lemma that can be used to prove that coercion `AddUnits M → M` is a topological embedding. Use `AddUnits.isEmbedding_val` or `toAddUnits_homeomorph` instead. -/] lemma embedding_val_mk {M : Type*} [DivisionMonoid M] [TopologicalSpace M] (h : ContinuousOn Inv.inv {x : M | IsUnit x}) : IsEmbedding (val : Mˣ → M) := isEmbedding_val_mk' h fun u ↦ (val_inv_eq_inv_val u).symm @[to_additive] theorem continuous_embedProduct : Continuous (embedProduct M) := continuous_induced_dom @[to_additive (attr := fun_prop)] theorem continuous_val : Continuous ((↑) : Mˣ → M) := (@continuous_embedProduct M _ _).fst @[to_additive] protected theorem continuous_iff {f : X → Mˣ} : Continuous f ↔ Continuous (val ∘ f) ∧ Continuous (fun x => ↑(f x)⁻¹ : X → M) := by simp only [isInducing_embedProduct.continuous_iff, embedProduct_apply, Function.comp_def, continuous_prodMk, opHomeomorph.symm.isInducing.continuous_iff, opHomeomorph_symm_apply, unop_op] @[to_additive (attr := fun_prop)] theorem continuous_coe_inv : Continuous (fun u => ↑u⁻¹ : Mˣ → M) := (Units.continuous_iff.1 continuous_id).2 @[to_additive] lemma continuous_map {f : M →* N} (hf : Continuous f) : Continuous (map f) := Units.continuous_iff.mpr ⟨hf.comp continuous_val, hf.comp continuous_coe_inv⟩ @[to_additive] lemma isOpenMap_map {f : M →* N} (hf_inj : Function.Injective f) (hf : IsOpenMap f) : IsOpenMap (map f) := by rintro _ ⟨U, hU, rfl⟩ have hg_openMap := hf.prodMap <| opHomeomorph.isOpenMap.comp (hf.comp opHomeomorph.symm.isOpenMap) refine ⟨_, hg_openMap U hU, Set.ext fun y ↦ ?_⟩ simp only [embedProduct, OneHom.coe_mk, Set.mem_preimage, Set.mem_image, Prod.mk.injEq, Prod.map, Prod.exists, MulOpposite.exists, MonoidHom.coe_mk] refine ⟨fun ⟨a, b, h, ha, hb⟩ ↦ ⟨⟨a, b, hf_inj ?_, hf_inj ?_⟩, ?_⟩, fun ⟨x, hxV, hx⟩ ↦ ⟨x, x.inv, by simp [hxV, ← hx]⟩⟩ all_goals simp_all end Units
.lake/packages/mathlib/Mathlib/Topology/Algebra/Localization.lean
import Mathlib.GroupTheory.MonoidLocalization.Basic import Mathlib.RingTheory.OreLocalization.Ring import Mathlib.Topology.Algebra.Ring.Basic /-! # Localization of topological rings The topological localization of a topological commutative ring `R` at a submonoid `M` is the ring `Localization M` endowed with the final ring topology of the natural homomorphism sending `x : R` to the equivalence class of `(x, 1)` in the localization of `R` at an `M`. ## Main Results - `Localization.ringTopology`: The localization of a topological commutative ring at a submonoid is a topological ring. -/ variable {R : Type*} [CommRing R] [TopologicalSpace R] {M : Submonoid R} /-- The ring topology on `Localization M` coinduced from the natural homomorphism sending `x : R` to the equivalence class of `(x, 1)`. -/ def Localization.ringTopology : RingTopology (Localization M) := RingTopology.coinduced (Localization.monoidOf M).toFun instance : TopologicalSpace (Localization M) := Localization.ringTopology.toTopologicalSpace instance : IsTopologicalRing (Localization M) := Localization.ringTopology.toIsTopologicalRing
.lake/packages/mathlib/Mathlib/Topology/Algebra/NonUnitalStarAlgebra.lean
import Mathlib.Algebra.Star.NonUnitalSubalgebra import Mathlib.Topology.Algebra.NonUnitalAlgebra import Mathlib.Topology.Algebra.Star /-! # Non-unital topological star (sub)algebras A non-unital topological star algebra over a topological semiring `R` is a topological (non-unital) semiring with a compatible continuous scalar multiplication by elements of `R` and a continuous `star` operation. We reuse typeclasses `ContinuousSMul` and `ContinuousStar` to express the latter two conditions. ## Results Any non-unital star subalgebra of a non-unital topological star algebra is itself a non-unital topological star algebra, and its closure is again a non-unital star subalgebra. -/ namespace NonUnitalStarSubalgebra section Semiring variable {R A B : Type*} [CommSemiring R] [TopologicalSpace A] [Star A] variable [NonUnitalSemiring A] [Module R A] [IsTopologicalSemiring A] [ContinuousStar A] variable [ContinuousConstSMul R A] instance instIsTopologicalSemiring (s : NonUnitalStarSubalgebra R A) : IsTopologicalSemiring s := s.toNonUnitalSubalgebra.instIsTopologicalSemiring /-- The (topological) closure of a non-unital star subalgebra of a non-unital topological star algebra is itself a non-unital star subalgebra. -/ def topologicalClosure (s : NonUnitalStarSubalgebra R A) : NonUnitalStarSubalgebra R A := { s.toNonUnitalSubalgebra.topologicalClosure with star_mem' := fun h ↦ map_mem_closure continuous_star h fun _ ↦ star_mem carrier := _root_.closure (s : Set A) } theorem le_topologicalClosure (s : NonUnitalStarSubalgebra R A) : s ≤ s.topologicalClosure := subset_closure theorem isClosed_topologicalClosure (s : NonUnitalStarSubalgebra R A) : IsClosed (s.topologicalClosure : Set A) := isClosed_closure theorem topologicalClosure_minimal (s : NonUnitalStarSubalgebra R A) {t : NonUnitalStarSubalgebra R A} (h : s ≤ t) (ht : IsClosed (t : Set A)) : s.topologicalClosure ≤ t := closure_minimal h ht /-- If a non-unital star subalgebra of a non-unital topological star algebra is commutative, then so is its topological closure. See note [reducible non-instances] -/ abbrev nonUnitalCommSemiringTopologicalClosure [T2Space A] (s : NonUnitalStarSubalgebra R A) (hs : ∀ x y : s, x * y = y * x) : NonUnitalCommSemiring s.topologicalClosure := s.toNonUnitalSubalgebra.nonUnitalCommSemiringTopologicalClosure hs variable [TopologicalSpace B] [Star B] [NonUnitalSemiring B] [Module R B] [IsTopologicalSemiring B] [ContinuousConstSMul R B] [ContinuousStar B] (s : NonUnitalStarSubalgebra R A) {φ : A →⋆ₙₐ[R] B} lemma map_topologicalClosure_le (hφ : Continuous φ) : map φ s.topologicalClosure ≤ (map φ s).topologicalClosure := image_closure_subset_closure_image hφ lemma topologicalClosure_map_le (hφ : IsClosedMap φ) : (map φ s).topologicalClosure ≤ map φ s.topologicalClosure := hφ.closure_image_subset _ lemma topologicalClosure_map (hφ : IsClosedMap φ) (hφ' : Continuous φ) : (map φ s).topologicalClosure = map φ s.topologicalClosure := SetLike.coe_injective <| hφ.closure_image_eq_of_continuous hφ' _ open NonUnitalStarAlgebra in -- we have to shadow the variables because some things currently require `StarRing` lemma topologicalClosure_adjoin_le_centralizer_centralizer (R : Type*) {A : Type*} [CommSemiring R] [StarRing R] [TopologicalSpace A] [NonUnitalSemiring A] [StarRing A] [Module R A] [IsTopologicalSemiring A] [ContinuousStar A] [ContinuousConstSMul R A] [IsScalarTower R A A] [SMulCommClass R A A] [StarModule R A] [T2Space A] (s : Set A) : (adjoin R s).topologicalClosure ≤ centralizer R (centralizer R s) := topologicalClosure_minimal _ (adjoin_le_centralizer_centralizer R s) (Set.isClosed_centralizer _) end Semiring section Ring variable {R A : Type*} [CommRing R] [TopologicalSpace A] variable [NonUnitalRing A] [Module R A] [Star A] [IsTopologicalRing A] [ContinuousStar A] variable [ContinuousConstSMul R A] instance instIsTopologicalRing (s : NonUnitalStarSubalgebra R A) : IsTopologicalRing s := s.toNonUnitalSubring.instIsTopologicalRing /-- If a non-unital star subalgebra of a non-unital topological star algebra is commutative, then so is its topological closure. See note [reducible non-instances]. -/ abbrev nonUnitalCommRingTopologicalClosure [T2Space A] (s : NonUnitalStarSubalgebra R A) (hs : ∀ x y : s, x * y = y * x) : NonUnitalCommRing s.topologicalClosure := { s.topologicalClosure.toNonUnitalRing, s.toSubsemigroup.commSemigroupTopologicalClosure hs with } end Ring end NonUnitalStarSubalgebra namespace NonUnitalStarAlgebra open NonUnitalStarSubalgebra variable (R : Type*) {A : Type*} [CommSemiring R] [StarRing R] [NonUnitalSemiring A] [StarRing A] variable [Module R A] [IsScalarTower R A A] [SMulCommClass R A A] [StarModule R A] variable [TopologicalSpace A] [IsTopologicalSemiring A] [ContinuousConstSMul R A] [ContinuousStar A] /-- The topological closure of the non-unital star subalgebra generated by a single element. -/ def elemental (x : A) : NonUnitalStarSubalgebra R A := adjoin R {x} |>.topologicalClosure namespace elemental @[simp, aesop safe (rule_sets := [SetLike])] theorem self_mem (x : A) : x ∈ elemental R x := le_topologicalClosure _ <| self_mem_adjoin_singleton R x @[simp, aesop safe (rule_sets := [SetLike])] theorem star_self_mem (x : A) : star x ∈ elemental R x := le_topologicalClosure _ <| star_self_mem_adjoin_singleton R x variable {R} in theorem le_of_mem {x : A} {s : NonUnitalStarSubalgebra R A} (hs : IsClosed (s : Set A)) (hx : x ∈ s) : elemental R x ≤ s := topologicalClosure_minimal _ (adjoin_le <| by simpa using hx) hs variable {R} in theorem le_iff_mem {x : A} {s : NonUnitalStarSubalgebra R A} (hs : IsClosed (s : Set A)) : elemental R x ≤ s ↔ x ∈ s := ⟨fun h ↦ h (self_mem R x), fun h ↦ le_of_mem hs h⟩ theorem isClosed (x : A) : IsClosed (elemental R x : Set A) := isClosed_topologicalClosure _ instance [T2Space A] {x : A} [IsStarNormal x] : NonUnitalCommSemiring (elemental R x) := nonUnitalCommSemiringTopologicalClosure _ <| by letI : NonUnitalCommSemiring (adjoin R {x}) := by refine NonUnitalStarAlgebra.adjoinNonUnitalCommSemiringOfComm R ?_ ?_ all_goals intro y hy z hz rw [Set.mem_singleton_iff] at hy hz rw [hy, hz] exact (star_comm_self' x).symm exact fun _ _ => mul_comm _ _ instance {R A : Type*} [CommRing R] [StarRing R] [NonUnitalRing A] [StarRing A] [Module R A] [IsScalarTower R A A] [SMulCommClass R A A] [StarModule R A] [TopologicalSpace A] [IsTopologicalRing A] [ContinuousConstSMul R A] [ContinuousStar A] [T2Space A] {x : A} [IsStarNormal x] : NonUnitalCommRing (elemental R x) where mul_comm := mul_comm instance {A : Type*} [UniformSpace A] [CompleteSpace A] [NonUnitalSemiring A] [StarRing A] [IsTopologicalSemiring A] [ContinuousStar A] [Module R A] [IsScalarTower R A A] [SMulCommClass R A A] [StarModule R A] [ContinuousConstSMul R A] (x : A) : CompleteSpace (elemental R x) := isClosed_closure.completeSpace_coe /-- The coercion from an elemental algebra to the full algebra is a `IsClosedEmbedding`. -/ theorem isClosedEmbedding_coe (x : A) : Topology.IsClosedEmbedding ((↑) : elemental R x → A) where eq_induced := rfl injective := Subtype.coe_injective isClosed_range := by simpa using isClosed R x lemma le_centralizer_centralizer [T2Space A] (x : A) : elemental R x ≤ centralizer R (centralizer R {x}) := topologicalClosure_adjoin_le_centralizer_centralizer .. end elemental end NonUnitalStarAlgebra
.lake/packages/mathlib/Mathlib/Topology/Algebra/MvPolynomial.lean
import Mathlib.Algebra.MvPolynomial.Eval import Mathlib.Topology.Algebra.Ring.Basic /-! # Multivariate polynomials and continuity In this file we prove the following lemma: * `MvPolynomial.continuous_eval`: `MvPolynomial.eval` is continuous ## Tags multivariate polynomial, continuity -/ variable {X σ : Type*} [TopologicalSpace X] [CommSemiring X] [IsTopologicalSemiring X] (p : MvPolynomial σ X) theorem MvPolynomial.continuous_eval : Continuous fun x ↦ eval x p := by continuity
.lake/packages/mathlib/Mathlib/Topology/Algebra/ClosedSubgroup.lean
import Mathlib.Topology.Algebra.Group.ClosedSubgroup deprecated_module (since := "2025-04-21")
.lake/packages/mathlib/Mathlib/Topology/Algebra/AsymptoticCone.lean
import Mathlib.Analysis.Convex.Between import Mathlib.Analysis.Convex.Topology import Mathlib.Topology.Algebra.Group.AddTorsor /-! # Asymptotic cone of a set This file defines the asymptotic cone of a set in a topological affine space. ## Implementation details The asymptotic cone of a set $A$ is usually defined as the set of points $v$ for which there exist sequences $t_n > 0$ and $x_n \in A$ such that $t_n \to 0$ and $t_n x_n \to v$. We take a different approach here using filters: we define the asymptotic cone of `s` as the set of vectors `v` such that `∃ᶠ p in Filter.atTop • 𝓝 v, p ∈ s` holds. ## Main definitions * `AffineSpace.asymptoticNhds`: the filter of neighborhoods at infinity in some direction. * `asymptoticCone`: the asymptotic cone of a subset of a topological affine space. ## Main statements * `Convex.smul_vadd_mem_of_isClosed_of_mem_asymptoticCone`: if `v` is in the asymptotic cone of a closed convex set `s`, then every ray of direction `v` starting from `s` is contained in `s`. * `Convex.smul_vadd_mem_of_mem_nhds_of_mem_asymptoticCone`: if `v` is in the asymptotic cone of a convex set `s`, then every ray of direction `v` starting from the interior of `s` is contained in `s`. -/ open scoped Pointwise Topology open Filter section General variable {k V P : Type*} [Field k] [LinearOrder k] [AddCommGroup V] [Module k V] [AddTorsor V P] [TopologicalSpace V] namespace AffineSpace variable (k P) in /-- In a topological affine space `P` over `k`, `AffineSpace.asymptoticNhds k P v` is the filter of neighborhoods at infinity in directions near `v`. In a topological vector space, this is the filter `Filter.atTop • 𝓝 v`. To support affine spaces, the actual definition is different and should be considered an implementation detail. Use `AffineSpace.asymptoticNhds_eq_smul` or `AffineSpace.asymptoticNhds_eq_smul_vadd` for unfolding. -/ @[irreducible] def asymptoticNhds (v : V) : Filter P := ⨆ p, atTop (α := k) • 𝓝 v +ᵥ pure p theorem asymptoticNhds_vadd_pure (v : V) (p : P) : asymptoticNhds k V v +ᵥ pure p = asymptoticNhds k P v := by simp_rw [asymptoticNhds, vadd_pure, map_iSup, map_map, Function.comp_def] refine (Equiv.vaddConst p).iSup_congr fun _ => ?_ simp [add_vadd] theorem vadd_asymptoticNhds (u v : V) : u +ᵥ asymptoticNhds k P v = asymptoticNhds k P v := by have ⟨p⟩ : Nonempty P := inferInstance nth_rw 1 [← asymptoticNhds_vadd_pure v p] simp_rw [← asymptoticNhds_vadd_pure v (u +ᵥ p), vadd_pure, ← Filter.map_vadd, map_map] congr with v exact vadd_comm u v p variable {α : Type*} {l : Filter α} theorem _root_.Filter.Tendsto.asymptoticNhds_vadd_const {f : α → V} {v : V} (p : P) (hf : Tendsto f l (asymptoticNhds k V v)) : Tendsto (fun x => f x +ᵥ p) l (asymptoticNhds k P v) := by rw [← asymptoticNhds_vadd_pure, vadd_pure] exact tendsto_map.comp hf theorem _root_.Filter.Tendsto.const_vadd_asymptoticNhds {f : α → P} {v : V} (u : V) (hf : Tendsto f l (asymptoticNhds k P v)) : Tendsto (fun x => u +ᵥ f x) l (asymptoticNhds k P v) := by rw [← vadd_asymptoticNhds u, ← Filter.map_vadd] exact tendsto_map.comp hf variable [TopologicalSpace k] [OrderTopology k] [IsStrictOrderedRing k] [IsTopologicalAddGroup V] [ContinuousSMul k V] theorem asymptoticNhds_eq_smul (v : V) : asymptoticNhds k V v = atTop (α := k) • 𝓝 v := by unfold asymptoticNhds apply le_antisymm · refine iSup_le fun u => ?_ simp_rw [vadd_eq_add, add_pure, ← map₂_smul, map_map₂, ← map_prod_eq_map₂] have : (fun x : k × V => x.1 • x.2 + u) =ᶠ[atTop ×ˢ 𝓝 v] (Function.uncurry (· • ·)) ∘ (fun x : k × V => (x.1, x.2 + x.1⁻¹ • u)) := by filter_upwards [tendsto_fst.eventually (eventually_ne_atTop 0)] with _ h simp [h] rw [map_congr this, ← map_map] apply map_mono have : Tendsto (fun x : k × V => (x.1, x.2 + x.1⁻¹ • u)) (atTop ×ˢ 𝓝 v) _ := tendsto_fst.prodMk <| tendsto_snd.add <| tendsto_fst.inv_tendsto_atTop.smul_const u simpa · apply (le_iSup _ 0).trans' simp theorem asymptoticNhds_eq_smul_vadd (v : V) (p : P) : asymptoticNhds k P v = atTop (α := k) • 𝓝 v +ᵥ pure p := by rw [← asymptoticNhds_eq_smul, asymptoticNhds_vadd_pure] instance {v : V} : (asymptoticNhds k P v).NeBot := by have ⟨p⟩ : Nonempty P := inferInstance rw [asymptoticNhds_eq_smul_vadd v p] infer_instance private theorem asymptoticNhds_zero' : asymptoticNhds k V (0 : V) = ⊤ := by rw [← top_le_iff, ← iSup_pure_eq_top, iSup_le_iff] intro v rw [← map_const (f := atTop (α := k))] have : (fun _ => v) =ᶠ[atTop (α := k)] (Function.uncurry (· • ·)) ∘ (fun c => (c, c⁻¹ • v)) := by filter_upwards [eventually_ne_atTop 0] with _ h simp [h] rw [map_congr this, ← map_map, asymptoticNhds_eq_smul, ← map₂_smul, ← map_prod_eq_map₂] apply map_mono have : Tendsto (fun c => (c, c⁻¹ • v)) (atTop (α := k)) _ := tendsto_id.prodMk <| tendsto_inv_atTop_zero.smul_const v simpa @[simp] theorem asymptoticNhds_zero : asymptoticNhds k P (0 : V) = ⊤ := by have ⟨p⟩ : Nonempty P := inferInstance rw [← asymptoticNhds_vadd_pure 0 p, asymptoticNhds_zero', vadd_pure] exact (Equiv.vaddConst p).surjective.filter_map_top theorem _root_.Filter.Tendsto.atTop_smul_nhds_tendsto_asymptoticNhds {f : α → k} {g : α → V} {v : V} (hf : Tendsto f l atTop) (hg : Tendsto g l (𝓝 v)) : Tendsto (fun x => f x • g x) l (asymptoticNhds k V v) := by rw [asymptoticNhds_eq_smul, ← map₂_smul, ← map_prod_eq_map₂] exact tendsto_map.comp (hf.prodMk hg) theorem _root_.Filter.Tendsto.atTop_smul_const_tendsto_asymptoticNhds {f : α → k} (v : V) (hf : Tendsto f l atTop) : Tendsto (fun x => f x • v) l (asymptoticNhds k V v) := hf.atTop_smul_nhds_tendsto_asymptoticNhds tendsto_const_nhds theorem asymptoticNhds_smul (v : V) {c : k} (hc : 0 < c) : asymptoticNhds k P (c • v) = asymptoticNhds k P v := by have ⟨p⟩ : Nonempty P := inferInstance simp_rw [asymptoticNhds_eq_smul_vadd _ p, ← show map (c • ·) (𝓝 v) = 𝓝 (c • v) from (Homeomorph.smulOfNeZero c hc.ne').map_nhds_eq v, ← map₂_smul, map₂_map_right, smul_smul, ← map₂_map_left, show map (· * c) atTop = atTop from (OrderIso.mulRight₀ _ hc).map_atTop] @[simp] theorem nhds_bind_asymptoticNhds (v : V) : (𝓝 v).bind (asymptoticNhds k P) = asymptoticNhds k P v := by apply le_antisymm · have ⟨p⟩ : Nonempty P := inferInstance eta_expand simp_rw [asymptoticNhds_eq_smul_vadd _ p, vadd_pure] nth_rw 2 [← nhds_bind_nhds] simp only [le_def, mem_map, ← map₂_smul, mem_map₂_iff, mem_bind] grind · rw [← pure_bind v (asymptoticNhds k P)] exact bind_mono (pure_le_nhds v) .rfl @[simp] theorem asymptoticNhds_bind_nhds [TopologicalSpace P] [IsTopologicalAddTorsor P] (v : V) : (asymptoticNhds k P v).bind 𝓝 = asymptoticNhds k P v := by refine le_antisymm (fun s h => ?_) (bind_mono le_rfl (.of_forall pure_le_nhds)) have ⟨p⟩ : Nonempty P := inferInstance rw [asymptoticNhds_eq_smul_vadd _ p, vadd_pure] at h ⊢ rw [← nhds_bind_nhds] at h obtain ⟨t₁, ht₁, t₂, ht₂, hs⟩ := h rw [mem_bind] at ht₂ obtain ⟨t₃, ht₃, ht₂⟩ := ht₂ rw [bind_map, mem_bind] refine ⟨(t₁ ∩ Set.Ioi 0) • t₃, smul_mem_smul (inter_mem ht₁ (Ioi_mem_atTop _)) ht₃, Set.forall_mem_image2.mpr fun c ⟨hc₁, hc₂⟩ u hu => ?_⟩ rw [show s = (· -ᵥ p) ⁻¹' ((· +ᵥ p) ⁻¹' s) by simp [Set.preimage_preimage]] apply tendsto_id.vsub tendsto_const_nhds rw [vadd_vsub] filter_upwards [smul_mem_nhds_smul₀ hc₂.ne' (ht₂ u hu)] rw [← Set.image_smul, Set.forall_mem_image] exact fun w hw => hs (Set.smul_mem_smul hc₁ hw) @[simp] theorem asymptoticNhds_bind_asymptoticNhds (v : V) : (asymptoticNhds k V v).bind (asymptoticNhds k P) = asymptoticNhds k P v := by refine Filter.ext' fun p => ?_ rw [asymptoticNhds_eq_smul, eventually_bind, ← map₂_smul, ← map_prod_eq_map₂, eventually_map, ← nhds_bind_asymptoticNhds, eventually_bind] nth_rw 2 [← map_snd_prod (atTop (α := k)) (𝓝 v)] rw [eventually_map] apply eventually_congr filter_upwards [tendsto_fst.eventually (eventually_gt_atTop 0)] with ⟨c, u⟩ (hc : 0 < c) simp only [asymptoticNhds_smul _ hc] end AffineSpace open AffineSpace variable (k) in /-- The set of directions `v` for which the set has points arbitrarily far in directions near `v`. -/ def asymptoticCone (s : Set P) : Set V := {v | ∃ᶠ p in asymptoticNhds k P v, p ∈ s} theorem mem_asymptoticCone_iff {v : V} {s : Set P} : v ∈ asymptoticCone k s ↔ ∃ᶠ p in asymptoticNhds k P v, p ∈ s := Iff.rfl @[simp] theorem asymptoticCone_empty : asymptoticCone k (∅ : Set P) = ∅ := Set.eq_empty_iff_forall_notMem.mpr fun _ => frequently_false _ @[gcongr] theorem asymptoticCone_mono {s t : Set P} (h : s ⊆ t) : asymptoticCone k s ⊆ asymptoticCone k t := fun _ h' => h'.mono h theorem asymptoticCone_union {s t : Set P} : asymptoticCone k (s ∪ t) = asymptoticCone k s ∪ asymptoticCone k t := by ext simp only [Set.mem_union, mem_asymptoticCone_iff, Filter.frequently_or_distrib] theorem asymptoticCone_biUnion {ι : Type*} {s : Set ι} (hs : s.Finite) (f : ι → Set P) : asymptoticCone k (⋃ i ∈ s, f i) = ⋃ i ∈ s, asymptoticCone k (f i) := by induction s, hs using Set.Finite.induction_on <;> simp [asymptoticCone_union, *] theorem asymptoticCone_sUnion {S : Set (Set P)} (hS : S.Finite) : asymptoticCone k (⋃₀ S) = ⋃ s ∈ S, asymptoticCone k s := by rw [Set.sUnion_eq_biUnion, asymptoticCone_biUnion hS] nonrec theorem Finset.asymptoticCone_biUnion {ι : Type*} (s : Finset ι) (f : ι → Set P) : asymptoticCone k (⋃ i ∈ s, f i) = ⋃ i ∈ s, asymptoticCone k (f i) := asymptoticCone_biUnion s.finite_toSet f theorem asymptoticCone_iUnion_of_finite {ι : Type*} [Finite ι] (f : ι → Set P) : asymptoticCone k (⋃ i, f i) = ⋃ i, asymptoticCone k (f i) := by rw [← Set.sUnion_range, asymptoticCone_sUnion (Set.finite_range f), Set.biUnion_range] variable [TopologicalSpace k] [OrderTopology k] [IsStrictOrderedRing k] [IsTopologicalAddGroup V] [ContinuousSMul k V] theorem zero_mem_asymptoticCone {s : Set P} : 0 ∈ asymptoticCone k s ↔ s.Nonempty := by refine ⟨Function.mtr ?_, fun _ => ?_⟩ · simp +contextual [Set.not_nonempty_iff_eq_empty] · simpa [mem_asymptoticCone_iff] theorem asymptoticCone_nonempty {s : Set P} : (asymptoticCone k s).Nonempty ↔ s.Nonempty := by refine ⟨Function.mtr ?_, fun h => ⟨0, zero_mem_asymptoticCone.mpr h⟩⟩ simp +contextual [Set.not_nonempty_iff_eq_empty] @[simp] theorem smul_mem_asymptoticCone_iff {s : Set P} {c : k} {v : V} (hc : 0 < c) : c • v ∈ asymptoticCone k s ↔ v ∈ asymptoticCone k s := by simp_rw [mem_asymptoticCone_iff, asymptoticNhds_smul v hc] theorem smul_mem_asymptoticCone {s : Set P} {c : k} {v : V} (hc : 0 ≤ c) (h : v ∈ asymptoticCone k s) : c • v ∈ asymptoticCone k s := by rcases hc.eq_or_lt with rfl | hc · rw [zero_smul, zero_mem_asymptoticCone, ← asymptoticCone_nonempty (k := k)]; exact ⟨v, h⟩ · rwa [smul_mem_asymptoticCone_iff hc] theorem asymptoticCone_eq_closure_of_forall_smul_mem {s : Set V} (hs : ∀ c : k, 0 < c → ∀ x ∈ s, c • x ∈ s) : asymptoticCone k s = closure s := by ext v rw [mem_closure_iff_frequently, ← map_snd_prod (atTop (α := k)) (𝓝 v), frequently_map, mem_asymptoticCone_iff, asymptoticNhds_eq_smul, ← map₂_smul, ← map_prod_eq_map₂, frequently_map] apply frequently_congr filter_upwards [tendsto_fst.eventually (eventually_gt_atTop 0)] with ⟨c, u⟩ hc refine ⟨fun hu => ?_, hs c hc u⟩ specialize hs c⁻¹ (inv_pos_of_pos hc) (c • u) hu rwa [inv_smul_smul₀ hc.ne'] at hs theorem asymptoticCone_submodule {s : Submodule k V} : asymptoticCone k (s : Set V) = closure s := asymptoticCone_eq_closure_of_forall_smul_mem fun _ _ _ h => s.smul_mem _ h theorem asymptoticCone_affineSubspace {s : AffineSubspace k P} (hs : (s : Set P).Nonempty) : asymptoticCone k (s : Set P) = closure s.direction := by have ⟨p, hp⟩ := hs ext v simp_rw [← asymptoticCone_submodule, mem_asymptoticCone_iff, ← asymptoticNhds_vadd_pure v p, vadd_pure, frequently_map, SetLike.mem_coe, s.vadd_mem_iff_mem_direction _ hp] @[simp] theorem asymptoticCone_univ : asymptoticCone k (Set.univ : Set P) = Set.univ := by rw [← AffineSubspace.top_coe k, asymptoticCone_affineSubspace Set.univ_nonempty, AffineSubspace.direction_top, Submodule.top_coe, closure_univ] theorem asymptoticCone_closure [TopologicalSpace P] [IsTopologicalAddTorsor P] (s : Set P) : asymptoticCone k (closure s) = asymptoticCone k s := by ext simp_rw [mem_asymptoticCone_iff, mem_closure_iff_frequently, ← frequently_bind, asymptoticNhds_bind_nhds] theorem isClosed_asymptoticCone {s : Set P} : IsClosed (asymptoticCone k s) := by have ⟨p⟩ : Nonempty P := inferInstance rw [isClosed_iff_frequently] intro v h simp_rw [mem_asymptoticCone_iff, ← frequently_bind, nhds_bind_asymptoticNhds] at h exact h @[simp] theorem asymptoticCone_asymptoticCone (s : Set P) : asymptoticCone k (asymptoticCone k s) = asymptoticCone k s := by ext simp_rw [mem_asymptoticCone_iff, ← Filter.frequently_bind, asymptoticNhds_bind_asymptoticNhds] end General section Convex open AffineSpace variable {k V : Type*} [Field k] [LinearOrder k] [IsStrictOrderedRing k] [TopologicalSpace k] [OrderTopology k] [AddCommGroup V] [Module k V] [TopologicalSpace V] [IsTopologicalAddGroup V] [ContinuousSMul k V] {s : Set V} /-- If a closed set `s` is star-convex at `p` and `v` is in the asymptotic cone of `s`, then the ray of direction `v` starting from `p` is contained in `s`. -/ theorem StarConvex.smul_vadd_mem_of_isClosed_of_mem_asymptoticCone {c : k} {v p : V} (hs₁ : StarConvex k p s) (hs₂ : IsClosed s) (hc : 0 ≤ c) (hv : v ∈ asymptoticCone k s) : c • v +ᵥ p ∈ s := by refine isClosed_iff_frequently.mp hs₂ _ <| tendsto_snd (f := atTop (α := k)) |>.const_smul _ |>.vadd_const _ |>.frequently ?_ rw [mem_asymptoticCone_iff, asymptoticNhds_eq_smul_vadd v p, vadd_pure, frequently_map, ← map₂_smul, ← map_prod_eq_map₂, frequently_map] at hv apply hv.mp filter_upwards [tendsto_fst.eventually (eventually_ge_atTop c)] with ⟨t, u⟩ (ht : c ≤ t) (h : t • u +ᵥ p ∈ s) change c • u +ᵥ p ∈ s apply hs₁.segment_subset h simp_rw [mem_segment_iff_sameRay, ← vsub_eq_sub, vadd_vsub, vadd_vsub_vadd_cancel_right, ← sub_smul] exact (SameRay.sameRay_nonneg_smul_left _ hc).nonneg_smul_right (sub_nonneg.mpr ht) /-- If `v` is in the asymptotic cone of a closed convex set `s`, then for every `p ∈ s`, the ray of direction `v` starting from `p` is contained in `s`. -/ theorem Convex.smul_vadd_mem_of_isClosed_of_mem_asymptoticCone {c : k} {v p : V} (hs₁ : Convex k s) (hs₂ : IsClosed s) (hc : 0 ≤ c) (hv : v ∈ asymptoticCone k s) (hp : p ∈ s) : c • v +ᵥ p ∈ s := (hs₁ hp).smul_vadd_mem_of_isClosed_of_mem_asymptoticCone hs₂ hc hv protected theorem Convex.asymptoticCone (hs : Convex k s) : Convex k (asymptoticCone k s) := by wlog hs' : IsClosed s generalizing s · rw [← asymptoticCone_closure]; exact this hs.closure isClosed_closure rcases s.eq_empty_or_nonempty with rfl | ⟨p, hp⟩ · rw [asymptoticCone_empty]; exact convex_empty intro v hv u hu a b ha hb hab rw [mem_asymptoticCone_iff] refine tendsto_id.atTop_smul_const_tendsto_asymptoticNhds _ |>.asymptoticNhds_vadd_const p |>.frequently (Eventually.frequently ?_) filter_upwards [eventually_ge_atTop 0] with c hc simp_rw [id, smul_add, smul_smul] have h₁ : c • v +ᵥ p ∈ s := hs.smul_vadd_mem_of_isClosed_of_mem_asymptoticCone hs' hc hv hp have h₂ : c • u +ᵥ p ∈ s := hs.smul_vadd_mem_of_isClosed_of_mem_asymptoticCone hs' hc hu hp apply hs.segment_subset h₁ h₂ rw [← affineSegment_eq_segment, mem_vadd_const_affineSegment, affineSegment_eq_segment] exists a, b, ha, hb, hab module /-- If `v` is in the asymptotic cone of a convex set `s`, then for every interior point `p`, the ray of direction `v` starting from `p` is contained in `s`. -/ theorem Convex.smul_vadd_mem_of_mem_nhds_of_mem_asymptoticCone {c : k} {v p : V} (hs : Convex k s) (hc : 0 ≤ c) (hp : s ∈ 𝓝 p) (hv : v ∈ asymptoticCone k s) : c • v +ᵥ p ∈ s := by rw [mem_asymptoticCone_iff, asymptoticNhds_eq_smul_vadd v (c • v +ᵥ p), vadd_pure, frequently_map, ← map₂_smul, ← map_prod_eq_map₂, frequently_map] at hv refine frequently_const.mp (hv.mp ?_) have : Tendsto (fun u => - (c • u : V) +ᵥ c • v +ᵥ p) (𝓝 v) (𝓝 p) := Continuous.tendsto' (by fun_prop) _ _ (by simp) filter_upwards [tendsto_fst.eventually <| eventually_gt_atTop 0, this.comp tendsto_snd hp] with ⟨t, u⟩ (ht : 0 < t) (hu : - (c • u) +ᵥ c • v +ᵥ p ∈ s) (h : t • u +ᵥ c • v +ᵥ p ∈ s) apply hs.segment_subset hu h simp_rw [mem_segment_iff_sameRay, ← vsub_eq_sub] rw [vsub_vadd_eq_vsub_sub, vsub_self, zero_sub, neg_neg, vadd_vsub] exact (SameRay.sameRay_nonneg_smul_left _ hc).pos_smul_right ht end Convex
.lake/packages/mathlib/Mathlib/Topology/Algebra/IsOpenUnits.lean
import Mathlib.RingTheory.Jacobson.Ideal import Mathlib.Topology.Algebra.GroupWithZero import Mathlib.Topology.Algebra.Nonarchimedean.AdicTopology /-! # Topological monoids with open units We say that a topological monoid `M` has open units (`IsOpenUnits`) if `Mˣ` is open in `M` and has the subspace topology (i.e. inverse is continuous). Typical examples include monoids with discrete topology, topological groups (or fields), and rings `R` equipped with the `I`-adic topology where `I ≤ J(R)` (`IsOpenUnits.of_isAdic`). A non-example is `𝔸ₖ`, because the topology on ideles is not the induced topology from adeles. This condition is necessary and sufficient for `U(R)` to be an open subspace of `X(R)` for all affine scheme `X` over `R` and all affine open subscheme `U ⊆ X`. -/ open Topology /-- We say that a topological monoid `M` has open units if `Mˣ` is open in `M` and has the subspace topology (i.e. inverse is continuous). Typical examples include monoids with discrete topology, topological groups (or fields), and rings `R` equipped with the `I`-adic topology where `I ≤ J(R)`. -/ @[mk_iff] class IsOpenUnits (M : Type*) [Monoid M] [TopologicalSpace M] : Prop where isOpenEmbedding_unitsVal : IsOpenEmbedding (Units.val : Mˣ → M) instance (priority := 900) (M : Type*) [Monoid M] [TopologicalSpace M] [DiscreteTopology M] : IsOpenUnits M where isOpenEmbedding_unitsVal := .of_continuous_injective_isOpenMap Units.continuous_val Units.val_injective fun _ _ ↦ isOpen_discrete _ instance (priority := 900) {M : Type*} [Group M] [TopologicalSpace M] [ContinuousInv M] : IsOpenUnits M where isOpenEmbedding_unitsVal := toUnits_homeomorph.symm.isOpenEmbedding instance (priority := 900) {M : Type*} [GroupWithZero M] [TopologicalSpace M] [ContinuousInv₀ M] [T1Space M] : IsOpenUnits M where isOpenEmbedding_unitsVal := by refine ⟨Units.isEmbedding_val₀, ?_⟩ convert (isClosed_singleton (X := M) (x := 0)).isOpen_compl ext simp only [Set.mem_range, Set.mem_compl_iff, Set.mem_singleton_iff] exact isUnit_iff_ne_zero /-- If `R` has the `I`-adic topology where `I` is contained in the Jacobson radical (e.g. when `R` is complete or local), then `Rˣ` is an open subspace of `R`. -/ lemma IsOpenUnits.of_isAdic {R : Type*} [CommRing R] [TopologicalSpace R] [IsTopologicalRing R] {I : Ideal R} (hR : IsAdic I) (hI : I ≤ Ideal.jacobson ⊥) : IsOpenUnits R := by refine ⟨.of_continuous_injective_isOpenMap Units.continuous_val Units.val_injective ?_⟩ refine (IsTopologicalGroup.isOpenMap_iff_nhds_one (f := Units.coeHom R)).mpr ?_ rw [nhds_induced, nhds_prod_eq] simp only [Units.embedProduct_apply, Units.val_one, inv_one, MulOpposite.op_one] intro s hs have H := hR ▸ Ideal.hasBasis_nhds_adic I 1 have := (H.prod (H.comap MulOpposite.opHomeomorph.symm)) simp only [Homeomorph.comap_nhds_eq, Homeomorph.symm_symm, MulOpposite.opHomeomorph_apply, MulOpposite.op_one, and_self, Set.image_add_left] at this have : ∃ n₁ n₂, ∀ (u : Rˣ), (-1 + u : R) ∈ I ^ n₁ → (-1 + u⁻¹ : R) ∈ I ^ n₂ → ↑u ∈ s := by simpa [Set.subset_def, forall_comm (β := Rˣ), forall_comm (β := _ = _)] using (((this.comap (Units.embedProduct R)).map (Units.coeHom R)).1 _).mp hs obtain ⟨n, hn, hn'⟩ : ∃ n ≠ 0, ∀ (u : Rˣ), (-1 + u : R) ∈ I ^ n → (-1 + u⁻¹ : R) ∈ I ^ n → ↑u ∈ s := by obtain ⟨n₁, n₂, H⟩ := this exact ⟨n₁ ⊔ n₂ ⊔ 1, by simp, fun u h₁ h₂ ↦ H u (Ideal.pow_le_pow_right (by simp) h₁) (Ideal.pow_le_pow_right (by simp) h₂)⟩ rw [H.1] refine ⟨n, trivial, ?_⟩ rintro _ ⟨x, hx, rfl⟩ have := Ideal.mem_jacobson_bot.mp (hI (Ideal.pow_le_self hn hx)) 1 rw [mul_one, add_comm] at this refine hn' this.unit (by simpa using hx) ?_ have : -1 + ↑this.unit⁻¹ = -this.unit⁻¹ * x := by trans this.unit⁻¹ * (-(1 + x) + 1) · rw [mul_add, mul_neg, IsUnit.val_inv_mul, mul_one] · simp rw [this] exact Ideal.mul_mem_left _ _ hx
.lake/packages/mathlib/Mathlib/Topology/Algebra/Field.lean
import Mathlib.Algebra.Field.Subfield.Defs import Mathlib.Algebra.GroupWithZero.Divisibility import Mathlib.Algebra.Order.Group.Pointwise.Interval import Mathlib.Topology.Algebra.GroupWithZero import Mathlib.Topology.Algebra.Ring.Basic import Mathlib.Topology.Order.LocalExtr /-! # Topological fields A topological division ring is a topological ring whose inversion function is continuous at every non-zero element. -/ variable {K : Type*} [DivisionRing K] [TopologicalSpace K] /-- Left-multiplication by a nonzero element of a topological division ring is proper, i.e., inverse images of compact sets are compact. -/ theorem Filter.tendsto_cocompact_mul_left₀ [ContinuousMul K] {a : K} (ha : a ≠ 0) : Filter.Tendsto (fun x : K => a * x) (Filter.cocompact K) (Filter.cocompact K) := Filter.tendsto_cocompact_mul_left (inv_mul_cancel₀ ha) /-- Right-multiplication by a nonzero element of a topological division ring is proper, i.e., inverse images of compact sets are compact. -/ theorem Filter.tendsto_cocompact_mul_right₀ [ContinuousMul K] {a : K} (ha : a ≠ 0) : Filter.Tendsto (fun x : K => x * a) (Filter.cocompact K) (Filter.cocompact K) := Filter.tendsto_cocompact_mul_right (mul_inv_cancel₀ ha) /-- Compact Hausdorff topological fields are finite. This is not an instance, as it would apply to every `Finite` goal, causing slowly failing typeclass search in some cases. -/ theorem DivisionRing.finite_of_compactSpace_of_t2Space {K} [DivisionRing K] [TopologicalSpace K] [IsTopologicalRing K] [CompactSpace K] [T2Space K] : Finite K := by suffices DiscreteTopology K by exact finite_of_compact_of_discrete rw [discreteTopology_iff_isOpen_singleton_zero] exact GroupWithZero.isOpen_singleton_zero variable (K) /-- A topological division ring is a division ring with a topology where all operations are continuous, including inversion. -/ class IsTopologicalDivisionRing : Prop extends IsTopologicalRing K, ContinuousInv₀ K section Subfield variable {α : Type*} [Field α] [TopologicalSpace α] [IsTopologicalDivisionRing α] /-- The (topological-space) closure of a subfield of a topological field is itself a subfield. -/ def Subfield.topologicalClosure (K : Subfield α) : Subfield α := { K.toSubring.topologicalClosure with carrier := _root_.closure (K : Set α) inv_mem' := fun x hx => by rcases eq_or_ne x 0 with (rfl | h) · rwa [inv_zero] · rw [← inv_coe_set, ← Set.image_inv_eq_inv] exact mem_closure_image (continuousAt_inv₀ h) hx } theorem Subfield.le_topologicalClosure (s : Subfield α) : s ≤ s.topologicalClosure := _root_.subset_closure theorem Subfield.isClosed_topologicalClosure (s : Subfield α) : IsClosed (s.topologicalClosure : Set α) := isClosed_closure theorem Subfield.topologicalClosure_minimal (s : Subfield α) {t : Subfield α} (h : s ≤ t) (ht : IsClosed (t : Set α)) : s.topologicalClosure ≤ t := closure_minimal h ht end Subfield section Units /-- In an ordered field, the units of the nonnegative elements are the positive elements. -/ @[simps!] def Nonneg.unitsHomeomorphPos (R : Type*) [DivisionSemiring R] [PartialOrder R] [IsStrictOrderedRing R] [PosMulReflectLT R] [TopologicalSpace R] [ContinuousInv₀ R] : { r : R // 0 ≤ r }ˣ ≃ₜ { r : R // 0 < r } where __ := Nonneg.unitsEquivPos R continuous_toFun := by rw [Topology.IsEmbedding.subtypeVal.continuous_iff] exact Continuous.subtype_val (p := (0 ≤ ·)) Units.continuous_val continuous_invFun := by rw [Units.continuous_iff] refine ⟨by fun_prop, ?_⟩ suffices Continuous fun (x : { r : R // 0 < r }) ↦ (x⁻¹ : R) by simpa [Topology.IsEmbedding.subtypeVal.continuous_iff, Function.comp_def] rw [continuous_iff_continuousAt] exact fun x ↦ ContinuousAt.inv₀ (by fun_prop) x.2.ne' end Units section affineHomeomorph /-! This section is about affine homeomorphisms from a topological field `𝕜` to itself. Technically it does not require `𝕜` to be a topological field, a topological ring that happens to be a field is enough. -/ variable {𝕜 : Type*} [Field 𝕜] [TopologicalSpace 𝕜] [IsTopologicalRing 𝕜] /-- The map `fun x => a * x + b`, as a homeomorphism from `𝕜` (a topological field) to itself, when `a ≠ 0`. -/ @[simps] def affineHomeomorph (a b : 𝕜) (h : a ≠ 0) : 𝕜 ≃ₜ 𝕜 where toFun x := a * x + b invFun y := (y - b) / a left_inv x := by simp only [add_sub_cancel_right] exact mul_div_cancel_left₀ x h right_inv y := by simp [mul_div_cancel₀ _ h] theorem affineHomeomorph_image_Icc {𝕜 : Type*} [Field 𝕜] [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜] [TopologicalSpace 𝕜] [IsTopologicalRing 𝕜] (a b c d : 𝕜) (h : 0 < a) : affineHomeomorph a b h.ne' '' Set.Icc c d = Set.Icc (a * c + b) (a * d + b) := by simp [h] theorem affineHomeomorph_image_Ico {𝕜 : Type*} [Field 𝕜] [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜] [TopologicalSpace 𝕜] [IsTopologicalRing 𝕜] (a b c d : 𝕜) (h : 0 < a) : affineHomeomorph a b h.ne' '' Set.Ico c d = Set.Ico (a * c + b) (a * d + b) := by simp [h] theorem affineHomeomorph_image_Ioc {𝕜 : Type*} [Field 𝕜] [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜] [TopologicalSpace 𝕜] [IsTopologicalRing 𝕜] (a b c d : 𝕜) (h : 0 < a) : affineHomeomorph a b h.ne' '' Set.Ioc c d = Set.Ioc (a * c + b) (a * d + b) := by simp [h] theorem affineHomeomorph_image_Ioo {𝕜 : Type*} [Field 𝕜] [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜] [TopologicalSpace 𝕜] [IsTopologicalRing 𝕜] (a b c d : 𝕜) (h : 0 < a) : affineHomeomorph a b h.ne' '' Set.Ioo c d = Set.Ioo (a * c + b) (a * d + b) := by simp [h] end affineHomeomorph section LocalExtr variable {α β : Type*} [TopologicalSpace α] [Semifield β] [LinearOrder β] [IsStrictOrderedRing β] {a : α} open Topology theorem IsLocalMin.inv {f : α → β} {a : α} (h1 : IsLocalMin f a) (h2 : ∀ᶠ z in 𝓝 a, 0 < f z) : IsLocalMax f⁻¹ a := by filter_upwards [h1, h2] with z h3 h4 using(inv_le_inv₀ h4 h2.self_of_nhds).mpr h3 end LocalExtr section Preconnected /-! Some results about functions on preconnected sets valued in a ring or field with a topology. -/ open Set variable {α 𝕜 : Type*} {f g : α → 𝕜} {S : Set α} [TopologicalSpace α] [TopologicalSpace 𝕜] [T1Space 𝕜] /-- If `f` is a function `α → 𝕜` which is continuous on a preconnected set `S`, and `f ^ 2 = 1` on `S`, then either `f = 1` on `S`, or `f = -1` on `S`. -/ theorem IsPreconnected.eq_one_or_eq_neg_one_of_sq_eq [Ring 𝕜] [NoZeroDivisors 𝕜] (hS : IsPreconnected S) (hf : ContinuousOn f S) (hsq : EqOn (f ^ 2) 1 S) : EqOn f 1 S ∨ EqOn f (-1) S := by have : DiscreteTopology ({1, -1} : Set 𝕜) := Finite.instDiscreteTopology have hmaps : MapsTo f S {1, -1} := by simpa only [EqOn, Pi.one_apply, Pi.pow_apply, sq_eq_one_iff] using hsq simpa using hS.eqOn_const_of_mapsTo hf hmaps /-- If `f, g` are functions `α → 𝕜`, both continuous on a preconnected set `S`, with `f ^ 2 = g ^ 2` on `S`, and `g z ≠ 0` all `z ∈ S`, then either `f = g` or `f = -g` on `S`. -/ theorem IsPreconnected.eq_or_eq_neg_of_sq_eq [Field 𝕜] [ContinuousInv₀ 𝕜] [ContinuousMul 𝕜] (hS : IsPreconnected S) (hf : ContinuousOn f S) (hg : ContinuousOn g S) (hsq : EqOn (f ^ 2) (g ^ 2) S) (hg_ne : ∀ {x : α}, x ∈ S → g x ≠ 0) : EqOn f g S ∨ EqOn f (-g) S := by have hsq : EqOn ((f / g) ^ 2) 1 S := fun x hx => by simpa [div_eq_one_iff_eq (pow_ne_zero _ (hg_ne hx)), div_pow] using hsq hx simpa +contextual [EqOn, div_eq_iff (hg_ne _)] using hS.eq_one_or_eq_neg_one_of_sq_eq (hf.div hg fun z => hg_ne) hsq /-- If `f, g` are functions `α → 𝕜`, both continuous on a preconnected set `S`, with `f ^ 2 = g ^ 2` on `S`, and `g z ≠ 0` all `z ∈ S`, then as soon as `f = g` holds at one point of `S` it holds for all points. -/ theorem IsPreconnected.eq_of_sq_eq [Field 𝕜] [ContinuousInv₀ 𝕜] [ContinuousMul 𝕜] (hS : IsPreconnected S) (hf : ContinuousOn f S) (hg : ContinuousOn g S) (hsq : EqOn (f ^ 2) (g ^ 2) S) (hg_ne : ∀ {x : α}, x ∈ S → g x ≠ 0) {y : α} (hy : y ∈ S) (hy' : f y = g y) : EqOn f g S := fun x hx => by rcases hS.eq_or_eq_neg_of_sq_eq hf hg @hsq @hg_ne with (h | h) · exact h hx · rw [h _, Pi.neg_apply, neg_eq_iff_add_eq_zero, ← two_mul, mul_eq_zero, (iff_of_eq (iff_false _)).2 (hg_ne _)] at hy' ⊢ <;> assumption end Preconnected section ContinuousSMul variable {F : Type*} [DivisionRing F] [TopologicalSpace F] [IsTopologicalRing F] (X : Type*) [TopologicalSpace X] [MulAction F X] [ContinuousSMul F X] instance Subfield.continuousSMul (M : Subfield F) : ContinuousSMul M X := Subring.continuousSMul M.toSubring X end ContinuousSMul
.lake/packages/mathlib/Mathlib/Topology/Algebra/Equicontinuity.lean
import Mathlib.Topology.Algebra.UniformConvergence import Mathlib.Topology.UniformSpace.Equicontinuity /-! # Algebra-related equicontinuity criteria -/ open Function open UniformConvergence @[to_additive] theorem equicontinuous_of_equicontinuousAt_one {ι G M hom : Type*} [TopologicalSpace G] [UniformSpace M] [Group G] [Group M] [IsTopologicalGroup G] [IsUniformGroup M] [FunLike hom G M] [MonoidHomClass hom G M] (F : ι → hom) (hf : EquicontinuousAt ((↑) ∘ F) (1 : G)) : Equicontinuous ((↑) ∘ F) := by rw [equicontinuous_iff_continuous] rw [equicontinuousAt_iff_continuousAt] at hf let φ : G →* (ι →ᵤ M) := { toFun := swap ((↑) ∘ F) map_one' := by dsimp [UniformFun]; ext; exact map_one _ map_mul' := fun a b => by dsimp [UniformFun]; ext; exact map_mul _ _ _ } exact continuous_of_continuousAt_one φ hf @[to_additive] theorem uniformEquicontinuous_of_equicontinuousAt_one {ι G M hom : Type*} [UniformSpace G] [UniformSpace M] [Group G] [Group M] [IsUniformGroup G] [IsUniformGroup M] [FunLike hom G M] [MonoidHomClass hom G M] (F : ι → hom) (hf : EquicontinuousAt ((↑) ∘ F) (1 : G)) : UniformEquicontinuous ((↑) ∘ F) := by rw [uniformEquicontinuous_iff_uniformContinuous] rw [equicontinuousAt_iff_continuousAt] at hf let φ : G →* (ι →ᵤ M) := { toFun := swap ((↑) ∘ F) map_one' := by dsimp [UniformFun]; ext; exact map_one _ map_mul' := fun a b => by dsimp [UniformFun]; ext; exact map_mul _ _ _ } exact uniformContinuous_of_continuousAt_one φ hf
.lake/packages/mathlib/Mathlib/Topology/Algebra/Polynomial.lean
import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.Inductions import Mathlib.Algebra.Polynomial.Splits import Mathlib.RingTheory.Polynomial.Vieta import Mathlib.Analysis.Normed.Field.Basic import Mathlib.Analysis.Normed.Ring.Lemmas /-! # Polynomials and limits In this file we prove the following lemmas. * `Polynomial.continuous_eval₂`: `Polynomial.eval₂` defines a continuous function. * `Polynomial.continuous_aeval`: `Polynomial.aeval` defines a continuous function; we also prove convenience lemmas `Polynomial.continuousAt_aeval`, `Polynomial.continuousWithinAt_aeval`, `Polynomial.continuousOn_aeval`. * `Polynomial.continuous`: `Polynomial.eval` defines a continuous functions; we also prove convenience lemmas `Polynomial.continuousAt`, `Polynomial.continuousWithinAt`, `Polynomial.continuousOn`. * `Polynomial.tendsto_norm_atTop`: `fun x ↦ ‖Polynomial.eval (z x) p‖` tends to infinity provided that `fun x ↦ ‖z x‖` tends to infinity and `0 < degree p`; * `Polynomial.tendsto_abv_eval₂_atTop`, `Polynomial.tendsto_abv_atTop`, `Polynomial.tendsto_abv_aeval_atTop`: a few versions of the previous statement for `IsAbsoluteValue abv` instead of norm. ## Tags Polynomial, continuity -/ open IsAbsoluteValue Filter namespace Polynomial section IsTopologicalSemiring variable {R S : Type*} [Semiring R] [TopologicalSpace R] [IsTopologicalSemiring R] (p : R[X]) @[continuity, fun_prop] protected theorem continuous_eval₂ [Semiring S] (p : S[X]) (f : S →+* R) : Continuous fun x => p.eval₂ f x := by simp only [eval₂_eq_sum] exact continuous_finset_sum _ fun c _ => continuous_const.mul (continuous_pow _) @[continuity, fun_prop] protected theorem continuous : Continuous fun x => p.eval x := p.continuous_eval₂ _ @[fun_prop] protected theorem continuousAt {a : R} : ContinuousAt (fun x => p.eval x) a := p.continuous.continuousAt @[fun_prop] protected theorem continuousWithinAt {s a} : ContinuousWithinAt (fun x => p.eval x) s a := p.continuous.continuousWithinAt @[fun_prop] protected theorem continuousOn {s} : ContinuousOn (fun x => p.eval x) s := p.continuous.continuousOn end IsTopologicalSemiring section TopologicalAlgebra variable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [TopologicalSpace A] [IsTopologicalSemiring A] (p : R[X]) @[continuity, fun_prop] protected theorem continuous_aeval : Continuous fun x : A => aeval x p := p.continuous_eval₂ _ @[fun_prop] protected theorem continuousAt_aeval {a : A} : ContinuousAt (fun x : A => aeval x p) a := p.continuous_aeval.continuousAt @[fun_prop] protected theorem continuousWithinAt_aeval {s a} : ContinuousWithinAt (fun x : A => aeval x p) s a := p.continuous_aeval.continuousWithinAt @[fun_prop] protected theorem continuousOn_aeval {s} : ContinuousOn (fun x : A => aeval x p) s := p.continuous_aeval.continuousOn end TopologicalAlgebra theorem tendsto_abv_eval₂_atTop {R S k α : Type*} [Semiring R] [Ring S] [Field k] [LinearOrder k] [IsStrictOrderedRing k] (f : R →+* S) (abv : S → k) [IsAbsoluteValue abv] (p : R[X]) (hd : 0 < degree p) (hf : f p.leadingCoeff ≠ 0) {l : Filter α} {z : α → S} (hz : Tendsto (abv ∘ z) l atTop) : Tendsto (fun x => abv (p.eval₂ f (z x))) l atTop := by revert hf; refine degree_pos_induction_on p hd ?_ ?_ ?_ <;> clear hd p · rintro _ - hc rw [leadingCoeff_mul_X, leadingCoeff_C] at hc simpa [abv_mul abv] using hz.const_mul_atTop ((abv_pos abv).2 hc) · intro _ _ ihp hf rw [leadingCoeff_mul_X] at hf simpa [abv_mul abv] using (ihp hf).atTop_mul_atTop₀ hz · intro _ a hd ihp hf rw [add_comm, leadingCoeff_add_of_degree_lt (degree_C_le.trans_lt hd)] at hf refine .atTop_of_add_const (abv (-f a)) ?_ refine tendsto_atTop_mono (fun _ => abv_add abv _ _) ?_ simpa using ihp hf theorem tendsto_abv_atTop {R k α : Type*} [Ring R] [Field k] [LinearOrder k] [IsStrictOrderedRing k] (abv : R → k) [IsAbsoluteValue abv] (p : R[X]) (h : 0 < degree p) {l : Filter α} {z : α → R} (hz : Tendsto (abv ∘ z) l atTop) : Tendsto (fun x => abv (p.eval (z x))) l atTop := by apply tendsto_abv_eval₂_atTop _ _ _ h _ hz exact mt leadingCoeff_eq_zero.1 (ne_zero_of_degree_gt h) theorem tendsto_abv_aeval_atTop {R A k α : Type*} [CommSemiring R] [Ring A] [Algebra R A] [Field k] [LinearOrder k] [IsStrictOrderedRing k] (abv : A → k) [IsAbsoluteValue abv] (p : R[X]) (hd : 0 < degree p) (h₀ : algebraMap R A p.leadingCoeff ≠ 0) {l : Filter α} {z : α → A} (hz : Tendsto (abv ∘ z) l atTop) : Tendsto (fun x => abv (aeval (z x) p)) l atTop := tendsto_abv_eval₂_atTop _ abv p hd h₀ hz variable {α R : Type*} [NormedRing R] [IsAbsoluteValue (norm : R → ℝ)] theorem tendsto_norm_atTop (p : R[X]) (h : 0 < degree p) {l : Filter α} {z : α → R} (hz : Tendsto (fun x => ‖z x‖) l atTop) : Tendsto (fun x => ‖p.eval (z x)‖) l atTop := p.tendsto_abv_atTop norm h hz theorem exists_forall_norm_le [ProperSpace R] (p : R[X]) : ∃ x, ∀ y, ‖p.eval x‖ ≤ ‖p.eval y‖ := if hp0 : 0 < degree p then p.continuous.norm.exists_forall_le <| p.tendsto_norm_atTop hp0 tendsto_norm_cocompact_atTop else ⟨p.coeff 0, by rw [eq_C_of_degree_le_zero (le_of_not_gt hp0)]; simp⟩ section Roots open Polynomial NNReal variable {F K : Type*} [CommRing F] [NormedField K] open Multiset theorem eq_one_of_roots_le {p : F[X]} {f : F →+* K} {B : ℝ} (hB : B < 0) (h1 : p.Monic) (h2 : Splits f p) (h3 : ∀ z ∈ (map f p).roots, ‖z‖ ≤ B) : p = 1 := h1.natDegree_eq_zero.mp (by contrapose! hB rw [← h1.natDegree_map f, natDegree_eq_card_roots' h2] at hB obtain ⟨z, hz⟩ := card_pos_iff_exists_mem.mp (zero_lt_iff.mpr hB) exact le_trans (norm_nonneg _) (h3 z hz)) theorem coeff_le_of_roots_le {p : F[X]} {f : F →+* K} {B : ℝ} (i : ℕ) (h1 : p.Monic) (h2 : Splits f p) (h3 : ∀ z ∈ (map f p).roots, ‖z‖ ≤ B) : ‖(map f p).coeff i‖ ≤ B ^ (p.natDegree - i) * p.natDegree.choose i := by obtain hB | hB := lt_or_ge B 0 · rw [eq_one_of_roots_le hB h1 h2 h3, Polynomial.map_one, natDegree_one, zero_tsub, pow_zero, one_mul, coeff_one] split_ifs with h <;> simp [h] rw [← h1.natDegree_map f] obtain hi | hi := lt_or_ge (map f p).natDegree i · rw [coeff_eq_zero_of_natDegree_lt hi, norm_zero] positivity rw [coeff_eq_esymm_roots_of_splits ((splits_id_iff_splits f).2 h2) hi, (h1.map _).leadingCoeff, one_mul, norm_mul, norm_pow, norm_neg, norm_one, one_pow, one_mul] apply ((norm_multiset_sum_le _).trans <| sum_le_card_nsmul _ _ fun r hr => _).trans · rw [Multiset.map_map, card_map, card_powersetCard, ← natDegree_eq_card_roots' h2, Nat.choose_symm hi, mul_comm, nsmul_eq_mul] intro r hr simp_rw [Multiset.mem_map] at hr obtain ⟨_, ⟨s, hs, rfl⟩, rfl⟩ := hr rw [mem_powersetCard] at hs lift B to ℝ≥0 using hB rw [← coe_nnnorm, ← NNReal.coe_pow, NNReal.coe_le_coe, ← nnnormHom_apply, ← MonoidHom.coe_coe, MonoidHom.map_multiset_prod] refine (prod_le_pow_card _ B fun x hx => ?_).trans_eq (by rw [card_map, hs.2]) obtain ⟨z, hz, rfl⟩ := Multiset.mem_map.1 hx exact h3 z (mem_of_le hs.1 hz) /-- The coefficients of the monic polynomials of bounded degree with bounded roots are uniformly bounded. -/ theorem coeff_bdd_of_roots_le {B : ℝ} {d : ℕ} (f : F →+* K) {p : F[X]} (h1 : p.Monic) (h2 : Splits f p) (h3 : p.natDegree ≤ d) (h4 : ∀ z ∈ (map f p).roots, ‖z‖ ≤ B) (i : ℕ) : ‖(map f p).coeff i‖ ≤ max B 1 ^ d * d.choose (d / 2) := by obtain hB | hB := le_or_gt 0 B · apply (coeff_le_of_roots_le i h1 h2 h4).trans calc _ ≤ max B 1 ^ (p.natDegree - i) * p.natDegree.choose i := by gcongr; apply le_max_left _ ≤ max B 1 ^ d * p.natDegree.choose i := by gcongr · apply le_max_right · exact le_trans (Nat.sub_le _ _) h3 _ ≤ max B 1 ^ d * d.choose (d / 2) := by gcongr; exact (i.choose_mono h3).trans (i.choose_le_middle d) · rw [eq_one_of_roots_le hB h1 h2 h4, Polynomial.map_one, coeff_one] refine le_trans ?_ (one_le_mul_of_one_le_of_one_le (one_le_pow₀ (le_max_right B 1)) ?_) · split_ifs <;> norm_num · exact mod_cast Nat.succ_le_iff.mpr (Nat.choose_pos (d.div_le_self 2)) end Roots end Polynomial
.lake/packages/mathlib/Mathlib/Topology/Algebra/Semigroup.lean
import Mathlib.Topology.Separation.Hausdorff /-! # Idempotents in topological semigroups This file provides a sufficient condition for a semigroup `M` to contain an idempotent (i.e. an element `m` such that `m * m = m `), namely that `M` is a nonempty compact Hausdorff space where right-multiplication by constants is continuous. We also state a corresponding lemma guaranteeing that a subset of `M` contains an idempotent. -/ /-- Any nonempty compact Hausdorff semigroup where right-multiplication is continuous contains an idempotent, i.e. an `m` such that `m * m = m`. -/ @[to_additive /-- Any nonempty compact Hausdorff additive semigroup where right-addition is continuous contains an idempotent, i.e. an `m` such that `m + m = m` -/] theorem exists_idempotent_of_compact_t2_of_continuous_mul_left {M} [Nonempty M] [Semigroup M] [TopologicalSpace M] [CompactSpace M] [T2Space M] (continuous_mul_left : ∀ r : M, Continuous (· * r)) : ∃ m : M, m * m = m := by /- We apply Zorn's lemma to the poset of nonempty closed subsemigroups of `M`. It will turn out that any minimal element is `{m}` for an idempotent `m : M`. -/ let S : Set (Set M) := { N | IsClosed N ∧ N.Nonempty ∧ ∀ (m) (_ : m ∈ N) (m') (_ : m' ∈ N), m * m' ∈ N } rsuffices ⟨N, hN⟩ : ∃ N', Minimal (· ∈ S) N' · obtain ⟨N_closed, ⟨m, hm⟩, N_mul⟩ := hN.prop use m /- We now have an element `m : M` of a minimal subsemigroup `N`, and want to show `m + m = m`. We first show that every element of `N` is of the form `m' + m`. -/ have scaling_eq_self : (· * m) '' N = N := by apply hN.eq_of_subset · refine ⟨(continuous_mul_left m).isClosedMap _ N_closed, ⟨_, ⟨m, hm, rfl⟩⟩, ?_⟩ rintro _ ⟨m'', hm'', rfl⟩ _ ⟨m', hm', rfl⟩ exact ⟨m'' * m * m', N_mul _ (N_mul _ hm'' _ hm) _ hm', mul_assoc _ _ _⟩ · rintro _ ⟨m', hm', rfl⟩ exact N_mul _ hm' _ hm /- In particular, this means that `m' * m = m` for some `m'`. We now use minimality again to show that this holds for all `m' ∈ N`. -/ have absorbing_eq_self : N ∩ { m' | m' * m = m } = N := by apply hN.eq_of_subset · refine ⟨N_closed.inter ((T1Space.t1 m).preimage (continuous_mul_left m)), ?_, ?_⟩ · rwa [← scaling_eq_self] at hm · rintro m'' ⟨mem'', eq'' : _ = m⟩ m' ⟨mem', eq' : _ = m⟩ refine ⟨N_mul _ mem'' _ mem', ?_⟩ rw [Set.mem_setOf_eq, mul_assoc, eq', eq''] apply Set.inter_subset_left rw [← absorbing_eq_self] at hm exact hm.2 refine zorn_superset _ fun c hcs hc => ?_ refine ⟨⋂₀ c, ⟨isClosed_sInter fun t ht => (hcs ht).1, ?_, fun m hm m' hm' => ?_⟩, fun s hs => Set.sInter_subset_of_mem hs⟩ · obtain rfl | hcnemp := c.eq_empty_or_nonempty · rw [Set.sInter_empty] apply Set.univ_nonempty convert @IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed _ _ _ hcnemp.coe_sort ((↑) : c → Set M) ?_ ?_ ?_ ?_ · exact Set.sInter_eq_iInter · refine DirectedOn.directed_val (IsChain.directedOn hc.symm) exacts [fun i => (hcs i.prop).2.1, fun i => (hcs i.prop).1.isCompact, fun i => (hcs i.prop).1] · rw [Set.mem_sInter] exact fun t ht => (hcs ht).2.2 m (Set.mem_sInter.mp hm t ht) m' (Set.mem_sInter.mp hm' t ht) /-- A version of `exists_idempotent_of_compact_t2_of_continuous_mul_left` where the idempotent lies in some specified nonempty compact subsemigroup. -/ @[to_additive exists_idempotent_in_compact_add_subsemigroup /-- A version of `exists_idempotent_of_compact_t2_of_continuous_add_left` where the idempotent lies in some specified nonempty compact additive subsemigroup. -/] theorem exists_idempotent_in_compact_subsemigroup {M} [Semigroup M] [TopologicalSpace M] [T2Space M] (continuous_mul_left : ∀ r : M, Continuous (· * r)) (s : Set M) (snemp : s.Nonempty) (s_compact : IsCompact s) (s_add : ∀ᵉ (x ∈ s) (y ∈ s), x * y ∈ s) : ∃ m ∈ s, m * m = m := by let M' := { m // m ∈ s } letI : Semigroup M' := { mul := fun p q => ⟨p.1 * q.1, s_add _ p.2 _ q.2⟩ mul_assoc := fun p q r => Subtype.eq (mul_assoc _ _ _) } haveI : CompactSpace M' := isCompact_iff_compactSpace.mp s_compact haveI : Nonempty M' := nonempty_subtype.mpr snemp have : ∀ p : M', Continuous (· * p) := fun p => ((continuous_mul_left p.1).comp continuous_subtype_val).subtype_mk _ obtain ⟨⟨m, hm⟩, idem⟩ := exists_idempotent_of_compact_t2_of_continuous_mul_left this exact ⟨m, hm, Subtype.ext_iff.mp idem⟩
.lake/packages/mathlib/Mathlib/Topology/Algebra/UniformMulAction.lean
import Mathlib.Algebra.Module.Opposite import Mathlib.Topology.UniformSpace.Completion import Mathlib.Topology.Algebra.IsUniformGroup.Defs /-! # Multiplicative action on the completion of a uniform space In this file we define typeclasses `UniformContinuousConstVAdd` and `UniformContinuousConstSMul` and prove that a multiplicative action on `X` with uniformly continuous `(•) c` can be extended to a multiplicative action on `UniformSpace.Completion X`. In later files once the additive group structure is set up, we provide * `UniformSpace.Completion.DistribMulAction` * `UniformSpace.Completion.MulActionWithZero` * `UniformSpace.Completion.Module` TODO: Generalise the results here from the concrete `Completion` to any `AbstractCompletion`. -/ universe u v w x y open scoped Uniformity noncomputable section variable (R : Type u) (M : Type v) (N : Type w) (X : Type x) (Y : Type y) [UniformSpace X] [UniformSpace Y] /-- An additive action such that for all `c`, the map `fun x ↦ c +ᵥ x` is uniformly continuous. -/ class UniformContinuousConstVAdd [VAdd M X] : Prop where uniformContinuous_const_vadd : ∀ c : M, UniformContinuous (c +ᵥ · : X → X) /-- A multiplicative action such that for all `c`, the map `fun x ↦ c • x` is uniformly continuous. -/ @[to_additive] class UniformContinuousConstSMul [SMul M X] : Prop where uniformContinuous_const_smul : ∀ c : M, UniformContinuous (c • · : X → X) export UniformContinuousConstVAdd (uniformContinuous_const_vadd) export UniformContinuousConstSMul (uniformContinuous_const_smul) instance AddMonoid.uniformContinuousConstSMul_nat [AddGroup X] [IsUniformAddGroup X] : UniformContinuousConstSMul ℕ X := ⟨uniformContinuous_const_nsmul⟩ instance AddGroup.uniformContinuousConstSMul_int [AddGroup X] [IsUniformAddGroup X] : UniformContinuousConstSMul ℤ X := ⟨uniformContinuous_const_zsmul⟩ /-- A `DistribMulAction` that is continuous on a uniform group is uniformly continuous. This can't be an instance due to it forming a loop with `UniformContinuousConstSMul.to_continuousConstSMul` -/ theorem uniformContinuousConstSMul_of_continuousConstSMul [Monoid R] [AddGroup M] [DistribMulAction R M] [UniformSpace M] [IsUniformAddGroup M] [ContinuousConstSMul R M] : UniformContinuousConstSMul R M := ⟨fun r => uniformContinuous_of_continuousAt_zero (DistribMulAction.toAddMonoidHom M r) (Continuous.continuousAt (continuous_const_smul r))⟩ /-- The action of `Semiring.toModule` is uniformly continuous. -/ instance Ring.uniformContinuousConstSMul [Ring R] [UniformSpace R] [IsUniformAddGroup R] [ContinuousMul R] : UniformContinuousConstSMul R R := uniformContinuousConstSMul_of_continuousConstSMul _ _ /-- The action of `Semiring.toOppositeModule` is uniformly continuous. -/ instance Ring.uniformContinuousConstSMul_op [Ring R] [UniformSpace R] [IsUniformAddGroup R] [ContinuousMul R] : UniformContinuousConstSMul Rᵐᵒᵖ R := uniformContinuousConstSMul_of_continuousConstSMul _ _ section SMul variable [SMul M X] @[to_additive] instance (priority := 100) UniformContinuousConstSMul.to_continuousConstSMul [UniformContinuousConstSMul M X] : ContinuousConstSMul M X := ⟨fun c => (uniformContinuous_const_smul c).continuous⟩ variable {M X Y} @[to_additive] theorem UniformContinuous.const_smul [UniformContinuousConstSMul M X] {f : Y → X} (hf : UniformContinuous f) (c : M) : UniformContinuous (c • f) := (uniformContinuous_const_smul c).comp hf @[to_additive] lemma IsUniformInducing.uniformContinuousConstSMul [SMul M Y] [UniformContinuousConstSMul M Y] {f : X → Y} (hf : IsUniformInducing f) (hsmul : ∀ (c : M) x, f (c • x) = c • f x) : UniformContinuousConstSMul M X where uniformContinuous_const_smul c := by simpa only [hf.uniformContinuous_iff, Function.comp_def, hsmul] using hf.uniformContinuous.const_smul c /-- If a scalar action is central, then its right action is uniform continuous when its left action is. -/ @[to_additive /-- If an additive action is central, then its right action is uniform continuous when its left action is. -/] instance (priority := 100) UniformContinuousConstSMul.op [SMul Mᵐᵒᵖ X] [IsCentralScalar M X] [UniformContinuousConstSMul M X] : UniformContinuousConstSMul Mᵐᵒᵖ X := ⟨MulOpposite.rec' fun c ↦ by simpa only [op_smul_eq_smul] using uniformContinuous_const_smul c⟩ @[to_additive] instance MulOpposite.uniformContinuousConstSMul [UniformContinuousConstSMul M X] : UniformContinuousConstSMul M Xᵐᵒᵖ := ⟨fun c => MulOpposite.uniformContinuous_op.comp <| MulOpposite.uniformContinuous_unop.const_smul c⟩ end SMul @[to_additive] instance IsUniformGroup.to_uniformContinuousConstSMul {G : Type u} [Group G] [UniformSpace G] [IsUniformGroup G] : UniformContinuousConstSMul G G := ⟨fun _ => uniformContinuous_const.mul uniformContinuous_id⟩ section Ring variable {R β : Type*} [Ring R] [UniformSpace R] [UniformSpace β] theorem UniformContinuous.const_mul' [UniformContinuousConstSMul R R] {f : β → R} (hf : UniformContinuous f) (a : R) : UniformContinuous fun x ↦ a * f x := hf.const_smul a theorem UniformContinuous.mul_const' [UniformContinuousConstSMul Rᵐᵒᵖ R] {f : β → R} (hf : UniformContinuous f) (a : R) : UniformContinuous fun x ↦ f x * a := hf.const_smul (MulOpposite.op a) theorem uniformContinuous_mul_left' [UniformContinuousConstSMul R R] (a : R) : UniformContinuous fun b : R => a * b := uniformContinuous_id.const_mul' _ theorem uniformContinuous_mul_right' [UniformContinuousConstSMul Rᵐᵒᵖ R] (a : R) : UniformContinuous fun b : R => b * a := uniformContinuous_id.mul_const' _ theorem UniformContinuous.div_const' {R β : Type*} [DivisionRing R] [UniformSpace R] [UniformContinuousConstSMul Rᵐᵒᵖ R] [UniformSpace β] {f : β → R} (hf : UniformContinuous f) (a : R) : UniformContinuous fun x ↦ f x / a := by simpa [div_eq_mul_inv] using hf.mul_const' a⁻¹ theorem uniformContinuous_div_const' {R : Type*} [DivisionRing R] [UniformSpace R] [UniformContinuousConstSMul Rᵐᵒᵖ R] (a : R) : UniformContinuous fun b : R => b / a := uniformContinuous_id.div_const' _ end Ring section Unit open scoped Pointwise variable {M X} @[to_additive] theorem IsUnit.smul_uniformity [Monoid M] [MulAction M X] [UniformContinuousConstSMul M X] {c : M} (hc : IsUnit c) : c • 𝓤 X = 𝓤 X := let ⟨d, hcd⟩ := hc.exists_right_inv have cU : c • 𝓤 X ≤ 𝓤 X := uniformContinuous_const_smul c have dU : d • 𝓤 X ≤ 𝓤 X := uniformContinuous_const_smul d le_antisymm cU <| by simpa [smul_smul, hcd] using Filter.smul_filter_le_smul_filter (a := c) dU @[to_additive (attr := simp)] theorem smul_uniformity [Group M] [MulAction M X] [UniformContinuousConstSMul M X] (c : M) : c • 𝓤 X = 𝓤 X := Group.isUnit _ |>.smul_uniformity theorem smul_uniformity₀ [GroupWithZero M] [MulAction M X] [UniformContinuousConstSMul M X] {c : M} (hc : c ≠ 0) : c • 𝓤 X = 𝓤 X := hc.isUnit.smul_uniformity end Unit namespace UniformSpace namespace Completion section SMul variable [SMul M X] @[to_additive] noncomputable instance : SMul M (Completion X) := ⟨fun c => Completion.map (c • ·)⟩ @[to_additive] theorem smul_def (c : M) (x : Completion X) : c • x = Completion.map (c • ·) x := rfl @[to_additive] instance : UniformContinuousConstSMul M (Completion X) := ⟨fun _ => uniformContinuous_map⟩ @[to_additive] instance instIsScalarTower [SMul N X] [SMul M N] [UniformContinuousConstSMul M X] [UniformContinuousConstSMul N X] [IsScalarTower M N X] : IsScalarTower M N (Completion X) := ⟨fun m n x => by have : _ = (_ : Completion X → Completion X) := map_comp (uniformContinuous_const_smul m) (uniformContinuous_const_smul n) refine Eq.trans ?_ (congr_fun this.symm x) exact congr_arg (fun f => Completion.map f x) (funext (smul_assoc _ _))⟩ @[to_additive] instance [SMul N X] [SMulCommClass M N X] [UniformContinuousConstSMul M X] [UniformContinuousConstSMul N X] : SMulCommClass M N (Completion X) := ⟨fun m n x => by have hmn : m • n • x = (Completion.map (SMul.smul m) ∘ Completion.map (SMul.smul n)) x := rfl have hnm : n • m • x = (Completion.map (SMul.smul n) ∘ Completion.map (SMul.smul m)) x := rfl rw [hmn, hnm, map_comp, map_comp] · exact congr_arg (fun f => Completion.map f x) (funext (smul_comm _ _)) repeat' exact uniformContinuous_const_smul _⟩ @[to_additive] instance [SMul Mᵐᵒᵖ X] [IsCentralScalar M X] : IsCentralScalar M (Completion X) := ⟨fun c a => (congr_arg fun f => Completion.map f a) <| funext (op_smul_eq_smul c)⟩ variable {M X} variable [UniformContinuousConstSMul M X] @[to_additive (attr := simp, norm_cast)] theorem coe_smul (c : M) (x : X) : (↑(c • x) : Completion X) = c • (x : Completion X) := (map_coe (uniformContinuous_const_smul c) x).symm end SMul @[to_additive] noncomputable instance [Monoid M] [MulAction M X] [UniformContinuousConstSMul M X] : MulAction M (Completion X) where one_smul := ext' (continuous_const_smul _) continuous_id fun a => by rw [← coe_smul, one_smul] mul_smul x y := ext' (continuous_const_smul _) ((continuous_const_smul _).const_smul _) fun a => by simp only [← coe_smul, mul_smul] end Completion end UniformSpace
.lake/packages/mathlib/Mathlib/Topology/Algebra/Affine.lean
import Mathlib.LinearAlgebra.AffineSpace.AffineMap import Mathlib.LinearAlgebra.AffineSpace.Midpoint import Mathlib.Topology.Algebra.Group.AddTorsor /-! # Topological properties of affine spaces and maps This file contains a few facts regarding the continuity of affine maps. -/ namespace AffineMap variable {R V P W Q : Type*} [AddCommGroup V] [TopologicalSpace V] [AddTorsor V P] [TopologicalSpace P] [IsTopologicalAddTorsor P] [AddCommGroup W] [TopologicalSpace W] [AddTorsor W Q] [TopologicalSpace Q] [IsTopologicalAddTorsor Q] section Ring variable [Ring R] [Module R V] [Module R W] /-- If `f` is an affine map, then its linear part is continuous iff `f` is continuous. -/ theorem continuous_linear_iff {f : P →ᵃ[R] Q} : Continuous f.linear ↔ Continuous f := by inhabit P have : (f.linear : V → W) = (Homeomorph.vaddConst <| f default).symm ∘ f ∘ (Homeomorph.vaddConst default) := by ext v simp rw [this] simp only [Homeomorph.comp_continuous_iff, Homeomorph.comp_continuous_iff'] /-- An affine map is continuous iff its underlying linear map is continuous. See also `AffineMap.continuous_linear_iff`. -/ @[deprecated continuous_linear_iff (since := "2025-09-13")] theorem continuous_iff {f : P →ᵃ[R] Q} : Continuous f ↔ Continuous f.linear := continuous_linear_iff.symm /-- If `f` is an affine map, then its linear part is an open map iff `f` is an open map. -/ theorem isOpenMap_linear_iff {f : P →ᵃ[R] Q} : IsOpenMap f.linear ↔ IsOpenMap f := by inhabit P have : (f.linear : V → W) = (Homeomorph.vaddConst <| f default).symm ∘ f ∘ (Homeomorph.vaddConst default) := by ext v simp rw [this] simp only [Homeomorph.comp_isOpenMap_iff, Homeomorph.comp_isOpenMap_iff'] variable [TopologicalSpace R] [ContinuousSMul R V] /-- The line map is continuous in all arguments. -/ @[continuity, fun_prop] theorem lineMap_continuous_uncurry : Continuous (fun pqt : P × P × R ↦ lineMap pqt.1 pqt.2.1 pqt.2.2) := by simp only [coe_lineMap] fun_prop /-- The line map is continuous. -/ theorem lineMap_continuous {p q : P} : Continuous (lineMap p q : R →ᵃ[R] P) := by fun_prop open Topology Filter section Tendsto variable {α : Type*} {l : Filter α} theorem _root_.Filter.Tendsto.lineMap {f₁ f₂ : α → P} {g : α → R} {p₁ p₂ : P} {c : R} (h₁ : Tendsto f₁ l (𝓝 p₁)) (h₂ : Tendsto f₂ l (𝓝 p₂)) (hg : Tendsto g l (𝓝 c)) : Tendsto (fun x => AffineMap.lineMap (f₁ x) (f₂ x) (g x)) l (𝓝 <| AffineMap.lineMap p₁ p₂ c) := (hg.smul (h₂.vsub h₁)).vadd h₁ theorem _root_.Filter.Tendsto.midpoint [Invertible (2 : R)] {f₁ f₂ : α → P} {p₁ p₂ : P} (h₁ : Tendsto f₁ l (𝓝 p₁)) (h₂ : Tendsto f₂ l (𝓝 p₂)) : Tendsto (fun x => midpoint R (f₁ x) (f₂ x)) l (𝓝 <| midpoint R p₁ p₂) := h₁.lineMap h₂ tendsto_const_nhds end Tendsto variable {X : Type*} [TopologicalSpace X] {f₁ f₂ : X → P} {g : X → R} {s : Set X} {x : X} @[fun_prop] theorem _root_.ContinuousWithinAt.lineMap (h₁ : ContinuousWithinAt f₁ s x) (h₂ : ContinuousWithinAt f₂ s x) (hg : ContinuousWithinAt g s x) : ContinuousWithinAt (fun x ↦ lineMap (f₁ x) (f₂ x) (g x)) s x := Tendsto.lineMap h₁ h₂ hg theorem _root_.ContinuousAt.lineMap (h₁ : ContinuousAt f₁ x) (h₂ : ContinuousAt f₂ x) (hg : ContinuousAt g x) : ContinuousAt (fun x ↦ lineMap (f₁ x) (f₂ x) (g x)) x := by fun_prop theorem _root_.ContinuousOn.lineMap (h₁ : ContinuousOn f₁ s) (h₂ : ContinuousOn f₂ s) (hg : ContinuousOn g s) : ContinuousOn (fun x ↦ lineMap (f₁ x) (f₂ x) (g x)) s := by fun_prop theorem _root_.Continuous.lineMap (h₁ : Continuous f₁) (h₂ : Continuous f₂) (hg : Continuous g) : Continuous (fun x ↦ lineMap (f₁ x) (f₂ x) (g x)) := by fun_prop end Ring section CommRing variable [CommRing R] [Module R V] [ContinuousConstSMul R V] @[continuity, fun_prop] theorem homothety_continuous (x : P) (t : R) : Continuous <| homothety x t := by rw [coe_homothety] fun_prop variable (R) [TopologicalSpace R] [Module R W] [ContinuousSMul R W] (x : Q) {s : Set Q} open Topology theorem _root_.eventually_homothety_mem_of_mem_interior {y : Q} (hy : y ∈ interior s) : ∀ᶠ δ in 𝓝 (1 : R), homothety x δ y ∈ s := by have cont : Continuous (fun δ : R => homothety x δ y) := lineMap_continuous filter_upwards [cont.tendsto' 1 y (by simp) |>.eventually (isOpen_interior.eventually_mem hy)] with _ h using interior_subset h theorem _root_.eventually_homothety_image_subset_of_finite_subset_interior {t : Set Q} (ht : t.Finite) (h : t ⊆ interior s) : ∀ᶠ δ in 𝓝 (1 : R), homothety x δ '' t ⊆ s := by suffices ∀ y ∈ t, ∀ᶠ δ in 𝓝 (1 : R), homothety x δ y ∈ s by simp_rw [Set.image_subset_iff] exact (Filter.eventually_all_finite ht).mpr this intro y hy exact eventually_homothety_mem_of_mem_interior R x (h hy) end CommRing section Field variable [Field R] [Module R V] [ContinuousConstSMul R V] theorem homothety_isOpenMap (x : P) (t : R) (ht : t ≠ 0) : IsOpenMap <| homothety x t := by apply IsOpenMap.of_inverse (homothety_continuous x t⁻¹) <;> intro e <;> simp [← AffineMap.comp_apply, ← homothety_mul, ht] end Field end AffineMap
.lake/packages/mathlib/Mathlib/Topology/Algebra/Algebra.lean
import Mathlib.Algebra.Algebra.Subalgebra.Lattice import Mathlib.Algebra.Algebra.Tower import Mathlib.Topology.Algebra.Module.LinearMap /-! # Topological (sub)algebras A topological algebra over a topological semiring `R` is a topological semiring with a compatible continuous scalar multiplication by elements of `R`. We reuse typeclass `ContinuousSMul` for topological algebras. ## Results The topological closure of a subalgebra is still a subalgebra, which as an algebra is a topological algebra. In this file we define continuous algebra homomorphisms, as algebra homomorphisms between topological (semi-)rings which are continuous. The set of continuous algebra homomorphisms between the topological `R`-algebras `A` and `B` is denoted by `A →A[R] B`. TODO: add continuous algebra isomorphisms. -/ assert_not_exists Module.Basis open Algebra Set TopologicalSpace Topology universe u v w section TopologicalAlgebra variable (R : Type*) (A : Type u) variable [CommSemiring R] [Semiring A] [Algebra R A] variable [TopologicalSpace R] [TopologicalSpace A] @[continuity, fun_prop] theorem continuous_algebraMap [ContinuousSMul R A] : Continuous (algebraMap R A) := by rw [algebraMap_eq_smul_one'] exact continuous_id.smul continuous_const theorem continuous_algebraMap_iff_smul [ContinuousMul A] : Continuous (algebraMap R A) ↔ Continuous fun p : R × A => p.1 • p.2 := by refine ⟨fun h => ?_, fun h => have : ContinuousSMul R A := ⟨h⟩; continuous_algebraMap _ _⟩ simp only [Algebra.smul_def] exact (h.comp continuous_fst).mul continuous_snd theorem continuousSMul_of_algebraMap [ContinuousMul A] (h : Continuous (algebraMap R A)) : ContinuousSMul R A := ⟨(continuous_algebraMap_iff_smul R A).1 h⟩ instance Subalgebra.continuousSMul (S : Subalgebra R A) (X) [TopologicalSpace X] [MulAction A X] [ContinuousSMul A X] : ContinuousSMul S X := Subsemiring.continuousSMul S.toSubsemiring X section variable [ContinuousSMul R A] /-- The inclusion of the base ring in a topological algebra as a continuous linear map. -/ @[simps] def algebraMapCLM : R →L[R] A := { Algebra.linearMap R A with toFun := algebraMap R A cont := continuous_algebraMap R A } theorem algebraMapCLM_coe : ⇑(algebraMapCLM R A) = algebraMap R A := rfl theorem algebraMapCLM_toLinearMap : (algebraMapCLM R A).toLinearMap = Algebra.linearMap R A := rfl end /-- If `R` is a discrete topological ring, then any topological ring `S` which is an `R`-algebra is also a topological `R`-algebra. NB: This could be an instance but the signature makes it very expensive in search. See https://github.com/leanprover-community/mathlib4/pull/15339 for the regressions caused by making this an instance. -/ theorem DiscreteTopology.instContinuousSMul [IsTopologicalSemiring A] [DiscreteTopology R] : ContinuousSMul R A := continuousSMul_of_algebraMap _ _ continuous_of_discreteTopology end TopologicalAlgebra section TopologicalAlgebra section variable (R : Type*) [CommSemiring R] (A : Type*) [Semiring A] /-- Continuous algebra homomorphisms between algebras. We only put the type classes that are necessary for the definition, although in applications `M` and `B` will be topological algebras over the topological ring `R`. -/ structure ContinuousAlgHom (R : Type*) [CommSemiring R] (A : Type*) [Semiring A] [TopologicalSpace A] (B : Type*) [Semiring B] [TopologicalSpace B] [Algebra R A] [Algebra R B] extends A →ₐ[R] B where cont : Continuous toFun := by fun_prop @[inherit_doc] notation:25 A " →A[" R "] " B => ContinuousAlgHom R A B namespace ContinuousAlgHom open Subalgebra section Semiring variable {R} {A} variable [TopologicalSpace A] variable {B : Type*} [Semiring B] [TopologicalSpace B] [Algebra R A] [Algebra R B] instance : FunLike (A →A[R] B) A B where coe f := f.toAlgHom coe_injective' f g h := by cases f; cases g simp only [mk.injEq] exact AlgHom.ext (congrFun h) instance : AlgHomClass (A →A[R] B) R A B where map_mul f x y := map_mul f.toAlgHom x y map_one f := map_one f.toAlgHom map_add f := map_add f.toAlgHom map_zero f := map_zero f.toAlgHom commutes f r := f.toAlgHom.commutes r @[simp] theorem toAlgHom_eq_coe (f : A →A[R] B) : f.toAlgHom = f := rfl @[simp, norm_cast] theorem coe_inj {f g : A →A[R] B} : (f : A →ₐ[R] B) = g ↔ f = g := by cases f; cases g; simp only [mk.injEq]; exact Eq.congr_right rfl @[simp] theorem coe_mk (f : A →ₐ[R] B) (h) : (mk f h : A →ₐ[R] B) = f := rfl @[simp] theorem coe_mk' (f : A →ₐ[R] B) (h) : (mk f h : A → B) = f := rfl @[simp, norm_cast] theorem coe_coe (f : A →A[R] B) : ⇑(f : A →ₐ[R] B) = f := rfl instance : ContinuousMapClass (A →A[R] B) A B where map_continuous f := f.2 @[fun_prop] protected theorem continuous (f : A →A[R] B) : Continuous f := f.2 protected theorem uniformContinuous {E₁ E₂ : Type*} [UniformSpace E₁] [UniformSpace E₂] [Ring E₁] [Ring E₂] [Algebra R E₁] [Algebra R E₂] [IsUniformAddGroup E₁] [IsUniformAddGroup E₂] (f : E₁ →A[R] E₂) : UniformContinuous f := uniformContinuous_addMonoidHom_of_continuous f.continuous /-- See Note [custom simps projection]. We need to specify this projection explicitly in this case, because it is a composition of multiple projections. -/ def Simps.apply (h : A →A[R] B) : A → B := h /-- See Note [custom simps projection]. -/ def Simps.coe (h : A →A[R] B) : A →ₐ[R] B := h initialize_simps_projections ContinuousAlgHom (toFun → apply, toAlgHom → coe) @[ext] theorem ext {f g : A →A[R] B} (h : ∀ x, f x = g x) : f = g := DFunLike.ext f g h /-- Copy of a `ContinuousAlgHom` with a new `toFun` equal to the old one. Useful to fix definitional equalities. -/ def copy (f : A →A[R] B) (f' : A → B) (h : f' = ⇑f) : A →A[R] B where toAlgHom := { toRingHom := (f : A →A[R] B).toRingHom.copy f' h commutes' := fun r => by simp only [AlgHom.toRingHom_eq_coe, h, RingHom.toMonoidHom_eq_coe, OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe, MonoidHom.coe_coe, RingHom.coe_copy, AlgHomClass.commutes f r] } cont := show Continuous f' from h.symm ▸ f.continuous @[simp] theorem coe_copy (f : A →A[R] B) (f' : A → B) (h : f' = ⇑f) : ⇑(f.copy f' h) = f' := rfl theorem copy_eq (f : A →A[R] B) (f' : A → B) (h : f' = ⇑f) : f.copy f' h = f := DFunLike.ext' h protected theorem map_zero (f : A →A[R] B) : f (0 : A) = 0 := map_zero f protected theorem map_add (f : A →A[R] B) (x y : A) : f (x + y) = f x + f y := map_add f x y protected theorem map_smul (f : A →A[R] B) (c : R) (x : A) : f (c • x) = c • f x := map_smul .. theorem map_smul_of_tower {R S : Type*} [CommSemiring S] [SMul R A] [Algebra S A] [SMul R B] [Algebra S B] [MulActionHomClass (A →A[S] B) R A B] (f : A →A[S] B) (c : R) (x : A) : f (c • x) = c • f x := map_smul f c x protected theorem map_sum {ι : Type*} (f : A →A[R] B) (s : Finset ι) (g : ι → A) : f (∑ i ∈ s, g i) = ∑ i ∈ s, f (g i) := map_sum .. /-- Any two continuous `R`-algebra morphisms from `R` are equal -/ @[ext (iff := false)] theorem ext_ring [TopologicalSpace R] {f g : R →A[R] A} : f = g := coe_inj.mp (ext_id _ _ _) theorem ext_ring_iff [TopologicalSpace R] {f g : R →A[R] A} : f = g ↔ f 1 = g 1 := ⟨fun h => h ▸ rfl, fun _ => ext_ring ⟩ /-- If two continuous algebra maps are equal on a set `s`, then they are equal on the closure of the `Algebra.adjoin` of this set. -/ theorem eqOn_closure_adjoin [T2Space B] {s : Set A} {f g : A →A[R] B} (h : Set.EqOn f g s) : Set.EqOn f g (closure (Algebra.adjoin R s : Set A)) := Set.EqOn.closure (AlgHom.eqOn_adjoin_iff.mpr h) f.continuous g.continuous /-- If the subalgebra generated by a set `s` is dense in the ambient module, then two continuous algebra maps equal on `s` are equal. -/ theorem ext_on [T2Space B] {s : Set A} (hs : Dense (Algebra.adjoin R s : Set A)) {f g : A →A[R] B} (h : Set.EqOn f g s) : f = g := ext fun x => eqOn_closure_adjoin h (hs x) variable [IsTopologicalSemiring A] /-- The topological closure of a subalgebra -/ def _root_.Subalgebra.topologicalClosure (s : Subalgebra R A) : Subalgebra R A where toSubsemiring := s.toSubsemiring.topologicalClosure algebraMap_mem' r := by simp only [Subsemiring.coe_carrier_toSubmonoid, Subsemiring.topologicalClosure_coe, Subalgebra.coe_toSubsemiring] apply subset_closure exact algebraMap_mem s r /-- Under a continuous algebra map, the image of the `TopologicalClosure` of a subalgebra is contained in the `TopologicalClosure` of its image. -/ theorem _root_.Subalgebra.map_topologicalClosure_le [IsTopologicalSemiring B] (f : A →A[R] B) (s : Subalgebra R A) : map f s.topologicalClosure ≤ (map f.toAlgHom s).topologicalClosure := image_closure_subset_closure_image f.continuous lemma _root_.Subalgebra.topologicalClosure_map_le [IsTopologicalSemiring B] (f : A →ₐ[R] B) (hf : IsClosedMap f) (s : Subalgebra R A) : (map f s).topologicalClosure ≤ map f s.topologicalClosure := hf.closure_image_subset _ lemma _root_.Subalgebra.topologicalClosure_map [IsTopologicalSemiring B] (f : A →A[R] B) (hf : IsClosedMap f) (s : Subalgebra R A) : (map f.toAlgHom s).topologicalClosure = map f.toAlgHom s.topologicalClosure := SetLike.coe_injective <| hf.closure_image_eq_of_continuous f.continuous _ @[simp] theorem _root_.Subalgebra.topologicalClosure_coe (s : Subalgebra R A) : (s.topologicalClosure : Set A) = closure ↑s := rfl /-- Under a dense continuous algebra map, a subalgebra whose `TopologicalClosure` is `⊤` is sent to another such submodule. That is, the image of a dense subalgebra under a map with dense range is dense. -/ theorem _root_.DenseRange.topologicalClosure_map_subalgebra [IsTopologicalSemiring B] {f : A →A[R] B} (hf' : DenseRange f) {s : Subalgebra R A} (hs : s.topologicalClosure = ⊤) : (s.map (f : A →ₐ[R] B)).topologicalClosure = ⊤ := by rw [SetLike.ext'_iff] at hs ⊢ simp only [Subalgebra.topologicalClosure_coe, coe_top, ← dense_iff_closure_eq, Subalgebra.coe_map, AlgHom.coe_coe] at hs ⊢ exact hf'.dense_image f.continuous hs end Semiring section id variable [TopologicalSpace A] variable [Algebra R A] /-- The identity map as a continuous algebra homomorphism. -/ protected def id : A →A[R] A := ⟨AlgHom.id R A, continuous_id⟩ instance : One (A →A[R] A) := ⟨ContinuousAlgHom.id R A⟩ theorem one_def : (1 : A →A[R] A) = ContinuousAlgHom.id R A := rfl theorem id_apply (x : A) : ContinuousAlgHom.id R A x = x := rfl @[simp, norm_cast] theorem coe_id : ((ContinuousAlgHom.id R A) : A →ₐ[R] A) = AlgHom.id R A:= rfl @[simp, norm_cast] theorem coe_id' : ⇑(ContinuousAlgHom.id R A ) = _root_.id := rfl @[simp, norm_cast] theorem coe_eq_id {f : A →A[R] A} : (f : A →ₐ[R] A) = AlgHom.id R A ↔ f = ContinuousAlgHom.id R A:= by rw [← coe_id, coe_inj] @[simp] theorem one_apply (x : A) : (1 : A →A[R] A) x = x := rfl end id section comp variable {R} {A} variable [TopologicalSpace A] variable {B : Type*} [Semiring B] [TopologicalSpace B] [Algebra R A] [Algebra R B] {C : Type*} [Semiring C] [Algebra R C] [TopologicalSpace C] /-- Composition of continuous algebra homomorphisms. -/ def comp (g : B →A[R] C) (f : A →A[R] B) : A →A[R] C := ⟨(g : B →ₐ[R] C).comp (f : A →ₐ[R] B), g.2.comp f.2⟩ @[simp, norm_cast] theorem coe_comp (h : B →A[R] C) (f : A →A[R] B) : (h.comp f : A →ₐ[R] C) = (h : B →ₐ[R] C).comp (f : A →ₐ[R] B) := rfl @[simp, norm_cast] theorem coe_comp' (h : B →A[R] C) (f : A →A[R] B) : ⇑(h.comp f) = h ∘ f := rfl theorem comp_apply (g : B →A[R] C) (f : A →A[R] B) (x : A) : (g.comp f) x = g (f x) := rfl @[simp] theorem comp_id (f : A →A[R] B) : f.comp (ContinuousAlgHom.id R A) = f := ext fun _x => rfl @[simp] theorem id_comp (f : A →A[R] B) : (ContinuousAlgHom.id R B).comp f = f := ext fun _x => rfl theorem comp_assoc {D : Type*} [Semiring D] [Algebra R D] [TopologicalSpace D] (h : C →A[R] D) (g : B →A[R] C) (f : A →A[R] B) : (h.comp g).comp f = h.comp (g.comp f) := rfl instance : Mul (A →A[R] A) := ⟨comp⟩ theorem mul_def (f g : A →A[R] A) : f * g = f.comp g := rfl @[simp] theorem coe_mul (f g : A →A[R] A) : ⇑(f * g) = f ∘ g := rfl theorem mul_apply (f g : A →A[R] A) (x : A) : (f * g) x = f (g x) := rfl instance : Monoid (A →A[R] A) where mul_one _ := ext fun _ => rfl one_mul _ := ext fun _ => rfl mul_assoc _ _ _ := ext fun _ => rfl theorem coe_pow (f : A →A[R] A) (n : ℕ) : ⇑(f ^ n) = f^[n] := hom_coe_pow _ rfl (fun _ _ ↦ rfl) _ _ /-- coercion from `ContinuousAlgHom` to `AlgHom` as a `RingHom`. -/ @[simps] def toAlgHomMonoidHom : (A →A[R] A) →* A →ₐ[R] A where toFun := (↑) map_one' := rfl map_mul' _ _ := rfl end comp section prod variable {R} {A} variable [TopologicalSpace A] variable {B : Type*} [Semiring B] [TopologicalSpace B] [Algebra R A] [Algebra R B] {C : Type*} [Semiring C] [Algebra R C] [TopologicalSpace C] /-- The Cartesian product of two continuous algebra morphisms as a continuous algebra morphism. -/ protected def prod (f₁ : A →A[R] B) (f₂ : A →A[R] C) : A →A[R] B × C := ⟨(f₁ : A →ₐ[R] B).prod f₂, f₁.2.prodMk f₂.2⟩ @[simp, norm_cast] theorem coe_prod (f₁ : A →A[R] B) (f₂ : A →A[R] C) : (f₁.prod f₂ : A →ₐ[R] B × C) = AlgHom.prod f₁ f₂ := rfl @[simp, norm_cast] theorem prod_apply (f₁ : A →A[R] B) (f₂ : A →A[R] C) (x : A) : f₁.prod f₂ x = (f₁ x, f₂ x) := rfl variable {F : Type*} instance {D : Type*} [UniformSpace D] [CompleteSpace D] [Semiring D] [Algebra R D] [T2Space B] [FunLike F D B] [AlgHomClass F R D B] [ContinuousMapClass F D B] (f g : F) : CompleteSpace (AlgHom.equalizer f g) := isClosed_eq (map_continuous f) (map_continuous g) |>.completeSpace_coe variable (R A B) /-- `Prod.fst` as a `ContinuousAlgHom`. -/ def fst : A × B →A[R] A where cont := continuous_fst toAlgHom := AlgHom.fst R A B /-- `Prod.snd` as a `ContinuousAlgHom`. -/ def snd : A × B →A[R] B where cont := continuous_snd toAlgHom := AlgHom.snd R A B variable {R A B} @[simp, norm_cast] theorem coe_fst : ↑(fst R A B) = AlgHom.fst R A B := rfl @[simp, norm_cast] theorem coe_fst' : ⇑(fst R A B) = Prod.fst := rfl @[simp, norm_cast] theorem coe_snd : ↑(snd R A B) = AlgHom.snd R A B := rfl @[simp, norm_cast] theorem coe_snd' : ⇑(snd R A B) = Prod.snd := rfl @[simp] theorem fst_prod_snd : (fst R A B).prod (snd R A B) = ContinuousAlgHom.id R (A × B) := ext fun ⟨_x, _y⟩ => rfl @[simp] theorem fst_comp_prod (f : A →A[R] B) (g : A →A[R] C) : (fst R B C).comp (f.prod g) = f := ext fun _x => rfl @[simp] theorem snd_comp_prod (f : A →A[R] B) (g : A →A[R] C) : (snd R B C).comp (f.prod g) = g := ext fun _x => rfl /-- `Prod.map` of two continuous algebra homomorphisms. -/ def prodMap {D : Type*} [Semiring D] [TopologicalSpace D] [Algebra R D] (f₁ : A →A[R] B) (f₂ : C →A[R] D) : A × C →A[R] B × D := (f₁.comp (fst R A C)).prod (f₂.comp (snd R A C)) @[simp, norm_cast] theorem coe_prodMap {D : Type*} [Semiring D] [TopologicalSpace D] [Algebra R D] (f₁ : A →A[R] B) (f₂ : C →A[R] D) : (f₁.prodMap f₂ : A × C →ₐ[R] B × D) = (f₁ : A →ₐ[R] B).prodMap (f₂ : C →ₐ[R] D) := rfl @[simp, norm_cast] theorem coe_prodMap' {D : Type*} [Semiring D] [TopologicalSpace D] [Algebra R D] (f₁ : A →A[R] B) (f₂ : C →A[R] D) : ⇑(f₁.prodMap f₂) = Prod.map f₁ f₂ := rfl /-- `ContinuousAlgHom.prod` as an `Equiv`. -/ @[simps apply] def prodEquiv : (A →A[R] B) × (A →A[R] C) ≃ (A →A[R] B × C) where toFun f := f.1.prod f.2 invFun f := ⟨(fst _ _ _).comp f, (snd _ _ _).comp f⟩ end prod section subalgebra variable {R A} variable [TopologicalSpace A] variable {B : Type*} [Semiring B] [TopologicalSpace B] [Algebra R A] [Algebra R B] /-- Restrict codomain of a continuous algebra morphism. -/ def codRestrict (f : A →A[R] B) (p : Subalgebra R B) (h : ∀ x, f x ∈ p) : A →A[R] p where cont := f.continuous.subtype_mk _ toAlgHom := (f : A →ₐ[R] B).codRestrict p h @[norm_cast] theorem coe_codRestrict (f : A →A[R] B) (p : Subalgebra R B) (h : ∀ x, f x ∈ p) : (f.codRestrict p h : A →ₐ[R] p) = (f : A →ₐ[R] B).codRestrict p h := rfl @[simp] theorem coe_codRestrict_apply (f : A →A[R] B) (p : Subalgebra R B) (h : ∀ x, f x ∈ p) (x) : (f.codRestrict p h x : B) = f x := rfl /-- Restrict the codomain of a continuous algebra homomorphism `f` to `f.range`. -/ @[reducible] def rangeRestrict (f : A →A[R] B) := f.codRestrict (@AlgHom.range R A B _ _ _ _ _ f) (@AlgHom.mem_range_self R A B _ _ _ _ _ f) @[simp] theorem coe_rangeRestrict (f : A →A[R] B) : (f.rangeRestrict : A →ₐ[R] (@AlgHom.range R A B _ _ _ _ _ f)) = (f : A →ₐ[R] B).rangeRestrict := rfl /-- `Subalgebra.val` as a `ContinuousAlgHom`. -/ def _root_.Subalgebra.valA (p : Subalgebra R A) : p →A[R] A where cont := continuous_subtype_val toAlgHom := p.val @[simp, norm_cast] theorem _root_.Subalgebra.coe_valA (p : Subalgebra R A) : p.valA = p.subtype := rfl @[simp] theorem _root_.Subalgebra.coe_valA' (p : Subalgebra R A) : ⇑p.valA = p.subtype := rfl @[simp] theorem _root_.Subalgebra.valA_apply (p : Subalgebra R A) (x : p) : p.valA x = x := rfl @[simp] theorem _root_.Submodule.range_valA (p : Subalgebra R A) : @AlgHom.range R p A _ _ _ _ _ p.valA = p := Subalgebra.range_val p end subalgebra section Ring variable {S : Type*} [Ring S] [TopologicalSpace S] [Algebra R S] {B : Type*} [Ring B] [TopologicalSpace B] [Algebra R B] protected theorem map_neg (f : S →A[R] B) (x : S) : f (-x) = -f x := map_neg f x protected theorem map_sub (f : S →A[R] B) (x y : S) : f (x - y) = f x - f y := map_sub f x y end Ring section RestrictScalars variable {S : Type*} [CommSemiring S] [Algebra R S] {B : Type*} [Ring B] [TopologicalSpace B] [Algebra R B] [Algebra S B] [IsScalarTower R S B] {C : Type*} [Ring C] [TopologicalSpace C] [Algebra R C] [Algebra S C] [IsScalarTower R S C] /-- If `A` is an `R`-algebra, then a continuous `A`-algebra morphism can be interpreted as a continuous `R`-algebra morphism. -/ def restrictScalars (f : B →A[S] C) : B →A[R] C := ⟨(f : B →ₐ[S] C).restrictScalars R, f.continuous⟩ variable {R} @[simp] theorem coe_restrictScalars (f : B →A[S] C) : (f.restrictScalars R : B →ₐ[R] C) = (f : B →ₐ[S] C).restrictScalars R := rfl @[simp] theorem coe_restrictScalars' (f : B →A[S] C) : ⇑(f.restrictScalars R) = f := rfl end RestrictScalars end ContinuousAlgHom end variable {R : Type*} [CommSemiring R] variable {A : Type u} [TopologicalSpace A] variable [Semiring A] [Algebra R A] variable [IsTopologicalSemiring A] instance (s : Subalgebra R A) : IsTopologicalSemiring s := s.toSubsemiring.topologicalSemiring theorem Subalgebra.le_topologicalClosure (s : Subalgebra R A) : s ≤ s.topologicalClosure := subset_closure theorem Subalgebra.isClosed_topologicalClosure (s : Subalgebra R A) : IsClosed (s.topologicalClosure : Set A) := by convert @isClosed_closure A _ s theorem Subalgebra.topologicalClosure_minimal {s t : Subalgebra R A} (h : s ≤ t) (ht : IsClosed (t : Set A)) : s.topologicalClosure ≤ t := closure_minimal h ht variable (R) in open Algebra in lemma Subalgebra.topologicalClosure_adjoin_le_centralizer_centralizer [T2Space A] (s : Set A) : (adjoin R s).topologicalClosure ≤ centralizer R (centralizer R s) := topologicalClosure_minimal (adjoin_le_centralizer_centralizer R s) (Set.isClosed_centralizer _) /-- If a subalgebra of a topological algebra is commutative, then so is its topological closure. See note [reducible non-instances]. -/ abbrev Subalgebra.commSemiringTopologicalClosure [T2Space A] (s : Subalgebra R A) (hs : ∀ x y : s, x * y = y * x) : CommSemiring s.topologicalClosure := { s.topologicalClosure.toSemiring, s.toSubmonoid.commMonoidTopologicalClosure hs with } /-- This is really a statement about topological algebra isomorphisms, but we don't have those, so we use the clunky approach of talking about an algebra homomorphism, and a separate homeomorphism, along with a witness that as functions they are the same. -/ theorem Subalgebra.topologicalClosure_comap_homeomorph (s : Subalgebra R A) {B : Type*} [TopologicalSpace B] [Ring B] [IsTopologicalRing B] [Algebra R B] (f : B →ₐ[R] A) (f' : B ≃ₜ A) (w : (f : B → A) = f') : s.topologicalClosure.comap f = (s.comap f).topologicalClosure := by apply SetLike.ext' simp only [Subalgebra.topologicalClosure_coe] simp only [Subalgebra.coe_comap] rw [w] exact f'.preimage_closure _ variable (R) open Subalgebra /-- The topological closure of the subalgebra generated by a single element. -/ def Algebra.elemental (x : A) : Subalgebra R A := (Algebra.adjoin R ({x} : Set A)).topologicalClosure namespace Algebra.elemental @[simp, aesop safe (rule_sets := [SetLike])] theorem self_mem (x : A) : x ∈ elemental R x := le_topologicalClosure _ <| self_mem_adjoin_singleton R x variable {R} in theorem le_of_mem {x : A} {s : Subalgebra R A} (hs : IsClosed (s : Set A)) (hx : x ∈ s) : elemental R x ≤ s := topologicalClosure_minimal (adjoin_le <| by simpa using hx) hs variable {R} in theorem le_iff_mem {x : A} {s : Subalgebra R A} (hs : IsClosed (s : Set A)) : elemental R x ≤ s ↔ x ∈ s := ⟨fun h ↦ h (self_mem R x), fun h ↦ le_of_mem hs h⟩ instance isClosed (x : A) : IsClosed (elemental R x : Set A) := isClosed_topologicalClosure _ instance [T2Space A] {x : A} : CommSemiring (elemental R x) := commSemiringTopologicalClosure _ letI : CommSemiring (adjoin R {x}) := adjoinCommSemiringOfComm R fun y hy z hz => by rw [mem_singleton_iff] at hy hz rw [hy, hz] fun _ _ => mul_comm _ _ instance {A : Type*} [UniformSpace A] [CompleteSpace A] [Semiring A] [IsTopologicalSemiring A] [Algebra R A] (x : A) : CompleteSpace (elemental R x) := isClosed_closure.completeSpace_coe /-- The coercion from an elemental algebra to the full algebra is a `IsClosedEmbedding`. -/ theorem isClosedEmbedding_coe (x : A) : IsClosedEmbedding ((↑) : elemental R x → A) where eq_induced := rfl injective := Subtype.coe_injective isClosed_range := by simpa using isClosed R x lemma le_centralizer_centralizer [T2Space A] (x : A) : elemental R x ≤ centralizer R (centralizer R {x}) := topologicalClosure_adjoin_le_centralizer_centralizer .. end Algebra.elemental end TopologicalAlgebra section Ring variable {R : Type*} [CommRing R] variable {A : Type u} [TopologicalSpace A] variable [Ring A] variable [Algebra R A] [IsTopologicalRing A] /-- If a subalgebra of a topological algebra is commutative, then so is its topological closure. See note [reducible non-instances]. -/ abbrev Subalgebra.commRingTopologicalClosure [T2Space A] (s : Subalgebra R A) (hs : ∀ x y : s, x * y = y * x) : CommRing s.topologicalClosure := { s.topologicalClosure.toRing, s.toSubmonoid.commMonoidTopologicalClosure hs with } instance [T2Space A] {x : A} : CommRing (elemental R x) where mul_comm := mul_comm end Ring
.lake/packages/mathlib/Mathlib/Topology/Algebra/ContinuousAffineEquiv.lean
import Mathlib.LinearAlgebra.AffineSpace.AffineEquiv import Mathlib.Topology.Algebra.Module.Equiv import Mathlib.Topology.Algebra.ContinuousAffineMap /-! # Continuous affine equivalences In this file, we define continuous affine equivalences, affine equivalences which are continuous with continuous inverse. ## Main definitions * `ContinuousAffineEquiv.refl k P`: the identity map as a `ContinuousAffineEquiv`; * `e.symm`: the inverse map of a `ContinuousAffineEquiv` as a `ContinuousAffineEquiv`; * `e.trans e'`: composition of two `ContinuousAffineEquiv`s; note that the order follows `mathlib`'s `CategoryTheory` convention (apply `e`, then `e'`), not the convention used in function composition and compositions of bundled morphisms. * `e.toHomeomorph`: the continuous affine equivalence `e` as a homeomorphism * `e.toContinuousAffineMap`: the continuous affine equivalence `e` as a continuous affine map * `ContinuousLinearEquiv.toContinuousAffineEquiv`: a continuous linear equivalence as a continuous affine equivalence * `ContinuousAffineEquiv.constVAdd`: `AffineEquiv.constVAdd` as a continuous affine equivalence ## TODO - equip `ContinuousAffineEquiv k P P` with a `Group` structure, with multiplication corresponding to composition in `AffineEquiv.group`. -/ open Function /-- A continuous affine equivalence, denoted `P₁ ≃ᴬ[k] P₂`, between two affine topological spaces is an affine equivalence such that forward and inverse maps are continuous. -/ structure ContinuousAffineEquiv (k P₁ P₂ : Type*) {V₁ V₂ : Type*} [Ring k] [AddCommGroup V₁] [Module k V₁] [AddTorsor V₁ P₁] [TopologicalSpace P₁] [AddCommGroup V₂] [Module k V₂] [AddTorsor V₂ P₂] [TopologicalSpace P₂] extends P₁ ≃ᵃ[k] P₂ where continuous_toFun : Continuous toFun := by fun_prop continuous_invFun : Continuous invFun := by fun_prop @[inherit_doc] notation:25 P₁ " ≃ᴬ[" k:25 "] " P₂:0 => ContinuousAffineEquiv k P₁ P₂ variable {k P₁ P₂ P₃ P₄ V₁ V₂ V₃ V₄ : Type*} [Ring k] [AddCommGroup V₁] [Module k V₁] [AddTorsor V₁ P₁] [TopologicalSpace P₁] [AddCommGroup V₂] [Module k V₂] [AddTorsor V₂ P₂] [TopologicalSpace P₂] [AddCommGroup V₃] [Module k V₃] [AddTorsor V₃ P₃] [TopologicalSpace P₃] [AddCommGroup V₄] [Module k V₄] [AddTorsor V₄ P₄] [TopologicalSpace P₄] namespace ContinuousAffineEquiv -- Basic set-up: standard fields, coercions and ext lemmas section Basic /-- A continuous affine equivalence is a homeomorphism. -/ def toHomeomorph (e : P₁ ≃ᴬ[k] P₂) : P₁ ≃ₜ P₂ where __ := e theorem toAffineEquiv_injective : Injective (toAffineEquiv : (P₁ ≃ᴬ[k] P₂) → P₁ ≃ᵃ[k] P₂) := by rintro ⟨e, econt, einv_cont⟩ ⟨e', e'cont, e'inv_cont⟩ H congr instance instEquivLike : EquivLike (P₁ ≃ᴬ[k] P₂) P₁ P₂ where coe f := f.toFun inv f := f.invFun left_inv f := f.left_inv right_inv f := f.right_inv coe_injective' _ _ h _ := toAffineEquiv_injective (DFunLike.coe_injective h) instance : HomeomorphClass (P₁ ≃ᴬ[k] P₂) P₁ P₂ where map_continuous f := f.continuous_toFun inv_continuous f := f.continuous_invFun attribute [coe] ContinuousAffineEquiv.toAffineEquiv /-- Coerce continuous affine equivalences to affine equivalences. -/ instance coe : Coe (P₁ ≃ᴬ[k] P₂) (P₁ ≃ᵃ[k] P₂) := ⟨toAffineEquiv⟩ @[deprecated (since := "2025-08-15")] alias coe_injective := toAffineEquiv_injective instance instFunLike : FunLike (P₁ ≃ᴬ[k] P₂) P₁ P₂ where coe f := f.toAffineEquiv coe_injective' _ _ h := toAffineEquiv_injective (DFunLike.coe_injective h) @[simp, norm_cast] theorem coe_coe (e : P₁ ≃ᴬ[k] P₂) : ⇑(e : P₁ ≃ᵃ[k] P₂) = e := rfl @[simp] theorem coe_toEquiv (e : P₁ ≃ᴬ[k] P₂) : ⇑e.toEquiv = e := rfl /-- See Note [custom simps projection]. We need to specify this projection explicitly in this case, because it is a composition of multiple projections. -/ def Simps.apply (e : P₁ ≃ᴬ[k] P₂) : P₁ → P₂ := e /-- See Note [custom simps projection]. -/ def Simps.symm_apply (e : P₁ ≃ᴬ[k] P₂) : P₂ → P₁ := e.symm initialize_simps_projections ContinuousAffineEquiv (toFun → apply, invFun → symm_apply) @[ext] theorem ext {e e' : P₁ ≃ᴬ[k] P₂} (h : ∀ x, e x = e' x) : e = e' := DFunLike.ext _ _ h @[continuity] protected theorem continuous (e : P₁ ≃ᴬ[k] P₂) : Continuous e := e.2 /-- A continuous affine equivalence is a continuous affine map. -/ def toContinuousAffineMap (e : P₁ ≃ᴬ[k] P₂) : P₁ →ᴬ[k] P₂ where __ := e cont := e.continuous_toFun @[simp] lemma coe_toContinuousAffineMap (e : P₁ ≃ᴬ[k] P₂) : ⇑e.toContinuousAffineMap = e := rfl lemma toContinuousAffineMap_injective : Function.Injective (toContinuousAffineMap : (P₁ ≃ᴬ[k] P₂) → (P₁ →ᴬ[k] P₂)) := by intro e e' h ext p simp_rw [← coe_toContinuousAffineMap, h] lemma toContinuousAffineMap_toAffineMap (e : P₁ ≃ᴬ[k] P₂) : e.toContinuousAffineMap.toAffineMap = e.toAffineEquiv.toAffineMap := rfl lemma toContinuousAffineMap_toContinuousMap (e : P₁ ≃ᴬ[k] P₂) : e.toContinuousAffineMap.toContinuousMap = toContinuousMap e.toHomeomorph := rfl end Basic section ReflSymmTrans variable (k P₁) in /-- Identity map as a `ContinuousAffineEquiv`. -/ def refl : P₁ ≃ᴬ[k] P₁ where toEquiv := Equiv.refl P₁ linear := LinearEquiv.refl k V₁ map_vadd' _ _ := rfl @[simp] theorem coe_refl : ⇑(refl k P₁) = id := rfl @[simp] theorem refl_apply (x : P₁) : refl k P₁ x = x := rfl @[simp] theorem toAffineEquiv_refl : (refl k P₁).toAffineEquiv = AffineEquiv.refl k P₁ := rfl @[simp] theorem toEquiv_refl : (refl k P₁).toEquiv = Equiv.refl P₁ := rfl /-- Inverse of a continuous affine equivalence as a continuous affine equivalence. -/ @[symm] def symm (e : P₁ ≃ᴬ[k] P₂) : P₂ ≃ᴬ[k] P₁ where toAffineEquiv := e.toAffineEquiv.symm continuous_toFun := e.continuous_invFun continuous_invFun := e.continuous_toFun @[simp] theorem toAffineEquiv_symm (e : P₁ ≃ᴬ[k] P₂) : e.symm.toAffineEquiv = e.toAffineEquiv.symm := rfl @[deprecated "use instead `toAffineEquiv_symm`, in the reverse direction" (since := "2025-06-08")] theorem symm_toAffineEquiv (e : P₁ ≃ᴬ[k] P₂) : e.toAffineEquiv.symm = e.symm.toAffineEquiv := rfl @[simp] theorem coe_symm_toAffineEquiv (e : P₁ ≃ᴬ[k] P₂) : ⇑e.toAffineEquiv.symm = e.symm := rfl @[simp] theorem toEquiv_symm (e : P₁ ≃ᴬ[k] P₂) : e.symm.toEquiv = e.toEquiv.symm := rfl @[deprecated "use instead `symm_toEquiv`, in the reverse direction" (since := "2025-06-08")] theorem symm_toEquiv (e : P₁ ≃ᴬ[k] P₂) : e.toEquiv.symm = e.symm.toEquiv := rfl @[simp] theorem coe_symm_toEquiv (e : P₁ ≃ᴬ[k] P₂) : ⇑e.toEquiv.symm = e.symm := rfl @[simp] theorem apply_symm_apply (e : P₁ ≃ᴬ[k] P₂) (p : P₂) : e (e.symm p) = p := e.toEquiv.apply_symm_apply p @[simp] theorem symm_apply_apply (e : P₁ ≃ᴬ[k] P₂) (p : P₁) : e.symm (e p) = p := e.toEquiv.symm_apply_apply p theorem apply_eq_iff_eq_symm_apply (e : P₁ ≃ᴬ[k] P₂) {p₁ p₂} : e p₁ = p₂ ↔ p₁ = e.symm p₂ := e.toEquiv.apply_eq_iff_eq_symm_apply theorem apply_eq_iff_eq (e : P₁ ≃ᴬ[k] P₂) {p₁ p₂ : P₁} : e p₁ = e p₂ ↔ p₁ = p₂ := e.toEquiv.apply_eq_iff_eq @[simp] theorem symm_symm (e : P₁ ≃ᴬ[k] P₂) : e.symm.symm = e := rfl theorem symm_bijective : Function.Bijective (symm : (P₁ ≃ᴬ[k] P₂) → _) := Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩ theorem symm_symm_apply (e : P₁ ≃ᴬ[k] P₂) (x : P₁) : e.symm.symm x = e x := rfl theorem symm_apply_eq (e : P₁ ≃ᴬ[k] P₂) {x y} : e.symm x = y ↔ x = e y := e.toAffineEquiv.symm_apply_eq theorem eq_symm_apply (e : P₁ ≃ᴬ[k] P₂) {x y} : y = e.symm x ↔ e y = x := e.toAffineEquiv.eq_symm_apply @[simp] theorem image_symm (f : P₁ ≃ᴬ[k] P₂) (s : Set P₂) : f.symm '' s = f ⁻¹' s := f.symm.toEquiv.image_eq_preimage_symm _ @[simp] theorem preimage_symm (f : P₁ ≃ᴬ[k] P₂) (s : Set P₁) : f.symm ⁻¹' s = f '' s := (f.symm.image_symm _).symm protected theorem bijective (e : P₁ ≃ᴬ[k] P₂) : Bijective e := e.toEquiv.bijective protected theorem surjective (e : P₁ ≃ᴬ[k] P₂) : Surjective e := e.toEquiv.surjective protected theorem injective (e : P₁ ≃ᴬ[k] P₂) : Injective e := e.toEquiv.injective protected theorem image_eq_preimage_symm (e : P₁ ≃ᴬ[k] P₂) (s : Set P₁) : e '' s = e.symm ⁻¹' s := e.toEquiv.image_eq_preimage_symm s protected theorem image_symm_eq_preimage (e : P₁ ≃ᴬ[k] P₂) (s : Set P₂) : e.symm '' s = e ⁻¹' s := by rw [e.symm.image_eq_preimage_symm, e.symm_symm] @[simp] theorem image_preimage (e : P₁ ≃ᴬ[k] P₂) (s : Set P₂) : e '' (e ⁻¹' s) = s := e.surjective.image_preimage s @[simp] theorem preimage_image (e : P₁ ≃ᴬ[k] P₂) (s : Set P₁) : e ⁻¹' (e '' s) = s := e.injective.preimage_image s theorem symm_image_image (e : P₁ ≃ᴬ[k] P₂) (s : Set P₁) : e.symm '' (e '' s) = s := e.toEquiv.symm_image_image s theorem image_symm_image (e : P₁ ≃ᴬ[k] P₂) (s : Set P₂) : e '' (e.symm '' s) = s := e.symm.symm_image_image s @[simp] theorem refl_symm : (refl k P₁).symm = refl k P₁ := rfl @[simp] theorem symm_refl : (refl k P₁).symm = refl k P₁ := rfl /-- Composition of two `ContinuousAffineEquiv`alences, applied left to right. -/ @[trans] def trans (e : P₁ ≃ᴬ[k] P₂) (e' : P₂ ≃ᴬ[k] P₃) : P₁ ≃ᴬ[k] P₃ where toAffineEquiv := e.toAffineEquiv.trans e'.toAffineEquiv continuous_toFun := e'.continuous_toFun.comp (e.continuous_toFun) continuous_invFun := e.continuous_invFun.comp (e'.continuous_invFun) @[simp] theorem coe_trans (e : P₁ ≃ᴬ[k] P₂) (e' : P₂ ≃ᴬ[k] P₃) : ⇑(e.trans e') = e' ∘ e := rfl @[simp] theorem trans_apply (e : P₁ ≃ᴬ[k] P₂) (e' : P₂ ≃ᴬ[k] P₃) (p : P₁) : e.trans e' p = e' (e p) := rfl theorem trans_assoc (e₁ : P₁ ≃ᴬ[k] P₂) (e₂ : P₂ ≃ᴬ[k] P₃) (e₃ : P₃ ≃ᴬ[k] P₄) : (e₁.trans e₂).trans e₃ = e₁.trans (e₂.trans e₃) := ext fun _ ↦ rfl @[simp] theorem trans_refl (e : P₁ ≃ᴬ[k] P₂) : e.trans (refl k P₂) = e := ext fun _ ↦ rfl @[simp] theorem refl_trans (e : P₁ ≃ᴬ[k] P₂) : (refl k P₁).trans e = e := ext fun _ ↦ rfl @[simp] theorem self_trans_symm (e : P₁ ≃ᴬ[k] P₂) : e.trans e.symm = refl k P₁ := ext e.symm_apply_apply @[simp] theorem symm_trans_self (e : P₁ ≃ᴬ[k] P₂) : e.symm.trans e = refl k P₂ := ext e.apply_symm_apply lemma trans_toContinuousAffineMap (e : P₁ ≃ᴬ[k] P₂) (e' : P₂ ≃ᴬ[k] P₃) : (e.trans e').toContinuousAffineMap = e'.toContinuousAffineMap.comp e.toContinuousAffineMap := rfl end ReflSymmTrans section variable {E F : Type*} [AddCommGroup E] [Module k E] [TopologicalSpace E] [AddCommGroup F] [Module k F] [TopologicalSpace F] /-- Reinterpret a continuous linear equivalence between modules as a continuous affine equivalence. -/ def _root_.ContinuousLinearEquiv.toContinuousAffineEquiv (L : E ≃L[k] F) : E ≃ᴬ[k] F where toAffineEquiv := L.toAffineEquiv continuous_toFun := L.continuous_toFun continuous_invFun := L.continuous_invFun @[simp] theorem _root_.ContinuousLinearEquiv.coe_toContinuousAffineEquiv (e : E ≃L[k] F) : ⇑e.toContinuousAffineEquiv = e := rfl lemma _root_.ContinuousLinearEquiv.toContinuousAffineEquiv_toContinuousAffineMap (L : E ≃L[k] F) : L.toContinuousAffineEquiv.toContinuousAffineMap = L.toContinuousLinearMap.toContinuousAffineMap := rfl variable (k P₁) in /-- The map `p ↦ v +ᵥ p` as a continuous affine automorphism of an affine space on which addition is continuous. -/ def constVAdd [ContinuousConstVAdd V₁ P₁] (v : V₁) : P₁ ≃ᴬ[k] P₁ where toAffineEquiv := AffineEquiv.constVAdd k P₁ v continuous_toFun := continuous_const_vadd v continuous_invFun := continuous_const_vadd (-v) lemma constVAdd_coe [ContinuousConstVAdd V₁ P₁] (v : V₁) : (constVAdd k P₁ v).toAffineEquiv = .constVAdd k P₁ v := rfl end section variable (e₁ : P₁ ≃ᴬ[k] P₂) (e₂ : P₃ ≃ᴬ[k] P₄) /-- Product of two continuous affine equivalences. The map comes from `Equiv.prodCongr` -/ @[simps toAffineEquiv] def prodCongr : P₁ × P₃ ≃ᴬ[k] P₂ × P₄ where __ := AffineEquiv.prodCongr e₁ e₂ continuous_toFun := by eta_expand; dsimp; fun_prop continuous_invFun := by eta_expand; dsimp; fun_prop @[simp] theorem prodCongr_symm : (e₁.prodCongr e₂).symm = e₁.symm.prodCongr e₂.symm := rfl @[simp] theorem prodCongr_apply (p : P₁ × P₃) : e₁.prodCongr e₂ p = (e₁ p.1, e₂ p.2) := rfl @[simp] theorem prodCongr_toContinuousAffineMap : (e₁.prodCongr e₂).toContinuousAffineMap = e₁.toContinuousAffineMap.prodMap e₂.toContinuousAffineMap := rfl end section variable (k P₁ P₂ P₃) /-- Product of affine spaces is commutative up to continuous affine isomorphism. -/ @[simps! apply symm_apply toAffineEquiv] def prodComm : P₁ × P₂ ≃ᴬ[k] P₂ × P₁ where __ := AffineEquiv.prodComm k P₁ P₂ continuous_toFun := continuous_swap continuous_invFun := continuous_swap @[simp] theorem prodComm_symm : (prodComm k P₁ P₂).symm = prodComm k P₂ P₁ := rfl /-- Product of affine spaces is associative up to continuous affine isomorphism. -/ @[simps! apply symm_apply toAffineEquiv] def prodAssoc : (P₁ × P₂) × P₃ ≃ᴬ[k] P₁ × (P₂ × P₃) where __ := AffineEquiv.prodAssoc k P₁ P₂ P₃ continuous_toFun := by eta_expand; dsimp; fun_prop continuous_invFun := by eta_expand; dsimp; fun_prop end end ContinuousAffineEquiv
.lake/packages/mathlib/Mathlib/Topology/Algebra/LinearTopology.lean
import Mathlib.RingTheory.TwoSidedIdeal.Operations import Mathlib.Topology.Algebra.Ring.Basic import Mathlib.Topology.Algebra.OpenSubgroup /-! # Linear topologies on modules and rings Let `M` be a (left) module over a ring `R`. Following [Stacks: Definition 15.36.1](https://stacks.math.columbia.edu/tag/07E8), we say that a topology on `M` is *`R`-linear* if it is invariant by translations and admits a basis of neighborhoods of 0 consisting of (left) `R`-submodules. If `M` is an `(R, R')`-bimodule, we show that a topology is both `R`-linear and `R'`-linear if and only if there exists a basis of neighborhoods of 0 consisting of `(R, R')`-subbimodules. In particular, we say that a topology on the ring `R` is *linear* if it is linear if it is linear when `R` is viewed as an `(R, Rᵐᵒᵖ)`-bimodule. By the previous results, this means that there exists a basis of neighborhoods of 0 consisting of two-sided ideals, hence our definition agrees with [N. Bourbaki, *Algebra II*, chapter 4, §2, n° 3][bourbaki1981]. ## Main definitions and statements * `IsLinearTopology R M`: the topology on `M` is `R`-linear, meaning that there exists a basis of neighborhoods of 0 consisting of `R`-submodules. Note that we don't impose that the topology is invariant by translation, so you'll often want to add `ContinuousConstVAdd M M` to get something meaningful. To express that the topology of a ring `R` is linear, use `[IsLinearTopology R R] [IsLinearTopology Rᵐᵒᵖ R]`. * `IsLinearTopology.mk_of_hasBasis`: a convenient constructor for `IsLinearTopology`. See also `IsLinearTopology.mk_of_hasBasis'`. * The discrete topology on `M` is `R`-linear (declared as an `instance`). * `IsLinearTopology.hasBasis_subbimodule`: assume that `M` is an `(R, R')`-bimodule, and that its topology is both `R`-linear and `R'`-linear. Then there exists a basis of neighborhoods of 0 made of `(R, R')`-subbimodules. Note that this is not trivial, since the bases witnessing `R`-linearity and `R'`-linearity may have nothing to do with each other * `IsLinearTopology.tendsto_smul_zero`: assume that the topology on `M` is linear. For `m : ι → M` such that `m i` tends to 0, `r i • m i` still tends to 0 for any `r : ι → R`. * `IsLinearTopology.hasBasis_twoSidedIdeal`: if the ring `R` is linearly topologized, in the sense that we have both `IsLinearTopology R R` and `IsLinearTopology Rᵐᵒᵖ R`, then there exists a basis of neighborhoods of 0 consisting of two-sided ideals. * Conversely, to prove `IsLinearTopology R R` and `IsLinearTopology Rᵐᵒᵖ R` from a basis of two-sided ideals, use `IsLinearTopology.mk_of_hasBasis'` twice. * `IsLinearTopology.tendsto_mul_zero_of_left`: assume that the topology on `R` is (right-)linear. For `f, g : ι → R` such that `f i` tends to `0`, `f i * g i` still tends to `0`. * `IsLinearTopology.tendsto_mul_zero_of_right`: assume that the topology on `R` is (left-)linear. For `f, g : ι → R` such that `g i` tends to `0`, `f i * g i` still tends to `0` * If `R` is a commutative ring and its topology is left-linear, it is automatically right-linear (declared as a low-priority instance). ## Notes on the implementation * Some statements assume `ContinuousAdd M` where `ContinuousConstVAdd M M` (invariance by translation) would be enough. In fact, in presence of `IsLinearTopology R M`, invariance by translation implies that `M` is a topological additive group on which `R` acts by homeomorphisms. Similarly, `IsLinearTopology R R` and `ContinuousConstVAdd R R` imply that `R` is a topological ring. All of this will follow from https://github.com/leanprover-community/mathlib4/issues/18437. Nevertheless, we don't plan on adding those facts as instances: one should use directly results from https://github.com/leanprover-community/mathlib4/issues/18437 to get `IsTopologicalAddGroup` and `IsTopologicalRing` instances. * The main constructor for `IsLinearTopology`, `IsLinearTopology.mk_of_hasBasis` is formulated in terms of the subobject classes `AddSubmonoidClass` and `SMulMemClass` to allow for more complicated types than `Submodule R M` or `Ideal R`. Unfortunately, the scalar ring in `SMulMemClass` is an `outParam`, which means that Lean only considers one base ring for a given subobject type. For example, Lean will *never* find `SMulMemClass (TwoSidedIdeal R) R R` because it prioritizes the (later-defined) instance of `SMulMemClass (TwoSidedIdeal R) Rᵐᵒᵖ R`. This makes `IsLinearTopology.mk_of_hasBasis` un-applicable to `TwoSidedIdeal` (and probably other types), thus we provide `IsLinearTopology.mk_of_hasBasis'` as an alternative not relying on typeclass inference. -/ open scoped Topology open Filter namespace IsLinearTopology section Module variable {R R' M : Type*} [Ring R] [Ring R'] [AddCommGroup M] [Module R M] [Module R' M] [SMulCommClass R R' M] [TopologicalSpace M] variable (R M) in /-- Consider a (left-)module `M` over a ring `R`. A topology on `M` is *`R`-linear* if the open sub-`R`-modules of `M` form a basis of neighborhoods of zero. Typically one would also that the topology is invariant by translation (`ContinuousConstVAdd M M`), or equivalently that `M` is a topological group, but we do not assume it for the definition. In particular, we say that a topology on the ring `R` is *linear* if it is both `R`-linear and `Rᵐᵒᵖ`-linear for the obvious module structures. To spell this in Lean, simply use `[IsLinearTopology R R] [IsLinearTopology Rᵐᵒᵖ R]`. -/ class _root_.IsLinearTopology where hasBasis_submodule' : (𝓝 (0 : M)).HasBasis (fun N : Submodule R M ↦ (N : Set M) ∈ 𝓝 0) (fun N : Submodule R M ↦ (N : Set M)) variable (R) in lemma hasBasis_submodule [IsLinearTopology R M] : (𝓝 (0 : M)).HasBasis (fun N : Submodule R M ↦ (N : Set M) ∈ 𝓝 0) (fun N : Submodule R M ↦ (N : Set M)) := IsLinearTopology.hasBasis_submodule' variable (R) in lemma hasBasis_open_submodule [ContinuousAdd M] [IsLinearTopology R M] : (𝓝 (0 : M)).HasBasis (fun N : Submodule R M ↦ IsOpen (N : Set M)) (fun N : Submodule R M ↦ (N : Set M)) := hasBasis_submodule R |>.congr (fun N ↦ ⟨N.toAddSubgroup.isOpen_of_mem_nhds, fun hN ↦ hN.mem_nhds (zero_mem N)⟩) (fun _ _ ↦ rfl) variable (R) in /-- A variant of `IsLinearTopology.mk_of_hasBasis` asking for an explicit proof that `S` is a class of submodules instead of relying on (fragile) typeclass inference of `SMulCommClass`. -/ lemma mk_of_hasBasis' {ι : Sort*} {S : Type*} [SetLike S M] [AddSubmonoidClass S M] {p : ι → Prop} {s : ι → S} (h : (𝓝 0).HasBasis p (fun i ↦ (s i : Set M))) (hsmul : ∀ s : S, ∀ r : R, ∀ m ∈ s, r • m ∈ s) : IsLinearTopology R M where hasBasis_submodule' := h.to_hasBasis (fun i hi ↦ ⟨ { carrier := s i, add_mem' := add_mem, zero_mem' := zero_mem _, smul_mem' := hsmul _}, h.mem_of_mem hi, subset_rfl⟩) (fun _ ↦ h.mem_iff.mp) variable (R) in /-- To show that `M` is linearly-topologized as an `R`-module, it suffices to show that it has a basis of neighborhoods of zero made of `R`-submodules. Note: for technical reasons detailed in the module docstring, Lean sometimes struggles to find the right `SMulMemClass` instance. See `IsLinearTopology.mk_of_hasBasis'` for a more explicit variant. -/ lemma mk_of_hasBasis {ι : Sort*} {S : Type*} [SetLike S M] [SMulMemClass S R M] [AddSubmonoidClass S M] {p : ι → Prop} {s : ι → S} (h : (𝓝 0).HasBasis p (fun i ↦ (s i : Set M))) : IsLinearTopology R M := mk_of_hasBasis' R h fun _ ↦ SMulMemClass.smul_mem theorem _root_.isLinearTopology_iff_hasBasis_submodule : IsLinearTopology R M ↔ (𝓝 0).HasBasis (fun N : Submodule R M ↦ (N : Set M) ∈ 𝓝 0) (fun N : Submodule R M ↦ (N : Set M)) := ⟨fun _ ↦ hasBasis_submodule R, fun h ↦ .mk_of_hasBasis R h⟩ theorem _root_.isLinearTopology_iff_hasBasis_open_submodule [ContinuousAdd M] : IsLinearTopology R M ↔ (𝓝 0).HasBasis (fun N : Submodule R M ↦ IsOpen (N : Set M)) (fun N : Submodule R M ↦ (N : Set M)) := ⟨fun _ ↦ hasBasis_open_submodule R, fun h ↦ .mk_of_hasBasis R h⟩ /-- The discrete topology on any `R`-module is `R`-linear. -/ instance [DiscreteTopology M] : IsLinearTopology R M := have : HasBasis (𝓝 0 : Filter M) (fun _ ↦ True) (fun (_ : Unit) ↦ (⊥ : Submodule R M)) := by rw [nhds_discrete] exact hasBasis_pure _ mk_of_hasBasis R this variable (R R') in open Set Pointwise in /-- Assume that `M` is a module over two rings `R` and `R'`, and that its topology is linear with respect to each of these rings. Then, it has a basis of neighborhoods of zero made of sub-`(R, R')`-bimodules. The proof is inspired by lemma 9 in [I. Kaplansky, *Topological Rings*](kaplansky_topological_1947). TODO: Formalize the lemma in its full strength. Note: due to the lack of a satisfying theory of sub-bimodules, we use `AddSubgroup`s with extra conditions. -/ lemma hasBasis_subbimodule [IsLinearTopology R M] [IsLinearTopology R' M] : (𝓝 (0 : M)).HasBasis (fun I : AddSubgroup M ↦ (I : Set M) ∈ 𝓝 0 ∧ (∀ r : R, ∀ x ∈ I, r • x ∈ I) ∧ (∀ r' : R', ∀ x ∈ I, r' • x ∈ I)) (fun I : AddSubgroup M ↦ (I : Set M)) := by -- Start from a neighborhood `V`. It contains some open sub-`R`-module `I`. refine IsLinearTopology.hasBasis_submodule R |>.to_hasBasis (fun I hI ↦ ?_) (fun I hI ↦ ⟨{I with smul_mem' := fun r x hx ↦ hI.2.1 r x hx}, hI.1, subset_rfl⟩) -- `I` itself is a neighborhood of zero, so it contains some open sub-`R'`-module `J`. rcases (hasBasis_submodule R').mem_iff.mp hI with ⟨J, hJ, J_sub_I⟩ set uR : Set R := univ -- Convenient to avoid type ascriptions set uR' : Set R' := univ have hRR : uR * uR ⊆ uR := subset_univ _ have hRI : uR • (I : Set M) ⊆ I := smul_subset_iff.mpr fun x _ i hi ↦ I.smul_mem x hi have hR'J : uR' • (J : Set M) ⊆ J := smul_subset_iff.mpr fun x _ j hj ↦ J.smul_mem x hj have hRJ : uR • (J : Set M) ⊆ I := subset_trans (smul_subset_smul_left J_sub_I) hRI -- Note that, on top of the obvious `R • I ⊆ I` and `R' • J ⊆ J`, we have `R • J ⊆ R • I ⊆ I`. -- Now set `S := J ∪ (R • J)`. We have: -- 1. `R • S = (R • J) ∪ (R • R • J) ⊆ R • J ⊆ S`. -- 2. `R' • S = (R' • J) ∪ (R' • R • J) ⊆ J ∪ (R • R' • J) ⊆ J ∪ (R • J) = S`. -- Hence the subgroup `A` generated by `S` is a sub-`(R, R')`-bimodule, -- which we claim is open and contained in `I`. -- Indeed, we have `J ⊆ S ⊆ I`, hence `J ⊆ A ⊆ I`, and `J` is open by hypothesis. set S : Set M := J ∪ uR • J have S_sub_I : S ⊆ I := union_subset J_sub_I hRJ have hRS : uR • S ⊆ S := calc uR • S = uR • (J : Set M) ∪ (uR * uR) • (J : Set M) := by simp_rw [S, smul_union, mul_smul] _ ⊆ uR • (J : Set M) ∪ uR • (J : Set M) := by gcongr _ = uR • (J : Set M) := union_self _ _ ⊆ S := subset_union_right have hR'S : uR' • S ⊆ S := calc uR' • S = uR' • (J : Set M) ∪ uR • uR' • (J : Set M) := by simp_rw [S, smul_union, smul_comm] _ ⊆ J ∪ uR • J := by gcongr _ = S := rfl set A : AddSubgroup M := .closure S have hRA : ∀ r : R, ∀ i ∈ A, r • i ∈ A := fun r i hi ↦ by refine AddSubgroup.closure_induction (fun x hx => ?base) ?zero (fun x y _ _ hx hy ↦ ?add) (fun x _ hx ↦ ?neg) hi case base => exact AddSubgroup.subset_closure <| hRS <| Set.smul_mem_smul trivial hx case zero => simp_rw [smul_zero]; exact zero_mem _ case add => simp_rw [smul_add]; exact add_mem hx hy case neg => simp_rw [smul_neg]; exact neg_mem hx have hR'A : ∀ r' : R', ∀ i ∈ A, r' • i ∈ A := fun r' i hi ↦ by refine AddSubgroup.closure_induction (fun x hx => ?base) ?zero (fun x y _ _ hx hy ↦ ?add) (fun x _ hx ↦ ?neg) hi case base => exact AddSubgroup.subset_closure <| hR'S <| Set.smul_mem_smul trivial hx case zero => simp_rw [smul_zero]; exact zero_mem _ case add => simp_rw [smul_add]; exact add_mem hx hy case neg => simp_rw [smul_neg]; exact neg_mem hx have A_sub_I : (A : Set M) ⊆ I := I.toAddSubgroup.closure_le.mpr S_sub_I have J_sub_A : (J : Set M) ⊆ A := subset_trans subset_union_left AddSubgroup.subset_closure exact ⟨A, ⟨mem_of_superset hJ J_sub_A, hRA, hR'A⟩, A_sub_I⟩ variable (R R') in open Set Pointwise in /-- A variant of `IsLinearTopology.hasBasis_subbimodule` using `IsOpen I` instead of `I ∈ 𝓝 0`. -/ lemma hasBasis_open_subbimodule [ContinuousAdd M] [IsLinearTopology R M] [IsLinearTopology R' M] : (𝓝 (0 : M)).HasBasis (fun I : AddSubgroup M ↦ IsOpen (I : Set M) ∧ (∀ r : R, ∀ x ∈ I, r • x ∈ I) ∧ (∀ r' : R', ∀ x ∈ I, r' • x ∈ I)) (fun I : AddSubgroup M ↦ (I : Set M)) := hasBasis_subbimodule R R' |>.congr (fun N ↦ and_congr_left' ⟨N.isOpen_of_mem_nhds, fun hN ↦ hN.mem_nhds (zero_mem N)⟩) (fun _ _ ↦ rfl) -- Even though `R` can be recovered from `a`, the nature of this lemma means that `a` will -- often be left for Lean to infer, so making `R` explicit is useful in practice. variable (R) in /-- If `M` is a linearly topologized `R`-module and `i ↦ m i` tends to zero, then `i ↦ a i • m i` still tends to zero for any family `a : ι → R`. -/ theorem tendsto_smul_zero [IsLinearTopology R M] {ι : Type*} {f : Filter ι} (a : ι → R) (m : ι → M) (ha : Tendsto m f (𝓝 0)) : Tendsto (a • m) f (𝓝 0) := by rw [hasBasis_submodule R |>.tendsto_right_iff] at ha ⊢ intro I hI filter_upwards [ha I hI] with i ai_mem exact I.smul_mem _ ai_mem variable (R) in /-- If the left and right actions of `R` on `M` coincide, then a topology is `Rᵐᵒᵖ`-linear if and only if it is `R`-linear. -/ theorem _root_.IsCentralScalar.isLinearTopology_iff [Module Rᵐᵒᵖ M] [IsCentralScalar R M] : IsLinearTopology Rᵐᵒᵖ M ↔ IsLinearTopology R M := by constructor <;> intro H · exact mk_of_hasBasis' R (IsLinearTopology.hasBasis_submodule Rᵐᵒᵖ) fun S r m hm ↦ op_smul_eq_smul r m ▸ S.smul_mem _ hm · exact mk_of_hasBasis' Rᵐᵒᵖ (IsLinearTopology.hasBasis_submodule R) fun S r m hm ↦ unop_smul_eq_smul r m ▸ S.smul_mem _ hm end Module section Ring variable {R : Type*} [Ring R] [TopologicalSpace R] theorem hasBasis_ideal [IsLinearTopology R R] : (𝓝 0).HasBasis (fun I : Ideal R ↦ (I : Set R) ∈ 𝓝 0) (fun I : Ideal R ↦ (I : Set R)) := hasBasis_submodule R theorem hasBasis_open_ideal [ContinuousAdd R] [IsLinearTopology R R] : (𝓝 0).HasBasis (fun I : Ideal R ↦ IsOpen (I : Set R)) (fun I : Ideal R ↦ (I : Set R)) := hasBasis_open_submodule R theorem _root_.isLinearTopology_iff_hasBasis_ideal : IsLinearTopology R R ↔ (𝓝 0).HasBasis (fun I : Ideal R ↦ (I : Set R) ∈ 𝓝 0) (fun I : Ideal R ↦ (I : Set R)) := isLinearTopology_iff_hasBasis_submodule theorem _root_.isLinearTopology_iff_hasBasis_open_ideal [IsTopologicalRing R] : IsLinearTopology R R ↔ (𝓝 0).HasBasis (fun I : Ideal R ↦ IsOpen (I : Set R)) (fun I : Ideal R ↦ (I : Set R)) := isLinearTopology_iff_hasBasis_open_submodule theorem hasBasis_right_ideal [IsLinearTopology Rᵐᵒᵖ R] : (𝓝 0).HasBasis (fun I : Submodule Rᵐᵒᵖ R ↦ (I : Set R) ∈ 𝓝 0) (fun I ↦ (I : Set R)) := hasBasis_submodule Rᵐᵒᵖ open Set Pointwise in /-- If a ring `R` is linearly ordered as a left *and* right module over itself, then it has a basis of neighborhoods of zero made of *two-sided* ideals. This is usually called a *linearly topologized ring*, but we do not add a specific spelling: you should use `[IsLinearTopology R R] [IsLinearTopology Rᵐᵒᵖ R]` instead. -/ lemma hasBasis_twoSidedIdeal [IsLinearTopology R R] [IsLinearTopology Rᵐᵒᵖ R] : (𝓝 (0 : R)).HasBasis (fun I : TwoSidedIdeal R ↦ (I : Set R) ∈ 𝓝 0) (fun I : TwoSidedIdeal R ↦ (I : Set R)) := hasBasis_subbimodule R Rᵐᵒᵖ |>.to_hasBasis (fun I ⟨hI, hRI, hRI'⟩ ↦ ⟨.mk' I (zero_mem _) add_mem neg_mem (hRI _ _) (hRI' _ _), by simpa using hI, by simp⟩) (fun I hI ↦ ⟨I.asIdeal.toAddSubgroup, ⟨hI, I.mul_mem_left, fun r x hx ↦ I.mul_mem_right x (r.unop) hx⟩, subset_rfl⟩) lemma hasBasis_open_twoSidedIdeal [ContinuousAdd R] [IsLinearTopology R R] [IsLinearTopology Rᵐᵒᵖ R] : (𝓝 (0 : R)).HasBasis (fun I : TwoSidedIdeal R ↦ IsOpen (I : Set R)) (fun I : TwoSidedIdeal R ↦ (I : Set R)) := hasBasis_twoSidedIdeal.congr (fun I ↦ ⟨I.asIdeal.toAddSubgroup.isOpen_of_mem_nhds, fun hI ↦ hI.mem_nhds (zero_mem I)⟩) (fun _ _ ↦ rfl) theorem _root_.isLinearTopology_iff_hasBasis_twoSidedIdeal : IsLinearTopology R R ∧ IsLinearTopology Rᵐᵒᵖ R ↔ (𝓝 0).HasBasis (fun I : TwoSidedIdeal R ↦ (I : Set R) ∈ 𝓝 0) (fun I : TwoSidedIdeal R ↦ (I : Set R)) := ⟨fun ⟨_, _⟩ ↦ hasBasis_twoSidedIdeal, fun h ↦ ⟨.mk_of_hasBasis' R h fun I r x hx ↦ I.mul_mem_left r x hx, .mk_of_hasBasis' Rᵐᵒᵖ h fun I r x hx ↦ I.mul_mem_right x r.unop hx⟩⟩ theorem _root_.isLinearTopology_iff_hasBasis_open_twoSidedIdeal [ContinuousAdd R] : IsLinearTopology R R ∧ IsLinearTopology Rᵐᵒᵖ R ↔ (𝓝 0).HasBasis (fun I : TwoSidedIdeal R ↦ IsOpen (I : Set R)) (fun I : TwoSidedIdeal R ↦ (I : Set R)) := ⟨fun ⟨_, _⟩ ↦ hasBasis_open_twoSidedIdeal, fun h ↦ ⟨.mk_of_hasBasis' R h fun I r x hx ↦ I.mul_mem_left r x hx, .mk_of_hasBasis' Rᵐᵒᵖ h fun I r x hx ↦ I.mul_mem_right x r.unop hx⟩⟩ theorem tendsto_mul_zero_of_left [IsLinearTopology Rᵐᵒᵖ R] {ι : Type*} {f : Filter ι} (a b : ι → R) (ha : Tendsto a f (𝓝 0)) : Tendsto (a * b) f (𝓝 0) := tendsto_smul_zero (R := Rᵐᵒᵖ) _ _ ha theorem tendsto_mul_zero_of_right [IsLinearTopology R R] {ι : Type*} {f : Filter ι} (a b : ι → R) (hb : Tendsto b f (𝓝 0)) : Tendsto (a * b) f (𝓝 0) := tendsto_smul_zero (R := R) _ _ hb end Ring section CommRing variable {R M : Type*} [CommRing R] [TopologicalSpace R] /-- If `R` is commutative and left-linearly topologized, it is also right-linearly topologized. -/ instance (priority := 100) [IsLinearTopology R R] : IsLinearTopology Rᵐᵒᵖ R := by rwa [IsCentralScalar.isLinearTopology_iff] end CommRing end IsLinearTopology
.lake/packages/mathlib/Mathlib/Topology/Algebra/ContinuousAffineMap.lean
import Mathlib.LinearAlgebra.AffineSpace.AffineMap import Mathlib.Topology.Algebra.Module.LinearMapPiProd import Mathlib.Topology.Algebra.Affine /-! # Continuous affine maps. This file defines a type of bundled continuous affine maps. ## Main definitions: * `ContinuousAffineMap` ## Notation: We introduce the notation `P →ᴬ[R] Q` for `ContinuousAffineMap R P Q` (not to be confused with the notation `A →A[R] B` for `ContinuousAlgHom`). Note that this is parallel to the notation `E →L[R] F` for `ContinuousLinearMap R E F`. -/ /-- A continuous map of affine spaces -/ structure ContinuousAffineMap (R : Type*) {V W : Type*} (P Q : Type*) [Ring R] [AddCommGroup V] [Module R V] [TopologicalSpace P] [AddTorsor V P] [AddCommGroup W] [Module R W] [TopologicalSpace Q] [AddTorsor W Q] extends P →ᵃ[R] Q where cont : Continuous toFun /-- A continuous map of affine spaces -/ notation:25 P " →ᴬ[" R "] " Q => ContinuousAffineMap R P Q namespace ContinuousAffineMap variable {R V W P Q : Type*} [Ring R] variable [AddCommGroup V] [Module R V] [TopologicalSpace P] [AddTorsor V P] variable [AddCommGroup W] [Module R W] [TopologicalSpace Q] [AddTorsor W Q] instance : Coe (P →ᴬ[R] Q) (P →ᵃ[R] Q) := ⟨toAffineMap⟩ attribute [coe] ContinuousAffineMap.toAffineMap theorem toAffineMap_injective {f g : P →ᴬ[R] Q} (h : (f : P →ᵃ[R] Q) = (g : P →ᵃ[R] Q)) : f = g := by cases f cases g congr instance : FunLike (P →ᴬ[R] Q) P Q where coe f := f.toAffineMap coe_injective' _ _ h := toAffineMap_injective <| DFunLike.coe_injective h instance : ContinuousMapClass (P →ᴬ[R] Q) P Q where map_continuous := cont theorem toFun_eq_coe (f : P →ᴬ[R] Q) : f.toFun = ⇑f := rfl theorem coe_injective : @Function.Injective (P →ᴬ[R] Q) (P → Q) (⇑) := DFunLike.coe_injective @[ext] theorem ext {f g : P →ᴬ[R] Q} (h : ∀ x, f x = g x) : f = g := DFunLike.ext _ _ h theorem congr_fun {f g : P →ᴬ[R] Q} (h : f = g) (x : P) : f x = g x := DFunLike.congr_fun h _ /-- Forgetting its algebraic properties, a continuous affine map is a continuous map. -/ def toContinuousMap (f : P →ᴬ[R] Q) : C(P, Q) := ⟨f, f.cont⟩ instance : CoeHead (P →ᴬ[R] Q) C(P, Q) := ⟨toContinuousMap⟩ @[simp] theorem toContinuousMap_coe (f : P →ᴬ[R] Q) : f.toContinuousMap = ↑f := rfl @[simp, norm_cast] theorem coe_toAffineMap (f : P →ᴬ[R] Q) : ((f : P →ᵃ[R] Q) : P → Q) = f := rfl @[simp, norm_cast] theorem coe_to_continuousMap (f : P →ᴬ[R] Q) : ((f : C(P, Q)) : P → Q) = f := rfl theorem to_continuousMap_injective {f g : P →ᴬ[R] Q} (h : (f : C(P, Q)) = (g : C(P, Q))) : f = g := by ext a exact ContinuousMap.congr_fun h a @[norm_cast] theorem coe_toAffineMap_mk (f : P →ᵃ[R] Q) (h) : ((⟨f, h⟩ : P →ᴬ[R] Q) : P →ᵃ[R] Q) = f := rfl @[norm_cast] theorem coe_continuousMap_mk (f : P →ᵃ[R] Q) (h) : ((⟨f, h⟩ : P →ᴬ[R] Q) : C(P, Q)) = ⟨f, h⟩ := rfl @[simp] theorem coe_mk (f : P →ᵃ[R] Q) (h) : ((⟨f, h⟩ : P →ᴬ[R] Q) : P → Q) = f := rfl @[simp] theorem mk_coe (f : P →ᴬ[R] Q) (h) : (⟨(f : P →ᵃ[R] Q), h⟩ : P →ᴬ[R] Q) = f := by ext rfl @[continuity] protected theorem continuous (f : P →ᴬ[R] Q) : Continuous f := f.2 variable (R P) /-- The constant map as a continuous affine map -/ def const (q : Q) : P →ᴬ[R] Q := { AffineMap.const R P q with cont := continuous_const } @[simp] theorem coe_const (q : Q) : ⇑(const R P q) = Function.const P q := rfl noncomputable instance : Inhabited (P →ᴬ[R] Q) := ⟨const R P <| Nonempty.some (by infer_instance : Nonempty Q)⟩ /-- The identity map as a continuous affine map -/ def id : P →ᴬ[R] P := { AffineMap.id R P with cont := continuous_id } @[simp, norm_cast] theorem coe_id : ⇑(id R P) = _root_.id := rfl variable {R P} {W₂ Q₂ W₃ Q₃ : Type*} variable [AddCommGroup W₂] [Module R W₂] [TopologicalSpace Q₂] [AddTorsor W₂ Q₂] /-- The composition of continuous affine maps as a continuous affine map -/ def comp (f : Q →ᴬ[R] Q₂) (g : P →ᴬ[R] Q) : P →ᴬ[R] Q₂ := { (f : Q →ᵃ[R] Q₂).comp (g : P →ᵃ[R] Q) with cont := f.cont.comp g.cont } @[simp, norm_cast] theorem coe_comp (f : Q →ᴬ[R] Q₂) (g : P →ᴬ[R] Q) : ⇑(f.comp g) = f ∘ g := rfl theorem comp_apply (f : Q →ᴬ[R] Q₂) (g : P →ᴬ[R] Q) (p : P) : f.comp g p = f (g p) := rfl @[simp] theorem comp_id (f : P →ᴬ[R] Q) : f.comp (id R P) = f := ext fun _ => rfl @[simp] theorem id_comp (f : P →ᴬ[R] Q) : (id R Q).comp f = f := ext fun _ => rfl /-- The continuous affine map sending `0` to `p₀` and `1` to `p₁` -/ def lineMap (p₀ p₁ : P) [TopologicalSpace R] [TopologicalSpace V] [ContinuousSMul R V] [ContinuousVAdd V P] : R →ᴬ[R] P where toAffineMap := AffineMap.lineMap p₀ p₁ cont := (continuous_id.smul continuous_const).vadd continuous_const @[simp] lemma lineMap_toAffineMap (p₀ p₁ : P) [TopologicalSpace R] [TopologicalSpace V] [ContinuousSMul R V] [ContinuousVAdd V P] : (lineMap p₀ p₁).toAffineMap = AffineMap.lineMap (k := R) p₀ p₁ := rfl lemma coe_lineMap_eq (p₀ p₁ : P) [TopologicalSpace R] [TopologicalSpace V] [ContinuousSMul R V] [ContinuousVAdd V P] : ⇑(ContinuousAffineMap.lineMap p₀ p₁) = ⇑(AffineMap.lineMap (k := R) p₀ p₁) := rfl section IsTopologicalAddTorsor variable [TopologicalSpace V] [IsTopologicalAddTorsor P] variable [TopologicalSpace W] [IsTopologicalAddTorsor Q] variable [TopologicalSpace W₂] [IsTopologicalAddTorsor Q₂] /-- The linear map underlying a continuous affine map is continuous. -/ def contLinear (f : P →ᴬ[R] Q) : V →L[R] W := { f.linear with toFun := f.linear cont := by rw [AffineMap.continuous_linear_iff]; exact f.cont } @[simp] theorem coe_contLinear (f : P →ᴬ[R] Q) : (f.contLinear : V → W) = f.linear := rfl @[simp] theorem coe_contLinear_eq_linear (f : P →ᴬ[R] Q) : (f.contLinear : V →ₗ[R] W) = (f : P →ᵃ[R] Q).linear := rfl @[simp] theorem coe_mk_contLinear_eq_linear (f : P →ᵃ[R] Q) (h) : ((⟨f, h⟩ : P →ᴬ[R] Q).contLinear : V → W) = f.linear := rfl @[deprecated (since := "2025-09-17")] alias coe_mk_const_linear_eq_linear := coe_mk_contLinear_eq_linear theorem coe_linear_eq_coe_contLinear (f : P →ᴬ[R] Q) : ((f : P →ᵃ[R] Q).linear : V → W) = (⇑f.contLinear : V → W) := rfl @[simp] theorem comp_contLinear (f : P →ᴬ[R] Q) (g : Q →ᴬ[R] Q₂) : (g.comp f).contLinear = g.contLinear.comp f.contLinear := rfl @[simp] theorem map_vadd (f : P →ᴬ[R] Q) (p : P) (v : V) : f (v +ᵥ p) = f.contLinear v +ᵥ f p := f.map_vadd' p v @[simp] theorem contLinear_map_vsub (f : P →ᴬ[R] Q) (p₁ p₂ : P) : f.contLinear (p₁ -ᵥ p₂) = f p₁ -ᵥ f p₂ := f.toAffineMap.linearMap_vsub p₁ p₂ @[simp] theorem const_contLinear (q : Q) : (const R P q).contLinear = 0 := rfl theorem contLinear_eq_zero_iff_exists_const (f : P →ᴬ[R] Q) : f.contLinear = 0 ↔ ∃ q, f = const R P q := by have h₁ : f.contLinear = 0 ↔ (f : P →ᵃ[R] Q).linear = 0 := by refine ⟨fun h => ?_, fun h => ?_⟩ <;> ext · rw [← coe_contLinear_eq_linear, h]; rfl · rw [← coe_linear_eq_coe_contLinear, h]; rfl have h₂ : ∀ q : Q, f = const R P q ↔ (f : P →ᵃ[R] Q) = AffineMap.const R P q := by intro q refine ⟨fun h => ?_, fun h => ?_⟩ <;> ext · rw [h]; rfl · rw [← coe_toAffineMap, h, AffineMap.const_apply, coe_const, Function.const_apply] simp_rw [h₁, h₂] exact (f : P →ᵃ[R] Q).linear_eq_zero_iff_exists_const end IsTopologicalAddTorsor section ModuleValuedMaps variable {S : Type*} variable [TopologicalSpace W] instance : Zero (P →ᴬ[R] W) := ⟨ContinuousAffineMap.const R P 0⟩ @[norm_cast, simp] theorem coe_zero : ((0 : P →ᴬ[R] W) : P → W) = 0 := rfl theorem zero_apply (x : P) : (0 : P →ᴬ[R] W) x = 0 := rfl section MulAction variable [Monoid S] [DistribMulAction S W] [SMulCommClass R S W] variable [ContinuousConstSMul S W] instance : SMul S (P →ᴬ[R] W) where smul t f := { t • (f : P →ᵃ[R] W) with cont := f.continuous.const_smul t } @[norm_cast, simp] theorem coe_smul (t : S) (f : P →ᴬ[R] W) : ⇑(t • f) = t • ⇑f := rfl theorem smul_apply (t : S) (f : P →ᴬ[R] W) (x : P) : (t • f) x = t • f x := rfl instance [DistribMulAction Sᵐᵒᵖ W] [IsCentralScalar S W] : IsCentralScalar S (P →ᴬ[R] W) where op_smul_eq_smul _ _ := ext fun _ ↦ op_smul_eq_smul _ _ instance : MulAction S (P →ᴬ[R] W) := Function.Injective.mulAction _ coe_injective coe_smul variable [TopologicalSpace V] [IsTopologicalAddTorsor P] [IsTopologicalAddGroup W] @[simp] theorem smul_contLinear (t : S) (f : P →ᴬ[R] W) : (t • f).contLinear = t • f.contLinear := rfl end MulAction variable [IsTopologicalAddGroup W] instance : Add (P →ᴬ[R] W) where add f g := { (f : P →ᵃ[R] W) + (g : P →ᵃ[R] W) with cont := f.continuous.add g.continuous } @[norm_cast, simp] theorem coe_add (f g : P →ᴬ[R] W) : ⇑(f + g) = f + g := rfl theorem add_apply (f g : P →ᴬ[R] W) (x : P) : (f + g) x = f x + g x := rfl instance : Sub (P →ᴬ[R] W) where sub f g := { (f : P →ᵃ[R] W) - (g : P →ᵃ[R] W) with cont := f.continuous.sub g.continuous } @[norm_cast, simp] theorem coe_sub (f g : P →ᴬ[R] W) : ⇑(f - g) = f - g := rfl theorem sub_apply (f g : P →ᴬ[R] W) (x : P) : (f - g) x = f x - g x := rfl instance : Neg (P →ᴬ[R] W) := { neg := fun f => { -(f : P →ᵃ[R] W) with cont := f.continuous.neg } } @[norm_cast, simp] theorem coe_neg (f : P →ᴬ[R] W) : ⇑(-f) = -f := rfl theorem neg_apply (f : P →ᴬ[R] W) (x : P) : (-f) x = -f x := rfl instance : AddCommGroup (P →ᴬ[R] W) := coe_injective.addCommGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ ↦ coe_smul _ _) fun _ _ ↦ coe_smul _ _ instance [Monoid S] [DistribMulAction S W] [SMulCommClass R S W] [ContinuousConstSMul S W] : DistribMulAction S (P →ᴬ[R] W) := Function.Injective.distribMulAction ⟨⟨fun f ↦ f.toAffineMap.toFun, rfl⟩, coe_add⟩ coe_injective coe_smul instance [Semiring S] [Module S W] [SMulCommClass R S W] [ContinuousConstSMul S W] : Module S (P →ᴬ[R] W) := Function.Injective.module S ⟨⟨fun f ↦ f.toAffineMap.toFun, rfl⟩, coe_add⟩ coe_injective coe_smul variable [TopologicalSpace V] [IsTopologicalAddTorsor P] @[simp] theorem zero_contLinear : (0 : P →ᴬ[R] W).contLinear = 0 := rfl @[simp] theorem add_contLinear (f g : P →ᴬ[R] W) : (f + g).contLinear = f.contLinear + g.contLinear := rfl @[simp] theorem sub_contLinear (f g : P →ᴬ[R] W) : (f - g).contLinear = f.contLinear - g.contLinear := rfl @[simp] theorem neg_contLinear (f : P →ᴬ[R] W) : (-f).contLinear = -f.contLinear := rfl end ModuleValuedMaps section variable [TopologicalSpace W] [IsTopologicalAddGroup W] [IsTopologicalAddTorsor Q] /-- The space of continuous affine maps from `P` to `Q` is an affine space over the space of continuous affine maps from `P` to `W`. -/ instance : AddTorsor (P →ᴬ[R] W) (P →ᴬ[R] Q) where vadd f g := { __ := f.toAffineMap +ᵥ g.toAffineMap, cont := f.cont.vadd g.cont } zero_vadd _ := ext fun _ ↦ zero_vadd _ _ add_vadd _ _ _ := ext fun _ ↦ add_vadd _ _ _ vsub f g := { __ := f.toAffineMap -ᵥ g.toAffineMap, cont := f.cont.vsub g.cont } vsub_vadd' _ _ := ext fun _ ↦ vsub_vadd _ _ vadd_vsub' _ _ := ext fun _ ↦ vadd_vsub _ _ @[simp] lemma vadd_apply (f : P →ᴬ[R] W) (g : P →ᴬ[R] Q) (p : P) : (f +ᵥ g) p = f p +ᵥ g p := rfl @[simp] lemma vsub_apply (f g : P →ᴬ[R] Q) (p : P) : (f -ᵥ g) p = f p -ᵥ g p := rfl @[simp] lemma vadd_toAffineMap (f : P →ᴬ[R] W) (g : P →ᴬ[R] Q) : (f +ᵥ g).toAffineMap = f.toAffineMap +ᵥ g.toAffineMap := rfl @[simp] lemma vsub_toAffineMap (f g : P →ᴬ[R] Q) : (f -ᵥ g).toAffineMap = f.toAffineMap -ᵥ g.toAffineMap := rfl variable [TopologicalSpace V] [IsTopologicalAddTorsor P] @[simp] lemma vadd_contLinear (f : P →ᴬ[R] W) (g : P →ᴬ[R] Q) : (f +ᵥ g).contLinear = f.contLinear + g.contLinear := rfl @[simp] lemma vsub_contLinear (f g : P →ᴬ[R] Q) : (f -ᵥ g).contLinear = f.contLinear - g.contLinear := rfl end section Prod variable {k P₁ P₂ P₃ P₄ V₁ V₂ V₃ V₄ : Type*} [Ring k] [AddCommGroup V₁] [Module k V₁] [AddTorsor V₁ P₁] [TopologicalSpace P₁] [AddCommGroup V₂] [Module k V₂] [AddTorsor V₂ P₂] [TopologicalSpace P₂] [AddCommGroup V₃] [Module k V₃] [AddTorsor V₃ P₃] [TopologicalSpace P₃] [AddCommGroup V₄] [Module k V₄] [AddTorsor V₄ P₄] [TopologicalSpace P₄] /-- The product of two continuous affine maps is a continuous affine map. -/ @[simps toAffineMap] def prod (f : P₁ →ᴬ[k] P₂) (g : P₁ →ᴬ[k] P₃) : P₁ →ᴬ[k] P₂ × P₃ where __ := AffineMap.prod f g cont := by eta_expand; dsimp; fun_prop theorem coe_prod (f : P₁ →ᴬ[k] P₂) (g : P₁ →ᴬ[k] P₃) : prod f g = Pi.prod f g := rfl @[simp] theorem prod_apply (f : P₁ →ᴬ[k] P₂) (g : P₁ →ᴬ[k] P₃) (p : P₁) : prod f g p = (f p, g p) := rfl /-- `Prod.map` of two continuous affine maps. -/ @[simps toAffineMap] def prodMap (f : P₁ →ᴬ[k] P₂) (g : P₃ →ᴬ[k] P₄) : P₁ × P₃ →ᴬ[k] P₂ × P₄ where __ := AffineMap.prodMap f g cont := by eta_expand; dsimp; fun_prop theorem coe_prodMap (f : P₁ →ᴬ[k] P₂) (g : P₃ →ᴬ[k] P₄) : ⇑(f.prodMap g) = Prod.map f g := rfl @[simp] theorem prodMap_apply (f : P₁ →ᴬ[k] P₂) (g : P₃ →ᴬ[k] P₄) (x) : f.prodMap g x = (f x.1, g x.2) := rfl variable [TopologicalSpace V₁] [IsTopologicalAddTorsor P₁] [TopologicalSpace V₂] [IsTopologicalAddTorsor P₂] [TopologicalSpace V₃] [IsTopologicalAddTorsor P₃] [TopologicalSpace V₄] [IsTopologicalAddTorsor P₄] @[simp] theorem prod_contLinear (f : P₁ →ᴬ[k] P₂) (g : P₁ →ᴬ[k] P₃) : (f.prod g).contLinear = f.contLinear.prod g.contLinear := rfl @[simp] theorem prodMap_contLinear (f : P₁ →ᴬ[k] P₂) (g : P₃ →ᴬ[k] P₄) : (f.prodMap g).contLinear = f.contLinear.prodMap g.contLinear := rfl end Prod end ContinuousAffineMap namespace ContinuousLinearMap variable {R V W : Type*} [Ring R] variable [AddCommGroup V] [Module R V] [TopologicalSpace V] variable [AddCommGroup W] [Module R W] [TopologicalSpace W] /-- A continuous linear map can be regarded as a continuous affine map. -/ def toContinuousAffineMap (f : V →L[R] W) : V →ᴬ[R] W where toFun := f linear := f map_vadd' := by simp cont := f.cont @[simp] theorem coe_toContinuousAffineMap (f : V →L[R] W) : ⇑f.toContinuousAffineMap = f := rfl @[simp] theorem toContinuousAffineMap_map_zero (f : V →L[R] W) : f.toContinuousAffineMap 0 = 0 := by simp variable [IsTopologicalAddGroup V] [IsTopologicalAddGroup W] @[simp] theorem toContinuousAffineMap_contLinear (f : V →L[R] W) : f.toContinuousAffineMap.contLinear = f := rfl @[deprecated (since := "2025-09-23")] alias _root_.ContinuousAffineMap.to_affine_map_contLinear := toContinuousAffineMap_contLinear theorem _root_.ContinuousAffineMap.decomp (f : V →ᴬ[R] W) : (f : V → W) = f.contLinear + Function.const V (f 0) := by rcases f with ⟨f, h⟩ rw [ContinuousAffineMap.coe_mk_contLinear_eq_linear, ContinuousAffineMap.coe_mk, f.decomp, Pi.add_apply, LinearMap.map_zero, zero_add, ← Function.const_def] end ContinuousLinearMap