Inversion (discrete mathematics)

A permutation, its inversion set and its left inversion count

Inversion is a concept in discrete mathematics to measure how much a sequence is out of its natural order.

(An inversion of a permutation is not to be confused with the inverse of a permutation. Also not with point reflection.)

## Definitions

[edit | edit source]

Map from the place-based to the element-based inversions of a permutation of four elements The element-based inversion multiset of this sequence contains (2,1) twice.

A permutation  π {\displaystyle \pi } has an inversion for each pair of elements that are out of their natural order, i.e. when  i < j {\displaystyle i<j} but  π ( i ) > π ( j ) {\displaystyle \pi (i)>\pi (j)} .
It may be identified by the pair of places  ( i , j ) {\displaystyle (i,j)} or by the pair of elements  ( π ( i ) , π ( j ) ) {\displaystyle {\bigl (}\pi (i),\pi (j){\bigr )}} .
This article favours the former convention (although the latter seems to be more common).

The inversion set of a permutation is the set of all its inversions.
For an  n {\displaystyle n} -element permutation the number of potential elements is the triangular number ( n 2 ) {\displaystyle \scriptstyle {n \choose 2}} .

The element-based inversion set is essentially the place-based inversion set of the inverse permutation, just with the elements of the pairs exchanged.

For sequences the element-based inversion set has to be defined as a multiset, as many pairs of places can have the same pair of elements.

The permutation graph has the elements of the permutation as vertices and an edge between elements that are out of order,
i.e. an edge is an inversion according to the element-based definition:  { π ( i ) , π ( j ) } {\displaystyle \\{\pi (i),\pi (j)\\}} is an edge iff  i < j ∧ π ( i ) > π ( j ) {\displaystyle i<j~~\land ~~\pi (i)>\pi (j)} .
It is more common to write that  { i , j } {\displaystyle \\{i,j\\}} is an edge iff  i < j ∧ π − 1 ( i ) > π − 1 ( j ) {\displaystyle i<j~~\land ~~\pi ^{-1}(i)>\pi ^{-1}(j)} . The latter is often written as  ( i − j ) ⋅ ( π − 1 ( i ) − π − 1 ( j ) ) < 0 {\displaystyle (i-j)\cdot {\bigl (}\pi ^{-1}(i)-\pi ^{-1}(j){\bigr )}<0} .

The permutation graphs of inverse permutations are isomorphic. That of  π − 1 {\displaystyle \pi ^{-1}} can be generated from that of  π {\displaystyle \pi } by changing each vertex  i {\displaystyle i} to  π ( i ) {\displaystyle \pi (i)} .

It seems that the permutation graph is only defined with place-based inversions. If it were generalized to apply to sequences, it would thus have to be defined as a multigraph.

The inversion number ( A034968 ) is the cardinality of the inversion set;
thus also the digit sum of the inversion related vectors;
and also the number of crossings in the arrow diagram of the permutation.

The parity of a permutation is the parity of its inversion number.
The sign of a permutation (the determinant of its matrix) corresponds to the parity: Even permutations have sign 1, odd permutations sign −1.

### Inversion related vectors

[edit | edit source]

There are four ways to condense the inversions of a permutation into a vector that uniquely determines it. Three of them are in use. (See sources below).

This article uses the terms left inversion count (l) and right inversion count (r) like Gnedin (similar to Calude and Deutsch), and the term inversion vector (v) like Wolfram.

The left and right inversion counts have the feature that interpreted as factorial numbers they determine the permutation's reverse colexicographic and lexicographic index.
The inversion vector does not appear to have a similar advantage, but it is widely used anyway.

Left inversion count l:
With the place-based definition  l ( i ) {\displaystyle l(i)} is the number of inversions whose bigger (right) component is  i {\displaystyle i} .

l ( i ) {\displaystyle l(i)} is the number of elements in  π {\displaystyle \pi } greater than  π ( i ) {\displaystyle \pi (i)} before  π ( i ) {\displaystyle \pi (i)} .
l ( i ) = # { k ∣ k < i ∧ π ( k ) > π ( i ) } {\displaystyle l(i)~~=~~\\#\left\\{k\mid k<i~\land ~\pi (k)>\pi (i)\right\\}}

Right inversion count r, often called Lehmer code:
With the place-based definition  r ( i ) {\displaystyle r(i)} is the number of inversions whose smaller (left) component is  i {\displaystyle i} .

r ( i ) {\displaystyle r(i)} is the number of elements in  π {\displaystyle \pi } smaller than  π ( i ) {\displaystyle \pi (i)} after  π ( i ) {\displaystyle \pi (i)} .
r ( i ) = # { k ∣ k > i ∧ π ( k ) < π ( i ) } {\displaystyle r(i)~~=~~\\#\\{k\mid k>i~\land ~\pi (k)<\pi (i)\\}}

Inversion vector v:
With the element-based definition  v ( i ) {\displaystyle v(i)} is the number of inversions whose smaller (right) component is  i {\displaystyle i} .

v ( i ) {\displaystyle v(i)} is the number of elements in  π {\displaystyle \pi } greater than  i {\displaystyle i} before  i {\displaystyle i} .
v ( i ) = # { k ∣ k > i ∧ π − 1 ( k ) < π − 1 ( i ) } {\displaystyle v(i)~~=~~\\#\\{k\mid k>i~\land ~\pi ^{-1}(k)<\pi ^{-1}(i)\\}}

A different way to say the same thing may be more intuitive:

v ( π ( i ) ) {\displaystyle v{\bigl (}\pi (i){\bigr )}} is the number of elements in  π {\displaystyle \pi } greater than  π ( i ) {\displaystyle \pi (i)} before  π ( i ) {\displaystyle \pi (i)} .
v ( π ( i ) ) = # { k ∣ k < i ∧ π ( k ) > π ( i ) } = l ( i ) {\displaystyle v{\bigl (}\pi (i){\bigr )}~~=~~\\#\\{k\mid k<i~\land ~\pi (k)>\pi (i)\\}~~~~~~~~~~~~~~~~=~~l(i)}

The latter definition would also work for a sequence, which does not have an inverse.

Python functions

def left_inversion_count(p):
n = len(p)
v = [0] * n
for i in range(n):
count = 0
for k in range(i):
if p[k] > p[i]:
count += 1
v[i] = count
return v

def right_inversion_count(p):
n = len(p)
v = [0] * n
for i in range(n):
count = 0
for k in range(i, n):
if p[k] < p[i]:
count += 1
v[i] = count
return v

def inversion_vector(p_raw):
if min(p_raw) == 1:  # assuming 1-based permutation
p = [entry-1 for entry in p_raw]
else:  # assuming 0-based permutation
p = p_raw
n = len(p)
v = [0] * n
for i in range(n):
count = 0
for k in range(i):
if p[k] > p[i]:
count += 1
v[p[i]] = count
return v

Relationship between l and v:

v = l . π = l ( π − 1 ) {\displaystyle v~~=~~l.\pi ~~=~~l(\pi ^{-1})}
|  ⇔ {\displaystyle \Leftrightarrow } |  v ( i ) = l ( π − 1 ( i ) ) {\displaystyle v(i)~~=~~l{\bigl (}\pi ^{-1}(i){\bigr )}} | (vector  x {\displaystyle x} permuted by  α {\displaystyle \alpha } is  x . α = x ( α − 1 ) {\displaystyle x.\alpha =x(\alpha ^{-1})} , compare Permutation notation)

|
|
|

l = v . π − 1 = v ( π ) {\displaystyle l~~=~~v.\pi ^{-1}~~=~~v(\pi )}
|  ⇔ {\displaystyle \Leftrightarrow } |  l ( i ) = v ( π ( i ) ) {\displaystyle l(i)~~=~~v{\bigl (}\pi (i){\bigr )}} |

The first digit of l and the last digit of v are always 0, and can be omitted.
When these vectors are permuted into each other, the omissible 0 from one does not necessarily become the omissible 0 in the other.

Relationship between r and v:
Both r and v can be found with the help of a Rothe diagram,
which is a permutation matrix with the 1s represented by dots, and an inversion in every position that has a dot to the right and below it.
r ( i ) {\displaystyle r(i)} is the sum of inversions in row  i {\displaystyle i} of the Rothe diagram, while  v ( i ) {\displaystyle v(i)} is the sum of inversions in column  i {\displaystyle i} .
The permutation matrix of the inverse is the transpose. Therefore v of a permutation is r of its inverse, and vice versa.

Relationship between r and l:

π ( i ) = i + r ( i ) − l ( i ) {\displaystyle \pi (i)~~=~~i+r(i)-l(i)}

This is proven in Gnedin & Olshanski 2012, and mentioned as `R[i]+i=p[i]+L[i]` in  A138159.

Permutations that are equal up to fixed points can be seen as equal. Equivalently, inversion related vectors that are equal up to trailing 0s can be seen as equal.
While for r and v the omissible 0 on the right is part of the trailing 0s, for l the omissible 0 on the left is separate from them.

## Example: Permutations of six elements

[edit | edit source]

The following images show two inverse permutations, their 9 inversions and the corresponding vectors.

v = l . π = l ( π − 1 ) {\displaystyle v=l.\pi =l(\pi ^{-1})}
v ( 3 ) = l ( π − 1 ( 3 ) ) = l ( 5 ) = 3 {\displaystyle v(3)=l(\pi ^{-1}(3))=l(5)=3} l = v . π − 1 = v ( π ) {\displaystyle l=v.\pi ^{-1}=v(\pi )}
l ( 3 ) = v ( π ( 3 ) ) = v ( 4 ) = 1 {\displaystyle l(3)=v(\pi (3))=v(4)=1} |  π = 674 = ( 1 2 5 3 4 6 ) = ( 1 2 3 4 5 6 2 5 4 6 3 1 ) {\displaystyle {\begin{aligned}\pi &={\mathit {674}}\\\&=(1~2~5~3~4~6)\\\&={\begin{pmatrix}1&2&3&4&5&6\\\2&5&4&6&3&1\end{pmatrix}}\end{aligned}}}

Permutation matrix | Rothe diagram | Place-based inversion set

l = (0, 0, 1, 0, 3, 5)
rev colex rank: 530100! = 674
r = (1, 3, 2, 2, 1, 0)
lex rank: 132210! = 209

| Element-based inversion set
Permutation graph

|
|
|
|

Formulas

|  |
|  |
v = l . π = l ( π − 1 ) {\displaystyle v=l.\pi =l(\pi ^{-1})}
v ( 3 ) = l ( π − 1 ( 3 ) ) = l ( 4 ) = 2 {\displaystyle v(3)=l(\pi ^{-1}(3))=l(4)=2} l = v . π − 1 = v ( π ) {\displaystyle l=v.\pi ^{-1}=v(\pi )}
l ( 3 ) = v ( π ( 3 ) ) = v ( 5 ) = 1 {\displaystyle l(3)=v(\pi (3))=v(5)=1} |  π = 327 = ( 1 6 4 3 5 2 ) = ( 1 2 3 4 5 6 6 1 5 3 2 4 ) {\displaystyle {\begin{aligned}\pi &={\mathit {327}}\\\&=(1~6~4~3~5~2)\\\&={\begin{pmatrix}1&2&3&4&5&6\\\6&1&5&3&2&4\end{pmatrix}}\end{aligned}}}

Permutation matrix | Rothe diagram | Place-based inversion set

l = (0, 1, 1, 2, 3, 2)
rev colex rank: 232110! = 327
r = (5, 0, 3, 1, 0, 0)
lex rank: 503100! = 620

| Element-based inversion set
Permutation graph

|
|
|
|

Mathematica omits the 0 at the end of the inversion vector. Compare p1 and p2 in Wolfram Alpha.

I: p1 = {2,5,4,6,3,1}
I: p2 = {6,1,5,3,2,4}

I: ToInversionVector[p1]
O: {5,0,3,1,0}
I: ToInversionVector[p2]
O: {1,3,2,2,1}

I: ToOrderedPairs[PermutationGraph[p1]]
O: {{2,1},{3,1},{4,1},{5,1},{6,1},{4,3},{5,3},{6,3},{5,4},{1,2},{1,3},{1,4},{1,5},{1,6},{3,4},{3,5},{3,6},{4,5}}
I: ToOrderedPairs[PermutationGraph[p2]]
O: {{6,1},{3,2},{5,2},{6,2},{5,3},{6,3},{5,4},{6,4},{6,5},{1,6},{2,3},{2,5},{2,6},{3,5},{3,6},{4,5},{4,6},{5,6}}

## Example: All permutations of four elements

[edit | edit source]

The six possible inversions of a 4-element permutation

The following sortable table shows the 24 permutations of four elements with their place-based inversion sets, inversion related vectors and inversion numbers.

It is shown twice, so different orders can be compared to each other. (The Python script used to create it is shown here.)

The columns with small text are the reflections of the main columns. Sorting by them gives the colexicographic order of the corresponding main column.

Inversion vector v and left inversion count l are shown next to each other, because they have the same digits.

Left and right inversion counts are related to the place-based inversion sets shown between them:
The nontrivial elements of l are the sums of the descending diagonals of the triangle, and those of r are the sums of the of the ascending diagonals.

The default order of the table is the reverse colex order by  π {\displaystyle \pi } , which is the same as the colex order by l. (This header cell is highlighted by a darker gray.)

Lex order by  π {\displaystyle \pi } is the same as lex order by r.

Ordering one table by r and the other one by v brings inverse permutations next to each other, i.e. those whose matrices are reflected at the main diagonal.

Ordering one table by reflected l and the other one by v brings permutations next to each other whose permutation matrices are reflected at the antidiagonal.

Ordering one table by reflected l and the other one by r brings permutations next to each other whose permutation matrices are rotated by 180°.
(It can be seen, that these permutations' inversion sets are symmetric to each other, which corresponds to l and r being symmetric to each other.)

Note that the set of all r, the set of all v and the set of all reflected l for the same symmetric group are equal.
So sorting by two columns that have the omissible 0 at the same end makes these columns equal.

3-element permutations

|  |  |

|  | π |  | v |  |  | l | p-b  | r |  | #

|
|
|
|
|
|
|
|
|
|

0 |  | 123 | 321 | 000 | 000 | 000 | 000 |  | 000 | 000 | 0
1 |  | 213 | 312 | 100 | 001 | 010 | 010 |  | 100 | 001 | 1
2 |  | 132 | 231 | 010 | 010 | 100 | 001 |  | 010 | 010 | 1
3 |  | 312 | 213 | 110 | 011 | 110 | 011 |  | 200 | 002 | 2
4 |  | 231 | 132 | 200 | 002 | 200 | 002 |  | 110 | 011 | 2
5 |  | 321 | 123 | 210 | 012 | 210 | 012 |  | 210 | 012 | 3
|  |

|  | π |  | v |  |  | l | p-b  | r |  | #

|
|
|
|
|
|
|
|
|
|

0 |  | 123 | 321 | 000 | 000 | 000 | 000 |  | 000 | 000 | 0
1 |  | 213 | 312 | 100 | 001 | 010 | 010 |  | 100 | 001 | 1
2 |  | 132 | 231 | 010 | 010 | 100 | 001 |  | 010 | 010 | 1
3 |  | 312 | 213 | 110 | 011 | 110 | 011 |  | 200 | 002 | 2
4 |  | 231 | 132 | 200 | 002 | 200 | 002 |  | 110 | 011 | 2
5 |  | 321 | 123 | 210 | 012 | 210 | 012 |  | 210 | 012 | 3
|  |

|  | π |  | v |  |  | l | p-b  | r |  | #

|
|
|
|
|
|
|
|
|
|

0 |  | 1234 | 4321 | 0000 | 0000 | 0000 | 0000 |  | 0000 | 0000 | 0
1 |  | 2134 | 4312 | 1000 | 0001 | 0010 | 0100 |  | 1000 | 0001 | 1
2 |  | 1324 | 4231 | 0100 | 0010 | 0100 | 0010 |  | 0100 | 0010 | 1
3 |  | 3124 | 4213 | 1100 | 0011 | 0110 | 0110 |  | 2000 | 0002 | 2
4 |  | 2314 | 4132 | 2000 | 0002 | 0200 | 0020 |  | 1100 | 0011 | 2
5 |  | 3214 | 4123 | 2100 | 0012 | 0210 | 0120 |  | 2100 | 0012 | 3
6 |  | 1243 | 3421 | 0010 | 0100 | 1000 | 0001 |  | 0010 | 0100 | 1
7 |  | 2143 | 3412 | 1010 | 0101 | 1010 | 0101 |  | 1010 | 0101 | 2
8 |  | 1423 | 3241 | 0110 | 0110 | 1100 | 0011 |  | 0200 | 0020 | 2
9 |  | 4123 | 3214 | 1110 | 0111 | 1110 | 0111 |  | 3000 | 0003 | 3
10 |  | 2413 | 3142 | 2010 | 0102 | 1200 | 0021 |  | 1200 | 0021 | 3
11 |  | 4213 | 3124 | 2110 | 0112 | 1210 | 0121 |  | 3100 | 0013 | 4
12 |  | 1342 | 2431 | 0200 | 0020 | 2000 | 0002 |  | 0110 | 0110 | 2
13 |  | 3142 | 2413 | 1200 | 0021 | 2010 | 0102 |  | 2010 | 0102 | 3
14 |  | 1432 | 2341 | 0210 | 0120 | 2100 | 0012 |  | 0210 | 0120 | 3
15 |  | 4132 | 2314 | 1210 | 0121 | 2110 | 0112 |  | 3010 | 0103 | 4
16 |  | 3412 | 2143 | 2200 | 0022 | 2200 | 0022 |  | 2200 | 0022 | 4
17 |  | 4312 | 2134 | 2210 | 0122 | 2210 | 0122 |  | 3200 | 0023 | 5
18 |  | 2341 | 1432 | 3000 | 0003 | 3000 | 0003 |  | 1110 | 0111 | 3
19 |  | 3241 | 1423 | 3100 | 0013 | 3010 | 0103 |  | 2110 | 0112 | 4
20 |  | 2431 | 1342 | 3010 | 0103 | 3100 | 0013 |  | 1210 | 0121 | 4
21 |  | 4231 | 1324 | 3110 | 0113 | 3110 | 0113 |  | 3110 | 0113 | 5
22 |  | 3421 | 1243 | 3200 | 0023 | 3200 | 0023 |  | 2210 | 0122 | 5
23 |  | 4321 | 1234 | 3210 | 0123 | 3210 | 0123 |  | 3210 | 0123 | 6
|  |

|  | π |  | v |  |  | l | p-b  | r |  | #

|
|
|
|
|
|
|
|
|
|

0 |  | 1234 | 4321 | 0000 | 0000 | 0000 | 0000 |  | 0000 | 0000 | 0
1 |  | 2134 | 4312 | 1000 | 0001 | 0010 | 0100 |  | 1000 | 0001 | 1
2 |  | 1324 | 4231 | 0100 | 0010 | 0100 | 0010 |  | 0100 | 0010 | 1
3 |  | 3124 | 4213 | 1100 | 0011 | 0110 | 0110 |  | 2000 | 0002 | 2
4 |  | 2314 | 4132 | 2000 | 0002 | 0200 | 0020 |  | 1100 | 0011 | 2
5 |  | 3214 | 4123 | 2100 | 0012 | 0210 | 0120 |  | 2100 | 0012 | 3
6 |  | 1243 | 3421 | 0010 | 0100 | 1000 | 0001 |  | 0010 | 0100 | 1
7 |  | 2143 | 3412 | 1010 | 0101 | 1010 | 0101 |  | 1010 | 0101 | 2
8 |  | 1423 | 3241 | 0110 | 0110 | 1100 | 0011 |  | 0200 | 0020 | 2
9 |  | 4123 | 3214 | 1110 | 0111 | 1110 | 0111 |  | 3000 | 0003 | 3
10 |  | 2413 | 3142 | 2010 | 0102 | 1200 | 0021 |  | 1200 | 0021 | 3
11 |  | 4213 | 3124 | 2110 | 0112 | 1210 | 0121 |  | 3100 | 0013 | 4
12 |  | 1342 | 2431 | 0200 | 0020 | 2000 | 0002 |  | 0110 | 0110 | 2
13 |  | 3142 | 2413 | 1200 | 0021 | 2010 | 0102 |  | 2010 | 0102 | 3
14 |  | 1432 | 2341 | 0210 | 0120 | 2100 | 0012 |  | 0210 | 0120 | 3
15 |  | 4132 | 2314 | 1210 | 0121 | 2110 | 0112 |  | 3010 | 0103 | 4
16 |  | 3412 | 2143 | 2200 | 0022 | 2200 | 0022 |  | 2200 | 0022 | 4
17 |  | 4312 | 2134 | 2210 | 0122 | 2210 | 0122 |  | 3200 | 0023 | 5
18 |  | 2341 | 1432 | 3000 | 0003 | 3000 | 0003 |  | 1110 | 0111 | 3
19 |  | 3241 | 1423 | 3100 | 0013 | 3010 | 0103 |  | 2110 | 0112 | 4
20 |  | 2431 | 1342 | 3010 | 0103 | 3100 | 0013 |  | 1210 | 0121 | 4
21 |  | 4231 | 1324 | 3110 | 0113 | 3110 | 0113 |  | 3110 | 0113 | 5
22 |  | 3421 | 1243 | 3200 | 0023 | 3200 | 0023 |  | 2210 | 0122 | 5
23 |  | 4321 | 1234 | 3210 | 0123 | 3210 | 0123 |  | 3210 | 0123 | 6

(A more detailled version of this table, including element-based inversion sets and the unused fourth vector, can be found here.)

## Weak order of permutations

[edit | edit source]

The Hasse diagram below in the middle shows the 24 inversion sets ordered by the subset relation.

If a permutation is assigned to each inversion set using the place-based definition, the resulting order of permutations is that of the permutohedron,
where  ( π , σ ) {\displaystyle (\pi ,\sigma )} is an edge iff  i < j ∧ π ( i ) + 1 = π ( j ) ∧ ( i j ) ⋅ π = σ {\displaystyle i<j~~\land ~~\pi (i)+1=\pi (j)~~\land ~~(ij)\cdot \pi =\sigma } , i.e. when only two elements with consecutive values are swapped.
(In the central diagram it can be seen on which positions the swapped elements are, by looking which digit changes for the edge.)

The bitwise  ≤ {\displaystyle \leq } ordering of the left and right inversion counts of these permutations gives the same order (because both are diagonal sums of the inversion set triangles).

Permutations and left inversion counts l | Inversion sets (place-based) | Permutations and right inversion counts r

|
|

Schlegel diagrams of the permutohedra above

| Permutations and left inversion counts l | Inversion sets (place-based) | Permutations and right inversion counts r

|
|

If a permutation were assigned to each inversion set using the element-based definition, the resulting order of permutations would be that of a Cayley graph,
where  ( π , σ ) {\displaystyle (\pi ,\sigma )} is an edge iff  i + 1 = j ∧ π ( i ) < π ( j ) ∧ ( i j ) ⋅ π = σ {\displaystyle i+1=j~~\land ~~\pi (i)<\pi (j)~~\land ~~(ij)\cdot \pi =\sigma } , i.e. when only two elements on consecutive places are swapped.

This Cayley graph of the symmetric group is similar to its permutohedron, but with each permutation replaced by its inverse.

Cayley graph

| Cayley graph as a Schlegel diagram |

The Cayley graph on the right shows the inverse permutations of those in the permutohedron above it.

Below their v are shown. They are the same vectors as the r in the permutohedron above (because the r is the v of the inverse permutation).

There are 12 edges of each color, and each represents the swapping of two elements on consecutive places — e.g. blue stands for the swapping of the elements on the first two places.

The six squares of the truncated octahedron have blue and red edges, and the edges connecting the squares are green. Four of the eight hexagons have blue and four have red edges.

| Inverse permutations and inversion vectors v

|
|

##  Inversions in sequences

[edit | edit source]

For sequences inversion sets and the related vectors are not unique. Their place-based inversion sets are multisets, and their inversion vectors can have bigger digits than would be allowed in a factorial number.

|  | S |  | #  |  | l |  | p-b  |  | r |  |  | u | e-b  |  | v |

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

5 |

| 0011 | 1100 | 0 | 0000 | 0000 | . .. ... |  | ... .. . | 0000 | 0000 | 0000 | 0000 | . .. ... | ... .. . | 0000 | 0000
17 |

| 0101 | 1010 | 1 | 0100 | 0010 | . .1 ... |  | ... 1. . | 0100 | 0010 | 0010 | 0100 | 1 .. ... | ... .. 1 | 1000 | 0001
20 |

| 0110 | 0110 | 2 | 2000 | 0002 | . .. .11 |  | 11\. .. . | 0110 | 0110 | 0020 | 0200 | 2 .. ... | ... .. 2 | 2000 | 0002
65 |

| 1001 | 1001 | 2 | 0110 | 0110 | 1 1. ... |  | ... .1 1 | 2000 | 0002 | 0020 | 0200 | 2 .. ... | ... .. 2 | 2000 | 0002
68 |

| 1010 | 0101 | 3 | 2010 | 0102 | 1 .. 1.1 |  | 1.1 .. 1 | 2010 | 0102 | 0030 | 0300 | 3 .. ... | ... .. 3 | 3000 | 0003
80 |

| 1100 | 0011 | 4 | 2200 | 0022 | . 11 11. |  | .11 11 . | 2200 | 0022 | 0040 | 0400 | 4 .. ... | ... .. 4 | 4000 | 0004

##  Arrays of permutations

[edit | edit source]

Similar permutations have similar inversion sets and corresponding vectors.

Some can be ordered in arrays, like the one on the right, corresponding to the number triangle  A211367.

##  Walsh permutations

[edit | edit source]

wp(4,8,1,2) = (0,4,8,12, 1,5,9,13, 2,6,10,14, 3,7,11,15)

r = v = (0,3,6,9, 0,2,4,6, 0,1,2,3, 0,0,0,0)
l = (0,0,0,0, 3,2,1,0, 6,4,2,0, 9,6,3,0)

wp(14,13,11,7) = (0,14,13,3, 11,5,6,8, 7,9,10,4, 12,2,1,15)

r = v = (0,13,12,2, 9,3,3,4, 3,3,3,2, 2,1,0,0)
l = (0,0,1,2, 2,3,3,3, 4,3,3,9, 2,12,13,0)

wp(13,11, 7,15) = (0,15,14,1, 13,2,3,12, 11,4,5,10, 6,9,8,7)

r = (0,14,13,0, 11,0,0,8, 7,0,0,4, 0,2,1,0)
v = (0,2,3,3, 5,5,6,8, 7,6,5,4, 3,2,1,0)
l = (0,0,1,2, 2,3,3,3, 4,5,5,5, 6,6,7,8)

|
|

## Sources

[edit | edit source]

### Books

[edit | edit source]

#### Cramer 1750

[edit | edit source]

Cramer defines the inversion under the name dérangement to calculate the sign of a permutation.

For the permutation 3 1 2 the dérangements are given as 3 before 1 and 3 before 2.

Cramer, Gabriel: Introduction à l'analyse des lignes courbes algébriques. Genève : chez les Frères Cramer & Cl. Philibert 1750 — Appendice (p. 658)

Chabert (1999). A history of algorithms : from the pebble to the microchip. Berlin New York: Springer. ISBN 9783540633693. — 9.1 Cramers rule (p. 286)

#### Rothe 1800

[edit | edit source]

Rothe essentially defines the right inversion count r under the name Stellenexponenten — but with each place bigger by 1.

s i {\displaystyle s_{i}} is the position of  π i {\displaystyle \pi _{i}} among the  π k {\displaystyle \pi _{k}} with  k ≥ i {\displaystyle k\geq i} in numerical order. (p. 163)

Strangely he counts from 1 rather than 0, which later leads to avoidable additions and subtractions by 1:

s i + 1 = # { π k ∣ k > i ∧ π k < π i } {\displaystyle s_{i}+1=\\#\\{\pi _{k}\mid k>i\land \pi _{k}<\pi _{i}\\}} (p. 165)
Each permutation has sign + {\displaystyle +} when the sum of the  s i − 1 {\displaystyle s_{i}-1} is even, and sign  − {\displaystyle -} when it is odd. (p. 266)

For the permutation  6 4 3 9 8 10 1 7 2 5 {\displaystyle 6~4~3~9~8~10~1~7~2~5} the Stellenexponenten are given as  6 4 3 6 5 5 1 3 1 1 {\displaystyle 6~4~3~6~5~5~1~3~1~1} .

Muir translates Stellenexponent as place-index and calls it “an ill-advised and purposeless modification of Cramers idea of a ‘derangement’”. (The Theory of the Determinant..., p. 55)

"Ueber Permutationen, in Beziehung auf die Stellen ihrer Elemente. Anwendung der daraus abgeleiteten Satze auf das Eliminationsproblem". In Hindenburg, Carl, ed., Sammlung Combinatorisch-Analytischer Abhandlungen, pp. 263–305, Bey G. Fleischer dem jüngern, 1800.

#### Laisant 1888

[edit | edit source]

After defining the factorial number system Laisant defines the right inversion count r under the name signe figuratif.

For the permutation  4 3 6 5 1 2 {\displaystyle 4~3~6~5~1~2} the signe figuratif is given as  ( 3 2 3 2 0 ) {\displaystyle (3~2~3~2~0)} .

Laisant, Charles-Ange (1888), "Sur la numération factorielle, application aux permutations", Bulletin de la Société Mathématique de France (in French), 16: 176–183

#### Aigner 2007

[edit | edit source]

p-b perm

> Now we look at permutations of  { 1 , 2 , . . . , n } {\displaystyle \\{1,2,...,n\\}} in word form  σ = a 1 , a 2 . . . a n , a i = σ ( i ) {\displaystyle \sigma =a_{1},a_{2}...a_{n},a_{i}=\sigma (i)} .
>  The pair  { i , j } {\displaystyle \\{i,j\\}} is called an inversion if  i < j {\displaystyle i<j} but  a i > a j {\displaystyle a_{i}>a_{j}} .

> A moment's thought shows that  { i , j } {\displaystyle \\{i,j\\}} is an inversion if and only if the edges  i a i {\displaystyle ia_{i}} and  j a j {\displaystyle ja_{j}} cross in the diagram.
>  Hence the inversion number  i n v ( σ ) {\displaystyle inv(\sigma )} equals the number of crossings.

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

#### Comtet 1974

[edit | edit source]

p-b perm

> An inversion of a permutation  σ ∈ S [ n ] {\displaystyle \sigma \in {\mathfrak {S}}[n]} is a pair  ( i , j ) {\displaystyle (i,j)} such that  1 ≤ i < j ≤ n {\displaystyle 1\leq i<j\leq n} and  σ ( i ) > σ ( j ) {\displaystyle \sigma (i)>\sigma (j)} . In this case we say that  σ {\displaystyle \sigma } has an inversion in  ( i , j ) {\displaystyle (i,j)} .

He uses the same definition for a non-bijective map in exercise 21 on permutations (p. 266).

Comtet, Louis (1974). Advanced combinatorics; the art of finite and infinite expansions. Dordrecht,Boston: D. Reidel Pub. Co. ISBN 9027704414. — 6.4 Inversions of a permutation of [n] (p. 237)

#### Cormen et al. 2001

[edit | edit source]

p-b seq

> Let  A [ 1.. n ] {\displaystyle A[1..n]} be an array of n distinct numbers. If  i < j {\displaystyle i<j} and  A [ i ] > A [ j ] {\displaystyle A[i]>A[j]} , then the pair  ( i , j ) {\displaystyle (i,j)} is called an inversion of  A {\displaystyle A} .

Cormen, Thomas (2001). Introduction to algorithms. Cambridge, Mass: MIT Press. ISBN 0262531968. — 2-4 Inversions (p. 41) and 5.2-5 (p. 122)

#### Knuth 1973

[edit | edit source]

e-b perm
v as inversion table

> If  i < j {\displaystyle i<j} and  a i > a j {\displaystyle a_{i}>a_{j}} , the pair  ( a i , a j ) {\displaystyle (a_{i},a_{j})} is called an inversion of the permutation; for example the permutation 3 1 4 2 has three inversions: (3, 1), (3, 2) and (4, 2).

> The inversion table b 1 b 2 . . . b n {\displaystyle b_{1}b_{2}...b_{n}} of the permutation  a 1 a 2 . . . a n {\displaystyle a_{1}a_{2}...a_{n}} is obtained by letting  b j {\displaystyle b_{j}} be the number of elements to the left of  j {\displaystyle j} that are greater than  j {\displaystyle j} .
>  In other words,  b j {\displaystyle b_{j}} is the number of inversions whose second component is  j {\displaystyle j} .

Knuth, Donald (1973). The art of computer programming. Reading, Mass: Addison-Wesley Pub. Co. ISBN 0201896850. — 5.1.1 Inversions (p. 11)

#### Pemmaraju & Skiena 2003

[edit | edit source]

e-b perm
v as inversion vector

> A pair of elements  ( π ( i ) , π ( j ) ) {\displaystyle (\pi (i),\pi (j))} in a permutation  π {\displaystyle \pi } represents an inversion if  i > j {\displaystyle i>j} and  π ( i ) < π ( j ) {\displaystyle \pi (i)<\pi (j)} .
>  An inversion is a pair of elements that are out of order [...]

> For any  n {\displaystyle n} -permutation  π {\displaystyle \pi } , we can define an inversion vector v {\displaystyle v} as follows. For each integer  i {\displaystyle i} ,  1 ≤ i ≤ n − 1 {\displaystyle 1\leq i\leq n-1} , the  i {\displaystyle i} th element of  v {\displaystyle v} is the number of elements in  π {\displaystyle \pi } greater than  i {\displaystyle i} to the left of  i {\displaystyle i} .

Pemmaraju, Sriram (2003). Computational discrete mathematics : combinatorics and graph theory with Mathematica. Cambridge, U.K. New York: Cambridge University Press. ISBN 9780521806862. — 2.2 Inversions and Inversion Vectors (p. 69)

#### Vitter & Flajolet 1990

[edit | edit source]

e-b perm
v as inversion table

> An inversion in permutation  σ {\displaystyle \sigma } is an “out of order” pair  ( σ k , σ j ) {\displaystyle (\sigma _{k},\sigma _{j})} of elements, in which  k < j {\displaystyle k<j} but  σ k > σ j {\displaystyle \sigma _{k}>\sigma _{j}} .
>  The number of inversions is thus a measure of the amount of disorder in a permutation.

> The inversion table of the permutation  σ = σ 1 σ 2 … σ n {\displaystyle \sigma =\sigma _{1}\sigma _{2}\dots \sigma _{n}} is the ordered sequence

>      b 1 , b 2 , … , b n {\displaystyle b_{1},b_{2},\dots ,b_{n}} , where  b k = | { 1 ≤ j < σ k − 1 | σ j > k } | {\displaystyle b_{k}={\Big |}\\{1\leq j<\sigma _{k}^{-}1|\sigma _{j}>k\\}{\Big |}} .

Leeuwen, J (1990). Handbook of theoretical computer science. Amsterdam New York Cambridge, Mass: Elsevier MIT Press. ISBN 9780444880710. — 3.1 Inversions (p. 459)

#### Grätzer 2016

[edit | edit source]

e-b perm

The authors define the usual strict linear ordering  1 < 2 < ⋯ < i < i + 1 < ⋯ < n {\displaystyle 1<2<\cdots <i<i+1<\cdots <n} on  [ n ] {\displaystyle [n]} as  I n = { ( i , j ) ∈ [ n ] × [ n ] | i < j } {\displaystyle {\mathcal {I}}_{n}=\\{~~(i,j)\in [n]\times [n]~~|~~i<j~~\\}} .

> Let  σ {\displaystyle \sigma } be a permutation on  [ n ] {\displaystyle [n]} . An inversion of  σ {\displaystyle \sigma } is an ordered pair  ( i , j ) ∈ I n {\displaystyle (i,j)\in {\mathcal {I}}_{n}} satisfying  σ − 1 ( i ) > σ − 1 ( j ) {\displaystyle \sigma ^{-1}(i)>\sigma ^{-1}(j)} .
>  The inversion set of  σ {\displaystyle \sigma } is then defined as  i n v ( σ ) = { ( i , j ) ∈ I n | σ − 1 ( i ) > σ − 1 ( j ) } {\displaystyle \mathrm {inv} (\sigma )=\\{~~(i,j)\in {\mathcal {I}}_{n}~~|~~\sigma ^{-1}(i)>\sigma ^{-1}(j)~~\\}} .

The inversion set of  ( 1 2 3 4 5 3 5 4 1 2 ) {\displaystyle {\begin{pmatrix}1&2&3&4&5\\\3&5&4&1&2\end{pmatrix}}} is given as  { ( 1 , 3 ) , ( 1 , 4 ) , ( 1 , 5 ) , ( 2 , 3 ) , ( 2 , 4 ) , ( 2 , 5 ) , ( 4 , 5 ) } {\displaystyle \\{(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(4,5)\\}} .

In the footnote it is mentioned that other authors often use the definition as an ordered pair  ( i , j ) ∈ I n {\displaystyle (i,j)\in {\mathcal {I}}_{n}} such that  σ ( i ) > σ ( j ) {\displaystyle \sigma (i)>\sigma (j)} .
TAoCP is given as an example — despite the fact that Knuth uses essentially the same definition (see above).

Gratzer, George (2016). Lattice theory. special topics and applications. Cham, Switzerland: Birkhäuser. ISBN 331944235X. — 7-2 Basic objects (p. 221)

#### Joshi 1989

[edit | edit source]

e-b seq
r as inversion table or inversion vector

> Let  x = x 1 x 2 … x n {\displaystyle x=x_{1}x_{2}\dots x_{n}} be a sequence of real numbers.
>  By an inversion in  x {\displaystyle x} , we mean a pair  ( x i , x j ) {\displaystyle (x_{i},x_{j})} such that  i < j {\displaystyle i<j} but  x i > x j {\displaystyle x_{i}>x_{j}} .
>  For each  i {\displaystyle i} , let  d i {\displaystyle d_{i}} = the number of inversions whose first entry is  x i {\displaystyle x_{i}} , i.e.

>      d i = | { x j : i < j , x i > x j } | {\displaystyle d_{i}={\big |}\\{x_{j}:i<j,x_{i}>x_{j}\\}{\big |}} .

> Then the sequence  ( d 1 d 2 … d n ) {\displaystyle (d_{1}d_{2}\dots d_{n})} is called the inversion table or inversion vector of  x {\displaystyle x} . [...]
>  The permutation  2 4 3 5 1 {\displaystyle 2~4~3~5~1} has  ( 1 , 2 , 1 , 1 , 0 ) {\displaystyle (1,2,1,1,0)} as its inversion table.

Joshi, K. D. (1989). Foundations of discrete mathematics. New York New Delhi, India: Wiley Wiley Eastern Ltd. ISBN 8122401201. — Definition 3.12 (p. 188)

#### Bóna 2012

[edit | edit source]

e-b perm

Bóna first uses the definition with elements:

> Let  p = p 1 p 2 ⋯ p n {\displaystyle p=p_{1}p_{2}\cdots p_{n}} be a permutation. We say that  ( p i , p j ) {\displaystyle (p_{i},p_{j})} is an inversion of  p {\displaystyle p} if  i < j {\displaystyle i<j} but  p i > p j {\displaystyle p_{i}>p_{j}} .
>  Permutation 31524 has four inversions, namely (3, 1), (3, 2), (5, 2), and (5,4).

2.1 Inversions (p. 43)

p-b seq

But for multisets he uses places instead:

> An inversion of a permutation  p = p 1 p 2 ⋯ p n {\displaystyle p=p_{1}p_{2}\cdots p_{n}} of a multiset is defined just as it was for permutations of sets, that is,  ( i , j ) {\displaystyle (i,j)} is a inversion if  i < j {\displaystyle i<j} , but  p i > p j {\displaystyle p_{i}>p_{j}} ·
>  The multiset-permutation 1322 has two inversions, (2, 3), and (2, 4).

2.2 Inversions in Permutations of Multisets (p. 57)

The definition of non-inversions also uses places:

> [...] look at all non-inversions of a generic permutation  p = p 1 p 2 ⋯ p n {\displaystyle p=p_{1}p_{2}\cdots p_{n}} ; that is, pairs so that  i < j {\displaystyle i<j} and  p i < p j {\displaystyle p_{i}<p_{j}} .

4.4.1.1 An exponential upper bound (p. 141)

Bóna, Miklós (2012). Combinatorics of permutations. Boca Raton, FL: CRC Press. ISBN 1439850518.

#### Calude et al. 2003

[edit | edit source]

l as left-inversion vector
r as right-inversion vector

> For permutations, an inversion vector is used as an auxiliary array because it fills in the holes made by the elements of the prefix in its defining sequence.
>  For the permutation  ( p [ i ] , … , p [ n ] ) {\displaystyle (p[i],\dots ,p[n])} the right-inversion vector ( g [ i ] , … , g [ n − 1 ] ) {\displaystyle (g[i],\dots ,g[n-1])} is defined by the rule that  g [ i ] {\displaystyle g[i]} is the number of  p [ j ] {\displaystyle p[j]} to the right of but smaller than  p [ i ] {\displaystyle p[i]} ;
>  in the left-inversion vector,  g [ i ] {\displaystyle g[i]} is the number of  p [ j ] {\displaystyle p[j]} to the left of but larger than  p [ i ] {\displaystyle p[i]} .

Calude, Cristian (2003). Discrete mathematics and theoretical computer science : 4th international conference, DMTCS 2003, Dijon, France, July 7-12, 2003 : proceedings. Berlin New York: Springer. ISBN 3540405054. — Generating Gray codes... (p. 81)

#### Lothaire 2002

[edit | edit source]

p-b perm
l as Lehmer encoding

> If  σ = σ ( 1 ) σ ( 2 ) … σ ( k ) {\displaystyle \sigma =\sigma (1)\sigma (2)\dots \sigma (k)} is [a permutation of  [ k ] {\displaystyle [k]} ] an inversion of  σ {\displaystyle \sigma } is a pair  ( i , j ) {\displaystyle (i,j)} such that  1 ≤ i < j ≤ k {\displaystyle 1\leq i<j\leq k} and  σ ( i ) > σ ( j ) {\displaystyle \sigma (i)>\sigma (j)} .

11.1. Prelimiaries (p. 367)

> Let  σ {\displaystyle \sigma } be a permutation of  [ n ] {\displaystyle [n]} . For  1 ≤ i ≤ n {\displaystyle 1\leq i\leq n} , let  l i {\displaystyle l_{i}} be the number of indices  j < i {\displaystyle j<i} such that  σ ( j ) > σ ( i ) {\displaystyle \sigma (j)>\sigma (i)} . The word  l = l 1 l 2 ⋯ l n {\displaystyle l=l_{1}l_{2}\cdots l_{n}} will be called the Lehmer encoding of  σ {\displaystyle \sigma } .

> To the permutation  σ = 6 8 4 5 9 3 1 2 7 {\displaystyle \sigma =6~8~4~5~9~3~1~2~7} corresponds the Lehmer encoding  l = 0 0 2 2 0 5 6 6 2 {\displaystyle l=0~0~2~2~0~5~6~6~2} .

11.4. Inversions of permutations with a given shape (p. 372)

Lothaire, M (2002). Algebraic combinatorics on words. Cambridge New York: Cambridge University Press. ISBN 0521812208.

### Papers

[edit | edit source]

#### Vajnovszki 2011

[edit | edit source]

p-b perm
l as Lehmer code

> The pair  ( i , j ) {\displaystyle (i,j)} is an inversion of  π ∈ S n {\displaystyle \pi \in {\mathfrak {S}}_{n}} if  i < j {\displaystyle i<j} but  π i > π j {\displaystyle \pi _{i}>\pi _{j}} . [...]

> An integer sequence  t 1 t 2 … t n {\displaystyle t_{1}t_{2}\dots t_{n}} is said to be subexcedent if  0 ≤ t i ≤ i − 1 {\displaystyle 0\leq t_{i}\leq i-1} for  1 ≤ i ≤ n {\displaystyle 1\leq i\leq n} , and the set of lenth- n {\displaystyle n} subexcedent sequences is denoted by  S n {\displaystyle S_{n}} [...].
>  The Lehmer code [5] is a bijection code :  S n -> S n {\displaystyle {\mathfrak {S}}_{n}\rightarrow S_{n}} which maps each permutation  π = π 1 π 2 … π n {\displaystyle \pi =\pi _{1}\pi _{2}\dots \pi _{n}} to a subexcedent sequence  t 1 t 2 … t n {\displaystyle t_{1}t_{2}\dots t_{n}}
>  where, for all  i , 1 ≤ i ≤ n {\displaystyle i,~1\leq i\leq n} ,  t i {\displaystyle ~t_{i}} is the number of inversions  ( j , i ) {\displaystyle (j,i)} in  π {\displaystyle \pi } (or equivalently, the number of entries in  π {\displaystyle \pi } larger than  π i {\displaystyle \pi _{i}} and on its left).
>  [5]  D. H. Lehmer, Teaching combinatorial tricks to a computer, in Proc. Sympos. Appl. Math., 10 (1960), Amer. Math. Soc., 179-193.

Vajnovszki. A new Euler–Mahonian constructive bijection — pp. 1-2

#### Gnedin & Olshanski 2012

[edit | edit source]

p-b perm
l as left inversion count
r as right inversion count

> For  σ ∈ S {\displaystyle \sigma \in {\mathfrak {S}}} , a pair of positions  ( i , j ) ∈ Z × Z {\displaystyle (i,j)\in \mathbb {Z} \times \mathbb {Z} } is an inversion in  σ {\displaystyle \sigma } if  i < j {\displaystyle i<j} and  σ ( i ) > σ ( j ) {\displaystyle \sigma (i)>\sigma (j)} .
>  If  ( i , j ) {\displaystyle (i,j)} is an inversion, we say that it is a left inversion for  j {\displaystyle j} , and a right inversion for  i {\displaystyle i} .
>  Introduce the counts of left and right inversions,

>      l i := # { j : j < i , σ ( j ) > σ ( i ) } , r i := # { j : j > i , σ ( j ) < σ ( i ) } , i ∈ Z {\displaystyle {\mathcal {l}}_{i}:=\\#\\{j:j<i,\sigma (j)>\sigma (i)\\},~~~~{\mathcal {r}}_{i}:=\\#\\{j:j>i,\sigma (j)<\sigma (i)\\},~~~~i\in \mathbb {Z} } ,

> respectively (of course, for the general  σ ∈ S {\displaystyle \sigma \in {\mathfrak {S}}} these quantities may be infinite).

4\. A construction from independent geometric variables (p. 624)

The authors proof the following formula for balanced permutations, which include finite permutations:

σ ( i ) = i + r i − l i , i ∈ Z {\displaystyle \sigma (i)=i+{\mathcal {r}}_{i}-{\mathcal {l}}_{i},~~~~i\in \mathbb {Z} }

Lemma 4.6 (p. 627)

Gnedin; Olshanski. The two-sided infinite extension of the Mallows model for random permutations

#### Deutsch et al. 2008

[edit | edit source]

p-b perm
r as right inversion vector

> In a permutation  π = π 1 π 2 … π n {\displaystyle \pi =\pi _{1}\pi _{2}\dots \pi _{n}} , an inversion is a pair  i < j {\displaystyle i<j} such that  π i > π j {\displaystyle \pi _{i}>\pi _{j}} . [...]
>  If  c i {\displaystyle c_{i}} is the number of  j > i {\displaystyle j>i} with  π j < π i {\displaystyle \pi _{j}<\pi _{i}} , then  ( c 1 , c 2 , … , c n ) {\displaystyle (c_{1},c_{2},\dots ,c_{n})} is called the right inversion vector of  π {\displaystyle \pi } [...].

Deutsch; Pergola; Pinzani. Six bijections between deco polyominoes and permutations — p. 5

#### Barth & Mutzel 2004

[edit | edit source]

e-b seq

Crossings in a bilayer graph... ...correspond to inversions of a non-bijective map.

> In a sequence  π = ⟨ a 0 , a 1 , … , a t − 1 ⟩ {\displaystyle \pi =\langle a_{0},a_{1},\dots ,a_{t-1}\rangle } of pairwise comparable elements  a i ( i = 0 , 1 , … , t − 1 ) {\displaystyle a_{i}~(i=0,1,\dots ,t-1)} , a pair  ( a i , a j ) {\displaystyle (a_{i},a_{j})} is called an inversion if  i < j {\displaystyle i<j} and  a i > a j {\displaystyle a_{i}>a_{j}} .

A crucial point of the article is illustrated by the images on the right: A bilayer graph that does not describe a map corresponds to a map that has the edges (green) as its domain and one layer of the vertices (blue) as its codomain. The number of crossings in the bilayer graph can be calculated as the number of inversions of the map.
In this example the map is  π = ⟨ 0 , 1 , 2 , 0 , 3 , 4 , 0 , 2 , 3 , 2 , 4 ⟩ {\displaystyle \pi =\langle 0,1,2,0,3,4,0,2,3,2,4\rangle } .

π 2 = 2 {\displaystyle \pi _{2}=2} ,  π 3 = 0 {\displaystyle \pi _{3}=0} and  π 6 = 0 {\displaystyle \pi _{6}=0} , so with the place-based definition the sequence would have the inversions  ( 2 , 3 ) {\displaystyle (2,3)} and  ( 2 , 6 ) {\displaystyle (2,6)} .
With the element-based definition, chosen by the authors, one could say that the sequence has the inversion  ( 2 , 0 ) {\displaystyle (2,0)} twice.

Barth, Wilhelm; Mutzel, Petra (2004). "Simple and Efficient Bilayer Cross Counting". Journal of Graph Algorithms and Applications 8 (2): 179-194. doi:10.7155/jgaa.00088. — 2 Bilayer Cross Counts and Inversion Numbers (p. 183)

*[p-b perm]: Place-based definition for permutations
*[p-b seq]: Place-based definition for permutations
*[e-b perm]: Element-based definition for permutations
*[e-b seq]: Element-based definition for sequences