Research-Stack/0-Core-Formalism/lean/external/OTOM/Waveprobe.lean

276 lines
10 KiB
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/-
Formal verification of `docs/specs/waveprobe_qubo_spec.tex` (2026-04-17).
Each section of the spec maps to a `section` here. Every equation is stated
as a Lean `theorem` or `def`. Proofs prefer `native_decide` for numerical
facts and direct algebraic manipulation for identities.
-/
import Mathlib.Data.Complex.Basic
import Mathlib.Algebra.BigOperators.Group.Finset.Basic
import Mathlib.Algebra.Star.BigOperators
import Mathlib.Data.Rat.Defs
import Mathlib.Data.Real.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Positivity
import Mathlib.Tactic.NormNum
namespace Waveprobe
open Complex BigOperators Finset
/-! ## §2 — The Waveprobe State -/
/-- A Waveprobe state is a complex amplitude vector over `Fin n`. Eq. (1). -/
abbrev State (n : ) := Fin n →
/-- Physics-convention inner product ⟨φ|ψ⟩ = Σ conj(φ i) · ψ i.
Conjugate-linear in the first argument, linear in the second. -/
def cdot {n : } (φ ψ : State n) : := ∑ i, (star (φ i)) * (ψ i)
/-- Normalization predicate: ⟨ψ|ψ⟩ = 1. -/
def Normalized {n : } (ψ : State n) : Prop := cdot ψ ψ = 1
/-- ⟨φ|ψ⟩* = ⟨ψ|φ⟩ (conjugate symmetry of the inner product). -/
theorem cdot_conj_symm {n : } (φ ψ : State n) : star (cdot φ ψ) = cdot ψ φ := by
unfold cdot
rw [star_sum]
refine Finset.sum_congr rfl ?_
intro i _
rw [star_mul', star_star, mul_comm]
/-! ## §3 — Projector and Local QUBO Formalism -/
/-- Projector P̂ψ = |ψc⟩⟨ψc|ψ⟩. Eq. (2). -/
def proj {n : } (ψc ψ : State n) : State n := fun i => (cdot ψc ψ) * (ψc i)
/-- Overlap energy E(s) = ⟨ψp|P̂|ψp⟩. Eq. (3) LHS. -/
def overlap {n : } (ψc ψp : State n) : := cdot ψp (proj ψc ψp)
/-- Overlap-energy identity: ⟨ψp|P̂|ψp⟩ = |⟨ψc|ψp⟩|² (as ). Eq. (3). -/
theorem overlap_eq_normSq {n : } (ψc ψp : State n) :
overlap ψc ψp = (cdot ψc ψp) * star (cdot ψc ψp) := by
unfold overlap proj cdot
have h1 : (∑ i, star (ψp i) * ((∑ j, star (ψc j) * ψp j) * ψc i))
= (∑ j, star (ψc j) * ψp j) * (∑ i, star (ψp i) * ψc i) := by
rw [Finset.mul_sum]
refine Finset.sum_congr rfl ?_
intro i _
ring
rw [h1]
have h2 : (∑ i, star (ψp i) * ψc i) = star (∑ i, star (ψc i) * ψp i) := by
rw [star_sum]
refine Finset.sum_congr rfl ?_
intro i _
rw [star_mul', star_star, mul_comm]
rw [h2]
/-- Helper: cdot is linear in its second argument (scalar multiplication). -/
theorem cdot_smul {n : } (a : ) (φ ψ : State n) :
cdot φ (fun i => a * ψ i) = a * cdot φ ψ := by
unfold cdot
rw [Finset.mul_sum]
refine Finset.sum_congr rfl ?_
intro i _; ring
/-- The projector is idempotent on normalized states: P̂² = P̂. -/
theorem proj_idempotent {n : } {ψc : State n} (hN : Normalized ψc) (ψ : State n) :
proj ψc (proj ψc ψ) = proj ψc ψ := by
unfold proj
ext i
have h : cdot ψc (fun j => (cdot ψc ψ) * (ψc j)) = cdot ψc ψ := by
rw [cdot_smul]
unfold Normalized at hN
rw [hN, mul_one]
rw [h]
/-- QUBO matrix Q_ij = conj(c_i) · c_j. Eq. (4). -/
def Qmat {n : } (c : Fin n → ) (i j : Fin n) : := star (c i) * (c j)
/-- Q is Hermitian: Q_ji = conj(Q_ij). -/
theorem Qmat_hermitian {n : } (c : Fin n → ) (i j : Fin n) :
Qmat c j i = star (Qmat c i j) := by
unfold Qmat
rw [star_mul', star_star, mul_comm]
/-- QUBO quadratic form x†Qx expanded as ∑∑ conj(xᵢ)·Q_ij·xⱼ. -/
def qform {n : } (c x : Fin n → ) : :=
∑ i, ∑ j, star (x i) * Qmat c i j * (x j)
/-- Bilinear (no-conjugation) form β(c,x) = ∑ᵢ cᵢ·xᵢ.
NOTE on spec §3 eq (4): the spec writes `Q_ij = c̄_i c_j`. Taken literally,
`x†Qx = |∑ᵢ cᵢ xᵢ|²` — a *bilinear* (not sesquilinear) squared magnitude.
The sesquilinear form `|⟨c|x⟩|²` (which matches the prose "projector
P̂ = |ψc⟩⟨ψc|") requires `Q_ij = c_i · c̄_j` instead. Both variants are
proved below so the user can choose. -/
def bilin {n : } (c x : Fin n → ) : := ∑ i, c i * x i
/-- Quadratic form under the literal spec formula `Q_ij = c̄_i c_j`
factors as `|β(c,x)|²` where β is the bilinear form. -/
theorem qform_eq_bilin_normSq {n : } (c x : Fin n → ) :
qform c x = star (bilin c x) * bilin c x := by
unfold qform Qmat bilin
have h1 : (∑ i, ∑ j, star (x i) * (star (c i) * c j) * x j)
= (∑ i, star (c i) * star (x i)) * (∑ j, c j * x j) := by
rw [Finset.sum_mul_sum]
refine Finset.sum_congr rfl ?_
intro i _
refine Finset.sum_congr rfl ?_
intro j _
ring
rw [h1]
congr 1
rw [star_sum]
refine Finset.sum_congr rfl ?_
intro i _
rw [star_mul']
/-- Corrected outer-product QUBO matrix `Q'_ij = c_i · c̄_j`. Under this
convention the quadratic form factors as `|⟨c|x⟩|²`, matching the
physical interpretation P̂ = |c⟩⟨c|. -/
def QmatOuter {n : } (c : Fin n → ) (i j : Fin n) : := (c i) * star (c j)
def qformOuter {n : } (c x : Fin n → ) : :=
∑ i, ∑ j, star (x i) * QmatOuter c i j * (x j)
theorem qformOuter_eq_cdot_normSq {n : } (c x : Fin n → ) :
qformOuter c x = star (cdot c x) * cdot c x := by
unfold qformOuter QmatOuter cdot
have h1 : (∑ i, ∑ j, star (x i) * (c i * star (c j)) * x j)
= (∑ i, c i * star (x i)) * (∑ j, star (c j) * x j) := by
rw [Finset.sum_mul_sum]
refine Finset.sum_congr rfl ?_
intro i _
refine Finset.sum_congr rfl ?_
intro j _
ring
rw [h1]
congr 1
rw [star_sum]
refine Finset.sum_congr rfl ?_
intro i _
rw [star_mul', star_star]
/-! ## §4 — Phase-Lock Coherence and Feature Fusion -/
/-- Canonical phase-lock weights from Eq. (6). Rationals for exact arithmetic. -/
def w_e : := 2/5 -- 0.4
def w_r : := 3/10 -- 0.3
def w_d : := 3/10 -- 0.3
/-- Weights sum to 1 exactly. -/
theorem weights_sum_one : w_e + w_r + w_d = 1 := by native_decide
/-- Phase-lock coherence φ(s,x) = wₑ·φₑ + wᵣ·φᵣ + w_d·φ_d. Eq. (5). -/
def phi (φ_e φ_r φ_d : ) : := w_e * φ_e + w_r * φ_r + w_d * φ_d
/-- If every component φₐ ∈ [0,1] then φ ∈ [0,1] (convex combination). -/
theorem phi_in_unit {φe φr φd : }
(he0 : 0 ≤ φe) (he1 : φe ≤ 1)
(hr0 : 0 ≤ φr) (hr1 : φr ≤ 1)
(hd0 : 0 ≤ φd) (hd1 : φd ≤ 1) :
0 ≤ phi φe φr φd ∧ phi φe φr φd ≤ 1 := by
refine ⟨?_, ?_⟩
· unfold phi w_e w_r w_d
have h1 : (0:) ≤ (2/5) * φe := by positivity
have h2 : (0:) ≤ (3/10) * φr := by positivity
have h3 : (0:) ≤ (3/10) * φd := by positivity
linarith
· unfold phi w_e w_r w_d
have h1 : (2/5 : ) * φe ≤ 2/5 := by
have : (0:) ≤ (2/5 : ) := by norm_num
nlinarith
have h2 : (3/10 : ) * φr ≤ 3/10 := by
have : (0:) ≤ (3/10 : ) := by norm_num
nlinarith
have h3 : (3/10 : ) * φd ≤ 3/10 := by
have : (0:) ≤ (3/10 : ) := by norm_num
nlinarith
linarith
/-! ## §5 — Indefinite Causal Order / Bell Bound
The classical CHSH bound |⟨O_AB⟩| ≤ 2 is a deep theorem about local-realistic
correlations. We record it here as a named hypothesis: any proof in the
Waveprobe framework must either (a) assume correlations are classical and
invoke a mathlib-grade CHSH proof, or (b) empirically detect violation. The
*statement* of the bound is formalized; the *proof* requires a full
probability-space construction that lives outside this module. -/
/-- Classical CHSH observable bound (|⟨O_AB⟩| ≤ 2) as a predicate over a
scalar expectation value. Eq. (7). -/
def chshClassical (expVal : ) : Prop := |expVal| ≤ 2
/-- Trivial witness: the zero correlation trivially satisfies the classical
CHSH bound. -/
theorem chsh_zero : chshClassical 0 := by
unfold chshClassical
simp
/-! ## §6 — Regret-Blink Coupling -/
/-- Blink cycle timing in ms as a function of regret magnitude R_mag.
Δt_blink = 500ms + 200ms · R_mag. Eq. (8). -/
def blinkMs (rMag : ) : := 500 + 200 * rMag
/-- Baseline (R_mag = 0) gives 500ms. -/
theorem blink_at_zero : blinkMs 0 = 500 := by native_decide
/-- Peak regret (R_mag = 1) gives 700ms. -/
theorem blink_at_one : blinkMs 1 = 700 := by native_decide
/-- Blink timing is monotone in R_mag. -/
theorem blink_monotone {r₁ r₂ : } (h : r₁ ≤ r₂) : blinkMs r₁ ≤ blinkMs r₂ := by
unfold blinkMs
have : (200 : ) * r₁ ≤ 200 * r₂ := by
have : (0:) ≤ 200 := by norm_num
nlinarith
linarith
/-- Decoherence time t_dec = 200ms (§6, prose). -/
def tDecMs : := 200
theorem blink_minus_baseline_eq_tDec : blinkMs 1 - 500 = tDecMs := by
native_decide
/-! ## §7 — Conservation and Totality -/
/-- Admission predicate: probe injection allowed iff BPB does not increase.
Eq. (9). -/
def admissibleInjection (bpbProbe bpbLocal : ) : Prop := bpbProbe ≤ bpbLocal
/-- Reflexivity: leaving the state unchanged is always admissible. -/
theorem admissible_reflexive (bpb : ) : admissibleInjection bpb bpb :=
le_refl bpb
/-- Transitivity: a cheaper probe is admissible if it beats any dominator. -/
theorem admissible_transitive {a b c : }
(hab : admissibleInjection a b) (hbc : admissibleInjection b c) :
admissibleInjection a c := by
unfold admissibleInjection at *
linarith
/-! ## Summary
Verified in this module:
§2 eq (1) — State definition (abbrev `State`)
§3 eq (2) — Projector `proj` and its idempotency (`proj_idempotent`)
§3 eq (3) — Overlap-energy identity (`overlap_eq_normSq`)
§3 eq (4) — QUBO matrix `Qmat`, hermiticity (`Qmat_hermitian`),
quadratic-form factorisation (`qform_eq_normSq`)
§4 eq (5) — `phi` definition; convex-combination bound (`phi_in_unit`)
§4 eq (6) — Weight normalisation (`weights_sum_one`)
§5 eq (7) — CHSH bound predicate (`chshClassical`, `chsh_zero`) —
classical inequality witnessed; full local-realistic proof
is out of scope for a finite-dim linear-algebra module.
§6 eq (8) — Blink timing; endpoints (`blink_at_zero`, `blink_at_one`),
monotonicity (`blink_monotone`), t_dec identity
(`blink_minus_baseline_eq_tDec`).
§7 eq (9) — Admission predicate reflexivity / transitivity.
Conjugate symmetry of the inner product (`cdot_conj_symm`) is proved as
supporting lemma.
-/
end Waveprobe