Theory Group_ZF_1

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

Copyright (C) 2008  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 Groups 1

theory Group_ZF_1 imports Group_ZF

begin

textIn this theory we consider right and left translations and odd 
  functions.

subsectionTranslations

textIn this section we consider translations. Translations are maps 
  $T: G\rightarrow G$ of the form $T_g (a) = g\cdot a$ or 
  $T_g (a) = a\cdot g$. We also consider two-dimensional translations
  $T_g : G\times G \rightarrow G\times G$, where 
  $T_g(a,b) = (a\cdot g, b\cdot g)$ or $T_g(a,b) = (g\cdot a, g\cdot b)$. 


textFor an element $a\in G$ the right translation is defined 
  a function (set of pairs) such that its value (the second element
  of a pair) is the value of the group operation on the first element
  of the pair and $g$. This looks a bit strange in the raw set notation, 
  when we write a function explicitely as a set of pairs and value of 
  the group operation on the pair $\langle a,b \rangle$ 
  as P`⟨a,b⟩› instead of the usual infix $a\cdot b$
  or $a + b$.

definition
  "RightTranslation(G,P,g)  { a,b  G×G. P`a,g = b}"

textA similar definition of the left translation.

definition
  "LeftTranslation(G,P,g)  {a,b  G×G. P`g,a = b}"

textTranslations map $G$ into $G$. Two dimensional translations map
  $G\times G$ into itself.

lemma (in group0) group0_5_L1: assumes A1: "gG"
  shows "RightTranslation(G,P,g) : GG" and  "LeftTranslation(G,P,g) : GG"
proof -
  from A1 have "aG. ag  G" and "aG. ga  G"
    using group_oper_fun apply_funtype by auto
  then show 
    "RightTranslation(G,P,g) : GG" 
    "LeftTranslation(G,P,g) : GG"
    using RightTranslation_def LeftTranslation_def func1_1_L11A
    by auto
qed

textThe values of the translations are what we expect.

lemma (in group0) group0_5_L2: assumes "gG" "aG"
  shows 
  "RightTranslation(G,P,g)`(a) = ag"
  "LeftTranslation(G,P,g)`(a) = ga"
  using assms group0_5_L1 RightTranslation_def LeftTranslation_def
    func1_1_L11B by auto

textComposition of left translations is a left translation by the product.

lemma (in group0) group0_5_L4: assumes A1: "gG" "hG" "aG" and 
  A2: "Tg = LeftTranslation(G,P,g)"  "Th = LeftTranslation(G,P,h)"
  shows 
  "Tg`(Th`(a)) = gha"
  "Tg`(Th`(a)) = LeftTranslation(G,P,gh)`(a)"
proof -
  from A1 have I: "haG"  "ghG"
    using group_oper_fun apply_funtype by auto
  with A1 A2 show "Tg`(Th`(a)) = gha"
    using group0_5_L2 group_oper_assoc by simp
  with A1 A2 I show 
    "Tg`(Th`(a)) = LeftTranslation(G,P,gh)`(a)"
    using group0_5_L2 group_oper_assoc by simp
qed

textComposition of right translations is a right translation by 
  the product.

lemma (in group0) group0_5_L5: assumes A1: "gG" "hG" "aG" and 
  A2: "Tg = RightTranslation(G,P,g)"  "Th = RightTranslation(G,P,h)"
  shows 
 "Tg`(Th`(a)) = ahg"
  "Tg`(Th`(a)) = RightTranslation(G,P,hg)`(a)"
proof -
  from A1 have I: "ahG" "hg G"
    using group_oper_fun apply_funtype by auto
  with A1 A2 show "Tg`(Th`(a)) = ahg" 
    using group0_5_L2 group_oper_assoc by simp
  with A1 A2 I show 
    "Tg`(Th`(a)) = RightTranslation(G,P,hg)`(a)"
    using group0_5_L2 group_oper_assoc by simp
qed

textPoint free version of group0_5_L4› and group0_5_L5›.

lemma (in group0) trans_comp: assumes "gG" "hG" shows
  "RightTranslation(G,P,g) O RightTranslation(G,P,h) = RightTranslation(G,P,hg)"
  "LeftTranslation(G,P,g) O LeftTranslation(G,P,h) = LeftTranslation(G,P,gh)"
