Ramanujan's Notebooks, Part I, Ch. 1: ch1IsSemiMagic
DefinitionRamanujanNotebooks_ch01_ch1IsSemiMagicnumber-theoryramanujan-notebooks
Every row sum and every column sum of the n × n array M equals r; nothing is
asked of the two diagonals and nothing about distinctness of the entries.
Reference: ![![10, 2, 8], ![4, 5, 11], ![6, 13, 1]] satisfies this with r = 20
(its diagonal sums are 16 and 19).
Definition code
import Mathlib
namespace RamanujanNotebooks
/-- Every row sum and every column sum of the `n × n` array `M` equals `r`; nothing is
asked of the two diagonals and nothing about distinctness of the entries.
Reference: `![![10, 2, 8], ![4, 5, 11], ![6, 13, 1]]` satisfies this with `r = 20`
(its diagonal sums are `16` and `19`). -/
def ch1IsSemiMagic {n : ℕ} (M : Fin n → Fin n → ℕ) (r : ℕ) : Prop :=
(∀ i : Fin n, (∑ j : Fin n, M i j) = r) ∧ (∀ j : Fin n, (∑ i : Fin n, M i j) = r)
end RamanujanNotebooks
Source
Bruce C. Berndt, Ramanujan's Notebooks, Part I (Springer, 1985), Chapter 1.