A complete combination theorem and the convergence of predicate inference
A complete abducer for each sort does not make Table 4.1 complete, even if every branch has a witness. The missing information is a type equation whose only purpose is to connect the premises to a numeric conclusion. A corrected combination algorithm can synthesize such equations and still send every logical query to a single-sort solver. For the predicate iteration there is a different answer. A solution bounds the number of strict refinements along a covered chain of free-term predicates. Two linear inequalities already give an arithmetic solution for which exact one-step refinement continues forever. Thesis, §§4.2 and 4.5 · First thesis review
1. A replacement for Theorem 4.5
Why fixing dead branches is insufficient
Take \(\exists u_{\mathrm{type}}\,\exists n_{\mathrm{num}}\) and two implications \[ u=\mathrm{Num}(0)\Rightarrow n=0,\qquad u=\mathrm{Num}(1)\Rightarrow n=1 . \] Assume \(0\ne 1\). The answer \(u=\mathrm{Num}(n)\) is valid and activates both branches. It explains their conclusions by constructor injectivity.
The type-only problem in Table 4.1 has two satisfiable premises and two empty conclusions. A correct, Definition 4.4-complete component may return just \(\top\), which covers every type-only answer. The table then obtains no index equation from either premise, since \(u=\mathrm{Num}(r_i)\) binds only a type variable. The arithmetic solver receives \(\top\Rightarrow n=0\) and \(\top\Rightarrow n=1\). Any one valuation witnessing strict consistency would have to satisfy both conclusions. There is no such answer. This example has no dead code, designated variables, or quantifier alternation. A final soundness filter cannot recover the missing candidate. Definitions 4.1 and 4.4 · Table 4.1 · Lean counterexample
The theorem and the interface
Theorem 4.5R (strict JCA). Take the thesis model of finite free constructor types with leaves in inhabited side sorts. Side functions and predicates are single-sorted. Type atoms are equations. Work with finitely many sorts per problem and candidate. Assume the finite syntax and legal witness terms are effectively enumerable, scope comparisons are effective, and each side sort has a correct and complete JCAQP enumerator in the sense of Definition 4.4. The algorithm below enumerates a correct and complete sequence of mixed answers for arbitrary finite prefixes, conjunctions, and designated sets. Indeed, every admissible written presentation is emitted up to renaming and reordering of conjuncts by the exhaustive version. The domains may be infinite or uncountable. The enumeration concerns terms expressible in the language, including its chosen encoding of literals. The procedure may run forever on a problem with no answers. Model in Appendix A.1.1
Write the raw answer as \(\exists B.\,(H\land\bigwedge_s L_s)\), where \(H\) contains its type equations, including the side expressions at their leaves. Fix the fresh names \(B\), the designated names \(K\) tested for escape, and one simultaneous tuple of witness terms \(\sigma\) for the names substituted in validity. Definition 4.1 substitutes the new and specified parameter names. Prior parameters or a restriction on the variables a witness may read can be recorded here too. Type-check each term and check its permitted reads. For validity use the actual prefix and the actual simultaneous substitution. Close any remaining free inputs according to the chosen convention. For the original weak escape rule, an open atom tested by \(\mathcal M\models Q.c\) has its remaining free variables universally closed. Ordinary relevance and branch consistency always see the unsubstituted answer. In particular, a variable that appears inside a replacement keeps its original meaning under simultaneous substitution. Thesis source, §4.2.1 · Parameter conventions
The outer enumeration guesses \(B,H,\sigma\) by increasing finite encoding length, up to consistent renaming. It retains the written \(H\) for escape and for the eventual output. For fixed \(B,H,\sigma\), each sort enumerates its part \(L_s\) independently, sharing only the fixed names. The rest of the proof specifies exactly what those independent searches must certify.
Ordinary branch witnesses and entailment
For branch \(i\), solve \(H\land D_i^{\rm type}\) together by finite-tree unification. Decompose equal constructors and collect equalities when two side arguments meet. Treat side expressions as opaque values at this step. A structural clash or occurs-check failure rejects this choice of \(H\) under strict consistency. Otherwise the result is an acyclic substitution for type variables, with arbitrary residual type holes, and some side equalities. Let \(G_{is}\) consist of these equalities of sort \(s\) and the original side premises of that sort.
Apply the same substitution to both sides of each type conclusion. Cancel identical holes, descend through matching constructors, and put every comparison of two side arguments into a list \(J_{is}\). Add the original side conclusions. A clash of constructor heads, two distinct residual holes, or a residual hole opposite a constructor makes relevance impossible for a live branch. Indeed, fix a feasible side valuation. The residual holes can still take arbitrary ground types. Different holes can be assigned different values, and a hole can receive a different root from the constructor it faces. This last argument also handles a hole compared with a term containing that hole.
The exact obligations on \(L_s\) are \[ \operatorname{sat}_s(G_{is}\land L_s),\qquad \mathcal M_s\models(G_{is}\land L_s)\Rightarrow J_{is} \quad\text{for every }i. \] For sufficiency, combine the local consistency rows for the same branch, then ground the residual type holes and evaluate the solved substitution. That constructs one mixed row. For relevance, constructor injectivity and the local entailments give every original conclusion on every such row. For necessity, project a mixed consistency row. Any local counterexample to entailment could be combined with the feasible rows of the other sorts and extended through the solved substitution. It would falsify a mixed conclusion. The witnesses for two different branches may differ. This is where strict consistency licenses the reverse implication.
Prefix witnesses at the right move
It remains to decide a positive mixed game \(\Pi.(E\land\bigwedge_s P_s)\). For answer validity, \(E=H\sigma\) and \(P_s=L_s\sigma\). The same construction tests a raw atom for the weak escape rule. Solve \(E\) as above and write \(p_x\) for the fully expanded pattern of every type coordinate \(x\) in \(\Pi\), including unconstrained coordinates. Each pattern consists of constructors, residual type holes, and maximal side expressions. Retain the side equalities from solving \(E\).
- Scan the prefix from left to right. For a universal type coordinate \(u\), require that \(p_u\) be a bare residual hole occurring in no preceding type coordinate pattern. Otherwise reject.
- For each existential type move \(x\) and every occurrence of a side expression \(e:s\) at an address of \(p_x\), introduce a new existential side move \(c_{x,e}\) at the position of \(x\) and require \(c_{x,e}=e\) in the final matrix. Use a distinct name per occurrence, including across different moves. Two equal occurrences will agree whenever the final equalities require it.
- Erase the type moves. For each \(s\), retain the original side moves of sort \(s\) and the new moves of that sort in their inherited order. Call the resulting prefix \(\Pi_s\). Its matrix consists of \(P_s\), the side equalities from solving \(E\), and the leaf equalities just added. With \(V_s\) denoting the last two groups, the test is \(\mathcal M_s\models\Pi_s.(P_s\land V_s)\) for each \(s\).
Compatibility lemma. The mixed game is true exactly when the structural test and all the side games succeed.
From the mixed game to the components. A universal type with a fixed constructor head can choose a different root. If an earlier type contains the universal’s bare hole at an address, its earlier value fixes the subtree there. The universal can choose a different value. These facts prove step 1. Now run a winning mixed strategy. At an existential type move the strategy has already chosen a whole tree. Every winning continuation has the prescribed pattern there, hence each exposed side address already contains a definite value. Play that value for its new existential move. This produces the leaf equalities on every play. To extract the strategy for one sort, fix the universal moves of all other sorts, including the type sort, to arbitrary inhabitants and simulate the original strategy. All choices on this simulation respect the retained order.
From the components to the mixed game. Interleave the winning side strategies, each reading its own history. Associate the bare hole of each universal type with the actual value played there. Give every other residual type hole one fixed ground type. At an existential type coordinate build \(p_x\) using those values for holes and the newly chosen \(c_{x,e}\) at side addresses. Step 1 guarantees that every universal type needed in this construction has already been played. At the end each frozen value equals the final evaluation of its side expression. The completed tuple therefore has the solved patterns and satisfies all induced equalities, hence \(E\) and all \(P_s\). This constructs the compatible mixed strategy. No strategy has been assumed to be a syntactic witness term: the required finite terms were already fixed in \(\sigma\). One-constructor freezing lemma · Lean proof of independent prefix interleaving
The argument uses two possible type roots, as supplied by the thesis’s arrow constructor and a ground type with another root. There is also a degenerate case. In an inhabited finite-tree algebra with just one productive constructor, that constructor has no recursive type argument: otherwise no finite tree could bottom out. Its type carrier is exactly the product of its side argument carriers, including the empty product for a single constant. Expand every type move into that tuple at its original position and decompose equality componentwise. Apply this after fixing the explicit witnesses and retain the original spelling for escape. This also covers a type carrier with only one element.
For example, in \(\exists x_{\rm type}\,\forall h_{\rm num}\,\exists v_{\rm num}.\ x=\mathrm{Num}(v)\land v=h\), the side game begins \(\exists c\,\forall h\,\exists v\). It requires \(c=v=h\) and fails. Moving \(x\) to the right of \(h\) changes the result. Projections that retain only the final side equations miss precisely this difference.
Escape, the component calls, and coverage
Test each original answer atom \(c\) separately. Under the weak rule, if the syntactic order test fails on an atom mentioning a designated name, the remaining way to admit that atom is \(\mathcal M\models Q.c\). Use the positive-game compiler on this unsubstituted atom. Under the strong rule on designated heads, apply its syntactic check directly. If the declared answer language requires a substitution presentation, verify that format too. Solving equations, exposing leaves, or substituting \(\sigma\) must never change the input to the escape check. This allows e.g. an arbitrary conjunction in the weak version even if its most general unifier has different variable occurrences.
For fixed \(H,B,\sigma\), the structural checks on type atoms and their escape tests are shared by all choices of \(L_s\). Each side enumerates the \(L_s\) passing its ordinary branch tests, its prefix test, and the escape tests for its own written atoms. All are positive tests on the side solver. Two elementary uses of a Definition 4.4 component suffice:
- To recognize truth of a closed \(\pi.F\) with a conjunctive matrix, run the abducer with no designated parameters on \(\pi:(\top\Rightarrow F)\), waiting for any output. If \(\pi.F\) holds, \(F\) is itself an answer: a winning strategy has at least one play in inhabited sorts. Conversely, validity of an emitted answer and its relevance imply \(\pi.F\). This is Proposition 4.2 in the parameter-free case.
- To recognize \(\operatorname{sat}(G)\land(G\models J)\), run the component on \(\forall\operatorname{FV}(G,J):(G\Rightarrow J)\) with no designated names. If the tests hold, \(\top\) qualifies. Conversely, each public row has an extension satisfying any emitted answer, by its all-universal validity (instantiate the fresh witness terms). Relevance gives \(G\models J\) and consistency supplies a row for \(G\). Use \(G=G_{is}\land L_s\) here.
Dovetail the finite obligations, all candidate strings, and the finite-sort Cartesian product of the successful streams. An unsuccessful candidate or an empty stream never blocks another. The algorithm needs no global validity oracle and no test that an enumerator has finished.
Proof of Theorem 4.5R. Every emitted combination passes ordinary consistency and relevance by the branch lemma, prefix validity for the same witness tuple by compatibility, and the escape tests on its actual syntax. Conversely take any Definition 4.1 answer and one of its legal witness tuples. Rename the fresh names, take its written type equations for \(H\), and take its written side atoms for each \(L_s\). The reverse directions of the two lemmas imply all its obligations. Each positive component test eventually emits a witness, even if the component returns only a covering answer. Fair scheduling therefore emits the original atoms up to renaming and order. The inverse renaming of fresh variables is the instantiating tuple required by Definition 4.4. It works simultaneously across all factors because their shared names were fixed at the outer enumeration. This establishes coverage, including for designated parameters and presentations with redundant equations.
Corollary (plug-ins that synthesize generalizations). An optimized side plug-in need only cover the feasible \(L_s\) at a fixed interface. Give the input interface names, including the names shared with \(H\) and \(\sigma\), rigid status for the coverage comparison. Permit an output \(L'_s\) to introduce private fresh names \(Z_s\), disjoint across sorts. It must pass the same local checks with legal validity witnesses extending the fixed \(\sigma\) on its original domain. For each admissible \(L_s\), require a local output and terms \(\theta_s\) for \(Z_s\) such that \[ \mathcal M_s\models L_s\Rightarrow L'_s[Z_s:=\theta_s] \] with every original interface name fixed. These terms may use the original side coordinates and parameters. Then the product of these smaller output streams is sound and Definition 4.4-complete. For soundness, unite the disjoint private validity-witness tuples and apply the prefix lemma. For coverage, alpha-rename the shared fresh names once, then unite the \(\theta_s\); their domains are disjoint and substitution fixes \(H\). Conjoining the local implications gives the required term-instantiated implication for the whole mixed answer. The tuple \(\sigma\) establishes a prefix game for an answer. The tuple \(\theta\) compares a target with an emitted answer on ordinary rows. The exhaustive component above realizes the stronger interface contract with \(Z_s\) empty. A faster component can replace it once it proves this contract. Ordinary component completeness that allows each side to reinstantiate a shared name independently gives no such gluing proof.
For example, a side generator treating \(z\) as private could cover \(\top\) with \(z=0\) using the constant witness \(0\). If the shared type equation is \(u=\mathrm{Num}(z)\), that substitution also changes the type pattern. A target row with \(u=\mathrm{Num}(1)\) has no extension to the new answer. Even one side sort needs the rigid-interface clause.
The algorithm changes the generator in an essential way. It explores type connections that a maximally general answer to the pure type subproblem can discard. The example at the start rules out a completeness theorem for the old generator under its published plug-in contract. In an implementation the existing generator can keep priority, provided an exhaustive stream gets fair time if completeness is claimed.
2. When does the predicate iteration converge?
Undecidability leaves room for a procedure that finds every existing solution and runs forever on some negative instances. It also leaves room for a decision on a class with a known bound on certificates. What it excludes is a terminating, correct and complete decision for all Milner–Mycroft programs. In particular, if certificates are finitely encoded and decidably checkable, there cannot be a computable input-size bound on the shortest certificate of every positive instance of that undecidable problem. Enumerating all strings up to the bound would decide it. Henglein, Type Inference with Polymorphic Recursion
A two-inequality solution with infinitely many strict refinements
Consider this ordinary recursive program, in the syntax accepted by InvarGenT.
let rec drift x d =
assert num x <= 0;
drift (x + d) dThe invariant obligations on the numeric inputs are \(I(x,d)\Rightarrow x\le0\) and \(I(x,d)\Rightarrow I(x+d,d)\). Both branches are live, for instance at \((0,0)\). Starting with the first safety check, put \(P_0(x,d)=(x\le0)\) and take the exact weakest one-step precondition \[ P_{k+1}(x,d)=(x\le0)\land P_k(x+d,d). \] Induction gives \(P_k=\bigwedge_{j=0}^k(x+jd\le0)\). At \((-k,1)\), \(P_k\) holds and \(P_{k+1}\) fails. Every step is strict. The intersection is exactly \(x\le0\land d\le0\), over integers, rationals, or reals. A positive \(d\) eventually crosses zero, and a nonpositive \(d\) preserves the first inequality. This is the greatest inductive precondition. Its size is constant. Lean proof over integers
A run of the checkout inferred \(\forall k,n,a\,[k\le0\land n\le0].\ \mathrm{Num}(k)\to\mathrm{Num}(n)\to a\) directly. The postulated divergence is a theorem about the weakest one-step policy; this actual inference succeeded. Thus a polynomial bound even on the full target invariant cannot supply a finite bound for that policy. Conversely, divergence of the weakest choice says nothing against a solver that guesses an inductive strengthening and verifies it.
The calculation gives an exact acceleration for a family. Suppose a transition is \(x'=x+d,\ d'=d\), with a conjunction of affine guards \(Mx\le b\) and constant \(M,b\). The greatest invariant maintaining those guards is \[ Mx\le b\quad\land\quad Md\le0 . \] Indeed \(M(x+jd)=Mx+jMd\) for every natural \(j\). Each positive component of \(Md\) eventually violates its guard. Each nonpositive component preserves it. This derives a candidate in one step and gives the two entailments a checker can replay on the original transition.
A positive convergence theorem for free-term predicates
Represent each predicate by the ground instances of a tuple pattern on its fixed public coordinates. Include any free environment parameters among these coordinates. Local existential variables are holes. Satisfiable conjunctions of finite-tree equations admit exactly this representation after unification and projection. Compare interpretations extensionally, up to renaming of holes. The following theorem concerns positive instances along a chain that continues to cover a particular solution.
Finite-height theorem. Suppose a sequence of interpretations strengthens each component by inclusion, and predicate \(i\) retains a fixed ground instance \(g_i\) throughout. A strict change means that some component loses at least one ground tuple. There can be at most \(\sum_i |g_i|\) strict changes, counting nodes in unfolded trees. More sharply, if every component continues to cover a nonempty solution pattern \(P_i^*\), the bound is \[ \sum_i\bigl(\rho(P_i^*)-\rho(P_i^0)\bigr),\qquad \rho(P)=\#\text{node occurrences in the tuple}-\#\text{distinct holes}. \] Thus a polynomial bound on the expanded solution patterns gives a polynomial bound on strict changes, irrespective of the number of incomparable interpretations the search could try.
Proof. In a nontrivial free ground algebra, inclusion between two single tuple patterns is one-sided matching. A fixed-head mismatch can be separated by a choice of root. A mismatch at a repeated hole can be separated by a ground assignment distinguishing the two target subterms. Matching makes the smaller pattern a substitution instance of the larger. Build that substitution by expanding a hole into a constructor with distinct fresh argument holes, then identifying holes as required. Expanding a hole occurring \(m\ge1\) times with an \(a\)-ary constructor increases node count by \(ma\) and changes distinct-hole count by \(a-1\). The rank increases by \(ma-a+1\ge1\), including at \(a=0\). Identifying two distinct holes also increases rank by one. Renaming leaves rank unchanged. Hence strict inclusion increases rank. A ground instance has rank exactly its unfolded size. Summing across predicates proves the bounds. A one-element carrier has no strict nonempty refinements. One-sided matching and coverage · Rank arithmetic
The encoding matters in the question about polynomial size. The equations \(t_0=a,\ t_{i+1}=f(t_i,t_i)\) present the tree \(t_n\) with \(O(n)\) bindings. Its unfolded tree has \(2^{n+1}-1\) nodes. Starting from a single hole, expose one constructor or constant of this tree per step, always using fresh holes for children. This gives \(2^{n+1}-1\) strict refinements covering the same compact target. It is an example of the possible height; a solver can jump straight to the target. A polynomial bound on the encoded equations still gives a finite bound through unfolding. It does not give a polynomial height by this argument. An empty target needs separate treatment: all patterns \(f^k(z)\) cover the empty relation and form an infinite strict chain.
Connection with Theorems 4.15–4.16. In the unary case the proof of 4.16 uses the update \(F_\chi^{k+1}=F_\chi^k\land A^\chi\). On a branch of that iteration where the public projected relations are nested and continue to contain a solution row for each predicate, the height theorem gives finite semantic stabilization in the pure free-term domain. This is a statement about the stated branch. It does not bound a search for that branch, repeated presentations of one relation, or the duration of a component abduction call. Table 4.4 also has transient phases, residual obligations, and a separate test for binary postconditions. Table 4.4 and Theorems 4.15–4.16
The Appendix A.4 proof of the covering chain invokes Axiom A.18. That axiom requires a conjunction interpolant on the shared free variables. In the plain free-equation language, take \(x=f(z)\Rightarrow x\ne a\). A conjunction on \(x\) alone true of every \(f(z)\) consists of identities. Substituting \(f(z)\) for \(x\) with \(z\) fresh identifies no two distinct terms in \(x\). Such a conjunction also holds at \(a\). An existential interpolant \(\exists z.\,x=f(z)\) would work in a larger interpolant language. This is a reason to give a convergence theorem whose proof of target preservation is independent of that axiom. Axiom A.18 and Lemma A.19
A semantic iteration with a finite successful path. Fix the generated branch system before instantiating predicates, a reachability policy, and a fixed public interface for each predicate. At state \(S\), a successor \((J,A)\) consists of a componentwise strengthening \(J\subseteq S\) and a residual with its validity witnesses. Check relevance with \(J\) in every premise and \(S\) in every conclusion. Check the required guard witnesses using \(J\) and \(A\), and check residual validity under the original prefix. A negative head is \(\bot\). These tests use exactly the source branches being claimed by the result. Predicate-local existential variables are independently fresh at each occurrence.
If \((I,A^*)\) is a solution covered by \(S\), \((I,A^*)\) is a legal successor. Substituting \(I\) in the premises gives the actual solution guards. Replacing the conclusions’ positive \(I\) occurrences by supersets preserves entailment. Guard consistency and residual validity are precisely the target’s own obligations. Consequently the semantic rule always offers a target-preserving successor. If a successful step has \(J=S\) extensionally, the verified residual and \(S\) already satisfy the original problem. At a strict step the rank increases. On any continued target-preserving choice with nonempty free-term components, there is therefore a successful stationary step within the height bound plus one, counting the final check. The existence assertion also follows by choosing the target and then reusing it. The rank bound controls every strict choice still covering that target. An effective search can dovetail candidate successors and paths instead of assuming the desired choices are known.
This rule supports both unary and binary predicates when their interpretations are finite-tree tuple patterns and the stated positive/negative occurrence condition holds. It is a replacement transition with explicit obligations. For the actual arithmetic updates of Table 4.4, a recursive caller can restore the same valid upper bound after every induction jump. The empty-demand stopping condition then fails indefinitely. Binary update and observed run
What a polynomial bound buys without monotone iteration
Fix a finite bit encoding and a known bound \(b=p(|\Phi|)\). Count the whole proposed solution: all predicate bodies, their binding interfaces and fresh names, the residual, and any syntactic witnesses whose existence cannot otherwise be decided. Encode variable indices, coefficients and DAG references in bits. There are at most \(2^{b+1}-1\) strings. For a decidable verifier, enumerate and check them, or run this search alongside the ordinary solver. This terminates and decides whether a solution of the specified size exists, for unary and binary predicates alike. A negative result excludes bounded certificates. On the promise that a positive input has such a certificate, it decides the original question. The bound gives neither polynomial verification time nor polynomial overall search time.
Here is a verifier for the branch language used above, with free finite types and decidable first-order side theories such as rational linear arithmetic. Substitute each proposed existential-conjunctive predicate body into each original occurrence, renaming its bound variables apart. Residual prefix validity with fixed syntactic witnesses is the positive mixed game from §1. Guard liveness reduces to existential satisfiability by joint unification. For relevance the additional case is a clause \[ \forall v.\ L(v)\Rightarrow\exists w.\,R(v,w) \] with conjunctive \(L,R\). Local witnesses of a predicate in a premise can be universally quantified here, since they are fresh for the conclusion. Solve the type equations of \(L\) first. If its side guards have no joint valuation the clause holds vacuously. Otherwise apply its type substitution to \(R\). The antecedent now ranges over independent arbitrary residual type holes and side inputs subject only to the feasible side guards \(G_s\). Put those residual holes in a universal block and the new conclusion variables in a trailing existential block. Use the structural test of §1 on the conclusion. Its failures can be exposed at any feasible side input. With all universal inputs before the new existentials, the remaining tests in each sort have the form \(\forall v_s.\,G_s(v_s)\Rightarrow\exists w_s.\,R_s(v_s,w_s)\), including any frozen side leaves among the existential variables. These independent tests combine on feasible guards by the same projection and extension argument as in §1. An explicitly false conclusion is checked by infeasibility of the antecedent. Thus the bounded search uses a decidable verifier in the advertised setting. For a general plug-in supplying only the positive semidecisions of Theorem 4.5R, exhaustion of bounded strings is insufficient to certify rejection.
If the bound covers only the written answer, there is a further distinction. In the pure free-term fragment with unrestricted reads for the thesis’s substituted fresh names, put those names in a trailing existential block for the validity check. A winning solved pattern yields explicit finite term witnesses by copying its bare universal coordinates and grounding remaining holes. Here bounded written bodies and residual suffice without a separate term-size promise. In a side theory, \(\forall h\,\exists w.\ (w\ge h\land w\ge-h)\) is true over the rationals, yet no affine term in \(h\) witnesses it for all \(h\). Hence a semantic trailing quantifier cannot in general replace the syntax of the admissible witness. For a fixed bound on bodies alone one can still dovetail the syntactic witnesses and find a bounded-body positive answer when one exists. A terminating negative decision needs a witness bound or a decision procedure for their synthesis. Original witness conventions
3. What would an InvarGenT implementation certify?
The practical question is which facts the checker may assume
when it accepts an inferred type. The abducer can guess a
stronger invariant, including the one for drift. Its
acceptance should have a justification that survives changing the search
order or hitting an iteration limit. Four cases clarify what is already
there and where the theory changes the implementation.
| Operation | What the checkout does | What would certify the result |
|---|---|---|
| Pass type information to arithmetic | combine_sbs unifies the premise and candidate before
computing the conclusion residual. This exposes equalities such as \(n=m\) from \(u=\mathrm{Num}(n)=\mathrm{Num}(m)\). |
Keep that operation for ordinary branch entailment. For a quantified validity check also record when indices become fixed. \(\exists x\,\forall h.\,x=\mathrm{Num}(h)\) must fail. Call site |
| Accept an inferred recursive scheme | The loop checks atom membership in successive formulas, flags for
outstanding work, and an iteration limit. Its ordinary result on
drift is the exact invariant above. |
Reinsert the candidate into the original obligations. For
drift that means proving \(I(x,d)\Rightarrow x\le0\) and \(I(x,d)\Rightarrow I(x+d,d)\). Both are
elementary arithmetic. This can certify a guess before a prescribed
number of rounds. A timeout remains evidence about the search. Loop
test · Atom
membership |
| Check dead code after simplification | Min/max expansion can split one source guard into several normalized premises. The dead-code flags approximate which contradictions to report. | Keep a source-case identity. Relevance must hold on every alternative. A positive source case remains feasible if at least one alternative has a witness under the answer. This makes the chosen source-level reachability policy checkable. Normalization lemma · Flag definitions |
| Accept a negative assertion | In the final assert false pass, the same
try … with Contradiction _ -> () surrounds both the
satisfiability test and the deliberate rejection when it succeeds. That
handler swallows both outcomes. Earlier iterations have a separate check
that raises NoAnswer. |
Instantiate the final predicates and residual in the scope of the original guard. Accept the negative obligation only if their conjunction is unsatisfiable. Distinguish a solver contradiction from a reachable-branch diagnostic. The observed control flow establishes a gap in this final pass; it does not establish acceptance of an erroneous program by the entire solver. Final pass · Earlier check |
For a regression test of the final negative check, use guard \(n=0\). A residual \(n=1\) rules the branch out. A residual \(n=0\) leaves it reachable. The distinction requires checking the final residual together with the guard and handling the two satisfiability outcomes separately.
Constructor invariants are a distinct language-design choice. To make
the short append infer its unrestricted signature, the
checker needs permission to assume \(0\le
n\) for a value of \(\mathrm{List}(a,n)\). The constructor
checks justify it by induction on values. The assertion does not hold of
every syntactic type index. A conservative route for closed datatypes is
to validate a proposed summary against each constructor and make it
available at the value binding. An external producer of that datatype
would need to respect the same specification. This is the remaining
change to the typing rules, as opposed to validating solutions for the
existing rules. Indexed
append and its derivation
Checks and scope. The reference compiler compares 3,500 mixed
prefix games, 3,500 strict branch judgments and 3,500 implications with
existential head variables with independent direct semantics over a
complete finite free datatype with two side sorts. It includes the
lost-index example, reordered prefixes, and an explicit designated
substitution. It implements the equational kernel; the theorem treats
arbitrary pure side atoms through the component queries. The Lean companion checks the live-branch
counterexample, prefix interleaving, rank arithmetic, and strict descent
and the exact limit of drift over integers. The
unification, constructor reconstruction and coverage proofs are given
above. The source runs used InvarGenT revision 772b9b45
with -inform -no_ml -no_sig -no_verif in the OCaml 5.5
compatibility build described in the first review. These are research
results and a reference implementation. The production solver would
still need to implement the revised search or independently replay the
checks to claim these guarantees.