Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

MacMahon parametrization: 3x3 magic squares vs admissible pairs

Proved
MagicSquares.magic_three_param_bij

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

combinatoricsenumerative-combinatoricsmagic-squares

The map

M⟼(M00, M02)M \longmapsto (M_{00},\, M_{02})M⟼(M00​,M02​)

is a bijection from the 3×33 \times 33×3 magic squares with nonnegative entries and line sum 3e3e3e onto the admissible parameter pairs

{(a,c)∈N2:e≤a+c≤3e,  a≤e+c,  c≤e+a}.\{(a,c) \in \mathbb{N}^{2} : e \le a + c \le 3e,\; a \le e + c,\; c \le e + a\}.{(a,c)∈N2:e≤a+c≤3e,a≤e+c,c≤e+a}.

Consequently the two counting functions agree: M3(3e)=paramCount(e)M_{3}(3e) = \mathrm{paramCount}(e)M3​(3e)=paramCount(e).

Injectivity. MacMahon's centre identity gives M11=eM_{11} = eM11​=e; then the diagonal and anti-diagonal identities give M22=2e−aM_{22} = 2e - aM22​=2e−a and M20=2e−cM_{20} = 2e - cM20​=2e−c, the row and column identities fill in M01=3e−a−cM_{01} = 3e - a - cM01​=3e−a−c, M21=a+c−eM_{21} = a + c - eM21​=a+c−e, M10=e+c−aM_{10} = e + c - aM10​=e+c−a, M12=e+a−cM_{12} = e + a - cM12​=e+a−c, and M02=cM_{02} = cM02​=c, M00=aM_{00} = aM00​=a by definition. So (a,c)(a,c)(a,c) determines MMM completely.

Surjectivity. Given an admissible pair, the array mkMagic3 e a c has nonnegative entries (that is exactly what admissibility says, together with the implied bounds a,c≤2ea, c \le 2ea,c≤2e) and its three rows, three columns and two diagonals all sum to 3e3e3e; each entry is at most 3e3e3e, so it lies in the search space {0,…,3e}\{0,\dots,3e\}{0,…,3e} used by magicCount.

Formalization Note magicCount 3 (3*e) counts arrays with entries in Fin (3*e+1); paramCount e counts the finset paramSet e. The bijection is expressed as an equality of cardinalities.

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

theorem magic_three_param_bij (e : ℕ) :
    magicCount 3 (3 * e) = paramCount e := by sorry

end MagicSquares
Source
P. A. MacMahon, Combinatory Analysis (1915); G. Xin, Constructing all magic squares of order three (2008).
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