Holevo Additivity Gap in Lean 4

Lean explorer

Exact Lean source

Nonadditivity.NoncommutativeCSEndpointSkeleton

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

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

96 declarations

Full module

1/-2Copyright (c) 2026 the Nonadditivity project contributors.3All rights reserved. See COPYRIGHT.md for licensing and attribution.4-/56import Nonadditivity.NoncommutativeCSEndpointTrace78/-! # Automatic compressed endpoint skeletons910The purely finite compiler below opens a label at its first repeated visit,11closes it at its last visit, and sums a singleton at its sole visit. Consecutive12middle visits are merged into one block. A later decoration may attach an13arbitrary operator to the whole block, without factorizing that operator.14-/1516noncomputable section17set_option backward.isDefEq.respectTransparency false18set_option linter.unusedSectionVars false19namespace Nonadditivity.NoncommutativeCS2021inductive EndpointSkeleton (I : Type*) :22    {m n : ℕ} → (Fin m → I) → (Fin n → I) → Type _23  | done {n : ℕ} (layout : Fin n → I) : EndpointSkeleton I layout layout24  | first {m n : ℕ} {a : Fin m → I} {b : Fin n → I} (i : I)25      (rest : EndpointSkeleton I (Fin.cons i a) b) : EndpointSkeleton I a b26  | last {m n : ℕ} {a : Fin (m + 1) → I} {b : Fin n → I} (p : Fin (m + 1))27      (rest : EndpointSkeleton I (p.removeNth a) b) : EndpointSkeleton I a b28  | middle {m n : ℕ} {a : Fin m → I} {b : Fin n → I} (visits : List (Fin m))29      (rest : EndpointSkeleton I a b) : EndpointSkeleton I a b30  | singleton {m n : ℕ} {a : Fin m → I} {b : Fin n → I} (i : I)31      (rest : EndpointSkeleton I a b) : EndpointSkeleton I a b3233namespace EndpointSkeleton34variable {I : Type*}3536def word {m n : ℕ} {a : Fin m → I} {b : Fin n → I} : EndpointSkeleton I a b → List I37  | .done _ => []38  | .first i P => i :: P.word39  | .last (a := a) p P => a p :: P.word40  | .middle (a := a) v P => v.map a ++ P.word41  | .singleton i P => i :: P.word4243def profileLabels {m n : ℕ} {a : Fin m → I} {b : Fin n → I} :44    EndpointSkeleton I a b → List I45  | .done _ => []46  | .first i P => i :: P.profileLabels47  | .last _ P => P.profileLabels48  | .middle _ P => P.profileLabels49  | .singleton i P => i :: P.profileLabels5051def startsMiddle {m n : ℕ} {a : Fin m → I} {b : Fin n → I} :52    EndpointSkeleton I a b → Bool53  | .middle _ _ => true54  | _ => false5556def Compressed {m n : ℕ} {a : Fin m → I} {b : Fin n → I} :57    EndpointSkeleton I a b → Prop58  | .done _ => True59  | .first _ P => P.Compressed60  | .last _ P => P.Compressed61  | .middle v P => v ≠ [] ∧ P.startsMiddle = false ∧ P.Compressed62  | .singleton _ P => P.Compressed6364/-- Prepending a middle visit merges it with the next middle block. -/65def prependMiddle {m n : ℕ} {a : Fin m → I} {b : Fin n → I}66    (p : Fin m) : EndpointSkeleton I a b → EndpointSkeleton I a b67  | .middle v P => .middle (p :: v) P68  | P => .middle [p] P6970@[simp] theorem word_prependMiddle {m n : ℕ} {a : Fin m → I} {b : Fin n → I}71    (p : Fin m) (P : EndpointSkeleton I a b) :72    (P.prependMiddle p).word = a p :: P.word := by73  cases P <;> simp [prependMiddle, word]7475@[simp] theorem profileLabels_prependMiddle {m n : ℕ} {a : Fin m → I} {b : Fin n → I}76    (p : Fin m) (P : EndpointSkeleton I a b) :77    (P.prependMiddle p).profileLabels = P.profileLabels := by78  cases P <;> rfl7980theorem compressed_prependMiddle {m n : ℕ} {a : Fin m → I} {b : Fin n → I}81    (p : Fin m) {P : EndpointSkeleton I a b} (hP : P.Compressed) :82    (P.prependMiddle p).Compressed := by83  cases P <;> simp_all [prependMiddle, Compressed, startsMiddle]8485theorem mem_range_removeNth {m : ℕ} {a : Fin (m + 1) → I}86    (ha : Function.Injective a) (p : Fin (m + 1)) (i : I) :87    i ∈ Set.range (p.removeNth a) ↔ i ∈ Set.range a ∧ i ≠ a p := by88  constructor89  · rintro ⟨q, rfl⟩90    refine ⟨⟨p.succAbove q, rfl⟩, ?_⟩91    exact fun h => Fin.succAbove_ne p q (ha h)92  · rintro ⟨⟨q, rfl⟩, hq⟩93    obtain ⟨r, hr⟩ := Fin.exists_succAbove_eq (show q ≠ p from fun h => hq (congrArg a h))94    exact ⟨r, congrArg a hr⟩9596/-- Every finite occurrence sequence admits a compressed first/last trace.97The independent profileLabels are precisely the labels not already open at the98start, each introduced once. No coefficient or norm assertion is assumed. -/99theorem exists_compressed [DecidableEq I] (l : List I) :100    ∀ {m : ℕ} (a : Fin m → I), Function.Injective a → (∀ p, a p ∈ l) →101      ∃ P : EndpointSkeleton I a (Fin.elim0 : Fin 0 → I),102        P.word = l ∧ P.Compressed ∧ P.profileLabels.Nodup ∧103          ∀ i, i ∈ P.profileLabels ↔ i ∈ l ∧ i ∉ Set.range a := by104  induction l with105  | nil =>106      intro m a ha hl107      cases m with108      | zero =>109          have he : a = (Fin.elim0 : Fin 0 → I) := Subsingleton.elim _ _110          subst a111          refine ⟨.done Fin.elim0, rfl, trivial, List.nodup_nil, ?_⟩112          simp [profileLabels]113      | succ m => simpa using hl (0 : Fin (m + 1))114  | cons i l ih =>115      intro m a ha hl116      by_cases hi : i ∈ Set.range a117      · obtain ⟨p, hp⟩ := hi118        by_cases hf : i ∈ l119        · have hl' : ∀ q, a q ∈ l := by120            intro q121            rcases List.mem_cons.mp (hl q) with hq | hq122            · exact hq ▸ hf123            · exact hq124          obtain ⟨P, hword, hcomp, hnodup, hvars⟩ := ih a ha hl'125          refine ⟨P.prependMiddle p, ?_, compressed_prependMiddle p hcomp, ?_, ?_⟩126          · simp [hword, hp]127          · simpa using hnodup128          · intro j129            rw [profileLabels_prependMiddle, hvars]130            have hi : i ∈ Set.range a := ⟨p, hp⟩131            simp only [List.mem_cons]132            by_cases he : j = i133            · subst j; simp [hi]134            · simp [he]135        · cases m with136          | zero => exact Fin.elim0 p137          | succ m =>138              have hb : Function.Injective (p.removeNth a) := ha.comp Fin.succAbove_right_injective139              have hl' : ∀ q, p.removeNth a q ∈ l := by140                intro q141                have hq := hl (p.succAbove q)142                rcases List.mem_cons.mp hq with hq | hq143                · have he : p.succAbove q = p := ha (hq.trans hp.symm)144                  exact (Fin.succAbove_ne p q he).elim145                · exact hq146              obtain ⟨P, hword, hcomp, hnodup, hvars⟩ := ih (p.removeNth a) hb hl'147              refine ⟨.last p P, ?_, hcomp, hnodup, ?_⟩148              · simp [word, hp, hword]149              · intro j150                change j ∈ P.profileLabels ↔ _151                rw [hvars, mem_range_removeNth ha p j, hp]152                simp only [List.mem_cons]153                by_cases he : j = i154                · subst j155                  simp [hf, show i ∈ Set.range a from ⟨p, hp⟩]156                · tauto157      · have hl' : ∀ q, a q ∈ l := by158          intro q159          rcases List.mem_cons.mp (hl q) with hq | hq160          · exact (hi ⟨q, hq⟩).elim161          · exact hq162        by_cases hf : i ∈ l163        · have hb : Function.Injective (Fin.cons i a) := Fin.cons_injective_of_injective hi ha164          have hlb : ∀ q : Fin (m + 1), (Fin.cons i a : Fin (m + 1) → I) q ∈ l := by165            intro q166            refine Fin.cases hf (fun r => ?_) q167            exact hl' r168          obtain ⟨P, hword, hcomp, hnodup, hvars⟩ := ih (Fin.cons i a) hb hlb169          have hnot : i ∉ P.profileLabels := by170            rw [hvars]171            simp [Fin.range_cons]172          refine ⟨.first i P, ?_, hcomp, List.nodup_cons.mpr ⟨hnot, hnodup⟩, ?_⟩173          · simp [word, hword]174          · intro j175            simp only [profileLabels, List.mem_cons, hvars, Fin.range_cons, Set.mem_insert_iff]176            by_cases he : j = i177            · subst j; simp [hi]178            · simp [he]179        · obtain ⟨P, hword, hcomp, hnodup, hvars⟩ := ih a ha hl'180          have hnot : i ∉ P.profileLabels := by rw [hvars]; simp [hf]181          refine ⟨.singleton i P, ?_, hcomp, List.nodup_cons.mpr ⟨hnot, hnodup⟩, ?_⟩182          · simp [word, hword]183          · intro j184            simp only [profileLabels, List.mem_cons, hvars]185            by_cases he : j = i186            · subst j; simp [hi]187            · simp [he]188189end EndpointSkeleton190end Nonadditivity.NoncommutativeCS