doc-src/TutorialI/Types/document/Overloading2.tex
author wenzelm
Tue, 16 May 2006 20:28:02 +0200
changeset 19654 2c02a8054616
parent 19288 85b684d3fdbd
child 30637 57753e0ec1d4
permissions -rw-r--r--
updated;
     1 %
     2 \begin{isabellebody}%
     3 \def\isabellecontext{Overloading{\isadigit{2}}}%
     4 %
     5 \isadelimtheory
     6 %
     7 \endisadelimtheory
     8 %
     9 \isatagtheory
    10 %
    11 \endisatagtheory
    12 {\isafoldtheory}%
    13 %
    14 \isadelimtheory
    15 %
    16 \endisadelimtheory
    17 %
    18 \begin{isamarkuptext}%
    19 Of course this is not the only possible definition of the two relations.
    20 Componentwise comparison of lists of equal length also makes sense. This time
    21 the elements of the list must also be of class \isa{ordrel} to permit their
    22 comparison:%
    23 \end{isamarkuptext}%
    24 \isamarkuptrue%
    25 \isacommand{instance}\isamarkupfalse%
    26 \ list\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}ordrel{\isacharparenright}ordrel\isanewline
    27 %
    28 \isadelimproof
    29 %
    30 \endisadelimproof
    31 %
    32 \isatagproof
    33 \isacommand{by}\isamarkupfalse%
    34 \ intro{\isacharunderscore}classes%
    35 \endisatagproof
    36 {\isafoldproof}%
    37 %
    38 \isadelimproof
    39 \isanewline
    40 %
    41 \endisadelimproof
    42 \isanewline
    43 \isacommand{defs}\isamarkupfalse%
    44 \ {\isacharparenleft}\isakeyword{overloaded}{\isacharparenright}\isanewline
    45 le{\isacharunderscore}list{\isacharunderscore}def{\isacharcolon}\ {\isachardoublequoteopen}xs\ {\isacharless}{\isacharless}{\isacharequal}\ {\isacharparenleft}ys{\isacharcolon}{\isacharcolon}{\isacharprime}a{\isacharcolon}{\isacharcolon}ordrel\ list{\isacharparenright}\ {\isasymequiv}\isanewline
    46 \ \ \ \ \ \ \ \ \ \ \ \ \ \ size\ xs\ {\isacharequal}\ size\ ys\ {\isasymand}\ {\isacharparenleft}{\isasymforall}i{\isacharless}size\ xs{\isachardot}\ xs{\isacharbang}i\ {\isacharless}{\isacharless}{\isacharequal}\ ys{\isacharbang}i{\isacharparenright}{\isachardoublequoteclose}%
    47 \begin{isamarkuptext}%
    48 \noindent
    49 The infix function \isa{{\isacharbang}} yields the nth element of a list.
    50 
    51 \begin{warn}
    52 A type constructor can be instantiated in only one way to
    53 a given type class.  For example, our two instantiations of \isa{list} must
    54 reside in separate theories with disjoint scopes.
    55 \end{warn}%
    56 \end{isamarkuptext}%
    57 \isamarkuptrue%
    58 %
    59 \isamarkupsubsubsection{Predefined Overloading%
    60 }
    61 \isamarkuptrue%
    62 %
    63 \begin{isamarkuptext}%
    64 HOL comes with a number of overloaded constants and corresponding classes.
    65 The most important ones are listed in Table~\ref{tab:overloading} in the appendix. They are
    66 defined on all numeric types and sometimes on other types as well, for example
    67 $-$ and \isa{{\isasymle}} on sets.
    68 
    69 In addition there is a special syntax for bounded quantifiers:
    70 \begin{center}
    71 \begin{tabular}{lcl}
    72 \isa{{\isasymforall}x{\isasymle}y{\isachardot}\ P\ x} & \isa{{\isasymrightleftharpoons}} & \isa{{\isachardoublequote}{\isasymforall}x{\isachardot}\ x\ {\isasymle}\ y\ {\isasymlongrightarrow}\ P\ x{\isachardoublequote}} \\
    73 \isa{{\isasymexists}x{\isasymle}y{\isachardot}\ P\ x} & \isa{{\isasymrightleftharpoons}} & \isa{{\isachardoublequote}{\isasymexists}x{\isachardot}\ x\ {\isasymle}\ y\ {\isasymand}\ P\ x{\isachardoublequote}}
    74 \end{tabular}
    75 \end{center}
    76 And analogously for \isa{{\isacharless}} instead of \isa{{\isasymle}}.%
    77 \end{isamarkuptext}%
    78 \isamarkuptrue%
    79 %
    80 \isadelimtheory
    81 %
    82 \endisadelimtheory
    83 %
    84 \isatagtheory
    85 %
    86 \endisatagtheory
    87 {\isafoldtheory}%
    88 %
    89 \isadelimtheory
    90 %
    91 \endisadelimtheory
    92 \end{isabellebody}%
    93 %%% Local Variables:
    94 %%% mode: latex
    95 %%% TeX-master: "root"
    96 %%% End: