Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

MacMahon's count of 3x3 magic squares with line sum a multiple of 3

Proved
MagicSquares.magic_count_three_divisible

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

combinatoricsmagic-squares

MacMahon's 1915 count of 3×33 \times 33×3 magic squares whose line sum is a multiple of 333.

Write M3(t)M_{3}(t)M3​(t) for the number of 3×33 \times 33×3 arrays of nonnegative integers whose three rows, three columns and two main diagonals all sum to ttt (entries need not be distinct). Then M3(t)M_{3}(t)M3​(t) vanishes unless 3∣t3 \mid t3∣t, and for t=3et = 3et=3e,

M3(3e)=2e2+2e+1,M_{3}(3e) = 2e^{2} + 2e + 1 ,M3​(3e)=2e2+2e+1,

which is the integral form of 29t2+23t+1\tfrac{2}{9}t^{2} + \tfrac{2}{3}t + 192​t2+32​t+1.

The companion statement MagicSquares.magic_count_three_otherwise records the vanishing when 3∤t3 \nmid t3∤t; together they give the complete counting function.

Formalization Note magicCount n t counts arrays with entries in Fin (t+1) satisfying the magic identities after coercion to ℕ. This is lossless because every entry of a nonnegative magic square with line sum ttt is at most ttt.

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

theorem magic_count_three_divisible (e : ℕ) :
    magicCount 3 (3 * e) = 2 * e ^ 2 + 2 * e + 1 := 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, Section 2, MacMahon's formula for M3(t)M_{3}(t)M3​(t) (1915).
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