Theory Topology_ZF_1

(* 
    This file is a part of IsarMathLib - 
    a library of formalized mathematics for Isabelle/Isar.

    Copyright (C) 2005 - 2022  Slawomir Kolodynski

    This program is free software; Redistribution and use in source and binary forms, 
    with or without modification, are permitted provided that the following conditions are met:

   1. Redistributions of source code must retain the above copyright notice, 
   this list of conditions and the following disclaimer.
   2. Redistributions in binary form must reproduce the above copyright notice, 
   this list of conditions and the following disclaimer in the documentation and/or 
   other materials provided with the distribution.
   3. The name of the author may not be used to endorse or promote products 
   derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*)

section Topology 1

theory Topology_ZF_1 imports Topology_ZF

begin

textIn this theory file we study separation axioms and the notion of base and
  subbase. Using the products of open sets as a subbase we define a natural
  topology on a product of two topological spaces.

subsectionSeparation axioms

textTopological spaces cas be classified according to certain properties
  called "separation axioms". In this section we define what it means that a 
  topological space is $T_0$, $T_1$ or $T_2$.

textA topology on $X$ is $T_0$ if for every pair of distinct points of $X$
  there is an open set that contains only one of them.

definition
  isT0 ("_ {is T0}" [90] 91) where
  "T {is T0}   x y. ((x  T  y  T   xy)  
  (UT. (xU  yU)  (yU  xU)))"
    

textA topology is $T_1$ if for every such pair there exist an open set that 
  contains the first point but not the second.

definition
  isT1 ("_ {is T1}" [90] 91) where
  "T {is T1}   x y. ((x  T  y  T   xy)  
  (UT. (xU  yU)))"

text $T_1$ topological spaces are exactly those in which all singletons are closed.

lemma (in topology0) t1_def_alt:
  shows "T {is T1}  (xT. {x} {is closed in} T)"
proof
  let ?X = "T"
  assume T1: "T {is T1}"
  { fix x assume "x?X"
    let ?U = "?X-{x}"
    have "?U  T"
    proof -
      let ?W = "y?U.{VT. yV  xV}" 
      { fix y assume "y?U"
        with topSpaceAssum have "({VT. yV  xV})  T"
          unfolding IsATopology_def by blast
      } hence "y?U. ({VT. yV  xV})  T" by blast
      with topSpaceAssum have "?WT" by (rule union_indexed_open)
      have "?U = ?W"
      proof
        show "?W?U" by auto
        { fix y assume "y?U"
          hence "y?X" and "yx" by auto
          with T1 x?X have  "y  {VT. yV  xV}"
            unfolding isT1_def by blast
          hence "y?W" by blast
        } thus "?U  ?W" by blast
      qed
      with ?WT show "?UT" by simp
    qed
    with x?X have "(?X-?U) {is closed in} T" and "?X-?U = {x}"
      using Top_3_L9 by auto
    hence "{x} {is closed in} T" by simp
  } thus "x?X. {x} {is closed in} T" by blast
next
  let ?X = "T" 
  assume scl: "xT. {x} {is closed in} T"
  { fix x y assume "x?X" "y?X" "xy"
    let ?U = "?X-{y}"
    from scl x?X y?X xy have "?U  T" "x?U  y?U"
      unfolding IsClosed_def by auto
    then have "UT. (xU  yU)" by (rule witness_exists)
  } then show "T {is T1}" unfolding isT1_def by blast
qed

textA topology is $T_2$ (Hausdorff) if for every pair of points there exist a 
  pair of disjoint open sets each containing one of the points. 
  This is an important class of topological spaces. In particular, metric 
  spaces are Hausdorff.

definition
  isT2 ("_ {is T2}" [90] 91) where
  "T {is T2}   x y. ((x  T  y  T   xy) 
  (UT. VT. xU  yV  UV=0))"

textA topology is regular if every closed set can be separated from a point in its complement
  by (disjoint) opens sets.

definition
  IsRegular ("_ {is regular}" 90)
  where "T {is regular}  D. D {is closed in} T  (xT-D.UT.VT. DUxVUV=0)"

textSome sources (e.g. Metamath) use a different definition of regularity: 
  any open neighborhood has a closed subneighborhood. The next lemma shows the equivalence
  of this with our definition.

lemma is_regular_def_alt: assumes "T {is a topology}" 
  shows "T {is regular}  (WT. xW. VT. xV  Closure(V,T)W)"
proof 
  let ?X = "T"
  from assms(1) have cntx: "topology0(T)"
    unfolding topology0_def by simp
  assume "T {is regular}"
  { fix W x assume "WT" "xW"
    have "VT. xV  Closure(V,T)W"
    proof -
      let ?D = "?X-W"
      from cntx WT T {is regular} xW
      have "UT.VT. ?DUxVUV=0"
        using topology0.Top_3_L9 unfolding IsRegular_def by auto
      then obtain U V where "UT" "VT" "?DU" "xV" "VU=0"
        by blast
      from cntx VT have "Closure(V,T)  ?X"
        using topology0.Top_3_L11(1) by blast      
      from cntx VT UT VU=0 ?DU
      have "Closure(V,T)  ?D = 0"
        using topology0.disj_open_cl_disj by blast
      with Closure(V,T)  ?X VT xV show ?thesis
        by blast
    qed
  } thus "WT. xW. VT. xV  Closure(V,T)W"
    by simp
next
  let ?X = "T"
  from assms(1) have cntx: "topology0(T)"
    unfolding topology0_def by simp
  assume regAlt: "WT. xW. VT. xV  Closure(V,T)W"
  { fix A assume "A {is closed in} T"
    have "x?X-A.UT.VT. AU  xV  UV=0"
    proof -
      { let ?W = "?X-A"
        from A {is closed in} T have "A?X" and "?WT"
          unfolding IsClosed_def by auto
        fix x assume "x?W"
        with regAlt ?WT have "VT. xV  Closure(V,T)?W"
          by simp
        then obtain V where "VT" "xV" "Closure(V,T)?W"
          by auto
        let ?U = "?X-Closure(V,T)"        
        from cntx VT have "V?X" and "VClosure(V,T)" 
          using topology0.cl_contains_set by auto
        with cntx A?X Closure(V,T)?W
        have "?UT" "A?U" "?UV = 0"
          using topology0.cl_is_closed(2) by auto
        with VT xV have "UT.VT. AU  xV  UV=0"
          by blast
      } thus ?thesis by blast
    qed
  } then show "T {is regular}" unfolding IsRegular_def 
    by blast
qed

textIf a topology is $T_1$ then it is $T_0$. 
  We don't really assume here that $T$ is a topology on $X$. 
  Instead, we prove the relation between isT0 condition and isT1.

lemma T1_is_T0: assumes A1: "T {is T1}" shows "T {is T0}"
proof -
  from A1 have " x y. x  T  y  T  xy  
    (UT. xU  yU)"
    using isT1_def by simp
  then have " x y. x  T  y  T  xy  
    (UT. xU  yU  yU  xU)"
    by auto
  then show "T {is T0}" using isT0_def by simp
qed

textIf a topology is $T_2$ then it is $T_1$.

lemma T2_is_T1: assumes A1: "T {is T2}" shows "T {is T1}"
proof -
  { fix x y assume "x  T"  "y  T"  "xy"
    with A1 have "UT. VT. xU  yV  UV=0"
      using isT2_def by auto
    then have "UT. xU  yU" by auto
  } then have " x y. x  T  y  T   xy  
      (UT. xU  yU)" by simp
  then show "T {is T1}" using isT1_def by simp
qed

textIn a $T_0$ space two points that can not be separated 
  by an open set are equal. Proof by contradiction.

lemma Top_1_1_L1: assumes A1: "T {is T0}" and A2: "x  T"  "y  T"
  and A3: "UT. (xU  yU)" 
  shows "x=y"
proof -
  { assume "xy"
    with A1 A2 have "UT. xU  yU  yU  xU"
      using isT0_def by simp
    with A3 have False by auto
  } then show "x=y" by auto
qed

subsectionBases and subbases

textSometimes it is convenient to talk about topologies in terms of their bases
  and subbases. These are certain collections of open sets that define
  the whole topology.

textA base of topology is a collection of open sets such that every 
  open set is a union of the sets from the base.

definition
  IsAbaseFor (infixl "{is a base for}" 65) where 
  "B {is a base for} T  BT  T = {A. APow(B)}"

textA subbase is a collection 
  of open sets such that finite intersection of those sets form a base.

