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

Quelle  WithTopology.lean   Sprache: Lean

 

/-
Copyright (c) 2026 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/

module

public import Mathlib.Topology.Defs.Induced

/-!
# Basic lemmas and instances about the `WithTopology` type synonym

`WithTopology X t` is a copy of `X` equipped with the topology `t`.
This is useful for providing multiple topologies on the same type
without causing instance conflicts.

In this file we setup basic API about this type
and transfer instances (basic, order) from `X` to `WithTopology X t`.

## Implementation notes

The pattern here is the same one as is used by `Lex` for order structures
and `WithLp` for metric structures.
-/


public section

variable {X : Type*} (t : TopologicalSpace X)

namespace WithTopology

lemma ofTopology_toTopology (x : X) : ofTopology (toTopology t x) = x := rfl

@[simp]
lemma toTopology_ofTopology (x : WithTopology X t) :
  toTopology t (ofTopology x) = x := rfl

lemma ofTopology_surjective : Function.Surjective (ofTopology (t := t)) :=
  Function.RightInverse.surjective <| ofTopology_toTopology _

lemma toTopology_surjective : Function.Surjective (toTopology t) :=
  Function.RightInverse.surjective <| toTopology_ofTopology _

lemma ofTopology_injective : Function.Injective (ofTopology (t := t)) :=
  Function.LeftInverse.injective <| toTopology_ofTopology _

lemma toTopology_injective : Function.Injective (toTopology t) :=
  Function.LeftInverse.injective <| ofTopology_toTopology _

lemma ofTopology_bijective : Function.Bijective (ofTopology (t := t)) :=
  ⟨ofTopology_injective t, ofTopology_surjective t⟩

lemma toTopology_bijective : Function.Bijective (toTopology t) :=
  ⟨toTopology_injective t, toTopology_surjective t⟩

/-- Injectivity lemma for the constructor `toTopology t`.

It is not marked as `@[simp]`, because its autogenerated version
is already in the default `simp` set. -/

lemma toTopology_inj {x y : X} : toTopology t x = toTopology t y ↔ x = y :=
  (toTopology_injective t).eq_iff

@[simp] lemma ofTopology_inj {x y : WithTopology X t} : ofTopology x = ofTopology y ↔ x = y :=
  (ofTopology_injective t).eq_iff

open scoped Topology

lemma isOpen_iff {s : Set (WithTopology X t)} :
    IsOpen s ↔ IsOpen[t] (toTopology t ⁻¹' s) :=
  .rfl

lemma isClosed_iff {s : Set (WithTopology X t)} :
    IsClosed s ↔ IsClosed[t] (toTopology t ⁻¹' s) := by
  simp [← isOpen_compl_iff, isOpen_iff]

/-- If `X` is equipped with topology `t`, the map `X → WithTopology X t` is continuous. -/
lemma continuous_toTopology : Continuous[t, _] (toTopology t) :=
  ⟨fun _ ↦ (·)⟩

/-- If `X` is equipped with topology `t`, the map `WithTopology X t → X` is continuous. -/
lemma continuous_ofTopology : Continuous[_, t] (ofTopology (t := t)) :=
  ⟨fun _ ↦ (·)⟩

/-! ### Set-theoretic lemmas -/

open Set

lemma image_ofTopology (s : Set (WithTopology X t)) : ofTopology '' s = toTopology t ⁻¹' s :=
  WithTopology.equiv X t |>.symm.image_symm_eq_preimage _

lemma preimage_toTopology (s : Set (WithTopology X t)) : toTopology t ⁻¹' s = ofTopology '' s :=
  (image_ofTopology t s).symm

lemma image_toTopology (s : Set X) : toTopology t '' s = ofTopology ⁻¹' s :=
  WithTopology.equiv X t |>.symm.image_eq_preimage_symm _

lemma preimage_ofTopology (s : Set X) : ofTopology ⁻¹' s = toTopology t '' s :=
  (image_toTopology t s).symm

/-!
### Instance transfers

In this section we transfer some instances from `X` to `WithTopology X t`.
-/


instance [Nonempty X] : Nonempty (WithTopology X t) :=
  (WithTopology.equiv X t).nonempty

instance [Inhabited X] : Inhabited (WithTopology X t) :=
  ⟨toTopology t default⟩

instance [Subsingleton X] : Subsingleton (WithTopology X t) :=
  (WithTopology.equiv X t).subsingleton

instance [Unique X] : Unique (WithTopology X t) := .mk' _

instance [Finite X] : Finite (WithTopology X t) := .of_equiv _ (WithTopology.equiv X t).symm

instance [Infinite X] : Infinite (WithTopology X t) := .of_injective _ <| toTopology_injective _

instance [Fintype X] : Fintype (WithTopology X t) :=
  .ofBijective (.toTopology t) (toTopology_bijective t)

deriving instance DecidableEq for WithTopology

instance [LE X] : LE (WithTopology X t) where
  le x y := ofTopology x ≤ ofTopology y

instance [LT X] : LT (WithTopology X t) where
  lt x y := ofTopology x < ofTopology y

-- TODO: `inferInstance` works here, but it shouldn't
instance [LE X] [DecidableLE X] : DecidableLE (WithTopology X t) := fun x y ↦
  inferInstanceAs (Decidable (x.ofTopology ≤ y.ofTopology))

-- TODO: `inferInstance` works here, but it shouldn't
instance [LT X] [DecidableLT X] : DecidableLT (WithTopology X t) := fun x y ↦
  inferInstanceAs (Decidable (x.ofTopology < y.ofTopology))

instance [Preorder X] : Preorder (WithTopology X t) :=
  .lift ofTopology

instance [PartialOrder X] : PartialOrder (WithTopology X t) :=
  ofTopology_injective t |>.partialOrder _ .rfl .rfl

@[to_dual]
instance [Max X] : Max (WithTopology X t) where
  max x y := toTopology t (max x.ofTopology y.ofTopology)

@[to_dual]
instance [SemilatticeSup X] : SemilatticeSup (WithTopology X t) :=
  ofTopology_injective t |>.semilatticeSup _ .rfl .rfl fun _ _ ↦ rfl

instance [Lattice X] : Lattice (WithTopology X t) where

instance [DistribLattice X] : DistribLattice (WithTopology X t) where
  le_sup_inf _ _ _ := le_sup_inf (α := X)

instance [Ord X] : Ord (WithTopology X t) where
  compare x y := compare x.ofTopology y.ofTopology

instance [LinearOrder X] : LinearOrder (WithTopology X t) :=
  ofTopology_injective t |>.linearOrder _ .rfl .rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl)

end WithTopology

Messung
CHZG
9010010096

¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet am  2026-11-24) ¤

*© Formatika GbR, Deutschland