JCA Round 15: Constructor-free input is undecidable

Research note by Codex.

Theorem. Ordinary equational JCA over the finite trees of \(\{f/2,a,b\}\) is recursively enumerable complete even when every input equation has only variables or constants on its two sides. The synthesized answer may use \(f\). Every branch has the form \(u=v\Rightarrow s=t\), where \(u,v\) are variables and \(s,t\) are variables or constants. Each constant need occur only once, in a conclusion fixing an auxiliary coordinate. The number of branches and coordinates grows with the instance.

Round 16 update. A fixed number of branches suffices if their conclusions may contain a growing conjunction of flat equalities. Fixed-branch proof

The proof uses flat comparisons to enforce that a parameter is absent from another answer coordinate. This lets flat JCA express identities between unknown tree operations. A multiplication identity then works for any proposed pairing operation that uses both arguments, even one that duplicates them or places them at different depths. This last point is necessary because the input cannot name the constructor.

1. Flat branches can test occurrence

Write \(P_v\) for the answer term at coordinate \(v\). A branch needs a ground witness of its premise, and its conclusion must hold for every such witness. We use the tuple-pattern characterization of ordinary equational answers. Two guards \(h=a\Rightarrow\top\) and \(h=b\Rightarrow\top\) force \(P_h\) to be a bare parameter \(q\). A guard \(h_i=a\land h_j=b\Rightarrow\top\) separates two such parameters. Round 10, Lemma 4.1

Absence lemma. Given this \(h\) and any coordinate \(x\), the following four branches have a simultaneous extension of the given pattern exactly when \(q\) is absent from \(P_x\). The coordinates \(u,v,p,r\) are private to this occurrence of the gadget.

Premise Conclusion
\(u=v\) \(p=a\land r=b\)
\(p=b\land r=a\) \(\top\)
\(p=u\) \(\top\)
\(p=x\land h=v\) \(\top\)

Proof. The first two branches force \(P_p,P_r\) to be distinct bare parameters. A consistent equation with a leaf on one side cannot force two independent parameter-to-constant bindings. Indeed it is either a constant comparison or the assignment of one variable to a term that omits it. All other variables stay free. Thus \(P_u,P_v\) are both compound. The third branch makes \(P_p\) absent from \(P_u\) by the occurs check. Its binding in the first branch therefore requires an occurrence in \(P_v\). In the final witness, the value of \(x\) occurs strictly inside the value of \(h\). An occurrence of \(q\) in \(P_x\) would make the latter value a subtree of the former.

Conversely choose fresh parameters \(s,t\) and set \((P_u,P_v,P_p,P_r)=(f(a,b),f(s,t),s,t)\). The comparison forces \(s=a,t=b\). For the last branch choose \(s\) equal to the value of \(P_x\) and assign \(q=f(s,t)\). Absence makes the choice of \(P_x\) independent of \(q\). The other two guards plainly have witnesses. \(\square\)

Presence lemma. To require \(q\) to occur in \(P_y\), introduce a private \(z\), enforce absence from \(P_z\), and add \(y=z\Rightarrow h=a\). If \(q\) were absent from both sides of the comparison, any consistency witness could be changed to set \(q=b\). Conversely, when \(q\) occurs in \(P_y\), choose \(P_z=P_y[q:=a]\). Equality at any such occurrence forces \(q=a\), and assigning \(q=a\) supplies a witness. \(\square\)

These gadgets constrain the original parameter itself. Private auxiliary coordinates may share parameters arbitrarily in a proposed answer. The reverse arguments above also apply to such answers.

2. Identities between unknown tree operations

