Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Magic constant of a normal magic square

Proved
MagicSquares.magic_constant_of_normal

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

combinatoricsmagic-squares

Every normal magic square has the magic constant n(n2+1)/2n(n^{2}+1)/2n(n2+1)/2.

Let MMM be an n×nn \times nn×n array whose entries are exactly the integers 1,2,…,n21,2,\dots,n^{2}1,2,…,n2, each used once, and suppose every row, every column and both main diagonals of MMM sum to the same number sss. Then

2s=n (n2+1).2s = n\,(n^{2}+1).2s=n(n2+1).

Equivalently s=n(n2+1)/2s = n(n^{2}+1)/2s=n(n2+1)/2, the classical magic constant: it is 1n\tfrac{1}{n}n1​ of the sum 1+2+⋯+n2=n2(n2+1)/21+2+\cdots+n^{2} = n^{2}(n^{2}+1)/21+2+⋯+n2=n2(n2+1)/2 of all entries.

Formalization Note The division by 222 is avoided by multiplying through, so the statement is an identity in N\mathbb{N}N. Normality is the conjunction of the entry bounds 1≤Mij≤n21 \le M_{ij} \le n^{2}1≤Mij​≤n2 with injectivity of the index-to-entry map.

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

theorem magic_constant_of_normal (n : ℕ) (M : Square n ℕ) (s : ℕ)
    (hN : IsNormal M) (hM : IsMagic M s) :
    2 * s = n * (n ^ 2 + 1) := by sorry

end MagicSquares
Source
Standard folklore; stated e.g. in Weisstein, MathWorld, "Magic Square", eq. for the magic constant of a normal magic square.

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