20 signature parts of our structures. |
20 signature parts of our structures. |
21 *} |
21 *} |
22 |
22 |
23 consts |
23 consts |
24 times :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<odot>" 70) |
24 times :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<odot>" 70) |
25 inverse :: "'a \<Rightarrow> 'a" ("(_\<inv>)" [1000] 999) |
25 invers :: "'a \<Rightarrow> 'a" ("(_\<inv>)" [1000] 999) |
26 one :: 'a ("\<unit>") |
26 one :: 'a ("\<unit>") |
27 |
27 |
28 text {* |
28 text {* |
29 \noindent Next we define class @{text monoid} of monoids with |
29 \noindent Next we define class @{text monoid} of monoids with |
30 operations @{text \<odot>} and @{text \<unit>}. Note that multiple class |
30 operations @{text \<odot>} and @{text \<unit>}. Note that multiple class |
64 |
64 |
65 text {* |
65 text {* |
66 \noindent Class @{text group} inherits associativity of @{text \<odot>} |
66 \noindent Class @{text group} inherits associativity of @{text \<odot>} |
67 from @{text semigroup} and adds two further group axioms. Similarly, |
67 from @{text semigroup} and adds two further group axioms. Similarly, |
68 @{text agroup} is defined as the subset of @{text group} such that |
68 @{text agroup} is defined as the subset of @{text group} such that |
69 for all of its elements @{text \<tau>}, the operation @{text "\<odot> \<Colon> \<tau> \<Rightarrow> \<tau> \<Rightarrow> \<tau>"} |
69 for all of its elements @{text \<tau>}, the operation @{text "\<odot> \<Colon> \<tau> \<Rightarrow> \<tau> \<Rightarrow> |
70 is even commutative. |
70 \<tau>"} is even commutative. |
71 *} |
71 *} |
72 |
72 |
73 |
73 |
74 subsection {* Abstract reasoning *} |
74 subsection {* Abstract reasoning *} |
75 |
75 |
218 So far we have covered the case of the form $\INSTANCE$~@{text |
218 So far we have covered the case of the form $\INSTANCE$~@{text |
219 "c\<^sub>1 < c\<^sub>2"}, namely \emph{abstract instantiation} --- |
219 "c\<^sub>1 < c\<^sub>2"}, namely \emph{abstract instantiation} --- |
220 $c@1$ is more special than @{text "c\<^sub>1"} and thus an instance |
220 $c@1$ is more special than @{text "c\<^sub>1"} and thus an instance |
221 of @{text "c\<^sub>2"}. Even more interesting for practical |
221 of @{text "c\<^sub>2"}. Even more interesting for practical |
222 applications are \emph{concrete instantiations} of axiomatic type |
222 applications are \emph{concrete instantiations} of axiomatic type |
223 classes. That is, certain simple schemes |
223 classes. That is, certain simple schemes @{text "(\<alpha>\<^sub>1, \<dots>, |
224 @{text "(\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>n) t \<Colon> c"} of class membership may be |
224 \<alpha>\<^sub>n) t \<Colon> c"} of class membership may be established at the |
225 established at the logical level and then transferred to Isabelle's |
225 logical level and then transferred to Isabelle's type signature |
226 type signature level. |
226 level. |
227 |
227 |
228 \medskip As a typical example, we show that type @{typ bool} with |
228 \medskip As a typical example, we show that type @{typ bool} with |
229 exclusive-or as @{text \<odot>} operation, identity as @{text \<inv>}, and |
229 exclusive-or as @{text \<odot>} operation, identity as @{text \<inv>}, and |
230 @{term False} as @{text \<unit>} forms an Abelian group. |
230 @{term False} as @{text \<unit>} forms an Abelian group. |
231 *} |
231 *} |
294 defs (overloaded) |
294 defs (overloaded) |
295 times_prod_def: "p \<odot> q \<equiv> (fst p \<odot> fst q, snd p \<odot> snd q)" |
295 times_prod_def: "p \<odot> q \<equiv> (fst p \<odot> fst q, snd p \<odot> snd q)" |
296 |
296 |
297 text {* |
297 text {* |
298 It is very easy to see that associativity of @{text \<odot>} on @{typ 'a} |
298 It is very easy to see that associativity of @{text \<odot>} on @{typ 'a} |
299 and @{text \<odot>} on @{typ 'b} transfers to @{text \<odot>} on @{typ "'a \<times> 'b"}. |
299 and @{text \<odot>} on @{typ 'b} transfers to @{text \<odot>} on @{typ "'a \<times> |
300 Hence the binary type constructor @{text \<odot>} maps semigroups to |
300 'b"}. Hence the binary type constructor @{text \<odot>} maps semigroups to |
301 semigroups. This may be established formally as follows. |
301 semigroups. This may be established formally as follows. |
302 *} |
302 *} |
303 |
303 |
304 instance * :: (semigroup, semigroup) semigroup |
304 instance * :: (semigroup, semigroup) semigroup |
305 proof (intro_classes, unfold times_prod_def) |
305 proof (intro_classes, unfold times_prod_def) |