36. Tuples
In order to generalize the idea of ordered pair to allow more than two coordinates, we need some notation.
36.1 Definition: n
Let $n$ be an integer, $n\geq 1$. Then $\mathbf{n}$ is defined to be the set
$$\{i\in\mathrm{N}\mid 1\leq i\leq n\}$$
36.1.1 Example $\mathbf{3}=\{1,2,3\}$.
36.1.2 Exercise Let $m$ and $n$ be positive integers. What is $\mathbf{m}\cap\mathbf{n}$? What is $\mathbf{m}\cup\mathbf{n}$? (Answer on page 244.)
A tuple is a generalization of the concept of ordered pair. A tuple satisfies this specification:
36.2 Specification: tuple
A tuple of length $n$, or $n$-tuple, is a mathematical object which
T.1 has an $i$th entry for each $i\in\mathbf{n}$, and
T.2 is distinct from its entries, and
T.3 is completely determined by specifying the $i$th entry for every $i\in\mathbf{n}$.
36.2.1 Example An ordered pair is the same thing as a 2-tuple.
36.2.2 Usage
a) A 3-tuple is usually called an ordered triple.
b) The usual way of denoting a tuple is by listing its entries in order inside angle brackets.
36.2.3 Example $\langle 1,3,3,-2\rangle$ is a tuple of integers. It has length 4. The integer 3 occurs as an entry in this 4-tuple twice, for $i=2$ and $i=3$.
36.2.4 Usage Tuples and their coordinates are often named according to a subscripting convention, by which one refers to the $i$th entry by subscripting $i$ to the name of the tuple. For example, let $a=\langle 1,3,3,-2\rangle$; then $a_{2}=3$ and $a_{4}=-2$. One often makes this convention clear by saying, “Let $a=\langle a_{i}\rangle_{i\in\mathbf{n}}$ be an $n$-tuple.”
Many authors would use curly brackets here: “$\{a_{i}\}_{i\in\mathbf{n}}$.” Nevertheless, $a$ is not a set.
36.2.5 Usage Many computer scientists refer to a tuple as a “vector”. Although this usage is widespread, it is not desirable; in mathematics, a vector is a geometric object which can be represented as a tuple, but is not itself a tuple.
It follows from Specification 36.2 that two $n$-tuples are equal if and only if they have the same entries. Formally:
36.3 Theorem: How to tell if tuples are equal
Let $a$ and $b$ be $n$-tuples. Then
$$a=b\Leftrightarrow(\forall i{:}\mathbf{n})(a_{i}=b_{i})$$
36.3.1 Exercise Which of these pairs of tuples are equal?
a) $\langle 3,3\rangle$, $\langle 3,3,3\rangle$.
b) $\langle 2,3\rangle$, $\langle 2,3,3\rangle$.
c) $\langle 2,3,2\rangle$, $\langle 3,2,2\rangle$.
(Answer on page 244.)
36.4 Special tuples
For formal completeness, one also has the concept of the null tuple (or empty tuple) $\langle\rangle$, which has length 0 and no entries, and a 1-tuple, which has length 1 and one entry.
The index set for the null tuple is the empty set. There is only one null tuple. In the context of formal language theory the unique null tuple is often denoted “Λ” (capital lambda) or sometimes “$\epsilon$” (small epsilon). We will use the notation Λ here.
36.4.1 Exercise For each tuple, give the integer $n$ for which it is an $n$-tuple and also give its second entry.
$$\begin{array}{ll} \text{a) } \langle 3,4,0\rangle & \text{d) } \langle\langle\langle 2,\langle 1,5\rangle\rangle,7\rangle,9\rangle \\ \text{b) } \langle\langle 3,4\rangle,\langle 1,5\rangle\rangle & \text{e) } \langle 3,\{1,2\}\rangle \\ \text{c) } \langle 3,\langle 5,\langle 2,1\rangle\rangle\rangle & \text{f) } \langle\mathrm{N},\mathrm{Z},\mathrm{Q},\mathrm{R}\rangle \end{array}$$
(Answer on page 244.)
Pages 50–51 of the book (PDF).