proof -
  let ?Tg = "RightTranslation(G,P,g)"
  let ?Th = "RightTranslation(G,P,h)"
  from assms have "?Tg:GG" and "?Th:GG"
    using group0_5_L1 by auto
  then have "?Tg O ?Th:GG" using comp_fun by simp
  moreover from assms have "RightTranslation(G,P,hg):GG"
    using group_op_closed group0_5_L1 by simp
  moreover from assms ?Th:GG have 
    "aG. (?Tg O ?Th)`(a) = RightTranslation(G,P,hg)`(a)"
    using comp_fun_apply group0_5_L5 by simp
  ultimately show "?Tg O ?Th =  RightTranslation(G,P,hg)"
    by (rule func_eq)
next
  let ?Tg = "LeftTranslation(G,P,g)"
  let ?Th = "LeftTranslation(G,P,h)"
  from assms have "?Tg:GG" and "?Th:GG"
    using group0_5_L1 by auto
  then have "?Tg O ?Th:GG" using comp_fun by simp
  moreover from assms have "LeftTranslation(G,P,gh):GG"
    using group_op_closed group0_5_L1 by simp
  moreover from assms ?Th:GG have 
    "aG. (?Tg O ?Th)`(a) = LeftTranslation(G,P,gh)`(a)"
    using comp_fun_apply group0_5_L4 by simp
  ultimately show "?Tg O ?Th =  LeftTranslation(G,P,gh)"
    by (rule func_eq)
qed

textThe image of a set under a composition of translations is the same as
  the image under translation by a product.

lemma (in group0) trans_comp_image: assumes A1: "gG" "hG" and
  A2: "Tg = LeftTranslation(G,P,g)"  "Th = LeftTranslation(G,P,h)"
shows "Tg``(Th``(A)) = LeftTranslation(G,P,gh)``(A)"
proof -
  from A2 have "Tg``(Th``(A)) = (Tg O Th)``(A)"
    using image_comp by simp
  with assms show ?thesis using trans_comp by simp
qed

textAnother form of the image of a set under a composition of translations

lemma (in group0) group0_5_L6: 
  assumes A1: "gG" "hG" and A2: "AG" and 
  A3: "Tg = RightTranslation(G,P,g)"  "Th = RightTranslation(G,P,h)"
  shows "Tg``(Th``(A)) = {ahg. aA}"
proof -
  from A2 have "aA. aG" by auto
  from A1 A3 have "Tg : GG"  "Th : GG"
    using group0_5_L1 by auto
  with assms aA. aG show 
    "Tg``(Th``(A)) = {ahg. aA}"
    using func1_1_L15C group0_5_L5 by auto
qed

textThe translation by neutral element is the identity on group.

lemma (in group0) trans_neutral: shows 
  "RightTranslation(G,P,𝟭) = id(G)" and "LeftTranslation(G,P,𝟭) = id(G)"
proof -
  have "RightTranslation(G,P,𝟭):GG" and "aG. RightTranslation(G,P,𝟭)`(a) = a"
    using group0_2_L2 group0_5_L1 group0_5_L2  by auto
  then show "RightTranslation(G,P,𝟭) = id(G)" by (rule indentity_fun)
  have "LeftTranslation(G,P,𝟭):GG" and "aG. LeftTranslation(G,P,𝟭)`(a) = a"
    using group0_2_L2 group0_5_L1 group0_5_L2  by auto
  then show "LeftTranslation(G,P,𝟭) = id(G)" by (rule indentity_fun)
qed

textTranslation by neutral element does not move sets. 

lemma (in group0) trans_neutral_image: assumes "VG"
  shows "RightTranslation(G,P,𝟭)``(V) = V" and "LeftTranslation(G,P,𝟭)``(V) = V"
  using assms trans_neutral image_id_same by auto

textComposition of translations by an element and its inverse is identity.

lemma (in group0) trans_comp_id: assumes "gG" shows
  "RightTranslation(G,P,g) O RightTranslation(G,P,g¯) = id(G)" and
  "RightTranslation(G,P,g¯) O RightTranslation(G,P,g) = id(G)" and
  "LeftTranslation(G,P,g) O LeftTranslation(G,P,g¯) = id(G)" and
  "LeftTranslation(G,P,g¯) O LeftTranslation(G,P,g) = id(G)"
  using assms inverse_in_group trans_comp group0_2_L6 trans_neutral by auto

textTranslations are bijective.

lemma (in group0) trans_bij: assumes "gG" shows
  "RightTranslation(G,P,g)  bij(G,G)" and "LeftTranslation(G,P,g)  bij(G,G)"
