Theory TopologicalGroup_ZF

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

    Copyright (C) 2009-2020  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 Topological groups - introduction

theory TopologicalGroup_ZF imports Topology_ZF_3 Group_ZF_1 Semigroup_ZF

begin

textThis theory is about the first subject of algebraic topology:
  topological groups.

subsectionTopological group: definition and notation

textTopological group is a group that is a topological space 
  at the same time. This means that a topological group is a triple of sets, 
  say $(G,f,T)$ such that $T$ is a topology on $G$, $f$ is a group 
  operation on $G$ and both $f$ and the operation of taking inverse in $G$ 
  are continuous. Since IsarMathLib defines topology without using the carrier,
  (see Topology_ZF›), in our setup we just use $\bigcup T$ instead
  of $G$ and say that the  pair of sets $(\bigcup T , f)$ is a group.
  This way our definition of being a topological group is a statement about two
  sets: the topology $T$ and the group operation $f$ on $G=\bigcup T$.
  Since the domain of the group operation is $G\times G$, the pair of 
  topologies in which $f$ is supposed to be continuous is $T$ and
  the product topology on $G\times G$ (which we will call $\tau$ below).

textThis way we arrive at the following definition of a predicate that
  states that pair of sets is a topological group.

definition
  "IsAtopologicalGroup(T,f)  (T {is a topology})  IsAgroup(T,f) 
  IsContinuous(ProductTopology(T,T),T,f)  
  IsContinuous(T,T,GroupInv(T,f))"

textWe will inherit notation from the topology0› locale. That locale assumes that
  $T$ is a topology. For convenience we will denote $G=\bigcup T$ and $\tau$ to be 
  the product topology on $G\times G$. To that we add some
  notation specific to groups. We will use additive notation
  for the group operation, even though we don't assume that the group is abelian.
  The notation $g+A$ will mean the left translation of the set $A$ by element $g$, i.e.
  $g+A=\{g+a|a\in A\}$.
  The group operation $G$ induces a natural operation on the subsets of $G$
  defined as $\langle A,B\rangle \mapsto \{x+y | x\in A, y\in B \}$.
  Such operation has been considered in func_ZF› and called 
  $f$ ''lifted to subsets of'' $G$. We will denote the value of such operation 
  on sets $A,B$ as $A+B$.
  The set of neigboorhoods of zero (denoted 𝒩0) is the 
  collection of (not necessarily open) sets whose interior contains the neutral
  element of the group.

locale topgroup = topology0 +

  fixes G
  defines G_def [simp]: "G  T"

  fixes prodtop ("τ")
  defines prodtop_def [simp]: "τ  ProductTopology(T,T)"

  fixes f

  assumes Ggroup: "IsAgroup(G,f)"

  assumes fcon: "IsContinuous(τ,T,f)"

  assumes inv_cont: "IsContinuous(T,T,GroupInv(G,f))"

  fixes grop (infixl "\<ra>" 90)
  defines grop_def [simp]: "x\<ra>y  f`x,y"

  fixes grinv ("\<rm> _" 89)
  defines grinv_def [simp]: "(\<rm>x)  GroupInv(G,f)`(x)"

  fixes grsub (infixl "\<rs>" 90)
  defines grsub_def [simp]: "x\<rs>y  x\<ra>(\<rm>y)"

  fixes setinv ("\<sm> _" 72)
  defines setninv_def [simp]: "\<sm>A  GroupInv(G,f)``(A)"

  fixes ltrans (infix "\<ltr>" 73)
  defines ltrans_def [simp]: "x \<ltr> A  LeftTranslation(G,f,x)``(A)"

  fixes rtrans (infix "\<rtr>" 73)
  defines rtrans_def [simp]: "A \<rtr> x  RightTranslation(G,f,x)``(A)"

  fixes setadd (infixl "\<sad>" 71)
  defines setadd_def [simp]: "A\<sad>B  (f {lifted to subsets of} G)`A,B"

  fixes gzero ("𝟬")
  defines gzero_def [simp]: "𝟬  TheNeutralElement(G,f)"

  fixes zerohoods ("𝒩0")
  defines zerohoods_def [simp]: "𝒩0  {A  Pow(G). 𝟬  int(A)}"

  fixes listsum (" _" 70)
  defines listsum_def[simp]: "k  Fold1(f,k)"

textThe first lemma states that we indeeed talk about topological group
  in the context of topgroup› locale.

lemma (in topgroup) topGroup: shows "IsAtopologicalGroup(T,f)"
  using topSpaceAssum Ggroup fcon inv_cont IsAtopologicalGroup_def 
  by simp

textIf a pair of sets $(T,f)$ forms a topological group, then
 all theorems proven in the topgroup› context are valid as applied to 
 $(T,f)$.

lemma topGroupLocale: assumes "IsAtopologicalGroup(T,f)"
  shows "topgroup(T,f)"
  using assms IsAtopologicalGroup_def topgroup_def 
    topgroup_axioms.intro topology0_def by simp

textWe can use the group0› locale in the context of topgroup›.

lemma (in topgroup) group0_valid_in_tgroup: shows "group0(G,f)"
  using Ggroup group0_def by simp

textWe can use the group0› locale in the context of topgroup›.

sublocale topgroup < group0 G f gzero grop grinv 
    unfolding group0_def gzero_def grop_def grinv_def using Ggroup by auto

textWe can use semigr0› locale in the context of topgroup›.

lemma (in topgroup) semigr0_valid_in_tgroup: shows "semigr0(G,f)"
  using Ggroup IsAgroup_def IsAmonoid_def semigr0_def by simp 

textWe can use the prod_top_spaces0› locale in the context of topgroup›.

