doc-src/AxClass/Nat/document/Semigroups.tex
changeset 17130 456fe8a09f90
parent 17129 228eec5f5502
child 17131 13c7d9c8557d
equal deleted inserted replaced
17129:228eec5f5502 17130:456fe8a09f90
     1 %
       
     2 \begin{isabellebody}%
       
     3 \def\isabellecontext{Semigroups}%
       
     4 \isamarkuptrue%
       
     5 %
       
     6 \isamarkupheader{Semigroups%
       
     7 }
       
     8 %
       
     9 \isadelimtheory
       
    10 %
       
    11 \endisadelimtheory
       
    12 %
       
    13 \isatagtheory
       
    14 \isamarkupfalse%
       
    15 \isacommand{theory}\ Semigroups\ \isakeyword{imports}\ Main\ \isakeyword{begin}%
       
    16 \endisatagtheory
       
    17 {\isafoldtheory}%
       
    18 %
       
    19 \isadelimtheory
       
    20 %
       
    21 \endisadelimtheory
       
    22 \isamarkuptrue%
       
    23 %
       
    24 \begin{isamarkuptext}%
       
    25 \medskip\noindent An axiomatic type class is simply a class of types
       
    26   that all meet certain properties, which are also called \emph{class
       
    27   axioms}. Thus, type classes may be also understood as type
       
    28   predicates --- i.e.\ abstractions over a single type argument \isa{{\isacharprime}a}.  Class axioms typically contain polymorphic constants that
       
    29   depend on this type \isa{{\isacharprime}a}.  These \emph{characteristic
       
    30   constants} behave like operations associated with the ``carrier''
       
    31   type \isa{{\isacharprime}a}.
       
    32 
       
    33   We illustrate these basic concepts by the following formulation of
       
    34   semigroups.%
       
    35 \end{isamarkuptext}%
       
    36 \isamarkupfalse%
       
    37 \isacommand{consts}\isanewline
       
    38 \ \ 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
       
    39 \isamarkupfalse%
       
    40 \isacommand{axclass}\ semigroup\ {\isasymsubseteq}\ type\isanewline
       
    41 \ \ assoc{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}x\ {\isasymodot}\ y{\isacharparenright}\ {\isasymodot}\ z\ {\isacharequal}\ x\ {\isasymodot}\ {\isacharparenleft}y\ {\isasymodot}\ z{\isacharparenright}{\isachardoublequote}\isamarkuptrue%
       
    42 %
       
    43 \begin{isamarkuptext}%
       
    44 \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
       
    45   all types \isa{{\isasymtau}} such that \isa{{\isasymodot}\ {\isasymColon}\ {\isasymtau}\ {\isasymRightarrow}\ {\isasymtau}\ {\isasymRightarrow}\ {\isasymtau}} is indeed an
       
    46   associative operator.  The \isa{assoc} axiom contains exactly one
       
    47   type variable, which is invisible in the above presentation, though.
       
    48   Also note that free term variables (like \isa{x}, \isa{y},
       
    49   \isa{z}) are allowed for user convenience --- conceptually all of
       
    50   these are bound by outermost universal quantifiers.
       
    51 
       
    52   \medskip In general, type classes may be used to describe
       
    53   \emph{structures} with exactly one carrier \isa{{\isacharprime}a} and a fixed
       
    54   \emph{signature}.  Different signatures require different classes.
       
    55   Below, class \isa{plus{\isacharunderscore}semigroup} represents semigroups \isa{{\isacharparenleft}{\isasymtau}{\isacharcomma}\ {\isasymoplus}\isactrlsup {\isasymtau}{\isacharparenright}}, while the original \isa{semigroup} would
       
    56   correspond to semigroups of the form \isa{{\isacharparenleft}{\isasymtau}{\isacharcomma}\ {\isasymodot}\isactrlsup {\isasymtau}{\isacharparenright}}.%
       
    57 \end{isamarkuptext}%
       
    58 \isamarkupfalse%
       
    59 \isacommand{consts}\isanewline
       
    60 \ \ 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
       
    61 \isamarkupfalse%
       
    62 \isacommand{axclass}\ plus{\isacharunderscore}semigroup\ {\isasymsubseteq}\ type\isanewline
       
    63 \ \ assoc{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}x\ {\isasymoplus}\ y{\isacharparenright}\ {\isasymoplus}\ z\ {\isacharequal}\ x\ {\isasymoplus}\ {\isacharparenleft}y\ {\isasymoplus}\ z{\isacharparenright}{\isachardoublequote}\isamarkuptrue%
       
    64 %
       
    65 \begin{isamarkuptext}%
       
    66 \noindent Even if classes \isa{plus{\isacharunderscore}semigroup} and \isa{semigroup} both represent semigroups in a sense, they are certainly
       
    67   not quite the same.%
       
    68 \end{isamarkuptext}%
       
    69 %
       
    70 \isadelimtheory
       
    71 %
       
    72 \endisadelimtheory
       
    73 %
       
    74 \isatagtheory
       
    75 \isamarkupfalse%
       
    76 \isacommand{end}%
       
    77 \endisatagtheory
       
    78 {\isafoldtheory}%
       
    79 %
       
    80 \isadelimtheory
       
    81 %
       
    82 \endisadelimtheory
       
    83 \isanewline
       
    84 \end{isabellebody}%
       
    85 %%% Local Variables:
       
    86 %%% mode: latex
       
    87 %%% TeX-master: "root"
       
    88 %%% End: