Exact Lean source
Nonadditivity.HaarPaletteDecoder
Download original .lean · View on GitHub · Jump to source
Direct imports
Nonadditivity.HaarChainColoringPalettesNonadditivity.HaarProfileAssignmentBoundMathlib.Data.List.GetDdependency
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
22 project constants, including generated, internal and private declarations.
22 declarations
Nonadditivity.HaarPaletteDecoder.blockDirectionsNonadditivity.HaarPaletteDecoder.blockDirections.eq_1internal/detail/privateNonadditivity.HaarPaletteDecoder.blockDirections.match_1internal/detail/privateNonadditivity.HaarPaletteDecoder.blockDirections_getNonadditivity.HaarPaletteDecoder.chainEmbedNonadditivity.HaarPaletteDecoder.chainEmbed._proof_1internal/detail/privateNonadditivity.HaarPaletteDecoder.chainEmbed.eq_1internal/detail/privateNonadditivity.HaarPaletteDecoder.chainForwardNonadditivity.HaarPaletteDecoder.chainForward.eq_1internal/detail/privateNonadditivity.HaarPaletteDecoder.decodeNonadditivity.HaarPaletteDecoder.decode.eq_1internal/detail/privateNonadditivity.HaarPaletteDecoder.decode_actual_blockNonadditivity.HaarPaletteDecoder.decode_chain_blockNonadditivity.HaarPaletteDecoder.decode_embedAssignmentNonadditivity.HaarPaletteDecoder.decode_singletonNonadditivity.HaarPaletteDecoder.forwardNonadditivity.HaarPaletteDecoder.orientedPaletteNonadditivity.HaarPaletteDecoder.orientedPalette_chainEmbedNonadditivity.HaarPaletteDecoder.orientedPalette_embedWordsNonadditivity.HaarPaletteDecoder.paletteGroupWordNonadditivity.HaarPaletteDecoder.paletteGroupWord_embedWordsNonadditivity.HaarProfileCoefficient.orientedWord.eq_1internal/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.HaarChainColoringPalettes7import Nonadditivity.HaarProfileAssignmentBound8import Mathlib.Data.List.GetD910/-! # Literal block decoding of the common word palette1112Each block reads its chosen profile words in its actual orientations. The13decoder reverses the block order to match the coefficient-factor convention.14Its singleton restriction agrees exactly with the padded endpoint families.15-/16noncomputable section17set_option backward.isDefEq.respectTransparency false18set_option maxHeartbeats 100000019namespace Nonadditivity.HaarPaletteDecoder20open HaarPathGraph HaarPathProfiles HaarProfileCoefficient HaarProfilePadding21HaarProfileAssignmentBound2223def paletteGroupWord {d M : ℕ} (w : Palette d M) : FreeGroup (Fin d) :=24FreeGroup.mk (List.ofFn w.2)2526@[simp] theorem paletteGroupWord_embedWords {d k M : ℕ} {p : Profile (Color d)}27(hk : k≤M) (w : Words d k p) : paletteGroupWord (embedWords hk w)=word w := rfl2829def orientedPalette {d M : ℕ} (forward : Bool) (w : Palette d M) : FreeGroup (Fin d) :=30if forward then paletteGroupWord w else (paletteGroupWord w)⁻¹3132@[simp] theorem orientedPalette_embedWords {d k M : ℕ} {p : Profile (Color d)}33(hk : k≤M) (forward : Bool) (w : Words d k p) :34orientedPalette forward (embedWords hk w)=orientedWord forward w := rfl3536def decode {I : Type*} {d M : ℕ} (directions : ℕ → ℕ → Bool)37(k : ℕ) (_labels : List I) (choices : List (Palette d M)) : FreeGroup (Fin d) :=38((choices.mapIdx (fun j w => orientedPalette (directions k j) w)).reverse).prod3940def forward {I : Type*} (directions : ℕ → ℕ → Bool) (k : ℕ) (_i : I) : Bool :=41directions k 04243@[simp] theorem decode_singleton {I : Type*} {d n M : ℕ} {p : Profile (Color d)}44(directions : ℕ → ℕ → Bool) (k : ℕ) (i : I) (hn : n≤M) (w : Words d n p) :45decode directions k [i] [embedWords hn w]=orientedWord (directions k 0) w := by46simp [decode]4748theorem decode_embedAssignment {I : Type*} {d M : ℕ}49(directions : ℕ → ℕ → Bool) (size : I → ℕ) (profile : I → Profile (Color d))50(hsize : ∀ i, size i≤M) (σ : ∀ i, Words d (size i) (profile i)) (k : ℕ) (i : I) :51decode directions k [i] [embedAssignment size profile hsize σ i]=52orientedWord (forward directions k i) (σ i) := by53exact decode_singleton directions k i (hsize i) (σ i)5455variable {V : Type*} [DecidableEq V] {d m : ℕ} (P : Path V d m)5657def chainForward (c : P.CoreChain) : Bool := decide (c=P.representative (P.chainLabel c))5859def chainEmbed (σ : P.ChainPalette) (e : P.unorientedChains) : Palette d m :=60embedWords (P.coreChain_length_le (P.representative e)) (σ e)6162theorem orientedPalette_chainEmbed (σ : P.ChainPalette) (c : P.CoreChain) :63orientedPalette (chainForward P c) (chainEmbed P σ (P.chainLabel c))=64word (P.paletteWord σ c) := by65rw [P.paletteWord_word]66simp only [chainEmbed,orientedPalette_embedWords,orientedWord,chainForward,decide_eq_true_eq]6768/-- Exact decoding of one actual core-chain block, including repeated labels69and arbitrary mixtures of the two orientations. -/70theorem decode_chain_block (σ : P.ChainPalette) (directions : ℕ → ℕ → Bool)71(k : ℕ) (cs : List P.CoreChain)72(hdir : ∀ j (hj : j<cs.length), directions k j=chainForward P cs[j]) :73decode directions k (cs.map P.chainLabel)74(cs.map (fun c => chainEmbed P σ (P.chainLabel c))) =75(cs.reverse.map (fun c => word (P.paletteWord σ c))).prod := by76have he : (cs.map (fun c => chainEmbed P σ (P.chainLabel c))).mapIdx77(fun j w => orientedPalette (directions k j) w) =78cs.map (fun c => word (P.paletteWord σ c)) := by79apply List.ext_getElem80· simp81· intro j hj hk82have hj' : j<cs.length := by simpa using hj83simp only [List.getElem_mapIdx,List.getElem_map]84rw [hdir j hj',orientedPalette_chainEmbed P]85unfold decode86rw [he,List.map_reverse]8788/-- Directions are read from the literal occurrence blocks. Out-of-range89entries are irrelevant to decoding and receive a fixed default. -/90def blockDirections (blocks : List (List P.CoreChain)) (k j : ℕ) : Bool :=91match (blocks.getD k [])[j]? with92| some c => chainForward P c93| none => true9495theorem blockDirections_get (blocks : List (List P.CoreChain)) (k : ℕ)96(hk : k<blocks.length) (j : ℕ) (hj : j<blocks[k].length) :97blockDirections P blocks k j=chainForward P blocks[k][j] := by98simp only [blockDirections,List.getD_eq_getElem blocks [] hk,List.getElem?_eq_getElem hj]99100theorem decode_actual_block (σ : P.ChainPalette) (blocks : List (List P.CoreChain))101(k : ℕ) (hk : k<blocks.length) :102decode (blockDirections P blocks) k (blocks[k].map P.chainLabel)103(blocks[k].map (fun c => chainEmbed P σ (P.chainLabel c))) =104(blocks[k].reverse.map (fun c => word (P.paletteWord σ c))).prod :=105decode_chain_block P σ _ _ _ (blockDirections_get P blocks k hk)106107end Nonadditivity.HaarPaletteDecoder