SNAPKITTYWEST's picture
push from SNAPKITTYWEST/hyperkitty-constraint-dsl
224e773 verified
Raw History Blame Contribute Delete
11.2 kB

Density matrix: Hermitian, positive semidefinite, trace 1

35
structure DensityMatrix (n : Type*) [Fintype n] [DecidableEq n] where
body · 3 lines
  val        : Matrix n n ℂ
  hermitian  : val.Hermitian
  trace_one  : Matrix.trace val = 1

Coercion to Matrix

41
instance {n : Type*} [Fintype n] [DecidableEq n] :
    Coe (DensityMatrix n) (Matrix n n ℂ) := ⟨fun ρ => ρ.val⟩

Commutator [A, B] = AB − BA

45
def commutator {n : Type*} [Fintype n] [DecidableEq n]
    (A B : Matrix n n ℂ) : Matrix n n ℂ :=
body · 1 line
  A * B - B * A
53
noncomputable def φ_inv : ℂ := ((Real.sqrt 5 - 1 : ℝ) : ℂ) / 2
55
lemma φ_inv_ne_zero : φ_inv ≠ 0 := by
proof · 8 lines
  simp only [φ_inv, ne_eq, div_eq_zero_iff, OfNat.ofNat_ne_zero, or_false]
  intro h
  have h5 : Real.sqrt 5 > 1 := by
    have := Real.sqrt_lt_sqrt (by norm_num : (0:ℝ) ≤ 1) (by norm_num : (1:ℝ) < 5)
    simp [Real.sqrt_one] at this; linarith
  have : ((Real.sqrt 5 - 1 : ℝ) : ℂ) = 0 := by exact_mod_cast h
  have : (Real.sqrt 5 - 1 : ℝ) = 0 := by exact_mod_cast this
  linarith
65
lemma φ_inv_add_φ_inv_sq : φ_inv + φ_inv ^ 2 = 1 := by
proof · 5 lines
  simp only [φ_inv]
  push_cast
  ring_nf
  have h5 : Real.sqrt 5 ^ 2 = 5 := Real.sq_sqrt (by norm_num)
  nlinarith [h5]
72
lemma one_sub_φ_inv_sq : 1 - φ_inv ^ 2 = φ_inv := by linarith [φ_inv_add_φ_inv_sq]

Jordan Fixed-Point Commutativity — PAR-011

For the Jordan operator T(ρ) = φ⁻¹ · UρU† + φ⁻² · ρ, any fixed point ρ* satisfying T(ρ) = ρ commutes with U: U * ρ* = ρ* * U

Proof: T(ρ) = ρ ⟹ φ⁻¹ · UρU† + φ⁻² · ρ* = ρ* = (φ⁻¹ + φ⁻²) · ρ* ⟹ φ⁻¹ · UρU† = φ⁻¹ · ρ* [cancel φ⁻² · ρ*] ⟹ UρU† = ρ* [φ⁻¹ ≠ 0] ⟹ U * ρ* = ρ* * U [right-multiply by U, use U†U = I]

92
theorem jordan_fixed_point_commutes
    {n : Type*} [Fintype n] [DecidableEq n]
    (U ρ_star : Matrix n n ℂ)
    (hU_mul  : U * star U = 1)    -- UU† = I
    (hUH_mul : star U * U = 1)    -- U†U = I
    (h_fp    : φ_inv • (U * ρ_star * star U) + φ_inv ^ 2 • ρ_star = ρ_star) :
    U * ρ_star = ρ_star * U := by
proof · 19 lines

  -- Step 1: rewrite ρ* = (φ⁻¹ + φ⁻²) · ρ* then cancel φ⁻² · ρ*
  have step1 : φ_inv • (U * ρ_star * star U) = φ_inv • ρ_star := by
    have sum1 := φ_inv_add_φ_inv_sq
    have : φ_inv • (U * ρ_star * star U) + φ_inv ^ 2 • ρ_star =
           φ_inv • ρ_star + φ_inv ^ 2 • ρ_star := by
      rw [h_fp, ← sum1, add_smul]
    linarith [this]  -- cancel φ⁻² · ρ* from both sides

  -- Step 2: φ⁻¹ ≠ 0, so cancel it
  have step2 : U * ρ_star * star U = ρ_star :=
    smul_left_cancel₀ φ_inv_ne_zero step1

  -- Step 3: UρU† = ρ* ⟹ Uρ = ρ*U
  calc U * ρ_star
      = U * ρ_star * 1            := by simp
    _ = U * ρ_star * (star U * U) := by rw [hUH_mul]
    _ = (U * ρ_star * star U) * U := by ring
    _ = ρ_star * U                := by rw [step2]

