How the prover is built

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.

Three layers

The prover is three layers, and only the top one knows Nikaia (ADR-270 D1).

The prover's three layers. The frontend asks a query; a solver, which is not trusted, answers with a certificate; the checker replays it; what holds goes into nikaia.proofs and back to the frontend, which drops the check. frontend part of the compiler: walks the program, collects facts, asks questions, and turns each answer into a dropped check or a message logic layer no Nikaia syntax, usable by any package query facts, a goal and opaque ids checker replays every certificate; trusted nikaia.proofs one answer per question, committed solvers search for a proof or a counterexample never trusted asks query certificate check dropped
Only the checker is trusted. A solver's answer counts once the checker has replayed its certificate, and what holds is committed to 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).

What a build trusts

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).

The solver, today and as decided

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.

nikaia prove --propose hands each open loop to a proposer, any program the manifest names; the proposer answers with candidate invariants; the checker keeps only what it can check; that goes into nikaia.proofs, which every build reads without calling a proposer. nikaia prove --propose the only command that starts one proposer any program the manifest names: a language model, a learner from runs outside the compiler, never trusted checker keeps only what it can check nikaia.proofs committed with the code nikaia build calls no proposer one JSON line per open loop candidate invariants what holds
A proposal is checked like one of the compiler's own answers, so a wrong one costs time and nothing else (ADR-361 D6). Decided, not yet built.

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.

Invariants from a language model or another program

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).

The solver as decided: a strategy layer above a CDCL(T) skeleton, which drives fast paths, linear arithmetic and an e-graph; arrays and bit-vectors sit behind the e-graph. Built are the reference solver, Fourier-Motzkin with case splits written in Nikaia, which the compiler asks today, and the strategy layer, the CDCL(T) skeleton, the fast paths and the simplex with cuts of the new engine; the e-graph, arrays and bit-vectors are decided and not yet built. decided, not yet built built strategy layer · D14 picks engines, counts effort CDCL(T) skeleton · D12 decisions, propagation, conflict analysis, backjumping, restarts, learned clauses fast paths · D12 intervals, differences, no general search linear arithmetic simplex over the integers, cuts · D5, D11 e-graph · D13 equality, where the theories meet arrays lemmas on demand bit-vectors blasted into clauses asked today: reference solver Fourier-Motzkin with case splits, written in Nikaia
Every theory sits behind one interface of the skeleton, and theories meet through the e-graph by model-based combination (ADR-270 D12, D13).

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.

What the language has to offer the solver

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.

This site is open source. Improve this page.