Holevo Additivity Gap in Lean 4

Lean explorer

Exact Lean source

Nonadditivity.NoncommutativeCSEndpointTrace

Download original .lean · View on GitHub · Jump to source

Relationships above come from literal import commands. The declarations below link to types and references extracted from Lean’s environment. Source text is complete and unchanged.

Declarations in this module

91 project constants, including generated, internal and private declarations.

91 declarations

Full module

1/-2Copyright (c) 2026 the Nonadditivity project contributors.3All rights reserved. See COPYRIGHT.md for licensing and attribution.4-/56import Nonadditivity.NoncommutativeCSAssignmentProducts78/-! # Compile named first/last endpoint traces910The input trace records the names of all active labels. Its literal factors11are evaluated from a single global assignment of profiles to those names.12The compiler inserts or removes the corresponding memory register. Closing13any register is allowed, so the theorem imposes no noncrossing restriction.14-/1516noncomputable section17set_option backward.isDefEq.respectTransparency false18set_option linter.unusedSectionVars false19namespace Nonadditivity.NoncommutativeCS20open scoped BigOperators InnerProduct2122variable {𝕜 E I J : Type*} [RCLike 𝕜]23variable [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [CompleteSpace E]24variable [Fintype J] [DecidableEq J]2526/-- A named endpoint trace with its exact active-label layout at both ends.27Middle coefficients see only currently active labels. -/28inductive EndpointTrace (𝕜 E I J : Type*) [RCLike 𝕜] [NormedAddCommGroup E]29    [InnerProductSpace 𝕜 E] : {m n : ℕ} → (Fin m → I) → (Fin n → I) → Type _30  | done {n : ℕ} (layout : Fin n → I) : EndpointTrace 𝕜 E I J layout layout31  | first {m n : ℕ} {layout : Fin m → I} {out : Fin n → I}32      (i : I) (A : J → E →L[𝕜] E)33      (rest : EndpointTrace 𝕜 E I J (Fin.cons i layout) out) :34      EndpointTrace 𝕜 E I J layout out35  | last {m n : ℕ} {layout : Fin (m + 1) → I} {out : Fin n → I}36      (p : Fin (m + 1)) (A : J → E →L[𝕜] E)37      (rest : EndpointTrace 𝕜 E I J (p.removeNth layout) out) :38      EndpointTrace 𝕜 E I J layout out39  | middle {m n : ℕ} {layout : Fin m → I} {out : Fin n → I}40      (A : (Fin m → J) → E →L[𝕜] E)41      (rest : EndpointTrace 𝕜 E I J layout out) : EndpointTrace 𝕜 E I J layout out42  | singleton {m n : ℕ} {layout : Fin m → I} {out : Fin n → I}43      (i : I) (A : J → E →L[𝕜] E)44      (rest : EndpointTrace 𝕜 E I J layout out) : EndpointTrace 𝕜 E I J layout out4546namespace EndpointTrace4748def compile {m n : ℕ} {a : Fin m → I} {b : Fin n → I} :49    EndpointTrace 𝕜 E I J a b → AssignmentProgram 𝕜 E J m n50  | .done _ => .done _51  | .first _ A P => .openReg 0 A P.compile52  | .last p A P => .closeReg p A P.compile53  | .middle A P => .middle A P.compile54  | .singleton _ A P => .singleton A P.compile5556/-- The name of each independent variable introduced by the trace. -/57def labels {m n : ℕ} {a : Fin m → I} {b : Fin n → I}58    (P : EndpointTrace 𝕜 E I J a b) : Fin P.compile.variableCount → I :=59  match P with60  | .done _ => Fin.elim061  | .first i _ P => Fin.cons i P.labels62  | .last _ _ P => P.labels63  | .middle _ P => P.labels64  | .singleton i _ P => Fin.cons i P.labels6566/-- Literal ordered factors, read directly from the global named assignment. -/67def factors {m n : ℕ} {a : Fin m → I} {b : Fin n → I}68    (P : EndpointTrace 𝕜 E I J a b) (σ : I → J) : List (E →L[𝕜] E) :=69  match P with70  | .done _ => []71  | .first i A P => P.factors σ ++ [A (σ i)]72  | .last (layout := a) p A P => P.factors σ ++ [A (σ (a p))]73  | .middle (layout := a) A P => P.factors σ ++ [A (σ ∘ a)]74  | .singleton i A P => P.factors σ ++ [A (σ i)]7576def markedFlags {m n : ℕ} {a : Fin m → I} {b : Fin n → I} :77    EndpointTrace 𝕜 E I J a b → List Bool78  | .done _ => []79  | .first _ _ P => true :: P.markedFlags80  | .last _ _ P => true :: P.markedFlags81  | .middle _ P => false :: P.markedFlags82  | .singleton _ _ P => true :: P.markedFlags8384theorem factors_length {m n : ℕ} {a : Fin m → I} {b : Fin n → I}85    (P : EndpointTrace 𝕜 E I J a b) (σ : I → J) :86    (P.factors σ).length = P.markedFlags.length := by87  induction P <;> simp_all [factors, markedFlags]8889/-- The compiler preserves every literal coefficient product. -/90theorem compile_factors {m n : ℕ} {a : Fin m → I} {b : Fin n → I}91    (P : EndpointTrace 𝕜 E I J a b) (σ : I → J) :92    P.compile.factors (σ ∘ P.labels) (σ ∘ a) = P.factors σ := by93  induction P with94  | done => rfl95  | first i A P ih =>96      simpa only [compile, labels, AssignmentProgram.factors, Fin.comp_cons,97        Fin.tail_cons, Fin.cons_zero, Fin.insertNth_zero', factors] using98        congrArg (fun l => l ++ [A (σ i)]) ih99  | @last m n a b p A P ih =>100      simpa only [compile, labels, AssignmentProgram.factors, factors,101        Fin.removeNth, Function.comp_def] using102        congrArg (fun l => l ++ [A (σ (a p))]) ih103  | @middle m n a b A P ih =>104      simpa only [compile, labels, AssignmentProgram.factors, factors] using105        congrArg (fun l => l ++ [A (σ ∘ a)]) ih106  | singleton i A P ih =>107      simpa only [compile, labels, AssignmentProgram.factors, factors,108        Fin.comp_cons, Fin.tail_cons, Fin.cons_zero] using109        congrArg (fun l => l ++ [A (σ i)]) ih110111/-- Every named label is introduced exactly once. This is the elementary112coverage condition on the first/singleton occurrences, independent of norms. -/113def CoversLabels {m n : ℕ} {a : Fin m → I} {b : Fin n → I}114    (P : EndpointTrace 𝕜 E I J a b) : Prop := Function.Bijective P.labels115116/-- The literal named global sum obeys the compiled endpoint/middle cost.117All memory identities have been proved by the compiler. -/118theorem sum_products_norm_le [Fintype I] [DecidableEq I]119    (P : EndpointTrace 𝕜 E I J (Fin.elim0 : Fin 0 → I) (Fin.elim0 : Fin 0 → I))120    (hP : P.CoversLabels) :121    ‖∑ σ : I → J, (P.factors σ).prod‖ ≤ P.compile.cost := by122  let e : Fin P.compile.variableCount ≃ I := Equiv.ofBijective P.labels hP123  have h := P.compile.named_sum_products_norm_le e124  have hi : ∀ σ : I → J,125      P.compile.factors (fun k => σ (e k)) Fin.elim0 = P.factors σ := by126    intro σ127    have hempty : σ ∘ (Fin.elim0 : Fin 0 → I) = Fin.elim0 := Subsingleton.elim _ _128    simpa only [e, Equiv.ofBijective_apply, hempty] using P.compile_factors σ129  simpa only [hi] using h130131end EndpointTrace132end Nonadditivity.NoncommutativeCS