plank_energy_diff_single_flip
Let $V$ be a real inner product space and $\iota$ a finite type with decidable equality. Let $n : \iota \to V$ be unit vectors, $w : \iota \to \mathbb{R}$ widths, $s : \iota \to \mathbb{R}$ shifts, $\varepsilon : \iota \to \mathbb{R}$ signs, and $i \in \iota$ with $\varepsilon_i = 1$ or $\varepsilon_i = -1$. Let $\varepsilon'$ be $\varepsilon$ with the sign at $i$ flipped, let $z = \frac{1}{2}\sum_j (\varepsilon_j w_j) \cdot n_j$ and $z' = \frac{1}{2}\sum_j (\varepsilon'_j w_j) \cdot n_j$. Define the energy $E(\sigma, v) = \|v\|^2 - \sum_j \sigma_j w_j s_j$. Then $E(\varepsilon, z) - E(\varepsilon', z') = 2 w_i (\varepsilon_i (\langle n_i, z \rangle - s_i) - w_i / 2)$.
Statement
open scoped RealInnerProductSpace in lemma plank_energy_diff_single_flip {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] {ι : Type*} [Fintype ι] [DecidableEq ι] (n : ι → V) (hn : ∀ i, ‖n i‖ = 1) (w : ι → ℝ) (s : ι → ℝ) (ε : ι → ℝ) (i : ι) (hε : ε i = 1 ∨ ε i = -1) : let ε' := Function.update ε i (-ε i) let z := (1 / 2 : ℝ) • ∑ j, (ε j * w j) • n j let z' := (1 / 2 : ℝ) • ∑ j, (ε' j * w j) • n j let E := fun (sgn : ι → ℝ) (pt : V) => ‖pt‖ ^ 2 - ∑ j, sgn j * w j * s j E ε z - E ε' z' = 2 * w i * (ε i * (⟪n i, z⟫ - s i) - w i / 2)
- Source
- arXiv:2611.00379, Lemma 3 proof
- Verified
- 04 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 2
- norm_sub_smul_sqLet $V$ be a real inner product space, let $z \in V$, let $n \in V$ be a unit vector with $\|n\| = 1$, and let $a \in \mathbb{R}$. Then…
- plank_signed_sum_flipLet $V$ be a real vector space and $\iota$ a finite type with decidable equality. Given vectors $n : \iota \to V$, weights…
- Used by 1
- plank_system_sign_vector_existsLet $V$ be a real inner product space, let $\iota$ be a finite type, let $n : \iota \to V$ be unit vectors, let $w : \iota \to \mathbb{R}$…
Read back from the Lean
Let $V$ be a real inner product space, $\iota$ a finite type with decidable equality, $n : \iota \to V$ a family of vectors satisfying $\|n(i)\| = 1$ for all $i \in \iota$, and let $w, s, \varepsilon : \iota \to \mathbb{R}$. Let $i \in \iota$ be an index such that $\varepsilon(i) = 1$ or $\varepsilon(i) = -1$. Define: - $\varepsilon' : \iota \to \mathbb{R}$ as the function update of $\varepsilon$ at index $i$ to $-\varepsilon(i)$; - $z = \frac{1}{2} \sum_{j \in \iota} (\varepsilon(j) w(j)) n(j) \in V$; - $z' = \frac{1}{2} \sum_{j \in \iota} (\varepsilon'(j) w(j)) n(j) \in V$; - $E(\mathrm{sgn}, \mathrm{pt}) = \|\mathrm{pt}\|^2 - \sum_{j \in \iota} \mathrm{sgn}(j) w(j) s(j)$ for $\mathrm{sgn} : \iota \to \mathbb{R}$ and $\mathrm{pt} \in V$. Then: $$E(\varepsilon, z) - E(\varepsilon', z') = 2 w(i) \left(\varepsilon(i) (\langle n(i), z \rangle - s(i)) - \frac{w(i)}{2}\right).$$
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 computes the energy difference $E(\varepsilon, z) - E(\varepsilon', z')$ by analyzing how flipping a single sign $\varepsilon_i \in \{-1, 1\}$ affects each term in the definition of the energy. First, flipping the sign at $i$ changes the linear shift sum by $-2 \varepsilon_i w_i s_i$, as all other terms remain identical. Second, the center vector shifts by $z' = z - (\varepsilon_i w_i) n_i$, so expanding $\|z'\|^2$ with the unit vector property $\|n_i\| = 1$ and $(\varepsilon_i w_i)^2 = w_i^2$ yields $\|z\|^2 - 2 \varepsilon_i w_i \langle n_i, z \rangle + w_i^2$. Subtracting $E(\varepsilon', z')$ from $E(\varepsilon, z)$ cancels both $\|z\|^2$ and the original shift sum, directly yielding the claimed identity.
The definitions of the energy $E$, the vectors $z$ and $z'$, and the flipped sign configuration $\varepsilon'$ are unfolded in the goal.
The tactic `dsimp only` expands the local `let`-bindings, expressing the energy difference $E(\varepsilon, z) - E(\varepsilon', z')$ directly in terms of the vector norms and the linear coordinate sums.
dsimp onlyThe linear shift sum under the flipped sign configuration $\varepsilon'$ satisfies $\sum_j \varepsilon'_j w_j s_j = \sum_j \varepsilon_j w_j s_j - 2 \varepsilon_i w_i s_i$.
To compute the difference between the two sums, `Finset.sum_sub_distrib` distributes the subtraction into each term. For any index $b \neq i$, the updated sign $\varepsilon'_b$ matches $\varepsilon_b$ by `dif_neg`, so the difference vanishes by `sub_self`. By `Finset.sum_eq_single_of_mem` and `Finset.mem_univ`, the sum collapses to the single term at index $i$, where the difference evaluates to $(-\varepsilon_i - \varepsilon_i) w_i s_i = -2 \varepsilon_i w_i s_i$. Rearranging this difference establishes the claimed formula for the new sum.
uses
Finset.sum_sub_distrib,dif_neg,sub_self,Finset.sum_eq_single_of_mem,Finset.mem_univhave hsum : (∑ j, Function.update ε i (-ε i) j * w j * s j) = (∑ j, ε j * w j * s j) - 2 * (ε i * w i * s i) := by have key : (∑ j, Function.update ε i (-ε i) j * w j * s j) - (∑ j, ε j * w j * s j) = - 2 * (ε i * w i * s i) := by rw [← Finset.sum_sub_distrib] have hzero : ∀ b ∈ Finset.univ, b ≠ i → (Function.update ε i (-ε i) b * w b * s b - ε b * w b * s b) = 0 := by intro b hb hne simp only [Function.update, dif_neg hne, sub_self] rw [Finset.sum_eq_single_of_mem i (Finset.mem_univ i) hzero] simp [Function.update] ring linarith
$\varepsilon_i^2 = 1$.
Since $\varepsilon_i$ is either $1$ or $-1$ by hypothesis, squaring either value gives $1$.
have heps : ε i ^ 2 = 1 := by rcases hε with h | h <;> rw [h] <;> norm_num
$(\varepsilon_i w_i)^2 = w_i^2$.
Expanding $(\varepsilon_i w_i)^2 = \varepsilon_i^2 w_i^2$ and substituting $\varepsilon_i^2 = 1$ leaves $w_i^2$.
have hsq : (ε i * w i) ^ 2 = w i ^ 2 := by have : (ε i * w i) ^ 2 = ε i ^ 2 * w i ^ 2 := by ring rw [this, heps]; ring
The squared norm $\|z'\|^2$ and the flipped linear sum in $E(\varepsilon', z')$ are rewritten in terms of $z$, $\langle n_i, z \rangle$, and the original linear sum.
Applying `plank_signed_sum_flip` expresses $z'$ as $z - (\varepsilon_i w_i) n_i$. Because $n_i$ is a unit vector, expanding the norm $\|z - (\varepsilon_i w_i) n_i\|^2$ using `norm_sub_smul_sq` yields $\|z\|^2 - 2 \varepsilon_i w_i \langle n_i, z \rangle + (\varepsilon_i w_i)^2$. Rewriting with `hsum` replaces the sum $\sum_j \varepsilon'_j w_j s_j$ with $\sum_j \varepsilon_j w_j s_j - 2 \varepsilon_i w_i s_i$.
uses
plank_signed_sum_flip,norm_sub_smul_sqrw [plank_signed_sum_flip n w ε i] rw [norm_sub_smul_sq _ (n i) (hn i) (ε i * w i)] rw [hsum]
The energy difference $E(\varepsilon, z) - E(\varepsilon', z')$ equals $2 w_i (\varepsilon_i (\langle n_i, z \rangle - s_i) - w_i / 2)$.
The squared norms $\|z\|^2$ and original linear sums $\sum_j \varepsilon_j w_j s_j$ cancel between $E(\varepsilon, z)$ and $E(\varepsilon', z')$. Substituting $(\varepsilon_i w_i)^2 = w_i^2$, both sides reduce to the same polynomial expression $2 \varepsilon_i w_i \langle n_i, z \rangle - 2 \varepsilon_i w_i s_i - w_i^2$, which is verified by non-linear arithmetic.
nlinarith [hsq]
Finset.sum_sub_distrib- The sum of a difference of two functions over a finite set equals the difference of their sums: $\sum_{x \in s} (f(x) - g(x)) = \sum_{x \in s} f(x) - \sum_{x \in s} g(x)$.
dif_neg- In a dependent if-then-else expression, when the condition is false, the expression evaluates to the false branch.
sub_self- Subtracting an element from itself gives zero: $a - a = 0$.
Finset.sum_eq_single_of_mem- If the terms of a sum over a finite set are all zero except possibly at a single element $a$, the sum equals the term at $a$.
Finset.mem_univ- Every element of a finite type belongs to the universal finset `Finset.univ`.
plank_signed_sum_flip- Flipping the sign $\varepsilon_i$ to $-\varepsilon_i$ in the scaled sum $\frac{1}{2} \sum_j (\varepsilon_j w_j) n_j$ subtracts $(\varepsilon_i w_i) n_i$ from the vector.
norm_sub_smul_sq- For any vector $z$ and unit vector $n$, the squared norm $\|z - a n\|^2$ expands as $\|z\|^2 - 2 a \langle n, z \rangle + a^2$.
- The final algebraic identity is verified automatically by `nlinarith` using the equality $(\varepsilon_i w_i)^2 = w_i^2$.
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.
open scoped RealInnerProductSpace in/-- Energy difference under flipping a single sign in a plank system. -/lemma plank_energy_diff_single_flip {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] {ι : Type*} [Fintype ι] [DecidableEq ι] (n : ι → V) (hn : ∀ i, ‖n i‖ = 1) (w : ι → ℝ) (s : ι → ℝ) (ε : ι → ℝ) (i : ι) (hε : ε i = 1 ∨ ε i = -1) : let ε' := Function.update ε i (-ε i) let z := (1 / 2 : ℝ) • ∑ j, (ε j * w j) • n j let z' := (1 / 2 : ℝ) • ∑ j, (ε' j * w j) • n j let E := fun (sgn : ι → ℝ) (pt : V) => ‖pt‖ ^ 2 - ∑ j, sgn j * w j * s j E ε z - E ε' z' = 2 * w i * (ε i * (⟪n i, z⟫ - s i) - w i / 2) := by dsimp only have hsum : (∑ j, Function.update ε i (-ε i) j * w j * s j) = (∑ j, ε j * w j * s j) - 2 * (ε i * w i * s i) := by have key : (∑ j, Function.update ε i (-ε i) j * w j * s j) - (∑ j, ε j * w j * s j) = - 2 * (ε i * w i * s i) := by rw [← Finset.sum_sub_distrib] have hzero : ∀ b ∈ Finset.univ, b ≠ i → (Function.update ε i (-ε i) b * w b * s b - ε b * w b * s b) = 0 := by intro b hb hne simp only [Function.update, dif_neg hne, sub_self] rw [Finset.sum_eq_single_of_mem i (Finset.mem_univ i) hzero] simp [Function.update] ring linarith have heps : ε i ^ 2 = 1 := by rcases hε with h | h <;> rw [h] <;> norm_num have hsq : (ε i * w i) ^ 2 = w i ^ 2 := by have : (ε i * w i) ^ 2 = ε i ^ 2 * w i ^ 2 := by ring rw [this, heps]; ring rw [plank_signed_sum_flip n w ε i] rw [norm_sub_smul_sq _ (n i) (hn i) (ε i * w i)] rw [hsum] nlinarith [hsq]