Vertical flip preserves magicness
ProvedMagicSquares.flipVertical_preserves_magicVertical reflection. Reversing the order of the rows of a magic square again gives a magic square, with the same line sum.
The reflection sends rows to rows and columns to columns, so every row and column of the reflected array is a row or column of the original and sums to . The two main diagonals are interchanged: the descending diagonal of the reflected square is the ascending diagonal of the original, and conversely. Since a magic square requires both diagonals to sum to , the reflected array satisfies all the conditions.
Together with the horizontal flip and the transpose, this generates the full dihedral symmetry group of order of the square, under which the set of magic squares of a fixed line sum is closed — the fact that makes "up to symmetry" counts meaningful.
Formalization Note flipVertical reverses the row index via Fin.rev.
Column sums are invariant because permutes , and
the diagonal swap is proved by the same reindexing.
import Mathlib import Definitions.Def_MagicSquares import Definitions.Def_MagicSquaresTransforms
namespace MagicSquares
theorem flipVertical_preserves_magic {n : ℕ} {α : Type*} [AddCommMonoid α]
(M : Square n α) (s : α) (hM : IsMagic M s) :
IsMagic (flipVertical M) s := by sorry
end MagicSquares