lemma (in topgroup) prod_top_spaces0_valid: shows "prod_top_spaces0(T,T,T)"
  using topSpaceAssum prod_top_spaces0_def by simp

textNegative of a group element is in group.

lemma (in topgroup) neg_in_tgroup: assumes "gG" shows "(\<rm>g)  G"
  using assms inverse_in_group by simp

textSum of two group elements is in the group.

lemma (in topgroup) group_op_closed_add:  assumes "x1  G"  "x2  G"
  shows "x1\<ra>x2  G" 
  using assms group_op_closed by simp

textZero is in the group.

lemma (in topgroup) zero_in_tgroup: shows "𝟬G"
  using group0_2_L2 by simp

text Another lemma about canceling with two group elements written in additive notation 

lemma (in topgroup) inv_cancel_two_add: 
  assumes "x1  G"  "x2  G" 
  shows 
    "x1\<ra>(\<rm>x2)\<ra>x2 = x1"
    "x1\<ra>x2\<ra>(\<rm>x2) = x1"
    "(\<rm>x1)\<ra>(x1\<ra>x2) = x2"
    "x1\<ra>((\<rm>x1)\<ra>x2) = x2"
  using assms inv_cancel_two by auto

textUseful identities proven in the Group_ZF› theory, rewritten here in additive notation.
  Note since the group operation notation is left associative we don't really need the first set
  of parentheses in some cases.

lemma (in topgroup) cancel_middle_add: assumes "x1  G"  "x2  G"  "x3  G"
  shows 
    "(x1\<ra>(\<rm>x2))\<ra>(x2\<ra>(\<rm>x3)) = x1\<ra> (\<rm>x3)"
    "((\<rm>x1)\<ra>x2)\<ra>((\<rm>x2)\<ra>x3) = (\<rm>x1)\<ra> x3" 
    "(\<rm> (x1\<ra>x2)) \<ra> (x1\<ra>x3) = (\<rm>x2)\<ra>x3"
    "(x1\<ra>x2) \<ra> (\<rm>(x3\<ra>x2)) =x1\<ra> (\<rm>x3)"
    "(\<rm>x1) \<ra> (x1\<ra>x2\<ra>x3) \<ra> (\<rm>x3) = x2"
proof - 
  from assms have "x1\<ra> (\<rm>x3) = (x1\<ra>(\<rm>x2))\<ra>(x2\<ra>(\<rm>x3))"
    using group0_2_L14A(1) by blast
  thus "(x1\<ra>(\<rm>x2))\<ra>(x2\<ra>(\<rm>x3)) = x1\<ra> (\<rm>x3)" by simp
  from assms have "(\<rm>x1)\<ra> x3 = ((\<rm>x1)\<ra>x2)\<ra>((\<rm>x2)\<ra>x3)"
    using group0_2_L14A(2) by blast
  thus "((\<rm>x1)\<ra>x2)\<ra>((\<rm>x2)\<ra>x3) = (\<rm>x1)\<ra> x3" by simp
  from assms show "(\<rm> (x1\<ra>x2)) \<ra> (x1\<ra>x3) = (\<rm>x2)\<ra>x3"
    using cancel_middle(1) by simp
  from assms show "(x1\<ra>x2) \<ra> (\<rm>(x3\<ra>x2)) =x1\<ra> (\<rm>x3)"
    using cancel_middle(2) by simp
  from assms show "(\<rm>x1) \<ra> (x1\<ra>x2\<ra>x3) \<ra> (\<rm>x3) = x2"
    using cancel_middle(3) by simp
qed

text We can cancel an element on the right from both sides of an equation. 

lemma (in topgroup) cancel_right_add: 
  assumes "x1  G"  "x2  G"  "x3  G" "x1\<ra>x2 = x3\<ra>x2" 
  shows "x1 = x3"
  using assms cancel_right by simp

text We can cancel an element on the left from both sides of an equation. 

lemma (in topgroup) cancel_left_add: 
  assumes "x1  G"  "x2  G"  "x3  G" "x1\<ra>x2 = x1\<ra>x3" 
  shows "x2 = x3"
  using assms cancel_left by simp

textWe can put an element on the other side of an equation.

lemma (in topgroup) put_on_the_other_side: 
  assumes "x1  G"  "x2  G" "x3 = x1\<ra>x2"
  shows "x3\<ra>(\<rm>x2) = x1" and "(\<rm>x1)\<ra>x3 = x2" 
  using assms group0_2_L18 by auto 

textA simple equation from lemma simple_equation0› in Group_ZF› in additive notation 

lemma (in topgroup) simple_equation0_add: 
  assumes "x1  G"  "x2  G"  "x3  G" "x1\<ra>(\<rm>x2) = (\<rm>x3)"
  shows "x3 = x2 \<ra> (\<rm>x1)"
  using assms simple_equation0 by blast

textA simple equation from lemma simple_equation1› in Group_ZF› in additive notation 

lemma (in topgroup) simple_equation1_add: 
  assumes "x1  G"  "x2  G"  "x3  G" "(\<rm>x1)\<ra>x2 = (\<rm>x3)"
  shows "x3 = (\<rm>x2) \<ra> x1"
  using assms simple_equation1 by blast

textThe set comprehension form of negative of a set. The proof uses the ginv_image› lemma from 
  Group_ZF› theory which states the same thing in multiplicative notation. 

lemma (in topgroup) ginv_image_add: assumes "VG" 
  shows "(\<sm>V)G" and "(\<sm>V) = {\<rm>x. x  V}" 
  using assms ginv_image by auto

text The additive notation version of ginv_image_el› lemma from Group_ZF› theory 

lemma (in topgroup) ginv_image_el_add: assumes "VG" "x  (\<sm>V)"
  shows "(\<rm>x)  V"
  using assms ginv_image_el by simp

