Repository navigation
Registration.stack is found in the contract the proof is of - #5120
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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'sstack: the bytes below the stack pointer that no buffer overlaps, and that do not wrap around), so the registration only repeats whatverified's type says, in a file reviewed by hand.ofApiandofSigalready pin it to that contract byrfl, so nobody needs to write or review it: #5114 had to edit seven registrations fromstack := 1008tostack := 560for 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.stackhas a default,by stack_of, and its type isStackOf contract:Nat, naming the contract so that the tactic can find the stack in it, exactly asConstsOfandconsts_ofdo for the tables of constants.contract, socontract's own default (used only whenverified's type does not determine it) can no longer mentionstack: it is theApi's contract for no stack.ofApiandofSigare unchanged. Whatstack_ofgives is therefore not trusted: the contract must be theApi's on the target for that stack, and oneSig.contractderives for it, andArtifact.stack, which the emitter documents in# Safety, is that number.Artifactitself is unchanged.No model, contract or
Verifiedchanges.Untrusted
stack_of(Proof/Framework/Registration.lean) unfolds the contract to itsSig.contract, asof_sigdoes, and gives itsstackargument as written there, soofApiandofSigcompare a term with itself.contract's default with a stack of their own, because theirverifiedis elaborated after the defaults are used (v.verifiedunder afun vwhose type is not yet known; a▸). The nine inArtifacts/(HMAC's x86-64init_any_key, RSA's ARMv7recover_primes_det) givevits type, as their neighbours already do; AES-GCM's x86-64initRegstates 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
mainwithout conflicts:lake buildof every module,lake env lean --run Emit.lean --check, the static checks, andci/check_lean_public_imports.pyon the edited modules.Generated by Claude Code