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