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