| 9722 |      1 | %
 | 
|  |      2 | \begin{isabellebody}%
 | 
| 9924 |      3 | \def\isabellecontext{pairs}%
 | 
| 17056 |      4 | %
 | 
|  |      5 | \isadelimtheory
 | 
|  |      6 | %
 | 
|  |      7 | \endisadelimtheory
 | 
|  |      8 | %
 | 
|  |      9 | \isatagtheory
 | 
|  |     10 | %
 | 
|  |     11 | \endisatagtheory
 | 
|  |     12 | {\isafoldtheory}%
 | 
|  |     13 | %
 | 
|  |     14 | \isadelimtheory
 | 
|  |     15 | %
 | 
|  |     16 | \endisadelimtheory
 | 
| 9541 |     17 | %
 | 
|  |     18 | \begin{isamarkuptext}%
 | 
| 11428 |     19 | \label{sec:pairs}\index{pairs and tuples}
 | 
|  |     20 | HOL also has ordered pairs: \isa{($a@1$,$a@2$)} is of type $\tau@1$
 | 
| 10538 |     21 | \indexboldpos{\isasymtimes}{$Isatype} $\tau@2$ provided each $a@i$ is of type
 | 
| 11428 |     22 | $\tau@i$. The functions \cdx{fst} and
 | 
|  |     23 | \cdx{snd} extract the components of a pair:
 | 
| 10538 |     24 |  \isa{fst($x$,$y$) = $x$} and \isa{snd($x$,$y$) = $y$}. Tuples
 | 
| 9933 |     25 | are simulated by pairs nested to the right: \isa{($a@1$,$a@2$,$a@3$)} stands
 | 
|  |     26 | for \isa{($a@1$,($a@2$,$a@3$))} and $\tau@1 \times \tau@2 \times \tau@3$ for
 | 
|  |     27 | $\tau@1 \times (\tau@2 \times \tau@3)$. Therefore we have
 | 
|  |     28 | \isa{fst(snd($a@1$,$a@2$,$a@3$)) = $a@2$}.
 | 
| 9541 |     29 | 
 | 
| 10539 |     30 | Remarks:
 | 
|  |     31 | \begin{itemize}
 | 
|  |     32 | \item
 | 
| 11428 |     33 | There is also the type \tydx{unit}, which contains exactly one
 | 
| 11456 |     34 | element denoted by~\cdx{()}.  This type can be viewed
 | 
| 10539 |     35 | as a degenerate product with 0 components.
 | 
|  |     36 | \item
 | 
|  |     37 | Products, like type \isa{nat}, are datatypes, which means
 | 
| 10538 |     38 | in particular that \isa{induct{\isacharunderscore}tac} and \isa{case{\isacharunderscore}tac} are applicable to
 | 
| 10539 |     39 | terms of product type.
 | 
| 10839 |     40 | Both replace the term by a pair of variables.
 | 
| 10539 |     41 | \item
 | 
| 10795 |     42 | Tuples with more than two or three components become unwieldy;
 | 
|  |     43 | records are preferable.
 | 
| 10539 |     44 | \end{itemize}
 | 
|  |     45 | For more information on pairs and records see Chapter~\ref{ch:more-types}.%
 | 
| 9541 |     46 | \end{isamarkuptext}%
 | 
| 17175 |     47 | \isamarkuptrue%
 | 
| 17056 |     48 | %
 | 
|  |     49 | \isadelimtheory
 | 
|  |     50 | %
 | 
|  |     51 | \endisadelimtheory
 | 
|  |     52 | %
 | 
|  |     53 | \isatagtheory
 | 
|  |     54 | %
 | 
|  |     55 | \endisatagtheory
 | 
|  |     56 | {\isafoldtheory}%
 | 
|  |     57 | %
 | 
|  |     58 | \isadelimtheory
 | 
|  |     59 | %
 | 
|  |     60 | \endisadelimtheory
 | 
| 9722 |     61 | \end{isabellebody}%
 | 
| 9145 |     62 | %%% Local Variables:
 | 
|  |     63 | %%% mode: latex
 | 
|  |     64 | %%% TeX-master: "root"
 | 
|  |     65 | %%% End:
 |