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