NLA-lib Explorer

Finset.sum_grid_boundary_eq

Library · theorem

On an n\times n grid with n>0, assign an element of an additive commutative group to each oriented edge. If adjacent cells agree on their shared edge and the bottom plus right edge equals the top plus left edge in each cell, the same identity holds for the four side sums around the outside of the grid.

Finset.sum_grid_boundary_eq.{u_1} {G : Type u_1} [AddCommGroup G]
  (bottom top left right : ℕ → ℕ → G) {n : ℕ} (hn : 0 < n)
  (hc : ∀ i < n, ∀ j < n, bottom i j + right i j = top i j + left i j)
  (hh : ∀ i < n, ∀ (j : ℕ), j + 1 < n → bottom i (j + 1) = top i j)
  (hv : ∀ (i : ℕ), i + 1 < n → ∀ j < n, left (i + 1) j = right i j) :
  ∑ j ∈ Finset.range n, right (n - 1) j - ∑ j ∈ Finset.range n, left 0 j =
    ∑ i ∈ Finset.range n, top i (n - 1) - ∑ i ∈ Finset.range n, bottom i 0

Full source on GitHub

Import NLAlib.ForMathlib.Algebra.BigOperators.Grid.