Inversions and the sorting sign #
The calculus of the sorting sign (inversions and sortSign are
defined in RS/Definitions.lean): the sign is antisymmetric under
adjacent transpositions of distinct elements, which is the
combinatorial engine of the alternating evaluation of mixed vertex
functionals.
Sorting signs square to one over ℂ.
theorem
RS.inversions_map_orderEmbedding
{α β : Type}
[LinearOrder α]
[LinearOrder β]
(e : α ↪o β)
(l : List α)
:
Increasing embeddings preserve inversion counts.
theorem
RS.sortSign_map_orderEmbedding
{α β : Type}
[LinearOrder α]
[LinearOrder β]
(e : α ↪o β)
(l : List α)
:
Increasing embeddings preserve the sorting sign.
theorem
RS.inversions_eq_zero_of_sorted
{α : Type}
[LinearOrder α]
(l : List α)
:
List.Pairwise (fun (x1 x2 : α) => x1 ≤ x2) l → inversions l = 0
Sorted lists have no inversions.
theorem
RS.sortSign_eq_one_of_sorted
{α : Type}
[LinearOrder α]
(l : List α)
(h : List.Pairwise (fun (x1 x2 : α) => x1 ≤ x2) l)
:
Sorted lists have sorting sign one.
Inversion counts are invariant under permuting the tail past a fixed head-filter: permuted lists have equal filter lengths.
theorem
RS.sortSign_pair_block_swap
{α : Type}
[LinearOrder α]
(l₁ l₂ : List α)
{p₁ p₂ q₁ q₂ : α}
(hp₁q₁ : p₁ ≠ q₁)
(hp₁q₂ : p₁ ≠ q₂)
(hp₂q₁ : p₂ ≠ q₁)
(hp₂q₂ : p₂ ≠ q₂)
:
Moving a two-element block past another two-element block preserves the sorting sign: four adjacent transpositions, an even number of sign flips.