Count inversions in a permutation written as a list.
Equations
- Hex.Matrix.inversionCount [] = 0
- Hex.Matrix.inversionCount (x_1 :: xs) = List.foldl (fun (acc : Nat) (y : Fin n) => acc + if y < x_1 then 1 else 0) 0 xs + Hex.Matrix.inversionCount xs
Instances For
theorem
Hex.Matrix.permutationVectors_complete
{n : Nat}
{perm : Vector (Fin n) n}
(hnodup : perm.toList.Nodup)
:
Every duplicate-free length-n vector of Fin n appears in
permutationVectors n. This gives the completeness half of the local
permutation enumeration used by the Leibniz determinant.
theorem
Hex.Matrix.permutationVectors_nodup
{n : Nat}
{perm : Vector (Fin n) n}
(hmem : perm ∈ permutationVectors n)
:
Every vector enumerated by permutationVectors n is duplicate-free, so
each listed vector really represents a permutation of Fin n.
The permutation enumeration itself has no duplicate vectors. This lets
determinant proofs compare sums over permutationVectors by list
permutation rather than by quotienting repeated terms.