AXIOM Axiom Documentation
UABLACKGRAYWHITE
Axiom · black

Contracts

Contracts are the center of Axiom: machine-readable statements about the valid state of a program.

Backend code is full of rules like “offset is inside the buffer” and “response fits the reserved capacity”. Axiom turns those rules into proof obligations.

ConstructResponsible sideMeaning
require exprcallerPrecondition; the call is valid only when proven.
ensure exprcalleePostcondition that every return path must prove.
invariant exprtype / loopA property that must remain true.
assert exprcompile timeAn explicit proof checkpoint.
runtime_assert exprruntimeAn intentionally retained runtime check.
assume exprtrusted boundaryA restricted “trust me” operation; this is sus.

A writer that cannot overflow

Object invariantAxiom
1writer:2    view<u8> out3    usize used45    invariant used <= out.size()67    push(u8 value):8        require used < out.size()9        out[used] = value10        used = used + 111        ensure used <= out.size()12END writer
2

Mutable caller-owned storage.

3

Used byte count.

5

Object invariant.

8

Caller must prove at least one byte is free.

9

The index is safe because of the contract.

10

Advance the cursor.

11

The implementation proves the invariant still holds.

Runtime input still works

Validate once, keep the proofAxiom
1set_page_size(u32 requested) -> result<u32, request_error>:2    if requested == 0 or requested > 100:3        RETURN error(invalid_page_size)4    assert requested >= 15    assert requested <= 1006    RETURN ok(requested)
2

Reject invalid external input at runtime.

4

After the branch, this is a proof checkpoint rather than a second runtime check.

6

The success value is now known to be in 1..100.

Why this resembles SPARK

SPARK treats contracts as proof obligations instead of decorative annotations. Axiom adopts that mindset and extends it into views, memory regions, task effects, and bundle planning.