9767
|
1 |
%
|
|
2 |
\begin{isabellebody}%
|
9921
|
3 |
\def\isabellecontext{Semigroups}%
|
8906
|
4 |
%
|
|
5 |
\isamarkupheader{Semigroups}
|
9672
|
6 |
\isacommand{theory}\ Semigroups\ {\isacharequal}\ Main{\isacharcolon}%
|
8906
|
7 |
\begin{isamarkuptext}%
|
|
8 |
\medskip\noindent An axiomatic type class is simply a class of types
|
8907
|
9 |
that all meet certain properties, which are also called \emph{class
|
|
10 |
axioms}. Thus, type classes may be also understood as type predicates
|
10140
|
11 |
--- i.e.\ abstractions over a single type argument \isa{{\isacharprime}a}. Class
|
8907
|
12 |
axioms typically contain polymorphic constants that depend on this
|
10140
|
13 |
type \isa{{\isacharprime}a}. These \emph{characteristic constants} behave like
|
|
14 |
operations associated with the ``carrier'' type \isa{{\isacharprime}a}.
|
8906
|
15 |
|
|
16 |
We illustrate these basic concepts by the following formulation of
|
|
17 |
semigroups.%
|
|
18 |
\end{isamarkuptext}%
|
8890
|
19 |
\isacommand{consts}\isanewline
|
10207
|
20 |
\ \ times\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymodot}{\isachardoublequote}\ {\isadigit{7}}{\isadigit{0}}{\isacharparenright}\isanewline
|
10140
|
21 |
\isacommand{axclass}\ semigroup\ {\isacharless}\ {\isachardoublequote}term{\isachardoublequote}\isanewline
|
|
22 |
\ \ assoc{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}x\ {\isasymodot}\ y{\isacharparenright}\ {\isasymodot}\ z\ {\isacharequal}\ x\ {\isasymodot}\ {\isacharparenleft}y\ {\isasymodot}\ z{\isacharparenright}{\isachardoublequote}%
|
8906
|
23 |
\begin{isamarkuptext}%
|
10140
|
24 |
\noindent Above we have first declared a polymorphic constant \isa{{\isasymodot}\ {\isasymColon}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a} and then defined the class \isa{semigroup} of
|
|
25 |
all types \isa{{\isasymtau}} such that \isa{{\isasymodot}\ {\isasymColon}\ {\isasymtau}\ {\isasymRightarrow}\ {\isasymtau}\ {\isasymRightarrow}\ {\isasymtau}} is indeed an
|
|
26 |
associative operator. The \isa{assoc} axiom contains exactly one
|
|
27 |
type variable, which is invisible in the above presentation, though.
|
|
28 |
Also note that free term variables (like \isa{x}, \isa{y}, \isa{z}) are allowed for user convenience --- conceptually all of these
|
|
29 |
are bound by outermost universal quantifiers.
|
8906
|
30 |
|
|
31 |
\medskip In general, type classes may be used to describe
|
10140
|
32 |
\emph{structures} with exactly one carrier \isa{{\isacharprime}a} and a fixed
|
8906
|
33 |
\emph{signature}. Different signatures require different classes.
|
10223
|
34 |
Below, class \isa{plus{\isacharunderscore}semigroup} represents semigroups
|
|
35 |
\isa{{\isacharparenleft}{\isasymtau}{\isacharcomma}\ {\isasymoplus}\isactrlsup {\isasymtau}{\isacharparenright}}, while the original \isa{semigroup} would
|
|
36 |
correspond to semigroups of the form \isa{{\isacharparenleft}{\isasymtau}{\isacharcomma}\ {\isasymodot}\isactrlsup {\isasymtau}{\isacharparenright}}.%
|
8906
|
37 |
\end{isamarkuptext}%
|
|
38 |
\isacommand{consts}\isanewline
|
10207
|
39 |
\ \ plus\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymoplus}{\isachardoublequote}\ {\isadigit{7}}{\isadigit{0}}{\isacharparenright}\isanewline
|
10140
|
40 |
\isacommand{axclass}\ plus{\isacharunderscore}semigroup\ {\isacharless}\ {\isachardoublequote}term{\isachardoublequote}\isanewline
|
|
41 |
\ \ assoc{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}x\ {\isasymoplus}\ y{\isacharparenright}\ {\isasymoplus}\ z\ {\isacharequal}\ x\ {\isasymoplus}\ {\isacharparenleft}y\ {\isasymoplus}\ z{\isacharparenright}{\isachardoublequote}%
|
8906
|
42 |
\begin{isamarkuptext}%
|
10140
|
43 |
\noindent Even if classes \isa{plus{\isacharunderscore}semigroup} and \isa{semigroup} both represent semigroups in a sense, they are certainly
|
|
44 |
not quite the same.%
|
8906
|
45 |
\end{isamarkuptext}%
|
9767
|
46 |
\isacommand{end}\end{isabellebody}%
|
9145
|
47 |
%%% Local Variables:
|
|
48 |
%%% mode: latex
|
|
49 |
%%% TeX-master: "root"
|
|
50 |
%%% End:
|