Transposing a magic square preserves magicness
ProvedMagicSquares.transpose_preserves_magiccombinatoricsmagic-squares
Transposition. If is a magic square of line sum , so is its transpose , with the same line sum.
The square is a symmetry of the grid, so it permutes the lines: rows of are the columns of and vice versa, while each main diagonal is fixed. Hence every line of is a line of and still sums to , and the same holds verbatim for panmagic (pandiagonal) squares, whose broken diagonals are also carried to broken diagonals.
Formalization Note transpose is the entrywise flip
from Definitions.Def_MagicSquaresTransforms. The four line sums are tracked by
rowSum_transpose, colSum_transpose, diagSum_transpose and
antiDiagSum_transpose; the anti-diagonal case uses that is a
bijection of , so reindexing the sum is legitimate.
Preamble
import Mathlib import Definitions.Def_MagicSquares import Definitions.Def_MagicSquaresTransforms
Formal statement
namespace MagicSquares
theorem transpose_preserves_magic {n : ℕ} {α : Type*} [AddCommMonoid α]
(M : Square n α) (s : α) (hM : IsMagic M s) :
IsMagic (transpose M) 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.