Exact Lean source
Nonadditivity.HaarPathTreeSegment
Download original .lean · View on GitHub · Jump to source
Direct imports
Nonadditivity.HaarPathTreeMathlib.Data.List.ChainOfFndependency
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
Nonadditivity.HaarPathGraph.Path.edgeAt_eq_unorientedNonadditivity.HaarPathGraph.Path.firstVisit_unoriented_injectiveNonadditivity.HaarPathGraph.Path.firstVisit_unoriented_injective._proof_1_1internal/detail/privateNonadditivity.HaarPathGraph.Path.firstVisit_unoriented_injective._proof_1_2internal/detail/privateNonadditivity.HaarPathGraph.Path.oldTreeSegmentNonadditivity.HaarPathGraph.Path.oldTreeSegment_reducedNonadditivity.HaarPathGraph.Path.oldTreeSegment_reduced._proof_1_1internal/detail/privateNonadditivity.HaarPathGraph.Path.oldTreeSegment_reduced._proof_1_2internal/detail/privateNonadditivity.HaarPathGraph.Path.oldTreeSegment_reduced._proof_1_3internal/detail/privateNonadditivity.HaarPathGraph.Path.oldTreeSegment_reduced._proof_1_4internal/detail/privateNonadditivity.HaarPathGraph.Path.oldTreeSegment_reduced._proof_1_5internal/detail/privateNonadditivity.HaarPathGraph.Path.oldTreeSegment_reduced._proof_1_6internal/detail/privateNonadditivity.HaarPathGraph.Path.oldTreeSegment_reduced._proof_1_7internal/detail/privateNonadditivity.HaarPathGraph.Path.oldTreeSegment_reduced._proof_1_8internal/detail/privateNonadditivity.HaarPathGraph.Path.oldTreeSegment_supportNonadditivity.HaarPathGraph.Path.old_segment_adjNonadditivity.HaarPathGraph.Path.old_segment_adj._proof_1_1internal/detail/privateNonadditivity.HaarPathGraph.Path.old_segment_adj._proof_1_2internal/detail/privateNonadditivity.HaarPathGraph.Path.old_segment_adj._proof_1_3internal/detail/privateNonadditivity.HaarPathGraph.Path.old_segment_adj._proof_1_4internal/detail/privateNonadditivity.HaarPathGraph.Path.old_segment_adj._proof_1_5internal/detail/privateNonadditivity.HaarPathGraph.Path.old_tree_edge_in_prefixNonadditivity.HaarPathGraph.Path.old_tree_edge_in_prefix._proof_1_1internal/detail/privateNonadditivity.HaarPathGraph.Path.old_tree_edge_in_prefix._proof_1_2internal/detail/privateNonadditivity.HaarPathGraph.Path.old_tree_edge_in_prefix._proof_1_3internal/detail/privateNonadditivity.HaarPathGraph.Path.tree_edge_eq_of_unorientedNonadditivity.HaarPathGraph.Path.tree_edge_nonloopNonadditivity.HaarPathGraph.Path.tree_edges_reducedNonadditivity.HaarPathGraph.Path.vertexAtNonadditivity.HaarPathGraph.Path.vertexAt._proof_1internal/detail/privateNonadditivity.HaarPathGraph.Path.vertexAt._proof_2internal/detail/privateNonadditivity.HaarPathGraph.Path.vertexAt_eqNonadditivity.HaarPathGraph.Path.vertexAt_eq._proof_1internal/detail/privateNonadditivity.HaarPathGraph.Path.vertexAt_finNonadditivity.HaarPathGraph.Path.vertexAt_fin._proof_1_1internal/detail/privateNonadditivity.HaarPathGraph.walkOfStepsNonadditivity.HaarPathGraph.walkOfSteps._proof_1internal/detail/privateNonadditivity.HaarPathGraph.walkOfSteps._proof_2internal/detail/privateNonadditivity.HaarPathGraph.walkOfSteps._proof_3internal/detail/privateNonadditivity.HaarPathGraph.walkOfSteps._proof_4internal/detail/privateNonadditivity.HaarPathGraph.walkOfSteps._sunfoldinternal/detail/privateNonadditivity.HaarPathGraph.walkOfSteps._unsafe_recinternal/detail/privateNonadditivity.HaarPathGraph.walkOfSteps.congr_simpNonadditivity.HaarPathGraph.walkOfSteps.eq_1internal/detail/privateNonadditivity.HaarPathGraph.walkOfSteps.eq_2internal/detail/privateNonadditivity.HaarPathGraph.walkOfSteps.eq_defNonadditivity.HaarPathGraph.walkOfSteps.match_1internal/detail/privateNonadditivity.HaarPathGraph.walkOfSteps_edgesNonadditivity.HaarPathGraph.walkOfSteps_reducedNonadditivity.HaarPathGraph.walkOfSteps_support_private.Nonadditivity.HaarPathTreeSegment.0.Nonadditivity.HaarPathGraph.walkOfSteps.match_1.eq_1internal/detail/private_private.Nonadditivity.HaarPathTreeSegment.0.Nonadditivity.HaarPathGraph.walkOfSteps.match_1.eq_2internal/detail/private_private.Nonadditivity.HaarPathTreeSegment.0.Nonadditivity.HaarPathGraph.walkOfSteps.match_1.splitterinternal/detail/private
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) := by32induction n generalizing v with33| zero => simp [walkOfSteps]34| succ n ih =>35rw [walkOfSteps, SimpleGraph.Walk.support_cons, ih]36conv_rhs => rw [List.ofFn_succ]37rfl3839theorem 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))) := by42induction n generalizing v with43| zero => simp [walkOfSteps]44| succ n ih =>45rw [walkOfSteps, SimpleGraph.Walk.edges_cons, ih, List.ofFn_succ]46rfl4748theorem 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 (· ≠ ·) := by52rw [walkOfSteps_edges, List.isChain_ofFn]53intro i hi54exact 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)) :63i=j := by64apply Fin.ext65by_contra hne66rcases 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) :75s(P.vertex i.castSucc,P.vertex i.succ) = s(P.vertex j.castSucc,P.vertex j.succ) :=76Sym2.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)) :81P.edgeAt i=P.edgeAt j := by82obtain ⟨k,hk,hki⟩ := Finset.mem_image.mp hi83obtain ⟨l,hl,hlj⟩ := Finset.mem_image.mp hj84have 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))87exact hki.symm.trans (hkl ▸ hlj)8889lemma tree_edge_nonloop {i : Fin m} (hi : P.edgeAt i ∈ P.treeEdges) :90P.vertex i.castSucc ≠ P.vertex i.succ := by91obtain ⟨k,hk,hki⟩ := Finset.mem_image.mp hi92have hn := ((P.mem_firstTimes k).mp hk) k.castSucc (show k.castSucc.val ≤ k.val from le_rfl)93rcases 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) :100s(P.vertex i.castSucc,P.vertex i.succ) ≠ s(P.vertex j.castSucc,P.vertex j.succ) := by101intro he102have hc := P.tree_edge_eq_of_unoriented hi hj he103have hs : j.castSucc=i.succ := Fin.ext (by simpa using hij.symm)104have he' : edge (P.vertex i.castSucc) (P.colors i) (P.vertex i.succ) =105edge (P.vertex i.succ) (P.colors j) (P.vertex j.succ) := by106simpa only [edgeAt, hs] using hc107exact 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) := by114obtain ⟨k,hk,hki⟩ := Finset.mem_image.mp hi115have hkf := (P.mem_firstTimes k).mp hk116have hki' : k.val ≤ i.val := by117by_contra h118exact P.firstVisit_edge_not_earlier hkf (by omega) hki.symm119have hka : k.val < a := by120by_contra h121exact hold k (by omega) (by omega) hkf122refine ⟨k,hkf,hka,?_⟩123rcases 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 := by132unfold vertexAt133congr 1134apply Fin.ext135exact min_eq_left (by omega)136137lemma vertexAt_eq (i : ℕ) (hi : i ≤ m) :138P.vertexAt i=P.vertex ⟨i,by omega⟩ := by139unfold vertexAt140congr 1141apply Fin.ext142exact 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))) := by149let i : Fin m := ⟨a+t,by omega⟩150have ha : a ≤ i.val := by dsimp [i]; omega151have hb : i.val < a+l := by dsimp [i]; omega152have he₁ : P.vertexAt (a+t)=P.vertex i.castSucc := by153rw [P.vertexAt_eq (a+t) (by omega)]; rfl154have he₂ : P.vertexAt (a+(t+1))=P.vertex i.succ := by155rw [P.vertexAt_eq (a+(t+1)) (by omega)]156rfl157rw [he₁,he₂]158exact 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)) :=164walkOfSteps (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 =170List.ofFn (fun t : Fin (l+1) => P.vertexAt (a+t.val)) :=171walkOfSteps_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 (· ≠ ·) := by177apply walkOfSteps_reduced178intro t ht179let i : Fin m := ⟨a+t,by omega⟩180let j : Fin m := ⟨a+(t+1),by omega⟩181have hi : a ≤ i.val ∧ i.val < a+l := by dsimp [i]; omega182have hj : a ≤ j.val ∧ j.val < a+l := by dsimp [j]; omega183have 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)185have hv₀ : P.vertexAt (a+t)=P.vertex i.castSucc := by186rw [P.vertexAt_eq (a+t) (by omega)]; rfl187have hv₁ : P.vertexAt (a+(t+1))=P.vertex i.succ := by188rw [P.vertexAt_eq (a+(t+1)) (by omega)]189rfl190have hv₁' : P.vertexAt (a+(t+1))=P.vertex j.castSucc := by191rw [P.vertexAt_eq (a+(t+1)) (by omega)]; rfl192have hv₂ : P.vertexAt (a+(t+2))=P.vertex j.succ := by193rw [P.vertexAt_eq (a+(t+2)) (by omega)]194rfl195change s(P.vertexAt (a+t),P.vertexAt (a+(t+1))) ≠196s(P.vertexAt (a+(t+1)),P.vertexAt (a+(t+2)))197simpa only [hv₀,hv₁,hv₂,← hv₁'] using he198199end Path200end Nonadditivity.HaarPathGraph