Why are an even number of flips required to get back to the original list?

Here is a combinatoric proof (which I am not sure if it is from permutation group).

Count the number of 'reversed pair' in the list. What I mean by reversed pair is pair of numbers which the one bigger in value comes before the smaller one. For example, in $[2,1,3,4]$, $(2,1)$ is a reversed pair but $(1,3)$ is not.

Now observe the change of the number of reversed pair when a flip is taken. Let's say the list is $[\cdots,a,\cdots,b,\cdots]$ and we flip $a,b$, turning it into $[\cdots,b,\cdots,a,\cdots]$. It should be obvious that those in front or behind does not contribute any changes. Also, for those in between, lets call one of it $c$, will only contribute if $a<c<b$ or $a>c>b$. $+2$ for the former and $-2$ for the latter. And finally, the $a,b$ pair. $+1$ if $a<b$ and $-1$ if $a>b$. Anyway, the total number changes by an odd number. Since you have total number of $0$ at beginning and you want $0$ at the end, you have to flip even number of times.

Hope this helps you.


Your flips of $[1,\ldots,n]$ are precisely transpositions of $\{1,\ldots,n\}$, so proving your statement about flips is immediately equivalent to proving the powerful statement about permutation groups that the identity is not the product of any odd number of transpositions. So it is inevitable to either rely on these powerful results or rederive them. I'll try to rederive them in an elementary way.


Let $f_1,\ldots,f_k$ flips of $[1,\ldots,n]$ such that $f_1\circ\cdots\circ f_k$ is the identity. We want to show $k$ is even. This is evidently true for $k=2$, and we proceed from here by induction, so let $k>2$ and suppose the above holds for all $k'<k$. I'll use cycle notation here and there for brevity.

A key observation that can be illustrated to the layman clearly by example, are the identities $$(cd)(ab)=(ab)(cd)\qquad\text{ and }\qquad(bc)(ab)=(ac)(bc),$$ meaning that a flip that does move $a$ followed by a flip that doesn't move $a$ has the same result as some flip that doesn't move $a$ followed by a flip that does move $a$. A picture illustrates this: enter image description here $$\texttt{These aren't the most illustrative pictures.}$$ In the identities above it is important to observe that the number of flips stays the same, and the number of flips that move $a$ also stays the same, while pushing the flip that moves $a$ to the left.

Let $a$ be a number switched by $f_1$. Because the sequence of flips results in the identity there must be another flip that switches $a$. Let $f_i$ be the next one, i.e. the one with the lowest $i$. Using the identities above we can push this flip left to get a sequence starting with $f_1$ followed by another flip that moves $a$, which still results in the identity. All the while keeping the same total number of flips, and the same number of flips switching $a$. If now the first two flips are distinct then the identity $$(a\ b)(a\ c)=(a\ c)(b\ c),$$ which holds for distinct $a$, $b$, $c$, yields a sequence of the same length with one less flip switching $a$, and still starting with a flip switching $a$. We can repeat this process for the next flip $f_j$ switching $a$, and keep repeating it until the first two flips are not distinct. Every time we repeat this process the number of flips moving $a$ decreases by $1$, and this number cannot be $1$, so we will get a sequence starting with two flips that are not distinct. This means the first two flips cancel, and hence that the remaining sequence of $k-2$ flips also results in the identity. Then by induction hypothesis $k-2$ is even, and therefore $k$ is even.


Let $\ell=(x_1,x_2,\ldots, x_n)$ be a list of the numbers in $[n]$. For each $k\in[n]$ denote by $p_k$ the number of $x_i\ (1\leq i<k)$ with $x_i>x_k\,$, and call $\beta(\ell):=\sum_{k=1}^n p_k$ the badness of $\ell$. It is easy to convince oneself that a transposition ("flip") $\tau:\>\ell\mapsto\ell'$ changes the badness by $\pm1$. It follows that an odd number of flips cannot restore a given $\ell$ to its original version.