This page describes the prover’s internal structure, what exists today, and what is decided and not yet built. The decisions are in ADR-270 for the solver and ADR-361 for loops, and the numbers that shaped them are in the solver workload. The questions this structure serves are under open questions about the prover.
The prover is three layers, and only the top one knows Nikaia (ADR-270 D1).
nikaia.proofs (ADR-270 D1, D5, D19).The frontend is part of the compiler (prover_walk, prover_claims,
prover_loops and their neighbours in crates/nikaia-std/src/compiler/). It
reads comparisons, guards, lengths, what a callee promises and a type’s rule,
and asks each question as a self-contained query made of facts, a goal, and
opaque ids for what they stand for (D3, D7). An answer is one of three. It is
proved, with a certificate, or refuted, with values that are checked by
evaluating them, or unknown.
The logic layer holds the terms, the normal form a query is keyed by, the checker, and SMT-LIB and Alethe at its edge for comparing with other solvers (D6, D19). Loops reach it as problems in constrained Horn clauses, which state what holds when the loop is reached, one turn as a relation, each way out, and what must hold after it (ADR-361 D1).
No solver is trusted. A proof is used only after the checker has replayed its certificate step by step, with clause steps, combinations of inequalities and their integer rounding, case splits, and the definition of a quotient by a constant (D5). The checker replays and does not search, which keeps it small.
What a build uses is the committed file nikaia.proofs, with one line per
question, keyed by the question’s normal form, holding its answer and the
evidence. Every entry is checked when it is read. A normal build searches only
for what is missing, and --locked searches nothing and fails on any
difference (D19-D22). The search itself may differ between machines and runs,
and what one machine proved is not rejected by another (D4).
Today’s solver is the reference solver, which decides linear integer
arithmetic by Fourier-Motzkin elimination with case splits on demand and is
written in Nikaia (logic_lia, logic_search). Its successor is decided
piece by piece, and each step is measured before the next (D8). The new
engine’s core is built, in Nikaia too (sv_*.nika): a CDCL(T) loop, the
simplex with cuts, fast paths, local search and a strategy layer, measured on
SMT-LIB sets by scripts/solver.nika. The compiler still asks the reference
solver; the switch, with the reference solver kept as the cross-check, is
#1285.
The skeleton is a CDCL loop over Boolean literals, and every theory sits
behind one interface. A theory takes a literal, propagates what it implies,
checks consistency, explains a propagation, backtracks, gives a model, and
names the terms it shares (D12). The compiler’s own questions are tiny, with
at most four variables and mostly bounds on single variables or differences
between two, so fast paths answer those without entering the general search
and without allocating (D9, D12). Theories are combined through the e-graph
by model-based combination. A theory’s model proposes equalities between
shared terms, the search decides them, and a theory that disagrees answers
with a conflict (D13). Numbers start as i64 and fall back to big integers
and fractions only where a value outgrows 32 bits (D11). Clauses live in one
arena of u32 words with watch lists that hold a blocking literal (D16).
| Part | Decided in | State |
|---|---|---|
| Three layers, query and answer, certificates and their checker | D1-D5 | built, in Nikaia |
| SMT-LIB and Alethe at the edge | D6 | built |
nikaia.proofs, checked on read, --locked |
D19-D22 | built |
| Loops as Horn clauses, invariants by closed forms and intervals, each checked | ADR-361 | built for whole numbers, more strategies to come (D5 there) |
| The solver’s inner loops measured in Nikaia against Rust | D8 step 1 | measured, the gaps found are in the lowering of indexes (solver workload, section 8) |
| Reference solver moved from Rust into Nikaia | D8 step 2 | done |
u32 variables, sparse rows, theory interface |
D8 step 3, D10, D12 | built; numbers are i64 kept small, and a step that would leave them answers unknown (D11) |
Big numbers where a value outgrows i64 |
D11 | not built |
| CDCL(T) skeleton, simplex, fast paths | D8 step 5, D12 | built, measured; not yet asked by the compiler (#1285) |
| Cuts, local search, strategy layer | D8 step 6, D14 | built, being tuned |
| E-graph, combination, arrays, bit-vectors | D13 | decided, not built |
| Parallel search within one question | D8 step 7, D18 | not built |
The same parts, each with a bar for how far it is built, are under what is being built.
A solver inside the compiler is not the only place a proof can come from. An outside program, a language model among them, may propose a loop invariant, and the compiler uses it only after checking it like one of its own (ADR-361 D6).
Only nikaia prove --propose starts a proposer, never build, run or
test, so the program’s code leaves the machine only through that command
and the proposer the manifest names. A wrong proposal costs time and nothing
else. The proposer is a child process, as language servers are, so what a
provider, a model, a key or a prompt is stays out of the compiler. This is
decided and not yet built, and what it adds is asked under
open questions about the prover.
The solver is written in Nikaia, so building it is also a test of the
language, with arenas of u32, flat loops over lists, and in-place changes
to one field of the solver while another is read. A probe of the forms a
CDCL(T) core and an e-graph need found most of them working and a few
defects in how they are lowered, each filed with its probe. They are
#1206 (an argument
that reads the list whose element a call changes),
#1207 (the value
or_insert hands back),
#1208 (a part of
mut self handed to a keep parameter),
#1209 (a part of a
list handed to a function and changed there),
#907 (contains
with a computed argument) and
#591 (a declared
struct as the key of a map). The work on the solver waits for these rather
than writing around them.