{"schema":1,"revision":"2f443f44c190a64c713d6ea71c3d99ce48f78252","examples":[{"id":"paper-x-residual","title":"Paper X · Residual partition","work":"paper-x","files":[{"module":"PaperX.Residual","path":"papers/paper-x/current/current_continuation/lean/PaperX/Residual.lean","sha256":"e7a1762b5c8015d9135dfd4cd26e2e215f4af9daf53384b3c64191083a43ebd2","inspect":"../../read/paper-x/residual-178b6097fed0.html","download":"../../documents/files/0719cc563221bf5f420256b871ff270fa515e814/Residual.lean","text":"import Std\n\n/-!\nPaper X, first checked block: residual partition and no crossing.\nThe reduction map is data. Positive-depth operations must preserve that map.\nAn infinite stream has a limit only under the explicit convergence hypothesis.\nNo arithmetic companion, occupancy, or Collatz assumption is imported.\n-/\nset_option autoImplicit false\nnamespace PaperX.Residual\n\nvariable {X R : Type}\n\ndef Fiber (red : X → R) (r : R) := {x : X // red x = r}\n\ndef pack (red : X → R) (x : X) : (r : R) × Fiber red r :=\n  ⟨red x, ⟨x, rfl⟩⟩\n\ndef unpack (red : X → R) (p : (r : R) × Fiber red r) : X := p.2.1\n\ntheorem unpack_pack (red : X → R) (x : X) : unpack red (pack red x) = x := rfl\n\ntheorem pack_unpack (red : X → R) (p : (r : R) × Fiber red r) :\n    pack red (unpack red p) = p := by\n  rcases p with ⟨r, x, hx⟩\n  cases hx\n  rfl\n\ntheorem residual_exhaustive (red : X → R) (x : X) : ∃ r, red x = r :=\n  ⟨red x, rfl⟩\n\ntheorem residual_unique (red : X → R) (x : X) (r s : R)\n    (hr : red x = r) (hs : red x = s) : r = s := hr.symm.trans hs\n\ntheorem fibers_disjoint (red : X → R) (r s : R) (hne : r ≠ s) :\n    ¬ ∃ x, red x = r ∧ red x = s := by\n  rintro ⟨x, hr, hs⟩\n  exact hne (residual_unique red x r s hr hs)\n\n/-- A finite sequence of allowed operations, including the empty sequence. -/\ninductive Reach (step : X → X → Prop) : X → X → Prop\n  | refl (x : X) : Reach step x x\n  | next {x y z : X} : Reach step x y → step y z → Reach step x z\n\ntheorem no_crossing_finite (red : X → R) (step : X → X → Prop)\n    (preserves : ∀ {x y}, step x y → red y = red x)\n    {x y : X} (h : Reach step x y) : red y = red x := by\n  induction h with\n  | refl => rfl\n  | next _ hs ih => exact (preserves hs).trans ih\n\ntheorem zeroth_order_obstruction (red : X → R) (step : X → X → Prop)\n    (preserves : ∀ {x y}, step x y → red y = red x)\n    {x y : X} (different : red x ≠ red y) : ¬ Reach step x y := by\n  intro h\n  exact different (no_crossing_finite red step preserves h).symm\n\ntheorem stream_invariant (red : X → R) (step : X → X → Prop)\n    (preserves : ∀ {x y}, step x y → red y = red x)\n    (stream : Nat → X) (follows : ∀ n, step (stream n) (stream (n+1))) :\n    ∀ n, red (stream n) = red (stream 0) := by\n  intro n\n  induction n with\n  | zero => rfl\n  | succ n ih => exact (preserves (follows n)).trans ih\n\n/-- Finite-precision convergence; the type of observations may depend on depth. -/\ndef PrecisionConverges {Y : Type} {Level : Nat → Type}\n    (observe : (d : Nat) → Y → Level d) (stream : Nat → Y) (limit : Y) : Prop :=\n  ∀ d, ∃ N, ∀ n, N ≤ n → observe d (stream n) = observe d limit\n\ntheorem no_crossing_limit {Y : Type} {Level : Nat → Type}\n    (observe : (d : Nat) → Y → Level d) (stream : Nat → Y) (limit : Y)\n    (sameRoot : ∀ n, observe 0 (stream n) = observe 0 (stream 0))\n    (converges : PrecisionConverges observe stream limit) :\n    observe 0 limit = observe 0 (stream 0) := by\n  obtain ⟨N, hN⟩ := converges 0\n  exact (hN N (Nat.le_refl N)).symm.trans (sameRoot N)\n\ntheorem positive_depth_mod (p x h : Nat) : (x + p*h) % p = x % p := by\n  simp [Nat.add_mod]\n\n/-- Root preservation alone does not imply convergence: alternating 0 and 3. -/\ndef oscillation (n : Nat) : Nat := if n % 2 = 0 then 0 else 3\n\ntheorem oscillation_same_root (n : Nat) : oscillation n % 3 = 0 := by\n  unfold oscillation\n  split <;> decide\n\n/-- At precision 9, the root-preserving stream is not even eventually constant. -/\ntheorem oscillation_not_eventually_constant_mod9 :\n    ¬ ∃ r N : Nat, ∀ n, N ≤ n → oscillation n % 9 = r := by\n  rintro ⟨r, N, h⟩\n  have he := h (2*N) (by omega)\n  have ho := h (2*N+1) (by omega)\n  have even : (2*N) % 2 = 0 := by omega\n  simp [oscillation, even] at he\n  simp [oscillation] at ho\n  omega\n\nend PaperX.Residual\n"}],"download_plan":{"files":386,"bytes":215208083}},{"id":"proof-path-compression","title":"Proof Path Theory · Compression","work":"proof-path-theory","files":[{"module":"ProofPath.Compression","path":"monographs/proof-path-theory/formal/ProofPath/Compression.lean","sha256":"b12eac584bfddf459c54e882191623de2007d73824db84e51fb38d82756d07b9","inspect":"../../read/proof-path-theory/compression-f755aa204adf.html","download":"../../documents/files/761b99539fd951340fb2a61102ae386cf44dad8e/Compression.lean","text":"import Mathlib.Data.Set.Function\n\nnamespace ProofPath\n\n/-- Task sufficiency is factorization, not the length of an encoding. -/\ndef Sufficient {A B C : Type*} (encode : A → B) (task : A → C) : Prop :=\n  ∃ decode : B → C, ∀ a, decode (encode a) = task a\n\ntheorem collision_obstructs_sufficiency {A B C : Type*}\n    (encode : A → B) (task : A → C) {a b : A}\n    (hc : encode a = encode b) (ht : task a ≠ task b) :\n    ¬ Sufficient encode task := by\n  rintro ⟨decode, hd⟩\n  exact ht ((hd a).symm.trans ((congrArg decode hc).trans (hd b)))\n\n/-- Losslessness means injectivity. It does not require identical bytes. -/\ntheorem all_predicates_sufficient_iff_injective {A B : Type*} (encode : A → B) :\n    (∀ task : A → Prop, Sufficient encode task) ↔ Function.Injective encode := by\n  constructor\n  · intro h a b he\n    obtain ⟨d, hd⟩ := h (fun x => x = a)\n    have hba : (b = a) = (a = a) := (hd b).symm.trans ((congrArg d he.symm).trans (hd a))\n    exact (Eq.mp hba.symm rfl).symm\n  · intro hi task\n    refine ⟨fun b => ∃ a, encode a = b ∧ task a, ?_⟩\n    intro a\n    apply propext\n    constructor\n    · rintro ⟨a', he, ht⟩\n      exact hi he ▸ ht\n    · exact fun ht => ⟨a, rfl, ht⟩\n\nend ProofPath\n"}],"mathlib_manifest":"workspaces/proof-path-compression.json","download_plan":{"files":747,"bytes":246713381}},{"id":"proof-path-recovery","title":"Proof Path Theory · Recovery with its local import","work":"proof-path-theory","files":[{"module":"ProofPath.Compression","path":"monographs/proof-path-theory/formal/ProofPath/Compression.lean","sha256":"b12eac584bfddf459c54e882191623de2007d73824db84e51fb38d82756d07b9","inspect":"../../read/proof-path-theory/compression-f755aa204adf.html","download":"../../documents/files/761b99539fd951340fb2a61102ae386cf44dad8e/Compression.lean","text":"import Mathlib.Data.Set.Function\n\nnamespace ProofPath\n\n/-- Task sufficiency is factorization, not the length of an encoding. -/\ndef Sufficient {A B C : Type*} (encode : A → B) (task : A → C) : Prop :=\n  ∃ decode : B → C, ∀ a, decode (encode a) = task a\n\ntheorem collision_obstructs_sufficiency {A B C : Type*}\n    (encode : A → B) (task : A → C) {a b : A}\n    (hc : encode a = encode b) (ht : task a ≠ task b) :\n    ¬ Sufficient encode task := by\n  rintro ⟨decode, hd⟩\n  exact ht ((hd a).symm.trans ((congrArg decode hc).trans (hd b)))\n\n/-- Losslessness means injectivity. It does not require identical bytes. -/\ntheorem all_predicates_sufficient_iff_injective {A B : Type*} (encode : A → B) :\n    (∀ task : A → Prop, Sufficient encode task) ↔ Function.Injective encode := by\n  constructor\n  · intro h a b he\n    obtain ⟨d, hd⟩ := h (fun x => x = a)\n    have hba : (b = a) = (a = a) := (hd b).symm.trans ((congrArg d he.symm).trans (hd a))\n    exact (Eq.mp hba.symm rfl).symm\n  · intro hi task\n    refine ⟨fun b => ∃ a, encode a = b ∧ task a, ?_⟩\n    intro a\n    apply propext\n    constructor\n    · rintro ⟨a', he, ht⟩\n      exact hi he ▸ ht\n    · exact fun ht => ⟨a, rfl, ht⟩\n\nend ProofPath\n"},{"module":"ProofPath.Recovery","path":"monographs/proof-path-theory/formal/ProofPath/Recovery.lean","sha256":"ab689304f37b09092620f9a82a523f51612f8b5ba652d15a333cc4c2221ba3d2","inspect":"../../read/proof-path-theory/recovery-a195bc8fa24c.html","download":"../../documents/files/b7a07c8e807004bc8590705bb9f65ba74995b8fe/Recovery.lean","text":"import ProofPath.Compression\n\n/-!\nRecovery on the attained image. This is the decoder domain used by the monograph.\nThe old total-codomain definition stays available and is compared explicitly.\n-/\nnamespace ProofPath\nnamespace Recovery\n\nvariable {A B C D : Type*}\n\ndef Image (encode : A → B) := {b : B // ∃ a : A, encode a = b}\n\ndef observed (encode : A → B) (a : A) : Image encode := ⟨encode a, a, rfl⟩\n\ndef Sufficient (encode : A → B) (task : A → C) : Prop :=\n  ∃ decode : Image encode → C, ∀ a, decode (observed encode a) = task a\n\ndef FiberConstant (encode : A → B) (task : A → C) : Prop :=\n  ∀ a a', encode a = encode a' → task a = task a'\n\ntheorem sufficient_iff_fiber_constant (encode : A → B) (task : A → C) :\n    Sufficient encode task ↔ FiberConstant encode task := by\n  constructor\n  · rintro ⟨d, hd⟩ a a' he\n    have hh : observed encode a = observed encode a' := Subtype.ext he\n    exact (hd a).symm.trans ((congrArg d hh).trans (hd a'))\n  · intro h\n    classical\n    let pick : Image encode → A := fun b => Classical.choose b.property\n    have hp : ∀ b : Image encode, encode (pick b) = b.val :=\n      fun b => Classical.choose_spec b.property\n    refine ⟨fun b => task (pick b), ?_⟩\n    intro a\n    exact h (pick (observed encode a)) a (hp (observed encode a))\n\ntheorem total_implies_attained (encode : A → B) (task : A → C)\n    (h : ProofPath.Sufficient encode task) : Sufficient encode task := by\n  rcases h with ⟨d, hd⟩\n  exact ⟨fun b => d b.val, hd⟩\n\n/-- A nonempty answer type supplies values for unattained representations. -/\ntheorem attained_iff_total [Nonempty C] (encode : A → B) (task : A → C) :\n    Sufficient encode task ↔ ProofPath.Sufficient encode task := by\n  constructor\n  · rintro ⟨d, hd⟩\n    classical\n    refine ⟨fun b => if h : ∃ a, encode a = b then d ⟨b, h⟩ else Classical.choice inferInstance, ?_⟩\n    intro a\n    simp only [dite_eq_left (show ∃ a', encode a' = encode a from ⟨a, rfl⟩)]\n    exact hd a\n  · exact total_implies_attained encode task\n\ntheorem decoder_unique (encode : A → B) (task : A → C)\n    (d e : Image encode → C)\n    (hd : ∀ a, d (observed encode a) = task a)\n    (he : ∀ a, e (observed encode a) = task a) : d = e := by\n  funext b\n  obtain ⟨a, ha⟩ := b.property\n  have hb : observed encode a = b := Subtype.ext ha\n  rw [← hb, hd, he]\n\n/-- The complete obstruction is an identified pair with different task answers. -/\ntheorem not_sufficient_iff_collision (encode : A → B) (task : A → C) :\n    ¬ Sufficient encode task ↔ ∃ a a', encode a = encode a' ∧ task a ≠ task a' := by\n  rw [sufficient_iff_fiber_constant]\n  unfold FiberConstant\n  push Not\n  rfl\n\ndef Recovers (coarse : A → B) (fine : A → C) : Prop := Sufficient fine coarse\n\ntheorem recovers_refl (encode : A → B) : Recovers encode encode := by\n  apply (sufficient_iff_fiber_constant _ _).mpr\n  exact fun _ _ h => h\n\ntheorem task_transport (coarse : A → B) (fine : A → C) (task : A → D)\n    (hr : Recovers coarse fine) (ht : Sufficient coarse task) : Sufficient fine task := by\n  apply (sufficient_iff_fiber_constant _ _).mpr\n  have h1 := (sufficient_iff_fiber_constant _ _).mp hr\n  have h2 := (sufficient_iff_fiber_constant _ _).mp ht\n  exact fun a b h => h2 a b (h1 a b h)\n\ntheorem recovers_trans (r : A → B) (s : A → C) (t : A → D)\n    (hrs : Recovers r s) (hst : Recovers s t) : Recovers r t :=\n  task_transport s t r hst hrs\n\n/-- A tagged portfolio recovers each of its coordinates. -/\ntheorem portfolio_left (r : A → B) (s : A → C) :\n    Recovers r (fun a => (r a, s a)) := by\n  apply (sufficient_iff_fiber_constant _ _).mpr\n  exact fun _ _ h => congrArg Prod.fst h\n\ntheorem portfolio_right (r : A → B) (s : A → C) :\n    Recovers s (fun a => (r a, s a)) := by\n  apply (sufficient_iff_fiber_constant _ _).mpr\n  exact fun _ _ h => congrArg Prod.snd h\n\n/-- Joint tasks supply the least information required by the entire task family. -/\ntheorem joint_sufficient_iff {I : Type*} {Y : I → Type*}\n    (encode : A → B) (tasks : (i : I) → A → Y i) :\n    Sufficient encode (fun a i => tasks i a) ↔ ∀ i, Sufficient encode (tasks i) := by\n  constructor\n  · intro h i\n    apply (sufficient_iff_fiber_constant _ _).mpr\n    intro a b hab\n    exact congrFun ((sufficient_iff_fiber_constant _ _).mp h a b hab) i\n  · intro h\n    apply (sufficient_iff_fiber_constant _ _).mpr\n    intro a b hab\n    funext i\n    exact (sufficient_iff_fiber_constant _ _).mp (h i) a b hab\n\ntheorem injective_sufficient (encode : A → B) (task : A → C)\n    (hi : Function.Injective encode) : Sufficient encode task := by\n  apply (sufficient_iff_fiber_constant _ _).mpr\n  exact fun _ _ h => congrArg task (hi h)\n\n/-- Attained and total decoding differ when an empty archive has an empty answer type. -/\ntheorem empty_attained_not_total :\n    Sufficient (fun a : Empty => Empty.elim a : Empty → Unit) (id : Empty → Empty) ∧\n    ¬ ProofPath.Sufficient (fun a : Empty => Empty.elim a : Empty → Unit) (id : Empty → Empty) := by\n  constructor\n  · apply (sufficient_iff_fiber_constant _ _).mpr\n    intro a\n    exact Empty.elim a\n  · rintro ⟨d, _⟩\n    exact Empty.elim (d ())\n\n/-- Hashing cannot repair a distinction already lost by serialization. -/\ntheorem serialized_collision_persists (serialize : A → B) (hash : B → C)\n    {a b : A} (h : serialize a = serialize b) :\n    hash (serialize a) = hash (serialize b) := congrArg hash h\n\n/-- Every task recoverable from a digest was already recoverable from its bytes. -/\ntheorem hash_task_data_processing (serialize : A → B) (hash : B → C)\n    (task : A → D) (h : Sufficient (hash ∘ serialize) task) :\n    Sufficient serialize task := by\n  apply (sufficient_iff_fiber_constant _ _).mpr\n  intro a b he\n  exact (sufficient_iff_fiber_constant _ _).mp h a b (congrArg hash he)\n\n/-- Injectivity only on attained serializations is sufficient to lose no further tasks. -/\ntheorem hash_preserves_tasks (serialize : A → B) (hash : B → C)\n    (hi : Set.InjOn hash (Set.range serialize)) (task : A → D) :\n    Sufficient (hash ∘ serialize) task ↔ Sufficient serialize task := by\n  constructor\n  · exact hash_task_data_processing serialize hash task\n  · intro h\n    apply (sufficient_iff_fiber_constant _ _).mpr\n    intro a b he\n    apply (sufficient_iff_fiber_constant _ _).mp h a b\n    exact hi ⟨a, rfl⟩ ⟨b, rfl⟩ he\n\nend Recovery\nend ProofPath\n"}],"compatibility":{"source":"-- Browser compatibility: Lean 4.33 calls this lemma dif_pos.\n-- Checked by Lean alongside Recovery; this is not retained paper source.\nuniverse u\ntheorem dite_eq_left {α : Sort u} {p : Prop} [Decidable p]\n    {t : p → α} {e : ¬ p → α} (h : p) : dite p t e = t h := by\n  exact dif_pos h\n","sha256":"b65e10d2350fe06cc5f6313218b198d51926102579207392cdfd70c2c9a834de"},"mathlib_manifest":"workspaces/proof-path-compression.json","download_plan":{"files":747,"bytes":246713381}},{"id":"paper-ii-linear-defects","title":"Paper II · Linear defects","work":"paper-ii","files":[{"module":"PaperII.LinearDefects","path":"papers/paper-ii/current/formal/current/KomorebiVerification/PaperII/LinearDefects.lean","sha256":"9ce2a78b78d77c65520415805cdd7e3f40be8ab4d388ff44e731777318dfccc5","inspect":"../../read/paper-ii/lineardefects-18657a7ae75a.html","download":"../../documents/files/1a71066dae573a696b17dac4f4e37fb31b2dc689/LinearDefects.lean","text":"/-\nCopyright (c) 2026 Komorebi P. All rights reserved.\nAuthors: Komorebi P.\n-/\n\nimport Mathlib.Analysis.Normed.Ring.Basic\nimport Mathlib.Tactic.NoncommRing\n\n/-!\n# Paper II: algebraic linear defects\n\nAuthor: Komorebi P.\n\nThis module records the noncommutative telescoping identity for a one-step\nintertwining defect.  The identity is valid in every ring and for every\nnatural power, including power zero.  It also gives the corresponding norm\nestimate in a normed ring and proves the inverse-sandwich identity from\nexplicit left- and right-inverse equations.\n-/\n\nset_option autoImplicit false\n\nnamespace Komorebi.PaperII.LinearDefects\n\nopen scoped BigOperators\n\nuniverse u\n\n/-! ## Power defects -/\n\n/-- The one-step defect of `C` with respect to the fine operator `Tf` and\nthe coarse operator `Tc`. -/\ndef defect {R : Type u} [Ring R] (C Tf Tc : R) : R :=\n  C * Tf - Tc * C\n\n/-- The power-defect telescoping identity, including the case `n = 0`.\n\nNo factors are commuted: the coarse powers remain on the left of the defect\nand the fine powers remain on its right.\n-/\ntheorem power_defect_identity_all {R : Type u} [Ring R]\n    (C Tf Tc : R) (n : ℕ) :\n    C * Tf ^ n - Tc ^ n * C =\n      ∑ k ∈ Finset.range n,\n        Tc ^ (n - 1 - k) * defect C Tf Tc * Tf ^ k := by\n  induction n with\n  | zero => simp [defect]\n  | succ n ih =>\n      rw [Finset.sum_range_succ]\n      calc\n        C * Tf ^ (n + 1) - Tc ^ (n + 1) * C =\n            Tc * (C * Tf ^ n - Tc ^ n * C) + defect C Tf Tc * Tf ^ n := by\n              simp only [defect, pow_succ']\n              noncomm_ring\n        _ = Tc * (∑ k ∈ Finset.range n,\n              Tc ^ (n - 1 - k) * defect C Tf Tc * Tf ^ k) +\n              defect C Tf Tc * Tf ^ n := by rw [ih]\n        _ = (∑ k ∈ Finset.range n,\n              Tc ^ ((n + 1) - 1 - k) * defect C Tf Tc * Tf ^ k) +\n              Tc ^ ((n + 1) - 1 - n) * defect C Tf Tc * Tf ^ n := by\n              congr 1\n              · rw [Finset.mul_sum]\n                apply Finset.sum_congr rfl\n                intro k hk\n                have hklt : k < n := Finset.mem_range.mp hk\n                have hexponent : n - 1 - k + 1 = n - k := by omega\n                calc\n                  Tc * (Tc ^ (n - 1 - k) * defect C Tf Tc * Tf ^ k) =\n                      (Tc * Tc ^ (n - 1 - k)) * defect C Tf Tc * Tf ^ k := by\n                        simp only [mul_assoc]\n                  _ = Tc ^ (n - 1 - k + 1) * defect C Tf Tc * Tf ^ k := by\n                        rw [← pow_succ']\n                  _ = Tc ^ (n - k) * defect C Tf Tc * Tf ^ k := by\n                        rw [hexponent]\n                  _ = Tc ^ ((n + 1) - 1 - k) * defect C Tf Tc * Tf ^ k := by\n                        have hsucc : (n + 1) - 1 - k = n - k := by omega\n                        rw [hsucc]\n              · simp\n\n/-- The positive-power form used in Paper II. -/\ntheorem power_defect_identity {R : Type u} [Ring R]\n    (C Tf Tc : R) (n : ℕ) (_hn : 0 < n) :\n    C * Tf ^ n - Tc ^ n * C =\n      ∑ k ∈ Finset.range n,\n        Tc ^ (n - 1 - k) * defect C Tf Tc * Tf ^ k :=\n  power_defect_identity_all C Tf Tc n\n\n/-- Submultiplicativity turns the exact telescoping formula into the usual\npower-defect estimate with the norms of the actual powers.  This form needs\nonly a `NormedRing`; neither completeness nor normalization of `‖1‖` is\nrequired. -/\ntheorem norm_power_defect_le_raw {R : Type u} [NormedRing R]\n    (C Tf Tc : R) (n : ℕ) :\n    ‖C * Tf ^ n - Tc ^ n * C‖ ≤\n      ∑ k ∈ Finset.range n,\n        ‖defect C Tf Tc‖ *\n          (‖Tc ^ (n - 1 - k)‖ * ‖Tf ^ k‖) := by\n  rw [power_defect_identity_all]\n  calc\n    ‖∑ k ∈ Finset.range n,\n        Tc ^ (n - 1 - k) * defect C Tf Tc * Tf ^ k‖ ≤\n        ∑ k ∈ Finset.range n,\n          ‖Tc ^ (n - 1 - k) * defect C Tf Tc * Tf ^ k‖ :=\n      norm_sum_le _ _\n    _ ≤ ∑ k ∈ Finset.range n,\n          ‖defect C Tf Tc‖ *\n            (‖Tc ^ (n - 1 - k)‖ * ‖Tf ^ k‖) := by\n      apply Finset.sum_le_sum\n      intro k _hk\n      calc\n        ‖Tc ^ (n - 1 - k) * defect C Tf Tc * Tf ^ k‖ ≤\n            ‖Tc ^ (n - 1 - k) * defect C Tf Tc‖ * ‖Tf ^ k‖ :=\n          norm_mul_le _ _\n        _ ≤ (‖Tc ^ (n - 1 - k)‖ * ‖defect C Tf Tc‖) * ‖Tf ^ k‖ :=\n          mul_le_mul_of_nonneg_right (norm_mul_le _ _) (norm_nonneg _)\n        _ = ‖defect C Tf Tc‖ *\n            (‖Tc ^ (n - 1 - k)‖ * ‖Tf ^ k‖) := by\n          ac_rfl\n\n/-- For a normalized norm, the raw estimate becomes the power bound displayed\nin Paper II.  Completeness is not required. -/\ntheorem norm_power_defect_le {R : Type u} [NormedRing R] [NormOneClass R]\n    (C Tf Tc : R) (n : ℕ) :\n    ‖C * Tf ^ n - Tc ^ n * C‖ ≤\n      ‖defect C Tf Tc‖ *\n        ∑ k ∈ Finset.range n, ‖Tc‖ ^ (n - 1 - k) * ‖Tf‖ ^ k := by\n  rw [power_defect_identity_all]\n  calc\n    ‖∑ k ∈ Finset.range n,\n        Tc ^ (n - 1 - k) * defect C Tf Tc * Tf ^ k‖ ≤\n        ∑ k ∈ Finset.range n,\n          ‖Tc ^ (n - 1 - k) * defect C Tf Tc * Tf ^ k‖ :=\n      norm_sum_le _ _\n    _ ≤ ∑ k ∈ Finset.range n,\n          ‖defect C Tf Tc‖ *\n            (‖Tc‖ ^ (n - 1 - k) * ‖Tf‖ ^ k) := by\n      apply Finset.sum_le_sum\n      intro k _hk\n      calc\n        ‖Tc ^ (n - 1 - k) * defect C Tf Tc * Tf ^ k‖ ≤\n            ‖Tc ^ (n - 1 - k) * defect C Tf Tc‖ * ‖Tf ^ k‖ :=\n          norm_mul_le _ _\n        _ ≤ (‖Tc ^ (n - 1 - k)‖ * ‖defect C Tf Tc‖) * ‖Tf ^ k‖ :=\n          mul_le_mul_of_nonneg_right (norm_mul_le _ _) (norm_nonneg _)\n        _ ≤ (‖Tc‖ ^ (n - 1 - k) * ‖defect C Tf Tc‖) * ‖Tf ^ k‖ :=\n          mul_le_mul_of_nonneg_right\n            (mul_le_mul_of_nonneg_right (norm_pow_le _ _) (norm_nonneg _))\n            (norm_nonneg _)\n        _ ≤ (‖Tc‖ ^ (n - 1 - k) * ‖defect C Tf Tc‖) * ‖Tf‖ ^ k :=\n          mul_le_mul_of_nonneg_left (norm_pow_le _ _)\n            (mul_nonneg (pow_nonneg (norm_nonneg _) _) (norm_nonneg _))\n        _ = ‖defect C Tf Tc‖ *\n            (‖Tc‖ ^ (n - 1 - k) * ‖Tf‖ ^ k) := by\n          ac_rfl\n    _ = ‖defect C Tf Tc‖ *\n          ∑ k ∈ Finset.range n, ‖Tc‖ ^ (n - 1 - k) * ‖Tf‖ ^ k := by\n      rw [Finset.mul_sum]\n\n/-! ## Explicit inverse witnesses -/\n\n/-- `xinv` is an explicitly supplied two-sided inverse of `x`.\n\nBoth equations are retained because the ambient ring need not be\ncommutative.\n-/\nstructure TwoSidedInverse {R : Type u} [Mul R] [One R]\n    (x xinv : R) : Prop where\n  left_inv : xinv * x = 1\n  right_inv : x * xinv = 1\n\n/-- The inverse-sandwich identity for two independently supplied inverse\nwitnesses. -/\ntheorem inverse_sandwich_identity {R : Type u} [Ring R]\n    (A Ainv B Binv C : R)\n    (hA : TwoSidedInverse A Ainv)\n    (hB : TwoSidedInverse B Binv) :\n    C * Binv - Ainv * C =\n      Ainv * (A * C - C * B) * Binv := by\n  calc\n    C * Binv - Ainv * C =\n        (Ainv * A) * (C * Binv) - (Ainv * C) * (B * Binv) := by\n          rw [hA.left_inv, hB.right_inv]\n          simp\n    _ = Ainv * (A * C - C * B) * Binv := by\n      noncomm_ring\n\n/-- The resolvent-defect identity in a possibly noncommutative ring.\n\nThe hypothesis `Commute z C` expresses exactly the centrality needed of the\nscalar shift.  In a commutative ring it is automatic.\n-/\ntheorem resolvent_defect_identity {R : Type u} [Ring R]\n    (z C Tf Tc Rf Rc : R)\n    (hf : TwoSidedInverse (z - Tf) Rf)\n    (hc : TwoSidedInverse (z - Tc) Rc)\n    (hzC : Commute z C) :\n    C * Rf - Rc * C = Rc * defect C Tf Tc * Rf := by\n  have hmiddle : (z - Tc) * C - C * (z - Tf) = defect C Tf Tc := by\n    simp only [defect, sub_mul, mul_sub]\n    rw [hzC.eq]\n    noncomm_ring\n  calc\n    C * Rf - Rc * C =\n        Rc * ((z - Tc) * C - C * (z - Tf)) * Rf :=\n      inverse_sandwich_identity (z - Tc) Rc (z - Tf) Rf C hc hf\n    _ = Rc * defect C Tf Tc * Rf := by rw [hmiddle]\n\nend Komorebi.PaperII.LinearDefects\n"}],"mathlib_manifest":"workspaces/paper-ii-linear-defects.json","download_plan":{"files":409,"bytes":363657123}},{"id":"paper-iii-coordinate-naturality","title":"Paper III · Coordinate naturality","work":"paper-iii","files":[{"module":"KomorebiPaperIII.CoordinateNaturality","path":"papers/paper-iii/current/formal/KomorebiPaperIII/CoordinateNaturality.lean","sha256":"8d5edd43d1df58952e77d448be1764bf68a62ae14b87ca242e69c9c52b246674","inspect":"../../read/paper-iii/coordinatenaturality-7ea6f4260fa2.html","download":"../../documents/files/4c8f402737f45768ff4289c03553801e931a3260/CoordinateNaturality.lean","text":"/-\nCopyright (c) 2026 Komorebi P. All rights reserved.\nAuthors: Komorebi P.\n-/\n\nimport Mathlib.Logic.Equiv.Basic\n\n/-!\n# Exact coordinate naturality for arbitrary maps\n\nAn exact coordinate system is represented by an equivalence from an ambient\ntype to a coordinate type.  No linear, topological, or differentiable\nstructure is needed.  Coordinate transport and coordinate representation are\ntherefore functorial for arbitrary functions.\n-/\n\nset_option autoImplicit false\n\nnamespace Komorebi.PaperIII.Transport\n\nuniverse u v w x y z\n\n/-- Exact change of coordinates from `source` coordinates to `target` coordinates. -/\ndef exactCoordinateTransport\n    {X : Type u} {Source : Type v} {Target : Type w}\n    (source : X ≃ Source) (target : X ≃ Target) : Source ≃ Target :=\n  source.symm.trans target\n\n@[simp] theorem exactCoordinateTransport_apply\n    {X : Type u} {Source : Type v} {Target : Type w}\n    (source : X ≃ Source) (target : X ≃ Target) (value : Source) :\n    exactCoordinateTransport source target value = target (source.symm value) :=\n  rfl\n\n/-- Exact transport from one coordinate system to itself is the identity. -/\n@[simp] theorem exactCoordinateTransport_self\n    {X : Type u} {Coordinate : Type v} (coordinate : X ≃ Coordinate) :\n    exactCoordinateTransport coordinate coordinate = Equiv.refl Coordinate := by\n  ext value\n  simp [exactCoordinateTransport]\n\n/-- Reversing an exact coordinate transport gives its inverse. -/\ntheorem exactCoordinateTransport_symm\n    {X : Type u} {Source : Type v} {Target : Type w}\n    (source : X ≃ Source) (target : X ≃ Target) :\n    (exactCoordinateTransport source target).symm =\n      exactCoordinateTransport target source := by\n  ext value\n  simp [exactCoordinateTransport]\n\n/-- Exact coordinate transports satisfy the cocycle law across heterogeneous coordinate types. -/\ntheorem exactCoordinateTransport_cocycle\n    {X : Type u} {A : Type v} {B : Type w} {C : Type x}\n    (a : X ≃ A) (b : X ≃ B) (c : X ≃ C) :\n    (exactCoordinateTransport a b).trans (exactCoordinateTransport b c) =\n      exactCoordinateTransport a c := by\n  ext value\n  simp [exactCoordinateTransport]\n\n/-- Every exact coordinate triangle has trivial holonomy. -/\ntheorem exactCoordinateTransport_triangle\n    {X : Type u} {A : Type v} {B : Type w} {C : Type x}\n    (a : X ≃ A) (b : X ≃ B) (c : X ≃ C) :\n    ((exactCoordinateTransport a b).trans\n      (exactCoordinateTransport b c)).trans\n        (exactCoordinateTransport c a) = Equiv.refl A := by\n  ext value\n  simp [exactCoordinateTransport]\n\n/-- Represent an arbitrary function between two exact coordinate systems. -/\ndef exactCoordinateMap\n    {X : Type u} {Y : Type v} {Source : Type w} {Target : Type x}\n    (source : X ≃ Source) (target : Y ≃ Target) (map : X → Y) :\n    Source → Target :=\n  fun value ↦ target (map (source.symm value))\n\n@[simp] theorem exactCoordinateMap_apply\n    {X : Type u} {Y : Type v} {Source : Type w} {Target : Type x}\n    (source : X ≃ Source) (target : Y ≃ Target) (map : X → Y)\n    (value : Source) :\n    exactCoordinateMap source target map value =\n      target (map (source.symm value)) :=\n  rfl\n\n/-- Exact coordinate representation preserves identities. -/\ntheorem exactCoordinateMap_id\n    {X : Type u} {Coordinate : Type v} (coordinate : X ≃ Coordinate) :\n    exactCoordinateMap coordinate coordinate id = id := by\n  funext value\n  simp [exactCoordinateMap]\n\n/-- Exact coordinate representation preserves composition of arbitrary functions. -/\ntheorem exactCoordinateMap_comp\n    {X : Type u} {Y : Type v} {Z : Type w}\n    {CX : Type x} {CY : Type y} {CZ : Type z}\n    (xCoordinate : X ≃ CX) (yCoordinate : Y ≃ CY)\n    (zCoordinate : Z ≃ CZ) (first : X → Y) (second : Y → Z) :\n    exactCoordinateMap xCoordinate zCoordinate (second ∘ first) =\n      exactCoordinateMap yCoordinate zCoordinate second ∘\n        exactCoordinateMap xCoordinate yCoordinate first := by\n  funext value\n  simp [exactCoordinateMap]\n\n/--\nChanging exact source and target coordinates commutes with representing any\nfunction.  This is set-level naturality and assumes neither linearity nor\ndifferentiability.\n-/\ntheorem exactCoordinateMap_naturality\n    {X : Type u} {Y : Type v}\n    {XA : Type w} {XB : Type x} {YR : Type y} {YS : Type z}\n    (sourceA : X ≃ XA) (sourceB : X ≃ XB)\n    (targetR : Y ≃ YR) (targetS : Y ≃ YS) (map : X → Y) :\n    exactCoordinateTransport targetR targetS ∘\n        exactCoordinateMap sourceA targetR map =\n      exactCoordinateMap sourceB targetS map ∘\n        exactCoordinateTransport sourceA sourceB := by\n  funext value\n  simp [exactCoordinateTransport, exactCoordinateMap, Function.comp_def]\n\nend Komorebi.PaperIII.Transport\n"}],"mathlib_manifest":"workspaces/paper-iii-coordinate-naturality.json","download_plan":{"files":685,"bytes":241016531}},{"id":"paper-iii-packet-coordinates","title":"Paper III · Packet coordinates","work":"paper-iii","files":[{"module":"KomorebiPaperIII.PacketCoordinates","path":"papers/paper-iii/current/formal/KomorebiPaperIII/PacketCoordinates.lean","sha256":"f6b79f47e2b7d20934ee422ddff22f7e11b168e7549fa4d6b46d8915a76b0285","inspect":"../../read/paper-iii/packetcoordinates-6d1508ff97ca.html","download":"../../documents/files/f5724b492367f620fe302a02c53cdf4982135b57/PacketCoordinates.lean","text":"/-\nCopyright (c) 2026 Komorebi P. All rights reserved.\nAuthors: Komorebi P.\n-/\nimport Mathlib.LinearAlgebra.Pi\n\n/-!\n# Actual coordinates of a finite orthogonal projector family\n\nThe coordinate type is the dependent product of the actual projector ranges.\nAnalysis and synthesis are constructed from the projectors, not supplied as an\ninvertibility certificate. Finiteness identifies this product with the finite\nalgebraic direct sum used in Paper III, Section 16. Zero projectors and the empty\nindex type are allowed; completeness then imposes the appropriate degeneracy.\n-/\nset_option autoImplicit false\nnoncomputable section\nopen scoped BigOperators\n\nnamespace Komorebi.PaperIII.PacketCoordinates\nuniverse u v w\n\n/-- A complete, pairwise orthogonal family of idempotent linear endomorphisms. -/\nstructure System (R : Type u) (M : Type v) (I : Type w)\n    [Semiring R] [AddCommMonoid M] [Module R M] [Fintype I] where\n  projector : I → M →ₗ[R] M\n  complete : ∑ i, projector i = LinearMap.id\n  idempotent : ∀ i, (projector i).comp (projector i) = projector i\n  orthogonal : ∀ i j, i ≠ j → (projector i).comp (projector j) = 0\n\nnamespace System\nvariable {R : Type u} {M : Type v} {I : Type w}\nvariable [Semiring R] [AddCommMonoid M] [Module R M] [Fintype I]\nvariable (P : System R M I)\n\n/-- The coordinate in slot `i` belongs to the actual range of projector `i`. -/\nabbrev Coordinates := (i : I) → LinearMap.range (P.projector i)\n\n/-- A vector in a projector range is fixed by that projector. -/\ntheorem projector_range_self (i : I) (x : LinearMap.range (P.projector i)) :\n    P.projector i (x : M) = (x : M) := by\n  rcases x.property with ⟨y, hy⟩\n  rw [← hy]\n  exact LinearMap.congr_fun (P.idempotent i) y\n\n/-- Distinct projectors annihilate vectors in each other's ranges. -/\ntheorem projector_range_other (i j : I) (h : i ≠ j)\n    (x : LinearMap.range (P.projector j)) : P.projector i (x : M) = 0 := by\n  rcases x.property with ⟨y, hy⟩\n  rw [← hy]\n  exact LinearMap.congr_fun (P.orthogonal i j h) y\n\n/-- Split an ambient vector into its projected components. -/\ndef analysis : M →ₗ[R] P.Coordinates where\n  toFun x i := ⟨P.projector i x, ⟨x, rfl⟩⟩\n  map_add' x y := by\n    funext i\n    apply Subtype.ext\n    exact (P.projector i).map_add x y\n  map_smul' r x := by\n    funext i\n    apply Subtype.ext\n    exact (P.projector i).map_smul r x\n\n/-- Reconstruct an ambient vector by summing the complete packet tuple. -/\ndef synthesis : P.Coordinates →ₗ[R] M where\n  toFun x := ∑ i, (x i : M)\n  map_add' x y := by\n    change (∑ i, ((x i : M) + (y i : M))) = _\n    exact Finset.sum_add_distrib\n  map_smul' r x := by\n    change (∑ i, r • (x i : M)) = r • (∑ i, (x i : M))\n    exact Finset.smul_sum.symm\n\n@[simp] theorem analysis_apply (x : M) (i : I) :\n    (P.analysis x i : M) = P.projector i x := rfl\n\n@[simp] theorem synthesis_apply (x : P.Coordinates) :\n    P.synthesis x = ∑ i, (x i : M) := rfl\n\n/-- Completeness proves synthesis after analysis is the ambient identity. -/\n@[simp] theorem synthesis_analysis (x : M) : P.synthesis (P.analysis x) = x := by\n  change (∑ i, P.projector i x) = x\n  simpa only [LinearMap.sum_apply, LinearMap.id_apply] using\n    LinearMap.congr_fun P.complete x\n\n/-- Idempotence and orthogonality prove analysis after synthesis is the tuple identity. -/\n@[simp] theorem analysis_synthesis (x : P.Coordinates) : P.analysis (P.synthesis x) = x := by\n  classical\n  funext i\n  apply Subtype.ext\n  change P.projector i (∑ j, (x j : M)) = (x i : M)\n  rw [map_sum]\n  rw [Finset.sum_eq_single i]\n  · exact P.projector_range_self i (x i)\n  · intro j _ hji\n    exact P.projector_range_other i j hji.symm (x j)\n  · simp\n\n/-- The coordinate linear equivalence is constructed from the projector axioms. -/\ndef coordinateEquiv : M ≃ₗ[R] P.Coordinates :=\n  { P.analysis with\n    invFun := P.synthesis\n    left_inv := P.synthesis_analysis\n    right_inv := P.analysis_synthesis }\n\n@[simp] theorem coordinateEquiv_apply (x : M) : P.coordinateEquiv x = P.analysis x := rfl\n@[simp] theorem coordinateEquiv_symm_apply (x : P.Coordinates) :\n    P.coordinateEquiv.symm x = P.synthesis x := rfl\n\n/-- Range membership and being fixed are literally the same packet condition. -/\ntheorem mem_range_iff_fixed (i : I) (x : M) :\n    x ∈ LinearMap.range (P.projector i) ↔ P.projector i x = x := by\n  constructor\n  · intro hx\n    exact P.projector_range_self i ⟨x, hx⟩\n  · intro hx\n    exact ⟨x, hx⟩\n\n/-- Complete projected data distinguish ambient vectors. -/\ntheorem analysis_injective : Function.Injective P.analysis := by\n  intro x y h\n  have hh := congrArg P.synthesis h\n  simpa only [P.synthesis_analysis] using hh\n\n/-- Every legal packet tuple is realized by its actual finite sum. -/\ntheorem analysis_surjective : Function.Surjective P.analysis := by\n  intro x\n  exact ⟨P.synthesis x, P.analysis_synthesis x⟩\n\nend System\nend Komorebi.PaperIII.PacketCoordinates\n"}],"mathlib_manifest":"workspaces/paper-iii-packet-coordinates.json","download_plan":{"files":408,"bytes":356307909}},{"id":"paper-vii-tensor-refinement","title":"Paper VII · Tensor refinement","work":"paper-vii","files":[{"module":"TensorRefinement","path":"papers/paper-vii/current/source/complete/Paper_VII_Complete_v0.6.0_With_Visual_Appendix/original_snapshot/formalization/TensorRefinement.lean","sha256":"b0587b32f55d50125790345695b777786d23e3f46141e7056049d3ef5a11e0f2","inspect":"../../read/paper-vii/tensorrefinement-1ceaa012a3e1.html","download":"../../documents/files/63c5e41180b834da22cb908020a4979f14a8853e/TensorRefinement.lean","text":"module\npublic import Mathlib.LinearAlgebra.Matrix.ConjTranspose\npublic import Mathlib.Algebra.BigOperators.Ring.Finset\npublic import Mathlib.Data.Fintype.Pi\npublic import Mathlib.Data.ZMod.Basic\npublic import Mathlib.Analysis.Complex.Basic\n/-! Author: Komorebi P. Paper VII second block, Theorem 3.2.\nArbitrary finite tensor products and regrouping by total residue. -/\npublic section\nset_option autoImplicit false\nnamespace KomorebiPaperVII.TensorRefinement\nopen scoped BigOperators\nsection Tensor\nvariable {F : Type*} [Fintype F] [DecidableEq F]\n  {D : F → Type*} [∀ i, Fintype (D i)]\ndef tensor (A : (i : F) → Matrix (D i) (D i) ℂ) :\n    Matrix ((i : F) → D i) ((i : F) → D i) ℂ :=\n  fun x y => ∏ i, A i (x i) (y i)\n\ntheorem tensor_mul (A B : (i : F) → Matrix (D i) (D i) ℂ) :\n    tensor (fun i => A i * B i) = tensor A * tensor B := by\n  ext x y\n  simp only [tensor, Matrix.mul_apply]\n  rw [Fintype.prod_sum]\n  apply Finset.sum_congr rfl\n  intro z _\n  exact Finset.prod_mul_distrib\n\nomit [∀ i, Fintype (D i)] [DecidableEq F] in\ntheorem tensor_one [∀ i, DecidableEq (D i)] :\n    tensor (fun i => (1 : Matrix (D i) (D i) ℂ)) = 1 := by\n  classical\n  ext x y\n  by_cases h : x = y\n  · subst y\n    simp [tensor]\n  · simp only [tensor, Matrix.one_apply, h, ite_false]\n    obtain ⟨i, hi⟩ := Function.ne_iff.mp h\n    exact Finset.prod_eq_zero (Finset.mem_univ i) (by simp [hi])\n\nomit [∀ i, Fintype (D i)] in\ntheorem tensor_sum {J : F → Type*} [∀ i, Fintype (J i)]\n    (P : (i : F) → J i → Matrix (D i) (D i) ℂ) :\n    (∑ a : (i : F) → J i, tensor (fun i => P i (a i))) =\n      tensor (fun i => ∑ j, P i j) := by\n  ext x y\n  simp only [Matrix.sum_apply]\n  change (∑ a : (i : F) → J i, ∏ i, P i (a i) (x i) (y i)) =\n    ∏ i, (∑ j, P i j) (x i) (y i)\n  simp only [Matrix.sum_apply]\n  exact (Fintype.prod_sum (fun i j => P i j (x i) (y i))).symm\n\nomit [∀ i, Fintype (D i)] [DecidableEq F] in\ntheorem tensor_adjoint (A : (i : F) → Matrix (D i) (D i) ℂ) :\n    (tensor A).conjTranspose = tensor (fun i => (A i).conjTranspose) := by\n  ext x y\n  simp [tensor, Matrix.conjTranspose_apply]\nend Tensor\n\nsection Fine\nvariable {F : Type*} [Fintype F] [DecidableEq F] {D J : F → Type*}\nvariable [∀ i, Fintype (D i)] [∀ i, DecidableEq (D i)]\nvariable [∀ i, Fintype (J i)] [∀ i, DecidableEq (J i)]\nvariable (P : (i : F) → J i → Matrix (D i) (D i) ℂ)\n\nomit [∀ i, DecidableEq (D i)] [∀ i, Fintype (J i)] in\ntheorem fine_mul\n    (hmul : ∀ i j k, P i j * P i k = if j = k then P i j else 0)\n    (a b : (i : F) → J i) :\n    tensor (fun i => P i (a i)) * tensor (fun i => P i (b i)) =\n      if a = b then tensor (fun i => P i (a i)) else 0 := by\n  classical\n  rw [← tensor_mul]\n  by_cases h : a = b\n  · subst b\n    simp only [ite_true, hmul]\n  · simp only [h, ite_false]\n    obtain ⟨i, hi⟩ := Function.ne_iff.mp h\n    ext x y\n    simp only [tensor, Matrix.zero_apply]\n    apply Finset.prod_eq_zero (Finset.mem_univ i)\n    simp only [hmul, hi, ite_false]\n    rfl\n\nomit [∀ i, Fintype (D i)] [∀ i, DecidableEq (J i)] in\ntheorem fine_complete (hsum : ∀ i, ∑ j, P i j = 1) :\n    (∑ a : (i : F) → J i, tensor (fun i => P i (a i))) = 1 := by\n  rw [tensor_sum]\n  simp_rw [hsum]\n  exact tensor_one\n\nomit [DecidableEq F] [∀ i, Fintype (D i)] [∀ i, DecidableEq (D i)]\n  [∀ i, Fintype (J i)] [∀ i, DecidableEq (J i)] in\ntheorem fine_selfAdjoint (hstar : ∀ i j, (P i j).conjTranspose = P i j)\n    (a : (i : F) → J i) :\n    (tensor (fun i => P i (a i))).conjTranspose = tensor (fun i => P i (a i)) := by\n  rw [tensor_adjoint]\n  simp_rw [hstar]\nend Fine\n\nsection Coarse\nvariable {R I J : Type*} [Ring R] [Fintype I] [DecidableEq I]\nvariable [Fintype J] [DecidableEq J]\ndef coarse (P : I → R) (address : I → J) (r : J) : R :=\n  ∑ a, if address a = r then P a else 0\n\nomit [Fintype J] in\ntheorem coarse_mul (P : I → R) (address : I → J)\n    (hmul : ∀ a b, P a * P b = if a = b then P a else 0) (r s : J) :\n    coarse P address r * coarse P address s =\n      if r = s then coarse P address r else 0 := by\n  unfold coarse\n  simp only [Finset.sum_mul, Finset.mul_sum]\n  have term (a b : I) :\n      (if address a = r then P a else 0) * (if address b = s then P b else 0) =\n      if a = b then (if address a = r ∧ r = s then P a else 0) else 0 := by\n    by_cases hab : a = b\n    · subst b\n      by_cases hr : address a = r <;> by_cases hs : r = s <;>\n        simp_all\n    · simp [hmul, hab, ite_mul, mul_ite]\n  simp_rw [term]\n  by_cases hrs : r = s <;> simp [hrs]\n\nomit [DecidableEq I] in\ntheorem coarse_complete (P : I → R) (address : I → J) (hsum : ∑ a, P a = 1) :\n    (∑ r, coarse P address r) = 1 := by\n  unfold coarse\n  rw [Finset.sum_comm]\n  simpa using hsum\n\nomit [DecidableEq I] [Fintype J] in\ntheorem coarse_selfAdjoint [StarRing R] (P : I → R) (address : I → J)\n    (hstar : ∀ a, star (P a) = P a) (r : J) :\n    star (coarse P address r) = coarse P address r := by\n  simp [coarse, star_sum, apply_ite, hstar]\nend Coarse\n\ntheorem tensor_polyphase_refinement {F : Type*} [Fintype F] [DecidableEq F] {D : F → Type*}\n    [∀ i, Fintype (D i)] [∀ i, DecidableEq (D i)]\n    (N : ℕ) [NeZero N] (P : (i : F) → ZMod N → Matrix (D i) (D i) ℂ)\n    (hmul : ∀ i j k, P i j * P i k = if j = k then P i j else 0)\n    (hsum : ∀ i, ∑ j, P i j = 1)\n    (hstar : ∀ i j, (P i j).conjTranspose = P i j) :\n    let Q := fun a : F → ZMod N => tensor (fun i => P i (a i))\n    let C := coarse Q (fun a => ∑ i, a i)\n    (∀ r s, C r * C s = if r = s then C r else 0) ∧\n      (∑ r, C r) = 1 ∧ (∀ r, (C r).conjTranspose = C r) := by\n  classical\n  dsimp only\n  refine ⟨?_, ?_, ?_⟩\n  · exact coarse_mul _ _ (fine_mul P hmul)\n  · exact coarse_complete _ _ (fine_complete P hsum)\n  · exact coarse_selfAdjoint _ _ (fine_selfAdjoint P hstar)\nend KomorebiPaperVII.TensorRefinement\n\n#print axioms KomorebiPaperVII.TensorRefinement.tensor_mul\n#print axioms KomorebiPaperVII.TensorRefinement.tensor_one\n#print axioms KomorebiPaperVII.TensorRefinement.tensor_sum\n#print axioms KomorebiPaperVII.TensorRefinement.tensor_adjoint\n#print axioms KomorebiPaperVII.TensorRefinement.fine_mul\n#print axioms KomorebiPaperVII.TensorRefinement.fine_complete\n#print axioms KomorebiPaperVII.TensorRefinement.fine_selfAdjoint\n#print axioms KomorebiPaperVII.TensorRefinement.coarse_mul\n#print axioms KomorebiPaperVII.TensorRefinement.coarse_complete\n#print axioms KomorebiPaperVII.TensorRefinement.coarse_selfAdjoint\n#print axioms KomorebiPaperVII.TensorRefinement.tensor_polyphase_refinement\n"}],"mathlib_manifest":"workspaces/paper-vii-tensor-refinement.json","download_plan":{"files":409,"bytes":363810038}},{"id":"paper-ix-residue-digits","title":"Paper IX · Retained residue lifting","work":"paper-ix","files":[{"module":"ResidueLiftDigits","path":"papers/paper-ix/current/preserved/PRSC_IX_Consolidated_Manuscript/polynomial_counts/formalization/ResidueLiftDigits.lean","sha256":"378dadff08814a05565baea228042017e58753f5a490d398655d4c95df8fb6d8","inspect":"../../read/paper-ix/residueliftdigits-5927d57f5357.html","download":"../../documents/files/d35b941868f4cc46a2158931e81caf69cce3fc7b/ResidueLiftDigits.lean","text":"module\npublic import Mathlib.Data.ZMod.Basic\npublic import Mathlib.Tactic.Ring\npublic import Mathlib.Data.Fintype.Card\n\n@[expose] public section\nnoncomputable section\nset_option autoImplicit false\n\nnamespace Komorebi.ResidueLiftDigits\n\nvariable {d : ℕ}\n\n/-- Correction classes modulo q are precisely the classes of shifted integers\nmodulo q^(L+1). This includes q=1 and L=0. -/\ntheorem shift_cast_eq_iff (q L : ℕ) (hq : 0 < q) (x s t : ℤ) :\n    ((x + (q : ℤ)^L * s : ℤ) : ZMod (q^(L+1))) =\n      ((x + (q : ℤ)^L * t : ℤ) : ZMod (q^(L+1))) ↔\n    (s : ZMod q) = (t : ZMod q) := by\n  rw [ZMod.intCast_eq_intCast_iff_dvd_sub,\n    ZMod.intCast_eq_intCast_iff_dvd_sub]\n  have hqL : (q : ℤ)^L ≠ 0 :=\n    pow_ne_zero _ (Int.natCast_ne_zero.mpr (Nat.ne_of_gt hq))\n  rw [show (x + (q : ℤ)^L * t) - (x + (q : ℤ)^L * s) =\n    (q : ℤ)^L * (t - s) by ring]\n  rw [Nat.cast_pow, pow_succ, mul_dvd_mul_iff_left hqL]\n\n/-- Actual residue vectors at the next level lying over the prescribed\ninteger vector x. The predicate uses canonical integer representatives. -/\nabbrev ResidueFiber (q L : ℕ) (x : Fin d → ℤ) :=\n  {y : Fin d → ZMod (q^(L+1)) //\n    ∀ i, (q : ℤ)^L ∣ ((y i).val : ℤ) - x i}\n\n/-- The actual next residue represented by a correction digit. -/\ndef digitResidue (q L : ℕ) (x : Fin d → ℤ) (t : Fin d → ZMod q) :\n    Fin d → ZMod (q^(L+1)) :=\n  fun i => ((x i + (q : ℤ)^L * ((t i).val : ℤ) : ℤ) : ZMod (q^(L+1)))\n\ntheorem digitResidue_mem (q L : ℕ) (hq : 0 < q)\n    (x : Fin d → ℤ) (t : Fin d → ZMod q) :\n    ∀ i, (q : ℤ)^L ∣ ((digitResidue q L x t i).val : ℤ) - x i := by\n  let : NeZero (q^(L+1)) := ⟨pow_ne_zero _ (Nat.ne_of_gt hq)⟩\n  intro i\n  have heq : (((digitResidue q L x t i).val : ℤ) : ZMod (q^(L+1))) =\n      ((x i + (q : ℤ)^L * ((t i).val : ℤ) : ℤ) : ZMod (q^(L+1))) := by\n    simp [digitResidue]\n  have hlarge := (ZMod.intCast_eq_intCast_iff_dvd_sub _ _ (q^(L+1))).mp heq\n  rw [Nat.cast_pow] at hlarge\n  have hlower : (q : ℤ)^L ∣\n      (x i + (q : ℤ)^L * ((t i).val : ℤ)) - ((digitResidue q L x t i).val : ℤ) :=\n    dvd_trans (pow_dvd_pow (q : ℤ) (Nat.le_succ L)) hlarge\n  have hsum := dvd_sub (dvd_mul_right ((q : ℤ)^L) ((t i).val : ℤ)) hlower\n  have hid : (q : ℤ)^L * ((t i).val : ℤ) -\n      ((x i + (q : ℤ)^L * ((t i).val : ℤ)) - ((digitResidue q L x t i).val : ℤ)) =\n      ((digitResidue q L x t i).val : ℤ) - x i := by ring\n  rwa [hid] at hsum\n\ntheorem digitResidue_injective (q L : ℕ) (hq : 0 < q) (x : Fin d → ℤ) :\n    Function.Injective (digitResidue q L x) := by\n  let : NeZero q := ⟨Nat.ne_of_gt hq⟩\n  intro s t h\n  funext i\n  have hi := (shift_cast_eq_iff q L hq (x i)\n    ((s i).val : ℤ) ((t i).val : ℤ)).mp (congrFun h i)\n  simpa using hi\n\ntheorem digitResidue_surjective (q L : ℕ) (hq : 0 < q) (x : Fin d → ℤ)\n    (y : ResidueFiber q L x) :\n    ∃ t : Fin d → ZMod q, digitResidue q L x t = y.val := by\n  let : NeZero q := ⟨Nat.ne_of_gt hq⟩\n  let : NeZero (q^(L+1)) := ⟨pow_ne_zero _ (Nat.ne_of_gt hq)⟩\n  choose s hs using y.property\n  refine ⟨fun i => (s i : ZMod q), ?_⟩\n  funext i\n  have hi := (shift_cast_eq_iff q L hq (x i)\n    (((s i : ZMod q)).val : ℤ) (s i)).mpr (by simp)\n  change digitResidue q L x (fun i => (s i : ZMod q)) i = _ at hi\n  rw [hi]\n  have hy : x i + (q : ℤ)^L * s i = ((y.val i).val : ℤ) := by\n    have hh := hs i\n    exact (sub_eq_iff_eq_add'.mp hh).symm\n  rw [hy]\n  simp\n\n/-- All q^d correction digit vectors bijectively parametrize the actual\nnext-level residue vectors over x. Integer corrections themselves are not\ncounted: they have infinitely many representatives. -/\ndef digitEquivResidue (q L : ℕ) (hq : 0 < q) (x : Fin d → ℤ) :\n    (Fin d → ZMod q) ≃ ResidueFiber q L x :=\n  Equiv.ofBijective\n    (fun t => ⟨digitResidue q L x t, digitResidue_mem q L hq x t⟩)\n    ⟨fun _ _ h => digitResidue_injective q L hq x (congrArg Subtype.val h),\n      fun y => by\n        obtain ⟨t, ht⟩ := digitResidue_surjective q L hq x y\n        exact ⟨t, Subtype.ext ht⟩⟩\n\n@[simp] theorem digitEquivResidue_apply (q L : ℕ) (hq : 0 < q)\n    (x : Fin d → ℤ) (t : Fin d → ZMod q) :\n    (digitEquivResidue q L hq x t).val = digitResidue q L x t := rfl\n\n/-- The canonical representative of an actual digit residue differs from\nits shifted integer representative by a multiple of the full next modulus. -/\ntheorem next_modulus_dvd_val_sub_shift (q L : ℕ) (hq : 0 < q)\n    (x : Fin d → ℤ) (t : Fin d → ZMod q) (i : Fin d) :\n    (q : ℤ)^(L+1) ∣\n      (((digitEquivResidue q L hq x t).val i).val : ℤ) -\n        (x i + (q : ℤ)^L * ((t i).val : ℤ)) := by\n  let : NeZero (q^(L+1)) := ⟨pow_ne_zero _ (Nat.ne_of_gt hq)⟩\n  have heq : ((x i + (q : ℤ)^L * ((t i).val : ℤ) : ℤ) : ZMod (q^(L+1))) =\n      ((((digitEquivResidue q L hq x t).val i).val : ℤ) : ZMod (q^(L+1))) := by\n    simp [digitEquivResidue_apply, digitResidue]\n  have h := (ZMod.intCast_eq_intCast_iff_dvd_sub _ _ (q^(L+1))).mp heq\n  simpa only [Nat.cast_pow] using h\n\n/-- Exactly q^d distinct next residue vectors lie above each lower residue,\nincluding the degenerate modulus q=1 and the zero-dimensional case. -/\ntheorem residueFiber_card (q L : ℕ) (hq : 0 < q) (x : Fin d → ℤ) :\n    Nat.card (ResidueFiber q L x) = q^d := by\n  let : NeZero q := ⟨Nat.ne_of_gt hq⟩\n  rw [← Nat.card_congr (digitEquivResidue q L hq x)]\n  simp [Nat.card_eq_fintype_card]\n\n#print axioms shift_cast_eq_iff\n#print axioms ResidueFiber\n#print axioms digitResidue\n#print axioms digitResidue_mem\n#print axioms digitResidue_injective\n#print axioms digitResidue_surjective\n#print axioms digitEquivResidue\n#print axioms digitEquivResidue_apply\n#print axioms next_modulus_dvd_val_sub_shift\n#print axioms residueFiber_card\n\nend Komorebi.ResidueLiftDigits\n"}],"mathlib_manifest":"workspaces/paper-ix-residue-digits.json","download_plan":{"files":408,"bytes":356302387}},{"id":"paper-x-compactness","title":"Paper X · Compactness","work":"paper-x","files":[{"module":"PaperX.Compactness","path":"papers/paper-x/current/current_continuation/lean/PaperX/Compactness.lean","sha256":"0bd9169cb2b0efc4938e70d7f13d535fcdce0066f6d98d72602a5686e08663f2","inspect":"../../read/paper-x/compactness-8ad68d4946f8.html","download":"../../documents/files/7bdc9133d6509ea2e4e6f0a35938ce4333731a90/Compactness.lean","text":"import Std\n\n/-!\nFinite inverse-system compactness, proved from elementary finite-list reasoning.\nLevels need not have surjective transition maps. The proof uses classical choice.\nLevel 0 represents the manuscript's first residual level (m = 1).\n-/\nset_option autoImplicit false\nnamespace PaperX.Compactness\n\n/-- A finite family of downward-closed height predicates has an unbounded member\nif the family has witnesses at every height. -/\ntheorem finite_unbounded_choice {X : Type} (P : X → Nat → Prop)\n    (down : ∀ x i j, i ≤ j → P x j → P x i) (xs : List X)\n    (witnesses : ∀ h, ∃ x, x ∈ xs ∧ P x h) :\n    ∃ x, x ∈ xs ∧ ∀ h, P x h := by\n  classical\n  induction xs with\n  | nil =>\n    obtain ⟨x, hx, _⟩ := witnesses 0\n    simp at hx\n  | cons a xs ih =>\n    by_cases ha : ∀ h, P a h\n    · exact ⟨a, by simp, ha⟩\n    · have bad : ∃ k, ¬ P a k := Classical.not_forall.mp ha\n      obtain ⟨k, hk⟩ := bad\n      have tail : ∀ h, ∃ x, x ∈ xs ∧ P x h := by\n        intro h\n        obtain ⟨x, hx, hp⟩ := witnesses (k+h)\n        have hx' : x = a ∨ x ∈ xs := List.mem_cons.mp hx\n        rcases hx' with hxa | hxt\n        · subst x\n          exact False.elim (hk (down a k (k+h) (by omega) hp))\n        · exact ⟨x, hxt, down x h (k+h) (by omega) hp⟩\n      obtain ⟨x, hx, hp⟩ := ih tail\n      exact ⟨x, List.mem_cons_of_mem a hx, hp⟩\n\nstructure Tower where\n  Level : Nat → Type\n  parent : (n : Nat) → Level (n+1) → Level n\n\nstructure Branch (T : Tower) where\n  value : (n : Nat) → T.Level n\n  compatible : ∀ n, T.parent n (value (n+1)) = value n\n\n/-- Finiteness is supplied by a complete finite enumeration; repetitions are allowed. -/\ndef FiniteLevels (T : Tower) : Prop :=\n  ∀ n, ∃ xs : List (T.Level n), ∀ x, x ∈ xs\n\ndef Ext (T : Tower) (n : Nat) : Nat → T.Level n → Prop\n  | 0, _ => True\n  | h+1, x => ∃ y : T.Level (n+1), T.parent n y = x ∧ Ext T (n+1) h y\n\ndef Live (T : Tower) (n : Nat) (x : T.Level n) : Prop := ∀ h, Ext T n h x\n\ntheorem ext_step_down (T : Tower) (h : Nat) :\n    ∀ n (x : T.Level n), Ext T n (h+1) x → Ext T n h x := by\n  induction h with\n  | zero => intro n x _; trivial\n  | succ h ih =>\n    intro n x hx\n    obtain ⟨y, hy, he⟩ := hx\n    exact ⟨y, hy, ih (n+1) y he⟩\n\ntheorem ext_down (T : Tower) (n : Nat) (x : T.Level n)\n    (i j : Nat) (hij : i ≤ j) (hj : Ext T n j x) : Ext T n i x := by\n  induction j with\n  | zero =>\n    have hi : i = 0 := by omega\n    subst i\n    trivial\n  | succ j ih =>\n    by_cases heq : i = j+1\n    · simpa [heq] using hj\n    · exact ih (by omega) (ext_step_down T j n x hj)\n\ntheorem ext_somewhere (T : Tower) (nonempty : ∀ n, Nonempty (T.Level n))\n    (h : Nat) : ∀ n, ∃ x : T.Level n, Ext T n h x := by\n  induction h with\n  | zero =>\n    intro n\n    obtain ⟨x⟩ := nonempty n\n    exact ⟨x, trivial⟩\n  | succ h ih =>\n    intro n\n    obtain ⟨y, hy⟩ := ih (n+1)\n    exact ⟨T.parent n y, y, rfl, hy⟩\n\ntheorem live_somewhere (T : Tower) (finite : FiniteLevels T)\n    (nonempty : ∀ n, Nonempty (T.Level n)) (n : Nat) :\n    ∃ x : T.Level n, Live T n x := by\n  obtain ⟨xs, cover⟩ := finite n\n  have witnesses : ∀ h, ∃ x, x ∈ xs ∧ Ext T n h x := by\n    intro h\n    obtain ⟨x, hx⟩ := ext_somewhere T nonempty h n\n    exact ⟨x, cover x, hx⟩\n  obtain ⟨x, _, hx⟩ := finite_unbounded_choice (fun x h => Ext T n h x)\n    (fun x i j hij hj => ext_down T n x i j hij hj) xs witnesses\n  exact ⟨x, hx⟩\n\ntheorem live_child (T : Tower) (finite : FiniteLevels T)\n    (n : Nat) (x : T.Level n) (hx : Live T n x) :\n    ∃ y : T.Level (n+1), T.parent n y = x ∧ Live T (n+1) y := by\n  obtain ⟨xs, cover⟩ := finite (n+1)\n  let P : T.Level (n+1) → Nat → Prop :=\n    fun y h => T.parent n y = x ∧ Ext T (n+1) h y\n  have witnesses : ∀ h, ∃ y, y ∈ xs ∧ P y h := by\n    intro h\n    obtain ⟨y, hy, he⟩ := hx (h+1)\n    exact ⟨y, cover y, hy, he⟩\n  have down : ∀ y i j, i ≤ j → P y j → P y i := by\n    intro y i j hij hj\n    exact ⟨hj.1, ext_down T (n+1) y i j hij hj.2⟩\n  obtain ⟨y, _, hy⟩ := finite_unbounded_choice P down xs witnesses\n  exact ⟨y, (hy 0).1, fun h => (hy h).2⟩\n\nnoncomputable def chooseChild (T : Tower) (finite : FiniteLevels T)\n    (n : Nat) (x : {x : T.Level n // Live T n x}) :\n    {y : T.Level (n+1) // Live T (n+1) y} :=\n  ⟨Classical.choose (live_child T finite n x.1 x.2),\n    (Classical.choose_spec (live_child T finite n x.1 x.2)).2⟩\n\ntheorem chooseChild_parent (T : Tower) (finite : FiniteLevels T)\n    (n : Nat) (x : {x : T.Level n // Live T n x}) :\n    T.parent n (chooseChild T finite n x).1 = x.1 :=\n  (Classical.choose_spec (live_child T finite n x.1 x.2)).1\n\nnoncomputable def branchNode (T : Tower) (finite : FiniteLevels T)\n    (start : {x : T.Level 0 // Live T 0 x}) :\n    (n : Nat) → {x : T.Level n // Live T n x}\n  | 0 => start\n  | n+1 => chooseChild T finite n (branchNode T finite start n)\n\n/-- A finite nonempty tower of sets with total reduction maps has a compatible branch. -/\ntheorem finite_branch_compactness (T : Tower) (finite : FiniteLevels T)\n    (nonempty : ∀ n, Nonempty (T.Level n)) : Nonempty (Branch T) := by\n  classical\n  obtain ⟨x, hx⟩ := live_somewhere T finite nonempty 0\n  let start : {x : T.Level 0 // Live T 0 x} := ⟨x, hx⟩\n  exact ⟨{\n    value := fun n => (branchNode T finite start n).1\n    compatible := fun n => chooseChild_parent T finite n (branchNode T finite start n)\n  }⟩\n\n/-- Any empty level prevents completion, not only an empty residual level. -/\ntheorem empty_level_obstruction (T : Tower) (n : Nat)\n    (empty : ¬ Nonempty (T.Level n)) : ¬ Nonempty (Branch T) := by\n  rintro ⟨b⟩\n  exact empty ⟨b.value n⟩\n\n/-- For finite levels, arbitrary-depth nonemptiness is equivalent to branch existence. -/\ntheorem branch_iff_levels_nonempty (T : Tower) (finite : FiniteLevels T) :\n    Nonempty (Branch T) ↔ ∀ n, Nonempty (T.Level n) := by\n  constructor\n  · rintro ⟨b⟩ n\n    exact ⟨b.value n⟩\n  · exact finite_branch_compactness T finite\n\n/-- Choice can assemble one compatible branch per index, without asserting that\nany of the level-nonemptiness hypotheses is automatically satisfied. -/\ntheorem indexed_finite_completion {I : Type} (T : I → Tower)\n    (finite : ∀ i, FiniteLevels (T i))\n    (nonempty : ∀ i n, Nonempty ((T i).Level n)) :\n    Nonempty ((i : I) → Branch (T i)) := by\n  classical\n  exact ⟨fun i => Classical.choice (finite_branch_compactness (T i) (finite i) (nonempty i))⟩\n\n/-- One missing level in one required tower prevents an indexed completion. -/\ntheorem indexed_empty_level_obstruction {I : Type} (T : I → Tower)\n    (i : I) (n : Nat) (empty : ¬ Nonempty ((T i).Level n)) :\n    ¬ Nonempty ((j : I) → Branch (T j)) := by\n  rintro ⟨b⟩\n  exact empty ⟨(b i).value n⟩\n\nend PaperX.Compactness\n"}],"download_plan":{"files":386,"bytes":215208083}},{"id":"paper-x-idempotent-newton","title":"Paper X · Idempotent Newton step","work":"paper-x","files":[{"module":"PaperX.IdempotentNewton","path":"papers/paper-x/current/current_continuation/lean/PaperX/IdempotentNewton.lean","sha256":"1323b96acd55f5f8ec9eded65cc586155e846ede01705279ea113db26232b2e6","inspect":"../../read/paper-x/idempotentnewton-9dee0eb97cd8.html","download":"../../documents/files/7429cc53a19038933ce49729a8c219b2dd88e13f/IdempotentNewton.lean","text":"import Mathlib.Tactic.NoncommRing\nimport Mathlib.Algebra.Ring.Hom.Defs\nimport Mathlib.Algebra.Ring.Nat\nimport Mathlib.Tactic.NormNum\n\n/-! Polynomial correction of an approximate idempotent in a possibly\nnoncommutative ring. No inverse of two is needed. -/\nset_option autoImplicit false\n\nnamespace PaperX.IdempotentNewton\n\nvariable {A B : Type*} [Ring A] [Ring B]\n\n/-- The universal integral polynomial used to correct an idempotent. -/\ndef correct (a : A) : A := 3 * a ^ 2 - 2 * a ^ 3\n\n/-- The correction changes the input by a multiple of its idempotence error. -/\ntheorem correct_sub (a : A) :\n    correct a - a = -(2 * a - 1) * (a ^ 2 - a) := by\n  unfold correct\n  simp only [show (2 : A) = 1 + 1 by norm_num,\n    show (3 : A) = 1 + 1 + 1 by norm_num]\n  noncomm_ring\n\n/-- One correction squares the idempotence error. -/\ntheorem correct_error (a : A) :\n    correct a ^ 2 - correct a =\n      (a ^ 2 - a) ^ 2 * (4 * a ^ 2 - 4 * a - 3) := by\n  unfold correct\n  simp only [show (2 : A) = 1 + 1 by norm_num,\n    show (3 : A) = 1 + 1 + 1 by norm_num,\n    show (4 : A) = 1 + 1 + 1 + 1 by norm_num]\n  noncomm_ring\n\n/-- Polynomial correction fixes exact idempotents. -/\ntheorem correct_eq_of_idempotent (a : A) (ha : a * a = a) :\n    correct a = a := by\n  have hz : a ^ 2 - a = 0 := by simp [pow_two, ha]\n  have hd := correct_sub a\n  rw [hz, mul_zero, sub_eq_zero] at hd\n  exact hd\n\n/-- Correction commutes with every unital ring homomorphism. -/\ntheorem map_correct (f : A →+* B) (a : A) :\n    f (correct a) = correct (f a) := by\n  unfold correct\n  rw [show (2 : A) = 1 + 1 by norm_num,\n    show (3 : A) = 1 + 1 + 1 by norm_num]\n  simp only [map_sub, map_mul, map_pow, map_add, map_one]\n  norm_num\n\n/-- If one matrix intertwines two endomorphisms, it intertwines their powers. -/\ntheorem pow_intertwines (a b p : A) (h : a * p = p * b) (n : ℕ) :\n    a ^ n * p = p * b ^ n := by\n  induction n with\n  | zero => simp\n  | succ n hn =>\n      rw [pow_succ', mul_assoc, hn, ← mul_assoc, h, mul_assoc, ← pow_succ']\n\n/-- Polynomial correction preserves every supplied intertwiner. -/\ntheorem correct_intertwines (a b p : A) (h : a * p = p * b) :\n    correct a * p = p * correct b := by\n  have h2 := pow_intertwines a b p h 2\n  have h3 := pow_intertwines a b p h 3\n  unfold correct\n  calc\n    (3 * a ^ 2 - 2 * a ^ 3) * p =\n        3 * (a ^ 2 * p) - 2 * (a ^ 3 * p) := by simp only [sub_mul, mul_assoc]\n    _ = 3 * (p * b ^ 2) - 2 * (p * b ^ 3) := by rw [h2, h3]\n    _ = p * (3 * b ^ 2 - 2 * b ^ 3) := by\n      simp only [show (2 : A) = 1 + 1 by norm_num,\n        show (3 : A) = 1 + 1 + 1 by norm_num]\n      noncomm_ring\n\nend PaperX.IdempotentNewton\n"}],"mathlib_manifest":"workspaces/paper-x-idempotent-newton.json","download_plan":{"files":408,"bytes":356176706}},{"id":"paper-xi-heisenberg","title":"Paper XI · Heisenberg form","work":"paper-xi","files":[{"module":"PaperXI.HeisenbergForm","path":"papers/paper-xi/current/formalization/PaperXI/HeisenbergForm.lean","sha256":"b9d055bf58ee5326c45c49e9267dcd9b113d6b1d2b3f0f82d5e7cd909890230c","inspect":"../../read/paper-xi/heisenbergform-e328f74be3b0.html","download":"../../documents/files/c431bebec0daac965398353cc7bc1b82f58a5c0b/HeisenbergForm.lean","text":"import Mathlib.LinearAlgebra.Dual.Defs\nimport Mathlib.LinearAlgebra.BilinearMap\nimport Mathlib.LinearAlgebra.Prod\nimport Mathlib.Tactic.Ring\n\n/-! The manuscript's standard alternating form on X plus its linear dual. -/\nset_option autoImplicit false\nnoncomputable section\nnamespace PaperXI.HeisenbergForm\n\nvariable {K X : Type*} [Field K] [AddCommGroup X] [Module K X]\n\ndef form : (X × Module.Dual K X) →ₗ[K] (X × Module.Dual K X) →ₗ[K] K where\n  toFun v :=\n    { toFun := fun w => w.2 v.1 - v.2 w.1\n      map_add' := by\n        intro w t\n        simp only [Prod.fst_add, Prod.snd_add, LinearMap.add_apply, map_add]\n        ring\n      map_smul' := by\n        intro a w\n        change (a • w.2) v.1 - v.2 (a • w.1) = a • (w.2 v.1 - v.2 w.1)\n        simp only [LinearMap.smul_apply, map_smul, smul_eq_mul]\n        ring }\n  map_add' := by\n    intro v w\n    apply LinearMap.ext\n    intro t\n    change t.2 (v + w).1 - (v + w).2 t.1 =\n      (t.2 v.1 - v.2 t.1) + (t.2 w.1 - w.2 t.1)\n    simp only [Prod.fst_add, Prod.snd_add, LinearMap.add_apply, map_add]\n    ring\n  map_smul' := by\n    intro a v\n    apply LinearMap.ext\n    intro w\n    change w.2 (a • v.1) - (a • v.2) w.1 = a • (w.2 v.1 - v.2 w.1)\n    simp only [LinearMap.smul_apply, map_smul, smul_eq_mul]\n    ring\n\n@[simp] theorem form_apply (v w : X × Module.Dual K X) :\n    form v w = w.2 v.1 - v.2 w.1 := rfl\n\ntheorem form_self (v : X × Module.Dual K X) : form v v = 0 := by\n  simp\n\ntheorem form_skew (v w : X × Module.Dual K X) : form v w = -form w v := by\n  simp\n\nend PaperXI.HeisenbergForm\n"}],"mathlib_manifest":"workspaces/paper-xi-heisenberg.json","download_plan":{"files":408,"bytes":356288357}},{"id":"paper-xi-one-plus-index","title":"Paper XI · One-plus index","work":"paper-xi","files":[{"module":"PaperXI.OnePlusIndex110","path":"papers/paper-xi/current/formalization/PaperXI/OnePlusIndex110.lean","sha256":"733e4888e34cb2eec83dd8b0d29ea395d269e9caa209f00d1fb751c61563ef49","inspect":"../../read/paper-xi/oneplusindex110-6aff06b68abb.html","download":"../../documents/files/36f8c54ede36c74246f0bca1525388daaba50ed1/OnePlusIndex110.lean","text":"import Mathlib.GroupTheory.Index\nimport Mathlib.RingTheory.Ideal.Basic\nimport Mathlib.Logic.Equiv.Defs\nimport Mathlib.Tactic.NoncommRing\n\n/-! Exact multiplicative/additive coset comparison. The named unit subgroup K\nmust really consist of all units 1+x for x in L. This does not pretend that\nan arbitrary full lattice contained in a radical automatically is a group. -/\nset_option autoImplicit false\nnoncomputable section\nnamespace PaperXI.OnePlusIndex110\n\nvariable {R : Type*} [Ring R]\n\ndef congruence (I : Ideal R) (K : Subgroup Rˣ) : Subgroup K where\n  carrier := {g | ((g : Rˣ) : R) - 1 ∈ I}\n  one_mem' := by simp\n  mul_mem' := by\n    intro a b ha hb\n    change (((a : Rˣ) : R) * ((b : Rˣ) : R)) - 1 ∈ I\n    have he : (((a : Rˣ) : R) * ((b : Rˣ) : R)) - 1 =\n        ((a : Rˣ) : R) * (((b : Rˣ) : R) - 1) + (((a : Rˣ) : R) - 1) := by noncomm_ring\n    rw [he]\n    exact I.add_mem (I.mul_mem_left _ hb) ha\n  inv_mem' := by\n    intro a ha\n    change (((a : Rˣ)⁻¹ : Rˣ) : R) - 1 ∈ I\n    have he : (((a : Rˣ)⁻¹ : Rˣ) : R) - 1 =\n        -((((a : Rˣ)⁻¹ : Rˣ) : R) * (((a : Rˣ) : R) - 1)) := by\n      rw [mul_sub, Units.inv_mul, mul_one]\n      abel\n    rw [he]\n    exact I.neg_mem (I.mul_mem_left _ ha)\n\ndef offsetEquiv (L : AddSubgroup R) (K : Subgroup Rˣ)\n    (hK : ∀ g : K, ((g : Rˣ) : R) - 1 ∈ L)\n    (hL : ∀ x : L, ∃ g : K, ((g : Rˣ) : R) = 1 + (x : R)) : K ≃ L :=\n  Equiv.ofBijective (fun g => ⟨((g : Rˣ) : R) - 1, hK g⟩) (by\n    constructor\n    · intro a b hab\n      apply Subtype.ext\n      apply Units.ext\n      have he := congrArg (fun x : L => (x : R)) hab\n      exact sub_left_injective he\n    · intro x\n      obtain ⟨g, hg⟩ := hL x\n      refine ⟨g, Subtype.ext ?_⟩\n      change ((g : Rˣ) : R) - 1 = (x : R)\n      rw [hg]\n      abel)\n\ntheorem inv_mul_sub_one_mem_iff (I : Ideal R) (a b : Rˣ) :\n    (((a⁻¹ * b : Rˣ) : R) - 1 ∈ I) ↔ ((b : R) - (a : R) ∈ I) := by\n  have hleft : ((a⁻¹ * b : Rˣ) : R) - 1 = (↑a⁻¹ : R) * ((b : R) - (a : R)) := by\n    rw [mul_sub, Units.inv_mul]\n    rfl\n  have hright : (b : R) - (a : R) = (a : R) * (((a⁻¹ * b : Rˣ) : R) - 1) := by\n    rw [mul_sub, Units.val_mul, ← mul_assoc, Units.mul_inv, one_mul, mul_one]\n  constructor\n  · intro h\n    rw [hright]\n    exact I.mul_mem_left _ h\n  · intro h\n    rw [hleft]\n    exact I.mul_mem_left _ h\n\ndef cosetEquiv (I : Ideal R) (L : AddSubgroup R) (K : Subgroup Rˣ)\n    (hK : ∀ g : K, ((g : Rˣ) : R) - 1 ∈ L)\n    (hL : ∀ x : L, ∃ g : K, ((g : Rˣ) : R) = 1 + (x : R)) :\n    (K ⧸ congruence I K) ≃ (L ⧸ I.toAddSubgroup.addSubgroupOf L) :=\n  Quotient.congr (offsetEquiv L K hK hL) (by\n    intro a b\n    rw [QuotientGroup.leftRel_apply, QuotientAddGroup.leftRel_apply]\n    change (((((a : Rˣ)⁻¹) * (b : Rˣ)) : R) - 1 ∈ I) ↔\n      (-(((a : Rˣ) : R) - 1) + (((b : Rˣ) : R) - 1) ∈ I)\n    have he : -(((a : Rˣ) : R) - 1) + (((b : Rˣ) : R) - 1) =\n        ((b : Rˣ) : R) - ((a : Rˣ) : R) := by abel\n    rw [he]\n    exact inv_mul_sub_one_mem_iff I (a : Rˣ) (b : Rˣ))\n\ntheorem index_eq_additive_relIndex (I : Ideal R) (L : AddSubgroup R) (K : Subgroup Rˣ)\n    (hK : ∀ g : K, ((g : Rˣ) : R) - 1 ∈ L)\n    (hL : ∀ x : L, ∃ g : K, ((g : Rˣ) : R) = 1 + (x : R)) :\n    (congruence I K).index = I.toAddSubgroup.relIndex L :=\n  Nat.card_congr (cosetEquiv I L K hK hL)\n\nend PaperXI.OnePlusIndex110\n"}],"mathlib_manifest":"workspaces/paper-xi-one-plus-index.json","download_plan":{"files":408,"bytes":356350760}},{"id":"paper-xii-compactness","title":"Paper XII · Retained compactness module","work":"paper-xii","files":[{"module":"PaperXII.ReuseCompactness","path":"papers/paper-xii/current/core/publication/source/lean_guide/formal_release/lean/PaperXII/ReuseCompactness.lean","sha256":"0bd9169cb2b0efc4938e70d7f13d535fcdce0066f6d98d72602a5686e08663f2","inspect":"../../read/paper-xii/reusecompactness-e0e60d0de83b.html","download":"../../documents/files/7bdc9133d6509ea2e4e6f0a35938ce4333731a90/ReuseCompactness.lean","text":"import Std\n\n/-!\nFinite inverse-system compactness, proved from elementary finite-list reasoning.\nLevels need not have surjective transition maps. The proof uses classical choice.\nLevel 0 represents the manuscript's first residual level (m = 1).\n-/\nset_option autoImplicit false\nnamespace PaperX.Compactness\n\n/-- A finite family of downward-closed height predicates has an unbounded member\nif the family has witnesses at every height. -/\ntheorem finite_unbounded_choice {X : Type} (P : X → Nat → Prop)\n    (down : ∀ x i j, i ≤ j → P x j → P x i) (xs : List X)\n    (witnesses : ∀ h, ∃ x, x ∈ xs ∧ P x h) :\n    ∃ x, x ∈ xs ∧ ∀ h, P x h := by\n  classical\n  induction xs with\n  | nil =>\n    obtain ⟨x, hx, _⟩ := witnesses 0\n    simp at hx\n  | cons a xs ih =>\n    by_cases ha : ∀ h, P a h\n    · exact ⟨a, by simp, ha⟩\n    · have bad : ∃ k, ¬ P a k := Classical.not_forall.mp ha\n      obtain ⟨k, hk⟩ := bad\n      have tail : ∀ h, ∃ x, x ∈ xs ∧ P x h := by\n        intro h\n        obtain ⟨x, hx, hp⟩ := witnesses (k+h)\n        have hx' : x = a ∨ x ∈ xs := List.mem_cons.mp hx\n        rcases hx' with hxa | hxt\n        · subst x\n          exact False.elim (hk (down a k (k+h) (by omega) hp))\n        · exact ⟨x, hxt, down x h (k+h) (by omega) hp⟩\n      obtain ⟨x, hx, hp⟩ := ih tail\n      exact ⟨x, List.mem_cons_of_mem a hx, hp⟩\n\nstructure Tower where\n  Level : Nat → Type\n  parent : (n : Nat) → Level (n+1) → Level n\n\nstructure Branch (T : Tower) where\n  value : (n : Nat) → T.Level n\n  compatible : ∀ n, T.parent n (value (n+1)) = value n\n\n/-- Finiteness is supplied by a complete finite enumeration; repetitions are allowed. -/\ndef FiniteLevels (T : Tower) : Prop :=\n  ∀ n, ∃ xs : List (T.Level n), ∀ x, x ∈ xs\n\ndef Ext (T : Tower) (n : Nat) : Nat → T.Level n → Prop\n  | 0, _ => True\n  | h+1, x => ∃ y : T.Level (n+1), T.parent n y = x ∧ Ext T (n+1) h y\n\ndef Live (T : Tower) (n : Nat) (x : T.Level n) : Prop := ∀ h, Ext T n h x\n\ntheorem ext_step_down (T : Tower) (h : Nat) :\n    ∀ n (x : T.Level n), Ext T n (h+1) x → Ext T n h x := by\n  induction h with\n  | zero => intro n x _; trivial\n  | succ h ih =>\n    intro n x hx\n    obtain ⟨y, hy, he⟩ := hx\n    exact ⟨y, hy, ih (n+1) y he⟩\n\ntheorem ext_down (T : Tower) (n : Nat) (x : T.Level n)\n    (i j : Nat) (hij : i ≤ j) (hj : Ext T n j x) : Ext T n i x := by\n  induction j with\n  | zero =>\n    have hi : i = 0 := by omega\n    subst i\n    trivial\n  | succ j ih =>\n    by_cases heq : i = j+1\n    · simpa [heq] using hj\n    · exact ih (by omega) (ext_step_down T j n x hj)\n\ntheorem ext_somewhere (T : Tower) (nonempty : ∀ n, Nonempty (T.Level n))\n    (h : Nat) : ∀ n, ∃ x : T.Level n, Ext T n h x := by\n  induction h with\n  | zero =>\n    intro n\n    obtain ⟨x⟩ := nonempty n\n    exact ⟨x, trivial⟩\n  | succ h ih =>\n    intro n\n    obtain ⟨y, hy⟩ := ih (n+1)\n    exact ⟨T.parent n y, y, rfl, hy⟩\n\ntheorem live_somewhere (T : Tower) (finite : FiniteLevels T)\n    (nonempty : ∀ n, Nonempty (T.Level n)) (n : Nat) :\n    ∃ x : T.Level n, Live T n x := by\n  obtain ⟨xs, cover⟩ := finite n\n  have witnesses : ∀ h, ∃ x, x ∈ xs ∧ Ext T n h x := by\n    intro h\n    obtain ⟨x, hx⟩ := ext_somewhere T nonempty h n\n    exact ⟨x, cover x, hx⟩\n  obtain ⟨x, _, hx⟩ := finite_unbounded_choice (fun x h => Ext T n h x)\n    (fun x i j hij hj => ext_down T n x i j hij hj) xs witnesses\n  exact ⟨x, hx⟩\n\ntheorem live_child (T : Tower) (finite : FiniteLevels T)\n    (n : Nat) (x : T.Level n) (hx : Live T n x) :\n    ∃ y : T.Level (n+1), T.parent n y = x ∧ Live T (n+1) y := by\n  obtain ⟨xs, cover⟩ := finite (n+1)\n  let P : T.Level (n+1) → Nat → Prop :=\n    fun y h => T.parent n y = x ∧ Ext T (n+1) h y\n  have witnesses : ∀ h, ∃ y, y ∈ xs ∧ P y h := by\n    intro h\n    obtain ⟨y, hy, he⟩ := hx (h+1)\n    exact ⟨y, cover y, hy, he⟩\n  have down : ∀ y i j, i ≤ j → P y j → P y i := by\n    intro y i j hij hj\n    exact ⟨hj.1, ext_down T (n+1) y i j hij hj.2⟩\n  obtain ⟨y, _, hy⟩ := finite_unbounded_choice P down xs witnesses\n  exact ⟨y, (hy 0).1, fun h => (hy h).2⟩\n\nnoncomputable def chooseChild (T : Tower) (finite : FiniteLevels T)\n    (n : Nat) (x : {x : T.Level n // Live T n x}) :\n    {y : T.Level (n+1) // Live T (n+1) y} :=\n  ⟨Classical.choose (live_child T finite n x.1 x.2),\n    (Classical.choose_spec (live_child T finite n x.1 x.2)).2⟩\n\ntheorem chooseChild_parent (T : Tower) (finite : FiniteLevels T)\n    (n : Nat) (x : {x : T.Level n // Live T n x}) :\n    T.parent n (chooseChild T finite n x).1 = x.1 :=\n  (Classical.choose_spec (live_child T finite n x.1 x.2)).1\n\nnoncomputable def branchNode (T : Tower) (finite : FiniteLevels T)\n    (start : {x : T.Level 0 // Live T 0 x}) :\n    (n : Nat) → {x : T.Level n // Live T n x}\n  | 0 => start\n  | n+1 => chooseChild T finite n (branchNode T finite start n)\n\n/-- A finite nonempty tower of sets with total reduction maps has a compatible branch. -/\ntheorem finite_branch_compactness (T : Tower) (finite : FiniteLevels T)\n    (nonempty : ∀ n, Nonempty (T.Level n)) : Nonempty (Branch T) := by\n  classical\n  obtain ⟨x, hx⟩ := live_somewhere T finite nonempty 0\n  let start : {x : T.Level 0 // Live T 0 x} := ⟨x, hx⟩\n  exact ⟨{\n    value := fun n => (branchNode T finite start n).1\n    compatible := fun n => chooseChild_parent T finite n (branchNode T finite start n)\n  }⟩\n\n/-- Any empty level prevents completion, not only an empty residual level. -/\ntheorem empty_level_obstruction (T : Tower) (n : Nat)\n    (empty : ¬ Nonempty (T.Level n)) : ¬ Nonempty (Branch T) := by\n  rintro ⟨b⟩\n  exact empty ⟨b.value n⟩\n\n/-- For finite levels, arbitrary-depth nonemptiness is equivalent to branch existence. -/\ntheorem branch_iff_levels_nonempty (T : Tower) (finite : FiniteLevels T) :\n    Nonempty (Branch T) ↔ ∀ n, Nonempty (T.Level n) := by\n  constructor\n  · rintro ⟨b⟩ n\n    exact ⟨b.value n⟩\n  · exact finite_branch_compactness T finite\n\n/-- Choice can assemble one compatible branch per index, without asserting that\nany of the level-nonemptiness hypotheses is automatically satisfied. -/\ntheorem indexed_finite_completion {I : Type} (T : I → Tower)\n    (finite : ∀ i, FiniteLevels (T i))\n    (nonempty : ∀ i n, Nonempty ((T i).Level n)) :\n    Nonempty ((i : I) → Branch (T i)) := by\n  classical\n  exact ⟨fun i => Classical.choice (finite_branch_compactness (T i) (finite i) (nonempty i))⟩\n\n/-- One missing level in one required tower prevents an indexed completion. -/\ntheorem indexed_empty_level_obstruction {I : Type} (T : I → Tower)\n    (i : I) (n : Nat) (empty : ¬ Nonempty ((T i).Level n)) :\n    ¬ Nonempty ((j : I) → Branch (T j)) := by\n  rintro ⟨b⟩\n  exact empty ⟨(b i).value n⟩\n\nend PaperX.Compactness\n"}],"download_plan":{"files":386,"bytes":215208083}},{"id":"komorebi-space-projective","title":"Komorebi Space · Projective example","work":"komorebi-space","files":[{"module":"KomorebiSpace.ProjectiveExample","path":"monographs/komorebi-space/lean/KomorebiSpace/ProjectiveExample.lean","sha256":"408d4ee8346ecb89ad99abc1636066eef90d2c01a0cd6f07df0630f8aafd8df4","inspect":"../../read/komorebi-space/projectiveexample-06083abdb1ca.html","download":"../../documents/files/38e7f24e6d05ba028598585458d9e99c77112f73/ProjectiveExample.lean","text":"import Mathlib.Data.ZMod.Basic\nimport Mathlib.Tactic.Ring\nimport Mathlib.Tactic.NormNum\n\nset_option autoImplicit false\n\n/-!\n# A nontrivial cocycle model\n\nFor G = (Z/2Z)^2, c(x,y) = x₂ y₁ is an additive Z/2Z-valued 2-cocycle.\nIt cannot be a scalar coboundary: scalar coboundaries on an abelian group are\nsymmetric, while this cocycle is not. This is a finite exact obstruction model,\nnot a theorem identifying any Galois group or proving Langlands descent.\n-/\nnamespace KomorebiSpace\nnamespace ProjectiveExample\nabbrev G := (ZMod 2) × (ZMod 2)\n\ndef phase (x y : G) : ZMod 2 := x.2 * y.1\n\n@[simp] theorem phase_zero_left (y : G) : phase 0 y = 0 := by simp [phase]\n@[simp] theorem phase_zero_right (x : G) : phase x 0 = 0 := by simp [phase]\n\ntheorem cocycle (x y z : G) :\n    phase x y + phase (x+y) z = phase y z + phase x (y+z) := by\n  simp only [phase, Prod.fst_add, Prod.snd_add]\n  ring\n\ndef coboundary (a : G → ZMod 2) (x y : G) : ZMod 2 := a x + a y - a (x+y)\n\ntheorem coboundary_symmetric (a : G → ZMod 2) (x y : G) :\n    coboundary a x y = coboundary a y x := by\n  unfold coboundary\n  rw [add_comm x y, add_comm (a x) (a y)]\n\ntheorem phase_asymmetric : phase (1,0) (0,1) ≠ phase (0,1) (1,0) := by\n  norm_num [phase]\n\ntheorem no_scalar_flattening : ¬ ∃ a : G → ZMod 2, ∀ x y, phase x y = coboundary a x y := by\n  rintro ⟨a, ha⟩\n  apply phase_asymmetric\n  rw [ha, ha, coboundary_symmetric]\nend ProjectiveExample\nend KomorebiSpace\n"}],"mathlib_manifest":"workspaces/komorebi-space-projective.json","download_plan":{"files":408,"bytes":356312168}},{"id":"komorebi-space-correction","title":"Komorebi Space · Correction","work":"komorebi-space","files":[{"module":"KomorebiSpace.Correction","path":"monographs/komorebi-space/lean/KomorebiSpace/Correction.lean","sha256":"089d9155e0a43f6606a290fd88e56e6deff657ae3d97769cec8070ff7d8f90d7","inspect":"../../read/komorebi-space/correction-4e251334bcc1.html","download":"../../documents/files/d842371d610a65bbf0d2168b93f3b0d4e3a4960d/Correction.lean","text":"import Mathlib.GroupTheory.QuotientGroup.Basic\nimport Mathlib.Data.Int.Basic\n\nset_option autoImplicit false\n\n/-!\n# Semantic constraints and a genuine obstruction quotient\n\nA raw linear defect d(f) is always removable by subtracting f. A nontrivial\nproblem must restrict admissible corrections. Here p records semantics and\ncorrections must lie in ker p. The obstruction is [d(f)] in R / d(ker p).\n-/\nuniverse u v w z\nnamespace KomorebiSpace\n\nstructure CorrectionProblem (E : Type u) (R : Type v) (S : Type w)\n    [AddCommGroup E] [AddCommGroup R] [AddCommGroup S] where\n  residual : E →+ R\n  semantics : E →+ S\n\nnamespace CorrectionProblem\nvariable {E : Type u} {R : Type v} {S : Type w}\nvariable [AddCommGroup E] [AddCommGroup R] [AddCommGroup S]\n\ndef boundaries (P : CorrectionProblem E R S) : AddSubgroup R :=\n  P.semantics.ker.map P.residual\n\nabbrev Obstruction (P : CorrectionProblem E R S) := R ⧸ P.boundaries\n\ndef obstruction (P : CorrectionProblem E R S) (x : E) : P.Obstruction :=\n  (P.residual x : R ⧸ P.boundaries)\n\n/-- Quotient vanishing is precisely solvability by an admissible correction. -/\ntheorem obstruction_zero_iff (P : CorrectionProblem E R S) (x : E) :\n    P.obstruction x = 0 ↔\n      ∃ a : E, P.semantics a = 0 ∧ P.residual a = P.residual x := by\n  change (P.residual x : R ⧸ P.boundaries) = 0 ↔ _\n  rw [QuotientAddGroup.eq_zero_iff]\n  rfl\n\n/-- Main constrained exactification equivalence, with semantics preserved. -/\ntheorem flatten_iff (P : CorrectionProblem E R S) (x : E) :\n    P.obstruction x = 0 ↔\n      ∃ y : E, P.residual y = 0 ∧ P.semantics y = P.semantics x := by\n  rw [P.obstruction_zero_iff]\n  constructor\n  · rintro ⟨a, ha, hd⟩\n    refine ⟨x-a, ?_, ?_⟩\n    · rw [map_sub, hd, sub_self]\n    · rw [map_sub, ha, sub_zero]\n  · rintro ⟨y, hy, hs⟩\n    refine ⟨x-y, ?_, ?_⟩\n    · rw [map_sub, hs, sub_self]\n    · rw [map_sub, hy, sub_zero]\n\ntheorem obstruction_invariant (P : CorrectionProblem E R S) (x a : E)\n    (ha : P.semantics a = 0) : P.obstruction (x-a) = P.obstruction x := by\n  have hz : (P.residual a : R ⧸ P.boundaries) = 0 :=\n    (QuotientAddGroup.eq_zero_iff _).2 ⟨a, ha, rfl⟩\n  change (P.residual (x-a) : R ⧸ P.boundaries) = (P.residual x : R ⧸ P.boundaries)\n  rw [map_sub, QuotientAddGroup.mk_sub, hz, sub_zero]\n\n/-- A dual witness rules out every semantics-preserving exact correction. -/\ntheorem nonzero_certificate (P : CorrectionProblem E R S)\n    {D : Type z} [AddCommGroup D] (L : R →+ D) (x : E)\n    (annihilate : ∀ a, P.semantics a = 0 → L (P.residual a) = 0)\n    (witness : L (P.residual x) ≠ 0) : P.obstruction x ≠ 0 := by\n  intro h\n  rcases (P.obstruction_zero_iff x).1 h with ⟨a, ha, he⟩\n  apply witness\n  rw [← he]\n  exact annihilate a ha\n\n/-- With no semantic restriction every linear primary defect is correctable. -/\ntheorem unrestricted_correction (d : E →+ R) (x : E) :\n    ∃ a : E, d x - d a = 0 := ⟨x, sub_self _⟩\n\n/-- An explicit nontrivial model: the residual itself is the protected semantics. -/\ndef rigidInteger : CorrectionProblem ℤ ℤ ℤ :=\n  ⟨AddMonoidHom.id ℤ, AddMonoidHom.id ℤ⟩\n\ntheorem rigid_one_obstructed : rigidInteger.obstruction 1 ≠ 0 := by\n  intro h\n  have hx := (rigidInteger.flatten_iff 1).1 h\n  change ∃ y : ℤ, y = 0 ∧ y = 1 at hx\n  obtain ⟨y, h0, h1⟩ := hx\n  omega\n\nend CorrectionProblem\nend KomorebiSpace\n"}],"mathlib_manifest":"workspaces/komorebi-space-correction.json","download_plan":{"files":408,"bytes":356211192}},{"id":"komorebi-space-cohomology","title":"Komorebi Space · Cohomology","work":"komorebi-space","files":[{"module":"KomorebiSpace.Cohomology","path":"monographs/komorebi-space/lean/KomorebiSpace/Cohomology.lean","sha256":"2ea9c62b6bbbb789fdf27e27c9363aa46b85981d6798e2daf5e6173d3e251f4b","inspect":"../../read/komorebi-space/cohomology-67bc5315e40c.html","download":"../../documents/files/97ef5cd409b3674f134fc61ddd916e66404d36fe/Cohomology.lean","text":"import Mathlib.GroupTheory.QuotientGroup.Basic\nimport Mathlib.Tactic.Abel\n\nset_option autoImplicit false\n\n/-!\n# The additive obstruction sector\n\nC¹ --δ₁--> C² --δ₂--> C³ with δ₂δ₁ = 0.\nNo assertion is made that arbitrary categorical square defects automatically\nform such a complex. An application must supply and verify this structure.\n-/\nuniverse u v w z\nnamespace KomorebiSpace\n\nstructure ObstructionComplex (A : Type u) (B : Type v) (C : Type w)\n    [AddCommGroup A] [AddCommGroup B] [AddCommGroup C] where\n  d₁ : A →+ B\n  d₂ : B →+ C\n  square_zero : ∀ a, d₂ (d₁ a) = 0\n\nnamespace ObstructionComplex\nvariable {A : Type u} {B : Type v} {C : Type w}\nvariable [AddCommGroup A] [AddCommGroup B] [AddCommGroup C]\n\nabbrev Cycles (K : ObstructionComplex A B C) := K.d₂.ker\n\ndef boundaryMap (K : ObstructionComplex A B C) : A →+ K.Cycles where\n  toFun := fun a => ⟨K.d₁ a, K.square_zero a⟩\n  map_zero' := by apply Subtype.ext; exact map_zero K.d₁\n  map_add' := by intro a b; apply Subtype.ext; exact map_add K.d₁ a b\n\nabbrev H2 (K : ObstructionComplex A B C) := K.Cycles ⧸ K.boundaryMap.range\n\ndef obstructionClass (K : ObstructionComplex A B C) (ω : K.Cycles) : K.H2 :=\n  (ω : K.Cycles ⧸ K.boundaryMap.range)\n\ntheorem class_zero_iff (K : ObstructionComplex A B C) (ω : K.Cycles) :\n    K.obstructionClass ω = 0 ↔ ∃ a, K.d₁ a = ω.val := by\n  change (ω : K.Cycles ⧸ K.boundaryMap.range) = 0 ↔ _\n  rw [QuotientAddGroup.eq_zero_iff]\n  constructor\n  · rintro ⟨a, ha⟩\n    exact ⟨a, congrArg Subtype.val ha⟩\n  · rintro ⟨a, ha⟩\n    exact ⟨a, Subtype.ext ha⟩\n\n/-- This is standard cohomological flattening, not a general descent theorem. -/\ntheorem flatten_iff (K : ObstructionComplex A B C) (ω : K.Cycles) :\n    K.obstructionClass ω = 0 ↔ ∃ a, ω.val - K.d₁ a = 0 := by\n  rw [K.class_zero_iff]\n  constructor\n  · rintro ⟨a, ha⟩; exact ⟨a, sub_eq_zero.mpr ha.symm⟩\n  · rintro ⟨a, ha⟩; exact ⟨a, (sub_eq_zero.mp ha).symm⟩\n\ndef correct (K : ObstructionComplex A B C) (ω : K.Cycles) (a : A) : K.Cycles :=\n  ⟨ω.val - K.d₁ a, by\n    change K.d₂ (ω.val - K.d₁ a) = 0\n    rw [map_sub, K.square_zero, show K.d₂ ω.val = 0 from ω.property, sub_self]⟩\n\n/-- Gauge correction does not change the obstruction class. -/\ntheorem correction_invariant (K : ObstructionComplex A B C) (ω : K.Cycles) (a : A) :\n    K.obstructionClass (K.correct ω a) = K.obstructionClass ω := by\n  have hc : K.correct ω a = ω - K.boundaryMap a := rfl\n  have hz : (K.boundaryMap a : K.Cycles ⧸ K.boundaryMap.range) = 0 :=\n    (QuotientAddGroup.eq_zero_iff _).2 ⟨a, rfl⟩\n  change (K.correct ω a : K.Cycles ⧸ K.boundaryMap.range) = _\n  rw [hc, QuotientAddGroup.mk_sub, hz, sub_zero]\n  rfl\n\n/-- A globally given primary coboundary never yields a nonzero H² class. -/\ntheorem primary_defect_class_zero (K : ObstructionComplex A B C) (a : A) :\n    K.obstructionClass (K.boundaryMap a) = 0 :=\n  (K.class_zero_iff _).2 ⟨a, rfl⟩\n\ntheorem obstruction_certificate (K : ObstructionComplex A B C)\n    {D : Type z} [AddCommGroup D] (L : B →+ D)\n    (hL : ∀ a, L (K.d₁ a) = 0) (ω : K.Cycles)\n    (hw : L ω.val ≠ 0) : K.obstructionClass ω ≠ 0 := by\n  intro h\n  rcases (K.class_zero_iff ω).1 h with ⟨a, ha⟩\n  apply hw\n  rw [← ha]\n  exact hL a\nend ObstructionComplex\n\nnamespace Differential\nvariable {A : Type u} [AddCommGroup A]\n\n/-- Anticommuting differentials use the unsigned total differential d+e. -/\ntheorem anticommuting_sum_square_zero (d e : A →+ A)\n    (hd : ∀ x, d (d x) = 0) (he : ∀ x, e (e x) = 0)\n    (hde : ∀ x, d (e x) + e (d x) = 0) (x : A) :\n    (d + e) ((d + e) x) = 0 := by\n  change d (d x + e x) + e (d x + e x) = 0\n  rw [map_add, map_add, hd, he]\n  simpa only [zero_add, add_zero] using hde x\nend Differential\nend KomorebiSpace\n"}],"mathlib_manifest":"workspaces/komorebi-space-cohomology.json","download_plan":{"files":408,"bytes":356214993}},{"id":"special-functions-core","title":"Special Functions · Projector calculus core","work":"monographs-special-functions","files":[{"module":"BrowserCoreLocal","path":"monographs/special-functions/lean/BrowserCoreLocal.lean","sha256":"610dc4b03643dbc69e780cde91f6bc58c3c1050be4c82c3a182f03cae9fbd95c","inspect":"../../read/monographs-special-functions/browsercorelocal-df22050e1789.html","download":"../../documents/files/5692c9e0f1b4772a998d0995929fb0dd58437cba/BrowserCoreLocal.lean","text":"import Mathlib.LinearAlgebra.Span.Basic\nimport Mathlib.Data.Matrix.Mul\nimport Mathlib.Algebra.BigOperators.Pi\nimport Mathlib.Analysis.Complex.Exponential\nimport Mathlib.Tactic.Ring\n\n/-!\n# Komorebi Projector Calculus — browser-safe formal core v1.2.2\n\nThis file is intentionally conservative.  It contains the foundational theorem\ntranche only.  The larger source-claim ledger is included in the companion\n`..._Full_Fixed.lean` file as data, not as theorem assumptions.\n-/\n\nset_option maxRecDepth 100000\nset_option maxHeartbeats 4000000\nset_option autoImplicit false\n\nnamespace Komorebi\n\n/-! ## Proof-status vocabulary -/\n\ninductive ClaimKind where\n  | definitionClaim\n  | theoremClaim\n  | propositionClaim\n  | lemmaClaim\n  | corollaryClaim\n  | exampleClaim\n  | remarkClaim\n  | algorithmClaim\n  | numericalCertificate\n  | classicalInput\n  | conjecture\n  | boundary\n  deriving Repr, DecidableEq, BEq, Inhabited\n\ninductive FormalizationStatus where\n  | kernelChecked\n  | proofTermPresent\n  | partialFormalization\n  | encodedDefinition\n  | queued\n  | blockedByLibrary\n  | numericalOnly\n  | conjectural\n  | externalInput\n  | contextOnly\n  | boundaryOnly\n  deriving Repr, DecidableEq, BEq, Inhabited\n\nstructure ClaimRecord where\n  id : String\n  corpus : String\n  volume : String\n  source : String\n  ordinal : Nat\n  title : String\n  heading : String\n  statement : String\n  kind : ClaimKind\n  status : FormalizationStatus\n  sourceStatus : String := \"\"\n  phase : String := \"\"\n  targetNamespace : String := \"\"\n  difficulty : String := \"\"\n  notes : String := \"\"\n  deriving Repr, Inhabited\n\ndef ClaimRecord.dependencySafe (claim : ClaimRecord) : Bool :=\n  claim.status == .kernelChecked\n\ndef ClaimRecord.isOpenOrBoundary (claim : ClaimRecord) : Bool :=\n  claim.kind == .conjecture || claim.kind == .boundary\n\n/-! ## A browser-safe operator grammar -/\n\nnamespace Seed\n\nuniverse u v\n\ninductive OperatorExpr (Atom : Type u) where\n  | id\n  | atom (f : Atom)\n  | comp (f g : OperatorExpr Atom)\n  deriving Repr\n\nnamespace OperatorExpr\n\nvariable {Atom : Type u} {X : Type v}\n\ndef eval (interpret : Atom → X → X) : OperatorExpr Atom → X → X\n  | .id => fun x => x\n  | .atom f => interpret f\n  | .comp f g => fun x => eval interpret g (eval interpret f x)\n\n@[simp] theorem eval_id (interpret : Atom → X → X) (x : X) :\n    eval interpret .id x = x := rfl\n\n@[simp] theorem eval_atom (interpret : Atom → X → X) (f : Atom) (x : X) :\n    eval interpret (.atom f) x = interpret f x := rfl\n\n@[simp] theorem eval_comp\n    (interpret : Atom → X → X) (f g : OperatorExpr Atom) (x : X) :\n    eval interpret (.comp f g) x = eval interpret g (eval interpret f x) := rfl\n\nend OperatorExpr\n\nstructure OperatorRelation (Atom : Type u) where\n  lhs : OperatorExpr Atom\n  rhs : OperatorExpr Atom\n\nnamespace OperatorRelation\n\nvariable {Atom : Type u} {X : Type v}\n\ndef Satisfied (interpret : Atom → X → X) (r : OperatorRelation Atom) : Prop :=\n  ∀ x, OperatorExpr.eval interpret r.lhs x = OperatorExpr.eval interpret r.rhs x\n\n@[simp] theorem satisfied_refl\n    (interpret : Atom → X → X) (f : OperatorExpr Atom) :\n    Satisfied interpret ⟨f, f⟩ := by\n  intro x\n  rfl\n\ntheorem satisfied_symm\n    (interpret : Atom → X → X) {r : OperatorRelation Atom}\n    (h : Satisfied interpret r) :\n    Satisfied interpret ⟨r.rhs, r.lhs⟩ := by\n  intro x\n  exact (h x).symm\n\ntheorem satisfied_trans\n    (interpret : Atom → X → X) {f g h : OperatorExpr Atom}\n    (hfg : Satisfied interpret ⟨f, g⟩)\n    (hgh : Satisfied interpret ⟨g, h⟩) :\n    Satisfied interpret ⟨f, h⟩ := by\n  intro x\n  exact (hfg x).trans (hgh x)\n\ntheorem satisfied_postcomp\n    (interpret : Atom → X → X) {r : OperatorRelation Atom}\n    (h : Satisfied interpret r) (g : OperatorExpr Atom) :\n    Satisfied interpret ⟨.comp r.lhs g, .comp r.rhs g⟩ := by\n  intro x\n  simp only [OperatorExpr.eval_comp]\n  rw [h x]\n\nend OperatorRelation\n\nuniverse w\n\nvariable {R : Type u} {M : Type v}\nvariable [Semiring R] [AddCommMonoid M] [Module R M]\n\ndef algebraicHull (S : Set M) : Submodule R M :=\n  Submodule.span R S\n\n@[simp] theorem seed_subset_hull (S : Set M) :\n    S ⊆ algebraicHull (R := R) S :=\n  Submodule.subset_span\n\ntheorem hull_le {S : Set M} {P : Submodule R M} (h : S ⊆ P) :\n    algebraicHull (R := R) S ≤ P :=\n  Submodule.span_le.2 h\n\n@[simp] theorem hull_empty :\n    algebraicHull (R := R) (∅ : Set M) = ⊥ := by\n  simp [algebraicHull]\n\n@[simp] theorem hull_univ :\n    algebraicHull (R := R) (Set.univ : Set M) = ⊤ := by\n  apply le_antisymm le_top\n  intro x hx\n  exact Submodule.subset_span (Set.mem_univ x)\n\nend Seed\n\n/-! ## Complete finite projector families -/\n\nnamespace Foundation\n\nuniverse u v w x y\n\nstructure LinearProjectorFamily\n    (R : Type u) (M : Type v) (ι : Type w)\n    [Semiring R] [AddCommMonoid M] [Module R M] [Fintype ι] where\n  proj : ι → Module.End R M\n  idempotent : ∀ i x, proj i (proj i x) = proj i x\n  orthogonal : ∀ {i j}, i ≠ j → ∀ x, proj i (proj j x) = 0\n  complete : ∀ x, (∑ i, proj i x) = x\n\nnamespace LinearProjectorFamily\n\nvariable {R : Type u} {M : Type v} {ι : Type w}\nvariable [Semiring R] [AddCommMonoid M] [Module R M] [Fintype ι]\n\n\ndef analyze (P : LinearProjectorFamily R M ι) (x : M) : ι → M :=\n  fun i => P.proj i x\n\n\ndef synthesize (_P : LinearProjectorFamily R M ι) (packets : ι → M) : M :=\n  ∑ i, packets i\n\n@[simp] theorem synthesize_analyze\n    (P : LinearProjectorFamily R M ι) (x : M) :\n    P.synthesize (P.analyze x) = x := by\n  simpa [synthesize, analyze] using P.complete x\n\ntheorem eq_of_projectors_eq\n    (P : LinearProjectorFamily R M ι) {x y : M}\n    (h : ∀ i, P.proj i x = P.proj i y) : x = y := by\n  calc\n    x = ∑ i, P.proj i x := (P.complete x).symm\n    _ = ∑ i, P.proj i y := by\n      apply Finset.sum_congr rfl\n      intro i hi\n      exact h i\n    _ = y := P.complete y\n\nend LinearProjectorFamily\n\nvariable {R : Type u} {M : Type v} {N : Type w} {L : Type x}\nvariable {ι : Type y} {κ : Type*} {τ : Type*}\nvariable [Semiring R]\nvariable [AddCommMonoid M] [Module R M]\nvariable [AddCommMonoid N] [Module R N]\nvariable [AddCommMonoid L] [Module R L]\nvariable [Fintype ι] [Fintype κ] [Fintype τ]\n\n\ndef transferBlock\n    (P : LinearProjectorFamily R M ι)\n    (Q : LinearProjectorFamily R N κ)\n    (T : M →ₗ[R] N) (j : κ) (i : ι) : M →ₗ[R] N :=\n  (Q.proj j).comp (T.comp (P.proj i))\n\n\ntheorem transferBlock_reconstruction\n    (P : LinearProjectorFamily R M ι)\n    (Q : LinearProjectorFamily R N κ)\n    (T : M →ₗ[R] N) (x : M) :\n    (∑ j, ∑ i, Q.proj j (T (P.proj i x))) = T x := by\n  calc\n    (∑ j, ∑ i, Q.proj j (T (P.proj i x))) =\n        ∑ j, Q.proj j (T (∑ i, P.proj i x)) := by\n          apply Finset.sum_congr rfl\n          intro j hj\n          simp only [map_sum]\n    _ = ∑ j, Q.proj j (T x) := by rw [P.complete x]\n    _ = T x := Q.complete (T x)\n\n\ntheorem transferBlock_comp\n    (P : LinearProjectorFamily R M ι)\n    (Q : LinearProjectorFamily R N κ)\n    (S : LinearProjectorFamily R L τ)\n    (T : M →ₗ[R] N) (U : N →ₗ[R] L)\n    (k : τ) (i : ι) (x : M) :\n    S.proj k (U (T (P.proj i x))) =\n      ∑ j, S.proj k (U (Q.proj j (T (P.proj i x)))) := by\n  have h := (Q.complete (T (P.proj i x))).symm\n  calc\n    S.proj k (U (T (P.proj i x))) =\n        S.proj k (U (∑ j, Q.proj j (T (P.proj i x)))) :=\n          congrArg (fun y => S.proj k (U y)) h\n    _ = ∑ j, S.proj k (U (Q.proj j (T (P.proj i x)))) := by\n          simp only [map_sum]\n\nend Foundation\n\n/-! ## Fibre and coordinate packets -/\n\nnamespace Packet\n\nuniverse u v w\n\nvariable {α : Type u} {β : Type v} {M : Type w}\n\n\ndef fibreProj [DecidableEq β] [Zero M]\n    (address : α → β) (b : β) (x : α → M) : α → M :=\n  fun a => if address a = b then x a else 0\n\n@[simp] theorem fibreProj_apply_same\n    [DecidableEq β] [Zero M]\n    (address : α → β) (b : β) (x : α → M) (a : α)\n    (h : address a = b) :\n    fibreProj address b x a = x a := by\n  simp [fibreProj, h]\n\n@[simp] theorem fibreProj_apply_ne\n    [DecidableEq β] [Zero M]\n    (address : α → β) (b : β) (x : α → M) (a : α)\n    (h : address a ≠ b) :\n    fibreProj address b x a = 0 := by\n  simp [fibreProj, h]\n\n\ntheorem fibreProj_idempotent\n    [DecidableEq β] [Zero M]\n    (address : α → β) (b : β) (x : α → M) :\n    fibreProj address b (fibreProj address b x) = fibreProj address b x := by\n  funext a\n  by_cases h : address a = b <;> simp [fibreProj, h]\n\n\ntheorem fibreProj_orthogonal\n    [DecidableEq β] [Zero M]\n    (address : α → β) {b c : β} (hbc : b ≠ c) (x : α → M) :\n    fibreProj address b (fibreProj address c x) = 0 := by\n  funext a\n  by_cases h : address a = b <;> simp [fibreProj, h, hbc]\n\n\ntheorem fibreProj_reconstruction\n    [DecidableEq β] [Fintype β] [AddCommMonoid M]\n    (address : α → β) (x : α → M) :\n    (∑ b, fibreProj address b x) = x := by\n  funext a\n  simp [fibreProj]\n\n\ndef coordinateProj {ι : Type u} [DecidableEq ι] [Zero M]\n    (i : ι) (x : ι → M) : ι → M :=\n  fun j => if j = i then x j else 0\n\n\ntheorem coordinateProj_reconstruction\n    {ι : Type u} [DecidableEq ι] [Fintype ι] [AddCommMonoid M]\n    (x : ι → M) :\n    (∑ i, coordinateProj i x) = x := by\n  funext j\n  simp [coordinateProj]\n\nend Packet\n\n/-! ## Block and factor-first operators -/\n\nnamespace Operator\n\nuniverse u v w\n\nvariable {ι : Type u} {κ : Type v} {M : Type w}\n\n\ndef blockApply\n    [Fintype κ] [AddCommMonoid M]\n    (T : ι → κ → M →+ M) (x : κ → M) : ι → M :=\n  fun i => ∑ j, T i j (x j)\n\n@[simp] theorem blockApply_zero\n    [Fintype κ] [AddCommMonoid M]\n    (T : ι → κ → M →+ M) :\n    blockApply T (0 : κ → M) = 0 := by\n  funext i\n  simp [blockApply]\n\nvariable {ρ : Type*} {R : Type*}\n\n\ndef lowRankApply\n    [Fintype κ] [Fintype ρ] [CommSemiring R]\n    (U : ι → ρ → R) (V : κ → ρ → R) (x : κ → R) : ι → R :=\n  fun i => ∑ r, U i r * (∑ j, V j r * x j)\n\n@[simp] theorem lowRankApply_zero_vector\n    [Fintype κ] [Fintype ρ] [CommSemiring R]\n    (U : ι → ρ → R) (V : κ → ρ → R) :\n    lowRankApply U V (0 : κ → R) = 0 := by\n  funext i\n  simp [lowRankApply]\n\nend Operator\n\n/-! ## Relation-supported matrix algebra -/\n\nnamespace Algebra\n\nuniverse u v\n\n\ndef MatrixSupported {ι : Type u} {A : Type v} [Zero A]\n    (rel : ι → ι → Prop) (M : Matrix ι ι A) : Prop :=\n  ∀ i j, ¬ rel i j → M i j = 0\n\n\ntheorem matrixSupported_zero\n    {ι : Type u} {A : Type v} [Zero A]\n    (rel : ι → ι → Prop) :\n    MatrixSupported rel (0 : Matrix ι ι A) := by\n  intro i j h\n  rfl\n\n\ntheorem MatrixSupported.add\n    {ι : Type u} {A : Type v} [AddMonoid A]\n    {rel : ι → ι → Prop} {M N : Matrix ι ι A}\n    (hM : MatrixSupported rel M) (hN : MatrixSupported rel N) :\n    MatrixSupported rel (M + N) := by\n  intro i j h\n  simp [hM i j h, hN i j h]\n\n\ntheorem MatrixSupported.neg\n    {ι : Type u} {A : Type v} [AddGroup A]\n    {rel : ι → ι → Prop} {M : Matrix ι ι A}\n    (hM : MatrixSupported rel M) :\n    MatrixSupported rel (-M) := by\n  intro i j h\n  simp [hM i j h]\n\n\ntheorem MatrixSupported.mul\n    {ι : Type u} {A : Type v}\n    [Fintype ι] [DecidableEq ι] [Semiring A]\n    {rel : ι → ι → Prop}\n    (htrans : ∀ i j k, rel i j → rel j k → rel i k)\n    {M N : Matrix ι ι A}\n    (hM : MatrixSupported rel M) (hN : MatrixSupported rel N) :\n    MatrixSupported rel (M * N) := by\n  intro i j hij\n  rw [Matrix.mul_apply]\n  apply Finset.sum_eq_zero\n  intro k hk\n  by_cases hik : rel i k\n  · by_cases hkj : rel k j\n    · exact (hij (htrans i k j hik hkj)).elim\n    · simp [hN k j hkj]\n  · simp [hM i k hik]\n\n\ndef IsLowerTriangular {ι : Type u} {A : Type v}\n    [Preorder ι] [Zero A] (M : Matrix ι ι A) : Prop :=\n  ∀ i j, i < j → M i j = 0\n\n\ndef IsUpperTriangular {ι : Type u} {A : Type v}\n    [Preorder ι] [Zero A] (M : Matrix ι ι A) : Prop :=\n  ∀ i j, j < i → M i j = 0\n\n\ntheorem IsLowerTriangular.add\n    {ι : Type u} {A : Type v} [Preorder ι] [AddMonoid A]\n    {M N : Matrix ι ι A}\n    (hM : IsLowerTriangular M) (hN : IsLowerTriangular N) :\n    IsLowerTriangular (M + N) := by\n  intro i j hij\n  simp [hM i j hij, hN i j hij]\n\n\ntheorem IsUpperTriangular.add\n    {ι : Type u} {A : Type v} [Preorder ι] [AddMonoid A]\n    {M N : Matrix ι ι A}\n    (hM : IsUpperTriangular M) (hN : IsUpperTriangular N) :\n    IsUpperTriangular (M + N) := by\n  intro i j hij\n  simp [hM i j hij, hN i j hij]\n\nend Algebra\n\n/-! ## Finite-difference and weighted-shift calculus -/\n\nnamespace FiniteDifference\n\nuniverse u\n\nvariable {R : Type u}\n\n\ndef forwardDiff [Ring R] (f : ℕ → R) (n : ℕ) : R :=\n  f (n + 1) - f n\n\n\ndef iteratedDiff [Ring R] : ℕ → (ℕ → R) → (ℕ → R)\n  | 0, f => f\n  | k + 1, f => forwardDiff (iteratedDiff k f)\n\n\ntheorem forwardDiff_add [CommRing R]\n    (f g : ℕ → R) (n : ℕ) :\n    forwardDiff (fun j => f j + g j) n = forwardDiff f n + forwardDiff g n := by\n  simp [forwardDiff]\n  ring\n\n\ntheorem forwardDiff_neg [CommRing R]\n    (f : ℕ → R) (n : ℕ) :\n    forwardDiff (fun j => -f j) n = -forwardDiff f n := by\n  simp [forwardDiff]\n  ring\n\n\ntheorem iteratedDiff_two [CommRing R]\n    (f : ℕ → R) (n : ℕ) :\n    iteratedDiff 2 f n = f (n + 2) - 2 * f (n + 1) + f n := by\n  simp [iteratedDiff, forwardDiff]\n  ring\n\n\ntheorem iteratedDiff_three [CommRing R]\n    (f : ℕ → R) (n : ℕ) :\n    iteratedDiff 3 f n =\n      f (n + 3) - 3 * f (n + 2) + 3 * f (n + 1) - f n := by\n  simp [iteratedDiff, forwardDiff]\n  ring\n\n\ndef weightedDiff [Ring R] (q : R) (f : ℕ → R) (n : ℕ) : R :=\n  f n - q * f (n + 1)\n\n\ndef iteratedWeightedDiff [Ring R] (q : R) : ℕ → (ℕ → R) → (ℕ → R)\n  | 0, f => f\n  | k + 1, f => weightedDiff q (iteratedWeightedDiff q k f)\n\n\ntheorem iteratedWeightedDiff_geometric [CommRing R]\n    (q r : R) (k n : ℕ) :\n    iteratedWeightedDiff q k (fun j => r ^ j) n =\n      (1 - q * r) ^ k * r ^ n := by\n  induction k generalizing n with\n  | zero => simp [iteratedWeightedDiff]\n  | succ k ih =>\n      simp [iteratedWeightedDiff, weightedDiff, ih, pow_succ]\n      ring\n\nend FiniteDifference\n\n/-! ## Polyphase coefficient sections -/\n\nnamespace Polyphase\n\nuniverse u\n\nvariable {A : Type u}\n\n\ndef coeffSection (m r : ℕ) (f : ℕ → A) (n : ℕ) : A :=\n  f (m * n + r)\n\n@[simp] theorem coeffSection_one_zero (f : ℕ → A) :\n    coeffSection 1 0 f = f := by\n  funext n\n  simp [coeffSection]\n\n\ntheorem coeffSection_comp\n    (l s m r : ℕ) (f : ℕ → A) (n : ℕ) :\n    coeffSection m r (coeffSection l s f) n =\n      coeffSection (l * m) (l * r + s) f n := by\n  simp [coeffSection, Nat.mul_add, Nat.mul_assoc, Nat.add_assoc]\n\nend Polyphase\n\n/-! ## Finite diagonal quantum coordinates -/\n\nnamespace Quantum\n\nuniverse u\n\n\ndef diagonalApply {ι : Type u} {R : Type*} [Mul R]\n    (diagonal : ι → R) (x : ι → R) : ι → R :=\n  fun i => diagonal i * x i\n\n@[simp] theorem diagonalApply_one\n    {ι : Type u} {R : Type*} [Monoid R] (x : ι → R) :\n    diagonalApply (fun _ => 1) x = x := by\n  funext i\n  simp [diagonalApply]\n\nnoncomputable def logPhase {ι : Type u}\n    (energy : ι → ℝ) (t : ℝ) : ι → ℂ :=\n  fun i => Complex.exp (-Complex.I * ((energy i * t : ℝ) : ℂ))\n\n@[simp] theorem logPhase_zero {ι : Type u} (energy : ι → ℝ) :\n    logPhase energy 0 = fun _ => 1 := by\n  funext i\n  simp [logPhase]\n\nnoncomputable def finiteAmplitude {ι : Type u} [Fintype ι]\n    (weight sign : ι → ℂ) (energy : ι → ℝ) (t : ℝ) : ℂ :=\n  ∑ i, weight i * sign i * logPhase energy t i\n\n@[simp] theorem finiteAmplitude_zero {ι : Type u} [Fintype ι]\n    (weight sign : ι → ℂ) (energy : ι → ℝ) :\n    finiteAmplitude weight sign energy 0 = ∑ i, weight i * sign i := by\n  simp [finiteAmplitude, logPhase]\n\nend Quantum\n\nend Komorebi\n\n/-! ## Browser smoke checks -/\n\n#check Komorebi.Foundation.LinearProjectorFamily.synthesize_analyze\n#check Komorebi.Foundation.transferBlock_reconstruction\n#check Komorebi.Foundation.transferBlock_comp\n#check Komorebi.Packet.fibreProj_reconstruction\n#check Komorebi.Algebra.MatrixSupported.mul\n#check Komorebi.FiniteDifference.iteratedWeightedDiff_geometric\n#check Komorebi.Polyphase.coeffSection_comp\n#check Komorebi.Quantum.finiteAmplitude_zero\n\n#eval \"Komorebi Projector Calculus browser-safe core v1.2.2 loaded\"\n"}],"mathlib_manifest":"workspaces/special-functions-core.json","download_plan":{"files":409,"bytes":363697354}}],"lean":"62b6a2291302d4bbeace37642a066b7510d0145c","mathlib":"de3a9cf33016bbb6d15880d7680643f7ca2d25ba","download_bytes":436452326,"execution":"local WebAssembly","changes_recorded_verification":false,"collection_catalog":"catalog.json","collection":{"sources":2722,"available_import_routes":363},"expanded_download_plan":{"files":409,"bytes":363864343}}
