AFTD Auto-Formalizing Theoretical Domains

perm_inversion_graph

def

The inversion graph of a permutation $\sigma$ on $\{0, \dots, n-1\}$ has vertex set $\{0, \dots, n-1\}$ and an edge between $i$ and $j$ if and only if $i$ and $j$ form an inversion of $\sigma$.

Statement

def perm_inversion_graph {n : ℕ} (σ : Equiv.Perm (Fin n)) : SimpleGraph (Fin n)
Defined in
arXiv:2611.33575 Section 1
Verified
27 Nov 2026
Axioms
none listed
Built on 2
  • LinearOrder.toTotalPreorderEvery LinearOrder is a TotalPreorder.
  • TotalPreorderA total preorder: a preorder where ≤ is total (complete). This is weaker than LinearOrder — it does NOT require antisymmetry or…

Read back from the Lean

Given a natural number n and a permutation σ of Fin n, perm_inversion_graph σ is the simple graph on vertex set Fin n whose adjacency relation connects two vertices i and j if and only if either (i < j and σ j < σ i) or (j < i and σ i < σ j) (that is, the unordered pair {i, j} forms an inversion of σ).

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

Lean source view module on GitHub

/-- The inversion graph of a permutation on Fin n, where two indices are adjacent if they form an inversion. -/
def perm_inversion_graph {n : ℕ} (σ : Equiv.Perm (Fin n)) : SimpleGraph (Fin n) := {
  Adj := fun i j => (i < j ∧ σ j < σ i) ∨ (j < i ∧ σ i < σ j)
  symm := ⟨fun _ _ h => h.symm⟩
  loopless := ⟨fun i => by rintro (⟨h, -⟩ | ⟨h, -⟩) <;> exact lt_irrefl i h⟩
}
See it in the graphDiscuss this resultChallenge it