Open and answer this issue on GitHub.
blocked, safety · opened 2026-11-22 · updated 2026-11-22 · 0 comments
Records ADR-proof-kani-v1 (Kani checks the prover’s proofs on the emitted Rust, in a mode of its own); the fourth of its six issues. Needs #2724
In the Kani mode the emitter writes a function’s preconditions, its callers’ facts it relies on and its frame as Kani function contracts, so Kani checks each function on its own and stubs a checked callee by its contract.
ADR-proof-kani-v1 D3 (requires, ensures, modifies, loop_modifies, stub_verified), D4 (only the axioms and a function’s own requires are assumed; every other fact is an obligation). ADR-269 D5 (a parameter is bounded only by a precondition). ADR-306 D11, D12 (callers’ facts).
requires and ensures are written by emit_contracts.nika as checks or comments today; the builder reads which.bounds_proven, bounds_proven.nika, its facts); the frame (what a mut parameter may change) from the ledger (ledgers).requires and ensures. With the Kani mode, each Nikaia requires / ensures the prover used is also written as #[cfg_attr(kani, kani::requires(…))] / kani::ensures(|result| …). A clause with no Rust spelling is reported (no contract: f: requires <text>) and the function is harnessed without it. Test: tests/compiler/tests/kani_mode_writes_requires_and_ensures.nika.mut / ref mut parameter’s frame becomes kani::modifies(…); a loop changing it gets kani::loop_modifies(…). Test: a function pushing into a ref mut Vec[i64] inside a counted loop.#[kani::stub_verified(callee)]; Kani then checks the call site’s facts against the callee’s requires (an obligation, D4). Test: a caller and a callee with a precondition, the caller’s fact proving it.requires of a callee: Kani must refuse the caller’s harness. Test: the refusal line as .stderr.Done when, with the Kani mode on, cargo kani -Z function-contracts -Z loop-contracts proves the contracts of every harnessed function of the four tests above, refuses item 4’s weakened one, and reports each clause it could not write; without the switch the lowering is byte-identical (lower-std diff empty, quoted). Item 4’s commit carries Fixes #N. Each surprise is a Found: line in the report, never a new issue number.
emit_contracts.nika, emit_function.nika and their lowered .rs (output). No Rust by hand.requires emits today.proof_for_contract without stub_verified (checking callees inline): the harness of a caller re-checks every callee and the run grows with the call depth.