Which observations can a recursive call use to choose its interval?
A recursive call must choose its package parameter before it sees the
returned value. It can already know the input state. In the new example,
the result at A is 1 and the result at B is 5.
A width-two interval containing that result must avoid \([2,4]\). At A the only
interval is \([-1,1]\). At
B it is \([5,7]\). The
state indices are 0 and 1, so the single affine expression \(6i-1\) makes both choices. InvarGenT checks
this witness and executes both recursive clients at budget 2. With the
same parameter left implicit, revision 311a5e4 rejects the
program at every outer budget. The following review fits the child key
from the two state indices and gives a three-state counterexample. Affine recovery and its limit Recursive source · Explicit witness and split-state
control
What a package boundary can tell abduction
First consider the earlier program whose recursive call always enters
B. Its base value is 6. Its result interval \([k,k+6]\) must contain 6 and avoid both
\([1,2]\) and \([10,11]\). To avoid the first band the
result must exceed 2. Indeed, its upper endpoint is at least 6, so the
comparison \(1\le r\) succeeds
somewhere in every admissible interval. To avoid the second band the
result must stay below 10, since its lower endpoint is at most 6.
Together the two requirements force \(k=3\). Previous counterexample
More generally, for \(w\ge0\) and every \(k\) with \(f\in[k,k+w]\), some opening satisfies \(l\le r\) exactly when \(l\le f\). For sufficiency use the upper endpoint. For necessity check \(k=f-w\). Dually, some opening satisfies \(r\le u\) at every legal key exactly when \(f\le u\). If the supplier value lies strictly outside a forbidden band, these tests identify which comparison a successful interval must falsify. If it lies inside the band, every admissible interval contains a bad value. Endpoint lemmas
InvarGenT now uses this observation when the ordinary guard search leaves several comparisons unresolved. It sets one declared package inequality at a time to equality, discards infeasible boundaries, and checks which comparisons hold throughout each remaining boundary. If one comparison survives as a candidate to falsify, the compiler proposes its integer complement as a positive goal. For a general package, a feasible boundary may exist at only some parameter values. The proposal therefore goes through the original full-package and final guard checks. A width-six package with endpoints 0 and 6 still rejects an assertion reached at 3. Compiler regressions and guard controls
This repair also covers a source arm that directly says
assert false. The original assertion stays in the
constraint system. After ordinary searches fail, the retry can use the
guard’s comparison to guide abduction and check the negative obligation
against the resulting solution. The width-six program now succeeds at
budget 2 with either form of the bad arms. Instrumenting the guards at
two recursive depths produces the expected six operand evaluations,
including with -keep_assert_false. Reversing the conjuncts
and moving the two forbidden bands to force the negative key \(-39\) at width 97 also succeed. Executable comparisons
When histories must share a key
Let a history \(h\) require a supplier value \(f_h\), a width \(w_h\ge0\), and avoidance of a finite collection of nonempty integer bands. The entire set of legal keys is the closed integer interval \([L_h,U_h]\), possibly empty. Start with \(L_h=f_h-w_h\) and \(U_h=f_h\). For each forbidden band \([l,u]\) ending below \(f_h\), raise \(L_h\) to at least \(u+1\). For every other band, lower \(U_h\) to at most \(l-w_h-1\). A band containing \(f_h\) crosses the two bounds. This also gives the greatest feasible key whenever one exists. Exact key interval
Write \(z(h)\) for the information available when the call chooses its parameter. A policy must pick the same key on all histories with the same observation. A policy exists exactly when \(L_h\le U_j\) for every ordered pair with \(z(h)=z(j)\). Thus one empty interval or two incompatible histories witness failure. This holds even for infinitely many histories. In a nonempty observation class, any one upper endpoint bounds all lower endpoints. A nonempty bounded-above set of integers attains its maximum. The pairwise inequalities put that maximum below every upper endpoint, so it serves the entire class. For finite input this constructs the policy by grouping the histories and taking their extrema. With infinitely many histories this proof establishes existence. An effective synthesis procedure needs a representation of the classes and their extrema. Uniform-choice theorem
A different requirement arises when the witness must be one integer-affine expression \(m x+c\) in an observed scalar \(x\). A slope \(m\) works exactly when \(m(x_j-x_h)\le U_j-L_h\) for every ordered pair. Subtract \(m x_h\) from each history’s two endpoints. The resulting intervals must share one intercept. For finite histories these inequalities give lower and upper bounds on the integer slope, with a direct compatibility check when two observations coincide. Any admissible slope and the largest adjusted lower endpoint supply a witness. Three observations can rule out a single affine expression even when every pair admits one. At \(x=0,1,2\), force keys \(0,1,0\) respectively using two forbidden bands per history. Each pair fits an integer line. The three values do not. Slope criterion and three-observation proof
What the failed update chose
In the recursive program the written arrow admits every interval containing \(4i+1\) at \(i\in\{0,1\}\). Let \(k\) be the current call’s parameter, \(j\) its child’s parameter, and \(r\) the opened result. Projecting each reported bad guard onto these four coordinates gives exactly
\[ i\in\{0,1\},\qquad k\le4i+1\le k+2,\qquad j=k,\qquad j\le r\le j+2,\qquad 2\le r\le4 . \]
The failed proposal passes the parent’s key to the child. At
A, \(k=j=1\) permits \(r=2\). At B, \(k=j=3\) permits \(r=4\). Z3 checked the projected formula in
both directions, over integers and over rationals. The Lean proof
verifies the replacement \(j=6i-1\) for
every admitted parent, including the call that uses that formula again
at the next depth. Moving the case split on A and
B before the recursive call also lets the compiler infer
both choices. Machine-checked policy
· Projection and executions
With budget 0 or 1, inference stops in the preceding definition of
base. For every budget of at least 2, that definition
finishes on pass 2. Two searches on run reach a finished
predicate update on pass 2 and fail their final guard checks. The other
attempted constraints retain a Boolean arm where the result must be
numeric. There is no later pass, induction jump, or producer-only replay
at the budget boundary on these paths. Complete traces agree at budgets
2, 3, 40 and 10,000 in each annotation mode. The remaining inference
problem is to choose a witness using an input that is already in scope.
Trace checks · Original infinite jump
recurrence
To reproduce the proofs with Lean 4.19, compile
thesis-review-27.lean to
thesis-review-27.olean in a temporary directory and include
it in LEAN_PATH when checking
thesis-review-28.lean. Run
python3 thesis-review-28.py /path/to/InvarGenT.native with
OCaml available. The optional --before takes revision
41750f0. The --trace option uses Python’s
z3-solver and compiler revision 311a5e4 built
with the four existing diagnostics. The OCaml 5.3 compatibility build
passed 334 active tests with 10 existing TODOs. All 169 previous example
signatures matched byte for byte. The source-level checks and traces
used the OCaml 5.5 compatibility build. Passes · Predicate interfaces · Jump and demand · Final guard