Home / Docs / Language guide

Verification

Release v0.4.0

11.1 What the compiler proves

Obligation Created at
refinement every point where a value flows into a refined type: arguments, returns, fields, annotated let, and every rebind of an editable binding
precondition every call and capability operation with requires
postcondition every normal return of a function or handler operation with ensures
division / and mod by a non-literal
exhaustive when with range or literal arms and no else
overflow each +, -, *, /, mod and unary - on a fixed-width type in code, and each narrowing conversion (edition 0.2)

When proving an obligation, the compiler may assume:

11.2 Statuses

Status Meaning Build
proven the solver proved the goal ok
refuted a counterexample exists error U5001, with the counterexample
unknown the solver could not decide error U5002: unknown is never accepted

A U5001 or U5002 comes with the ranked repair candidates that apply at its site, each with an escape cost. None has a mechanical edit, and none is applied automatically. For a refinement or precondition obligation, with goal G, the compiler words them, in this order:

Repair When it is proposed Escape cost
strengthen the type of the parameter p to a refined kind that implies G the value is the parameter p of the enclosing function 0
add requires G to the enclosing function; its callers then prove it the enclosing function is not pub, and G names only its parameters 0
add a guard (if or a when arm) that handles the values where G does not hold always 0
check the value with checked(value, G) else fail <Variant> always 1

checked is an escape: its repair carries "escape": {"kind": "checked", "cost": ...} in --json, and the human output says escape: checked with its cost. Escapes always come after the repairs that keep the proof, and so do the other escapes, a raised checked_per_module (U7003) and a trusted module or policy (U4003, U4004, U7005) (ADR 0095).

Inside an example there is no parameter and no requires, so only the guard and checked remain. The other kinds have their own repairs, all with escape cost 0:

A goal that names no value, such as the 0 != 0 of x / 0, is false whatever the values: it has no repair and no counterexample, and the code itself has to change.

checked is the last resort: it replaces a proof with a runtime test and counts against the escape budget (§6.5).

11.3 Tiers

Tier Checks Command
0 syntax, formatting, names, types, effects, capabilities, information flow, budgets una check --tier 0
1 tier 0 plus every proof obligation (Z3) una check

Verification is reproducible: