Status: Accepted
Date: November 29, 2026 (the consolidation and D15, #1790; D16, #1929; the decisions themselves October 3 to November 16, 2026)
History: the records this one replaces are archived in docs/history/adr; read them only for how the decision was reached
Answers: the owner’s question whether the compiler should know bounds
on the values a list holds, who finds them, and what they cost;
#1053 (the facts
the walk lacks); #1790
(whether a found bound’s end may be a multiple of a length);
#1929 (whether a
callee’s growth of a list is a found fact)
Supersedes / Related: takes the decisions on found facts from the
numbered records now in the history, with new numbers;
ADR-prover-walk-v1 (the walk that reads them),
ADR-prover-checks-v1 (what is done with a proof),
ADR-prover-refusals-v1 D6 (an obligation on
outside data is not dropped) ·
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-361 D3, D4, D13 (nobody has to write an invariant; every one used is checked);
ADR-369 D4 (found rules of a type)
Many of the costly checks are on a value read out of a list:
let start = list[k] // list is one of watched
... value[arena[start + at]] ... // start + at: u32, checked; the index too
The walk knows nothing of start, yet the program says what is in those
lists: watched only ever receives c * size with c < clauses, arena
only … % (2 * variables). Without a bound on the values a list holds, an
overflow option buys nothing - the overflow checks a walk can prove from
ordinary facts (2 * v + 1 with v < 2000) are the ones LLVM already drops.
Half the index and arithmetic checks in tools/*.nika stayed 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. And (2026-11-08): what a list holds is only found, never written for the prover to read (D2).
What may the compiler find about a program’s data and functions, from what, and what does it keep?
Global and Depends contracts (what a subprogram reads
and writes) for bodies without them.For what a list holds, ADR-prover-checks-v1 §2 weighs two families: the programmer writes a bound in the element type (Wuffs, Ada, Liquid Haskell, Dafny), or the tool infers one interval per array from every write (Astrée’s smashing, Clousot’s FunArray). D1 is the second.
For a list bound in the body being walked (a let, not a parameter), the walk
keeps a lower and an upper bound that hold of every value it holds,
linear terms over names the body never changes. The bound is the join of
what each write puts in: a literal’s items, push, insert, resize’s fill
value, xs[i] = v, and, for a list of lists, the same writes into xs[i].
Each write’s value is proved within the bound at that write, from the
facts that hold there.
The list has no bound if it is handed to a call that may change it (a
mut parameter, or a callee this program does not declare), captured by a
lambda, a task, an overlap branch or a select arm, or written by any
method not on a closed list. A value read from a list with a bound is a
number of the proof with that bound, wherever ADR-prover-walk-v1 D1 reads a number: in an index,
a comparison, an arithmetic check. A binding of such a read (let start =
list[k]) keeps the bound, and so does a binding of an inner list (let list
= watched[lit]) for its values.
The bound is found flow-insensitively, before the walk, from the writes of the whole body - Astrée’s smashing, with no fixpoint. The constants a write’s value lies between come from interval propagation over the linear facts that hold there; each end is then confirmed by the solver on a certificate the checker accepts, and an end it does not confirm is open. Two passes find the bounds, each reading the last one’s, and a third keeps only those every write is proved to stay within while assuming all of them - an inductive invariant. A bound that holds only by assuming itself larger is dropped.
D1’s bound on every value a list holds is found, not only for a let, but
for a list in a field and a list a function receives, and an end may be a
length of another list that never shrinks while the bound holds
(x < values.len() for atoms, when no reachable write removes from
values). For a field, the bound is a found type invariant
(ADR-369): every write to the field anywhere in the program is
seen, as D1 sees a body’s writes, and each write’s value is proved within the
bound at that write. For a parameter, it is a found precondition, proved at
every caller from the caller’s own facts (#1331). Built by #1397. A read takes the bound as
D1’s read does; nothing is instantiated in a certificate beyond the one
value read.
The bound is only found. No xs.all(|x| ...), no element rule and no
bound in the type is written by the program for the prover to read: a value
the compiler cannot bound stays checked where it is read, and the gap is an
issue of the derivation, visible in the measurement (owner, 2026-11-08: a
written fact hides the prover’s gap). This replaces step 3 of
docs/facts-about-data.md and option E (ADR-prover-checks-v1 §3) for element bounds.
Widened (supervisor, 2026-11-15, #1688): a field’s list of whole numbers
may also have the found rule ascending (xs[i] <= xs[i + 1]): proved at
each push (the value is at least the last element), kept by pop and a
truncation, lost at any other write. A read then takes xs[j] <= xs[k] for
j <= k, so the last element kept bounds every element. Like every found
rule it is never written by the program.
Widened (supervisor, 2026-11-16, #1688): the end of a field’s bound may
also be the length of another field’s list that shrinks
(limits.each() <= trail.len()), by D2’s own rule: every write is seen and
proved. A write to the bounded list is proved within the bound as before; a
shrink of the other list (pop, truncate(n), clear) is a write to the
bound and keeps it only where the walk proves every element still within the
new length there (for an ascending list, its last element <= n, after its
own truncation). Where it cannot, the rule is lost and the reads stay
checked.
pub fields, ends in the same value, a list’s own length (supervisor, 2026-11-08, #1397).Three questions D2 left open, decided by its own rule, every write is seen and proved within the bound:
pub field has a found bound when every file that can write it is
in the build: its type is not visible outside its package, or the package
is a program no other package imports. Otherwise code the compiler does not
see may write it (ADR-369 §5), and its values stay checked.col_atoms[k][j] <
atoms.len(), both fields of one self): a found type invariant relating
two fields, as ADR-369’s written rules do, holding when no write shrinks
the end field and every write to the bounded one is proved below it.parent.push(id)
with id = parent.len()): when nothing removes from the list, a write
proved below the length at that write stays below it, so D2’s “another
list” includes the list itself.The bound stays only found (D2). Decided by the supervisor as obvious under
the language principles (docs/supervisor.md, Language decisions): no
written form, nobody pays who does not ask for --bounds.
Two questions the walk left open, decided the way D2 is, only found:
find(b) < parent.len() when every return
is a value proved within it), derived in the callee like a frame of
D12 and, like it, never published (D14). A call
in a cycle (a recursive find) takes the bound as D1’s third pass takes a
loop’s: assumed, then proved at every return under the assumption. A
written ensures is read as it always was.row_value[a] beside atoms[a]): a
found relation between two lists of one value or one body, holding where
every change of the one’s length is matched by the same change of the
other’s before the next read. An index proved below the one’s length is
then below the other’s. Nothing is written for it.Decided by the supervisor as obvious under the language principles
(docs/supervisor.md, Language decisions): a derivation, no written form.
Two places D1 and D2 did not name, decided by their rule, every write is seen and proved within the bound:
let, D2/D3 for a field or a parameter): every insert and
every write through an entry is seen and proved within the bound where it
stands. A read m.get(k) ?? d is within the bound when d is; a read that
leaves by ?? continue or ?? return is within it as it stands.for x in f(...) binding and an element read of the result take
it as a read of a let list does.The bound stays only found (D2). Decided by the supervisor as obvious under
the language principles (docs/supervisor.md, Language decisions): a map
is a container as a list is, a returned list a value as D4’s is; no written
form, nobody pays who does not ask for --bounds.
D4’s second bullet, widened by its own rule:
lit_clauses.len() == 2 * atoms.len(): a found
relation a.len() == c * b.len() for a whole-number constant c of at
least 1, holding where every change of b’s length by one is matched by a
change of a’s by c before the next read. D4’s as long as is c = 1.
An index proved below c * b.len() is then below a.len(), and one below
b.len() is below a.len().Ends of an element of a list of lists (col_atoms[c][i] < atoms.len()) are
D7’s.
Decided by the supervisor as obvious under the language principles
(docs/supervisor.md, Language decisions): the same derivation as D4, no
written form.
D1 already counts the writes into xs[i] of a list of lists as writes of
xs, and gives one bound to every value of every inner list; D2 finds D1’s
bound for a field and a parameter, and D3 lets its end be another field of
the same value. Together they decide col_atoms[c][i] < atoms.len(): a
found type invariant on the field col_atoms, holding when every write into
any inner list (self.col_atoms[c].push(x), self.col_atoms[c][i] = x, a
pushed or assigned whole inner list whose own values are proved within it)
is seen and proved within the bound where it stands, and no write shrinks
atoms. A read self.col_atoms[c][i], a for a in self.col_atoms[c]
binding and a let of either take the bound as D1’s read does.
#385 stays open
for what it asks: a bound on values a table computes from its own values
(d[i][j] <= i + j), which no write of D1’s kind proves; D6 named it here
by mistake.
Decided by the supervisor as the reading of D1, D2 and D3 together
(docs/supervisor.md, Language decisions): only found, no written form.
D4 finds a bound on the value a callee returns against a length
(find(b) < parent.len()). The same derivation finds a relation of the
result to the callee’s arguments: a linear inequality between the returned
value, the integer arguments and the lengths of the list and string
arguments (skip_blanks(cs, from) >= from, next(cs, i) <= cs.len()),
holding when it is proved at every return of the callee’s body. At the call
the arguments are put in for the parameters, and the walk takes the relation
as a fact about the result, as D4’s bound is taken. A recursive callee
takes it as D4 does: assumed, then proved at every return under the
assumption. It is only found and never published (D14); a written
ensures is read as it always was.
Which relations are tried is the walk’s: those its ADR-prover-walk-v1 D1 queries at the call sites need (the result against an argument it is compared with, against the lengths it indexes), not every one that holds.
Decided by the supervisor as obvious under the language principles
(docs/supervisor.md, Language decisions): D4’s derivation with the
arguments in the fact, no written form.
Three places where #1531 found the walk stopping short of its own rules, decided by them:
self as one more argument: a bound on what it
returns, the element ends of a list it returns, and a relation of its result
or of self’s fields to their values at the call (self.var_col.len() one
more after new_var, its result equal to the old length) are found at every
return and carried to the caller, never published (D14).self. D11’s claims over a callee’s
arguments include claims over the receiver’s fields and their lengths
(i < self.heap.len() for heap_down, self.heap.len() > 0 for pop),
gathered and asked at each call site as D11 asks the others; the same limits
hold (no pub method another package can call, none taken as a value).limit.cases is an i64, so after
if x >= limit.cases { return } the walk knows x <= i64::MAX - 1 and the
overflow check of x + 1 is proved.Decided by the supervisor as obvious under the language principles
(docs/supervisor.md, Language decisions): each is a rule of D4, D11 or ADR-prover-walk-v1 D8 applied where it already reads, no written form, nobody pays who
does not ask for --bounds.
D4, D8 and ADR-prover-walk-v1 D8 find facts of a whole-number result; a result that is a
struct carries none, so let e = error_of(cs, at); e.offset - 1 stays
checked though every return of error_of builds E { offset: ... } from a
value proved at least 1 (#1557). Each whole-number field of a struct literal
at a return is read as D4, D8 and ADR-prover-walk-v1 D8 read a returned value: a bound against
a length, a relation to the arguments, an interval, holding when it is proved
at every return of the callee’s body (a return that builds the struct
otherwise than by a literal, or returns another struct value, gives that
field nothing). At a let bound to the call the walk takes them as facts of
e.field, a name of the walk as ADR-prover-walk-v1 D4 makes it, and keeps them until what ADR-prover-walk-v1 D4
lists for that path. They are only found and never published (D14),
and a method’s struct result is read the same way (D9).
Decided by the supervisor as obvious under the language principles
(docs/supervisor.md, Language decisions): D4 and D8 applied to the
fields of the value returned, no written form.
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 (D12) 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 D11-D14 changes.
Changed by ADR-prover-refusals-v1 D6: 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. Narrowed by D16: a found relation of a length in
the frame to its value before the call is a fact again after it.
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.
struct Sat { value: Vec[i64], lits: Vec[i64] }
impl Sat {
fn add(mut self, l: i64) { if l >= 0 && l < 2 * self.value.len() { self.lits.push(l) } }
fn assign(mut self, l: i64) { self.value[l / 2] = 1 } // proved
fn first(mut self) { if self.lits.len() > 0 { self.assign(self.lits[0]) } }
}
D2’s end, a length of another list, may be a linear term of one length and
constants, c * xs.len() + d with c and d whole-number constants the walk
knows (self.lits.each() < 2 * self.value.len()), by D2’s own rule: every
write to the bounded list is seen and proved within the term at that write,
and the term’s list does not shrink (or, where it does, D2’s second widening
holds with the term in place of the length). A read takes the bound as D1’s
read does; at a call, D11 then derives l < 2 * self.value.len() for
assign, and self.value[l / 2] is proved under it and 0 <= l. With
c = 1 and d = 0 it is D2’s end as it stood.
Why. D1’s bounds are linear terms already, D6 finds a.len() == c *
b.len() for a length, and D11’s widening (#1673) takes c * xs.len() + d for
a derived precondition; leaving the field’s bound at a bare length was the
one place the term stopped, and it kept sv_sat.nika’s
self.value[l / 2] checked.
Decided by the supervisor as obvious under the language principles
(docs/supervisor.md, Language decisions): D1’s linear terms and D11’s
widening applied to D2’s end; only found, no written form, nobody pays who
does not ask for --bounds.
struct Table { cells: Vec[i64] }
impl Table {
fn grow(mut self) { self.cells.push(1) }
fn c(mut self) -> i64 {
let r = self.first_odd()
if r < 0 { return 0 }
self.grow()
return self.cells[r] // proved
}
}
D12 forgets, at a call, every fact about a path in the callee’s frame, and a
length the callee only grows is such a path: r < self.cells.len() is lost
at self.grow(). The same derivation as D8’s finds a relation of a length in
the frame after the call to the same length before it, and to the
integer arguments: a linear inequality (self.cells.len() >= old, xs.len()
== old + 1), holding when it is proved at every return of the callee’s body,
with the length at entry as old. At the call the walk forgets the path as
D12 says and then takes the relation as a fact, with old the length it knew
before the call, so a fact r < old gives r < self.cells.len() again. A
callee in a cycle takes it as D4 does: assumed, then proved at every return
under the assumption. A body that may shrink the list on some path proves no
such relation, and the fact stays forgotten, as now.
Which relations are tried is the walk’s, as in D8: those its queries after
the call need. It is only found and never published (D14), and it holds for a
mut parameter’s length as for mut self’s (grow(xs) then xs[r]).
Decided by the supervisor as obvious under the language principles
(docs/supervisor.md, Language decisions): D8’s derivation, with a length
the callee changes in the place of its result, and D12’s frame keeping facts
the walk throws away; only found, no written form, no meaning changed.
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.d[i][j] <= i + j): #385 (D7).