path
stringlengths
11
71
content
stringlengths
75
124k
Topology\Category\LightProfinite\Sequence.lean
/- Copyright (c) 2024 Dagur Asgeirsson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Dagur Asgeirsson -/ import Mathlib.Topology.Compactification.OnePoint import Mathlib.Topology.Category.LightProfinite.Basic /-! # The light profinite set classifying convergent sequences This files defines the light profinite set `ℕ∪{∞}`, defined as the one point compactification of `ℕ`. -/ open CategoryTheory TopologicalSpace OnePoint namespace LightProfinite /-- The continuous map from `ℕ∪{∞}` to `ℝ` sending `n` to `1/(n+1)` and `∞` to `0`. -/ noncomputable def natUnionInftyEmbedding : C(OnePoint ℕ, ℝ) where toFun | ∞ => 0 | OnePoint.some n => 1 / (n+1 : ℝ) continuous_toFun := OnePoint.continuous_iff_from_nat _ |>.mpr tendsto_one_div_add_atTop_nhds_zero_nat /-- The continuous map from `ℕ∪{∞}` to `ℝ` sending `n` to `1/(n+1)` and `∞` to `0` is a closed embedding. -/ lemma closedEmbedding_natUnionInftyEmbedding : ClosedEmbedding natUnionInftyEmbedding := by refine closedEmbedding_of_continuous_injective_closed natUnionInftyEmbedding.continuous ?_ ?_ · rintro (_|n) (_|m) h · rfl · simp only [natUnionInftyEmbedding, one_div, ContinuousMap.coe_mk, zero_eq_inv] at h rw [← Nat.cast_one, ← Nat.cast_add, eq_comm, Nat.cast_eq_zero] at h simp at h · simp only [natUnionInftyEmbedding, one_div, ContinuousMap.coe_mk, inv_eq_zero] at h rw [← Nat.cast_one, ← Nat.cast_add, Nat.cast_eq_zero] at h simp at h · simp only [natUnionInftyEmbedding, one_div, ContinuousMap.coe_mk, inv_inj, add_left_inj, Nat.cast_inj] at h rw [h] · exact fun _ hC => (hC.isCompact.image natUnionInftyEmbedding.continuous).isClosed instance : MetrizableSpace (OnePoint ℕ) := closedEmbedding_natUnionInftyEmbedding.metrizableSpace /-- The one point compactification of the natural numbers as a light profinite set. -/ abbrev NatUnionInfty : LightProfinite := of (OnePoint ℕ) @[inherit_doc] scoped notation "ℕ∪{∞}" => NatUnionInfty instance : Coe ℕ ℕ∪{∞} := optionCoe open Filter Topology lemma continuous_iff_convergent {Y : Type*} [TopologicalSpace Y] (f : ℕ∪{∞} → Y) : Continuous f ↔ Tendsto (fun x : ℕ ↦ f x) atTop (𝓝 (f ∞)) := continuous_iff_from_nat f end LightProfinite
Topology\Category\Profinite\AsLimit.lean
/- Copyright (c) 2021 Adam Topaz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Calle Sönne, Adam Topaz -/ import Mathlib.Topology.Category.Profinite.Basic import Mathlib.Topology.DiscreteQuotient /-! # Profinite sets as limits of finite sets. We show that any profinite set is isomorphic to the limit of its discrete (hence finite) quotients. ## Definitions There are a handful of definitions in this file, given `X : Profinite`: 1. `X.fintypeDiagram` is the functor `DiscreteQuotient X ⥤ FintypeCat` whose limit is isomorphic to `X` (the limit taking place in `Profinite` via `FintypeCat.toProfinite`, see 2). 2. `X.diagram` is an abbreviation for `X.fintypeDiagram ⋙ FintypeCat.toProfinite`. 3. `X.asLimitCone` is the cone over `X.diagram` whose cone point is `X`. 4. `X.isoAsLimitConeLift` is the isomorphism `X ≅ (Profinite.limitCone X.diagram).X` induced by lifting `X.asLimitCone`. 5. `X.asLimitConeIso` is the isomorphism `X.asLimitCone ≅ (Profinite.limitCone X.diagram)` induced by `X.isoAsLimitConeLift`. 6. `X.asLimit` is a term of type `IsLimit X.asLimitCone`. 7. `X.lim : CategoryTheory.Limits.LimitCone X.asLimitCone` is a bundled combination of 3 and 6. -/ noncomputable section open CategoryTheory namespace Profinite universe u variable (X : Profinite.{u}) /-- The functor `DiscreteQuotient X ⥤ Fintype` whose limit is isomorphic to `X`. -/ def fintypeDiagram : DiscreteQuotient X ⥤ FintypeCat where obj S := @FintypeCat.of S (Fintype.ofFinite S) map f := DiscreteQuotient.ofLE f.le -- Porting note: `map_comp` used to be proved by default by `aesop_cat`. -- once `aesop_cat` can prove this again, remove the entire `map_comp` here. map_comp _ _ := by ext; aesop_cat /-- An abbreviation for `X.fintypeDiagram ⋙ FintypeCat.toProfinite`. -/ abbrev diagram : DiscreteQuotient X ⥤ Profinite := X.fintypeDiagram ⋙ FintypeCat.toProfinite /-- A cone over `X.diagram` whose cone point is `X`. -/ def asLimitCone : CategoryTheory.Limits.Cone X.diagram := { pt := X π := { app := fun S => ⟨S.proj, IsLocallyConstant.continuous (S.proj_isLocallyConstant)⟩ } } instance isIso_asLimitCone_lift : IsIso ((limitConeIsLimit.{u, u} X.diagram).lift X.asLimitCone) := CompHausLike.isIso_of_bijective _ (by refine ⟨fun a b h => ?_, fun a => ?_⟩ · refine DiscreteQuotient.eq_of_forall_proj_eq fun S => ?_ apply_fun fun f : (limitCone.{u, u} X.diagram).pt => f.val S at h exact h · obtain ⟨b, hb⟩ := DiscreteQuotient.exists_of_compat (fun S => a.val S) fun _ _ h => a.prop (homOfLE h) use b -- ext S : 3 -- Porting note: `ext` does not work, replaced with following three lines. apply Subtype.ext apply funext rintro S -- Porting note: end replacement block apply hb ) /-- The isomorphism between `X` and the explicit limit of `X.diagram`, induced by lifting `X.asLimitCone`. -/ def isoAsLimitConeLift : X ≅ (limitCone.{u, u} X.diagram).pt := asIso <| (limitConeIsLimit.{u, u} _).lift X.asLimitCone /-- The isomorphism of cones `X.asLimitCone` and `Profinite.limitCone X.diagram`. The underlying isomorphism is defeq to `X.isoAsLimitConeLift`. -/ def asLimitConeIso : X.asLimitCone ≅ limitCone.{u, u} _ := Limits.Cones.ext (isoAsLimitConeLift _) fun _ => rfl /-- `X.asLimitCone` is indeed a limit cone. -/ def asLimit : CategoryTheory.Limits.IsLimit X.asLimitCone := Limits.IsLimit.ofIsoLimit (limitConeIsLimit _) X.asLimitConeIso.symm /-- A bundled version of `X.asLimitCone` and `X.asLimit`. -/ def lim : Limits.LimitCone X.diagram := ⟨X.asLimitCone, X.asLimit⟩ end Profinite
Topology\Category\Profinite\Basic.lean
/- Copyright (c) 2020 Kevin Buzzard. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kevin Buzzard, Calle Sönne -/ import Mathlib.CategoryTheory.FintypeCat import Mathlib.Topology.Category.CompHaus.Basic import Mathlib.Topology.LocallyConstant.Basic /-! # The category of Profinite Types We construct the category of profinite topological spaces, often called profinite sets -- perhaps they could be called profinite types in Lean. The type of profinite topological spaces is called `Profinite`. It has a category instance and is a fully faithful subcategory of `TopCat`. The fully faithful functor is called `Profinite.toTop`. ## Implementation notes A profinite type is defined to be a topological space which is compact, Hausdorff and totally disconnected. ## TODO * Define procategories and prove that `Profinite` is equivalent to `Pro (FintypeCat)`. ## Tags profinite -/ -- This was a global instance prior to #13170. We may experiment with removing it. attribute [local instance] CategoryTheory.ConcreteCategory.instFunLike universe v u open CategoryTheory Topology CompHausLike /-- The type of profinite topological spaces. -/ abbrev Profinite := CompHausLike (fun X ↦ TotallyDisconnectedSpace X) namespace Profinite instance (X : Type*) [TopologicalSpace X] [TotallyDisconnectedSpace X] : HasProp (fun Y ↦ TotallyDisconnectedSpace Y) X := ⟨(inferInstance : TotallyDisconnectedSpace X)⟩ /-- Construct a term of `Profinite` from a type endowed with the structure of a compact, Hausdorff and totally disconnected topological space. -/ abbrev of (X : Type*) [TopologicalSpace X] [CompactSpace X] [T2Space X] [TotallyDisconnectedSpace X] : Profinite := CompHausLike.of _ X instance : Inhabited Profinite := ⟨Profinite.of PEmpty⟩ instance {X : Profinite} : TotallyDisconnectedSpace X := X.prop instance {X : Profinite} : TotallyDisconnectedSpace ((forget Profinite).obj X) := by change TotallyDisconnectedSpace X exact inferInstance end Profinite /-- The fully faithful embedding of `Profinite` in `CompHaus`. -/ abbrev profiniteToCompHaus : Profinite ⥤ CompHaus := compHausLikeToCompHaus _ -- Porting note: deriving fails, adding manually. -- deriving Full, Faithful -- Porting note: added, as it is not found otherwise. instance {X : Profinite} : TotallyDisconnectedSpace (profiniteToCompHaus.obj X) := X.prop /-- The fully faithful embedding of `Profinite` in `TopCat`. This is definitionally the same as the obvious composite. -/ abbrev Profinite.toTopCat : Profinite ⥤ TopCat := CompHausLike.compHausLikeToTop _ -- Porting note: deriving fails, adding manually. -- deriving Full, Faithful section Profinite -- Without explicit universe annotations here, Lean introduces two universe variables and -- unhelpfully defines a function `CompHaus.{max u₁ u₂} → Profinite.{max u₁ u₂}`. /-- (Implementation) The object part of the connected_components functor from compact Hausdorff spaces to Profinite spaces, given by quotienting a space by its connected components. See: https://stacks.math.columbia.edu/tag/0900 -/ def CompHaus.toProfiniteObj (X : CompHaus.{u}) : Profinite.{u} where toTop := TopCat.of (ConnectedComponents X) is_compact := Quotient.compactSpace is_hausdorff := ConnectedComponents.t2 prop := ConnectedComponents.totallyDisconnectedSpace /-- (Implementation) The bijection of homsets to establish the reflective adjunction of Profinite spaces in compact Hausdorff spaces. -/ def Profinite.toCompHausEquivalence (X : CompHaus.{u}) (Y : Profinite.{u}) : (CompHaus.toProfiniteObj X ⟶ Y) ≃ (X ⟶ profiniteToCompHaus.obj Y) where toFun f := f.comp ⟨Quotient.mk'', continuous_quotient_mk'⟩ invFun g := { toFun := Continuous.connectedComponentsLift g.2 continuous_toFun := Continuous.connectedComponentsLift_continuous g.2 } left_inv _ := ContinuousMap.ext <| ConnectedComponents.surjective_coe.forall.2 fun _ => rfl right_inv _ := ContinuousMap.ext fun _ => rfl /-- The connected_components functor from compact Hausdorff spaces to profinite spaces, left adjoint to the inclusion functor. -/ def CompHaus.toProfinite : CompHaus ⥤ Profinite := Adjunction.leftAdjointOfEquiv Profinite.toCompHausEquivalence fun _ _ _ _ _ => rfl theorem CompHaus.toProfinite_obj' (X : CompHaus) : ↥(CompHaus.toProfinite.obj X) = ConnectedComponents X := rfl /-- Finite types are given the discrete topology. -/ def FintypeCat.botTopology (A : FintypeCat) : TopologicalSpace A := ⊥ section DiscreteTopology attribute [local instance] FintypeCat.botTopology theorem FintypeCat.discreteTopology (A : FintypeCat) : DiscreteTopology A := ⟨rfl⟩ attribute [local instance] FintypeCat.discreteTopology /-- The natural functor from `Fintype` to `Profinite`, endowing a finite type with the discrete topology. -/ @[simps] def FintypeCat.toProfinite : FintypeCat ⥤ Profinite where obj A := Profinite.of A map f := ⟨f, by continuity⟩ attribute [nolint simpNF] FintypeCat.toProfinite_map_apply /-- `FintypeCat.toLightProfinite` is fully faithful. -/ def FintypeCat.toProfiniteFullyFaithful : toProfinite.FullyFaithful where preimage f := (f : _ → _) map_preimage _ := rfl preimage_map _ := rfl instance : FintypeCat.toProfinite.Faithful := FintypeCat.toProfiniteFullyFaithful.faithful instance : FintypeCat.toProfinite.Full := FintypeCat.toProfiniteFullyFaithful.full end DiscreteTopology end Profinite namespace Profinite /-- An explicit limit cone for a functor `F : J ⥤ Profinite`, defined in terms of `CompHaus.limitCone`, which is defined in terms of `TopCat.limitCone`. -/ def limitCone {J : Type v} [SmallCategory J] (F : J ⥤ Profinite.{max u v}) : Limits.Cone F where pt := { toTop := (CompHaus.limitCone.{v, u} (F ⋙ profiniteToCompHaus)).pt.toTop prop := by change TotallyDisconnectedSpace ({ u : ∀ j : J, F.obj j | _ } : Type _) exact Subtype.totallyDisconnectedSpace } π := { app := (CompHaus.limitCone.{v, u} (F ⋙ profiniteToCompHaus)).π.app -- Porting note: was `by tidy`: naturality := by intro j k f ext ⟨g, p⟩ exact (p f).symm } /-- The limit cone `Profinite.limitCone F` is indeed a limit cone. -/ def limitConeIsLimit {J : Type v} [SmallCategory J] (F : J ⥤ Profinite.{max u v}) : Limits.IsLimit (limitCone F) where lift S := (CompHaus.limitConeIsLimit.{v, u} (F ⋙ profiniteToCompHaus)).lift (profiniteToCompHaus.mapCone S) uniq S m h := (CompHaus.limitConeIsLimit.{v, u} _).uniq (profiniteToCompHaus.mapCone S) _ h /-- The adjunction between CompHaus.to_Profinite and Profinite.to_CompHaus -/ def toProfiniteAdjToCompHaus : CompHaus.toProfinite ⊣ profiniteToCompHaus := Adjunction.adjunctionOfEquivLeft _ _ /-- The category of profinite sets is reflective in the category of compact Hausdorff spaces -/ instance toCompHaus.reflective : Reflective profiniteToCompHaus where adj := Profinite.toProfiniteAdjToCompHaus noncomputable instance toCompHaus.createsLimits : CreatesLimits profiniteToCompHaus := monadicCreatesLimits _ noncomputable instance toTopCat.reflective : Reflective Profinite.toTopCat := Reflective.comp profiniteToCompHaus compHausToTop noncomputable instance toTopCat.createsLimits : CreatesLimits Profinite.toTopCat := monadicCreatesLimits _ instance hasLimits : Limits.HasLimits Profinite := hasLimits_of_hasLimits_createsLimits Profinite.toTopCat instance hasColimits : Limits.HasColimits Profinite := hasColimits_of_reflective profiniteToCompHaus noncomputable instance forgetPreservesLimits : Limits.PreservesLimits (forget Profinite) := by apply Limits.compPreservesLimits Profinite.toTopCat (forget TopCat) theorem epi_iff_surjective {X Y : Profinite.{u}} (f : X ⟶ Y) : Epi f ↔ Function.Surjective f := by constructor · -- Porting note: in mathlib3 `contrapose` saw through `Function.Surjective`. dsimp [Function.Surjective] contrapose! rintro ⟨y, hy⟩ hf let C := Set.range f have hC : IsClosed C := (isCompact_range f.continuous).isClosed let U := Cᶜ have hyU : y ∈ U := by refine Set.mem_compl ?_ rintro ⟨y', hy'⟩ exact hy y' hy' have hUy : U ∈ 𝓝 y := hC.compl_mem_nhds hyU obtain ⟨V, hV, hyV, hVU⟩ := isTopologicalBasis_isClopen.mem_nhds_iff.mp hUy classical let Z := of (ULift.{u} <| Fin 2) let g : Y ⟶ Z := ⟨(LocallyConstant.ofIsClopen hV).map ULift.up, LocallyConstant.continuous _⟩ let h : Y ⟶ Z := ⟨fun _ => ⟨1⟩, continuous_const⟩ have H : h = g := by rw [← cancel_epi f] ext x apply ULift.ext dsimp [g, LocallyConstant.ofIsClopen] -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [comp_apply, ContinuousMap.coe_mk, comp_apply, ContinuousMap.coe_mk, Function.comp_apply, if_neg] refine mt (fun α => hVU α) ?_ simp only [U, C, Set.mem_range_self, not_true, not_false_iff, Set.mem_compl_iff] apply_fun fun e => (e y).down at H dsimp [g, LocallyConstant.ofIsClopen] at H -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [ContinuousMap.coe_mk, ContinuousMap.coe_mk, Function.comp_apply, if_pos hyV] at H exact top_ne_bot H · rw [← CategoryTheory.epi_iff_surjective] apply (forget Profinite).epi_of_epi_map end Profinite
Topology\Category\Profinite\CofilteredLimit.lean
/- Copyright (c) 2021 Adam Topaz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Adam Topaz -/ import Mathlib.Topology.Category.Profinite.Basic import Mathlib.Topology.LocallyConstant.Basic import Mathlib.Topology.DiscreteQuotient import Mathlib.Topology.Category.TopCat.Limits.Cofiltered import Mathlib.Topology.Category.TopCat.Limits.Konig /-! # Cofiltered limits of profinite sets. This file contains some theorems about cofiltered limits of profinite sets. ## Main Results - `exists_isClopen_of_cofiltered` shows that any clopen set in a cofiltered limit of profinite sets is the pullback of a clopen set from one of the factors in the limit. - `exists_locally_constant` shows that any locally constant function from a cofiltered limit of profinite sets factors through one of the components. -/ namespace Profinite open scoped Classical open CategoryTheory open CategoryTheory.Limits -- This was a global instance prior to #13170. We may experiment with removing it. attribute [local instance] ConcreteCategory.instFunLike universe u v variable {J : Type v} [SmallCategory J] [IsCofiltered J] {F : J ⥤ Profinite.{max u v}} (C : Cone F) /-- If `X` is a cofiltered limit of profinite sets, then any clopen subset of `X` arises from a clopen set in one of the terms in the limit. -/ theorem exists_isClopen_of_cofiltered {U : Set C.pt} (hC : IsLimit C) (hU : IsClopen U) : ∃ (j : J) (V : Set (F.obj j)), IsClopen V ∧ U = C.π.app j ⁻¹' V := by -- First, we have the topological basis of the cofiltered limit obtained by pulling back -- clopen sets from the factors in the limit. By continuity, all such sets are again clopen. have hB := TopCat.isTopologicalBasis_cofiltered_limit.{u, v} (F ⋙ Profinite.toTopCat) (Profinite.toTopCat.mapCone C) (isLimitOfPreserves _ hC) (fun j => {W | IsClopen W}) ?_ (fun i => isClopen_univ) (fun i U1 U2 hU1 hU2 => hU1.inter hU2) ?_ rotate_left · intro i change TopologicalSpace.IsTopologicalBasis {W : Set (F.obj i) | IsClopen W} apply isTopologicalBasis_isClopen · rintro i j f V (hV : IsClopen _) exact ⟨hV.1.preimage ((F ⋙ toTopCat).map f).continuous, hV.2.preimage ((F ⋙ toTopCat).map f).continuous⟩ -- Porting note: `<;> continuity` fails -- Using this, since `U` is open, we can write `U` as a union of clopen sets all of which -- are preimages of clopens from the factors in the limit. obtain ⟨S, hS, h⟩ := hB.open_eq_sUnion hU.2 clear hB let j : S → J := fun s => (hS s.2).choose let V : ∀ s : S, Set (F.obj (j s)) := fun s => (hS s.2).choose_spec.choose have hV : ∀ s : S, IsClopen (V s) ∧ s.1 = C.π.app (j s) ⁻¹' V s := fun s => (hS s.2).choose_spec.choose_spec -- Since `U` is also closed, hence compact, it is covered by finitely many of the -- clopens constructed in the previous step. have hUo : ∀ (i : ↑S), IsOpen ((fun s ↦ (forget Profinite).map (C.π.app (j s)) ⁻¹' V s) i) := by intro s exact (hV s).1.2.preimage (C.π.app (j s)).continuous have hsU : U ⊆ ⋃ (i : ↑S), (fun s ↦ (forget Profinite).map (C.π.app (j s)) ⁻¹' V s) i := by dsimp only rw [h] rintro x ⟨T, hT, hx⟩ refine ⟨_, ⟨⟨T, hT⟩, rfl⟩, ?_⟩ dsimp only [forget_map_eq_coe] rwa [← (hV ⟨T, hT⟩).2] have := hU.1.isCompact.elim_finite_subcover (fun s : S => C.π.app (j s) ⁻¹' V s) hUo hsU -- Porting note: same remark as after `hB` -- We thus obtain a finite set `G : Finset J` and a clopen set of `F.obj j` for each -- `j ∈ G` such that `U` is the union of the preimages of these clopen sets. obtain ⟨G, hG⟩ := this -- Since `J` is cofiltered, we can find a single `j0` dominating all the `j ∈ G`. -- Pulling back all of the sets from the previous step to `F.obj j0` and taking a union, -- we obtain a clopen set in `F.obj j0` which works. obtain ⟨j0, hj0⟩ := IsCofiltered.inf_objs_exists (G.image j) let f : ∀ s ∈ G, j0 ⟶ j s := fun s hs => (hj0 (Finset.mem_image.mpr ⟨s, hs, rfl⟩)).some let W : S → Set (F.obj j0) := fun s => if hs : s ∈ G then F.map (f s hs) ⁻¹' V s else Set.univ -- Conclude, using the `j0` and the clopen set of `F.obj j0` obtained above. refine ⟨j0, ⋃ (s : S) (_ : s ∈ G), W s, ?_, ?_⟩ · apply isClopen_biUnion_finset intro s hs dsimp [W] rw [dif_pos hs] exact ⟨(hV s).1.1.preimage (F.map _).continuous, (hV s).1.2.preimage (F.map _).continuous⟩ · ext x constructor · intro hx simp_rw [W, Set.preimage_iUnion, Set.mem_iUnion] obtain ⟨_, ⟨s, rfl⟩, _, ⟨hs, rfl⟩, hh⟩ := hG hx refine ⟨s, hs, ?_⟩ rwa [dif_pos hs, ← Set.preimage_comp, ← CompHausLike.coe_comp, ← Functor.map_comp, C.w] · intro hx simp_rw [W, Set.preimage_iUnion, Set.mem_iUnion] at hx obtain ⟨s, hs, hx⟩ := hx rw [h] refine ⟨s.1, s.2, ?_⟩ rw [(hV s).2] rwa [dif_pos hs, ← Set.preimage_comp, ← CompHausLike.coe_comp, ← Functor.map_comp, C.w] at hx theorem exists_locallyConstant_fin_two (hC : IsLimit C) (f : LocallyConstant C.pt (Fin 2)) : ∃ (j : J) (g : LocallyConstant (F.obj j) (Fin 2)), f = g.comap (C.π.app _) := by let U := f ⁻¹' {0} have hU : IsClopen U := f.isLocallyConstant.isClopen_fiber _ obtain ⟨j, V, hV, h⟩ := exists_isClopen_of_cofiltered C hC hU use j, LocallyConstant.ofIsClopen hV apply LocallyConstant.locallyConstant_eq_of_fiber_zero_eq simp only [Fin.isValue, Functor.const_obj_obj, LocallyConstant.coe_comap, Set.preimage_comp, LocallyConstant.ofIsClopen_fiber_zero] -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [← h] theorem exists_locallyConstant_finite_aux {α : Type*} [Finite α] (hC : IsLimit C) (f : LocallyConstant C.pt α) : ∃ (j : J) (g : LocallyConstant (F.obj j) (α → Fin 2)), (f.map fun a b => if a = b then (0 : Fin 2) else 1) = g.comap (C.π.app _) := by cases nonempty_fintype α let ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1 let ff := (f.map ι).flip have hff := fun a : α => exists_locallyConstant_fin_two _ hC (ff a) choose j g h using hff let G : Finset J := Finset.univ.image j obtain ⟨j0, hj0⟩ := IsCofiltered.inf_objs_exists G have hj : ∀ a, j a ∈ (Finset.univ.image j : Finset J) := by intro a simp only [Finset.mem_image, Finset.mem_univ, true_and, exists_apply_eq_apply] let fs : ∀ a : α, j0 ⟶ j a := fun a => (hj0 (hj a)).some let gg : α → LocallyConstant (F.obj j0) (Fin 2) := fun a => (g a).comap (F.map (fs _)) let ggg := LocallyConstant.unflip gg refine ⟨j0, ggg, ?_⟩ have : f.map ι = LocallyConstant.unflip (f.map ι).flip := by simp rw [this]; clear this have : LocallyConstant.comap (C.π.app j0) ggg = LocallyConstant.unflip (LocallyConstant.comap (C.π.app j0) ggg).flip := by simp rw [this]; clear this congr 1 ext1 a change ff a = _ rw [h] dsimp ext1 x change _ = (g a) ((C.π.app j0 ≫ F.map (fs a)) x) rw [C.w]; rfl theorem exists_locallyConstant_finite_nonempty {α : Type*} [Finite α] [Nonempty α] (hC : IsLimit C) (f : LocallyConstant C.pt α) : ∃ (j : J) (g : LocallyConstant (F.obj j) α), f = g.comap (C.π.app _) := by inhabit α obtain ⟨j, gg, h⟩ := exists_locallyConstant_finite_aux _ hC f let ι : α → α → Fin 2 := fun a b => if a = b then 0 else 1 let σ : (α → Fin 2) → α := fun f => if h : ∃ a : α, ι a = f then h.choose else default refine ⟨j, gg.map σ, ?_⟩ ext x simp only [Functor.const_obj_obj, LocallyConstant.coe_comap, LocallyConstant.map_apply, Function.comp_apply] dsimp [σ] have h1 : ι (f x) = gg (C.π.app j x) := by change f.map (fun a b => if a = b then (0 : Fin 2) else 1) x = _ -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [h] rfl have h2 : ∃ a : α, ι a = gg (C.π.app j x) := ⟨f x, h1⟩ -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [dif_pos h2] apply_fun ι · rw [h2.choose_spec] exact h1 · intro a b hh have hhh := congr_fun hh a dsimp [ι] at hhh rw [if_pos rfl] at hhh split_ifs at hhh with hh1 · exact hh1.symm · exact False.elim (bot_ne_top hhh) /-- Any locally constant function from a cofiltered limit of profinite sets factors through one of the components. -/ theorem exists_locallyConstant {α : Type*} (hC : IsLimit C) (f : LocallyConstant C.pt α) : ∃ (j : J) (g : LocallyConstant (F.obj j) α), f = g.comap (C.π.app _) := by let S := f.discreteQuotient let ff : S → α := f.lift cases isEmpty_or_nonempty S · suffices ∃ j, IsEmpty (F.obj j) by refine this.imp fun j hj => ?_ refine ⟨⟨hj.elim, fun A => ?_⟩, ?_⟩ · suffices (fun a ↦ IsEmpty.elim hj a) ⁻¹' A = ∅ by rw [this] exact isOpen_empty exact @Set.eq_empty_of_isEmpty _ hj _ · ext x exact hj.elim' (C.π.app j x) simp only [← not_nonempty_iff, ← not_forall] intro h haveI : ∀ j : J, Nonempty ((F ⋙ Profinite.toTopCat).obj j) := h haveI : ∀ j : J, T2Space ((F ⋙ Profinite.toTopCat).obj j) := fun j => (inferInstance : T2Space (F.obj j)) haveI : ∀ j : J, CompactSpace ((F ⋙ Profinite.toTopCat).obj j) := fun j => (inferInstance : CompactSpace (F.obj j)) have cond := TopCat.nonempty_limitCone_of_compact_t2_cofiltered_system.{u} (F ⋙ Profinite.toTopCat) suffices Nonempty C.pt from IsEmpty.false (S.proj this.some) let D := Profinite.toTopCat.mapCone C have hD : IsLimit D := isLimitOfPreserves Profinite.toTopCat hC have CD := (hD.conePointUniqueUpToIso (TopCat.limitConeIsLimit.{v, max u v} _)).inv exact cond.map CD · let f' : LocallyConstant C.pt S := ⟨S.proj, S.proj_isLocallyConstant⟩ obtain ⟨j, g', hj⟩ := exists_locallyConstant_finite_nonempty _ hC f' refine ⟨j, ⟨ff ∘ g', g'.isLocallyConstant.comp _⟩, ?_⟩ ext1 t apply_fun fun e => e t at hj dsimp at hj ⊢ rw [← hj] rfl end Profinite
Topology\Category\Profinite\EffectiveEpi.lean
/- Copyright (c) 2023 Jon Eugster. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Dagur Asgeirsson, Boris Bolvig Kjær, Jon Eugster, Sina Hazratpour -/ import Mathlib.CategoryTheory.Sites.Coherent.ReflectsPreregular import Mathlib.Topology.Category.CompHaus.EffectiveEpi import Mathlib.Topology.Category.Profinite.Limits import Mathlib.Topology.Category.Stonean.Basic /-! # Effective epimorphisms in `Profinite` This file proves that `EffectiveEpi`, `Epi` and `Surjective` are all equivalent in `Profinite`. As a consequence we deduce from the material in `Mathlib.Topology.Category.CompHausLike.EffectiveEpi` that `Profinite` is `Preregular` and `Precoherent`. We also prove that for a finite family of morphisms in `Profinite` with fixed target, the conditions jointly surjective, jointly epimorphic and effective epimorphic are all equivalent. -/ universe u open CategoryTheory Limits attribute [local instance] ConcreteCategory.instFunLike namespace Profinite open List in theorem effectiveEpi_tfae {B X : Profinite.{u}} (π : X ⟶ B) : TFAE [ EffectiveEpi π , Epi π , Function.Surjective π ] := by tfae_have 1 → 2 · intro; infer_instance tfae_have 2 ↔ 3 · exact epi_iff_surjective π tfae_have 3 → 1 · exact fun hπ ↦ ⟨⟨CompHausLike.effectiveEpiStruct π hπ⟩⟩ tfae_finish instance : profiniteToCompHaus.PreservesEffectiveEpis where preserves f h := ((CompHaus.effectiveEpi_tfae _).out 0 2).mpr (((Profinite.effectiveEpi_tfae _).out 0 2).mp h) instance : profiniteToCompHaus.ReflectsEffectiveEpis where reflects f h := ((Profinite.effectiveEpi_tfae f).out 0 2).mpr (((CompHaus.effectiveEpi_tfae _).out 0 2).mp h) /-- An effective presentation of an `X : Profinite` with respect to the inclusion functor from `Stonean` -/ noncomputable def profiniteToCompHausEffectivePresentation (X : CompHaus) : profiniteToCompHaus.EffectivePresentation X where p := Stonean.toProfinite.obj X.presentation f := CompHaus.presentation.π X effectiveEpi := ((CompHaus.effectiveEpi_tfae _).out 0 1).mpr (inferInstance : Epi _) instance : profiniteToCompHaus.EffectivelyEnough where presentation X := ⟨profiniteToCompHausEffectivePresentation X⟩ instance : Preregular Profinite.{u} := profiniteToCompHaus.reflects_preregular example : Precoherent Profinite.{u} := inferInstance -- TODO: prove this for `Type*` open List in theorem effectiveEpiFamily_tfae {α : Type} [Finite α] {B : Profinite.{u}} (X : α → Profinite.{u}) (π : (a : α) → (X a ⟶ B)) : TFAE [ EffectiveEpiFamily X π , Epi (Sigma.desc π) , ∀ b : B, ∃ (a : α) (x : X a), π a x = b ] := by tfae_have 2 → 1 · intro simpa [← effectiveEpi_desc_iff_effectiveEpiFamily, (effectiveEpi_tfae (Sigma.desc π)).out 0 1] tfae_have 1 → 2 · intro; infer_instance tfae_have 3 ↔ 1 · erw [((CompHaus.effectiveEpiFamily_tfae (fun a ↦ profiniteToCompHaus.obj (X a)) (fun a ↦ profiniteToCompHaus.map (π a))).out 2 0 : )] exact ⟨fun h ↦ profiniteToCompHaus.finite_effectiveEpiFamily_of_map _ _ h, fun _ ↦ inferInstance⟩ tfae_finish theorem effectiveEpiFamily_of_jointly_surjective {α : Type} [Finite α] {B : Profinite.{u}} (X : α → Profinite.{u}) (π : (a : α) → (X a ⟶ B)) (surj : ∀ b : B, ∃ (a : α) (x : X a), π a x = b) : EffectiveEpiFamily X π := ((effectiveEpiFamily_tfae X π).out 2 0).mp surj end Profinite
Topology\Category\Profinite\Limits.lean
/- Copyright (c) 2023 Adam Topaz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Adam Topaz, Dagur Asgeirsson -/ import Mathlib.Topology.Category.Profinite.Basic import Mathlib.Topology.Category.CompHausLike.Limits /-! # Explicit limits and colimits This file applies the general API for explicit limits and colimits in `CompHausLike P` (see the file `Mathlib.Topology.Category.CompHausLike.Limits`) to the special case of `Profinite`. -/ namespace Profinite universe u w open CategoryTheory Limits CompHausLike instance : HasExplicitPullbacks (fun Y ↦ TotallyDisconnectedSpace Y) where hasProp _ _ := { hasProp := show TotallyDisconnectedSpace {_xy : _ | _} from inferInstance} instance : HasExplicitFiniteCoproducts.{w, u} (fun Y ↦ TotallyDisconnectedSpace Y) where hasProp _ := { hasProp := show TotallyDisconnectedSpace (Σ (_a : _), _) from inferInstance} /-- A one-element space is terminal in `Profinite` -/ abbrev isTerminalPUnit : IsTerminal (Profinite.of PUnit.{u + 1}) := CompHausLike.isTerminalPUnit example : FinitaryExtensive Profinite.{u} := inferInstance noncomputable example : PreservesFiniteCoproducts profiniteToCompHaus := inferInstance end Profinite
Topology\Category\Profinite\Nobeling.lean
/- Copyright (c) 2023 Dagur Asgeirsson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Dagur Asgeirsson -/ import Mathlib.Algebra.Category.ModuleCat.Free import Mathlib.Topology.Category.Profinite.CofilteredLimit import Mathlib.Topology.Category.Profinite.Product import Mathlib.Topology.LocallyConstant.Algebra import Mathlib.Data.Bool.Basic /-! # Nöbeling's theorem This file proves Nöbeling's theorem. ## Main result * `LocallyConstant.freeOfProfinite`: Nöbeling's theorem. For `S : Profinite`, the `ℤ`-module `LocallyConstant S ℤ` is free. ## Proof idea We follow the proof of theorem 5.4 in [scholze2019condensed], in which the idea is to embed `S` in a product of `I` copies of `Bool` for some sufficiently large `I`, and then to choose a well-ordering on `I` and use ordinal induction over that well-order. Here we can let `I` be the set of clopen subsets of `S` since `S` is totally separated. The above means it suffices to prove the following statement: For a closed subset `C` of `I → Bool`, the `ℤ`-module `LocallyConstant C ℤ` is free. For `i : I`, let `e C i : LocallyConstant C ℤ` denote the map `fun f ↦ (if f.val i then 1 else 0)`. The basis will consist of products `e C iᵣ * ⋯ * e C i₁` with `iᵣ > ⋯ > i₁` which cannot be written as linear combinations of lexicographically smaller products. We call this set `GoodProducts C` What is proved by ordinal induction is that this set is linearly independent. The fact that it spans can be proved directly. ## References - [scholze2019condensed], Theorem 5.4. -/ universe u namespace Profinite namespace NobelingProof variable {I : Type u} [LinearOrder I] [IsWellOrder I (·<·)] (C : Set (I → Bool)) open Profinite ContinuousMap CategoryTheory Limits Opposite Submodule section Projections /-! ## Projection maps The purpose of this section is twofold. Firstly, in the proof that the set `GoodProducts C` spans the whole module `LocallyConstant C ℤ`, we need to project `C` down to finite discrete subsets and write `C` as a cofiltered limit of those. Secondly, in the inductive argument, we need to project `C` down to "smaller" sets satisfying the inductive hypothesis. In this section we define the relevant projection maps and prove some compatibility results. ### Main definitions * Let `J : I → Prop`. Then `Proj J : (I → Bool) → (I → Bool)` is the projection mapping everything that satisfies `J i` to itself, and everything else to `false`. * The image of `C` under `Proj J` is denoted `π C J` and the corresponding map `C → π C J` is called `ProjRestrict`. If `J` implies `K` we have a map `ProjRestricts : π C K → π C J`. * `spanCone_isLimit` establishes that when `C` is compact, it can be written as a limit of its images under the maps `Proj (· ∈ s)` where `s : Finset I`. -/ variable (J K L : I → Prop) [∀ i, Decidable (J i)] [∀ i, Decidable (K i)] [∀ i, Decidable (L i)] /-- The projection mapping everything that satisfies `J i` to itself, and everything else to `false` -/ def Proj : (I → Bool) → (I → Bool) := fun c i ↦ if J i then c i else false @[simp] theorem continuous_proj : Continuous (Proj J : (I → Bool) → (I → Bool)) := by dsimp (config := { unfoldPartialApp := true }) [Proj] apply continuous_pi intro i split · apply continuous_apply · apply continuous_const /-- The image of `Proj π J` -/ def π : Set (I → Bool) := (Proj J) '' C /-- The restriction of `Proj π J` to a subset, mapping to its image. -/ @[simps!] def ProjRestrict : C → π C J := Set.MapsTo.restrict (Proj J) _ _ (Set.mapsTo_image _ _) @[simp] theorem continuous_projRestrict : Continuous (ProjRestrict C J) := Continuous.restrict _ (continuous_proj _) theorem proj_eq_self {x : I → Bool} (h : ∀ i, x i ≠ false → J i) : Proj J x = x := by ext i simp only [Proj, ite_eq_left_iff] contrapose! simpa only [ne_comm] using h i theorem proj_prop_eq_self (hh : ∀ i x, x ∈ C → x i ≠ false → J i) : π C J = C := by ext x refine ⟨fun ⟨y, hy, h⟩ ↦ ?_, fun h ↦ ⟨x, h, ?_⟩⟩ · rwa [← h, proj_eq_self]; exact (hh · y hy) · rw [proj_eq_self]; exact (hh · x h) theorem proj_comp_of_subset (h : ∀ i, J i → K i) : (Proj J ∘ Proj K) = (Proj J : (I → Bool) → (I → Bool)) := by ext x i; dsimp [Proj]; aesop theorem proj_eq_of_subset (h : ∀ i, J i → K i) : π (π C K) J = π C J := by ext x refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩ · obtain ⟨y, ⟨z, hz, rfl⟩, rfl⟩ := h refine ⟨z, hz, (?_ : _ = (Proj J ∘ Proj K) z)⟩ rw [proj_comp_of_subset J K h] · obtain ⟨y, hy, rfl⟩ := h dsimp [π] rw [← Set.image_comp] refine ⟨y, hy, ?_⟩ rw [proj_comp_of_subset J K h] variable {J K L} /-- A variant of `ProjRestrict` with domain of the form `π C K` -/ @[simps!] def ProjRestricts (h : ∀ i, J i → K i) : π C K → π C J := Homeomorph.setCongr (proj_eq_of_subset C J K h) ∘ ProjRestrict (π C K) J @[simp] theorem continuous_projRestricts (h : ∀ i, J i → K i) : Continuous (ProjRestricts C h) := Continuous.comp (Homeomorph.continuous _) (continuous_projRestrict _ _) theorem surjective_projRestricts (h : ∀ i, J i → K i) : Function.Surjective (ProjRestricts C h) := (Homeomorph.surjective _).comp (Set.surjective_mapsTo_image_restrict _ _) variable (J) in theorem projRestricts_eq_id : ProjRestricts C (fun i (h : J i) ↦ h) = id := by ext ⟨x, y, hy, rfl⟩ i simp (config := { contextual := true }) only [π, Proj, ProjRestricts_coe, id_eq, if_true] theorem projRestricts_eq_comp (hJK : ∀ i, J i → K i) (hKL : ∀ i, K i → L i) : ProjRestricts C hJK ∘ ProjRestricts C hKL = ProjRestricts C (fun i ↦ hKL i ∘ hJK i) := by ext x i simp only [π, Proj, Function.comp_apply, ProjRestricts_coe] aesop theorem projRestricts_comp_projRestrict (h : ∀ i, J i → K i) : ProjRestricts C h ∘ ProjRestrict C K = ProjRestrict C J := by ext x i simp only [π, Proj, Function.comp_apply, ProjRestricts_coe, ProjRestrict_coe] aesop variable (J) /-- The objectwise map in the isomorphism `spanFunctor ≅ Profinite.indexFunctor`. -/ def iso_map : C(π C J, (IndexFunctor.obj C J)) := ⟨fun x ↦ ⟨fun i ↦ x.val i.val, by rcases x with ⟨x, y, hy, rfl⟩ refine ⟨y, hy, ?_⟩ ext ⟨i, hi⟩ simp [precomp, Proj, hi]⟩, by refine Continuous.subtype_mk (continuous_pi fun i ↦ ?_) _ exact (continuous_apply i.val).comp continuous_subtype_val⟩ lemma iso_map_bijective : Function.Bijective (iso_map C J) := by refine ⟨fun a b h ↦ ?_, fun a ↦ ?_⟩ · ext i rw [Subtype.ext_iff] at h by_cases hi : J i · exact congr_fun h ⟨i, hi⟩ · rcases a with ⟨_, c, hc, rfl⟩ rcases b with ⟨_, d, hd, rfl⟩ simp only [Proj, if_neg hi] · refine ⟨⟨fun i ↦ if hi : J i then a.val ⟨i, hi⟩ else false, ?_⟩, ?_⟩ · rcases a with ⟨_, y, hy, rfl⟩ exact ⟨y, hy, rfl⟩ · ext i exact dif_pos i.prop variable {C} variable (hC : IsCompact C) /-- For a given compact subset `C` of `I → Bool`, `spanFunctor` is the functor from the poset of finsets of `I` to `Profinite`, sending a finite subset set `J` to the image of `C` under the projection `Proj J`. -/ noncomputable def spanFunctor [∀ (s : Finset I) (i : I), Decidable (i ∈ s)] : (Finset I)ᵒᵖ ⥤ Profinite.{u} where obj s := @Profinite.of (π C (· ∈ (unop s))) _ (by rw [← isCompact_iff_compactSpace]; exact hC.image (continuous_proj _)) _ _ map h := ⟨(ProjRestricts C (leOfHom h.unop)), continuous_projRestricts _ _⟩ map_id J := by simp only [projRestricts_eq_id C (· ∈ (unop J))]; rfl map_comp _ _ := by dsimp; congr; dsimp; rw [projRestricts_eq_comp] /-- The limit cone on `spanFunctor` with point `C`. -/ noncomputable def spanCone [∀ (s : Finset I) (i : I), Decidable (i ∈ s)] : Cone (spanFunctor hC) where pt := @Profinite.of C _ (by rwa [← isCompact_iff_compactSpace]) _ _ π := { app := fun s ↦ ⟨ProjRestrict C (· ∈ unop s), continuous_projRestrict _ _⟩ naturality := by intro X Y h simp only [Functor.const_obj_obj, Homeomorph.setCongr, Homeomorph.homeomorph_mk_coe, Functor.const_obj_map, Category.id_comp, ← projRestricts_comp_projRestrict C (leOfHom h.unop)] rfl } /-- `spanCone` is a limit cone. -/ noncomputable def spanCone_isLimit [∀ (s : Finset I) (i : I), Decidable (i ∈ s)] : CategoryTheory.Limits.IsLimit (spanCone hC) := by refine (IsLimit.postcomposeHomEquiv (NatIso.ofComponents (fun s ↦ (CompHausLike.isoOfBijective _ (iso_map_bijective C (· ∈ unop s)))) ?_) (spanCone hC)) (IsLimit.ofIsoLimit (indexCone_isLimit hC) (Cones.ext (Iso.refl _) ?_)) · intro ⟨s⟩ ⟨t⟩ ⟨⟨⟨f⟩⟩⟩ ext x have : iso_map C (· ∈ t) ∘ ProjRestricts C f = IndexFunctor.map C f ∘ iso_map C (· ∈ s) := by ext _ i; exact dif_pos i.prop exact congr_fun this x · intro ⟨s⟩ ext x have : iso_map C (· ∈ s) ∘ ProjRestrict C (· ∈ s) = IndexFunctor.π_app C (· ∈ s) := by ext _ i; exact dif_pos i.prop erw [← this] rfl end Projections section Products /-! ## Defining the basis Our proposed basis consists of products `e C iᵣ * ⋯ * e C i₁` with `iᵣ > ⋯ > i₁` which cannot be written as linear combinations of lexicographically smaller products. See below for the definition of `e`. ### Main definitions * For `i : I`, we let `e C i : LocallyConstant C ℤ` denote the map `fun f ↦ (if f.val i then 1 else 0)`. * `Products I` is the type of lists of decreasing elements of `I`, so a typical element is `[i₁, i₂,..., iᵣ]` with `i₁ > i₂ > ... > iᵣ`. * `Products.eval C` is the `C`-evaluation of a list. It takes a term `[i₁, i₂,..., iᵣ] : Products I` and returns the actual product `e C i₁ ··· e C iᵣ : LocallyConstant C ℤ`. * `GoodProducts C` is the set of `Products I` such that their `C`-evaluation cannot be written as a linear combination of evaluations of lexicographically smaller lists. ### Main results * `Products.evalFacProp` and `Products.evalFacProps` establish the fact that `Products.eval`  interacts nicely with the projection maps from the previous section. * `GoodProducts.span_iff_products`: the good products span `LocallyConstant C ℤ` iff all the products span `LocallyConstant C ℤ`. -/ /-- `e C i` is the locally constant map from `C : Set (I → Bool)` to `ℤ` sending `f` to 1 if `f.val i = true`, and 0 otherwise. -/ def e (i : I) : LocallyConstant C ℤ where toFun := fun f ↦ (if f.val i then 1 else 0) isLocallyConstant := by rw [IsLocallyConstant.iff_continuous] exact (continuous_of_discreteTopology (f := fun (a : Bool) ↦ (if a then (1 : ℤ) else 0))).comp ((continuous_apply i).comp continuous_subtype_val) /-- `Products I` is the type of lists of decreasing elements of `I`, so a typical element is `[i₁, i₂, ...]` with `i₁ > i₂ > ...`. We order `Products I` lexicographically, so `[] < [i₁, ...]`, and `[i₁, i₂, ...] < [j₁, j₂, ...]` if either `i₁ < j₁`, or `i₁ = j₁` and `[i₂, ...] < [j₂, ...]`. Terms `m = [i₁, i₂, ..., iᵣ]` of this type will be used to represent products of the form `e C i₁ ··· e C iᵣ : LocallyConstant C ℤ` . The function associated to `m` is `m.eval`. -/ def Products (I : Type*) [LinearOrder I] := {l : List I // l.Chain' (·>·)} namespace Products instance : LinearOrder (Products I) := inferInstanceAs (LinearOrder {l : List I // l.Chain' (·>·)}) @[simp] theorem lt_iff_lex_lt (l m : Products I) : l < m ↔ List.Lex (·<·) l.val m.val := by cases l; cases m; rw [Subtype.mk_lt_mk]; exact Iff.rfl instance : IsWellFounded (Products I) (·<·) := by have : (· < · : Products I → _ → _) = (fun l m ↦ List.Lex (·<·) l.val m.val) := by ext; exact lt_iff_lex_lt _ _ rw [this] dsimp [Products] rw [(by rfl : (·>· : I → _) = flip (·<·))] infer_instance /-- The evaluation `e C i₁ ··· e C iᵣ : C → ℤ` of a formal product `[i₁, i₂, ..., iᵣ]`. -/ def eval (l : Products I) := (l.1.map (e C)).prod /-- The predicate on products which we prove picks out a basis of `LocallyConstant C ℤ`. We call such a product "good". -/ def isGood (l : Products I) : Prop := l.eval C ∉ Submodule.span ℤ ((Products.eval C) '' {m | m < l}) theorem rel_head!_of_mem [Inhabited I] {i : I} {l : Products I} (hi : i ∈ l.val) : i ≤ l.val.head! := List.Sorted.le_head! (List.chain'_iff_pairwise.mp l.prop) hi theorem head!_le_of_lt [Inhabited I] {q l : Products I} (h : q < l) (hq : q.val ≠ []) : q.val.head! ≤ l.val.head! := List.head!_le_of_lt l.val q.val h hq end Products /-- The set of good products. -/ def GoodProducts := {l : Products I | l.isGood C} namespace GoodProducts /-- Evaluation of good products. -/ def eval (l : {l : Products I // l.isGood C}) : LocallyConstant C ℤ := Products.eval C l.1 theorem injective : Function.Injective (eval C) := by intro ⟨a, ha⟩ ⟨b, hb⟩ h dsimp [eval] at h rcases lt_trichotomy a b with (h'|rfl|h') · exfalso; apply hb; rw [← h] exact Submodule.subset_span ⟨a, h', rfl⟩ · rfl · exfalso; apply ha; rw [h] exact Submodule.subset_span ⟨b, ⟨h',rfl⟩⟩ /-- The image of the good products in the module `LocallyConstant C ℤ`. -/ def range := Set.range (GoodProducts.eval C) /-- The type of good products is equivalent to its image. -/ noncomputable def equiv_range : GoodProducts C ≃ range C := Equiv.ofInjective (eval C) (injective C) theorem equiv_toFun_eq_eval : (equiv_range C).toFun = Set.rangeFactorization (eval C) := rfl theorem linearIndependent_iff_range : LinearIndependent ℤ (GoodProducts.eval C) ↔ LinearIndependent ℤ (fun (p : range C) ↦ p.1) := by rw [← @Set.rangeFactorization_eq _ _ (GoodProducts.eval C), ← equiv_toFun_eq_eval C] exact linearIndependent_equiv (equiv_range C) end GoodProducts namespace Products theorem eval_eq (l : Products I) (x : C) : l.eval C x = if ∀ i, i ∈ l.val → (x.val i = true) then 1 else 0 := by change LocallyConstant.evalMonoidHom x (l.eval C) = _ rw [eval, map_list_prod] split_ifs with h · simp only [List.map_map] apply List.prod_eq_one simp only [List.mem_map, Function.comp_apply] rintro _ ⟨i, hi, rfl⟩ exact if_pos (h i hi) · simp only [List.map_map, List.prod_eq_zero_iff, List.mem_map, Function.comp_apply] push_neg at h convert h with i dsimp [LocallyConstant.evalMonoidHom, e] simp only [ite_eq_right_iff, one_ne_zero] theorem evalFacProp {l : Products I} (J : I → Prop) (h : ∀ a, a ∈ l.val → J a) [∀ j, Decidable (J j)] : l.eval (π C J) ∘ ProjRestrict C J = l.eval C := by ext x dsimp [ProjRestrict] rw [Products.eval_eq, Products.eval_eq] congr apply forall_congr; intro i apply forall_congr; intro hi simp [h i hi, Proj] theorem evalFacProps {l : Products I} (J K : I → Prop) (h : ∀ a, a ∈ l.val → J a) [∀ j, Decidable (J j)] [∀ j, Decidable (K j)] (hJK : ∀ i, J i → K i) : l.eval (π C J) ∘ ProjRestricts C hJK = l.eval (π C K) := by have : l.eval (π C J) ∘ Homeomorph.setCongr (proj_eq_of_subset C J K hJK) = l.eval (π (π C K) J) := by ext; simp [Homeomorph.setCongr, Products.eval_eq] rw [ProjRestricts, ← Function.comp.assoc, this, ← evalFacProp (π C K) J h] theorem prop_of_isGood {l : Products I} (J : I → Prop) [∀ j, Decidable (J j)] (h : l.isGood (π C J)) : ∀ a, a ∈ l.val → J a := by intro i hi by_contra h' apply h suffices eval (π C J) l = 0 by rw [this] exact Submodule.zero_mem _ ext ⟨_, _, _, rfl⟩ rw [eval_eq, if_neg fun h ↦ ?_, LocallyConstant.zero_apply] simpa [Proj, h'] using h i hi end Products /-- The good products span `LocallyConstant C ℤ` if and only all the products do. -/ theorem GoodProducts.span_iff_products : ⊤ ≤ Submodule.span ℤ (Set.range (eval C)) ↔ ⊤ ≤ Submodule.span ℤ (Set.range (Products.eval C)) := by refine ⟨fun h ↦ le_trans h (span_mono (fun a ⟨b, hb⟩ ↦ ⟨b.val, hb⟩)), fun h ↦ le_trans h ?_⟩ rw [span_le] rintro f ⟨l, rfl⟩ let L : Products I → Prop := fun m ↦ m.eval C ∈ span ℤ (Set.range (GoodProducts.eval C)) suffices L l by assumption apply IsWellFounded.induction (·<· : Products I → Products I → Prop) intro l h dsimp by_cases hl : l.isGood C · apply subset_span exact ⟨⟨l, hl⟩, rfl⟩ · simp only [Products.isGood, not_not] at hl suffices Products.eval C '' {m | m < l} ⊆ span ℤ (Set.range (GoodProducts.eval C)) by rw [← span_le] at this exact this hl rintro a ⟨m, hm, rfl⟩ exact h m hm end Products section Span /-! ## The good products span Most of the argument is developing an API for `π C (· ∈ s)` when `s : Finset I`; then the image of `C` is finite with the discrete topology. In this case, there is a direct argument that the good products span. The general result is deduced from this. ### Main theorems * `GoodProducts.spanFin` : The good products span the locally constant functions on `π C (· ∈ s)` if `s` is finite. * `GoodProducts.span` : The good products span `LocallyConstant C ℤ` for every closed subset `C`. -/ section Fin variable (s : Finset I) /-- The `ℤ`-linear map induced by precomposition of the projection `C → π C (· ∈ s)`. -/ noncomputable def πJ : LocallyConstant (π C (· ∈ s)) ℤ →ₗ[ℤ] LocallyConstant C ℤ := LocallyConstant.comapₗ ℤ ⟨_, (continuous_projRestrict C (· ∈ s))⟩ theorem eval_eq_πJ (l : Products I) (hl : l.isGood (π C (· ∈ s))) : l.eval C = πJ C s (l.eval (π C (· ∈ s))) := by ext f simp only [πJ, LocallyConstant.comapₗ, LinearMap.coe_mk, AddHom.coe_mk, (continuous_projRestrict C (· ∈ s)), LocallyConstant.coe_comap, Function.comp_apply] exact (congr_fun (Products.evalFacProp C (· ∈ s) (Products.prop_of_isGood C (· ∈ s) hl)) _).symm /-- `π C (· ∈ s)` is finite for a finite set `s`. -/ noncomputable instance : Fintype (π C (· ∈ s)) := by let f : π C (· ∈ s) → (s → Bool) := fun x j ↦ x.val j.val refine Fintype.ofInjective f ?_ intro ⟨_, x, hx, rfl⟩ ⟨_, y, hy, rfl⟩ h ext i by_cases hi : i ∈ s · exact congrFun h ⟨i, hi⟩ · simp only [Proj, if_neg hi] open scoped Classical in /-- The Kronecker delta as a locally constant map from `π C (· ∈ s)` to `ℤ`. -/ noncomputable def spanFinBasis (x : π C (· ∈ s)) : LocallyConstant (π C (· ∈ s)) ℤ where toFun := fun y ↦ if y = x then 1 else 0 isLocallyConstant := haveI : DiscreteTopology (π C (· ∈ s)) := Finite.instDiscreteTopology IsLocallyConstant.of_discrete _ open scoped Classical in theorem spanFinBasis.span : ⊤ ≤ Submodule.span ℤ (Set.range (spanFinBasis C s)) := by intro f _ rw [Finsupp.mem_span_range_iff_exists_finsupp] use Finsupp.onFinset (Finset.univ) f.toFun (fun _ _ ↦ Finset.mem_univ _) ext x change LocallyConstant.evalₗ ℤ x _ = _ simp only [zsmul_eq_mul, map_finsupp_sum, LocallyConstant.evalₗ_apply, LocallyConstant.coe_mul, Pi.mul_apply, spanFinBasis, LocallyConstant.coe_mk, mul_ite, mul_one, mul_zero, Finsupp.sum_ite_eq, Finsupp.mem_support_iff, ne_eq, ite_not] split_ifs with h <;> [exact h.symm; rfl] /-- A certain explicit list of locally constant maps. The theorem `factors_prod_eq_basis` shows that the product of the elements in this list is the delta function `spanFinBasis C s x`. -/ def factors (x : π C (· ∈ s)) : List (LocallyConstant (π C (· ∈ s)) ℤ) := List.map (fun i ↦ if x.val i = true then e (π C (· ∈ s)) i else (1 - (e (π C (· ∈ s)) i))) (s.sort (·≥·)) theorem list_prod_apply (x : C) (l : List (LocallyConstant C ℤ)) : l.prod x = (l.map (LocallyConstant.evalMonoidHom x)).prod := by rw [← map_list_prod (LocallyConstant.evalMonoidHom x) l] rfl theorem factors_prod_eq_basis_of_eq {x y : (π C fun x ↦ x ∈ s)} (h : y = x) : (factors C s x).prod y = 1 := by rw [list_prod_apply (π C (· ∈ s)) y _] apply List.prod_eq_one simp only [h, List.mem_map, LocallyConstant.evalMonoidHom, factors] rintro _ ⟨a, ⟨b, _, rfl⟩, rfl⟩ dsimp split_ifs with hh · rw [e, LocallyConstant.coe_mk, if_pos hh] · rw [LocallyConstant.sub_apply, e, LocallyConstant.coe_mk, LocallyConstant.coe_mk, if_neg hh] simp only [LocallyConstant.toFun_eq_coe, LocallyConstant.coe_one, Pi.one_apply, sub_zero] theorem e_mem_of_eq_true {x : (π C (· ∈ s))} {a : I} (hx : x.val a = true) : e (π C (· ∈ s)) a ∈ factors C s x := by rcases x with ⟨_, z, hz, rfl⟩ simp only [factors, List.mem_map, Finset.mem_sort] refine ⟨a, ?_, if_pos hx⟩ aesop (add simp Proj) theorem one_sub_e_mem_of_false {x y : (π C (· ∈ s))} {a : I} (ha : y.val a = true) (hx : x.val a = false) : 1 - e (π C (· ∈ s)) a ∈ factors C s x := by simp only [factors, List.mem_map, Finset.mem_sort] use a simp only [hx, ite_false, and_true] rcases y with ⟨_, z, hz, rfl⟩ aesop (add simp Proj) theorem factors_prod_eq_basis_of_ne {x y : (π C (· ∈ s))} (h : y ≠ x) : (factors C s x).prod y = 0 := by rw [list_prod_apply (π C (· ∈ s)) y _] apply List.prod_eq_zero simp only [List.mem_map] obtain ⟨a, ha⟩ : ∃ a, y.val a ≠ x.val a := by contrapose! h; ext; apply h cases hx : x.val a · rw [hx, ne_eq, Bool.not_eq_false] at ha refine ⟨1 - (e (π C (· ∈ s)) a), ⟨one_sub_e_mem_of_false _ _ ha hx, ?_⟩⟩ rw [e, LocallyConstant.evalMonoidHom_apply, LocallyConstant.sub_apply, LocallyConstant.coe_one, Pi.one_apply, LocallyConstant.coe_mk, if_pos ha, sub_self] · refine ⟨e (π C (· ∈ s)) a, ⟨e_mem_of_eq_true _ _ hx, ?_⟩⟩ rw [hx] at ha rw [LocallyConstant.evalMonoidHom_apply, e, LocallyConstant.coe_mk, if_neg ha] /-- If `s` is finite, the product of the elements of the list `factors C s x` is the delta function at `x`. -/ theorem factors_prod_eq_basis (x : π C (· ∈ s)) : (factors C s x).prod = spanFinBasis C s x := by ext y dsimp [spanFinBasis] split_ifs with h <;> [exact factors_prod_eq_basis_of_eq _ _ h; exact factors_prod_eq_basis_of_ne _ _ h] theorem GoodProducts.finsupp_sum_mem_span_eval {a : I} {as : List I} (ha : List.Chain' (· > ·) (a :: as)) {c : Products I →₀ ℤ} (hc : (c.support : Set (Products I)) ⊆ {m | m.val ≤ as}) : (Finsupp.sum c fun a_1 b ↦ e (π C (· ∈ s)) a * b • Products.eval (π C (· ∈ s)) a_1) ∈ Submodule.span ℤ (Products.eval (π C (· ∈ s)) '' {m | m.val ≤ a :: as}) := by apply Submodule.finsupp_sum_mem intro m hm have hsm := (LinearMap.mulLeft ℤ (e (π C (· ∈ s)) a)).map_smul dsimp at hsm rw [hsm] apply Submodule.smul_mem apply Submodule.subset_span have hmas : m.val ≤ as := by apply hc simpa only [Finset.mem_coe, Finsupp.mem_support_iff] using hm refine ⟨⟨a :: m.val, ha.cons_of_le m.prop hmas⟩, ⟨List.cons_le_cons a hmas, ?_⟩⟩ simp only [Products.eval, List.map, List.prod_cons] /-- If `s` is a finite subset of `I`, then the good products span. -/ theorem GoodProducts.spanFin : ⊤ ≤ Submodule.span ℤ (Set.range (eval (π C (· ∈ s)))) := by rw [span_iff_products] refine le_trans (spanFinBasis.span C s) ?_ rw [Submodule.span_le] rintro _ ⟨x, rfl⟩ rw [← factors_prod_eq_basis] let l := s.sort (·≥·) dsimp [factors] suffices l.Chain' (·>·) → (l.map (fun i ↦ if x.val i = true then e (π C (· ∈ s)) i else (1 - (e (π C (· ∈ s)) i)))).prod ∈ Submodule.span ℤ ((Products.eval (π C (· ∈ s))) '' {m | m.val ≤ l}) from Submodule.span_mono (Set.image_subset_range _ _) (this (Finset.sort_sorted_gt _).chain') induction l with | nil => intro _ apply Submodule.subset_span exact ⟨⟨[], List.chain'_nil⟩,⟨Or.inl rfl, rfl⟩⟩ | cons a as ih => rw [List.map_cons, List.prod_cons] intro ha specialize ih (by rw [List.chain'_cons'] at ha; exact ha.2) rw [Finsupp.mem_span_image_iff_total] at ih simp only [Finsupp.mem_supported, Finsupp.total_apply] at ih obtain ⟨c, hc, hc'⟩ := ih rw [← hc']; clear hc' have hmap := fun g ↦ map_finsupp_sum (LinearMap.mulLeft ℤ (e (π C (· ∈ s)) a)) c g dsimp at hmap ⊢ split_ifs · rw [hmap] exact finsupp_sum_mem_span_eval _ _ ha hc · ring_nf rw [hmap] apply Submodule.add_mem · apply Submodule.neg_mem exact finsupp_sum_mem_span_eval _ _ ha hc · apply Submodule.finsupp_sum_mem intro m hm apply Submodule.smul_mem apply Submodule.subset_span refine ⟨m, ⟨?_, rfl⟩⟩ simp only [Set.mem_setOf_eq] have hmas : m.val ≤ as := hc (by simpa only [Finset.mem_coe, Finsupp.mem_support_iff] using hm) refine le_trans hmas ?_ cases as with | nil => exact (List.nil_lt_cons a []).le | cons b bs => apply le_of_lt rw [List.chain'_cons] at ha have hlex := List.lt.head bs (b :: bs) ha.1 exact (List.lt_iff_lex_lt _ _).mp hlex end Fin theorem fin_comap_jointlySurjective (hC : IsClosed C) (f : LocallyConstant C ℤ) : ∃ (s : Finset I) (g : LocallyConstant (π C (· ∈ s)) ℤ), f = g.comap ⟨(ProjRestrict C (· ∈ s)), continuous_projRestrict _ _⟩ := by obtain ⟨J, g, h⟩ := @Profinite.exists_locallyConstant (Finset I)ᵒᵖ _ _ _ (spanCone hC.isCompact) ℤ (spanCone_isLimit hC.isCompact) f exact ⟨(Opposite.unop J), g, h⟩ /-- The good products span all of `LocallyConstant C ℤ` if `C` is closed. -/ theorem GoodProducts.span (hC : IsClosed C) : ⊤ ≤ Submodule.span ℤ (Set.range (eval C)) := by rw [span_iff_products] intro f _ obtain ⟨K, f', rfl⟩ : ∃ K f', f = πJ C K f' := fin_comap_jointlySurjective C hC f refine Submodule.span_mono ?_ <| Submodule.apply_mem_span_image_of_mem_span (πJ C K) <| spanFin C K (Submodule.mem_top : f' ∈ ⊤) rintro l ⟨y, ⟨m, rfl⟩, rfl⟩ exact ⟨m.val, eval_eq_πJ C K m.val m.prop⟩ end Span section Ordinal /-! ## Relating elements of the well-order `I` with ordinals We choose a well-ordering on `I`. This amounts to regarding `I` as an ordinal, and as such it can be regarded as the set of all strictly smaller ordinals, allowing to apply ordinal induction. ### Main definitions * `ord I i` is the term `i` of `I` regarded as an ordinal. * `term I ho` is a sufficiently small ordinal regarded as a term of `I`. * `contained C o` is a predicate saying that `C` is "small" enough in relation to the ordinal `o` to satisfy the inductive hypothesis. * `P I` is the predicate on ordinals about linear independence of good products, which the rest of this file is spent on proving by induction. -/ variable (I) /-- A term of `I` regarded as an ordinal. -/ def ord (i : I) : Ordinal := Ordinal.typein ((·<·) : I → I → Prop) i /-- An ordinal regarded as a term of `I`. -/ noncomputable def term {o : Ordinal} (ho : o < Ordinal.type ((·<·) : I → I → Prop)) : I := Ordinal.enum ((·<·) : I → I → Prop) o ho variable {I} theorem term_ord_aux {i : I} (ho : ord I i < Ordinal.type ((·<·) : I → I → Prop)) : term I ho = i := by simp only [term, ord, Ordinal.enum_typein] @[simp] theorem ord_term_aux {o : Ordinal} (ho : o < Ordinal.type ((·<·) : I → I → Prop)) : ord I (term I ho) = o := by simp only [ord, term, Ordinal.typein_enum] theorem ord_term {o : Ordinal} (ho : o < Ordinal.type ((·<·) : I → I → Prop)) (i : I) : ord I i = o ↔ term I ho = i := by refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩ · subst h exact term_ord_aux ho · subst h exact ord_term_aux ho /-- A predicate saying that `C` is "small" enough to satisfy the inductive hypothesis. -/ def contained (o : Ordinal) : Prop := ∀ f, f ∈ C → ∀ (i : I), f i = true → ord I i < o variable (I) in /-- The predicate on ordinals which we prove by induction, see `GoodProducts.P0`, `GoodProducts.Plimit` and `GoodProducts.linearIndependentAux` in the section `Induction` below -/ def P (o : Ordinal) : Prop := o ≤ Ordinal.type (·<· : I → I → Prop) → (∀ (C : Set (I → Bool)), IsClosed C → contained C o → LinearIndependent ℤ (GoodProducts.eval C)) theorem Products.prop_of_isGood_of_contained {l : Products I} (o : Ordinal) (h : l.isGood C) (hsC : contained C o) (i : I) (hi : i ∈ l.val) : ord I i < o := by by_contra h' apply h suffices eval C l = 0 by simp [this, Submodule.zero_mem] ext x simp only [eval_eq, LocallyConstant.coe_zero, Pi.zero_apply, ite_eq_right_iff, one_ne_zero] contrapose! h' exact hsC x.val x.prop i (h'.1 i hi) end Ordinal section Zero /-! ## The zero case of the induction In this case, we have `contained C 0` which means that `C` is either empty or a singleton. -/ instance : Subsingleton (LocallyConstant (∅ : Set (I → Bool)) ℤ) := subsingleton_iff.mpr (fun _ _ ↦ LocallyConstant.ext isEmptyElim) instance : IsEmpty { l // Products.isGood (∅ : Set (I → Bool)) l } := isEmpty_iff.mpr fun ⟨l, hl⟩ ↦ hl <| by rw [subsingleton_iff.mp inferInstance (Products.eval ∅ l) 0] exact Submodule.zero_mem _ theorem GoodProducts.linearIndependentEmpty : LinearIndependent ℤ (eval (∅ : Set (I → Bool))) := linearIndependent_empty_type /-- The empty list as a `Products` -/ def Products.nil : Products I := ⟨[], by simp only [List.chain'_nil]⟩ theorem Products.lt_nil_empty : { m : Products I | m < Products.nil } = ∅ := by ext ⟨m, hm⟩ refine ⟨fun h ↦ ?_, by tauto⟩ simp only [Set.mem_setOf_eq, lt_iff_lex_lt, nil, List.Lex.not_nil_right] at h instance {α : Type*} [TopologicalSpace α] [Nonempty α] : Nontrivial (LocallyConstant α ℤ) := ⟨0, 1, ne_of_apply_ne DFunLike.coe <| (Function.const_injective (β := ℤ)).ne zero_ne_one⟩ theorem Products.isGood_nil : Products.isGood ({fun _ ↦ false} : Set (I → Bool)) Products.nil := by intro h simp only [Products.lt_nil_empty, Products.eval, List.map, List.prod_nil, Set.image_empty, Submodule.span_empty, Submodule.mem_bot, one_ne_zero] at h theorem Products.span_nil_eq_top : Submodule.span ℤ (eval ({fun _ ↦ false} : Set (I → Bool)) '' {nil}) = ⊤ := by rw [Set.image_singleton, eq_top_iff] intro f _ rw [Submodule.mem_span_singleton] refine ⟨f default, ?_⟩ simp only [eval, List.map, List.prod_nil, zsmul_eq_mul, mul_one] ext x obtain rfl : x = default := by simp only [Set.default_coe_singleton, eq_iff_true_of_subsingleton] rfl /-- There is a unique `GoodProducts` for the singleton `{fun _ ↦ false}`. -/ noncomputable instance : Unique { l // Products.isGood ({fun _ ↦ false} : Set (I → Bool)) l } where default := ⟨Products.nil, Products.isGood_nil⟩ uniq := by intro ⟨⟨l, hl⟩, hll⟩ ext apply Subtype.ext apply (List.Lex.nil_left_or_eq_nil l (r := (·<·))).resolve_left intro _ apply hll have he : {Products.nil} ⊆ {m | m < ⟨l,hl⟩} := by simpa only [Products.nil, Products.lt_iff_lex_lt, Set.singleton_subset_iff, Set.mem_setOf_eq] apply Submodule.span_mono (Set.image_subset _ he) rw [Products.span_nil_eq_top] exact Submodule.mem_top instance (α : Type*) [TopologicalSpace α] : NoZeroSMulDivisors ℤ (LocallyConstant α ℤ) := by constructor intro c f h rw [or_iff_not_imp_left] intro hc ext x apply mul_right_injective₀ hc simp [LocallyConstant.ext_iff] at h simpa [LocallyConstant.ext_iff] using h x theorem GoodProducts.linearIndependentSingleton : LinearIndependent ℤ (eval ({fun _ ↦ false} : Set (I → Bool))) := by refine linearIndependent_unique (eval ({fun _ ↦ false} : Set (I → Bool))) ?_ simp only [eval, Products.eval, List.map, List.prod_nil, ne_eq, one_ne_zero, not_false_eq_true] end Zero section Maps /-! ## `ℤ`-linear maps induced by projections We define injective `ℤ`-linear maps between modules of the form `LocallyConstant C ℤ` induced by precomposition with the projections defined in the section `Projections`. ### Main definitions * `πs` and `πs'` are the `ℤ`-linear maps corresponding to `ProjRestrict` and `ProjRestricts`  respectively. ### Main result * We prove that `πs` and `πs'` interact well with `Products.eval` and the main application is the theorem `isGood_mono` which says that the property `isGood` is "monotone" on ordinals. -/ theorem contained_eq_proj (o : Ordinal) (h : contained C o) : C = π C (ord I · < o) := by have := proj_prop_eq_self C (ord I · < o) simp [π, Bool.not_eq_false] at this exact (this (fun i x hx ↦ h x hx i)).symm theorem isClosed_proj (o : Ordinal) (hC : IsClosed C) : IsClosed (π C (ord I · < o)) := (continuous_proj (ord I · < o)).isClosedMap C hC theorem contained_proj (o : Ordinal) : contained (π C (ord I · < o)) o := by intro x ⟨_, _, h⟩ j hj aesop (add simp Proj) /-- The `ℤ`-linear map induced by precomposition of the projection `C → π C (ord I · < o)`. -/ @[simps!] noncomputable def πs (o : Ordinal) : LocallyConstant (π C (ord I · < o)) ℤ →ₗ[ℤ] LocallyConstant C ℤ := LocallyConstant.comapₗ ℤ ⟨(ProjRestrict C (ord I · < o)), (continuous_projRestrict _ _)⟩ theorem coe_πs (o : Ordinal) (f : LocallyConstant (π C (ord I · < o)) ℤ) : πs C o f = f ∘ ProjRestrict C (ord I · < o) := by rfl theorem injective_πs (o : Ordinal) : Function.Injective (πs C o) := LocallyConstant.comap_injective ⟨_, (continuous_projRestrict _ _)⟩ (Set.surjective_mapsTo_image_restrict _ _) /-- The `ℤ`-linear map induced by precomposition of the projection `π C (ord I · < o₂) → π C (ord I · < o₁)` for `o₁ ≤ o₂`. -/ @[simps!] noncomputable def πs' {o₁ o₂ : Ordinal} (h : o₁ ≤ o₂) : LocallyConstant (π C (ord I · < o₁)) ℤ →ₗ[ℤ] LocallyConstant (π C (ord I · < o₂)) ℤ := LocallyConstant.comapₗ ℤ ⟨(ProjRestricts C (fun _ hh ↦ lt_of_lt_of_le hh h)), (continuous_projRestricts _ _)⟩ theorem coe_πs' {o₁ o₂ : Ordinal} (h : o₁ ≤ o₂) (f : LocallyConstant (π C (ord I · < o₁)) ℤ) : (πs' C h f).toFun = f.toFun ∘ (ProjRestricts C (fun _ hh ↦ lt_of_lt_of_le hh h)) := by rfl theorem injective_πs' {o₁ o₂ : Ordinal} (h : o₁ ≤ o₂) : Function.Injective (πs' C h) := LocallyConstant.comap_injective ⟨_, (continuous_projRestricts _ _)⟩ (surjective_projRestricts _ fun _ hi ↦ lt_of_lt_of_le hi h) namespace Products theorem lt_ord_of_lt {l m : Products I} {o : Ordinal} (h₁ : m < l) (h₂ : ∀ i ∈ l.val, ord I i < o) : ∀ i ∈ m.val, ord I i < o := List.Sorted.lt_ord_of_lt (List.chain'_iff_pairwise.mp l.2) (List.chain'_iff_pairwise.mp m.2) h₁ h₂ theorem eval_πs {l : Products I} {o : Ordinal} (hlt : ∀ i ∈ l.val, ord I i < o) : πs C o (l.eval (π C (ord I · < o))) = l.eval C := by simpa only [← LocallyConstant.coe_inj] using evalFacProp C (ord I · < o) hlt theorem eval_πs' {l : Products I} {o₁ o₂ : Ordinal} (h : o₁ ≤ o₂) (hlt : ∀ i ∈ l.val, ord I i < o₁) : πs' C h (l.eval (π C (ord I · < o₁))) = l.eval (π C (ord I · < o₂)) := by rw [← LocallyConstant.coe_inj, ← LocallyConstant.toFun_eq_coe] exact evalFacProps C (fun (i : I) ↦ ord I i < o₁) (fun (i : I) ↦ ord I i < o₂) hlt (fun _ hh ↦ lt_of_lt_of_le hh h) theorem eval_πs_image {l : Products I} {o : Ordinal} (hl : ∀ i ∈ l.val, ord I i < o) : eval C '' { m | m < l } = (πs C o) '' (eval (π C (ord I · < o)) '' { m | m < l }) := by ext f simp only [Set.mem_image, Set.mem_setOf_eq, exists_exists_and_eq_and] apply exists_congr; intro m apply and_congr_right; intro hm rw [eval_πs C (lt_ord_of_lt hm hl)] theorem eval_πs_image' {l : Products I} {o₁ o₂ : Ordinal} (h : o₁ ≤ o₂) (hl : ∀ i ∈ l.val, ord I i < o₁) : eval (π C (ord I · < o₂)) '' { m | m < l } = (πs' C h) '' (eval (π C (ord I · < o₁)) '' { m | m < l }) := by ext f simp only [Set.mem_image, Set.mem_setOf_eq, exists_exists_and_eq_and] apply exists_congr; intro m apply and_congr_right; intro hm rw [eval_πs' C h (lt_ord_of_lt hm hl)] theorem head_lt_ord_of_isGood [Inhabited I] {l : Products I} {o : Ordinal} (h : l.isGood (π C (ord I · < o))) (hn : l.val ≠ []) : ord I (l.val.head!) < o := prop_of_isGood C (ord I · < o) h l.val.head! (List.head!_mem_self hn) /-- If `l` is good w.r.t. `π C (ord I · < o₁)` and `o₁ ≤ o₂`, then it is good w.r.t. `π C (ord I · < o₂)` -/ theorem isGood_mono {l : Products I} {o₁ o₂ : Ordinal} (h : o₁ ≤ o₂) (hl : l.isGood (π C (ord I · < o₁))) : l.isGood (π C (ord I · < o₂)) := by intro hl' apply hl rwa [eval_πs_image' C h (prop_of_isGood C _ hl), ← eval_πs' C h (prop_of_isGood C _ hl), Submodule.apply_mem_span_image_iff_mem_span (injective_πs' C h)] at hl' end Products end Maps section Limit /-! ## The limit case of the induction We relate linear independence in `LocallyConstant (π C (ord I · < o')) ℤ` with linear independence in `LocallyConstant C ℤ`, where `contained C o` and `o' < o`. When `o` is a limit ordinal, we prove that the good products in `LocallyConstant C ℤ` are linearly independent if and only if a certain directed union is linearly independent. Each term in this directed union is in bijection with the good products w.r.t. `π C (ord I · < o')` for an ordinal `o' < o`, and these are linearly independent by the inductive hypothesis. ### Main definitions * `GoodProducts.smaller` is the image of good products coming from a smaller ordinal. * `GoodProducts.range_equiv`: The image of the `GoodProducts` in `C` is equivalent to the union of `smaller C o'` over all ordinals `o' < o`. ### Main results * `Products.limitOrdinal`: for `o` a limit ordinal such that `contained C o`, a product `l` is good w.r.t. `C` iff it there exists an ordinal `o' < o` such that `l` is good w.r.t. `π C (ord I · < o')`. * `GoodProducts.linearIndependent_iff_union_smaller` is the result mentioned above, that the good products are linearly independent iff a directed union is. -/ namespace GoodProducts /-- The image of the `GoodProducts` for `π C (ord I · < o)` in `LocallyConstant C ℤ`. The name `smaller` refers to the setting in which we will use this, when we are mapping in `GoodProducts` from a smaller set, i.e. when `o` is a smaller ordinal than the one `C` is "contained" in. -/ def smaller (o : Ordinal) : Set (LocallyConstant C ℤ) := (πs C o) '' (range (π C (ord I · < o))) /-- The map from the image of the `GoodProducts` in `LocallyConstant (π C (ord I · < o)) ℤ` to `smaller C o` -/ noncomputable def range_equiv_smaller_toFun (o : Ordinal) (x : range (π C (ord I · < o))) : smaller C o := ⟨πs C o ↑x, x.val, x.property, rfl⟩ theorem range_equiv_smaller_toFun_bijective (o : Ordinal) : Function.Bijective (range_equiv_smaller_toFun C o) := by dsimp (config := { unfoldPartialApp := true }) [range_equiv_smaller_toFun] refine ⟨fun a b hab ↦ ?_, fun ⟨a, b, hb⟩ ↦ ?_⟩ · ext1 simp only [Subtype.mk.injEq] at hab exact injective_πs C o hab · use ⟨b, hb.1⟩ simpa only [Subtype.mk.injEq] using hb.2 /-- The equivalence from the image of the `GoodProducts` in `LocallyConstant (π C (ord I · < o)) ℤ` to `smaller C o` -/ noncomputable def range_equiv_smaller (o : Ordinal) : range (π C (ord I · < o)) ≃ smaller C o := Equiv.ofBijective (range_equiv_smaller_toFun C o) (range_equiv_smaller_toFun_bijective C o) theorem smaller_factorization (o : Ordinal) : (fun (p : smaller C o) ↦ p.1) ∘ (range_equiv_smaller C o).toFun = (πs C o) ∘ (fun (p : range (π C (ord I · < o))) ↦ p.1) := by rfl theorem linearIndependent_iff_smaller (o : Ordinal) : LinearIndependent ℤ (GoodProducts.eval (π C (ord I · < o))) ↔ LinearIndependent ℤ (fun (p : smaller C o) ↦ p.1) := by rw [GoodProducts.linearIndependent_iff_range, ← LinearMap.linearIndependent_iff (πs C o) (LinearMap.ker_eq_bot_of_injective (injective_πs _ _)), ← smaller_factorization C o] exact linearIndependent_equiv _ theorem smaller_mono {o₁ o₂ : Ordinal} (h : o₁ ≤ o₂) : smaller C o₁ ⊆ smaller C o₂ := by rintro f ⟨g, hg, rfl⟩ simp only [smaller, Set.mem_image] use πs' C h g obtain ⟨⟨l, gl⟩, rfl⟩ := hg refine ⟨?_, ?_⟩ · use ⟨l, Products.isGood_mono C h gl⟩ ext x rw [eval, ← Products.eval_πs' _ h (Products.prop_of_isGood C _ gl), eval] · rw [← LocallyConstant.coe_inj, coe_πs C o₂, ← LocallyConstant.toFun_eq_coe, coe_πs', Function.comp.assoc, projRestricts_comp_projRestrict C _, coe_πs] rfl end GoodProducts variable {o : Ordinal} (ho : o.IsLimit) (hsC : contained C o) theorem Products.limitOrdinal (l : Products I) : l.isGood (π C (ord I · < o)) ↔ ∃ (o' : Ordinal), o' < o ∧ l.isGood (π C (ord I · < o')) := by refine ⟨fun h ↦ ?_, fun ⟨o', ⟨ho', hl⟩⟩ ↦ isGood_mono C (le_of_lt ho') hl⟩ use Finset.sup l.val.toFinset (fun a ↦ Order.succ (ord I a)) have ha : ⊥ < o := by rw [Ordinal.bot_eq_zero, Ordinal.pos_iff_ne_zero]; exact ho.1 have hslt : Finset.sup l.val.toFinset (fun a ↦ Order.succ (ord I a)) < o := by simp only [Finset.sup_lt_iff ha, List.mem_toFinset] exact fun b hb ↦ ho.2 _ (prop_of_isGood C (ord I · < o) h b hb) refine ⟨hslt, fun he ↦ h ?_⟩ have hlt : ∀ i ∈ l.val, ord I i < Finset.sup l.val.toFinset (fun a ↦ Order.succ (ord I a)) := by intro i hi simp only [Finset.lt_sup_iff, List.mem_toFinset, Order.lt_succ_iff] exact ⟨i, hi, le_rfl⟩ rwa [eval_πs_image' C (le_of_lt hslt) hlt, ← eval_πs' C (le_of_lt hslt) hlt, Submodule.apply_mem_span_image_iff_mem_span (injective_πs' C _)] theorem GoodProducts.union : range C = ⋃ (e : {o' // o' < o}), (smaller C e.val) := by ext p simp only [smaller, range, Set.mem_iUnion, Set.mem_image, Set.mem_range, Subtype.exists] refine ⟨fun hp ↦ ?_, fun hp ↦ ?_⟩ · obtain ⟨l, hl, rfl⟩ := hp rw [contained_eq_proj C o hsC, Products.limitOrdinal C ho] at hl obtain ⟨o', ho'⟩ := hl refine ⟨o', ho'.1, eval (π C (ord I · < o')) ⟨l, ho'.2⟩, ⟨l, ho'.2, rfl⟩, ?_⟩ exact Products.eval_πs C (Products.prop_of_isGood C _ ho'.2) · obtain ⟨o', h, _, ⟨l, hl, rfl⟩, rfl⟩ := hp refine ⟨l, ?_, (Products.eval_πs C (Products.prop_of_isGood C _ hl)).symm⟩ rw [contained_eq_proj C o hsC] exact Products.isGood_mono C (le_of_lt h) hl /-- The image of the `GoodProducts` in `C` is equivalent to the union of `smaller C o'` over all ordinals `o' < o`. -/ def GoodProducts.range_equiv : range C ≃ ⋃ (e : {o' // o' < o}), (smaller C e.val) := Equiv.Set.ofEq (union C ho hsC) theorem GoodProducts.range_equiv_factorization : (fun (p : ⋃ (e : {o' // o' < o}), (smaller C e.val)) ↦ p.1) ∘ (range_equiv C ho hsC).toFun = (fun (p : range C) ↦ (p.1 : LocallyConstant C ℤ)) := rfl theorem GoodProducts.linearIndependent_iff_union_smaller {o : Ordinal} (ho : o.IsLimit) (hsC : contained C o) : LinearIndependent ℤ (GoodProducts.eval C) ↔ LinearIndependent ℤ (fun (p : ⋃ (e : {o' // o' < o}), (smaller C e.val)) ↦ p.1) := by rw [GoodProducts.linearIndependent_iff_range, ← range_equiv_factorization C ho hsC] exact linearIndependent_equiv (range_equiv C ho hsC) end Limit section Successor /-! ## The successor case in the induction Here we assume that `o` is an ordinal such that `contained C (o+1)` and `o < I`. The element in `I` corresponding to `o` is called `term I ho`, but in this informal docstring we refer to it simply as `o`. This section follows the proof in [scholze2019condensed] quite closely. A translation of the notation there is as follows: ``` [scholze2019condensed] | This file `S₀` |`C0` `S₁` |`C1` `\overline{S}` |`π C (ord I · < o) `\overline{S}'` |`C'` The left map in the exact sequence |`πs` The right map in the exact sequence |`Linear_CC'` ``` When comparing the proof of the successor case in Theorem 5.4 in [scholze2019condensed] with this proof, one should read the phrase "is a basis" as "is linearly independent". Also, the short exact sequence in [scholze2019condensed] is only proved to be left exact here (indeed, that is enough since we are only proving linear independence). This section is split into two sections. The first one, `ExactSequence` defines the left exact sequence mentioned in the previous paragraph (see `succ_mono` and `succ_exact`). It corresponds to the penultimate paragraph of the proof in [scholze2019condensed]. The second one, `GoodProducts` corresponds to the last paragraph in the proof in [scholze2019condensed]. ### Main definitions The main definitions in the section `ExactSequence` are all just notation explained in the table above. The main definitions in the section `GoodProducts` are as follows: * `MaxProducts`: the set of good products that contain the ordinal `o` (since we have `contained C (o+1)`, these all start with `o`). * `GoodProducts.sum_equiv`: the equivalence between `GoodProducts C` and the disjoint union of `MaxProducts C` and `GoodProducts (π C (ord I · < o))`. ### Main results * The main results in the section `ExactSequence` are `succ_mono` and `succ_exact` which together say that the secuence given by `πs` and `Linear_CC'` is left exact: ``` f g 0 --→ LocallyConstant (π C (ord I · < o)) ℤ --→ LocallyConstant C ℤ --→ LocallyConstant C' ℤ ``` where `f` is `πs` and `g` is `Linear_CC'`. The main results in the section `GoodProducts` are as follows: * `Products.max_eq_eval` says that the linear map on the right in the exact sequence, i.e. `Linear_CC'`, takes the evaluation of a term of `MaxProducts` to the evaluation of the corresponding list with the leading `o` removed. * `GoodProducts.maxTail_isGood` says that removing the leading `o` from a term of `MaxProducts C`  yields a list which `isGood` with respect to `C'`. -/ variable {o : Ordinal} (hC : IsClosed C) (hsC : contained C (Order.succ o)) (ho : o < Ordinal.type (·<· : I → I → Prop)) section ExactSequence /-- The subset of `C` consisting of those elements whose `o`-th entry is `false`. -/ def C0 := C ∩ {f | f (term I ho) = false} /-- The subset of `C` consisting of those elements whose `o`-th entry is `true`. -/ def C1 := C ∩ {f | f (term I ho) = true} theorem isClosed_C0 : IsClosed (C0 C ho) := by refine hC.inter ?_ have h : Continuous (fun (f : I → Bool) ↦ f (term I ho)) := continuous_apply (term I ho) exact IsClosed.preimage h (t := {false}) (isClosed_discrete _) theorem isClosed_C1 : IsClosed (C1 C ho) := by refine hC.inter ?_ have h : Continuous (fun (f : I → Bool) ↦ f (term I ho)) := continuous_apply (term I ho) exact IsClosed.preimage h (t := {true}) (isClosed_discrete _) theorem contained_C1 : contained (π (C1 C ho) (ord I · < o)) o := contained_proj _ _ theorem union_C0C1_eq : (C0 C ho) ∪ (C1 C ho) = C := by ext x simp only [C0, C1, Set.mem_union, Set.mem_inter_iff, Set.mem_setOf_eq, ← and_or_left, and_iff_left_iff_imp, Bool.dichotomy (x (term I ho)), implies_true] /-- The intersection of `C0` and the projection of `C1`. We will apply the inductive hypothesis to this set. -/ def C' := C0 C ho ∩ π (C1 C ho) (ord I · < o) theorem isClosed_C' : IsClosed (C' C ho) := IsClosed.inter (isClosed_C0 _ hC _) (isClosed_proj _ _ (isClosed_C1 _ hC _)) theorem contained_C' : contained (C' C ho) o := fun f hf i hi ↦ contained_C1 C ho f hf.2 i hi variable (o) /-- Swapping the `o`-th coordinate to `true`. -/ noncomputable def SwapTrue : (I → Bool) → I → Bool := fun f i ↦ if ord I i = o then true else f i theorem continuous_swapTrue : Continuous (SwapTrue o : (I → Bool) → I → Bool) := by dsimp (config := { unfoldPartialApp := true }) [SwapTrue] apply continuous_pi intro i apply Continuous.comp' · apply continuous_bot · apply continuous_apply variable {o} theorem swapTrue_mem_C1 (f : π (C1 C ho) (ord I · < o)) : SwapTrue o f.val ∈ C1 C ho := by obtain ⟨f, g, hg, rfl⟩ := f convert hg dsimp (config := { unfoldPartialApp := true }) [SwapTrue] ext i split_ifs with h · rw [ord_term ho] at h simpa only [← h] using hg.2.symm · simp only [Proj, ite_eq_left_iff, not_lt, @eq_comm _ false, ← Bool.not_eq_true] specialize hsC g hg.1 i intro h' contrapose! hsC exact ⟨hsC, Order.succ_le_of_lt (h'.lt_of_ne' h)⟩ /-- The first way to map `C'` into `C`. -/ def CC'₀ : C' C ho → C := fun g ↦ ⟨g.val,g.prop.1.1⟩ /-- The second way to map `C'` into `C`. -/ noncomputable def CC'₁ : C' C ho → C := fun g ↦ ⟨SwapTrue o g.val, (swapTrue_mem_C1 C hsC ho ⟨g.val,g.prop.2⟩).1⟩ theorem continuous_CC'₀ : Continuous (CC'₀ C ho) := Continuous.subtype_mk continuous_subtype_val _ theorem continuous_CC'₁ : Continuous (CC'₁ C hsC ho) := Continuous.subtype_mk (Continuous.comp (continuous_swapTrue o) continuous_subtype_val) _ /-- The `ℤ`-linear map induced by precomposing with `CC'₀` -/ noncomputable def Linear_CC'₀ : LocallyConstant C ℤ →ₗ[ℤ] LocallyConstant (C' C ho) ℤ := LocallyConstant.comapₗ ℤ ⟨(CC'₀ C ho), (continuous_CC'₀ C ho)⟩ /-- The `ℤ`-linear map induced by precomposing with `CC'₁` -/ noncomputable def Linear_CC'₁ : LocallyConstant C ℤ →ₗ[ℤ] LocallyConstant (C' C ho) ℤ := LocallyConstant.comapₗ ℤ ⟨(CC'₁ C hsC ho), (continuous_CC'₁ C hsC ho)⟩ /-- The difference between `Linear_CC'₁` and `Linear_CC'₀`. -/ noncomputable def Linear_CC' : LocallyConstant C ℤ →ₗ[ℤ] LocallyConstant (C' C ho) ℤ := Linear_CC'₁ C hsC ho - Linear_CC'₀ C ho theorem CC_comp_zero : ∀ y, (Linear_CC' C hsC ho) ((πs C o) y) = 0 := by intro y ext x dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁, LocallyConstant.sub_apply] simp only [Pi.zero_apply, sub_eq_zero] congr 1 ext i dsimp [CC'₀, CC'₁, ProjRestrict, Proj] apply if_ctx_congr Iff.rfl _ (fun _ ↦ rfl) simp only [SwapTrue, ite_eq_right_iff] intro h₁ h₂ exact (h₁.ne h₂).elim theorem C0_projOrd {x : I → Bool} (hx : x ∈ C0 C ho) : Proj (ord I · < o) x = x := by ext i simp only [Proj, Set.mem_setOf, ite_eq_left_iff, not_lt] intro hi rw [le_iff_lt_or_eq] at hi cases' hi with hi hi · specialize hsC x hx.1 i rw [← not_imp_not] at hsC simp only [not_lt, Bool.not_eq_true, Order.succ_le_iff] at hsC exact (hsC hi).symm · simp only [C0, Set.mem_inter_iff, Set.mem_setOf_eq] at hx rw [eq_comm, ord_term ho] at hi rw [← hx.2, hi] theorem C1_projOrd {x : I → Bool} (hx : x ∈ C1 C ho) : SwapTrue o (Proj (ord I · < o) x) = x := by ext i dsimp [SwapTrue, Proj] split_ifs with hi h · rw [ord_term ho] at hi rw [← hx.2, hi] · rfl · simp only [not_lt] at h have h' : o < ord I i := lt_of_le_of_ne h (Ne.symm hi) specialize hsC x hx.1 i rw [← not_imp_not] at hsC simp only [not_lt, Bool.not_eq_true, Order.succ_le_iff] at hsC exact (hsC h').symm open scoped Classical in theorem CC_exact {f : LocallyConstant C ℤ} (hf : Linear_CC' C hsC ho f = 0) : ∃ y, πs C o y = f := by dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁] at hf simp only [sub_eq_zero, ← LocallyConstant.coe_inj, LocallyConstant.coe_comap, continuous_CC'₀, continuous_CC'₁] at hf let C₀C : C0 C ho → C := fun x ↦ ⟨x.val, x.prop.1⟩ have h₀ : Continuous C₀C := Continuous.subtype_mk continuous_induced_dom _ let C₁C : π (C1 C ho) (ord I · < o) → C := fun x ↦ ⟨SwapTrue o x.val, (swapTrue_mem_C1 C hsC ho x).1⟩ have h₁ : Continuous C₁C := Continuous.subtype_mk ((continuous_swapTrue o).comp continuous_subtype_val) _ refine ⟨LocallyConstant.piecewise' ?_ (isClosed_C0 C hC ho) (isClosed_proj _ o (isClosed_C1 C hC ho)) (f.comap ⟨C₀C, h₀⟩) (f.comap ⟨C₁C, h₁⟩) ?_, ?_⟩ · rintro _ ⟨y, hyC, rfl⟩ simp only [Set.mem_union, Set.mem_setOf_eq, Set.mem_univ, iff_true] rw [← union_C0C1_eq C ho] at hyC refine hyC.imp (fun hyC ↦ ?_) (fun hyC ↦ ⟨y, hyC, rfl⟩) rwa [C0_projOrd C hsC ho hyC] · intro x hx simpa only [h₀, h₁, LocallyConstant.coe_comap] using (congrFun hf ⟨x, hx⟩).symm · ext ⟨x, hx⟩ rw [← union_C0C1_eq C ho] at hx cases' hx with hx₀ hx₁ · have hx₀' : ProjRestrict C (ord I · < o) ⟨x, hx⟩ = x := by simpa only [ProjRestrict, Set.MapsTo.val_restrict_apply] using C0_projOrd C hsC ho hx₀ simp only [πs_apply_apply, hx₀', hx₀, LocallyConstant.piecewise'_apply_left, LocallyConstant.coe_comap, ContinuousMap.coe_mk, Function.comp_apply] · have hx₁' : (ProjRestrict C (ord I · < o) ⟨x, hx⟩).val ∈ π (C1 C ho) (ord I · < o) := by simpa only [ProjRestrict, Set.MapsTo.val_restrict_apply] using ⟨x, hx₁, rfl⟩ simp only [C₁C, πs_apply_apply, continuous_projRestrict, LocallyConstant.coe_comap, Function.comp_apply, hx₁', LocallyConstant.piecewise'_apply_right, h₁] congr simp only [ContinuousMap.coe_mk, Subtype.mk.injEq] exact C1_projOrd C hsC ho hx₁ variable (o) in theorem succ_mono : CategoryTheory.Mono (ModuleCat.ofHom (πs C o)) := by rw [ModuleCat.mono_iff_injective] exact injective_πs _ _ theorem succ_exact : (ShortComplex.mk (ModuleCat.ofHom (πs C o)) (ModuleCat.ofHom (Linear_CC' C hsC ho)) (by ext; apply CC_comp_zero)).Exact := by rw [ShortComplex.moduleCat_exact_iff] intro f exact CC_exact C hC hsC ho end ExactSequence section GoodProducts namespace GoodProducts /-- The `GoodProducts` in `C` that contain `o` (they necessarily start with `o`, see `GoodProducts.head!_eq_o_of_maxProducts`) -/ def MaxProducts : Set (Products I) := {l | l.isGood C ∧ term I ho ∈ l.val} theorem union_succ : GoodProducts C = GoodProducts (π C (ord I · < o)) ∪ MaxProducts C ho := by ext l simp only [GoodProducts, MaxProducts, Set.mem_union, Set.mem_setOf_eq] refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩ · by_cases hh : term I ho ∈ l.val · exact Or.inr ⟨h, hh⟩ · left intro he apply h have h' := Products.prop_of_isGood_of_contained C _ h hsC simp only [Order.lt_succ_iff] at h' simp only [not_imp_not] at hh have hh' : ∀ a ∈ l.val, ord I a < o := by intro a ha refine (h' a ha).lt_of_ne ?_ rw [ne_eq, ord_term ho a] rintro rfl contradiction rwa [Products.eval_πs_image C hh', ← Products.eval_πs C hh', Submodule.apply_mem_span_image_iff_mem_span (injective_πs _ _)] · refine h.elim (fun hh ↦ ?_) And.left have := Products.isGood_mono C (Order.lt_succ o).le hh rwa [contained_eq_proj C (Order.succ o) hsC] /-- The inclusion map from the sum of `GoodProducts (π C (ord I · < o))` and `(MaxProducts C ho)` to `Products I`. -/ def sum_to : (GoodProducts (π C (ord I · < o))) ⊕ (MaxProducts C ho) → Products I := Sum.elim Subtype.val Subtype.val theorem injective_sum_to : Function.Injective (sum_to C ho) := by refine Function.Injective.sum_elim Subtype.val_injective Subtype.val_injective (fun ⟨a,ha⟩ ⟨b,hb⟩ ↦ (fun (hab : a = b) ↦ ?_)) rw [← hab] at hb have ha' := Products.prop_of_isGood C _ ha (term I ho) hb.2 simp only [ord_term_aux, lt_self_iff_false] at ha' theorem sum_to_range : Set.range (sum_to C ho) = GoodProducts (π C (ord I · < o)) ∪ MaxProducts C ho := by have h : Set.range (sum_to C ho) = _ ∪ _ := Set.Sum.elim_range _ _; rw [h]; congr<;> ext l · exact ⟨fun ⟨m,hm⟩ ↦ by rw [← hm]; exact m.prop, fun hl ↦ ⟨⟨l,hl⟩, rfl⟩⟩ · exact ⟨fun ⟨m,hm⟩ ↦ by rw [← hm]; exact m.prop, fun hl ↦ ⟨⟨l,hl⟩, rfl⟩⟩ /-- The equivalence from the sum of `GoodProducts (π C (ord I · < o))` and `(MaxProducts C ho)` to `GoodProducts C`. -/ noncomputable def sum_equiv : GoodProducts (π C (ord I · < o)) ⊕ (MaxProducts C ho) ≃ GoodProducts C := calc _ ≃ Set.range (sum_to C ho) := Equiv.ofInjective (sum_to C ho) (injective_sum_to C ho) _ ≃ _ := Equiv.Set.ofEq <| by rw [sum_to_range C ho, union_succ C hsC ho] theorem sum_equiv_comp_eval_eq_elim : eval C ∘ (sum_equiv C hsC ho).toFun = (Sum.elim (fun (l : GoodProducts (π C (ord I · < o))) ↦ Products.eval C l.1) (fun (l : MaxProducts C ho) ↦ Products.eval C l.1)) := by ext ⟨_,_⟩ <;> [rfl; rfl] /-- Let `N := LocallyConstant (π C (ord I · < o)) ℤ` `M := LocallyConstant C ℤ` `P := LocallyConstant (C' C ho) ℤ` `ι := GoodProducts (π C (ord I · < o))` `ι' := GoodProducts (C' C ho')` `v : ι → N := GoodProducts.eval (π C (ord I · < o))` Then `SumEval C ho` is the map `u` in the diagram below. It is linearly independent if and only if `GoodProducts.eval C` is, see `linearIndependent_iff_sum`. The top row is the exact sequence given by `succ_exact` and `succ_mono`. The left square commutes by `GoodProducts.square_commutes`. ``` 0 --→ N --→ M --→ P ↑ ↑ ↑ v| u| | ι → ι ⊕ ι' ← ι' ``` -/ def SumEval : GoodProducts (π C (ord I · < o)) ⊕ MaxProducts C ho → LocallyConstant C ℤ := Sum.elim (fun l ↦ l.1.eval C) (fun l ↦ l.1.eval C) theorem linearIndependent_iff_sum : LinearIndependent ℤ (eval C) ↔ LinearIndependent ℤ (SumEval C ho) := by rw [← linearIndependent_equiv (sum_equiv C hsC ho), SumEval, ← sum_equiv_comp_eval_eq_elim C hsC ho] exact Iff.rfl theorem span_sum : Set.range (eval C) = Set.range (Sum.elim (fun (l : GoodProducts (π C (ord I · < o))) ↦ Products.eval C l.1) (fun (l : MaxProducts C ho) ↦ Products.eval C l.1)) := by rw [← sum_equiv_comp_eval_eq_elim C hsC ho, Equiv.toFun_as_coe, EquivLike.range_comp (e := sum_equiv C hsC ho)] theorem square_commutes : SumEval C ho ∘ Sum.inl = ModuleCat.ofHom (πs C o) ∘ eval (π C (ord I · < o)) := by ext l dsimp [SumEval] rw [← Products.eval_πs C (Products.prop_of_isGood _ _ l.prop)] rfl end GoodProducts theorem swapTrue_eq_true (x : I → Bool) : SwapTrue o x (term I ho) = true := by simp only [SwapTrue, ord_term_aux, ite_true] theorem mem_C'_eq_false : ∀ x, x ∈ C' C ho → x (term I ho) = false := by rintro x ⟨_, y, _, rfl⟩ simp only [Proj, ord_term_aux, lt_self_iff_false, ite_false] /-- `List.tail` as a `Products`. -/ def Products.Tail (l : Products I) : Products I := ⟨l.val.tail, List.Chain'.tail l.prop⟩ theorem Products.max_eq_o_cons_tail [Inhabited I] (l : Products I) (hl : l.val ≠ []) (hlh : l.val.head! = term I ho) : l.val = term I ho :: l.Tail.val := by rw [← List.cons_head!_tail hl, hlh] rfl theorem Products.max_eq_o_cons_tail' [Inhabited I] (l : Products I) (hl : l.val ≠ []) (hlh : l.val.head! = term I ho) (hlc : List.Chain' (·>·) (term I ho :: l.Tail.val)) : l = ⟨term I ho :: l.Tail.val, hlc⟩ := by simp_rw [← max_eq_o_cons_tail ho l hl hlh] rfl theorem GoodProducts.head!_eq_o_of_maxProducts [Inhabited I] (l : ↑(MaxProducts C ho)) : l.val.val.head! = term I ho := by rw [eq_comm, ← ord_term ho] have hm := l.prop.2 have := Products.prop_of_isGood_of_contained C _ l.prop.1 hsC l.val.val.head! (List.head!_mem_self (List.ne_nil_of_mem hm)) simp only [Order.lt_succ_iff] at this refine eq_of_le_of_not_lt this (not_lt.mpr ?_) have h : ord I (term I ho) ≤ ord I l.val.val.head! := by simp only [← ord_term_aux, ord, Ordinal.typein_le_typein, not_lt] exact Products.rel_head!_of_mem hm rwa [ord_term_aux] at h theorem GoodProducts.max_eq_o_cons_tail (l : MaxProducts C ho) : l.val.val = (term I ho) :: l.val.Tail.val := have : Inhabited I := ⟨term I ho⟩ Products.max_eq_o_cons_tail ho l.val (List.ne_nil_of_mem l.prop.2) (head!_eq_o_of_maxProducts _ hsC ho l) theorem Products.evalCons {l : List I} {a : I} (hla : (a::l).Chain' (·>·)) : Products.eval C ⟨a::l,hla⟩ = (e C a) * Products.eval C ⟨l,List.Chain'.sublist hla (List.tail_sublist (a::l))⟩ := by simp only [eval.eq_1, List.map, List.prod_cons] theorem Products.max_eq_eval [Inhabited I] (l : Products I) (hl : l.val ≠ []) (hlh : l.val.head! = term I ho) : Linear_CC' C hsC ho (l.eval C) = l.Tail.eval (C' C ho) := by have hlc : ((term I ho) :: l.Tail.val).Chain' (·>·) := by rw [← max_eq_o_cons_tail ho l hl hlh]; exact l.prop rw [max_eq_o_cons_tail' ho l hl hlh hlc, Products.evalCons] ext x simp only [Linear_CC', Linear_CC'₁, LocallyConstant.comapₗ, Linear_CC'₀, Subtype.coe_eta, LinearMap.sub_apply, LinearMap.coe_mk, AddHom.coe_mk, LocallyConstant.sub_apply, LocallyConstant.coe_comap, LocallyConstant.coe_mul, ContinuousMap.coe_mk, Function.comp_apply, Pi.mul_apply] rw [CC'₁, CC'₀, Products.eval_eq, Products.eval_eq, Products.eval_eq] simp only [mul_ite, mul_one, mul_zero] have hi' : ∀ i, i ∈ l.Tail.val → (x.val i = SwapTrue o x.val i) := by intro i hi simp only [SwapTrue, @eq_comm _ (x.val i), ite_eq_right_iff, ord_term ho] rintro rfl exact ((List.Chain.rel hlc hi).ne rfl).elim have H : (∀ i, i ∈ l.Tail.val → (x.val i = true)) = (∀ i, i ∈ l.Tail.val → (SwapTrue o x.val i = true)) := by apply forall_congr; intro i; apply forall_congr; intro hi; rw [hi' i hi] simp only [H] split_ifs with h₁ h₂ h₃ <;> try (dsimp [e]) · rw [if_pos (swapTrue_eq_true _ _), if_neg] · rfl · simp [mem_C'_eq_false C ho x x.prop, Bool.coe_false] · push_neg at h₂; obtain ⟨i, hi⟩ := h₂; exfalso; rw [hi' i hi.1] at hi; exact hi.2 (h₁ i hi.1) · push_neg at h₁; obtain ⟨i, hi⟩ := h₁; exfalso; rw [← hi' i hi.1] at hi; exact hi.2 (h₃ i hi.1) namespace GoodProducts theorem max_eq_eval (l : MaxProducts C ho) : Linear_CC' C hsC ho (l.val.eval C) = l.val.Tail.eval (C' C ho) := have : Inhabited I := ⟨term I ho⟩ Products.max_eq_eval _ _ _ _ (List.ne_nil_of_mem l.prop.2) (head!_eq_o_of_maxProducts _ hsC ho l) theorem max_eq_eval_unapply : (Linear_CC' C hsC ho) ∘ (fun (l : MaxProducts C ho) ↦ Products.eval C l.val) = (fun l ↦ l.val.Tail.eval (C' C ho)) := by ext1 l exact max_eq_eval _ _ _ _ theorem chain'_cons_of_lt (l : MaxProducts C ho) (q : Products I) (hq : q < l.val.Tail) : List.Chain' (fun x x_1 ↦ x > x_1) (term I ho :: q.val) := by have : Inhabited I := ⟨term I ho⟩ rw [List.chain'_iff_pairwise] simp only [gt_iff_lt, List.pairwise_cons] refine ⟨fun a ha ↦ lt_of_le_of_lt (Products.rel_head!_of_mem ha) ?_, List.chain'_iff_pairwise.mp q.prop⟩ refine lt_of_le_of_lt (Products.head!_le_of_lt hq (q.val.ne_nil_of_mem ha)) ?_ by_cases hM : l.val.Tail.val = [] · rw [Products.lt_iff_lex_lt, hM] at hq simp only [List.Lex.not_nil_right] at hq · have := l.val.prop rw [max_eq_o_cons_tail C hsC ho l, List.chain'_iff_pairwise] at this exact List.rel_of_pairwise_cons this (List.head!_mem_self hM) theorem good_lt_maxProducts (q : GoodProducts (π C (ord I · < o))) (l : MaxProducts C ho) : List.Lex (·<·) q.val.val l.val.val := by have : Inhabited I := ⟨term I ho⟩ by_cases h : q.val.val = [] · rw [h, max_eq_o_cons_tail C hsC ho l] exact List.Lex.nil · rw [← List.cons_head!_tail h, max_eq_o_cons_tail C hsC ho l] apply List.Lex.rel rw [← Ordinal.typein_lt_typein (·<·)] simp only [term, Ordinal.typein_enum] exact Products.prop_of_isGood C _ q.prop q.val.val.head! (List.head!_mem_self h) /-- Removing the leading `o` from a term of `MaxProducts C` yields a list which `isGood` with respect to `C'`. -/ theorem maxTail_isGood (l : MaxProducts C ho) (h₁ : ⊤ ≤ Submodule.span ℤ (Set.range (eval (π C (ord I · < o))))) : l.val.Tail.isGood (C' C ho) := by have : Inhabited I := ⟨term I ho⟩ -- Write `l.Tail` as a linear combination of smaller products: intro h rw [Finsupp.mem_span_image_iff_total, ← max_eq_eval C hsC ho] at h obtain ⟨m, ⟨hmmem, hmsum⟩⟩ := h rw [Finsupp.total_apply] at hmsum -- Write the image of `l` under `Linear_CC'` as `Linear_CC'` applied to the linear combination -- above, with leading `term I ho`'s added to each term: have : (Linear_CC' C hsC ho) (l.val.eval C) = (Linear_CC' C hsC ho) (Finsupp.sum m fun i a ↦ a • ((term I ho :: i.1).map (e C)).prod) := by rw [← hmsum] simp only [map_finsupp_sum] apply Finsupp.sum_congr intro q hq rw [LinearMap.map_smul] rw [Finsupp.mem_supported] at hmmem have hx'' : q < l.val.Tail := hmmem hq have : ∃ (p : Products I), p.val ≠ [] ∧ p.val.head! = term I ho ∧ q = p.Tail := ⟨⟨term I ho :: q.val, chain'_cons_of_lt C hsC ho l q hx''⟩, ⟨List.cons_ne_nil _ _, by simp only [List.head!_cons], by simp only [Products.Tail, List.tail_cons, Subtype.coe_eta]⟩⟩ obtain ⟨p, hp⟩ := this rw [hp.2.2, ← Products.max_eq_eval C hsC ho p hp.1 hp.2.1] dsimp [Products.eval] rw [Products.max_eq_o_cons_tail ho p hp.1 hp.2.1] rfl have hse := succ_exact C hC hsC ho rw [ShortComplex.moduleCat_exact_iff_range_eq_ker] at hse dsimp [ModuleCat.ofHom] at hse -- Rewrite `this` using exact sequence manipulations to conclude that a term is in the range of -- the linear map `πs`: rw [← LinearMap.sub_mem_ker_iff, ← hse] at this obtain ⟨(n : LocallyConstant (π C (ord I · < o)) ℤ), hn⟩ := this rw [eq_sub_iff_add_eq] at hn have hn' := h₁ (Submodule.mem_top : n ∈ ⊤) rw [Finsupp.mem_span_range_iff_exists_finsupp] at hn' obtain ⟨w,hc⟩ := hn' rw [← hc, map_finsupp_sum] at hn apply l.prop.1 rw [← hn] -- Now we just need to prove that a sum of two terms belongs to a span: apply Submodule.add_mem · apply Submodule.finsupp_sum_mem intro q _ erw [LinearMap.map_smul (fₗ := πs C o) (c := w q) (x := eval (π C (ord I · < o)) q)] apply Submodule.smul_mem apply Submodule.subset_span dsimp only [eval] rw [Products.eval_πs C (Products.prop_of_isGood _ _ q.prop)] refine ⟨q.val, ⟨?_, rfl⟩⟩ simp only [Products.lt_iff_lex_lt, Set.mem_setOf_eq] exact good_lt_maxProducts C hsC ho q l · apply Submodule.finsupp_sum_mem intro q hq apply Submodule.smul_mem apply Submodule.subset_span rw [Finsupp.mem_supported] at hmmem rw [← Finsupp.mem_support_iff] at hq refine ⟨⟨term I ho :: q.val, chain'_cons_of_lt C hsC ho l q (hmmem hq)⟩, ⟨?_, rfl⟩⟩ simp only [Products.lt_iff_lex_lt, Set.mem_setOf_eq] rw [max_eq_o_cons_tail C hsC ho l] exact List.Lex.cons ((Products.lt_iff_lex_lt q l.val.Tail).mp (hmmem hq)) /-- Given `l : MaxProducts C ho`, its `Tail` is a `GoodProducts (C' C ho)`. -/ noncomputable def MaxToGood (h₁ : ⊤ ≤ Submodule.span ℤ (Set.range (eval (π C (ord I · < o))))) : MaxProducts C ho → GoodProducts (C' C ho) := fun l ↦ ⟨l.val.Tail, maxTail_isGood C hC hsC ho l h₁⟩ theorem maxToGood_injective (h₁ : ⊤ ≤ Submodule.span ℤ (Set.range (eval (π C (ord I · < o))))) : (MaxToGood C hC hsC ho h₁).Injective := by intro m n h apply Subtype.ext ∘ Subtype.ext rw [Subtype.ext_iff] at h dsimp [MaxToGood] at h rw [max_eq_o_cons_tail C hsC ho m, max_eq_o_cons_tail C hsC ho n, h] theorem linearIndependent_comp_of_eval (h₁ : ⊤ ≤ Submodule.span ℤ (Set.range (eval (π C (ord I · < o))))) : LinearIndependent ℤ (eval (C' C ho)) → LinearIndependent ℤ (ModuleCat.ofHom (Linear_CC' C hsC ho) ∘ SumEval C ho ∘ Sum.inr) := by dsimp [SumEval, ModuleCat.ofHom] erw [max_eq_eval_unapply C hsC ho] intro h let f := MaxToGood C hC hsC ho h₁ have hf : f.Injective := maxToGood_injective C hC hsC ho h₁ have hh : (fun l ↦ Products.eval (C' C ho) l.val.Tail) = eval (C' C ho) ∘ f := rfl rw [hh] exact h.comp f hf end GoodProducts end GoodProducts end Successor section Induction /-! ## The induction Here we put together the results of the sections `Zero`, `Limit` and `Successor` to prove the predicate `P I o` holds for all ordinals `o`, and conclude with the main result: * `GoodProducts.linearIndependent` which says that `GoodProducts C` is linearly independent when `C` is closed. We also define * `GoodProducts.Basis` which uses `GoodProducts.linearIndependent` and `GoodProducts.span` to define a basis for `LocallyConstant C ℤ`  -/ theorem GoodProducts.P0 : P I 0 := fun _ C _ hsC ↦ by have : C ⊆ {(fun _ ↦ false)} := fun c hc ↦ by ext x; exact Bool.eq_false_iff.mpr (fun ht ↦ (Ordinal.not_lt_zero (ord I x)) (hsC c hc x ht)) rw [Set.subset_singleton_iff_eq] at this cases this · subst C exact linearIndependentEmpty · subst C exact linearIndependentSingleton theorem GoodProducts.Plimit (o : Ordinal) (ho : Ordinal.IsLimit o) : (∀ (o' : Ordinal), o' < o → P I o') → P I o := by intro h hho C hC hsC rw [linearIndependent_iff_union_smaller C ho hsC] exact linearIndependent_iUnion_of_directed (Monotone.directed_le fun _ _ h ↦ GoodProducts.smaller_mono C h) fun ⟨o', ho'⟩ ↦ (linearIndependent_iff_smaller _ _).mp (h o' ho' (le_of_lt (lt_of_lt_of_le ho' hho)) (π C (ord I · < o')) (isClosed_proj _ _ hC) (contained_proj _ _)) theorem GoodProducts.linearIndependentAux (μ : Ordinal) : P I μ := by refine Ordinal.limitRecOn μ P0 (fun o h ho C hC hsC ↦ ?_) (fun o ho h ↦ (GoodProducts.Plimit o ho (fun o' ho' ↦ (h o' ho')))) have ho' : o < Ordinal.type (·<· : I → I → Prop) := lt_of_lt_of_le (Order.lt_succ _) ho rw [linearIndependent_iff_sum C hsC ho'] refine ModuleCat.linearIndependent_leftExact (succ_exact C hC hsC ho') ?_ ?_ (succ_mono C o) (square_commutes C ho') · exact h (le_of_lt ho') (π C (ord I · < o)) (isClosed_proj C o hC) (contained_proj C o) · exact linearIndependent_comp_of_eval C hC hsC ho' (span (π C (ord I · < o)) (isClosed_proj C o hC)) (h (le_of_lt ho') (C' C ho') (isClosed_C' C hC ho') (contained_C' C ho')) theorem GoodProducts.linearIndependent (hC : IsClosed C) : LinearIndependent ℤ (GoodProducts.eval C) := GoodProducts.linearIndependentAux (Ordinal.type (·<· : I → I → Prop)) (le_refl _) C hC (fun _ _ _ _ ↦ Ordinal.typein_lt_type _ _) /-- `GoodProducts C` as a `ℤ`-basis for `LocallyConstant C ℤ`. -/ noncomputable def GoodProducts.Basis (hC : IsClosed C) : Basis (GoodProducts C) ℤ (LocallyConstant C ℤ) := Basis.mk (GoodProducts.linearIndependent C hC) (GoodProducts.span C hC) end Induction variable {S : Profinite} {ι : S → I → Bool} (hι : ClosedEmbedding ι) /-- Given a profinite set `S` and a closed embedding `S → (I → Bool)`, the `ℤ`-module `LocallyConstant C ℤ` is free. -/ theorem Nobeling_aux : Module.Free ℤ (LocallyConstant S ℤ) := Module.Free.of_equiv' (Module.Free.of_basis <| GoodProducts.Basis _ hι.isClosed_range) (LocallyConstant.congrLeftₗ ℤ (Homeomorph.ofEmbedding ι hι.toEmbedding)).symm end NobelingProof variable (S : Profinite.{u}) open scoped Classical in /-- The embedding `S → (I → Bool)` where `I` is the set of clopens of `S`. -/ noncomputable def Nobeling.ι : S → ({C : Set S // IsClopen C} → Bool) := fun s C => decide (s ∈ C.1) open scoped Classical in /-- The map `Nobeling.ι` is a closed embedding. -/ theorem Nobeling.embedding : ClosedEmbedding (Nobeling.ι S) := by apply Continuous.closedEmbedding · dsimp (config := { unfoldPartialApp := true }) [ι] refine continuous_pi ?_ intro C rw [← IsLocallyConstant.iff_continuous] refine ((IsLocallyConstant.tfae _).out 0 3).mpr ?_ rintro ⟨⟩ · refine IsClopen.isOpen (isClopen_compl_iff.mp ?_) convert C.2 ext x simp only [Set.mem_compl_iff, Set.mem_preimage, Set.mem_singleton_iff, decide_eq_false_iff_not, not_not] · refine IsClopen.isOpen ?_ convert C.2 ext x simp only [Set.mem_preimage, Set.mem_singleton_iff, decide_eq_true_eq] · intro a b h by_contra hn obtain ⟨C, hC, hh⟩ := exists_isClopen_of_totally_separated hn apply hh.2 ∘ of_decide_eq_true dsimp (config := { unfoldPartialApp := true }) [ι] at h rw [← congr_fun h ⟨C, hC⟩] exact decide_eq_true hh.1 end Profinite open Profinite NobelingProof /-- Nöbeling's theorem: the `ℤ`-module `LocallyConstant S ℤ` is free for every `S : Profinite` -/ instance LocallyConstant.freeOfProfinite (S : Profinite.{u}) : Module.Free ℤ (LocallyConstant S ℤ) := @Nobeling_aux {C : Set S // IsClopen C} (IsWellOrder.linearOrder WellOrderingRel) WellOrderingRel.isWellOrder S (Nobeling.ι S) (Nobeling.embedding S)
Topology\Category\Profinite\Product.lean
/- Copyright (c) 2023 Dagur Asgeirsson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Dagur Asgeirsson -/ import Mathlib.Topology.Category.Profinite.Basic /-! # Compact subsets of products as limits in `Profinite` This file exhibits a compact subset `C` of a product `(i : ι) → X i` of totally disconnected Hausdorff spaces as a cofiltered limit in `Profinite` indexed by `Finset ι`. ## Main definitions - `Profinite.indexFunctor` is the functor `(Finset ι)ᵒᵖ ⥤ Profinite` indexing the limit. It maps `J` to the restriction of `C` to `J` - `Profinite.indexCone` is a cone on `Profinite.indexFunctor` with cone point `C` ## Main results - `Profinite.isIso_indexCone_lift` says that the natural map from the cone point of the explicit limit cone in `Profinite` on `indexFunctor` to the cone point of `indexCone` is an isomorphism - `Profinite.asLimitindexConeIso` is the induced isomorphism of cones. - `Profinite.indexCone_isLimit` says that `indexCone` is a limit cone. -/ universe u namespace Profinite variable {ι : Type u} {X : ι → Type} [∀ i, TopologicalSpace (X i)] (C : Set ((i : ι) → X i)) (J K : ι → Prop) namespace IndexFunctor open ContinuousMap /-- The object part of the functor `indexFunctor : (Finset ι)ᵒᵖ ⥤ Profinite`. -/ def obj : Set ((i : {i : ι // J i}) → X i) := ContinuousMap.precomp (Subtype.val (p := J)) '' C /-- The projection maps in the limit cone `indexCone`. -/ def π_app : C(C, obj C J) := ⟨Set.MapsTo.restrict (precomp (Subtype.val (p := J))) _ _ (Set.mapsTo_image _ _), Continuous.restrict _ (Pi.continuous_precomp' _)⟩ variable {J K} /-- The morphism part of the functor `indexFunctor : (Finset ι)ᵒᵖ ⥤ Profinite`. -/ def map (h : ∀ i, J i → K i) : C(obj C K, obj C J) := ⟨Set.MapsTo.restrict (precomp (Set.inclusion h)) _ _ (fun _ hx ↦ by obtain ⟨y, hy⟩ := hx rw [← hy.2] exact ⟨y, hy.1, rfl⟩), Continuous.restrict _ (Pi.continuous_precomp' _)⟩ theorem surjective_π_app : Function.Surjective (π_app C J) := by intro x obtain ⟨y, hy⟩ := x.prop exact ⟨⟨y, hy.1⟩, Subtype.ext hy.2⟩ theorem map_comp_π_app (h : ∀ i, J i → K i) : map C h ∘ π_app C K = π_app C J := rfl variable {C} theorem eq_of_forall_π_app_eq (a b : C) (h : ∀ (J : Finset ι), π_app C (· ∈ J) a = π_app C (· ∈ J) b) : a = b := by ext i specialize h ({i} : Finset ι) rw [Subtype.ext_iff] at h simp only [π_app, ContinuousMap.precomp, ContinuousMap.coe_mk, Set.MapsTo.val_restrict_apply] at h exact congr_fun h ⟨i, Finset.mem_singleton.mpr rfl⟩ end IndexFunctor variable [∀ i, T2Space (X i)] [∀ i, TotallyDisconnectedSpace (X i)] variable {C} variable (hC : IsCompact C) open CategoryTheory Limits Opposite IndexFunctor /-- The functor from the poset of finsets of `ι` to `Profinite`, indexing the limit. -/ noncomputable def indexFunctor : (Finset ι)ᵒᵖ ⥤ Profinite.{u} where obj J := @Profinite.of (obj C (· ∈ (unop J))) _ (by rw [← isCompact_iff_compactSpace]; exact hC.image (Pi.continuous_precomp' _)) _ _ map h := map C (leOfHom h.unop) /-- The limit cone on `indexFunctor` -/ noncomputable def indexCone : Cone (indexFunctor hC) where pt := @Profinite.of C _ (by rwa [← isCompact_iff_compactSpace]) _ _ π := { app := fun J ↦ π_app C (· ∈ unop J) } instance isIso_indexCone_lift : IsIso ((limitConeIsLimit.{u, u} (indexFunctor hC)).lift (indexCone hC)) := haveI : CompactSpace C := by rwa [← isCompact_iff_compactSpace] CompHausLike.isIso_of_bijective _ (by refine ⟨fun a b h ↦ ?_, fun a ↦ ?_⟩ · refine eq_of_forall_π_app_eq a b (fun J ↦ ?_) apply_fun fun f : (limitCone.{u, u} (indexFunctor hC)).pt => f.val (op J) at h exact h · rsuffices ⟨b, hb⟩ : ∃ (x : C), ∀ (J : Finset ι), π_app C (· ∈ J) x = a.val (op J) · use b apply Subtype.ext apply funext intro J exact hb (unop J) have hc : ∀ (J : Finset ι) s, IsClosed ((π_app C (· ∈ J)) ⁻¹' {s}) := by intro J s refine IsClosed.preimage (π_app C (· ∈ J)).continuous ?_ exact T1Space.t1 s have H₁ : ∀ (Q₁ Q₂ : Finset ι), Q₁ ≤ Q₂ → π_app C (· ∈ Q₁) ⁻¹' {a.val (op Q₁)} ⊇ π_app C (· ∈ Q₂) ⁻¹' {a.val (op Q₂)} := by intro J K h x hx simp only [Set.mem_preimage, Set.mem_singleton_iff] at hx ⊢ rw [← map_comp_π_app C h, Function.comp_apply, hx, ← a.prop (homOfLE h).op] rfl obtain ⟨x, hx⟩ : Set.Nonempty (⋂ (J : Finset ι), π_app C (· ∈ J) ⁻¹' {a.val (op J)}) := IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed (fun J : Finset ι => π_app C (· ∈ J) ⁻¹' {a.val (op J)}) (directed_of_isDirected_le H₁) (fun J => (Set.singleton_nonempty _).preimage (surjective_π_app _)) (fun J => (hc J (a.val (op J))).isCompact) fun J => hc J (a.val (op J)) exact ⟨x, Set.mem_iInter.1 hx⟩) /-- The canonical map from `C` to the explicit limit as an isomorphism. -/ noncomputable def isoindexConeLift : @Profinite.of C _ (by rwa [← isCompact_iff_compactSpace]) _ _ ≅ (Profinite.limitCone.{u, u} (indexFunctor hC)).pt := asIso <| (Profinite.limitConeIsLimit.{u, u} _).lift (indexCone hC) /-- The isomorphism of cones induced by `isoindexConeLift`. -/ noncomputable def asLimitindexConeIso : indexCone hC ≅ Profinite.limitCone.{u, u} _ := Limits.Cones.ext (isoindexConeLift hC) fun _ => rfl /-- `indexCone` is a limit cone. -/ noncomputable def indexCone_isLimit : CategoryTheory.Limits.IsLimit (indexCone hC) := Limits.IsLimit.ofIsoLimit (Profinite.limitConeIsLimit _) (asLimitindexConeIso hC).symm end Profinite
Topology\Category\Profinite\Projective.lean
/- Copyright (c) 2021 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.Topology.Category.Profinite.Basic import Mathlib.Topology.StoneCech import Mathlib.CategoryTheory.Preadditive.Projective import Mathlib.CategoryTheory.ConcreteCategory.EpiMono /-! # Profinite sets have enough projectives In this file we show that `Profinite` has enough projectives. ## Main results Let `X` be a profinite set. * `Profinite.projective_ultrafilter`: the space `Ultrafilter X` is a projective object * `Profinite.projectivePresentation`: the natural map `Ultrafilter X → X` is a projective presentation -/ noncomputable section universe u v w open CategoryTheory Function -- This was a global instance prior to #13170. We may experiment with removing it. attribute [local instance] ConcreteCategory.instFunLike namespace Profinite instance projective_ultrafilter (X : Type u) : Projective (of <| Ultrafilter X) where factors {Y Z} f g hg := by rw [epi_iff_surjective] at hg obtain ⟨g', hg'⟩ := hg.hasRightInverse let t : X → Y := g' ∘ f ∘ (pure : X → Ultrafilter X) let h : Ultrafilter X → Y := Ultrafilter.extend t have hh : Continuous h := continuous_ultrafilter_extend _ use ⟨h, hh⟩ apply (forget Profinite).map_injective simp only [h, ContinuousMap.coe_mk, coe_comp] convert denseRange_pure.equalizer (g.continuous.comp hh) f.continuous _ -- Porting note: same fix as in `Topology.Category.CompHaus.Projective` let g'' : ContinuousMap Y Z := g have : g'' ∘ g' = id := hg'.comp_eq_id -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [comp.assoc, ultrafilter_extend_extends, ← comp.assoc, this, id_comp] /-- For any profinite `X`, the natural map `Ultrafilter X → X` is a projective presentation. -/ def projectivePresentation (X : Profinite.{u}) : ProjectivePresentation X where p := of <| Ultrafilter X f := ⟨_, continuous_ultrafilter_extend id⟩ projective := Profinite.projective_ultrafilter X epi := ConcreteCategory.epi_of_surjective _ fun x => ⟨(pure x : Ultrafilter X), congr_fun (ultrafilter_extend_extends (𝟙 X)) x⟩ instance : EnoughProjectives Profinite.{u} where presentation X := ⟨projectivePresentation X⟩ end Profinite
Topology\Category\Stonean\Adjunctions.lean
/- Copyright (c) 2023 Dagur Asgeirsson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Dagur Asgeirsson -/ import Mathlib.Topology.Category.Stonean.Basic import Mathlib.Topology.Category.TopCat.Adjunctions import Mathlib.Topology.StoneCech /-! # Adjunctions involving the category of Stonean spaces This file constructs the left adjoint `typeToStonean` to the forgetful functor from Stonean spaces to sets, using the Stone-Cech compactification. This allows to conclude that the monomorphisms in `Stonean` are precisely the injective maps (see `Stonean.mono_iff_injective`). -/ universe u open CategoryTheory Adjunction namespace Stonean /-- The object part of the compactification functor from types to Stonean spaces. -/ def stoneCechObj (X : Type u) : Stonean := letI : TopologicalSpace X := ⊥ haveI : DiscreteTopology X := ⟨rfl⟩ haveI : ExtremallyDisconnected (StoneCech X) := CompactT2.Projective.extremallyDisconnected StoneCech.projective of (StoneCech X) /-- The equivalence of homsets to establish the adjunction between the Stone-Cech compactification functor and the forgetful functor. -/ noncomputable def stoneCechEquivalence (X : Type u) (Y : Stonean.{u}) : (stoneCechObj X ⟶ Y) ≃ (X ⟶ (forget Stonean).obj Y) := by letI : TopologicalSpace X := ⊥ haveI : DiscreteTopology X := ⟨rfl⟩ refine fullyFaithfulToCompHaus.homEquiv.trans ?_ exact (_root_.stoneCechEquivalence (TopCat.of X) (toCompHaus.obj Y)).trans (TopCat.adj₁.homEquiv _ _) end Stonean /-- The Stone-Cech compactification functor from types to Stonean spaces. -/ noncomputable def typeToStonean : Type u ⥤ Stonean.{u} := leftAdjointOfEquiv Stonean.stoneCechEquivalence fun _ _ _ _ _ => rfl namespace Stonean /-- The Stone-Cech compactification functor is left adjoint to the forgetful functor. -/ noncomputable def stoneCechAdjunction : typeToStonean ⊣ (forget Stonean) := adjunctionOfEquivLeft stoneCechEquivalence fun _ _ _ _ _ => rfl /-- The forgetful functor from Stonean spaces, being a right adjoint, preserves limits. -/ noncomputable instance forget.preservesLimits : Limits.PreservesLimits (forget Stonean) := rightAdjointPreservesLimits stoneCechAdjunction end Stonean
Topology\Category\Stonean\Basic.lean
/- Copyright (c) 2023 Adam Topaz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Adam Topaz -/ import Mathlib.Topology.ExtremallyDisconnected import Mathlib.Topology.Category.CompHaus.Projective import Mathlib.Topology.Category.Profinite.Basic /-! # Extremally disconnected sets This file develops some of the basic theory of extremally disconnected compact Hausdorff spaces. ## Overview This file defines the type `Stonean` of all extremally (note: not "extremely"!) disconnected compact Hausdorff spaces, gives it the structure of a large category, and proves some basic observations about this category and various functors from it. The Lean implementation: a term of type `Stonean` is a pair, considering of a term of type `CompHaus` (i.e. a compact Hausdorff topological space) plus a proof that the space is extremally disconnected. This is equivalent to the assertion that the term is projective in `CompHaus`, in the sense of category theory (i.e., such that morphisms out of the object can be lifted along epimorphisms). ## Main definitions * `Stonean` : the category of extremally disconnected compact Hausdorff spaces. * `Stonean.toCompHaus` : the forgetful functor `Stonean ⥤ CompHaus` from Stonean spaces to compact Hausdorff spaces * `Stonean.toProfinite` : the functor from Stonean spaces to profinite spaces. -/ universe u open CategoryTheory open scoped Topology -- This was a global instance prior to #13170. We may experiment with removing it. attribute [local instance] ConcreteCategory.instFunLike /-- `Stonean` is the category of extremally disconnected compact Hausdorff spaces. -/ abbrev Stonean := CompHausLike (fun X ↦ ExtremallyDisconnected X) namespace CompHaus /-- `Projective` implies `ExtremallyDisconnected`. -/ instance (X : CompHaus.{u}) [Projective X] : ExtremallyDisconnected X := by apply CompactT2.Projective.extremallyDisconnected intro A B _ _ _ _ _ _ f g hf hg hsurj let A' : CompHaus := CompHaus.of A let B' : CompHaus := CompHaus.of B let f' : X ⟶ B' := ⟨f, hf⟩ let g' : A' ⟶ B' := ⟨g,hg⟩ have : Epi g' := by rw [CompHaus.epi_iff_surjective] assumption obtain ⟨h, hh⟩ := Projective.factors f' g' refine ⟨h, h.2, ?_⟩ ext t apply_fun (fun e => e t) at hh exact hh /-- `Projective` implies `Stonean`. -/ @[simps!] def toStonean (X : CompHaus.{u}) [Projective X] : Stonean where toTop := X.toTop prop := inferInstance end CompHaus namespace Stonean /-- The (forgetful) functor from Stonean spaces to compact Hausdorff spaces. -/ abbrev toCompHaus : Stonean.{u} ⥤ CompHaus.{u} := compHausLikeToCompHaus _ /-- The forgetful functor `Stonean ⥤ CompHaus` is fully faithful. -/ abbrev fullyFaithfulToCompHaus : toCompHaus.FullyFaithful := CompHausLike.fullyFaithfulToCompHausLike _ open CompHausLike instance (X : Type*) [TopologicalSpace X] [ExtremallyDisconnected X] : HasProp (fun Y ↦ ExtremallyDisconnected Y) X := ⟨(inferInstance : ExtremallyDisconnected X)⟩ /-- Construct a term of `Stonean` from a type endowed with the structure of a compact, Hausdorff and extremally disconnected topological space. -/ abbrev of (X : Type*) [TopologicalSpace X] [CompactSpace X] [T2Space X] [ExtremallyDisconnected X] : Stonean := CompHausLike.of _ X instance (X : Stonean.{u}) : ExtremallyDisconnected X := X.prop /-- The functor from Stonean spaces to profinite spaces. -/ abbrev toProfinite : Stonean.{u} ⥤ Profinite.{u} := CompHausLike.toCompHausLike (fun _ ↦ inferInstance) instance (X : Stonean.{u}) : ExtremallyDisconnected ((forget _).obj X) := X.prop instance (X : Stonean.{u}) : TotallyDisconnectedSpace ((forget _).obj X) := show TotallyDisconnectedSpace X from inferInstance /-- A finite discrete space as a Stonean space. -/ def mkFinite (X : Type*) [Finite X] [TopologicalSpace X] [DiscreteTopology X] : Stonean where toTop := (CompHaus.of X).toTop prop := by dsimp constructor intro U _ apply isOpen_discrete (closure U) /-- A morphism in `Stonean` is an epi iff it is surjective. -/ lemma epi_iff_surjective {X Y : Stonean} (f : X ⟶ Y) : Epi f ↔ Function.Surjective f := by refine ⟨?_, ConcreteCategory.epi_of_surjective _⟩ dsimp [Function.Surjective] intro h y by_contra! hy let C := Set.range f have hC : IsClosed C := (isCompact_range f.continuous).isClosed let U := Cᶜ have hUy : U ∈ 𝓝 y := by simp only [C, Set.mem_range, hy, exists_false, not_false_eq_true, hC.compl_mem_nhds] obtain ⟨V, hV, hyV, hVU⟩ := isTopologicalBasis_isClopen.mem_nhds_iff.mp hUy classical let g : Y ⟶ mkFinite (ULift (Fin 2)) := ⟨(LocallyConstant.ofIsClopen hV).map ULift.up, LocallyConstant.continuous _⟩ let h : Y ⟶ mkFinite (ULift (Fin 2)) := ⟨fun _ => ⟨1⟩, continuous_const⟩ have H : h = g := by rw [← cancel_epi f] ext x apply ULift.ext -- why is `ext` not doing this automatically? change 1 = ite _ _ _ -- why is `dsimp` not getting me here? rw [if_neg] refine mt (hVU ·) ?_ -- what would be an idiomatic tactic for this step? simpa only [U, Set.mem_compl_iff, Set.mem_range, not_exists, not_forall, not_not] using exists_apply_eq_apply f x apply_fun fun e => (e y).down at H change 1 = ite _ _ _ at H -- why is `dsimp at H` not getting me here? rw [if_pos hyV] at H exact one_ne_zero H /-- Every Stonean space is projective in `CompHaus` -/ instance instProjectiveCompHausCompHaus (X : Stonean) : Projective (toCompHaus.obj X) where factors := by intro B C φ f _ haveI : ExtremallyDisconnected (toCompHaus.obj X).toTop := X.prop have hf : Function.Surjective f := by rwa [← CompHaus.epi_iff_surjective] obtain ⟨f', h⟩ := CompactT2.ExtremallyDisconnected.projective φ.continuous f.continuous hf use ⟨f', h.left⟩ ext exact congr_fun h.right _ /-- Every Stonean space is projective in `Profinite` -/ instance (X : Stonean) : Projective (toProfinite.obj X) where factors := by intro B C φ f _ haveI : ExtremallyDisconnected (toProfinite.obj X) := X.prop have hf : Function.Surjective f := by rwa [← Profinite.epi_iff_surjective] obtain ⟨f', h⟩ := CompactT2.ExtremallyDisconnected.projective φ.continuous f.continuous hf use ⟨f', h.left⟩ ext exact congr_fun h.right _ /-- Every Stonean space is projective in `Stonean`. -/ instance (X : Stonean) : Projective X where factors := by intro B C φ f _ haveI : ExtremallyDisconnected X.toTop := X.prop have hf : Function.Surjective f := by rwa [← Stonean.epi_iff_surjective] obtain ⟨f', h⟩ := CompactT2.ExtremallyDisconnected.projective φ.continuous f.continuous hf use ⟨f', h.left⟩ ext exact congr_fun h.right _ end Stonean namespace CompHaus /-- If `X` is compact Hausdorff, `presentation X` is a Stonean space equipped with an epimorphism down to `X` (see `CompHaus.presentation.π` and `CompHaus.presentation.epi_π`). It is a "constructive" witness to the fact that `CompHaus` has enough projectives. -/ noncomputable def presentation (X : CompHaus) : Stonean where toTop := (projectivePresentation X).p.1 prop := by refine CompactT2.Projective.extremallyDisconnected (@fun Y Z _ _ _ _ _ _ f g hfcont hgcont hgsurj => ?_) let g₁ : (CompHaus.of Y) ⟶ (CompHaus.of Z) := ⟨g, hgcont⟩ let f₁ : (projectivePresentation X).p ⟶ (CompHaus.of Z) := ⟨f, hfcont⟩ have hg₁ : Epi g₁ := (epi_iff_surjective _).2 hgsurj refine ⟨Projective.factorThru f₁ g₁, (Projective.factorThru f₁ g₁).2, funext (fun _ => ?_)⟩ change (Projective.factorThru f₁ g₁ ≫ g₁) _ = f _ rw [Projective.factorThru_comp] rfl /-- The morphism from `presentation X` to `X`. -/ noncomputable def presentation.π (X : CompHaus) : Stonean.toCompHaus.obj X.presentation ⟶ X := (projectivePresentation X).f /-- The morphism from `presentation X` to `X` is an epimorphism. -/ noncomputable instance presentation.epi_π (X : CompHaus) : Epi (π X) := (projectivePresentation X).epi /-- The underlying `CompHaus` of a `Stonean`. -/ abbrev _root_.Stonean.compHaus (X : Stonean) := Stonean.toCompHaus.obj X /-- ``` X | (f) | \/ Z ---(e)---> Y ``` If `Z` is a Stonean space, `f : X ⟶ Y` an epi in `CompHaus` and `e : Z ⟶ Y` is arbitrary, then `lift e f` is a fixed (but arbitrary) lift of `e` to a morphism `Z ⟶ X`. It exists because `Z` is a projective object in `CompHaus`. -/ noncomputable def lift {X Y : CompHaus} {Z : Stonean} (e : Z.compHaus ⟶ Y) (f : X ⟶ Y) [Epi f] : Z.compHaus ⟶ X := Projective.factorThru e f @[simp, reassoc] lemma lift_lifts {X Y : CompHaus} {Z : Stonean} (e : Z.compHaus ⟶ Y) (f : X ⟶ Y) [Epi f] : lift e f ≫ f = e := by simp [lift] lemma Gleason (X : CompHaus.{u}) : Projective X ↔ ExtremallyDisconnected X := by constructor · intro h show ExtremallyDisconnected X.toStonean infer_instance · intro h let X' : Stonean := ⟨X.toTop, inferInstance⟩ show Projective X'.compHaus apply Stonean.instProjectiveCompHausCompHaus end CompHaus namespace Profinite /-- If `X` is profinite, `presentation X` is a Stonean space equipped with an epimorphism down to `X` (see `Profinite.presentation.π` and `Profinite.presentation.epi_π`). -/ noncomputable def presentation (X : Profinite) : Stonean where toTop := (profiniteToCompHaus.obj X).projectivePresentation.p.toTop prop := (profiniteToCompHaus.obj X).presentation.prop /-- The morphism from `presentation X` to `X`. -/ noncomputable def presentation.π (X : Profinite) : Stonean.toProfinite.obj X.presentation ⟶ X := (profiniteToCompHaus.obj X).projectivePresentation.f /-- The morphism from `presentation X` to `X` is an epimorphism. -/ noncomputable instance presentation.epi_π (X : Profinite) : Epi (π X) := by have := (profiniteToCompHaus.obj X).projectivePresentation.epi rw [CompHaus.epi_iff_surjective] at this rw [epi_iff_surjective] exact this /-- ``` X | (f) | \/ Z ---(e)---> Y ``` If `Z` is a Stonean space, `f : X ⟶ Y` an epi in `Profinite` and `e : Z ⟶ Y` is arbitrary, then `lift e f` is a fixed (but arbitrary) lift of `e` to a morphism `Z ⟶ X`. It is `CompHaus.lift e f` as a morphism in `Profinite`. -/ noncomputable def lift {X Y : Profinite} {Z : Stonean} (e : Stonean.toProfinite.obj Z ⟶ Y) (f : X ⟶ Y) [Epi f] : Stonean.toProfinite.obj Z ⟶ X := Projective.factorThru e f @[simp, reassoc] lemma lift_lifts {X Y : Profinite} {Z : Stonean} (e : Stonean.toProfinite.obj Z ⟶ Y) (f : X ⟶ Y) [Epi f] : lift e f ≫ f = e := by simp [lift] lemma projective_of_extrDisc {X : Profinite.{u}} (hX : ExtremallyDisconnected X) : Projective X := by show Projective (Stonean.toProfinite.obj ⟨X.toTop, inferInstance⟩) exact inferInstance end Profinite
Topology\Category\Stonean\EffectiveEpi.lean
/- Copyright (c) 2023 Jon Eugster. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Dagur Asgeirsson, Boris Bolvig Kjær, Jon Eugster, Sina Hazratpour, Nima Rasekh -/ import Mathlib.CategoryTheory.Sites.Coherent.ReflectsPreregular import Mathlib.Topology.Category.CompHaus.EffectiveEpi import Mathlib.Topology.Category.Stonean.Limits /-! # Effective epimorphisms in `Stonean` This file proves that `EffectiveEpi`, `Epi` and `Surjective` are all equivalent in `Stonean`. As a consequence we deduce from the material in `Mathlib.Topology.Category.CompHausLike.EffectiveEpi` that `Stonean` is `Preregular` and `Precoherent`. We also prove that for a finite family of morphisms in `Stonean` with fixed target, the conditions jointly surjective, jointly epimorphic and effective epimorphic are all equivalent. -/ universe u open CategoryTheory Limits CompHausLike attribute [local instance] ConcreteCategory.instFunLike namespace Stonean open List in theorem effectiveEpi_tfae {B X : Stonean.{u}} (π : X ⟶ B) : TFAE [ EffectiveEpi π , Epi π , Function.Surjective π ] := by tfae_have 1 → 2 · intro; infer_instance tfae_have 2 ↔ 3 · exact epi_iff_surjective π tfae_have 3 → 1 · exact fun hπ ↦ ⟨⟨effectiveEpiStruct π hπ⟩⟩ tfae_finish instance : Stonean.toCompHaus.PreservesEffectiveEpis where preserves f h := ((CompHaus.effectiveEpi_tfae (Stonean.toCompHaus.map f)).out 0 2).mpr (((Stonean.effectiveEpi_tfae f).out 0 2).mp h) instance : Stonean.toCompHaus.ReflectsEffectiveEpis where reflects f h := ((Stonean.effectiveEpi_tfae f).out 0 2).mpr (((CompHaus.effectiveEpi_tfae (Stonean.toCompHaus.map f)).out 0 2).mp h) /-- An effective presentation of an `X : CompHaus` with respect to the inclusion functor from `Stonean` -/ noncomputable def stoneanToCompHausEffectivePresentation (X : CompHaus) : Stonean.toCompHaus.EffectivePresentation X where p := X.presentation f := CompHaus.presentation.π X effectiveEpi := ((CompHaus.effectiveEpi_tfae _).out 0 1).mpr (inferInstance : Epi _) instance : Stonean.toCompHaus.EffectivelyEnough where presentation X := ⟨stoneanToCompHausEffectivePresentation X⟩ instance : Preregular Stonean := Stonean.toCompHaus.reflects_preregular example : Precoherent Stonean.{u} := inferInstance -- TODO: prove this for `Type*` open List in theorem effectiveEpiFamily_tfae {α : Type} [Finite α] {B : Stonean.{u}} (X : α → Stonean.{u}) (π : (a : α) → (X a ⟶ B)) : TFAE [ EffectiveEpiFamily X π , Epi (Sigma.desc π) , ∀ b : B, ∃ (a : α) (x : X a), π a x = b ] := by tfae_have 2 → 1 · intro simpa [← effectiveEpi_desc_iff_effectiveEpiFamily, (effectiveEpi_tfae (Sigma.desc π)).out 0 1] tfae_have 1 → 2 · intro; infer_instance tfae_have 3 ↔ 1 · erw [((CompHaus.effectiveEpiFamily_tfae (fun a ↦ Stonean.toCompHaus.obj (X a)) (fun a ↦ Stonean.toCompHaus.map (π a))).out 2 0 : )] exact ⟨fun h ↦ Stonean.toCompHaus.finite_effectiveEpiFamily_of_map _ _ h, fun _ ↦ inferInstance⟩ tfae_finish theorem effectiveEpiFamily_of_jointly_surjective {α : Type} [Finite α] {B : Stonean.{u}} (X : α → Stonean.{u}) (π : (a : α) → (X a ⟶ B)) (surj : ∀ b : B, ∃ (a : α) (x : X a), π a x = b) : EffectiveEpiFamily X π := ((effectiveEpiFamily_tfae X π).out 2 0).mp surj end Stonean
Topology\Category\Stonean\Limits.lean
/- Copyright (c) 2023 Adam Topaz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Adam Topaz, Dagur Asgeirsson, Filippo A. E. Nuccio, Riccardo Brasca -/ import Mathlib.Topology.Category.CompHausLike.Limits import Mathlib.Topology.Category.Stonean.Basic /-! # Explicit limits and colimits This file applies the general API for explicit limits and colimits in `CompHausLike P` (see the file `Mathlib.Topology.Category.CompHausLike.Limits`) to the special case of `Stonean`. -/ universe w u open CategoryTheory Limits CompHausLike attribute [local instance] ConcreteCategory.instFunLike namespace Stonean instance : HasExplicitFiniteCoproducts.{w, u} (fun Y ↦ ExtremallyDisconnected Y) where hasProp _ := { hasProp := show ExtremallyDisconnected (Σ (_a : _), _) from inferInstance} variable {X Y Z : Stonean} {f : X ⟶ Z} (i : Y ⟶ Z) (hi : OpenEmbedding f) lemma extremallyDisconnected_preimage : ExtremallyDisconnected (i ⁻¹' (Set.range f)) where open_closure U hU := by have h : IsClopen (i ⁻¹' (Set.range f)) := ⟨IsClosed.preimage i.continuous (isCompact_range f.continuous).isClosed, IsOpen.preimage i.continuous hi.isOpen_range⟩ rw [← (closure U).preimage_image_eq Subtype.coe_injective, ← h.1.closedEmbedding_subtype_val.closure_image_eq U] exact isOpen_induced (ExtremallyDisconnected.open_closure _ (h.2.openEmbedding_subtype_val.isOpenMap U hU)) lemma extremallyDisconnected_pullback : ExtremallyDisconnected {xy : X × Y | f xy.1 = i xy.2} := have := extremallyDisconnected_preimage i hi let e := (TopCat.pullbackHomeoPreimage i i.2 f hi.toEmbedding).symm let e' : {xy : X × Y | f xy.1 = i xy.2} ≃ₜ {xy : Y × X | i xy.1 = f xy.2} := by exact TopCat.homeoOfIso ((TopCat.pullbackIsoProdSubtype f i).symm ≪≫ pullbackSymmetry _ _ ≪≫ (TopCat.pullbackIsoProdSubtype i f)) extremallyDisconnected_of_homeo (e.trans e'.symm) instance : HasExplicitPullbacksOfInclusions (fun (Y : TopCat.{u}) ↦ ExtremallyDisconnected Y) := by apply CompHausLike.hasPullbacksOfInclusions intro _ _ _ _ _ hi exact ⟨extremallyDisconnected_pullback _ hi⟩ example : FinitaryExtensive Stonean.{u} := inferInstance noncomputable example : PreservesFiniteCoproducts Stonean.toCompHaus := inferInstance noncomputable example : PreservesFiniteCoproducts Stonean.toProfinite := inferInstance end Stonean
Topology\Category\TopCat\Adjunctions.lean
/- Copyright (c) 2017 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot, Mario Carneiro -/ import Mathlib.Topology.Category.TopCat.Basic import Mathlib.CategoryTheory.Adjunction.Basic /-! # Adjunctions regarding the category of topological spaces This file shows that the forgetful functor from topological spaces to types has a left and right adjoint, given by `TopCat.discrete`, resp. `TopCat.trivial`, the functors which equip a type with the discrete, resp. trivial, topology. -/ universe u open CategoryTheory open TopCat namespace TopCat /-- Equipping a type with the discrete topology is left adjoint to the forgetful functor `Top ⥤ Type`. -/ @[simps! unit counit] def adj₁ : discrete ⊣ forget TopCat.{u} := Adjunction.mkOfUnitCounit { unit := { app := fun X => id } counit := { app := fun X => ⟨id, continuous_bot⟩ } } /-- Equipping a type with the trivial topology is right adjoint to the forgetful functor `Top ⥤ Type`. -/ @[simps! unit counit] def adj₂ : forget TopCat.{u} ⊣ trivial := Adjunction.mkOfUnitCounit { unit := { app := fun X => ⟨id, continuous_top⟩ } counit := { app := fun X => id } } instance : (forget TopCat.{u}).IsRightAdjoint := ⟨_, ⟨adj₁⟩⟩ instance : (forget TopCat.{u}).IsLeftAdjoint := ⟨_, ⟨adj₂⟩⟩ end TopCat
Topology\Category\TopCat\Basic.lean
/- Copyright (c) 2017 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot, Scott Morrison, Mario Carneiro -/ import Mathlib.CategoryTheory.ConcreteCategory.BundledHom import Mathlib.Topology.ContinuousFunction.Basic /-! # Category instance for topological spaces We introduce the bundled category `TopCat` of topological spaces together with the functors `TopCat.discrete` and `TopCat.trivial` from the category of types to `TopCat` which equip a type with the corresponding discrete, resp. trivial, topology. For a proof that these functors are left, resp. right adjoint to the forgetful functor, see `Mathlib.Topology.Category.TopCat.Adjunctions`. -/ open CategoryTheory open TopologicalSpace universe u /-- The category of topological spaces and continuous maps. -/ @[to_additive existing TopCat] def TopCat : Type (u + 1) := Bundled TopologicalSpace namespace TopCat instance bundledHom : BundledHom @ContinuousMap where toFun := @ContinuousMap.toFun id := @ContinuousMap.id comp := @ContinuousMap.comp deriving instance LargeCategory for TopCat -- Porting note: currently no derive handler for ConcreteCategory -- see https://github.com/leanprover-community/mathlib4/issues/5020 instance concreteCategory : ConcreteCategory TopCat := inferInstanceAs <| ConcreteCategory (Bundled TopologicalSpace) instance : CoeSort TopCat Type* where coe X := X.α instance topologicalSpaceUnbundled (X : TopCat) : TopologicalSpace X := X.str -- We leave this temporarily as a reminder of the downstream instances #13170 -- -- Porting note: cannot find a coercion to function otherwise -- -- attribute [instance] ConcreteCategory.instFunLike in -- instance (X Y : TopCat.{u}) : CoeFun (X ⟶ Y) fun _ => X → Y where -- coe (f : C(X, Y)) := f instance instFunLike (X Y : TopCat) : FunLike (X ⟶ Y) X Y := inferInstanceAs <| FunLike C(X, Y) X Y instance instMonoidHomClass (X Y : TopCat) : ContinuousMapClass (X ⟶ Y) X Y := inferInstanceAs <| ContinuousMapClass C(X, Y) X Y -- Porting note (#10618): simp can prove this; removed simp theorem id_app (X : TopCat.{u}) (x : ↑X) : (𝟙 X : X ⟶ X) x = x := rfl -- Porting note (#10618): simp can prove this; removed simp theorem comp_app {X Y Z : TopCat.{u}} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : (f ≫ g : X → Z) x = g (f x) := rfl @[simp] theorem coe_id (X : TopCat.{u}) : (𝟙 X : X → X) = id := rfl @[simp] theorem coe_comp {X Y Z : TopCat.{u}} (f : X ⟶ Y) (g : Y ⟶ Z) : (f ≫ g : X → Z) = g ∘ f := rfl @[simp] lemma hom_inv_id_apply {X Y : TopCat} (f : X ≅ Y) (x : X) : f.inv (f.hom x) = x := DFunLike.congr_fun f.hom_inv_id x @[simp] lemma inv_hom_id_apply {X Y : TopCat} (f : X ≅ Y) (y : Y) : f.hom (f.inv y) = y := DFunLike.congr_fun f.inv_hom_id y /-- Construct a bundled `Top` from the underlying type and the typeclass. -/ def of (X : Type u) [TopologicalSpace X] : TopCat := -- Porting note: needed to call inferInstance ⟨X, inferInstance⟩ instance topologicalSpace_coe (X : TopCat) : TopologicalSpace X := X.str -- Porting note: cannot see through forget; made reducible to get closer to Lean 3 behavior @[instance] abbrev topologicalSpace_forget (X : TopCat) : TopologicalSpace <| (forget TopCat).obj X := X.str @[simp] theorem coe_of (X : Type u) [TopologicalSpace X] : (of X : Type u) = X := rfl /-- Replace a function coercion for a morphism `TopCat.of X ⟶ TopCat.of Y` with the definitionally equal function coercion for a continuous map `C(X, Y)`. -/ @[simp] theorem coe_of_of {X Y : Type u} [TopologicalSpace X] [TopologicalSpace Y] {f : C(X, Y)} {x} : @DFunLike.coe (TopCat.of X ⟶ TopCat.of Y) ((CategoryTheory.forget TopCat).obj (TopCat.of X)) (fun _ ↦ (CategoryTheory.forget TopCat).obj (TopCat.of Y)) ConcreteCategory.instFunLike f x = @DFunLike.coe C(X, Y) X (fun _ ↦ Y) _ f x := rfl instance inhabited : Inhabited TopCat := ⟨TopCat.of Empty⟩ -- Porting note: added to ease the port of `AlgebraicTopology.TopologicalSimplex` lemma hom_apply {X Y : TopCat} (f : X ⟶ Y) (x : X) : f x = ContinuousMap.toFun f x := rfl /-- The discrete topology on any type. -/ def discrete : Type u ⥤ TopCat.{u} where obj X := ⟨X , ⊥⟩ map f := @ContinuousMap.mk _ _ ⊥ ⊥ f continuous_bot instance {X : Type u} : DiscreteTopology (discrete.obj X) := ⟨rfl⟩ /-- The trivial topology on any type. -/ def trivial : Type u ⥤ TopCat.{u} where obj X := ⟨X, ⊤⟩ map f := @ContinuousMap.mk _ _ ⊤ ⊤ f continuous_top /-- Any homeomorphisms induces an isomorphism in `Top`. -/ @[simps] def isoOfHomeo {X Y : TopCat.{u}} (f : X ≃ₜ Y) : X ≅ Y where -- Porting note: previously ⟨f⟩ for hom (inv) and tidy closed proofs hom := f.toContinuousMap inv := f.symm.toContinuousMap hom_inv_id := by ext; exact f.symm_apply_apply _ inv_hom_id := by ext; exact f.apply_symm_apply _ /-- Any isomorphism in `Top` induces a homeomorphism. -/ @[simps] def homeoOfIso {X Y : TopCat.{u}} (f : X ≅ Y) : X ≃ₜ Y where toFun := f.hom invFun := f.inv left_inv x := by simp right_inv x := by simp continuous_toFun := f.hom.continuous continuous_invFun := f.inv.continuous @[simp] theorem of_isoOfHomeo {X Y : TopCat.{u}} (f : X ≃ₜ Y) : homeoOfIso (isoOfHomeo f) = f := by -- Porting note: unfold some defs now dsimp [homeoOfIso, isoOfHomeo] ext rfl @[simp] theorem of_homeoOfIso {X Y : TopCat.{u}} (f : X ≅ Y) : isoOfHomeo (homeoOfIso f) = f := by -- Porting note: unfold some defs now dsimp [homeoOfIso, isoOfHomeo] ext rfl -- Porting note: simpNF requested partially simped version below theorem openEmbedding_iff_comp_isIso {X Y Z : TopCat} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso g] : OpenEmbedding (f ≫ g) ↔ OpenEmbedding f := (TopCat.homeoOfIso (asIso g)).openEmbedding.of_comp_iff f @[simp] theorem openEmbedding_iff_comp_isIso' {X Y Z : TopCat} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso g] : OpenEmbedding ((forget TopCat).map f ≫ (forget TopCat).map g) ↔ OpenEmbedding f := by simp only [← Functor.map_comp] exact openEmbedding_iff_comp_isIso f g -- Porting note: simpNF requested partially simped version below theorem openEmbedding_iff_isIso_comp {X Y Z : TopCat} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso f] : OpenEmbedding (f ≫ g) ↔ OpenEmbedding g := by constructor · intro h convert h.comp (TopCat.homeoOfIso (asIso f).symm).openEmbedding exact congrArg _ (IsIso.inv_hom_id_assoc f g).symm · exact fun h => h.comp (TopCat.homeoOfIso (asIso f)).openEmbedding @[simp] theorem openEmbedding_iff_isIso_comp' {X Y Z : TopCat} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso f] : OpenEmbedding ((forget TopCat).map f ≫ (forget TopCat).map g) ↔ OpenEmbedding g := by simp only [← Functor.map_comp] exact openEmbedding_iff_isIso_comp f g end TopCat
Topology\Category\TopCat\EffectiveEpi.lean
/- Copyright (c) 2024 Dagur Asgeirsson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Dagur Asgeirsson -/ import Mathlib.CategoryTheory.EffectiveEpi.RegularEpi import Mathlib.CategoryTheory.EffectiveEpi.Comp import Mathlib.Topology.Category.TopCat.Limits.Pullbacks /-! # Effective epimorphisms in `TopCat` This file proves the result `TopCat.effectiveEpi_iff_quotientMap`: The effective epimorphisms in `TopCat` are precisely the quotient maps. -/ universe u open CategoryTheory Limits namespace TopCat /-- Implementation: If `π` is a morphism in `TopCat` which is a quotient map, then it is an effective epimorphism. The theorem `TopCat.effectiveEpi_iff_quotientMap` should be used instead of this definition. -/ noncomputable def effectiveEpiStructOfQuotientMap {B X : TopCat.{u}} (π : X ⟶ B) (hπ : QuotientMap π) : EffectiveEpiStruct π where /- `QuotientMap.lift` gives the required morphism -/ desc e h := hπ.lift e fun a b hab ↦ DFunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩ (by ext; exact hab)) a /- `QuotientMap.lift_comp` gives the factorisation -/ fac e h := (hπ.lift_comp e fun a b hab ↦ DFunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩ (by ext; exact hab)) a) /- Uniqueness follows from the fact that `QuotientMap.lift` is an equivalence (given by `QuotientMap.liftEquiv`). -/ uniq e h g hm := by suffices g = hπ.liftEquiv ⟨e, fun a b hab ↦ DFunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩ (by ext; exact hab)) a⟩ by assumption rw [← Equiv.symm_apply_eq hπ.liftEquiv] ext simp only [QuotientMap.liftEquiv_symm_apply_coe, ContinuousMap.comp_apply, ← hm] rfl /-- The effective epimorphisms in `TopCat` are precisely the quotient maps. -/ theorem effectiveEpi_iff_quotientMap {B X : TopCat.{u}} (π : X ⟶ B) : EffectiveEpi π ↔ QuotientMap π := by /- The backward direction is given by `effectiveEpiStructOfQuotientMap` above. -/ refine ⟨fun _ ↦ ?_, fun hπ ↦ ⟨⟨effectiveEpiStructOfQuotientMap π hπ⟩⟩⟩ /- Since `TopCat` has pullbacks, `π` is in fact a `RegularEpi`. This means that it exhibits `B` as a coequalizer of two maps into `X`. It suffices to prove that `π` followed by the isomorphism to an arbitrary coequalizer is a quotient map. -/ have hπ : RegularEpi π := inferInstance let F := parallelPair hπ.left hπ.right let i : B ≅ colimit F := hπ.isColimit.coconePointUniqueUpToIso (colimit.isColimit _) suffices QuotientMap (homeoOfIso i ∘ π) by simpa [← Function.comp.assoc] using (homeoOfIso i).symm.quotientMap.comp this constructor /- Effective epimorphisms are epimorphisms and epimorphisms in `TopCat` are surjective. -/ · change Function.Surjective (π ≫ i.hom) rw [← epi_iff_surjective] infer_instance /- The key to proving that the coequalizer has the quotient topology is `TopCat.coequalizer_isOpen_iff` which characterises the open sets in a coequalizer. -/ · ext U have : π ≫ i.hom = colimit.ι F WalkingParallelPair.one := by simp [i, ← Iso.eq_comp_inv] rw [isOpen_coinduced (f := (homeoOfIso i ∘ π)), coequalizer_isOpen_iff _ U, ← this] rfl end TopCat
Topology\Category\TopCat\EpiMono.lean
/- Copyright (c) 2019 Reid Barton. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Reid Barton -/ import Mathlib.Topology.Category.TopCat.Adjunctions import Mathlib.CategoryTheory.Functor.EpiMono /-! # Epi- and monomorphisms in `Top` This file shows that a continuous function is an epimorphism in the category of topological spaces if and only if it is surjective, and that a continuous function is a monomorphism in the category of topological spaces if and only if it is injective. -/ universe u open CategoryTheory open TopCat namespace TopCat theorem epi_iff_surjective {X Y : TopCat.{u}} (f : X ⟶ Y) : Epi f ↔ Function.Surjective f := by suffices Epi f ↔ Epi ((forget TopCat).map f) by rw [this, CategoryTheory.epi_iff_surjective] rfl constructor · intro infer_instance · apply Functor.epi_of_epi_map theorem mono_iff_injective {X Y : TopCat.{u}} (f : X ⟶ Y) : Mono f ↔ Function.Injective f := by suffices Mono f ↔ Mono ((forget TopCat).map f) by rw [this, CategoryTheory.mono_iff_injective] rfl constructor · intro infer_instance · apply Functor.mono_of_mono_map end TopCat
Topology\Category\TopCat\OpenNhds.lean
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Topology.Category.TopCat.Opens import Mathlib.Data.Set.Subsingleton /-! # The category of open neighborhoods of a point Given an object `X` of the category `TopCat` of topological spaces and a point `x : X`, this file builds the type `OpenNhds x` of open neighborhoods of `x` in `X` and endows it with the partial order given by inclusion and the corresponding category structure (as a full subcategory of the poset category `Set X`). This is used in `Topology.Sheaves.Stalks` to build the stalk of a sheaf at `x` as a limit over `OpenNhds x`. ## Main declarations Besides `OpenNhds`, the main constructions here are: * `inclusion (x : X)`: the obvious functor `OpenNhds x ⥤ Opens X` * `functorNhds`: An open map `f : X ⟶ Y` induces a functor `OpenNhds x ⥤ OpenNhds (f x)` * `adjunctionNhds`: An open map `f : X ⟶ Y` induces an adjunction between `OpenNhds x` and `OpenNhds (f x)`. -/ open CategoryTheory TopologicalSpace Opposite universe u variable {X Y : TopCat.{u}} (f : X ⟶ Y) namespace TopologicalSpace /-- The type of open neighbourhoods of a point `x` in a (bundled) topological space. -/ def OpenNhds (x : X) := FullSubcategory fun U : Opens X => x ∈ U namespace OpenNhds instance partialOrder (x : X) : PartialOrder (OpenNhds x) where le U V := U.1 ≤ V.1 le_refl _ := by dsimp [LE.le]; exact le_rfl le_trans _ _ _ := by dsimp [LE.le]; exact le_trans le_antisymm _ _ i j := FullSubcategory.ext <| le_antisymm i j instance (x : X) : Lattice (OpenNhds x) := { OpenNhds.partialOrder x with inf := fun U V => ⟨U.1 ⊓ V.1, ⟨U.2, V.2⟩⟩ le_inf := fun U V W => @le_inf _ _ U.1.1 V.1.1 W.1.1 inf_le_left := fun U V => @inf_le_left _ _ U.1.1 V.1.1 inf_le_right := fun U V => @inf_le_right _ _ U.1.1 V.1.1 sup := fun U V => ⟨U.1 ⊔ V.1, Set.mem_union_left V.1.1 U.2⟩ sup_le := fun U V W => @sup_le _ _ U.1.1 V.1.1 W.1.1 le_sup_left := fun U V => @le_sup_left _ _ U.1.1 V.1.1 le_sup_right := fun U V => @le_sup_right _ _ U.1.1 V.1.1 } instance (x : X) : OrderTop (OpenNhds x) where top := ⟨⊤, trivial⟩ le_top _ := by dsimp [LE.le]; exact le_top instance (x : X) : Inhabited (OpenNhds x) := ⟨⊤⟩ instance openNhdsCategory (x : X) : Category.{u} (OpenNhds x) := inferInstance instance opensNhdsHomHasCoeToFun {x : X} {U V : OpenNhds x} : CoeFun (U ⟶ V) fun _ => U.1 → V.1 := ⟨fun f x => ⟨x, f.le x.2⟩⟩ /-- The inclusion `U ⊓ V ⟶ U` as a morphism in the category of open sets. -/ def infLELeft {x : X} (U V : OpenNhds x) : U ⊓ V ⟶ U := homOfLE inf_le_left /-- The inclusion `U ⊓ V ⟶ V` as a morphism in the category of open sets. -/ def infLERight {x : X} (U V : OpenNhds x) : U ⊓ V ⟶ V := homOfLE inf_le_right /-- The inclusion functor from open neighbourhoods of `x` to open sets in the ambient topological space. -/ def inclusion (x : X) : OpenNhds x ⥤ Opens X := fullSubcategoryInclusion _ @[simp] theorem inclusion_obj (x : X) (U) (p) : (inclusion x).obj ⟨U, p⟩ = U := rfl theorem openEmbedding {x : X} (U : OpenNhds x) : OpenEmbedding U.1.inclusion := U.1.openEmbedding /-- The preimage functor from neighborhoods of `f x` to neighborhoods of `x`. -/ def map (x : X) : OpenNhds (f x) ⥤ OpenNhds x where obj U := ⟨(Opens.map f).obj U.1, U.2⟩ map i := (Opens.map f).map i -- Porting note: Changed `⟨(Opens.map f).obj U, by tidy⟩` to `⟨(Opens.map f).obj U, q⟩` @[simp] theorem map_obj (x : X) (U) (q) : (map f x).obj ⟨U, q⟩ = ⟨(Opens.map f).obj U, q⟩ := rfl @[simp] theorem map_id_obj (x : X) (U) : (map (𝟙 X) x).obj U = U := rfl @[simp] theorem map_id_obj' (x : X) (U) (p) (q) : (map (𝟙 X) x).obj ⟨⟨U, p⟩, q⟩ = ⟨⟨U, p⟩, q⟩ := rfl @[simp] theorem map_id_obj_unop (x : X) (U : (OpenNhds x)ᵒᵖ) : (map (𝟙 X) x).obj (unop U) = unop U := by simp @[simp] theorem op_map_id_obj (x : X) (U : (OpenNhds x)ᵒᵖ) : (map (𝟙 X) x).op.obj U = U := by simp /-- `Opens.map f` and `OpenNhds.map f` form a commuting square (up to natural isomorphism) with the inclusion functors into `Opens X`. -/ @[simps! hom_app inv_app] def inclusionMapIso (x : X) : inclusion (f x) ⋙ Opens.map f ≅ map f x ⋙ inclusion x := NatIso.ofComponents fun U => { hom := 𝟙 _, inv := 𝟙 _ } @[simp] theorem inclusionMapIso_hom (x : X) : (inclusionMapIso f x).hom = 𝟙 _ := rfl @[simp] theorem inclusionMapIso_inv (x : X) : (inclusionMapIso f x).inv = 𝟙 _ := rfl end OpenNhds end TopologicalSpace namespace IsOpenMap open TopologicalSpace variable {f} /-- An open map `f : X ⟶ Y` induces a functor `OpenNhds x ⥤ OpenNhds (f x)`. -/ @[simps] def functorNhds (h : IsOpenMap f) (x : X) : OpenNhds x ⥤ OpenNhds (f x) where obj U := ⟨h.functor.obj U.1, ⟨x, U.2, rfl⟩⟩ map i := h.functor.map i /-- An open map `f : X ⟶ Y` induces an adjunction between `OpenNhds x` and `OpenNhds (f x)`. -/ def adjunctionNhds (h : IsOpenMap f) (x : X) : IsOpenMap.functorNhds h x ⊣ OpenNhds.map f x := Adjunction.mkOfUnitCounit { unit := { app := fun U => homOfLE fun x hxU => ⟨x, hxU, rfl⟩ } counit := { app := fun V => homOfLE fun y ⟨_, hfxV, hxy⟩ => hxy ▸ hfxV } } end IsOpenMap
Topology\Category\TopCat\Opens.lean
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.CategoryTheory.Category.Preorder import Mathlib.CategoryTheory.EqToHom import Mathlib.Topology.Category.TopCat.EpiMono import Mathlib.Topology.Sets.Opens /-! # The category of open sets in a topological space. We define `toTopCat : Opens X ⥤ TopCat` and `map (f : X ⟶ Y) : Opens Y ⥤ Opens X`, given by taking preimages of open sets. Unfortunately `Opens` isn't (usefully) a functor `TopCat ⥤ Cat`. (One can in fact define such a functor, but using it results in unresolvable `Eq.rec` terms in goals.) Really it's a 2-functor from (spaces, continuous functions, equalities) to (categories, functors, natural isomorphisms). We don't attempt to set up the full theory here, but do provide the natural isomorphisms `mapId : map (𝟙 X) ≅ 𝟭 (opens X)` and `mapComp : map (f ≫ g) ≅ map g ⋙ map f`. Beyond that, there's a collection of simp lemmas for working with these constructions. -/ open CategoryTheory TopologicalSpace Opposite universe u namespace TopologicalSpace.Opens variable {X Y Z : TopCat.{u}} /-! Since `Opens X` has a partial order, it automatically receives a `Category` instance. Unfortunately, because we do not allow morphisms in `Prop`, the morphisms `U ⟶ V` are not just proofs `U ≤ V`, but rather `ULift (PLift (U ≤ V))`. -/ instance opensHomHasCoeToFun {U V : Opens X} : CoeFun (U ⟶ V) fun _ => U → V := ⟨fun f x => ⟨x, f.le x.2⟩⟩ /-! We now construct as morphisms various inclusions of open sets. -/ -- This is tedious, but necessary because we decided not to allow Prop as morphisms in a category... /-- The inclusion `U ⊓ V ⟶ U` as a morphism in the category of open sets. -/ noncomputable def infLELeft (U V : Opens X) : U ⊓ V ⟶ U := inf_le_left.hom /-- The inclusion `U ⊓ V ⟶ V` as a morphism in the category of open sets. -/ noncomputable def infLERight (U V : Opens X) : U ⊓ V ⟶ V := inf_le_right.hom /-- The inclusion `U i ⟶ iSup U` as a morphism in the category of open sets. -/ noncomputable def leSupr {ι : Type*} (U : ι → Opens X) (i : ι) : U i ⟶ iSup U := (le_iSup U i).hom /-- The inclusion `⊥ ⟶ U` as a morphism in the category of open sets. -/ noncomputable def botLE (U : Opens X) : ⊥ ⟶ U := bot_le.hom /-- The inclusion `U ⟶ ⊤` as a morphism in the category of open sets. -/ noncomputable def leTop (U : Opens X) : U ⟶ ⊤ := le_top.hom -- We do not mark this as a simp lemma because it breaks open `x`. -- Nevertheless, it is useful in `SheafOfFunctions`. theorem infLELeft_apply (U V : Opens X) (x) : (infLELeft U V) x = ⟨x.1, (@inf_le_left _ _ U V : _ ≤ _) x.2⟩ := rfl @[simp] theorem infLELeft_apply_mk (U V : Opens X) (x) (m) : (infLELeft U V) ⟨x, m⟩ = ⟨x, (@inf_le_left _ _ U V : _ ≤ _) m⟩ := rfl @[simp] theorem leSupr_apply_mk {ι : Type*} (U : ι → Opens X) (i : ι) (x) (m) : (leSupr U i) ⟨x, m⟩ = ⟨x, (le_iSup U i : _) m⟩ := rfl /-- The functor from open sets in `X` to `Top`, realising each open set as a topological space itself. -/ def toTopCat (X : TopCat.{u}) : Opens X ⥤ TopCat where obj U := ⟨U, inferInstance⟩ map i := ⟨fun x => ⟨x.1, i.le x.2⟩, (Embedding.continuous_iff embedding_subtype_val).2 continuous_induced_dom⟩ @[simp] theorem toTopCat_map (X : TopCat.{u}) {U V : Opens X} {f : U ⟶ V} {x} {h} : ((toTopCat X).map f) ⟨x, h⟩ = ⟨x, f.le h⟩ := rfl /-- The inclusion map from an open subset to the whole space, as a morphism in `TopCat`. -/ @[simps (config := .asFn)] def inclusion {X : TopCat.{u}} (U : Opens X) : (toTopCat X).obj U ⟶ X where toFun := _ continuous_toFun := continuous_subtype_val @[simp] theorem coe_inclusion {X : TopCat} {U : Opens X} : (inclusion U : U → X) = Subtype.val := rfl theorem openEmbedding {X : TopCat.{u}} (U : Opens X) : OpenEmbedding (inclusion U) := IsOpen.openEmbedding_subtype_val U.2 /-- The inclusion of the top open subset (i.e. the whole space) is an isomorphism. -/ def inclusionTopIso (X : TopCat.{u}) : (toTopCat X).obj ⊤ ≅ X where hom := inclusion ⊤ inv := ⟨fun x => ⟨x, trivial⟩, continuous_def.2 fun U ⟨_, hS, hSU⟩ => hSU ▸ hS⟩ /-- `Opens.map f` gives the functor from open sets in Y to open set in X, given by taking preimages under f. -/ def map (f : X ⟶ Y) : Opens Y ⥤ Opens X where obj U := ⟨f ⁻¹' (U : Set Y), U.isOpen.preimage f.continuous⟩ map i := ⟨⟨fun x h => i.le h⟩⟩ @[simp] theorem map_coe (f : X ⟶ Y) (U : Opens Y) : ((map f).obj U : Set X) = f ⁻¹' (U : Set Y) := rfl @[simp] theorem map_obj (f : X ⟶ Y) (U) (p) : (map f).obj ⟨U, p⟩ = ⟨f ⁻¹' U, p.preimage f.continuous⟩ := rfl @[simp] lemma map_homOfLE (f : X ⟶ Y) {U V : Opens Y} (e : U ≤ V) : (TopologicalSpace.Opens.map f).map (homOfLE e) = homOfLE (show (Opens.map f).obj U ≤ (Opens.map f).obj V from fun _ hx ↦ e hx) := rfl @[simp] theorem map_id_obj (U : Opens X) : (map (𝟙 X)).obj U = U := let ⟨_, _⟩ := U rfl @[simp 1100] theorem map_id_obj' (U) (p) : (map (𝟙 X)).obj ⟨U, p⟩ = ⟨U, p⟩ := rfl @[simp 1100] theorem map_id_obj_unop (U : (Opens X)ᵒᵖ) : (map (𝟙 X)).obj (unop U) = unop U := let ⟨_, _⟩ := U.unop rfl @[simp 1100] theorem op_map_id_obj (U : (Opens X)ᵒᵖ) : (map (𝟙 X)).op.obj U = U := by simp @[simp] lemma map_top (f : X ⟶ Y) : (Opens.map f).obj ⊤ = ⊤ := rfl /-- The inclusion `U ⟶ (map f).obj ⊤` as a morphism in the category of open sets. -/ noncomputable def leMapTop (f : X ⟶ Y) (U : Opens X) : U ⟶ (map f).obj ⊤ := leTop U @[simp] theorem map_comp_obj (f : X ⟶ Y) (g : Y ⟶ Z) (U) : (map (f ≫ g)).obj U = (map f).obj ((map g).obj U) := rfl @[simp] theorem map_comp_obj' (f : X ⟶ Y) (g : Y ⟶ Z) (U) (p) : (map (f ≫ g)).obj ⟨U, p⟩ = (map f).obj ((map g).obj ⟨U, p⟩) := rfl @[simp] theorem map_comp_map (f : X ⟶ Y) (g : Y ⟶ Z) {U V} (i : U ⟶ V) : (map (f ≫ g)).map i = (map f).map ((map g).map i) := rfl @[simp] theorem map_comp_obj_unop (f : X ⟶ Y) (g : Y ⟶ Z) (U) : (map (f ≫ g)).obj (unop U) = (map f).obj ((map g).obj (unop U)) := rfl @[simp] theorem op_map_comp_obj (f : X ⟶ Y) (g : Y ⟶ Z) (U) : (map (f ≫ g)).op.obj U = (map f).op.obj ((map g).op.obj U) := rfl theorem map_iSup (f : X ⟶ Y) {ι : Type*} (U : ι → Opens Y) : (map f).obj (iSup U) = iSup ((map f).obj ∘ U) := by ext1; rw [iSup_def, iSup_def, map_obj] dsimp; rw [Set.preimage_iUnion] section variable (X) /-- The functor `Opens X ⥤ Opens X` given by taking preimages under the identity function is naturally isomorphic to the identity functor. -/ @[simps] def mapId : map (𝟙 X) ≅ 𝟭 (Opens X) where hom := { app := fun U => eqToHom (map_id_obj U) } inv := { app := fun U => eqToHom (map_id_obj U).symm } theorem map_id_eq : map (𝟙 X) = 𝟭 (Opens X) := by rfl end /-- The natural isomorphism between taking preimages under `f ≫ g`, and the composite of taking preimages under `g`, then preimages under `f`. -/ @[simps] def mapComp (f : X ⟶ Y) (g : Y ⟶ Z) : map (f ≫ g) ≅ map g ⋙ map f where hom := { app := fun U => eqToHom (map_comp_obj f g U) } inv := { app := fun U => eqToHom (map_comp_obj f g U).symm } theorem map_comp_eq (f : X ⟶ Y) (g : Y ⟶ Z) : map (f ≫ g) = map g ⋙ map f := rfl -- We could make `f g` implicit here, but it's nice to be able to see when -- they are the identity (often!) /-- If two continuous maps `f g : X ⟶ Y` are equal, then the functors `Opens Y ⥤ Opens X` they induce are isomorphic. -/ def mapIso (f g : X ⟶ Y) (h : f = g) : map f ≅ map g := NatIso.ofComponents fun U => eqToIso (by rw [congr_arg map h]) theorem map_eq (f g : X ⟶ Y) (h : f = g) : map f = map g := by subst h rfl @[simp] theorem mapIso_refl (f : X ⟶ Y) (h) : mapIso f f h = Iso.refl (map _) := rfl @[simp] theorem mapIso_hom_app (f g : X ⟶ Y) (h : f = g) (U : Opens Y) : (mapIso f g h).hom.app U = eqToHom (by rw [h]) := rfl @[simp] theorem mapIso_inv_app (f g : X ⟶ Y) (h : f = g) (U : Opens Y) : (mapIso f g h).inv.app U = eqToHom (by rw [h]) := rfl /-- A homeomorphism of spaces gives an equivalence of categories of open sets. TODO: define `OrderIso.equivalence`, use it. -/ @[simps] def mapMapIso {X Y : TopCat.{u}} (H : X ≅ Y) : Opens Y ≌ Opens X where functor := map H.hom inverse := map H.inv unitIso := NatIso.ofComponents fun U => eqToIso (by simp [map, Set.preimage_preimage]) counitIso := NatIso.ofComponents fun U => eqToIso (by simp [map, Set.preimage_preimage]) end TopologicalSpace.Opens /-- An open map `f : X ⟶ Y` induces a functor `Opens X ⥤ Opens Y`. -/ @[simps obj_coe] def IsOpenMap.functor {X Y : TopCat} {f : X ⟶ Y} (hf : IsOpenMap f) : Opens X ⥤ Opens Y where obj U := ⟨f '' (U : Set X), hf (U : Set X) U.2⟩ map h := ⟨⟨Set.image_subset _ h.down.down⟩⟩ /-- An open map `f : X ⟶ Y` induces an adjunction between `Opens X` and `Opens Y`. -/ def IsOpenMap.adjunction {X Y : TopCat} {f : X ⟶ Y} (hf : IsOpenMap f) : Adjunction hf.functor (TopologicalSpace.Opens.map f) := Adjunction.mkOfUnitCounit { unit := { app := fun U => homOfLE fun x hxU => ⟨x, hxU, rfl⟩ } counit := { app := fun V => homOfLE fun y ⟨_, hfxV, hxy⟩ => hxy ▸ hfxV } } instance IsOpenMap.functorFullOfMono {X Y : TopCat} {f : X ⟶ Y} (hf : IsOpenMap f) [H : Mono f] : hf.functor.Full where map_surjective i := ⟨homOfLE fun x hx => by obtain ⟨y, hy, eq⟩ := i.le ⟨x, hx, rfl⟩ exact (TopCat.mono_iff_injective f).mp H eq ▸ hy, rfl⟩ instance IsOpenMap.functor_faithful {X Y : TopCat} {f : X ⟶ Y} (hf : IsOpenMap f) : hf.functor.Faithful where lemma OpenEmbedding.functor_obj_injective {X Y : TopCat} {f : X ⟶ Y} (hf : OpenEmbedding f) : Function.Injective hf.isOpenMap.functor.obj := fun _ _ e ↦ Opens.ext (Set.image_injective.mpr hf.inj (congr_arg (↑· : Opens Y → Set Y) e)) namespace TopologicalSpace.Opens open TopologicalSpace @[simp] theorem openEmbedding_obj_top {X : TopCat} (U : Opens X) : U.openEmbedding.isOpenMap.functor.obj ⊤ = U := by ext1 exact Set.image_univ.trans Subtype.range_coe @[simp] theorem inclusion_map_eq_top {X : TopCat} (U : Opens X) : (Opens.map U.inclusion).obj U = ⊤ := by ext1 exact Subtype.coe_preimage_self _ @[simp] theorem adjunction_counit_app_self {X : TopCat} (U : Opens X) : U.openEmbedding.isOpenMap.adjunction.counit.app U = eqToHom (by simp) := Subsingleton.elim _ _ theorem inclusion_top_functor (X : TopCat) : (@Opens.openEmbedding X ⊤).isOpenMap.functor = map (inclusionTopIso X).inv := by refine CategoryTheory.Functor.ext ?_ ?_ · intro U ext x exact ⟨fun ⟨⟨_, _⟩, h, rfl⟩ => h, fun h => ⟨⟨x, trivial⟩, h, rfl⟩⟩ · subsingleton theorem functor_obj_map_obj {X Y : TopCat} {f : X ⟶ Y} (hf : IsOpenMap f) (U : Opens Y) : hf.functor.obj ((Opens.map f).obj U) = hf.functor.obj ⊤ ⊓ U := by ext constructor · rintro ⟨x, hx, rfl⟩ exact ⟨⟨x, trivial, rfl⟩, hx⟩ · rintro ⟨⟨x, -, rfl⟩, hx⟩ exact ⟨x, hx, rfl⟩ -- Porting note: added to ease the proof of `functor_map_eq_inf` lemma set_range_forget_map_inclusion {X : TopCat} (U : Opens X) : Set.range ((forget TopCat).map (inclusion U)) = (U : Set X) := by ext x constructor · rintro ⟨x, rfl⟩ exact x.2 · intro h exact ⟨⟨x, h⟩, rfl⟩ @[simp] theorem functor_map_eq_inf {X : TopCat} (U V : Opens X) : U.openEmbedding.isOpenMap.functor.obj ((Opens.map U.inclusion).obj V) = V ⊓ U := by ext1 refine Set.image_preimage_eq_inter_range.trans ?_ erw [set_range_forget_map_inclusion U] rfl theorem map_functor_eq' {X U : TopCat} (f : U ⟶ X) (hf : OpenEmbedding f) (V) : ((Opens.map f).obj <| hf.isOpenMap.functor.obj V) = V := Opens.ext <| Set.preimage_image_eq _ hf.inj @[simp] theorem map_functor_eq {X : TopCat} {U : Opens X} (V : Opens U) : ((Opens.map U.inclusion).obj <| U.openEmbedding.isOpenMap.functor.obj V) = V := TopologicalSpace.Opens.map_functor_eq' _ U.openEmbedding V @[simp] theorem adjunction_counit_map_functor {X : TopCat} {U : Opens X} (V : Opens U) : U.openEmbedding.isOpenMap.adjunction.counit.app (U.openEmbedding.isOpenMap.functor.obj V) = eqToHom (by dsimp; rw [map_functor_eq V]) := by subsingleton end TopologicalSpace.Opens
Topology\Category\TopCat\Yoneda.lean
/- Copyright (c) 2023 Dagur Asgeirsson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Dagur Asgeirsson -/ import Mathlib.CategoryTheory.Limits.Preserves.Finite import Mathlib.CategoryTheory.Limits.Opposites import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Products import Mathlib.CategoryTheory.Limits.Shapes.Types import Mathlib.Topology.Category.TopCat.Limits.Products /-! # Yoneda presheaves on topologically concrete categories This file develops some API for "topologically concrete" categories, defining universe polymorphic "Yoneda presheaves" on such categories. -/ universe w w' v u open CategoryTheory Opposite Limits variable {C : Type u} [Category.{v} C] (F : C ⥤ TopCat.{w}) (Y : Type w') [TopologicalSpace Y] namespace ContinuousMap /-- A universe polymorphic "Yoneda presheaf" on `C` given by continuous maps into a topoological space `Y`. -/ @[simps] def yonedaPresheaf : Cᵒᵖ ⥤ Type (max w w') where obj X := C(F.obj (unop X), Y) map f g := ContinuousMap.comp g (F.map f.unop) /-- A universe polymorphic Yoneda presheaf on `TopCat` given by continuous maps into a topoological space `Y`. -/ @[simps] def yonedaPresheaf' : TopCat.{w}ᵒᵖ ⥤ Type (max w w') where obj X := C((unop X).1, Y) map f g := ContinuousMap.comp g f.unop theorem comp_yonedaPresheaf' : yonedaPresheaf F Y = F.op ⋙ yonedaPresheaf' Y := rfl theorem piComparison_fac {α : Type} (X : α → TopCat) : piComparison (yonedaPresheaf'.{w, w'} Y) (fun x ↦ op (X x)) = (yonedaPresheaf' Y).map ((opCoproductIsoProduct X).inv ≫ (TopCat.sigmaIsoSigma X).inv.op) ≫ (equivEquivIso (sigmaEquiv Y (fun x ↦ (X x).1))).inv ≫ (Types.productIso _).inv := by rw [← Category.assoc, Iso.eq_comp_inv] ext simp only [yonedaPresheaf', unop_op, piComparison, types_comp_apply, Types.productIso_hom_comp_eval_apply, Types.pi_lift_π_apply, comp_apply, TopCat.coe_of, unop_comp, Quiver.Hom.unop_op, sigmaEquiv, equivEquivIso_hom, Equiv.toIso_inv, Equiv.coe_fn_symm_mk, comp_assoc, sigmaMk_apply, ← opCoproductIsoProduct_inv_comp_ι] rfl /-- The universe polymorphic Yoneda presheaf on `TopCat` preserves finite products. -/ noncomputable instance : PreservesFiniteProducts (yonedaPresheaf'.{w, w'} Y) where preserves J _ := { preservesLimit := fun {K} => have : ∀ {α : Type} (X : α → TopCat), PreservesLimit (Discrete.functor (fun x ↦ op (X x))) (yonedaPresheaf'.{w, w'} Y) := fun X => @PreservesProduct.ofIsoComparison _ _ _ _ (yonedaPresheaf' Y) _ (fun x ↦ op (X x)) _ _ (by rw [piComparison_fac]; infer_instance) let i : K ≅ Discrete.functor (fun i ↦ op (unop (K.obj ⟨i⟩))) := Discrete.natIsoFunctor preservesLimitOfIsoDiagram _ i.symm } end ContinuousMap
Topology\Category\TopCat\Limits\Basic.lean
/- Copyright (c) 2017 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot, Scott Morrison, Mario Carneiro, Andrew Yang -/ import Mathlib.Topology.Category.TopCat.Basic import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Basic /-! # The category of topological spaces has all limits and colimits Further, these limits and colimits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ open TopologicalSpace CategoryTheory CategoryTheory.Limits Opposite universe v u w noncomputable section namespace TopCat variable {J : Type v} [SmallCategory J] local notation "forget" => forget TopCat /-- A choice of limit cone for a functor `F : J ⥤ TopCat`. Generally you should just use `limit.cone F`, unless you need the actual definition (which is in terms of `Types.limitCone`). -/ def limitCone (F : J ⥤ TopCat.{max v u}) : Cone F where pt := TopCat.of { u : ∀ j : J, F.obj j | ∀ {i j : J} (f : i ⟶ j), F.map f (u i) = u j } π := { app := fun j => { toFun := fun u => u.val j -- Porting note: `continuity` from the original mathlib3 proof failed here. continuous_toFun := Continuous.comp (continuous_apply _) (continuous_subtype_val) } naturality := fun X Y f => by -- Automation fails in various ways in this proof. Why?! dsimp rw [Category.id_comp] apply ContinuousMap.ext intro a exact (a.2 f).symm } /-- A choice of limit cone for a functor `F : J ⥤ TopCat` whose topology is defined as an infimum of topologies infimum. Generally you should just use `limit.cone F`, unless you need the actual definition (which is in terms of `Types.limitCone`). -/ def limitConeInfi (F : J ⥤ TopCat.{max v u}) : Cone F where pt := ⟨(Types.limitCone.{v,u} (F ⋙ forget)).pt, ⨅ j, (F.obj j).str.induced ((Types.limitCone.{v,u} (F ⋙ forget)).π.app j)⟩ π := { app := fun j => ⟨(Types.limitCone.{v,u} (F ⋙ forget)).π.app j, continuous_iff_le_induced.mpr (iInf_le _ _)⟩ naturality := fun _ _ f => ContinuousMap.coe_injective ((Types.limitCone.{v,u} (F ⋙ forget)).π.naturality f) } /-- The chosen cone `TopCat.limitCone F` for a functor `F : J ⥤ TopCat` is a limit cone. Generally you should just use `limit.isLimit F`, unless you need the actual definition (which is in terms of `Types.limitConeIsLimit`). -/ def limitConeIsLimit (F : J ⥤ TopCat.{max v u}) : IsLimit (limitCone.{v,u} F) where lift S := { toFun := fun x => ⟨fun j => S.π.app _ x, fun f => by dsimp erw [← S.w f] rfl⟩ continuous_toFun := Continuous.subtype_mk (continuous_pi fun j => (S.π.app j).2) fun x i j f => by dsimp rw [← S.w f] rfl } uniq S m h := by apply ContinuousMap.ext; intros a; apply Subtype.ext; funext j dsimp rw [← h] rfl /-- The chosen cone `TopCat.limitConeInfi F` for a functor `F : J ⥤ TopCat` is a limit cone. Generally you should just use `limit.isLimit F`, unless you need the actual definition (which is in terms of `Types.limitConeIsLimit`). -/ def limitConeInfiIsLimit (F : J ⥤ TopCat.{max v u}) : IsLimit (limitConeInfi.{v,u} F) := by refine IsLimit.ofFaithful forget (Types.limitConeIsLimit.{v,u} (F ⋙ forget)) -- Porting note: previously could infer all ?_ except continuity (fun s => ⟨fun v => ⟨fun j => (Functor.mapCone forget s).π.app j v, ?_⟩, ?_⟩) fun s => ?_ · dsimp [Functor.sections] intro _ _ _ rw [← comp_apply', forget_map_eq_coe, ← s.π.naturality, forget_map_eq_coe] dsimp rw [Category.id_comp] · exact continuous_iff_coinduced_le.mpr (le_iInf fun j => coinduced_le_iff_le_induced.mp <| (continuous_iff_coinduced_le.mp (s.π.app j).continuous : _)) · rfl instance topCat_hasLimitsOfSize : HasLimitsOfSize.{v, v} TopCat.{max v u} where has_limits_of_shape _ := { has_limit := fun F => HasLimit.mk { cone := limitCone.{v,u} F isLimit := limitConeIsLimit F } } instance topCat_hasLimits : HasLimits TopCat.{u} := TopCat.topCat_hasLimitsOfSize.{u, u} instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize forget where preservesLimitsOfShape {_} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v,u} F) (Types.limitConeIsLimit.{v,u} (F ⋙ forget)) } instance forgetPreservesLimits : PreservesLimits forget := TopCat.forgetPreservesLimitsOfSize.{u,u} /-- A choice of colimit cocone for a functor `F : J ⥤ TopCat`. Generally you should just use `colimit.cocone F`, unless you need the actual definition (which is in terms of `Types.colimitCocone`). -/ def colimitCocone (F : J ⥤ TopCat.{max v u}) : Cocone F where pt := ⟨(Types.TypeMax.colimitCocone.{v,u} (F ⋙ forget)).pt, ⨆ j, (F.obj j).str.coinduced ((Types.TypeMax.colimitCocone (F ⋙ forget)).ι.app j)⟩ ι := { app := fun j => ⟨(Types.TypeMax.colimitCocone (F ⋙ forget)).ι.app j, continuous_iff_coinduced_le.mpr <| -- Porting note: didn't need function before le_iSup (fun j => coinduced ((Types.TypeMax.colimitCocone (F ⋙ forget)).ι.app j) (F.obj j).str) j⟩ naturality := fun _ _ f => ContinuousMap.coe_injective ((Types.TypeMax.colimitCocone (F ⋙ forget)).ι.naturality f) } /-- The chosen cocone `TopCat.colimitCocone F` for a functor `F : J ⥤ TopCat` is a colimit cocone. Generally you should just use `colimit.isColimit F`, unless you need the actual definition (which is in terms of `Types.colimitCoconeIsColimit`). -/ def colimitCoconeIsColimit (F : J ⥤ TopCat.{max v u}) : IsColimit (colimitCocone F) := by refine IsColimit.ofFaithful forget (Types.TypeMax.colimitCoconeIsColimit.{v, u} _) (fun s => -- Porting note: it appears notation for forget breaks dot notation (also above) -- Porting note: previously function was inferred ⟨Quot.lift (fun p => (Functor.mapCocone forget s).ι.app p.fst p.snd) ?_, ?_⟩) fun s => ?_ · intro _ _ ⟨_, h⟩ dsimp rw [h, Functor.comp_map, ← comp_apply', s.ι.naturality] dsimp rw [Category.comp_id] · exact continuous_iff_le_induced.mpr (iSup_le fun j => coinduced_le_iff_le_induced.mp <| (continuous_iff_coinduced_le.mp (s.ι.app j).continuous : _)) · rfl instance topCat_hasColimitsOfSize : HasColimitsOfSize.{v,v} TopCat.{max v u} where has_colimits_of_shape _ := { has_colimit := fun F => HasColimit.mk { cocone := colimitCocone F isColimit := colimitCoconeIsColimit F } } instance topCat_hasColimits : HasColimits TopCat.{u} := TopCat.topCat_hasColimitsOfSize.{u, u} instance forgetPreservesColimitsOfSize : PreservesColimitsOfSize.{v, v} forget where preservesColimitsOfShape := { preservesColimit := fun {F} => preservesColimitOfPreservesColimitCocone (colimitCoconeIsColimit F) (Types.TypeMax.colimitCoconeIsColimit (F ⋙ forget)) } instance forgetPreservesColimits : PreservesColimits (forget : TopCat.{u} ⥤ Type u) := TopCat.forgetPreservesColimitsOfSize.{u, u} /-- The terminal object of `Top` is `PUnit`. -/ def isTerminalPUnit : IsTerminal (TopCat.of PUnit.{u + 1}) := haveI : ∀ X, Unique (X ⟶ TopCat.of PUnit.{u + 1}) := fun X => ⟨⟨⟨fun _ => PUnit.unit, by continuity⟩⟩, fun f => by ext; aesop⟩ Limits.IsTerminal.ofUnique _ /-- The terminal object of `Top` is `PUnit`. -/ def terminalIsoPUnit : ⊤_ TopCat.{u} ≅ TopCat.of PUnit := terminalIsTerminal.uniqueUpToIso isTerminalPUnit /-- The initial object of `Top` is `PEmpty`. -/ def isInitialPEmpty : IsInitial (TopCat.of PEmpty.{u + 1}) := haveI : ∀ X, Unique (TopCat.of PEmpty.{u + 1} ⟶ X) := fun X => ⟨⟨⟨fun x => x.elim, by continuity⟩⟩, fun f => by ext ⟨⟩⟩ Limits.IsInitial.ofUnique _ /-- The initial object of `Top` is `PEmpty`. -/ def initialIsoPEmpty : ⊥_ TopCat.{u} ≅ TopCat.of PEmpty := initialIsInitial.uniqueUpToIso isInitialPEmpty end TopCat
Topology\Category\TopCat\Limits\Cofiltered.lean
/- Copyright (c) 2017 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot, Scott Morrison, Mario Carneiro, Andrew Yang -/ import Mathlib.Topology.Category.TopCat.Limits.Basic import Mathlib.CategoryTheory.Filtered.Basic /-! # Cofiltered limits in the category of topological spaces Given a *compatible* collection of topological bases for the factors in a cofiltered limit which contain `Set.univ` and are closed under intersections, the induced *naive* collection of sets in the limit is, in fact, a topological basis. -/ open TopologicalSpace open CategoryTheory open CategoryTheory.Limits universe u v w noncomputable section namespace TopCat section CofilteredLimit variable {J : Type v} [SmallCategory J] [IsCofiltered J] (F : J ⥤ TopCat.{max v u}) (C : Cone F) /-- Given a *compatible* collection of topological bases for the factors in a cofiltered limit which contain `Set.univ` and are closed under intersections, the induced *naive* collection of sets in the limit is, in fact, a topological basis. -/ theorem isTopologicalBasis_cofiltered_limit (hC : IsLimit C) (T : ∀ j, Set (Set (F.obj j))) (hT : ∀ j, IsTopologicalBasis (T j)) (univ : ∀ i : J, Set.univ ∈ T i) (inter : ∀ (i) (U1 U2 : Set (F.obj i)), U1 ∈ T i → U2 ∈ T i → U1 ∩ U2 ∈ T i) (compat : ∀ (i j : J) (f : i ⟶ j) (V : Set (F.obj j)) (_hV : V ∈ T j), F.map f ⁻¹' V ∈ T i) : IsTopologicalBasis {U : Set C.pt | ∃ (j : _) (V : Set (F.obj j)), V ∈ T j ∧ U = C.π.app j ⁻¹' V} := by classical -- The limit cone for `F` whose topology is defined as an infimum. let D := limitConeInfi F -- The isomorphism between the cone point of `C` and the cone point of `D`. let E : C.pt ≅ D.pt := hC.conePointUniqueUpToIso (limitConeInfiIsLimit _) have hE : Inducing E.hom := (TopCat.homeoOfIso E).inducing -- Reduce to the assertion of the theorem with `D` instead of `C`. suffices IsTopologicalBasis {U : Set D.pt | ∃ (j : _) (V : Set (F.obj j)), V ∈ T j ∧ U = D.π.app j ⁻¹' V} by convert this.inducing hE ext U0 constructor · rintro ⟨j, V, hV, rfl⟩ exact ⟨D.π.app j ⁻¹' V, ⟨j, V, hV, rfl⟩, rfl⟩ · rintro ⟨W, ⟨j, V, hV, rfl⟩, rfl⟩ exact ⟨j, V, hV, rfl⟩ -- Using `D`, we can apply the characterization of the topological basis of a -- topology defined as an infimum... convert IsTopologicalBasis.iInf_induced hT fun j (x : D.pt) => D.π.app j x using 1 ext U0 constructor · rintro ⟨j, V, hV, rfl⟩ let U : ∀ i, Set (F.obj i) := fun i => if h : i = j then by rw [h]; exact V else Set.univ refine ⟨U, {j}, ?_, ?_⟩ · simp only [Finset.mem_singleton] rintro i rfl simpa [U] · simp [U] · rintro ⟨U, G, h1, h2⟩ obtain ⟨j, hj⟩ := IsCofiltered.inf_objs_exists G let g : ∀ e ∈ G, j ⟶ e := fun _ he => (hj he).some let Vs : J → Set (F.obj j) := fun e => if h : e ∈ G then F.map (g e h) ⁻¹' U e else Set.univ let V : Set (F.obj j) := ⋂ (e : J) (_he : e ∈ G), Vs e refine ⟨j, V, ?_, ?_⟩ · -- An intermediate claim used to apply induction along `G : Finset J` later on. have : ∀ (S : Set (Set (F.obj j))) (E : Finset J) (P : J → Set (F.obj j)) (_univ : Set.univ ∈ S) (_inter : ∀ A B : Set (F.obj j), A ∈ S → B ∈ S → A ∩ B ∈ S) (_cond : ∀ (e : J) (_he : e ∈ E), P e ∈ S), (⋂ (e) (_he : e ∈ E), P e) ∈ S := by intro S E induction E using Finset.induction_on with | empty => intro P he _hh simpa | @insert a E _ha hh1 => intro hh2 hh3 hh4 hh5 rw [Finset.set_biInter_insert] refine hh4 _ _ (hh5 _ (Finset.mem_insert_self _ _)) (hh1 _ hh3 hh4 ?_) intro e he exact hh5 e (Finset.mem_insert_of_mem he) -- use the intermediate claim to finish off the goal using `univ` and `inter`. refine this _ _ _ (univ _) (inter _) ?_ intro e he dsimp [Vs] rw [dif_pos he] exact compat j e (g e he) (U e) (h1 e he) · -- conclude... rw [h2] change _ = (D.π.app j)⁻¹' ⋂ (e : J) (_ : e ∈ G), Vs e rw [Set.preimage_iInter] apply congrArg ext1 e erw [Set.preimage_iInter] apply congrArg ext1 he -- Porting note: needed more hand holding here change (D.π.app e)⁻¹' U e = (D.π.app j) ⁻¹' if h : e ∈ G then F.map (g e h) ⁻¹' U e else Set.univ rw [dif_pos he, ← Set.preimage_comp] apply congrFun apply congrArg erw [← coe_comp, D.w] -- now `erw` after #13170 rfl end CofilteredLimit end TopCat
Topology\Category\TopCat\Limits\Konig.lean
/- Copyright (c) 2021 Kyle Miller. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kyle Miller -/ import Mathlib.CategoryTheory.Filtered.Basic import Mathlib.Topology.Category.TopCat.Limits.Basic /-! # Topological Kőnig's lemma A topological version of Kőnig's lemma is that the inverse limit of nonempty compact Hausdorff spaces is nonempty. (Note: this can be generalized further to inverse limits of nonempty compact T0 spaces, where all the maps are closed maps; see [Stone1979] --- however there is an erratum for Theorem 4 that the element in the inverse limit can have cofinally many components that are not closed points.) We give this in a more general form, which is that cofiltered limits of nonempty compact Hausdorff spaces are nonempty (`nonempty_limitCone_of_compact_t2_cofiltered_system`). This also applies to inverse limits, where `{J : Type u} [Preorder J] [IsDirected J (≤)]` and `F : Jᵒᵖ ⥤ TopCat`. The theorem is specialized to nonempty finite types (which are compact Hausdorff with the discrete topology) in lemmas `nonempty_sections_of_finite_cofiltered_system` and `nonempty_sections_of_finite_inverse_system` in the file `Mathlib.CategoryTheory.CofilteredSystem`. (See <https://stacks.math.columbia.edu/tag/086J> for the Set version.) -/ open CategoryTheory open CategoryTheory.Limits -- Porting note: changed universe order as `v` is usually passed explicitly universe v u w noncomputable section namespace TopCat section TopologicalKonig variable {J : Type u} [SmallCategory J] -- Porting note: generalized `F` to land in `v` not `u` variable (F : J ⥤ TopCat.{v}) private abbrev FiniteDiagramArrow {J : Type u} [SmallCategory J] (G : Finset J) := Σ' (X Y : J) (_ : X ∈ G) (_ : Y ∈ G), X ⟶ Y private abbrev FiniteDiagram (J : Type u) [SmallCategory J] := Σ G : Finset J, Finset (FiniteDiagramArrow G) /-- Partial sections of a cofiltered limit are sections when restricted to a finite subset of objects and morphisms of `J`. -/ -- Porting note: generalized `F` to land in `v` not `u` def partialSections {J : Type u} [SmallCategory J] (F : J ⥤ TopCat.{v}) {G : Finset J} (H : Finset (FiniteDiagramArrow G)) : Set (∀ j, F.obj j) := {u | ∀ {f : FiniteDiagramArrow G} (_ : f ∈ H), F.map f.2.2.2.2 (u f.1) = u f.2.1} theorem partialSections.nonempty [IsCofilteredOrEmpty J] [h : ∀ j : J, Nonempty (F.obj j)] {G : Finset J} (H : Finset (FiniteDiagramArrow G)) : (partialSections F H).Nonempty := by classical cases isEmpty_or_nonempty J · exact ⟨isEmptyElim, fun {j} => IsEmpty.elim' inferInstance j.1⟩ haveI : IsCofiltered J := ⟨⟩ use fun j : J => if hj : j ∈ G then F.map (IsCofiltered.infTo G H hj) (h (IsCofiltered.inf G H)).some else (h _).some rintro ⟨X, Y, hX, hY, f⟩ hf dsimp only rwa [dif_pos hX, dif_pos hY, ← comp_app, ← F.map_comp, @IsCofiltered.infTo_commutes _ _ _ G H] theorem partialSections.directed : Directed Superset fun G : FiniteDiagram J => partialSections F G.2 := by classical intro A B let ιA : FiniteDiagramArrow A.1 → FiniteDiagramArrow (A.1 ⊔ B.1) := fun f => ⟨f.1, f.2.1, Finset.mem_union_left _ f.2.2.1, Finset.mem_union_left _ f.2.2.2.1, f.2.2.2.2⟩ let ιB : FiniteDiagramArrow B.1 → FiniteDiagramArrow (A.1 ⊔ B.1) := fun f => ⟨f.1, f.2.1, Finset.mem_union_right _ f.2.2.1, Finset.mem_union_right _ f.2.2.2.1, f.2.2.2.2⟩ refine ⟨⟨A.1 ⊔ B.1, A.2.image ιA ⊔ B.2.image ιB⟩, ?_, ?_⟩ · rintro u hu f hf have : ιA f ∈ A.2.image ιA ⊔ B.2.image ιB := by apply Finset.mem_union_left rw [Finset.mem_image] exact ⟨f, hf, rfl⟩ exact hu this · rintro u hu f hf have : ιB f ∈ A.2.image ιA ⊔ B.2.image ιB := by apply Finset.mem_union_right rw [Finset.mem_image] exact ⟨f, hf, rfl⟩ exact hu this theorem partialSections.closed [∀ j : J, T2Space (F.obj j)] {G : Finset J} (H : Finset (FiniteDiagramArrow G)) : IsClosed (partialSections F H) := by have : partialSections F H = ⋂ (f : FiniteDiagramArrow G) (_ : f ∈ H), {u | F.map f.2.2.2.2 (u f.1) = u f.2.1} := by ext1 simp only [Set.mem_iInter, Set.mem_setOf_eq] rfl rw [this] apply isClosed_biInter intro f _ -- Porting note: can't see through forget have : T2Space ((forget TopCat).obj (F.obj f.snd.fst)) := inferInstanceAs (T2Space (F.obj f.snd.fst)) apply isClosed_eq -- Porting note: used to be a single `continuity` that closed both goals · exact (F.map f.snd.snd.snd.snd).continuous.comp (continuous_apply f.fst) · continuity /-- Cofiltered limits of nonempty compact Hausdorff spaces are nonempty topological spaces. -/ -- Porting note: generalized from `TopCat.{u}` to `TopCat.{max v u}` theorem nonempty_limitCone_of_compact_t2_cofiltered_system (F : J ⥤ TopCat.{max v u}) [IsCofilteredOrEmpty J] [∀ j : J, Nonempty (F.obj j)] [∀ j : J, CompactSpace (F.obj j)] [∀ j : J, T2Space (F.obj j)] : Nonempty (TopCat.limitCone F).pt := by classical obtain ⟨u, hu⟩ := IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed (fun G => partialSections F _) (partialSections.directed F) (fun G => partialSections.nonempty F _) (fun G => IsClosed.isCompact (partialSections.closed F _)) fun G => partialSections.closed F _ use u intro X Y f let G : FiniteDiagram J := ⟨{X, Y}, {⟨X, Y, by simp only [true_or_iff, eq_self_iff_true, Finset.mem_insert], by simp only [eq_self_iff_true, or_true_iff, Finset.mem_insert, Finset.mem_singleton], f⟩}⟩ exact hu _ ⟨G, rfl⟩ (Finset.mem_singleton_self _) end TopologicalKonig end TopCat
Topology\Category\TopCat\Limits\Products.lean
/- Copyright (c) 2017 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot, Scott Morrison, Mario Carneiro, Andrew Yang -/ import Mathlib.Topology.Category.TopCat.EpiMono import Mathlib.Topology.Category.TopCat.Limits.Basic import Mathlib.CategoryTheory.Limits.Shapes.Products import Mathlib.CategoryTheory.Limits.ConcreteCategory.Basic import Mathlib.Data.Set.Subsingleton import Mathlib.Tactic.CategoryTheory.Elementwise /-! # Products and coproducts in the category of topological spaces -/ open TopologicalSpace open CategoryTheory open CategoryTheory.Limits universe v u w noncomputable section namespace TopCat variable {J : Type v} [SmallCategory J] /-- The projection from the product as a bundled continuous map. -/ abbrev piπ {ι : Type v} (α : ι → TopCat.{max v u}) (i : ι) : TopCat.of (∀ i, α i) ⟶ α i := ⟨fun f => f i, continuous_apply i⟩ /-- The explicit fan of a family of topological spaces given by the pi type. -/ @[simps! pt π_app] def piFan {ι : Type v} (α : ι → TopCat.{max v u}) : Fan α := Fan.mk (TopCat.of (∀ i, α i)) (piπ.{v,u} α) /-- The constructed fan is indeed a limit -/ def piFanIsLimit {ι : Type v} (α : ι → TopCat.{max v u}) : IsLimit (piFan α) where lift S := { toFun := fun s i => S.π.app ⟨i⟩ s continuous_toFun := continuous_pi (fun i => (S.π.app ⟨i⟩).2) } uniq := by intro S m h apply ContinuousMap.ext; intro x funext i set_option tactic.skipAssignedInstances false in dsimp rw [ContinuousMap.coe_mk, ← h ⟨i⟩] rfl fac s j := rfl /-- The product is homeomorphic to the product of the underlying spaces, equipped with the product topology. -/ def piIsoPi {ι : Type v} (α : ι → TopCat.{max v u}) : ∏ᶜ α ≅ TopCat.of (∀ i, α i) := (limit.isLimit _).conePointUniqueUpToIso (piFanIsLimit.{v, u} α) -- Specifying the universes in `piFanIsLimit` wasn't necessary when we had `TopCatMax`  @[reassoc (attr := simp)] theorem piIsoPi_inv_π {ι : Type v} (α : ι → TopCat.{max v u}) (i : ι) : (piIsoPi α).inv ≫ Pi.π α i = piπ α i := by simp [piIsoPi] theorem piIsoPi_inv_π_apply {ι : Type v} (α : ι → TopCat.{max v u}) (i : ι) (x : ∀ i, α i) : (Pi.π α i : _) ((piIsoPi α).inv x) = x i := ConcreteCategory.congr_hom (piIsoPi_inv_π α i) x -- Porting note: needing the type ascription on `∏ᶜ α : TopCat.{max v u}` is unfortunate. theorem piIsoPi_hom_apply {ι : Type v} (α : ι → TopCat.{max v u}) (i : ι) (x : (∏ᶜ α : TopCat.{max v u})) : (piIsoPi α).hom x i = (Pi.π α i : _) x := by have := piIsoPi_inv_π α i rw [Iso.inv_comp_eq] at this exact ConcreteCategory.congr_hom this x -- Porting note: Lean doesn't automatically reduce TopCat.of X|>.α to X now /-- The inclusion to the coproduct as a bundled continuous map. -/ abbrev sigmaι {ι : Type v} (α : ι → TopCat.{max v u}) (i : ι) : α i ⟶ TopCat.of (Σi, α i) := by refine ContinuousMap.mk ?_ ?_ · dsimp apply Sigma.mk i · dsimp; continuity /-- The explicit cofan of a family of topological spaces given by the sigma type. -/ @[simps! pt ι_app] def sigmaCofan {ι : Type v} (α : ι → TopCat.{max v u}) : Cofan α := Cofan.mk (TopCat.of (Σi, α i)) (sigmaι α) /-- The constructed cofan is indeed a colimit -/ def sigmaCofanIsColimit {ι : Type v} (β : ι → TopCat.{max v u}) : IsColimit (sigmaCofan β) where desc S := { toFun := fun (s : of (Σ i, β i)) => S.ι.app ⟨s.1⟩ s.2 continuous_toFun := continuous_sigma fun i => (S.ι.app ⟨i⟩).continuous_toFun } uniq := by intro S m h ext ⟨i, x⟩ simp only [hom_apply, ← h] congr fac s j := by cases j aesop_cat /-- The coproduct is homeomorphic to the disjoint union of the topological spaces. -/ def sigmaIsoSigma {ι : Type v} (α : ι → TopCat.{max v u}) : ∐ α ≅ TopCat.of (Σi, α i) := (colimit.isColimit _).coconePointUniqueUpToIso (sigmaCofanIsColimit.{v, u} α) -- Specifying the universes in `sigmaCofanIsColimit` wasn't necessary when we had `TopCatMax`  @[reassoc (attr := simp)] theorem sigmaIsoSigma_hom_ι {ι : Type v} (α : ι → TopCat.{max v u}) (i : ι) : Sigma.ι α i ≫ (sigmaIsoSigma α).hom = sigmaι α i := by simp [sigmaIsoSigma] theorem sigmaIsoSigma_hom_ι_apply {ι : Type v} (α : ι → TopCat.{max v u}) (i : ι) (x : α i) : (sigmaIsoSigma α).hom ((Sigma.ι α i : _) x) = Sigma.mk i x := ConcreteCategory.congr_hom (sigmaIsoSigma_hom_ι α i) x theorem sigmaIsoSigma_inv_apply {ι : Type v} (α : ι → TopCat.{max v u}) (i : ι) (x : α i) : (sigmaIsoSigma α).inv ⟨i, x⟩ = (Sigma.ι α i : _) x := by rw [← sigmaIsoSigma_hom_ι_apply, ← comp_app, ← comp_app, Iso.hom_inv_id, Category.comp_id] -- Porting note: cannot use .topologicalSpace in place .str theorem induced_of_isLimit {F : J ⥤ TopCat.{max v u}} (C : Cone F) (hC : IsLimit C) : C.pt.str = ⨅ j, (F.obj j).str.induced (C.π.app j) := by let homeo := homeoOfIso (hC.conePointUniqueUpToIso (limitConeInfiIsLimit F)) refine homeo.inducing.induced.trans ?_ change induced homeo (⨅ j : J, _) = _ simp [induced_iInf, induced_compose] rfl theorem limit_topology (F : J ⥤ TopCat.{max v u}) : (limit F).str = ⨅ j, (F.obj j).str.induced (limit.π F j) := induced_of_isLimit _ (limit.isLimit F) section Prod -- Porting note: why is autoParam not firing? /-- The first projection from the product. -/ abbrev prodFst {X Y : TopCat.{u}} : TopCat.of (X × Y) ⟶ X := ⟨Prod.fst, by continuity⟩ /-- The second projection from the product. -/ abbrev prodSnd {X Y : TopCat.{u}} : TopCat.of (X × Y) ⟶ Y := ⟨Prod.snd, by continuity⟩ /-- The explicit binary cofan of `X, Y` given by `X × Y`. -/ def prodBinaryFan (X Y : TopCat.{u}) : BinaryFan X Y := BinaryFan.mk prodFst prodSnd /-- The constructed binary fan is indeed a limit -/ def prodBinaryFanIsLimit (X Y : TopCat.{u}) : IsLimit (prodBinaryFan X Y) where lift := fun S : BinaryFan X Y => { toFun := fun s => (S.fst s, S.snd s) -- Porting note: continuity failed again here. Lean cannot infer -- ContinuousMapClass (X ⟶ Y) X Y for X Y : TopCat which may be one of the problems continuous_toFun := Continuous.prod_mk (BinaryFan.fst S).continuous_toFun (BinaryFan.snd S).continuous_toFun } fac := by rintro S (_ | _) <;> {dsimp; ext; rfl} uniq := by intro S m h -- Porting note: used to be `ext x` refine ContinuousMap.ext (fun (x : ↥(S.pt)) => Prod.ext ?_ ?_) · specialize h ⟨WalkingPair.left⟩ apply_fun fun e => e x at h exact h · specialize h ⟨WalkingPair.right⟩ apply_fun fun e => e x at h exact h /-- The homeomorphism between `X ⨯ Y` and the set-theoretic product of `X` and `Y`, equipped with the product topology. -/ def prodIsoProd (X Y : TopCat.{u}) : X ⨯ Y ≅ TopCat.of (X × Y) := (limit.isLimit _).conePointUniqueUpToIso (prodBinaryFanIsLimit X Y) @[reassoc (attr := simp)] theorem prodIsoProd_hom_fst (X Y : TopCat.{u}) : (prodIsoProd X Y).hom ≫ prodFst = Limits.prod.fst := by simp [← Iso.eq_inv_comp, prodIsoProd] rfl @[reassoc (attr := simp)] theorem prodIsoProd_hom_snd (X Y : TopCat.{u}) : (prodIsoProd X Y).hom ≫ prodSnd = Limits.prod.snd := by simp [← Iso.eq_inv_comp, prodIsoProd] rfl -- Porting note: need to force Lean to coerce X × Y to a type theorem prodIsoProd_hom_apply {X Y : TopCat.{u}} (x : ↑ (X ⨯ Y)) : (prodIsoProd X Y).hom x = ((Limits.prod.fst : X ⨯ Y ⟶ _) x, (Limits.prod.snd : X ⨯ Y ⟶ _) x) := by -- Porting note (#11041): `ext` didn't pick this up. apply Prod.ext · exact ConcreteCategory.congr_hom (prodIsoProd_hom_fst X Y) x · exact ConcreteCategory.congr_hom (prodIsoProd_hom_snd X Y) x @[reassoc (attr := simp), elementwise] theorem prodIsoProd_inv_fst (X Y : TopCat.{u}) : (prodIsoProd X Y).inv ≫ Limits.prod.fst = prodFst := by simp [Iso.inv_comp_eq] @[reassoc (attr := simp), elementwise] theorem prodIsoProd_inv_snd (X Y : TopCat.{u}) : (prodIsoProd X Y).inv ≫ Limits.prod.snd = prodSnd := by simp [Iso.inv_comp_eq] theorem prod_topology {X Y : TopCat.{u}} : (X ⨯ Y).str = induced (Limits.prod.fst : X ⨯ Y ⟶ _) X.str ⊓ induced (Limits.prod.snd : X ⨯ Y ⟶ _) Y.str := by let homeo := homeoOfIso (prodIsoProd X Y) refine homeo.inducing.induced.trans ?_ change induced homeo (_ ⊓ _) = _ simp [induced_compose] rfl theorem range_prod_map {W X Y Z : TopCat.{u}} (f : W ⟶ Y) (g : X ⟶ Z) : Set.range (Limits.prod.map f g) = (Limits.prod.fst : Y ⨯ Z ⟶ _) ⁻¹' Set.range f ∩ (Limits.prod.snd : Y ⨯ Z ⟶ _) ⁻¹' Set.range g := by ext x constructor · rintro ⟨y, rfl⟩ simp_rw [Set.mem_inter_iff, Set.mem_preimage, Set.mem_range] -- sizable changes in this proof after #13170 erw [← comp_apply, ← comp_apply] simp_rw [Limits.prod.map_fst, Limits.prod.map_snd, comp_apply] exact ⟨exists_apply_eq_apply _ _, exists_apply_eq_apply _ _⟩ · rintro ⟨⟨x₁, hx₁⟩, ⟨x₂, hx₂⟩⟩ use (prodIsoProd W X).inv (x₁, x₂) change (forget TopCat).map _ _ = _ apply Concrete.limit_ext rintro ⟨⟨⟩⟩ · change limit.π (pair Y Z) _ ((prod.map f g) _) = _ erw [← comp_apply, Limits.prod.map_fst] change (_ ≫ _ ≫ f) _ = _ erw [TopCat.prodIsoProd_inv_fst_assoc,TopCat.comp_app] exact hx₁ · change limit.π (pair Y Z) _ ((prod.map f g) _) = _ erw [← comp_apply, Limits.prod.map_snd] change (_ ≫ _ ≫ g) _ = _ erw [TopCat.prodIsoProd_inv_snd_assoc,TopCat.comp_app] exact hx₂ theorem inducing_prod_map {W X Y Z : TopCat.{u}} {f : W ⟶ X} {g : Y ⟶ Z} (hf : Inducing f) (hg : Inducing g) : Inducing (Limits.prod.map f g) := by constructor simp_rw [topologicalSpace_coe, prod_topology, induced_inf, induced_compose, ← coe_comp, prod.map_fst, prod.map_snd, coe_comp, ← induced_compose (g := f), ← induced_compose (g := g)] erw [← hf.induced, ← hg.induced] -- now `erw` after #13170 rfl -- `rfl` was not needed before #13170 theorem embedding_prod_map {W X Y Z : TopCat.{u}} {f : W ⟶ X} {g : Y ⟶ Z} (hf : Embedding f) (hg : Embedding g) : Embedding (Limits.prod.map f g) := ⟨inducing_prod_map hf.toInducing hg.toInducing, by haveI := (TopCat.mono_iff_injective _).mpr hf.inj haveI := (TopCat.mono_iff_injective _).mpr hg.inj exact (TopCat.mono_iff_injective _).mp inferInstance⟩ end Prod /-- The binary coproduct cofan in `TopCat`. -/ protected def binaryCofan (X Y : TopCat.{u}) : BinaryCofan X Y := BinaryCofan.mk (⟨Sum.inl, by continuity⟩ : X ⟶ TopCat.of (X ⊕ Y)) ⟨Sum.inr, by continuity⟩ /-- The constructed binary coproduct cofan in `TopCat` is the coproduct. -/ def binaryCofanIsColimit (X Y : TopCat.{u}) : IsColimit (TopCat.binaryCofan X Y) := by refine Limits.BinaryCofan.isColimitMk (fun s => {toFun := Sum.elim s.inl s.inr, continuous_toFun := ?_ }) ?_ ?_ ?_ · apply Continuous.sum_elim (BinaryCofan.inl s).continuous_toFun (BinaryCofan.inr s).continuous_toFun · intro s ext rfl · intro s ext rfl · intro s m h₁ h₂ ext (x | x) exacts [(ConcreteCategory.congr_hom h₁ x : _), (ConcreteCategory.congr_hom h₂ x : _)] theorem binaryCofan_isColimit_iff {X Y : TopCat} (c : BinaryCofan X Y) : Nonempty (IsColimit c) ↔ OpenEmbedding c.inl ∧ OpenEmbedding c.inr ∧ IsCompl (Set.range c.inl) (Set.range c.inr) := by classical constructor · rintro ⟨h⟩ rw [← show _ = c.inl from h.comp_coconePointUniqueUpToIso_inv (binaryCofanIsColimit X Y) ⟨WalkingPair.left⟩, ← show _ = c.inr from h.comp_coconePointUniqueUpToIso_inv (binaryCofanIsColimit X Y) ⟨WalkingPair.right⟩] dsimp refine ⟨(homeoOfIso <| h.coconePointUniqueUpToIso (binaryCofanIsColimit X Y)).symm.openEmbedding.comp openEmbedding_inl, (homeoOfIso <| h.coconePointUniqueUpToIso (binaryCofanIsColimit X Y)).symm.openEmbedding.comp openEmbedding_inr, ?_⟩ erw [Set.range_comp, ← eq_compl_iff_isCompl, Set.range_comp _ Sum.inr, ← Set.image_compl_eq (homeoOfIso <| h.coconePointUniqueUpToIso (binaryCofanIsColimit X Y)).symm.bijective, Set.compl_range_inr, Set.image_comp] · rintro ⟨h₁, h₂, h₃⟩ have : ∀ x, x ∈ Set.range c.inl ∨ x ∈ Set.range c.inr := by rw [eq_compl_iff_isCompl.mpr h₃.symm] exact fun _ => or_not refine ⟨BinaryCofan.IsColimit.mk _ ?_ ?_ ?_ ?_⟩ · intro T f g refine ContinuousMap.mk ?_ ?_ · exact fun x => if h : x ∈ Set.range c.inl then f ((Equiv.ofInjective _ h₁.inj).symm ⟨x, h⟩) else g ((Equiv.ofInjective _ h₂.inj).symm ⟨x, (this x).resolve_left h⟩) rw [continuous_iff_continuousAt] intro x by_cases h : x ∈ Set.range c.inl · revert h x apply (IsOpen.continuousOn_iff _).mp · rw [continuousOn_iff_continuous_restrict] convert_to Continuous (f ∘ (Homeomorph.ofEmbedding _ h₁.toEmbedding).symm) · ext ⟨x, hx⟩ exact dif_pos hx apply Continuous.comp · exact f.continuous_toFun · continuity · exact h₁.isOpen_range · revert h x apply (IsOpen.continuousOn_iff _).mp · rw [continuousOn_iff_continuous_restrict] have : ∀ a, a ∉ Set.range c.inl → a ∈ Set.range c.inr := by rintro a (h : a ∈ (Set.range c.inl)ᶜ) rwa [eq_compl_iff_isCompl.mpr h₃.symm] convert_to Continuous (g ∘ (Homeomorph.ofEmbedding _ h₂.toEmbedding).symm ∘ Subtype.map _ this) · ext ⟨x, hx⟩ exact dif_neg hx apply Continuous.comp · exact g.continuous_toFun · apply Continuous.comp · continuity · rw [embedding_subtype_val.toInducing.continuous_iff] exact continuous_subtype_val · change IsOpen (Set.range c.inl)ᶜ rw [← eq_compl_iff_isCompl.mpr h₃.symm] exact h₂.isOpen_range · intro T f g ext x refine (dif_pos ?_).trans ?_ · exact ⟨x, rfl⟩ · dsimp conv_lhs => erw [Equiv.ofInjective_symm_apply] rfl -- `rfl` was not needed here before #13170 · intro T f g ext x refine (dif_neg ?_).trans ?_ · rintro ⟨y, e⟩ have : c.inr x ∈ Set.range c.inl ⊓ Set.range c.inr := ⟨⟨_, e⟩, ⟨_, rfl⟩⟩ rwa [disjoint_iff.mp h₃.1] at this · exact congr_arg g (Equiv.ofInjective_symm_apply _ _) · rintro T _ _ m rfl rfl ext x change m x = dite _ _ _ split_ifs <;> exact congr_arg _ (Equiv.apply_ofInjective_symm _ ⟨_, _⟩).symm end TopCat
Topology\Category\TopCat\Limits\Pullbacks.lean
/- Copyright (c) 2017 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot, Scott Morrison, Mario Carneiro, Andrew Yang -/ import Mathlib.Topology.Category.TopCat.Limits.Products /-! # Pullbacks and pushouts in the category of topological spaces -/ open TopologicalSpace open CategoryTheory open CategoryTheory.Limits universe v u w noncomputable section namespace TopCat variable {J : Type v} [SmallCategory J] section Pullback variable {X Y Z : TopCat.{u}} /-- The first projection from the pullback. -/ abbrev pullbackFst (f : X ⟶ Z) (g : Y ⟶ Z) : TopCat.of { p : X × Y // f p.1 = g p.2 } ⟶ X := ⟨Prod.fst ∘ Subtype.val, by apply Continuous.comp <;> set_option tactic.skipAssignedInstances false in continuity⟩ lemma pullbackFst_apply (f : X ⟶ Z) (g : Y ⟶ Z) (x) : pullbackFst f g x = x.1.1 := rfl /-- The second projection from the pullback. -/ abbrev pullbackSnd (f : X ⟶ Z) (g : Y ⟶ Z) : TopCat.of { p : X × Y // f p.1 = g p.2 } ⟶ Y := ⟨Prod.snd ∘ Subtype.val, by apply Continuous.comp <;> set_option tactic.skipAssignedInstances false in continuity⟩ lemma pullbackSnd_apply (f : X ⟶ Z) (g : Y ⟶ Z) (x) : pullbackSnd f g x = x.1.2 := rfl /-- The explicit pullback cone of `X, Y` given by `{ p : X × Y // f p.1 = g p.2 }`. -/ def pullbackCone (f : X ⟶ Z) (g : Y ⟶ Z) : PullbackCone f g := PullbackCone.mk (pullbackFst f g) (pullbackSnd f g) (by dsimp [pullbackFst, pullbackSnd, Function.comp_def] ext ⟨x, h⟩ -- Next 2 lines were -- `rw [comp_apply, ContinuousMap.coe_mk, comp_apply, ContinuousMap.coe_mk]` -- `exact h` before leanprover/lean4#2644 rw [comp_apply, comp_apply] congr!) /-- The constructed cone is a limit. -/ def pullbackConeIsLimit (f : X ⟶ Z) (g : Y ⟶ Z) : IsLimit (pullbackCone f g) := PullbackCone.isLimitAux' _ (by intro S constructor; swap · exact { toFun := fun x => ⟨⟨S.fst x, S.snd x⟩, by simpa using ConcreteCategory.congr_hom S.condition x⟩ continuous_toFun := by apply Continuous.subtype_mk <| Continuous.prod_mk ?_ ?_ · exact (PullbackCone.fst S)|>.continuous_toFun · exact (PullbackCone.snd S)|>.continuous_toFun } refine ⟨?_, ?_, ?_⟩ · delta pullbackCone ext a -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [comp_apply, ContinuousMap.coe_mk] · delta pullbackCone ext a -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [comp_apply, ContinuousMap.coe_mk] · intro m h₁ h₂ -- Porting note (#11041): used to be `ext x`. apply ContinuousMap.ext; intro x apply Subtype.ext apply Prod.ext · simpa using ConcreteCategory.congr_hom h₁ x · simpa using ConcreteCategory.congr_hom h₂ x) /-- The pullback of two maps can be identified as a subspace of `X × Y`. -/ def pullbackIsoProdSubtype (f : X ⟶ Z) (g : Y ⟶ Z) : pullback f g ≅ TopCat.of { p : X × Y // f p.1 = g p.2 } := (limit.isLimit _).conePointUniqueUpToIso (pullbackConeIsLimit f g) @[reassoc (attr := simp)] theorem pullbackIsoProdSubtype_inv_fst (f : X ⟶ Z) (g : Y ⟶ Z) : (pullbackIsoProdSubtype f g).inv ≫ pullback.fst _ _ = pullbackFst f g := by simp [pullbackCone, pullbackIsoProdSubtype] theorem pullbackIsoProdSubtype_inv_fst_apply (f : X ⟶ Z) (g : Y ⟶ Z) (x : { p : X × Y // f p.1 = g p.2 }) : pullback.fst f g ((pullbackIsoProdSubtype f g).inv x) = (x : X × Y).fst := ConcreteCategory.congr_hom (pullbackIsoProdSubtype_inv_fst f g) x @[reassoc (attr := simp)] theorem pullbackIsoProdSubtype_inv_snd (f : X ⟶ Z) (g : Y ⟶ Z) : (pullbackIsoProdSubtype f g).inv ≫ pullback.snd _ _ = pullbackSnd f g := by simp [pullbackCone, pullbackIsoProdSubtype] theorem pullbackIsoProdSubtype_inv_snd_apply (f : X ⟶ Z) (g : Y ⟶ Z) (x : { p : X × Y // f p.1 = g p.2 }) : pullback.snd f g ((pullbackIsoProdSubtype f g).inv x) = (x : X × Y).snd := ConcreteCategory.congr_hom (pullbackIsoProdSubtype_inv_snd f g) x theorem pullbackIsoProdSubtype_hom_fst (f : X ⟶ Z) (g : Y ⟶ Z) : (pullbackIsoProdSubtype f g).hom ≫ pullbackFst f g = pullback.fst _ _ := by rw [← Iso.eq_inv_comp, pullbackIsoProdSubtype_inv_fst] theorem pullbackIsoProdSubtype_hom_snd (f : X ⟶ Z) (g : Y ⟶ Z) : (pullbackIsoProdSubtype f g).hom ≫ pullbackSnd f g = pullback.snd _ _ := by rw [← Iso.eq_inv_comp, pullbackIsoProdSubtype_inv_snd] -- Porting note: why do I need to tell Lean to coerce pullback to a type theorem pullbackIsoProdSubtype_hom_apply {f : X ⟶ Z} {g : Y ⟶ Z} (x : ConcreteCategory.forget.obj (pullback f g)) : (pullbackIsoProdSubtype f g).hom x = ⟨⟨pullback.fst f g x, pullback.snd f g x⟩, by simpa using ConcreteCategory.congr_hom pullback.condition x⟩ := by apply Subtype.ext; apply Prod.ext exacts [ConcreteCategory.congr_hom (pullbackIsoProdSubtype_hom_fst f g) x, ConcreteCategory.congr_hom (pullbackIsoProdSubtype_hom_snd f g) x] theorem pullback_topology {X Y Z : TopCat.{u}} (f : X ⟶ Z) (g : Y ⟶ Z) : (pullback f g).str = induced (pullback.fst f g) X.str ⊓ induced (pullback.snd f g) Y.str := by let homeo := homeoOfIso (pullbackIsoProdSubtype f g) refine homeo.inducing.induced.trans ?_ change induced homeo (induced _ ( (induced Prod.fst X.str) ⊓ (induced Prod.snd Y.str))) = _ simp only [induced_compose, induced_inf] congr theorem range_pullback_to_prod {X Y Z : TopCat} (f : X ⟶ Z) (g : Y ⟶ Z) : Set.range (prod.lift (pullback.fst f g) (pullback.snd f g)) = { x | (Limits.prod.fst ≫ f) x = (Limits.prod.snd ≫ g) x } := by ext x constructor · rintro ⟨y, rfl⟩ change (_ ≫ _ ≫ f) _ = (_ ≫ _ ≫ g) _ -- new `change` after #13170 simp [pullback.condition] · rintro (h : f (_, _).1 = g (_, _).2) use (pullbackIsoProdSubtype f g).inv ⟨⟨_, _⟩, h⟩ change (forget TopCat).map _ _ = _ -- new `change` after #13170 apply Concrete.limit_ext rintro ⟨⟨⟩⟩ <;> erw [← comp_apply, ← comp_apply, limit.lift_π] <;> -- now `erw` after #13170 -- This used to be `simp` before leanprover/lean4#2644 aesop_cat /-- The pullback along an embedding is (isomorphic to) the preimage. -/ noncomputable def pullbackHomeoPreimage {X Y Z : Type*} [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] (f : X → Z) (hf : Continuous f) (g : Y → Z) (hg : Embedding g) : { p : X × Y // f p.1 = g p.2 } ≃ₜ f ⁻¹' Set.range g where toFun := fun x ↦ ⟨x.1.1, _, x.2.symm⟩ invFun := fun x ↦ ⟨⟨x.1, Exists.choose x.2⟩, (Exists.choose_spec x.2).symm⟩ left_inv := by intro x ext <;> dsimp apply hg.inj convert x.prop exact Exists.choose_spec (p := fun y ↦ g y = f (↑x : X × Y).1) _ right_inv := fun x ↦ rfl continuous_toFun := by apply Continuous.subtype_mk exact continuous_fst.comp continuous_subtype_val continuous_invFun := by apply Continuous.subtype_mk refine continuous_prod_mk.mpr ⟨continuous_subtype_val, hg.toInducing.continuous_iff.mpr ?_⟩ convert hf.comp continuous_subtype_val ext x exact Exists.choose_spec x.2 theorem inducing_pullback_to_prod {X Y Z : TopCat.{u}} (f : X ⟶ Z) (g : Y ⟶ Z) : Inducing <| ⇑(prod.lift (pullback.fst f g) (pullback.snd f g)) := ⟨by simp [topologicalSpace_coe, prod_topology, pullback_topology, induced_compose, ← coe_comp]⟩ theorem embedding_pullback_to_prod {X Y Z : TopCat.{u}} (f : X ⟶ Z) (g : Y ⟶ Z) : Embedding <| ⇑(prod.lift (pullback.fst f g) (pullback.snd f g)) := ⟨inducing_pullback_to_prod f g, (TopCat.mono_iff_injective _).mp inferInstance⟩ /-- If the map `S ⟶ T` is mono, then there is a description of the image of `W ×ₛ X ⟶ Y ×ₜ Z`. -/ theorem range_pullback_map {W X Y Z S T : TopCat} (f₁ : W ⟶ S) (f₂ : X ⟶ S) (g₁ : Y ⟶ T) (g₂ : Z ⟶ T) (i₁ : W ⟶ Y) (i₂ : X ⟶ Z) (i₃ : S ⟶ T) [H₃ : Mono i₃] (eq₁ : f₁ ≫ i₃ = i₁ ≫ g₁) (eq₂ : f₂ ≫ i₃ = i₂ ≫ g₂) : Set.range (pullback.map f₁ f₂ g₁ g₂ i₁ i₂ i₃ eq₁ eq₂) = (pullback.fst g₁ g₂) ⁻¹' Set.range i₁ ∩ (pullback.snd g₁ g₂) ⁻¹' Set.range i₂ := by ext constructor · rintro ⟨y, rfl⟩ simp only [Set.mem_inter_iff, Set.mem_preimage, Set.mem_range] erw [← comp_apply, ← comp_apply] -- now `erw` after #13170 simp only [limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app, comp_apply] exact ⟨exists_apply_eq_apply _ _, exists_apply_eq_apply _ _⟩ rintro ⟨⟨x₁, hx₁⟩, ⟨x₂, hx₂⟩⟩ have : f₁ x₁ = f₂ x₂ := by apply (TopCat.mono_iff_injective _).mp H₃ erw [← comp_apply, eq₁, ← comp_apply, eq₂, -- now `erw` after #13170 comp_apply, comp_apply, hx₁, hx₂, ← comp_apply, pullback.condition] rfl -- `rfl` was not needed before #13170 use (pullbackIsoProdSubtype f₁ f₂).inv ⟨⟨x₁, x₂⟩, this⟩ change (forget TopCat).map _ _ = _ apply Concrete.limit_ext rintro (_ | _ | _) <;> erw [← comp_apply, ← comp_apply] -- now `erw` after #13170 · simp only [Category.assoc, limit.lift_π, PullbackCone.mk_π_app_one] simp only [cospan_one, pullbackIsoProdSubtype_inv_fst_assoc, comp_apply] erw [pullbackFst_apply, hx₁] rw [← limit.w _ WalkingCospan.Hom.inl, cospan_map_inl, comp_apply (g := g₁)] rfl -- `rfl` was not needed before #13170 · simp only [cospan_left, limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app, pullbackIsoProdSubtype_inv_fst_assoc, comp_apply] erw [hx₁] -- now `erw` after #13170 rfl -- `rfl` was not needed before #13170 · simp only [cospan_right, limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app, pullbackIsoProdSubtype_inv_snd_assoc, comp_apply] erw [hx₂] -- now `erw` after #13170 rfl -- `rfl` was not needed before #13170 theorem pullback_fst_range {X Y S : TopCat} (f : X ⟶ S) (g : Y ⟶ S) : Set.range (pullback.fst f g) = { x : X | ∃ y : Y, f x = g y } := by ext x constructor · rintro ⟨(y : (forget TopCat).obj _), rfl⟩ use (pullback.snd f g) y exact ConcreteCategory.congr_hom pullback.condition y · rintro ⟨y, eq⟩ use (TopCat.pullbackIsoProdSubtype f g).inv ⟨⟨x, y⟩, eq⟩ rw [pullbackIsoProdSubtype_inv_fst_apply] theorem pullback_snd_range {X Y S : TopCat} (f : X ⟶ S) (g : Y ⟶ S) : Set.range (pullback.snd f g) = { y : Y | ∃ x : X, f x = g y } := by ext y constructor · rintro ⟨(x : (forget TopCat).obj _), rfl⟩ use (pullback.fst f g) x exact ConcreteCategory.congr_hom pullback.condition x · rintro ⟨x, eq⟩ use (TopCat.pullbackIsoProdSubtype f g).inv ⟨⟨x, y⟩, eq⟩ rw [pullbackIsoProdSubtype_inv_snd_apply] /-- If there is a diagram where the morphisms `W ⟶ Y` and `X ⟶ Z` are embeddings, then the induced morphism `W ×ₛ X ⟶ Y ×ₜ Z` is also an embedding. ``` W ⟶ Y ↘ ↘ S ⟶ T ↗ ↗ X ⟶ Z ``` -/ theorem pullback_map_embedding_of_embeddings {W X Y Z S T : TopCat.{u}} (f₁ : W ⟶ S) (f₂ : X ⟶ S) (g₁ : Y ⟶ T) (g₂ : Z ⟶ T) {i₁ : W ⟶ Y} {i₂ : X ⟶ Z} (H₁ : Embedding i₁) (H₂ : Embedding i₂) (i₃ : S ⟶ T) (eq₁ : f₁ ≫ i₃ = i₁ ≫ g₁) (eq₂ : f₂ ≫ i₃ = i₂ ≫ g₂) : Embedding (pullback.map f₁ f₂ g₁ g₂ i₁ i₂ i₃ eq₁ eq₂) := by refine embedding_of_embedding_compose (ContinuousMap.continuous_toFun _) (show Continuous (prod.lift (pullback.fst g₁ g₂) (pullback.snd g₁ g₂)) from ContinuousMap.continuous_toFun _) ?_ suffices Embedding (prod.lift (pullback.fst f₁ f₂) (pullback.snd f₁ f₂) ≫ Limits.prod.map i₁ i₂) by simpa [← coe_comp] using this rw [coe_comp] exact Embedding.comp (embedding_prod_map H₁ H₂) (embedding_pullback_to_prod _ _) /-- If there is a diagram where the morphisms `W ⟶ Y` and `X ⟶ Z` are open embeddings, and `S ⟶ T` is mono, then the induced morphism `W ×ₛ X ⟶ Y ×ₜ Z` is also an open embedding. ``` W ⟶ Y ↘ ↘ S ⟶ T ↗ ↗ X ⟶ Z ``` -/ theorem pullback_map_openEmbedding_of_open_embeddings {W X Y Z S T : TopCat.{u}} (f₁ : W ⟶ S) (f₂ : X ⟶ S) (g₁ : Y ⟶ T) (g₂ : Z ⟶ T) {i₁ : W ⟶ Y} {i₂ : X ⟶ Z} (H₁ : OpenEmbedding i₁) (H₂ : OpenEmbedding i₂) (i₃ : S ⟶ T) [H₃ : Mono i₃] (eq₁ : f₁ ≫ i₃ = i₁ ≫ g₁) (eq₂ : f₂ ≫ i₃ = i₂ ≫ g₂) : OpenEmbedding (pullback.map f₁ f₂ g₁ g₂ i₁ i₂ i₃ eq₁ eq₂) := by constructor · apply pullback_map_embedding_of_embeddings f₁ f₂ g₁ g₂ H₁.toEmbedding H₂.toEmbedding i₃ eq₁ eq₂ · rw [range_pullback_map] apply IsOpen.inter <;> apply Continuous.isOpen_preimage · apply ContinuousMap.continuous_toFun · exact H₁.isOpen_range · apply ContinuousMap.continuous_toFun · exact H₂.isOpen_range theorem snd_embedding_of_left_embedding {X Y S : TopCat} {f : X ⟶ S} (H : Embedding f) (g : Y ⟶ S) : Embedding <| ⇑(pullback.snd f g) := by convert (homeoOfIso (asIso (pullback.snd (𝟙 S) g))).embedding.comp (pullback_map_embedding_of_embeddings (i₂ := 𝟙 Y) f g (𝟙 S) g H (homeoOfIso (Iso.refl _)).embedding (𝟙 _) rfl (by simp)) erw [← coe_comp] simp theorem fst_embedding_of_right_embedding {X Y S : TopCat} (f : X ⟶ S) {g : Y ⟶ S} (H : Embedding g) : Embedding <| ⇑(pullback.fst f g) := by convert (homeoOfIso (asIso (pullback.fst f (𝟙 S)))).embedding.comp (pullback_map_embedding_of_embeddings (i₁ := 𝟙 X) f g f (𝟙 _) (homeoOfIso (Iso.refl _)).embedding H (𝟙 _) rfl (by simp)) erw [← coe_comp] simp theorem embedding_of_pullback_embeddings {X Y S : TopCat} {f : X ⟶ S} {g : Y ⟶ S} (H₁ : Embedding f) (H₂ : Embedding g) : Embedding (limit.π (cospan f g) WalkingCospan.one) := by convert H₂.comp (snd_embedding_of_left_embedding H₁ g) erw [← coe_comp] rw [← limit.w _ WalkingCospan.Hom.inr] rfl theorem snd_openEmbedding_of_left_openEmbedding {X Y S : TopCat} {f : X ⟶ S} (H : OpenEmbedding f) (g : Y ⟶ S) : OpenEmbedding <| ⇑(pullback.snd f g) := by convert (homeoOfIso (asIso (pullback.snd (𝟙 S) g))).openEmbedding.comp (pullback_map_openEmbedding_of_open_embeddings (i₂ := 𝟙 Y) f g (𝟙 _) g H (homeoOfIso (Iso.refl _)).openEmbedding (𝟙 _) rfl (by simp)) erw [← coe_comp] simp theorem fst_openEmbedding_of_right_openEmbedding {X Y S : TopCat} (f : X ⟶ S) {g : Y ⟶ S} (H : OpenEmbedding g) : OpenEmbedding <| ⇑(pullback.fst f g) := by convert (homeoOfIso (asIso (pullback.fst f (𝟙 S)))).openEmbedding.comp (pullback_map_openEmbedding_of_open_embeddings (i₁ := 𝟙 X) f g f (𝟙 _) (homeoOfIso (Iso.refl _)).openEmbedding H (𝟙 _) rfl (by simp)) erw [← coe_comp] simp /-- If `X ⟶ S`, `Y ⟶ S` are open embeddings, then so is `X ×ₛ Y ⟶ S`. -/ theorem openEmbedding_of_pullback_open_embeddings {X Y S : TopCat} {f : X ⟶ S} {g : Y ⟶ S} (H₁ : OpenEmbedding f) (H₂ : OpenEmbedding g) : OpenEmbedding (limit.π (cospan f g) WalkingCospan.one) := by convert H₂.comp (snd_openEmbedding_of_left_openEmbedding H₁ g) erw [← coe_comp] rw [← limit.w _ WalkingCospan.Hom.inr] rfl theorem fst_iso_of_right_embedding_range_subset {X Y S : TopCat} (f : X ⟶ S) {g : Y ⟶ S} (hg : Embedding g) (H : Set.range f ⊆ Set.range g) : IsIso (pullback.fst f g) := by let esto : (pullback f g : TopCat) ≃ₜ X := (Homeomorph.ofEmbedding _ (fst_embedding_of_right_embedding f hg)).trans { toFun := Subtype.val invFun := fun x => ⟨x, by rw [pullback_fst_range] exact ⟨_, (H (Set.mem_range_self x)).choose_spec.symm⟩⟩ left_inv := fun ⟨_, _⟩ => rfl right_inv := fun x => rfl } convert (isoOfHomeo esto).isIso_hom theorem snd_iso_of_left_embedding_range_subset {X Y S : TopCat} {f : X ⟶ S} (hf : Embedding f) (g : Y ⟶ S) (H : Set.range g ⊆ Set.range f) : IsIso (pullback.snd f g) := by let esto : (pullback f g : TopCat) ≃ₜ Y := (Homeomorph.ofEmbedding _ (snd_embedding_of_left_embedding hf g)).trans { toFun := Subtype.val invFun := fun x => ⟨x, by rw [pullback_snd_range] exact ⟨_, (H (Set.mem_range_self x)).choose_spec⟩⟩ left_inv := fun ⟨_, _⟩ => rfl right_inv := fun x => rfl } convert (isoOfHomeo esto).isIso_hom theorem pullback_snd_image_fst_preimage (f : X ⟶ Z) (g : Y ⟶ Z) (U : Set X) : (pullback.snd f g) '' ((pullback.fst f g) ⁻¹' U) = g ⁻¹' (f '' U) := by ext x constructor · rintro ⟨(y : (forget TopCat).obj _), hy, rfl⟩ exact ⟨(pullback.fst f g) y, hy, ConcreteCategory.congr_hom pullback.condition y⟩ · rintro ⟨y, hy, eq⟩ -- next 5 lines were -- `exact ⟨(TopCat.pullbackIsoProdSubtype f g).inv ⟨⟨_, _⟩, eq⟩, by simpa, by simp⟩` before #13170 refine ⟨(TopCat.pullbackIsoProdSubtype f g).inv ⟨⟨_, _⟩, eq⟩, ?_, ?_⟩ · simp only [coe_of, Set.mem_preimage] convert hy erw [pullbackIsoProdSubtype_inv_fst_apply] · rw [pullbackIsoProdSubtype_inv_snd_apply] theorem pullback_fst_image_snd_preimage (f : X ⟶ Z) (g : Y ⟶ Z) (U : Set Y) : (pullback.fst f g) '' ((pullback.snd f g) ⁻¹' U) = f ⁻¹' (g '' U) := by ext x constructor · rintro ⟨(y : (forget TopCat).obj _), hy, rfl⟩ exact ⟨(pullback.snd f g) y, hy, (ConcreteCategory.congr_hom pullback.condition y).symm⟩ · rintro ⟨y, hy, eq⟩ -- next 5 lines were -- `exact ⟨(TopCat.pullbackIsoProdSubtype f g).inv ⟨⟨_, _⟩, eq.symm⟩, by simpa, by simp⟩` -- before #13170 refine ⟨(TopCat.pullbackIsoProdSubtype f g).inv ⟨⟨_, _⟩, eq.symm⟩, ?_, ?_⟩ · simp only [coe_of, Set.mem_preimage] convert hy erw [pullbackIsoProdSubtype_inv_snd_apply] · rw [pullbackIsoProdSubtype_inv_fst_apply] end Pullback --TODO: Add analogous constructions for `pushout`. theorem coinduced_of_isColimit {F : J ⥤ TopCat.{max v u}} (c : Cocone F) (hc : IsColimit c) : c.pt.str = ⨆ j, (F.obj j).str.coinduced (c.ι.app j) := by let homeo := homeoOfIso (hc.coconePointUniqueUpToIso (colimitCoconeIsColimit F)) ext refine homeo.symm.isOpen_preimage.symm.trans (Iff.trans ?_ isOpen_iSup_iff.symm) exact isOpen_iSup_iff theorem colimit_topology (F : J ⥤ TopCat.{max v u}) : (colimit F).str = ⨆ j, (F.obj j).str.coinduced (colimit.ι F j) := coinduced_of_isColimit _ (colimit.isColimit F) theorem colimit_isOpen_iff (F : J ⥤ TopCat.{max v u}) (U : Set ((colimit F : _) : Type max v u)) : IsOpen U ↔ ∀ j, IsOpen (colimit.ι F j ⁻¹' U) := by dsimp [topologicalSpace_coe] conv_lhs => rw [colimit_topology F] exact isOpen_iSup_iff theorem coequalizer_isOpen_iff (F : WalkingParallelPair ⥤ TopCat.{u}) (U : Set ((colimit F : _) : Type u)) : IsOpen U ↔ IsOpen (colimit.ι F WalkingParallelPair.one ⁻¹' U) := by rw [colimit_isOpen_iff] constructor · intro H exact H _ · intro H j cases j · rw [← colimit.w F WalkingParallelPairHom.left] exact (F.map WalkingParallelPairHom.left).continuous_toFun.isOpen_preimage _ H · exact H end TopCat
Topology\Compactification\OnePoint.lean
/- Copyright (c) 2021 Yourong Zang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yourong Zang, Yury Kudryashov -/ import Mathlib.Data.Fintype.Option import Mathlib.Topology.Separation import Mathlib.Topology.Sets.Opens /-! # The OnePoint Compactification We construct the OnePoint compactification (the one-point compactification) of an arbitrary topological space `X` and prove some properties inherited from `X`. ## Main definitions * `OnePoint`: the OnePoint compactification, we use coercion for the canonical embedding `X → OnePoint X`; when `X` is already compact, the compactification adds an isolated point to the space. * `OnePoint.infty`: the extra point ## Main results * The topological structure of `OnePoint X` * The connectedness of `OnePoint X` for a noncompact, preconnected `X` * `OnePoint X` is `T₀` for a T₀ space `X` * `OnePoint X` is `T₁` for a T₁ space `X` * `OnePoint X` is normal if `X` is a locally compact Hausdorff space ## Tags one-point compactification, Alexandroff compactification, compactness -/ open Set Filter Topology /-! ### Definition and basic properties In this section we define `OnePoint X` to be the disjoint union of `X` and `∞`, implemented as `Option X`. Then we restate some lemmas about `Option X` for `OnePoint X`. -/ variable {X : Type*} /-- The OnePoint extension of an arbitrary topological space `X` -/ def OnePoint (X : Type*) := Option X /-- The repr uses the notation from the `OnePoint` locale. -/ instance [Repr X] : Repr (OnePoint X) := ⟨fun o _ => match o with | none => "∞" | some a => "↑" ++ repr a⟩ namespace OnePoint /-- The point at infinity -/ @[match_pattern] def infty : OnePoint X := none @[inherit_doc] scoped notation "∞" => OnePoint.infty /-- Coercion from `X` to `OnePoint X`. -/ @[coe, match_pattern] def some : X → OnePoint X := Option.some instance : CoeTC X (OnePoint X) := ⟨some⟩ instance : Inhabited (OnePoint X) := ⟨∞⟩ protected lemma «forall» {p : OnePoint X → Prop} : (∀ (x : OnePoint X), p x) ↔ p ∞ ∧ ∀ (x : X), p x := Option.forall protected lemma «exists» {p : OnePoint X → Prop} : (∃ x, p x) ↔ p ∞ ∨ ∃ (x : X), p x := Option.exists instance [Fintype X] : Fintype (OnePoint X) := inferInstanceAs (Fintype (Option X)) instance infinite [Infinite X] : Infinite (OnePoint X) := inferInstanceAs (Infinite (Option X)) theorem coe_injective : Function.Injective ((↑) : X → OnePoint X) := Option.some_injective X @[norm_cast] theorem coe_eq_coe {x y : X} : (x : OnePoint X) = y ↔ x = y := coe_injective.eq_iff @[simp] theorem coe_ne_infty (x : X) : (x : OnePoint X) ≠ ∞ := nofun @[simp] theorem infty_ne_coe (x : X) : ∞ ≠ (x : OnePoint X) := nofun /-- Recursor for `OnePoint` using the preferred forms `∞` and `↑x`. -/ @[elab_as_elim] protected def rec {C : OnePoint X → Sort*} (h₁ : C ∞) (h₂ : ∀ x : X, C x) : ∀ z : OnePoint X, C z | ∞ => h₁ | (x : X) => h₂ x theorem isCompl_range_coe_infty : IsCompl (range ((↑) : X → OnePoint X)) {∞} := isCompl_range_some_none X -- Porting note: moved @[simp] to a new lemma theorem range_coe_union_infty : range ((↑) : X → OnePoint X) ∪ {∞} = univ := range_some_union_none X @[simp] theorem insert_infty_range_coe : insert ∞ (range (@some X)) = univ := insert_none_range_some _ @[simp] theorem range_coe_inter_infty : range ((↑) : X → OnePoint X) ∩ {∞} = ∅ := range_some_inter_none X @[simp] theorem compl_range_coe : (range ((↑) : X → OnePoint X))ᶜ = {∞} := compl_range_some X theorem compl_infty : ({∞}ᶜ : Set (OnePoint X)) = range ((↑) : X → OnePoint X) := (@isCompl_range_coe_infty X).symm.compl_eq theorem compl_image_coe (s : Set X) : ((↑) '' s : Set (OnePoint X))ᶜ = (↑) '' sᶜ ∪ {∞} := by rw [coe_injective.compl_image_eq, compl_range_coe] theorem ne_infty_iff_exists {x : OnePoint X} : x ≠ ∞ ↔ ∃ y : X, (y : OnePoint X) = x := by induction x using OnePoint.rec <;> simp instance canLift : CanLift (OnePoint X) X (↑) fun x => x ≠ ∞ := WithTop.canLift theorem not_mem_range_coe_iff {x : OnePoint X} : x ∉ range some ↔ x = ∞ := by rw [← mem_compl_iff, compl_range_coe, mem_singleton_iff] theorem infty_not_mem_range_coe : ∞ ∉ range ((↑) : X → OnePoint X) := not_mem_range_coe_iff.2 rfl theorem infty_not_mem_image_coe {s : Set X} : ∞ ∉ ((↑) : X → OnePoint X) '' s := not_mem_subset (image_subset_range _ _) infty_not_mem_range_coe @[simp] theorem coe_preimage_infty : ((↑) : X → OnePoint X) ⁻¹' {∞} = ∅ := by ext simp /-! ### Topological space structure on `OnePoint X` We define a topological space structure on `OnePoint X` so that `s` is open if and only if * `(↑) ⁻¹' s` is open in `X`; * if `∞ ∈ s`, then `((↑) ⁻¹' s)ᶜ` is compact. Then we reformulate this definition in a few different ways, and prove that `(↑) : X → OnePoint X` is an open embedding. If `X` is not a compact space, then we also prove that `(↑)` has dense range, so it is a dense embedding. -/ variable [TopologicalSpace X] instance : TopologicalSpace (OnePoint X) where IsOpen s := (∞ ∈ s → IsCompact (((↑) : X → OnePoint X) ⁻¹' s)ᶜ) ∧ IsOpen (((↑) : X → OnePoint X) ⁻¹' s) isOpen_univ := by simp isOpen_inter s t := by rintro ⟨hms, hs⟩ ⟨hmt, ht⟩ refine ⟨?_, hs.inter ht⟩ rintro ⟨hms', hmt'⟩ simpa [compl_inter] using (hms hms').union (hmt hmt') isOpen_sUnion S ho := by suffices IsOpen ((↑) ⁻¹' ⋃₀ S : Set X) by refine ⟨?_, this⟩ rintro ⟨s, hsS : s ∈ S, hs : ∞ ∈ s⟩ refine IsCompact.of_isClosed_subset ((ho s hsS).1 hs) this.isClosed_compl ?_ exact compl_subset_compl.mpr (preimage_mono <| subset_sUnion_of_mem hsS) rw [preimage_sUnion] exact isOpen_biUnion fun s hs => (ho s hs).2 variable {s : Set (OnePoint X)} {t : Set X} theorem isOpen_def : IsOpen s ↔ (∞ ∈ s → IsCompact ((↑) ⁻¹' s : Set X)ᶜ) ∧ IsOpen ((↑) ⁻¹' s : Set X) := Iff.rfl theorem isOpen_iff_of_mem' (h : ∞ ∈ s) : IsOpen s ↔ IsCompact ((↑) ⁻¹' s : Set X)ᶜ ∧ IsOpen ((↑) ⁻¹' s : Set X) := by simp [isOpen_def, h] theorem isOpen_iff_of_mem (h : ∞ ∈ s) : IsOpen s ↔ IsClosed ((↑) ⁻¹' s : Set X)ᶜ ∧ IsCompact ((↑) ⁻¹' s : Set X)ᶜ := by simp only [isOpen_iff_of_mem' h, isClosed_compl_iff, and_comm] theorem isOpen_iff_of_not_mem (h : ∞ ∉ s) : IsOpen s ↔ IsOpen ((↑) ⁻¹' s : Set X) := by simp [isOpen_def, h] theorem isClosed_iff_of_mem (h : ∞ ∈ s) : IsClosed s ↔ IsClosed ((↑) ⁻¹' s : Set X) := by have : ∞ ∉ sᶜ := fun H => H h rw [← isOpen_compl_iff, isOpen_iff_of_not_mem this, ← isOpen_compl_iff, preimage_compl] theorem isClosed_iff_of_not_mem (h : ∞ ∉ s) : IsClosed s ↔ IsClosed ((↑) ⁻¹' s : Set X) ∧ IsCompact ((↑) ⁻¹' s : Set X) := by rw [← isOpen_compl_iff, isOpen_iff_of_mem (mem_compl h), ← preimage_compl, compl_compl] @[simp] theorem isOpen_image_coe {s : Set X} : IsOpen ((↑) '' s : Set (OnePoint X)) ↔ IsOpen s := by rw [isOpen_iff_of_not_mem infty_not_mem_image_coe, preimage_image_eq _ coe_injective] theorem isOpen_compl_image_coe {s : Set X} : IsOpen ((↑) '' s : Set (OnePoint X))ᶜ ↔ IsClosed s ∧ IsCompact s := by rw [isOpen_iff_of_mem, ← preimage_compl, compl_compl, preimage_image_eq _ coe_injective] exact infty_not_mem_image_coe @[simp] theorem isClosed_image_coe {s : Set X} : IsClosed ((↑) '' s : Set (OnePoint X)) ↔ IsClosed s ∧ IsCompact s := by rw [← isOpen_compl_iff, isOpen_compl_image_coe] /-- An open set in `OnePoint X` constructed from a closed compact set in `X` -/ def opensOfCompl (s : Set X) (h₁ : IsClosed s) (h₂ : IsCompact s) : TopologicalSpace.Opens (OnePoint X) := ⟨((↑) '' s)ᶜ, isOpen_compl_image_coe.2 ⟨h₁, h₂⟩⟩ theorem infty_mem_opensOfCompl {s : Set X} (h₁ : IsClosed s) (h₂ : IsCompact s) : ∞ ∈ opensOfCompl s h₁ h₂ := mem_compl infty_not_mem_image_coe @[continuity] theorem continuous_coe : Continuous ((↑) : X → OnePoint X) := continuous_def.mpr fun _s hs => hs.right theorem isOpenMap_coe : IsOpenMap ((↑) : X → OnePoint X) := fun _ => isOpen_image_coe.2 theorem openEmbedding_coe : OpenEmbedding ((↑) : X → OnePoint X) := openEmbedding_of_continuous_injective_open continuous_coe coe_injective isOpenMap_coe theorem isOpen_range_coe : IsOpen (range ((↑) : X → OnePoint X)) := openEmbedding_coe.isOpen_range theorem isClosed_infty : IsClosed ({∞} : Set (OnePoint X)) := by rw [← compl_range_coe, isClosed_compl_iff] exact isOpen_range_coe theorem nhds_coe_eq (x : X) : 𝓝 ↑x = map ((↑) : X → OnePoint X) (𝓝 x) := (openEmbedding_coe.map_nhds_eq x).symm theorem nhdsWithin_coe_image (s : Set X) (x : X) : 𝓝[(↑) '' s] (x : OnePoint X) = map (↑) (𝓝[s] x) := (openEmbedding_coe.toEmbedding.map_nhdsWithin_eq _ _).symm theorem nhdsWithin_coe (s : Set (OnePoint X)) (x : X) : 𝓝[s] ↑x = map (↑) (𝓝[(↑) ⁻¹' s] x) := (openEmbedding_coe.map_nhdsWithin_preimage_eq _ _).symm theorem comap_coe_nhds (x : X) : comap ((↑) : X → OnePoint X) (𝓝 x) = 𝓝 x := (openEmbedding_coe.toInducing.nhds_eq_comap x).symm /-- If `x` is not an isolated point of `X`, then `x : OnePoint X` is not an isolated point of `OnePoint X`. -/ instance nhdsWithin_compl_coe_neBot (x : X) [h : NeBot (𝓝[≠] x)] : NeBot (𝓝[≠] (x : OnePoint X)) := by simpa [nhdsWithin_coe, preimage, coe_eq_coe] using h.map some theorem nhdsWithin_compl_infty_eq : 𝓝[≠] (∞ : OnePoint X) = map (↑) (coclosedCompact X) := by refine (nhdsWithin_basis_open ∞ _).ext (hasBasis_coclosedCompact.map _) ?_ ?_ · rintro s ⟨hs, hso⟩ refine ⟨_, (isOpen_iff_of_mem hs).mp hso, ?_⟩ simp [Subset.rfl] · rintro s ⟨h₁, h₂⟩ refine ⟨_, ⟨mem_compl infty_not_mem_image_coe, isOpen_compl_image_coe.2 ⟨h₁, h₂⟩⟩, ?_⟩ simp [compl_image_coe, ← diff_eq, subset_preimage_image] /-- If `X` is a non-compact space, then `∞` is not an isolated point of `OnePoint X`. -/ instance nhdsWithin_compl_infty_neBot [NoncompactSpace X] : NeBot (𝓝[≠] (∞ : OnePoint X)) := by rw [nhdsWithin_compl_infty_eq] infer_instance instance (priority := 900) nhdsWithin_compl_neBot [∀ x : X, NeBot (𝓝[≠] x)] [NoncompactSpace X] (x : OnePoint X) : NeBot (𝓝[≠] x) := OnePoint.rec OnePoint.nhdsWithin_compl_infty_neBot (fun y => OnePoint.nhdsWithin_compl_coe_neBot y) x theorem nhds_infty_eq : 𝓝 (∞ : OnePoint X) = map (↑) (coclosedCompact X) ⊔ pure ∞ := by rw [← nhdsWithin_compl_infty_eq, nhdsWithin_compl_singleton_sup_pure] theorem tendsto_coe_infty : Tendsto (↑) (coclosedCompact X) (𝓝 (∞ : OnePoint X)) := by rw [nhds_infty_eq] exact Filter.Tendsto.mono_right tendsto_map le_sup_left theorem hasBasis_nhds_infty : (𝓝 (∞ : OnePoint X)).HasBasis (fun s : Set X => IsClosed s ∧ IsCompact s) fun s => (↑) '' sᶜ ∪ {∞} := by rw [nhds_infty_eq] exact (hasBasis_coclosedCompact.map _).sup_pure _ @[simp] theorem comap_coe_nhds_infty : comap ((↑) : X → OnePoint X) (𝓝 ∞) = coclosedCompact X := by simp [nhds_infty_eq, comap_sup, comap_map coe_injective] theorem le_nhds_infty {f : Filter (OnePoint X)} : f ≤ 𝓝 ∞ ↔ ∀ s : Set X, IsClosed s → IsCompact s → (↑) '' sᶜ ∪ {∞} ∈ f := by simp only [hasBasis_nhds_infty.ge_iff, and_imp] theorem ultrafilter_le_nhds_infty {f : Ultrafilter (OnePoint X)} : (f : Filter (OnePoint X)) ≤ 𝓝 ∞ ↔ ∀ s : Set X, IsClosed s → IsCompact s → (↑) '' s ∉ f := by simp only [le_nhds_infty, ← compl_image_coe, Ultrafilter.mem_coe, Ultrafilter.compl_mem_iff_not_mem] theorem tendsto_nhds_infty' {α : Type*} {f : OnePoint X → α} {l : Filter α} : Tendsto f (𝓝 ∞) l ↔ Tendsto f (pure ∞) l ∧ Tendsto (f ∘ (↑)) (coclosedCompact X) l := by simp [nhds_infty_eq, and_comm] theorem tendsto_nhds_infty {α : Type*} {f : OnePoint X → α} {l : Filter α} : Tendsto f (𝓝 ∞) l ↔ ∀ s ∈ l, f ∞ ∈ s ∧ ∃ t : Set X, IsClosed t ∧ IsCompact t ∧ MapsTo (f ∘ (↑)) tᶜ s := tendsto_nhds_infty'.trans <| by simp only [tendsto_pure_left, hasBasis_coclosedCompact.tendsto_left_iff, forall_and, and_assoc, exists_prop] theorem continuousAt_infty' {Y : Type*} [TopologicalSpace Y] {f : OnePoint X → Y} : ContinuousAt f ∞ ↔ Tendsto (f ∘ (↑)) (coclosedCompact X) (𝓝 (f ∞)) := tendsto_nhds_infty'.trans <| and_iff_right (tendsto_pure_nhds _ _) theorem continuousAt_infty {Y : Type*} [TopologicalSpace Y] {f : OnePoint X → Y} : ContinuousAt f ∞ ↔ ∀ s ∈ 𝓝 (f ∞), ∃ t : Set X, IsClosed t ∧ IsCompact t ∧ MapsTo (f ∘ (↑)) tᶜ s := continuousAt_infty'.trans <| by simp only [hasBasis_coclosedCompact.tendsto_left_iff, and_assoc] theorem continuousAt_coe {Y : Type*} [TopologicalSpace Y] {f : OnePoint X → Y} {x : X} : ContinuousAt f x ↔ ContinuousAt (f ∘ (↑)) x := by rw [ContinuousAt, nhds_coe_eq, tendsto_map'_iff, ContinuousAt]; rfl lemma continuous_iff {Y : Type*} [TopologicalSpace Y] (f : OnePoint X → Y) : Continuous f ↔ Tendsto (fun x : X ↦ f x) (coclosedCompact X) (𝓝 (f ∞)) ∧ Continuous (fun x : X ↦ f x) := by simp only [continuous_iff_continuousAt, OnePoint.forall, continuousAt_coe, continuousAt_infty', Function.comp_def] /-- A constructor for continuous maps out of a one point compactification, given a continuous map from the underlying space and a limit value at infinity. -/ def continuousMapMk {Y : Type*} [TopologicalSpace Y] (f : C(X, Y)) (y : Y) (h : Tendsto f (coclosedCompact X) (𝓝 y)) : C(OnePoint X, Y) where toFun | ∞ => y | some x => f x continuous_toFun := by rw [continuous_iff] refine ⟨h, f.continuous⟩ lemma continuous_iff_from_discrete {Y : Type*} [TopologicalSpace Y] [DiscreteTopology X] (f : OnePoint X → Y) : Continuous f ↔ Tendsto (fun x : X ↦ f x) cofinite (𝓝 (f ∞)) := by simp [continuous_iff, cocompact_eq_cofinite, continuous_of_discreteTopology] /-- A constructor for continuous maps out of a one point compactification of a discrete space, given a map from the underlying space and a limit value at infinity. -/ def continuousMapMkDiscrete {Y : Type*} [TopologicalSpace Y] [DiscreteTopology X] (f : X → Y) (y : Y) (h : Tendsto f cofinite (𝓝 y)) : C(OnePoint X, Y) := continuousMapMk ⟨f, continuous_of_discreteTopology⟩ y (by simpa [cocompact_eq_cofinite]) variable (X) in /-- Continuous maps out of the one point compactification of an infinite discrete space to a Hausdorff space correspond bijectively to "convergent" maps out of the discrete space. -/ noncomputable def continuousMapDiscreteEquiv (Y : Type*) [DiscreteTopology X] [TopologicalSpace Y] [T2Space Y] [Infinite X] : C(OnePoint X, Y) ≃ { f : X → Y // ∃ L, Tendsto (fun x : X ↦ f x) cofinite (𝓝 L) } where toFun f := ⟨(f ·), ⟨f ∞, continuous_iff_from_discrete _ |>.mp (map_continuous f)⟩⟩ invFun f := { toFun := fun x => match x with | ∞ => Classical.choose f.2 | some x => f.1 x continuous_toFun := continuous_iff_from_discrete _ |>.mpr <| Classical.choose_spec f.2 } left_inv f := by ext x refine OnePoint.rec ?_ ?_ x · refine tendsto_nhds_unique ?_ (continuous_iff_from_discrete _ |>.mp <| map_continuous f) let f' : { f : X → Y // ∃ L, Tendsto (fun x : X ↦ f x) cofinite (𝓝 L) } := ⟨fun x ↦ f x, ⟨f ∞, continuous_iff_from_discrete f |>.mp <| map_continuous f⟩⟩ exact Classical.choose_spec f'.property · simp right_inv f := rfl lemma continuous_iff_from_nat {Y : Type*} [TopologicalSpace Y] (f : OnePoint ℕ → Y) : Continuous f ↔ Tendsto (fun x : ℕ ↦ f x) atTop (𝓝 (f ∞)) := by rw [continuous_iff_from_discrete, Nat.cofinite_eq_atTop] /-- A constructor for continuous maps out of the one point compactification of `ℕ`, given a sequence and a limit value at infinity. -/ def continuousMapMkNat {Y : Type*} [TopologicalSpace Y] (f : ℕ → Y) (y : Y) (h : Tendsto f atTop (𝓝 y)) : C(OnePoint ℕ, Y) := continuousMapMkDiscrete f y (by rwa [Nat.cofinite_eq_atTop]) /-- Continuous maps out of the one point compactification of `ℕ` to a Hausdorff space `Y` correspond bijectively to convergent sequences in `Y`. -/ noncomputable def continuousMapNatEquiv (Y : Type*) [TopologicalSpace Y] [T2Space Y] : C(OnePoint ℕ, Y) ≃ { f : ℕ → Y // ∃ L, Tendsto (f ·) atTop (𝓝 L) } := by refine (continuousMapDiscreteEquiv ℕ Y).trans { toFun := fun ⟨f, hf⟩ ↦ ⟨f, by rwa [← Nat.cofinite_eq_atTop]⟩ invFun := fun ⟨f, hf⟩ ↦ ⟨f, by rwa [Nat.cofinite_eq_atTop]⟩ left_inv := fun _ ↦ rfl right_inv := fun _ ↦ rfl } /-- If `X` is not a compact space, then the natural embedding `X → OnePoint X` has dense range. -/ theorem denseRange_coe [NoncompactSpace X] : DenseRange ((↑) : X → OnePoint X) := by rw [DenseRange, ← compl_infty] exact dense_compl_singleton _ theorem denseEmbedding_coe [NoncompactSpace X] : DenseEmbedding ((↑) : X → OnePoint X) := { openEmbedding_coe with dense := denseRange_coe } @[simp, norm_cast] theorem specializes_coe {x y : X} : (x : OnePoint X) ⤳ y ↔ x ⤳ y := openEmbedding_coe.toInducing.specializes_iff @[simp, norm_cast] theorem inseparable_coe {x y : X} : Inseparable (x : OnePoint X) y ↔ Inseparable x y := openEmbedding_coe.toInducing.inseparable_iff theorem not_specializes_infty_coe {x : X} : ¬Specializes ∞ (x : OnePoint X) := isClosed_infty.not_specializes rfl (coe_ne_infty x) theorem not_inseparable_infty_coe {x : X} : ¬Inseparable ∞ (x : OnePoint X) := fun h => not_specializes_infty_coe h.specializes theorem not_inseparable_coe_infty {x : X} : ¬Inseparable (x : OnePoint X) ∞ := fun h => not_specializes_infty_coe h.specializes' theorem inseparable_iff {x y : OnePoint X} : Inseparable x y ↔ x = ∞ ∧ y = ∞ ∨ ∃ x' : X, x = x' ∧ ∃ y' : X, y = y' ∧ Inseparable x' y' := by induction x using OnePoint.rec <;> induction y using OnePoint.rec <;> simp [not_inseparable_infty_coe, not_inseparable_coe_infty, coe_eq_coe, Inseparable.refl] /-! ### Compactness and separation properties In this section we prove that `OnePoint X` is a compact space; it is a T₀ (resp., T₁) space if the original space satisfies the same separation axiom. If the original space is a locally compact Hausdorff space, then `OnePoint X` is a normal (hence, T₃ and Hausdorff) space. Finally, if the original space `X` is *not* compact and is a preconnected space, then `OnePoint X` is a connected space. -/ /-- For any topological space `X`, its one point compactification is a compact space. -/ instance : CompactSpace (OnePoint X) where isCompact_univ := by have : Tendsto ((↑) : X → OnePoint X) (cocompact X) (𝓝 ∞) := by rw [nhds_infty_eq] exact (tendsto_map.mono_left cocompact_le_coclosedCompact).mono_right le_sup_left rw [← insert_none_range_some X] exact this.isCompact_insert_range_of_cocompact continuous_coe /-- The one point compactification of a `T0Space` space is a `T0Space`. -/ instance [T0Space X] : T0Space (OnePoint X) := by refine ⟨fun x y hxy => ?_⟩ rcases inseparable_iff.1 hxy with (⟨rfl, rfl⟩ | ⟨x, rfl, y, rfl, h⟩) exacts [rfl, congr_arg some h.eq] /-- The one point compactification of a `T1Space` space is a `T1Space`. -/ instance [T1Space X] : T1Space (OnePoint X) where t1 z := by induction z using OnePoint.rec · exact isClosed_infty · rw [← image_singleton, isClosed_image_coe] exact ⟨isClosed_singleton, isCompact_singleton⟩ /-- The one point compactification of a locally compact R₁ space is a normal topological space. -/ instance [LocallyCompactSpace X] [R1Space X] : NormalSpace (OnePoint X) := by suffices R1Space (OnePoint X) by infer_instance have key : ∀ z : X, Disjoint (𝓝 (some z)) (𝓝 ∞) := fun z ↦ by rw [nhds_infty_eq, disjoint_sup_right, nhds_coe_eq, coclosedCompact_eq_cocompact, disjoint_map coe_injective, ← principal_singleton, disjoint_principal_right, compl_infty] exact ⟨disjoint_nhds_cocompact z, range_mem_map⟩ refine ⟨fun x y ↦ ?_⟩ induction x using OnePoint.rec <;> induction y using OnePoint.rec · exact .inl le_rfl · exact .inr (key _).symm · exact .inr (key _) · rw [nhds_coe_eq, nhds_coe_eq, disjoint_map coe_injective, specializes_coe] apply specializes_or_disjoint_nhds /-- The one point compactification of a weakly locally compact Hausdorff space is a T₄ (hence, Hausdorff and regular) topological space. -/ example [WeaklyLocallyCompactSpace X] [T2Space X] : T4Space (OnePoint X) := inferInstance /-- If `X` is not a compact space, then `OnePoint X` is a connected space. -/ instance [PreconnectedSpace X] [NoncompactSpace X] : ConnectedSpace (OnePoint X) where toPreconnectedSpace := denseEmbedding_coe.toDenseInducing.preconnectedSpace toNonempty := inferInstance /-- If `X` is an infinite type with discrete topology (e.g., `ℕ`), then the identity map from `CofiniteTopology (OnePoint X)` to `OnePoint X` is not continuous. -/ theorem not_continuous_cofiniteTopology_of_symm [Infinite X] [DiscreteTopology X] : ¬Continuous (@CofiniteTopology.of (OnePoint X)).symm := by inhabit X simp only [continuous_iff_continuousAt, ContinuousAt, not_forall] use CofiniteTopology.of ↑(default : X) simpa [nhds_coe_eq, nhds_discrete, CofiniteTopology.nhds_eq] using (finite_singleton ((default : X) : OnePoint X)).infinite_compl instance (X : Type*) [TopologicalSpace X] [DiscreteTopology X] : TotallySeparatedSpace (OnePoint X) where isTotallySeparated_univ x _ y _ hxy := by cases x with | none => refine ⟨{y}ᶜ, {y}, isOpen_compl_singleton, ?_, hxy, rfl, (compl_union_self _).symm.subset, disjoint_compl_left⟩ rw [OnePoint.isOpen_iff_of_not_mem] exacts [isOpen_discrete _, hxy] | some val => refine ⟨{some val}, {some val}ᶜ, ?_, isOpen_compl_singleton, rfl, hxy.symm, by simp, disjoint_compl_right⟩ rw [OnePoint.isOpen_iff_of_not_mem] exacts [isOpen_discrete _, (Option.some_ne_none val).symm] end OnePoint /-- A concrete counterexample shows that `Continuous.homeoOfEquivCompactToT2` cannot be generalized from `T2Space` to `T1Space`. Let `α = OnePoint ℕ` be the one-point compactification of `ℕ`, and let `β` be the same space `OnePoint ℕ` with the cofinite topology. Then `α` is compact, `β` is T1, and the identity map `id : α → β` is a continuous equivalence that is not a homeomorphism. -/ theorem Continuous.homeoOfEquivCompactToT2.t1_counterexample : ∃ (α β : Type) (_ : TopologicalSpace α) (_ : TopologicalSpace β), CompactSpace α ∧ T1Space β ∧ ∃ f : α ≃ β, Continuous f ∧ ¬Continuous f.symm := ⟨OnePoint ℕ, CofiniteTopology (OnePoint ℕ), inferInstance, inferInstance, inferInstance, inferInstance, CofiniteTopology.of, CofiniteTopology.continuous_of, OnePoint.not_continuous_cofiniteTopology_of_symm⟩
Topology\Compactness\Compact.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Order.Filter.Basic import Mathlib.Topology.Bases import Mathlib.Data.Set.Accumulate import Mathlib.Topology.Bornology.Basic import Mathlib.Topology.LocallyFinite /-! # Compact sets and compact spaces ## Main definitions We define the following properties for sets in a topological space: * `IsCompact`: a set such that each open cover has a finite subcover. This is defined in mathlib using filters. The main property of a compact set is `IsCompact.elim_finite_subcover`. * `CompactSpace`: typeclass stating that the whole space is a compact set. * `NoncompactSpace`: a space that is not a compact space. ## Main results * `isCompact_univ_pi`: **Tychonov's theorem** - an arbitrary product of compact sets is compact. -/ 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} -- 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 /-- 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 [not_mem_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 /-- 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 -- Porting note (#11215): 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} [hι : 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_not_mem, mem_iUnion, exists_prop, mem_inter_iff, not_and, iff_self_iff, 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_not_mem, mem_iUnion, exists_prop, mem_inter_iff, not_and, iff_self_iff, mem_iInter, mem_compl_iff] using ht⟩ -- Porting note (#11215): 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 t ↦ isClosed_biInter fun _ _ ↦ htc _) (by rwa [← iInter_eq_iInter_finset]) (directed_of_isDirected_le fun _ _ h ↦ biInter_subset_biInter_left h) /-- 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 LocallyFinite.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⟩ /-- 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) @[deprecated (since := "2024-02-28")] alias IsCompact.nonempty_iInter_of_directed_nonempty_compact_closed := IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed /-- 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 <| 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 @[deprecated (since := "2024-02-28")] alias IsCompact.nonempty_iInter_of_sequence_nonempty_compact_closed := IsCompact.nonempty_iInter_of_sequence_nonempty_isCompact_isClosed /-- 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.toSet, ?_, 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_not_mem (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] -- Porting note (#11215): 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 x 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 @[simp] theorem isCompact_empty : IsCompact (∅ : Set X) := fun _f hnf hsf => Not.elim hnf.ne <| empty_mem_iff_bot.1 <| le_principal_iff.1 hsf @[simp] theorem isCompact_singleton {x : X} : IsCompact ({x} : Set X) := fun f 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 -- Porting note: golfed a proof instead of fixing it 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 -- Porting note: generalized to `ι : Sort*` 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 theorem Set.Finite.isCompact (hs : s.Finite) : IsCompact s := biUnion_of_singleton s ▸ hs.isCompact_biUnion fun _ _ => isCompact_singleton 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 -- Porting note (#11215): 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_nhd_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 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 erw [← 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) ⟨_, Finset.mem_image_of_mem _ 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.toSet.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 _) 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 @[deprecated "see `cocompact_eq_atTop` with `import Mathlib.Topology.Instances.Nat`" (since := "2024-02-07")] theorem _root_.Nat.cocompact_eq : cocompact ℕ = atTop := (cocompact_eq_cofinite ℕ).trans Nat.cofinite_eq_atTop 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, 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⟩ @[deprecated mem_coclosedCompact_iff (since := "2024-02-16")] theorem mem_coclosedCompact : s ∈ coclosedCompact X ↔ ∃ t, IsClosed t ∧ IsCompact t ∧ tᶜ ⊆ s := by simp only [hasBasis_coclosedCompact.mem_iff, and_assoc] @[deprecated mem_coclosedCompact_iff (since := "2024-02-16")] theorem mem_coclosed_compact' : s ∈ coclosedCompact X ↔ ∃ t, IsClosed t ∧ IsCompact t ∧ sᶜ ⊆ t := by simp only [hasBasis_coclosedCompact.mem_iff, compl_subset_comm, and_assoc] /-- 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 {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) /-- 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) @[deprecated (since := "2024-01-28")] alias cluster_point_of_compact := exists_clusterPt_of_compactSpace 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 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 -- Porting note: a lemma instead of `export` to make `X` explicit 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 [acc_iff_cluster, 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⟩ /-- If `X` is a compact space, then a locally finite family of sets of `X` can have only finitely many nonempty elements. -/ theorem LocallyFinite.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 LocallyFinite.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 LocallyFinite.fintypeOfCompact [CompactSpace X] {f : ι → Set X} (hf : LocallyFinite f) (hne : ∀ i, (f i).Nonempty) : Fintype ι := fintypeOfFiniteUniv (hf.finite_of_compact hne) /-- 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 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.prod_mk continuous_id) -- Porting note: renamed, golfed /-- If `X` is a compact topological space, then `Prod.snd : X × Y → Y` is a closed map. -/ theorem isClosedMap_snd_of_compactSpace [CompactSpace X] : IsClosedMap (Prod.snd : X × Y → Y) := fun s hs => by rw [← isOpen_compl_iff, isOpen_iff_mem_nhds] intro y hy have : univ ×ˢ {y} ⊆ sᶜ := by exact fun (x, y') ⟨_, rfl⟩ hs => hy ⟨(x, y'), hs, rfl⟩ rcases generalized_tube_lemma isCompact_univ isCompact_singleton hs.isOpen_compl this with ⟨U, V, -, hVo, hU, hV, hs⟩ refine mem_nhds_iff.2 ⟨V, ?_, hVo, hV rfl⟩ rintro _ hzV ⟨z, hzs, rfl⟩ exact hs ⟨hU trivial, hzV⟩ hzs /-- If `Y` is a compact topological space, then `Prod.fst : X × Y → X` is a closed map. -/ theorem isClosedMap_fst_of_compactSpace [CompactSpace Y] : IsClosedMap (Prod.fst : X × Y → X) := isClosedMap_snd_of_compactSpace.comp isClosedMap_swap 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 Inducing.isCompact_iff {f : X → Y} (hf : Inducing 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 Embedding.isCompact_iff {f : X → Y} (hf : Embedding f) : IsCompact s ↔ IsCompact (f '' s) := hf.toInducing.isCompact_iff /-- The preimage of a compact set under an inducing map is a compact set. -/ theorem Inducing.isCompact_preimage {f : X → Y} (hf : Inducing 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 Inducing.isCompact_preimage_iff {f : X → Y} (hf : Inducing 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 Inducing.isCompact_preimage' {f : X → Y} (hf : Inducing 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 ClosedEmbedding.isCompact_preimage {f : X → Y} (hf : ClosedEmbedding f) {K : Set Y} (hK : IsCompact K) : IsCompact (f ⁻¹' K) := hf.toInducing.isCompact_preimage (hf.isClosed_range) hK /-- A closed embedding is proper, ie, inverse images of compact sets are contained in compacts. Moreover, the preimage of a compact set is compact, see `ClosedEmbedding.isCompact_preimage`. -/ theorem ClosedEmbedding.tendsto_cocompact {f : X → Y} (hf : ClosedEmbedding 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) := embedding_subtype_val.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 ClosedEmbedding.noncompactSpace [NoncompactSpace X] {f : X → Y} (hf : ClosedEmbedding f) : NoncompactSpace Y := noncompactSpace_of_neBot hf.tendsto_cocompact.neBot protected theorem ClosedEmbedding.compactSpace [h : CompactSpace Y] {f : X → Y} (hf : ClosedEmbedding f) : CompactSpace X := ⟨by rw [hf.toInducing.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) := ULift.closedEmbedding_down.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 /-- 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, ⟨Uc, Uo, Ucne⟩, 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, exists_prop, not_and, Set.mem_iInter, Subtype.forall, mem_setOf_eq, 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 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 V'ᶜ ⟨?_, isOpen_compl_iff.mpr V'cls, ?_⟩ (Set.subset_compl_comm.mp 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
Topology\Compactness\CompactlyGeneratedSpace.lean
/- Copyright (c) 2024 Etienne Marion. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Dagur Asgeirsson, Etienne Marion -/ import Mathlib.Topology.Category.CompHaus.Basic import Mathlib.Topology.Compactification.OnePoint /-! # 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 prov 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} [TopologicalSpace X] [TopologicalSpace Y] /-- 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 [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 /-- 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 /-- 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 /-- 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 [tX : TopologicalSpace X] [tY : TopologicalSpace Y] [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_uLift_down exact (h (CompHaus.of (ULift.{v} S)) ⟨g, hg⟩).preimage continuous_uLift_up · let g : ULift.{u} S → X ⊕ Y := Sum.inr ∘ f ∘ ULift.down have hg : Continuous g := continuous_inr.comp <| hf.comp continuous_uLift_down exact (h (CompHaus.of (ULift.{u} S)) ⟨g, hg⟩).preimage continuous_uLift_up /-- 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_uLift_up.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, (continuousMapMkNat u p hup).continuous.comp continuous_uLift_down⟩ 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 {Y : Type u} [tX : TopologicalSpace X] [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_uLift_down exact (h _ g hg).preimage continuous_uLift_up /-- 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 [T2Space X] (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 [T2Space X] (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 and compactly generated. -/ instance (priority := 100) [WeaklyLocallyCompactSpace X] [T2Space 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ℱ₃ end CompactlyGeneratedSpace
Topology\Compactness\Lindelof.lean
/- Copyright (c) 2023 Josha Dekker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Josha Dekker -/ 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 [not_mem_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ö 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_not_mem 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 f 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, 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₂⟩ /-- A compact space `X` is Lindelöf. -/ instance (priority := 100) [CompactSpace X] : LindelofSpace X := { isLindelof_univ := isCompact_univ.isLindelof} 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.prod_mk 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 Inducing.isLindelof_iff {f : X → Y} (hf : Inducing 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 Embedding.isLindelof_iff {f : X → Y} (hf : Embedding f) : IsLindelof s ↔ IsLindelof (f '' s) := hf.toInducing.isLindelof_iff /-- The preimage of a Lindelöf set under an inducing map is a Lindelöf set. -/ theorem Inducing.isLindelof_preimage {f : X → Y} (hf : Inducing 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 ClosedEmbedding.isLindelof_preimage {f : X → Y} (hf : ClosedEmbedding f) {K : Set Y} (hK : IsLindelof K) : IsLindelof (f ⁻¹' K) := hf.toInducing.isLindelof_preimage (hf.isClosed_range) hK /-- A closed embedding is proper, ie, inverse images of Lindelöf sets are contained in Lindelöf. Moreover, the preimage of a Lindelöf set is Lindelöf, see `ClosedEmbedding.isLindelof_preimage`. -/ theorem ClosedEmbedding.tendsto_coLindelof {f : X → Y} (hf : ClosedEmbedding 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) := embedding_subtype_val.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 ClosedEmbedding.nonLindelofSpace [NonLindelofSpace X] {f : X → Y} (hf : ClosedEmbedding f) : NonLindelofSpace Y := nonLindelofSpace_of_neBot hf.tendsto_coLindelof.neBot protected theorem ClosedEmbedding.LindelofSpace [h : LindelofSpace Y] {f : X → Y} (hf : ClosedEmbedding f) : LindelofSpace X := ⟨by rw [hf.toInducing.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
Topology\Compactness\LocallyCompact.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Topology.Compactness.Compact /-! # Locally compact spaces We define the following classes of topological spaces: * `WeaklyLocallyCompactSpace`: every point `x` has a compact neighborhood. * `LocallyCompactSpace`: for every point `x`, every open neighborhood of `x` contains a compact neighborhood of `x`. The definition is formulated in terms of the neighborhood filter. -/ 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 := fun 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⟩ /-- 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⟩⟩ @[deprecated (since := "2023-12-29")] alias locallyCompactSpace_of_hasBasis := LocallyCompactSpace.of_hasBasis 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⟩ protected theorem ClosedEmbedding.locallyCompactSpace [LocallyCompactSpace Y] {f : X → Y} (hf : ClosedEmbedding f) : LocallyCompactSpace X := haveI : ∀ x : X, (𝓝 x).HasBasis (fun s => s ∈ 𝓝 (f x) ∧ IsCompact s) (f ⁻¹' ·) := fun x ↦ by rw [hf.toInducing.nhds_eq_comap] exact (compact_basis_nhds _).comap _ .of_hasBasis this fun x s hs => hf.isCompact_preimage hs.2 protected theorem IsClosed.locallyCompactSpace [LocallyCompactSpace X] {s : Set X} (hs : IsClosed s) : LocallyCompactSpace s := (closedEmbedding_subtype_val hs).locallyCompactSpace protected theorem OpenEmbedding.locallyCompactSpace [LocallyCompactSpace Y] {f : X → Y} (hf : OpenEmbedding f) : LocallyCompactSpace X := by have : ∀ x : X, (𝓝 x).HasBasis (fun s ↦ (s ∈ 𝓝 (f x) ∧ IsCompact s) ∧ s ⊆ range f) (f ⁻¹' ·) := fun x ↦ by rw [hf.nhds_eq_comap] exact ((compact_basis_nhds _).restrict_subset <| hf.isOpen_range.mem_nhds <| mem_range_self _).comap _ refine .of_hasBasis this fun x s hs => ?_ rw [hf.toInducing.isCompact_iff, image_preimage_eq_of_subset hs.2] exact hs.1.2 protected theorem IsOpen.locallyCompactSpace [LocallyCompactSpace X] {s : Set X} (hs : IsOpen s) : LocallyCompactSpace s := hs.openEmbedding_subtype_val.locallyCompactSpace
Topology\Compactness\Paracompact.lean
/- Copyright (c) 2021 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Reid Barton, Yury Kudryashov -/ import Mathlib.Topology.Homeomorph import Mathlib.Data.Option.Basic /-! # 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 -- Porting note (#10888): added proof of uc 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 ClosedEmbedding.paracompactSpace [ParacompactSpace Y] {e : X → Y} (he : ClosedEmbedding 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.closedEmbedding.paracompactSpace, fun _ ↦ e.closedEmbedding.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' -- Porting note: Commented out `haveI` for now. --haveI : ∀ (n) (x : ↑(Kdiff n ∩ s)), Nonempty (ι x) := fun n x ↦ (hB x x.2.2).nonempty 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, mem_image, 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⟩
Topology\Compactness\PseudometrizableLindelof.lean
/- Copyright (c) 2023 Josha Dekker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Josha Dekker -/ import Mathlib.Topology.Metrizable.Basic import Mathlib.Topology.Compactness.Lindelof /-! # Second-countability of pseudometrizable Lindelöf spaces Factored out from `Mathlib.Topology.Compactness.Lindelof` 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
Topology\Compactness\SigmaCompact.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Topology.Compactness.LocallyCompact /-! # 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 `Inducing`, the image `f '' s` of a set `s` is σ-compact if and only `s` is σ-compact. -/ lemma Inducing.isSigmaCompact_iff {f : X → Y} {s : Set X} (hf : Inducing 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 Embedding.isSigmaCompact_iff {f : X → Y} {s : Set X} (hf : Embedding f) : IsSigmaCompact s ↔ IsSigmaCompact (f '' s) := hf.toInducing.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) := embedding_subtype_val.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.sigma_compact [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_locally_compact_second_countable [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 -- Porting note: doesn't work on the same line 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 theorem ClosedEmbedding.sigmaCompactSpace {e : Y → X} (he : ClosedEmbedding e) : SigmaCompactSpace Y := ⟨⟨fun n => e ⁻¹' compactCovering X n, fun n => he.isCompact_preimage (isCompact_compactCovering _ _), by rw [← preimage_iUnion, iUnion_compactCovering, preimage_univ]⟩⟩ theorem IsClosed.sigmaCompactSpace {s : Set X} (hs : IsClosed s) : SigmaCompactSpace s := (closedEmbedding_subtype_val hs).sigmaCompactSpace instance [SigmaCompactSpace Y] : SigmaCompactSpace (ULift.{u} Y) := ULift.closedEmbedding_down.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_sigma_compact {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_sigma_compact {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_sigma_compact 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 /-- 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 _ _ (not_mem_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] [LocallyCompactSpace X] : Inhabited (CompactExhaustion X) := ⟨CompactExhaustion.choice X⟩ end CompactExhaustion
Topology\Connected\Basic.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Basic import Mathlib.Order.SuccPred.Relation import Mathlib.Topology.Irreducible /-! # Connected subsets of topological spaces In this file we define connected subsets of a topological spaces and various other properties and classes related to connectivity. ## Main definitions We define the following properties for sets in a topological space: * `IsConnected`: a nonempty set that has no non-trivial open partition. See also the section below in the module doc. * `connectedComponent` is the connected component of an element in the space. We also have a class stating that the whole space satisfies that property: `ConnectedSpace` ## On the definition of connected sets/spaces In informal mathematics, connected spaces are assumed to be nonempty. We formalise the predicate without that assumption as `IsPreconnected`. In other words, the only difference is whether the empty space counts as connected. There are good reasons to consider the empty space to be “too simple to be simple” See also https://ncatlab.org/nlab/show/too+simple+to+be+simple, and in particular https://ncatlab.org/nlab/show/too+simple+to+be+simple#relationship_to_biased_definitions. -/ open Set Function Topology TopologicalSpace Relation universe u v variable {α : Type u} {β : Type v} {ι : Type*} {π : ι → Type*} [TopologicalSpace α] {s t u v : Set α} section Preconnected /-- A preconnected set is one where there is no non-trivial open partition. -/ def IsPreconnected (s : Set α) : Prop := ∀ u v : Set α, IsOpen u → IsOpen v → s ⊆ u ∪ v → (s ∩ u).Nonempty → (s ∩ v).Nonempty → (s ∩ (u ∩ v)).Nonempty /-- A connected set is one that is nonempty and where there is no non-trivial open partition. -/ def IsConnected (s : Set α) : Prop := s.Nonempty ∧ IsPreconnected s theorem IsConnected.nonempty {s : Set α} (h : IsConnected s) : s.Nonempty := h.1 theorem IsConnected.isPreconnected {s : Set α} (h : IsConnected s) : IsPreconnected s := h.2 theorem IsPreirreducible.isPreconnected {s : Set α} (H : IsPreirreducible s) : IsPreconnected s := fun _ _ hu hv _ => H _ _ hu hv theorem IsIrreducible.isConnected {s : Set α} (H : IsIrreducible s) : IsConnected s := ⟨H.nonempty, H.isPreirreducible.isPreconnected⟩ theorem isPreconnected_empty : IsPreconnected (∅ : Set α) := isPreirreducible_empty.isPreconnected theorem isConnected_singleton {x} : IsConnected ({x} : Set α) := isIrreducible_singleton.isConnected theorem isPreconnected_singleton {x} : IsPreconnected ({x} : Set α) := isConnected_singleton.isPreconnected theorem Set.Subsingleton.isPreconnected {s : Set α} (hs : s.Subsingleton) : IsPreconnected s := hs.induction_on isPreconnected_empty fun _ => isPreconnected_singleton /-- If any point of a set is joined to a fixed point by a preconnected subset, then the original set is preconnected as well. -/ theorem isPreconnected_of_forall {s : Set α} (x : α) (H : ∀ y ∈ s, ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t) : IsPreconnected s := by rintro u v hu hv hs ⟨z, zs, zu⟩ ⟨y, ys, yv⟩ have xs : x ∈ s := by rcases H y ys with ⟨t, ts, xt, -, -⟩ exact ts xt -- Porting note (#11215): TODO: use `wlog xu : x ∈ u := hs xs using u v y z, v u z y` cases hs xs with | inl xu => rcases H y ys with ⟨t, ts, xt, yt, ht⟩ have := ht u v hu hv (ts.trans hs) ⟨x, xt, xu⟩ ⟨y, yt, yv⟩ exact this.imp fun z hz => ⟨ts hz.1, hz.2⟩ | inr xv => rcases H z zs with ⟨t, ts, xt, zt, ht⟩ have := ht v u hv hu (ts.trans <| by rwa [union_comm]) ⟨x, xt, xv⟩ ⟨z, zt, zu⟩ exact this.imp fun _ h => ⟨ts h.1, h.2.2, h.2.1⟩ /-- If any two points of a set are contained in a preconnected subset, then the original set is preconnected as well. -/ theorem isPreconnected_of_forall_pair {s : Set α} (H : ∀ x ∈ s, ∀ y ∈ s, ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t) : IsPreconnected s := by rcases eq_empty_or_nonempty s with (rfl | ⟨x, hx⟩) exacts [isPreconnected_empty, isPreconnected_of_forall x fun y => H x hx y] /-- A union of a family of preconnected sets with a common point is preconnected as well. -/ theorem isPreconnected_sUnion (x : α) (c : Set (Set α)) (H1 : ∀ s ∈ c, x ∈ s) (H2 : ∀ s ∈ c, IsPreconnected s) : IsPreconnected (⋃₀ c) := by apply isPreconnected_of_forall x rintro y ⟨s, sc, ys⟩ exact ⟨s, subset_sUnion_of_mem sc, H1 s sc, ys, H2 s sc⟩ theorem isPreconnected_iUnion {ι : Sort*} {s : ι → Set α} (h₁ : (⋂ i, s i).Nonempty) (h₂ : ∀ i, IsPreconnected (s i)) : IsPreconnected (⋃ i, s i) := Exists.elim h₁ fun f hf => isPreconnected_sUnion f _ hf (forall_mem_range.2 h₂) theorem IsPreconnected.union (x : α) {s t : Set α} (H1 : x ∈ s) (H2 : x ∈ t) (H3 : IsPreconnected s) (H4 : IsPreconnected t) : IsPreconnected (s ∪ t) := sUnion_pair s t ▸ isPreconnected_sUnion x {s, t} (by rintro r (rfl | rfl | h) <;> assumption) (by rintro r (rfl | rfl | h) <;> assumption) theorem IsPreconnected.union' {s t : Set α} (H : (s ∩ t).Nonempty) (hs : IsPreconnected s) (ht : IsPreconnected t) : IsPreconnected (s ∪ t) := by rcases H with ⟨x, hxs, hxt⟩ exact hs.union x hxs hxt ht theorem IsConnected.union {s t : Set α} (H : (s ∩ t).Nonempty) (Hs : IsConnected s) (Ht : IsConnected t) : IsConnected (s ∪ t) := by rcases H with ⟨x, hx⟩ refine ⟨⟨x, mem_union_left t (mem_of_mem_inter_left hx)⟩, ?_⟩ exact Hs.isPreconnected.union x (mem_of_mem_inter_left hx) (mem_of_mem_inter_right hx) Ht.isPreconnected /-- The directed sUnion of a set S of preconnected subsets is preconnected. -/ theorem IsPreconnected.sUnion_directed {S : Set (Set α)} (K : DirectedOn (· ⊆ ·) S) (H : ∀ s ∈ S, IsPreconnected s) : IsPreconnected (⋃₀ S) := by rintro u v hu hv Huv ⟨a, ⟨s, hsS, has⟩, hau⟩ ⟨b, ⟨t, htS, hbt⟩, hbv⟩ obtain ⟨r, hrS, hsr, htr⟩ : ∃ r ∈ S, s ⊆ r ∧ t ⊆ r := K s hsS t htS have Hnuv : (r ∩ (u ∩ v)).Nonempty := H _ hrS u v hu hv ((subset_sUnion_of_mem hrS).trans Huv) ⟨a, hsr has, hau⟩ ⟨b, htr hbt, hbv⟩ have Kruv : r ∩ (u ∩ v) ⊆ ⋃₀ S ∩ (u ∩ v) := inter_subset_inter_left _ (subset_sUnion_of_mem hrS) exact Hnuv.mono Kruv /-- The biUnion of a family of preconnected sets is preconnected if the graph determined by whether two sets intersect is preconnected. -/ theorem IsPreconnected.biUnion_of_reflTransGen {ι : Type*} {t : Set ι} {s : ι → Set α} (H : ∀ i ∈ t, IsPreconnected (s i)) (K : ∀ i, i ∈ t → ∀ j, j ∈ t → ReflTransGen (fun i j => (s i ∩ s j).Nonempty ∧ i ∈ t) i j) : IsPreconnected (⋃ n ∈ t, s n) := by let R := fun i j : ι => (s i ∩ s j).Nonempty ∧ i ∈ t have P : ∀ i, i ∈ t → ∀ j, j ∈ t → ReflTransGen R i j → ∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ j ∈ p, s j) := fun i hi j hj h => by induction h with | refl => refine ⟨{i}, singleton_subset_iff.mpr hi, mem_singleton i, mem_singleton i, ?_⟩ rw [biUnion_singleton] exact H i hi | @tail j k _ hjk ih => obtain ⟨p, hpt, hip, hjp, hp⟩ := ih hjk.2 refine ⟨insert k p, insert_subset_iff.mpr ⟨hj, hpt⟩, mem_insert_of_mem k hip, mem_insert k p, ?_⟩ rw [biUnion_insert] refine (H k hj).union' (hjk.1.mono ?_) hp rw [inter_comm] exact inter_subset_inter_right _ (subset_biUnion_of_mem hjp) refine isPreconnected_of_forall_pair ?_ intro x hx y hy obtain ⟨i : ι, hi : i ∈ t, hxi : x ∈ s i⟩ := mem_iUnion₂.1 hx obtain ⟨j : ι, hj : j ∈ t, hyj : y ∈ s j⟩ := mem_iUnion₂.1 hy obtain ⟨p, hpt, hip, hjp, hp⟩ := P i hi j hj (K i hi j hj) exact ⟨⋃ j ∈ p, s j, biUnion_subset_biUnion_left hpt, mem_biUnion hip hxi, mem_biUnion hjp hyj, hp⟩ /-- The biUnion of a family of preconnected sets is preconnected if the graph determined by whether two sets intersect is preconnected. -/ theorem IsConnected.biUnion_of_reflTransGen {ι : Type*} {t : Set ι} {s : ι → Set α} (ht : t.Nonempty) (H : ∀ i ∈ t, IsConnected (s i)) (K : ∀ i, i ∈ t → ∀ j, j ∈ t → ReflTransGen (fun i j : ι => (s i ∩ s j).Nonempty ∧ i ∈ t) i j) : IsConnected (⋃ n ∈ t, s n) := ⟨nonempty_biUnion.2 <| ⟨ht.some, ht.some_mem, (H _ ht.some_mem).nonempty⟩, IsPreconnected.biUnion_of_reflTransGen (fun i hi => (H i hi).isPreconnected) K⟩ /-- Preconnectedness of the iUnion of a family of preconnected sets indexed by the vertices of a preconnected graph, where two vertices are joined when the corresponding sets intersect. -/ theorem IsPreconnected.iUnion_of_reflTransGen {ι : Type*} {s : ι → Set α} (H : ∀ i, IsPreconnected (s i)) (K : ∀ i j, ReflTransGen (fun i j : ι => (s i ∩ s j).Nonempty) i j) : IsPreconnected (⋃ n, s n) := by rw [← biUnion_univ] exact IsPreconnected.biUnion_of_reflTransGen (fun i _ => H i) fun i _ j _ => by simpa [mem_univ] using K i j theorem IsConnected.iUnion_of_reflTransGen {ι : Type*} [Nonempty ι] {s : ι → Set α} (H : ∀ i, IsConnected (s i)) (K : ∀ i j, ReflTransGen (fun i j : ι => (s i ∩ s j).Nonempty) i j) : IsConnected (⋃ n, s n) := ⟨nonempty_iUnion.2 <| Nonempty.elim ‹_› fun i : ι => ⟨i, (H _).nonempty⟩, IsPreconnected.iUnion_of_reflTransGen (fun i => (H i).isPreconnected) K⟩ section SuccOrder open Order variable [LinearOrder β] [SuccOrder β] [IsSuccArchimedean β] /-- The iUnion of connected sets indexed by a type with an archimedean successor (like `ℕ` or `ℤ`) such that any two neighboring sets meet is preconnected. -/ theorem IsPreconnected.iUnion_of_chain {s : β → Set α} (H : ∀ n, IsPreconnected (s n)) (K : ∀ n, (s n ∩ s (succ n)).Nonempty) : IsPreconnected (⋃ n, s n) := IsPreconnected.iUnion_of_reflTransGen H fun i j => reflTransGen_of_succ _ (fun i _ => K i) fun i _ => by rw [inter_comm] exact K i /-- The iUnion of connected sets indexed by a type with an archimedean successor (like `ℕ` or `ℤ`) such that any two neighboring sets meet is connected. -/ theorem IsConnected.iUnion_of_chain [Nonempty β] {s : β → Set α} (H : ∀ n, IsConnected (s n)) (K : ∀ n, (s n ∩ s (succ n)).Nonempty) : IsConnected (⋃ n, s n) := IsConnected.iUnion_of_reflTransGen H fun i j => reflTransGen_of_succ _ (fun i _ => K i) fun i _ => by rw [inter_comm] exact K i /-- The iUnion of preconnected sets indexed by a subset of a type with an archimedean successor (like `ℕ` or `ℤ`) such that any two neighboring sets meet is preconnected. -/ theorem IsPreconnected.biUnion_of_chain {s : β → Set α} {t : Set β} (ht : OrdConnected t) (H : ∀ n ∈ t, IsPreconnected (s n)) (K : ∀ n : β, n ∈ t → succ n ∈ t → (s n ∩ s (succ n)).Nonempty) : IsPreconnected (⋃ n ∈ t, s n) := by have h1 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → k ∈ t := fun hi hj hk => ht.out hi hj (Ico_subset_Icc_self hk) have h2 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → succ k ∈ t := fun hi hj hk => ht.out hi hj ⟨hk.1.trans <| le_succ _, succ_le_of_lt hk.2⟩ have h3 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → (s k ∩ s (succ k)).Nonempty := fun hi hj hk => K _ (h1 hi hj hk) (h2 hi hj hk) refine IsPreconnected.biUnion_of_reflTransGen H fun i hi j hj => ?_ exact reflTransGen_of_succ _ (fun k hk => ⟨h3 hi hj hk, h1 hi hj hk⟩) fun k hk => ⟨by rw [inter_comm]; exact h3 hj hi hk, h2 hj hi hk⟩ /-- The iUnion of connected sets indexed by a subset of a type with an archimedean successor (like `ℕ` or `ℤ`) such that any two neighboring sets meet is preconnected. -/ theorem IsConnected.biUnion_of_chain {s : β → Set α} {t : Set β} (hnt : t.Nonempty) (ht : OrdConnected t) (H : ∀ n ∈ t, IsConnected (s n)) (K : ∀ n : β, n ∈ t → succ n ∈ t → (s n ∩ s (succ n)).Nonempty) : IsConnected (⋃ n ∈ t, s n) := ⟨nonempty_biUnion.2 <| ⟨hnt.some, hnt.some_mem, (H _ hnt.some_mem).nonempty⟩, IsPreconnected.biUnion_of_chain ht (fun i hi => (H i hi).isPreconnected) K⟩ end SuccOrder /-- Theorem of bark and tree: if a set is within a preconnected set and its closure, then it is preconnected as well. See also `IsConnected.subset_closure`. -/ protected theorem IsPreconnected.subset_closure {s : Set α} {t : Set α} (H : IsPreconnected s) (Kst : s ⊆ t) (Ktcs : t ⊆ closure s) : IsPreconnected t := fun u v hu hv htuv ⟨_y, hyt, hyu⟩ ⟨_z, hzt, hzv⟩ => let ⟨p, hpu, hps⟩ := mem_closure_iff.1 (Ktcs hyt) u hu hyu let ⟨q, hqv, hqs⟩ := mem_closure_iff.1 (Ktcs hzt) v hv hzv let ⟨r, hrs, hruv⟩ := H u v hu hv (Subset.trans Kst htuv) ⟨p, hps, hpu⟩ ⟨q, hqs, hqv⟩ ⟨r, Kst hrs, hruv⟩ /-- Theorem of bark and tree: if a set is within a connected set and its closure, then it is connected as well. See also `IsPreconnected.subset_closure`. -/ protected theorem IsConnected.subset_closure {s : Set α} {t : Set α} (H : IsConnected s) (Kst : s ⊆ t) (Ktcs : t ⊆ closure s) : IsConnected t := ⟨Nonempty.mono Kst H.left, IsPreconnected.subset_closure H.right Kst Ktcs⟩ /-- The closure of a preconnected set is preconnected as well. -/ protected theorem IsPreconnected.closure {s : Set α} (H : IsPreconnected s) : IsPreconnected (closure s) := IsPreconnected.subset_closure H subset_closure Subset.rfl /-- The closure of a connected set is connected as well. -/ protected theorem IsConnected.closure {s : Set α} (H : IsConnected s) : IsConnected (closure s) := IsConnected.subset_closure H subset_closure <| Subset.rfl /-- The image of a preconnected set is preconnected as well. -/ protected theorem IsPreconnected.image [TopologicalSpace β] {s : Set α} (H : IsPreconnected s) (f : α → β) (hf : ContinuousOn f s) : IsPreconnected (f '' s) := by -- Unfold/destruct definitions in hypotheses rintro u v hu hv huv ⟨_, ⟨x, xs, rfl⟩, xu⟩ ⟨_, ⟨y, ys, rfl⟩, yv⟩ rcases continuousOn_iff'.1 hf u hu with ⟨u', hu', u'_eq⟩ rcases continuousOn_iff'.1 hf v hv with ⟨v', hv', v'_eq⟩ -- Reformulate `huv : f '' s ⊆ u ∪ v` in terms of `u'` and `v'` replace huv : s ⊆ u' ∪ v' := by rw [image_subset_iff, preimage_union] at huv replace huv := subset_inter huv Subset.rfl rw [union_inter_distrib_right, u'_eq, v'_eq, ← union_inter_distrib_right] at huv exact (subset_inter_iff.1 huv).1 -- Now `s ⊆ u' ∪ v'`, so we can apply `‹IsPreconnected s›` obtain ⟨z, hz⟩ : (s ∩ (u' ∩ v')).Nonempty := by refine H u' v' hu' hv' huv ⟨x, ?_⟩ ⟨y, ?_⟩ <;> rw [inter_comm] exacts [u'_eq ▸ ⟨xu, xs⟩, v'_eq ▸ ⟨yv, ys⟩] rw [← inter_self s, inter_assoc, inter_left_comm s u', ← inter_assoc, inter_comm s, inter_comm s, ← u'_eq, ← v'_eq] at hz exact ⟨f z, ⟨z, hz.1.2, rfl⟩, hz.1.1, hz.2.1⟩ /-- The image of a connected set is connected as well. -/ protected theorem IsConnected.image [TopologicalSpace β] {s : Set α} (H : IsConnected s) (f : α → β) (hf : ContinuousOn f s) : IsConnected (f '' s) := ⟨image_nonempty.mpr H.nonempty, H.isPreconnected.image f hf⟩ theorem isPreconnected_closed_iff {s : Set α} : IsPreconnected s ↔ ∀ t t', IsClosed t → IsClosed t' → s ⊆ t ∪ t' → (s ∩ t).Nonempty → (s ∩ t').Nonempty → (s ∩ (t ∩ t')).Nonempty := ⟨by rintro h t t' ht ht' htt' ⟨x, xs, xt⟩ ⟨y, ys, yt'⟩ rw [← not_disjoint_iff_nonempty_inter, ← subset_compl_iff_disjoint_right, compl_inter] intro h' have xt' : x ∉ t' := (h' xs).resolve_left (absurd xt) have yt : y ∉ t := (h' ys).resolve_right (absurd yt') have := h _ _ ht.isOpen_compl ht'.isOpen_compl h' ⟨y, ys, yt⟩ ⟨x, xs, xt'⟩ rw [← compl_union] at this exact this.ne_empty htt'.disjoint_compl_right.inter_eq, by rintro h u v hu hv huv ⟨x, xs, xu⟩ ⟨y, ys, yv⟩ rw [← not_disjoint_iff_nonempty_inter, ← subset_compl_iff_disjoint_right, compl_inter] intro h' have xv : x ∉ v := (h' xs).elim (absurd xu) id have yu : y ∉ u := (h' ys).elim id (absurd yv) have := h _ _ hu.isClosed_compl hv.isClosed_compl h' ⟨y, ys, yu⟩ ⟨x, xs, xv⟩ rw [← compl_union] at this exact this.ne_empty huv.disjoint_compl_right.inter_eq⟩ theorem Inducing.isPreconnected_image [TopologicalSpace β] {s : Set α} {f : α → β} (hf : Inducing f) : IsPreconnected (f '' s) ↔ IsPreconnected s := by refine ⟨fun h => ?_, fun h => h.image _ hf.continuous.continuousOn⟩ rintro u v hu' hv' huv ⟨x, hxs, hxu⟩ ⟨y, hys, hyv⟩ rcases hf.isOpen_iff.1 hu' with ⟨u, hu, rfl⟩ rcases hf.isOpen_iff.1 hv' with ⟨v, hv, rfl⟩ replace huv : f '' s ⊆ u ∪ v := by rwa [image_subset_iff] rcases h u v hu hv huv ⟨f x, mem_image_of_mem _ hxs, hxu⟩ ⟨f y, mem_image_of_mem _ hys, hyv⟩ with ⟨_, ⟨z, hzs, rfl⟩, hzuv⟩ exact ⟨z, hzs, hzuv⟩ /- TODO: The following lemmas about connection of preimages hold more generally for strict maps (the quotient and subspace topologies of the image agree) whose fibers are preconnected. -/ theorem IsPreconnected.preimage_of_isOpenMap [TopologicalSpace β] {f : α → β} {s : Set β} (hs : IsPreconnected s) (hinj : Function.Injective f) (hf : IsOpenMap f) (hsf : s ⊆ range f) : IsPreconnected (f ⁻¹' s) := fun u v hu hv hsuv hsu hsv => by replace hsf : f '' (f ⁻¹' s) = s := image_preimage_eq_of_subset hsf obtain ⟨_, has, ⟨a, hau, rfl⟩, hav⟩ : (s ∩ (f '' u ∩ f '' v)).Nonempty := by refine hs (f '' u) (f '' v) (hf u hu) (hf v hv) ?_ ?_ ?_ · simpa only [hsf, image_union] using image_subset f hsuv · simpa only [image_preimage_inter] using hsu.image f · simpa only [image_preimage_inter] using hsv.image f · exact ⟨a, has, hau, hinj.mem_set_image.1 hav⟩ theorem IsPreconnected.preimage_of_isClosedMap [TopologicalSpace β] {s : Set β} (hs : IsPreconnected s) {f : α → β} (hinj : Function.Injective f) (hf : IsClosedMap f) (hsf : s ⊆ range f) : IsPreconnected (f ⁻¹' s) := isPreconnected_closed_iff.2 fun u v hu hv hsuv hsu hsv => by replace hsf : f '' (f ⁻¹' s) = s := image_preimage_eq_of_subset hsf obtain ⟨_, has, ⟨a, hau, rfl⟩, hav⟩ : (s ∩ (f '' u ∩ f '' v)).Nonempty := by refine isPreconnected_closed_iff.1 hs (f '' u) (f '' v) (hf u hu) (hf v hv) ?_ ?_ ?_ · simpa only [hsf, image_union] using image_subset f hsuv · simpa only [image_preimage_inter] using hsu.image f · simpa only [image_preimage_inter] using hsv.image f · exact ⟨a, has, hau, hinj.mem_set_image.1 hav⟩ theorem IsConnected.preimage_of_isOpenMap [TopologicalSpace β] {s : Set β} (hs : IsConnected s) {f : α → β} (hinj : Function.Injective f) (hf : IsOpenMap f) (hsf : s ⊆ range f) : IsConnected (f ⁻¹' s) := ⟨hs.nonempty.preimage' hsf, hs.isPreconnected.preimage_of_isOpenMap hinj hf hsf⟩ theorem IsConnected.preimage_of_isClosedMap [TopologicalSpace β] {s : Set β} (hs : IsConnected s) {f : α → β} (hinj : Function.Injective f) (hf : IsClosedMap f) (hsf : s ⊆ range f) : IsConnected (f ⁻¹' s) := ⟨hs.nonempty.preimage' hsf, hs.isPreconnected.preimage_of_isClosedMap hinj hf hsf⟩ theorem IsPreconnected.subset_or_subset (hu : IsOpen u) (hv : IsOpen v) (huv : Disjoint u v) (hsuv : s ⊆ u ∪ v) (hs : IsPreconnected s) : s ⊆ u ∨ s ⊆ v := by specialize hs u v hu hv hsuv obtain hsu | hsu := (s ∩ u).eq_empty_or_nonempty · exact Or.inr ((Set.disjoint_iff_inter_eq_empty.2 hsu).subset_right_of_subset_union hsuv) · replace hs := mt (hs hsu) simp_rw [Set.not_nonempty_iff_eq_empty, ← Set.disjoint_iff_inter_eq_empty, disjoint_iff_inter_eq_empty.1 huv] at hs exact Or.inl ((hs s.disjoint_empty).subset_left_of_subset_union hsuv) theorem IsPreconnected.subset_left_of_subset_union (hu : IsOpen u) (hv : IsOpen v) (huv : Disjoint u v) (hsuv : s ⊆ u ∪ v) (hsu : (s ∩ u).Nonempty) (hs : IsPreconnected s) : s ⊆ u := Disjoint.subset_left_of_subset_union hsuv (by by_contra hsv rw [not_disjoint_iff_nonempty_inter] at hsv obtain ⟨x, _, hx⟩ := hs u v hu hv hsuv hsu hsv exact Set.disjoint_iff.1 huv hx) theorem IsPreconnected.subset_right_of_subset_union (hu : IsOpen u) (hv : IsOpen v) (huv : Disjoint u v) (hsuv : s ⊆ u ∪ v) (hsv : (s ∩ v).Nonempty) (hs : IsPreconnected s) : s ⊆ v := hs.subset_left_of_subset_union hv hu huv.symm (union_comm u v ▸ hsuv) hsv /-- If a preconnected set `s` intersects an open set `u`, and limit points of `u` inside `s` are contained in `u`, then the whole set `s` is contained in `u`. -/ theorem IsPreconnected.subset_of_closure_inter_subset (hs : IsPreconnected s) (hu : IsOpen u) (h'u : (s ∩ u).Nonempty) (h : closure u ∩ s ⊆ u) : s ⊆ u := by have A : s ⊆ u ∪ (closure u)ᶜ := by intro x hx by_cases xu : x ∈ u · exact Or.inl xu · right intro h'x exact xu (h (mem_inter h'x hx)) apply hs.subset_left_of_subset_union hu isClosed_closure.isOpen_compl _ A h'u exact disjoint_compl_right.mono_right (compl_subset_compl.2 subset_closure) theorem IsPreconnected.prod [TopologicalSpace β] {s : Set α} {t : Set β} (hs : IsPreconnected s) (ht : IsPreconnected t) : IsPreconnected (s ×ˢ t) := by apply isPreconnected_of_forall_pair rintro ⟨a₁, b₁⟩ ⟨ha₁, hb₁⟩ ⟨a₂, b₂⟩ ⟨ha₂, hb₂⟩ refine ⟨Prod.mk a₁ '' t ∪ flip Prod.mk b₂ '' s, ?_, .inl ⟨b₁, hb₁, rfl⟩, .inr ⟨a₂, ha₂, rfl⟩, ?_⟩ · rintro _ (⟨y, hy, rfl⟩ | ⟨x, hx, rfl⟩) exacts [⟨ha₁, hy⟩, ⟨hx, hb₂⟩] · exact (ht.image _ (Continuous.Prod.mk _).continuousOn).union (a₁, b₂) ⟨b₂, hb₂, rfl⟩ ⟨a₁, ha₁, rfl⟩ (hs.image _ (continuous_id.prod_mk continuous_const).continuousOn) theorem IsConnected.prod [TopologicalSpace β] {s : Set α} {t : Set β} (hs : IsConnected s) (ht : IsConnected t) : IsConnected (s ×ˢ t) := ⟨hs.1.prod ht.1, hs.2.prod ht.2⟩ theorem isPreconnected_univ_pi [∀ i, TopologicalSpace (π i)] {s : ∀ i, Set (π i)} (hs : ∀ i, IsPreconnected (s i)) : IsPreconnected (pi univ s) := by rintro u v uo vo hsuv ⟨f, hfs, hfu⟩ ⟨g, hgs, hgv⟩ classical rcases exists_finset_piecewise_mem_of_mem_nhds (uo.mem_nhds hfu) g with ⟨I, hI⟩ induction' I using Finset.induction_on with i I _ ihI · refine ⟨g, hgs, ⟨?_, hgv⟩⟩ simpa using hI · rw [Finset.piecewise_insert] at hI have := I.piecewise_mem_set_pi hfs hgs refine (hsuv this).elim ihI fun h => ?_ set S := update (I.piecewise f g) i '' s i have hsub : S ⊆ pi univ s := by refine image_subset_iff.2 fun z hz => ?_ rwa [update_preimage_univ_pi] exact fun j _ => this j trivial have hconn : IsPreconnected S := (hs i).image _ (continuous_const.update i continuous_id).continuousOn have hSu : (S ∩ u).Nonempty := ⟨_, mem_image_of_mem _ (hfs _ trivial), hI⟩ have hSv : (S ∩ v).Nonempty := ⟨_, ⟨_, this _ trivial, update_eq_self _ _⟩, h⟩ refine (hconn u v uo vo (hsub.trans hsuv) hSu hSv).mono ?_ exact inter_subset_inter_left _ hsub @[simp] theorem isConnected_univ_pi [∀ i, TopologicalSpace (π i)] {s : ∀ i, Set (π i)} : IsConnected (pi univ s) ↔ ∀ i, IsConnected (s i) := by simp only [IsConnected, ← univ_pi_nonempty_iff, forall_and, and_congr_right_iff] refine fun hne => ⟨fun hc i => ?_, isPreconnected_univ_pi⟩ rw [← eval_image_univ_pi hne] exact hc.image _ (continuous_apply _).continuousOn /-- The connected component of a point is the maximal connected set that contains this point. -/ def connectedComponent (x : α) : Set α := ⋃₀ { s : Set α | IsPreconnected s ∧ x ∈ s } open Classical in /-- Given a set `F` in a topological space `α` and a point `x : α`, the connected component of `x` in `F` is the connected component of `x` in the subtype `F` seen as a set in `α`. This definition does not make sense if `x` is not in `F` so we return the empty set in this case. -/ def connectedComponentIn (F : Set α) (x : α) : Set α := if h : x ∈ F then (↑) '' connectedComponent (⟨x, h⟩ : F) else ∅ theorem connectedComponentIn_eq_image {F : Set α} {x : α} (h : x ∈ F) : connectedComponentIn F x = (↑) '' connectedComponent (⟨x, h⟩ : F) := dif_pos h theorem connectedComponentIn_eq_empty {F : Set α} {x : α} (h : x ∉ F) : connectedComponentIn F x = ∅ := dif_neg h theorem mem_connectedComponent {x : α} : x ∈ connectedComponent x := mem_sUnion_of_mem (mem_singleton x) ⟨isPreconnected_singleton, mem_singleton x⟩ theorem mem_connectedComponentIn {x : α} {F : Set α} (hx : x ∈ F) : x ∈ connectedComponentIn F x := by simp [connectedComponentIn_eq_image hx, mem_connectedComponent, hx] theorem connectedComponent_nonempty {x : α} : (connectedComponent x).Nonempty := ⟨x, mem_connectedComponent⟩ theorem connectedComponentIn_nonempty_iff {x : α} {F : Set α} : (connectedComponentIn F x).Nonempty ↔ x ∈ F := by rw [connectedComponentIn] split_ifs <;> simp [connectedComponent_nonempty, *] theorem connectedComponentIn_subset (F : Set α) (x : α) : connectedComponentIn F x ⊆ F := by rw [connectedComponentIn] split_ifs <;> simp theorem isPreconnected_connectedComponent {x : α} : IsPreconnected (connectedComponent x) := isPreconnected_sUnion x _ (fun _ => And.right) fun _ => And.left theorem isPreconnected_connectedComponentIn {x : α} {F : Set α} : IsPreconnected (connectedComponentIn F x) := by rw [connectedComponentIn]; split_ifs · exact inducing_subtype_val.isPreconnected_image.mpr isPreconnected_connectedComponent · exact isPreconnected_empty theorem isConnected_connectedComponent {x : α} : IsConnected (connectedComponent x) := ⟨⟨x, mem_connectedComponent⟩, isPreconnected_connectedComponent⟩ theorem isConnected_connectedComponentIn_iff {x : α} {F : Set α} : IsConnected (connectedComponentIn F x) ↔ x ∈ F := by simp_rw [← connectedComponentIn_nonempty_iff, IsConnected, isPreconnected_connectedComponentIn, and_true_iff] theorem IsPreconnected.subset_connectedComponent {x : α} {s : Set α} (H1 : IsPreconnected s) (H2 : x ∈ s) : s ⊆ connectedComponent x := fun _z hz => mem_sUnion_of_mem hz ⟨H1, H2⟩ theorem IsPreconnected.subset_connectedComponentIn {x : α} {F : Set α} (hs : IsPreconnected s) (hxs : x ∈ s) (hsF : s ⊆ F) : s ⊆ connectedComponentIn F x := by have : IsPreconnected (((↑) : F → α) ⁻¹' s) := by refine inducing_subtype_val.isPreconnected_image.mp ?_ rwa [Subtype.image_preimage_coe, inter_eq_right.mpr hsF] have h2xs : (⟨x, hsF hxs⟩ : F) ∈ (↑) ⁻¹' s := by rw [mem_preimage] exact hxs have := this.subset_connectedComponent h2xs rw [connectedComponentIn_eq_image (hsF hxs)] refine Subset.trans ?_ (image_subset _ this) rw [Subtype.image_preimage_coe, inter_eq_right.mpr hsF] theorem IsConnected.subset_connectedComponent {x : α} {s : Set α} (H1 : IsConnected s) (H2 : x ∈ s) : s ⊆ connectedComponent x := H1.2.subset_connectedComponent H2 theorem IsPreconnected.connectedComponentIn {x : α} {F : Set α} (h : IsPreconnected F) (hx : x ∈ F) : connectedComponentIn F x = F := (connectedComponentIn_subset F x).antisymm (h.subset_connectedComponentIn hx subset_rfl) theorem connectedComponent_eq {x y : α} (h : y ∈ connectedComponent x) : connectedComponent x = connectedComponent y := eq_of_subset_of_subset (isConnected_connectedComponent.subset_connectedComponent h) (isConnected_connectedComponent.subset_connectedComponent (Set.mem_of_mem_of_subset mem_connectedComponent (isConnected_connectedComponent.subset_connectedComponent h))) theorem connectedComponent_eq_iff_mem {x y : α} : connectedComponent x = connectedComponent y ↔ x ∈ connectedComponent y := ⟨fun h => h ▸ mem_connectedComponent, fun h => (connectedComponent_eq h).symm⟩ theorem connectedComponentIn_eq {x y : α} {F : Set α} (h : y ∈ connectedComponentIn F x) : connectedComponentIn F x = connectedComponentIn F y := by have hx : x ∈ F := connectedComponentIn_nonempty_iff.mp ⟨y, h⟩ simp_rw [connectedComponentIn_eq_image hx] at h ⊢ obtain ⟨⟨y, hy⟩, h2y, rfl⟩ := h simp_rw [connectedComponentIn_eq_image hy, connectedComponent_eq h2y] theorem connectedComponentIn_univ (x : α) : connectedComponentIn univ x = connectedComponent x := subset_antisymm (isPreconnected_connectedComponentIn.subset_connectedComponent <| mem_connectedComponentIn trivial) (isPreconnected_connectedComponent.subset_connectedComponentIn mem_connectedComponent <| subset_univ _) theorem connectedComponent_disjoint {x y : α} (h : connectedComponent x ≠ connectedComponent y) : Disjoint (connectedComponent x) (connectedComponent y) := Set.disjoint_left.2 fun _ h1 h2 => h ((connectedComponent_eq h1).trans (connectedComponent_eq h2).symm) theorem isClosed_connectedComponent {x : α} : IsClosed (connectedComponent x) := closure_subset_iff_isClosed.1 <| isConnected_connectedComponent.closure.subset_connectedComponent <| subset_closure mem_connectedComponent theorem Continuous.image_connectedComponent_subset [TopologicalSpace β] {f : α → β} (h : Continuous f) (a : α) : f '' connectedComponent a ⊆ connectedComponent (f a) := (isConnected_connectedComponent.image f h.continuousOn).subset_connectedComponent ((mem_image f (connectedComponent a) (f a)).2 ⟨a, mem_connectedComponent, rfl⟩) theorem Continuous.image_connectedComponentIn_subset [TopologicalSpace β] {f : α → β} {s : Set α} {a : α} (hf : Continuous f) (hx : a ∈ s) : f '' connectedComponentIn s a ⊆ connectedComponentIn (f '' s) (f a) := (isPreconnected_connectedComponentIn.image _ hf.continuousOn).subset_connectedComponentIn (mem_image_of_mem _ <| mem_connectedComponentIn hx) (image_subset _ <| connectedComponentIn_subset _ _) theorem Continuous.mapsTo_connectedComponent [TopologicalSpace β] {f : α → β} (h : Continuous f) (a : α) : MapsTo f (connectedComponent a) (connectedComponent (f a)) := mapsTo'.2 <| h.image_connectedComponent_subset a theorem Continuous.mapsTo_connectedComponentIn [TopologicalSpace β] {f : α → β} {s : Set α} (h : Continuous f) {a : α} (hx : a ∈ s) : MapsTo f (connectedComponentIn s a) (connectedComponentIn (f '' s) (f a)) := mapsTo'.2 <| image_connectedComponentIn_subset h hx theorem irreducibleComponent_subset_connectedComponent {x : α} : irreducibleComponent x ⊆ connectedComponent x := isIrreducible_irreducibleComponent.isConnected.subset_connectedComponent mem_irreducibleComponent @[mono] theorem connectedComponentIn_mono (x : α) {F G : Set α} (h : F ⊆ G) : connectedComponentIn F x ⊆ connectedComponentIn G x := by by_cases hx : x ∈ F · rw [connectedComponentIn_eq_image hx, connectedComponentIn_eq_image (h hx), ← show ((↑) : G → α) ∘ inclusion h = (↑) from rfl, image_comp] exact image_subset _ ((continuous_inclusion h).image_connectedComponent_subset ⟨x, hx⟩) · rw [connectedComponentIn_eq_empty hx] exact Set.empty_subset _ /-- A preconnected space is one where there is no non-trivial open partition. -/ class PreconnectedSpace (α : Type u) [TopologicalSpace α] : Prop where /-- The universal set `Set.univ` in a preconnected space is a preconnected set. -/ isPreconnected_univ : IsPreconnected (univ : Set α) export PreconnectedSpace (isPreconnected_univ) /-- A connected space is a nonempty one where there is no non-trivial open partition. -/ class ConnectedSpace (α : Type u) [TopologicalSpace α] extends PreconnectedSpace α : Prop where /-- A connected space is nonempty. -/ toNonempty : Nonempty α attribute [instance 50] ConnectedSpace.toNonempty -- see Note [lower instance priority] -- see Note [lower instance priority] theorem isConnected_univ [ConnectedSpace α] : IsConnected (univ : Set α) := ⟨univ_nonempty, isPreconnected_univ⟩ lemma preconnectedSpace_iff_univ : PreconnectedSpace α ↔ IsPreconnected (univ : Set α) := ⟨fun h ↦ h.1, fun h ↦ ⟨h⟩⟩ lemma connectedSpace_iff_univ : ConnectedSpace α ↔ IsConnected (univ : Set α) := ⟨fun h ↦ ⟨univ_nonempty, h.1.1⟩, fun h ↦ ConnectedSpace.mk (toPreconnectedSpace := ⟨h.2⟩) ⟨h.1.some⟩⟩ theorem isPreconnected_range [TopologicalSpace β] [PreconnectedSpace α] {f : α → β} (h : Continuous f) : IsPreconnected (range f) := @image_univ _ _ f ▸ isPreconnected_univ.image _ h.continuousOn theorem isConnected_range [TopologicalSpace β] [ConnectedSpace α] {f : α → β} (h : Continuous f) : IsConnected (range f) := ⟨range_nonempty f, isPreconnected_range h⟩ theorem Function.Surjective.connectedSpace [ConnectedSpace α] [TopologicalSpace β] {f : α → β} (hf : Surjective f) (hf' : Continuous f) : ConnectedSpace β := by rw [connectedSpace_iff_univ, ← hf.range_eq] exact isConnected_range hf' instance Quotient.instConnectedSpace {s : Setoid α} [ConnectedSpace α] : ConnectedSpace (Quotient s) := (surjective_quotient_mk' _).connectedSpace continuous_coinduced_rng theorem DenseRange.preconnectedSpace [TopologicalSpace β] [PreconnectedSpace α] {f : α → β} (hf : DenseRange f) (hc : Continuous f) : PreconnectedSpace β := ⟨hf.closure_eq ▸ (isPreconnected_range hc).closure⟩ theorem connectedSpace_iff_connectedComponent : ConnectedSpace α ↔ ∃ x : α, connectedComponent x = univ := by constructor · rintro ⟨⟨x⟩⟩ exact ⟨x, eq_univ_of_univ_subset <| isPreconnected_univ.subset_connectedComponent (mem_univ x)⟩ · rintro ⟨x, h⟩ haveI : PreconnectedSpace α := ⟨by rw [← h]; exact isPreconnected_connectedComponent⟩ exact ⟨⟨x⟩⟩ theorem preconnectedSpace_iff_connectedComponent : PreconnectedSpace α ↔ ∀ x : α, connectedComponent x = univ := by constructor · intro h x exact eq_univ_of_univ_subset <| isPreconnected_univ.subset_connectedComponent (mem_univ x) · intro h cases' isEmpty_or_nonempty α with hα hα · exact ⟨by rw [univ_eq_empty_iff.mpr hα]; exact isPreconnected_empty⟩ · exact ⟨by rw [← h (Classical.choice hα)]; exact isPreconnected_connectedComponent⟩ @[simp] theorem PreconnectedSpace.connectedComponent_eq_univ {X : Type*} [TopologicalSpace X] [h : PreconnectedSpace X] (x : X) : connectedComponent x = univ := preconnectedSpace_iff_connectedComponent.mp h x instance [TopologicalSpace β] [PreconnectedSpace α] [PreconnectedSpace β] : PreconnectedSpace (α × β) := ⟨by rw [← univ_prod_univ] exact isPreconnected_univ.prod isPreconnected_univ⟩ instance [TopologicalSpace β] [ConnectedSpace α] [ConnectedSpace β] : ConnectedSpace (α × β) := ⟨inferInstance⟩ instance [∀ i, TopologicalSpace (π i)] [∀ i, PreconnectedSpace (π i)] : PreconnectedSpace (∀ i, π i) := ⟨by rw [← pi_univ univ]; exact isPreconnected_univ_pi fun i => isPreconnected_univ⟩ instance [∀ i, TopologicalSpace (π i)] [∀ i, ConnectedSpace (π i)] : ConnectedSpace (∀ i, π i) := ⟨inferInstance⟩ -- see Note [lower instance priority] instance (priority := 100) PreirreducibleSpace.preconnectedSpace (α : Type u) [TopologicalSpace α] [PreirreducibleSpace α] : PreconnectedSpace α := ⟨isPreirreducible_univ.isPreconnected⟩ -- see Note [lower instance priority] instance (priority := 100) IrreducibleSpace.connectedSpace (α : Type u) [TopologicalSpace α] [IrreducibleSpace α] : ConnectedSpace α where toNonempty := IrreducibleSpace.toNonempty theorem Subtype.preconnectedSpace {s : Set α} (h : IsPreconnected s) : PreconnectedSpace s where isPreconnected_univ := by rwa [← inducing_subtype_val.isPreconnected_image, image_univ, Subtype.range_val] theorem Subtype.connectedSpace {s : Set α} (h : IsConnected s) : ConnectedSpace s where toPreconnectedSpace := Subtype.preconnectedSpace h.isPreconnected toNonempty := h.nonempty.to_subtype theorem isPreconnected_iff_preconnectedSpace {s : Set α} : IsPreconnected s ↔ PreconnectedSpace s := ⟨Subtype.preconnectedSpace, fun h => by simpa using isPreconnected_univ.image ((↑) : s → α) continuous_subtype_val.continuousOn⟩ theorem isConnected_iff_connectedSpace {s : Set α} : IsConnected s ↔ ConnectedSpace s := ⟨Subtype.connectedSpace, fun h => ⟨nonempty_subtype.mp h.2, isPreconnected_iff_preconnectedSpace.mpr h.1⟩⟩ end Preconnected
Topology\Connected\Clopen.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Subset import Mathlib.Topology.Clopen import Mathlib.Topology.Connected.Basic /-! # Connected subsets and their relation to clopen sets In this file we show how connected subsets of a topological space are intimately connected to clopen sets. ## Main declarations + `IsClopen.biUnion_connectedComponent_eq`: a clopen set is the union of its connected components. + `PreconnectedSpace.induction₂`: an induction principle for preconnected spaces. + `ConnectedComponents`: The connected compoenents of a topological space, as a quotient type. -/ open Set Function Topology TopologicalSpace Relation universe u v variable {α : Type u} {β : Type v} {ι : Type*} {π : ι → Type*} [TopologicalSpace α] {s t u v : Set α} section Preconnected /-- Preconnected sets are either contained in or disjoint to any given clopen set. -/ theorem IsPreconnected.subset_isClopen {s t : Set α} (hs : IsPreconnected s) (ht : IsClopen t) (hne : (s ∩ t).Nonempty) : s ⊆ t := hs.subset_left_of_subset_union ht.isOpen ht.compl.isOpen disjoint_compl_right (by simp) hne theorem Sigma.isConnected_iff [∀ i, TopologicalSpace (π i)] {s : Set (Σi, π i)} : IsConnected s ↔ ∃ i t, IsConnected t ∧ s = Sigma.mk i '' t := by refine ⟨fun hs => ?_, ?_⟩ · obtain ⟨⟨i, x⟩, hx⟩ := hs.nonempty have : s ⊆ range (Sigma.mk i) := hs.isPreconnected.subset_isClopen isClopen_range_sigmaMk ⟨⟨i, x⟩, hx, x, rfl⟩ exact ⟨i, Sigma.mk i ⁻¹' s, hs.preimage_of_isOpenMap sigma_mk_injective isOpenMap_sigmaMk this, (Set.image_preimage_eq_of_subset this).symm⟩ · rintro ⟨i, t, ht, rfl⟩ exact ht.image _ continuous_sigmaMk.continuousOn theorem Sigma.isPreconnected_iff [hι : Nonempty ι] [∀ i, TopologicalSpace (π i)] {s : Set (Σi, π i)} : IsPreconnected s ↔ ∃ i t, IsPreconnected t ∧ s = Sigma.mk i '' t := by refine ⟨fun hs => ?_, ?_⟩ · obtain rfl | h := s.eq_empty_or_nonempty · exact ⟨Classical.choice hι, ∅, isPreconnected_empty, (Set.image_empty _).symm⟩ · obtain ⟨a, t, ht, rfl⟩ := Sigma.isConnected_iff.1 ⟨h, hs⟩ exact ⟨a, t, ht.isPreconnected, rfl⟩ · rintro ⟨a, t, ht, rfl⟩ exact ht.image _ continuous_sigmaMk.continuousOn theorem Sum.isConnected_iff [TopologicalSpace β] {s : Set (α ⊕ β)} : IsConnected s ↔ (∃ t, IsConnected t ∧ s = Sum.inl '' t) ∨ ∃ t, IsConnected t ∧ s = Sum.inr '' t := by refine ⟨fun hs => ?_, ?_⟩ · obtain ⟨x | x, hx⟩ := hs.nonempty · have h : s ⊆ range Sum.inl := hs.isPreconnected.subset_isClopen isClopen_range_inl ⟨.inl x, hx, x, rfl⟩ refine Or.inl ⟨Sum.inl ⁻¹' s, ?_, ?_⟩ · exact hs.preimage_of_isOpenMap Sum.inl_injective isOpenMap_inl h · exact (image_preimage_eq_of_subset h).symm · have h : s ⊆ range Sum.inr := hs.isPreconnected.subset_isClopen isClopen_range_inr ⟨.inr x, hx, x, rfl⟩ refine Or.inr ⟨Sum.inr ⁻¹' s, ?_, ?_⟩ · exact hs.preimage_of_isOpenMap Sum.inr_injective isOpenMap_inr h · exact (image_preimage_eq_of_subset h).symm · rintro (⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩) · exact ht.image _ continuous_inl.continuousOn · exact ht.image _ continuous_inr.continuousOn theorem Sum.isPreconnected_iff [TopologicalSpace β] {s : Set (α ⊕ β)} : IsPreconnected s ↔ (∃ t, IsPreconnected t ∧ s = Sum.inl '' t) ∨ ∃ t, IsPreconnected t ∧ s = Sum.inr '' t := by refine ⟨fun hs => ?_, ?_⟩ · obtain rfl | h := s.eq_empty_or_nonempty · exact Or.inl ⟨∅, isPreconnected_empty, (Set.image_empty _).symm⟩ obtain ⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩ := Sum.isConnected_iff.1 ⟨h, hs⟩ · exact Or.inl ⟨t, ht.isPreconnected, rfl⟩ · exact Or.inr ⟨t, ht.isPreconnected, rfl⟩ · rintro (⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩) · exact ht.image _ continuous_inl.continuousOn · exact ht.image _ continuous_inr.continuousOn /-- A continuous map from a connected space to a disjoint union `Σ i, π i` can be lifted to one of the components `π i`. See also `ContinuousMap.exists_lift_sigma` for a version with bundled `ContinuousMap`s. -/ theorem Continuous.exists_lift_sigma [ConnectedSpace α] [∀ i, TopologicalSpace (π i)] {f : α → Σ i, π i} (hf : Continuous f) : ∃ (i : ι) (g : α → π i), Continuous g ∧ f = Sigma.mk i ∘ g := by obtain ⟨i, hi⟩ : ∃ i, range f ⊆ range (.mk i) := by rcases Sigma.isConnected_iff.1 (isConnected_range hf) with ⟨i, s, -, hs⟩ exact ⟨i, hs.trans_subset (image_subset_range _ _)⟩ rcases range_subset_range_iff_exists_comp.1 hi with ⟨g, rfl⟩ refine ⟨i, g, ?_, rfl⟩ rwa [← embedding_sigmaMk.continuous_iff] at hf theorem nonempty_inter [PreconnectedSpace α] {s t : Set α} : IsOpen s → IsOpen t → s ∪ t = univ → s.Nonempty → t.Nonempty → (s ∩ t).Nonempty := by simpa only [univ_inter, univ_subset_iff] using @PreconnectedSpace.isPreconnected_univ α _ _ s t theorem isClopen_iff [PreconnectedSpace α] {s : Set α} : IsClopen s ↔ s = ∅ ∨ s = univ := ⟨fun hs => by_contradiction fun h => have h1 : s ≠ ∅ ∧ sᶜ ≠ ∅ := ⟨mt Or.inl h, mt (fun h2 => Or.inr <| (by rw [← compl_compl s, h2, compl_empty] : s = univ)) h⟩ let ⟨_, h2, h3⟩ := nonempty_inter hs.2 hs.1.isOpen_compl (union_compl_self s) (nonempty_iff_ne_empty.2 h1.1) (nonempty_iff_ne_empty.2 h1.2) h3 h2, by rintro (rfl | rfl) <;> [exact isClopen_empty; exact isClopen_univ]⟩ theorem IsClopen.eq_univ [PreconnectedSpace α] {s : Set α} (h' : IsClopen s) (h : s.Nonempty) : s = univ := (isClopen_iff.mp h').resolve_left h.ne_empty open Set.Notation in lemma isClopen_preimage_val {X : Type*} [TopologicalSpace X] {u v : Set X} (hu : IsOpen u) (huv : Disjoint (frontier u) v) : IsClopen (v ↓∩ u) := by refine ⟨?_, isOpen_induced hu (f := Subtype.val)⟩ refine isClosed_induced_iff.mpr ⟨closure u, isClosed_closure, ?_⟩ apply image_val_injective simp only [Subtype.image_preimage_coe] rw [closure_eq_self_union_frontier, inter_union_distrib_left, inter_comm _ (frontier u), huv.inter_eq, union_empty] section disjoint_subsets variable [PreconnectedSpace α] {s : ι → Set α} (h_nonempty : ∀ i, (s i).Nonempty) (h_disj : Pairwise (Disjoint on s)) /-- In a preconnected space, any disjoint family of non-empty clopen subsets has at most one element. -/ lemma subsingleton_of_disjoint_isClopen (h_clopen : ∀ i, IsClopen (s i)) : Subsingleton ι := by replace h_nonempty : ∀ i, s i ≠ ∅ := by intro i; rw [← nonempty_iff_ne_empty]; exact h_nonempty i rw [← not_nontrivial_iff_subsingleton] by_contra contra obtain ⟨i, j, h_ne⟩ := contra replace h_ne : s i ∩ s j = ∅ := by simpa only [← bot_eq_empty, eq_bot_iff, ← inf_eq_inter, ← disjoint_iff_inf_le] using h_disj h_ne cases' isClopen_iff.mp (h_clopen i) with hi hi · exact h_nonempty i hi · rw [hi, univ_inter] at h_ne exact h_nonempty j h_ne /-- In a preconnected space, any disjoint cover by non-empty open subsets has at most one element. -/ lemma subsingleton_of_disjoint_isOpen_iUnion_eq_univ (h_open : ∀ i, IsOpen (s i)) (h_Union : ⋃ i, s i = univ) : Subsingleton ι := by refine subsingleton_of_disjoint_isClopen h_nonempty h_disj (fun i ↦ ⟨?_, h_open i⟩) rw [← isOpen_compl_iff, compl_eq_univ_diff, ← h_Union, iUnion_diff] refine isOpen_iUnion (fun j ↦ ?_) rcases eq_or_ne i j with rfl | h_ne · simp · simpa only [(h_disj h_ne.symm).sdiff_eq_left] using h_open j /-- In a preconnected space, any finite disjoint cover by non-empty closed subsets has at most one element. -/ lemma subsingleton_of_disjoint_isClosed_iUnion_eq_univ [Finite ι] (h_closed : ∀ i, IsClosed (s i)) (h_Union : ⋃ i, s i = univ) : Subsingleton ι := by refine subsingleton_of_disjoint_isClopen h_nonempty h_disj (fun i ↦ ⟨h_closed i, ?_⟩) rw [← isClosed_compl_iff, compl_eq_univ_diff, ← h_Union, iUnion_diff] refine isClosed_iUnion_of_finite (fun j ↦ ?_) rcases eq_or_ne i j with rfl | h_ne · simp · simpa only [(h_disj h_ne.symm).sdiff_eq_left] using h_closed j end disjoint_subsets theorem frontier_eq_empty_iff [PreconnectedSpace α] {s : Set α} : frontier s = ∅ ↔ s = ∅ ∨ s = univ := isClopen_iff_frontier_eq_empty.symm.trans isClopen_iff theorem nonempty_frontier_iff [PreconnectedSpace α] {s : Set α} : (frontier s).Nonempty ↔ s.Nonempty ∧ s ≠ univ := by simp only [nonempty_iff_ne_empty, Ne, frontier_eq_empty_iff, not_or] /-- In a preconnected space, given a transitive relation `P`, if `P x y` and `P y x` are true for `y` close enough to `x`, then `P x y` holds for all `x, y`. This is a version of the fact that, if an equivalence relation has open classes, then it has a single equivalence class. -/ lemma PreconnectedSpace.induction₂' [PreconnectedSpace α] (P : α → α → Prop) (h : ∀ x, ∀ᶠ y in 𝓝 x, P x y ∧ P y x) (h' : Transitive P) (x y : α) : P x y := by let u := {z | P x z} have A : IsClosed u := by apply isClosed_iff_nhds.2 (fun z hz ↦ ?_) rcases hz _ (h z) with ⟨t, ht, h't⟩ exact h' h't ht.2 have B : IsOpen u := by apply isOpen_iff_mem_nhds.2 (fun z hz ↦ ?_) filter_upwards [h z] with t ht exact h' hz ht.1 have C : u.Nonempty := ⟨x, (mem_of_mem_nhds (h x)).1⟩ have D : u = Set.univ := IsClopen.eq_univ ⟨A, B⟩ C show y ∈ u simp [D] /-- In a preconnected space, if a symmetric transitive relation `P x y` is true for `y` close enough to `x`, then it holds for all `x, y`. This is a version of the fact that, if an equivalence relation has open classes, then it has a single equivalence class. -/ lemma PreconnectedSpace.induction₂ [PreconnectedSpace α] (P : α → α → Prop) (h : ∀ x, ∀ᶠ y in 𝓝 x, P x y) (h' : Transitive P) (h'' : Symmetric P) (x y : α) : P x y := by refine PreconnectedSpace.induction₂' P (fun z ↦ ?_) h' x y filter_upwards [h z] with a ha exact ⟨ha, h'' ha⟩ /-- In a preconnected set, given a transitive relation `P`, if `P x y` and `P y x` are true for `y` close enough to `x`, then `P x y` holds for all `x, y`. This is a version of the fact that, if an equivalence relation has open classes, then it has a single equivalence class. -/ lemma IsPreconnected.induction₂' {s : Set α} (hs : IsPreconnected s) (P : α → α → Prop) (h : ∀ x ∈ s, ∀ᶠ y in 𝓝[s] x, P x y ∧ P y x) (h' : ∀ x y z, x ∈ s → y ∈ s → z ∈ s → P x y → P y z → P x z) {x y : α} (hx : x ∈ s) (hy : y ∈ s) : P x y := by let Q : s → s → Prop := fun a b ↦ P a b show Q ⟨x, hx⟩ ⟨y, hy⟩ have : PreconnectedSpace s := Subtype.preconnectedSpace hs apply PreconnectedSpace.induction₂' · rintro ⟨x, hx⟩ have Z := h x hx rwa [nhdsWithin_eq_map_subtype_coe] at Z · rintro ⟨a, ha⟩ ⟨b, hb⟩ ⟨c, hc⟩ hab hbc exact h' a b c ha hb hc hab hbc /-- In a preconnected set, if a symmetric transitive relation `P x y` is true for `y` close enough to `x`, then it holds for all `x, y`. This is a version of the fact that, if an equivalence relation has open classes, then it has a single equivalence class. -/ lemma IsPreconnected.induction₂ {s : Set α} (hs : IsPreconnected s) (P : α → α → Prop) (h : ∀ x ∈ s, ∀ᶠ y in 𝓝[s] x, P x y) (h' : ∀ x y z, x ∈ s → y ∈ s → z ∈ s → P x y → P y z → P x z) (h'' : ∀ x y, x ∈ s → y ∈ s → P x y → P y x) {x y : α} (hx : x ∈ s) (hy : y ∈ s) : P x y := by apply hs.induction₂' P (fun z hz ↦ ?_) h' hx hy filter_upwards [h z hz, self_mem_nhdsWithin] with a ha h'a exact ⟨ha, h'' z a hz h'a ha⟩ /-- A set `s` is preconnected if and only if for every cover by two open sets that are disjoint on `s`, it is contained in one of the two covering sets. -/ theorem isPreconnected_iff_subset_of_disjoint {s : Set α} : IsPreconnected s ↔ ∀ u v, IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v := by constructor <;> intro h · intro u v hu hv hs huv specialize h u v hu hv hs contrapose! huv simp [not_subset] at huv rcases huv with ⟨⟨x, hxs, hxu⟩, ⟨y, hys, hyv⟩⟩ have hxv : x ∈ v := or_iff_not_imp_left.mp (hs hxs) hxu have hyu : y ∈ u := or_iff_not_imp_right.mp (hs hys) hyv exact h ⟨y, hys, hyu⟩ ⟨x, hxs, hxv⟩ · intro u v hu hv hs hsu hsv by_contra H specialize h u v hu hv hs (Set.not_nonempty_iff_eq_empty.mp H) apply H cases' h with h h · rcases hsv with ⟨x, hxs, hxv⟩ exact ⟨x, hxs, ⟨h hxs, hxv⟩⟩ · rcases hsu with ⟨x, hxs, hxu⟩ exact ⟨x, hxs, ⟨hxu, h hxs⟩⟩ /-- A set `s` is connected if and only if for every cover by a finite collection of open sets that are pairwise disjoint on `s`, it is contained in one of the members of the collection. -/ theorem isConnected_iff_sUnion_disjoint_open {s : Set α} : IsConnected s ↔ ∀ U : Finset (Set α), (∀ u v : Set α, u ∈ U → v ∈ U → (s ∩ (u ∩ v)).Nonempty → u = v) → (∀ u ∈ U, IsOpen u) → (s ⊆ ⋃₀ ↑U) → ∃ u ∈ U, s ⊆ u := by rw [IsConnected, isPreconnected_iff_subset_of_disjoint] classical refine ⟨fun ⟨hne, h⟩ U hU hUo hsU => ?_, fun h => ⟨?_, fun u v hu hv hs hsuv => ?_⟩⟩ · induction U using Finset.induction_on with | empty => exact absurd (by simpa using hsU) hne.not_subset_empty | @insert u U uU IH => simp only [← forall_cond_comm, Finset.forall_mem_insert, Finset.exists_mem_insert, Finset.coe_insert, sUnion_insert, implies_true, true_and] at * refine (h _ hUo.1 (⋃₀ ↑U) (isOpen_sUnion hUo.2) hsU ?_).imp_right ?_ · refine subset_empty_iff.1 fun x ⟨hxs, hxu, v, hvU, hxv⟩ => ?_ exact ne_of_mem_of_not_mem hvU uU (hU.1 v hvU ⟨x, hxs, hxu, hxv⟩).symm · exact IH (fun u hu => (hU.2 u hu).2) hUo.2 · simpa [subset_empty_iff, nonempty_iff_ne_empty] using h ∅ · rw [← not_nonempty_iff_eq_empty] at hsuv have := hsuv; rw [inter_comm u] at this simpa [*, or_imp, forall_and] using h {u, v} -- Porting note: `IsPreconnected.subset_isClopen` moved up from here /-- Preconnected sets are either contained in or disjoint to any given clopen set. -/ theorem disjoint_or_subset_of_isClopen {s t : Set α} (hs : IsPreconnected s) (ht : IsClopen t) : Disjoint s t ∨ s ⊆ t := (disjoint_or_nonempty_inter s t).imp_right <| hs.subset_isClopen ht /-- A set `s` is preconnected if and only if for every cover by two closed sets that are disjoint on `s`, it is contained in one of the two covering sets. -/ theorem isPreconnected_iff_subset_of_disjoint_closed : IsPreconnected s ↔ ∀ u v, IsClosed u → IsClosed v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v := by constructor <;> intro h · intro u v hu hv hs huv rw [isPreconnected_closed_iff] at h specialize h u v hu hv hs contrapose! huv simp [not_subset] at huv rcases huv with ⟨⟨x, hxs, hxu⟩, ⟨y, hys, hyv⟩⟩ have hxv : x ∈ v := or_iff_not_imp_left.mp (hs hxs) hxu have hyu : y ∈ u := or_iff_not_imp_right.mp (hs hys) hyv exact h ⟨y, hys, hyu⟩ ⟨x, hxs, hxv⟩ · rw [isPreconnected_closed_iff] intro u v hu hv hs hsu hsv by_contra H specialize h u v hu hv hs (Set.not_nonempty_iff_eq_empty.mp H) apply H cases' h with h h · rcases hsv with ⟨x, hxs, hxv⟩ exact ⟨x, hxs, ⟨h hxs, hxv⟩⟩ · rcases hsu with ⟨x, hxs, hxu⟩ exact ⟨x, hxs, ⟨hxu, h hxs⟩⟩ /-- A closed set `s` is preconnected if and only if for every cover by two closed sets that are disjoint, it is contained in one of the two covering sets. -/ theorem isPreconnected_iff_subset_of_fully_disjoint_closed {s : Set α} (hs : IsClosed s) : IsPreconnected s ↔ ∀ u v, IsClosed u → IsClosed v → s ⊆ u ∪ v → Disjoint u v → s ⊆ u ∨ s ⊆ v := by refine isPreconnected_iff_subset_of_disjoint_closed.trans ⟨?_, ?_⟩ <;> intro H u v hu hv hss huv · apply H u v hu hv hss rw [huv.inter_eq, inter_empty] have H1 := H (u ∩ s) (v ∩ s) rw [subset_inter_iff, subset_inter_iff] at H1 simp only [Subset.refl, and_true] at H1 apply H1 (hu.inter hs) (hv.inter hs) · rw [← union_inter_distrib_right] exact subset_inter hss Subset.rfl · rwa [disjoint_iff_inter_eq_empty, ← inter_inter_distrib_right, inter_comm] theorem IsClopen.connectedComponent_subset {x} (hs : IsClopen s) (hx : x ∈ s) : connectedComponent x ⊆ s := isPreconnected_connectedComponent.subset_isClopen hs ⟨x, mem_connectedComponent, hx⟩ /-- The connected component of a point is always a subset of the intersection of all its clopen neighbourhoods. -/ theorem connectedComponent_subset_iInter_isClopen {x : α} : connectedComponent x ⊆ ⋂ Z : { Z : Set α // IsClopen Z ∧ x ∈ Z }, Z := subset_iInter fun Z => Z.2.1.connectedComponent_subset Z.2.2 /-- A clopen set is the union of its connected components. -/ theorem IsClopen.biUnion_connectedComponent_eq {Z : Set α} (h : IsClopen Z) : ⋃ x ∈ Z, connectedComponent x = Z := Subset.antisymm (iUnion₂_subset fun _ => h.connectedComponent_subset) fun _ h => mem_iUnion₂_of_mem h mem_connectedComponent open Set.Notation in /-- If `u v : Set X` and `u ⊆ v` is clopen in `v`, then `u` is the union of the connected components of `v` in `X` which intersect `u`. -/ lemma IsClopen.biUnion_connectedComponentIn {X : Type*} [TopologicalSpace X] {u v : Set X} (hu : IsClopen (v ↓∩ u)) (huv₁ : u ⊆ v) : u = ⋃ x ∈ u, connectedComponentIn v x := by have := congr(((↑) : Set v → Set X) $(hu.biUnion_connectedComponent_eq.symm)) simp only [Subtype.image_preimage_coe, mem_preimage, iUnion_coe_set, image_val_iUnion, inter_eq_right.mpr huv₁] at this nth_rw 1 [this] congr! 2 with x hx simp only [← connectedComponentIn_eq_image] exact le_antisymm (iUnion_subset fun _ ↦ le_rfl) <| iUnion_subset fun hx ↦ subset_iUnion₂_of_subset (huv₁ hx) hx le_rfl /-- The preimage of a connected component is preconnected if the function has connected fibers and a subset is closed iff the preimage is. -/ theorem preimage_connectedComponent_connected [TopologicalSpace β] {f : α → β} (connected_fibers : ∀ t : β, IsConnected (f ⁻¹' {t})) (hcl : ∀ T : Set β, IsClosed T ↔ IsClosed (f ⁻¹' T)) (t : β) : IsConnected (f ⁻¹' connectedComponent t) := by -- The following proof is essentially https://stacks.math.columbia.edu/tag/0377 -- although the statement is slightly different have hf : Surjective f := Surjective.of_comp fun t : β => (connected_fibers t).1 refine ⟨Nonempty.preimage connectedComponent_nonempty hf, ?_⟩ have hT : IsClosed (f ⁻¹' connectedComponent t) := (hcl (connectedComponent t)).1 isClosed_connectedComponent -- To show it's preconnected we decompose (f ⁻¹' connectedComponent t) as a subset of two -- closed disjoint sets in α. We want to show that it's a subset of either. rw [isPreconnected_iff_subset_of_fully_disjoint_closed hT] intro u v hu hv huv uv_disj -- To do this we decompose connectedComponent t into T₁ and T₂ -- we will show that connectedComponent t is a subset of either and hence -- (f ⁻¹' connectedComponent t) is a subset of u or v let T₁ := { t' ∈ connectedComponent t | f ⁻¹' {t'} ⊆ u } let T₂ := { t' ∈ connectedComponent t | f ⁻¹' {t'} ⊆ v } have fiber_decomp : ∀ t' ∈ connectedComponent t, f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v := by intro t' ht' apply isPreconnected_iff_subset_of_disjoint_closed.1 (connected_fibers t').2 u v hu hv · exact Subset.trans (preimage_mono (singleton_subset_iff.2 ht')) huv rw [uv_disj.inter_eq, inter_empty] have T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u := by apply eq_of_subset_of_subset · rw [← biUnion_preimage_singleton] refine iUnion₂_subset fun t' ht' => subset_inter ?_ ht'.2 rw [hf.preimage_subset_preimage_iff, singleton_subset_iff] exact ht'.1 rintro a ⟨hat, hau⟩ constructor · exact mem_preimage.1 hat refine (fiber_decomp (f a) (mem_preimage.1 hat)).resolve_right fun h => ?_ exact uv_disj.subset_compl_right hau (h rfl) -- This proof is exactly the same as the above (modulo some symmetry) have T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v := by apply eq_of_subset_of_subset · rw [← biUnion_preimage_singleton] refine iUnion₂_subset fun t' ht' => subset_inter ?_ ht'.2 rw [hf.preimage_subset_preimage_iff, singleton_subset_iff] exact ht'.1 rintro a ⟨hat, hav⟩ constructor · exact mem_preimage.1 hat · refine (fiber_decomp (f a) (mem_preimage.1 hat)).resolve_left fun h => ?_ exact uv_disj.subset_compl_left hav (h rfl) -- Now we show T₁, T₂ are closed, cover connectedComponent t and are disjoint. have hT₁ : IsClosed T₁ := (hcl T₁).2 (T₁_u.symm ▸ IsClosed.inter hT hu) have hT₂ : IsClosed T₂ := (hcl T₂).2 (T₂_v.symm ▸ IsClosed.inter hT hv) have T_decomp : connectedComponent t ⊆ T₁ ∪ T₂ := fun t' ht' => by rw [mem_union t' T₁ T₂] cases' fiber_decomp t' ht' with htu htv · left exact ⟨ht', htu⟩ right exact ⟨ht', htv⟩ have T_disjoint : Disjoint T₁ T₂ := by refine Disjoint.of_preimage hf ?_ rw [T₁_u, T₂_v, disjoint_iff_inter_eq_empty, ← inter_inter_distrib_left, uv_disj.inter_eq, inter_empty] -- Now we do cases on whether (connectedComponent t) is a subset of T₁ or T₂ to show -- that the preimage is a subset of u or v. cases' (isPreconnected_iff_subset_of_fully_disjoint_closed isClosed_connectedComponent).1 isPreconnected_connectedComponent T₁ T₂ hT₁ hT₂ T_decomp T_disjoint with h h · left rw [Subset.antisymm_iff] at T₁_u suffices f ⁻¹' connectedComponent t ⊆ f ⁻¹' T₁ from (this.trans T₁_u.1).trans inter_subset_right exact preimage_mono h · right rw [Subset.antisymm_iff] at T₂_v suffices f ⁻¹' connectedComponent t ⊆ f ⁻¹' T₂ from (this.trans T₂_v.1).trans inter_subset_right exact preimage_mono h theorem QuotientMap.preimage_connectedComponent [TopologicalSpace β] {f : α → β} (hf : QuotientMap f) (h_fibers : ∀ y : β, IsConnected (f ⁻¹' {y})) (a : α) : f ⁻¹' connectedComponent (f a) = connectedComponent a := ((preimage_connectedComponent_connected h_fibers (fun _ => hf.isClosed_preimage.symm) _).subset_connectedComponent mem_connectedComponent).antisymm (hf.continuous.mapsTo_connectedComponent a) theorem QuotientMap.image_connectedComponent [TopologicalSpace β] {f : α → β} (hf : QuotientMap f) (h_fibers : ∀ y : β, IsConnected (f ⁻¹' {y})) (a : α) : f '' connectedComponent a = connectedComponent (f a) := by rw [← hf.preimage_connectedComponent h_fibers, image_preimage_eq _ hf.surjective] end Preconnected section connectedComponentSetoid /-- The setoid of connected components of a topological space -/ def connectedComponentSetoid (α : Type*) [TopologicalSpace α] : Setoid α := ⟨fun x y => connectedComponent x = connectedComponent y, ⟨fun x => by trivial, fun h1 => h1.symm, fun h1 h2 => h1.trans h2⟩⟩ /-- The quotient of a space by its connected components -/ def ConnectedComponents (α : Type u) [TopologicalSpace α] := Quotient (connectedComponentSetoid α) namespace ConnectedComponents /-- Coercion from a topological space to the set of connected components of this space. -/ def mk : α → ConnectedComponents α := Quotient.mk'' instance : CoeTC α (ConnectedComponents α) := ⟨mk⟩ @[simp] theorem coe_eq_coe {x y : α} : (x : ConnectedComponents α) = y ↔ connectedComponent x = connectedComponent y := Quotient.eq'' theorem coe_ne_coe {x y : α} : (x : ConnectedComponents α) ≠ y ↔ connectedComponent x ≠ connectedComponent y := coe_eq_coe.not theorem coe_eq_coe' {x y : α} : (x : ConnectedComponents α) = y ↔ x ∈ connectedComponent y := coe_eq_coe.trans connectedComponent_eq_iff_mem instance [Inhabited α] : Inhabited (ConnectedComponents α) := ⟨mk default⟩ instance : TopologicalSpace (ConnectedComponents α) := inferInstanceAs (TopologicalSpace (Quotient _)) theorem surjective_coe : Surjective (mk : α → ConnectedComponents α) := surjective_quot_mk _ theorem quotientMap_coe : QuotientMap (mk : α → ConnectedComponents α) := quotientMap_quot_mk @[continuity] theorem continuous_coe : Continuous (mk : α → ConnectedComponents α) := quotientMap_coe.continuous @[simp] theorem range_coe : range (mk : α → ConnectedComponents α) = univ := surjective_coe.range_eq end ConnectedComponents /-- The preimage of a singleton in `connectedComponents` is the connected component of an element in the equivalence class. -/ theorem connectedComponents_preimage_singleton {x : α} : (↑) ⁻¹' ({↑x} : Set (ConnectedComponents α)) = connectedComponent x := by ext y rw [mem_preimage, mem_singleton_iff, ConnectedComponents.coe_eq_coe'] /-- The preimage of the image of a set under the quotient map to `connectedComponents α` is the union of the connected components of the elements in it. -/ theorem connectedComponents_preimage_image (U : Set α) : (↑) ⁻¹' ((↑) '' U : Set (ConnectedComponents α)) = ⋃ x ∈ U, connectedComponent x := by simp only [connectedComponents_preimage_singleton, preimage_iUnion₂, image_eq_iUnion] end connectedComponentSetoid /-- If every map to `Bool` (a discrete two-element space), that is continuous on a set `s`, is constant on s, then s is preconnected -/ theorem isPreconnected_of_forall_constant {s : Set α} (hs : ∀ f : α → Bool, ContinuousOn f s → ∀ x ∈ s, ∀ y ∈ s, f x = f y) : IsPreconnected s := by unfold IsPreconnected by_contra! rcases this with ⟨u, v, u_op, v_op, hsuv, ⟨x, x_in_s, x_in_u⟩, ⟨y, y_in_s, y_in_v⟩, H⟩ have hy : y ∉ u := fun y_in_u => eq_empty_iff_forall_not_mem.mp H y ⟨y_in_s, ⟨y_in_u, y_in_v⟩⟩ have : ContinuousOn u.boolIndicator s := by apply (continuousOn_boolIndicator_iff_isClopen _ _).mpr ⟨_, _⟩ · rw [preimage_subtype_coe_eq_compl hsuv H] exact (v_op.preimage continuous_subtype_val).isClosed_compl · exact u_op.preimage continuous_subtype_val simpa [(u.mem_iff_boolIndicator _).mp x_in_u, (u.not_mem_iff_boolIndicator _).mp hy] using hs _ this x x_in_s y y_in_s /-- A `PreconnectedSpace` version of `isPreconnected_of_forall_constant` -/ theorem preconnectedSpace_of_forall_constant (hs : ∀ f : α → Bool, Continuous f → ∀ x y, f x = f y) : PreconnectedSpace α := ⟨isPreconnected_of_forall_constant fun f hf x _ y _ => hs f (continuous_iff_continuousOn_univ.mpr hf) x y⟩
Topology\Connected\LocallyConnected.lean
/- Copyright (c) 2022 Anatole Dedecker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anatole Dedecker -/ import Mathlib.Topology.Connected.Basic /-! # Locally connected topological spaces A topological space is **locally connected** if each neighborhood filter admits a basis of connected *open* sets. Local connectivity is equivalent to each point having a basis of connected (not necessarily open) sets --- but in a non-trivial way, so we choose this definition and prove the equivalence later in `locallyConnectedSpace_iff_connected_basis`. -/ open Set Topology universe u v variable {α : Type u} {β : Type v} {ι : Type*} {π : ι → Type*} [TopologicalSpace α] {s t u v : Set α} section LocallyConnectedSpace /-- A topological space is **locally connected** if each neighborhood filter admits a basis of connected *open* sets. Note that it is equivalent to each point having a basis of connected (non necessarily open) sets but in a non-trivial way, so we choose this definition and prove the equivalence later in `locallyConnectedSpace_iff_connected_basis`. -/ class LocallyConnectedSpace (α : Type*) [TopologicalSpace α] : Prop where /-- Open connected neighborhoods form a basis of the neighborhoods filter. -/ open_connected_basis : ∀ x, (𝓝 x).HasBasis (fun s : Set α => IsOpen s ∧ x ∈ s ∧ IsConnected s) id theorem locallyConnectedSpace_iff_open_connected_basis : LocallyConnectedSpace α ↔ ∀ x, (𝓝 x).HasBasis (fun s : Set α => IsOpen s ∧ x ∈ s ∧ IsConnected s) id := ⟨@LocallyConnectedSpace.open_connected_basis _ _, LocallyConnectedSpace.mk⟩ theorem locallyConnectedSpace_iff_open_connected_subsets : LocallyConnectedSpace α ↔ ∀ x, ∀ U ∈ 𝓝 x, ∃ V : Set α, V ⊆ U ∧ IsOpen V ∧ x ∈ V ∧ IsConnected V := by simp_rw [locallyConnectedSpace_iff_open_connected_basis] refine forall_congr' fun _ => ?_ constructor · intro h U hU rcases h.mem_iff.mp hU with ⟨V, hV, hVU⟩ exact ⟨V, hVU, hV⟩ · exact fun h => ⟨fun U => ⟨fun hU => let ⟨V, hVU, hV⟩ := h U hU ⟨V, hV, hVU⟩, fun ⟨V, ⟨hV, hxV, _⟩, hVU⟩ => mem_nhds_iff.mpr ⟨V, hVU, hV, hxV⟩⟩⟩ /-- A space with discrete topology is a locally connected space. -/ instance (priority := 100) DiscreteTopology.toLocallyConnectedSpace (α) [TopologicalSpace α] [DiscreteTopology α] : LocallyConnectedSpace α := locallyConnectedSpace_iff_open_connected_subsets.2 fun x _U hU => ⟨{x}, singleton_subset_iff.2 <| mem_of_mem_nhds hU, isOpen_discrete _, rfl, isConnected_singleton⟩ theorem connectedComponentIn_mem_nhds [LocallyConnectedSpace α] {F : Set α} {x : α} (h : F ∈ 𝓝 x) : connectedComponentIn F x ∈ 𝓝 x := by rw [(LocallyConnectedSpace.open_connected_basis x).mem_iff] at h rcases h with ⟨s, ⟨h1s, hxs, h2s⟩, hsF⟩ exact mem_nhds_iff.mpr ⟨s, h2s.isPreconnected.subset_connectedComponentIn hxs hsF, h1s, hxs⟩ protected theorem IsOpen.connectedComponentIn [LocallyConnectedSpace α] {F : Set α} {x : α} (hF : IsOpen F) : IsOpen (connectedComponentIn F x) := by rw [isOpen_iff_mem_nhds] intro y hy rw [connectedComponentIn_eq hy] exact connectedComponentIn_mem_nhds (hF.mem_nhds <| connectedComponentIn_subset F x hy) theorem isOpen_connectedComponent [LocallyConnectedSpace α] {x : α} : IsOpen (connectedComponent x) := by rw [← connectedComponentIn_univ] exact isOpen_univ.connectedComponentIn theorem isClopen_connectedComponent [LocallyConnectedSpace α] {x : α} : IsClopen (connectedComponent x) := ⟨isClosed_connectedComponent, isOpen_connectedComponent⟩ theorem locallyConnectedSpace_iff_connectedComponentIn_open : LocallyConnectedSpace α ↔ ∀ F : Set α, IsOpen F → ∀ x ∈ F, IsOpen (connectedComponentIn F x) := by constructor · intro h exact fun F hF x _ => hF.connectedComponentIn · intro h rw [locallyConnectedSpace_iff_open_connected_subsets] refine fun x U hU => ⟨connectedComponentIn (interior U) x, (connectedComponentIn_subset _ _).trans interior_subset, h _ isOpen_interior x ?_, mem_connectedComponentIn ?_, isConnected_connectedComponentIn_iff.mpr ?_⟩ <;> exact mem_interior_iff_mem_nhds.mpr hU theorem locallyConnectedSpace_iff_connected_subsets : LocallyConnectedSpace α ↔ ∀ (x : α), ∀ U ∈ 𝓝 x, ∃ V ∈ 𝓝 x, IsPreconnected V ∧ V ⊆ U := by constructor · rw [locallyConnectedSpace_iff_open_connected_subsets] intro h x U hxU rcases h x U hxU with ⟨V, hVU, hV₁, hxV, hV₂⟩ exact ⟨V, hV₁.mem_nhds hxV, hV₂.isPreconnected, hVU⟩ · rw [locallyConnectedSpace_iff_connectedComponentIn_open] refine fun h U hU x _ => isOpen_iff_mem_nhds.mpr fun y hy => ?_ rw [connectedComponentIn_eq hy] rcases h y U (hU.mem_nhds <| (connectedComponentIn_subset _ _) hy) with ⟨V, hVy, hV, hVU⟩ exact Filter.mem_of_superset hVy (hV.subset_connectedComponentIn (mem_of_mem_nhds hVy) hVU) theorem locallyConnectedSpace_iff_connected_basis : LocallyConnectedSpace α ↔ ∀ x, (𝓝 x).HasBasis (fun s : Set α => s ∈ 𝓝 x ∧ IsPreconnected s) id := by rw [locallyConnectedSpace_iff_connected_subsets] exact forall_congr' fun x => Filter.hasBasis_self.symm theorem locallyConnectedSpace_of_connected_bases {ι : Type*} (b : α → ι → Set α) (p : α → ι → Prop) (hbasis : ∀ x, (𝓝 x).HasBasis (p x) (b x)) (hconnected : ∀ x i, p x i → IsPreconnected (b x i)) : LocallyConnectedSpace α := by rw [locallyConnectedSpace_iff_connected_basis] exact fun x => (hbasis x).to_hasBasis (fun i hi => ⟨b x i, ⟨(hbasis x).mem_of_mem hi, hconnected x i hi⟩, subset_rfl⟩) fun s hs => ⟨(hbasis x).index s hs.1, ⟨(hbasis x).property_index hs.1, (hbasis x).set_index_subset hs.1⟩⟩ theorem OpenEmbedding.locallyConnectedSpace [LocallyConnectedSpace α] [TopologicalSpace β] {f : β → α} (h : OpenEmbedding f) : LocallyConnectedSpace β := by refine locallyConnectedSpace_of_connected_bases (fun _ s ↦ f ⁻¹' s) (fun x s ↦ (IsOpen s ∧ f x ∈ s ∧ IsConnected s) ∧ s ⊆ range f) (fun x ↦ ?_) (fun x s hxs ↦ hxs.1.2.2.isPreconnected.preimage_of_isOpenMap h.inj h.isOpenMap hxs.2) rw [h.nhds_eq_comap] exact LocallyConnectedSpace.open_connected_basis (f x) |>.restrict_subset (h.isOpen_range.mem_nhds <| mem_range_self _) |>.comap _ theorem IsOpen.locallyConnectedSpace [LocallyConnectedSpace α] {U : Set α} (hU : IsOpen U) : LocallyConnectedSpace U := hU.openEmbedding_subtype_val.locallyConnectedSpace end LocallyConnectedSpace
Topology\Connected\PathConnected.lean
/- Copyright (c) 2020 Patrick Massot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot -/ import Mathlib.Topology.Order.ProjIcc import Mathlib.Topology.CompactOpen import Mathlib.Topology.UnitInterval /-! # Path connectedness ## Main definitions In the file the unit interval `[0, 1]` in `ℝ` is denoted by `I`, and `X` is a topological space. * `Path (x y : X)` is the type of paths from `x` to `y`, i.e., continuous maps from `I` to `X` mapping `0` to `x` and `1` to `y`. * `Path.map` is the image of a path under a continuous map. * `Joined (x y : X)` means there is a path between `x` and `y`. * `Joined.somePath (h : Joined x y)` selects some path between two points `x` and `y`. * `pathComponent (x : X)` is the set of points joined to `x`. * `PathConnectedSpace X` is a predicate class asserting that `X` is non-empty and every two points of `X` are joined. Then there are corresponding relative notions for `F : Set X`. * `JoinedIn F (x y : X)` means there is a path `γ` joining `x` to `y` with values in `F`. * `JoinedIn.somePath (h : JoinedIn F x y)` selects a path from `x` to `y` inside `F`. * `pathComponentIn F (x : X)` is the set of points joined to `x` in `F`. * `IsPathConnected F` asserts that `F` is non-empty and every two points of `F` are joined in `F`. * `LocPathConnectedSpace X` is a predicate class asserting that `X` is locally path-connected: each point has a basis of path-connected neighborhoods (we do *not* ask these to be open). ## Main theorems * `Joined` and `JoinedIn F` are transitive relations. One can link the absolute and relative version in two directions, using `(univ : Set X)` or the subtype `↥F`. * `pathConnectedSpace_iff_univ : PathConnectedSpace X ↔ IsPathConnected (univ : Set X)` * `isPathConnected_iff_pathConnectedSpace : IsPathConnected F ↔ PathConnectedSpace ↥F` For locally path connected spaces, we have * `pathConnectedSpace_iff_connectedSpace : PathConnectedSpace X ↔ ConnectedSpace X` * `IsOpen.isConnected_iff_isPathConnected (U_op : IsOpen U) : IsPathConnected U ↔ IsConnected U` ## Implementation notes By default, all paths have `I` as their source and `X` as their target, but there is an operation `Set.IccExtend` that will extend any continuous map `γ : I → X` into a continuous map `IccExtend zero_le_one γ : ℝ → X` that is constant before `0` and after `1`. This is used to define `Path.extend` that turns `γ : Path x y` into a continuous map `γ.extend : ℝ → X` whose restriction to `I` is the original `γ`, and is equal to `x` on `(-∞, 0]` and to `y` on `[1, +∞)`. -/ noncomputable section open scoped Classical open Topology Filter unitInterval Set Function variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] {x y z : X} {ι : Type*} /-! ### Paths -/ /-- Continuous path connecting two points `x` and `y` in a topological space -/ -- porting note (#5171): removed @[nolint has_nonempty_instance] structure Path (x y : X) extends C(I, X) where /-- The start point of a `Path`. -/ source' : toFun 0 = x /-- The end point of a `Path`. -/ target' : toFun 1 = y instance Path.funLike : FunLike (Path x y) I X where coe := fun γ ↦ ⇑γ.toContinuousMap coe_injective' := fun γ₁ γ₂ h => by simp only [DFunLike.coe_fn_eq] at h cases γ₁; cases γ₂; congr -- Porting note (#10754): added this instance so that we can use `FunLike.coe` for `CoeFun` -- this also fixed very strange `simp` timeout issues instance Path.continuousMapClass : ContinuousMapClass (Path x y) I X where map_continuous γ := show Continuous γ.toContinuousMap by fun_prop -- Porting note: not necessary in light of the instance above /- instance : CoeFun (Path x y) fun _ => I → X := ⟨fun p => p.toFun⟩ -/ @[ext] protected theorem Path.ext : ∀ {γ₁ γ₂ : Path x y}, (γ₁ : I → X) = γ₂ → γ₁ = γ₂ := by rintro ⟨⟨x, h11⟩, h12, h13⟩ ⟨⟨x, h21⟩, h22, h23⟩ rfl rfl namespace Path @[simp] theorem coe_mk_mk (f : I → X) (h₁) (h₂ : f 0 = x) (h₃ : f 1 = y) : ⇑(mk ⟨f, h₁⟩ h₂ h₃ : Path x y) = f := rfl -- Porting note: the name `Path.coe_mk` better refers to a new lemma below variable (γ : Path x y) @[continuity] protected theorem continuous : Continuous γ := γ.continuous_toFun @[simp] protected theorem source : γ 0 = x := γ.source' @[simp] protected theorem target : γ 1 = y := γ.target' /-- 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 : I → X := γ initialize_simps_projections Path (toFun → simps.apply, -toContinuousMap) @[simp] theorem coe_toContinuousMap : ⇑γ.toContinuousMap = γ := rfl -- Porting note: this is needed because of the `Path.continuousMapClass` instance @[simp] theorem coe_mk : ⇑(γ : C(I, X)) = γ := rfl /-- Any function `φ : Π (a : α), Path (x a) (y a)` can be seen as a function `α × I → X`. -/ instance hasUncurryPath {X α : Type*} [TopologicalSpace X] {x y : α → X} : HasUncurry (∀ a : α, Path (x a) (y a)) (α × I) X := ⟨fun φ p => φ p.1 p.2⟩ /-- The constant path from a point to itself -/ @[refl, simps] def refl (x : X) : Path x x where toFun _t := x continuous_toFun := continuous_const source' := rfl target' := rfl @[simp] theorem refl_range {a : X} : range (Path.refl a) = {a} := by simp [Path.refl, CoeFun.coe] /-- The reverse of a path from `x` to `y`, as a path from `y` to `x` -/ @[symm, simps] def symm (γ : Path x y) : Path y x where toFun := γ ∘ σ continuous_toFun := by continuity source' := by simpa [-Path.target] using γ.target target' := by simpa [-Path.source] using γ.source @[simp] theorem symm_symm (γ : Path x y) : γ.symm.symm = γ := by ext t show γ (σ (σ t)) = γ t rw [unitInterval.symm_symm] theorem symm_bijective : Function.Bijective (Path.symm : Path x y → Path y x) := Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩ @[simp] theorem refl_symm {a : X} : (Path.refl a).symm = Path.refl a := by ext rfl @[simp] theorem symm_range {a b : X} (γ : Path a b) : range γ.symm = range γ := by ext x simp only [mem_range, Path.symm, DFunLike.coe, unitInterval.symm, SetCoe.exists, comp_apply, Subtype.coe_mk] constructor <;> rintro ⟨y, hy, hxy⟩ <;> refine ⟨1 - y, mem_iff_one_sub_mem.mp hy, ?_⟩ <;> convert hxy simp /-! #### Space of paths -/ open ContinuousMap /- porting note: because of the `DFunLike` instance, we already have a coercion to `C(I, X)` so we avoid adding another. --instance : Coe (Path x y) C(I, X) := --⟨fun γ => γ.1⟩ -/ /-- The following instance defines the topology on the path space to be induced from the compact-open topology on the space `C(I,X)` of continuous maps from `I` to `X`. -/ instance topologicalSpace : TopologicalSpace (Path x y) := TopologicalSpace.induced ((↑) : _ → C(I, X)) ContinuousMap.compactOpen theorem continuous_eval : Continuous fun p : Path x y × I => p.1 p.2 := ContinuousMap.continuous_eval.comp <| (continuous_induced_dom (α := Path x y)).prod_map continuous_id @[continuity] theorem _root_.Continuous.path_eval {Y} [TopologicalSpace Y] {f : Y → Path x y} {g : Y → I} (hf : Continuous f) (hg : Continuous g) : Continuous fun y => f y (g y) := Continuous.comp continuous_eval (hf.prod_mk hg) theorem continuous_uncurry_iff {Y} [TopologicalSpace Y] {g : Y → Path x y} : Continuous ↿g ↔ Continuous g := Iff.symm <| continuous_induced_rng.trans ⟨fun h => continuous_uncurry_of_continuous ⟨_, h⟩, continuous_of_continuous_uncurry (fun (y : Y) ↦ ContinuousMap.mk (g y))⟩ /-- A continuous map extending a path to `ℝ`, constant before `0` and after `1`. -/ def extend : ℝ → X := IccExtend zero_le_one γ /-- See Note [continuity lemma statement]. -/ theorem _root_.Continuous.path_extend {γ : Y → Path x y} {f : Y → ℝ} (hγ : Continuous ↿γ) (hf : Continuous f) : Continuous fun t => (γ t).extend (f t) := Continuous.IccExtend hγ hf /-- A useful special case of `Continuous.path_extend`. -/ @[continuity, fun_prop] theorem continuous_extend : Continuous γ.extend := γ.continuous.Icc_extend' theorem _root_.Filter.Tendsto.path_extend {l r : Y → X} {y : Y} {l₁ : Filter ℝ} {l₂ : Filter X} {γ : ∀ y, Path (l y) (r y)} (hγ : Tendsto (↿γ) (𝓝 y ×ˢ l₁.map (projIcc 0 1 zero_le_one)) l₂) : Tendsto (↿fun x => (γ x).extend) (𝓝 y ×ˢ l₁) l₂ := Filter.Tendsto.IccExtend _ hγ theorem _root_.ContinuousAt.path_extend {g : Y → ℝ} {l r : Y → X} (γ : ∀ y, Path (l y) (r y)) {y : Y} (hγ : ContinuousAt (↿γ) (y, projIcc 0 1 zero_le_one (g y))) (hg : ContinuousAt g y) : ContinuousAt (fun i => (γ i).extend (g i)) y := hγ.IccExtend (fun x => γ x) hg @[simp] theorem extend_extends {a b : X} (γ : Path a b) {t : ℝ} (ht : t ∈ (Icc 0 1 : Set ℝ)) : γ.extend t = γ ⟨t, ht⟩ := IccExtend_of_mem _ γ ht theorem extend_zero : γ.extend 0 = x := by simp theorem extend_one : γ.extend 1 = y := by simp @[simp] theorem extend_extends' {a b : X} (γ : Path a b) (t : (Icc 0 1 : Set ℝ)) : γ.extend t = γ t := IccExtend_val _ γ t @[simp] theorem extend_range {a b : X} (γ : Path a b) : range γ.extend = range γ := IccExtend_range _ γ theorem extend_of_le_zero {a b : X} (γ : Path a b) {t : ℝ} (ht : t ≤ 0) : γ.extend t = a := (IccExtend_of_le_left _ _ ht).trans γ.source theorem extend_of_one_le {a b : X} (γ : Path a b) {t : ℝ} (ht : 1 ≤ t) : γ.extend t = b := (IccExtend_of_right_le _ _ ht).trans γ.target @[simp] theorem refl_extend {a : X} : (Path.refl a).extend = fun _ => a := rfl /-- The path obtained from a map defined on `ℝ` by restriction to the unit interval. -/ def ofLine {f : ℝ → X} (hf : ContinuousOn f I) (h₀ : f 0 = x) (h₁ : f 1 = y) : Path x y where toFun := f ∘ ((↑) : unitInterval → ℝ) continuous_toFun := hf.comp_continuous continuous_subtype_val Subtype.prop source' := h₀ target' := h₁ theorem ofLine_mem {f : ℝ → X} (hf : ContinuousOn f I) (h₀ : f 0 = x) (h₁ : f 1 = y) : ∀ t, ofLine hf h₀ h₁ t ∈ f '' I := fun ⟨t, t_in⟩ => ⟨t, t_in, rfl⟩ attribute [local simp] Iic_def /-- Concatenation of two paths from `x` to `y` and from `y` to `z`, putting the first path on `[0, 1/2]` and the second one on `[1/2, 1]`. -/ @[trans] def trans (γ : Path x y) (γ' : Path y z) : Path x z where toFun := (fun t : ℝ => if t ≤ 1 / 2 then γ.extend (2 * t) else γ'.extend (2 * t - 1)) ∘ (↑) continuous_toFun := by refine (Continuous.if_le ?_ ?_ continuous_id continuous_const (by norm_num)).comp continuous_subtype_val <;> fun_prop source' := by norm_num target' := by norm_num theorem trans_apply (γ : Path x y) (γ' : Path y z) (t : I) : (γ.trans γ') t = if h : (t : ℝ) ≤ 1 / 2 then γ ⟨2 * t, (mul_pos_mem_iff zero_lt_two).2 ⟨t.2.1, h⟩⟩ else γ' ⟨2 * t - 1, two_mul_sub_one_mem_iff.2 ⟨(not_le.1 h).le, t.2.2⟩⟩ := show ite _ _ _ = _ by split_ifs <;> rw [extend_extends] @[simp] theorem trans_symm (γ : Path x y) (γ' : Path y z) : (γ.trans γ').symm = γ'.symm.trans γ.symm := by ext t simp only [trans_apply, ← one_div, symm_apply, not_le, Function.comp_apply] split_ifs with h h₁ h₂ <;> rw [coe_symm_eq] at h · have ht : (t : ℝ) = 1 / 2 := by linarith norm_num [ht] · refine congr_arg _ (Subtype.ext ?_) norm_num [sub_sub_eq_add_sub, mul_sub] · refine congr_arg _ (Subtype.ext ?_) norm_num [mul_sub, h] ring -- TODO norm_num should really do this · exfalso linarith @[simp] theorem refl_trans_refl {a : X} : (Path.refl a).trans (Path.refl a) = Path.refl a := by ext simp only [Path.trans, ite_self, one_div, Path.refl_extend] rfl theorem trans_range {a b c : X} (γ₁ : Path a b) (γ₂ : Path b c) : range (γ₁.trans γ₂) = range γ₁ ∪ range γ₂ := by rw [Path.trans] apply eq_of_subset_of_subset · rintro x ⟨⟨t, ht0, ht1⟩, hxt⟩ by_cases h : t ≤ 1 / 2 · left use ⟨2 * t, ⟨by linarith, by linarith⟩⟩ rw [← γ₁.extend_extends] rwa [coe_mk_mk, Function.comp_apply, if_pos h] at hxt · right use ⟨2 * t - 1, ⟨by linarith, by linarith⟩⟩ rw [← γ₂.extend_extends] rwa [coe_mk_mk, Function.comp_apply, if_neg h] at hxt · rintro x (⟨⟨t, ht0, ht1⟩, hxt⟩ | ⟨⟨t, ht0, ht1⟩, hxt⟩) · use ⟨t / 2, ⟨by linarith, by linarith⟩⟩ have : t / 2 ≤ 1 / 2 := (div_le_div_right (zero_lt_two : (0 : ℝ) < 2)).mpr ht1 rw [coe_mk_mk, Function.comp_apply, if_pos this, Subtype.coe_mk] ring_nf rwa [γ₁.extend_extends] · by_cases h : t = 0 · use ⟨1 / 2, ⟨by linarith, by linarith⟩⟩ rw [coe_mk_mk, Function.comp_apply, if_pos le_rfl, Subtype.coe_mk, mul_one_div_cancel (two_ne_zero' ℝ)] rw [γ₁.extend_one] rwa [← γ₂.extend_extends, h, γ₂.extend_zero] at hxt · use ⟨(t + 1) / 2, ⟨by linarith, by linarith⟩⟩ replace h : t ≠ 0 := h have ht0 := lt_of_le_of_ne ht0 h.symm have : ¬(t + 1) / 2 ≤ 1 / 2 := by rw [not_le] linarith rw [coe_mk_mk, Function.comp_apply, Subtype.coe_mk, if_neg this] ring_nf rwa [γ₂.extend_extends] /-- Image of a path from `x` to `y` by a map which is continuous on the path. -/ def map' (γ : Path x y) {f : X → Y} (h : ContinuousOn f (range γ)) : Path (f x) (f y) where toFun := f ∘ γ continuous_toFun := h.comp_continuous γ.continuous (fun x ↦ mem_range_self x) source' := by simp target' := by simp /-- Image of a path from `x` to `y` by a continuous map -/ def map (γ : Path x y) {f : X → Y} (h : Continuous f) : Path (f x) (f y) := γ.map' h.continuousOn @[simp] theorem map_coe (γ : Path x y) {f : X → Y} (h : Continuous f) : (γ.map h : I → Y) = f ∘ γ := by ext t rfl @[simp] theorem map_symm (γ : Path x y) {f : X → Y} (h : Continuous f) : (γ.map h).symm = γ.symm.map h := rfl @[simp] theorem map_trans (γ : Path x y) (γ' : Path y z) {f : X → Y} (h : Continuous f) : (γ.trans γ').map h = (γ.map h).trans (γ'.map h) := by ext t rw [trans_apply, map_coe, Function.comp_apply, trans_apply] split_ifs <;> rfl @[simp] theorem map_id (γ : Path x y) : γ.map continuous_id = γ := by ext rfl @[simp] theorem map_map (γ : Path x y) {Z : Type*} [TopologicalSpace Z] {f : X → Y} (hf : Continuous f) {g : Y → Z} (hg : Continuous g) : (γ.map hf).map hg = γ.map (hg.comp hf) := by ext rfl /-- Casting a path from `x` to `y` to a path from `x'` to `y'` when `x' = x` and `y' = y` -/ def cast (γ : Path x y) {x' y'} (hx : x' = x) (hy : y' = y) : Path x' y' where toFun := γ continuous_toFun := γ.continuous source' := by simp [hx] target' := by simp [hy] @[simp] theorem symm_cast {a₁ a₂ b₁ b₂ : X} (γ : Path a₂ b₂) (ha : a₁ = a₂) (hb : b₁ = b₂) : (γ.cast ha hb).symm = γ.symm.cast hb ha := rfl @[simp] theorem trans_cast {a₁ a₂ b₁ b₂ c₁ c₂ : X} (γ : Path a₂ b₂) (γ' : Path b₂ c₂) (ha : a₁ = a₂) (hb : b₁ = b₂) (hc : c₁ = c₂) : (γ.cast ha hb).trans (γ'.cast hb hc) = (γ.trans γ').cast ha hc := rfl @[simp] theorem cast_coe (γ : Path x y) {x' y'} (hx : x' = x) (hy : y' = y) : (γ.cast hx hy : I → X) = γ := rfl @[continuity, fun_prop] theorem symm_continuous_family {ι : Type*} [TopologicalSpace ι] {a b : ι → X} (γ : ∀ t : ι, Path (a t) (b t)) (h : Continuous ↿γ) : Continuous ↿fun t => (γ t).symm := h.comp (continuous_id.prod_map continuous_symm) @[continuity] theorem continuous_symm : Continuous (symm : Path x y → Path y x) := continuous_uncurry_iff.mp <| symm_continuous_family _ (continuous_fst.path_eval continuous_snd) @[continuity] theorem continuous_uncurry_extend_of_continuous_family {ι : Type*} [TopologicalSpace ι] {a b : ι → X} (γ : ∀ t : ι, Path (a t) (b t)) (h : Continuous ↿γ) : Continuous ↿fun t => (γ t).extend := by apply h.comp (continuous_id.prod_map continuous_projIcc) exact zero_le_one @[continuity] theorem trans_continuous_family {ι : Type*} [TopologicalSpace ι] {a b c : ι → X} (γ₁ : ∀ t : ι, Path (a t) (b t)) (h₁ : Continuous ↿γ₁) (γ₂ : ∀ t : ι, Path (b t) (c t)) (h₂ : Continuous ↿γ₂) : Continuous ↿fun t => (γ₁ t).trans (γ₂ t) := by have h₁' := Path.continuous_uncurry_extend_of_continuous_family γ₁ h₁ have h₂' := Path.continuous_uncurry_extend_of_continuous_family γ₂ h₂ simp only [HasUncurry.uncurry, CoeFun.coe, Path.trans, (· ∘ ·)] refine Continuous.if_le ?_ ?_ (continuous_subtype_val.comp continuous_snd) continuous_const ?_ · change Continuous ((fun p : ι × ℝ => (γ₁ p.1).extend p.2) ∘ Prod.map id (fun x => 2 * x : I → ℝ)) exact h₁'.comp (continuous_id.prod_map <| continuous_const.mul continuous_subtype_val) · change Continuous ((fun p : ι × ℝ => (γ₂ p.1).extend p.2) ∘ Prod.map id (fun x => 2 * x - 1 : I → ℝ)) exact h₂'.comp (continuous_id.prod_map <| (continuous_const.mul continuous_subtype_val).sub continuous_const) · rintro st hst simp [hst, mul_inv_cancel (two_ne_zero' ℝ)] @[continuity] theorem _root_.Continuous.path_trans {f : Y → Path x y} {g : Y → Path y z} : Continuous f → Continuous g → Continuous fun t => (f t).trans (g t) := by intro hf hg apply continuous_uncurry_iff.mp exact trans_continuous_family _ (continuous_uncurry_iff.mpr hf) _ (continuous_uncurry_iff.mpr hg) @[continuity] theorem continuous_trans {x y z : X} : Continuous fun ρ : Path x y × Path y z => ρ.1.trans ρ.2 := continuous_fst.path_trans continuous_snd /-! #### Product of paths -/ section Prod variable {a₁ a₂ a₃ : X} {b₁ b₂ b₃ : Y} /-- Given a path in `X` and a path in `Y`, we can take their pointwise product to get a path in `X × Y`. -/ protected def prod (γ₁ : Path a₁ a₂) (γ₂ : Path b₁ b₂) : Path (a₁, b₁) (a₂, b₂) where toContinuousMap := ContinuousMap.prodMk γ₁.toContinuousMap γ₂.toContinuousMap source' := by simp target' := by simp @[simp] theorem prod_coe (γ₁ : Path a₁ a₂) (γ₂ : Path b₁ b₂) : ⇑(γ₁.prod γ₂) = fun t => (γ₁ t, γ₂ t) := rfl /-- Path composition commutes with products -/ theorem trans_prod_eq_prod_trans (γ₁ : Path a₁ a₂) (δ₁ : Path a₂ a₃) (γ₂ : Path b₁ b₂) (δ₂ : Path b₂ b₃) : (γ₁.prod γ₂).trans (δ₁.prod δ₂) = (γ₁.trans δ₁).prod (γ₂.trans δ₂) := by ext t <;> unfold Path.trans <;> simp only [Path.coe_mk_mk, Path.prod_coe, Function.comp_apply] <;> split_ifs <;> rfl end Prod section Pi variable {χ : ι → Type*} [∀ i, TopologicalSpace (χ i)] {as bs cs : ∀ i, χ i} /-- Given a family of paths, one in each Xᵢ, we take their pointwise product to get a path in Π i, Xᵢ. -/ protected def pi (γ : ∀ i, Path (as i) (bs i)) : Path as bs where toContinuousMap := ContinuousMap.pi fun i => (γ i).toContinuousMap source' := by simp target' := by simp @[simp] theorem pi_coe (γ : ∀ i, Path (as i) (bs i)) : ⇑(Path.pi γ) = fun t i => γ i t := rfl /-- Path composition commutes with products -/ theorem trans_pi_eq_pi_trans (γ₀ : ∀ i, Path (as i) (bs i)) (γ₁ : ∀ i, Path (bs i) (cs i)) : (Path.pi γ₀).trans (Path.pi γ₁) = Path.pi fun i => (γ₀ i).trans (γ₁ i) := by ext t i unfold Path.trans simp only [Path.coe_mk_mk, Function.comp_apply, pi_coe] split_ifs <;> rfl end Pi /-! #### Pointwise multiplication/addition of two paths in a topological (additive) group -/ /-- Pointwise multiplication of paths in a topological group. The additive version is probably more useful. -/ @[to_additive "Pointwise addition of paths in a topological additive group."] protected def mul [Mul X] [ContinuousMul X] {a₁ b₁ a₂ b₂ : X} (γ₁ : Path a₁ b₁) (γ₂ : Path a₂ b₂) : Path (a₁ * a₂) (b₁ * b₂) := (γ₁.prod γ₂).map continuous_mul @[to_additive] protected theorem mul_apply [Mul X] [ContinuousMul X] {a₁ b₁ a₂ b₂ : X} (γ₁ : Path a₁ b₁) (γ₂ : Path a₂ b₂) (t : unitInterval) : (γ₁.mul γ₂) t = γ₁ t * γ₂ t := rfl /-! #### Truncating a path -/ /-- `γ.truncate t₀ t₁` is the path which follows the path `γ` on the time interval `[t₀, t₁]` and stays still otherwise. -/ def truncate {X : Type*} [TopologicalSpace X] {a b : X} (γ : Path a b) (t₀ t₁ : ℝ) : Path (γ.extend <| min t₀ t₁) (γ.extend t₁) where toFun s := γ.extend (min (max s t₀) t₁) continuous_toFun := γ.continuous_extend.comp ((continuous_subtype_val.max continuous_const).min continuous_const) source' := by simp only [min_def, max_def'] norm_cast split_ifs with h₁ h₂ h₃ h₄ · simp [γ.extend_of_le_zero h₁] · congr linarith · have h₄ : t₁ ≤ 0 := le_of_lt (by simpa using h₂) simp [γ.extend_of_le_zero h₄, γ.extend_of_le_zero h₁] all_goals rfl target' := by simp only [min_def, max_def'] norm_cast split_ifs with h₁ h₂ h₃ · simp [γ.extend_of_one_le h₂] · rfl · have h₄ : 1 ≤ t₀ := le_of_lt (by simpa using h₁) simp [γ.extend_of_one_le h₄, γ.extend_of_one_le (h₄.trans h₃)] · rfl /-- `γ.truncateOfLE t₀ t₁ h`, where `h : t₀ ≤ t₁` is `γ.truncate t₀ t₁` casted as a path from `γ.extend t₀` to `γ.extend t₁`. -/ def truncateOfLE {X : Type*} [TopologicalSpace X] {a b : X} (γ : Path a b) {t₀ t₁ : ℝ} (h : t₀ ≤ t₁) : Path (γ.extend t₀) (γ.extend t₁) := (γ.truncate t₀ t₁).cast (by rw [min_eq_left h]) rfl theorem truncate_range {a b : X} (γ : Path a b) {t₀ t₁ : ℝ} : range (γ.truncate t₀ t₁) ⊆ range γ := by rw [← γ.extend_range] simp only [range_subset_iff, SetCoe.exists, SetCoe.forall] intro x _hx simp only [DFunLike.coe, Path.truncate, mem_range_self] /-- For a path `γ`, `γ.truncate` gives a "continuous family of paths", by which we mean the uncurried function which maps `(t₀, t₁, s)` to `γ.truncate t₀ t₁ s` is continuous. -/ @[continuity] theorem truncate_continuous_family {a b : X} (γ : Path a b) : Continuous (fun x => γ.truncate x.1 x.2.1 x.2.2 : ℝ × ℝ × I → X) := γ.continuous_extend.comp (((continuous_subtype_val.comp (continuous_snd.comp continuous_snd)).max continuous_fst).min (continuous_fst.comp continuous_snd)) @[continuity] theorem truncate_const_continuous_family {a b : X} (γ : Path a b) (t : ℝ) : Continuous ↿(γ.truncate t) := by have key : Continuous (fun x => (t, x) : ℝ × I → ℝ × ℝ × I) := by fun_prop exact γ.truncate_continuous_family.comp key @[simp] theorem truncate_self {a b : X} (γ : Path a b) (t : ℝ) : γ.truncate t t = (Path.refl <| γ.extend t).cast (by rw [min_self]) rfl := by ext x rw [cast_coe] simp only [truncate, DFunLike.coe, refl, min_def, max_def] split_ifs with h₁ h₂ <;> congr @[simp 1001] -- Porting note: increase `simp` priority so left-hand side doesn't simplify theorem truncate_zero_zero {a b : X} (γ : Path a b) : γ.truncate 0 0 = (Path.refl a).cast (by rw [min_self, γ.extend_zero]) γ.extend_zero := by convert γ.truncate_self 0 @[simp 1001] -- Porting note: increase `simp` priority so left-hand side doesn't simplify theorem truncate_one_one {a b : X} (γ : Path a b) : γ.truncate 1 1 = (Path.refl b).cast (by rw [min_self, γ.extend_one]) γ.extend_one := by convert γ.truncate_self 1 @[simp] theorem truncate_zero_one {a b : X} (γ : Path a b) : γ.truncate 0 1 = γ.cast (by simp [zero_le_one, extend_zero]) (by simp) := by ext x rw [cast_coe] have : ↑x ∈ (Icc 0 1 : Set ℝ) := x.2 rw [truncate, coe_mk_mk, max_eq_left this.1, min_eq_left this.2, extend_extends'] /-! #### Reparametrising a path -/ /-- Given a path `γ` and a function `f : I → I` where `f 0 = 0` and `f 1 = 1`, `γ.reparam f` is the path defined by `γ ∘ f`. -/ def reparam (γ : Path x y) (f : I → I) (hfcont : Continuous f) (hf₀ : f 0 = 0) (hf₁ : f 1 = 1) : Path x y where toFun := γ ∘ f continuous_toFun := by fun_prop source' := by simp [hf₀] target' := by simp [hf₁] @[simp] theorem coe_reparam (γ : Path x y) {f : I → I} (hfcont : Continuous f) (hf₀ : f 0 = 0) (hf₁ : f 1 = 1) : ⇑(γ.reparam f hfcont hf₀ hf₁) = γ ∘ f := rfl -- Porting note: this seems like it was poorly named (was: `coe_to_fun`) @[simp] theorem reparam_id (γ : Path x y) : γ.reparam id continuous_id rfl rfl = γ := by ext rfl theorem range_reparam (γ : Path x y) {f : I → I} (hfcont : Continuous f) (hf₀ : f 0 = 0) (hf₁ : f 1 = 1) : range (γ.reparam f hfcont hf₀ hf₁) = range γ := by change range (γ ∘ f) = range γ have : range f = univ := by rw [range_iff_surjective] intro t have h₁ : Continuous (Set.IccExtend (zero_le_one' ℝ) f) := by continuity have := intermediate_value_Icc (zero_le_one' ℝ) h₁.continuousOn · rw [IccExtend_left, IccExtend_right, Icc.mk_zero, Icc.mk_one, hf₀, hf₁] at this rcases this t.2 with ⟨w, hw₁, hw₂⟩ rw [IccExtend_of_mem _ _ hw₁] at hw₂ exact ⟨_, hw₂⟩ rw [range_comp, this, image_univ] theorem refl_reparam {f : I → I} (hfcont : Continuous f) (hf₀ : f 0 = 0) (hf₁ : f 1 = 1) : (refl x).reparam f hfcont hf₀ hf₁ = refl x := by ext simp end Path /-! ### Being joined by a path -/ /-- The relation "being joined by a path". This is an equivalence relation. -/ def Joined (x y : X) : Prop := Nonempty (Path x y) @[refl] theorem Joined.refl (x : X) : Joined x x := ⟨Path.refl x⟩ /-- When two points are joined, choose some path from `x` to `y`. -/ def Joined.somePath (h : Joined x y) : Path x y := Nonempty.some h @[symm] theorem Joined.symm {x y : X} (h : Joined x y) : Joined y x := ⟨h.somePath.symm⟩ @[trans] theorem Joined.trans {x y z : X} (hxy : Joined x y) (hyz : Joined y z) : Joined x z := ⟨hxy.somePath.trans hyz.somePath⟩ variable (X) /-- The setoid corresponding the equivalence relation of being joined by a continuous path. -/ def pathSetoid : Setoid X where r := Joined iseqv := Equivalence.mk Joined.refl Joined.symm Joined.trans /-- The quotient type of points of a topological space modulo being joined by a continuous path. -/ def ZerothHomotopy := Quotient (pathSetoid X) instance ZerothHomotopy.inhabited : Inhabited (ZerothHomotopy ℝ) := ⟨@Quotient.mk' ℝ (pathSetoid ℝ) 0⟩ variable {X} /-! ### Being joined by a path inside a set -/ /-- The relation "being joined by a path in `F`". Not quite an equivalence relation since it's not reflexive for points that do not belong to `F`. -/ def JoinedIn (F : Set X) (x y : X) : Prop := ∃ γ : Path x y, ∀ t, γ t ∈ F variable {F : Set X} theorem JoinedIn.mem (h : JoinedIn F x y) : x ∈ F ∧ y ∈ F := by rcases h with ⟨γ, γ_in⟩ have : γ 0 ∈ F ∧ γ 1 ∈ F := by constructor <;> apply γ_in simpa using this theorem JoinedIn.source_mem (h : JoinedIn F x y) : x ∈ F := h.mem.1 theorem JoinedIn.target_mem (h : JoinedIn F x y) : y ∈ F := h.mem.2 /-- When `x` and `y` are joined in `F`, choose a path from `x` to `y` inside `F` -/ def JoinedIn.somePath (h : JoinedIn F x y) : Path x y := Classical.choose h theorem JoinedIn.somePath_mem (h : JoinedIn F x y) (t : I) : h.somePath t ∈ F := Classical.choose_spec h t /-- If `x` and `y` are joined in the set `F`, then they are joined in the subtype `F`. -/ theorem JoinedIn.joined_subtype (h : JoinedIn F x y) : Joined (⟨x, h.source_mem⟩ : F) (⟨y, h.target_mem⟩ : F) := ⟨{ toFun := fun t => ⟨h.somePath t, h.somePath_mem t⟩ continuous_toFun := by fun_prop source' := by simp target' := by simp }⟩ theorem JoinedIn.ofLine {f : ℝ → X} (hf : ContinuousOn f I) (h₀ : f 0 = x) (h₁ : f 1 = y) (hF : f '' I ⊆ F) : JoinedIn F x y := ⟨Path.ofLine hf h₀ h₁, fun t => hF <| Path.ofLine_mem hf h₀ h₁ t⟩ theorem JoinedIn.joined (h : JoinedIn F x y) : Joined x y := ⟨h.somePath⟩ theorem joinedIn_iff_joined (x_in : x ∈ F) (y_in : y ∈ F) : JoinedIn F x y ↔ Joined (⟨x, x_in⟩ : F) (⟨y, y_in⟩ : F) := ⟨fun h => h.joined_subtype, fun h => ⟨h.somePath.map continuous_subtype_val, by simp⟩⟩ @[simp] theorem joinedIn_univ : JoinedIn univ x y ↔ Joined x y := by simp [JoinedIn, Joined, exists_true_iff_nonempty] theorem JoinedIn.mono {U V : Set X} (h : JoinedIn U x y) (hUV : U ⊆ V) : JoinedIn V x y := ⟨h.somePath, fun t => hUV (h.somePath_mem t)⟩ theorem JoinedIn.refl (h : x ∈ F) : JoinedIn F x x := ⟨Path.refl x, fun _t => h⟩ @[symm] theorem JoinedIn.symm (h : JoinedIn F x y) : JoinedIn F y x := by cases' h.mem with hx hy simp_all [joinedIn_iff_joined] exact h.symm theorem JoinedIn.trans (hxy : JoinedIn F x y) (hyz : JoinedIn F y z) : JoinedIn F x z := by cases' hxy.mem with hx hy cases' hyz.mem with hx hy simp_all [joinedIn_iff_joined] exact hxy.trans hyz theorem Specializes.joinedIn (h : x ⤳ y) (hx : x ∈ F) (hy : y ∈ F) : JoinedIn F x y := by refine ⟨⟨⟨Set.piecewise {1} (const I y) (const I x), ?_⟩, by simp, by simp⟩, fun t ↦ ?_⟩ · exact isClosed_singleton.continuous_piecewise_of_specializes continuous_const continuous_const fun _ ↦ h · simp only [Path.coe_mk_mk, piecewise] split_ifs <;> assumption theorem Inseparable.joinedIn (h : Inseparable x y) (hx : x ∈ F) (hy : y ∈ F) : JoinedIn F x y := h.specializes.joinedIn hx hy /-! ### Path component -/ /-- The path component of `x` is the set of points that can be joined to `x`. -/ def pathComponent (x : X) := { y | Joined x y } @[simp] theorem mem_pathComponent_self (x : X) : x ∈ pathComponent x := Joined.refl x @[simp] theorem pathComponent.nonempty (x : X) : (pathComponent x).Nonempty := ⟨x, mem_pathComponent_self x⟩ theorem mem_pathComponent_of_mem (h : x ∈ pathComponent y) : y ∈ pathComponent x := Joined.symm h theorem pathComponent_symm : x ∈ pathComponent y ↔ y ∈ pathComponent x := ⟨fun h => mem_pathComponent_of_mem h, fun h => mem_pathComponent_of_mem h⟩ theorem pathComponent_congr (h : x ∈ pathComponent y) : pathComponent x = pathComponent y := by ext z constructor · intro h' rw [pathComponent_symm] exact (h.trans h').symm · intro h' rw [pathComponent_symm] at h' ⊢ exact h'.trans h theorem pathComponent_subset_component (x : X) : pathComponent x ⊆ connectedComponent x := fun y h => (isConnected_range h.somePath.continuous).subset_connectedComponent ⟨0, by simp⟩ ⟨1, by simp⟩ /-- The path component of `x` in `F` is the set of points that can be joined to `x` in `F`. -/ def pathComponentIn (x : X) (F : Set X) := { y | JoinedIn F x y } @[simp] theorem pathComponentIn_univ (x : X) : pathComponentIn x univ = pathComponent x := by simp [pathComponentIn, pathComponent, JoinedIn, Joined, exists_true_iff_nonempty] theorem Joined.mem_pathComponent (hyz : Joined y z) (hxy : y ∈ pathComponent x) : z ∈ pathComponent x := hxy.trans hyz /-! ### Path connected sets -/ /-- A set `F` is path connected if it contains a point that can be joined to all other in `F`. -/ def IsPathConnected (F : Set X) : Prop := ∃ x ∈ F, ∀ {y}, y ∈ F → JoinedIn F x y theorem isPathConnected_iff_eq : IsPathConnected F ↔ ∃ x ∈ F, pathComponentIn x F = F := by constructor <;> rintro ⟨x, x_in, h⟩ <;> use x, x_in · ext y exact ⟨fun hy => hy.mem.2, h⟩ · intro y y_in rwa [← h] at y_in theorem IsPathConnected.joinedIn (h : IsPathConnected F) : ∀ᵉ (x ∈ F) (y ∈ F), JoinedIn F x y := fun _x x_in _y y_in => let ⟨_b, _b_in, hb⟩ := h (hb x_in).symm.trans (hb y_in) theorem isPathConnected_iff : IsPathConnected F ↔ F.Nonempty ∧ ∀ᵉ (x ∈ F) (y ∈ F), JoinedIn F x y := ⟨fun h => ⟨let ⟨b, b_in, _hb⟩ := h; ⟨b, b_in⟩, h.joinedIn⟩, fun ⟨⟨b, b_in⟩, h⟩ => ⟨b, b_in, fun x_in => h _ b_in _ x_in⟩⟩ /-- If `f` is continuous on `F` and `F` is path-connected, so is `f(F)`. -/ theorem IsPathConnected.image' (hF : IsPathConnected F) {f : X → Y} (hf : ContinuousOn f F) : IsPathConnected (f '' F) := by rcases hF with ⟨x, x_in, hx⟩ use f x, mem_image_of_mem f x_in rintro _ ⟨y, y_in, rfl⟩ refine ⟨(hx y_in).somePath.map' ?_, fun t ↦ ⟨_, (hx y_in).somePath_mem t, rfl⟩⟩ exact hf.mono (range_subset_iff.2 (hx y_in).somePath_mem) /-- If `f` is continuous and `F` is path-connected, so is `f(F)`. -/ theorem IsPathConnected.image (hF : IsPathConnected F) {f : X → Y} (hf : Continuous f) : IsPathConnected (f '' F) := hF.image' hf.continuousOn /-- If `f : X → Y` is a `Inducing`, `f(F)` is path-connected iff `F` is. -/ nonrec theorem Inducing.isPathConnected_iff {f : X → Y} (hf : Inducing f) : IsPathConnected F ↔ IsPathConnected (f '' F) := by refine ⟨fun hF ↦ hF.image hf.continuous, fun hF ↦ ?_⟩ simp? [isPathConnected_iff] at hF ⊢ says simp only [isPathConnected_iff, image_nonempty, mem_image, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] at hF ⊢ refine ⟨hF.1, fun x hx y hy ↦ ?_⟩ rcases hF.2 x hx y hy with ⟨γ, hγ⟩ choose γ' hγ' hγγ' using hγ have key₁ : Inseparable x (γ' 0) := by rw [← hf.inseparable_iff, hγγ' 0, γ.source] have key₂ : Inseparable (γ' 1) y := by rw [← hf.inseparable_iff, hγγ' 1, γ.target] refine key₁.joinedIn hx (hγ' 0) |>.trans ⟨⟨⟨γ', ?_⟩, rfl, rfl⟩, hγ'⟩ |>.trans (key₂.joinedIn (hγ' 1) hy) simpa [hf.continuous_iff] using γ.continuous.congr fun t ↦ (hγγ' t).symm /-- If `h : X → Y` is a homeomorphism, `h(s)` is path-connected iff `s` is. -/ @[simp] theorem Homeomorph.isPathConnected_image {s : Set X} (h : X ≃ₜ Y) : IsPathConnected (h '' s) ↔ IsPathConnected s := h.inducing.isPathConnected_iff.symm /-- If `h : X → Y` is a homeomorphism, `h⁻¹(s)` is path-connected iff `s` is. -/ @[simp] theorem Homeomorph.isPathConnected_preimage {s : Set Y} (h : X ≃ₜ Y) : IsPathConnected (h ⁻¹' s) ↔ IsPathConnected s := by rw [← Homeomorph.image_symm]; exact h.symm.isPathConnected_image theorem IsPathConnected.mem_pathComponent (h : IsPathConnected F) (x_in : x ∈ F) (y_in : y ∈ F) : y ∈ pathComponent x := (h.joinedIn x x_in y y_in).joined theorem IsPathConnected.subset_pathComponent (h : IsPathConnected F) (x_in : x ∈ F) : F ⊆ pathComponent x := fun _y y_in => h.mem_pathComponent x_in y_in theorem isPathConnected_singleton (x : X) : IsPathConnected ({x} : Set X) := by refine ⟨x, rfl, ?_⟩ rintro y rfl exact JoinedIn.refl rfl theorem IsPathConnected.union {U V : Set X} (hU : IsPathConnected U) (hV : IsPathConnected V) (hUV : (U ∩ V).Nonempty) : IsPathConnected (U ∪ V) := by rcases hUV with ⟨x, xU, xV⟩ use x, Or.inl xU rintro y (yU | yV) · exact (hU.joinedIn x xU y yU).mono subset_union_left · exact (hV.joinedIn x xV y yV).mono subset_union_right /-- If a set `W` is path-connected, then it is also path-connected when seen as a set in a smaller ambient type `U` (when `U` contains `W`). -/ theorem IsPathConnected.preimage_coe {U W : Set X} (hW : IsPathConnected W) (hWU : W ⊆ U) : IsPathConnected (((↑) : U → X) ⁻¹' W) := by rcases hW with ⟨x, x_in, hx⟩ use ⟨x, hWU x_in⟩, by simp [x_in] rintro ⟨y, hyU⟩ hyW exact ⟨(hx hyW).joined_subtype.somePath.map (continuous_inclusion hWU), by simp⟩ theorem IsPathConnected.exists_path_through_family {n : ℕ} {s : Set X} (h : IsPathConnected s) (p : Fin (n + 1) → X) (hp : ∀ i, p i ∈ s) : ∃ γ : Path (p 0) (p n), range γ ⊆ s ∧ ∀ i, p i ∈ range γ := by let p' : ℕ → X := fun k => if h : k < n + 1 then p ⟨k, h⟩ else p ⟨0, n.zero_lt_succ⟩ obtain ⟨γ, hγ⟩ : ∃ γ : Path (p' 0) (p' n), (∀ i ≤ n, p' i ∈ range γ) ∧ range γ ⊆ s := by have hp' : ∀ i ≤ n, p' i ∈ s := by intro i hi simp [p', Nat.lt_succ_of_le hi, hp] clear_value p' clear hp p induction' n with n hn · use Path.refl (p' 0) constructor · rintro i hi rw [Nat.le_zero.mp hi] exact ⟨0, rfl⟩ · rw [range_subset_iff] rintro _x exact hp' 0 le_rfl · rcases hn fun i hi => hp' i <| Nat.le_succ_of_le hi with ⟨γ₀, hγ₀⟩ rcases h.joinedIn (p' n) (hp' n n.le_succ) (p' <| n + 1) (hp' (n + 1) <| le_rfl) with ⟨γ₁, hγ₁⟩ let γ : Path (p' 0) (p' <| n + 1) := γ₀.trans γ₁ use γ have range_eq : range γ = range γ₀ ∪ range γ₁ := γ₀.trans_range γ₁ constructor · rintro i hi by_cases hi' : i ≤ n · rw [range_eq] left exact hγ₀.1 i hi' · rw [not_le, ← Nat.succ_le_iff] at hi' have : i = n.succ := le_antisymm hi hi' rw [this] use 1 exact γ.target · rw [range_eq] apply union_subset hγ₀.2 rw [range_subset_iff] exact hγ₁ have hpp' : ∀ k < n + 1, p k = p' k := by intro k hk simp only [p', hk, dif_pos] congr ext rw [Fin.val_cast_of_lt hk] use γ.cast (hpp' 0 n.zero_lt_succ) (hpp' n n.lt_succ_self) simp only [γ.cast_coe] refine And.intro hγ.2 ?_ rintro ⟨i, hi⟩ suffices p ⟨i, hi⟩ = p' i by convert hγ.1 i (Nat.le_of_lt_succ hi) rw [← hpp' i hi] suffices i = i % n.succ by congr rw [Nat.mod_eq_of_lt hi] theorem IsPathConnected.exists_path_through_family' {n : ℕ} {s : Set X} (h : IsPathConnected s) (p : Fin (n + 1) → X) (hp : ∀ i, p i ∈ s) : ∃ (γ : Path (p 0) (p n)) (t : Fin (n + 1) → I), (∀ t, γ t ∈ s) ∧ ∀ i, γ (t i) = p i := by rcases h.exists_path_through_family p hp with ⟨γ, hγ⟩ rcases hγ with ⟨h₁, h₂⟩ simp only [range, mem_setOf_eq] at h₂ rw [range_subset_iff] at h₁ choose! t ht using h₂ exact ⟨γ, t, h₁, ht⟩ /-! ### Path connected spaces -/ /-- A topological space is path-connected if it is non-empty and every two points can be joined by a continuous path. -/ class PathConnectedSpace (X : Type*) [TopologicalSpace X] : Prop where /-- A path-connected space must be nonempty. -/ nonempty : Nonempty X /-- Any two points in a path-connected space must be joined by a continuous path. -/ joined : ∀ x y : X, Joined x y theorem pathConnectedSpace_iff_zerothHomotopy : PathConnectedSpace X ↔ Nonempty (ZerothHomotopy X) ∧ Subsingleton (ZerothHomotopy X) := by letI := pathSetoid X constructor · intro h refine ⟨(nonempty_quotient_iff _).mpr h.1, ⟨?_⟩⟩ rintro ⟨x⟩ ⟨y⟩ exact Quotient.sound (PathConnectedSpace.joined x y) · unfold ZerothHomotopy rintro ⟨h, h'⟩ exact ⟨(nonempty_quotient_iff _).mp h, fun x y => Quotient.exact <| Subsingleton.elim ⟦x⟧ ⟦y⟧⟩ namespace PathConnectedSpace variable [PathConnectedSpace X] /-- Use path-connectedness to build a path between two points. -/ def somePath (x y : X) : Path x y := Nonempty.some (joined x y) end PathConnectedSpace theorem isPathConnected_iff_pathConnectedSpace : IsPathConnected F ↔ PathConnectedSpace F := by rw [isPathConnected_iff] constructor · rintro ⟨⟨x, x_in⟩, h⟩ refine ⟨⟨⟨x, x_in⟩⟩, ?_⟩ rintro ⟨y, y_in⟩ ⟨z, z_in⟩ have H := h y y_in z z_in rwa [joinedIn_iff_joined y_in z_in] at H · rintro ⟨⟨x, x_in⟩, H⟩ refine ⟨⟨x, x_in⟩, fun y y_in z z_in => ?_⟩ rw [joinedIn_iff_joined y_in z_in] apply H theorem pathConnectedSpace_iff_univ : PathConnectedSpace X ↔ IsPathConnected (univ : Set X) := by constructor · intro h haveI := @PathConnectedSpace.nonempty X _ _ inhabit X refine ⟨default, mem_univ _, ?_⟩ intros y _hy simpa using PathConnectedSpace.joined default y · intro h have h' := h.joinedIn cases' h with x h exact ⟨⟨x⟩, by simpa using h'⟩ theorem isPathConnected_univ [PathConnectedSpace X] : IsPathConnected (univ : Set X) := pathConnectedSpace_iff_univ.mp inferInstance theorem isPathConnected_range [PathConnectedSpace X] {f : X → Y} (hf : Continuous f) : IsPathConnected (range f) := by rw [← image_univ] exact isPathConnected_univ.image hf theorem Function.Surjective.pathConnectedSpace [PathConnectedSpace X] {f : X → Y} (hf : Surjective f) (hf' : Continuous f) : PathConnectedSpace Y := by rw [pathConnectedSpace_iff_univ, ← hf.range_eq] exact isPathConnected_range hf' instance Quotient.instPathConnectedSpace {s : Setoid X} [PathConnectedSpace X] : PathConnectedSpace (Quotient s) := (surjective_quotient_mk' X).pathConnectedSpace continuous_coinduced_rng /-- This is a special case of `NormedSpace.instPathConnectedSpace` (and `TopologicalAddGroup.pathConnectedSpace`). It exists only to simplify dependencies. -/ instance Real.instPathConnectedSpace : PathConnectedSpace ℝ where joined x y := ⟨⟨⟨fun (t : I) ↦ (1 - t) * x + t * y, by fun_prop⟩, by simp, by simp⟩⟩ nonempty := inferInstance theorem pathConnectedSpace_iff_eq : PathConnectedSpace X ↔ ∃ x : X, pathComponent x = univ := by simp [pathConnectedSpace_iff_univ, isPathConnected_iff_eq] -- see Note [lower instance priority] instance (priority := 100) PathConnectedSpace.connectedSpace [PathConnectedSpace X] : ConnectedSpace X := by rw [connectedSpace_iff_connectedComponent] rcases isPathConnected_iff_eq.mp (pathConnectedSpace_iff_univ.mp ‹_›) with ⟨x, _x_in, hx⟩ use x rw [← univ_subset_iff] exact (by simpa using hx : pathComponent x = univ) ▸ pathComponent_subset_component x theorem IsPathConnected.isConnected (hF : IsPathConnected F) : IsConnected F := by rw [isConnected_iff_connectedSpace] rw [isPathConnected_iff_pathConnectedSpace] at hF exact @PathConnectedSpace.connectedSpace _ _ hF namespace PathConnectedSpace variable [PathConnectedSpace X] theorem exists_path_through_family {n : ℕ} (p : Fin (n + 1) → X) : ∃ γ : Path (p 0) (p n), ∀ i, p i ∈ range γ := by have : IsPathConnected (univ : Set X) := pathConnectedSpace_iff_univ.mp (by infer_instance) rcases this.exists_path_through_family p fun _i => True.intro with ⟨γ, -, h⟩ exact ⟨γ, h⟩ theorem exists_path_through_family' {n : ℕ} (p : Fin (n + 1) → X) : ∃ (γ : Path (p 0) (p n)) (t : Fin (n + 1) → I), ∀ i, γ (t i) = p i := by have : IsPathConnected (univ : Set X) := pathConnectedSpace_iff_univ.mp (by infer_instance) rcases this.exists_path_through_family' p fun _i => True.intro with ⟨γ, t, -, h⟩ exact ⟨γ, t, h⟩ end PathConnectedSpace /-! ### Locally path connected spaces -/ /-- A topological space is locally path connected, at every point, path connected neighborhoods form a neighborhood basis. -/ class LocPathConnectedSpace (X : Type*) [TopologicalSpace X] : Prop where /-- Each neighborhood filter has a basis of path-connected neighborhoods. -/ path_connected_basis : ∀ x : X, (𝓝 x).HasBasis (fun s : Set X => s ∈ 𝓝 x ∧ IsPathConnected s) id export LocPathConnectedSpace (path_connected_basis) theorem locPathConnected_of_bases {p : ι → Prop} {s : X → ι → Set X} (h : ∀ x, (𝓝 x).HasBasis p (s x)) (h' : ∀ x i, p i → IsPathConnected (s x i)) : LocPathConnectedSpace X := by constructor intro x apply (h x).to_hasBasis · intro i pi exact ⟨s x i, ⟨(h x).mem_of_mem pi, h' x i pi⟩, by rfl⟩ · rintro U ⟨U_in, _hU⟩ rcases (h x).mem_iff.mp U_in with ⟨i, pi, hi⟩ tauto theorem pathConnectedSpace_iff_connectedSpace [LocPathConnectedSpace X] : PathConnectedSpace X ↔ ConnectedSpace X := by constructor · intro h infer_instance · intro hX rw [pathConnectedSpace_iff_eq] use Classical.arbitrary X refine IsClopen.eq_univ ⟨?_, ?_⟩ (by simp) · rw [isClosed_iff_nhds] intro y H rcases (path_connected_basis y).ex_mem with ⟨U, ⟨U_in, hU⟩⟩ rcases H U U_in with ⟨z, hz, hz'⟩ exact (hU.joinedIn z hz y <| mem_of_mem_nhds U_in).joined.mem_pathComponent hz' · rw [isOpen_iff_mem_nhds] intro y y_in rcases (path_connected_basis y).ex_mem with ⟨U, ⟨U_in, hU⟩⟩ apply mem_of_superset U_in rw [← pathComponent_congr y_in] exact hU.subset_pathComponent (mem_of_mem_nhds U_in) theorem pathConnected_subset_basis [LocPathConnectedSpace X] {U : Set X} (h : IsOpen U) (hx : x ∈ U) : (𝓝 x).HasBasis (fun s : Set X => s ∈ 𝓝 x ∧ IsPathConnected s ∧ s ⊆ U) id := (path_connected_basis x).hasBasis_self_subset (IsOpen.mem_nhds h hx) theorem locPathConnected_of_isOpen [LocPathConnectedSpace X] {U : Set X} (h : IsOpen U) : LocPathConnectedSpace U := ⟨by rintro ⟨x, x_in⟩ rw [nhds_subtype_eq_comap] constructor intro V rw [(HasBasis.comap ((↑) : U → X) (pathConnected_subset_basis h x_in)).mem_iff] constructor · rintro ⟨W, ⟨W_in, hW, hWU⟩, hWV⟩ exact ⟨Subtype.val ⁻¹' W, ⟨⟨preimage_mem_comap W_in, hW.preimage_coe hWU⟩, hWV⟩⟩ · rintro ⟨W, ⟨W_in, hW⟩, hWV⟩ refine ⟨(↑) '' W, ⟨Filter.image_coe_mem_of_mem_comap (IsOpen.mem_nhds h x_in) W_in, hW.image continuous_subtype_val, Subtype.coe_image_subset U W⟩, ?_⟩ rintro x ⟨y, ⟨y_in, hy⟩⟩ rw [← Subtype.coe_injective hy] tauto⟩ theorem IsOpen.isConnected_iff_isPathConnected [LocPathConnectedSpace X] {U : Set X} (U_op : IsOpen U) : IsPathConnected U ↔ IsConnected U := by rw [isConnected_iff_connectedSpace, isPathConnected_iff_pathConnectedSpace] haveI := locPathConnected_of_isOpen U_op exact pathConnectedSpace_iff_connectedSpace
Topology\Connected\Separation.lean
/- Copyright (c) 2024 Dagur Asgeirsson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Dagur Asgeirsson -/ import Mathlib.Topology.Separation /-! # Separation and (dis)connectedness properties of topological spaces. This file provides an instance `T2Space X` given `TotallySeparatedSpace X`. ## TODO * Move the last part of `Topology/Separation` to this file. -/ variable {X : Type*} [TopologicalSpace X] section TotallySeparated /-- A totally separated space is T2. -/ instance TotallySeparatedSpace.t2Space [TotallySeparatedSpace X] : T2Space X where t2 x y h := by obtain ⟨u, v, h₁, h₂, h₃, h₄, _, h₅⟩ := isTotallySeparated_univ trivial trivial h exact ⟨u, v, h₁, h₂, h₃, h₄, h₅⟩ end TotallySeparated
Topology\Connected\TotallyDisconnected.lean
/- Copyright (c) 2018 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau, Patrick Massot, Yury Kudryashov -/ import Mathlib.Topology.Connected.Clopen /-! # Totally disconnected and totally separated topological spaces ## Main definitions We define the following properties for sets in a topological space: * `IsTotallyDisconnected`: all of its connected components are singletons. * `IsTotallySeparated`: any two points can be separated by two disjoint opens that cover the set. For both of these definitions, we also have a class stating that the whole space satisfies that property: `TotallyDisconnectedSpace`, `TotallySeparatedSpace`. -/ open Set Function universe u v variable {α : Type u} {β : Type v} {ι : Type*} {π : ι → Type*} [TopologicalSpace α] {s t u v : Set α} section TotallyDisconnected /-- A set `s` is called totally disconnected if every subset `t ⊆ s` which is preconnected is a subsingleton, ie either empty or a singleton. -/ def IsTotallyDisconnected (s : Set α) : Prop := ∀ t, t ⊆ s → IsPreconnected t → t.Subsingleton theorem isTotallyDisconnected_empty : IsTotallyDisconnected (∅ : Set α) := fun _ ht _ _ x_in _ _ => (ht x_in).elim theorem isTotallyDisconnected_singleton {x} : IsTotallyDisconnected ({x} : Set α) := fun _ ht _ => subsingleton_singleton.anti ht /-- A space is totally disconnected if all of its connected components are singletons. -/ @[mk_iff] class TotallyDisconnectedSpace (α : Type u) [TopologicalSpace α] : Prop where /-- The universal set `Set.univ` in a totally disconnected space is totally disconnected. -/ isTotallyDisconnected_univ : IsTotallyDisconnected (univ : Set α) theorem IsPreconnected.subsingleton [TotallyDisconnectedSpace α] {s : Set α} (h : IsPreconnected s) : s.Subsingleton := TotallyDisconnectedSpace.isTotallyDisconnected_univ s (subset_univ s) h instance Pi.totallyDisconnectedSpace {α : Type*} {β : α → Type*} [∀ a, TopologicalSpace (β a)] [∀ a, TotallyDisconnectedSpace (β a)] : TotallyDisconnectedSpace (∀ a : α, β a) := ⟨fun t _ h2 => have this : ∀ a, IsPreconnected ((fun x : ∀ a, β a => x a) '' t) := fun a => h2.image (fun x => x a) (continuous_apply a).continuousOn fun x x_in y y_in => funext fun a => (this a).subsingleton ⟨x, x_in, rfl⟩ ⟨y, y_in, rfl⟩⟩ instance Prod.totallyDisconnectedSpace [TopologicalSpace β] [TotallyDisconnectedSpace α] [TotallyDisconnectedSpace β] : TotallyDisconnectedSpace (α × β) := ⟨fun t _ h2 => have H1 : IsPreconnected (Prod.fst '' t) := h2.image Prod.fst continuous_fst.continuousOn have H2 : IsPreconnected (Prod.snd '' t) := h2.image Prod.snd continuous_snd.continuousOn fun x hx y hy => Prod.ext (H1.subsingleton ⟨x, hx, rfl⟩ ⟨y, hy, rfl⟩) (H2.subsingleton ⟨x, hx, rfl⟩ ⟨y, hy, rfl⟩)⟩ instance [TopologicalSpace β] [TotallyDisconnectedSpace α] [TotallyDisconnectedSpace β] : TotallyDisconnectedSpace (α ⊕ β) := by refine ⟨fun s _ hs => ?_⟩ obtain ⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩ := Sum.isPreconnected_iff.1 hs · exact ht.subsingleton.image _ · exact ht.subsingleton.image _ instance [∀ i, TopologicalSpace (π i)] [∀ i, TotallyDisconnectedSpace (π i)] : TotallyDisconnectedSpace (Σi, π i) := by refine ⟨fun s _ hs => ?_⟩ obtain rfl | h := s.eq_empty_or_nonempty · exact subsingleton_empty · obtain ⟨a, t, ht, rfl⟩ := Sigma.isConnected_iff.1 ⟨h, hs⟩ exact ht.isPreconnected.subsingleton.image _ -- Porting note: reformulated using `Pairwise` /-- Let `X` be a topological space, and suppose that for all distinct `x,y ∈ X`, there is some clopen set `U` such that `x ∈ U` and `y ∉ U`. Then `X` is totally disconnected. -/ theorem isTotallyDisconnected_of_isClopen_set {X : Type*} [TopologicalSpace X] (hX : Pairwise fun x y => ∃ (U : Set X), IsClopen U ∧ x ∈ U ∧ y ∉ U) : IsTotallyDisconnected (Set.univ : Set X) := by rintro S - hS unfold Set.Subsingleton by_contra! h_contra rcases h_contra with ⟨x, hx, y, hy, hxy⟩ obtain ⟨U, hU, hxU, hyU⟩ := hX hxy specialize hS U Uᶜ hU.2 hU.compl.2 (fun a _ => em (a ∈ U)) ⟨x, hx, hxU⟩ ⟨y, hy, hyU⟩ rw [inter_compl_self, Set.inter_empty] at hS exact Set.not_nonempty_empty hS /-- A space is totally disconnected iff its connected components are subsingletons. -/ theorem totallyDisconnectedSpace_iff_connectedComponent_subsingleton : TotallyDisconnectedSpace α ↔ ∀ x : α, (connectedComponent x).Subsingleton := by constructor · intro h x apply h.1 · exact subset_univ _ exact isPreconnected_connectedComponent intro h; constructor intro s s_sub hs rcases eq_empty_or_nonempty s with (rfl | ⟨x, x_in⟩) · exact subsingleton_empty · exact (h x).anti (hs.subset_connectedComponent x_in) /-- A space is totally disconnected iff its connected components are singletons. -/ theorem totallyDisconnectedSpace_iff_connectedComponent_singleton : TotallyDisconnectedSpace α ↔ ∀ x : α, connectedComponent x = {x} := by rw [totallyDisconnectedSpace_iff_connectedComponent_subsingleton] refine forall_congr' fun x => ?_ rw [subsingleton_iff_singleton] exact mem_connectedComponent @[simp] theorem connectedComponent_eq_singleton [TotallyDisconnectedSpace α] (x : α) : connectedComponent x = {x} := totallyDisconnectedSpace_iff_connectedComponent_singleton.1 ‹_› x /-- The image of a connected component in a totally disconnected space is a singleton. -/ @[simp] theorem Continuous.image_connectedComponent_eq_singleton {β : Type*} [TopologicalSpace β] [TotallyDisconnectedSpace β] {f : α → β} (h : Continuous f) (a : α) : f '' connectedComponent a = {f a} := (Set.subsingleton_iff_singleton <| mem_image_of_mem f mem_connectedComponent).mp (isPreconnected_connectedComponent.image f h.continuousOn).subsingleton theorem isTotallyDisconnected_of_totallyDisconnectedSpace [TotallyDisconnectedSpace α] (s : Set α) : IsTotallyDisconnected s := fun t _ ht => TotallyDisconnectedSpace.isTotallyDisconnected_univ _ t.subset_univ ht theorem isTotallyDisconnected_of_image [TopologicalSpace β] {f : α → β} (hf : ContinuousOn f s) (hf' : Injective f) (h : IsTotallyDisconnected (f '' s)) : IsTotallyDisconnected s := fun _t hts ht _x x_in _y y_in => hf' <| h _ (image_subset f hts) (ht.image f <| hf.mono hts) (mem_image_of_mem f x_in) (mem_image_of_mem f y_in) theorem Embedding.isTotallyDisconnected [TopologicalSpace β] {f : α → β} (hf : Embedding f) {s : Set α} (h : IsTotallyDisconnected (f '' s)) : IsTotallyDisconnected s := isTotallyDisconnected_of_image hf.continuous.continuousOn hf.inj h lemma Embedding.isTotallyDisconnected_image [TopologicalSpace β] {f : α → β} (hf : Embedding f) {s : Set α} : IsTotallyDisconnected (f '' s) ↔ IsTotallyDisconnected s := by refine ⟨hf.isTotallyDisconnected, fun hs u hus hu ↦ ?_⟩ obtain ⟨v, hvs, rfl⟩ : ∃ v, v ⊆ s ∧ f '' v = u := ⟨f ⁻¹' u ∩ s, inter_subset_right, by rwa [image_preimage_inter, inter_eq_left]⟩ rw [hf.toInducing.isPreconnected_image] at hu exact (hs v hvs hu).image _ lemma Embedding.isTotallyDisconnected_range [TopologicalSpace β] {f : α → β} (hf : Embedding f) : IsTotallyDisconnected (range f) ↔ TotallyDisconnectedSpace α := by rw [totallyDisconnectedSpace_iff, ← image_univ, hf.isTotallyDisconnected_image] lemma totallyDisconnectedSpace_subtype_iff {s : Set α} : TotallyDisconnectedSpace s ↔ IsTotallyDisconnected s := by rw [← embedding_subtype_val.isTotallyDisconnected_range, Subtype.range_val] instance Subtype.totallyDisconnectedSpace {α : Type*} {p : α → Prop} [TopologicalSpace α] [TotallyDisconnectedSpace α] : TotallyDisconnectedSpace (Subtype p) := totallyDisconnectedSpace_subtype_iff.2 (isTotallyDisconnected_of_totallyDisconnectedSpace _) end TotallyDisconnected section TotallySeparated /-- A set `s` is called totally separated if any two points of this set can be separated by two disjoint open sets covering `s`. -/ def IsTotallySeparated (s : Set α) : Prop := Set.Pairwise s fun x y => ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ x ∈ u ∧ y ∈ v ∧ s ⊆ u ∪ v ∧ Disjoint u v theorem isTotallySeparated_empty : IsTotallySeparated (∅ : Set α) := fun _ => False.elim theorem isTotallySeparated_singleton {x} : IsTotallySeparated ({x} : Set α) := fun _ hp _ hq hpq => (hpq <| (eq_of_mem_singleton hp).symm ▸ (eq_of_mem_singleton hq).symm).elim theorem isTotallyDisconnected_of_isTotallySeparated {s : Set α} (H : IsTotallySeparated s) : IsTotallyDisconnected s := by intro t hts ht x x_in y y_in by_contra h obtain ⟨u : Set α, v : Set α, hu : IsOpen u, hv : IsOpen v, hxu : x ∈ u, hyv : y ∈ v, hs : s ⊆ u ∪ v, huv⟩ := H (hts x_in) (hts y_in) h refine (ht _ _ hu hv (hts.trans hs) ⟨x, x_in, hxu⟩ ⟨y, y_in, hyv⟩).ne_empty ?_ rw [huv.inter_eq, inter_empty] alias IsTotallySeparated.isTotallyDisconnected := isTotallyDisconnected_of_isTotallySeparated /-- A space is totally separated if any two points can be separated by two disjoint open sets covering the whole space. -/ class TotallySeparatedSpace (α : Type u) [TopologicalSpace α] : Prop where /-- The universal set `Set.univ` in a totally separated space is totally separated. -/ isTotallySeparated_univ : IsTotallySeparated (univ : Set α) -- see Note [lower instance priority] instance (priority := 100) TotallySeparatedSpace.totallyDisconnectedSpace (α : Type u) [TopologicalSpace α] [TotallySeparatedSpace α] : TotallyDisconnectedSpace α := ⟨TotallySeparatedSpace.isTotallySeparated_univ.isTotallyDisconnected⟩ -- see Note [lower instance priority] instance (priority := 100) TotallySeparatedSpace.of_discrete (α : Type*) [TopologicalSpace α] [DiscreteTopology α] : TotallySeparatedSpace α := ⟨fun _ _ b _ h => ⟨{b}ᶜ, {b}, isOpen_discrete _, isOpen_discrete _, h, rfl, (compl_union_self _).symm.subset, disjoint_compl_left⟩⟩ theorem exists_isClopen_of_totally_separated {α : Type*} [TopologicalSpace α] [TotallySeparatedSpace α] {x y : α} (hxy : x ≠ y) : ∃ U : Set α, IsClopen U ∧ x ∈ U ∧ y ∈ Uᶜ := by obtain ⟨U, V, hU, hV, Ux, Vy, f, disj⟩ := TotallySeparatedSpace.isTotallySeparated_univ (Set.mem_univ x) (Set.mem_univ y) hxy have hU := isClopen_inter_of_disjoint_cover_clopen isClopen_univ f hU hV disj rw [univ_inter _] at hU rw [← Set.subset_compl_iff_disjoint_right, subset_compl_comm] at disj exact ⟨U, hU, Ux, disj Vy⟩ end TotallySeparated variable [TopologicalSpace β] [TotallyDisconnectedSpace β] {f : α → β} theorem Continuous.image_eq_of_connectedComponent_eq (h : Continuous f) (a b : α) (hab : connectedComponent a = connectedComponent b) : f a = f b := singleton_eq_singleton_iff.1 <| h.image_connectedComponent_eq_singleton a ▸ h.image_connectedComponent_eq_singleton b ▸ hab ▸ rfl /-- The lift to `connectedComponents α` of a continuous map from `α` to a totally disconnected space -/ def Continuous.connectedComponentsLift (h : Continuous f) : ConnectedComponents α → β := fun x => Quotient.liftOn' x f h.image_eq_of_connectedComponent_eq @[continuity] theorem Continuous.connectedComponentsLift_continuous (h : Continuous f) : Continuous h.connectedComponentsLift := h.quotient_liftOn' <| by convert h.image_eq_of_connectedComponent_eq @[simp] theorem Continuous.connectedComponentsLift_apply_coe (h : Continuous f) (x : α) : h.connectedComponentsLift x = f x := rfl @[simp] theorem Continuous.connectedComponentsLift_comp_coe (h : Continuous f) : h.connectedComponentsLift ∘ (↑) = f := rfl theorem connectedComponents_lift_unique' {β : Sort*} {g₁ g₂ : ConnectedComponents α → β} (hg : g₁ ∘ ((↑) : α → ConnectedComponents α) = g₂ ∘ (↑)) : g₁ = g₂ := ConnectedComponents.surjective_coe.injective_comp_right hg theorem Continuous.connectedComponentsLift_unique (h : Continuous f) (g : ConnectedComponents α → β) (hg : g ∘ (↑) = f) : g = h.connectedComponentsLift := connectedComponents_lift_unique' <| hg.trans h.connectedComponentsLift_comp_coe.symm instance ConnectedComponents.totallyDisconnectedSpace : TotallyDisconnectedSpace (ConnectedComponents α) := by rw [totallyDisconnectedSpace_iff_connectedComponent_singleton] refine ConnectedComponents.surjective_coe.forall.2 fun x => ?_ rw [← ConnectedComponents.quotientMap_coe.image_connectedComponent, ← connectedComponents_preimage_singleton, image_preimage_eq _ ConnectedComponents.surjective_coe] refine ConnectedComponents.surjective_coe.forall.2 fun y => ?_ rw [connectedComponents_preimage_singleton] exact isConnected_connectedComponent /-- Functoriality of `connectedComponents` -/ def Continuous.connectedComponentsMap {β : Type*} [TopologicalSpace β] {f : α → β} (h : Continuous f) : ConnectedComponents α → ConnectedComponents β := Continuous.connectedComponentsLift (ConnectedComponents.continuous_coe.comp h) theorem Continuous.connectedComponentsMap_continuous {β : Type*} [TopologicalSpace β] {f : α → β} (h : Continuous f) : Continuous h.connectedComponentsMap := Continuous.connectedComponentsLift_continuous (ConnectedComponents.continuous_coe.comp h) /-- A preconnected set `s` has the property that every map to a discrete space that is continuous on `s` is constant on `s` -/ theorem IsPreconnected.constant {Y : Type*} [TopologicalSpace Y] [DiscreteTopology Y] {s : Set α} (hs : IsPreconnected s) {f : α → Y} (hf : ContinuousOn f s) {x y : α} (hx : x ∈ s) (hy : y ∈ s) : f x = f y := (hs.image f hf).subsingleton (mem_image_of_mem f hx) (mem_image_of_mem f hy) /-- A `PreconnectedSpace` version of `isPreconnected.constant` -/ theorem PreconnectedSpace.constant {Y : Type*} [TopologicalSpace Y] [DiscreteTopology Y] (hp : PreconnectedSpace α) {f : α → Y} (hf : Continuous f) {x y : α} : f x = f y := IsPreconnected.constant hp.isPreconnected_univ (Continuous.continuousOn hf) trivial trivial /-- Refinement of `IsPreconnected.constant` only assuming the map factors through a discrete subset of the target. -/ theorem IsPreconnected.constant_of_mapsTo {S : Set α} (hS : IsPreconnected S) {β} [TopologicalSpace β] {T : Set β} [DiscreteTopology T] {f : α → β} (hc : ContinuousOn f S) (hTm : MapsTo f S T) {x y : α} (hx : x ∈ S) (hy : y ∈ S) : f x = f y := by let F : S → T := hTm.restrict f S T suffices F ⟨x, hx⟩ = F ⟨y, hy⟩ by rwa [← Subtype.coe_inj] at this exact (isPreconnected_iff_preconnectedSpace.mp hS).constant (hc.restrict_mapsTo _) /-- A version of `IsPreconnected.constant_of_mapsTo` that assumes that the codomain is nonempty and proves that `f` is equal to `const α y` on `S` for some `y ∈ T`. -/ theorem IsPreconnected.eqOn_const_of_mapsTo {S : Set α} (hS : IsPreconnected S) {β} [TopologicalSpace β] {T : Set β} [DiscreteTopology T] {f : α → β} (hc : ContinuousOn f S) (hTm : MapsTo f S T) (hne : T.Nonempty) : ∃ y ∈ T, EqOn f (const α y) S := by rcases S.eq_empty_or_nonempty with (rfl | ⟨x, hx⟩) · exact hne.imp fun _ hy => ⟨hy, eqOn_empty _ _⟩ · exact ⟨f x, hTm hx, fun x' hx' => hS.constant_of_mapsTo hc hTm hx' hx⟩
Topology\ContinuousFunction\Algebra.lean
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Nicolò Cavalleri -/ import Mathlib.Algebra.Algebra.Pi import Mathlib.Algebra.Order.Group.Lattice import Mathlib.Algebra.Periodic import Mathlib.Algebra.Algebra.Subalgebra.Basic import Mathlib.Algebra.Star.StarAlgHom import Mathlib.Tactic.FieldSimp import Mathlib.Topology.Algebra.Module.Basic import Mathlib.Topology.Algebra.InfiniteSum.Basic import Mathlib.Topology.Algebra.Ring.Basic import Mathlib.Topology.Algebra.Star import Mathlib.Topology.Algebra.UniformGroup import Mathlib.Topology.ContinuousFunction.Ordered import Mathlib.Topology.UniformSpace.CompactConvergence /-! # Algebraic structures over continuous functions In this file we define instances of algebraic structures over the type `ContinuousMap α β` (denoted `C(α, β)`) of **bundled** continuous maps from `α` to `β`. For example, `C(α, β)` is a group when `β` is a group, a ring when `β` is a ring, etc. For each type of algebraic structure, we also define an appropriate subobject of `α → β` with carrier `{ f : α → β | Continuous f }`. For example, when `β` is a group, a subgroup `continuousSubgroup α β` of `α → β` is constructed with carrier `{ f : α → β | Continuous f }`. Note that, rather than using the derived algebraic structures on these subobjects (for example, when `β` is a group, the derived group structure on `continuousSubgroup α β`), one should use `C(α, β)` with the appropriate instance of the structure. -/ assert_not_exists StoneCech --attribute [elab_without_expected_type] Continuous.comp namespace ContinuousFunctions variable {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] variable {f g : { f : α → β | Continuous f }} instance : CoeFun { f : α → β | Continuous f } fun _ => α → β := ⟨Subtype.val⟩ end ContinuousFunctions namespace ContinuousMap variable {α : Type*} {β : Type*} {γ : Type*} variable [TopologicalSpace α] [TopologicalSpace β] [TopologicalSpace γ] /-! ### `mul` and `add` -/ @[to_additive] instance instMul [Mul β] [ContinuousMul β] : Mul C(α, β) := ⟨fun f g => ⟨f * g, continuous_mul.comp (f.continuous.prod_mk g.continuous : _)⟩⟩ @[to_additive (attr := norm_cast, simp)] theorem coe_mul [Mul β] [ContinuousMul β] (f g : C(α, β)) : ⇑(f * g) = f * g := rfl @[to_additive (attr := simp)] theorem mul_apply [Mul β] [ContinuousMul β] (f g : C(α, β)) (x : α) : (f * g) x = f x * g x := rfl @[to_additive (attr := simp)] theorem mul_comp [Mul γ] [ContinuousMul γ] (f₁ f₂ : C(β, γ)) (g : C(α, β)) : (f₁ * f₂).comp g = f₁.comp g * f₂.comp g := rfl /-! ### `one` -/ @[to_additive] instance [One β] : One C(α, β) := ⟨const α 1⟩ @[to_additive (attr := norm_cast, simp)] theorem coe_one [One β] : ⇑(1 : C(α, β)) = 1 := rfl @[to_additive (attr := simp)] theorem one_apply [One β] (x : α) : (1 : C(α, β)) x = 1 := rfl @[to_additive (attr := simp)] theorem one_comp [One γ] (g : C(α, β)) : (1 : C(β, γ)).comp g = 1 := rfl /-! ### `Nat.cast` -/ instance [NatCast β] : NatCast C(α, β) := ⟨fun n => ContinuousMap.const _ n⟩ @[simp, norm_cast] theorem coe_natCast [NatCast β] (n : ℕ) : ((n : C(α, β)) : α → β) = n := rfl @[deprecated (since := "2024-04-17")] alias coe_nat_cast := coe_natCast @[simp] theorem natCast_apply [NatCast β] (n : ℕ) (x : α) : (n : C(α, β)) x = n := rfl @[deprecated (since := "2024-04-17")] alias nat_cast_apply := natCast_apply /-! ### `Int.cast` -/ instance [IntCast β] : IntCast C(α, β) := ⟨fun n => ContinuousMap.const _ n⟩ @[simp, norm_cast] theorem coe_intCast [IntCast β] (n : ℤ) : ((n : C(α, β)) : α → β) = n := rfl @[deprecated (since := "2024-04-17")] alias coe_int_cast := coe_intCast @[simp] theorem intCast_apply [IntCast β] (n : ℤ) (x : α) : (n : C(α, β)) x = n := rfl @[deprecated (since := "2024-04-17")] alias int_cast_apply := intCast_apply /-! ### `nsmul` and `pow` -/ instance instNSMul [AddMonoid β] [ContinuousAdd β] : SMul ℕ C(α, β) := ⟨fun n f => ⟨n • ⇑f, f.continuous.nsmul n⟩⟩ @[to_additive existing] instance instPow [Monoid β] [ContinuousMul β] : Pow C(α, β) ℕ := ⟨fun f n => ⟨(⇑f) ^ n, f.continuous.pow n⟩⟩ @[to_additive (attr := norm_cast) (reorder := 7 8)] theorem coe_pow [Monoid β] [ContinuousMul β] (f : C(α, β)) (n : ℕ) : ⇑(f ^ n) = (⇑f) ^ n := rfl @[to_additive (attr := norm_cast)] theorem pow_apply [Monoid β] [ContinuousMul β] (f : C(α, β)) (n : ℕ) (x : α) : (f ^ n) x = f x ^ n := rfl -- don't make auto-generated `coe_nsmul` and `nsmul_apply` simp, as the linter complains they're -- redundant WRT `coe_smul` attribute [simp] coe_pow pow_apply @[to_additive] theorem pow_comp [Monoid γ] [ContinuousMul γ] (f : C(β, γ)) (n : ℕ) (g : C(α, β)) : (f ^ n).comp g = f.comp g ^ n := rfl -- don't make `nsmul_comp` simp as the linter complains it's redundant WRT `smul_comp` attribute [simp] pow_comp /-! ### `inv` and `neg` -/ @[to_additive] instance [Inv β] [ContinuousInv β] : Inv C(α, β) where inv f := ⟨f⁻¹, f.continuous.inv⟩ @[to_additive (attr := simp)] theorem coe_inv [Inv β] [ContinuousInv β] (f : C(α, β)) : ⇑f⁻¹ = (⇑f)⁻¹ := rfl @[to_additive (attr := simp)] theorem inv_apply [Inv β] [ContinuousInv β] (f : C(α, β)) (x : α) : f⁻¹ x = (f x)⁻¹ := rfl @[to_additive (attr := simp)] theorem inv_comp [Inv γ] [ContinuousInv γ] (f : C(β, γ)) (g : C(α, β)) : f⁻¹.comp g = (f.comp g)⁻¹ := rfl /-! ### `div` and `sub` -/ @[to_additive] instance [Div β] [ContinuousDiv β] : Div C(α, β) where div f g := ⟨f / g, f.continuous.div' g.continuous⟩ @[to_additive (attr := norm_cast, simp)] theorem coe_div [Div β] [ContinuousDiv β] (f g : C(α, β)) : ⇑(f / g) = f / g := rfl @[to_additive (attr := simp)] theorem div_apply [Div β] [ContinuousDiv β] (f g : C(α, β)) (x : α) : (f / g) x = f x / g x := rfl @[to_additive (attr := simp)] theorem div_comp [Div γ] [ContinuousDiv γ] (f g : C(β, γ)) (h : C(α, β)) : (f / g).comp h = f.comp h / g.comp h := rfl /-! ### `zpow` and `zsmul` -/ instance instZSMul [AddGroup β] [TopologicalAddGroup β] : SMul ℤ C(α, β) where smul z f := ⟨z • ⇑f, f.continuous.zsmul z⟩ @[to_additive existing] instance instZPow [Group β] [TopologicalGroup β] : Pow C(α, β) ℤ where pow f z := ⟨(⇑f) ^ z, f.continuous.zpow z⟩ @[to_additive (attr := norm_cast) (reorder := 7 8)] theorem coe_zpow [Group β] [TopologicalGroup β] (f : C(α, β)) (z : ℤ) : ⇑(f ^ z) = (⇑f) ^ z := rfl @[to_additive] theorem zpow_apply [Group β] [TopologicalGroup β] (f : C(α, β)) (z : ℤ) (x : α) : (f ^ z) x = f x ^ z := rfl -- don't make auto-generated `coe_zsmul` and `zsmul_apply` simp as the linter complains they're -- redundant WRT `coe_smul` attribute [simp] coe_zpow zpow_apply @[to_additive] theorem zpow_comp [Group γ] [TopologicalGroup γ] (f : C(β, γ)) (z : ℤ) (g : C(α, β)) : (f ^ z).comp g = f.comp g ^ z := rfl -- don't make `zsmul_comp` simp as the linter complains it's redundant WRT `smul_comp` attribute [simp] zpow_comp end ContinuousMap section GroupStructure /-! ### Group structure In this section we show that continuous functions valued in a topological group inherit the structure of a group. -/ section Subtype /-- The `Submonoid` of continuous maps `α → β`. -/ @[to_additive "The `AddSubmonoid` of continuous maps `α → β`. "] def continuousSubmonoid (α : Type*) (β : Type*) [TopologicalSpace α] [TopologicalSpace β] [MulOneClass β] [ContinuousMul β] : Submonoid (α → β) where carrier := { f : α → β | Continuous f } one_mem' := @continuous_const _ _ _ _ 1 mul_mem' fc gc := fc.mul gc /-- The subgroup of continuous maps `α → β`. -/ @[to_additive "The `AddSubgroup` of continuous maps `α → β`. "] def continuousSubgroup (α : Type*) (β : Type*) [TopologicalSpace α] [TopologicalSpace β] [Group β] [TopologicalGroup β] : Subgroup (α → β) := { continuousSubmonoid α β with inv_mem' := fun fc => Continuous.inv fc } end Subtype namespace ContinuousMap variable {α β : Type*} [TopologicalSpace α] [TopologicalSpace β] @[to_additive] instance [Semigroup β] [ContinuousMul β] : Semigroup C(α, β) := coe_injective.semigroup _ coe_mul @[to_additive] instance [CommSemigroup β] [ContinuousMul β] : CommSemigroup C(α, β) := coe_injective.commSemigroup _ coe_mul @[to_additive] instance [MulOneClass β] [ContinuousMul β] : MulOneClass C(α, β) := coe_injective.mulOneClass _ coe_one coe_mul instance [MulZeroClass β] [ContinuousMul β] : MulZeroClass C(α, β) := coe_injective.mulZeroClass _ coe_zero coe_mul instance [SemigroupWithZero β] [ContinuousMul β] : SemigroupWithZero C(α, β) := coe_injective.semigroupWithZero _ coe_zero coe_mul @[to_additive] instance [Monoid β] [ContinuousMul β] : Monoid C(α, β) := coe_injective.monoid _ coe_one coe_mul coe_pow instance [MonoidWithZero β] [ContinuousMul β] : MonoidWithZero C(α, β) := coe_injective.monoidWithZero _ coe_zero coe_one coe_mul coe_pow @[to_additive] instance [CommMonoid β] [ContinuousMul β] : CommMonoid C(α, β) := coe_injective.commMonoid _ coe_one coe_mul coe_pow instance [CommMonoidWithZero β] [ContinuousMul β] : CommMonoidWithZero C(α, β) := coe_injective.commMonoidWithZero _ coe_zero coe_one coe_mul coe_pow @[to_additive] instance [LocallyCompactSpace α] [Mul β] [ContinuousMul β] : ContinuousMul C(α, β) := ⟨by refine continuous_of_continuous_uncurry _ ?_ have h1 : Continuous fun x : (C(α, β) × C(α, β)) × α => x.fst.fst x.snd := continuous_eval.comp (continuous_fst.prod_map continuous_id) have h2 : Continuous fun x : (C(α, β) × C(α, β)) × α => x.fst.snd x.snd := continuous_eval.comp (continuous_snd.prod_map continuous_id) exact h1.mul h2⟩ /-- Coercion to a function as a `MonoidHom`. Similar to `MonoidHom.coeFn`. -/ @[to_additive (attr := simps) "Coercion to a function as an `AddMonoidHom`. Similar to `AddMonoidHom.coeFn`." ] def coeFnMonoidHom [Monoid β] [ContinuousMul β] : C(α, β) →* α → β where toFun f := f map_one' := coe_one map_mul' := coe_mul variable (α) /-- Composition on the left by a (continuous) homomorphism of topological monoids, as a `MonoidHom`. Similar to `MonoidHom.compLeft`. -/ @[to_additive (attr := simps) "Composition on the left by a (continuous) homomorphism of topological `AddMonoid`s, as an `AddMonoidHom`. Similar to `AddMonoidHom.comp_left`."] protected def _root_.MonoidHom.compLeftContinuous {γ : Type*} [Monoid β] [ContinuousMul β] [TopologicalSpace γ] [Monoid γ] [ContinuousMul γ] (g : β →* γ) (hg : Continuous g) : C(α, β) →* C(α, γ) where toFun f := (⟨g, hg⟩ : C(β, γ)).comp f map_one' := ext fun _ => g.map_one map_mul' _ _ := ext fun _ => g.map_mul _ _ variable {α} /-- Composition on the right as a `MonoidHom`. Similar to `MonoidHom.compHom'`. -/ @[to_additive (attr := simps) "Composition on the right as an `AddMonoidHom`. Similar to `AddMonoidHom.compHom'`."] def compMonoidHom' {γ : Type*} [TopologicalSpace γ] [MulOneClass γ] [ContinuousMul γ] (g : C(α, β)) : C(β, γ) →* C(α, γ) where toFun f := f.comp g map_one' := one_comp g map_mul' f₁ f₂ := mul_comp f₁ f₂ g @[to_additive (attr := simp)] theorem coe_prod [CommMonoid β] [ContinuousMul β] {ι : Type*} (s : Finset ι) (f : ι → C(α, β)) : ⇑(∏ i ∈ s, f i) = ∏ i ∈ s, (f i : α → β) := map_prod coeFnMonoidHom f s @[to_additive] theorem prod_apply [CommMonoid β] [ContinuousMul β] {ι : Type*} (s : Finset ι) (f : ι → C(α, β)) (a : α) : (∏ i ∈ s, f i) a = ∏ i ∈ s, f i a := by simp @[to_additive] instance [Group β] [TopologicalGroup β] : Group C(α, β) := coe_injective.group _ coe_one coe_mul coe_inv coe_div coe_pow coe_zpow @[to_additive] instance instCommGroupContinuousMap [CommGroup β] [TopologicalGroup β] : CommGroup C(α, β) := coe_injective.commGroup _ coe_one coe_mul coe_inv coe_div coe_pow coe_zpow @[to_additive] instance [CommGroup β] [TopologicalGroup β] : TopologicalGroup C(α, β) where continuous_mul := by letI : UniformSpace β := TopologicalGroup.toUniformSpace β have : UniformGroup β := comm_topologicalGroup_is_uniform rw [continuous_iff_continuousAt] rintro ⟨f, g⟩ rw [ContinuousAt, tendsto_iff_forall_compact_tendstoUniformlyOn, nhds_prod_eq] exact fun K hK => uniformContinuous_mul.comp_tendstoUniformlyOn ((tendsto_iff_forall_compact_tendstoUniformlyOn.mp Filter.tendsto_id K hK).prod (tendsto_iff_forall_compact_tendstoUniformlyOn.mp Filter.tendsto_id K hK)) continuous_inv := by letI : UniformSpace β := TopologicalGroup.toUniformSpace β have : UniformGroup β := comm_topologicalGroup_is_uniform rw [continuous_iff_continuousAt] intro f rw [ContinuousAt, tendsto_iff_forall_compact_tendstoUniformlyOn] exact fun K hK => uniformContinuous_inv.comp_tendstoUniformlyOn (tendsto_iff_forall_compact_tendstoUniformlyOn.mp Filter.tendsto_id K hK) -- TODO: rewrite the next three lemmas for products and deduce sum case via `to_additive`, once -- definition of `tprod` is in place /-- If `α` is locally compact, and an infinite sum of functions in `C(α, β)` converges to `g` (for the compact-open topology), then the pointwise sum converges to `g x` for all `x ∈ α`. -/ theorem hasSum_apply {γ : Type*} [AddCommMonoid β] [ContinuousAdd β] {f : γ → C(α, β)} {g : C(α, β)} (hf : HasSum f g) (x : α) : HasSum (fun i : γ => f i x) (g x) := by let ev : C(α, β) →+ β := (Pi.evalAddMonoidHom _ x).comp coeFnAddMonoidHom exact hf.map ev (ContinuousMap.continuous_eval_const x) theorem summable_apply [AddCommMonoid β] [ContinuousAdd β] {γ : Type*} {f : γ → C(α, β)} (hf : Summable f) (x : α) : Summable fun i : γ => f i x := (hasSum_apply hf.hasSum x).summable theorem tsum_apply [T2Space β] [AddCommMonoid β] [ContinuousAdd β] {γ : Type*} {f : γ → C(α, β)} (hf : Summable f) (x : α) : ∑' i : γ, f i x = (∑' i : γ, f i) x := (hasSum_apply hf.hasSum x).tsum_eq end ContinuousMap end GroupStructure section RingStructure /-! ### Ring structure In this section we show that continuous functions valued in a topological semiring `R` inherit the structure of a ring. -/ section Subtype /-- The subsemiring of continuous maps `α → β`. -/ def continuousSubsemiring (α : Type*) (R : Type*) [TopologicalSpace α] [TopologicalSpace R] [NonAssocSemiring R] [TopologicalSemiring R] : Subsemiring (α → R) := { continuousAddSubmonoid α R, continuousSubmonoid α R with } /-- The subring of continuous maps `α → β`. -/ def continuousSubring (α : Type*) (R : Type*) [TopologicalSpace α] [TopologicalSpace R] [Ring R] [TopologicalRing R] : Subring (α → R) := { continuousAddSubgroup α R, continuousSubsemiring α R with } end Subtype namespace ContinuousMap instance {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] [NonUnitalNonAssocSemiring β] [TopologicalSemiring β] : NonUnitalNonAssocSemiring C(α, β) := coe_injective.nonUnitalNonAssocSemiring _ coe_zero coe_add coe_mul coe_nsmul instance {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] [NonUnitalSemiring β] [TopologicalSemiring β] : NonUnitalSemiring C(α, β) := coe_injective.nonUnitalSemiring _ coe_zero coe_add coe_mul coe_nsmul instance {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] [AddMonoidWithOne β] [ContinuousAdd β] : AddMonoidWithOne C(α, β) := coe_injective.addMonoidWithOne _ coe_zero coe_one coe_add coe_nsmul coe_natCast instance {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] [NonAssocSemiring β] [TopologicalSemiring β] : NonAssocSemiring C(α, β) := coe_injective.nonAssocSemiring _ coe_zero coe_one coe_add coe_mul coe_nsmul coe_natCast instance {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] [Semiring β] [TopologicalSemiring β] : Semiring C(α, β) := coe_injective.semiring _ coe_zero coe_one coe_add coe_mul coe_nsmul coe_pow coe_natCast instance {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] [NonUnitalNonAssocRing β] [TopologicalRing β] : NonUnitalNonAssocRing C(α, β) := coe_injective.nonUnitalNonAssocRing _ coe_zero coe_add coe_mul coe_neg coe_sub coe_nsmul coe_zsmul instance {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] [NonUnitalRing β] [TopologicalRing β] : NonUnitalRing C(α, β) := coe_injective.nonUnitalRing _ coe_zero coe_add coe_mul coe_neg coe_sub coe_nsmul coe_zsmul instance {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] [NonAssocRing β] [TopologicalRing β] : NonAssocRing C(α, β) := coe_injective.nonAssocRing _ coe_zero coe_one coe_add coe_mul coe_neg coe_sub coe_nsmul coe_zsmul coe_natCast coe_intCast instance instRing {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] [Ring β] [TopologicalRing β] : Ring C(α, β) := coe_injective.ring _ coe_zero coe_one coe_add coe_mul coe_neg coe_sub coe_nsmul coe_zsmul coe_pow coe_natCast coe_intCast instance {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] [NonUnitalCommSemiring β] [TopologicalSemiring β] : NonUnitalCommSemiring C(α, β) := coe_injective.nonUnitalCommSemiring _ coe_zero coe_add coe_mul coe_nsmul instance {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] [CommSemiring β] [TopologicalSemiring β] : CommSemiring C(α, β) := coe_injective.commSemiring _ coe_zero coe_one coe_add coe_mul coe_nsmul coe_pow coe_natCast instance {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] [NonUnitalCommRing β] [TopologicalRing β] : NonUnitalCommRing C(α, β) := coe_injective.nonUnitalCommRing _ coe_zero coe_add coe_mul coe_neg coe_sub coe_nsmul coe_zsmul instance {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] [CommRing β] [TopologicalRing β] : CommRing C(α, β) := coe_injective.commRing _ coe_zero coe_one coe_add coe_mul coe_neg coe_sub coe_nsmul coe_zsmul coe_pow coe_natCast coe_intCast instance {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] [LocallyCompactSpace α] [NonUnitalSemiring β] [TopologicalSemiring β] : TopologicalSemiring C(α, β) where instance {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] [LocallyCompactSpace α] [NonUnitalRing β] [TopologicalRing β] : TopologicalRing C(α, β) where /-- Composition on the left by a (continuous) homomorphism of topological semirings, as a `RingHom`. Similar to `RingHom.compLeft`. -/ @[simps!] protected def _root_.RingHom.compLeftContinuous (α : Type*) {β : Type*} {γ : Type*} [TopologicalSpace α] [TopologicalSpace β] [Semiring β] [TopologicalSemiring β] [TopologicalSpace γ] [Semiring γ] [TopologicalSemiring γ] (g : β →+* γ) (hg : Continuous g) : C(α, β) →+* C(α, γ) := { g.toMonoidHom.compLeftContinuous α hg, g.toAddMonoidHom.compLeftContinuous α hg with } /-- Coercion to a function as a `RingHom`. -/ @[simps!] def coeFnRingHom {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] [Semiring β] [TopologicalSemiring β] : C(α, β) →+* α → β := { (coeFnMonoidHom : C(α, β) →* _), (coeFnAddMonoidHom : C(α, β) →+ _) with } end ContinuousMap end RingStructure attribute [local ext] Subtype.eq section ModuleStructure /-! ### Module structure In this section we show that continuous functions valued in a topological module `M` over a topological semiring `R` inherit the structure of a module. -/ section Subtype variable (α : Type*) [TopologicalSpace α] variable (R : Type*) [Semiring R] variable (M : Type*) [TopologicalSpace M] [AddCommGroup M] variable [Module R M] [ContinuousConstSMul R M] [TopologicalAddGroup M] /-- The `R`-submodule of continuous maps `α → M`. -/ def continuousSubmodule : Submodule R (α → M) := { continuousAddSubgroup α M with carrier := { f : α → M | Continuous f } smul_mem' := fun c _ hf => hf.const_smul c } end Subtype namespace ContinuousMap variable {α β : Type*} [TopologicalSpace α] [TopologicalSpace β] {R R₁ : Type*} {M : Type*} [TopologicalSpace M] {M₂ : Type*} [TopologicalSpace M₂] @[to_additive] instance instSMul [SMul R M] [ContinuousConstSMul R M] : SMul R C(α, M) := ⟨fun r f => ⟨r • ⇑f, f.continuous.const_smul r⟩⟩ @[to_additive] instance [LocallyCompactSpace α] [SMul R M] [ContinuousConstSMul R M] : ContinuousConstSMul R C(α, M) := ⟨fun γ => continuous_of_continuous_uncurry _ (continuous_eval.const_smul γ)⟩ @[to_additive] instance [LocallyCompactSpace α] [TopologicalSpace R] [SMul R M] [ContinuousSMul R M] : ContinuousSMul R C(α, M) := ⟨by refine continuous_of_continuous_uncurry _ ?_ have h : Continuous fun x : (R × C(α, M)) × α => x.fst.snd x.snd := continuous_eval.comp (continuous_snd.prod_map continuous_id) exact (continuous_fst.comp continuous_fst).smul h⟩ @[to_additive (attr := simp, norm_cast)] theorem coe_smul [SMul R M] [ContinuousConstSMul R M] (c : R) (f : C(α, M)) : ⇑(c • f) = c • ⇑f := rfl @[to_additive] theorem smul_apply [SMul R M] [ContinuousConstSMul R M] (c : R) (f : C(α, M)) (a : α) : (c • f) a = c • f a := rfl @[to_additive (attr := simp)] theorem smul_comp [SMul R M] [ContinuousConstSMul R M] (r : R) (f : C(β, M)) (g : C(α, β)) : (r • f).comp g = r • f.comp g := rfl @[to_additive] instance [SMul R M] [ContinuousConstSMul R M] [SMul R₁ M] [ContinuousConstSMul R₁ M] [SMulCommClass R R₁ M] : SMulCommClass R R₁ C(α, M) where smul_comm _ _ _ := ext fun _ => smul_comm _ _ _ instance [SMul R M] [ContinuousConstSMul R M] [SMul R₁ M] [ContinuousConstSMul R₁ M] [SMul R R₁] [IsScalarTower R R₁ M] : IsScalarTower R R₁ C(α, M) where smul_assoc _ _ _ := ext fun _ => smul_assoc _ _ _ instance [SMul R M] [SMul Rᵐᵒᵖ M] [ContinuousConstSMul R M] [IsCentralScalar R M] : IsCentralScalar R C(α, M) where op_smul_eq_smul _ _ := ext fun _ => op_smul_eq_smul _ _ instance [Monoid R] [MulAction R M] [ContinuousConstSMul R M] : MulAction R C(α, M) := Function.Injective.mulAction _ coe_injective coe_smul instance [Monoid R] [AddMonoid M] [DistribMulAction R M] [ContinuousAdd M] [ContinuousConstSMul R M] : DistribMulAction R C(α, M) := Function.Injective.distribMulAction coeFnAddMonoidHom coe_injective coe_smul variable [Semiring R] [AddCommMonoid M] [AddCommMonoid M₂] variable [ContinuousAdd M] [Module R M] [ContinuousConstSMul R M] variable [ContinuousAdd M₂] [Module R M₂] [ContinuousConstSMul R M₂] instance module : Module R C(α, M) := Function.Injective.module R coeFnAddMonoidHom coe_injective coe_smul variable (R) /-- Composition on the left by a continuous linear map, as a `LinearMap`. Similar to `LinearMap.compLeft`. -/ @[simps] protected def _root_.ContinuousLinearMap.compLeftContinuous (α : Type*) [TopologicalSpace α] (g : M →L[R] M₂) : C(α, M) →ₗ[R] C(α, M₂) := { g.toLinearMap.toAddMonoidHom.compLeftContinuous α g.continuous with map_smul' := fun c _ => ext fun _ => g.map_smul' c _ } /-- Coercion to a function as a `LinearMap`. -/ @[simps] def coeFnLinearMap : C(α, M) →ₗ[R] α → M := { (coeFnAddMonoidHom : C(α, M) →+ _) with map_smul' := coe_smul } end ContinuousMap end ModuleStructure section AlgebraStructure /-! ### Algebra structure In this section we show that continuous functions valued in a topological algebra `A` over a ring `R` inherit the structure of an algebra. Note that the hypothesis that `A` is a topological algebra is obtained by requiring that `A` be both a `ContinuousSMul` and a `TopologicalSemiring`. -/ section Subtype variable {α : Type*} [TopologicalSpace α] {R : Type*} [CommSemiring R] {A : Type*} [TopologicalSpace A] [Semiring A] [Algebra R A] [TopologicalSemiring A] /-- The `R`-subalgebra of continuous maps `α → A`. -/ def continuousSubalgebra : Subalgebra R (α → A) := { continuousSubsemiring α A with carrier := { f : α → A | Continuous f } algebraMap_mem' := fun r => (continuous_const : Continuous fun _ : α => algebraMap R A r) } end Subtype section ContinuousMap variable {α : Type*} [TopologicalSpace α] {R : Type*} [CommSemiring R] {A : Type*} [TopologicalSpace A] [Semiring A] [Algebra R A] [TopologicalSemiring A] {A₂ : Type*} [TopologicalSpace A₂] [Semiring A₂] [Algebra R A₂] [TopologicalSemiring A₂] /-- Continuous constant functions as a `RingHom`. -/ def ContinuousMap.C : R →+* C(α, A) where toFun := fun c : R => ⟨fun _ : α => (algebraMap R A) c, continuous_const⟩ map_one' := by ext _; exact (algebraMap R A).map_one map_mul' c₁ c₂ := by ext _; exact (algebraMap R A).map_mul _ _ map_zero' := by ext _; exact (algebraMap R A).map_zero map_add' c₁ c₂ := by ext _; exact (algebraMap R A).map_add _ _ @[simp] theorem ContinuousMap.C_apply (r : R) (a : α) : ContinuousMap.C r a = algebraMap R A r := rfl instance ContinuousMap.algebra : Algebra R C(α, A) where toRingHom := ContinuousMap.C commutes' c f := by ext x; exact Algebra.commutes' _ _ smul_def' c f := by ext x; exact Algebra.smul_def' _ _ variable (R) /-- Composition on the left by a (continuous) homomorphism of topological `R`-algebras, as an `AlgHom`. Similar to `AlgHom.compLeft`. -/ @[simps!] protected def AlgHom.compLeftContinuous {α : Type*} [TopologicalSpace α] (g : A →ₐ[R] A₂) (hg : Continuous g) : C(α, A) →ₐ[R] C(α, A₂) := { g.toRingHom.compLeftContinuous α hg with commutes' := fun _ => ContinuousMap.ext fun _ => g.commutes' _ } variable (A) /-- Precomposition of functions into a topological semiring by a continuous map is an algebra homomorphism. -/ @[simps] def ContinuousMap.compRightAlgHom {α β : Type*} [TopologicalSpace α] [TopologicalSpace β] (f : C(α, β)) : C(β, A) →ₐ[R] C(α, A) where toFun g := g.comp f map_zero' := ext fun _ ↦ rfl map_add' _ _ := ext fun _ ↦ rfl map_one' := ext fun _ ↦ rfl map_mul' _ _ := ext fun _ ↦ rfl commutes' _ := ext fun _ ↦ rfl variable {A} /-- Coercion to a function as an `AlgHom`. -/ @[simps!] def ContinuousMap.coeFnAlgHom : C(α, A) →ₐ[R] α → A := { (ContinuousMap.coeFnRingHom : C(α, A) →+* _) with commutes' := fun _ => rfl } variable {R} /-- A version of `Set.SeparatesPoints` for subalgebras of the continuous functions, used for stating the Stone-Weierstrass theorem. -/ abbrev Subalgebra.SeparatesPoints (s : Subalgebra R C(α, A)) : Prop := Set.SeparatesPoints ((fun f : C(α, A) => (f : α → A)) '' (s : Set C(α, A))) theorem Subalgebra.separatesPoints_monotone : Monotone fun s : Subalgebra R C(α, A) => s.SeparatesPoints := fun s s' r h x y n => by obtain ⟨f, m, w⟩ := h n rcases m with ⟨f, ⟨m, rfl⟩⟩ exact ⟨_, ⟨f, ⟨r m, rfl⟩⟩, w⟩ @[simp] theorem algebraMap_apply (k : R) (a : α) : algebraMap R C(α, A) k a = k • (1 : A) := by rw [Algebra.algebraMap_eq_smul_one] rfl variable {𝕜 : Type*} [TopologicalSpace 𝕜] variable (s : Set C(α, 𝕜)) (f : s) (x : α) /-- A set of continuous maps "separates points strongly" if for each pair of distinct points there is a function with specified values on them. We give a slightly unusual formulation, where the specified values are given by some function `v`, and we ask `f x = v x ∧ f y = v y`. This avoids needing a hypothesis `x ≠ y`. In fact, this definition would work perfectly well for a set of non-continuous functions, but as the only current use case is in the Stone-Weierstrass theorem, writing it this way avoids having to deal with casts inside the set. (This may need to change if we do Stone-Weierstrass on non-compact spaces, where the functions would be continuous functions vanishing at infinity.) -/ def Set.SeparatesPointsStrongly (s : Set C(α, 𝕜)) : Prop := ∀ (v : α → 𝕜) (x y : α), ∃ f ∈ s, (f x : 𝕜) = v x ∧ f y = v y variable [Field 𝕜] [TopologicalRing 𝕜] /-- Working in continuous functions into a topological field, a subalgebra of functions that separates points also separates points strongly. By the hypothesis, we can find a function `f` so `f x ≠ f y`. By an affine transformation in the field we can arrange so that `f x = a` and `f x = b`. -/ theorem Subalgebra.SeparatesPoints.strongly {s : Subalgebra 𝕜 C(α, 𝕜)} (h : s.SeparatesPoints) : (s : Set C(α, 𝕜)).SeparatesPointsStrongly := fun v x y => by by_cases n : x = y · subst n exact ⟨_, (v x • (1 : s) : s).prop, mul_one _, mul_one _⟩ obtain ⟨_, ⟨f, hf, rfl⟩, hxy⟩ := h n replace hxy : f x - f y ≠ 0 := sub_ne_zero_of_ne hxy let a := v x let b := v y let f' : s := ((b - a) * (f x - f y)⁻¹) • (algebraMap _ s (f x) - (⟨f, hf⟩ : s)) + algebraMap _ s a refine ⟨f', f'.prop, ?_, ?_⟩ · simp [f'] · simp [f', inv_mul_cancel_right₀ hxy] end ContinuousMap instance ContinuousMap.subsingleton_subalgebra (α : Type*) [TopologicalSpace α] (R : Type*) [CommSemiring R] [TopologicalSpace R] [TopologicalSemiring R] [Subsingleton α] : Subsingleton (Subalgebra R C(α, R)) := ⟨fun s₁ s₂ => by cases isEmpty_or_nonempty α · have : Subsingleton C(α, R) := DFunLike.coe_injective.subsingleton subsingleton · inhabit α ext f have h : f = algebraMap R C(α, R) (f default) := by ext x' simp only [mul_one, Algebra.id.smul_eq_mul, algebraMap_apply] congr simp [eq_iff_true_of_subsingleton] rw [h] simp only [Subalgebra.algebraMap_mem]⟩ end AlgebraStructure section ModuleOverContinuousFunctions /-! ### Structure as module over scalar functions If `M` is a module over `R`, then we show that the space of continuous functions from `α` to `M` is naturally a module over the ring of continuous functions from `α` to `R`. -/ namespace ContinuousMap instance instSMul' {α : Type*} [TopologicalSpace α] {R : Type*} [Semiring R] [TopologicalSpace R] {M : Type*} [TopologicalSpace M] [AddCommMonoid M] [Module R M] [ContinuousSMul R M] : SMul C(α, R) C(α, M) := ⟨fun f g => ⟨fun x => f x • g x, Continuous.smul f.2 g.2⟩⟩ instance module' {α : Type*} [TopologicalSpace α] (R : Type*) [Semiring R] [TopologicalSpace R] [TopologicalSemiring R] (M : Type*) [TopologicalSpace M] [AddCommMonoid M] [ContinuousAdd M] [Module R M] [ContinuousSMul R M] : Module C(α, R) C(α, M) where smul := (· • ·) smul_add c f g := by ext x; exact smul_add (c x) (f x) (g x) add_smul c₁ c₂ f := by ext x; exact add_smul (c₁ x) (c₂ x) (f x) mul_smul c₁ c₂ f := by ext x; exact mul_smul (c₁ x) (c₂ x) (f x) one_smul f := by ext x; exact one_smul R (f x) zero_smul f := by ext x; exact zero_smul _ _ smul_zero r := by ext x; exact smul_zero _ end ContinuousMap end ModuleOverContinuousFunctions /-! We now provide formulas for `f ⊓ g` and `f ⊔ g`, where `f g : C(α, β)`, in terms of `ContinuousMap.abs`. -/ namespace ContinuousMap section Lattice variable {α : Type*} [TopologicalSpace α] variable {β : Type*} [TopologicalSpace β] /-! `C(α, β)`is a lattice ordered group -/ @[to_additive] instance instCovariantClass_mul_le_left [PartialOrder β] [Mul β] [ContinuousMul β] [CovariantClass β β (· * ·) (· ≤ ·)] : CovariantClass C(α, β) C(α, β) (· * ·) (· ≤ ·) := ⟨fun _ _ _ hg₁₂ x => mul_le_mul_left' (hg₁₂ x) _⟩ @[to_additive] instance instCovariantClass_mul_le_right [PartialOrder β] [Mul β] [ContinuousMul β] [CovariantClass β β (Function.swap (· * ·)) (· ≤ ·)] : CovariantClass C(α, β) C(α, β) (Function.swap (· * ·)) (· ≤ ·) := ⟨fun _ _ _ hg₁₂ x => mul_le_mul_right' (hg₁₂ x) _⟩ variable [Group β] [TopologicalGroup β] [Lattice β] [TopologicalLattice β] @[to_additive (attr := simp, norm_cast)] lemma coe_mabs (f : C(α, β)) : ⇑|f|ₘ = |⇑f|ₘ := rfl @[to_additive (attr := simp)] lemma mabs_apply (f : C(α, β)) (x : α) : |f|ₘ x = |f x|ₘ := rfl end Lattice /-! ### Star structure If `β` has a continuous star operation, we put a star structure on `C(α, β)` by using the star operation pointwise. If `β` is a ⋆-ring, then `C(α, β)` inherits a ⋆-ring structure. If `β` is a ⋆-ring and a ⋆-module over `R`, then the space of continuous functions from `α` to `β` is a ⋆-module over `R`. -/ section StarStructure variable {R α β : Type*} variable [TopologicalSpace α] [TopologicalSpace β] section Star variable [Star β] [ContinuousStar β] instance : Star C(α, β) where star f := starContinuousMap.comp f @[simp] theorem coe_star (f : C(α, β)) : ⇑(star f) = star (⇑f) := rfl @[simp] theorem star_apply (f : C(α, β)) (x : α) : star f x = star (f x) := rfl instance instTrivialStar [TrivialStar β] : TrivialStar C(α, β) where star_trivial _ := ext fun _ => star_trivial _ end Star instance [InvolutiveStar β] [ContinuousStar β] : InvolutiveStar C(α, β) where star_involutive _ := ext fun _ => star_star _ instance starAddMonoid [AddMonoid β] [ContinuousAdd β] [StarAddMonoid β] [ContinuousStar β] : StarAddMonoid C(α, β) where star_add _ _ := ext fun _ => star_add _ _ instance starMul [Mul β] [ContinuousMul β] [StarMul β] [ContinuousStar β] : StarMul C(α, β) where star_mul _ _ := ext fun _ => star_mul _ _ instance [NonUnitalNonAssocSemiring β] [TopologicalSemiring β] [StarRing β] [ContinuousStar β] : StarRing C(α, β) := { ContinuousMap.starAddMonoid, ContinuousMap.starMul with } instance [Star R] [Star β] [SMul R β] [StarModule R β] [ContinuousStar β] [ContinuousConstSMul R β] : StarModule R C(α, β) where star_smul _ _ := ext fun _ => star_smul _ _ end StarStructure section Precomposition variable {X Y Z : Type*} [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] variable (𝕜 : Type*) [CommSemiring 𝕜] variable (A : Type*) [TopologicalSpace A] [Semiring A] [TopologicalSemiring A] [Star A] variable [ContinuousStar A] [Algebra 𝕜 A] /-- The functorial map taking `f : C(X, Y)` to `C(Y, A) →⋆ₐ[𝕜] C(X, A)` given by pre-composition with the continuous function `f`. See `ContinuousMap.compMonoidHom'` and `ContinuousMap.compAddMonoidHom'`, `ContinuousMap.compRightAlgHom` for bundlings of pre-composition into a `MonoidHom`, an `AddMonoidHom` and an `AlgHom`, respectively, under suitable assumptions on `A`. -/ @[simps] def compStarAlgHom' (f : C(X, Y)) : C(Y, A) →⋆ₐ[𝕜] C(X, A) where toFun g := g.comp f map_one' := one_comp _ map_mul' _ _ := rfl map_zero' := zero_comp f map_add' _ _ := rfl commutes' _ := rfl map_star' _ := rfl /-- `ContinuousMap.compStarAlgHom'` sends the identity continuous map to the identity `StarAlgHom` -/ theorem compStarAlgHom'_id : compStarAlgHom' 𝕜 A (ContinuousMap.id X) = StarAlgHom.id 𝕜 C(X, A) := StarAlgHom.ext fun _ => ContinuousMap.ext fun _ => rfl /-- `ContinuousMap.compStarAlgHom'` is functorial. -/ theorem compStarAlgHom'_comp (g : C(Y, Z)) (f : C(X, Y)) : compStarAlgHom' 𝕜 A (g.comp f) = (compStarAlgHom' 𝕜 A f).comp (compStarAlgHom' 𝕜 A g) := StarAlgHom.ext fun _ => ContinuousMap.ext fun _ => rfl end Precomposition section Postcomposition variable (X : Type*) {𝕜 A B C : Type*} [TopologicalSpace X] [CommSemiring 𝕜] variable [TopologicalSpace A] [Semiring A] [TopologicalSemiring A] [Star A] variable [ContinuousStar A] [Algebra 𝕜 A] variable [TopologicalSpace B] [Semiring B] [TopologicalSemiring B] [Star B] variable [ContinuousStar B] [Algebra 𝕜 B] variable [TopologicalSpace C] [Semiring C] [TopologicalSemiring C] [Star C] variable [ContinuousStar C] [Algebra 𝕜 C] /-- Post-composition with a continuous star algebra homomorphism is a star algebra homomorphism between spaces of continuous maps. -/ @[simps] def compStarAlgHom (φ : A →⋆ₐ[𝕜] B) (hφ : Continuous φ) : C(X, A) →⋆ₐ[𝕜] C(X, B) where toFun f := (⟨φ, hφ⟩ : C(A, B)).comp f map_one' := ext fun _ => map_one φ map_mul' f g := ext fun x => map_mul φ (f x) (g x) map_zero' := ext fun _ => map_zero φ map_add' f g := ext fun x => map_add φ (f x) (g x) commutes' r := ext fun _x => AlgHomClass.commutes φ r map_star' f := ext fun x => map_star φ (f x) /-- `ContinuousMap.compStarAlgHom` sends the identity `StarAlgHom` on `A` to the identity `StarAlgHom` on `C(X, A)`. -/ lemma compStarAlgHom_id : compStarAlgHom X (.id 𝕜 A) continuous_id = .id 𝕜 C(X, A) := rfl /-- `ContinuousMap.compStarAlgHom` is functorial. -/ lemma compStarAlgHom_comp (φ : A →⋆ₐ[𝕜] B) (ψ : B →⋆ₐ[𝕜] C) (hφ : Continuous φ) (hψ : Continuous ψ) : compStarAlgHom X (ψ.comp φ) (hψ.comp hφ) = (compStarAlgHom X ψ hψ).comp (compStarAlgHom X φ hφ) := rfl end Postcomposition section Periodicity variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] /-! ### Summing translates of a function -/ /-- Summing the translates of `f` by `ℤ • p` gives a map which is periodic with period `p`. (This is true without any convergence conditions, since if the sum doesn't converge it is taken to be the zero map, which is periodic.) -/ theorem periodic_tsum_comp_add_zsmul [AddCommGroup X] [TopologicalAddGroup X] [AddCommMonoid Y] [ContinuousAdd Y] [T2Space Y] (f : C(X, Y)) (p : X) : Function.Periodic (⇑(∑' n : ℤ, f.comp (ContinuousMap.addRight (n • p)))) p := by intro x by_cases h : Summable fun n : ℤ => f.comp (ContinuousMap.addRight (n • p)) · convert congr_arg (fun f : C(X, Y) => f x) ((Equiv.addRight (1 : ℤ)).tsum_eq _) using 1 -- Porting note: in mathlib3 the proof from here was: -- simp_rw [← tsum_apply h, ← tsum_apply ((equiv.add_right (1 : ℤ)).summable_iff.mpr h), -- equiv.coe_add_right, comp_apply, coe_add_right, add_one_zsmul, add_comm (_ • p) p, -- ← add_assoc] -- However now the second `← tsum_apply` doesn't fire unless we use `erw`. simp_rw [← tsum_apply h] erw [← tsum_apply ((Equiv.addRight (1 : ℤ)).summable_iff.mpr h)] simp [coe_addRight, add_one_zsmul, add_comm (_ • p) p, ← add_assoc] · rw [tsum_eq_zero_of_not_summable h] simp only [coe_zero, Pi.zero_apply] end Periodicity end ContinuousMap namespace Homeomorph variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] variable (𝕜 : Type*) [CommSemiring 𝕜] variable (A : Type*) [TopologicalSpace A] [Semiring A] [TopologicalSemiring A] [StarRing A] variable [ContinuousStar A] [Algebra 𝕜 A] /-- `ContinuousMap.compStarAlgHom'` as a `StarAlgEquiv` when the continuous map `f` is actually a homeomorphism. -/ @[simps] def compStarAlgEquiv' (f : X ≃ₜ Y) : C(Y, A) ≃⋆ₐ[𝕜] C(X, A) := { f.toContinuousMap.compStarAlgHom' 𝕜 A with toFun := (f : C(X, Y)).compStarAlgHom' 𝕜 A invFun := (f.symm : C(Y, X)).compStarAlgHom' 𝕜 A left_inv := fun g => by simp only [ContinuousMap.compStarAlgHom'_apply, ContinuousMap.comp_assoc, toContinuousMap_comp_symm, ContinuousMap.comp_id] right_inv := fun g => by simp only [ContinuousMap.compStarAlgHom'_apply, ContinuousMap.comp_assoc, symm_comp_toContinuousMap, ContinuousMap.comp_id] map_smul' := fun k a => map_smul (f.toContinuousMap.compStarAlgHom' 𝕜 A) k a } end Homeomorph /-! ### Evaluation as a bundled map -/ variable {X : Type*} (S R : Type*) [TopologicalSpace X] [CommSemiring S] [CommSemiring R] variable [Algebra S R] [TopologicalSpace R] [TopologicalSemiring R] /-- Evaluation of continuous maps at a point, bundled as an algebra homomorphism. -/ @[simps] def ContinuousMap.evalAlgHom (x : X) : C(X, R) →ₐ[S] R where toFun f := f x map_zero' := rfl map_one' := rfl map_add' _ _ := rfl map_mul' _ _ := rfl commutes' _ := rfl /-- Evaluation of continuous maps at a point, bundled as a star algebra homomorphism. -/ @[simps!] def ContinuousMap.evalStarAlgHom [StarRing R] [ContinuousStar R] (x : X) : C(X, R) →⋆ₐ[S] R := { ContinuousMap.evalAlgHom S R x with map_star' := fun _ => rfl }
Topology\ContinuousFunction\Basic.lean
/- Copyright (c) 2020 Nicolò Cavalleri. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nicolò Cavalleri -/ import Mathlib.Data.Set.UnionLift import Mathlib.Topology.Homeomorph /-! # Continuous bundled maps In this file we define the type `ContinuousMap` of continuous bundled maps. We use the `DFunLike` design, so each type of morphisms has a companion typeclass which is meant to be satisfied by itself and all stricter types. -/ open Function open scoped Topology /-- The type of continuous maps from `α` to `β`. When possible, instead of parametrizing results over `(f : C(α, β))`, you should parametrize over `{F : Type*} [ContinuousMapClass F α β] (f : F)`. When you extend this structure, make sure to extend `ContinuousMapClass`. -/ structure ContinuousMap (α β : Type*) [TopologicalSpace α] [TopologicalSpace β] where /-- The function `α → β` -/ protected toFun : α → β /-- Proposition that `toFun` is continuous -/ protected continuous_toFun : Continuous toFun := by continuity /-- The type of continuous maps from `α` to `β`. -/ notation "C(" α ", " β ")" => ContinuousMap α β section /-- `ContinuousMapClass F α β` states that `F` is a type of continuous maps. You should extend this class when you extend `ContinuousMap`. -/ class ContinuousMapClass (F α β : Type*) [TopologicalSpace α] [TopologicalSpace β] [FunLike F α β] : Prop where /-- Continuity -/ map_continuous (f : F) : Continuous f end export ContinuousMapClass (map_continuous) attribute [continuity, fun_prop] map_continuous section ContinuousMapClass variable {F α β : Type*} [TopologicalSpace α] [TopologicalSpace β] [FunLike F α β] variable [ContinuousMapClass F α β] theorem map_continuousAt (f : F) (a : α) : ContinuousAt f a := (map_continuous f).continuousAt theorem map_continuousWithinAt (f : F) (s : Set α) (a : α) : ContinuousWithinAt f s a := (map_continuous f).continuousWithinAt /-- Coerce a bundled morphism with a `ContinuousMapClass` instance to a `ContinuousMap`. -/ @[coe] def toContinuousMap (f : F) : C(α, β) := ⟨f, map_continuous f⟩ instance : CoeTC F C(α, β) := ⟨toContinuousMap⟩ end ContinuousMapClass /-! ### Continuous maps-/ namespace ContinuousMap variable {α β γ δ : Type*} [TopologicalSpace α] [TopologicalSpace β] [TopologicalSpace γ] [TopologicalSpace δ] instance funLike : FunLike C(α, β) α β where coe := ContinuousMap.toFun coe_injective' f g h := by cases f; cases g; congr instance toContinuousMapClass : ContinuousMapClass C(α, β) α β where map_continuous := ContinuousMap.continuous_toFun @[simp] theorem toFun_eq_coe {f : C(α, β)} : f.toFun = (f : α → β) := rfl instance : CanLift (α → β) C(α, β) DFunLike.coe Continuous := ⟨fun f hf ↦ ⟨⟨f, hf⟩, rfl⟩⟩ /-- See note [custom simps projection]. -/ def Simps.apply (f : C(α, β)) : α → β := f -- this must come after the coe_to_fun definition initialize_simps_projections ContinuousMap (toFun → apply) @[simp] -- Porting note: removed `norm_cast` attribute protected theorem coe_coe {F : Type*} [FunLike F α β] [ContinuousMapClass F α β] (f : F) : ⇑(f : C(α, β)) = f := rfl @[ext] theorem ext {f g : C(α, β)} (h : ∀ a, f a = g a) : f = g := DFunLike.ext _ _ h /-- Copy of a `ContinuousMap` with a new `toFun` equal to the old one. Useful to fix definitional equalities. -/ protected def copy (f : C(α, β)) (f' : α → β) (h : f' = f) : C(α, β) where toFun := f' continuous_toFun := h.symm ▸ f.continuous_toFun @[simp] theorem coe_copy (f : C(α, β)) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' := rfl theorem copy_eq (f : C(α, β)) (f' : α → β) (h : f' = f) : f.copy f' h = f := DFunLike.ext' h variable {f g : C(α, β)} /-- Deprecated. Use `map_continuous` instead. -/ protected theorem continuous (f : C(α, β)) : Continuous f := f.continuous_toFun @[continuity] theorem continuous_set_coe (s : Set C(α, β)) (f : s) : Continuous (f : α → β) := f.1.continuous /-- Deprecated. Use `map_continuousAt` instead. -/ protected theorem continuousAt (f : C(α, β)) (x : α) : ContinuousAt f x := f.continuous.continuousAt /-- Deprecated. Use `DFunLike.congr_fun` instead. -/ protected theorem congr_fun {f g : C(α, β)} (H : f = g) (x : α) : f x = g x := H ▸ rfl /-- Deprecated. Use `DFunLike.congr_arg` instead. -/ protected theorem congr_arg (f : C(α, β)) {x y : α} (h : x = y) : f x = f y := h ▸ rfl theorem coe_injective : @Function.Injective C(α, β) (α → β) (↑) := fun f g h => by cases f; cases g; congr @[simp] theorem coe_mk (f : α → β) (h : Continuous f) : ⇑(⟨f, h⟩ : C(α, β)) = f := rfl theorem map_specializes (f : C(α, β)) {x y : α} (h : x ⤳ y) : f x ⤳ f y := h.map f.2 section variable (α β) /-- The continuous functions from `α` to `β` are the same as the plain functions when `α` is discrete. -/ @[simps] def equivFnOfDiscrete [DiscreteTopology α] : C(α, β) ≃ (α → β) := ⟨fun f => f, fun f => ⟨f, continuous_of_discreteTopology⟩, fun _ => by ext; rfl, fun _ => by ext; rfl⟩ end variable (α) /-- The identity as a continuous map. -/ protected def id : C(α, α) where toFun := id @[simp] theorem coe_id : ⇑(ContinuousMap.id α) = id := rfl /-- The constant map as a continuous map. -/ def const (b : β) : C(α, β) where toFun := fun _ : α => b @[simp] theorem coe_const (b : β) : ⇑(const α b) = Function.const α b := rfl /-- `Function.const α b` as a bundled continuous function of `b`. -/ @[simps (config := .asFn)] def constPi : C(β, α → β) where toFun b := Function.const α b instance [Inhabited β] : Inhabited C(α, β) := ⟨const α default⟩ variable {α} @[simp] theorem id_apply (a : α) : ContinuousMap.id α a = a := rfl @[simp] theorem const_apply (b : β) (a : α) : const α b a = b := rfl /-- The composition of continuous maps, as a continuous map. -/ def comp (f : C(β, γ)) (g : C(α, β)) : C(α, γ) where toFun := f ∘ g @[simp] theorem coe_comp (f : C(β, γ)) (g : C(α, β)) : ⇑(comp f g) = f ∘ g := rfl @[simp] theorem comp_apply (f : C(β, γ)) (g : C(α, β)) (a : α) : comp f g a = f (g a) := rfl @[simp] theorem comp_assoc (f : C(γ, δ)) (g : C(β, γ)) (h : C(α, β)) : (f.comp g).comp h = f.comp (g.comp h) := rfl @[simp] theorem id_comp (f : C(α, β)) : (ContinuousMap.id _).comp f = f := ext fun _ => rfl @[simp] theorem comp_id (f : C(α, β)) : f.comp (ContinuousMap.id _) = f := ext fun _ => rfl @[simp] theorem const_comp (c : γ) (f : C(α, β)) : (const β c).comp f = const α c := ext fun _ => rfl @[simp] theorem comp_const (f : C(β, γ)) (b : β) : f.comp (const α b) = const α (f b) := ext fun _ => rfl @[simp] theorem cancel_right {f₁ f₂ : C(β, γ)} {g : C(α, β)} (hg : Surjective g) : f₁.comp g = f₂.comp g ↔ f₁ = f₂ := ⟨fun h => ext <| hg.forall.2 <| DFunLike.ext_iff.1 h, congr_arg (ContinuousMap.comp · g)⟩ @[simp] theorem cancel_left {f : C(β, γ)} {g₁ g₂ : C(α, β)} (hf : Injective f) : f.comp g₁ = f.comp g₂ ↔ g₁ = g₂ := ⟨fun h => ext fun a => hf <| by rw [← comp_apply, h, comp_apply], congr_arg _⟩ instance [Nonempty α] [Nontrivial β] : Nontrivial C(α, β) := ⟨let ⟨b₁, b₂, hb⟩ := exists_pair_ne β ⟨const _ b₁, const _ b₂, fun h => hb <| DFunLike.congr_fun h <| Classical.arbitrary α⟩⟩ section Prod variable {α₁ α₂ β₁ β₂ : Type*} [TopologicalSpace α₁] [TopologicalSpace α₂] [TopologicalSpace β₁] [TopologicalSpace β₂] /-- `Prod.fst : (x, y) ↦ x` as a bundled continuous map. -/ @[simps (config := .asFn)] def fst : C(α × β, α) where toFun := Prod.fst /-- `Prod.snd : (x, y) ↦ y` as a bundled continuous map. -/ @[simps (config := .asFn)] def snd : C(α × β, β) where toFun := Prod.snd /-- Given two continuous maps `f` and `g`, this is the continuous map `x ↦ (f x, g x)`. -/ def prodMk (f : C(α, β₁)) (g : C(α, β₂)) : C(α, β₁ × β₂) where toFun x := (f x, g x) /-- Given two continuous maps `f` and `g`, this is the continuous map `(x, y) ↦ (f x, g y)`. -/ @[simps] def prodMap (f : C(α₁, α₂)) (g : C(β₁, β₂)) : C(α₁ × β₁, α₂ × β₂) where toFun := Prod.map f g continuous_toFun := f.continuous.prod_map g.continuous -- Porting note: proof was `continuity` @[simp] theorem prod_eval (f : C(α, β₁)) (g : C(α, β₂)) (a : α) : (prodMk f g) a = (f a, g a) := rfl /-- `Prod.swap` bundled as a `ContinuousMap`. -/ @[simps!] def prodSwap : C(α × β, β × α) := .prodMk .snd .fst end Prod section Sigma variable {I A : Type*} {X : I → Type*} [TopologicalSpace A] [∀ i, TopologicalSpace (X i)] /-- `Sigma.mk i` as a bundled continuous map. -/ @[simps apply] def sigmaMk (i : I) : C(X i, Σ i, X i) where toFun := Sigma.mk i /-- To give a continuous map out of a disjoint union, it suffices to give a continuous map out of each term. This is `Sigma.uncurry` for continuous maps. -/ @[simps] def sigma (f : ∀ i, C(X i, A)) : C((Σ i, X i), A) where toFun ig := f ig.fst ig.snd variable (A X) in /-- Giving a continuous map out of a disjoint union is the same as giving a continuous map out of each term. This is a version of `Equiv.piCurry` for continuous maps. -/ @[simps] def sigmaEquiv : (∀ i, C(X i, A)) ≃ C((Σ i, X i), A) where toFun := sigma invFun f i := f.comp (sigmaMk i) left_inv := by intro; ext; simp right_inv := by intro; ext; simp end Sigma section Pi variable {I A : Type*} {X Y : I → Type*} [TopologicalSpace A] [∀ i, TopologicalSpace (X i)] [∀ i, TopologicalSpace (Y i)] /-- Abbreviation for product of continuous maps, which is continuous -/ def pi (f : ∀ i, C(A, X i)) : C(A, ∀ i, X i) where toFun (a : A) (i : I) := f i a @[simp] theorem pi_eval (f : ∀ i, C(A, X i)) (a : A) : (pi f) a = fun i : I => (f i) a := rfl /-- Evaluation at point as a bundled continuous map. -/ @[simps (config := .asFn)] def eval (i : I) : C(∀ j, X j, X i) where toFun := Function.eval i variable (A X) in /-- Giving a continuous map out of a disjoint union is the same as giving a continuous map out of each term -/ @[simps] def piEquiv : (∀ i, C(A, X i)) ≃ C(A, ∀ i, X i) where toFun := pi invFun f i := (eval i).comp f left_inv := by intro; ext; simp [pi] right_inv := by intro; ext; simp [pi] /-- Combine a collection of bundled continuous maps `C(X i, Y i)` into a bundled continuous map `C(∀ i, X i, ∀ i, Y i)`. -/ @[simps!] def piMap (f : ∀ i, C(X i, Y i)) : C((i : I) → X i, (i : I) → Y i) := .pi fun i ↦ (f i).comp (eval i) /-- "Precomposition" as a continuous map between dependent types. -/ def precomp {ι : Type*} (φ : ι → I) : C((i : I) → X i, (i : ι) → X (φ i)) := ⟨_, Pi.continuous_precomp' φ⟩ end Pi section Restrict variable (s : Set α) /-- The restriction of a continuous function `α → β` to a subset `s` of `α`. -/ def restrict (f : C(α, β)) : C(s, β) where toFun := f ∘ ((↑) : s → α) @[simp] theorem coe_restrict (f : C(α, β)) : ⇑(f.restrict s) = f ∘ ((↑) : s → α) := rfl @[simp] theorem restrict_apply (f : C(α, β)) (s : Set α) (x : s) : f.restrict s x = f x := rfl @[simp] theorem restrict_apply_mk (f : C(α, β)) (s : Set α) (x : α) (hx : x ∈ s) : f.restrict s ⟨x, hx⟩ = f x := rfl theorem injective_restrict [T2Space β] {s : Set α} (hs : Dense s) : Injective (restrict s : C(α, β) → C(s, β)) := fun f g h ↦ DFunLike.ext' <| f.continuous.ext_on hs g.continuous <| Set.restrict_eq_restrict_iff.1 <| congr_arg DFunLike.coe h /-- The restriction of a continuous map to the preimage of a set. -/ @[simps] def restrictPreimage (f : C(α, β)) (s : Set β) : C(f ⁻¹' s, s) := ⟨s.restrictPreimage f, continuous_iff_continuousAt.mpr fun _ => f.2.continuousAt.restrictPreimage⟩ end Restrict section Gluing variable {ι : Type*} (S : ι → Set α) (φ : ∀ i : ι, C(S i, β)) (hφ : ∀ (i j) (x : α) (hxi : x ∈ S i) (hxj : x ∈ S j), φ i ⟨x, hxi⟩ = φ j ⟨x, hxj⟩) (hS : ∀ x : α, ∃ i, S i ∈ 𝓝 x) /-- A family `φ i` of continuous maps `C(S i, β)`, where the domains `S i` contain a neighbourhood of each point in `α` and the functions `φ i` agree pairwise on intersections, can be glued to construct a continuous map in `C(α, β)`. -/ noncomputable def liftCover : C(α, β) := haveI H : ⋃ i, S i = Set.univ := Set.iUnion_eq_univ_iff.2 fun x ↦ (hS x).imp fun _ ↦ mem_of_mem_nhds mk (Set.liftCover S (fun i ↦ φ i) hφ H) <| continuous_of_cover_nhds hS fun i ↦ by rw [continuousOn_iff_continuous_restrict] simpa (config := { unfoldPartialApp := true }) only [Set.restrict, Set.liftCover_coe] using (φ i).continuous variable {S φ hφ hS} @[simp] theorem liftCover_coe {i : ι} (x : S i) : liftCover S φ hφ hS x = φ i x := by rw [liftCover, coe_mk, Set.liftCover_coe _] -- @[simp] -- Porting note: the simpNF linter complained theorem liftCover_restrict {i : ι} : (liftCover S φ hφ hS).restrict (S i) = φ i := by ext simp only [coe_restrict, Function.comp_apply, liftCover_coe] variable (A : Set (Set α)) (F : ∀ s ∈ A, C(s, β)) (hF : ∀ (s) (hs : s ∈ A) (t) (ht : t ∈ A) (x : α) (hxi : x ∈ s) (hxj : x ∈ t), F s hs ⟨x, hxi⟩ = F t ht ⟨x, hxj⟩) (hA : ∀ x : α, ∃ i ∈ A, i ∈ 𝓝 x) /-- A family `F s` of continuous maps `C(s, β)`, where (1) the domains `s` are taken from a set `A` of sets in `α` which contain a neighbourhood of each point in `α` and (2) the functions `F s` agree pairwise on intersections, can be glued to construct a continuous map in `C(α, β)`. -/ noncomputable def liftCover' : C(α, β) := by let S : A → Set α := (↑) let F : ∀ i : A, C(i, β) := fun i => F i i.prop refine liftCover S F (fun i j => hF i i.prop j j.prop) ?_ intro x obtain ⟨s, hs, hsx⟩ := hA x exact ⟨⟨s, hs⟩, hsx⟩ variable {A F hF hA} -- Porting note: did not need `by delta liftCover'; exact` in mathlib3; goal was -- closed by `liftCover_coe x'` -- Might be something to do with the `let`s in the definition of `liftCover'`? @[simp] theorem liftCover_coe' {s : Set α} {hs : s ∈ A} (x : s) : liftCover' A F hF hA x = F s hs x := let x' : ((↑) : A → Set α) ⟨s, hs⟩ := x by delta liftCover'; exact liftCover_coe x' -- Porting note: porting program suggested `ext <| liftCover_coe'` @[simp] theorem liftCover_restrict' {s : Set α} {hs : s ∈ A} : (liftCover' A F hF hA).restrict s = F s hs := ext <| liftCover_coe' (hF := hF) (hA := hA) end Gluing end ContinuousMap section Lift variable {X Y Z : Type*} [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] {f : C(X, Y)} /-- `Setoid.quotientKerEquivOfRightInverse` as a homeomorphism. -/ @[simps!] def Function.RightInverse.homeomorph {f' : C(Y, X)} (hf : Function.RightInverse f' f) : Quotient (Setoid.ker f) ≃ₜ Y where toEquiv := Setoid.quotientKerEquivOfRightInverse _ _ hf continuous_toFun := quotientMap_quot_mk.continuous_iff.mpr f.continuous continuous_invFun := continuous_quotient_mk'.comp f'.continuous namespace QuotientMap /-- The homeomorphism from the quotient of a quotient map to its codomain. This is `Setoid.quotientKerEquivOfSurjective` as a homeomorphism. -/ @[simps!] noncomputable def homeomorph (hf : QuotientMap f) : Quotient (Setoid.ker f) ≃ₜ Y where toEquiv := Setoid.quotientKerEquivOfSurjective _ hf.surjective continuous_toFun := quotientMap_quot_mk.continuous_iff.mpr hf.continuous continuous_invFun := by rw [hf.continuous_iff] convert continuous_quotient_mk' ext simp only [Equiv.invFun_as_coe, Function.comp_apply, (Setoid.quotientKerEquivOfSurjective f hf.surjective).symm_apply_eq] rfl variable (hf : QuotientMap f) (g : C(X, Z)) (h : Function.FactorsThrough g f) /-- Descend a continuous map, which is constant on the fibres, along a quotient map. -/ @[simps] noncomputable def lift : C(Y, Z) where toFun := ((fun i ↦ Quotient.liftOn' i g (fun _ _ (hab : f _ = f _) ↦ h hab)) : Quotient (Setoid.ker f) → Z) ∘ hf.homeomorph.symm continuous_toFun := Continuous.comp (continuous_quot_lift _ g.2) (Homeomorph.continuous _) /-- The obvious triangle induced by `QuotientMap.lift` commutes: ``` g X --→ Z | ↗ f | / hf.lift g h v / Y ``` -/ @[simp] theorem lift_comp : (hf.lift g h).comp f = g := by ext simpa using h (Function.rightInverse_surjInv _ _) /-- `QuotientMap.lift` as an equivalence. -/ @[simps] noncomputable def liftEquiv : { g : C(X, Z) // Function.FactorsThrough g f} ≃ C(Y, Z) where toFun g := hf.lift g g.prop invFun g := ⟨g.comp f, fun _ _ h ↦ by simp only [ContinuousMap.comp_apply]; rw [h]⟩ left_inv := by intro; simp right_inv := by intro g ext a simpa using congrArg g (Function.rightInverse_surjInv hf.surjective a) end QuotientMap end Lift namespace Homeomorph variable {α β γ : Type*} [TopologicalSpace α] [TopologicalSpace β] [TopologicalSpace γ] variable (f : α ≃ₜ β) (g : β ≃ₜ γ) /-- The forward direction of a homeomorphism, as a bundled continuous map. -/ @[simps] def toContinuousMap (e : α ≃ₜ β) : C(α, β) := ⟨e, e.continuous_toFun⟩ /-- `Homeomorph.toContinuousMap` as a coercion. -/ instance : Coe (α ≃ₜ β) C(α, β) := ⟨Homeomorph.toContinuousMap⟩ -- Porting note: Syntactic tautology /- theorem toContinuousMap_as_coe : f.toContinuousMap = f := rfl -/ @[simp] theorem coe_refl : (Homeomorph.refl α : C(α, α)) = ContinuousMap.id α := rfl @[simp] theorem coe_trans : (f.trans g : C(α, γ)) = (g : C(β, γ)).comp f := rfl /-- Left inverse to a continuous map from a homeomorphism, mirroring `Equiv.symm_comp_self`. -/ @[simp] theorem symm_comp_toContinuousMap : (f.symm : C(β, α)).comp (f : C(α, β)) = ContinuousMap.id α := by rw [← coe_trans, self_trans_symm, coe_refl] /-- Right inverse to a continuous map from a homeomorphism, mirroring `Equiv.self_comp_symm`. -/ @[simp] theorem toContinuousMap_comp_symm : (f : C(α, β)).comp (f.symm : C(β, α)) = ContinuousMap.id β := by rw [← coe_trans, symm_trans_self, coe_refl] end Homeomorph
Topology\ContinuousFunction\Bounded.lean
/- Copyright (c) 2018 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel, Mario Carneiro, Yury Kudryashov, Heather Macbeth -/ import Mathlib.Algebra.Module.MinimalAxioms import Mathlib.Topology.ContinuousFunction.Algebra import Mathlib.Analysis.Normed.Order.Lattice import Mathlib.Analysis.NormedSpace.OperatorNorm.Basic import Mathlib.Analysis.CStarAlgebra.Basic import Mathlib.Analysis.Normed.Operator.ContinuousLinearMap import Mathlib.Topology.Bornology.BoundedOperation /-! # Bounded continuous functions The type of bounded continuous functions taking values in a metric space, with the uniform distance. -/ noncomputable section open scoped Classical open Topology Bornology NNReal uniformity UniformConvergence open Set Filter Metric Function universe u v w variable {F : Type*} {α : Type u} {β : Type v} {γ : Type w} /-- `α →ᵇ β` is the type of bounded continuous functions `α → β` from a topological space to a metric space. When possible, instead of parametrizing results over `(f : α →ᵇ β)`, you should parametrize over `(F : Type*) [BoundedContinuousMapClass F α β] (f : F)`. When you extend this structure, make sure to extend `BoundedContinuousMapClass`. -/ structure BoundedContinuousFunction (α : Type u) (β : Type v) [TopologicalSpace α] [PseudoMetricSpace β] extends ContinuousMap α β : Type max u v where map_bounded' : ∃ C, ∀ x y, dist (toFun x) (toFun y) ≤ C scoped[BoundedContinuousFunction] infixr:25 " →ᵇ " => BoundedContinuousFunction section -- Porting note: Changed type of `α β` from `Type*` to `outParam Type*`. /-- `BoundedContinuousMapClass F α β` states that `F` is a type of bounded continuous maps. You should also extend this typeclass when you extend `BoundedContinuousFunction`. -/ class BoundedContinuousMapClass (F : Type*) (α β : outParam Type*) [TopologicalSpace α] [PseudoMetricSpace β] [FunLike F α β] extends ContinuousMapClass F α β : Prop where map_bounded (f : F) : ∃ C, ∀ x y, dist (f x) (f y) ≤ C end export BoundedContinuousMapClass (map_bounded) namespace BoundedContinuousFunction section Basics variable [TopologicalSpace α] [PseudoMetricSpace β] [PseudoMetricSpace γ] variable {f g : α →ᵇ β} {x : α} {C : ℝ} instance instFunLike : FunLike (α →ᵇ β) α β where coe f := f.toFun coe_injective' f g h := by obtain ⟨⟨_, _⟩, _⟩ := f obtain ⟨⟨_, _⟩, _⟩ := g congr instance instBoundedContinuousMapClass : BoundedContinuousMapClass (α →ᵇ β) α β where map_continuous f := f.continuous_toFun map_bounded f := f.map_bounded' instance instCoeTC [FunLike F α β] [BoundedContinuousMapClass F α β] : CoeTC F (α →ᵇ β) := ⟨fun f => { toFun := f continuous_toFun := map_continuous f map_bounded' := map_bounded f }⟩ @[simp] theorem coe_to_continuous_fun (f : α →ᵇ β) : (f.toContinuousMap : α → β) = f := 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 (h : α →ᵇ β) : α → β := h initialize_simps_projections BoundedContinuousFunction (toContinuousMap_toFun → apply) protected theorem bounded (f : α →ᵇ β) : ∃ C, ∀ x y : α, dist (f x) (f y) ≤ C := f.map_bounded' protected theorem continuous (f : α →ᵇ β) : Continuous f := f.toContinuousMap.continuous @[ext] theorem ext (h : ∀ x, f x = g x) : f = g := DFunLike.ext _ _ h theorem isBounded_range (f : α →ᵇ β) : IsBounded (range f) := isBounded_range_iff.2 f.bounded theorem isBounded_image (f : α →ᵇ β) (s : Set α) : IsBounded (f '' s) := f.isBounded_range.subset <| image_subset_range _ _ theorem eq_of_empty [h : IsEmpty α] (f g : α →ᵇ β) : f = g := ext <| h.elim /-- A continuous function with an explicit bound is a bounded continuous function. -/ def mkOfBound (f : C(α, β)) (C : ℝ) (h : ∀ x y : α, dist (f x) (f y) ≤ C) : α →ᵇ β := ⟨f, ⟨C, h⟩⟩ @[simp] theorem mkOfBound_coe {f} {C} {h} : (mkOfBound f C h : α → β) = (f : α → β) := rfl /-- A continuous function on a compact space is automatically a bounded continuous function. -/ def mkOfCompact [CompactSpace α] (f : C(α, β)) : α →ᵇ β := ⟨f, isBounded_range_iff.1 (isCompact_range f.continuous).isBounded⟩ @[simp] theorem mkOfCompact_apply [CompactSpace α] (f : C(α, β)) (a : α) : mkOfCompact f a = f a := rfl /-- If a function is bounded on a discrete space, it is automatically continuous, and therefore gives rise to an element of the type of bounded continuous functions. -/ @[simps] def mkOfDiscrete [DiscreteTopology α] (f : α → β) (C : ℝ) (h : ∀ x y : α, dist (f x) (f y) ≤ C) : α →ᵇ β := ⟨⟨f, continuous_of_discreteTopology⟩, ⟨C, h⟩⟩ /-- The uniform distance between two bounded continuous functions. -/ instance instDist : Dist (α →ᵇ β) := ⟨fun f g => sInf { C | 0 ≤ C ∧ ∀ x : α, dist (f x) (g x) ≤ C }⟩ theorem dist_eq : dist f g = sInf { C | 0 ≤ C ∧ ∀ x : α, dist (f x) (g x) ≤ C } := rfl theorem dist_set_exists : ∃ C, 0 ≤ C ∧ ∀ x : α, dist (f x) (g x) ≤ C := by rcases isBounded_iff.1 (f.isBounded_range.union g.isBounded_range) with ⟨C, hC⟩ refine ⟨max 0 C, le_max_left _ _, fun x => (hC ?_ ?_).trans (le_max_right _ _)⟩ <;> [left; right] <;> apply mem_range_self /-- The pointwise distance is controlled by the distance between functions, by definition. -/ theorem dist_coe_le_dist (x : α) : dist (f x) (g x) ≤ dist f g := le_csInf dist_set_exists fun _ hb => hb.2 x /- This lemma will be needed in the proof of the metric space instance, but it will become useless afterwards as it will be superseded by the general result that the distance is nonnegative in metric spaces. -/ private theorem dist_nonneg' : 0 ≤ dist f g := le_csInf dist_set_exists fun _ => And.left /-- The distance between two functions is controlled by the supremum of the pointwise distances. -/ theorem dist_le (C0 : (0 : ℝ) ≤ C) : dist f g ≤ C ↔ ∀ x : α, dist (f x) (g x) ≤ C := ⟨fun h x => le_trans (dist_coe_le_dist x) h, fun H => csInf_le ⟨0, fun _ => And.left⟩ ⟨C0, H⟩⟩ theorem dist_le_iff_of_nonempty [Nonempty α] : dist f g ≤ C ↔ ∀ x, dist (f x) (g x) ≤ C := ⟨fun h x => le_trans (dist_coe_le_dist x) h, fun w => (dist_le (le_trans dist_nonneg (w (Nonempty.some ‹_›)))).mpr w⟩ theorem dist_lt_of_nonempty_compact [Nonempty α] [CompactSpace α] (w : ∀ x : α, dist (f x) (g x) < C) : dist f g < C := by have c : Continuous fun x => dist (f x) (g x) := by continuity obtain ⟨x, -, le⟩ := IsCompact.exists_isMaxOn isCompact_univ Set.univ_nonempty (Continuous.continuousOn c) exact lt_of_le_of_lt (dist_le_iff_of_nonempty.mpr fun y => le trivial) (w x) theorem dist_lt_iff_of_compact [CompactSpace α] (C0 : (0 : ℝ) < C) : dist f g < C ↔ ∀ x : α, dist (f x) (g x) < C := by fconstructor · intro w x exact lt_of_le_of_lt (dist_coe_le_dist x) w · by_cases h : Nonempty α · exact dist_lt_of_nonempty_compact · rintro - convert C0 apply le_antisymm _ dist_nonneg' rw [dist_eq] exact csInf_le ⟨0, fun C => And.left⟩ ⟨le_rfl, fun x => False.elim (h (Nonempty.intro x))⟩ theorem dist_lt_iff_of_nonempty_compact [Nonempty α] [CompactSpace α] : dist f g < C ↔ ∀ x : α, dist (f x) (g x) < C := ⟨fun w x => lt_of_le_of_lt (dist_coe_le_dist x) w, dist_lt_of_nonempty_compact⟩ /-- The type of bounded continuous functions, with the uniform distance, is a pseudometric space. -/ instance instPseudoMetricSpace : PseudoMetricSpace (α →ᵇ β) where dist_self f := le_antisymm ((dist_le le_rfl).2 fun x => by simp) dist_nonneg' dist_comm f g := by simp [dist_eq, dist_comm] dist_triangle f g h := (dist_le (add_nonneg dist_nonneg' dist_nonneg')).2 fun x => le_trans (dist_triangle _ _ _) (add_le_add (dist_coe_le_dist _) (dist_coe_le_dist _)) -- Porting note (#10888): added proof for `edist_dist` edist_dist x y := by dsimp; congr; simp [dist_nonneg'] /-- The type of bounded continuous functions, with the uniform distance, is a metric space. -/ instance instMetricSpace {β} [MetricSpace β] : MetricSpace (α →ᵇ β) where eq_of_dist_eq_zero hfg := by ext x exact eq_of_dist_eq_zero (le_antisymm (hfg ▸ dist_coe_le_dist _) dist_nonneg) theorem nndist_eq : nndist f g = sInf { C | ∀ x : α, nndist (f x) (g x) ≤ C } := Subtype.ext <| dist_eq.trans <| by rw [val_eq_coe, coe_sInf, coe_image] simp_rw [mem_setOf_eq, ← NNReal.coe_le_coe, coe_mk, exists_prop, coe_nndist] theorem nndist_set_exists : ∃ C, ∀ x : α, nndist (f x) (g x) ≤ C := Subtype.exists.mpr <| dist_set_exists.imp fun _ ⟨ha, h⟩ => ⟨ha, h⟩ theorem nndist_coe_le_nndist (x : α) : nndist (f x) (g x) ≤ nndist f g := dist_coe_le_dist x /-- On an empty space, bounded continuous functions are at distance 0. -/ theorem dist_zero_of_empty [IsEmpty α] : dist f g = 0 := by rw [(ext isEmptyElim : f = g), dist_self] theorem dist_eq_iSup : dist f g = ⨆ x : α, dist (f x) (g x) := by cases isEmpty_or_nonempty α · rw [iSup_of_empty', Real.sSup_empty, dist_zero_of_empty] refine (dist_le_iff_of_nonempty.mpr <| le_ciSup ?_).antisymm (ciSup_le dist_coe_le_dist) exact dist_set_exists.imp fun C hC => forall_mem_range.2 hC.2 theorem nndist_eq_iSup : nndist f g = ⨆ x : α, nndist (f x) (g x) := Subtype.ext <| dist_eq_iSup.trans <| by simp_rw [val_eq_coe, coe_iSup, coe_nndist] theorem tendsto_iff_tendstoUniformly {ι : Type*} {F : ι → α →ᵇ β} {f : α →ᵇ β} {l : Filter ι} : Tendsto F l (𝓝 f) ↔ TendstoUniformly (fun i => F i) f l := Iff.intro (fun h => tendstoUniformly_iff.2 fun ε ε0 => (Metric.tendsto_nhds.mp h ε ε0).mp (eventually_of_forall fun n hn x => lt_of_le_of_lt (dist_coe_le_dist x) (dist_comm (F n) f ▸ hn))) fun h => Metric.tendsto_nhds.mpr fun _ ε_pos => (h _ (dist_mem_uniformity <| half_pos ε_pos)).mp (eventually_of_forall fun n hn => lt_of_le_of_lt ((dist_le (half_pos ε_pos).le).mpr fun x => dist_comm (f x) (F n x) ▸ le_of_lt (hn x)) (half_lt_self ε_pos)) /-- The topology on `α →ᵇ β` is exactly the topology induced by the natural map to `α →ᵤ β`. -/ theorem inducing_coeFn : Inducing (UniformFun.ofFun ∘ (⇑) : (α →ᵇ β) → α →ᵤ β) := by rw [inducing_iff_nhds] refine fun f => eq_of_forall_le_iff fun l => ?_ rw [← tendsto_iff_comap, ← tendsto_id', tendsto_iff_tendstoUniformly, UniformFun.tendsto_iff_tendstoUniformly] simp [comp_def] -- TODO: upgrade to a `UniformEmbedding` theorem embedding_coeFn : Embedding (UniformFun.ofFun ∘ (⇑) : (α →ᵇ β) → α →ᵤ β) := ⟨inducing_coeFn, fun _ _ h => ext fun x => congr_fun h x⟩ variable (α) /-- Constant as a continuous bounded function. -/ @[simps! (config := .asFn)] -- Porting note: Changed `simps` to `simps!` def const (b : β) : α →ᵇ β := ⟨ContinuousMap.const α b, 0, by simp⟩ variable {α} theorem const_apply' (a : α) (b : β) : (const α b : α → β) a = b := rfl /-- If the target space is inhabited, so is the space of bounded continuous functions. -/ instance [Inhabited β] : Inhabited (α →ᵇ β) := ⟨const α default⟩ theorem lipschitz_evalx (x : α) : LipschitzWith 1 fun f : α →ᵇ β => f x := LipschitzWith.mk_one fun _ _ => dist_coe_le_dist x theorem uniformContinuous_coe : @UniformContinuous (α →ᵇ β) (α → β) _ _ (⇑) := uniformContinuous_pi.2 fun x => (lipschitz_evalx x).uniformContinuous theorem continuous_coe : Continuous fun (f : α →ᵇ β) x => f x := UniformContinuous.continuous uniformContinuous_coe /-- When `x` is fixed, `(f : α →ᵇ β) ↦ f x` is continuous. -/ @[continuity] theorem continuous_eval_const {x : α} : Continuous fun f : α →ᵇ β => f x := (continuous_apply x).comp continuous_coe /-- The evaluation map is continuous, as a joint function of `u` and `x`. -/ @[continuity] theorem continuous_eval : Continuous fun p : (α →ᵇ β) × α => p.1 p.2 := (continuous_prod_of_continuous_lipschitzWith _ 1 fun f => f.continuous) <| lipschitz_evalx /-- Bounded continuous functions taking values in a complete space form a complete space. -/ instance instCompleteSpace [CompleteSpace β] : CompleteSpace (α →ᵇ β) := complete_of_cauchySeq_tendsto fun (f : ℕ → α →ᵇ β) (hf : CauchySeq f) => by /- We have to show that `f n` converges to a bounded continuous function. For this, we prove pointwise convergence to define the limit, then check it is a continuous bounded function, and then check the norm convergence. -/ rcases cauchySeq_iff_le_tendsto_0.1 hf with ⟨b, b0, b_bound, b_lim⟩ have f_bdd := fun x n m N hn hm => le_trans (dist_coe_le_dist x) (b_bound n m N hn hm) have fx_cau : ∀ x, CauchySeq fun n => f n x := fun x => cauchySeq_iff_le_tendsto_0.2 ⟨b, b0, f_bdd x, b_lim⟩ choose F hF using fun x => cauchySeq_tendsto_of_complete (fx_cau x) /- `F : α → β`, `hF : ∀ (x : α), Tendsto (fun n ↦ ↑(f n) x) atTop (𝓝 (F x))` `F` is the desired limit function. Check that it is uniformly approximated by `f N`. -/ have fF_bdd : ∀ x N, dist (f N x) (F x) ≤ b N := fun x N => le_of_tendsto (tendsto_const_nhds.dist (hF x)) (Filter.eventually_atTop.2 ⟨N, fun n hn => f_bdd x N n N (le_refl N) hn⟩) refine ⟨⟨⟨F, ?_⟩, ?_⟩, ?_⟩ · -- Check that `F` is continuous, as a uniform limit of continuous functions have : TendstoUniformly (fun n x => f n x) F atTop := by refine Metric.tendstoUniformly_iff.2 fun ε ε0 => ?_ refine ((tendsto_order.1 b_lim).2 ε ε0).mono fun n hn x => ?_ rw [dist_comm] exact lt_of_le_of_lt (fF_bdd x n) hn exact this.continuous (eventually_of_forall fun N => (f N).continuous) · -- Check that `F` is bounded rcases (f 0).bounded with ⟨C, hC⟩ refine ⟨C + (b 0 + b 0), fun x y => ?_⟩ calc dist (F x) (F y) ≤ dist (f 0 x) (f 0 y) + (dist (f 0 x) (F x) + dist (f 0 y) (F y)) := dist_triangle4_left _ _ _ _ _ ≤ C + (b 0 + b 0) := by mono · -- Check that `F` is close to `f N` in distance terms refine tendsto_iff_dist_tendsto_zero.2 (squeeze_zero (fun _ => dist_nonneg) ?_ b_lim) exact fun N => (dist_le (b0 _)).2 fun x => fF_bdd x N /-- Composition of a bounded continuous function and a continuous function. -/ def compContinuous {δ : Type*} [TopologicalSpace δ] (f : α →ᵇ β) (g : C(δ, α)) : δ →ᵇ β where toContinuousMap := f.1.comp g map_bounded' := f.map_bounded'.imp fun _ hC _ _ => hC _ _ @[simp] theorem coe_compContinuous {δ : Type*} [TopologicalSpace δ] (f : α →ᵇ β) (g : C(δ, α)) : ⇑(f.compContinuous g) = f ∘ g := rfl @[simp] theorem compContinuous_apply {δ : Type*} [TopologicalSpace δ] (f : α →ᵇ β) (g : C(δ, α)) (x : δ) : f.compContinuous g x = f (g x) := rfl theorem lipschitz_compContinuous {δ : Type*} [TopologicalSpace δ] (g : C(δ, α)) : LipschitzWith 1 fun f : α →ᵇ β => f.compContinuous g := LipschitzWith.mk_one fun _ _ => (dist_le dist_nonneg).2 fun x => dist_coe_le_dist (g x) theorem continuous_compContinuous {δ : Type*} [TopologicalSpace δ] (g : C(δ, α)) : Continuous fun f : α →ᵇ β => f.compContinuous g := (lipschitz_compContinuous g).continuous /-- Restrict a bounded continuous function to a set. -/ def restrict (f : α →ᵇ β) (s : Set α) : s →ᵇ β := f.compContinuous <| (ContinuousMap.id _).restrict s @[simp] theorem coe_restrict (f : α →ᵇ β) (s : Set α) : ⇑(f.restrict s) = f ∘ (↑) := rfl @[simp] theorem restrict_apply (f : α →ᵇ β) (s : Set α) (x : s) : f.restrict s x = f x := rfl /-- Composition (in the target) of a bounded continuous function with a Lipschitz map again gives a bounded continuous function. -/ def comp (G : β → γ) {C : ℝ≥0} (H : LipschitzWith C G) (f : α →ᵇ β) : α →ᵇ γ := ⟨⟨fun x => G (f x), H.continuous.comp f.continuous⟩, let ⟨D, hD⟩ := f.bounded ⟨max C 0 * D, fun x y => calc dist (G (f x)) (G (f y)) ≤ C * dist (f x) (f y) := H.dist_le_mul _ _ _ ≤ max C 0 * dist (f x) (f y) := by gcongr; apply le_max_left _ ≤ max C 0 * D := by gcongr; apply hD ⟩⟩ /-- The composition operator (in the target) with a Lipschitz map is Lipschitz. -/ theorem lipschitz_comp {G : β → γ} {C : ℝ≥0} (H : LipschitzWith C G) : LipschitzWith C (comp G H : (α →ᵇ β) → α →ᵇ γ) := LipschitzWith.of_dist_le_mul fun f g => (dist_le (mul_nonneg C.2 dist_nonneg)).2 fun x => calc dist (G (f x)) (G (g x)) ≤ C * dist (f x) (g x) := H.dist_le_mul _ _ _ ≤ C * dist f g := by gcongr; apply dist_coe_le_dist /-- The composition operator (in the target) with a Lipschitz map is uniformly continuous. -/ theorem uniformContinuous_comp {G : β → γ} {C : ℝ≥0} (H : LipschitzWith C G) : UniformContinuous (comp G H : (α →ᵇ β) → α →ᵇ γ) := (lipschitz_comp H).uniformContinuous /-- The composition operator (in the target) with a Lipschitz map is continuous. -/ theorem continuous_comp {G : β → γ} {C : ℝ≥0} (H : LipschitzWith C G) : Continuous (comp G H : (α →ᵇ β) → α →ᵇ γ) := (lipschitz_comp H).continuous /-- Restriction (in the target) of a bounded continuous function taking values in a subset. -/ def codRestrict (s : Set β) (f : α →ᵇ β) (H : ∀ x, f x ∈ s) : α →ᵇ s := ⟨⟨s.codRestrict f H, f.continuous.subtype_mk _⟩, f.bounded⟩ section Extend variable {δ : Type*} [TopologicalSpace δ] [DiscreteTopology δ] /-- A version of `Function.extend` for bounded continuous maps. We assume that the domain has discrete topology, so we only need to verify boundedness. -/ nonrec def extend (f : α ↪ δ) (g : α →ᵇ β) (h : δ →ᵇ β) : δ →ᵇ β where toFun := extend f g h continuous_toFun := continuous_of_discreteTopology map_bounded' := by rw [← isBounded_range_iff, range_extend f.injective] exact g.isBounded_range.union (h.isBounded_image _) @[simp] theorem extend_apply (f : α ↪ δ) (g : α →ᵇ β) (h : δ →ᵇ β) (x : α) : extend f g h (f x) = g x := f.injective.extend_apply _ _ _ @[simp] nonrec theorem extend_comp (f : α ↪ δ) (g : α →ᵇ β) (h : δ →ᵇ β) : extend f g h ∘ f = g := extend_comp f.injective _ _ nonrec theorem extend_apply' {f : α ↪ δ} {x : δ} (hx : x ∉ range f) (g : α →ᵇ β) (h : δ →ᵇ β) : extend f g h x = h x := extend_apply' _ _ _ hx theorem extend_of_empty [IsEmpty α] (f : α ↪ δ) (g : α →ᵇ β) (h : δ →ᵇ β) : extend f g h = h := DFunLike.coe_injective <| Function.extend_of_isEmpty f g h @[simp] theorem dist_extend_extend (f : α ↪ δ) (g₁ g₂ : α →ᵇ β) (h₁ h₂ : δ →ᵇ β) : dist (g₁.extend f h₁) (g₂.extend f h₂) = max (dist g₁ g₂) (dist (h₁.restrict (range f)ᶜ) (h₂.restrict (range f)ᶜ)) := by refine le_antisymm ((dist_le <| le_max_iff.2 <| Or.inl dist_nonneg).2 fun x => ?_) (max_le ?_ ?_) · rcases em (∃ y, f y = x) with (⟨x, rfl⟩ | hx) · simp only [extend_apply] exact (dist_coe_le_dist x).trans (le_max_left _ _) · simp only [extend_apply' hx] lift x to ((range f)ᶜ : Set δ) using hx calc dist (h₁ x) (h₂ x) = dist (h₁.restrict (range f)ᶜ x) (h₂.restrict (range f)ᶜ x) := rfl _ ≤ dist (h₁.restrict (range f)ᶜ) (h₂.restrict (range f)ᶜ) := dist_coe_le_dist x _ ≤ _ := le_max_right _ _ · refine (dist_le dist_nonneg).2 fun x => ?_ rw [← extend_apply f g₁ h₁, ← extend_apply f g₂ h₂] exact dist_coe_le_dist _ · refine (dist_le dist_nonneg).2 fun x => ?_ calc dist (h₁ x) (h₂ x) = dist (extend f g₁ h₁ x) (extend f g₂ h₂ x) := by rw [extend_apply' x.coe_prop, extend_apply' x.coe_prop] _ ≤ _ := dist_coe_le_dist _ theorem isometry_extend (f : α ↪ δ) (h : δ →ᵇ β) : Isometry fun g : α →ᵇ β => extend f g h := Isometry.of_dist_eq fun g₁ g₂ => by simp [dist_nonneg] end Extend end Basics section ArzelaAscoli variable [TopologicalSpace α] [CompactSpace α] [PseudoMetricSpace β] variable {f g : α →ᵇ β} {x : α} {C : ℝ} /- Arzela-Ascoli theorem asserts that, on a compact space, a set of functions sharing a common modulus of continuity and taking values in a compact set forms a compact subset for the topology of uniform convergence. In this section, we prove this theorem and several useful variations around it. -/ /-- First version, with pointwise equicontinuity and range in a compact space. -/ theorem arzela_ascoli₁ [CompactSpace β] (A : Set (α →ᵇ β)) (closed : IsClosed A) (H : Equicontinuous ((↑) : A → α → β)) : IsCompact A := by simp_rw [Equicontinuous, Metric.equicontinuousAt_iff_pair] at H refine isCompact_of_totallyBounded_isClosed ?_ closed refine totallyBounded_of_finite_discretization fun ε ε0 => ?_ rcases exists_between ε0 with ⟨ε₁, ε₁0, εε₁⟩ let ε₂ := ε₁ / 2 / 2 /- We have to find a finite discretization of `u`, i.e., finite information that is sufficient to reconstruct `u` up to `ε`. This information will be provided by the values of `u` on a sufficiently dense set `tα`, slightly translated to fit in a finite `ε₂`-dense set `tβ` in the image. Such sets exist by compactness of the source and range. Then, to check that these data determine the function up to `ε`, one uses the control on the modulus of continuity to extend the closeness on tα to closeness everywhere. -/ have ε₂0 : ε₂ > 0 := half_pos (half_pos ε₁0) have : ∀ x : α, ∃ U, x ∈ U ∧ IsOpen U ∧ ∀ y ∈ U, ∀ z ∈ U, ∀ {f : α →ᵇ β}, f ∈ A → dist (f y) (f z) < ε₂ := fun x => let ⟨U, nhdsU, hU⟩ := H x _ ε₂0 let ⟨V, VU, openV, xV⟩ := _root_.mem_nhds_iff.1 nhdsU ⟨V, xV, openV, fun y hy z hz f hf => hU y (VU hy) z (VU hz) ⟨f, hf⟩⟩ choose U hU using this /- For all `x`, the set `hU x` is an open set containing `x` on which the elements of `A` fluctuate by at most `ε₂`. We extract finitely many of these sets that cover the whole space, by compactness. -/ obtain ⟨tα : Set α, _, hfin, htα : univ ⊆ ⋃ x ∈ tα, U x⟩ := isCompact_univ.elim_finite_subcover_image (fun x _ => (hU x).2.1) fun x _ => mem_biUnion (mem_univ _) (hU x).1 rcases hfin.nonempty_fintype with ⟨_⟩ obtain ⟨tβ : Set β, _, hfin, htβ : univ ⊆ ⋃y ∈ tβ, ball y ε₂⟩ := @finite_cover_balls_of_compact β _ _ isCompact_univ _ ε₂0 rcases hfin.nonempty_fintype with ⟨_⟩ -- Associate to every point `y` in the space a nearby point `F y` in `tβ` choose F hF using fun y => show ∃ z ∈ tβ, dist y z < ε₂ by simpa using htβ (mem_univ y) -- `F : β → β`, `hF : ∀ (y : β), F y ∈ tβ ∧ dist y (F y) < ε₂` /- Associate to every function a discrete approximation, mapping each point in `tα` to a point in `tβ` close to its true image by the function. -/ refine ⟨tα → tβ, by infer_instance, fun f a => ⟨F (f.1 a), (hF (f.1 a)).1⟩, ?_⟩ rintro ⟨f, hf⟩ ⟨g, hg⟩ f_eq_g -- If two functions have the same approximation, then they are within distance `ε` refine lt_of_le_of_lt ((dist_le <| le_of_lt ε₁0).2 fun x => ?_) εε₁ obtain ⟨x', x'tα, hx'⟩ := mem_iUnion₂.1 (htα (mem_univ x)) calc dist (f x) (g x) ≤ dist (f x) (f x') + dist (g x) (g x') + dist (f x') (g x') := dist_triangle4_right _ _ _ _ _ ≤ ε₂ + ε₂ + ε₁ / 2 := by refine le_of_lt (add_lt_add (add_lt_add ?_ ?_) ?_) · exact (hU x').2.2 _ hx' _ (hU x').1 hf · exact (hU x').2.2 _ hx' _ (hU x').1 hg · have F_f_g : F (f x') = F (g x') := (congr_arg (fun f : tα → tβ => (f ⟨x', x'tα⟩ : β)) f_eq_g : _) calc dist (f x') (g x') ≤ dist (f x') (F (f x')) + dist (g x') (F (f x')) := dist_triangle_right _ _ _ _ = dist (f x') (F (f x')) + dist (g x') (F (g x')) := by rw [F_f_g] _ < ε₂ + ε₂ := (add_lt_add (hF (f x')).2 (hF (g x')).2) _ = ε₁ / 2 := add_halves _ _ = ε₁ := by rw [add_halves, add_halves] /-- Second version, with pointwise equicontinuity and range in a compact subset. -/ theorem arzela_ascoli₂ (s : Set β) (hs : IsCompact s) (A : Set (α →ᵇ β)) (closed : IsClosed A) (in_s : ∀ (f : α →ᵇ β) (x : α), f ∈ A → f x ∈ s) (H : Equicontinuous ((↑) : A → α → β)) : IsCompact A := by /- This version is deduced from the previous one by restricting to the compact type in the target, using compactness there and then lifting everything to the original space. -/ have M : LipschitzWith 1 Subtype.val := LipschitzWith.subtype_val s let F : (α →ᵇ s) → α →ᵇ β := comp (↑) M refine IsCompact.of_isClosed_subset ((?_ : IsCompact (F ⁻¹' A)).image (continuous_comp M)) closed fun f hf => ?_ · haveI : CompactSpace s := isCompact_iff_compactSpace.1 hs refine arzela_ascoli₁ _ (continuous_iff_isClosed.1 (continuous_comp M) _ closed) ?_ rw [uniformEmbedding_subtype_val.toUniformInducing.equicontinuous_iff] exact H.comp (A.restrictPreimage F) · let g := codRestrict s f fun x => in_s f x hf rw [show f = F g by ext; rfl] at hf ⊢ exact ⟨g, hf, rfl⟩ /-- Third (main) version, with pointwise equicontinuity and range in a compact subset, but without closedness. The closure is then compact. -/ theorem arzela_ascoli [T2Space β] (s : Set β) (hs : IsCompact s) (A : Set (α →ᵇ β)) (in_s : ∀ (f : α →ᵇ β) (x : α), f ∈ A → f x ∈ s) (H : Equicontinuous ((↑) : A → α → β)) : IsCompact (closure A) := /- This version is deduced from the previous one by checking that the closure of `A`, in addition to being closed, still satisfies the properties of compact range and equicontinuity. -/ arzela_ascoli₂ s hs (closure A) isClosed_closure (fun _ x hf => (mem_of_closed' hs.isClosed).2 fun ε ε0 => let ⟨g, gA, dist_fg⟩ := Metric.mem_closure_iff.1 hf ε ε0 ⟨g x, in_s g x gA, lt_of_le_of_lt (dist_coe_le_dist _) dist_fg⟩) (H.closure' continuous_coe) end ArzelaAscoli section One variable [TopologicalSpace α] [PseudoMetricSpace β] [One β] @[to_additive] instance instOne : One (α →ᵇ β) := ⟨const α 1⟩ @[to_additive (attr := simp)] theorem coe_one : ((1 : α →ᵇ β) : α → β) = 1 := rfl @[to_additive (attr := simp)] theorem mkOfCompact_one [CompactSpace α] : mkOfCompact (1 : C(α, β)) = 1 := rfl @[to_additive] theorem forall_coe_one_iff_one (f : α →ᵇ β) : (∀ x, f x = 1) ↔ f = 1 := (@DFunLike.ext_iff _ _ _ _ f 1).symm @[to_additive (attr := simp)] theorem one_compContinuous [TopologicalSpace γ] (f : C(γ, α)) : (1 : α →ᵇ β).compContinuous f = 1 := rfl end One section add variable [TopologicalSpace α] [PseudoMetricSpace β] [AddMonoid β] [BoundedAdd β] [ContinuousAdd β] variable (f g : α →ᵇ β) {x : α} {C : ℝ} /-- The pointwise sum of two bounded continuous functions is again bounded continuous. -/ instance instAdd : Add (α →ᵇ β) where add f g := { toFun := fun x ↦ f x + g x continuous_toFun := f.continuous.add g.continuous map_bounded' := add_bounded_of_bounded_of_bounded (map_bounded f) (map_bounded g) } @[simp] theorem coe_add : ⇑(f + g) = f + g := rfl theorem add_apply : (f + g) x = f x + g x := rfl @[simp] theorem mkOfCompact_add [CompactSpace α] (f g : C(α, β)) : mkOfCompact (f + g) = mkOfCompact f + mkOfCompact g := rfl theorem add_compContinuous [TopologicalSpace γ] (h : C(γ, α)) : (g + f).compContinuous h = g.compContinuous h + f.compContinuous h := rfl @[simp] theorem coe_nsmulRec : ∀ n, ⇑(nsmulRec n f) = n • ⇑f | 0 => by rw [nsmulRec, zero_smul, coe_zero] | n + 1 => by rw [nsmulRec, succ_nsmul, coe_add, coe_nsmulRec n] instance instSMulNat : SMul ℕ (α →ᵇ β) where smul n f := { toContinuousMap := n • f.toContinuousMap map_bounded' := by simpa [coe_nsmulRec] using (nsmulRec n f).map_bounded' } @[simp] theorem coe_nsmul (r : ℕ) (f : α →ᵇ β) : ⇑(r • f) = r • ⇑f := rfl @[simp] theorem nsmul_apply (r : ℕ) (f : α →ᵇ β) (v : α) : (r • f) v = r • f v := rfl instance instAddMonoid : AddMonoid (α →ᵇ β) := DFunLike.coe_injective.addMonoid _ coe_zero coe_add fun _ _ => coe_nsmul _ _ /-- Coercion of a `NormedAddGroupHom` is an `AddMonoidHom`. Similar to `AddMonoidHom.coeFn`. -/ @[simps] def coeFnAddHom : (α →ᵇ β) →+ α → β where toFun := (⇑) map_zero' := coe_zero map_add' := coe_add variable (α β) /-- The additive map forgetting that a bounded continuous function is bounded. -/ @[simps] def toContinuousMapAddHom : (α →ᵇ β) →+ C(α, β) where toFun := toContinuousMap map_zero' := rfl map_add' := by intros ext simp end add section comm_add variable [TopologicalSpace α] variable [PseudoMetricSpace β] [AddCommMonoid β] [BoundedAdd β] [ContinuousAdd β] @[to_additive] instance instAddCommMonoid : AddCommMonoid (α →ᵇ β) where add_comm f g := by ext; simp [add_comm] @[simp] theorem coe_sum {ι : Type*} (s : Finset ι) (f : ι → α →ᵇ β) : ⇑(∑ i ∈ s, f i) = ∑ i ∈ s, (f i : α → β) := map_sum coeFnAddHom f s theorem sum_apply {ι : Type*} (s : Finset ι) (f : ι → α →ᵇ β) (a : α) : (∑ i ∈ s, f i) a = ∑ i ∈ s, f i a := by simp end comm_add section LipschitzAdd /- In this section, if `β` is an `AddMonoid` whose addition operation is Lipschitz, then we show that the space of bounded continuous functions from `α` to `β` inherits a topological `AddMonoid` structure, by using pointwise operations and checking that they are compatible with the uniform distance. Implementation note: The material in this section could have been written for `LipschitzMul` and transported by `@[to_additive]`. We choose not to do this because this causes a few lemma names (for example, `coe_mul`) to conflict with later lemma names for normed rings; this is only a trivial inconvenience, but in any case there are no obvious applications of the multiplicative version. -/ variable [TopologicalSpace α] [PseudoMetricSpace β] [AddMonoid β] [LipschitzAdd β] variable (f g : α →ᵇ β) {x : α} {C : ℝ} instance instLipschitzAdd : LipschitzAdd (α →ᵇ β) where lipschitz_add := ⟨LipschitzAdd.C β, by have C_nonneg := (LipschitzAdd.C β).coe_nonneg rw [lipschitzWith_iff_dist_le_mul] rintro ⟨f₁, g₁⟩ ⟨f₂, g₂⟩ rw [dist_le (mul_nonneg C_nonneg dist_nonneg)] intro x refine le_trans (lipschitz_with_lipschitz_const_add ⟨f₁ x, g₁ x⟩ ⟨f₂ x, g₂ x⟩) ?_ refine mul_le_mul_of_nonneg_left ?_ C_nonneg apply max_le_max <;> exact dist_coe_le_dist x⟩ end LipschitzAdd section sub variable [TopologicalSpace α] variable {R : Type*} [PseudoMetricSpace R] [Sub R] [BoundedSub R] [ContinuousSub R] variable (f g : α →ᵇ R) /-- The pointwise difference of two bounded continuous functions is again bounded continuous. -/ instance instSub : Sub (α →ᵇ R) where sub f g := { toFun := fun x ↦ (f x - g x), map_bounded' := sub_bounded_of_bounded_of_bounded f.map_bounded' g.map_bounded' } theorem sub_apply {x : α} : (f - g) x = f x - g x := rfl @[simp] theorem coe_sub : ⇑(f - g) = f - g := rfl end sub section casts variable [TopologicalSpace α] {β : Type*} [PseudoMetricSpace β] instance [NatCast β] : NatCast (α →ᵇ β) := ⟨fun n ↦ BoundedContinuousFunction.const _ n⟩ @[simp] theorem natCast_apply [NatCast β] (n : ℕ) (x : α) : (n : α →ᵇ β) x = n := rfl instance [IntCast β] : IntCast (α →ᵇ β) := ⟨fun m ↦ BoundedContinuousFunction.const _ m⟩ @[simp] theorem intCast_apply [IntCast β] (m : ℤ) (x : α) : (m : α →ᵇ β) x = m := rfl end casts section mul variable [TopologicalSpace α] {R : Type*} [PseudoMetricSpace R] instance instMul [Mul R] [BoundedMul R] [ContinuousMul R] : Mul (α →ᵇ R) where mul f g := { toFun := fun x ↦ f x * g x continuous_toFun := f.continuous.mul g.continuous map_bounded' := mul_bounded_of_bounded_of_bounded (map_bounded f) (map_bounded g) } @[simp] theorem coe_mul [Mul R] [BoundedMul R] [ContinuousMul R] (f g : α →ᵇ R) : ⇑(f * g) = f * g := rfl theorem mul_apply [Mul R] [BoundedMul R] [ContinuousMul R] (f g : α →ᵇ R) (x : α) : (f * g) x = f x * g x := rfl instance instPow [Monoid R] [BoundedMul R] [ContinuousMul R] : Pow (α →ᵇ R) ℕ where pow f n := { toFun := fun x ↦ (f x) ^ n continuous_toFun := f.continuous.pow n map_bounded' := by obtain ⟨C, hC⟩ := Metric.isBounded_iff.mp <| isBounded_pow (isBounded_range f) n exact ⟨C, fun x y ↦ hC (by simp) (by simp)⟩ } theorem coe_pow [Monoid R] [BoundedMul R] [ContinuousMul R] (n : ℕ) (f : α →ᵇ R) : ⇑(f ^ n) = (⇑f) ^ n := rfl @[simp] theorem pow_apply [Monoid R] [BoundedMul R] [ContinuousMul R] (n : ℕ) (f : α →ᵇ R) (x : α) : (f ^ n) x = f x ^ n := rfl instance instMonoid [Monoid R] [BoundedMul R] [ContinuousMul R] : Monoid (α →ᵇ R) := Injective.monoid (↑) DFunLike.coe_injective' rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) instance instCommMonoid [CommMonoid R] [BoundedMul R] [ContinuousMul R] : CommMonoid (α →ᵇ R) where __ := instMonoid mul_comm f g := by ext x; simp [mul_apply, mul_comm] instance instSemiring [Semiring R] [BoundedMul R] [ContinuousMul R] [BoundedAdd R] [ContinuousAdd R] : Semiring (α →ᵇ R) := Injective.semiring (↑) DFunLike.coe_injective' rfl rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) end mul section NormedAddCommGroup /- In this section, if `β` is a normed group, then we show that the space of bounded continuous functions from `α` to `β` inherits a normed group structure, by using pointwise operations and checking that they are compatible with the uniform distance. -/ variable [TopologicalSpace α] [SeminormedAddCommGroup β] variable (f g : α →ᵇ β) {x : α} {C : ℝ} instance instNorm : Norm (α →ᵇ β) := ⟨(dist · 0)⟩ theorem norm_def : ‖f‖ = dist f 0 := rfl /-- The norm of a bounded continuous function is the supremum of `‖f x‖`. We use `sInf` to ensure that the definition works if `α` has no elements. -/ theorem norm_eq (f : α →ᵇ β) : ‖f‖ = sInf { C : ℝ | 0 ≤ C ∧ ∀ x : α, ‖f x‖ ≤ C } := by simp [norm_def, BoundedContinuousFunction.dist_eq] /-- When the domain is non-empty, we do not need the `0 ≤ C` condition in the formula for `‖f‖` as a `sInf`. -/ theorem norm_eq_of_nonempty [h : Nonempty α] : ‖f‖ = sInf { C : ℝ | ∀ x : α, ‖f x‖ ≤ C } := by obtain ⟨a⟩ := h rw [norm_eq] congr ext simp only [mem_setOf_eq, and_iff_right_iff_imp] exact fun h' => le_trans (norm_nonneg (f a)) (h' a) @[simp] theorem norm_eq_zero_of_empty [IsEmpty α] : ‖f‖ = 0 := dist_zero_of_empty theorem norm_coe_le_norm (x : α) : ‖f x‖ ≤ ‖f‖ := calc ‖f x‖ = dist (f x) ((0 : α →ᵇ β) x) := by simp [dist_zero_right] _ ≤ ‖f‖ := dist_coe_le_dist _ lemma neg_norm_le_apply (f : α →ᵇ ℝ) (x : α) : -‖f‖ ≤ f x := (abs_le.mp (norm_coe_le_norm f x)).1 lemma apply_le_norm (f : α →ᵇ ℝ) (x : α) : f x ≤ ‖f‖ := (abs_le.mp (norm_coe_le_norm f x)).2 theorem dist_le_two_norm' {f : γ → β} {C : ℝ} (hC : ∀ x, ‖f x‖ ≤ C) (x y : γ) : dist (f x) (f y) ≤ 2 * C := calc dist (f x) (f y) ≤ ‖f x‖ + ‖f y‖ := dist_le_norm_add_norm _ _ _ ≤ C + C := add_le_add (hC x) (hC y) _ = 2 * C := (two_mul _).symm /-- Distance between the images of any two points is at most twice the norm of the function. -/ theorem dist_le_two_norm (x y : α) : dist (f x) (f y) ≤ 2 * ‖f‖ := dist_le_two_norm' f.norm_coe_le_norm x y variable {f} /-- The norm of a function is controlled by the supremum of the pointwise norms. -/ theorem norm_le (C0 : (0 : ℝ) ≤ C) : ‖f‖ ≤ C ↔ ∀ x : α, ‖f x‖ ≤ C := by simpa using @dist_le _ _ _ _ f 0 _ C0 theorem norm_le_of_nonempty [Nonempty α] {f : α →ᵇ β} {M : ℝ} : ‖f‖ ≤ M ↔ ∀ x, ‖f x‖ ≤ M := by simp_rw [norm_def, ← dist_zero_right] exact dist_le_iff_of_nonempty theorem norm_lt_iff_of_compact [CompactSpace α] {f : α →ᵇ β} {M : ℝ} (M0 : 0 < M) : ‖f‖ < M ↔ ∀ x, ‖f x‖ < M := by simp_rw [norm_def, ← dist_zero_right] exact dist_lt_iff_of_compact M0 theorem norm_lt_iff_of_nonempty_compact [Nonempty α] [CompactSpace α] {f : α →ᵇ β} {M : ℝ} : ‖f‖ < M ↔ ∀ x, ‖f x‖ < M := by simp_rw [norm_def, ← dist_zero_right] exact dist_lt_iff_of_nonempty_compact variable (f) /-- Norm of `const α b` is less than or equal to `‖b‖`. If `α` is nonempty, then it is equal to `‖b‖`. -/ theorem norm_const_le (b : β) : ‖const α b‖ ≤ ‖b‖ := (norm_le (norm_nonneg b)).2 fun _ => le_rfl @[simp] theorem norm_const_eq [h : Nonempty α] (b : β) : ‖const α b‖ = ‖b‖ := le_antisymm (norm_const_le b) <| h.elim fun x => (const α b).norm_coe_le_norm x /-- Constructing a bounded continuous function from a uniformly bounded continuous function taking values in a normed group. -/ def ofNormedAddCommGroup {α : Type u} {β : Type v} [TopologicalSpace α] [SeminormedAddCommGroup β] (f : α → β) (Hf : Continuous f) (C : ℝ) (H : ∀ x, ‖f x‖ ≤ C) : α →ᵇ β := ⟨⟨fun n => f n, Hf⟩, ⟨_, dist_le_two_norm' H⟩⟩ @[simp] theorem coe_ofNormedAddCommGroup {α : Type u} {β : Type v} [TopologicalSpace α] [SeminormedAddCommGroup β] (f : α → β) (Hf : Continuous f) (C : ℝ) (H : ∀ x, ‖f x‖ ≤ C) : (ofNormedAddCommGroup f Hf C H : α → β) = f := rfl theorem norm_ofNormedAddCommGroup_le {f : α → β} (hfc : Continuous f) {C : ℝ} (hC : 0 ≤ C) (hfC : ∀ x, ‖f x‖ ≤ C) : ‖ofNormedAddCommGroup f hfc C hfC‖ ≤ C := (norm_le hC).2 hfC /-- Constructing a bounded continuous function from a uniformly bounded function on a discrete space, taking values in a normed group. -/ def ofNormedAddCommGroupDiscrete {α : Type u} {β : Type v} [TopologicalSpace α] [DiscreteTopology α] [SeminormedAddCommGroup β] (f : α → β) (C : ℝ) (H : ∀ x, norm (f x) ≤ C) : α →ᵇ β := ofNormedAddCommGroup f continuous_of_discreteTopology C H @[simp] theorem coe_ofNormedAddCommGroupDiscrete {α : Type u} {β : Type v} [TopologicalSpace α] [DiscreteTopology α] [SeminormedAddCommGroup β] (f : α → β) (C : ℝ) (H : ∀ x, ‖f x‖ ≤ C) : (ofNormedAddCommGroupDiscrete f C H : α → β) = f := rfl /-- Taking the pointwise norm of a bounded continuous function with values in a `SeminormedAddCommGroup` yields a bounded continuous function with values in ℝ. -/ def normComp : α →ᵇ ℝ := f.comp norm lipschitzWith_one_norm @[simp] theorem coe_normComp : (f.normComp : α → ℝ) = norm ∘ f := rfl @[simp] theorem norm_normComp : ‖f.normComp‖ = ‖f‖ := by simp only [norm_eq, coe_normComp, norm_norm, Function.comp] theorem bddAbove_range_norm_comp : BddAbove <| Set.range <| norm ∘ f := (@isBounded_range _ _ _ _ f.normComp).bddAbove theorem norm_eq_iSup_norm : ‖f‖ = ⨆ x : α, ‖f x‖ := by simp_rw [norm_def, dist_eq_iSup, coe_zero, Pi.zero_apply, dist_zero_right] /-- If `‖(1 : β)‖ = 1`, then `‖(1 : α →ᵇ β)‖ = 1` if `α` is nonempty. -/ instance instNormOneClass [Nonempty α] [One β] [NormOneClass β] : NormOneClass (α →ᵇ β) where norm_one := by simp only [norm_eq_iSup_norm, coe_one, Pi.one_apply, norm_one, ciSup_const] /-- The pointwise opposite of a bounded continuous function is again bounded continuous. -/ instance : Neg (α →ᵇ β) := ⟨fun f => ofNormedAddCommGroup (-f) f.continuous.neg ‖f‖ fun x => norm_neg ((⇑f) x) ▸ f.norm_coe_le_norm x⟩ @[simp] theorem coe_neg : ⇑(-f) = -f := rfl theorem neg_apply : (-f) x = -f x := rfl @[simp] theorem mkOfCompact_neg [CompactSpace α] (f : C(α, β)) : mkOfCompact (-f) = -mkOfCompact f := rfl @[simp] theorem mkOfCompact_sub [CompactSpace α] (f g : C(α, β)) : mkOfCompact (f - g) = mkOfCompact f - mkOfCompact g := rfl @[simp] theorem coe_zsmulRec : ∀ z, ⇑(zsmulRec (· • ·) z f) = z • ⇑f | Int.ofNat n => by rw [zsmulRec, Int.ofNat_eq_coe, coe_nsmul, natCast_zsmul] | Int.negSucc n => by rw [zsmulRec, negSucc_zsmul, coe_neg, coe_nsmul] instance instSMulInt : SMul ℤ (α →ᵇ β) where smul n f := { toContinuousMap := n • f.toContinuousMap map_bounded' := by simpa using (zsmulRec (· • ·) n f).map_bounded' } @[simp] theorem coe_zsmul (r : ℤ) (f : α →ᵇ β) : ⇑(r • f) = r • ⇑f := rfl @[simp] theorem zsmul_apply (r : ℤ) (f : α →ᵇ β) (v : α) : (r • f) v = r • f v := rfl instance instAddCommGroup : AddCommGroup (α →ᵇ β) := DFunLike.coe_injective.addCommGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ => coe_nsmul _ _) fun _ _ => coe_zsmul _ _ instance instSeminormedAddCommGroup : SeminormedAddCommGroup (α →ᵇ β) where dist_eq f g := by simp only [norm_eq, dist_eq, dist_eq_norm, sub_apply] instance instNormedAddCommGroup {α β} [TopologicalSpace α] [NormedAddCommGroup β] : NormedAddCommGroup (α →ᵇ β) := { instSeminormedAddCommGroup with -- Porting note (#10888): Added a proof for `eq_of_dist_eq_zero` eq_of_dist_eq_zero } theorem nnnorm_def : ‖f‖₊ = nndist f 0 := rfl theorem nnnorm_coe_le_nnnorm (x : α) : ‖f x‖₊ ≤ ‖f‖₊ := norm_coe_le_norm _ _ theorem nndist_le_two_nnnorm (x y : α) : nndist (f x) (f y) ≤ 2 * ‖f‖₊ := dist_le_two_norm _ _ _ /-- The `nnnorm` of a function is controlled by the supremum of the pointwise `nnnorm`s. -/ theorem nnnorm_le (C : ℝ≥0) : ‖f‖₊ ≤ C ↔ ∀ x : α, ‖f x‖₊ ≤ C := norm_le C.prop theorem nnnorm_const_le (b : β) : ‖const α b‖₊ ≤ ‖b‖₊ := norm_const_le _ @[simp] theorem nnnorm_const_eq [Nonempty α] (b : β) : ‖const α b‖₊ = ‖b‖₊ := Subtype.ext <| norm_const_eq _ theorem nnnorm_eq_iSup_nnnorm : ‖f‖₊ = ⨆ x : α, ‖f x‖₊ := Subtype.ext <| (norm_eq_iSup_norm f).trans <| by simp_rw [val_eq_coe, NNReal.coe_iSup, coe_nnnorm] theorem abs_diff_coe_le_dist : ‖f x - g x‖ ≤ dist f g := by rw [dist_eq_norm] exact (f - g).norm_coe_le_norm x theorem coe_le_coe_add_dist {f g : α →ᵇ ℝ} : f x ≤ g x + dist f g := sub_le_iff_le_add'.1 <| (abs_le.1 <| @dist_coe_le_dist _ _ _ _ f g x).2 theorem norm_compContinuous_le [TopologicalSpace γ] (f : α →ᵇ β) (g : C(γ, α)) : ‖f.compContinuous g‖ ≤ ‖f‖ := ((lipschitz_compContinuous g).dist_le_mul f 0).trans <| by rw [NNReal.coe_one, one_mul, dist_zero_right] end NormedAddCommGroup section BoundedSMul /-! ### `BoundedSMul` (in particular, topological module) structure In this section, if `β` is a metric space and a `𝕜`-module whose addition and scalar multiplication are compatible with the metric structure, then we show that the space of bounded continuous functions from `α` to `β` inherits a so-called `BoundedSMul` structure (in particular, a `ContinuousMul` structure, which is the mathlib formulation of being a topological module), by using pointwise operations and checking that they are compatible with the uniform distance. -/ variable {𝕜 : Type*} [PseudoMetricSpace 𝕜] [TopologicalSpace α] [PseudoMetricSpace β] section SMul variable [Zero 𝕜] [Zero β] [SMul 𝕜 β] [BoundedSMul 𝕜 β] instance instSMul : SMul 𝕜 (α →ᵇ β) where smul c f := { toContinuousMap := c • f.toContinuousMap map_bounded' := let ⟨b, hb⟩ := f.bounded ⟨dist c 0 * b, fun x y => by refine (dist_smul_pair c (f x) (f y)).trans ?_ refine mul_le_mul_of_nonneg_left ?_ dist_nonneg exact hb x y⟩ } @[simp] theorem coe_smul (c : 𝕜) (f : α →ᵇ β) : ⇑(c • f) = fun x => c • f x := rfl theorem smul_apply (c : 𝕜) (f : α →ᵇ β) (x : α) : (c • f) x = c • f x := rfl instance instIsCentralScalar [SMul 𝕜ᵐᵒᵖ β] [IsCentralScalar 𝕜 β] : IsCentralScalar 𝕜 (α →ᵇ β) where op_smul_eq_smul _ _ := ext fun _ => op_smul_eq_smul _ _ instance instBoundedSMul : BoundedSMul 𝕜 (α →ᵇ β) where dist_smul_pair' c f₁ f₂ := by rw [dist_le (mul_nonneg dist_nonneg dist_nonneg)] intro x refine (dist_smul_pair c (f₁ x) (f₂ x)).trans ?_ exact mul_le_mul_of_nonneg_left (dist_coe_le_dist x) dist_nonneg dist_pair_smul' c₁ c₂ f := by rw [dist_le (mul_nonneg dist_nonneg dist_nonneg)] intro x refine (dist_pair_smul c₁ c₂ (f x)).trans ?_ refine mul_le_mul_of_nonneg_left ?_ dist_nonneg convert dist_coe_le_dist (β := β) x simp end SMul section MulAction variable [MonoidWithZero 𝕜] [Zero β] [MulAction 𝕜 β] [BoundedSMul 𝕜 β] instance instMulAction : MulAction 𝕜 (α →ᵇ β) := DFunLike.coe_injective.mulAction _ coe_smul end MulAction section DistribMulAction variable [MonoidWithZero 𝕜] [AddMonoid β] [DistribMulAction 𝕜 β] [BoundedSMul 𝕜 β] variable [BoundedAdd β] [ContinuousAdd β] instance instDistribMulAction : DistribMulAction 𝕜 (α →ᵇ β) := DFunLike.coe_injective.distribMulAction ⟨⟨_, coe_zero⟩, coe_add⟩ coe_smul end DistribMulAction section Module variable [Semiring 𝕜] [AddCommMonoid β] [Module 𝕜 β] [BoundedSMul 𝕜 β] variable {f g : α →ᵇ β} {x : α} {C : ℝ} variable [BoundedAdd β] [ContinuousAdd β] instance instModule : Module 𝕜 (α →ᵇ β) := DFunLike.coe_injective.module _ ⟨⟨_, coe_zero⟩, coe_add⟩ coe_smul variable (𝕜) /-- The evaluation at a point, as a continuous linear map from `α →ᵇ β` to `β`. -/ def evalCLM (x : α) : (α →ᵇ β) →L[𝕜] β where toFun f := f x map_add' f g := add_apply _ _ map_smul' c f := smul_apply _ _ _ @[simp] theorem evalCLM_apply (x : α) (f : α →ᵇ β) : evalCLM 𝕜 x f = f x := rfl variable (α β) /-- The linear map forgetting that a bounded continuous function is bounded. -/ @[simps] def toContinuousMapLinearMap : (α →ᵇ β) →ₗ[𝕜] C(α, β) where toFun := toContinuousMap map_smul' _ _ := rfl map_add' _ _ := rfl end Module end BoundedSMul section NormedSpace /-! ### Normed space structure In this section, if `β` is a normed space, then we show that the space of bounded continuous functions from `α` to `β` inherits a normed space structure, by using pointwise operations and checking that they are compatible with the uniform distance. -/ variable {𝕜 : Type*} variable [TopologicalSpace α] [SeminormedAddCommGroup β] variable {f g : α →ᵇ β} {x : α} {C : ℝ} instance instNormedSpace [NormedField 𝕜] [NormedSpace 𝕜 β] : NormedSpace 𝕜 (α →ᵇ β) := ⟨fun c f => by refine norm_ofNormedAddCommGroup_le _ (mul_nonneg (norm_nonneg _) (norm_nonneg _)) ?_ exact fun x => norm_smul c (f x) ▸ mul_le_mul_of_nonneg_left (f.norm_coe_le_norm _) (norm_nonneg _)⟩ variable [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 β] variable [SeminormedAddCommGroup γ] [NormedSpace 𝕜 γ] variable (α) -- TODO does this work in the `BoundedSMul` setting, too? /-- Postcomposition of bounded continuous functions into a normed module by a continuous linear map is a continuous linear map. Upgraded version of `ContinuousLinearMap.compLeftContinuous`, similar to `LinearMap.compLeft`. -/ protected def _root_.ContinuousLinearMap.compLeftContinuousBounded (g : β →L[𝕜] γ) : (α →ᵇ β) →L[𝕜] α →ᵇ γ := LinearMap.mkContinuous { toFun := fun f => ofNormedAddCommGroup (g ∘ f) (g.continuous.comp f.continuous) (‖g‖ * ‖f‖) fun x => g.le_opNorm_of_le (f.norm_coe_le_norm x) map_add' := fun f g => by ext; simp map_smul' := fun c f => by ext; simp } ‖g‖ fun f => norm_ofNormedAddCommGroup_le _ (mul_nonneg (norm_nonneg g) (norm_nonneg f)) (fun x => by exact g.le_opNorm_of_le (f.norm_coe_le_norm x)) @[simp] theorem _root_.ContinuousLinearMap.compLeftContinuousBounded_apply (g : β →L[𝕜] γ) (f : α →ᵇ β) (x : α) : (g.compLeftContinuousBounded α f) x = g (f x) := rfl end NormedSpace section NormedRing /-! ### Normed ring structure In this section, if `R` is a normed ring, then we show that the space of bounded continuous functions from `α` to `R` inherits a normed ring structure, by using pointwise operations and checking that they are compatible with the uniform distance. -/ variable [TopologicalSpace α] {R : Type*} section NonUnital section Seminormed variable [NonUnitalSeminormedRing R] instance instNonUnitalRing : NonUnitalRing (α →ᵇ R) := DFunLike.coe_injective.nonUnitalRing _ coe_zero coe_add coe_mul coe_neg coe_sub (fun _ _ => coe_nsmul _ _) fun _ _ => coe_zsmul _ _ instance instNonUnitalSeminormedRing : NonUnitalSeminormedRing (α →ᵇ R) := { instSeminormedAddCommGroup with norm_mul := fun f g => norm_ofNormedAddCommGroup_le _ (mul_nonneg (norm_nonneg _) (norm_nonneg _)) (fun x ↦ (norm_mul_le _ _).trans <| mul_le_mul (norm_coe_le_norm f x) (norm_coe_le_norm g x) (norm_nonneg _) (norm_nonneg _)) -- Porting note: These 5 fields were missing. Add them. left_distrib, right_distrib, zero_mul, mul_zero, mul_assoc } end Seminormed instance instNonUnitalNormedRing [NonUnitalNormedRing R] : NonUnitalNormedRing (α →ᵇ R) where __ := instNonUnitalSeminormedRing __ := instNormedAddCommGroup end NonUnital section Seminormed variable [SeminormedRing R] @[simp] theorem coe_npowRec (f : α →ᵇ R) : ∀ n, ⇑(npowRec n f) = (⇑f) ^ n | 0 => by rw [npowRec, pow_zero, coe_one] | n + 1 => by rw [npowRec, pow_succ, coe_mul, coe_npowRec f n] instance hasNatPow : Pow (α →ᵇ R) ℕ where pow f n := { toContinuousMap := f.toContinuousMap ^ n map_bounded' := by simpa [coe_npowRec] using (npowRec n f).map_bounded' } instance : NatCast (α →ᵇ R) := ⟨fun n => BoundedContinuousFunction.const _ n⟩ @[simp, norm_cast] theorem coe_natCast (n : ℕ) : ((n : α →ᵇ R) : α → R) = n := rfl -- See note [no_index around OfNat.ofNat] @[simp, norm_cast] theorem coe_ofNat (n : ℕ) [n.AtLeastTwo] : ((no_index OfNat.ofNat n : α →ᵇ R) : α → R) = OfNat.ofNat n := rfl instance : IntCast (α →ᵇ R) := ⟨fun n => BoundedContinuousFunction.const _ n⟩ @[simp, norm_cast] theorem coe_intCast (n : ℤ) : ((n : α →ᵇ R) : α → R) = n := rfl instance instRing : Ring (α →ᵇ R) := DFunLike.coe_injective.ring _ coe_zero coe_one coe_add coe_mul coe_neg coe_sub (fun _ _ => coe_nsmul _ _) (fun _ _ => coe_zsmul _ _) (fun _ _ => coe_pow _ _) coe_natCast coe_intCast instance instSeminormedRing : SeminormedRing (α →ᵇ R) where __ := instRing __ := instNonUnitalSeminormedRing end Seminormed instance instNormedRing [NormedRing R] : NormedRing (α →ᵇ R) where __ := instRing __ := instNonUnitalNormedRing end NormedRing section NormedCommRing /-! ### Normed commutative ring structure In this section, if `R` is a normed commutative ring, then we show that the space of bounded continuous functions from `α` to `R` inherits a normed commutative ring structure, by using pointwise operations and checking that they are compatible with the uniform distance. -/ variable [TopologicalSpace α] {R : Type*} instance instCommRing [SeminormedCommRing R] : CommRing (α →ᵇ R) where mul_comm _ _ := ext fun _ ↦ mul_comm _ _ instance instSeminormedCommRing [SeminormedCommRing R] : SeminormedCommRing (α →ᵇ R) where __ := instCommRing __ := instSeminormedAddCommGroup -- Porting note (#10888): Added proof for `norm_mul` norm_mul := norm_mul_le instance instNormedCommRing [NormedCommRing R] : NormedCommRing (α →ᵇ R) where __ := instCommRing __ := instNormedAddCommGroup -- Porting note (#10888): Added proof for `norm_mul` norm_mul := norm_mul_le end NormedCommRing section NormedAlgebra /-! ### Normed algebra structure In this section, if `γ` is a normed algebra, then we show that the space of bounded continuous functions from `α` to `γ` inherits a normed algebra structure, by using pointwise operations and checking that they are compatible with the uniform distance. -/ variable {𝕜 : Type*} [NormedField 𝕜] variable [TopologicalSpace α] [SeminormedAddCommGroup β] [NormedSpace 𝕜 β] variable [NormedRing γ] [NormedAlgebra 𝕜 γ] variable {f g : α →ᵇ γ} {x : α} {c : 𝕜} /-- `BoundedContinuousFunction.const` as a `RingHom`. -/ def C : 𝕜 →+* α →ᵇ γ where toFun := fun c : 𝕜 => const α ((algebraMap 𝕜 γ) c) map_one' := ext fun _ => (algebraMap 𝕜 γ).map_one map_mul' _ _ := ext fun _ => (algebraMap 𝕜 γ).map_mul _ _ map_zero' := ext fun _ => (algebraMap 𝕜 γ).map_zero map_add' _ _ := ext fun _ => (algebraMap 𝕜 γ).map_add _ _ instance instAlgebra : Algebra 𝕜 (α →ᵇ γ) where toRingHom := C commutes' _ _ := ext fun _ ↦ Algebra.commutes' _ _ smul_def' _ _ := ext fun _ ↦ Algebra.smul_def' _ _ @[simp] theorem algebraMap_apply (k : 𝕜) (a : α) : algebraMap 𝕜 (α →ᵇ γ) k a = k • (1 : γ) := by simp only [Algebra.algebraMap_eq_smul_one, coe_smul, coe_one, Pi.one_apply] instance instNormedAlgebra : NormedAlgebra 𝕜 (α →ᵇ γ) where __ := instAlgebra __ := instNormedSpace /-! ### Structure as normed module over scalar functions If `β` is a normed `𝕜`-space, then we show that the space of bounded continuous functions from `α` to `β` is naturally a module over the algebra of bounded continuous functions from `α` to `𝕜`. -/ instance instSMul' : SMul (α →ᵇ 𝕜) (α →ᵇ β) where smul f g := ofNormedAddCommGroup (fun x => f x • g x) (f.continuous.smul g.continuous) (‖f‖ * ‖g‖) fun x => calc ‖f x • g x‖ ≤ ‖f x‖ * ‖g x‖ := norm_smul_le _ _ _ ≤ ‖f‖ * ‖g‖ := mul_le_mul (f.norm_coe_le_norm _) (g.norm_coe_le_norm _) (norm_nonneg _) (norm_nonneg _) instance instModule' : Module (α →ᵇ 𝕜) (α →ᵇ β) := Module.ofMinimalAxioms (fun c _ _ => ext fun a => smul_add (c a) _ _) (fun _ _ _ => ext fun _ => add_smul _ _ _) (fun _ _ _ => ext fun _ => mul_smul _ _ _) (fun f => ext fun x => one_smul 𝕜 (f x)) /- TODO: When `NormedModule` has been added to `Analysis.Normed.Module.Basic`, this shows that the space of bounded continuous functions from `α` to `β` is naturally a normed module over the algebra of bounded continuous functions from `α` to `𝕜`. -/ instance : BoundedSMul (α →ᵇ 𝕜) (α →ᵇ β) := BoundedSMul.of_norm_smul_le fun _ _ => norm_ofNormedAddCommGroup_le _ (mul_nonneg (norm_nonneg _) (norm_nonneg _)) _ end NormedAlgebra theorem NNReal.upper_bound {α : Type*} [TopologicalSpace α] (f : α →ᵇ ℝ≥0) (x : α) : f x ≤ nndist f 0 := by have key : nndist (f x) ((0 : α →ᵇ ℝ≥0) x) ≤ nndist f 0 := @dist_coe_le_dist α ℝ≥0 _ _ f 0 x simp only [coe_zero, Pi.zero_apply] at key rwa [NNReal.nndist_zero_eq_val' (f x)] at key /-! ### Star structures In this section, if `β` is a normed ⋆-group, then so is the space of bounded continuous functions from `α` to `β`, by using the star operation pointwise. If `𝕜` is normed field and a ⋆-ring over which `β` is a normed algebra and a star module, then the space of bounded continuous functions from `α` to `β` is a star module. If `β` is a ⋆-ring in addition to being a normed ⋆-group, then `α →ᵇ β` inherits a ⋆-ring structure. In summary, if `β` is a C⋆-algebra over `𝕜`, then so is `α →ᵇ β`; note that completeness is guaranteed when `β` is complete (see `BoundedContinuousFunction.complete`). -/ section NormedAddCommGroup variable {𝕜 : Type*} [NormedField 𝕜] [StarRing 𝕜] [TopologicalSpace α] [SeminormedAddCommGroup β] [StarAddMonoid β] [NormedStarGroup β] variable [NormedSpace 𝕜 β] [StarModule 𝕜 β] instance instStarAddMonoid : StarAddMonoid (α →ᵇ β) where star f := f.comp star starNormedAddGroupHom.lipschitz star_involutive f := ext fun x => star_star (f x) star_add f g := ext fun x => star_add (f x) (g x) /-- The right-hand side of this equality can be parsed `star ∘ ⇑f` because of the instance `Pi.instStarForAll`. Upon inspecting the goal, one sees `⊢ ↑(star f) = star ↑f`. -/ @[simp] theorem coe_star (f : α →ᵇ β) : ⇑(star f) = star (⇑f) := rfl @[simp] theorem star_apply (f : α →ᵇ β) (x : α) : star f x = star (f x) := rfl instance instNormedStarGroup : NormedStarGroup (α →ᵇ β) where norm_star f := by simp only [norm_eq, star_apply, norm_star] instance instStarModule : StarModule 𝕜 (α →ᵇ β) where star_smul k f := ext fun x => star_smul k (f x) end NormedAddCommGroup section CStarRing variable [TopologicalSpace α] variable [NonUnitalNormedRing β] [StarRing β] instance instStarRing [NormedStarGroup β] : StarRing (α →ᵇ β) where __ := instStarAddMonoid star_mul f g := ext fun x ↦ star_mul (f x) (g x) variable [CStarRing β] instance instCStarRing : CStarRing (α →ᵇ β) where norm_mul_self_le f := by rw [← sq, ← Real.le_sqrt (norm_nonneg _) (norm_nonneg _), norm_le (Real.sqrt_nonneg _)] intro x rw [Real.le_sqrt (norm_nonneg _) (norm_nonneg _), sq, ← CStarRing.norm_star_mul_self] exact norm_coe_le_norm (star f * f) x end CStarRing section NormedLatticeOrderedGroup variable [TopologicalSpace α] [NormedLatticeAddCommGroup β] instance instPartialOrder : PartialOrder (α →ᵇ β) := PartialOrder.lift (fun f => f.toFun) (by simp [Injective]) instance instSup : Sup (α →ᵇ β) where sup f g := { toFun := f ⊔ g continuous_toFun := f.continuous.sup g.continuous map_bounded' := by obtain ⟨C₁, hf⟩ := f.bounded obtain ⟨C₂, hg⟩ := g.bounded refine ⟨C₁ + C₂, fun x y ↦ ?_⟩ simp_rw [NormedAddCommGroup.dist_eq] at hf hg ⊢ exact (norm_sup_sub_sup_le_add_norm _ _ _ _).trans (add_le_add (hf _ _) (hg _ _)) } instance instInf : Inf (α →ᵇ β) where inf f g := { toFun := f ⊓ g continuous_toFun := f.continuous.inf g.continuous map_bounded' := by obtain ⟨C₁, hf⟩ := f.bounded obtain ⟨C₂, hg⟩ := g.bounded refine ⟨C₁ + C₂, fun x y ↦ ?_⟩ simp_rw [NormedAddCommGroup.dist_eq] at hf hg ⊢ exact (norm_inf_sub_inf_le_add_norm _ _ _ _).trans (add_le_add (hf _ _) (hg _ _)) } @[simp, norm_cast] lemma coe_sup (f g : α →ᵇ β) : ⇑(f ⊔ g) = ⇑f ⊔ ⇑g := rfl @[simp, norm_cast] lemma coe_inf (f g : α →ᵇ β) : ⇑(f ⊓ g) = ⇑f ⊓ ⇑g := rfl instance instSemilatticeSup : SemilatticeSup (α →ᵇ β) := DFunLike.coe_injective.semilatticeSup _ coe_sup instance instSemilatticeInf : SemilatticeInf (α →ᵇ β) := DFunLike.coe_injective.semilatticeInf _ coe_inf instance instLattice : Lattice (α →ᵇ β) := DFunLike.coe_injective.lattice _ coe_sup coe_inf @[simp, norm_cast] lemma coe_abs (f : α →ᵇ β) : ⇑|f| = |⇑f| := rfl @[simp, norm_cast] lemma coe_posPart (f : α →ᵇ β) : ⇑f⁺ = (⇑f)⁺ := rfl @[simp, norm_cast] lemma coe_negPart (f : α →ᵇ β) : ⇑f⁻ = (⇑f)⁻ := rfl @[deprecated (since := "2024-02-21")] alias coeFn_sup := coe_sup @[deprecated (since := "2024-02-21")] alias coeFn_abs := coe_abs instance instNormedLatticeAddCommGroup : NormedLatticeAddCommGroup (α →ᵇ β) := { instSeminormedAddCommGroup with add_le_add_left := by intro f g h₁ h t simp only [coe_to_continuous_fun, Pi.add_apply, add_le_add_iff_left, coe_add, ContinuousMap.toFun_eq_coe] exact h₁ _ solid := by intro f g h have i1 : ∀ t, ‖f t‖ ≤ ‖g t‖ := fun t => HasSolidNorm.solid (h t) rw [norm_le (norm_nonneg _)] exact fun t => (i1 t).trans (norm_coe_le_norm g t) -- Porting note (#10888): added proof for `eq_of_dist_eq_zero` eq_of_dist_eq_zero } end NormedLatticeOrderedGroup section NonnegativePart variable [TopologicalSpace α] /-- The nonnegative part of a bounded continuous `ℝ`-valued function as a bounded continuous `ℝ≥0`-valued function. -/ def nnrealPart (f : α →ᵇ ℝ) : α →ᵇ ℝ≥0 := BoundedContinuousFunction.comp _ (show LipschitzWith 1 Real.toNNReal from lipschitzWith_posPart) f @[simp] theorem nnrealPart_coeFn_eq (f : α →ᵇ ℝ) : ⇑f.nnrealPart = Real.toNNReal ∘ ⇑f := rfl /-- The absolute value of a bounded continuous `ℝ`-valued function as a bounded continuous `ℝ≥0`-valued function. -/ def nnnorm (f : α →ᵇ ℝ) : α →ᵇ ℝ≥0 := BoundedContinuousFunction.comp _ (show LipschitzWith 1 fun x : ℝ => ‖x‖₊ from lipschitzWith_one_norm) f @[simp] theorem nnnorm_coeFn_eq (f : α →ᵇ ℝ) : ⇑f.nnnorm = NNNorm.nnnorm ∘ ⇑f := rfl -- TODO: Use `posPart` and `negPart` here /-- Decompose a bounded continuous function to its positive and negative parts. -/ theorem self_eq_nnrealPart_sub_nnrealPart_neg (f : α →ᵇ ℝ) : ⇑f = (↑) ∘ f.nnrealPart - (↑) ∘ (-f).nnrealPart := by funext x dsimp simp only [max_zero_sub_max_neg_zero_eq_self] /-- Express the absolute value of a bounded continuous function in terms of its positive and negative parts. -/ theorem abs_self_eq_nnrealPart_add_nnrealPart_neg (f : α →ᵇ ℝ) : abs ∘ ⇑f = (↑) ∘ f.nnrealPart + (↑) ∘ (-f).nnrealPart := by funext x dsimp simp only [max_zero_add_max_neg_zero_eq_abs_self] end NonnegativePart section variable {α : Type*} [TopologicalSpace α] -- TODO: `f + const _ ‖f‖` is just `f⁺` lemma add_norm_nonneg (f : α →ᵇ ℝ) : 0 ≤ f + const _ ‖f‖ := by intro x simp only [ContinuousMap.toFun_eq_coe, coe_to_continuous_fun, coe_zero, Pi.zero_apply, coe_add, const_toFun, Pi.add_apply] linarith [(abs_le.mp (norm_coe_le_norm f x)).1] lemma norm_sub_nonneg (f : α →ᵇ ℝ) : 0 ≤ const _ ‖f‖ - f := by intro x simp only [ContinuousMap.toFun_eq_coe, coe_to_continuous_fun, coe_zero, Pi.zero_apply, coe_sub, const_toFun, Pi.sub_apply, sub_nonneg] linarith [(abs_le.mp (norm_coe_le_norm f x)).2] end end BoundedContinuousFunction
Topology\ContinuousFunction\CocompactMap.lean
/- Copyright (c) 2022 Jireh Loreaux. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jireh Loreaux -/ import Mathlib.Topology.ContinuousFunction.Basic /-! # Cocompact continuous maps The type of *cocompact continuous maps* are those which tend to the cocompact filter on the codomain along the cocompact filter on the domain. When the domain and codomain are Hausdorff, this is equivalent to many other conditions, including that preimages of compact sets are compact. -/ universe u v w open Filter Set /-! ### Cocompact continuous maps -/ /-- A *cocompact continuous map* is a continuous function between topological spaces which tends to the cocompact filter along the cocompact filter. Functions for which preimages of compact sets are compact always satisfy this property, and the converse holds for cocompact continuous maps when the codomain is Hausdorff (see `CocompactMap.tendsto_of_forall_preimage` and `CocompactMap.isCompact_preimage`). Cocompact maps thus generalise proper maps, with which they correspond when the codomain is Hausdorff. -/ structure CocompactMap (α : Type u) (β : Type v) [TopologicalSpace α] [TopologicalSpace β] extends ContinuousMap α β : Type max u v where /-- The cocompact filter on `α` tends to the cocompact filter on `β` under the function -/ cocompact_tendsto' : Tendsto toFun (cocompact α) (cocompact β) section /-- `CocompactMapClass F α β` states that `F` is a type of cocompact continuous maps. You should also extend this typeclass when you extend `CocompactMap`. -/ class CocompactMapClass (F : Type*) (α β : outParam Type*) [TopologicalSpace α] [TopologicalSpace β] [FunLike F α β] extends ContinuousMapClass F α β : Prop where /-- The cocompact filter on `α` tends to the cocompact filter on `β` under the function -/ cocompact_tendsto (f : F) : Tendsto f (cocompact α) (cocompact β) end namespace CocompactMapClass variable {F α β : Type*} [TopologicalSpace α] [TopologicalSpace β] variable [FunLike F α β] [CocompactMapClass F α β] /-- Turn an element of a type `F` satisfying `CocompactMapClass F α β` into an actual `CocompactMap`. This is declared as the default coercion from `F` to `CocompactMap α β`. -/ @[coe] def toCocompactMap (f : F) : CocompactMap α β := { (f : C(α, β)) with cocompact_tendsto' := cocompact_tendsto f } instance : CoeTC F (CocompactMap α β) := ⟨toCocompactMap⟩ end CocompactMapClass export CocompactMapClass (cocompact_tendsto) namespace CocompactMap section Basics variable {α β γ δ : Type*} [TopologicalSpace α] [TopologicalSpace β] [TopologicalSpace γ] [TopologicalSpace δ] instance : FunLike (CocompactMap α β) α β where coe f := f.toFun coe_injective' f g h := by obtain ⟨⟨_, _⟩, _⟩ := f obtain ⟨⟨_, _⟩, _⟩ := g congr instance : CocompactMapClass (CocompactMap α β) α β where map_continuous f := f.continuous_toFun cocompact_tendsto f := f.cocompact_tendsto' @[simp] theorem coe_toContinuousMap {f : CocompactMap α β} : (f.toContinuousMap : α → β) = f := rfl @[ext] theorem ext {f g : CocompactMap α β} (h : ∀ x, f x = g x) : f = g := DFunLike.ext _ _ h /-- Copy of a `CocompactMap` with a new `toFun` equal to the old one. Useful to fix definitional equalities. -/ protected def copy (f : CocompactMap α β) (f' : α → β) (h : f' = f) : CocompactMap α β where toFun := f' continuous_toFun := by rw [h] exact f.continuous_toFun cocompact_tendsto' := by simp_rw [h] exact f.cocompact_tendsto' @[simp] theorem coe_copy (f : CocompactMap α β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' := rfl theorem copy_eq (f : CocompactMap α β) (f' : α → β) (h : f' = f) : f.copy f' h = f := DFunLike.ext' h @[simp] theorem coe_mk (f : C(α, β)) (h : Tendsto f (cocompact α) (cocompact β)) : ⇑(⟨f, h⟩ : CocompactMap α β) = f := rfl section variable (α) /-- The identity as a cocompact continuous map. -/ protected def id : CocompactMap α α := ⟨ContinuousMap.id _, tendsto_id⟩ @[simp] theorem coe_id : ⇑(CocompactMap.id α) = id := rfl end instance : Inhabited (CocompactMap α α) := ⟨CocompactMap.id α⟩ /-- The composition of cocompact continuous maps, as a cocompact continuous map. -/ def comp (f : CocompactMap β γ) (g : CocompactMap α β) : CocompactMap α γ := ⟨f.toContinuousMap.comp g, (cocompact_tendsto f).comp (cocompact_tendsto g)⟩ @[simp] theorem coe_comp (f : CocompactMap β γ) (g : CocompactMap α β) : ⇑(comp f g) = f ∘ g := rfl @[simp] theorem comp_apply (f : CocompactMap β γ) (g : CocompactMap α β) (a : α) : comp f g a = f (g a) := rfl @[simp] theorem comp_assoc (f : CocompactMap γ δ) (g : CocompactMap β γ) (h : CocompactMap α β) : (f.comp g).comp h = f.comp (g.comp h) := rfl @[simp] theorem id_comp (f : CocompactMap α β) : (CocompactMap.id _).comp f = f := ext fun _ => rfl @[simp] theorem comp_id (f : CocompactMap α β) : f.comp (CocompactMap.id _) = f := ext fun _ => rfl theorem tendsto_of_forall_preimage {f : α → β} (h : ∀ s, IsCompact s → IsCompact (f ⁻¹' s)) : Tendsto f (cocompact α) (cocompact β) := fun s hs => match mem_cocompact.mp hs with | ⟨t, ht, hts⟩ => mem_map.mpr (mem_cocompact.mpr ⟨f ⁻¹' t, h t ht, by simpa using preimage_mono hts⟩) /-- Preimages of compact closed sets are compact under a cocompact continuous map. -/ theorem isCompact_preimage_of_isClosed (f : CocompactMap α β) ⦃s : Set β⦄ (hs : IsCompact s) (h's : IsClosed s) : IsCompact (f ⁻¹' s) := by obtain ⟨t, ht, hts⟩ := mem_cocompact'.mp (by simpa only [preimage_image_preimage, preimage_compl] using mem_map.mp (cocompact_tendsto f <| mem_cocompact.mpr ⟨s, hs, compl_subset_compl.mpr (image_preimage_subset f _)⟩)) exact ht.of_isClosed_subset (h's.preimage <| map_continuous f) (by simpa using hts) /-- If the codomain is Hausdorff, preimages of compact sets are compact under a cocompact continuous map. -/ theorem isCompact_preimage [T2Space β] (f : CocompactMap α β) ⦃s : Set β⦄ (hs : IsCompact s) : IsCompact (f ⁻¹' s) := isCompact_preimage_of_isClosed f hs hs.isClosed end Basics end CocompactMap /-- A homeomorphism is a cocompact map. -/ @[simps] def Homeomorph.toCocompactMap {α β : Type*} [TopologicalSpace α] [TopologicalSpace β] (f : α ≃ₜ β) : CocompactMap α β where toFun := f continuous_toFun := f.continuous cocompact_tendsto' := by refine CocompactMap.tendsto_of_forall_preimage fun K hK => ?_ erw [K.preimage_equiv_eq_image_symm] exact hK.image f.symm.continuous
Topology\ContinuousFunction\Compact.lean
/- Copyright (c) 2021 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Topology.ContinuousFunction.Bounded import Mathlib.Topology.UniformSpace.Compact import Mathlib.Topology.CompactOpen import Mathlib.Topology.Sets.Compacts import Mathlib.Analysis.Normed.Group.InfiniteSum /-! # Continuous functions on a compact space Continuous functions `C(α, β)` from a compact space `α` to a metric space `β` are automatically bounded, and so acquire various structures inherited from `α →ᵇ β`. This file transfers these structures, and restates some lemmas characterising these structures. If you need a lemma which is proved about `α →ᵇ β` but not for `C(α, β)` when `α` is compact, you should restate it here. You can also use `ContinuousMap.equivBoundedOfCompact` to move functions back and forth. -/ noncomputable section open scoped Classical open Topology NNReal BoundedContinuousFunction open Set Filter Metric open BoundedContinuousFunction namespace ContinuousMap variable {α β E : Type*} [TopologicalSpace α] [CompactSpace α] [MetricSpace β] [NormedAddCommGroup E] section variable (α β) /-- When `α` is compact, the bounded continuous maps `α →ᵇ β` are equivalent to `C(α, β)`. -/ @[simps (config := .asFn)] def equivBoundedOfCompact : C(α, β) ≃ (α →ᵇ β) := ⟨mkOfCompact, BoundedContinuousFunction.toContinuousMap, fun f => by ext rfl, fun f => by ext rfl⟩ theorem uniformInducing_equivBoundedOfCompact : UniformInducing (equivBoundedOfCompact α β) := UniformInducing.mk' (by simp only [hasBasis_compactConvergenceUniformity.mem_iff, uniformity_basis_dist_le.mem_iff] exact fun s => ⟨fun ⟨⟨a, b⟩, ⟨_, ⟨ε, hε, hb⟩⟩, hs⟩ => ⟨{ p | ∀ x, (p.1 x, p.2 x) ∈ b }, ⟨ε, hε, fun _ h x => hb ((dist_le hε.le).mp h x)⟩, fun f g h => hs fun x _ => h x⟩, fun ⟨_, ⟨ε, hε, ht⟩, hs⟩ => ⟨⟨Set.univ, { p | dist p.1 p.2 ≤ ε }⟩, ⟨isCompact_univ, ⟨ε, hε, fun _ h => h⟩⟩, fun ⟨f, g⟩ h => hs _ _ (ht ((dist_le hε.le).mpr fun x => h x (mem_univ x)))⟩⟩) theorem uniformEmbedding_equivBoundedOfCompact : UniformEmbedding (equivBoundedOfCompact α β) := { uniformInducing_equivBoundedOfCompact α β with inj := (equivBoundedOfCompact α β).injective } /-- When `α` is compact, the bounded continuous maps `α →ᵇ 𝕜` are additively equivalent to `C(α, 𝕜)`. -/ -- Porting note: the following `simps` received a "maximum recursion depth" error -- @[simps! (config := .asFn) apply symm_apply] def addEquivBoundedOfCompact [AddMonoid β] [LipschitzAdd β] : C(α, β) ≃+ (α →ᵇ β) := ({ toContinuousMapAddHom α β, (equivBoundedOfCompact α β).symm with } : (α →ᵇ β) ≃+ C(α, β)).symm -- Porting note: added this `simp` lemma manually because of the `simps` error above @[simp] theorem addEquivBoundedOfCompact_symm_apply [AddMonoid β] [LipschitzAdd β] : ⇑((addEquivBoundedOfCompact α β).symm) = toContinuousMapAddHom α β := rfl -- Porting note: added this `simp` lemma manually because of the `simps` error above @[simp] theorem addEquivBoundedOfCompact_apply [AddMonoid β] [LipschitzAdd β] : ⇑(addEquivBoundedOfCompact α β) = mkOfCompact := rfl instance metricSpace : MetricSpace C(α, β) := (uniformEmbedding_equivBoundedOfCompact α β).comapMetricSpace _ /-- When `α` is compact, and `β` is a metric space, the bounded continuous maps `α →ᵇ β` are isometric to `C(α, β)`. -/ @[simps! (config := .asFn) toEquiv apply symm_apply] def isometryEquivBoundedOfCompact : C(α, β) ≃ᵢ (α →ᵇ β) where isometry_toFun _ _ := rfl toEquiv := equivBoundedOfCompact α β end @[simp] theorem _root_.BoundedContinuousFunction.dist_mkOfCompact (f g : C(α, β)) : dist (mkOfCompact f) (mkOfCompact g) = dist f g := rfl @[simp] theorem _root_.BoundedContinuousFunction.dist_toContinuousMap (f g : α →ᵇ β) : dist f.toContinuousMap g.toContinuousMap = dist f g := rfl open BoundedContinuousFunction section variable {f g : C(α, β)} {C : ℝ} /-- The pointwise distance is controlled by the distance between functions, by definition. -/ theorem dist_apply_le_dist (x : α) : dist (f x) (g x) ≤ dist f g := by simp only [← dist_mkOfCompact, dist_coe_le_dist, ← mkOfCompact_apply] /-- The distance between two functions is controlled by the supremum of the pointwise distances. -/ theorem dist_le (C0 : (0 : ℝ) ≤ C) : dist f g ≤ C ↔ ∀ x : α, dist (f x) (g x) ≤ C := by simp only [← dist_mkOfCompact, BoundedContinuousFunction.dist_le C0, mkOfCompact_apply] theorem dist_le_iff_of_nonempty [Nonempty α] : dist f g ≤ C ↔ ∀ x, dist (f x) (g x) ≤ C := by simp only [← dist_mkOfCompact, BoundedContinuousFunction.dist_le_iff_of_nonempty, mkOfCompact_apply] theorem dist_lt_iff_of_nonempty [Nonempty α] : dist f g < C ↔ ∀ x : α, dist (f x) (g x) < C := by simp only [← dist_mkOfCompact, dist_lt_iff_of_nonempty_compact, mkOfCompact_apply] theorem dist_lt_of_nonempty [Nonempty α] (w : ∀ x : α, dist (f x) (g x) < C) : dist f g < C := dist_lt_iff_of_nonempty.2 w theorem dist_lt_iff (C0 : (0 : ℝ) < C) : dist f g < C ↔ ∀ x : α, dist (f x) (g x) < C := by rw [← dist_mkOfCompact, dist_lt_iff_of_compact C0] simp only [mkOfCompact_apply] end instance [CompleteSpace β] : CompleteSpace C(α, β) := (isometryEquivBoundedOfCompact α β).completeSpace -- TODO at some point we will need lemmas characterising this norm! -- At the moment the only way to reason about it is to transfer `f : C(α,E)` back to `α →ᵇ E`. instance : Norm C(α, E) where norm x := dist x 0 @[simp] theorem _root_.BoundedContinuousFunction.norm_mkOfCompact (f : C(α, E)) : ‖mkOfCompact f‖ = ‖f‖ := rfl @[simp] theorem _root_.BoundedContinuousFunction.norm_toContinuousMap_eq (f : α →ᵇ E) : ‖f.toContinuousMap‖ = ‖f‖ := rfl open BoundedContinuousFunction instance : NormedAddCommGroup C(α, E) := { ContinuousMap.metricSpace _ _, ContinuousMap.instAddCommGroupContinuousMap with dist_eq := fun x y => by rw [← norm_mkOfCompact, ← dist_mkOfCompact, dist_eq_norm, mkOfCompact_sub] dist := dist norm := norm } instance [Nonempty α] [One E] [NormOneClass E] : NormOneClass C(α, E) where norm_one := by simp only [← norm_mkOfCompact, mkOfCompact_one, norm_one] section variable (f : C(α, E)) -- The corresponding lemmas for `BoundedContinuousFunction` are stated with `{f}`, -- and so can not be used in dot notation. theorem norm_coe_le_norm (x : α) : ‖f x‖ ≤ ‖f‖ := (mkOfCompact f).norm_coe_le_norm x /-- Distance between the images of any two points is at most twice the norm of the function. -/ theorem dist_le_two_norm (x y : α) : dist (f x) (f y) ≤ 2 * ‖f‖ := (mkOfCompact f).dist_le_two_norm x y /-- The norm of a function is controlled by the supremum of the pointwise norms. -/ theorem norm_le {C : ℝ} (C0 : (0 : ℝ) ≤ C) : ‖f‖ ≤ C ↔ ∀ x : α, ‖f x‖ ≤ C := @BoundedContinuousFunction.norm_le _ _ _ _ (mkOfCompact f) _ C0 theorem norm_le_of_nonempty [Nonempty α] {M : ℝ} : ‖f‖ ≤ M ↔ ∀ x, ‖f x‖ ≤ M := @BoundedContinuousFunction.norm_le_of_nonempty _ _ _ _ _ (mkOfCompact f) _ theorem norm_lt_iff {M : ℝ} (M0 : 0 < M) : ‖f‖ < M ↔ ∀ x, ‖f x‖ < M := @BoundedContinuousFunction.norm_lt_iff_of_compact _ _ _ _ _ (mkOfCompact f) _ M0 theorem nnnorm_lt_iff {M : ℝ≥0} (M0 : 0 < M) : ‖f‖₊ < M ↔ ∀ x : α, ‖f x‖₊ < M := f.norm_lt_iff M0 theorem norm_lt_iff_of_nonempty [Nonempty α] {M : ℝ} : ‖f‖ < M ↔ ∀ x, ‖f x‖ < M := @BoundedContinuousFunction.norm_lt_iff_of_nonempty_compact _ _ _ _ _ _ (mkOfCompact f) _ theorem nnnorm_lt_iff_of_nonempty [Nonempty α] {M : ℝ≥0} : ‖f‖₊ < M ↔ ∀ x, ‖f x‖₊ < M := f.norm_lt_iff_of_nonempty theorem apply_le_norm (f : C(α, ℝ)) (x : α) : f x ≤ ‖f‖ := le_trans (le_abs.mpr (Or.inl (le_refl (f x)))) (f.norm_coe_le_norm x) theorem neg_norm_le_apply (f : C(α, ℝ)) (x : α) : -‖f‖ ≤ f x := le_trans (neg_le_neg (f.norm_coe_le_norm x)) (neg_le.mp (neg_le_abs (f x))) theorem norm_eq_iSup_norm : ‖f‖ = ⨆ x : α, ‖f x‖ := (mkOfCompact f).norm_eq_iSup_norm theorem norm_restrict_mono_set {X : Type*} [TopologicalSpace X] (f : C(X, E)) {K L : TopologicalSpace.Compacts X} (hKL : K ≤ L) : ‖f.restrict K‖ ≤ ‖f.restrict L‖ := (norm_le _ (norm_nonneg _)).mpr fun x => norm_coe_le_norm (f.restrict L) <| Set.inclusion hKL x end section variable {R : Type*} [NormedRing R] instance : NormedRing C(α, R) := { (inferInstance : NormedAddCommGroup C(α, R)), ContinuousMap.instRing with norm_mul := fun f g => norm_mul_le (mkOfCompact f) (mkOfCompact g) } end section variable {𝕜 : Type*} [NormedField 𝕜] [NormedSpace 𝕜 E] instance normedSpace : NormedSpace 𝕜 C(α, E) where norm_smul_le c f := (norm_smul_le c (mkOfCompact f) : _) section variable (α 𝕜 E) /-- When `α` is compact and `𝕜` is a normed field, the `𝕜`-algebra of bounded continuous maps `α →ᵇ β` is `𝕜`-linearly isometric to `C(α, β)`. -/ def linearIsometryBoundedOfCompact : C(α, E) ≃ₗᵢ[𝕜] α →ᵇ E := { addEquivBoundedOfCompact α E with map_smul' := fun c f => by ext norm_cast norm_map' := fun f => rfl } variable {α E} -- to match `BoundedContinuousFunction.evalCLM` /-- The evaluation at a point, as a continuous linear map from `C(α, 𝕜)` to `𝕜`. -/ def evalCLM (x : α) : C(α, E) →L[𝕜] E := (BoundedContinuousFunction.evalCLM 𝕜 x).comp (linearIsometryBoundedOfCompact α E 𝕜).toLinearIsometry.toContinuousLinearMap end -- this lemma and the next are the analogues of those autogenerated by `@[simps]` for -- `equivBoundedOfCompact`, `addEquivBoundedOfCompact` @[simp] theorem linearIsometryBoundedOfCompact_symm_apply (f : α →ᵇ E) : (linearIsometryBoundedOfCompact α E 𝕜).symm f = f.toContinuousMap := rfl @[simp] theorem linearIsometryBoundedOfCompact_apply_apply (f : C(α, E)) (a : α) : (linearIsometryBoundedOfCompact α E 𝕜 f) a = f a := rfl @[simp] theorem linearIsometryBoundedOfCompact_toIsometryEquiv : (linearIsometryBoundedOfCompact α E 𝕜).toIsometryEquiv = isometryEquivBoundedOfCompact α E := rfl @[simp] -- Porting note: adjusted LHS because `simpNF` complained it simplified. theorem linearIsometryBoundedOfCompact_toAddEquiv : ((linearIsometryBoundedOfCompact α E 𝕜).toLinearEquiv : C(α, E) ≃+ (α →ᵇ E)) = addEquivBoundedOfCompact α E := rfl @[simp] theorem linearIsometryBoundedOfCompact_of_compact_toEquiv : (linearIsometryBoundedOfCompact α E 𝕜).toLinearEquiv.toEquiv = equivBoundedOfCompact α E := rfl end section variable {𝕜 : Type*} {γ : Type*} [NormedField 𝕜] [NormedRing γ] [NormedAlgebra 𝕜 γ] instance : NormedAlgebra 𝕜 C(α, γ) := { ContinuousMap.normedSpace, ContinuousMap.algebra with } end end ContinuousMap namespace ContinuousMap section UniformContinuity variable {α β : Type*} variable [MetricSpace α] [CompactSpace α] [MetricSpace β] /-! We now set up some declarations making it convenient to use uniform continuity. -/ theorem uniform_continuity (f : C(α, β)) (ε : ℝ) (h : 0 < ε) : ∃ δ > 0, ∀ {x y}, dist x y < δ → dist (f x) (f y) < ε := Metric.uniformContinuous_iff.mp (CompactSpace.uniformContinuous_of_continuous f.continuous) ε h -- This definition allows us to separate the choice of some `δ`, -- and the corresponding use of `dist a b < δ → dist (f a) (f b) < ε`, -- even across different declarations. /-- An arbitrarily chosen modulus of uniform continuity for a given function `f` and `ε > 0`. -/ def modulus (f : C(α, β)) (ε : ℝ) (h : 0 < ε) : ℝ := Classical.choose (uniform_continuity f ε h) theorem modulus_pos (f : C(α, β)) {ε : ℝ} {h : 0 < ε} : 0 < f.modulus ε h := (Classical.choose_spec (uniform_continuity f ε h)).1 theorem dist_lt_of_dist_lt_modulus (f : C(α, β)) (ε : ℝ) (h : 0 < ε) {a b : α} (w : dist a b < f.modulus ε h) : dist (f a) (f b) < ε := (Classical.choose_spec (uniform_continuity f ε h)).2 w end UniformContinuity end ContinuousMap section CompLeft variable (X : Type*) {𝕜 β γ : Type*} [TopologicalSpace X] [CompactSpace X] [NontriviallyNormedField 𝕜] variable [NormedAddCommGroup β] [NormedSpace 𝕜 β] [NormedAddCommGroup γ] [NormedSpace 𝕜 γ] open ContinuousMap /-- Postcomposition of continuous functions into a normed module by a continuous linear map is a continuous linear map. Transferred version of `ContinuousLinearMap.compLeftContinuousBounded`, upgraded version of `ContinuousLinearMap.compLeftContinuous`, similar to `LinearMap.compLeft`. -/ protected def ContinuousLinearMap.compLeftContinuousCompact (g : β →L[𝕜] γ) : C(X, β) →L[𝕜] C(X, γ) := (linearIsometryBoundedOfCompact X γ 𝕜).symm.toLinearIsometry.toContinuousLinearMap.comp <| (g.compLeftContinuousBounded X).comp <| (linearIsometryBoundedOfCompact X β 𝕜).toLinearIsometry.toContinuousLinearMap @[simp] theorem ContinuousLinearMap.toLinear_compLeftContinuousCompact (g : β →L[𝕜] γ) : (g.compLeftContinuousCompact X : C(X, β) →ₗ[𝕜] C(X, γ)) = g.compLeftContinuous 𝕜 X := by ext f rfl @[simp] theorem ContinuousLinearMap.compLeftContinuousCompact_apply (g : β →L[𝕜] γ) (f : C(X, β)) (x : X) : g.compLeftContinuousCompact X f x = g (f x) := rfl end CompLeft namespace ContinuousMap /-! We now setup variations on `compRight* f`, where `f : C(X, Y)` (that is, precomposition by a continuous map), as a morphism `C(Y, T) → C(X, T)`, respecting various types of structure. In particular: * `compRightContinuousMap`, the bundled continuous map (for this we need `X Y` compact). * `compRightHomeomorph`, when we precompose by a homeomorphism. * `compRightAlgHom`, when `T = R` is a topological ring. -/ section CompRight /-- Precomposition by a continuous map is itself a continuous map between spaces of continuous maps. -/ def compRightContinuousMap {X Y : Type*} (T : Type*) [TopologicalSpace X] [CompactSpace X] [TopologicalSpace Y] [CompactSpace Y] [MetricSpace T] (f : C(X, Y)) : C(C(Y, T), C(X, T)) where toFun g := g.comp f continuous_toFun := by refine Metric.continuous_iff.mpr ?_ intro g ε ε_pos refine ⟨ε, ε_pos, fun g' h => ?_⟩ rw [ContinuousMap.dist_lt_iff ε_pos] at h ⊢ exact fun x => h (f x) @[simp] theorem compRightContinuousMap_apply {X Y : Type*} (T : Type*) [TopologicalSpace X] [CompactSpace X] [TopologicalSpace Y] [CompactSpace Y] [MetricSpace T] (f : C(X, Y)) (g : C(Y, T)) : (compRightContinuousMap T f) g = g.comp f := rfl /-- Precomposition by a homeomorphism is itself a homeomorphism between spaces of continuous maps. -/ def compRightHomeomorph {X Y : Type*} (T : Type*) [TopologicalSpace X] [CompactSpace X] [TopologicalSpace Y] [CompactSpace Y] [MetricSpace T] (f : X ≃ₜ Y) : C(Y, T) ≃ₜ C(X, T) where toFun := compRightContinuousMap T f.toContinuousMap invFun := compRightContinuousMap T f.symm.toContinuousMap left_inv g := ext fun _ => congr_arg g (f.apply_symm_apply _) right_inv g := ext fun _ => congr_arg g (f.symm_apply_apply _) theorem compRightAlgHom_continuous {X Y : Type*} (R A : Type*) [TopologicalSpace X] [CompactSpace X] [TopologicalSpace Y] [CompactSpace Y] [CommSemiring R] [Semiring A] [MetricSpace A] [TopologicalSemiring A] [Algebra R A] (f : C(X, Y)) : Continuous (compRightAlgHom R A f) := map_continuous (compRightContinuousMap A f) end CompRight section LocalNormalConvergence /-! ### Local normal convergence A sum of continuous functions (on a locally compact space) is "locally normally convergent" if the sum of its sup-norms on any compact subset is summable. This implies convergence in the topology of `C(X, E)` (i.e. locally uniform convergence). -/ open TopologicalSpace variable {X : Type*} [TopologicalSpace X] [LocallyCompactSpace X] variable {E : Type*} [NormedAddCommGroup E] [CompleteSpace E] theorem summable_of_locally_summable_norm {ι : Type*} {F : ι → C(X, E)} (hF : ∀ K : Compacts X, Summable fun i => ‖(F i).restrict K‖) : Summable F := by refine (ContinuousMap.exists_tendsto_compactOpen_iff_forall _).2 fun K hK => ?_ lift K to Compacts X using hK have A : ∀ s : Finset ι, restrict (↑K) (∑ i ∈ s, F i) = ∑ i ∈ s, restrict K (F i) := by intro s ext1 x simp -- This used to be the end of the proof before leanprover/lean4#2644 erw [restrict_apply, restrict_apply, restrict_apply, restrict_apply] simp? says simp only [coe_sum, Finset.sum_apply] congr! simpa only [HasSum, A] using (hF K).of_norm end LocalNormalConvergence /-! ### Star structures In this section, if `β` is a normed ⋆-group, then so is the space of continuous functions from `α` to `β`, by using the star operation pointwise. Furthermore, if `α` is compact and `β` is a C⋆-ring, then `C(α, β)` is a C⋆-ring. -/ section NormedSpace variable {α : Type*} {β : Type*} variable [TopologicalSpace α] [NormedAddCommGroup β] [StarAddMonoid β] [NormedStarGroup β] theorem _root_.BoundedContinuousFunction.mkOfCompact_star [CompactSpace α] (f : C(α, β)) : mkOfCompact (star f) = star (mkOfCompact f) := rfl instance [CompactSpace α] : NormedStarGroup C(α, β) where norm_star f := by rw [← BoundedContinuousFunction.norm_mkOfCompact, BoundedContinuousFunction.mkOfCompact_star, norm_star, BoundedContinuousFunction.norm_mkOfCompact] end NormedSpace section CStarRing variable {α : Type*} {β : Type*} variable [TopologicalSpace α] [NormedRing β] [StarRing β] instance [CompactSpace α] [CStarRing β] : CStarRing C(α, β) where norm_mul_self_le f := by rw [← sq, ← Real.le_sqrt (norm_nonneg _) (norm_nonneg _), ContinuousMap.norm_le _ (Real.sqrt_nonneg _)] intro x rw [Real.le_sqrt (norm_nonneg _) (norm_nonneg _), sq, ← CStarRing.norm_star_mul_self] exact ContinuousMap.norm_coe_le_norm (star f * f) x end CStarRing end ContinuousMap
Topology\ContinuousFunction\CompactlySupported.lean
/- Copyright (c) 2024 Yoh Tanimoto. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yoh Tanimoto -/ import Mathlib.Topology.ContinuousFunction.CocompactMap import Mathlib.Topology.ContinuousFunction.ZeroAtInfty import Mathlib.Topology.Support /-! # Compactly supported continuous functions In this file, we define the type `C_c(α, β)` of compactly supported continuous functions and the class `CompactlySupportedContinuousMapClass`, and prove basic properties. ## Main definitions and results This file contains various instances such as `Add`, `Mul`, `SMul F C_c(α, β)` when `F` is a class of continuous functions. When `β` has more structures, `C_c(α, β)` inherits such structures as `AddCommGroup`, `NonUnitalRing` and `StarRing`. When the domain `α` is compact, `ContinuousMap.liftCompactlySupported` gives the identification `C(α, β) ≃ C_c(α, β)`. -/ variable {F α β γ : Type*} [TopologicalSpace α] /-- `C_c(α, β)` is the type of continuous functions `α → β` with compact support from a topological space to a topological space with a zero element. When possible, instead of parametrizing results over `f : C_c(α, β)`, you should parametrize over `{F : Type*} [CompactlySupportedContinuousMapClass F α β] (f : F)`. When you extend this structure, make sure to extend `CompactlySupportedContinuousMapClass`. -/ structure CompactlySupportedContinuousMap (α β : Type*) [TopologicalSpace α] [Zero β] [TopologicalSpace β] extends ContinuousMap α β where /-- The function has compact support . -/ hasCompactSupport' : HasCompactSupport toFun @[inherit_doc] scoped[CompactlySupported] notation (priority := 2000) "C_c(" α ", " β ")" => CompactlySupportedContinuousMap α β @[inherit_doc] scoped[CompactlySupported] notation α " →C_c " β => CompactlySupportedContinuousMap α β open CompactlySupported section /-- `CompactlySupportedContinuousMapClass F α β` states that `F` is a type of continuous maps with compact support. You should also extend this typeclass when you extend `CompactlySupportedContinuousMap`. -/ class CompactlySupportedContinuousMapClass (F : Type*) (α β : outParam <| Type*) [TopologicalSpace α] [Zero β] [TopologicalSpace β] [FunLike F α β] extends ContinuousMapClass F α β : Prop where /-- Each member of the class has compact support. -/ hasCompactSupport (f : F) : HasCompactSupport f end namespace CompactlySupportedContinuousMap section Basics variable [TopologicalSpace β] [Zero β] instance : FunLike C_c(α, β) α β where coe f := f.toFun coe_injective' f g h := by obtain ⟨⟨_, _⟩, _⟩ := f obtain ⟨⟨_, _⟩, _⟩ := g congr protected lemma hasCompactSupport (f : C_c(α, β)) : HasCompactSupport f := f.hasCompactSupport' instance : CompactlySupportedContinuousMapClass C_c(α, β) α β where map_continuous f := f.continuous_toFun hasCompactSupport f := f.hasCompactSupport' @[simp] theorem coe_toContinuousMap (f : C_c(α, β)) : (f.toContinuousMap : α → β) = f := rfl @[ext] theorem ext {f g : C_c(α, β)} (h : ∀ x, f x = g x) : f = g := DFunLike.ext _ _ h @[simp] theorem coe_mk (f : C(α, β)) (h : HasCompactSupport f) : ⇑(⟨f, h⟩ : C_c(α, β)) = f := rfl /-- Copy of a `CompactlySupportedContinuousMap` with a new `toFun` equal to the old one. Useful to fix definitional equalities. -/ protected def copy (f : C_c(α, β)) (f' : α → β) (h : f' = f) : C_c(α, β) where toFun := f' continuous_toFun := by rw [h] exact f.continuous_toFun hasCompactSupport' := by simp_rw [h] exact f.hasCompactSupport' @[simp] theorem coe_copy (f : C_c(α, β)) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' := rfl theorem copy_eq (f : C_c(α, β)) (f' : α → β) (h : f' = f) : f.copy f' h = f := DFunLike.ext' h theorem eq_of_empty [IsEmpty α] (f g : C_c(α, β)) : f = g := ext <| IsEmpty.elim ‹_› /-- A continuous function on a compact space automatically has compact support. -/ @[simps] def ContinuousMap.liftCompactlySupported [CompactSpace α] : C(α, β) ≃ C_c(α, β) where toFun f := { toFun := f continuous_toFun := f.continuous hasCompactSupport' := HasCompactSupport.of_compactSpace f } invFun f := f left_inv _ := rfl right_inv _ := rfl end Basics /-! ### Algebraic structure Whenever `β` has the structure of continuous additive monoid and a compatible topological structure, then `C_c(α, β)` inherits a corresponding algebraic structure. The primary exception to this is that `C_c(α, β)` will not have a multiplicative identity. -/ section AlgebraicStructure variable [TopologicalSpace β] (x : α) instance [Zero β] : Zero C_c(α, β) where zero := { toFun := (0 : C(α, β)) continuous_toFun := (0 : C(α, β)).2 hasCompactSupport' := by simp [HasCompactSupport, tsupport] } instance [Zero β] : Inhabited C_c(α, β) := ⟨0⟩ @[simp] theorem coe_zero [Zero β] : ⇑(0 : C_c(α, β)) = 0 := rfl theorem zero_apply [Zero β] : (0 : C_c(α, β)) x = 0 := rfl instance [MulZeroClass β] [ContinuousMul β] : Mul C_c(α, β) := ⟨fun f g => ⟨f * g, HasCompactSupport.mul_left g.2⟩⟩ @[simp] theorem coe_mul [MulZeroClass β] [ContinuousMul β] (f g : C_c(α, β)) : ⇑(f * g) = f * g := rfl theorem mul_apply [MulZeroClass β] [ContinuousMul β] (f g : C_c(α, β)) : (f * g) x = f x * g x := rfl /-- the product of `f : F` assuming `ContinuousMapClass F α γ` and `ContinuousSMul γ β` and `g : C_c(α, β)` is in `C_c(α, β)` -/ instance [Zero β] [TopologicalSpace γ] [SMulZeroClass γ β] [ContinuousSMul γ β] {F : Type*} [FunLike F α γ] [ContinuousMapClass F α γ] : SMul F C_c(α, β) where smul f g := ⟨⟨fun x ↦ f x • g x, (map_continuous f).smul g.continuous⟩, g.hasCompactSupport'.smul_left⟩ @[simp] theorem coe_smulc [Zero β] [TopologicalSpace γ] [SMulZeroClass γ β] [ContinuousSMul γ β] {F : Type*} [FunLike F α γ] [ContinuousMapClass F α γ] (f : F) (g : C_c(α, β)) : ⇑(f • g) = fun x => f x • g x := rfl theorem smulc_apply [Zero β] [TopologicalSpace γ] [SMulZeroClass γ β] [ContinuousSMul γ β] {F : Type*} [FunLike F α γ] [ContinuousMapClass F α γ] (f : F) (g : C_c(α, β)) (x : α) : (f • g) x = f x • g x := rfl instance [MulZeroClass β] [ContinuousMul β] : MulZeroClass C_c(α, β) := DFunLike.coe_injective.mulZeroClass _ coe_zero coe_mul instance [SemigroupWithZero β] [ContinuousMul β] : SemigroupWithZero C_c(α, β) := DFunLike.coe_injective.semigroupWithZero _ coe_zero coe_mul instance [AddZeroClass β] [ContinuousAdd β] : Add C_c(α, β) := ⟨fun f g => ⟨f + g, HasCompactSupport.add f.2 g.2⟩⟩ @[simp] theorem coe_add [AddZeroClass β] [ContinuousAdd β] (f g : C_c(α, β)) : ⇑(f + g) = f + g := rfl theorem add_apply [AddZeroClass β] [ContinuousAdd β] (f g : C_c(α, β)) : (f + g) x = f x + g x := rfl instance [AddZeroClass β] [ContinuousAdd β] : AddZeroClass C_c(α, β) := DFunLike.coe_injective.addZeroClass _ coe_zero coe_add /-- Coercion to a function as a `AddMonoidHom`. Similar to `AddMonoidHom.coeFn`. -/ def coeFnMonoidHom [AddMonoid β] [ContinuousAdd β] : C_c(α, β) →+ α → β where toFun f := f map_zero' := coe_zero map_add' := coe_add instance [Zero β] {R : Type*} [SMulZeroClass R β] [ContinuousConstSMul R β] : SMul R C_c(α, β) := ⟨fun r f => ⟨⟨r • ⇑f, Continuous.const_smul f.continuous r⟩, HasCompactSupport.smul_left f.2⟩⟩ @[simp, norm_cast] theorem coe_smul [Zero β] {R : Type*} [SMulZeroClass R β] [ContinuousConstSMul R β] (r : R) (f : C_c(α, β)) : ⇑(r • f) = r • ⇑f := rfl theorem smul_apply [Zero β] {R : Type*} [SMulZeroClass R β] [ContinuousConstSMul R β] (r : R) (f : C_c(α, β)) (x : α) : (r • f) x = r • f x := rfl section AddMonoid instance [AddMonoid β] [ContinuousAdd β] : AddMonoid C_c(α, β) := DFunLike.coe_injective.addMonoid _ coe_zero coe_add fun _ _ => rfl end AddMonoid instance [AddCommMonoid β] [ContinuousAdd β] : AddCommMonoid C_c(α, β) := DFunLike.coe_injective.addCommMonoid _ coe_zero coe_add fun _ _ => rfl @[simp] theorem coe_sum [AddCommMonoid β] [ContinuousAdd β] {ι : Type*} (s : Finset ι) (f : ι → C_c(α, β)) : ⇑(∑ i in s, f i) = ∑ i in s, (f i : α → β) := map_sum coeFnMonoidHom f s theorem sum_apply [AddCommMonoid β] [ContinuousAdd β] {ι : Type*} (s : Finset ι) (f : ι → C_c(α, β)) (a : α) : (∑ i in s, f i) a = ∑ i in s, f i a := by simp section AddGroup variable [AddGroup β] [TopologicalAddGroup β] (f g : C_c(α, β)) instance : Neg C_c(α, β) where neg f := { toFun := -f.1 continuous_toFun := map_continuous (-f.1) hasCompactSupport' := by simpa [HasCompactSupport, tsupport] using f.2 } @[simp] theorem coe_neg : ⇑(-f) = -f := rfl theorem neg_apply : (-f) x = -f x := rfl instance : Sub C_c(α, β) where sub f g := { toFun := f.1 - g.1 continuous_toFun := map_continuous (f.1 - g.1) hasCompactSupport' := by simpa [sub_eq_add_neg] using HasCompactSupport.add f.2 (-g).2 } @[simp] theorem coe_sub : ⇑(f - g) = f - g := rfl theorem sub_apply : (f - g) x = f x - g x := rfl instance : AddGroup C_c(α, β) := DFunLike.coe_injective.addGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ => rfl) fun _ _ => rfl end AddGroup instance [AddCommGroup β] [TopologicalAddGroup β] : AddCommGroup C_c(α, β) := DFunLike.coe_injective.addCommGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ => rfl) fun _ _ => rfl instance [Zero β] {R : Type*} [Zero R] [SMulWithZero R β] [SMulWithZero Rᵐᵒᵖ β] [ContinuousConstSMul R β] [IsCentralScalar R β] : IsCentralScalar R C_c(α, β) := ⟨fun _ _ => ext fun _ => op_smul_eq_smul _ _⟩ instance [Zero β] {R : Type*} [Zero R] [SMulWithZero R β] [ContinuousConstSMul R β] : SMulWithZero R C_c(α, β) := Function.Injective.smulWithZero ⟨_, coe_zero⟩ DFunLike.coe_injective coe_smul instance [Zero β] {R : Type*} [MonoidWithZero R] [MulActionWithZero R β] [ContinuousConstSMul R β] : MulActionWithZero R C_c(α, β) := Function.Injective.mulActionWithZero ⟨_, coe_zero⟩ DFunLike.coe_injective coe_smul instance [AddCommMonoid β] [ContinuousAdd β] {R : Type*} [Semiring R] [Module R β] [ContinuousConstSMul R β] : Module R C_c(α, β) := Function.Injective.module R ⟨⟨_, coe_zero⟩, coe_add⟩ DFunLike.coe_injective coe_smul instance [NonUnitalNonAssocSemiring β] [TopologicalSemiring β] : NonUnitalNonAssocSemiring C_c(α, β) := DFunLike.coe_injective.nonUnitalNonAssocSemiring _ coe_zero coe_add coe_mul fun _ _ => rfl instance [NonUnitalSemiring β] [TopologicalSemiring β] : NonUnitalSemiring C_c(α, β) := DFunLike.coe_injective.nonUnitalSemiring _ coe_zero coe_add coe_mul fun _ _ => rfl instance [NonUnitalCommSemiring β] [TopologicalSemiring β] : NonUnitalCommSemiring C_c(α, β) := DFunLike.coe_injective.nonUnitalCommSemiring _ coe_zero coe_add coe_mul fun _ _ => rfl instance [NonUnitalNonAssocRing β] [TopologicalRing β] : NonUnitalNonAssocRing C_c(α, β) := DFunLike.coe_injective.nonUnitalNonAssocRing _ coe_zero coe_add coe_mul coe_neg coe_sub (fun _ _ => rfl) fun _ _ => rfl instance [NonUnitalRing β] [TopologicalRing β] : NonUnitalRing C_c(α, β) := DFunLike.coe_injective.nonUnitalRing _ coe_zero coe_add coe_mul coe_neg coe_sub (fun _ _ => rfl) fun _ _ => rfl instance [NonUnitalCommRing β] [TopologicalRing β] : NonUnitalCommRing C_c(α, β) := DFunLike.coe_injective.nonUnitalCommRing _ coe_zero coe_add coe_mul coe_neg coe_sub (fun _ _ => rfl) fun _ _ => rfl instance {R : Type*} [Semiring R] [NonUnitalNonAssocSemiring β] [TopologicalSemiring β] [Module R β] [ContinuousConstSMul R β] [IsScalarTower R β β] : IsScalarTower R C_c(α, β) C_c(α, β) where smul_assoc r f g := by ext simp only [smul_eq_mul, coe_mul, coe_smul, Pi.mul_apply, Pi.smul_apply] rw [← smul_eq_mul, ← smul_eq_mul, smul_assoc] instance {R : Type*} [Semiring R] [NonUnitalNonAssocSemiring β] [TopologicalSemiring β] [Module R β] [ContinuousConstSMul R β] [SMulCommClass R β β] : SMulCommClass R C_c(α, β) C_c(α, β) where smul_comm r f g := by ext simp only [smul_eq_mul, coe_smul, coe_mul, Pi.smul_apply, Pi.mul_apply] rw [← smul_eq_mul, ← smul_eq_mul, smul_comm] end AlgebraicStructure section Star /-! ### Star structure It is possible to equip `C_c(α, β)` with a pointwise `star` operation whenever there is a continuous `star : β → β` for which `star (0 : β) = 0`. We don't have quite this weak a typeclass, but `StarAddMonoid` is close enough. The `StarAddMonoid` class on `C_c(α, β)` is inherited from their counterparts on `α →ᵇ β`. -/ variable [TopologicalSpace β] [AddMonoid β] [StarAddMonoid β] [ContinuousStar β] instance : Star C_c(α, β) where star f := { toFun := fun x => star (f x) continuous_toFun := (map_continuous f).star hasCompactSupport' := by rw [HasCompactSupport, tsupport] simp only have support_star : (Function.support fun (x : α) => star (f x)) = Function.support f := by ext x simp only [Function.mem_support, ne_eq, star_eq_zero] rw [support_star] exact f.2 } @[simp] theorem coe_star (f : C_c(α, β)) : ⇑(star f) = star (⇑f) := rfl theorem star_apply (f : C_c(α, β)) (x : α) : (star f) x = star (f x) := rfl instance [TrivialStar β] : TrivialStar C_c(α, β) where star_trivial f := ext fun x => star_trivial (f x) instance [ContinuousAdd β] : StarAddMonoid C_c(α, β) where star_involutive f := ext fun x => star_star (f x) star_add f g := ext fun x => star_add (f x) (g x) end Star section StarModule variable {𝕜 : Type*} [Zero 𝕜] [Star 𝕜] [AddMonoid β] [StarAddMonoid β] [TopologicalSpace β] [ContinuousStar β] [SMulWithZero 𝕜 β] [ContinuousConstSMul 𝕜 β] [StarModule 𝕜 β] instance : StarModule 𝕜 C_c(α, β) where star_smul k f := ext fun x => star_smul k (f x) end StarModule section StarRing variable [NonUnitalSemiring β] [StarRing β] [TopologicalSpace β] [ContinuousStar β] [TopologicalSemiring β] instance : StarRing C_c(α, β) := { CompactlySupportedContinuousMap.instStarAddMonoid with star_mul := fun f g => ext fun x => star_mul (f x) (g x) } end StarRing /-! ### `C_c` as a functor For each `β` with sufficient structure, there is a contravariant functor `C_c(-, β)` from the category of topological spaces with morphisms given by `CocompactMap`s. -/ variable {δ : Type*} [TopologicalSpace β] [TopologicalSpace γ] [TopologicalSpace δ] local notation α " →co " β => CocompactMap α β section variable [Zero δ] /-- Composition of a continuous function with compact support with a cocompact map yields another continuous function with compact support. -/ def comp (f : C_c(γ, δ)) (g : β →co γ) : C_c(β, δ) where toContinuousMap := (f : C(γ, δ)).comp g hasCompactSupport' := by apply IsCompact.of_isClosed_subset (g.isCompact_preimage_of_isClosed f.2 (isClosed_tsupport _)) (isClosed_tsupport (f ∘ g)) intro x hx rw [tsupport, Set.mem_preimage, _root_.mem_closure_iff] intro o ho hgxo rw [tsupport, _root_.mem_closure_iff] at hx obtain ⟨y, hy⟩ := hx (g ⁻¹' o) (IsOpen.preimage g.1.2 ho) hgxo exact ⟨g y, hy⟩ @[simp] theorem coe_comp_to_continuous_fun (f : C_c(γ, δ)) (g : β →co γ) : ((f.comp g) : β → δ) = f ∘ g := rfl @[simp] theorem comp_id (f : C_c(γ, δ)) : f.comp (CocompactMap.id γ) = f := ext fun _ => rfl @[simp] theorem comp_assoc (f : C_c(γ, δ)) (g : β →co γ) (h : α →co β) : (f.comp g).comp h = f.comp (g.comp h) := rfl @[simp] theorem zero_comp (g : β →co γ) : (0 : C_c(γ, δ)).comp g = 0 := rfl end variable [T2Space γ] /-- Composition as an additive monoid homomorphism. -/ def compAddMonoidHom [AddMonoid δ] [ContinuousAdd δ] (g : β →co γ) : C_c(γ, δ) →+ C_c(β, δ) where toFun f := f.comp g map_zero' := zero_comp g map_add' _ _ := rfl /-- Composition as a semigroup homomorphism. -/ def compMulHom [MulZeroClass δ] [ContinuousMul δ] (g : β →co γ) : C_c(γ, δ) →ₙ* C_c(β, δ) where toFun f := f.comp g map_mul' _ _ := rfl /-- Composition as a linear map. -/ def compLinearMap [AddCommMonoid δ] [ContinuousAdd δ] {R : Type*} [Semiring R] [Module R δ] [ContinuousConstSMul R δ] (g : β →co γ) : C_c(γ, δ) →ₗ[R] C_c(β, δ) where toFun f := f.comp g map_add' _ _ := rfl map_smul' _ _ := rfl /-- Composition as a non-unital algebra homomorphism. -/ def compNonUnitalAlgHom {R : Type*} [Semiring R] [NonUnitalNonAssocSemiring δ] [TopologicalSemiring δ] [Module R δ] [ContinuousConstSMul R δ] (g : β →co γ) : C_c(γ, δ) →ₙₐ[R] C_c(β, δ) where toFun f := f.comp g map_smul' _ _ := rfl map_zero' := rfl map_add' _ _ := rfl map_mul' _ _ := rfl end CompactlySupportedContinuousMap namespace CompactlySupportedContinuousMapClass section Basic variable [Zero β] [TopologicalSpace β] [FunLike F α β] [CompactlySupportedContinuousMapClass F α β] instance : CoeTC F (CompactlySupportedContinuousMap α β) := ⟨fun f => { toFun := f continuous_toFun := map_continuous f hasCompactSupport' := hasCompactSupport f }⟩ /-- A continuous function on a compact space has automatically compact support. This is not an instance to avoid type class loops. -/ lemma of_compactSpace (G : Type*) [FunLike G α β] [ContinuousMapClass G α β] [CompactSpace α] : CompactlySupportedContinuousMapClass G α β where map_continuous := map_continuous hasCompactSupport := by intro f exact HasCompactSupport.of_compactSpace f end Basic section Uniform variable [UniformSpace β] [UniformSpace γ] [Zero γ] [FunLike F β γ] [CompactlySupportedContinuousMapClass F β γ] theorem uniformContinuous (f : F) : UniformContinuous (f : β → γ) := (map_continuous f).uniformContinuous_of_tendsto_cocompact (HasCompactSupport.is_zero_at_infty (hasCompactSupport f)) end Uniform section ZeroAtInfty variable [TopologicalSpace β] [TopologicalSpace γ] [Zero γ] [FunLike F β γ] [CompactlySupportedContinuousMapClass F β γ] instance : ZeroAtInftyContinuousMapClass F β γ where zero_at_infty f := HasCompactSupport.is_zero_at_infty (hasCompactSupport f) end ZeroAtInfty end CompactlySupportedContinuousMapClass
Topology\ContinuousFunction\ContinuousMapZero.lean
/- Copyright (c) 2024 Jireh Loreaux. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jireh Loreaux -/ import Mathlib.Topology.ContinuousFunction.Algebra /-! # Continuous maps sending zero to zero This is the type of continuous maps from `X` to `R` such that `(0 : X) ↦ (0 : R)` for which we provide the scoped notation `C(X, R)₀`. We provide this as a dedicated type solely for the non-unital continuous functional calculus, as using various terms of type `Ideal C(X, R)` were overly burdensome on type class synthesis. Of course, one could generalize to maps between pointed topological spaces, but that goes beyond the purpose of this type. -/ assert_not_exists StarOrderedRing open Set Function /-- The type of continuous maps which map zero to zero. Note that one should never use the structure projection `ContinuousMapZero.toContinuousMap` and instead favor the coercion `(↑) : C(X, R)₀ → C(X, R)` available from the instance of `ContinuousMapClass`. All the instances on `C(X, R)₀` from `C(X, R)` passes through this coercion, not the structure projection. Of course, the two are definitionally equal, but not reducibly so. -/ structure ContinuousMapZero (X R : Type*) [Zero X] [Zero R] [TopologicalSpace X] [TopologicalSpace R] extends C(X, R) where map_zero' : toContinuousMap 0 = 0 namespace ContinuousMapZero @[inherit_doc] scoped notation "C(" X ", " R ")₀" => ContinuousMapZero X R section Basic variable {X Y R : Type*} [Zero X] [Zero Y] [Zero R] variable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace R] instance instFunLike : FunLike C(X, R)₀ X R where coe f := f.toFun coe_injective' _ _ h := congr(⟨⟨$(h), _⟩, _⟩) instance instContinuousMapClass : ContinuousMapClass C(X, R)₀ X R where map_continuous f := f.continuous instance instZeroHomClass : ZeroHomClass C(X, R)₀ X R where map_zero f := f.map_zero' @[ext] lemma ext {f g : C(X, R)₀} (h : ∀ x, f x = g x) : f = g := DFunLike.ext f g h @[simp] lemma coe_mk {f : C(X, R)} {h0 : f 0 = 0} : ⇑(mk f h0) = f := rfl lemma toContinuousMap_injective : Injective ((↑) : C(X, R)₀ → C(X, R)) := fun _ _ h ↦ congr(.mk $(h) _) lemma range_toContinuousMap : range ((↑) : C(X, R)₀ → C(X, R)) = {f : C(X, R) | f 0 = 0} := Set.ext fun f ↦ ⟨fun ⟨f', hf'⟩ ↦ hf' ▸ map_zero f', fun hf ↦ ⟨⟨f, hf⟩, rfl⟩⟩ /-- Composition of continuous maps which map zero to zero. -/ def comp (g : C(Y, R)₀) (f : C(X, Y)₀) : C(X, R)₀ where toContinuousMap := (g : C(Y, R)).comp (f : C(X, Y)) map_zero' := show g (f 0) = 0 from map_zero f ▸ map_zero g @[simp] lemma comp_apply (g : C(Y, R)₀) (f : C(X, Y)₀) (x : X) : g.comp f x = g (f x) := rfl instance instPartialOrder [PartialOrder R] : PartialOrder C(X, R)₀ := .lift _ DFunLike.coe_injective' lemma le_def [PartialOrder R] (f g : C(X, R)₀) : f ≤ g ↔ ∀ x, f x ≤ g x := Iff.rfl protected instance instTopologicalSpace : TopologicalSpace C(X, R)₀ := TopologicalSpace.induced ((↑) : C(X, R)₀ → C(X, R)) inferInstance lemma embedding_toContinuousMap : Embedding ((↑) : C(X, R)₀ → C(X, R)) where induced := rfl inj _ _ h := ext fun x ↦ congr($(h) x) instance [T0Space R] : T0Space C(X, R)₀ := embedding_toContinuousMap.t0Space instance [T1Space R] : T1Space C(X, R)₀ := embedding_toContinuousMap.t1Space instance [T2Space R] : T2Space C(X, R)₀ := embedding_toContinuousMap.t2Space lemma closedEmbedding_toContinuousMap [T1Space R] : ClosedEmbedding ((↑) : C(X, R)₀ → C(X, R)) where toEmbedding := embedding_toContinuousMap isClosed_range := by rw [range_toContinuousMap] exact isClosed_singleton.preimage <| ContinuousMap.continuous_eval_const 0 /-- The identity function as an element of `C(s, R)₀` when `0 ∈ (s : Set R)`. -/ @[simps!] protected def id {s : Set R} [Zero s] (h0 : ((0 : s) : R) = 0) : C(s, R)₀ := ⟨.restrict s (.id R), h0⟩ @[simp] lemma toContinuousMap_id {s : Set R} [Zero s] (h0 : ((0 : s) : R) = 0) : (ContinuousMapZero.id h0 : C(s, R)) = .restrict s (.id R) := rfl end Basic section Algebra variable {X R : Type*} [Zero X] [TopologicalSpace X] variable [TopologicalSpace R] instance instZero [Zero R] : Zero C(X, R)₀ where zero := ⟨0, rfl⟩ @[simp] lemma coe_zero [Zero R] : ⇑(0 : C(X, R)₀) = 0 := rfl instance instAdd [AddZeroClass R] [ContinuousAdd R] : Add C(X, R)₀ where add f g := ⟨f + g, by simp⟩ @[simp] lemma coe_add [AddZeroClass R] [ContinuousAdd R] (f g : C(X, R)₀) : ⇑(f + g) = f + g := rfl instance instMul [MulZeroClass R] [ContinuousMul R] : Mul C(X, R)₀ where mul f g := ⟨f * g, by simp⟩ @[simp] lemma coe_mul [MulZeroClass R] [ContinuousMul R] (f g : C(X, R)₀) : ⇑(f * g) = f * g := rfl instance instSMul {M : Type*} [Zero R] [SMulZeroClass M R] [ContinuousConstSMul M R] : SMul M C(X, R)₀ where smul m f := ⟨m • f, by simp⟩ @[simp] lemma coe_smul {M : Type*} [Zero R] [SMulZeroClass M R] [ContinuousConstSMul M R] (m : M) (f : C(X, R)₀) : ⇑(m • f) = m • f := rfl section Semiring variable [CommSemiring R] [TopologicalSemiring R] instance instNonUnitalCommSemiring : NonUnitalCommSemiring C(X, R)₀ := toContinuousMap_injective.nonUnitalCommSemiring _ rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) instance instModule {M : Type*} [Semiring M] [Module M R] [ContinuousConstSMul M R] : Module M C(X, R)₀ := toContinuousMap_injective.module M { toFun := _, map_add' := fun _ _ ↦ rfl, map_zero' := rfl } (fun _ _ ↦ rfl) instance instSMulCommClass {M N : Type*} [SMulZeroClass M R] [ContinuousConstSMul M R] [SMulZeroClass N R] [ContinuousConstSMul N R] [SMulCommClass M N R] : SMulCommClass M N C(X, R)₀ where smul_comm _ _ _ := ext fun _ ↦ smul_comm .. instance instSMulCommClass' {M : Type*} [SMulZeroClass M R] [SMulCommClass M R R] [ContinuousConstSMul M R] : SMulCommClass M C(X, R)₀ C(X, R)₀ where smul_comm m f g := ext fun x ↦ smul_comm m (f x) (g x) instance instIsScalarTower {M N : Type*} [SMulZeroClass M R] [ContinuousConstSMul M R] [SMulZeroClass N R] [ContinuousConstSMul N R] [SMul M N] [IsScalarTower M N R] : IsScalarTower M N C(X, R)₀ where smul_assoc _ _ _ := ext fun _ ↦ smul_assoc .. instance instIsScalarTower' {M : Type*} [SMulZeroClass M R] [IsScalarTower M R R] [ContinuousConstSMul M R] : IsScalarTower M C(X, R)₀ C(X, R)₀ where smul_assoc m f g := ext fun x ↦ smul_assoc m (f x) (g x) instance instStarRing [StarRing R] [ContinuousStar R] : StarRing C(X, R)₀ where star f := ⟨star f, by simp⟩ star_involutive _ := ext fun _ ↦ star_star _ star_mul _ _ := ext fun _ ↦ star_mul .. star_add _ _ := ext fun _ ↦ star_add .. instance instStarModule [StarRing R] {M : Type*} [SMulZeroClass M R] [ContinuousConstSMul M R] [Star M] [StarModule M R] [ContinuousStar R] : StarModule M C(X, R)₀ where star_smul r f := ext fun x ↦ star_smul r (f x) @[simp] lemma coe_star [StarRing R] [ContinuousStar R] (f : C(X, R)₀) : ⇑(star f) = star ⇑f := rfl instance [StarRing R] [ContinuousStar R] [TrivialStar R] : TrivialStar C(X, R)₀ where star_trivial _ := DFunLike.ext _ _ fun _ ↦ star_trivial _ instance instCanLift : CanLift C(X, R) C(X, R)₀ (↑) (fun f ↦ f 0 = 0) where prf f hf := ⟨⟨f, hf⟩, rfl⟩ /-- The coercion `C(X, R)₀ → C(X, R)` bundled as a non-unital star algebra homomorphism. -/ @[simps] def toContinuousMapHom [StarRing R] [ContinuousStar R] : C(X, R)₀ →⋆ₙₐ[R] C(X, R) where toFun f := f map_smul' _ _ := rfl map_zero' := rfl map_add' _ _ := rfl map_mul' _ _ := rfl map_star' _ := rfl lemma coe_toContinuousMapHom [StarRing R] [ContinuousStar R] : ⇑(toContinuousMapHom (X := X) (R := R)) = (↑) := rfl /-- Coercion to a function as an `AddMonoidHom`. Similar to `ContinuousMap.coeFnAddMonoidHom`. -/ def coeFnAddMonoidHom : C(X, R)₀ →+ X → R where toFun f := f map_zero' := coe_zero map_add' f g := by simp @[simp] lemma coe_sum {ι : Type*} (s : Finset ι) (f : ι → C(X, R)₀) : ⇑(s.sum f) = s.sum (fun i => ⇑(f i)) := map_sum coeFnAddMonoidHom f s end Semiring section Ring variable {X R : Type*} [Zero X] [TopologicalSpace X] variable [CommRing R] [TopologicalSpace R] [TopologicalRing R] instance instSub : Sub C(X, R)₀ where sub f g := ⟨f - g, by simp⟩ instance instNeg : Neg C(X, R)₀ where neg f := ⟨-f, by simp⟩ instance instNonUnitalCommRing : NonUnitalCommRing C(X, R)₀ := toContinuousMap_injective.nonUnitalCommRing _ rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) @[simp] lemma coe_neg (f : C(X, R)₀) : ⇑(-f) = -⇑f := rfl instance : ContinuousNeg C(X, R)₀ where continuous_neg := by rw [continuous_induced_rng] exact continuous_neg.comp continuous_induced_dom end Ring end Algebra section UniformSpace variable {X R : Type*} [Zero X] [TopologicalSpace X] variable [Zero R] [UniformSpace R] protected instance instUniformSpace : UniformSpace C(X, R)₀ := .comap toContinuousMap inferInstance lemma uniformEmbedding_toContinuousMap : UniformEmbedding ((↑) : C(X, R)₀ → C(X, R)) where comap_uniformity := rfl inj _ _ h := ext fun x ↦ congr($(h) x) instance [T1Space R] [CompleteSpace C(X, R)] : CompleteSpace C(X, R)₀ := completeSpace_iff_isComplete_range uniformEmbedding_toContinuousMap.toUniformInducing |>.mpr closedEmbedding_toContinuousMap.isClosed_range.isComplete lemma uniformEmbedding_comp {Y : Type*} [UniformSpace Y] [Zero Y] (g : C(Y, R)₀) (hg : UniformEmbedding g) : UniformEmbedding (g.comp · : C(X, Y)₀ → C(X, R)₀) := uniformEmbedding_toContinuousMap.of_comp_iff.mp <| ContinuousMap.uniformEmbedding_comp g.toContinuousMap hg |>.comp uniformEmbedding_toContinuousMap /-- The uniform equivalence `C(X, R)₀ ≃ᵤ C(Y, R)₀` induced by a homeomorphism of the domains sending `0 : X` to `0 : Y`. -/ def _root_.UniformEquiv.arrowCongrLeft₀ {Y : Type*} [TopologicalSpace Y] [Zero Y] (f : X ≃ₜ Y) (hf : f 0 = 0) : C(X, R)₀ ≃ᵤ C(Y, R)₀ where toFun g := g.comp ⟨f.symm.toContinuousMap, (f.toEquiv.apply_eq_iff_eq_symm_apply.eq ▸ hf).symm⟩ invFun g := g.comp ⟨f.toContinuousMap, hf⟩ left_inv g := ext fun _ ↦ congrArg g <| f.left_inv _ right_inv g := ext fun _ ↦ congrArg g <| f.right_inv _ uniformContinuous_toFun := uniformEmbedding_toContinuousMap.uniformContinuous_iff.mpr <| ContinuousMap.uniformContinuous_comp_left f.symm.toContinuousMap |>.comp uniformEmbedding_toContinuousMap.uniformContinuous uniformContinuous_invFun := uniformEmbedding_toContinuousMap.uniformContinuous_iff.mpr <| ContinuousMap.uniformContinuous_comp_left f.toContinuousMap |>.comp uniformEmbedding_toContinuousMap.uniformContinuous end UniformSpace section CompHoms variable {X Y M R S : Type*} [Zero X] [Zero Y] [CommSemiring M] [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace R] [TopologicalSpace S] [CommSemiring R] [StarRing R] [TopologicalSemiring R] [ContinuousStar R] [CommSemiring S] [StarRing S] [TopologicalSemiring S] [ContinuousStar S] [Module M R] [Module M S] [ContinuousConstSMul M R] [ContinuousConstSMul M S] variable (R) in /-- The functor `C(·, R)₀` from topological spaces with zero (and `ContinuousMapZero` maps) to non-unital star algebras. -/ @[simps] def nonUnitalStarAlgHom_precomp (f : C(X, Y)₀) : C(Y, R)₀ →⋆ₙₐ[R] C(X, R)₀ where toFun g := g.comp f map_zero' := rfl map_add' _ _ := rfl map_mul' _ _ := rfl map_star' _ := rfl map_smul' _ _ := rfl variable (X) in /-- The functor `C(X, ·)₀` from non-unital topological star algebras (with non-unital continuous star homomorphisms) to non-unital star algebras. -/ @[simps apply] def nonUnitalStarAlgHom_postcomp (φ : R →⋆ₙₐ[M] S) (hφ : Continuous φ) : C(X, R)₀ →⋆ₙₐ[M] C(X, S)₀ where toFun := .comp ⟨⟨φ, hφ⟩, by simp⟩ map_zero' := ext <| by simp map_add' _ _ := ext <| by simp map_mul' _ _ := ext <| by simp map_star' _ := ext <| by simp [map_star] map_smul' r f := ext <| by simp end CompHoms end ContinuousMapZero
Topology\ContinuousFunction\Ideals.lean
/- Copyright (c) 2022 Jireh Loreaux. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jireh Loreaux -/ import Mathlib.Topology.Algebra.Algebra import Mathlib.Topology.ContinuousFunction.Compact import Mathlib.Topology.UrysohnsLemma import Mathlib.Analysis.RCLike.Basic import Mathlib.Analysis.Normed.Ring.Units import Mathlib.Topology.Algebra.Module.CharacterSpace /-! # Ideals of continuous functions For a topological semiring `R` and a topological space `X` there is a Galois connection between `Ideal C(X, R)` and `Set X` given by sending each `I : Ideal C(X, R)` to `{x : X | ∀ f ∈ I, f x = 0}ᶜ` and mapping `s : Set X` to the ideal with carrier `{f : C(X, R) | ∀ x ∈ sᶜ, f x = 0}`, and we call these maps `ContinuousMap.setOfIdeal` and `ContinuousMap.idealOfSet`. As long as `R` is Hausdorff, `ContinuousMap.setOfIdeal I` is open, and if, in addition, `X` is locally compact, then `ContinuousMap.setOfIdeal s` is closed. When `R = 𝕜` with `RCLike 𝕜` and `X` is compact Hausdorff, then this Galois connection can be improved to a true Galois correspondence (i.e., order isomorphism) between the type `opens X` and the subtype of closed ideals of `C(X, 𝕜)`. Because we do not have a bundled type of closed ideals, we simply register this as a Galois insertion between `Ideal C(X, 𝕜)` and `opens X`, which is `ContinuousMap.idealOpensGI`. Consequently, the maximal ideals of `C(X, 𝕜)` are precisely those ideals corresponding to (complements of) singletons in `X`. In addition, when `X` is locally compact and `𝕜` is a nontrivial topological integral domain, then there is a natural continuous map from `X` to `WeakDual.characterSpace 𝕜 C(X, 𝕜)` given by point evaluation, which is herein called `WeakDual.CharacterSpace.continuousMapEval`. Again, when `X` is compact Hausdorff and `RCLike 𝕜`, more can be obtained. In particular, in that context this map is bijective, and since the domain is compact and the codomain is Hausdorff, it is a homeomorphism, herein called `WeakDual.CharacterSpace.homeoEval`. ## Main definitions * `ContinuousMap.idealOfSet`: ideal of functions which vanish on the complement of a set. * `ContinuousMap.setOfIdeal`: complement of the set on which all functions in the ideal vanish. * `ContinuousMap.opensOfIdeal`: `ContinuousMap.setOfIdeal` as a term of `opens X`. * `ContinuousMap.idealOpensGI`: The Galois insertion `ContinuousMap.opensOfIdeal` and `fun s ↦ ContinuousMap.idealOfSet ↑s`. * `WeakDual.CharacterSpace.continuousMapEval`: the natural continuous map from a locally compact topological space `X` to the `WeakDual.characterSpace 𝕜 C(X, 𝕜)` which sends `x : X` to point evaluation at `x`, with modest hypothesis on `𝕜`. * `WeakDual.CharacterSpace.homeoEval`: this is `WeakDual.CharacterSpace.continuousMapEval` upgraded to a homeomorphism when `X` is compact Hausdorff and `RCLike 𝕜`. ## Main statements * `ContinuousMap.idealOfSet_ofIdeal_eq_closure`: when `X` is compact Hausdorff and `RCLike 𝕜`, `idealOfSet 𝕜 (setOfIdeal I) = I.closure` for any ideal `I : Ideal C(X, 𝕜)`. * `ContinuousMap.setOfIdeal_ofSet_eq_interior`: when `X` is compact Hausdorff and `RCLike 𝕜`, `setOfIdeal (idealOfSet 𝕜 s) = interior s` for any `s : Set X`. * `ContinuousMap.ideal_isMaximal_iff`: when `X` is compact Hausdorff and `RCLike 𝕜`, a closed ideal of `C(X, 𝕜)` is maximal if and only if it is `idealOfSet 𝕜 {x}ᶜ` for some `x : X`. ## Implementation details Because there does not currently exist a bundled type of closed ideals, we don't provide the actual order isomorphism described above, and instead we only consider the Galois insertion `ContinuousMap.idealOpensGI`. ## Tags ideal, continuous function, compact, Hausdorff -/ open scoped NNReal namespace ContinuousMap open TopologicalSpace section TopologicalRing variable {X R : Type*} [TopologicalSpace X] [Semiring R] variable [TopologicalSpace R] [TopologicalSemiring R] variable (R) /-- Given a topological ring `R` and `s : Set X`, construct the ideal in `C(X, R)` of functions which vanish on the complement of `s`. -/ def idealOfSet (s : Set X) : Ideal C(X, R) where carrier := {f : C(X, R) | ∀ x ∈ sᶜ, f x = 0} add_mem' {f g} hf hg x hx := by simp [hf x hx, hg x hx, coe_add, Pi.add_apply, add_zero] zero_mem' _ _ := rfl smul_mem' c f hf x hx := mul_zero (c x) ▸ congr_arg (fun y => c x * y) (hf x hx) theorem idealOfSet_closed [T2Space R] (s : Set X) : IsClosed (idealOfSet R s : Set C(X, R)) := by simp only [idealOfSet, Submodule.coe_set_mk, Set.setOf_forall] exact isClosed_iInter fun x => isClosed_iInter fun _ => isClosed_eq (continuous_eval_const x) continuous_const variable {R} theorem mem_idealOfSet {s : Set X} {f : C(X, R)} : f ∈ idealOfSet R s ↔ ∀ ⦃x : X⦄, x ∈ sᶜ → f x = 0 := by convert Iff.rfl theorem not_mem_idealOfSet {s : Set X} {f : C(X, R)} : f ∉ idealOfSet R s ↔ ∃ x ∈ sᶜ, f x ≠ 0 := by simp_rw [mem_idealOfSet]; push_neg; rfl /-- Given an ideal `I` of `C(X, R)`, construct the set of points for which every function in the ideal vanishes on the complement. -/ def setOfIdeal (I : Ideal C(X, R)) : Set X := {x : X | ∀ f ∈ I, (f : C(X, R)) x = 0}ᶜ theorem not_mem_setOfIdeal {I : Ideal C(X, R)} {x : X} : x ∉ setOfIdeal I ↔ ∀ ⦃f : C(X, R)⦄, f ∈ I → f x = 0 := by rw [← Set.mem_compl_iff, setOfIdeal, compl_compl, Set.mem_setOf] theorem mem_setOfIdeal {I : Ideal C(X, R)} {x : X} : x ∈ setOfIdeal I ↔ ∃ f ∈ I, (f : C(X, R)) x ≠ 0 := by simp_rw [setOfIdeal, Set.mem_compl_iff, Set.mem_setOf]; push_neg; rfl theorem setOfIdeal_open [T2Space R] (I : Ideal C(X, R)) : IsOpen (setOfIdeal I) := by simp only [setOfIdeal, Set.setOf_forall, isOpen_compl_iff] exact isClosed_iInter fun f => isClosed_iInter fun _ => isClosed_eq (map_continuous f) continuous_const /-- The open set `ContinuousMap.setOfIdeal I` realized as a term of `opens X`. -/ @[simps] def opensOfIdeal [T2Space R] (I : Ideal C(X, R)) : Opens X := ⟨setOfIdeal I, setOfIdeal_open I⟩ @[simp] theorem setOfTop_eq_univ [Nontrivial R] : setOfIdeal (⊤ : Ideal C(X, R)) = Set.univ := Set.univ_subset_iff.mp fun _ _ => mem_setOfIdeal.mpr ⟨1, Submodule.mem_top, one_ne_zero⟩ @[simp] theorem idealOfEmpty_eq_bot : idealOfSet R (∅ : Set X) = ⊥ := Ideal.ext fun f => by simp only [mem_idealOfSet, Set.compl_empty, Set.mem_univ, forall_true_left, Ideal.mem_bot, DFunLike.ext_iff, zero_apply] @[simp] theorem mem_idealOfSet_compl_singleton (x : X) (f : C(X, R)) : f ∈ idealOfSet R ({x}ᶜ : Set X) ↔ f x = 0 := by simp only [mem_idealOfSet, compl_compl, Set.mem_singleton_iff, forall_eq] variable (X R) theorem ideal_gc : GaloisConnection (setOfIdeal : Ideal C(X, R) → Set X) (idealOfSet R) := by refine fun I s => ⟨fun h f hf => ?_, fun h x hx => ?_⟩ · by_contra h' rcases not_mem_idealOfSet.mp h' with ⟨x, hx, hfx⟩ exact hfx (not_mem_setOfIdeal.mp (mt (@h x) hx) hf) · obtain ⟨f, hf, hfx⟩ := mem_setOfIdeal.mp hx by_contra hx' exact not_mem_idealOfSet.mpr ⟨x, hx', hfx⟩ (h hf) end TopologicalRing section RCLike open RCLike variable {X 𝕜 : Type*} [RCLike 𝕜] [TopologicalSpace X] /-- An auxiliary lemma used in the proof of `ContinuousMap.idealOfSet_ofIdeal_eq_closure` which may be useful on its own. -/ theorem exists_mul_le_one_eqOn_ge (f : C(X, ℝ≥0)) {c : ℝ≥0} (hc : 0 < c) : ∃ g : C(X, ℝ≥0), (∀ x : X, (g * f) x ≤ 1) ∧ {x : X | c ≤ f x}.EqOn (g * f) 1 := ⟨{ toFun := (f ⊔ const X c)⁻¹ continuous_toFun := ((map_continuous f).sup <| map_continuous _).inv₀ fun _ => (hc.trans_le le_sup_right).ne' }, fun x => (inv_mul_le_iff (hc.trans_le le_sup_right)).mpr ((mul_one (f x ⊔ c)).symm ▸ le_sup_left), fun x hx => by simpa only [coe_const, mul_apply, coe_mk, Pi.inv_apply, Pi.sup_apply, Function.const_apply, sup_eq_left.mpr (Set.mem_setOf.mp hx), ne_eq, Pi.one_apply] using inv_mul_cancel (hc.trans_le hx).ne' ⟩ variable [CompactSpace X] [T2Space X] @[simp] theorem idealOfSet_ofIdeal_eq_closure (I : Ideal C(X, 𝕜)) : idealOfSet 𝕜 (setOfIdeal I) = I.closure := by /- Since `idealOfSet 𝕜 (setOfIdeal I)` is closed and contains `I`, it contains `I.closure`. For the reverse inclusion, given `f ∈ idealOfSet 𝕜 (setOfIdeal I)` and `(ε : ℝ≥0) > 0` it suffices to show that `f` is within `ε` of `I`. -/ refine le_antisymm ?_ ((idealOfSet_closed 𝕜 <| setOfIdeal I).closure_subset_iff.mpr fun f hf x hx => not_mem_setOfIdeal.mp hx hf) refine (fun f hf => Metric.mem_closure_iff.mpr fun ε hε => ?_) lift ε to ℝ≥0 using hε.lt.le replace hε := show (0 : ℝ≥0) < ε from hε simp_rw [dist_nndist] norm_cast -- Let `t := {x : X | ε / 2 ≤ ‖f x‖₊}}` which is closed and disjoint from `set_of_ideal I`. set t := {x : X | ε / 2 ≤ ‖f x‖₊} have ht : IsClosed t := isClosed_le continuous_const (map_continuous f).nnnorm have htI : Disjoint t (setOfIdeal I)ᶜ := by refine Set.subset_compl_iff_disjoint_left.mp fun x hx => ?_ simpa only [t, Set.mem_setOf, Set.mem_compl_iff, not_le] using (nnnorm_eq_zero.mpr (mem_idealOfSet.mp hf hx)).trans_lt (half_pos hε) /- It suffices to produce `g : C(X, ℝ≥0)` which takes values in `[0,1]` and is constantly `1` on `t` such that when composed with the natural embedding of `ℝ≥0` into `𝕜` lies in the ideal `I`. Indeed, then `‖f - f * ↑g‖ ≤ ‖f * (1 - ↑g)‖ ≤ ⨆ ‖f * (1 - ↑g) x‖`. When `x ∉ t`, `‖f x‖ < ε / 2` and `‖(1 - ↑g) x‖ ≤ 1`, and when `x ∈ t`, `(1 - ↑g) x = 0`, and clearly `f * ↑g ∈ I`. -/ suffices ∃ g : C(X, ℝ≥0), (algebraMapCLM ℝ≥0 𝕜 : C(ℝ≥0, 𝕜)).comp g ∈ I ∧ (∀ x, g x ≤ 1) ∧ t.EqOn g 1 by obtain ⟨g, hgI, hg, hgt⟩ := this refine ⟨f * (algebraMapCLM ℝ≥0 𝕜 : C(ℝ≥0, 𝕜)).comp g, I.mul_mem_left f hgI, ?_⟩ rw [nndist_eq_nnnorm] refine (nnnorm_lt_iff _ hε).2 fun x => ?_ simp only [coe_sub, coe_mul, Pi.sub_apply, Pi.mul_apply] by_cases hx : x ∈ t · simpa only [hgt hx, comp_apply, Pi.one_apply, ContinuousMap.coe_coe, algebraMapCLM_apply, map_one, mul_one, sub_self, nnnorm_zero] using hε · refine lt_of_le_of_lt ?_ (half_lt_self hε) have := calc ‖((1 - (algebraMapCLM ℝ≥0 𝕜 : C(ℝ≥0, 𝕜)).comp g) x : 𝕜)‖₊ = ‖1 - algebraMap ℝ≥0 𝕜 (g x)‖₊ := by simp only [coe_sub, coe_one, coe_comp, ContinuousMap.coe_coe, Pi.sub_apply, Pi.one_apply, Function.comp_apply, algebraMapCLM_apply] _ = ‖algebraMap ℝ≥0 𝕜 (1 - g x)‖₊ := by simp only [Algebra.algebraMap_eq_smul_one, NNReal.smul_def, NNReal.coe_sub (hg x), NNReal.coe_one, sub_smul, one_smul] _ ≤ 1 := (nnnorm_algebraMap_nnreal 𝕜 (1 - g x)).trans_le tsub_le_self calc ‖f x - f x * (algebraMapCLM ℝ≥0 𝕜 : C(ℝ≥0, 𝕜)).comp g x‖₊ = ‖f x * (1 - (algebraMapCLM ℝ≥0 𝕜 : C(ℝ≥0, 𝕜)).comp g) x‖₊ := by simp only [mul_sub, coe_sub, coe_one, Pi.sub_apply, Pi.one_apply, mul_one] _ ≤ ε / 2 * ‖(1 - (algebraMapCLM ℝ≥0 𝕜 : C(ℝ≥0, 𝕜)).comp g) x‖₊ := ((nnnorm_mul_le _ _).trans (mul_le_mul_right' (not_le.mp <| show ¬ε / 2 ≤ ‖f x‖₊ from hx).le _)) _ ≤ ε / 2 := by simpa only [mul_one] using mul_le_mul_left' this _ /- There is some `g' : C(X, ℝ≥0)` which is strictly positive on `t` such that the composition `↑g` with the natural embedding of `ℝ≥0` into `𝕜` lies in `I`. This follows from compactness of `t` and that we can do it in any neighborhood of a point `x ∈ t`. Indeed, since `x ∈ t`, then `fₓ x ≠ 0` for some `fₓ ∈ I` and so `fun y ↦ ‖(star fₓ * fₓ) y‖₊` is strictly posiive in a neighborhood of `y`. Moreover, `(‖(star fₓ * fₓ) y‖₊ : 𝕜) = (star fₓ * fₓ) y`, so composition of this map with the natural embedding is just `star fₓ * fₓ ∈ I`. -/ have : ∃ g' : C(X, ℝ≥0), (algebraMapCLM ℝ≥0 𝕜 : C(ℝ≥0, 𝕜)).comp g' ∈ I ∧ ∀ x ∈ t, 0 < g' x := by refine ht.isCompact.induction_on ?_ ?_ ?_ ?_ · refine ⟨0, ?_, fun x hx => False.elim hx⟩ convert I.zero_mem ext simp only [comp_apply, zero_apply, ContinuousMap.coe_coe, map_zero] · rintro s₁ s₂ hs ⟨g, hI, hgt⟩; exact ⟨g, hI, fun x hx => hgt x (hs hx)⟩ · rintro s₁ s₂ ⟨g₁, hI₁, hgt₁⟩ ⟨g₂, hI₂, hgt₂⟩ refine ⟨g₁ + g₂, ?_, fun x hx => ?_⟩ · convert I.add_mem hI₁ hI₂ ext y simp only [coe_add, Pi.add_apply, map_add, coe_comp, Function.comp_apply, ContinuousMap.coe_coe] · rcases hx with (hx | hx) · simpa only [zero_add] using add_lt_add_of_lt_of_le (hgt₁ x hx) zero_le' · simpa only [zero_add] using add_lt_add_of_le_of_lt zero_le' (hgt₂ x hx) · intro x hx replace hx := htI.subset_compl_right hx rw [compl_compl, mem_setOfIdeal] at hx obtain ⟨g, hI, hgx⟩ := hx have := (map_continuous g).continuousAt.eventually_ne hgx refine ⟨{y : X | g y ≠ 0} ∩ t, mem_nhdsWithin_iff_exists_mem_nhds_inter.mpr ⟨_, this, Set.Subset.rfl⟩, ⟨⟨fun x => ‖g x‖₊ ^ 2, (map_continuous g).nnnorm.pow 2⟩, ?_, fun x hx => pow_pos (norm_pos_iff.mpr hx.1) 2⟩⟩ convert I.mul_mem_left (star g) hI ext simp only [comp_apply, ContinuousMap.coe_coe, coe_mk, algebraMapCLM_toFun, map_pow, mul_apply, star_apply, star_def] simp only [normSq_eq_def', RCLike.conj_mul, ofReal_pow] rfl /- Get the function `g'` which is guaranteed to exist above. By the extreme value theorem and compactness of `t`, there is some `0 < c` such that `c ≤ g' x` for all `x ∈ t`. Then by `exists_mul_le_one_eqOn_ge` there is some `g` for which `g * g'` is the desired function. -/ obtain ⟨g', hI', hgt'⟩ := this obtain ⟨c, hc, hgc'⟩ : ∃ c > 0, ∀ y : X, y ∈ t → c ≤ g' y := t.eq_empty_or_nonempty.elim (fun ht' => ⟨1, zero_lt_one, fun y hy => False.elim (by rwa [ht'] at hy)⟩) fun ht' => let ⟨x, hx, hx'⟩ := ht.isCompact.exists_isMinOn ht' (map_continuous g').continuousOn ⟨g' x, hgt' x hx, hx'⟩ obtain ⟨g, hg, hgc⟩ := exists_mul_le_one_eqOn_ge g' hc refine ⟨g * g', ?_, hg, hgc.mono hgc'⟩ convert I.mul_mem_left ((algebraMapCLM ℝ≥0 𝕜 : C(ℝ≥0, 𝕜)).comp g) hI' ext simp only [algebraMapCLM_coe, comp_apply, mul_apply, ContinuousMap.coe_coe, map_mul] theorem idealOfSet_ofIdeal_isClosed {I : Ideal C(X, 𝕜)} (hI : IsClosed (I : Set C(X, 𝕜))) : idealOfSet 𝕜 (setOfIdeal I) = I := (idealOfSet_ofIdeal_eq_closure I).trans (Ideal.ext <| Set.ext_iff.mp hI.closure_eq) variable (𝕜) @[simp] theorem setOfIdeal_ofSet_eq_interior (s : Set X) : setOfIdeal (idealOfSet 𝕜 s) = interior s := by refine Set.Subset.antisymm ((setOfIdeal_open (idealOfSet 𝕜 s)).subset_interior_iff.mpr fun x hx => let ⟨f, hf, hfx⟩ := mem_setOfIdeal.mp hx Set.not_mem_compl_iff.mp (mt (@hf x) hfx)) fun x hx => ?_ -- If `x ∉ closure sᶜ`, we must produce `f : C(X, 𝕜)` which is zero on `sᶜ` and `f x ≠ 0`. rw [← compl_compl (interior s), ← closure_compl] at hx simp_rw [mem_setOfIdeal, mem_idealOfSet] /- Apply Urysohn's lemma to get `g : C(X, ℝ)` which is zero on `sᶜ` and `g x ≠ 0`, then compose with the natural embedding `ℝ ↪ 𝕜` to produce the desired `f`. -/ obtain ⟨g, hgs, hgx : Set.EqOn g 1 {x}, -⟩ := exists_continuous_zero_one_of_isClosed isClosed_closure isClosed_singleton (Set.disjoint_singleton_right.mpr hx) exact ⟨⟨fun x => g x, continuous_ofReal.comp (map_continuous g)⟩, by simpa only [coe_mk, ofReal_eq_zero] using fun x hx => hgs (subset_closure hx), by simpa only [coe_mk, hgx (Set.mem_singleton x), Pi.one_apply, RCLike.ofReal_one] using one_ne_zero⟩ theorem setOfIdeal_ofSet_of_isOpen {s : Set X} (hs : IsOpen s) : setOfIdeal (idealOfSet 𝕜 s) = s := (setOfIdeal_ofSet_eq_interior 𝕜 s).trans hs.interior_eq variable (X) /-- The Galois insertion `ContinuousMap.opensOfIdeal : Ideal C(X, 𝕜) → Opens X` and `fun s ↦ ContinuousMap.idealOfSet ↑s`. -/ @[simps] def idealOpensGI : GaloisInsertion (opensOfIdeal : Ideal C(X, 𝕜) → Opens X) fun s => idealOfSet 𝕜 s where choice I _ := opensOfIdeal I.closure gc I s := ideal_gc X 𝕜 I s le_l_u s := (setOfIdeal_ofSet_of_isOpen 𝕜 s.isOpen).ge choice_eq I hI := congr_arg _ <| Ideal.ext (Set.ext_iff.mp (isClosed_of_closure_subset <| (idealOfSet_ofIdeal_eq_closure I ▸ hI : I.closure ≤ I)).closure_eq) variable {X} theorem idealOfSet_isMaximal_iff (s : Opens X) : (idealOfSet 𝕜 (s : Set X)).IsMaximal ↔ IsCoatom s := by rw [Ideal.isMaximal_def] refine (idealOpensGI X 𝕜).isCoatom_iff (fun I hI => ?_) s rw [← Ideal.isMaximal_def] at hI exact idealOfSet_ofIdeal_isClosed inferInstance theorem idealOf_compl_singleton_isMaximal (x : X) : (idealOfSet 𝕜 ({x}ᶜ : Set X)).IsMaximal := (idealOfSet_isMaximal_iff 𝕜 (Closeds.singleton x).compl).mpr <| Opens.isCoatom_iff.mpr ⟨x, rfl⟩ variable {𝕜} theorem setOfIdeal_eq_compl_singleton (I : Ideal C(X, 𝕜)) [hI : I.IsMaximal] : ∃ x : X, setOfIdeal I = {x}ᶜ := by have h : (idealOfSet 𝕜 (setOfIdeal I)).IsMaximal := (idealOfSet_ofIdeal_isClosed (inferInstance : IsClosed (I : Set C(X, 𝕜)))).symm ▸ hI obtain ⟨x, hx⟩ := Opens.isCoatom_iff.1 ((idealOfSet_isMaximal_iff 𝕜 (opensOfIdeal I)).1 h) exact ⟨x, congr_arg (fun (s : Opens X) => (s : Set X)) hx⟩ theorem ideal_isMaximal_iff (I : Ideal C(X, 𝕜)) [hI : IsClosed (I : Set C(X, 𝕜))] : I.IsMaximal ↔ ∃ x : X, idealOfSet 𝕜 {x}ᶜ = I := by refine ⟨?_, fun h => let ⟨x, hx⟩ := h hx ▸ idealOf_compl_singleton_isMaximal 𝕜 x⟩ intro hI' obtain ⟨x, hx⟩ := setOfIdeal_eq_compl_singleton I exact ⟨x, by simpa only [idealOfSet_ofIdeal_eq_closure, I.closure_eq_of_isClosed hI] using congr_arg (idealOfSet 𝕜) hx.symm⟩ end RCLike end ContinuousMap namespace WeakDual namespace CharacterSpace open Function ContinuousMap variable (X 𝕜 : Type*) [TopologicalSpace X] section ContinuousMapEval variable [LocallyCompactSpace X] [CommRing 𝕜] [TopologicalSpace 𝕜] [TopologicalRing 𝕜] variable [Nontrivial 𝕜] [NoZeroDivisors 𝕜] /-- The natural continuous map from a locally compact topological space `X` to the `WeakDual.characterSpace 𝕜 C(X, 𝕜)` which sends `x : X` to point evaluation at `x`. -/ def continuousMapEval : C(X, characterSpace 𝕜 C(X, 𝕜)) where toFun x := ⟨{ toFun := fun f => f x map_add' := fun f g => rfl map_smul' := fun z f => rfl cont := continuous_eval_const x }, by rw [CharacterSpace.eq_set_map_one_map_mul]; exact ⟨rfl, fun f g => rfl⟩⟩ continuous_toFun := by exact Continuous.subtype_mk (continuous_of_continuous_eval map_continuous) _ @[simp] theorem continuousMapEval_apply_apply (x : X) (f : C(X, 𝕜)) : continuousMapEval X 𝕜 x f = f x := rfl end ContinuousMapEval variable [CompactSpace X] [T2Space X] [RCLike 𝕜] theorem continuousMapEval_bijective : Bijective (continuousMapEval X 𝕜) := by refine ⟨fun x y hxy => ?_, fun φ => ?_⟩ · contrapose! hxy rcases exists_continuous_zero_one_of_isClosed (isClosed_singleton : _root_.IsClosed {x}) (isClosed_singleton : _root_.IsClosed {y}) (Set.disjoint_singleton.mpr hxy) with ⟨f, fx, fy, -⟩ rw [DFunLike.ne_iff] use (⟨fun (x : ℝ) => (x : 𝕜), RCLike.continuous_ofReal⟩ : C(ℝ, 𝕜)).comp f simpa only [continuousMapEval_apply_apply, ContinuousMap.comp_apply, coe_mk, Ne, RCLike.ofReal_inj] using ((fx (Set.mem_singleton x)).symm ▸ (fy (Set.mem_singleton y)).symm ▸ zero_ne_one : f x ≠ f y) · obtain ⟨x, hx⟩ := (ideal_isMaximal_iff (RingHom.ker φ)).mp inferInstance refine ⟨x, CharacterSpace.ext_ker <| Ideal.ext fun f => ?_⟩ simpa only [RingHom.mem_ker, continuousMapEval_apply_apply, mem_idealOfSet_compl_singleton, RingHom.mem_ker] using SetLike.ext_iff.mp hx f /-- This is the natural homeomorphism between a compact Hausdorff space `X` and the `WeakDual.characterSpace 𝕜 C(X, 𝕜)`. -/ noncomputable def homeoEval : X ≃ₜ characterSpace 𝕜 C(X, 𝕜) := @Continuous.homeoOfEquivCompactToT2 _ _ _ _ _ _ { Equiv.ofBijective _ (continuousMapEval_bijective X 𝕜) with toFun := continuousMapEval X 𝕜 } (map_continuous (continuousMapEval X 𝕜)) end CharacterSpace end WeakDual
Topology\ContinuousFunction\LocallyConstant.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Topology.LocallyConstant.Algebra import Mathlib.Topology.ContinuousFunction.Basic import Mathlib.Topology.ContinuousFunction.Algebra /-! # The algebra morphism from locally constant functions to continuous functions. -/ namespace LocallyConstant variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] (f : LocallyConstant X Y) /-- The inclusion of locally-constant functions into continuous functions as a multiplicative monoid hom. -/ @[to_additive (attr := simps) "The inclusion of locally-constant functions into continuous functions as an additive monoid hom."] def toContinuousMapMonoidHom [Monoid Y] [ContinuousMul Y] : LocallyConstant X Y →* C(X, Y) where toFun := (↑) map_one' := by ext simp map_mul' x y := by ext simp /-- The inclusion of locally-constant functions into continuous functions as a linear map. -/ @[simps] def toContinuousMapLinearMap (R : Type*) [Semiring R] [AddCommMonoid Y] [Module R Y] [ContinuousAdd Y] [ContinuousConstSMul R Y] : LocallyConstant X Y →ₗ[R] C(X, Y) where toFun := (↑) map_add' x y := by ext simp map_smul' x y := by ext simp /-- The inclusion of locally-constant functions into continuous functions as an algebra map. -/ @[simps] def toContinuousMapAlgHom (R : Type*) [CommSemiring R] [Semiring Y] [Algebra R Y] [TopologicalSemiring Y] : LocallyConstant X Y →ₐ[R] C(X, Y) where toFun := (↑) map_one' := by ext simp map_mul' x y := by ext simp map_zero' := by ext simp map_add' x y := by ext simp commutes' r := by ext x simp [Algebra.smul_def] end LocallyConstant
Topology\ContinuousFunction\Ordered.lean
/- Copyright (c) 2021 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Shing Tak Lam -/ import Mathlib.Topology.ContinuousFunction.Basic import Mathlib.Topology.Order.Lattice import Mathlib.Topology.Order.ProjIcc /-! # Bundled continuous maps into orders, with order-compatible topology -/ variable {α : Type*} {β : Type*} {γ : Type*} variable [TopologicalSpace α] [TopologicalSpace β] [TopologicalSpace γ] namespace ContinuousMap /-! We now set up the partial order and lattice structure (given by pointwise min and max) on continuous functions. -/ instance partialOrder [PartialOrder β] : PartialOrder C(α, β) := PartialOrder.lift (fun f => f.toFun) (fun f g _ => by aesop) theorem le_def [PartialOrder β] {f g : C(α, β)} : f ≤ g ↔ ∀ a, f a ≤ g a := Pi.le_def theorem lt_def [PartialOrder β] {f g : C(α, β)} : f < g ↔ (∀ a, f a ≤ g a) ∧ ∃ a, f a < g a := Pi.lt_def section SemilatticeSup variable [SemilatticeSup β] [ContinuousSup β] instance sup : Sup C(α, β) where sup f g := { toFun := fun a ↦ f a ⊔ g a } @[simp, norm_cast] lemma coe_sup (f g : C(α, β)) : ⇑(f ⊔ g) = ⇑f ⊔ g := rfl @[simp] lemma sup_apply (f g : C(α, β)) (a : α) : (f ⊔ g) a = f a ⊔ g a := rfl instance semilatticeSup : SemilatticeSup C(α, β) := DFunLike.coe_injective.semilatticeSup _ fun _ _ ↦ rfl lemma sup'_apply {ι : Type*} {s : Finset ι} (H : s.Nonempty) (f : ι → C(α, β)) (a : α) : s.sup' H f a = s.sup' H fun i ↦ f i a := Finset.comp_sup'_eq_sup'_comp H (fun g : C(α, β) ↦ g a) fun _ _ ↦ rfl @[simp, norm_cast] lemma coe_sup' {ι : Type*} {s : Finset ι} (H : s.Nonempty) (f : ι → C(α, β)) : ⇑(s.sup' H f) = s.sup' H fun i ↦ ⇑(f i) := by ext; simp [sup'_apply] end SemilatticeSup section SemilatticeInf variable [SemilatticeInf β] [ContinuousInf β] instance inf : Inf C(α, β) where inf f g := { toFun := fun a ↦ f a ⊓ g a } @[simp, norm_cast] lemma coe_inf (f g : C(α, β)) : ⇑(f ⊓ g) = ⇑f ⊓ g := rfl @[simp] lemma inf_apply (f g : C(α, β)) (a : α) : (f ⊓ g) a = f a ⊓ g a := rfl instance semilatticeInf : SemilatticeInf C(α, β) := DFunLike.coe_injective.semilatticeInf _ fun _ _ ↦ rfl lemma inf'_apply {ι : Type*} {s : Finset ι} (H : s.Nonempty) (f : ι → C(α, β)) (a : α) : s.inf' H f a = s.inf' H fun i ↦ f i a := Finset.comp_inf'_eq_inf'_comp H (fun g : C(α, β) ↦ g a) fun _ _ ↦ rfl @[simp, norm_cast] lemma coe_inf' {ι : Type*} {s : Finset ι} (H : s.Nonempty) (f : ι → C(α, β)) : ⇑(s.inf' H f) = s.inf' H fun i ↦ ⇑(f i) := by ext; simp [inf'_apply] end SemilatticeInf instance [Lattice β] [TopologicalLattice β] : Lattice C(α, β) := DFunLike.coe_injective.lattice _ (fun _ _ ↦ rfl) fun _ _ ↦ rfl -- TODO transfer this lattice structure to `BoundedContinuousFunction` section Extend variable [LinearOrder α] [OrderTopology α] {a b : α} (h : a ≤ b) /-- Extend a continuous function `f : C(Set.Icc a b, β)` to a function `f : C(α, β)`. -/ def IccExtend (f : C(Set.Icc a b, β)) : C(α, β) where toFun := Set.IccExtend h f @[simp] theorem coe_IccExtend (f : C(Set.Icc a b, β)) : ((IccExtend h f : C(α, β)) : α → β) = Set.IccExtend h f := rfl end Extend end ContinuousMap
Topology\ContinuousFunction\Polynomial.lean
/- Copyright (c) 2021 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Topology.Algebra.Polynomial import Mathlib.Topology.ContinuousFunction.Algebra import Mathlib.Topology.UnitInterval import Mathlib.Algebra.Star.Subalgebra /-! # Constructions relating polynomial functions and continuous functions. ## Main definitions * `Polynomial.toContinuousMapOn p X`: for `X : Set R`, interprets a polynomial `p` as a bundled continuous function in `C(X, R)`. * `Polynomial.toContinuousMapOnAlgHom`: the same, as an `R`-algebra homomorphism. * `polynomialFunctions (X : Set R) : Subalgebra R C(X, R)`: polynomial functions as a subalgebra. * `polynomialFunctions_separatesPoints (X : Set R) : (polynomialFunctions X).SeparatesPoints`: the polynomial functions separate points. -/ variable {R : Type*} open Polynomial namespace Polynomial section variable [Semiring R] [TopologicalSpace R] [TopologicalSemiring R] /-- Every polynomial with coefficients in a topological semiring gives a (bundled) continuous function. -/ @[simps] def toContinuousMap (p : R[X]) : C(R, R) := ⟨fun x : R => p.eval x, by fun_prop⟩ open ContinuousMap in lemma toContinuousMap_X_eq_id : X.toContinuousMap = .id R := by ext; simp /-- A polynomial as a continuous function, with domain restricted to some subset of the semiring of coefficients. (This is particularly useful when restricting to compact sets, e.g. `[0,1]`.) -/ @[simps] def toContinuousMapOn (p : R[X]) (X : Set R) : C(X, R) := ⟨fun x : X => p.toContinuousMap x, by fun_prop⟩ open ContinuousMap in lemma toContinuousMapOn_X_eq_restrict_id (s : Set R) : X.toContinuousMapOn s = restrict s (.id R) := by ext; simp -- TODO some lemmas about when `toContinuousMapOn` is injective? end section variable {α : Type*} [TopologicalSpace α] [CommSemiring R] [TopologicalSpace R] [TopologicalSemiring R] @[simp] theorem aeval_continuousMap_apply (g : R[X]) (f : C(α, R)) (x : α) : ((Polynomial.aeval f) g) x = g.eval (f x) := by refine Polynomial.induction_on' g ?_ ?_ · intro p q hp hq simp [hp, hq] · intro n a simp [Pi.pow_apply] end noncomputable section variable [CommSemiring R] [TopologicalSpace R] [TopologicalSemiring R] /-- The algebra map from `R[X]` to continuous functions `C(R, R)`. -/ @[simps] def toContinuousMapAlgHom : R[X] →ₐ[R] C(R, R) where toFun p := p.toContinuousMap map_zero' := by ext simp map_add' _ _ := by ext simp map_one' := by ext simp map_mul' _ _ := by ext simp commutes' _ := by ext simp [Algebra.algebraMap_eq_smul_one] /-- The algebra map from `R[X]` to continuous functions `C(X, R)`, for any subset `X` of `R`. -/ @[simps] def toContinuousMapOnAlgHom (X : Set R) : R[X] →ₐ[R] C(X, R) where toFun p := p.toContinuousMapOn X map_zero' := by ext simp map_add' _ _ := by ext simp map_one' := by ext simp map_mul' _ _ := by ext simp commutes' _ := by ext simp [Algebra.algebraMap_eq_smul_one] end end Polynomial section variable [CommSemiring R] [TopologicalSpace R] [TopologicalSemiring R] /-- The subalgebra of polynomial functions in `C(X, R)`, for `X` a subset of some topological semiring `R`. -/ noncomputable -- Porting note: added noncomputable def polynomialFunctions (X : Set R) : Subalgebra R C(X, R) := (⊤ : Subalgebra R R[X]).map (Polynomial.toContinuousMapOnAlgHom X) @[simp] theorem polynomialFunctions_coe (X : Set R) : (polynomialFunctions X : Set C(X, R)) = Set.range (Polynomial.toContinuousMapOnAlgHom X) := by ext simp [polynomialFunctions] -- TODO: -- if `f : R → R` is an affine equivalence, then pulling back along `f` -- induces a normed algebra isomorphism between `polynomialFunctions X` and -- `polynomialFunctions (f ⁻¹' X)`, intertwining the pullback along `f` of `C(R, R)` to itself. theorem polynomialFunctions_separatesPoints (X : Set R) : (polynomialFunctions X).SeparatesPoints := fun x y h => by -- We use `Polynomial.X`, then clean up. refine ⟨_, ⟨⟨_, ⟨⟨Polynomial.X, ⟨Algebra.mem_top, rfl⟩⟩, rfl⟩⟩, ?_⟩⟩ dsimp; simp only [Polynomial.eval_X] exact fun h' => h (Subtype.ext h') open unitInterval open ContinuousMap /-- The preimage of polynomials on `[0,1]` under the pullback map by `x ↦ (b-a) * x + a` is the polynomials on `[a,b]`. -/ theorem polynomialFunctions.comap_compRightAlgHom_iccHomeoI (a b : ℝ) (h : a < b) : (polynomialFunctions I).comap (compRightAlgHom ℝ ℝ (iccHomeoI a b h).symm.toContinuousMap) = polynomialFunctions (Set.Icc a b) := by ext f fconstructor · rintro ⟨p, ⟨-, w⟩⟩ rw [DFunLike.ext_iff] at w dsimp at w let q := p.comp ((b - a)⁻¹ • Polynomial.X + Polynomial.C (-a * (b - a)⁻¹)) refine ⟨q, ⟨?_, ?_⟩⟩ · simp · ext x simp only [q, neg_mul, RingHom.map_neg, RingHom.map_mul, AlgHom.coe_toRingHom, Polynomial.eval_X, Polynomial.eval_neg, Polynomial.eval_C, Polynomial.eval_smul, smul_eq_mul, Polynomial.eval_mul, Polynomial.eval_add, Polynomial.coe_aeval_eq_eval, Polynomial.eval_comp, Polynomial.toContinuousMapOnAlgHom_apply, Polynomial.toContinuousMapOn_apply, Polynomial.toContinuousMap_apply] convert w ⟨_, _⟩ · ext simp only [iccHomeoI_symm_apply_coe, Subtype.coe_mk] replace h : b - a ≠ 0 := sub_ne_zero_of_ne h.ne.symm simp only [mul_add] field_simp ring · change _ + _ ∈ I rw [mul_comm (b - a)⁻¹, ← neg_mul, ← add_mul, ← sub_eq_add_neg] have w₁ : 0 < (b - a)⁻¹ := inv_pos.mpr (sub_pos.mpr h) have w₂ : 0 ≤ (x : ℝ) - a := sub_nonneg.mpr x.2.1 have w₃ : (x : ℝ) - a ≤ b - a := sub_le_sub_right x.2.2 a fconstructor · exact mul_nonneg w₂ (le_of_lt w₁) · rw [← div_eq_mul_inv, div_le_one (sub_pos.mpr h)] exact w₃ · rintro ⟨p, ⟨-, rfl⟩⟩ let q := p.comp ((b - a) • Polynomial.X + Polynomial.C a) refine ⟨q, ⟨?_, ?_⟩⟩ · simp · ext x simp [q, mul_comm] theorem polynomialFunctions.eq_adjoin_X (s : Set R) : polynomialFunctions s = Algebra.adjoin R {toContinuousMapOnAlgHom s X} := by refine le_antisymm ?_ (Algebra.adjoin_le fun _ h => ⟨X, trivial, (Set.mem_singleton_iff.1 h).symm⟩) rintro - ⟨p, -, rfl⟩ rw [AlgHom.coe_toRingHom] refine p.induction_on (fun r => ?_) (fun f g hf hg => ?_) fun n r hn => ?_ · rw [Polynomial.C_eq_algebraMap, AlgHomClass.commutes] exact Subalgebra.algebraMap_mem _ r · rw [map_add] exact add_mem hf hg · rw [pow_succ, ← mul_assoc, map_mul] exact mul_mem hn (Algebra.subset_adjoin <| Set.mem_singleton _) theorem polynomialFunctions.le_equalizer {A : Type*} [Semiring A] [Algebra R A] (s : Set R) (φ ψ : C(s, R) →ₐ[R] A) (h : φ (toContinuousMapOnAlgHom s X) = ψ (toContinuousMapOnAlgHom s X)) : polynomialFunctions s ≤ AlgHom.equalizer φ ψ := by rw [polynomialFunctions.eq_adjoin_X s] exact φ.adjoin_le_equalizer ψ fun x hx => (Set.mem_singleton_iff.1 hx).symm ▸ h open StarAlgebra theorem polynomialFunctions.starClosure_eq_adjoin_X [StarRing R] [ContinuousStar R] (s : Set R) : (polynomialFunctions s).starClosure = adjoin R {toContinuousMapOnAlgHom s X} := by rw [polynomialFunctions.eq_adjoin_X s, adjoin_eq_starClosure_adjoin] theorem polynomialFunctions.starClosure_le_equalizer {A : Type*} [StarRing R] [ContinuousStar R] [Semiring A] [StarRing A] [Algebra R A] (s : Set R) (φ ψ : C(s, R) →⋆ₐ[R] A) (h : φ (toContinuousMapOnAlgHom s X) = ψ (toContinuousMapOnAlgHom s X)) : (polynomialFunctions s).starClosure ≤ StarAlgHom.equalizer φ ψ := by rw [polynomialFunctions.starClosure_eq_adjoin_X s] exact StarAlgHom.adjoin_le_equalizer φ ψ fun x hx => (Set.mem_singleton_iff.1 hx).symm ▸ h end
Topology\ContinuousFunction\Sigma.lean
/- Copyright (c) 2023 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Topology.CompactOpen /-! # Equivalence between `C(X, Σ i, Y i)` and `Σ i, C(X, Y i)` If `X` is a connected topological space, then for every continuous map `f` from `X` to the disjoint union of a collection of topological spaces `Y i` there exists a unique index `i` and a continuous map from `g` to `Y i` such that `f` is the composition of the natural embedding `Sigma.mk i : Y i → Σ i, Y i` with `g`. This defines an equivalence between `C(X, Σ i, Y i)` and `Σ i, C(X, Y i)`. In fact, this equivalence is a homeomorphism if the spaces of continuous maps are equipped with the compact-open topology. ## Implementation notes There are two natural ways to talk about this result: one is to say that for each `f` there exist unique `i` and `g`; another one is to define a noncomputable equivalence. We choose the second way because it is easier to use an equivalence in applications. ## TODO Some results in this file can be generalized to the case when `X` is a preconnected space. However, if `X` is empty, then any index `i` will work, so there is no 1-to-1 corespondence. ## Keywords continuous map, sigma type, disjoint union -/ noncomputable section open scoped Topology open Filter variable {X ι : Type*} {Y : ι → Type*} [TopologicalSpace X] [∀ i, TopologicalSpace (Y i)] namespace ContinuousMap theorem embedding_sigmaMk_comp [Nonempty X] : Embedding (fun g : Σ i, C(X, Y i) ↦ (sigmaMk g.1).comp g.2) where toInducing := inducing_sigma.2 ⟨fun i ↦ (sigmaMk i).inducing_comp embedding_sigmaMk.toInducing, fun i ↦ let ⟨x⟩ := ‹Nonempty X› ⟨_, (isOpen_sigma_fst_preimage {i}).preimage (continuous_eval_const x), fun _ ↦ Iff.rfl⟩⟩ inj := by · rintro ⟨i, g⟩ ⟨i', g'⟩ h obtain ⟨rfl, hg⟩ : i = i' ∧ HEq (⇑g) (⇑g') := Function.eq_of_sigmaMk_comp <| congr_arg DFunLike.coe h simpa using hg section ConnectedSpace variable [ConnectedSpace X] /-- Every continuous map from a connected topological space to the disjoint union of a family of topological spaces is a composition of the embedding `ContinuousMap.sigmMk i : C(Y i, Σ i, Y i)` for some `i` and a continuous map `g : C(X, Y i)`. See also `Continuous.exists_lift_sigma` for a version with unbundled functions and `ContinuousMap.sigmaCodHomeomorph` for a homeomorphism defined using this fact. -/ theorem exists_lift_sigma (f : C(X, Σ i, Y i)) : ∃ i g, f = (sigmaMk i).comp g := let ⟨i, g, hg, hfg⟩ := f.continuous.exists_lift_sigma ⟨i, ⟨g, hg⟩, DFunLike.ext' hfg⟩ variable (X Y) /-- Homeomorphism between the type `C(X, Σ i, Y i)` of continuous maps from a connected topological space to the disjoint union of a family of topological spaces and the disjoint union of the types of continuous maps `C(X, Y i)`. The inverse map sends `⟨i, g⟩` to `ContinuousMap.comp (ContinuousMap.sigmaMk i) g`. -/ @[simps! symm_apply] def sigmaCodHomeomorph : C(X, Σ i, Y i) ≃ₜ Σ i, C(X, Y i) := .symm <| Equiv.toHomeomorphOfInducing (.ofBijective _ ⟨embedding_sigmaMk_comp.inj, fun f ↦ let ⟨i, g, hg⟩ := f.exists_lift_sigma; ⟨⟨i, g⟩, hg.symm⟩⟩) embedding_sigmaMk_comp.toInducing end ConnectedSpace end ContinuousMap
Topology\ContinuousFunction\StarOrdered.lean
/- Copyright (c) 2024 Jireh Loreaux. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jireh Loreaux -/ import Mathlib.Analysis.Complex.Basic import Mathlib.Data.Real.StarOrdered import Mathlib.Topology.ContinuousFunction.Algebra import Mathlib.Topology.ContinuousFunction.ContinuousMapZero /-! # Continuous functions as a star-ordered ring -/ open scoped NNReal namespace ContinuousMap variable {α : Type*} [TopologicalSpace α] lemma starOrderedRing_of_sqrt {R : Type*} [PartialOrder R] [NonUnitalRing R] [StarRing R] [StarOrderedRing R] [TopologicalSpace R] [ContinuousStar R] [TopologicalRing R] (sqrt : R → R) (h_continuousOn : ContinuousOn sqrt {x : R | 0 ≤ x}) (h_sqrt : ∀ x, 0 ≤ x → star (sqrt x) * sqrt x = x) : StarOrderedRing C(α, R) := StarOrderedRing.of_nonneg_iff' add_le_add_left fun f ↦ by constructor · intro hf use (mk _ h_continuousOn.restrict).comp ⟨_, map_continuous f |>.codRestrict (by exact hf ·)⟩ ext x exact h_sqrt (f x) (hf x) |>.symm · rintro ⟨f, rfl⟩ rw [ContinuousMap.le_def] exact fun x ↦ star_mul_self_nonneg (f x) open scoped ComplexOrder in open RCLike in instance (priority := 100) instStarOrderedRingRCLike {𝕜 : Type*} [RCLike 𝕜] : StarOrderedRing C(α, 𝕜) := starOrderedRing_of_sqrt ((↑) ∘ Real.sqrt ∘ re) (by fun_prop) fun x hx ↦ by simp only [Function.comp_apply,star_def] obtain hx' := nonneg_iff.mp hx |>.right rw [← conj_eq_iff_im, conj_eq_iff_re] at hx' rw [conj_ofReal, ← ofReal_mul, Real.mul_self_sqrt, hx'] rw [nonneg_iff] simpa using nonneg_iff.mp hx |>.left instance instStarOrderedRingReal : StarOrderedRing C(α, ℝ) := instStarOrderedRingRCLike (𝕜 := ℝ) open scoped ComplexOrder in open Complex in instance instStarOrderedRingComplex : StarOrderedRing C(α, ℂ) := instStarOrderedRingRCLike (𝕜 := ℂ) open NNReal in instance instStarOrderedRingNNReal : StarOrderedRing C(α, ℝ≥0) := StarOrderedRing.of_le_iff fun f g ↦ by constructor · intro hfg use .comp ⟨sqrt, by fun_prop⟩ (g - f) ext1 x simpa using add_tsub_cancel_of_le (hfg x) |>.symm · rintro ⟨s, rfl⟩ exact fun _ ↦ by simp end ContinuousMap namespace ContinuousMapZero variable {α : Type*} [TopologicalSpace α] [Zero α] instance instStarOrderedRing {R : Type*} [TopologicalSpace R] [OrderedCommSemiring R] [NoZeroDivisors R] [StarRing R] [StarOrderedRing R] [TopologicalSemiring R] [ContinuousStar R] [StarOrderedRing C(α, R)] : StarOrderedRing C(α, R)₀ where le_iff f g := by constructor · rw [le_def, ← ContinuousMap.coe_coe, ← ContinuousMap.coe_coe g, ← ContinuousMap.le_def, StarOrderedRing.le_iff] rintro ⟨p, hp_mem, hp⟩ induction hp_mem using AddSubmonoid.closure_induction_left generalizing f g with | one => exact ⟨0, zero_mem _, by ext x; congrm($(hp) x)⟩ | mul_left s s_mem p p_mem hp' => obtain ⟨s, rfl⟩ := s_mem simp only at * have h₀ : (star s * s + p) 0 = 0 := by simpa using congr($(hp) 0).symm rw [← add_assoc] at hp have p'₀ : 0 ≤ p 0 := by rw [← StarOrderedRing.nonneg_iff] at p_mem; exact p_mem 0 have s₉ : (star s * s) 0 = 0 := le_antisymm ((le_add_of_nonneg_right p'₀).trans_eq h₀) (star_mul_self_nonneg (s 0)) have s₀' : s 0 = 0 := by aesop let s' : C(α, R)₀ := ⟨s, s₀'⟩ obtain ⟨p', hp'_mem, rfl⟩ := hp' (f + star s' * s') g hp refine ⟨star s' * s' + p', ?_, by rw [add_assoc]⟩ exact add_mem (AddSubmonoid.subset_closure ⟨s', rfl⟩) hp'_mem · rintro ⟨p, hp, rfl⟩ induction hp using AddSubmonoid.closure_induction' generalizing f with | mem s s_mem => obtain ⟨s, rfl⟩ := s_mem exact fun x ↦ le_add_of_nonneg_right (star_mul_self_nonneg (s x)) | one => simp | mul g₁ _ g₂ _ h₁ h₂ => calc f ≤ f + g₁ := h₁ f _ ≤ (f + g₁) + g₂ := h₂ (f + g₁) _ = f + (g₁ + g₂) := add_assoc _ _ _ instance instStarOrderedRingReal : StarOrderedRing C(α, ℝ)₀ := instStarOrderedRing (R := ℝ) open scoped ComplexOrder in instance instStarOrderedRingComplex : StarOrderedRing C(α, ℂ)₀ := instStarOrderedRing (R := ℂ) instance instStarOrderedRingNNReal : StarOrderedRing C(α, ℝ≥0)₀ := instStarOrderedRing (R := ℝ≥0) end ContinuousMapZero
Topology\ContinuousFunction\StoneWeierstrass.lean
/- Copyright (c) 2021 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Heather Macbeth -/ import Mathlib.Algebra.Algebra.Subalgebra.Unitization import Mathlib.Analysis.RCLike.Basic import Mathlib.Topology.Algebra.StarSubalgebra import Mathlib.Topology.ContinuousFunction.ContinuousMapZero import Mathlib.Topology.ContinuousFunction.Weierstrass /-! # The Stone-Weierstrass theorem If a subalgebra `A` of `C(X, ℝ)`, where `X` is a compact topological space, separates points, then it is dense. We argue as follows. * In any subalgebra `A` of `C(X, ℝ)`, if `f ∈ A`, then `abs f ∈ A.topologicalClosure`. This follows from the Weierstrass approximation theorem on `[-‖f‖, ‖f‖]` by approximating `abs` uniformly thereon by polynomials. * This ensures that `A.topologicalClosure` is actually a sublattice: if it contains `f` and `g`, then it contains the pointwise supremum `f ⊔ g` and the pointwise infimum `f ⊓ g`. * Any nonempty sublattice `L` of `C(X, ℝ)` which separates points is dense, by a nice argument approximating a given `f` above and below using separating functions. For each `x y : X`, we pick a function `g x y ∈ L` so `g x y x = f x` and `g x y y = f y`. By continuity these functions remain close to `f` on small patches around `x` and `y`. We use compactness to identify a certain finitely indexed infimum of finitely indexed supremums which is then close to `f` everywhere, obtaining the desired approximation. * Finally we put these pieces together. `L = A.topologicalClosure` is a nonempty sublattice which separates points since `A` does, and so is dense (in fact equal to `⊤`). We then prove the complex version for star subalgebras `A`, by separately approximating the real and imaginary parts using the real subalgebra of real-valued functions in `A` (which still separates points, by taking the norm-square of a separating function). ## Future work Extend to cover the case of subalgebras of the continuous functions vanishing at infinity, on non-compact spaces. -/ noncomputable section namespace ContinuousMap variable {X : Type*} [TopologicalSpace X] [CompactSpace X] open scoped Polynomial /-- Turn a function `f : C(X, ℝ)` into a continuous map into `Set.Icc (-‖f‖) (‖f‖)`, thereby explicitly attaching bounds. -/ def attachBound (f : C(X, ℝ)) : C(X, Set.Icc (-‖f‖) ‖f‖) where toFun x := ⟨f x, ⟨neg_norm_le_apply f x, apply_le_norm f x⟩⟩ @[simp] theorem attachBound_apply_coe (f : C(X, ℝ)) (x : X) : ((attachBound f) x : ℝ) = f x := rfl theorem polynomial_comp_attachBound (A : Subalgebra ℝ C(X, ℝ)) (f : A) (g : ℝ[X]) : (g.toContinuousMapOn (Set.Icc (-‖f‖) ‖f‖)).comp (f : C(X, ℝ)).attachBound = Polynomial.aeval f g := by ext simp only [ContinuousMap.coe_comp, Function.comp_apply, ContinuousMap.attachBound_apply_coe, Polynomial.toContinuousMapOn_apply, Polynomial.aeval_subalgebra_coe, Polynomial.aeval_continuousMap_apply, Polynomial.toContinuousMap_apply] -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [ContinuousMap.attachBound_apply_coe] /-- Given a continuous function `f` in a subalgebra of `C(X, ℝ)`, postcomposing by a polynomial gives another function in `A`. This lemma proves something slightly more subtle than this: we take `f`, and think of it as a function into the restricted target `Set.Icc (-‖f‖) ‖f‖)`, and then postcompose with a polynomial function on that interval. This is in fact the same situation as above, and so also gives a function in `A`. -/ theorem polynomial_comp_attachBound_mem (A : Subalgebra ℝ C(X, ℝ)) (f : A) (g : ℝ[X]) : (g.toContinuousMapOn (Set.Icc (-‖f‖) ‖f‖)).comp (f : C(X, ℝ)).attachBound ∈ A := by rw [polynomial_comp_attachBound] apply SetLike.coe_mem theorem comp_attachBound_mem_closure (A : Subalgebra ℝ C(X, ℝ)) (f : A) (p : C(Set.Icc (-‖f‖) ‖f‖, ℝ)) : p.comp (attachBound (f : C(X, ℝ))) ∈ A.topologicalClosure := by -- `p` itself is in the closure of polynomials, by the Weierstrass theorem, have mem_closure : p ∈ (polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).topologicalClosure := continuousMap_mem_polynomialFunctions_closure _ _ p -- and so there are polynomials arbitrarily close. have frequently_mem_polynomials := mem_closure_iff_frequently.mp mem_closure -- To prove `p.comp (attachBound f)` is in the closure of `A`, -- we show there are elements of `A` arbitrarily close. apply mem_closure_iff_frequently.mpr -- To show that, we pull back the polynomials close to `p`, refine ((compRightContinuousMap ℝ (attachBound (f : C(X, ℝ)))).continuousAt p).tendsto.frequently_map _ ?_ frequently_mem_polynomials -- but need to show that those pullbacks are actually in `A`. rintro _ ⟨g, ⟨-, rfl⟩⟩ simp only [SetLike.mem_coe, AlgHom.coe_toRingHom, compRightContinuousMap_apply, Polynomial.toContinuousMapOnAlgHom_apply] apply polynomial_comp_attachBound_mem theorem abs_mem_subalgebra_closure (A : Subalgebra ℝ C(X, ℝ)) (f : A) : |(f : C(X, ℝ))| ∈ A.topologicalClosure := by let f' := attachBound (f : C(X, ℝ)) let abs : C(Set.Icc (-‖f‖) ‖f‖, ℝ) := { toFun := fun x : Set.Icc (-‖f‖) ‖f‖ => |(x : ℝ)| } change abs.comp f' ∈ A.topologicalClosure apply comp_attachBound_mem_closure theorem inf_mem_subalgebra_closure (A : Subalgebra ℝ C(X, ℝ)) (f g : A) : (f : C(X, ℝ)) ⊓ (g : C(X, ℝ)) ∈ A.topologicalClosure := by rw [inf_eq_half_smul_add_sub_abs_sub' ℝ] refine A.topologicalClosure.smul_mem (A.topologicalClosure.sub_mem (A.topologicalClosure.add_mem (A.le_topologicalClosure f.property) (A.le_topologicalClosure g.property)) ?_) _ exact mod_cast abs_mem_subalgebra_closure A _ theorem inf_mem_closed_subalgebra (A : Subalgebra ℝ C(X, ℝ)) (h : IsClosed (A : Set C(X, ℝ))) (f g : A) : (f : C(X, ℝ)) ⊓ (g : C(X, ℝ)) ∈ A := by convert inf_mem_subalgebra_closure A f g apply SetLike.ext' symm erw [closure_eq_iff_isClosed] exact h theorem sup_mem_subalgebra_closure (A : Subalgebra ℝ C(X, ℝ)) (f g : A) : (f : C(X, ℝ)) ⊔ (g : C(X, ℝ)) ∈ A.topologicalClosure := by rw [sup_eq_half_smul_add_add_abs_sub' ℝ] refine A.topologicalClosure.smul_mem (A.topologicalClosure.add_mem (A.topologicalClosure.add_mem (A.le_topologicalClosure f.property) (A.le_topologicalClosure g.property)) ?_) _ exact mod_cast abs_mem_subalgebra_closure A _ theorem sup_mem_closed_subalgebra (A : Subalgebra ℝ C(X, ℝ)) (h : IsClosed (A : Set C(X, ℝ))) (f g : A) : (f : C(X, ℝ)) ⊔ (g : C(X, ℝ)) ∈ A := by convert sup_mem_subalgebra_closure A f g apply SetLike.ext' symm erw [closure_eq_iff_isClosed] exact h open scoped Topology -- Here's the fun part of Stone-Weierstrass! theorem sublattice_closure_eq_top (L : Set C(X, ℝ)) (nA : L.Nonempty) (inf_mem : ∀ᵉ (f ∈ L) (g ∈ L), f ⊓ g ∈ L) (sup_mem : ∀ᵉ (f ∈ L) (g ∈ L), f ⊔ g ∈ L) (sep : L.SeparatesPointsStrongly) : closure L = ⊤ := by -- We start by boiling down to a statement about close approximation. rw [eq_top_iff] rintro f - refine Filter.Frequently.mem_closure ((Filter.HasBasis.frequently_iff Metric.nhds_basis_ball).mpr fun ε pos => ?_) simp only [exists_prop, Metric.mem_ball] -- It will be helpful to assume `X` is nonempty later, -- so we get that out of the way here. by_cases nX : Nonempty X swap · exact ⟨nA.some, (dist_lt_iff pos).mpr fun x => False.elim (nX ⟨x⟩), nA.choose_spec⟩ /- The strategy now is to pick a family of continuous functions `g x y` in `A` with the property that `g x y x = f x` and `g x y y = f y` (this is immediate from `h : SeparatesPointsStrongly`) then use continuity to see that `g x y` is close to `f` near both `x` and `y`, and finally using compactness to produce the desired function `h` as a maximum over finitely many `x` of a minimum over finitely many `y` of the `g x y`. -/ dsimp only [Set.SeparatesPointsStrongly] at sep choose g hg w₁ w₂ using sep f -- For each `x y`, we define `U x y` to be `{z | f z - ε < g x y z}`, -- and observe this is a neighbourhood of `y`. let U : X → X → Set X := fun x y => {z | f z - ε < g x y z} have U_nhd_y : ∀ x y, U x y ∈ 𝓝 y := by intro x y refine IsOpen.mem_nhds ?_ ?_ · apply isOpen_lt <;> continuity · rw [Set.mem_setOf_eq, w₂] exact sub_lt_self _ pos -- Fixing `x` for a moment, we have a family of functions `fun y ↦ g x y` -- which on different patches (the `U x y`) are greater than `f z - ε`. -- Taking the supremum of these functions -- indexed by a finite collection of patches which cover `X` -- will give us an element of `A` that is globally greater than `f z - ε` -- and still equal to `f x` at `x`. -- Since `X` is compact, for every `x` there is some finset `ys t` -- so the union of the `U x y` for `y ∈ ys x` still covers everything. let ys : X → Finset X := fun x => (CompactSpace.elim_nhds_subcover (U x) (U_nhd_y x)).choose let ys_w : ∀ x, ⋃ y ∈ ys x, U x y = ⊤ := fun x => (CompactSpace.elim_nhds_subcover (U x) (U_nhd_y x)).choose_spec have ys_nonempty : ∀ x, (ys x).Nonempty := fun x => Set.nonempty_of_union_eq_top_of_nonempty _ _ nX (ys_w x) -- Thus for each `x` we have the desired `h x : A` so `f z - ε < h x z` everywhere -- and `h x x = f x`. let h : X → L := fun x => ⟨(ys x).sup' (ys_nonempty x) fun y => (g x y : C(X, ℝ)), Finset.sup'_mem _ sup_mem _ _ _ fun y _ => hg x y⟩ have lt_h : ∀ x z, f z - ε < (h x : X → ℝ) z := by intro x z obtain ⟨y, ym, zm⟩ := Set.exists_set_mem_of_union_eq_top _ _ (ys_w x) z dsimp simp only [Subtype.coe_mk, coe_sup', Finset.sup'_apply, Finset.lt_sup'_iff] exact ⟨y, ym, zm⟩ have h_eq : ∀ x, (h x : X → ℝ) x = f x := by intro x; simp [w₁] -- For each `x`, we define `W x` to be `{z | h x z < f z + ε}`, let W : X → Set X := fun x => {z | (h x : X → ℝ) z < f z + ε} -- This is still a neighbourhood of `x`. have W_nhd : ∀ x, W x ∈ 𝓝 x := by intro x refine IsOpen.mem_nhds ?_ ?_ · -- Porting note: mathlib3 `continuity` found `continuous_set_coe` apply isOpen_lt (continuous_set_coe _ _) continuity · dsimp only [W, Set.mem_setOf_eq] rw [h_eq] exact lt_add_of_pos_right _ pos -- Since `X` is compact, there is some finset `ys t` -- so the union of the `W x` for `x ∈ xs` still covers everything. let xs : Finset X := (CompactSpace.elim_nhds_subcover W W_nhd).choose let xs_w : ⋃ x ∈ xs, W x = ⊤ := (CompactSpace.elim_nhds_subcover W W_nhd).choose_spec have xs_nonempty : xs.Nonempty := Set.nonempty_of_union_eq_top_of_nonempty _ _ nX xs_w -- Finally our candidate function is the infimum over `x ∈ xs` of the `h x`. -- This function is then globally less than `f z + ε`. let k : (L : Type _) := ⟨xs.inf' xs_nonempty fun x => (h x : C(X, ℝ)), Finset.inf'_mem _ inf_mem _ _ _ fun x _ => (h x).2⟩ refine ⟨k.1, ?_, k.2⟩ -- We just need to verify the bound, which we do pointwise. rw [dist_lt_iff pos] intro z -- We rewrite into this particular form, -- so that simp lemmas about inequalities involving `Finset.inf'` can fire. rw [show ∀ a b ε : ℝ, dist a b < ε ↔ a < b + ε ∧ b - ε < a by intros; simp only [← Metric.mem_ball, Real.ball_eq_Ioo, Set.mem_Ioo, and_comm]] fconstructor · dsimp simp only [Finset.inf'_lt_iff, ContinuousMap.inf'_apply] exact Set.exists_set_mem_of_union_eq_top _ _ xs_w z · dsimp simp only [Finset.lt_inf'_iff, ContinuousMap.inf'_apply] rintro x - apply lt_h /-- The **Stone-Weierstrass Approximation Theorem**, that a subalgebra `A` of `C(X, ℝ)`, where `X` is a compact topological space, is dense if it separates points. -/ theorem subalgebra_topologicalClosure_eq_top_of_separatesPoints (A : Subalgebra ℝ C(X, ℝ)) (w : A.SeparatesPoints) : A.topologicalClosure = ⊤ := by -- The closure of `A` is closed under taking `sup` and `inf`, -- and separates points strongly (since `A` does), -- so we can apply `sublattice_closure_eq_top`. apply SetLike.ext' let L := A.topologicalClosure have n : Set.Nonempty (L : Set C(X, ℝ)) := ⟨(1 : C(X, ℝ)), A.le_topologicalClosure A.one_mem⟩ convert sublattice_closure_eq_top (L : Set C(X, ℝ)) n (fun f fm g gm => inf_mem_closed_subalgebra L A.isClosed_topologicalClosure ⟨f, fm⟩ ⟨g, gm⟩) (fun f fm g gm => sup_mem_closed_subalgebra L A.isClosed_topologicalClosure ⟨f, fm⟩ ⟨g, gm⟩) (Subalgebra.SeparatesPoints.strongly (Subalgebra.separatesPoints_monotone A.le_topologicalClosure w)) simp [L] /-- An alternative statement of the Stone-Weierstrass theorem. If `A` is a subalgebra of `C(X, ℝ)` which separates points (and `X` is compact), every real-valued continuous function on `X` is a uniform limit of elements of `A`. -/ theorem continuousMap_mem_subalgebra_closure_of_separatesPoints (A : Subalgebra ℝ C(X, ℝ)) (w : A.SeparatesPoints) (f : C(X, ℝ)) : f ∈ A.topologicalClosure := by rw [subalgebra_topologicalClosure_eq_top_of_separatesPoints A w] simp /-- An alternative statement of the Stone-Weierstrass theorem, for those who like their epsilons. If `A` is a subalgebra of `C(X, ℝ)` which separates points (and `X` is compact), every real-valued continuous function on `X` is within any `ε > 0` of some element of `A`. -/ theorem exists_mem_subalgebra_near_continuousMap_of_separatesPoints (A : Subalgebra ℝ C(X, ℝ)) (w : A.SeparatesPoints) (f : C(X, ℝ)) (ε : ℝ) (pos : 0 < ε) : ∃ g : A, ‖(g : C(X, ℝ)) - f‖ < ε := by have w := mem_closure_iff_frequently.mp (continuousMap_mem_subalgebra_closure_of_separatesPoints A w f) rw [Metric.nhds_basis_ball.frequently_iff] at w obtain ⟨g, H, m⟩ := w ε pos rw [Metric.mem_ball, dist_eq_norm] at H exact ⟨⟨g, m⟩, H⟩ /-- An alternative statement of the Stone-Weierstrass theorem, for those who like their epsilons and don't like bundled continuous functions. If `A` is a subalgebra of `C(X, ℝ)` which separates points (and `X` is compact), every real-valued continuous function on `X` is within any `ε > 0` of some element of `A`. -/ theorem exists_mem_subalgebra_near_continuous_of_separatesPoints (A : Subalgebra ℝ C(X, ℝ)) (w : A.SeparatesPoints) (f : X → ℝ) (c : Continuous f) (ε : ℝ) (pos : 0 < ε) : ∃ g : A, ∀ x, ‖(g : X → ℝ) x - f x‖ < ε := by obtain ⟨g, b⟩ := exists_mem_subalgebra_near_continuousMap_of_separatesPoints A w ⟨f, c⟩ ε pos use g rwa [norm_lt_iff _ pos] at b end ContinuousMap section RCLike open RCLike -- Redefine `X`, since for the next lemma it need not be compact variable {𝕜 : Type*} {X : Type*} [RCLike 𝕜] [TopologicalSpace X] open ContinuousMap /- a post-port refactor eliminated `conjInvariantSubalgebra`, which was only used to state and prove the Stone-Weierstrass theorem, in favor of using `StarSubalgebra`s, which didn't exist at the time Stone-Weierstrass was written. -/ /-- If a star subalgebra of `C(X, 𝕜)` separates points, then the real subalgebra of its purely real-valued elements also separates points. -/ theorem Subalgebra.SeparatesPoints.rclike_to_real {A : StarSubalgebra 𝕜 C(X, 𝕜)} (hA : A.SeparatesPoints) : ((A.restrictScalars ℝ).comap (ofRealAm.compLeftContinuous ℝ continuous_ofReal)).SeparatesPoints := by intro x₁ x₂ hx -- Let `f` in the subalgebra `A` separate the points `x₁`, `x₂` obtain ⟨_, ⟨f, hfA, rfl⟩, hf⟩ := hA hx let F : C(X, 𝕜) := f - const _ (f x₂) -- Subtract the constant `f x₂` from `f`; this is still an element of the subalgebra have hFA : F ∈ A := by refine A.sub_mem hfA (@Eq.subst _ (· ∈ A) _ _ ?_ <| A.smul_mem A.one_mem <| f x₂) ext1 simp only [coe_smul, coe_one, smul_apply, one_apply, Algebra.id.smul_eq_mul, mul_one, const_apply] -- Consider now the function `fun x ↦ |f x - f x₂| ^ 2` refine ⟨_, ⟨⟨(‖F ·‖ ^ 2), by continuity⟩, ?_, rfl⟩, ?_⟩ · -- This is also an element of the subalgebra, and takes only real values rw [SetLike.mem_coe, Subalgebra.mem_comap] convert (A.restrictScalars ℝ).mul_mem hFA (star_mem hFA : star F ∈ A) ext1 simp [← RCLike.mul_conj] · -- And it also separates the points `x₁`, `x₂` simpa [F] using sub_ne_zero.mpr hf variable [CompactSpace X] /-- The Stone-Weierstrass approximation theorem, `RCLike` version, that a star subalgebra `A` of `C(X, 𝕜)`, where `X` is a compact topological space and `RCLike 𝕜`, is dense if it separates points. -/ theorem ContinuousMap.starSubalgebra_topologicalClosure_eq_top_of_separatesPoints (A : StarSubalgebra 𝕜 C(X, 𝕜)) (hA : A.SeparatesPoints) : A.topologicalClosure = ⊤ := by rw [StarSubalgebra.eq_top_iff] -- Let `I` be the natural inclusion of `C(X, ℝ)` into `C(X, 𝕜)` let I : C(X, ℝ) →ₗ[ℝ] C(X, 𝕜) := ofRealCLM.compLeftContinuous ℝ X -- The main point of the proof is that its range (i.e., every real-valued function) is contained -- in the closure of `A` have key : LinearMap.range I ≤ (A.toSubmodule.restrictScalars ℝ).topologicalClosure := by -- Let `A₀` be the subalgebra of `C(X, ℝ)` consisting of `A`'s purely real elements; it is the -- preimage of `A` under `I`. In this argument we only need its submodule structure. let A₀ : Submodule ℝ C(X, ℝ) := (A.toSubmodule.restrictScalars ℝ).comap I -- By `Subalgebra.SeparatesPoints.rclike_to_real`, this subalgebra also separates points, so -- we may apply the real Stone-Weierstrass result to it. have SW : A₀.topologicalClosure = ⊤ := haveI := subalgebra_topologicalClosure_eq_top_of_separatesPoints _ hA.rclike_to_real congr_arg Subalgebra.toSubmodule this rw [← Submodule.map_top, ← SW] -- So it suffices to prove that the image under `I` of the closure of `A₀` is contained in the -- closure of `A`, which follows by abstract nonsense have h₁ := A₀.topologicalClosure_map ((@ofRealCLM 𝕜 _).compLeftContinuousCompact X) have h₂ := (A.toSubmodule.restrictScalars ℝ).map_comap_le I exact h₁.trans (Submodule.topologicalClosure_mono h₂) -- In particular, for a function `f` in `C(X, 𝕜)`, the real and imaginary parts of `f` are in the -- closure of `A` intro f let f_re : C(X, ℝ) := (⟨RCLike.re, RCLike.reCLM.continuous⟩ : C(𝕜, ℝ)).comp f let f_im : C(X, ℝ) := (⟨RCLike.im, RCLike.imCLM.continuous⟩ : C(𝕜, ℝ)).comp f have h_f_re : I f_re ∈ A.topologicalClosure := key ⟨f_re, rfl⟩ have h_f_im : I f_im ∈ A.topologicalClosure := key ⟨f_im, rfl⟩ -- So `f_re + I • f_im` is in the closure of `A` have := A.topologicalClosure.add_mem h_f_re (A.topologicalClosure.smul_mem h_f_im RCLike.I) rw [StarSubalgebra.mem_toSubalgebra] at this convert this -- And this, of course, is just `f` ext apply Eq.symm simp [I, f_re, f_im, mul_comm RCLike.I _] end RCLike section PolynomialFunctions open StarSubalgebra Polynomial open scoped Polynomial /-- Polynomial functions in are dense in `C(s, ℝ)` when `s` is compact. See `polynomialFunctions_closure_eq_top` for the special case `s = Set.Icc a b` which does not use the full Stone-Weierstrass theorem. Of course, that version could be used to prove this one as well. -/ theorem polynomialFunctions.topologicalClosure (s : Set ℝ) [CompactSpace s] : (polynomialFunctions s).topologicalClosure = ⊤ := ContinuousMap.subalgebra_topologicalClosure_eq_top_of_separatesPoints _ (polynomialFunctions_separatesPoints s) /-- The star subalgebra generated by polynomials functions is dense in `C(s, 𝕜)` when `s` is compact and `𝕜` is either `ℝ` or `ℂ`. -/ theorem polynomialFunctions.starClosure_topologicalClosure {𝕜 : Type*} [RCLike 𝕜] (s : Set 𝕜) [CompactSpace s] : (polynomialFunctions s).starClosure.topologicalClosure = ⊤ := ContinuousMap.starSubalgebra_topologicalClosure_eq_top_of_separatesPoints _ (Subalgebra.separatesPoints_monotone le_sup_left (polynomialFunctions_separatesPoints s)) /-- Continuous algebra homomorphisms from `C(s, ℝ)` into an `ℝ`-algebra `A` which agree at `X : 𝕜[X]` (interpreted as a continuous map) are, in fact, equal. -/ @[ext (iff := false)] theorem ContinuousMap.algHom_ext_map_X {A : Type*} [Ring A] [Algebra ℝ A] [TopologicalSpace A] [T2Space A] {s : Set ℝ} [CompactSpace s] {φ ψ : C(s, ℝ) →ₐ[ℝ] A} (hφ : Continuous φ) (hψ : Continuous ψ) (h : φ (toContinuousMapOnAlgHom s X) = ψ (toContinuousMapOnAlgHom s X)) : φ = ψ := by suffices (⊤ : Subalgebra ℝ C(s, ℝ)) ≤ AlgHom.equalizer φ ψ from AlgHom.ext fun x => this (by trivial) rw [← polynomialFunctions.topologicalClosure s] exact Subalgebra.topologicalClosure_minimal (polynomialFunctions s) (polynomialFunctions.le_equalizer s φ ψ h) (isClosed_eq hφ hψ) /-- Continuous star algebra homomorphisms from `C(s, 𝕜)` into a star `𝕜`-algebra `A` which agree at `X : 𝕜[X]` (interpreted as a continuous map) are, in fact, equal. -/ @[ext (iff := false)] theorem ContinuousMap.starAlgHom_ext_map_X {𝕜 A : Type*} [RCLike 𝕜] [Ring A] [StarRing A] [Algebra 𝕜 A] [TopologicalSpace A] [T2Space A] {s : Set 𝕜} [CompactSpace s] {φ ψ : C(s, 𝕜) →⋆ₐ[𝕜] A} (hφ : Continuous φ) (hψ : Continuous ψ) (h : φ (toContinuousMapOnAlgHom s X) = ψ (toContinuousMapOnAlgHom s X)) : φ = ψ := by suffices (⊤ : StarSubalgebra 𝕜 C(s, 𝕜)) ≤ StarAlgHom.equalizer φ ψ from StarAlgHom.ext fun x => this mem_top rw [← polynomialFunctions.starClosure_topologicalClosure s] exact StarSubalgebra.topologicalClosure_minimal (polynomialFunctions.starClosure_le_equalizer s φ ψ h) (isClosed_eq hφ hψ) end PolynomialFunctions /-! ### Continuous maps sending zero to zero -/ section ContinuousMapZero variable {X : Type*} [TopologicalSpace X] {𝕜 : Type*} [RCLike 𝕜] open NonUnitalStarAlgebra Submodule namespace ContinuousMap /- `set_option maxSynthPendingDepth 2` after https://github.com/leanprover/lean4/pull/4119 allows use to remove some shortcut instances. -/ set_option maxSynthPendingDepth 2 lemma adjoin_id_eq_span_one_union (s : Set 𝕜) : ((StarAlgebra.adjoin 𝕜 {(restrict s (.id 𝕜) : C(s, 𝕜))}) : Set C(s, 𝕜)) = span 𝕜 ({(1 : C(s, 𝕜))} ∪ (adjoin 𝕜 {(restrict s (.id 𝕜) : C(s, 𝕜))})) := by ext x rw [SetLike.mem_coe, SetLike.mem_coe, ← StarAlgebra.adjoin_nonUnitalStarSubalgebra, ← StarSubalgebra.mem_toSubalgebra, ← Subalgebra.mem_toSubmodule, StarAlgebra.adjoin_nonUnitalStarSubalgebra_eq_span, span_union, span_eq_toSubmodule] open Pointwise in lemma adjoin_id_eq_span_one_add (s : Set 𝕜) : ((StarAlgebra.adjoin 𝕜 {(restrict s (.id 𝕜) : C(s, 𝕜))}) : Set C(s, 𝕜)) = (span 𝕜 {(1 : C(s, 𝕜))} : Set C(s, 𝕜)) + (adjoin 𝕜 {(restrict s (.id 𝕜) : C(s, 𝕜))}) := by ext x rw [SetLike.mem_coe, ← StarAlgebra.adjoin_nonUnitalStarSubalgebra, ← StarSubalgebra.mem_toSubalgebra, ← Subalgebra.mem_toSubmodule, StarAlgebra.adjoin_nonUnitalStarSubalgebra_eq_span, mem_sup] simp [Set.mem_add] lemma nonUnitalStarAlgebraAdjoin_id_subset_ker_evalStarAlgHom {s : Set 𝕜} (h0 : 0 ∈ s) : (adjoin 𝕜 {restrict s (.id 𝕜)} : Set C(s, 𝕜)) ⊆ RingHom.ker (evalStarAlgHom 𝕜 𝕜 (⟨0, h0⟩ : s)) := by intro f hf induction hf using adjoin_induction' with | mem f hf => obtain rfl := Set.mem_singleton_iff.mp hf rfl | add f _ g _ hf hg => exact add_mem hf hg | zero => exact zero_mem _ | mul f _ g _ _ hg => exact Ideal.mul_mem_left _ f hg | smul r f _ hf => rw [SetLike.mem_coe, RingHom.mem_ker] at hf ⊢ rw [map_smul, hf, smul_zero] | star f _ hf => rw [SetLike.mem_coe, RingHom.mem_ker] at hf ⊢ rw [map_star, hf, star_zero] lemma ker_evalStarAlgHom_inter_adjoin_id (s : Set 𝕜) (h0 : 0 ∈ s) : (StarAlgebra.adjoin 𝕜 {restrict s (.id 𝕜)} : Set C(s, 𝕜)) ∩ RingHom.ker (evalStarAlgHom 𝕜 𝕜 (⟨0, h0⟩ : s)) = adjoin 𝕜 {restrict s (.id 𝕜)} := by ext f constructor · rintro ⟨hf₁, hf₂⟩ rw [SetLike.mem_coe] at hf₂ ⊢ simp_rw [adjoin_id_eq_span_one_add, Set.mem_add, SetLike.mem_coe, mem_span_singleton] at hf₁ obtain ⟨-, ⟨r, rfl⟩, f, hf, rfl⟩ := hf₁ have := nonUnitalStarAlgebraAdjoin_id_subset_ker_evalStarAlgHom h0 hf simp only [SetLike.mem_coe, RingHom.mem_ker, evalStarAlgHom_apply] at hf₂ this rw [add_apply, this, add_zero, smul_apply, one_apply, smul_eq_mul, mul_one] at hf₂ rwa [hf₂, zero_smul, zero_add] · simp only [Set.mem_inter_iff, SetLike.mem_coe] refine fun hf ↦ ⟨?_, nonUnitalStarAlgebraAdjoin_id_subset_ker_evalStarAlgHom h0 hf⟩ exact adjoin_le_starAlgebra_adjoin _ _ hf -- the statement should be in terms of non unital subalgebras, but we lack API open RingHom Filter Topology in theorem AlgHom.closure_ker_inter {F S K A : Type*} [CommRing K] [Ring A] [Algebra K A] [TopologicalSpace K] [T1Space K] [TopologicalSpace A] [ContinuousSub A] [ContinuousSMul K A] [FunLike F A K] [AlgHomClass F K A K] [SetLike S A] [OneMemClass S A] [AddSubgroupClass S A] [SMulMemClass S K A] (φ : F) (hφ : Continuous φ) (s : S) : closure (s ∩ RingHom.ker φ) = closure s ∩ (ker φ : Set A) := by refine subset_antisymm ?_ ?_ · simpa only [ker_eq, (isClosed_singleton.preimage hφ).closure_eq] using closure_inter_subset_inter_closure s (ker φ : Set A) · intro x ⟨hxs, (hxφ : φ x = 0)⟩ rw [mem_closure_iff_clusterPt, ClusterPt] at hxs have : Tendsto (fun y ↦ y - φ y • 1) (𝓝 x ⊓ 𝓟 s) (𝓝 x) := by conv => congr; rfl; rfl; rw [← sub_zero x, ← zero_smul K 1, ← hxφ] exact Filter.tendsto_inf_left (Continuous.tendsto (by fun_prop) x) refine mem_closure_of_tendsto this <| eventually_inf_principal.mpr ?_ filter_upwards [] with g hg using ⟨sub_mem hg (SMulMemClass.smul_mem _ <| one_mem _), by simp [RingHom.mem_ker]⟩ lemma ker_evalStarAlgHom_eq_closure_adjoin_id (s : Set 𝕜) (h0 : 0 ∈ s) [CompactSpace s] : (RingHom.ker (evalStarAlgHom 𝕜 𝕜 (⟨0, h0⟩ : s)) : Set C(s, 𝕜)) = closure (adjoin 𝕜 {(restrict s (.id 𝕜))}) := by rw [← ker_evalStarAlgHom_inter_adjoin_id s h0, AlgHom.closure_ker_inter (φ := evalStarAlgHom 𝕜 𝕜 (X := s) ⟨0, h0⟩) (continuous_eval_const _) _] convert (Set.univ_inter _).symm rw [← Polynomial.toContinuousMapOn_X_eq_restrict_id, ← Polynomial.toContinuousMapOnAlgHom_apply, ← polynomialFunctions.starClosure_eq_adjoin_X s] congrm(($(polynomialFunctions.starClosure_topologicalClosure s) : Set C(s, 𝕜))) end ContinuousMap open ContinuousMapZero in /-- If `s : Set 𝕜` with `RCLike 𝕜` is compact and contains `0`, then the non-unital star subalgebra generated by the identity function in `C(s, 𝕜)₀` is dense. This can be seen as a version of the Weierstrass approximation theorem. -/ lemma ContinuousMapZero.adjoin_id_dense {s : Set 𝕜} [Zero s] (h0 : ((0 : s) : 𝕜) = 0) [CompactSpace s] : Dense (adjoin 𝕜 {(.id h0 : C(s, 𝕜)₀)} : Set C(s, 𝕜)₀) := by have h0' : 0 ∈ s := h0 ▸ (0 : s).property rw [dense_iff_closure_eq, ← closedEmbedding_toContinuousMap.injective.preimage_image (closure _), ← closedEmbedding_toContinuousMap.closure_image_eq, ← coe_toContinuousMapHom, ← NonUnitalStarSubalgebra.coe_map, NonUnitalStarAlgHom.map_adjoin_singleton, toContinuousMapHom_apply, toContinuousMap_id h0, ← ContinuousMap.ker_evalStarAlgHom_eq_closure_adjoin_id s h0'] apply Set.eq_univ_of_forall fun f ↦ ?_ simp only [Set.mem_preimage, toContinuousMapHom_apply, SetLike.mem_coe, RingHom.mem_ker, ContinuousMap.evalStarAlgHom_apply, ContinuousMap.coe_coe] rw [show ⟨0, h0'⟩ = (0 : s) by ext; exact h0.symm, _root_.map_zero f] end ContinuousMapZero
Topology\ContinuousFunction\T0Sierpinski.lean
/- Copyright (c) 2022 Ivan Sadofschi Costa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Ivan Sadofschi Costa -/ import Mathlib.Topology.Order import Mathlib.Topology.Sets.Opens import Mathlib.Topology.ContinuousFunction.Basic /-! # Any T0 space embeds in a product of copies of the Sierpinski space. We consider `Prop` with the Sierpinski topology. If `X` is a topological space, there is a continuous map `productOfMemOpens` from `X` to `Opens X → Prop` which is the product of the maps `X → Prop` given by `x ↦ x ∈ u`. The map `productOfMemOpens` is always inducing. Whenever `X` is T0, `productOfMemOpens` is also injective and therefore an embedding. -/ noncomputable section namespace TopologicalSpace theorem eq_induced_by_maps_to_sierpinski (X : Type*) [t : TopologicalSpace X] : t = ⨅ u : Opens X, sierpinskiSpace.induced (· ∈ u) := by apply le_antisymm · rw [le_iInf_iff] exact fun u => Continuous.le_induced (isOpen_iff_continuous_mem.mp u.2) · intro u h rw [← generateFrom_iUnion_isOpen] apply isOpen_generateFrom_of_mem simp only [Set.mem_iUnion, Set.mem_setOf_eq, isOpen_induced_iff] exact ⟨⟨u, h⟩, {True}, isOpen_singleton_true, by simp [Set.preimage]⟩ variable (X : Type*) [TopologicalSpace X] /-- The continuous map from `X` to the product of copies of the Sierpinski space, (one copy for each open subset `u` of `X`). The `u` coordinate of `productOfMemOpens x` is given by `x ∈ u`. -/ def productOfMemOpens : C(X, Opens X → Prop) where toFun x u := x ∈ u continuous_toFun := continuous_pi_iff.2 fun u => continuous_Prop.2 u.isOpen theorem productOfMemOpens_inducing : Inducing (productOfMemOpens X) := by convert inducing_iInf_to_pi fun (u : Opens X) (x : X) => x ∈ u apply eq_induced_by_maps_to_sierpinski theorem productOfMemOpens_injective [T0Space X] : Function.Injective (productOfMemOpens X) := by intro x1 x2 h apply Inseparable.eq rw [← Inducing.inseparable_iff (productOfMemOpens_inducing X), h] theorem productOfMemOpens_embedding [T0Space X] : Embedding (productOfMemOpens X) := Embedding.mk (productOfMemOpens_inducing X) (productOfMemOpens_injective X) end TopologicalSpace
Topology\ContinuousFunction\Units.lean
/- Copyright (c) 2022 Jireh Loreaux. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jireh Loreaux -/ import Mathlib.Analysis.Normed.Ring.Units import Mathlib.Algebra.Algebra.Spectrum import Mathlib.Topology.ContinuousFunction.Algebra /-! # Units of continuous functions This file concerns itself with `C(X, M)ˣ` and `C(X, Mˣ)` when `X` is a topological space and `M` has some monoid structure compatible with its topology. -/ variable {X M R 𝕜 : Type*} [TopologicalSpace X] namespace ContinuousMap section Monoid variable [Monoid M] [TopologicalSpace M] [ContinuousMul M] /-- Equivalence between continuous maps into the units of a monoid with continuous multiplication and the units of the monoid of continuous maps. -/ -- Porting note: `simps` made bad `simp` lemmas (LHS simplifies) so we add them manually below @[to_additive (attr := simps apply_val_apply symm_apply_apply_val) "Equivalence between continuous maps into the additive units of an additive monoid with continuous addition and the additive units of the additive monoid of continuous maps."] def unitsLift : C(X, Mˣ) ≃ C(X, M)ˣ where toFun f := { val := ⟨fun x => f x, Units.continuous_val.comp f.continuous⟩ inv := ⟨fun x => ↑(f x)⁻¹, Units.continuous_val.comp (continuous_inv.comp f.continuous)⟩ val_inv := ext fun x => Units.mul_inv _ inv_val := ext fun x => Units.inv_mul _ } invFun f := { toFun := fun x => ⟨(f : C(X, M)) x, (↑f⁻¹ : C(X, M)) x, ContinuousMap.congr_fun f.mul_inv x, ContinuousMap.congr_fun f.inv_mul x⟩ continuous_toFun := continuous_induced_rng.2 <| (f : C(X, M)).continuous.prod_mk <| MulOpposite.continuous_op.comp (↑f⁻¹ : C(X, M)).continuous } left_inv f := by ext; rfl right_inv f := by ext; rfl -- Porting note: add manually because `simps` used `inv` and `simpNF` complained @[to_additive (attr := simp)] lemma unitsLift_apply_inv_apply (f : C(X, Mˣ)) (x : X) : (↑(ContinuousMap.unitsLift f)⁻¹ : C(X, M)) x = (f x)⁻¹ := rfl -- Porting note: add manually because `simps` used `inv` and `simpNF` complained @[to_additive (attr := simp)] lemma unitsLift_symm_apply_apply_inv' (f : C(X, M)ˣ) (x : X) : (ContinuousMap.unitsLift.symm f x)⁻¹ = (↑f⁻¹ : C(X, M)) x := by rfl end Monoid section NormedRing variable [NormedRing R] [CompleteSpace R] theorem continuous_isUnit_unit {f : C(X, R)} (h : ∀ x, IsUnit (f x)) : Continuous fun x => (h x).unit := by refine continuous_induced_rng.2 (Continuous.prod_mk f.continuous (MulOpposite.continuous_op.comp (continuous_iff_continuousAt.mpr fun x => ?_))) have := NormedRing.inverse_continuousAt (h x).unit simp only simp only [← Ring.inverse_unit, IsUnit.unit_spec] at this ⊢ exact this.comp (f.continuousAt x) -- Porting note: this had the worst namespace: `NormedRing` /-- Construct a continuous map into the group of units of a normed ring from a function into the normed ring and a proof that every element of the range is a unit. -/ @[simps] noncomputable def unitsOfForallIsUnit {f : C(X, R)} (h : ∀ x, IsUnit (f x)) : C(X, Rˣ) where toFun x := (h x).unit continuous_toFun := continuous_isUnit_unit h instance canLift : CanLift C(X, R) C(X, Rˣ) (fun f => ⟨fun x => f x, Units.continuous_val.comp f.continuous⟩) fun f => ∀ x, IsUnit (f x) where prf f h := ⟨unitsOfForallIsUnit h, by ext; rfl⟩ theorem isUnit_iff_forall_isUnit (f : C(X, R)) : IsUnit f ↔ ∀ x, IsUnit (f x) := Iff.intro (fun h => fun x => ⟨unitsLift.symm h.unit x, rfl⟩) fun h => ⟨ContinuousMap.unitsLift (unitsOfForallIsUnit h), by ext; rfl⟩ end NormedRing section NormedField variable [NormedField 𝕜] [NormedDivisionRing R] [Algebra 𝕜 R] [CompleteSpace R] theorem isUnit_iff_forall_ne_zero (f : C(X, R)) : IsUnit f ↔ ∀ x, f x ≠ 0 := by simp_rw [f.isUnit_iff_forall_isUnit, isUnit_iff_ne_zero] theorem spectrum_eq_preimage_range (f : C(X, R)) : spectrum 𝕜 f = algebraMap _ _ ⁻¹' Set.range f := by ext x simp only [spectrum.mem_iff, isUnit_iff_forall_ne_zero, not_forall, sub_apply, algebraMap_apply, mul_one, Classical.not_not, Set.mem_range, sub_eq_zero, @eq_comm _ (x • 1 : R) _, Set.mem_preimage, Algebra.algebraMap_eq_smul_one, smul_apply, one_apply] theorem spectrum_eq_range [CompleteSpace 𝕜] (f : C(X, 𝕜)) : spectrum 𝕜 f = Set.range f := by rw [spectrum_eq_preimage_range, Algebra.id.map_eq_id] exact Set.preimage_id end NormedField end ContinuousMap
Topology\ContinuousFunction\Weierstrass.lean
/- Copyright (c) 2021 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Analysis.SpecialFunctions.Bernstein import Mathlib.Topology.Algebra.Algebra /-! # The Weierstrass approximation theorem for continuous functions on `[a,b]` We've already proved the Weierstrass approximation theorem in the sense that we've shown that the Bernstein approximations to a continuous function on `[0,1]` converge uniformly. Here we rephrase this more abstractly as `polynomialFunctions_closure_eq_top' : (polynomialFunctions I).topologicalClosure = ⊤` and then, by precomposing with suitable affine functions, `polynomialFunctions_closure_eq_top : (polynomialFunctions (Set.Icc a b)).topologicalClosure = ⊤` -/ open ContinuousMap Filter open scoped unitInterval /-- The special case of the Weierstrass approximation theorem for the interval `[0,1]`. This is just a matter of unravelling definitions and using the Bernstein approximations. -/ theorem polynomialFunctions_closure_eq_top' : (polynomialFunctions I).topologicalClosure = ⊤ := by rw [eq_top_iff] rintro f - refine Filter.Frequently.mem_closure ?_ refine Filter.Tendsto.frequently (bernsteinApproximation_uniform f) ?_ apply frequently_of_forall intro n simp only [SetLike.mem_coe] apply Subalgebra.sum_mem rintro n - apply Subalgebra.smul_mem dsimp [bernstein, polynomialFunctions] simp /-- The **Weierstrass Approximation Theorem**: polynomials functions on `[a, b] ⊆ ℝ` are dense in `C([a,b],ℝ)` (While we could deduce this as an application of the Stone-Weierstrass theorem, our proof of that relies on the fact that `abs` is in the closure of polynomials on `[-M, M]`, so we may as well get this done first.) -/ theorem polynomialFunctions_closure_eq_top (a b : ℝ) : (polynomialFunctions (Set.Icc a b)).topologicalClosure = ⊤ := by cases' lt_or_le a b with h h -- (Otherwise it's easy; we'll deal with that later.) · -- We can pullback continuous functions on `[a,b]` to continuous functions on `[0,1]`, -- by precomposing with an affine map. let W : C(Set.Icc a b, ℝ) →ₐ[ℝ] C(I, ℝ) := compRightAlgHom ℝ ℝ (iccHomeoI a b h).symm.toContinuousMap -- This operation is itself a homeomorphism -- (with respect to the norm topologies on continuous functions). let W' : C(Set.Icc a b, ℝ) ≃ₜ C(I, ℝ) := compRightHomeomorph ℝ (iccHomeoI a b h).symm have w : (W : C(Set.Icc a b, ℝ) → C(I, ℝ)) = W' := rfl -- Thus we take the statement of the Weierstrass approximation theorem for `[0,1]`, have p := polynomialFunctions_closure_eq_top' -- and pullback both sides, obtaining an equation between subalgebras of `C([a,b], ℝ)`. apply_fun fun s => s.comap W at p simp only [Algebra.comap_top] at p -- Since the pullback operation is continuous, it commutes with taking `topologicalClosure`, rw [Subalgebra.topologicalClosure_comap_homeomorph _ W W' w] at p -- and precomposing with an affine map takes polynomial functions to polynomial functions. rw [polynomialFunctions.comap_compRightAlgHom_iccHomeoI] at p -- 🎉 exact p · -- Otherwise, `b ≤ a`, and the interval is a subsingleton, subsingleton [(Set.subsingleton_Icc_of_ge h).coe_sort] /-- An alternative statement of Weierstrass' theorem. Every real-valued continuous function on `[a,b]` is a uniform limit of polynomials. -/ theorem continuousMap_mem_polynomialFunctions_closure (a b : ℝ) (f : C(Set.Icc a b, ℝ)) : f ∈ (polynomialFunctions (Set.Icc a b)).topologicalClosure := by rw [polynomialFunctions_closure_eq_top _ _] simp open scoped Polynomial /-- An alternative statement of Weierstrass' theorem, for those who like their epsilons. Every real-valued continuous function on `[a,b]` is within any `ε > 0` of some polynomial. -/ theorem exists_polynomial_near_continuousMap (a b : ℝ) (f : C(Set.Icc a b, ℝ)) (ε : ℝ) (pos : 0 < ε) : ∃ p : ℝ[X], ‖p.toContinuousMapOn _ - f‖ < ε := by have w := mem_closure_iff_frequently.mp (continuousMap_mem_polynomialFunctions_closure _ _ f) rw [Metric.nhds_basis_ball.frequently_iff] at w obtain ⟨-, H, ⟨m, ⟨-, rfl⟩⟩⟩ := w ε pos rw [Metric.mem_ball, dist_eq_norm] at H exact ⟨m, H⟩ /-- Another alternative statement of Weierstrass's theorem, for those who like epsilons, but not bundled continuous functions. Every real-valued function `ℝ → ℝ` which is continuous on `[a,b]` can be approximated to within any `ε > 0` on `[a,b]` by some polynomial. -/ theorem exists_polynomial_near_of_continuousOn (a b : ℝ) (f : ℝ → ℝ) (c : ContinuousOn f (Set.Icc a b)) (ε : ℝ) (pos : 0 < ε) : ∃ p : ℝ[X], ∀ x ∈ Set.Icc a b, |p.eval x - f x| < ε := by let f' : C(Set.Icc a b, ℝ) := ⟨fun x => f x, continuousOn_iff_continuous_restrict.mp c⟩ obtain ⟨p, b⟩ := exists_polynomial_near_continuousMap a b f' ε pos use p rw [norm_lt_iff _ pos] at b intro x m exact b ⟨x, m⟩
Topology\ContinuousFunction\ZeroAtInfty.lean
/- Copyright (c) 2022 Jireh Loreaux. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jireh Loreaux -/ import Mathlib.Topology.ContinuousFunction.Bounded import Mathlib.Topology.ContinuousFunction.CocompactMap /-! # Continuous functions vanishing at infinity The type of continuous functions vanishing at infinity. When the domain is compact `C(α, β) ≃ C₀(α, β)` via the identity map. When the codomain is a metric space, every continuous map which vanishes at infinity is a bounded continuous function. When the domain is a locally compact space, this type has nice properties. ## TODO * Create more intances of algebraic structures (e.g., `NonUnitalSemiring`) once the necessary type classes (e.g., `TopologicalRing`) are sufficiently generalized. * Relate the unitization of `C₀(α, β)` to the Alexandroff compactification. -/ universe u v w variable {F : Type*} {α : Type u} {β : Type v} {γ : Type w} [TopologicalSpace α] open BoundedContinuousFunction Topology Bornology open Filter Metric /-- `C₀(α, β)` is the type of continuous functions `α → β` which vanish at infinity from a topological space to a metric space with a zero element. When possible, instead of parametrizing results over `(f : C₀(α, β))`, you should parametrize over `(F : Type*) [ZeroAtInftyContinuousMapClass F α β] (f : F)`. When you extend this structure, make sure to extend `ZeroAtInftyContinuousMapClass`. -/ structure ZeroAtInftyContinuousMap (α : Type u) (β : Type v) [TopologicalSpace α] [Zero β] [TopologicalSpace β] extends ContinuousMap α β : Type max u v where /-- The function tends to zero along the `cocompact` filter. -/ zero_at_infty' : Tendsto toFun (cocompact α) (𝓝 0) @[inherit_doc] scoped[ZeroAtInfty] notation (priority := 2000) "C₀(" α ", " β ")" => ZeroAtInftyContinuousMap α β @[inherit_doc] scoped[ZeroAtInfty] notation α " →C₀ " β => ZeroAtInftyContinuousMap α β open ZeroAtInfty section /-- `ZeroAtInftyContinuousMapClass F α β` states that `F` is a type of continuous maps which vanish at infinity. You should also extend this typeclass when you extend `ZeroAtInftyContinuousMap`. -/ class ZeroAtInftyContinuousMapClass (F : Type*) (α β : outParam Type*) [TopologicalSpace α] [Zero β] [TopologicalSpace β] [FunLike F α β] extends ContinuousMapClass F α β : Prop where /-- Each member of the class tends to zero along the `cocompact` filter. -/ zero_at_infty (f : F) : Tendsto f (cocompact α) (𝓝 0) end export ZeroAtInftyContinuousMapClass (zero_at_infty) namespace ZeroAtInftyContinuousMap section Basics variable [TopologicalSpace β] [Zero β] [FunLike F α β] [ZeroAtInftyContinuousMapClass F α β] instance instFunLike : FunLike C₀(α, β) α β where coe f := f.toFun coe_injective' f g h := by obtain ⟨⟨_, _⟩, _⟩ := f obtain ⟨⟨_, _⟩, _⟩ := g congr instance instZeroAtInftyContinuousMapClass : ZeroAtInftyContinuousMapClass C₀(α, β) α β where map_continuous f := f.continuous_toFun zero_at_infty f := f.zero_at_infty' instance instCoeTC : CoeTC F C₀(α, β) := ⟨fun f => { toFun := f continuous_toFun := map_continuous f zero_at_infty' := zero_at_infty f }⟩ @[simp] theorem coe_toContinuousMap (f : C₀(α, β)) : (f.toContinuousMap : α → β) = f := rfl @[ext] theorem ext {f g : C₀(α, β)} (h : ∀ x, f x = g x) : f = g := DFunLike.ext _ _ h /-- Copy of a `ZeroAtInftyContinuousMap` with a new `toFun` equal to the old one. Useful to fix definitional equalities. -/ protected def copy (f : C₀(α, β)) (f' : α → β) (h : f' = f) : C₀(α, β) where toFun := f' continuous_toFun := by rw [h] exact f.continuous_toFun zero_at_infty' := by simp_rw [h] exact f.zero_at_infty' @[simp] theorem coe_copy (f : C₀(α, β)) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' := rfl theorem copy_eq (f : C₀(α, β)) (f' : α → β) (h : f' = f) : f.copy f' h = f := DFunLike.ext' h theorem eq_of_empty [IsEmpty α] (f g : C₀(α, β)) : f = g := ext <| IsEmpty.elim ‹_› /-- A continuous function on a compact space is automatically a continuous function vanishing at infinity. -/ @[simps] def ContinuousMap.liftZeroAtInfty [CompactSpace α] : C(α, β) ≃ C₀(α, β) where toFun f := { toFun := f continuous_toFun := f.continuous zero_at_infty' := by simp } invFun f := f left_inv f := by ext rfl right_inv f := by ext rfl /-- A continuous function on a compact space is automatically a continuous function vanishing at infinity. This is not an instance to avoid type class loops. -/ lemma zeroAtInftyContinuousMapClass.ofCompact {G : Type*} [FunLike G α β] [ContinuousMapClass G α β] [CompactSpace α] : ZeroAtInftyContinuousMapClass G α β where map_continuous := map_continuous zero_at_infty := by simp end Basics /-! ### Algebraic structure Whenever `β` has suitable algebraic structure and a compatible topological structure, then `C₀(α, β)` inherits a corresponding algebraic structure. The primary exception to this is that `C₀(α, β)` will not have a multiplicative identity. -/ section AlgebraicStructure variable [TopologicalSpace β] (x : α) instance instZero [Zero β] : Zero C₀(α, β) := ⟨⟨0, tendsto_const_nhds⟩⟩ instance instInhabited [Zero β] : Inhabited C₀(α, β) := ⟨0⟩ @[simp] theorem coe_zero [Zero β] : ⇑(0 : C₀(α, β)) = 0 := rfl theorem zero_apply [Zero β] : (0 : C₀(α, β)) x = 0 := rfl instance instMul [MulZeroClass β] [ContinuousMul β] : Mul C₀(α, β) := ⟨fun f g => ⟨f * g, by simpa only [mul_zero] using (zero_at_infty f).mul (zero_at_infty g)⟩⟩ @[simp] theorem coe_mul [MulZeroClass β] [ContinuousMul β] (f g : C₀(α, β)) : ⇑(f * g) = f * g := rfl theorem mul_apply [MulZeroClass β] [ContinuousMul β] (f g : C₀(α, β)) : (f * g) x = f x * g x := rfl instance instMulZeroClass [MulZeroClass β] [ContinuousMul β] : MulZeroClass C₀(α, β) := DFunLike.coe_injective.mulZeroClass _ coe_zero coe_mul instance instSemigroupWithZero [SemigroupWithZero β] [ContinuousMul β] : SemigroupWithZero C₀(α, β) := DFunLike.coe_injective.semigroupWithZero _ coe_zero coe_mul instance instAdd [AddZeroClass β] [ContinuousAdd β] : Add C₀(α, β) := ⟨fun f g => ⟨f + g, by simpa only [add_zero] using (zero_at_infty f).add (zero_at_infty g)⟩⟩ @[simp] theorem coe_add [AddZeroClass β] [ContinuousAdd β] (f g : C₀(α, β)) : ⇑(f + g) = f + g := rfl theorem add_apply [AddZeroClass β] [ContinuousAdd β] (f g : C₀(α, β)) : (f + g) x = f x + g x := rfl instance instAddZeroClass [AddZeroClass β] [ContinuousAdd β] : AddZeroClass C₀(α, β) := DFunLike.coe_injective.addZeroClass _ coe_zero coe_add instance instSMul [Zero β] {R : Type*} [Zero R] [SMulWithZero R β] [ContinuousConstSMul R β] : SMul R C₀(α, β) := -- Porting note: Original version didn't have `Continuous.const_smul f.continuous r` ⟨fun r f => ⟨⟨r • ⇑f, Continuous.const_smul f.continuous r⟩, by simpa [smul_zero] using (zero_at_infty f).const_smul r⟩⟩ @[simp, norm_cast] theorem coe_smul [Zero β] {R : Type*} [Zero R] [SMulWithZero R β] [ContinuousConstSMul R β] (r : R) (f : C₀(α, β)) : ⇑(r • f) = r • ⇑f := rfl theorem smul_apply [Zero β] {R : Type*} [Zero R] [SMulWithZero R β] [ContinuousConstSMul R β] (r : R) (f : C₀(α, β)) (x : α) : (r • f) x = r • f x := rfl section AddMonoid variable [AddMonoid β] [ContinuousAdd β] (f g : C₀(α, β)) instance instAddMonoid : AddMonoid C₀(α, β) := DFunLike.coe_injective.addMonoid _ coe_zero coe_add fun _ _ => rfl end AddMonoid instance instAddCommMonoid [AddCommMonoid β] [ContinuousAdd β] : AddCommMonoid C₀(α, β) := DFunLike.coe_injective.addCommMonoid _ coe_zero coe_add fun _ _ => rfl section AddGroup variable [AddGroup β] [TopologicalAddGroup β] (f g : C₀(α, β)) instance instNeg : Neg C₀(α, β) := ⟨fun f => ⟨-f, by simpa only [neg_zero] using (zero_at_infty f).neg⟩⟩ @[simp] theorem coe_neg : ⇑(-f) = -f := rfl theorem neg_apply : (-f) x = -f x := rfl instance instSub : Sub C₀(α, β) := ⟨fun f g => ⟨f - g, by simpa only [sub_zero] using (zero_at_infty f).sub (zero_at_infty g)⟩⟩ @[simp] theorem coe_sub : ⇑(f - g) = f - g := rfl theorem sub_apply : (f - g) x = f x - g x := rfl instance instAddGroup : AddGroup C₀(α, β) := DFunLike.coe_injective.addGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ => rfl) fun _ _ => rfl end AddGroup instance instAddCommGroup [AddCommGroup β] [TopologicalAddGroup β] : AddCommGroup C₀(α, β) := DFunLike.coe_injective.addCommGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ => rfl) fun _ _ => rfl instance instIsCentralScalar [Zero β] {R : Type*} [Zero R] [SMulWithZero R β] [SMulWithZero Rᵐᵒᵖ β] [ContinuousConstSMul R β] [IsCentralScalar R β] : IsCentralScalar R C₀(α, β) := ⟨fun _ _ => ext fun _ => op_smul_eq_smul _ _⟩ instance instSMulWithZero [Zero β] {R : Type*} [Zero R] [SMulWithZero R β] [ContinuousConstSMul R β] : SMulWithZero R C₀(α, β) := Function.Injective.smulWithZero ⟨_, coe_zero⟩ DFunLike.coe_injective coe_smul instance instMulActionWithZero [Zero β] {R : Type*} [MonoidWithZero R] [MulActionWithZero R β] [ContinuousConstSMul R β] : MulActionWithZero R C₀(α, β) := Function.Injective.mulActionWithZero ⟨_, coe_zero⟩ DFunLike.coe_injective coe_smul instance instModule [AddCommMonoid β] [ContinuousAdd β] {R : Type*} [Semiring R] [Module R β] [ContinuousConstSMul R β] : Module R C₀(α, β) := Function.Injective.module R ⟨⟨_, coe_zero⟩, coe_add⟩ DFunLike.coe_injective coe_smul instance instNonUnitalNonAssocSemiring [NonUnitalNonAssocSemiring β] [TopologicalSemiring β] : NonUnitalNonAssocSemiring C₀(α, β) := DFunLike.coe_injective.nonUnitalNonAssocSemiring _ coe_zero coe_add coe_mul fun _ _ => rfl instance instNonUnitalSemiring [NonUnitalSemiring β] [TopologicalSemiring β] : NonUnitalSemiring C₀(α, β) := DFunLike.coe_injective.nonUnitalSemiring _ coe_zero coe_add coe_mul fun _ _ => rfl instance instNonUnitalCommSemiring [NonUnitalCommSemiring β] [TopologicalSemiring β] : NonUnitalCommSemiring C₀(α, β) := DFunLike.coe_injective.nonUnitalCommSemiring _ coe_zero coe_add coe_mul fun _ _ => rfl instance instNonUnitalNonAssocRing [NonUnitalNonAssocRing β] [TopologicalRing β] : NonUnitalNonAssocRing C₀(α, β) := DFunLike.coe_injective.nonUnitalNonAssocRing _ coe_zero coe_add coe_mul coe_neg coe_sub (fun _ _ => rfl) fun _ _ => rfl instance instNonUnitalRing [NonUnitalRing β] [TopologicalRing β] : NonUnitalRing C₀(α, β) := DFunLike.coe_injective.nonUnitalRing _ coe_zero coe_add coe_mul coe_neg coe_sub (fun _ _ => rfl) fun _ _ => rfl instance instNonUnitalCommRing [NonUnitalCommRing β] [TopologicalRing β] : NonUnitalCommRing C₀(α, β) := DFunLike.coe_injective.nonUnitalCommRing _ coe_zero coe_add coe_mul coe_neg coe_sub (fun _ _ => rfl) fun _ _ => rfl instance instIsScalarTower {R : Type*} [Semiring R] [NonUnitalNonAssocSemiring β] [TopologicalSemiring β] [Module R β] [ContinuousConstSMul R β] [IsScalarTower R β β] : IsScalarTower R C₀(α, β) C₀(α, β) where smul_assoc r f g := by ext simp only [smul_eq_mul, coe_mul, coe_smul, Pi.mul_apply, Pi.smul_apply] rw [← smul_eq_mul, ← smul_eq_mul, smul_assoc] instance instSMulCommClass {R : Type*} [Semiring R] [NonUnitalNonAssocSemiring β] [TopologicalSemiring β] [Module R β] [ContinuousConstSMul R β] [SMulCommClass R β β] : SMulCommClass R C₀(α, β) C₀(α, β) where smul_comm r f g := by ext simp only [smul_eq_mul, coe_smul, coe_mul, Pi.smul_apply, Pi.mul_apply] rw [← smul_eq_mul, ← smul_eq_mul, smul_comm] end AlgebraicStructure section Uniform variable [UniformSpace β] [UniformSpace γ] [Zero γ] variable [FunLike F β γ] [ZeroAtInftyContinuousMapClass F β γ] theorem uniformContinuous (f : F) : UniformContinuous (f : β → γ) := (map_continuous f).uniformContinuous_of_tendsto_cocompact (zero_at_infty f) end Uniform /-! ### Metric structure When `β` is a metric space, then every element of `C₀(α, β)` is bounded, and so there is a natural inclusion map `ZeroAtInftyContinuousMap.toBCF : C₀(α, β) → (α →ᵇ β)`. Via this map `C₀(α, β)` inherits a metric as the pullback of the metric on `α →ᵇ β`. Moreover, this map has closed range in `α →ᵇ β` and consequently `C₀(α, β)` is a complete space whenever `β` is complete. -/ section Metric open Metric Set variable [PseudoMetricSpace β] [Zero β] [FunLike F α β] [ZeroAtInftyContinuousMapClass F α β] protected theorem bounded (f : F) : ∃ C, ∀ x y : α, dist ((f : α → β) x) (f y) ≤ C := by obtain ⟨K : Set α, hK₁, hK₂⟩ := mem_cocompact.mp (tendsto_def.mp (zero_at_infty (f : F)) _ (closedBall_mem_nhds (0 : β) zero_lt_one)) obtain ⟨C, hC⟩ := (hK₁.image (map_continuous f)).isBounded.subset_closedBall (0 : β) refine ⟨max C 1 + max C 1, fun x y => ?_⟩ have : ∀ x, f x ∈ closedBall (0 : β) (max C 1) := by intro x by_cases hx : x ∈ K · exact (mem_closedBall.mp <| hC ⟨x, hx, rfl⟩).trans (le_max_left _ _) · exact (mem_closedBall.mp <| mem_preimage.mp (hK₂ hx)).trans (le_max_right _ _) exact (dist_triangle (f x) 0 (f y)).trans (add_le_add (mem_closedBall.mp <| this x) (mem_closedBall'.mp <| this y)) theorem isBounded_range (f : C₀(α, β)) : IsBounded (range f) := isBounded_range_iff.2 (ZeroAtInftyContinuousMap.bounded f) theorem isBounded_image (f : C₀(α, β)) (s : Set α) : IsBounded (f '' s) := f.isBounded_range.subset <| image_subset_range _ _ instance (priority := 100) instBoundedContinuousMapClass : BoundedContinuousMapClass F α β := { ‹ZeroAtInftyContinuousMapClass F α β› with map_bounded := fun f => ZeroAtInftyContinuousMap.bounded f } /-- Construct a bounded continuous function from a continuous function vanishing at infinity. -/ @[simps!] def toBCF (f : C₀(α, β)) : α →ᵇ β := ⟨f, map_bounded f⟩ section variable (α) (β) theorem toBCF_injective : Function.Injective (toBCF : C₀(α, β) → α →ᵇ β) := fun f g h => by ext x simpa only using DFunLike.congr_fun h x end variable {C : ℝ} {f g : C₀(α, β)} /-- The type of continuous functions vanishing at infinity, with the uniform distance induced by the inclusion `ZeroAtInftyContinuousMap.toBCF`, is a pseudo-metric space. -/ noncomputable instance instPseudoMetricSpace : PseudoMetricSpace C₀(α, β) := PseudoMetricSpace.induced toBCF inferInstance /-- The type of continuous functions vanishing at infinity, with the uniform distance induced by the inclusion `ZeroAtInftyContinuousMap.toBCF`, is a metric space. -/ noncomputable instance instMetricSpace {β : Type*} [MetricSpace β] [Zero β] : MetricSpace C₀(α, β) := MetricSpace.induced _ (toBCF_injective α β) inferInstance @[simp] theorem dist_toBCF_eq_dist {f g : C₀(α, β)} : dist f.toBCF g.toBCF = dist f g := rfl open BoundedContinuousFunction /-- Convergence in the metric on `C₀(α, β)` is uniform convergence. -/ theorem tendsto_iff_tendstoUniformly {ι : Type*} {F : ι → C₀(α, β)} {f : C₀(α, β)} {l : Filter ι} : Tendsto F l (𝓝 f) ↔ TendstoUniformly (fun i => F i) f l := by simpa only [Metric.tendsto_nhds] using @BoundedContinuousFunction.tendsto_iff_tendstoUniformly _ _ _ _ _ (fun i => (F i).toBCF) f.toBCF l theorem isometry_toBCF : Isometry (toBCF : C₀(α, β) → α →ᵇ β) := by tauto theorem isClosed_range_toBCF : IsClosed (range (toBCF : C₀(α, β) → α →ᵇ β)) := by refine isClosed_iff_clusterPt.mpr fun f hf => ?_ rw [clusterPt_principal_iff] at hf have : Tendsto f (cocompact α) (𝓝 0) := by refine Metric.tendsto_nhds.mpr fun ε hε => ?_ obtain ⟨_, hg, g, rfl⟩ := hf (ball f (ε / 2)) (ball_mem_nhds f <| half_pos hε) refine (Metric.tendsto_nhds.mp (zero_at_infty g) (ε / 2) (half_pos hε)).mp (eventually_of_forall fun x hx => ?_) calc dist (f x) 0 ≤ dist (g.toBCF x) (f x) + dist (g x) 0 := dist_triangle_left _ _ _ _ < dist g.toBCF f + ε / 2 := add_lt_add_of_le_of_lt (dist_coe_le_dist x) hx _ < ε := by simpa [add_halves ε] using add_lt_add_right (mem_ball.1 hg) (ε / 2) exact ⟨⟨f.toContinuousMap, this⟩, rfl⟩ @[deprecated (since := "2024-03-17")] alias closed_range_toBCF := isClosed_range_toBCF /-- Continuous functions vanishing at infinity taking values in a complete space form a complete space. -/ instance instCompleteSpace [CompleteSpace β] : CompleteSpace C₀(α, β) := (completeSpace_iff_isComplete_range isometry_toBCF.uniformInducing).mpr isClosed_range_toBCF.isComplete end Metric section Norm /-! ### Normed space The norm structure on `C₀(α, β)` is the one induced by the inclusion `toBCF : C₀(α, β) → (α →ᵇ b)`, viewed as an additive monoid homomorphism. Then `C₀(α, β)` is naturally a normed space over a normed field `𝕜` whenever `β` is as well. -/ section NormedSpace noncomputable instance instSeminormedAddCommGroup [SeminormedAddCommGroup β] : SeminormedAddCommGroup C₀(α, β) := SeminormedAddCommGroup.induced _ _ (⟨⟨toBCF, rfl⟩, fun _ _ => rfl⟩ : C₀(α, β) →+ α →ᵇ β) noncomputable instance instNormedAddCommGroup [NormedAddCommGroup β] : NormedAddCommGroup C₀(α, β) := NormedAddCommGroup.induced _ _ (⟨⟨toBCF, rfl⟩, fun _ _ => rfl⟩ : C₀(α, β) →+ α →ᵇ β) (toBCF_injective α β) variable [SeminormedAddCommGroup β] {𝕜 : Type*} [NormedField 𝕜] [NormedSpace 𝕜 β] @[simp] theorem norm_toBCF_eq_norm {f : C₀(α, β)} : ‖f.toBCF‖ = ‖f‖ := rfl instance : NormedSpace 𝕜 C₀(α, β) where norm_smul_le k f := (norm_smul_le k f.toBCF : _) end NormedSpace section NormedRing noncomputable instance instNonUnitalSeminormedRing [NonUnitalSeminormedRing β] : NonUnitalSeminormedRing C₀(α, β) := { instNonUnitalRing, instSeminormedAddCommGroup with norm_mul := fun f g => norm_mul_le f.toBCF g.toBCF } noncomputable instance instNonUnitalNormedRing [NonUnitalNormedRing β] : NonUnitalNormedRing C₀(α, β) := { instNonUnitalRing, instNormedAddCommGroup with norm_mul := fun f g => norm_mul_le f.toBCF g.toBCF } noncomputable instance instNonUnitalSeminormedCommRing [NonUnitalSeminormedCommRing β] : NonUnitalSeminormedCommRing C₀(α, β) := { instNonUnitalSeminormedRing, instNonUnitalCommRing with } noncomputable instance instNonUnitalNormedCommRing [NonUnitalNormedCommRing β] : NonUnitalNormedCommRing C₀(α, β) := { instNonUnitalNormedRing, instNonUnitalCommRing with } end NormedRing end Norm section Star /-! ### Star structure It is possible to equip `C₀(α, β)` with a pointwise `star` operation whenever there is a continuous `star : β → β` for which `star (0 : β) = 0`. We don't have quite this weak a typeclass, but `StarAddMonoid` is close enough. The `StarAddMonoid` and `NormedStarGroup` classes on `C₀(α, β)` are inherited from their counterparts on `α →ᵇ β`. Ultimately, when `β` is a C⋆-ring, then so is `C₀(α, β)`. -/ variable [TopologicalSpace β] [AddMonoid β] [StarAddMonoid β] [ContinuousStar β] instance instStar : Star C₀(α, β) where star f := { toFun := fun x => star (f x) continuous_toFun := (map_continuous f).star zero_at_infty' := by simpa only [star_zero] using (continuous_star.tendsto (0 : β)).comp (zero_at_infty f) } @[simp] theorem coe_star (f : C₀(α, β)) : ⇑(star f) = star (⇑f) := rfl theorem star_apply (f : C₀(α, β)) (x : α) : (star f) x = star (f x) := rfl instance instStarAddMonoid [ContinuousAdd β] : StarAddMonoid C₀(α, β) where star_involutive f := ext fun x => star_star (f x) star_add f g := ext fun x => star_add (f x) (g x) end Star section NormedStar variable [NormedAddCommGroup β] [StarAddMonoid β] [NormedStarGroup β] instance instNormedStarGroup : NormedStarGroup C₀(α, β) where norm_star f := (norm_star f.toBCF : _) end NormedStar section StarModule variable {𝕜 : Type*} [Zero 𝕜] [Star 𝕜] [AddMonoid β] [StarAddMonoid β] [TopologicalSpace β] [ContinuousStar β] [SMulWithZero 𝕜 β] [ContinuousConstSMul 𝕜 β] [StarModule 𝕜 β] instance instStarModule : StarModule 𝕜 C₀(α, β) where star_smul k f := ext fun x => star_smul k (f x) end StarModule section StarRing variable [NonUnitalSemiring β] [StarRing β] [TopologicalSpace β] [ContinuousStar β] [TopologicalSemiring β] instance instStarRing : StarRing C₀(α, β) := { ZeroAtInftyContinuousMap.instStarAddMonoid with star_mul := fun f g => ext fun x => star_mul (f x) (g x) } end StarRing section CStarRing instance instCStarRing [NonUnitalNormedRing β] [StarRing β] [CStarRing β] : CStarRing C₀(α, β) where norm_mul_self_le f := CStarRing.norm_mul_self_le (x := f.toBCF) end CStarRing /-! ### C₀ as a functor For each `β` with sufficient structure, there is a contravariant functor `C₀(-, β)` from the category of topological spaces with morphisms given by `CocompactMap`s. -/ variable {δ : Type*} [TopologicalSpace β] [TopologicalSpace γ] [TopologicalSpace δ] local notation α " →co " β => CocompactMap α β section variable [Zero δ] /-- Composition of a continuous function vanishing at infinity with a cocompact map yields another continuous function vanishing at infinity. -/ def comp (f : C₀(γ, δ)) (g : β →co γ) : C₀(β, δ) where toContinuousMap := (f : C(γ, δ)).comp g zero_at_infty' := (zero_at_infty f).comp (cocompact_tendsto g) @[simp] theorem coe_comp_to_continuous_fun (f : C₀(γ, δ)) (g : β →co γ) : ((f.comp g) : β → δ) = f ∘ g := rfl @[simp] theorem comp_id (f : C₀(γ, δ)) : f.comp (CocompactMap.id γ) = f := ext fun _ => rfl @[simp] theorem comp_assoc (f : C₀(γ, δ)) (g : β →co γ) (h : α →co β) : (f.comp g).comp h = f.comp (g.comp h) := rfl @[simp] theorem zero_comp (g : β →co γ) : (0 : C₀(γ, δ)).comp g = 0 := rfl end /-- Composition as an additive monoid homomorphism. -/ def compAddMonoidHom [AddMonoid δ] [ContinuousAdd δ] (g : β →co γ) : C₀(γ, δ) →+ C₀(β, δ) where toFun f := f.comp g map_zero' := zero_comp g map_add' _ _ := rfl /-- Composition as a semigroup homomorphism. -/ def compMulHom [MulZeroClass δ] [ContinuousMul δ] (g : β →co γ) : C₀(γ, δ) →ₙ* C₀(β, δ) where toFun f := f.comp g map_mul' _ _ := rfl /-- Composition as a linear map. -/ def compLinearMap [AddCommMonoid δ] [ContinuousAdd δ] {R : Type*} [Semiring R] [Module R δ] [ContinuousConstSMul R δ] (g : β →co γ) : C₀(γ, δ) →ₗ[R] C₀(β, δ) where toFun f := f.comp g map_add' _ _ := rfl map_smul' _ _ := rfl /-- Composition as a non-unital algebra homomorphism. -/ def compNonUnitalAlgHom {R : Type*} [Semiring R] [NonUnitalNonAssocSemiring δ] [TopologicalSemiring δ] [Module R δ] [ContinuousConstSMul R δ] (g : β →co γ) : C₀(γ, δ) →ₙₐ[R] C₀(β, δ) where toFun f := f.comp g map_smul' _ _ := rfl map_zero' := rfl map_add' _ _ := rfl map_mul' _ _ := rfl end ZeroAtInftyContinuousMap
Topology\Defs\Basic.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Jeremy Avigad -/ import Mathlib.Order.SetNotation import Mathlib.Tactic.Continuity import Mathlib.Tactic.FunProp /-! # Basic definitions about topological spaces This file contains definitions about topology that do not require imports other than `Mathlib.Data.Set.Lattice`. ## Main definitions * `TopologicalSpace X`: a typeclass endowing `X` with a topology. By definition, a topology is a collection of sets called *open sets* such that - `isOpen_univ`: the whole space is open; - `IsOpen.inter`: the intersection of two open sets is an open set; - `isOpen_sUnion`: the union of a family of open sets is an open set. * `IsOpen s`: predicate saying that `s` is an open set, same as `TopologicalSpace.IsOpen`. * `IsClosed s`: a set is called *closed*, if its complement is an open set. For technical reasons, this is a typeclass. * `IsClopen s`: a set is *clopen* if it is both closed and open. * `interior s`: the *interior* of a set `s` is the maximal open set that is included in `s`. * `closure s`: the *closure* of a set `s` is the minimal closed set that includes `s`. * `frontier s`: the *frontier* of a set is the set difference `closure s \ interior s`. A point `x` belongs to `frontier s`, if any neighborhood of `x` contains points both from `s` and `sᶜ`. * `Dense s`: a set is *dense* if its closure is the whole space. We define it as `∀ x, x ∈ closure s` so that one can write `(h : Dense s) x`. * `DenseRange f`: a function has *dense range*, if `Set.range f` is a dense set. * `Continuous f`: a map is *continuous*, if the preimage of any open set is an open set. * `IsOpenMap f`: a map is an *open map*, if the image of any open set is an open set. * `IsClosedMap f`: a map is a *closed map*, if the image of any closed set is a closed set. ** Notation We introduce notation `IsOpen[t]`, `IsClosed[t]`, `closure[t]`, `Continuous[t₁, t₂]` that allow passing custom topologies to these predicates and functions without using `@`. -/ universe u v open Set /-- A topology on `X`. -/ @[to_additive existing TopologicalSpace] class TopologicalSpace (X : Type u) where /-- A predicate saying that a set is an open set. Use `IsOpen` in the root namespace instead. -/ protected IsOpen : Set X → Prop /-- The set representing the whole space is an open set. Use `isOpen_univ` in the root namespace instead. -/ protected isOpen_univ : IsOpen univ /-- The intersection of two open sets is an open set. Use `IsOpen.inter` instead. -/ protected isOpen_inter : ∀ s t, IsOpen s → IsOpen t → IsOpen (s ∩ t) /-- The union of a family of open sets is an open set. Use `isOpen_sUnion` in the root namespace instead. -/ protected isOpen_sUnion : ∀ s, (∀ t ∈ s, IsOpen t) → IsOpen (⋃₀ s) variable {X : Type u} {Y : Type v} /-! ### Predicates on sets -/ section Defs variable [TopologicalSpace X] [TopologicalSpace Y] {s t : Set X} /-- `IsOpen s` means that `s` is open in the ambient topological space on `X` -/ def IsOpen : Set X → Prop := TopologicalSpace.IsOpen @[simp] theorem isOpen_univ : IsOpen (univ : Set X) := TopologicalSpace.isOpen_univ theorem IsOpen.inter (hs : IsOpen s) (ht : IsOpen t) : IsOpen (s ∩ t) := TopologicalSpace.isOpen_inter s t hs ht theorem isOpen_sUnion {s : Set (Set X)} (h : ∀ t ∈ s, IsOpen t) : IsOpen (⋃₀ s) := TopologicalSpace.isOpen_sUnion s h /-- A set is closed if its complement is open -/ class IsClosed (s : Set X) : Prop where /-- The complement of a closed set is an open set. -/ isOpen_compl : IsOpen sᶜ /-- A set is clopen if it is both closed and open. -/ def IsClopen (s : Set X) : Prop := IsClosed s ∧ IsOpen s /-- A set is locally closed if it is the intersection of some open set and some closed set. Also see `isLocallyClosed_tfae` and other lemmas in `Mathlib/Topology/LocallyClosed`. -/ def IsLocallyClosed (s : Set X) : Prop := ∃ (U Z : Set X), IsOpen U ∧ IsClosed Z ∧ s = U ∩ Z /-- The interior of a set `s` is the largest open subset of `s`. -/ def interior (s : Set X) : Set X := ⋃₀ { t | IsOpen t ∧ t ⊆ s } /-- The closure of `s` is the smallest closed set containing `s`. -/ def closure (s : Set X) : Set X := ⋂₀ { t | IsClosed t ∧ s ⊆ t } /-- The frontier of a set is the set of points between the closure and interior. -/ def frontier (s : Set X) : Set X := closure s \ interior s /-- The coborder is defined as the complement of `closure s \ s`, or the union of `s` and the complement of `∂(s)`. This is the largest set in which `s` is closed, and `s` is locally closed if and only if `coborder s` is open. This is unnamed in the literature, and this name is due to the fact that `coborder s = (border sᶜ)ᶜ` where `border s = s \ interior s` is the border in the sense of Hausdorff. -/ def coborder (s : Set X) : Set X := (closure s \ s)ᶜ /-- A set is dense in a topological space if every point belongs to its closure. -/ def Dense (s : Set X) : Prop := ∀ x, x ∈ closure s /-- `f : α → X` has dense range if its range (image) is a dense subset of `X`. -/ def DenseRange {α : Type*} (f : α → X) := Dense (range f) /-- A function between topological spaces is continuous if the preimage of every open set is open. Registered as a structure to make sure it is not unfolded by Lean. -/ @[fun_prop] structure Continuous (f : X → Y) : Prop where /-- The preimage of an open set under a continuous function is an open set. Use `IsOpen.preimage` instead. -/ isOpen_preimage : ∀ s, IsOpen s → IsOpen (f ⁻¹' s) /-- A map `f : X → Y` is said to be an *open map*, if the image of any open `U : Set X` is open in `Y`. -/ def IsOpenMap (f : X → Y) : Prop := ∀ U : Set X, IsOpen U → IsOpen (f '' U) /-- A map `f : X → Y` is said to be a *closed map*, if the image of any closed `U : Set X` is closed in `Y`. -/ def IsClosedMap (f : X → Y) : Prop := ∀ U : Set X, IsClosed U → IsClosed (f '' U) end Defs /-! ### Notation for non-standard topologies -/ /-- Notation for `IsOpen` with respect to a non-standard topology. -/ scoped[Topology] notation (name := IsOpen_of) "IsOpen[" t "]" => @IsOpen _ t /-- Notation for `IsClosed` with respect to a non-standard topology. -/ scoped[Topology] notation (name := IsClosed_of) "IsClosed[" t "]" => @IsClosed _ t /-- Notation for `closure` with respect to a non-standard topology. -/ scoped[Topology] notation (name := closure_of) "closure[" t "]" => @closure _ t /-- Notation for `Continuous` with respect to a non-standard topologies. -/ scoped[Topology] notation (name := Continuous_of) "Continuous[" t₁ ", " t₂ "]" => @Continuous _ _ t₁ t₂ /-- The property `BaireSpace α` means that the topological space `α` has the Baire property: any countable intersection of open dense subsets is dense. Formulated here when the source space is ℕ. Use `dense_iInter_of_isOpen` which works for any countable index type instead. -/ class BaireSpace (X : Type*) [TopologicalSpace X] : Prop where baire_property : ∀ f : ℕ → Set X, (∀ n, IsOpen (f n)) → (∀ n, Dense (f n)) → Dense (⋂ n, f n)
Topology\Defs\Filter.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Jeremy Avigad -/ import Mathlib.Topology.Defs.Basic import Mathlib.Order.Filter.Ultrafilter import Mathlib.Data.Set.Lattice /-! # Definitions about filters in topological spaces In this file we define filters in topological spaces, as well as other definitions that rely on `Filter`s. ## Main Definitions ### Neighborhoods filter * `nhds x`: the filter of neighborhoods of a point in a topological space, denoted by `𝓝 x` in the `Topology` scope. A set is called a neighborhood of `x`, if it includes an open set around `x`. * `nhdsWithin x s`: the filter of neighborhoods of a point within a set, defined as `𝓝 x ⊓ 𝓟 s` and denoted by `𝓝[s] x`. We also introduce notation for some special sets `s`, see below. * `nhdsSet s`: the filter of neighborhoods of a set in a topological space, denoted by `𝓝ˢ s` in the `Topology` scope. A set `t` is called a neighborhood of `s`, if it includes an open set that includes `s`. ### Continuity at a point * `ContinuousAt f x`: a function `f` is continuous at a point `x`, if it tends to `𝓝 (f x)` along `𝓝 x`. * `ContinuousWithinAt f s x`: a function `f` is continuous within a set `s` at a point `x`, if it tends to `𝓝 (f x)` along `𝓝[s] x`. * `ContinuousOn f s`: a function `f : X → Y` is continuous on a set `s`, if it is continuous within `s` at every point of `s`. ### Limits * `lim f`: a limit of a filter `f` in a nonempty topological space. If there exists `x` such that `f ≤ 𝓝 x`, then `lim f` is one of such points, otherwise it is `Classical.choice _`. In a Hausdorff topological space, the limit is unique if it exists. * `Ultrafilter.lim f`: a limit of an ultrafilter `f`, defined as the limit of `(f : Filter X)` with a proof of `Nonempty X` deduced from existence of an ultrafilter on `X`. * `limUnder f g`: a limit of a filter `f` along a function `g`, defined as `lim (Filter.map g f)`. ### Cluster points and accumulation points * `ClusterPt x F`: a point `x` is a *cluster point* of a filter `F`, if `𝓝 x` is not disjoint with `F`. * `MapClusterPt x F u`: a point `x` is a *cluster point* of a function `u` along a filter `F`, if it is a cluster point of the filter `Filter.map u F`. * `AccPt x F`: a point `x` is an *accumulation point* of a filter `F`, if `𝓝[≠] x` is not disjoint with `F`. Every accumulation point of a filter is its cluster point, but not vice versa. * `IsCompact s`: a set `s` is compact if for every nontrivial filter `f` that contains `s`, there exists `a ∈ s` such that every set of `f` meets every neighborhood of `a`. Equivalently, a set `s` is compact if for any cover of `s` by open sets, there exists a finite subcover. * `CompactSpace`, `NoncompactSpace`: typeclasses saying that the whole space is a compact set / is not a compact set, respectively. * `WeaklyLocallyCompactSpace X`: typeclass saying that every point of `X` has a compact neighborhood. * `LocallyCompactSpace X`: typeclass saying that every point of `X` has a basis of compact neighborhoods. Every locally compact space is a weakly locally compact space. The reverse implication is true for R₁ (preregular) spaces. * `LocallyCompactPair X Y`: an auxiliary typeclass saying that for any continuous function `f : X → Y`, a point `x`, and a neighborhood `s` of `f x`, there exists a compact neighborhood `K` of `x` such that `f` maps `K` to `s`. * `Filter.cocompact`, `Filter.coclosedCompact`: filters generated by complements to compact and closed compact sets, respectively. ## Notations * `𝓝 x`: the filter `nhds x` of neighborhoods of a point `x`; * `𝓟 s`: the principal filter of a set `s`, defined elsewhere; * `𝓝[s] x`: the filter `nhdsWithin x s` of neighborhoods of a point `x` within a set `s`; * `𝓝[≤] x`: the filter `nhdsWithin x (Set.Iic x)` of left-neighborhoods of `x`; * `𝓝[≥] x`: the filter `nhdsWithin x (Set.Ici x)` of right-neighborhoods of `x`; * `𝓝[<] x`: the filter `nhdsWithin x (Set.Iio x)` of punctured left-neighborhoods of `x`; * `𝓝[>] x`: the filter `nhdsWithin x (Set.Ioi x)` of punctured right-neighborhoods of `x`; * `𝓝[≠] x`: the filter `nhdsWithin x {x}ᶜ` of punctured neighborhoods of `x`; * `𝓝ˢ s`: the filter `nhdsSet s` of neighborhoods of a set. -/ variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] open Filter open scoped Topology /-- A set is called a neighborhood of `x` if it contains an open set around `x`. The set of all neighborhoods of `x` forms a filter, the neighborhood filter at `x`, is here defined as the infimum over the principal filters of all open sets containing `x`. -/ irreducible_def nhds (x : X) : Filter X := ⨅ s ∈ { s : Set X | x ∈ s ∧ IsOpen s }, 𝓟 s @[inherit_doc] scoped[Topology] notation "𝓝" => nhds /-- The "neighborhood within" filter. Elements of `𝓝[s] x` are sets containing the intersection of `s` and a neighborhood of `x`. -/ def nhdsWithin (x : X) (s : Set X) : Filter X := 𝓝 x ⊓ 𝓟 s @[inherit_doc] scoped[Topology] notation "𝓝[" s "] " x:100 => nhdsWithin x s /-- Notation for the filter of punctured neighborhoods of a point. -/ scoped[Topology] notation3 "𝓝[≠] " x:100 => nhdsWithin x (@singleton _ (Set _) Set.instSingletonSet x)ᶜ /-- Notation for the filter of right neighborhoods of a point. -/ scoped[Topology] notation3 "𝓝[≥] " x:100 => nhdsWithin x (Set.Ici x) /-- Notation for the filter of left neighborhoods of a point. -/ scoped[Topology] notation3 "𝓝[≤] " x:100 => nhdsWithin x (Set.Iic x) /-- Notation for the filter of punctured right neighborhoods of a point. -/ scoped[Topology] notation3 "𝓝[>] " x:100 => nhdsWithin x (Set.Ioi x) /-- Notation for the filter of punctured left neighborhoods of a point. -/ scoped[Topology] notation3 "𝓝[<] " x:100 => nhdsWithin x (Set.Iio x) /-- The filter of neighborhoods of a set in a topological space. -/ def nhdsSet (s : Set X) : Filter X := sSup (nhds '' s) @[inherit_doc] scoped[Topology] notation "𝓝ˢ" => nhdsSet /-- A function between topological spaces is continuous at a point `x₀` if `f x` tends to `f x₀` when `x` tends to `x₀`. -/ @[fun_prop] def ContinuousAt (f : X → Y) (x : X) := Tendsto f (𝓝 x) (𝓝 (f x)) /-- A function between topological spaces is continuous at a point `x₀` within a subset `s` if `f x` tends to `f x₀` when `x` tends to `x₀` while staying within `s`. -/ @[fun_prop] def ContinuousWithinAt (f : X → Y) (s : Set X) (x : X) : Prop := Tendsto f (𝓝[s] x) (𝓝 (f x)) /-- A function between topological spaces is continuous on a subset `s` when it's continuous at every point of `s` within `s`. -/ @[fun_prop] def ContinuousOn (f : X → Y) (s : Set X) : Prop := ∀ x ∈ s, ContinuousWithinAt f s x /-- `x` specializes to `y` (notation: `x ⤳ y`) if either of the following equivalent properties hold: * `𝓝 x ≤ 𝓝 y`; this property is used as the definition; * `pure x ≤ 𝓝 y`; in other words, any neighbourhood of `y` contains `x`; * `y ∈ closure {x}`; * `closure {y} ⊆ closure {x}`; * for any closed set `s` we have `x ∈ s → y ∈ s`; * for any open set `s` we have `y ∈ s → x ∈ s`; * `y` is a cluster point of the filter `pure x = 𝓟 {x}`. This relation defines a `Preorder` on `X`. If `X` is a T₀ space, then this preorder is a partial order. If `X` is a T₁ space, then this partial order is trivial : `x ⤳ y ↔ x = y`. -/ def Specializes (x y : X) : Prop := 𝓝 x ≤ 𝓝 y @[inherit_doc] infixl:300 " ⤳ " => Specializes /-- Two points `x` and `y` in a topological space are `Inseparable` if any of the following equivalent properties hold: - `𝓝 x = 𝓝 y`; we use this property as the definition; - for any open set `s`, `x ∈ s ↔ y ∈ s`, see `inseparable_iff_open`; - for any closed set `s`, `x ∈ s ↔ y ∈ s`, see `inseparable_iff_closed`; - `x ∈ closure {y}` and `y ∈ closure {x}`, see `inseparable_iff_mem_closure`; - `closure {x} = closure {y}`, see `inseparable_iff_closure_eq`. -/ def Inseparable (x y : X) : Prop := 𝓝 x = 𝓝 y variable (X) /-- Specialization forms a preorder on the topological space. -/ def specializationPreorder : Preorder X := { Preorder.lift (OrderDual.toDual ∘ 𝓝) with le := fun x y => y ⤳ x lt := fun x y => y ⤳ x ∧ ¬x ⤳ y } /-- A `setoid` version of `Inseparable`, used to define the `SeparationQuotient`. -/ def inseparableSetoid : Setoid X := { Setoid.comap 𝓝 ⊥ with r := Inseparable } /-- The quotient of a topological space by its `inseparableSetoid`. This quotient is guaranteed to be a T₀ space. -/ def SeparationQuotient := Quotient (inseparableSetoid X) variable {X} section Lim /-- If `f` is a filter, then `Filter.lim f` is a limit of the filter, if it exists. -/ noncomputable def lim [Nonempty X] (f : Filter X) : X := Classical.epsilon fun x => f ≤ 𝓝 x /-- If `F` is an ultrafilter, then `Filter.Ultrafilter.lim F` is a limit of the filter, if it exists. Note that dot notation `F.lim` can be used for `F : Filter.Ultrafilter X`. -/ noncomputable nonrec def Ultrafilter.lim (F : Ultrafilter X) : X := @lim X _ (nonempty_of_neBot F) F /-- If `f` is a filter in `α` and `g : α → X` is a function, then `limUnder f g` is a limit of `g` at `f`, if it exists. -/ noncomputable def limUnder {α : Type*} [Nonempty X] (f : Filter α) (g : α → X) : X := lim (f.map g) end Lim /-- A point `x` is a cluster point of a filter `F` if `𝓝 x ⊓ F ≠ ⊥`. Also known as an accumulation point or a limit point, but beware that terminology varies. This is *not* the same as asking `𝓝[≠] x ⊓ F ≠ ⊥`, which is called `AccPt` in Mathlib. See `mem_closure_iff_clusterPt` in particular. -/ def ClusterPt (x : X) (F : Filter X) : Prop := NeBot (𝓝 x ⊓ F) /-- A point `x` is a cluster point of a sequence `u` along a filter `F` if it is a cluster point of `map u F`. -/ def MapClusterPt {ι : Type*} (x : X) (F : Filter ι) (u : ι → X) : Prop := ClusterPt x (map u F) /-- A point `x` is an accumulation point of a filter `F` if `𝓝[≠] x ⊓ F ≠ ⊥`. See also `ClusterPt`. -/ def AccPt (x : X) (F : Filter X) : Prop := NeBot (𝓝[≠] x ⊓ F) /-- A set `s` is compact if for every nontrivial filter `f` that contains `s`, there exists `a ∈ s` such that every set of `f` meets every neighborhood of `a`. -/ def IsCompact (s : Set X) := ∀ ⦃f⦄ [NeBot f], f ≤ 𝓟 s → ∃ x ∈ s, ClusterPt x f variable (X) in /-- Type class for compact spaces. Separation is sometimes included in the definition, especially in the French literature, but we do not include it here. -/ class CompactSpace : Prop where /-- In a compact space, `Set.univ` is a compact set. -/ isCompact_univ : IsCompact (Set.univ : Set X) variable (X) in /-- `X` is a noncompact topological space if it is not a compact space. -/ class NoncompactSpace : Prop where /-- In a noncompact space, `Set.univ` is not a compact set. -/ noncompact_univ : ¬IsCompact (Set.univ : Set X) /-- We say that a topological space is a *weakly locally compact space*, if each point of this space admits a compact neighborhood. -/ class WeaklyLocallyCompactSpace (X : Type*) [TopologicalSpace X] : Prop where /-- Every point of a weakly locally compact space admits a compact neighborhood. -/ exists_compact_mem_nhds (x : X) : ∃ s, IsCompact s ∧ s ∈ 𝓝 x export WeaklyLocallyCompactSpace (exists_compact_mem_nhds) /-- There are various definitions of "locally compact space" in the literature, which agree for Hausdorff spaces but not in general. This one is the precise condition on X needed for the evaluation map `C(X, Y) × X → Y` to be continuous for all `Y` when `C(X, Y)` is given the compact-open topology. See also `WeaklyLocallyCompactSpace`, a typeclass that only assumes that each point has a compact neighborhood. -/ class LocallyCompactSpace (X : Type*) [TopologicalSpace X] : Prop where /-- In a locally compact space, every neighbourhood of every point contains a compact neighbourhood of that same point. -/ local_compact_nhds : ∀ (x : X), ∀ n ∈ 𝓝 x, ∃ s ∈ 𝓝 x, s ⊆ n ∧ IsCompact s /-- We say that `X` and `Y` are a locally compact pair of topological spaces, if for any continuous map `f : X → Y`, a point `x : X`, and a neighbourhood `s ∈ 𝓝 (f x)`, there exists a compact neighbourhood `K ∈ 𝓝 x` such that `f` maps `K` to `s`. This is a technical assumption that appears in several theorems, most notably in `ContinuousMap.continuous_comp'` and `ContinuousMap.continuous_eval`. It is satisfied in two cases: - if `X` is a locally compact topological space, for obvious reasons; - if `X` is a weakly locally compact topological space and `Y` is an R₁ space; this fact is a simple generalization of the theorem saying that a weakly locally compact R₁ topological space is locally compact. -/ class LocallyCompactPair (X Y : Type*) [TopologicalSpace X] [TopologicalSpace Y] : Prop where /-- If `f : X → Y` is a continuous map in a locally compact pair of topological spaces and `s : Set Y` is a neighbourhood of `f x`, `x : X`, then there exists a compact neighbourhood `K` of `x` such that `f` maps `K` to `s`. -/ exists_mem_nhds_isCompact_mapsTo : ∀ {f : X → Y} {x : X} {s : Set Y}, Continuous f → s ∈ 𝓝 (f x) → ∃ K ∈ 𝓝 x, IsCompact K ∧ Set.MapsTo f K s export LocallyCompactPair (exists_mem_nhds_isCompact_mapsTo) variable (X) in /-- `Filter.cocompact` is the filter generated by complements to compact sets. -/ def Filter.cocompact : Filter X := ⨅ (s : Set X) (_ : IsCompact s), 𝓟 sᶜ variable (X) in /-- `Filter.coclosedCompact` is the filter generated by complements to closed compact sets. In a Hausdorff space, this is the same as `Filter.cocompact`. -/ def Filter.coclosedCompact : Filter X := ⨅ (s : Set X) (_ : IsClosed s) (_ : IsCompact s), 𝓟 sᶜ
Topology\Defs\Induced.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Jeremy Avigad -/ import Mathlib.Topology.Basic /-! # Induced and coinduced topologies In this file we define the induced and coinduced topologies, as well as topology inducing maps, topological embeddings, and quotient maps. ## Main definitions * `TopologicalSpace.induced`: given `f : X → Y` and a topology on `Y`, the induced topology on `X` is the collection of sets that are preimages of some open set in `Y`. This is the coarsest topology that makes `f` continuous. * `TopologicalSpace.coinduced`: given `f : X → Y` and a topology on `X`, the coinduced topology on `Y` is defined such that `s : Set Y` is open if the preimage of `s` is open. This is the finest topology that makes `f` continuous. * `Inducing`: a map `f : X → Y` is called *inducing*, if the topology on the domain is equal to the induced topology. * `Embedding`: a map `f : X → Y` is an *embedding*, if it is a topology inducing map and it is injective. * `OpenEmbedding`: a map `f : X → Y` is an *open embedding*, if it is an embedding and its range is open. An open embedding is an open map. * `ClosedEmbedding`: a map `f : X → Y` is an *open embedding*, if it is an embedding and its range is open. An open embedding is an open map. * `QuotientMap`: a map `f : X → Y` is a *quotient map*, if it is surjective and the topology on the codomain is equal to the coinduced topology. -/ open Set open scoped Topology namespace TopologicalSpace variable {X Y : Type*} /-- Given `f : X → Y` and a topology on `Y`, the induced topology on `X` is the collection of sets that are preimages of some open set in `Y`. This is the coarsest topology that makes `f` continuous. -/ def induced (f : X → Y) (t : TopologicalSpace Y) : TopologicalSpace X where IsOpen s := ∃ t, IsOpen t ∧ f ⁻¹' t = s isOpen_univ := ⟨univ, isOpen_univ, preimage_univ⟩ isOpen_inter := by rintro s₁ s₂ ⟨s'₁, hs₁, rfl⟩ ⟨s'₂, hs₂, rfl⟩ exact ⟨s'₁ ∩ s'₂, hs₁.inter hs₂, preimage_inter⟩ isOpen_sUnion S h := by choose! g hgo hfg using h refine ⟨⋃₀ (g '' S), isOpen_sUnion <| forall_mem_image.2 hgo, ?_⟩ rw [preimage_sUnion, biUnion_image, sUnion_eq_biUnion] exact iUnion₂_congr hfg instance _root_.instTopologicalSpaceSubtype {p : X → Prop} [t : TopologicalSpace X] : TopologicalSpace (Subtype p) := induced (↑) t /-- Given `f : X → Y` and a topology on `X`, the coinduced topology on `Y` is defined such that `s : Set Y` is open if the preimage of `s` is open. This is the finest topology that makes `f` continuous. -/ def coinduced (f : X → Y) (t : TopologicalSpace X) : TopologicalSpace Y where IsOpen s := IsOpen (f ⁻¹' s) isOpen_univ := t.isOpen_univ isOpen_inter s₁ s₂ h₁ h₂ := h₁.inter h₂ isOpen_sUnion s h := by simpa only [preimage_sUnion] using isOpen_biUnion h end TopologicalSpace variable {X Y : Type*} [tX : TopologicalSpace X] [tY : TopologicalSpace Y] /-- We say that restrictions of the topology on `X` to sets from a family `S` generates the original topology, if either of the following equivalent conditions hold: - a set which is relatively open in each `s ∈ S` is open; - a set which is relatively closed in each `s ∈ S` is closed; - for any topological space `Y`, a function `f : X → Y` is continuous provided that it is continuous on each `s ∈ S`. -/ structure RestrictGenTopology (S : Set (Set X)) : Prop where isOpen_of_forall_induced (u : Set X) : (∀ s ∈ S, IsOpen ((↑) ⁻¹' u : Set s)) → IsOpen u /-- A function `f : X → Y` between topological spaces is inducing if the topology on `X` is induced by the topology on `Y` through `f`, meaning that a set `s : Set X` is open iff it is the preimage under `f` of some open set `t : Set Y`. -/ @[mk_iff] structure Inducing (f : X → Y) : Prop where /-- The topology on the domain is equal to the induced topology. -/ induced : tX = tY.induced f /-- A function between topological spaces is an embedding if it is injective, and for all `s : Set X`, `s` is open iff it is the preimage of an open set. -/ @[mk_iff] structure Embedding [TopologicalSpace X] [TopologicalSpace Y] (f : X → Y) extends Inducing f : Prop where /-- A topological embedding is injective. -/ inj : Function.Injective f /-- An open embedding is an embedding with open range. -/ @[mk_iff] structure OpenEmbedding (f : X → Y) extends Embedding f : Prop where /-- The range of an open embedding is an open set. -/ isOpen_range : IsOpen <| range f /-- A closed embedding is an embedding with closed image. -/ @[mk_iff] structure ClosedEmbedding (f : X → Y) extends Embedding f : Prop where /-- The range of a closed embedding is a closed set. -/ isClosed_range : IsClosed <| range f /-- A function between topological spaces is a quotient map if it is surjective, and for all `s : Set Y`, `s` is open iff its preimage is an open set. -/ def QuotientMap {X : Type*} {Y : Type*} [tX : TopologicalSpace X] [tY : TopologicalSpace Y] (f : X → Y) : Prop := Function.Surjective f ∧ tY = tX.coinduced f
Topology\Defs\Sequences.lean
/- Copyright (c) 2018 Jan-David Salchow. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jan-David Salchow, Patrick Massot, Yury Kudryashov -/ import Mathlib.Topology.Defs.Filter /-! # Sequences in topological spaces In this file we define sequential closure, continuity, compactness etc. ## Main definitions ### Set operation * `seqClosure s`: sequential closure of a set, the set of limits of sequences of points of `s`; ### Predicates * `IsSeqClosed s`: predicate saying that a set is sequentially closed, i.e., `seqClosure s ⊆ s`; * `SeqContinuous f`: predicate saying that a function is sequentially continuous, i.e., for any sequence `u : ℕ → X` that converges to a point `x`, the sequence `f ∘ u` converges to `f x`; * `IsSeqCompact s`: predicate saying that a set is sequentially compact, i.e., every sequence taking values in `s` has a converging subsequence. ### Type classes * `FrechetUrysohnSpace X`: a typeclass saying that a topological space is a *Fréchet-Urysohn space*, i.e., the sequential closure of any set is equal to its closure. * `SequentialSpace X`: a typeclass saying that a topological space is a *sequential space*, i.e., any sequentially closed set in this space is closed. This condition is weaker than being a Fréchet-Urysohn space. * `SeqCompactSpace X`: a typeclass saying that a topological space is sequentially compact, i.e., every sequence in `X` has a converging subsequence. ## Tags sequentially closed, sequentially compact, sequential space -/ open Set Filter open scoped Topology variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] /-- The sequential closure of a set `s : Set X` in a topological space `X` is the set of all `a : X` which arise as limit of sequences in `s`. Note that the sequential closure of a set is not guaranteed to be sequentially closed. -/ def seqClosure (s : Set X) : Set X := { a | ∃ x : ℕ → X, (∀ n : ℕ, x n ∈ s) ∧ Tendsto x atTop (𝓝 a) } /-- A set `s` is sequentially closed if for any converging sequence `x n` of elements of `s`, the limit belongs to `s` as well. Note that the sequential closure of a set is not guaranteed to be sequentially closed. -/ def IsSeqClosed (s : Set X) : Prop := ∀ ⦃x : ℕ → X⦄ ⦃p : X⦄, (∀ n, x n ∈ s) → Tendsto x atTop (𝓝 p) → p ∈ s /-- A function between topological spaces is sequentially continuous if it commutes with limit of convergent sequences. -/ def SeqContinuous (f : X → Y) : Prop := ∀ ⦃x : ℕ → X⦄ ⦃p : X⦄, Tendsto x atTop (𝓝 p) → Tendsto (f ∘ x) atTop (𝓝 (f p)) /-- A set `s` is sequentially compact if every sequence taking values in `s` has a converging subsequence. -/ def IsSeqCompact (s : Set X) := ∀ ⦃x : ℕ → X⦄, (∀ n, x n ∈ s) → ∃ a ∈ s, ∃ φ : ℕ → ℕ, StrictMono φ ∧ Tendsto (x ∘ φ) atTop (𝓝 a) variable (X) /-- A space `X` is sequentially compact if every sequence in `X` has a converging subsequence. -/ @[mk_iff] class SeqCompactSpace : Prop where isSeqCompact_univ : IsSeqCompact (univ : Set X) export SeqCompactSpace (isSeqCompact_univ) @[deprecated (since := "2024-07-25")] alias seq_compact_univ := isSeqCompact_univ /-- A topological space is called a *Fréchet-Urysohn space*, if the sequential closure of any set is equal to its closure. Since one of the inclusions is trivial, we require only the non-trivial one in the definition. -/ class FrechetUrysohnSpace : Prop where closure_subset_seqClosure : ∀ s : Set X, closure s ⊆ seqClosure s /-- A topological space is said to be a *sequential space* if any sequentially closed set in this space is closed. This condition is weaker than being a Fréchet-Urysohn space. -/ class SequentialSpace : Prop where isClosed_of_seq : ∀ s : Set X, IsSeqClosed s → IsClosed s variable {X} /-- In a sequential space, a sequentially closed set is closed. -/ protected theorem IsSeqClosed.isClosed [SequentialSpace X] {s : Set X} (hs : IsSeqClosed s) : IsClosed s := SequentialSpace.isClosed_of_seq s hs
Topology\EMetricSpace\Basic.lean
/- Copyright (c) 2015, 2017 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Robert Y. Lewis, Johannes Hölzl, Mario Carneiro, Sébastien Gouëzel -/ import Mathlib.Data.ENNReal.Real import Mathlib.Order.Interval.Finset.Nat import Mathlib.Topology.UniformSpace.Pi import Mathlib.Topology.UniformSpace.UniformConvergence import Mathlib.Topology.UniformSpace.UniformEmbedding /-! # Extended metric spaces This file is devoted to the definition and study of `EMetricSpace`s, i.e., metric spaces in which the distance is allowed to take the value ∞. This extended distance is called `edist`, and takes values in `ℝ≥0∞`. Many definitions and theorems expected on emetric spaces are already introduced on uniform spaces and topological spaces. For example: open and closed sets, compactness, completeness, continuity and uniform continuity. The class `EMetricSpace` therefore extends `UniformSpace` (and `TopologicalSpace`). Since a lot of elementary properties don't require `eq_of_edist_eq_zero` we start setting up the theory of `PseudoEMetricSpace`, where we don't require `edist x y = 0 → x = y` and we specialize to `EMetricSpace` at the end. -/ open Set Filter Classical open scoped Uniformity Topology Filter NNReal ENNReal Pointwise universe u v w variable {α : Type u} {β : Type v} {X : Type*} /-- Characterizing uniformities associated to a (generalized) distance function `D` in terms of the elements of the uniformity. -/ theorem uniformity_dist_of_mem_uniformity [LinearOrder β] {U : Filter (α × α)} (z : β) (D : α → α → β) (H : ∀ s, s ∈ U ↔ ∃ ε > z, ∀ {a b : α}, D a b < ε → (a, b) ∈ s) : U = ⨅ ε > z, 𝓟 { p : α × α | D p.1 p.2 < ε } := HasBasis.eq_biInf ⟨fun s => by simp only [H, subset_def, Prod.forall, mem_setOf]⟩ /-- `EDist α` means that `α` is equipped with an extended distance. -/ @[ext] class EDist (α : Type*) where edist : α → α → ℝ≥0∞ export EDist (edist) /-- Creating a uniform space from an extended distance. -/ def uniformSpaceOfEDist (edist : α → α → ℝ≥0∞) (edist_self : ∀ x : α, edist x x = 0) (edist_comm : ∀ x y : α, edist x y = edist y x) (edist_triangle : ∀ x y z : α, edist x z ≤ edist x y + edist y z) : UniformSpace α := .ofFun edist edist_self edist_comm edist_triangle fun ε ε0 => ⟨ε / 2, ENNReal.half_pos ε0.ne', fun _ h₁ _ h₂ => (ENNReal.add_lt_add h₁ h₂).trans_eq (ENNReal.add_halves _)⟩ -- the uniform structure is embedded in the emetric space structure -- to avoid instance diamond issues. See Note [forgetful inheritance]. /-- Extended (pseudo) metric spaces, with an extended distance `edist` possibly taking the value ∞ Each pseudo_emetric space induces a canonical `UniformSpace` and hence a canonical `TopologicalSpace`. This is enforced in the type class definition, by extending the `UniformSpace` structure. When instantiating a `PseudoEMetricSpace` structure, the uniformity fields are not necessary, they will be filled in by default. There is a default value for the uniformity, that can be substituted in cases of interest, for instance when instantiating a `PseudoEMetricSpace` structure on a product. Continuity of `edist` is proved in `Topology.Instances.ENNReal` -/ class PseudoEMetricSpace (α : Type u) extends EDist α : Type u where edist_self : ∀ x : α, edist x x = 0 edist_comm : ∀ x y : α, edist x y = edist y x edist_triangle : ∀ x y z : α, edist x z ≤ edist x y + edist y z toUniformSpace : UniformSpace α := uniformSpaceOfEDist edist edist_self edist_comm edist_triangle uniformity_edist : 𝓤 α = ⨅ ε > 0, 𝓟 { p : α × α | edist p.1 p.2 < ε } := by rfl attribute [instance] PseudoEMetricSpace.toUniformSpace /- Pseudoemetric spaces are less common than metric spaces. Therefore, we work in a dedicated namespace, while notions associated to metric spaces are mostly in the root namespace. -/ /-- Two pseudo emetric space structures with the same edistance function coincide. -/ @[ext] protected theorem PseudoEMetricSpace.ext {α : Type*} {m m' : PseudoEMetricSpace α} (h : m.toEDist = m'.toEDist) : m = m' := by cases' m with ed _ _ _ U hU cases' m' with ed' _ _ _ U' hU' congr 1 exact UniformSpace.ext (((show ed = ed' from h) ▸ hU).trans hU'.symm) variable [PseudoEMetricSpace α] export PseudoEMetricSpace (edist_self edist_comm edist_triangle) attribute [simp] edist_self /-- Triangle inequality for the extended distance -/ theorem edist_triangle_left (x y z : α) : edist x y ≤ edist z x + edist z y := by rw [edist_comm z]; apply edist_triangle theorem edist_triangle_right (x y z : α) : edist x y ≤ edist x z + edist y z := by rw [edist_comm y]; apply edist_triangle theorem edist_congr_right {x y z : α} (h : edist x y = 0) : edist x z = edist y z := by apply le_antisymm · rw [← zero_add (edist y z), ← h] apply edist_triangle · rw [edist_comm] at h rw [← zero_add (edist x z), ← h] apply edist_triangle theorem edist_congr_left {x y z : α} (h : edist x y = 0) : edist z x = edist z y := by rw [edist_comm z x, edist_comm z y] apply edist_congr_right h -- new theorem theorem edist_congr {w x y z : α} (hl : edist w x = 0) (hr : edist y z = 0) : edist w y = edist x z := (edist_congr_right hl).trans (edist_congr_left hr) theorem edist_triangle4 (x y z t : α) : edist x t ≤ edist x y + edist y z + edist z t := calc edist x t ≤ edist x z + edist z t := edist_triangle x z t _ ≤ edist x y + edist y z + edist z t := add_le_add_right (edist_triangle x y z) _ /-- The triangle (polygon) inequality for sequences of points; `Finset.Ico` version. -/ theorem edist_le_Ico_sum_edist (f : ℕ → α) {m n} (h : m ≤ n) : edist (f m) (f n) ≤ ∑ i ∈ Finset.Ico m n, edist (f i) (f (i + 1)) := by induction n, h using Nat.le_induction with | base => rw [Finset.Ico_self, Finset.sum_empty, edist_self] | succ n hle ihn => calc edist (f m) (f (n + 1)) ≤ edist (f m) (f n) + edist (f n) (f (n + 1)) := edist_triangle _ _ _ _ ≤ (∑ i ∈ Finset.Ico m n, _) + _ := add_le_add ihn le_rfl _ = ∑ i ∈ Finset.Ico m (n + 1), _ := by { rw [Nat.Ico_succ_right_eq_insert_Ico hle, Finset.sum_insert, add_comm]; simp } /-- The triangle (polygon) inequality for sequences of points; `Finset.range` version. -/ theorem edist_le_range_sum_edist (f : ℕ → α) (n : ℕ) : edist (f 0) (f n) ≤ ∑ i ∈ Finset.range n, edist (f i) (f (i + 1)) := Nat.Ico_zero_eq_range ▸ edist_le_Ico_sum_edist f (Nat.zero_le n) /-- A version of `edist_le_Ico_sum_edist` with each intermediate distance replaced with an upper estimate. -/ theorem edist_le_Ico_sum_of_edist_le {f : ℕ → α} {m n} (hmn : m ≤ n) {d : ℕ → ℝ≥0∞} (hd : ∀ {k}, m ≤ k → k < n → edist (f k) (f (k + 1)) ≤ d k) : edist (f m) (f n) ≤ ∑ i ∈ Finset.Ico m n, d i := le_trans (edist_le_Ico_sum_edist f hmn) <| Finset.sum_le_sum fun _k hk => hd (Finset.mem_Ico.1 hk).1 (Finset.mem_Ico.1 hk).2 /-- A version of `edist_le_range_sum_edist` with each intermediate distance replaced with an upper estimate. -/ theorem edist_le_range_sum_of_edist_le {f : ℕ → α} (n : ℕ) {d : ℕ → ℝ≥0∞} (hd : ∀ {k}, k < n → edist (f k) (f (k + 1)) ≤ d k) : edist (f 0) (f n) ≤ ∑ i ∈ Finset.range n, d i := Nat.Ico_zero_eq_range ▸ edist_le_Ico_sum_of_edist_le (zero_le n) fun _ => hd /-- Reformulation of the uniform structure in terms of the extended distance -/ theorem uniformity_pseudoedist : 𝓤 α = ⨅ ε > 0, 𝓟 { p : α × α | edist p.1 p.2 < ε } := PseudoEMetricSpace.uniformity_edist theorem uniformSpace_edist : ‹PseudoEMetricSpace α›.toUniformSpace = uniformSpaceOfEDist edist edist_self edist_comm edist_triangle := UniformSpace.ext uniformity_pseudoedist theorem uniformity_basis_edist : (𝓤 α).HasBasis (fun ε : ℝ≥0∞ => 0 < ε) fun ε => { p : α × α | edist p.1 p.2 < ε } := (@uniformSpace_edist α _).symm ▸ UniformSpace.hasBasis_ofFun ⟨1, one_pos⟩ _ _ _ _ _ /-- Characterization of the elements of the uniformity in terms of the extended distance -/ theorem mem_uniformity_edist {s : Set (α × α)} : s ∈ 𝓤 α ↔ ∃ ε > 0, ∀ {a b : α}, edist a b < ε → (a, b) ∈ s := uniformity_basis_edist.mem_uniformity_iff /-- Given `f : β → ℝ≥0∞`, if `f` sends `{i | p i}` to a set of positive numbers accumulating to zero, then `f i`-neighborhoods of the diagonal form a basis of `𝓤 α`. For specific bases see `uniformity_basis_edist`, `uniformity_basis_edist'`, `uniformity_basis_edist_nnreal`, and `uniformity_basis_edist_inv_nat`. -/ protected theorem EMetric.mk_uniformity_basis {β : Type*} {p : β → Prop} {f : β → ℝ≥0∞} (hf₀ : ∀ x, p x → 0 < f x) (hf : ∀ ε, 0 < ε → ∃ x, p x ∧ f x ≤ ε) : (𝓤 α).HasBasis p fun x => { p : α × α | edist p.1 p.2 < f x } := by refine ⟨fun s => uniformity_basis_edist.mem_iff.trans ?_⟩ constructor · rintro ⟨ε, ε₀, hε⟩ rcases hf ε ε₀ with ⟨i, hi, H⟩ exact ⟨i, hi, fun x hx => hε <| lt_of_lt_of_le hx.out H⟩ · exact fun ⟨i, hi, H⟩ => ⟨f i, hf₀ i hi, H⟩ /-- Given `f : β → ℝ≥0∞`, if `f` sends `{i | p i}` to a set of positive numbers accumulating to zero, then closed `f i`-neighborhoods of the diagonal form a basis of `𝓤 α`. For specific bases see `uniformity_basis_edist_le` and `uniformity_basis_edist_le'`. -/ protected theorem EMetric.mk_uniformity_basis_le {β : Type*} {p : β → Prop} {f : β → ℝ≥0∞} (hf₀ : ∀ x, p x → 0 < f x) (hf : ∀ ε, 0 < ε → ∃ x, p x ∧ f x ≤ ε) : (𝓤 α).HasBasis p fun x => { p : α × α | edist p.1 p.2 ≤ f x } := by refine ⟨fun s => uniformity_basis_edist.mem_iff.trans ?_⟩ constructor · rintro ⟨ε, ε₀, hε⟩ rcases exists_between ε₀ with ⟨ε', hε'⟩ rcases hf ε' hε'.1 with ⟨i, hi, H⟩ exact ⟨i, hi, fun x hx => hε <| lt_of_le_of_lt (le_trans hx.out H) hε'.2⟩ · exact fun ⟨i, hi, H⟩ => ⟨f i, hf₀ i hi, fun x hx => H (le_of_lt hx.out)⟩ theorem uniformity_basis_edist_le : (𝓤 α).HasBasis (fun ε : ℝ≥0∞ => 0 < ε) fun ε => { p : α × α | edist p.1 p.2 ≤ ε } := EMetric.mk_uniformity_basis_le (fun _ => id) fun ε ε₀ => ⟨ε, ε₀, le_refl ε⟩ theorem uniformity_basis_edist' (ε' : ℝ≥0∞) (hε' : 0 < ε') : (𝓤 α).HasBasis (fun ε : ℝ≥0∞ => ε ∈ Ioo 0 ε') fun ε => { p : α × α | edist p.1 p.2 < ε } := EMetric.mk_uniformity_basis (fun _ => And.left) fun ε ε₀ => let ⟨δ, hδ⟩ := exists_between hε' ⟨min ε δ, ⟨lt_min ε₀ hδ.1, lt_of_le_of_lt (min_le_right _ _) hδ.2⟩, min_le_left _ _⟩ theorem uniformity_basis_edist_le' (ε' : ℝ≥0∞) (hε' : 0 < ε') : (𝓤 α).HasBasis (fun ε : ℝ≥0∞ => ε ∈ Ioo 0 ε') fun ε => { p : α × α | edist p.1 p.2 ≤ ε } := EMetric.mk_uniformity_basis_le (fun _ => And.left) fun ε ε₀ => let ⟨δ, hδ⟩ := exists_between hε' ⟨min ε δ, ⟨lt_min ε₀ hδ.1, lt_of_le_of_lt (min_le_right _ _) hδ.2⟩, min_le_left _ _⟩ theorem uniformity_basis_edist_nnreal : (𝓤 α).HasBasis (fun ε : ℝ≥0 => 0 < ε) fun ε => { p : α × α | edist p.1 p.2 < ε } := EMetric.mk_uniformity_basis (fun _ => ENNReal.coe_pos.2) fun _ε ε₀ => let ⟨δ, hδ⟩ := ENNReal.lt_iff_exists_nnreal_btwn.1 ε₀ ⟨δ, ENNReal.coe_pos.1 hδ.1, le_of_lt hδ.2⟩ theorem uniformity_basis_edist_nnreal_le : (𝓤 α).HasBasis (fun ε : ℝ≥0 => 0 < ε) fun ε => { p : α × α | edist p.1 p.2 ≤ ε } := EMetric.mk_uniformity_basis_le (fun _ => ENNReal.coe_pos.2) fun _ε ε₀ => let ⟨δ, hδ⟩ := ENNReal.lt_iff_exists_nnreal_btwn.1 ε₀ ⟨δ, ENNReal.coe_pos.1 hδ.1, le_of_lt hδ.2⟩ theorem uniformity_basis_edist_inv_nat : (𝓤 α).HasBasis (fun _ => True) fun n : ℕ => { p : α × α | edist p.1 p.2 < (↑n)⁻¹ } := EMetric.mk_uniformity_basis (fun n _ ↦ ENNReal.inv_pos.2 <| ENNReal.natCast_ne_top n) fun _ε ε₀ ↦ let ⟨n, hn⟩ := ENNReal.exists_inv_nat_lt (ne_of_gt ε₀) ⟨n, trivial, le_of_lt hn⟩ theorem uniformity_basis_edist_inv_two_pow : (𝓤 α).HasBasis (fun _ => True) fun n : ℕ => { p : α × α | edist p.1 p.2 < 2⁻¹ ^ n } := EMetric.mk_uniformity_basis (fun _ _ => ENNReal.pow_pos (ENNReal.inv_pos.2 ENNReal.two_ne_top) _) fun _ε ε₀ => let ⟨n, hn⟩ := ENNReal.exists_inv_two_pow_lt (ne_of_gt ε₀) ⟨n, trivial, le_of_lt hn⟩ /-- Fixed size neighborhoods of the diagonal belong to the uniform structure -/ theorem edist_mem_uniformity {ε : ℝ≥0∞} (ε0 : 0 < ε) : { p : α × α | edist p.1 p.2 < ε } ∈ 𝓤 α := mem_uniformity_edist.2 ⟨ε, ε0, id⟩ namespace EMetric instance (priority := 900) instIsCountablyGeneratedUniformity : IsCountablyGenerated (𝓤 α) := isCountablyGenerated_of_seq ⟨_, uniformity_basis_edist_inv_nat.eq_iInf⟩ -- Porting note: changed explicit/implicit /-- ε-δ characterization of uniform continuity on a set for pseudoemetric spaces -/ theorem uniformContinuousOn_iff [PseudoEMetricSpace β] {f : α → β} {s : Set α} : UniformContinuousOn f s ↔ ∀ ε > 0, ∃ δ > 0, ∀ {a}, a ∈ s → ∀ {b}, b ∈ s → edist a b < δ → edist (f a) (f b) < ε := uniformity_basis_edist.uniformContinuousOn_iff uniformity_basis_edist /-- ε-δ characterization of uniform continuity on pseudoemetric spaces -/ theorem uniformContinuous_iff [PseudoEMetricSpace β] {f : α → β} : UniformContinuous f ↔ ∀ ε > 0, ∃ δ > 0, ∀ {a b : α}, edist a b < δ → edist (f a) (f b) < ε := uniformity_basis_edist.uniformContinuous_iff uniformity_basis_edist theorem uniformInducing_iff [PseudoEMetricSpace β] {f : α → β} : UniformInducing f ↔ UniformContinuous f ∧ ∀ δ > 0, ∃ ε > 0, ∀ {a b : α}, edist (f a) (f b) < ε → edist a b < δ := uniformInducing_iff'.trans <| Iff.rfl.and <| ((uniformity_basis_edist.comap _).le_basis_iff uniformity_basis_edist).trans <| by simp only [subset_def, Prod.forall]; rfl /-- ε-δ characterization of uniform embeddings on pseudoemetric spaces -/ nonrec theorem uniformEmbedding_iff [PseudoEMetricSpace β] {f : α → β} : UniformEmbedding f ↔ Function.Injective f ∧ UniformContinuous f ∧ ∀ δ > 0, ∃ ε > 0, ∀ {a b : α}, edist (f a) (f b) < ε → edist a b < δ := (uniformEmbedding_iff _).trans <| and_comm.trans <| Iff.rfl.and uniformInducing_iff /-- If a map between pseudoemetric spaces is a uniform embedding then the edistance between `f x` and `f y` is controlled in terms of the distance between `x` and `y`. In fact, this lemma holds for a `UniformInducing` map. TODO: generalize? -/ theorem controlled_of_uniformEmbedding [PseudoEMetricSpace β] {f : α → β} (h : UniformEmbedding f) : (∀ ε > 0, ∃ δ > 0, ∀ {a b : α}, edist a b < δ → edist (f a) (f b) < ε) ∧ ∀ δ > 0, ∃ ε > 0, ∀ {a b : α}, edist (f a) (f b) < ε → edist a b < δ := ⟨uniformContinuous_iff.1 h.uniformContinuous, (uniformEmbedding_iff.1 h).2.2⟩ /-- ε-δ characterization of Cauchy sequences on pseudoemetric spaces -/ protected theorem cauchy_iff {f : Filter α} : Cauchy f ↔ f ≠ ⊥ ∧ ∀ ε > 0, ∃ t ∈ f, ∀ x, x ∈ t → ∀ y, y ∈ t → edist x y < ε := by rw [← neBot_iff]; exact uniformity_basis_edist.cauchy_iff /-- A very useful criterion to show that a space is complete is to show that all sequences which satisfy a bound of the form `edist (u n) (u m) < B N` for all `n m ≥ N` are converging. This is often applied for `B N = 2^{-N}`, i.e., with a very fast convergence to `0`, which makes it possible to use arguments of converging series, while this is impossible to do in general for arbitrary Cauchy sequences. -/ theorem complete_of_convergent_controlled_sequences (B : ℕ → ℝ≥0∞) (hB : ∀ n, 0 < B n) (H : ∀ u : ℕ → α, (∀ N n m : ℕ, N ≤ n → N ≤ m → edist (u n) (u m) < B N) → ∃ x, Tendsto u atTop (𝓝 x)) : CompleteSpace α := UniformSpace.complete_of_convergent_controlled_sequences (fun n => { p : α × α | edist p.1 p.2 < B n }) (fun n => edist_mem_uniformity <| hB n) H /-- A sequentially complete pseudoemetric space is complete. -/ theorem complete_of_cauchySeq_tendsto : (∀ u : ℕ → α, CauchySeq u → ∃ a, Tendsto u atTop (𝓝 a)) → CompleteSpace α := UniformSpace.complete_of_cauchySeq_tendsto /-- Expressing locally uniform convergence on a set using `edist`. -/ theorem tendstoLocallyUniformlyOn_iff {ι : Type*} [TopologicalSpace β] {F : ι → β → α} {f : β → α} {p : Filter ι} {s : Set β} : TendstoLocallyUniformlyOn F f p s ↔ ∀ ε > 0, ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, ∀ᶠ n in p, ∀ y ∈ t, edist (f y) (F n y) < ε := by refine ⟨fun H ε hε => H _ (edist_mem_uniformity hε), fun H u hu x hx => ?_⟩ rcases mem_uniformity_edist.1 hu with ⟨ε, εpos, hε⟩ rcases H ε εpos x hx with ⟨t, ht, Ht⟩ exact ⟨t, ht, Ht.mono fun n hs x hx => hε (hs x hx)⟩ /-- Expressing uniform convergence on a set using `edist`. -/ theorem tendstoUniformlyOn_iff {ι : Type*} {F : ι → β → α} {f : β → α} {p : Filter ι} {s : Set β} : TendstoUniformlyOn F f p s ↔ ∀ ε > 0, ∀ᶠ n in p, ∀ x ∈ s, edist (f x) (F n x) < ε := by refine ⟨fun H ε hε => H _ (edist_mem_uniformity hε), fun H u hu => ?_⟩ rcases mem_uniformity_edist.1 hu with ⟨ε, εpos, hε⟩ exact (H ε εpos).mono fun n hs x hx => hε (hs x hx) /-- Expressing locally uniform convergence using `edist`. -/ theorem tendstoLocallyUniformly_iff {ι : Type*} [TopologicalSpace β] {F : ι → β → α} {f : β → α} {p : Filter ι} : TendstoLocallyUniformly F f p ↔ ∀ ε > 0, ∀ x : β, ∃ t ∈ 𝓝 x, ∀ᶠ n in p, ∀ y ∈ t, edist (f y) (F n y) < ε := by simp only [← tendstoLocallyUniformlyOn_univ, tendstoLocallyUniformlyOn_iff, mem_univ, forall_const, exists_prop, nhdsWithin_univ] /-- Expressing uniform convergence using `edist`. -/ theorem tendstoUniformly_iff {ι : Type*} {F : ι → β → α} {f : β → α} {p : Filter ι} : TendstoUniformly F f p ↔ ∀ ε > 0, ∀ᶠ n in p, ∀ x, edist (f x) (F n x) < ε := by simp only [← tendstoUniformlyOn_univ, tendstoUniformlyOn_iff, mem_univ, forall_const] end EMetric open EMetric /-- Auxiliary function to replace the uniformity on a pseudoemetric space with a uniformity which is equal to the original one, but maybe not defeq. This is useful if one wants to construct a pseudoemetric space with a specified uniformity. See Note [forgetful inheritance] explaining why having definitionally the right uniformity is often important. -/ def PseudoEMetricSpace.replaceUniformity {α} [U : UniformSpace α] (m : PseudoEMetricSpace α) (H : 𝓤[U] = 𝓤[PseudoEMetricSpace.toUniformSpace]) : PseudoEMetricSpace α where edist := @edist _ m.toEDist edist_self := edist_self edist_comm := edist_comm edist_triangle := edist_triangle toUniformSpace := U uniformity_edist := H.trans (@PseudoEMetricSpace.uniformity_edist α _) /-- The extended pseudometric induced by a function taking values in a pseudoemetric space. -/ def PseudoEMetricSpace.induced {α β} (f : α → β) (m : PseudoEMetricSpace β) : PseudoEMetricSpace α where edist x y := edist (f x) (f y) edist_self _ := edist_self _ edist_comm _ _ := edist_comm _ _ edist_triangle _ _ _ := edist_triangle _ _ _ toUniformSpace := UniformSpace.comap f m.toUniformSpace uniformity_edist := (uniformity_basis_edist.comap (Prod.map f f)).eq_biInf /-- Pseudoemetric space instance on subsets of pseudoemetric spaces -/ instance {α : Type*} {p : α → Prop} [PseudoEMetricSpace α] : PseudoEMetricSpace (Subtype p) := PseudoEMetricSpace.induced Subtype.val ‹_› /-- The extended pseudodistance on a subset of a pseudoemetric space is the restriction of the original pseudodistance, by definition -/ theorem Subtype.edist_eq {p : α → Prop} (x y : Subtype p) : edist x y = edist (x : α) y := rfl namespace MulOpposite /-- Pseudoemetric space instance on the multiplicative opposite of a pseudoemetric space. -/ @[to_additive "Pseudoemetric space instance on the additive opposite of a pseudoemetric space."] instance {α : Type*} [PseudoEMetricSpace α] : PseudoEMetricSpace αᵐᵒᵖ := PseudoEMetricSpace.induced unop ‹_› @[to_additive] theorem edist_unop (x y : αᵐᵒᵖ) : edist (unop x) (unop y) = edist x y := rfl @[to_additive] theorem edist_op (x y : α) : edist (op x) (op y) = edist x y := rfl end MulOpposite section ULift instance : PseudoEMetricSpace (ULift α) := PseudoEMetricSpace.induced ULift.down ‹_› theorem ULift.edist_eq (x y : ULift α) : edist x y = edist x.down y.down := rfl @[simp] theorem ULift.edist_up_up (x y : α) : edist (ULift.up x) (ULift.up y) = edist x y := rfl end ULift /-- The product of two pseudoemetric spaces, with the max distance, is an extended pseudometric spaces. We make sure that the uniform structure thus constructed is the one corresponding to the product of uniform spaces, to avoid diamond problems. -/ instance Prod.pseudoEMetricSpaceMax [PseudoEMetricSpace β] : PseudoEMetricSpace (α × β) where edist x y := edist x.1 y.1 ⊔ edist x.2 y.2 edist_self x := by simp edist_comm x y := by simp [edist_comm] edist_triangle x y z := max_le (le_trans (edist_triangle _ _ _) (add_le_add (le_max_left _ _) (le_max_left _ _))) (le_trans (edist_triangle _ _ _) (add_le_add (le_max_right _ _) (le_max_right _ _))) uniformity_edist := uniformity_prod.trans <| by simp [PseudoEMetricSpace.uniformity_edist, ← iInf_inf_eq, setOf_and] toUniformSpace := inferInstance theorem Prod.edist_eq [PseudoEMetricSpace β] (x y : α × β) : edist x y = max (edist x.1 y.1) (edist x.2 y.2) := rfl section Pi open Finset variable {π : β → Type*} [Fintype β] -- Porting note: reordered instances instance [∀ b, EDist (π b)] : EDist (∀ b, π b) where edist f g := Finset.sup univ fun b => edist (f b) (g b) theorem edist_pi_def [∀ b, EDist (π b)] (f g : ∀ b, π b) : edist f g = Finset.sup univ fun b => edist (f b) (g b) := rfl theorem edist_le_pi_edist [∀ b, EDist (π b)] (f g : ∀ b, π b) (b : β) : edist (f b) (g b) ≤ edist f g := le_sup (f := fun b => edist (f b) (g b)) (Finset.mem_univ b) theorem edist_pi_le_iff [∀ b, EDist (π b)] {f g : ∀ b, π b} {d : ℝ≥0∞} : edist f g ≤ d ↔ ∀ b, edist (f b) (g b) ≤ d := Finset.sup_le_iff.trans <| by simp only [Finset.mem_univ, forall_const] theorem edist_pi_const_le (a b : α) : (edist (fun _ : β => a) fun _ => b) ≤ edist a b := edist_pi_le_iff.2 fun _ => le_rfl @[simp] theorem edist_pi_const [Nonempty β] (a b : α) : (edist (fun _ : β => a) fun _ => b) = edist a b := Finset.sup_const univ_nonempty (edist a b) /-- The product of a finite number of pseudoemetric spaces, with the max distance, is still a pseudoemetric space. This construction would also work for infinite products, but it would not give rise to the product topology. Hence, we only formalize it in the good situation of finitely many spaces. -/ instance pseudoEMetricSpacePi [∀ b, PseudoEMetricSpace (π b)] : PseudoEMetricSpace (∀ b, π b) where edist_self f := bot_unique <| Finset.sup_le <| by simp edist_comm f g := by simp [edist_pi_def, edist_comm] edist_triangle f g h := edist_pi_le_iff.2 fun b => le_trans (edist_triangle _ (g b) _) (add_le_add (edist_le_pi_edist _ _ _) (edist_le_pi_edist _ _ _)) toUniformSpace := Pi.uniformSpace _ uniformity_edist := by simp only [Pi.uniformity, PseudoEMetricSpace.uniformity_edist, comap_iInf, gt_iff_lt, preimage_setOf_eq, comap_principal, edist_pi_def] rw [iInf_comm]; congr; funext ε rw [iInf_comm]; congr; funext εpos simp [setOf_forall, εpos] end Pi namespace EMetric variable {x y z : α} {ε ε₁ ε₂ : ℝ≥0∞} {s t : Set α} /-- `EMetric.ball x ε` is the set of all points `y` with `edist y x < ε` -/ def ball (x : α) (ε : ℝ≥0∞) : Set α := { y | edist y x < ε } @[simp] theorem mem_ball : y ∈ ball x ε ↔ edist y x < ε := Iff.rfl theorem mem_ball' : y ∈ ball x ε ↔ edist x y < ε := by rw [edist_comm, mem_ball] /-- `EMetric.closedBall x ε` is the set of all points `y` with `edist y x ≤ ε` -/ def closedBall (x : α) (ε : ℝ≥0∞) := { y | edist y x ≤ ε } @[simp] theorem mem_closedBall : y ∈ closedBall x ε ↔ edist y x ≤ ε := Iff.rfl theorem mem_closedBall' : y ∈ closedBall x ε ↔ edist x y ≤ ε := by rw [edist_comm, mem_closedBall] @[simp] theorem closedBall_top (x : α) : closedBall x ∞ = univ := eq_univ_of_forall fun _ => mem_setOf.2 le_top theorem ball_subset_closedBall : ball x ε ⊆ closedBall x ε := fun _ h => le_of_lt h.out theorem pos_of_mem_ball (hy : y ∈ ball x ε) : 0 < ε := lt_of_le_of_lt (zero_le _) hy theorem mem_ball_self (h : 0 < ε) : x ∈ ball x ε := by rwa [mem_ball, edist_self] theorem mem_closedBall_self : x ∈ closedBall x ε := by rw [mem_closedBall, edist_self]; apply zero_le theorem mem_ball_comm : x ∈ ball y ε ↔ y ∈ ball x ε := by rw [mem_ball', mem_ball] theorem mem_closedBall_comm : x ∈ closedBall y ε ↔ y ∈ closedBall x ε := by rw [mem_closedBall', mem_closedBall] @[gcongr] theorem ball_subset_ball (h : ε₁ ≤ ε₂) : ball x ε₁ ⊆ ball x ε₂ := fun _y (yx : _ < ε₁) => lt_of_lt_of_le yx h @[gcongr] theorem closedBall_subset_closedBall (h : ε₁ ≤ ε₂) : closedBall x ε₁ ⊆ closedBall x ε₂ := fun _y (yx : _ ≤ ε₁) => le_trans yx h theorem ball_disjoint (h : ε₁ + ε₂ ≤ edist x y) : Disjoint (ball x ε₁) (ball y ε₂) := Set.disjoint_left.mpr fun z h₁ h₂ => (edist_triangle_left x y z).not_lt <| (ENNReal.add_lt_add h₁ h₂).trans_le h theorem ball_subset (h : edist x y + ε₁ ≤ ε₂) (h' : edist x y ≠ ∞) : ball x ε₁ ⊆ ball y ε₂ := fun z zx => calc edist z y ≤ edist z x + edist x y := edist_triangle _ _ _ _ = edist x y + edist z x := add_comm _ _ _ < edist x y + ε₁ := ENNReal.add_lt_add_left h' zx _ ≤ ε₂ := h theorem exists_ball_subset_ball (h : y ∈ ball x ε) : ∃ ε' > 0, ball y ε' ⊆ ball x ε := by have : 0 < ε - edist y x := by simpa using h refine ⟨ε - edist y x, this, ball_subset ?_ (ne_top_of_lt h)⟩ exact (add_tsub_cancel_of_le (mem_ball.mp h).le).le theorem ball_eq_empty_iff : ball x ε = ∅ ↔ ε = 0 := eq_empty_iff_forall_not_mem.trans ⟨fun h => le_bot_iff.1 (le_of_not_gt fun ε0 => h _ (mem_ball_self ε0)), fun ε0 _ h => not_lt_of_le (le_of_eq ε0) (pos_of_mem_ball h)⟩ theorem ordConnected_setOf_closedBall_subset (x : α) (s : Set α) : OrdConnected { r | closedBall x r ⊆ s } := ⟨fun _ _ _ h₁ _ h₂ => (closedBall_subset_closedBall h₂.2).trans h₁⟩ theorem ordConnected_setOf_ball_subset (x : α) (s : Set α) : OrdConnected { r | ball x r ⊆ s } := ⟨fun _ _ _ h₁ _ h₂ => (ball_subset_ball h₂.2).trans h₁⟩ /-- Relation “two points are at a finite edistance” is an equivalence relation. -/ def edistLtTopSetoid : Setoid α where r x y := edist x y < ⊤ iseqv := ⟨fun x => by rw [edist_self]; exact ENNReal.coe_lt_top, fun h => by rwa [edist_comm], fun hxy hyz => lt_of_le_of_lt (edist_triangle _ _ _) (ENNReal.add_lt_top.2 ⟨hxy, hyz⟩)⟩ @[simp] theorem ball_zero : ball x 0 = ∅ := by rw [EMetric.ball_eq_empty_iff] theorem nhds_basis_eball : (𝓝 x).HasBasis (fun ε : ℝ≥0∞ => 0 < ε) (ball x) := nhds_basis_uniformity uniformity_basis_edist theorem nhdsWithin_basis_eball : (𝓝[s] x).HasBasis (fun ε : ℝ≥0∞ => 0 < ε) fun ε => ball x ε ∩ s := nhdsWithin_hasBasis nhds_basis_eball s theorem nhds_basis_closed_eball : (𝓝 x).HasBasis (fun ε : ℝ≥0∞ => 0 < ε) (closedBall x) := nhds_basis_uniformity uniformity_basis_edist_le theorem nhdsWithin_basis_closed_eball : (𝓝[s] x).HasBasis (fun ε : ℝ≥0∞ => 0 < ε) fun ε => closedBall x ε ∩ s := nhdsWithin_hasBasis nhds_basis_closed_eball s theorem nhds_eq : 𝓝 x = ⨅ ε > 0, 𝓟 (ball x ε) := nhds_basis_eball.eq_biInf theorem mem_nhds_iff : s ∈ 𝓝 x ↔ ∃ ε > 0, ball x ε ⊆ s := nhds_basis_eball.mem_iff theorem mem_nhdsWithin_iff : s ∈ 𝓝[t] x ↔ ∃ ε > 0, ball x ε ∩ t ⊆ s := nhdsWithin_basis_eball.mem_iff section variable [PseudoEMetricSpace β] {f : α → β} theorem tendsto_nhdsWithin_nhdsWithin {t : Set β} {a b} : Tendsto f (𝓝[s] a) (𝓝[t] b) ↔ ∀ ε > 0, ∃ δ > 0, ∀ ⦃x⦄, x ∈ s → edist x a < δ → f x ∈ t ∧ edist (f x) b < ε := (nhdsWithin_basis_eball.tendsto_iff nhdsWithin_basis_eball).trans <| forall₂_congr fun ε _ => exists_congr fun δ => and_congr_right fun _ => forall_congr' fun x => by simp; tauto theorem tendsto_nhdsWithin_nhds {a b} : Tendsto f (𝓝[s] a) (𝓝 b) ↔ ∀ ε > 0, ∃ δ > 0, ∀ {x : α}, x ∈ s → edist x a < δ → edist (f x) b < ε := by rw [← nhdsWithin_univ b, tendsto_nhdsWithin_nhdsWithin] simp only [mem_univ, true_and_iff] theorem tendsto_nhds_nhds {a b} : Tendsto f (𝓝 a) (𝓝 b) ↔ ∀ ε > 0, ∃ δ > 0, ∀ ⦃x⦄, edist x a < δ → edist (f x) b < ε := nhds_basis_eball.tendsto_iff nhds_basis_eball end theorem isOpen_iff : IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, ball x ε ⊆ s := by simp [isOpen_iff_nhds, mem_nhds_iff] theorem isOpen_ball : IsOpen (ball x ε) := isOpen_iff.2 fun _ => exists_ball_subset_ball theorem isClosed_ball_top : IsClosed (ball x ⊤) := isOpen_compl_iff.1 <| isOpen_iff.2 fun _y hy => ⟨⊤, ENNReal.coe_lt_top, fun _z hzy hzx => hy (edistLtTopSetoid.trans (edistLtTopSetoid.symm hzy) hzx)⟩ theorem ball_mem_nhds (x : α) {ε : ℝ≥0∞} (ε0 : 0 < ε) : ball x ε ∈ 𝓝 x := isOpen_ball.mem_nhds (mem_ball_self ε0) theorem closedBall_mem_nhds (x : α) {ε : ℝ≥0∞} (ε0 : 0 < ε) : closedBall x ε ∈ 𝓝 x := mem_of_superset (ball_mem_nhds x ε0) ball_subset_closedBall theorem ball_prod_same [PseudoEMetricSpace β] (x : α) (y : β) (r : ℝ≥0∞) : ball x r ×ˢ ball y r = ball (x, y) r := ext fun z => by simp [Prod.edist_eq] theorem closedBall_prod_same [PseudoEMetricSpace β] (x : α) (y : β) (r : ℝ≥0∞) : closedBall x r ×ˢ closedBall y r = closedBall (x, y) r := ext fun z => by simp [Prod.edist_eq] /-- ε-characterization of the closure in pseudoemetric spaces -/ theorem mem_closure_iff : x ∈ closure s ↔ ∀ ε > 0, ∃ y ∈ s, edist x y < ε := (mem_closure_iff_nhds_basis nhds_basis_eball).trans <| by simp only [mem_ball, edist_comm x] theorem tendsto_nhds {f : Filter β} {u : β → α} {a : α} : Tendsto u f (𝓝 a) ↔ ∀ ε > 0, ∀ᶠ x in f, edist (u x) a < ε := nhds_basis_eball.tendsto_right_iff theorem tendsto_atTop [Nonempty β] [SemilatticeSup β] {u : β → α} {a : α} : Tendsto u atTop (𝓝 a) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, edist (u n) a < ε := (atTop_basis.tendsto_iff nhds_basis_eball).trans <| by simp only [exists_prop, true_and_iff, mem_Ici, mem_ball] theorem inseparable_iff : Inseparable x y ↔ edist x y = 0 := by simp [inseparable_iff_mem_closure, mem_closure_iff, edist_comm, forall_lt_iff_le'] -- see Note [nolint_ge] /-- In a pseudoemetric space, Cauchy sequences are characterized by the fact that, eventually, the pseudoedistance between its elements is arbitrarily small -/ theorem cauchySeq_iff [Nonempty β] [SemilatticeSup β] {u : β → α} : CauchySeq u ↔ ∀ ε > 0, ∃ N, ∀ m, N ≤ m → ∀ n, N ≤ n → edist (u m) (u n) < ε := uniformity_basis_edist.cauchySeq_iff /-- A variation around the emetric characterization of Cauchy sequences -/ theorem cauchySeq_iff' [Nonempty β] [SemilatticeSup β] {u : β → α} : CauchySeq u ↔ ∀ ε > (0 : ℝ≥0∞), ∃ N, ∀ n ≥ N, edist (u n) (u N) < ε := uniformity_basis_edist.cauchySeq_iff' /-- A variation of the emetric characterization of Cauchy sequences that deals with `ℝ≥0` upper bounds. -/ theorem cauchySeq_iff_NNReal [Nonempty β] [SemilatticeSup β] {u : β → α} : CauchySeq u ↔ ∀ ε : ℝ≥0, 0 < ε → ∃ N, ∀ n, N ≤ n → edist (u n) (u N) < ε := uniformity_basis_edist_nnreal.cauchySeq_iff' theorem totallyBounded_iff {s : Set α} : TotallyBounded s ↔ ∀ ε > 0, ∃ t : Set α, t.Finite ∧ s ⊆ ⋃ y ∈ t, ball y ε := ⟨fun H _ε ε0 => H _ (edist_mem_uniformity ε0), fun H _r ru => let ⟨ε, ε0, hε⟩ := mem_uniformity_edist.1 ru let ⟨t, ft, h⟩ := H ε ε0 ⟨t, ft, h.trans <| iUnion₂_mono fun _ _ _ => hε⟩⟩ theorem totallyBounded_iff' {s : Set α} : TotallyBounded s ↔ ∀ ε > 0, ∃ t, t ⊆ s ∧ Set.Finite t ∧ s ⊆ ⋃ y ∈ t, ball y ε := ⟨fun H _ε ε0 => (totallyBounded_iff_subset.1 H) _ (edist_mem_uniformity ε0), fun H _r ru => let ⟨ε, ε0, hε⟩ := mem_uniformity_edist.1 ru let ⟨t, _, ft, h⟩ := H ε ε0 ⟨t, ft, h.trans <| iUnion₂_mono fun _ _ _ => hε⟩⟩ section Compact -- Porting note (#11215): TODO: generalize to a uniform space with metrizable uniformity /-- For a set `s` in a pseudo emetric space, if for every `ε > 0` there exists a countable set that is `ε`-dense in `s`, then there exists a countable subset `t ⊆ s` that is dense in `s`. -/ theorem subset_countable_closure_of_almost_dense_set (s : Set α) (hs : ∀ ε > 0, ∃ t : Set α, t.Countable ∧ s ⊆ ⋃ x ∈ t, closedBall x ε) : ∃ t, t ⊆ s ∧ t.Countable ∧ s ⊆ closure t := by rcases s.eq_empty_or_nonempty with (rfl | ⟨x₀, hx₀⟩) · exact ⟨∅, empty_subset _, countable_empty, empty_subset _⟩ choose! T hTc hsT using fun n : ℕ => hs n⁻¹ (by simp) have : ∀ r x, ∃ y ∈ s, closedBall x r ∩ s ⊆ closedBall y (r * 2) := fun r x => by rcases (closedBall x r ∩ s).eq_empty_or_nonempty with (he | ⟨y, hxy, hys⟩) · refine ⟨x₀, hx₀, ?_⟩ rw [he] exact empty_subset _ · refine ⟨y, hys, fun z hz => ?_⟩ calc edist z y ≤ edist z x + edist y x := edist_triangle_right _ _ _ _ ≤ r + r := add_le_add hz.1 hxy _ = r * 2 := (mul_two r).symm choose f hfs hf using this refine ⟨⋃ n : ℕ, f n⁻¹ '' T n, iUnion_subset fun n => image_subset_iff.2 fun z _ => hfs _ _, countable_iUnion fun n => (hTc n).image _, ?_⟩ refine fun x hx => mem_closure_iff.2 fun ε ε0 => ?_ rcases ENNReal.exists_inv_nat_lt (ENNReal.half_pos ε0.lt.ne').ne' with ⟨n, hn⟩ rcases mem_iUnion₂.1 (hsT n hx) with ⟨y, hyn, hyx⟩ refine ⟨f n⁻¹ y, mem_iUnion.2 ⟨n, mem_image_of_mem _ hyn⟩, ?_⟩ calc edist x (f n⁻¹ y) ≤ (n : ℝ≥0∞)⁻¹ * 2 := hf _ _ ⟨hyx, hx⟩ _ < ε := ENNReal.mul_lt_of_lt_div hn open TopologicalSpace in /-- If a set `s` is separable in a (pseudo extended) metric space, then it admits a countable dense subset. This is not obvious, as the countable set whose closure covers `s` given by the definition of separability does not need in general to be contained in `s`. -/ theorem _root_.TopologicalSpace.IsSeparable.exists_countable_dense_subset {s : Set α} (hs : IsSeparable s) : ∃ t, t ⊆ s ∧ t.Countable ∧ s ⊆ closure t := by have : ∀ ε > 0, ∃ t : Set α, t.Countable ∧ s ⊆ ⋃ x ∈ t, closedBall x ε := fun ε ε0 => by rcases hs with ⟨t, htc, hst⟩ refine ⟨t, htc, hst.trans fun x hx => ?_⟩ rcases mem_closure_iff.1 hx ε ε0 with ⟨y, hyt, hxy⟩ exact mem_iUnion₂.2 ⟨y, hyt, mem_closedBall.2 hxy.le⟩ exact subset_countable_closure_of_almost_dense_set _ this open TopologicalSpace in /-- If a set `s` is separable, then the corresponding subtype is separable in a (pseudo extended) metric space. This is not obvious, as the countable set whose closure covers `s` does not need in general to be contained in `s`. -/ theorem _root_.TopologicalSpace.IsSeparable.separableSpace {s : Set α} (hs : IsSeparable s) : SeparableSpace s := by rcases hs.exists_countable_dense_subset with ⟨t, hts, htc, hst⟩ lift t to Set s using hts refine ⟨⟨t, countable_of_injective_of_countable_image Subtype.coe_injective.injOn htc, ?_⟩⟩ rwa [inducing_subtype_val.dense_iff, Subtype.forall] -- Porting note (#11215): TODO: generalize to metrizable spaces /-- A compact set in a pseudo emetric space is separable, i.e., it is a subset of the closure of a countable set. -/ theorem subset_countable_closure_of_compact {s : Set α} (hs : IsCompact s) : ∃ t, t ⊆ s ∧ t.Countable ∧ s ⊆ closure t := by refine subset_countable_closure_of_almost_dense_set s fun ε hε => ?_ rcases totallyBounded_iff'.1 hs.totallyBounded ε hε with ⟨t, -, htf, hst⟩ exact ⟨t, htf.countable, hst.trans <| iUnion₂_mono fun _ _ => ball_subset_closedBall⟩ end Compact section SecondCountable open TopologicalSpace variable (α) /-- A sigma compact pseudo emetric space has second countable topology. -/ instance (priority := 90) secondCountable_of_sigmaCompact [SigmaCompactSpace α] : SecondCountableTopology α := by suffices SeparableSpace α by exact UniformSpace.secondCountable_of_separable α choose T _ hTc hsubT using fun n => subset_countable_closure_of_compact (isCompact_compactCovering α n) refine ⟨⟨⋃ n, T n, countable_iUnion hTc, fun x => ?_⟩⟩ rcases iUnion_eq_univ_iff.1 (iUnion_compactCovering α) x with ⟨n, hn⟩ exact closure_mono (subset_iUnion _ n) (hsubT _ hn) variable {α} theorem secondCountable_of_almost_dense_set (hs : ∀ ε > 0, ∃ t : Set α, t.Countable ∧ ⋃ x ∈ t, closedBall x ε = univ) : SecondCountableTopology α := by suffices SeparableSpace α from UniformSpace.secondCountable_of_separable α have : ∀ ε > 0, ∃ t : Set α, Set.Countable t ∧ univ ⊆ ⋃ x ∈ t, closedBall x ε := by simpa only [univ_subset_iff] using hs rcases subset_countable_closure_of_almost_dense_set (univ : Set α) this with ⟨t, -, htc, ht⟩ exact ⟨⟨t, htc, fun x => ht (mem_univ x)⟩⟩ end SecondCountable section Diam /-- The diameter of a set in a pseudoemetric space, named `EMetric.diam` -/ noncomputable def diam (s : Set α) := ⨆ (x ∈ s) (y ∈ s), edist x y theorem diam_eq_sSup (s : Set α) : diam s = sSup (image2 edist s s) := sSup_image2.symm theorem diam_le_iff {d : ℝ≥0∞} : diam s ≤ d ↔ ∀ x ∈ s, ∀ y ∈ s, edist x y ≤ d := by simp only [diam, iSup_le_iff] theorem diam_image_le_iff {d : ℝ≥0∞} {f : β → α} {s : Set β} : diam (f '' s) ≤ d ↔ ∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) ≤ d := by simp only [diam_le_iff, forall_mem_image] theorem edist_le_of_diam_le {d} (hx : x ∈ s) (hy : y ∈ s) (hd : diam s ≤ d) : edist x y ≤ d := diam_le_iff.1 hd x hx y hy /-- If two points belong to some set, their edistance is bounded by the diameter of the set -/ theorem edist_le_diam_of_mem (hx : x ∈ s) (hy : y ∈ s) : edist x y ≤ diam s := edist_le_of_diam_le hx hy le_rfl /-- If the distance between any two points in a set is bounded by some constant, this constant bounds the diameter. -/ theorem diam_le {d : ℝ≥0∞} (h : ∀ x ∈ s, ∀ y ∈ s, edist x y ≤ d) : diam s ≤ d := diam_le_iff.2 h /-- The diameter of a subsingleton vanishes. -/ theorem diam_subsingleton (hs : s.Subsingleton) : diam s = 0 := nonpos_iff_eq_zero.1 <| diam_le fun _x hx y hy => (hs hx hy).symm ▸ edist_self y ▸ le_rfl /-- The diameter of the empty set vanishes -/ @[simp] theorem diam_empty : diam (∅ : Set α) = 0 := diam_subsingleton subsingleton_empty /-- The diameter of a singleton vanishes -/ @[simp] theorem diam_singleton : diam ({x} : Set α) = 0 := diam_subsingleton subsingleton_singleton @[to_additive (attr := simp)] theorem diam_one [One α] : diam (1 : Set α) = 0 := diam_singleton theorem diam_iUnion_mem_option {ι : Type*} (o : Option ι) (s : ι → Set α) : diam (⋃ i ∈ o, s i) = ⨆ i ∈ o, diam (s i) := by cases o <;> simp theorem diam_insert : diam (insert x s) = max (⨆ y ∈ s, edist x y) (diam s) := eq_of_forall_ge_iff fun d => by simp only [diam_le_iff, forall_mem_insert, edist_self, edist_comm x, max_le_iff, iSup_le_iff, zero_le, true_and_iff, forall_and, and_self_iff, ← and_assoc] theorem diam_pair : diam ({x, y} : Set α) = edist x y := by simp only [iSup_singleton, diam_insert, diam_singleton, ENNReal.max_zero_right] theorem diam_triple : diam ({x, y, z} : Set α) = max (max (edist x y) (edist x z)) (edist y z) := by simp only [diam_insert, iSup_insert, iSup_singleton, diam_singleton, ENNReal.max_zero_right, ENNReal.sup_eq_max] /-- The diameter is monotonous with respect to inclusion -/ @[gcongr] theorem diam_mono {s t : Set α} (h : s ⊆ t) : diam s ≤ diam t := diam_le fun _x hx _y hy => edist_le_diam_of_mem (h hx) (h hy) /-- The diameter of a union is controlled by the diameter of the sets, and the edistance between two points in the sets. -/ theorem diam_union {t : Set α} (xs : x ∈ s) (yt : y ∈ t) : diam (s ∪ t) ≤ diam s + edist x y + diam t := by have A : ∀ a ∈ s, ∀ b ∈ t, edist a b ≤ diam s + edist x y + diam t := fun a ha b hb => calc edist a b ≤ edist a x + edist x y + edist y b := edist_triangle4 _ _ _ _ _ ≤ diam s + edist x y + diam t := add_le_add (add_le_add (edist_le_diam_of_mem ha xs) le_rfl) (edist_le_diam_of_mem yt hb) refine diam_le fun a ha b hb => ?_ cases' (mem_union _ _ _).1 ha with h'a h'a <;> cases' (mem_union _ _ _).1 hb with h'b h'b · calc edist a b ≤ diam s := edist_le_diam_of_mem h'a h'b _ ≤ diam s + (edist x y + diam t) := le_self_add _ = diam s + edist x y + diam t := (add_assoc _ _ _).symm · exact A a h'a b h'b · have Z := A b h'b a h'a rwa [edist_comm] at Z · calc edist a b ≤ diam t := edist_le_diam_of_mem h'a h'b _ ≤ diam s + edist x y + diam t := le_add_self theorem diam_union' {t : Set α} (h : (s ∩ t).Nonempty) : diam (s ∪ t) ≤ diam s + diam t := by let ⟨x, ⟨xs, xt⟩⟩ := h simpa using diam_union xs xt theorem diam_closedBall {r : ℝ≥0∞} : diam (closedBall x r) ≤ 2 * r := diam_le fun a ha b hb => calc edist a b ≤ edist a x + edist b x := edist_triangle_right _ _ _ _ ≤ r + r := add_le_add ha hb _ = 2 * r := (two_mul r).symm theorem diam_ball {r : ℝ≥0∞} : diam (ball x r) ≤ 2 * r := le_trans (diam_mono ball_subset_closedBall) diam_closedBall theorem diam_pi_le_of_le {π : β → Type*} [Fintype β] [∀ b, PseudoEMetricSpace (π b)] {s : ∀ b : β, Set (π b)} {c : ℝ≥0∞} (h : ∀ b, diam (s b) ≤ c) : diam (Set.pi univ s) ≤ c := by refine diam_le fun x hx y hy => edist_pi_le_iff.mpr ?_ rw [mem_univ_pi] at hx hy exact fun b => diam_le_iff.1 (h b) (x b) (hx b) (y b) (hy b) end Diam end EMetric --namespace /-- We now define `EMetricSpace`, extending `PseudoEMetricSpace`. -/ class EMetricSpace (α : Type u) extends PseudoEMetricSpace α : Type u where eq_of_edist_eq_zero : ∀ {x y : α}, edist x y = 0 → x = y @[ext] protected theorem EMetricSpace.ext {α : Type*} {m m' : EMetricSpace α} (h : m.toEDist = m'.toEDist) : m = m' := by cases m cases m' congr ext1 assumption variable {γ : Type w} [EMetricSpace γ] export EMetricSpace (eq_of_edist_eq_zero) /-- Characterize the equality of points by the vanishing of their extended distance -/ @[simp] theorem edist_eq_zero {x y : γ} : edist x y = 0 ↔ x = y := ⟨eq_of_edist_eq_zero, fun h => h ▸ edist_self _⟩ @[simp] theorem zero_eq_edist {x y : γ} : 0 = edist x y ↔ x = y := eq_comm.trans edist_eq_zero theorem edist_le_zero {x y : γ} : edist x y ≤ 0 ↔ x = y := nonpos_iff_eq_zero.trans edist_eq_zero @[simp] theorem edist_pos {x y : γ} : 0 < edist x y ↔ x ≠ y := by simp [← not_le] /-- Two points coincide if their distance is `< ε` for all positive ε -/ theorem eq_of_forall_edist_le {x y : γ} (h : ∀ ε > 0, edist x y ≤ ε) : x = y := eq_of_edist_eq_zero (eq_of_le_of_forall_le_of_dense bot_le h) -- see Note [lower instance priority] /-- An emetric space is separated -/ instance (priority := 100) EMetricSpace.instT0Space : T0Space γ where t0 _ _ h := eq_of_edist_eq_zero <| inseparable_iff.1 h /-- A map between emetric spaces is a uniform embedding if and only if the edistance between `f x` and `f y` is controlled in terms of the distance between `x` and `y` and conversely. -/ theorem EMetric.uniformEmbedding_iff' [EMetricSpace β] {f : γ → β} : UniformEmbedding f ↔ (∀ ε > 0, ∃ δ > 0, ∀ {a b : γ}, edist a b < δ → edist (f a) (f b) < ε) ∧ ∀ δ > 0, ∃ ε > 0, ∀ {a b : γ}, edist (f a) (f b) < ε → edist a b < δ := by rw [uniformEmbedding_iff_uniformInducing, uniformInducing_iff, uniformContinuous_iff] /-- If a `PseudoEMetricSpace` is a T₀ space, then it is an `EMetricSpace`. -/ -- Porting note: made `reducible`; -- Porting note (#11215): TODO: make it an instance? abbrev EMetricSpace.ofT0PseudoEMetricSpace (α : Type*) [PseudoEMetricSpace α] [T0Space α] : EMetricSpace α := { ‹PseudoEMetricSpace α› with eq_of_edist_eq_zero := fun h => (EMetric.inseparable_iff.2 h).eq } /-- Auxiliary function to replace the uniformity on an emetric space with a uniformity which is equal to the original one, but maybe not defeq. This is useful if one wants to construct an emetric space with a specified uniformity. See Note [forgetful inheritance] explaining why having definitionally the right uniformity is often important. -/ def EMetricSpace.replaceUniformity {γ} [U : UniformSpace γ] (m : EMetricSpace γ) (H : 𝓤[U] = 𝓤[PseudoEMetricSpace.toUniformSpace]) : EMetricSpace γ where edist := @edist _ m.toEDist edist_self := edist_self eq_of_edist_eq_zero := @eq_of_edist_eq_zero _ _ edist_comm := edist_comm edist_triangle := edist_triangle toUniformSpace := U uniformity_edist := H.trans (@PseudoEMetricSpace.uniformity_edist γ _) /-- The extended metric induced by an injective function taking values in an emetric space. -/ def EMetricSpace.induced {γ β} (f : γ → β) (hf : Function.Injective f) (m : EMetricSpace β) : EMetricSpace γ := { PseudoEMetricSpace.induced f m.toPseudoEMetricSpace with eq_of_edist_eq_zero := fun h => hf (edist_eq_zero.1 h) } /-- EMetric space instance on subsets of emetric spaces -/ instance {α : Type*} {p : α → Prop} [EMetricSpace α] : EMetricSpace (Subtype p) := EMetricSpace.induced Subtype.val Subtype.coe_injective ‹_› /-- EMetric space instance on the multiplicative opposite of an emetric space. -/ @[to_additive "EMetric space instance on the additive opposite of an emetric space."] instance {α : Type*} [EMetricSpace α] : EMetricSpace αᵐᵒᵖ := EMetricSpace.induced MulOpposite.unop MulOpposite.unop_injective ‹_› instance {α : Type*} [EMetricSpace α] : EMetricSpace (ULift α) := EMetricSpace.induced ULift.down ULift.down_injective ‹_› /-- The product of two emetric spaces, with the max distance, is an extended metric spaces. We make sure that the uniform structure thus constructed is the one corresponding to the product of uniform spaces, to avoid diamond problems. -/ instance Prod.emetricSpaceMax [EMetricSpace β] : EMetricSpace (γ × β) := .ofT0PseudoEMetricSpace _ /-- Reformulation of the uniform structure in terms of the extended distance -/ theorem uniformity_edist : 𝓤 γ = ⨅ ε > 0, 𝓟 { p : γ × γ | edist p.1 p.2 < ε } := PseudoEMetricSpace.uniformity_edist section Pi open Finset variable {π : β → Type*} [Fintype β] /-- The product of a finite number of emetric spaces, with the max distance, is still an emetric space. This construction would also work for infinite products, but it would not give rise to the product topology. Hence, we only formalize it in the good situation of finitely many spaces. -/ instance emetricSpacePi [∀ b, EMetricSpace (π b)] : EMetricSpace (∀ b, π b) := .ofT0PseudoEMetricSpace _ end Pi namespace EMetric /-- A compact set in an emetric space is separable, i.e., it is the closure of a countable set. -/ theorem countable_closure_of_compact {s : Set γ} (hs : IsCompact s) : ∃ t, t ⊆ s ∧ t.Countable ∧ s = closure t := by rcases subset_countable_closure_of_compact hs with ⟨t, hts, htc, hsub⟩ exact ⟨t, hts, htc, hsub.antisymm (closure_minimal hts hs.isClosed)⟩ section Diam variable {s : Set γ} theorem diam_eq_zero_iff : diam s = 0 ↔ s.Subsingleton := ⟨fun h _x hx _y hy => edist_le_zero.1 <| h ▸ edist_le_diam_of_mem hx hy, diam_subsingleton⟩ theorem diam_pos_iff : 0 < diam s ↔ s.Nontrivial := by simp only [pos_iff_ne_zero, Ne, diam_eq_zero_iff, Set.not_subsingleton_iff] theorem diam_pos_iff' : 0 < diam s ↔ ∃ x ∈ s, ∃ y ∈ s, x ≠ y := by simp only [diam_pos_iff, Set.Nontrivial, exists_prop] end Diam end EMetric /-! ### Separation quotient -/ instance [PseudoEMetricSpace X] : EDist (SeparationQuotient X) where edist := SeparationQuotient.lift₂ edist fun _ _ _ _ hx hy => edist_congr (EMetric.inseparable_iff.1 hx) (EMetric.inseparable_iff.1 hy) @[simp] theorem SeparationQuotient.edist_mk [PseudoEMetricSpace X] (x y : X) : edist (mk x) (mk y) = edist x y := rfl open SeparationQuotient in instance [PseudoEMetricSpace X] : EMetricSpace (SeparationQuotient X) := @EMetricSpace.ofT0PseudoEMetricSpace (SeparationQuotient X) { edist_self := surjective_mk.forall.2 edist_self, edist_comm := surjective_mk.forall₂.2 edist_comm, edist_triangle := surjective_mk.forall₃.2 edist_triangle, toUniformSpace := inferInstance, uniformity_edist := comap_injective (surjective_mk.prodMap surjective_mk) <| by simp [comap_mk_uniformity, PseudoEMetricSpace.uniformity_edist] } _ /-! ### `Additive`, `Multiplicative` The distance on those type synonyms is inherited without change. -/ open Additive Multiplicative section variable [EDist X] instance : EDist (Additive X) := ‹EDist X› instance : EDist (Multiplicative X) := ‹EDist X› @[simp] theorem edist_ofMul (a b : X) : edist (ofMul a) (ofMul b) = edist a b := rfl @[simp] theorem edist_ofAdd (a b : X) : edist (ofAdd a) (ofAdd b) = edist a b := rfl @[simp] theorem edist_toMul (a b : Additive X) : edist (toMul a) (toMul b) = edist a b := rfl @[simp] theorem edist_toAdd (a b : Multiplicative X) : edist (toAdd a) (toAdd b) = edist a b := rfl end instance [PseudoEMetricSpace X] : PseudoEMetricSpace (Additive X) := ‹PseudoEMetricSpace X› instance [PseudoEMetricSpace X] : PseudoEMetricSpace (Multiplicative X) := ‹PseudoEMetricSpace X› instance [EMetricSpace X] : EMetricSpace (Additive X) := ‹EMetricSpace X› instance [EMetricSpace X] : EMetricSpace (Multiplicative X) := ‹EMetricSpace X› /-! ### Order dual The distance on this type synonym is inherited without change. -/ open OrderDual section variable [EDist X] instance : EDist Xᵒᵈ := ‹EDist X› @[simp] theorem edist_toDual (a b : X) : edist (toDual a) (toDual b) = edist a b := rfl @[simp] theorem edist_ofDual (a b : Xᵒᵈ) : edist (ofDual a) (ofDual b) = edist a b := rfl end instance [PseudoEMetricSpace X] : PseudoEMetricSpace Xᵒᵈ := ‹PseudoEMetricSpace X› instance [EMetricSpace X] : EMetricSpace Xᵒᵈ := ‹EMetricSpace X›
Topology\EMetricSpace\Lipschitz.lean
/- Copyright (c) 2018 Rohan Mitta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rohan Mitta, Kevin Buzzard, Alistair Tucker, Johannes Hölzl, Yury Kudryashov -/ import Mathlib.Logic.Function.Iterate import Mathlib.Topology.EMetricSpace.Basic import Mathlib.Tactic.GCongr /-! # Lipschitz continuous functions A map `f : α → β` between two (extended) metric spaces is called *Lipschitz continuous* with constant `K ≥ 0` if for all `x, y` we have `edist (f x) (f y) ≤ K * edist x y`. For a metric space, the latter inequality is equivalent to `dist (f x) (f y) ≤ K * dist x y`. There is also a version asserting this inequality only for `x` and `y` in some set `s`. Finally, `f : α → β` is called *locally Lipschitz continuous* if each `x : α` has a neighbourhood on which `f` is Lipschitz continuous (with some constant). In this file we provide various ways to prove that various combinations of Lipschitz continuous functions are Lipschitz continuous. We also prove that Lipschitz continuous functions are uniformly continuous, and that locally Lipschitz functions are continuous. ## Main definitions and lemmas * `LipschitzWith K f`: states that `f` is Lipschitz with constant `K : ℝ≥0` * `LipschitzOnWith K f s`: states that `f` is Lipschitz with constant `K : ℝ≥0` on a set `s` * `LipschitzWith.uniformContinuous`: a Lipschitz function is uniformly continuous * `LipschitzOnWith.uniformContinuousOn`: a function which is Lipschitz on a set `s` is uniformly continuous on `s`. * `LocallyLipschitz f`: states that `f` is locally Lipschitz * `LocallyLipschitzOn f s`: states that `f` is locally Lipschitz on `s`. * `LocallyLipschitz.continuous`: a locally Lipschitz function is continuous. ## Implementation notes The parameter `K` has type `ℝ≥0`. This way we avoid conjunction in the definition and have coercions both to `ℝ` and `ℝ≥0∞`. Constructors whose names end with `'` take `K : ℝ` as an argument, and return `LipschitzWith (Real.toNNReal K) f`. -/ universe u v w x open Filter Function Set Topology NNReal ENNReal Bornology variable {α : Type u} {β : Type v} {γ : Type w} {ι : Type x} section PseudoEMetricSpace variable [PseudoEMetricSpace α] [PseudoEMetricSpace β] {K : ℝ≥0} {s t : Set α} {f : α → β} /-- A function `f` is **Lipschitz continuous** with constant `K ≥ 0` if for all `x, y` we have `dist (f x) (f y) ≤ K * dist x y`. -/ def LipschitzWith (K : ℝ≥0) (f : α → β) := ∀ x y, edist (f x) (f y) ≤ K * edist x y /-- A function `f` is **Lipschitz continuous** with constant `K ≥ 0` **on `s`** if for all `x, y` in `s` we have `dist (f x) (f y) ≤ K * dist x y`. -/ def LipschitzOnWith (K : ℝ≥0) (f : α → β) (s : Set α) := ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → edist (f x) (f y) ≤ K * edist x y /-- `f : α → β` is called **locally Lipschitz continuous** iff every point `x` has a neighourhood on which `f` is Lipschitz. -/ def LocallyLipschitz (f : α → β) : Prop := ∀ x, ∃ K, ∃ t ∈ 𝓝 x, LipschitzOnWith K f t /-- `f : α → β` is called **locally Lipschitz continuous** on `s` iff every point `x` of `s` has a neighourhood within `s` on which `f` is Lipschitz. -/ def LocallyLipschitzOn (s : Set α) (f : α → β) : Prop := ∀ ⦃x⦄, x ∈ s → ∃ K, ∃ t ∈ 𝓝[s] x, LipschitzOnWith K f t /-- Every function is Lipschitz on the empty set (with any Lipschitz constant). -/ @[simp] theorem lipschitzOnWith_empty (K : ℝ≥0) (f : α → β) : LipschitzOnWith K f ∅ := fun _ => False.elim @[simp] lemma locallyLipschitzOn_empty (f : α → β) : LocallyLipschitzOn ∅ f := fun _ ↦ False.elim /-- Being Lipschitz on a set is monotone w.r.t. that set. -/ theorem LipschitzOnWith.mono (hf : LipschitzOnWith K f t) (h : s ⊆ t) : LipschitzOnWith K f s := fun _x x_in _y y_in => hf (h x_in) (h y_in) lemma LocallyLipschitzOn.mono (hf : LocallyLipschitzOn t f) (h : s ⊆ t) : LocallyLipschitzOn s f := fun x hx ↦ by obtain ⟨K, u, hu, hfu⟩ := hf (h hx); exact ⟨K, u, nhdsWithin_mono _ h hu, hfu⟩ /-- `f` is Lipschitz iff it is Lipschitz on the entire space. -/ @[simp] lemma lipschitzOnWith_univ : LipschitzOnWith K f univ ↔ LipschitzWith K f := by simp [LipschitzOnWith, LipschitzWith] @[deprecated (since := "2024-07-17")] alias lipschitzOn_univ := lipschitzOnWith_univ @[simp] lemma locallyLipschitzOn_univ : LocallyLipschitzOn univ f ↔ LocallyLipschitz f := by simp [LocallyLipschitzOn, LocallyLipschitz] theorem lipschitzOnWith_iff_restrict : LipschitzOnWith K f s ↔ LipschitzWith K (s.restrict f) := by simp only [LipschitzOnWith, LipschitzWith, SetCoe.forall', restrict, Subtype.edist_eq] lemma lipschitzOnWith_restrict {t : Set s} : LipschitzOnWith K (s.restrict f) t ↔ LipschitzOnWith K f (s ∩ Subtype.val '' t) := by simp only [LipschitzOnWith, LipschitzWith, Subtype.forall, restrict, Subtype.edist_eq]; aesop lemma locallyLipschitzOn_iff_restrict : LocallyLipschitzOn s f ↔ LocallyLipschitz (s.restrict f) := by simp only [LocallyLipschitzOn, LocallyLipschitz, SetCoe.forall', restrict, Subtype.edist_eq, ← lipschitzOnWith_iff_restrict, lipschitzOnWith_restrict, nhds_subtype_eq_comap_nhdsWithin, mem_comap] congr! with x K constructor · rintro ⟨t, ht, hft⟩ exact ⟨_, ⟨t, ht, Subset.rfl⟩, hft.mono <| inter_subset_right.trans <| image_preimage_subset ..⟩ · rintro ⟨t, ⟨u, hu, hut⟩, hft⟩ exact ⟨s ∩ u, Filter.inter_mem self_mem_nhdsWithin hu, hft.mono fun x hx ↦ ⟨hx.1, ⟨x, hx.1⟩, hut hx.2, rfl⟩⟩ alias ⟨LipschitzOnWith.to_restrict, _⟩ := lipschitzOnWith_iff_restrict alias ⟨LocallyLipschitzOn.restrict, _⟩ := locallyLipschitzOn_iff_restrict lemma Set.MapsTo.lipschitzOnWith_iff_restrict {t : Set β} (h : MapsTo f s t) : LipschitzOnWith K f s ↔ LipschitzWith K (h.restrict f s t) := _root_.lipschitzOnWith_iff_restrict alias ⟨LipschitzOnWith.to_restrict_mapsTo, _⟩ := Set.MapsTo.lipschitzOnWith_iff_restrict end PseudoEMetricSpace namespace LipschitzWith open EMetric variable [PseudoEMetricSpace α] [PseudoEMetricSpace β] [PseudoEMetricSpace γ] variable {K : ℝ≥0} {f : α → β} {x y : α} {r : ℝ≥0∞} protected theorem lipschitzOnWith (h : LipschitzWith K f) (s : Set α) : LipschitzOnWith K f s := fun x _ y _ => h x y theorem edist_le_mul (h : LipschitzWith K f) (x y : α) : edist (f x) (f y) ≤ K * edist x y := h x y theorem edist_le_mul_of_le (h : LipschitzWith K f) (hr : edist x y ≤ r) : edist (f x) (f y) ≤ K * r := (h x y).trans <| ENNReal.mul_left_mono hr theorem edist_lt_mul_of_lt (h : LipschitzWith K f) (hK : K ≠ 0) (hr : edist x y < r) : edist (f x) (f y) < K * r := (h x y).trans_lt <| (ENNReal.mul_lt_mul_left (ENNReal.coe_ne_zero.2 hK) ENNReal.coe_ne_top).2 hr theorem mapsTo_emetric_closedBall (h : LipschitzWith K f) (x : α) (r : ℝ≥0∞) : MapsTo f (closedBall x r) (closedBall (f x) (K * r)) := fun _y hy => h.edist_le_mul_of_le hy theorem mapsTo_emetric_ball (h : LipschitzWith K f) (hK : K ≠ 0) (x : α) (r : ℝ≥0∞) : MapsTo f (ball x r) (ball (f x) (K * r)) := fun _y hy => h.edist_lt_mul_of_lt hK hy theorem edist_lt_top (hf : LipschitzWith K f) {x y : α} (h : edist x y ≠ ⊤) : edist (f x) (f y) < ⊤ := (hf x y).trans_lt <| ENNReal.mul_lt_top ENNReal.coe_ne_top h theorem mul_edist_le (h : LipschitzWith K f) (x y : α) : (K⁻¹ : ℝ≥0∞) * edist (f x) (f y) ≤ edist x y := by rw [mul_comm, ← div_eq_mul_inv] exact ENNReal.div_le_of_le_mul' (h x y) protected theorem of_edist_le (h : ∀ x y, edist (f x) (f y) ≤ edist x y) : LipschitzWith 1 f := fun x y => by simp only [ENNReal.coe_one, one_mul, h] protected theorem weaken (hf : LipschitzWith K f) {K' : ℝ≥0} (h : K ≤ K') : LipschitzWith K' f := fun x y => le_trans (hf x y) <| ENNReal.mul_right_mono (ENNReal.coe_le_coe.2 h) theorem ediam_image_le (hf : LipschitzWith K f) (s : Set α) : EMetric.diam (f '' s) ≤ K * EMetric.diam s := by apply EMetric.diam_le rintro _ ⟨x, hx, rfl⟩ _ ⟨y, hy, rfl⟩ exact hf.edist_le_mul_of_le (EMetric.edist_le_diam_of_mem hx hy) theorem edist_lt_of_edist_lt_div (hf : LipschitzWith K f) {x y : α} {d : ℝ≥0∞} (h : edist x y < d / K) : edist (f x) (f y) < d := calc edist (f x) (f y) ≤ K * edist x y := hf x y _ < d := ENNReal.mul_lt_of_lt_div' h /-- A Lipschitz function is uniformly continuous. -/ protected theorem uniformContinuous (hf : LipschitzWith K f) : UniformContinuous f := EMetric.uniformContinuous_iff.2 fun ε εpos => ⟨ε / K, ENNReal.div_pos_iff.2 ⟨ne_of_gt εpos, ENNReal.coe_ne_top⟩, hf.edist_lt_of_edist_lt_div⟩ /-- A Lipschitz function is continuous. -/ protected theorem continuous (hf : LipschitzWith K f) : Continuous f := hf.uniformContinuous.continuous /-- Constant functions are Lipschitz (with any constant). -/ protected theorem const (b : β) : LipschitzWith 0 fun _ : α => b := fun x y => by simp only [edist_self, zero_le] protected theorem const' (b : β) {K : ℝ≥0} : LipschitzWith K fun _ : α => b := fun x y => by simp only [edist_self, zero_le] /-- The identity is 1-Lipschitz. -/ protected theorem id : LipschitzWith 1 (@id α) := LipschitzWith.of_edist_le fun _ _ => le_rfl /-- The inclusion of a subset is 1-Lipschitz. -/ protected theorem subtype_val (s : Set α) : LipschitzWith 1 (Subtype.val : s → α) := LipschitzWith.of_edist_le fun _ _ => le_rfl theorem subtype_mk (hf : LipschitzWith K f) {p : β → Prop} (hp : ∀ x, p (f x)) : LipschitzWith K (fun x => ⟨f x, hp x⟩ : α → { y // p y }) := hf protected theorem eval {α : ι → Type u} [∀ i, PseudoEMetricSpace (α i)] [Fintype ι] (i : ι) : LipschitzWith 1 (Function.eval i : (∀ i, α i) → α i) := LipschitzWith.of_edist_le fun f g => by convert edist_le_pi_edist f g i /-- The restriction of a `K`-Lipschitz function is `K`-Lipschitz. -/ protected theorem restrict (hf : LipschitzWith K f) (s : Set α) : LipschitzWith K (s.restrict f) := fun x y => hf x y /-- The composition of Lipschitz functions is Lipschitz. -/ protected theorem comp {Kf Kg : ℝ≥0} {f : β → γ} {g : α → β} (hf : LipschitzWith Kf f) (hg : LipschitzWith Kg g) : LipschitzWith (Kf * Kg) (f ∘ g) := fun x y => calc edist (f (g x)) (f (g y)) ≤ Kf * edist (g x) (g y) := hf _ _ _ ≤ Kf * (Kg * edist x y) := ENNReal.mul_left_mono (hg _ _) _ = (Kf * Kg : ℝ≥0) * edist x y := by rw [← mul_assoc, ENNReal.coe_mul] theorem comp_lipschitzOnWith {Kf Kg : ℝ≥0} {f : β → γ} {g : α → β} {s : Set α} (hf : LipschitzWith Kf f) (hg : LipschitzOnWith Kg g s) : LipschitzOnWith (Kf * Kg) (f ∘ g) s := lipschitzOnWith_iff_restrict.mpr <| hf.comp hg.to_restrict protected theorem prod_fst : LipschitzWith 1 (@Prod.fst α β) := LipschitzWith.of_edist_le fun _ _ => le_max_left _ _ protected theorem prod_snd : LipschitzWith 1 (@Prod.snd α β) := LipschitzWith.of_edist_le fun _ _ => le_max_right _ _ /-- If `f` and `g` are Lipschitz functions, so is the induced map `f × g` to the product type. -/ protected theorem prod {f : α → β} {Kf : ℝ≥0} (hf : LipschitzWith Kf f) {g : α → γ} {Kg : ℝ≥0} (hg : LipschitzWith Kg g) : LipschitzWith (max Kf Kg) fun x => (f x, g x) := by intro x y rw [ENNReal.coe_mono.map_max, Prod.edist_eq, ENNReal.max_mul] exact max_le_max (hf x y) (hg x y) protected theorem prod_mk_left (a : α) : LipschitzWith 1 (Prod.mk a : β → α × β) := by simpa only [max_eq_right zero_le_one] using (LipschitzWith.const a).prod LipschitzWith.id protected theorem prod_mk_right (b : β) : LipschitzWith 1 fun a : α => (a, b) := by simpa only [max_eq_left zero_le_one] using LipschitzWith.id.prod (LipschitzWith.const b) protected theorem uncurry {f : α → β → γ} {Kα Kβ : ℝ≥0} (hα : ∀ b, LipschitzWith Kα fun a => f a b) (hβ : ∀ a, LipschitzWith Kβ (f a)) : LipschitzWith (Kα + Kβ) (Function.uncurry f) := by rintro ⟨a₁, b₁⟩ ⟨a₂, b₂⟩ simp only [Function.uncurry, ENNReal.coe_add, add_mul] apply le_trans (edist_triangle _ (f a₂ b₁) _) exact add_le_add (le_trans (hα _ _ _) <| ENNReal.mul_left_mono <| le_max_left _ _) (le_trans (hβ _ _ _) <| ENNReal.mul_left_mono <| le_max_right _ _) /-- Iterates of a Lipschitz function are Lipschitz. -/ protected theorem iterate {f : α → α} (hf : LipschitzWith K f) : ∀ n, LipschitzWith (K ^ n) f^[n] | 0 => by simpa only [pow_zero] using LipschitzWith.id | n + 1 => by rw [pow_succ]; exact (LipschitzWith.iterate hf n).comp hf theorem edist_iterate_succ_le_geometric {f : α → α} (hf : LipschitzWith K f) (x n) : edist (f^[n] x) (f^[n + 1] x) ≤ edist x (f x) * (K : ℝ≥0∞) ^ n := by rw [iterate_succ, mul_comm] simpa only [ENNReal.coe_pow] using (hf.iterate n) x (f x) protected theorem mul_end {f g : Function.End α} {Kf Kg} (hf : LipschitzWith Kf f) (hg : LipschitzWith Kg g) : LipschitzWith (Kf * Kg) (f * g : Function.End α) := hf.comp hg /-- The product of a list of Lipschitz continuous endomorphisms is a Lipschitz continuous endomorphism. -/ protected theorem list_prod (f : ι → Function.End α) (K : ι → ℝ≥0) (h : ∀ i, LipschitzWith (K i) (f i)) : ∀ l : List ι, LipschitzWith (l.map K).prod (l.map f).prod | [] => by simpa using LipschitzWith.id | i::l => by simp only [List.map_cons, List.prod_cons] exact (h i).mul_end (LipschitzWith.list_prod f K h l) protected theorem pow_end {f : Function.End α} {K} (h : LipschitzWith K f) : ∀ n : ℕ, LipschitzWith (K ^ n) (f ^ n : Function.End α) | 0 => by simpa only [pow_zero] using LipschitzWith.id | n + 1 => by rw [pow_succ, pow_succ] exact (LipschitzWith.pow_end h n).mul_end h end LipschitzWith namespace LipschitzOnWith variable [PseudoEMetricSpace α] [PseudoEMetricSpace β] [PseudoEMetricSpace γ] variable {K : ℝ≥0} {s : Set α} {f : α → β} protected theorem uniformContinuousOn (hf : LipschitzOnWith K f s) : UniformContinuousOn f s := uniformContinuousOn_iff_restrict.mpr hf.to_restrict.uniformContinuous protected theorem continuousOn (hf : LipschitzOnWith K f s) : ContinuousOn f s := hf.uniformContinuousOn.continuousOn theorem edist_le_mul_of_le (h : LipschitzOnWith K f s) {x y : α} (hx : x ∈ s) (hy : y ∈ s) {r : ℝ≥0∞} (hr : edist x y ≤ r) : edist (f x) (f y) ≤ K * r := (h hx hy).trans <| ENNReal.mul_left_mono hr theorem edist_lt_of_edist_lt_div (hf : LipschitzOnWith K f s) {x y : α} (hx : x ∈ s) (hy : y ∈ s) {d : ℝ≥0∞} (hd : edist x y < d / K) : edist (f x) (f y) < d := hf.to_restrict.edist_lt_of_edist_lt_div <| show edist (⟨x, hx⟩ : s) ⟨y, hy⟩ < d / K from hd protected theorem comp {g : β → γ} {t : Set β} {Kg : ℝ≥0} (hg : LipschitzOnWith Kg g t) (hf : LipschitzOnWith K f s) (hmaps : MapsTo f s t) : LipschitzOnWith (Kg * K) (g ∘ f) s := lipschitzOnWith_iff_restrict.mpr <| hg.to_restrict.comp (hf.to_restrict_mapsTo hmaps) /-- If `f` and `g` are Lipschitz on `s`, so is the induced map `f × g` to the product type. -/ protected theorem prod {g : α → γ} {Kf Kg : ℝ≥0} (hf : LipschitzOnWith Kf f s) (hg : LipschitzOnWith Kg g s) : LipschitzOnWith (max Kf Kg) (fun x => (f x, g x)) s := by intro _ hx _ hy rw [ENNReal.coe_mono.map_max, Prod.edist_eq, ENNReal.max_mul] exact max_le_max (hf hx hy) (hg hx hy) theorem ediam_image2_le (f : α → β → γ) {K₁ K₂ : ℝ≥0} (s : Set α) (t : Set β) (hf₁ : ∀ b ∈ t, LipschitzOnWith K₁ (f · b) s) (hf₂ : ∀ a ∈ s, LipschitzOnWith K₂ (f a) t) : EMetric.diam (Set.image2 f s t) ≤ ↑K₁ * EMetric.diam s + ↑K₂ * EMetric.diam t := by simp only [EMetric.diam_le_iff, forall_image2_iff] intro a₁ ha₁ b₁ hb₁ a₂ ha₂ b₂ hb₂ refine (edist_triangle _ (f a₂ b₁) _).trans ?_ exact add_le_add ((hf₁ b₁ hb₁ ha₁ ha₂).trans <| ENNReal.mul_left_mono <| EMetric.edist_le_diam_of_mem ha₁ ha₂) ((hf₂ a₂ ha₂ hb₁ hb₂).trans <| ENNReal.mul_left_mono <| EMetric.edist_le_diam_of_mem hb₁ hb₂) end LipschitzOnWith namespace LocallyLipschitz variable [PseudoEMetricSpace α] [PseudoEMetricSpace β] [PseudoEMetricSpace γ] {f : α → β} /-- A Lipschitz function is locally Lipschitz. -/ protected lemma _root_.LipschitzWith.locallyLipschitz {K : ℝ≥0} (hf : LipschitzWith K f) : LocallyLipschitz f := fun _ ↦ ⟨K, univ, Filter.univ_mem, lipschitzOnWith_univ.mpr hf⟩ /-- The identity function is locally Lipschitz. -/ protected lemma id : LocallyLipschitz (@id α) := LipschitzWith.id.locallyLipschitz /-- Constant functions are locally Lipschitz. -/ protected lemma const (b : β) : LocallyLipschitz (fun _ : α ↦ b) := (LipschitzWith.const b).locallyLipschitz /-- A locally Lipschitz function is continuous. (The converse is false: for example, $x ↦ \sqrt{x}$ is continuous, but not locally Lipschitz at 0.) -/ protected theorem continuous {f : α → β} (hf : LocallyLipschitz f) : Continuous f := by rw [continuous_iff_continuousAt] intro x rcases (hf x) with ⟨K, t, ht, hK⟩ exact (hK.continuousOn).continuousAt ht /-- The composition of locally Lipschitz functions is locally Lipschitz. --/ protected lemma comp {f : β → γ} {g : α → β} (hf : LocallyLipschitz f) (hg : LocallyLipschitz g) : LocallyLipschitz (f ∘ g) := by intro x -- g is Lipschitz on t ∋ x, f is Lipschitz on u ∋ g(x) rcases hg x with ⟨Kg, t, ht, hgL⟩ rcases hf (g x) with ⟨Kf, u, hu, hfL⟩ refine ⟨Kf * Kg, t ∩ g⁻¹' u, inter_mem ht (hg.continuous.continuousAt hu), ?_⟩ exact hfL.comp (hgL.mono inter_subset_left) ((mapsTo_preimage g u).mono_left inter_subset_right) /-- If `f` and `g` are locally Lipschitz, so is the induced map `f × g` to the product type. -/ protected lemma prod {f : α → β} (hf : LocallyLipschitz f) {g : α → γ} (hg : LocallyLipschitz g) : LocallyLipschitz fun x => (f x, g x) := by intro x rcases hf x with ⟨Kf, t₁, h₁t, hfL⟩ rcases hg x with ⟨Kg, t₂, h₂t, hgL⟩ refine ⟨max Kf Kg, t₁ ∩ t₂, Filter.inter_mem h₁t h₂t, ?_⟩ exact (hfL.mono inter_subset_left).prod (hgL.mono inter_subset_right) protected theorem prod_mk_left (a : α) : LocallyLipschitz (Prod.mk a : β → α × β) := (LipschitzWith.prod_mk_left a).locallyLipschitz protected theorem prod_mk_right (b : β) : LocallyLipschitz (fun a : α => (a, b)) := (LipschitzWith.prod_mk_right b).locallyLipschitz protected theorem iterate {f : α → α} (hf : LocallyLipschitz f) : ∀ n, LocallyLipschitz f^[n] | 0 => by simpa only [pow_zero] using LocallyLipschitz.id | n + 1 => by rw [iterate_add, iterate_one]; exact (hf.iterate n).comp hf protected theorem mul_end {f g : Function.End α} (hf : LocallyLipschitz f) (hg : LocallyLipschitz g) : LocallyLipschitz (f * g : Function.End α) := hf.comp hg protected theorem pow_end {f : Function.End α} (h : LocallyLipschitz f) : ∀ n : ℕ, LocallyLipschitz (f ^ n : Function.End α) | 0 => by simpa only [pow_zero] using LocallyLipschitz.id | n + 1 => by rw [pow_succ] exact (h.pow_end n).mul_end h end LocallyLipschitz namespace LocallyLipschitzOn variable [PseudoEMetricSpace α] [PseudoEMetricSpace β] {f : α → β} {s : Set α} protected lemma continuousOn (hf : LocallyLipschitzOn s f) : ContinuousOn f s := continuousOn_iff_continuous_restrict.2 hf.restrict.continuous end LocallyLipschitzOn /-- Consider a function `f : α × β → γ`. Suppose that it is continuous on each “vertical fiber” `{a} × t`, `a ∈ s`, and is Lipschitz continuous on each “horizontal fiber” `s × {b}`, `b ∈ t` with the same Lipschitz constant `K`. Then it is continuous on `s × t`. Moreover, it suffices to require continuity on vertical fibers for `a` from a subset `s' ⊆ s` that is dense in `s`. The actual statement uses (Lipschitz) continuity of `fun y ↦ f (a, y)` and `fun x ↦ f (x, b)` instead of continuity of `f` on subsets of the product space. -/ theorem continuousOn_prod_of_subset_closure_continuousOn_lipschitzOnWith [PseudoEMetricSpace α] [TopologicalSpace β] [PseudoEMetricSpace γ] (f : α × β → γ) {s s' : Set α} {t : Set β} (hs' : s' ⊆ s) (hss' : s ⊆ closure s') (K : ℝ≥0) (ha : ∀ a ∈ s', ContinuousOn (fun y => f (a, y)) t) (hb : ∀ b ∈ t, LipschitzOnWith K (fun x => f (x, b)) s) : ContinuousOn f (s ×ˢ t) := by rintro ⟨x, y⟩ ⟨hx : x ∈ s, hy : y ∈ t⟩ refine EMetric.nhds_basis_closed_eball.tendsto_right_iff.2 fun ε (ε0 : 0 < ε) => ?_ replace ε0 : 0 < ε / 2 := ENNReal.half_pos ε0.ne' obtain ⟨δ, δpos, hδ⟩ : ∃ δ : ℝ≥0, 0 < δ ∧ (δ : ℝ≥0∞) * ↑(3 * K) < ε / 2 := ENNReal.exists_nnreal_pos_mul_lt ENNReal.coe_ne_top ε0.ne' rw [← ENNReal.coe_pos] at δpos rcases EMetric.mem_closure_iff.1 (hss' hx) δ δpos with ⟨x', hx', hxx'⟩ have A : s ∩ EMetric.ball x δ ∈ 𝓝[s] x := inter_mem_nhdsWithin _ (EMetric.ball_mem_nhds _ δpos) have B : t ∩ { b | edist (f (x', b)) (f (x', y)) ≤ ε / 2 } ∈ 𝓝[t] y := inter_mem self_mem_nhdsWithin (ha x' hx' y hy (EMetric.closedBall_mem_nhds (f (x', y)) ε0)) filter_upwards [nhdsWithin_prod A B] with ⟨a, b⟩ ⟨⟨has, hax⟩, ⟨hbt, hby⟩⟩ calc edist (f (a, b)) (f (x, y)) ≤ edist (f (a, b)) (f (x', b)) + edist (f (x', b)) (f (x', y)) + edist (f (x', y)) (f (x, y)) := edist_triangle4 _ _ _ _ _ ≤ K * (δ + δ) + ε / 2 + K * δ := by gcongr · refine (hb b hbt).edist_le_mul_of_le has (hs' hx') ?_ exact (edist_triangle _ _ _).trans (add_le_add (le_of_lt hax) hxx'.le) · exact hby · exact (hb y hy).edist_le_mul_of_le (hs' hx') hx ((edist_comm _ _).trans_le hxx'.le) _ = δ * ↑(3 * K) + ε / 2 := by push_cast; ring _ ≤ ε / 2 + ε / 2 := by gcongr _ = ε := ENNReal.add_halves _ /-- Consider a function `f : α × β → γ`. Suppose that it is continuous on each “vertical fiber” `{a} × t`, `a ∈ s`, and is Lipschitz continuous on each “horizontal fiber” `s × {b}`, `b ∈ t` with the same Lipschitz constant `K`. Then it is continuous on `s × t`. The actual statement uses (Lipschitz) continuity of `fun y ↦ f (a, y)` and `fun x ↦ f (x, b)` instead of continuity of `f` on subsets of the product space. -/ theorem continuousOn_prod_of_continuousOn_lipschitzOnWith [PseudoEMetricSpace α] [TopologicalSpace β] [PseudoEMetricSpace γ] (f : α × β → γ) {s : Set α} {t : Set β} (K : ℝ≥0) (ha : ∀ a ∈ s, ContinuousOn (fun y => f (a, y)) t) (hb : ∀ b ∈ t, LipschitzOnWith K (fun x => f (x, b)) s) : ContinuousOn f (s ×ˢ t) := continuousOn_prod_of_subset_closure_continuousOn_lipschitzOnWith f Subset.rfl subset_closure K ha hb /-- Consider a function `f : α × β → γ`. Suppose that it is continuous on each “vertical section” `{a} × univ` for `a : α` from a dense set. Suppose that it is Lipschitz continuous on each “horizontal section” `univ × {b}`, `b : β` with the same Lipschitz constant `K`. Then it is continuous. The actual statement uses (Lipschitz) continuity of `fun y ↦ f (a, y)` and `fun x ↦ f (x, b)` instead of continuity of `f` on subsets of the product space. -/ theorem continuous_prod_of_dense_continuous_lipschitzWith [PseudoEMetricSpace α] [TopologicalSpace β] [PseudoEMetricSpace γ] (f : α × β → γ) (K : ℝ≥0) {s : Set α} (hs : Dense s) (ha : ∀ a ∈ s, Continuous fun y => f (a, y)) (hb : ∀ b, LipschitzWith K fun x => f (x, b)) : Continuous f := by simp only [continuous_iff_continuousOn_univ, ← univ_prod_univ, ← lipschitzOnWith_univ] at * exact continuousOn_prod_of_subset_closure_continuousOn_lipschitzOnWith f (subset_univ _) hs.closure_eq.ge K ha fun b _ => hb b /-- Consider a function `f : α × β → γ`. Suppose that it is continuous on each “vertical section” `{a} × univ`, `a : α`, and is Lipschitz continuous on each “horizontal section” `univ × {b}`, `b : β` with the same Lipschitz constant `K`. Then it is continuous. The actual statement uses (Lipschitz) continuity of `fun y ↦ f (a, y)` and `fun x ↦ f (x, b)` instead of continuity of `f` on subsets of the product space. -/ theorem continuous_prod_of_continuous_lipschitzWith [PseudoEMetricSpace α] [TopologicalSpace β] [PseudoEMetricSpace γ] (f : α × β → γ) (K : ℝ≥0) (ha : ∀ a, Continuous fun y => f (a, y)) (hb : ∀ b, LipschitzWith K fun x => f (x, b)) : Continuous f := continuous_prod_of_dense_continuous_lipschitzWith f K dense_univ (fun _ _ ↦ ha _) hb
Topology\EMetricSpace\Paracompact.lean
/- Copyright (c) 202 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov -/ import Mathlib.SetTheory.Ordinal.Basic import Mathlib.Tactic.GCongr import Mathlib.Topology.EMetricSpace.Basic import Mathlib.Topology.Compactness.Paracompact /-! # (Extended) metric spaces are paracompact In this file we provide two instances: * `EMetric.instParacompactSpace`: a `PseudoEMetricSpace` is paracompact; formalization is based on [MR0236876]; * `EMetric.instNormalSpace`: an `EMetricSpace` is a normal topological space. ## TODO Generalize to `PseudoMetrizableSpace`s. ## Tags metric space, paracompact space, normal space -/ variable {α : Type*} open ENNReal Topology Set namespace EMetric -- See note [lower instance priority] /-- A `PseudoEMetricSpace` is always a paracompact space. Formalization is based on [MR0236876]. -/ instance (priority := 100) instParacompactSpace [PseudoEMetricSpace α] : ParacompactSpace α := by /- We start with trivial observations about `1 / 2 ^ k`. Here and below we use `1 / 2 ^ k` in the comments and `2⁻¹ ^ k` in the code. -/ have pow_pos : ∀ k : ℕ, (0 : ℝ≥0∞) < 2⁻¹ ^ k := fun k => ENNReal.pow_pos (ENNReal.inv_pos.2 ENNReal.two_ne_top) _ have hpow_le : ∀ {m n : ℕ}, m ≤ n → (2⁻¹ : ℝ≥0∞) ^ n ≤ 2⁻¹ ^ m := @fun m n h => pow_le_pow_right_of_le_one' (ENNReal.inv_le_one.2 ENNReal.one_lt_two.le) h have h2pow : ∀ n : ℕ, 2 * (2⁻¹ : ℝ≥0∞) ^ (n + 1) = 2⁻¹ ^ n := fun n => by simp [pow_succ', ← mul_assoc, ENNReal.mul_inv_cancel two_ne_zero two_ne_top] -- Consider an open covering `S : Set (Set α)` refine ⟨fun ι s ho hcov => ?_⟩ simp only [iUnion_eq_univ_iff] at hcov -- choose a well founded order on `S` -- Porting note (#11215): TODO: add lemma that claims `∃ i : LinearOrder ι, WellFoundedLT ι` let _ : LinearOrder ι := by classical exact linearOrderOfSTO WellOrderingRel have wf : WellFounded ((· < ·) : ι → ι → Prop) := @IsWellFounded.wf ι WellOrderingRel _ -- Let `ind x` be the minimal index `s : S` such that `x ∈ s`. set ind : α → ι := fun x => wf.min { i : ι | x ∈ s i } (hcov x) have mem_ind : ∀ x, x ∈ s (ind x) := fun x => wf.min_mem _ (hcov x) have nmem_of_lt_ind : ∀ {x i}, i < ind x → x ∉ s i := @fun x i hlt hxi => wf.not_lt_min _ (hcov x) hxi hlt /- The refinement `D : ℕ → ι → Set α` is defined recursively. For each `n` and `i`, `D n i` is the union of balls `ball x (1 / 2 ^ n)` over all points `x` such that * `ind x = i`; * `x` does not belong to any `D m j`, `m < n`; * `ball x (3 / 2 ^ n) ⊆ s i`; We define this sequence using `Nat.strongRecOn'`, then restate it as `Dn` and `memD`. -/ set D : ℕ → ι → Set α := fun n => Nat.strongRecOn' n fun n D' i => ⋃ (x : α) (hxs : ind x = i) (hb : ball x (3 * 2⁻¹ ^ n) ⊆ s i) (hlt : ∀ (m : ℕ) (H : m < n), ∀ (j : ι), x ∉ D' m H j), ball x (2⁻¹ ^ n) with hD have Dn : ∀ n i, D n i = ⋃ (x : α) (hxs : ind x = i) (hb : ball x (3 * 2⁻¹ ^ n) ⊆ s i) (hlt : ∀ m < n, ∀ (j : ι), x ∉ D m j), ball x (2⁻¹ ^ n) := fun n s => by simp only [hD] rw [Nat.strongRecOn'_beta] have memD : ∀ {n i y}, y ∈ D n i ↔ ∃ x : α, ind x = i ∧ ball x (3 * 2⁻¹ ^ n) ⊆ s i ∧ (∀ m < n, ∀ (j : ι), x ∉ D m j) ∧ edist y x < 2⁻¹ ^ n := by intro n i y rw [Dn n i] simp only [mem_iUnion, mem_ball, exists_prop] -- The sets `D n i` cover the whole space. Indeed, for each `x` we can choose `n` such that -- `ball x (3 / 2 ^ n) ⊆ s (ind x)`, then either `x ∈ D n i`, or `x ∈ D m i` for some `m < n`. have Dcov : ∀ x, ∃ n i, x ∈ D n i := fun x => by obtain ⟨n, hn⟩ : ∃ n : ℕ, ball x (3 * 2⁻¹ ^ n) ⊆ s (ind x) := by -- This proof takes 5 lines because we can't import `specific_limits` here rcases isOpen_iff.1 (ho <| ind x) x (mem_ind x) with ⟨ε, ε0, hε⟩ have : 0 < ε / 3 := ENNReal.div_pos_iff.2 ⟨ε0.lt.ne', ENNReal.coe_ne_top⟩ rcases ENNReal.exists_inv_two_pow_lt this.ne' with ⟨n, hn⟩ refine ⟨n, Subset.trans (ball_subset_ball ?_) hε⟩ simpa only [div_eq_mul_inv, mul_comm] using (ENNReal.mul_lt_of_lt_div hn).le by_contra! h apply h n (ind x) exact memD.2 ⟨x, rfl, hn, fun _ _ _ => h _ _, mem_ball_self (pow_pos _)⟩ -- Each `D n i` is a union of open balls, hence it is an open set have Dopen : ∀ n i, IsOpen (D n i) := fun n i => by rw [Dn] iterate 4 refine isOpen_iUnion fun _ => ?_ exact isOpen_ball -- the covering `D n i` is a refinement of the original covering: `D n i ⊆ s i` have HDS : ∀ n i, D n i ⊆ s i := fun n i x => by rw [memD] rintro ⟨y, rfl, hsub, -, hyx⟩ refine hsub (hyx.trans_le <| le_mul_of_one_le_left' ?_) norm_num1 -- Let us show the rest of the properties. Since the definition expects a family indexed -- by a single parameter, we use `ℕ × ι` as the domain. refine ⟨ℕ × ι, fun ni => D ni.1 ni.2, fun _ => Dopen _ _, ?_, ?_, fun ni => ⟨ni.2, HDS _ _⟩⟩ -- The sets `D n i` cover the whole space as we proved earlier · refine iUnion_eq_univ_iff.2 fun x ↦ ?_ rcases Dcov x with ⟨n, i, h⟩ exact ⟨⟨n, i⟩, h⟩ /- Let us prove that the covering `D n i` is locally finite. Take a point `x` and choose `n`, `i` so that `x ∈ D n i`. Since `D n i` is an open set, we can choose `k` so that `B = ball x (1 / 2 ^ (n + k + 1)) ⊆ D n i`. -/ · intro x rcases Dcov x with ⟨n, i, hn⟩ have : D n i ∈ 𝓝 x := IsOpen.mem_nhds (Dopen _ _) hn rcases (nhds_basis_uniformity uniformity_basis_edist_inv_two_pow).mem_iff.1 this with ⟨k, -, hsub : ball x (2⁻¹ ^ k) ⊆ D n i⟩ set B := ball x (2⁻¹ ^ (n + k + 1)) refine ⟨B, ball_mem_nhds _ (pow_pos _), ?_⟩ -- The sets `D m i`, `m > n + k`, are disjoint with `B` have Hgt : ∀ m ≥ n + k + 1, ∀ (i : ι), Disjoint (D m i) B := fun m hm i => by rw [disjoint_iff_inf_le] rintro y ⟨hym, hyx⟩ rcases memD.1 hym with ⟨z, rfl, _hzi, H, hz⟩ have : z ∉ ball x (2⁻¹ ^ k) := fun hz' => H n (by omega) i (hsub hz') apply this calc edist z x ≤ edist y z + edist y x := edist_triangle_left _ _ _ _ < 2⁻¹ ^ m + 2⁻¹ ^ (n + k + 1) := ENNReal.add_lt_add hz hyx _ ≤ 2⁻¹ ^ (k + 1) + 2⁻¹ ^ (k + 1) := (add_le_add (hpow_le <| by omega) (hpow_le <| by omega)) _ = 2⁻¹ ^ k := by rw [← two_mul, h2pow] -- For each `m ≤ n + k` there is at most one `j` such that `D m j ∩ B` is nonempty. have Hle : ∀ m ≤ n + k, Set.Subsingleton { j | (D m j ∩ B).Nonempty } := by rintro m hm j₁ ⟨y, hyD, hyB⟩ j₂ ⟨z, hzD, hzB⟩ by_contra! h' : j₁ ≠ j₂ wlog h : j₁ < j₂ generalizing j₁ j₂ y z · exact this z hzD hzB y hyD hyB h'.symm (h'.lt_or_lt.resolve_left h) rcases memD.1 hyD with ⟨y', rfl, hsuby, -, hdisty⟩ rcases memD.1 hzD with ⟨z', rfl, -, -, hdistz⟩ suffices edist z' y' < 3 * 2⁻¹ ^ m from nmem_of_lt_ind h (hsuby this) calc edist z' y' ≤ edist z' x + edist x y' := edist_triangle _ _ _ _ ≤ edist z z' + edist z x + (edist y x + edist y y') := (add_le_add (edist_triangle_left _ _ _) (edist_triangle_left _ _ _)) _ < 2⁻¹ ^ m + 2⁻¹ ^ (n + k + 1) + (2⁻¹ ^ (n + k + 1) + 2⁻¹ ^ m) := by apply_rules [ENNReal.add_lt_add] _ = 2 * (2⁻¹ ^ m + 2⁻¹ ^ (n + k + 1)) := by simp only [two_mul, add_comm] _ ≤ 2 * (2⁻¹ ^ m + 2⁻¹ ^ (m + 1)) := by gcongr 2 * (_ + ?_); exact hpow_le (add_le_add hm le_rfl) _ = 3 * 2⁻¹ ^ m := by rw [mul_add, h2pow, ← two_add_one_eq_three, add_mul, one_mul] -- Finally, we glue `Hgt` and `Hle` have : (⋃ (m ≤ n + k) (i ∈ { i : ι | (D m i ∩ B).Nonempty }), {(m, i)}).Finite := (finite_le_nat _).biUnion' fun i hi => (Hle i hi).finite.biUnion' fun _ _ => finite_singleton _ refine this.subset fun I hI => ?_ simp only [mem_iUnion] refine ⟨I.1, ?_, I.2, hI, rfl⟩ exact not_lt.1 fun hlt => (Hgt I.1 hlt I.2).le_bot hI.choose_spec -- Porting note: no longer an instance because `inferInstance` can find it theorem t4Space [EMetricSpace α] : T4Space α := inferInstance end EMetric
Topology\FiberBundle\Basic.lean
/- Copyright (c) 2019 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel, Floris van Doorn, Heather Macbeth -/ 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 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 #13052 and #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 #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 can not 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_inducing' : ∀ b : B, Inducing (@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_inducing : Inducing (@TotalSpace.mk B F E b) := totalSpaceMk_inducing' 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_inducing 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 quotientMap_proj [Nonempty F] : QuotientMap (π F E) := (isOpenMap_proj F E).to_quotientMap (continuous_proj F E) (surjective_proj F E) theorem continuous_totalSpaceMk (x : B) : Continuous (@TotalSpace.mk B F E x) := (totalSpaceMk_inducing F E x).continuous theorem totalSpaceMk_embedding (x : B) : Embedding (@TotalSpace.mk B F E x) := ⟨totalSpaceMk_inducing F E x, TotalSpace.mk_injective x⟩ theorem totalSpaceMk_closedEmbedding [T1Space B] (x : B) : ClosedEmbedding (@TotalSpace.mk B F E x) := ⟨totalSpaceMk_embedding 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 -- Porting note: removed `@[simp, mfld_simps]` because `simp` could already prove this 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 cases' lt_or_le b a with hab 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_nhdsWithin_Iic_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_lt 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_nhdsWithin_Ici_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`. -/ -- Porting note(#5171): was @[nolint has_nonempty_instance] 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] -- Porting note(#5171): was has_nonempty_instance 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] -- Porting note(#5171): was has_nonempty_instance 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 : ι) : PartialHomeomorph (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 [prod_mk_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 [prod_mk_mem_set_prod_eq, mem_inter_iff, and_true_iff, 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.prod (Z.continuousOn_coordChange i j) continuousOn_invFun := by simpa [inter_comm] using continuous_fst.continuousOn.prod (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 erw [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 a 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_iff, Set.mem_univ, Set.prod_mk_mem_set_prod_eq] using hp map_target' p hp := by simpa only [Set.mem_preimage, and_true_iff, 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 [prod_mk_mem_set_prod_eq, and_true_iff, 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 erw [mem_prod] simp only [and_true_iff, 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, true_and_iff, Prod.mk.inj_iff, prod_mk_mem_set_prod_eq, PartialEquiv.trans_source, mem_inter_iff, and_true_iff, mem_preimage, proj, mem_univ, eq_self_iff_true, (· ∘ ·), PartialEquiv.coe_trans, TotalSpace.proj] 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, prod_mk_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 [PartialEquiv.right_inv, preimage_inter, PartialEquiv.left_inv] 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).toPartialHomeomorph.continuousAt_iff_continuousAt_comp_left ?_).2 ?_ · exact A · apply continuousAt_id.prod simp only [(· ∘ ·), mfld_simps, localTrivAt_snd] 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).toPartialHomeomorph.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 -- Porting note (#10618): was @[simp, mfld_simps], now `simp` can prove it 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_inducing' b := inducing_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 [(· ∘ ·), localTrivAt_apply_mk, Trivialization.coe_coe, ← (embedding_prod_mk 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 partial homeomorphisms and hence local trivializations. -/ -- Porting note (#5171): was @[nolint has_nonempty_instance] 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_inducing : ∀ b : B, Inducing (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, TotalSpace.proj] 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.toPartialHomeomorph.continuous_iff_continuous_comp_left (a.totalSpaceMk_preimage_source b)] exact continuous_iff_le_induced.mpr (le_antisymm_iff.mp (a.totalSpaceMk_inducing b).induced).1 theorem inducing_totalSpaceMk_of_inducing_comp (b : B) (h : Inducing (a.pretrivializationAt b ∘ TotalSpace.mk b)) : @Inducing _ _ _ a.totalSpaceTopology (TotalSpace.mk b) := by letI := a.totalSpaceTopology rw [← restrict_comp_codRestrict (a.mem_pretrivializationAt_source b)] at h apply Inducing.of_codRestrict (a.mem_pretrivializationAt_source b) refine inducing_of_inducing_compose ?_ (continuousOn_iff_continuous_restrict.mp (a.trivializationOfMemPretrivializationAtlas (a.pretrivialization_mem_atlas b)).continuousOn_toFun) h 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_inducing' := fun b ↦ a.inducing_totalSpaceMk_of_inducing_comp b (a.totalSpaceMk_inducing 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
Topology\FiberBundle\Constructions.lean
/- Copyright (c) 2022 Nicolò Cavalleri. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nicolò Cavalleri, Sébastien Gouëzel, Heather Macbeth, Floris van Doorn -/ 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 TopologicalSpace Filter Set Bundle open scoped Classical open Topology Bundle /-! ### The trivial bundle -/ namespace Bundle namespace Trivial variable (B : Type*) (F : Type*) -- Porting note (#10754): Added name for this instance. -- 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 inducing_toProd : Inducing (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. -/ def homeomorphProd : TotalSpace F (Trivial B F) ≃ₜ B × F := (TotalSpace.toProd _ _).toHomeomorphOfInducing (inducing_toProd B F) /-- Local trivialization for trivial bundle. -/ def trivialization : Trivialization F (π F (Bundle.Trivial B F)) where -- Porting note: golfed toPartialHomeomorph := (homeomorphProd B F).toPartialHomeomorph baseSet := univ open_baseSet := isOpen_univ source_eq := rfl target_eq := univ_prod_univ.symm proj_toFun _ _ := rfl @[simp] theorem trivialization_source : (trivialization B F).source = univ := rfl @[simp] theorem trivialization_target : (trivialization B F).target = univ := rfl /-- Fiber bundle instance on the trivial bundle. -/ 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_inducing' _ := (homeomorphProd B F).symm.inducing.comp (inducing_const_prod.2 inducing_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 `Inducing`. -/ theorem FiberBundle.Prod.inducing_diag : Inducing (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.inducing_diag F₁ E₁ F₂ E₂).continuous have hf₂ : ContinuousOn f₂ (e₁.source ×ˢ e₂.source) := e₁.toPartialHomeomorph.continuousOn.prod_map e₂.toPartialHomeomorph.continuousOn have hf₃ : Continuous f₃ := (continuous_fst.comp continuous_fst).prod_mk (continuous_snd.prod_map continuous_snd) 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₃, Prod.toFun', Prod.mk.inj_iff, Function.comp_apply, and_true_iff] 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.inducing_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)) := (continuous_id.prod_map continuous_fst).prod_mk (continuous_id.prod_map continuous_snd) refine (e₁.continuousOn_symm.prod_map 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`. -/ 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' x h := ⟨h, Set.mem_univ _⟩ map_target' x h := h.1 left_inv' x := Prod.left_inv right_inv' x := Prod.right_inv open_source := by convert (e₁.open_source.prod e₂.open_source).preimage (FiberBundle.Prod.inducing_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 x _ := rfl @[simp] theorem baseSet_prod : (prod e₁ e₂).baseSet = e₁.baseSet ∩ e₂.baseSet := rfl 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. -/ noncomputable instance FiberBundle.prod : FiberBundle (F₁ × F₂) (E₁ ×ᵇ E₂) where totalSpaceMk_inducing' b := by rw [← (Prod.inducing_diag F₁ E₁ F₂ E₂).of_comp_iff] exact (totalSpaceMk_inducing F₁ E₁ b).prod_map (totalSpaceMk_inducing 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) := by -- Porting note: Original proof was `delta_instance Bundle.Pullback` intro x rw [Bundle.Pullback] infer_instance 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) : Inducing (@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, induced_const, top_inf_eq, pullbackTopology_def] exact le_of_eq (FiberBundle.totalSpaceMk_inducing F E (f x)).induced variable {E F} variable [∀ _b, Zero (E _b)] {K : Type U} [FunLike K B' B] [ContinuousMapClass K B' B] -- Porting note: universe levels are explicitly provided /-- A fiber bundle trivialization can be pulled back to a trivialization on the pullback bundle. -/ 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 [prod_mk_mem_set_prod_eq, mem_univ, and_true_iff, 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_iff] 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.prod (continuous_snd.comp_continuousOn <| e.continuousOn.comp (Pullback.continuous_lift F E f).continuousOn Subset.rfl) continuousOn_invFun := by dsimp only simp_rw [(inducing_pullbackTotalSpaceEmbedding F E f).continuousOn_iff, Function.comp, pullbackTotalSpaceEmbedding] refine continuousOn_fst.prod (e.continuousOn_symm.comp ((map_continuous f).prod_map continuous_id).continuousOn Subset.rfl) source_eq := by dsimp only rw [e.source_eq] rfl target_eq := rfl proj_toFun y _ := rfl noncomputable instance FiberBundle.pullback [∀ x, TopologicalSpace (E x)] [FiberBundle F E] (f : K) : FiberBundle F ((f : B' → B) *ᵖ E) where totalSpaceMk_inducing' x := inducing_of_inducing_compose (Pullback.continuous_totalSpaceMk F E) (Pullback.continuous_lift F E f) (totalSpaceMk_inducing F E (f x)) 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
Topology\FiberBundle\IsHomeomorphicTrivialBundle.lean
/- Copyright (c) 2019 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Topology.Homeomorph /-! # 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. -/ 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 quotientMap_proj [Nonempty F] (h : IsHomeomorphicTrivialFiberBundle F proj) : QuotientMap proj := h.isOpenMap_proj.to_quotientMap 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⟩
Topology\FiberBundle\Trivialization.lean
/- Copyright (c) 2019 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Data.Bundle import Mathlib.Data.Set.Image import Mathlib.Topology.PartialHomeomorph import Mathlib.Topology.Order.Basic /-! # Trivializations ## Main definitions ### Basic definitions * `Trivialization F p` : structure extending 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 leanprover-community/mathlib#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 {ι : Type*} {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 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 -- Porting note (#11215): 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, PartialEquiv.invFun_as_coe, 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 [prod_mk_mem_set_prod_eq, mem_inter_iff, and_true_iff, 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)) {x' : TotalSpace F E} {b : B} {y : E b} @[simp] 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 {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_not_mem (e : Pretrivialization F (π F E)) {b : B} (hb : b ∉ e.baseSet) (y : F) : e.symm b y = 0 := dif_neg hb theorem coe_symm_of_not_mem (e : Pretrivialization F (π F E)) {b : B} (hb : b ∉ e.baseSet) : (e.symm b : F → E b) = 0 := funext fun _ => dif_neg hb 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 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 partial homeomorphisms, defining a local trivialization of a projection `proj : Z → B` with fiber `F`, as a 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. -/ -- Porting note (#5171): was @[nolint has_nonempty_instance] structure Trivialization (proj : Z → B) extends PartialHomeomorph Z (B × F) where baseSet : Set B open_baseSet : IsOpen baseSet source_eq : source = proj ⁻¹' baseSet target_eq : target = baseSet ×ˢ univ proj_toFun : ∀ p ∈ source, (toPartialHomeomorph 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.toPartialHomeomorph = e'.toPartialHomeomorph) (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⟩ theorem toPretrivialization_injective : Function.Injective fun e : Trivialization F proj => e.toPretrivialization := fun e e' h => by ext1 exacts [PartialHomeomorph.toPartialEquiv_injective (congr_arg Pretrivialization.toPartialEquiv h), congr_arg Pretrivialization.baseSet h] @[simp, mfld_simps] theorem coe_coe : ⇑e.toPartialHomeomorph = 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.toPartialHomeomorph.source_inter_preimage_target_inter s @[simp, mfld_simps] theorem coe_mk (e : PartialHomeomorph 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.toPartialHomeomorph.symm x ∈ e.source := e.toPartialHomeomorph.map_target hx theorem proj_symm_apply {x : B × F} (hx : x ∈ e.target) : proj (e.toPartialHomeomorph.symm x) = x.1 := e.toPretrivialization.proj_symm_apply hx theorem proj_symm_apply' {b : B} {x : F} (hx : b ∈ e.baseSet) : proj (e.toPartialHomeomorph.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.toPartialHomeomorph.symm x) = x := e.toPartialHomeomorph.right_inv hx theorem apply_symm_apply' {b : B} {x : F} (hx : b ∈ e.baseSet) : e (e.toPartialHomeomorph.symm (b, x)) = (b, x) := e.toPretrivialization.apply_symm_apply' hx @[simp, mfld_simps] theorem symm_apply_mk_proj (ex : x ∈ e.source) : e.toPartialHomeomorph.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.toPartialHomeomorph.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 /-- Auxilliary 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⟩ /-- Auxilliary 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 /-- Composition of a `Trivialization` and a `Homeomorph`. -/ protected def compHomeomorph {Z' : Type*} [TopologicalSpace Z'] (h : Z' ≃ₜ Z) : Trivialization F (proj ∘ h) where toPartialHomeomorph := h.toPartialHomeomorph.trans e.toPartialHomeomorph baseSet := e.baseSet open_baseSet := e.open_baseSet source_eq := by simp [source_eq, preimage_preimage, (· ∘ ·)] 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.toPartialHomeomorph.symm.continuousAt_iff_continuousAt_comp_right hez, PartialHomeomorph.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)) {x' : TotalSpace 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'.toPartialHomeomorph.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.toPartialHomeomorph.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.toPartialHomeomorph.symm (b, y)).2 := dif_pos hb theorem symm_apply_of_not_mem (e : Trivialization F (π F E)) {b : B} (hb : b ∉ e.baseSet) (y : F) : e.symm b y = 0 := dif_neg hb theorem mk_symm (e : Trivialization F (π F E)) {b : B} (hb : b ∈ e.baseSet) (y : F) : TotalSpace.mk b (e.symm b y) = e.toPartialHomeomorph.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 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.toPartialHomeomorph.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.toPartialHomeomorph.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 toPartialHomeomorph := e.toPartialHomeomorph.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₁.toPartialHomeomorph.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₁.toPartialHomeomorph.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₂.toPartialHomeomorph.continuousOn.comp_continuous (e₁.toPartialHomeomorph.continuousOn_symm.comp_continuous ?_ ?_) ?_) · exact continuous_const.prod_mk continuous_id · 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 variable {B' : Type*} [TopologicalSpace B'] theorem isImage_preimage_prod (e : Trivialization F proj) (s : Set B) : e.toPartialHomeomorph.IsImage (proj ⁻¹' s) (s ×ˢ univ) := fun x hx => by simp [e.coe_fst', 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 toPartialHomeomorph := ((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 toPartialHomeomorph := e.toPartialHomeomorph.piecewise e'.toPartialHomeomorph (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 toPartialHomeomorph := e.toPartialHomeomorph.disjointUnion e'.toPartialHomeomorph (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') · show (e.source.piecewise e e' p).1 = proj p rw [piecewise_eq_of_mem, e.coe_fst] <;> exact hp · show (e.source.piecewise e e' p).1 = proj p rw [piecewise_eq_of_not_mem, e'.coe_fst hp'] simp only [source_eq] at hp' ⊢ exact fun h => H.le_bot ⟨h, hp'⟩ end Piecewise end Trivialization
Topology\Hom\Open.lean
/- Copyright (c) 2022 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Topology.ContinuousFunction.Basic /-! # Continuous open maps This file defines bundled continuous open maps. We use the `DFunLike` design, so each type of morphisms has a companion typeclass which is meant to be satisfied by itself and all stricter types. ## Types of morphisms * `ContinuousOpenMap`: Continuous open maps. ## Typeclasses * `ContinuousOpenMapClass` -/ open Function variable {F α β γ δ : Type*} /-- The type of continuous open maps from `α` to `β`, aka Priestley homomorphisms. -/ structure ContinuousOpenMap (α β : Type*) [TopologicalSpace α] [TopologicalSpace β] extends ContinuousMap α β where map_open' : IsOpenMap toFun infixr:25 " →CO " => ContinuousOpenMap section /-- `ContinuousOpenMapClass F α β` states that `F` is a type of continuous open maps. You should extend this class when you extend `ContinuousOpenMap`. -/ class ContinuousOpenMapClass (F : Type*) (α β : outParam Type*) [TopologicalSpace α] [TopologicalSpace β] [FunLike F α β] extends ContinuousMapClass F α β : Prop where map_open (f : F) : IsOpenMap f end export ContinuousOpenMapClass (map_open) instance [TopologicalSpace α] [TopologicalSpace β] [FunLike F α β] [ContinuousOpenMapClass F α β] : CoeTC F (α →CO β) := ⟨fun f => ⟨f, map_open f⟩⟩ /-! ### Continuous open maps -/ namespace ContinuousOpenMap variable [TopologicalSpace α] [TopologicalSpace β] [TopologicalSpace γ] [TopologicalSpace δ] instance instFunLike : FunLike (α →CO β) α β where coe f := f.toFun coe_injective' f g h := by obtain ⟨⟨_, _⟩, _⟩ := f obtain ⟨⟨_, _⟩, _⟩ := g congr instance : ContinuousOpenMapClass (α →CO β) α β where map_continuous f := f.continuous_toFun map_open f := f.map_open' theorem toFun_eq_coe {f : α →CO β} : f.toFun = (f : α → β) := rfl @[simp] -- Porting note: new, simpNF of `toFun_eq_coe` theorem coe_toContinuousMap (f : α →CO β) : (f.toContinuousMap : α → β) = f := rfl @[ext] theorem ext {f g : α →CO β} (h : ∀ a, f a = g a) : f = g := DFunLike.ext f g h /-- Copy of a `ContinuousOpenMap` with a new `ContinuousMap` equal to the old one. Useful to fix definitional equalities. -/ protected def copy (f : α →CO β) (f' : α → β) (h : f' = f) : α →CO β := ⟨f.toContinuousMap.copy f' <| h, h.symm.subst f.map_open'⟩ @[simp] theorem coe_copy (f : α →CO β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' := rfl theorem copy_eq (f : α →CO β) (f' : α → β) (h : f' = f) : f.copy f' h = f := DFunLike.ext' h variable (α) /-- `id` as a `ContinuousOpenMap`. -/ protected def id : α →CO α := ⟨ContinuousMap.id _, IsOpenMap.id⟩ instance : Inhabited (α →CO α) := ⟨ContinuousOpenMap.id _⟩ @[simp] theorem coe_id : ⇑(ContinuousOpenMap.id α) = id := rfl variable {α} @[simp] theorem id_apply (a : α) : ContinuousOpenMap.id α a = a := rfl /-- Composition of `ContinuousOpenMap`s as a `ContinuousOpenMap`. -/ def comp (f : β →CO γ) (g : α →CO β) : ContinuousOpenMap α γ := ⟨f.toContinuousMap.comp g.toContinuousMap, f.map_open'.comp g.map_open'⟩ @[simp] theorem coe_comp (f : β →CO γ) (g : α →CO β) : (f.comp g : α → γ) = f ∘ g := rfl @[simp] theorem comp_apply (f : β →CO γ) (g : α →CO β) (a : α) : (f.comp g) a = f (g a) := rfl @[simp] theorem comp_assoc (f : γ →CO δ) (g : β →CO γ) (h : α →CO β) : (f.comp g).comp h = f.comp (g.comp h) := rfl @[simp] theorem comp_id (f : α →CO β) : f.comp (ContinuousOpenMap.id α) = f := ext fun _ => rfl @[simp] theorem id_comp (f : α →CO β) : (ContinuousOpenMap.id β).comp f = f := ext fun _ => rfl @[simp] theorem cancel_right {g₁ g₂ : β →CO γ} {f : α →CO β} (hf : Surjective f) : g₁.comp f = g₂.comp f ↔ g₁ = g₂ := ⟨fun h => ext <| hf.forall.2 <| DFunLike.ext_iff.1 h, fun h => congr_arg₂ _ h rfl⟩ @[simp] theorem cancel_left {g : β →CO γ} {f₁ f₂ : α →CO β} (hg : Injective g) : g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ := ⟨fun h => ext fun a => hg <| by rw [← comp_apply, h, comp_apply], congr_arg _⟩ end ContinuousOpenMap
Topology\Homotopy\Basic.lean
/- Copyright (c) 2021 Shing Tak Lam. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Shing Tak Lam -/ import Mathlib.Topology.Order.ProjIcc import Mathlib.Topology.ContinuousFunction.Ordered import Mathlib.Topology.CompactOpen import Mathlib.Topology.UnitInterval /-! # Homotopy between functions In this file, we define a homotopy between two functions `f₀` and `f₁`. First we define `ContinuousMap.Homotopy` between the two functions, with no restrictions on the intermediate maps. Then, as in the formalisation in HOL-Analysis, we define `ContinuousMap.HomotopyWith f₀ f₁ P`, for homotopies between `f₀` and `f₁`, where the intermediate maps satisfy the predicate `P`. Finally, we define `ContinuousMap.HomotopyRel f₀ f₁ S`, for homotopies between `f₀` and `f₁` which are fixed on `S`. ## Definitions * `ContinuousMap.Homotopy f₀ f₁` is the type of homotopies between `f₀` and `f₁`. * `ContinuousMap.HomotopyWith f₀ f₁ P` is the type of homotopies between `f₀` and `f₁`, where the intermediate maps satisfy the predicate `P`. * `ContinuousMap.HomotopyRel f₀ f₁ S` is the type of homotopies between `f₀` and `f₁` which are fixed on `S`. For each of the above, we have * `refl f`, which is the constant homotopy from `f` to `f`. * `symm F`, which reverses the homotopy `F`. For example, if `F : ContinuousMap.Homotopy f₀ f₁`, then `F.symm : ContinuousMap.Homotopy f₁ f₀`. * `trans F G`, which concatenates the homotopies `F` and `G`. For example, if `F : ContinuousMap.Homotopy f₀ f₁` and `G : ContinuousMap.Homotopy f₁ f₂`, then `F.trans G : ContinuousMap.Homotopy f₀ f₂`. We also define the relations * `ContinuousMap.Homotopic f₀ f₁` is defined to be `Nonempty (ContinuousMap.Homotopy f₀ f₁)` * `ContinuousMap.HomotopicWith f₀ f₁ P` is defined to be `Nonempty (ContinuousMap.HomotopyWith f₀ f₁ P)` * `ContinuousMap.HomotopicRel f₀ f₁ P` is defined to be `Nonempty (ContinuousMap.HomotopyRel f₀ f₁ P)` and for `ContinuousMap.homotopic` and `ContinuousMap.homotopic_rel`, we also define the `setoid` and `quotient` in `C(X, Y)` by these relations. ## References - [HOL-Analysis formalisation](https://isabelle.in.tum.de/library/HOL/HOL-Analysis/Homotopy.html) -/ noncomputable section universe u v w x variable {F : Type*} {X : Type u} {Y : Type v} {Z : Type w} {Z' : Type x} {ι : Type*} variable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] [TopologicalSpace Z'] open unitInterval namespace ContinuousMap /-- `ContinuousMap.Homotopy f₀ f₁` is the type of homotopies from `f₀` to `f₁`. When possible, instead of parametrizing results over `(f : Homotopy f₀ f₁)`, you should parametrize over `{F : Type*} [HomotopyLike F f₀ f₁] (f : F)`. When you extend this structure, make sure to extend `ContinuousMap.HomotopyLike`. -/ structure Homotopy (f₀ f₁ : C(X, Y)) extends C(I × X, Y) where /-- value of the homotopy at 0 -/ map_zero_left : ∀ x, toFun (0, x) = f₀ x /-- value of the homotopy at 1 -/ map_one_left : ∀ x, toFun (1, x) = f₁ x section /-- `ContinuousMap.HomotopyLike F f₀ f₁` states that `F` is a type of homotopies between `f₀` and `f₁`. You should extend this class when you extend `ContinuousMap.Homotopy`. -/ class HomotopyLike {X Y : outParam Type*} [TopologicalSpace X] [TopologicalSpace Y] (F : Type*) (f₀ f₁ : outParam <| C(X, Y)) [FunLike F (I × X) Y] extends ContinuousMapClass F (I × X) Y : Prop where /-- value of the homotopy at 0 -/ map_zero_left (f : F) : ∀ x, f (0, x) = f₀ x /-- value of the homotopy at 1 -/ map_one_left (f : F) : ∀ x, f (1, x) = f₁ x end namespace Homotopy section variable {f₀ f₁ : C(X, Y)} instance instFunLike : FunLike (Homotopy f₀ f₁) (I × X) Y where coe f := f.toFun coe_injective' f g h := by obtain ⟨⟨_, _⟩, _⟩ := f obtain ⟨⟨_, _⟩, _⟩ := g congr instance : HomotopyLike (Homotopy f₀ f₁) f₀ f₁ where map_continuous f := f.continuous_toFun map_zero_left f := f.map_zero_left map_one_left f := f.map_one_left @[ext] theorem ext {F G : Homotopy f₀ f₁} (h : ∀ x, F x = G x) : F = G := DFunLike.ext _ _ h /-- 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 (F : Homotopy f₀ f₁) : I × X → Y := F initialize_simps_projections Homotopy (toFun → apply, -toContinuousMap) /-- Deprecated. Use `map_continuous` instead. -/ protected theorem continuous (F : Homotopy f₀ f₁) : Continuous F := F.continuous_toFun @[simp] theorem apply_zero (F : Homotopy f₀ f₁) (x : X) : F (0, x) = f₀ x := F.map_zero_left x @[simp] theorem apply_one (F : Homotopy f₀ f₁) (x : X) : F (1, x) = f₁ x := F.map_one_left x @[simp] theorem coe_toContinuousMap (F : Homotopy f₀ f₁) : ⇑F.toContinuousMap = F := rfl /-- Currying a homotopy to a continuous function from `I` to `C(X, Y)`. -/ def curry (F : Homotopy f₀ f₁) : C(I, C(X, Y)) := F.toContinuousMap.curry @[simp] theorem curry_apply (F : Homotopy f₀ f₁) (t : I) (x : X) : F.curry t x = F (t, x) := rfl /-- Continuously extending a curried homotopy to a function from `ℝ` to `C(X, Y)`. -/ def extend (F : Homotopy f₀ f₁) : C(ℝ, C(X, Y)) := F.curry.IccExtend zero_le_one theorem extend_apply_of_le_zero (F : Homotopy f₀ f₁) {t : ℝ} (ht : t ≤ 0) (x : X) : F.extend t x = f₀ x := by rw [← F.apply_zero] exact ContinuousMap.congr_fun (Set.IccExtend_of_le_left (zero_le_one' ℝ) F.curry ht) x theorem extend_apply_of_one_le (F : Homotopy f₀ f₁) {t : ℝ} (ht : 1 ≤ t) (x : X) : F.extend t x = f₁ x := by rw [← F.apply_one] exact ContinuousMap.congr_fun (Set.IccExtend_of_right_le (zero_le_one' ℝ) F.curry ht) x @[simp] theorem extend_apply_coe (F : Homotopy f₀ f₁) (t : I) (x : X) : F.extend t x = F (t, x) := ContinuousMap.congr_fun (Set.IccExtend_val (zero_le_one' ℝ) F.curry t) x @[simp] theorem extend_apply_of_mem_I (F : Homotopy f₀ f₁) {t : ℝ} (ht : t ∈ I) (x : X) : F.extend t x = F (⟨t, ht⟩, x) := ContinuousMap.congr_fun (Set.IccExtend_of_mem (zero_le_one' ℝ) F.curry ht) x protected theorem congr_fun {F G : Homotopy f₀ f₁} (h : F = G) (x : I × X) : F x = G x := ContinuousMap.congr_fun (congr_arg _ h) x protected theorem congr_arg (F : Homotopy f₀ f₁) {x y : I × X} (h : x = y) : F x = F y := F.toContinuousMap.congr_arg h end /-- Given a continuous function `f`, we can define a `Homotopy f f` by `F (t, x) = f x` -/ @[simps] def refl (f : C(X, Y)) : Homotopy f f where toFun x := f x.2 map_zero_left _ := rfl map_one_left _ := rfl instance : Inhabited (Homotopy (ContinuousMap.id X) (ContinuousMap.id X)) := ⟨Homotopy.refl _⟩ /-- Given a `Homotopy f₀ f₁`, we can define a `Homotopy f₁ f₀` by reversing the homotopy. -/ @[simps] def symm {f₀ f₁ : C(X, Y)} (F : Homotopy f₀ f₁) : Homotopy f₁ f₀ where toFun x := F (σ x.1, x.2) map_zero_left := by norm_num map_one_left := by norm_num @[simp] theorem symm_symm {f₀ f₁ : C(X, Y)} (F : Homotopy f₀ f₁) : F.symm.symm = F := by ext simp theorem symm_bijective {f₀ f₁ : C(X, Y)} : Function.Bijective (Homotopy.symm : Homotopy f₀ f₁ → Homotopy f₁ f₀) := Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩ /-- Given `Homotopy f₀ f₁` and `Homotopy f₁ f₂`, we can define a `Homotopy f₀ f₂` by putting the first homotopy on `[0, 1/2]` and the second on `[1/2, 1]`. -/ def trans {f₀ f₁ f₂ : C(X, Y)} (F : Homotopy f₀ f₁) (G : Homotopy f₁ f₂) : Homotopy f₀ f₂ where toFun x := if (x.1 : ℝ) ≤ 1 / 2 then F.extend (2 * x.1) x.2 else G.extend (2 * x.1 - 1) x.2 continuous_toFun := by refine continuous_if_le (continuous_induced_dom.comp continuous_fst) continuous_const (F.continuous.comp (by continuity)).continuousOn (G.continuous.comp (by continuity)).continuousOn ?_ rintro x hx norm_num [hx] map_zero_left x := by norm_num map_one_left x := by norm_num theorem trans_apply {f₀ f₁ f₂ : C(X, Y)} (F : Homotopy f₀ f₁) (G : Homotopy f₁ f₂) (x : I × X) : (F.trans G) x = if h : (x.1 : ℝ) ≤ 1 / 2 then F (⟨2 * x.1, (unitInterval.mul_pos_mem_iff zero_lt_two).2 ⟨x.1.2.1, h⟩⟩, x.2) else G (⟨2 * x.1 - 1, unitInterval.two_mul_sub_one_mem_iff.2 ⟨(not_le.1 h).le, x.1.2.2⟩⟩, x.2) := show ite _ _ _ = _ by split_ifs <;> · rw [extend, ContinuousMap.coe_IccExtend, Set.IccExtend_of_mem] rfl theorem symm_trans {f₀ f₁ f₂ : C(X, Y)} (F : Homotopy f₀ f₁) (G : Homotopy f₁ f₂) : (F.trans G).symm = G.symm.trans F.symm := by ext ⟨t, _⟩ rw [trans_apply, symm_apply, trans_apply] simp only [coe_symm_eq, symm_apply] split_ifs with h₁ h₂ h₂ · have ht : (t : ℝ) = 1 / 2 := by linarith norm_num [ht] · congr 2 apply Subtype.ext simp only [coe_symm_eq] linarith · congr 2 apply Subtype.ext simp only [coe_symm_eq] linarith · exfalso linarith /-- Casting a `Homotopy f₀ f₁` to a `Homotopy g₀ g₁` where `f₀ = g₀` and `f₁ = g₁`. -/ @[simps] def cast {f₀ f₁ g₀ g₁ : C(X, Y)} (F : Homotopy f₀ f₁) (h₀ : f₀ = g₀) (h₁ : f₁ = g₁) : Homotopy g₀ g₁ where toFun := F map_zero_left := by simp [← h₀] map_one_left := by simp [← h₁] /-- Composition of a `Homotopy g₀ g₁` and `f : C(X, Y)` as a homotopy between `g₀.comp f` and `g₁.comp f`. -/ @[simps!] def compContinuousMap {g₀ g₁ : C(Y, Z)} (G : Homotopy g₀ g₁) (f : C(X, Y)) : Homotopy (g₀.comp f) (g₁.comp f) where toContinuousMap := G.comp (.prodMap (.id _) f) map_zero_left _ := G.map_zero_left _ map_one_left _ := G.map_one_left _ /-- If we have a `Homotopy f₀ f₁` and a `Homotopy g₀ g₁`, then we can compose them and get a `Homotopy (g₀.comp f₀) (g₁.comp f₁)`. -/ @[simps] def hcomp {f₀ f₁ : C(X, Y)} {g₀ g₁ : C(Y, Z)} (F : Homotopy f₀ f₁) (G : Homotopy g₀ g₁) : Homotopy (g₀.comp f₀) (g₁.comp f₁) where toFun x := G (x.1, F x) map_zero_left := by simp map_one_left := by simp /-- Let `F` be a homotopy between `f₀ : C(X, Y)` and `f₁ : C(X, Y)`. Let `G` be a homotopy between `g₀ : C(X, Z)` and `g₁ : C(X, Z)`. Then `F.prodMk G` is the homotopy between `f₀.prodMk g₀` and `f₁.prodMk g₁` that sends `p` to `(F p, G p)`. -/ nonrec def prodMk {f₀ f₁ : C(X, Y)} {g₀ g₁ : C(X, Z)} (F : Homotopy f₀ f₁) (G : Homotopy g₀ g₁) : Homotopy (f₀.prodMk g₀) (f₁.prodMk g₁) where toContinuousMap := F.prodMk G map_zero_left _ := Prod.ext (F.map_zero_left _) (G.map_zero_left _) map_one_left _ := Prod.ext (F.map_one_left _) (G.map_one_left _) /-- Let `F` be a homotopy between `f₀ : C(X, Y)` and `f₁ : C(X, Y)`. Let `G` be a homotopy between `g₀ : C(Z, Z')` and `g₁ : C(Z, Z')`. Then `F.prodMap G` is the homotopy between `f₀.prodMap g₀` and `f₁.prodMap g₁` that sends `(t, x, z)` to `(F (t, x), G (t, z))`. -/ def prodMap {f₀ f₁ : C(X, Y)} {g₀ g₁ : C(Z, Z')} (F : Homotopy f₀ f₁) (G : Homotopy g₀ g₁) : Homotopy (f₀.prodMap g₀) (f₁.prodMap g₁) := .prodMk (.hcomp (.refl .fst) F) (.hcomp (.refl .snd) G) /-- Given a family of homotopies `F i` between `f₀ i : C(X, Y i)` and `f₁ i : C(X, Y i)`, returns a homotopy between `ContinuousMap.pi f₀` and `ContinuousMap.pi f₁`. -/ protected def pi {Y : ι → Type*} [∀ i, TopologicalSpace (Y i)] {f₀ f₁ : ∀ i, C(X, Y i)} (F : ∀ i, Homotopy (f₀ i) (f₁ i)) : Homotopy (.pi f₀) (.pi f₁) where toContinuousMap := .pi fun i ↦ F i map_zero_left x := funext fun i ↦ (F i).map_zero_left x map_one_left x := funext fun i ↦ (F i).map_one_left x /-- Given a family of homotopies `F i` between `f₀ i : C(X i, Y i)` and `f₁ i : C(X i, Y i)`, returns a homotopy between `ContinuousMap.piMap f₀` and `ContinuousMap.piMap f₁`. -/ protected def piMap {X Y : ι → Type*} [∀ i, TopologicalSpace (X i)] [∀ i, TopologicalSpace (Y i)] {f₀ f₁ : ∀ i, C(X i, Y i)} (F : ∀ i, Homotopy (f₀ i) (f₁ i)) : Homotopy (.piMap f₀) (.piMap f₁) := .pi fun i ↦ .hcomp (.refl <| .eval i) (F i) end Homotopy /-- Given continuous maps `f₀` and `f₁`, we say `f₀` and `f₁` are homotopic if there exists a `Homotopy f₀ f₁`. -/ def Homotopic (f₀ f₁ : C(X, Y)) : Prop := Nonempty (Homotopy f₀ f₁) namespace Homotopic @[refl] theorem refl (f : C(X, Y)) : Homotopic f f := ⟨Homotopy.refl f⟩ @[symm] theorem symm ⦃f g : C(X, Y)⦄ (h : Homotopic f g) : Homotopic g f := h.map Homotopy.symm @[trans] theorem trans ⦃f g h : C(X, Y)⦄ (h₀ : Homotopic f g) (h₁ : Homotopic g h) : Homotopic f h := h₀.map2 Homotopy.trans h₁ theorem hcomp {f₀ f₁ : C(X, Y)} {g₀ g₁ : C(Y, Z)} (h₀ : Homotopic f₀ f₁) (h₁ : Homotopic g₀ g₁) : Homotopic (g₀.comp f₀) (g₁.comp f₁) := h₀.map2 Homotopy.hcomp h₁ theorem equivalence : Equivalence (@Homotopic X Y _ _) := ⟨refl, by apply symm, by apply trans⟩ nonrec theorem prodMk {f₀ f₁ : C(X, Y)} {g₀ g₁ : C(X, Z)} : Homotopic f₀ f₁ → Homotopic g₀ g₁ → Homotopic (f₀.prodMk g₀) (f₁.prodMk g₁) | ⟨F⟩, ⟨G⟩ => ⟨F.prodMk G⟩ nonrec theorem prodMap {f₀ f₁ : C(X, Y)} {g₀ g₁ : C(Z, Z')} : Homotopic f₀ f₁ → Homotopic g₀ g₁ → Homotopic (f₀.prodMap g₀) (f₁.prodMap g₁) | ⟨F⟩, ⟨G⟩ => ⟨F.prodMap G⟩ /-- If each `f₀ i : C(X, Y i)` is homotopic to `f₁ i : C(X, Y i)`, then `ContinuousMap.pi f₀` is homotopic to `ContinuousMap.pi f₁`. -/ protected theorem pi {Y : ι → Type*} [∀ i, TopologicalSpace (Y i)] {f₀ f₁ : ∀ i, C(X, Y i)} (F : ∀ i, Homotopic (f₀ i) (f₁ i)) : Homotopic (.pi f₀) (.pi f₁) := ⟨.pi fun i ↦ (F i).some⟩ /-- If each `f₀ i : C(X, Y i)` is homotopic to `f₁ i : C(X, Y i)`, then `ContinuousMap.pi f₀` is homotopic to `ContinuousMap.pi f₁`. -/ protected theorem piMap {X Y : ι → Type*} [∀ i, TopologicalSpace (X i)] [∀ i, TopologicalSpace (Y i)] {f₀ f₁ : ∀ i, C(X i, Y i)} (F : ∀ i, Homotopic (f₀ i) (f₁ i)) : Homotopic (.piMap f₀) (.piMap f₁) := .pi fun i ↦ .hcomp (.refl <| .eval i) (F i) end Homotopic /-- The type of homotopies between `f₀ f₁ : C(X, Y)`, where the intermediate maps satisfy the predicate `P : C(X, Y) → Prop` -/ structure HomotopyWith (f₀ f₁ : C(X, Y)) (P : C(X, Y) → Prop) extends Homotopy f₀ f₁ where -- Porting note (#11215): TODO: use `toHomotopy.curry t` /-- the intermediate maps of the homotopy satisfy the property -/ prop' : ∀ t, P ⟨fun x => toFun (t, x), Continuous.comp continuous_toFun (continuous_const.prod_mk continuous_id')⟩ namespace HomotopyWith section variable {f₀ f₁ : C(X, Y)} {P : C(X, Y) → Prop} instance instFunLike : FunLike (HomotopyWith f₀ f₁ P) (I × X) Y where coe F := ⇑F.toHomotopy coe_injective' | ⟨⟨⟨_, _⟩, _, _⟩, _⟩, ⟨⟨⟨_, _⟩, _, _⟩, _⟩, rfl => rfl instance : HomotopyLike (HomotopyWith f₀ f₁ P) f₀ f₁ where map_continuous F := F.continuous_toFun map_zero_left F := F.map_zero_left map_one_left F := F.map_one_left theorem coeFn_injective : @Function.Injective (HomotopyWith f₀ f₁ P) (I × X → Y) (⇑) := DFunLike.coe_injective' @[ext] theorem ext {F G : HomotopyWith f₀ f₁ P} (h : ∀ x, F x = G x) : F = G := DFunLike.ext F G h /-- 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 (F : HomotopyWith f₀ f₁ P) : I × X → Y := F initialize_simps_projections HomotopyWith (toHomotopy_toContinuousMap_toFun → apply, -toHomotopy_toContinuousMap) @[continuity] protected theorem continuous (F : HomotopyWith f₀ f₁ P) : Continuous F := F.continuous_toFun @[simp] theorem apply_zero (F : HomotopyWith f₀ f₁ P) (x : X) : F (0, x) = f₀ x := F.map_zero_left x @[simp] theorem apply_one (F : HomotopyWith f₀ f₁ P) (x : X) : F (1, x) = f₁ x := F.map_one_left x -- Porting note: removed `simp` theorem coe_toContinuousMap (F : HomotopyWith f₀ f₁ P) : ⇑F.toContinuousMap = F := rfl @[simp] theorem coe_toHomotopy (F : HomotopyWith f₀ f₁ P) : ⇑F.toHomotopy = F := rfl theorem prop (F : HomotopyWith f₀ f₁ P) (t : I) : P (F.toHomotopy.curry t) := F.prop' t theorem extendProp (F : HomotopyWith f₀ f₁ P) (t : ℝ) : P (F.toHomotopy.extend t) := F.prop _ end variable {P : C(X, Y) → Prop} /-- Given a continuous function `f`, and a proof `h : P f`, we can define a `HomotopyWith f f P` by `F (t, x) = f x` -/ @[simps!] def refl (f : C(X, Y)) (hf : P f) : HomotopyWith f f P where toHomotopy := Homotopy.refl f prop' := fun _ => hf instance : Inhabited (HomotopyWith (ContinuousMap.id X) (ContinuousMap.id X) fun _ => True) := ⟨HomotopyWith.refl _ trivial⟩ /-- Given a `HomotopyWith f₀ f₁ P`, we can define a `HomotopyWith f₁ f₀ P` by reversing the homotopy. -/ @[simps!] def symm {f₀ f₁ : C(X, Y)} (F : HomotopyWith f₀ f₁ P) : HomotopyWith f₁ f₀ P where toHomotopy := F.toHomotopy.symm prop' := fun t => F.prop (σ t) @[simp] theorem symm_symm {f₀ f₁ : C(X, Y)} (F : HomotopyWith f₀ f₁ P) : F.symm.symm = F := ext <| Homotopy.congr_fun <| Homotopy.symm_symm _ theorem symm_bijective {f₀ f₁ : C(X, Y)} : Function.Bijective (HomotopyWith.symm : HomotopyWith f₀ f₁ P → HomotopyWith f₁ f₀ P) := Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩ /-- Given `HomotopyWith f₀ f₁ P` and `HomotopyWith f₁ f₂ P`, we can define a `HomotopyWith f₀ f₂ P` by putting the first homotopy on `[0, 1/2]` and the second on `[1/2, 1]`. -/ def trans {f₀ f₁ f₂ : C(X, Y)} (F : HomotopyWith f₀ f₁ P) (G : HomotopyWith f₁ f₂ P) : HomotopyWith f₀ f₂ P := { F.toHomotopy.trans G.toHomotopy with prop' := fun t => by simp only [Homotopy.trans] change P ⟨fun _ => ite ((t : ℝ) ≤ _) _ _, _⟩ split_ifs · exact F.extendProp _ · exact G.extendProp _ } theorem trans_apply {f₀ f₁ f₂ : C(X, Y)} (F : HomotopyWith f₀ f₁ P) (G : HomotopyWith f₁ f₂ P) (x : I × X) : (F.trans G) x = if h : (x.1 : ℝ) ≤ 1 / 2 then F (⟨2 * x.1, (unitInterval.mul_pos_mem_iff zero_lt_two).2 ⟨x.1.2.1, h⟩⟩, x.2) else G (⟨2 * x.1 - 1, unitInterval.two_mul_sub_one_mem_iff.2 ⟨(not_le.1 h).le, x.1.2.2⟩⟩, x.2) := Homotopy.trans_apply _ _ _ theorem symm_trans {f₀ f₁ f₂ : C(X, Y)} (F : HomotopyWith f₀ f₁ P) (G : HomotopyWith f₁ f₂ P) : (F.trans G).symm = G.symm.trans F.symm := ext <| Homotopy.congr_fun <| Homotopy.symm_trans _ _ /-- Casting a `HomotopyWith f₀ f₁ P` to a `HomotopyWith g₀ g₁ P` where `f₀ = g₀` and `f₁ = g₁`. -/ @[simps!] def cast {f₀ f₁ g₀ g₁ : C(X, Y)} (F : HomotopyWith f₀ f₁ P) (h₀ : f₀ = g₀) (h₁ : f₁ = g₁) : HomotopyWith g₀ g₁ P where toHomotopy := F.toHomotopy.cast h₀ h₁ prop' := F.prop end HomotopyWith /-- Given continuous maps `f₀` and `f₁`, we say `f₀` and `f₁` are homotopic with respect to the predicate `P` if there exists a `HomotopyWith f₀ f₁ P`. -/ def HomotopicWith (f₀ f₁ : C(X, Y)) (P : C(X, Y) → Prop) : Prop := Nonempty (HomotopyWith f₀ f₁ P) namespace HomotopicWith variable {P : C(X, Y) → Prop} -- Porting note: removed @[refl] theorem refl (f : C(X, Y)) (hf : P f) : HomotopicWith f f P := ⟨HomotopyWith.refl f hf⟩ @[symm] theorem symm ⦃f g : C(X, Y)⦄ (h : HomotopicWith f g P) : HomotopicWith g f P := ⟨h.some.symm⟩ -- Note: this was formerly tagged with `@[trans]`, and although the `trans` attribute accepted it -- the `trans` tactic could not use it. -- An update to the trans tactic coming in mathlib4#7014 will reject this attribute. -- It could be restored by changing the argument order to `HomotopicWith P f g`. @[trans] theorem trans ⦃f g h : C(X, Y)⦄ (h₀ : HomotopicWith f g P) (h₁ : HomotopicWith g h P) : HomotopicWith f h P := ⟨h₀.some.trans h₁.some⟩ end HomotopicWith /-- A `HomotopyRel f₀ f₁ S` is a homotopy between `f₀` and `f₁` which is fixed on the points in `S`. -/ abbrev HomotopyRel (f₀ f₁ : C(X, Y)) (S : Set X) := HomotopyWith f₀ f₁ fun f ↦ ∀ x ∈ S, f x = f₀ x namespace HomotopyRel section variable {f₀ f₁ : C(X, Y)} {S : Set X} theorem eq_fst (F : HomotopyRel f₀ f₁ S) (t : I) {x : X} (hx : x ∈ S) : F (t, x) = f₀ x := F.prop t x hx theorem eq_snd (F : HomotopyRel f₀ f₁ S) (t : I) {x : X} (hx : x ∈ S) : F (t, x) = f₁ x := by rw [F.eq_fst t hx, ← F.eq_fst 1 hx, F.apply_one] theorem fst_eq_snd (F : HomotopyRel f₀ f₁ S) {x : X} (hx : x ∈ S) : f₀ x = f₁ x := F.eq_fst 0 hx ▸ F.eq_snd 0 hx end variable {f₀ f₁ f₂ : C(X, Y)} {S : Set X} /-- Given a map `f : C(X, Y)` and a set `S`, we can define a `HomotopyRel f f S` by setting `F (t, x) = f x` for all `t`. This is defined using `HomotopyWith.refl`, but with the proof filled in. -/ @[simps!] def refl (f : C(X, Y)) (S : Set X) : HomotopyRel f f S := HomotopyWith.refl f fun _ _ ↦ rfl /-- Given a `HomotopyRel f₀ f₁ S`, we can define a `HomotopyRel f₁ f₀ S` by reversing the homotopy. -/ @[simps!] def symm (F : HomotopyRel f₀ f₁ S) : HomotopyRel f₁ f₀ S where toHomotopy := F.toHomotopy.symm prop' := fun _ _ hx ↦ F.eq_snd _ hx @[simp] theorem symm_symm (F : HomotopyRel f₀ f₁ S) : F.symm.symm = F := HomotopyWith.symm_symm F theorem symm_bijective : Function.Bijective (HomotopyRel.symm : HomotopyRel f₀ f₁ S → HomotopyRel f₁ f₀ S) := Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩ /-- Given `HomotopyRel f₀ f₁ S` and `HomotopyRel f₁ f₂ S`, we can define a `HomotopyRel f₀ f₂ S` by putting the first homotopy on `[0, 1/2]` and the second on `[1/2, 1]`. -/ def trans (F : HomotopyRel f₀ f₁ S) (G : HomotopyRel f₁ f₂ S) : HomotopyRel f₀ f₂ S where toHomotopy := F.toHomotopy.trans G.toHomotopy prop' t x hx := by simp only [Homotopy.trans] split_ifs · simp [HomotopyWith.extendProp F (2 * t) x hx, F.fst_eq_snd hx, G.fst_eq_snd hx] · simp [HomotopyWith.extendProp G (2 * t - 1) x hx, F.fst_eq_snd hx, G.fst_eq_snd hx] theorem trans_apply (F : HomotopyRel f₀ f₁ S) (G : HomotopyRel f₁ f₂ S) (x : I × X) : (F.trans G) x = if h : (x.1 : ℝ) ≤ 1 / 2 then F (⟨2 * x.1, (unitInterval.mul_pos_mem_iff zero_lt_two).2 ⟨x.1.2.1, h⟩⟩, x.2) else G (⟨2 * x.1 - 1, unitInterval.two_mul_sub_one_mem_iff.2 ⟨(not_le.1 h).le, x.1.2.2⟩⟩, x.2) := Homotopy.trans_apply _ _ _ theorem symm_trans (F : HomotopyRel f₀ f₁ S) (G : HomotopyRel f₁ f₂ S) : (F.trans G).symm = G.symm.trans F.symm := HomotopyWith.ext <| Homotopy.congr_fun <| Homotopy.symm_trans _ _ /-- Casting a `HomotopyRel f₀ f₁ S` to a `HomotopyRel g₀ g₁ S` where `f₀ = g₀` and `f₁ = g₁`. -/ @[simps!] def cast {f₀ f₁ g₀ g₁ : C(X, Y)} (F : HomotopyRel f₀ f₁ S) (h₀ : f₀ = g₀) (h₁ : f₁ = g₁) : HomotopyRel g₀ g₁ S where toHomotopy := Homotopy.cast F.toHomotopy h₀ h₁ prop' t x hx := by simpa only [← h₀, ← h₁] using F.prop t x hx /-- Post-compose a homotopy relative to a set by a continuous function. -/ @[simps!] def compContinuousMap {f₀ f₁ : C(X, Y)} (F : f₀.HomotopyRel f₁ S) (g : C(Y, Z)) : (g.comp f₀).HomotopyRel (g.comp f₁) S where toHomotopy := F.hcomp (ContinuousMap.Homotopy.refl g) prop' t x hx := congr_arg g (F.prop t x hx) end HomotopyRel /-- Given continuous maps `f₀` and `f₁`, we say `f₀` and `f₁` are homotopic relative to a set `S` if there exists a `HomotopyRel f₀ f₁ S`. -/ def HomotopicRel (f₀ f₁ : C(X, Y)) (S : Set X) : Prop := Nonempty (HomotopyRel f₀ f₁ S) namespace HomotopicRel variable {S : Set X} /-- If two maps are homotopic relative to a set, then they are homotopic. -/ protected theorem homotopic {f₀ f₁ : C(X, Y)} (h : HomotopicRel f₀ f₁ S) : Homotopic f₀ f₁ := h.map fun F ↦ F.1 -- Porting note: removed @[refl] theorem refl (f : C(X, Y)) : HomotopicRel f f S := ⟨HomotopyRel.refl f S⟩ @[symm] theorem symm ⦃f g : C(X, Y)⦄ (h : HomotopicRel f g S) : HomotopicRel g f S := h.map HomotopyRel.symm @[trans] theorem trans ⦃f g h : C(X, Y)⦄ (h₀ : HomotopicRel f g S) (h₁ : HomotopicRel g h S) : HomotopicRel f h S := h₀.map2 HomotopyRel.trans h₁ theorem equivalence : Equivalence fun f g : C(X, Y) => HomotopicRel f g S := ⟨refl, by apply symm, by apply trans⟩ end HomotopicRel @[simp] theorem homotopicRel_empty {f₀ f₁ : C(X, Y)} : HomotopicRel f₀ f₁ ∅ ↔ Homotopic f₀ f₁ := ⟨fun h ↦ h.homotopic, fun ⟨F⟩ ↦ ⟨⟨F, fun _ _ ↦ False.elim⟩⟩⟩ end ContinuousMap
Topology\Homotopy\Contractible.lean
/- Copyright (c) 2022 Praneeth Kolichala. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Praneeth Kolichala -/ import Mathlib.Topology.Homotopy.Path import Mathlib.Topology.Homotopy.Equiv /-! # Contractible spaces In this file, we define `ContractibleSpace`, a space that is homotopy equivalent to `Unit`. -/ noncomputable section namespace ContinuousMap variable {X Y Z : Type*} [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] /-- A map is nullhomotopic if it is homotopic to a constant map. -/ def Nullhomotopic (f : C(X, Y)) : Prop := ∃ y : Y, Homotopic f (ContinuousMap.const _ y) theorem nullhomotopic_of_constant (y : Y) : Nullhomotopic (ContinuousMap.const X y) := ⟨y, by rfl⟩ theorem Nullhomotopic.comp_right {f : C(X, Y)} (hf : f.Nullhomotopic) (g : C(Y, Z)) : (g.comp f).Nullhomotopic := by cases' hf with y hy use g y exact Homotopic.hcomp hy (Homotopic.refl g) theorem Nullhomotopic.comp_left {f : C(Y, Z)} (hf : f.Nullhomotopic) (g : C(X, Y)) : (f.comp g).Nullhomotopic := by cases' hf with y hy use y exact Homotopic.hcomp (Homotopic.refl g) hy end ContinuousMap open ContinuousMap /-- A contractible space is one that is homotopy equivalent to `Unit`. -/ class ContractibleSpace (X : Type*) [TopologicalSpace X] : Prop where hequiv_unit' : Nonempty (X ≃ₕ Unit) -- Porting note: added to work around lack of infer kinds theorem ContractibleSpace.hequiv_unit (X : Type*) [TopologicalSpace X] [ContractibleSpace X] : Nonempty (X ≃ₕ Unit) := ContractibleSpace.hequiv_unit' theorem id_nullhomotopic (X : Type*) [TopologicalSpace X] [ContractibleSpace X] : (ContinuousMap.id X).Nullhomotopic := by obtain ⟨hv⟩ := ContractibleSpace.hequiv_unit X use hv.invFun () convert hv.left_inv.symm theorem contractible_iff_id_nullhomotopic (Y : Type*) [TopologicalSpace Y] : ContractibleSpace Y ↔ (ContinuousMap.id Y).Nullhomotopic := by constructor · intro apply id_nullhomotopic rintro ⟨p, h⟩ refine { hequiv_unit' := ⟨{ toFun := ContinuousMap.const _ () invFun := ContinuousMap.const _ p left_inv := ?_ right_inv := ?_ }⟩ } · exact h.symm · convert Homotopic.refl (ContinuousMap.id Unit) variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] protected theorem ContinuousMap.HomotopyEquiv.contractibleSpace [ContractibleSpace Y] (e : X ≃ₕ Y) : ContractibleSpace X := ⟨(ContractibleSpace.hequiv_unit Y).map e.trans⟩ protected theorem ContinuousMap.HomotopyEquiv.contractibleSpace_iff (e : X ≃ₕ Y) : ContractibleSpace X ↔ ContractibleSpace Y := ⟨fun _ => e.symm.contractibleSpace, fun _ => e.contractibleSpace⟩ protected theorem Homeomorph.contractibleSpace [ContractibleSpace Y] (e : X ≃ₜ Y) : ContractibleSpace X := e.toHomotopyEquiv.contractibleSpace protected theorem Homeomorph.contractibleSpace_iff (e : X ≃ₜ Y) : ContractibleSpace X ↔ ContractibleSpace Y := e.toHomotopyEquiv.contractibleSpace_iff namespace ContractibleSpace instance [Unique Y] : ContractibleSpace Y := by have : ContractibleSpace (Unit) := ⟨⟨HomotopyEquiv.refl Unit⟩⟩ apply (Homeomorph.homeomorphOfUnique Y Unit).contractibleSpace variable (X Y) in theorem hequiv [ContractibleSpace X] [ContractibleSpace Y] : Nonempty (X ≃ₕ Y) := by rcases ContractibleSpace.hequiv_unit' (X := X) with ⟨h⟩ rcases ContractibleSpace.hequiv_unit' (X := Y) with ⟨h'⟩ exact ⟨h.trans h'.symm⟩ instance (priority := 100) [ContractibleSpace X] : PathConnectedSpace X := by obtain ⟨p, ⟨h⟩⟩ := id_nullhomotopic X have : ∀ x, Joined p x := fun x => ⟨(h.evalAt x).symm⟩ rw [pathConnectedSpace_iff_eq]; use p; ext; tauto end ContractibleSpace
Topology\Homotopy\Equiv.lean
/- Copyright (c) 2021 Shing Tak Lam. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Shing Tak Lam -/ import Mathlib.Topology.Homotopy.Basic /-! # Homotopy equivalences between topological spaces In this file, we define homotopy equivalences between topological spaces `X` and `Y` as a pair of functions `f : C(X, Y)` and `g : C(Y, X)` such that `f.comp g` and `g.comp f` are both homotopic to `ContinuousMap.id`. ## Main definitions - `ContinuousMap.HomotopyEquiv` is the type of homotopy equivalences between topological spaces. ## Notation We introduce the notation `X ≃ₕ Y` for `ContinuousMap.HomotopyEquiv X Y` in the `ContinuousMap` locale. -/ universe u v w x variable {X : Type u} {Y : Type v} {Z : Type w} {Z' : Type x} variable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] [TopologicalSpace Z'] namespace ContinuousMap /-- A homotopy equivalence between topological spaces `X` and `Y` are a pair of functions `toFun : C(X, Y)` and `invFun : C(Y, X)` such that `toFun.comp invFun` and `invFun.comp toFun` are both homotopic to corresponding identity maps. -/ @[ext] structure HomotopyEquiv (X : Type u) (Y : Type v) [TopologicalSpace X] [TopologicalSpace Y] where toFun : C(X, Y) invFun : C(Y, X) left_inv : (invFun.comp toFun).Homotopic (ContinuousMap.id X) right_inv : (toFun.comp invFun).Homotopic (ContinuousMap.id Y) scoped infixl:25 " ≃ₕ " => ContinuousMap.HomotopyEquiv namespace HomotopyEquiv /-- Coercion of a `HomotopyEquiv` to function. While the Lean 4 way is to unfold coercions, this auxiliary definition will make porting of Lean 3 code easier. Porting note (#11215): TODO: drop this definition. -/ @[coe] def toFun' (e : X ≃ₕ Y) : X → Y := e.toFun instance : CoeFun (X ≃ₕ Y) fun _ => X → Y := ⟨toFun'⟩ @[simp] theorem toFun_eq_coe (h : HomotopyEquiv X Y) : (h.toFun : X → Y) = h := rfl @[continuity] theorem continuous (h : HomotopyEquiv X Y) : Continuous h := h.toFun.continuous end HomotopyEquiv end ContinuousMap open ContinuousMap namespace Homeomorph /-- Any homeomorphism is a homotopy equivalence. -/ def toHomotopyEquiv (h : X ≃ₜ Y) : X ≃ₕ Y where toFun := h invFun := h.symm left_inv := by rw [symm_comp_toContinuousMap] right_inv := by rw [toContinuousMap_comp_symm] @[simp] theorem coe_toHomotopyEquiv (h : X ≃ₜ Y) : (h.toHomotopyEquiv : X → Y) = h := rfl end Homeomorph namespace ContinuousMap namespace HomotopyEquiv /-- If `X` is homotopy equivalent to `Y`, then `Y` is homotopy equivalent to `X`. -/ def symm (h : X ≃ₕ Y) : Y ≃ₕ X where toFun := h.invFun invFun := h.toFun left_inv := h.right_inv right_inv := h.left_inv @[simp] theorem coe_invFun (h : HomotopyEquiv X Y) : (⇑h.invFun : Y → X) = ⇑h.symm := 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 (h : X ≃ₕ Y) : X → Y := h /-- 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.symm_apply (h : X ≃ₕ Y) : Y → X := h.symm initialize_simps_projections HomotopyEquiv (toFun_toFun → apply, invFun_toFun → symm_apply, -toFun, -invFun) /-- Any topological space is homotopy equivalent to itself. -/ @[simps!] def refl (X : Type u) [TopologicalSpace X] : X ≃ₕ X := (Homeomorph.refl X).toHomotopyEquiv instance : Inhabited (HomotopyEquiv Unit Unit) := ⟨refl Unit⟩ /-- If `X` is homotopy equivalent to `Y`, and `Y` is homotopy equivalent to `Z`, then `X` is homotopy equivalent to `Z`. -/ @[simps!] def trans (h₁ : X ≃ₕ Y) (h₂ : Y ≃ₕ Z) : X ≃ₕ Z where toFun := h₂.toFun.comp h₁.toFun invFun := h₁.invFun.comp h₂.invFun left_inv := by refine Homotopic.trans ?_ h₁.left_inv exact ((Homotopic.refl _).hcomp h₂.left_inv).hcomp (Homotopic.refl _) right_inv := by refine Homotopic.trans ?_ h₂.right_inv exact ((Homotopic.refl _).hcomp h₁.right_inv).hcomp (Homotopic.refl _) theorem symm_trans (h₁ : X ≃ₕ Y) (h₂ : Y ≃ₕ Z) : (h₁.trans h₂).symm = h₂.symm.trans h₁.symm := rfl /-- If `X` is homotopy equivalent to `Y` and `Z` is homotopy equivalent to `Z'`, then `X × Z` is homotopy equivalent to `Z × Z'`. -/ def prodCongr (h₁ : X ≃ₕ Y) (h₂ : Z ≃ₕ Z') : (X × Z) ≃ₕ (Y × Z') where toFun := h₁.toFun.prodMap h₂.toFun invFun := h₁.invFun.prodMap h₂.invFun left_inv := h₁.left_inv.prodMap h₂.left_inv right_inv := h₁.right_inv.prodMap h₂.right_inv /-- If `X i` is homotopy equivalent to `Y i` for each `i`, then the space of functions (a.k.a. the indexed product) `∀ i, X i` is homotopy equivalent to `∀ i, Y i`. -/ def piCongrRight {ι : Type*} {X Y : ι → Type*} [∀ i, TopologicalSpace (X i)] [∀ i, TopologicalSpace (Y i)] (h : ∀ i, X i ≃ₕ Y i) : (∀ i, X i) ≃ₕ (∀ i, Y i) where toFun := .piMap fun i ↦ (h i).toFun invFun := .piMap fun i ↦ (h i).invFun left_inv := .piMap fun i ↦ (h i).left_inv right_inv := .piMap fun i ↦ (h i).right_inv end HomotopyEquiv end ContinuousMap open ContinuousMap namespace Homeomorph @[simp] theorem refl_toHomotopyEquiv (X : Type u) [TopologicalSpace X] : (Homeomorph.refl X).toHomotopyEquiv = HomotopyEquiv.refl X := rfl @[simp] theorem symm_toHomotopyEquiv (h : X ≃ₜ Y) : h.symm.toHomotopyEquiv = h.toHomotopyEquiv.symm := rfl @[simp] theorem trans_toHomotopyEquiv (h₀ : X ≃ₜ Y) (h₁ : Y ≃ₜ Z) : (h₀.trans h₁).toHomotopyEquiv = h₀.toHomotopyEquiv.trans h₁.toHomotopyEquiv := rfl end Homeomorph
Topology\Homotopy\HomotopyGroup.lean
/- Copyright (c) 2021 Roberto Alvarez. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Roberto Alvarez -/ import Mathlib.AlgebraicTopology.FundamentalGroupoid.FundamentalGroup import Mathlib.GroupTheory.EckmannHilton import Mathlib.Logic.Equiv.TransferInstance import Mathlib.Algebra.Group.Ext /-! # `n`th homotopy group We define the `n`th homotopy group at `x : X`, `π_n X x`, as the equivalence classes of functions from the `n`-dimensional cube to the topological space `X` that send the boundary to the base point `x`, up to homotopic equivalence. Note that such functions are generalized loops `GenLoop (Fin n) x`; in particular `GenLoop (Fin 1) x ≃ Path x x`. We show that `π_0 X x` is equivalent to the path-connected components, and that `π_1 X x` is equivalent to the fundamental group at `x`. We provide a group instance using path composition and show commutativity when `n > 1`. ## definitions * `GenLoop N x` is the type of continuous functions `I^N → X` that send the boundary to `x`, * `HomotopyGroup.Pi n X x` denoted `π_ n X x` is the quotient of `GenLoop (Fin n) x` by homotopy relative to the boundary, * group instance `Group (π_(n+1) X x)`, * commutative group instance `CommGroup (π_(n+2) X x)`. TODO: * `Ω^M (Ω^N X) ≃ₜ Ω^(M⊕N) X`, and `Ω^M X ≃ₜ Ω^N X` when `M ≃ N`. Similarly for `π_`. * Path-induced homomorphisms. Show that `HomotopyGroup.pi1EquivFundamentalGroup` is a group isomorphism. * Examples with `𝕊^n`: `π_n (𝕊^n) = ℤ`, `π_m (𝕊^n)` trivial for `m < n`. * Actions of π_1 on π_n. * Lie algebra: `⁅π_(n+1), π_(m+1)⁆` contained in `π_(n+m+1)`. -/ open scoped unitInterval Topology open Homeomorph noncomputable section scoped[Topology] notation "I^" N => N → I namespace Cube /-- The points in a cube with at least one projection equal to 0 or 1. -/ def boundary (N : Type*) : Set (I^N) := {y | ∃ i, y i = 0 ∨ y i = 1} variable {N : Type*} [DecidableEq N] /-- The forward direction of the homeomorphism between the cube $I^N$ and $I × I^{N\setminus\{j\}}$. -/ abbrev splitAt (i : N) : (I^N) ≃ₜ I × I^{ j // j ≠ i } := funSplitAt I i /-- The backward direction of the homeomorphism between the cube $I^N$ and $I × I^{N\setminus\{j\}}$. -/ abbrev insertAt (i : N) : (I × I^{ j // j ≠ i }) ≃ₜ I^N := (funSplitAt I i).symm theorem insertAt_boundary (i : N) {t₀ : I} {t} (H : (t₀ = 0 ∨ t₀ = 1) ∨ t ∈ boundary { j // j ≠ i }) : insertAt i ⟨t₀, t⟩ ∈ boundary N := by obtain H | ⟨j, H⟩ := H · use i; rwa [funSplitAt_symm_apply, dif_pos rfl] · use j; rwa [funSplitAt_symm_apply, dif_neg j.prop, Subtype.coe_eta] end Cube variable (N X : Type*) [TopologicalSpace X] (x : X) /-- The space of paths with both endpoints equal to a specified point `x : X`. -/ abbrev LoopSpace := Path x x scoped[Topology.Homotopy] notation "Ω" => LoopSpace instance LoopSpace.inhabited : Inhabited (Path x x) := ⟨Path.refl x⟩ /-- The `n`-dimensional generalized loops based at `x` in a space `X` are continuous functions `I^n → X` that sends the boundary to `x`. We allow an arbitrary indexing type `N` in place of `Fin n` here. -/ def GenLoop : Set C(I^N, X) := {p | ∀ y ∈ Cube.boundary N, p y = x} @[inherit_doc] scoped[Topology.Homotopy] notation "Ω^" => GenLoop open Topology.Homotopy variable {N X x} namespace GenLoop instance instFunLike : FunLike (Ω^ N X x) (I^N) X where coe f := f.1 coe_injective' := fun ⟨⟨f, _⟩, _⟩ ⟨⟨g, _⟩, _⟩ _ => by congr @[ext] theorem ext (f g : Ω^ N X x) (H : ∀ y, f y = g y) : f = g := DFunLike.coe_injective' (funext H) @[simp] theorem mk_apply (f : C(I^N, X)) (H y) : (⟨f, H⟩ : Ω^ N X x) y = f y := rfl /-- Copy of a `GenLoop` with a new map from the unit cube equal to the old one. Useful to fix definitional equalities. -/ def copy (f : Ω^ N X x) (g : (I^N) → X) (h : g = f) : Ω^ N X x := ⟨⟨g, h.symm ▸ f.1.2⟩, by convert f.2⟩ /- porting note: this now requires the `instFunLike` instance, so the instance is now put before `copy`. -/ theorem coe_copy (f : Ω^ N X x) {g : (I^N) → X} (h : g = f) : ⇑(copy f g h) = g := rfl theorem copy_eq (f : Ω^ N X x) {g : (I^N) → X} (h : g = f) : copy f g h = f := by ext x exact congr_fun h x theorem boundary (f : Ω^ N X x) : ∀ y ∈ Cube.boundary N, f y = x := f.2 /-- The constant `GenLoop` at `x`. -/ def const : Ω^ N X x := ⟨ContinuousMap.const _ x, fun _ _ => rfl⟩ @[simp] theorem const_apply {t} : (@const N X _ x) t = x := rfl instance inhabited : Inhabited (Ω^ N X x) := ⟨const⟩ /-- The "homotopic relative to boundary" relation between `GenLoop`s. -/ def Homotopic (f g : Ω^ N X x) : Prop := f.1.HomotopicRel g.1 (Cube.boundary N) namespace Homotopic variable {f g h : Ω^ N X x} @[refl] theorem refl (f : Ω^ N X x) : Homotopic f f := ContinuousMap.HomotopicRel.refl _ @[symm] nonrec theorem symm (H : Homotopic f g) : Homotopic g f := H.symm @[trans] nonrec theorem trans (H0 : Homotopic f g) (H1 : Homotopic g h) : Homotopic f h := H0.trans H1 theorem equiv : Equivalence (@Homotopic N X _ x) := ⟨Homotopic.refl, Homotopic.symm, Homotopic.trans⟩ instance setoid (N) (x : X) : Setoid (Ω^ N X x) := ⟨Homotopic, equiv⟩ end Homotopic section LoopHomeo variable [DecidableEq N] /-- Loop from a generalized loop by currying $I^N → X$ into $I → (I^{N\setminus\{j\}} → X)$. -/ @[simps] def toLoop (i : N) (p : Ω^ N X x) : Ω (Ω^ { j // j ≠ i } X x) const where toFun t := ⟨(p.val.comp (Cube.insertAt i).toContinuousMap).curry t, fun y yH => p.property (Cube.insertAt i (t, y)) (Cube.insertAt_boundary i <| Or.inr yH)⟩ source' := by ext t; refine p.property (Cube.insertAt i (0, t)) ⟨i, Or.inl ?_⟩; simp target' := by ext t; refine p.property (Cube.insertAt i (1, t)) ⟨i, Or.inr ?_⟩; simp theorem continuous_toLoop (i : N) : Continuous (@toLoop N X _ x _ i) := Path.continuous_uncurry_iff.1 <| Continuous.subtype_mk (ContinuousMap.continuous_eval.comp <| Continuous.prod_map (ContinuousMap.continuous_curry.comp <| (ContinuousMap.continuous_comp_left _).comp continuous_subtype_val) continuous_id) _ /-- Generalized loop from a loop by uncurrying $I → (I^{N\setminus\{j\}} → X)$ into $I^N → X$. -/ @[simps] def fromLoop (i : N) (p : Ω (Ω^ { j // j ≠ i } X x) const) : Ω^ N X x := ⟨(ContinuousMap.comp ⟨Subtype.val, by fun_prop⟩ p.toContinuousMap).uncurry.comp (Cube.splitAt i).toContinuousMap, by rintro y ⟨j, Hj⟩ simp only [ContinuousMap.comp_apply, toContinuousMap_apply, funSplitAt_apply, ContinuousMap.uncurry_apply, ContinuousMap.coe_mk, Function.uncurry_apply_pair] obtain rfl | Hne := eq_or_ne j i · cases' Hj with Hj Hj <;> simp only [Hj, p.coe_toContinuousMap, p.source, p.target] <;> rfl · exact GenLoop.boundary _ _ ⟨⟨j, Hne⟩, Hj⟩⟩ theorem continuous_fromLoop (i : N) : Continuous (@fromLoop N X _ x _ i) := ((ContinuousMap.continuous_comp_left _).comp <| ContinuousMap.continuous_uncurry.comp <| (ContinuousMap.continuous_comp _).comp continuous_induced_dom).subtype_mk _ theorem to_from (i : N) (p : Ω (Ω^ { j // j ≠ i } X x) const) : toLoop i (fromLoop i p) = p := by simp_rw [toLoop, fromLoop, ContinuousMap.comp_assoc, toContinuousMap_comp_symm, ContinuousMap.comp_id] ext; rfl /-- The `n+1`-dimensional loops are in bijection with the loops in the space of `n`-dimensional loops with base point `const`. We allow an arbitrary indexing type `N` in place of `Fin n` here. -/ @[simps] def loopHomeo (i : N) : Ω^ N X x ≃ₜ Ω (Ω^ { j // j ≠ i } X x) const where toFun := toLoop i invFun := fromLoop i left_inv p := by ext; exact congr_arg p (by dsimp; exact Equiv.apply_symm_apply _ _) right_inv := to_from i continuous_toFun := continuous_toLoop i continuous_invFun := continuous_fromLoop i theorem toLoop_apply (i : N) {p : Ω^ N X x} {t} {tn} : toLoop i p t tn = p (Cube.insertAt i ⟨t, tn⟩) := rfl theorem fromLoop_apply (i : N) {p : Ω (Ω^ { j // j ≠ i } X x) const} {t : I^N} : fromLoop i p t = p (t i) (Cube.splitAt i t).snd := rfl /-- Composition with `Cube.insertAt` as a continuous map. -/ abbrev cCompInsert (i : N) : C(C(I^N, X), C(I × I^{ j // j ≠ i }, X)) := ⟨fun f => f.comp (Cube.insertAt i).toContinuousMap, (Cube.insertAt i).toContinuousMap.continuous_comp_left⟩ /-- A homotopy between `n+1`-dimensional loops `p` and `q` constant on the boundary seen as a homotopy between two paths in the space of `n`-dimensional paths. -/ def homotopyTo (i : N) {p q : Ω^ N X x} (H : p.1.HomotopyRel q.1 (Cube.boundary N)) : C(I × I, C(I^{ j // j ≠ i }, X)) := ((⟨_, ContinuousMap.continuous_curry⟩ : C(_, _)).comp <| (cCompInsert i).comp H.toContinuousMap.curry).uncurry -- porting note (#11083): `@[simps]` no longer too slow in Lean 4 but does not generate this lemma. theorem homotopyTo_apply (i : N) {p q : Ω^ N X x} (H : p.1.HomotopyRel q.1 <| Cube.boundary N) (t : I × I) (tₙ : I^{ j // j ≠ i }) : homotopyTo i H t tₙ = H (t.fst, Cube.insertAt i (t.snd, tₙ)) := rfl theorem homotopicTo (i : N) {p q : Ω^ N X x} : Homotopic p q → (toLoop i p).Homotopic (toLoop i q) := by refine Nonempty.map fun H => ⟨⟨⟨fun t => ⟨homotopyTo i H t, ?_⟩, ?_⟩, ?_, ?_⟩, ?_⟩ · rintro y ⟨i, iH⟩ rw [homotopyTo_apply, H.eq_fst, p.2] all_goals apply Cube.insertAt_boundary; right; exact ⟨i, iH⟩ · continuity iterate 2 intro; ext; erw [homotopyTo_apply, toLoop_apply]; swap · apply H.apply_zero · apply H.apply_one intro t y yH ext; erw [homotopyTo_apply] apply H.eq_fst; use i rw [funSplitAt_symm_apply, dif_pos rfl]; exact yH /-- The converse to `GenLoop.homotopyTo`: a homotopy between two loops in the space of `n`-dimensional loops can be seen as a homotopy between two `n+1`-dimensional paths. -/ @[simps!] def homotopyFrom (i : N) {p q : Ω^ N X x} (H : (toLoop i p).Homotopy (toLoop i q)) : C(I × I^N, X) := (ContinuousMap.comp ⟨_, ContinuousMap.continuous_uncurry⟩ (ContinuousMap.comp ⟨Subtype.val, by continuity⟩ H.toContinuousMap).curry).uncurry.comp <| (ContinuousMap.id I).prodMap (Cube.splitAt i).toContinuousMap -- porting note (#11083): @[simps!] no longer too slow in Lean 4. theorem homotopicFrom (i : N) {p q : Ω^ N X x} : (toLoop i p).Homotopic (toLoop i q) → Homotopic p q := by refine Nonempty.map fun H => ⟨⟨homotopyFrom i H, ?_, ?_⟩, ?_⟩ pick_goal 3 · rintro t y ⟨j, jH⟩ erw [homotopyFrom_apply] obtain rfl | h := eq_or_ne j i · simp only [Prod.map_apply, id_eq, toContinuousMap_apply, funSplitAt_apply, Function.uncurry_apply_pair] rw [H.eq_fst] exacts [congr_arg p ((Cube.splitAt j).left_inv _), jH] · rw [p.2 _ ⟨j, jH⟩]; apply boundary; exact ⟨⟨j, h⟩, jH⟩ all_goals intro apply (homotopyFrom_apply _ _ _).trans simp only [Prod.map_apply, id_eq, toContinuousMap_apply, funSplitAt_apply, Function.uncurry_apply_pair, ContinuousMap.HomotopyWith.apply_zero, ContinuousMap.HomotopyWith.apply_one, ne_eq, Path.coe_toContinuousMap, toLoop_apply_coe, ContinuousMap.curry_apply, ContinuousMap.comp_apply] first | apply congr_arg p | apply congr_arg q apply (Cube.splitAt i).left_inv /-- Concatenation of two `GenLoop`s along the `i`th coordinate. -/ def transAt (i : N) (f g : Ω^ N X x) : Ω^ N X x := copy (fromLoop i <| (toLoop i f).trans <| toLoop i g) (fun t => if (t i : ℝ) ≤ 1 / 2 then f (Function.update t i <| Set.projIcc 0 1 zero_le_one (2 * t i)) else g (Function.update t i <| Set.projIcc 0 1 zero_le_one (2 * t i - 1))) (by ext1; symm dsimp only [Path.trans, fromLoop, Path.coe_mk_mk, Function.comp_apply, mk_apply, ContinuousMap.comp_apply, toContinuousMap_apply, funSplitAt_apply, ContinuousMap.uncurry_apply, ContinuousMap.coe_mk, Function.uncurry_apply_pair] split_ifs · show f _ = _; congr 1 · show g _ = _; congr 1) /-- Reversal of a `GenLoop` along the `i`th coordinate. -/ def symmAt (i : N) (f : Ω^ N X x) : Ω^ N X x := (copy (fromLoop i (toLoop i f).symm) fun t => f fun j => if j = i then σ (t i) else t j) <| by ext1; change _ = f _; congr; ext1; simp theorem transAt_distrib {i j : N} (h : i ≠ j) (a b c d : Ω^ N X x) : transAt i (transAt j a b) (transAt j c d) = transAt j (transAt i a c) (transAt i b d) := by ext; simp_rw [transAt, coe_copy, Function.update_apply, if_neg h, if_neg h.symm] split_ifs <;> · congr 1; ext1; simp only [Function.update, eq_rec_constant, dite_eq_ite] apply ite_ite_comm; rintro rfl; exact h.symm theorem fromLoop_trans_toLoop {i : N} {p q : Ω^ N X x} : fromLoop i ((toLoop i p).trans <| toLoop i q) = transAt i p q := (copy_eq _ _).symm theorem fromLoop_symm_toLoop {i : N} {p : Ω^ N X x} : fromLoop i (toLoop i p).symm = symmAt i p := (copy_eq _ _).symm end LoopHomeo end GenLoop /-- The `n`th homotopy group at `x` defined as the quotient of `Ω^n x` by the `GenLoop.Homotopic` relation. -/ def HomotopyGroup (N X : Type*) [TopologicalSpace X] (x : X) : Type _ := Quotient (GenLoop.Homotopic.setoid N x) -- Porting note: in Lean 3 this instance was derived instance : Inhabited (HomotopyGroup N X x) := inferInstanceAs <| Inhabited <| Quotient (GenLoop.Homotopic.setoid N x) variable [DecidableEq N] open GenLoop /-- Equivalence between the homotopy group of X and the fundamental group of `Ω^{j // j ≠ i} x`. -/ def homotopyGroupEquivFundamentalGroup (i : N) : HomotopyGroup N X x ≃ FundamentalGroup (Ω^ { j // j ≠ i } X x) const := by refine Equiv.trans ?_ (CategoryTheory.Groupoid.isoEquivHom _ _).symm apply Quotient.congr (loopHomeo i).toEquiv exact fun p q => ⟨homotopicTo i, homotopicFrom i⟩ /-- Homotopy group of finite index. -/ abbrev HomotopyGroup.Pi (n) (X : Type*) [TopologicalSpace X] (x : X) := HomotopyGroup (Fin n) _ x scoped[Topology] notation "π_" => HomotopyGroup.Pi /-- The 0-dimensional generalized loops based at `x` are in bijection with `X`. -/ def genLoopHomeoOfIsEmpty (N x) [IsEmpty N] : Ω^ N X x ≃ₜ X where toFun f := f 0 invFun y := ⟨ContinuousMap.const _ y, fun _ ⟨i, _⟩ => isEmptyElim i⟩ left_inv f := by ext; exact congr_arg f (Subsingleton.elim _ _) right_inv _ := rfl continuous_toFun := (ContinuousMap.continuous_eval_const (0 : N → I)).comp continuous_induced_dom continuous_invFun := ContinuousMap.const'.2.subtype_mk _ /-- The homotopy "group" indexed by an empty type is in bijection with the path components of `X`, aka the `ZerothHomotopy`. -/ def homotopyGroupEquivZerothHomotopyOfIsEmpty (N x) [IsEmpty N] : HomotopyGroup N X x ≃ ZerothHomotopy X := Quotient.congr (genLoopHomeoOfIsEmpty N x).toEquiv (by -- joined iff homotopic intros a₁ a₂ constructor <;> rintro ⟨H⟩ exacts [⟨{ toFun := fun t => H ⟨t, isEmptyElim⟩ source' := (H.apply_zero _).trans (congr_arg a₁ <| Subsingleton.elim _ _) target' := (H.apply_one _).trans (congr_arg a₂ <| Subsingleton.elim _ _) }⟩, ⟨{ toFun := fun t0 => H t0.fst map_zero_left := fun _ => H.source.trans (congr_arg a₁ <| Subsingleton.elim _ _) map_one_left := fun _ => H.target.trans (congr_arg a₂ <| Subsingleton.elim _ _) prop' := fun _ _ ⟨i, _⟩ => isEmptyElim i }⟩]) /-- The 0th homotopy "group" is in bijection with `ZerothHomotopy`. -/ def HomotopyGroup.pi0EquivZerothHomotopy : π_ 0 X x ≃ ZerothHomotopy X := homotopyGroupEquivZerothHomotopyOfIsEmpty (Fin 0) x /-- The 1-dimensional generalized loops based at `x` are in bijection with loops at `x`. -/ def genLoopEquivOfUnique (N) [Unique N] : Ω^ N X x ≃ Ω X x where toFun p := Path.mk ⟨fun t => p fun _ => t, by continuity⟩ (GenLoop.boundary _ (fun _ => 0) ⟨default, Or.inl rfl⟩) (GenLoop.boundary _ (fun _ => 1) ⟨default, Or.inr rfl⟩) invFun p := ⟨⟨fun c => p (c default), by continuity⟩, by rintro y ⟨i, iH | iH⟩ <;> cases Unique.eq_default i <;> apply (congr_arg p iH).trans exacts [p.source, p.target]⟩ left_inv p := by ext y; exact congr_arg p (eq_const_of_unique y).symm right_inv p := by ext; rfl /- TODO (?): deducing this from `homotopyGroupEquivFundamentalGroup` would require combination of `CategoryTheory.Functor.mapAut` and `FundamentalGroupoid.fundamentalGroupoidFunctor` applied to `genLoopHomeoOfIsEmpty`, with possibly worse defeq. -/ /-- The homotopy group at `x` indexed by a singleton is in bijection with the fundamental group, i.e. the loops based at `x` up to homotopy. -/ def homotopyGroupEquivFundamentalGroupOfUnique (N) [Unique N] : HomotopyGroup N X x ≃ FundamentalGroup X x := by refine Equiv.trans ?_ (CategoryTheory.Groupoid.isoEquivHom _ _).symm refine Quotient.congr (genLoopEquivOfUnique N) ?_ intros a₁ a₂; constructor <;> rintro ⟨H⟩ · exact ⟨{ toFun := fun tx => H (tx.fst, fun _ => tx.snd) map_zero_left := fun _ => H.apply_zero _ map_one_left := fun _ => H.apply_one _ prop' := fun t y iH => H.prop' _ _ ⟨default, iH⟩ }⟩ refine ⟨⟨⟨⟨fun tx => H (tx.fst, tx.snd default), H.continuous.comp ?_⟩, fun y => ?_, fun y => ?_⟩, ?_⟩⟩ · exact continuous_fst.prod_mk ((continuous_apply _).comp continuous_snd) · exact (H.apply_zero _).trans (congr_arg a₁ (eq_const_of_unique y).symm) · exact (H.apply_one _).trans (congr_arg a₂ (eq_const_of_unique y).symm) · rintro t y ⟨i, iH⟩ cases Unique.eq_default i exact (H.eq_fst _ iH).trans (congr_arg a₁ (eq_const_of_unique y).symm) /-- The first homotopy group at `x` is in bijection with the fundamental group. -/ def HomotopyGroup.pi1EquivFundamentalGroup : π_ 1 X x ≃ FundamentalGroup X x := homotopyGroupEquivFundamentalGroupOfUnique (Fin 1) namespace HomotopyGroup /-- Group structure on `HomotopyGroup N X x` for nonempty `N` (in particular `π_(n+1) X x`). -/ instance group (N) [DecidableEq N] [Nonempty N] : Group (HomotopyGroup N X x) := (homotopyGroupEquivFundamentalGroup <| Classical.arbitrary N).group /-- Group structure on `HomotopyGroup` obtained by pulling back path composition along the `i`th direction. The group structures for two different `i j : N` distribute over each other, and therefore are equal by the Eckmann-Hilton argument. -/ abbrev auxGroup (i : N) : Group (HomotopyGroup N X x) := (homotopyGroupEquivFundamentalGroup i).group theorem isUnital_auxGroup (i : N) : EckmannHilton.IsUnital (auxGroup i).mul (⟦const⟧ : HomotopyGroup N X x) where left_id := (auxGroup i).one_mul right_id := (auxGroup i).mul_one theorem auxGroup_indep (i j : N) : (auxGroup i : Group (HomotopyGroup N X x)) = auxGroup j := by by_cases h : i = j; · rw [h] refine Group.ext (EckmannHilton.mul (isUnital_auxGroup i) (isUnital_auxGroup j) ?_) rintro ⟨a⟩ ⟨b⟩ ⟨c⟩ ⟨d⟩ change Quotient.mk' _ = _ apply congr_arg Quotient.mk' simp only [fromLoop_trans_toLoop, transAt_distrib h, coe_toEquiv, loopHomeo_apply, coe_symm_toEquiv, loopHomeo_symm_apply] theorem transAt_indep {i} (j) (f g : Ω^ N X x) : (⟦transAt i f g⟧ : HomotopyGroup N X x) = ⟦transAt j f g⟧ := by simp_rw [← fromLoop_trans_toLoop] let m := fun (G) (_ : Group G) => ((· * ·) : G → G → G) exact congr_fun₂ (congr_arg (m <| HomotopyGroup N X x) <| auxGroup_indep i j) ⟦g⟧ ⟦f⟧ theorem symmAt_indep {i} (j) (f : Ω^ N X x) : (⟦symmAt i f⟧ : HomotopyGroup N X x) = ⟦symmAt j f⟧ := by simp_rw [← fromLoop_symm_toLoop] let inv := fun (G) (_ : Group G) => ((·⁻¹) : G → G) exact congr_fun (congr_arg (inv <| HomotopyGroup N X x) <| auxGroup_indep i j) ⟦f⟧ /-- Characterization of multiplicative identity -/ theorem one_def [Nonempty N] : (1 : HomotopyGroup N X x) = ⟦const⟧ := rfl /-- Characterization of multiplication -/ theorem mul_spec [Nonempty N] {i} {p q : Ω^ N X x} : -- Porting note (#11215): TODO: introduce `HomotopyGroup.mk` and remove defeq abuse. ((· * ·) : _ → _ → HomotopyGroup N X x) ⟦p⟧ ⟦q⟧ = ⟦transAt i q p⟧ := by rw [transAt_indep (Classical.arbitrary N) q, ← fromLoop_trans_toLoop] apply Quotient.sound rfl /-- Characterization of multiplicative inverse -/ theorem inv_spec [Nonempty N] {i} {p : Ω^ N X x} : ((⟦p⟧)⁻¹ : HomotopyGroup N X x) = ⟦symmAt i p⟧ := by rw [symmAt_indep (Classical.arbitrary N) p, ← fromLoop_symm_toLoop] apply Quotient.sound rfl /-- Multiplication on `HomotopyGroup N X x` is commutative for nontrivial `N`. In particular, multiplication on `π_(n+2)` is commutative. -/ instance commGroup [Nontrivial N] : CommGroup (HomotopyGroup N X x) := let h := exists_ne (Classical.arbitrary N) @EckmannHilton.commGroup (HomotopyGroup N X x) _ 1 (isUnital_auxGroup <| Classical.choose h) _ (by rintro ⟨a⟩ ⟨b⟩ ⟨c⟩ ⟨d⟩ apply congr_arg Quotient.mk' simp only [fromLoop_trans_toLoop, transAt_distrib <| Classical.choose_spec h, coe_toEquiv, loopHomeo_apply, coe_symm_toEquiv, loopHomeo_symm_apply]) end HomotopyGroup
Topology\Homotopy\HSpaces.lean
/- Copyright (c) 2022 Filippo A. E. Nuccio Mortarino Majno di Capriglio. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Filippo A. E. Nuccio, Junyan Xu -/ import Mathlib.Topology.CompactOpen import Mathlib.Topology.Connected.PathConnected import Mathlib.Topology.Homotopy.Basic /-! # H-spaces This file defines H-spaces mainly following the approach proposed by Serre in his paper *Homologie singulière des espaces fibrés*. The idea beneath `H-spaces` is that they are topological spaces with a binary operation `⋀ : X → X → X` that is a homotopic-theoretic weakening of an operation what would make `X` into a topological monoid. In particular, there exists a "neutral element" `e : X` such that `fun x ↦e ⋀ x` and `fun x ↦ x ⋀ e` are homotopic to the identity on `X`, see [the Wikipedia page of H-spaces](https://en.wikipedia.org/wiki/H-space). Some notable properties of `H-spaces` are * Their fundamental group is always abelian (by the same argument for topological groups); * Their cohomology ring comes equipped with a structure of a Hopf-algebra; * The loop space based at every `x : X` carries a structure of an `H-spaces`. ## Main Results * Every topological group `G` is an `H-space` using its operation `* : G → G → G` (this is already true if `G` has an instance of a `MulOneClass` and `ContinuousMul`); * Given two `H-spaces` `X` and `Y`, their product is again an `H`-space. We show in an example that starting with two topological groups `G, G'`, the `H`-space structure on `G × G'` is definitionally equal to the product of `H-space` structures on `G` and `G'`. * The loop space based at every `x : X` carries a structure of an `H-spaces`. ## To Do * Prove that for every `NormedAddTorsor Z` and every `z : Z`, the operation `fun x y ↦ midpoint x y` defines an `H-space` structure with `z` as a "neutral element". * Prove that `S^0`, `S^1`, `S^3` and `S^7` are the unique spheres that are `H-spaces`, where the first three inherit the structure because they are topological groups (they are Lie groups, actually), isomorphic to the invertible elements in `ℤ`, in `ℂ` and in the quaternion; and the fourth from the fact that `S^7` coincides with the octonions of norm 1 (it is not a group, in particular, only has an instance of `MulOneClass`). ## References * [J.-P. Serre, *Homologie singulière des espaces fibrés. Applications*, Ann. of Math (2) 1951, 54, 425–505][serre1951] -/ universe u v noncomputable section open scoped unitInterval open Path ContinuousMap Set.Icc TopologicalSpace /-- A topological space `X` is an H-space if it behaves like a (potentially non-associative) topological group, but where the axioms for a group only hold up to homotopy. -/ class HSpace (X : Type u) [TopologicalSpace X] where hmul : C(X × X, X) e : X hmul_e_e : hmul (e, e) = e eHmul : (hmul.comp <| (const X e).prodMk <| ContinuousMap.id X).HomotopyRel (ContinuousMap.id X) {e} hmulE : (hmul.comp <| (ContinuousMap.id X).prodMk <| const X e).HomotopyRel (ContinuousMap.id X) {e} /-- The binary operation `hmul` on an `H`-space -/ scoped[HSpaces] notation x "⋀" y => HSpace.hmul (x, y) -- Porting note: opening `HSpaces` so that the above notation works open HSpaces instance HSpace.prod (X : Type u) (Y : Type v) [TopologicalSpace X] [TopologicalSpace Y] [HSpace X] [HSpace Y] : HSpace (X × Y) where hmul := ⟨fun p => (p.1.1 ⋀ p.2.1, p.1.2 ⋀ p.2.2), by -- Porting note: was `continuity` exact ((map_continuous HSpace.hmul).comp ((continuous_fst.comp continuous_fst).prod_mk (continuous_fst.comp continuous_snd))).prod_mk ((map_continuous HSpace.hmul).comp ((continuous_snd.comp continuous_fst).prod_mk (continuous_snd.comp continuous_snd))) ⟩ e := (HSpace.e, HSpace.e) hmul_e_e := by simp only [ContinuousMap.coe_mk, Prod.mk.inj_iff] exact ⟨HSpace.hmul_e_e, HSpace.hmul_e_e⟩ eHmul := by let G : I × X × Y → X × Y := fun p => (HSpace.eHmul (p.1, p.2.1), HSpace.eHmul (p.1, p.2.2)) have hG : Continuous G := (Continuous.comp HSpace.eHmul.1.1.2 (continuous_fst.prod_mk (continuous_fst.comp continuous_snd))).prod_mk (Continuous.comp HSpace.eHmul.1.1.2 (continuous_fst.prod_mk (continuous_snd.comp continuous_snd))) use! ⟨G, hG⟩ · rintro ⟨x, y⟩ exact Prod.ext (HSpace.eHmul.1.2 x) (HSpace.eHmul.1.2 y) · rintro ⟨x, y⟩ exact Prod.ext (HSpace.eHmul.1.3 x) (HSpace.eHmul.1.3 y) · rintro t ⟨x, y⟩ h replace h := Prod.mk.inj_iff.mp h exact Prod.ext (HSpace.eHmul.2 t x h.1) (HSpace.eHmul.2 t y h.2) hmulE := by let G : I × X × Y → X × Y := fun p => (HSpace.hmulE (p.1, p.2.1), HSpace.hmulE (p.1, p.2.2)) have hG : Continuous G := (Continuous.comp HSpace.hmulE.1.1.2 (continuous_fst.prod_mk (continuous_fst.comp continuous_snd))).prod_mk (Continuous.comp HSpace.hmulE.1.1.2 (continuous_fst.prod_mk (continuous_snd.comp continuous_snd))) use! ⟨G, hG⟩ · rintro ⟨x, y⟩ exact Prod.ext (HSpace.hmulE.1.2 x) (HSpace.hmulE.1.2 y) · rintro ⟨x, y⟩ exact Prod.ext (HSpace.hmulE.1.3 x) (HSpace.hmulE.1.3 y) · rintro t ⟨x, y⟩ h replace h := Prod.mk.inj_iff.mp h exact Prod.ext (HSpace.hmulE.2 t x h.1) (HSpace.hmulE.2 t y h.2) namespace TopologicalGroup /-- The definition `toHSpace` is not an instance because its additive version would lead to a diamond since a topological field would inherit two `HSpace` structures, one from the `MulOneClass` and one from the `AddZeroClass`. In the case of a group, we make `TopologicalGroup.hSpace` an instance."-/ @[to_additive "The definition `toHSpace` is not an instance because it comes together with a multiplicative version which would lead to a diamond since a topological field would inherit two `HSpace` structures, one from the `MulOneClass` and one from the `AddZeroClass`. In the case of an additive group, we make `TopologicalAddGroup.hSpace` an instance."] def toHSpace (M : Type u) [MulOneClass M] [TopologicalSpace M] [ContinuousMul M] : HSpace M where hmul := ⟨Function.uncurry Mul.mul, continuous_mul⟩ e := 1 hmul_e_e := one_mul 1 eHmul := (HomotopyRel.refl _ _).cast rfl (by ext1; apply one_mul) hmulE := (HomotopyRel.refl _ _).cast rfl (by ext1; apply mul_one) @[to_additive] instance (priority := 600) hSpace (G : Type u) [TopologicalSpace G] [Group G] [TopologicalGroup G] : HSpace G := toHSpace G theorem one_eq_hSpace_e {G : Type u} [TopologicalSpace G] [Group G] [TopologicalGroup G] : (1 : G) = HSpace.e := rfl /- In the following example we see that the H-space structure on the product of two topological groups is definitionally equally to the product H-space-structure of the two groups. -/ example {G G' : Type u} [TopologicalSpace G] [Group G] [TopologicalGroup G] [TopologicalSpace G'] [Group G'] [TopologicalGroup G'] : TopologicalGroup.hSpace (G × G') = HSpace.prod G G' := by simp only [HSpace.prod] rfl end TopologicalGroup namespace unitInterval /-- `qRight` is analogous to the function `Q` defined on p. 475 of [serre1951] that helps proving continuity of `delayReflRight`. -/ def qRight (p : I × I) : I := Set.projIcc 0 1 zero_le_one (2 * p.1 / (1 + p.2)) theorem continuous_qRight : Continuous qRight := continuous_projIcc.comp <| Continuous.div (by fun_prop) (by fun_prop) fun x ↦ (add_pos zero_lt_one).ne' theorem qRight_zero_left (θ : I) : qRight (0, θ) = 0 := Set.projIcc_of_le_left _ <| by simp only [coe_zero, mul_zero, zero_div, le_refl] theorem qRight_one_left (θ : I) : qRight (1, θ) = 1 := Set.projIcc_of_right_le _ <| (le_div_iff <| add_pos zero_lt_one).2 <| by dsimp only rw [coe_one, one_mul, mul_one, add_comm, ← one_add_one_eq_two] simp only [add_le_add_iff_right] exact le_one _ theorem qRight_zero_right (t : I) : (qRight (t, 0) : ℝ) = if (t : ℝ) ≤ 1 / 2 then (2 : ℝ) * t else 1 := by simp only [qRight, coe_zero, add_zero, div_one] split_ifs · rw [Set.projIcc_of_mem _ ((mul_pos_mem_iff zero_lt_two).2 _)] refine ⟨t.2.1, ?_⟩ tauto · rw [(Set.projIcc_eq_right _).2] · linarith · exact zero_lt_one theorem qRight_one_right (t : I) : qRight (t, 1) = t := Eq.trans (by rw [qRight]; norm_num) <| Set.projIcc_val zero_le_one _ end unitInterval namespace Path open unitInterval variable {X : Type u} [TopologicalSpace X] {x y : X} /-- This is the function analogous to the one on p. 475 of [serre1951], defining a homotopy from the product path `γ ∧ e` to `γ`. -/ def delayReflRight (θ : I) (γ : Path x y) : Path x y where toFun t := γ (qRight (t, θ)) continuous_toFun := γ.continuous.comp (continuous_qRight.comp <| Continuous.Prod.mk_left θ) source' := by dsimp only rw [qRight_zero_left, γ.source] target' := by dsimp only rw [qRight_one_left, γ.target] theorem continuous_delayReflRight : Continuous fun p : I × Path x y => delayReflRight p.1 p.2 := continuous_uncurry_iff.mp <| (continuous_snd.comp continuous_fst).path_eval <| continuous_qRight.comp <| continuous_snd.prod_mk <| continuous_fst.comp continuous_fst theorem delayReflRight_zero (γ : Path x y) : delayReflRight 0 γ = γ.trans (Path.refl y) := by ext t simp only [delayReflRight, trans_apply, refl_extend, Path.coe_mk_mk, Function.comp_apply, refl_apply] split_ifs with h; swap on_goal 1 => conv_rhs => rw [← γ.target] all_goals apply congr_arg γ; ext1; rw [qRight_zero_right] exacts [if_neg h, if_pos h] theorem delayReflRight_one (γ : Path x y) : delayReflRight 1 γ = γ := by ext t exact congr_arg γ (qRight_one_right t) /-- This is the function on p. 475 of [serre1951], defining a homotopy from a path `γ` to the product path `e ∧ γ`. -/ def delayReflLeft (θ : I) (γ : Path x y) : Path x y := (delayReflRight θ γ.symm).symm theorem continuous_delayReflLeft : Continuous fun p : I × Path x y => delayReflLeft p.1 p.2 := Path.continuous_symm.comp <| continuous_delayReflRight.comp <| continuous_fst.prod_mk <| Path.continuous_symm.comp continuous_snd theorem delayReflLeft_zero (γ : Path x y) : delayReflLeft 0 γ = (Path.refl x).trans γ := by simp only [delayReflLeft, delayReflRight_zero, trans_symm, refl_symm, Path.symm_symm] theorem delayReflLeft_one (γ : Path x y) : delayReflLeft 1 γ = γ := by simp only [delayReflLeft, delayReflRight_one, Path.symm_symm] /-- The loop space at x carries a structure of an H-space. Note that the field `eHmul` (resp. `hmulE`) neither implies nor is implied by `Path.Homotopy.reflTrans` (resp. `Path.Homotopy.transRefl`). -/ instance (x : X) : HSpace (Path x x) where hmul := ⟨fun ρ => ρ.1.trans ρ.2, continuous_trans⟩ e := refl x hmul_e_e := refl_trans_refl eHmul := { toHomotopy := ⟨⟨fun p : I × Path x x ↦ delayReflLeft p.1 p.2, continuous_delayReflLeft⟩, delayReflLeft_zero, delayReflLeft_one⟩ prop' := by rintro t _ rfl; exact refl_trans_refl.symm } hmulE := { toHomotopy := ⟨⟨fun p : I × Path x x ↦ delayReflRight p.1 p.2, continuous_delayReflRight⟩, delayReflRight_zero, delayReflRight_one⟩ prop' := by rintro t _ rfl; exact refl_trans_refl.symm } end Path
Topology\Homotopy\Path.lean
/- Copyright (c) 2021 Shing Tak Lam. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Shing Tak Lam -/ import Mathlib.Topology.Homotopy.Basic import Mathlib.Topology.Connected.PathConnected import Mathlib.Analysis.Convex.Basic /-! # Homotopy between paths In this file, we define a `Homotopy` between two `Path`s. In addition, we define a relation `Homotopic` on `Path`s, and prove that it is an equivalence relation. ## Definitions * `Path.Homotopy p₀ p₁` is the type of homotopies between paths `p₀` and `p₁` * `Path.Homotopy.refl p` is the constant homotopy between `p` and itself * `Path.Homotopy.symm F` is the `Path.Homotopy p₁ p₀` defined by reversing the homotopy * `Path.Homotopy.trans F G`, where `F : Path.Homotopy p₀ p₁`, `G : Path.Homotopy p₁ p₂` is the `Path.Homotopy p₀ p₂` defined by putting the first homotopy on `[0, 1/2]` and the second on `[1/2, 1]` * `Path.Homotopy.hcomp F G`, where `F : Path.Homotopy p₀ q₀` and `G : Path.Homotopy p₁ q₁` is a `Path.Homotopy (p₀.trans p₁) (q₀.trans q₁)` * `Path.Homotopic p₀ p₁` is the relation saying that there is a homotopy between `p₀` and `p₁` * `Path.Homotopic.setoid x₀ x₁` is the setoid on `Path`s from `Path.Homotopic` * `Path.Homotopic.Quotient x₀ x₁` is the quotient type from `Path x₀ x₀` by `Path.Homotopic.setoid` -/ universe u v variable {X : Type u} {Y : Type v} [TopologicalSpace X] [TopologicalSpace Y] variable {x₀ x₁ x₂ x₃ : X} noncomputable section open unitInterval namespace Path /-- The type of homotopies between two paths. -/ abbrev Homotopy (p₀ p₁ : Path x₀ x₁) := ContinuousMap.HomotopyRel p₀.toContinuousMap p₁.toContinuousMap {0, 1} namespace Homotopy section variable {p₀ p₁ : Path x₀ x₁} theorem coeFn_injective : @Function.Injective (Homotopy p₀ p₁) (I × I → X) (⇑) := DFunLike.coe_injective @[simp] theorem source (F : Homotopy p₀ p₁) (t : I) : F (t, 0) = x₀ := calc F (t, 0) = p₀ 0 := ContinuousMap.HomotopyRel.eq_fst _ _ (.inl rfl) _ = x₀ := p₀.source @[simp] theorem target (F : Homotopy p₀ p₁) (t : I) : F (t, 1) = x₁ := calc F (t, 1) = p₀ 1 := ContinuousMap.HomotopyRel.eq_fst _ _ (.inr rfl) _ = x₁ := p₀.target /-- Evaluating a path homotopy at an intermediate point, giving us a `Path`. -/ def eval (F : Homotopy p₀ p₁) (t : I) : Path x₀ x₁ where toFun := F.toHomotopy.curry t source' := by simp target' := by simp @[simp] theorem eval_zero (F : Homotopy p₀ p₁) : F.eval 0 = p₀ := by ext t simp [eval] @[simp] theorem eval_one (F : Homotopy p₀ p₁) : F.eval 1 = p₁ := by ext t simp [eval] end section variable {p₀ p₁ p₂ : Path x₀ x₁} /-- Given a path `p`, we can define a `Homotopy p p` by `F (t, x) = p x`. -/ @[simps!] def refl (p : Path x₀ x₁) : Homotopy p p := ContinuousMap.HomotopyRel.refl p.toContinuousMap {0, 1} /-- Given a `Homotopy p₀ p₁`, we can define a `Homotopy p₁ p₀` by reversing the homotopy. -/ @[simps!] def symm (F : Homotopy p₀ p₁) : Homotopy p₁ p₀ := ContinuousMap.HomotopyRel.symm F @[simp] theorem symm_symm (F : Homotopy p₀ p₁) : F.symm.symm = F := ContinuousMap.HomotopyRel.symm_symm F theorem symm_bijective : Function.Bijective (Homotopy.symm : Homotopy p₀ p₁ → Homotopy p₁ p₀) := Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩ /-- Given `Homotopy p₀ p₁` and `Homotopy p₁ p₂`, we can define a `Homotopy p₀ p₂` by putting the first homotopy on `[0, 1/2]` and the second on `[1/2, 1]`. -/ def trans (F : Homotopy p₀ p₁) (G : Homotopy p₁ p₂) : Homotopy p₀ p₂ := ContinuousMap.HomotopyRel.trans F G theorem trans_apply (F : Homotopy p₀ p₁) (G : Homotopy p₁ p₂) (x : I × I) : (F.trans G) x = if h : (x.1 : ℝ) ≤ 1 / 2 then F (⟨2 * x.1, (unitInterval.mul_pos_mem_iff zero_lt_two).2 ⟨x.1.2.1, h⟩⟩, x.2) else G (⟨2 * x.1 - 1, unitInterval.two_mul_sub_one_mem_iff.2 ⟨(not_le.1 h).le, x.1.2.2⟩⟩, x.2) := ContinuousMap.HomotopyRel.trans_apply _ _ _ theorem symm_trans (F : Homotopy p₀ p₁) (G : Homotopy p₁ p₂) : (F.trans G).symm = G.symm.trans F.symm := ContinuousMap.HomotopyRel.symm_trans _ _ /-- Casting a `Homotopy p₀ p₁` to a `Homotopy q₀ q₁` where `p₀ = q₀` and `p₁ = q₁`. -/ @[simps!] def cast {p₀ p₁ q₀ q₁ : Path x₀ x₁} (F : Homotopy p₀ p₁) (h₀ : p₀ = q₀) (h₁ : p₁ = q₁) : Homotopy q₀ q₁ := ContinuousMap.HomotopyRel.cast F (congr_arg _ h₀) (congr_arg _ h₁) end section variable {p₀ q₀ : Path x₀ x₁} {p₁ q₁ : Path x₁ x₂} /-- Suppose `p₀` and `q₀` are paths from `x₀` to `x₁`, `p₁` and `q₁` are paths from `x₁` to `x₂`. Furthermore, suppose `F : Homotopy p₀ q₀` and `G : Homotopy p₁ q₁`. Then we can define a homotopy from `p₀.trans p₁` to `q₀.trans q₁`. -/ def hcomp (F : Homotopy p₀ q₀) (G : Homotopy p₁ q₁) : Homotopy (p₀.trans p₁) (q₀.trans q₁) where toFun x := if (x.2 : ℝ) ≤ 1 / 2 then (F.eval x.1).extend (2 * x.2) else (G.eval x.1).extend (2 * x.2 - 1) continuous_toFun := continuous_if_le (continuous_induced_dom.comp continuous_snd) continuous_const (F.toHomotopy.continuous.comp (by continuity)).continuousOn (G.toHomotopy.continuous.comp (by continuity)).continuousOn fun x hx => by norm_num [hx] map_zero_left x := by simp [Path.trans] map_one_left x := by simp [Path.trans] prop' x t ht := by cases' ht with ht ht · norm_num [ht] · rw [Set.mem_singleton_iff] at ht norm_num [ht] theorem hcomp_apply (F : Homotopy p₀ q₀) (G : Homotopy p₁ q₁) (x : I × I) : F.hcomp G x = if h : (x.2 : ℝ) ≤ 1 / 2 then F.eval x.1 ⟨2 * x.2, (unitInterval.mul_pos_mem_iff zero_lt_two).2 ⟨x.2.2.1, h⟩⟩ else G.eval x.1 ⟨2 * x.2 - 1, unitInterval.two_mul_sub_one_mem_iff.2 ⟨(not_le.1 h).le, x.2.2.2⟩⟩ := show ite _ _ _ = _ by split_ifs <;> exact Path.extend_extends _ _ theorem hcomp_half (F : Homotopy p₀ q₀) (G : Homotopy p₁ q₁) (t : I) : F.hcomp G (t, ⟨1 / 2, by norm_num, by norm_num⟩) = x₁ := show ite _ _ _ = _ by norm_num end /-- Suppose `p` is a path, then we have a homotopy from `p` to `p.reparam f` by the convexity of `I`. -/ def reparam (p : Path x₀ x₁) (f : I → I) (hf : Continuous f) (hf₀ : f 0 = 0) (hf₁ : f 1 = 1) : Homotopy p (p.reparam f hf hf₀ hf₁) where toFun x := p ⟨σ x.1 * x.2 + x.1 * f x.2, show (σ x.1 : ℝ) • (x.2 : ℝ) + (x.1 : ℝ) • (f x.2 : ℝ) ∈ I from convex_Icc _ _ x.2.2 (f x.2).2 (by unit_interval) (by unit_interval) (by simp)⟩ map_zero_left x := by norm_num map_one_left x := by norm_num prop' t x hx := by cases' hx with hx hx · rw [hx] simp [hf₀] · rw [Set.mem_singleton_iff] at hx rw [hx] simp [hf₁] continuous_toFun := by -- Porting note: was `continuity` in auto-param refine continuous_const.path_eval ?_ apply Continuous.subtype_mk apply Continuous.add <;> apply Continuous.mul · exact continuous_induced_dom.comp (unitInterval.continuous_symm.comp continuous_fst) · continuity · continuity · continuity /-- Suppose `F : Homotopy p q`. Then we have a `Homotopy p.symm q.symm` by reversing the second argument. -/ @[simps] def symm₂ {p q : Path x₀ x₁} (F : p.Homotopy q) : p.symm.Homotopy q.symm where toFun x := F ⟨x.1, σ x.2⟩ map_zero_left := by simp [Path.symm] map_one_left := by simp [Path.symm] prop' t x hx := by cases' hx with hx hx · rw [hx] simp · rw [Set.mem_singleton_iff] at hx rw [hx] simp /-- Given `F : Homotopy p q`, and `f : C(X, Y)`, we can define a homotopy from `p.map f.continuous` to `q.map f.continuous`. -/ @[simps] def map {p q : Path x₀ x₁} (F : p.Homotopy q) (f : C(X, Y)) : Homotopy (p.map f.continuous) (q.map f.continuous) where toFun := f ∘ F map_zero_left := by simp map_one_left := by simp prop' t x hx := by cases' hx with hx hx · simp [hx] · rw [Set.mem_singleton_iff] at hx simp [hx] end Homotopy /-- Two paths `p₀` and `p₁` are `Path.Homotopic` if there exists a `Homotopy` between them. -/ def Homotopic (p₀ p₁ : Path x₀ x₁) : Prop := Nonempty (p₀.Homotopy p₁) namespace Homotopic @[refl] theorem refl (p : Path x₀ x₁) : p.Homotopic p := ⟨Homotopy.refl p⟩ @[symm] theorem symm ⦃p₀ p₁ : Path x₀ x₁⦄ (h : p₀.Homotopic p₁) : p₁.Homotopic p₀ := h.map Homotopy.symm @[trans] theorem trans ⦃p₀ p₁ p₂ : Path x₀ x₁⦄ (h₀ : p₀.Homotopic p₁) (h₁ : p₁.Homotopic p₂) : p₀.Homotopic p₂ := h₀.map2 Homotopy.trans h₁ theorem equivalence : Equivalence (@Homotopic X _ x₀ x₁) := ⟨refl, (symm ·), (trans · ·)⟩ nonrec theorem map {p q : Path x₀ x₁} (h : p.Homotopic q) (f : C(X, Y)) : Homotopic (p.map f.continuous) (q.map f.continuous) := h.map fun F => F.map f theorem hcomp {p₀ p₁ : Path x₀ x₁} {q₀ q₁ : Path x₁ x₂} (hp : p₀.Homotopic p₁) (hq : q₀.Homotopic q₁) : (p₀.trans q₀).Homotopic (p₁.trans q₁) := hp.map2 Homotopy.hcomp hq /-- The setoid on `Path`s defined by the equivalence relation `Path.Homotopic`. That is, two paths are equivalent if there is a `Homotopy` between them. -/ protected def setoid (x₀ x₁ : X) : Setoid (Path x₀ x₁) := ⟨Homotopic, equivalence⟩ /-- The quotient on `Path x₀ x₁` by the equivalence relation `Path.Homotopic`. -/ protected def Quotient (x₀ x₁ : X) := Quotient (Homotopic.setoid x₀ x₁) attribute [local instance] Homotopic.setoid instance : Inhabited (Homotopic.Quotient () ()) := ⟨Quotient.mk' <| Path.refl ()⟩ /-- The composition of path homotopy classes. This is `Path.trans` descended to the quotient. -/ def Quotient.comp (P₀ : Path.Homotopic.Quotient x₀ x₁) (P₁ : Path.Homotopic.Quotient x₁ x₂) : Path.Homotopic.Quotient x₀ x₂ := Quotient.map₂ Path.trans (fun (_ : Path x₀ x₁) _ hp (_ : Path x₁ x₂) _ hq => hcomp hp hq) P₀ P₁ theorem comp_lift (P₀ : Path x₀ x₁) (P₁ : Path x₁ x₂) : ⟦P₀.trans P₁⟧ = Quotient.comp ⟦P₀⟧ ⟦P₁⟧ := rfl /-- The image of a path homotopy class `P₀` under a map `f`. This is `Path.map` descended to the quotient. -/ def Quotient.mapFn (P₀ : Path.Homotopic.Quotient x₀ x₁) (f : C(X, Y)) : Path.Homotopic.Quotient (f x₀) (f x₁) := Quotient.map (fun q : Path x₀ x₁ => q.map f.continuous) (fun _ _ h => Path.Homotopic.map h f) P₀ theorem map_lift (P₀ : Path x₀ x₁) (f : C(X, Y)) : ⟦P₀.map f.continuous⟧ = Quotient.mapFn ⟦P₀⟧ f := rfl -- Porting note: Type was originally `HEq ⟦p₁⟧ ⟦p₂⟧` theorem hpath_hext {p₁ : Path x₀ x₁} {p₂ : Path x₂ x₃} (hp : ∀ t, p₁ t = p₂ t) : @HEq (Path.Homotopic.Quotient _ _) ⟦p₁⟧ (Path.Homotopic.Quotient _ _) ⟦p₂⟧ := by obtain rfl : x₀ = x₂ := by convert hp 0 <;> simp obtain rfl : x₁ = x₃ := by convert hp 1 <;> simp rw [heq_iff_eq]; congr; ext t; exact hp t end Homotopic /-- A path `Path x₀ x₁` generates a homotopy between constant functions `fun _ ↦ x₀` and `fun _ ↦ x₁`. -/ @[simps!] def toHomotopyConst (p : Path x₀ x₁) : (ContinuousMap.const Y x₀).Homotopy (ContinuousMap.const Y x₁) where toContinuousMap := p.toContinuousMap.comp ContinuousMap.fst map_zero_left _ := p.source map_one_left _ := p.target end Path /-- Two constant continuous maps with nonempty domain are homotopic if and only if their values are joined by a path in the codomain. -/ @[simp] theorem ContinuousMap.homotopic_const_iff [Nonempty Y] : (ContinuousMap.const Y x₀).Homotopic (ContinuousMap.const Y x₁) ↔ Joined x₀ x₁ := by inhabit Y refine ⟨fun ⟨H⟩ ↦ ⟨⟨(H.toContinuousMap.comp .prodSwap).curry default, ?_, ?_⟩⟩, fun ⟨p⟩ ↦ ⟨p.toHomotopyConst⟩⟩ <;> simp namespace ContinuousMap.Homotopy /-- Given a homotopy `H : f ∼ g`, get the path traced by the point `x` as it moves from `f x` to `g x`. -/ def evalAt {X : Type*} {Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] {f g : C(X, Y)} (H : ContinuousMap.Homotopy f g) (x : X) : Path (f x) (g x) where toFun t := H (t, x) source' := H.apply_zero x target' := H.apply_one x end ContinuousMap.Homotopy
Topology\Homotopy\Product.lean
/- Copyright (c) 2021 Praneeth Kolichala. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Praneeth Kolichala -/ import Mathlib.Topology.Constructions import Mathlib.Topology.Homotopy.Path /-! # Product of homotopies In this file, we introduce definitions for the product of homotopies. We show that the products of relative homotopies are still relative homotopies. Finally, we specialize to the case of path homotopies, and provide the definition for the product of path classes. We show various lemmas associated with these products, such as the fact that path products commute with path composition, and that projection is the inverse of products. ## Definitions ### General homotopies - `ContinuousMap.Homotopy.pi homotopies`: Let f and g be a family of functions indexed on I, such that for each i ∈ I, fᵢ and gᵢ are maps from A to Xᵢ. Let `homotopies` be a family of homotopies from fᵢ to gᵢ for each i. Then `Homotopy.pi homotopies` is the canonical homotopy from ∏ f to ∏ g, where ∏ f is the product map from A to Πi, Xᵢ, and similarly for ∏ g. - `ContinuousMap.HomotopyRel.pi homotopies`: Same as `ContinuousMap.Homotopy.pi`, but all homotopies are done relative to some set S ⊆ A. - `ContinuousMap.Homotopy.prod F G` is the product of homotopies F and G, where F is a homotopy between f₀ and f₁, G is a homotopy between g₀ and g₁. The result F × G is a homotopy between (f₀ × g₀) and (f₁ × g₁). Again, all homotopies are done relative to S. - `ContinuousMap.HomotopyRel.prod F G`: Same as `ContinuousMap.Homotopy.prod`, but all homotopies are done relative to some set S ⊆ A. ### Path products - `Path.Homotopic.pi` The product of a family of path classes, where a path class is an equivalence class of paths up to path homotopy. - `Path.Homotopic.prod` The product of two path classes. -/ noncomputable section namespace ContinuousMap open ContinuousMap section Pi variable {I A : Type*} {X : I → Type*} [∀ i, TopologicalSpace (X i)] [TopologicalSpace A] {f g : ∀ i, C(A, X i)} {S : Set A} -- Porting note: this definition is already in `Topology.Homotopy.Basic` -- /-- The product homotopy of `homotopies` between functions `f` and `g` -/ -- @[simps] -- def Homotopy.pi (homotopies : ∀ i, Homotopy (f i) (g i)) : Homotopy (pi f) (pi g) where -- toFun t i := homotopies i t -- map_zero_left t := by ext i; simp only [pi_eval, Homotopy.apply_zero] -- map_one_left t := by ext i; simp only [pi_eval, Homotopy.apply_one] /-- The relative product homotopy of `homotopies` between functions `f` and `g` -/ @[simps!] def HomotopyRel.pi (homotopies : ∀ i : I, HomotopyRel (f i) (g i) S) : HomotopyRel (pi f) (pi g) S := { Homotopy.pi fun i => (homotopies i).toHomotopy with prop' := by intro t x hx dsimp only [coe_mk, pi_eval, toFun_eq_coe, HomotopyWith.coe_toContinuousMap] simp only [Function.funext_iff, ← forall_and] intro i exact (homotopies i).prop' t x hx } end Pi section Prod variable {α β : Type*} [TopologicalSpace α] [TopologicalSpace β] {A : Type*} [TopologicalSpace A] {f₀ f₁ : C(A, α)} {g₀ g₁ : C(A, β)} {S : Set A} /-- The product of homotopies `F` and `G`, where `F` takes `f₀` to `f₁` and `G` takes `g₀` to `g₁` -/ @[simps] def Homotopy.prod (F : Homotopy f₀ f₁) (G : Homotopy g₀ g₁) : Homotopy (ContinuousMap.prodMk f₀ g₀) (ContinuousMap.prodMk f₁ g₁) where toFun t := (F t, G t) map_zero_left x := by simp only [prod_eval, Homotopy.apply_zero] map_one_left x := by simp only [prod_eval, Homotopy.apply_one] /-- The relative product of homotopies `F` and `G`, where `F` takes `f₀` to `f₁` and `G` takes `g₀` to `g₁` -/ @[simps!] def HomotopyRel.prod (F : HomotopyRel f₀ f₁ S) (G : HomotopyRel g₀ g₁ S) : HomotopyRel (prodMk f₀ g₀) (prodMk f₁ g₁) S where toHomotopy := Homotopy.prod F.toHomotopy G.toHomotopy prop' t x hx := Prod.ext (F.prop' t x hx) (G.prop' t x hx) end Prod end ContinuousMap namespace Path.Homotopic attribute [local instance] Path.Homotopic.setoid local infixl:70 " ⬝ " => Quotient.comp section Pi variable {ι : Type*} {X : ι → Type*} [∀ i, TopologicalSpace (X i)] {as bs cs : ∀ i, X i} /-- The product of a family of path homotopies. This is just a specialization of `HomotopyRel`. -/ def piHomotopy (γ₀ γ₁ : ∀ i, Path (as i) (bs i)) (H : ∀ i, Path.Homotopy (γ₀ i) (γ₁ i)) : Path.Homotopy (Path.pi γ₀) (Path.pi γ₁) := ContinuousMap.HomotopyRel.pi H /-- The product of a family of path homotopy classes. -/ def pi (γ : ∀ i, Path.Homotopic.Quotient (as i) (bs i)) : Path.Homotopic.Quotient as bs := (Quotient.map Path.pi fun x y hxy => Nonempty.map (piHomotopy x y) (Classical.nonempty_pi.mpr hxy)) (Quotient.choice γ) theorem pi_lift (γ : ∀ i, Path (as i) (bs i)) : (Path.Homotopic.pi fun i => ⟦γ i⟧) = ⟦Path.pi γ⟧ := by unfold pi; simp /-- Composition and products commute. This is `Path.trans_pi_eq_pi_trans` descended to path homotopy classes. -/ theorem comp_pi_eq_pi_comp (γ₀ : ∀ i, Path.Homotopic.Quotient (as i) (bs i)) (γ₁ : ∀ i, Path.Homotopic.Quotient (bs i) (cs i)) : pi γ₀ ⬝ pi γ₁ = pi fun i ↦ γ₀ i ⬝ γ₁ i := by induction γ₁ using Quotient.induction_on_pi with | _ a => induction γ₀ using Quotient.induction_on_pi simp only [pi_lift] rw [← Path.Homotopic.comp_lift, Path.trans_pi_eq_pi_trans, ← pi_lift] rfl /-- Abbreviation for projection onto the ith coordinate. -/ abbrev proj (i : ι) (p : Path.Homotopic.Quotient as bs) : Path.Homotopic.Quotient (as i) (bs i) := p.mapFn ⟨_, continuous_apply i⟩ /-- Lemmas showing projection is the inverse of pi. -/ @[simp] theorem proj_pi (i : ι) (paths : ∀ i, Path.Homotopic.Quotient (as i) (bs i)) : proj i (pi paths) = paths i := by induction paths using Quotient.induction_on_pi rw [proj, pi_lift, ← Path.Homotopic.map_lift] congr @[simp] theorem pi_proj (p : Path.Homotopic.Quotient as bs) : (pi fun i => proj i p) = p := by induction p using Quotient.inductionOn simp_rw [proj, ← Path.Homotopic.map_lift] erw [pi_lift] congr end Pi section Prod variable {α β : Type*} [TopologicalSpace α] [TopologicalSpace β] {a₁ a₂ a₃ : α} {b₁ b₂ b₃ : β} {p₁ p₁' : Path a₁ a₂} {p₂ p₂' : Path b₁ b₂} (q₁ : Path.Homotopic.Quotient a₁ a₂) (q₂ : Path.Homotopic.Quotient b₁ b₂) /-- The product of homotopies h₁ and h₂. This is `HomotopyRel.prod` specialized for path homotopies. -/ def prodHomotopy (h₁ : Path.Homotopy p₁ p₁') (h₂ : Path.Homotopy p₂ p₂') : Path.Homotopy (p₁.prod p₂) (p₁'.prod p₂') := ContinuousMap.HomotopyRel.prod h₁ h₂ /-- The product of path classes q₁ and q₂. This is `Path.prod` descended to the quotient. -/ def prod (q₁ : Path.Homotopic.Quotient a₁ a₂) (q₂ : Path.Homotopic.Quotient b₁ b₂) : Path.Homotopic.Quotient (a₁, b₁) (a₂, b₂) := Quotient.map₂ Path.prod (fun _ _ h₁ _ _ h₂ => Nonempty.map2 prodHomotopy h₁ h₂) q₁ q₂ variable (p₁ p₁' p₂ p₂') theorem prod_lift : prod ⟦p₁⟧ ⟦p₂⟧ = ⟦p₁.prod p₂⟧ := rfl variable (r₁ : Path.Homotopic.Quotient a₂ a₃) (r₂ : Path.Homotopic.Quotient b₂ b₃) /-- Products commute with path composition. This is `trans_prod_eq_prod_trans` descended to the quotient. -/ theorem comp_prod_eq_prod_comp : prod q₁ q₂ ⬝ prod r₁ r₂ = prod (q₁ ⬝ r₁) (q₂ ⬝ r₂) := by induction q₁, q₂ using Quotient.inductionOn₂ induction r₁, r₂ using Quotient.inductionOn₂ simp only [prod_lift, ← Path.Homotopic.comp_lift, Path.trans_prod_eq_prod_trans] variable {c₁ c₂ : α × β} /-- Abbreviation for projection onto the left coordinate of a path class. -/ abbrev projLeft (p : Path.Homotopic.Quotient c₁ c₂) : Path.Homotopic.Quotient c₁.1 c₂.1 := p.mapFn ⟨_, continuous_fst⟩ /-- Abbreviation for projection onto the right coordinate of a path class. -/ abbrev projRight (p : Path.Homotopic.Quotient c₁ c₂) : Path.Homotopic.Quotient c₁.2 c₂.2 := p.mapFn ⟨_, continuous_snd⟩ /-- Lemmas showing projection is the inverse of product. -/ @[simp] theorem projLeft_prod : projLeft (prod q₁ q₂) = q₁ := by induction q₁, q₂ using Quotient.inductionOn₂ rw [projLeft, prod_lift, ← Path.Homotopic.map_lift] congr @[simp] theorem projRight_prod : projRight (prod q₁ q₂) = q₂ := by induction q₁, q₂ using Quotient.inductionOn₂ rw [projRight, prod_lift, ← Path.Homotopic.map_lift] congr @[simp] theorem prod_projLeft_projRight (p : Path.Homotopic.Quotient (a₁, b₁) (a₂, b₂)) : prod (projLeft p) (projRight p) = p := by induction p using Quotient.inductionOn simp only [projLeft, projRight, ← Path.Homotopic.map_lift, prod_lift] congr end Prod end Path.Homotopic
Topology\Instances\AddCircle.lean
/- Copyright (c) 2022 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Order.ToIntervalMod import Mathlib.Algebra.Ring.AddAut import Mathlib.Data.Nat.Totient import Mathlib.GroupTheory.Divisible import Mathlib.Topology.Connected.PathConnected import Mathlib.Topology.IsLocalHomeomorph /-! # 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`: the natural equivalence `AddCircle p ≃ Ico 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`: 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 [LinearOrderedAddCommGroup 𝕜] [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)] -- Porting note: added have : ContinuousNeg 𝕜 := TopologicalAddGroup.toContinuousNeg 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 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`. -/ @[nolint unusedArguments] abbrev AddCircle [LinearOrderedAddCommGroup 𝕜] (p : 𝕜) := 𝕜 ⧸ zmultiples p namespace AddCircle section LinearOrderedAddCommGroup variable [LinearOrderedAddCommGroup 𝕜] (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 theorem coe_eq_zero_iff {x : 𝕜} : (x : AddCircle p) = 0 ↔ ∃ n : ℤ, n • p = x := by simp [AddSubgroup.mem_zmultiples_iff] 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⟩ theorem coe_period : (p : AddCircle p) = 0 := (QuotientAddGroup.eq_zero_iff p).2 <| mem_zmultiples p /- Porting note (#10618): `simp` attribute removed because linter reports: simp can prove this: by simp only [@mem_zmultiples, @QuotientAddGroup.mk_add_of_mem] -/ 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 [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 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 have : (equivIco p a) x = ⟨x, hx⟩ := by rw [Equiv.apply_eq_iff_eq_symm_apply] rfl rw [liftIco, comp_apply, this] rfl theorem liftIoc_coe_apply {f : 𝕜 → B} {x : 𝕜} (hx : x ∈ Ioc a (a + p)) : liftIoc p a f ↑x = f x := by have : (equivIoc p a) x = ⟨x, hx⟩ := by rw [Equiv.apply_eq_iff_eq_symm_apply] rfl rw [liftIoc, comp_apply, this] 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 a partial homeomorphism. -/ @[simps] def partialHomeomorphCoe [DiscreteTopology (zmultiples p)] : PartialHomeomorph 𝕜 (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 ContinuousAt.continuousOn (fun _ ↦ continuousAt_subtype_val.comp ∘ continuousAt_equivIco p a) 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 ⟨partialHomeomorphCoe 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_subset _ Ico_subset_Icc_self) <| coe_image_Ico_eq _ _ end LinearOrderedAddCommGroup section LinearOrderedField variable [LinearOrderedField 𝕜] (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 [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 variable [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 only [algebraMap.coe_zero, Int.cast_zero, inv_zero, zero_mul, QuotientAddGroup.mk_zero] 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 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_lt hn variable (p) theorem gcd_mul_addOrderOf_div_eq {n : ℕ} (m : ℕ) (hn : 0 < n) : m.gcd n * addOrderOf (↑(↑m / ↑n * p) : AddCircle p) = n := by rw [mul_comm_div, ← nsmul_eq_mul, coe_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] variable {p} 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 induction m · simp only [Int.ofNat_eq_coe, Int.cast_natCast, Int.natAbs_ofNat] 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 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 fun k hk => ?_, ?_⟩ · rintro ⟨m, _, h₁, rfl⟩ exact addOrderOf_div_of_gcd_eq_one h h₁ have h0 := addOrderOf_nsmul_eq_zero (k : AddCircle p) rw [hk, ← coe_nsmul, coe_eq_zero_iff] at h0 obtain ⟨a, ha⟩ := h0 have h0 : (_ : 𝕜) ≠ 0 := Nat.cast_ne_zero.2 h.ne' rw [nsmul_eq_mul, mul_comm, ← div_eq_iff h0, ← a.ediv_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 have han : _ = a % n := Int.toNat_of_nonneg (Int.emod_nonneg _ <| mod_cast h.ne') have he : (↑(↑((a % n).toNat) / ↑n * p) : AddCircle p) = k := by convert congr_arg (QuotientAddGroup.mk : 𝕜 → (AddCircle p)) ha using 1 rw [coe_add, ← Int.cast_natCast, han, zsmul_eq_mul, mul_div_right_comm, eq_comm, add_left_eq_self, ← zsmul_eq_mul, coe_zsmul, coe_period, smul_zero] refine ⟨(a % n).toNat, ?_, ?_, he⟩ · rw [← Int.ofNat_lt, han] exact Int.emod_lt_of_pos _ (Int.ofNat_lt.2 h) · have := (gcd_mul_addOrderOf_div_eq p (Int.toNat (a % ↑n)) h).trans ((congr_arg addOrderOf he).trans hk).symm rw [he, Nat.mul_left_eq_self_iff] at this · exact this · rwa [hk] 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⟩ 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.ext_iff] at h rw [← sub_eq_zero, ← coe_sub, ← sub_mul, ← sub_div, ← Int.cast_natCast m₁, ← Int.cast_natCast m₂, ← Int.cast_sub, coe_eq_zero_iff] at h obtain ⟨m, hm⟩ := h rw [← mul_div_right_comm, eq_div_iff, mul_comm, ← zsmul_eq_mul, mul_smul_comm, ← nsmul_eq_mul, ← natCast_zsmul, smul_smul, (zsmul_strictMono_left hp.out).injective.eq_iff, mul_comm] at hm swap · exact Nat.cast_ne_zero.2 hn.ne' rw [← @Nat.cast_inj ℤ, ← sub_eq_zero] refine Int.eq_zero_of_abs_lt_dvd ⟨_, hm.symm⟩ (abs_sub_lt_iff.2 ⟨?_, ?_⟩) <;> apply (Int.sub_le_self _ <| Nat.cast_nonneg _).trans_lt (Nat.cast_lt.2 _) 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 erw [infinite_coe_iff] exact infinite_not_isOfFinAddOrder hu exact Nat.card_eq_zero_of_infinite · have : IsEmpty { u : AddCircle p // ¬IsOfFinAddOrder u } := by simpa 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_add_order_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'] end FiniteOrderPoints end LinearOrderedField 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 instance instZeroLTOne [StrictOrderedSemiring 𝕜] : Fact ((0 : 𝕜) < 1) := ⟨zero_lt_one⟩ /-- The unit circle `ℝ ⧸ ℤ`. -/ abbrev UnitAddCircle := AddCircle (1 : ℝ) end UnitAddCircle 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 [LinearOrderedAddCommGroup 𝕜] (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 -- Porting note: was `simp_rw` rw [quotientMap_quotient_mk'.continuous_iff] simp_rw [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 [inducing_subtype_val.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`. -/ variable {p a} 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 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]) 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]) end AddCircle end IdentifyIccEnds 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 (hp := Real.fact_zero_lt_one) (a := 0), 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
Topology\Instances\CantorSet.lean
/- Copyright (c) 2024 Jana Göken. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Artur Szafarczyk, Suraj Krishna M S, Jean-Baptiste Stiegler, Isabelle Dubois, Tomáš Jakl, Lorenzo Zanichelli, Alina Yan, Emilie Uthaiwat, Jana Göken, Filippo A. E. Nuccio -/ import Mathlib.Topology.Metrizable.Basic import Mathlib.Topology.Algebra.GroupWithZero import Mathlib.Topology.Instances.Real /-! # 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. -/ /-- 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, inv_nonneg] refine ⟨⟨ ?_, ?_⟩, ?_, ?_⟩ <;> norm_num | succ n ih => apply And.intro · -- goal: 1 / 4 ∈ preCantorSet (n + 1) -- follows by the inductive hyphothesis, 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 hyphothesis, 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] /-- The ternary Cantor set is a subset of [0,1]. -/ lemma cantorSet_subset_unitInterval : cantorSet ⊆ Set.Icc 0 1 := Set.iInter_subset _ 0 /-- The preCantor sets are closed. -/ lemma isClosed_preCantorSet (n : ℕ) : IsClosed (preCantorSet n) := by let f := Homeomorph.mulLeft₀ (1 / 3 : ℝ) (by norm_num) 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.closedEmbedding.closed_iff_image_closed.mp ih · simpa [g, f, div_eq_inv_mul] using g.closedEmbedding.closed_iff_image_closed.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
Topology\Instances\Complex.lean
/- Copyright (c) 2022 Xavier Roblot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Xavier Roblot -/ import Mathlib.Analysis.Complex.Basic import Mathlib.Data.Complex.FiniteDimensional import Mathlib.FieldTheory.IntermediateField import Mathlib.LinearAlgebra.FiniteDimensional 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 = ofReal.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.denseEmbedding_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 : TopologicalDivisionRing ℂ := TopologicalDivisionRing.mk letI : TopologicalRing K.topologicalClosure := Subring.instTopologicalRing K.topologicalClosure.toSubring set ι : K → K.topologicalClosure := ⇑(Subfield.inclusion K.le_topologicalClosure) have ui : UniformInducing ι := ⟨by erw [uniformity_subtype, uniformity_subtype, Filter.comap_comap] congr ⟩ let di := ui.denseInducing (?_ : DenseRange ι) · -- extψ : closure(K) →+* ℂ is the extension of ψ : K →+* ℂ let extψ := DenseInducing.extendRingHom ui di.dense hc haveI hψ := (uniformContinuous_uniformly_extend ui di.dense hc).continuous cases' 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 ofReal.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 : ℝ, ofReal.rangeRestrict r = j (ι x) · have := RingHom.congr_fun (ringHom_eq_ofReal_of_continuous hψ₁) r -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [RingHom.comp_apply, RingHom.comp_apply, hr, RingEquiv.toRingHom_eq_coe] at this convert this using 1 · exact (DenseInducing.extend_eq di hc.continuous _).symm · rw [← ofReal.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 _) cases' ringHom_eq_id_or_conj_of_continuous hψ₁ with h h · left ext1 z convert RingHom.congr_fun h z using 1 exact (DenseInducing.extend_eq di hc.continuous z).symm · right ext1 z convert RingHom.congr_fun h z using 1 exact (DenseInducing.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 _) (DenseEmbedding.subtype denseEmbedding_id (K : Set ℂ)).dense (by continuity : Continuous j) rintro ⟨y, hy⟩ use ⟨y, by convert hy simp only [id, Set.image_id'] rfl ⟩ end ComplexSubfield
Topology\Instances\Discrete.lean
/- Copyright (c) 2022 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne -/ import Mathlib.Order.SuccPred.Basic import Mathlib.Topology.Order.Basic import Mathlib.Topology.Metrizable.Uniformity /-! # 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 (singletons_open_iff_discrete.mpr hd) (iUnion_of_singleton α) @[deprecated DiscreteTopology.secondCountableTopology_of_countable (since := "2024-03-11")] theorem DiscreteTopology.secondCountableTopology_of_encodable {α : Type*} [TopologicalSpace α] [DiscreteTopology α] [Countable α] : SecondCountableTopology α := DiscreteTopology.secondCountableTopology_of_countable theorem bot_topologicalSpace_eq_generateFrom_of_pred_succOrder {α} [PartialOrder α] [PredOrder α] [SuccOrder α] [NoMinOrder α] [NoMaxOrder α] : (⊥ : TopologicalSpace α) = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } := by refine (eq_bot_of_singletons_open fun a => ?_).symm have h_singleton_eq_inter : {a} = Iio (succ a) ∩ Ioi (pred a) := by suffices h_singleton_eq_inter' : {a} = Iic a ∩ Ici a by rw [h_singleton_eq_inter', ← Ioi_pred, ← Iio_succ] rw [inter_comm, Ici_inter_Iic, Icc_self a] rw [h_singleton_eq_inter] letI := Preorder.topology α apply IsOpen.inter · exact isOpen_generateFrom_of_mem ⟨succ a, Or.inr rfl⟩ · exact isOpen_generateFrom_of_mem ⟨pred a, Or.inl rfl⟩ theorem discreteTopology_iff_orderTopology_of_pred_succ' [PartialOrder α] [PredOrder α] [SuccOrder α] [NoMinOrder α] [NoMaxOrder α] : DiscreteTopology α ↔ OrderTopology α := by refine ⟨fun h => ⟨?_⟩, fun h => ⟨?_⟩⟩ · rw [h.eq_bot] exact bot_topologicalSpace_eq_generateFrom_of_pred_succOrder · rw [h.topology_eq_generate_intervals] exact bot_topologicalSpace_eq_generateFrom_of_pred_succOrder.symm instance (priority := 100) DiscreteTopology.orderTopology_of_pred_succ' [h : DiscreteTopology α] [PartialOrder α] [PredOrder α] [SuccOrder α] [NoMinOrder α] [NoMaxOrder α] : OrderTopology α := discreteTopology_iff_orderTopology_of_pred_succ'.1 h theorem LinearOrder.bot_topologicalSpace_eq_generateFrom {α} [LinearOrder α] [PredOrder α] [SuccOrder α] : (⊥ : TopologicalSpace α) = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } := by refine (eq_bot_of_singletons_open fun a => ?_).symm have h_singleton_eq_inter : {a} = Iic a ∩ Ici a := by rw [inter_comm, Ici_inter_Iic, Icc_self a] by_cases ha_top : IsTop a · rw [ha_top.Iic_eq, inter_comm, inter_univ] at h_singleton_eq_inter by_cases ha_bot : IsBot a · rw [ha_bot.Ici_eq] at h_singleton_eq_inter rw [h_singleton_eq_inter] -- Porting note: Specified instance for `isOpen_univ` explicitly to fix an error. apply @isOpen_univ _ (generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a }) · rw [isBot_iff_isMin] at ha_bot rw [← Ioi_pred_of_not_isMin ha_bot] at h_singleton_eq_inter rw [h_singleton_eq_inter] exact isOpen_generateFrom_of_mem ⟨pred a, Or.inl rfl⟩ · rw [isTop_iff_isMax] at ha_top rw [← Iio_succ_of_not_isMax ha_top] at h_singleton_eq_inter by_cases ha_bot : IsBot a · rw [ha_bot.Ici_eq, inter_univ] at h_singleton_eq_inter rw [h_singleton_eq_inter] exact isOpen_generateFrom_of_mem ⟨succ a, Or.inr rfl⟩ · rw [isBot_iff_isMin] at ha_bot rw [← Ioi_pred_of_not_isMin ha_bot] at h_singleton_eq_inter rw [h_singleton_eq_inter] -- Porting note: Specified instance for `IsOpen.inter` explicitly to fix an error. letI := Preorder.topology α apply IsOpen.inter · exact isOpen_generateFrom_of_mem ⟨succ a, Or.inr rfl⟩ · exact isOpen_generateFrom_of_mem ⟨pred a, Or.inl rfl⟩ theorem discreteTopology_iff_orderTopology_of_pred_succ [LinearOrder α] [PredOrder α] [SuccOrder α] : DiscreteTopology α ↔ OrderTopology α := by refine ⟨fun h => ⟨?_⟩, fun h => ⟨?_⟩⟩ · rw [h.eq_bot] exact LinearOrder.bot_topologicalSpace_eq_generateFrom · rw [h.topology_eq_generate_intervals] exact LinearOrder.bot_topologicalSpace_eq_generateFrom.symm instance (priority := 100) DiscreteTopology.orderTopology_of_pred_succ [h : DiscreteTopology α] [LinearOrder α] [PredOrder α] [SuccOrder α] : OrderTopology α := discreteTopology_iff_orderTopology_of_pred_succ.mp h instance (priority := 100) DiscreteTopology.metrizableSpace [DiscreteTopology α] : MetrizableSpace α := by obtain rfl := DiscreteTopology.eq_bot (α := α) exact @UniformSpace.metrizableSpace α ⊥ (isCountablyGenerated_principal _) _
Topology\Instances\ENNReal.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl -/ import Mathlib.Topology.Order.MonotoneContinuity import Mathlib.Topology.Algebra.Order.LiminfLimsup import Mathlib.Topology.Instances.NNReal import Mathlib.Topology.EMetricSpace.Lipschitz import Mathlib.Topology.Metrizable.Basic import Mathlib.Topology.Order.T5 /-! # Topology on extended non-negative reals -/ noncomputable section open Set Filter Metric Function open scoped Topology ENNReal NNReal variable {α : Type*} {β : Type*} {γ : Type*} namespace ENNReal variable {a b c d : ℝ≥0∞} {r p q : ℝ≥0} {x y z : ℝ≥0∞} {ε ε₁ ε₂ : ℝ≥0∞} {s : Set ℝ≥0∞} section TopologicalSpace open TopologicalSpace /-- Topology on `ℝ≥0∞`. Note: this is different from the `EMetricSpace` topology. The `EMetricSpace` topology has `IsOpen {∞}`, while this topology doesn't have singleton elements. -/ instance : TopologicalSpace ℝ≥0∞ := Preorder.topology ℝ≥0∞ instance : OrderTopology ℝ≥0∞ := ⟨rfl⟩ -- short-circuit type class inference instance : T2Space ℝ≥0∞ := inferInstance instance : T5Space ℝ≥0∞ := inferInstance instance : T4Space ℝ≥0∞ := inferInstance instance : SecondCountableTopology ℝ≥0∞ := orderIsoUnitIntervalBirational.toHomeomorph.embedding.secondCountableTopology instance : MetrizableSpace ENNReal := orderIsoUnitIntervalBirational.toHomeomorph.embedding.metrizableSpace theorem embedding_coe : Embedding ((↑) : ℝ≥0 → ℝ≥0∞) := coe_strictMono.embedding_of_ordConnected <| by rw [range_coe']; exact ordConnected_Iio 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 openEmbedding_coe : OpenEmbedding ((↑) : ℝ≥0 → ℝ≥0∞) := ⟨embedding_coe, by rw [range_coe']; exact isOpen_Iio⟩ theorem coe_range_mem_nhds : range ((↑) : ℝ≥0 → ℝ≥0∞) ∈ 𝓝 (r : ℝ≥0∞) := IsOpen.mem_nhds openEmbedding_coe.isOpen_range <| mem_range_self _ @[norm_cast] theorem tendsto_coe {f : Filter α} {m : α → ℝ≥0} {a : ℝ≥0} : Tendsto (fun a => (m a : ℝ≥0∞)) f (𝓝 ↑a) ↔ Tendsto m f (𝓝 a) := embedding_coe.tendsto_nhds_iff.symm @[fun_prop] theorem continuous_coe : Continuous ((↑) : ℝ≥0 → ℝ≥0∞) := embedding_coe.continuous theorem continuous_coe_iff {α} [TopologicalSpace α] {f : α → ℝ≥0} : (Continuous fun a => (f a : ℝ≥0∞)) ↔ Continuous f := embedding_coe.continuous_iff.symm theorem nhds_coe {r : ℝ≥0} : 𝓝 (r : ℝ≥0∞) = (𝓝 r).map (↑) := (openEmbedding_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 nhds_coe_coe {r p : ℝ≥0} : 𝓝 ((r : ℝ≥0∞), (p : ℝ≥0∞)) = (𝓝 (r, p)).map fun p : ℝ≥0 × ℝ≥0 => (↑p.1, ↑p.2) := ((openEmbedding_coe.prod openEmbedding_coe).map_nhds_eq (r, p)).symm 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 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 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 [mem_setOf_eq, 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 y => 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 -- Porting note (#11215): TODO: add a TC for `≠ ∞`? @[instance] theorem nhdsWithin_Ioi_coe_neBot {r : ℝ≥0} : (𝓝[>] (r : ℝ≥0∞)).NeBot := nhdsWithin_Ioi_self_neBot' ⟨∞, ENNReal.coe_lt_top⟩ @[instance] theorem nhdsWithin_Ioi_zero_neBot : (𝓝[>] (0 : ℝ≥0∞)).NeBot := nhdsWithin_Ioi_coe_neBot @[instance] theorem nhdsWithin_Ioi_one_neBot : (𝓝[>] (1 : ℝ≥0∞)).NeBot := nhdsWithin_Ioi_coe_neBot @[instance] theorem nhdsWithin_Ioi_nat_neBot (n : ℕ) : (𝓝[>] (n : ℝ≥0∞)).NeBot := nhdsWithin_Ioi_coe_neBot @[instance] theorem nhdsWithin_Ioi_ofNat_nebot (n : ℕ) [n.AtLeastTwo] : (𝓝[>] (OfNat.ofNat n : ℝ≥0∞)).NeBot := nhdsWithin_Ioi_coe_neBot @[instance] theorem nhdsWithin_Iio_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_gt 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ε) · exact (add_le_add_left (min_le_right _ _) _).trans_lt 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 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) instance : ContinuousAdd ℝ≥0∞ := by refine ⟨continuous_iff_continuousAt.2 ?_⟩ rintro ⟨_ | a, b⟩ · exact tendsto_nhds_top_mono' continuousAt_fst fun p => le_add_right le_rfl rcases b with (_ | b) · exact tendsto_nhds_top_mono' continuousAt_snd fun p => le_add_left le_rfl simp only [ContinuousAt, some_eq_coe, nhds_coe_coe, ← coe_add, tendsto_map'_iff, (· ∘ ·), tendsto_coe, tendsto_add] 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_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 => ?_ rw [lt_tsub_iff_left] calc y.2 + x ≤ ↑(b + 1) + x := add_le_add_right hy.2 _ _ < y.1 := 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, (· ∘ ·), 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.prod_mk_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 [(· ∘ ·), 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, (· ∘ ·), 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.prod_mk_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 a s has IH · simp [tendsto_const_nhds] simp only [Finset.prod_insert has] apply Tendsto.mul (h _ (Finset.mem_insert_self _ _)) · right exact (prod_lt_top fun i hi => h' _ (Finset.mem_insert_of_mem hi)).ne · 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 n IH · simp [continuous_const] 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_iff, not_false_iff] · exact Or.inl fun h => H (pow_eq_zero h) · simp only [H, pow_eq_top_iff, zero_ne_top, false_or_iff, eq_self_iff_true, not_true, Ne, not_false_iff, false_and_iff] · simp only [H, true_or_iff, 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_iff] 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 (Continuous.Prod.mk a) fun x => ?_ simp only [a_ne_top, Ne, mem_setOf_eq, Prod.mk.inj_iff, false_and_iff, 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.comp continuousOn_sub (Continuous.continuousOn (Continuous.Prod.mk a)) 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] · rw [show (fun x => x - a) = (fun p : ℝ≥0∞ × ℝ≥0∞ => p.fst - p.snd) ∘ fun x => ⟨x, a⟩ by rfl] apply ContinuousOn.comp_continuous continuousOn_sub (continuous_id'.prod_mk continuous_const) intro x simp only [a_infty, Ne, mem_setOf_eq, Prod.mk.inj_iff, and_false_iff, 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 iInf_mul_left' {ι} {f : ι → ℝ≥0∞} {a : ℝ≥0∞} (h : a = ∞ → ⨅ i, f i = 0 → ∃ i, f i = 0) (h0 : a = 0 → Nonempty ι) : ⨅ i, a * f i = a * ⨅ i, f i := by by_cases H : a = ∞ ∧ ⨅ i, f i = 0 · rcases h H.1 H.2 with ⟨i, hi⟩ rw [H.2, mul_zero, ← bot_eq_zero, iInf_eq_bot] exact fun b hb => ⟨i, by rwa [hi, mul_zero, ← bot_eq_zero]⟩ · rw [not_and_or] at H cases isEmpty_or_nonempty ι · rw [iInf_of_empty, iInf_of_empty, mul_top] exact mt h0 (not_nonempty_iff.2 ‹_›) · exact (ENNReal.mul_left_mono.map_iInf_of_continuousAt' (ENNReal.continuousAt_const_mul H)).symm theorem iInf_mul_left {ι} [Nonempty ι] {f : ι → ℝ≥0∞} {a : ℝ≥0∞} (h : a = ∞ → ⨅ i, f i = 0 → ∃ i, f i = 0) : ⨅ i, a * f i = a * ⨅ i, f i := iInf_mul_left' h fun _ => ‹Nonempty ι› theorem iInf_mul_right' {ι} {f : ι → ℝ≥0∞} {a : ℝ≥0∞} (h : a = ∞ → ⨅ i, f i = 0 → ∃ i, f i = 0) (h0 : a = 0 → Nonempty ι) : ⨅ i, f i * a = (⨅ i, f i) * a := by simpa only [mul_comm a] using iInf_mul_left' h h0 theorem iInf_mul_right {ι} [Nonempty ι] {f : ι → ℝ≥0∞} {a : ℝ≥0∞} (h : a = ∞ → ⨅ i, f i = 0 → ∃ i, f i = 0) : ⨅ i, f i * a = (⨅ i, f i) * a := iInf_mul_right' h fun _ => ‹Nonempty ι› theorem inv_map_iInf {ι : Sort*} {x : ι → ℝ≥0∞} : (iInf x)⁻¹ = ⨆ i, (x i)⁻¹ := OrderIso.invENNReal.map_iInf x theorem inv_map_iSup {ι : Sort*} {x : ι → ℝ≥0∞} : (iSup x)⁻¹ = ⨅ i, (x i)⁻¹ := OrderIso.invENNReal.map_iSup x 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 instance : ContinuousInv ℝ≥0∞ := ⟨OrderIso.invENNReal.continuous⟩ @[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] -- Porting note (#11215): 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 theorem iSup_add {ι : Sort*} {s : ι → ℝ≥0∞} [Nonempty ι] : iSup s + a = ⨆ b, s b + a := Monotone.map_iSup_of_continuousAt' (continuousAt_id.add continuousAt_const) <| monotone_id.add monotone_const theorem biSup_add' {ι : Sort*} {p : ι → Prop} (h : ∃ i, p i) {f : ι → ℝ≥0∞} : (⨆ (i) (_ : p i), f i) + a = ⨆ (i) (_ : p i), f i + a := by haveI : Nonempty { i // p i } := nonempty_subtype.2 h simp only [iSup_subtype', iSup_add] theorem add_biSup' {ι : Sort*} {p : ι → Prop} (h : ∃ i, p i) {f : ι → ℝ≥0∞} : (a + ⨆ (i) (_ : p i), f i) = ⨆ (i) (_ : p i), a + f i := by simp only [add_comm a, biSup_add' h] theorem biSup_add {ι} {s : Set ι} (hs : s.Nonempty) {f : ι → ℝ≥0∞} : (⨆ i ∈ s, f i) + a = ⨆ i ∈ s, f i + a := biSup_add' hs theorem add_biSup {ι} {s : Set ι} (hs : s.Nonempty) {f : ι → ℝ≥0∞} : (a + ⨆ i ∈ s, f i) = ⨆ i ∈ s, a + f i := add_biSup' hs theorem sSup_add {s : Set ℝ≥0∞} (hs : s.Nonempty) : sSup s + a = ⨆ b ∈ s, b + a := by rw [sSup_eq_iSup, biSup_add hs] theorem add_iSup {ι : Sort*} {s : ι → ℝ≥0∞} [Nonempty ι] : a + iSup s = ⨆ b, a + s b := by rw [add_comm, iSup_add]; simp [add_comm] theorem iSup_add_iSup_le {ι ι' : Sort*} [Nonempty ι] [Nonempty ι'] {f : ι → ℝ≥0∞} {g : ι' → ℝ≥0∞} {a : ℝ≥0∞} (h : ∀ i j, f i + g j ≤ a) : iSup f + iSup g ≤ a := by simp_rw [iSup_add, add_iSup]; exact iSup₂_le h theorem biSup_add_biSup_le' {ι ι'} {p : ι → Prop} {q : ι' → Prop} (hp : ∃ i, p i) (hq : ∃ j, q j) {f : ι → ℝ≥0∞} {g : ι' → ℝ≥0∞} {a : ℝ≥0∞} (h : ∀ i, p i → ∀ j, q j → f i + g j ≤ a) : ((⨆ (i) (_ : p i), f i) + ⨆ (j) (_ : q j), g j) ≤ a := by simp_rw [biSup_add' hp, add_biSup' hq] exact iSup₂_le fun i hi => iSup₂_le (h i hi) theorem biSup_add_biSup_le {ι ι'} {s : Set ι} {t : Set ι'} (hs : s.Nonempty) (ht : t.Nonempty) {f : ι → ℝ≥0∞} {g : ι' → ℝ≥0∞} {a : ℝ≥0∞} (h : ∀ i ∈ s, ∀ j ∈ t, f i + g j ≤ a) : ((⨆ i ∈ s, f i) + ⨆ j ∈ t, g j) ≤ a := biSup_add_biSup_le' hs ht h theorem iSup_add_iSup {ι : Sort*} {f g : ι → ℝ≥0∞} (h : ∀ i j, ∃ k, f i + g j ≤ f k + g k) : iSup f + iSup g = ⨆ a, f a + g a := by cases isEmpty_or_nonempty ι · simp only [iSup_of_empty, bot_eq_zero, zero_add] · refine le_antisymm ?_ (iSup_le fun a => add_le_add (le_iSup _ _) (le_iSup _ _)) refine iSup_add_iSup_le fun i j => ?_ rcases h i j with ⟨k, hk⟩ exact le_iSup_of_le k hk theorem iSup_add_iSup_of_monotone {ι : Type*} [Preorder ι] [IsDirected ι (· ≤ ·)] {f g : ι → ℝ≥0∞} (hf : Monotone f) (hg : Monotone g) : iSup f + iSup g = ⨆ a, f a + g a := iSup_add_iSup fun i j ↦ (exists_ge_ge i j).imp fun _k ⟨hi, hj⟩ ↦ by gcongr <;> apply_rules theorem finsetSum_iSup {α ι : Type*} {s : Finset α} {f : α → ι → ℝ≥0∞} (hf : ∀ i j, ∃ k, ∀ a, f a i ≤ f a k ∧ f a j ≤ f a k) : ∑ a ∈ s, ⨆ i, f a i = ⨆ i, ∑ a ∈ s, f a i := by induction s using Finset.cons_induction with | empty => simp | cons a s ha ihs => simp_rw [Finset.sum_cons, ihs] refine iSup_add_iSup fun i j ↦ (hf i j).imp fun k hk ↦ ?_ gcongr exacts [(hk a).1, (hk _).2] theorem finsetSum_iSup_of_monotone {α} {ι} [Preorder ι] [IsDirected ι (· ≤ ·)] {s : Finset α} {f : α → ι → ℝ≥0∞} (hf : ∀ a, Monotone (f a)) : (∑ a ∈ s, iSup (f a)) = ⨆ n, ∑ a ∈ s, f a n := finsetSum_iSup fun i j ↦ (exists_ge_ge i j).imp fun _k ⟨hi, hj⟩ a ↦ ⟨hf a hi, hf a hj⟩ @[deprecated (since := "2024-07-14")] alias finset_sum_iSup_nat := finsetSum_iSup_of_monotone theorem mul_iSup {ι : Sort*} {f : ι → ℝ≥0∞} {a : ℝ≥0∞} : a * iSup f = ⨆ i, a * f i := by by_cases hf : ∀ i, f i = 0 · obtain rfl : f = fun _ => 0 := funext hf simp only [iSup_zero_eq_zero, mul_zero] · refine (monotone_id.const_mul' _).map_iSup_of_continuousAt ?_ (mul_zero a) refine ENNReal.Tendsto.const_mul tendsto_id (Or.inl ?_) exact mt iSup_eq_zero.1 hf theorem mul_sSup {s : Set ℝ≥0∞} {a : ℝ≥0∞} : a * sSup s = ⨆ i ∈ s, a * i := by simp only [sSup_eq_iSup, mul_iSup] theorem iSup_mul {ι : Sort*} {f : ι → ℝ≥0∞} {a : ℝ≥0∞} : iSup f * a = ⨆ i, f i * a := by rw [mul_comm, mul_iSup]; congr; funext; rw [mul_comm] theorem smul_iSup {ι : Sort*} {R} [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] (f : ι → ℝ≥0∞) (c : R) : (c • ⨆ i, f i) = ⨆ i, c • f i := by -- Porting note: replaced `iSup _` with `iSup f` simp only [← smul_one_mul c (f _), ← smul_one_mul c (iSup f), ENNReal.mul_iSup] theorem smul_sSup {R} [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] (s : Set ℝ≥0∞) (c : R) : c • sSup s = ⨆ i ∈ s, c • i := by -- Porting note: replaced `_` with `s` simp_rw [← smul_one_mul c (sSup s), ENNReal.mul_sSup, smul_one_mul] theorem iSup_div {ι : Sort*} {f : ι → ℝ≥0∞} {a : ℝ≥0∞} : iSup f / a = ⨆ i, f i / a := iSup_mul protected theorem tendsto_coe_sub {b : ℝ≥0∞} : Tendsto (fun b : ℝ≥0∞ => ↑r - b) (𝓝 b) (𝓝 (↑r - b)) := continuous_nnreal_sub.tendsto _ theorem sub_iSup {ι : Sort*} [Nonempty ι] {b : ι → ℝ≥0∞} (hr : a < ∞) : (a - ⨆ i, b i) = ⨅ i, a - b i := antitone_const_tsub.map_iSup_of_continuousAt' (continuous_sub_left hr.ne).continuousAt 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⟩ theorem exists_lt_add_of_lt_add {x y z : ℝ≥0∞} (h : x < y + z) (hy : y ≠ 0) (hz : z ≠ 0) : ∃ y' z', y' < y ∧ z' < z ∧ x < y' + z' := by have : NeZero y := ⟨hy⟩ have : NeZero z := ⟨hz⟩ have A : Tendsto (fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 + p.2) (𝓝[<] y ×ˢ 𝓝[<] z) (𝓝 (y + z)) := by apply Tendsto.mono_left _ (Filter.prod_mono nhdsWithin_le_nhds nhdsWithin_le_nhds) rw [← nhds_prod_eq] exact tendsto_add rcases ((A.eventually (lt_mem_nhds h)).and (Filter.prod_mem_prod self_mem_nhdsWithin self_mem_nhdsWithin)).exists with ⟨⟨y', z'⟩, hx, hy', hz'⟩ exact ⟨y', z', hy', hz', hx⟩ theorem ofReal_cinfi (f : α → ℝ) [Nonempty α] : ENNReal.ofReal (⨅ i, f i) = ⨅ i, ENNReal.ofReal (f i) := by by_cases hf : BddBelow (range f) · exact Monotone.map_ciInf_of_continuousAt ENNReal.continuous_ofReal.continuousAt (fun i j hij => ENNReal.ofReal_le_ofReal hij) hf · symm rw [Real.iInf_of_not_bddBelow hf, ENNReal.ofReal_zero, ← ENNReal.bot_eq_zero, iInf_eq_bot] obtain ⟨y, hy_mem, hy_neg⟩ := not_bddBelow_iff.mp hf 0 obtain ⟨i, rfl⟩ := mem_range.mpr hy_mem refine fun x hx => ⟨i, ?_⟩ rwa [ENNReal.ofReal_of_nonpos hy_neg.le] 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, eventually_atTop, not_exists, not_forall, not_le, exists_prop] 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, eventually_atTop, not_exists, not_forall, not_le, exists_prop] 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⟩ 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 := tsum_sigma' (fun _ => ENNReal.summable) ENNReal.summable protected theorem tsum_sigma' {β : α → Type*} (f : (Σa, β a) → ℝ≥0∞) : ∑' p : Σa, β a, f p = ∑' (a) (b), f ⟨a, b⟩ := tsum_sigma' (fun _ => ENNReal.summable) ENNReal.summable protected theorem tsum_prod {f : α → β → ℝ≥0∞} : ∑' p : α × β, f p.1 p.2 = ∑' (a) (b), f a b := tsum_prod' ENNReal.summable fun _ => ENNReal.summable protected theorem tsum_prod' {f : α × β → ℝ≥0∞} : ∑' p : α × β, f p = ∑' (a) (b), f (a, b) := tsum_prod' ENNReal.summable fun _ => ENNReal.summable protected theorem tsum_comm {f : α → β → ℝ≥0∞} : ∑' a, ∑' b, f a b = ∑' b, ∑' a, f a b := tsum_comm' ENNReal.summable (fun _ => ENNReal.summable) fun _ => ENNReal.summable protected theorem tsum_add : ∑' a, (f a + g a) = ∑' a, f a + ∑' a, g a := tsum_add ENNReal.summable ENNReal.summable protected theorem tsum_le_tsum (h : ∀ a, f a ≤ g a) : ∑' a, f a ≤ ∑' a, g a := tsum_le_tsum h ENNReal.summable ENNReal.summable @[gcongr] protected theorem _root_.GCongr.ennreal_tsum_le_tsum (h : ∀ a, f a ≤ g a) : tsum f ≤ tsum g := ENNReal.tsum_le_tsum h protected theorem sum_le_tsum {f : α → ℝ≥0∞} (s : Finset α) : ∑ x ∈ s, f x ≤ ∑' x, f x := sum_le_tsum s (fun _ _ => zero_le _) ENNReal.summable 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 := le_tsum' ENNReal.summable a @[simp] protected theorem tsum_eq_zero : ∑' i, f i = 0 ↔ ∀ i, f i = 0 := tsum_eq_zero_iff ENNReal.summable 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_iff, 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.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 := tsum_le_tsum_of_inj f hf (fun _ _ => zero_le _) (fun _ => le_rfl) ENNReal.summable 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.toSet 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] 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) := tsum_eq_add_tsum_ite' b ENNReal.summable 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 := tsum_le_tsum_of_inj (↑) Subtype.val_injective (fun _ _ => zero_le _) (fun i => i.2) ENNReal.summable 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.card ≤ 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.card * ε = ∑ _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.top_toNNReal, 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 := _root_.tsum_le_of_sum_range_le (summable_of_sum_range_le h) 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 := tsum_le_tsum_of_inj i hi (fun _ _ => zero_le _) (fun _ => le_rfl) (summable_comp_injective hf hi) 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 ((tsum_eq_zero_iff (indicator_summable hf s)).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 rw [← tsum_zero] exact 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 tsum_eq_add_tsum_ite' i (NNReal.summable_of_le (fun i' => ?_) hf) 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 := _root_.tsum_le_of_sum_range_le ENNReal.summable 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 [(· ∘ ·), ← 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] /-- 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 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_iff] /-- 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 ?_⟩ <;> refine add_le_add_left (le_trans (mul_le_mul_left' ?_ _) hδ.le) _ 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')) := (add_le_add_left (add_le_add (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.prod_mk 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.prod_mk_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_ball {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_lt 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_lt 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 sum_le_tsum _ (fun _ _ => zero_le _) ENNReal.summable /-- 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 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] apply (toReal_le_toReal _ t_ne_top).mpr (min_le_left t x) simp_all only [ne_eq, min_eq_top, false_and, not_false_eq_true] 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 have obs_x : min t x ≠ ∞ := by simp_all only [ne_eq, min_eq_top, false_and, not_false_eq_true] have obs_y : min t y ≠ ∞ := by simp_all only [ne_eq, min_eq_top, false_and, not_false_eq_true] exact (ENNReal.toReal_le_toReal obs_x obs_y).mpr (min_le_min_left t x_le_y) /-- The truncated cast `ENNReal.truncateToReal t : ℝ≥0∞ → ℝ` is continuous when `t ≠ ∞`. -/ lemma continuous_truncateToReal {t : ℝ≥0∞} (t_ne_top : t ≠ ∞) : Continuous (truncateToReal t) := by apply continuousOn_toReal.comp_continuous (continuous_min.comp (Continuous.Prod.mk t)) simp [t_ne_top] end truncateToReal section LimsupLiminf variable {ι : Type*} lemma limsup_sub_const (F : Filter ι) [NeBot F] (f : ι → ℝ≥0∞) (c : ℝ≥0∞) : Filter.limsup (fun i ↦ f i - c) F = Filter.limsup f F - c := (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 ι) [NeBot F] (f : ι → ℝ≥0∞) {c : ℝ≥0∞} (c_ne_top : c ≠ ∞) : Filter.limsup (fun i ↦ c - f i) F = c - Filter.liminf f F := (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 /-- If `xs : ι → ℝ≥0∞` is bounded, then we have `liminf (toReal ∘ xs) = toReal (liminf xs)`. -/ lemma liminf_toReal_eq {ι : Type*} {F : Filter ι} [NeBot F] {b : ℝ≥0∞} (b_ne_top : b ≠ ∞) {xs : ι → ℝ≥0∞} (le_b : ∀ᶠ i in F, xs i ≤ b) : F.liminf (fun i ↦ (xs i).toReal) = (F.liminf xs).toReal := by have liminf_le : F.liminf xs ≤ 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, (xs i).toReal = ENNReal.truncateToReal b (xs i) := by filter_upwards [le_b] with i i_le_b simp only [truncateToReal_eq_toReal b_ne_top i_le_b, implies_true] have aux' : (F.liminf xs).toReal = ENNReal.truncateToReal b (F.liminf xs) := 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) xs (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 `xs : ι → ℝ≥0∞` is bounded, then we have `liminf (toReal ∘ xs) = toReal (liminf xs)`. -/ lemma limsup_toReal_eq {ι : Type*} {F : Filter ι} [NeBot F] {b : ℝ≥0∞} (b_ne_top : b ≠ ∞) {xs : ι → ℝ≥0∞} (le_b : ∀ᶠ i in F, xs i ≤ b) : F.limsup (fun i ↦ (xs i).toReal) = (F.limsup xs).toReal := by have aux : ∀ᶠ i in F, (xs i).toReal = ENNReal.truncateToReal b (xs i) := by filter_upwards [le_b] with i i_le_b simp only [truncateToReal_eq_toReal b_ne_top i_le_b, implies_true] have aux' : (F.limsup xs).toReal = ENNReal.truncateToReal b (F.limsup xs) := 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) xs (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 end LimsupLiminf end ENNReal -- namespace
Topology\Instances\EReal.lean
/- Copyright (c) 2021 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Data.Rat.Encodable import Mathlib.Data.Real.EReal import Mathlib.Topology.Instances.ENNReal import Mathlib.Topology.Order.MonotoneContinuity /-! # Topological structure on `EReal` We endow `EReal` with the order topology, and prove basic properties of this topology. ## 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 scoped Classical open Set Filter Metric TopologicalSpace Topology open scoped ENNReal NNReal Filter variable {α : Type*} [TopologicalSpace α] namespace EReal instance : TopologicalSpace EReal := Preorder.topology EReal instance : OrderTopology EReal := ⟨rfl⟩ instance : T5Space EReal := inferInstance instance : T2Space EReal := inferInstance lemma denseRange_ratCast : DenseRange (fun r : ℚ ↦ ((r : ℝ) : EReal)) := dense_of_exists_between fun _ _ h => exists_range_iff.2 <| exists_rat_btwn_of_lt h instance : SecondCountableTopology EReal := have : SeparableSpace EReal := ⟨⟨_, countable_range _, denseRange_ratCast⟩⟩ .of_separableSpace_orderTopology _ /-! ### Real coercion -/ theorem embedding_coe : Embedding ((↑) : ℝ → EReal) := coe_strictMono.embedding_of_ordConnected <| by rw [range_coe_eq_Ioo]; exact ordConnected_Ioo theorem openEmbedding_coe : OpenEmbedding ((↑) : ℝ → EReal) := ⟨embedding_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) := embedding_coe.tendsto_nhds_iff.symm theorem _root_.continuous_coe_real_ereal : Continuous ((↑) : ℝ → EReal) := embedding_coe.continuous theorem continuous_coe_iff {f : α → ℝ} : (Continuous fun a => (f a : EReal)) ↔ Continuous f := embedding_coe.continuous_iff.symm theorem nhds_coe {r : ℝ} : 𝓝 (r : EReal) = (𝓝 r).map (↑) := (openEmbedding_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) := ((openEmbedding_coe.prod openEmbedding_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 embedding_coe_ennreal : Embedding ((↑) : ℝ≥0∞ → EReal) := coe_ennreal_strictMono.embedding_of_ordConnected <| by rw [range_coe_ennreal]; exact ordConnected_Ici theorem closedEmbedding_coe_ennreal : ClosedEmbedding ((↑) : ℝ≥0∞ → EReal) := ⟨embedding_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) := embedding_coe_ennreal.tendsto_nhds_iff.symm theorem _root_.continuous_coe_ennreal_ereal : Continuous ((↑) : ℝ≥0∞ → EReal) := embedding_coe_ennreal.continuous theorem continuous_coe_ennreal_iff {f : α → ℝ≥0∞} : (Continuous fun a => (f a : EReal)) ↔ Continuous f := embedding_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.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.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] /-! ### Liminfs and Limsups -/ section LimInfSup variable {α : Type*} {f : Filter α} {u v : α → EReal} {a b : EReal} lemma liminf_le_liminf (h : u ≤ᶠ[f] v) : liminf u f ≤ liminf v f := Filter.liminf_le_liminf h lemma limsup_le_limsup (h : u ≤ᶠ[f] v) : limsup u f ≤ limsup v f := Filter.limsup_le_limsup h /-- This lemma is superseded by `limsup_add_le_of_le` (weaker hypothesis) and `limsup_add_lt_of_lt` (stronger thesis). -/ private lemma limsup_add_le_of_lt (ha : limsup u f < a) (hb : limsup v f < b) : limsup (u + v) f ≤ a + b := by rcases eq_or_neBot f with (rfl | _) · simp only [limsup_bot, bot_le] rw [← @limsup_const EReal α _ f _ (a + b)] apply limsup_le_limsup (Eventually.mp (Eventually.and (eventually_lt_of_limsup_lt ha) (eventually_lt_of_limsup_lt hb)) (eventually_of_forall _)) simp only [Pi.add_apply, and_imp] intro x exact fun ux_lt_a vx_lt_b ↦ add_le_add (le_of_lt ux_lt_a) (le_of_lt vx_lt_b) lemma limsup_add_lt_of_lt (ha : limsup u f < a) (hb : limsup v f < b) : limsup (u + v) f < a + b := by obtain ⟨c, hc, hca⟩ := DenselyOrdered.dense _ _ ha obtain ⟨d, hd, hdb⟩ := DenselyOrdered.dense _ _ hb exact (limsup_add_le_of_lt hc hd).trans_lt (add_lt_add hca hdb) 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 apply (le_iff_le_forall_real_gt ⊥ (limsup (u + v) f)).1 intro x rcases exists_between_coe_real (h'.lt_top) with ⟨y, ⟨hy, _⟩⟩ rw [← sub_add_cancel x y, coe_add (x - y) y, coe_sub x y] intro _ apply @limsup_add_le_of_lt α f u v (x - y) y _ hy rw [h, ← coe_sub x y] exact bot_lt_coe (x - y) lemma limsup_add_le_add_limsup (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 rcases eq_bot_or_bot_lt (limsup u f) with (u_bot | u_nbot) · have v_ntop := h.neg_resolve_left u_bot rw [limsup_add_bot_of_ne_top u_bot v_ntop]; exact bot_le rcases eq_bot_or_bot_lt (limsup v f) with (v_bot | v_nbot) · have u_ntop := h'.neg_resolve_right v_bot rw [add_comm, limsup_add_bot_of_ne_top v_bot u_ntop]; exact bot_le rcases eq_top_or_lt_top (limsup v f) with (v_top | v_ntop) · rw [v_top, add_top_of_ne_bot (ne_of_gt u_nbot)]; exact le_top have limsup_v_real := coe_toReal (ne_of_lt v_ntop) (ne_of_gt v_nbot) apply (le_iff_le_forall_real_gt _ _).1 intros x hx rcases lt_iff_exists_real_btwn.1 hx with ⟨y, ⟨sum_lt_y, y_lt_x⟩⟩ have key₁ : limsup u f < (y - limsup v f) := by apply lt_of_eq_of_lt _ (sub_lt_sub_of_lt_of_le sum_lt_y (le_of_eq (Eq.refl (limsup v f))) (ne_of_gt v_nbot) (ne_of_lt v_ntop)) rw [← limsup_v_real, add_sub_cancel_right] have key₂ : limsup v f < limsup v f + x - y := by rw [← limsup_v_real]; norm_cast; norm_cast at y_lt_x; linarith apply le_of_le_of_eq (limsup_add_le_of_lt key₁ key₂) rw [← limsup_v_real]; norm_cast; linarith lemma limsup_add_le_of_le (ha : limsup u f < a) (hb : limsup v f ≤ b) : limsup (u + v) f ≤ a + b := by rcases lt_or_eq_of_le hb with (hb | hb) · exact limsup_add_le_of_lt ha hb by_cases hb' : b = ⊤ · convert le_top on_goal 1 => rw [hb'] -- This closes both remaining goals at once. exact add_top_of_ne_bot ha.ne_bot exact (limsup_add_le_add_limsup (hb ▸ Or.inr hb') (Or.inl ha.ne_top)).trans (add_le_add ha.le hb.le) 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 liminf_add_gt_of_gt (ha : a < liminf u f) (hb : b < liminf v f) : a + b < liminf (u + v) f := by have ha' : a ≠ ⊤ := ha.ne_top have hb' : b ≠ ⊤ := hb.ne_top have h : limsup (-(u + v)) f = limsup (-u + -v) f := by apply limsup_congr filter_upwards [eventually_lt_of_lt_liminf ha, eventually_lt_of_lt_liminf hb] with x hax hbx dsimp rw [neg_add (Or.inl hax.ne_bot) (Or.inr hbx.ne_bot), sub_eq_add_neg] rw [← neg_lt_neg_iff, ← limsup_neg] at ha hb ⊢ rw [neg_add (Or.inr hb') (Or.inl ha'), h] exact limsup_add_lt_of_lt ha hb 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 ((ge_iff_le_forall_real_lt (liminf (u + v) f) ⊤).1 _) intro x rcases exists_between_coe_real (Ne.bot_lt h') with ⟨y, ⟨_, hy⟩⟩ intro _ rw [← sub_add_cancel x y, coe_add (x - y) y] exact coe_sub x y ▸ @liminf_add_gt_of_gt α f u v (x - y) y (h ▸ coe_sub x y ▸ coe_lt_top (x-y)) hy |>.le lemma add_liminf_le_liminf_add : (liminf u f) + (liminf v f) ≤ liminf (u + v) f := by by_cases hu : liminf u f = ⊥ · simp_all by_cases hv : liminf v f = ⊥ · simp_all have h' : limsup (-(u + v)) f = limsup (-u + -v) f := by apply limsup_congr filter_upwards [eventually_lt_of_lt_liminf (bot_lt_iff_ne_bot.mpr hu), eventually_lt_of_lt_liminf (bot_lt_iff_ne_bot.mpr hv)] with x hux hvx dsimp rw [neg_add (Or.inl hux.ne_bot) (Or.inr hvx.ne_bot), sub_eq_add_neg] rw [← neg_le_neg_iff, neg_add (Or.inl hu) (Or.inr hv), sub_eq_add_neg] rw [← neg_inj, neg_bot] at hu hv simp_rw [← limsup_neg] at hu hv ⊢ exact h' ▸ limsup_add_le_add_limsup (Or.inr hv) (Or.inl hu) lemma limsup_le_iff {b : EReal} : limsup u f ≤ b ↔ ∀ c : ℝ, b < c → ∀ᶠ a : α in f, u a ≤ c := by rw [← le_iff_le_forall_real_gt] refine ⟨?_, ?_⟩ <;> intro h c b_lt_c · rcases exists_between_coe_real b_lt_c with ⟨d, b_lt_d, d_lt_c⟩ specialize h d b_lt_d have key := Filter.eventually_lt_of_limsup_lt (lt_of_le_of_lt h d_lt_c) apply Filter.mem_of_superset key rw [Set.setOf_subset_setOf] exact fun a h' ↦ le_of_lt h' · rcases eq_or_neBot f with (rfl | _) · simp only [limsup_bot, bot_le] · specialize h c b_lt_c exact @Filter.limsup_const EReal α _ f _ (c : EReal) ▸ limsup_le_limsup h 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, (· ∘ ·), 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, 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, (· ∘ ·), 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, 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, (· ∘ ·), 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 /-! ### Negation -/ instance : ContinuousNeg EReal := ⟨negOrderIso.continuous⟩ /-! ### 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.prod_map (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, (· ∘ ·), 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 · intros 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 · intros 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 [gt_iff_lt, 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, div_mul_div_comm, mul_comm, ← 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 end EReal
Topology\Instances\Int.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro -/ import Mathlib.Data.Int.Interval import Mathlib.Data.Int.SuccPred import Mathlib.Data.Int.ConditionallyCompleteOrder import Mathlib.Topology.Instances.Discrete import Mathlib.Topology.MetricSpace.Bounded import Mathlib.Topology.MetricSpace.Pseudo.Lemmas import Mathlib.Order.Filter.Archimedean /-! # Topology on the integers The structure of a metric space on `ℤ` is introduced in this file, induced from `ℝ`. -/ noncomputable section open Metric Set Filter 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 uniformEmbedding_coe_real : UniformEmbedding ((↑) : ℤ → ℝ) := uniformEmbedding_bot_of_pairwise_le_dist zero_lt_one pairwise_one_le_dist theorem closedEmbedding_coe_real : ClosedEmbedding ((↑) : ℤ → ℝ) := closedEmbedding_of_pairwise_le_dist zero_lt_one pairwise_one_le_dist instance : MetricSpace ℤ := Int.uniformEmbedding_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⟩ @[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 @[deprecated (since := "2024-02-07")] alias cocompact_eq := cocompact_eq_atBot_atTop @[simp] theorem cofinite_eq : (cofinite : Filter ℤ) = atBot ⊔ atTop := by rw [← cocompact_eq_cofinite, cocompact_eq_atBot_atTop] end Int
Topology\Instances\Irrational.lean
/- Copyright (c) 2021 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov -/ import Mathlib.Data.Real.Irrational import Mathlib.Data.Rat.Encodable import Mathlib.Topology.GDelta /-! # 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 @[deprecated (since := "2024-02-15")] alias isGδ_irrational := IsGδ.setOf_irrational 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_nat 1⟩, by simp⟩⟩ instance : NoMinOrder { x // Irrational x } := ⟨fun ⟨x, hx⟩ => ⟨⟨x - (1 : ℕ), hx.sub_nat 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.closedEmbedding_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
Topology\Instances\Matrix.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash, Eric Wieser -/ import Mathlib.Topology.Algebra.InfiniteSum.Basic import Mathlib.Topology.Algebra.Ring.Basic import Mathlib.Topology.Algebra.Star import Mathlib.LinearAlgebra.Matrix.NonsingularInverse 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 * 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 /-! ### 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] [TopologicalAddGroup R] : TopologicalAddGroup (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] 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] 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 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] theorem Continuous.matrix_col {ι : Type*} {A : X → n → R} (hA : Continuous A) : Continuous fun x => col ι (A x) := continuous_matrix fun i _ => (continuous_apply i).comp hA @[continuity] theorem Continuous.matrix_row {ι : Type*} {A : X → n → R} (hA : Continuous A) : Continuous fun x => row ι (A x) := continuous_matrix fun _ _ => (continuous_apply _).comp hA @[continuity] 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] theorem Continuous.matrix_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 => dotProduct (A x) (B x) := continuous_finset_sum _ fun i _ => ((continuous_apply i).comp hA).mul ((continuous_apply i).comp hB) /-- For square matrices the usual `continuous_mul` can be used. -/ @[continuity] 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] [TopologicalSemiring R] : TopologicalSemiring (Matrix n n R) where instance Matrix.topologicalRing [Fintype n] [NonUnitalNonAssocRing R] [TopologicalRing R] : TopologicalRing (Matrix n n R) where @[continuity] 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] 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).matrix_dotProduct hB @[continuity] 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.matrix_dotProduct <| continuous_pi fun _j => hB.matrix_elem _ _ @[continuity] 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] 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] 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] 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] theorem Continuous.matrix_det [Fintype n] [DecidableEq n] [CommRing R] [TopologicalRing 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] theorem Continuous.matrix_updateColumn [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).updateColumn i (B x) := continuous_matrix fun _j k => (continuous_apply k).comp <| ((continuous_apply _).comp hA).update i ((continuous_apply _).comp hB) @[continuity] 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] theorem Continuous.matrix_cramer [Fintype n] [DecidableEq n] [CommRing R] [TopologicalRing 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_updateColumn _ hB).matrix_det @[continuity] theorem Continuous.matrix_adjugate [Fintype n] [DecidableEq n] [CommRing R] [TopologicalRing 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_updateColumn 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] [TopologicalRing 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 -- lemmas about functions in `Data/Matrix/Block.lean` section BlockMatrices @[continuity] 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] 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] 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] 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] 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 [Semiring α] [AddCommMonoid R] [TopologicalSpace R] [Module α R] theorem HasSum.matrix_transpose {f : X → Matrix m n R} {a : Matrix m n R} (hf : HasSum f a) : HasSum (fun x => (f x)ᵀ) aᵀ := (hf.map (Matrix.transposeAddEquiv m n R) continuous_id.matrix_transpose : _) theorem Summable.matrix_transpose {f : X → Matrix m n R} (hf : Summable f) : Summable fun x => (f x)ᵀ := hf.hasSum.matrix_transpose.summable @[simp] theorem summable_matrix_transpose {f : X → Matrix m n R} : (Summable fun x => (f x)ᵀ) ↔ Summable f := 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} : (∑' x, f x)ᵀ = ∑' x, (f x)ᵀ := by by_cases hf : Summable f · exact hf.hasSum.matrix_transpose.tsum_eq.symm · have hft := summable_matrix_transpose.not.mpr hf rw [tsum_eq_zero_of_not_summable hf, tsum_eq_zero_of_not_summable hft, transpose_zero] theorem HasSum.matrix_conjTranspose [StarAddMonoid R] [ContinuousStar R] {f : X → Matrix m n R} {a : Matrix m n R} (hf : HasSum f a) : HasSum (fun x => (f x)ᴴ) aᴴ := (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) : Summable fun x => (f x)ᴴ := 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)ᴴ) ↔ Summable f := 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} : (∑' x, f x)ᴴ = ∑' x, (f x)ᴴ := by by_cases hf : Summable f · exact hf.hasSum.matrix_conjTranspose.tsum_eq.symm · have hft := summable_matrix_conjTranspose.not.mpr hf rw [tsum_eq_zero_of_not_summable hf, tsum_eq_zero_of_not_summable hft, conjTranspose_zero] theorem HasSum.matrix_diagonal [DecidableEq n] {f : X → n → R} {a : n → R} (hf : HasSum f a) : HasSum (fun x => diagonal (f x)) (diagonal a) := hf.map (diagonalAddMonoidHom n R) continuous_id.matrix_diagonal theorem Summable.matrix_diagonal [DecidableEq n] {f : X → n → R} (hf : Summable f) : Summable fun x => diagonal (f x) := hf.hasSum.matrix_diagonal.summable @[simp] theorem summable_matrix_diagonal [DecidableEq n] {f : X → n → R} : (Summable fun x => diagonal (f x)) ↔ Summable f := 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 (∑' x, f x) = ∑' x, diagonal (f x) := by by_cases hf : Summable f · exact hf.hasSum.matrix_diagonal.tsum_eq.symm · have hft := summable_matrix_diagonal.not.mpr hf rw [tsum_eq_zero_of_not_summable hf, tsum_eq_zero_of_not_summable hft] exact diagonal_zero theorem HasSum.matrix_diag {f : X → Matrix n n R} {a : Matrix n n R} (hf : HasSum f a) : HasSum (fun x => diag (f x)) (diag a) := hf.map (diagAddMonoidHom n R) continuous_matrix_diag theorem Summable.matrix_diag {f : X → Matrix n n R} (hf : Summable f) : Summable fun x => diag (f x) := 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) : HasSum (fun x => blockDiagonal (f x)) (blockDiagonal a) := 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) : Summable fun x => blockDiagonal (f x) := hf.hasSum.matrix_blockDiagonal.summable theorem summable_matrix_blockDiagonal [DecidableEq p] {f : X → p → Matrix m n R} : (Summable fun x => blockDiagonal (f x)) ↔ Summable f := 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 (∑' x, f x) = ∑' x, blockDiagonal (f x) := by by_cases hf : Summable f · exact hf.hasSum.matrix_blockDiagonal.tsum_eq.symm · have hft := summable_matrix_blockDiagonal.not.mpr hf rw [tsum_eq_zero_of_not_summable hf, tsum_eq_zero_of_not_summable hft] exact blockDiagonal_zero theorem HasSum.matrix_blockDiag {f : X → Matrix (m × p) (n × p) R} {a : Matrix (m × p) (n × p) R} (hf : HasSum f a) : HasSum (fun x => blockDiag (f x)) (blockDiag a) := (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) : Summable fun x => blockDiag (f x) := 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) : HasSum (fun x => blockDiagonal' (f x)) (blockDiagonal' a) := 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) : Summable fun x => blockDiagonal' (f x) := 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)) ↔ Summable f := 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' (∑' x, f x) = ∑' x, blockDiagonal' (f x) := by by_cases hf : Summable f · exact hf.hasSum.matrix_blockDiagonal'.tsum_eq.symm · have hft := summable_matrix_blockDiagonal'.not.mpr hf rw [tsum_eq_zero_of_not_summable hf, tsum_eq_zero_of_not_summable hft] exact blockDiagonal'_zero 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) : HasSum (fun x => blockDiag' (f x)) (blockDiag' a) := 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) : Summable fun x => blockDiag' (f x) := hf.hasSum.matrix_blockDiag'.summable end BlockMatrices end tsum
Topology\Instances\Nat.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro -/ 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 Metric Set Filter 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 uniformEmbedding_coe_real : UniformEmbedding ((↑) : ℕ → ℝ) := uniformEmbedding_bot_of_pairwise_le_dist zero_lt_one pairwise_one_le_dist theorem closedEmbedding_coe_real : ClosedEmbedding ((↑) : ℕ → ℝ) := closedEmbedding_of_pairwise_le_dist zero_lt_one pairwise_one_le_dist instance : MetricSpace ℕ := Nat.uniformEmbedding_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_lt 0 r with (hr | hr) · rw [← preimage_closedBall, Real.closedBall_eq_Icc, preimage_Icc] exact add_nonneg (cast_nonneg x) hr · 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 : NoncompactSpace ℕ := noncompactSpace_of_neBot <| by simp [Filter.atTop_neBot] end Nat
Topology\Instances\NNReal.lean
/- Copyright (c) 2018 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.Data.NNReal.Star import Mathlib.Topology.Algebra.InfiniteSum.Order import Mathlib.Topology.Algebra.InfiniteSum.Ring import Mathlib.Topology.Instances.Real import Mathlib.Topology.MetricSpace.Isometry /-! # Topology on `ℝ≥0` The natural topology on `ℝ≥0` (the one induced from `ℝ`), and a basic API. ## Main definitions Instances for the following typeclasses are defined: * `TopologicalSpace ℝ≥0` * `TopologicalSemiring ℝ≥0` * `SecondCountableTopology ℝ≥0` * `OrderTopology ℝ≥0` * `ProperSpace ℝ≥0` * `ContinuousSub ℝ≥0` * `HasContinuousInv₀ ℝ≥0` (continuity of `x⁻¹` away from `0`) * `ContinuousSMul ℝ≥0 α` (whenever `α` has a continuous `MulAction ℝ α`) Everything is inherited from the corresponding structures on the reals. ## 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 Set TopologicalSpace Metric Filter open scoped Topology namespace NNReal instance : TopologicalSpace ℝ≥0 := inferInstance -- short-circuit type class inference instance : TopologicalSemiring ℝ≥0 where toContinuousAdd := continuousAdd_induced toRealHom toContinuousMul := continuousMul_induced toRealHom instance : SecondCountableTopology ℝ≥0 := inferInstanceAs (SecondCountableTopology { x : ℝ | 0 ≤ x }) instance : OrderTopology ℝ≥0 := orderTopology_of_ordConnected (t := Ici 0) instance : CompleteSpace ℝ≥0 := isClosed_Ici.completeSpace_coe instance : ContinuousStar ℝ≥0 where continuous_star := continuous_id section coe variable {α : Type*} open Filter Finset 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 (config := .asFn)] noncomputable def _root_.ContinuousMap.realToNNReal : C(ℝ, ℝ≥0) := .mk Real.toNNReal continuous_real_toNNReal theorem continuous_coe : Continuous ((↑) : ℝ≥0 → ℝ) := continuous_subtype_val /-- Embedding of `ℝ≥0` to `ℝ` as a bundled continuous map. -/ @[simps (config := .asFn)] def _root_.ContinuousMap.coeNNRealReal : C(ℝ≥0, ℝ) := ⟨(↑), continuous_coe⟩ instance ContinuousMap.canLift {X : Type*} [TopologicalSpace X] : CanLift C(X, ℝ) C(X, ℝ≥0) ContinuousMap.coeNNRealReal.comp fun f => ∀ x, 0 ≤ f x where prf f hf := ⟨⟨fun x => ⟨f x, hf x⟩, f.2.subtype_mk _⟩, DFunLike.ext' rfl⟩ @[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 instance : ContinuousSub ℝ≥0 := ⟨((continuous_coe.fst'.sub continuous_coe.snd').max continuous_const).subtype_mk _⟩ instance : HasContinuousInv₀ ℝ≥0 := inferInstance instance [TopologicalSpace α] [MulAction ℝ α] [ContinuousSMul ℝ α] : ContinuousSMul ℝ≥0 α where continuous_smul := continuous_induced_dom.fst'.smul continuous_snd @[norm_cast] theorem hasSum_coe {f : α → ℝ≥0} {r : ℝ≥0} : HasSum (fun a => (f a : ℝ)) (r : ℝ) ↔ HasSum f r := by simp only [HasSum, ← coe_sum, tendsto_coe] protected theorem _root_.HasSum.toNNReal {f : α → ℝ} {y : ℝ} (hf₀ : ∀ n, 0 ≤ f n) (hy : HasSum f y) : HasSum (fun x => Real.toNNReal (f x)) y.toNNReal := by lift y to ℝ≥0 using hy.nonneg hf₀ lift f to α → ℝ≥0 using hf₀ simpa [hasSum_coe] using hy theorem hasSum_real_toNNReal_of_nonneg {f : α → ℝ} (hf_nonneg : ∀ n, 0 ≤ f n) (hf : Summable f) : HasSum (fun n => Real.toNNReal (f n)) (Real.toNNReal (∑' n, f n)) := hf.hasSum.toNNReal hf_nonneg @[norm_cast] theorem summable_coe {f : α → ℝ≥0} : (Summable fun a => (f a : ℝ)) ↔ Summable f := by 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⟩ theorem summable_mk {f : α → ℝ} (hf : ∀ n, 0 ≤ f n) : (@Summable ℝ≥0 _ _ _ fun n => ⟨f n, hf n⟩) ↔ Summable f := Iff.symm <| summable_coe (f := fun x => ⟨f x, hf x⟩) open scoped Classical @[norm_cast] theorem coe_tsum {f : α → ℝ≥0} : ↑(∑' a, f a) = ∑' a, (f a : ℝ) := if hf : Summable f then Eq.symm <| (hasSum_coe.2 <| hf.hasSum).tsum_eq else by simp [tsum_def, hf, mt summable_coe.1 hf] theorem coe_tsum_of_nonneg {f : α → ℝ} (hf₁ : ∀ n, 0 ≤ f n) : (⟨∑' n, f n, tsum_nonneg hf₁⟩ : ℝ≥0) = (∑' 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) : ∑' x, a * f x = a * ∑' 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) : ∑' x, f x * a = (∑' 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) := (sum_add_tsum_nat_add' <| (summable_nat_add_iff k).2 hf).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 instance instProperSpace : ProperSpace ℝ≥0 where isCompact_closedBall x r := by have emb : ClosedEmbedding ((↑) : ℝ≥0 → ℝ) := Isometry.closedEmbedding fun _ ↦ congrFun rfl exact emb.isCompact_preimage (K := Metric.closedBall x r) (isCompact_closedBall _ _) end NNReal
Topology\Instances\PNat.lean
/- Copyright (c) 2024 Miyahara Kō. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Miyahara Kō -/ 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 uniformEmbedding_coe : UniformEmbedding ((↑) : ℕ+ → ℕ) := uniformEmbedding_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
Topology\Instances\Rat.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro -/ import Mathlib.Topology.Algebra.Order.Archimedean import Mathlib.Topology.Instances.Nat import Mathlib.Topology.Instances.Real /-! # Topology on the rational numbers The structure of a metric space on `ℚ` is introduced in this file, induced from `ℝ`. -/ open Metric Set Filter 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 uniformEmbedding_coe_real : UniformEmbedding ((↑) : ℚ → ℝ) := uniformEmbedding_comap Rat.cast_injective theorem denseEmbedding_coe_real : DenseEmbedding ((↑) : ℚ → ℝ) := uniformEmbedding_coe_real.denseEmbedding Rat.denseRange_cast theorem embedding_coe_real : Embedding ((↑) : ℚ → ℝ) := denseEmbedding_coe_real.to_embedding 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.uniformEmbedding_coe_rat : UniformEmbedding ((↑) : ℕ → ℚ) := uniformEmbedding_bot_of_pairwise_le_dist zero_lt_one <| by simpa using Nat.pairwise_one_le_dist theorem Nat.closedEmbedding_coe_rat : ClosedEmbedding ((↑) : ℕ → ℚ) := closedEmbedding_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.uniformEmbedding_coe_rat : UniformEmbedding ((↑) : ℤ → ℚ) := uniformEmbedding_bot_of_pairwise_le_dist zero_lt_one <| by simpa using Int.pairwise_one_le_dist theorem Int.closedEmbedding_coe_rat : ClosedEmbedding ((↑) : ℤ → ℚ) := closedEmbedding_of_pairwise_le_dist zero_lt_one <| by simpa using Int.pairwise_one_le_dist namespace Rat instance : NoncompactSpace ℚ := Int.closedEmbedding_coe_rat.noncompactSpace theorem uniformContinuous_add : UniformContinuous fun p : ℚ × ℚ => p.1 + p.2 := Rat.uniformEmbedding_coe_real.toUniformInducing.uniformContinuous_iff.2 <| by simp only [(· ∘ ·), Rat.cast_add] exact Real.uniformContinuous_add.comp (Rat.uniformContinuous_coe_real.prod_map Rat.uniformContinuous_coe_real) theorem uniformContinuous_neg : UniformContinuous (@Neg.neg ℚ _) := Metric.uniformContinuous_iff.2 fun ε ε0 => ⟨_, ε0, fun h => by rw [dist_comm] at h; simpa only [dist_eq, cast_neg, neg_sub_neg] using h⟩ instance : UniformAddGroup ℚ := UniformAddGroup.mk' Rat.uniformContinuous_add Rat.uniformContinuous_neg instance : TopologicalAddGroup ℚ := 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 : TopologicalRing ℚ := inferInstance nonrec theorem totallyBounded_Icc (a b : ℚ) : TotallyBounded (Icc a b) := by simpa only [preimage_cast_Icc] using totallyBounded_preimage Rat.uniformEmbedding_coe_real.toUniformInducing (totallyBounded_Icc (a : ℝ) b) end Rat
Topology\Instances\RatLemmas.lean
/- Copyright (c) 2022 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Topology.Instances.Irrational import Mathlib.Topology.Instances.Rat import Mathlib.Topology.Compactification.OnePoint /-! # 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 q : ℚ} {s t : Set ℚ} theorem interior_compact_eq_empty (hs : IsCompact s) : interior s = ∅ := denseEmbedding_coe_real.toDenseInducing.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 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_lt.resolve_left hlt <;> assumption 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
Topology\Instances\Real.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro -/ import Mathlib.Data.Real.Star import Mathlib.Algebra.Algebra.Basic import Mathlib.Algebra.Periodic import Mathlib.Topology.Algebra.Order.Field import Mathlib.Topology.Algebra.UniformMulAction import Mathlib.Topology.Algebra.Star import Mathlib.Topology.Instances.Int import Mathlib.Topology.Order.Bornology /-! # Topological properties of ℝ -/ noncomputable section open scoped Classical open Filter Int Metric Set TopologicalSpace Bornology open scoped Topology Uniformity Interval universe u v w variable {α : Type u} {β : Type v} {γ : Type w} instance : NoncompactSpace ℝ := Int.closedEmbedding_coe_real.noncompactSpace theorem Real.uniformContinuous_add : UniformContinuous fun p : ℝ × ℝ => p.1 + p.2 := Metric.uniformContinuous_iff.2 fun _ε ε0 => let ⟨δ, δ0, Hδ⟩ := rat_add_continuous_lemma abs ε0 ⟨δ, δ0, fun h => let ⟨h₁, h₂⟩ := max_lt_iff.1 h Hδ h₁ h₂⟩ theorem Real.uniformContinuous_neg : UniformContinuous (@Neg.neg ℝ _) := Metric.uniformContinuous_iff.2 fun ε ε0 => ⟨_, ε0, fun h => by rw [dist_comm] at h; simpa only [Real.dist_eq, neg_sub_neg] using h⟩ instance : ContinuousStar ℝ := ⟨continuous_id⟩ instance : UniformAddGroup ℝ := UniformAddGroup.mk' Real.uniformContinuous_add Real.uniformContinuous_neg -- short-circuit type class inference instance : TopologicalAddGroup ℝ := by infer_instance instance : TopologicalRing ℝ := inferInstance instance : TopologicalDivisionRing ℝ := inferInstance instance : ProperSpace ℝ where isCompact_closedBall x r := by rw [Real.closedBall_eq_Icc] apply isCompact_Icc instance : SecondCountableTopology ℝ := secondCountable_of_proper theorem Real.isTopologicalBasis_Ioo_rat : @IsTopologicalBasis ℝ _ (⋃ (a : ℚ) (b : ℚ) (_ : a < b), {Ioo (a : ℝ) b}) := isTopologicalBasis_of_isOpen_of_nhds (by simp (config := { contextual := true }) [isOpen_Ioo]) fun a v hav hv => let ⟨l, u, ⟨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 a' ⟨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] @[deprecated (since := "2024-02-07")] alias Real.cocompact_eq := cocompact_eq_atBot_atTop @[deprecated (since := "2024-02-07")] alias Real.atBot_le_cocompact := atBot_le_cocompact @[deprecated (since := "2024-02-07")] alias Real.atTop_le_cocompact := atTop_le_cocompact /- 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, 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_const_mul {x : ℝ} : UniformContinuous (x * ·) := uniformContinuous_const_smul x 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₂⟩ -- Porting note: moved `TopologicalRing` instance up instance Real.instCompleteSpace : CompleteSpace ℝ := by apply complete_of_cauchySeq_tendsto intro u hu let c : CauSeq ℝ abs := ⟨u, Metric.cauchySeq_iff'.1 hu⟩ refine ⟨c.lim, fun s h => ?_⟩ rcases Metric.mem_nhds_iff.1 h with ⟨ε, ε0, hε⟩ have := c.equiv_lim ε ε0 simp only [mem_map, mem_atTop_sets, mem_setOf_eq] exact this.imp fun N hN n hn => hε (hN n hn) theorem Real.totallyBounded_ball (x ε : ℝ) : TotallyBounded (ball x ε) := by rw [Real.ball_eq_Ioo]; apply totallyBounded_Ioo section theorem closure_of_rat_image_lt {q : ℚ} : closure (((↑) : ℚ → ℝ) '' { x | q < x }) = { r | ↑q ≤ r } := Subset.antisymm (isClosed_Ici.closure_subset_iff.2 (image_subset_iff.2 fun p (h : q < p) => by simpa using h.le)) fun x hx => mem_closure_iff_nhds.2 fun t ht => let ⟨ε, ε0, hε⟩ := Metric.mem_nhds_iff.1 ht let ⟨p, h₁, h₂⟩ := exists_rat_btwn ((lt_add_iff_pos_right x).2 ε0) ⟨p, hε <| by rwa [mem_ball, Real.dist_eq, abs_of_pos (sub_pos.2 h₁), sub_lt_iff_lt_add'], mem_image_of_mem _ <| Rat.cast_lt.1 <| lt_of_le_of_lt hx.out h₁⟩ /- 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 instance instIsOrderBornology : IsOrderBornology ℝ where isBounded_iff_bddBelow_bddAbove s := by refine ⟨fun bdd ↦ ?_, fun h ↦ isBounded_of_bddAbove_of_bddBelow h.2 h.1⟩ obtain ⟨r, hr⟩ : ∃ r : ℝ, s ⊆ Icc (-r) r := by simpa [Real.closedBall_eq_Icc] using bdd.subset_closedBall 0 exact ⟨bddBelow_Icc.mono hr, bddAbove_Icc.mono hr⟩ 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 section Subgroups 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 end Subgroups
Topology\Instances\RealVectorSpace.lean
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Topology.Algebra.Module.Basic 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.denseEmbedding_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⟩
Topology\Instances\Sign.lean
/- Copyright (c) 2022 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers -/ import Mathlib.Data.Sign 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 α] [DecidableRel ((· < ·) : α → α → Prop)] [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_lt with (h_neg | h_pos) · exact continuousAt_sign_of_neg h_neg · exact continuousAt_sign_of_pos h_pos end LinearOrder
Topology\Instances\TrivSqZeroExt.lean
/- Copyright (c) 2023 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.Algebra.TrivSqZeroExt import Mathlib.Topology.Algebra.InfiniteSum.Basic import Mathlib.Topology.Algebra.Module.Basic /-! # 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 scoped 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).prod (𝓝 x.snd) := by cases x using Prod.rec exact nhds_prod_eq theorem nhds_inl [Zero M] (x : R) : 𝓝 (inl x : tsze R M) = (𝓝 x).prod (𝓝 0) := nhds_def _ theorem nhds_inr [Zero R] (m : M) : 𝓝 (inr m : tsze R M) = (𝓝 0).prod (𝓝 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.prod_mk continuous_const theorem continuous_inr [Zero R] : Continuous (inr : M → tsze R M) := continuous_const.prod_mk continuous_id theorem embedding_inl [Zero M] : Embedding (inl : R → tsze R M) := embedding_of_embedding_compose continuous_inl continuous_fst embedding_id theorem embedding_inr [Zero R] : Embedding (inr : M → tsze R M) := embedding_of_embedding_compose continuous_inr continuous_snd embedding_id variable (R M) /-- `TrivSqZeroExt.fst` as a continuous linear map. -/ @[simps] def fstCLM [CommSemiring R] [AddCommMonoid M] [Module R M] : tsze R M →L[R] R := { 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)).prod_mk <| ((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 `TopologicalRing` instance below. -/ theorem topologicalSemiring [Semiring R] [AddCommMonoid M] [Module R M] [Module Rᵐᵒᵖ M] [TopologicalSemiring R] [ContinuousAdd M] [ContinuousSMul R M] [ContinuousSMul Rᵐᵒᵖ M] : TopologicalSemiring (tsze R M) := { } instance [Ring R] [AddCommGroup M] [Module R M] [Module Rᵐᵒᵖ M] [TopologicalRing R] [TopologicalAddGroup M] [ContinuousSMul R M] [ContinuousSMul Rᵐᵒᵖ M] : TopologicalRing (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] [UniformAddGroup R] [UniformAddGroup M] : UniformAddGroup (tsze R M) := inferInstanceAs <| UniformAddGroup (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.prod_mk uniformContinuous_const theorem uniformContinuous_inr [Zero R] : UniformContinuous (inr : M → tsze R M) := uniformContinuous_const.prod_mk uniformContinuous_id end Uniformity end TrivSqZeroExt
Topology\Instances\ZMod.lean
/- Copyright (c) 2024 David Loeffler. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: David Loeffler -/ 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
Topology\LocallyConstant\Algebra.lean
/- Copyright (c) 2021 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.Algebra.Algebra.Pi import Mathlib.LinearAlgebra.Pi import Mathlib.Topology.LocallyConstant.Basic /-! # Algebraic structure on locally constant functions This file puts algebraic structure (`Group`, `AddGroup`, etc) on the type of locally constant functions. -/ namespace LocallyConstant variable {X Y : Type*} [TopologicalSpace X] @[to_additive] instance [One Y] : One (LocallyConstant X Y) where one := const X 1 @[to_additive (attr := simp)] theorem coe_one [One Y] : ⇑(1 : LocallyConstant X Y) = (1 : X → Y) := rfl @[to_additive] theorem one_apply [One Y] (x : X) : (1 : LocallyConstant X Y) x = 1 := rfl @[to_additive] instance [Inv Y] : Inv (LocallyConstant X Y) where inv f := ⟨f⁻¹, f.isLocallyConstant.inv⟩ @[to_additive (attr := simp)] theorem coe_inv [Inv Y] (f : LocallyConstant X Y) : ⇑(f⁻¹ : LocallyConstant X Y) = (f : X → Y)⁻¹ := rfl @[to_additive] theorem inv_apply [Inv Y] (f : LocallyConstant X Y) (x : X) : f⁻¹ x = (f x)⁻¹ := rfl @[to_additive] instance [Mul Y] : Mul (LocallyConstant X Y) where mul f g := ⟨f * g, f.isLocallyConstant.mul g.isLocallyConstant⟩ @[to_additive (attr := simp)] theorem coe_mul [Mul Y] (f g : LocallyConstant X Y) : ⇑(f * g) = f * g := rfl @[to_additive] theorem mul_apply [Mul Y] (f g : LocallyConstant X Y) (x : X) : (f * g) x = f x * g x := rfl @[to_additive] instance [MulOneClass Y] : MulOneClass (LocallyConstant X Y) := Function.Injective.mulOneClass DFunLike.coe DFunLike.coe_injective' rfl fun _ _ => rfl /-- `DFunLike.coe` as a `MonoidHom`. -/ @[to_additive (attr := simps) "`DFunLike.coe` as an `AddMonoidHom`."] def coeFnMonoidHom [MulOneClass Y] : LocallyConstant X Y →* X → Y where toFun := DFunLike.coe map_one' := rfl map_mul' _ _ := rfl /-- The constant-function embedding, as a multiplicative monoid hom. -/ @[to_additive (attr := simps) "The constant-function embedding, as an additive monoid hom."] def constMonoidHom [MulOneClass Y] : Y →* LocallyConstant X Y where toFun := const X map_one' := rfl map_mul' _ _ := rfl instance [MulZeroClass Y] : MulZeroClass (LocallyConstant X Y) := Function.Injective.mulZeroClass DFunLike.coe DFunLike.coe_injective' rfl fun _ _ => rfl instance [MulZeroOneClass Y] : MulZeroOneClass (LocallyConstant X Y) := Function.Injective.mulZeroOneClass DFunLike.coe DFunLike.coe_injective' rfl rfl fun _ _ => rfl section CharFn variable (Y) [MulZeroOneClass Y] {U V : Set X} /-- Characteristic functions are locally constant functions taking `x : X` to `1` if `x ∈ U`, where `U` is a clopen set, and `0` otherwise. -/ noncomputable def charFn (hU : IsClopen U) : LocallyConstant X Y := indicator 1 hU theorem coe_charFn (hU : IsClopen U) : (charFn Y hU : X → Y) = Set.indicator U 1 := rfl theorem charFn_eq_one [Nontrivial Y] (x : X) (hU : IsClopen U) : charFn Y hU x = (1 : Y) ↔ x ∈ U := Set.indicator_eq_one_iff_mem _ theorem charFn_eq_zero [Nontrivial Y] (x : X) (hU : IsClopen U) : charFn Y hU x = (0 : Y) ↔ x ∉ U := Set.indicator_eq_zero_iff_not_mem _ theorem charFn_inj [Nontrivial Y] (hU : IsClopen U) (hV : IsClopen V) (h : charFn Y hU = charFn Y hV) : U = V := Set.indicator_one_inj Y <| coe_inj.mpr h end CharFn @[to_additive] instance [Div Y] : Div (LocallyConstant X Y) where div f g := ⟨f / g, f.isLocallyConstant.div g.isLocallyConstant⟩ @[to_additive] theorem coe_div [Div Y] (f g : LocallyConstant X Y) : ⇑(f / g) = f / g := rfl @[to_additive] theorem div_apply [Div Y] (f g : LocallyConstant X Y) (x : X) : (f / g) x = f x / g x := rfl @[to_additive] instance [Semigroup Y] : Semigroup (LocallyConstant X Y) := Function.Injective.semigroup DFunLike.coe DFunLike.coe_injective' fun _ _ => rfl instance [SemigroupWithZero Y] : SemigroupWithZero (LocallyConstant X Y) := Function.Injective.semigroupWithZero DFunLike.coe DFunLike.coe_injective' rfl fun _ _ => rfl @[to_additive] instance [CommSemigroup Y] : CommSemigroup (LocallyConstant X Y) := Function.Injective.commSemigroup DFunLike.coe DFunLike.coe_injective' fun _ _ => rfl variable {α R : Type*} @[to_additive] instance smul [SMul α Y] : SMul α (LocallyConstant X Y) where smul n f := f.map (n • ·) @[to_additive (attr := simp)] theorem coe_smul [SMul R Y] (r : R) (f : LocallyConstant X Y) : ⇑(r • f) = r • (f : X → Y) := rfl @[to_additive] theorem smul_apply [SMul R Y] (r : R) (f : LocallyConstant X Y) (x : X) : (r • f) x = r • f x := rfl @[to_additive existing LocallyConstant.smul] instance [Pow Y α] : Pow (LocallyConstant X Y) α where pow f n := f.map (· ^ n) @[to_additive] instance [Monoid Y] : Monoid (LocallyConstant X Y) := Function.Injective.monoid DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) fun _ _ => rfl instance [NatCast Y] : NatCast (LocallyConstant X Y) where natCast n := const X n instance [IntCast Y] : IntCast (LocallyConstant X Y) where intCast n := const X n instance [AddMonoidWithOne Y] : AddMonoidWithOne (LocallyConstant X Y) := Function.Injective.addMonoidWithOne DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl @[to_additive] instance [CommMonoid Y] : CommMonoid (LocallyConstant X Y) := Function.Injective.commMonoid DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) fun _ _ => rfl @[to_additive] instance [Group Y] : Group (LocallyConstant X Y) := Function.Injective.group DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) @[to_additive] instance [CommGroup Y] : CommGroup (LocallyConstant X Y) := Function.Injective.commGroup DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) instance [Distrib Y] : Distrib (LocallyConstant X Y) := Function.Injective.distrib DFunLike.coe DFunLike.coe_injective' (fun _ _ => rfl) fun _ _ => rfl instance [NonUnitalNonAssocSemiring Y] : NonUnitalNonAssocSemiring (LocallyConstant X Y) := Function.Injective.nonUnitalNonAssocSemiring DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) instance [NonUnitalSemiring Y] : NonUnitalSemiring (LocallyConstant X Y) := Function.Injective.nonUnitalSemiring DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) instance [NonAssocSemiring Y] : NonAssocSemiring (LocallyConstant X Y) := Function.Injective.nonAssocSemiring DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl /-- The constant-function embedding, as a ring hom. -/ @[simps] def constRingHom [NonAssocSemiring Y] : Y →+* LocallyConstant X Y := { constMonoidHom, constAddMonoidHom with toFun := const X } instance [Semiring Y] : Semiring (LocallyConstant X Y) := Function.Injective.semiring DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl instance [NonUnitalCommSemiring Y] : NonUnitalCommSemiring (LocallyConstant X Y) := Function.Injective.nonUnitalCommSemiring DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) instance [CommSemiring Y] : CommSemiring (LocallyConstant X Y) := Function.Injective.commSemiring DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl instance [NonUnitalNonAssocRing Y] : NonUnitalNonAssocRing (LocallyConstant X Y) := Function.Injective.nonUnitalNonAssocRing DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) instance [NonUnitalRing Y] : NonUnitalRing (LocallyConstant X Y) := Function.Injective.nonUnitalRing DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) instance [NonAssocRing Y] : NonAssocRing (LocallyConstant X Y) := Function.Injective.nonAssocRing DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ => rfl) instance [Ring Y] : Ring (LocallyConstant X Y) := Function.Injective.ring DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) fun _ => rfl instance [NonUnitalCommRing Y] : NonUnitalCommRing (LocallyConstant X Y) := Function.Injective.nonUnitalCommRing DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) instance [CommRing Y] : CommRing (LocallyConstant X Y) := Function.Injective.commRing DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) fun _ => rfl variable {R : Type*} instance [Monoid R] [MulAction R Y] : MulAction R (LocallyConstant X Y) := Function.Injective.mulAction _ coe_injective fun _ _ => rfl instance [Monoid R] [AddMonoid Y] [DistribMulAction R Y] : DistribMulAction R (LocallyConstant X Y) := Function.Injective.distribMulAction coeFnAddMonoidHom coe_injective fun _ _ => rfl instance [Semiring R] [AddCommMonoid Y] [Module R Y] : Module R (LocallyConstant X Y) := Function.Injective.module R coeFnAddMonoidHom coe_injective fun _ _ => rfl section Algebra variable [CommSemiring R] [Semiring Y] [Algebra R Y] instance : Algebra R (LocallyConstant X Y) where toRingHom := constRingHom.comp <| algebraMap R Y commutes' := by intros ext exact Algebra.commutes' _ _ smul_def' := by intros ext exact Algebra.smul_def' _ _ @[simp] theorem coe_algebraMap (r : R) : ⇑(algebraMap R (LocallyConstant X Y) r) = algebraMap R (X → Y) r := rfl end Algebra section coeFn /-- `DFunLike.coe` as a `RingHom`. -/ @[simps!] def coeFnRingHom [Semiring Y] : LocallyConstant X Y →+* X → Y where toMonoidHom := coeFnMonoidHom __ := coeFnAddMonoidHom /-- `DFunLike.coe` as a linear map. -/ @[simps!] def coeFnₗ (R : Type*) [Semiring R] [AddCommMonoid Y] [Module R Y] : LocallyConstant X Y →ₗ[R] X → Y where toAddHom := coeFnAddMonoidHom.toAddHom map_smul' _ _ := rfl /-- `DFunLike.coe` as an `AlgHom`. -/ @[simps!] def coeFnAlgHom (R : Type*) [CommSemiring R] [Semiring Y] [Algebra R Y] : LocallyConstant X Y →ₐ[R] X → Y where toRingHom := coeFnRingHom commutes' _ := rfl end coeFn section Eval /-- Evaluation as a `MonoidHom` -/ @[to_additive (attr := simps!) "Evaluation as an `AddMonoidHom`"] def evalMonoidHom [MulOneClass Y] (x : X) : LocallyConstant X Y →* Y := (Pi.evalMonoidHom _ x).comp coeFnMonoidHom /-- Evaluation as a linear map -/ @[simps!] def evalₗ (R : Type*) [Semiring R] [AddCommMonoid Y] [Module R Y] (x : X) : LocallyConstant X Y →ₗ[R] Y := (LinearMap.proj x).comp (coeFnₗ R) /-- Evaluation as a `RingHom` -/ @[simps!] def evalRingHom [Semiring Y] (x : X) : LocallyConstant X Y →+* Y := (Pi.evalRingHom _ x).comp coeFnRingHom /-- Evaluation as an `AlgHom` -/ @[simps!] def evalₐ (R : Type*) [CommSemiring R] [Semiring Y] [Algebra R Y] (x : X) : LocallyConstant X Y →ₐ[R] Y := (Pi.evalAlgHom _ _ x).comp (coeFnAlgHom R) end Eval section Comap variable [TopologicalSpace Y] {Z : Type*} /-- `LocallyConstant.comap` as a `MonoidHom`. -/ @[to_additive (attr := simps) "`LocallyConstant.comap` as an `AddMonoidHom`."] def comapMonoidHom [MulOneClass Z] (f : C(X, Y)) : LocallyConstant Y Z →* LocallyConstant X Z where toFun := comap f map_one' := rfl map_mul' _ _ := rfl /-- `LocallyConstant.comap` as a linear map. -/ @[simps!] def comapₗ (R : Type*) [Semiring R] [AddCommMonoid Z] [Module R Z] (f : C(X, Y)) : LocallyConstant Y Z →ₗ[R] LocallyConstant X Z where toFun := comap f map_add' := map_add (comapAddMonoidHom f) map_smul' _ _ := rfl /-- `LocallyConstant.comap` as a `RingHom`. -/ @[simps!] def comapRingHom [Semiring Z] (f : C(X, Y)) : LocallyConstant Y Z →+* LocallyConstant X Z where toMonoidHom := comapMonoidHom f __ := (comapAddMonoidHom f) /-- `LocallyConstant.comap` as an `AlgHom` -/ @[simps!] def comapₐ (R : Type*) [CommSemiring R] [Semiring Z] [Algebra R Z] (f : C(X, Y)) : LocallyConstant Y Z →ₐ[R] LocallyConstant X Z where toRingHom := comapRingHom f commutes' _ := rfl lemma ker_comapₗ [Semiring R] [AddCommMonoid Z] [Module R Z] (f : C(X, Y)) (hfs : Function.Surjective f) : LinearMap.ker (comapₗ R f : LocallyConstant Y Z →ₗ[R] LocallyConstant X Z) = ⊥ := LinearMap.ker_eq_bot_of_injective <| comap_injective _ hfs /-- `LocallyConstant.congrLeft` as a linear equivalence. -/ @[simps!] def congrLeftₗ (R : Type*) [Semiring R] [AddCommMonoid Z] [Module R Z] (e : X ≃ₜ Y) : LocallyConstant X Z ≃ₗ[R] LocallyConstant Y Z where toLinearMap := comapₗ R ⟨_, e.symm.continuous⟩ __ := congrLeft e /-- `LocallyConstant.congrLeft` as a `RingEquiv`. -/ @[simps!] def congrLeftRingEquiv [Semiring Z] (e : X ≃ₜ Y) : LocallyConstant X Z ≃+* LocallyConstant Y Z where toEquiv := congrLeft e __ := comapMonoidHom ⟨_, e.symm.continuous⟩ __ := comapAddMonoidHom ⟨_, e.symm.continuous⟩ /-- `LocallyConstant.congrLeft` as an `AlgEquiv`. -/ @[simps!] def congrLeftₐ (R : Type*) [CommSemiring R] [Semiring Z] [Algebra R Z] (e : X ≃ₜ Y) : LocallyConstant X Z ≃ₐ[R] LocallyConstant Y Z where toEquiv := congrLeft e __ := comapₐ R ⟨_, e.symm.continuous⟩ end Comap section Map variable {Z : Type*} /-- `LocallyConstant.map` as a `MonoidHom`. -/ @[to_additive (attr := simps) "`LocallyConstant.map` as an `AddMonoidHom`."] def mapMonoidHom [MulOneClass Y] [MulOneClass Z] (f : Y →* Z) : LocallyConstant X Y →* LocallyConstant X Z where toFun := map f map_one' := by aesop map_mul' := by aesop /-- `LocallyConstant.map` as a linear map. -/ @[simps!] def mapₗ (R : Type*) [Semiring R] [AddCommMonoid Y] [Module R Y] [AddCommMonoid Z] [Module R Z] (f : Y →ₗ[R] Z) : LocallyConstant X Y →ₗ[R] LocallyConstant X Z where toFun := map f map_add' := by aesop map_smul' := by aesop /-- `LocallyConstant.map` as a `RingHom`. -/ @[simps!] def mapRingHom [Semiring Y] [Semiring Z] (f : Y →+* Z) : LocallyConstant X Y →+* LocallyConstant X Z where toMonoidHom := mapMonoidHom f __ := (mapAddMonoidHom f.toAddMonoidHom) /-- `LocallyConstant.map` as an `AlgHom` -/ @[simps!] def mapₐ (R : Type*) [CommSemiring R] [Semiring Y] [Algebra R Y] [Semiring Z] [Algebra R Z] (f : Y →ₐ[R] Z) : LocallyConstant X Y →ₐ[R] LocallyConstant X Z where toRingHom := mapRingHom f commutes' _ := by aesop /-- `LocallyConstant.congrRight` as a linear equivalence. -/ @[simps!] def congrRightₗ (R : Type*) [Semiring R] [AddCommMonoid Y] [Module R Y] [AddCommMonoid Z] [Module R Z] (e : Y ≃ₗ[R] Z) : LocallyConstant X Y ≃ₗ[R] LocallyConstant X Z where toLinearMap := mapₗ R e __ := congrRight e.toEquiv /-- `LocallyConstant.congrRight` as a `RingEquiv`. -/ @[simps!] def congrRightRingEquiv [Semiring Y] [Semiring Z] (e : Y ≃+* Z) : LocallyConstant X Y ≃+* LocallyConstant X Z where toEquiv := congrRight e __ := mapMonoidHom e.toMonoidHom __ := mapAddMonoidHom e.toAddMonoidHom /-- `LocallyConstant.congrRight` as an `AlgEquiv`. -/ @[simps!] def congrRightₐ (R : Type*) [CommSemiring R] [Semiring Y] [Algebra R Y] [Semiring Z] [Algebra R Z] (e : Y ≃ₐ[R] Z) : LocallyConstant X Y ≃ₐ[R] LocallyConstant X Z where toEquiv := congrRight e __ := mapₐ R e.toAlgHom end Map section Const /-- `LocallyConstant.const` as a linear map. -/ @[simps!] def constₗ (R : Type*) [Semiring R] [AddCommMonoid Y] [Module R Y] : Y →ₗ[R] LocallyConstant X Y where toFun := const X map_add' _ _ := rfl map_smul' _ _ := rfl /-- `LocallyConstant.const` as an `AlgHom` -/ @[simps!] def constₐ (R : Type*) [CommSemiring R] [Semiring Y] [Algebra R Y] : Y →ₐ[R] LocallyConstant X Y where toRingHom := constRingHom commutes' _ := rfl end Const end LocallyConstant
Topology\LocallyConstant\Basic.lean
/- Copyright (c) 2021 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.Algebra.GroupWithZero.Indicator import Mathlib.Tactic.FinCases import Mathlib.Topology.Sets.Closeds /-! # Locally constant functions This file sets up the theory of locally constant function from a topological space to a type. ## Main definitions and constructions * `IsLocallyConstant f` : a map `f : X → Y` where `X` is a topological space is locally constant if every set in `Y` has an open preimage. * `LocallyConstant X Y` : the type of locally constant maps from `X` to `Y` * `LocallyConstant.map` : push-forward of locally constant maps * `LocallyConstant.comap` : pull-back of locally constant maps -/ variable {X Y Z α : Type*} [TopologicalSpace X] open Set Filter open Topology /-- A function between topological spaces is locally constant if the preimage of any set is open. -/ def IsLocallyConstant (f : X → Y) : Prop := ∀ s : Set Y, IsOpen (f ⁻¹' s) namespace IsLocallyConstant open List in protected theorem tfae (f : X → Y) : TFAE [IsLocallyConstant f, ∀ x, ∀ᶠ x' in 𝓝 x, f x' = f x, ∀ x, IsOpen { x' | f x' = f x }, ∀ y, IsOpen (f ⁻¹' {y}), ∀ x, ∃ U : Set X, IsOpen U ∧ x ∈ U ∧ ∀ x' ∈ U, f x' = f x] := by tfae_have 1 → 4 · exact fun h y => h {y} tfae_have 4 → 3 · exact fun h x => h (f x) tfae_have 3 → 2 · exact fun h x => IsOpen.mem_nhds (h x) rfl tfae_have 2 → 5 · intro h x rcases mem_nhds_iff.1 (h x) with ⟨U, eq, hU, hx⟩ exact ⟨U, hU, hx, eq⟩ tfae_have 5 → 1 · intro h s refine isOpen_iff_forall_mem_open.2 fun x hx ↦ ?_ rcases h x with ⟨U, hU, hxU, eq⟩ exact ⟨U, fun x' hx' => mem_preimage.2 <| (eq x' hx').symm ▸ hx, hU, hxU⟩ tfae_finish @[nontriviality] theorem of_discrete [DiscreteTopology X] (f : X → Y) : IsLocallyConstant f := fun _ => isOpen_discrete _ theorem isOpen_fiber {f : X → Y} (hf : IsLocallyConstant f) (y : Y) : IsOpen { x | f x = y } := hf {y} theorem isClosed_fiber {f : X → Y} (hf : IsLocallyConstant f) (y : Y) : IsClosed { x | f x = y } := ⟨hf {y}ᶜ⟩ theorem isClopen_fiber {f : X → Y} (hf : IsLocallyConstant f) (y : Y) : IsClopen { x | f x = y } := ⟨isClosed_fiber hf _, isOpen_fiber hf _⟩ theorem iff_exists_open (f : X → Y) : IsLocallyConstant f ↔ ∀ x, ∃ U : Set X, IsOpen U ∧ x ∈ U ∧ ∀ x' ∈ U, f x' = f x := (IsLocallyConstant.tfae f).out 0 4 theorem iff_eventually_eq (f : X → Y) : IsLocallyConstant f ↔ ∀ x, ∀ᶠ y in 𝓝 x, f y = f x := (IsLocallyConstant.tfae f).out 0 1 theorem exists_open {f : X → Y} (hf : IsLocallyConstant f) (x : X) : ∃ U : Set X, IsOpen U ∧ x ∈ U ∧ ∀ x' ∈ U, f x' = f x := (iff_exists_open f).1 hf x protected theorem eventually_eq {f : X → Y} (hf : IsLocallyConstant f) (x : X) : ∀ᶠ y in 𝓝 x, f y = f x := (iff_eventually_eq f).1 hf x theorem iff_isOpen_fiber_apply {f : X → Y} : IsLocallyConstant f ↔ ∀ x, IsOpen (f ⁻¹' {f x}) := (IsLocallyConstant.tfae f).out 0 2 theorem iff_isOpen_fiber {f : X → Y} : IsLocallyConstant f ↔ ∀ y, IsOpen (f ⁻¹' {y}) := (IsLocallyConstant.tfae f).out 0 3 protected theorem continuous [TopologicalSpace Y] {f : X → Y} (hf : IsLocallyConstant f) : Continuous f := ⟨fun _ _ => hf _⟩ theorem iff_continuous {_ : TopologicalSpace Y} [DiscreteTopology Y] (f : X → Y) : IsLocallyConstant f ↔ Continuous f := ⟨IsLocallyConstant.continuous, fun h s => h.isOpen_preimage s (isOpen_discrete _)⟩ theorem of_constant (f : X → Y) (h : ∀ x y, f x = f y) : IsLocallyConstant f := (iff_eventually_eq f).2 fun _ => eventually_of_forall fun _ => h _ _ protected theorem const (y : Y) : IsLocallyConstant (Function.const X y) := of_constant _ fun _ _ => rfl protected theorem comp {f : X → Y} (hf : IsLocallyConstant f) (g : Y → Z) : IsLocallyConstant (g ∘ f) := fun s => by rw [Set.preimage_comp] exact hf _ theorem prod_mk {Y'} {f : X → Y} {f' : X → Y'} (hf : IsLocallyConstant f) (hf' : IsLocallyConstant f') : IsLocallyConstant fun x => (f x, f' x) := (iff_eventually_eq _).2 fun x => (hf.eventually_eq x).mp <| (hf'.eventually_eq x).mono fun _ hf' hf => Prod.ext hf hf' theorem comp₂ {Y₁ Y₂ Z : Type*} {f : X → Y₁} {g : X → Y₂} (hf : IsLocallyConstant f) (hg : IsLocallyConstant g) (h : Y₁ → Y₂ → Z) : IsLocallyConstant fun x => h (f x) (g x) := (hf.prod_mk hg).comp fun x : Y₁ × Y₂ => h x.1 x.2 theorem comp_continuous [TopologicalSpace Y] {g : Y → Z} {f : X → Y} (hg : IsLocallyConstant g) (hf : Continuous f) : IsLocallyConstant (g ∘ f) := fun s => by rw [Set.preimage_comp] exact hf.isOpen_preimage _ (hg _) /-- A locally constant function is constant on any preconnected set. -/ theorem apply_eq_of_isPreconnected {f : X → Y} (hf : IsLocallyConstant f) {s : Set X} (hs : IsPreconnected s) {x y : X} (hx : x ∈ s) (hy : y ∈ s) : f x = f y := by let U := f ⁻¹' {f y} suffices x ∉ Uᶜ from Classical.not_not.1 this intro hxV specialize hs U Uᶜ (hf {f y}) (hf {f y}ᶜ) _ ⟨y, ⟨hy, rfl⟩⟩ ⟨x, ⟨hx, hxV⟩⟩ · simp only [union_compl_self, subset_univ] · simp only [inter_empty, Set.not_nonempty_empty, inter_compl_self] at hs theorem apply_eq_of_preconnectedSpace [PreconnectedSpace X] {f : X → Y} (hf : IsLocallyConstant f) (x y : X) : f x = f y := hf.apply_eq_of_isPreconnected isPreconnected_univ trivial trivial theorem eq_const [PreconnectedSpace X] {f : X → Y} (hf : IsLocallyConstant f) (x : X) : f = Function.const X (f x) := funext fun y => hf.apply_eq_of_preconnectedSpace y x theorem exists_eq_const [PreconnectedSpace X] [Nonempty Y] {f : X → Y} (hf : IsLocallyConstant f) : ∃ y, f = Function.const X y := by cases' isEmpty_or_nonempty X with h h · exact ⟨Classical.arbitrary Y, funext <| h.elim⟩ · exact ⟨f (Classical.arbitrary X), hf.eq_const _⟩ theorem iff_is_const [PreconnectedSpace X] {f : X → Y} : IsLocallyConstant f ↔ ∀ x y, f x = f y := ⟨fun h _ _ => h.apply_eq_of_isPreconnected isPreconnected_univ trivial trivial, of_constant _⟩ theorem range_finite [CompactSpace X] {f : X → Y} (hf : IsLocallyConstant f) : (Set.range f).Finite := by letI : TopologicalSpace Y := ⊥; haveI := discreteTopology_bot Y exact (isCompact_range hf.continuous).finite_of_discrete @[to_additive] theorem one [One Y] : IsLocallyConstant (1 : X → Y) := IsLocallyConstant.const 1 @[to_additive] theorem inv [Inv Y] ⦃f : X → Y⦄ (hf : IsLocallyConstant f) : IsLocallyConstant f⁻¹ := hf.comp fun x => x⁻¹ @[to_additive] theorem mul [Mul Y] ⦃f g : X → Y⦄ (hf : IsLocallyConstant f) (hg : IsLocallyConstant g) : IsLocallyConstant (f * g) := hf.comp₂ hg (· * ·) @[to_additive] theorem div [Div Y] ⦃f g : X → Y⦄ (hf : IsLocallyConstant f) (hg : IsLocallyConstant g) : IsLocallyConstant (f / g) := hf.comp₂ hg (· / ·) /-- If a composition of a function `f` followed by an injection `g` is locally constant, then the locally constant property descends to `f`. -/ theorem desc {α β : Type*} (f : X → α) (g : α → β) (h : IsLocallyConstant (g ∘ f)) (inj : Function.Injective g) : IsLocallyConstant f := fun s => by rw [← preimage_image_eq s inj, preimage_preimage] exact h (g '' s) theorem of_constant_on_connected_components [LocallyConnectedSpace X] {f : X → Y} (h : ∀ x, ∀ y ∈ connectedComponent x, f y = f x) : IsLocallyConstant f := (iff_exists_open _).2 fun x => ⟨connectedComponent x, isOpen_connectedComponent, mem_connectedComponent, h x⟩ theorem of_constant_on_connected_clopens [LocallyConnectedSpace X] {f : X → Y} (h : ∀ U : Set X, IsConnected U → IsClopen U → ∀ x ∈ U, ∀ y ∈ U, f y = f x) : IsLocallyConstant f := of_constant_on_connected_components fun x => h (connectedComponent x) isConnected_connectedComponent isClopen_connectedComponent x mem_connectedComponent theorem of_constant_on_preconnected_clopens [LocallyConnectedSpace X] {f : X → Y} (h : ∀ U : Set X, IsPreconnected U → IsClopen U → ∀ x ∈ U, ∀ y ∈ U, f y = f x) : IsLocallyConstant f := of_constant_on_connected_clopens fun U hU ↦ h U hU.isPreconnected end IsLocallyConstant /-- A (bundled) locally constant function from a topological space `X` to a type `Y`. -/ structure LocallyConstant (X Y : Type*) [TopologicalSpace X] where /-- The underlying function. -/ protected toFun : X → Y /-- The map is locally constant. -/ protected isLocallyConstant : IsLocallyConstant toFun namespace LocallyConstant instance [Inhabited Y] : Inhabited (LocallyConstant X Y) := ⟨⟨_, IsLocallyConstant.const default⟩⟩ instance : FunLike (LocallyConstant X Y) X Y where coe := LocallyConstant.toFun coe_injective' := by rintro ⟨_, _⟩ ⟨_, _⟩ _; congr /-- See Note [custom simps projections]. -/ def Simps.apply (f : LocallyConstant X Y) : X → Y := f initialize_simps_projections LocallyConstant (toFun → apply) @[simp] theorem toFun_eq_coe (f : LocallyConstant X Y) : f.toFun = f := rfl @[simp] theorem coe_mk (f : X → Y) (h) : ⇑(⟨f, h⟩ : LocallyConstant X Y) = f := rfl protected theorem congr_fun {f g : LocallyConstant X Y} (h : f = g) (x : X) : f x = g x := DFunLike.congr_fun h x protected theorem congr_arg (f : LocallyConstant X Y) {x y : X} (h : x = y) : f x = f y := DFunLike.congr_arg f h theorem coe_injective : @Function.Injective (LocallyConstant X Y) (X → Y) (↑) := fun _ _ => DFunLike.ext' @[norm_cast] theorem coe_inj {f g : LocallyConstant X Y} : (f : X → Y) = g ↔ f = g := coe_injective.eq_iff @[ext] theorem ext ⦃f g : LocallyConstant X Y⦄ (h : ∀ x, f x = g x) : f = g := DFunLike.ext _ _ h section CodomainTopologicalSpace variable [TopologicalSpace Y] (f : LocallyConstant X Y) protected theorem continuous : Continuous f := f.isLocallyConstant.continuous /-- We can turn a locally-constant function into a bundled `ContinuousMap`. -/ @[coe] def toContinuousMap : C(X, Y) := ⟨f, f.continuous⟩ /-- As a shorthand, `LocallyConstant.toContinuousMap` is available as a coercion -/ instance : Coe (LocallyConstant X Y) C(X, Y) := ⟨toContinuousMap⟩ -- Porting note: became a syntactic `rfl` @[simp] theorem coe_continuousMap : ((f : C(X, Y)) : X → Y) = (f : X → Y) := rfl theorem toContinuousMap_injective : Function.Injective (toContinuousMap : LocallyConstant X Y → C(X, Y)) := fun _ _ h => ext (ContinuousMap.congr_fun h) end CodomainTopologicalSpace /-- The constant locally constant function on `X` with value `y : Y`. -/ def const (X : Type*) {Y : Type*} [TopologicalSpace X] (y : Y) : LocallyConstant X Y := ⟨Function.const X y, IsLocallyConstant.const _⟩ @[simp] theorem coe_const (y : Y) : (const X y : X → Y) = Function.const X y := rfl /-- The locally constant function to `Fin 2` associated to a clopen set. -/ def ofIsClopen {X : Type*} [TopologicalSpace X] {U : Set X} [∀ x, Decidable (x ∈ U)] (hU : IsClopen U) : LocallyConstant X (Fin 2) where toFun x := if x ∈ U then 0 else 1 isLocallyConstant := by refine IsLocallyConstant.iff_isOpen_fiber.2 <| Fin.forall_fin_two.2 ⟨?_, ?_⟩ · convert hU.2 using 1 ext simp only [mem_singleton_iff, Fin.one_eq_zero_iff, mem_preimage, ite_eq_left_iff, Nat.succ_succ_ne_one] tauto · rw [← isClosed_compl_iff] convert hU.1 ext simp @[simp] theorem ofIsClopen_fiber_zero {X : Type*} [TopologicalSpace X] {U : Set X} [∀ x, Decidable (x ∈ U)] (hU : IsClopen U) : ofIsClopen hU ⁻¹' ({0} : Set (Fin 2)) = U := by ext simp only [ofIsClopen, mem_singleton_iff, Fin.one_eq_zero_iff, coe_mk, mem_preimage, ite_eq_left_iff, Nat.succ_succ_ne_one] tauto @[simp] theorem ofIsClopen_fiber_one {X : Type*} [TopologicalSpace X] {U : Set X} [∀ x, Decidable (x ∈ U)] (hU : IsClopen U) : ofIsClopen hU ⁻¹' ({1} : Set (Fin 2)) = Uᶜ := by ext simp only [ofIsClopen, mem_singleton_iff, coe_mk, Fin.zero_eq_one_iff, mem_preimage, ite_eq_right_iff, mem_compl_iff, Nat.succ_succ_ne_one] theorem locallyConstant_eq_of_fiber_zero_eq {X : Type*} [TopologicalSpace X] (f g : LocallyConstant X (Fin 2)) (h : f ⁻¹' ({0} : Set (Fin 2)) = g ⁻¹' {0}) : f = g := by simp only [Set.ext_iff, mem_singleton_iff, mem_preimage] at h ext1 x exact Fin.fin_two_eq_of_eq_zero_iff (h x) theorem range_finite [CompactSpace X] (f : LocallyConstant X Y) : (Set.range f).Finite := f.isLocallyConstant.range_finite theorem apply_eq_of_isPreconnected (f : LocallyConstant X Y) {s : Set X} (hs : IsPreconnected s) {x y : X} (hx : x ∈ s) (hy : y ∈ s) : f x = f y := f.isLocallyConstant.apply_eq_of_isPreconnected hs hx hy theorem apply_eq_of_preconnectedSpace [PreconnectedSpace X] (f : LocallyConstant X Y) (x y : X) : f x = f y := f.isLocallyConstant.apply_eq_of_isPreconnected isPreconnected_univ trivial trivial theorem eq_const [PreconnectedSpace X] (f : LocallyConstant X Y) (x : X) : f = const X (f x) := ext fun _ => apply_eq_of_preconnectedSpace f _ _ theorem exists_eq_const [PreconnectedSpace X] [Nonempty Y] (f : LocallyConstant X Y) : ∃ y, f = const X y := by rcases Classical.em (Nonempty X) with (⟨⟨x⟩⟩ | hX) · exact ⟨f x, f.eq_const x⟩ · exact ⟨Classical.arbitrary Y, ext fun x => (hX ⟨x⟩).elim⟩ /-- Push forward of locally constant maps under any map, by post-composition. -/ def map (f : Y → Z) (g : LocallyConstant X Y) : LocallyConstant X Z := ⟨f ∘ g, g.isLocallyConstant.comp f⟩ @[simp] theorem map_apply (f : Y → Z) (g : LocallyConstant X Y) : ⇑(map f g) = f ∘ g := rfl @[simp] theorem map_id : @map X Y Y _ id = id := rfl @[simp] theorem map_comp {Y₁ Y₂ Y₃ : Type*} (g : Y₂ → Y₃) (f : Y₁ → Y₂) : @map X _ _ _ g ∘ map f = map (g ∘ f) := rfl /-- Given a locally constant function to `α → β`, construct a family of locally constant functions with values in β indexed by α. -/ def flip {X α β : Type*} [TopologicalSpace X] (f : LocallyConstant X (α → β)) (a : α) : LocallyConstant X β := f.map fun f => f a /-- If α is finite, this constructs a locally constant function to `α → β` given a family of locally constant functions with values in β indexed by α. -/ def unflip {X α β : Type*} [Finite α] [TopologicalSpace X] (f : α → LocallyConstant X β) : LocallyConstant X (α → β) where toFun x a := f a x isLocallyConstant := IsLocallyConstant.iff_isOpen_fiber.2 fun g => by have : (fun (x : X) (a : α) => f a x) ⁻¹' {g} = ⋂ a : α, f a ⁻¹' {g a} := by ext; simp [Function.funext_iff] rw [this] exact isOpen_iInter_of_finite fun a => (f a).isLocallyConstant _ @[simp] theorem unflip_flip {X α β : Type*} [Finite α] [TopologicalSpace X] (f : LocallyConstant X (α → β)) : unflip f.flip = f := rfl @[simp] theorem flip_unflip {X α β : Type*} [Finite α] [TopologicalSpace X] (f : α → LocallyConstant X β) : (unflip f).flip = f := rfl section Comap variable [TopologicalSpace Y] /-- Pull back of locally constant maps under a continuous map, by pre-composition. -/ def comap (f : C(X, Y)) (g : LocallyConstant Y Z) : LocallyConstant X Z := ⟨g ∘ f, g.isLocallyConstant.comp_continuous f.continuous⟩ @[simp] theorem coe_comap (f : C(X, Y)) (g : LocallyConstant Y Z) : (comap f g) = g ∘ f := rfl theorem coe_comap_apply (f : C(X, Y)) (g : LocallyConstant Y Z) (x : X) : comap f g x = g (f x) := rfl @[simp] theorem comap_id : comap (@ContinuousMap.id X _) = @id (LocallyConstant X Z) := rfl theorem comap_comp {W : Type*} [TopologicalSpace W] (f : C(W, X)) (g : C(X, Y)) : comap (Z := Z) (g.comp f) = comap f ∘ comap g := rfl theorem comap_comap {W : Type*} [TopologicalSpace W] (f : C(W, X)) (g : C(X, Y)) (x : LocallyConstant Y Z) : comap f (comap g x) = comap (g.comp f) x := rfl theorem comap_const (f : C(X, Y)) (y : Y) (h : ∀ x, f x = y) : (comap f : LocallyConstant Y Z → LocallyConstant X Z) = fun g => const X (g y) := by ext; simp [h] lemma comap_injective (f : C(X, Y)) (hfs : f.1.Surjective) : (comap (Z := Z) f).Injective := by intro a b h ext y obtain ⟨x, hx⟩ := hfs y simpa [← hx] using LocallyConstant.congr_fun h x end Comap section Desc /-- If a locally constant function factors through an injection, then it factors through a locally constant function. -/ def desc {X α β : Type*} [TopologicalSpace X] {g : α → β} (f : X → α) (h : LocallyConstant X β) (cond : g ∘ f = h) (inj : Function.Injective g) : LocallyConstant X α where toFun := f isLocallyConstant := IsLocallyConstant.desc _ g (cond.symm ▸ h.isLocallyConstant) inj @[simp] theorem coe_desc {X α β : Type*} [TopologicalSpace X] (f : X → α) (g : α → β) (h : LocallyConstant X β) (cond : g ∘ f = h) (inj : Function.Injective g) : ⇑(desc f h cond inj) = f := rfl end Desc section Indicator variable {R : Type*} [One R] {U : Set X} (f : LocallyConstant X R) open scoped Classical /-- Given a clopen set `U` and a locally constant function `f`, `LocallyConstant.mulIndicator` returns the locally constant function that is `f` on `U` and `1` otherwise. -/ @[to_additive (attr := simps) "Given a clopen set `U` and a locally constant function `f`, `LocallyConstant.indicator` returns the locally constant function that is `f` on `U` and `0` otherwise. "] noncomputable def mulIndicator (hU : IsClopen U) : LocallyConstant X R where toFun := Set.mulIndicator U f isLocallyConstant := fun s => by rw [mulIndicator_preimage, Set.ite, Set.diff_eq] exact ((f.2 s).inter hU.isOpen).union ((IsLocallyConstant.const 1 s).inter hU.compl.isOpen) variable (a : X) @[to_additive] theorem mulIndicator_apply_eq_if (hU : IsClopen U) : mulIndicator f hU a = if a ∈ U then f a else 1 := Set.mulIndicator_apply U f a variable {a} @[to_additive] theorem mulIndicator_of_mem (hU : IsClopen U) (h : a ∈ U) : f.mulIndicator hU a = f a := Set.mulIndicator_of_mem h _ @[to_additive] theorem mulIndicator_of_not_mem (hU : IsClopen U) (h : a ∉ U) : f.mulIndicator hU a = 1 := Set.mulIndicator_of_not_mem h _ end Indicator section Equiv /-- The equivalence between `LocallyConstant X Z` and `LocallyConstant Y Z` given a homeomorphism `X ≃ₜ Y` -/ @[simps] def congrLeft [TopologicalSpace Y] (e : X ≃ₜ Y) : LocallyConstant X Z ≃ LocallyConstant Y Z where toFun := comap e.symm invFun := comap e left_inv := by intro simp [comap_comap] right_inv := by intro simp [comap_comap] /-- The equivalence between `LocallyConstant X Y` and `LocallyConstant X Z` given an equivalence `Y ≃ Z` -/ @[simps] def congrRight (e : Y ≃ Z) : LocallyConstant X Y ≃ LocallyConstant X Z where toFun := map e invFun := map e.symm left_inv := by intro; ext; simp right_inv := by intro; ext; simp variable (X) in /-- The set of clopen subsets of a topological space is equivalent to the locally constant maps to a two-element set -/ def equivClopens [∀ (s : Set X) x, Decidable (x ∈ s)] : LocallyConstant X (Fin 2) ≃ TopologicalSpace.Clopens X where toFun f := ⟨f ⁻¹' {0}, f.2.isClopen_fiber _⟩ invFun s := ofIsClopen s.2 left_inv _ := locallyConstant_eq_of_fiber_zero_eq _ _ (by simp) right_inv _ := by simp end Equiv section Piecewise /-- Given two closed sets covering a topological space, and locally constant maps on these two sets, then if these two locally constant maps agree on the intersection, we get a piecewise defined locally constant map on the whole space. TODO: Generalise this construction to `ContinuousMap`. -/ def piecewise {C₁ C₂ : Set X} (h₁ : IsClosed C₁) (h₂ : IsClosed C₂) (h : C₁ ∪ C₂ = Set.univ) (f : LocallyConstant C₁ Z) (g : LocallyConstant C₂ Z) (hfg : ∀ (x : X) (hx : x ∈ C₁ ∩ C₂), f ⟨x, hx.1⟩ = g ⟨x, hx.2⟩) [DecidablePred (· ∈ C₁)] : LocallyConstant X Z where toFun i := if hi : i ∈ C₁ then f ⟨i, hi⟩ else g ⟨i, (Set.compl_subset_iff_union.mpr h) hi⟩ isLocallyConstant := by let dZ : TopologicalSpace Z := ⊥ haveI : DiscreteTopology Z := discreteTopology_bot Z obtain ⟨f, hf⟩ := f obtain ⟨g, hg⟩ := g rw [IsLocallyConstant.iff_continuous] at hf hg ⊢ dsimp only [coe_mk] rw [Set.union_eq_iUnion] at h refine (locallyFinite_of_finite _).continuous h (fun i ↦ ?_) (fun i ↦ ?_) · cases i <;> [exact h₂; exact h₁] · cases i <;> rw [continuousOn_iff_continuous_restrict] · convert hg ext x simp only [cond_false, restrict_apply, Subtype.coe_eta, dite_eq_right_iff] exact fun hx ↦ hfg x ⟨hx, x.prop⟩ · simp only [cond_true, restrict_dite, Subtype.coe_eta] exact hf @[simp] lemma piecewise_apply_left {C₁ C₂ : Set X} (h₁ : IsClosed C₁) (h₂ : IsClosed C₂) (h : C₁ ∪ C₂ = Set.univ) (f : LocallyConstant C₁ Z) (g : LocallyConstant C₂ Z) (hfg : ∀ (x : X) (hx : x ∈ C₁ ∩ C₂), f ⟨x, hx.1⟩ = g ⟨x, hx.2⟩) [DecidablePred (· ∈ C₁)] (x : X) (hx : x ∈ C₁) : piecewise h₁ h₂ h f g hfg x = f ⟨x, hx⟩ := by simp only [piecewise, Set.mem_preimage, continuous_subtype_val.restrictPreimage, coe_comap, Function.comp_apply, coe_mk] rw [dif_pos hx] @[simp] lemma piecewise_apply_right {C₁ C₂ : Set X} (h₁ : IsClosed C₁) (h₂ : IsClosed C₂) (h : C₁ ∪ C₂ = Set.univ) (f : LocallyConstant C₁ Z) (g : LocallyConstant C₂ Z) (hfg : ∀ (x : X) (hx : x ∈ C₁ ∩ C₂), f ⟨x, hx.1⟩ = g ⟨x, hx.2⟩) [DecidablePred (· ∈ C₁)] (x : X) (hx : x ∈ C₂) : piecewise h₁ h₂ h f g hfg x = g ⟨x, hx⟩ := by simp only [piecewise, Set.mem_preimage, continuous_subtype_val.restrictPreimage, coe_comap, Function.comp_apply, coe_mk] split_ifs with h · exact hfg x ⟨h, hx⟩ · rfl /-- A variant of `LocallyConstant.piecewise` where the two closed sets cover a subset. TODO: Generalise this construction to `ContinuousMap`. -/ def piecewise' {C₀ C₁ C₂ : Set X} (h₀ : C₀ ⊆ C₁ ∪ C₂) (h₁ : IsClosed C₁) (h₂ : IsClosed C₂) (f₁ : LocallyConstant C₁ Z) (f₂ : LocallyConstant C₂ Z) [DecidablePred (· ∈ C₁)] (hf : ∀ x (hx : x ∈ C₁ ∩ C₂), f₁ ⟨x, hx.1⟩ = f₂ ⟨x, hx.2⟩) : LocallyConstant C₀ Z := letI : ∀ j : C₀, Decidable (j ∈ Subtype.val ⁻¹' C₁) := fun j ↦ decidable_of_iff (↑j ∈ C₁) Iff.rfl piecewise (h₁.preimage continuous_subtype_val) (h₂.preimage continuous_subtype_val) (by simpa [eq_univ_iff_forall] using h₀) (f₁.comap ⟨(restrictPreimage C₁ ((↑) : C₀ → X)), continuous_subtype_val.restrictPreimage⟩) (f₂.comap ⟨(restrictPreimage C₂ ((↑) : C₀ → X)), continuous_subtype_val.restrictPreimage⟩) <| by rintro ⟨x, hx₀⟩ ⟨hx₁ : x ∈ C₁, hx₂ : x ∈ C₂⟩ simpa using hf x ⟨hx₁, hx₂⟩ @[simp] lemma piecewise'_apply_left {C₀ C₁ C₂ : Set X} (h₀ : C₀ ⊆ C₁ ∪ C₂) (h₁ : IsClosed C₁) (h₂ : IsClosed C₂) (f₁ : LocallyConstant C₁ Z) (f₂ : LocallyConstant C₂ Z) [DecidablePred (· ∈ C₁)] (hf : ∀ x (hx : x ∈ C₁ ∩ C₂), f₁ ⟨x, hx.1⟩ = f₂ ⟨x, hx.2⟩) (x : C₀) (hx : x.val ∈ C₁) : piecewise' h₀ h₁ h₂ f₁ f₂ hf x = f₁ ⟨x.val, hx⟩ := by letI : ∀ j : C₀, Decidable (j ∈ Subtype.val ⁻¹' C₁) := fun j ↦ decidable_of_iff (↑j ∈ C₁) Iff.rfl rw [piecewise', piecewise_apply_left (f := (f₁.comap ⟨(restrictPreimage C₁ ((↑) : C₀ → X)), continuous_subtype_val.restrictPreimage⟩)) (hx := hx)] rfl @[simp] lemma piecewise'_apply_right {C₀ C₁ C₂ : Set X} (h₀ : C₀ ⊆ C₁ ∪ C₂) (h₁ : IsClosed C₁) (h₂ : IsClosed C₂) (f₁ : LocallyConstant C₁ Z) (f₂ : LocallyConstant C₂ Z) [DecidablePred (· ∈ C₁)] (hf : ∀ x (hx : x ∈ C₁ ∩ C₂), f₁ ⟨x, hx.1⟩ = f₂ ⟨x, hx.2⟩) (x : C₀) (hx : x.val ∈ C₂) : piecewise' h₀ h₁ h₂ f₁ f₂ hf x = f₂ ⟨x.val, hx⟩ := by letI : ∀ j : C₀, Decidable (j ∈ Subtype.val ⁻¹' C₁) := fun j ↦ decidable_of_iff (↑j ∈ C₁) Iff.rfl rw [piecewise', piecewise_apply_right (f := (f₁.comap ⟨(restrictPreimage C₁ ((↑) : C₀ → X)), continuous_subtype_val.restrictPreimage⟩)) (hx := hx)] rfl end Piecewise end LocallyConstant
Topology\Maps\Basic.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Patrick Massot -/ import Mathlib.Topology.Order /-! # Specific classes of maps between topological spaces This file introduces the following properties of a map `f : X → Y` between topological spaces: * `IsOpenMap f` means the image of an open set under `f` is open. * `IsClosedMap f` means the image of a closed set under `f` is closed. (Open and closed maps need not be continuous.) * `Inducing f` means the topology on `X` is the one induced via `f` from the topology on `Y`. These behave like embeddings except they need not be injective. Instead, points of `X` which are identified by `f` are also inseparable in the topology on `X`. * `Embedding f` means `f` is inducing and also injective. Equivalently, `f` identifies `X` with a subspace of `Y`. * `OpenEmbedding f` means `f` is an embedding with open image, so it identifies `X` with an open subspace of `Y`. Equivalently, `f` is an embedding and an open map. * `ClosedEmbedding f` similarly means `f` is an embedding with closed image, so it identifies `X` with a closed subspace of `Y`. Equivalently, `f` is an embedding and a closed map. * `QuotientMap f` is the dual condition to `Embedding f`: `f` is surjective and the topology on `Y` is the one coinduced via `f` from the topology on `X`. Equivalently, `f` identifies `Y` with a quotient of `X`. Quotient maps are also sometimes known as identification maps. ## References * <https://en.wikipedia.org/wiki/Open_and_closed_maps> * <https://en.wikipedia.org/wiki/Embedding#General_topology> * <https://en.wikipedia.org/wiki/Quotient_space_(topology)#Quotient_map> ## Tags open map, closed map, embedding, quotient map, identification map -/ open Set Filter Function open TopologicalSpace Topology Filter variable {X : Type*} {Y : Type*} {Z : Type*} {ι : Type*} {f : X → Y} {g : Y → Z} section Inducing variable [TopologicalSpace Y] theorem inducing_induced (f : X → Y) : @Inducing X Y (TopologicalSpace.induced f ‹_›) _ f := @Inducing.mk _ _ (TopologicalSpace.induced f ‹_›) _ _ rfl variable [TopologicalSpace X] theorem inducing_id : Inducing (@id X) := ⟨induced_id.symm⟩ variable [TopologicalSpace Z] protected theorem Inducing.comp (hg : Inducing g) (hf : Inducing f) : Inducing (g ∘ f) := ⟨by rw [hf.induced, hg.induced, induced_compose]⟩ theorem Inducing.of_comp_iff (hg : Inducing g) : Inducing (g ∘ f) ↔ Inducing f := by refine ⟨fun h ↦ ?_, hg.comp⟩ rw [inducing_iff, hg.induced, induced_compose, h.induced] theorem inducing_of_inducing_compose (hf : Continuous f) (hg : Continuous g) (hgf : Inducing (g ∘ f)) : Inducing f := ⟨le_antisymm (by rwa [← continuous_iff_le_induced]) (by rw [hgf.induced, ← induced_compose] exact induced_mono hg.le_induced)⟩ theorem inducing_iff_nhds : Inducing f ↔ ∀ x, 𝓝 x = comap f (𝓝 (f x)) := (inducing_iff _).trans (induced_iff_nhds_eq f) namespace Inducing theorem nhds_eq_comap (hf : Inducing f) : ∀ x : X, 𝓝 x = comap f (𝓝 <| f x) := inducing_iff_nhds.1 hf theorem basis_nhds {p : ι → Prop} {s : ι → Set Y} (hf : Inducing f) {x : X} (h_basis : (𝓝 (f x)).HasBasis p s) : (𝓝 x).HasBasis p (preimage f ∘ s) := hf.nhds_eq_comap x ▸ h_basis.comap f theorem nhdsSet_eq_comap (hf : Inducing f) (s : Set X) : 𝓝ˢ s = comap f (𝓝ˢ (f '' s)) := by simp only [nhdsSet, sSup_image, comap_iSup, hf.nhds_eq_comap, iSup_image] theorem map_nhds_eq (hf : Inducing f) (x : X) : (𝓝 x).map f = 𝓝[range f] f x := hf.induced.symm ▸ map_nhds_induced_eq x theorem map_nhds_of_mem (hf : Inducing f) (x : X) (h : range f ∈ 𝓝 (f x)) : (𝓝 x).map f = 𝓝 (f x) := hf.induced.symm ▸ map_nhds_induced_of_mem h theorem mapClusterPt_iff (hf : Inducing f) {x : X} {l : Filter X} : MapClusterPt (f x) l f ↔ ClusterPt x l := by delta MapClusterPt ClusterPt rw [← Filter.push_pull', ← hf.nhds_eq_comap, map_neBot_iff] theorem image_mem_nhdsWithin (hf : Inducing f) {x : X} {s : Set X} (hs : s ∈ 𝓝 x) : f '' s ∈ 𝓝[range f] f x := hf.map_nhds_eq x ▸ image_mem_map hs theorem tendsto_nhds_iff {f : ι → Y} {l : Filter ι} {y : Y} (hg : Inducing g) : Tendsto f l (𝓝 y) ↔ Tendsto (g ∘ f) l (𝓝 (g y)) := by rw [hg.nhds_eq_comap, tendsto_comap_iff] theorem continuousAt_iff (hg : Inducing g) {x : X} : ContinuousAt f x ↔ ContinuousAt (g ∘ f) x := hg.tendsto_nhds_iff theorem continuous_iff (hg : Inducing g) : Continuous f ↔ Continuous (g ∘ f) := by simp_rw [continuous_iff_continuousAt, hg.continuousAt_iff] theorem continuousAt_iff' (hf : Inducing f) {x : X} (h : range f ∈ 𝓝 (f x)) : ContinuousAt (g ∘ f) x ↔ ContinuousAt g (f x) := by simp_rw [ContinuousAt, Filter.Tendsto, ← hf.map_nhds_of_mem _ h, Filter.map_map, comp] protected theorem continuous (hf : Inducing f) : Continuous f := hf.continuous_iff.mp continuous_id theorem closure_eq_preimage_closure_image (hf : Inducing f) (s : Set X) : closure s = f ⁻¹' closure (f '' s) := by ext x rw [Set.mem_preimage, ← closure_induced, hf.induced] theorem isClosed_iff (hf : Inducing f) {s : Set X} : IsClosed s ↔ ∃ t, IsClosed t ∧ f ⁻¹' t = s := by rw [hf.induced, isClosed_induced_iff] theorem isClosed_iff' (hf : Inducing f) {s : Set X} : IsClosed s ↔ ∀ x, f x ∈ closure (f '' s) → x ∈ s := by rw [hf.induced, isClosed_induced_iff'] theorem isClosed_preimage (h : Inducing f) (s : Set Y) (hs : IsClosed s) : IsClosed (f ⁻¹' s) := (isClosed_iff h).mpr ⟨s, hs, rfl⟩ theorem isOpen_iff (hf : Inducing f) {s : Set X} : IsOpen s ↔ ∃ t, IsOpen t ∧ f ⁻¹' t = s := by rw [hf.induced, isOpen_induced_iff] theorem setOf_isOpen (hf : Inducing f) : {s : Set X | IsOpen s} = preimage f '' {t | IsOpen t} := Set.ext fun _ ↦ hf.isOpen_iff theorem dense_iff (hf : Inducing f) {s : Set X} : Dense s ↔ ∀ x, f x ∈ closure (f '' s) := by simp only [Dense, hf.closure_eq_preimage_closure_image, mem_preimage] theorem of_subsingleton [Subsingleton X] (f : X → Y) : Inducing f := ⟨Subsingleton.elim _ _⟩ end Inducing end Inducing section Embedding theorem Function.Injective.embedding_induced [t : TopologicalSpace Y] (hf : Injective f) : @_root_.Embedding X Y (t.induced f) t f := @_root_.Embedding.mk X Y (t.induced f) t _ (inducing_induced f) hf variable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] theorem Embedding.mk' (f : X → Y) (inj : Injective f) (induced : ∀ x, comap f (𝓝 (f x)) = 𝓝 x) : Embedding f := ⟨inducing_iff_nhds.2 fun x => (induced x).symm, inj⟩ theorem embedding_id : Embedding (@id X) := ⟨inducing_id, fun _ _ h => h⟩ protected theorem Embedding.comp (hg : Embedding g) (hf : Embedding f) : Embedding (g ∘ f) := { hg.toInducing.comp hf.toInducing with inj := fun _ _ h => hf.inj <| hg.inj h } theorem Embedding.of_comp_iff (hg : Embedding g) : Embedding (g ∘ f) ↔ Embedding f := by simp_rw [embedding_iff, hg.toInducing.of_comp_iff, hg.inj.of_comp_iff f] theorem embedding_of_embedding_compose (hf : Continuous f) (hg : Continuous g) (hgf : Embedding (g ∘ f)) : Embedding f := { induced := (inducing_of_inducing_compose hf hg hgf.toInducing).induced inj := fun x₁ x₂ h => hgf.inj <| by simp [h, (· ∘ ·)] } protected theorem Function.LeftInverse.embedding {f : X → Y} {g : Y → X} (h : LeftInverse f g) (hf : Continuous f) (hg : Continuous g) : _root_.Embedding g := embedding_of_embedding_compose hg hf <| h.comp_eq_id.symm ▸ embedding_id theorem Embedding.map_nhds_eq (hf : Embedding f) (x : X) : (𝓝 x).map f = 𝓝[range f] f x := hf.1.map_nhds_eq x theorem Embedding.map_nhds_of_mem (hf : Embedding f) (x : X) (h : range f ∈ 𝓝 (f x)) : (𝓝 x).map f = 𝓝 (f x) := hf.1.map_nhds_of_mem x h theorem Embedding.tendsto_nhds_iff {f : ι → Y} {l : Filter ι} {y : Y} (hg : Embedding g) : Tendsto f l (𝓝 y) ↔ Tendsto (g ∘ f) l (𝓝 (g y)) := hg.toInducing.tendsto_nhds_iff theorem Embedding.continuous_iff (hg : Embedding g) : Continuous f ↔ Continuous (g ∘ f) := Inducing.continuous_iff hg.1 theorem Embedding.continuous (hf : Embedding f) : Continuous f := Inducing.continuous hf.1 theorem Embedding.closure_eq_preimage_closure_image (hf : Embedding f) (s : Set X) : closure s = f ⁻¹' closure (f '' s) := hf.1.closure_eq_preimage_closure_image s /-- The topology induced under an inclusion `f : X → Y` from a discrete topological space `Y` is the discrete topology on `X`. See also `DiscreteTopology.of_continuous_injective`. -/ theorem Embedding.discreteTopology [DiscreteTopology Y] (hf : Embedding f) : DiscreteTopology X := .of_continuous_injective hf.continuous hf.inj theorem Embedding.of_subsingleton [Subsingleton X] (f : X → Y) : Embedding f := ⟨.of_subsingleton f, f.injective_of_subsingleton⟩ end Embedding section QuotientMap variable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] theorem quotientMap_iff : QuotientMap f ↔ Surjective f ∧ ∀ s : Set Y, IsOpen s ↔ IsOpen (f ⁻¹' s) := and_congr Iff.rfl TopologicalSpace.ext_iff theorem quotientMap_iff_closed : QuotientMap f ↔ Surjective f ∧ ∀ s : Set Y, IsClosed s ↔ IsClosed (f ⁻¹' s) := quotientMap_iff.trans <| Iff.rfl.and <| compl_surjective.forall.trans <| by simp only [isOpen_compl_iff, preimage_compl] namespace QuotientMap protected theorem id : QuotientMap (@id X) := ⟨fun x => ⟨x, rfl⟩, coinduced_id.symm⟩ protected theorem comp (hg : QuotientMap g) (hf : QuotientMap f) : QuotientMap (g ∘ f) := ⟨hg.left.comp hf.left, by rw [hg.right, hf.right, coinduced_compose]⟩ protected theorem of_quotientMap_compose (hf : Continuous f) (hg : Continuous g) (hgf : QuotientMap (g ∘ f)) : QuotientMap g := ⟨hgf.1.of_comp, le_antisymm (by rw [hgf.right, ← coinduced_compose]; exact coinduced_mono hf.coinduced_le) hg.coinduced_le⟩ theorem of_inverse {g : Y → X} (hf : Continuous f) (hg : Continuous g) (h : LeftInverse g f) : QuotientMap g := QuotientMap.of_quotientMap_compose hf hg <| h.comp_eq_id.symm ▸ QuotientMap.id protected theorem continuous_iff (hf : QuotientMap f) : Continuous g ↔ Continuous (g ∘ f) := by rw [continuous_iff_coinduced_le, continuous_iff_coinduced_le, hf.right, coinduced_compose] protected theorem continuous (hf : QuotientMap f) : Continuous f := hf.continuous_iff.mp continuous_id protected theorem surjective (hf : QuotientMap f) : Surjective f := hf.1 protected theorem isOpen_preimage (hf : QuotientMap f) {s : Set Y} : IsOpen (f ⁻¹' s) ↔ IsOpen s := ((quotientMap_iff.1 hf).2 s).symm protected theorem isClosed_preimage (hf : QuotientMap f) {s : Set Y} : IsClosed (f ⁻¹' s) ↔ IsClosed s := ((quotientMap_iff_closed.1 hf).2 s).symm end QuotientMap end QuotientMap section OpenMap variable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] namespace IsOpenMap protected theorem id : IsOpenMap (@id X) := fun s hs => by rwa [image_id] protected theorem comp (hg : IsOpenMap g) (hf : IsOpenMap f) : IsOpenMap (g ∘ f) := fun s hs => by rw [image_comp]; exact hg _ (hf _ hs) theorem isOpen_range (hf : IsOpenMap f) : IsOpen (range f) := by rw [← image_univ] exact hf _ isOpen_univ theorem image_mem_nhds (hf : IsOpenMap f) {x : X} {s : Set X} (hx : s ∈ 𝓝 x) : f '' s ∈ 𝓝 (f x) := let ⟨t, hts, ht, hxt⟩ := mem_nhds_iff.1 hx mem_of_superset (IsOpen.mem_nhds (hf t ht) (mem_image_of_mem _ hxt)) (image_subset _ hts) theorem range_mem_nhds (hf : IsOpenMap f) (x : X) : range f ∈ 𝓝 (f x) := hf.isOpen_range.mem_nhds <| mem_range_self _ theorem mapsTo_interior (hf : IsOpenMap f) {s : Set X} {t : Set Y} (h : MapsTo f s t) : MapsTo f (interior s) (interior t) := mapsTo'.2 <| interior_maximal (h.mono interior_subset Subset.rfl).image_subset (hf _ isOpen_interior) theorem image_interior_subset (hf : IsOpenMap f) (s : Set X) : f '' interior s ⊆ interior (f '' s) := (hf.mapsTo_interior (mapsTo_image f s)).image_subset theorem nhds_le (hf : IsOpenMap f) (x : X) : 𝓝 (f x) ≤ (𝓝 x).map f := le_map fun _ => hf.image_mem_nhds theorem of_nhds_le (hf : ∀ x, 𝓝 (f x) ≤ map f (𝓝 x)) : IsOpenMap f := fun _s hs => isOpen_iff_mem_nhds.2 fun _y ⟨_x, hxs, hxy⟩ => hxy ▸ hf _ (image_mem_map <| hs.mem_nhds hxs) theorem of_sections (h : ∀ x, ∃ g : Y → X, ContinuousAt g (f x) ∧ g (f x) = x ∧ RightInverse g f) : IsOpenMap f := of_nhds_le fun x => let ⟨g, hgc, hgx, hgf⟩ := h x calc 𝓝 (f x) = map f (map g (𝓝 (f x))) := by rw [map_map, hgf.comp_eq_id, map_id] _ ≤ map f (𝓝 (g (f x))) := map_mono hgc _ = map f (𝓝 x) := by rw [hgx] theorem of_inverse {f' : Y → X} (h : Continuous f') (l_inv : LeftInverse f f') (r_inv : RightInverse f f') : IsOpenMap f := of_sections fun _ => ⟨f', h.continuousAt, r_inv _, l_inv⟩ /-- A continuous surjective open map is a quotient map. -/ theorem to_quotientMap (open_map : IsOpenMap f) (cont : Continuous f) (surj : Surjective f) : QuotientMap f := quotientMap_iff.2 ⟨surj, fun s => ⟨fun h => h.preimage cont, fun h => surj.image_preimage s ▸ open_map _ h⟩⟩ theorem interior_preimage_subset_preimage_interior (hf : IsOpenMap f) {s : Set Y} : interior (f ⁻¹' s) ⊆ f ⁻¹' interior s := hf.mapsTo_interior (mapsTo_preimage _ _) theorem preimage_interior_eq_interior_preimage (hf₁ : IsOpenMap f) (hf₂ : Continuous f) (s : Set Y) : f ⁻¹' interior s = interior (f ⁻¹' s) := Subset.antisymm (preimage_interior_subset_interior_preimage hf₂) (interior_preimage_subset_preimage_interior hf₁) theorem preimage_closure_subset_closure_preimage (hf : IsOpenMap f) {s : Set Y} : f ⁻¹' closure s ⊆ closure (f ⁻¹' s) := by rw [← compl_subset_compl] simp only [← interior_compl, ← preimage_compl, hf.interior_preimage_subset_preimage_interior] theorem preimage_closure_eq_closure_preimage (hf : IsOpenMap f) (hfc : Continuous f) (s : Set Y) : f ⁻¹' closure s = closure (f ⁻¹' s) := hf.preimage_closure_subset_closure_preimage.antisymm (hfc.closure_preimage_subset s) theorem preimage_frontier_subset_frontier_preimage (hf : IsOpenMap f) {s : Set Y} : f ⁻¹' frontier s ⊆ frontier (f ⁻¹' s) := by simpa only [frontier_eq_closure_inter_closure, preimage_inter] using inter_subset_inter hf.preimage_closure_subset_closure_preimage hf.preimage_closure_subset_closure_preimage theorem preimage_frontier_eq_frontier_preimage (hf : IsOpenMap f) (hfc : Continuous f) (s : Set Y) : f ⁻¹' frontier s = frontier (f ⁻¹' s) := by simp only [frontier_eq_closure_inter_closure, preimage_inter, preimage_compl, hf.preimage_closure_eq_closure_preimage hfc] theorem of_isEmpty [h : IsEmpty X] (f : X → Y) : IsOpenMap f := of_nhds_le h.elim end IsOpenMap theorem isOpenMap_iff_nhds_le : IsOpenMap f ↔ ∀ x : X, 𝓝 (f x) ≤ (𝓝 x).map f := ⟨fun hf => hf.nhds_le, IsOpenMap.of_nhds_le⟩ theorem isOpenMap_iff_interior : IsOpenMap f ↔ ∀ s, f '' interior s ⊆ interior (f '' s) := ⟨IsOpenMap.image_interior_subset, fun hs u hu => subset_interior_iff_isOpen.mp <| calc f '' u = f '' interior u := by rw [hu.interior_eq] _ ⊆ interior (f '' u) := hs u⟩ /-- An inducing map with an open range is an open map. -/ protected theorem Inducing.isOpenMap (hi : Inducing f) (ho : IsOpen (range f)) : IsOpenMap f := IsOpenMap.of_nhds_le fun _ => (hi.map_nhds_of_mem _ <| IsOpen.mem_nhds ho <| mem_range_self _).ge /-- Preimage of a dense set under an open map is dense. -/ protected theorem Dense.preimage {s : Set Y} (hs : Dense s) (hf : IsOpenMap f) : Dense (f ⁻¹' s) := fun x ↦ hf.preimage_closure_subset_closure_preimage <| hs (f x) end OpenMap section IsClosedMap variable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] namespace IsClosedMap open Function protected theorem id : IsClosedMap (@id X) := fun s hs => by rwa [image_id] protected theorem comp (hg : IsClosedMap g) (hf : IsClosedMap f) : IsClosedMap (g ∘ f) := by intro s hs rw [image_comp] exact hg _ (hf _ hs) theorem closure_image_subset (hf : IsClosedMap f) (s : Set X) : closure (f '' s) ⊆ f '' closure s := closure_minimal (image_subset _ subset_closure) (hf _ isClosed_closure) theorem of_inverse {f' : Y → X} (h : Continuous f') (l_inv : LeftInverse f f') (r_inv : RightInverse f f') : IsClosedMap f := fun s hs => by rw [image_eq_preimage_of_inverse r_inv l_inv] exact hs.preimage h theorem of_nonempty (h : ∀ s, IsClosed s → s.Nonempty → IsClosed (f '' s)) : IsClosedMap f := by intro s hs; rcases eq_empty_or_nonempty s with h2s | h2s · simp_rw [h2s, image_empty, isClosed_empty] · exact h s hs h2s theorem isClosed_range (hf : IsClosedMap f) : IsClosed (range f) := @image_univ _ _ f ▸ hf _ isClosed_univ @[deprecated (since := "2024-03-17")] alias closed_range := isClosed_range theorem to_quotientMap (hcl : IsClosedMap f) (hcont : Continuous f) (hsurj : Surjective f) : QuotientMap f := quotientMap_iff_closed.2 ⟨hsurj, fun s => ⟨fun hs => hs.preimage hcont, fun hs => hsurj.image_preimage s ▸ hcl _ hs⟩⟩ end IsClosedMap theorem Inducing.isClosedMap (hf : Inducing f) (h : IsClosed (range f)) : IsClosedMap f := by intro s hs rcases hf.isClosed_iff.1 hs with ⟨t, ht, rfl⟩ rw [image_preimage_eq_inter_range] exact ht.inter h theorem isClosedMap_iff_closure_image : IsClosedMap f ↔ ∀ s, closure (f '' s) ⊆ f '' closure s := ⟨IsClosedMap.closure_image_subset, fun hs c hc => isClosed_of_closure_subset <| calc closure (f '' c) ⊆ f '' closure c := hs c _ = f '' c := by rw [hc.closure_eq]⟩ /-- A map `f : X → Y` is closed if and only if for all sets `s`, any cluster point of `f '' s` is the image by `f` of some cluster point of `s`. If you require this for all filters instead of just principal filters, and also that `f` is continuous, you get the notion of **proper map**. See `isProperMap_iff_clusterPt`. -/ theorem isClosedMap_iff_clusterPt : IsClosedMap f ↔ ∀ s y, MapClusterPt y (𝓟 s) f → ∃ x, f x = y ∧ ClusterPt x (𝓟 s) := by simp [MapClusterPt, isClosedMap_iff_closure_image, subset_def, mem_closure_iff_clusterPt, and_comm] theorem IsClosedMap.closure_image_eq_of_continuous (f_closed : IsClosedMap f) (f_cont : Continuous f) (s : Set X) : closure (f '' s) = f '' closure s := subset_antisymm (f_closed.closure_image_subset s) (image_closure_subset_closure_image f_cont) theorem IsClosedMap.lift'_closure_map_eq (f_closed : IsClosedMap f) (f_cont : Continuous f) (F : Filter X) : (map f F).lift' closure = map f (F.lift' closure) := by rw [map_lift'_eq2 (monotone_closure Y), map_lift'_eq (monotone_closure X)] congr ext s : 1 exact f_closed.closure_image_eq_of_continuous f_cont s theorem IsClosedMap.mapClusterPt_iff_lift'_closure {F : Filter X} (f_closed : IsClosedMap f) (f_cont : Continuous f) {y : Y} : MapClusterPt y F f ↔ ((F.lift' closure) ⊓ 𝓟 (f ⁻¹' {y})).NeBot := by rw [MapClusterPt, clusterPt_iff_lift'_closure', f_closed.lift'_closure_map_eq f_cont, ← comap_principal, ← map_neBot_iff f, Filter.push_pull, principal_singleton] end IsClosedMap section OpenEmbedding variable [TopologicalSpace X] [TopologicalSpace Y] theorem OpenEmbedding.isOpenMap (hf : OpenEmbedding f) : IsOpenMap f := hf.toEmbedding.toInducing.isOpenMap hf.isOpen_range theorem OpenEmbedding.map_nhds_eq (hf : OpenEmbedding f) (x : X) : map f (𝓝 x) = 𝓝 (f x) := hf.toEmbedding.map_nhds_of_mem _ <| hf.isOpen_range.mem_nhds <| mem_range_self _ theorem OpenEmbedding.open_iff_image_open (hf : OpenEmbedding f) {s : Set X} : IsOpen s ↔ IsOpen (f '' s) := ⟨hf.isOpenMap s, fun h => by convert ← h.preimage hf.toEmbedding.continuous apply preimage_image_eq _ hf.inj⟩ theorem OpenEmbedding.tendsto_nhds_iff [TopologicalSpace Z] {f : ι → Y} {l : Filter ι} {y : Y} (hg : OpenEmbedding g) : Tendsto f l (𝓝 y) ↔ Tendsto (g ∘ f) l (𝓝 (g y)) := hg.toEmbedding.tendsto_nhds_iff theorem OpenEmbedding.tendsto_nhds_iff' (hf : OpenEmbedding f) {l : Filter Z} {x : X} : Tendsto (g ∘ f) (𝓝 x) l ↔ Tendsto g (𝓝 (f x)) l := by rw [Tendsto, ← map_map, hf.map_nhds_eq]; rfl theorem OpenEmbedding.continuousAt_iff [TopologicalSpace Z] (hf : OpenEmbedding f) {x : X} : ContinuousAt (g ∘ f) x ↔ ContinuousAt g (f x) := hf.tendsto_nhds_iff' theorem OpenEmbedding.continuous (hf : OpenEmbedding f) : Continuous f := hf.toEmbedding.continuous theorem OpenEmbedding.open_iff_preimage_open (hf : OpenEmbedding f) {s : Set Y} (hs : s ⊆ range f) : IsOpen s ↔ IsOpen (f ⁻¹' s) := by rw [hf.open_iff_image_open, image_preimage_eq_inter_range, inter_eq_self_of_subset_left hs] theorem openEmbedding_of_embedding_open (h₁ : Embedding f) (h₂ : IsOpenMap f) : OpenEmbedding f := ⟨h₁, h₂.isOpen_range⟩ /-- A surjective embedding is an `OpenEmbedding`. -/ theorem _root_.Embedding.toOpenEmbedding_of_surjective (hf : Embedding f) (hsurj : f.Surjective) : OpenEmbedding f := ⟨hf, hsurj.range_eq ▸ isOpen_univ⟩ theorem openEmbedding_iff_embedding_open : OpenEmbedding f ↔ Embedding f ∧ IsOpenMap f := ⟨fun h => ⟨h.1, h.isOpenMap⟩, fun h => openEmbedding_of_embedding_open h.1 h.2⟩ theorem openEmbedding_of_continuous_injective_open (h₁ : Continuous f) (h₂ : Injective f) (h₃ : IsOpenMap f) : OpenEmbedding f := by simp only [openEmbedding_iff_embedding_open, embedding_iff, inducing_iff_nhds, *, and_true_iff] exact fun x => le_antisymm (h₁.tendsto _).le_comap (@comap_map _ _ (𝓝 x) _ h₂ ▸ comap_mono (h₃.nhds_le _)) theorem openEmbedding_iff_continuous_injective_open : OpenEmbedding f ↔ Continuous f ∧ Injective f ∧ IsOpenMap f := ⟨fun h => ⟨h.continuous, h.inj, h.isOpenMap⟩, fun h => openEmbedding_of_continuous_injective_open h.1 h.2.1 h.2.2⟩ theorem openEmbedding_id : OpenEmbedding (@id X) := ⟨embedding_id, IsOpenMap.id.isOpen_range⟩ namespace OpenEmbedding variable [TopologicalSpace Z] protected theorem comp (hg : OpenEmbedding g) (hf : OpenEmbedding f) : OpenEmbedding (g ∘ f) := ⟨hg.1.comp hf.1, (hg.isOpenMap.comp hf.isOpenMap).isOpen_range⟩ theorem isOpenMap_iff (hg : OpenEmbedding g) : IsOpenMap f ↔ IsOpenMap (g ∘ f) := by simp_rw [isOpenMap_iff_nhds_le, ← map_map, comp, ← hg.map_nhds_eq, Filter.map_le_map_iff hg.inj] theorem of_comp_iff (f : X → Y) (hg : OpenEmbedding g) : OpenEmbedding (g ∘ f) ↔ OpenEmbedding f := by simp only [openEmbedding_iff_continuous_injective_open, ← hg.isOpenMap_iff, ← hg.1.continuous_iff, hg.inj.of_comp_iff] theorem of_comp (f : X → Y) (hg : OpenEmbedding g) (h : OpenEmbedding (g ∘ f)) : OpenEmbedding f := (OpenEmbedding.of_comp_iff f hg).1 h theorem of_isEmpty [IsEmpty X] (f : X → Y) : OpenEmbedding f := openEmbedding_of_embedding_open (.of_subsingleton f) (IsOpenMap.of_isEmpty f) end OpenEmbedding end OpenEmbedding section ClosedEmbedding variable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] namespace ClosedEmbedding theorem tendsto_nhds_iff {g : ι → X} {l : Filter ι} {x : X} (hf : ClosedEmbedding f) : Tendsto g l (𝓝 x) ↔ Tendsto (f ∘ g) l (𝓝 (f x)) := hf.toEmbedding.tendsto_nhds_iff theorem continuous (hf : ClosedEmbedding f) : Continuous f := hf.toEmbedding.continuous theorem isClosedMap (hf : ClosedEmbedding f) : IsClosedMap f := hf.toEmbedding.toInducing.isClosedMap hf.isClosed_range theorem closed_iff_image_closed (hf : ClosedEmbedding f) {s : Set X} : IsClosed s ↔ IsClosed (f '' s) := ⟨hf.isClosedMap s, fun h => by rw [← preimage_image_eq s hf.inj] exact h.preimage hf.continuous⟩ theorem closed_iff_preimage_closed (hf : ClosedEmbedding f) {s : Set Y} (hs : s ⊆ range f) : IsClosed s ↔ IsClosed (f ⁻¹' s) := by rw [hf.closed_iff_image_closed, image_preimage_eq_of_subset hs] theorem _root_.closedEmbedding_of_embedding_closed (h₁ : Embedding f) (h₂ : IsClosedMap f) : ClosedEmbedding f := ⟨h₁, image_univ (f := f) ▸ h₂ univ isClosed_univ⟩ theorem _root_.closedEmbedding_of_continuous_injective_closed (h₁ : Continuous f) (h₂ : Injective f) (h₃ : IsClosedMap f) : ClosedEmbedding f := by refine closedEmbedding_of_embedding_closed ⟨⟨?_⟩, h₂⟩ h₃ refine h₁.le_induced.antisymm fun s hs => ?_ refine ⟨(f '' sᶜ)ᶜ, (h₃ _ hs.isClosed_compl).isOpen_compl, ?_⟩ rw [preimage_compl, preimage_image_eq _ h₂, compl_compl] theorem _root_.closedEmbedding_id : ClosedEmbedding (@id X) := ⟨embedding_id, IsClosedMap.id.isClosed_range⟩ theorem comp (hg : ClosedEmbedding g) (hf : ClosedEmbedding f) : ClosedEmbedding (g ∘ f) := ⟨hg.toEmbedding.comp hf.toEmbedding, (hg.isClosedMap.comp hf.isClosedMap).isClosed_range⟩ theorem of_comp_iff (hg : ClosedEmbedding g) : ClosedEmbedding (g ∘ f) ↔ ClosedEmbedding f := by simp_rw [closedEmbedding_iff, hg.toEmbedding.of_comp_iff, Set.range_comp, ← hg.closed_iff_image_closed] theorem closure_image_eq (hf : ClosedEmbedding f) (s : Set X) : closure (f '' s) = f '' closure s := hf.isClosedMap.closure_image_eq_of_continuous hf.continuous s end ClosedEmbedding end ClosedEmbedding
Topology\Maps\Proper\Basic.lean
/- Copyright (c) 2023 Anatole Dedecker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anatole Dedecker, Etienne Marion -/ import Mathlib.Topology.Homeomorph import Mathlib.Topology.Filter import Mathlib.Topology.Defs.Sequences /-! # Proper maps between topological spaces This file develops the basic theory of proper maps between topological spaces. A map `f : X → Y` between two topological spaces is said to be **proper** if it is continuous and satisfies the following equivalent conditions: 1. `f` is closed and has compact fibers. 2. `f` is **universally closed**, in the sense that for any topological space `Z`, the map `Prod.map f id : X × Z → Y × Z` is closed. 3. For any `ℱ : Filter X`, all cluster points of `map f ℱ` are images by `f` of some cluster point of `ℱ`. We take 3 as the definition in `IsProperMap`, and we show the equivalence with 1, 2, and some other variations. We also show the usual characterization of proper maps to a locally compact Hausdorff space as continuous maps such that preimages of compact sets are compact. ## Main statements * `isProperMap_iff_ultrafilter`: characterization of proper maps in terms of limits of ultrafilters instead of cluster points of filters. * `IsProperMap.pi_map`: any product of proper maps is proper. * `isProperMap_iff_isClosedMap_and_compact_fibers`: a map is proper if and only if it is continuous, closed, and has compact fibers * `isProperMap_iff_isCompact_preimage`: a map to a Hausdorff compactly generated space is proper if and only if it is continuous and preimages of compact sets are compact. This is in particular true if the space is locally compact or sequential. * `isProperMap_iff_universally_closed`: a map is proper if and only if it is continuous and universally closed, in the sense of condition 2. above. ## Implementation notes In algebraic geometry, it is common to also ask that proper maps are *separated*, in the sense of [Stacks: definition OCY1](https://stacks.math.columbia.edu/tag/0CY1). We don't follow this convention because it is unclear whether it would give the right notion in all cases, and in particular for the theory of proper group actions. That means that our terminology does **NOT** align with that of [Stacks: Characterizing proper maps](https://stacks.math.columbia.edu/tag/005M), instead our definition of `IsProperMap` coincides with what they call "Bourbaki-proper". Concerning `isProperMap_iff_isCompact_preimage`, this result should be the only one needed to link the definition of a proper map and the criteria "preimage of compact sets are compact", however the notion of compactly generated space is not yet in Mathlib (TODO) so it is used as an intermediate result to prove `WeaklyLocallyCompactSpace.isProperMap_iff_isCompact_preimage` and `SequentialSpace.isProperMap_iff_isCompact_preimage`. In the future those should be inferred by typeclass inference. Regarding the proofs, we don't really follow Bourbaki and go for more filter-heavy proofs, as usual. In particular, their arguments rely heavily on restriction of closed maps (see `IsClosedMap.restrictPreimage`), which makes them somehow annoying to formalize in type theory. In contrast, the filter-based proofs work really well thanks to the existing API. In fact, the filter proofs work so well that I thought this would be a great pedagogical resource about how we use filters. For that reason, **all interesting proofs in this file are commented**, so don't hesitate to have a look! ## TODO * prove the equivalence with condition 3 of [Stacks: Theorem 005R](https://stacks.math.columbia.edu/tag/005R). Note that they mean something different by "universally closed". ## References * [N. Bourbaki, *General Topology*][bourbaki1966] * [Stacks: Characterizing proper maps](https://stacks.math.columbia.edu/tag/005M) -/ assert_not_exists StoneCech open Filter Topology Function Set open Prod (fst snd) variable {X Y Z W ι : Type*} [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] [TopologicalSpace W] {f : X → Y} {g : Y → Z} universe u v /-- A map `f : X → Y` between two topological spaces is said to be **proper** if it is continuous and, for all `ℱ : Filter X`, any cluster point of `map f ℱ` is the image by `f` of a cluster point of `ℱ`. -/ @[mk_iff isProperMap_iff_clusterPt, fun_prop] structure IsProperMap (f : X → Y) extends Continuous f : Prop where /-- By definition, if `f` is a proper map and `ℱ` is any filter on `X`, then any cluster point of `map f ℱ` is the image by `f` of some cluster point of `ℱ`. -/ clusterPt_of_mapClusterPt : ∀ ⦃ℱ : Filter X⦄, ∀ ⦃y : Y⦄, MapClusterPt y ℱ f → ∃ x, f x = y ∧ ClusterPt x ℱ /-- Definition of proper maps. See also `isClosedMap_iff_clusterPt` for a related criterion for closed maps. -/ add_decl_doc isProperMap_iff_clusterPt /-- By definition, a proper map is continuous. -/ @[fun_prop] lemma IsProperMap.continuous (h : IsProperMap f) : Continuous f := h.toContinuous /-- A proper map is closed. -/ lemma IsProperMap.isClosedMap (h : IsProperMap f) : IsClosedMap f := by rw [isClosedMap_iff_clusterPt] exact fun s y ↦ h.clusterPt_of_mapClusterPt (ℱ := 𝓟 s) (y := y) /-- Characterization of proper maps by ultrafilters. -/ lemma isProperMap_iff_ultrafilter : IsProperMap f ↔ Continuous f ∧ ∀ ⦃𝒰 : Ultrafilter X⦄, ∀ ⦃y : Y⦄, Tendsto f 𝒰 (𝓝 y) → ∃ x, f x = y ∧ 𝒰 ≤ 𝓝 x := by -- This is morally trivial since ultrafilters give all the information about cluster points. rw [isProperMap_iff_clusterPt] refine and_congr_right (fun _ ↦ ?_) constructor <;> intro H · intro 𝒰 y (hY : (Ultrafilter.map f 𝒰 : Filter Y) ≤ _) simp_rw [← Ultrafilter.clusterPt_iff] at hY ⊢ exact H hY · simp_rw [MapClusterPt, ClusterPt, ← Filter.push_pull', map_neBot_iff, ← exists_ultrafilter_iff, forall_exists_index] intro ℱ y 𝒰 hy rcases H (tendsto_iff_comap.mpr <| hy.trans inf_le_left) with ⟨x, hxy, hx⟩ exact ⟨x, hxy, 𝒰, le_inf hx (hy.trans inf_le_right)⟩ lemma isProperMap_iff_ultrafilter_of_t2 [T2Space Y] : IsProperMap f ↔ Continuous f ∧ ∀ ⦃𝒰 : Ultrafilter X⦄, ∀ ⦃y : Y⦄, Tendsto f 𝒰 (𝓝 y) → ∃ x, 𝒰.1 ≤ 𝓝 x := isProperMap_iff_ultrafilter.trans <| and_congr_right fun hc ↦ forall₃_congr fun _𝒰 _y hy ↦ exists_congr fun x ↦ and_iff_right_of_imp fun h ↦ tendsto_nhds_unique ((hc.tendsto x).mono_left h) hy /-- If `f` is proper and converges to `y` along some ultrafilter `𝒰`, then `𝒰` converges to some `x` such that `f x = y`. -/ lemma IsProperMap.ultrafilter_le_nhds_of_tendsto (h : IsProperMap f) ⦃𝒰 : Ultrafilter X⦄ ⦃y : Y⦄ (hy : Tendsto f 𝒰 (𝓝 y)) : ∃ x, f x = y ∧ 𝒰 ≤ 𝓝 x := (isProperMap_iff_ultrafilter.mp h).2 hy /-- The composition of two proper maps is proper. -/ lemma IsProperMap.comp (hf : IsProperMap f) (hg : IsProperMap g) : IsProperMap (g ∘ f) := by refine ⟨by fun_prop, fun ℱ z h ↦ ?_⟩ rw [mapClusterPt_comp] at h rcases hg.clusterPt_of_mapClusterPt h with ⟨y, rfl, hy⟩ rcases hf.clusterPt_of_mapClusterPt hy with ⟨x, rfl, hx⟩ use x, rfl /-- If the composition of two continuous functions `g ∘ f` is proper and `f` is surjective, then `g` is proper. -/ lemma isProperMap_of_comp_of_surj (hf : Continuous f) (hg : Continuous g) (hgf : IsProperMap (g ∘ f)) (f_surj : f.Surjective) : IsProperMap g := by refine ⟨hg, fun ℱ z h ↦ ?_⟩ rw [← ℱ.map_comap_of_surjective f_surj, ← mapClusterPt_comp] at h rcases hgf.clusterPt_of_mapClusterPt h with ⟨x, rfl, hx⟩ rw [← ℱ.map_comap_of_surjective f_surj] exact ⟨f x, rfl, hx.map hf.continuousAt tendsto_map⟩ /-- If the composition of two continuous functions `g ∘ f` is proper and `g` is injective, then `f` is proper. -/ lemma isProperMap_of_comp_of_inj {f : X → Y} {g : Y → Z} (hf : Continuous f) (hg : Continuous g) (hgf : IsProperMap (g ∘ f)) (g_inj : g.Injective) : IsProperMap f := by refine ⟨hf, fun ℱ y h ↦ ?_⟩ rcases hgf.clusterPt_of_mapClusterPt (h.map hg.continuousAt tendsto_map) with ⟨x, hx1, hx2⟩ exact ⟨x, g_inj hx1, hx2⟩ /-- If the composition of two continuous functions `f : X → Y` and `g : Y → Z` is proper and `Y` is T2, then `f` is proper. -/ lemma isProperMap_of_comp_of_t2 [T2Space Y] (hf : Continuous f) (hg : Continuous g) (hgf : IsProperMap (g ∘ f)) : IsProperMap f := by rw [isProperMap_iff_ultrafilter_of_t2] refine ⟨hf, fun 𝒰 y h ↦ ?_⟩ rw [isProperMap_iff_ultrafilter] at hgf rcases hgf.2 ((hg.tendsto y).comp h) with ⟨x, -, hx⟩ exact ⟨x, hx⟩ /-- A binary product of proper maps is proper. -/ lemma IsProperMap.prod_map {g : Z → W} (hf : IsProperMap f) (hg : IsProperMap g) : IsProperMap (Prod.map f g) := by simp_rw [isProperMap_iff_ultrafilter] at hf hg ⊢ constructor -- Continuity is clear. · exact hf.1.prod_map hg.1 -- Let `𝒰 : Ultrafilter (X × Z)`, and assume that `f × g` tends to some `(y, w) : Y × W` -- along `𝒰`. · intro 𝒰 ⟨y, w⟩ hyw -- That means that `f` tends to `y` along `map fst 𝒰` and `g` tends to `w` along `map snd 𝒰`. simp_rw [nhds_prod_eq, tendsto_prod_iff'] at hyw -- Thus, by properness of `f` and `g`, we get some `x : X` and `z : Z` such that `f x = y`, -- `g z = w`, `map fst 𝒰` tends to `x`, and `map snd 𝒰` tends to `y`. rcases hf.2 (show Tendsto f (Ultrafilter.map fst 𝒰) (𝓝 y) by simpa using hyw.1) with ⟨x, hxy, hx⟩ rcases hg.2 (show Tendsto g (Ultrafilter.map snd 𝒰) (𝓝 w) by simpa using hyw.2) with ⟨z, hzw, hz⟩ -- By the properties of the product topology, that means that `𝒰` tends to `(x, z)`, -- which completes the proof since `(f × g)(x, z) = (y, w)`. refine ⟨⟨x, z⟩, Prod.ext hxy hzw, ?_⟩ rw [nhds_prod_eq, le_prod] exact ⟨hx, hz⟩ /-- Any product of proper maps is proper. -/ lemma IsProperMap.pi_map {X Y : ι → Type*} [∀ i, TopologicalSpace (X i)] [∀ i, TopologicalSpace (Y i)] {f : (i : ι) → X i → Y i} (h : ∀ i, IsProperMap (f i)) : IsProperMap (fun (x : ∀ i, X i) i ↦ f i (x i)) := by simp_rw [isProperMap_iff_ultrafilter] at h ⊢ constructor -- Continuity is clear. · exact continuous_pi fun i ↦ (h i).1.comp (continuous_apply i) -- Let `𝒰 : Ultrafilter (Π i, X i)`, and assume that `Π i, f i` tends to some `y : Π i, Y i` -- along `𝒰`. · intro 𝒰 y hy -- That means that each `f i` tends to `y i` along `map (eval i) 𝒰`. have : ∀ i, Tendsto (f i) (Ultrafilter.map (eval i) 𝒰) (𝓝 (y i)) := by simpa [tendsto_pi_nhds] using hy -- Thus, by properness of all the `f i`s, we can choose some `x : Π i, X i` such that, for all -- `i`, `f i (x i) = y i` and `map (eval i) 𝒰` tends to `x i`. choose x hxy hx using fun i ↦ (h i).2 (this i) -- By the properties of the product topology, that means that `𝒰` tends to `x`, -- which completes the proof since `(Π i, f i) x = y`. refine ⟨x, funext hxy, ?_⟩ rwa [nhds_pi, le_pi] /-- The preimage of a compact set by a proper map is again compact. See also `isProperMap_iff_isCompact_preimage` which proves that this property completely characterizes proper map when the codomain is compactly generated and Hausdorff. -/ lemma IsProperMap.isCompact_preimage (h : IsProperMap f) {K : Set Y} (hK : IsCompact K) : IsCompact (f ⁻¹' K) := by rw [isCompact_iff_ultrafilter_le_nhds] -- Let `𝒰 ≤ 𝓟 (f ⁻¹' K)` an ultrafilter. intro 𝒰 h𝒰 -- In other words, we have `map f 𝒰 ≤ 𝓟 K` rw [← comap_principal, ← map_le_iff_le_comap, ← Ultrafilter.coe_map] at h𝒰 -- Thus, by compactness of `K`, the ultrafilter `map f 𝒰` tends to some `y ∈ K`. rcases hK.ultrafilter_le_nhds _ h𝒰 with ⟨y, hyK, hy⟩ -- Then, by properness of `f`, that means that `𝒰` tends to some `x ∈ f ⁻¹' {y} ⊆ f ⁻¹' K`, -- which completes the proof. rcases h.ultrafilter_le_nhds_of_tendsto hy with ⟨x, rfl, hx⟩ exact ⟨x, hyK, hx⟩ /-- A map is proper if and only if it is closed and its fibers are compact. -/ theorem isProperMap_iff_isClosedMap_and_compact_fibers : IsProperMap f ↔ Continuous f ∧ IsClosedMap f ∧ ∀ y, IsCompact (f ⁻¹' {y}) := by constructor <;> intro H -- Note: In Bourbaki, the direct implication is proved by going through universally closed maps. -- We could do the same (using a `TFAE` cycle) but proving it directly from -- `IsProperMap.isCompact_preimage` is nice enough already so we don't bother with that. · exact ⟨H.continuous, H.isClosedMap, fun y ↦ H.isCompact_preimage isCompact_singleton⟩ · rw [isProperMap_iff_clusterPt] -- Let `ℱ : Filter X` and `y` some cluster point of `map f ℱ`. refine ⟨H.1, fun ℱ y hy ↦ ?_⟩ -- That means that the singleton `pure y` meets the "closure" of `map f ℱ`, by which we mean -- `Filter.lift' (map f ℱ) closure`. But `f` is closed, so -- `closure (map f ℱ) = map f (closure ℱ)` (see `IsClosedMap.lift'_closure_map_eq`). -- Thus `map f (closure ℱ ⊓ 𝓟 (f ⁻¹' {y})) = map f (closure ℱ) ⊓ 𝓟 {y} ≠ ⊥`, hence -- `closure ℱ ⊓ 𝓟 (f ⁻¹' {y}) ≠ ⊥`. rw [H.2.1.mapClusterPt_iff_lift'_closure H.1] at hy -- Now, applying the compactness of `f ⁻¹' {y}` to the nontrivial filter -- `closure ℱ ⊓ 𝓟 (f ⁻¹' {y})`, we obtain that it has a cluster point `x ∈ f ⁻¹' {y}`. rcases H.2.2 y (f := Filter.lift' ℱ closure ⊓ 𝓟 (f ⁻¹' {y})) inf_le_right with ⟨x, hxy, hx⟩ refine ⟨x, hxy, ?_⟩ -- In particular `x` is a cluster point of `closure ℱ`. Since cluster points of `closure ℱ` -- are exactly cluster points of `ℱ` (see `clusterPt_lift'_closure_iff`), this completes -- the proof. rw [← clusterPt_lift'_closure_iff] exact hx.mono inf_le_left /-- An injective and continuous function is proper if and only if it is closed. -/ lemma isProperMap_iff_isClosedMap_of_inj (f_cont : Continuous f) (f_inj : f.Injective) : IsProperMap f ↔ IsClosedMap f := by refine ⟨fun h ↦ h.isClosedMap, fun h ↦ ?_⟩ rw [isProperMap_iff_isClosedMap_and_compact_fibers] exact ⟨f_cont, h, fun y ↦ (subsingleton_singleton.preimage f_inj).isCompact⟩ /-- A injective continuous and closed map is proper. -/ lemma isProperMap_of_isClosedMap_of_inj (f_cont : Continuous f) (f_inj : f.Injective) (f_closed : IsClosedMap f) : IsProperMap f := (isProperMap_iff_isClosedMap_of_inj f_cont f_inj).2 f_closed /-- A homeomorphism is proper. -/ @[simp] lemma Homeomorph.isProperMap (e : X ≃ₜ Y) : IsProperMap e := isProperMap_of_isClosedMap_of_inj e.continuous e.injective e.isClosedMap /-- The identity is proper. -/ @[simp] lemma isProperMap_id : IsProperMap (id : X → X) := (Homeomorph.refl X).isProperMap /-- A closed embedding is proper. -/ lemma isProperMap_of_closedEmbedding (hf : ClosedEmbedding f) : IsProperMap f := isProperMap_of_isClosedMap_of_inj hf.continuous hf.inj hf.isClosedMap /-- The coercion from a closed subset is proper. -/ lemma isProperMap_subtype_val_of_closed {U : Set X} (hU : IsClosed U) : IsProperMap ((↑) : U → X) := isProperMap_of_closedEmbedding hU.closedEmbedding_subtype_val /-- The restriction of a proper map to a closed subset is proper. -/ lemma isProperMap_restr_of_proper_of_closed {U : Set X} (hf : IsProperMap f) (hU : IsClosed U) : IsProperMap (fun x : U ↦ f x) := IsProperMap.comp (isProperMap_subtype_val_of_closed hU) hf /-- The range of a proper map is closed. -/ lemma IsProperMap.isClosed_range (hf : IsProperMap f) : IsClosed (range f) := hf.isClosedMap.isClosed_range @[deprecated (since := "2024-05-08")] alias IsProperMap.closed_range := IsProperMap.isClosed_range /-- Version of `isProperMap_iff_isClosedMap_and_compact_fibers` in terms of `cofinite` and `cocompact`. Only works when the codomain is `T1`. -/ lemma isProperMap_iff_isClosedMap_and_tendsto_cofinite [T1Space Y] : IsProperMap f ↔ Continuous f ∧ IsClosedMap f ∧ Tendsto f (cocompact X) cofinite := by simp_rw [isProperMap_iff_isClosedMap_and_compact_fibers, Tendsto, le_cofinite_iff_compl_singleton_mem, mem_map, preimage_compl] refine and_congr_right fun f_cont ↦ and_congr_right fun _ ↦ ⟨fun H y ↦ (H y).compl_mem_cocompact, fun H y ↦ ?_⟩ rcases mem_cocompact.mp (H y) with ⟨K, hK, hKy⟩ exact hK.of_isClosed_subset (isClosed_singleton.preimage f_cont) (compl_le_compl_iff_le.mp hKy) /-- A continuous map from a compact space to a T₂ space is a proper map. -/ theorem Continuous.isProperMap [CompactSpace X] [T2Space Y] (hf : Continuous f) : IsProperMap f := isProperMap_iff_isClosedMap_and_tendsto_cofinite.2 ⟨hf, hf.isClosedMap, by simp⟩ /-- If `Y` is Hausdorff and compactly generated, then proper maps `X → Y` are exactly continuous maps such that the preimage of any compact set is compact. This result should be the only one needed to link the definition of a proper map and the criteria "preimage of compact sets are compact", but the notion of compactly generated space is not yet in Mathlib (TODO) so we use it as an intermediate result to prove `WeaklyLocallyCompactSpace.isProperMap_iff_isCompact_preimage` and `SequentialSpace.isProperMap_iff_isCompact_preimage`. In the future those should be inferred by typeclass inference. -/ theorem isProperMap_iff_isCompact_preimage [T2Space Y] (compactlyGenerated : ∀ s : Set Y, IsClosed s ↔ ∀ ⦃K⦄, IsCompact K → IsClosed (s ∩ K)) : IsProperMap f ↔ Continuous f ∧ ∀ ⦃K⦄, IsCompact K → IsCompact (f ⁻¹' K) where mp hf := ⟨hf.continuous, fun _ ↦ hf.isCompact_preimage⟩ mpr := fun ⟨hf, h⟩ ↦ isProperMap_iff_isClosedMap_and_compact_fibers.2 ⟨hf, fun _ hs ↦ (compactlyGenerated _).2 fun _ hK ↦ image_inter_preimage .. ▸ (((h hK).inter_left hs).image hf).isClosed, fun _ ↦ h isCompact_singleton⟩ /-- A locally compact space is compactly generated. -/ theorem compactlyGenerated_of_weaklyLocallyCompactSpace [T2Space X] [WeaklyLocallyCompactSpace X] {s : Set X} : IsClosed s ↔ ∀ ⦃K⦄, IsCompact K → IsClosed (s ∩ K) := by refine ⟨fun hs K hK ↦ hs.inter hK.isClosed, fun h ↦ ?_⟩ rw [isClosed_iff_forall_filter] intro x ℱ hℱ₁ hℱ₂ hℱ₃ rcases exists_compact_mem_nhds x with ⟨K, hK, K_mem⟩ exact mem_of_mem_inter_left <| isClosed_iff_forall_filter.1 (h hK) x ℱ hℱ₁ (inf_principal ▸ le_inf hℱ₂ (le_trans hℱ₃ <| le_principal_iff.2 K_mem)) hℱ₃ /-- If `Y` is locally compact and Hausdorff, then proper maps `X → Y` are exactly continuous maps such that the preimage of any compact set is compact. This result is a direct consequence of `isProperMap_iff_isCompact_preimage`, because any Hausdorff and weakly locally compact space is compactly generated. In the future it should be inferred by typeclass inference, however compactly generated spaces are not yet in Mathlib (TODO), therefore we also add this theorem. -/ theorem WeaklyLocallyCompactSpace.isProperMap_iff_isCompact_preimage [T2Space Y] [WeaklyLocallyCompactSpace Y] : IsProperMap f ↔ Continuous f ∧ ∀ ⦃K⦄, IsCompact K → IsCompact (f ⁻¹' K) := _root_.isProperMap_iff_isCompact_preimage (fun _ ↦ compactlyGenerated_of_weaklyLocallyCompactSpace) /-- A sequential space is compactly generated. -/ theorem compactlyGenerated_of_sequentialSpace [T2Space X] [SequentialSpace X] {s : Set X} : IsClosed s ↔ ∀ ⦃K⦄, IsCompact K → IsClosed (s ∩ K) := by refine ⟨fun hs K hK ↦ hs.inter hK.isClosed, fun h ↦ SequentialSpace.isClosed_of_seq _ fun u p hu hup ↦ mem_of_mem_inter_left ((h hup.isCompact_insert_range).mem_of_tendsto hup ?_)⟩ simp only [mem_inter_iff, mem_insert_iff, mem_range, exists_apply_eq_apply, or_true, and_true, eventually_atTop, ge_iff_le] exact ⟨0, fun n _ ↦ hu n⟩ /-- If `Y` is sequential and Hausdorff, then proper maps `X → Y` are exactly continuous maps such that the preimage of any compact set is compact. This result is a direct consequence of `isProperMap_iff_isCompact_preimage`, because any Hausdorff and sequential space is compactly generated. In the future it should be inferred by typeclass inference, however compactly generated spaces are not yet in Mathlib (TODO), therefore we also add this theorem. -/ theorem SequentialSpace.isProperMap_iff_isCompact_preimage [T2Space Y] [SequentialSpace Y] : IsProperMap f ↔ Continuous f ∧ ∀ ⦃K⦄, IsCompact K → IsCompact (f ⁻¹' K) := _root_.isProperMap_iff_isCompact_preimage (fun _ ↦ compactlyGenerated_of_sequentialSpace) /-- Version of `isProperMap_iff_isCompact_preimage` in terms of `cocompact`. -/ lemma isProperMap_iff_tendsto_cocompact [T2Space Y] (compactlyGenerated : ∀ s : Set Y, IsClosed s ↔ ∀ ⦃K⦄, IsCompact K → IsClosed (s ∩ K)) : IsProperMap f ↔ Continuous f ∧ Tendsto f (cocompact X) (cocompact Y) := by simp_rw [isProperMap_iff_isCompact_preimage compactlyGenerated, hasBasis_cocompact.tendsto_right_iff, ← mem_preimage, eventually_mem_set, preimage_compl] refine and_congr_right fun f_cont ↦ ⟨fun H K hK ↦ (H hK).compl_mem_cocompact, fun H K hK ↦ ?_⟩ rcases mem_cocompact.mp (H K hK) with ⟨K', hK', hK'y⟩ exact hK'.of_isClosed_subset (hK.isClosed.preimage f_cont) (compl_le_compl_iff_le.mp hK'y) /-- Version of `WeaklyLocallyCompactSpace.isProperMap_iff_isCompact_preimage` in terms of `cocompact`. -/ lemma WeaklyLocallyCompactSpace.isProperMap_iff_tendsto_cocompact [T2Space Y] [WeaklyLocallyCompactSpace Y] : IsProperMap f ↔ Continuous f ∧ Tendsto f (cocompact X) (cocompact Y) := _root_.isProperMap_iff_tendsto_cocompact (fun _ ↦ compactlyGenerated_of_weaklyLocallyCompactSpace) /-- Version of `SequentialSpace.isProperMap_iff_isCompact_preimage` in terms of `cocompact`. -/ lemma SequentialSpace.isProperMap_iff_tendsto_cocompact [T2Space Y] [SequentialSpace Y] : IsProperMap f ↔ Continuous f ∧ Tendsto f (cocompact X) (cocompact Y) := _root_.isProperMap_iff_tendsto_cocompact (fun _ ↦ compactlyGenerated_of_sequentialSpace) /-- A proper map `f : X → Y` is **universally closed**: for any topological space `Z`, the map `Prod.map f id : X × Z → Y × Z` is closed. We will prove in `isProperMap_iff_universally_closed` that proper maps are exactly continuous maps which have this property, but this result should be easier to use because it allows `Z` to live in any universe. -/ theorem IsProperMap.universally_closed (Z) [TopologicalSpace Z] (h : IsProperMap f) : IsClosedMap (Prod.map f id : X × Z → Y × Z) := -- `f × id` is proper as a product of proper maps, hence closed. (h.prod_map isProperMap_id).isClosedMap /-- A map `f : X → Y` is proper if and only if it is continuous and the map `(Prod.map f id : X × Filter X → Y × Filter X)` is closed. This is stronger than `isProperMap_iff_universally_closed` since it shows that there's only one space to check to get properness, but in most cases it doesn't matter. -/ theorem isProperMap_iff_isClosedMap_filter {X : Type u} {Y : Type v} [TopologicalSpace X] [TopologicalSpace Y] {f : X → Y} : IsProperMap f ↔ Continuous f ∧ IsClosedMap (Prod.map f id : X × Filter X → Y × Filter X) := by constructor <;> intro H -- The direct implication is clear. · exact ⟨H.continuous, H.universally_closed _⟩ · rw [isProperMap_iff_ultrafilter] -- Let `𝒰 : Ultrafilter X`, and assume that `f` tends to some `y` along `𝒰`. refine ⟨H.1, fun 𝒰 y hy ↦ ?_⟩ -- In `X × Filter X`, consider the closed set `F := closure {(x, ℱ) | ℱ = pure x}` let F : Set (X × Filter X) := closure {xℱ | xℱ.2 = pure xℱ.1} -- Since `f × id` is closed, the set `(f × id) '' F` is also closed. have := H.2 F isClosed_closure -- Let us show that `(y, 𝒰) ∈ (f × id) '' F`. have : (y, ↑𝒰) ∈ Prod.map f id '' F := -- Note that, by the properties of the topology on `Filter X`, the function `pure : X → Filter X` -- tends to the point `𝒰` of `Filter X` along the filter `𝒰` on `X`. Since `f` tends to `y` along -- `𝒰`, we get that the function `(f, pure) : X → (Y, Filter X)` tends to `(y, 𝒰)` along -- `𝒰`. Furthermore, each `(f, pure)(x) = (f × id)(x, pure x)` is clearly an element of -- the closed set `(f × id) '' F`, thus the limit `(y, 𝒰)` also belongs to that set. this.mem_of_tendsto (hy.prod_mk_nhds (Filter.tendsto_pure_self (𝒰 : Filter X))) (eventually_of_forall fun x ↦ ⟨⟨x, pure x⟩, subset_closure rfl, rfl⟩) -- The above shows that `(y, 𝒰) = (f x, 𝒰)`, for some `x : X` such that `(x, 𝒰) ∈ F`. rcases this with ⟨⟨x, _⟩, hx, ⟨_, _⟩⟩ -- We already know that `f x = y`, so to finish the proof we just have to check that `𝒰` tends -- to `x`. So, for `U ∈ 𝓝 x` arbitrary, let's show that `U ∈ 𝒰`. Since `𝒰` is a ultrafilter, -- it is enough to show that `Uᶜ` is not in `𝒰`. refine ⟨x, rfl, fun U hU ↦ Ultrafilter.compl_not_mem_iff.mp fun hUc ↦ ?_⟩ rw [mem_closure_iff_nhds] at hx -- Indeed, if that was the case, the set `V := {𝒢 : Filter X | Uᶜ ∈ 𝒢}` would be a neighborhood -- of `𝒰` in `Filter X`, hence `U ×ˢ V` would be a neighborhood of `(x, 𝒰) : X × Filter X`. -- But recall that `(x, 𝒰) ∈ F = closure {(x, ℱ) | ℱ = pure x}`, so the neighborhood `U ×ˢ V` -- must contain some element of the form `(z, pure z)`. In other words, we have `z ∈ U` and -- `Uᶜ ∈ pure z`, which means `z ∈ Uᶜ` by the definition of pure. -- This is a contradiction, which completes the proof. rcases hx (U ×ˢ {𝒢 | Uᶜ ∈ 𝒢}) (prod_mem_nhds hU (isOpen_setOf_mem.mem_nhds hUc)) with ⟨⟨z, 𝒢⟩, ⟨⟨hz : z ∈ U, hz' : Uᶜ ∈ 𝒢⟩, rfl : 𝒢 = pure z⟩⟩ exact hz' hz
Topology\Maps\Proper\UniversallyClosed.lean
/- Copyright (c) 2023 Anatole Dedecker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anatole Dedecker, Etienne Marion -/ import Mathlib.Topology.Maps.Proper.Basic import Mathlib.Topology.StoneCech /-! # A map is proper iff it is continuous and universally closed -/ open Filter universe u v /-- A map `f : X → Y` is proper if and only if it is continuous and the map `(Prod.map f id : X × Ultrafilter X → Y × Ultrafilter X)` is closed. This is stronger than `isProperMap_iff_universally_closed` since it shows that there's only one space to check to get properness, but in most cases it doesn't matter. -/ theorem isProperMap_iff_isClosedMap_ultrafilter {X : Type u} {Y : Type v} [TopologicalSpace X] [TopologicalSpace Y] {f : X → Y} : IsProperMap f ↔ Continuous f ∧ IsClosedMap (Prod.map f id : X × Ultrafilter X → Y × Ultrafilter X) := by -- The proof is basically the same as above. constructor <;> intro H · exact ⟨H.continuous, H.universally_closed _⟩ · rw [isProperMap_iff_ultrafilter] refine ⟨H.1, fun 𝒰 y hy ↦ ?_⟩ let F : Set (X × Ultrafilter X) := closure {xℱ | xℱ.2 = pure xℱ.1} have := H.2 F isClosed_closure have : (y, 𝒰) ∈ Prod.map f id '' F := this.mem_of_tendsto (hy.prod_mk_nhds (Ultrafilter.tendsto_pure_self 𝒰)) (eventually_of_forall fun x ↦ ⟨⟨x, pure x⟩, subset_closure rfl, rfl⟩) rcases this with ⟨⟨x, _⟩, hx, ⟨_, _⟩⟩ refine ⟨x, rfl, fun U hU ↦ Ultrafilter.compl_not_mem_iff.mp fun hUc ↦ ?_⟩ rw [mem_closure_iff_nhds] at hx rcases hx (U ×ˢ {𝒢 | Uᶜ ∈ 𝒢}) (prod_mem_nhds hU ((ultrafilter_isOpen_basic _).mem_nhds hUc)) with ⟨⟨y, 𝒢⟩, ⟨⟨hy : y ∈ U, hy' : Uᶜ ∈ 𝒢⟩, rfl : 𝒢 = pure y⟩⟩ exact hy' hy /-- A map `f : X → Y` is proper if and only if it is continuous and **universally closed**, in the sense that for any topological space `Z`, the map `Prod.map f id : X × Z → Y × Z` is closed. Note that `Z` lives in the same universe as `X` here, but `IsProperMap.universally_closed` does not have this restriction. This is taken as the definition of properness in [N. Bourbaki, *General Topology*][bourbaki1966]. -/ theorem isProperMap_iff_universally_closed {X : Type u} {Y : Type v} [TopologicalSpace X] [TopologicalSpace Y] {f : X → Y} : IsProperMap f ↔ Continuous f ∧ ∀ (Z : Type u) [TopologicalSpace Z], IsClosedMap (Prod.map f id : X × Z → Y × Z) := by constructor <;> intro H · exact ⟨H.continuous, fun Z ↦ H.universally_closed _⟩ · rw [isProperMap_iff_isClosedMap_ultrafilter] exact ⟨H.1, H.2 _⟩