doc-src/TutorialI/Types/document/Overloading2.tex
author paulson
Tue, 10 Feb 2004 12:17:04 +0100
changeset 14379 ea10a8c3e9cf
parent 13778 61272514e3b5
child 15181 8d9575d1caa7
permissions -rw-r--r--
updated links to the old ftp site
nipkow@10305
     1
%
nipkow@10305
     2
\begin{isabellebody}%
nipkow@10305
     3
\def\isabellecontext{Overloading{\isadigit{2}}}%
wenzelm@11866
     4
\isamarkupfalse%
nipkow@10305
     5
%
nipkow@10305
     6
\begin{isamarkuptext}%
nipkow@10305
     7
Of course this is not the only possible definition of the two relations.
nipkow@10328
     8
Componentwise comparison of lists of equal length also makes sense. This time
nipkow@10328
     9
the elements of the list must also be of class \isa{ordrel} to permit their
nipkow@10328
    10
comparison:%
nipkow@10305
    11
\end{isamarkuptext}%
wenzelm@11866
    12
\isamarkuptrue%
nipkow@10305
    13
\isacommand{instance}\ list\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}ordrel{\isacharparenright}ordrel\isanewline
wenzelm@11866
    14
\isamarkupfalse%
nipkow@10305
    15
\isacommand{by}\ intro{\isacharunderscore}classes\isanewline
nipkow@10305
    16
\isanewline
wenzelm@11866
    17
\isamarkupfalse%
nipkow@10305
    18
\isacommand{defs}\ {\isacharparenleft}\isakeyword{overloaded}{\isacharparenright}\isanewline
nipkow@10305
    19
le{\isacharunderscore}list{\isacharunderscore}def{\isacharcolon}\ {\isachardoublequote}xs\ {\isacharless}{\isacharless}{\isacharequal}\ {\isacharparenleft}ys{\isacharcolon}{\isacharcolon}{\isacharprime}a{\isacharcolon}{\isacharcolon}ordrel\ list{\isacharparenright}\ {\isasymequiv}\isanewline
wenzelm@11866
    20
\ \ \ \ \ \ \ \ \ \ \ \ \ \ size\ xs\ {\isacharequal}\ size\ ys\ {\isasymand}\ {\isacharparenleft}{\isasymforall}i{\isacharless}size\ xs{\isachardot}\ xs{\isacharbang}i\ {\isacharless}{\isacharless}{\isacharequal}\ ys{\isacharbang}i{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
wenzelm@11866
    21
%
nipkow@10305
    22
\begin{isamarkuptext}%
nipkow@10328
    23
\noindent
paulson@11494
    24
The infix function \isa{{\isacharbang}} yields the nth element of a list.
paulson@11494
    25
paulson@11494
    26
\begin{warn}
paulson@11494
    27
A type constructor can be instantiated in only one way to
paulson@11494
    28
a given type class.  For example, our two instantiations of \isa{list} must
nipkow@12334
    29
reside in separate theories with disjoint scopes.
paulson@11494
    30
\end{warn}%
nipkow@10396
    31
\end{isamarkuptext}%
wenzelm@11866
    32
\isamarkuptrue%
nipkow@10396
    33
%
paulson@10878
    34
\isamarkupsubsubsection{Predefined Overloading%
paulson@10397
    35
}
wenzelm@11866
    36
\isamarkuptrue%
nipkow@10396
    37
%
nipkow@10396
    38
\begin{isamarkuptext}%
nipkow@10396
    39
HOL comes with a number of overloaded constants and corresponding classes.
nipkow@10978
    40
The most important ones are listed in Table~\ref{tab:overloading} in the appendix. They are
nipkow@10971
    41
defined on all numeric types and sometimes on other types as well, for example
paulson@11494
    42
$-$ and \isa{{\isasymle}} on sets.
nipkow@10396
    43
paulson@14379
    44
In addition there is a special syntax for bounded quantifiers:
nipkow@10696
    45
\begin{center}
nipkow@10696
    46
\begin{tabular}{lcl}
paulson@14379
    47
\isa{{\isasymforall}x{\isasymle}y{\isachardot}\ P\ x} & \isa{{\isasymrightleftharpoons}} & \isa{{\isachardoublequote}{\isasymforall}x{\isachardot}\ x\ {\isasymle}\ y\ {\isasymlongrightarrow}\ P\ x{\isachardoublequote}} \\
paulson@14379
    48
\isa{{\isasymexists}x{\isasymle}y{\isachardot}\ P\ x} & \isa{{\isasymrightleftharpoons}} & \isa{{\isachardoublequote}{\isasymexists}x{\isachardot}\ x\ {\isasymle}\ y\ {\isasymand}\ P\ x{\isachardoublequote}}
nipkow@10696
    49
\end{tabular}
nipkow@10696
    50
\end{center}
paulson@14379
    51
And analogously for \isa{{\isacharless}} instead of \isa{{\isasymle}}.%
nipkow@10305
    52
\end{isamarkuptext}%
wenzelm@11866
    53
\isamarkuptrue%
wenzelm@11866
    54
\isamarkupfalse%
nipkow@10305
    55
\end{isabellebody}%
nipkow@10305
    56
%%% Local Variables:
nipkow@10305
    57
%%% mode: latex
nipkow@10305
    58
%%% TeX-master: "root"
nipkow@10305
    59
%%% End: