Exact Lean source
Nonadditivity.HaarPathClasses
Download original .lean · View on GitHub · Jump to source
Direct imports
Nonadditivity.HaarPathTreeMathlib.Logic.Equiv.Fintypedependency
Imported by project modules
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
33 project constants, including generated, internal and private declarations.
33 declarations
Nonadditivity.HaarPathClasses.IncidenceNonadditivity.HaarPathClasses.PathClassNonadditivity.HaarPathClasses.RelabeledNonadditivity.HaarPathClasses.SamePatternNonadditivity.HaarPathClasses.classPatternCodeNonadditivity.HaarPathClasses.classPatternCode._proof_1internal/detail/privateNonadditivity.HaarPathClasses.classPatternCode_injectiveNonadditivity.HaarPathClasses.exists_perm_of_kernel_eqNonadditivity.HaarPathClasses.incidenceColorNonadditivity.HaarPathClasses.incidenceIndexNonadditivity.HaarPathClasses.incidenceVertexNonadditivity.HaarPathClasses.incidenceVertex_eqNonadditivity.HaarPathClasses.instFintypePathClassOfDecidableEqNonadditivity.HaarPathClasses.pathSetoidNonadditivity.HaarPathClasses.patternCodeNonadditivity.HaarPathClasses.patternCode.eq_1internal/detail/privateNonadditivity.HaarPathClasses.patternCode_eq_iffNonadditivity.HaarPathClasses.patternCode_eq_iff._simp_1_2internal/detail/privateNonadditivity.HaarPathClasses.rangeEquivOfKernelNonadditivity.HaarPathClasses.rangeEquivOfKernel._proof_1internal/detail/privateNonadditivity.HaarPathClasses.rangeEquivOfKernel._proof_2internal/detail/privateNonadditivity.HaarPathClasses.rangeEquivOfKernel._proof_3internal/detail/privateNonadditivity.HaarPathClasses.rangeEquivOfKernel._proof_4internal/detail/privateNonadditivity.HaarPathClasses.rangeEquivOfKernel._proof_5internal/detail/privateNonadditivity.HaarPathClasses.rangeEquivOfKernel._proof_6internal/detail/privateNonadditivity.HaarPathClasses.rangeEquivOfKernel._proof_7internal/detail/privateNonadditivity.HaarPathClasses.rangeEquivOfKernel._proof_8internal/detail/privateNonadditivity.HaarPathClasses.rangeEquivOfKernel._proof_9internal/detail/privateNonadditivity.HaarPathClasses.rangeEquivOfKernel_applyNonadditivity.HaarPathClasses.relabeled_iff_samePatternNonadditivity.HaarPathClasses.relabeled_samePatternNonadditivity.HaarPathClasses.samePattern_equivalenceNonadditivity.HaarPathClasses.samePattern_relabeled
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.Logic.Equiv.Fintype89/-! # Literal vertex-and-local-color path equivalence1011BC's first path equivalence simultaneously preserves repeated vertices and12repeated colors at each vertex. Both directions of every traversal are part13of the incidence data. This file constructs the relabelling permutations14from equality patterns; they are not supplied as an assumption.15-/16noncomputable section17namespace Nonadditivity.HaarPathClasses18open HaarPathGraph HaarPathProfiles19variable {A E : Type*}2021/-- Equality of two labeling kernels gives an actual bijection of their ranges. -/22def rangeEquivOfKernel (f g : A → E)23(h : ∀ a b, f a=f b ↔ g a=g b) : Set.range f ≃ Set.range g where24toFun x := ⟨g (Classical.choose x.property),⟨_,rfl⟩⟩25invFun y := ⟨f (Classical.choose y.property),⟨_,rfl⟩⟩26left_inv x := by27apply Subtype.ext28have he := Classical.choose_spec x.property29have he' := Classical.choose_spec30(show g (Classical.choose x.property) ∈ Set.range g from ⟨_,rfl⟩)31exact ((h _ _).mpr he').trans he32right_inv y := by33apply Subtype.ext34have he := Classical.choose_spec y.property35have he' := Classical.choose_spec36(show f (Classical.choose y.property) ∈ Set.range f from ⟨_,rfl⟩)37exact ((h _ _).mp he').trans he3839theorem rangeEquivOfKernel_apply (f g : A → E)40(h : ∀ a b, f a=f b ↔ g a=g b) (a : A) :41(rangeEquivOfKernel f g h ⟨f a,⟨a,rfl⟩⟩).val=g a := by42exact (h _ _).mp (Classical.choose_spec (show f a∈Set.range f from ⟨a,rfl⟩))4344/-- For a finite label alphabet, the range bijection extends to a genuine45permutation of the whole alphabet. -/46theorem exists_perm_of_kernel_eq [Fintype E] (f g : A → E)47(h : ∀ a b, f a=f b ↔ g a=g b) :48∃ σ : Equiv.Perm E, ∀ a, σ (f a)=g a := by49classical50let e := rangeEquivOfKernel f g h51refine ⟨e.extendSubtype,fun a => ?_⟩52rw [Equiv.extendSubtype_apply_of_mem e (f a) ⟨a,rfl⟩]53exact rangeEquivOfKernel_apply f g h a5455variable {V : Type*} {d m : ℕ}5657abbrev Incidence (m : ℕ) := Fin m × Bool5859def incidenceVertex (P : Path V d m) (a : Incidence m) : V :=60if a.2 then P.vertex a.1.castSucc else P.vertex a.1.succ6162def incidenceColor (P : Path V d m) (a : Incidence m) : Color d :=63if a.2 then P.colors a.1 else flipColor (P.colors a.1)6465def incidenceIndex (a : Incidence m) : Fin (m+1) :=66if a.2 then a.1.castSucc else a.1.succ6768@[simp] theorem incidenceVertex_eq (P : Path V d m) (a : Incidence m) :69incidenceVertex P a=P.vertex (incidenceIndex a) := by70obtain ⟨i,b⟩ := a71cases b <;> rfl7273/-- The exact local-color relabelling relation on actual paths. Requiring74both incidences of each edge is BC's compatibility at its two endpoints. -/75def Relabeled (P Q : Path V d m) : Prop :=76∃ τ : Equiv.Perm V, ∃ β : V → Equiv.Perm (Color d),77(∀ j, τ (P.vertex j)=Q.vertex j) ∧78∀ a, β (incidenceVertex P a) (incidenceColor P a)=incidenceColor Q a7980/-- Finite observable equality patterns of vertices and local colors. -/81def SamePattern (P Q : Path V d m) : Prop :=82(∀ i j, P.vertex i=P.vertex j ↔ Q.vertex i=Q.vertex j) ∧83∀ a b, incidenceVertex P a=incidenceVertex P b →84(incidenceColor P a=incidenceColor P b ↔ incidenceColor Q a=incidenceColor Q b)8586theorem relabeled_samePattern {P Q : Path V d m} (h : Relabeled P Q) :87SamePattern P Q := by88obtain ⟨τ,β,hv,hc⟩ := h89constructor90· intro i j91rw [←hv i,←hv j]92exact τ.injective.eq_iff.symm93· intro a b hab94rw [←hc a,←hc b,hab]95exact (β (incidenceVertex P b)).injective.eq_iff.symm9697/-- Actual construction of all global and local permutations from patterns. -/98theorem samePattern_relabeled [Fintype V] {P Q : Path V d m}99(h : SamePattern P Q) : Relabeled P Q := by100classical101obtain ⟨τ,hτ⟩ := exists_perm_of_kernel_eq P.vertex Q.vertex h.1102have hlocal (v : V) : ∃ β : Equiv.Perm (Color d),103∀ a : {a : Incidence m // incidenceVertex P a=v},104β (incidenceColor P a.val)=incidenceColor Q a.val := by105apply exists_perm_of_kernel_eq106intro a b107exact h.2 a.val b.val (a.property.trans b.property.symm)108choose β hβ using hlocal109refine ⟨τ,β,hτ,fun a => ?_⟩110exact hβ (incidenceVertex P a) ⟨a,rfl⟩111112theorem relabeled_iff_samePattern [Fintype V] (P Q : Path V d m) :113Relabeled P Q ↔ SamePattern P Q :=114⟨relabeled_samePattern,samePattern_relabeled⟩115116/-- Coarse path equivalence is an actual equivalence relation. -/117theorem samePattern_equivalence : Equivalence (@SamePattern V d m) := by118constructor119· intro P120exact ⟨fun _ _ => Iff.rfl,fun _ _ _ => Iff.rfl⟩121· intro P Q h122refine ⟨fun i j => (h.1 i j).symm,fun a b hab => ?_⟩123have hbase : incidenceVertex P a=incidenceVertex P b := by124simp only [incidenceVertex_eq]125apply (h.1 (incidenceIndex a) (incidenceIndex b)).mpr126simpa only [incidenceVertex_eq] using hab127exact (h.2 a b hbase).symm128· intro P Q R hp hq129refine ⟨fun i j => (hp.1 i j).trans (hq.1 i j),fun a b hab => ?_⟩130have hbase : incidenceVertex Q a=incidenceVertex Q b := by131simp only [incidenceVertex_eq]132apply (hp.1 (incidenceIndex a) (incidenceIndex b)).mp133simpa only [incidenceVertex_eq] using hab134exact (hp.2 a b hab).trans (hq.2 a b hbase)135136def pathSetoid : Setoid (Path V d m) := ⟨SamePattern,samePattern_equivalence⟩137138/-- The quotient in the path counting problem, with the paper's genuine139relabeling relation characterized above. -/140abbrev PathClass (V : Type*) (d m : ℕ) := Quotient (@pathSetoid V d m)141142/-- A finite Boolean code for the entire incidence pattern. This initial143normal form is exact; its later sparse encoding uses exploration marks. -/144def patternCode [DecidableEq V] (P : Path V d m) :145((Fin (m+1) × Fin (m+1)) → Bool) × ((Incidence m × Incidence m) → Bool) :=146(fun p => decide (P.vertex p.1=P.vertex p.2),147fun p => decide (incidenceVertex P p.1=incidenceVertex P p.2 ∧148incidenceColor P p.1=incidenceColor P p.2))149150theorem patternCode_eq_iff [DecidableEq V] (P Q : Path V d m) :151patternCode P=patternCode Q ↔ SamePattern P Q := by152constructor153· intro h154have hv : ∀ i j, P.vertex i=P.vertex j ↔ Q.vertex i=Q.vertex j := by155intro i j156have he := congrFun (congrArg Prod.fst h) (i,j)157simpa only [patternCode,decide_eq_decide] using he158refine ⟨hv,fun a b hab => ?_⟩159have hab' : incidenceVertex Q a=incidenceVertex Q b := by160simp only [incidenceVertex_eq]161apply (hv (incidenceIndex a) (incidenceIndex b)).mp162simpa only [incidenceVertex_eq] using hab163have he := congrFun (congrArg Prod.snd h) (a,b)164simpa only [patternCode,hab,hab',true_and,decide_eq_decide] using he165· intro h166apply Prod.ext167· funext p168exact decide_eq_decide.mpr (h.1 p.1 p.2)169· funext p170apply decide_eq_decide.mpr171have hv : incidenceVertex P p.1=incidenceVertex P p.2 ↔172incidenceVertex Q p.1=incidenceVertex Q p.2 := by173simpa only [incidenceVertex_eq] using h.1 (incidenceIndex p.1) (incidenceIndex p.2)174constructor175· rintro ⟨hb,hc⟩176exact ⟨hv.mp hb,(h.2 p.1 p.2 hb).mp hc⟩177· rintro ⟨hb,hc⟩178exact ⟨hv.mpr hb,(h.2 p.1 p.2 (hv.mpr hb)).mpr hc⟩179180/-- An injective, actual finite representation of the path quotient. -/181def classPatternCode [DecidableEq V] (C : PathClass V d m) :=182Quotient.lift patternCode183(fun _ _ h => (patternCode_eq_iff _ _).mpr h) C184185theorem classPatternCode_injective [DecidableEq V] :186Function.Injective (@classPatternCode V d m _) := by187intro a b188induction a using Quotient.inductionOn with189| h P =>190induction b using Quotient.inductionOn with191| h Q =>192intro he193apply Quotient.sound194exact (patternCode_eq_iff P Q).mp he195196instance [DecidableEq V] : Fintype (PathClass V d m) :=197Fintype.ofInjective classPatternCode classPatternCode_injective198199end Nonadditivity.HaarPathClasses