textOf course the product topology is a topology (on $G\times G$).

lemma (in topgroup) prod_top_on_G:
  shows "τ {is a topology}" and "τ = G×G"
  using topSpaceAssum Top_1_4_T1 by auto

textLet's recall that $f$ is a binary operation on $G$ in this context.

lemma (in topgroup) topgroup_f_binop: shows "f : G×G  G"
  using Ggroup group0_def group0.group_oper_fun by simp

textA subgroup of a topological group is a topological group 
  with relative topology
  and restricted operation. Relative topology is the same
  as T {restricted to} H›
  which is defined to be $\{V \cap H: V\in T\}$ in ZF1› theory.

lemma (in topgroup) top_subgroup: assumes A1: "IsAsubgroup(H,f)"
  shows "IsAtopologicalGroup(T {restricted to} H,restrict(f,H×H))"
proof -
  let 0 = "T {restricted to} H"
  let ?fH = "restrict(f,H×H)"
  have "0 = G  H" using union_restrict by simp
  also from A1 have " = H" 
    using group0_3_L2 by blast
  finally have "0 = H" by simp
  have "0 {is a topology}" using Top_1_L4 by simp
  moreover from A1 0 = H have "IsAgroup(0,?fH)"
    using IsAsubgroup_def by simp
  moreover have "IsContinuous(ProductTopology(0,0),0,?fH)"
  proof -
    have "two_top_spaces0(τ, T,f)"
      using topSpaceAssum prod_top_on_G topgroup_f_binop prod_top_on_G
	two_top_spaces0_def by simp
    moreover 
    from A1 have "H  G" using group0_3_L2 by simp
    then have "H×H  τ" using prod_top_on_G by auto
    moreover have "IsContinuous(τ,T,f)" using fcon by simp
    ultimately have 
      "IsContinuous(τ {restricted to} H×H, T {restricted to} ?fH``(H×H),?fH)" using two_top_spaces0.restr_restr_image_cont
      by simp
    moreover have
      "ProductTopology(0,0) = τ {restricted to} H×H" using topSpaceAssum prod_top_restr_comm
      by simp
    moreover from A1 have "?fH``(H×H) = H" using image_subgr_op
      by simp
    ultimately show ?thesis by simp
  qed 
  moreover have "IsContinuous(0,0,GroupInv(0,?fH))"
  proof -
    let ?g = "restrict(GroupInv(G,f),H)"
    have "GroupInv(G,f) : G  G"
      using Ggroup group0_2_T2 by simp
    then have "two_top_spaces0(T,T,GroupInv(G,f))"
      using topSpaceAssum two_top_spaces0_def by simp
    moreover from A1 have "H  T" using group0_3_L2 by simp
    ultimately have 
      "IsContinuous(0,T {restricted to} ?g``(H),?g)"
      using inv_cont two_top_spaces0.restr_restr_image_cont
      by simp
    moreover from A1 have "?g``(H) = H" using restr_inv_onto by simp  
    moreover
    from A1 have "GroupInv(H,?fH) = ?g" using group0_3_T1 by simp
    with 0 = H have "?g = GroupInv(0,?fH)" by simp
    ultimately show ?thesis by simp
  qed
  ultimately show ?thesis unfolding IsAtopologicalGroup_def by simp
qed

subsectionInterval arithmetic, translations and inverse of set

textIn this section we list some properties of operations of translating a
  set and reflecting it around the neutral element of the group. Many of the results
  are proven in other theories, here we just collect them and rewrite in notation
  specific to the topgroup› context.

textDifferent ways of looking at adding sets.

lemma (in topgroup) interval_add: assumes "AG" "BG" shows
  "A\<sad>B  G" 
  "A\<sad>B = f``(A×B)"  
  "A\<sad>B = (xA. x\<ltr>B)"
  "A\<sad>B = {x\<ra>y. x,y  A×B}" 
proof -
  from assms show "A\<sad>B  G" and "A\<sad>B = f``(A×B)" and "A\<sad>B = {x\<ra>y. x,y  A×B}"
    using topgroup_f_binop lift_subsets_explained by auto
  from assms show "A\<sad>B = (xA. x\<ltr>B)" using image_ltrans_union by simp
qed

text If the neutral element is in a set, then it is in the sum of the sets. 

lemma (in topgroup) interval_add_zero: assumes "AG" "𝟬A"
  shows "𝟬  A\<sad>A"
proof -
  from assms have "𝟬\<ra>𝟬  A\<sad>A" using interval_add(4) by auto
  then show "𝟬  A\<sad>A" using group0_2_L2 by auto
qed

textSome lemmas from Group_ZF_1› about images of set by translations 
  written in additive notation

lemma (in topgroup) lrtrans_image: assumes "VG" "xG"
  shows 
    "x\<ltr>V = {x\<ra>v. vV}" 
    "V\<rtr>x = {v\<ra>x. vV}"
  using assms ltrans_image rtrans_image by auto
  
text Right and left translations of a set are subsets of the group. 
  This is of course typically applied to the subsets of the group, but formally we don't
  need to assume that. 

lemma (in topgroup) lrtrans_in_group_add: assumes "xG" 
  shows  "x\<ltr>V  G" and "V\<rtr>x G"
  using assms lrtrans_in_group by auto
    
text A corollary from interval_add› 

corollary (in topgroup) elements_in_set_sum: assumes "AG" "BG"
  "t  A\<sad>B" shows "sA. qB. t=s\<ra>q"
  using assms interval_add(4) by auto 

text A corollary from  lrtrans_image›  

corollary (in topgroup) elements_in_ltrans: 
  assumes "BG" "gG" "t  g\<ltr>B" 
  shows "qB. t=g\<ra>q"
  using assms lrtrans_image(1) by simp 

