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 ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9722
a5f86aed785b *** empty log message ***
nipkow
parents: 9721
diff changeset
     1
%
a5f86aed785b *** empty log message ***
nipkow
parents: 9721
diff changeset
     2
\begin{isabellebody}%
9541
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9145
diff changeset
     3
%
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9145
diff changeset
     4
\begin{isamarkuptext}%
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9145
diff changeset
     5
HOL also has pairs: \isa{($a@1$,$a@2$)} is of type \isa{$\tau@1$ *
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9145
diff changeset
     6
  $\tau@2$} provided each $a@i$ is of type $\tau@i$. The components of a pair
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9145
diff changeset
     7
are extracted by \isa{fst} and \isa{snd}: \isa{fst($x$,$y$) = $x$} and
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9145
diff changeset
     8
\isa{snd($x$,$y$) = $y$}. Tuples are simulated by pairs nested to the right:
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9145
diff changeset
     9
\isa{($a@1$,$a@2$,$a@3$)} stands for \isa{($a@1$,($a@2$,$a@3$))} and
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9145
diff changeset
    10
\isa{$\tau@1$ * $\tau@2$ * $\tau@3$} for \isa{$\tau@1$ * ($\tau@2$ *
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9145
diff changeset
    11
  $\tau@3$)}. Therefore we have \isa{fst(snd($a@1$,$a@2$,$a@3$)) = $a@2$}.
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9145
diff changeset
    12
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9145
diff changeset
    13
It is possible to use (nested) tuples as patterns in abstractions, for
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9145
diff changeset
    14
example \isa{\isasymlambda(x,y,z).x+y+z} and
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9145
diff changeset
    15
\isa{\isasymlambda((x,y),z).x+y+z}.
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9145
diff changeset
    16
In addition to explicit $\lambda$-abstractions, tuple patterns can be used in
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9145
diff changeset
    17
most variable binding constructs. Typical examples are
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9145
diff changeset
    18
\begin{quote}
9673
1b2d4f995b13 updated;
wenzelm
parents: 9644
diff changeset
    19
\isa{let\ {\isacharparenleft}\mbox{x}{\isacharcomma}\ \mbox{y}{\isacharparenright}\ {\isacharequal}\ \mbox{f}\ \mbox{z}\ in\ {\isacharparenleft}\mbox{y}{\isacharcomma}\ \mbox{x}{\isacharparenright}}\\
1b2d4f995b13 updated;
wenzelm
parents: 9644
diff changeset
    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}}
9541
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9145
diff changeset
    21
\end{quote}
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9145
diff changeset
    22
Further important examples are quantifiers and sets (see~\S\ref{quant-pats}).%
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9145
diff changeset
    23
\end{isamarkuptext}%
9722
a5f86aed785b *** empty log message ***
nipkow
parents: 9721
diff changeset
    24
\end{isabellebody}%
9145
9f7b8de5bfaf updated;
wenzelm
parents: 8749
diff changeset
    25
%%% Local Variables:
9f7b8de5bfaf updated;
wenzelm
parents: 8749
diff changeset
    26
%%% mode: latex
9f7b8de5bfaf updated;
wenzelm
parents: 8749
diff changeset
    27
%%% TeX-master: "root"
9f7b8de5bfaf updated;
wenzelm
parents: 8749
diff changeset
    28
%%% End: