|
|
| Table of contents |
|
2 Formal Definitions 3 Usage in Computer Science |
A tuple of length n is usually described as an n-tuple. A 2-tuple is an ordered pair; a 3-tuple is a triple or triplet. The n can be any positive integer; thus one can for example say that a quaternion can be represented as a 4-tuple, and further constructed names are possible, such as octuple, but many mathematicians find it quicker to write "8-tuple", even if still pronouncing "octuple".
The main properties that disinguish a tuple from, for example, a set are that (1) it can contain an object more than once and (2) the objects appear in a certain order. Note that (1) distinguises it from an ordered set and (2) from a bag. This is often formalized by giving the following rule for the identity of two n-tuples:
Names of Tuples
Formal Definitions
Another way of formalizing tuples is by mapping them to more primitive constructs in set theory such as ordered pairs. For example, an n-tuple can be defined as an ordered pair of an (n-1)-tuple and its last entry:
using the usual set-theoretic definition of an ordered pair this results in the following inductive definition:
In computer science (especially in programming languages and database theory such as the relational model) a tuple is usually defined as a finite function that maps field names to a certain value. It's purpose is the same as in mathematics, namely to indicate that a certain entity or object consists of certain components and/or has certain properties, but here these components are identified by a unique field name and not by a position, which often leads to a more user-friendly notation.
A small example of a tuple would be:
In programming languages tuples are used to form data structures. For example, a structure that represents a node in a doubly linked list could be the following: