Skip to content

Registration.stack is found in the contract the proof is of - #5120

Merged
alex merged 1 commit into
mainfrom
claude/beautiful-clarke-lq6jdt
Nov 15, 2026
Merged

alex merged 1 commit into
mainfrom
claude/beautiful-clarke-lq6jdt

Conversation

@alex

@alex alex commented Nov 15, 2026

Copy link
Copy Markdown
Member

A registration states the stack its code's calls and frames use (stack := 592). That number is a parameter of the contract its proof is of (Sig.contract's stack: the bytes below the stack pointer that no buffer overlaps, and that do not wrap around), so the registration only repeats what verified's type says, in a file reviewed by hand. ofApi and ofSig already pin it to that contract by rfl, so nobody needs to write or review it: #5114 had to edit seven registrations from stack := 1008 to stack := 560 for a change that was entirely in the code and its proof.

This PR makes it derivable; the next one removes it from the registration files.

Trust change (TCB/Registration.lean)

  • Registration.stack has a default, by stack_of, and its type is StackOf contract: Nat, naming the contract so that the tactic can find the stack in it, exactly as ConstsOf and consts_of do for the tables of constants.
  • It is declared after contract, so contract's own default (used only when verified's type does not determine it) can no longer mention stack: it is the Api's contract for no stack.
  • ofApi and ofSig are unchanged. What stack_of gives is therefore not trusted: the contract must be the Api's on the target for that stack, and one Sig.contract derives for it, and Artifact.stack, which the emitter documents in # Safety, is that number. Artifact itself is unchanged.

No model, contract or Verified changes.

Untrusted

  • stack_of (Proof/Framework/Registration.lean) unfolds the contract to its Sig.contract, as of_sig does, and gives its stack argument as written there, so ofApi and ofSig compare a term with itself.
  • Ten registrations relied on contract's default with a stack of their own, because their verified is elaborated after the defaults are used (v.verified under a fun v whose type is not yet known; a ▸). The nine in Artifacts/ (HMAC's x86-64 init_any_key, RSA's ARMv7 recover_primes_det) give v its type, as their neighbours already do; AES-GCM's x86-64 initReg states its contract.

Every existing stack := still elaborates, and none is removed here. The generated crates are unchanged.

Checked

On a3186ac (the latest cached build when I started), then rebased onto main without conflicts: lake build of every module, lake env lean --run Emit.lean --check, the static checks, and ci/check_lean_public_imports.py on the edited modules.


Generated by Claude Code

A registration stated the stack its code's calls and frames use
(`stack := 592`), which is a parameter of the contract its proof is of
(`Sig.contract`'s `stack`: the bytes below the stack pointer that no
buffer overlaps), and which `ofApi` and `ofSig` already pin to that
contract by `rfl`. So it was stated twice, once in a file reviewed by hand.

`Registration.stack` now has a default, `stack_of`
(`Proof/Framework/Registration.lean`): the `stack` of the `Sig.contract`
that the contract `verified` proves unfolds to, as `consts_of` finds the
tables of constants. Its type, `StackOf contract`, is `Nat` and names the
contract for the tactic, as `ConstsOf` does. `ofApi` and `ofSig` are
unchanged, so what `stack_of` gives is not trusted: the contract must be
the `Api`'s for that stack, and the emitter documents exactly it.

`contract`'s own default, for a `verified` whose type does not determine
it, can no longer mention `stack`, and is the `Api`'s for no stack. Ten
registrations relied on it with a stack of their own, their `verified`
being elaborated after the defaults (`v.verified` under a `fun v` whose
type is not yet known, a `▸`): the nine in `Artifacts/` give `v` its
type, and AES-GCM's x86-64 `initReg` states its contract.

No registration drops its `stack` here, and the generated crates are
unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHHMmMkznUjKKnRwx5M
@alex
alex enabled auto-merge November 15, 2026 17:18
@alex
alex added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit f8da3f7 Nov 15, 2026
25 checks passed
@alex
alex deleted the claude/beautiful-clarke-lq6jdt branch November 15, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants