Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Lean/Mathlib/Mathlib/Analysis/LocallyConvex/     Datei vom 15.10.2026 mit Größe 59 kB image not shown  

SSL WithSeminorms.lean   Sprache: Lean

 

/-
Copyright (c) 2022 Moritz Doll. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Moritz Doll, Anatole Dedecker
-/

module

public import Mathlib.Analysis.LocallyConvex.Bounded
public import Mathlib.Analysis.Real.Sqrt
public import Mathlib.Topology.Algebra.Equicontinuity
public import Mathlib.Topology.Algebra.FilterBasis
public import Mathlib.Topology.Algebra.Module.LocallyConvex
public import Mathlib.Topology.MetricSpace.Equicontinuity

import Mathlib.Topology.Algebra.Module.Equiv.Basic

/-!
# Topology induced by a family of seminorms

## Main definitions

* `SeminormFamily.basisSets`: The set of open seminorm balls for a family of seminorms.
* `SeminormFamily.moduleFilterBasis`: A module filter basis formed by the open balls.
* `Seminorm.IsBounded`: A linear map `f : E →ₗ[��] F` is bounded iff every seminorm in `F` can be
  bounded by a finite number of seminorms in `E`.
* `WithSeminorms p`, when `p` is a family of seminorms on `E`, is a proposition expressing that the
  (existing) topology on `E` is induced by the seminorms `p`.
* `IsNormableSpace �� E` is a class asserting that the (existing) topology on `E` is induced
  by *some* `��`-seminorm
* `PolynormableSpace �� E` is a class asserting that the (existing) topology on `E` is induced
  by *some* family of `��`-seminorms. If `��` is `RCLike`, this is equivalent to
  `LocallyConvexSpace �� E`.
  The terminology is inspired by N. Bourbaki, *Variétés différentielles et analytiques*. However,
  unlike Bourbaki, we do not ask seminorms to be ultrametric when `��` is ultrametric.

## Main statements

* `WithSeminorms.toLocallyConvexSpace`: A space equipped with a family of seminorms is locally
  convex.
* `WithSeminorms.firstCountable`: A space is first countable if its topology is induced by a
  countable family of seminorms.

## Continuity of semilinear maps

If `E` and `F` are topological vector space with the topology induced by a family of seminorms, then
we have a direct method to prove that a linear map is continuous:
* `Seminorm.continuous_from_bounded`: A bounded linear map `f : E →ₗ[��] F` is continuous.

If the topology of a space `E` is induced by a family of seminorms, then we can characterize von
Neumann boundedness in terms of that seminorm family. Together with
`LinearMap.continuous_of_locally_bounded` this gives general criterion for continuity.

* `WithSeminorms.isVonNBounded_iff_finset_seminorm_bounded`
* `WithSeminorms.isVonNBounded_iff_seminorm_bounded`
* `WithSeminorms.image_isVonNBounded_iff_finset_seminorm_bounded`
* `WithSeminorms.image_isVonNBounded_iff_seminorm_bounded`

## Tags

seminorm, locally convex
-/


open scoped Finset

@[expose] public section

open NormedField Set Seminorm TopologicalSpace Filter List Bornology

open NNReal Pointwise Topology Uniformity

variable {R �� ��₂ �� ��₂ E F G ι ι' : Type*}

section FilterBasis

variable [SeminormedRing R] [AddCommGroup E] [Module R E]
variable (R E ι)

/-- An abbreviation for indexed families of seminorms. This is mainly to allow for dot-notation. -/
abbrev SeminormFamily :=
  ι → Seminorm R E

variable {R E ι}

namespace SeminormFamily

/-- The sets of a filter basis for the neighborhood filter of 0. -/
def basisSets (p : SeminormFamily R E ι) : Set (Set E) :=
  ⋃ (s : Finset ι) (r) (_ : 0 < r), singleton (ball (s.sup p) (0 : E) r)

variable (p : SeminormFamily R E ι)

theorem basisSets_iff {U : Set E} :
    U ∈ p.basisSets ↔ ∃ (i : Finset ι) (r : ℝ), 0 < r ∧ U = ball (i.sup p) 0 r := by
  simp only [basisSets, mem_iUnion, exists_prop, mem_singleton_iff]

theorem basisSets_mem (i : Finset ι) {r : ℝ} (hr : 0 < r) : (i.sup p).ball 0 r ∈ p.basisSets :=
  (basisSets_iff _).mpr ⟨i, _, hr, rfl⟩

theorem basisSets_singleton_mem (i : ι) {r : ℝ} (hr : 0 < r) : (p i).ball 0 r ∈ p.basisSets :=
  (basisSets_iff _).mpr ⟨{i}, _, hr, by rw [Finset.sup_singleton]⟩

theorem basisSets_univ_mem : univ ∈ p.basisSets :=
  (basisSets_iff _).mpr ⟨∅, _, one_pos, by
    rw [Finset.sup_empty, Seminorm.bot_eq_zero, ball_zero' _ one_pos]⟩

theorem basisSets_nonempty : p.basisSets.Nonempty := by
  refine nonempty_def.mpr ⟨univ, basisSets_univ_mem _⟩

theorem basisSets_intersect (U V : Set E) (hU : U ∈ p.basisSets) (hV : V ∈ p.basisSets) :
    ∃ z ∈ p.basisSets, z ⊆ U ∩ V := by
  classical
    rcases p.basisSets_iff.mp hU with ⟨s, r₁, hr₁, hU⟩
    rcases p.basisSets_iff.mp hV with ⟨t, r₂, hr₂, hV⟩
    use ((s ∪ t).sup p).ball 0 (min r₁ r₂)
    refine ⟨p.basisSets_mem (s ∪ t) (lt_min_iff.mpr ⟨hr₁, hr₂⟩), ?_⟩
    rw [hU, hV, ball_finset_sup_eq_iInter _ _ _ (lt_min_iff.mpr ⟨hr₁, hr₂⟩),
      ball_finset_sup_eq_iInter _ _ _ hr₁, ball_finset_sup_eq_iInter _ _ _ hr₂]
    exact
      Set.subset_inter
        (Set.iInter₂_mono' fun i hi =>
          ⟨i, Finset.subset_union_left hi, ball_mono <| min_le_left _ _⟩)
        (Set.iInter₂_mono' fun i hi =>
          ⟨i, Finset.subset_union_right hi, ball_mono <| min_le_right _ _⟩)

theorem basisSets_zero (U) (hU : U ∈ p.basisSets) : (0 : E) ∈ U := by
  rcases p.basisSets_iff.mp hU with ⟨ι', r, hr, hU⟩
  rw [hU, mem_ball_zero, map_zero]
  exact hr

theorem basisSets_add (U) (hU : U ∈ p.basisSets) :
    ∃ V ∈ p.basisSets, V + V ⊆ U := by
  rcases p.basisSets_iff.mp hU with ⟨s, r, hr, hU⟩
  use (s.sup p).ball 0 (r / 2)
  refine ⟨p.basisSets_mem s (div_pos hr zero_lt_two), ?_⟩
  refine Set.Subset.trans (ball_add_ball_subset (s.sup p) (r / 2) (r / 2) 0 0) ?_
  rw [hU, add_zero, add_halves]

theorem basisSets_neg (U) (hU' : U ∈ p.basisSets) :
    ∃ V ∈ p.basisSets, V ⊆ (fun x : E => -x) ⁻¹' U := by
  rcases p.basisSets_iff.mp hU' with ⟨s, r, _, hU⟩
  rw [hU, neg_preimage, neg_ball (s.sup p), neg_zero]
  exact ⟨U, hU', Eq.subset hU⟩

/-- The `addGroupFilterBasis` induced by the filter basis `Seminorm.basisSets`. -/
@[instance_reducible]
protected def addGroupFilterBasis : AddGroupFilterBasis E :=
  addGroupFilterBasisOfComm p.basisSets p.basisSets_nonempty p.basisSets_intersect p.basisSets_zero
    p.basisSets_add p.basisSets_neg

theorem basisSets_smul_right (v : E) (U : Set E) (hU : U ∈ p.basisSets) :
    ∀ᶠ x : R in �� 0, x • v ∈ U := by
  rcases p.basisSets_iff.mp hU with ⟨s, r, hr, hU⟩
  rw [hU, Filter.eventually_iff]
  simp_rw [(s.sup p).mem_ball_zero, map_smul_eq_mul]
  by_cases! h : 0 < (s.sup p) v
  · simp_rw [(lt_div_iff₀ h).symm]
    rw [← _root_.ball_zero_eq]
    exact Metric.ball_mem_nhds 0 (div_pos hr h)
  simp_rw [le_antisymm h (apply_nonneg _ v), mul_zero, hr]
  exact IsOpen.mem_nhds isOpen_univ (mem_univ 0)

theorem basisSets_smul (U) (hU : U ∈ p.basisSets) :
    ∃ V ∈ �� (0 : R), ∃ W ∈ p.addGroupFilterBasis.sets, V • W ⊆ U := by
  rcases p.basisSets_iff.mp hU with ⟨s, r, hr, hU⟩
  refine ⟨Metric.ball 0 √r, Metric.ball_mem_nhds 0 (Real.sqrt_pos.mpr hr), ?_⟩
  refine ⟨(s.sup p).ball 0 √r, p.basisSets_mem s (Real.sqrt_pos.mpr hr), ?_⟩
  refine Set.Subset.trans (ball_smul_ball (s.sup p) √r √r) ?_
  rw [hU, Real.mul_self_sqrt (le_of_lt hr)]

variable [NormedDivisionRing ��] [AddCommGroup F] [Module �� F] (p : SeminormFamily �� F ι)

theorem basisSets_smul_left (x : ��) (U : Set F) (hU : U ∈ p.basisSets) :
    ∃ V ∈ p.addGroupFilterBasis.sets, V ⊆ (fun y : F => x • y) ⁻¹' U := by
  rcases p.basisSets_iff.mp hU with ⟨s, r, hr, hU⟩
  rw [hU]
  by_cases h : x ≠ 0
  · rw [(s.sup p).smul_ball_preimage 0 r x h, smul_zero]
    use (s.sup p).ball 0 (r / ‖x‖)
    exact ⟨p.basisSets_mem s (div_pos hr (norm_pos_iff.mpr h)), Subset.rfl⟩
  refine ⟨(s.sup p).ball 0 r, p.basisSets_mem s hr, ?_⟩
  simp only [not_ne_iff.mp h, Set.subset_def, mem_ball_zero, hr, mem_univ, map_zero, imp_true_iff,
    preimage_const_of_mem, zero_smul]

/-- The `moduleFilterBasis` induced by the filter basis `Seminorm.basisSets`. -/
protected def moduleFilterBasis : ModuleFilterBasis �� F where
  toAddGroupFilterBasis := p.addGroupFilterBasis
  smul' := p.basisSets_smul _
  smul_left' := p.basisSets_smul_left
  smul_right' := p.basisSets_smul_right

theorem filter_eq_iInf (p : SeminormFamily �� F ι) :
    p.moduleFilterBasis.toFilterBasis.filter = ⨅ i, (�� 0).comap (p i) := by
  refine le_antisymm (le_iInf fun i => ?_) ?_
  · rw [p.moduleFilterBasis.toFilterBasis.hasBasis.le_basis_iff
        (Metric.nhds_basis_ball.comap _)]
    intro ε hε
    refine ⟨(p i).ball 0 ε, ?_, ?_⟩
    · rw [← (Finset.sup_singleton : _ = p i)]
      exact p.basisSets_mem {i} hε
    · rw [id, (p i).ball_zero_eq_preimage_ball]
  · rw [p.moduleFilterBasis.toFilterBasis.hasBasis.ge_iff]
    rintro U (hU : U ∈ p.basisSets)
    rcases p.basisSets_iff.mp hU with ⟨s, r, hr, rfl⟩
    rw [id, Seminorm.ball_finset_sup_eq_iInter _ _ _ hr, s.iInter_mem_sets]
    exact fun i _ =>
      Filter.mem_iInf_of_mem i
        ⟨Metric.ball 0 r, Metric.ball_mem_nhds 0 hr,
          Eq.subset (p i).ball_zero_eq_preimage_ball.symm⟩

/-- If a family of seminorms is continuous, then their basis sets are neighborhoods of zero. -/
lemma basisSets_mem_nhds {�� E ι : Type*} [NormedField ��]
    [AddCommGroup E] [Module �� E] [TopologicalSpace E] (p : SeminormFamily �� E ι)
    (hp : ∀ i, Continuous (p i)) (U : Set E) (hU : U ∈ p.basisSets) : U ∈ �� (0 : E) := by
  obtain ⟨s, r, hr, rfl⟩ := p.basisSets_iff.mp hU
  clear hU
  refine Seminorm.ball_mem_nhds ?_ hr
  classical
  induction s using Finset.induction_on with
  | empty => simpa using continuous_zero
  | insert a s _ hs =>
    simp only [Finset.sup_insert, coe_sup]
    exact Continuous.max (hp a) hs

end SeminormFamily

end FilterBasis

section Bounded

namespace Seminorm

variable [SeminormedRing ��] [AddCommGroup E] [Module �� E]
variable [SeminormedRing ��₂] [AddCommGroup F] [Module ��₂ F]
variable {σ₁₂ : �� →+* ��₂} [RingHomIsometric σ₁₂]

/-- The proposition that a linear map is bounded between spaces with families of seminorms. -/
def IsBounded (p : ι → Seminorm �� E) (q : ι' → Seminorm ��₂ F) (f : E →ₛₗ[σ₁₂] F) : Prop :=
  ∀ i, ∃ s : Finset ι, ∃ C : ℝ≥0, (q i).comp f ≤ C • s.sup p

theorem IsBounded.of_real {p : ι → Seminorm �� E} {q : ι' → Seminorm ��₂ F} {f : E →ₛₗ[σ₁₂] F}
    (H : ∀ i, ∃ s : Finset ι, ∃ C : ℝ, ∀ x, q i (f x) ≤ C * (s.sup p) x) :
    IsBounded p q f := by
  rw [IsBounded]
  gconvert H with i s H
  obtain ⟨C, hC⟩ := H
  refine ⟨C.toNNReal, fun x ↦ show q i (f x) ≤ C.toNNReal • ((s.sup p) x) from ?_⟩
  exact (hC x).trans <| mul_le_mul_of_nonneg_right C.le_coe_toNNReal (apply_nonneg _ _)

theorem isBounded_const (ι' : Type*) [Nonempty ι'] {p : ι → Seminorm �� E} {q : Seminorm ��₂ F}
    (f : E →ₛₗ[σ₁₂] F) :
    IsBounded p (fun _ : ι' => q) f ↔ ∃ (s : Finset ι) (C : ℝ≥0), q.comp f ≤ C • s.sup p := by
  simp only [IsBounded, forall_const]

theorem const_isBounded (ι : Type*) [Nonempty ι] {p : Seminorm �� E} {q : ι' → Seminorm ��₂ F}
    (f : E →ₛₗ[σ₁₂] F) : IsBounded (fun _ : ι => p) q f ↔ ∀ i, ∃ C : ℝ≥0, (q i).comp f ≤ C • p := by
  constructor <;> intro h i
  · rcases h i with ⟨s, C, h⟩
    exact ⟨C, h.trans (IsOrderedSMul.smul_le_smul_left _ p (Finset.sup_le fun _ _ ↦ le_rfl) C)⟩
  · use {Classical.arbitrary ι}
    simp only [h, Finset.sup_singleton]

theorem isBounded_sup {p : ι → Seminorm �� E} {q : ι' → Seminorm ��₂ F} {f : E →ₛₗ[σ₁₂] F}
    (hf : IsBounded p q f) (s' : Finset ι') :
    ∃ (C : ℝ≥0) (s : Finset ι), (s'.sup q).comp f ≤ C • s.sup p := by
  classical
  obtain rfl | _ := s'.eq_empty_or_nonempty
  · exact ⟨1, ∅, by simp [Seminorm.bot_eq_zero]⟩
  choose fₛ fC hf using hf
  use #s' • s'.sup fC, Finset.biUnion s' fₛ
  have hs : ∀ i : ι', i ∈ s' → (q i).comp f ≤ s'.sup fC • (Finset.biUnion s' fₛ).sup p := by
    intro i hi
    refine (hf i).trans (IsOrderedSMul.smul_le_smul (Finset.le_sup hi) ?_)
    exact Finset.sup_mono (Finset.subset_biUnion_of_mem fₛ hi)
  refine (comp_mono f (finset_sup_le_sum q s')).trans ?_
  simp_rw [← pullback_apply, map_sum, pullback_apply]
  refine (Finset.sum_le_sum hs).trans ?_
  rw [Finset.sum_const, smul_assoc]

end Seminorm

end Bounded

section Topology

variable [NormedField ��] [AddCommGroup E] [Module �� E]

/-- The proposition that the topology of `E` is induced by a family of seminorms `p`. -/
structure WithSeminorms (p : SeminormFamily �� E ι) [topology : TopologicalSpace E] : Prop where
  topology_eq_withSeminorms : topology = p.moduleFilterBasis.topology

variable (�� E) in
/-- A topological vector space `E` is **normable** over `��` if its topology is induced by
*some* `��`-seminorm. Note that this does not imply that the space is Hausdorff.
To endow such a space with a normed space structure with the same topology, use:
```
  let : SeminormedAddCommGroup E := IsNormableSpace.toSeminormedAddCommGroup �� E
  let : NormedSpace �� E := IsNormableSpace.toNormedSpace �� E
```
-/

class IsNormableSpace [topology : TopologicalSpace E] where
  withSeminorms' : ∃ (p : Seminorm �� E), WithSeminorms (fun (_ : Unit) ↦ p)

variable (�� E) in
/-- A topological vector space `E` is **polynormable** over `��` if its topology is induced by
*some* family of `��`-seminorms. Equivalently, its topology is induced by *all* its continuous
seminorm.

If `��` is `RCLike`, this is equivalent to `LocallyConvexSpace �� E`. -/

class PolynormableSpace [topology : TopologicalSpace E] where
  withSeminorms' : WithSeminorms (fun p : {p : Seminorm �� E // Continuous p} ↦ p.1)

theorem WithSeminorms.withSeminorms_eq {p : SeminormFamily �� E ι} [t : TopologicalSpace E]
    (hp : WithSeminorms p) : t = p.moduleFilterBasis.topology :=
  hp.1

variable [TopologicalSpace E]
variable {p : SeminormFamily �� E ι}

variable (�� E) in
theorem PolynormableSpace.withSeminorms [PolynormableSpace �� E] :
    WithSeminorms (fun p : {p : Seminorm �� E // Continuous p} ↦ p.1) :=
  PolynormableSpace.withSeminorms'

theorem WithSeminorms.isTopologicalAddGroup (hp : WithSeminorms p) : IsTopologicalAddGroup E := by
  rw [hp.withSeminorms_eq]
  exact AddGroupFilterBasis.isTopologicalAddGroup _

@[deprecated (since := "2026-08-21")]
alias WithSeminorms.topologicalAddGroup := WithSeminorms.isTopologicalAddGroup

variable (�� E) in
/-- A polynormable space is a topological additive group.

This cannot be an instance, because `��` can't be inferred. -/

theorem PolynormableSpace.isTopologicalAddGroup [PolynormableSpace �� E] :
    IsTopologicalAddGroup E :=
  PolynormableSpace.withSeminorms �� E |>.isTopologicalAddGroup

theorem WithSeminorms.continuousSMul (hp : WithSeminorms p) : ContinuousSMul �� E := by
  rw [hp.withSeminorms_eq]
  exact ModuleFilterBasis.continuousSMul _

variable (�� E) in
/-- A polynormable space has continuous scalar multiplication. -/
instance PolynormableSpace.continuousSMul [PolynormableSpace �� E] :
    ContinuousSMul �� E :=
  PolynormableSpace.withSeminorms �� E |>.continuousSMul

theorem WithSeminorms.hasBasis (hp : WithSeminorms p) :
    (�� (0 : E)).HasBasis (fun s : Set E => s ∈ p.basisSets) id := by
  rw [congr_fun (congr_arg (@nhds E) hp.1) 0]
  exact AddGroupFilterBasis.nhds_zero_hasBasis _

theorem WithSeminorms.hasBasis_zero_ball (hp : WithSeminorms p) :
    (�� (0 : E)).HasBasis
    (fun sr : Finset ι × ℝ => 0 < sr.2) fun sr => (sr.1.sup p).ball 0 sr.2 := by
  refine ⟨fun V => ?_⟩
  simp only [hp.hasBasis.mem_iff, SeminormFamily.basisSets_iff, Prod.exists, id_eq]
  grind

variable (�� E) in
theorem PolynormableSpace.hasBasis_zero_ball [PolynormableSpace �� E] :
    (�� (0 : E)).HasBasis
    (fun p : Seminorm �� E ↦ Continuous p) (fun p ↦ p.ball 0 1) := by
  refine (PolynormableSpace.withSeminorms �� E).hasBasis_zero_ball.to_hasBasis ?_ ?_
  · intro ⟨s, r⟩ hr
    use r⁻¹.toNNReal • (s.sup (↑))
    constructor
    · have := PolynormableSpace.isTopologicalAddGroup
      exact (Seminorm.continuous_finsetSup fun t ht ↦ t.2).const_smul _
    · rw [ball_smul, Real.coe_toNNReal, one_div, inv_inv] <;>
      positivity
  · intro p p_cont
    use ⟨{⟨p, p_cont⟩}, 1⟩, one_pos
    simp

theorem WithSeminorms.hasBasis_ball (hp : WithSeminorms p) {x : E} :
    (�� (x : E)).HasBasis
    (fun sr : Finset ι × ℝ => 0 < sr.2) fun sr => (sr.1.sup p).ball x sr.2 := by
  have : IsTopologicalAddGroup E := hp.isTopologicalAddGroup
  rw [← map_add_left_nhds_zero]
  convert hp.hasBasis_zero_ball.map (x + ·) using 1
  ext sr : 1
  -- Porting note: extra type ascriptions needed on `0`
  have : (sr.fst.sup p).ball (x +ᵥ (0 : E)) sr.snd = x +ᵥ (sr.fst.sup p).ball 0 sr.snd :=
    Eq.symm (Seminorm.vadd_ball (sr.fst.sup p))
  rwa [vadd_eq_add, add_zero] at this

/-- The `x`-neighbourhoods of a space whose topology is induced by a family of seminorms
are exactly the sets which contain seminorm balls around `x`. -/

theorem WithSeminorms.mem_nhds_iff (hp : WithSeminorms p) (x : E) (U : Set E) :
    U ∈ �� x ↔ ∃ s : Finset ι, ∃ r > 0, (s.sup p).ball x r ⊆ U := by
  rw [hp.hasBasis_ball.mem_iff, Prod.exists]

/-- The open sets of a space whose topology is induced by a family of seminorms
are exactly the sets which contain seminorm balls around all of their points. -/

theorem WithSeminorms.isOpen_iff_mem_balls (hp : WithSeminorms p) (U : Set E) :
    IsOpen U ↔ ∀ x ∈ U, ∃ s : Finset ι, ∃ r > 0, (s.sup p).ball x r ⊆ U := by
  simp_rw [← WithSeminorms.mem_nhds_iff hp _ U, isOpen_iff_mem_nhds]

/- Note that through the following lemmas, one also immediately has that separating families
of seminorms induce T₂ and T₃ topologies by `IsTopologicalAddGroup.t2Space`
and `IsTopologicalAddGroup.t3Space` -/

/-- A separating family of seminorms induces a T₁ topology. -/
theorem WithSeminorms.T1_of_separating (hp : WithSeminorms p)
    (h : ∀ x, x ≠ 0 → ∃ i, p i x ≠ 0) : T1Space E := by
  have := hp.isTopologicalAddGroup
  refine IsTopologicalAddGroup.t1Space _ ?_
  rw [← isOpen_compl_iff, hp.isOpen_iff_mem_balls]
  rintro x (hx : x ≠ 0)
  obtain ⟨i, pi_nonzero⟩ := h x hx
  refine ⟨{i}, p i x, by positivity, subset_compl_singleton_iff.mpr ?_⟩
  rw [Finset.sup_singleton, mem_ball, zero_sub, map_neg_eq_map, not_lt]

/-- A family of seminorms inducing a T₁ topology is separating. -/
theorem WithSeminorms.separating_of_T1 [T1Space E] (hp : WithSeminorms p) (x : E) (hx : x ≠ 0) :
    ∃ i, p i x ≠ 0 := by
  have := ((t1Space_tfae E).out 1 10).mp (inferInstance : T1Space E)
  by_contra! h
  refine hx (this ?_)
  rw [hp.hasBasis_zero_ball.specializes_iff]
  rintro ⟨s, r⟩ (hr : 0 < r)
  simp only [ball_finset_sup_eq_iInter _ _ _ hr, mem_iInter₂, mem_ball_zero, h, hr, forall_true_iff]

/-- A family of seminorms is separating iff it induces a T₁ topology. -/
theorem WithSeminorms.separating_iff_T1 (hp : WithSeminorms p) :
    (∀ x, x ≠ 0 → ∃ i, p i x ≠ 0) ↔ T1Space E := by
  refine ⟨WithSeminorms.T1_of_separating hp, ?_⟩
  intro
  exact WithSeminorms.separating_of_T1 hp

end Topology

section Tendsto

variable [NormedField ��] [AddCommGroup E] [Module �� E] [TopologicalSpace E]
variable {p : SeminormFamily �� E ι}

/-- Convergence along filters for `WithSeminorms`.

Variant with `Finset.sup`. -/

theorem WithSeminorms.tendsto_nhds' (hp : WithSeminorms p) (u : F → E) {f : Filter F} (y₀ : E) :
    Filter.Tendsto u f (�� y₀) ↔
    ∀ (s : Finset ι) (ε), 0 < ε → ∀ᶠ x in f, s.sup p (u x - y₀) < ε := by
  simp [hp.hasBasis_ball.tendsto_right_iff]

/-- Convergence along filters for `WithSeminorms`. -/
theorem WithSeminorms.tendsto_nhds (hp : WithSeminorms p) (u : F → E) {f : Filter F} (y₀ : E) :
    Filter.Tendsto u f (�� y₀) ↔ ∀ i ε, 0 < ε → ∀ᶠ x in f, p i (u x - y₀) < ε := by
  rw [hp.tendsto_nhds' u y₀]
  exact
    ⟨fun h i => by simpa only [Finset.sup_singleton] using h {i}, fun h s ε hε =>
      (s.eventually_all.2 fun i _ => h i ε hε).mono fun _ => finset_sup_apply_lt hε⟩

variable [SemilatticeSup F] [Nonempty F]

/-- Limit `→ ∞` for `WithSeminorms`. -/
theorem WithSeminorms.tendsto_nhds_atTop (hp : WithSeminorms p) (u : F → E) (y₀ : E) :
    Filter.Tendsto u Filter.atTop (�� y₀) ↔
    ∀ i ε, 0 < ε → ∃ x₀, ∀ x, x₀ ≤ x → p i (u x - y₀) < ε := by
  rw [hp.tendsto_nhds u y₀]
  exact forall₃_congr fun _ _ _ => Filter.eventually_atTop

end Tendsto

section IsTopologicalAddGroup

variable [NormedField ��] [AddCommGroup E] [Module �� E]

section TopologicalSpace

variable [t : TopologicalSpace E]

theorem SeminormFamily.withSeminorms_of_nhds [IsTopologicalAddGroup E] (p : SeminormFamily �� E ι)
    (h : �� (0 : E) = p.moduleFilterBasis.toFilterBasis.filter) : WithSeminorms p := by
  refine
    ⟨IsTopologicalAddGroup.ext inferInstance p.addGroupFilterBasis.isTopologicalAddGroup ?_⟩
  rw [AddGroupFilterBasis.nhds_zero_eq]
  exact h

theorem SeminormFamily.withSeminorms_of_hasBasis [IsTopologicalAddGroup E]
    (p : SeminormFamily �� E ι) (h : (�� (0 : E)).HasBasis (fun s : Set E => s ∈ p.basisSets) id) :
    WithSeminorms p :=
  p.withSeminorms_of_nhds <|
    Filter.HasBasis.eq_of_same_basis h p.addGroupFilterBasis.toFilterBasis.hasBasis

theorem SeminormFamily.withSeminorms_iff_nhds_eq_iInf [IsTopologicalAddGroup E]
    (p : SeminormFamily �� E ι) : WithSeminorms p ↔ (�� (0 : E)) = ⨅ i, (�� 0).comap (p i) := by
  rw [← p.filter_eq_iInf]
  refine ⟨fun h => ?_, p.withSeminorms_of_nhds⟩
  rw [h.topology_eq_withSeminorms]
  exact AddGroupFilterBasis.nhds_zero_eq _

/-- The topology induced by a family of seminorms is exactly the infimum of the ones induced by
each seminorm individually. We express this as a characterization of `WithSeminorms p`. -/

theorem SeminormFamily.withSeminorms_iff_topologicalSpace_eq_iInf [IsTopologicalAddGroup E]
    (p : SeminormFamily �� E ι) :
    WithSeminorms p ↔
      t = ⨅ i, (p i).toSeminormedAddCommGroup.toUniformSpace.toTopologicalSpace := by
  rw [p.withSeminorms_iff_nhds_eq_iInf,
    IsTopologicalAddGroup.ext_iff inferInstance (isTopologicalAddGroup_iInf fun i => inferInstance),
    nhds_iInf]
  congrm _ = ⨅ i, ?_
  exact @comap_norm_nhds_zero _ (p i).toSeminormedAddGroup

/-- The topology induced by a family of seminorms is exactly the infimum of the ones induced by
each seminorm individually. We express this as a characterization of `WithSeminorms p`. -/

theorem WithSeminorms.topologicalSpace_eq_iInf
    {p : SeminormFamily �� E ι} (hp : WithSeminorms p) :
    t = ⨅ i, (p i).toSeminormedAddCommGroup.toUniformSpace.toTopologicalSpace := by
  have : IsTopologicalAddGroup E := WithSeminorms.isTopologicalAddGroup hp
  exact p.withSeminorms_iff_topologicalSpace_eq_iInf.1 hp

theorem WithSeminorms.continuous_seminorm {p : SeminormFamily �� E ι} (hp : WithSeminorms p)
    (i : ι) : Continuous (p i) := by
  have := hp.isTopologicalAddGroup
  rw [p.withSeminorms_iff_topologicalSpace_eq_iInf.mp hp]
  exact continuous_iInf_dom (@continuous_norm _ (p i).toSeminormedAddGroup)

theorem WithSeminorms.continuous_finsetSup_seminorm {p : SeminormFamily �� E ι}
    (hp : WithSeminorms p) (s : Finset ι) : Continuous (s.sup p : Seminorm �� E) :=
  have := hp.isTopologicalAddGroup
  Seminorm.continuous_finsetSup fun i _ ↦ hp.continuous_seminorm i

theorem WithSeminorms.toPolynormableSpace {p : SeminormFamily �� E ι} (hp : WithSeminorms p) :
    PolynormableSpace �� E where
  withSeminorms' := by
    have := hp.isTopologicalAddGroup
    have hp' (i : ι) : Continuous (p i) := hp.continuous_seminorm i
    rw [SeminormFamily.withSeminorms_iff_nhds_eq_iInf] at ⊢ hp
    refine le_antisymm ?_ ?_
    · simp_rw [le_iInf_iff, ← tendsto_iff_comap]
      intro ⟨p, hp⟩
      exact hp.tendsto' 0 0 (map_zero _)
    · simp_rw [hp, le_iInf_iff]
      intro i
      exact iInf_le (ι := {p : Seminorm �� E // Continuous p}) _ ⟨p i, hp' i⟩

instance [h : IsNormableSpace �� E] : PolynormableSpace �� E := by
  rcases h.withSeminorms' with ⟨q, hq⟩
  exact hq.toPolynormableSpace

end TopologicalSpace

/-- The uniform structure induced by a family of seminorms is exactly the infimum of the ones
induced by each seminorm individually. We express this as a characterization of
`WithSeminorms p`. -/

theorem SeminormFamily.withSeminorms_iff_uniformSpace_eq_iInf [u : UniformSpace E]
    [IsUniformAddGroup E] (p : SeminormFamily �� E ι) :
    WithSeminorms p ↔ u = ⨅ i, (p i).toSeminormedAddCommGroup.toUniformSpace := by
  rw [p.withSeminorms_iff_nhds_eq_iInf,
    IsUniformAddGroup.ext_iff inferInstance (isUniformAddGroup_iInf fun i => inferInstance),
    UniformSpace.toTopologicalSpace_iInf, nhds_iInf]
  congrm _ = ⨅ i, ?_
  exact @comap_norm_nhds_zero _ (p i).toAddGroupSeminorm.toSeminormedAddGroup

end IsTopologicalAddGroup

section NormedSpace

/-- The topology of a `NormedSpace �� E` is induced by the seminorm `normSeminorm �� E`. -/
theorem norm_withSeminorms (�� E) [NormedField ��] [SeminormedAddCommGroup E] [NormedSpace �� E] :
    WithSeminorms fun _ : Unit => normSeminorm �� E := by
  rw [SeminormFamily.withSeminorms_iff_nhds_eq_iInf, iInf_const, coe_normSeminorm,
    comap_norm_nhds_zero]

/-- A (semi-)normed space is normable. -/
instance [NormedField ��] [SeminormedAddCommGroup E] [NormedSpace �� E] : IsNormableSpace �� E :=
  ⟨⟨normSeminorm �� E, norm_withSeminorms �� E⟩⟩

variable [NormedField ��] [ha : AddCommGroup E] [hm : Module �� E]
  [t : TopologicalSpace E] [hn : IsNormableSpace �� E]

variable (�� E)

/-- A seminorm defining the topology in a normable space. -/
noncomputable def IsNormableSpace.seminorm : Seminorm �� E := hn.withSeminorms'.choose

lemma IsNormableSpace.withSeminorms_seminorm : WithSeminorms (fun (_ : Unit) ↦ hn.seminorm �� E) :=
  hn.withSeminorms'.choose_spec

/-- A normable space can be endowed with a seminorm defining the same topology. -/
noncomputable abbrev IsNormableSpace.toSeminormedAddCommGroup : SeminormedAddCommGroup E := by
  let : Norm E := ⟨IsNormableSpace.seminorm �� E⟩
  let c : SeminormedSpace.Core �� E :=
  { norm_nonneg x := apply_nonneg _ x
    norm_smul c x := map_smul_eq_mul _ c x
    norm_triangle x y := map_add_le_add _ x y }
  refine SeminormedAddCommGroup.ofCoreReplaceTopology c ?_
  rw [hn.withSeminorms_seminorm.topologicalSpace_eq_iInf, ciInf_unique]

/-- A normable space can be endowed with a normed space structure. -/
noncomputable abbrev IsNormableSpace.toNormedSpace :
    letI : SeminormedAddCommGroup E := IsNormableSpace.toSeminormedAddCommGroup �� E
    NormedSpace �� E :=
  letI : SeminormedAddCommGroup E := IsNormableSpace.toSeminormedAddCommGroup �� E
  { norm_smul_le c x := (map_smul_eq_mul (IsNormableSpace.seminorm �� E) c x).le }

instance [AddCommGroup F] [Module �� F] [TopologicalSpace F] [IsNormableSpace �� F] :
    IsNormableSpace �� (E × F) := by
  let : SeminormedAddCommGroup E := IsNormableSpace.toSeminormedAddCommGroup �� E
  let : NormedSpace �� E := IsNormableSpace.toNormedSpace �� E
  let : SeminormedAddCommGroup F := IsNormableSpace.toSeminormedAddCommGroup �� F
  let : NormedSpace �� F := IsNormableSpace.toNormedSpace �� F
  infer_instance

instance {E : ι → Type*} [Finite ι] [∀ i, AddCommGroup (E i)] [∀ i, Module �� (E i)]
    [∀ i, TopologicalSpace (E i)] [∀ i, IsNormableSpace �� (E i)] :
    IsNormableSpace �� (Π i, E i) := by
  let A i : SeminormedAddCommGroup (E i) := IsNormableSpace.toSeminormedAddCommGroup �� (E i)
  let B i : NormedSpace �� (E i) := IsNormableSpace.toNormedSpace �� (E i)
  let : Fintype ι := Fintype.ofFinite ι
  infer_instance

include �� in
/-- A normable space is metrizable. Not an instance as the field of scalars can not be guessed
by typeclass inference. -/

theorem IsNormableSpace.toPseudoMetrizableSpace : PseudoMetrizableSpace E := by
  let : SeminormedAddCommGroup E := IsNormableSpace.toSeminormedAddCommGroup �� E
  infer_instance

end NormedSpace

section NontriviallyNormedField

variable [NontriviallyNormedField ��] [AddCommGroup E] [Module �� E]
variable {p : SeminormFamily �� E ι}
variable [TopologicalSpace E]

theorem WithSeminorms.isVonNBounded_iff_finset_seminorm_bounded {s : Set E} (hp : WithSeminorms p) :
    IsVonNBounded �� s ↔ ∀ I : Finset ι, ∃ r > 0, ∀ x ∈ s, I.sup p x < r := by
  rw [hp.hasBasis.isVonNBounded_iff]
  constructor
  · intro h I
    simp only [id] at h
    specialize h ((I.sup p).ball 0 1) (p.basisSets_mem I zero_lt_one)
    rcases h.exists_pos with ⟨r, hr, h⟩
    obtain ⟨a, ha⟩ := NormedField.exists_lt_norm �� r
    specialize h a (le_of_lt ha)
    rw [Seminorm.smul_ball_zero (norm_pos_iff.1 <| hr.trans ha), mul_one] at h
    refine ⟨‖a‖, lt_trans hr ha, ?_⟩
    intro x hx
    specialize h hx
    exact (Finset.sup I p).mem_ball_zero.mp h
  intro h s' hs'
  rcases p.basisSets_iff.mp hs' with ⟨I, r, hr, hs'⟩
  rw [id, hs']
  rcases h I with ⟨r', _, h'⟩
  simp_rw [← (I.sup p).mem_ball_zero] at h'
  refine Absorbs.mono_right ?_ h'
  exact (Finset.sup I p).ball_zero_absorbs_ball_zero hr

theorem WithSeminorms.image_isVonNBounded_iff_finset_seminorm_bounded (f : G → E) {s : Set G}
    (hp : WithSeminorms p) :
    IsVonNBounded �� (f '' s) ↔
      ∀ I : Finset ι, ∃ r > 0, ∀ x ∈ s, I.sup p (f x) < r := by
  simp_rw [hp.isVonNBounded_iff_finset_seminorm_bounded, Set.forall_mem_image]

theorem WithSeminorms.isVonNBounded_iff_seminorm_bounded {s : Set E} (hp : WithSeminorms p) :
    IsVonNBounded �� s ↔ ∀ i : ι, ∃ r > 0, ∀ x ∈ s, p i x < r := by
  rw [hp.isVonNBounded_iff_finset_seminorm_bounded]
  constructor
  · intro hI i
    convert! hI { i }
    rw [Finset.sup_singleton]
  intro hi I
  by_cases! hI : I.Nonempty
  · choose r hr h using hi
    have h' : 0 < I.sup' hI r := by
      rcases hI with ⟨i, hi⟩
      exact lt_of_lt_of_le (hr i) (Finset.le_sup' r hi)
    refine ⟨I.sup' hI r, h', fun x hx => finset_sup_apply_lt h' fun i hi => ?_⟩
    refine lt_of_lt_of_le (h i x hx) ?_
    simp only [Finset.le_sup'_iff]
    exact ⟨i, hi, (Eq.refl _).le⟩
  simp only [hI, Finset.sup_empty, coe_bot, Pi.zero_apply]
  exact ⟨1, zero_lt_one, fun _ _ => zero_lt_one⟩

theorem WithSeminorms.image_isVonNBounded_iff_seminorm_bounded (f : G → E) {s : Set G}
    (hp : WithSeminorms p) :
    IsVonNBounded �� (f '' s) ↔ ∀ i : ι, ∃ r > 0, ∀ x ∈ s, p i (f x) < r := by
  simp_rw [hp.isVonNBounded_iff_seminorm_bounded, Set.forall_mem_image]

theorem WithSeminorms.isVonNBounded_iff_seminorm_bddAbove {s : Set E} (hp : WithSeminorms p) :
    IsVonNBounded �� s ↔ ∀ i : ι, BddAbove (p i '' s) := by
  simp_rw [hp.isVonNBounded_iff_seminorm_bounded, bddAbove_def, forall_mem_image]
  congrm ∀ i, ?_
  constructor
  · rintro ⟨r, _⟩
    use r
    grind
  · rintro ⟨r, _⟩
    use 1 + max r 0
    grind

/-- In a topological vector space, the topology is generated by a single seminorm `p` iff
the unit ball for this seminorm is a bounded neighborhood of `0`. -/

theorem withSeminorms_iff_mem_nhds_isVonNBounded [IsTopologicalAddGroup E]
    [ContinuousConstSMul �� E] {p : Seminorm �� E} :
    WithSeminorms (fun (_ : Unit) ↦ p) ↔ p.ball 0 1 ∈ �� 0 ∧ IsVonNBounded �� (p.ball 0 1) := by
  /- The nontrivial direction is from right to left. With `SeminormFamily.withSeminorms_of_nhds`,
  we need to see that the neighborhoods of zero for the initial topology and for `p` coincide. -/

  refine ⟨fun h ↦ ⟨?_, ?_⟩, ?_⟩
  · apply (h.mem_nhds_iff _ _).2
    exact ⟨Finset.univ, 1, zero_lt_one, by simp⟩
  · apply h.isVonNBounded_iff_seminorm_bounded.2 (fun i ↦ ?_)
    exact ⟨1, zero_lt_one, by simp⟩
  rintro ⟨h, h'⟩
  apply SeminormFamily.withSeminorms_of_nhds
  ext s
  refine ⟨fun hs ↦ ?_, fun hs ↦ ?_⟩
  · /- Show that a neighborhood `s` of zero for the topology is a neighborhood for `p`, by using the
    boundedness of `p.ball 0 1`: this ensures that, for some nonzero `c`, we have
    `p.ball 0 1 ⊆ c • s`, and therefore `p.ball 0 (‖c‖⁻¹) ⊆ s`. -/

    obtain ⟨c, hc, c_ne⟩ : ∃ (c : ��), p.ball 0 1 ⊆ c • s ∧ c ≠ 0 :=
      ((h' hs).and (eventually_ne_cobounded 0)).exists
    have : p.ball 0 (‖c⁻¹‖) ⊆ s := by
      have : c • p.ball 0 (‖c⁻¹‖) ⊆ c • s := by
        simpa [smul_ball_zero c_ne, ← norm_mul, c_ne] using hc
      rwa [smul_set_subset_smul_set_iff₀ c_ne] at this
    grw [← this]
    apply FilterBasis.mem_filter_of_mem
    change p.ball 0 (‖c⁻¹‖) ∈ SeminormFamily.basisSets (fun (i : Unit) ↦ p)
    apply SeminormFamily.basisSets_singleton_mem _ 0
    simpa using c_ne
  · /- Show that a neighborhood `s` for `p` is a neighborhood for the topology, by using the
    fact that `p.ball 0 1` is a neighborhood of `0`. Indeed, `s` contains a ball `p.ball 0 r`,
    which contains `c • p.ball 0 1` for some nonzero `c`. The latter set is a neighborhood of zero
    for the topology thanks to the topological vector space assumption. -/

    rcases (FilterBasis.mem_filter_iff _).1 hs with ⟨t, ht, ts⟩
    grw [← ts]
    rcases (SeminormFamily.basisSets_iff _).1 ht with ⟨w, r, r_pos, hw⟩
    rcases eq_or_ne w ∅ with rfl | w_ne
    · simp only [ball, Finset.sup_empty, sub_zero, coe_bot, Pi.zero_apply, r_pos, ofPred_true] at hw
      simp [hw]
    have : t = p.ball 0 r := by
      have : w = Finset.univ := by
        rcases Finset.nonempty_of_ne_empty w_ne with ⟨i, hi⟩
        ext j
        simp only [Subsingleton.elim j i, hi, Finset.mem_univ]
      simpa only [this, Finset.univ_unique, Fin.default_eq_zero, Fin.isValue,
        Finset.sup_singleton] using hw
    rw [this]
    obtain ⟨c, c_pos, hc⟩ : ∃ (c : ��), 0 < ‖c‖ ∧ ‖c‖ < r := exists_norm_lt �� r_pos
    have c_ne : c ≠ 0 := (by simpa using c_pos)
    have : c • p.ball 0 1 ⊆ p.ball 0 r := by
      rw [smul_ball_zero c_ne]
      exact ball_mono (by simpa using hc.le)
    grw [← this]
    simpa using smul_mem_nhds_smul₀ c_ne h

end NontriviallyNormedField

section continuous_of_bounded

namespace WithSeminorms

variable [NontriviallyNormedField ��] [AddCommGroup E] [Module �� E]
variable [NormedField ��] [Module �� E]
variable [NormedField ��₂] [AddCommGroup F] [Module ��₂ F]
variable [NormedField ��₂] [Module ��₂ F]
variable {σ₁₂ : �� →+* ��₂} [RingHomIsometric σ₁₂]
variable {τ₁₂ : �� →+* ��₂} [RingHomIsometric τ₁₂]

theorem continuous_of_continuous_comp {q : SeminormFamily ��₂ F ι'} [TopologicalSpace E]
    [IsTopologicalAddGroup E] [TopologicalSpace F] (hq : WithSeminorms q)
    (f : E →ₛₗ[τ₁₂] F) (hf : ∀ i, Continuous ((q i).comp f)) : Continuous f := by
  have : IsTopologicalAddGroup F := hq.isTopologicalAddGroup
  refine continuous_of_continuousAt_zero f ?_
  simp_rw [ContinuousAt, f.map_zero, q.withSeminorms_iff_nhds_eq_iInf.mp hq, Filter.tendsto_iInf,
    Filter.tendsto_comap_iff]
  intro i
  convert! (hf i).continuousAt.tendsto
  exact (map_zero _).symm

theorem continuous_iff_continuous_comp {q : SeminormFamily ��₂ F ι'} [TopologicalSpace E]
    [IsTopologicalAddGroup E] [TopologicalSpace F] (hq : WithSeminorms q) (f : E →ₛₗ[τ₁₂] F) :
    Continuous f ↔ ∀ i, Continuous ((q i).comp f) :=
  ⟨fun h i => (hq.continuous_seminorm i).comp h, continuous_of_continuous_comp hq f⟩

theorem continuous_of_isBounded {p : SeminormFamily �� E ι} {q : SeminormFamily ��₂ F ι'}
    {_ : TopologicalSpace E} (hp : WithSeminorms p) {_ : TopologicalSpace F} (hq : WithSeminorms q)
    (f : E →ₛₗ[τ₁₂] F) (hf : Seminorm.IsBounded p q f) : Continuous f := by
  have : IsTopologicalAddGroup E := hp.isTopologicalAddGroup
  refine continuous_of_continuous_comp hq _ fun i => ?_
  rcases hf i with ⟨s, C, hC⟩
  rw [← finset_sup_smul] at hC
  exact continuous_of_le
    (continuous_finsetSup fun i _ ↦ (hp.continuous_seminorm i).const_smul C) hC

theorem continuous_normedSpace_rng (F) [SeminormedAddCommGroup F] [NormedSpace ��₂ F]
    [TopologicalSpace E] {p : ι → Seminorm �� E} (hp : WithSeminorms p)
    (f : E →ₛₗ[τ₁₂] F) (hf : ∃ (s : Finset ι) (C : ℝ≥0), (normSeminorm ��₂ F).comp f ≤ C • s.sup p) :
    Continuous f := by
  rw [← Seminorm.isBounded_const Unit] at hf
  exact continuous_of_isBounded hp (norm_withSeminorms ��₂ F) f hf

lemma _root_.Seminorm.abs_le_of_le [Module ℝ E] {p : Seminorm ℝ E}
    {f : E →ₗ[ℝ] ℝ} (hfp : ∀ x, f x ≤ p x) (x : E) :
    |f x| ≤ p x :=
  abs_le.2 ⟨neg_le.1 (by simpa using hfp (-x)), hfp x⟩

theorem continuous_real_rng [Module ℝ E] [TopologicalSpace E] {p : ι → Seminorm ℝ E}
    (hp : WithSeminorms p) (f : E →ₗ[ℝ] ℝ)
    (hf : ∃ (s : Finset ι) (C : ℝ≥0), ∀ x, f x ≤ (C • s.sup p) x) :
    Continuous f := by
  obtain ⟨s, C, hC⟩ := hf
  exact continuous_normedSpace_rng ℝ hp f ⟨s, C, abs_le_of_le hC⟩

theorem continuous_normedSpace_dom (E) [SeminormedAddCommGroup E] [NormedSpace �� E]
    [TopologicalSpace F] {q : ι → Seminorm ��₂ F} (hq : WithSeminorms q)
    (f : E →ₛₗ[τ₁₂] F) (hf : ∀ i : ι, ∃ C : ℝ≥0, (q i).comp f ≤ C • normSeminorm �� E) :
    Continuous f := by
  rw [← Seminorm.const_isBounded Unit] at hf
  exact continuous_of_isBounded (norm_withSeminorms �� E) hq f hf

/-- Let `E` and `F` be two topological vector spaces over a `NontriviallyNormedField`, and assume
that the topology of `F` is generated by some family of seminorms `q`. For a family `f` of linear
maps from `E` to `F`, the following are equivalent:
* `f` is equicontinuous at `0`.
* `f` is equicontinuous.
* `f` is uniformly equicontinuous.
* For each `q i`, the family of seminorms `k ↦ (q i) ∘ (f k)` is bounded by some continuous
  seminorm `p` on `E`.
* For each `q i`, the seminorm `⊔ k, (q i) ∘ (f k)` is well-defined and continuous.

In particular, if you can determine all continuous seminorms on `E`, that gives you a complete
characterization of equicontinuity for linear maps from `E` to `F`. For example `E` and `F` are
both normed spaces, you get `NormedSpace.equicontinuous_tfae`. -/

protected theorem equicontinuous_tfae {κ : Type*}
    {q : SeminormFamily ��₂ F ι'} [UniformSpace E] [IsUniformAddGroup E] [u : UniformSpace F]
    [hu : IsUniformAddGroup F] (hq : WithSeminorms q) [ContinuousSMul �� E]
    (f : κ → E →ₛₗ[σ₁₂] F) : TFAE
    [ EquicontinuousAt ((↑) ∘ f) 0,
      Equicontinuous ((↑) ∘ f),
      UniformEquicontinuous ((↑) ∘ f),
      ∀ i, ∃ p : Seminorm �� E, Continuous p ∧ ∀ k, (q i).comp (f k) ≤ p,
      ∀ i, BddAbove (range fun k ↦ (q i).comp (f k)) ∧ Continuous (⨆ k, (q i).comp (f k)) ] := by
  -- We start by reducing to the case where the target is a seminormed space
  rw [q.withSeminorms_iff_uniformSpace_eq_iInf.mp hq, uniformEquicontinuous_iInf_rng,
      equicontinuous_iInf_rng, equicontinuousAt_iInf_rng]
  refine forall_tfae [_, _, _, _, _] fun i ↦ ?_
  let _ : SeminormedAddCommGroup F := (q i).toSeminormedAddCommGroup
  clear u hu hq
  -- Now we can prove the equivalence in this setting
  simp only [List.map]
  tfae_have 1 → 3 := uniformEquicontinuous_of_equicontinuousAt_zero f
  tfae_have 3 → 2 := UniformEquicontinuous.equicontinuous
  tfae_have 2 → 1 := fun H ↦ H 0
  tfae_have 3 → 5
  | H => by
    have : ∀ᶠ x in �� 0, ∀ k, q i (f k x) ≤ 1 := by
      filter_upwards [Metric.equicontinuousAt_iff_right.mp (H.equicontinuous 0) 1 one_pos]
        with x hx k
      simpa using! (hx k).le
    have bdd : BddAbove (range fun k ↦ (q i).comp (f k)) :=
      Seminorm.bddAbove_of_absorbent (absorbent_nhds_zero this)
        (fun x hx ↦ ⟨1, forall_mem_range.mpr hx⟩)
    rw [← Seminorm.coe_iSup_eq bdd]
    refine ⟨bdd, Seminorm.continuous' (r := 1) ?_⟩
    filter_upwards [this] with x hx
    simpa only [closedBall_iSup bdd _ one_pos, mem_iInter, mem_closedBall_zero] using! hx
  tfae_have 5 → 4 := fun H ↦ ⟨⨆ k, (q i).comp (f k), Seminorm.coe_iSup_eq H.1 ▸ H.2, le_ciSup H.1⟩
  tfae_have 4 → 1 -- This would work over any `NormedField`
  | ⟨p, hp, hfp⟩ =>
    Metric.equicontinuousAt_of_continuity_modulus p (map_zero p ▸ hp.tendsto 0) _ <|
      Eventually.of_forall fun x k ↦ by simpa using! hfp k x
  tfae_finish

@[deprecated (since := "2026-10-27")]
protected alias equicontinuous_TFAE := WithSeminorms.equicontinuous_tfae

theorem uniformEquicontinuous_iff_exists_continuous_seminorm {κ : Type*}
    {q : SeminormFamily ��₂ F ι'} [UniformSpace E] [IsUniformAddGroup E] [u : UniformSpace F]
    [IsUniformAddGroup F] (hq : WithSeminorms q) [ContinuousSMul �� E]
    (f : κ → E →ₛₗ[σ₁₂] F) :
    UniformEquicontinuous ((↑) ∘ f) ↔
    ∀ i, ∃ p : Seminorm �� E, Continuous p ∧ ∀ k, (q i).comp (f k) ≤ p :=
  (hq.equicontinuous_tfae f).out 3 4

theorem uniformEquicontinuous_iff_bddAbove_and_continuous_iSup {κ : Type*}
    {q : SeminormFamily ��₂ F ι'} [UniformSpace E] [IsUniformAddGroup E] [u : UniformSpace F]
    [IsUniformAddGroup F] (hq : WithSeminorms q) [ContinuousSMul �� E]
    (f : κ → E →ₛₗ[σ₁₂] F) :
    UniformEquicontinuous ((↑) ∘ f) ↔ ∀ i,
    BddAbove (range fun k ↦ (q i).comp (f k)) ∧
      Continuous (⨆ k, (q i).comp (f k)) :=
  (hq.equicontinuous_tfae f).out 3 5

end WithSeminorms

section Congr

namespace WithSeminorms

variable [NormedField ��] [AddCommGroup E] [Module �� E]
variable [SeminormedRing ��₂] [AddCommGroup F] [Module ��₂ F]

/-- Two families of seminorms `p` and `q` on the same space generate the same topology
if each `p i` is bounded by some `C • Finset.sup s q` and vice-versa.

We formulate these boundedness assumptions as `Seminorm.IsBounded q p LinearMap.id` (and
vice-versa) to reuse the API. Furthermore, we don't actually state it as an equality of topologies
but as a way to deduce `WithSeminorms q` from `WithSeminorms p`, since this should be more
useful in practice. -/

protected theorem congr {p : SeminormFamily �� E ι} {q : SeminormFamily �� E ι'}
    [t : TopologicalSpace E] (hp : WithSeminorms p) (hpq : Seminorm.IsBounded p q LinearMap.id)
    (hqp : Seminorm.IsBounded q p LinearMap.id) : WithSeminorms q := by
  constructor
  rw [hp.topology_eq_withSeminorms]
  clear hp t
  refine le_antisymm ?_ ?_ <;>
  rw [← continuous_id_iff_le] <;>
  refine continuous_of_isBounded (.mk (topology := _) rfl) (.mk (topology := _) rfl)
    LinearMap.id (by assumption)

protected theorem finset_sups {p : SeminormFamily �� E ι} [TopologicalSpace E]
    (hp : WithSeminorms p) : WithSeminorms (fun s : Finset ι ↦ s.sup p) := by
  refine hp.congr ?_ ?_
  · intro s
    refine ⟨s, 1, ?_⟩
    rw [one_smul]
    rfl
  · intro i
    refine ⟨{{i}}, 1, ?_⟩
    rw [Finset.sup_singleton, Finset.sup_singleton, one_smul]
    rfl

protected theorem partial_sups [Preorder ι] [LocallyFiniteOrderBot ι] {p : SeminormFamily �� E ι}
    [TopologicalSpace E] (hp : WithSeminorms p) : WithSeminorms (fun i ↦ (Finset.Iic i).sup p) := by
  refine hp.congr ?_ ?_
  · intro i
    refine ⟨Finset.Iic i, 1, ?_⟩
    rw [one_smul]
    rfl
  · intro i
    refine ⟨{i}, 1, ?_⟩
    rw [Finset.sup_singleton, one_smul]
    exact (Finset.le_sup (Finset.mem_Iic.mpr le_rfl) : p i ≤ (Finset.Iic i).sup p)

protected theorem congr_equiv {p : SeminormFamily �� E ι} [t : TopologicalSpace E]
    (hp : WithSeminorms p) (e : ι' ≃ ι) : WithSeminorms (p ∘ e) := by
  refine hp.congr ?_ ?_ <;>
  intro i <;>
  [use {e i}, 1; use {e.symm i}, 1] <;>
  simp

end WithSeminorms

end Congr

end continuous_of_bounded

section bounded_of_continuous

namespace Seminorm

variable [NontriviallyNormedField ��] [AddCommGroup E] [Module �� E]
  [SeminormedAddCommGroup F] [NormedSpace �� F]
  {p : SeminormFamily �� E ι}

/-- In a semi-`NormedSpace`, a continuous seminorm is zero on elements of norm `0`. -/
lemma map_eq_zero_of_norm_eq_zero (q : Seminorm �� F)
    (hq : Continuous q) {x : F} (hx : ‖x‖ = 0) : q x = 0 :=
  (map_zero q) ▸
    ((specializes_iff_mem_closure.mpr <| mem_closure_zero_iff_norm.mpr hx).map hq).eq.symm

/-- Let `F` be a semi-`NormedSpace` over a `NontriviallyNormedField`, and let `q` be a
seminorm on `F`. If `q` is continuous, then it is uniformly controlled by the norm, that is there
is some `C > 0` such that `∀ x, q x ≤ C * ‖x‖`.
The continuity ensures boundedness on a ball of some radius `ε`. The nontriviality of the
norm is then used to rescale any element into an element of norm in `[ε/C, ε[`, thus with a
controlled image by `q`. The control of `q` at the original element follows by rescaling. -/

lemma bound_of_continuous_normedSpace (q : Seminorm �� F)
    (hq : Continuous q) : ∃ C, 0 < C ∧ (∀ x : F, q x ≤ C * ‖x‖) := by
  have hq' : Tendsto q (�� 0) (�� 0) := map_zero q ▸ hq.tendsto 0
  rcases NormedAddGroup.nhds_zero_basis_norm_lt.mem_iff.mp (hq' <| Iio_mem_nhds one_pos)
    with ⟨ε, ε_pos, hε⟩
  rcases NormedField.exists_one_lt_norm �� with ⟨c, hc⟩
  have : 0 < ‖c‖ / ε := by positivity
  refine ⟨‖c‖ / ε, this, fun x ↦ ?_⟩
  by_cases hx : ‖x‖ = 0
  · rw [hx, mul_zero]
    exact le_of_eq (map_eq_zero_of_norm_eq_zero q hq hx)
  · refine (normSeminorm �� F).bound_of_shell q ε_pos hc (fun x hle hlt ↦ ?_) hx
    refine (le_of_lt <| show q x < _ from hε hlt).trans ?_
    rwa [← div_le_iff₀' this, one_div_div]

/-- Let `E` be a topological vector space (over a `NontriviallyNormedField`) whose topology is
generated by some family of seminorms `p`, and let `q` be a seminorm on `E`. If `q` is continuous,
then it is uniformly controlled by *finitely many* seminorms of `p`, that is there
is some finset `s` of the index set and some `C > 0` such that `q ≤ C • s.sup p`. -/

lemma bound_of_continuous [t : TopologicalSpace E] (hp : WithSeminorms p)
    (q : Seminorm �� E) (hq : Continuous q) :
    ∃ s : Finset ι, ∃ C : ℝ≥0, C ≠ 0 ∧ q ≤ C • s.sup p := by
  -- The continuity of `q` gives us a finset `s` and a real `ε > 0`
  -- such that `hε : (s.sup p).ball 0 ε ⊆ q.ball 0 1`.
  rcases hp.hasBasis.mem_iff.mp (ball_mem_nhds hq one_pos) with ⟨V, hV, hε⟩
  rcases p.basisSets_iff.mp hV with ⟨s, ε, ε_pos, rfl⟩
  -- Now forget that `E` already had a topology and view it as the (semi)normed space
  -- `(E, s.sup p)`.
  clear hp hq t
  let _ : SeminormedAddCommGroup E := (s.sup p).toSeminormedAddCommGroup
  let _ : NormedSpace �� E := { norm_smul_le := fun a b ↦ le_of_eq (map_smul_eq_mul (s.sup p) a b) }
  -- The inclusion `hε` tells us exactly that `q` is *still* continuous for this new topology
  have : Continuous q := by
    apply Seminorm.continuous (r := 1) (mem_of_superset (Metric.ball_mem_nhds _ ε_pos) ?_)
    rw [← ball_eq_metric]
    exact hε
  -- Hence we can conclude by applying `bound_of_continuous_normedSpace`.
  rcases bound_of_continuous_normedSpace q this with ⟨C, C_pos, hC⟩
  exact ⟨s, ⟨C, C_pos.le⟩, fun H ↦ C_pos.ne.symm (congr_arg NNReal.toReal H), hC⟩
  -- Note that the key ingredient for this proof is that, by scaling arguments hidden in
  -- `Seminorm.continuous`, we only have to look at the `q`-ball of radius one, and the `s` we get
  -- from that will automatically work for all other radii.

/-- Let `E` be a topological vector space (over a `NontriviallyNormedField`) whose topology is
generated by some family of seminorms `p`, and let `q` be a seminorm on `E`. If `q` is continuous,
then it is uniformly controlled by the sum of *finitely many* seminorms of `p`, that is there
is some finset `s` of the index set and some `C > 0` such that `q ≤ C • ∑ i ∈ s, p i`. -/

lemma bound_sum_of_continuous [t : TopologicalSpace E] (hp : WithSeminorms p)
    (q : Seminorm �� E) (hq : Continuous q) :
    ∃ s : Finset ι, ∃ C : ℝ≥0, C ≠ 0 ∧ q ≤ C • ∑ i ∈ s, p i := by
  obtain ⟨s, C, C_ne, hC⟩ := bound_of_continuous hp q hq
  use s, C, C_ne
  calc
    _ ≤ C • s.sup p := hC
    _ ≤ _ := by gcongr; apply finset_sup_le_sum

end Seminorm

namespace WithSeminorms

variable [NontriviallyNormedField ��] [AddCommGroup E] [Module �� E]
  [SeminormedAddCommGroup F] [NormedSpace �� F]
  {p : SeminormFamily �� E ι}

@[elab_as_elim]
lemma induction_sup_of_continuous [TopologicalSpace E] (hp : WithSeminorms p)
    {motive : Seminorm �� E → Prop}
    (base : ∀ i, motive (p i))
    (zero : motive 0)
    (sup : ∀ r s, motive r → motive s → motive (r ⊔ s))
    (le : ∀ r s, r ≤ s → motive s → motive r)
    (smul : ∀ r (C : ℝ≥0), motive r → motive (C • r))
    {q : Seminorm �� E} (cont : Continuous q) :
    motive q := by
  classical
  rcases bound_of_continuous hp q cont with ⟨s, C, hC, hs⟩
  refine le _ _ hs (smul _ _ ?_)
  refine s.induction_on ?_ ?_
  · simpa [Seminorm.bot_eq_zero] using zero
  · intro _ t _ ht
    rw [Finset.sup_insert]
    exact sup _ _ (base _) ht

@[elab_as_elim]
lemma induction_add_of_continuous [TopologicalSpace E] (hp : WithSeminorms p)
    {motive : Seminorm �� E → Prop}
    (base : ∀ i, motive (p i))
    (zero : motive 0)
    (add : ∀ r s, motive r → motive s → motive (r + s))
    (le : ∀ r s, r ≤ s → motive s → motive r)
    (smul : ∀ r (C : ℝ≥0), motive r → motive (C • r))
    {q : Seminorm �� E} (cont : Continuous q) :
    motive q :=
  induction_sup_of_continuous hp base zero
    (fun r s hr hs ↦ le _ _ (fun x ↦ by simp) (add r s hr hs)) le smul cont

end WithSeminorms

end bounded_of_continuous

section LocallyConvexSpace

open LocallyConvexSpace

variable [NormedField ��] [NormedSpace ℝ ��] [AddCommGroup E] [Module �� E] [Module ℝ E]
  [IsScalarTower ℝ �� E] [TopologicalSpace E]

theorem WithSeminorms.toLocallyConvexSpace {p : SeminormFamily �� E ι} (hp : WithSeminorms p) :
    LocallyConvexSpace ℝ E := by
  have := hp.isTopologicalAddGroup
  apply ofBasisZero ℝ E id fun s => s ∈ p.basisSets
  · rw [hp.1, AddGroupFilterBasis.nhds_eq _, AddGroupFilterBasis.N_zero]
    exact FilterBasis.hasBasis _
  · intro s hs
    change s ∈ Set.iUnion _ at hs
    simp_rw [Set.mem_iUnion, Set.mem_singleton_iff] at hs
    rcases hs with ⟨I, r, _, rfl⟩
    exact convex_ball _ _ _

/-- A `PolynormableSpace` over `ℝ` is locally convex.

TODO: generalize to `RCLike`. -/

instance (priority := low) [PolynormableSpace ℝ E] : LocallyConvexSpace ℝ E :=
  PolynormableSpace.withSeminorms ℝ E |>.toLocallyConvexSpace

end LocallyConvexSpace

section NormedSpace

variable (��) [NormedField ��] [NormedSpace ℝ ��] [SeminormedAddCommGroup E]

/-- Not an instance since `��` can't be inferred. See `NormedSpace.toLocallyConvexSpace` for a
slightly weaker instance version. -/

theorem NormedSpace.toLocallyConvexSpace' [NormedSpace �� E] [Module ℝ E] [IsScalarTower ℝ �� E] :
    LocallyConvexSpace ℝ E :=
  (norm_withSeminorms �� E).toLocallyConvexSpace

/-- See `NormedSpace.toLocallyConvexSpace'` for a slightly stronger version which is not an
instance. -/

instance NormedSpace.toLocallyConvexSpace [NormedSpace ℝ E] : LocallyConvexSpace ℝ E :=
  NormedSpace.toLocallyConvexSpace' ℝ

end NormedSpace

section TopologicalConstructions

variable [NormedField ��] [AddCommGroup E] [Module �� E]
variable [NormedField ��₂] [AddCommGroup F] [Module ��₂ F]
variable {σ₁₂ : �� →+* ��₂} [RingHomIsometric σ₁₂]

/-- The family of seminorms obtained by composing each seminorm by a linear map. -/
def SeminormFamily.comp (q : SeminormFamily ��₂ F ι) (f : E →ₛₗ[σ₁₂] F) : SeminormFamily �� E ι :=
  fun i => (q i).comp f

theorem SeminormFamily.comp_apply (q : SeminormFamily ��₂ F ι) (i : ι) (f : E →ₛₗ[σ₁₂] F) :
    q.comp f i = (q i).comp f :=
  rfl

theorem SeminormFamily.comp_smul_nnreal (q : SeminormFamily ��₂ F ι) (c : NNReal)
    (f : E →ₛₗ[σ₁₂] F) :
    c • q.comp f = (c • q).comp f := by
  ext
  simp [SeminormFamily.comp_apply, Seminorm.comp_apply]

theorem SeminormFamily.finset_sup_comp (q : SeminormFamily ��₂ F ι) (s : Finset ι)
    (f : E →ₛₗ[σ₁₂] F) : (s.sup q).comp f = s.sup (q.comp f) := by
  ext x
  rw [Seminorm.comp_apply, Seminorm.finset_sup_apply, Seminorm.finset_sup_apply]
  rfl

variable [TopologicalSpace F]

theorem LinearMap.withSeminorms_induced {q : SeminormFamily ��₂ F ι}
    (hq : WithSeminorms q) (f : E →ₛₗ[σ₁₂] F) :
    WithSeminorms (topology := induced f inferInstance) (q.comp f) := by
  have := hq.isTopologicalAddGroup
  let _ : TopologicalSpace E := induced f inferInstance
  have : IsTopologicalAddGroup E := isTopologicalAddGroup_induced f
  rw [(q.comp f).withSeminorms_iff_nhds_eq_iInf, nhds_induced, map_zero,
    q.withSeminorms_iff_nhds_eq_iInf.mp hq, Filter.comap_iInf]
  refine iInf_congr fun i => ?_
  exact Filter.comap_comap

protected theorem PolynormableSpace.induced [PolynormableSpace ��₂ F] (f : E →ₛₗ[σ₁₂] F) :
    PolynormableSpace �� E (topology := induced f inferInstance) := by
  let _ : TopologicalSpace E := induced f inferInstance
  exact f.withSeminorms_induced (PolynormableSpace.withSeminorms ��₂ F) |>.toPolynormableSpace

lemma Topology.IsInducing.withSeminorms {q : SeminormFamily ��₂ F ι}
    (hq : WithSeminorms q) [TopologicalSpace E] {f : E →ₛₗ[σ₁₂] F} (hf : IsInducing f) :
    WithSeminorms (q.comp f) := by
  rw [hf.eq_induced]
  exact f.withSeminorms_induced hq

theorem Topology.IsInducing.isNormableSpace [h : IsNormableSpace ��₂ F]
    [TopologicalSpace E] {f : E →ₛₗ[σ₁₂] F} (hf : IsInducing f) :
    IsNormableSpace �� E := by
  rcases h.withSeminorms' with ⟨p, hp⟩
  exact ⟨p.comp f, hf.withSeminorms hp⟩

theorem Topology.IsInducing.polynormableSpace [PolynormableSpace ��₂ F]
    [TopologicalSpace E] {f : E →ₛₗ[σ₁₂] F} (hf : IsInducing f) :
    PolynormableSpace �� E :=
  hf.withSeminorms (PolynormableSpace.withSeminorms ��₂ F) |>.toPolynormableSpace

instance [IsNormableSpace ��₂ F] {S : Submodule ��₂ F} :
    IsNormableSpace ��₂ S :=
  IsInducing.isNormableSpace (f := S.subtype) .subtypeVal

instance [PolynormableSpace ��₂ F] {S : Submodule ��₂ F} :
    PolynormableSpace ��₂ S :=
  IsInducing.polynormableSpace (f := S.subtype) .subtypeVal

theorem ContinuousLinearEquiv.isNormableSpace {σ₂₁ : ��₂ →+* ��}
    [RingHomInvPair σ₁₂ σ₂₁] [RingHomInvPair σ₂₁ σ₁₂] [IsNormableSpace ��₂ F]
    [TopologicalSpace E] (f : E ≃SL[σ₁₂] F) :
    IsNormableSpace �� E :=
  f.toHomeomorph.isInducing.isNormableSpace

theorem ContinuousLinearEquiv.PolynormableSpace {σ₂₁ : ��₂ →+* ��}
    [RingHomInvPair σ₁₂ σ₂₁] [RingHomInvPair σ₂₁ σ₁₂] [PolynormableSpace ��₂ F]
    [TopologicalSpace E] (f : E ≃SL[σ₁₂] F) :
    PolynormableSpace �� E :=
  f.toHomeomorph.isInducing.polynormableSpace

section NontriviallyNormedField

variable {�� : Type*} [NontriviallyNormedField ��] [Module �� E] [TopologicalSpace E]
variable {σ₁₂ : �� →+* ��₂} [RingHomIsometric σ₁₂]

theorem Seminorm.bound_comp_of_isInducing {p : Seminorm �� E} (hp : Continuous p)
    {q : SeminormFamily ��₂ F ι} (hq : WithSeminorms q) {f : E →ₛₗ[σ₁₂] F} (hf : IsInducing f) :
    ∃ (s : Finset ι) (C : ℝ≥0), C ≠ 0 ∧ p ≤ (C • s.sup q).comp f := by
  obtain ⟨s, C, hC, hqC⟩ := Seminorm.bound_of_continuous (hf.withSeminorms hq) p hp
  rw [← SeminormFamily.finset_sup_comp, ← Seminorm.smul_comp] at hqC
  exact ⟨s, C, hC, hqC⟩

theorem Seminorm.exists_le_comp_of_isInducing {p : Seminorm �� E} (hp : Continuous p)
    [PolynormableSpace ��₂ F] {f : E →ₛₗ[σ₁₂] F} (hf : IsInducing f) :
    ∃ p₂ : Seminorm ��₂ F, Continuous p₂ ∧ p ≤ p₂.comp f := by
  obtain ⟨s, C, -, hqC⟩ := Seminorm.bound_comp_of_isInducing hp
    (PolynormableSpace.withSeminorms ��₂ F) hf
  have := (PolynormableSpace.withSeminorms ��₂ F).isTopologicalAddGroup
  exact ⟨_, Continuous.const_smul (continuous_finsetSup fun i _ => i.2) C, hqC⟩

end NontriviallyNormedField

/-- (Disjoint) union of seminorm families. -/
protected def SeminormFamily.sigma {κ : ι → Type*} (p : (i : ι) → SeminormFamily �� E (κ i)) :
    SeminormFamily �� E ((i : ι) × κ i) :=
  fun ⟨i, k⟩ => p i k

theorem withSeminorms_iInf {κ : ι → Type*}
    {p : (i : ι) → SeminormFamily �� E (κ i)} {t : ι → TopologicalSpace E}
    (hp : ∀ i, WithSeminorms (topology := t i) (p i)) :
    WithSeminorms (topology := ⨅ i, t i) (SeminormFamily.sigma p) := by
  have : ∀ i, @IsTopologicalAddGroup E (t i) _ :=
    fun i ↦ @WithSeminorms.isTopologicalAddGroup _ _ _ _ _ _ (t i) _ (hp i)
  have : @IsTopologicalAddGroup E (⨅ i, t i) _ := isTopologicalAddGroup_iInf inferInstance
  simp_rw [@SeminormFamily.withSeminorms_iff_topologicalSpace_eq_iInf _ _ _ _ _ _ _ (_)] at hp ⊢
  rw [iInf_sigma]
  exact iInf_congr hp

theorem PolynormableSpace.iInf {t : ι → TopologicalSpace E}
    (ht : ∀ i, PolynormableSpace �� E (topology := t i)) :
    PolynormableSpace �� E (topology := ⨅ i, t i) := by
  let _ : TopologicalSpace E := ⨅ i, t i
  exact withSeminorms_iInf (fun i ↦ (ht i).withSeminorms') |>.toPolynormableSpace

theorem PolynormableSpace.sInf {ts : Set (TopologicalSpace E)}
    (hts : ∀ t ∈ ts, PolynormableSpace �� E (topology := t)) :
    PolynormableSpace �� E (topology := sInf ts) := by
  rw [sInf_eq_iInf']
  exact .iInf fun t ↦ hts t.1 t.2

theorem PolynormableSpace.inf {t₁ t₂ : TopologicalSpace E}
    (ht₁ : PolynormableSpace �� E (topology := t₁))
    (ht₂ : PolynormableSpace �� E (topology := t₂)) :
    PolynormableSpace �� E (topology := t₁ ⊓ t₂) := by
  rw [← sInf_pair]
  exact .sInf (by simp [ht₁, ht₂])

theorem withSeminorms_pi {κ : ι → Type*} {E : ι → Type*}
    [∀ i, AddCommGroup (E i)] [∀ i, Module �� (E i)] [∀ i, TopologicalSpace (E i)]
    {p : (i : ι) → SeminormFamily �� (E i) (κ i)}
    (hp : ∀ i, WithSeminorms (p i)) :
    WithSeminorms (SeminormFamily.sigma (fun i ↦ (p i).comp (LinearMap.proj i))) :=
  withSeminorms_iInf fun i ↦ (LinearMap.proj i).withSeminorms_induced (hp i)

instance {E : ι → Type*} [∀ i, AddCommGroup (E i)] [∀ i, Module �� (E i)]
    [∀ i, TopologicalSpace (E i)] [∀ i, PolynormableSpace �� (E i)] :
    PolynormableSpace �� (Π i, E i) :=
  .iInf fun i ↦ .induced (LinearMap.proj (R := ��) (φ := E) i)

instance {E₁ E₂ : Type*} [AddCommGroup E₁] [AddCommGroup E₂] [Module �� E₁] [Module �� E₂]
    [TopologicalSpace E₁] [TopologicalSpace E₂] [PolynormableSpace �� E₁] [PolynormableSpace �� E₂] :
    PolynormableSpace �� (E₁ × E₂) :=
  .inf (.induced <| LinearMap.fst �� E₁ E₂) (.induced <| LinearMap.snd �� E₁ E₂)

end TopologicalConstructions

section TopologicalProperties

variable [NontriviallyNormedField ��] [AddCommGroup E] [Module �� E] [Countable ι]
variable {p : SeminormFamily �� E ι}
variable [TopologicalSpace E]

/-- If the topology of a space is induced by a countable family of seminorms, then the topology
is first countable. -/

theorem WithSeminorms.firstCountableTopology (hp : WithSeminorms p) :
    FirstCountableTopology E := by
  have := hp.isTopologicalAddGroup
  let _ : UniformSpace E := IsTopologicalAddGroup.rightUniformSpace E
  have : IsUniformAddGroup E := isUniformAddGroup_of_addCommGroup
  have : (�� (0 : E)).IsCountablyGenerated := by
    rw [p.withSeminorms_iff_nhds_eq_iInf.mp hp]
    exact Filter.iInf.isCountablyGenerated _
  have : (uniformity E).IsCountablyGenerated := IsUniformAddGroup.uniformity_countably_generated
  exact UniformSpace.firstCountableTopology E

end TopologicalProperties

Messung
CHZG
9210010097

¤ Dauer der Verarbeitung: 0.91 Sekunden  ¤

*© Formatika GbR, Deutschland