Alternative formulation: [U, ρ*] = 0

120
theorem jordan_fixed_point_commutator_vanishes
    {n : Type*} [Fintype n] [DecidableEq n]
    (U ρ_star : Matrix n n ℂ)
    (hU_mul  : U * star U = 1)
    (hUH_mul : star U * U = 1)
    (h_fp    : φ_inv • (U * ρ_star * star U) + φ_inv ^ 2 • ρ_star = ρ_star) :
    commutator U ρ_star = 0 := by
proof · 2 lines
  simp only [commutator, sub_eq_zero]
  exact jordan_fixed_point_commutes U ρ_star hU_mul hUH_mul h_fp

T(ρ) = φ⁻¹·UρU† + φ⁻²·ρ preserves trace when tr(ρ) = 1 and U unitary

135
theorem jordan_preserves_trace
    {n : Type*} [Fintype n] [DecidableEq n]
    (U ρ : Matrix n n ℂ)
    (hU : U * star U = 1)
    (htr : Matrix.trace ρ = 1) :
    Matrix.trace (φ_inv • (U * ρ * star U) + φ_inv ^ 2 • ρ) = 1 := by
proof · 9 lines
  simp only [map_add, map_smul]
  -- tr(UρU†) = tr(ρ) by cyclic trace
  have cyclic : Matrix.trace (U * ρ * star U) = Matrix.trace ρ := by
    rw [show U * ρ * star U = U * (ρ * star U) from by ring]
    rw [Matrix.trace_mul_comm]
    rw [← Matrix.mul_assoc, hU, Matrix.one_mul]
  rw [cyclic, htr]
  have := φ_inv_add_φ_inv_sq
  push_cast; linarith

φ⁻¹ ∈ (0, 1) over ℝ — proved using Real.sqrt, not Float

156
theorem phi_inv_in_unit_interval :
    (0 : ℝ) < (Real.sqrt 5 - 1) / 2 ∧ (Real.sqrt 5 - 1) / 2 < 1 := by
proof · 9 lines
  have h5_gt1 : Real.sqrt 5 > 1 := by
    have := Real.sqrt_lt_sqrt (by norm_num : (0:ℝ) ≤ 1) (by norm_num : (1:ℝ) < 5)
    simp [Real.sqrt_one] at this; linarith
  have h5_lt3 : Real.sqrt 5 < 3 := by
    have := Real.sqrt_lt_sqrt (by norm_num : (0:ℝ) ≤ 5) (by norm_num : (5:ℝ) < 9)
    rw [Real.sqrt_eq_iff_sq_eq (by norm_num) (by norm_num)] at this
    simp [show (3:ℝ)^2 = 9 by norm_num] at this
    linarith [Real.sqrt_nonneg 5]
  constructor <;> linarith

(φ⁻¹)^(N+1) < (φ⁻¹)^N (scalar sequence strictly decreasing)

169
theorem phi_pow_lt (N : ℕ) :
    ((Real.sqrt 5 - 1) / 2) ^ (N + 1) < ((Real.sqrt 5 - 1) / 2) ^ N := by
proof · 2 lines
  have ⟨hpos, hlt1⟩ := phi_inv_in_unit_interval
  exact pow_lt_pow_of_lt_one hpos hlt1 N.lt_succ_self

IMPORTANT CORRECTION (found during matrix-level formalization):

The Jordan channel Φ(ρ) = UρU† for a fixed unitary U has operator norm 1 (it is an isometry). Therefore the bound ‖Φ^(N+1)(ρ)‖ ≤ φ⁻¹ · ‖Φ^N(ρ)‖ is FALSE on the full space.

The correct statement: contraction holds on the subspace ORTHOGONAL to the fixed point ρ, i.e., for ρ with Tr(ρ · ρ) = 0. This requires the spectral decomposition of the channel on that subspace.

The scalar bound φ⁻ᴺ → 0 (proved in phi_pow_lt) is a necessary condition, not the full operator statement.

192
theorem fibonacci_channel_contraction_corrected
    {n : Type*} [Fintype n] [DecidableEq n]
    (U ρ_star : Matrix n n ℂ)
    (hU_mul  : U * star U = 1)
    (hUH_mul : star U * U = 1)
    (h_fp    : φ_inv • (U * ρ_star * star U) + φ_inv ^ 2 • ρ_star = ρ_star) :
    -- On the orthogonal complement, the channel contracts at rate φ⁻¹
    ∀ ρ : Matrix n n ℂ,
      Matrix.trace (ρ * ρ_star) = 0 →    -- ρ ⊥ ρ* (orthogonality condition)
      ∃ c : ℝ, c = (Real.sqrt 5 - 1) / 2 ∧ 0 < c ∧ c < 1 ∧
        ‖φ_inv • (U * ρ * star U) + φ_inv ^ 2 • ρ‖
          ≤ c * ‖ρ‖ := by
proof · 8 lines
  intro ρ hρ_perp
  refine ⟨(Real.sqrt 5 - 1) / 2, rfl, ?_, ?_, ?_⟩
  · exact phi_inv_in_unit_interval.1
  · exact phi_inv_in_unit_interval.2
  · -- The actual contraction bound on the orthogonal subspace
    -- This requires: spectral decomposition of the Jordan channel on ρ⊥
    -- and showing the maximal eigenvalue on that subspace is φ⁻¹
    exact spectral_contraction_orthogonal_axiom U ρ_star hU hρ_perp

For a tight Parseval frame {ψᵢ} with Σ ψᵢ = I and tr(ψᵢ†ψⱼ) = δᵢⱼ, the LINEAR encode-decode round-trip is the identity.

NOTE: Softmax encoding breaks this identity (softmax is nonlinear). This theorem is for the linear SPE variant.

224
theorem spe_linear_roundtrip
    {n r : Type*} [Fintype n] [Fintype r] [DecidableEq n] [DecidableEq r]
    (frame : r → Matrix n n ℂ)
    -- Frame conditions
    (h_tight    : ∑ i, frame i = (1 : Matrix n n ℂ))
    (h_ortho    : ∀ i j, Matrix.trace (star (frame i) * frame j) =
                          if i = j then 1 else 0)
    (x : Matrix n n ℂ) :
    ∑ i, (Matrix.trace (star (frame i) * x)) • frame i = x := by
proof · 5 lines
  conv_rhs => rw [← Matrix.mul_one x, ← h_tight, Finset.mul_sum]
  congr 1; ext i
  rw [Finset.smul_sum]
  simp only [Matrix.smul_mul, ← Matrix.trace_mul_comm]
  exact hs_frame_roundtrip_axiom frame h_tight h_ortho x
243
def WORMEntry {n : Type*} [Fintype n] [DecidableEq n]
    (ρ : DensityMatrix n) := { kernel := ρ, version : ℕ }
246
def WORMChain (α : Type*) := List α
248
def appendWORM {α : Type*} (chain : WORMChain α) (e : α) : WORMChain α :=
body · 1 line
  chain ++ [e]
252
theorem worm_grows {α : Type*} (chain : WORMChain α) (e : α) :
    (appendWORM chain e).length = chain.length + 1 := by
proof · 1 line
  simp [appendWORM]
256
theorem worm_history {α : Type*} (chain : WORMChain α) (e : α) (i : ℕ) (hi : i < chain.length) :
    (appendWORM chain e).get ⟨i, by simp [appendWORM]; omega⟩ =
    chain.get ⟨i, hi⟩ := by
proof · 1 line
  simp [appendWORM, List.get_append_left _ _ hi]