VOOZH about

URL: https://en.wikiversity.org/wiki/Permutation_notation

⇱ Permutation notation - Wikiversity


Jump to content
From Wikiversity

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 👁 {\displaystyle \pi }
is interpreted as moving objects from starting places to other places, there are two ways to describe it.

Visualisations of 👁 {\displaystyle P}
as an active permutation
Arrow diagram of 👁 {\displaystyle P}
👁 Image
Matrix representations of 👁 {\displaystyle P}
Left (prefix)
👁 {\displaystyle M{\bigl (}\pi (i),i{\bigr )}=1}
Right (postfix)
👁 {\displaystyle M{\bigl (}i,\pi (i){\bigr )}=1}
Map 👁 Image
👁 Image
Cycle 👁 Image
👁 Image

There are two ways to assign a matrix to a permutation, corresponding to the two ways of multiplying permutations.

There are two ways to draw arrows in the chosen matrix, one similar to two-line and the other to cycle notation. (The former is used in the blue boxes 14 and 15, the latter in the rest of the article.)

The usual way is as an active permutation or map or substitution:

👁 {\displaystyle \pi }
moves an object from place 👁 {\displaystyle i}
to place 👁 {\displaystyle \pi (i)}
. In an arrow diagram, the one-line notation denotes where the arrows go.
In this case, the result of applying 👁 {\displaystyle \pi }
to a vector 👁 {\displaystyle (x_{1},\dots ,x_{n})}
is 👁 {\displaystyle (x_{\pi ^{-1}(1)},\dots ,x_{\pi ^{-1}(n)})}
.

👁 {\displaystyle \pi }
may also be represented as the result of applying it to the natural order. This is called a passive permutation[1] or (re)arrangement or ordering:

👁 {\displaystyle \pi }
replaces an object in position 👁 {\displaystyle i}
by that in position 👁 {\displaystyle \pi (i)}
. In an arrow diagram, the one-line notation denotes where the arrows come from.
In this case the result of applying 👁 {\displaystyle \pi }
to a vector 👁 {\displaystyle (x_{1},\dots ,x_{n})}
is 👁 {\displaystyle (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, 👁 {\displaystyle \pi \sigma (x)=\pi {\bigl (}\sigma (x){\bigr )}}
.

👁 {\displaystyle \pi \sigma }
can be thought of as 👁 {\displaystyle \pi ~{\scriptstyle after}~\sigma }
, and 👁 {\displaystyle \pi x}
as 👁 {\displaystyle \pi ~{\scriptstyle of}~x}
This notation corresponds to the usual way of writing function compositions.

With postfix notation or right action, 👁 {\displaystyle \pi \sigma (x)=x\pi \sigma =\sigma {\bigl (}\pi (x){\bigr )}}
.

👁 {\displaystyle \pi \sigma }
can be thought of as 👁 {\displaystyle \pi ~{\scriptstyle before}~\sigma }
, and 👁 {\displaystyle x\pi }
as (image of) 👁 {\displaystyle x~{\scriptstyle under}~\pi }
.
This notation is common in group theory.
(In the Python examples in this article (P*Q)(2) = 2^P^Q = Q(P(2)). The result is R(2) = 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

[edit | edit source]

👁 {\displaystyle \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

[edit | edit source]

If permuting 👁 {\displaystyle v}
by 👁 {\displaystyle \alpha }
gives 👁 {\displaystyle (v_{\alpha ^{-1}(1)},v_{\alpha ^{-1}(2)},v_{\alpha ^{-1}(3)})=(v_{2},v_{3},v_{1})}
the permutation is active.

Active left

[edit | edit source]
AL

If 👁 {\displaystyle \alpha \beta ={\begin{pmatrix}2&1&3\\1&3&2\end{pmatrix}}{\begin{pmatrix}1&2&3\\2&1&3\end{pmatrix}}={\begin{pmatrix}1&2&3\\1&3&2\end{pmatrix}}}
the notation should be seen as active left. *

👁 {\displaystyle \alpha \beta }
means 👁 {\displaystyle \alpha ~{\scriptstyle after}~\beta }
and can be written 👁 {\displaystyle \alpha (\beta )}
.      👁 {\displaystyle \alpha (1)}
can be written 👁 {\displaystyle \alpha 1}
.

Permuting 👁 {\displaystyle v}
by 👁 {\displaystyle \alpha }
may be written in different ways: 👁 {\displaystyle ~~v_{\alpha ^{-1}}~~=~~v(\alpha ^{-1})~~=~~\alpha .v~~=~~v\alpha ^{-1}}

The notation with the dot is just an abbreviation one may define. With two permutations it means: 👁 {\displaystyle \alpha .\beta ~~=~~(\alpha \beta ^{-1})^{-1}~~=~~\beta \alpha ^{-1}}

Active right

[edit | edit source]
AR

If 👁 {\displaystyle \alpha \beta ={\begin{pmatrix}1&2&3\\3&1&2\end{pmatrix}}{\begin{pmatrix}3&1&2\\3&2&1\end{pmatrix}}={\begin{pmatrix}1&2&3\\3&2&1\end{pmatrix}}}
the notation should be seen as active right. *

👁 {\displaystyle \alpha \beta }
means 👁 {\displaystyle \alpha ~{\scriptstyle before}~\beta }
and can be written 👁 {\displaystyle \beta (\alpha )}
.      👁 {\displaystyle \alpha (1)}
can be written 👁 {\displaystyle 1\alpha }
.

Permuting 👁 {\displaystyle v}
by 👁 {\displaystyle \alpha }
may be written in different ways: 👁 {\displaystyle ~~v_{\alpha ^{-1}}~~=~~v(\alpha ^{-1})~~=~~v.\alpha ~~=~~\alpha ^{-1}v}
     (Compare box 12a.)

The abbreviation with the dot corresponds to the function permute in Wolfram. With two permutations it means: 👁 {\displaystyle \alpha .\beta ~~=~~(\alpha ^{-1}\beta )^{-1}~~=~~\beta ^{-1}\alpha }

Passive

[edit | edit source]

If permuting 👁 {\displaystyle v}
by 👁 {\displaystyle \alpha }
gives 👁 {\displaystyle (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

[edit | edit source]

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

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 👁 {\displaystyle n}
-th finite permutation.
👁 {\displaystyle P=(0132)}
is denoted 👁 {\displaystyle {\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 👁 {\displaystyle Q={\mathit {119}}}
, 👁 {\displaystyle R={\mathit {109}}}
and 👁 {\displaystyle S={\mathit {83}}}
[2], but only the letters are used.)

Box 0 Initialisation for the computations

Python:
Permutations in SymPy should be interpreted as AR (the documentation states that "p*q means first apply p, then q").
But the results do not discourage the interpretation as PL.

The simple function before gives the same results.
The result of using it on the non-bijective map 👁 {\displaystyle E}
suggests the interpretation as AR,
but that of permuting the vector 👁 {\displaystyle V}
suggests the interpretation as PL.

from sympy.combinatorics import Permutation

def before(positions, sequence):
 return [sequence[i] for i in positions]

def inv(perm):
 length = len(perm)
 if sorted(perm) != list(range(length)):
 print('Inverse not possible!')
 else:
 inverse = [0] * length
 for key, val in enumerate(perm):
 inverse[val] = key
 return inverse

p = [1, 3, 0, 2, 4]
q = [4, 3, 2, 1, 0]
r = before(p, q)

P = Permutation(p)
Q = Permutation(q)
R = P * Q

v = ['0', '1', '2', '3', '4']
e = [0, 0, 4, 2, 3, 2]

Wolfram:
Permutations in Mathematica are 1-based:

p = {2,4,1,3,5}
q = {5,4,3,2,1}
v = {v1,v2,v3,v4,v5}
e = {1,1,5,3,4,3}


Active vs. passive

[edit | edit source]

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

Box 1 Ambiguity of 👁 {\displaystyle P\cdot Q=R}
Passive (PL):     👁 {\displaystyle P~{\scriptstyle after}~Q~=~R}
Active (AR):     👁 {\displaystyle P~{\scriptstyle before}~Q~=~R}
👁 Image
👁 Image
👁 Image
👁 Image

If it is only required, that 👁 {\displaystyle P\cdot Q=R}
, and no one intends to permute vectors, there is no need to choose an interpretation.
In other terms: It only matters that the 1s in the permutation matrices are at 👁 {\displaystyle {\bigl (}i,\pi (i){\bigr )}}
, and the question if the arrows go clockwise (AR) or anticlockwise (PL) is irrelevant.

If on the other hand it is only required that a permutation permutes the vector 👁 {\displaystyle V}
into 👁 {\displaystyle Y}
, it does dot matter if it is labelled 👁 {\displaystyle R}
or 👁 {\displaystyle R^{-1}}
.
In other terms: As long as the arrow goes from 0 to 3, it does not matter if it is labelled 3 (AR) or 0 (PR).

While the permutations on the left and right have the same labels and do different things, the permutations below do exactly the same as those above them, but are labelled differently.
(Compare box 19, showing the same for 4-element permutations.)

Box 1a Ambiguity of 👁 {\displaystyle P^{-1}\cdot Q^{-1}=R^{-1}}
Active (AL):     👁 {\displaystyle P^{-1}~{\scriptstyle after}~Q^{-1}~=~R^{-1}}
Passive (PR):     👁 {\displaystyle P^{-1}~{\scriptstyle before}~Q^{-1}~=~R^{-1}}
👁 Image
👁 Image
👁 Image
👁 Image
In these matrices the 1s are in the positions 👁 {\displaystyle {\bigl (}\pi (i),i{\bigr )}}
. They are exactly as those above, except that rows instead of columns are labelled.

Left vs. right

[edit | edit source]
Box 2 Ambiguity of 👁 {\displaystyle P\cdot Q}
with active permutations
Left (AL):     👁 {\displaystyle P~{\scriptstyle after}~Q~=~S}
Right (AR):     👁 {\displaystyle P~{\scriptstyle before}~Q~=~R}
👁 Image
👁 Image
👁 Image
👁 Image
Box 3 Ambiguity of 👁 {\displaystyle P\cdot Q}
with passive permutations
Left (PL):     👁 {\displaystyle P~{\scriptstyle after}~Q~=~R}
Right (PR):     👁 {\displaystyle P~{\scriptstyle before}~Q~=~S}
👁 Image
👁 Image
👁 Image
👁 Image

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) 👁 {\displaystyle \alpha \cdot \beta }
means 👁 {\displaystyle \alpha ~{\scriptstyle after}~\beta }
. In postfix notation (right action) 👁 {\displaystyle \beta \cdot \alpha }
means 👁 {\displaystyle \beta ~{\scriptstyle before}~\alpha }
.
Obviously 👁 {\displaystyle \alpha ~{\scriptstyle after}~\beta }
and 👁 {\displaystyle \beta ~{\scriptstyle before}~\alpha }
are just different ways to say the same thing.

Active

[edit | edit source]
Box 4 Formulas for 👁 {\displaystyle R}
and 👁 {\displaystyle S}
in two-line and cycle notation
AL:     👁 {\displaystyle \alpha \beta =\alpha ~{\scriptstyle after}~\beta }
AR:     👁 {\displaystyle \beta \alpha =\beta ~{\scriptstyle before}~\alpha }

👁 {\displaystyle {\begin{aligned}QP&~~=~~{\begin{pmatrix}0&1&2&3&4\\4&3&2&1&0\end{pmatrix}}{\begin{pmatrix}0&1&2&3&4\\1&3&0&2&4\end{pmatrix}}\\&~~=~~{\begin{pmatrix}1&3&0&2&4\\3&1&4&2&0\end{pmatrix}}{\begin{pmatrix}0&1&2&3&4\\1&3&0&2&4\end{pmatrix}}\\&~~=~~{\begin{pmatrix}0&1&2&3&4\\3&1&4&2&0\end{pmatrix}}~~=~~R\end{aligned}}}

👁 {\displaystyle {\begin{aligned}PQ&~~=~~{\begin{pmatrix}0&1&2&3&4\\1&3&0&2&4\end{pmatrix}}{\begin{pmatrix}0&1&2&3&4\\4&3&2&1&0\end{pmatrix}}\\&~~=~~{\begin{pmatrix}0&1&2&3&4\\1&3&0&2&4\end{pmatrix}}{\begin{pmatrix}1&3&0&2&4\\3&1&4&2&0\end{pmatrix}}\\&~~=~~{\begin{pmatrix}0&1&2&3&4\\3&1&4&2&0\end{pmatrix}}~~=~~R\end{aligned}}}

👁 {\displaystyle {\begin{aligned}PQ&~~=~~{\begin{pmatrix}0&1&2&3&4\\1&3&0&2&4\end{pmatrix}}{\begin{pmatrix}0&1&2&3&4\\4&3&2&1&0\end{pmatrix}}\\&~~=~~{\begin{pmatrix}4&3&2&1&0\\4&2&0&3&1\end{pmatrix}}{\begin{pmatrix}0&1&2&3&4\\4&3&2&1&0\end{pmatrix}}\\&~~=~~{\begin{pmatrix}0&1&2&3&4\\4&2&0&3&1\end{pmatrix}}~~=~~S\end{aligned}}}

👁 {\displaystyle {\begin{aligned}QP&~~=~~{\begin{pmatrix}0&1&2&3&4\\4&3&2&1&0\end{pmatrix}}{\begin{pmatrix}0&1&2&3&4\\1&3&0&2&4\end{pmatrix}}\\&~~=~~{\begin{pmatrix}0&1&2&3&4\\4&3&2&1&0\end{pmatrix}}{\begin{pmatrix}4&3&2&1&0\\4&2&0&3&1\end{pmatrix}}\\&~~=~~{\begin{pmatrix}0&1&2&3&4\\4&2&0&3&1\end{pmatrix}}~~=~~S\end{aligned}}}

The top left row is reordered like the bottom right, so the bottom left row becomes the result. The top right row is reordered like the bottom left, so the bottom right row becomes the result.
👁 {\displaystyle QP~=~(04)(13)\cdot (0132)~=~(0324)~=~R}
👁 {\displaystyle PQ~=~(0132)\cdot (04)(13)~=~(0324)~=~R}
👁 {\displaystyle PQ~=~(0132)\cdot (04)(13)~=~(0412)~=~S}
👁 {\displaystyle QP~=~(04)(13)\cdot (0132)~=~(0412)~=~S}
Box 5 Computation (AR only)
Box 5a Python
>>> Permutation.print_cyclic = True

>>> P
Permutation(4)(0, 1, 3, 2)
>>> Q
Permutation(0, 4)(1, 3)

>>> ~P
Permutation(4)(0, 2, 3, 1)
>>> ~Q
Permutation(0, 4)(1, 3)

>>> ~Q * ~P
Permutation(0, 4, 2, 3)
>>> P * Q
Permutation(0, 3, 2, 4)
>>> Q * P
Permutation(0, 4, 1, 2)
>>> Permutation.print_cyclic = False

>>> P
Permutation[1, 3, 0, 2, 4]
>>> Q
Permutation[4, 3, 2, 1, 0]

>>> ~P
Permutation[2, 0, 3, 1, 4]
>>> ~Q
Permutation[4, 3, 2, 1, 0]

>>> ~Q * ~P
Permutation[4, 1, 3, 0, 2]
>>> P * Q
Permutation[3, 1, 4, 2, 0]
>>> Q * P
Permutation[4, 2, 0, 3, 1]
 
 
>>> p
[1, 3, 0, 2, 4]
>>> q
[4, 3, 2, 1, 0]

>>> inv(p)
[2, 0, 3, 1, 4]
>>> inv(q)
[4, 3, 2, 1, 0]

>>> before(inv(q), inv(p))
[4, 1, 3, 0, 2]
>>> before(p, q)
[3, 1, 4, 2, 0]
>>> before(q, p)
[4, 2, 0, 3, 1]
Box 5b Wolfram
I: p
O: {2,4,1,3,5}
I: q
O: {5,4,3,2,1}

I: PermutationCycles[p]
O: Cycles[{{1,2,4,3}}]
I: PermutationCycles[q]
O: Cycles[{{1,5},{2,4}}]

I: PermutationProduct[InversePermutation[q], InversePermutation[p]] (* R^-1 *)
O: {5,2,4,1,3}
I: PermutationProduct[p, q] (* R *)
O: {4,2,5,3,1}
I: PermutationProduct[q, p] (* S *)
O: {5,3,1,4,2}


Box 6 👁 {\displaystyle R^{-1}}
👁 Image
First doing 👁 {\displaystyle Q^{-1}}
and then doing 👁 {\displaystyle P^{-1}}
is the same as doing 👁 {\displaystyle R^{-1}}
.
👁 Image
AL:     👁 {\displaystyle P^{-1}~{\scriptstyle after}~Q^{-1}~=~R^{-1}}
👁 Image
AR:     👁 {\displaystyle Q^{-1}~{\scriptstyle before}~P^{-1}~=~R^{-1}}
Box 7 👁 {\displaystyle R}
👁 Image
First doing 👁 {\displaystyle P}
and then doing 👁 {\displaystyle Q}
is the same as doing 👁 {\displaystyle R}
.
👁 Image
AL:     👁 {\displaystyle Q~{\scriptstyle after}~P~=~R}
👁 Image
AR:     👁 {\displaystyle P~{\scriptstyle before}~Q~=~R}
Box 8 👁 {\displaystyle S}
👁 Image
First doing 👁 {\displaystyle Q}
and then doing 👁 {\displaystyle P}
is the same as doing 👁 {\displaystyle S}
.
👁 Image
AL:     👁 {\displaystyle P~{\scriptstyle after}~Q~=~S}
👁 Image
AR:     👁 {\displaystyle Q~{\scriptstyle before}~P~=~S}

Passive

[edit | edit source]
Box 9 👁 {\displaystyle R^{-1}}
👁 Image
First doing 👁 {\displaystyle P^{-1}}
and then doing 👁 {\displaystyle Q^{-1}}
is the same as doing 👁 {\displaystyle R^{-1}}
.
👁 Image
PL:     👁 {\displaystyle Q^{-1}~{\scriptstyle after}~P^{-1}~=~R^{-1}}
👁 Image
PR:     👁 {\displaystyle P^{-1}~{\scriptstyle before}~Q^{-1}~=~R^{-1}}
Box 10 👁 {\displaystyle R}
👁 Image
First doing 👁 {\displaystyle Q}
and then doing 👁 {\displaystyle P}
is the same as doing 👁 {\displaystyle R}
.
👁 Image
PL:     👁 {\displaystyle P~{\scriptstyle after}~Q~=~R}
👁 Image
PR:     👁 {\displaystyle Q~{\scriptstyle before}~P~=~R}
Box 11 👁 {\displaystyle S}
👁 Image
First doing 👁 {\displaystyle P}
and then doing 👁 {\displaystyle Q}
is the same as doing 👁 {\displaystyle S}
.
👁 Image
PL:     👁 {\displaystyle Q~{\scriptstyle after}~P~=~S}
👁 Image
PR:     👁 {\displaystyle P~{\scriptstyle before}~Q~=~S}


Vectors, scalars and non-bijective maps

[edit | edit source]

Active

[edit | edit source]
Box 12 Permuting a vector
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
Box 12a Formulas and computation

👁 {\displaystyle {\begin{aligned}&P^{-1}V&~=~&V.P&~=~&V_{P^{-1}}&~=~&(V_{P^{-1}(0)},\dots ,V_{P^{-1}(4)})&~=~&(V_{2},V_{0},V_{3},V_{1},V_{4})&&&~=~&X\\&Q^{-1}X&~=~&X.Q&~=~&X_{Q^{-1}}&~=~&(X_{Q^{-1}(0)},\dots ,X_{Q^{-1}(4)})&~=~&(X_{4},X_{3},X_{2},X_{1},X_{0})&~=~&(V_{4},V_{1},V_{3},V_{0},V_{2})&~=~&Y\\\\&R^{-1}V&~=~&V.R&~=~&V_{R^{-1}}&~=~&(V_{R^{-1}(0)},\dots ,V_{R^{-1}(4)})&~=~&(V_{4},V_{1},V_{3},V_{0},V_{2})&&&~=~&Y\end{aligned}}}

Python:

>>> x = before(inv(p), v)
>>> x
['2', '0', '3', '1', '4']

>>> before(inv(q), x) # Y
['4', '1', '3', '0', '2']
>>> before(inv(r), v) # Y
['4', '1', '3', '0', '2']

Wolfram:

 
I: x = Permute[v, p]
O: {v3,v1,v4,v2,v5}

I: Permute[x, q] (* Y *)
O: {v5,v2,v4,v1,v3}
I: Permute[v, r] (* Y *)
O: {v5,v2,v4,v1,v3}
Box 13 Concatenation with a scalar as permuting a vector
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
Box 13a Computation

Python:

>>> before([0], p)
[1]

>>> before([1], q)
[3]
>>> before([0], r)
[3]

Wolfram:

I: PermutationReplace[1, p]
O: 2

I: PermutationReplace[2, q]
O: 4
I: PermutationReplace[1, r]
O: 4
Box 14 Concatenation with a scalar as concatenation with a constant
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
Box 15 Concatenation with a non-bijective map
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image

👁 {\displaystyle E=(0,0,4,2,3,2)}

👁 {\displaystyle {\begin{aligned}RE&~~=~~{\Bigl (}R{\bigl (}E(0){\bigr )},\dots ,R{\bigl (}E(5){\bigr )}{\Bigr )}\\&~~=~~{\bigl (}R(0),R(0),R(4),R(2),R(3),R(2){\bigr )}\\&~~=~~(3,3,0,4,2,4)~~=~~G\end{aligned}}}

👁 {\displaystyle {\begin{aligned}ER&~~=~~(0ER,\dots ,5ER)\\&~~=~~(0R,0R,4R,2R,3R,2R)\\&~~=~~(3,3,0,4,2,4)~~=~~G\end{aligned}}}

Box 15a Computation

Python:

>>> f = before(e, p)
>>> f
[1, 1, 4, 0, 2, 0]

>>> before(f, q) # G
[3, 3, 0, 4, 2, 4]
>>> before(e, r) # G
[3, 3, 0, 4, 2, 4]

Wolfram:

 
I: f = PermutationReplace[e, p]
O: {2,2,5,1,3,1}

I: PermutationReplace[f, q] (* G *)
O: {4,4,1,5,3,5}
I: PermutationReplace[e, r] (* G *)
O: {4,4,1,5,3,5}

Passive

[edit | edit source]
Box 16 Permuting a vector
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
Box 16a Formulas and computation

👁 {\displaystyle {\begin{aligned}&QV&~~=~~&(V_{Q(0)},\dots ,V_{Q(4)})&~~=~~&(V_{4},V_{3},V_{2},V_{1},V_{0})&&&~~=~~&A\\&PA&~~=~~&(A_{P(0)},\dots ,A_{P(4)})&~~=~~&(A_{1},A_{3},A_{0},A_{2},A_{4})&~~=~~&(V_{3},V_{1},V_{4},V_{2},V_{0})&~~=~~&B\\\\&RV&~~=~~&(V_{R(0)},\dots ,V_{R(4)})&~~=~~&(V_{3},V_{1},V_{4},V_{2},V_{0})&&&~~=~~&B\end{aligned}}}

Python:

>>> a = before(q, v)
>>> a
['4', '3', '2', '1', '0']

>>> before(p, a) # B
['3', '1', '4', '2', '0']
>>> before(r, v) # B
['3', '1', '4', '2', '0']

Wolfram:

 
I: a = Permute[v, InversePermutation[q]]
O: {v5,v4,v3,v2,v1}

I: Permute[a, InversePermutation[p]] (* B *)
O: {v4,v2,v5,v3,v1}
I: Permute[v, InversePermutation[r]] (* B *)
O: {v4,v2,v5,v3,v1}
Box 17 Concatenation with a scalar as permuting a vector
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
Box 17a Computation

Python:

>>> before([3], inv(q))
[1]

>>> before([1], inv(p))
[0]
>>> before([3], inv(r))
[0]

Wolfram:

I: PermutationReplace[4,InversePermutation[q]]
O: 2

I: PermutationReplace[2,InversePermutation[p]]
O: 1
I: PermutationReplace[4,InversePermutation[r]]
O: 1

Examples with permutations of the square

[edit | edit source]

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)

[edit | edit source]

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 👁 {\displaystyle e}
to 👁 {\displaystyle ab}
in the example below is first through the arrow 👁 {\displaystyle a}
and then through the edge 👁 {\displaystyle b}
.) A source that uses this convention is Visual Group Theory by Nathan Carter.

permutohedron section, cycle graph, Cayley table
ocagonal section of the permutation of S4 corresponding to this subgroup
Cycle graph (Formulas on the left correspond to the Cayley graph in the middle.)
👁 Image
Cayley table (AR)
Box 18 Cayley graphs

The three Cayley graphs below show how each element of the group can be displayed as a product of two different elements.
The formulas are in postfix (AR) notation, i.e. an arrow representing 👁 {\displaystyle \beta }
goes from 👁 {\displaystyle \alpha }
to 👁 {\displaystyle \alpha \beta }
. An undirected edge is shorthand for arrows in both directions.

👁 {\displaystyle p={\mathit {10}}}
  (orange arrow),     👁 {\displaystyle t={\mathit {2}}}
  (green edge)
👁 {\displaystyle a={\mathit {13}}}
  (red arrow),     👁 {\displaystyle b={\mathit {7}}}
  (blue edge)
👁 {\displaystyle b={\mathit {7}}}
  (blue edge),     👁 {\displaystyle c={\mathit {21}}}
  (pink edge)
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image

orange arrow from 👁 {\displaystyle {\mathit {21}}}
to 👁 {\displaystyle {\mathit {16}}}
:
👁 {\displaystyle {\mathit {21}}\cdot p={\mathit {21}}\cdot {\mathit {10}}={\mathit {16}}}

green edge between 👁 {\displaystyle {\mathit {21}}}
and 👁 {\displaystyle {\mathit {23}}}
:
👁 {\displaystyle {\mathit {21}}\cdot t={\mathit {21}}\cdot {\mathit {2}}={\mathit {23}}}
  and   👁 {\displaystyle {\mathit {23}}\cdot t={\mathit {23}}\cdot {\mathit {2}}={\mathit {21}}}

red arrow from 👁 {\displaystyle {\mathit {16}}}
to 👁 {\displaystyle {\mathit {21}}}
:
👁 {\displaystyle {\mathit {16}}\cdot a={\mathit {16}}\cdot {\mathit {13}}={\mathit {21}}}

blue edge between 👁 {\displaystyle {\mathit {2}}}
and 👁 {\displaystyle {\mathit {10}}}
:
👁 {\displaystyle {\mathit {2}}\cdot b={\mathit {2}}\cdot {\mathit {7}}={\mathit {10}}}
  and   👁 {\displaystyle {\mathit {10}}\cdot b={\mathit {10}}\cdot {\mathit {7}}={\mathit {2}}}

blue edge between 👁 {\displaystyle {\mathit {2}}}
and 👁 {\displaystyle {\mathit {10}}}
:
👁 {\displaystyle {\mathit {2}}\cdot b={\mathit {2}}\cdot {\mathit {7}}={\mathit {10}}}
  and   👁 {\displaystyle {\mathit {10}}\cdot b={\mathit {10}}\cdot {\mathit {7}}={\mathit {2}}}

pink edge between 👁 {\displaystyle {\mathit {2}}}
and 👁 {\displaystyle {\mathit {23}}}
:
👁 {\displaystyle {\mathit {2}}\cdot c={\mathit {2}}\cdot {\mathit {21}}={\mathit {23}}}
  and   👁 {\displaystyle {\mathit {23}}\cdot c={\mathit {23}}\cdot {\mathit {21}}={\mathit {2}}}

Active left (linear maps)

[edit | edit source]

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

permutations as linear maps
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
Cayley tables
The rotations of the square form the cyclic group C4. The 2×2 matrices of the linear maps are a subgroup of SL(2,3), and within that of the quaternion group.
👁 Image
Cayley table (AL)
Cayley table of the cyclic subgroup
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
👁 Image
corresponding subgroup of the quaternion group

Active vs. passive

[edit | edit source]
Box 19 Ambiguity of 👁 {\displaystyle {\mathit {10}}\cdot {\mathit {2}}={\mathit {16}}}
Passive (PL):     👁 {\displaystyle {\mathit {10}}~{\scriptstyle after}~{\mathit {2}}={\mathit {16}}}
Active (AR):     👁 {\displaystyle {\mathit {10}}~{\scriptstyle before}~{\mathit {2}}={\mathit {16}}}
👁 Image
👁 Image

The inverse of 👁 {\displaystyle {\mathit {10}}}
is 👁 {\displaystyle {\mathit {13}}}
, while 👁 {\displaystyle {\mathit {2}}}
and 👁 {\displaystyle {\mathit {16}}}
are self-conjugate.

The Cayley table above contains 👁 {\displaystyle {\mathit {10}}\cdot {\mathit {2}}={\mathit {16}}}
, so it fits the row above, and it contains 👁 {\displaystyle {\mathit {2}}\cdot {\mathit {13}}={\mathit {16}}}
, so its transpose would fit the row below.

As above (box 1) the permutations on the left and right have the same labels and do different things, while the permutations below do exactly the same as those above them, but are labelled differently.

Box 19a Ambiguity of 👁 {\displaystyle {\mathit {10}}^{-1}\cdot {\mathit {2}}^{-1}={\mathit {16}}^{-1}}
which is 👁 {\displaystyle {\mathit {13}}\cdot {\mathit {2}}={\mathit {16}}}
Active (AL):     👁 {\displaystyle {\mathit {13}}~{\scriptstyle after}~{\mathit {2}}={\mathit {16}}}
Passive (PR):     👁 {\displaystyle {\mathit {13}}~{\scriptstyle before}~{\mathit {2}}={\mathit {16}}}
👁 Image
👁 Image

Left vs. right

[edit | edit source]

Active

[edit | edit source]
Cayley tables
👁 Image
AL (or PR)
👁 Image
AR (or PL)
Box 20 👁 {\displaystyle {\mathit {7}}}
👁 Image
AL:     👁 {\displaystyle {\mathit {10}}~{\scriptstyle after}~{\mathit {2}}={\mathit {7}}}
👁 Image
AR:     👁 {\displaystyle {\mathit {2}}~{\scriptstyle before}~{\mathit {10}}={\mathit {7}}}
Box 21 👁 {\displaystyle {\mathit {16}}}
👁 Image
AL:     👁 {\displaystyle {\mathit {2}}~{\scriptstyle after}~{\mathit {10}}={\mathit {16}}}
👁 Image
AR:     👁 {\displaystyle {\mathit {10}}~{\scriptstyle before}~{\mathit {2}}={\mathit {16}}}

Passive

[edit | edit source]
Box 22 👁 {\displaystyle {\mathit {7}}}
👁 Image
PL:     👁 {\displaystyle {\mathit {2}}~{\scriptstyle after}~{\mathit {10}}={\mathit {7}}}
👁 Image
PR:     👁 {\displaystyle {\mathit {10}}~{\scriptstyle before}~{\mathit {2}}={\mathit {7}}}
Box 23 👁 {\displaystyle {\mathit {16}}}
👁 Image
PL:     👁 {\displaystyle {\mathit {10}}~{\scriptstyle after}~{\mathit {2}}={\mathit {16}}}
👁 Image
PR:     👁 {\displaystyle {\mathit {2}}~{\scriptstyle before}~{\mathit {10}}={\mathit {16}}}

Languages

[edit | edit source]

Wolfram

[edit | edit source]
👁 {\displaystyle P}
as permutation matrix and arrow diagram in Wolfram Alpha

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

👁 {\displaystyle P}
is shown as 👁 {\displaystyle {\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 p = {2,4,1,3,5} corresponds to Cycles[{{1,2,4,3}}].
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)

More examples
I: p
O: {2,4,1,3,5}
I: q
O: {5,4,3,2,1}

I: PermutationProduct[p, q] (* R *)
O: {4,2,5,3,1}
I: PermutationProduct[q, p] (* S *)
O: {5,3,1,4,2}

For two permutations PermutationReplace gives the same result as PermutationProduct:

I: PermutationReplace[p, q] (* R *)
O: {4,2,5,3,1}
I: PermutationReplace[q, p] (* S *)
O: {5,3,1,4,2}
👁 Image
Permute[p, q]
👁 Image
Permute[q, p]

Permute[p, q] is PermutationProduct[q, p] but Permute[q, p] is not PermutationProduct[p, q]:

I: Permute[p, q]
O: {5,3,1,4,2}
I: Permute[q, p]
O: {3,5,2,4,1}

Permute[a, b] with permutations a, b behaves like InversePermutation[PermutationProduct[InversePermutation[a], b]] = PermutationProduct[InversePermutation[b], a].

Confusingly the result of Permute[q, p] changes to {4,2,5,3,1} when the Combinatorica package is used (Needs["Combinatorica`"]),
i.e. Permute[a, b] with permutations a, b now behaves like PermutationProduct[b, a].

The result of Permute[p, q] is {5,3,1,4,2} in both cases because q is self-conjugate —
thus PermutationProduct[q, p] = PermutationProduct[InversePermutation[q], p].


SymPy

[edit | edit source]

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 a^b is the same as ~b*a*b (see Python script), which is a permutation in the same conjugacy class.

👁 Image
Permutations 👁 {\displaystyle {\mathit {0}}\dots {\mathit {23}}}


Example:    👁 {\displaystyle {\mathit {15}}=(031)}
👁 Image
👁 {\displaystyle (a,b)~~=~~a\cdot b}


Example:    👁 {\displaystyle {\mathit {6}}\cdot {\mathit {15}}~~=~~{\mathit {9}}}
👁 Image
👁 {\displaystyle (a,b)~~=~~a^{b}~~=~~b^{-1}\cdot a\cdot b}
      (details on file page)

Example:    👁 {\displaystyle {\mathit {6^{15}}}~~=~~{\mathit {15}}^{-1}\cdot {\mathit {6}}\cdot {\mathit {15}}~~=~~{\mathit {20}}\cdot {\mathit {6}}\cdot {\mathit {15}}~~=~~{\mathit {2}}}


Negative results for ~p(i)

Inverse permutations behave strangely when accessed from the right.
👁 {\displaystyle {\mathit {15}}^{-1}}
should behave exactly like 👁 {\displaystyle {\mathit {20}}}
. While i^~p15 behaves as expected, ~p15(i) gives negative results:


p15 = Permutation([3, 0, 2, 1]), p20 = Permutation([1, 3, 2, 0])
The two permutations are inverses: p20 == ~p15 = True
[i^~p15 for i in range(4)] = [1, 3, 2, 0]
[~p15(i) for i in range(4)] = [-4, -1, -3, -2]


These numbers would work to access the values of a list with four elements in Python - e.g. a[-1] = a[3] is the last element of a.
[-4, -1, -3, -2] converted accordingly is [0, 3, 1, 2], which is permutation 👁 {\displaystyle {\mathit {8}}}
.
Doing the same for all permutations of four elements (see Python script) shows the following result:
Where the expected permutation is 👁 {\displaystyle a}
, the converted permutation is 👁 {\displaystyle b}
with 👁 {\displaystyle a\cdot b={\mathit {23}}}
.
Here the expected permutations is 👁 {\displaystyle {\mathit {20}}}
, and the converted permutation is 👁 {\displaystyle {\mathit {8}}}
, because 👁 {\displaystyle {\mathit {20}}\cdot {\mathit {8}}={\mathit {23}}}
.


Sources

[edit | edit source]

There appear to be no sources that actually use the passive interpretation of permutations, so the sources below are active left and active right.

Aigner 2007

[edit | edit source]

We read a product always from right to left, thus for

👁 {\displaystyle \sigma ={\begin{pmatrix}1&2&3&4&5&6\\2&3&4&1&6&5\end{pmatrix}}}
,   👁 {\displaystyle \tau ={\begin{pmatrix}1&2&3&4&5&6\\1&3&4&5&2&6\end{pmatrix}}}
,

we have

👁 {\displaystyle \tau \sigma ={\begin{pmatrix}1&2&3&4&5&6\\3&4&5&1&6&2\end{pmatrix}}}
  and   👁 {\displaystyle \sigma \tau ={\begin{pmatrix}1&2&3&4&5&6\\2&4&1&6&3&5\end{pmatrix}}}
.


We call 👁 {\displaystyle \sigma =\sigma (1)\sigma (2)\dots \sigma (n)}
the word representation of 👁 {\displaystyle \sigma }
.

Aigner, Martin (2007). A course in enumeration. Berlin New York: Springer. ISBN 3642072534.Word Representation (p. 27 ff)

Right

[edit | edit source]

Knuth 1973

[edit | edit source]

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

👁 {\displaystyle \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}}}

👁 {\displaystyle \alpha \beta =(02)(153)\cdot (05)(14)(23)=(0341)(25)}

SymPy
>>> from sympy.combinatorics import Permutation

>>> a = Permutation(0, 2)(1, 5, 3)
>>> b = Permutation(0, 5)(1, 4)(2, 3)

>>> a * b
Permutation(0, 3, 4, 1)(2, 5)
>>> b * a
Permutation(0, 3)(1, 4, 5, 2)

>>> Permutation.print_cyclic = False

>>> a
Permutation[2, 5, 0, 1, 4, 3]
>>> b
Permutation[5, 4, 3, 2, 1, 0]

>>> a * b
Permutation[3, 0, 5, 4, 1, 2]
>>> b * a
Permutation[3, 4, 1, 0, 5, 2]

The left permutation sees the argument first:

Notice that the image of 1 under 👁 {\displaystyle \alpha \beta }
is 👁 {\displaystyle 1(\alpha \beta )=(1\alpha )\beta =5\beta =0}
, etc.

SymPy: (1^a)^b = 5^b = 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 👁 {\displaystyle \alpha (1)=5}
, makes it natural to think that 👁 {\displaystyle \alpha \beta (1)}
should mean 👁 {\displaystyle \alpha (\beta (1))=\alpha (4)=4}
.

SymPy: a(b(1)) = a(4) = 4

Knuth, Donald (1973). The art of computer programming. Reading, Mass: Addison-Wesley Pub. Co. ISBN 0201896850. — Chapter 7.2.1.2. Generating all permutations


Cameron 1994

[edit | edit source]

Cameron decribes the active form of a permutation as a one-to-one mapping from 👁 {\displaystyle X=\{x_{1},\dots ,x_{n}\}}
to itself, and the passive form as the ordered n-tuple 👁 {\displaystyle {\bigl (}\pi (x_{1}),\dots ,\pi (x_{n}){\bigr )}}
.

I wrote 👁 {\displaystyle \pi (x)}
for the result of applying the function 👁 {\displaystyle \pi }
to the element 👁 {\displaystyle x}
.
[...] In order that the result of applying first 👁 {\displaystyle \pi _{1}}
and then 👁 {\displaystyle \pi _{2}}
can be called 👁 {\displaystyle \pi _{1}\pi _{2}}
, it is more natural to denote the image of 👁 {\displaystyle x}
under 👁 {\displaystyle \pi }
as 👁 {\displaystyle 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.

Cameron, Peter J. (1994), Combinatorics: Topics, Techniques, Algorithms, Cambridge University Press, ISBN 0-521-45761-0 — Chapter 3.5 Permutations (p. 29)

Grimaldi 2004

[edit | edit source]
👁 Image
Illustrations of 👁 {\displaystyle \pi _{1}}
and 👁 {\displaystyle r_{1}}
as in the book, illustration of 👁 {\displaystyle \pi _{1}r_{1}}
added

Grimaldi defines 👁 {\displaystyle \pi _{1}={\begin{pmatrix}1&2&3\\3&1&2\end{pmatrix}}}
as the left rotation of a triangle and 👁 {\displaystyle 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 👁 {\displaystyle \pi _{1}r_{1}={\begin{pmatrix}1&2&3\\3&2&1\end{pmatrix}}=r_{3}}
is the reflection about the vertical axis.

Grimaldi, Ralph (2004). Discrete and combinatorial mathematics : an applied introduction. Reading, Mass: Addison-Wesley Longman. ISBN 0321211030. — Example 16.7 (p.749)


References

[edit | edit source]
  1. Some authors – see Cameron (1994) – call a permutations one-line notation the passive form. But this article calls a permutation passive when its one-line notation denotes where the arrows in its arrow diagram come from — as opposed to where they go. In the 19th century passive permutations were called permutations, while permutations in the modern sense were called substitutions.
  2. Compare this list of the first 40320 finite permutations: https://oeis.org/A198380/a198380_1.txt (1-based)