Exact Lean source
Nonadditivity.NoncommutativeCSSkeletonDecoration
Download original .lean · View on GitHub · Jump to source
Direct imports
Nonadditivity.NoncommutativeCSEndpointSkeletonMathlib.Data.List.FinRangedependency
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
59 project constants, including generated, internal and private declarations.
59 declarations
Nonadditivity.NoncommutativeCS.EndpointSkeleton.blockFactorsNonadditivity.NoncommutativeCS.EndpointSkeleton.blockFactors._sunfoldinternal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.blockFactors._unsafe_recinternal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.blockFactors.eq_1internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.blockFactors.eq_2internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.blockFactors.eq_3internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.blockFactors.eq_4internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.blockFactors.eq_5internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.blockFactors.eq_defNonadditivity.NoncommutativeCS.EndpointSkeleton.block_sum_norm_leNonadditivity.NoncommutativeCS.EndpointSkeleton.coefficient_exponent_leNonadditivity.NoncommutativeCS.EndpointSkeleton.coefficient_exponent_le._proof_1_1internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.compressed_length_leNonadditivity.NoncommutativeCS.EndpointSkeleton.compressed_length_le._proof_1_10internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.compressed_length_le._proof_1_11internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.compressed_length_le._proof_1_12internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.compressed_length_le._proof_1_13internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.compressed_length_le._proof_1_8internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.compressed_length_le._proof_1_9internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.coversLabels_of_profileLabelsNonadditivity.NoncommutativeCS.EndpointSkeleton.decorateNonadditivity.NoncommutativeCS.EndpointSkeleton.decorate._sunfoldinternal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.decorate._unsafe_recinternal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.decorate.eq_1internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.decorate.eq_2internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.decorate.eq_3internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.decorate.eq_4internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.decorate.eq_5internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.decorate.eq_defNonadditivity.NoncommutativeCS.EndpointSkeleton.decorate.match_1internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.decorate_factorsNonadditivity.NoncommutativeCS.EndpointSkeleton.decorate_labelsNonadditivity.NoncommutativeCS.EndpointSkeleton.decorate_markedFlagsNonadditivity.NoncommutativeCS.EndpointSkeleton.exists_closed_compilerNonadditivity.NoncommutativeCS.EndpointSkeleton.markedFlagsNonadditivity.NoncommutativeCS.EndpointSkeleton.markedFlags._sunfoldinternal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.markedFlags._unsafe_recinternal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.markedFlags.eq_1internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.markedFlags.eq_2internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.markedFlags.eq_3internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.markedFlags.eq_4internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.markedFlags.eq_5internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.markedFlags.eq_defNonadditivity.NoncommutativeCS.EndpointSkeleton.marked_count_boundaryNonadditivity.NoncommutativeCS.EndpointSkeleton.marked_count_boundary._proof_1_7internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.marked_count_boundary._proof_1_8internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.marked_count_boundary._proof_1_9internal/detail/privateNonadditivity.NoncommutativeCS.EndpointSkeleton.profileLabels_length_eq_cardNonadditivity.NoncommutativeCS.EndpointSkeleton.startsMiddle_false_of_empty_private.Nonadditivity.NoncommutativeCSSkeletonDecoration.0.Nonadditivity.NoncommutativeCS.EndpointSkeleton.decorate.match_1.eq_1internal/detail/private_private.Nonadditivity.NoncommutativeCSSkeletonDecoration.0.Nonadditivity.NoncommutativeCS.EndpointSkeleton.decorate.match_1.eq_2internal/detail/private_private.Nonadditivity.NoncommutativeCSSkeletonDecoration.0.Nonadditivity.NoncommutativeCS.EndpointSkeleton.decorate.match_1.eq_3internal/detail/private_private.Nonadditivity.NoncommutativeCSSkeletonDecoration.0.Nonadditivity.NoncommutativeCS.EndpointSkeleton.decorate.match_1.eq_4internal/detail/private_private.Nonadditivity.NoncommutativeCSSkeletonDecoration.0.Nonadditivity.NoncommutativeCS.EndpointSkeleton.decorate.match_1.eq_5internal/detail/private_private.Nonadditivity.NoncommutativeCSSkeletonDecoration.0.Nonadditivity.NoncommutativeCS.EndpointSkeleton.decorate.match_1.splitterinternal/detail/private_private.Nonadditivity.NoncommutativeCSSkeletonDecoration.0.Nonadditivity.NoncommutativeCS.EndpointSkeleton.startsMiddle.match_1.eq_1internal/detail/private_private.Nonadditivity.NoncommutativeCSSkeletonDecoration.0.Nonadditivity.NoncommutativeCS.EndpointSkeleton.startsMiddle.match_1.eq_2internal/detail/private_private.Nonadditivity.NoncommutativeCSSkeletonDecoration.0.Nonadditivity.NoncommutativeCS.EndpointSkeleton.startsMiddle.match_1.splitterinternal/detail/private_private.Nonadditivity.NoncommutativeCSSkeletonDecoration.0.Nonadditivity.NoncommutativeCS.EndpointSkeleton.startsMiddle.match_1.splitter._sparseCasesOn_2internal/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.NoncommutativeCSEndpointSkeleton7import Mathlib.Data.List.FinRange89/-! # Whole-block coefficient decoration and global sum bound1011A middle block is decorated by one arbitrary coefficient operator depending12on its whole list of profile choices. No product decomposition of that13operator is required. The preceding compiler supplies all endpoint bookkeeping.14-/1516noncomputable section17set_option backward.isDefEq.respectTransparency false18set_option linter.unusedSectionVars false19namespace Nonadditivity.NoncommutativeCS.EndpointSkeleton20open scoped BigOperators InnerProduct2122variable {𝕜 E I J : Type*} [RCLike 𝕜]23variable [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [CompleteSpace E]24variable [Fintype J] [DecidableEq J]2526def decorate {m n : ℕ} {a : Fin m → I} {b : Fin n → I}27(P : EndpointSkeleton I a b) (A : ℕ → List I → List J → E →L[𝕜] E)28(k : ℕ) : EndpointTrace 𝕜 E I J a b :=29match P with30| .done a => .done a31| .first i P => .first i (fun j => A k [i] [j]) (P.decorate A (k + 1))32| .last (a := a) p P => .last p (fun j => A k [a p] [j]) (P.decorate A (k + 1))33| .middle (a := a) v P =>34.middle (fun s => A k (v.map a) (v.map s)) (P.decorate A (k + 1))35| .singleton i P => .singleton i (fun j => A k [i] [j]) (P.decorate A (k + 1))3637/-- The independent variable names are determined by the occurrence trace,38and are independent of every coefficient operator. -/39theorem decorate_labels {m n : ℕ} {a : Fin m → I} {b : Fin n → I}40(P : EndpointSkeleton I a b) (A : ℕ → List I → List J → E →L[𝕜] E) (k : ℕ) :41List.ofFn (P.decorate A k).labels = P.profileLabels := by42induction P generalizing k with43| done => rfl44| first i P ih =>45simpa [decorate, EndpointTrace.labels, EndpointTrace.compile,46AssignmentProgram.variableCount, List.ofFn_succ, profileLabels] using47congrArg (List.cons i) (ih (k + 1))48| last p P ih => exact ih (k + 1)49| middle v P ih => exact ih (k + 1)50| singleton i P ih =>51simpa [decorate, EndpointTrace.labels, EndpointTrace.compile,52AssignmentProgram.variableCount, List.ofFn_succ, profileLabels] using53congrArg (List.cons i) (ih (k + 1))5455def markedFlags {m n : ℕ} {a : Fin m → I} {b : Fin n → I} :56EndpointSkeleton I a b → List Bool57| .done _ => []58| .first _ P => true :: P.markedFlags59| .last _ P => true :: P.markedFlags60| .middle _ P => false :: P.markedFlags61| .singleton _ P => true :: P.markedFlags6263/-- Every independent label pays at most two marked occurrences, allowing64for the registers already open at the two boundaries. -/65theorem marked_count_boundary {m n : ℕ} {a : Fin m → I} {b : Fin n → I}66(P : EndpointSkeleton I a b) :67P.markedFlags.count true + n ≤ 2 * P.profileLabels.length + m := by68induction P <;> simp_all [markedFlags, profileLabels] <;> omega6970/-- Compression prevents adjacent middle blocks. The one possible extra71block occurs only if the trace itself starts in the middle. -/72theorem compressed_length_le {m n : ℕ} {a : Fin m → I} {b : Fin n → I}73(P : EndpointSkeleton I a b) (hP : P.Compressed) :74P.markedFlags.length ≤ 2 * P.markedFlags.count true +75(if P.startsMiddle then 1 else 0) := by76induction P with77| done => simp [markedFlags, startsMiddle]78| first i P ih =>79have h := ih hP80cases hs : P.startsMiddle <;> simp_all [markedFlags, startsMiddle] <;> omega81| last p P ih =>82have h := ih hP83cases hs : P.startsMiddle <;> simp_all [markedFlags, startsMiddle] <;> omega84| middle v P ih =>85obtain ⟨_, hs, hc⟩ := hP86have h := ih hc87simp_all [markedFlags, startsMiddle]88| singleton i P ih =>89have h := ih hP90cases hs : P.startsMiddle <;> simp_all [markedFlags, startsMiddle] <;> omega9192theorem startsMiddle_false_of_empty {n : ℕ} {b : Fin n → I}93(P : EndpointSkeleton I (Fin.elim0 : Fin 0 → I) b) (hP : P.Compressed) :94P.startsMiddle = false := by95cases P with96| done => rfl97| first => rfl98| singleton => rfl99| middle v P =>100cases v with101| nil => exact (hP.1 rfl).elim102| cons p v => exact Fin.elim0 p103104/-- The corrected BC coefficient exponent for an actual compressed trace.105This uses the true block count and counts the costly marked factors only. -/106theorem coefficient_exponent_le107(P : EndpointSkeleton I (Fin.elim0 : Fin 0 → I) (Fin.elim0 : Fin 0 → I))108(hP : P.Compressed) :109P.markedFlags.length - 1 + P.markedFlags.count true ≤1106 * P.profileLabels.length - 1 := by111have hl := P.compressed_length_le hP112rw [P.startsMiddle_false_of_empty hP] at hl113have hm := P.marked_count_boundary114simp only [Bool.false_eq_true, if_false, Nat.add_zero] at hl hm115omega116117theorem decorate_markedFlags {m n : ℕ} {a : Fin m → I} {b : Fin n → I}118(P : EndpointSkeleton I a b) (A : ℕ → List I → List J → E →L[𝕜] E) (k : ℕ) :119(P.decorate A k).markedFlags = P.markedFlags := by120induction P generalizing k <;> simp_all [decorate, markedFlags, EndpointTrace.markedFlags]121122/-- Ordered factors read directly from a global assignment; middle blocks123receive their full profile list in one call to `A`. -/124def blockFactors {m n : ℕ} {a : Fin m → I} {b : Fin n → I}125(P : EndpointSkeleton I a b) (A : ℕ → List I → List J → E →L[𝕜] E)126(k : ℕ) (σ : I → J) : List (E →L[𝕜] E) :=127match P with128| .done _ => []129| .first i P => P.blockFactors A (k + 1) σ ++ [A k [i] [σ i]]130| .last (a := a) p P => P.blockFactors A (k + 1) σ ++ [A k [a p] [σ (a p)]]131| .middle (a := a) v P =>132P.blockFactors A (k + 1) σ ++ [A k (v.map a) ((v.map a).map σ)]133| .singleton i P => P.blockFactors A (k + 1) σ ++ [A k [i] [σ i]]134135theorem decorate_factors {m n : ℕ} {a : Fin m → I} {b : Fin n → I}136(P : EndpointSkeleton I a b) (A : ℕ → List I → List J → E →L[𝕜] E)137(k : ℕ) (σ : I → J) :138(P.decorate A k).factors σ = P.blockFactors A k σ := by139induction P generalizing k <;>140simp_all [decorate, EndpointTrace.factors, blockFactors, List.map_map]141142theorem coversLabels_of_profileLabels {m n : ℕ} {a : Fin m → I} {b : Fin n → I}143(P : EndpointSkeleton I a b) (A : ℕ → List I → List J → E →L[𝕜] E) (k : ℕ)144(hn : P.profileLabels.Nodup) (hc : ∀ i : I, i ∈ P.profileLabels) :145(P.decorate A k).CoversLabels := by146constructor147· apply List.nodup_ofFn.mp148rw [decorate_labels]149exact hn150· intro i151have hi := hc i152rw [← decorate_labels P A k, List.mem_ofFn] at hi153exact hi154155/-- A fully compiled, literal sum over all global profiles for whole-block156operators, with the exact endpoint and middle operator costs. -/157theorem block_sum_norm_le [Fintype I] [DecidableEq I]158(P : EndpointSkeleton I (Fin.elim0 : Fin 0 → I) (Fin.elim0 : Fin 0 → I))159(A : ℕ → List I → List J → E →L[𝕜] E) (k : ℕ)160(hn : P.profileLabels.Nodup) (hc : ∀ i : I, i ∈ P.profileLabels) :161‖∑ σ : I → J, (P.blockFactors A k σ).prod‖ ≤ (P.decorate A k).compile.cost := by162have h := (P.decorate A k).sum_products_norm_le (P.coversLabels_of_profileLabels A k hn hc)163simpa only [decorate_factors] using h164165theorem profileLabels_length_eq_card [Fintype I] [DecidableEq I]166{m n : ℕ} {a : Fin m → I} {b : Fin n → I} (P : EndpointSkeleton I a b)167(hn : P.profileLabels.Nodup) (hc : ∀ i : I, i ∈ P.profileLabels) :168P.profileLabels.length = Fintype.card I := by169have hu : P.profileLabels.toFinset = Finset.univ := by170apply Finset.eq_univ_of_forall171intro i172exact List.mem_toFinset.mpr (hc i)173simpa [hu] using (List.toFinset_card_of_nodup hn).symm174175/-- For a word containing every label, the automatic compiler supplies all176coverage and distinctness facts needed by the global profile inequality. -/177theorem exists_closed_compiler [Fintype I] [DecidableEq I]178(l : List I) (hl : ∀ i : I, i ∈ l) :179∃ P : EndpointSkeleton I (Fin.elim0 : Fin 0 → I) (Fin.elim0 : Fin 0 → I),180P.word = l ∧ P.Compressed ∧ P.profileLabels.Nodup ∧181(∀ i : I, i ∈ P.profileLabels) ∧182P.markedFlags.length - 1 + P.markedFlags.count true ≤ 6 * Fintype.card I - 1 := by183obtain ⟨P, hw, hp, hn, hc⟩ := exists_compressed l (Fin.elim0 : Fin 0 → I)184(fun p => Fin.elim0 p) (fun p => Fin.elim0 p)185have hc' : ∀ i : I, i ∈ P.profileLabels := by186intro i187apply (hc i).mpr188exact ⟨hl i, by rintro ⟨p, _⟩; exact Fin.elim0 p⟩189refine ⟨P, hw, hp, hn, hc', ?_⟩190have h := P.coefficient_exponent_le hp191rwa [P.profileLabels_length_eq_card hn hc'] at h192193end Nonadditivity.NoncommutativeCS.EndpointSkeleton