97. Tuples as functions
Let $n$ be a positive integer, and let
$$\mathbf{n} = \{1,2,\ldots,n\}$$
An $n$-tuple
$$\mathbf{a} = \langle a_{1},\ldots,a_{n}\rangle$$
in $A^{n}$ associates to each element $i$ of $\mathbf{n}$ an element $a_{i}$ of $A$. This determines a function $i \mapsto a_{i}$ with domain $\mathbf{n}$ and codomain $A$. Conversely, any such function determines an $n$-tuple in $A^{n}$ by setting its coordinate at $i$ to be its value at $i$.
When $\mathbf{a} \in A_{1} \times A_{2} \times \cdots \times A_{n}$, so that different components are in different sets, this way of looking at $n$-tuples is more complicated. Every coordinate $a_{i}$ is an element of the union $C = A_{1} \cup A_{2} \cup \cdots \cup A_{n}$, so that $\mathbf{a}$ can be thought of as a function from $\mathbf{n} \to C$. In this case, however, not every such function is a tuple in $A_{1} \times A_{2} \times \cdots \times A_{n}$: we must impose the additional requirement that $a_{i} \in A_{i}$.
We sum all this up in an alternative definition of tuple:
97.1 Definition: tuple as function
A tuple in $\prod_{i=1}^{n} A_{i}$ is a function
$$\mathbf{a}\colon \mathbf{n} \to A_{1} \cup A_{2} \cup \cdots \cup A_{n}$$
with the property that for each $i$, $a(i) \in A_{i}$.
97.1.1 Example The tuple $\langle 2,1,3\rangle$ is the function $1 \mapsto 2$, $2 \mapsto 1$, $3 \mapsto 3$ (compare Section 95.1.3).
97.1.2 Example The tuple $\langle 5,5,5,5\rangle$ is the constant function $C_{5}\colon \{1,2,3,4\} \to \mathrm{Z}$.
97.1.3 Exercise Write the domain and the graph of these tuples regarded as functions on the index set.
a) $\langle 2,5,-1,3,6\rangle$.
b) $\langle \pi,5,\pi-1,\sqrt{2}\rangle$.
c) $\langle\langle 3,5\rangle, \langle 8,-7\rangle, \langle 5,5\rangle\rangle$.
(Answer on page 248.)
97.1.4 Example A simple database might have records each of which consists of the name of a student, the student’s student number, and the number of classes the student takes. Such a record would be a triple $\langle w,x,n\rangle$, where $w$ is an element of the set $A^{*}$ of strings of English letters and spaces (this notation is introduced formally in Definitions 109.2 and 110.1), $x$ is an element of the set $D^{*}$ of strings of decimal digits, and $n \in \mathrm{N}$. This triple corresponds to a function $F\colon \{1,2,3\} \to A^{*} \times D^{*} \times \mathrm{N}$ with the property that $F(1) \in A^{*}$, $F(2) \in D^{*}$ and $F(3) \in \mathrm{N}$.
Modeling detabases this way is the principle behind relational database theory.
97.1.5 Remark In the case that all the $A_{i}$ are the same, so that $\mathbf{a} \in A^{n}$, we now have the situation that $A^{\mathbf{n}}$ (the set of functions from $\mathbf{n}$ to $A$, where $\mathbf{n} = \{1,2,\ldots,n\}$) and $A^{n}$ (the set of $n$-tuples in $A$) are essentially the same thing. That is the origin of the notation $B^{A}$.
97.2 Tuples with other index sets
The discussion above suggests that by regarding a tuple as a function set, we can use any set as index set.
97.2.1 Example In computer science it is often convenient to start a list at 0 instead of at 1, giving a tuple $\langle a_{0},a_{1},\ldots,a_{n}\rangle$. This is then a tuple indexed by the set $\{0,1,\ldots,n\}$ for some $n$ (so it has $n+1$ entries!).
97.2.2 Example An infinite sequence of integers is indexed by $\mathrm{N}^{+}$, so it is an element of $\mathrm{Z}^{\mathrm{N}^{+}}$.
97.2.3 Example This is another look at Example 97.1.4. The point of view that a triple $\langle\mathrm{Jones},1235551212,4\rangle$ is a function with domain $\{1,2,3\}$ has an arbitrary nature: it doesn’t matter that the name is first, the student number second and the number of classes third. What matters is that Jones is the name, 1235551212 is the student number and 4 is the number of classes. Thus it would be conceptually better to regard the triple as a function whose domain is the set $\{\mathrm{Name},\mathrm{StudentNumber},\mathrm{NumberOfClasses}\}$, with the property that $f(\mathrm{Name}) \in A^{*}$, $F(\mathrm{StudentNumber}) \in D^{*}$ and $F(\mathrm{NumberOfClasses}) \in \mathrm{N}$. This eliminates the spurious ordering of data imposed by using the set $\{1,2,3\}$ as domain.
In this context, the elements of a set such as
$$\{\mathrm{Name},\mathrm{StudentNumber},\mathrm{NumberOfClasses}\}$$
are called the field names of the database.
97.3 Definition: function as tuple
A function $T\colon S \to A$ is is also called an $S$-tuple or a family of elements of $A$ indexed by $S$.
97.3.1 Exercise Write each of these functions as tuples.
a) $F\colon \{1,2,3,4,5\} \to \mathrm{R}$, $\Gamma(F) = \bigl\{\langle 2,5\rangle, \langle 1,5\rangle, \langle 3,3\rangle, \langle 5,-1\rangle, \langle 4,17\rangle\bigr\}$.
b) $F\colon \{1,2,3,4,5\} \to \mathrm{R}$, $F(n) = (n+1)\pi$.
c) $x \mapsto x^{2}\colon \{1,2,3,4,5,6\} \to \mathrm{R}$.
(Answer on page 248.)
Pages 138–140 of the book (PDF).