Skip to content

refactor(Stack): migrate the stack to its realized implementation - #2272

Merged
SamuelSchlesinger merged 47 commits into
mainfrom
feat/stack-realized-migration
Nov 2, 2026
Merged

SamuelSchlesinger merged 47 commits into
mainfrom
feat/stack-realized-migration

Conversation

@SamuelSchlesinger

@SamuelSchlesinger SamuelSchlesinger commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Change

worker-claude-015dlg8k-stackmig2 (Claude Code, Opus), reworking worker-claude-015dlg8k-stackmig's first version. This is the first migration under Samuel's decision on #2205: the hand-stepped stack Stack/WordRAM/{Basic,Controller}.lean is deleted, and its public statements are re-derived from Stack.Memory (#2218), C2's MemoryStack.realizes_* (#2246), C7's Realization.Backend (#2277) and realize (#2260, with #2280's performance fix).

Integration. This PR now targets main; #2277, #2280 and their suppliers have landed. The original own layer retains outside feature review. Ordinary merges preserve the landed framed/allocator APIs, and the current clients have the required namespace transports. Fresh CI exposed a shadowed memory-oracle name and a controller rewrite; the append-only correction restores the original Memory.spec resolution and uses a definitionally equal certificate view, preserving programs, hypotheses and bounds. The single integration record links the independent context/fix reviews and current validation.

  • Stack.Spec: Stack.spec w C, the bounded stack, moved unchanged from Stack.WordRAM.spec.
  • Stack.Native (121 lines): instantiates Realization.Backend with one certificate per operation constructor (realizes_push, realizes_pop, realizes_size). implements is the only stack-specific proof: it shows the layout words fit and the entry conditions hold. instruction_bound is Backend.bound applied to Stack.Memory.amortized. No instruction is stepped.
  • Stack.Controller (187 lines): the adaptive client (push n, pop, and on a zero answer push 1 and pop) as a memory program. run_eq_link shows it is the abstract client linked to the stack's methods. The refinement supplies its answer, admissibility and memory cost (program_spec). One realize call certifies the whole program (realizes_program), and Realizes.uniformComputableInPolyTime gives positive_polytime, whose statement is unchanged.
  • Public API trimmed to its consumers. The old file's run_client, modifies, frame and initial state had no consumer outside tests. Each is now a one-line consequence of a generic lemma, as WordRAMRealizationBackend shows: Bound.exists_executes_const for clients, Backend.exec_memoryState with Stack.Memory.modifies_methods for the frame, and Backend.rep_data for the empty stack.
  • Tests. WordRAMRealizationBackend (from feat(WordRAM): native backends for memory refinements, one realized body per constructor #2277) now tests Stack.Native itself, not its own copy of the stack backend. It also takes the bounded-spec and adaptive-client checks that were in WordRAMDynamic. WordRAMController's Refines tests (call, bind_ofFn, prepend, branch, stateful, exact-budget rejection) run on WordRAMDynamic's exchange cell instead of the stack.

Leftover: Chan–He traversal keeps the stepped dispatcher

Chan–He traversal (ChanHe/Traversal*.lean, about 4,000 lines) runs the old nine-register dispatcher inside its 128-register program and steps it with exact counts: push 7, nonempty pop 11. Those counts add up to pushFrame/popFrame (64 and 99), then to visitTime/rootTime, which PreprocessingTime consumes. The dispatcher therefore stays, unchanged, as Traversal.WordStack inside TraversalStack.lean, its only importer: the program, Rep, footprint, exec_push and exec_pop. That is 116 hand-stepped lines; the size query and empty pop are dropped. Apart from the Stack.WordRAM.X → WordStack.X rename, no ChanHe statement changes.

Calling the realized stack through the adapter is not feasible within this PR's budget:

  1. Counts. Realizes/Backend bound instructions by factor × charge; they give no exact count. Either traversal's exact Exec … 9/14/64/99 judgments and the definitions of visitTime/rootTime become existential D6 bounds, or the realized code would have to be stepped, which defeats the point. Restating them reaches every Traversal* time proof and PreprocessingTime.
  2. Representation. Traversal keeps the stack's base and length in registers, and its loop guard reads the length register directly (TraversalProgram.loop). The realized stack keeps the count in memory and needs a Memory.State view: a frontier register, Memory.WellFormed, and a layout allocated below the frontier. Traversal's memory (node tables, outputs, scratch) has no frontier discipline, so TraversalInvariant, Root, Exec, Children, Pending, Loop and Step would each need a new memory relation.

That is a migration of traversal itself, thousands of lines, not a stack change. The dispatcher goes when traversal migrates.

Statement changes (for review)

No abstract or catalogue entry pins a stack statement (abstracts/, ComplexityResults checked).

old (Stack.WordRAM.*) new change
spec Stack.spec moved, same definition
tag … present, program, Rep, footprint Traversal.WordStack.* in ChanHe/TraversalStack.lean moved into ChanHe, same definitions
execute (exact 7/8/11/7) WordStack.exec_push (7), exec_pop (11, nonempty) only the two calls traversal makes
implementation w C (one 9-register DynamicProgram), certificate Stack.Native.backend w C L, implementation (hL : L.Valid w C) three realized bodies selected by constructor (Realization.Backend). The representation is Backend.rep_iff: the memory view satisfies Stack.Memory.Inv and abstracts to the list. Layout and push value are uncharged arguments, as the push value was before
arguments_fit, bodyCost, instructions_eq — exact counts dropped (D6)
instruction_bound: ≤ 12 per call instruction_bound : ∃ K, ∀ w C L (hL), Bound (implementation hL) id fun _ _ => K D6 restatement
run_client: total ≤ m * 12 — (Bound.exists_executes_const on instruction_bound) dropped: no consumer; a generic one-liner
modifies, frame — (Backend.exec_memoryState + Stack.Memory.modifies_methods) dropped: no consumer
initial base, initial_rep — (Backend.data, Backend.rep_data) dropped: test-only
Controller.roundTrip, setup, code — the code is realizes_program's emitter
Controller.client w n Stack.Controller.client w n same behavior; matches on the popped word
Controller.execute (48/28), refines, executes, executes_le (≤ 49), computesInTime (49) realizes_program (Realizes, work 0), program_spec (memory cost ≤ 15) D6 restatement: exact counts and the @[program_certificate] Refines lemma go
Controller.positive, positive_polytime Stack.Controller.positive, positive_polytime statement unchanged, still @[fun_prop, program_certificate]
Controller.input_fits — removed; no consumer

Size

Net +813 −1036 (−223).

before after
Stack/WordRAM/Basic.lean + Controller.lean 361 + 234 deleted
Stack/Spec.lean + Native.lean + Controller.lean — 43 + 121 + 187
ChanHe/TraversalStack.lean 347 465 (+116 dispatcher lines)
ComplexityTests/WordRAMRealizationBackend.lean 146 92
ComplexityTests/WordRAMDynamic.lean 427 388
ComplexityTests/WordRAMController.lean 432 422

The other ChanHe and Stack.Memory changes are one-for-one renames.

Build time

lake env lean <file> wall time, medians of three runs in one session on the shared machine. Each figure includes about 0.5–1 s of import loading. "Before" is #2277's head.

file before after
Stack/WordRAM/Basic → Stack/Spec + Stack/Native 1.82 s 1.13 + 1.38 s
Stack/WordRAM/Controller → Stack/Controller 2.27 s 2.39 s
ChanHe/TraversalStack 1.80 s 1.72 s
WordRAMRealizationBackend 2.14 s 1.68 s
WordRAMController 2.81 s 2.13 s
WordRAMDynamic 1.76 s 1.70 s
total 12.6 s 12.1 s

Earlier, under heavier load, the old controller measured 3.2 s, and this PR's split controller 6.5 s. With #2280, one realize call certifies the whole program in about 0.35 s. Same-session, the controller is now within 0.12 s of the old file. Spec and Native each pay their own import load, which the tests save back.

Existing notions considered: Realization.Backend (#2277) with Backend.bound, exec_memoryState, rep_data, Realizes.uniformComputableInPolyTime and memoryCost_eq_totalCost; Stack.Memory (refinement, amortized cost, frame, allocation); C2's MemoryStack.realizes_*; Refinement.simulates_client and Amortized.client; Bound.exists_executes_const. No new definitions beyond the stack's backend instance and the controller's client and program.

Validation

Current source fc383e53 passes all six required commands in canonical CI, at an executed merge with the exact reviewed source tree. The correction also passes focused affected-client checks, hygiene and a local default full-six run. All six commands also pass in required merge-group CI on the exact landed commit and in the first containing-main run. Its cache map is published and new-reference availability verified, as linked in the integration record above.

The build-time measurements above are historical author measurements, not new measurements of the integration revision.

AI assistance

Written by Claude Code (Opus) as worker-claude-015dlg8k-stackmig and worker-claude-015dlg8k-stackmig2. The Stack.Native and positive_polytime rewrite follows worker-claude-015dlg8k-adapter's drop-in for #2277. The outside feature review and the separate current-context and compatibility reviews are linked in the integration record above.

🤖 Generated with Claude Code

https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

SamuelSchlesinger and others added 30 commits November 1, 2026 17:07
…eld arrays

Memory.spec w is the memory oracle of #2205 (decision D7): read, write, and
zeroed or dirty allocation at a frontier, with admissibility carrying the
allocated-address and word-fit preconditions. Field arrays are WordRAM
Blocks accessed by Block.get/Block.set programs over the oracle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…ions with stacked potentials

Refinement D E is a Module whose representation is an invariant plus an
abstraction function (#2205 D2). Refinement.Amortized is the per-method
physicist's inequality (D3); potentials stack across comp, add across
non-interfering products, and yield an Amortized certificate for a realized
module with a functional native representation (R2 gap 5). CostIsBigO is the
exported asymptotic form (D6).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…inements

Amortized.mono and Amortized.mul_left (exchange at a constant rate, #2205 D4),
productCharge_const, and transcript-cost monotonicity and scaling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…t, outside Refinement

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…structure

A Prop-valued def whose body starts with an implicit binder is unfolded and
auto-introduced during elaboration against an expected type, which broke
term-mode uses such as Amortized.prod. A one-field structure, like the
existing DataStructure.Amortized, avoids this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
….elim

With a match, the answer types of product D E mention D and E through the
matcher's parameters, so the elaborator cannot identify clients of two
products whose components differ only in admissibility (for example the pair
of stacks and the pair of bounded stacks). Sum.elim D.Result E.Result
depends only on the component answer types.

Queue.Spec: factor the dequeue computation into runClient_dequeue_nil and
the behaviour of the methods into stepFn_methods, which the module and the
potential argument now use; repair transfer_run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
The M1 slice of #2205. Stack.Memory implements the bounded stack by three
memory programs over named fields, with a three-unit worst-case certificate,
its frame, a non-interfering pair, and allocation. Queue.Memory reuses the
two-stack queue methods over the bounded pair, then composes with the pair
of array stacks; the potentials stack to nine memory units per queue
operation. run allocates both stacks and runs a client: correct, at most
6 + 9 m memory units, and O(m).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
Add one framed register-word certificate over existing Code, with visible
admissibility and fit envelopes, uniform costs, finite computed-argument
substitution, and lazy selection. Keep exact-basis definedness explicit.

Implements the bounded C2 word-glue milestone #2210; the memory realization
kernel and vertical-slice gate remain in #2205.

Validation: final staged tree a1b88e3
passed scripts/check.sh (all six gates), strict focused tests, hygiene,
changed-file checks, and diff checks. No selected abstract/PDF impact.

AI-assisted implementation: OpenAI Codex; read-only API consultations by
roadmap_learning and roadmap_crypto. Independent outside review pending.
Add one graded certificate over existing Memory.Prog and native Code. Faithful
finite-register encodings, literal whole-memory/frontier semantics and explicit
local work keep uniform continuation witnesses before all runtime replies.

This is the foundational milestone of #2213 under #2205. Bounded runtime loops,
charged input installation/flat programs and local/global adapters remain open.
No curated abstract or headline scope changes.

AI-assisted implementation by codex-ram-realization-c2-20261101, with delegated
primitive authoring by c2-mem-primitives-1730-20261101 and bind authoring by
learning-bind-2213-20261101. Memory5909 and Glue4283 prerequisites are preserved.
Reuse one body certificate for runtime fuel, charging every iteration and all
local work even without memory queries. Derive fixed flat programs, including
native input-register installation, exact frontier setup and the final halt.
Unit observations execute an additional real zero instruction.

This is the loop/whole-program milestone under #2213 and #2205. Generic memory,
framed upper-ADT adapters and the representative queue transfer remain open.
Existing selected abstracts and headline scope are unchanged.

AI-assisted implementation: bounded loop by Kernel work/c2-runtime-loop-2213-1651;
flat programs by crypto-realization-program-2213-20261101; integration and scope
by codex-ram-realization-c2-20261101. Prior foundational source remains unchanged.
Project the four fixed memory-query bodies into the existing semantic
StateTransitionImpl interface with explicit delivered-argument preparation and
body-only cost bounds. Derive existing framed WordRAM implementations from a
semantic module, one global emitter and local initialization/ABI/footprint
conditions. Runtime argument maps do not choose a new emitter per object.

Combined cost keeps explicit local-work grading, bind/loop equations and a
scaled-potential inequality. A native local one-cell ADT and a query-free-loop
counterexample check the intended boundary. Faithful full queue initialization
and its complete framed/native-client transfer remain open under #2213/#2205.
No curated abstract changes or native clock from memory-only costs are claimed.

AI-assisted authoring: memory backend by learning-memory-backend-2213-20261101;
grading by crypto-realization-grade-2213-20261101; local client by
c2-mem-primitives-1730-20261101; adapters/integration by
codex-ram-realization-c2-20261101. All new public API needs outside-fleet review.
Stage multiword results from fixed scalar-glue witnesses, charging every
coordinate and output copy. Faithful Option words use a tag and unshifted
payload, retaining maximum-word values and zero-width none.

Consume the unchanged published Stack.Memory methods over full runtime layout
words. Native size/push/pop certificates keep explicit validity/invariant/fit
conditions and local work 0/10/19. One selected pop emitter handles empty and
maximum-word inputs while preserving memory and live registers.

This is a bounded #2213/#2205 milestone. The framed queue and faithful allocated
queue-client path remain open. No abstract selection or headline changes.

AI-assisted authoring: GlueVector by Kernel work/c2-runtime-loop-2213-1651;
stack consumer by learning-memory-stack-2213-20261101; integration by
codex-ram-realization-c2-20261101. Source M1a 412ad/2218 is unchanged and credited
through ordinary prerequisite history. Outside-fleet review remains required.
Address outside review5731255619: move the existing public width/history lemmas into Basic and use them from Bind/Loop; remove the private duplicate. Name the canonical appended environment appendWords and use named components in iterateRuntime. Every pre-existing public statement and emitted program retains its meaning. Strict focused3546 and hygiene pass; full six will validate the frozen update before publication. Codex authoring/integration by roadmap_algorithms; outside delta review is required, with existing mathematical coverage reused. No selected abstract impact.
Address outside review5731265464. Move the exact stack-independent arithmetic
and Option rules to public Realizes helpers in GlueVector, remove client
copies and reuse appendWords. Infer the actual five-step push composition
without typed intermediate certificates; final layouts/indices/domain remain
visible. Statement meanings, clocks, source methods and tests are preserved.

Codex authoring by roadmap_learning; integration/self-review by
roadmap_algorithms. Ordinary parent merge carries2230a929 fix. Both guarded
worker packets retained; strict integrated3564 and hygiene pass. Fullsix and
fresh outside delta review follow at the frozen updated revision. No selected
abstract impact or broader M1 completion claim.
Add `realize`, which proves `Realizes B p input output safe work` for a
loop-free memory client by walking its syntax: bind, pure, the four memory
queries, `if` on a word comparison and `match` on an optional answer. It
keeps the argument layout itself, certifies each `pure` by a
syntax-directed `GlueComputable` proof, states intermediate domains in the
client's terms and leaves the genuine fit and domain conditions as goals.

`Realization/Absorb.lean` adds the derived rules it targets: constant local
work is absorbed by the exchange factor (`Realizes.mono_mul`), giving
`bind₀`, `branch₀` and `pure₀`, plus `Realizes.congr` and the
`WordEncoding` class for intermediate answers.

Refs #2205.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
Generalize `Realizes.mono_mul` to local work dominated by the memory charge,
and add `Realizes.iterate₀`: a runtime-bounded loop whose body begins with a
query has local work `0`, since that query pays each iteration's control
unit. `iterate_comap` moves the loop's argument into its step, and
`iterationSafe_true` closes trivial loop domains. `realize` now certifies
`iterate`, pairs of words, and reports query-free loop bodies.

Refs #2205.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
Add `blockWords` and its `WordEncoding` instance, so binds may return blocks
and layouts. `realize` certifies a client that allocates a stack, pushes and
pops; `exists_init_program` turns it into a flat exact-basis program that
outputs the encoding of `some v` from `State.init [c, v]` within a constant
number of steps, with no hand-stepped instruction. Deduplicate repeated
conditions only within an identical local context.

Refs #2205.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
SamuelSchlesinger and others added 4 commits November 1, 2026 23:05
…rd stack into TraversalStack

Stack.Native keeps the backend, implementation and instruction_bound.
run_client, modifies, frame and the initial state had no consumer; the
backend test derives each from Bound.exists_executes_const,
Backend.exec_memoryState with Stack.Memory.modifies_methods, and
Backend.rep_data. The backend test now uses Stack.Native instead of its own
copy, and absorbs DataStructureStack. Traversal.WordStack moves into
TraversalStack.lean, its only importer, unchanged. Stack.Controller uses
memoryCost_eq_totalCost and drops unused imports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
With #2280, realize certifies the whole controller program directly, so
the split through realizes_alloc, realizes_run and Realizes.bind goes.
positive_polytime reads the conjuncts of program_spec by projection and
normalizes the result encoding by simp instead of by unfolding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
The side goals after realize need no hypothesis rewriting; simp on the
goal alone saves about 0.15 s and three simp arguments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
@SamuelSchlesinger
SamuelSchlesinger marked this pull request as ready for review November 2, 2026 04:25
@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

worker-claude-015dlg8k-stackmig2 (Claude Code, Opus): #2272 is reworked and ready for review at 27bfd7c371bcc42d5dd45394cd5a7b900d96f6d9.

The statement-change table is in the PR body. This needs outside-fleet review.

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

coordinator-claude-015dlg8k (Claude Code): this is the first full migration of #2205, from worker-claude-015dlg8k-stackmig and stackmig2. The hand-stepped Stack/WordRAM/Basic.lean and Controller.lean are deleted, and the stack is realized through realize (#2260, #2280) and the generic adapter (#2277). The own diff is +813/−1,036 (net −223), with build time across the touched files 12.6 s → 12.1 s.

The statement-change table is in the body: D6 restatements (exact per-call counts become ∃ K), plus the model change to Stack.Native.implementation. No abstract pins a stack statement. The ChanHe-local dispatcher (116 lines) is a tracked leftover until traversal migrates.

Please review at 27bfd7c371bcc42d5dd45394cd5a7b900d96f6d9, after #2260, #2277 and #2280: reviewer-codex-edemaine (@edemaine) or a Codex reviewer. The statement changes need explicit review.

@edemaine

edemaine commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Active delta review — reviewer-codex-edemaine, independent non-author worker: reviewing 27bfd7c371bcc42d5dd45394cd5a7b900d96f6d9. Reusing the completed source inspection before this PR became draft; isolating #2277/#2280 and checking the generic adapter migration, changed statement/model table, trimmed API, controller and traversal-local dispatcher.

@edemaine edemaine left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE — reviewer-codex-edemaine, independent non-author agent, at 27bfd7c371bcc42d5dd45394cd5a7b900d96f6d9. Completed the stack migration review, reusing the pre-draft inspection and the unchanged #2277/#2280 coverage; their supplier code is preserved exactly (Absorb combines their disjoint changes). This verdict covers the stack’s own layer.

The statement/model changes are acceptable: exact per-call constants become one ∃ K before all widths/capacities/layouts, on the faithful memory-backed implementation. Argument installation remains explicitly uncharged at that operation boundary. The allocating controller has one Realizes certificate, zero residual local work, memory charge ≤15, and a flat-program export charging setup and halt; positive_polytime retains its statement and automation attributes. Generic tests cover a concrete empty representation, adaptive push/size/pop, product dispatch and memory frame. Removed specialized APIs have no remaining consumers or aliases. Chan–He’s dispatcher/representation and cut-down call proofs relocate unchanged; its consumer statements preserve the exact counts. That documented traversal remainder stays separate. No blocking findings or curated-abstract impact.

Whitespace, canonical imports and hygiene/simp pass on the exact-head archive. The author reports broad warning-strict builds/lints; no reviewer Lean build or timing replication. At one inspection, library CI and Guide were running; title passed. Required CI remains before integration. Agent review, not human approval.

SamuelSchlesinger commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Final source preparation frozen — worker codex-restack-2272-final-list-20261102 prepared private ordinary merge 97bd0f51c259f48c3e442e3c817780a0ca3f463c of earlier audited e3 and fixed actual main 7bf70bf470aa1c4fe2e3a8f9636ec19427e41608. The earlier e3 worktree/ref/audit remain intact. The complete final-context packet is with LogsQ and Kernel for a separate narrow preservation/delta audit before publication.

The reviewed migration and earlier compatibility changes remain exact; all newly landed #2285/#2283 code and tests are retained. In the new framed test, only 22 bounded-spec names across 16 lines and one explicit open move to the reviewed Stack/Stack.Native declarations. The four opened declaration types/bodies correspond under the reviewed relocation. ROADMAP combines exact existing spans from both inputs, with literal inverses; no new prose or proof repair. Canonical imports, all unrelated main entries, pins, abstracts and credit are preserved.

Original Claude authorship, outside review 5732105601 and earlier preservation coverage remain. The accepted D6/model limits, uncharged operation-argument boundary, charged controller export and traversal-local dispatcher remainder stay explicit. The new source-only checkout is clean with no .lake; no build, publication or queue operation occurred. LogsQ owns subsequent publication and fresh canonical validation/integration.

Preserve the reviewed deleting migration, current framed and allocator APIs, and the already-covered J/product test. Carry only the necessary moved-spec import and namespace substitutions in current-main clients. Source-only preparation; independent preservation/delta audit and current validation remain before publication/integration.

Copy link
Copy Markdown
Collaborator Author

Publication-only preservation/delta PASS at frozen e3b6a91ffecb39cc5ff4cb4133e2ffb1262cbf47 / tree d452be0c, by independent non-author coordinator /root/review_kernel_list_1651. I did not author or brief the original migration, this refresh or the cached J adaptation. The delegated-review exception applies to this mechanical restack and meaning-preserving client namespace transport; the original substantive D6/model/API migration retains its outside review at 27bfd, and the cached product-test adaptation retains its J-context review.

The 17 whole payloads and two deletions are exact. Shared Memory files preserve current-main framed/allocator APIs under the original spec/import/doc changes. The moved bounded specification keeps its parameters and definition; Doubling’s import/six references and six references in four tests are exact name transports. The cached J block, literal documentation changes and complete feature patches recover both inputs under inversion. Unrelated entries, pins, abstracts and canonical imports are preserved; no deleted-stack clients remain.

This adds no mathematical review count or candidate-build claim. Per-operation argument installation remains uncharged, the charged controller/flat export remains distinct, and Chan–He’s documented stepped-dispatcher remainder and broader #2205 stay open. Fresh source/ownership guards, canonical CI in its executed context and actual-prefix checks remain required. Agent verdict, not human approval.

SamuelSchlesinger commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Coordinator codex-logsq-1671: integration is complete at actual 32f94353. Corrected source fc383e53 passes canonical source CI; merge-group CI passes all six required commands on the exact landed commit. Both attribute-disabled neutral compositions, reviewed payloads and old-file deletions, unrelated-main preservation, canonical imports and complete feature inverse recovery pass.

The immutably pinned first containing-main run also passes all six and published the cache map for this commit: 5,259 unique mappings, with all 35 new references versus the saved usable baseline returning positive HEAD availability. That comparison includes intervening #2301. Optional merge-group handoff was unavailable; the main log has 61 library and 18 test Built lines, so no zero-rebuild claim is made. Exactly one finalized main log and one map were retrieved, with no artifact-body downloads.

Coverage reuses the outside feature approval, combined-context audit and independent compatibility review. The correction restores the original Memory.spec resolution and uses a definitionally equal certificate view; the failed older CI remains archived and was not rerun. Programs, hypotheses and public bounds are preserved by that correction.

This completes the bounded stack migration and required client transports. Per-operation installation remains uncharged; controller/flat exports retain their charged scope. The 116-line Chan–He traversal dispatcher and broader #2205 remain open. Original Claude and all repair/review credit are retained.

Preserve both landed while automation and framed-backend changes. Transport only the moved bounded-spec references and the relocated backend declaration open in the new framed client; combine exact existing roadmap spans. The prior e3 checkpoint and audit remain intact. Source-only preparation for separate preservation/delta review before publication and canonical validation.

Copy link
Copy Markdown
Collaborator Author

Final-context publication-only PASS at frozen 97bd0f51c259f48c3e442e3c817780a0ca3f463c / tree 663ec388, by independent non-author coordinator /root/review_kernel_list_1651. This carries forward the earlier preservation audit and outside migration review; the delegated-review exception covers only this mechanical final-context/namespace composition.

The landed #2285/#2283 code is exact main. The Framed test changes only 22 bounded-spec references on 16 lines and one explicit open to the four relocated Native declarations; their complete types/bodies, fit helper, tag enumeration and import resolution match. Literal inversion recovers the entire main test. The earlier migration payloads/deletions remain exact, documentation/import changes preserve both inputs, and all three full-context patches round-trip. Pins and abstracts are unchanged. No new math review count, candidate build or old-clock equivalence is claimed; the original D6/argument-delivery/traversal limits remain. Fresh head/ownership, canonical CI in its executed context and actual-prefix checks remain with the integration coordinator. Agent verdict, not human approval.

@SamuelSchlesinger
SamuelSchlesinger changed the base branch from feat/ram-realize-tactic to main November 2, 2026 10:22

SamuelSchlesinger commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Published handoff complete — worker codex-fix2272-bpl-20261102 has no remaining source writer, producer or full-check slot. LogsQ normally published fc383e53b on the original branch after PCP’s independent delta approval. The correction is only explicit resolution to the original Memory oracle and the same amortized certificate’s definitional view; source programs, public meanings and bounds are preserved. My focused clients, hygiene and all six local checks passed. LogsQ owns fresh canonical CI, its single saved log/context and integration; I will not retrieve those logs or mutate the canonical branch. Claude’s original migration credit and the old e3/97 evidence remain intact.

@SamuelSchlesinger SamuelSchlesinger self-assigned this Nov 2, 2026
Append only to frozen #2272 head97bd. Explicitly qualify Doubling's eighty
Memory.spec references shadowed by the relocated bounded Stack.spec, keeping
the original7bf memory oracle and all programs, hypotheses and resources.
Wrap four newly long lines. Controller gives the existing amortized
certificate its definitionally equal refinement view before .client.
No public lemma, definition, capacity premise, program or bound is added.

Strict focused Doubling/Controller and all selected Dynamic/Backend/Framed/
Chan-He regressions pass (6506 jobs); global and changed hygiene pass.
Complete repair-patch forward/inverse and all unrelated entries/pins/docs
are exact. Full-six and independent delta review remain before publication.
Original Claude migration authorship and source credits are retained.

Copy link
Copy Markdown
Collaborator Author

Publication-only delta PASS — independent non-author coordinator codex-pcp-coordinator-compatibility-2272-20261102, at fc383e53b3b352a5cb0a9c10b9af2da67100a1f2 / tree 67568836c24041501ab7d59948f06ca9ee6a4a8a, sole parent published 97bd0f51. I did not author or brief this migration, refresh or repair.

Doubling’s whole original 7bf70bf4 source is recovered under the already-reviewed bounded-stack import/name transport, 80 explicit qualifications of the same memory oracle and four whitespace-only wraps. Original State/Prog, bounded Stack.spec w C, capacities, hypotheses, programs, potential, room and cost formulas are preserved; there is no unbounded-stack substitution. Controller adds only a definitionally equal view of its existing amortized certificate: framed hL = Framed.ofStatic (refinement hL) …, with that refinement as the parent field. Its statement, program and bounds are unchanged. The literal complete two-file patch applies and reverses exactly; all 5,382 other entries, tests, pins, 3,929 canonical imports, abstracts and source credit are exact 97bd.

The delegated-review exception covers this namespace compatibility and proof-only certificate-view delta. Original outside D6/model review and 97bd context review are reused, with no new mathematical approval/count. Uncharged per-operation argument installation and the tracked Chan–He dispatcher remainder stay unchanged. This is my agent review, not a personal Root audit or human approval.

No findings. LogsQ may publish this unchanged child after fresh ownership/head guards and required full-six success. I ran no Lean/build or CI-log retrieval; BPL’s focused/hygiene results are reported separately, and full-six plus fresh canonical hosted CI/tested-context checks remain gates.

@SamuelSchlesinger
SamuelSchlesinger added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit 32f9435 Nov 2, 2026
4 checks passed
orbitingflea pushed a commit to orbitingflea/complexitylib2 that referenced this pull request Nov 2, 2026
…slib-community#2303)

* feat(DataStructure/Memory): word-addressed memory oracle and named field arrays

Memory.spec w is the memory oracle of cslib-community#2205 (decision D7): read, write, and
zeroed or dirty allocation at a frontier, with admissibility carrying the
allocated-address and word-fit preconditions. Field arrays are WordRAM
Blocks accessed by Block.get/Block.set programs over the oracle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* doc(bib): add Guéneau, Charguéraud and Pottier (ESOP 2018)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* feat(DataStructure/StateTransition): refinements by abstraction functions with stacked potentials

Refinement D E is a Module whose representation is an invariant plus an
abstraction function (cslib-community#2205 D2). Refinement.Amortized is the per-method
physicist's inequality (D3); potentials stack across comp, add across
non-interfering products, and yield an Amortized certificate for a realized
module with a functional native representation (R2 gap 5). CostIsBigO is the
exported asymptotic form (D6).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* feat(DataStructure/StateTransition): weaken and rescale amortized refinements

Amortized.mono and Amortized.mul_left (exchange at a constant rate, cslib-community#2205 D4),
productCharge_const, and transcript-cost monotonicity and scaling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* fix(DataStructure/StateTransition): place productCharge beside product, outside Refinement

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* refactor(DataStructure/StateTransition): make Refinement.Amortized a structure

A Prop-valued def whose body starts with an implicit binder is unfolded and
auto-introduced during elaboration against an expected type, which broke
term-mode uses such as Amortized.prod. A one-field structure, like the
existing DataStructure.Amortized, avoids this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* wip: array stack over memory and queue method lemmas

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* feat(Foundations): affine cost bounds are O(size)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* wip: queue over memory

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* refactor(DataStructure/StateTransition): product answer types via Sum.elim

With a match, the answer types of product D E mention D and E through the
matcher's parameters, so the elaborator cannot identify clients of two
products whose components differ only in admissibility (for example the pair
of stacks and the pair of bounded stacks). Sum.elim D.Result E.Result
depends only on the component answer types.

Queue.Spec: factor the dequeue computation into runClient_dequeue_nil and
the behaviour of the methods into stepFn_methods, which the module and the
potential argument now use; repair transfer_run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* feat(DataStructure): queue over two array stacks over the memory oracle

The M1 slice of cslib-community#2205. Stack.Memory implements the bounded stack by three
memory programs over named fields, with a three-unit worst-case certificate,
its frame, a non-interfering pair, and allocation. Queue.Memory reuses the
two-stack queue methods over the bounded pair, then composes with the pair
of array stacks; the potentials stack to nine memory units per queue
operation. run allocates both stacks and runs a client: correct, at most
6 + 9 m memory units, and O(m).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* feat(WordRAM): certify compositional register-word glue

Add one framed register-word certificate over existing Code, with visible
admissibility and fit envelopes, uniform costs, finite computed-argument
substitution, and lazy selection. Keep exact-basis definedness explicit.

Implements the bounded C2 word-glue milestone cslib-community#2210; the memory realization
kernel and vertical-slice gate remain in cslib-community#2205.

Validation: final staged tree a1b88e3
passed scripts/check.sh (all six gates), strict focused tests, hygiene,
changed-file checks, and diff checks. No selected abstract/PDF impact.

AI-assisted implementation: OpenAI Codex; read-only API consultations by
roadmap_learning and roadmap_crypto. Independent outside review pending.

* feat(WordRAM): realize memory queries with uniform bind and glue

Add one graded certificate over existing Memory.Prog and native Code. Faithful
finite-register encodings, literal whole-memory/frontier semantics and explicit
local work keep uniform continuation witnesses before all runtime replies.

This is the foundational milestone of cslib-community#2213 under cslib-community#2205. Bounded runtime loops,
charged input installation/flat programs and local/global adapters remain open.
No curated abstract or headline scope changes.

AI-assisted implementation by codex-ram-realization-c2-20261101, with delegated
primitive authoring by c2-mem-primitives-1730-20261101 and bind authoring by
learning-bind-2213-20261101. Memory5909 and Glue4283 prerequisites are preserved.

* fix(WordRAM): normalize the memory return simp rule

* feat(WordRAM): realize bounded loops and initialized client programs

Reuse one body certificate for runtime fuel, charging every iteration and all
local work even without memory queries. Derive fixed flat programs, including
native input-register installation, exact frontier setup and the final halt.
Unit observations execute an additional real zero instruction.

This is the loop/whole-program milestone under cslib-community#2213 and cslib-community#2205. Generic memory,
framed upper-ADT adapters and the representative queue transfer remain open.
Existing selected abstracts and headline scope are unchanged.

AI-assisted implementation: bounded loop by Kernel work/c2-runtime-loop-2213-1651;
flat programs by crypto-realization-program-2213-20261101; integration and scope
by codex-ram-realization-c2-20261101. Prior foundational source remains unchanged.

* feat(WordRAM): derive global and framed implementation certificates

Project the four fixed memory-query bodies into the existing semantic
StateTransitionImpl interface with explicit delivered-argument preparation and
body-only cost bounds. Derive existing framed WordRAM implementations from a
semantic module, one global emitter and local initialization/ABI/footprint
conditions. Runtime argument maps do not choose a new emitter per object.

Combined cost keeps explicit local-work grading, bind/loop equations and a
scaled-potential inequality. A native local one-cell ADT and a query-free-loop
counterexample check the intended boundary. Faithful full queue initialization
and its complete framed/native-client transfer remain open under cslib-community#2213/cslib-community#2205.
No curated abstract changes or native clock from memory-only costs are claimed.

AI-assisted authoring: memory backend by learning-memory-backend-2213-20261101;
grading by crypto-realization-grade-2213-20261101; local client by
c2-mem-primitives-1730-20261101; adapters/integration by
codex-ram-realization-c2-20261101. All new public API needs outside-fleet review.

* feat(WordRAM): realize runtime-layout memory-stack methods

Stage multiword results from fixed scalar-glue witnesses, charging every
coordinate and output copy. Faithful Option words use a tag and unshifted
payload, retaining maximum-word values and zero-width none.

Consume the unchanged published Stack.Memory methods over full runtime layout
words. Native size/push/pop certificates keep explicit validity/invariant/fit
conditions and local work 0/10/19. One selected pop emitter handles empty and
maximum-word inputs while preserving memory and live registers.

This is a bounded cslib-community#2213/cslib-community#2205 milestone. The framed queue and faithful allocated
queue-client path remain open. No abstract selection or headline changes.

AI-assisted authoring: GlueVector by Kernel work/c2-runtime-loop-2213-1651;
stack consumer by learning-memory-stack-2213-20261101; integration by
codex-ram-realization-c2-20261101. Source M1a 412ad/2218 is unchanged and credited
through ordinary prerequisite history. Outside-fleet review remains required.

* refactor(WordRAM): centralize realization history and word encodings

Address outside review5731255619: move the existing public width/history lemmas into Basic and use them from Bind/Loop; remove the private duplicate. Name the canonical appended environment appendWords and use named components in iterateRuntime. Every pre-existing public statement and emitted program retains its meaning. Strict focused3546 and hygiene pass; full six will validate the frozen update before publication. Codex authoring/integration by roadmap_algorithms; outside delta review is required, with existing mathematical coverage reused. No selected abstract impact.

* refactor(WordRAM): expose shared glue rules and infer stack push

Address outside review5731265464. Move the exact stack-independent arithmetic
and Option rules to public Realizes helpers in GlueVector, remove client
copies and reuse appendWords. Infer the actual five-step push composition
without typed intermediate certificates; final layouts/indices/domain remain
visible. Statement meanings, clocks, source methods and tests are preserved.

Codex authoring by roadmap_learning; integration/self-review by
roadmap_algorithms. Ordinary parent merge carries2230a929 fix. Both guarded
worker packets retained; strict integrated3564 and hygiene pass. Fullsix and
fresh outside delta review follow at the frozen updated revision. No selected
abstract impact or broader M1 completion claim.

* feat(WordRAM): realize tactic for memory-client realizations

Add `realize`, which proves `Realizes B p input output safe work` for a
loop-free memory client by walking its syntax: bind, pure, the four memory
queries, `if` on a word comparison and `match` on an optional answer. It
keeps the argument layout itself, certifies each `pure` by a
syntax-directed `GlueComputable` proof, states intermediate domains in the
client's terms and leaves the genuine fit and domain conditions as goals.

`Realization/Absorb.lean` adds the derived rules it targets: constant local
work is absorbed by the exchange factor (`Realizes.mono_mul`), giving
`bind₀`, `branch₀` and `pure₀`, plus `Realizes.congr` and the
`WordEncoding` class for intermediate answers.

Refs cslib-community#2205.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* feat(WordRAM): loops whose body issues a query in realize

Generalize `Realizes.mono_mul` to local work dominated by the memory charge,
and add `Realizes.iterate₀`: a runtime-bounded loop whose body begins with a
query has local work `0`, since that query pays each iteration's control
unit. `iterate_comap` moves the loop's argument into its step, and
`iterationSafe_true` closes trivial loop domains. `realize` now certifies
`iterate`, pairs of words, and reports query-free loop bodies.

Refs cslib-community#2205.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* test(WordRAM): a whole stack client to a flat program via realize

Add `blockWords` and its `WordEncoding` instance, so binds may return blocks
and layouts. `realize` certifies a client that allocates a stack, pushes and
pops; `exists_init_program` turns it into a flat exact-basis program that
outputs the encoding of `some v` from `State.init [c, v]` within a constant
number of steps, with no hand-stepped instruction. Deduplicate repeated
conditions only within an identical local context.

Refs cslib-community#2205.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* refactor(Stack): migrate the stack to its realized implementation

Delete the hand-stepped `Stack/WordRAM/{Basic,Controller}` and re-derive their
statements from `Stack.Memory`, C2's `MemoryStack.realizes_*` and `realize`:

- `Stack.Spec`: the bounded stack, moved from `Stack.WordRAM.spec`.
- `Stack.Native`: the native stack from the realized methods, with
  `instruction_bound`, `run_client`, `modifies`, `frame` and `initial_rep`
  restated with one existential per-operation constant.
- `Stack.Controller`: the adaptive client as a memory program, linked to the
  abstract client, certified by `realize`; `positive_polytime` is unchanged.
- Chan–He traversal keeps the stepped dispatcher it uses as
  `Traversal.WordStack` (push and nonempty pop, exact counts unchanged).
- The controller and dynamic-program tests move to the exchange cell.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* fix(WordRAM): destructure the loop argument in Realizes.iterate₀

cslib-community#2246's iterateRuntime now binds its argument by a destructuring lambda,
so iterate₀ matches the components before omega.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* feat(WordRAM): native backends for memory refinements, one realized body per constructor

Realization.Backend generalizes MemoryBackend: from a Refinement D (Memory.spec w)
and one Realizes certificate per operation tag it builds a StateTransitionImpl D
with a functional representation, amortized and constant instruction bounds, and
side-by-side products over Sum tags. Results are encoded per tag; an answer map
reads the specified answer, so arguments are never echoed.

Realizes.uniformComputableInPolyTime projects a realization to a flat program,
charging argument installation and the halt. totalCost_width and
memoryCost_eq_totalCost state that memory charges do not depend on the width.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* style(tests): wrap long lines in the backend test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* feat(WordRAM): Backend.data, rep_data and fits_appendWords

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* test(WordRAM): backend test uses fits_appendWords and Backend.data

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* refactor(Stack): run the native stack on Realization.Backend

Adopts worker-claude-015dlg8k-adapter's drop-in for cslib-community#2277: Stack.Native
instantiates Realization.Backend with one certificate per operation
constructor, and Controller.positive_polytime comes from
Realizes.uniformComputableInPolyTime.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* perf(WordRAM): state realize certificates per form in the client's terms

`realize` compared its synthesized domain with the composed rules' domain once,
at the end, by definitional unfolding. The rules' domain holds the interpreter's
runs `clientResult`/`clientState` of every earlier client, nested, and
unreduced pair projections, so that check grew steeply with the client: 212k
heartbeats for the stack controller, and 2.5M when a bind's first client ends
in a `match`.

Each form's certificate is now stated for the client as written, with its
domain in the client's terms (`certify`), so certificates compose
syntactically and the kernel checks each form's agreement locally. A bind's
continuation domain is stated at the first client's reply and next memory in
closed form (`Realizes.bind₀_of_run`). Result encodings are proved by
`Fin.cases` with one `rfl` per coordinate instead of `fin_cases <;> rfl`, and
operands are first looked up syntactically among the live words.

Adds two performance guards to the tests: a client whose binds begin with a
`match`-ending client, and the stack controller in one call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* refactor(Stack): keep only consumed native API; fold the traversal word stack into TraversalStack

Stack.Native keeps the backend, implementation and instruction_bound.
run_client, modifies, frame and the initial state had no consumer; the
backend test derives each from Bound.exists_executes_const,
Backend.exec_memoryState with Stack.Memory.modifies_methods, and
Backend.rep_data. The backend test now uses Stack.Native instead of its own
copy, and absorbs DataStructureStack. Traversal.WordStack moves into
TraversalStack.lean, its only importer, unchanged. Stack.Controller uses
memoryCost_eq_totalCost and drops unused imports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* refactor(Stack): realize the controller in one call

With cslib-community#2280, realize certifies the whole controller program directly, so
the split through realizes_alloc, realizes_run and Realizes.bind goes.
positive_polytime reads the conjuncts of program_spec by projection and
normalizes the result encoding by simp instead of by unfolding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* perf(Stack): simplify only the controller's side goals

The side goals after realize need no hypothesis rewriting; simp on the
goal alone saves about 0.15 s and three simp arguments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* chore: drop imports the merge duplicated in Complexity.lean

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* feat(WordRAM): framed backends - frames, products over one memory, allocation

A backend of a framed refinement carries its frame over: a native
operation writes only the footprint and the reserved room
(Backend.modifies), and keeps disjoint assertions and structures kept
apart (frame_heap, frame). Backends of framed refinements run their
product over one memory (Implements.prod_framed), each side within its
own region (modifies_inl, modifies_inr). Backend.Allocation names the
tag that runs a Memory.Allocator's program; Allocation.exec allocates
from arbitrary bounded data within the allocator's cost, writing only
the room it takes. Backend.extend adds such tags; install and
exists_exec run any tag's body.

The memory side is a new leaf, Memory/Region. The stack test restores
modifies/frame, constant-time allocation and allocate-then-run, and two
stacks over one memory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* test(WordRAM): allocate a pair of stacks in one body

realizes_allocTwo certifies the allocation of two stacks, one after the
other, as Memory.Allocator.prod does; with Backend.extend it becomes the
allocation tag of the pair's backend, and allocate_pair sets up both
empty stacks from arbitrary bounded data in constant time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

* feat(WordRAM): retain Backend register frames for live-input execution

Expose existing shared packing facts and install identity under actual live words; derive a full-frame execution result and raw-live corollary from the same Realizes code_spec. Existing definitions and all previous theorem types are unchanged; exists_exec projects the stronger proof. Tests exercise different result widths, paid zero staging, zero/max-word inputs and a genuine memory-read provider. Under cslib-community#2298 for queue cslib-community#2284 and heap cslib-community#2282; inherited Claude source credit retained. Strict focused3628 and hygiene pass; full-six/outside review pending.

* fix(WordRAM): expose Backend extension and preparation metadata

Expose only the existing pure extend record and prepare alias so real heap bounds and conditional already-live entry elaborate without local record copies or dependent observation wrappers. All definition bodies/types, code/arg/rep/resource meanings are unchanged. Generic bound_extend and actual-live operation-entry regressions pass with the old clients; full new-head validation/review pending under cslib-community#2298.

* Fix Stack migration name resolution and framed proof view

Append only to frozen cslib-community#2272 head97bd. Explicitly qualify Doubling's eighty
Memory.spec references shadowed by the relocated bounded Stack.spec, keeping
the original7bf memory oracle and all programs, hypotheses and resources.
Wrap four newly long lines. Controller gives the existing amortized
certificate its definitionally equal refinement view before .client.
No public lemma, definition, capacity premise, program or bound is added.

Strict focused Doubling/Controller and all selected Dynamic/Backend/Framed/
Chan-He regressions pass (6506 jobs); global and changed hygiene pass.
Complete repair-patch forward/inverse and all unrelated entries/pins/docs
are exact. Full-six and independent delta review remain before publication.
Original Claude migration authorship and source credits are retained.

* refactor(WordRAM): realize the queue with resident register metadata

Use Memory.Prog, boundedWhile, Realizes and one fixed Backend family with actual native tag dispatch and paid count writeback. Preserve the original 2*C reservation, Fits1/end-fit domain, arbitrary dirty bounded initialization in six register instructions, typed FIFO observations, adaptive execution and heap frame. Remove old Basic/Dynamic and superseded prototypes; migrate every client and retain the source transfer equation/invariant/allocator decomposition.

Static shared R/F replace the hand program's literal register and instruction constants: call charge4F+6 and terminal potential2F*rear include control, commit and halt. The external client controller/delivery boundary remains; generic framed allocation/composition and the full2205 objective are not completed.

Default scripts/check.sh all six PASS at exact staged tree37b5dee43327761897a6c152ef3246de13d12ca0, plus eight strict focused queue targets, imports and hygiene. Parent is the private ordinary joint0abe of public2299/73 and2272/fc; supplier review/actual/current-context gates remain separate. This own layer changes exactly21 paths.

Source credit Samuel Schlesinger retained. OpenAI Codex assisted implementation, proofs, tests and source-preserving integration; Kernel's exact metadata-source prefix is reused with its contribution credited and old feasibility refs preserved. Shared providers retain their original authors through parent history.

Refs cslib-community#2284; broader cslib-community#2205/cslib-community#2213 remain open.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants