BCCG Theorem 1: the counting polynomial of semi-magic squares
OpenMagicSquares.semi_magic_polynomialGoal. For every order there is a polynomial which, simultaneously, has degree exactly , agrees with the counting function at every nonnegative integer, satisfies the reciprocity law for every integer , and vanishes at . This is Theorem 1 of Beck--Cohen--Cuomo--Gribelyuk, proved by Ehrhart and by Stanley in 1973 and given an elementary proof by Spencer in 1980. It separates the semi-magic squares from the magic, symmetric and pandiagonal classes, whose counting functions are quasi-polynomials rather than polynomials.
import Mathlib import Definitions.Def_MagicSquares open MagicSquares
namespace MagicSquares
theorem semi_magic_polynomial (n : ℕ) (hn : 1 ≤ n) :
∃ p : Polynomial ℚ,
p.natDegree = (n - 1) ^ 2 ∧
(∀ t : ℕ, p.eval (t : ℚ) = (semiMagicCount n t : ℚ)) ∧
(∀ t : ℤ, p.eval (((-(n : ℤ) - t : ℤ) : ℚ))
= (-1 : ℚ) ^ (n - 1) * p.eval ((t : ℤ) : ℚ)) ∧
(∀ k : ℤ, 1 ≤ k → k ≤ (n : ℤ) - 1 → p.eval (-(k : ℚ)) = 0) := by
sorry
end MagicSquaresRead-back
What the Lean code literally says, in plain math · deepseek-v4.1-flash (WorkBuddy blind sub-agent)
Let be a natural number with . Then there exists a polynomial satisfying all of the following simultaneously:
- its natural degree equals , where is the natural-number subtraction (so is necessarily non-zero of ordinary degree );
- for every natural number , in ;
- for every integer , , where is minus (lifted to ) and the exponent is natural subtraction;
- for every integer , if and (integer subtraction) then .
Here counts the arrays over (entries integers ) whose every row and column sums to . When the stated degree is , the reciprocity factor is , and the vanishing condition is vacuously true.
Confirmed by the mission captain (proposal self-audit).