Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Counting admissible MacMahon parameters for 3x3 squares

Proved
MagicSquares.param_three_card

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

combinatoricsenumerative-combinatoricsmagic-squares

The number of admissible MacMahon parameter pairs for line sum 3e3e3e is

paramCount(e)  =  #{(a,c)∈N2:e≤a+c≤3e,  a≤e+c,  c≤e+a}  =  2e2+2e+1.\mathrm{paramCount}(e) \;=\; \#\{(a,c) \in \mathbb{N}^{2} : e \le a+c \le 3e,\; a \le e+c,\; c \le e+a\} \;=\; 2e^{2} + 2e + 1 .paramCount(e)=#{(a,c)∈N2:e≤a+c≤3e,a≤e+c,c≤e+a}=2e2+2e+1.

Proof. Substituting p=a−ep = a - ep=a−e and q=c−eq = c - eq=c−e, the four inequalities read ∣p+q∣≤e|p+q| \le e∣p+q∣≤e and ∣p−q∣≤e|p-q| \le e∣p−q∣≤e, and since max⁡(∣p+q∣,∣p−q∣)=∣p∣+∣q∣\max(|p+q|,|p-q|) = |p| + |q|max(∣p+q∣,∣p−q∣)=∣p∣+∣q∣ this is exactly ∣p∣+∣q∣≤e|p| + |q| \le e∣p∣+∣q∣≤e: the ℓ1\ell_{1}ℓ1​ ball of radius eee in Z2\mathbb{Z}^{2}Z2. On the sphere ∣p∣+∣q∣=k|p| + |q| = k∣p∣+∣q∣=k there are 4k4k4k lattice points for k≥1k \ge 1k≥1 and one for k=0k = 0k=0, so the ball has

1+∑k=1e4k  =  1+2e(e+1)  =  2e2+2e+11 + \sum_{k=1}^{e} 4k \;=\; 1 + 2e(e+1) \;=\; 2e^{2} + 2e + 11+k=1∑e​4k=1+2e(e+1)=2e2+2e+1

points.

Equivalently one may sum over aaa: for fixed a∈[0,2e]a \in [0,2e]a∈[0,2e] the admissible ccc form the interval [ ∣a−e∣, min⁡(a+e, 3e−a) ][\,|a-e|,\ \min(a+e,\,3e-a)\,][∣a−e∣, min(a+e,3e−a)], which has 2a+12a+12a+1 elements when a≤ea \le ea≤e and 4e−2a+14e-2a+14e−2a+1 elements when a≥ea \ge ea≥e; summing gives (e+1)2+e2=2e2+2e+1(e+1)^{2} + e^{2} = 2e^{2} + 2e + 1(e+1)2+e2=2e2+2e+1.

Formalization Note paramCount e is the cardinality of the finset paramSet e, defined by filtering the box [0,2e]×[0,2e][0,2e] \times [0,2e][0,2e]×[0,2e] — the bounds a,c≤2ea, c \le 2ea,c≤2e are implied by admissibility, so this is lossless.

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

theorem param_three_card (e : ℕ) :
    paramCount e = 2 * e ^ 2 + 2 * e + 1 := by sorry

end MagicSquares
Source
P. A. MacMahon, Combinatory Analysis (1915): M3(t)=29t2+23t+1M_3(t) = \tfrac{2}{9}t^2 + \tfrac{2}{3}t + 1M3​(t)=92​t2+32​t+1 for 3∣t3 \mid t3∣t.
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