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
     1 %
     2 \begin{isabellebody}%
     3 \def\isabellecontext{Overloading{\isadigit{2}}}%
     4 \isamarkupfalse%
     5 %
     6 \begin{isamarkuptext}%
     7 Of course this is not the only possible definition of the two relations.
     8 Componentwise comparison of lists of equal length also makes sense. This time
     9 the elements of the list must also be of class \isa{ordrel} to permit their
    10 comparison:%
    11 \end{isamarkuptext}%
    12 \isamarkuptrue%
    13 \isacommand{instance}\ list\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}ordrel{\isacharparenright}ordrel\isanewline
    14 \isamarkupfalse%
    15 \isacommand{by}\ intro{\isacharunderscore}classes\isanewline
    16 \isanewline
    17 \isamarkupfalse%
    18 \isacommand{defs}\ {\isacharparenleft}\isakeyword{overloaded}{\isacharparenright}\isanewline
    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
    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%
    21 %
    22 \begin{isamarkuptext}%
    23 \noindent
    24 The infix function \isa{{\isacharbang}} yields the nth element of a list.
    25 
    26 \begin{warn}
    27 A type constructor can be instantiated in only one way to
    28 a given type class.  For example, our two instantiations of \isa{list} must
    29 reside in separate theories with disjoint scopes.
    30 \end{warn}%
    31 \end{isamarkuptext}%
    32 \isamarkuptrue%
    33 %
    34 \isamarkupsubsubsection{Predefined Overloading%
    35 }
    36 \isamarkuptrue%
    37 %
    38 \begin{isamarkuptext}%
    39 HOL comes with a number of overloaded constants and corresponding classes.
    40 The most important ones are listed in Table~\ref{tab:overloading} in the appendix. They are
    41 defined on all numeric types and sometimes on other types as well, for example
    42 $-$ and \isa{{\isasymle}} on sets.
    43 
    44 In addition there is a special syntax for bounded quantifiers:
    45 \begin{center}
    46 \begin{tabular}{lcl}
    47 \isa{{\isasymforall}x{\isasymle}y{\isachardot}\ P\ x} & \isa{{\isasymrightleftharpoons}} & \isa{{\isachardoublequote}{\isasymforall}x{\isachardot}\ x\ {\isasymle}\ y\ {\isasymlongrightarrow}\ P\ x{\isachardoublequote}} \\
    48 \isa{{\isasymexists}x{\isasymle}y{\isachardot}\ P\ x} & \isa{{\isasymrightleftharpoons}} & \isa{{\isachardoublequote}{\isasymexists}x{\isachardot}\ x\ {\isasymle}\ y\ {\isasymand}\ P\ x{\isachardoublequote}}
    49 \end{tabular}
    50 \end{center}
    51 And analogously for \isa{{\isacharless}} instead of \isa{{\isasymle}}.%
    52 \end{isamarkuptext}%
    53 \isamarkuptrue%
    54 \isamarkupfalse%
    55 \end{isabellebody}%
    56 %%% Local Variables:
    57 %%% mode: latex
    58 %%% TeX-master: "root"
    59 %%% End: