# Tuple

In mathematics and computer science a **tuple** captures the intuitive notion of an ordered list of elements. Depending on the mathematical foundation chosen, the formal notion differs slightly. In set theory, an **(ordered) n-tuple** is a sequence (or ordered list) of

`n`elements, where

`n`is a positive integer. There is also one 0-tuple, which is just an empty sequence. When

*n*is understood from context, an

*n*-tuple is sometimes referred to just as tuple, but this practice is not common in set theory texts. An

*n*-tuple is defined inductively using the construction of an ordered pair. In type theory, commonly used in programming languages, a

**tuple**has a product type: not only is the length fixed, but also the types of the components have to be specified, thus the length alone is not sufficient to inductively define a notion.

Tuples are usually written by listing the elements within parentheses '()' and separated by commas; for example, (2, 7, 4, 1, 7) denotes a 5-tuple. Sometimes other delimiters are used, such as brackets '[]' or angle parentheses ''. (However, braces '{}' are almost never used for tuples, as they are the standard notation for sets.)

Tuples are often used to describe other mathematical objects. In algebra, for example, a ring is commonly defined as a 3-tuple (*E*,+,×), where *E* is some set, and '+','×' are functions from *E*×*E* to *E* with specific properties. In computer science, tuples are directly implemented as product types in most functional programming languages. More commonly though, they are (also) implemented as record types, where the components are labeled instead of being identified by position alone. This approach is also used in relational algebra, one of the cornerstones of relational database theory.

## Contents

## Origin of name

The term originated as an abstraction of the sequence: single, double, triple, quadruple, quintuple, *n-*tuple. A 2-tuple is called a pair; a 3-tuple is a triple or triplet. The *n* can be any nonnegative integer. For example, a complex number can be represented as a 2-tuple, and a quaternion can be represented as a 4-tuple. Further constructed names are possible, such as *octuple*, but many mathematicians find it quicker to write "8-tuple", even if still pronouncing this "octuple".

Although the word *tuple* was taken as an apparent suffix of some of the names for tuples of specific length, such as *quintuple*, this is based on a false analysis. The word *quintuple* comes from Latin *quintuplex*, which should be analyzed as *quintu-plex*, in which the suffix *plex* comes from *plicare* "to fold", from which also English *ply* (and hence also the calque *fivefold*).

## Names for tuples of specific length

- 0: empty tuple
- 1: single; singleton
- 2: pair/doublet
- 3: triple/triplet
- 4: quadruple
- 5: quintuple / pentuple
- 6: sextuple / hextuple
- 7: septuple
- 8: octuple
- 9: nonuple
- 10: decuple
- 11: undecuple / hendecuple
- 12: duodecuple
- 100: centuple

An empty tuple is also called a unit in type theory.

## Formal definitions

### Characteristic properties

The main properties that distinguish a tuple from, for example, a set are that

- it can contain an object more than once;
- the objects appear in a certain order;
- it has finite size.

Note that (1) distinguishes it from an ordered set and that (2) distinguishes it from a multiset. This is often formalized by giving the following rule for the identity of two *n-*tuples:

- (
*a*_{1},*a*_{2}, …,*a*) = (_{n}*b*_{1},*b*_{2}, …,*b*) if and only if_{n}*a*_{1}=*b*_{1},*a*_{2}=*b*_{2}, …, and*a*_{n}=*b*_{n}.

### Tuples as functions

An *n*-tuple can also be regarded as a function whose domain is the natural numbers { 1, 2, …, *n* } (or { 0, 1, …, *n*-1 }); that is, a set of index-element pairs:

- (
*a*_{1},*a*_{2}, …,*a*n) ≡ { (1,_{}*a*_{1}), (2,*a*_{2}), … (*n*,*a*_{n}) }

or

- (
*a*_{0},*a*_{1}, …,*a*n_{}*−1*) ≡ { (0,*a*_{0}), (1,*a*_{1}), … (*n*−1,*a*_{n−1}) }.

### Tuples as nested ordered pairs

Another way of formalizing tuples is as nested ordered pairs. Namely,

- the 0-tuple (i.e. the empty tuple) is represented by the empty set Ø;
- an
*n-*tuple, with*n*> 0, can be defined as an ordered pair of its first entry and an (*n*−1)-tuple containing the remaining entries:- (
*a*_{1},*a*_{2}, …,*a*) = (_{n}*a*_{1}, (*a*_{2}, …,*a*_{n-1},*a*n))._{}

