electrical_flow_cross_term
If F is a skew-symmetric flow on Fin k satisfying the voltage law d i j * F i j = h i - h j for all i ≠ j, and G is a skew-symmetric flow with divergence b (so ∑ j, G i j = b i for all i), then the cross term ∑ i, ∑ j with i < j, d i j * F i j * G i j equals ∑ i, b i * h i.
Statement
theorem electrical_flow_cross_term {k : ℕ} (d : Fin k → Fin k → ℝ) (F G : Fin k → Fin k → ℝ) (h : Fin k → ℝ) (b : Fin k → ℝ) (hF_skew : ∀ i j, F i j = -F j i) (hF_volt : ∀ i j, i ≠ j → d i j * F i j = h i - h j) (hG_skew : ∀ i j, G i j = -G j i) (hG_div : ∀ i, ∑ j, G i j = b i) : (∑ i : Fin k, ∑ j with i < j, d i j * F i j * G i j) = ∑ i, b i * h i
- Source
- arXiv:2611.05669, Appendix A
- Verified
- 06 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 2
- TotalPreorderA total preorder: a preorder where
≤is total (complete). This is weaker thanLinearOrder— it does NOT require antisymmetry or… - LinearOrder.toTotalPreorderEvery
LinearOrderis aTotalPreorder.
- TotalPreorderA total preorder: a preorder where
Read back from the Lean
For any natural number $k$, given functions $d, F, G : \text{Fin } k \to \text{Fin } k \to \mathbb{R}$ and $h, b : \text{Fin } k \to \mathbb{R}$ satisfying: 1. $F$ is skew-symmetric: for all $i, j \in \text{Fin } k$, $F(i, j) = -F(j, i)$, 2. Ohm's law / potential difference condition: for all $i, j \in \text{Fin } k$ with $i \neq j$, $d(i, j) F(i, j) = h(i) - h(j)$, 3. $G$ is skew-symmetric: for all $i, j \in \text{Fin } k$, $G(i, j) = -G(j, i)$, 4. Divergence condition: for all $i \in \text{Fin } k$, $\sum_{j : \text{Fin } k} G(i, j) = b(i)$, then: $$\sum_{i : \text{Fin } k} \sum_{\substack{j : \text{Fin } k \\ i < j}} d(i, j) F(i, j) G(i, j) = \sum_{i : \text{Fin } k} b(i) h(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 evaluates the cross term by discrete integration by parts. First, the voltage law replaces d(i,j) * F(i,j) with h(i) - h(j) on pairs i < j, splitting the sum into two parts. Swapping summation indices and using the skew-symmetry of G converts the subtracted term into a sum over j < i. Combining the two parts covers all j ≠ i (with the diagonal vanishing because G(i,i) = 0), so factoring out h(i) and using the divergence condition ∑_j G(i,j) = b(i) yields the inner product ∑_i b(i) * h(i).
The restricted sum ∑_{i} ∑_{j: i < j} d(i,j) F(i,j) G(i,j) equals the sum over all pairs ∑_i ∑_j of the indicator term if i < j then (h(i) - h(j)) * G(i,j) else 0.
The proof introduces hF_skew (line 3) and establishes lemma h1 (lines 4–13). By Finset.sum_filter, the sum over {j | i < j} is expressed as an indicator over all j. For pairs with i < j, we have i ≠ j by ne_of_lt, allowing the voltage condition hF_volt to replace d(i,j) * F(i,j) with h(i) - h(j). Line 14 rewrites the main goal with h1.
uses
Finset.sum_congr,Finset.sum_filter,ne_of_lthave _ := hF_skew have h1 : (∑ i : Fin k, ∑ j with i < j, d i j * F i j * G i j) = ∑ i, ∑ j, if i < j then (h i - h j) * G i j else 0 := by apply Finset.sum_congr rfl intro i _ rw [Finset.sum_filter] apply Finset.sum_congr rfl intro j _ split_ifs with hij · rw [hF_volt i j (ne_of_lt hij)] · rfl rw [h1]
The double sum splits into the difference of two sums: (∑_i ∑_j if i < j then h(i) * G(i,j) else 0) - (∑_i ∑_j if i < j then h(j) * G(i,j) else 0).
Lemma h2 (lines 15–24) distributes the subtraction (h(i) - h(j)) * G(i,j) = h(i) * G(i,j) - h(j) * G(i,j) across both the outer and inner sums using Finset.sum_sub_distrib and congruence Finset.sum_congr, verified pointwise by ring arithmetic. Line 25 rewrites the goal with h2.
uses
Finset.sum_sub_distrib,Finset.sum_congrhave h2 : (∑ i : Fin k, ∑ j, if i < j then (h i - h j) * G i j else (0 : ℝ)) = (∑ i, ∑ j, if i < j then h i * G i j else 0) - (∑ i, ∑ j, if i < j then h j * G i j else 0) := by rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro i _ rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro j _ split_ifs <;> ring rw [h2]
The second sum equals -∑_i ∑_j (if j < i then h(i) * G(i,j) else 0), so subtracting it turns the whole expression into ∑_i ((∑_j if i < j then h(i) * G(i,j) else 0) + (∑_j if j < i then h(i) * G(i,j) else 0)).
Lemma h3 (lines 26–36) swaps the summation indices i and j in the second double sum using Finset.sum_comm, converting the condition i < j into j < i and the summand into h(i) * G(j,i). Applying the skew-symmetry of G (G(j,i) = -G(i,j)) pulls out a minus sign using Finset.sum_neg_distrib. On line 37, rewriting with h3 converts subtraction of a negative into addition via sub_neg_eq_add, and Finset.sum_add_distrib merges the outer sums over i.
uses
Finset.sum_comm,Finset.sum_neg_distrib,Finset.sum_congr,sub_neg_eq_add,Finset.sum_add_distribhave h3 : (∑ i : Fin k, ∑ j, if i < j then h j * G i j else (0 : ℝ)) = - ∑ i, ∑ j, if j < i then h i * G i j else 0 := by rw [Finset.sum_comm] rw [← Finset.sum_neg_distrib] apply Finset.sum_congr rfl intro i _ rw [← Finset.sum_neg_distrib] apply Finset.sum_congr rfl intro j _ rw [hG_skew j i] split_ifs <;> ring rw [h3, sub_neg_eq_add, ← Finset.sum_add_distrib]
For each node i, the sum over j of the combined indicators equals b(i) * h(i).
Lemma h4 (lines 38–51) fixes an index i and adds the two inner sums with Finset.sum_add_distrib. Sublemma hterm (lines 42–50) shows that for every j, the sum of the two indicators (if i < j then h(i)*G(i,j) else 0) + (if j < i then h(i)*G(i,j) else 0) equals h(i) * G(i,j): by lt_trichotomy on i and j, if i < j or j < i, one branch is active and the other is 0; if i = j, both branches are 0, which matches h(i) * G(i,i) because G(i,i) = 0 by skew-symmetry (hG_skew). Factoring out h(i) via Finset.mul_sum leaves h(i) * ∑_j G(i,j), which by the divergence condition hG_div evaluates to h(i) * b(i) = b(i) * h(i).
uses
Finset.sum_add_distrib,Finset.sum_congr,lt_trichotomy,if_pos,if_neg,asymm,add_zero,zero_add,Finset.mul_sum,mul_commhave h4 : ∀ i : Fin k, (∑ j, if i < j then h i * G i j else 0) + (∑ j, if j < i then h i * G i j else 0) = b i * h i := by intro i rw [← Finset.sum_add_distrib] have hterm : (∑ j, ((if i < j then h i * G i j else 0) + (if j < i then h i * G i j else 0))) = ∑ j, h i * G i j := by apply Finset.sum_congr rfl intro j _ rcases lt_trichotomy i j with hij | rfl | hji · rw [if_pos hij, if_neg (asymm hij), add_zero] · have hG0 : G i i = 0 := by have := hG_skew i i; linarith simp [hG0] · rw [if_pos hji, if_neg (asymm hji), zero_add] rw [hterm, ← Finset.mul_sum, hG_div i, mul_comm]
The total energy cross term equals ∑_i b(i) * h(i).
Sum congruence Finset.sum_congr replaces each term in the outer sum over i with b(i) * h(i) using lemma h4, completing the proof.
uses
Finset.sum_congrapply Finset.sum_congr rfl intro i _ exact h4 i
Finset.sum_congr- Two finite sums are equal if their index sets are equal and their summands agree on every element of the index set.
Finset.sum_filter- A sum over elements satisfying a predicate equals the sum over all elements with an if-then-else indicator.
ne_of_lt- In a preorder, if a < b then a ≠ b.
Finset.sum_sub_distrib- The sum of a difference equals the difference of the sums: ∑ (f - g) = ∑ f - ∑ g.
Finset.sum_comm- The order of summation in a double finite sum can be interchanged: ∑_i ∑_j f(i,j) = ∑_j ∑_i f(i,j).
Finset.sum_neg_distrib- Negation distributes over finite summation: ∑ (-f) = -∑ f.
sub_neg_eq_add- Subtracting a negative quantity is equivalent to addition: a - (-b) = a + b.
Finset.sum_add_distrib- The sum of a sum equals the sum of the individual sums: ∑ (f + g) = ∑ f + ∑ g.
lt_trichotomy- In any linear order, exactly one of a < b, a = b, or b < a holds.
if_pos- If a proposition c is true, the conditional expression (if c then t else e) evaluates to t.
if_neg- If a proposition c is false, the conditional expression (if c then t else e) evaluates to e.
asymm- An asymmetric relation satisfies r(a, b) → ¬r(b, a); in particular, a < b implies ¬(b < a).
add_zero- Adding zero on the right leaves an element unchanged: a + 0 = a.
zero_add- Adding zero on the left leaves an element unchanged: 0 + a = a.
Finset.mul_sum- A factor distributes from the left over a finite sum: a * ∑ f_i = ∑ (a * f_i).
mul_comm- Multiplication is commutative: a * b = b * a.
- The hypothesis `hF_skew` is brought into scope on line 3 via `have _ := hF_skew` but is never actually used; skew-symmetry of G and the voltage law on i ≠ j suffice since the sum only ranges over pairs with i < j.
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.
/-- The cross term in the energy of a potential-induced flow and a feasible flow equals the inner product of potentials and demands. -/theorem electrical_flow_cross_term {k : ℕ} (d : Fin k → Fin k → ℝ) (F G : Fin k → Fin k → ℝ) (h : Fin k → ℝ) (b : Fin k → ℝ) (hF_skew : ∀ i j, F i j = -F j i) (hF_volt : ∀ i j, i ≠ j → d i j * F i j = h i - h j) (hG_skew : ∀ i j, G i j = -G j i) (hG_div : ∀ i, ∑ j, G i j = b i) : (∑ i : Fin k, ∑ j with i < j, d i j * F i j * G i j) = ∑ i, b i * h i := by have _ := hF_skew have h1 : (∑ i : Fin k, ∑ j with i < j, d i j * F i j * G i j) = ∑ i, ∑ j, if i < j then (h i - h j) * G i j else 0 := by apply Finset.sum_congr rfl intro i _ rw [Finset.sum_filter] apply Finset.sum_congr rfl intro j _ split_ifs with hij · rw [hF_volt i j (ne_of_lt hij)] · rfl rw [h1] have h2 : (∑ i : Fin k, ∑ j, if i < j then (h i - h j) * G i j else (0 : ℝ)) = (∑ i, ∑ j, if i < j then h i * G i j else 0) - (∑ i, ∑ j, if i < j then h j * G i j else 0) := by rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro i _ rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro j _ split_ifs <;> ring rw [h2] have h3 : (∑ i : Fin k, ∑ j, if i < j then h j * G i j else (0 : ℝ)) = - ∑ i, ∑ j, if j < i then h i * G i j else 0 := by rw [Finset.sum_comm] rw [← Finset.sum_neg_distrib] apply Finset.sum_congr rfl intro i _ rw [← Finset.sum_neg_distrib] apply Finset.sum_congr rfl intro j _ rw [hG_skew j i] split_ifs <;> ring rw [h3, sub_neg_eq_add, ← Finset.sum_add_distrib] have h4 : ∀ i : Fin k, (∑ j, if i < j then h i * G i j else 0) + (∑ j, if j < i then h i * G i j else 0) = b i * h i := by intro i rw [← Finset.sum_add_distrib] have hterm : (∑ j, ((if i < j then h i * G i j else 0) + (if j < i then h i * G i j else 0))) = ∑ j, h i * G i j := by apply Finset.sum_congr rfl intro j _ rcases lt_trichotomy i j with hij | rfl | hji · rw [if_pos hij, if_neg (asymm hij), add_zero] · have hG0 : G i i = 0 := by have := hG_skew i i; linarith simp [hG0] · rw [if_pos hji, if_neg (asymm hji), zero_add] rw [hterm, ← Finset.mul_sum, hG_div i, mul_comm] apply Finset.sum_congr rfl intro i _ exact h4 i