text Another corollary of lrtrans_image› 

corollary (in topgroup) elements_in_rtrans: 
  assumes "BG" "gG"  "t  B\<rtr>g" shows "qB. t=q\<ra>g"
  using assms lrtrans_image(2) by simp

textAnother corollary from interval_add› 

corollary (in topgroup) elements_in_set_sum_inv: 
  assumes "AG" "BG" "t=s\<ra>q" "sA" "qB"
  shows "t  A\<sad>B"
  using assms interval_add by auto 

textAnother corollary of lrtrans_image› 

corollary (in topgroup) elements_in_ltrans_inv: assumes "BG" "gG" "qB" "t=g\<ra>q"
  shows "t  g\<ltr>B"
  using assms lrtrans_image(1) by auto 

textAnother corollary of rtrans_image_add› 

lemma (in topgroup) elements_in_rtrans_inv:
  assumes "BG" "gG" "qB" "t=q\<ra>g"
  shows "t  B\<rtr>g"
  using assms lrtrans_image(2) by auto 

textRight and left translations are continuous.

lemma (in topgroup) trans_cont: assumes "gG" shows
  "IsContinuous(T,T,RightTranslation(G,f,g))" and
  "IsContinuous(T,T,LeftTranslation(G,f,g))"
using assms trans_eq_section topgroup_f_binop fcon prod_top_spaces0_valid 
  prod_top_spaces0.fix_1st_var_cont prod_top_spaces0.fix_2nd_var_cont
  by auto

textLeft and right translations of an open set are open.

lemma (in topgroup) open_tr_open: assumes "gG" and "VT"
  shows "g\<ltr>V  T" and  "V\<rtr>g  T"
  using assms neg_in_tgroup trans_cont IsContinuous_def trans_image_vimage by auto

textRight and left translations are homeomorphisms.

lemma (in topgroup) tr_homeo: assumes "gG" shows
  "IsAhomeomorphism(T,T,RightTranslation(G,f,g))" and
  "IsAhomeomorphism(T,T,LeftTranslation(G,f,g))"
  using assms trans_bij trans_cont open_tr_open bij_cont_open_homeo 
  by auto

textLeft translations preserve interior.

lemma (in topgroup) ltrans_interior: assumes A1: "gG" and A2: "AG" 
  shows "g \<ltr> int(A) = int(g\<ltr>A)"
proof -
  from assms have "A  T" and "IsAhomeomorphism(T,T,LeftTranslation(G,f,g))" using tr_homeo 
    by auto
  then show ?thesis using int_top_invariant by simp
qed

textRight translations preserve interior.

lemma (in topgroup) rtrans_interior: assumes A1: "gG" and A2: "AG" 
  shows "int(A) \<rtr> g = int(A\<rtr>g)"
proof -
  from assms have "A  T" and "IsAhomeomorphism(T,T,RightTranslation(G,f,g))" using tr_homeo 
    by auto
  then show ?thesis using int_top_invariant by simp
qed

textTranslating by an inverse and then by an element cancels out.

lemma (in topgroup) trans_inverse_elem: assumes "gG" and "AG"
  shows "g\<ltr>((\<rm>g)\<ltr>A) = A"
  using assms neg_in_tgroup trans_comp_image group0_2_L6 trans_neutral image_id_same 
  by simp

textInverse of an open set is open.

lemma (in topgroup) open_inv_open: assumes "VT" shows "(\<sm>V)  T"
  using assms inv_image_vimage inv_cont IsContinuous_def by simp

textInverse is a homeomorphism.

lemma (in topgroup) inv_homeo: shows "IsAhomeomorphism(T,T,GroupInv(G,f))"
  using group_inv_bij inv_cont open_inv_open bij_cont_open_homeo by simp

textTaking negative preserves interior.

lemma (in topgroup) int_inv_inv_int: assumes "A  G" 
  shows "int(\<sm>A) = \<sm>(int(A))"
  using assms inv_homeo int_top_invariant by simp

subsectionNeighborhoods of zero

textZero neighborhoods are (not necessarily open) sets whose interior
  contains the neutral element of the group. In the topgroup› locale
  the collection of neighboorhoods of zero is denoted 𝒩0. 

textThe whole space is a neighborhood of zero.

lemma (in topgroup) zneigh_not_empty: shows "G  𝒩0"
  using topSpaceAssum IsATopology_def Top_2_L3 zero_in_tgroup
  by simp


textAny element that belongs to a subset of the group belongs to that subset with the 
  interior of a neighborhood of zero added. 

lemma (in topgroup) elem_in_int_sad: assumes "AG" "gA" "H  𝒩0"
  shows "g  A\<sad>int(H)"
proof -
  from assms(3) have "𝟬  int(H)" and "int(H)  G" using Top_2_L2 by auto
  with assms(1,2) have "g\<ra>𝟬  A\<sad>int(H)" using elements_in_set_sum_inv
    by simp
  with assms(1,2) show ?thesis using group0_2_L2 by auto
qed

textAny element belongs to the interior of any neighboorhood of zero
  left translated by that element.

lemma (in topgroup) elem_in_int_ltrans:
  assumes "gG" and "H  𝒩0"
  shows "g  int(g\<ltr>H)" and "g  int(g\<ltr>H) \<sad> int(H)"
proof -
  from assms(2) have "𝟬  int(H)" and "int(H)  G" using Top_2_L2 by auto
  with assms(1) have "g  g \<ltr> int(H)" using neut_trans_elem by simp
  with assms show "g  int(g\<ltr>H)" using ltrans_interior by simp
  from assms(1) have "int(g\<ltr>H)  G" using lrtrans_in_group_add(1) Top_2_L1
    by blast
  with g  int(g\<ltr>H) assms(2) show "g  int(g\<ltr>H) \<sad> int(H)" 
    using elem_in_int_sad by simp
