Issue #2506: Invariant proposers: nikaia prove --propose hands open loop problems to outside programs and checks what they answer (ADR-361 D6)

Open and answer this issue on GitHub.

ready · opened 2026-11-21 · updated 2026-11-21 · 0 comments

Part of #640

What it is

Outside programs, an LLM among them, may propose loop invariants; the compiler only checks what they propose (ADR-361 D6, Part III 13.2 and 13.3). A proposer is a program named in the manifest’s [prove] table, run only by nikaia prove --propose (or --propose=CMD for one run), never by nikaia build, run or test. It runs as a child process with one JSON line per open loop problem each way (ADR-361 D6, round 4, 0.0.998). Every candidate goes through the three-query check of ADR-361 D4 (built in d3d27e2d), and what passes is written to nikaia.proofs with the proposer as its origin (the invariant line was built in 2e4328bf).

To build

  1. The exchange, for one run: nikaia prove --propose=CMD. Start the proposer once as a child process. Write one JSON line per open loop problem to its stdin: {"version": 1, "id": …, "problem": …, "source": …, "names": […]}; problem is SMT-LIB HORN, source is the loop’s source text, names are the names it reads. Close stdin after the last line. Read one JSON line per answer from its stdout: {"id": …, "candidates": […]}, each candidate an SMT-LIB term over the names. Show the proposer’s stderr to the user. D4 checks each candidate; write the ones that pass to nikaia.proofs with the proposer as their origin. Test, with a stub proposer written in Nikaia and run with nikaia run: one true and one false candidate, only the true one is written.
  2. A proposer that misbehaves is one helper lost. Skip a proposer that crashes, ends early, or writes a line in another shape; the other proposers and the built-in strategies continue. Tests with the stub proposer: a proposer that crashes, the run continues; a line in the wrong shape is skipped; an unknown version is refused with a message.
  3. The manifest: [prove] proposers = ["cmd arg", …] and nikaia prove --propose. Tests: nikaia build never starts a proposer; --locked reads the written entry.

Done when

nikaia prove --propose=CMD and nikaia prove --propose with [prove] proposers hand each open loop problem to the proposers as JSON lines, write only candidates that pass the three queries to nikaia.proofs with the proposer as origin, survive a proposer that crashes or answers in another shape, and nikaia build never starts one, each shown by the tests above; the last commit carries Fixes for this issue and the report has a Found: line per finding.

Split from #640 by Claude Code

Back to Open Issues