definition
  IsAsubBaseFor (infixl "{is a subbase for}" 65) where
  "B {is a subbase for} T  
  B  T  {A. A  FinPow(B)} {is a base for} T"

textBelow we formulate a condition that we will prove to be necessary and 
  sufficient for a collection $B$ of open sets to form a base. 
  It says that for any two sets $U,V$ from the collection $B$ we can
  find a point $x\in U\cap V$ with a neighboorhod 
  from $B$ contained in $U\cap V$.

definition
  SatisfiesBaseCondition ("_ {satisfies the base condition}" [50] 50)
  where
  "B {satisfies the base condition}  
  U V. ((UB  VB)  (x  UV. WB. xW  W  UV))"

textA collection that is closed with respect to intersection
  satisfies the base condition.

lemma inter_closed_base: assumes "UB.(VB. UV  B)"
  shows  "B {satisfies the base condition}" 
proof -
    { fix U V x assume "UB" and "VB" and "x  UV"
      with assms have "WB. xW  W  UV" by blast
    } then show ?thesis using SatisfiesBaseCondition_def by simp
qed

textEach open set is a union of some sets from the base.

lemma Top_1_2_L1: assumes "B {is a base for} T"  and "UT" 
  shows "APow(B). U = A"
  using assms IsAbaseFor_def by simp

textElements of base are open.

lemma base_sets_open: 
  assumes "B {is a base for} T" and "U  B"
  shows "U  T"
  using assms IsAbaseFor_def by auto

textA base defines topology uniquely.

lemma same_base_same_top: 
  assumes "B {is a base for} T" and "B {is a base for} S" 
  shows "T = S"
  using assms IsAbaseFor_def by simp

textEvery point from an open set has a neighboorhood from the base
  that is contained in the set.

lemma point_open_base_neigh: 
  assumes A1: "B {is a base for} T" and A2: "UT" and A3: "xU"
  shows "VB. VU  xV"
proof -
  from A1 A2 obtain A where "A  Pow(B)" and "U = A"
    using Top_1_2_L1 by blast
  with A3 obtain V where "VA" and "xV" by auto
  with A  Pow(B) U = A show ?thesis by auto
qed

textA criterion for a collection to be a base for a topology
  that is a slight reformulation of the definition. The only thing
  different that in the definition is that we assume only that
  every open set is a union of some sets from the base. The definition
  requires also the opposite inclusion that every union of the 
  sets from the base is open, but that we can prove if we assume that
  $T$ is a topology.

lemma is_a_base_criterion: assumes A1: "T {is a topology}"
  and A2: "B  T" and A3: "V  T. A  Pow(B). V = A"
  shows "B {is a base for} T"
proof -
  from A3 have "T  {A. APow(B)}" by auto
  moreover have "{A. APow(B)}  T"
  proof
    fix U assume "U  {A. APow(B)}"
    then obtain A where "A  Pow(B)" and "U = A"
      by auto
    with B  T have "A  Pow(T)" by auto
    with A1 U = A show "U  T"
      unfolding IsATopology_def by simp
  qed
  ultimately have "T = {A. APow(B)}" by auto
  with A2 show "B {is a base for} T" 
    unfolding IsAbaseFor_def by simp
qed
    
textA necessary condition for a collection of sets to be a base for some 
  topology : every point in the intersection
  of two sets in the base has a neighboorhood from the base contained
  in the intersection.

lemma Top_1_2_L2: 
  assumes A1:"T. T {is a topology}  B {is a base for} T"
  and A2: "VB"  "WB"
  shows " x  VW. UB. xU  U  V  W"
proof -
  from A1 obtain T where 
    D1: "T {is a topology}"   "B {is a base for} T"
    by auto
  then have "B  T" using IsAbaseFor_def by auto
  with A2 have "VT" and "WT" using IsAbaseFor_def by auto
  with D1 have "APow(B). VW = A" using IsATopology_def Top_1_2_L1
    by auto
  then obtain A where "A  B" and "V  W = A" by auto
  then show " x  VW. UB. (xU  U  V  W)" by auto
qed

textWe will construct a topology as the collection of unions of (would-be)
  base. First we prove that if the collection of sets satisfies the 
  condition we want to show to be sufficient, the the intersection belongs
  to what we will define as topology (am I clear here?). Having this fact 
  ready simplifies the proof of the next lemma. There is not much topology
  here, just some set theory.