qed

textAny element belongs to the interior of any neighboorhood of zero
  right translated by that element.

lemma (in topgroup) elem_in_int_rtrans:
  assumes A1: "gG" and A2: "H  𝒩0"
  shows "g  int(H\<rtr>g)" and "g  int(H\<rtr>g) \<sad> int(H)"
proof -
  from A2 have "𝟬  int(H)" and "int(H)  G" using Top_2_L2 by auto
  with A1 have "g  int(H) \<rtr> g" using neut_trans_elem by simp
  with assms show "g  int(H\<rtr>g)" using rtrans_interior by simp
  from assms(1) have "int(H\<rtr>g)  G" using lrtrans_in_group_add(2) Top_2_L1
    by blast
  with g  int(H\<rtr>g) assms(2) show "g  int(H\<rtr>g) \<sad> int(H)" 
    using elem_in_int_sad by simp
qed

textNegative of a neighborhood of zero is a neighborhood of zero.

lemma (in topgroup) neg_neigh_neigh: assumes "H  𝒩0"
  shows "(\<sm>H)  𝒩0"
proof -
  from assms have "int(H)  G" and "𝟬  int(H)" using Top_2_L1 by auto
  with assms have "𝟬  int(\<sm>H)" using neut_inv_neut int_inv_inv_int by simp
  moreover
  have "GroupInv(G,f):GG" using Ggroup group0_2_T2 by simp
  then have "(\<sm>H)  G" using func1_1_L6 by simp
  ultimately show ?thesis by simp
qed

textLeft translating an open set by a negative of a point that belongs to it
  makes it a neighboorhood of zero.

lemma (in topgroup) open_trans_neigh: assumes A1: "UT" and "gU"
  shows "(\<rm>g)\<ltr>U  𝒩0"
proof -
  let ?H = "(\<rm>g)\<ltr>U"
  from assms have "gG" by auto
  then have "(\<rm>g)  G" using neg_in_tgroup by simp
  with A1 have "?HT" using open_tr_open by simp
  hence "?H  G" by auto
  moreover have "𝟬  int(?H)"
  proof -
    from assms have "UG" and "gU" by auto
    with ?HT show "𝟬  int(?H)" using elem_trans_neut Top_2_L3 by auto
  qed
  ultimately show ?thesis by simp
qed

textRight translating an open set by a negative of a point that belongs to it
  makes it a neighboorhood of zero.

lemma (in topgroup) open_trans_neigh_2: assumes A1: "UT" and "gU"
  shows "U\<rtr>(\<rm>g)  𝒩0"
proof -
  let ?H = "U\<rtr>(\<rm>g)"
  from assms have "gG" by auto
  then have "(\<rm>g)  G" using neg_in_tgroup by simp
  with A1 have "?HT" using open_tr_open by simp
  hence "?H  G" by auto
  moreover have "𝟬  int(?H)"
  proof -
    from assms have "UG" and "gU" by auto
    with ?HT show "𝟬  int(?H)" using elem_trans_neut Top_2_L3  by auto
  qed
  ultimately show ?thesis by simp
qed

textRight and left translating an neighboorhood of zero by a point and its negative 
  makes it back a neighboorhood of zero.

lemma (in topgroup) lrtrans_neigh: assumes "W𝒩0" and "xG"
  shows "x\<ltr>(W\<rtr>(\<rm>x))  𝒩0" and "(x\<ltr>W)\<rtr>(\<rm>x)  𝒩0"
proof -
  from assms(2) have "x\<ltr>(W\<rtr>(\<rm>x))  G" using lrtrans_in_group_add(1) by simp
  moreover have "𝟬  int(x\<ltr>(W\<rtr>(\<rm>x)))"
  proof -
    from assms(2) have "int(W\<rtr>(\<rm>x))  G" 
      using neg_in_tgroup lrtrans_in_group_add(2) Top_2_L1 by blast
    with assms(2) have "(x\<ltr>int((W\<rtr>(\<rm>x)))) = {x\<ra>y. yint(W\<rtr>(\<rm>x))}"
      using lrtrans_image(1) by simp
    moreover from assms have "(\<rm>x)  int(W\<rtr>(\<rm>x))" 
      using neg_in_tgroup elem_in_int_rtrans(1) by simp
    ultimately have "x\<ra>(\<rm>x)  x\<ltr>int(W\<rtr>(\<rm>x))" by auto
    with assms show ?thesis using group0_2_L6 neg_in_tgroup lrtrans_in_group_add(2) ltrans_interior 
      by simp
  qed
  ultimately show "x\<ltr>(W\<rtr>(\<rm>x))  𝒩0" by simp
  from assms(2) have "(x\<ltr>W)\<rtr>(\<rm>x)  G" using lrtrans_in_group_add(2) neg_in_tgroup 
    by simp
  moreover have "𝟬  int((x\<ltr>W)\<rtr>(\<rm>x))"
  proof -
    from assms(2) have "int((x\<ltr>W))  G" using lrtrans_in_group_add(1) Top_2_L1 by blast
    with assms(2) have "int(x\<ltr>W) \<rtr> (\<rm>x) = {y\<ra>(\<rm>x).yint(x\<ltr>W)}"
      using neg_in_tgroup  lrtrans_image(2) by simp
    moreover from assms have "x  int(x\<ltr>W)" using elem_in_int_ltrans(1) by simp
    ultimately have "x\<ra>(\<rm>x)  int(x\<ltr>W) \<rtr> (\<rm>x)" by auto
    with assms(2) have "𝟬  int(x\<ltr>W) \<rtr> (\<rm>x)" using group0_2_L6 by simp
    with assms show ?thesis using group0_2_L6 neg_in_tgroup lrtrans_in_group_add(1) rtrans_interior
      by auto
  qed
  ultimately show "(x\<ltr>W)\<rtr>(\<rm>x)  𝒩0" by simp
qed

textIf $A$ is a subset of $B$ translated by $-x$ then its translation by $x$ is a subset of $B$.

lemma (in topgroup) trans_subset:
  assumes "A  ((\<rm>x)\<ltr>B)""xG" "BG"
  shows "x\<ltr>A  B"
proof-
  from assms(1) have "x\<ltr>A  (x\<ltr> ((\<rm>x)\<ltr>B))" by auto
  with assms(2,3) show "x\<ltr>A  B"
    using neg_in_tgroup trans_comp_image group0_2_L6 trans_neutral image_id_same by simp
qed

text Every neighborhood of zero has a symmetric subset that is a neighborhood of zero.

theorem (in topgroup) exists_sym_zerohood:
  assumes "U𝒩0"
  shows "V𝒩0. (VU  (\<sm>V)=V)"
proof
  let ?V = "U(\<sm>U)"
  have "UG" using assms unfolding zerohoods_def by auto
  then have "?VG" by auto
  have invg:" GroupInv(G, f)  G  G" using group0_2_T2 Ggroup by auto
  have invb:"GroupInv(G, f) bij(G,G)" using group_inv_bij(2) by auto
  have "(\<sm>?V)=GroupInv(G,f)-``?V" unfolding setninv_def using inv_image_vimage 
    by auto
  also have "=(GroupInv(G,f)-``U)(GroupInv(G,f)-``(\<sm>U))" using invim_inter_inter_invim invg 
    by auto
  also have "=(\<sm>U)(GroupInv(G,f)-``(GroupInv(G,f)``U))" 
    unfolding setninv_def using inv_image_vimage by auto
  also from UG have "=(\<sm>U)U" using inj_vimage_image invb unfolding bij_def
    by auto
  finally have "(\<sm>?V)=?V" by auto
  then show "?V  U  (\<sm> ?V) = ?V" by auto
  from assms have "(\<sm>U)𝒩0" using neg_neigh_neigh by auto
  with assms have "𝟬  int(U)int(\<sm>U)" unfolding zerohoods_def by auto
  moreover have "int(U)int(\<sm>U) = int(?V)" using int_inter_int by simp
  ultimately have "𝟬  int(?V)" by (rule set_mem_eq)
  with ?VG show "?V𝒩0" using zerohoods_def by auto
qed 

text We can say even more than in exists_sym_zerohood›:
  every neighborhood of zero $U$ has a symmetric subset that is a neighborhood of zero and its 
  set double is contained in $U$.

theorem (in topgroup) exists_procls_zerohood:
  assumes "U𝒩0"
  shows "V𝒩0. (VU (V\<sad>V)U  (\<sm>V)=V)"
proof-
  have "int(U)T" using Top_2_L2 by auto
  then have "f-``(int(U))τ" using fcon IsContinuous_def by auto
  moreover have fne:"f ` 𝟬, 𝟬 = 𝟬" using group0_2_L2 by auto
  moreover
  have "𝟬int(U)" using assms unfolding zerohoods_def by auto
  then have "f -`` {𝟬}f-``(int(U))" using func1_1_L8 vimage_def by auto
  then have "GroupInv(G,f)f-``(int(U))" using group0_2_T3 by auto
  then have "𝟬,𝟬f-``(int(U))" using fne zero_in_tgroup unfolding GroupInv_def
    by auto
  ultimately obtain W V where 
    wop:"WT" and vop:"VT" and cartsub:"W×Vf-``(int(U))" and zerhood:"𝟬,𝟬W×V" 
    using prod_top_point_neighb topSpaceAssum
    unfolding prodtop_def by force
  then have "𝟬W" and "𝟬V" by auto
  then have "𝟬WV" by auto
  have sub:"WVG" using wop vop G_def by auto
  have assoc:"fG×GG" using group_oper_fun by auto
  {
    fix t s assume "tWV" and "sWV"
    then have "tW" and "sV" by auto
    then have "t,sW×V" by auto
    then have "t,sf-``(int(U))" using cartsub by auto
    then have "f`t,sint(U)" using func1_1_L15 assoc by auto
  } hence "{f`t,s. t,s(WV)×(WV)}int(U)" by auto
  then have "(WV)\<sad>(WV)int(U)" 
    unfolding setadd_def using lift_subsets_explained(4) assoc sub
    by auto
  then have "(WV)\<sad>(WV)U" using Top_2_L1 by auto
  from topSpaceAssum have "WVT" using vop wop unfolding IsATopology_def by auto
  then have "int(WV)=WV" using Top_2_L3 by auto
  with sub 𝟬WV have "WV𝒩0" unfolding zerohoods_def by auto
  then obtain Q where "Q𝒩0" and "QWV" and "(\<sm>Q)=Q" using exists_sym_zerohood by blast
  then have "Q×Q(WV)×(WV)" by auto 
  moreover from QWV have "WVG" and "QG" using vop wop unfolding G_def by auto
  ultimately have "Q\<sad>Q(WV)\<sad>(WV)" using interval_add(2) func1_1_L8 by auto
  with (WV)\<sad>(WV)U have "Q\<sad>QU" by auto
  from Q𝒩0 have "𝟬Q" unfolding zerohoods_def using Top_2_L1 by auto
  with Q\<sad>QU QG have "𝟬\<ltr>QU" using interval_add(3) by auto
  with QG have "QU" unfolding ltrans_def gzero_def using trans_neutral(2) image_id_same 
    by auto
  with Q𝒩0 Q\<sad>QU (\<sm>Q)=Q show ?thesis by auto
