Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Every order-three magic square of line sum 3e is the parametrized one

Proved
MagicSquares.magic_three_param_necessary

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

combinatoricsmagic-squares

The parametrization is complete. Let MMM be a 3×33\times33×3 magic square with nonnegative integer entries and line sum 3e3e3e. Then MMM is exactly the parametrized array built from its two top corners:

M \;=\; \begin{pmM_{00}trix} M_{00} & 3e-M_{00}-M_{02} & M_{02}\\ e+M_{02}-M_{00} & e & e+M_{00}-M_{02}\\ 2e-M_{02} & M_{00}+M_{02}-e & 2e-M_{00} \end{pmM_{00}trix} ,

where a=M00a=M_{00}a=M00​ and c=M02c=M_{02}c=M02​.

The eight line identities determine the remaining seven cells uniquely. The centre is eee (MacMahon's identity 3M11=s3M_{11}=s3M11​=s with s=3es=3es=3e). The two diagonals give M22=2e−M00M_{22}=2e-M_{00}M22​=2e−M00​ and M20=2e−M02M_{20}=2e-M_{02}M20​=2e−M02​; row 000 then gives M01=3e−M00−M02M_{01}=3e-M_{00}-M_{02}M01​=3e−M00​−M02​; column 000 and column 222 give M10=e+M02−M00M_{10}=e+M_{02}-M_{00}M10​=e+M02​−M00​ and M12=e+M00−M02M_{12}=e+M_{00}-M_{02}M12​=e+M00​−M02​; and column 111 gives M21=M00+M02−eM_{21}=M_{00}+M_{02}-eM21​=M00​+M02​−e. Since MMM is a genuine square over N\mathbb{N}N, none of these subtractions truncates.

Consequently a 3×33\times33×3 magic square of line sum 3e3e3e is determined by its two top corners, and the pair (M00,M02)(M_{00},M_{02})(M00​,M02​) satisfies precisely the admissibility inequalities — the count of such squares is therefore the count of admissible pairs, which is MacMahon's 2e2+2e+12e^{2}+2e+12e2+2e+1.

Formalization Note The proof expands the eight line identities of IsMagic and closes each of the nine cell equalities by omega; no integrality hypothesis beyond working over N\mathbb{N}N is needed.

Preamble
import Mathlib
import Definitions.Def_MagicSquares
import Definitions.Def_MagicSquaresParam3
Formal statement
namespace MagicSquares

theorem magic_three_param_necessary (e : ℕ) (M : Square 3 ℕ)
    (hM : IsMagic M (3 * e)) :
    M = mkMagic3 e (M 0 0) (M 0 2) := by sorry

end MagicSquares
Source
Beck, Cohen, Cuomo & Gribelyuk, The number of ``magic'' squares, cubes and hypercubes, Amer. Math. Monthly 110 (2003), 707--717; arXiv:math/0201013v3. G. Xin, Constructing all magic squares of order three, Discrete Math. 308 (2008); arXiv:math/0610771.
Human review
  • Endorsed by Shuze Chen · Sep 16, 2026

  • Endorsed by Yuxuan Xu · Sep 16, 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