Document the formally verified specifications #495
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 377 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.355
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #495"
general
weight: 0.35
chfast
The documentation of
intx.hppgets the specifications of the functions whose RV64 machine code is proved in Lean on the branchfv/main(#447), as@preand@postwith Lean terms. They show onmainwhat is verified: a function without@postis not.@note FV:marks the uses that the proofs do not cover:x += xand the other operators in place with y as the object, a quotient that overlaps the numerator inudivrem_by1()andudivrem_by2(), andoperator IntwithInt = bool. The README links tolean/README.mdonfv/main, which explains the specifications and what they assume, so the details change there without a change ofmain.The proofs stay on
fv/main: they take hours to build, somaindoes not check them, and they followfv/main, not each change ofmain.The pipeline
1.
include/intx/intx.hpp: the@preand@postof each function. Trusted: reviewed to state what the function is meant to do.2.
lean/IntxRV/Api.cpp: the instances to verify, compiled by clang 21 to RV64 (-O2 -march=rv64imafd). Automated (scripts/rv_build.sh). The compiler is not trusted: its machine code is what is proved.3.
lean/scripts/rv_gen.py: the machine code of each instance from the object file, linked by lld with its callees and constant data. Automated. Trusted: the code in Lean is the code of the object.4. The decoding of each word of the code to an instruction of the Sail RISC-V model. Automated, proved in Lean.
5.
lean/scripts/rv_api.py: the specification of each instance for the machine code: the arguments and the result in registers and memory by the RISC-V calling convention, the buffers that do not overlap, and the registers and the memory that the function keeps. Automated. Trusted: the translation of the C++ signatures.6.
lean/IntxRV/Api/*.lean: the proof that the machine code, run on the Sail model, returns with the@post. Written for each function, checked by Lean.7.
lean/Checks/: every instance has a proof that uses only the axioms of Lean and the opaque functions of the Sail model (nosorry,native_decideorbv_decide), and the preconditions of its specification hold in a machine state. Automated, checked by Lean.Also trusted: the Lean kernel and the Sail model with its environment, in which the memory of the buffers is ordinary RAM.
The cost
90 instances of 66 functions are proved, in about 42,000 lines of Lean. On the CI runner of GitHub Actions (4 CPUs, 16 GB):
| build | time |
|---|---|
| all the proofs, with the decode proofs cached | about 3 hours |
| all the proofs and the decode proofs of a new machine code | up to 6 hours |
| a change of one proof | about 10 minutes |
The slowest proof, of
udivrem_knuth_normalized(), takes 8 minutes and 11 GB; the decoding of a word of machine code 3-5 seconds and 120 MB.