qed
 
subsectionClosure in topological groups

textThis section is devoted to a characterization of closure
  in topological groups.

textClosure of a set is contained in the sum of the set and any
  neighboorhood of zero.

lemma (in topgroup) cl_contains_zneigh:
  assumes A1: "AG" and A2: "H  𝒩0"
  shows "cl(A)  A\<sad>H"
proof
  fix x assume "x  cl(A)"
  from A1 have "cl(A)  G" using Top_3_L11 by simp
  with x  cl(A) have "xG" by auto
  have "int(H)  G" using Top_2_L2 by auto
  let ?V = "int(x \<ltr> (\<sm>H))"
  have "?V = x \<ltr> (\<sm>int(H))"
  proof -
    from A2 xG have "?V = x \<ltr> int(\<sm>H)" 
      using neg_neigh_neigh ltrans_interior by simp
    with A2 show ?thesis  using int_inv_inv_int by simp
  qed
  have "A?V  0"
  proof -
    from A2 xG x  cl(A) have "?VT" and "x  cl(A)  ?V" 
      using neg_neigh_neigh elem_in_int_ltrans(1) Top_2_L2 by auto
    with A1 show "A?V  0" using cl_inter_neigh by simp
  qed
  then obtain y where "yA" and "y?V" by auto
  with ?V = x \<ltr> (\<sm>int(H)) int(H)  G xG have "x  y\<ltr>int(H)"
    using ltrans_inv_in by simp
  with yA have "x  (yA. y\<ltr>H)" using Top_2_L1 func1_1_L8 by auto
  with assms show "x  A\<sad>H" using interval_add(3) by simp
qed

textThe next theorem provides a characterization of closure in topological
  groups in terms of neighborhoods of zero.

theorem (in topgroup) cl_topgroup:
  assumes "AG" shows "cl(A) = (H𝒩0. A\<sad>H)"
proof
  from assms show "cl(A)  (H𝒩0. A\<sad>H)" 
    using zneigh_not_empty cl_contains_zneigh by auto
next
  { fix x assume "x  (H𝒩0. A\<sad>H)"
    then have "x  A\<sad>G" using zneigh_not_empty by auto
    with assms have "xG" using interval_add by blast
    have "UT. xU  UA  0"
    proof -
      { fix U assume "UT" and "xU"
        let ?H = "\<sm>((\<rm>x)\<ltr>U)"
        from UT and xU have "(\<rm>x)\<ltr>U  G" and "?H  𝒩0" 
          using open_trans_neigh neg_neigh_neigh by auto
        with x  (H𝒩0. A\<sad>H) have "x  A\<sad>?H" by auto
        with assms ?H  𝒩0 obtain y where "yA" and "x  y\<ltr>?H"
          using interval_add(3) by auto
        have "yU"
        proof -
          from assms yA have "yG" by auto
          with (\<rm>x)\<ltr>U  G and x  y\<ltr>?H have "y  x\<ltr>((\<rm>x)\<ltr>U)"
            using ltrans_inv_in by simp
          with UT xG show "yU" 
            using neg_in_tgroup trans_comp_image group0_2_L6 trans_neutral image_id_same
              by auto
        qed
        with yA have "UA  0" by auto
      } thus ?thesis by simp
    qed
    with assms xG have "x  cl(A)" using inter_neigh_cl by simp
  } thus "(H𝒩0. A\<sad>H)  cl(A)" by auto
qed

subsectionSums of sequences of elements and subsets

textIn this section we consider properties of the function $G^n\rightarrow G$, 
  $x=(x_0,x_1,...,x_{n-1})\mapsto \sum_{i=0}^{n-1}x_i$. We will model the cartesian product
  $G^n$ by the space of sequences $n\rightarrow G$, where $n=\{0,1,...,n-1 \}$ is a natural number. 
  This space is equipped with a natural product topology defined in Topology_ZF_3›.

textLet's recall first that the sum of elements of a group is an element of the group.

lemma (in topgroup) sum_list_in_group:
  assumes "n  nat" and "x: succ(n)G"
  shows "(x)  G"
proof -
  from assms have "semigr0(G,f)" and "n  nat" "x: succ(n)G"
    using semigr0_valid_in_tgroup by auto
  then have "Fold1(f,x)  G" by (rule semigr0.prod_type)
  thus "(x)  G" by simp
qed

textIn this context x\<ra>y› is the same as the value of the group operation
  on the elements $x$ and $y$. Normally we shouldn't need to state this a s separate lemma.

lemma (in topgroup) grop_def1: shows "f`x,y = x\<ra>y" by simp 

textAnother theorem from Semigroup_ZF› theory that is useful to have in the
  additive notation.

lemma (in topgroup) shorter_set_add:
  assumes "n  nat" and "x: succ(succ(n))G"
  shows "(x) = (Init(x)) \<ra> (x`(succ(n)))"
proof -
  from assms have "semigr0(G,f)" and "n  nat" "x: succ(succ(n))G"
    using semigr0_valid_in_tgroup by auto
  then have "Fold1(f,x) = f`Fold1(f,Init(x)),x`(succ(n))"
    by (rule semigr0.shorter_seq)
  thus ?thesis by simp   
qed

textSum is a continuous function in the product topology.

