Repository navigation
Feat: Interval proofs from guards and locals drop provably safe integer checks (#148) - #218
Merged
Merged
Conversation
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.
Closes #148
Feature added:
if x < e,while lo < hi, an early-returning guard), dropped on assignment and at loop back-edges;//and%by constants, whose results are bounded;len()bound now equals the verifier's 2**62.//and%by a power-of-two constant, applied to a proven non-negative value, emit a shift or mask.Behaviour change: proven ADD, SUB, MUL and NEG are now emitted unchecked (
tp_proven*). Before, they still called the checked helper plus a SystemError check.-DTP_CHECK_PROVEN, which turns a wrong proof into a SystemError, and now also runstest_interval_proofs.py.Defect fixed:
x % 10 + 1used to be proven by the front end but rejected by the verifier, so the whole function stayed interpreted.Tests added:
test_interval_proofs.py, 84 tests.<=narrowed as<, no join, ...) all fail tests.Tests changed (each where a fact changed):
test_verify: the mod/floordiv bounds test, the intervals-cannot-prove test, the wrong-node mutation, and a stale comment.test_cgen: the generation test, the bad-proven case, and the lying-proof test (which now builds with-DTP_CHECK_PROVEN).test_frontend: thei // 2parameter becamei // 3.test_frontend_classes: binary-treesmakeis no longermay_deopt.Checked ops in the benchmarks' C:
The remaining checks come from full-range function parameters and would need interprocedural facts.
Measured (quiet window, interleaved against develop, 11 pairs;
benchmarks/typedpython/results/2026-10-17-interval-proofs-ab.json): fannkuch 0.997 (0.63 to 1.21), binary-trees 1.001 (0.75 to 1.20). No measurable speedup: the removed checks were well-predicted branches.Verification (local, 3.15.0rc1t): full suite 1090 passed, 3 skipped. The compiled function sets of all five benchmarks equal develop's.