ΘρϵηΠατπ

Inversion Lookahead in Sorted Concatenation
Suppose that a=(a1,,an) and b=(b1,,bm) are finite tuples sorted in ascending order and define c=concat(a,b). If ai and bj form an inversion then for every k[in] ak and bj form an inversion in c

Before the proof starts note that c has n+m elements, and then bj refers to the element at position n+j with respect to c

We know that bj<ai because they form an inversion, we also know that a is sorted in ascending order, therefore we know that bj<ai<ai+1<<an, therefore for each k[i...n] we know (k,n+j) forms an inversion in c as needed.

No Inversion Lookahead in Sorted Concatenation
Suppose that a=(a1,,an) and b=(b1,,bm) are finite tuples sorted in ascending order and define c=concat(a,b). If ai and bj do not form an inversion then for every k[jm] ai and bk do not form an inversion in c
Since ai and bj do not form an inversion then we know that aibj, since b is sorted in ascending order then we know that aibjbj+1bm, and thus for every k[jm] we know ai and bk do not form an inversion.
\texttt{counting_inversions} ParseError: Expected 'EOF', got '_' at position 17: …texttt{counting_̲inversions} is Correct
Given any list A \texttt{counting_inversions} ParseError: Expected 'EOF', got '_' at position 17: …texttt{counting_̲inversions} returns the number of inversions in A