theorem (in topgroup) sum_continuous: assumes "n  nat"
  shows "IsContinuous(SeqProductTopology(succ(n),T),T,{x,x.xsucc(n)G})"
  proof -
    note n  nat
    moreover have "IsContinuous(SeqProductTopology(succ(0),T),T,{x,x.xsucc(0)G})"
    proof -
      have "{x,x.xsucc(0)G} = {x,x`(0). x1G}"
        using semigr0_valid_in_tgroup semigr0.prod_of_1elem by simp
      moreover have
        "IsAhomeomorphism(SeqProductTopology(1,T),T,{x,x`(0). x1T})" using topSpaceAssum singleton_prod_top1
          by simp
      ultimately show ?thesis using IsAhomeomorphism_def by simp
    qed
    moreover have "knat.
      IsContinuous(SeqProductTopology(succ(k),T),T,{x,x.xsucc(k)G})
      
      IsContinuous(SeqProductTopology(succ(succ(k)),T),T,{x,x.xsucc(succ(k))G})"
      proof -
        { fix k assume "k  nat"
          let ?s = "{x,x.xsucc(k)G}"
          let ?g = "{p,?s`(fst(p)),snd(p). p  (succ(k)G)×G}"
          let ?h = "{x,Init(x),x`(succ(k)). x  succ(succ(k))G}"
          let  = "SeqProductTopology(succ(k),T)"
          let  = "SeqProductTopology(succ(succ(k)),T)"
          assume "IsContinuous(,T,?s)"
          from k  nat have "?s: (succ(k)G)  G"
            using sum_list_in_group ZF_fun_from_total by simp 
          have "?h: (succ(succ(k))G)(succ(k)G)×G"
          proof -
            { fix x assume "x  succ(succ(k))G"
              with k  nat have "Init(x)  (succ(k)G)"
                using init_props by simp
              with k  nat x : succ(succ(k))G 
                have "Init(x),x`(succ(k))  (succ(k)G)×G" using apply_funtype
                  by blast 
           } then show ?thesis using ZF_fun_from_total by simp
          qed
          moreover have "?g:((succ(k)G)×G)(G×G)"
          proof -
            { fix p assume "p  (succ(k)G)×G"
              hence "fst(p): succ(k)G" and "snd(p)  G" by auto
              with ?s: (succ(k)G)  G have "?s`(fst(p)),snd(p)  G×G"
                using apply_funtype by blast 
            } then show "?g:((succ(k)G)×G)(G×G)" using ZF_fun_from_total
              by simp
          qed
          moreover have "f : G×G  G" using topgroup_f_binop by simp
          ultimately have "f O ?g O ?h :(succ(succ(k))G)G" using comp_fun
            by blast 
          from k  nat have "IsContinuous(,ProductTopology(,T),?h)"
            using topSpaceAssum finite_top_prod_homeo IsAhomeomorphism_def
            by simp
          moreover have "IsContinuous(ProductTopology(,T),τ,?g)"
          proof -
            from topSpaceAssum have 
               "T {is a topology}" " {is a topology}" " = succ(k)G"
               using seq_prod_top_is_top by auto
            moreover from  = succ(k)G ?s: (succ(k)G)  G 
              have "?s:T" by simp 
            moreover note IsContinuous(,T,?s)
            moreover from  = succ(k)G 
              have "?g = {p,?s`(fst(p)),snd(p). p  ×T}"
              by simp
            ultimately have "IsContinuous(ProductTopology(,T),ProductTopology(T,T),?g)"
              using cart_prod_cont1 by blast 
            thus ?thesis by simp
          qed         
          moreover have "IsContinuous(τ,T,f)" using fcon by simp
          moreover have "{x,x.xsucc(succ(k))G} = f O ?g O ?h"
          proof -
            let ?d = "{x,x.xsucc(succ(k))G}"
            from knat have "xsucc(succ(k))G. (x)  G"
              using sum_list_in_group by blast 
            then have "?d:(succ(succ(k))G)G" 
              using sum_list_in_group ZF_fun_from_total by simp
            moreover note f O ?g O ?h :(succ(succ(k))G)G
            moreover have "xsucc(succ(k))G. ?d`(x) = (f O ?g O ?h)`(x)"
            proof
              fix x assume "xsucc(succ(k))G"
              then have I: "?h`(x) = Init(x),x`(succ(k))"
                using ZF_fun_from_tot_val1 by simp
              moreover from knat xsucc(succ(k))G 
                have "Init(x): succ(k)G" 
                using init_props by simp
              moreover from knat x:succ(succ(k))G 
                have II: "x`(succ(k))  G"
                using apply_funtype by blast
              ultimately have "?h`(x)  (succ(k)G)×G" by simp
              then have "?g`(?h`(x)) = ?s`(fst(?h`(x))),snd(?h`(x))"
                using ZF_fun_from_tot_val1 by simp
              with I have "?g`(?h`(x)) = ?s`(Init(x)),x`(succ(k))"
                by simp
              with Init(x): succ(k)G have "?g`(?h`(x)) = Init(x),x`(succ(k))"
                using ZF_fun_from_tot_val1 by simp
              with k  nat x: succ(succ(k))G 
                have "f`(?g`(?h`(x))) = (x)"
                using shorter_set_add by simp
              with x  succ(succ(k))G have "f`(?g`(?h`(x))) = ?d`(x)"
                using ZF_fun_from_tot_val1 by simp
              moreover from 
                ?h: (succ(succ(k))G)(succ(k)G)×G
                ?g:((succ(k)G)×G)(G×G)
                f:(G×G)G xsucc(succ(k))G
                have "(f O ?g O ?h)`(x) = f`(?g`(?h`(x)))" by (rule func1_1_L18)
              ultimately show "?d`(x) = (f O ?g O ?h)`(x)" by simp 
            qed
            ultimately show "{x,x.xsucc(succ(k))G} = f O ?g O ?h" 
              using func_eq by simp
          qed
          moreover note IsContinuous(τ,T,f)
          ultimately have "IsContinuous(,T,{x,x.xsucc(succ(k))G})"
            using comp_cont3 by simp
        } thus ?thesis by simp
      qed
    ultimately show ?thesis by (rule ind_on_nat)
  qed
end