|
8890
|
1 |
|
|
|
2 |
theory Group = Main:;
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
consts
|
|
|
6 |
times :: "'a => 'a => 'a" (infixl "\<Otimes>" 70)
|
|
|
7 |
inverse :: "'a => 'a" ("(_\<inv>)" [1000] 999)
|
|
|
8 |
one :: 'a ("\<unit>");
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
axclass
|
|
|
12 |
monoid < "term"
|
|
|
13 |
assoc: "(x \<Otimes> y) \<Otimes> z = x \<Otimes> (y \<Otimes> z)"
|
|
|
14 |
left_unit: "\<unit> \<Otimes> x = x"
|
|
|
15 |
right_unit: "x \<Otimes> \<unit> = x";
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
axclass
|
|
|
19 |
semigroup < "term"
|
|
|
20 |
assoc: "(x \<Otimes> y) \<Otimes> z = x \<Otimes> (y \<Otimes> z)";
|
|
|
21 |
|
|
|
22 |
axclass
|
|
|
23 |
group < semigroup
|
|
|
24 |
left_unit: "\<unit> \<Otimes> x = x"
|
|
|
25 |
left_inverse: "inverse x \<Otimes> x = \<unit>";
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
text {*
|
|
|
29 |
The group axioms only state the properties of left unit and inverse,
|
|
|
30 |
the right versions may be derived as follows.
|
|
|
31 |
*};
|
|
|
32 |
|
|
|
33 |
theorem group_right_inverse: "x \<Otimes> x\<inv> = (\<unit>::'a::group)";
|
|
|
34 |
proof -;
|
|
|
35 |
have "x \<Otimes> x\<inv> = \<unit> \<Otimes> (x \<Otimes> x\<inv>)";
|
|
|
36 |
by (simp only: group.left_unit);
|
|
|
37 |
also; have "... = (\<unit> \<Otimes> x) \<Otimes> x\<inv>";
|
|
|
38 |
by (simp only: semigroup.assoc);
|
|
|
39 |
also; have "... = (x\<inv>)\<inv> \<Otimes> x\<inv> \<Otimes> x \<Otimes> x\<inv>";
|
|
|
40 |
by (simp only: group.left_inverse);
|
|
|
41 |
also; have "... = (x\<inv>)\<inv> \<Otimes> (x\<inv> \<Otimes> x) \<Otimes> x\<inv>";
|
|
|
42 |
by (simp only: semigroup.assoc);
|
|
|
43 |
also; have "... = (x\<inv>)\<inv> \<Otimes> \<unit> \<Otimes> x\<inv>";
|
|
|
44 |
by (simp only: group.left_inverse);
|
|
|
45 |
also; have "... = (x\<inv>)\<inv> \<Otimes> (\<unit> \<Otimes> x\<inv>)";
|
|
|
46 |
by (simp only: semigroup.assoc);
|
|
|
47 |
also; have "... = (x\<inv>)\<inv> \<Otimes> x\<inv>";
|
|
|
48 |
by (simp only: group.left_unit);
|
|
|
49 |
also; have "... = \<unit>";
|
|
|
50 |
by (simp only: group.left_inverse);
|
|
|
51 |
finally; show ?thesis; .;
|
|
|
52 |
qed;
|
|
|
53 |
|
|
|
54 |
text {*
|
|
|
55 |
With $group_right_inverse$ already available,
|
|
|
56 |
$group_right_unit$\label{thm:group-right-unit} is now established
|
|
|
57 |
much easier.
|
|
|
58 |
*};
|
|
|
59 |
|
|
|
60 |
theorem group_right_unit: "x \<Otimes> \<unit> = (x::'a::group)";
|
|
|
61 |
proof -;
|
|
|
62 |
have "x \<Otimes> \<unit> = x \<Otimes> (x\<inv> \<Otimes> x)";
|
|
|
63 |
by (simp only: group.left_inverse);
|
|
|
64 |
also; have "... = x \<Otimes> x\<inv> \<Otimes> x";
|
|
|
65 |
by (simp only: semigroup.assoc);
|
|
|
66 |
also; have "... = \<unit> \<Otimes> 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;
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
axclass
|
|
|
75 |
agroup < group
|
|
|
76 |
commute: "x \<Otimes> y = y \<Otimes> x";
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
instance monoid < semigroup;
|
|
|
81 |
proof intro_classes;
|
|
|
82 |
fix x y z :: "'a::monoid";
|
|
|
83 |
show "x \<Otimes> y \<Otimes> z = x \<Otimes> (y \<Otimes> z)";
|
|
|
84 |
by (rule monoid.assoc);
|
|
|
85 |
qed;
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
instance group < monoid;
|
|
|
89 |
proof intro_classes;
|
|
|
90 |
fix x y z :: "'a::group";
|
|
|
91 |
show "x \<Otimes> y \<Otimes> z = x \<Otimes> (y \<Otimes> z)";
|
|
|
92 |
by (rule semigroup.assoc);
|
|
|
93 |
show "\<unit> \<Otimes> x = x";
|
|
|
94 |
by (rule group.left_unit);
|
|
|
95 |
show "x \<Otimes> \<unit> = x";
|
|
|
96 |
by (rule group_right_unit);
|
|
|
97 |
qed;
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
defs
|
|
|
102 |
times_bool_def: "x \<Otimes> y \\<equiv> x \\<noteq> (y\\<Colon>bool)"
|
|
|
103 |
inverse_bool_def: "x\<inv> \\<equiv> x\\<Colon>bool"
|
|
|
104 |
unit_bool_def: "\<unit> \\<equiv> False";
|
|
|
105 |
|
|
|
106 |
instance bool :: agroup;
|
|
|
107 |
proof (intro_classes,
|
|
|
108 |
unfold times_bool_def inverse_bool_def unit_bool_def);
|
|
|
109 |
fix x y z :: bool;
|
|
|
110 |
show "((x \\<noteq> y) \\<noteq> z) = (x \\<noteq> (y \\<noteq> z))"; by blast;
|
|
|
111 |
show "(False \\<noteq> x) = x"; by blast;
|
|
|
112 |
show "(x \\<noteq> x) = False"; by blast;
|
|
|
113 |
show "(x \\<noteq> y) = (y \\<noteq> x)"; by blast;
|
|
|
114 |
qed;
|
|
|
115 |
|
|
|
116 |
|
|
|
117 |
defs
|
|
|
118 |
prod_prod_def: "p \<Otimes> q \\<equiv> (fst p \<Otimes> fst q, snd p \<Otimes> snd q)";
|
|
|
119 |
|
|
|
120 |
instance * :: (semigroup, semigroup) semigroup;
|
|
|
121 |
proof (intro_classes, unfold prod_prod_def);
|
|
|
122 |
fix p q r :: "'a::semigroup * 'b::semigroup";
|
|
|
123 |
show
|
|
|
124 |
"(fst (fst p \<Otimes> fst q, snd p \<Otimes> snd q) \<Otimes> fst r,
|
|
|
125 |
snd (fst p \<Otimes> fst q, snd p \<Otimes> snd q) \<Otimes> snd r) =
|
|
|
126 |
(fst p \<Otimes> fst (fst q \<Otimes> fst r, snd q \<Otimes> snd r),
|
|
|
127 |
snd p \<Otimes> snd (fst q \<Otimes> fst r, snd q \<Otimes> snd r))";
|
|
|
128 |
by (simp add: semigroup.assoc);
|
|
|
129 |
qed;
|
|
|
130 |
|
|
|
131 |
end; |