plank_signed_sum_flip
Let $V$ be a real vector space and $\iota$ a finite type with decidable equality. Given vectors $n : \iota \to V$, weights $w : \iota \to \mathbb{R}$, signs $\varepsilon : \iota \to \mathbb{R}$, and an index $i \in \iota$, replacing $\varepsilon_i$ with $-\varepsilon_i$ changes $\frac{1}{2} \sum_{j \in \iota} (\varepsilon_j w_j) \cdot n_j$ to $\frac{1}{2} \sum_{j \in \iota} (\varepsilon_j w_j) \cdot n_j - (\varepsilon_i w_i) \cdot n_i$.
Statement
lemma plank_signed_sum_flip {V : Type*} [AddCommGroup V] [Module ℝ V] {ι : Type*} [Fintype ι] [DecidableEq ι] (n : ι → V) (w : ι → ℝ) (ε : ι → ℝ) (i : ι) : (1 / 2 : ℝ) • ∑ j, (Function.update ε i (-ε i) j * w j) • n j = (1 / 2 : ℝ) • ∑ j, (ε j * w j) • n j - (ε i * w i) • n i
- Source
- arXiv:2611.00379, Lemma 3 proof
- Verified
- 04 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Used by 1
- plank_energy_diff_single_flipLet $V$ be a real inner product space and $\iota$ a finite type with decidable equality. Let $n : \iota \to V$ be unit vectors,…
Read back from the Lean
Let $V$ be a real vector space (an additive commutative group with an $\mathbb{R}$-module structure) and $\iota$ a finite type with decidable equality. For any functions $n : \iota \to V$, $w : \iota \to \mathbb{R}$, $\varepsilon : \iota \to \mathbb{R}$, and any index $i : \iota$, $$\frac{1}{2} \cdot \sum_{j \in \iota} (\varepsilon'(j) w(j)) \cdot n(j) = \frac{1}{2} \cdot \left(\sum_{j \in \iota} (\varepsilon(j) w(j)) \cdot n(j)\right) - (\varepsilon(i) w(i)) \cdot n(i)$$ where $\varepsilon' = \text{Function.update } \varepsilon\ i\ (-\varepsilon(i))$ is the function that agrees with $\varepsilon$ everywhere except at $i$, where it takes the value $-\varepsilon(i)$.
Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.
The proof, explained
The proof first establishes an unscaled version of the identity: flipping the sign $\varepsilon_i \mapsto -\varepsilon_i$ alters the total sum by subtracting $2 (\varepsilon_i w_i) \cdot n_i$. This is shown by isolating the $i$-th term from the sum and verifying that all other terms remain identical. Finally, multiplying the unscaled identity by $\frac{1}{2}$ distributes across the subtraction and simplifies $\frac{1}{2} \cdot 2 = 1$ to obtain the desired result.
Isolating the $i$-th term reduces the unscaled identity to comparing the sum outside $\{i\}$ and the isolated terms.
We introduce an auxiliary lemma $h$ asserting that flipping $\varepsilon_i$ to $-\varepsilon_i$ changes the unscaled sum by $-2 (\varepsilon_i w_i) \cdot n_i$. Using `Finset.sum_erase_add` and `Finset.mem_univ`, we separate the $i$-th index from the sum over $\iota$ on both sides. Applying `Function.update_apply` together with simplification lemmas (`if_true`, `and_true`, `ne_eq`) evaluates the updated sign at $i$ to $-\varepsilon_i$ and rewrites the remaining terms as conditionals.
uses
Finset.sum_erase_add,Finset.mem_univ,Function.update_apply,if_true,and_true,ne_eqhave h : ∑ j, (Function.update ε i (-ε i) j * w j) • n j = (∑ j, (ε j * w j) • n j) - (2 : ℝ) • ((ε i * w i) • n i) := by rw [← Finset.sum_erase_add _ (fun j => (Function.update ε i (-ε i) j * w j) • n j) (Finset.mem_univ i)] rw [← Finset.sum_erase_add _ (fun j => (ε j * w j) • n j) (Finset.mem_univ i)] simp only [Function.update_apply, Finset.mem_univ, and_true, ne_eq, if_true]
The sum over all indices other than $i$ is unchanged after flipping $\varepsilon_i$.
We establish the congruence `hcongr` stating that the sum over $\iota \setminus \{i\}$ is identical before and after the sign flip. By `Finset.sum_congr`, it suffices to show equality term-by-term. For each $x \in \iota \setminus \{i\}$, `Finset.mem_erase` gives $x \neq i$, so `if_neg` simplifies the updated sign $\text{if } x = i \text{ then } -\varepsilon_i \text{ else } \varepsilon_x$ back to $\varepsilon_x$.
uses
Finset.sum_congr,Finset.mem_erase,if_neghave hcongr : (∑ x ∈ Finset.univ.erase i, ((if x = i then -ε i else ε x) * w x) • n x) = ∑ x ∈ Finset.univ.erase i, (ε x * w x) • n x := by apply Finset.sum_congr rfl intro x hx rw [Finset.mem_erase] at hx rw [if_neg hx.1]
The unscaled identity $h$ holds: flipping the $i$-th sign subtracts $2 (\varepsilon_i w_i) \cdot n_i$ from the sum.
Rewriting with `hcongr` makes the sums over $\iota \setminus \{i\}$ identical on both sides. The remaining equation reduces to the linear vector relation $S + (-T) = S + T - 2T$, which is discharged by the `module` decision procedure for module arithmetic.
rw [hcongr] moduleScaling the unscaled identity by $\frac{1}{2}$ completes the proof.
Substituting the identity $h$ into the main goal, we distribute the scalar $\frac{1}{2}$ over the subtraction using `smul_sub` and group scalar multiplications with `smul_smul`. This leaves a scalar factor of $\frac{1}{2} \cdot 2$ on the $i$-th term, which `norm_num` evaluates to $1$.
uses
smul_sub,smul_smulrw [h, smul_sub, smul_smul] norm_num
and_true- The proposition $p \land \text{True}$ is logically equivalent to $p$.
Finset.mem_erase- An element $a$ belongs to $s \setminus \{b\}$ if and only if $a \neq b$ and $a \in s$.
Finset.mem_univ- Every element of a finite type belongs to the universal finset `Finset.univ`.
Finset.sum_congr- Two sums over finite sets are equal if their index sets are equal and their summands agree on every element.
Finset.sum_erase_add- For any finite set $s$, function $f$, and element $a \in s$, the sum of $f$ over $s$ equals the sum over $s \setminus \{a\}$ plus $f(a)$.
Function.update_apply- Evaluating the function update `Function.update f a' b` at $a$ yields $b$ if $a = a'$ and $f(a)$ otherwise.
if_neg- A conditional expression `if c then t else e` reduces to $e$ when $c$ is false ($\neg c$).
if_true- A conditional expression `if True then t else e` reduces to $t$.
ne_eq- The inequality $a \neq b$ is defined as $\neg(a = b)$.
smul_sub- Scalar multiplication distributes over subtraction: $r \cdot (x - y) = r \cdot x - r \cdot y$.
smul_smul- Scalar multiplication is associative with respect to ring multiplication: $a_1 \cdot (a_2 \cdot b) = (a_1 a_2) \cdot b$.
- The `module` tactic automatically verifies linear vector arithmetic in $V$ (specifically that $S + (-T) = S + T - 2T$).
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.
/-- Effect on a signed sum of vectors when flipping a single coordinate sign. -/lemma plank_signed_sum_flip {V : Type*} [AddCommGroup V] [Module ℝ V] {ι : Type*} [Fintype ι] [DecidableEq ι] (n : ι → V) (w : ι → ℝ) (ε : ι → ℝ) (i : ι) : (1 / 2 : ℝ) • ∑ j, (Function.update ε i (-ε i) j * w j) • n j = (1 / 2 : ℝ) • ∑ j, (ε j * w j) • n j - (ε i * w i) • n i := by have h : ∑ j, (Function.update ε i (-ε i) j * w j) • n j = (∑ j, (ε j * w j) • n j) - (2 : ℝ) • ((ε i * w i) • n i) := by rw [← Finset.sum_erase_add _ (fun j => (Function.update ε i (-ε i) j * w j) • n j) (Finset.mem_univ i)] rw [← Finset.sum_erase_add _ (fun j => (ε j * w j) • n j) (Finset.mem_univ i)] simp only [Function.update_apply, Finset.mem_univ, and_true, ne_eq, if_true] have hcongr : (∑ x ∈ Finset.univ.erase i, ((if x = i then -ε i else ε x) * w x) • n x) = ∑ x ∈ Finset.univ.erase i, (ε x * w x) • n x := by apply Finset.sum_congr rfl intro x hx rw [Finset.mem_erase] at hx rw [if_neg hx.1] rw [hcongr] module rw [h, smul_sub, smul_smul] norm_num