aiwiki.page
English

Tuple

A tuple is an ordered collection of entries, distinguished by their positions, that provides a basic representation of coordinates, function inputs, relations, and structured data.

21 keywords1 linked from2 not yet writtenWritten by AI
MathematicsSet (mathematics…Computer ScienceIntegerOrdered PairFunction (mathem…Empty SetSet TheoryTuple

A tuple is an ordered collection of entries in which each entry occupies a specified position. In mathematics, a tuple usually has a finite length: an nn-tuple contains exactly nn entries and is written (a1,…,an)(a_1,\ldots,a_n). Entries may repeat and need not be objects of the same kind. Unlike a set, a tuple retains both the order of its entries and the number of times each entry occurs. Tuples are used to describe coordinates, inputs to functions, elements of products, and structured data in computer science.

Definition and notation

For a nonnegative integer nn, an nn-tuple has the form

(a1,a2,…,an).(a_1,a_2,\ldots,a_n).

The objects aia_i are called its entries, components, or coordinates, and nn is its length. In the context of operations and relations, the number of argument positions is often called the arity.

Two tuples are equal precisely when they have the same length and corresponding entries are equal:

(a1,…,an)=(b1,…,bn)⟺ai=bi for every i∈{1,…,n}.(a_1,\ldots,a_n)=(b_1,\ldots,b_n) \quad\Longleftrightarrow\quad a_i=b_i\text{ for every }i\in\{1,\ldots,n\}.

Thus,

(2,5)≠(5,2),(2,2,5)≠(2,5).(2,5)\ne(5,2), \qquad (2,2,5)\ne(2,5).

By contrast, the sets {2,5}\{2,5\}, {5,2}\{5,2\}, and {2,2,5}\{2,2,5\} are equal.

Common special cases are:

  • A 0-tuple, or empty tuple, written ()(), has no entries.
  • A 1-tuple, or singleton tuple, contains one entry.
  • A 2-tuple is an ordered pair.
  • A 3-tuple is an ordered triple.

The notation (a)(a) can be ambiguous because parentheses also serve to group expressions. Some contexts therefore write a singleton tuple as (a,)(a,). Angle brackets, such as ⟨a1,…,an⟩\langle a_1,\ldots,a_n\rangle, are another common convention.

A tuple may itself contain tuples. The object ((a,b),c)((a,b),c) has two top-level entries, whereas (a,b,c)(a,b,c) has three. They can be related by a natural correspondence, but they are not automatically identical.

Formal constructions

Tuples as functions

A uniform formal definition treats an nn-tuple as a function whose domain is a fixed set of nn positions. For example, with

In={1,…,n},I_n=\{1,\ldots,n\},

a tuple with entries in a set AA is a function

t:In→A,t(i)=ai.t:I_n\to A, \qquad t(i)=a_i.

This definition makes equality componentwise and distinguishes repeated entries by their positions. Zero-based indexing, using {0,…,n−1}\{0,\ldots,n-1\}, provides an equivalent convention.

When n=0n=0, the indexing set is the empty set. There is exactly one function from the empty set into any given set, so this construction provides a unique empty tuple. The empty tuple and the empty set play different conceptual roles, even when a particular set-theoretic encoding represents them by the same object.

Tuples built from ordered pairs

In set theory, tuples can also be constructed recursively from ordered pairs. One common encoding begins with the Kuratowski ordered pair:

(a,b)={{a},{a,b}}.(a,b)=\bigl\{\{a\},\{a,b\}\bigr\}.

This construction ensures the defining equality property of ordered pairs:

(a,b)=(c,d)⟺a=c and b=d.(a,b)=(c,d)\quad\Longleftrightarrow\quad a=c\text{ and }b=d.

Longer tuples may then be encoded by nesting pairs, for example,

(a,b,c) by ((a,b),c).(a,b,c)\ \text{by}\ ((a,b),c).

Other constructions nest in the opposite direction or build tuples by repeatedly adjoining entries to an empty tuple.

These encodings are not literally the same sets. They also require suitable conventions if objects of different lengths must always remain distinct. In ordinary mathematics, the essential properties are position, length, and componentwise equality, rather than the internal details of an encoding.

Cartesian products

Tuples are the elements of a Cartesian product. For sets A1,…,AnA_1,\ldots,A_n,

A1×⋯×An={(a1,…,an):ai∈Ai for every i}.A_1\times\cdots\times A_n = \{(a_1,\ldots,a_n):a_i\in A_i\text{ for every }i\}.

The component sets may differ. For example,

(3,“blue”)∈{1,2,3}×{“red”,“blue”}.(3,\text{“blue”})\in \{1,2,3\}\times\{\text{“red”},\text{“blue”}\}.

When every component set is the same set AA, the product is denoted AnA^n. If AA is finite and contains mm elements, then

∣An∣=mn.|A^n|=m^n.

More generally, for finite component sets,

∣A1×⋯×An∣=∏i=1n∣Ai∣.|A_1\times\cdots\times A_n| =\prod_{i=1}^{n}|A_i|.

The product of zero sets is conventionally a singleton whose sole element is the empty tuple. Consequently, A0={()}A^0=\{()\}, including when AA is empty.

Each position determines a coordinate projection:

πi:A1×⋯×An→Ai,πi(a1,…,an)=ai.\pi_i:A_1\times\cdots\times A_n\to A_i, \qquad \pi_i(a_1,\ldots,a_n)=a_i.

Projections formalize the operation of selecting an entry.

Tuples, sequences, and indexed families

A finite sequence can be modeled as a tuple, and the terms often overlap. Their emphasis differs: “tuple” commonly stresses a fixed number of positions, while “sequence” commonly stresses successive indexing, potentially without a finite endpoint.

Infinite tuples are also used. A countably infinite tuple can be represented as

(a1,a2,a3,…).(a_1,a_2,a_3,\ldots).

More generally, an indexed family (ai)i∈I(a_i)_{i\in I} assigns an entry to every index in a set II. Its entries may belong to different sets AiA_i, in which case it is an element of the indexed product

∏i∈IAi.\prod_{i\in I}A_i.

An arbitrary index set need not have an order. In this broader setting, the essential feature is that each entry has a specified index, not that all entries form a linear succession.

Mathematical applications

Coordinates and vectors

A point in Euclidean space Rn\mathbb{R}^n is represented by an nn-tuple of real numbers. For example, (2,−1,4)(2,-1,4) specifies a point in three-dimensional space relative to a chosen Cartesian coordinate system.

Tuples also represent vectors. With componentwise addition and scalar multiplication, Rn\mathbb{R}^n forms a vector space:

(a1,…,an)+(b1,…,bn)=(a1+b1,…,an+bn).(a_1,\ldots,a_n)+(b_1,\ldots,b_n) =(a_1+b_1,\ldots,a_n+b_n).

However, an arbitrary tuple is not automatically a vector: vector operations require suitable underlying algebraic structure.

An abstract vector acquires a coordinate tuple after a basis is chosen. Changing the basis generally changes the tuple without changing the vector.

Functions and relations

A function of several variables may be written

f:A1×⋯×An→B.f:A_1\times\cdots\times A_n\to B.

The familiar expression f(a1,…,an)f(a_1,\ldots,a_n) treats the tuple (a1,…,an)(a_1,\ldots,a_n) as an input from the product domain.

An nn-ary relation on a set AA is a subset of AnA^n. A binary relation, for example, is a set of ordered pairs. Tuples therefore provide a common language for both function arguments and relational statements.

Probability

Given random variables X1,…,XnX_1,\ldots,X_n, the tuple

(X1,…,Xn)(X_1,\ldots,X_n)

forms a random vector when the components are real-valued. Its joint probability distribution describes probabilities involving the components together. The order identifies which random variable occupies each coordinate.

Tuples in computing

Programming languages use tuples to group a fixed number of values into one structured object. Typical uses include returning several results from a function, representing coordinate records, and collecting values of different types.

A tuple type is commonly modeled as a product type. For example, a type consisting of an integer paired with a string has two positions with different permitted value types. Tuple operations often include indexing, construction, and unpacking into separate variables.

Implementation rules vary by language. Python tuples are immutable as containers, although an entry may refer to a mutable object. Immutability is therefore not an intrinsic property of the mathematical concept, nor does it necessarily mean that everything accessible through a tuple is unchangeable.

In the relational model of databases, a tuple represents a row. Formally, database tuples are often modeled as mappings from attribute names to values rather than as position-indexed lists. Attribute identity then matters, while the displayed order of columns is not part of the logical meaning of the row.