op1525_pair_cut_switch_sum
For any finite collection of ordered nonloop vertex pairs and a Boolean vertex coloring, the sum over all single-vertex switches of the number of differently colored pairs equals (n−4) times the original number plus twice the number of pairs.
Statement
theorem op1525_pair_cut_switch_sum {V : Type*} [DecidableEq V] [Fintype V] (E : Finset (V × V)) (f : V → Bool) (hloop : ∀ e ∈ E, e.1 ≠ e.2) : (∑ v : V, ∑ e ∈ E, if xor (f e.1) (decide (e.1 = v)) = xor (f e.2) (decide (e.2 = v)) then (0 : ℤ) else 1) = ((Fintype.card V : ℤ) - 4) * (∑ e ∈ E, if f e.1 = f e.2 then (0 : ℤ) else 1) + 2 * (E.card : ℤ)
- Source
- A component of the complete-multipartite reconstruction route for OP-1525 and arXiv:2611.13901.
- Verified
- 17 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext
The proof, explained
We evaluate the double sum by swapping the order of summation, summing over vertices for each fixed pair e = (e.1, e.2) ∈ E rather than over pairs for each vertex. For a fixed pair with initial cut indicator c ∈ {0, 1}, switching a vertex v changes whether its endpoints have different colors if and only if v = e.1 or v = e.2, in which case the cut indicator toggles from c to 1 - c. Since e has no self-loops (e.1 ≠ e.2), these two switch events are mutually exclusive, so summing over all v ∈ V yields (|V| - 2) * c + 2 * (1 - c) = (|V| - 4) * c + 2. Summing this expression across all e ∈ E and distributing the constant factor immediately gives (|V| - 4) * (∑ e ∈ E, c) + 2 * |E|.
The sum over all vertex switches of the cut size equals the sum over all edges of each edge's cut contribution across all vertex switches.
We enable classical logic and swap the two finite summations using `Finset.sum_comm`, turning the sum over vertices v followed by edges e into a sum over edges e followed by vertices v.
uses
Finset.sum_commclassical rw [Finset.sum_comm]For any edge e = (e.1, e.2) ∈ E with initial cut indicator c (defined as 0 if f(e.1) = f(e.2) and 1 otherwise), the cut indicator after flipping vertex v equals c + (if e.1 = v then 1 - 2*c else 0) + (if e.2 = v then 1 - 2*c else 0). automation
We state the single-edge sum lemma `hsingle` and let c be the edge's initial cut indicator. For any vertex v, flipping v leaves the endpoint colors unchanged if v ∉ {e.1, e.2} (preserving cut indicator c), and toggles the cut indicator to 1 - c = c + (1 - 2*c) if v is e.1 or e.2. Because e is not a loop (e.1 ≠ e.2 by hypothesis `hloop`), v cannot equal both endpoints at once. Lean verifies this formula across all 16 cases of vertex equality and endpoint colors using `simp_all` and integer arithmetic (`omega`).
have hsingle (e : V × V) (he : e ∈ E) : (∑ v : V, if xor (f e.1) (decide (e.1 = v)) = xor (f e.2) (decide (e.2 = v)) then (0 : ℤ) else 1) = ((Fintype.card V : ℤ) - 4) * (if f e.1 = f e.2 then (0 : ℤ) else 1) + 2 := by let c : ℤ := if f e.1 = f e.2 then 0 else 1 have hpoint (v : V) : (if xor (f e.1) (decide (e.1 = v)) = xor (f e.2) (decide (e.2 = v)) then (0 : ℤ) else 1) = c + (if e.1 = v then 1 - 2 * c else 0) + (if e.2 = v then 1 - 2 * c else 0) := by have hne := hloop e he by_cases h1 : e.1 = v <;> by_cases h2 : e.2 = v <;> cases ha : f e.1 <;> cases hb : f e.2 <;> simp_all [c] <;> omega
For any vertex a ∈ V and integer z, summing the point-mass indicator (if a = v then z else 0) over all v ∈ V equals z.
The summand is non-zero only at v = a where it evaluates to z. Using symmetry of equality via `eq_comm`, `simp` evaluates the sum over all vertices to z.
uses
eq_commhave hsum (a : V) (z : ℤ) : (∑ v : V, if a = v then z else 0) = z := by simp [eq_comm]
For each edge e ∈ E, the sum over all vertices v ∈ V of the cut indicator after switching v equals (|V| - 4) * c + 2, where c is the edge's initial cut indicator.
Substituting the pointwise formula `hpoint`, the sum over v distributes into three sums via `Finset.sum_add_distrib`: the constant c, which sums to |V| * c using `Finset.sum_const`, `Finset.card_univ`, and `nsmul_eq_mul`; and the two indicator terms for e.1 = v and e.2 = v, each summing to 1 - 2*c via `hsum`. Unfolding c and rearranging with `ring` produces |V| * c + 2 * (1 - 2*c) = (|V| - 4) * c + 2, completing `hsingle`.
uses
Finset.sum_add_distrib,Finset.sum_const,Finset.card_univ,nsmul_eq_mulsimp_rw [hpoint, Finset.sum_add_distrib] simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] rw [hsum, hsum] dsimp [c] ringThe total switched cut sum equals ∑ e ∈ E, ((|V| - 4) * c(e) + 2).
Using `Finset.sum_congr`, we replace the inner sum over vertices for each edge e ∈ E with the evaluation established by `hsingle`.
uses
Finset.sum_congrcalc _ = ∑ e ∈ E, (((Fintype.card V : ℤ) - 4) * (if f e.1 = f e.2 then (0 : ℤ) else 1) + 2) := by apply Finset.sum_congr rfl intro e he exact hsingle e he
The sum ∑ e ∈ E, ((|V| - 4) * c(e) + 2) equals (|V| - 4) * (∑ e ∈ E, c(e)) + 2 * |E|, completing the proof.
We distribute the summation over addition with `Finset.sum_add_distrib` and factor the constant factor (|V| - 4) out of the edge sum using `Finset.mul_sum`. Simplifying the remaining constant sum ∑ e ∈ E, 2 into 2 * |E| with `mul_comm` completes the calculation.
uses
Finset.sum_add_distrib,Finset.mul_sum,mul_comm_ = _ := by rw [Finset.sum_add_distrib, ← Finset.mul_sum]; simp [mul_comm]
Finset.sum_comm- The order of two finite summations can be exchanged: ∑ x ∈ s, ∑ y ∈ t, f(x, y) = ∑ y ∈ t, ∑ x ∈ s, f(x, y).
eq_comm- Equality is symmetric: a = b ↔ b = a.
Finset.sum_add_distrib- Finite summation distributes over addition: ∑ x ∈ s, (f(x) + g(x)) = ∑ x ∈ s, f(x) + ∑ x ∈ s, g(x).
Finset.sum_const- Summing a constant b over a finite set s equals the cardinality of s times b: ∑ _x ∈ s, b = |s| • b.
Finset.card_univ- The cardinality of the universal finset of a finite type equals the cardinality of the type.
nsmul_eq_mul- Natural scalar multiplication in a semiring equals multiplication by the natural number: n • a = n * a.
Finset.sum_congr- If two finite sets are equal and two functions agree on every element of the set, their sums over the set are equal.
Finset.mul_sum- Multiplication distributes over finite summation: a * ∑ i ∈ s, f(i) = ∑ i ∈ s, a * f(i).
mul_comm- Multiplication is commutative: a * b = b * a.
- The case analysis in line 28 (verifying that flipping vertex v alters edge e's cut indicator by c + (if e.1 = v then 1 - 2*c else 0) + (if e.2 = v then 1 - 2*c else 0)) is discharged across all 16 subgoals by the automated tactics `simp_all` and `omega`.
Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.
Lean source view module on GitHub
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
theorem op1525_pair_cut_switch_sum {V : Type*} [DecidableEq V] [Fintype V] (E : Finset (V × V)) (f : V → Bool) (hloop : ∀ e ∈ E, e.1 ≠ e.2) : (∑ v : V, ∑ e ∈ E, if xor (f e.1) (decide (e.1 = v)) = xor (f e.2) (decide (e.2 = v)) then (0 : ℤ) else 1) = ((Fintype.card V : ℤ) - 4) * (∑ e ∈ E, if f e.1 = f e.2 then (0 : ℤ) else 1) + 2 * (E.card : ℤ) := by classical rw [Finset.sum_comm] have hsingle (e : V × V) (he : e ∈ E) : (∑ v : V, if xor (f e.1) (decide (e.1 = v)) = xor (f e.2) (decide (e.2 = v)) then (0 : ℤ) else 1) = ((Fintype.card V : ℤ) - 4) * (if f e.1 = f e.2 then (0 : ℤ) else 1) + 2 := by let c : ℤ := if f e.1 = f e.2 then 0 else 1 have hpoint (v : V) : (if xor (f e.1) (decide (e.1 = v)) = xor (f e.2) (decide (e.2 = v)) then (0 : ℤ) else 1) = c + (if e.1 = v then 1 - 2 * c else 0) + (if e.2 = v then 1 - 2 * c else 0) := by have hne := hloop e he by_cases h1 : e.1 = v <;> by_cases h2 : e.2 = v <;> cases ha : f e.1 <;> cases hb : f e.2 <;> simp_all [c] <;> omega have hsum (a : V) (z : ℤ) : (∑ v : V, if a = v then z else 0) = z := by simp [eq_comm] simp_rw [hpoint, Finset.sum_add_distrib] simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] rw [hsum, hsum] dsimp [c] ring calc _ = ∑ e ∈ E, (((Fintype.card V : ℤ) - 4) * (if f e.1 = f e.2 then (0 : ℤ) else 1) + 2) := by apply Finset.sum_congr rfl intro e he exact hsingle e he _ = _ := by rw [Finset.sum_add_distrib, ← Finset.mul_sum]; simp [mul_comm]