2
$\begingroup$

The sequence $(1,2,3,4)$ can be represented by the set $\left\{\{1\},\{1,2\},\{1,2,3\},\{1,2,3,4\}\right\}$ - it is obvious that it contains all the information required to generate the sequence.

Is there such a set that can represent the non-decreasing sequence $(1,2,2,3,4,4,4)$?

  • 1
    Would $\{1, \{2, \{2, \{3, \{4, \{4, \{4\} \} \} \}\} \}\} $ be acceptable?2017-01-13
  • 0
    Heh, certainly looks like an answer... not sure I can use it for my purposes though. I'm looking for something that will translate well into code...2017-01-13

3 Answers 3

1

For $(1,2,2,3,4,4,4)$:

$\left\{\{(1,1,1)\},\\ \{(1,1,1), (2,2,1)\},\\ \{(1,1,1), (2,2,2)\}, \\ \{(1,1,1), (2,2,2), (3,3,1)\},\\ \{(1,1,1), (2,2,2), (3,3,1), (4,4,1)\}\\ \{(1,1,1), (2,2,2), (3,3,1), (4,4,2)\}\\ \{(1,1,1), (2,2,2), (3,3,1), (4,4,3)\} \right\}$

First positions of triplets determines the index of same-number sequence, the second one - an element generating this sequence, the third one - the length of the sequence.

To show the idea, create a set for $(1,1,2,1,4,4,8)$:

$\left\{ \{(1,1,1)\},\\ \{(1,1,2)\},\\ \{(1,1,2), (2,2,1)\},\\ \{(1,1,2), (2,2,1), (3,1,1)\},\\ \{(1,1,2), (2,2,1), (3,1,1), (4,4,1)\},\\ \{(1,1,2), (2,2,1), (3,1,1), (4,4,2)\},\\ \{(1,1,2), (2,2,1), (3,1,1), (4,4,2), (5,8,1)\} \right\}$

1

Any sequence can be represented as a set just by creating a set of pairs, where each pair contains an element of the sequence along with its position in the sequence:

$$ \{(0,1) (1,2) (2,2) (3,3) (4,4) (5,4) (6,4)\} $$

where we use the Kuratowski encoding for pairs $(a,b) = \{a, \{a,b\}\}$, so the set is:

$$ \{\{0, \{0,1\}\}, \{1, \{1,2\}\}, \{2, \{2\}\} \dots \{6, \{6, 4\}\} \} $$

The Kuratowski encoding can also be used for $n$-tuples for any $n$, so if your sequence is finite you can actually create a set with just a single $n$-tuple, although it's a bit of a complex set to write and I'll leave as an exercise to the reader.

  • 1
    It is not trivial to extend Kuratowski directly to longer tuples: naively attempting to say $(a,b,c)=\{\{a\},\{a,b\},\{a,b,c\}\}$ leads to the problem that, for example, $(1,2,2)$ and $(1,1,2)$ both have the same representation. But if you always know the length of your tuple, you can of course use $(a,b,c)=(a,(b,c))$.2017-01-13
1

The usual way to represent finite sequences of variable length in set theory is to work with functions from $\{0,1,\ldots,n-1\}$ to the elements of the sequence.

So your sequence $(1,2,2,3,4,4,4)$ would be represented by $$ \{(0,1),(1,2),(2,2),(3,3),(4,4),(5,4),(6,4)\} $$ (where the ordered pairs would themselves be Kuratowski pairs: $(a,b)=\{\{a\},\{a,b\}\}$).

If this representation is not adequate or convenient for your purposes, you probably need to explain in more details what your requirements are.