From charlesreid1

Line 164: Line 164:


The result of applying this procedure, of skipping between the top and bottom rows, is a set of 1 or more permutation factors. If we continue with the example <math>\pi</math> above, we'll eventually get:
The result of applying this procedure, of skipping between the top and bottom rows, is a set of 1 or more permutation factors. If we continue with the example <math>\pi</math> above, we'll eventually get:
Original:


<math>
<math>
Line 171: Line 173:
\end{smallmatrix}\bigr)
\end{smallmatrix}\bigr)
</math>
</math>
First factor pulled out:


<math>
<math>
Line 184: Line 188:
</math>
</math>


Second and third factors pulled out:
<math>
\pi = \bigl( \begin{smallmatrix}
\pi = \bigl( \begin{smallmatrix}
     a & d & d & b & c & d & b & b & c \\
     a & d & d & b & c & d & b & b & c \\

Revision as of 00:23, 11 January 2018

Permutation Counts

For counting the number of permutations of a Rubik's Cube, see Rubiks Cube/Numbers

Permutation Algebra

In order to create a system for talking about and dealing with permutations, we follow Volume 3 of Knuth's The Art of Computer Programming (see AOCP).

Representation of a Rubik's Cube

The mathematical. representation of a Rubik's Cube is discussed on the Rubiks Cube/Tuple page, but in short, that page concludes that we should represent the Rubik's Cube by using a particular permutation of an n-tuple, where n is the number of faces.

A 3x3 Rubik's Cube state is represented by a particular permutation of the integers 1 to 36. The solved state is (1 2 3 4 ... 35 36).

A 4x4 Rubik's Cube state is represented by a particular permutation of the integers 1 to 96. The solved state is (1 2 3 4 ... 35 36).

Writing a Permutation

Knuth introduces the top-bottom notation for permutations, in which a particular permutation of a sequence of $ n $ integers is written by first writing each element of the sequence in increasing order on the top row, then writing the occurrence of each element in the order it occurs on the bottom row:

$ a = \bigl(\begin{smallmatrix} 1 & 2 & 3 & \cdots & n-1 & n \\ 2 & 3 & 4 & \cdots & n & 1 \end{smallmatrix}\bigr) $

Intercalation Product

We now define an intercalation operation with two permutations; this is basically an operation that interleaves two permutations. We will see why this is useful in a moment.

Suppose we have two permutations, $ \alpha $ and $ \beta $, of four objects $ \{a, b, c, d\} $, each occurring multiple times:

$ \alpha = \bigl(\begin{smallmatrix} a & a & b & c & d \\ c & a & d & a & b \end{smallmatrix}\bigr) $

$ \beta = \bigl(\begin{smallmatrix} a & b & d & d & d \\ b & d & d & a & d \end{smallmatrix}\bigr) $

Then we can define the intercalation product $ \alpha \top \beta $ as the elements of these permutations combined in a way that interleaves elements of both, in a way that groups all elements by the letter on the top row, but sorts within those letters according to the original order in $ \alpha $ and $ \beta $. For our example:

$ \alpha \top \beta = \bigl(\begin{smallmatrix} a & a & b & c & d \\ c & a & d & a & b \end{smallmatrix}\bigr) \top \bigl(\begin{smallmatrix} a & b & d & d & d \\ b & d & d & a & d \end{smallmatrix}\bigr) = \bigl(\begin{smallmatrix} a & a & a & b & b & c & d & d & d & d \\ c & a & b & d & d & a & b & d & a & d \end{smallmatrix}\bigr) = $

This is basically an interleaving operation. All top-bottom pairs with $ a $ at the top are grouped together; all from $ \alpha $ come first, and all from $ \beta $ come second.

The first two $ a $ items in $ \alpha \top \beta $ come from $ \alpha $, the third $ a $ item comes from $ \beta $.

Etc.

Properties of Intercalation

Before using the intercalation product, let's define a few properties :

  • If $ \alpha \top \pi = \beta \top \pi $ or $ \pi \top \alpha = \pi \top \beta $ this implies $ \alpha = \beta $
  • Identity element exists such that $ \epsilon \top \alpha = \alpha \top \epsilon = \alpha $
  • Commutative property only holds if $ \alpha $ independent of $ \beta $; then $ \alpha \top \beta = \beta \top \alpha $. This property does not hold in general.

Cycles and Intercalation

Cycles are elements that are swapped in some prescribed way. For example, suppose we have a sequence,

$ \bigl(\begin{smallmatrix} x_1 & x_2 & \dots & x_n \end{smallmatrix}\bigr) $

and further suppose that we shift this sequence to the left by one element, and write in the two line notation:

$ \bigl(\begin{smallmatrix} x_1 & x_2 & \dots & x_{n-1} & x_n \\ x_2 & x_3 & \dots & x_{n} & x_1 \end{smallmatrix}\bigr) $

We can observe that the product of disjoint cycles is the same as their intercalation.

Now we have a full "product" permutation.

Factoring Permutations

An Example

Suppose we have a permutation:

$ \pi = \bigl(\begin{smallmatrix} a & a & b & b & b & b & b & c & c & c & d & d & d & d & d \\ d & b & c & b & c & a & c & d & a & d & d & b & b & b & d \end{smallmatrix}\bigr) $

and suppose that we want to "factor" the permutation - that is, to write the permutation as the intercalation product of independent, disjoint cycles $ \pi = \alpha \top \beta \top \dots \top \gamma $.

Assembling Factors

We can assemble each factor one at a time using the following algorithm:

Start by supposing that the first factor $ \alpha $ contains the first symbol $ a $. If this assumption is true, then $ \alpha $ must map $ a $ to the same thing that the final permutation maps $ a $ to, namely, the first column of $ \pi $, which is the combination $ \begin{smallmatrix} a \\ d \end{smallmatrix} $. This means that the first entry in $ \alpha $ must turn $ a $ into $ d $.

Now we suppose that $ \alpha $ contains $ d $, as a consequence of the prior step. Let's find the leftmost $ d $ in the top line, and see what symbol it will map to. It maps to b. This means that the first entry in $ \alpha $ must turn $ d $ into $ d $ and should therefore contain $ \begin{smallmatrix} d \\ d \end{smallmatrix} $

Now we start with the outcome of the previous step, which is another $ d $. Since we already used the first d-d pairing, we look for the second leftmost d, which is part of the combination/mapping $ \begin{smallmatrix} d \\ b \end{smallmatrix} $. This implies the mapping d-b should be in $ \alpha $, and we use the mapping outcome b as the starting point for the next step.

If we keep doing this, eventually we will get:

$ \alpha = \bigl(\begin{smallmatrix} a & d & d & b & c & d & b & b & c \\ d & d & b & c & d & b & b & c & a \end{smallmatrix}\bigr) $

Why Does This Work

Let's pause for a moment and see what's happening. What we're doing is following a thread between the top and bottom rows of the permutation; this thread tells us how elements are being moved around to create permutations.

(A simpler but easier way to see this is by comparing two permutations of 1 2 3 4 5 6: consider the permutation 2 1 3 4 6 5, versus the permutation 2 4 5 6 1 3. The first permutation swaps positions 0 and 1, and positions 4 and 5, independently; the second permutation mixes all positions together.)

We are assembling $ \alpha $ piece by piece, by pulling out pairs from the top and bottom row of $ \pi $ and putting them into $ \alpha $. At some point we will come back to the starting point, the symbol $ a $, and we will be finished finding the first factor $ \alpha $, which is a disjoint cycle.

By starting from the top row and following where it leads in the bottom row, and continuing until we return to the original starting element in the top row, we can carve up the permutation into groups of pieces exchanged with one another and not with any other pieces, or groups of pieces that don't move.

Forming All Factors

We then continue the process of assembling factors from what is left of $ \pi $. (Note that if $ \pi $ is prime, every element of $ \pi $ will appear in $ \alpha $ and there will be no further products.) Eventually we will have a number of factors,

$ \pi = \alpha \top \beta \top \dots \top \gamma $

The result of applying this procedure, of skipping between the top and bottom rows, is a set of 1 or more permutation factors. If we continue with the example $ \pi $ above, we'll eventually get:

Original:

$ \pi = \bigl( \begin{smallmatrix} a & a & b & b & b & b & b & c & c & c & d & d & d & d & d \\ d & b & c & b & c & a & c & d & a & d & d & b & b & b & d \end{smallmatrix}\bigr) $

First factor pulled out:

$ \pi = \bigl( \begin{smallmatrix} a & d & d & b & c & d & b & b & c \\ d & d & b & c & d & b & b & c & a \end{smallmatrix} \bigr) \top \bigl( \begin{smallmatrix} a & b & b & c & d & d \\ b & a & c & d & b & d \end{smallmatrix} \bigr) $

Second and third factors pulled out:

$ \pi = \bigl( \begin{smallmatrix} a & d & d & b & c & d & b & b & c \\ d & d & b & c & d & b & b & c & a \end{smallmatrix} \bigr) \top \bigl( \begin{smallmatrix} a & b \\ b & a \end{smallmatrix} \bigr) \top \bigl( \begin{smallmatrix} b & c & d & d \\ c & d & b & d \end{smallmatrix} \bigr) $

Permutation Factoring

Flags