| author | Lars Hupel <lars.hupel@mytum.de> |
| Thu, 19 Nov 2015 10:05:46 +0100 | |
| changeset 61702 | 2e89bc578935 |
| parent 61541 | 846c72206207 |
| child 61797 | 458b4e3720ab |
| permissions | -rw-r--r-- |
| 33026 | 1 |
(* Title: HOL/Isar_Examples/Group.thy |
|
6763
df12aef00932
Some bits of group theory. Demonstrate calculational proofs.
wenzelm
parents:
diff
changeset
|
2 |
Author: Markus Wenzel, TU Muenchen |
|
df12aef00932
Some bits of group theory. Demonstrate calculational proofs.
wenzelm
parents:
diff
changeset
|
3 |
*) |
|
df12aef00932
Some bits of group theory. Demonstrate calculational proofs.
wenzelm
parents:
diff
changeset
|
4 |
|
| 58882 | 5 |
section \<open>Basic group theory\<close> |
| 7748 | 6 |
|
| 31758 | 7 |
theory Group |
8 |
imports Main |
|
9 |
begin |
|
|
6763
df12aef00932
Some bits of group theory. Demonstrate calculational proofs.
wenzelm
parents:
diff
changeset
|
10 |
|
| 58614 | 11 |
subsection \<open>Groups and calculational reasoning\<close> |
| 6784 | 12 |
|
| 61541 | 13 |
text \<open>Groups over signature \<open>(\<times> :: \<alpha> \<Rightarrow> \<alpha> \<Rightarrow> \<alpha>, one :: \<alpha>, inverse :: \<alpha> \<Rightarrow> \<alpha>)\<close> |
14 |
are defined as an axiomatic type class as follows. Note that the parent |
|
15 |
class \<open>\<times>\<close> is provided by the basic HOL theory.\<close> |
|
|
6763
df12aef00932
Some bits of group theory. Demonstrate calculational proofs.
wenzelm
parents:
diff
changeset
|
16 |
|
| 35317 | 17 |
class group = times + one + inverse + |
| 37671 | 18 |
assumes group_assoc: "(x * y) * z = x * (y * z)" |
19 |
and group_left_one: "1 * x = x" |
|
20 |
and group_left_inverse: "inverse x * x = 1" |
|
|
6763
df12aef00932
Some bits of group theory. Demonstrate calculational proofs.
wenzelm
parents:
diff
changeset
|
21 |
|
| 61541 | 22 |
text \<open>The group axioms only state the properties of left one and inverse, |
23 |
the right versions may be derived as follows.\<close> |
|
|
6763
df12aef00932
Some bits of group theory. Demonstrate calculational proofs.
wenzelm
parents:
diff
changeset
|
24 |
|
| 37671 | 25 |
theorem (in group) group_right_inverse: "x * inverse x = 1" |
| 10007 | 26 |
proof - |
| 37671 | 27 |
have "x * inverse x = 1 * (x * inverse x)" |
| 10141 | 28 |
by (simp only: group_left_one) |
| 55656 | 29 |
also have "\<dots> = 1 * x * inverse x" |
| 10007 | 30 |
by (simp only: group_assoc) |
| 55656 | 31 |
also have "\<dots> = inverse (inverse x) * inverse x * x * inverse x" |
| 10007 | 32 |
by (simp only: group_left_inverse) |
| 55656 | 33 |
also have "\<dots> = inverse (inverse x) * (inverse x * x) * inverse x" |
| 10007 | 34 |
by (simp only: group_assoc) |
| 55656 | 35 |
also have "\<dots> = inverse (inverse x) * 1 * inverse x" |
| 10007 | 36 |
by (simp only: group_left_inverse) |
| 55656 | 37 |
also have "\<dots> = inverse (inverse x) * (1 * inverse x)" |
| 10007 | 38 |
by (simp only: group_assoc) |
| 55656 | 39 |
also have "\<dots> = inverse (inverse x) * inverse x" |
| 10141 | 40 |
by (simp only: group_left_one) |
| 55656 | 41 |
also have "\<dots> = 1" |
| 10007 | 42 |
by (simp only: group_left_inverse) |
43 |
finally show ?thesis . |
|
44 |
qed |
|
|
6763
df12aef00932
Some bits of group theory. Demonstrate calculational proofs.
wenzelm
parents:
diff
changeset
|
45 |
|
| 61541 | 46 |
text \<open>With \<open>group_right_inverse\<close> already available, \<open>group_right_one\<close> |
47 |
\label{thm:group-right-one} is now established much easier.\<close>
|
|
|
6763
df12aef00932
Some bits of group theory. Demonstrate calculational proofs.
wenzelm
parents:
diff
changeset
|
48 |
|
| 37671 | 49 |
theorem (in group) group_right_one: "x * 1 = x" |
| 10007 | 50 |
proof - |
| 37671 | 51 |
have "x * 1 = x * (inverse x * x)" |
| 10007 | 52 |
by (simp only: group_left_inverse) |
| 55656 | 53 |
also have "\<dots> = x * inverse x * x" |
| 10007 | 54 |
by (simp only: group_assoc) |
| 55656 | 55 |
also have "\<dots> = 1 * x" |
| 10007 | 56 |
by (simp only: group_right_inverse) |
| 55656 | 57 |
also have "\<dots> = x" |
| 10141 | 58 |
by (simp only: group_left_one) |
| 10007 | 59 |
finally show ?thesis . |
60 |
qed |
|
|
6763
df12aef00932
Some bits of group theory. Demonstrate calculational proofs.
wenzelm
parents:
diff
changeset
|
61 |
|
| 61541 | 62 |
text \<open> |
63 |
\<^medskip> |
|
64 |
The calculational proof style above follows typical presentations given in |
|
65 |
any introductory course on algebra. The basic technique is to form a |
|
66 |
transitive chain of equations, which in turn are established by |
|
67 |
simplifying with appropriate rules. The low-level logical details of |
|
68 |
equational reasoning are left implicit. |
|
| 6784 | 69 |
|
| 61541 | 70 |
Note that ``\<open>\<dots>\<close>'' is just a special term variable that is bound |
71 |
automatically to the argument\footnote{The argument of a curried infix
|
|
72 |
expression happens to be its right-hand side.} of the last fact achieved |
|
73 |
by any local assumption or proven statement. In contrast to \<open>?thesis\<close>, the |
|
74 |
``\<open>\<dots>\<close>'' variable is bound \<^emph>\<open>after\<close> the proof is finished. |
|
| 7874 | 75 |
|
| 37671 | 76 |
There are only two separate Isar language elements for calculational |
| 61541 | 77 |
proofs: ``\isakeyword{also}'' for initial or intermediate calculational
|
78 |
steps, and ``\isakeyword{finally}'' for exhibiting the result of a
|
|
79 |
calculation. These constructs are not hardwired into Isabelle/Isar, but |
|
80 |
defined on top of the basic Isar/VM interpreter. Expanding the |
|
81 |
\isakeyword{also} and \isakeyword{finally} derived language elements,
|
|
82 |
calculations may be simulated by hand as demonstrated below.\<close> |
|
| 6784 | 83 |
|
| 37671 | 84 |
theorem (in group) "x * 1 = x" |
| 10007 | 85 |
proof - |
| 37671 | 86 |
have "x * 1 = x * (inverse x * x)" |
| 10007 | 87 |
by (simp only: group_left_inverse) |
|
6763
df12aef00932
Some bits of group theory. Demonstrate calculational proofs.
wenzelm
parents:
diff
changeset
|
88 |
|
| 7433 | 89 |
note calculation = this |
| 58614 | 90 |
-- \<open>first calculational step: init calculation register\<close> |
|
6763
df12aef00932
Some bits of group theory. Demonstrate calculational proofs.
wenzelm
parents:
diff
changeset
|
91 |
|
| 55656 | 92 |
have "\<dots> = x * inverse x * x" |
| 10007 | 93 |
by (simp only: group_assoc) |
|
6763
df12aef00932
Some bits of group theory. Demonstrate calculational proofs.
wenzelm
parents:
diff
changeset
|
94 |
|
| 7433 | 95 |
note calculation = trans [OF calculation this] |
| 58614 | 96 |
-- \<open>general calculational step: compose with transitivity rule\<close> |
|
6763
df12aef00932
Some bits of group theory. Demonstrate calculational proofs.
wenzelm
parents:
diff
changeset
|
97 |
|
| 55656 | 98 |
have "\<dots> = 1 * x" |
| 10007 | 99 |
by (simp only: group_right_inverse) |
|
6763
df12aef00932
Some bits of group theory. Demonstrate calculational proofs.
wenzelm
parents:
diff
changeset
|
100 |
|
| 7433 | 101 |
note calculation = trans [OF calculation this] |
| 58614 | 102 |
-- \<open>general calculational step: compose with transitivity rule\<close> |
|
6763
df12aef00932
Some bits of group theory. Demonstrate calculational proofs.
wenzelm
parents:
diff
changeset
|
103 |
|
| 55656 | 104 |
have "\<dots> = x" |
| 10141 | 105 |
by (simp only: group_left_one) |
|
6763
df12aef00932
Some bits of group theory. Demonstrate calculational proofs.
wenzelm
parents:
diff
changeset
|
106 |
|
| 7433 | 107 |
note calculation = trans [OF calculation this] |
| 58614 | 108 |
-- \<open>final calculational step: compose with transitivity rule \dots\<close> |
| 6784 | 109 |
from calculation |
| 58614 | 110 |
-- \<open>\dots\ and pick up the final result\<close> |
|
6763
df12aef00932
Some bits of group theory. Demonstrate calculational proofs.
wenzelm
parents:
diff
changeset
|
111 |
|
| 10007 | 112 |
show ?thesis . |
113 |
qed |
|
|
6763
df12aef00932
Some bits of group theory. Demonstrate calculational proofs.
wenzelm
parents:
diff
changeset
|
114 |
|
| 61541 | 115 |
text \<open>Note that this scheme of calculations is not restricted to plain |
116 |
transitivity. Rules like anti-symmetry, or even forward and backward |
|
117 |
substitution work as well. For the actual implementation of |
|
118 |
\isacommand{also} and \isacommand{finally}, Isabelle/Isar maintains
|
|
119 |
separate context information of ``transitivity'' rules. Rule selection |
|
120 |
takes place automatically by higher-order unification.\<close> |
|
| 7874 | 121 |
|
|
6763
df12aef00932
Some bits of group theory. Demonstrate calculational proofs.
wenzelm
parents:
diff
changeset
|
122 |
|
| 58614 | 123 |
subsection \<open>Groups as monoids\<close> |
| 6793 | 124 |
|
| 61541 | 125 |
text \<open>Monoids over signature \<open>(\<times> :: \<alpha> \<Rightarrow> \<alpha> \<Rightarrow> \<alpha>, one :: \<alpha>)\<close> are defined like |
126 |
this.\<close> |
|
| 6793 | 127 |
|
| 35317 | 128 |
class monoid = times + one + |
| 37671 | 129 |
assumes monoid_assoc: "(x * y) * z = x * (y * z)" |
130 |
and monoid_left_one: "1 * x = x" |
|
131 |
and monoid_right_one: "x * 1 = x" |
|
| 6793 | 132 |
|
| 61541 | 133 |
text \<open>Groups are \<^emph>\<open>not\<close> yet monoids directly from the definition. For |
134 |
monoids, \<open>right_one\<close> had to be included as an axiom, but for groups both |
|
135 |
\<open>right_one\<close> and \<open>right_inverse\<close> are derivable from the other axioms. With |
|
136 |
\<open>group_right_one\<close> derived as a theorem of group theory (see |
|
| 37671 | 137 |
page~\pageref{thm:group-right-one}), we may still instantiate
|
| 61541 | 138 |
\<open>group \<subseteq> monoid\<close> properly as follows.\<close> |
| 6793 | 139 |
|
| 61541 | 140 |
instance group \<subseteq> monoid |
| 37671 | 141 |
by intro_classes |
142 |
(rule group_assoc, |
|
143 |
rule group_left_one, |
|
144 |
rule group_right_one) |
|
| 6793 | 145 |
|
| 58614 | 146 |
text \<open>The \isacommand{instance} command actually is a version of
|
| 61541 | 147 |
\isacommand{theorem}, setting up a goal that reflects the intended class
|
148 |
relation (or type constructor arity). Thus any Isar proof language element |
|
149 |
may be involved to establish this statement. When concluding the proof, |
|
150 |
the result is transformed into the intended type signature extension |
|
151 |
behind the scenes.\<close> |
|
| 37671 | 152 |
|
| 7874 | 153 |
|
| 58614 | 154 |
subsection \<open>More theorems of group theory\<close> |
| 10141 | 155 |
|
| 58614 | 156 |
text \<open>The one element is already uniquely determined by preserving |
| 61541 | 157 |
an \<^emph>\<open>arbitrary\<close> group element.\<close> |
| 10141 | 158 |
|
| 37671 | 159 |
theorem (in group) group_one_equality: |
160 |
assumes eq: "e * x = x" |
|
161 |
shows "1 = e" |
|
| 10141 | 162 |
proof - |
| 37671 | 163 |
have "1 = x * inverse x" |
| 10141 | 164 |
by (simp only: group_right_inverse) |
| 55656 | 165 |
also have "\<dots> = (e * x) * inverse x" |
| 10141 | 166 |
by (simp only: eq) |
| 55656 | 167 |
also have "\<dots> = e * (x * inverse x)" |
| 10141 | 168 |
by (simp only: group_assoc) |
| 55656 | 169 |
also have "\<dots> = e * 1" |
| 10141 | 170 |
by (simp only: group_right_inverse) |
| 55656 | 171 |
also have "\<dots> = e" |
| 10141 | 172 |
by (simp only: group_right_one) |
173 |
finally show ?thesis . |
|
174 |
qed |
|
175 |
||
| 58614 | 176 |
text \<open>Likewise, the inverse is already determined by the cancel property.\<close> |
| 10141 | 177 |
|
| 37671 | 178 |
theorem (in group) group_inverse_equality: |
179 |
assumes eq: "x' * x = 1" |
|
180 |
shows "inverse x = x'" |
|
| 10141 | 181 |
proof - |
| 37671 | 182 |
have "inverse x = 1 * inverse x" |
| 10141 | 183 |
by (simp only: group_left_one) |
| 55656 | 184 |
also have "\<dots> = (x' * x) * inverse x" |
| 10141 | 185 |
by (simp only: eq) |
| 55656 | 186 |
also have "\<dots> = x' * (x * inverse x)" |
| 10141 | 187 |
by (simp only: group_assoc) |
| 55656 | 188 |
also have "\<dots> = x' * 1" |
| 10141 | 189 |
by (simp only: group_right_inverse) |
| 55656 | 190 |
also have "\<dots> = x'" |
| 10141 | 191 |
by (simp only: group_right_one) |
192 |
finally show ?thesis . |
|
193 |
qed |
|
194 |
||
| 58614 | 195 |
text \<open>The inverse operation has some further characteristic properties.\<close> |
| 10141 | 196 |
|
| 37671 | 197 |
theorem (in group) group_inverse_times: "inverse (x * y) = inverse y * inverse x" |
| 10141 | 198 |
proof (rule group_inverse_equality) |
| 37671 | 199 |
show "(inverse y * inverse x) * (x * y) = 1" |
| 10141 | 200 |
proof - |
201 |
have "(inverse y * inverse x) * (x * y) = |
|
202 |
(inverse y * (inverse x * x)) * y" |
|
203 |
by (simp only: group_assoc) |
|
| 55656 | 204 |
also have "\<dots> = (inverse y * 1) * y" |
| 10141 | 205 |
by (simp only: group_left_inverse) |
| 55656 | 206 |
also have "\<dots> = inverse y * y" |
| 10141 | 207 |
by (simp only: group_right_one) |
| 55656 | 208 |
also have "\<dots> = 1" |
| 10141 | 209 |
by (simp only: group_left_inverse) |
210 |
finally show ?thesis . |
|
211 |
qed |
|
212 |
qed |
|
213 |
||
| 37671 | 214 |
theorem (in group) inverse_inverse: "inverse (inverse x) = x" |
| 10141 | 215 |
proof (rule group_inverse_equality) |
216 |
show "x * inverse x = one" |
|
217 |
by (simp only: group_right_inverse) |
|
218 |
qed |
|
219 |
||
| 37671 | 220 |
theorem (in group) inverse_inject: |
221 |
assumes eq: "inverse x = inverse y" |
|
222 |
shows "x = y" |
|
| 10141 | 223 |
proof - |
| 37671 | 224 |
have "x = x * 1" |
| 10141 | 225 |
by (simp only: group_right_one) |
| 55656 | 226 |
also have "\<dots> = x * (inverse y * y)" |
| 10141 | 227 |
by (simp only: group_left_inverse) |
| 55656 | 228 |
also have "\<dots> = x * (inverse x * y)" |
| 10141 | 229 |
by (simp only: eq) |
| 55656 | 230 |
also have "\<dots> = (x * inverse x) * y" |
| 10141 | 231 |
by (simp only: group_assoc) |
| 55656 | 232 |
also have "\<dots> = 1 * y" |
| 10141 | 233 |
by (simp only: group_right_inverse) |
| 55656 | 234 |
also have "\<dots> = y" |
| 10141 | 235 |
by (simp only: group_left_one) |
236 |
finally show ?thesis . |
|
237 |
qed |
|
238 |
||
239 |
end |