Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Vathek training frame: tile partitions, accumulator, tiled gradient

Definition
VathekFrame

by ajax · Sep 22, 2026 · Mathlib 0df444a (Lean v4.33.1)

formal-verificationmachine-learning

The core vocabulary of the tiled-graft training frame. Parameter space is W=RdW = \mathbb{R}^dW=Rd (as EuclideanSpace ℝ (Fin d)) and shared-state space is V=RmV = \mathbb{R}^mV=Rm. A valid tile partition of a finite occurrence set III is a finite list of pairwise-disjoint tiles whose union is exactly III; tiles may be empty or uneven. The streaming accumulator carries three slots — the running weighted loss, the running direct parameter-gradient contribution AAA (directAccum), and the running shared-state cotangent contribution CCC (sharedAccum) — updated by an executable left-to-right fold in which every tile reads the same fixed pre-update data. The monolithic objective is Lξ(w)=∑i∈Iαi fi(w,h(w))L_\xi(w) = \sum_{i \in I} \alpha_i \, f_i(w, h(w))Lξ​(w)=∑i∈I​αi​fi​(w,h(w)). The tiled gradient is gtile=A+Dh(w0)⊤Cg_{\mathrm{tile}} = A + Dh(w_0)^{\top} Cgtile​=A+Dh(w0​)⊤C: accumulated direct contributions plus one reverse pass of the shared derivative applied to the summed cotangent. Radius-ccc global clipping CcC_cCc​ is a total function with both branches specified (the zero gradient is fixed). The trainable projection PTP_TPT​ zeroes every frozen coordinate. The logical step applies the deterministic optimizer exactly once to the masked, clipped gradient.

Definition code
import Mathlib.Tactic
import Mathlib.Analysis.InnerProductSpace.Adjoint
import Mathlib.Analysis.Calculus.Gradient.Basic
import Mathlib.Data.List.Basic

/-!
# VathekProof — the tiled-graft training frame (white paper §4)

Shared vocabulary for the mission "Vathek I: Tiled graft training preserves the
mathematical update".  Parameter space is `W = EuclideanSpace ℝ (Fin d)` (the `d`
logical parameter coordinates, §4.1) and shared-state space is
`V = EuclideanSpace ℝ (Fin m)`.
-/

namespace VathekProof

/-- §4.4: a *valid tile partition* of a finite occurrence set `I` is a finite list of
pairwise-disjoint tiles whose union is exactly `I`.  Tiles may be empty or uneven; an
empty tile can be removed without changing the semantics. -/
def IsTilePartition {ι : Type*} [DecidableEq ι] (I : Finset ι) (ℬ : List (Finset ι)) : Prop :=
  ℬ.foldr (· ∪ ·) ∅ = I ∧ ℬ.Pairwise (fun B₁ B₂ => Disjoint B₁ B₂)

/-- §4.4: streaming accumulator state — the running weighted loss, the running direct
parameter-gradient contribution (`directAccum`), and the running shared-state cotangent
contribution (`sharedAccum`). -/
structure TileAccum (W V : Type*) where
  /-- running weighted loss over the occurrences visited so far -/
  loss : ℝ
  /-- running direct parameter-gradient contribution -/
  direct : W
  /-- running shared-state cotangent contribution -/
  shared : V

/-- §4.4: one step of the streaming accumulator over tile `B`.  Everything is read at
the fixed pre-update data (`val`, `a`, `c`); no parameter is updated between tiles. -/
def tileAccumStep {ι W V : Type*} [AddCommMonoid W] [AddCommMonoid V] [Module ℝ W] [Module ℝ V]
    (α : ι → ℝ) (val : ι → ℝ) (a : ι → W) (c : ι → V)
    (B : Finset ι) (acc : TileAccum W V) : TileAccum W V where
  loss := acc.loss + ∑ i ∈ B, α i * val i
  direct := acc.direct + ∑ i ∈ B, α i • a i
  shared := acc.shared + ∑ i ∈ B, α i • c i

/-- §4.4: the streaming fold itself, processing tiles left to right from an initial
empty accumulator. -/
def tileAccumFold {ι W V : Type*} [AddCommMonoid W] [AddCommMonoid V] [Module ℝ W] [Module ℝ V]
    (α : ι → ℝ) (val : ι → ℝ) (a : ι → W) (c : ι → V) :
    List (Finset ι) → TileAccum W V → TileAccum W V
  | [], acc => acc
  | B :: ℬ, acc => tileAccumFold α val a c ℬ (tileAccumStep α val a c B acc)

/-- §4.4: the tiled evaluator's accumulator after processing all tiles. -/
def tileAccum {ι W V : Type*} [AddCommMonoid W] [AddCommMonoid V] [Module ℝ W] [Module ℝ V]
    (α : ι → ℝ) (val : ι → ℝ) (a : ι → W) (c : ι → V) (ℬ : List (Finset ι)) : TileAccum W V :=
  tileAccumFold α val a c ℬ ⟨0, 0, 0⟩

/-- §4.3 (1): the monolithic logical objective
`L_ξ(w) = ∑_{i ∈ I} αᵢ · fᵢ(w, h(w))`. -/
noncomputable def frameLoss {ι : Type*} {W V : Type*} (h : W → V) (f : ι → W × V → ℝ)
    (α : ι → ℝ) (I : Finset ι) (w : W) : ℝ :=
  ∑ i ∈ I, α i * f i (w, h w)

/-- §4.4 (3): the tiled gradient — the accumulated direct contributions `A`, plus one
reverse pass of the shared derivative applied to the summed shared cotangent `C`:
`g_tile = A + Dh(w₀)ᵀ C`. -/
noncomputable def tiledGrad {ι : Type*} {d m : ℕ} (α : ι → ℝ) (val : ι → ℝ)
    (a : ι → EuclideanSpace ℝ (Fin d)) (c : ι → EuclideanSpace ℝ (Fin m))
    (Dh : EuclideanSpace ℝ (Fin d) →L[ℝ] EuclideanSpace ℝ (Fin m))
    (ℬ : List (Finset ι)) : EuclideanSpace ℝ (Fin d) :=
  (tileAccum α val a c ℬ).direct + Dh.adjoint (tileAccum α val a c ℬ).shared

/-- §4.5: radius-`c` clipping of the whole (already masked) logical gradient.  Both
branches are total: at the zero gradient the clip fixes `0`. -/
noncomputable def clipVec {W : Type*} [NormedAddCommGroup W] [NormedSpace ℝ W]
    (c : ℝ) (g : W) : W :=
  if ‖g‖ ≤ c then g else (c / ‖g‖) • g

/-- §4.1: `P_T` — the coordinate projection that zeroes every frozen coordinate
(`j ∉ T`) and keeps every trainable coordinate (`j ∈ T`). -/
def coordMask {d : ℕ} (T : Finset (Fin d)) (w : EuclideanSpace ℝ (Fin d)) :
    EuclideanSpace ℝ (Fin d) :=
  WithLp.toLp 2 (fun j => if j ∈ T then w j else 0)

/-- §4.5 (4): one logical optimizer application — project the accumulated gradient
onto trainable coordinates, clip globally, and apply the (deterministic) optimizer
exactly once. -/
noncomputable def logicalStep {d : ℕ} {σ : Type*} (T : Finset (Fin d)) (c : ℝ)
    (U : σ → EuclideanSpace ℝ (Fin d) → σ) (S : σ)
    (g : EuclideanSpace ℝ (Fin d)) : σ :=
  U S (clipVec c (coordMask T g))

end VathekProof
Source
Vathek Graft: A Proof and Evidence Programme, mission-source white paper v1.0, 22 September 2026 (Thomas Davis). Sections 4.1-4.5.
Read-back

What the Lean code literally says, in plain math · glm-5.3 (independent auditor subagent)

{"text": "{\n "readback": "IsTilePartition. For any type iota\\\\iotaiota equipped with decidable equality (the instance used to form finite-set unions), any finite set IsubseteqiotaI \\\\subseteq \\\\iotaIsubseteqiota, and any finite list of finite sets mathcalB=(B1,B2,ldots,Bk)\\\\mathcal{B} = (B_1, B_2, \\\\ldots, B_k)mathcalB=(B1​,B2​,ldots,Bk​) of subsets of iota\\\\iotaiota, mathrmIsTilePartition(I,mathcalB)\\\\mathrm{IsTilePartition}(I, \\\\mathcal{B})mathrmIsTilePartition(I,mathcalB) is the proposition asserting two things simultaneously:\n\n

B1cupB2cupcdotscupBk=IqquadtextandqquadBpcapBq=varnothingtextforentriesatdistinctpositionspneqq.B_1 \\\\cup B_2 \\\\cup \\\\cdots \\\\cup B_k = I \\\\qquad\\\\text{and}\\\\qquad B_p \\\\cap B_q = \\\\varnothing \\\\ \\\\text{for entries at distinct positions } p \\\\neq q.B1​cupB2​cupcdotscupBk​=IqquadtextandqquadBp​capBq​=varnothingtextforentriesatdistinctpositionspneqq.

\n\nThe union is the iterated binary union of the list, taken in order and starting from varnothing\\\\varnothingvarnothing, so an empty list gives varnothing\\\\varnothingvarnothing; hence the empty list is a valid partition exactly when I=varnothingI = \\\\varnothingI=varnothing. Disjointness is required pairwise between entries at distinct positions of the list; consequently, a tile occurring twice in the list must be disjoint from itself, which forces it to be empty \u2014 a repeated nonempty tile violates the predicate, while repeated empty tiles are allowed. Tiles may be empty and may be of arbitrary, unequal sizes; the union is required to equal III exactly, not merely to cover it or be contained in it.\n\nTileAccum. For two arbitrary types WWW and VVV, with no algebraic structure assumed, mathrmTileAccum(W,V)\\\\mathrm{TileAccum}(W, V)mathrmTileAccum(W,V) is the type of ordered triples (L,A,C)(L, A, C)(L,A,C) whose first component LLL is a real number (field loss), whose second component AAA is an element of WWW (field direct), and whose third component CCC is an element of VVV (field shared). It is pure data: the declaration provides the three projection maps selecting LLL, AAA, and CCC, and nothing more.\n\ntileAccumStep. For any types iota,W,V\\\\iota, W, Viota,W,V such that WWW and VVV are commutative additive monoids carrying the structure of real vector spaces (so each has a zero, an associative commutative addition, and a scalar multiplication by reals), given weight and value functions alpha,mathrmval:iotatomathbbR\\\\alpha, \\\\mathrm{val} : \\\\iota \\\\to \\\\mathbb{R}alpha,mathrmval:iotatomathbbR, families a:iotatoWa : \\\\iota \\\\to Wa:iotatoW and c:iotatoVc : \\\\iota \\\\to Vc:iotatoV, a finite set BsubseteqiotaB \\\\subseteq \\\\iotaBsubseteqiota, and an accumulator (L,A,C)inmathrmTileAccum(W,V)(L, A, C) \\\\in \\\\mathrm{TileAccum}(W, V)(L,A,C)inmathrmTileAccum(W,V), one step returns the new accumulator with components\n\n

L′=L+sumiinBalphai,mathrmval(i),qquadA′=A+sumiinBalphaicdotai,qquadC′=C+sumiinBalphaicdotci,L' = L + \\\\sum_{i \\\\in B} \\\\alpha_i \\\\, \\\\mathrm{val}(i), \\\\qquad A' = A + \\\\sum_{i \\\\in B} \\\\alpha_i \\\\cdot a_i, \\\\qquad C' = C + \\\\sum_{i \\\\in B} \\\\alpha_i \\\\cdot c_i,L′=L+sumiinB​alphai​,mathrmval(i),qquadA′=A+sumiinB​alphai​cdotai​,qquadC′=C+sumiinB​alphai​cdotci​,

\n\nwhere alphaicdotai\\\\alpha_i \\\\cdot a_ialphai​cdotai​ denotes the scalar action of mathbbR\\\\mathbb{R}mathbbR on WWW (similarly on VVV). Each component is the old one plus the BBB-sum of alpha\\\\alphaalpha-weighted contributions; the sums range over the finite set BBB, so each index is counted once, and B=varnothingB = \\\\varnothingB=varnothing makes the step the identity on the accumulator. The step is a total function: no hypothesis is imposed on BBB, and the weights alphai\\\\alpha_ialphai​ are arbitrary reals (possibly negative or larger than 111). All four data functions are read at their given arguments; the step computes and returns a new record and modifies nothing.\n\ntileAccumFold. With the same type assumptions and the same arguments alpha,mathrmval,a,c\\\\alpha, \\\\mathrm{val}, a, calpha,mathrmval,a,c as the step, this is a total function of a list of tiles mathcalB=(B1,ldots,Bk)\\\\mathcal{B} = (B_1, \\\\ldots, B_k)mathcalB=(B1​,ldots,Bk​) and an accumulator, defined by structural recursion on the list: on the empty list it returns the accumulator unchanged; on B1::(B2,ldots,Bk)B_1 :: (B_2, \\\\ldots, B_k)B1​::(B2​,ldots,Bk​) it applies one step at B1B_1B1​ and recurses on the remaining list with the updated accumulator. Tiles are thus processed in list order, first to last, threading the accumulator through. The recursion is structural, so the function is defined for every list of finite sets: tiles may repeat or overlap, and the list need not satisfy any partition property.\n\ntileAccum. The accumulator after processing all tiles: the fold above applied to mathcalB=(B1,ldots,Bk)\\\\mathcal{B} = (B_1, \\\\ldots, B_k)mathcalB=(B1​,ldots,Bk​) with the initial accumulator (0,0,0)(0, 0, 0)(0,0,0), the zeros being those of mathbbR\\\\mathbb{R}mathbbR, WWW, and VVV. Unfolding the recursion, the three components are\n\n

L=sump=1ksumiinBpalphai,mathrmval(i),qquadA=sump=1ksumiinBpalphaicdotai,qquadC=sump=1ksumiinBpalphaicdotci,L = \\\\sum_{p=1}^{k} \\\\sum_{i \\\\in B_p} \\\\alpha_i \\\\, \\\\mathrm{val}(i), \\\\qquad A = \\\\sum_{p=1}^{k} \\\\sum_{i \\\\in B_p} \\\\alpha_i \\\\cdot a_i, \\\\qquad C = \\\\sum_{p=1}^{k} \\\\sum_{i \\\\in B_p} \\\\alpha_i \\\\cdot c_i,L=sump=1k​sumiinBp​​alphai​,mathrmval(i),qquadA=sump=1k​sumiinBp​​alphai​cdotai​,qquadC=sump=1k​sumiinBp​​alphai​cdotci​,

\n\nthe outer sums running over the positions of the list: an index iii belonging to several tiles, or a tile repeated in the list, contributes once per occurrence. For the empty list the result is (0,0,0)(0, 0, 0)(0,0,0). Because all additions involved are commutative, this final value does not depend on the order of the list, although the intermediate accumulator states do.\n\nframeLoss. For a type iota\\\\iotaiota and arbitrary types W,VW, VW,V carrying no structure whatsoever, given an arbitrary map h:WtoVh : W \\\\to Vh:WtoV, a family f:iotato(WtimesVtomathbbR)f : \\\\iota \\\\to (W \\\\times V \\\\to \\\\mathbb{R})f:iotato(WtimesVtomathbbR), weights alpha:iotatomathbbR\\\\alpha : \\\\iota \\\\to \\\\mathbb{R}alpha:iotatomathbbR, a finite set IsubseteqiotaI \\\\subseteq \\\\iotaIsubseteqiota, and a point winWw \\\\in WwinW, this defines the real number\n\n

L(w)=sumiinIalphaicdotfibig(w,,h(w)big).L(w) = \\\\sum_{i \\\\in I} \\\\alpha_i \\\\cdot f_i\\\\big(w,\\\\, h(w)\\\\big).L(w)=sumiinI​alphai​cdotfi​big(w,,h(w)big).

\n\nEach summand evaluates fif_ifi​ at the pair whose first component is www itself and whose second component is h(w)h(w)h(w); the shared value h(w)h(w)h(w) is the same in every term of the sum. No assumption is placed on hhh or on the fif_ifi​ (in particular no continuity or differentiability), none on the weights (arbitrary reals, possibly negative), and III may be empty, in which case L(w)=0L(w) = 0L(w)=0.\n\ntiledGrad. For a type iota\\\\iotaiota and natural numbers d,md, md,m: given alpha,mathrmval:iotatomathbbR\\\\alpha, \\\\mathrm{val} : \\\\iota \\\\to \\\\mathbb{R}alpha,mathrmval:iotatomathbbR, families a:iotatomathbbRda : \\\\iota \\\\to \\\\mathbb{R}^da:iotatomathbbRd and c:iotatomathbbRmc : \\\\iota \\\\to \\\\mathbb{R}^mc:iotatomathbbRm (Euclidean spaces of ddd- and mmm-tuples with the standard inner product), a continuous mathbbR\\\\mathbb{R}mathbbR-linear map Dh:mathbbRdtomathbbRmDh : \\\\mathbb{R}^d \\\\to \\\\mathbb{R}^mDh:mathbbRdtomathbbRm, and a list of finite sets mathcalB\\\\mathcal{B}mathcalB, this defines the vector in mathbbRd\\\\mathbb{R}^dmathbbRd\n\n

gmathrmtile=A+Dhast(C),g_{\\\\mathrm{tile}} = A + Dh^{\\\\ast}(C),gmathrmtile​=A+Dhast(C),

\n\nwhere (L,A,C)=mathrmtileAccum(alpha,mathrmval,a,c,mathcalB)(L, A, C) = \\\\mathrm{tileAccum}(\\\\alpha, \\\\mathrm{val}, a, c, \\\\mathcal{B})(L,A,C)=mathrmtileAccum(alpha,mathrmval,a,c,mathcalB) is the accumulator expanded above, and Dhast:mathbbRmtomathbbRdDh^{\\\\ast} : \\\\mathbb{R}^m \\\\to \\\\mathbb{R}^dDhast:mathbbRmtomathbbRd is the adjoint of DhDhDh with respect to the standard inner products, i.e. the unique continuous linear map satisfying langleDh,x,,yrangle=langlex,,Dhastyrangle\\\\langle Dh\\\\, x,\\\\, y \\\\rangle = \\\\langle x,\\\\, Dh^{\\\\ast} y \\\\ranglelangleDh,x,,yrangle=langlex,,Dhastyrangle for all xinmathbbRdx \\\\in \\\\mathbb{R}^dxinmathbbRd, yinmathbbRmy \\\\in \\\\mathbb{R}^myinmathbbRm (over the reals, the transpose). Only the components AAA and CCC of the accumulator enter the value: the loss component LLL \u2014 and hence the entire argument mathrmval\\\\mathrm{val}mathrmval \u2014 has no influence on the result. Furthermore, no hypothesis connects mathcalB\\\\mathcal{B}mathcalB to a partition of any set: it is an arbitrary list, and indices occurring in several tiles are counted with multiplicity.\n\nclipVec. For a real number ccc and a vector ggg in a real normed space WWW (a normed abelian group with a compatible scalar multiplication by mathbbR\\\\mathbb{R}mathbbR; in particular ∣g∣=0\\\\|g\\\\| = 0∣g∣=0 exactly when g=0g = 0g=0), the clipped vector is defined by an if-then-else on the inclusive norm test ∣g∣lec\\\\|g\\\\| \\\\le c∣g∣lec:\n\n

\\\\mathrm{clip}_c(g) = \\\\begin{cases} g, & \\\\text{if } \\\\|g\\\\| \\\\le c, \\\\\\\\[4pt] \\\\dfrac{c}{\\\\|g\\\\|}\\\\, g, & \\\\text{if } \\\\|g\\\\| > c. \\\\end{cases}

\n\nThe function is total for every cinmathbbRc \\\\in \\\\mathbb{R}cinmathbbR, and real division is total with the convention x/0=0x / 0 = 0x/0=0. Consequences of the literal clauses: if gneq0g \\\\neq 0gneq0 and 0lec<∣g∣0 \\\\le c < \\\\|g\\\\|0lec<∣g∣, the result is ggg rescaled by the positive factor c/∣g∣c/\\\\|g\\\\|c/∣g∣, i.e. a vector of norm exactly ccc pointing along ggg (and c=0c = 0c=0 yields the zero vector); if gneq0g \\\\neq 0gneq0 and c<0c < 0c<0, the test ∣g∣lec\\\\|g\\\\| \\\\le c∣g∣lec necessarily fails and the else-branch multiplies ggg by the negative scalar c/∣g∣c/\\\\|g\\\\|c/∣g∣, producing a vector of norm ∣c∣|c|∣c∣ pointing opposite to ggg; if g=0g = 0g=0, both branches return the zero vector \u2014 for cge0c \\\\ge 0cge0 via the then-branch, and for c<0c < 0c<0 via the else-branch, where tfracc∣g∣g=tfracc0cdot0=0cdot0=0\\\\tfrac{c}{\\\\|g\\\\|} g = \\\\tfrac{c}{0} \\\\cdot 0 = 0 \\\\cdot 0 = 0tfracc∣g∣g=tfracc0cdot0=0cdot0=0 under the stated division convention.\n\ncoordMask. For a natural number ddd, a finite set TTT of coordinates (Tsubseteq0,ldots,d−1T \\\\subseteq \\\\{0, \\\\ldots, d-1\\\\}Tsubseteq0,ldots,d−1, the index type of length ddd), and a vector winmathbbRdw \\\\in \\\\mathbb{R}^dwinmathbbRd, this is the coordinatewise mask PTP_TPT​ defined by\n\n

(P_T\\\\, w)_j = \\\\begin{cases} w_j, & j \\\\in T, \\\\\\\\ 0, & j \\\\notin T, \\\\end{cases} \\\\qquad j = 0, \\\\ldots, d-1,

\n\ni.e. coordinates in TTT are kept and all others are set to zero. (The code re-packages the coordinate function into the Euclidean-space type; on underlying coordinates this packaging is the identity, so the map is exactly the mask above.) The map is linear in www; if T=varnothingT = \\\\varnothingT=varnothing it is the zero map, and if TTT is the full set of all ddd coordinates it is the identity.\n\nlogicalStep. For a natural number ddd and an arbitrary type sigma\\\\sigmasigma carrying no structure, given a finite set TTT of coordinates, a real number ccc, an arbitrary function U:sigmatomathbbRdtosigmaU : \\\\sigma \\\\to \\\\mathbb{R}^d \\\\to \\\\sigmaU:sigmatomathbbRdtosigma, a state SinsigmaS \\\\in \\\\sigmaSinsigma, and a direction ginmathbbRdg \\\\in \\\\mathbb{R}^dginmathbbRd, one logical step returns the state\n\n

Ubig(S,;mathrmclipc(PT,g)big),U\\\\big(S,\\\\; \\\\mathrm{clip}_c(P_T\\\\, g)\\\\big),Ubig(S,;mathrmclipc​(PT​,g)big),

\n\nthat is: the direction ggg is first masked to the coordinates in TTT by PTP_TPT​; the masked vector is then clipped by mathrmclipc\\\\mathrm{clip}_cmathrmclipc​, so the radius test applies to ∣PT,g∣\\\\|P_T\\\\, g\\\\|∣PT​,g∣ \u2014 the norm of the already-masked vector, not of ggg; and finally UUU is applied exactly once to the pair consisting of the starting state SSS and the resulting clipped vector. No property whatsoever is assumed of UUU: it is an arbitrary function of a state and a direction returning a state. Besides the clipping scalar c/∣cdot∣c/\\\\|{\\\\cdot}\\\\|c/∣cdot∣ above, no further scaling, normalization, or correction factor appears anywhere in the step, and UUU is applied a single time, not iterated. The radius ccc is an arbitrary real, so the negative-radius and zero-vector behavior of mathrmclipc\\\\mathrm{clip}_cmathrmclipc​ described above carries over verbatim."\n}", "details": {"resolvedPath": "/home/ajax/.omp/agent/sessions/-math/2026-09-22T19-31-08-510Z_01a0ca99-be5e-7000-93c6-dac7c74cc004/RB-VathekFrame.md", "contentType": "text/markdown", "totalLines": 3, "displayContent": {"text": "{\n "readback": "IsTilePartition. For any type iota\\\\iotaiota equipped with decidable equality (the instance used to form finite-set unions), any finite set IsubseteqiotaI \\\\subseteq \\\\iotaIsubseteqiota, and any finite list of finite sets mathcalB=(B1,B2,ldots,Bk)\\\\mathcal{B} = (B_1, B_2, \\\\ldots, B_k)mathcalB=(B1​,B2​,ldots,Bk​) of subsets of iota\\\\iotaiota, mathrmIsTilePartition(I,mathcalB)\\\\mathrm{IsTilePartition}(I, \\\\mathcal{B})mathrmIsTilePartition(I,mathcalB) is the proposition asserting two things simultaneously:\n\n

B1cupB2cupcdotscupBk=IqquadtextandqquadBpcapBq=varnothingtextforentriesatdistinctpositionspneqq.B_1 \\\\cup B_2 \\\\cup \\\\cdots \\\\cup B_k = I \\\\qquad\\\\text{and}\\\\qquad B_p \\\\cap B_q = \\\\varnothing \\\\ \\\\text{for entries at distinct positions } p \\\\neq q.B1​cupB2​cupcdotscupBk​=IqquadtextandqquadBp​capBq​=varnothingtextforentriesatdistinctpositionspneqq.

\n\nThe union is the iterated binary union of the list, taken in order and starting from varnothing\\\\varnothingvarnothing, so an empty list gives varnothing\\\\varnothingvarnothing; hence the empty list is a valid partition exactly when I=varnothingI = \\\\varnothingI=varnothing. Disjointness is required pairwise between entries at distinct positions of the list; consequently, a tile occurring twice in the list must be disjoint from itself, which forces it to be empty \u2014 a repeated nonempty tile violates the predicate, while repeated empty tiles are allowed. Tiles may be empty and may be of arbitrary, unequal sizes; the union is required to equal III exactly, not merely to cover it or be contained in it.\n\nTileAccum. For two arbitrary types WWW and VVV, with no algebraic structure assumed, mathrmTileAccum(W,V)\\\\mathrm{TileAccum}(W, V)mathrmTileAccum(W,V) is the type of ordered triples (L,A,C)(L, A, C)(L,A,C) whose first component LLL is a real number (field loss), whose second component AAA is an element of WWW (field direct), and whose third component CCC is an element of VVV (field shared). It is pure data: the declaration provides the three projection maps selecting LLL, AAA, and CCC, and nothing more.\n\ntileAccumStep. For any types iota,W,V\\\\iota, W, Viota,W,V such that WWW and VVV are commutative additive monoids carrying the structure of real vector spaces (so each has a zero, an associative commutative addition, and a scalar multiplication by reals), given weight and value functions alpha,mathrmval:iotatomathbbR\\\\alpha, \\\\mathrm{val} : \\\\iota \\\\to \\\\mathbb{R}alpha,mathrmval:iotatomathbbR, families a:iotatoWa : \\\\iota \\\\to Wa:iotatoW and c:iotatoVc : \\\\iota \\\\to Vc:iotatoV, a finite set BsubseteqiotaB \\\\subseteq \\\\iotaBsubseteqiota, and an accumulator (L,A,C)inmathrmTileAccum(W,V)(L, A, C) \\\\in \\\\mathrm{TileAccum}(W, V)(L,A,C)inmathrmTileAccum(W,V), one step returns the new accumulator with components\n\n

L′=L+sumiinBalphai,mathrmval(i),qquadA′=A+sumiinBalphaicdotai,qquadC′=C+sumiinBalphaicdotci,L' = L + \\\\sum_{i \\\\in B} \\\\alpha_i \\\\, \\\\mathrm{val}(i), \\\\qquad A' = A + \\\\sum_{i \\\\in B} \\\\alpha_i \\\\cdot a_i, \\\\qquad C' = C + \\\\sum_{i \\\\in B} \\\\alpha_i \\\\cdot c_i,L′=L+sumiinB​alphai​,mathrmval(i),qquadA′=A+sumiinB​alphai​cdotai​,qquadC′=C+sumiinB​alphai​cdotci​,

\n\nwhere alphaicdotai\\\\alpha_i \\\\cdot a_ialphai​cdotai​ denotes the scalar action of mathbbR\\\\mathbb{R}mathbbR on WWW (similarly on VVV). Each component is the old one plus the BBB-sum of alpha\\\\alphaalpha-weighted contributions; the sums range over the finite set BBB, so each index is counted once, and B=varnothingB = \\\\varnothingB=varnothing makes the step the identity on the accumulator. The step is a total function: no hypothesis is imposed on BBB, and the weights alphai\\\\alpha_ialphai​ are arbitrary reals (possibly negative or larger than 111). All four data functions are read at their given arguments; the step computes and returns a new record and modifies nothing.\n\ntileAccumFold. With the same type assumptions and the same arguments alpha,mathrmval,a,c\\\\alpha, \\\\mathrm{val}, a, calpha,mathrmval,a,c as the step, this is a total function of a list of tiles mathcalB=(B1,ldots,Bk)\\\\mathcal{B} = (B_1, \\\\ldots, B_k)mathcalB=(B1​,ldots,Bk​) and an accumulator, defined by structural recursion on the list: on the empty list it returns the accumulator unchanged; on B1::(B2,ldots,Bk)B_1 :: (B_2, \\\\ldots, B_k)B1​::(B2​,ldots,Bk​) it applies one step at B1B_1B1​ and recurses on the remaining list with the updated accumulator. Tiles are thus processed in list order, first to last, threading the accumulator through. The recursion is structural, so the function is defined for every list of finite sets: tiles may repeat or overlap, and the list need not satisfy any partition property.\n\ntileAccum. The accumulator after processing all tiles: the fold above applied to mathcalB=(B1,ldots,Bk)\\\\mathcal{B} = (B_1, \\\\ldots, B_k)mathcalB=(B1​,ldots,Bk​) with the initial accumulator (0,0,0)(0, 0, 0)(0,0,0), the zeros being those of mathbbR\\\\mathbb{R}mathbbR, WWW, and VVV. Unfolding the recursion, the three components are\n\n

L=sump=1ksumiinBpalphai,mathrmval(i),qquadA=sump=1ksumiinBpalphaicdotai,qquadC=sump=1ksumiinBpalphaicdotci,L = \\\\sum_{p=1}^{k} \\\\sum_{i \\\\in B_p} \\\\alpha_i \\\\, \\\\mathrm{val}(i), \\\\qquad A = \\\\sum_{p=1}^{k} \\\\sum_{i \\\\in B_p} \\\\alpha_i \\\\cdot a_i, \\\\qquad C = \\\\sum_{p=1}^{k} \\\\sum_{i \\\\in B_p} \\\\alpha_i \\\\cdot c_i,L=sump=1k​sumiinBp​​alphai​,mathrmval(i),qquadA=sump=1k​sumiinBp​​alphai​cdotai​,qquadC=sump=1k​sumiinBp​​alphai​cdotci​,

\n\nthe outer sums running over the positions of the list: an index iii belonging to several tiles, or a tile repeated in the list, contributes once per occurrence. For the empty list the result is (0,0,0)(0, 0, 0)(0,0,0). Because all additions involved are commutative, this final value does not depend on the order of the list, although the intermediate accumulator states do.\n\nframeLoss. For a type iota\\\\iotaiota and arbitrary types W,VW, VW,V carrying no structure whatsoever, given an arbitrary map h:WtoVh : W \\\\to Vh:WtoV, a family f:iotato(WtimesVtomathbbR)f : \\\\iota \\\\to (W \\\\times V \\\\to \\\\mathbb{R})f:iotato(WtimesVtomathbbR), weights alpha:iotatomathbbR\\\\alpha : \\\\iota \\\\to \\\\mathbb{R}alpha:iotatomathbbR, a finite set IsubseteqiotaI \\\\subseteq \\\\iotaIsubseteqiota, and a point winWw \\\\in WwinW, this defines the real number\n\n

L(w)=sumiinIalphaicdotfibig(w,,h(w)big).L(w) = \\\\sum_{i \\\\in I} \\\\alpha_i \\\\cdot f_i\\\\big(w,\\\\, h(w)\\\\big).L(w)=sumiinI​alphai​cdotfi​big(w,,h(w)big).

\n\nEach summand evaluates fif_ifi​ at the pair whose first component is www itself and whose second component is h(w)h(w)h(w); the shared value h(w)h(w)h(w) is the same in every term of the sum. No assumption is placed on hhh or on the fif_ifi​ (in particular no continuity or differentiability), none on the weights (arbitrary reals, possibly negative), and III may be empty, in which case L(w)=0L(w) = 0L(w)=0.\n\ntiledGrad. For a type iota\\\\iotaiota and natural numbers d,md, md,m: given alpha,mathrmval:iotatomathbbR\\\\alpha, \\\\mathrm{val} : \\\\iota \\\\to \\\\mathbb{R}alpha,mathrmval:iotatomathbbR, families a:iotatomathbbRda : \\\\iota \\\\to \\\\mathbb{R}^da:iotatomathbbRd and c:iotatomathbbRmc : \\\\iota \\\\to \\\\mathbb{R}^mc:iotatomathbbRm (Euclidean spaces of ddd- and mmm-tuples with the standard inner product), a continuous mathbbR\\\\mathbb{R}mathbbR-linear map Dh:mathbbRdtomathbbRmDh : \\\\mathbb{R}^d \\\\to \\\\mathbb{R}^mDh:mathbbRdtomathbbRm, and a list of finite sets mathcalB\\\\mathcal{B}mathcalB, this defines the vector in mathbbRd\\\\mathbb{R}^dmathbbRd\n\n

gmathrmtile=A+Dhast(C),g_{\\\\mathrm{tile}} = A + Dh^{\\\\ast}(C),gmathrmtile​=A+Dhast(C),

\n\nwhere (L,A,C)=mathrmtileAccum(alpha,mathrmval,a,c,mathcalB)(L, A, C) = \\\\mathrm{tileAccum}(\\\\alpha, \\\\mathrm{val}, a, c, \\\\mathcal{B})(L,A,C)=mathrmtileAccum(alpha,mathrmval,a,c,mathcalB) is the accumulator expanded above, and Dhast:mathbbRmtomathbbRdDh^{\\\\ast} : \\\\mathbb{R}^m \\\\to \\\\mathbb{R}^dDhast:mathbbRmtomathbbRd is the adjoint of DhDhDh with respect to the standard inner products, i.e. the unique continuous linear map satisfying langleDh,x,,yrangle=langlex,,Dhastyrangle\\\\langle Dh\\\\, x,\\\\, y \\\\rangle = \\\\langle x,\\\\, Dh^{\\\\ast} y \\\\ranglelangleDh,x,,yrangle=langlex,,Dhastyrangle for all xinmathbbRdx \\\\in \\\\mathbb{R}^dxinmathbbRd, yinmathbbRmy \\\\in \\\\mathbb{R}^myinmathbbRm (over the reals, the transpose). Only the components AAA and CCC of the accumulator enter the value: the loss component LLL \u2014 and hence the entire argument mathrmval\\\\mathrm{val}mathrmval \u2014 has no influence on the result. Furthermore, no hypothesis connects mathcalB\\\\mathcal{B}mathcalB to a partition of any set: it is an arbitrary list, and indices occurring in several tiles are counted with multiplicity.\n\nclipVec. For a real number ccc and a vector ggg in a real normed space WWW (a normed abelian group with a compatible scalar multiplication by mathbbR\\\\mathbb{R}mathbbR; in particular ∣g∣=0\\\\|g\\\\| = 0∣g∣=0 exactly when g=0g = 0g=0), the clipped vector is defined by an if-then-else on the inclusive norm test ∣g∣lec\\\\|g\\\\| \\\\le c∣g∣lec:\n\n

\\\\mathrm{clip}_c(g) = \\\\begin{cases} g, & \\\\text{if } \\\\|g\\\\| \\\\le c, \\\\\\\\[4pt] \\\\dfrac{c}{\\\\|g\\\\|}\\\\, g, & \\\\text{if } \\\\|g\\\\| > c. \\\\end{cases}

\n\nThe function is total for every cinmathbbRc \\\\in \\\\mathbb{R}cinmathbbR, and real division is total with the convention x/0=0x / 0 = 0x/0=0. Consequences of the literal clauses: if gneq0g \\\\neq 0gneq0 and 0lec<∣g∣0 \\\\le c < \\\\|g\\\\|0lec<∣g∣, the result is ggg rescaled by the positive factor c/∣g∣c/\\\\|g\\\\|c/∣g∣, i.e. a vector of norm exactly ccc pointing along ggg (and c=0c = 0c=0 yields the zero vector); if gneq0g \\\\neq 0gneq0 and c<0c < 0c<0, the test ∣g∣lec\\\\|g\\\\| \\\\le c∣g∣lec necessarily fails and the else-branch multiplies ggg by the negative scalar c/∣g∣c/\\\\|g\\\\|c/∣g∣, producing a vector of norm ∣c∣|c|∣c∣ pointing opposite to ggg; if g=0g = 0g=0, both branches return the zero vector \u2014 for cge0c \\\\ge 0cge0 via the then-branch, and for c<0c < 0c<0 via the else-branch, where tfracc∣g∣g=tfracc0cdot0=0cdot0=0\\\\tfrac{c}{\\\\|g\\\\|} g = \\\\tfrac{c}{0} \\\\cdot 0 = 0 \\\\cdot 0 = 0tfracc∣g∣g=tfracc0cdot0=0cdot0=0 under the stated division convention.\n\ncoordMask. For a natural number ddd, a finite set TTT of coordinates (Tsubseteq0,ldots,d−1T \\\\subseteq \\\\{0, \\\\ldots, d-1\\\\}Tsubseteq0,ldots,d−1, the index type of length ddd), and a vector winmathbbRdw \\\\in \\\\mathbb{R}^dwinmathbbRd, this is the coordinatewise mask PTP_TPT​ defined by\n\n

(P_T\\\\, w)_j = \\\\begin{cases} w_j, & j \\\\in T, \\\\\\\\ 0, & j \\\\notin T, \\\\end{cases} \\\\qquad j = 0, \\\\ldots, d-1,

\n\ni.e. coordinates in TTT are kept and all others are set to zero. (The code re-packages the coordinate function into the Euclidean-space type; on underlying coordinates this packaging is the identity, so the map is exactly the mask above.) The map is linear in www; if T=varnothingT = \\\\varnothingT=varnothing it is the zero map, and if TTT is the full set of all ddd coordinates it is the identity.\n\nlogicalStep. For a natural number ddd and an arbitrary type sigma\\\\sigmasigma carrying no structure, given a finite set TTT of coordinates, a real number ccc, an arbitrary function U:sigmatomathbbRdtosigmaU : \\\\sigma \\\\to \\\\mathbb{R}^d \\\\to \\\\sigmaU:sigmatomathbbRdtosigma, a state SinsigmaS \\\\in \\\\sigmaSinsigma, and a direction ginmathbbRdg \\\\in \\\\mathbb{R}^dginmathbbRd, one logical step returns the state\n\n

Ubig(S,;mathrmclipc(PT,g)big),U\\\\big(S,\\\\; \\\\mathrm{clip}_c(P_T\\\\, g)\\\\big),Ubig(S,;mathrmclipc​(PT​,g)big),

\n\nthat is: the direction ggg is first masked to the coordinates in TTT by PTP_TPT​; the masked vector is then clipped by mathrmclipc\\\\mathrm{clip}_cmathrmclipc​, so the radius test applies to ∣PT,g∣\\\\|P_T\\\\, g\\\\|∣PT​,g∣ \u2014 the norm of the already-masked vector, not of ggg; and finally UUU is applied exactly once to the pair consisting of the starting state SSS and the resulting clipped vector. No property whatsoever is assumed of UUU: it is an arbitrary function of a state and a direction returning a state. Besides the clipping scalar c/∣cdot∣c/\\\\|{\\\\cdot}\\\\|c/∣cdot∣ above, no further scaling, normalization, or correction factor appears anywhere in the step, and UUU is applied a single time, not iterated. The radius ccc is an arbitrary real, so the negative-radius and zero-vector behavior of mathrmclipc\\\\mathrm{clip}_cmathrmclipc​ described above carries over verbatim."\n}", "startLine": 1, "lineNumbers": [1, 2, 3]}, "meta": {"source": {"type": "internal", "value": "agent://RB-VathekFrame"}}}}

Human review
  • Endorsed by Shuze Chen · Sep 25, 2026

  • Endorsed by ajax · Sep 25, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me