AFTD Auto-Formalizing Theoretical Domains

pmSumListAux

def

pmSumListAux takes a semiring α, natural numbers N and D, a weight function W : WeightsN N D α, a vertex coloring ι : Fin N → Fin D, a step count n : ℕ, and a vertex list L : List (Fin N), returning an element of α defined by recursion on (n, L): 1 if n = 0; 0 if n = 1; 1 if n ≥ 2 and L = []; 0 if n ≥ 2 and L = [_]; and if n + 2 and L = v :: vs, the sum over u ∈ vs of W (mkEdge v u (ι v) (ι u)) * pmSumListAux W ι n (vs.erase u).

Statement

def pmSumListAux {α : Type*} [Semiring α] {N D : ℕ} (W : WeightsN N D α) (ι : Fin N → Fin D) : ℕ → List (Fin N) → α
Defined in
arXiv:2611.26300
Verified
23 Nov 2026
Axioms
none listed
Built on 2
  • mkEdgeConstructs an edge in a quantum graph connecting vertex $v$ with colour $c_v$ to vertex $u$ with colour $c_u$.
  • WeightsNThe type of edge-weight functions on a quantum graph on $N$ vertices with $D$ colours with values in $\alpha$.
Used by 1
  • pmSumListGiven a semiring α, weights W : WeightsN N D α, a vertex coloring ι : Fin N → Fin D, and a vertex list L : List (Fin N), pmSumList W ι L…

Read back from the Lean

pmSumListAux defines an auxiliary function for computing a weighted matching-like sum over a list of vertices. Given: - a type α with a Semiring instance, - natural numbers N and D (implicit), - a weight function W : WeightsN N D α (assigning a weight in α to each directed edge with vertex and color labels), - a color/label assignment ι : Fin N → Fin D, the function takes a natural number argument k : ℕ and a list of vertices l : List (Fin N) and returns an element of α, defined by recursion: - If k = 0: returns 1 for any list. - If k = 1: returns 0 for any list. - If k ≥ 2: - If the list is empty ([]): returns 1. - If the list has exactly one element ([_]): returns 0. - If the list has at least two elements (v :: vs): for each vertex u in vs, it computes the product of the edge weight W (mkEdge v u (ι v) (ι u)) and the recursive call pmSumListAux W ι (k - 2) (vs.erase u) (where vs.erase u removes the first occurrence of u from vs), and sums these products over all u in vs.

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

/-- Recursive helper for computing the sum of weights over all perfect matchings. -/
def pmSumListAux {α : Type*} [Semiring α] {N D : ℕ} (W : WeightsN N D α) (ι : Fin N → Fin D) : ℕ → List (Fin N) → α
| 0, _ => 1
| 1, _ => 0
| _ + 2, [] => 1
| _ + 2, [_] => 0
| n + 2, v :: vs =>
  (vs.map (fun u =>
    W (mkEdge v u (ι v) (ι u)) * pmSumListAux W ι n (vs.erase u))).sum
See it in the graphDiscuss this resultChallenge it