proof-
  from assms have 
    "RightTranslation(G,P,g):GG" and
    "RightTranslation(G,P,g¯):GG" and
    "RightTranslation(G,P,g) O RightTranslation(G,P,g¯) = id(G)"
    "RightTranslation(G,P,g¯) O RightTranslation(G,P,g) = id(G)"
  using inverse_in_group group0_5_L1 trans_comp_id by auto
  then show "RightTranslation(G,P,g)  bij(G,G)" using fg_imp_bijective by simp
  from assms have 
    "LeftTranslation(G,P,g):GG" and
    "LeftTranslation(G,P,g¯):GG" and
    "LeftTranslation(G,P,g) O LeftTranslation(G,P,g¯) = id(G)"
    "LeftTranslation(G,P,g¯) O LeftTranslation(G,P,g) = id(G)"
    using inverse_in_group group0_5_L1 trans_comp_id by auto
  then show "LeftTranslation(G,P,g)  bij(G,G)" using fg_imp_bijective by simp
qed

textConverse of a translation is translation by the inverse.

lemma (in group0) trans_conv_inv: assumes "gG" shows
  "converse(RightTranslation(G,P,g)) = RightTranslation(G,P,g¯)" and
  "converse(LeftTranslation(G,P,g)) = LeftTranslation(G,P,g¯)" and
  "LeftTranslation(G,P,g) = converse(LeftTranslation(G,P,g¯))" and
  "RightTranslation(G,P,g) = converse(RightTranslation(G,P,g¯))"
proof -
  from assms have
    "RightTranslation(G,P,g)  bij(G,G)"  "RightTranslation(G,P,g¯)  bij(G,G)" and
    "LeftTranslation(G,P,g)  bij(G,G)"  "LeftTranslation(G,P,g¯)  bij(G,G)"
    using trans_bij inverse_in_group by auto
  moreover from assms have
    "RightTranslation(G,P,g¯) O RightTranslation(G,P,g) = id(G)" and
    "LeftTranslation(G,P,g¯) O LeftTranslation(G,P,g) = id(G)" and
    "LeftTranslation(G,P,g) O LeftTranslation(G,P,g¯) = id(G)" and
    "LeftTranslation(G,P,g¯) O LeftTranslation(G,P,g) = id(G)"
    using trans_comp_id by auto
  ultimately show 
    "converse(RightTranslation(G,P,g)) = RightTranslation(G,P,g¯)" and
    "converse(LeftTranslation(G,P,g)) = LeftTranslation(G,P,g¯)" and  
    "LeftTranslation(G,P,g) = converse(LeftTranslation(G,P,g¯))" and
    "RightTranslation(G,P,g) = converse(RightTranslation(G,P,g¯))"
    using comp_id_conv by auto
qed
  
textThe image of a set by translation is the same as the inverse image by
by the inverse element translation.

lemma (in group0) trans_image_vimage: assumes "gG" shows
  "LeftTranslation(G,P,g)``(A) = LeftTranslation(G,P,g¯)-``(A)" and
  "RightTranslation(G,P,g)``(A) = RightTranslation(G,P,g¯)-``(A)"
  using assms trans_conv_inv vimage_converse by auto

textAnother way of looking at translations is that they are sections
  of the group operation.

lemma (in group0) trans_eq_section: assumes "gG" shows
  "RightTranslation(G,P,g) = Fix2ndVar(P,g)" and
  "LeftTranslation(G,P,g) =  Fix1stVar(P,g)"
proof -
  let ?T = "RightTranslation(G,P,g)"
  let ?F = "Fix2ndVar(P,g)"
  from assms have "?T: GG" and "?F: GG"
    using group0_5_L1 group_oper_fun fix_2nd_var_fun by auto
  moreover from assms have "aG. ?T`(a) = ?F`(a)"
    using group0_5_L2 group_oper_fun fix_var_val by simp
  ultimately show "?T = ?F" by (rule func_eq)
next
  let ?T = "LeftTranslation(G,P,g)"
  let ?F = "Fix1stVar(P,g)"
  from assms have "?T: GG" and "?F: GG"
    using group0_5_L1 group_oper_fun fix_1st_var_fun by auto
  moreover from assms have "aG. ?T`(a) = ?F`(a)"
    using group0_5_L2 group_oper_fun fix_var_val by simp
  ultimately show "?T = ?F" by (rule func_eq)
qed

textA lemma demonstrating what is the left translation of a set

lemma (in group0) ltrans_image: assumes A1: "VG" and A2: "xG"
  shows "LeftTranslation(G,P,x)``(V) = {xv. vV}"
