# Parity of a permutation

Permutations of 4 elements

Odd permutations have a green or orange background. The numbers in the right column are the inversion numbers (sequence A034968 in the OEIS), which have the same parity as the permutation.

In mathematics, when X is a finite set of at least two elements, the permutations of X (i.e. the bijective functions from X to X) fall into two classes of equal size: the even permutations and the odd permutations. If any total ordering of X is fixed, the parity (oddness or evenness) of a permutation ${\displaystyle \sigma }$ of X can be defined as the parity of the number of inversions for σ, i.e., of pairs of elements x, y of X such that ${\displaystyle x and ${\displaystyle \sigma (x)>\sigma (y)}$.

The sign or signature of a permutation σ is denoted sgn(σ) and defined as +1 if σ is even and −1 if σ is odd. The signature defines the alternating character of the symmetric group Sn. Another notation for the sign of a permutation is given by the more general Levi-Civita symbol (${\displaystyle \epsilon _{\sigma }}$), which is defined for all maps from X to X, and has value zero for non-bijective maps.

The sign of a permutation can be explicitly expressed as

sgn(σ) = (−1)N(σ)

where N(σ) is the number of inversions in σ.

Alternatively, the sign of a permutation σ can be defined from its decomposition into the product of transpositions as

sgn(σ) = (−1)m

where m is the number of transpositions in the decomposition. Although such a decomposition is not unique, the parity of the number of transpositions in all decompositions is the same, implying that the sign of a permutation is well-defined.[1]

## Example

Consider the permutation σ of the set {1, 2, 3, 4, 5} which turns the initial arrangement 12345 into 34521. It can be obtained by three transpositions: first exchange the places of 1 and 3, then exchange the places of 2 and 4, and finally exchange the places of 1 and 5. This shows that the given permutation σ is odd. Using the notation explained in the Permutation article, we can write

${\displaystyle \sigma ={\begin{pmatrix}1&2&3&4&5\\3&4&5&2&1\end{pmatrix}}={\begin{pmatrix}1&3&5\end{pmatrix}}{\begin{pmatrix}2&4\end{pmatrix}}={\begin{pmatrix}1&5\end{pmatrix}}{\begin{pmatrix}1&3\end{pmatrix}}{\begin{pmatrix}2&4\end{pmatrix}}.}$

There are many other ways of writing σ as a composition of transpositions, for instance

σ = (2 3) (1 2) (2 4) (3 5) (4 5),

but it is impossible to write it as a product of an even number of transpositions.

## Properties

The identity permutation is an even permutation.[1] An even permutation can be obtained as the composition of an even number and only an even number of exchanges (called transpositions) of two elements, while an odd permutation can be obtained by (only) an odd number of transpositions.

• the composition of two even permutations is even
• the composition of two odd permutations is even
• the composition of an odd and an even permutation is odd

From these it follows that

• the inverse of every even permutation is even
• the inverse of every odd permutation is odd

Considering the symmetric group Sn of all permutations of the set {1, ..., n}, we can conclude that the map

sgn: Sn → {−1, 1}

that assigns to every permutation its signature is a group homomorphism.[2]

Furthermore, we see that the even permutations form a subgroup of Sn.[1] This is the alternating group on n letters, denoted by An.[3] It is the kernel of the homomorphism sgn.[4] The odd permutations cannot form a subgroup, since the composite of two odd permutations is even, but they form a coset of An (in Sn).[5]

If n > 1 , then there are just as many even permutations in Sn as there are odd ones;[3] consequently, An contains n!/2 permutations. [The reason: if σ is even, then (1 2) σ is odd; if σ is odd, then (1 2) σ is even; the two maps are inverse to each other.][3]

A cycle is even if and only if its length is odd. This follows from formulas like

(abcde) = (de) (ce) (be) (ae)

In practice, in order to determine whether a given permutation is even or odd, one writes the permutation as a product of disjoint cycles. The permutation is odd if and only if this factorization contains an odd number of even-length cycles.

Another method for determining whether a given permutation is even or odd is to construct the corresponding permutation matrix and compute its determinant. The value of the determinant is the same as the parity of the permutation.

Every permutation of odd order must be even. The permutation (12)(34) in A4 shows that the converse is not true in general.

## Equivalence of the two definitions

### Proof 1

Every permutation can be produced by a sequence of transpositions (2-element exchanges): with the first transposition we put the first element of the permutation in its proper place, the second transposition puts the second element right etc. Since we cannot be left with just a single element in an incorrect position, we must achieve the permutation with our last transposition. Given a permutation σ, we can write it as a product of transpositions in many different ways. We want to show that either all of those decompositions have an even number of transpositions, or all have an odd number.

Suppose we have two such decompositions:

σ = T1 T2 ... Tk
σ = Q1 Q2 ... Qm.

We want to show that k and m are either both even, or both odd.

Every transposition can be written as a product of an odd number of transpositions of adjacent elements, e.g.

(2 5) = (2 3) (3 4) (4 5) (4 3) (3 2).

To see this, note that if we have the transposition (i j) on an n-element set {1,...,i,...,j,...,n}, one way to decompose it is as [(j-1 j)(j-2 j-1)...(i+1 i+2)][(i+1 i)(i+2 i+1)...(j j-1)]. The right block of transpositions first frees up the j space by moving j over to the j-1 space; then, j-1 goes into the j-2 space with j-2 in the j space, j-2 goes into the j-3 space with j-3 in the j space, etc., until i+1 ends up in the i space and i in the j space. Thus, each element from i+1 to j-1 is in a space one to the left from where it ought to be. In the left block, each of those elements is restored one at a time to its original space, after resting in the i space for the duration of one permutation. j ends up in the i space, and i in the j space, with nothing else altered, as desired. The number of transpositions is (j-i) + (j-i - 1), which is clearly odd.

If we decompose in this way each of the transpositions T1...Tk and Q1...Qm above into an odd number of adjacent transpositions, we get the new decompositions:

σ = T*1 T*2 ... T*k′
σ = Q*1 Q*2 ... Q*m′

where all of the T*1...T*k′ Q*1...Q*m′ are adjacent, k − k′ is even, and m − m′ is even.

Now compose the inverse of T*k′ (which happens to be the same permutation) with σ. T*k' is the transposition (i, i + 1) of two adjacent numbers, so, compared to σ, the new permutation σ (i, i + 1) will have exactly one inversion pair less (in case (i, i + 1) was an inversion pair for σ) or more (in case (i, i + 1) was not an inversion pair). Then apply the inverses of T*k′-1, T*k'-2, ..., T*1 in the same way, "unraveling" the permutation σ. At the end we get the identity permutation, whose N (see above) is zero. This means that the original N(σ) less k' is even and also N(σ) less k is even (addition modulo two is independent of sign).

We can do the same thing with the other decomposition, Q*m'...Q*1, and it will turn out that the original N(σ) less m is even.

Therefore, m − k is even, as we wanted to show.

We can thus define the parity of σ to be that of its number of constituent transpositions, because we see that this can have only one value. And this must agree with the parity of the number of inversions under any ordering, as seen above, so the definitions are indeed well-defined and equivalent.

### Proof 2

An alternative proof uses the polynomial

${\displaystyle P(x_{1},\ldots ,x_{n})=\prod _{i

So for instance in the case n = 3, we have

${\displaystyle P(x_{1},x_{2},x_{3})=(x_{1}-x_{2})(x_{2}-x_{3})(x_{1}-x_{3})\;}$

Now for a given permutation σ of the numbers {1, ..., n}, we define

${\displaystyle \operatorname {sgn} (\sigma )={\frac {P(x_{\sigma (1)},\ldots ,x_{\sigma (n)})}{P(x_{1},\ldots ,x_{n})}}}$

Since the polynomial ${\displaystyle P(x_{\sigma (1)},\dots ,x_{\sigma (n)})}$ has the same factors as ${\displaystyle P(x_{1},\dots ,x_{n})}$ except for their signs, if follows that sgn(σ) is either +1 or −1. Furthermore, if σ and τ are two permutations, we see that

${\displaystyle \operatorname {sgn} (\sigma \tau )={\frac {P(x_{\sigma (\tau (1))},\ldots ,x_{\sigma (\tau (n))})}{P(x_{1},\ldots ,x_{n})}}}$
${\displaystyle ={\frac {P(x_{\tau (1)},\ldots ,x_{\tau (n)})}{P(x_{1},\ldots ,x_{n})}}\cdot {\frac {P(x_{\sigma (\tau (1))},\ldots ,x_{\sigma (\tau (n))})}{P(x_{\tau (1)},\ldots ,x_{\tau (n)})}}}$
${\displaystyle =\operatorname {sgn} (\sigma )\cdot \operatorname {sgn} (\tau )}$

Since with this definition it is furthermore clear that any transposition of two elements has signature −1, we do indeed recover the signature as defined earlier.

### Proof 3

A third approach uses the presentation of the group Sn in terms of generators ${\displaystyle \tau _{1},\dots ,\tau _{n-1}}$ and relations

• ${\displaystyle \tau _{i}^{2}=1}$  for all i
• ${\displaystyle \tau _{i}^{}\tau _{i+1}\tau _{i}=\tau _{i+1}\tau _{i}\tau _{i+1}}$   for all i < n − 1
• ${\displaystyle \tau _{i}^{}\tau _{j}=\tau _{j}\tau _{i}}$   if |i − j| ≥ 2.

[Here the generator ${\displaystyle \tau _{i}}$ represents the transposition (i, i + 1).] All relations keep the length of a word the same or change it by two. Starting with an even-length word will thus always result in an even-length word after using the relations, and similarly for odd-length words. It is therefore unambiguous to call the elements of Sn represented by even-length words "even", and the elements represented by odd-length words "odd".

## Other definitions and proofs

The parity of a permutation of ${\displaystyle n}$ points is also encoded in its cycle structure.

Let ${\displaystyle \sigma =(i_{1}i_{2}\dots i_{r+1})(j_{1}j_{2}\dots j_{s+1})\dots (l_{1}l_{2}\dots l_{u+1})}$ be the unique decomposition of ${\displaystyle \sigma }$ into disjoint cycles, which can be composed in any order because they commute. A cycle ${\displaystyle (abc\dots xyz)}$ involving ${\displaystyle k+1}$ points can always be obtained by composing ${\displaystyle k}$ transpositions (2-cycles):

${\displaystyle (abc\dots xyz)=(ab)(bc)\dots (xy)(yz)}$,

so call ${\displaystyle k}$ the size of the cycle, and observe that, under this definition, transpositions are cycles of size 1. From a decomposition into ${\displaystyle m}$ disjoint cycles we can obtain a decomposition of ${\displaystyle \sigma }$ into ${\displaystyle k_{1}+k_{2}+\dots +k_{m}}$ transpositions, where ${\displaystyle k_{i}}$ is the size of the ith cycle. The number ${\displaystyle N(\sigma )=k_{1}+k_{2}+\dots +k_{m}}$ is called the discriminant of ${\displaystyle \sigma }$, and can also be computed as

${\displaystyle n-{\text{number of disjoint cycles in the decomposition of }}\sigma }$

if we take care to include the fixed points of ${\displaystyle \sigma }$ as 1-cycles.

Suppose a transposition ${\displaystyle (ab)}$ is applied after a permutation ${\displaystyle \sigma }$. When ${\displaystyle a}$ and ${\displaystyle b}$ are in different cycles of ${\displaystyle \sigma }$ then

${\displaystyle (ab)(ac_{1}c_{2}\dots c_{r})(bd_{1}d_{2}\dots d_{s})=(ac_{1}c_{2}\dots c_{r}bd_{1}d_{2}\dots d_{s})}$,

and if ${\displaystyle a}$ and ${\displaystyle b}$ are in the same cycle of ${\displaystyle \sigma }$ then

${\displaystyle (ab)(ac_{1}c_{2}\dots c_{r}bd_{1}d_{2}\dots d_{s})=(ac_{1}c_{2}\dots c_{r})(bd_{1}d_{2}\dots d_{s})}$.

In either case, it can be seen that ${\displaystyle N((ab)\sigma )=N(\sigma )\pm 1}$, so the parity of ${\displaystyle N((ab)\sigma )}$ will be different from the parity of ${\displaystyle N(\sigma )}$.

If ${\displaystyle \sigma =t_{1}t_{2}\dots t_{r}}$ is an arbitrary decomposition of a permutation ${\displaystyle \sigma }$ into transpositions, by applying the ${\displaystyle r}$ transpositions ${\displaystyle t_{1}}$ after ${\displaystyle t_{2}}$ after ... after ${\displaystyle t_{r}}$ after the identity (whose ${\displaystyle N}$ is zero) observe that ${\displaystyle N(\sigma )}$ and ${\displaystyle r}$ have the same parity. By defining the parity of ${\displaystyle \sigma }$ as the parity of ${\displaystyle N(\sigma )}$, a permutation that has an even length decomposition is an even permutation and a permutation that has one odd length decomposition is an odd permutation.

Remarks:

• A careful examination of the above argument shows that ${\displaystyle r\geq N(\sigma )}$, and since any decomposition of ${\displaystyle \sigma }$ into cycles whose sizes sum to ${\displaystyle r}$ can be expressed as a composition of ${\displaystyle r}$ transpositions, the number ${\displaystyle N(\sigma )}$ is the minimum possible sum of the sizes of the cycles in a decomposition of ${\displaystyle \sigma }$, including the cases in which all cycles are transpositions.
• This proof does not introduce a (possibly arbitrary) order into the set of points on which ${\displaystyle \sigma }$ acts.

## Generalizations

Parity can be generalized to Coxeter groups: one defines a length function ${\displaystyle l(v),}$ which depends on a choice of generators (for the symmetric group, adjacent transpositions), and then the function ${\displaystyle v\mapsto (-1)^{l(v)}}$ gives a generalized sign map.