Both are ordered collections that can have repeated elements. Is there a difference? Are there other terms that are used for similar concepts, and how are these terms different?
What's the difference between tuples and sequences?
8 Answers
A sequence requires each element to be of the same type.
A tuple can have elements with different types.
You can compare it with arrays and structs in C (respectively).
For example, let's consider the DFA $(Q,F,s,\delta,\Sigma)$ quintuple. It's a tuple with the full set of states $Q$; a set of final states $F$; a starting state $s$; the state transition function $\delta$ and the alphabet $\Sigma$.
-
0Is this by definition, or by convention? – 2012-03-21
-
1One definition of an infinite sequence is as a function from $\mathbb N$ to some target space $X$, hence every element must live in the space $X$. – 2012-03-21
-
0This is customary usage, not part of a formal definition. But it's practically forced on us by the purposes for which tuples are used. I'm thinking of a statistical data set in which each data point is a tuple in which the first component is a person's height, the second his weight, the third his income, the fourth his SAT scores, etc. The components are not measured in the same units as each other. Each data point is a tuple. – 2012-03-21
-
0dls, but couldn't you just expand space X to include all the kinds of elements you would put in any slot? – 2012-03-22
-
0ratchet freak, couldn't you say that a sequence is a special kind of tuple? – 2012-03-22
-
3@ratchetfreak: Your explanation with respect to *types* seems to be computer language centered. Do you also have a *mathematical concept* of the term *type* in mind when distinguishing between *same type* and *different types*? Maybe you could add a helpful statement in your answer. – 2015-06-15
-
0In case anyone didn't know: https://en.wikipedia.org/wiki/Deterministic_finite_automaton – 2018-07-22
A tuple is usually finite, a sequence usually infinite, but these are not hard restrictions.
-
0By convention, I assume. – 2012-03-21
Using a basic set theoretic definition, a tuple (a, b, c, ..) represents an element of the Cartesian product of sets A x B x C ...
In a vector space the tuple represents the components of a vector in terms of basis vectors.
A sequence on the other hand represents a function (usually of the natural numbers) to some set A, and strictly speaking a sequence is then a subset of N x A.
For numeric sequences, It makes sense to consider whether they are convergent. One could add the elements of a numeric sequence to get a series and consider if the corresponding series is convergent. I can't think of any equivalent concept for tuples even when they comprise numeric values.
-
0This explanation jibes well with how these concepts are taught at Ohio State. – 2017-03-20
The difference seems to be:
- A psychological difference: people often think about the concepts differently.
- A difference in the way people encode these when reducing everything to set theory. This is probably never a useful thing to do except when what you're doing is set theory.
Revised version six years later: In a sequence, the linear order in which things appear is essential information. In a tuple, the roles played by the different components are what is essential.
Thus at tuple may specify: longitude, latitude, point in time, temperature, humidity, barometric pressure. You could list the numbers in a different order and correspondingly list the those labels in a different order, and you'd still have the same tuple, but not the same sequence.
-
0Could you expand on both differences? How do people tend to think of tuples that is different than how they think of sequences (is ratchet freak's answer an example of that)? How do people encode tuples and sequences using sets (Wikipedia is silent about sequences)? – 2012-03-20
-
1I agree with ratchet freak. – 2012-03-21
-
0What you are saying here is basically a verification that they indeed are different, and even though you give examples of in what cases they differ, you still don't explain _how_ they differ, which is what I think the question aims at. If you would explain how they differ, that is, how people think about the two concepts (and why these differ), and how people encode them when reducing everything to set theory (and why these differ), your answer would be a lot more satisfying. – 2014-01-04
To make your life easier...just use the widely accepted difference that tuples are finite sequences. So whenever your sequence has a finite number of elements, consider it a tuple! Otherwise it is just a sequence. For me that is the distinction that I have safely used over the years....and still use!
-
0Velcome to the site! – 2014-05-13
A sequence is a kind of tuple whose elements are all of the same type —http://christian.heinleins.net/apples/sequ
I think this is a nice answer, sequence and tuple are not exclusive.
There is no established convention. If you attribute a property to a sequence only, you might always find some authors in some book enlisting that property for the tuples too.
However, a sequence is any function whose domain, said the index set, is an ordered set and whose values, said terms, are denoted $f_n$ rather than $f(n)$. The index set is typically $\mathbb{N}$, but may be also $\mathbb{Z}$ or an interval of $\mathbb{Z}$.
A tuple can be thought as a sequence whose index set is finite. This set is often $\{1,\ldots,n\}$, but it can be $\{m,\ldots,n\}$ too, where $m,n\in \mathbb{Z}$ and $m However, tuple definitions can also have structural differences with sequences. For example they can be thought in terms of nested ordered pairs rather than as a function. If encoding tuples as finite sequences, you may write the triple:
$$
\langle x_1,x_2,x_3 \rangle = \{(1, x_1),(2, x_2),(3, x_3)\}
$$
where $(a,b)$ denotes an ordered pair. For a nested tuple (using left associativity), you have:
$$
\langle x_1,x_2,x_3 \rangle = \big((x_1, x_2), x_3\big)
$$
Note that there is no index set here. This form is strictly related to Cartesian products and you can think of it as an element of the set: $X_1\times X_2\times X_3=(X_1\times X_2)\times X_3$.
The tuple itself can be represented in terms of a Cartesian product:
$$
\langle x_1,x_2,x_3 \rangle = \{x_1\}\times \{x_2\}\times \{x_3\}
$$
Sequences' elements are indexed with natural numbers N.
Tuples' elements are indexed with positive integers N*.
Sequence is use to define relations in general
(i.e. where the cardinality of arbitrary sets is not clearly identified).
Tuple is use to define finitary relations in particular
(i.e. where the cardinality of finite sets can be directly identified).
"While the cardinality of a finite set is just the number of its elements, extending the notion to infinite sets usually starts with defining the notion of comparison of arbitrary (in particular infinite) sets." From Wikipedia, the free encyclopedia.
-
0The first set of assertions is wrong in my experience. Most mathematical literature that I've seen starts indexing from $1$ for both "sequences" and "tuples". Those with a computer science bent and those who like to use the set-theoretic definition of the non-negative integers might prefer to start from $0$ for both, not just for sequences. I don't know what the second set of assertions is supposed to mean. And the Wiki quote is irrelevant. – 2015-06-14
-
0Tuples are sequences starting from 1. – 2015-06-14
-
0Sequences starting at 0 are not Tuples but simply sequences. – 2015-06-14
-
0[Here](http://courses.umass.edu/phil595s-gmh/pdf/set%20theory/Set-Theory-Chap0.pdf) (go to Section 28, "K-Tuples; Finite Sequences"), [here](https://books.google.com/books?id=pf0Rmrv-eDYC&lpg=PA41&ots=WSviT3Foqz&dq=tuple&pg=PA41#v=onepage&q=tuple&f=false) and [here](http://settheory.net/set2.pdf) we have tuples starting from 0. And https://en.wikipedia.org/wiki/Sequence#Indexing states "Sequences can be indexed beginning and ending from any integer." – 2015-06-14
-
0"Sequences can be indexed beginning and ending from any integer." This is true for Sequences not for Tuples. Starting Tuples from 0 or 1 is a user's choice - I prefer starting tuples from 1 since the "size" is directly given from the number k for a k-tuple. – 2015-06-14