Issue #1319: The solver answers a batch on every thread, with the same answers at every thread count (ADR-270 D8 step 4, D18)

Open and answer this issue on GitHub.

ready · opened 2026-11-07 · updated 2026-11-21 · 2 comments

Part of #1053. Was blocked on #1285 (the solver moves into crates/nikaia-std/src/tools/ and becomes the engine behind lg_check; this builds on the files there), now closed; the solver’s files have since moved to packages/logic/src/sv_*.nika (4a48f306a, “The solvers and the logic layer are the package logic”). ADR-270 D8 step 4.

Goal

The rest of D8 step 4. nikaia.proofs (D19-D22) is built (proofs_answers.nika, proofs_book.nika, --locked). Two parts are open:

To build

This issue’s part:

  1. The batch entry: one call sv_check_batch(queries, budget) -> Vec[LgAnswer] answers a list of queries. Above a work threshold it uses par_iter() (ADR-235, Part II 12.6); below it, a plain loop. The threshold is a named parameter in the strategy’s parameter set (D14), counted in the solver’s work units, not in time. The answers keep the input’s order, so the result is the same at every thread count. Test: tests/compiler/tests/solver_batch.nika + .stdout. A batch answered at threshold 0 (always parallel) and at a threshold above the batch (one thread) prints the same answers.
  2. scripts/solver.nika run --threads N answers the files of a set through sv_check_batch. --summary prints the same solved count and the same answers as without --threads.
  3. The speedup figure, recorded in this issue: the speedup of a batch of SMT-LIB-sized queries (tests/solver/qflia, tests/solver/qflra). D8 asks for at least 0.7 × threads. docs/measuring.md counts work and has no rule for threads yet. Measured with callgrind --separate-threads=yes: speedup = total instructions / instructions of the busiest thread. Wall time is shown beside it, not as the figure. This rule is added to docs/measuring.md.

Done when

A batch above the threshold runs on every thread with the same answers at every thread count (the solver_batch test, and scripts/solver.nika run --threads N --summary equal to the run without it), and the speedup figure with the rule in docs/measuring.md is recorded here; the commit of item 1 carries Fixes #1319.

Files and limits

Ruled out

Split (2026-11-21)

Comments

keywan-ghadami, 2026-11-07

Owner, 2026-11-07: the solver is a product of its own. It should be faster than z3 and cvc5, use fewer resources, and solve more. ADR-270 D17 now records the resource goal. Added to this issue:

  1. Fourier-Motzkin as one pipeline of the strategy (D8, D14): sv_strategy_pick chooses it from the features (small, dense, without disjunctions), the same way it chooses the search or the walk, rather than sv_ask always running it first. The compiler’s order (FM first, #1285) stays until the measurements show that the pick is cheaper on the compiler’s queries.
  2. A cheap stage before Fourier-Motzkin: equalities substituted, bounds propagated, facts that share no variable with the goal dropped. Each step is a named parameter (D14). Measured on the compiler’s queries and on QF_LIA: instructions and answers before and after. It is kept only where it saves work or answers more.
  3. Resource figures on the rod (scripts/solver.nika, D17): beside solved count and PAR-2, instructions (callgrind) and peak memory, for this solver, z3 and cvc5, on the instances all three solve.

Generated by Claude Code

keywan-ghadami, 2026-11-21

Split into run-sized issues (2026-11-21).

Found built: item 10, the resource figures on the rod (instructions and peak memory for this solver, z3 and cvc5), in 667b0ff4 (compare in scripts/solver.nika). Items 1-9 were not found built (no sv_check_batch, no solver-cache / solver-measure, no --threads in scripts/solver.nika; sv_ask still runs Fourier-Motzkin first and sv_strategy_pick never picks it).

The blocker “The compiler asks the new solver: move it into tools” (#1285) is closed, so the label is now ready. The solver’s files moved to packages/logic/src/sv_*.nika (4a48f306a); the bodies name that place.

This issue keeps items 1 and 2 (the batch entry, --threads) and the speedup figure of item 7 with its rule for docs/measuring.md.

New issues:


Generated by Claude Code

Back to Open Issues