9722
|
1 |
%
|
|
2 |
\begin{isabellebody}%
|
9924
|
3 |
\def\isabellecontext{pairs}%
|
9541
|
4 |
%
|
|
5 |
\begin{isamarkuptext}%
|
9933
|
6 |
HOL also has pairs: \isa{($a@1$,$a@2$)} is of type $\tau@1$
|
|
7 |
\indexboldpos{\isasymtimes}{$IsaFun} $\tau@2$ provided each $a@i$ is of type
|
|
8 |
$\tau@i$. The components of a pair are extracted by \isa{fst} and
|
|
9 |
\isa{snd}: \isa{fst($x$,$y$) = $x$} and \isa{snd($x$,$y$) = $y$}. Tuples
|
|
10 |
are simulated by pairs nested to the right: \isa{($a@1$,$a@2$,$a@3$)} stands
|
|
11 |
for \isa{($a@1$,($a@2$,$a@3$))} and $\tau@1 \times \tau@2 \times \tau@3$ for
|
|
12 |
$\tau@1 \times (\tau@2 \times \tau@3)$. Therefore we have
|
|
13 |
\isa{fst(snd($a@1$,$a@2$,$a@3$)) = $a@2$}.
|
9541
|
14 |
|
|
15 |
It is possible to use (nested) tuples as patterns in abstractions, for
|
|
16 |
example \isa{\isasymlambda(x,y,z).x+y+z} and
|
|
17 |
\isa{\isasymlambda((x,y),z).x+y+z}.
|
|
18 |
In addition to explicit $\lambda$-abstractions, tuple patterns can be used in
|
|
19 |
most variable binding constructs. Typical examples are
|
|
20 |
\begin{quote}
|
9792
|
21 |
\isa{let\ {\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}\ {\isacharequal}\ f\ z\ in\ {\isacharparenleft}y{\isacharcomma}\ x{\isacharparenright}}\\
|
10187
|
22 |
\isa{case\ xs\ of\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymRightarrow}\ {\isadigit{0}}\ {\isacharbar}\ {\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}\ {\isacharhash}\ zs\ {\isasymRightarrow}\ x\ {\isacharplus}\ y}
|
9541
|
23 |
\end{quote}
|
|
24 |
Further important examples are quantifiers and sets (see~\S\ref{quant-pats}).%
|
|
25 |
\end{isamarkuptext}%
|
9722
|
26 |
\end{isabellebody}%
|
9145
|
27 |
%%% Local Variables:
|
|
28 |
%%% mode: latex
|
|
29 |
%%% TeX-master: "root"
|
|
30 |
%%% End:
|