Skip to content
ImagineWorld

LPC-SM: Local Predictive Coding and Sparse Memory for Long-Context Language Modeling

node_idnode-paper_arxiv-2604.03263_lpc-sm-local-predictive-coding-and-sparse-memory-for-long-context-language
node_typenode-paper
schema_profileworld.node_paper.v1
alternate_namesarxiv-2604.03263
statusactive
orthogonal_scopemanifold, entropy, authority, state
manifoldworld
entropymedium
authorityguides
stateexternal
domainimagineworld.net
node_interiorrosetta_contract
unisonone evidence claim read five ways: seated in the predictive-harnesses field, the work combines local predictive coding with sparse memory for long-context language modeling — anticipation computed locally, memory kept sparse, for long sequences — its framework, regime, and stance agreeing on what it is
governed_byWORLD-MANIFOLD, CORPUS
constitutional_citationCONSTITUTION
evidence_bundleworld-bundle-paper
publication_classarxiv_preprint
paper_titleLPC-SM: Local Predictive Coding and Sparse Memory for Long-Context Language Modeling
paper_authorsKeqin Xie
arxiv_id2604.03263
arxiv_urlhttps://arxiv.org/abs/2604.03263
arxiv_categories{"primary":"cs.CL","secondary":["cs.AI","cs.NE"]}
arxiv_v1
arxiv_submitted_at2026-03-12
arxiv_updated_at2026-03-12
ocr_sourcearxiv_html
ocr_quality_classverbatim_latexml_html
extraction_toolarxiv-nodepaper-transpose
extraction_pipeline_versionworld-ingest-arxiv-html-v1.0
extracted_at2026-10-13T06:51:09Z
math_preserved_as_latextrue
figures_extractedfalse
references_structurally_parsedfalse
created_at2026-10-13T06:51:09Z
updated_at2026-10-14T05:23:52Z
local graph

LPC-SM: Local Predictive Coding and Sparse Memory for Long-Context Language Modeling

Section titled “LPC-SM: Local Predictive Coding and Sparse Memory for Long-Context Language Modeling”

Authors: Keqin Xie

arxiv: 2604.03263

Converted to markdown on 2026-10-13 from the arXiv HTML (LaTeXML) rendering. This paper’s figures are not image-based or were unavailable; captions are kept.


Most current long-context language models still rely on attention to handle both local interaction and long-range state, which leaves relatively little room to test alternative decompositions of sequence modeling. We propose LPC-SM, a hybrid autoregressive architecture that separates local attention, persistent memory, predictive correction, and run-time control within the same block, and we use Orthogonal Novelty Transport (ONT) to govern slow-memory writes. We evaluate a 158M-parameter model in three stages spanning base language modeling, mathematical continuation, and 4096-token continuation. Removing mHC raises the Stage-A final LM loss from 12.630 to 15.127, while adaptive sparse control improves the Stage-B final LM loss from 12.137 to 10.787 relative to a matched fixed-ratio continuation. The full route remains stable at sequence length 4096, where Stage C ends with final LM loss 11.582 and improves the delayed-identifier diagnostic from 14.396 to 12.031 in key cross-entropy. Taken together, these results show that long-context autoregressive modeling can be organized around a broader division of labor than attention alone.

Keywords: long-context language modeling; sparse memory; predictive coding; recurrent memory; hybrid autoregressive models

Transformer language models have been scaled with striking success, and most of that success has come from making attention broader, denser, cheaper, or easier to reuse. Even when recurrence, compression, or retrieval enters the picture, attention usually remains the place where the model is expected to reconcile nearby context with far-away state. That default is strong enough that alternative decompositions of sequence modeling are often treated as peripheral unless they already outperform a mature Transformer baseline. We think that order of judgment is too restrictive. Before asking whether another decomposition wins, it is worth asking whether it can be made coherent, trainable, and empirically legible in its own right [1, 2, 3, 4, 5, 6, 7].

LPC-SM starts from that narrower question. We keep local causal attention for what it already does well: short-range precision. We then give longer-lived state to a dual-timescale memory, expose representation mismatch through an explicit predictive-correction pathway, and let a small set of learned controllers regulate sparsity, memory writing, and stopping behavior. The point is not to remove attention from the model, nor to argue that a recurrent state should replace it wholesale. The point is to test whether these roles become easier to study once they are assigned to different mechanisms rather than folded back into a single attention-dominant block.

That choice makes the slow-memory write unusually important. If chunk summaries repeatedly move in directions the slow state already represents, the model spends write capacity on reinforcement rather than accumulation. ONT is our answer to that problem. It leaves the component already aligned with the slow state untouched and amplifies only the orthogonal novelty component before the write. From one angle, this is a small geometric modification. From another, it is the moment where the architecture commits to the idea that memory should preserve what is already there and spend additional capacity on what is genuinely new.

We evaluate LPC-SM at 158M parameters in three stages: base language modeling, mathematical continuation, and a 4096-token continuation run. The evidence at this scale is uneven in a useful way. mHC and adaptive sparse control show clear gains. Slow memory helps, though more modestly. Predictive coding, ONT, and learned stopping are not yet well summarized by base LM loss alone. That asymmetry is informative. It suggests that the architecture is already doing enough for individual mechanisms to become separable, even if not all of them have reached the regime in which their intended benefits are fully visible.

The immediate backdrop for LPC-SM is still the Transformer family, including sparse and local variants [8, 9, 10, 11, 12]. Those models differ sharply in efficiency, receptive field, and memory footprint, yet they share a common structural assumption: context is still mediated mainly through attention. That is the baseline from which LPC-SM departs. We are not asking whether attention can be made cheaper; we are asking what changes once attention is no longer asked to be the only durable carrier of sequence state.

A second thread in the literature weakens that assumption by introducing persistent state. Transformer-XL, Compressive Transformer, recurrent memory transformers, RetNet, RWKV, and Mamba all treat recurrence or compressed state as something more than a cache optimization [13, 14, 15, 16, 17, 18]. More recent systems such as Griffin, Titans, Hymba, and Mamba-2 go further in blending attention with recurrent or state-space components [2, 3, 4, 1]. LPC-SM is close to this line of work in spirit. The difference is that we make two distinctions explicit that are often left implicit: fast versus slow memory, and local correction versus long-range storage.

Long-context extension methods form a neighboring but distinct literature. LongRoPE and InfLLM show that existing models can often be pushed well beyond their nominal context range through positional extrapolation or memory-assisted inference [5, 6]. We see those methods as evidence that long-context behavior is still pliable. At the same time, they leave the internal division of labor mostly intact. LPC-SM addresses a different question. Instead of stretching an attention-centered architecture outward, we reassign some of the work inward, at the block level, before asking how far the context can be extended.

The predictive-correction path draws on predictive-coding ideas in neuroscience and machine learning [19, 20, 21, 22]. Most language models let depth absorb mismatch implicitly: hidden states are updated, but the disagreement between a local explanation and the current representation is not itself exposed as a first-class quantity. We chose to expose it because mismatch seems like exactly the kind of signal that should interact with internal control. Once that signal is available, connections to adaptive computation and routing become natural [23, 24, 25, 26, 27], though LPC-SM does not use those ideas in the usual token-skipping or expert-selection form.

Let x_1:Tx\_{1:T} be a token sequence and let h_t0h\_{t}^{0} denote its token-plus-position embedding at position tt. LPC-SM applies LL identical autoregressive blocks followed by a final normalization and two output heads. Figures 1, 2, and 3 illustrate the overall stack, the internal structure of a single block, and the ONT write used by the slow-memory pathway.

Figure 1: Overall LPC-SM stack.

Each block begins with RMSNorm [28] and then combines three information sources at token position tt: a local-attention read, a dual-timescale memory read, and a predictive correction. The local-attention path is windowed and causal,

a_t=Attn(h_max⁡(1,t−w+1):t),a\_{t}=\mathrm{Attn}(h\_{\max(1,t-w+1):t}),

where ww is the local window. The goal of this path is local precision rather than long-range storage.

In the default configuration, queries, keys, and values are obtained from a shared linear projection. The implementation also supports a multi-head latent-attention variant in which

q_t=W_qh_t,z_t=W_zh_t,k_t=W_k↑z_t,v_t=W_v↑z_t,q\_{t}=W\_{q}h\_{t},\qquad z\_{t}=W\_{z}h\_{t},\qquad k\_{t}=W\_{k}^{\uparrow}z\_{t},\qquad v\_{t}=W\_{v}^{\uparrow}z\_{t},

so that the key-value side is compressed through a latent bottleneck before being lifted back into head space. This option is not essential to the architecture, but it is part of the model family implemented in the code and allows us to vary how much of the local path is spent on explicit key-value bandwidth.

The memory path maintains a fast state updated every token and a slow state updated only at chunk boundaries. The fast state follows

d_t=σ(W_dh_t),u_t=tanh⁡(W_uh_t),d\_{t}=\sigma(W\_{d}h\_{t}),\qquad u\_{t}=\tanh(W\_{u}h\_{t}),
m_tf=d_t⊙m_t−1f+(1−d_t)⊙u_t.m\_{t}^{f}=d\_{t}\odot m\_{t-1}^{f}+(1-d\_{t})\odot u\_{t}.

Separate gates query the fast and slow pathways,

q_tf=σ(W_qfh_t),q_ts=σ(W_qsh_t),q\_{t}^{f}=\sigma(W\_{qf}h\_{t}),\qquad q\_{t}^{s}=\sigma(W\_{qs}h\_{t}),
r_t=W_r[q_tf⊙m_tf∥q_ts⊙m_k−1s].r\_{t}=W\_{r}\big[q\_{t}^{f}\odot m\_{t}^{f}\parallel q\_{t}^{s}\odot m\_{k-1}^{s}\big].

This design gives the model a token-level recurrent trace and a chunk-level persistent state without forcing either one to replace local attention. The distinction matters because these two memories are not doing the same job at different timescales. The fast state remains close to tokenwise evidence, while the slow state only changes when a chunk has accumulated enough evidence to justify a write. Put differently, the architecture assumes that persistence should be selective, not continuous.

Figure 2: A single LPC-SM block.

At the end of chunk C_kC\_{k}, the block forms a chunk summary

$$c_{k}=\frac{1}{C_{k}

The slow-memory gate is input dependent,

g_k=σ(W_gh_t).g\_{k}=\sigma(W\_{g}h\_{t}).

The question is how c_kc\_{k} should be transported before it is written into the slow state. ONT defines the aligned component relative to the previous slow state m_k−1sm\_{k-1}^{s} by

proj(c_k∣m_k−1s)={0,if ∥m_k−1s∥_2=0,c_k⊤m_k−1s∥m_k−1s∥_22m_k−1s,otherwise,\mathrm{proj}(c\_{k}\mid m\_{k-1}^{s})=\begin{cases}0,&\text{if }\|m\_{k-1}^{s}\|\_{2}=0,\\[6.0pt] \dfrac{c\_{k}^{\top}m\_{k-1}^{s}}{\|m\_{k-1}^{s}\|\_{2}^{2}}m\_{k-1}^{s},&\text{otherwise,}\end{cases}

and the novelty component by

n_k=c_k−proj(c_k∣m_k−1s).n\_{k}=c\_{k}-\mathrm{proj}(c\_{k}\mid m\_{k-1}^{s}).

The transported summary is

c_k⋆=c_k+α_nn_k,c\_{k}^{\star}=c\_{k}+\alpha\_{n}n\_{k},

where α_n≥0\alpha\_{n}\geq 0 is the novelty coefficient. The slow-memory update then follows:

u~_k=tanh⁡(W_cc_k⋆),m_ks=g_k⊙m_k−1s+(1−g_k)⊙u~_k.\tilde{u}\_{k}=\tanh(W\_{c}c\_{k}^{\star}),\qquad m\_{k}^{s}=g\_{k}\odot m\_{k-1}^{s}+(1-g\_{k})\odot\tilde{u}\_{k}.

During autoregressive generation, the same write rule operates on a per-layer cache that keeps the attention history, fast state, slow state, and the running partial chunk summary. That choice is easy to overlook, but it matters. A slow-memory mechanism can look appealing on paper and still drift into a train-inference mismatch if prompt-side partial chunks are treated differently from training chunks. We therefore keep the write order aligned across the two regimes as closely as possible.

Figure 3: Orthogonal Novelty Transport for slow-memory writes.

The block also predicts the current hidden state from local context and memory and then corrects that prediction with an explicit mismatch signal.

The predictor is initialized by

h^_t(0)=f_pred([a_t∥r_t]),\hat{h}\_{t}^{(0)}=f\_{\mathrm{pred}}\big([a\_{t}\parallel r\_{t}]\big),

and refined iteratively:

h^_t(s+1)=h^_t(s)+f_refine([a_t∥r_t∥h_t−h^_t(s)]).\hat{h}\_{t}^{(s+1)}=\hat{h}\_{t}^{(s)}+f\_{\mathrm{refine}}\big([a\_{t}\parallel r\_{t}\parallel h\_{t}-\hat{h}\_{t}^{(s)}]\big).

LPC-SM does not force this pathway to act uniformly at every token. Instead, a learned controller converts error statistics into a sparse event mask through score normalization, a learned bias-scale transform, a temperature, and a straight-through hard threshold. The sparse ratio itself remains learnable within prescribed bounds. That detail is central to how we interpret the controller: the architecture is not merely sparsified; it is allowed to choose how sparse it wants to be within a bounded regime.

The same model family also contains an optional multi-head-coupled residual router (mHC), following the hyper-connection view developed in [29]. Our use is narrower than the full formulation in that work: here mHC sits inside each LPC-SM block as a residual transport layer rather than as a global system-level redesign. Rather than forwarding a single hidden stream directly through the block, mHC lifts the state into multiple streams, learns pre-mixing weights, applies a Sinkhorn-normalized residual transport across streams, and then injects the updated block output back through learned post-mixing coefficients. What we found empirically is that this is not a cosmetic addition. At 158M parameters, mHC is the mechanism whose removal hurts most. That makes it more natural to read mHC as part of the core block geometry than as an optional embellishment.

The training objective combines next-token prediction with auxiliary terms for predictive correction, sparsity, memory magnitude, and stopping:

L=\displaystyle L={}L_lm+λ_predL_pred+λ_sparseL_sparse\displaystyle L\_{\mathrm{lm}}+\lambda\_{\mathrm{pred}}L\_{\mathrm{pred}}+\lambda\_{\mathrm{sparse}}L\_{\mathrm{sparse}}
------------
+λ_memL_mem+λ_stopL_stop.\displaystyle+\lambda\_{\mathrm{mem}}L\_{\mathrm{mem}}+\lambda\_{\mathrm{stop}}L\_{\mathrm{stop}}.

The language-model term is standard cross-entropy. The auxiliary terms are there for a narrower reason: they keep the explicit mechanisms from becoming inert. Predictive correction is penalized through its mismatch signal, sparsity is regularized so the controller cannot drift arbitrarily, memory magnitude is constrained to keep the recurrent path from dominating by scale alone, and the stop head is nudged toward EOS-sensitive behavior. We do not claim that this objective is the only reasonable one. We claim something smaller: once the architecture exposes correction, sparsity, memory, and stopping as explicit state variables, it is natural to let the training objective acknowledge them rather than pretend they are invisible.

All experiments reported here use the same 158,313,241-parameter model with a GPT-2 tokenizer. Training proceeds in three stages summarized in Table 1.

Table 1: Staged training schedule for the 158M study.

StageCorpusTokensSeq.
ADolma3-base32.77M2048
BOpenWebMath-10k16.38M2048
CLongMino continuation24.58M4096

We evaluate LPC-SM across base modeling, mathematical continuation, and longer-context continuation under a common training pipeline. The staged schedule is not only a convenience for limited compute. It also separates three questions that would be entangled in a single monolithic run: whether the architecture can serve as a base language model at all, whether its internal control signals remain useful when the domain shifts toward mathematics, and whether the same route survives a substantial increase in effective context length. Keeping these stages explicit makes the later comparisons easier to interpret.

Given the parameter count of 158M, the token budgets in Stages A and B (32.77M and 16.38M, respectively) place the model in a significant underfitting regime relative to standard scaling laws [30, 31]. We treat these runs as a proof-of-concept study of structural emergence, numerical stability, and functional interaction among the LPC-SM modules rather than as a compute-optimal perplexity target. The small-scale setting is useful precisely because it makes the early behavior of the controllers and the ONT pathway easier to inspect.

Stage A includes the full model together with five ablations: slow memory removed, predictive coding removed, ONT disabled, stop head removed, and mHC removed. This stage is designed to answer a narrow architectural question: which mechanisms affect the optimization behavior of the base model under a fixed parameter budget? Stage B compares adaptive sparse control against a fixed sparse-ratio control initialized from the same Stage-A checkpoint and trained on the same data for the same budget. Because the initialization and continuation corpus are matched, the comparison isolates the value of learned control more cleanly than a comparison across independently trained models would. Stage C extends the full route to sequence length 4096. Here the emphasis is not on winning against another method, but on whether the full architecture remains trainable once longer-sequence recurrence, chunked writes, and explicit correction are exercised together.

We use final LM loss at the end of each stage as the primary metric. We also report training throughput, the learned sparse ratio, and fixed-prompt sanity checks. Final LM loss is not intended to summarize every design goal of LPC-SM. In particular, predictive correction, ONT, and the stop head are meant to affect behavior that is only partially visible through base pretraining loss. We nevertheless treat final loss as the most stable common measure across all reported runs, and we interpret the ablations with that limitation in mind rather than reading every gain or loss as a full verdict on the underlying mechanism.

Tables 2, 3, and 4 summarize the 158M study.

Table 2: Stage-A ablations at 158M parameters. Lower is better.

VariantFinal LMΔ\Delta (%)Tok/sFinal ratio
Full LPC-SM12.6300.00067980.226
w/o slow memory12.671+0.320219380.249
w/o predictive coding12.413-1.71970830.600
w/o ONT11.781-6.72466760.235
w/o stop head12.078-4.37766300.228
w/o mHC15.127+19.76470380.234

Stage A separates the block into mechanisms that affect optimization in visibly different ways. The clearest regression comes from removing mHC: the final LM loss rises from 12.630 to 15.127, which is large enough to treat residual routing as part of the effective core block rather than as an optional refinement. Removing slow memory changes the final loss only slightly, but the direction is still unfavorable to the ablation. That is a weaker signal than the mHC result, yet it is consistent with the claim that the recurrent path is doing some useful work even before the model has been trained at larger scale.

The remaining ablations are less straightforward. Removing predictive coding, ONT, or the stop head lowers the base-stage LM loss. In the present regime, we interpret that result cautiously. The model is strongly undertrained relative to its parameter count, and several LPC-SM components are not designed primarily to improve short-budget next-token loss. Predictive correction, novelty-constrained transport, and stopping all bias the internal organization of the model toward behaviors whose payoff is more likely to appear under continuation, longer-range conditioning, or downstream adaptation than in the most immediate Stage-A metric.

Table 3: Continuation runs at 158M parameters.

StageVariantSeq.Final LMΔ\Delta (%)Tok/sFinal ratio
BAdaptive sparse control204810.7870.00067280.214
BFixed sparse control204812.137+12.51767110.226
CAdaptive long-context continuation409611.582–37110.215

Stage B provides the clearest evidence that the internal controller is doing substantive work rather than merely tracking training noise. The adaptive run improves final LM loss by 12.5% relative to the matched fixed-ratio control while holding initialization, data, and training budget constant. Because the two runs differ only in whether the sparse ratio remains learnable, the comparison isolates the role of adaptive control more cleanly than the broader Stage-A ablations. In this setting, allowing the controller to move appears to help the model rebalance computation as the continuation domain shifts from general text to mathematics.

Stage C addresses a different question. Here the issue is not whether the controller beats a fixed alternative, but whether the full route remains trainable once the sequence length doubles from 2048 to 4096. The run completes without removing the memory pathway, predictive correction, routing, or learned control, and it finishes with final LM loss 11.582. From the perspective of architecture validation, this matters because a hybrid block can look reasonable at short sequence lengths yet become brittle once recurrence, chunked writes, and longer continuation interact. That behavior does not appear in the present run.

Table 4: Diagnostic delayed-identifier probe. Lower key cross-entropy is better. The probe uses a header that introduces a key, a long distractor region, and a trigger prefix that asks the model to continue the identifier. Stage-A values use six 2040-token prompts; the Stage-C column scores the same probe after long-context continuation.

ProbeStage-A fullw/o slow memoryw/o ONTStage-C full
Delayed identifier CE14.39613.86515.42712.031

Table 4 adds a more diagnostic view of long-range conditioning than free generation does at this stage. Instead of asking the model to produce an answer from scratch, we score the cross-entropy of the correct delayed identifier under teacher forcing. Two patterns stand out. First, disabling ONT worsens the diagnostic relative to the full model, which is consistent with the idea that novelty-aware writes help preserve delayed information. Second, the full model improves substantially after Stage C continuation, with the delayed-identifier cross-entropy falling from 14.396 to 12.031 on the same probe family. The comparison with the slow-memory ablation remains mixed: at 158M, the no-memory variant is still slightly better on this probe than the full Stage-A model. For that reason, we do not read Table 4 as a definitive isolation of the slow-memory mechanism. We read it as evidence that long-context continuation sharpens delayed conditioning in the full route, while the contribution of individual memory components is not yet cleanly separated at the present scale.

We introduced LPC-SM as a long-context autoregressive architecture that separates local attention, persistent memory, predictive correction, and internal control within the same block. Across the 158M study, the strongest empirical support comes from mHC and adaptive sparse control. Removing mHC causes the largest Stage-A regression, while adaptive sparse control clearly outperforms a matched fixed-ratio continuation in Stage B. The full route also remains stable when the sequence length doubles to 4096 in Stage C.

The evidence for the memory pathway is more qualified. Slow memory is compatible with stable long-context continuation, and the delayed-identifier probe improves materially after Stage C training, with the key cross-entropy falling from 14.396 to 12.031. At the same time, the 158M ablations do not yet isolate a uniformly positive effect for every memory-related component under every metric. That is the main reason we treat the present paper as an architecture validation study rather than as a claim of compute-optimal superiority.

Within that scope, the results are still meaningful. They show that the LPC-SM decomposition can be trained end to end, that several of its internal control mechanisms matter measurably, and that longer-context continuation sharpens delayed conditioning in the full model. Larger 1B-scale runs are currently in progress.

We state here the mathematical properties corresponding to the ONT write used in the implementation. The underlying geometry is the standard orthogonal decomposition of a vector into components parallel and orthogonal to a reference direction [32], specialized here to the slow-memory write rule used by LPC-SM.

Definition A.1 (ONT projection, novelty, and transport).
Section titled “Definition A.1 (ONT projection, novelty, and transport).”

Let EE be a real inner-product space. For c,m∈Ec,m\in E and α∈R\alpha\in\mathbb{R}, define

P_m(c)={0,if m=0,⟨c,m⟩∥m∥2m,if m≠0,N_m(c)=c−P_m(c),P\_{m}(c)=\begin{cases}0,&\text{if }m=0,\\[4.0pt] \dfrac{\langle c,m\rangle}{\|m\|^{2}}m,&\text{if }m\neq 0,\end{cases}\qquad N\_{m}(c)=c-P\_{m}(c),

and

T_α(c,m)=c+αN_m(c).T\_{\alpha}(c,m)=c+\alpha N\_{m}(c).
Definition A.2 (Comparison target and feasible set).
Section titled “Definition A.2 (Comparison target and feasible set).”

For c∈Ec\in E and α∈R\alpha\in\mathbb{R}, define the comparison target

Y_α(c)=(1+α)c.Y\_{\alpha}(c)=(1+\alpha)c.

For c,m∈Ec,m\in E, define the feasible affine set

A(c,m)={x∈E:⟨x,m⟩=⟨c,m⟩}.\mathcal{A}(c,m)=\{x\in E:\langle x,m\rangle=\langle c,m\rangle\}.
Proposition A.3 (Basic decomposition and aligned gap).
Section titled “Proposition A.3 (Basic decomposition and aligned gap).”

For every c,m∈Ec,m\in E and α∈R\alpha\in\mathbb{R},

c=P_m(c)+N_m(c),⟨N_m(c),m⟩=0,c=P\_{m}(c)+N\_{m}(c),\qquad\langle N\_{m}(c),m\rangle=0,

and

T_α(c,m)=P_m(c)+(1+α)N_m(c).T\_{\alpha}(c,m)=P\_{m}(c)+(1+\alpha)N\_{m}(c).

Moreover,

Y_α(c)\displaystyle Y\_{\alpha}(c)=T_α(c,m)+αP_m(c),\displaystyle=T\_{\alpha}(c,m)+\alpha P\_{m}(c),
------------
T_α(c,m)−Y_α(c)\displaystyle T\_{\alpha}(c,m)-Y\_{\alpha}(c)=−αP_m(c).\displaystyle=-\alpha P\_{m}(c).

The identity c=P_m(c)+N_m(c)c=P\_{m}(c)+N\_{m}(c) is immediate from the definition of N_m(c)N\_{m}(c). When m=0m=0, the orthogonality claim reduces to ⟨c,0⟩=0\langle c,0\rangle=0. When m≠0m\neq 0, P_m(c)P\_{m}(c) is the usual projection of cc onto the one-dimensional subspace spanned by mm, so

⟨N_m(c),m⟩=⟨c−P_m(c),m⟩=⟨c,m⟩−⟨c,m⟩∥m∥2⟨m,m⟩=0.\langle N\_{m}(c),m\rangle=\langle c-P\_{m}(c),m\rangle=\langle c,m\rangle-\frac{\langle c,m\rangle}{\|m\|^{2}}\langle m,m\rangle=0.

Substituting c=P_m(c)+N_m(c)c=P\_{m}(c)+N\_{m}(c) into T_α(c,m)=c+αN_m(c)T\_{\alpha}(c,m)=c+\alpha N\_{m}(c) gives

T_α(c,m)=P_m(c)+(1+α)N_m(c).T\_{\alpha}(c,m)=P\_{m}(c)+(1+\alpha)N\_{m}(c).

Likewise,

Y_α(c)=(1+α)(P_m(c)+N_m(c))=T_α(c,m)+αP_m(c),Y\_{\alpha}(c)=(1+\alpha)\bigl(P\_{m}(c)+N\_{m}(c)\bigr)=T\_{\alpha}(c,m)+\alpha P\_{m}(c),

and the final identity follows by subtraction. ∎

For every c,m∈Ec,m\in E and α∈R\alpha\in\mathbb{R}, the ONT transport satisfies

⟨T_α(c,m),m⟩=⟨c,m⟩.\langle T\_{\alpha}(c,m),m\rangle=\langle c,m\rangle.

Equivalently, T_α(c,m)∈A(c,m)T\_{\alpha}(c,m)\in\mathcal{A}(c,m).

By definition,

⟨T_α(c,m),m⟩=⟨c+αN_m(c),m⟩=⟨c,m⟩+α⟨N_m(c),m⟩.\langle T\_{\alpha}(c,m),m\rangle=\langle c+\alpha N\_{m}(c),m\rangle=\langle c,m\rangle+\alpha\langle N\_{m}(c),m\rangle.

The orthogonality result from Proposition A.3 implies ⟨N_m(c),m⟩=0\langle N\_{m}(c),m\rangle=0, hence

⟨T_α(c,m),m⟩=⟨c,m⟩.\langle T\_{\alpha}(c,m),m\rangle=\langle c,m\rangle.

∎

Theorem A.5 (ONT is the constrained minimizer).
Section titled “Theorem A.5 (ONT is the constrained minimizer).”

Let EE be a real inner-product space, let c,m∈Ec,m\in E, and let α∈R\alpha\in\mathbb{R}. Then for every x∈A(c,m)x\in\mathcal{A}(c,m),

∥x−Y_α(c)∥2=∥x−T_α(c,m)∥2+∥T_α(c,m)−Y_α(c)∥2.\|x-Y\_{\alpha}(c)\|^{2}=\|x-T\_{\alpha}(c,m)\|^{2}+\|T\_{\alpha}(c,m)-Y\_{\alpha}(c)\|^{2}.

Consequently,

∥T_α(c,m)−Y_α(c)∥≤∥x−Y_α(c)∥for all x∈A(c,m).\|T\_{\alpha}(c,m)-Y\_{\alpha}(c)\|\leq\|x-Y\_{\alpha}(c)\|\qquad\text{for all }x\in\mathcal{A}(c,m).

Thus T_α(c,m)T\_{\alpha}(c,m) is a minimizer of

min⁡{∥x−Y_α(c)∥:x∈A(c,m)}.\min\{\|x-Y\_{\alpha}(c)\|:x\in\mathcal{A}(c,m)\}.

Fix x∈A(c,m)x\in\mathcal{A}(c,m). Since both xx and T_α(c,m)T\_{\alpha}(c,m) lie in A(c,m)\mathcal{A}(c,m), we have

⟨x−T_α(c,m),m⟩=0.\langle x-T\_{\alpha}(c,m),m\rangle=0.

By Proposition A.3, P_m(c)P\_{m}(c) is either zero or a scalar multiple of mm, hence

⟨x−T_α(c,m),P_m(c)⟩=0.\langle x-T\_{\alpha}(c,m),P\_{m}(c)\rangle=0.

Using the identity

T_α(c,m)−Y_α(c)=−αP_m(c),T\_{\alpha}(c,m)-Y\_{\alpha}(c)=-\alpha P\_{m}(c),

we obtain

⟨x−T_α(c,m),T_α(c,m)−Y_α(c)⟩=0.\langle x-T\_{\alpha}(c,m),T\_{\alpha}(c,m)-Y\_{\alpha}(c)\rangle=0.

Now decompose

x−Y_α(c)=(x−T_α(c,m))+(T_α(c,m)−Y_α(c)).x-Y\_{\alpha}(c)=\bigl(x-T\_{\alpha}(c,m)\bigr)+\bigl(T\_{\alpha}(c,m)-Y\_{\alpha}(c)\bigr).

The two summands are orthogonal, so the Pythagorean theorem yields

∥x−Y_α(c)∥2=∥x−T_α(c,m)∥2+∥T_α(c,m)−Y_α(c)∥2.\|x-Y\_{\alpha}(c)\|^{2}=\|x-T\_{\alpha}(c,m)\|^{2}+\|T\_{\alpha}(c,m)-Y\_{\alpha}(c)\|^{2}.

Since the first term on the right-hand side is nonnegative, the minimality inequality follows immediately. ∎

Under the assumptions of Theorem A.5, T_α(c,m)T\_{\alpha}(c,m) is the unique minimizer of

min⁡{∥x−Y_α(c)∥:x∈A(c,m)}.\min\{\|x-Y\_{\alpha}(c)\|:x\in\mathcal{A}(c,m)\}.

Suppose x∈A(c,m)x\in\mathcal{A}(c,m) is also a minimizer. Then

∥x−Y_α(c)∥=∥T_α(c,m)−Y_α(c)∥.\|x-Y\_{\alpha}(c)\|=\|T\_{\alpha}(c,m)-Y\_{\alpha}(c)\|.

Substituting this equality into the identity from Theorem A.5 gives

∥x−T_α(c,m)∥2=0.\|x-T\_{\alpha}(c,m)\|^{2}=0.

Hence ∥x−T_α(c,m)∥=0\|x-T\_{\alpha}(c,m)\|=0, so x=T_α(c,m)x=T\_{\alpha}(c,m). ∎

Corollary A.7 (Hilbert-space generalization).
Section titled “Corollary A.7 (Hilbert-space generalization).”

Let HH be a real Hilbert space. For every c,m∈Hc,m\in H and every α∈R\alpha\in\mathbb{R}, the ONT transport T_α(c,m)T\_{\alpha}(c,m) is the unique minimizer of

min⁡{∥x−(1+α)c∥:x∈H, ⟨x,m⟩=⟨c,m⟩}.\min\{\|x-(1+\alpha)c\|:x\in H,\ \langle x,m\rangle=\langle c,m\rangle\}.

The preceding arguments use only the axioms of a real inner-product space and therefore already hold in every such space. A real Hilbert space is, by definition, a complete real inner-product space, so the result follows by specialization. ∎

The ONT update is the write rule used by LPC-SM to insert a chunk summary into slow memory. The corresponding design problem is to construct a write xx that preserves the component already aligned with the current slow-memory state mm, while favoring motion in the novelty direction N_m(c)N\_{m}(c). For fixed c,m∈Ec,m\in E and α∈R\alpha\in\mathbb{R}, consider

min⁡_x∈A(c,m)\displaystyle\min\_{x\in\mathcal{A}(c,m)}J_α,c,m(x),\displaystyle\mathcal{J}\_{\alpha,c,m}(x),
------------
J_α,c,m(x)=\displaystyle\mathcal{J}\_{\alpha,c,m}(x)={}12∥x−c∥2−α⟨x−c,N_m(c)⟩,\displaystyle\frac{1}{2}\|x-c\|^{2}-\alpha\langle x-c,N\_{m}(c)\rangle,

where A(c,m)={x∈E:⟨x,m⟩=⟨c,m⟩}\mathcal{A}(c,m)=\{x\in E:\langle x,m\rangle=\langle c,m\rangle\} [33, 34, 35, 36, 37]. In the implementation, α=α_n≥0\alpha=\alpha\_{n}\geq 0; the theorem is stated for arbitrary α∈R\alpha\in\mathbb{R} because the characterization itself does not require a sign restriction.

Theorem A.8 (ONT solves the slow-memory write problem).
Section titled “Theorem A.8 (ONT solves the slow-memory write problem).”

Let EE be a real inner-product space. For every c,m∈Ec,m\in E and every α∈R\alpha\in\mathbb{R}, the ONT transport T_α(c,m)T\_{\alpha}(c,m) is the unique minimizer of

min⁡{J_α,c,m(x):x∈A(c,m)}.\min\{\mathcal{J}\_{\alpha,c,m}(x):x\in\mathcal{A}(c,m)\}.

Write N=N_m(c)N=N\_{m}(c) and T=T_α(c,m)=c+αNT=T\_{\alpha}(c,m)=c+\alpha N. By Proposition A.4, T∈A(c,m)T\in\mathcal{A}(c,m). Fix any feasible write x∈A(c,m)x\in\mathcal{A}(c,m). Then

J_α,c,m(x)\displaystyle\mathcal{J}\_{\alpha,c,m}(x)=12∥x−c∥2−α⟨x−c,N⟩\displaystyle=\frac{1}{2}\|x-c\|^{2}-\alpha\langle x-c,N\rangle
------------
=12∥(x−c)−αN∥2−12α2∥N∥2.\displaystyle=\frac{1}{2}\|(x-c)-\alpha N\|^{2}-\frac{1}{2}\alpha^{2}\|N\|^{2}.

Since (x−c)−αN=x−(c+αN)=x−T(x-c)-\alpha N=x-(c+\alpha N)=x-T, we obtain

J_α,c,m(x)=12∥x−T∥2−12α2∥N∥2.\mathcal{J}\_{\alpha,c,m}(x)=\frac{1}{2}\|x-T\|^{2}-\frac{1}{2}\alpha^{2}\|N\|^{2}.

Evaluating the same identity at x=Tx=T gives

J_α,c,m(T)=−12α2∥N∥2.\mathcal{J}\_{\alpha,c,m}(T)=-\frac{1}{2}\alpha^{2}\|N\|^{2}.

Therefore, for every feasible xx,

J_α,c,m(x)−J_α,c,m(T)=12∥x−T∥2≥0.\mathcal{J}\_{\alpha,c,m}(x)-\mathcal{J}\_{\alpha,c,m}(T)=\frac{1}{2}\|x-T\|^{2}\geq 0.

Hence TT minimizes J_α,c,m\mathcal{J}\_{\alpha,c,m} over A(c,m)\mathcal{A}(c,m). If xx is any other minimizer, then the display above implies ∥x−T∥2=0\|x-T\|^{2}=0, and therefore x=Tx=T. Thus the minimizer is unique. ∎

Listing 1: Module aggregator.

⬇

import LPCSMFormal.ONT

import LPCSMFormal.ONTOptimality

Listing 2: Core ONT geometry.

⬇

import Mathlib.Analysis.InnerProductSpace.Basic

import Mathlib.Tactic

noncomputable section

namespace LPCSMFormal

variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace Real E]

def rinner (x y : E) : Real :=

inner Real x y

def ontProj (chunkSummary slowMemory : E) : E :=

if _h : norm slowMemory = 0 then

0

else

SMul.smul ((rinner chunkSummary slowMemory) / (norm slowMemory ^ 2)) slowMemory

def ontNovelty (chunkSummary slowMemory : E) : E :=

chunkSummary - ontProj chunkSummary slowMemory

def ontTransport (alpha : Real) (chunkSummary slowMemory : E) : E :=

chunkSummary + SMul.smul alpha (ontNovelty chunkSummary slowMemory)

theorem ontProj_zero_right (chunkSummary : E) :

ontProj chunkSummary 0 = 0 := by

simp [ontProj]

theorem ontDecomposition (chunkSummary slowMemory : E) :

ontProj chunkSummary slowMemory + ontNovelty chunkSummary slowMemory = chunkSummary := by

simp [ontNovelty]

theorem ontNovelty_inner_slowMemory (chunkSummary slowMemory : E) :

inner Real (ontNovelty chunkSummary slowMemory) slowMemory = 0 := by

by_cases h : norm slowMemory = 0

case pos =>

have hs : slowMemory = 0 := by

exact norm_eq_zero.mp h

simp [ontNovelty, ontProj, hs]

case neg =>

have hpos : 0 < norm slowMemory := by

exact lt_of_le_of_ne (norm_nonneg slowMemory) (Ne.symm h)

have hnorm : Ne (norm slowMemory ^ 2) 0 := by

positivity

rw [ontNovelty, inner_sub_left]

simp [ontProj, h]

have hinner :

inner Real (SMul.smul (rinner chunkSummary slowMemory / (norm slowMemory ^ 2)) slowMemory) slowMemory =

(rinner chunkSummary slowMemory / (norm slowMemory ^ 2)) * inner Real slowMemory slowMemory := by

simpa using

(real_inner_smul_left

slowMemory

slowMemory

(rinner chunkSummary slowMemory / (norm slowMemory ^ 2)))

rw [hinner, real_inner_self_eq_norm_sq]

field_simp [hnorm]

simp [rinner]

theorem ontTransport_eq_proj_plus_scaled_novelty (alpha : Real) (chunkSummary slowMemory : E) :

ontTransport alpha chunkSummary slowMemory =

ontProj chunkSummary slowMemory +

SMul.smul (1 + alpha) (ontNovelty chunkSummary slowMemory) := by

calc

ontTransport alpha chunkSummary slowMemory

= chunkSummary + SMul.smul alpha (ontNovelty chunkSummary slowMemory) := by

rfl

_ = ontProj chunkSummary slowMemory

  • ontNovelty chunkSummary slowMemory

  • SMul.smul alpha (ontNovelty chunkSummary slowMemory) := by

rw [ontDecomposition]

_ = ontProj chunkSummary slowMemory

  • (ontNovelty chunkSummary slowMemory

  • SMul.smul alpha (ontNovelty chunkSummary slowMemory)) := by

simp [add_assoc]

_ = ontProj chunkSummary slowMemory

  • SMul.smul (1 + alpha) (ontNovelty chunkSummary slowMemory) := by

have hsmul :

ontNovelty chunkSummary slowMemory

  • SMul.smul alpha (ontNovelty chunkSummary slowMemory) =

SMul.smul (1 + alpha) (ontNovelty chunkSummary slowMemory) := by

simpa [one_smul] using (add_smul 1 alpha (ontNovelty chunkSummary slowMemory)).symm

rw [hsmul]

theorem ontTransport_inner_slowMemory (alpha : Real) (chunkSummary slowMemory : E) :

rinner (ontTransport alpha chunkSummary slowMemory) slowMemory =

rinner chunkSummary slowMemory := by

rw [ontTransport, rinner, inner_add_left]

have hsmul :

inner Real (SMul.smul alpha (ontNovelty chunkSummary slowMemory)) slowMemory =

alpha * inner Real (ontNovelty chunkSummary slowMemory) slowMemory := by

simpa using real_inner_smul_left (ontNovelty chunkSummary slowMemory) slowMemory alpha

rw [hsmul, ontNovelty_inner_slowMemory]

simp [rinner]

end LPCSMFormal

Listing 3: Optimality, uniqueness, and variational characterization.

⬇

import LPCSMFormal.ONT

import Mathlib.Analysis.InnerProductSpace.Basic

import Mathlib.Tactic

noncomputable section

namespace LPCSMFormal

variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace Real E]

— Derived analytical objects used to characterize the code-defined transport.

— The implementation primitive remains ‘ontTransport‘ from ‘ONT.lean‘.

def ontTarget (alpha : Real) (chunkSummary : E) : E :=

SMul.smul (1 + alpha) chunkSummary

def ontWriteObjective (alpha : Real) (chunkSummary slowMemory x : E) : Real :=

(1 / 2 : Real) * (norm (x - chunkSummary) ^ 2)

  • alpha * inner Real (x - chunkSummary) (ontNovelty chunkSummary slowMemory)

theorem ontTarget_eq_transport_add_scaled_proj (alpha : Real) (chunkSummary slowMemory : E) :

ontTarget alpha chunkSummary =

ontTransport alpha chunkSummary slowMemory + SMul.smul alpha (ontProj chunkSummary slowMemory) := by

unfold ontTarget

conv_lhs =>

rw [<- ontDecomposition chunkSummary slowMemory]

have hsmuladd :

SMul.smul (1 + alpha) (ontProj chunkSummary slowMemory + ontNovelty chunkSummary slowMemory) =

SMul.smul (1 + alpha) (ontProj chunkSummary slowMemory)

  • SMul.smul (1 + alpha) (ontNovelty chunkSummary slowMemory) := by

exact

smul_add

(1 + alpha)

(ontProj chunkSummary slowMemory)

(ontNovelty chunkSummary slowMemory)

rw [hsmuladd]

rw [show SMul.smul (1 + alpha) (ontProj chunkSummary slowMemory) =

ontProj chunkSummary slowMemory + SMul.smul alpha (ontProj chunkSummary slowMemory) by

simpa [one_smul] using (add_smul 1 alpha (ontProj chunkSummary slowMemory))]

rw [ontTransport_eq_proj_plus_scaled_novelty]

simp [add_assoc, add_left_comm, add_comm]

theorem ontTransport_sub_target_eq_neg_scaled_proj (alpha : Real) (chunkSummary slowMemory : E) :

ontTransport alpha chunkSummary slowMemory - ontTarget alpha chunkSummary =

SMul.smul (-alpha) (ontProj chunkSummary slowMemory) := by

calc

ontTransport alpha chunkSummary slowMemory - ontTarget alpha chunkSummary

= ontTransport alpha chunkSummary slowMemory

  • (ontTransport alpha chunkSummary slowMemory + SMul.smul alpha (ontProj chunkSummary slowMemory)) := by

rw [ontTarget_eq_transport_add_scaled_proj alpha chunkSummary slowMemory]

_ = -SMul.smul alpha (ontProj chunkSummary slowMemory) := by

abel_nf

_ = SMul.smul (-alpha) (ontProj chunkSummary slowMemory) := by

exact (neg_smul alpha (ontProj chunkSummary slowMemory)).symm

theorem feasible_inner_slow_eq_zero

(alpha : Real)

(chunkSummary slowMemory x : E)

(hfeas : rinner x slowMemory = rinner chunkSummary slowMemory) :

inner Real (x - ontTransport alpha chunkSummary slowMemory) slowMemory = 0 := by

have htransport :

inner Real (ontTransport alpha chunkSummary slowMemory) slowMemory =

inner Real chunkSummary slowMemory := by

simpa [rinner] using (ontTransport_inner_slowMemory alpha chunkSummary slowMemory)

rw [rinner] at hfeas

rw [inner_sub_left]

rw [hfeas, htransport]

simp [rinner]

theorem feasible_inner_proj_eq_zero

(alpha : Real)

(chunkSummary slowMemory x : E)

(hfeas : rinner x slowMemory = rinner chunkSummary slowMemory) :

inner Real (x - ontTransport alpha chunkSummary slowMemory) (ontProj chunkSummary slowMemory) = 0 := by

by_cases h : norm slowMemory = 0

case pos =>

have hs : slowMemory = 0 := by

exact norm_eq_zero.mp h

simp [ontProj, hs]

case neg =>

have hproj :

ontProj chunkSummary slowMemory =

SMul.smul ((rinner chunkSummary slowMemory) / (norm slowMemory ^ 2)) slowMemory := by

simp [ontProj, h]

have hinner :

inner Real (x - ontTransport alpha chunkSummary slowMemory)

(SMul.smul ((rinner chunkSummary slowMemory) / (norm slowMemory ^ 2)) slowMemory) =

((rinner chunkSummary slowMemory) / (norm slowMemory ^ 2))

* inner Real (x - ontTransport alpha chunkSummary slowMemory) slowMemory := by

simpa using

real_inner_smul_right

(x - ontTransport alpha chunkSummary slowMemory)

slowMemory

((rinner chunkSummary slowMemory) / (norm slowMemory ^ 2))

rw [hproj, hinner, feasible_inner_slow_eq_zero alpha chunkSummary slowMemory x hfeas]

simp

theorem feasible_inner_transport_target_eq_zero

(alpha : Real)

(chunkSummary slowMemory x : E)

(hfeas : rinner x slowMemory = rinner chunkSummary slowMemory) :

inner Real

(x - ontTransport alpha chunkSummary slowMemory)

(ontTransport alpha chunkSummary slowMemory - ontTarget alpha chunkSummary) = 0 := by

rw [ontTransport_sub_target_eq_neg_scaled_proj]

have hneg :

SMul.smul (-alpha) (ontProj chunkSummary slowMemory) =

-SMul.smul alpha (ontProj chunkSummary slowMemory) := by

exact neg_smul alpha (ontProj chunkSummary slowMemory)

rw [hneg, inner_neg_right]

have hinner :

inner Real

(x - ontTransport alpha chunkSummary slowMemory)

(SMul.smul alpha (ontProj chunkSummary slowMemory)) =

alpha * inner Real

(x - ontTransport alpha chunkSummary slowMemory)

(ontProj chunkSummary slowMemory) := by

simpa using

real_inner_smul_right

(x - ontTransport alpha chunkSummary slowMemory)

(ontProj chunkSummary slowMemory)

alpha

rw [hinner, feasible_inner_proj_eq_zero alpha chunkSummary slowMemory x hfeas]

simp

theorem ontTransport_objective_decomposition

(alpha : Real)

(chunkSummary slowMemory x : E)

(hfeas : rinner x slowMemory = rinner chunkSummary slowMemory) :

norm (x - ontTarget alpha chunkSummary) * norm (x - ontTarget alpha chunkSummary) =

norm (x - ontTransport alpha chunkSummary slowMemory) * norm (x - ontTransport alpha chunkSummary slowMemory)

  • norm (ontTransport alpha chunkSummary slowMemory - ontTarget alpha chunkSummary)

* norm (ontTransport alpha chunkSummary slowMemory - ontTarget alpha chunkSummary) := by

have hsplit :

x - ontTarget alpha chunkSummary =

(x - ontTransport alpha chunkSummary slowMemory)

  • (ontTransport alpha chunkSummary slowMemory - ontTarget alpha chunkSummary) := by

abel_nf

have horth :

inner Real

(x - ontTransport alpha chunkSummary slowMemory)

(ontTransport alpha chunkSummary slowMemory - ontTarget alpha chunkSummary) = 0 := by

exact feasible_inner_transport_target_eq_zero alpha chunkSummary slowMemory x hfeas

rw [hsplit]

exact

norm_add_sq_eq_norm_sq_add_norm_sq_of_inner_eq_zero

(x - ontTransport alpha chunkSummary slowMemory)

(ontTransport alpha chunkSummary slowMemory - ontTarget alpha chunkSummary)

horth

theorem ontTransport_minimal

(alpha : Real)

(chunkSummary slowMemory x : E)

(hfeas : rinner x slowMemory = rinner chunkSummary slowMemory) :

norm (ontTransport alpha chunkSummary slowMemory - ontTarget alpha chunkSummary) <=

norm (x - ontTarget alpha chunkSummary) := by

have hdecomp :=

ontTransport_objective_decomposition alpha chunkSummary slowMemory x hfeas

have hnonneg :

0 <= norm (x - ontTransport alpha chunkSummary slowMemory)

* norm (x - ontTransport alpha chunkSummary slowMemory) := by

positivity

have hsq :

norm (ontTransport alpha chunkSummary slowMemory - ontTarget alpha chunkSummary)

* norm (ontTransport alpha chunkSummary slowMemory - ontTarget alpha chunkSummary)

<= norm (x - ontTarget alpha chunkSummary) * norm (x - ontTarget alpha chunkSummary) := by

nlinarith [hdecomp]

have hleft : 0 <= norm (ontTransport alpha chunkSummary slowMemory - ontTarget alpha chunkSummary) := by

exact norm_nonneg _

have hright : 0 <= norm (x - ontTarget alpha chunkSummary) := by

exact norm_nonneg _

nlinarith

theorem ontTransport_unique_minimizer

(alpha : Real)

(chunkSummary slowMemory x : E)

(hfeas : rinner x slowMemory = rinner chunkSummary slowMemory)

(hmin :

forall y : E,

rinner y slowMemory = rinner chunkSummary slowMemory ->

norm (x - ontTarget alpha chunkSummary) <= norm (y - ontTarget alpha chunkSummary)) :

x = ontTransport alpha chunkSummary slowMemory := by

have hx_le :

norm (x - ontTarget alpha chunkSummary) <=

norm (ontTransport alpha chunkSummary slowMemory - ontTarget alpha chunkSummary) := by

apply hmin

exact ontTransport_inner_slowMemory alpha chunkSummary slowMemory

have hopt_le :

norm (ontTransport alpha chunkSummary slowMemory - ontTarget alpha chunkSummary) <=

norm (x - ontTarget alpha chunkSummary) := by

exact ontTransport_minimal alpha chunkSummary slowMemory x hfeas

have heq_obj :

norm (x - ontTarget alpha chunkSummary) =

norm (ontTransport alpha chunkSummary slowMemory - ontTarget alpha chunkSummary) := by

exact le_antisymm hx_le hopt_le

have hdecomp :=

ontTransport_objective_decomposition alpha chunkSummary slowMemory x hfeas

have hzero_sq :

norm (x - ontTransport alpha chunkSummary slowMemory)

* norm (x - ontTransport alpha chunkSummary slowMemory) = 0 := by

rw [heq_obj] at hdecomp

nlinarith [hdecomp]

have hzero_norm :

norm (x - ontTransport alpha chunkSummary slowMemory) = 0 := by

have hnonneg : 0 <= norm (x - ontTransport alpha chunkSummary slowMemory) := by

exact norm_nonneg _

nlinarith

exact sub_eq_zero.mp (norm_eq_zero.mp hzero_norm)

theorem ontWriteObjective_eq_square_completion

(alpha : Real)

(chunkSummary slowMemory x : E) :

ontWriteObjective alpha chunkSummary slowMemory x =

(1 / 2 : Real) * (norm (x - ontTransport alpha chunkSummary slowMemory) ^ 2)

  • (1 / 2 : Real) * (alpha ^ 2) * (norm (ontNovelty chunkSummary slowMemory) ^ 2) := by

set u : E := x - chunkSummary

set n : E := ontNovelty chunkSummary slowMemory

have h_expand :

inner Real (u - SMul.smul alpha n) (u - SMul.smul alpha n) =

inner Real u u - 2 * alpha * inner Real u n + alpha ^ 2 * inner Real n n := by

have h1 :

inner Real (SMul.smul alpha n) u = alpha * inner Real n u := by

simpa using real_inner_smul_left n u alpha

have h2 :

inner Real u (SMul.smul alpha n) = alpha * inner Real u n := by

simpa using real_inner_smul_right u n alpha

have h3 :

inner Real (SMul.smul alpha n) (SMul.smul alpha n) = alpha ^ 2 * inner Real n n := by

have h3’ :

inner Real n (SMul.smul alpha n) = alpha * inner Real n n := by

simpa using real_inner_smul_right n n alpha

calc

inner Real (SMul.smul alpha n) (SMul.smul alpha n)

= alpha * inner Real n (SMul.smul alpha n) := by

exact real_inner_smul_left n (SMul.smul alpha n) alpha

_ = alpha * (alpha * inner Real n n) := by

rw [h3’]

_ = alpha ^ 2 * inner Real n n := by

ring

have h4 :

inner Real (SMul.smul alpha n) (u - SMul.smul alpha n) =

inner Real (SMul.smul alpha n) u - inner Real (SMul.smul alpha n) (SMul.smul alpha n) := by

rw [inner_sub_right]

rw [inner_sub_left, inner_sub_right]

rw [h2, h4, h1, h3]

have hcomm : inner Real n u = inner Real u n := by

simpa using (real_inner_comm n u).symm

rw [hcomm]

ring

have h_rearr :

(1 / 2 : Real) * inner Real u u - alpha * inner Real u n =

(1 / 2 : Real) * inner Real (u - SMul.smul alpha n) (u - SMul.smul alpha n)

  • (1 / 2 : Real) * (alpha ^ 2) * inner Real n n := by

nlinarith [h_expand]

have hu :

u - SMul.smul alpha n = x - ontTransport alpha chunkSummary slowMemory := by

simp [u, n, ontTransport]

abel_nf

calc

ontWriteObjective alpha chunkSummary slowMemory x

= (1 / 2 : Real) * inner Real u u - alpha * inner Real u n := by

unfold ontWriteObjective

rw [show inner Real (x - chunkSummary) (ontNovelty chunkSummary slowMemory) = inner Real u n by rfl]

rw [show inner Real u u = norm u ^ 2 by simp]

_ = (1 / 2 : Real) * inner Real (u - SMul.smul alpha n) (u - SMul.smul alpha n)

  • (1 / 2 : Real) * (alpha ^ 2) * inner Real n n := by

exact h_rearr

_ = (1 / 2 : Real) * (norm (u - SMul.smul alpha n) ^ 2)

  • (1 / 2 : Real) * (alpha ^ 2) * (norm n ^ 2) := by

rw [show inner Real (u - SMul.smul alpha n) (u - SMul.smul alpha n) =

norm (u - SMul.smul alpha n) ^ 2 by

simp]

rw [show inner Real n n = norm n ^ 2 by simp]

_ = (1 / 2 : Real) * (norm (x - ontTransport alpha chunkSummary slowMemory) ^ 2)

  • (1 / 2 : Real) * (alpha ^ 2) * (norm (ontNovelty chunkSummary slowMemory) ^ 2) := by

rw [hu]

theorem ontWriteObjective_minimal

(alpha : Real)

(chunkSummary slowMemory x : E) :

ontWriteObjective alpha chunkSummary slowMemory (ontTransport alpha chunkSummary slowMemory) <=

ontWriteObjective alpha chunkSummary slowMemory x := by

rw [ontWriteObjective_eq_square_completion, ontWriteObjective_eq_square_completion]

have hopt_zero :

norm

(ontTransport alpha chunkSummary slowMemory - ontTransport alpha chunkSummary slowMemory) ^ 2 = 0 := by

simp

have hnonneg : 0 <= (1 / 2 : Real) * (norm (x - ontTransport alpha chunkSummary slowMemory) ^ 2) := by

positivity

nlinarith [hopt_zero]

theorem ontWriteObjective_unique_minimizer

(alpha : Real)

(chunkSummary slowMemory x : E)

(hmin :

forall y : E,

ontWriteObjective alpha chunkSummary slowMemory x <=

ontWriteObjective alpha chunkSummary slowMemory y) :

x = ontTransport alpha chunkSummary slowMemory := by

have hx_le :

ontWriteObjective alpha chunkSummary slowMemory x <=

ontWriteObjective alpha chunkSummary slowMemory (ontTransport alpha chunkSummary slowMemory) := by

exact hmin (ontTransport alpha chunkSummary slowMemory)

have hopt_le :

ontWriteObjective alpha chunkSummary slowMemory (ontTransport alpha chunkSummary slowMemory) <=

ontWriteObjective alpha chunkSummary slowMemory x := by

exact ontWriteObjective_minimal alpha chunkSummary slowMemory x

have heq_obj :

ontWriteObjective alpha chunkSummary slowMemory x =

ontWriteObjective alpha chunkSummary slowMemory (ontTransport alpha chunkSummary slowMemory) := by

exact le_antisymm hx_le hopt_le

have hzero_sq :

norm (x - ontTransport alpha chunkSummary slowMemory) ^ 2 = 0 := by

have heq_obj’ := heq_obj

rw [ontWriteObjective_eq_square_completion, ontWriteObjective_eq_square_completion] at heq_obj’

have hopt_zero :

norm

(ontTransport alpha chunkSummary slowMemory - ontTransport alpha chunkSummary slowMemory) ^ 2 = 0 := by

simp

nlinarith [heq_obj’, hopt_zero]

have hzero_norm : norm (x - ontTransport alpha chunkSummary slowMemory) = 0 := by

have hnonneg : 0 <= norm (x - ontTransport alpha chunkSummary slowMemory) := by

exact norm_nonneg _

nlinarith

exact sub_eq_zero.mp (norm_eq_zero.mp hzero_norm)

theorem ontWriteObjective_minimal_feasible

(alpha : Real)

(chunkSummary slowMemory x : E)

(_hfeas : rinner x slowMemory = rinner chunkSummary slowMemory) :

ontWriteObjective alpha chunkSummary slowMemory (ontTransport alpha chunkSummary slowMemory) <=

ontWriteObjective alpha chunkSummary slowMemory x := by

exact ontWriteObjective_minimal alpha chunkSummary slowMemory x

theorem ontWriteObjective_unique_minimizer_feasible

(alpha : Real)

(chunkSummary slowMemory x : E)

(hfeas : rinner x slowMemory = rinner chunkSummary slowMemory)

(hmin :

forall y : E,

rinner y slowMemory = rinner chunkSummary slowMemory ->

ontWriteObjective alpha chunkSummary slowMemory x <=

ontWriteObjective alpha chunkSummary slowMemory y) :

x = ontTransport alpha chunkSummary slowMemory := by

have hx_le :

ontWriteObjective alpha chunkSummary slowMemory x <=

ontWriteObjective alpha chunkSummary slowMemory (ontTransport alpha chunkSummary slowMemory) := by

apply hmin

exact ontTransport_inner_slowMemory alpha chunkSummary slowMemory

have hopt_le :

ontWriteObjective alpha chunkSummary slowMemory (ontTransport alpha chunkSummary slowMemory) <=

ontWriteObjective alpha chunkSummary slowMemory x := by

exact ontWriteObjective_minimal_feasible alpha chunkSummary slowMemory x hfeas

have heq_obj :

ontWriteObjective alpha chunkSummary slowMemory x =

ontWriteObjective alpha chunkSummary slowMemory (ontTransport alpha chunkSummary slowMemory) := by

exact le_antisymm hx_le hopt_le

have hzero_sq :

norm (x - ontTransport alpha chunkSummary slowMemory) ^ 2 = 0 := by

have heq_obj’ := heq_obj

rw [ontWriteObjective_eq_square_completion, ontWriteObjective_eq_square_completion] at heq_obj’

have hopt_zero :

norm

(ontTransport alpha chunkSummary slowMemory - ontTransport alpha chunkSummary slowMemory) ^ 2 = 0 := by

simp

nlinarith [heq_obj’, hopt_zero]

have hzero_norm : norm (x - ontTransport alpha chunkSummary slowMemory) = 0 := by

have hnonneg : 0 <= norm (x - ontTransport alpha chunkSummary slowMemory) := by

exact norm_nonneg _

nlinarith

exact sub_eq_zero.mp (norm_eq_zero.mp hzero_norm)

section Hilbert

variable {H : Type*} [NormedAddCommGroup H] [InnerProductSpace Real H] [CompleteSpace H]

theorem ontTransport_minimal_hilbert

(alpha : Real)

(chunkSummary slowMemory x : H)

(hfeas : rinner x slowMemory = rinner chunkSummary slowMemory) :

norm (ontTransport alpha chunkSummary slowMemory - ontTarget alpha chunkSummary) <=

norm (x - ontTarget alpha chunkSummary) := by

let _ := (inferInstance : CompleteSpace H)

exact ontTransport_minimal alpha chunkSummary slowMemory x hfeas

theorem ontTransport_unique_minimizer_hilbert

(alpha : Real)

(chunkSummary slowMemory x : H)

(hfeas : rinner x slowMemory = rinner chunkSummary slowMemory)

(hmin :

forall y : H,

rinner y slowMemory = rinner chunkSummary slowMemory ->

norm (x - ontTarget alpha chunkSummary) <= norm (y - ontTarget alpha chunkSummary)) :

x = ontTransport alpha chunkSummary slowMemory := by

let _ := (inferInstance : CompleteSpace H)

exact ontTransport_unique_minimizer alpha chunkSummary slowMemory x hfeas hmin

theorem ontWriteObjective_minimal_feasible_hilbert

(alpha : Real)

(chunkSummary slowMemory x : H)

(hfeas : rinner x slowMemory = rinner chunkSummary slowMemory) :

ontWriteObjective alpha chunkSummary slowMemory (ontTransport alpha chunkSummary slowMemory) <=

ontWriteObjective alpha chunkSummary slowMemory x := by

let _ := (inferInstance : CompleteSpace H)

exact ontWriteObjective_minimal_feasible alpha chunkSummary slowMemory x hfeas

theorem ontWriteObjective_unique_minimizer_feasible_hilbert

(alpha : Real)

(chunkSummary slowMemory x : H)

(hfeas : rinner x slowMemory = rinner chunkSummary slowMemory)

(hmin :

forall y : H,

rinner y slowMemory = rinner chunkSummary slowMemory ->

ontWriteObjective alpha chunkSummary slowMemory x <=

ontWriteObjective alpha chunkSummary slowMemory y) :

x = ontTransport alpha chunkSummary slowMemory := by

let _ := (inferInstance : CompleteSpace H)

exact ontWriteObjective_unique_minimizer_feasible alpha chunkSummary slowMemory x hfeas hmin

end Hilbert

end LPCSMFormal

  • [1]

    Albert Gu and Tri Dao. Transformers are SSMs: Generalized models and efficient algorithms through structured state space duality, 2024. URL https://arxiv.org/abs/2405.21060. arXiv:2405.21060.

  • [2]

    Soham De, Sam Smith, Anushan Fernando, Aleksandar Botev, George Tucker, Michal Valko, Razvan Pascanu, Sebastian Ruder, Yee Whye Teh, and Donald Metzler. Griffin: Mixing gated linear recurrences with local attention for efficient language models, 2024. URL https://arxiv.org/abs/2402.19427. arXiv:2402.19427.

  • [3]

    Ali Behrouz, Peilin Zhong, and Vahab Mirrokni. Titans: Learning to memorize at test time, 2025. URL https://arxiv.org/abs/2501.00663. arXiv:2501.00663.

  • [4]

    Xin Dong, Tianyu Liu, Yuhang Zang, Yanyan Zhao, Jiapeng Zhang, Zhaopeng Tu, Chengqiang Huang, Huadong Wang, and Jie Zhou. Hymba: A hybrid-head architecture for small language models, 2024. URL https://arxiv.org/abs/2411.13676. arXiv:2411.13676.

  • [5]

    Yiran Ding, Li Dong, Peiyuan Liu, Kaixiong Zhou, Ermo Hua, Song Lin, Zhuang Li, Yuejie Zhang, Yuhang Cao, Lei Shang, Xin Jiang, and Qun Liu. Longrope: Extending LLM context window beyond 2 million tokens, 2024. URL https://arxiv.org/abs/2402.13753. arXiv:2402.13753.

  • [6]

    Chaojun Xiao, Longyue Wang, Yingjia Wan, Yang Wang, Yuxuan Peng, Hao Zhu, Tianyu Liu, Xingyao Wang, Yusen Zhang, Chaojie Zhang, Zhiyuan Liu, and Maosong Sun. InfLLM: Training-free long-context extrapolation for LLMs with an efficient context memory, 2024. URL https://arxiv.org/abs/2402.04617. arXiv:2402.04617.

  • [7]

    Yu Zhang, Yifan Chen, Yichen Gong, Zhenyu Yang, Xuanjing Huang, and Kimi Team. Kimi linear: An expressive, efficient attention architecture, 2025. URL https://arxiv.org/abs/2510.26692. arXiv:2510.26692.

  • [8]

    Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need, 2017. URL https://arxiv.org/abs/1706.03762. arXiv:1706.03762.

  • [9]

    Rewon Child, Scott Gray, Alec Radford, and Ilya Sutskever. Generating long sequences with sparse transformers, 2019. URL https://arxiv.org/abs/1904.10509. arXiv:1904.10509.

  • [10]

    Sainbayar Sukhbaatar, Edouard Grave, Guillaume Lample, Herve Jegou, and Armand Joulin. Adaptive attention span in transformers, 2019. URL https://arxiv.org/abs/1905.07799. arXiv:1905.07799.

  • [11]

    Iz Beltagy, Matthew E. Peters, and Arman Cohan. Longformer: The long-document transformer, 2020. URL https://arxiv.org/abs/2004.05150. arXiv:2004.05150.

  • [12]

    Manzil Zaheer, Guru Guruganesh, Avinava Dubey, Joshua Ainslie, Chris Alberti, Santiago Ontanon, Philip Pham, Anirudh Ravula, Qifan Wang, Li Yang, and Amr Ahmed. Big bird: Transformers for longer sequences, 2020. URL https://arxiv.org/abs/2007.14062. arXiv:2007.14062.

  • [13]

    Zihang Dai, Zhilin Yang, Yiming Yang, Jaime Carbonell, Quoc V. Le, and Ruslan Salakhutdinov. Transformer-XL: Attentive language models beyond a fixed-length context, 2019. URL https://arxiv.org/abs/1901.02860. arXiv:1901.02860.

  • [14]

    Jack W. Rae, Anna Potapenko, Siddhant M. Jayakumar, Chloe Hillier, and Timothy P. Lillicrap. Compressive transformers for long-range sequence modelling, 2019. URL https://arxiv.org/abs/1911.05507. arXiv:1911.05507.

  • [15]

    Aydar Bulatov, Yuri Kuratov, and Mikhail S. Burtsev. Recurrent memory transformer. In Advances in Neural Information Processing Systems 35, 2022. doi: 10.52202/068431-0805. URL https://doi.org/10.52202/068431-0805.

  • [16]

    Yutao Sun et al. Retentive network: A successor to transformer for large language models, 2023. URL https://arxiv.org/abs/2307.08621. arXiv:2307.08621.

  • [17]

    Bo Peng et al. RWKV: Reinventing RNNs for the transformer era. In Findings of the Association for Computational Linguistics: EMNLP 2023, 2023. doi: 10.18653/v1/2023.findings-emnlp.936. URL https://doi.org/10.18653/v1/2023.findings-emnlp.936.

  • [18]

    Albert Gu and Tri Dao. Mamba: Linear-time sequence modeling with selective state spaces, 2023. URL https://arxiv.org/abs/2312.00752. arXiv:2312.00752.

  • [19]

    Rajesh P. N. Rao and Dana H. Ballard. Predictive coding in the visual cortex: a functional interpretation of some extra-classical receptive-field effects. Nature Neuroscience, 2(1):79–87, 1999. doi: 10.1038/4580. URL https://doi.org/10.1038/4580.

  • [20]

    Karl Friston. A theory of cortical responses. Philosophical Transactions of the Royal Society B: Biological Sciences, 360(1456):815–836, 2005. doi: 10.1098/rstb.2005.1622. URL https://doi.org/10.1098/rstb.2005.1622.

  • [21]

    William Lotter, Gabriel Kreiman, and David Cox. Deep predictive coding networks for video prediction and unsupervised learning, 2016. URL https://arxiv.org/abs/1605.08104. arXiv:1605.08104.

  • [22]

    Tim Whittington and Rafal Bogacz. Predictive coding approximates backprop along arbitrary computation graphs, 2020. URL https://arxiv.org/abs/2006.04182. arXiv:2006.04182.

  • [23]

    Alex Graves. Adaptive computation time for recurrent neural networks, 2016. URL https://arxiv.org/abs/1603.08983. arXiv:1603.08983.

  • [24]

    Mostafa Dehghani, Stephan Gouws, Oriol Vinyals, Jakob Uszkoreit, and Łukasz Kaiser. Universal transformers, 2018. URL https://arxiv.org/abs/1807.03819. arXiv:1807.03819.

  • [25]

    Mher Elbayad, Jiatao Gu, Edouard Grave, and Michael Auli. Depth-adaptive transformer, 2019. URL https://arxiv.org/abs/1910.10073. arXiv:1910.10073.

  • [26]

    Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc V. Le, Geoffrey Hinton, and Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts layer, 2017. URL https://arxiv.org/abs/1701.06538. arXiv:1701.06538.

  • [27]

    William Fedus, Barret Zoph, and Noam Shazeer. Switch transformers: Scaling to trillion parameter models with simple and efficient sparsity, 2021. URL https://arxiv.org/abs/2101.03961. arXiv:2101.03961.

  • [28]

    Biao Zhang and Rico Sennrich. Root mean square layer normalization. In Advances in Neural Information Processing Systems 32 (NeurIPS), 2019. URL https://proceedings.neurips.cc/paper/2019/hash/1e8a19426224ca89e83cef47f1e7f53b-Abstract.html.

  • [29]

    Zhenda Xie, Yixuan Wei, Huanqi Cao, Chenggang Zhao, Chengqi Deng, Jiashi Li, Damai Dai, Huazuo Gao, Jiang Chang, Kuai Yu, Liang Zhao, Shangyan Zhou, Zhean Xu, Zhengyan Zhang, Wangding Zeng, Shengding Hu, Yuqing Wang, Jingyang Yuan, Lean Wang, and Wenfeng Liang. mHC: Manifold-constrained hyper-connections, 2025. URL https://arxiv.org/abs/2512.24880. arXiv:2512.24880.

  • [30]

    Jared Kaplan, Sam McCandlish, Tom Henighan, Tom B. Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu, and Dario Amodei. Scaling laws for neural language models, 2020. URL https://arxiv.org/abs/2001.08361. arXiv:2001.08361.

  • [31]

    Jordan Hoffmann, Sebastian Borgeaud, Arthur Mensch, Elena Buchatskaya, Trevor Cai, Eliza Rutherford, Diego de Las Casas, Lisa Anne Hendricks, Johannes Welbl, Aidan Clark, Tom Hennigan, Eric Noland, Katie Millican, George van den Driessche, Bogdan Damoc, Aurelia Guy, Simon Osindero, Karen Simonyan, Erich Elsen, Jack W. Rae, Oriol Vinyals, and Laurent Sifre. Training compute-optimal large language models, 2022. URL https://arxiv.org/abs/2203.15556. arXiv:2203.15556.

  • [32]

    Carl D. Meyer. Matrix Analysis and Applied Linear Algebra. SIAM, 2000. Chapter 5: Norms, Inner Products, and Orthogonality.

  • [33]

    Ward Cheney and Allen A. Goldstein. Proximity maps for convex sets. Proceedings of the American Mathematical Society, 10(3):448–450, 1959. doi: 10.1090/S0002-9939-1959-0105008-8. URL https://doi.org/10.1090/S0002-9939-1959-0105008-8.

  • [34]

    Heinz H. Bauschke and Jonathan M. Borwein. On projection algorithms for solving convex feasibility problems. SIAM Review, 38(3):367–426, 1996. doi: 10.1137/S0036144593251710. URL https://doi.org/10.1137/S0036144593251710.

  • [35]

    Frank Deutsch. The method of alternating orthogonal projections. In Approximation Theory, Spline Functions and Applications. Springer, 1992. doi: 10.1007/978-94-011-2634-2_5. URL https://doi.org/10.1007/978-94-011-2634-2_5.

  • [36]

    Heinz H. Bauschke, Hui Ouyang, and Xianfu Wang. Best approximation mappings in hilbert spaces. Mathematical Programming, 189(1):1–35, 2021. doi: 10.1007/S10107-021-01718-Y. URL https://doi.org/10.1007/S10107-021-01718-Y.

  • [37]

    Heinz H. Bauschke and Valentin R. Koch. Projection methods: Swiss army knives for solving feasibility and best approximation problems with halfspaces. In Approximation, Optimization, and Mathematical Economics. American Mathematical Society, 2015. doi: 10.1090/CONM/636/12726. URL https://doi.org/10.1090/CONM/636/12726.