Affine substitution preserves the magic property
ProvedMagicSquares.affine_preserves_magicAffine substitution. Let be a magic square of order with line sum , and let be scalars. The array with entries
is again magic, with line sum
Each line has exactly entries, so its sum becomes ; this applies to rows, columns and both main diagonals alike. The shift by contributes because it is added times along the line.
Two consequences drive the enumerative theory. Taking shows that the counting function depends only on the line sum up to translation, and taking over gives the classical complement , which sends a normal magic square of order to another one with line sum .
Formalization Note affine a b M is the entrywise map from
Definitions.Def_MagicSquaresTransforms. The ring law is used only to distribute
over a finite sum and to collapse to .
import Mathlib import Definitions.Def_MagicSquares import Definitions.Def_MagicSquaresTransforms
namespace MagicSquares
theorem affine_preserves_magic {n : ℕ} {α : Type*} [Semiring α]
(M : Square n α) (s a b : α) (hM : IsMagic M s) :
IsMagic (affine a b M) (a * s + n • b) := by sorry
end MagicSquares