Files
sisi/verifiers/prove/proof-bridging.md
T
swaitsandClaude Fable 5.2 2fc1fe9c2d
ci / tests (macos-latest, python 3.11) (push) Canceled after 0s
ci / tests (macos-latest, python 3.13) (push) Canceled after 0s
ci / tests (macos-latest, python 3.9) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.11) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.13) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.9) (push) Canceled after 0s
sisi 0.1.0: a shared rulebook and verification tool for AI coding agents
Contracts with a ladder of checks, an end-of-turn gate, retrospectives and
shared lessons, time-to-delivery measurement, a library of 140 verification
techniques and 20 recipes, personal data kept outside the clone, and
releases with rollback. Standard library only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 22:29:02 -07:00

3.1 KiB

id, title, answers, rung, section, languages, kinds, cost, detect, ran_here, verified
id title answers rung section languages kinds cost detect ran_here verified
proof-bridging Bridging a proof on a simplified type to the real type with a differential test My proof was done on a simpler representation (like i64); does the real code (like Decimal) behave the same? 2 prove any money, general medium yes ran

Use when

  • A proof tool handles only a simple model (Kani on i64, Lean on Nat, Dafny on int) and the production code uses another type (Decimal, BigInt, floating point, a struct).
  • You want to say the proof carries over to the real code, with evidence you can run.

Do not use when

  • You can prove the real type directly (aeneas-rust-to-lean, verus). Do that instead.
  • The two types differ in the property you proved (rounding, overflow, ordering): then the bridge must show where they agree, and the claim shrinks to that region.

Set up

Write the model function and the real function with the same shape. In the test, generate inputs, run both, convert the model result to the real type, and assert equal. Include an independent exact reference (a big-integer or rational one) as a third voice when the model is lossy. Use proptest in Rust or hypothesis in Python for random inputs, plus a fixed list of edge cases (zero, minimum, maximum, ties, negatives).

Minimal example

fn halve_model(x: i64) -> i64 { x / 2 }          // what the proof covers
fn halve_real(x: i128) -> i128 { x / 2 }         // what production runs (wider type)

#[test]
fn bridge_agrees() {
    let mut s: u64 = 0x9E37_79B9_7F4A_7C15;       // fixed seed: reproducible
    for _ in 0..100_000 {
        s ^= s << 13; s ^= s >> 7; s ^= s << 17;  // xorshift
        let x = s as i64;
        assert_eq!(halve_model(x) as i128, halve_real(x as i128));
    }
}

State in the test's doc comment which proof it carries (kani proof halve_is_floor), over which inputs, and what is assumed equal.

Run

cargo test bridge

Passing looks like: exit 0 and test tests::bridge_agrees ... ok. Failure: the first disagreeing input in the panic message.

As a contract check

{"id": "prove-bridge-i64-to-wide", "claim": "The real halve agrees with the proved i64 model on 100000 seeded inputs and the edge cases", "kind": "money", "rung": 2, "cmd": "cargo test bridge", "expect": {"exit": 0, "stdout_contains": "test result: ok"}, "tier": "deep", "timeout_s": 600}

What a pass does not prove

  • It samples, so the bridge is rung 2, and the proved claim for the real type is only as strong as the bridge. Say so in the contract claim.
  • The bridge must show: same results where both are defined; both refuse (error or None) on the same inputs; behaviour at the model's bounds; and every wrapper between the proof and the real call. A wrapper that is not in the bridge is unproved.
  • Compare against an independent exact reference where the model truncates (for example integer division drops fractions that Decimal keeps), or you test two things that share a flaw.
  • Generators that rarely hit edges miss them; list ties, zero, min and max explicitly.