doc-src/AxClass/generated/Group.tex
author kleing
Mon, 25 Sep 2000 12:08:49 +0200
changeset 10069 c7226e6f9625
parent 9921 7acefd99e748
child 10140 ba9297b71897
permissions -rw-r--r--
untabified for HTML
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9767
dc2ee9b2e065 updated;
wenzelm
parents: 9672
diff changeset
     1
%
dc2ee9b2e065 updated;
wenzelm
parents: 9672
diff changeset
     2
\begin{isabellebody}%
9921
7acefd99e748 updated;
wenzelm
parents: 9767
diff changeset
     3
\def\isabellecontext{Group}%
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
     4
%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
     5
\isamarkupheader{Basic group theory}
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
     6
\isacommand{theory}\ Group\ {\isacharequal}\ Main{\isacharcolon}%
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
     7
\begin{isamarkuptext}%
8907
wenzelm
parents: 8903
diff changeset
     8
\medskip\noindent The meta-type system of Isabelle supports
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
     9
 \emph{intersections} and \emph{inclusions} of type classes. These
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    10
 directly correspond to intersections and inclusions of type
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    11
 predicates in a purely set theoretic sense. This is sufficient as a
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    12
 means to describe simple hierarchies of structures.  As an
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    13
 illustration, we use the well-known example of semigroups, monoids,
8907
wenzelm
parents: 8903
diff changeset
    14
 general groups and Abelian groups.%
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    15
\end{isamarkuptext}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    16
%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    17
\isamarkupsubsection{Monoids and Groups}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    18
%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    19
\begin{isamarkuptext}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    20
First we declare some polymorphic constants required later for the
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    21
 signature parts of our structures.%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    22
\end{isamarkuptext}%
8890
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
    23
\isacommand{consts}\isanewline
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    24
\ \ times\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isacharequal}{\isachargreater}\ {\isacharprime}a\ {\isacharequal}{\isachargreater}\ {\isacharprime}a{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymOtimes}{\isachardoublequote}\ \isadigit{7}\isadigit{0}{\isacharparenright}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    25
\ \ inverse\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isacharequal}{\isachargreater}\ {\isacharprime}a{\isachardoublequote}\ \ \ \ \ \ \ \ {\isacharparenleft}{\isachardoublequote}{\isacharparenleft}{\isacharunderscore}{\isasyminv}{\isacharparenright}{\isachardoublequote}\ {\isacharbrackleft}\isadigit{1}\isadigit{0}\isadigit{0}\isadigit{0}{\isacharbrackright}\ \isadigit{9}\isadigit{9}\isadigit{9}{\isacharparenright}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    26
\ \ one\ {\isacharcolon}{\isacharcolon}\ {\isacharprime}a\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isacharparenleft}{\isachardoublequote}{\isasymunit}{\isachardoublequote}{\isacharparenright}%
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    27
\begin{isamarkuptext}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    28
\noindent Next we define class $monoid$ of monoids with operations
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    29
 $\TIMES$ and $1$.  Note that multiple class axioms are allowed for
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    30
 user convenience --- they simply represent the conjunction of their
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    31
 respective universal closures.%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    32
\end{isamarkuptext}%
8890
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
    33
\isacommand{axclass}\isanewline
9665
2a6d7f1409f9 updated;
wenzelm
parents: 9519
diff changeset
    34
\ \ monoid\ {\isacharless}\ {\isachardoublequote}term{\isachardoublequote}\isanewline
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    35
\ \ assoc{\isacharcolon}\ \ \ \ \ \ {\isachardoublequote}{\isacharparenleft}x\ {\isasymOtimes}\ y{\isacharparenright}\ {\isasymOtimes}\ z\ {\isacharequal}\ x\ {\isasymOtimes}\ {\isacharparenleft}y\ {\isasymOtimes}\ z{\isacharparenright}{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    36
\ \ left{\isacharunderscore}unit{\isacharcolon}\ \ {\isachardoublequote}{\isasymunit}\ {\isasymOtimes}\ x\ {\isacharequal}\ x{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    37
\ \ right{\isacharunderscore}unit{\isacharcolon}\ {\isachardoublequote}x\ {\isasymOtimes}\ {\isasymunit}\ {\isacharequal}\ x{\isachardoublequote}%
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    38
\begin{isamarkuptext}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    39
\noindent So class $monoid$ contains exactly those types $\tau$ where
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    40
 $\TIMES :: \tau \To \tau \To \tau$ and $1 :: \tau$ are specified
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    41
 appropriately, such that $\TIMES$ is associative and $1$ is a left
9519
fdc3b5bcd79d updated;
wenzelm
parents: 9331
diff changeset
    42
 and right unit element for the $\TIMES$ operation.%
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    43
\end{isamarkuptext}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    44
%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    45
\begin{isamarkuptext}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    46
\medskip Independently of $monoid$, we now define a linear hierarchy
8907
wenzelm
parents: 8903
diff changeset
    47
 of semigroups, general groups and Abelian groups.  Note that the
wenzelm
parents: 8903
diff changeset
    48
 names of class axioms are automatically qualified with each class
wenzelm
parents: 8903
diff changeset
    49
 name, so we may re-use common names such as $assoc$.%
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    50
\end{isamarkuptext}%
8890
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
    51
\isacommand{axclass}\isanewline
9665
2a6d7f1409f9 updated;
wenzelm
parents: 9519
diff changeset
    52
\ \ semigroup\ {\isacharless}\ {\isachardoublequote}term{\isachardoublequote}\isanewline
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    53
\ \ assoc{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}x\ {\isasymOtimes}\ y{\isacharparenright}\ {\isasymOtimes}\ z\ {\isacharequal}\ x\ {\isasymOtimes}\ {\isacharparenleft}y\ {\isasymOtimes}\ z{\isacharparenright}{\isachardoublequote}\isanewline
8890
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
    54
\isanewline
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
    55
\isacommand{axclass}\isanewline
9665
2a6d7f1409f9 updated;
wenzelm
parents: 9519
diff changeset
    56
\ \ group\ {\isacharless}\ semigroup\isanewline
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    57
\ \ left{\isacharunderscore}unit{\isacharcolon}\ \ \ \ {\isachardoublequote}{\isasymunit}\ {\isasymOtimes}\ x\ {\isacharequal}\ x{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    58
\ \ left{\isacharunderscore}inverse{\isacharcolon}\ {\isachardoublequote}x{\isasyminv}\ {\isasymOtimes}\ x\ {\isacharequal}\ {\isasymunit}{\isachardoublequote}\isanewline
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    59
\isanewline
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    60
\isacommand{axclass}\isanewline
9665
2a6d7f1409f9 updated;
wenzelm
parents: 9519
diff changeset
    61
\ \ agroup\ {\isacharless}\ group\isanewline
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    62
\ \ commute{\isacharcolon}\ {\isachardoublequote}x\ {\isasymOtimes}\ y\ {\isacharequal}\ y\ {\isasymOtimes}\ x{\isachardoublequote}%
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    63
\begin{isamarkuptext}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    64
\noindent Class $group$ inherits associativity of $\TIMES$ from
8907
wenzelm
parents: 8903
diff changeset
    65
 $semigroup$ and adds two further group axioms. Similarly, $agroup$
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    66
 is defined as the subset of $group$ such that for all of its elements
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    67
 $\tau$, the operation $\TIMES :: \tau \To \tau \To \tau$ is even
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    68
 commutative.%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    69
\end{isamarkuptext}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    70
%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    71
\isamarkupsubsection{Abstract reasoning}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    72
%
8890
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
    73
\begin{isamarkuptext}%
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    74
In a sense, axiomatic type classes may be viewed as \emph{abstract
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    75
 theories}.  Above class definitions gives rise to abstract axioms
8907
wenzelm
parents: 8903
diff changeset
    76
 $assoc$, $left_unit$, $left_inverse$, $commute$, where any of these
wenzelm
parents: 8903
diff changeset
    77
 contain a type variable $\alpha :: c$ that is restricted to types of
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    78
 the corresponding class $c$.  \emph{Sort constraints} like this
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    79
 express a logical precondition for the whole formula.  For example,
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    80
 $assoc$ states that for all $\tau$, provided that $\tau ::
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    81
 semigroup$, the operation $\TIMES :: \tau \To \tau \To \tau$ is
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    82
 associative.
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    83
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    84
 \medskip From a technical point of view, abstract axioms are just
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    85
 ordinary Isabelle theorems, which may be used in proofs without
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    86
 special treatment.  Such ``abstract proofs'' usually yield new
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
    87
 ``abstract theorems''.  For example, we may now derive the following
8907
wenzelm
parents: 8903
diff changeset
    88
 well-known laws of general groups.%
8890
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
    89
\end{isamarkuptext}%
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    90
\isacommand{theorem}\ group{\isacharunderscore}right{\isacharunderscore}inverse{\isacharcolon}\ {\isachardoublequote}x\ {\isasymOtimes}\ x{\isasyminv}\ {\isacharequal}\ {\isacharparenleft}{\isasymunit}{\isasymColon}{\isacharprime}a{\isasymColon}group{\isacharparenright}{\isachardoublequote}\isanewline
9665
2a6d7f1409f9 updated;
wenzelm
parents: 9519
diff changeset
    91
\isacommand{proof}\ {\isacharminus}\isanewline
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    92
\ \ \isacommand{have}\ {\isachardoublequote}x\ {\isasymOtimes}\ x{\isasyminv}\ {\isacharequal}\ {\isasymunit}\ {\isasymOtimes}\ {\isacharparenleft}x\ {\isasymOtimes}\ x{\isasyminv}{\isacharparenright}{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    93
\ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ group{\isachardot}left{\isacharunderscore}unit{\isacharparenright}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    94
\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isasymunit}\ {\isasymOtimes}\ x\ {\isasymOtimes}\ x{\isasyminv}{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    95
\ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ semigroup{\isachardot}assoc{\isacharparenright}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    96
\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isacharparenleft}x{\isasyminv}{\isacharparenright}{\isasyminv}\ {\isasymOtimes}\ x{\isasyminv}\ {\isasymOtimes}\ x\ {\isasymOtimes}\ x{\isasyminv}{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    97
\ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ group{\isachardot}left{\isacharunderscore}inverse{\isacharparenright}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    98
\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isacharparenleft}x{\isasyminv}{\isacharparenright}{\isasyminv}\ {\isasymOtimes}\ {\isacharparenleft}x{\isasyminv}\ {\isasymOtimes}\ x{\isacharparenright}\ {\isasymOtimes}\ x{\isasyminv}{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    99
\ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ semigroup{\isachardot}assoc{\isacharparenright}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   100
\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isacharparenleft}x{\isasyminv}{\isacharparenright}{\isasyminv}\ {\isasymOtimes}\ {\isasymunit}\ {\isasymOtimes}\ x{\isasyminv}{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   101
\ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ group{\isachardot}left{\isacharunderscore}inverse{\isacharparenright}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   102
\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isacharparenleft}x{\isasyminv}{\isacharparenright}{\isasyminv}\ {\isasymOtimes}\ {\isacharparenleft}{\isasymunit}\ {\isasymOtimes}\ x{\isasyminv}{\isacharparenright}{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   103
\ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ semigroup{\isachardot}assoc{\isacharparenright}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   104
\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isacharparenleft}x{\isasyminv}{\isacharparenright}{\isasyminv}\ {\isasymOtimes}\ x{\isasyminv}{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   105
\ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ group{\isachardot}left{\isacharunderscore}unit{\isacharparenright}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   106
\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isasymunit}{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   107
\ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ group{\isachardot}left{\isacharunderscore}inverse{\isacharparenright}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   108
\ \ \isacommand{finally}\ \isacommand{show}\ {\isacharquery}thesis\ \isacommand{{\isachardot}}\isanewline
8890
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
   109
\isacommand{qed}%
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
   110
\begin{isamarkuptext}%
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   111
\noindent With $group_right_inverse$ already available,
8890
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
   112
 $group_right_unit$\label{thm:group-right-unit} is now established
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
   113
 much easier.%
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
   114
\end{isamarkuptext}%
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   115
\isacommand{theorem}\ group{\isacharunderscore}right{\isacharunderscore}unit{\isacharcolon}\ {\isachardoublequote}x\ {\isasymOtimes}\ {\isasymunit}\ {\isacharequal}\ {\isacharparenleft}x{\isasymColon}{\isacharprime}a{\isasymColon}group{\isacharparenright}{\isachardoublequote}\isanewline
9665
2a6d7f1409f9 updated;
wenzelm
parents: 9519
diff changeset
   116
\isacommand{proof}\ {\isacharminus}\isanewline
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   117
\ \ \isacommand{have}\ {\isachardoublequote}x\ {\isasymOtimes}\ {\isasymunit}\ {\isacharequal}\ x\ {\isasymOtimes}\ {\isacharparenleft}x{\isasyminv}\ {\isasymOtimes}\ x{\isacharparenright}{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   118
\ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ group{\isachardot}left{\isacharunderscore}inverse{\isacharparenright}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   119
\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ x\ {\isasymOtimes}\ x{\isasyminv}\ {\isasymOtimes}\ x{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   120
\ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ semigroup{\isachardot}assoc{\isacharparenright}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   121
\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isasymunit}\ {\isasymOtimes}\ x{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   122
\ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ group{\isacharunderscore}right{\isacharunderscore}inverse{\isacharparenright}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   123
\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ x{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   124
\ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ group{\isachardot}left{\isacharunderscore}unit{\isacharparenright}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   125
\ \ \isacommand{finally}\ \isacommand{show}\ {\isacharquery}thesis\ \isacommand{{\isachardot}}\isanewline
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   126
\isacommand{qed}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   127
\begin{isamarkuptext}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   128
\medskip Abstract theorems may be instantiated to only those types
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   129
 $\tau$ where the appropriate class membership $\tau :: c$ is known at
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   130
 Isabelle's type signature level.  Since we have $agroup \subseteq
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   131
 group \subseteq semigroup$ by definition, all theorems of $semigroup$
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   132
 and $group$ are automatically inherited by $group$ and $agroup$.%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   133
\end{isamarkuptext}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   134
%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   135
\isamarkupsubsection{Abstract instantiation}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   136
%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   137
\begin{isamarkuptext}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   138
From the definition, the $monoid$ and $group$ classes have been
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   139
 independent.  Note that for monoids, $right_unit$ had to be included
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   140
 as an axiom, but for groups both $right_unit$ and $right_inverse$ are
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   141
 derivable from the other axioms.  With $group_right_unit$ derived as
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   142
 a theorem of group theory (see page~\pageref{thm:group-right-unit}),
8907
wenzelm
parents: 8903
diff changeset
   143
 we may now instantiate $monoid \subseteq semigroup$ and $group
wenzelm
parents: 8903
diff changeset
   144
 \subseteq monoid$ properly as follows
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   145
 (cf.\ \figref{fig:monoid-group}).
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   146
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   147
 \begin{figure}[htbp]
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   148
   \begin{center}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   149
     \small
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   150
     \unitlength 0.6mm
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   151
     \begin{picture}(65,90)(0,-10)
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   152
       \put(15,10){\line(0,1){10}} \put(15,30){\line(0,1){10}}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   153
       \put(15,50){\line(1,1){10}} \put(35,60){\line(1,-1){10}}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   154
       \put(15,5){\makebox(0,0){$agroup$}}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   155
       \put(15,25){\makebox(0,0){$group$}}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   156
       \put(15,45){\makebox(0,0){$semigroup$}}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   157
       \put(30,65){\makebox(0,0){$term$}} \put(50,45){\makebox(0,0){$monoid$}}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   158
     \end{picture}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   159
     \hspace{4em}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   160
     \begin{picture}(30,90)(0,0)
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   161
       \put(15,10){\line(0,1){10}} \put(15,30){\line(0,1){10}}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   162
       \put(15,50){\line(0,1){10}} \put(15,70){\line(0,1){10}}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   163
       \put(15,5){\makebox(0,0){$agroup$}}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   164
       \put(15,25){\makebox(0,0){$group$}}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   165
       \put(15,45){\makebox(0,0){$monoid$}}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   166
       \put(15,65){\makebox(0,0){$semigroup$}}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   167
       \put(15,85){\makebox(0,0){$term$}}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   168
     \end{picture}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   169
     \caption{Monoids and groups: according to definition, and by proof}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   170
     \label{fig:monoid-group}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   171
   \end{center}
8907
wenzelm
parents: 8903
diff changeset
   172
 \end{figure}%
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   173
\end{isamarkuptext}%
9665
2a6d7f1409f9 updated;
wenzelm
parents: 9519
diff changeset
   174
\isacommand{instance}\ monoid\ {\isacharless}\ semigroup\isanewline
2a6d7f1409f9 updated;
wenzelm
parents: 9519
diff changeset
   175
\isacommand{proof}\ intro{\isacharunderscore}classes\isanewline
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   176
\ \ \isacommand{fix}\ x\ y\ z\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a{\isasymColon}monoid{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   177
\ \ \isacommand{show}\ {\isachardoublequote}x\ {\isasymOtimes}\ y\ {\isasymOtimes}\ z\ {\isacharequal}\ x\ {\isasymOtimes}\ {\isacharparenleft}y\ {\isasymOtimes}\ z{\isacharparenright}{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   178
\ \ \ \ \isacommand{by}\ {\isacharparenleft}rule\ monoid{\isachardot}assoc{\isacharparenright}\isanewline
8890
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
   179
\isacommand{qed}\isanewline
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
   180
\isanewline
9665
2a6d7f1409f9 updated;
wenzelm
parents: 9519
diff changeset
   181
\isacommand{instance}\ group\ {\isacharless}\ monoid\isanewline
2a6d7f1409f9 updated;
wenzelm
parents: 9519
diff changeset
   182
\isacommand{proof}\ intro{\isacharunderscore}classes\isanewline
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   183
\ \ \isacommand{fix}\ x\ y\ z\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a{\isasymColon}group{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   184
\ \ \isacommand{show}\ {\isachardoublequote}x\ {\isasymOtimes}\ y\ {\isasymOtimes}\ z\ {\isacharequal}\ x\ {\isasymOtimes}\ {\isacharparenleft}y\ {\isasymOtimes}\ z{\isacharparenright}{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   185
\ \ \ \ \isacommand{by}\ {\isacharparenleft}rule\ semigroup{\isachardot}assoc{\isacharparenright}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   186
\ \ \isacommand{show}\ {\isachardoublequote}{\isasymunit}\ {\isasymOtimes}\ x\ {\isacharequal}\ x{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   187
\ \ \ \ \isacommand{by}\ {\isacharparenleft}rule\ group{\isachardot}left{\isacharunderscore}unit{\isacharparenright}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   188
\ \ \isacommand{show}\ {\isachardoublequote}x\ {\isasymOtimes}\ {\isasymunit}\ {\isacharequal}\ x{\isachardoublequote}\isanewline
9665
2a6d7f1409f9 updated;
wenzelm
parents: 9519
diff changeset
   189
\ \ \ \ \isacommand{by}\ {\isacharparenleft}rule\ group{\isacharunderscore}right{\isacharunderscore}unit{\isacharparenright}\isanewline
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   190
\isacommand{qed}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   191
\begin{isamarkuptext}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   192
\medskip The $\isakeyword{instance}$ command sets up an appropriate
8907
wenzelm
parents: 8903
diff changeset
   193
 goal that represents the class inclusion (or type arity, see
wenzelm
parents: 8903
diff changeset
   194
 \secref{sec:inst-arity}) to be proven
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   195
 (see also \cite{isabelle-isar-ref}).  The $intro_classes$ proof
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   196
 method does back-chaining of class membership statements wrt.\ the
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   197
 hierarchy of any classes defined in the current theory; the effect is
8907
wenzelm
parents: 8903
diff changeset
   198
 to reduce to the initial statement to a number of goals that directly
wenzelm
parents: 8903
diff changeset
   199
 correspond to any class axioms encountered on the path upwards
8922
wenzelm
parents: 8907
diff changeset
   200
 through the class hierarchy.%
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   201
\end{isamarkuptext}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   202
%
8907
wenzelm
parents: 8903
diff changeset
   203
\isamarkupsubsection{Concrete instantiation \label{sec:inst-arity}}
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   204
%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   205
\begin{isamarkuptext}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   206
So far we have covered the case of the form
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   207
 $\isakeyword{instance}~c@1 < c@2$, namely \emph{abstract
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   208
 instantiation} --- $c@1$ is more special than $c@2$ and thus an
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   209
 instance of $c@2$.  Even more interesting for practical applications
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   210
 are \emph{concrete instantiations} of axiomatic type classes.  That
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   211
 is, certain simple schemes $(\alpha@1, \ldots, \alpha@n)t :: c$ of
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   212
 class membership may be established at the logical level and then
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   213
 transferred to Isabelle's type signature level.
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   214
8907
wenzelm
parents: 8903
diff changeset
   215
 \medskip As a typical example, we show that type $bool$ with
9519
fdc3b5bcd79d updated;
wenzelm
parents: 9331
diff changeset
   216
 exclusive-or as $\TIMES$ operation, identity as $\isasyminv$, and
8907
wenzelm
parents: 8903
diff changeset
   217
 $False$ as $1$ forms an Abelian group.%
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   218
\end{isamarkuptext}%
9665
2a6d7f1409f9 updated;
wenzelm
parents: 9519
diff changeset
   219
\isacommand{defs}\ {\isacharparenleft}\isakeyword{overloaded}{\isacharparenright}\isanewline
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   220
\ \ times{\isacharunderscore}bool{\isacharunderscore}def{\isacharcolon}\ \ \ {\isachardoublequote}x\ {\isasymOtimes}\ y\ {\isasymequiv}\ x\ {\isasymnoteq}\ {\isacharparenleft}y{\isasymColon}bool{\isacharparenright}{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   221
\ \ inverse{\isacharunderscore}bool{\isacharunderscore}def{\isacharcolon}\ {\isachardoublequote}x{\isasyminv}\ {\isasymequiv}\ x{\isasymColon}bool{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   222
\ \ unit{\isacharunderscore}bool{\isacharunderscore}def{\isacharcolon}\ \ \ \ {\isachardoublequote}{\isasymunit}\ {\isasymequiv}\ False{\isachardoublequote}%
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   223
\begin{isamarkuptext}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   224
\medskip It is important to note that above $\DEFS$ are just
8907
wenzelm
parents: 8903
diff changeset
   225
 overloaded meta-level constant definitions, where type classes are
wenzelm
parents: 8903
diff changeset
   226
 not yet involved at all.  This form of constant definition with
wenzelm
parents: 8903
diff changeset
   227
 overloading (and optional recursion over the syntactic structure of
wenzelm
parents: 8903
diff changeset
   228
 simple types) are admissible as definitional extensions of plain HOL
wenzelm
parents: 8903
diff changeset
   229
 \cite{Wenzel:1997:TPHOL}.  The Haskell-style type system is not
wenzelm
parents: 8903
diff changeset
   230
 required for overloading.  Nevertheless, overloaded definitions are
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   231
 best applied in the context of type classes.
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   232
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   233
 \medskip Since we have chosen above $\DEFS$ of the generic group
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   234
 operations on type $bool$ appropriately, the class membership $bool
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   235
 :: agroup$ may be now derived as follows.%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   236
\end{isamarkuptext}%
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   237
\isacommand{instance}\ bool\ {\isacharcolon}{\isacharcolon}\ agroup\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   238
\isacommand{proof}\ {\isacharparenleft}intro{\isacharunderscore}classes{\isacharcomma}\isanewline
9665
2a6d7f1409f9 updated;
wenzelm
parents: 9519
diff changeset
   239
\ \ \ \ unfold\ times{\isacharunderscore}bool{\isacharunderscore}def\ inverse{\isacharunderscore}bool{\isacharunderscore}def\ unit{\isacharunderscore}bool{\isacharunderscore}def{\isacharparenright}\isanewline
9519
fdc3b5bcd79d updated;
wenzelm
parents: 9331
diff changeset
   240
\ \ \isacommand{fix}\ x\ y\ z\isanewline
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   241
\ \ \isacommand{show}\ {\isachardoublequote}{\isacharparenleft}{\isacharparenleft}x\ {\isasymnoteq}\ y{\isacharparenright}\ {\isasymnoteq}\ z{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}x\ {\isasymnoteq}\ {\isacharparenleft}y\ {\isasymnoteq}\ z{\isacharparenright}{\isacharparenright}{\isachardoublequote}\ \isacommand{by}\ blast\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   242
\ \ \isacommand{show}\ {\isachardoublequote}{\isacharparenleft}False\ {\isasymnoteq}\ x{\isacharparenright}\ {\isacharequal}\ x{\isachardoublequote}\ \isacommand{by}\ blast\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   243
\ \ \isacommand{show}\ {\isachardoublequote}{\isacharparenleft}x\ {\isasymnoteq}\ x{\isacharparenright}\ {\isacharequal}\ False{\isachardoublequote}\ \isacommand{by}\ blast\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   244
\ \ \isacommand{show}\ {\isachardoublequote}{\isacharparenleft}x\ {\isasymnoteq}\ y{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}y\ {\isasymnoteq}\ x{\isacharparenright}{\isachardoublequote}\ \isacommand{by}\ blast\isanewline
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   245
\isacommand{qed}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   246
\begin{isamarkuptext}%
8907
wenzelm
parents: 8903
diff changeset
   247
The result of an $\isakeyword{instance}$ statement is both expressed
wenzelm
parents: 8903
diff changeset
   248
 as a theorem of Isabelle's meta-logic, and as a type arity of the
wenzelm
parents: 8903
diff changeset
   249
 type signature.  The latter enables type-inference system to take
wenzelm
parents: 8903
diff changeset
   250
 care of this new instance automatically.
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   251
8907
wenzelm
parents: 8903
diff changeset
   252
 \medskip We could now also instantiate our group theory classes to
wenzelm
parents: 8903
diff changeset
   253
 many other concrete types.  For example, $int :: agroup$ (e.g.\ by
wenzelm
parents: 8903
diff changeset
   254
 defining $\TIMES$ as addition, $\isasyminv$ as negation and $1$ as
wenzelm
parents: 8903
diff changeset
   255
 zero) or $list :: (term)semigroup$ (e.g.\ if $\TIMES$ is defined as
wenzelm
parents: 8903
diff changeset
   256
 list append).  Thus, the characteristic constants $\TIMES$,
wenzelm
parents: 8903
diff changeset
   257
 $\isasyminv$, $1$ really become overloaded, i.e.\ have different
wenzelm
parents: 8903
diff changeset
   258
 meanings on different types.%
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   259
\end{isamarkuptext}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   260
%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   261
\isamarkupsubsection{Lifting and Functors}
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   262
%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   263
\begin{isamarkuptext}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   264
As already mentioned above, overloading in the simply-typed HOL
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   265
 systems may include recursion over the syntactic structure of types.
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   266
 That is, definitional equations $c^\tau \equiv t$ may also contain
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   267
 constants of name $c$ on the right-hand side --- if these have types
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   268
 that are structurally simpler than $\tau$.
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   269
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   270
 This feature enables us to \emph{lift operations}, say to Cartesian
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   271
 products, direct sums or function spaces.  Subsequently we lift
8907
wenzelm
parents: 8903
diff changeset
   272
 $\TIMES$ component-wise to binary products $\alpha \times \beta$.%
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   273
\end{isamarkuptext}%
9665
2a6d7f1409f9 updated;
wenzelm
parents: 9519
diff changeset
   274
\isacommand{defs}\ {\isacharparenleft}\isakeyword{overloaded}{\isacharparenright}\isanewline
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   275
\ \ times{\isacharunderscore}prod{\isacharunderscore}def{\isacharcolon}\ {\isachardoublequote}p\ {\isasymOtimes}\ q\ {\isasymequiv}\ {\isacharparenleft}fst\ p\ {\isasymOtimes}\ fst\ q{\isacharcomma}\ snd\ p\ {\isasymOtimes}\ snd\ q{\isacharparenright}{\isachardoublequote}%
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   276
\begin{isamarkuptext}%
8907
wenzelm
parents: 8903
diff changeset
   277
It is very easy to see that associativity of $\TIMES^\alpha$ and
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   278
 $\TIMES^\beta$ transfers to ${\TIMES}^{\alpha \times \beta}$.  Hence
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   279
 the binary type constructor $\times$ maps semigroups to semigroups.
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   280
 This may be established formally as follows.%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   281
\end{isamarkuptext}%
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   282
\isacommand{instance}\ {\isacharasterisk}\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}semigroup{\isacharcomma}\ semigroup{\isacharparenright}\ semigroup\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   283
\isacommand{proof}\ {\isacharparenleft}intro{\isacharunderscore}classes{\isacharcomma}\ unfold\ times{\isacharunderscore}prod{\isacharunderscore}def{\isacharparenright}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   284
\ \ \isacommand{fix}\ p\ q\ r\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a{\isasymColon}semigroup\ {\isasymtimes}\ {\isacharprime}b{\isasymColon}semigroup{\isachardoublequote}\isanewline
9519
fdc3b5bcd79d updated;
wenzelm
parents: 9331
diff changeset
   285
\ \ \isacommand{show}\isanewline
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   286
\ \ \ \ {\isachardoublequote}{\isacharparenleft}fst\ {\isacharparenleft}fst\ p\ {\isasymOtimes}\ fst\ q{\isacharcomma}\ snd\ p\ {\isasymOtimes}\ snd\ q{\isacharparenright}\ {\isasymOtimes}\ fst\ r{\isacharcomma}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   287
\ \ \ \ \ \ snd\ {\isacharparenleft}fst\ p\ {\isasymOtimes}\ fst\ q{\isacharcomma}\ snd\ p\ {\isasymOtimes}\ snd\ q{\isacharparenright}\ {\isasymOtimes}\ snd\ r{\isacharparenright}\ {\isacharequal}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   288
\ \ \ \ \ \ \ {\isacharparenleft}fst\ p\ {\isasymOtimes}\ fst\ {\isacharparenleft}fst\ q\ {\isasymOtimes}\ fst\ r{\isacharcomma}\ snd\ q\ {\isasymOtimes}\ snd\ r{\isacharparenright}{\isacharcomma}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   289
\ \ \ \ \ \ \ \ snd\ p\ {\isasymOtimes}\ snd\ {\isacharparenleft}fst\ q\ {\isasymOtimes}\ fst\ r{\isacharcomma}\ snd\ q\ {\isasymOtimes}\ snd\ r{\isacharparenright}{\isacharparenright}{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
   290
\ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ add{\isacharcolon}\ semigroup{\isachardot}assoc{\isacharparenright}\isanewline
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   291
\isacommand{qed}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   292
\begin{isamarkuptext}%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   293
Thus, if we view class instances as ``structures'', then overloaded
8907
wenzelm
parents: 8903
diff changeset
   294
 constant definitions with recursion over types indirectly provide
wenzelm
parents: 8903
diff changeset
   295
 some kind of ``functors'' --- i.e.\ mappings between abstract
8903
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   296
 theories.%
78d6e47469e4 new Isar version;
wenzelm
parents: 8890
diff changeset
   297
\end{isamarkuptext}%
9767
dc2ee9b2e065 updated;
wenzelm
parents: 9672
diff changeset
   298
\isacommand{end}\end{isabellebody}%
9145
9f7b8de5bfaf updated;
wenzelm
parents: 8922
diff changeset
   299
%%% Local Variables:
9f7b8de5bfaf updated;
wenzelm
parents: 8922
diff changeset
   300
%%% mode: latex
9f7b8de5bfaf updated;
wenzelm
parents: 8922
diff changeset
   301
%%% TeX-master: "root"
9f7b8de5bfaf updated;
wenzelm
parents: 8922
diff changeset
   302
%%% End: