Holevo Additivity Gap in Lean 4

Lean explorer

Exact Lean source

Nonadditivity.HaarPathTreeSegment

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

Direct imports

Imported by project modules

2 direct reverse imports

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

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

53 declarations

Full module

1/-2Copyright (c) 2026 the Nonadditivity project contributors.3All rights reserved. See COPYRIGHT.md for licensing and attribution.4-/56import Nonadditivity.HaarPathTree7import Mathlib.Data.List.ChainOfFn89/-! # Actual old-tree segments are reduced routes in the decoded prefix1011Colored tree edges are uniquely determined by their unordered endpoints.12Therefore reduced colors exclude immediate reversal even after colors are13forgotten. An interval containing only old tree traversals is a literal walk14in the discovery graph at the beginning of that interval.15-/16noncomputable section17set_option maxHeartbeats 100000018namespace Nonadditivity.HaarPathGraph1920section Walk21variable {V : Type*} {T : SimpleGraph V}2223def walkOfSteps (v : ℕ → V) : (n : ℕ) →24    (∀ i, i < n → T.Adj (v i) (v (i+1))) → T.Walk (v 0) (v n)25  | 0, _ => .nil26  | n+1, h => .cons (h 0 (by omega))27      (walkOfSteps (fun i => v (i+1)) n (fun i hi => h (i+1) (by omega)))2829theorem walkOfSteps_support (v : ℕ → V) (n : ℕ)30    (h : ∀ i, i < n → T.Adj (v i) (v (i+1))) :31    (walkOfSteps v n h).support = List.ofFn (fun i : Fin (n+1) => v i.val) := by32  induction n generalizing v with33  | zero => simp [walkOfSteps]34  | succ n ih =>35    rw [walkOfSteps, SimpleGraph.Walk.support_cons, ih]36    conv_rhs => rw [List.ofFn_succ]37    rfl3839theorem walkOfSteps_edges (v : ℕ → V) (n : ℕ)40    (h : ∀ i, i < n → T.Adj (v i) (v (i+1))) :41    (walkOfSteps v n h).edges = List.ofFn (fun i : Fin n => s(v i.val, v (i.val+1))) := by42  induction n generalizing v with43  | zero => simp [walkOfSteps]44  | succ n ih =>45    rw [walkOfSteps, SimpleGraph.Walk.edges_cons, ih, List.ofFn_succ]46    rfl4748theorem walkOfSteps_reduced (v : ℕ → V) (n : ℕ)49    (h : ∀ i, i < n → T.Adj (v i) (v (i+1)))50    (hr : ∀ i, i+1 < n → s(v i, v (i+1)) ≠ s(v (i+1), v (i+2))) :51    (walkOfSteps v n h).edges.IsChain (· ≠ ·) := by52  rw [walkOfSteps_edges, List.isChain_ofFn]53  intro i hi54  exact hr i hi55end Walk5657namespace Path58variable {V : Type*} [DecidableEq V] {d m : ℕ} (P : Path V d m)5960lemma firstVisit_unoriented_injective {i j : Fin m}61    (hi : P.FirstVisit i) (hj : P.FirstVisit j)62    (h : s(P.vertex i.castSucc,P.vertex i.succ) = s(P.vertex j.castSucc,P.vertex j.succ)) :63    i=j := by64  apply Fin.ext65  by_contra hne66  rcases lt_or_gt_of_ne hne with hij | hji67  · rcases Sym2.eq_iff.mp h with ⟨hx,hy⟩ | ⟨hx,hy⟩68    · exact hj i.succ (by simp; omega) hy69    · exact hj i.castSucc (by simp; omega) hx70  · rcases Sym2.eq_iff.mp h with ⟨hx,hy⟩ | ⟨hx,hy⟩71    · exact hi j.succ (by simp; omega) hy.symm72    · exact hi j.castSucc (by simp; omega) hy.symm7374lemma edgeAt_eq_unoriented {i j : Fin m} (h : P.edgeAt i=P.edgeAt j) :75    s(P.vertex i.castSucc,P.vertex i.succ) = s(P.vertex j.castSucc,P.vertex j.succ) :=76  Sym2.eq_iff.mpr (edge_endpoints h)7778lemma tree_edge_eq_of_unoriented {i j : Fin m}79    (hi : P.edgeAt i ∈ P.treeEdges) (hj : P.edgeAt j ∈ P.treeEdges)80    (h : s(P.vertex i.castSucc,P.vertex i.succ) = s(P.vertex j.castSucc,P.vertex j.succ)) :81    P.edgeAt i=P.edgeAt j := by82  obtain ⟨k,hk,hki⟩ := Finset.mem_image.mp hi83  obtain ⟨l,hl,hlj⟩ := Finset.mem_image.mp hj84  have hkl : k=l := P.firstVisit_unoriented_injective85    ((P.mem_firstTimes k).mp hk) ((P.mem_firstTimes l).mp hl)86    ((P.edgeAt_eq_unoriented hki).trans (h.trans (P.edgeAt_eq_unoriented hlj).symm))87  exact hki.symm.trans (hkl ▸ hlj)8889lemma tree_edge_nonloop {i : Fin m} (hi : P.edgeAt i ∈ P.treeEdges) :90    P.vertex i.castSucc ≠ P.vertex i.succ := by91  obtain ⟨k,hk,hki⟩ := Finset.mem_image.mp hi92  have hn := ((P.mem_firstTimes k).mp hk) k.castSucc (show k.castSucc.val ≤ k.val from le_rfl)93  rcases edge_endpoints hki with ⟨hx,hy⟩ | ⟨hx,hy⟩94  · intro he; exact hn (hx.trans (he.trans hy.symm))95  · intro he; exact hn (hx.trans (he.symm.trans hy.symm))9697/-- Forgetting colors preserves non-backtracking on discovery-tree edges. -/98theorem tree_edges_reduced {i j : Fin m} (hij : i.val+1=j.val)99    (hi : P.edgeAt i ∈ P.treeEdges) (hj : P.edgeAt j ∈ P.treeEdges) :100    s(P.vertex i.castSucc,P.vertex i.succ) ≠ s(P.vertex j.castSucc,P.vertex j.succ) := by101  intro he102  have hc := P.tree_edge_eq_of_unoriented hi hj he103  have hs : j.castSucc=i.succ := Fin.ext (by simpa using hij.symm)104  have he' : edge (P.vertex i.castSucc) (P.colors i) (P.vertex i.succ) =105      edge (P.vertex i.succ) (P.colors j) (P.vertex j.succ) := by106    simpa only [edgeAt, hs] using hc107  exact P.reduced i j hij (edge_reverse_color (P.tree_edge_nonloop hi) he')108109/-- Every edge of an old-only interval was discovered before the interval. -/110theorem old_tree_edge_in_prefix {a b : ℕ} {i : Fin m}111    (hai : a ≤ i.val) (hib : i.val < b) (hi : P.edgeAt i ∈ P.treeEdges)112    (hold : ∀ j : Fin m, a ≤ j.val → j.val < b → ¬P.FirstVisit j) :113    (P.discoveryGraph a).Adj (P.vertex i.castSucc) (P.vertex i.succ) := by114  obtain ⟨k,hk,hki⟩ := Finset.mem_image.mp hi115  have hkf := (P.mem_firstTimes k).mp hk116  have hki' : k.val ≤ i.val := by117    by_contra h118    exact P.firstVisit_edge_not_earlier hkf (by omega) hki.symm119  have hka : k.val < a := by120    by_contra h121    exact hold k (by omega) (by omega) hkf122  refine ⟨k,hkf,hka,?_⟩123  rcases edge_endpoints hki with ⟨hx,hy⟩ | ⟨hx,hy⟩124  · exact Or.inl ⟨hx.symm,hy.symm⟩125  · exact Or.inr ⟨hy.symm,hx.symm⟩126127/-- A total notation for the actual vertex sequence, clipped only outside128the path's valid index range. All segment uses remain inside that range. -/129def vertexAt (i : ℕ) : V := P.vertex ⟨min i m,by omega⟩130131@[simp] theorem vertexAt_fin (i : Fin (m+1)) : P.vertexAt i.val=P.vertex i := by132  unfold vertexAt133  congr 1134  apply Fin.ext135  exact min_eq_left (by omega)136137lemma vertexAt_eq (i : ℕ) (hi : i ≤ m) :138    P.vertexAt i=P.vertex ⟨i,by omega⟩ := by139  unfold vertexAt140  congr 1141  apply Fin.ext142  exact min_eq_left hi143144theorem old_segment_adj (a l : ℕ) (hbound : a+l ≤ m)145    (htree : ∀ i : Fin m, a ≤ i.val → i.val < a+l → P.edgeAt i ∈ P.treeEdges)146    (hold : ∀ i : Fin m, a ≤ i.val → i.val < a+l → ¬P.FirstVisit i)147    (t : ℕ) (ht : t < l) :148    (P.discoveryGraph a).Adj (P.vertexAt (a+t)) (P.vertexAt (a+(t+1))) := by149  let i : Fin m := ⟨a+t,by omega⟩150  have ha : a ≤ i.val := by dsimp [i]; omega151  have hb : i.val < a+l := by dsimp [i]; omega152  have he₁ : P.vertexAt (a+t)=P.vertex i.castSucc := by153    rw [P.vertexAt_eq (a+t) (by omega)]; rfl154  have he₂ : P.vertexAt (a+(t+1))=P.vertex i.succ := by155    rw [P.vertexAt_eq (a+(t+1)) (by omega)]156    rfl157  rw [he₁,he₂]158  exact P.old_tree_edge_in_prefix ha hb (htree i ha hb) hold159160def oldTreeSegment (a l : ℕ) (hbound : a+l ≤ m)161    (htree : ∀ i : Fin m, a ≤ i.val → i.val < a+l → P.edgeAt i ∈ P.treeEdges)162    (hold : ∀ i : Fin m, a ≤ i.val → i.val < a+l → ¬P.FirstVisit i) :163    (P.discoveryGraph a).Walk (P.vertexAt a) (P.vertexAt (a+l)) :=164  walkOfSteps (fun t => P.vertexAt (a+t)) l (P.old_segment_adj a l hbound htree hold)165166theorem oldTreeSegment_support (a l : ℕ) (hbound : a+l ≤ m)167    (htree : ∀ i : Fin m, a ≤ i.val → i.val < a+l → P.edgeAt i ∈ P.treeEdges)168    (hold : ∀ i : Fin m, a ≤ i.val → i.val < a+l → ¬P.FirstVisit i) :169    (P.oldTreeSegment a l hbound htree hold).support =170      List.ofFn (fun t : Fin (l+1) => P.vertexAt (a+t.val)) :=171  walkOfSteps_support _ _ _172173theorem oldTreeSegment_reduced (a l : ℕ) (hbound : a+l ≤ m)174    (htree : ∀ i : Fin m, a ≤ i.val → i.val < a+l → P.edgeAt i ∈ P.treeEdges)175    (hold : ∀ i : Fin m, a ≤ i.val → i.val < a+l → ¬P.FirstVisit i) :176    (P.oldTreeSegment a l hbound htree hold).edges.IsChain (· ≠ ·) := by177  apply walkOfSteps_reduced178  intro t ht179  let i : Fin m := ⟨a+t,by omega⟩180  let j : Fin m := ⟨a+(t+1),by omega⟩181  have hi : a ≤ i.val ∧ i.val < a+l := by dsimp [i]; omega182  have hj : a ≤ j.val ∧ j.val < a+l := by dsimp [j]; omega183  have he := P.tree_edges_reduced (i := i) (j := j) (by dsimp [i,j]; omega)184    (htree i hi.1 hi.2) (htree j hj.1 hj.2)185  have hv₀ : P.vertexAt (a+t)=P.vertex i.castSucc := by186    rw [P.vertexAt_eq (a+t) (by omega)]; rfl187  have hv₁ : P.vertexAt (a+(t+1))=P.vertex i.succ := by188    rw [P.vertexAt_eq (a+(t+1)) (by omega)]189    rfl190  have hv₁' : P.vertexAt (a+(t+1))=P.vertex j.castSucc := by191    rw [P.vertexAt_eq (a+(t+1)) (by omega)]; rfl192  have hv₂ : P.vertexAt (a+(t+2))=P.vertex j.succ := by193    rw [P.vertexAt_eq (a+(t+2)) (by omega)]194    rfl195  change s(P.vertexAt (a+t),P.vertexAt (a+(t+1))) ≠196    s(P.vertexAt (a+(t+1)),P.vertexAt (a+(t+2)))197  simpa only [hv₀,hv₁,hv₂,← hv₁'] using he198199end Path200end Nonadditivity.HaarPathGraph