Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Ramanujan's Notebooks, Part I, Ch. 1: ch1IsMagic

Definition
RamanujanNotebooks_ch01_ch1IsMagic

by FormallyCorrect · Oct 6, 2026 · Mathlib 0df444a (Lean v4.33.1)

number-theoryramanujan-notebooks

M is a magic square with common sum r in the sense of Chapter 1 (p. 16): every row, every column and both diagonals of the n × n array of natural numbers sum to r. Distinctness of the entries is NOT part of this predicate (the book asks for it only "usually"); zero entries are allowed. Reference: ![![6, 1, 8], ![7, 5, 3], ![2, 9, 4]] is magic with r = 15; ![![10, 2, 7], ![4, 6, 9], ![5, 11, 3]] is not magic for any r (secondary diagonal 18, rows 19).

Definition code
import Mathlib
import Definitions.Def_RamanujanNotebooks_ch01_ch1AntiDiagSum
import Definitions.Def_RamanujanNotebooks_ch01_ch1DiagSum
import Definitions.Def_RamanujanNotebooks_ch01_ch1IsSemiMagic

namespace RamanujanNotebooks

/-- `M` is a magic square with common sum `r` in the sense of Chapter 1 (p. 16): every row,
every column and both diagonals of the `n × n` array of natural numbers sum to `r`.
Distinctness of the entries is NOT part of this predicate (the book asks for it only
"usually"); zero entries are allowed.
Reference: `![![6, 1, 8], ![7, 5, 3], ![2, 9, 4]]` is magic with `r = 15`;
`![![10, 2, 7], ![4, 6, 9], ![5, 11, 3]]` is not magic for any `r` (secondary diagonal `18`,
rows `19`). -/
def ch1IsMagic {n : ℕ} (M : Fin n → Fin n → ℕ) (r : ℕ) : Prop :=
  ch1IsSemiMagic M r ∧ ch1DiagSum M = r ∧ ch1AntiDiagSum M = r

end RamanujanNotebooks
Source
Bruce C. Berndt, Ramanujan's Notebooks, Part I (Springer, 1985), Chapter 1.

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, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me