doc-src/AxClass/generated/Semigroups.tex
author wenzelm
Mon, 22 May 2000 10:31:44 +0200
changeset 8906 fc7841f31388
parent 8903 78d6e47469e4
child 8907 813fabceec00
permissions -rw-r--r--
tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8890
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
     1
\begin{isabelle}%
8906
wenzelm
parents: 8903
diff changeset
     2
%
wenzelm
parents: 8903
diff changeset
     3
\isamarkupheader{Semigroups}
wenzelm
parents: 8903
diff changeset
     4
\isacommand{theory}~Semigroups~=~Main:%
wenzelm
parents: 8903
diff changeset
     5
\begin{isamarkuptext}%
wenzelm
parents: 8903
diff changeset
     6
\medskip\noindent An axiomatic type class is simply a class of types
wenzelm
parents: 8903
diff changeset
     7
 that all meet certain \emph{axioms}. Thus, type classes may be also
wenzelm
parents: 8903
diff changeset
     8
 understood as type predicates --- i.e.\ abstractions over a single
wenzelm
parents: 8903
diff changeset
     9
 type argument $\alpha$.  Class axioms typically contain polymorphic
wenzelm
parents: 8903
diff changeset
    10
 constants that depend on this type $\alpha$.  These
wenzelm
parents: 8903
diff changeset
    11
 \emph{characteristic constants} behave like operations associated
wenzelm
parents: 8903
diff changeset
    12
 with the ``carrier'' type $\alpha$.
wenzelm
parents: 8903
diff changeset
    13
wenzelm
parents: 8903
diff changeset
    14
 We illustrate these basic concepts by the following formulation of
wenzelm
parents: 8903
diff changeset
    15
 semigroups.%
wenzelm
parents: 8903
diff changeset
    16
\end{isamarkuptext}%
8890
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
    17
\isacommand{consts}\isanewline
8906
wenzelm
parents: 8903
diff changeset
    18
~~times~::~{"}'a~{\isasymRightarrow}~'a~{\isasymRightarrow}~'a{"}~~~~(\isakeyword{infixl}~{"}{\isasymOtimes}{"}~70)\isanewline
wenzelm
parents: 8903
diff changeset
    19
\isacommand{axclass}\isanewline
wenzelm
parents: 8903
diff changeset
    20
~~semigroup~<~{"}term{"}\isanewline
wenzelm
parents: 8903
diff changeset
    21
~~assoc:~{"}(x~{\isasymOtimes}~y)~{\isasymOtimes}~z~=~x~{\isasymOtimes}~(y~{\isasymOtimes}~z){"}%
wenzelm
parents: 8903
diff changeset
    22
\begin{isamarkuptext}%
wenzelm
parents: 8903
diff changeset
    23
\noindent Above we have first declared a polymorphic constant $\TIMES
wenzelm
parents: 8903
diff changeset
    24
 :: \alpha \To \alpha \To \alpha$ and then defined the class
wenzelm
parents: 8903
diff changeset
    25
 $semigroup$ of all types $\tau$ such that $\TIMES :: \tau \To \tau
wenzelm
parents: 8903
diff changeset
    26
 \To \tau$ is indeed an associative operator.  The $assoc$ axiom
wenzelm
parents: 8903
diff changeset
    27
 contains exactly one type variable, which is invisible in the above
wenzelm
parents: 8903
diff changeset
    28
 presentation, though.  Also note that free term variables (like $x$,
wenzelm
parents: 8903
diff changeset
    29
 $y$, $z$) are allowed for user convenience --- conceptually all of
wenzelm
parents: 8903
diff changeset
    30
 these are bound by outermost universal quantifiers.
wenzelm
parents: 8903
diff changeset
    31
wenzelm
parents: 8903
diff changeset
    32
 \medskip In general, type classes may be used to describe
wenzelm
parents: 8903
diff changeset
    33
 \emph{structures} with exactly one carrier $\alpha$ and a fixed
wenzelm
parents: 8903
diff changeset
    34
 \emph{signature}.  Different signatures require different classes.
wenzelm
parents: 8903
diff changeset
    35
 Subsequently, class $plus_semigroup$ represents semigroups of the
wenzelm
parents: 8903
diff changeset
    36
 form $(\tau, \PLUS^\tau)$, while $semigroup$ above would correspond
wenzelm
parents: 8903
diff changeset
    37
 to semigroups $(\tau, \TIMES^\tau)$.%
wenzelm
parents: 8903
diff changeset
    38
\end{isamarkuptext}%
wenzelm
parents: 8903
diff changeset
    39
\isacommand{consts}\isanewline
wenzelm
parents: 8903
diff changeset
    40
~~plus~::~{"}'a~{\isasymRightarrow}~'a~{\isasymRightarrow}~'a{"}~~~~(\isakeyword{infixl}~{"}{\isasymOplus}{"}~70)\isanewline
8890
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
    41
\isacommand{axclass}\isanewline
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
    42
~~plus\_semigroup~<~{"}term{"}\isanewline
8906
wenzelm
parents: 8903
diff changeset
    43
~~assoc:~{"}(x~{\isasymOplus}~y)~{\isasymOplus}~z~=~x~{\isasymOplus}~(y~{\isasymOplus}~z){"}%
wenzelm
parents: 8903
diff changeset
    44
\begin{isamarkuptext}%
wenzelm
parents: 8903
diff changeset
    45
\noindent Even if classes $plus_semigroup$ and $times_semigroup$ both
wenzelm
parents: 8903
diff changeset
    46
 represent semigroups in a sense, they are certainly not the same!%
wenzelm
parents: 8903
diff changeset
    47
\end{isamarkuptext}%
8890
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
    48
\isacommand{end}\end{isabelle}%