- (

Thus, for example, the tuple (3, 5, 3) would be the same as (3,(5,(3,Ø))).

This definition mirrors the most common representation of tuples as linked lists — as used, for example, in standard implementations of the Lisp programming language.

A variant of this definition starts "peeling off" elements from the other end:

- the 0-tuple is the empty set Ø;
- for
*n*> 0,

- (
*a*_{1},*a*_{2}, …,*a*) = ((_{n}*a*_{1},*a*_{2}, …,*a*_{n-1}),*a*n)._{}

Thus, for example, the tuple (3, 5, 3) would be the same as (((Ø,3),5),3).

### Tuples as nested sets

Using ordered pair, the second definition above can be reformulated in terms of pure set theory as:

- the 0-tuple (i.e. the empty tuple) is the empty set Ø;
- if
*x*is an*n-*tuple, and*a*is any element, then { {*x*}, {*x*,*a*} } is an (*n*+ 1)-tuple.

In this formulation, the tuple (3, 5, 3) would be

- { { (3, 5) }, { (3, 5), 3 } } =
- { { { { (3) }, { (3), 5 } } }, { { { (3) }, { (3), 5 } }, 3 } } =
- { { { { { { Ø }, { Ø, 3 } } }, { { { Ø }, { Ø, 3 } }, 5 } } }, { { { { { Ø }, { Ø, 3 } } }, { { { Ø }, { Ø, 3 } }, 5 } }, 3 } }

## Relational model

In database theory, the model extends the definition of a tuple to associate a distinct name with each component.^{[1]} A tuple in the relational model is formally defined as a finite function that maps field names to values, rather than a sequence, so its components may appear in any order. Its purpose is the same as in mathematics, that is, to indicate that an object consists of certain components, but the components are identified by name instead of position, which often leads to a more user-friendly and practical notation, for example:

- ( player : "Harry", score : 25 )

A tuple is usually implemented as a row in a database table, but see relational algebra for means of deriving tuples not physically represented in a table.

## Type theory

In type theory, commonly used in programming languages, a tuple has a product type; this fixes not only the length, but also the underlying types of each component. Formally (x_{1}, ...,x_{n}) : T_{1}×...×T_{n}, and the projections are term constructors π_{1}(x) : T_{1}, ..., π_{n}(x) : T_{n}. The the tuple with labeled elements used in the relational model (see section above) has a record type. Both of these types can be defined as simple extensions of simply typed lambda calculus.^{[2]}

The notion of a tuple in type theory and that in set theory are related in the following way: If we consider the natural model of a type theory, and use the Scott brackets to indicate the semantic interpretation, then the model consists of some sets *T*_{1}, ..., *T*_{n} (note: the use of italics here that distinguishes sets from types) such that T_{1} = *T*_{1}, ..., T_{n} = *T*_{n}, and the interpretation of the basic terms is x_{1} T_{1}, ..., x_{n} T_{n}. The type theory tuple has the natural interpretation as a set theory *n*-tuple: (x_{1}, ...,x_{n}) = (x_{1}, ...,x_{n}).^{[3]} The unit type has as semantic interpretation the 0-tuple.

## See also

Look up in Wiktionary, the free dictionary. tuple |

- Cartesian product
- Relation (mathematics)
- Arity
- Formal language
- Tuplespace
- OLAP: Multidimensional Expressions

## References

- ↑ R Rramakrishnan, J Gehrke.
*Database Management Systems, 3rd edition.*2003. - ↑ Pierce, Benjamin (2002).
*Types and Programming Languages*. MIT Press. 126-132. ISBN 0-262-16209-1. - ↑ Stewe Awody,
*From sets, to types, to categories, to sets*, 2009, preprint

The set theory definitions herein are found in any textbook on the topic, e.g.

- Gaisi Takeuti, W. M. Zaring,
*Introduction to Axiomatic Set Theory*, Springer GTM 1, 1971, ISBN 978-0-387-90024-7, p.14 - Abraham Adolf Fraenkel, Yehoshua Bar-Hillel, Azriel Lévy,
*Foundations of set theory*, Elsevier Studies in Logic Vol. 67, Edition 2, revised, 1973, ISBN 0720422701, p. 33 - Keith Devlin,
*The Joy of Sets*. Springer Verlag, 2nd ed., 1993, ISBN 0-387-94094-4, pp. 7-8 - George J. Tourlakis,
*Lecture Notes in Logic and Set Theory. Volume 2: Set theory*, Cambridge University Press, 2003, ISBN 978-0-521-75374-6, pp. 182-193