Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Bijection between semi-magic squares and normalized parameters

Proved
MagicSquares.sm3_bij

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

combinatoricsenumerative-combinatoricsmagic-squares

The map

(u,v,w,x,y,z)⟼uD+vE+wF+xA+yB+zC(u,v,w,x,y,z)\longmapsto uD+vE+wF+xA+yB+zC(u,v,w,x,y,z)⟼uD+vE+wF+xA+yB+zC

is a bijection from the normalized coefficient vectors — six nonnegative integers summing to ttt with min⁡(x,y,z)=0\min(x,y,z)=0min(x,y,z)=0 — onto the 3×33\times33×3 semi-magic squares of line sum ttt. Consequently

H3(t)=sm3Count(t).H_{3}(t)=\mathrm{sm3Count}(t).H3​(t)=sm3Count(t).

Surjectivity and injectivity are exactly the two halves of sm3_canonical; what is left is the bookkeeping that turns a bijection of carriers into an equality of Finset.cards. Two coercions have to be handled explicitly. First, semiMagicCount 3 t counts arrays with entries in Fin (t+1), so the forward map must be read into that finite type — legitimate because every entry of a semi-magic square of line sum ttt is at most ttt. Second, sm3Count t counts functions Fin 6 → Fin (t+1), and the bound is again lossless because the six coefficients sum to ttt.

Formalization Note Both directions therefore need a Finset.card_bij with an explicit proof that the round trip is the identity on each side.

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

theorem sm3_bij (t : ℕ) : semiMagicCount 3 t = sm3Count t := by sorry

end MagicSquares
Source
P. A. MacMahon, Combinatory Analysis (1915); M. Beck, T. Cohen, J. Cuomo, P. Gribelyuk, The number of "magic" squares, cubes and hypercubes, Amer. Math. Monthly 110 (2003), 707-717; arXiv:math/0201013v3, Section 2, Theorem 1.
Human review
  • Endorsed by Shuze Chen · Sep 17, 2026

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