From 8bd016aa15d7a1a12dae5b5c4c08e6d7086e5591 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Sat, 28 Nov 2026 10:29:11 +0000 Subject: [PATCH 1/3] =?UTF-8?q?Import=20the=20all-dimensional=20Kochen?= =?UTF-8?q?=E2=80=93Specker=20theorem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LeanPool/KochenSpecker.lean | 21 +++ LeanPool/KochenSpecker/Cabello18.lean | 125 +++++++++++++ LeanPool/KochenSpecker/Checker.lean | 125 +++++++++++++ LeanPool/KochenSpecker/Imports.lean | 14 ++ LeanPool/KochenSpecker/Main.lean | 70 +++++++ LeanPool/KochenSpecker/Peres33.lean | 258 ++++++++++++++++++++++++++ LeanPool/KochenSpecker/Valuation.lean | 162 ++++++++++++++++ LeanPool/projects/kochen-specker.yaml | 44 +++++ 8 files changed, 819 insertions(+) create mode 100644 LeanPool/KochenSpecker.lean create mode 100644 LeanPool/KochenSpecker/Cabello18.lean create mode 100644 LeanPool/KochenSpecker/Checker.lean create mode 100644 LeanPool/KochenSpecker/Imports.lean create mode 100644 LeanPool/KochenSpecker/Main.lean create mode 100644 LeanPool/KochenSpecker/Peres33.lean create mode 100644 LeanPool/KochenSpecker/Valuation.lean create mode 100644 LeanPool/projects/kochen-specker.yaml diff --git a/LeanPool/KochenSpecker.lean b/LeanPool/KochenSpecker.lean new file mode 100644 index 0000000000..4a19ec1e52 --- /dev/null +++ b/LeanPool/KochenSpecker.lean @@ -0,0 +1,21 @@ +/- +Copyright (c) 2026 Zayn Blore. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Zayn Blore +-/ + +module + +public import LeanPool.KochenSpecker.Main + +/-! +# The Kochenโ€“Specker theorem in every finite dimension + +Source: doi:10.1512/iumj.1968.17.17004, url:https://github.com/zblore/kochen-specker-lean/tree/a9f552a11188809b15ba14ef2db5a2a8ecd3c83b +Authors: Zayn Blore +Status: verified +Main declarations: `KochenSpecker.kochen_specker`, `KochenSpecker.not_isValuation`, + `KochenSpecker.kochen_specker_of_four_le` +Tags: contextuality, inner-product-spaces, finite-certificates +MSC: 81P13, 46C05 +-/ diff --git a/LeanPool/KochenSpecker/Cabello18.lean b/LeanPool/KochenSpecker/Cabello18.lean new file mode 100644 index 0000000000..a67dc43d5c --- /dev/null +++ b/LeanPool/KochenSpecker/Cabello18.lean @@ -0,0 +1,125 @@ +/- +Copyright (c) 2026 Zayn Blore. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Zayn Blore +-/ +module + +public import LeanPool.KochenSpecker.Valuation +public import Mathlib.Algebra.BigOperators.Group.Finset.Basic + +/-! +# Dimension four: Cabello's 18 vectors, by parity + +Cabello, Estebaranz and Garcรญa-Alcaine (*Bell-Kochen-Specker theorem: A proof with 18 vectors*, +Phys. Lett. A 212 (1996) 183) gave 18 vectors in `โ„โด`, with integer coordinates, forming 9 +orthogonal bases in which every vector appears exactly twice. A valuation would make each basis +contribute exactly one `true`, nine in all, while each `true` vector is counted twice, an even +number. This proof uses no computer search. + +The parity argument is `no_assignment`; `not_isValuation_four` turns it into the theorem in `๐•œโด` +for every `RCLike ๐•œ`. The combinatorial core was first written for the author's csd-lean4 +(`Empirical/QM/Contextuality/KS18.lean`); this is a standalone version. +-/ + +@[expose] public section + +open Module + +namespace KochenSpecker.Cabello + +/-- The 18 vectors. -/ +def vecs : Fin 18 โ†’ Fin 4 โ†’ โ„ค := + ![![0, 0, 0, 1], ![0, 0, 1, 0], ![1, 1, 0, 0], ![1, -1, 0, 0], ![0, 1, 0, 0], ![1, 0, 1, 0], + ![1, 0, -1, 0], ![1, -1, 1, -1], ![1, -1, -1, 1], ![0, 0, 1, 1], ![1, 1, 1, 1], + ![0, 1, 0, -1], ![1, 0, 0, 1], ![1, 0, 0, -1], ![0, 1, -1, 0], ![1, 1, -1, 1], + ![1, 1, 1, -1], ![-1, 1, 1, 1]] + +/-- The 9 bases, as four vector indices each. -/ +def bases : Fin 9 โ†’ Fin 4 โ†’ Fin 18 := + ![![0, 1, 2, 3], ![0, 4, 5, 6], ![2, 7, 8, 9], ![6, 7, 10, 11], ![1, 4, 12, 13], + ![8, 10, 13, 14], ![3, 9, 15, 16], ![5, 11, 15, 17], ![12, 14, 16, 17]] + +/-- The integer dot product. -/ +def dot (x y : Fin 4 โ†’ โ„ค) : โ„ค := x 0 * y 0 + x 1 * y 1 + x 2 * y 2 + x 3 * y 3 + +theorem bases_orth : โˆ€ B : Fin 9, โˆ€ i j : Fin 4, i โ‰  j โ†’ + dot (vecs (bases B i)) (vecs (bases B j)) = 0 := by decide + +theorem dot_self_pos : โˆ€ n : Fin 18, 0 < dot (vecs n) (vecs n) := by decide + +/-- Every vector appears in exactly two of the 36 basis slots. -/ +theorem appears_twice : โˆ€ n : Fin 18, + (Finset.univ.filter (fun p : Fin 9 ร— Fin 4 => bases p.1 p.2 = n)).card = 2 := by decide + +/-- **The parity argument.** No assignment gives exactly one `true` in each of the 9 bases. -/ +theorem no_assignment (c : Fin 18 โ†’ Bool) + (h : โˆ€ B, (Finset.univ.filter (fun i : Fin 4 => c (bases B i) = true)).card = 1) : False := by + set S := Finset.univ.filter (fun p : Fin 9 ร— Fin 4 => c (bases p.1 p.2) = true) + set T := Finset.univ.filter (fun n : Fin 18 => c n = true) + -- Basis by basis, the `true` slots number nine. + have h9 : S.card = 9 := by + rw [Finset.card_filter, โ† Finset.univ_product_univ, Finset.sum_product] + simp only [โ† Finset.card_filter, h] + simp + -- Vector by vector, each `true` vector fills two slots. + have h2 : S.card = 2 * T.card := by + rw [Finset.card_eq_sum_card_fiberwise (f := fun p : Fin 9 ร— Fin 4 => bases p.1 p.2) (t := T) + (fun p hp => by simpa [S, T] using hp)] + rw [Finset.sum_congr rfl (g := fun _ => 2) (fun n hn => ?_), Finset.sum_const, smul_eq_mul, + mul_comm] + have hn' : c n = true := by simpa [T] using hn + rw [โ† appears_twice n] + congr 1 + ext p + simp only [S, Finset.mem_filter, Finset.mem_univ, true_and, and_iff_right_iff_imp] + intro hp + rw [hp] + exact hn' + omega + +/-! ### From the vectors to unit vectors of `๐•œโด` -/ + +variable {๐•œ : Type*} [RCLike ๐•œ] + +/-- A vector of `๐•œโด` with integer coordinates. -/ +def vec (x : Fin 4 โ†’ โ„ค) : EuclideanSpace ๐•œ (Fin 4) := WithLp.toLp 2 (fun k => ((x k : โ„ค) : ๐•œ)) + +theorem inner_vec (x y : Fin 4 โ†’ โ„ค) : inner ๐•œ (vec (๐•œ := ๐•œ) x) (vec y) = ((dot x y : โ„ค) : ๐•œ) := by + simp only [vec, PiLp.inner_apply, RCLike.inner_apply', map_intCast, Fin.sum_univ_four, dot] + push_cast + ring + +theorem vec_ne_zero (n : Fin 18) : vec (๐•œ := ๐•œ) (vecs n) โ‰  0 := by + intro h0 + have h := inner_vec (๐•œ := ๐•œ) (vecs n) (vecs n) + rw [h0, inner_zero_left] at h + have : ((dot (vecs n) (vecs n) : โ„ค) : ๐•œ) โ‰  0 := by exact_mod_cast (dot_self_pos n).ne' + exact this h.symm + +/-- The `n`-th vector, normalised. -/ +noncomputable def unit (n : Fin 18) : EuclideanSpace ๐•œ (Fin 4) := + (โ€–vec (๐•œ := ๐•œ) (vecs n)โ€–โปยน : ๐•œ) โ€ข vec (vecs n) + +theorem norm_unit (n : Fin 18) : โ€–unit (๐•œ := ๐•œ) nโ€– = 1 := norm_smul_inv_norm (vec_ne_zero n) + +/-- Each of the 9 bases, normalised, is orthonormal. -/ +theorem orthonormal_basis (B : Fin 9) : Orthonormal ๐•œ (fun i => unit (๐•œ := ๐•œ) (bases B i)) := by + rw [orthonormal_iff_ite] + intro i j + split_ifs with hij + ยท subst hij + rw [inner_self_eq_norm_sq_to_K, norm_unit] + simp + ยท simp [unit, inner_smul_left, inner_smul_right, inner_vec, bases_orth B i j hij] + +/-- **The Kochenโ€“Specker theorem in `๐•œโด`**, by Cabello's parity argument. -/ +theorem not_isValuation_four (v : EuclideanSpace ๐•œ (Fin 4) โ†’ Bool) : ยฌ IsValuation ๐•œ 4 v := by + intro hv + refine no_assignment (fun n => v (unit n)) (fun B => ?_) + obtain โŸจi, hi, huโŸฉ := hv.existsUnique_of_orthonormal (by simp) (orthonormal_basis B) + rw [Finset.card_eq_one] + exact โŸจi, by ext j; simp only [Finset.mem_filter, Finset.mem_univ, true_and, + Finset.mem_singleton]; exact โŸจhu j, fun e => e โ–ธ hiโŸฉโŸฉ + +end KochenSpecker.Cabello diff --git a/LeanPool/KochenSpecker/Checker.lean b/LeanPool/KochenSpecker/Checker.lean new file mode 100644 index 0000000000..0c7a248e6e --- /dev/null +++ b/LeanPool/KochenSpecker/Checker.lean @@ -0,0 +1,125 @@ +/- +Copyright (c) 2026 Zayn Blore. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Zayn Blore +-/ +module + +public import Mathlib.Data.List.Basic + +/-! +# A checked case-split refutation of Kochenโ€“Specker colourings + +A *system* is a list of pairs and a list of triads of natural-number labels. A *colouring* of a +system gives each label a truth value so that no pair has both labels `true` and every triad has +exactly one label `true`. + +A `Refutation` is a binary tree of case splits. `refutes S ฯ r` evaluates it under a partial +assignment `ฯ`: `close` succeeds when `ฯ` already violates some constraint (two `true`s on a pair +or a triad, or three `false`s on a triad), and `branch v t f` requires `t` to succeed with `v` set +`true` and `f` with `v` set `false`. `no_colouring_of_refutes` shows that a refutation accepted +from the empty assignment rules out every colouring. Refutations are generated outside Lean +(`scripts/peres33.py`) and checked here by the kernel; nothing computed outside Lean is trusted. + +The method, a case-split tree over a list-based partial assignment checked with `decide`, is the +one used by M. Kernaghan's `lean-ks` (github.com/michaelkernaghan/contextuality), which the author +read before writing this file. This file was written separately: the constraints are explicit +pair and triad lists rather than an orthogonality test, a single `close` searches for any +violated constraint rather than naming one, and triads require exactly one `true`. +-/ + +@[expose] public section + +namespace KochenSpecker + +/-- A partial assignment of truth values to labels; the first entry for a label wins. -/ +abbrev Partial := List (โ„• ร— Bool) + +/-- The value a partial assignment gives a label, if any. -/ +def valueOf : Partial โ†’ โ„• โ†’ Option Bool + | [], _ => none + | (w, b) :: ฯ, v => if w = v then some b else valueOf ฯ v + +/-- Pairs and triads of labels. -/ +structure Constraints where + /-- Pairs that cannot both be true. -/ + pairs : List (โ„• ร— โ„•) + /-- Triads in which exactly one label is true. -/ + triads : List (โ„• ร— โ„• ร— โ„•) + +/-- `c` colours `S`: no pair is all `true`, and each triad has exactly one `true`. -/ +def Colours (S : Constraints) (c : โ„• โ†’ Bool) : Prop := + (โˆ€ p โˆˆ S.pairs, ยฌ (c p.1 = true โˆง c p.2 = true)) โˆง + (โˆ€ t โˆˆ S.triads, (c t.1 && !c t.2.1 && !c t.2.2) || (!c t.1 && c t.2.1 && !c t.2.2) || + (!c t.1 && !c t.2.1 && c t.2.2) = true) + +/-- `c` extends the partial assignment `ฯ`. -/ +def Extends (c : โ„• โ†’ Bool) (ฯ : Partial) : Prop := โˆ€ v b, valueOf ฯ v = some b โ†’ c v = b + +/-- The number of labels among three that `ฯ` sets to `b`. -/ +def countValue (ฯ : Partial) (b : Bool) (t : โ„• ร— โ„• ร— โ„•) : โ„• := + (if valueOf ฯ t.1 = some b then 1 else 0) + (if valueOf ฯ t.2.1 = some b then 1 else 0) + + (if valueOf ฯ t.2.2 = some b then 1 else 0) + +/-- `ฯ` already violates a constraint of `S`. -/ +def violated (S : Constraints) (ฯ : Partial) : Bool := + S.pairs.any (fun p => valueOf ฯ p.1 = some true โˆง valueOf ฯ p.2 = some true) || + S.triads.any (fun t => 2 โ‰ค countValue ฯ true t โˆจ countValue ฯ false t = 3) + +/-- A case-split refutation. -/ +inductive Refutation where + | close + | branch (v : โ„•) (t f : Refutation) + +/-- Evaluate a refutation under a partial assignment. -/ +def refutes (S : Constraints) : Partial โ†’ Refutation โ†’ Bool + | ฯ, .close => violated S ฯ + | ฯ, .branch v t f => refutes S ((v, true) :: ฯ) t && refutes S ((v, false) :: ฯ) f + +theorem Extends.cons {c : โ„• โ†’ Bool} {ฯ : Partial} {v : โ„•} {b : Bool} (h : Extends c ฯ) + (hv : c v = b) : Extends c ((v, b) :: ฯ) := by + intro w b' hw + simp only [valueOf] at hw + split_ifs at hw with hvw + ยท cases hw + exact hvw โ–ธ hv + ยท exact h w b' hw + +/-- What `ฯ` says about a label agrees with the colouring. -/ +theorem valueOf_eq {c : โ„• โ†’ Bool} {ฯ : Partial} (h : Extends c ฯ) (v : โ„•) : + valueOf ฯ v = none โˆจ valueOf ฯ v = some (c v) := by + rcases hl : valueOf ฯ v with _ | b + ยท exact Or.inl rfl + ยท exact Or.inr (by rw [h v b hl]) + +/-- No constraint is violated by a partial assignment that a colouring extends. -/ +theorem violated_eq_false {S : Constraints} {c : โ„• โ†’ Bool} {ฯ : Partial} (hc : Colours S c) + (h : Extends c ฯ) : violated S ฯ = false := by + simp only [violated, Bool.or_eq_false_iff, List.any_eq_false, decide_eq_true_eq] + refine โŸจfun p hp โŸจh1, h2โŸฉ => hc.1 p hp โŸจh p.1 true h1, h p.2 true h2โŸฉ, fun t ht => ?_โŸฉ + have h3 := hc.2 t ht + rcases valueOf_eq h t.1 with e1 | e1 <;> rcases valueOf_eq h t.2.1 with e2 | e2 <;> + rcases valueOf_eq h t.2.2 with e3 | e3 <;> + ยท simp only [countValue, e1, e2, e3] + cases hx : c t.1 <;> cases hy : c t.2.1 <;> cases hz : c t.2.2 <;> simp_all + +/-- An accepted refutation leaves no colouring that extends `ฯ`. -/ +theorem not_extends_of_refutes (S : Constraints) {c : โ„• โ†’ Bool} (hc : Colours S c) : + โˆ€ (cert : Refutation) (ฯ : Partial), refutes S ฯ cert = true โ†’ ยฌ Extends c ฯ + | .close, ฯ, hchk, h => by + simp only [refutes] at hchk + rw [violated_eq_false hc h] at hchk + exact Bool.false_ne_true hchk + | .branch v t f, ฯ, hchk, h => by + simp only [refutes, Bool.and_eq_true] at hchk + cases hv : c v + ยท exact not_extends_of_refutes S hc f _ hchk.2 (Extends.cons h hv) + ยท exact not_extends_of_refutes S hc t _ hchk.1 (Extends.cons h hv) + +/-- A refutation accepted from the empty assignment rules out every colouring. -/ +theorem no_colouring_of_refutes (S : Constraints) (cert : Refutation) + (h : refutes S [] cert = true) : ยฌ โˆƒ c, Colours S c := by + rintro โŸจc, hcโŸฉ + exact not_extends_of_refutes S hc cert [] h (fun _ _ hv => by simp [valueOf] at hv) + +end KochenSpecker diff --git a/LeanPool/KochenSpecker/Imports.lean b/LeanPool/KochenSpecker/Imports.lean new file mode 100644 index 0000000000..b56a184b78 --- /dev/null +++ b/LeanPool/KochenSpecker/Imports.lean @@ -0,0 +1,14 @@ +/- +Copyright (c) 2026 Lean Pool contributors. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Lean Pool contributors +-/ +module -- shake: keep-all --deprecated_module: ignore + +-- Generated project imports; run `lake exe mk_all`. +public import LeanPool.KochenSpecker +public import LeanPool.KochenSpecker.Cabello18 +public import LeanPool.KochenSpecker.Checker +public import LeanPool.KochenSpecker.Main +public import LeanPool.KochenSpecker.Peres33 +public import LeanPool.KochenSpecker.Valuation diff --git a/LeanPool/KochenSpecker/Main.lean b/LeanPool/KochenSpecker/Main.lean new file mode 100644 index 0000000000..9a75b8fc0c --- /dev/null +++ b/LeanPool/KochenSpecker/Main.lean @@ -0,0 +1,70 @@ +/- +Copyright (c) 2026 Zayn Blore. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Zayn Blore +-/ +module + +public import LeanPool.KochenSpecker.Peres33 +public import LeanPool.KochenSpecker.Cabello18 + +/-! +# The Kochenโ€“Specker theorem + +**Theorem** (Kochen and Specker, 1967). In a Hilbert space of dimension `d โ‰ฅ 3`, real or +complex, no map `v` from vectors to `{true, false}` is `true` on exactly one vector of every +orthonormal basis. + +* Dimension three is `Peres.not_isValuation_three` (Peres's 33 rays, a kernel-checked case split). +* `IsValuation.exists_subspace` restricts a valuation in dimension `d + 1` to the orthogonal + complement of a unit vector where it is `false`; so `NoValuation.of_le` carries the theorem + from dimension three to every larger dimension, for every inner product space, not only `๐•œแตˆ`. +* `kochen_specker_of_four_le` proves the case `d โ‰ฅ 4` a second way, from Cabello's 18 vectors by + a parity count, with no computer search. +-/ + +@[expose] public section + +open Module + +namespace KochenSpecker + +universe u + +variable {๐•œ : Type*} [RCLike ๐•œ] + +/-- No inner product space of dimension three carries a valuation. -/ +theorem noValuation_three : NoValuation.{u} ๐•œ 3 := by + intro E _ _ hE v hv + have : FiniteDimensional ๐•œ E := Module.finite_of_finrank_pos (by omega) + set ฯ† := ((stdOrthonormalBasis ๐•œ E).reindex (finCongr hE)).repr + exact Peres.not_isValuation_three _ (hv.map ฯ†) + +/-- No inner product space of dimension four carries a valuation (Cabello's parity argument). -/ +theorem noValuation_four : NoValuation.{u} ๐•œ 4 := by + intro E _ _ hE v hv + have : FiniteDimensional ๐•œ E := Module.finite_of_finrank_pos (by omega) + set ฯ† := ((stdOrthonormalBasis ๐•œ E).reindex (finCongr hE)).repr + exact Cabello.not_isValuation_four _ (hv.map ฯ†) + +/-- **The Kochenโ€“Specker theorem** in every inner product space of dimension `d โ‰ฅ 3` over `โ„` or +`โ„‚` (any `RCLike ๐•œ`). -/ +theorem not_isValuation {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ๐•œ E] {d : โ„•} + (hd : 3 โ‰ค d) (hE : finrank ๐•œ E = d) (v : E โ†’ Bool) : ยฌ IsValuation ๐•œ d v := + noValuation_three.of_le (by norm_num) hd E hE v + +/-- **The Kochenโ€“Specker theorem.** For `d โ‰ฅ 3` and `๐•œ = โ„` or `โ„‚`, no map from `๐•œแตˆ` to +`Bool` is `true` on exactly one vector of every orthonormal basis. -/ +theorem kochen_specker {d : โ„•} (hd : 3 โ‰ค d) : + ยฌ โˆƒ v : EuclideanSpace ๐•œ (Fin d) โ†’ Bool, + โˆ€ b : OrthonormalBasis (Fin d) ๐•œ (EuclideanSpace ๐•œ (Fin d)), โˆƒ! i, v (b i) = true := + fun โŸจv, hvโŸฉ => not_isValuation hd (by simp) v hv + +/-- The case `d โ‰ฅ 4` of `kochen_specker`, proved from Cabello's 18 vectors by a parity count, +independently of Peres's rays and of any computer-generated certificate. -/ +theorem kochen_specker_of_four_le {d : โ„•} (hd : 4 โ‰ค d) : + ยฌ โˆƒ v : EuclideanSpace ๐•œ (Fin d) โ†’ Bool, + โˆ€ b : OrthonormalBasis (Fin d) ๐•œ (EuclideanSpace ๐•œ (Fin d)), โˆƒ! i, v (b i) = true := + fun โŸจv, hvโŸฉ => noValuation_four.of_le (by norm_num) hd _ (by simp) v hv + +end KochenSpecker diff --git a/LeanPool/KochenSpecker/Peres33.lean b/LeanPool/KochenSpecker/Peres33.lean new file mode 100644 index 0000000000..29322b9dbd --- /dev/null +++ b/LeanPool/KochenSpecker/Peres33.lean @@ -0,0 +1,258 @@ +/- +Copyright (c) 2026 Zayn Blore. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Zayn Blore +-/ +module + +public import LeanPool.KochenSpecker.Checker +public import LeanPool.KochenSpecker.Valuation +public import Mathlib.Analysis.SpecialFunctions.Sqrt + +/-! +# Dimension three: Peres's 33 rays + +Peres (*Two simple proofs of the Kochen-Specker theorem*, J. Phys. A 24 (1991) L175) gave 33 rays +in `โ„ยณ`: the coordinate permutations and sign changes of `(0, 0, 1)`, `(0, 1, 1)`, `(0, 1, โˆš2)` +and `(1, 1, โˆš2)`, one vector per ray. Coordinates are kept exactly, as pairs `(a, b)` of integers +meaning `a + b โˆš2`, so orthogonality is an integer computation. + +They have 72 orthogonal pairs and 16 orthogonal triads (`sys`, checked by `pair_orth` and +`triad_orth`), and no colouring: `check_ok` runs a case-split certificate through +`KochenSpecker.Checker` in the kernel. Unit propagation and branching on active clauses generate +the tree. + +`not_isValuation_three` turns this into the theorem in `๐•œยณ` for every `RCLike ๐•œ` (so for `โ„ยณ` +and `โ„‚ยณ`): a valuation would colour the normalised rays, since each orthogonal triad is an +orthonormal basis (exactly one `true`) and each orthogonal pair extends to one (at most one +`true`). +-/ + +@[expose] public section + +open Module + +namespace KochenSpecker.Peres + +-- Exact ray data from the upstream scripts/peres33.py +/-- Peres's 33 rays, coordinates `(a, b)` meaning `a + b โˆš2`. -/ +def rays : List (Fin 3 โ†’ โ„ค ร— โ„ค) := [ + ![(0, 0), (0, 0), (1, 0)], + ![(0, 0), (1, 0), (0, 0)], + ![(1, 0), (0, 0), (0, 0)], + ![(0, 0), (1, 0), (1, 0)], + ![(0, 0), (1, 0), (-1, 0)], + ![(1, 0), (0, 0), (1, 0)], + ![(1, 0), (0, 0), (-1, 0)], + ![(1, 0), (1, 0), (0, 0)], + ![(1, 0), (-1, 0), (0, 0)], + ![(0, 0), (1, 0), (0, 1)], + ![(0, 0), (1, 0), (0, -1)], + ![(0, 0), (0, 1), (1, 0)], + ![(0, 0), (0, 1), (-1, 0)], + ![(1, 0), (0, 0), (0, 1)], + ![(1, 0), (0, 0), (0, -1)], + ![(1, 0), (0, 1), (0, 0)], + ![(1, 0), (0, -1), (0, 0)], + ![(0, 1), (0, 0), (1, 0)], + ![(0, 1), (0, 0), (-1, 0)], + ![(0, 1), (1, 0), (0, 0)], + ![(0, 1), (-1, 0), (0, 0)], + ![(1, 0), (1, 0), (0, 1)], + ![(1, 0), (1, 0), (0, -1)], + ![(1, 0), (-1, 0), (0, 1)], + ![(1, 0), (-1, 0), (0, -1)], + ![(1, 0), (0, 1), (1, 0)], + ![(1, 0), (0, 1), (-1, 0)], + ![(1, 0), (0, -1), (1, 0)], + ![(1, 0), (0, -1), (-1, 0)], + ![(0, 1), (1, 0), (1, 0)], + ![(0, 1), (1, 0), (-1, 0)], + ![(0, 1), (-1, 0), (1, 0)], + ![(0, 1), (-1, 0), (-1, 0)] +] + +/-- The orthogonal pairs and triads of `rays`, by index. -/ +def sys : Constraints where + pairs := [(0, 1), (0, 2), (0, 7), (0, 8), (0, 15), (0, 16), (0, 19), (0, 20), (1, 2), (1, 5), (1, + 6), (1, 13), (1, 14), (1, 17), (1, 18), (2, 3), (2, 4), (2, 9), (2, 10), (2, 11), (2, 12), (3, + 4), (3, 30), (3, 31), (4, 29), (4, 32), (5, 6), (5, 26), (5, 28), (6, 25), (6, 27), (7, 8), (7, + 23), (7, 24), (8, 21), (8, 22), (9, 12), (9, 26), (9, 27), (10, 11), (10, 25), (10, 28), (11, + 22), (11, 23), (12, 21), (12, 24), (13, 18), (13, 30), (13, 32), (14, 17), (14, 29), (14, 31), + (15, 20), (15, 31), (15, 32), (16, 19), (16, 29), (16, 30), (17, 22), (17, 24), (18, 21), (18, + 23), (19, 27), (19, 28), (20, 25), (20, 26), (21, 22), (23, 24), (25, 27), (26, 28), (29, 32), + (30, 31)] + triads := [(0, 1, 2), (0, 7, 8), (0, 15, 20), (0, 16, 19), (1, 5, 6), (1, 13, 18), (1, 14, 17), + (2, 3, 4), (2, 9, 12), (2, 10, 11), (3, 30, 31), (4, 29, 32), (5, 26, 28), (6, 25, 27), (7, 23, + 24), (8, 21, 22)] + +/-- A case-split refutation of every colouring of `sys`, with branches chosen by +unit propagation and the number of remaining literals in active clauses. -/ +def cert : Refutation := + (.branch 2 (.branch 1 .close (.branch 9 .close (.branch 10 .close (.branch 4 .close (.branch 0 + .close (.branch 3 .close (.branch 12 .close (.branch 11 .close (.branch 31 (.branch 15 .close + (.branch 14 .close (.branch 20 (.branch 17 (.branch 24 .close (.branch 30 .close (.branch 26 + .close (.branch 22 .close (.branch 25 .close (.branch 19 (.branch 27 .close (.branch 28 .close + (.branch 5 (.branch 6 .close .close) .close))) (.branch 16 (.branch 29 .close (.branch 32 + (.branch 13 .close (.branch 18 (.branch 21 .close (.branch 23 .close (.branch 8 (.branch 7 + .close .close) .close))) .close)) .close)) .close))))))) .close) .close))) (.branch 30 (.branch + 13 .close (.branch 18 (.branch 21 .close (.branch 23 .close (.branch 16 .close (.branch 19 + (.branch 28 .close (.branch 27 .close (.branch 17 (.branch 24 .close (.branch 14 .close (.branch + 22 .close (.branch 7 (.branch 8 .close .close) .close)))) (.branch 14 (.branch 29 .close + (.branch 32 (.branch 15 .close (.branch 20 (.branch 26 .close (.branch 25 .close (.branch 6 + (.branch 5 .close .close) .close))) .close)) .close)) .close)))) .close)))) .close)) + .close)))))))))) (.branch 1 (.branch 6 .close (.branch 5 .close (.branch 0 .close (.branch 18 + .close (.branch 14 .close (.branch 13 .close (.branch 17 .close (.branch 28 (.branch 26 .close + (.branch 10 .close (.branch 19 .close (.branch 16 (.branch 29 .close (.branch 30 .close (.branch + 11 (.branch 23 .close (.branch 22 .close (.branch 12 (.branch 9 .close (.branch 24 .close + (.branch 7 (.branch 21 .close (.branch 8 .close .close)) .close))) (.branch 9 (.branch 27 .close + (.branch 25 (.branch 20 .close (.branch 15 (.branch 31 .close (.branch 32 .close (.branch 3 + (.branch 4 .close .close) .close))) .close)) .close)) .close)))) .close))) .close)))) (.branch + 26 (.branch 9 .close (.branch 12 (.branch 20 .close (.branch 21 .close (.branch 15 (.branch 24 + .close (.branch 32 .close (.branch 31 .close (.branch 16 (.branch 29 .close (.branch 30 .close + (.branch 4 (.branch 19 .close (.branch 3 .close .close)) .close))) (.branch 19 (.branch 27 + .close (.branch 25 (.branch 10 .close (.branch 11 (.branch 22 .close (.branch 8 (.branch 7 + .close (.branch 23 .close .close)) .close)) .close)) .close)) .close))))) .close))) .close)) + .close))))))))) (.branch 0 (.branch 8 .close (.branch 7 .close (.branch 20 .close (.branch 16 + .close (.branch 15 .close (.branch 19 .close (.branch 22 (.branch 21 .close (.branch 11 .close + (.branch 17 .close (.branch 10 (.branch 14 (.branch 25 .close (.branch 28 .close (.branch 31 + .close (.branch 29 .close (.branch 9 (.branch 12 .close (.branch 26 .close (.branch 27 .close + (.branch 6 (.branch 5 .close .close) .close)))) (.branch 12 (.branch 24 .close (.branch 23 + (.branch 18 .close (.branch 13 (.branch 30 .close (.branch 32 .close (.branch 3 (.branch 4 + .close .close) .close))) .close)) .close)) .close)))))) .close) .close)))) (.branch 21 (.branch + 18 .close (.branch 12 .close (.branch 13 (.branch 9 (.branch 30 .close (.branch 26 .close + (.branch 27 .close (.branch 32 .close (.branch 3 (.branch 4 .close (.branch 31 .close (.branch + 29 (.branch 14 .close (.branch 17 (.branch 24 .close (.branch 23 (.branch 11 .close (.branch 10 + (.branch 28 .close (.branch 5 (.branch 25 .close (.branch 6 .close .close)) .close)) .close)) + .close)) .close)) .close))) (.branch 31 (.branch 14 .close (.branch 4 (.branch 29 .close + (.branch 17 (.branch 24 .close (.branch 23 (.branch 11 .close (.branch 10 (.branch 28 .close + (.branch 25 .close (.branch 6 (.branch 5 .close .close) .close))) .close)) .close)) .close)) + .close)) .close)))))) .close) .close))) .close)))))))) .close))) + +/-- The `n`-th ray. -/ +def ray (n : โ„•) : Fin 3 โ†’ โ„ค ร— โ„ค := rays.getD n (fun _ => (0, 0)) + +/-- The inner product of two rays, as `(a, b)` meaning `a + b โˆš2`. -/ +def ipZ (x y : Fin 3 โ†’ โ„ค ร— โ„ค) : โ„ค ร— โ„ค := + ((x 0).1 * (y 0).1 + 2 * (x 0).2 * (y 0).2 + (x 1).1 * (y 1).1 + 2 * (x 1).2 * (y 1).2 + + (x 2).1 * (y 2).1 + 2 * (x 2).2 * (y 2).2, + (x 0).1 * (y 0).2 + (x 0).2 * (y 0).1 + (x 1).1 * (y 1).2 + (x 1).2 * (y 1).1 + + (x 2).1 * (y 2).2 + (x 2).2 * (y 2).1) + +theorem rays_length : rays.length = 33 := by decide + +/-- Every listed pair is orthogonal. -/ +theorem pair_orth : โˆ€ p โˆˆ sys.pairs, ipZ (ray p.1) (ray p.2) = (0, 0) := by decide + +/-- Every listed triad is pairwise orthogonal. -/ +theorem triad_orth : โˆ€ t โˆˆ sys.triads, ipZ (ray t.1) (ray t.2.1) = (0, 0) โˆง + ipZ (ray t.1) (ray t.2.2) = (0, 0) โˆง ipZ (ray t.2.1) (ray t.2.2) = (0, 0) := by decide + +/-- Each ray has squared length a positive integer: `ipZ r r = (m, 0)` with `0 < m`. -/ +theorem self_pos : โˆ€ n < 33, (ipZ (ray n) (ray n)).2 = 0 โˆง 0 < (ipZ (ray n) (ray n)).1 := by + decide + +/-- **No colouring of Peres's rays**, checked by the kernel. -/ +theorem check_ok : refutes sys [] cert = true := by decide + +theorem pair_lt : โˆ€ p โˆˆ sys.pairs, p.1 < 33 โˆง p.2 < 33 := by decide + +theorem triad_lt : โˆ€ t โˆˆ sys.triads, t.1 < 33 โˆง t.2.1 < 33 โˆง t.2.2 < 33 := by decide + +/-! ### From rays to unit vectors of `๐•œยณ` -/ + +variable {๐•œ : Type*} [RCLike ๐•œ] + +/-- `a + b โˆš2`. -/ +noncomputable def toR (z : โ„ค ร— โ„ค) : โ„ := z.1 + z.2 * โˆš2 + +/-- A ray as a vector of `๐•œยณ`. -/ +noncomputable def vec (x : Fin 3 โ†’ โ„ค ร— โ„ค) : EuclideanSpace ๐•œ (Fin 3) := + WithLp.toLp 2 (fun k => ((toR (x k) : โ„) : ๐•œ)) + +theorem inner_vec (x y : Fin 3 โ†’ โ„ค ร— โ„ค) : + inner ๐•œ (vec (๐•œ := ๐•œ) x) (vec y) = (((ipZ x y).1 + (ipZ x y).2 * โˆš2 : โ„) : ๐•œ) := by + have h2 : ((โˆš2 : โ„) : ๐•œ) ^ 2 = 2 := by + exact_mod_cast congrArg (fun r : โ„ => (r : ๐•œ)) (Real.sq_sqrt (show (0 : โ„) โ‰ค 2 by norm_num)) + simp only [vec, PiLp.inner_apply, RCLike.inner_apply', RCLike.conj_ofReal, + Fin.sum_univ_three, toR, ipZ] + push_cast + linear_combination + (((x 0).2 : ๐•œ) * (y 0).2 + ((x 1).2 : ๐•œ) * (y 1).2 + ((x 2).2 : ๐•œ) * (y 2).2) * h2 + +theorem inner_vec_eq_zero {x y : Fin 3 โ†’ โ„ค ร— โ„ค} (h : ipZ x y = (0, 0)) : + inner ๐•œ (vec (๐•œ := ๐•œ) x) (vec y) = 0 := by + rw [inner_vec, h] + simp + +theorem vec_ne_zero {n : โ„•} (hn : n < 33) : vec (๐•œ := ๐•œ) (ray n) โ‰  0 := by + intro h0 + have h := inner_vec (๐•œ := ๐•œ) (ray n) (ray n) + rw [h0, inner_zero_left, (self_pos n hn).1] at h + have hm := (self_pos n hn).2 + have : ((((ipZ (ray n) (ray n)).1 : โ„)) : ๐•œ) โ‰  0 := by + rw [RCLike.ofReal_ne_zero] + exact_mod_cast hm.ne' + apply this + rw [h] + simp + +/-- The `n`-th ray, normalised. -/ +noncomputable def unit (n : โ„•) : EuclideanSpace ๐•œ (Fin 3) := + (โ€–vec (๐•œ := ๐•œ) (ray n)โ€–โปยน : ๐•œ) โ€ข vec (ray n) + +theorem norm_unit {n : โ„•} (hn : n < 33) : โ€–unit (๐•œ := ๐•œ) nโ€– = 1 := + norm_smul_inv_norm (vec_ne_zero hn) + +theorem inner_unit_eq_zero {m n : โ„•} (h : ipZ (ray m) (ray n) = (0, 0)) : + inner ๐•œ (unit (๐•œ := ๐•œ) m) (unit n) = 0 := by + simp [unit, inner_smul_left, inner_smul_right, inner_vec_eq_zero h] + +theorem inner_unit_self {n : โ„•} (hn : n < 33) : inner ๐•œ (unit (๐•œ := ๐•œ) n) (unit n) = 1 := by + rw [inner_self_eq_norm_sq_to_K, norm_unit hn] + simp + +/-! ### A valuation colours the rays -/ + +/-- Exactly one of three values is `true`. -/ +theorem exactlyOne_of_existsUnique {ฮฑ : Type*} {g : Fin 3 โ†’ ฮฑ} {w : ฮฑ โ†’ Bool} + (h : โˆƒ! i, w (g i) = true) : + (w (g 0) && !w (g 1) && !w (g 2)) || (!w (g 0) && w (g 1) && !w (g 2)) || + (!w (g 0) && !w (g 1) && w (g 2)) = true := by + obtain โŸจi, hi, huโŸฉ := h + have key : โˆ€ j, w (g j) = true โ†” j = i := fun j => โŸจhu j, fun e => e โ–ธ hiโŸฉ + have e0 := key 0 + have e1 := key 1 + have e2 := key 2 + generalize w (g 0) = a at e0 โŠข + generalize w (g 1) = b at e1 โŠข + generalize w (g 2) = c at e2 โŠข + revert e0 e1 e2 + fin_cases i <;> revert a b c <;> decide + +/-- A valuation of `๐•œยณ` colours Peres's system. -/ +theorem colours_of_isValuation {v : EuclideanSpace ๐•œ (Fin 3) โ†’ Bool} + (hv : IsValuation ๐•œ 3 v) : Colours sys (fun n => v (unit n)) := by + have hE : finrank ๐•œ (EuclideanSpace ๐•œ (Fin 3)) = 1 + 2 := by simp + refine โŸจfun p hp => ?_, fun t ht => ?_โŸฉ + ยท obtain โŸจh1, h2โŸฉ := pair_lt p hp + exact hv.not_both (n := 1) hE (norm_unit h1) (norm_unit h2) + (inner_unit_eq_zero (pair_orth p hp)) + ยท obtain โŸจh1, h2, h3โŸฉ := triad_lt t ht + obtain โŸจo12, o13, o23โŸฉ := triad_orth t ht + have hf : Orthonormal ๐•œ ![unit (๐•œ := ๐•œ) t.1, unit t.2.1, unit t.2.2] := by + rw [orthonormal_iff_ite] + have s12 := inner_eq_zero_symm.1 (inner_unit_eq_zero (๐•œ := ๐•œ) o12) + have s13 := inner_eq_zero_symm.1 (inner_unit_eq_zero (๐•œ := ๐•œ) o13) + have s23 := inner_eq_zero_symm.1 (inner_unit_eq_zero (๐•œ := ๐•œ) o23) + intro i j + fin_cases i <;> fin_cases j <;> + simp [norm_unit h1, norm_unit h2, norm_unit h3, inner_unit_eq_zero o12, + inner_unit_eq_zero o13, inner_unit_eq_zero o23, s12, s13, s23] + simpa using exactlyOne_of_existsUnique (hv.existsUnique_of_orthonormal (by simp) hf) + +/-- **The Kochenโ€“Specker theorem in `๐•œยณ`.** -/ +theorem not_isValuation_three (v : EuclideanSpace ๐•œ (Fin 3) โ†’ Bool) : ยฌ IsValuation ๐•œ 3 v := + fun hv => no_colouring_of_refutes sys cert check_ok โŸจ_, colours_of_isValuation hvโŸฉ + +end KochenSpecker.Peres diff --git a/LeanPool/KochenSpecker/Valuation.lean b/LeanPool/KochenSpecker/Valuation.lean new file mode 100644 index 0000000000..88c15961fa --- /dev/null +++ b/LeanPool/KochenSpecker/Valuation.lean @@ -0,0 +1,162 @@ +/- +Copyright (c) 2026 Zayn Blore. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Zayn Blore +-/ +module + +public import Mathlib.Analysis.InnerProductSpace.PiL2 +public import Mathlib.Analysis.InnerProductSpace.Projection.FiniteDimensional + +/-! +# Kochenโ€“Specker valuations + +A *Kochenโ€“Specker valuation* on an inner product space `E` of dimension `d` is a map `v : E โ†’ Bool` +that is `true` on exactly one vector of every orthonormal basis (indexed by `Fin d`). Nothing is +assumed about `v` off unit vectors, or about its behaviour under phases. + +* `IsValuation.existsUnique_of_orthonormal`: exactly one `true` on any `d` orthonormal vectors. +* `IsValuation.not_both`: never `true` on two orthonormal vectors (when `d โ‰ฅ 2`). +* `IsValuation.map`: valuations transfer along linear isometric equivalences. +* `IsValuation.exists_subspace`: a valuation in dimension `d + 1` (`d โ‰ฅ 1`) restricts to one on + the orthogonal complement of a unit vector where it is `false`, a space of dimension `d`. +* `NoValuation.succ`, `NoValuation.of_le`: so the absence of valuations in dimension `d` + propagates to every larger dimension. +-/ + +@[expose] public section + +open Module + +namespace KochenSpecker + +variable {๐•œ : Type*} [RCLike ๐•œ] + +section General + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ๐•œ E] + +variable (๐•œ) in +/-- `v` is a **Kochenโ€“Specker valuation** in dimension `d`: every orthonormal basis indexed by +`Fin d` has exactly one vector on which `v` is `true`. -/ +def IsValuation (d : โ„•) (v : E โ†’ Bool) : Prop := + โˆ€ b : OrthonormalBasis (Fin d) ๐•œ E, โˆƒ! i, v (b i) = true + +/-- `d` orthonormal vectors in a space of dimension `d` carry exactly one `true`. -/ +theorem IsValuation.existsUnique_of_orthonormal {d : โ„•} [NeZero d] {v : E โ†’ Bool} + (hv : IsValuation ๐•œ d v) (hE : finrank ๐•œ E = d) {f : Fin d โ†’ E} (hf : Orthonormal ๐•œ f) : + โˆƒ! i, v (f i) = true := by + have hcard : Fintype.card (Fin d) = finrank ๐•œ E := by simp [hE] + set B := basisOfOrthonormalOfCardEqFinrank hf hcard + have hB : (B : Fin d โ†’ E) = f := coe_basisOfOrthonormalOfCardEqFinrank hf hcard + have hon : Orthonormal ๐•œ B := by rw [hB]; exact hf + have := hv (B.toOrthonormalBasis hon) + simpa [Module.Basis.coe_toOrthonormalBasis, hB] using this + +/-- A valuation is never `true` on two orthonormal vectors. -/ +theorem IsValuation.not_both {n : โ„•} {v : E โ†’ Bool} (hv : IsValuation ๐•œ (n + 2) v) + (hE : finrank ๐•œ E = n + 2) {x y : E} (hx : โ€–xโ€– = 1) (hy : โ€–yโ€– = 1) (hxy : inner ๐•œ x y = 0) : + ยฌ (v x = true โˆง v y = true) := by + rintro โŸจhvx, hvyโŸฉ + have : FiniteDimensional ๐•œ E := Module.finite_of_finrank_pos (by omega) + set w : Fin (n + 2) โ†’ E := fun i => if i = 0 then x else if i = 1 then y else 0 + have h01 : (0 : Fin (n + 2)) โ‰  1 := by simp + have hw : Orthonormal ๐•œ (({0, 1} : Set (Fin (n + 2))).domRestrict w) := by + rw [orthonormal_iff_ite] + rintro โŸจi, hiโŸฉ โŸจj, hjโŸฉ + simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hi hj + have hyx : inner ๐•œ y x = 0 := inner_eq_zero_symm.1 hxy + rcases hi with rfl | rfl <;> rcases hj with rfl | rfl <;> + simp [Set.domRestrict_apply, w, h01, h01.symm, hxy, hyx, inner_self_eq_norm_sq_to_K, hx, hy] + obtain โŸจb, hbโŸฉ := hw.exists_orthonormalBasis_extension_of_card_eq (by simp [hE]) + have hb0 : b 0 = x := by rw [hb 0 (by simp)]; simp [w] + have hb1 : b 1 = y := by rw [hb 1 (by simp)]; simp [w, h01.symm] + obtain โŸจi, -, huโŸฉ := hv b + exact h01 ((hu 0 (show v (b 0) = true by rw [hb0]; exact hvx)).trans + (hu 1 (show v (b 1) = true by rw [hb1]; exact hvy)).symm) + +variable {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ๐•œ F] + +/-- Valuations transfer along linear isometric equivalences. -/ +theorem IsValuation.map {d : โ„•} {v : E โ†’ Bool} (hv : IsValuation ๐•œ d v) (ฯ† : E โ‰ƒโ‚—แตข[๐•œ] F) : + IsValuation ๐•œ d (fun y => v (ฯ†.symm y)) := by + intro b + simpa using hv (b.map ฯ†.symm) + +/-- A valuation in dimension `d + 1` restricts to the orthogonal complement of a unit vector on +which it is `false`, a subspace of dimension `d`. -/ +theorem IsValuation.exists_subspace {d : โ„•} [NeZero d] {v : E โ†’ Bool} + (hv : IsValuation ๐•œ (d + 1) v) (hE : finrank ๐•œ E = d + 1) : + โˆƒ K : Submodule ๐•œ E, finrank ๐•œ K = d โˆง IsValuation ๐•œ d (fun x : K => v x) := by + have : Fact (finrank ๐•œ E = d + 1) := โŸจhEโŸฉ + have : FiniteDimensional ๐•œ E := .of_fact_finrank_eq_succ d + -- A unit vector `u` where `v` is `false`. + set bโ‚€ := (stdOrthonormalBasis ๐•œ E).reindex (finCongr hE) + obtain โŸจiโ‚€, -, huniqโŸฉ := hv bโ‚€ + obtain โŸจj, hjโŸฉ : โˆƒ j : Fin (d + 1), j โ‰  iโ‚€ := by + by_cases h : iโ‚€ = 0 + ยท refine โŸจFin.last d, fun e => NeZero.ne d ?_โŸฉ + have := congrArg Fin.val (e.trans h) + simpa using this + ยท exact โŸจ0, fun e => h e.symmโŸฉ + have hfalse : v (bโ‚€ j) = false := by + cases h : v (bโ‚€ j) + ยท rfl + ยท exact absurd (huniq j h) hj + set u := bโ‚€ j + have hu1 : โ€–uโ€– = 1 := bโ‚€.orthonormal.1 j + have hu0 : u โ‰  0 := by + intro h + rw [h, norm_zero] at hu1 + exact zero_ne_one hu1 + refine โŸจ(๐•œ โˆ™ u)แ—ฎ, Submodule.finrank_orthogonal_span_singleton hu0, fun b => ?_โŸฉ + -- `u` together with an orthonormal basis of its complement. + set f : Fin (d + 1) โ†’ E := Fin.cons u (fun i => (b i : E)) + have hperp : โˆ€ i, inner ๐•œ u (b i : E) = 0 := fun i => + Submodule.mem_orthogonal_singleton_iff_inner_right.1 (b i).2 + have hb : โˆ€ i j, inner ๐•œ (b i : E) (b j : E) = if i = j then 1 else 0 := fun i j => by + rw [โ† Submodule.coe_inner] + exact orthonormal_iff_ite.1 b.orthonormal i j + have hf : Orthonormal ๐•œ f := by + rw [orthonormal_iff_ite] + intro i k + induction i using Fin.cases <;> induction k using Fin.cases + ยท simp [f, inner_self_eq_norm_sq_to_K, hu1] + ยท simp [f, hperp, (Fin.succ_ne_zero _).symm] + ยท simp [f, inner_eq_zero_symm.1 (hperp _), Fin.succ_ne_zero] + ยท simp [f, hb] + obtain โŸจk, hk, hkuโŸฉ := hv.existsUnique_of_orthonormal hE hf + induction k using Fin.cases with + | zero => simp [f, u, hfalse] at hk + | succ k => + refine โŸจk, by simpa [f] using hk, fun m hm => Fin.succ_injective _ ?_โŸฉ + exact hku m.succ (by simpa [f] using hm) + +end General + +universe u + +variable (๐•œ) in +/-- No inner product space of dimension `d` (in universe `u`) carries a Kochenโ€“Specker +valuation. -/ +def NoValuation (d : โ„•) : Prop := + โˆ€ (E : Type u) [NormedAddCommGroup E] [InnerProductSpace ๐•œ E], finrank ๐•œ E = d โ†’ + โˆ€ v : E โ†’ Bool, ยฌ IsValuation ๐•œ d v + +/-- The absence of valuations passes from dimension `d โ‰ฅ 1` to dimension `d + 1`. -/ +theorem NoValuation.succ {d : โ„•} [NeZero d] (h : NoValuation.{u} ๐•œ d) : + NoValuation.{u} ๐•œ (d + 1) := by + intro E _ _ hE v hv + obtain โŸจK, hK, hvKโŸฉ := hv.exists_subspace hE + exact h K hK _ hvK + +/-- The absence of valuations passes from dimension `d โ‰ฅ 1` to every larger dimension. -/ +theorem NoValuation.of_le {d d' : โ„•} (hd : 1 โ‰ค d) (h : NoValuation.{u} ๐•œ d) (hdd' : d โ‰ค d') : + NoValuation.{u} ๐•œ d' := by + induction d', hdd' using Nat.le_induction with + | base => exact h + | succ n hn ih => + have : NeZero n := โŸจby omegaโŸฉ + exact ih.succ + +end KochenSpecker diff --git a/LeanPool/projects/kochen-specker.yaml b/LeanPool/projects/kochen-specker.yaml new file mode 100644 index 0000000000..22e344a429 --- /dev/null +++ b/LeanPool/projects/kochen-specker.yaml @@ -0,0 +1,44 @@ +slug: kochen-specker +title: The Kochenโ€“Specker theorem in every finite dimension +summary: Rules out Boolean valuations that mark exactly one vector in each + orthonormal basis of a real or complex inner product space of dimension at + least three. The proof checks a case-split certificate for Peres's rays, + propagates nonexistence by restriction to orthogonal complements, and includes + a second proof from Cabello's parity construction beginning in dimension four. +branch: mathematical physics +entry_module: LeanPool.KochenSpecker +authors: +- Zayn Blore +source: + title: The Problem of Hidden Variables in Quantum Mechanics + doi: 10.1512/iumj.1968.17.17004 + url: https://github.com/zblore/kochen-specker-lean/tree/a9f552a11188809b15ba14ef2db5a2a8ecd3c83b + github_repo: zblore/kochen-specker-lean + commit: a9f552a11188809b15ba14ef2db5a2a8ecd3c83b +license: Apache-2.0 +status: verified +provenance: AI +main_declarations: +- KochenSpecker.kochen_specker +- KochenSpecker.not_isValuation +- KochenSpecker.kochen_specker_of_four_le +main_results: +- declaration: KochenSpecker.kochen_specker + informal: In Euclidean dimension d โ‰ฅ 3 over an RCLike field, no Boolean map + marks exactly one vector in each orthonormal basis. + source_ref: Kochen and Specker, Theorem 1, for the real dimension-three obstruction; Peres, DOI 10.1088/0305-4470/24/4/003, for the 33-ray configuration. +- declaration: KochenSpecker.not_isValuation + informal: The same nonexistence holds in any inner product space of finite + dimension d โ‰ฅ 3 over an RCLike field. + source_ref: Imported formalization, with the dimension-three certificate propagated by orthogonal-complement restriction. +- declaration: KochenSpecker.kochen_specker_of_four_le + informal: Cabello's four-dimensional configuration yields the Euclidean + nonexistence result for every d โ‰ฅ 4 by a parity argument and dimension propagation. + source_ref: Cabello, Estebaranz, and Garcรญa-Alcaine, DOI 10.1016/0375-9601(96)00134-X, for the four-dimensional configuration. +tags: +- contextuality +- inner-product-spaces +- finite-certificates +msc: +- 81P13 +- 46C05 From 65ecedb0e965326b48d3dd236af248d514b8ce1e Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Sat, 28 Nov 2026 11:18:41 +0000 Subject: [PATCH 2/3] =?UTF-8?q?Qualify=20the=20Kochen=E2=80=93Specker=20so?= =?UTF-8?q?urce=20attribution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LeanPool/KochenSpecker/Main.lean | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/LeanPool/KochenSpecker/Main.lean b/LeanPool/KochenSpecker/Main.lean index 9a75b8fc0c..b62448544b 100644 --- a/LeanPool/KochenSpecker/Main.lean +++ b/LeanPool/KochenSpecker/Main.lean @@ -11,9 +11,12 @@ public import LeanPool.KochenSpecker.Cabello18 /-! # The Kochenโ€“Specker theorem -**Theorem** (Kochen and Specker, 1967). In a Hilbert space of dimension `d โ‰ฅ 3`, real or -complex, no map `v` from vectors to `{true, false}` is `true` on exactly one vector of every -orthonormal basis. +Kochen and Speckerโ€™s original obstruction (Theorem 1 of *The Problem of Hidden Variables in +Quantum Mechanics*) rules out a homomorphism from a finite partial Boolean algebra +constructed in real dimension three. + +This development proves a vector-valuation formulation over `โ„` and `โ„‚` in every finite +dimension `d โ‰ฅ 3`: no Boolean map on vectors marks exactly one vector of each orthonormal basis. * Dimension three is `Peres.not_isValuation_three` (Peres's 33 rays, a kernel-checked case split). * `IsValuation.exists_subspace` restricts a valuation in dimension `d + 1` to the orthogonal @@ -47,14 +50,15 @@ theorem noValuation_four : NoValuation.{u} ๐•œ 4 := by set ฯ† := ((stdOrthonormalBasis ๐•œ E).reindex (finCongr hE)).repr exact Cabello.not_isValuation_four _ (hv.map ฯ†) -/-- **The Kochenโ€“Specker theorem** in every inner product space of dimension `d โ‰ฅ 3` over `โ„` or -`โ„‚` (any `RCLike ๐•œ`). -/ +/-- The vector-valuation obstruction in every inner product space of dimension `d โ‰ฅ 3` +over `โ„` or `โ„‚` (any `RCLike ๐•œ`). -/ theorem not_isValuation {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ๐•œ E] {d : โ„•} (hd : 3 โ‰ค d) (hE : finrank ๐•œ E = d) (v : E โ†’ Bool) : ยฌ IsValuation ๐•œ d v := noValuation_three.of_le (by norm_num) hd E hE v -/-- **The Kochenโ€“Specker theorem.** For `d โ‰ฅ 3` and `๐•œ = โ„` or `โ„‚`, no map from `๐•œแตˆ` to -`Bool` is `true` on exactly one vector of every orthonormal basis. -/ +/-- The vector-valuation formulation of the Kochenโ€“Specker theorem in `๐•œแตˆ`. For `d โ‰ฅ 3` +and `๐•œ = โ„` or `โ„‚`, every Boolean map fails to mark exactly one vector in some +orthonormal basis. -/ theorem kochen_specker {d : โ„•} (hd : 3 โ‰ค d) : ยฌ โˆƒ v : EuclideanSpace ๐•œ (Fin d) โ†’ Bool, โˆ€ b : OrthonormalBasis (Fin d) ๐•œ (EuclideanSpace ๐•œ (Fin d)), โˆƒ! i, v (b i) = true := From 685caaa9297775af30484f9b77520165cd81c7ec Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Sat, 28 Nov 2026 11:20:15 +0000 Subject: [PATCH 3/3] =?UTF-8?q?Name=20the=20target=20of=20the=20original?= =?UTF-8?q?=20Kochen=E2=80=93Specker=20obstruction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LeanPool/KochenSpecker/Main.lean | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LeanPool/KochenSpecker/Main.lean b/LeanPool/KochenSpecker/Main.lean index b62448544b..1fe3f43ecc 100644 --- a/LeanPool/KochenSpecker/Main.lean +++ b/LeanPool/KochenSpecker/Main.lean @@ -12,8 +12,8 @@ public import LeanPool.KochenSpecker.Cabello18 # The Kochenโ€“Specker theorem Kochen and Speckerโ€™s original obstruction (Theorem 1 of *The Problem of Hidden Variables in -Quantum Mechanics*) rules out a homomorphism from a finite partial Boolean algebra -constructed in real dimension three. +Quantum Mechanics*) constructs a finite partial Boolean algebra of subspaces of `โ„ยณ` +with no homomorphism to the two-element Boolean algebra. This development proves a vector-valuation formulation over `โ„` and `โ„‚` in every finite dimension `d โ‰ฅ 3`: no Boolean map on vectors marks exactly one vector of each orthonormal basis.