Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

The semi-magic squares of order two

Proved
MagicSquares.semi_magic_count_two

by Yuxuan Xu · Sep 18, 2026 · Mathlib 0df444a (Lean v4.33.1)

combinatoricsenumerative-combinatoricsmagic-squares

The order-two semi-magic count. Writing Hn(t)H_{n}(t)Hn​(t) for the number of n×nn\times nn×n arrays of nonnegative integers whose rows and columns all sum to ttt, the theorem states

H2(t)=t+1.H_{2}(t)=t+1 .H2​(t)=t+1.

Proof. A 2×22\times22×2 semi-magic square of line sum ttt reads (at−at−aa)\begin{pmatrix} a & t-a\\ t-a & a\end{pmatrix}(at−a​t−aa​), so it is determined by its top-left corner aaa, and aaa may be any of 0,1,…,t0,1,\dots,t0,1,…,t. This is the first value in the structural statement that Hn(t)H_{n}(t)Hn​(t) is a polynomial of degree (n−1)2(n-1)^{2}(n−1)2 — for n=2n=2n=2 that is degree one, matching t+1t+1t+1.

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

theorem semi_magic_count_two (t : ℕ) : semiMagicCount 2 t = t + 1 := by sorry

end MagicSquares
Source
M. Beck, M. Cohen, J. Cuomo and P. Gribelyuk, The number of "magic" squares, cubes and hypercubes, Amer. Math. Monthly 110 (2003), 707--717 (arXiv:math/0201013).
Human review
  • Endorsed by Shuze Chen · Sep 19, 2026

  • Endorsed by Yuxuan Xu · Sep 19, 2026

    Confirmed by the mission captain (proposal self-audit).

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