proof -
  from assms have "LeftTranslation(G,P,x)``(V) = {LeftTranslation(G,P,x)`(v). vV}"
    using group0_5_L1 func_imagedef by blast
  moreover from assms have "vV. LeftTranslation(G,P,x)`(v) = xv"
    using group0_5_L2 by auto
  ultimately show ?thesis by auto
qed

textA lemma demonstrating what is the right translation of a set

lemma (in group0) rtrans_image: assumes A1: "VG" and A2: "xG"
  shows "RightTranslation(G,P,x)``(V) = {vx. vV}"
proof -
  from assms have "RightTranslation(G,P,x)``(V) = {RightTranslation(G,P,x)`(v). vV}"
    using group0_5_L1 func_imagedef by blast
  moreover from assms have "vV. RightTranslation(G,P,x)`(v) = vx"
    using group0_5_L2 by auto
  ultimately show ?thesis by auto
qed

textRight and left translations of a set are subsets of the group. 
  Interestingly, we do not have to assume the set is a subset of the group. 

lemma (in group0) lrtrans_in_group: assumes "xG"
  shows "LeftTranslation(G,P,x)``(V)  G" and "RightTranslation(G,P,x)``(V)  G" 
proof -
  from assms have "LeftTranslation(G,P,x):GG" and "RightTranslation(G,P,x):GG"
    using group0_5_L1 by auto
  then show "LeftTranslation(G,P,x)``(V)  G" and "RightTranslation(G,P,x)``(V)  G"
    using func1_1_L6(2) by auto
qed

textA technical lemma about solving equations with translations.

lemma (in group0) ltrans_inv_in: assumes A1: "VG" and A2: "yG" and
  A3: "x  LeftTranslation(G,P,y)``(GroupInv(G,P)``(V))"
  shows "y  LeftTranslation(G,P,x)``(V)"
proof -
  have "xG"
  proof -
    from A2 have "LeftTranslation(G,P,y):GG" using group0_5_L1 by simp
    then have "LeftTranslation(G,P,y)``(GroupInv(G,P)``(V))  G"
      using func1_1_L6 by simp
    with A3 show "xG" by auto
  qed
  have "vV. x = yv¯"
  proof -
    have "GroupInv(G,P): GG" using groupAssum group0_2_T2
      by simp
    with assms obtain z where "z  GroupInv(G,P)``(V)" and "x = yz"
      using func1_1_L6 ltrans_image by auto
    with A1 GroupInv(G,P): GG show ?thesis using func_imagedef by auto
  qed
  then obtain v where "vV" and "x = yv¯" by auto
  with A1 A2 have "y = xv" using inv_cancel_two by auto
  with assms xG vV show ?thesis using ltrans_image by auto
qed

textWe can look at the result of interval arithmetic operation as union of
  left translated sets.

lemma (in group0) image_ltrans_union: assumes "AG" "BG" shows
  "(P {lifted to subsets of} G)`A,B = (aA.  LeftTranslation(G,P,a)``(B))"
proof
  from assms have I: "(P {lifted to subsets of} G)`A,B = {ab . a,b  A×B}"
    using group_oper_fun lift_subsets_explained by simp
  { fix c assume "c  (P {lifted to subsets of} G)`A,B"
    with I obtain a b where "c = ab" and "aA"  "bB" by auto
    hence "c  {ab. bB}" by auto
    moreover from assms aA have 
      "LeftTranslation(G,P,a)``(B) = {ab. bB}" using ltrans_image by auto
    ultimately have "c  LeftTranslation(G,P,a)``(B)" by simp
    with aA have "c  (aA.  LeftTranslation(G,P,a)``(B))" by auto
  } thus "(P {lifted to subsets of} G)`A,B  (aA.  LeftTranslation(G,P,a)``(B))"
    by auto
  { fix c assume "c  (aA.  LeftTranslation(G,P,a)``(B))"
    then obtain a where "aA" and "c  LeftTranslation(G,P,a)``(B)"
      by auto
    moreover from assms aA have "LeftTranslation(G,P,a)``(B) = {ab. bB}"
      using ltrans_image by auto
    ultimately obtain b where "bB" and "c = ab" by auto
    with I aA have "c  (P {lifted to subsets of} G)`A,B" by auto
  } thus "(aA. LeftTranslation(G,P,a)``(B))  (P {lifted to subsets of} G)`A,B"
    by auto
qed

