
<div class="callout callout-note"><p>This page covers language constructs the prover understands, not every <code>vary prove</code> capability. For bounded checking, proof statuses, and counterexample replay, see <a href="/docs/prove/how-it-works/">How it works</a>. For caching, CI baselines, editor support, mutation testing, and Lean export, see <a href="/docs/prove/toolchain/">Toolchain integration</a>. Start with <a href="/docs/prove/first-proofs/">Writing your first proofs</a> for a guided example. A construct the prover cannot follow is reported <code>unsupported</code> by name; it is never reported proven.</p></div>

## Values and types

| Type | What is supported | Notes |
|---|---|---|
| `Int` | Arithmetic, comparisons, `//` and `%` with JVM rules | Modelled as an unbounded integer, with an overflow check on each operation. See [Solvers](/docs/prove/solvers/) for the exact 64-bit model |
| `Bool` | All operators | |
| `Str` | Literals, `len`, `==`, `!=`, `+` | With Z3 or cvc5 also indexing, slices, `startswith`, `endswith`, `strip`, `lower`, `upper`, `contains`, `find`, `replace`. `split` and `join` are opaque, with length facts |
| `Float` | Passing a value through unchanged | Arithmetic needs `--solver z3` or `--solver cvc5`, where it follows IEEE 754, including NaN. On the bundled solver it is reported unsupported with a hint |
| `Decimal` | `add`, `subtract`, `multiply`, `negate`, `abs`, comparisons, sign tests, `from_int`, `parse` of a literal, and `round`, `quantize`, `divide` with a literal scale | Modelled by its exact value. The scale it carries is not modelled. A product of two unknown decimals can need Z3 |
| `T?` | `Int?`, `Bool?`, objects, `data` values | Narrowing by `is not None`, `!= None`, `and`, `or`, `not` and an early return, and `!!` on `None`, are checked |
| Enums | Parameters, locals, return values, `match` on a variable | A wrong claim is refuted with a named variant such as `Color.Green`. Variants can carry any modelled value |
| `data` types | Fields of any modelled type | Compared by field |
| Classes | Fields, nested objects, optional fields, aliasing, invariants, `modifies` | Held in a heap model, never as plain values, because they are mutable and compared by reference |
| Tuples | Returned from a function, read by a constant index, unpacked with `let (a, b) = ...`, compared with `==` | Cannot be stored in a list or a field, or used in arithmetic |

## Collections

| Type | What is supported |
|---|---|
| `List[T]` | Elements of `Int`, `Bool`, `Str`, `data` or enum. Lists of lists to any depth. `len`, indexing (an out-of-range index is a checked obligation), slices (also of lists of lists), `+` (a literal or another list), `in`, `not in`, `==`, `!=`, `xs != None`, `sum`, `map`, `filter` and `sorted` with lambdas, and `[f(x) for x in xs if c]` over a range or a list of `Int` or `Bool`. `is_permutation(a, b)` from `collections` says two `List[Int]` hold the same values the same number of times |
| Changing a list | `xs[i] = v`, `append` and `pop`, on a list nothing else can see: a `let` or `mut` list made in the function, or the only list parameter of a function (which then belongs in `modifies`). A call to such a function gives the caller's own list a new value that satisfies the callee's `out` and `post`. See [Advanced proof techniques](/docs/prove/advanced/) |
| `Dict[K, V]` | `Int` or `Str` keys. Values that are scalars, `Str`, classes, lists or `data`. `d[k]` (the key must be present, which is checked), `k in d`, `k not in d`, `len(d)`, `d.get(k)`, `d.keys()` |
| `Set[T]` | `in`, `add`, `remove`, `len`, `union`, `intersection`, `difference`, and `{e for x in xs if c}` over a range or a list of `Int`, so `len({...})` works in a contract |
| `forall` and `exists` | Over a range or directly over a list. The body can call a predicate or nest another quantifier |

`sum` is exact: its total is described by a running-total recurrence, so a contract about it holds for lists of any length when a loop invariant states the running total. The total must fit in 64 bits, which is a checked obligation.

## Control flow and errors

