NK1207, NK1302, NK1303 and unproved-checksNote (#1600, 2026-11-15):
crates/nikaia-std/src/tools/has moved tocrates/nikaia-std/src/compiler/(its generated Rust tocompiler/lowered/). D9 and D13 keep the old path; the Rust module is stillnikaia_std::tools.
Status: Accepted
Date: November 29, 2026 (the consolidation, #1790; the decisions themselves October 4 to November 14, 2026; D6-D10 the owner’s, November 11, 2026: “ein Indexzugriff über Daten von außen braucht einen Beweis, sonst ist es ein Compilerfehler; was jetzt nicht geht, wird repariert oder zusätzlich mit einem sichtbaren Guard geschützt”)
History: the records this one replaces are archived in docs/history/adr; read them only for how the decision was reached
Answers: when a check nobody writes is not left to run time but refuses
the build: where the compiler shows it fails (an index, an overflow, a
shift, a divisor), where data from outside the program reaches it unproved,
and where a package asks for every check proved
Changes: ADR-380 D1 (an index the compiler does not prove
keeps its check) and ADR-prover-found-facts-v1
D11 (a derived precondition is never a refusal), both for data from outside
the program only (D6)
Supersedes / Related: takes the decisions on refusals from the numbered
records now in the history, with new numbers;
ADR-prover-walk-v1 (the walk that shows a check
fails or holds), ADR-prover-checks-v1 (what is
done with a proof) ·
ADR-269 D6 (NK1202, a guard where outside data arrives), D8
(a refutation is a model checked by evaluation);
ADR-359 D9 (refuted-claims);
ADR-380 D2 (unproved-claims);
ADR-010 D2, ADR-365 D1 (which sources are outside
the program);
Part I 1.4 and Part III 13.3, C.1 (NK1118);
#1571
(a guard at the call does not yet prove an index in a private function)
A program has three checks nobody writes: an index stays inside its list, an operation on whole numbers stays inside its type, and a divisor is not zero. Each stops the program at the line that runs it. When does the compiler refuse the program instead?
Where the walk shows the check fails for a value the program reaches, the
check would not rescue the program (D1-D4). A divisor that is a constant zero
is refused already (NK1118), but a divisor the compiler shows is zero only
through the walk, as fn f(d: int) -> int { return 10 / d } called as
f(0), built and stopped the program where it ran.
Where no value the program reaches is shown to fail, the fault may still be one a stranger chooses:
fn month_name(month: int) -> String {
let names = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
return names[month]
}
fn handle(req: Request) -> String {
let month = text::parse_i64(req.query("month") ?? "") ?? 1
return "" if !(month >= 0 && month <= 12) // one too many
return month_name(month)
}
The guard is wrong by one, and a request with month=12 stops the program at
names[month]. This built: the index kept a check (ADR-380 D1), the derived
precondition month < 12 was dropped because the caller does not prove it
(ADR-prover-found-facts-v1 D11), and the
compiler said nothing. NK1207 does not apply either: no value the program
reaches is shown to fail. The fault depends on what a stranger sends.
The derived preconditions were written to remove run time checks; a check that stays was counted as cost, not as a fault. The owner’s direction (2026-11-11) puts preventing faults first and performance second. Indexing a 12-element list is an implicit claim that the index is below 12. When someone outside the program chooses the index, that claim is exactly what ADR-269 D6 says no program can make about outside data without a guard (D6-D13).
Nikaia already knows which values are outside (ADR-010, ADR-365) and already proves indexes. This record joins the two.
let third = xs[5] over a list the walk knows holds three is refused, with
the value that fails, as a claim a program writes is (ADR-269 D8, NK1207);
refuted-claims = "warn" builds it with the check. Why an error. The
check would stop the program where the line runs; it would not rescue it. A
program the compiler has shown wrong does not build, whichever kind of check
showed it. Only on a refutation, never on unknown, and on ADR-269 D8’s
terms: a model checked by evaluation, for values the program reaches. The walk
runs at every build for this, whatever remove-*-checks says.
A / or % on whole numbers whose divisor the walk shows is zero for a value
the program reaches is refused with NK1207, naming the value, as an index
past the end is (D1). Only on a refutation, never on unknown: a
model checked by evaluation (ADR-269 D8). refuted-claims = "warn" builds it
with the check, a warning where it is reached.
d != 0 for each divisor d that is not a literal is a goal of the walk, as
0 <= i < xs.len() is for an index, and the walk runs for it at every build,
whatever remove-*-checks says. A divisor that is a constant zero stays
NK1118, refused before the walk.
The check that a divisor is not zero stays in the machine code, proved or
not. Whether remove-overflow-checks may also drop a proved one is not part
of this decision; it is a question of speed and is asked with a measurement.
unproved-checks = "error" (supervisor, 2026-11-09).The owner asked (2026-11-09) whether a value from outside should not need a
guard anyway, since otherwise nobody can be sure the program does not stop
at run time. For a written assert that is already so (ADR-269 D6, ADR-380).
For the checks nobody writes it is not: ADR-prover-checks-v1 §5 keeps Nikaia on the “check what is
not proved” side, and ADR-269 §6 left SPARK’s all checks proved open until
a package wants it. A package that wants it is now the case.
[build] unproved-checks is allow, the default, or error;
--unproved-checks overrides it for a single build, as
unproved-claims (ADR-380 D2). At error each index, overflow and
division the walk does not prove is refused (a new code beside NK1300, reserved with the build)
with the walk’s reason, and the help names the guard where the value
arrives (return … if i >= xs.len(), throw BadInput(n) if n > 100),
after which the check is proved from the guard and costs nothing.std and the
toolchain are lowered at allow (ADR-prover-checks-v1 D12) until their own figure reaches every
site.allow for now: a bound not found costs speed, never a
refusal (ADR-prover-checks-v1 §5), because a program must build before the prover is complete.error as the default (owner, 2026-11-09): “only a matter
of time, once the figure is at every site, and that is the goal”. That the
goal can be reached is not provable in general; it is pursued anyway. The
default changes when lower-std --bounds proves every index, overflow and
division of std and the toolchain (or guards them), and the line ADR-prover-checks-v1 §5 draws moves
with it.Decided by the supervisor as the opt-in that ADR-269 §6 and ADR-380 D2
prepare (docs/supervisor.md, Language decisions); the goal of the
default is the owner’s.
NK1302.An index into a list, a string or a slice, and a slice’s bounds, whose value
depends on data from outside the program (ADR-010 D2, ADR-365 D1: a request, a
socket, a database row, standard input, a file not marked trusted: true)
is proved in bounds while the program is built, or the build refuses it,
NK1302. “Depends” is the flow the compiler already follows for NK1202: the
value, or a value computed from it, reaches the index.
The walk follows the value through every call whose body it reads in the
package. A private function’s index on a parameter that a caller fills with
outside data is asked at that call, as the derived precondition of ADR-prover-found-facts-v1 D11.
For that caller the precondition is an obligation, not a fact to drop. The
message names the call, the index, and the case the walk could not exclude
(“Here month can be 12; names has 12 elements”).
An index that no outside data reaches is not asked. It is proved or checked as before (ADR-380 D1).
As with NK1202, the message names the form that works: a guard where the value
arrives, throw BadInput(month) if !(month >= 0 && month < 12), or the early
return that rejects it, after which the index is proved from the guard and
costs nothing. A guard that does not prove the index (one too many, as in §1)
leaves the refusal in place. That is the point of the rule. An assert is not
a way out: it is a claim about outside data (NK1202).
A guard the compiler should read and does not is a defect of the walk (#1571, #1482). It is fixed in the walk, not written around.
unproved-claims decides the severity, as for NK1300.NK1302 is a claim the build did not prove, so it follows
[build] unproved-claims (ADR-380 D2): at error, the default, the program
is refused. At warn it builds, each site a warning and a check where it is
reached. The switch exists for the day a better or a different prover
disagrees with an older one, not as a stage on the way in.
There is no intermediate warning stage by default. The build that adds
NK1302 also makes every site it finds in crates/nikaia-std/src/tools,
packages/ and examples/ build. Each site is one of two things:
Until those are done, the refusal is not merged.
--bounds shows it.--bounds lists an index that outside data reaches as such, with the source
of the value. It shows it as proved, with the guard that proves it, or as
refused (NK1302). At warn it shows the index as checked because of the
switch.
pub function states what its body needs (owner, 2026-11-14, #1576).A pub function cannot see who calls it, so every call into it may carry data
from outside. An index, a divisor or an overflow on a parameter that its body
does not prove from its own guards needs one of two things: a written
precondition on that parameter (an assert, published as requires,
ADR-269 D18, D20) or a guard in the body that handles the case. Otherwise it is
refused, NK1302 for an index and NK1303 for a divisor or an overflow (D12),
under unproved-claims (D8). Postconditions stay optional: a caller that needs
a fact about a result gets the hint NK1263 (ADR-359 D4). A derived
precondition is still never published (ADR-prover-found-facts-v1 D14).
The rule of D6 applies the same way to / and % and to the plain +, -
and *. An operation that data from outside reaches, and that the build does
not prove safe (a divisor not zero, and for / and % on signed integers not
the minimum by -1; a result inside its type), is refused, NK1303, under
unproved-claims (D8). Where the author chose how overflow is handled, with
wrapping_*, saturating_* or checked_*, that choice is the handling and
nothing is refused. --bounds lists / and % as proved or checked, as it
already does for +, - and * (D10).
D11 and D12 are fixed rules; the order of the work does not reopen them:
crates/nikaia-std/src/tools, packages/ and examples/
that they would refuse are listed;std contract, a ledger entry) or the prover is improved. No guard goes
into our own code only so that the prover gets through. An i64 or u64
+, -, * gets its goal within the bounds walk’s window ±2^62 (as
#444 and the division goal); a proof there is final, and NK1207 is raised
only when the refuting values, computed with checked_*, really leave the
type (ADR-270 D11, #1810);A warning first, an error later. The owner rejected it (2026-11-11): code that builds with a fault a stranger can trigger is what the rule is there to stop, and the sites in our own code are repaired before the rule is merged (D9).
Refusing every index the compiler does not prove. That is SPARK’s silver level. Most unproved indexes in our code are reached by no outside data, and the prover is incomplete (ADR-269 D10). Outside data is where a stranger chooses the value.
Accepting an assert as the way out. An assert about outside data would
claim what the program cannot know (ADR-269 D6). Only a guard handles the
case.
NK1302 beside NK1202 and NK1300. 13.3 says that
unproved-claims covers it.tests/compiler/: f(0) over 10 / d is
refused with NK1207 and the value; with refuted-claims = "warn" it
builds and stops where it runs; a divisor the walk cannot decide builds as
before.remove-overflow-checks may also drop a proved divisor check (D4):
a question of speed, asked with a measurement.