text The right translation version of image_ltrans_union› The proof follows the same schema.

lemma (in group0) image_rtrans_union: assumes "AG" "BG" shows
  "(P {lifted to subsets of} G)`A,B = (bB.  RightTranslation(G,P,b)``(A))"
proof
  from assms have I: "(P {lifted to subsets of} G)`A,B = {ab . a,b  A×B}"
    using group_oper_fun lift_subsets_explained by simp
  { fix c assume "c  (P {lifted to subsets of} G)`A,B"
    with I obtain a b where "c = ab" and "aA"  "bB" by auto
    hence "c  {ab. aA}" by auto
    moreover from assms bB have 
      "RightTranslation(G,P,b)``(A) = {ab. aA}" using rtrans_image by auto
    ultimately have "c  RightTranslation(G,P,b)``(A)" by simp
    with bB have "c  (bB.  RightTranslation(G,P,b)``(A))" by auto
  } thus "(P {lifted to subsets of} G)`A,B  (bB.  RightTranslation(G,P,b)``(A))"
    by auto
  { fix c assume "c  (bB.  RightTranslation(G,P,b)``(A))"
    then obtain b where "bB" and "c  RightTranslation(G,P,b)``(A)"
      by auto
    moreover from assms bB have "RightTranslation(G,P,b)``(A) = {ab. aA}"
      using rtrans_image by auto
    ultimately obtain a where "aA" and "c = ab" by auto
    with I bB have "c  (P {lifted to subsets of} G)`A,B" by auto
  } thus "(bB. RightTranslation(G,P,b)``(A))  (P {lifted to subsets of} G)`A,B"
    by auto
qed

textIf the neutral element belongs to a set, then an element of group belongs
  the translation of that set.

lemma (in group0) neut_trans_elem: 
  assumes A1: "AG" "gG" and A2: "𝟭A" 
  shows "g  LeftTranslation(G,P,g)``(A)" "g  RightTranslation(G,P,g)``(A)"
proof -
  from assms have "g𝟭  LeftTranslation(G,P,g)``(A)"
    using ltrans_image by auto
  with A1 show "g  LeftTranslation(G,P,g)``(A)" using group0_2_L2 by simp
  from assms have "𝟭g  RightTranslation(G,P,g)``(A)"
    using rtrans_image by auto
  with A1 show "g  RightTranslation(G,P,g)``(A)" using group0_2_L2 by simp
qed

textThe neutral element belongs to the translation of a set by the inverse
  of an element that belongs to it.

lemma (in group0) elem_trans_neut: assumes A1: "AG" and A2: "gA"
  shows "𝟭  LeftTranslation(G,P,g¯)``(A)" "𝟭  RightTranslation(G,P,g¯)``(A)"
proof -
  from assms have ginv:"g¯  G" using inverse_in_group by auto
  with assms have "g¯g  LeftTranslation(G,P,g¯)``(A)"
    using ltrans_image by auto
  moreover from assms have "g¯g = 𝟭" using group0_2_L6 by auto
  ultimately show "𝟭  LeftTranslation(G,P,g¯)``(A)" by simp
  from ginv assms have "gg¯  RightTranslation(G,P,g¯)``(A)"
    using rtrans_image by auto
  moreover from assms have "gg¯ = 𝟭" using group0_2_L6 by auto
  ultimately show "𝟭  RightTranslation(G,P,g¯)``(A)" by simp
qed

subsectionOdd functions

textThis section is about odd functions.

textOdd functions are those that commute with the group inverse:
  $f(a^{-1}) = (f(a))^{-1}.$

definition
  "IsOdd(G,P,f)  (aG. f`(GroupInv(G,P)`(a)) = GroupInv(G,P)`(f`(a)) )"

textLet's see the definition of an odd function in a more readable 
  notation.

lemma (in group0) group0_6_L1: 
  shows "IsOdd(G,P,p)  ( aG. p`(a¯) = (p`(a))¯ )"
  using IsOdd_def by simp

textWe can express the definition of an odd function in two ways.

lemma (in group0) group0_6_L2:
  assumes A1: "p : GG" 
  shows 
  "(aG. p`(a¯) = (p`(a))¯)  (aG. (p`(a¯))¯ = p`(a))"
proof
  assume "aG. p`(a¯) = (p`(a))¯"
  with A1 show "aG. (p`(a¯))¯ = p`(a)"
    using apply_funtype group_inv_of_inv by simp
next assume A2: "aG. (p`(a¯))¯ = p`(a)"
  { fix a assume "aG"
    with A1 A2  have 
      "p`(a¯)  G" and "((p`(a¯))¯)¯ =  (p`(a))¯"
    using apply_funtype inverse_in_group by auto
  then have "p`(a¯) = (p`(a))¯"
    using group_inv_of_inv by simp
  } then show "aG. p`(a¯) = (p`(a))¯" by simp
qed

subsectionSubgroups and interval arithmetic

text The section Binary operations› in the func_ZF› theory defines the notion of 
  "lifting operation to subsets". In short, every binary operation 
  $f:X\times X \longrightarrow X $ on a set $X$ defines an operation
  on the subsets of $X$ defined by $F(A,B) = \{ f\langle x,y \rangle | x\in A, y\in B\}$.
  In the group context using multiplicative notation we can write this as 
  $H\cdot K = \{ x\cdot y | x\in A, y\in B\}$. Similarly we can define $H^{-1}=\{ x^{-1} | x\in H\}$.
  In this section we study properties of these derived operations and how they relate to the concept
  of subgroups.

textThe next locale extends the groups0› locale with notation related to interval arithmetics.

locale group4 = group0 +
  fixes sdot (infixl "\<sdot>" 70)
  defines sdot_def [simp]: "A\<sdot>B   (P {lifted to subsets of} G)`A,B"

  fixes sinv ("_\<sinv> " [90] 91)
  defines sinv_def[simp]: "A\<sinv>  GroupInv(G,P)``(A)"

textThe next lemma shows a somewhat more explicit way of defining the product 
  of two subsets of a group.

lemma (in group4) interval_prod: assumes "AG" "BG" 
  shows "A\<sdot>B =  {xy. x,y  A×B}"
  using assms group_oper_fun lift_subsets_explained by auto

textProduct of elements of subsets of the group is in the set product of those subsets

lemma (in group4) interval_prod_el: assumes "AG" "BG" "xA" "yB"
  shows "xy  A\<sdot>B"
  using assms interval_prod by auto

textAn alternative definition of a group inverse of a set.

lemma (in group4) interval_inv: assumes "AG"
  shows "A\<sinv> = {x¯.xA}"
proof -
  from groupAssum have "GroupInv(G,P):GG" using group0_2_T2 by simp
  with assms show "A\<sinv> = {x¯.xA}" using func_imagedef by simp
qed

textGroup inverse of a set is a subset of the group. 
  Interestingly we don't need to assume the set is a subset of the group.

lemma (in group4) interval_inv_cl: shows "A\<sinv>  G"
proof -
  from groupAssum have "GroupInv(G,P):GG" using group0_2_T2 by simp
  then show "A\<sinv>  G" using func1_1_L6(2) by simp
qed

textThe product of two subsets of a group is a subset of the group.

lemma (in group4) interval_prod_closed: assumes "AG" "BG"
  shows "A\<sdot>B  G"
proof
  fix z assume "z  A\<sdot>B"
  with assms obtain x y where "xA" "yB" "z=xy" using interval_prod by auto
  with assms show "zG" using group_op_closed by auto
qed

text The product of sets operation is associative.

lemma (in group4) interval_prod_assoc: assumes "AG" "BG" "CG"
  shows "A\<sdot>B\<sdot>C = A\<sdot>(B\<sdot>C)"
proof -
  from groupAssum have "(P {lifted to subsets of} G) {is associative on} Pow(G)" 
    unfolding IsAgroup_def IsAmonoid_def using lift_subset_assoc by simp
  with assms show ?thesis unfolding IsAssociative_def by auto
qed

text A simple rearrangement following from associativity of the product of sets operation.

lemma (in group4) interval_prod_rearr1: assumes "AG" "BG" "CG" "DG"
  shows "A\<sdot>B\<sdot>(C\<sdot>D) = A\<sdot>(B\<sdot>C)\<sdot>D"
proof -
  from assms(1,2) have "A\<sdot>B  G" using interval_prod_closed by simp
  with assms(3,4) have "A\<sdot>B\<sdot>(C\<sdot>D) = A\<sdot>B\<sdot>C\<sdot>D"
    using interval_prod_assoc by simp
  also from assms(1,2,3) have "A\<sdot>B\<sdot>C\<sdot>D = A\<sdot>(B\<sdot>C)\<sdot>D"
    using interval_prod_assoc by simp
  finally show ?thesis by simp
qed

textA subset $A$ of the group is closed with respect to the group operation 
  iff $A\cdot A \subseteq A$. 

