Issue #1718: Found rule: a list of positions whose non-negative elements stay below another list’s length, kept across a truncate

Open and answer this issue on GitHub.

blocked, solver · opened 2026-11-15 · updated 2026-11-22 · 4 comments

Filed by the driver from the Found: of the run of issue-1668 (#1668) (owner, 2026-11-06).

Found

sv_sat heap invariant has no rule. Probe: struct H { heap: Vec[i64], place: Vec[i64] } with fn up(mut self, i: i64) { self.heap[i] = 0 }, fn pop(mut self) { ...; self.heap.truncate(last); self.place[top] = -1 } and a caller if self.place[v] >= 0 { self.up(self.place[v]) }: line self.heap[i] stays checked. ADR-306 D21/D22 index rule needs every element in 0..heap.len() and nothing taking from heap; sv_sat’s place holds -1 for “not in the heap”, heap_pop truncates heap (kept only by the permutation heap[place[v]] == v), and heap_insert writes place[v] = heap.len() before the push

Needs

supervisor decision: a found rule “every non-negative element of a is below b.len()” kept across a truncate of b (a permutation pair rule), or leave the three sites checked

To build

Done when

The probe gives the specified result and its test is green.


Generated by Claude Code

Comments

keywan-ghadami, 2026-11-15

Supervisor decision (2026-11-15): no language question. ADR-369 D4 already lets the compiler find a rule over a struct’s private fields that every construction makes and every method keeps; “every non-negative element of place is below heap.len()”, kept across heap.truncate(..) where the method also writes -1 to the one element that pointed past the new end, is one more shape for that search. Built as a found rule under D4: proved with certificates, kept in nikaia.proofs, never checked at run time, never published.

Done when: sv_sat.nika 960, 967, 971 are proved by the found rule, with a tests/compiler/tests/ program of the probe’s shape (its .bounds showing the rule as found), and a variant where one method breaks it stays checked.

Status: ready, prover lane.


Generated by Claude Code

keywan-ghadami, 2026-11-16

Brief queued: issue-1718


agent: builder model: opus max_turns: 200 budget_usd: 30 effort: medium —

Issue #1718

Your work order is issue #1718, inlined below with its comments. There is no brief written around it: plan your own steps from its To build list, build them in order, commit after each finished step, and end when its Done when holds (or at the limits of builder.md, reporting what is left). The facts in your prompt are Core of docs/builder-facts.md; more on a topic: nikaia run scripts/syntax.nika -- KEYWORD, a probe: nikaia run scripts/probe.nika -- SNIPPET.

Measure the issue against docs/issues.md while you work: what it lacked, what was wrong in it. That answer goes into the report’s Issue: field. A finding, a changed plan or a finished item also goes into the issue as a comment (gh api repos/Nikaia-Foundation/Nikaia/issues/1718/comments -F body=@file, ending with the Claude Code footer), rule I13.

Rules (CLAUDE.md; shared checkout)

Report (at most 15 lines, to exactly /home/user/Nikaia/docs/briefs/prover/issue-1718.md.report.md)

Fields: Result, Files, Commit, Body (optional), Fixes, Pushed, Tests, Gate, Deviation, Found, Needs, Changelog, Issue, Owner (a question for the owner), Comment (#N <text>, what to say on another issue; the driver posts it, one line each), Friction, Disk freed, and last Attribution: with your commit trailer lines below it.


Generated by Claude Code

keywan-ghadami, 2026-11-16

Run: issue-1718, Result: blocked

Tokens: input 30, cache read 733072, cache write 56932, output 9948 Cost: 0.84 USD, time 2 min 12 s, turns 15

Report

Result: blocked Files: none Commit: none Pushed: none Tests: issue probe run with target/fast/nikaia (HEAD c2c6a35cc) check --bounds: line 5 self.heap[i] “checked: a parameter whose callers do not prove a bound (ADR-391 D1)”, the other 8 indexes proved; nothing built, nothing committed Gate: green Deviation: none Found: The rule decided for #1718 (“every non-negative element of place is below heap.len()”, kept across heap.truncate where the method writes -1 to the element that pointed past the new end) is not inductive, so it cannot be proved as a found rule under ADR-369 D4: from heap=[0,1], place=[0,1,1] (the rule holds) the issue’s pop (top=heap[0]; last=len-1; moved=heap[last]; heap[0]=moved; place[moved]=0; heap.truncate(last); place[top]=-1) leaves place[2]=1 with heap.len()=1, so bump(2) indexes heap[1] out of bounds; which element pointed past the new end is known only through the pair link heap[place[v]] == v (with place[heap[p]] == p), a relation between two lists that the prover cannot state (prover_arena.nika has only Int, Var, Le, Lt, Ge, Eq over linear terms, no array read or write) and that sv_sat’s heap_up/heap_down sift loops break inside the loop (the hole slot), so it would also need loop invariants over arrays. Probe, check –bounds: struct H { heap: Vec[i64], place: Vec[i64] }\n\nimpl H {\n fn up(mut self, i: i64) sync {\n self.heap[i] = 0\n }\n\n fn insert(mut self, v: i64) sync {\n if v >= 0 && v < self.place.len() {\n self.place[v] = self.heap.len()\n self.heap.push(v)\n }\n }\n\n fn pop(mut self) sync {\n if self.heap.len() > 0 {\n let top = self.heap[0]\n let last = self.heap.len() - 1\n let moved = self.heap[last]\n self.heap[0] = moved\n if moved >= 0 && moved < self.place.len() {\n self.place[moved] = 0\n }\n self.heap.truncate(last)\n if top >= 0 && top < self.place.len() {\n self.place[top] = -1\n }\n }\n }\n\n fn bump(mut self, v: i64) sync {\n if v >= 0 && v < self.place.len() && self.place[v] >= 0 {\n self.up(self.place[v])\n }\n }\n}\n\nfn main() throws {\n let mut h = H { heap: [], place: [-1, -1] }\n h.insert(1)\n h.bump(1)\n h.pop()\n println(f"{h.heap.len()}")\n} gives line 5 self.heap[i] checked (ADR-391 D1); the decision expects it proved. No decision yet: build a permutation-pair rule kind with array terms in the prover (a new theory, larger than one run), or leave sv_sat.nika 960, 967, 971 checked. Needs: supervisor decision: the decided “non-negative elements below len, kept across truncate” rule cannot be proved inductive without the permutation link heap[place[v]] == v; decide between a permutation-pair rule (array terms in prover_arena plus loop invariants for the sift loops) or leaving sv_sat.nika 960, 967, 971 checked Changelog: none Issue: wrong I8a: the supervisor’s decision names a rule (non-negative elements below heap.len(), kept across truncate with a -1 write) that does not hold inductively on its own; the issue’s probe needed a state that satisfies the rule and breaks after pop (heap=[0,1], place=[0,1,1]) to show the rule needs the permutation link Owner: none Comment: none Friction: none Disk freed: none; target/nikaia-project-tests 1.9G, / 4.9G free of 252G, no new cache entry over 100 MB Attribution: Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01UVxJDwk9ubq9teP7QCErff

Debrief

  1. Most turns: working out whether the decided rule could be proved at all. That meant reading bounds_rules.nika (the rules_* candidates, rules_give, rules_exit, rules_truncated, rules_element_write) to see that rules are checked write by write, then finding a state the rule allows that pop breaks. The whole run was about 12 turns, and that part was most of them.
  2. Looked up: where found rules live (bounds_rules.nika) and how the existing index and capped kinds work, the sv_sat heap code (lines 905–1000), the earlier #1668 commit and its test, and what the prover can express (prover_arena.nika: whole numbers, names and comparisons, no list reads). The brief could have named bounds_rules.nika, the capped kind (#1785) as the nearest existing kind, and prover_arena.nika.
  3. Checks: the issue’s probe through check --bounds (needed), copying the before binary (wasted, since I built nothing), and the disk figures. I ran no builds or tests.
  4. Change that would save the most: a rule for decisions that write an invariant: before calling it ready, the writer tests that the rule survives each method (writes, truncates, sentinel values) from any state where it holds. A non-inductive invariant shows up in one paragraph; this one should have been caught at decision time.
  5. What the issue lacked:
    • rules-gap: the decision gave no check that the invariant survives pop from every state where it holds. A state where it holds and pop breaks it (heap=[0,1], place=[0,1,1]) shows it needs the heap[place[v]] == v link.
    • Correction: I wrote wrong I8a in the report without reading I8a in docs/issues.md. I took the label from the subject of commit 439f36ef9, so the report’s Issue: label is a guess and should not be trusted.
    • rules-gap: no line saying the prover has no list terms, so any rule that relates elements of two lists is out of reach.
  6. Traps for the next builder:
Fact: Core The prover’s term arena (prover_arena.nika) has only Int, Var, Le, Lt, Ge, Eq. A found rule linking elements of two lists (a[b[i]] == i) cannot be stated, so check first that the asked rule holds on its own through every method.
Fact: Core Found rules are checked at each element write (rules_element_write), not at method exit. A method that breaks a rule for a moment (write before push, truncate before a sentinel write) fails it even if the method ends with the rule true.

Generated by Claude Code

keywan-ghadami, 2026-11-16

Builder run of 2026-11-16: blocked. The decided rule (non-negative elements of place stay below heap.len(), kept across truncate) is not inductive on its own: from heap=[0,1], place=[0,1,1] the issue’s pop leaves place[2]=1 with heap.len()=1. It needs the permutation link heap[place[v]] == v, a relation between two lists the prover cannot state (no array terms in prover_arena), plus loop invariants for the sift loops. Taken out of the prover queue; it waits for a decision between a permutation-pair rule and leaving sv_sat.nika 960, 967, 971 checked.


Generated by Claude Code

Back to Open Issues