Status: Accepted
Date: November 7, 2026 (supervisor’s decision, by the language principles, on the owner’s direction that the compiler derives as much as it can itself, in small pieces it stores and reuses)
Answers: #1053 (the facts the walk lacks)
Related: ADR-269 D5 (a precondition is an assert at the top), D18 (only what is written is a contract);
ADR-270 D19-D22 (nikaia.proofs); ADR-306 (the walk of the checks);
ADR-361 D3, D4, D13 (nobody has to write an invariant; every one used is checked);
ADR-369 D4 (found rules of a type)
Half the index and arithmetic checks in tools/*.nika stay at run time
(#1053: 3049 of 6009 proved on November 7, 2026). The solver is not what
stops them: a new engine added three sites. The facts are missing, and most
of them are in the program already:
A parameter no precondition bounds (274 indexes, 282 operations):
fn pick(arms: ref Vec[i64], at: i64) -> i64 {
let mut before = 0
while before < at {
sum = arms[before] // checked: nothing says at <= arms.len()
before += 1
}
}
Every caller in the package passes an at no larger than arms.len().
ADR-269 D5 makes the author write assert(at <= arms.len()) to say it.
A fact about one field lost at a call on mut self:
while r < self.rows.len() {
self.note(1) // only writes self.hits
sum = self.rows[r] // checked: the call may have changed rows
r += 1
}
The walk forgets every fact about self at the call, because it does not
know what note writes. Its body says so.
The owner’s direction (2026-11-07): the programmer writes as little as possible; the compiler derives what it can, in small pieces, stores what it derived and uses it again.
Global and Depends contracts (what a subprogram reads
and writes) for bodies without them.For a function that is not pub (or whose package is a program), the walk
gathers at each call site the facts it holds over the arguments, in the
callee’s parameter names and their lengths (at <= arms.len(),
0 <= at), and proposes as the callee’s derived preconditions the claims
every call site proves. A claim is proposed from the shapes the walk already
reads: a comparison between an argument and a length or a constant at the
call site, and the facts a call site’s guard gives. Each is then a fact at the
callee’s entry, as a written assert at the top is (ADR-269 D5), and an
obligation at every call site, asked like any other claim (ADR-361 D4). A
function taken as a value (a lambda, a function pointer) has call sites the
walk does not see and derives none. A derived precondition is never a
refusal: a caller that does not prove it removes it, and the checks it would
have removed stay.
Widened (supervisor, 2026-11-15, #1673): the length side of a proposed
claim may be a linear term of one length and constants, c * xs.len() + d
with c and d constants the walk knows (l < 2 * value.len(),
at <= xs.len() - 1), when every call site proves that term. The callee then
reads the claim like any written assert of the same shape, so
xs[l >> 1] under l < 2 * xs.len() and 0 <= l is proved.
Widened (supervisor, 2026-11-16, by the language principles: the owner’s direction that the compiler derives what it can; 132 sites in private functions stayed checked because the proposals took too few shapes): a proposed claim may also be
p.order,
p.walked, p.order.len()), read through ref and mut parameters and
self, when the callee’s own frame (D2) does not write that path before the
read;g != 0), and a list that is not empty
(xs.len() >= 1);0 <= x and x < c * xs.len() + d
as in the widening above, so x + 1 and x - 1 are proved under it.Each is proposed only when every call site proves it, and is a fact and an obligation like any other derived precondition; nothing else in D1-D4 changes.
Changed by ADR-396 D1: a caller that fills a parameter with data from
outside the program and does not prove a derived bound of an index on it is
refused, NK1302.
For every function the walk derives its frame: the paths it may write
through its mut parameters and mut self (a field, a field’s length, an
element), by its own assignments and by the frames of what it calls, over the
call graph to a fixed point; a call the walk cannot resolve writes
everything. At a call, the walk forgets only the facts about the paths in the
callee’s frame. A frame changes no meaning and no check; it only keeps facts
the walk now throws away.
A derived precondition’s obligations and a frame’s uses are claims like any
other: their answers are kept in nikaia.proofs (ADR-270 D19-D22), checked
when read, written by a normal build and compared under --locked. The
proposals themselves are cheap and read off the source in each build; what is
kept is what costs, the proofs. An edit to a callee or a caller changes the
claims it asks and so the entries it uses; nothing else is searched again.
A derived precondition or frame is never published in the ledger, never
checked when the program runs, and never part of a function’s contract
(ADR-269 D18): a pub function’s preconditions are the ones its author
writes. --asserts and --bounds show a derived precondition as such, with
the call sites that prove it, so a reader sees what carried a proof.
Asking the author for an assert at the top of every private function.
It is what ADR-269 D5 offers today and what the owner’s direction rules out:
the facts are in the callers already.
Storing the derived claims themselves in nikaia.derived. That record is
what a package’s contract was derived from (ADR-251 D1); a derived
precondition is not a contract, and the proofs that matter are already kept
in nikaia.proofs.
Publishing frames in the ledger for other packages. Useful later, beside
touches, but it widens what a package promises; it waits for a need across
a package boundary.
--bounds shows them.