Permutation notation

This article examines different notations for the composition of permutations with each other and with vectors.

Permutations are bijections from a set to itself, and the set does not need to have an order. They can also be described as operations that move things from one set of places to another set of places — which is the natural mental image when the permutation is, e.g., a rotation of a cube. In the end it does not matter what kind of mental image is used to understand what a permutation is or does, as long as there is no ambiguity about what result a formula will yield. When a permutation $$\pi$$ is interpreted as moving objects from starting places to other places, there are two ways to describe it.

The usual way is as an active permutation or map or substitution:
 * $$\pi$$ moves an object from place $$i$$ to place $$\pi(i)$$. In an arrow diagram, the one-line notation denotes where the arrows go.
 * In this case, the result of applying $$\pi$$ to a vector $$(x_1,\dots,x_n)$$ is $$(x_{\pi^{-1}(1)},\dots,x_{\pi^{-1}(n)})$$.

$$\pi$$ may also be represented as the result of applying it to the natural order. This is called a passive permutation or (re)arrangement or ordering:
 * $$\pi$$ replaces an object in position $$i$$ by that in position $$\pi(i)$$. In an arrow diagram, the one-line notation denotes where the arrows come from.
 * In this case the result of applying $$\pi$$ to a vector $$(x_1,\dots,x_n)$$ is $$(x_{\pi(1)},\dots,x_{\pi(n)})$$.

Confusing these two interpretations will lead to confusing permutations with their inverses. Active and passive transformations seem to be a related concept.

Composition of permutations is associative, but not commutative.

With prefix notation or left action, $$\pi \sigma(x) = \pi \bigl(\sigma(x)\bigr)$$.
 * $$\pi \sigma$$ can be thought of as $$\pi ~ {\scriptstyle after} ~ \sigma$$, and $$\pi x$$ as $$\pi ~ {\scriptstyle of} ~ x$$
 * This notation corresponds to the usual way of writing function compositions.

With postfix notation or right action, $$\pi \sigma(x) = x \pi \sigma = \sigma \bigl(\pi(x)\bigr)$$.
 * $$\pi \sigma$$ can be thought of as $$\pi ~ {\scriptstyle before} ~ \sigma$$, and $$x \pi$$ as (image of) $$x ~ {\scriptstyle under} ~ \pi$$.
 * This notation is common in group theory.
 * (In the Python examples in this article  =   =  . The result is   = 4).

In its graphics this article shows all possible interpretations, including the passive ones. To avoid confusion, however, the accompanying calculations use only active right notation, which is the notation used by SymPy and Wolfram.

Notations
$$\alpha = \begin{pmatrix} 1 & 2 & 3 \\ 3 & 1 & 2 \end{pmatrix}, ~ \beta = \begin{pmatrix} 1 & 2 & 3 \\ 2 & 1 & 3 \end{pmatrix}, ~ v = (v_1, v_2, v_3), \alpha^{-1} = \begin{pmatrix} 1 & 2 & 3 \\ 2 & 3 & 1 \end{pmatrix}$$

Active
If permuting $$v$$ by $$\alpha$$ gives $$(v_{\alpha^{-1}(1)}, v_{\alpha^{-1}(2)}, v_{\alpha^{-1}(3)}) = (v_2, v_3, v_1)$$ the permutation is active.

Passive
If permuting $$v$$ by $$\alpha$$ gives $$(v_{\alpha(1)}, v_{\alpha(2)}, v_{\alpha(3)}) = (v_3, v_1, v_2)$$ the permutation is passive.

Passive left should be seen as a misunderstanding of active right, and passive right should be seen as a misunderstanding of active left. *

*  (Unless permuting a vector proofs otherwise.)

Examples with 5-element permutations
Permutations can be combined with
 * other permutations (boxes 1 to 11)
 * vectors of the same length with arbitrary elements (green boxes 12 and 16)
 * vectors of arbitrary length with elements from the same range, i.e., maps with the same codomain as the permutation, but bijectivity is not required (blue boxes 14 and 15)
 * scalars from the same range (red boxes 13 and 17, compare blue box 14)

The variables used in the main examples are
 * the permutations $$P = \begin{pmatrix} 0 & 1 & 2 & 3 & 4 \\ 1 & 3 & 0 & 2 & 4 \end{pmatrix} = (0132)$$ and $$Q = \begin{pmatrix} 0 & 1 & 2 & 3 & 4 \\ 4 & 3 & 2 & 1 & 0 \end{pmatrix} = (04)(13)$$
 * the vector $$V = (V_0, \dots, V_4)$$ (in the graphics simply $$0 \dots 4$$)
 * the vector $$E = (0, 0, 4, 2, 3, 2)$$