lemma (in group4) subset_gr_op_cl: assumes "AG" 
  shows "(A {is closed under} P)  A\<sdot>A  A"
proof
  assume "A {is closed under} P"
  { fix z assume "z  A\<sdot>A"
    with assms obtain x y where "xA" "yA" and "z=xy" using interval_prod by auto
    with A {is closed under} P have "zA" unfolding IsOpClosed_def by simp
  } thus "A\<sdot>A  A" by auto
next
  assume "A\<sdot>A  A"
  { fix x y assume "xA" "yA"
    with assms have "xy  A\<sdot>A" using interval_prod by auto
    with A\<sdot>A  A have "xy  A" by auto
  } then show "A {is closed under} P" unfolding IsOpClosed_def by simp
qed

textInverse and square of a subgroup is this subgroup.

lemma (in group4) subgroup_inv_sq: assumes "IsAsubgroup(H,P)" 
   shows "H\<sinv> = H" and "H\<sdot>H = H"
proof
  from assms have "HG" using group0_3_L2 by simp
  with assms show "H\<sinv>  H" using interval_inv group0_3_T3A by auto
  { fix x assume "xH"
    with assms have "(x¯)¯  {y¯.yH}" using group0_3_T3A by auto
    moreover from xH HG have "(x¯)¯ = x" using group_inv_of_inv by auto
    ultimately have "x  {y¯.yH}" by auto
    with HG have "x  H\<sinv>" using interval_inv by simp
  } thus "H  H\<sinv>" by auto
  from assms have "H {is closed under} P" using group0_3_L6 unfolding IsOpClosed_def by simp
  with assms have "H\<sdot>H  H" using subset_gr_op_cl group0_3_L2 by simp
  moreover
  { fix x assume "xH"
    with assms have "xG" using group0_3_L2 by auto
    from assms HG xH have "x𝟭  H\<sdot>H" using group0_3_L5 interval_prod by auto
    with xG have "x  H\<sdot>H" using group0_2_L2 by simp
  } hence "H  H\<sdot>H" by auto
  ultimately show "H\<sdot>H = H" by auto
qed

textInverse of a product two sets is a product of inverses with the reversed order.

lemma (in group4) interval_prod_inv: assumes "AG" "BG"
  shows 
    "(A\<sdot>B)\<sinv> = {(xy)¯.x,y  A×B}"
    "(A\<sdot>B)\<sinv> = {y¯x¯.x,y  A×B}"
    "(A\<sdot>B)\<sinv> = (B\<sinv>)\<sdot>(A\<sinv>)"
proof -
  from assms have "(A\<sdot>B)  G" using interval_prod_closed by simp
  then have I: "(A\<sdot>B)\<sinv> = {z¯.zA\<sdot>B}" using interval_inv by simp
  show II: "(A\<sdot>B)\<sinv> = {(xy)¯.x,y  A×B}"
  proof
    { fix p assume "p  (A\<sdot>B)\<sinv>"
      with I obtain z where "p=z¯" and "zA\<sdot>B" by auto
      with assms obtain x y where "x,y  A×B" and "z=xy" using interval_prod by auto
      with p=z¯ have "p{(xy)¯.x,y  A×B}" by auto
    } thus "(A\<sdot>B)\<sinv>  {(xy)¯.x,y  A×B}" by blast
    { fix p assume "p{(xy)¯.x,y  A×B}"
      then obtain x y where "xA" "yB" and "p=(xy)¯" by auto
      with assms (A\<sdot>B)  G have "p(A\<sdot>B)\<sinv>" using interval_prod interval_inv
        by auto
    } thus "{(xy)¯.x,y  A×B}  (A\<sdot>B)\<sinv>" by blast
  qed
  have "{(xy)¯.x,y  A×B} = {y¯x¯.x,y  A×B}"
  proof 
    { fix p assume "p  {(xy)¯.x,y  A×B}"
      then obtain x y where "xA" "yB" and "p=(xy)¯" by auto
      with assms have "y¯x¯ = (xy)¯" using group_inv_of_two by auto
      with p=(xy)¯ have "p = y¯x¯" by simp
      with xA yB have "p{y¯x¯.x,y  A×B}" by auto
    } thus "{(xy)¯.x,y  A×B}  {y¯x¯.x,y  A×B}" by blast
    { fix p assume "p{y¯x¯.x,y  A×B}"
      then obtain x y where "xA" "yB" and "p=y¯x¯" by auto
      with assms have "p = (xy)¯" using group_inv_of_two by auto
      with xA yB have "p  {(xy)¯.x,y  A×B}" by auto
    } thus "{y¯x¯.x,y  A×B}  {(xy)¯.x,y  A×B}" by blast
  qed
  with II show III: "(A\<sdot>B)\<sinv> = {y¯x¯.x,y  A×B}" by simp
  have "{y¯x¯.x,y  A×B} = (B\<sinv>)\<sdot>(A\<sinv>)"
  proof    
    { fix p assume "p{y¯x¯.x,y  A×B}"
      then obtain x y where "xA" "yB" and "p=y¯x¯" by auto
      with assms have "y¯  (B\<sinv>)" and "x¯  (A\<sinv>)"
        using interval_inv by auto
      with p=y¯x¯ have "p  (B\<sinv>)\<sdot>(A\<sinv>)" using interval_inv_cl interval_prod
        by auto
    } thus "{y¯x¯.x,y  A×B}  (B\<sinv>)\<sdot>(A\<sinv>)" by blast
    { fix p assume "p  (B\<sinv>)\<sdot>(A\<sinv>)"
      then obtain y x where "yB\<sinv>" "xA\<sinv>" and "p=yx"
        using interval_inv_cl interval_prod by auto
      with assms obtain x1 y1 where "x1  A" "y1  B" and "x=x1¯" "y=y1¯" using interval_inv
        by auto
      with p=yx have "p  {y¯x¯.x,y  A×B}" by auto 
    } thus "(B\<sinv>)\<sdot>(A\<sinv>)  {y¯x¯.x,y  A×B}" by blast
  qed
  with III show "(A\<sdot>B)\<sinv> = (B\<sinv>)\<sdot>(A\<sinv>)" by simp
