Recall that we number positions in permutations starting from 0,
but the $n$-permutations consist of numbers from $\{1,2,\ldots,n\}$.
We have $\alpha_3=12121$ and the generation of $\{1,2,3\}$ is:
$$123\Arrow{1} 213 \Arrow{2} 312\Arrow{1} 132\Arrow{2} 231 \Arrow{1} 321$$
The generation of all 24 permutations of $\{1,2,3,4\}$ has the following structure.
$$1234\Arrow{\alpha_3} 3214\Arrow{3}4123 \Arrow{\alpha_3} 2143\Arrow{3}$$
$$ 3412 \Arrow{\alpha_3} 1432 \Arrow{3} 2341 \Arrow{\alpha_3} 4321$$
Problem 135: The words representing combinatorial generations |
There are many interesting strings related to combinatorial generations, their characteristic feature is usually high compressibility. Here we discuss permutation generations. Usually they produce each successive permutation by applying some kind of a basic operation. The sequence of this operations, corresponding to the permutation ordering, is called the generating sequence. It is treated as a word over the alphabet consisting of names of basic operations. The most interesting are cases when this alphabet is small. We present in detail two generation sequences $\alpha_n,\beta_n$, then in the notes we mention briefly sequences $\gamma$ and $\Phi$. Assume the permutation of numbers $\{1,2,\ldots,n\}$ is stored in the table $\pi$, with positions numbered from zero.
$\alpha_n$ is a generating sequence: starting from the id-permutation $\pi=(\pi_0,\pi_1,\pi_2,\ldots,\pi_{n-1})\,=\, (1,2,\ldots,n),$ and consecutively applying operations from $\alpha_n$ all $n$-permutations are generated, each exactly once.
We consider compression in terms of straight-line programs. A straight-line program, briefly SLP, is a context-free grammar that produces a single word $w$ over a given alphabet $\Sigma$.
An SLP can be also defined as a sequence of recurrences (equations), using operations of concatenation of words. Compression by straight-line programs is also called Grammar-Based Compression.