Jump to content

Tuple

From Wikipedia, the free encyclopedia

Inmathematics,atupleis a finitesequenceorordered listofnumbersor, more generally,mathematical objects,which are called theelementsof the tuple. Ann-tupleis a tuple ofnelements, wherenis a non-negativeinteger.There is only one 0-tuple, called theempty tuple.A 1-tuple and a 2-tuple are commonly called asingletonand anordered pair,respectively.

Tuples may be formally defined from ordered pairs byrecurrenceby starting fromordered pairs;indeed, ann-tuple can be identified with the ordered pair of its(n− 1)first elements and itsnth element.

Tuples are usually written by listing the elements within parentheses "( )",separated by a comma and a space; for example,(2, 7, 4, 1, 7)denotes a 5-tuple. Sometimes other symbols are used to surround the elements, such as square brackets "[ ]" or angle brackets "⟨ ⟩". Braces "{ }" are used to specifyarraysin some programming languages but not in mathematical expressions, as they are the standard notation forsets.The termtuplecan often occur when discussing other mathematical objects, such asvectors.

Incomputer science,tuples come in many forms. Most typedfunctional programminglanguages implement tuples directly asproduct types,[1]tightly associated withalgebraic data types,pattern matching,anddestructuring assignment.[2]Many programming languages offer an alternative to tuples, known asrecord types,featuring unordered elements accessed by label.[3]A few programming languages combine ordered tuple product types and unordered record types into a single construct, as inC structsand Haskell records.Relational databasesmay formally identify theirrows(records) astuples.

Tuples also occur inrelational algebra;when programming thesemantic webwith theResource Description Framework(RDF); inlinguistics;[4]and inphilosophy.[5]

Etymology[edit]

The term originated as an abstraction of the sequence: single, couple/double, triple, quadruple, quintuple, sextuple, septuple, octuple,...,n‑tuple,..., where the prefixes are taken from theLatinnames of the numerals. The unique 0-tuple is called thenull tupleorempty tuple.A 1‑tuple is called asingle(orsingleton), a 2‑tuple is called anordered pairorcouple,and a 3‑tuple is called atriple(ortriplet). The numberncan be any nonnegativeinteger.For example, acomplex numbercan be represented as a 2‑tuple of reals, aquaternioncan be represented as a 4‑tuple, anoctonioncan be represented as an 8‑tuple, and asedenioncan be represented as a 16‑tuple.

Although these uses treat‑upleas the suffix, the original suffix was‑pleas in "triple" (three-fold) or "decuple" (ten‑fold). This originates frommedieval Latinplus(meaning "more" ) related toGreek‑πλοῦς, which replaced the classical and late antique‑plex(meaning "folded" ), as in "duplex".[6][a]

Properties[edit]

The general rule for the identity of twon-tuples is

if and only if.

Thus a tuple has properties that distinguish it from aset:

  1. A tuple may contain multiple instances of the same element, so
    tuple;but set.
  2. Tuple elements are ordered: tuple,but set.
  3. A tuple has a finite number of elements, while a set or amultisetmay have an infinite number of elements.

Definitions[edit]

There are several definitions of tuples that give them the properties described in the previous section.

Tuples as functions[edit]

The-tuple may be identified as theempty function.Forthe-tuplemay be identified with the (surjective)function

withdomain

and withcodomain

that is defined atby

That is,is the function defined by

in which case the equality

necessarily holds.

Tuples as sets of ordered pairs

Functions are commonly identified with theirgraphs,which is a certain set of ordered pairs. Indeed, many authors use graphs as the definition of a function. Using this definition of "function", the above functioncan be defined as:

Tuples as nested ordered pairs[edit]

Another way of modeling tuples in Set Theory is as nestedordered pairs.This approach assumes that the notion of ordered pair has already been defined.

  1. The 0-tuple (i.e. the empty tuple) is represented by the empty set.
  2. Ann-tuple, withn> 0,can be defined as an ordered pair of its first entry and an(n− 1)-tuple (which contains the remaining entries whenn> 1):

This definition can be applied recursively to the(n− 1)-tuple:

Thus, for example:

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

  1. The 0-tuple is the empty set.
  2. Forn> 0:

This definition can be applied recursively:

Thus, for example:

Tuples as nested sets[edit]

UsingKuratowski's representation for an ordered pair,the second definition above can be reformulated in terms of pureset theory:

  1. The 0-tuple (i.e. the empty tuple) is represented by the empty set;
  2. Letbe ann-tuple,and let.Then,.(The right arrow,,could be read as "adjoined with".)

In this formulation:

n-tuples ofm-sets[edit]

Indiscrete mathematics,especiallycombinatoricsand finiteprobability theory,n-tuples arise in the context of various counting problems and are treated more informally as ordered lists of lengthn.[7]n-tuples whose entries come from a set ofmelements are also calledarrangements with repetition,permutations of a multisetand, in some non-English literature,variations with repetition.The number ofn-tuples of anm-set ismn.This follows from the combinatorialrule of product.[8]IfSis a finite set ofcardinalitym,this number is the cardinality of then-foldCartesian powerS×S× ⋯ ×S.Tuples are elements of this product set.

Type theory[edit]

Intype theory,commonly used inprogramming languages,a tuple has aproduct type;this fixes not only the length, but also the underlying types of each component. Formally:

and theprojectionsare term constructors:

The tuple with labeled elements used in therelational modelhas arecord type.Both of these types can be defined as simple extensions of thesimply typed lambda calculus.[9]

The notion of a tuple in type theory and that in set theory are related in the following way: If we consider the naturalmodelof a type theory, and use the Scott brackets to indicate the semantic interpretation, then the model consists of some sets(note: the use of italics here that distinguishes sets from types) such that:

and the interpretation of the basic terms is:

.

Then-tuple of type theory has the natural interpretation as ann-tuple of set theory:[10]

Theunit typehas as semantic interpretation the 0-tuple.

See also[edit]

Notes[edit]

  1. ^Compare the etymology ofploidy,from the Greek for -fold.

References[edit]

  1. ^"Algebraic data type - HaskellWiki".wiki.haskell.org.
  2. ^"Destructuring assignment".MDN Web Docs.18 April 2023.
  3. ^"Does JavaScript Guarantee Object Property Order?".Stack Overflow.
  4. ^Matthews, P. H., ed. (January 2007)."N‐tuple".The Concise Oxford Dictionary of Linguistics.Oxford University Press.ISBN9780199202720.Retrieved1 May2015.
  5. ^ Blackburn, Simon(1994). "ordered n-tuple".The Oxford Dictionary of Philosophy.Oxford guidelines quick reference (3 ed.). Oxford: Oxford University Press (published 2016). p. 342.ISBN9780198735304.Retrieved2017-06-30.ordered n-tuple[:] A generalization of the notion of an [...] ordered pair to sequences of n objects.
  6. ^OED,s.v."triple", "quadruple", "quintuple", "decuple"
  7. ^D'Angelo & West 2000,p. 9
  8. ^D'Angelo & West 2000,p. 101
  9. ^Pierce, Benjamin (2002).Types and Programming Languages.MIT Press. pp.126–132.ISBN0-262-16209-1.
  10. ^Steve Awodey,From sets, to types, to categories, to sets,2009,preprint

Sources[edit]

External links[edit]

  • The dictionary definition oftupleat Wiktionary