Exact Lean source
Nonadditivity.HaarPathChains
Download original .lean · View on GitHub · Jump to source
Direct imports
Nonadditivity.HaarPathGraphMathlib.Data.List.InductiondependencyMathlib.Data.List.Chaindependency
Imported by project modules
3 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
57 project constants, including generated, internal and private declarations.
57 declarations
Nonadditivity.HaarPathGraph.Path.CoreChainNonadditivity.HaarPathGraph.Path.CoreChain.congr_simpNonadditivity.HaarPathGraph.Path.InternalChainNonadditivity.HaarPathGraph.Path.InternalChain.belowNonadditivity.HaarPathGraph.Path.InternalChain.below.casesOnNonadditivity.HaarPathGraph.Path.InternalChain.below.consNonadditivity.HaarPathGraph.Path.InternalChain.below.recNonadditivity.HaarPathGraph.Path.InternalChain.below.singleNonadditivity.HaarPathGraph.Path.InternalChain.brecOnNonadditivity.HaarPathGraph.Path.InternalChain.casesOnNonadditivity.HaarPathGraph.Path.InternalChain.consNonadditivity.HaarPathGraph.Path.InternalChain.recNonadditivity.HaarPathGraph.Path.InternalChain.recOnNonadditivity.HaarPathGraph.Path.InternalChain.singleNonadditivity.HaarPathGraph.Path.ToCoreNonadditivity.HaarPathGraph.Path.ToCore.belowNonadditivity.HaarPathGraph.Path.ToCore.below.casesOnNonadditivity.HaarPathGraph.Path.ToCore.below.consNonadditivity.HaarPathGraph.Path.ToCore.below.lastNonadditivity.HaarPathGraph.Path.ToCore.below.recNonadditivity.HaarPathGraph.Path.ToCore.brecOnNonadditivity.HaarPathGraph.Path.ToCore.casesOnNonadditivity.HaarPathGraph.Path.ToCore.consNonadditivity.HaarPathGraph.Path.ToCore.internalChainNonadditivity.HaarPathGraph.Path.ToCore.lastNonadditivity.HaarPathGraph.Path.ToCore.recNonadditivity.HaarPathGraph.Path.ToCore.recOnNonadditivity.HaarPathGraph.Path.card_coreChain_le_coreDartsNonadditivity.HaarPathGraph.Path.coreChainEncodeNonadditivity.HaarPathGraph.Path.coreChainEncode._proof_1internal/detail/privateNonadditivity.HaarPathGraph.Path.coreChainEncode._proof_2internal/detail/privateNonadditivity.HaarPathGraph.Path.coreChainEncode_injectiveNonadditivity.HaarPathGraph.Path.coreChainFintypeNonadditivity.HaarPathGraph.Path.coreChainReverseNonadditivity.HaarPathGraph.Path.coreChainReverse._proof_1internal/detail/privateNonadditivity.HaarPathGraph.Path.coreChainReverse._proof_2internal/detail/privateNonadditivity.HaarPathGraph.Path.coreChainReverse._proof_3internal/detail/privateNonadditivity.HaarPathGraph.Path.coreChainReverse._proof_4internal/detail/privateNonadditivity.HaarPathGraph.Path.coreChainReverse_involutiveNonadditivity.HaarPathGraph.Path.coreChainReverse_ne_selfNonadditivity.HaarPathGraph.Path.coreDartsNonadditivity.HaarPathGraph.Path.internalChain_appendNonadditivity.HaarPathGraph.Path.internalChain_isChainNonadditivity.HaarPathGraph.Path.internalChain_nonemptyNonadditivity.HaarPathGraph.Path.internalChain_reverseNonadditivity.HaarPathGraph.Path.internalChain_toCoreNonadditivity.HaarPathGraph.Path.next_dart_uniqueNonadditivity.HaarPathGraph.Path.reverse_memNonadditivity.HaarPathGraph.Path.reverse_mem._simp_1_1internal/detail/privateNonadditivity.HaarPathGraph.Path.reverse_mem._simp_1_2internal/detail/privateNonadditivity.HaarPathGraph.Path.toCore_head_memNonadditivity.HaarPathGraph.Path.toCore_last_coreNonadditivity.HaarPathGraph.Path.toCore_nonemptyNonadditivity.HaarPathGraph.Path.toCore_uniqueNonadditivity.HaarPathGraph.reduced_ne_reverseNonadditivity.HaarPathGraph.reverse_ne_selfNonadditivity.HaarPathGraph.reverse_reverse
Full module
1/-2Copyright (c) 2026 the Nonadditivity project contributors.3All rights reserved. See COPYRIGHT.md for licensing and attribution.4-/56import Nonadditivity.HaarPathGraph7import Mathlib.Data.List.Induction8import Mathlib.Data.List.Chain910/-! # Deterministic chains between core vertices1112A reduced chain cannot choose a branch before reaching a core vertex: at13an internal vertex of degree two the incoming dart excludes one incidence14and forces the next dart. This file formalizes that uniqueness for actual15colored graph darts, rather than assuming a chain reconstruction oracle.16-/17noncomputable section18namespace Nonadditivity.HaarPathGraph19open HaarPathProfiles20variable {V : Type*} {d m : ℕ}2122@[simp] theorem reverse_reverse (q : Dart V d) : reverse (reverse q) = q := by23simp [reverse]2425theorem reverse_ne_self (q : Dart V d) : reverse q ≠ q := by26obtain ⟨e,b⟩ := q27cases b <;> simp [reverse]2829/-- A nonempty reduced dart word cannot equal its reverse with all30orientations reversed. The middle dart or middle pair would backtrack. -/31theorem reduced_ne_reverse (l : List (Dart V d)) (hne : l ≠ [])32(hred : l.IsChain fun a b => b ≠ reverse a) : l.reverse.map reverse ≠ l := by33induction l using List.bidirectionalRecOn with34| H0 => exact (hne rfl).elim35| H1 a =>36simpa using reverse_ne_self a37| Hn a l b ih =>38intro he39have hba : reverse b=a := by40simpa using congrArg List.head? he41have hab : reverse a=b := by rw [←hba,reverse_reverse]42have he' : l.reverse.map reverse=l := by43simp only [List.reverse_cons,List.reverse_append,44List.map_append,List.map_cons,List.map_nil,45hba,hab] at he46exact List.append_cancel_right (List.cons.inj he).247by_cases hl : l=[]48· subst l49have hr : b ≠ reverse a := by simpa using hred50exact hr hab.symm51· exact ih hl hred.tail.left_of_append he'5253namespace Path54variable [DecidableEq V] (P : Path V d m)5556lemma reverse_mem {q : Dart V d} (hq : q ∈ P.darts) : reverse q ∈ P.darts := by57simpa only [darts, Finset.mem_product, Finset.mem_univ, and_true, reverse] using hq5859/-- The degree-two condition uniquely determines the continuation away from60an incoming incidence. -/61theorem next_dart_unique {a b c : Dart V d}62(ha : a ∈ P.darts) (hb : b ∈ P.darts) (hc : c ∈ P.darts)63(hcore : source a ∉ P.coreVertices)64(hab : source a=source b) (hac : source a=source c)65(hba : b ≠ a) (hca : c ≠ a) : b=c := by66have hv := P.source_mem ha67have hdeg : P.degree (source a)=2 := by68by_contra h69exact hcore (Finset.mem_filter.mpr ⟨hv,Or.inr h⟩)70let S := P.darts.filter fun q => source q=source a71have hsub : {a,b} ⊆ S := by72intro q hq73rcases Finset.mem_insert.mp hq with rfl | hq74· exact Finset.mem_filter.mpr ⟨ha,rfl⟩75· rw [Finset.mem_singleton] at hq76subst q77exact Finset.mem_filter.mpr ⟨hb,hab.symm⟩78have heq : {a,b}=S := Finset.eq_of_subset_of_card_le hsub (by79change P.degree (source a) ≤ _80simp [hdeg,Ne.symm hba])81have hcm : c ∈ ({a,b} : Finset (Dart V d)) := by82rw [heq]83exact Finset.mem_filter.mpr ⟨hc,hac.symm⟩84exact (by simpa [hca] using hcm : c=b).symm8586/-- A chain stopped on first arrival at a core vertex. Its initial vertex may87be arbitrary; the complete chains later require a core initial vertex too. -/88inductive ToCore : List (Dart V d) → Prop89| last (a : Dart V d) (ha : a ∈ P.darts)90(hcore : source (reverse a) ∈ P.coreVertices) : ToCore [a]91| cons (a b : Dart V d) (l : List (Dart V d))92(ha : a ∈ P.darts) (hcore : source (reverse a) ∉ P.coreVertices)93(hjoin : source (reverse a)=source b) (hred : b ≠ reverse a)94(htail : ToCore (b::l)) : ToCore (a::b::l)9596lemma toCore_nonempty {l : List (Dart V d)} (h : P.ToCore l) : l ≠ [] := by97cases h <;> simp9899lemma toCore_head_mem {a : Dart V d} {l : List (Dart V d)} (h : P.ToCore (a::l)) :100a ∈ P.darts := by cases h <;> assumption101102/-- Exact deterministic reconstruction from the initial dart. -/103theorem toCore_unique {l : List (Dart V d)} (h : P.ToCore l) :104∀ {l' : List (Dart V d)}, P.ToCore l' → l.head?=l'.head? → l=l' := by105induction h with106| last a ha hcore =>107intro l' h' hhead108cases h' with109| last b hb hbcore => simpa using hhead110| cons b c l hb hbcore hjoin hred htail =>111have hab : a=b := by simpa using hhead112subst b113exact (hbcore hcore).elim114| cons a b l ha hcore hjoin hred htail ih =>115intro l' h' hhead116cases h' with117| last c hc hccore =>118have hac : a=c := by simpa using hhead119subst c120exact (hcore hccore).elim121| cons c e s hc hccore hcjoin hcred hctail =>122have hac : a=c := by simpa using hhead123subst c124have hbe : b=e := P.next_dart_unique (P.reverse_mem ha)125(P.toCore_head_mem htail) (P.toCore_head_mem hctail) hcore hjoin hcjoin hred hcred126subst e127exact congrArg (List.cons a) (ih hctail rfl)128129/-- The same reduced chains before specifying their terminal vertex. -/130inductive InternalChain : List (Dart V d) → Prop131| single (a : Dart V d) (ha : a ∈ P.darts) : InternalChain [a]132| cons (a b : Dart V d) (l : List (Dart V d))133(ha : a ∈ P.darts) (hcore : source (reverse a) ∉ P.coreVertices)134(hjoin : source (reverse a)=source b) (hred : b ≠ reverse a)135(htail : InternalChain (b::l)) : InternalChain (a::b::l)136137lemma internalChain_nonempty {l : List (Dart V d)} (h : P.InternalChain l) : l ≠ [] := by138cases h <;> simp139140lemma ToCore.internalChain {l : List (Dart V d)} (h : P.ToCore l) : P.InternalChain l := by141induction h with142| last a ha hc => exact InternalChain.single a ha143| cons a b l ha hc hj hr ht ih => exact InternalChain.cons a b l ha hc hj hr ih144145lemma toCore_last_core {l : List (Dart V d)} (h : P.ToCore l) :146source (reverse (l.getLast (P.toCore_nonempty h))) ∈ P.coreVertices := by147induction h with148| last a ha hc => simpa using hc149| cons a b l ha hc hj hr ht ih => simpa using ih150151lemma internalChain_toCore {l : List (Dart V d)} (h : P.InternalChain l)152(hc : source (reverse (l.getLast (P.internalChain_nonempty h))) ∈ P.coreVertices) :153P.ToCore l := by154induction h with155| single a ha => exact ToCore.last a ha (by simpa using hc)156| cons a b l ha hcore hj hr ht ih =>157exact ToCore.cons a b l ha hcore hj hr (ih (by simpa using hc))158159/-- Appending one edge checks only the old final incidence. -/160theorem internalChain_append {l : List (Dart V d)} (h : P.InternalChain l)161(b : Dart V d) (hb : b ∈ P.darts)162(hcore : source (reverse (l.getLast (P.internalChain_nonempty h))) ∉ P.coreVertices)163(hjoin : source (reverse (l.getLast (P.internalChain_nonempty h)))=source b)164(hred : b ≠ reverse (l.getLast (P.internalChain_nonempty h))) :165P.InternalChain (l++[b]) := by166induction h with167| single a ha =>168exact InternalChain.cons a b [] ha (by simpa using hcore)169(by simpa using hjoin) (by simpa using hred) (InternalChain.single b hb)170| cons a c l ha hc hj hr ht ih =>171exact InternalChain.cons a c (l++[b]) ha hc hj hr172(ih (by simpa using hcore) (by simpa using hjoin) (by simpa using hred))173174/-- A reversed internal chain is still reduced and has the same internal175vertices. This proves reversal compatibility for actual graph chains. -/176theorem internalChain_reverse {l : List (Dart V d)} (h : P.InternalChain l) :177P.InternalChain (l.reverse.map reverse) := by178induction h with179| single a ha =>180exact InternalChain.single (reverse a) (P.reverse_mem ha)181| cons a b l ha hc hj hr ht ih =>182rw [List.reverse_cons, List.map_append, List.map_singleton]183apply P.internalChain_append ih (reverse a) (P.reverse_mem ha)184· simpa [List.getLast_map, List.getLast_reverse, reverse_reverse, ←hj] using hc185· simpa [List.getLast_map, List.getLast_reverse, reverse_reverse] using hj.symm186· simpa [List.getLast_map, List.getLast_reverse, reverse_reverse] using Ne.symm hr187188/-- Chains that both start and end at core vertices. -/189def CoreChain := {l : List (Dart V d) // P.ToCore l ∧190∃ a t, l=a::t ∧ source a ∈ P.coreVertices}191192/-- Literal incidences at core vertices. -/193def coreDarts : Finset (Dart V d) := P.darts.filter fun q => source q ∈ P.coreVertices194195/-- Encoding by the first incidence proves finiteness without assuming any196bound on the length of a chain. -/197def coreChainEncode (c : P.CoreChain) : {q // q ∈ P.coreDarts} := by198let a := c.val.head (P.toCore_nonempty c.property.1)199refine ⟨a,Finset.mem_filter.mpr ⟨?_,?_⟩⟩200· obtain ⟨b,t,he,hcore⟩ := c.property.2201simpa [a,he] using P.toCore_head_mem (he ▸ c.property.1)202· obtain ⟨b,t,he,hcore⟩ := c.property.2203simpa [a,he] using hcore204205theorem coreChainEncode_injective : Function.Injective P.coreChainEncode := by206intro c c' h207apply Subtype.ext208apply P.toCore_unique c.property.1 c'.property.1209have hh := congrArg Subtype.val h210change c.val.head (P.toCore_nonempty c.property.1) =211c'.val.head (P.toCore_nonempty c'.property.1) at hh212rw [List.head?_eq_some_head (P.toCore_nonempty c.property.1),213List.head?_eq_some_head (P.toCore_nonempty c'.property.1), hh]214215instance coreChainFintype : Fintype P.CoreChain :=216Fintype.ofInjective P.coreChainEncode P.coreChainEncode_injective217218lemma internalChain_isChain {l : List (Dart V d)} (h : P.InternalChain l) :219l.IsChain fun a b => b ≠ reverse a := by220induction h with221| single a ha => simp222| cons a b l ha hc hj hr ht ih => exact List.isChain_cons_cons.mpr ⟨hr,ih⟩223224/-- Actual reversal of a complete core chain. -/225def coreChainReverse (c : P.CoreChain) : P.CoreChain := by226let l := c.val.reverse.map reverse227have hi : P.InternalChain l := P.internalChain_reverse c.property.1.internalChain228have hstart : source (c.val.head (P.toCore_nonempty c.property.1)) ∈ P.coreVertices := by229obtain ⟨a,t,he,hc⟩ := c.property.2230simpa [he] using hc231have ht : P.ToCore l := P.internalChain_toCore hi (by232simpa [l,List.getLast_map,List.getLast_reverse] using hstart)233refine ⟨l,ht,⟨l.head (P.toCore_nonempty ht),l.tail,234(List.cons_head_tail (P.toCore_nonempty ht)).symm,?_⟩⟩235simpa [l,List.head_map,List.head_reverse] using P.toCore_last_core c.property.1236237@[simp] theorem coreChainReverse_involutive (c : P.CoreChain) :238P.coreChainReverse (P.coreChainReverse c)=c := by239apply Subtype.ext240change (c.val.reverse.map reverse).reverse.map reverse=c.val241simp [List.map_reverse,List.map_map,Function.comp_def]242243theorem coreChainReverse_ne_self (c : P.CoreChain) : P.coreChainReverse c ≠ c := by244intro h245have he := congrArg Subtype.val h246exact reduced_ne_reverse c.val (P.toCore_nonempty c.property.1)247(P.internalChain_isChain c.property.1.internalChain) he248249/-- Every actual chain has a different initial core incidence. -/250theorem card_coreChain_le_coreDarts : Fintype.card P.CoreChain ≤ P.coreDarts.card := by251simpa using Fintype.card_le_of_injective P.coreChainEncode P.coreChainEncode_injective252253end Path254end Nonadditivity.HaarPathGraph