Tighten Kani proof bounds for solver tractability#111
Merged
Conversation
The first scheduled Kani run to include prop-amm (13 Jul) hit the GitHub-hosted runner's 6-hour hard limit: every other crate's proofs finished in under 3 minutes, but prop-amm's "Run Kani" step ran from 07:08 to 13:08 and was killed, surfacing as a cancelled run. The culprit is proof_quote_brackets_oracle, which left the oracle price at the full u64 range while multiplying it by the symbolic spread — a 64x14-bit nonlinear multiply plus 128-bit divisions, the worst case for the bit-precise solver (the old comment called this "linear", but both operands are symbolic). Cap the price at 16 bits: the rounding identities depend only on the product's residue mod 10_000, which a 16-bit price against the full spread range already covers exhaustively. Also tighten the symbolic-divisor harnesses (buy/sell to 8-bit amounts/prices, the chained round trip to 6-bit) to match the bounds the other finance proof crates stay tractable with, and give the verify job a 45-minute timeout so a blown-up harness fails fast and loudly instead of burning 6 hours and showing up as "cancelled". Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FYjBwE7n8i1J3ycYD8ebup
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.
Summary
This PR improves the tractability of Kani formal verification proofs by tightening symbolic value bounds in the prop-amm crate and adding a CI timeout to catch runaway verification jobs.
Key Changes
Quote bracket proof (
proof_quote_brackets_oracle): Increased price bound from unbounded u64 to 16-bit (0xFFFF) with detailed explanation of why this exercises all rounding edges without sacrificing coverage. The previous unbounded price caused the harness to run for hours.Buy/sell oracle value proofs: Reduced amount and price bounds from 1023 to 255 (8-bit) to align with solver tractability limits used in other finance proof crates. Updated comments to explain that symbolic divisor bit-width significantly impacts solver cost.
Round-trip profit proof: Further tightened bounds to 63 for both amount and price, as this harness chains two symbolic divisions and requires stricter constraints.
CI timeout: Added a 45-minute timeout to the Kani proof job to fail fast and loudly when harness bounds cause the solver to blow up, rather than silently hitting the 6-hour runner limit and appearing as a "cancelled" run.
Implementation Details
The changes are grounded in the observation that:
https://claude.ai/code/session_01FYjBwE7n8i1J3ycYD8ebup