Consider a finite set of universally quantified identities. Expressions use first-order variables and unknown operation symbols of specified arities. A solution assigns each operation a finite tree over \(f,a,b\) and its formal arguments, so that the identities hold syntactically after expansion. We may require an operation to use a particular argument. The following compilation has constructor-free input and polynomial size.

  1. Allocate coordinates \(g_1,\ldots,g_d\) for the universal variables and \(h_1,\ldots,h_k\) for the formals, where \(k\) is the largest arity. Force all these coordinates to be distinct bare parameters using §1. Give each operation \(U\) a body coordinate \(y_U\). Keep every \(g_i\) and every unused trailing \(h_j\) parameter out of that body by the absence gadget. A required argument gets the presence gadget for its \(h_j\) and \(y_U\).
  2. Process each application \(e=U(e_1,\ldots,e_l)\) after its children. Write \(v_{e_j}\) for a computed child value, using \(g_i\) for a universal variable. Start with \(b_0=y_U\). Introduce fresh \(b_1,\ldots,b_l\) and, for each \(j\), require the \(h_j\) parameter absent from \(P_{b_j}\). Add the single-comparison branch \(h_j=v_{e_j}\Rightarrow b_{j-1}=b_j\). Use \(b_l\) as \(v_e\) and keep all formal parameters out of this final value. For a nullary operation the final value is its body.
  3. Give each final equality of represented expressions its own branch with empty premise. A two-equation conclusion in the absence gadget can likewise be split into two branches sharing the same premise.

Correctness. Given term operations, use them as the bodies on the \(h\) parameters. Each intermediate \(b_j\) is the body with its first \(j\) arguments replaced by their expanded expressions on the \(g\) parameters. These expressions use no \(h\) parameter. All the required absences thus hold. The gadgets extend the pattern using fresh private variables, and each comparison can specialize its one formal freely.

Conversely ground nuisance parameters to \(a\) and keep the designated \(g,h\) parameters free. Fix any ground valuation of them at stage \(j\). Reset just \(h_j\) to the value of \(v_{e_j}\). The child and \(b_j\) are independent of this change. Relevance says that \(b_j\) equals \(b_{j-1}\) evaluated with this substitution. Composing the stages therefore evaluates the original body on the entire child tuple. Its independence from the \(g\) parameters makes the same operation work for every valuation of the globals. Induction over expressions recovers all identities. Equality under every ground substitution implies syntactic equality here. Distinct variables can be tested using distinct ground codes of one common depth greater than both terms’ depths. A variable opposite a compound containing such a code then has strictly smaller depth. \(\square\)

One comparison can select a joint witness. For any nonempty pure consistency guard \(D\Rightarrow\top\), introduce a fresh pair \(u,v\). Replace the guard by \(u=v\Rightarrow e\) for each equation \(e\) of \(D\), always using that same pair. Every answer to the replacement admits a witness for \(u=v\). Each conclusion holds in that very witness, so it satisfies all of \(D\).

For the other direction take an answer pattern and one of its witnesses \(\eta\) for \(D\). List the parameters \(q_1,\ldots,q_t\) in the expanded equations \(D[P]\). For \(P_u\) pack this list into a tree using \(f\) with terminator \(a\). Use the same tree with leaves \(\eta(q_j)\) for \(P_v\). Equality is consistent and fixes all those parameters to their selected values. This construction also works for a guard with one equation or no parameters. Each pure guard gets its own pair. A tautological test \(z=z\) supplies the empty premise of a final equality. The resulting input uses only single variable comparisons as premises. All packing takes place in the synthesized answer. \(\square\)

3. Force natural numbers without prescribing a constructor

Require a binary unknown \(L\) to use both its head and its tail argument. For distinct formal letters \(v,w\) put

\[S_{v,w}(x)=L(v,L(w,x)).\]

For each arithmetic variable introduce a ternary unknown \(N\) and require the identity

\[N(v,w,S_{v,w}(x))=S_{v,w}(N(v,w,x)).\]

Numeral lemma. Every solution has \(N(v,w,x)=S_{v,w}^{\,n}(x)\) for one \(n\ge0\).

Proof. Fix \(v,w\) as distinct new letters and consider finite terms containing the hole \(x\), with composition by substitution for all occurrences of \(x\). This monoid is free on the terms that admit no nontrivial factorization. Here is a proof. In \(A(B)=C(D)\), if \(|B|\ge |D|\), each occurrence of \(x\) inside a copy of \(B\) lies inside a copy of \(D\) contained in it. The two subtrees intersect at that leaf and their sizes order them by containment. Every occurrence of the term \(D\) contains \(x\). Distinct copies of \(D\) cannot nest properly and every such occurrence in the common product coincides with a designated copy, by following any of its \(x\) leaves. Replacing all copies of \(D\) in \(B\) by \(x\) gives \(B=E(D)\). If the two right factors are irreducible, the larger must therefore equal the smaller. Right cancellation follows by contracting their copies in the whole term. Factoring into irreducibles terminates because nonidentity factors are strictly smaller than their composition. This proves existence and uniqueness of the factor word.

The factor word of \(L(v,x)\) contains the letter \(v\) in at least one factor and contains no \(w\). The factor word of \(L(w,x)\) has the converse property. Their concatenation cannot be a proper power. After deleting unmarked factors, all \(v\)-bearing factors precede all \(w\)-bearing factors, and both occur. Repeating any word containing both would reverse that order somewhere. Thus \(S_{v,w}\) is primitive. Commuting nonempty words are powers of a common word, by successively canceling the shorter prefix in their commutation equation. The identity context is the zeroth power. A proposed \(N\) omitting \(x\) cannot commute with \(S\), since applying the latter strictly increases its size. The claimed exponent follows. \(\square\)

The identity with the two formal letters fixes the whole ternary term, so its numeral behavior persists under every substitution for those letters. Encode \(p=1\) by \(N_p(v,w,x)=S_{v,w}(x)\). Encode \(p=m+n\) by \(N_p(v,w,x)=N_m(v,w,N_n(v,w,x))\). Distinct iterates have distinct sizes.

4. Multiplication and the depth weights

Take distinct universal letters \(v,w,i,j,x,y,r\). Abbreviate \(S_A=S_{v,w}\) and \(S_B=S_{i,j}\). Call the numerals for \(m,n,p\) on the corresponding tag pair, for example \(N_p^A(x)=N_p(v,w,x)\). For one constraint \(mn=p\), introduce a fresh operation \(G(r,x,y,v,w,i,j)\). Leave the four color arguments unchanged at both calls and abbreviate those calls by \(G(r,x,y)\). Require the single identity

\[ G\big(L(L(N_p^A(x),N_m^B(y)),r),x,y\big) = L\big(L(x,y),G(r,N_n^A(x),S_B(y))\big). \tag{1} \]

This is the shifted-list multiplication construction of Spies and Forster, with \(L\) in place of the list and pair constructors and separate colors for the two counters. Their proof fixes a rigid binary constructor. The depth calculation below proves the converse for a freely chosen \(L\). Spies and Forster, §5, Lemmas 5.10–5.18

Forward. If \(p=mn\), put \(H_t=L(S_A^{tn}(x),S_B^t(y))\) and choose \(G=L(H_0,L(H_1,\ldots,L(H_{m-1},r)\ldots))\). Use \(G=r\) when \(m=0\). On the left (1) appends \(H_m\) at the tail. On the right it prepends \(H_0\) and increments every existing index by one. This is a syntactic identity for any \(L\).

Backward. For a term \(T\) and formal letter \(u\) write \([T]_u(z)=\sum z^{|p|}\) over the addresses \(p\) of occurrences of \(u\). Substitution multiplies the weights along an address and adds the contributions from different holes. Write \(h,q\) for the head and tail polynomials of \(L\). Both are nonzero, and \(q\) has zero constant coefficient because the root of \(L\) is compound. Consequently there is a positive real \(\lambda\) with \(q(\lambda)=1\) and \(h(\lambda)>0\). The tail weight of either successor is \(s=q^2\). The weight of its outer color is \(h\). Its \(k\)th iterate has tail weight \(s^k\) and outer-color weight \(hJ_k\), where \(J_k=1+s+\cdots+s^{k-1}\) and \(J_0=0\).

Let \(R\) be the tail polynomial of \(G\). For the first counter let \(A\) be the \(x\) polynomial and \(V\) the \(v\) polynomial of \(G\). For the second use its \(y\) and \(i\) polynomials instead. The following notation covers both.

Counter Endpoint exponent \(e\) Increment exponent \(d\) Head coefficient \(K\) in \(L(L(x,y),r)\)
First \(p\) \(n\) \(h^2\)
Second \(m\) \(1\) \(hq\)

Reading the base letter and the outer color, respectively, on both sides of (1) gives the polynomial identities

\[ KR s^e+A=K+qA s^d,\qquad KRhJ_e+V=qV+qAhJ_d. \tag{2} \]

At \(\lambda\), the first identity gives \(R(\lambda)=1\). The second gives \(K(\lambda)e=A(\lambda)d\). We also need the relative weights of the two base letters in the arbitrary body \(G\). Multiply the first identity by \(h\) and subtract the second multiplied by \(s-1\). Using \((s-1)J_k=s^k-1\) gives

\[Kh(R-1)=(q-1)\big(hA-(s-1)V\big). \tag{3}\]

Use (3) for both counters, cross-multiply by the other \(K\), and cancel the nonzero polynomial \(q-1\) before evaluating at \(\lambda\). Since \(s(\lambda)=1\), the result is \(A_1(\lambda)/K_1(\lambda)=A_2(\lambda)/K_2(\lambda)\). The second ratio is \(m\) by the second counter’s endpoint equation. The first counter now gives \(p=mn\), including \(n=0\). \(\square\)

5. Decision consequence and verification

Satisfiability over the natural numbers of finite systems \(p=1\), \(m+n=p\), \(mn=p\) is recursively enumerable complete. The numeral and multiplication lemmas encode precisely these constraints as identities. Section 2 compiles them to ordinary flat JCA branches, all over the same two constants. Sequential specialization uses one premise equation per call stage even for the seven-argument history \(G\). The witness-selection construction then eliminates every multiple-equation guard. All premises compare variables, and each conclusion is one equality. A candidate finite answer can be enumerated and checked by unification, giving membership. Spies and Forster, §2.3, elementary Diophantine equations · Bayer et al., formalization of the DPRM theorem

The two constants need appear only once each. Replace all their occurrences by two new coordinates \(c_a,c_b\) and add \(z=z\Rightarrow c_a=a\) and \(z=z\Rightarrow c_b=b\). Every answer now fixes those coordinates throughout.

Two distinct input constants are sharp. If the whole flat instance mentions at most one constant, assigning every coordinate that value satisfies all premises and conclusions simultaneously. With no input constant any one ground value suffices.

The constructor-free fragment therefore has no computable bound on minimum successful witness depth as a function of input size. The fixed-branch question is finer. This reduction allocates branches for the operations and their evaluation sites. The four-branch theorem for inputs with constructors and the decision procedure for a single flat comparison with constant outputs still apply in their stated settings.

The Lean 4.19.0 proof with mathlib v4.19.0 checks numeral rigidity and the equivalence between (1) having a history term and \(p=mn\). It takes arbitrary finite tree bodies as input. The kernel reports only propext, Classical.choice, and Quot.sound. The same file verifies the four-branch absence gadget. Sections 1–2 give the proof of the compilation from identities to the final flat instances.

The executable reduction builds the final single-comparison branches, checks their syntax, constructs complete answer patterns including the witness selectors, and verifies each branch by finite-tree unification. The two positive examples give 1,948 and 2,227 single-comparison branches. A nonlinear pairing duplicates its tail in the second example. The program tests 720 candidate guards after the three setup branches, verifies absence in all 156 accepted cases, and rejects a proposed history with a false endpoint.

python3 projects/jca/agent-collab/round-15-experiments.py
# In a Lean 4.19.0 project with mathlib v4.19.0, pass the path to the proof.
lake env lean /path/to/round-15-proof.lean