doc-src/TutorialI/Misc/document/pairs.tex
author nipkow
Tue, 29 Aug 2000 15:43:29 +0200
changeset 9722 a5f86aed785b
parent 9721 7e51c9f3d5a0
child 9792 bbefb6ce5cb2
permissions -rw-r--r--
*** empty log message ***
     1 %
     2 \begin{isabellebody}%
     3 %
     4 \begin{isamarkuptext}%
     5 HOL also has pairs: \isa{($a@1$,$a@2$)} is of type \isa{$\tau@1$ *
     6   $\tau@2$} provided each $a@i$ is of type $\tau@i$. The components of a pair
     7 are extracted by \isa{fst} and \isa{snd}: \isa{fst($x$,$y$) = $x$} and
     8 \isa{snd($x$,$y$) = $y$}. Tuples are simulated by pairs nested to the right:
     9 \isa{($a@1$,$a@2$,$a@3$)} stands for \isa{($a@1$,($a@2$,$a@3$))} and
    10 \isa{$\tau@1$ * $\tau@2$ * $\tau@3$} for \isa{$\tau@1$ * ($\tau@2$ *
    11   $\tau@3$)}. Therefore we have \isa{fst(snd($a@1$,$a@2$,$a@3$)) = $a@2$}.
    12 
    13 It is possible to use (nested) tuples as patterns in abstractions, for
    14 example \isa{\isasymlambda(x,y,z).x+y+z} and
    15 \isa{\isasymlambda((x,y),z).x+y+z}.
    16 In addition to explicit $\lambda$-abstractions, tuple patterns can be used in
    17 most variable binding constructs. Typical examples are
    18 \begin{quote}
    19 \isa{let\ {\isacharparenleft}\mbox{x}{\isacharcomma}\ \mbox{y}{\isacharparenright}\ {\isacharequal}\ \mbox{f}\ \mbox{z}\ in\ {\isacharparenleft}\mbox{y}{\isacharcomma}\ \mbox{x}{\isacharparenright}}\\
    20 \isa{case\ \mbox{xs}\ of\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymRightarrow}\ \isadigit{0}\ {\isacharbar}\ {\isacharparenleft}\mbox{x}{\isacharcomma}\ \mbox{y}{\isacharparenright}\ {\isacharhash}\ \mbox{zs}\ {\isasymRightarrow}\ \mbox{x}\ {\isacharplus}\ \mbox{y}}
    21 \end{quote}
    22 Further important examples are quantifiers and sets (see~\S\ref{quant-pats}).%
    23 \end{isamarkuptext}%
    24 \end{isabellebody}%
    25 %%% Local Variables:
    26 %%% mode: latex
    27 %%% TeX-master: "root"
    28 %%% End: