AFTD Auto-Formalizing Theoretical Domains

magic_square_score

def

Given dA dB dE : ℕ, Alice's effects A : Fin 3 → (Fin 3 → Bool) → Matrix (Fin dA) (Fin dA) ℂ (A x s: row x, then answer s), Bob's effects B : Fin 3 → (Fin 3 → Bool) → Matrix (Fin dB) (Fin dB) ℂ (B j c: column j, then answer c), and a complex matrix ρ indexed by the product type (Fin dA × Fin dB) × Fin dE (the state on Alice, Bob and the adversary Eve, left-associated): magic_square_score A B ρ is the real number (1/9) · Σ_{x : Fin 3} Σ_{j : Fin 3} Σ_{s : Fin 3 → Bool} Σ_{c : Fin 3 → Bool} (if s j = c x then Re Tr(((A x s ⊗ₖ B j c) ⊗ₖ I_{Fin dE}) * ρ) else 0), with Kronecker products (Matrix.kronecker) grouped left as written and Re the real part of the complex trace. It is the score of the strategy: with row x and column j uniform and independent, the probability that Alice's j-th sign equals Bob's sign in row x, i.e. Tr(W ρ) with W = (1/9) Σ_{x,j,s,c} [s_j = c_x] A_{s|x} ⊗ B_{c|j} ⊗ I_E.

Statement

noncomputable def magic_square_score {dA dB dE : ℕ}
    (A : Fin 3 → (Fin 3 → Bool) → Matrix (Fin dA) (Fin dA) ℂ)
    (B : Fin 3 → (Fin 3 → Bool) → Matrix (Fin dB) (Fin dB) ℂ)
    (ρ : Matrix ((Fin dA × Fin dB) × Fin dE) ((Fin dA × Fin dB) × Fin dE) ℂ) : ℝ
Defined in
arXiv:2610.12001 (Exact value and rigidity of the 2x3 magic rectangle), Sec. 6, proof of Theorem 6.1 (the winning effect W).
Verified
02 Nov 2026
Axioms
none listed
Used by 3
  • magic_square_guess_fn_concaveOnThe function g = magic_square_guess_fn — g(w) is the supremum of the adversary's probability of guessing Alice's complete first-row answer…
  • magic_square_guess_fnmagic_square_guess_fn w is the real supremum (sSup in ℝ) of the set of reals p for which there exist dA dB dE : ℕ, A : Fin 3 → (Fin 3 →…
  • magic_square_guess_fn_ge_linearFor 0 ≤ δ ≤ 1 - β₀, with β₀ = (2 + √(2/3))/3 the magic-square threshold: 1 - g(β₀ + δ) ≤ 3δ / (4(1 - β₀)), where β₀ =…

Read back from the Lean

Given natural numbers dA, dB, and dE, families of complex matrices A : Fin 3 → (Fin 3 → Bool) → Matrix (Fin dA) (Fin dA) ℂ and B : Fin 3 → (Fin 3 → Bool) → Matrix (Fin dB) (Fin dB) ℂ, and a state/matrix ρ : Matrix ((Fin dA × Fin dB) × Fin dE) ((Fin dA × Fin dB) × Fin dE) ℂ, magic_square_score A B ρ is the real number defined as: (1 / 9) multiplied by the sum over all row choices x : Fin 3, column choices j : Fin 3, row assignments s : Fin 3 → Bool, and column assignments c : Fin 3 → Bool of: - the real part of the trace of (((A x s ⊗ₖ B j c) ⊗ₖ (1 : Matrix (Fin dE) (Fin dE) ℂ)) * ρ) if s j = c x, - and 0 otherwise, where ⊗ₖ denotes the Kronecker product of matrices and 1 is the identity matrix on Fin dE.

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

Lean source view module on GitHub

/-- The winning probability of a magic-square strategy with uniform independent inputs: Alice gets row `x`, Bob column `j`, and they win when Alice's `j`-th sign equals Bob's sign in row `x`. -/
noncomputable def magic_square_score {dA dB dE : ℕ}
    (A : Fin 3 → (Fin 3 → Bool) → Matrix (Fin dA) (Fin dA) ℂ)
    (B : Fin 3 → (Fin 3 → Bool) → Matrix (Fin dB) (Fin dB) ℂ)
    (ρ : Matrix ((Fin dA × Fin dB) × Fin dE) ((Fin dA × Fin dB) × Fin dE) ℂ) : ℝ := open scoped Kronecker in
  (1 / 9 : ℝ) * ∑ x : Fin 3, ∑ j : Fin 3, ∑ s : Fin 3 → Bool, ∑ c : Fin 3 → Bool,
    if s j = c x then
      (((A x s ⊗ₖ B j c) ⊗ₖ (1 : Matrix (Fin dE) (Fin dE) ℂ)) * ρ).trace.re
    else 0
See it in the graphDiscuss this resultChallenge it