Total sum of a semi-magic square is n times the line sum
ProvedMagicSquares.total_sum_eq_n_line_sumcombinatoricsmagic-squares
Row-sum aggregation. Let be an array over an additive commutative monoid, and suppose every row sums to the same value (a semi-magic square of line sum ). Then the sum of all entries is
Indeed the total is the sum of the row sums, each of which equals . This is the first structural identity of the theory: it is what converts the row condition into a global constraint, and it is the reason the magic constant of a normal magic square of order must be — the entries are , whose total is , and dividing by gives the line sum.
Formalization Note Entries live in an arbitrary AddCommMonoid, so the
statement reads (nsmul) rather than ; over
or a semiring the two coincide. Only the row half of IsSemiMagic is used.
Preamble
import Mathlib import Definitions.Def_MagicSquares
Formal statement
namespace MagicSquares
theorem total_sum_eq_n_line_sum {n : ℕ} {α : Type*} [AddCommMonoid α]
(M : Square n α) (s : α) (hM : IsSemiMagic M s) :
totalSum M = n • s := by sorry
end MagicSquaresSource
Beck, Cohen, Cuomo & Gribelyuk, The number of ``magic'' squares, cubes and hypercubes, Amer. Math. Monthly 110 (2003), 707--717; arXiv:math/0201013v3.