Skip to content

Tighten Kani proof bounds for solver tractability#111

Merged
mikemaccana merged 1 commit into
mainfrom
claude/solana-examples-ci-failures-de67pd
Jul 14, 2026
Merged

Tighten Kani proof bounds for solver tractability#111
mikemaccana merged 1 commit into
mainfrom
claude/solana-examples-ci-failures-de67pd

Conversation

@mikemaccana

Copy link
Copy Markdown
Collaborator

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:

  • Nonlinear arithmetic (multiplying two symbolic values) is the worst case for bit-precise solvers
  • Rounding behavior depends only on residues and carry patterns, which smaller bounded ranges fully exercise
  • The solver's cost for symbolic division grows with the divisor's bit-width
  • Tighter bounds maintain proof coverage while dramatically improving verification time

https://claude.ai/code/session_01FYjBwE7n8i1J3ycYD8ebup

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
@mikemaccana mikemaccana merged commit 0017870 into main Jul 14, 2026
42 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants