Which witnesses may change at a recursive call?
In the flag program, a recursive call can use key zero at both flag values. If its result reaches the guard, the flag and the result must both be one. At that observation the call can also use key \(n\), and the package at \(n\) rules out one. Add a quantified \(j\) to the input predicate with \(j=k\). The caller can instantiate \(j=0\) at its first typing and \(j=n\) at its second. InvarGenT used to freeze \(j\) at zero. It now accepts this declaration with an iteration budget of two. The same holds for \(2j=k\), for \(j\le k\le j+1\), and for \(j=\max(k,1-k)\). All four export the original domain and result relation. Runnable inequality example · Earlier failure · Compiler and signature checks
The domain at a tuple of arrow coordinates
Fix the nonnumeric shape of the recursive arrow. Write \(p(a)\) for the tuple of all its numeric positions in the inferred scheme, including the arguments of the returned existential type constructor. Let \(D(a)\) be its inferred admission predicate. Use \(q(b),E(b)\) for the corresponding written scheme. The assignments \(a,b\) range over their own quantified indices. Any free indices keep their surrounding values. Bind a proposed second typing to a tuple \(z\) of concrete coordinate values. Its exact numeric admission test is
\[ A(z) = (\exists a.\ D(a)\land p(a)=z) \land (\exists b.\ E(b)\land q(b)=z). \]
Proof. Each legal instantiation gives the values of the variables bound by its scheme, and matching the arrow gives the tuple equations. Conversely the two witnesses instantiate both schemes with the same numeric arrow. At a fixed tuple the existential type constructor supplies the same package predicate. Each opening of that package may still choose its own private result witnesses. If \(a_1+a_2\) occupies one arrow position, only the sum is fixed by that position. If \(a_1\) also occurs in another position, the same \(a_1\) must satisfy both equations. Tuple compatibility lemma
A third runtime argument makes the distinction observable. Give it type \(\mathrm{Num}(j+m)\) and require \(j=k\), \(0\le m\) and \(n\le j+m\). If the argument value is \(t\), the new witnesses are \(j=k\) and \(m=t-k\). Every key in \([0,n]\) remains available when \(n\le t\). At \(n=t=4\), changing the key from zero to four changes the decomposition of the same argument from \((0,4)\) to \((4,0)\). InvarGenT accepts with budget two and exports precisely the extra condition \(n\le t\). Compound-coordinate program · Exported-domain check
At a call, \(z\) comes from the written arrow with the selected key replaced by the probe expression. The compiler binds bare quantified coordinates directly to tuple positions and eliminates the remaining quantified variables. It projects the inferred and written schemes separately. Suppose the intersection is a union of cells \(A_c(z)\). Opening a package with postcondition \(P\) wherever the key is legal amounts to imposing \(A_c(z)\Rightarrow\exists w.\ P(z,r,w)\) for every cell. A particular probe may have no admitted cell at the observed result. Checking a mandatory endpoint instead requires the premise to entail the union of its cells. This distinction also applies to keys licensed in successive rounds. Adding the hidden strip \(j\le k\le j+1\) to the fixed-endpoint and staged examples preserves both exported signatures. Conditional opening lemma · Guard countermodel · Staged admissions
Projecting rational indices
In each linear case solve the equalities with hidden coordinates first. For a remaining hidden coordinate \(h\), write its inequalities as lower bounds \(L_i\le h\) and upper bounds \(h\le U_j\). Eliminating \(h\) leaves every pair \(L_i\le U_j\). For any assignment satisfying the pairs, choose the greatest lower bound in the finite list, or the least upper bound if there are only upper bounds. With neither, choose zero. This constructs a rational witness. Reversing the pivot order extends a solution of the retained rows to a solution of the whole case. A numeric type index can be fractional even when the observed OCaml result is an integer. Formal one-pivot proof, including empty bound lists
An extremum involving a remaining hidden variable splits into its two linear alternatives. An extremum that becomes public after an equality substitution can stay as a single atom. For instance, projecting \(j=k\) together with \(\min(j+1-n,n+1-j)\le0\) leaves \(k\le n-1\lor n+1\le k\). The hole at \(n\) survives. The numeric regression tests include shared-coordinate equations, one-sided bounds, incompatible bounds and a fractional witness. In a compiler control the base returns one, so the inferred key domain excludes \(n\). Adding \(j=k\) preserves rejection of the reachable Boolean arm. Its numeric counterpart executes with the narrowed domain. A separate driver compared the returned formulas with Z3’s existential arithmetic over the reals at every visible valuation for 1,280 generated problems, including 640 with fractional coefficients. Projection driver · Equivalence check
Admission replay happens after candidate inference. On \(j\le k\le j+1\), fixing replay alone still missed the two-pass budget. For this declaration the abducer can use the projected domain immediately. The compiler now does so on a retyping attempt when it can express the projection as one scheme predicate. It checks the candidate against the original declaration as well as the exported scheme. Inequality example
How many cells can be needed?
Introduce \(m\) private digits \(b_i\) with \(0\le b_i\le2\) and \(\min(b_i,2-b_i)\le0\). Each digit is zero or two. Starting with \(s_0=0\), require \(s_{i+1}=3s_i+b_i\) and expose only \(k=s_m\). The lifted description uses \(O(m)\) atoms and coefficients of constant size. Its projection has exactly \(2^m\) values. Reading the last digit modulo three and dividing out that digit recovers the entire sequence at fixed length.
Every legal value is even. An interval containing two legal values also contains the odd integer immediately above the smaller one. Thus an exact union of convex cells needs at least \(2^m\) cells, and singleton cells attain the bound. This holds for either rational or integral visible coordinates. The bound concerns an explicit convex-cell representation. With one digit the compiler keeps the public disjunction in one cell. At lengths two through five, the projection driver returns 4, 8, 16 and 32 singleton cells. The historical replay checks every singleton and the union against the digit set. A later projection repair leaves the final disjunction inside each branch. At the same lengths it returns 2, 4, 8 and 16 cells with two legal values apiece. Injectivity and the one-code-per-interval theorem · Keeping public disjunctions during projection
Two visible coordinates that must move together
Now retain \(j=k\) and add \(r\le j+2\) to the result
package. The condition follows from the other bounds at every legal key.
Its presence puts \(j\) in the written
package’s parameter tuple. At \(f=1\),
\(n\ge2\), the ordinary typing \((k,j)=(0,0)\) permits result one. Changing
only \(k\) or only \(j\) leaves zero as the sole admitted pair
reachable from that typing. The simultaneous change to \((n,n)\) is legal, and the package there
excludes one. This gives a complete guard proof using one additional
typing. Revision e3b1348 rejected the Boolean guarded arm
at budgets two and 10,000. The subsequent tuple checker accepts it with
budget two. Repair Keeping the
extra package parameter and replacing that arm by numeric zero compiles
and runs. Supplying the stronger result predicate \(r=0\) also lets the original Boolean arm
check at budget two. The diagonal obstruction applies to what these
scalar retypings can derive from the given package. Executable variants · Proof for every width
For \(d\) visible coordinates required to be equal, even a sequence of legal moves changing at most \(d-1\) coordinates at a time cannot leave the original diagonal point. Every move retains one coordinate, whose value determines all the others. Moving all \(d\) together reaches any other admitted diagonal point. This gives a lower bound on the number of coordinates a single retyping must be able to change, independently of how many scalar probes the checker tries. Diagonal lemma
Here the coordinate count depends on the presentation of the scheme. Substitute \(k\) for \(j\) throughout the package and remove the equation \(j=k\). The original Boolean arm then checks with budget two, and the public signature matches the two-coordinate numeric control. More generally, if the domain entails \(j=g(k)\), substituting \(g(k)\) in both the domain and every arrow position preserves the set of observable typings. In the presence of an explicit graph equation its witness is \(j=g(k)\) in the reverse direction. Such equations can generate a vector of candidate keys from one scalar target. The admission proof already accepts a tuple \(z\). Evaluating every changed coordinate at the proposed target and checking \(A(z)\) licenses the new package opening on the same runtime result. Substitution lemma · Source-level replay
The convergence counterexample for Table 4.4 still applies. On the
capped climb the original common-atom jump loses the upper bound on
every pass from pass 8 onward. The consumer restores it each time. A
stored solution with two inequalities suffices for the cycle. With
InvarGenT revision e3b1348, budget 8 fails and budget 9
accepts the band from \(m\) to \(m+20\). The hidden-witness examples concern
what can be certified before the jump. Induction-jump recurrence and
original trace · Current
pass-9 trace
The OCaml 5.3 compatibility suite passed all 362 active tests, with ten existing TODOs. All 185 prior example signatures matched byte for byte. The compiler and arithmetic replays used OCaml 5.5.1.
Run Lean 4.19 on thesis-review-38.lean. With Python’s
z3-solver and OCaml installed, run
python3 thesis-review-38.py /path/to/InvarGenT.native. The
optional --before takes revision be8af94. For
--numeric-driver, copy the linked OCaml driver to
src/ProjectionOracle.ml and build its native target
alongside InvarGenT.