In the Wolfram calculations, the 1-based equivalents are used.

Permutations of four elements are identified by their index numbers in RevCoLex order, i.e., as the $$n$$-th finite permutation. $$P = (0 1 3 2)$$ is denoted $$\mathit{10}$$ where it appears among other permutations of only four elements. (See box 19, compare with box 1.) (Equivalents for the permutations of five elements would be $$Q = \mathit{119}$$, $$R = \mathit{109}$$ and $$S = \mathit{83}$$, but only the letters are used.)

Active vs. passive
A simple rule to avoid passive permutations: If the rows of a permutation matrix are labelled, the cycles must go clockwise (AR ). If the columns are labelled, the cycles must go anticlockwise (AL ).

Left vs. right
The following examples show with arrow diagrams what the composed permutations actually do, and how this can be interpreted as a product in two different ways, corresponding to two different matrix multiplications.

The two arrangements of matrices are symmetric to each other, including the direction of the arrows in the matrices. In other terms: The matrix image on the left and on the right show exactly the same thing in a different way. The arrows in both arrangements of matrices are the same as in the arrow diagram to their left.

In prefix notation (left action) $$\alpha \cdot \beta$$ means $$\alpha ~ {\scriptstyle after} ~ \beta$$. In postfix notation (right action) $$\beta \cdot \alpha$$ means $$\beta ~ {\scriptstyle before} ~ \alpha$$. Obviously $$\alpha ~ {\scriptstyle after} ~ \beta$$ and $$\beta ~ {\scriptstyle before} ~ \alpha$$ are just different ways to say the same thing.

Examples with permutations of the square
The dihedral group Dih4 is the group of symmetries of the square. It has 8 elements and is not abelian - therefore order of operation matters.

Active right (Cayley tables)
In Cayley graphs postfix notation is common. One may find it more natural here, because this way the product read from left to right corresponds to the path from the identity vertex to the vertex of the permutation. (E.g. the path from $$e$$ to $$ab$$ in the example below is first through the arrow $$a$$ and then through the edge $$b$$.) A source that uses this convention is Visual Group Theory by Nathan Carter.

Active left (linear maps)
This section uses prefix notation, because here the permutations are connected to 2×2 signed permutation matrices describing s. E.g. the matrices of $$\mathit{10}$$, $$\mathit{13}$$ and $$\mathit{23}$$ are rotation matrices. Linear maps and their matrices are usually concatenated like funcions, i.e. in prefix notation.

Wolfram
Wolfram Alpha displays permutations in a way that resembles PL representation in this article, which – if only permutation concatenation is concerned – is the same as AR. (See boxes 1 and 19.)

$$P$$ is shown as $$\begin{pmatrix} 1 & 2 & 3 & 4 & 5 \\ 2 & 4 & 1 & 3 & 5 \end{pmatrix} = (1243)$$, but in the arrow diagram and the permutation matrix the arrow from 1 goes to 3 — not to 2.

Wolfram does not accept the element 0, so the examples are converted to 1-based permutations: P = (1243)(5)  = 2 4 1 3 5  http://www.wolframalpha.com/input/?i=permutation+(1+2+4+3)(5) Q = (15)(24)(3) = 5 4 3 2 1 http://www.wolframalpha.com/input/?i=permutation+(1+5)(2+4)(3) R = (1435)(2)  = 4 2 5 3 1  http://www.wolframalpha.com/input/?i=permutation+(1+4+3+5)(2) S = (1523)(4)  = 5 3 1 4 2  http://www.wolframalpha.com/input/?i=permutation+(1+5+2+3)(4)

A blogpost from 2011 shows that back then the list notation with curly braces was the inverse of the one-line notation. But in the calculations shown in this article (done in Mathematica Online in December 2016) the permutation  corresponds to. Apparently in the meantime a notation people found confusing was dropped in favour of a more mainstream one.

This article uses three binary Wolfram functions:

PermutationProduct[a, b, c] gives the product of permutations a, b, c. (box 5b)

PermutationReplace[expr, perm] replaces each part in expr by its image under the permutation perm. (boxes 13a, 15a, 17a)

Permute[l, p] permutes list l according to permutation p. (boxes 12a, 16a)

SymPy
http://docs.sympy.org/dev/modules/combinatorics/permutations.html

The composite of two permutations p*q means first apply p, then q, so i^(p*q) = (i^p)^q which is i^p^q according to Python precedence rules.

SymPy has two operators for permutations: Multiplication and what could be called exponentiation. The latter seems to be intended only to access elements of a permutation, but can be used to combine two combinations. The result of  is the same as   (see Python script), which is a permutation in the same conjugacy class.

Aigner 2007
We read a product always from right to left, thus for
 * $$\sigma = \begin{pmatrix} 1 & 2 & 3 & 4 & 5 & 6 \\ 2 & 3 & 4 & 1 & 6 & 5 \end{pmatrix}$$,  $$\tau = \begin{pmatrix} 1 & 2 & 3 & 4 & 5 & 6 \\ 1 & 3 & 4 & 5 & 2 & 6 \end{pmatrix}$$,

we have
 * $$\tau \sigma = \begin{pmatrix} 1 & 2 & 3 & 4 & 5 & 6 \\ 3 & 4 & 5 & 1 & 6 & 2 \end{pmatrix}$$  and   $$\sigma \tau = \begin{pmatrix} 1 & 2 & 3 & 4 & 5 & 6 \\ 2 & 4 & 1 & 6 & 3 & 5 \end{pmatrix}$$.

We call $$\sigma = \sigma(1) \sigma(2) \dots \sigma(n)$$ the word representation of $$\sigma$$.

— Word Representation (p. 27 ff)

Knuth 1973
In TAoCP Knuth states that in his book permutations are always multiplied from left to right, and gives the following example:

$$\alpha \beta =\begin{pmatrix}0 & 1 & 2 & 3 & 4 & 5 \\ 2 & 5 & 0 & 1 & 4 & 3 \end{pmatrix}\begin{pmatrix}0 & 1 & 2 & 3 & 4 & 5 \\5 & 4 & 3 & 2 & 1 & 0 \end{pmatrix} = \begin{pmatrix}0 & 1 & 2 & 3 & 4 & 5 \\ 2 & 5 & 0 & 1 & 4 & 3 \end{pmatrix} \begin{pmatrix}2 & 5 & 0 & 1 & 4 & 3 \\3 & 0 & 5 & 4 & 1 & 2 \end{pmatrix} = \begin{pmatrix}0 & 1 & 2 & 3 & 4 & 5 \\3 & 0 & 5 & 4 & 1 & 2 \end{pmatrix}$$

$$\alpha \beta = (0 2)(1 5 3) \cdot (0 5)(1 4)(2 3) = (0 3 4 1)(2 5)$$

The left permutation sees the argument first:

Notice that the image of 1 under $$\alpha \beta$$ is $$1(\alpha \beta) = (1 \alpha) \beta = 5 \beta = 0$$, etc. SymPy:  =   = 0

This is not to be confused with right to left multiplication of permutations, i.e. the way functions are composed:

[...] traditional functional notation, in which one writes $$\alpha(1) = 5$$, makes it natural to think that $$\alpha \beta(1)$$ should mean $$\alpha(\beta(1)) = \alpha(4) = 4$$. SymPy:  =   = 4

— Chapter 7.2.1.2. Generating all permutations

Cameron 1994
Cameron decribes the active form of a permutation as a one-to-one mapping from $$X = \{x_1,\dots,x_n\}$$ to itself, and the passive form as the ordered n-tuple $$\bigl(\pi(x_1),\dots,\pi(x_n)\bigr)$$. I wrote $$\pi(x)$$ for the result of applying the function $$\pi$$ to the element $$x$$. [...] In order that the result of applying first $$\pi_1$$ and then $$\pi_2$$ can be called $$\pi_1 \pi_2$$, it is more natural to denote the image of $$x$$ under $$\pi$$ as $$x \pi$$. [Footnote:] We say that permutations act on the right if they compose according to this rule.

What Cameron calls the passive permutation is simply the one-line or word representation of an (active) permutation, not a passive permutation in the sense of this article.

— Chapter 3.5 Permutations (p. 29)

Grimaldi 2004


Grimaldi defines $$\pi_1 = \begin{pmatrix} 1 & 2 & 3 \\ 3 & 1 & 2 \end{pmatrix}$$ as the left rotation of a triangle and $$r_1 = \begin{pmatrix} 1 & 2 & 3 \\ 2 & 1 & 3 \end{pmatrix}$$ as the reflection that leaves the right base angle in place. Their product $$\pi_1 r_1 = \begin{pmatrix} 1 & 2 & 3 \\ 3 & 2 & 1 \end{pmatrix} = r_3$$ is the reflection about the vertical axis.

— Example 16.7 (p.749)

