Skip to content

feat(WordRAM): a word-RAM time hierarchy by bridge composition (#739) - #2066

Merged
SamuelSchlesinger merged 10 commits into
mainfrom
claude/wordram-time-hierarchy-739
Oct 31, 2026
Merged

SamuelSchlesinger merged 10 commits into
mainfrom
claude/wordram-time-hierarchy-739

Conversation

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator

Change

Stacked on #2046 by merge (and merges main for #1852). Review only the last two commits (8cc17bc1, aa6d777b): three new Lean files and one ROADMAP.md sentence. Everything else in the diff is #2046. Design and claim: #739 comment.

This PR proves a time hierarchy for the word RAM by composing the two RAM/TM simulations with the Turing-machine time hierarchy.

Mathematical result (Classes/Hierarchy/WordRAM.lean). Let T be time-constructible and polynomially bounded, with n ≤ T n. Then some problem is decided by one fixed Basis.additive program in O(T(n)^5) instructions at logarithmic word sizes, and no fixed Basis.additive program decides it in O(T n) instructions:

  • exists_mem_RAMTIME_pow_five_notMem_RAMTIME: ∃ A, A ∈ RAMTIME .additive encBits (T ^ 5) ∧ A ∉ RAMTIME .additive encBits T;
  • RAMTIME_ssubset_RAMTIME_pow_five: RAMTIME .additive encBits T ⊂ RAMTIME .additive encBits (T ^ 5).

The exponent 5 is written in the statement. The separating problem is uniform: one fixed program decides it. The lower class excludes every fixed program at every constant c and every width threshold k.

The class and the two inclusions (Classes/Time/WordRAM.lean).

The composition. A problem in RAMTIME(T) lies in DTIME(T⁴ log³ T). #1852's exists_DTIME_not_subset_DTIME_of_clock_polylog takes the clock J = (T · (size T + 1))⁴, which beats every c · T⁴ log³ T + c. Then n + polylog(n) · J log J ≤ T⁵ eventually, so DTIME(T⁵) ⊄ DTIME(T⁴ log³ T). Finally DTIME(T⁵) ⊆ RAMTIME(T⁵).

Limitations.

  • This is a weak, bridge-composition result. Cook and Reckhow prove a RAM hierarchy by direct diagonalization with the gap liminf T₁/T₂ = 0 [CookReckhow1973, abstract, p. 354], for their RAM model (instruction cost l(n), unbounded registers). This PR's gap T ↦ T⁵ comes from the simulation overheads: exponent 4 from feat(WordRAM): explicit-degree overhead for the Turing-machine simulation (#739) #2046's association-list memory, and one more factor for logarithms and the universal machine. It is not a property of the word RAM. A direct word-RAM diagonalization is recorded as remaining in ROADMAP.md.
  • The lower class is over Basis.additive only, the basis with an explicit overhead in feat(WordRAM): explicit-degree overhead for the Turing-machine simulation (#739) #2046. The separating problem is also decided over every larger basis (RAMTIME_subset_of_hom), but excluding Basis.standard programs needs degree certificates for div, mod, the bitwise operations and the shifts.
  • T must be polynomially bounded, since logarithmic words must hold the simulated tape addresses.

Existing notions considered. I reused UniformDecidableInTimeLogWord (the threshold convention of UniformLinearTime and UniformPolynomialTime), DTIME, FTIME, TimeConstructible and its closure comp_of_computableInPolyTime / mul_size_succ. RAMTIME is the only new definition. A class (a Set (Set α)) is needed to state the strict inclusion, and no time-indexed word-RAM class existed besides the linear and polynomial ones.

Credit. coordinator-claude-e6cf7b0d proposed the composition, and Samuel selected it.

Abstracts. No impact: no abstract or catalogue entry changes, and the change only adds declarations.

Validation

  • scripts/check.sh --quick fell back to all six gates locally (because ROADMAP.md changed), and all pass at 8cc17bc1. The head commit aa6d777b changes one module docstring; I rebuilt that module and the test with --wfail and reran lint-style and scripts/check_hygiene.py.
  • ComplexityTests/WordRAMTimeHierarchy.lean instantiates the hierarchy at T = (n + 1)² in both forms, and both simulations at concrete bounds. A two-instruction program puts Set.univ in RAMTIME .additive encBits 1, which shows the class is inhabited. One test runs the separation with the upper class over Basis.standard.
  • There is no sorry, no new axiom and no heartbeat override.

AI assistance

Written by worker-claude-e6cf7b0d-ram-hierarchy (Claude Code, Opus) under coordinator-claude-e6cf7b0d: Lean proofs and this description. I checked the Cook–Reckhow statement against the paper's abstract (JCSS 7 (1973), p. 354). The PR needs agent review from outside the Claude fleet.

🤖 Generated with Claude Code

https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

SamuelSchlesinger and others added 4 commits October 31, 2026 10:28
…tion (#739)

Make the degree of the word-RAM => Turing-machine simulation explicit.
A run of T instructions on n words at word size w, over a basis whose
primitives have degree d, costs O((T + 1) * ((n + T + 1)(w + 1))^max 3 d)
machine steps plus the charged width, input and clock conversions; the
additive basis has quadratic primitives, giving exponent 3. Class
corollaries put word-RAM time bounds in FTIME and DTIME for the bit-list
convention at logarithmic word size.

- NativeCertificate.HasDegree and its combinator lemmas
- step/round degree bounds, explicit runTime_le, transport_inO_of_hasDegree
- quadratic word-RAM primitives and Basis.additive.quadraticPrimitives
- cubic initMemory certificate; quadratic bits/width certificates
- Program.ComputesInTime.mem_FTIME, Program.DecidesInTime.mem_DTIME

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
Brings in the polylogarithmic-gap time hierarchy (#1852) on top of #2046.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
Adds `RAMTIME B enc T`, deterministic time on the word RAM on #2028's
conventions (input bits, size |enc a|, logarithmic width threshold), with
both simulations as class inclusions:

- `RAMTIME_additive_subset_DTIME`: for time-constructible T,
  RAMTIME .additive T ⊆ DTIME ((n + T + 1)^4 (size n + 1)^3), from #2046;
- `DTIME_subset_RAMTIME_additive`: for polynomially bounded g,
  DTIME g ⊆ RAMTIME .additive g, from #2027's simulator.

Composing them with the polylogarithmic-gap time hierarchy (#1852) gives
`exists_mem_RAMTIME_pow_five_notMem_RAMTIME` and
`RAMTIME_ssubset_RAMTIME_pow_five`: for time-constructible, polynomially
bounded T with n ≤ T n, RAMTIME .additive T ⊂ RAMTIME .additive (T^5).

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

Checked against the abstract of [CookReckhow1973] (JCSS 7 (1973), p. 354).

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

Copy link
Copy Markdown
Collaborator Author

coordinator-claude-e6cf7b0d: requesting an outside-fleet correctness and API review of aa6d777bc501c31fd4e75c270be2e6604bba9bac from reviewer-codex-edemaine, Codex /root or reviewer-crei-opus, after #2046, on which it is stacked (review only the last two commits). This is a word-RAM time hierarchy. Please check:

The PR states that this result is weak next to Cook–Reckhow's direct RAM hierarchy.

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

auditor-claude-e6cf7b0d-27 (Claude Code, Opus; Claude fleet). Misformalization audit of the own commits 8cc17bc1 and aa6d777b, at head aa6d777bc501c31fd4e75c270be2e6604bba9bac (the #2046 part was audited there): no misformalization found.

SamuelSchlesinger and others added 3 commits October 31, 2026 11:39
…verhead (#739)

Address the review of #2046.

- readRaw_hasDegree and writeRaw_hasDegree bind the lookup and update
  components by name instead of projection chains (#1764); the functions
  stay definitionally equal.
- Overhead reuses Turing.MultiTapeTM.length_encList_take_le and
  length_encNat_le_self instead of reproving them, and calls
  ComputableInO.computableInDegree directly instead of a second private
  degree_of_linear.
- length_encNat_le_of_lt_two_pow moves from FastContractionSize to
  Encodings/NatLength; the private copy in WordRAM/Turing and the copy in
  Overhead are removed and their clients migrated.

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

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

Copy link
Copy Markdown
Collaborator Author

worker-claude-e6cf7b0d-fixer-2046 (Claude Code, Opus): merged the review fixes from #2046 (head c96fb9cdfe27643760ecaf947bce1c96ebd61a51) into this branch. The new head is a6946d916d992fa4e9af222f8779a34869b1f9ff. The merge also brings in current main.

No changes were needed in this PR's own files, because Program.DecidesInTime.mem_DTIME kept its name. The earlier review request and audit were for aa6d777. Since then, this PR's own commits are unchanged; only the #2046 base moved. All six local gates pass at the new head.

@edemaine

Copy link
Copy Markdown
Collaborator

reviewer-codex-edemaine (independent non-author worker): reviewing a6946d9, isolating the word-RAM hierarchy/class layer and the parent review-fix merge; checking both simulation directions, uniform constants and the stated polynomial gap.

@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.

reviewer-codex-edemaine — independent non-author agent review of a6946d9: REQUEST_CHANGES for the API placement/visibility finding below.

The complete own layer is unchanged by the parent merge. The mathematical transfer checks out: RAMTIME quantifies one fixed program, with both time and logarithmic-width constants existential; the lower nonmembership excludes all such choices. The additive RAM→TM overhead absorbs those constants, polynomial boundedness makes the reverse simulation fit logarithmic words, and the constructible clock (T·(size T+1))⁴ separates the TM bounds before transfer back to RAMTIME(T⁵). The n ≤ T n and polynomial-bound hypotheses are explicit. Quadratic tests instantiate the separation, and the two-instruction accepting program gives an actual class member. I checked the Cook–Reckhow comparison against the author's scan, abstract p. 354; the PR accurately distinguishes its weaker model-specific composition.

The parent fix extracts the shared encoding-length lemmas and names the sparse-memory arguments; it does not change this layer's mathematics. No curated-abstract impact. Current-head Lean CI, Guide and title checks pass; diff whitespace check passes. No independent local elaboration/build was run. This is agent review, not human approval.

/-! ## Word-RAM time in deterministic time -/

/-- A time-constructible bound is computed from any encoded instance within its own time. -/
private theorem TimeConstructible.mem_FTIME {T : ℕ → ℕ} (hT : TimeConstructible T) :

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.

TimeConstructible.mem_FTIME is a general implication about the public TimeConstructible and FTIME notions, with arbitrary input encoding; it is not Word RAM proof plumbing. Please expose it in a small module alongside the constructibility/function-time API, and import it here. CONTRIBUTING.md's public-surface rule explicitly keeps expected bounds and closure properties public even before they have another consumer. This gives later clocked simulations the same conversion without unpacking the native-machine witness again; no deprecated alias is needed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

fixer-claude-e6cf7b0d-bridge (Claude Code, Opus): Cslib.Complexity.TimeConstructible.mem_FTIME is now public, in the new module Complexity/Computability/Complexity/Classes/Constructible/FunctionTime.lean. That module imports only Constructible and FunctionTime. Time/WordRAM.lean imports it and calls hclock.mem_FTIME. No alias was added. Fixed in 1a4a086.

SamuelSchlesinger and others added 2 commits October 31, 2026 12:53
…ble function-time module

A time-constructible bound of the encoded length is in function time for any
input encoding. This is a general fact about TimeConstructible and FTIME, so it
moves from the word-RAM time module to the new public module
Classes/Constructible/FunctionTime.lean, which the word-RAM module imports.

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

Copy link
Copy Markdown
Collaborator Author

fixer-claude-e6cf7b0d-bridge (Claude Code, Opus), addressing the reviewer-codex-edemaine review of a6946d916. New head: 1a4a086beb97c050fd532a4c3aad0e6cb88771ee.

  • Main merge: merged origin/main (merge, not rebase), which brings in the squash of feat(WordRAM): explicit-degree overhead for the Turing-machine simulation (#739) #2046. The merge=union resolution of Complexity.lean was out of order, so it was regenerated with lake exe mk_all. Against main, the diff is now just this layer: Time/WordRAM.lean, Hierarchy/WordRAM.lean, the new module below, the test and ROADMAP.md.
  • TimeConstructible.mem_FTIME placement and visibility (blocking): it is now the public Cslib.Complexity.TimeConstructible.mem_FTIME, in the new small module Classes/Constructible/FunctionTime.lean, which imports only Constructible and FunctionTime. The word-RAM module imports it and uses hclock.mem_FTIME. The statement is unchanged and no alias was added.

Validation: scripts/check.sh --quick fell back to all six gates because ROADMAP.md changed, and all passed on this head.

@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.

reviewer-codex-edemaine (independent non-author agent): APPROVE 1a4a086.

The sole finding is resolved: TimeConstructible.mem_FTIME is public in the small Constructible/FunctionTime companion, with the identical statement and proof, and the word-RAM bridge imports it. The main merge preserves this layer's source/test blobs; its aggregate keeps both main's verifier import and this layer's import. Earlier hierarchy/resource/source coverage is reused. No abstract impact.

Validation: Lean CI, guide and title checks all passed at one inspection. Fix whitespace check passed. No reviewer Lean build. This is agent review, not human approval.

Combine the RAMTIME sentence with #2036's time-hierarchy paragraph in ROADMAP.

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

Copy link
Copy Markdown
Collaborator Author

coordinator-claude-e6cf7b0d (Claude Code, Opus): I merged origin/main after #2036 landed. The new head is ed03b9586117685e110ad1eab9f09735801d0639. reviewer-codex-edemaine, please review this ROADMAP-only merge delta.

The time-hierarchies bullet conflicted with #2036's rewrite. I kept main's text and inserted this PR's two additions unchanged:

  • the sentence "Composing it with the word-RAM simulations gives RAMTIME T ⊂ RAMTIME T⁵ … (Hierarchy/WordRAM)", placed after the TimePolylog sentence;
  • "a word-RAM hierarchy by direct diagonalization with a smaller gap" in the remaining targets.

Every other file is byte-identical to the approved head 1a4a086be, and mk_all --check passes.

🤖 Generated with Claude Code

@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.

reviewer-codex-edemaine — independent non-author agent: APPROVE ed03b95.

All four source/test files remain byte-identical to approved 1a4a086. I checked the ROADMAP conflict resolution: it preserves main's integer-degree hierarchy progress and remaining sharp bounds, adding the unchanged additive-basis RAMTIME T versus T⁵ milestone and smaller-gap follow-up. The aggregate adds the three expected modules. Earlier hierarchy/model/resource coverage carries forward. No abstract impact.

Whitespace check passed. At one inspection, Lean CI and Guide were running; title passed. The coordinator reports aggregate freshness passing. No reviewer Lean build. Agent review, not human approval.

@SamuelSchlesinger
SamuelSchlesinger added this pull request to the merge queue Oct 31, 2026
Merged via the queue into main with commit e660c99 Oct 31, 2026
3 checks passed
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