| Construct | Behaviour |
|---|---|
| `if`, `elif`, `else`, `while`, `for` | Supported. Loops need an `invariant` to prove anything about what they compute |
| Recursion | Calls are checked against the function contract. A `decreases` measure proves termination; without one, the result promise can still be proven while termination remains unknown |
| `break`, `continue` | Supported |
| `match` | Checked for every variant |
| `Result[T, E]` | `Ok`, `Err`, `is_ok`, `is_err`, `unwrap`, `unwrap_err`, `unwrap_or` and the `?` operator. Each `?` is a possible early return, and the `out` clause is checked on every one |
| `raise` | Ends its path. `out` and `post` describe normal returns, so they are not checked on it. Class invariants and the frame still are |
| `assert` | Always checked |
| `try` | A `raise` in the body continues into the handlers; a call that may raise also enters them from before the `try`; `finally` runs on every path |
| `spawn`, `task_group` | Checked task by task against the contract of the spawned function of the program; two tasks that may write the same field are refuted as "concurrent writes"; a `task_group` with a timeout may end by `TimeoutError`. Nothing is claimed about every schedule |
| Channels | Opaque. Treated as calls the prover can't enter |

## Proof constructs

| Construct | What it does |
|---|---|
| `in`, `out`, `post`, `old(...)` | State preconditions and result or state promises. Calls use the callee's contract; `old(...)` refers to state at function entry |
| `invariant`, `decreases` | Establish loop facts and termination. The prover can infer common `decreases` clauses, but checks them like written clauses |
| Class `invariant`, `modifies` | Check object state and limit which fields a method may change. Missing `modifies` clauses can be inferred and reported |
| `lemma`, `ghost let`, `ghost mut` | Supply facts and proof-only state. They are checked and erased from compiled code |
| Quantifier triggers | Guide the solver when a `forall` proof is slow or undecided |

See [Advanced proof techniques](/docs/prove/advanced/) for examples and limits.

## Calls and code the prover can't see

| Case | What happens |
|---|---|
| A call to a function with a contract | Checked against the contract, never the body |
| A call to a built-in with an `extern def` contract (`ord`) | The contract's `in` is checked at the call and its `out` is assumed of the result. Every such contract is run against the runtime by a test |
| A call to a function with no body and no contract | Returns an unknown value of its declared type. Anything it could change (an object, list or dict passed in) is forgotten afterwards, unless the function is `pure`. Reported as `opaque:NAME` |
| A type with no model (`Path`, `Json`, `Instant`, keys) | An opaque value. It can be stored, passed, returned and compared with `==`, nothing else |
| A construct the prover can't follow | Only the obligations on its path are `unsupported`. The function's other obligations are still proven |

To close a boundary, give the callee an `out` clause, or make it `pure` if it changes nothing. A proof that relied on an opaque call lists it under `assumes` in the JSON report, so you can see what was taken on trust.

## Contracts for runtime functions

A few standard library functions have no Vary body: they are implemented by the runtime. So the prover has something to reason with, the standard library states their contract with an `extern def`. It declares nothing callable and generates no code. It only says what a call accepts and promises.

```python
pure extern def chr(code: Int) -> Str {
    out (r) {
        len(r) == 1
    }
}

extern def Json.stringify(self) -> Str {
    out (r) {
        len(r) >= 2
    }
}
```

The `Class.method` form gives the contract of a method on a runtime class. `pure` says the call changes nothing, so the prover keeps what it knew about the arguments across the call. Without `pure`, anything passed in is forgotten afterwards. At a call, the `in` clause is checked and the `out` clause is assumed of the result. A test runs every such contract against the real runtime, so an axiom the runtime breaks fails the build. `extern def` is for the standard library only; in your own code, give the function a body and a contract.

## Interfaces

A class that implements an interface must honour the interface's contracts: accept everything the interface method accepts, and promise nothing weaker. `vary prove` checks this for every method that appears in both, and reports it under the method name joined to the interface name with an at sign.

## How enums, options and data are solved

Enums, `Result`, `Int?`, `Bool?`, optional objects and plain `data` types are decided with the solver's own datatype sort on the bundled solver, Z3 and cvc5. Lists, dicts and optionals of these values are arrays of that datatype. This is why a claim about an enum variant or an optional field usually gets a definite answer rather than unknown.