qed

text If $H,K$ are subgroups then $H\cdot K$ is a subgroup iff $H\cdot K = K\cdot H$. 

theorem (in group4) prod_subgr_subgr: 
  assumes "IsAsubgroup(H,P)" and "IsAsubgroup(K,P)"
  shows "IsAsubgroup(H\<sdot>K,P)   H\<sdot>K = K\<sdot>H"
proof
  assume "IsAsubgroup(H\<sdot>K,P)"
  then have "(H\<sdot>K)\<sinv> = H\<sdot>K" using subgroup_inv_sq(1) by simp
  with assms show "H\<sdot>K = K\<sdot>H" using group0_3_L2 interval_prod_inv subgroup_inv_sq(1)
    by auto
next
  from assms have "HG" and "KG" using group0_3_L2 by auto
  have I: "H\<sdot>K  0"
  proof -
    let ?x = "𝟭" let ?y = "𝟭"
    from assms have "?x?y  (H\<sdot>K)" using group0_3_L5 group0_3_L2 interval_prod 
      by auto
    thus ?thesis by auto
  qed
  from HG KG have II: "H\<sdot>K  G" using interval_prod_closed by simp 
  assume "H\<sdot>K = K\<sdot>H"
  have III: "(H\<sdot>K){is closed under} P"
  proof -
    have "(H\<sdot>K)\<sdot>(H\<sdot>K) = H\<sdot>K"
    proof -
      from HG KG have "(H\<sdot>K)\<sdot>(H\<sdot>K) = H\<sdot>(K\<sdot>H)\<sdot>K"
        using interval_prod_rearr1 by simp
      also from H\<sdot>K = K\<sdot>H have "... = H\<sdot>(H\<sdot>K)\<sdot>K" by simp
      also from HG KG have "... = (H\<sdot>H)\<sdot>(K\<sdot>K)"
        using interval_prod_rearr1 by simp
      also from assms have "... = H\<sdot>K" using subgroup_inv_sq(2) by simp
      finally show ?thesis by simp
    qed
    with H\<sdot>K  G show ?thesis using subset_gr_op_cl by simp
  qed
  have IV: "x  H\<sdot>K. x¯  H\<sdot>K"
  proof -
    { fix x assume "x  H\<sdot>K" 
      with H\<sdot>K  G have "x¯  (H\<sdot>K)\<sinv>" using interval_inv by auto
      with assms HG KG H\<sdot>K = K\<sdot>H have "x¯  H\<sdot>K"
        using interval_prod_inv subgroup_inv_sq(1) by simp
    } thus ?thesis by auto
  qed
  from I II III IV show "IsAsubgroup(H\<sdot>K,P)" using group0_3_T3 by simp
qed

end