Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

The pandiagonal squares of order two

Proved
MagicSquares.pandiagonal_count_two

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

combinatoricsenumerative-combinatoricsmagic-squares

The order-two pandiagonal count. With Pn(t)P_{n}(t)Pn​(t) the number of pandiagonal squares of order nnn and line sum ttt in the counting-theory sense of IsPandiagonal (semi-magic plus the wrapped diagonals parallel to the main diagonal), the theorem states

P2(t)={1,2∣t,0,2∤t.P_{2}(t)=\begin{cases}1,&2\mid t,\\ 0,&2\nmid t.\end{cases}P2​(t)={1,0,​2∣t,2∤t.​

Proof. At order two the two wrapped diagonals of a semi-magic square are exactly its main and anti-diagonal, so IsPandiagonal coincides with IsMagic and P2=M2P_{2}=M_{2}P2​=M2​. This is the last order at which the two notions agree: from order three on they diverge.

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

theorem pandiagonal_count_two (t : ℕ) : pandiagonalCount 2 t = if 2 ∣ t then 1 else 0 := by sorry

end MagicSquares
Source
M. Beck, M. Cohen, J. Cuomo and P. Gribelyuk, The number of "magic" squares, cubes and hypercubes, Amer. Math. Monthly 110 (2003), 707--717 (arXiv:math/0201013).

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