import Std namespace CubeParity def Cube : Nat → Type | 0 => Unit | n+1 => Bool × Cube n def total : (n : Nat) → (Cube n → Rat) → Rat | 0, f => f () | n+1, f => total n (fun y => f (false, y)) + total n (fun y => f (true, y)) def parity : (n : Nat) → Cube n → Rat | 0, _ => 1 | n+1, (b,x) => if b then -parity n x else parity n x def distance : (n : Nat) → Cube n → Cube n → Nat | 0, _, _ => 0 | n+1, (b,x), (c,y) => distance n x y + (if b == c then 0 else 1) def diff : Nat → (Nat → Rat) → Rat | 0, f => f 0 | n+1, f => diff n f - diff n (fun j => f (j+1)) theorem total_neg (n : Nat) (f : Cube n → Rat) : total n (fun y => -(f y)) = -(total n f) := by induction n with | zero => rfl | succ n ih => simp only [total, ih] grind theorem parity_row (n : Nat) (f : Nat → Rat) (x : Cube n) : total n (fun y => f (distance n x y) * parity n y) = parity n x * diff n f := by induction n generalizing f with | zero => simp [total, distance, parity, diff] | succ n ih => obtain ⟨b,x⟩ := x cases b <;> simp [total, distance, parity, diff, Rat.mul_neg, total_neg, ih f x, ih (fun j => f (j+1)) x] <;> grind def choose2 (m : Nat) := m*(m-1)/2 def entry (j : Nat) : Rat := 16 / ((9*choose2 (8-j) + 15*j*(8-j) + 25*choose2 j : Nat) : Rat) theorem parity_eigenvalue (x : Cube 8) : total 8 (fun y => entry (distance 8 x y) * parity 8 y) = parity 8 x * (-190592 / 1063516360725) := by rw [parity_row] congr 1 decide +kernel theorem parity_square (n : Nat) (x : Cube n) : parity n x * parity n x = 1 := by induction n with | zero => simp [parity] | succ n ih => obtain ⟨b,x⟩ := x cases b <;> simp [parity, ih, Rat.neg_mul, Rat.mul_neg] def PosSemidefinite (n : Nat) (f : Nat → Rat) : Prop := ∀ w : Cube n → Rat, 0 ≤ total n (fun x => w x * total n (fun y => f (distance n x y) * w y)) theorem not_posSemidefinite : ¬ PosSemidefinite 8 entry := by intro h have bad := h (parity 8) have row (x : Cube 8) : parity 8 x * total 8 (fun y => entry (distance 8 x y) * parity 8 y) = -190592 / 1063516360725 := by rw [parity_eigenvalue, ← Rat.mul_assoc, parity_square, Rat.one_mul] simp only [row] at bad exact (by decide +kernel : ¬ (0 : Rat) ≤ total 8 (fun _ => -190592 / 1063516360725)) bad end CubeParity