Repository navigation
chore(proofs): no axiom prints in library modules - #4247
Merged
Merged
Conversation
The two unforgeability modules ended with nine `#print axioms` commands under `#guard_msgs`, which ran again at every build of the module. `lake exe check-decls` in CI already fails on any axiom beyond the three standard ones, for every theorem of these modules, so they go. A new check, `scripts/check_lean_commands.py`, fails on any line of a library module that runs a `#` command, outside comments and strings. A command that must run at build time is listed with its reason in `scripts/check_lean_commands_allowlist.txt`. CI runs the check and its tests, and CONTRIBUTING.md states the rule. Closes ethereum#4236. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
The nine
#print axiomschecks leave the two unforgeability modules, and a new CI check rejects any command such as#print,#evalor#checkin a library module.The axioms of those theorems stay checked: the declaration check of CI already fails on any theorem of EthLib that depends on an axiom beyond the three standard ones.
Closes #4236.
The problem
Proofs/Xmss/Unforgeability.leanandProofs/Sphincs/Unforgeability.leanended with nine commands of the form#guard_msgs in #print axioms <theorem>.Each one runs again at every build of its module, so axiom checks lived in the build rather than in the check that CI runs for them.
Nothing stopped a new
#evalor#checkfrom landing in a library module either.The idea
lake exe check-decls, the step "declarations" of CI, loadsEthLib,EthLib.ProofsandEthLib.Exportsand fails on any axiom beyondpropext,Classical.choiceandQuot.soundthat a declaration depends on; its baseline lists no axiom finding.Both modules sit under
EthLib.Proofs, so the nine guards only repeated it, and they go.scripts/check_lean_commands.pyreads every Lean file underEthLib/, blanks its comments and strings with the stripper ofsoundness_facts.py, and reports each line where a#keyword, such as#evalor#eval!, opens the line or followsin.A command that must run at build time goes in
scripts/check_lean_commands_allowlist.txt, aspath | reason | command line; an entry that matches no command fails the check.CONTRIBUTING.mdstates the rule beside the rule on axioms.Example
The XMSS module ended with six blocks like this one, now removed:
On the tree before this change, the new check reports 18 lines, one for each
#guard_msgsand one for each#print.It reports none of the 35 lines that open with a vector literal such as
#v[...], since[follows#v.For reviewers
git logshows that the prints came with the unforgeability proofs (leanXMSS SUF proof #156, proof(xmss): bound forgery when the signer tells why signing failed #910, proof(sphincs): prove that leanSPHINCS is unforgeable #991, proof(xmss): move the signer's secrets behind two hidden-seed hops #1586, proof(xmss): bound the probability that a signing request fails #1588, proof(xmss): bound a forgery by the adversary's own hash calls #3370, proof(sphincs): bound a forgery by the adversary's own hash calls #3372, proof(sphincs): charge the signer's long counter searches apart #3461); none of these pull requests, their issues or the two files carry theleanVMlabel.#command, not only#print,#evaland#check, so#reduce,#synthor#exitcannot slip in either.An allowlist entry with its reason replaces that comment, because the check can then fail on an entry that no longer matches.
#keyword, such asrun_cmd, are out of scope; none exists inEthLib/.Checks
lake build --wfail EthLib.Cryptography.Proofs.Xmss.Unforgeability EthLib.Cryptography.Proofs.Sphincs.Unforgeability: success.lake exe check-decls --scope EthLib.Cryptography.Proofs.Xmss --baseline <empty file> EthLib.Cryptography.Proofs.Xmss.Unforgeability: 7446 declarations, 0 findings; the same for SPHINCS: 9332 declarations, 0 findings.python scripts/check_lean_commands.py: no finding; onupstream/masterit reports the 18 lines above.python -m unittest scripts/test_check_lean_commands.py: 11 tests pass; dropping the comment stripper, the keyword boundary, the allowlist match or the stale-entry report each makes a test fail.uvx ruff check,uvx ruff format --check,uvx ty check,check_python_comments.py,check_docstrings.pyon the new scripts: no finding.check_writing.py --base upstream/master,check_lean_layout.py --base upstream/master,check_layers.py,soundness_facts.py --check,check_comment_code.py: no finding.🤖 Generated with Claude Code