Skip to content

test(GenericRAM/Native): stack recursion with direct-contraction leaves - #1903

Draft
SamuelSchlesinger wants to merge 6 commits into
mainfrom
claude/t2-recursion-direct-toy
Draft

SamuelSchlesinger wants to merge 6 commits into
mainfrom
claude/t2-recursion-direct-toy

Conversation

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator

Change

This PR is a test only, and it is stacked on #1896. Until #1896 lands, the diff also shows #1896's files, so review only ComplexityTests/StackRecursionDirect.lean. After #1896 merges I will merge main back in.

This is the toy recursion asked for under #1538 (T2.9-prep). It instantiates StackRecursion.Scheme with #1862's directContractionCertificate as the leaf step. A node (k, (P, r, d)) is a chain of k calls, each with one child and the identity as combination step, and the chain ends in a leaf that contracts d modulo 2^P.

  • eval_chain: every chain has a derivation with k + 1 nodes and k levels.
  • run_chain: with fuel 2k + 1, the run returns some (d.contraction % 2^P) on every input.
  • chain_polyTime and chainCertificate: the components are polynomial-time, so one fixed machine computes the contraction.
  • chainCertificate_le: certificate_le applied with a size invariant. The time is 2k + 2 rounds, each a polynomial in (k + 1)(3n + 2) plus the leaf's L(n+1)^L 2^m. The space is polynomial. This shows that a non-polynomial leaf is charged only through the leaf bounds.

Validation

Local scripts/check.sh --quick fell back to all six gates, which pass on this branch (#1896 with main merged in, plus the test). check_hygiene.py passes.

AI assistance

Written by worker-claude-e6cf7b0d-t2-native (Claude Code, Opus 5.5) under coordinator-claude-e6cf7b0d. Needs non-Claude-fleet review of the test file.

🤖 Generated with Claude Code

https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

SamuelSchlesinger and others added 5 commits October 30, 2026 22:19
A generic recursion scheme (leaf test, leaf step, start/next/absorb/finish)
run by an explicit stack machine. Derivations `Eval I x y n h` (n nodes,
h stack levels) are evaluated in 2n - 1 steps through states with at most
h open frames. One native certificate runs the machine for a natively
computed fuel; its time is (fuel + 1) times a polynomial in (h+1)(F+1)
plus the leaf time, and its space a polynomial plus the leaf space.

Also the node count of a recursion tree and its 2^O(n/sqrt(log n)) bound
(Foundations/Data/Nat/RecursionTree.lean), for the call count of
[OpenAI2026ETH, Appendix D.4.7].

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

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

The fuel of the stack recursion on the scale of ContractionAlgorithm,
computed in binary from n in unary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
A chain of identity calls ending in #1862's direct summation: one fixed
machine computes d.contraction % 2^P with linear fuel, and the resource
theorem charges the exponential leaf only at the leaf.

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 review of 88e79c8a4b67cec557a8a50791fbbd5ca2902f2c from reviewer-codex-edemaine, Codex /root or reviewer-crei-opus. This is #1538 T2.9 groundwork, the native runtime for Theorem D.1 (prerequisite of #1833). A toy recursion with #1862 leaves and an identity combination, with its resource bound (draft; contains #1896).

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

integrator-claude-e6cf7b0d-a (integration delegate of coordinator-claude-e6cf7b0d, at Samuel's request): merging main into this branch now that #1896 has landed, so the diff is only this PR's own files. It stays a draft and is not queued.

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

This branch has not been deployed

No deployments
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.

1 participant