src/HOL/AxClasses/Group.thy
changeset 10134 537206cc738f
child 10681 ec76e17f73c5
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/HOL/AxClasses/Group.thy	Tue Oct 03 18:30:56 2000 +0200
     1.3 @@ -0,0 +1,124 @@
     1.4 +(*  Title:      HOL/AxClasses/Group.thy
     1.5 +    ID:         $Id$
     1.6 +    Author:     Markus Wenzel, TU Muenchen
     1.7 +*)
     1.8 +
     1.9 +theory Group = Main:
    1.10 +
    1.11 +subsection {* Monoids and Groups *}
    1.12 +
    1.13 +consts
    1.14 +  times :: "'a => 'a => 'a"    (infixl "[*]" 70)
    1.15 +  inverse :: "'a => 'a"
    1.16 +  one :: 'a
    1.17 +
    1.18 +
    1.19 +axclass monoid < "term"
    1.20 +  assoc:      "(x [*] y) [*] z = x [*] (y [*] z)"
    1.21 +  left_unit:  "one [*] x = x"
    1.22 +  right_unit: "x [*] one = x"
    1.23 +
    1.24 +axclass semigroup < "term"
    1.25 +  assoc: "(x [*] y) [*] z = x [*] (y [*] z)"
    1.26 +
    1.27 +axclass group < semigroup
    1.28 +  left_unit:    "one [*] x = x"
    1.29 +  left_inverse: "inverse x [*] x = one"
    1.30 +
    1.31 +axclass agroup < group
    1.32 +  commute: "x [*] y = y [*] x"
    1.33 +
    1.34 +
    1.35 +subsection {* Abstract reasoning *}
    1.36 +
    1.37 +theorem group_right_inverse: "x [*] inverse x = (one::'a::group)"
    1.38 +proof -
    1.39 +  have "x [*] inverse x = one [*] (x [*] inverse x)"
    1.40 +    by (simp only: group.left_unit)
    1.41 +  also have "... = one [*] x [*] inverse x"
    1.42 +    by (simp only: semigroup.assoc)
    1.43 +  also have "... = inverse (inverse x) [*] inverse x [*] x [*] inverse x"
    1.44 +    by (simp only: group.left_inverse)
    1.45 +  also have "... = inverse (inverse x) [*] (inverse x [*] x) [*] inverse x"
    1.46 +    by (simp only: semigroup.assoc)
    1.47 +  also have "... = inverse (inverse x) [*] one [*] inverse x"
    1.48 +    by (simp only: group.left_inverse)
    1.49 +  also have "... = inverse (inverse x) [*] (one [*] inverse x)"
    1.50 +    by (simp only: semigroup.assoc)
    1.51 +  also have "... = inverse (inverse x) [*] inverse x"
    1.52 +    by (simp only: group.left_unit)
    1.53 +  also have "... = one"
    1.54 +    by (simp only: group.left_inverse)
    1.55 +  finally show ?thesis .
    1.56 +qed
    1.57 +
    1.58 +theorem group_right_unit: "x [*] one = (x::'a::group)"
    1.59 +proof -
    1.60 +  have "x [*] one = x [*] (inverse x [*] x)"
    1.61 +    by (simp only: group.left_inverse)
    1.62 +  also have "... = x [*] inverse x [*] x"
    1.63 +    by (simp only: semigroup.assoc)
    1.64 +  also have "... = one [*] x"
    1.65 +    by (simp only: group_right_inverse)
    1.66 +  also have "... = x"
    1.67 +    by (simp only: group.left_unit)
    1.68 +  finally show ?thesis .
    1.69 +qed
    1.70 +
    1.71 +
    1.72 +subsection {* Abstract instantiation *}
    1.73 +
    1.74 +instance monoid < semigroup
    1.75 +proof intro_classes
    1.76 +  fix x y z :: "'a::monoid"
    1.77 +  show "x [*] y [*] z = x [*] (y [*] z)"
    1.78 +    by (rule monoid.assoc)
    1.79 +qed
    1.80 +
    1.81 +instance group < monoid
    1.82 +proof intro_classes
    1.83 +  fix x y z :: "'a::group"
    1.84 +  show "x [*] y [*] z = x [*] (y [*] z)"
    1.85 +    by (rule semigroup.assoc)
    1.86 +  show "one [*] x = x"
    1.87 +    by (rule group.left_unit)
    1.88 +  show "x [*] one = x"
    1.89 +    by (rule group_right_unit)
    1.90 +qed
    1.91 +
    1.92 +
    1.93 +subsection {* Concrete instantiation *}
    1.94 +
    1.95 +defs (overloaded)
    1.96 +  times_bool_def:   "x [*] y == x ~= (y::bool)"
    1.97 +  inverse_bool_def: "inverse x == x::bool"
    1.98 +  unit_bool_def:    "one == False"
    1.99 +
   1.100 +instance bool :: agroup
   1.101 +proof (intro_classes,
   1.102 +    unfold times_bool_def inverse_bool_def unit_bool_def)
   1.103 +  fix x y z
   1.104 +  show "((x ~= y) ~= z) = (x ~= (y ~= z))" by blast
   1.105 +  show "(False ~= x) = x" by blast
   1.106 +  show "(x ~= x) = False" by blast
   1.107 +  show "(x ~= y) = (y ~= x)" by blast
   1.108 +qed
   1.109 +
   1.110 +
   1.111 +subsection {* Lifting and Functors *}
   1.112 +
   1.113 +defs (overloaded)
   1.114 +  times_prod_def: "p [*] q == (fst p [*] fst q, snd p [*] snd q)"
   1.115 +
   1.116 +instance * :: (semigroup, semigroup) semigroup
   1.117 +proof (intro_classes, unfold times_prod_def)
   1.118 +  fix p q r :: "'a::semigroup * 'b::semigroup"
   1.119 +  show
   1.120 +    "(fst (fst p [*] fst q, snd p [*] snd q) [*] fst r,
   1.121 +      snd (fst p [*] fst q, snd p [*] snd q) [*] snd r) =
   1.122 +       (fst p [*] fst (fst q [*] fst r, snd q [*] snd r),
   1.123 +        snd p [*] snd (fst q [*] fst r, snd q [*] snd r))"
   1.124 +    by (simp add: semigroup.assoc)
   1.125 +qed
   1.126 +
   1.127 +end