Issue #1890: bounds: indexes read out of another list (173 sites in packages/logic): survey, found element rules, then array terms and the permutation pair (sv_sat 960/967/971)

Open and answer this issue on GitHub.

ready, solver · opened 2026-11-16 · updated 2026-11-23 · 2 comments

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

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

To build

Done when

The probe or check gives the expected output the first item names from its ADR or Part I-III section, and a tests/compiler/tests/ test (or the named check) that failed on the unfixed tree is green; or the probe already passes on develop and a test pins it, naming the commit that fixed it; or the issue is closed as by design, naming the function or ADR.


Generated by Claude Code

Comments

keywan-ghadami, 2026-11-16

From the report of the run of issue-1891 (#1891):

The rule for the I8a gap behind this decision is in docs/issues.md (#1891): a decided field rule is checked as an induction step from any allowed state, and a relation it leans on that the prover cannot state is a decision, not an item.


Generated by Claude Code

keywan-ghadami, 2026-11-23

Decision (owner, 2026-11-23): option A is built. The aim is that the prover proves every index of the program by itself, with an invariant written by hand only in rare cases. Leaving the three sites checked is refused.

Where #1890 stands among the open work: nikaia check --bounds over packages/logic on 1c580ed6b reports 1353 indexes, 624 proved. Of the 729 unproved indexes, 173 stop at “a value read out of a list, of which the walk knows no fact”: 133 elements of a named list (ADR-306 D7, D21), 20 elements of a call’s result (D24), 20 other reads. This is the largest class with one cause. heap[place[v]] is its hardest case, because only the coupling of two lists proves it.

To build, in this order

  1. Survey. Sort the 133 element-of-a-named-list index sites of packages/logic by the rule that would prove each one: (a) the elements of Y stay in 0..X.len(), and the rule is inductive (X only grows, or every write to Y is checked against X.len()); (b) the same with -1 allowed, read after a >= 0 test; (c) a permutation pair X[Y[v]] == v and Y[X[p]] == p (heap and place, index maps); (d) something else, named. Each site gets file and line. The table goes into the report and into docs/solver-workload.md.
  2. Found element rules (a) and (b) (ADR-306 D21), for the sites the survey finds, with a test per kind. This includes Found rule: a list of positions whose non-negative elements … (#1718) where it is inductive.
  3. Array terms in the prover (prover_arena.nika: a read X[t] as a term, and the rule that two reads of the same list at equal indices are equal), then the permutation-pair rule (c), with the loop invariants over the sift loops of heap_up and heap_down. This proves sv_sat.nika 960, 967 and 971, and unblocks “bounds: an index taken from another list’s element” (#1668). Step 3 starts with its own design text (an ADR on array terms), which the supervisor writes before the build.

Steps 1 and 2 are a builder run each; step 3 is split once its ADR stands.

Done when: the survey’s table is in docs/solver-workload.md, every site of kinds (a) and (b) is proved, and sv_sat.nika 960, 967 and 971 are proved.


Generated by Claude Code

Back to Open Issues