Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Positive semi-magic squares shift to line sum t - n

Proved
MagicSquares.positive_shift_count

by Tamas Fulop · Sep 20, 2026 · Mathlib 0df444a (Lean v4.33.1)

combinatoricsehrhartenumerative-combinatoricsmagic-squares

The shift bijection between positive and ordinary semi-magic squares. Let n≥1n \ge 1n≥1 and t≥nt \ge nt≥n. Subtracting the all-ones matrix JJJ gives a bijection between the positive semi-magic squares of line sum ttt (every entry at least one) and all semi-magic squares of line sum t−nt - nt−n, so that

In(t)=Hn(t−n).I_{n}(t) = H_{n}(t - n).In​(t)=Hn​(t−n).

The map is its own inverse up to adding JJJ back: since JJJ itself has every line sum equal to nnn, subtracting it drops every line sum by exactly nnn while preserving nonnegativity precisely for the positive squares. This is the elementary combinatorial half of Stanley's reciprocity argument: it converts the geometric interior count supplied by Ehrhart--Macdonald reciprocity into an ordinary value of the counting function, with no polyhedral machinery of its own.

Formalization Note Lean states both sides as cardinals over Square n (Fin (t+1))-style finsets via positiveInteriorCount and semiMagicCount, with t - n the truncated natural subtraction (exact here since t≥nt \ge nt≥n).

Preamble
import Mathlib
import Definitions.Def_MagicSquares
import Definitions.Def_MagicSquares_positiveInteriorCount
open MagicSquares
Formal statement
namespace MagicSquares

theorem positive_shift_count (n t : ℕ) (hn : 1 ≤ n) (hnt : n ≤ t) :
    positiveInteriorCount n t = semiMagicCount n (t - n) := by sorry

end MagicSquares
Source
R. P. Stanley, Duke Math. J. 40 (1973), 607--632, interior points of dilates of the Birkhoff polytope via the all-ones shift; M. Beck and D. Paxton, The Ehrhart polynomial of the Birkhoff polytope (arXiv:math.CO/0202267).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, licensed under Apache 2.0.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTermsJoin SlackJoin Zulip© 2026 Prove2Me