Alpha. Vary is under active development and not ready for production use. Syntax, APIs, performance, and behaviour may change between releases.

Toolchain integration

At a glance

FeatureCommand or settingWhat it gives you
Proof cacheAutomaticResults are cached per function by content hash. Editing a function re-proves it and the functions that depend on its contract, and nothing else
EditorSave a fileProves in the background. Refuted shows as an error with an example input, undecided as a warning. Budgets are short
Check rulesvary checkVCC005 flags a loop in a function with an out or post contract that has no invariant, and VCC006 flags a lemma that nothing calls
CI baseline--write-baseline proofs.json, --baseline proofs.jsonRecords what is proven and fails a run when any of it regresses
Vacuous and trivial contractsAutomatic, --no-trivialityAn in block no input satisfies makes the function vacuous and nothing in it proven; a proven clause that holds without the body is marked trivial
Replayvary prove --replayRuns the compiled function on solver-chosen inputs and observes every proven clause on the runtime result; a disagreement is replay-mismatch
Check removalelide_proven_contracts = true under [compiler]Removes the run-time out, post and loop checks of fully proven functions
Mutationvary prove --mutants, vary mutate --with-proofsProof results kill mutants without running tests
Reportsvary prove --jsonA versioned machine-readable report
Lean--export-lean, --external-proofsA hand-off for goals SMT cannot settle

CI baselines

Record what is proven once, and let CI fail when anything in the record stops being proven:

vary prove --write-baseline proofs.json
vary prove --baseline proofs.json

A proven obligation in the baseline that is no longer proven fails the run, whatever it became.

Contracts that cannot hide

A proof is only as good as the contract it proves. Two questions are asked beside every proof so a wrong contract cannot pass as a right one.

VerdictWhat it meansWhat you do
vacuousNo input satisfies the in block (with the class invariants). Every obligation of the function is vacuous and none counts as proven. The note names the clauses that conflictFix the in block
trivialA proven out or post clause holds without the function body: a tautology such as r == r, or a clause the in block already implies. The verdict stays provenDecide whether the clause is meant to carry intent; if so, strengthen it

trivial is advice and never fails a run. --no-triviality switches the question off. vary check rule VCC002 catches the shapes that need no solver.

Replay against the compiled program

A proof says what the source means. The compiled program is what runs. --replay checks that they agree:

vary prove --replay src/

For every function with a proven out or post clause, the solver picks a few inputs that satisfy the in block, the compiled function runs on them through the test runner, and each proven clause is observed on the runtime result. A clause that fails is reported as replay-mismatch with the input, the run fails, and the cause is a compiler or encoding bug by definition. Clauses that use old(...) are not replayed and the report says how many were skipped. The replay is cached with the proof, so an unchanged function is not run again.

Removing checks that are proven

Contracts run as checks in production unless you tell the compiler otherwise. When a function's contracts are all proven, those checks can never fail, so they can go. Set elide_proven_contracts = true under [compiler] in vary.toml.

What is removedWhen
out, post and loop checksThe function is fully proven
in checks on underscore-private functionsEvery call site is proven
in checks on public functionselide_public_preconditions is set. Callers outside the file are then unchecked, so enable it only when you accept that

The setting is part of the artifact identity, so a cached build never mixes checked and unchecked code.

Proofs and mutation testing

Mutation testing asks whether your checks notice a change. Proofs make that question cheaper and sharper.

CommandWhat it does
vary mutate --with-proofsA mutant that the prover refutes is counted as killed without running any test, which speeds up slow suites. The report gains a proof section: which functions are fully proven and how many of their mutants the proof kills or lets through
vary prove --mutantsMutates each proven function and proves the mutants. A mutant whose contract obligations all still hold means the contract is too weak to notice that change

A mutant that survives a proof is a better signal than one that survives a test suite: it means the contract itself has a gap, not just the tests.

Reports and what a proof relied on

vary prove --json writes a versioned report. Each obligation lists assumes: the callee contracts and the builtin axioms (builtin:sorted, builtin:sum, and so on) that the proof used. Opaque calls appear as opaque:NAME. This is the trusted base of a result, made visible. A clause that holds without the body carries "trivial": true, the summary counts vacuous obligations and trivial_clauses, and a replayed function carries a replay block with the inputs run and every mismatch.

Lean export

When SMT cannot settle a goal, hand it to a proof assistant:

vary prove --export-lean proofs/ --function gcd
vary prove --external-proofs proofs/

The first command writes a Lean 4 file. A recursive function with a decreases measure becomes a Lean def with termination_by, so theorems about it can be proven. You write the proof. The second command accepts <function>.lean files that Lean checks and reports the goals as proven-external.

Vary guards the hand-off. The theorem statements and function definitions in the file must be exactly the exported ones, a stale proof is rejected, and a file that uses sorry or declares extra axioms is rejected. Only the decreasing_by proof and helper theorems are yours.