Exact Lean source
Nonadditivity.NoncommutativeCSBlocks
Download original .lean · View on GitHub · Jump to source
Direct imports
Nonadditivity.NoncommutativeCSSkeletonDecorationMathlib.Data.List.SplitLengthsdependency
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
31 project constants, including generated, internal and private declarations.
31 declarations
Nonadditivity.NoncommutativeCS.EndpointSkeleton.blockFactors_eq_reverse_mapIdxNonadditivity.NoncommutativeCS.EndpointSkeleton.blocksNonadditivity.NoncommutativeCS.EndpointSkeleton.blocks._sunfoldinternal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.blocks._unsafe_recinternal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.blocks.eq_1internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.blocks.eq_2internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.blocks.eq_3internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.blocks.eq_4internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.blocks.eq_5internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.blocks.eq_defNonadditivity.NoncommutativeCS.EndpointSkeleton.blocks.match_1internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.blocks_nonemptyNonadditivity.NoncommutativeCS.EndpointSkeleton.flatten_blocksNonadditivity.NoncommutativeCS.EndpointSkeleton.flatten_map_reversed_occurrenceBlocksNonadditivity.NoncommutativeCS.EndpointSkeleton.flatten_occurrenceBlocksNonadditivity.NoncommutativeCS.EndpointSkeleton.flatten_reversed_occurrenceBlocksNonadditivity.NoncommutativeCS.EndpointSkeleton.length_blocksNonadditivity.NoncommutativeCS.EndpointSkeleton.length_occurrenceBlocksNonadditivity.NoncommutativeCS.EndpointSkeleton.lengths_occurrenceBlocksNonadditivity.NoncommutativeCS.EndpointSkeleton.map_occurrenceBlocksNonadditivity.NoncommutativeCS.EndpointSkeleton.occurrenceBlocksNonadditivity.NoncommutativeCS.EndpointSkeleton.occurrenceBlocks.eq_1internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.occurrenceBlocks_nonempty_private.Nonadditivity.NoncommutativeCSBlocks.0.Nonadditivity.NoncommutativeCS.EndpointSkeleton.blocks.match_1.eq_1internal/detail/private_private.Nonadditivity.NoncommutativeCSBlocks.0.Nonadditivity.NoncommutativeCS.EndpointSkeleton.blocks.match_1.eq_2internal/detail/private_private.Nonadditivity.NoncommutativeCSBlocks.0.Nonadditivity.NoncommutativeCS.EndpointSkeleton.blocks.match_1.eq_3internal/detail/private_private.Nonadditivity.NoncommutativeCSBlocks.0.Nonadditivity.NoncommutativeCS.EndpointSkeleton.blocks.match_1.eq_4internal/detail/private_private.Nonadditivity.NoncommutativeCSBlocks.0.Nonadditivity.NoncommutativeCS.EndpointSkeleton.blocks.match_1.eq_5internal/detail/private_private.Nonadditivity.NoncommutativeCSBlocks.0.Nonadditivity.NoncommutativeCS.EndpointSkeleton.blocks.match_1.splitterinternal/detail/private_private.Nonadditivity.NoncommutativeCSBlocks.0.Nonadditivity.NoncommutativeCS.EndpointSkeleton.map_splitLengthsinternal/detail/private_private.Nonadditivity.NoncommutativeCSBlocks.0.Nonadditivity.NoncommutativeCS.EndpointSkeleton.splitLengths_lengths_flatteninternal/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.NoncommutativeCSSkeletonDecoration7import Mathlib.Data.List.SplitLengths89/-! # Literal blocks and occurrence lifts of endpoint skeletons1011Each compressed middle run is a single block. Splitting an actual occurrence12list by these block lengths preserves every occurrence and hence all its13orientation data, while recovering precisely the skeleton's label blocks.14-/15noncomputable section16namespace Nonadditivity.NoncommutativeCS.EndpointSkeleton17variable {I C : Type*}1819def blocks {m n : ℕ} {a : Fin m → I} {b : Fin n → I} :20EndpointSkeleton I a b → List (List I)21| .done _ => []22| .first i P => [i] :: P.blocks23| .last (a := a) p P => [a p] :: P.blocks24| .middle (a := a) visits P => visits.map a :: P.blocks25| .singleton i P => [i] :: P.blocks2627@[simp] theorem flatten_blocks {m n : ℕ} {a : Fin m → I} {b : Fin n → I}28(P : EndpointSkeleton I a b) : P.blocks.flatten=P.word := by29induction P <;> simp_all [blocks, word]3031@[simp] theorem length_blocks {m n : ℕ} {a : Fin m → I} {b : Fin n → I}32(P : EndpointSkeleton I a b) : P.blocks.length=P.markedFlags.length := by33induction P <;> simp_all [blocks, markedFlags]3435theorem blocks_nonempty {m n : ℕ} {a : Fin m → I} {b : Fin n → I}36(P : EndpointSkeleton I a b) (hP : P.Compressed) :37∀ block ∈ P.blocks, block ≠ [] := by38induction P with39| done => simp [blocks]40| first i P ih => simpa [blocks] using ih hP41| last p P ih => simpa [blocks] using ih hP42| middle visits P ih => simpa [blocks] using And.intro hP.1 (ih hP.2.2)43| singleton i P ih => simpa [blocks] using ih hP4445private theorem map_splitLengths (f : C → I) (sizes : List ℕ) (cs : List C) :46(sizes.splitLengths cs).map (List.map f)=sizes.splitLengths (cs.map f) := by47induction sizes generalizing cs with48| nil => simp49| cons n ns ih => simp [List.splitLengths_cons, ih, List.map_take, List.map_drop]5051private theorem splitLengths_lengths_flatten (ls : List (List I)) :52(ls.map List.length).splitLengths ls.flatten=ls := by53induction ls with54| nil => simp55| cons l ls ih => simp [List.splitLengths_cons, ih]5657/-- Actual occurrences split according to the skeleton, retaining their58full values rather than replacing them by label names. -/59def occurrenceBlocks {m n : ℕ} {a : Fin m → I} {b : Fin n → I}60(P : EndpointSkeleton I a b) (cs : List C) : List (List C) :=61(P.blocks.map List.length).splitLengths cs6263theorem map_occurrenceBlocks {m n : ℕ} {a : Fin m → I} {b : Fin n → I}64(P : EndpointSkeleton I a b) (label : C → I) (cs : List C)65(hcs : cs.map label=P.word) :66(P.occurrenceBlocks cs).map (List.map label)=P.blocks := by67unfold occurrenceBlocks68rw [map_splitLengths, hcs, ← P.flatten_blocks, splitLengths_lengths_flatten]6970theorem flatten_occurrenceBlocks {m n : ℕ} {a : Fin m → I} {b : Fin n → I}71(P : EndpointSkeleton I a b) (label : C → I) (cs : List C)72(hcs : cs.map label=P.word) :73(P.occurrenceBlocks cs).flatten=cs := by74apply List.flatten_splitLengths75have hlen := congrArg List.length hcs76simpa only [List.length_map, ← P.flatten_blocks, List.length_flatten] using hlen.le7778theorem lengths_occurrenceBlocks {m n : ℕ} {a : Fin m → I} {b : Fin n → I}79(P : EndpointSkeleton I a b) (label : C → I) (cs : List C)80(hcs : cs.map label=P.word) :81(P.occurrenceBlocks cs).map List.length=P.blocks.map List.length := by82have h := congrArg (List.map List.length) (P.map_occurrenceBlocks label cs hcs)83simpa only [List.map_map, List.length_map, Function.comp_def] using h8485@[simp] theorem length_occurrenceBlocks {m n : ℕ} {a : Fin m → I} {b : Fin n → I}86(P : EndpointSkeleton I a b) (cs : List C) :87(P.occurrenceBlocks cs).length=P.markedFlags.length := by88simp [occurrenceBlocks]8990theorem occurrenceBlocks_nonempty {m n : ℕ} {a : Fin m → I} {b : Fin n → I}91(P : EndpointSkeleton I a b) (hP : P.Compressed)92(label : C → I) (cs : List C) (hcs : cs.map label=P.word) :93∀ block ∈ P.occurrenceBlocks cs, block ≠ [] := by94intro block hb he95have hm : block.map label ∈ P.blocks := by96rw [← P.map_occurrenceBlocks label cs hcs]97exact List.mem_map_of_mem hb98exact P.blocks_nonempty hP _ hm (by simp [he])99100/-- Reading the compiler from right to left restores the actual original101occurrence order, including all repeated orientations. -/102theorem flatten_reversed_occurrenceBlocks {m n : ℕ} {a : Fin m → I} {b : Fin n → I}103(P : EndpointSkeleton I a b) (label : C → I) (cs : List C)104(hcs : cs.reverse.map label=P.word) :105((P.occurrenceBlocks cs.reverse).reverse.map List.reverse).flatten=cs := by106have h := congrArg List.reverse (P.flatten_occurrenceBlocks label cs.reverse hcs)107simpa only [List.reverse_flatten, List.reverse_reverse, List.map_reverse] using h108109theorem flatten_map_reversed_occurrenceBlocks {m n : ℕ} {a : Fin m → I} {b : Fin n → I}110(P : EndpointSkeleton I a b) (label : C → I) (cs : List C)111(hcs : cs.reverse.map label=P.word) :112((P.occurrenceBlocks cs.reverse).map List.reverse).reverse.flatten=cs := by113have h := congrArg List.reverse (P.flatten_occurrenceBlocks label cs.reverse hcs)114simpa only [List.reverse_flatten, List.reverse_reverse] using h115116/-- The register compiler multiplies the chronological blocks in reverse117order, with exactly their original absolute block indices. -/118theorem blockFactors_eq_reverse_mapIdx119{𝕜 E J : Type*} [RCLike 𝕜] [NormedAddCommGroup E]120[InnerProductSpace 𝕜 E] [CompleteSpace E] [Fintype J] [DecidableEq J]121{m n : ℕ} {a : Fin m → I} {b : Fin n → I}122(P : EndpointSkeleton I a b) (A : ℕ → List I → List J → E →L[𝕜] E)123(k : ℕ) (σ : I → J) :124P.blockFactors A k σ=125(P.blocks.mapIdx (fun j ls => A (k+j) ls (ls.map σ))).reverse := by126induction P generalizing k <;>127simp_all [blocks, blockFactors, List.mapIdx_cons, Nat.add_assoc,128Nat.add_left_comm, Nat.add_comm]129130end Nonadditivity.NoncommutativeCS.EndpointSkeleton