import Mathlib namespace AdamLab.QuantumMongeFoundations /-- 1-qubit Bloch marginal `(c_I, c_X, c_Y, c_Z)` extracted from a 2-qubit Pauli table `Fin 4 → Fin 4 → ℚ`. -/ def leftMarginal (c : Fin 4 → Fin 4 → ℚ) : Fin 4 → ℚ := fun μ => c μ 0 def rightMarginal (c : Fin 4 → Fin 4 → ℚ) : Fin 4 → ℚ := fun ν => c 0 ν /-- Theorem 1: Monge tie-line equivalence between neighboring 2-qubit cross-sections `c12` and `c23` sharing site 2 (`rightMarginal c12 = leftMarginal c23`). -/ theorem monge_pauli_tie_line_iff (c12 c23 : Fin 4 → Fin 4 → ℚ) : rightMarginal c12 = leftMarginal c23 ↔ ∀ ν : Fin 4, c12 0 ν = c23 ν 0 := by constructor · intro h ν exact congr_fun h ν · intro h funext ν exact h ν /-- Theorem 2: Hard Monge tie-line projection `m = (a + b) / 2` eliminates seam overlap (`m - m = 0`) and satisfies the exact Pythagorean error reduction identity relative to any true marginal `t`. -/ theorem monge_projection_zero_overlap_and_pythagoras (a b t : ℚ) : let m := (a + b) / 2 m - m = 0 ∧ (a - t) ^ 2 + (b - t) ^ 2 = 2 * (m - t) ^ 2 + (a - b) ^ 2 / 2 ∧ 2 * (m - t) ^ 2 ≤ (a - t) ^ 2 + (b - t) ^ 2 := by intro m refine ⟨by ring, by ring, ?_⟩ have hsq : (0 : ℚ) ≤ (a - b) ^ 2 / 2 := by positivity have hid : (a - t) ^ 2 + (b - t) ^ 2 = 2 * (m - t) ^ 2 + (a - b) ^ 2 / 2 := by ring linarith /-- Theorem 3: Star-graph Monge averaging on a vertex of degree 5 (such as an Fe 3d orbital in the `K_{5,5}` Fe₂S₂ graph) compresses sum-of-squares error by factor 5 (`5 * m² ≤ ∑ eᵢ²`). -/ theorem monge_star_degree_d_variance_bound (e1 e2 e3 e4 e5 : ℚ) : 5 * ((e1 + e2 + e3 + e4 + e5) / 5) ^ 2 ≤ e1 ^ 2 + e2 ^ 2 + e3 ^ 2 + e4 ^ 2 + e5 ^ 2 := by have hlagrange : 5 * (e1 ^ 2 + e2 ^ 2 + e3 ^ 2 + e4 ^ 2 + e5 ^ 2) - (e1 + e2 + e3 + e4 + e5) ^ 2 = (e1 - e2) ^ 2 + (e1 - e3) ^ 2 + (e1 - e4) ^ 2 + (e1 - e5) ^ 2 + (e2 - e3) ^ 2 + (e2 - e4) ^ 2 + (e2 - e5) ^ 2 + (e3 - e4) ^ 2 + (e3 - e5) ^ 2 + (e4 - e5) ^ 2 := by ring have hpos : (0 : ℚ) ≤ (e1 - e2) ^ 2 + (e1 - e3) ^ 2 + (e1 - e4) ^ 2 + (e1 - e5) ^ 2 + (e2 - e3) ^ 2 + (e2 - e4) ^ 2 + (e2 - e5) ^ 2 + (e3 - e4) ^ 2 + (e3 - e5) ^ 2 + (e4 - e5) ^ 2 := by positivity linarith /-- Theorem 4: Adaptive trust-region convex update `(1 - α) * tr0 + α * tr1` (`0 ≤ α ≤ 1`) preserves exact unit trace and non-negativity of PSD expectations. -/ theorem trust_region_convex_step_preserves_trace_and_positivity (α tr0 tr1 q0 q1 : ℚ) (hα0 : 0 ≤ α) (hα1 : α ≤ 1) (ht0 : tr0 = 1) (ht1 : tr1 = 1) (hq0 : 0 ≤ q0) (hq1 : 0 ≤ q1) : (1 - α) * tr0 + α * tr1 = 1 ∧ 0 ≤ (1 - α) * q0 + α * q1 := by refine ⟨by rw [ht0, ht1]; ring, ?_⟩ have h1m : 0 ≤ 1 - α := by linarith nlinarith /-- Theorem 5 (Castigliano–Mazziotti Dual No-Overshoot Shield): If a Hamiltonian expectation decomposes into `E0 + ∑ w_k * p_k` with `w_k ≥ 0` and P/Q/G-cone expectations `p_k ≥ 0`, then `E_recon ≥ E0` holds unconditionally (zero non-variational energy overshoot!). -/ theorem mazziotti_pq_dual_no_overshoot {n : ℕ} (E0 : ℚ) (w p : Fin n → ℚ) (hw : ∀ i, 0 ≤ w i) (hp : ∀ i, 0 ≤ p i) : E0 ≤ E0 + ∑ i : Fin n, w i * p i := by have hsum : (0 : ℚ) ≤ ∑ i : Fin n, w i * p i := Finset.sum_nonneg (fun i _ => mul_nonneg (hw i) (hp i)) linarith /-- Theorem 6: Fermionic Monge contraction sum rule `∀ p, ∑ r, D2 p p r r = (N - 1) * D1 p p` implies exact global 2-electron trace `(N - 1) * ∑ p, D1 p p`. -/ theorem fermionic_monge_contraction_sum_rule {K : ℕ} (N : ℚ) (D1 : Fin K → Fin K → ℚ) (D2 : Fin K → Fin K → Fin K → Fin K → ℚ) (hmonge : ∀ p : Fin K, (∑ r : Fin K, D2 p p r r) = (N - 1) * D1 p p) : (∑ p : Fin K, ∑ r : Fin K, D2 p p r r) = (N - 1) * (∑ p : Fin K, D1 p p) := by calc (∑ p : Fin K, ∑ r : Fin K, D2 p p r r) = ∑ p : Fin K, (N - 1) * D1 p p := Finset.sum_congr rfl (fun p _ => hmonge p) _ = (N - 1) * (∑ p : Fin K, D1 p p) := (Finset.mul_sum Finset.univ (fun p => D1 p p) (N - 1)).symm /-- Theorem 7: Exact reversibility of spin-free 2-RDM cumulant separation `D2 = (D1_pq * D1_rs - D1_ps * D1_rq / 2) + Δ`. -/ theorem spinfree_cumulant_exact_decomposition (d1_pq d1_rs d1_ps d1_rq d2_pqrs : ℚ) : let mf := d1_pq * d1_rs - d1_ps * d1_rq / 2 let cumulant := d2_pqrs - mf mf + cumulant = d2_pqrs := by intro mf cumulant ring /-- Theorem 8: Quantum Monogamy / Frustration Lower Bound on a 3-site cell, preventing simultaneous maximal negative correlators (the root cause of Heisenberg energy overshoot). -/ theorem monogamy_frustration_overshoot_blocker (s1 s2 s3 : ℚ) : -(s1 ^ 2 + s2 ^ 2 + s3 ^ 2) ≤ 2 * (s1 * s2 + s2 * s3 + s1 * s3) := by have hsq : (0 : ℚ) ≤ (s1 + s2 + s3) ^ 2 := sq_nonneg (s1 + s2 + s3) linarith end AdamLab.QuantumMongeFoundations