lemma Top_1_2_L3:
  assumes A1: "x VW . UB. xU  U  VW"
  shows "VW  {A. APow(B)}"
proof
  let ?A = "xVW. {UB. xU  U  VW}"
  show "?APow(B)" by auto
  from A1 show "VW = ?A" by blast
qed

textThe next lemma is needed when proving that the would-be topology is
  closed with respect to taking intersections. We show here that intersection
  of two sets from this (would-be) topology can be written as union of sets 
  from the topology.

lemma Top_1_2_L4:
  assumes A1:  "U1  {A. APow(B)}"   "U2  {A. APow(B)}"
  and A2: "B {satisfies the base condition}"
  shows "C. C  {A. APow(B)}  U1U2 = C"
proof -
  from A1 A2 obtain A1 A2 where 
    D1: "A1 Pow(B)"  "U1 = A1"  "A2  Pow(B)"  "U2 = A2" 
    by auto
  let ?C = "UA1.{UV. VA2}"
  from D1 have "(UA1. UB)  (VA2. VB)" by auto
  with A2 have "?C  {A . A  Pow(B)}"
    using Top_1_2_L3 SatisfiesBaseCondition_def by auto
  moreover from D1 have "U1  U2 = ?C" by auto
  ultimately show ?thesis by auto
qed

textIf $B$ satisfies the base condition, then the collection of unions
  of sets from $B$ is a topology and $B$ is a base for this topology.

theorem Top_1_2_T1:
  assumes A1: "B {satisfies the base condition}"
  and A2: "T = {A. APow(B)}"
  shows "T {is a topology}" and "B {is a base for} T"
proof -
  show "T {is a topology}"
  proof -
    have I: "CPow(T). C  T"
    proof -
      { fix C assume A3: "C  Pow(T)"
        let ?Q = " {{APow(B). U = A}. UC}"
        from A2 A3 have "UC. APow(B). U = A" by auto
        then have "?Q = C" using ZF1_1_L10 by simp
        moreover from A2 have "?Q  T" by auto
        ultimately have "C  T" by simp
      } thus "CPow(T). C  T" by auto
    qed
    moreover have "UT.  VT. UV  T"
    proof -
      { fix U V assume  "U  T"  "V  T"
        with A1 A2 have "C.(C  T  UV = C)"
        using Top_1_2_L4 by simp
        then obtain C where "C  T" and  "UV = C"
          by auto
          with I have "UV  T" by simp
      } then show "UT.  VT. UV  T" by simp
    qed
    ultimately show "T {is a topology}" using IsATopology_def
      by simp
  qed
  from A2 have "BT" by auto
  with A2 show "B {is a base for} T" using IsAbaseFor_def 
    by simp
qed

textThe carrier of the base and topology are the same.

lemma Top_1_2_L5: assumes "B {is a base for} T"
  shows "T = B"
  using assms IsAbaseFor_def by auto

textIf $B$ is a base for $T$, then $T$ is the smallest topology containing $B$.


lemma base_smallest_top: 
  assumes A1: "B {is a base for} T" and  A2: "S {is a topology}" and A3: "BS"
  shows "TS"
proof
  fix U assume "UT"
  with A1 obtain BU where "BU  B" and "U = BU" using IsAbaseFor_def by auto
  with A3 have "BU  S" by auto 
  with A2 U = BU show "US" using IsATopology_def by simp
qed

textIf $B$ is a base for $T$ and $B$ is a topology, then $B=T$.

lemma base_topology: assumes "B {is a topology}" and "B {is a base for} T"
  shows "B=T" using assms base_sets_open base_smallest_top by blast 

subsectionProduct topology

textIn this section we consider a topology defined on a product of two sets.

textGiven two topological spaces we can define a topology on the product of 
  the carriers such that the cartesian products of the sets of the topologies 
  are a base for the product topology. Recall that for two collections $S,T$ 
  of sets the product collection is defined (in ZF1.thy›) as the collections of cartesian 
  products $A\times B$, where $A\in S, B\in T$. The $T\times_tS$ notation is defined as
  an alternative to the verbose  ProductTopology(T,S)›). 

definition ProductTopology (infixl "×t" 65) where
  "T ×t S   {W. W  Pow(ProductCollection(T,S))}"

textThe product collection satisfies the base condition.

lemma Top_1_4_L1: 
  assumes A1: "T {is a topology}"   "S {is a topology}"
  and A2: "A  ProductCollection(T,S)"  "B  ProductCollection(T,S)"
  shows "x(AB). WProductCollection(T,S). (xW  W  A  B)"
proof
  fix x assume A3: "x  AB"
  from A2 obtain U1 V1 U2 V2 where 
    D1: "U1T"  "V1S"   "A=U1×V1"  "U2T"  "V2S"   "B=U2×V2"
    using ProductCollection_def by auto
  let ?W = "(U1U2) × (V1V2)"
  from A1 D1 have "U1U2  T" and "V1V2  S"
    using IsATopology_def by auto
  then have "?W  ProductCollection(T,S)" using ProductCollection_def 
    by auto
  moreover from A3 D1 have "x?W" and "?W  AB" by auto
  ultimately have "W. (W  ProductCollection(T,S)  xW  W  AB)"
    by auto
  thus "WProductCollection(T,S). (xW  W  A  B)" by auto
qed

textThe product topology is indeed a topology on the product.

theorem Top_1_4_T1: assumes A1: "T {is a topology}"  "S {is a topology}"
  shows 
  "(T×tS) {is a topology}"
  "ProductCollection(T,S) {is a base for} (T×tS)"
  "(T×tS) = T × S"
proof -
  from A1 show 
    "(T×tS) {is a topology}"
    "ProductCollection(T,S) {is a base for} (T×tS)"
    using Top_1_4_L1 ProductCollection_def 
      SatisfiesBaseCondition_def ProductTopology_def Top_1_2_T1 
    by auto
  then show "(T×tS) = T × S"
    using Top_1_2_L5 ZF1_1_L6 by simp
qed

textEach point of a set open in the product topology has a neighborhood
  which is a cartesian product of open sets.

lemma prod_top_point_neighb: 
  assumes A1: "T {is a topology}"  "S {is a topology}" and 
  A2: "U  ProductTopology(T,S)" and A3: "x  U"
  shows "V W. VT  WS  V×W  U  x  V×W"
proof -
  from A1 have 
    "ProductCollection(T,S) {is a base for} ProductTopology(T,S)"
    using Top_1_4_T1 by simp
  with A2 A3 obtain Z where 
    "Z  ProductCollection(T,S)" and "Z  U  xZ"
    using point_open_base_neigh by blast
  then obtain V W where "V  T" and "WS" and" V×W  U  x  V×W"
    using ProductCollection_def by auto
  thus ?thesis by auto
qed

textProducts of open sets are open in the product topology.

lemma prod_open_open_prod: 
  assumes A1: "T {is a topology}"  "S {is a topology}" and
  A2: "UT" "VS"
  shows "U×V  ProductTopology(T,S)"
proof -
  from A1 have 
    "ProductCollection(T,S) {is a base for} ProductTopology(T,S)"
    using Top_1_4_T1 by simp
  moreover from A2 have "U×V  ProductCollection(T,S)"
    unfolding ProductCollection_def by auto
  ultimately show "U×V  ProductTopology(T,S)"
    using base_sets_open by simp
qed

textSets that are open in the product topology are contained in the product
  of the carrier.

lemma prod_open_type: assumes A1: "T {is a topology}"  "S {is a topology}" and
  A2: "V  ProductTopology(T,S)"
  shows "V  T × S"
proof -
  from A2 have "V   ProductTopology(T,S)" by auto
  with A1 show ?thesis using Top_1_4_T1 by simp
qed

textA reverse of prod_top_point_neighb›: if each point of set has an neighborhood in the set
  that is a cartesian product of open sets, then the set is open.

lemma point_neighb_prod_top: 
  assumes "T {is a topology}"  "S {is a topology}"
  and "pV. UT.WS. pU×W  U×W  V"
shows "V  ProductTopology(T,S)"
proof -
  from assms(1,2) have I: "topology0(ProductTopology(T,S))" 
    using Top_1_4_T1(1) topology0_def by simp
  moreover 
  { fix p assume "pV"
    with assms(3) obtain U W where "UT" "WS" "pU×W" "U×W  V"
      by auto
    with assms(1,2) have "NProductTopology(T,S). pN  NV"
      using prod_open_open_prod by auto
  } hence "pV. NProductTopology(T,S). pN  NV" by blast
  ultimately show ?thesis using topology0.open_neigh_open by simp
qed

textSuppose we have subsets $A\subseteq X, B\subseteq Y$, where
  $X,Y$ are topological spaces with topologies $T,S$. We can the consider
  relative topologies on $T_A, S_B$ on sets $A,B$ and the collection
  of cartesian products of sets open in $T_A, S_B$, (namely 
  $\{U\times V: U\in T_A, V\in S_B\}$. The next lemma states that
  this collection is a base of the product topology on $X\times Y$
  restricted to the product $A\times B$.

lemma prod_restr_base_restr:
  assumes A1: "T {is a topology}"  "S {is a topology}"
  shows 
  "ProductCollection(T {restricted to} A, S {restricted to} B)
  {is a base for} (ProductTopology(T,S) {restricted to} A×B)"
proof -
  let ?ℬ = "ProductCollection(T {restricted to} A, S {restricted to} B)"
  let  = "ProductTopology(T,S)"
  from A1 have "( {restricted to} A×B) {is a topology}"
    using Top_1_4_T1 topology0_def topology0.Top_1_L4
    by simp
  moreover have "?ℬ  ( {restricted to} A×B)"
  proof
    fix U assume "U  ?ℬ"
    then obtain UA UB where "U = UA × UB" and
      "UA  (T {restricted to} A)" and "UB  (S {restricted to} B)"
      using ProductCollection_def by auto
    then obtain WA WB where 
      "WA  T"  "UA = WA  A" and "WB  S"  "UB = WB  B"
      using RestrictedTo_def by auto
    with U = UA × UB have "U = WA×WB  (A×B)" by auto
    moreover from A1 WA  T and WB  S have "WA×WB  "
      using prod_open_open_prod by simp
    ultimately show "U   {restricted to} A×B"
      using RestrictedTo_def by auto
  qed
  moreover have "U   {restricted to} A×B.
    C  Pow(?ℬ). U = C"
  proof
    fix U assume "U   {restricted to} A×B"
    then obtain W where "W  " and "U = W  (A×B)"
      using RestrictedTo_def by auto
    from A1 W   obtain AW  where 
      "AW  Pow(ProductCollection(T,S))" and "W = AW"
       using Top_1_4_T1 IsAbaseFor_def by auto
    let ?C = "{V  A×B. V  AW}" 
    have "?C  Pow(?ℬ)" and "U = ?C"
    proof -
      { fix R assume "R  ?C"
	then obtain V where "V  AW" and "R = V  A×B"
	  by auto
	with AW  Pow(ProductCollection(T,S)) obtain VT VS where 
	  "VT  T" and "VS  S" and "V = VT × VS"
	  using ProductCollection_def by auto
	with R = V  A×B have "R  ?ℬ"
	  using ProductCollection_def RestrictedTo_def
	  by auto
      } then show "?C  Pow(?ℬ)" by auto
      from U = W  (A×B) and W = AW
      show "U = ?C" by auto
    qed
    thus "C  Pow(?ℬ). U = C" by blast
  qed
  ultimately show ?thesis by (rule is_a_base_criterion)
qed
    
textWe can commute taking restriction (relative topology) and
  product topology. The reason the two topologies are the same is
  that they have the same base.

lemma prod_top_restr_comm: 
  assumes A1: "T {is a topology}"  "S {is a topology}"
  shows
  "ProductTopology(T {restricted to} A,S {restricted to} B) =
  ProductTopology(T,S) {restricted to} (A×B)"
proof -
  let ?ℬ = "ProductCollection(T {restricted to} A, S {restricted to} B)"
  from A1 have
    "?ℬ {is a base for} ProductTopology(T {restricted to} A,S {restricted to} B)"
    using topology0_def topology0.Top_1_L4 Top_1_4_T1 by simp
  moreover from A1 have 
    "?ℬ {is a base for} ProductTopology(T,S) {restricted to} (A×B)"
    using prod_restr_base_restr by simp
  ultimately show ?thesis by (rule same_base_same_top)
qed

textProjection of a section of an open set is open.

lemma prod_sec_open1: assumes A1: "T {is a topology}"  "S {is a topology}" and
  A2: "V  ProductTopology(T,S)" and A3: "x  T"
  shows "{y  S. x,y  V}  S"
proof -
  let ?A = "{y  S. x,y  V}"
  from A1 have "topology0(S)" using topology0_def by simp
  moreover have "y?A.WS. (yW  W?A)"
    proof
      fix y assume "y  ?A"
      then have "x,y  V" by simp
      with A1 A2 have "x,y  T × S" using prod_open_type by blast
      hence "x  T" and "y  S" by auto
      from A1 A2 x,y  V have "U W. UT  WS  U×W  V  x,y  U×W"
        by (rule prod_top_point_neighb)
      then obtain U W where  "UT" "WS" "U×W  V" "x,y  U×W"
        by auto
      with A1 A2 show "WS. (yW  W?A)" using prod_open_type section_proj
        by auto
    qed
  ultimately show ?thesis by (rule topology0.open_neigh_open)
qed

textProjection of a section of an open set is open. This is dual of 
prod_sec_open1› with a very similar proof.

lemma prod_sec_open2: assumes A1: "T {is a topology}"  "S {is a topology}" and
  A2: "V  ProductTopology(T,S)" and A3: "y  S"
  shows "{x  T. x,y  V}  T"
proof -
  let ?A = "{x  T. x,y  V}"
  from A1 have "topology0(T)" using topology0_def by simp
  moreover have "x?A.WT. (xW  W?A)"
    proof
      fix x assume "x  ?A"
      then have "x,y  V" by simp
      with A1 A2 have "x,y  T × S" using prod_open_type by blast
      hence "x  T" and "y  S" by auto
      from A1 A2 x,y  V have "U W. UT  WS  U×W  V  x,y  U×W"
        by (rule prod_top_point_neighb)
      then obtain U W where  "UT" "WS" "U×W  V" "x,y  U×W"
        by auto
      with A1 A2 show "WT. (xW  W?A)" using prod_open_type section_proj
        by auto
    qed
  ultimately show ?thesis by (rule topology0.open_neigh_open)
qed

subsectionHausdorff spaces

textIn this section we study properties of Hausdorff spaces (sometimes called separated spaces) 
  These are topological spaces that are $T_2$ as defined above.

textA space is Hausdorff if and only if the diagonal $\Delta = \{\langle x,x\rangle : x\in X\}$
  is closed in the product topology on $X\times X$. 

theorem t2_iff_diag_closed: assumes "T {is a topology}"
  shows "T {is T2}  {x,x. xT} {is closed in} ProductTopology(T,T)"
proof
  let ?X = "T"
  from assms(1) have I: "topology0(ProductTopology(T,T))" 
    using Top_1_4_T1(1) topology0_def by simp
  assume "T {is T2}" show "{x,x. x?X} {is closed in} ProductTopology(T,T)"
  proof -
    let ?Dc = "?X×?X - {x,x. x?X}"
    have "p?Dc.UT.VT. pU×V  U×V  ?Dc"
    proof -
      { fix p assume "p?Dc"
        then obtain x y where "p=x,y" "x?X" "y?X" "xy" by auto
        with T {is T2} obtain U V where "UT" "VT" "xU" "yV" "UV = 0"
          unfolding isT2_def by blast
        with assms p=x,y have "UT.VT. pU×V  U×V  ?Dc" by auto
      } hence "p. p?Dc  (UT.VT. pU×V  U×V  ?Dc)" by simp
      then show ?thesis by (rule exists_in_set)
    qed
    with assms show ?thesis using Top_1_4_T1(3) point_neighb_prod_top 
      unfolding IsClosed_def by auto
  qed
next
  let ?X = "T"
  assume A: "{x,x. x?X} {is closed in} ProductTopology(T,T)" show "T {is T2}"
  proof -
    { let ?Dc = "?X×?X - {x,x. x?X}"
      fix x y assume "x?X" "y?X" "xy" 
      with assms A have "?Dc  ProductTopology(T,T)" and "x,y  ?Dc"
        using Top_1_4_T1(3) unfolding IsClosed_def by auto
      with assms obtain U V where "UT" "VT" "U×V  ?Dc" "x,y  U×V"
        using prod_top_point_neighb by blast
      moreover from U×V  ?Dc have "UV = 0" by auto
      ultimately have "UT.VT. xU  yV  UV=0" by auto
    } then show "T {is T2}" unfolding isT2_def by simp
  qed
qed

end