Exact Lean source
Nonadditivity.HaarPathColorMarks
Download original .lean · View on GitHub · Jump to source
Direct imports
Imported by project modules
1 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
19 project constants, including generated, internal and private declarations.
19 declarations
Nonadditivity.HaarPathClasses.incidenceOrderNonadditivity.HaarPathClasses.incidenceRankNonadditivity.HaarPathClasses.incidenceRank.eq_1internal/detail/privateNonadditivity.HaarPathClasses.incidenceRank_injectiveNonadditivity.HaarPathClasses.incidenceRank_injective._proof_1_2internal/detail/privateNonadditivity.HaarPathClasses.incidenceRank_injective._proof_1_3internal/detail/privateNonadditivity.HaarPathClasses.matchingIncidencesNonadditivity.HaarPathClasses.matchingIncidences.congr_simpNonadditivity.HaarPathClasses.matchingIncidences.eq_1internal/detail/privateNonadditivity.HaarPathClasses.mem_matchingIncidencesNonadditivity.HaarPathClasses.mem_matchingIncidences._simp_1internal/detail/privateNonadditivity.HaarPathClasses.outgoingCodeNonadditivity.HaarPathClasses.outgoingCode.eq_1internal/detail/privateNonadditivity.HaarPathClasses.outgoingCode_alphabet_cardNonadditivity.HaarPathClasses.outgoingCode_none_iffNonadditivity.HaarPathClasses.outgoingCode_some_leNonadditivity.HaarPathClasses.outgoingCode_some_memNonadditivity.HaarPathClasses.outgoingMark_of_code_eqNonadditivity.HaarPathClasses.prefixSamePattern_extend_code
Full module
1/-2Copyright (c) 2026 the Nonadditivity project contributors.3All rights reserved. See COPYRIGHT.md for licensing and attribution.4-/56import Nonadditivity.HaarPathFreshRuns78/-! # Literal finite marks for outgoing color classes910An outgoing color is encoded by its least matching prior incidence, or by a11fresh-color sentinel. Equality of these concrete finite codes reconstructs12the full outgoing-color equality pattern. The honest alphabet has `2m+1`13members; no smaller cardinality is assumed.14-/1516noncomputable section17namespace Nonadditivity.HaarPathClasses18open HaarPathGraph HaarPathProfiles1920variable {V : Type*} [DecidableEq V] {d m : ℕ}2122def incidenceRank (a : Incidence m) : ℕ := 2*a.1.val + if a.2 then 1 else 02324theorem incidenceRank_injective : Function.Injective (@incidenceRank m) := by25rintro ⟨a,ab⟩ ⟨b,bb⟩ he26cases ab <;> cases bb <;> simp [incidenceRank] at he27· have h : a=b := Fin.ext (by omega)28simp [h]29· omega30· omega31· have h : a=b := Fin.ext (by omega)32simp [h]3334local instance incidenceOrder : LinearOrder (Incidence m) :=35LinearOrder.lift' incidenceRank incidenceRank_injective3637/-- Previous incidences at this vertex carrying the new outgoing color. -/38def matchingIncidences (P : Path V d m) (i : Fin m) : Finset (Incidence m) :=39Finset.univ.filter fun a => a.1.val < i.val ∧40incidenceVertex P a=P.vertex i.castSucc ∧ incidenceColor P a=P.colors i4142@[simp] theorem mem_matchingIncidences (P : Path V d m) (i : Fin m) (a : Incidence m) :43a ∈ matchingIncidences P i ↔ a.1.val < i.val ∧44incidenceVertex P a=P.vertex i.castSucc ∧ incidenceColor P a=P.colors i := by45simp [matchingIncidences]4647/-- The least previous matching incidence, with `none` for a new color. -/48def outgoingCode (P : Path V d m) (i : Fin m) : Option (Incidence m) :=49if h : (matchingIncidences P i).Nonempty then50some ((matchingIncidences P i).min' h) else none5152theorem outgoingCode_some_mem (P : Path V d m) (i : Fin m) (a : Incidence m)53(h : outgoingCode P i=some a) : a ∈ matchingIncidences P i := by54unfold outgoingCode at h55split_ifs at h with hn56· have he := Option.some.inj h57rw [←he]58exact Finset.min'_mem _ _5960theorem outgoingCode_none_iff (P : Path V d m) (i : Fin m) :61outgoingCode P i=none ↔ matchingIncidences P i=∅ := by62unfold outgoingCode63split_ifs with hn64· simp [hn.ne_empty]65· simp [Finset.not_nonempty_iff_eq_empty.mp hn]6667theorem outgoingCode_some_le (P : Path V d m) (i : Fin m) (a b : Incidence m)68(ha : outgoingCode P i=some a) (hb : b∈matchingIncidences P i) :69incidenceRank a ≤ incidenceRank b := by70have hn : (matchingIncidences P i).Nonempty := ⟨b,hb⟩71have he : (matchingIncidences P i).min' hn=a := by72simpa [outgoingCode, hn] using ha73rw [←he]74exact Finset.min'_le _ _ hb7576/-- This is an explicit bound for the actual mark type. -/77theorem outgoingCode_alphabet_card : Fintype.card (Option (Incidence m))=2*m+1 := by78simp [Nat.mul_comm]7980/-- Equality of finite marks recovers every outgoing-color comparison. -/81theorem outgoingMark_of_code_eq (P Q : Path V d m) (i : Fin m)82(hp : PrefixSamePattern P Q i.val) (hc : outgoingCode P i=outgoingCode Q i) :83OutgoingMark P Q i := by84intro a ha hv85cases hcode : outgoingCode P i with86| none =>87have heP := (outgoingCode_none_iff P i).mp hcode88have heQ := (outgoingCode_none_iff Q i).mp (hc.symm.trans hcode)89have hvQ : incidenceVertex Q a=Q.vertex i.castSucc := by90rw [incidenceVertex_eq]91apply (hp.1 (incidenceIndex a) i.castSucc92(incidenceIndex_le_of_before a ha) (by simp)).mp93simpa only [incidenceVertex_eq] using hv94apply iff_of_false95· intro he96have hmem := (mem_matchingIncidences P i a).mpr ⟨ha,hv,he⟩97simp [heP] at hmem98· intro he99have hmem := (mem_matchingIncidences Q i a).mpr ⟨ha,hvQ,he⟩100simp [heQ] at hmem101| some b =>102have hbP := (mem_matchingIncidences P i b).mp (outgoingCode_some_mem P i b hcode)103have hbQ := (mem_matchingIncidences Q i b).mp104(outgoingCode_some_mem Q i b (hc.symm.trans hcode))105have he := hp.2 a b ha hbP.1 (hv.trans hbP.2.1.symm)106simpa only [hbP.2.2,hbQ.2.2] using he107108/-- A concrete finite color mark suffices to extend a fresh path prefix. -/109theorem prefixSamePattern_extend_code (P Q : Path V d m) (i : Fin m)110(hp : PrefixSamePattern P Q i.val) (hP : P.FirstVisit i) (hQ : Q.FirstVisit i)111(hc : outgoingCode P i=outgoingCode Q i) : PrefixSamePattern P Q (i.val+1) :=112prefixSamePattern_extend_firstVisit P Q i hp hP hQ (outgoingMark_of_code_eq P Q i hp hc)113114end Nonadditivity.HaarPathClasses