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$.
-
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.
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.
-
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