Issue #1929: Prover: a list a callee only grows keeps its index facts across the call (ADR-prover-found-facts-v1 D16)

Open and answer this issue on GitHub.

ready, bugs, queued · opened 2026-11-16 · updated 2026-11-29 · 0 comments

Filed by the driver from the Found: of the run of issue-1757 (#1757) (owner, 2026-11-06). Decided 2026-11-29 (supervisor): ADR-prover-found-facts-v1 D16 (00ccf2cc).

Found

sv_simplex.nika 883/884 (self.var_col[v], self.values[v] after let v = self.fractional(); if v < 0 { return }) stay checked. The cause is self.cut_check(...), a ref mut self call that only grows var_col (through new_var’s push), which drops the fact v < self.var_col.len().

Probe on develop d8fc849d, nikaia check --bounds m.nika:

struct Table {
    cells: Vec[i64],
}

impl Table {
    fn first_odd(ref self) -> i64 {
        let mut i = 0
        while i < self.cells.len() {
            if self.cells[i] % 2 != 0 {
                return i
            }
            i += 1
        }
        return -1
    }

    fn grow(ref mut self) {
        self.cells.push(1)
    }

    fn c(ref mut self) -> i64 {
        let r = self.first_odd()
        if r < 0 {
            return 0
        }
        self.grow()
        return self.cells[r]
    }
}

fn first_odd_of(xs: Vec[i64]) -> i64 {
    let mut i = 0
    while i < xs.len() {
        if xs[i] % 2 != 0 {
            return i
        }
        i += 1
    }
    return -1
}

fn grow(mut xs: Vec[i64]) {
    xs.push(1)
}

fn main() throws {
    let mut t = Table { cells: [2, 3] }
    println(t.c())
    let mut xs: Vec[i64] = [2, 3]
    let r = first_odd_of(xs)
    if r >= 0 {
        grow(xs)
        println(xs[r])
    }
}

The program prints 3 twice. The relevant lines of check --bounds:

    27  self.cells[r]  checked: no fact bounds what it reads - a counter, a loop, a length, or one list as long as another (#432, #383, #388)
    53  xs[r]          checked: no fact bounds what it reads - a counter, a loop, a length, or one list as long as another (#432, #383, #388)

Both should be proved, since the length only grows. Without the grow call both are proved.

Cause: the walk takes a call’s frame (ADR-prover-found-facts-v1 D12) and forgets every fact about a path in it, self.cells.len() included. No found postcondition says the length is at least what it was.

Decision

ADR-prover-found-facts-v1 D16: D8’s derivation, with a length the callee changes in the place of its result, finds a relation of that length after the call to the same length before it (len >= old, len == old + 1), proved at every return. After the call the walk takes the relation with the length it knew before, so r < old gives r < self.cells.len(). A recursive callee takes it as D4 does. A body that may shrink the list proves nothing, and the fact stays forgotten. Only found, never published (D14).

To build

Done when

The probe’s lines 27 and 53 are proved under check --bounds, the pop variant stays checked, and the test is green.


Generated by Claude Code

Back to Open Issues