src/HOL/AxClasses/Group.thy
 author wenzelm Tue Oct 03 18:30:56 2000 +0200 (2000-10-03) changeset 10134 537206cc738f child 10681 ec76e17f73c5 permissions -rw-r--r--
moved axclass tutorial examples to top dir;
```     1 (*  Title:      HOL/AxClasses/Group.thy
```
```     2     ID:         \$Id\$
```
```     3     Author:     Markus Wenzel, TU Muenchen
```
```     4 *)
```
```     5
```
```     6 theory Group = Main:
```
```     7
```
```     8 subsection {* Monoids and Groups *}
```
```     9
```
```    10 consts
```
```    11   times :: "'a => 'a => 'a"    (infixl "[*]" 70)
```
```    12   inverse :: "'a => 'a"
```
```    13   one :: 'a
```
```    14
```
```    15
```
```    16 axclass monoid < "term"
```
```    17   assoc:      "(x [*] y) [*] z = x [*] (y [*] z)"
```
```    18   left_unit:  "one [*] x = x"
```
```    19   right_unit: "x [*] one = x"
```
```    20
```
```    21 axclass semigroup < "term"
```
```    22   assoc: "(x [*] y) [*] z = x [*] (y [*] z)"
```
```    23
```
```    24 axclass group < semigroup
```
```    25   left_unit:    "one [*] x = x"
```
```    26   left_inverse: "inverse x [*] x = one"
```
```    27
```
```    28 axclass agroup < group
```
```    29   commute: "x [*] y = y [*] x"
```
```    30
```
```    31
```
```    32 subsection {* Abstract reasoning *}
```
```    33
```
```    34 theorem group_right_inverse: "x [*] inverse x = (one::'a::group)"
```
```    35 proof -
```
```    36   have "x [*] inverse x = one [*] (x [*] inverse x)"
```
```    37     by (simp only: group.left_unit)
```
```    38   also have "... = one [*] x [*] inverse x"
```
```    39     by (simp only: semigroup.assoc)
```
```    40   also have "... = inverse (inverse x) [*] inverse x [*] x [*] inverse x"
```
```    41     by (simp only: group.left_inverse)
```
```    42   also have "... = inverse (inverse x) [*] (inverse x [*] x) [*] inverse x"
```
```    43     by (simp only: semigroup.assoc)
```
```    44   also have "... = inverse (inverse x) [*] one [*] inverse x"
```
```    45     by (simp only: group.left_inverse)
```
```    46   also have "... = inverse (inverse x) [*] (one [*] inverse x)"
```
```    47     by (simp only: semigroup.assoc)
```
```    48   also have "... = inverse (inverse x) [*] inverse x"
```
```    49     by (simp only: group.left_unit)
```
```    50   also have "... = one"
```
```    51     by (simp only: group.left_inverse)
```
```    52   finally show ?thesis .
```
```    53 qed
```
```    54
```
```    55 theorem group_right_unit: "x [*] one = (x::'a::group)"
```
```    56 proof -
```
```    57   have "x [*] one = x [*] (inverse x [*] x)"
```
```    58     by (simp only: group.left_inverse)
```
```    59   also have "... = x [*] inverse x [*] x"
```
```    60     by (simp only: semigroup.assoc)
```
```    61   also have "... = one [*] x"
```
```    62     by (simp only: group_right_inverse)
```
```    63   also have "... = x"
```
```    64     by (simp only: group.left_unit)
```
```    65   finally show ?thesis .
```
```    66 qed
```
```    67
```
```    68
```
```    69 subsection {* Abstract instantiation *}
```
```    70
```
```    71 instance monoid < semigroup
```
```    72 proof intro_classes
```
```    73   fix x y z :: "'a::monoid"
```
```    74   show "x [*] y [*] z = x [*] (y [*] z)"
```
```    75     by (rule monoid.assoc)
```
```    76 qed
```
```    77
```
```    78 instance group < monoid
```
```    79 proof intro_classes
```
```    80   fix x y z :: "'a::group"
```
```    81   show "x [*] y [*] z = x [*] (y [*] z)"
```
```    82     by (rule semigroup.assoc)
```
```    83   show "one [*] x = x"
```
```    84     by (rule group.left_unit)
```
```    85   show "x [*] one = x"
```
```    86     by (rule group_right_unit)
```
```    87 qed
```
```    88
```
```    89
```
```    90 subsection {* Concrete instantiation *}
```
```    91
```
```    92 defs (overloaded)
```
```    93   times_bool_def:   "x [*] y == x ~= (y::bool)"
```
```    94   inverse_bool_def: "inverse x == x::bool"
```
```    95   unit_bool_def:    "one == False"
```
```    96
```
```    97 instance bool :: agroup
```
```    98 proof (intro_classes,
```
```    99     unfold times_bool_def inverse_bool_def unit_bool_def)
```
```   100   fix x y z
```
```   101   show "((x ~= y) ~= z) = (x ~= (y ~= z))" by blast
```
```   102   show "(False ~= x) = x" by blast
```
```   103   show "(x ~= x) = False" by blast
```
```   104   show "(x ~= y) = (y ~= x)" by blast
```
```   105 qed
```
```   106
```
```   107
```
```   108 subsection {* Lifting and Functors *}
```
```   109
```
```   110 defs (overloaded)
```
```   111   times_prod_def: "p [*] q == (fst p [*] fst q, snd p [*] snd q)"
```
```   112
```
```   113 instance * :: (semigroup, semigroup) semigroup
```
```   114 proof (intro_classes, unfold times_prod_def)
```
```   115   fix p q r :: "'a::semigroup * 'b::semigroup"
```
```   116   show
```
```   117     "(fst (fst p [*] fst q, snd p [*] snd q) [*] fst r,
```
```   118       snd (fst p [*] fst q, snd p [*] snd q) [*] snd r) =
```
```   119        (fst p [*] fst (fst q [*] fst r, snd q [*] snd r),
```
```   120         snd p [*] snd (fst q [*] fst r, snd q [*] snd r))"
```
```   121     by (simp add: semigroup.assoc)
```
```   122 qed
```
```   123
```
```   124 end
```