text:
# The existential theory of equations with rational constraints in free groups is PSPACE–complete

### ACM Classification

F.2. Analysis of Algorithms and Problem Complexity, F.2.2. Computation on Discrete Structures, F.4. Mathematical Logic and Formal Languages.
Subject Descriptor Equations in Free Groups.

## 1 Introduction

Around the 1980’s a great progress was achieved on the algorithmic decidability of elementary theories of free monoids and groups. In 1977 Makanin  proved that the existential theory of equations in free monoids is decidable by presenting an algorithm which solves the satisfiability problem for a single word equation with constants. In 1983 he extended his result to the more complicated framework in free groups . In fact, using a result by Merzlyakov  he also showed that the positive theory of equations in free groups is decidable , and Razborov was able to give a description of the whole solution set . The algorithms of Makanin are very complex: For word equations the running time was first estimated by several towers of exponentials and it took more than 20 years to lower it down to the best known bound for Makanin’s original algorithm, which is to date $`\mathrm{EXPSPACE}`$ . For solving equations in free groups Kościelski and Pacholski  have shown that the scheme proposed by Makanin is not primitive recursive.

In 1999 Plandowski invented another method for solving word equations and he showed that the satisfiability problem for word equations is in $`\mathrm{PSPACE}`$, . One ingredient of his work is to use data compression to reduce the exponential space to polynomial space. The importance of data compression was first recognized by Rytter and Plandowski when applying Lempel-Ziv encodings to the minimal solution of a word equation . Another important notion is the definition of an $`\mathrm{}`$-factorization of the solution being explained below. Gutiérrez extended Plandowski’s method to the case of free groups, . Thus, a non-primitive recursive scheme for solving equations in free groups has been replaced by a polynomial space bounded algorithm. Hagenah and Diekert worked independently in the same direction and using some ideas of Gutiérrez they obtained a result which includes the presence of rational constraints. This appeared as extended abstract in  and also as a part of the PhD-thesis of Hagenah .

The present paper is a journal version of . It shows that the existential theory of equations in free groups with rational constraints is $`\mathrm{PSPACE}`$–complete. Rational constraints mean that a possible solution has to respect a specification which is given by a regular word language. The idea to consider regular constraints for word equations goes back to Schulz  who also pointed out the importance of this concept, see also . The $`\mathrm{PSPACE}`$–completeness for the case of word equations with regular constraints has been stated by Rytter already, as cited in \[26, Thm. 1\].

Our proof reduces the case of equations with rational constraints in free groups to the case equations with regular constraints in free monoids with involution, which turns out to be the central object. (Makanin uses the notion of “paired alphabet”, but a main difference is that he considered “non contractible” solutions only, whereas we deal with general solutions and, in addition, we have constraints.) During our work we extend the method of  such that it copes with the involution and the method of  such that it copes with rational constraints. The first step is a reduction to the satisfiability problem of a single equation with regular constraints in a free monoid with involution. In order to avoid an exponential blow-up, we do not use a reduction as in , but a simpler one. In particular, we can handle negations simply by positive rational constraints. In the second step we show that the satisfiability problem of a single equation with regular constraints in a free monoid with involution is still in $`\mathrm{PSPACE}`$. This part is rather technical and we introduce several new notions like base-change, projection, partial solution, and free interval. The careful handling of free intervals is necessary because of the constraints. In some sense this is the only additional difficulty which we will meet when dealing with constraints. After these preparations we can follow Plandowski’s method. Throughout we shall use many of the deep ideas which were presented in , and apply them in a different setting. Hence, as we cannot use Plandowski’s result as a black box, we have to go through the whole construction again. As a result our paper is (involuntarily) self-contained, up to standard knowledge in combinatorics on words and linear Diophantine equations.

## 2 Free Groups and their Rational Subsets

Let $`\mathrm{\Sigma }`$ be a finite alphabet. By $`F(\mathrm{\Sigma })`$ we denote the free group over $`\mathrm{\Sigma }`$. Elements of $`F(\mathrm{\Sigma })`$ can be represented by words in $`(\mathrm{\Sigma }\overline{\mathrm{\Sigma }})^{}`$, where $`\overline{\mathrm{\Sigma }}=\{\overline{a}a\mathrm{\Sigma }\}`$. We read $`\overline{a}`$ as $`a^1`$ in $`F(\mathrm{\Sigma })`$ and we use the convention that $`\overline{\overline{a}}=a`$. Hence the set $`\mathrm{\Gamma }=\mathrm{\Sigma }\overline{\mathrm{\Sigma }}`$ is equipped with an involution $`\overline{^{^{}}}:\mathrm{\Gamma }\mathrm{\Gamma }`$; the involution is extended to $`\mathrm{\Gamma }^{}`$ by $`\overline{a_1\mathrm{}a_n}=\overline{a_n}\mathrm{}\overline{a_1}`$ for $`n0`$ and $`a_i\mathrm{\Gamma }`$, $`1in`$. The empty word as well as the unit element in other monoids is denoted by $`1`$. By $`\psi :\mathrm{\Gamma }^{}F(\mathrm{\Sigma })`$ we denote the canonical homomorphism. A word $`w\mathrm{\Gamma }^{}`$ is freely reduced, if it contains no factor of the form $`a\overline{a}`$ with $`a\mathrm{\Gamma }`$. The reduction of a word $`w\mathrm{\Gamma }^{}`$ can be computed by using the Noetherian and confluent rewriting system $`\{a\overline{a}1a\mathrm{\Gamma }\}`$. For $`w\mathrm{\Gamma }^{}`$ we denote by $`\widehat{w}`$ the freely reduced word which denotes the same group element in $`F(\mathrm{\Sigma })`$ as $`w`$. Hence, $`\psi (u)=\psi (v)`$ if and only if $`\widehat{u}=\widehat{v}`$ in $`\mathrm{\Gamma }^{}`$.

The class of rational languages in $`F(\mathrm{\Sigma })`$ is inductively defined as follows: Every finite subset of $`F(\mathrm{\Sigma })`$ is rational. If $`P_1,P_2F(\mathrm{\Sigma })`$ are rational, then $`P_1P_2`$, $`P_1P_2`$, and $`P_1^{}`$ are rational. Hence, $`PF(\mathrm{\Sigma })`$ is rational if and only if $`P=\psi (P^{})`$ for some regular language $`P^{}\mathrm{\Gamma }^{}`$.111We follow the usual convention to call a rational subset of a free monoid regular. This convention is due to Kleene’s Theorem stating that regular, rational, and recognizable have the same meaning in free monoids. But in free groups these notions are different and we have to be more precise. In particular, we can use a non-deterministic finite automata over $`\mathrm{\Gamma }`$ for specifying rational group languages over $`F(\mathrm{\Sigma })`$.

The following proposition is due to M. Benois , see also \[2, Sect. III. 2\].

###### Proposition 1

Let $`P^{}\mathrm{\Gamma }^{}`$ be a regular language and $`P=\psi (P^{})F(\mathrm{\Sigma })`$. Then we effectively find a regular language $`\stackrel{~}{P}^{}\mathrm{\Gamma }^{}`$ such that $`\stackrel{~}{P}^{}=\{\widehat{w}\mathrm{\Gamma }^{}\psi (w)P\}`$. Hence, the complement of $`P`$ is the rational group language $`\psi (\stackrel{~}{P}^{})`$ and the family of rational group languages is an effective Boolean algebra.

Proof. (Sketch) Using the same state set (and some additional transitions which are labeled with the empty word) we can construct (in polynomial time) a finite automaton which accepts the following language

$$P^{\prime \prime }=\{v\mathrm{\Gamma }^{}uP^{}:u\stackrel{}{}v\}$$

where $`u\stackrel{}{}v`$ means that $`v`$ is a descendant of $`u`$ by the convergent rewriting system $`\{a\overline{a}1a\mathrm{\Gamma }\}`$. Then we complement $`P^{\prime \prime }`$ with respect to $`\mathrm{\Gamma }^{}`$; and we build the intersection with the regular set of freely reduced words. $`\mathrm{}`$

## 3 The Existential Theory

In the following $`\mathrm{\Omega }`$ denotes a finite set of variables (or unknowns) and we let $`\overline{^{^{}}}:\mathrm{\Omega }\mathrm{\Omega }`$ be an involution without fixed points. Clearly, if $`X\mathrm{\Omega }`$ has an interpretation in $`F(\mathrm{\Sigma })`$, then we read $`\overline{X}`$ as $`X^1F(\mathrm{\Sigma })`$.

The existential theory of equations with rational constraints in free groups is inductively defined as follows. Atomic formulae are either of the form $`W=1`$, where $`W(\mathrm{\Gamma }\mathrm{\Omega })^{}`$ or of the form $`XP`$, where $`X`$ is in $`\mathrm{\Omega }`$ and $`PF(\mathrm{\Sigma })`$ is a rational language. A propositional formula is build up by atomic formulae using negations, conjunctions and disjunctions. The existential theory refers to closed existentially quantified propositional formulae which evaluate to true over $`F(\mathrm{\Sigma })`$.

###### Theorem 2

The following problem is $`\mathrm{PSPACE}`$–complete.

INPUT: A closed existentially quantified propositional formula with rational constraints in the free group $`F(\mathrm{\Sigma })`$ for some finite alphabet $`\mathrm{\Sigma }`$.

QUESTION: Does the formula evaluate to true over $`F(\mathrm{\Sigma })`$?

The $`\mathrm{PSPACE}`$–hardness follows from a result of Kozen , since (due to the constraints) the empty intersection problem of regular sets can easily be encoded in the problem above. The same argument applies to Theorems 4 and 5 below and therefore the $`\mathrm{PSPACE}`$–hardness is not discussed further in the sequel: We have to show the inclusion in $`\mathrm{PSPACE}`$, only.

The $`\mathrm{PSPACE}`$ algorithm for solving Theorem 2 will be described by a (highly) non-deterministic procedure. We will make sure that if the input evaluates to true, then at least one possible output is true. If it evaluates to false, then no (positive) output is possible. By standard methods (Savitch’s Theorem) such a procedure can be transformed into a polynomial space bounded deterministic decision procedure, see any textbook on complexity theory, e.g. .

We start the procedure as follows. Using the rules of DeMorgan we may assume that there are no negations at all, but the atomic formulae are now of the either form: $`W=1`$, $`W1`$, $`XP`$, $`XP`$ with $`W(\mathrm{\Gamma }\mathrm{\Omega })^{}`$, $`X\mathrm{\Omega }`$, and $`PF(\mathrm{\Sigma })`$ rational.222The reason that we keep $`XP`$ instead of $`X\stackrel{~}{P}`$ where $`\stackrel{~}{P}=F(\mathrm{\Sigma })P`$ is that the complementation may involve an exponential blow-up of the state space; this has to be avoided.

The next step is to replace every formula $`W1`$ by

$$X:WX=1X\{1\},$$

where X is a fresh variable, hence we can put $`X`$ to the front. Now we eliminate all disjunctions. More precisely, every subformula of type $`AB`$ is non-deterministically replaced either by $`A`$ or by $`B`$. At this stage the propositional formula has become a conjunction of formulae of type $`W=1`$, $`XP`$, $`XP`$ with $`W(\mathrm{\Gamma }\mathrm{\Omega })^{}`$, $`X\mathrm{\Omega }`$, and $`PF(\mathrm{\Sigma })`$ rational.

We may assume that $`|W|3`$, since if $`1|W|<3`$, then we may replace $`W=1`$ by $`Wa\overline{a}=1`$ for some $`a\mathrm{\Gamma }`$. For the following it is convenient to assume that $`|W|=3`$ for all subformulae $`W=1`$. This is also easy to achieve. As long as there is a subformula $`x_1\mathrm{}x_k=1`$, $`x_i\mathrm{\Gamma }\mathrm{\Omega }`$ for $`1ik`$ and $`k4`$, we replace it by the conjunction

$$Y:x_1x_2Y=1\overline{Y}x_3\mathrm{}x_k=1,$$

where $`Y`$ is a fresh variable and $`Y`$ is put to the front, and then proceed recursively. This finishes the first phase. The output of this phase is a system of atomic formulae of type $`W=1`$, $`XP`$, $`XP`$ with $`W(\mathrm{\Gamma }\mathrm{\Omega })^3`$, $`X\mathrm{\Omega }`$, and $`PF(\mathrm{\Sigma })`$ rational.

At this point we switch to the existential theory of equations with regular constraints in free monoids where these monoids have an involution. Recall that $`XP`$ (resp. $`XP`$) means in fact $`X\psi (P^{})`$ (resp. $`X\psi (P^{})`$) where $`P^{}\mathrm{\Gamma }^{}`$ is a regular word language specified by some finite non-deterministic automaton. Using $`\psi `$-symbols we obtain an interpretation over $`(\mathrm{\Gamma }^{},\overline{^{^{}}})`$ without changing the truth value by replacing syntactically each subformula $`XP`$ (resp. $`X\overline{)}P`$) by $`\psi (X)\psi (P^{})`$ (resp. $`\psi (X)\psi (P^{})`$) and by replacing each subformula $`W=1`$ by $`\psi (W)=1`$.

We keep the interpretation over words, but we eliminate now all occurrences of $`\psi `$ again. We begin with the occurrences of $`\psi `$ in the constraints. Let $`P^{}\mathrm{\Gamma }^{}`$ be regular being accepted by some finite automaton with state set $`Q`$. As stated in the in the first part of the proof of Proposition 1, we construct a finite automaton, using the same state set, which accepts the following language

$$P^{\prime \prime }=\{v\mathrm{\Gamma }^{}uP^{}:u\stackrel{}{}v\}.$$

In particular, $`\psi (P^{})=\psi (P^{\prime \prime })`$ and $`\widehat{P}P^{\prime \prime }`$ where $`\widehat{P}=\{\widehat{u}\mathrm{\Gamma }^{}uP^{}\}`$.

We replace all positive atomic subformulae of the form $`\psi (X)\psi (P^{})`$ by $`XP^{\prime \prime }`$. A simple reflection shows that the truth value has not changed since we can think of $`X`$ of being a freely reduced word. For a negative formulae $`\psi (X)\psi (P^{})`$ we have to be a little more careful. Let $`N\mathrm{\Gamma }^{}`$ be the regular set of all freely reduced words. The language $`N`$ is accepted by a deterministic finite automaton with $`|\mathrm{\Gamma }|+1`$ states. We replace $`\psi (X)\psi (P^{})`$ by

$$XP^{\prime \prime }XN,$$

where $`P^{\prime \prime }`$ is as above. Again the truth value did not change.

We now have to deal with the formulae $`\psi (xyz)=1`$ where $`x,y,z\mathrm{\Gamma }\mathrm{\Omega }`$. Observe that the underlying propositional formula is satisfiable over $`\mathrm{\Gamma }^{}`$ if and only if it is satisfiable in freely reduced words. The following lemma is well-known. Its easy proof is left to the reader.

###### Lemma 3

Let $`u,v,w\mathrm{\Gamma }^{}`$ be freely reduced words. Then we have $`\psi (uvw)=1`$ (i.e. $`uvw=1`$ in $`F(\mathrm{\Sigma })`$) if and only if there are words $`P,Q,R\mathrm{\Gamma }^{}`$ such that $`u=PQ`$, $`v=\overline{Q}R`$, and $`w=\overline{R}\overline{P}`$ holds in $`\mathrm{\Gamma }^{}`$.

Based on this lemma we replace each atomic subformulae $`\psi (xyz)=1`$ with $`x,y,z\mathrm{\Gamma }\mathrm{\Omega }`$ by a conjunction

$$PQR:x=PQy=\overline{Q}Rz=\overline{R}\overline{P},$$

where $`P`$, $`Q`$, $`R`$ are fresh variables and the existential block is put to the front. The new existential formula has no occurrence of $`\psi `$ anymore. The atomic subformulae are of the form $`x=yz`$, $`XP`$, $`XP`$, where $`x,y,z\mathrm{\Gamma }\mathrm{\Omega }`$ and $`P\mathrm{\Gamma }^{}`$ is regular. The size of the formula is linear in the size of the original formula. Therefore Theorem 2 is a consequence of Theorem 4.

## 4 Free Monoids with Involution

As above, let $`\mathrm{\Gamma }`$ be an alphabet of constants and $`\mathrm{\Omega }`$ be an alphabet of variables. There are involutions $`\overline{^{^{}}}:\mathrm{\Gamma }\mathrm{\Gamma }`$ and $`\overline{^{^{}}}:\mathrm{\Omega }\mathrm{\Omega }`$. The involution on $`\mathrm{\Omega }`$ is without fixed points, but we explicitly allow fixed points for the involution on $`\mathrm{\Gamma }`$. 333Fixed points for the involution on constants are needed in the proof later anyhow and this more general setting leads to further applications,  The involution is extended to $`(\mathrm{\Gamma }\mathrm{\Omega })^{}`$ by $`\overline{x_1\mathrm{}x_n}=\overline{x_n}\mathrm{}\overline{x_1}`$ for $`n0`$ and $`x_i\mathrm{\Gamma }\mathrm{\Omega }`$, $`1in`$.

From now on, all monoids $`M`$ under consideration are equipped with an involution $`\overline{^{^{}}}:MM`$, i.e. we have $`\overline{1}=1`$ for the unit element, $`\overline{\overline{x}}=x`$, and $`\overline{xy}=\overline{y}\overline{x}`$ for all $`x,yM`$. A homomorphism between monoids $`M`$ and $`M^{}`$ is therefore a mapping $`h:MM^{}`$ such that $`h(1)=1`$, $`h(xy)=h(x)h(y)`$, and $`h(\overline{x})=\overline{h(x)}`$ for all $`x,yM`$. The pair $`(\mathrm{\Gamma }^{},\overline{^{^{}}})`$ is called a *free monoid with involution*. 444Note that $`(\mathrm{\Gamma }^{},\overline{^{^{}}})`$ is a free monoid which has an involution, but it is not a free object in the category of monoids with involution, as soon as the involution has fixed points.

The existential theory of equations with regular constraints in free monoids with involution is based on atomic formulae of type $`U=V`$ where $`U,V(\mathrm{\Gamma }\mathrm{\Omega })^{}`$ and of type $`XP`$ where $`X\mathrm{\Omega }`$ and $`P\mathrm{\Gamma }^{}`$ is a regular language specified by some non-deterministic finite automaton. Again, a propositional formula is build up by atomic formulae using negations, conjunctions and disjunctions. The existential theory refers to closed existentially quantified propositional formulae which evaluate to true over $`(\mathrm{\Gamma }^{},\overline{^{^{}}})`$.

The following statement is the main result of the paper.

###### Theorem 4

The following problem is $`\mathrm{PSPACE}`$–complete.

INPUT: A closed existentially quantified propositional formula with regular constraints in a free monoid with involution over $`(\mathrm{\Gamma },\overline{^{^{}}})`$.

QUESTION: Does the formula evaluate to true over $`(\mathrm{\Gamma }^{},\overline{^{^{}}})`$?

The proof of Theorem 4 is in a first step (next section) a reduction to Theorem 5. The proof of Theorem 5 will be the essential technical contribution.

## 5 From Regular Constraints to Boolean Matrices and a Single Equation

The first part of the proof is very similar to what we have done above. By DeMorgan we have no negations and all subformulae are of type $`U=V`$, $`UV`$, $`XP`$, $`XP`$, where $`U,V(\mathrm{\Gamma }\mathrm{\Omega })^{}`$, $`X\mathrm{\Omega }`$, and $`P\mathrm{\Gamma }^{}`$ is regular.

Since we work over a free monoid $`\mathrm{\Gamma }^{}`$ it is easy to handle inequalities $`UV`$ where $`U,V(\mathrm{\Gamma }\mathrm{\Omega })^{}`$. We recall it under the assumption $`|\mathrm{\Gamma }|2`$: A subformulae $`UV`$ is replaced by

$$XYZ:\underset{ab}{}(U=VaXV=UaX(U=XaYV=XbZ)).$$

Making guesses we can eliminate all disjunctions and we obtain a propositional formula which is a single conjunction over subformulae of type $`U=V`$, $`XP`$, and $`XP`$ where $`U,V(\mathrm{\Gamma }\mathrm{\Omega })^{}`$, $`X\mathrm{\Omega }`$, and $`P\mathrm{\Gamma }^{}`$ is regular.

By another standard procedure we can replace a conjunction of word equations over $`(\mathrm{\Gamma }\mathrm{\Omega })^{}`$ by a single word equation $`L=R`$ with $`L,R(\mathrm{\Gamma }\mathrm{\Omega })^+`$. For example, we may choose a new letter $`a`$ and then we can replace a system $`L_1=R_1`$, $`L_2=R_2,\mathrm{},L_k=R_k`$ by $`L_1aL_2a\mathrm{}aL_k=R_1aR_2a\mathrm{}aR_k`$ and a list $`X\mathrm{\Gamma }^{}`$ for all $`X\mathrm{\Omega }`$; this works since $`a\mathrm{\Gamma }`$.

Therefore we may assume that our input is given by a single equation $`L=R`$ with $`L,R(\mathrm{\Gamma }\mathrm{\Omega })^+`$ and by two lists $`(X_jP_j,1jm)`$ and $`(X_jP_j,m<jk)`$ where $`X_j\mathrm{\Omega }`$ and each regular language $`P_j\mathrm{\Gamma }^{}`$ is specified by some non-deterministic automaton $`𝒜_j=(Q_j,\mathrm{\Gamma },\delta _j,I_j,F_j)`$ where $`Q_j`$ is the set of states, $`\delta _jQ_j\times \mathrm{\Gamma }\times Q_j`$ is the transition relation, $`I_jQ_j`$ is the subset of initial states, and $`F_jQ_j`$ is the subset of final states, $`1jk`$. Of course, a variable $`X`$ may occur several times in the list with different constraints, therefore we might have $`k`$ greater than $`|\mathrm{\Omega }|`$. The question is whether there is a solution.

A *solution* is a mapping $`\sigma :\mathrm{\Omega }\mathrm{\Gamma }^{}`$ being extended to a homomorphism $`\sigma :(\mathrm{\Gamma }\mathrm{\Omega })^{}\mathrm{\Gamma }^{}`$ by leaving the letters from $`\mathrm{\Gamma }`$ invariant such that the following conditions are satisfied:

$$\begin{array}{cccc}\hfill \sigma (L)& =& \sigma (R),\hfill & \\ \hfill \sigma (\overline{X})& =& \overline{\sigma (X)}\hfill & \text{for }X\mathrm{\Omega },\hfill \\ \hfill \sigma (X_j)& & P_j\hfill & \text{for }1jm,\hfill \\ \hfill \sigma (X_j)& & P_j\hfill & \text{for }m<jk.\hfill \end{array}$$

For the next steps it turns out to be more convenient to work within the framework of Boolean matrices instead of finite automata: Let $`Q`$ be the disjoint union of the state spaces $`Q_j`$, $`1jk`$. We may assume that $`Q=\{1,\mathrm{},n\}`$. Let $`\delta =_{1jk}\delta _j`$, then $`\delta Q\times \mathrm{\Gamma }\times Q`$ and with each $`a\mathrm{\Gamma }`$ we can associate a Boolean $`n\times n`$ matrix $`g(a)𝔹^{n\times n}`$ such that $`g(a)_{i,j}=`$$`(i,a,j)\delta `$” for $`1i,jn`$. Since our monoids should have an involution, we shall in fact work with $`2n\times 2n`$ matrices. Henceforth $`M𝔹^{2n\times 2n}`$ denotes the following monoid with involution:

$$M=\{\left(\begin{array}{cc}A& 0\\ 0& B\end{array}\right)A,B𝔹^{n\times n}\},$$

where

$$\overline{\left(\begin{array}{cc}A& 0\\ 0& B\end{array}\right)}=\left(\begin{array}{cc}B^T& 0\\ 0& A^T\end{array}\right)$$

and the operator $`^T`$ denotes the transposition. We define a homomorphism $`h:\mathrm{\Gamma }^{}M`$ by

$$h(a)=\left(\begin{array}{cc}g(a)& 0\\ 0& g(\overline{a})^T\end{array}\right)\text{for}a\mathrm{\Gamma },$$

where the mapping $`g:\mathrm{\Gamma }𝔹^{n\times n}`$ is defined as above. The homomorphism $`h`$ can be computed in polynomial time and it respects the involution. Now, for each regular language $`P_j`$, $`1jk`$ we compute vectors $`I_j,F_j𝔹^{2n}`$ such that for all $`w\mathrm{\Gamma }^{}`$ and $`1jk`$ we have the equivalence:

$$wP_jI_j^Th(w)F_j=1.$$

Having done these computations we make a non-deterministic guess $`\rho (X)M`$ for each variable $`X\mathrm{\Omega }`$. We verify $`\rho (\overline{X})=\overline{\rho (X)}`$ for all $`X\mathrm{\Omega }`$ and whenever there is a constraint of type $`XP_j`$ for some $`1jm`$ (or $`XP_j`$ for some $`m<jk`$), then we verify $`I_j^T\rho (X)F_j=1`$, if $`1jm`$ (or $`I_j^T\rho (X)F_j=0`$, if $`m<jk`$).

After these preliminaries, we introduce the formal definition of an equation $`E`$ with constraints: Let $`d,n`$ and let $`M𝔹^{2n\times 2n}`$ be the monoid with involution defined above. We consider an equation of length $`d`$ over some $`\mathrm{\Gamma }`$ and $`\mathrm{\Omega }`$ with constraints in $`M`$ being specified by a list $`E`$ containing the following items:

* The alphabet $`(\mathrm{\Gamma },\overline{^{^{}}})`$ with involution.
* The homomorphism $`h:\mathrm{\Gamma }^{}M`$ which is specified by a mapping $`h:\mathrm{\Gamma }M`$ such that $`h(\overline{a})=\overline{h(a)}`$ for all $`a\mathrm{\Gamma }`$.
* The alphabet $`(\mathrm{\Omega },\overline{^{^{}}})`$ with involution without fixed points.
* A mapping $`\rho :\mathrm{\Omega }M`$ such that $`\rho (\overline{X})=\overline{\rho (X)}`$ for all $`X\mathrm{\Omega }`$.
* The equation $`L=R`$ where $`L,R(\mathrm{\Gamma }\mathrm{\Omega })^+`$ and $`|LR|=d`$.

We will denote this list simply by

$$E=(\mathrm{\Gamma },h,\mathrm{\Omega },\rho ;L=R).$$

A convenient definition for the input size is given by $`n+d+\mathrm{log}_2(|\mathrm{\Gamma }|+|\mathrm{\Omega }|)`$. This definition takes into account that there might be constants or variables with constraints which are not present in the equation. Recall that $`n`$ refers to the dimension of the boolean matrices, and this parameter is part of the input.

A solution of $`E`$ is a mapping $`\sigma :\mathrm{\Omega }\mathrm{\Gamma }^{}`$ (being extended to a homomorphism $`\sigma :(\mathrm{\Gamma }\mathrm{\Omega })^{}\mathrm{\Gamma }^{}`$ by leaving the letters from $`\mathrm{\Gamma }`$ invariant) such that the following three conditions are satisfied:

$`\sigma (L)`$ $`=`$ $`\sigma (R),`$
$`\sigma (\overline{X})`$ $`=`$ $`\overline{\sigma (X)}\text{for all}X\mathrm{\Omega },`$
$`h\sigma (X)`$ $`=`$ $`\rho (X)\text{for all}X\mathrm{\Omega }.`$
By the reduction above, Theorem 4 is a consequence of the next statement which says that the satisfiability problem of equations with constraints can be solved in polynomial space.

###### Theorem 5

The following problem is $`\mathrm{PSPACE}`$–complete.

INPUT: An equation $`E_0`$ with constraints $`E_0=(\mathrm{\Gamma }_0,h_0,\mathrm{\Omega }_0,\rho _0;L_0=R_0).`$

QUESTION: Is there a solution $`\sigma :\mathrm{\Omega }_0\mathrm{\Gamma }_0^{}`$?

For the proof we need an explicit space bound. Therefore we fix some polynomial $`p`$ and and we allow working space $`p(n+d+\mathrm{log}_2(|\mathrm{\Gamma }|+|\mathrm{\Omega }|)`$. An appropriate choice of the polynomial $`p`$ can be calculated from the presentation below. What is important is that the notions of admissibility being used in the next sections always refer to some fixed polynomials. The following lemma states that some basic operations, which we have to perform several times can be done in $`\mathrm{PSPACE}`$.

###### Lemma 6

The following two problems can be solved in polynomial space with respect to the input size $`n+\mathrm{log}(|\mathrm{\Gamma }|)`$.

INPUT: A matrix $`AM`$ and a mapping $`h:\mathrm{\Gamma }M`$.

QUESTION: Is there some $`w\mathrm{\Gamma }^{}`$ such that $`h(w)=A`$?

INPUT: A matrix $`AM`$ and a mapping $`h:\mathrm{\Gamma }M`$.

QUESTION: Is there some $`w\mathrm{\Gamma }^{}`$ such that $`h(w)=A`$ and $`w=\overline{w}`$?

Proof. The first question can be solved by guessing a word $`w`$ letter by letter and calculating $`h(w)`$. The second question can be solved since $`w=\overline{w}`$ implies $`w=ua\overline{u}`$ for some $`u\mathrm{\Gamma }^{}`$ and $`a\mathrm{\Gamma }\{1\}`$ with $`a=\overline{a}`$. Hence we can guess $`u`$ and $`a`$. During the guess we compute $`B=h(u)`$ and then we verify $`A=Bh(a)\overline{B}`$. $`\mathrm{}`$

Here is a first application of Lemma 6: Assume that an equation with constraints $`E=(\mathrm{\Gamma },h,\mathrm{\Omega },\rho ;L=R)`$ contains in the specification some variable $`X`$ which does not occur in $`LR\overline{LR}`$, then the equation might be unsolvable, simply because $`\rho (X)h(\mathrm{\Gamma }^{})`$. However, by the lemma above we can test this in $`\mathrm{PSPACE}`$. If $`\rho (X)h(\mathrm{\Gamma }^{})`$, then we can safely cancel $`X`$ and $`\overline{X}`$. Thus, we put this test in the preprocessing, and in the following we shall assume that all variables occur somewhere in $`LR\overline{LR}`$. In particular, we may assume $`|\mathrm{\Omega }|2|LR|`$.

## 6 The Exponent of Periodicity

A key step in proving Theorem 5 is to find a bound on the exponent of periodicity in a minimal solution. This idea is used in all known algorithms for solving word equations in general, c.f., .

Let $`w\mathrm{\Gamma }^{}`$ be a word. The exponent of periodicity $`\mathrm{exp}(w)`$ is defined by

$$\mathrm{exp}(w)=sup\{\alpha u,v,p\mathrm{\Gamma }^{},p1:w=up^\alpha v\}.$$

We have $`\mathrm{exp}(w)>0`$ if and only if $`w`$ is not the empty word. Let $`E=(\mathrm{\Gamma },h,\mathrm{\Omega },\rho ,L=R)`$ be an equation with constraints. The exponent of periodicity of $`E`$ is also denoted by $`\mathrm{exp}(E)`$. It is defined by

$$\mathrm{exp}(E)=inf\{\{\mathrm{exp}(\sigma (L))\sigma \mathrm{is}\mathrm{a}\mathrm{solution}\mathrm{of}E\}\{\mathrm{}\}\}.$$

By definitions we have $`\mathrm{exp}(E)<\mathrm{}`$ if and only if $`E`$ is solvable. Here we show that the well-known result from word equations  transfers to the situation here. The exponent of periodicity of a solvable equation can be bounded by a singly exponential function. Thus, in the following sections we shall assume that if $`E_0`$ is solvable, then $`\mathrm{exp}(E_0)2^{𝒪(d+n\mathrm{log}n)}`$. This is the content of the next proposition.

###### Proposition 7

Let $`E=(\mathrm{\Gamma },h,\mathrm{\Omega },\rho ;L=R)`$ be an equation with constraints and let $`\sigma :\mathrm{\Omega }\mathrm{\Gamma }^{}`$ be a solution. Then we find effectively a solution $`\sigma ^{}:\mathrm{\Omega }\mathrm{\Gamma }^{}`$ such that $`\mathrm{exp}(\sigma ^{}(L))2^{𝒪(d+n\mathrm{log}n)}`$.

The rest of this section is devoted to prove Proposition 7. Since it follows standard lines, the proof can be skipped in a first reading.

Proof. Let $`pA^+`$ be a primitive word. In our setting the definition of the $`p`$-stable normal form of a word $`wA^{}`$ depends on the property whether or not $`\overline{p}`$ is a factor of $`p^2`$. So we distinguish two cases and in the following we also write $`p^1`$ for denoting $`\overline{p}`$. Then, for example, $`p^3`$ means the same as $`\overline{p}^3`$.

First case: We assume that $`\overline{p}`$ is not a factor of $`p^2`$. The idea is to replace each maximal factor of the form $`p^\alpha `$ with $`\alpha 2`$ by a sequence $`p,\alpha 2,p`$ and each maximal factor of the form $`\overline{p}^\alpha `$ with $`\alpha 2`$ by a sequence $`\overline{p},(\alpha 2),\overline{p}`$. This leads to the following notion:

The $`p`$-stable normal form (first kind) of $`wA^{}`$ is a shortest sequence ($`k`$ is minimal)

$$(u_0,\epsilon _1\alpha _1,u_1,\mathrm{},\epsilon _k\alpha _k,u_k)$$

such that $`k0`$, $`u_0,u_iA^{}`$, $`\epsilon _i\{+1,1\}`$, $`\alpha _i0`$ for $`1ik`$, and the following conditions are satisfied:

* $`w=u_0p^{\epsilon _1\alpha _1}u_1\mathrm{}p^{\epsilon _k\alpha _k}u_k`$.
* $`k=0`$ if and only if neither $`p^2`$ nor $`\overline{p}^2`$ is a factor of $`w.`$
* If $`k1`$, then:

$`u_0`$ $``$ $`A^{}p^{\epsilon _1}A^{}p^{\pm 2}A^{},`$
$`u_i`$ $``$ $`(A^{}p^{\epsilon _{i+1}}p^{\epsilon _i}A^{})A^{}p^{\pm 2}A^{}\text{ for }1i<k,`$
$`u_k`$ $``$ $`p^{\epsilon _k}A^{}A^{}p^{\pm 2}A^{}.`$

The $`p`$-stable normal form of $`\overline{w}`$ becomes

$$(\overline{u_k},\epsilon _k\alpha _k,u_{k1},\mathrm{},\epsilon _1\alpha _1,\overline{u_0}).$$

###### Example 8

Let $`p=a\overline{a}ba\overline{a}`$ with $`b\overline{b}`$ and $`w=p^4\overline{b}a\overline{a}p^1a\overline{a}\overline{b}p^2`$. Then the $`p`$-stable normal form of $`w`$ is:

$$(\overline{a}a\overline{a}b,2,a\overline{a}ba\overline{a}\overline{b}a\overline{a},1,a\overline{a}\overline{b}a\overline{a}\overline{b}a\overline{a},0,a\overline{a}\overline{b}a\overline{a}).$$

Second case: We assume that $`\overline{p}`$ is a factor of $`p^2`$. Then we can write $`p=rs`$ with $`\overline{p}=sr`$ and $`r=\overline{r}`$, $`s=\overline{s}`$. We allow $`r=1`$, hence the second case includes the case $`p=\overline{p}`$. In fact, if $`r=1`$, then below we obtain the usual definition of $`p`$-stable normal form. Moreover, by switching to some conjugated word of $`p`$ we could always assume that $`r\{1,a\}`$ for some letter $`a`$ being fixed by the involution, $`a=\overline{a}`$, but this switch is not made here. The idea is to replace each maximal factor of the form $`(rs)^\alpha r`$ with $`\alpha 2`$ by a sequence $`rs,\alpha 2,sr`$. In this notation $`\alpha 2`$ is representing the factor $`(rs)^{\alpha 2}r=p^{\alpha 2}r=r\overline{p}^{\alpha 2}`$.

The $`p`$-stable normal form (second kind) of $`wA^{}`$ is now a shortest sequence ($`k`$ is minimal)

$$(u_0,\alpha _1,u_1,\mathrm{},\alpha _k,u_k)$$

such that $`k0`$, $`u_0,u_iA^{},\alpha _i0`$ for $`1ik`$, and the following conditions are satisfied:

* $`w=u_0p^{\alpha _1}ru_1\mathrm{}p^{\alpha _k}ru_k`$.
* $`k=0`$ if and only if $`p^2r`$ is not a factor of $`w.`$
* If $`k1`$, then:

$`u_0`$ $``$ $`A^{}rs(A^{}p^2rA^{}A^{}rsrs),`$
$`u_i`$ $``$ $`(A^{}rssrA^{})(srsrA^{}A^{}p^2rA^{}A^{}rsrs)\text{ for }1i<k,`$
$`u_k`$ $``$ $`srA^{}(A^{}p^2rA^{}srsrA^{}).`$

Since $`\overline{rs}=sr`$, the $`p`$-stable normal form of $`\overline{w}`$ becomes

$$(\overline{u_k},\alpha _k,u_1,\mathrm{},\alpha _1,\overline{u_0}).$$

So, for the second kind no negative integers interfere.

###### Example 9

Let $`p=a\overline{a}b`$ with $`b=\overline{b}`$. Then $`r=a\overline{a}`$ and $`s=b`$. Let $`w=\overline{a}p^4ap^3a`$ Then the $`p`$-stable normal form of $`w`$ is:

$$(\overline{a}ba\overline{a}b,2,ba\overline{a}baa\overline{a}b,0,ba\overline{a}ba).$$

In both cases we can write the $`p`$-stable normal form of $`w`$ as a sequence

$$(u_0,\alpha _1,u_1,\mathrm{},\alpha _k,u_k)$$

where $`u_i`$ are words and $`\alpha _i`$ are integers.

For every finite semigroup $`S`$ there is a number $`c(S)`$ such that for all $`sS`$ the element $`s^{c(S)}`$ is idempotent, i.e., $`s^{c(S)}=s^{2c(S)}`$. It is clear that the number $`c(M)`$ for our monoid $`M𝔹^{2n\times 2n}`$ is the same as the number $`c(𝔹^{n\times n})`$. It is well-known  that we can take $`c(𝔹^{n\times n})=n!`$ (it is however more convenient to define $`c(M)=3`$ for $`n=1`$). Hence in the following $`c(M)=\mathrm{max}\{3,n!\}`$.

For specific situations this might be an overestimation, but this choice guarantees $`h(uv^{c(M)}w)=h(uv^{2c(M)}w)`$ for all $`u,v,w\mathrm{\Gamma }^{}`$ and all $`h:\mathrm{\Gamma }^{}M`$.

Now, let $`w,w^{}\mathrm{\Gamma }^{}`$ be words such that the $`p`$-stable normal forms are identical up to one position where for $`w`$ appears an integer $`\alpha _i`$ and for $`w^{}`$ appears an integer $`\alpha _i^{}`$. We know $`h(w)=h(w^{})`$ whenever the following conditions are satisfied: $`\alpha _i\alpha _i^{}>0`$, $`|\alpha _i|c(M)`$, $`|\alpha _i^{}|c(M)`$, and $`\alpha _i\alpha _i^{}(modc(M))`$. Then we have $`h(w)=h(w^{})`$. This is the reason to change the syntax of the $`p`$-stable normal form. Each non-zero integer $`\alpha ^{}`$ is written as $`\alpha ^{}=\epsilon (q+\alpha c(M))`$ where $`\epsilon ,q,\alpha `$ are uniquely defined by $`\epsilon \{+1,1\}`$, $`0q<c(M)`$, and $`\alpha 0`$. For $`\alpha ^{}=0`$ we may choose $`\epsilon =q=\alpha =0`$. We shall read $`\alpha `$ as a variable ranging over non-negative integers, but $`\epsilon `$, $`q`$, and $`c(M)`$ are viewed as constants. In fact, if $`|\alpha ^{}|<c(M)`$, then we best view $`\alpha `$ also as a constant in order to avoid problems with the constraints.

Let $`u`$, $`v`$, and $`w`$ be words such that $`uv=w`$ holds. Write these words in their $`p`$-stable normal forms:

$$\begin{array}{cc}u:\hfill & (u_0,\epsilon _1(q_1+\alpha _1c(S)),u_1,\mathrm{},\epsilon _k(q_k+\alpha _kc(S)),u_k),\hfill \\ v:\hfill & (v_0,\epsilon _1^{}(s_1+\beta _1c(S)),v_1,\mathrm{},\epsilon _{\mathrm{}}^{}(s_{\mathrm{}}+\beta _{\mathrm{}}c(S)),v_{\mathrm{}}),\hfill \\ w:\hfill & (w_0,\epsilon _1^{\prime \prime }(t_1+\gamma _1c(S)),w_1,\mathrm{},\epsilon _m^{\prime \prime }(t_m+\gamma _mc(S)),w_m).\hfill \end{array}$$

Since $`uv=w`$ there are many identities. For example, for $`k,\mathrm{}2`$ we have $`u_0=w_0`$, $`v_l=w_m`$, $`q_1=t_1`$, $`\alpha _1=\gamma _1`$, etc. What exactly happens depends only on the $`p`$-stable normal form of the product $`u_kv_0`$. There are several cases, which easily can be listed. We treat only one of them, which is in some sense the worst case in order to produce a large exponent of periodicity. This is the case where $`p=rs`$ with $`r=\overline{r}`$ and $`s=\overline{s}`$. Then it might be that $`u_k=srsr_1`$ and $`v_0=r_2srs`$ with $`r_1r_2=r`$ (and $`r_11r_2`$). Hence we have $`u_kv_0=sp^3`$ and $`k+\mathrm{}=m+1`$. It follows $`\alpha _1=\gamma _1,\mathrm{},\alpha _{k1}=\gamma _{k1}`$, $`\beta _2=\gamma _{k+1},\mathrm{},\beta _{\mathrm{}}=\gamma _m`$, and there is only one non-trivial identity:

$$q_k+s_1+4+(\alpha _k+\beta _1)c(S)=t_k+\gamma _kc(S).$$

Since by assumption $`c(S)3`$, the case $`u_kv_0=sp^3`$ leads to the identity:

$$\gamma _k=\alpha _k+\beta _1+c\text{ with }c\{0,1,2\}.$$

Assume now that $`\alpha _k1`$ and $`\beta _11`$. If we replace $`\alpha _k`$, $`\beta _1`$, and $`\gamma _k`$ by some $`\alpha _k^{}1`$, $`\beta _1^{}1`$, and $`\gamma _k^{}1`$ such that still $`\gamma _k^{}=\alpha _k^{}+\beta _1^{}+c`$, then we obtain new words $`u^{}`$, $`v^{}`$, and $`w^{}`$ with the same images under $`h`$ in $`M`$ and still the identity $`u^{}v^{}=w^{}`$.

What follows then is completely analogous to what has been done in detail in . Using the $`p`$-stable normal form we can associate with an equation $`L=R`$ of denotational length $`d`$ together with its solution $`\sigma :\mathrm{\Omega }\mathrm{\Gamma }^{}`$ some linear Diophantine system of $`d`$ equations in at most $`3d`$ variables. The variables range over natural numbers since zeros are substituted. (In fact the number of variables can be reduced to be at most $`2|\mathrm{\Omega }|`$). The parameters of this system are such that maximal size of a minimal solution (with respect to the component wise partial order of $`^d`$) is in $`𝒪(2^{1.6d})`$ with the same approach as in . This tight bound is based in turn on the work of ; a more moderate bound $`2^{𝒪(d)}`$ (which is enough for our purposes) is easier to obtain, see e.g. . The maximal size of a minimal solution of the linear Diophantine system has a backward translation to a bound on the exponent of periodicity. For this translation we have to multiply with the factor $`c(M)2^{𝒪(n\mathrm{log}n)}`$ and to add $`c(M)+1`$. Putting everything together we obtain the claim of the proposition. $`\mathrm{}`$

## 7 Exponential Expressions

During the procedure which solves Theorem 5 various other equations with constraints are considered but the monoid $`M`$ will not change.

There will be not enough space to write down the equation $`L=R`$ in plain form, in general. In fact, there is a provable exponential lower bound for the length $`|LR|`$ in the worst case which we can meet during the procedure. In order to overcome this difficulty Plandowski’s method uses data compression for words in $`(\mathrm{\Gamma }\mathrm{\Omega })^{}`$ in terms of exponential expressions.

Exponential expressions (their evaluation and their size) are inductively defined:

* Every word $`w\mathrm{\Gamma }^{}`$ denotes an exponential expression. The evaluation $`\mathrm{eval}(w)`$ is equal to $`w`$, its size $`w`$ is equal to the length $`|w|`$.
* Let $`e`$, $`e^{}`$ be exponential expressions. Then $`ee^{}`$ is an exponential expression. Its evaluation is the concatenation $`\mathrm{eval}(ee^{})=\mathrm{eval}(e)\mathrm{eval}(e^{})`$, its size is $`ee^{}=e+e^{}`$.
* Let $`e`$ be an exponential expression and $`k`$. Then $`(e)^k`$ is an exponential expression. Its evaluation is $`\mathrm{eval}((e)^k)=(\mathrm{eval}(e))^k`$, its size is $`(e)^k=\mathrm{log}(k)+e`$ where $`\mathrm{log}(k)=\mathrm{max}\{1,\mathrm{log}_2(k)\}`$.

It is not difficult to show that the length of $`\mathrm{eval}(e)`$ is at most exponential in the size of $`e`$, a fact which is, strictly speaking, not needed for the proof of Theorem 5. What we need however is the next lemma. Its proof can be done easily by structural induction and it is omitted.

###### Lemma 10

Let $`u\mathrm{\Gamma }^{}`$ be a factor of a word $`w\mathrm{\Gamma }^{}`$. Assume that $`w`$ can be represented by some exponential expression of size $`p`$. Then we find an exponential expression of size at most $`p^2`$ that represents $`u`$.

We say that an exponential expression $`e`$ is admissible, if its size $`e`$ is bounded by some fixed polynomial in the input size of $`E_0`$. The lemma above states that if $`e`$ is admissible, then we find admissible exponential expressions for all factors of $`\mathrm{eval}(e)`$. But now the admissibility is defined with respect to some polynomial which is the square of the original polynomial, so, in a nested way, we can apply this procedure a constant number of times, only. In our application the nested depth does not go beyond two.

The next lemma is straightforward since we allow a polynomial space bound without any time restriction. Again, the proof is left to the reader.

###### Lemma 11

The following two problems can be solved in $`\mathrm{PSPACE}`$.

INPUT: Exponential expressions $`e`$ and $`e^{}`$.

QUESTION: Do we have $`\mathrm{eval}(e)=\mathrm{eval}(e^{})`$?

INPUT: A mapping $`h:\mathrm{\Gamma }M`$ and an exponential expression $`e`$.

OUTPUT: The matrix $`h(\mathrm{eval}(e))M`$.

###### Remark 12

The computation above can actually be performed in polynomial time, but this is not evident for the first question, see  for details.

Henceforth we allow that the part $`L=R`$ of an equation with constraints may also be given by a pair of exponential expressions $`(e_L,e_R)`$ with $`\mathrm{eval}(e_L)=L`$ and $`\mathrm{eval}(e_R)=R`$. We say that $`E=(\mathrm{\Gamma },h,\mathrm{\Omega },\rho ;e_L=e_R)`$ is admissible, if $`e_Le_R`$ is admissible, $`|\mathrm{\Gamma }\mathrm{\Gamma }_0|`$ has polynomial size, $`\mathrm{\Omega }\mathrm{\Omega }_0`$, and $`h(a)=h_0(a)`$ for $`a\mathrm{\Gamma }\mathrm{\Gamma }_0`$.

For two admissible equations with constraints $`E=(\mathrm{\Gamma },h,\mathrm{\Omega },\rho ;e_L=e_R)`$ and $`E^{}=(\mathrm{\Gamma },h,\mathrm{\Omega },\rho ;e_L^{}=e_R^{})`$ we write $`EE^{}`$, if $`\mathrm{eval}(e_L)=\mathrm{eval}(e_L^{})`$ and $`\mathrm{eval}(e_R)=\mathrm{eval}(e_R^{})`$ as strings in $`(\mathrm{\Gamma }\mathrm{\Omega })^{}`$. This means that they represent exactly the same equations.

## 8 Base Changes

In this section we fix a mapping $`h:\mathrm{\Gamma }M`$ which respects the involution. Let $`(\mathrm{\Gamma }^{},\overline{^{^{}}})`$ be an alphabet with involution and let $`\beta :\mathrm{\Gamma }^{}\mathrm{\Gamma }^{}`$ be some mapping $`\beta `$ such that $`\beta (\overline{a})=\overline{\beta (a)}`$ for all $`a\mathrm{\Gamma }^{}`$. We define $`h^{}:\mathrm{\Gamma }^{}M`$ such that $`h^{}=h\beta `$. We also extend to a homomorphism $`\beta :(\mathrm{\Gamma }^{}\mathrm{\Omega })^{}(\mathrm{\Gamma }\mathrm{\Omega })^{}`$ by leaving the variables invariant.

Let $`E^{}=(\mathrm{\Gamma }^{},h^{},\mathrm{\Omega },\rho ;L^{}=R^{}).`$ be an equation with constraints. The base change $`\beta _{}(E^{})`$ is defined by

$$\beta _{}(E^{})=(\mathrm{\Gamma },h,\mathrm{\Omega },\rho ;\beta (L^{})=\beta (R^{})).$$

We also refer to $`\beta :\mathrm{\Gamma }^{}\mathrm{\Gamma }^{}`$ as a base change and we say that $`\beta `$ is admissible, if $`|\mathrm{\Gamma }^{}|`$ has polynomial size and if $`\beta (a)`$ can be represented by some admissible exponential expression for all $`a\mathrm{\Gamma }^{}`$.

###### Remark 13

If $`\beta :\mathrm{\Gamma }^{}\mathrm{\Gamma }^{}`$ is an admissible base change and if $`L^{}=R^{}`$ is given by a pair of admissible exponential expressions, then we can represent $`\beta _{}(E^{})`$ by some admissible equation with constraints. A representation of $`\beta _{}(E^{})`$ is computable in polynomial time.

###### Lemma 14

Let $`E^{}`$ be an equation with constraints and $`\beta :\mathrm{\Gamma }^{}\mathrm{\Gamma }^{}`$ be a base change. If $`\sigma ^{}`$ is a solution of $`E^{}`$, then $`\sigma =\beta \sigma ^{}`$ is a solution of $`\beta _{}(E^{})`$.

Proof. Clearly $`\sigma (\overline{X})=\overline{\sigma (X)}`$ and $`h\sigma (X)=h\beta \sigma ^{}(X)=h^{}\sigma ^{}(X)=\rho (X)`$ for all $`X\mathrm{\Omega }`$. Next by definition $`\sigma (a)=a`$ for $`a\mathrm{\Gamma }`$ and $`\beta (X)=X`$ for $`X\mathrm{\Omega }`$. Hence $`\sigma \beta (a)=\beta \sigma ^{}(a)`$ for $`a\mathrm{\Gamma }^{}`$ and therefore $`\sigma \beta =\beta \sigma ^{}:(\mathrm{\Gamma }^{}\mathrm{\Omega })^{}\mathrm{\Gamma }^{}`$. This means $`\sigma \beta (L)=\beta \sigma ^{}(L)=\beta \sigma ^{}(R)=\sigma \beta (R)`$ since $`\sigma ^{}(L)=\sigma ^{}(R)`$. $`\mathrm{}`$

The lemma above leads to the first rule.

Rule 1 If $`E`$ is of the form $`\beta _{}(E^{})`$ and if we are looking for a solution of $`E`$, then it is enough to find a solution for $`E^{}`$. Hence, during a non-deterministic search we may replace $`E`$ by $`E^{}`$.

###### Example 15

Consider the following equation $`E`$ with constraints over $`\mathrm{\Gamma }=\{a,b,c,\overline{a},\overline{b},\overline{c}\}`$:

$$X\overline{X}=Y\overline{b}\overline{c}\overline{b}\overline{a}\overline{b}\overline{c}\overline{b}YZabcb\overline{Y}.$$

Let there be the constraints for $`X`$ and $`Z`$ saying $`X\mathrm{\Gamma }^{300}\mathrm{\Gamma }^{}`$ and $`Z\overline{b}\overline{c}\overline{b}\overline{a}\mathrm{\Gamma }^{}`$. Define $`\mathrm{\Gamma }^{}=\{a,b,\overline{a},\overline{b}\}`$ and a base change $`\beta :\mathrm{\Gamma }^{}\mathrm{\Gamma }^{}`$ by $`\beta (a)=abcb`$ and $`\beta (b)=bcb`$. Then the equation $`E`$ is of the form $`\beta _{}(E^{})`$ where $`E^{}`$ is given by

$$X\overline{X}=Y\overline{a}\overline{b}YZa\overline{Y}$$

and the new (and sharper) constraint for $`Z`$ is simply $`Z\overline{a}\mathrm{\Gamma }_{}^{}{}_{}{}^{}`$, for $`X`$ we may sharpen the constraint to $`X\mathrm{\Gamma }_{}^{}{}_{}{}^{100}\mathrm{\Gamma }_{}^{}{}_{}{}^{}`$ According to Rule 1 it is enough to solve $`E^{}`$. The effect of the base change $`\beta `$ is that the equation $`E^{}`$ is shorter and the alphabet of constants becomes smaller, since the letter $`c`$ is not used anymore. Note also that the length restriction on $`X`$ became smaller, too. However this has a prize; in general, $`E=\beta _{}(E^{})`$ might have a solution, whereas $`E^{}`$ is unsolvable. As we will see later, our guess has been correct in the sense that $`E^{}`$ still has a solution.

## 9 Projections

Let $`(\mathrm{\Gamma },\overline{^{^{}}})`$ and $`(\mathrm{\Gamma }^{},\overline{^{^{}}})`$ be alphabets with involution such that $`(\mathrm{\Gamma },\overline{^{^{}}})(\mathrm{\Gamma }^{},\overline{^{^{}}})`$. A projection is a homomorphism $`\pi :\mathrm{\Gamma }_{}^{}{}_{}{}^{}\mathrm{\Gamma }^{}`$ such that both $`\pi (a)=a`$ for $`a\mathrm{\Gamma }`$ and $`\pi (\overline{a})=\overline{\pi (a)}`$ for all $`a\mathrm{\Gamma }^{}`$. If $`h:\mathrm{\Gamma }M`$ is given, then a projection $`\pi `$ defines also $`h^{}:\mathrm{\Gamma }^{}M`$ by $`h^{}=h\pi `$.

Let $`E`$ be an equation with constraints $`E=(\mathrm{\Gamma },h,\mathrm{\Omega },\rho ;L=R).`$ Then we can define an equation with constraints $`\pi ^{}(E)`$ by

$$\pi ^{}(E)=(\mathrm{\Gamma }^{},h\pi ,\mathrm{\Omega },\rho ;L=R).$$

The difference between $`E`$ and $`\pi ^{}(E)`$ is only in the alphabets of constants and in the mappings $`h`$ and $`h^{}=h\pi `$. Note that every projection $`\pi :\mathrm{\Gamma }_{}^{}{}_{}{}^{}\mathrm{\Gamma }^{}`$ defines a base change $`\pi _{}`$ such that $`\pi _{}\pi ^{}(E)=E`$.

###### Lemma 16

Let $`E=(\mathrm{\Gamma },h,\mathrm{\Omega },\rho ;L=R)`$ and $`E^{}=(\mathrm{\Gamma }^{},h^{},\mathrm{\Omega },\rho ;L=R)`$ be equations with constraints. Then the following two statements hold.

1. There is a projection $`\pi :\mathrm{\Gamma }_{}^{}{}_{}{}^{}\mathrm{\Gamma }^{}`$ such that $`\pi ^{}(E)=E^{}`$, if and only if both $`h^{}(\mathrm{\Gamma }^{})h(\mathrm{\Gamma }^{})`$ and for all $`a\mathrm{\Gamma }^{}`$ with $`a=\overline{a}`$ there is some $`w\mathrm{\Gamma }^{}`$ with $`w=\overline{w}`$ such that $`h^{}(a)=h(w)`$.
2. If we have $`\pi ^{}(E)=E^{}`$ and if $`\sigma ^{}:\mathrm{\Omega }\mathrm{\Gamma }_{}^{}{}_{}{}^{}`$ is a solution of $`E^{}`$, then we effectively find a solution $`\sigma `$ for $`E`$ such that $`|\sigma (L)|2|M||\sigma ^{}(L)|`$.

Proof. i) Clearly, the only-if condition is satisfied by the definition of a projection since then $`h^{}=h\pi `$. For the converse, assume that $`h^{}(\mathrm{\Gamma }^{})h(\mathrm{\Gamma }^{})`$ and that $`a=\overline{a}`$ implies $`h^{}(a)h(\{w\mathrm{\Gamma }^{}w=\overline{w}\})`$. Then for each $`a\mathrm{\Gamma }^{}\mathrm{\Gamma }`$ we can choose a word $`w_a\mathrm{\Gamma }^{}`$ such that $`h^{}(a)=h(w_a)`$. We can make the choice such that $`w_{\overline{a}}=\overline{w_a}`$ for all $`a\mathrm{\Gamma }^{}\mathrm{\Gamma }`$. If $`a\overline{a}`$, then we can find $`w_a`$ such that $`|w_a|<|M|`$, since we can take the shortest word $`w_a\mathrm{\Gamma }^{}`$ such that $`h(w_a)=h^{}(a)M`$. For $`a=\overline{a}`$ we know that there is some word $`w_a\mathrm{\Gamma }^{}`$ with $`h^{}(a)=h(w_a)`$ and $`w_a=\overline{w_a}`$. Hence we can write $`w_a=vb\overline{v}`$ with $`b\mathrm{\Gamma }\{1\}`$ and $`b=\overline{b}`$. For $`b1`$ we can demand $`|w_a|2|M|1`$. For $`b=1`$ we can demand $`|w_a|2|M|2`$. Thus, we find a projection $`\pi :\mathrm{\Gamma }_{}^{}{}_{}{}^{}\mathrm{\Gamma }^{}`$ such that $`\pi ^{}(E)=E^{}`$ and moreover, $`|\pi (a)|<2|M|`$ for all $`a\mathrm{\Gamma }^{}`$.

ii) Using the reasoning in the proof of i) we may assume that $`\pi :\mathrm{\Gamma }_{}^{}{}_{}{}^{}\mathrm{\Gamma }^{}`$ satisfies $`|\pi (a)|<2|M|`$ for all $`a\mathrm{\Gamma }^{}`$. Since $`\pi `$ defines a base change with $`\pi _{}(E^{})=E`$, we know by Lemma 14 that $`\sigma =\pi \sigma ^{}`$ is a solution of $`E`$. Clearly, $`|\sigma (L)|=|\pi \sigma ^{}(L)|2|M||\sigma ^{}(L)|`$. $`\mathrm{}`$

###### Remark 17

In the following we will meet the problem to decide whether there is a projection $`\pi :\mathrm{\Gamma }_{}^{}{}_{}{}^{}\mathrm{\Gamma }^{}`$ such that $`\pi ^{}(E)=E^{}`$. We actually need not too much space for this test. It is not necessary to write down $`\pi `$. We can use the criterion in the lemma above and Lemma 6. Then we have to store in the working space only some Boolean matrices of $`𝔹^{2n\times 2n}`$. In particular, if $`n`$ is a constant (or logarithmically bounded in the input size), then the test $`\pi :\pi ^{}(E)=E^{}`$ can be done in polynomial time. However, if $`n`$ becomes a substantial part of the input size, then the test might be difficult in the sense that we might need the full power of $`\mathrm{PSPACE}`$.

The lemma above leads now to the second rule.

Rule 2 If $`\pi `$ is a projection and if we are looking for a solution of $`E`$, then it is enough to find a solution for $`\pi ^{}(E)`$. Hence, during a non-deterministic search we may replace $`E`$ by $`\pi ^{}(E)`$.

###### Example 18

Let us continue with the equation which has been obtained by the transformation in Example 15. In order to simplify notations, we will call $`E`$ the equation $`X\overline{X}=Y\overline{a}\overline{b}YZa\overline{Y}`$, and $`\mathrm{\Gamma }=\{a,b,\overline{a},\overline{b}\}`$.

Remember that the constraint on $`X`$ demanded a rather long solution. Therefore we may reintroduce a letter $`c`$ and put $`\mathrm{\Gamma }^{}=\{a,b,c,\overline{a},\overline{b},\overline{c}\}`$. Then we may define a projection $`\pi :\mathrm{\Gamma }^{}\mathrm{\Gamma }^{}`$ by, say, $`\pi (c)=b^{100}`$. The equation $`E^{}=\pi ^{}(E)`$ looks as above, but in $`E^{}`$ we may change the constraint for $`X`$. We may sharpen the new constraint for $`X`$ to be $`X\mathrm{\Gamma }^{}c\mathrm{\Gamma }^{}`$. Thus, the solution for $`X`$ might be very short now.

## 10 Partial Solutions

Let $`\mathrm{\Omega }^{}\mathrm{\Omega }`$ be a subset of the variables which is closed under involution. We assume that there is a mapping $`\rho ^{}:\mathrm{\Omega }^{}M`$ with $`\rho ^{}(\overline{x})=\overline{\rho ^{}(x)}`$, but we do not require that $`\rho ^{}`$ is the restriction of $`\rho :\mathrm{\Omega }M`$. Consider an equation with constraints $`E=(\mathrm{\Gamma },h,\mathrm{\Omega },\rho ;L=R).`$ A partial solution is a mapping $`\delta :\mathrm{\Omega }\mathrm{\Gamma }^{}\mathrm{\Omega }^{}\mathrm{\Gamma }^{}\mathrm{\Gamma }^{}`$ such that the following conditions are satisfied:

1. $`\delta (X)\mathrm{\Gamma }^{}X\mathrm{\Gamma }^{}`$

for all $`X\mathrm{\Omega }^{}`$,
2. $`\delta (X)\mathrm{\Gamma }^{}`$

for all $`X\mathrm{\Omega }\mathrm{\Omega }^{}`$,
3. $`\delta (\overline{X})=\overline{\delta (X)}`$

for all $`X\mathrm{\Omega }`$.

The mapping $`\delta `$ is extended to a homomorphism $`\delta :(\mathrm{\Gamma }\mathrm{\Omega })^{}(\mathrm{\Gamma }\mathrm{\Omega }^{})^{}`$ by leaving the elements of $`\mathrm{\Gamma }`$ invariant. Let $`E^{}=(\mathrm{\Gamma },h,\mathrm{\Omega }^{},\rho ^{};L^{}=R^{})`$ be another equation with constraints (using the same $`\mathrm{\Gamma }`$ and $`h`$). We write $`E^{}=\delta _{}(E)`$, if there exists some partial solution $`\delta :\mathrm{\Omega }\mathrm{\Gamma }^{}\mathrm{\Omega }\mathrm{\Gamma }^{}\mathrm{\Gamma }^{}`$ such that the following conditions hold: $`L^{}=\delta (L)`$, $`R^{}=\delta (R)`$, $`\rho (X)=h(u)\rho ^{}(X)h(v)`$ for $`\delta (X)=uXv`$, and $`\rho (X)=h(w)`$ for $`\delta (X)=w\mathrm{\Gamma }^{}`$.

###### Lemma 19

In the notation of above, let $`E^{}=\delta _{}(E)`$ for some partial solution $`\delta :\mathrm{\Omega }\mathrm{\Gamma }^{}\mathrm{\Omega }\mathrm{\Gamma }^{}\mathrm{\Gamma }^{}`$. If $`\sigma ^{}`$ is a solution of $`E^{}`$, then $`\sigma =\sigma ^{}\delta `$ is a solution of $`E`$. Moreover, we have $`\sigma (L)=\sigma ^{}(L^{})`$ and $`\sigma (R)=\sigma ^{}(R^{})`$.

Proof. By definition, $`\delta `$ and $`\sigma ^{}`$ are extended to homomorphisms $`\delta :(\mathrm{\Gamma }\mathrm{\Omega })^{}(\mathrm{\Gamma }\mathrm{\Omega }^{})^{}`$ and $`\sigma ^{}:(\mathrm{\Gamma }\mathrm{\Omega }^{})^{}\mathrm{\Gamma }^{}`$ leaving the letters of $`\mathrm{\Gamma }`$ invariant. Since $`E^{}=\delta _{}(E)`$ we have $`\delta (L)=L^{}`$ and $`\delta (R)=R^{}`$. Since $`\sigma ^{}`$ is a solution, we have $`\sigma (L)=\sigma ^{}\delta (L)=\sigma ^{}(L^{})=\sigma ^{}(R^{})=\sigma ^{}\delta (R)=\sigma (R)`$ and $`\sigma `$ leaves the letters of $`\mathrm{\Gamma }`$ invariant. The solution $`\sigma ^{}`$ satisfies $`h\sigma ^{}(X)=\rho ^{}(X)`$ for all $`X\mathrm{\Omega }^{}`$. Hence, if $`\delta (X)=uXv`$, then $`\rho (X)=h(u)\rho ^{}(X)h(v)=h(u\sigma ^{}(X)v)=h\sigma ^{}(uXv)=h\sigma ^{}\delta (X)=h\sigma (X)`$. If $`\delta (X)=w\mathrm{\Gamma }^{}`$, then $`\sigma (X)=\sigma ^{}\delta (X)=w`$ and $`\rho (X)=h(w)`$, again by the definition of a partial solution. $`\mathrm{}`$

###### Lemma 20

The following problem can be solved in $`\mathrm{PSPACE}`$.

INPUT: Two equations with constraints $`E=(\mathrm{\Gamma },h,\mathrm{\Omega },\rho ;e_L=e_R)`$ and $`E^{}=(\mathrm{\Gamma },h,\mathrm{\Omega }^{},\rho ^{};e_L^{}=e_R^{})`$.

QUESTION: Is there some partial solution $`\delta `$ such that $`\delta _{}(E)E^{}`$?

Moreover, if $`\delta _{}(E)E^{}`$ is true, then there are admissible exponential expressions $`e_u`$, $`e_v`$ for each $`X\mathrm{\Omega }^{}`$ and an admissible exponential expression $`e_w`$ for each $`X\mathrm{\Omega }\mathrm{\Omega }^{}`$ such that

$$\begin{array}{cccc}\hfill \delta (X)& =& \mathrm{eval}(e_u)X\mathrm{eval}(e_v)\hfill & \mathrm{for}X\mathrm{\Omega }^{},\hfill \\ \hfill \delta (X)& =& \mathrm{eval}(e_w)\hfill & \mathrm{for}X\mathrm{\Omega }\mathrm{\Omega }^{}.\hfill \end{array}$$

Proof. Let $`L=\mathrm{eval}(e_L)`$, $`R=\mathrm{eval}(e_R)`$, $`L^{}=\mathrm{eval}(e_L^{})`$, and $`R^{}=\mathrm{eval}(e_R^{})`$. The non-deterministic algorithm works as follows:

For each $`X\mathrm{\Omega }^{}`$ we guess admissible exponential expressions $`e_u`$ and $`e_v`$ with $`\mathrm{eval}(e_u),\mathrm{eval}(e_v)\mathrm{\Gamma }^{}`$. We define an exponential expressions $`e_X=e_uXe_v`$ and $`\delta (X)=\mathrm{eval}(e_X)`$. For each $`X\mathrm{\Omega }\mathrm{\Omega }^{}`$ we guess an admissible exponential $`e_X`$ with $`\mathrm{eval}(e_X)\mathrm{\Gamma }^{}`$ and $`\delta (X)=\mathrm{eval}(e_X)`$.

Next we verify whether or not $`\delta _{}(E)E^{}`$. During this test we have to create an exponential expression $`f_L`$ (and $`f_R`$, resp.) by replacing $`X`$ in $`e_L`$ (and $`e_R`$, resp.) with the expression $`e_X`$. This increases the size in the worst case by a factor of $`\mathrm{max}\{e_XX\mathrm{\Omega }\}`$. The other tests whether $`\rho (X)=h(u)\rho ^{}(X)h(v)`$ for $`\delta (X)=uXv`$ and $`\rho (X)=h(w)`$ for $`\delta (X)=w\mathrm{\Gamma }^{}`$ involve admissible exponential expressions over Boolean matrices and can be done in polynomial time.

The correctness of the algorithm follows from our general assumption that all $`X\mathrm{\Omega }`$ appear in $`LR\overline{LR}`$. Therefore, if we have $`\delta _{}(E)E^{}`$, then $`\delta (X)`$ (or $`\delta (\overline{X})`$) appears necessarily as a factor in $`L^{}R^{}=\delta (LR)`$. Hence $`\delta (X)`$ has an exponential expression of polynomial size by Lemma 10. Therefore guesses of $`e_u`$, $`e_v`$, and $`e_w`$ as above are possible without running out of space. $`\mathrm{}`$

###### Remark 21

Actually, the test for $`\delta _{}(E)E^{}`$ can be performed in non-deterministic polynomial time by Remark 12.

The lemma above leads to the third and last rule.

Rule 3 If $`\delta `$ is a partial solution and if we are looking for a solution of $`E`$, then it is enough to find a solution for $`\delta _{}(E)`$. Hence, during a non-deterministic search we may replace $`E`$ by $`\delta _{}(E)`$.

###### Remark 22

We can think of a partial solution $`\delta :\mathrm{\Omega }\mathrm{\Gamma }^{}\mathrm{\Omega }^{}\mathrm{\Gamma }^{}\mathrm{\Gamma }^{}`$ in the following sense. Assume we have an idea about $`\sigma (X)`$ for some $`X\mathrm{\Omega }`$. Then we might guess $`\sigma (X)`$ entirely. In this case we can define $`\delta (X)=\sigma (X)`$ and we have $`X\mathrm{\Omega }^{}`$. For some other $`X`$ we might guess only some prefix $`u`$ and some suffix $`v`$ of $`\sigma (X)`$. Then we define $`\delta (X)=uXv`$ and we have to guess some $`\rho ^{}(X)M`$ such that $`\rho (x):h(u)\rho ^{}(X)h(v)`$. If our guess was correct, then such a matrix $`\rho ^{}(X)M`$ must exist. We have partially specified the solution and applying Rule 3, we continue this process by replacing the equation $`L=R`$ by the new equation $`\delta (L)=\delta (R)`$.

###### Example 23

We continue with our running example. After renaming, the equation $`E`$ is given by

$$X\overline{X}=Y\overline{a}\overline{b}YZa\overline{Y},$$

and the alphabet of constant is given by $`\mathrm{\Gamma }=\{a,b,c,\overline{a},\overline{b},\overline{c}\}`$. The constraints are $`X\mathrm{\Gamma }^{}c\mathrm{\Gamma }^{}`$ and $`Z\overline{a}\{a,b,\overline{a},\overline{b}\}^{}`$.

We may guess the partial solution as follows: $`\delta (X)=aX`$, $`\delta (Y)=Y`$, and $`\delta (Z)=\overline{a}b`$. The new equation $`\delta _{}(E)`$ is

$$aX\overline{X}\overline{a}=Y\overline{a}\overline{b}Y\overline{a}ba\overline{Y}.$$

The remaining constraint is that the solution for $`X`$ has to use the letter $`c`$.

The process can continue, for example, we can apply Rule 1 again by defining another base change $`\beta (b)=ba`$ to get the equation

$$aX\overline{X}\overline{a}=Y\overline{b}Y\overline{a}b\overline{Y}$$

over $`\mathrm{\Gamma }=\{a,b,c,\overline{a},\overline{b},\overline{c}\}`$. Since the last equation has a solution (e.g., given by $`\sigma (X)=bc\overline{c}\overline{b}\overline{b}abc`$ and $`\sigma (Y)=abc\overline{c}\overline{b}`$), the first equation with constraints in Example 15 has a solution too.

## 11 The Search Graph and Plandowski’s Algorithm

In the following we show that there is some fixed polynomial (which can be calculated from the presentation below) such that the high-level description of Plandowski’s algorithm is as follows: On input $`E_0`$ compute the maximal space bound, given by the polynomial, to be used by the procedure. Then apply non-deterministically Rules 1, 2, and 3 until an equation with a trivial solution is found.

From the description above it follows that the specification of the algorithm just uses Rules 1, 2, 3. The algorithm is simple but it demands a good heuristics to explore the search graph. The hard part is to prove that this schema is correct; for this we have to be more precise.

The search graph is a directed graph: The nodes are admissible equations with constraints. For two nodes $`E`$, $`E^{}`$, we define an arc $`EE^{}`$, if there are an admissible base change $`\beta `$, a projection $`\pi `$, and a partial solution $`\delta `$ such that $`\delta _{}(\pi ^{}(E))\beta _{}(E^{})`$.

###### Lemma 24

The following problem can be decided in $`\mathrm{PSPACE}`$.

INPUT: Admissible equations with constraints $`E`$ and $`E^{}`$.

QUESTION: Is there an arc $`EE^{}`$ in the search graph?

Proof. We first guess some alphabet $`(\mathrm{\Gamma }_{}^{}{}_{}{}^{},\overline{^{^{}}})`$ of polynomial size together with $`h^{\prime \prime }:\mathrm{\Gamma }_{}^{}{}_{}{}^{}M`$. Then we guess some admissible base change $`\beta :\mathrm{\Gamma }^{}\mathrm{\Gamma }_{}^{\prime \prime }{}_{}{}^{}`$ such that $`h^{}=h^{\prime \prime }\beta `$ and we compute $`\beta _{}(E^{})`$.

Next we guess some admissible equation with constraints $`E^{\prime \prime }`$ which uses $`\mathrm{\Gamma }^{\prime \prime }`$ and $`\mathrm{\Omega }`$. We check using Lemma 20 that there is some partial solution $`\delta :\mathrm{\Omega }\mathrm{\Gamma }_{}^{\prime \prime }{}_{}{}^{}\mathrm{\Omega }^{}\mathrm{\Gamma }_{}^{\prime \prime }{}_{}{}^{}\mathrm{\Gamma }_{}^{\prime \prime }{}_{}{}^{}`$ such that $`\delta _{}(E^{\prime \prime })\beta _{}(E^{})`$. (Note that every equation with constraints $`E^{\prime \prime }`$ satisfying $`\delta _{}(E^{\prime \prime })\beta _{}(E^{})`$ for some $`\delta `$ is admissible by Lemma 10.) Finally we check using Remark 22 and that there is some projection $`\pi :\mathrm{\Gamma }^{\prime \prime }\mathrm{\Gamma }`$ such that $`\pi ^{}(E)E^{\prime \prime }`$. We obtain $`\delta _{}(\pi ^{}(E))\beta _{}(E^{})`$. $`\mathrm{}`$

###### Remark 25

Following Remarks 12 and 21 the problem in Lemma 24 can be decided in non-deterministic polynomial time, if the monoid $`M`$ is not part of the input and viewed as a constant. If, as in our setting, $`M`$ is part of the input, then $`\mathrm{PSPACE}`$ is the best we can prove, because the test for the projection becomes difficult.

Plandowski’s algorithm works as follows:

begin

$`E:=E_0`$

while $`\mathrm{\Omega }\mathrm{}`$ do

Guess an admissible equation $`E^{}`$ with constraints

Verify that $`EE^{}`$ is an arc in the search graph

$`E:=E^{}`$

endwhile

return$`\mathrm{eval}(e_L)=\mathrm{eval}(e_R)`$

end

By Rules 1–3 (Lemmata 14, 16 $`ii)`$, and 19), if $`EE^{}`$ is an arc in the search graph and $`E^{}`$ is solvable, then $`E`$ is solvable, too. Thus, if the algorithm returns true, then $`E_0`$ is solvable. The proof of Theorem 5 is therefore reduced to the statement that if $`E_0`$ is solvable, then the search graph contains a path to some node without variables and the exponential expressions defining the equation evaluate to the same word. This existence proof is the hard part, it covers the rest of the paper.

###### Remark 26

If $`EE^{}`$ is due to some $`\pi :\mathrm{\Gamma }_{}^{\prime \prime }{}_{}{}^{}\mathrm{\Gamma }^{}`$, $`\delta :\mathrm{\Omega }\mathrm{\Gamma }_{}^{\prime \prime }{}_{}{}^{}\mathrm{\Omega }^{}\mathrm{\Gamma }_{}^{\prime \prime }{}_{}{}^{}\mathrm{\Gamma }_{}^{\prime \prime }{}_{}{}^{}`$, and $`\beta :\mathrm{\Gamma }_{}^{}{}_{}{}^{}\mathrm{\Gamma }_{}^{\prime \prime }{}_{}{}^{}`$, then a solution $`\sigma ^{}:\mathrm{\Omega }^{}\mathrm{\Gamma }_{}^{}{}_{}{}^{}`$ of $`E^{}`$ yields the solution $`\sigma =\pi (\beta \sigma ^{})\delta `$. Hence we may assume that the length of a solution has increased by at most an exponential factor by Lemma 16 $`ii)`$. Since we are going to perform the search in a graph of at most exponential size, we get automatically a doubly exponential upper bound for the length of a minimal solution by backwards computation on such a path. This is still the best known upper bound (although an singly exponential bound is conjectured), see .

## 12 Free Intervals

In this section we introduce the notion of free interval in order to cope with long factors in the solution which are not related to any cut. If there were no constraints, then these factors would not appear in a minimal solution. In our setting we cannot avoid these factors.

For a word $`w\mathrm{\Gamma }^{}`$ we let $`\{0,\mathrm{},|w|\}`$ be the set of its positions. The interpretation is that factors of $`w`$ are between positions. To be more specific let $`w=a_1\mathrm{}a_m`$, $`a_i\mathrm{\Gamma }`$ for $`1im`$. Then $`[\alpha ,\beta ]`$ with $`0\alpha <\beta m`$ is called a *positive interval* and the factor $`w[\alpha ,\beta ]`$ is defined by the word $`w[\alpha ,\beta ]=a_{\alpha +1}\mathrm{}a_\beta `$.

It is convenient to have an involution on the set of intervals. Therefore $`[\beta ,\alpha ]`$ is also called an interval (but it is never positive), and we define $`w[\beta ,\alpha ]=\overline{w[\alpha ,\beta ]}`$. We allow also $`\alpha =\beta `$ and we define $`w[\alpha ,\alpha ]`$ to be the empty word. For all $`0\alpha ,\beta m`$ we let $`\overline{[\alpha ,\beta ]}=[\beta ,\alpha ]`$, then always $`\overline{w[\alpha ,\beta ]}=w\overline{[\alpha ,\beta ]}`$.

Let us focus on the word $`w_0\mathrm{\Gamma }_0^{}`$ which in our notation is the solution $`w_0=\sigma (L_0)=\sigma (R_0)`$, where $`L_0=x_1\mathrm{}x_g`$ and $`R_0=x_{g+1}\mathrm{}x_d`$, $`x_i(\mathrm{\Gamma }_0\mathrm{\Omega }_0)`$ for $`1id`$. We are going to define an equivalence relation $``$ on the set of intervals of $`w_0`$. For this we have to fix some few more notations. We let $`m_0=|w_0|`$ and for $`i\{1,\mathrm{},d\}`$ we define positions $`\mathrm{l}(i)\{0,\mathrm{},m_01\}`$ and $`\mathrm{r}(i)\{1,\mathrm{},m_0\}`$ by the congruences

$`\mathrm{l}(i)`$ $``$ $`|\sigma (x_1\mathrm{}x_{i1})|modm_0,`$
$`\mathrm{r}(i)`$ $``$ $`|\sigma (x_{i+1}\mathrm{}x_d)|modm_0.`$
This means, the factor $`\sigma (x_i)`$ starts in $`w_0`$ at the left position $`\mathrm{l}(i)`$ and it ends at the right position $`\mathrm{r}(i)`$. In particular, we have $`\mathrm{l}(1)=\mathrm{l}(g+1)=0`$ and $`\mathrm{r}(g)=\mathrm{r}(d)=m_0`$. The set of $`\mathrm{l}`$ and $`\mathrm{r}`$ positions is called the set of cuts. Thus, the set of cuts is $`\{\mathrm{l}(i),\mathrm{r}(i)1id\}`$. There are at most $`d`$ cuts. These positions cut the word $`w_0`$ in at most $`d1`$ factors. For convenience we henceforth assume $`2g<d<m_0`$ whenever necessary. We make also the assumption that $`\sigma (x_i)1`$ for all $`1id`$. This assumption can be realized e.g. by a first step in Plandowski’s algorithm using a partial solution $`\delta `$ which sends a variable $`X`$ to the empty word, if $`\sigma (X)=1`$ and sends $`X`$ to itself otherwise. Another choice to realize this assumption is by a guess in some preprocessing.

We have $`\sigma (x_i)=w_0[\mathrm{l}(i),\mathrm{r}(i)]`$ and $`\sigma (\overline{x_i})=w_0[\mathrm{r}(i),\mathrm{l}(i)]`$ for $`1id`$. By our assumption, the interval $`[\mathrm{l}(i),\mathrm{r}(i)]`$ is positive. Let us consider a pair $`(i,j)`$ such that $`i,j1,\mathrm{},d`$ and $`x_i=x_j`$ or $`x_i=\overline{x_j}`$. For $`\mu ,\nu \{0,\mathrm{},\mathrm{r}(i)\mathrm{l}(i)\}`$ we define a relation $``$ by:

$`[\mathrm{l}(i)+\mu ,\mathrm{l}(i)+\nu ]`$ $``$ $`[\mathrm{l}(j)+\mu ,\mathrm{l}(j)+\nu ],\mathrm{if}x_i=x_j,`$
$`[\mathrm{l}(i)+\mu ,\mathrm{l}(i)+\nu ]`$ $``$ $`[\mathrm{r}(j)\mu ,\mathrm{r}(j)\nu ],\mathrm{if}x_i=\overline{x_j}.`$
Note that $``$ is a symmetric relation. Moreover, $`[\alpha ,\beta ][\alpha ^{},\beta ^{}]`$ implies both $`[\beta ,\alpha ][\beta ^{},\alpha ^{}]`$ and $`w_0[\alpha ,\beta ]=w_0[\alpha ^{},\beta ^{}]`$. By $``$ we denote the reflexive and transitive closure of $``$. Then $``$ is an equivalence relation and again, $`[\alpha ,\beta ][\alpha ^{},\beta ^{}]`$ implies both $`[\beta ,\alpha ][\beta ^{},\alpha ^{}]`$ and $`w_0[\alpha ,\beta ]=w_0[\alpha ^{},\beta ^{}]`$.

Next we define the notion of free interval. An interval $`[\alpha ,\beta ]`$ is called free, if whenever $`[\alpha ,\beta ][\alpha ^{},\beta ^{}]`$, then there is no cut $`\gamma ^{}`$ with $`\mathrm{min}\{\alpha ^{},\beta ^{}\}<\gamma ^{}<\mathrm{max}\{\alpha ^{},\beta ^{}\}`$. Clearly, the set of free intervals is closed under involution, i.e., if $`[\alpha ,\beta ]`$ is free, then $`[\beta ,\alpha ]`$ is free, too. It is also clear that $`[\alpha ,\beta ]`$ is free whenever $`|\beta \alpha |1`$.

###### Example 27

The last equation in Example 23, namely

$$aX\overline{X}\overline{a}=Y\overline{b}Y\overline{a}b\overline{Y},$$

has a solution which yields the word

$$w_0=\stackrel{0}{|}a\stackrel{1}{|}bc\overline{c}\overline{b}\stackrel{5}{|}\overline{b}\stackrel{6}{|}abc\stackrel{9}{|}\overline{c}\overline{b}\stackrel{11}{|}\overline{a}\stackrel{12}{|}b\stackrel{13}{|}bc\overline{c}\overline{b}\stackrel{17}{|}\overline{a}\stackrel{18}{|}.$$

The set of cuts is shown by the bars. The intervals $`[1,5]`$, $`[13,17]`$, and $`[6,9]`$ are not free, since $`[1,5][17,13][7,11]`$ and $`[6,9][0,3]`$ and $`[7,11]`$, $`[0,3]`$ contain cuts. There is only one equivalence class of free intervals of length longer than 1 (up to involution), which is given by $`[1,3][17,15][7,9][11,9][5,3][13,15]`$.

The next lemma says that subintervals of free intervals are free again.

###### Lemma 28

Let $`[\alpha ,\beta ]`$ be a free interval and $`\mu ,\nu `$ such that $`\mathrm{min}\{\alpha ,\beta \}\mu ,\nu \mathrm{max}\{\alpha ,\beta \}`$. Then the interval $`[\mu ,\nu ]`$ is also free.

Proof. We may assume that $`\alpha \mu <\nu \beta `$. By contradiction assume that $`[\mu ,\nu ]`$ is not free. Then there is some $`k0`$ and some cut $`\gamma ^{}`$ such that

$$[\mu ,\nu ]=[\mu _0,\nu _0][\mu _1,\nu _1]\mathrm{}[\mu _k,\nu _k]$$

with $`\mathrm{min}\{\mu _k,\nu _k\}<\gamma ^{}<\mathrm{max}\{\mu _k,\nu _k\}`$. If $`k=0`$, then we have a immediate contradiction. For $`k1`$ the relation $`[\mu ,\nu ][\mu _1,\nu _1]`$ is due to some pair $`x_i`$, $`x_j`$ with $`x_i=x_j`$ or $`x_i=\overline{x_j}`$. Since $`[\alpha ,\beta ]`$ contains no cut, we can use the same pair to find an interval $`[\alpha _1,\beta _1]`$ such that $`[\alpha ,\beta ][\alpha _1,\beta _1]`$ and $`\mu _1,\nu _1\{\mathrm{min}\{\alpha _1,\beta _1\},\mathrm{},\mathrm{max}\{\alpha _1,\beta _1\}\}`$. Using induction on $`k`$ we see that $`[\alpha _1,\beta _1]`$ cannot be free. A contradiction, because then $`[\alpha ,\beta ]`$ is not free. $`\mathrm{}`$

Next we introduce the notion of implicit cut for non-free intervals. For our purpose it is enough to define it for positive intervals. So, let $`0\alpha <\beta m_0`$ such that $`[\alpha ,\beta ]`$ is not free. A position $`\gamma `$ with $`\alpha <\gamma <\beta `$ is called an implicit cut of $`[\alpha ,\beta ]`$, if we meet the following situation. There is a cut $`\gamma ^{}`$ and an interval $`[\alpha ^{},\beta ^{}]`$ such that

$`\mathrm{min}\{\alpha ^{},\beta ^{}\}<`$ $`\gamma ^{}`$ $`<\mathrm{max}\{\alpha ^{},\beta ^{}\},`$
$`[\alpha ,\beta ]`$ $``$ $`[\alpha ^{},\beta ^{}],`$
$`\gamma \alpha `$ $`=`$ $`|\gamma ^{}\alpha ^{}|.`$
The following observation will be used throughout. If we have $`\alpha \mu <\gamma <\nu \beta `$ and $`\gamma `$ is an implicit cut of $`[\alpha ,\beta ]`$, then $`\gamma `$ is also an implicit cut of $`[\mu ,\nu ]`$. In particular, neither $`[\mu ,\nu ]`$ nor $`[\nu ,\mu ]`$ is a free interval.555However, if $`\gamma `$ is an implicit cut of $`[\mu ,\nu ]`$, then it might happen that $`\gamma `$ is no implicit cut of $`[\alpha ,\beta ]`$, although $`[\alpha ,\beta ]`$ is certainly not free.

###### Lemma 29

Let $`0\alpha \alpha ^{}<\beta \beta ^{}m_0`$ such that $`[\alpha ,\beta ]`$ and $`[\alpha ^{},\beta ^{}]`$ are free intervals. Then the interval $`[\alpha ,\beta ^{}]`$ is free, too.

Proof. Assume by contradiction that $`[\alpha ,\beta ^{}]`$ is not free. Then it contains an implicit cut $`\gamma `$ with $`\alpha <\gamma <\beta ^{}`$. By the observation above: If $`\gamma <\beta `$, then $`\gamma `$ is an implicit cut of $`[\alpha ,\beta ]`$ and $`[\alpha ,\beta ]`$ is not free. Otherwise, $`\alpha ^{}<\gamma `$ and $`\alpha ^{},\beta ^{}`$ is not free. $`\mathrm{}`$

We now consider the maximal elements. A free interval $`[\alpha ,\beta ]`$ is called maximal free, if there is no free interval $`[\alpha ^{},\beta ^{}]`$ such that both $`\alpha ^{}\mathrm{min}\{\alpha ,\beta \}\mathrm{max}\{\alpha ,\beta \}\beta ^{}`$ and $`\beta ^{}\alpha ^{}>|\beta \alpha |`$. With this notion Lemma 29 states that maximal free intervals do not overlap.

###### Lemma 30

Let $`[\alpha ,\beta ]`$ be a maximal free interval. Then there are intervals $`[\gamma ,\delta ]`$ and $`[\gamma ^{},\delta ^{}]`$ such that $`[\alpha ,\beta ][\gamma ,\delta ][\gamma ^{},\delta ^{}]`$ and $`\gamma `$ and $`\delta ^{}`$ are cuts.

Proof. We may assume that $`[\alpha ,\beta ]`$ is a positive interval, i.e., $`\alpha <\beta `$. We show the existence of $`[\gamma ,\delta ]`$ where $`[\alpha ,\beta ][\gamma ,\delta ]`$ and $`\gamma `$ is a cut. The existence of $`[\gamma ^{},\delta ^{}]`$ where $`[\alpha ,\beta ][\gamma ^{},\delta ^{}]`$ and $`\delta ^{}`$ is a cut follows by a symmetric argument.

If $`\alpha =0`$, then $`\alpha `$ itself is a cut and we can choose $`\delta =\beta `$. Hence let $`1\alpha `$ and consider the positive interval $`[\alpha 1,\beta ]`$. This interval is not free, but the only possible position for an implicit cut is $`\alpha `$. Thus for some cut $`\gamma `$ we have $`[\alpha 1,\beta ][\alpha ^{},\beta ^{}]`$ with $`\mathrm{min}\{\alpha ^{},\beta ^{}\}<\gamma <\mathrm{max}\{\alpha ^{},\beta ^{}\}`$ and $`|\gamma \alpha ^{}|=1`$. A simple reflection shows that we have $`[\alpha 1,\alpha ][\alpha ^{},\gamma ]`$ and $`[\alpha ,\beta ][\gamma ,\beta ^{}]`$. Hence we can choose $`\delta =\beta ^{}`$. $`\mathrm{}`$

###### Proposition 31

Let $`\mathrm{\Gamma }`$ be the set of words $`w\mathrm{\Gamma }_0^{}`$ such that there is a maximal free interval $`[\alpha ,\beta ]`$ with $`w=w_0[\alpha ,\beta ]`$. Then $`\mathrm{\Gamma }`$ is a subset of $`\mathrm{\Gamma }_0^+`$ of size at most $`2d2`$. The set $`\mathrm{\Gamma }`$ is closed under involution.

Proof. Let $`[\alpha ,\beta ]`$ be maximal free. Then $`|\beta \alpha |1`$ and $`[\beta ,\alpha ]`$ is maximal free, too. Hence $`\mathrm{\Gamma }\mathrm{\Gamma }_0^+`$ and $`\mathrm{\Gamma }`$ is closed under involution. By Lemma 30 we may assume that $`\alpha `$ is a cut. Say $`\alpha <\beta `$. Then $`\alpha m_0`$ and there is no other maximal free interval $`[\alpha ,\beta ^{}]`$ with $`\alpha <\beta ^{}`$ because of Lemma 29. Hence there are at most $`d1`$ such intervals $`[\alpha ,\beta ]`$. Symmetrically, there are at most $`d1`$ maximal free intervals $`[\alpha ,\beta ]`$ where $`\beta <\alpha `$ and $`\alpha `$ is a cut. $`\mathrm{}`$

For a moment let $`\mathrm{\Gamma }_0^{}=\mathrm{\Gamma }_0\mathrm{\Gamma }`$ where $`\mathrm{\Gamma }\mathrm{\Gamma }_0^+`$ is the set defined in Proposition 31. The inclusion $`\mathrm{\Gamma }_0^{}\mathrm{\Gamma }_0^+`$ defines a natural projection $`\pi :\mathrm{\Gamma }_0^{}\mathrm{\Gamma }_0^{}`$ and a mapping $`h_0^{}:\mathrm{\Gamma }_0^{}M`$ by $`h_0^{}=h_0\pi `$. Consider the equation with constraints $`\pi ^{}(E)`$, this is a node in the search graph, because the size of $`\mathrm{\Gamma }`$ is linear in $`d`$.

The reason to switch from $`\mathrm{\Gamma }_0`$ to $`\mathrm{\Gamma }_0^{}`$ is that, due to the constraints, the word $`w_0`$ may have long free intervals, even in a minimal solution. Over $`\mathrm{\Gamma }_0^{}`$ long free intervals can be avoided. Formally, we replace $`w_0`$ by a solution $`w_0^{}`$ where $`w_0^{}\mathrm{\Gamma }^{}`$. The definition of $`w_0^{}`$ is based on a factorization of $`w_0`$ in maximal free intervals. There is a unique sequence $`0=\alpha _0<\alpha _1<\mathrm{}<\alpha _k=m_0`$ such that $`[\alpha _{i1},\alpha _i]`$ is a maximal free interval for each $`1ik`$ and

$$w_0=w_0[\alpha _0,\alpha _i]\mathrm{}w_0[\alpha _{k1},\alpha _k].$$

Note that all cuts occur as some $`\alpha _p`$, therefore we can think of the factors $`w_0[\alpha _{i1},\alpha _i]`$ as letters in $`\mathrm{\Gamma }`$ for $`1ik`$. Moreover, all constants which appear in $`L_0R_0`$ are elements of $`\mathrm{\Gamma }`$. We replace $`w_0`$ by the word $`w_0^{}\mathrm{\Gamma }^{}`$. Then we can define $`\sigma :\mathrm{\Omega }\mathrm{\Gamma }^{}`$ such that both $`\sigma (L_0)=\sigma (R_0)=w_0^{}`$ and $`\rho _0=h_0^{}\sigma `$. In other terms, $`\sigma `$ is a solution of $`\pi ^{}(E_0)`$. We have $`w_0=\pi (w_0^{})`$ and $`\mathrm{exp}(w_0^{})\mathrm{exp}(w_0)`$. The crucial point is that $`w_0^{}`$ has no long free intervals anymore. With respect to $`w_0^{}`$ and $`\mathrm{\Gamma }_0^{}`$ all maximal free intervals have length exactly one.

In the next step we show that we can reduce the alphabet of constants to be $`\mathrm{\Gamma }`$. The inclusion of $`\mathrm{\Gamma }`$ in $`\mathrm{\Gamma }_{}^{}{}_{0}{}^{}`$ defines an admissible base change $`\beta :\mathrm{\Gamma }\mathrm{\Gamma }_{}^{}{}_{0}{}^{}`$. Consider $`E_0^{}=(\mathrm{\Gamma },h,\mathrm{\Omega }_0,\rho _0;L_0=R_0)`$ where $`h`$ is the restriction of the mapping $`h_0^{}`$. Then we have $`\pi ^{}(E_0)=\beta _{}(E_0^{})`$. The search graph contains an arc from $`E_0`$ to $`E_0^{}`$, since we may choose $`\delta `$ to be the identity. The equation with constraints $`E_0^{}`$ has a solution $`\sigma `$ with $`\sigma (L_0)=w_0^{}`$ and $`\mathrm{exp}(w_0^{})\mathrm{exp}(w_0)`$.

In order to avoid too many notations we identify $`E_0`$ and $`E_0^{}`$, hence we also assume $`w_0=w_0^{}`$. However, as a reminder that we have changed the alphabet of constants (recall that some words became letters), we prefer to use the notation $`\mathrm{\Gamma }`$ rather than $`\mathrm{\Gamma }_0`$. Thus, in what follows we shall make the following assumptions:

$`E_0`$ $`=`$ $`(\mathrm{\Gamma },h,\mathrm{\Omega }_0,\rho _0;L_0=R_0),`$
$`L_0`$ $`=`$ $`x_1\mathrm{}x_g\text{ and }g2,`$
$`R_0`$ $`=`$ $`x_{g+1}\mathrm{}x_d\text{ and }d>g,`$
$`|\mathrm{\Gamma }|`$ $``$ $`2d2,`$
$`|\mathrm{\Omega }_0|`$ $``$ $`2d,`$
$`M`$ $``$ $`𝔹^{2n\times 2n}.`$
Moreover: All variables $`X`$ occur in $`L_0R_0\overline{L_0R_0}`$. There is a solution $`\sigma `$ such that $`w_0=\sigma (L_0)=\sigma (R_0)`$ with $`\sigma (X_i)1`$ for $`1id`$ and $`\rho _0=h\sigma =h_0\sigma `$. We have $`|w_0|=m_0`$ and $`\mathrm{exp}(w_0)2^{𝒪(d+n\mathrm{log}n)}`$. All maximal free intervals have length exactly one, i.e., every positive interval $`[\alpha ,\beta ]`$ with $`\beta \alpha >1`$ contains an implicit cut.

It is because of the last sentence that we have worked out the details about free intervals. This difficulty is due to the constraints. Without them the reasoning would have been much simpler. But the good news are that from now on, the presence of constraints will not interfere very much.

###### Example 32

Following Example 27, we use the same equation $`aX\overline{X}\overline{a}=Y\overline{b}Y\overline{a}b\overline{Y}`$ and we consider the solution $`w_0`$.

The new solution is defined by replacing in $`w_0`$ each factor $`bc`$ by a new letter $`d`$ which represents a maximal free interval. The new $`w_0`$ has the form

$$w_0=\stackrel{0}{|}a\stackrel{1}{|}d\overline{d}\stackrel{3}{|}\overline{b}\stackrel{4}{|}ad\stackrel{6}{|}\overline{d}\stackrel{7}{|}\overline{a}\stackrel{8}{|}b\stackrel{9}{|}d\overline{d}\stackrel{11}{|}\overline{a}\stackrel{12}{|}.$$

Now all maximal intervals have length one.

## 13 Critical Words and Blocks

In the following $`\mathrm{}`$ denotes an integer which varies between $`1`$ and $`m_0`$. For each $`\mathrm{}`$ we define the set of critical words $`C_{\mathrm{}}`$ by

$$C_{\mathrm{}}=\{w_0[\gamma \mathrm{},\gamma +\mathrm{}],w_0[\gamma +\mathrm{},\gamma \mathrm{}]\gamma \mathrm{is}\mathrm{a}\mathrm{cut}\mathrm{and}\mathrm{}\gamma m_0\mathrm{}\}.$$

We have $`1|C_{\mathrm{}}|2d4`$ and $`C_{\mathrm{}}`$ is closed under involution. Each word $`uC_{\mathrm{}}`$ has length $`2\mathrm{}`$, it can be written in the form $`u=u_1u_2`$ with $`|u_1|=|u_2|=\mathrm{}`$. Then $`u_1`$ (resp. $`\overline{u_2}`$) appears as a suffix, left of some cut and $`u_2`$ (resp. $`\overline{u_1}`$) appears as a prefix, right of the same cut.

A triple $`(u,w,v)(\{1\}\mathrm{\Gamma }^{\mathrm{}})\times \mathrm{\Gamma }^+\times (\{1\}\mathrm{\Gamma }^{\mathrm{}})`$ is called a block if first, up to a possible prefix or suffix no other factor of the word $`uwv`$ is a critical word, second, $`u1`$ if and only if a prefix of $`uwv`$ of length $`2\mathrm{}`$ belongs to $`C_{\mathrm{}}`$, and third, $`v1`$ if and only if a suffix of $`uwv`$ of length $`2\mathrm{}`$ belongs to $`C_{\mathrm{}}`$. The set of blocks is denoted by $`B_{\mathrm{}}`$. It is viewed (as a possibly infinite) alphabet where the involution is defined by $`\overline{(u,w,v)}=(\overline{v},\overline{w},\overline{u})`$. We can define a homomorphism $`\pi _{\mathrm{}}:B_{\mathrm{}}^{}\mathrm{\Gamma }^{}`$ by $`\pi _{\mathrm{}}(u,w,v)=w\mathrm{\Gamma }^+`$ being extended to a projection $`\pi _{\mathrm{}}:(B_{\mathrm{}}\mathrm{\Gamma })^{}\mathrm{\Gamma }^{}`$ by leaving $`\mathrm{\Gamma }`$ invariant. We define $`h_{\mathrm{}}:(B_{\mathrm{}}\mathrm{\Gamma })M`$ by $`h_{\mathrm{}}=h\pi _{\mathrm{}}`$. In the following we shall consider finite subsets $`\mathrm{\Gamma }_{\mathrm{}}B_{\mathrm{}}\mathrm{\Gamma }`$ which are closed under involution. Then by $`\pi _{\mathrm{}}:\mathrm{\Gamma }_{\mathrm{}}^{}\mathrm{\Gamma }^{}`$ and $`h_{\mathrm{}}:\mathrm{\Gamma }_{\mathrm{}}^{}M`$ we understand the restrictions of the respective homomorphisms.

For every non-empty word $`w\mathrm{\Gamma }^+`$ we define its $`\mathrm{}`$-factorization as follows. We write

$$F_{\mathrm{}}(w)=(u_1,w_1,v_1)\mathrm{}(u_k,w_k,v_k)B_{\mathrm{}}^+$$

such that $`w=w_1\mathrm{}w_k`$ and for $`1ik`$ the following conditions are satisfied:

* $`v_i`$ is a prefix of $`w_{i+1}\mathrm{}w_k`$,
* $`v_i=1`$ if and only if $`i=k`$,
* $`u_i`$ is a suffix of $`w_1\mathrm{}w_{i1}`$,
* $`u_i=1`$ if and only if $`i=1`$.

Note that the $`\mathrm{}`$-factorization of a word $`w`$ is unique. For $`k2`$ we have $`|w_1|\mathrm{}`$ and $`|w_k|\mathrm{}`$, but all other $`w_i`$ may be short. If no critical word appears as a factor of $`w`$, then $`F_{\mathrm{}}(w)=(1,w,1)`$. In particular, this is the case for $`|w|<2\mathrm{}`$. If we have $`w=puvq`$ with $`|u|=|v|=\mathrm{}`$ and $`uvC_{\mathrm{}}`$, then there is a unique $`i\{1,\mathrm{},k1\}`$ such that $`u=u_{i+1}`$, $`v=v_i`$, and $`pu=w_1\mathrm{}w_i`$, $`vq=w_{i+1}\mathrm{}w_k`$. Thus, $`F_{\mathrm{}}(w)`$ contains a factor $`(u_i,w_i,v)(u,w_{i+1},v_{i+1})`$ where $`v`$ is a prefix of $`w_{i+1}v_{i+1}`$ and $`u`$ is a suffix of $`u_iw_i`$. For example, the $`\mathrm{}`$-factorization of $`uvC_{\mathrm{}}`$ with $`|u|=|v|=\mathrm{}`$ is

$$F_{\mathrm{}}(uv)=(1,u,v)(u,v,1).$$

We define the $`\mathrm{head}`$, $`\mathrm{body}`$, and $`\mathrm{tail}`$ of a word $`w`$ based on its $`\mathrm{}`$-factorization

$$F_{\mathrm{}}(w)=(u_1,w_1,v_1)\mathrm{}(u_k,w_k,v_k)$$

in $`B_{\mathrm{}}^{}`$ and $`\mathrm{\Gamma }^{}`$ as follows:

$`\mathrm{Head}_{\mathrm{}}(w)`$ $`=`$ $`(u_1,w_1,v_1)B_{\mathrm{}},`$
$`\mathrm{head}_{\mathrm{}}(w)`$ $`=`$ $`w_1\mathrm{\Gamma }^+,`$
$`\mathrm{Body}_{\mathrm{}}(w)`$ $`=`$ $`(u_2,w_2,v_2)\mathrm{}(u_{k1},w_{k1},v_{k1})B_{\mathrm{}}^{},`$
$`\mathrm{body}_{\mathrm{}}(w)`$ $`=`$ $`w_2\mathrm{}w_{k1}\mathrm{\Gamma }^{},`$
$`\mathrm{Tail}_{\mathrm{}}(w)`$ $`=`$ $`(u_k,w_k,v_k)B_{\mathrm{}},`$
$`\mathrm{tail}_{\mathrm{}}(w)`$ $`=`$ $`w_k\mathrm{\Gamma }^+.`$
For $`k2`$ (in particular, if $`\mathrm{body}_{\mathrm{}}(w)1`$) we have

$`F_{\mathrm{}}(w)`$ $`=`$ $`\mathrm{Head}_{\mathrm{}}(w)\mathrm{Body}_{\mathrm{}}(w)\mathrm{Tail}_{\mathrm{}}(w),`$
$`w`$ $`=`$ $`\mathrm{head}_{\mathrm{}}(w)\mathrm{body}_{\mathrm{}}(w)\mathrm{tail}_{\mathrm{}}(w).`$
Moreover, $`u_2`$ is a suffix of $`w_1`$ and $`v_{k1}`$ is a prefix of $`w_k`$.

Assume $`\mathrm{body}_{\mathrm{}}(w)1`$ and let $`u,v\mathrm{\Gamma }^{}`$ be any words. Then we can view $`w`$ in the context $`uwv`$ and $`\mathrm{Body}_{\mathrm{}}(w)`$ appears as a proper factor in the $`\mathrm{}`$-factorization of $`uwv`$. More precisely, let

$$F_{\mathrm{}}(uwv)=(u_1,w_1,v_1)\mathrm{}(u_k,w_k,v_k).$$

Then there are unique $`1p<qk`$ such that:

$`F_{\mathrm{}}(uwv)`$ $`=`$ $`(u_1,w_1,v_1)\mathrm{}(u_p,w_p,v_p)\mathrm{Body}_{\mathrm{}}(w)(u_q,w_q,v_q)\mathrm{}(u_k,w_k,v_k),`$
$`w_1\mathrm{}w_p`$ $`=`$ $`u\mathrm{head}_{\mathrm{}}(w),`$
$`w_q\mathrm{}w_k`$ $`=`$ $`\mathrm{tail}_{\mathrm{}}(w)v`$
Finally, we note that the above definitions are compatible with the involution. We have $`F_{\mathrm{}}(\overline{w})=\overline{F_{\mathrm{}}(w)}`$, $`\mathrm{Head}_{\mathrm{}}(\overline{w})=\overline{\mathrm{Tail}_{\mathrm{}}(w)}`$, and $`\mathrm{Body}_{\mathrm{}}(\overline{w})=\overline{\mathrm{Body}_{\mathrm{}}(w)}`$.

## 14 The $`\mathrm{}`$-Transformation

Our equation with constraints is $`E_0=(\mathrm{\Gamma },h,\mathrm{\Omega }_0,\rho _0;x_1\mathrm{}x_g=x_{g+1}\mathrm{}x_d).`$ We start with the $`\mathrm{}`$-factorization of $`w_0=\sigma (x_1\mathrm{}x_g)=\sigma (x_{g+1}\mathrm{}x_d)`$. Let

$$F_{\mathrm{}}(w_0)=(u_1,w_1,v_1)\mathrm{}(u_k,w_k,v_k).$$

A sequence $`S=(u_p,w_p,v_p)\mathrm{}(u_q,w_q,v_q)`$ with $`1pqk`$ is called an $`\mathrm{}`$-factor. We say that $`S`$ is a *cover* of a positive interval $`[\alpha ,\beta ]`$, if both $`|w_1\mathrm{}w_{p1}|\alpha `$ and $`|w_{q+1}\mathrm{}w_k|m_0\beta `$. Thus, $`w_0[\alpha ,\beta ]`$ becomes a factor of $`w_p\mathrm{}w_q`$. It is a minimal cover, if neither $`(u_{p+1},w_{p+1},v_{p+1})\mathrm{}(u_q,w_q,v_q)`$ nor $`(u_p,w_p,v_p)\mathrm{}(u_{q1},w_{q1},v_{q1})`$ is a cover of $`[\alpha ,\beta ]`$. The minimal cover exists and it is unique.

We let $`\mathrm{\Omega }_{\mathrm{}}=\{X\mathrm{\Omega }_0\mathrm{body}_{\mathrm{}}(\sigma (X))1\}`$, and we are going to define a new left-hand side $`L_{\mathrm{}}(B_{\mathrm{}}\mathrm{\Omega }_{\mathrm{}})^{}`$ and a new right-hand side $`R_{\mathrm{}}(B_{\mathrm{}}\mathrm{\Omega }_{\mathrm{}})^{}`$. For $`L_{\mathrm{}}`$ we consider those $`1ig`$ where $`\mathrm{body}_{\mathrm{}}(\sigma (x_i))1`$. Note that this implies $`x_i\mathrm{\Omega }_{\mathrm{}}`$ since $`\mathrm{}1`$ and then the $`\mathrm{body}`$ of a constant is always empty. Recall the definition of $`\mathrm{l}(i)`$ and $`\mathrm{r}(i)`$, and define $`\alpha =\mathrm{l}(i)+|\mathrm{head}_{\mathrm{}}(\sigma (x_i))|`$ and $`\beta =\mathrm{r}(i)|\mathrm{tail}_{\mathrm{}}(\sigma (x_i))|`$. Then we have $`w_0[\alpha ,\beta ]=\mathrm{body}_{\mathrm{}}(\sigma (x_i))`$. Next consider the $`\mathrm{}`$-factor $`S_i=(u_p,w_p,v_p)\mathrm{}(u_q,w_q,v_q)`$ which is the minimal cover of $`[\alpha ,\beta ]`$. Then we have $`1<pq<k`$ and $`w_p\mathrm{}w_q=w_0[\alpha ,\beta ]=\mathrm{body}_{\mathrm{}}(\sigma (x_i))`$. The definition of $`S_i`$ depends only on $`x_i`$, but not on the choice of the index $`i`$.

We replace the $`\mathrm{}`$-factor $`S_i`$ in $`F_{\mathrm{}}(w_0)`$ by the variable $`x_i`$. Having done this for all $`1ig`$ with $`\mathrm{body}_{\mathrm{}}(\sigma (x_i))1`$ we obtain the left-hand side $`L_{\mathrm{}}(B_{\mathrm{}}\mathrm{\Omega }_{\mathrm{}})^{}`$ of the $`\mathrm{}`$-transformation $`E_{\mathrm{}}`$. For $`R_{\mathrm{}}`$ we proceed analogously by replacing those $`\mathrm{}`$-factors $`S_i`$ where $`\mathrm{body}_{\mathrm{}}(\sigma (x_i))1`$ and $`g+1id`$.

For $`E_{\mathrm{}}`$ we cannot use the alphabet $`B_{\mathrm{}}`$, because it might be too large or even infinite. Therefore we let $`\mathrm{\Gamma }_{\mathrm{}^{}}`$ be the smallest subset of $`B_{\mathrm{}}`$ which is closed under involution and which satisfies $`L_{\mathrm{}}R_{\mathrm{}}(\mathrm{\Gamma }_{\mathrm{}^{}}\mathrm{\Omega }_{\mathrm{}})^{}`$. We let $`\mathrm{\Gamma }_{\mathrm{}}=\mathrm{\Gamma }_{\mathrm{}^{}}\mathrm{\Gamma }`$. The projection $`\pi _{\mathrm{}}:\mathrm{\Gamma }_{\mathrm{}}^{}\mathrm{\Gamma }^{}`$ and the mapping $`h_{\mathrm{}}:\mathrm{\Gamma }_{\mathrm{}}M`$ are defined by the restriction of $`\pi _{\mathrm{}}:B_{\mathrm{}}\mathrm{\Gamma }^{}`$, $`\pi _{\mathrm{}}(u,w,v)=w`$ and $`h_{\mathrm{}}(u,w,v)=h(w)M`$ and by $`\pi _{\mathrm{}}(a)=a`$ and $`h_{\mathrm{}}(a)=h(a)`$ for $`a\mathrm{\Gamma }`$.

Finally, we define the mapping $`\rho _{\mathrm{}}:\mathrm{\Omega }_{\mathrm{}}M`$ by $`\rho _{\mathrm{}}(X)=h(\mathrm{body}_{\mathrm{}}(\sigma (X)))`$. This completes the definition of the $`\mathrm{}`$-transformation:

$$E_{\mathrm{}}=(\mathrm{\Gamma }_{\mathrm{}},h_{\mathrm{}},\mathrm{\Omega }_{\mathrm{}},\rho _{\mathrm{}};L_{\mathrm{}}=R_{\mathrm{}}).$$

###### Remark 33

One can verify that $`\sigma _{\mathrm{}}:\mathrm{\Omega }_{\mathrm{}}\mathrm{\Gamma }_{\mathrm{}}^{}`$, $`\sigma _{\mathrm{}}(X)=\phi _{\mathrm{}}(\mathrm{Body}_{\mathrm{}}(\sigma (X)))`$ defines a solution of $`E_{\mathrm{}}`$, where $`\phi _{\mathrm{}}`$ is the identity on $`\mathrm{\Gamma }_{\mathrm{}}`$ and $`\pi _{\mathrm{}}`$ on $`B_{\mathrm{}}\mathrm{\Gamma }_{\mathrm{}^{}}`$. Although, up to the trivial case $`\mathrm{}=m_0`$, we make no explicit use of this fact.

###### Example 34

We continue with our example $`aX\overline{X}\overline{a}=Y\overline{b}Y\overline{a}b\overline{Y}`$ and the solution $`\sigma `$ which has been given by

$$w_0=ad\overline{d}\overline{b}ad\overline{d}\overline{a}bd\overline{d}\overline{a},$$

where the bars show the cuts.

Up to involution, the set $`C_1`$ is given by $`\{ad,bd,\overline{a}b,d\overline{d}\}`$ and $`C_2`$ is given by $`\{d\overline{d}\overline{b}a,\overline{d}\overline{b}ad,ad\overline{d}\overline{a},d\overline{d}\overline{a}b\}`$. The 1-factorization of $`w_0`$ can be obtained letter by letter. The 2-factorization of $`w_0`$ is given by the following sequence:

$$(1,ad\overline{d},\overline{b}a)(d\overline{d},\overline{b},ad)(\overline{d}\overline{b},ad,\overline{d}\overline{a})(ad,\overline{d},\overline{a}b)(d\overline{d},\overline{a},bd)(\overline{d}\overline{a},b,d\overline{d})(\overline{a}b,d\overline{d}a,1).$$

Recall $`\sigma (X)=d\overline{d}\overline{b}ad`$ and $`\sigma (Y)=ad\overline{d}`$. Hence their 2-factorizations are $`(1,ad\overline{d},\overline{b}a)(d\overline{d},\overline{b},ad)(\overline{d}\overline{b},ad,1)`$ and $`(1,ad\overline{d},1)`$, respectively.

By renaming letters, the 2-factorization of $`w_0`$ becomes $`a\overline{b}cdeb\overline{a}`$ and the equation $`E`$ reduces to $`E_2:aXcdeX\overline{a}=a\overline{b}cdeb\overline{a}`$ since the body of $`\sigma (Y)`$ is empty.

The reader can check that the 3-factorization of $`w_0`$ after renaming is the very same word as the 2-factorization, but the 3-factorization of $`\sigma (X)`$ is now one letter, $`(1,d\overline{d}\overline{b}ad,1)`$, so $`E_3`$ becomes a trivial equation. Plandowski’s algorithm will return true at this stage.

###### Remark 35

i) In the extreme case $`\mathrm{}=m_0`$, the $`\mathrm{}`$-transformation becomes trivial. Let $`a=(1,w_0,1)`$. Then $`\overline{a}=(1,\overline{w_0},1)`$ and $`\mathrm{\Gamma }_{m_0}=\{a,\overline{a}\}\mathrm{\Gamma }`$. Moreover, we have $`L_{m_0}=R_{m_0}=a`$, and $`h_{m_0}(a)=h(w_0)M`$. Since $`\mathrm{\Omega }_{m_0}=\mathrm{}`$, the equation with constraints $`E_{m_0}`$ has trivially a solution. It is clear that $`E_{m_0}`$ is a node in the search graph, and if we reach $`E_{m_0}`$, then the algorithm will return true.

ii) The other extreme case is $`\mathrm{}=1`$. The situation again is simple, but the precise definition is technically more involved. Consider a block $`(u,w,v)`$ which appears in $`F_1(w_0)`$. Then $`w=w_0[\alpha ,\beta ]`$ for some $`\beta \alpha 1`$. We cannot have $`\beta \alpha 2`$, because then $`[\alpha ,\beta ]`$ would have an implicit cut $`\gamma `$, but $`w_0[\gamma 1,\gamma +1]C_1`$ and no critical word is a factor of $`w`$. An immediate consequence is $`|\mathrm{\Gamma }_1|(|\mathrm{\Gamma }|+1)^3𝒪(d^3)`$. Let $`X\mathrm{\Omega }_0`$. Then $`\mathrm{Body}_1(\sigma (X))1`$ if and only if $`|\sigma (X)|3`$. Thus, for $`X\mathrm{\Omega }_1`$ we have $`\sigma (X)=bcu=vde`$ with $`b,c,d,e\mathrm{\Gamma }`$ and $`u,v\mathrm{\Gamma }^+`$. It follows:

$$F_1(\sigma (X))=(1,b,c)(b,c,v_2)\mathrm{}(u_{|v|+1},d,e)(d,e,1).$$

For example, for $`|v|=1`$ this means $`b=u_{|v|+1}`$, $`c=d`$, and $`v_2=e`$.

We can describe $`L_1\mathrm{\Gamma }_1^{}`$ as follows:

For $`1ig`$ let $`w_i=\sigma (x_i)`$ and $`a_i`$ the last letter of $`\sigma (x_{i1})`$ if $`i>1`$ and $`a_1=1`$. Let $`f_i`$ the first letter of $`\sigma (x_{i+1})`$ if $`i<g`$ and $`f_g=1`$. Let $`b_i`$ the first letter of $`w_i`$ and $`e_i`$ the last letter of $`w_i`$.

For $`|w_i|=1`$ we replace $`x_i`$ by the $`1`$-factor $`(a_i,b_i,f_i)`$.

For $`|w_i|=2`$ we replace $`x_i`$ by the $`1`$-factor $`(a_i,b_i,e_i)(b_i,e_i,f_i)`$.

For $`|w_i|3`$ we let $`c_i`$ be the second letter of $`w_i`$ and $`d_i`$ its second last. In this case we replace $`x_i`$ by $`(a_i,b_i,c_i)x_i(d_i,e_i,f_i)`$.

The definition of $`R_1`$ is analogous. Thus, we obtain $`|L_1R_1|3|L_0R_0|=3d`$, and $`E_1`$ is admissible. We also see that there was an overestimation of the size of $`|\mathrm{\Gamma }_1|`$. For each $`x_i`$ we need at most two constants together with their involutions. Since $`\mathrm{\Gamma }_1`$ contains also $`\mathrm{\Gamma }`$, we obtain $`|\mathrm{\Gamma }_1|6d`$.

By the remark above, $`E_1`$ and $`E_{m_0}`$ are admissible and hence nodes of the search graph. The goal is to reach $`E_{m_0}`$ via $`E_1`$ when starting with $`E_0`$. For the moment it is even not clear that the $`\mathrm{}`$-transformations with $`1<\mathrm{}<m_0`$ belongs to the search graph. We prove this statement in the next section.

## 15 The $`\mathrm{}`$-transformation $`E_{\mathrm{}}`$ is admissible

###### Proposition 36

There is a polynomial $`p`$ (of degree at most 4) such that each $`E_{\mathrm{}}`$ is admissible for all $`\mathrm{}1`$.

Proof. It is enough to show that $`L_{\mathrm{}}`$ and $`R_{\mathrm{}}`$ can be represented by exponential expressions of size $`𝒪(d^2(d+n\mathrm{log}n))`$. Then $`\mathrm{\Gamma }_{\mathrm{}}`$ can have size at most $`𝒪(d^2(d+n\mathrm{log}n))`$ and the assertion follows. We will estimate the size of an exponential expression for $`L_{\mathrm{}}`$, only.

We start again with the $`\mathrm{}`$-transformation of

$$F_{\mathrm{}}(w_0)=(u_1,w_1,v_1)\mathrm{}(u_k,w_k,v_k).$$

If $`k`$ is small there is nothing to do since $`|L_{\mathrm{}}||F_{\mathrm{}}(w_0)|`$. An easy reflection shows that $`|L_{\mathrm{}}|`$ can become large, only if there is some $`1ig`$ such that $`\mathrm{head}_{\mathrm{}}(\sigma (x_i))`$ or $`\mathrm{tail}_{\mathrm{}}(\sigma (x_i))`$ is long. By symmetry we treat the case $`\mathrm{head}_{\mathrm{}}(\sigma (x_i))`$ only and we fix some notation. We let $`1ig`$, $`\alpha =\mathrm{l}(i)`$, and $`\beta =\alpha +|\mathrm{head}_{\mathrm{}}(\sigma (x_i))|`$. Let

$$(u_{p1},w_{p1},v_{p1})\mathrm{}(u_{q+1},w_{q+1},v_{q+1})$$

be a minimal cover of $`[\alpha ,\beta ]`$. We may assume that $`qp`$ is large. It is enough to find an exponential expression for the $`\mathrm{}`$-factor

$$(u_p,w_p,v_p)\mathrm{}(u_q,w_q,v_q)$$

having size in $`𝒪(d(d+n\mathrm{log}n))`$, because we want the whole expression to have size in $`𝒪(d^2(d+n\mathrm{log}n))`$.

Note that $`w_p\mathrm{}w_q`$ is a proper factor of $`\mathrm{head}_{\mathrm{}}(\sigma (x_i))`$. Hence no critical word of $`C_{\mathrm{}}`$ can appear as a factor inside $`w_p\mathrm{}w_q`$. This means there is some $`psq`$ such that both $`|w_p\mathrm{}w_{s1}|<\mathrm{}`$ and $`|w_{s+1}\mathrm{}w_q|<\mathrm{}`$. Indeed, if $`|w_p\mathrm{}w_{q1}|<\mathrm{}`$, then we choose $`s=q`$. Otherwise we let $`psq`$ be minimal such that $`|w_p\mathrm{}w_s|\mathrm{}`$. Then $`|w_{s+1}\mathrm{}w_q|\mathrm{}`$ is impossible because $`u_{s+1}v_sC_{\mathrm{}}`$ would appear as a factor in $`w_p\mathrm{}w_q`$. We can write

$$(u_p,w_p,v_p)\mathrm{}(u_q,w_q,v_q)=S_1(u_s,w_s,v_s)S_2;$$

and since $`(u_s,w_s,v_s)\mathrm{\Gamma }_{\mathrm{}}`$ is a letter, it is enough to find exponential expressions for $`S_i`$, $`i=1,2`$, of size $`𝒪(d(d+n\mathrm{log}n))`$ each. As a conclusion it is enough to prove the following lemma. $`\mathrm{}`$

The statement of the next lemma is slightly more general as we need it above. There we need the lemma for $`c=1`$, but later we will apply the lemma with values $`c32d`$.

###### Lemma 37

Let $`c>0`$ be a number and

$$S=(u_1,w_1,v_1)\mathrm{}(u_k,w_k,v_k)B_{\mathrm{}}^{}$$

be a sequence which appears as some $`\mathrm{}`$-factor in $`F_{\mathrm{}}(w_0)`$. If we have $`k3`$ or $`|w_2\mathrm{}w_{k1}|c\mathrm{}`$, then we can represent the sequence by some exponential expression of size $`𝒪(cd(d+n\mathrm{log}n))`$.

Proof. We show that there is an exponential expression of size $`𝒪(d(d+n\mathrm{log}n))`$ under the assumption $`|w_1\mathrm{}w_k|<\mathrm{}`$. This is enough, because we always can write $`S`$ as $`a_0S_1a_1\mathrm{}S_c^{}a_c^{}`$, where $`c^{}c`$, the $`a_i`$ are letters, and each $`S_i`$ satisfies the assumption. Note that the assumption implies $`u_11v_k`$ and we may define $`u_{k+1}`$ as the suffix of length $`\mathrm{}`$ of $`u_1w_1\mathrm{}w_k`$. For $`1ik`$ let $`z_i=u_{i+1}v_i`$. Then $`z_iC_{\mathrm{}}`$ is a critical word which appears as a factor in $`z=u_1w_1w_2\mathrm{}w_kv_k`$. If the words $`z_i`$, $`1i<k`$ are pairwise different, then $`k1|C_{\mathrm{}}|𝒪(d)`$ and we are done. Hence we may assume that there are repetitions. Let $`j`$ be the smallest index such that a critical word is seen for the second time and let $`i<j`$ be the first appearance of $`z_j`$. This means for $`1i<j`$ the words $`z_1,\mathrm{},z_{j1}`$ are pairwise different and $`z_i=z_j`$. Now, $`|w_1\mathrm{}w_k|<\mathrm{}`$ and $`|z_i|=2\mathrm{}`$, hence $`z_i`$ and $`z_j`$ overlap in $`z`$. We can choose $`r`$ maximal such that $`u_1w_1\mathrm{}w_i(w_{i+1}\mathrm{}w_j)^rv_j`$ is a prefix of the word $`z`$. (Note that the last factor $`v_j`$ insures that the prefix ends with $`z_j`$). For some index $`s>j`$ we can write

$$z=u_1w_1\mathrm{}w_i(w_{i+1}\mathrm{}w_j)^rw_s\mathrm{}w_kv_k.$$

We claim that $`z_i\{z_s,\mathrm{},z_k\}`$. Indeed, let $`t`$ be maximal such that $`z_i=z_t`$ and assume that $`jt`$. Then both $`|w_{i+1}\mathrm{}w_j|`$ and $`|w_{j+1}\mathrm{}w_t|`$ are periods of $`z_i`$, but $`|w_{i+1}\mathrm{}w_t||z|`$. Hence by Fine and Wilf’s Theorem  we obtain that the greatest common divisor of $`|w_{i+1}\mathrm{}w_j|`$ and $`|w_{j+1}\mathrm{}w_t|`$ is a period, too. Due to the definition of an $`\mathrm{}`$-factorization ($`z_j`$ was the first repetition) the length $`|w_{j+1}\mathrm{}w_t|`$ is therefore a multiple of $`|w_{i+1}\mathrm{}w_j|`$ and we must have $`t=s1`$. This shows the claim. Moreover, we have

$`(u_1,w_1,v_1)\mathrm{}(u_k,w_k,v_k)`$
$`=`$ $`(u_1,w_1,v_1)\mathrm{}(u_i,w_i,v_i)[(u_{i+1},w_{i+1},v_{i+1})\mathrm{}(u_j,w_j,v_j)]^rS^{}`$
where $`S^{}=(u_s,w_s,v_s)\mathrm{}(u_k,w_k,v_k)`$ for $`s=i+1+r(ji)`$. We have $`r\mathrm{exp}(w_0)`$, hence $`r2^{𝒪(d+n\mathrm{log}n)}`$. It follows that

$$(u_1,w_1,v_1)\mathrm{}(u_i,w_i,v_i)[(u_{i+1},w_{i+1},v_{i+1})\mathrm{}(u_j,w_j,v_j)]^r$$

is an exponential expression of size $`j+\mathrm{log}(r)𝒪(d+n\mathrm{log}n)`$. More precisely, for some suitable constant $`\stackrel{~}{c}`$ its size is at most $`\stackrel{~}{c}(d+n\mathrm{log}n)`$. The constant $`\stackrel{~}{c}`$ depends only on the constant which is hidden when writing $`\mathrm{exp}(w_0)2^{𝒪(d+n\mathrm{log}n)}`$. By induction on the size of the set $`\{z_1,\mathrm{},z_k\}`$ we may assume that $`S^{}=(u_s,w_s,v_s)\mathrm{}(u_k,w_k,v_k)`$ has an exponential expression of size at most $`|\{z_s,\mathrm{},z_k\}|\stackrel{~}{c}(d+n)`$. Hence the exponential expression for $`S`$ has size at most

$$\stackrel{~}{c}(d+n\mathrm{log}n)+|\{z_s,\mathrm{},z_k\}|\stackrel{~}{c}(d+n\mathrm{log}n)|\{z_1,\mathrm{},z_k\}|\stackrel{~}{c}(d+n\mathrm{log}n).$$

Thus, the size is in $`𝒪(d(d+n\mathrm{log}n))`$. $`\mathrm{}`$

At this stage we know that all $`\mathrm{}`$-transformations are admissible (with respect to some suitable polynomial of degree 4). Thus $`E_1,\mathrm{},E_{m_0}`$ are nodes of the search graph. Next we show that the search graph contains arcs $`E_0E_1`$ and $`E_{\mathrm{}}E_{\mathrm{}^{}}`$ for $`1\mathrm{}<\mathrm{}^{}2\mathrm{}`$. Hence the graph contains a path (of logarithmic length in $`m_0`$) from $`E_0`$ to $`E_{m_0}`$. The non-deterministic procedure is able to find this path and on input $`E_0`$ Plandowski’s algorithm gives the correct answer.

In order to establish the existence of arcs from $`E_{\mathrm{}}`$ to $`E_{\mathrm{}^{}}`$ for $`0\mathrm{}<\mathrm{}^{}\mathrm{max}\{1,2\mathrm{}\}`$ we shall define intermediate equations $`E_\mathrm{},\mathrm{}^{}`$ such that there is an admissible base change $`\beta `$, a projection $`\pi `$, and a partial solution $`\delta `$ with

$$\delta _{}(\pi ^{}(E_{\mathrm{}}))E_\mathrm{},\mathrm{}^{}\beta _{}(E_{\mathrm{}^{}}).$$

## 16 The arc from $`E_0`$ to $`E_1`$

Recall the definition of $`E_1=(\mathrm{\Gamma }_1,h_1,\mathrm{\Omega }_1,\rho _1;L_1=R_1).`$ The letters of $`\mathrm{\Gamma }_1`$ can be written either as $`(a,b,c)`$ or as $`b`$ with $`a,c\mathrm{\Gamma }\{1\}`$ and $`b\mathrm{\Gamma }`$. We define a projection which is used here as a base change $`\beta :\mathrm{\Gamma }_1\mathrm{\Gamma }`$ by $`\beta (a,b,c)=b`$ and leaving the letters of $`\mathrm{\Gamma }`$ invariant. Clearly, $`h_1=h\beta `$, and $`\beta `$ defines an admissible base change. Define $`E_{0,1}=\beta _{}(E_1)`$. Then we have $`L_{0,1}=\beta (L_1)`$ and $`R_{0,1}=\beta (R_1)`$ where $`\beta :(\mathrm{\Gamma }_1\mathrm{\Omega }_1)^{}(\mathrm{\Gamma }\mathrm{\Omega }_1)^{}`$ is the extension with $`\beta (X)=X`$ for all $`X\mathrm{\Omega }_1`$. We have $`\mathrm{\Gamma }_{0,1}=\mathrm{\Gamma }`$

It is now obvious how to define the partial solution $`\delta :\mathrm{\Omega }_0\mathrm{\Gamma }\mathrm{\Omega }_1\mathrm{\Gamma }\mathrm{\Gamma }^{}`$ such that $`\delta _{}(E_0)=E_{0,1}`$. If $`|\sigma (X)|2`$, then we let $`\delta (X)=\sigma (X)`$. For $`|\sigma (X)|3`$ we write $`\sigma (X)=aub`$ with $`a,b\mathrm{\Gamma }`$ and $`u\mathrm{\Gamma }^+`$. Then we have $`X\mathrm{\Omega }_1=\mathrm{\Omega }_{0,1}`$ and we define $`\delta (X)=aXb`$ and $`\rho _{0,1}(X)=h(u)`$. For $`X\mathrm{\Omega }_1`$ we have $`\rho _1(X)=h(\mathrm{body}_1(\sigma (X)))`$, hence $`\rho _{0,1}=\rho _1`$, too. This shows that, indeed, $`\delta _{}(E_0)=\beta _{}(E_1)`$. Formally, we can write this as $`\delta _{}(\pi ^{}(E_0))=\beta _{}(E_1)`$, where $`\pi `$ is the identity. Hence there is an arc from $`E_0`$ to $`E_1`$.

## 17 The equations $`E_\mathrm{},\mathrm{}^{}`$ for $`1\mathrm{}<\mathrm{}^{}2\mathrm{}`$

In this section we define for each $`1\mathrm{}<\mathrm{}^{}2\mathrm{}`$ an intermediate equation with constraints

$$\beta _{}(E_{\mathrm{}^{}})=E_\mathrm{},\mathrm{}^{}=(\mathrm{\Gamma }_\mathrm{},\mathrm{}^{},h_\mathrm{},\mathrm{}^{},\mathrm{\Omega }_{\mathrm{}^{}},\rho _{\mathrm{}^{}};L_\mathrm{},\mathrm{}^{}=R_\mathrm{},\mathrm{}^{})$$

by some base change $`\beta :\mathrm{\Gamma }_{\mathrm{}^{}}(B_{\mathrm{}}\mathrm{\Gamma })^{}`$, then we show that $`\beta `$ is admissible.

Recall $`\mathrm{\Gamma }\mathrm{\Gamma }_{\mathrm{}^{}}B_{\mathrm{}^{}}\mathrm{\Gamma }`$. The base change $`\beta `$ leaves the letters of $`\mathrm{\Gamma }`$ invariant. Consider some $`(u,w,v)\mathrm{\Gamma }_{\mathrm{}^{}}\mathrm{\Gamma }`$. It is enough to define $`\beta (u,w,v)`$ or $`\beta (\overline{v},\overline{w},\overline{u})`$. Hence we may assume that $`(u,w,v)`$ appears as a letter in the $`\mathrm{}^{}`$-factorization $`F_{\mathrm{}^{}}(w_0)`$. Therefore we find a positive interval $`[\alpha ,\beta ]`$ such that $`w=w_0[\alpha ,\beta ]`$ and such that the following two conditions are satisfied:

1) We have $`u=1`$ and $`\alpha =0`$ or $`|u|=\mathrm{}^{}`$, $`\alpha \mathrm{}^{}`$, and $`u=w_0[\alpha \mathrm{}^{},\alpha ]`$.

2) We have $`v=1`$ and $`\beta =m_0`$ or $`|v|=\mathrm{}^{}`$, $`\beta m_0\mathrm{}^{}`$, and $`v=w_0[\beta ,\beta +\mathrm{}^{}]`$.

Let $`(u_p,w_p,v_p)\mathrm{}(u_q,w_q,v_q)`$ be the $`\mathrm{}`$-factor which is the minimal cover of $`[\alpha ,\beta ]`$ with respect to the $`\mathrm{}`$-factorization $`F_{\mathrm{}}(w_0)`$. Since $`\mathrm{}\mathrm{}^{}`$ we have $`w_p\mathrm{}w_q=w`$. Moreover, the word $`u_p`$ is a suffix of $`u`$ and $`v_q`$ is a prefix of $`v`$. We define

$$\beta (u,w,v)=(u_p,w_p,v_p)\mathrm{}(u_q,w_q,v_q)B_{\mathrm{}}^+.$$

The definition does not depend on the choice of $`[\alpha ,\beta ]`$ as long as $`0\alpha <\beta m_0`$ and 1) and 2) are satisfied. We have $`\overline{\beta (u,w,v)}=\beta (\overline{v},\overline{w},\overline{u})`$ and $`h_{\mathrm{}}\beta =h_{\mathrm{}^{}}`$. Now let $`\mathrm{\Gamma }_\mathrm{},\mathrm{}^{}B_{\mathrm{}}\mathrm{\Gamma }`$ be the smallest subset such that $`\beta (\mathrm{\Gamma }_{\mathrm{}^{}})\mathrm{\Gamma }_\mathrm{},\mathrm{}^{}^{}`$. Then $`\mathrm{\Gamma }_\mathrm{},\mathrm{}^{}`$ contains $`\mathrm{\Gamma }`$ and it is closed under involution (since $`\mathrm{\Gamma }_{\mathrm{}^{}}`$ has this property). A crucial, but easy reflection shows that $`\mathrm{\Gamma }_{\mathrm{}}\mathrm{\Gamma }_\mathrm{},\mathrm{}^{}`$. This will become essential later.

We view $`\beta `$ as a homomorphism $`\beta :\mathrm{\Gamma }_{\mathrm{}^{}}^{}\mathrm{\Gamma }_\mathrm{},\mathrm{}^{}^{}`$ and define $`E_\mathrm{},\mathrm{}^{}=\beta _{}(E_{\mathrm{}^{}})`$. Let us show that $`\beta `$ defines an admissible base change. Since $`E_{\mathrm{}^{}}`$ is already known to be admissible with respect to some polynomial of degree 4, it is enough to find some admissible exponential expression (again with respect to some polynomial of degree 4) for the $`\mathrm{}`$-factor

$$\beta (u,w,v)=(u_p,w_p,v_p)\mathrm{}(u_q,w_q,v_q)$$

where $`(u,w,v)\mathrm{\Gamma }_{\mathrm{}^{}}\mathrm{\Gamma }`$. We use the same notations as above. Thus, for some positive interval $`[\alpha ,\beta ]`$ we have $`w_p\mathrm{}w_q=w_0[\alpha ,\beta ]`$, the word $`u`$ is a suffix of $`w_0[0,\alpha ]`$, and $`v`$ is a prefix of $`w_0[\beta ,m_0]`$. If $`qp`$ is small, there is nothing to do. By Lemma 37 we may also assume that $`\beta \alpha >32d\mathrm{}`$. We are to define inductively a sequence of positions

$$\alpha =\alpha _0<\alpha _1<\mathrm{}<\alpha _i<\mathrm{}<\beta _i<\mathrm{}<\beta _1<\beta _0=\beta .$$

Each time we let $`W_i=w_0[\alpha _i,\beta _i]`$. Thus, $`W_0=w_p\mathrm{}w_q`$. Assume that $`W_i=w_0[\alpha _i,\beta _i]`$ is already defined such that $`\beta _i\alpha _i2`$. The interval $`[\alpha _i,\beta _i]`$ is not free. Hence, there is some implicit cut $`\gamma _i`$ with $`\alpha _i<\gamma _i<\beta _i`$. The word $`W_i`$ is a factor of $`w`$, hence no factor of $`W_i`$ belongs to the set of critical words $`C_{\mathrm{}^{}}`$. This implies $`\beta _i\gamma _i<\mathrm{}^{}`$ or $`\gamma _i\alpha _i<\mathrm{}^{}`$. If we have $`\beta _i\gamma _i<\mathrm{}^{}`$ then we let $`\alpha _{i+1}=\alpha _i`$ and $`\beta _{i+1}=\gamma _i`$. In the other case we let $`\alpha _{i+1}=\gamma _i`$ and $`\beta _{i+1}=\beta _i`$. Thus $`W_{i+1}`$ is defined such that $`W_{i+1}`$ is a proper factor of $`W_i`$ with $`|W_i||W_{i+1}|<\mathrm{}^{}`$.

We need some additional book keeping. We define $`r_i\{\mathrm{l},\mathrm{r}\}`$ by $`r_i=\mathrm{r}`$ if $`\beta _i=\beta _{i+1}`$ and $`r_i=\mathrm{l}`$ otherwise (i.e., $`\alpha _i=\alpha _{i+1}`$). Furthermore the implicit cut $`\gamma _i`$ corresponds to some real cut $`\gamma _i^{}`$ and $`\alpha _i^{}<\gamma _i^{}<\beta _i^{}`$ such that $`W_i=w_0[\alpha _i^{},\beta _i^{}]`$ or $`W_i=w_0[\beta _i^{},\alpha _i^{}]`$. We define $`s_i\{+,\}`$ by $`s_i=+`$ if $`W_i=w_0[\alpha _i^{},\beta _i^{}]`$ and $`s_i=`$ otherwise (in particular, $`s_i=`$ implies $`\overline{W_i}=w_0[\alpha _i^{},\beta _i^{}]`$). The triple $`(\gamma _i^{},r_i,s_i)`$ is denoted by $`\gamma (i)`$. There are at most $`4(d2)`$ such triples and $`\gamma (i)`$ is defined whenever $`W_{i+1}`$ is defined. We stop the induction procedure after the first repetition. Thus we find $`0i<j<4d`$ such that $`\gamma (i)=\gamma (j)`$. We obtain a sequence $`W_0,W_1,\mathrm{},W_i,\mathrm{},W_j`$ where each word is a proper factor of the preceding one. We have $`|W_0||W_j|<4d\mathrm{}^{}8d\mathrm{}`$ and due to $`|W_0|>32d\mathrm{}`$ the sequence above really exists, moreover $`|W_j|>8d\mathrm{}`$.

Next, we show that $`W_j`$ has a non-trivial overlap with itself. We treat the case $`\gamma (i)=\gamma (j)=(\gamma ,\mathrm{r},+)`$ only. The other three cases $`(\gamma ,\mathrm{r},)`$, $`(\gamma ,\mathrm{l},+)`$, and $`(\gamma ,\mathrm{l},)`$ can be treated analogously. For some $`\alpha ^{}<\gamma <\beta ^{}`$ we have $`W_i=w_0[\alpha ^{},\beta ^{}]`$ and $`W_{i+1}=w_0[\gamma ,\beta ^{}]`$. Thus, for some $`\gamma \mu <\nu \beta ^{}`$ we have $`W_j=w_0[\mu ,\nu ]`$ and we can assume that $`\mu \gamma <(ji)\mathrm{}^{}4d\mathrm{}^{}\mathrm{}^{}8d\mathrm{}\mathrm{}^{}`$. On the other hand we have $`\gamma (j)=(\gamma ,\mathrm{r},+)`$, too. Hence for some $`\mu ^{}<\gamma <\nu ^{}`$ with $`\gamma \mu ^{}<\mathrm{}^{}`$ we have $`W_j=w_0[\mu ^{},\nu ^{}]`$, too. Therefore $`0<\mu \mu ^{}<8d\mathrm{}`$ and $`W_j`$ has some non-trivial overlap. We can write $`W_j=W^eW^{}`$ such that $`1|W|<8d\mathrm{}`$ and $`W^{}`$ is a prefix of $`W`$.

Putting everything together, we arrive in all cases at a factorization $`W_0=UW^eV`$ with $`e\mathrm{exp}(w_0)`$, $`1|W|<8d\mathrm{}`$, and $`|U|+|V|<16d\mathrm{}`$. However, we have not finished yet. Recall that we are looking for an admissible exponential expression for

$$\beta (u,w,v)=(u_p,w_p,v_p)\mathrm{}(u_q,w_q,v_q).$$

Due to $`|W_0|>\mathrm{}`$ we can choose $`r`$ minimal, $`p<rq+1`$, and $`s`$ maximal $`p1s<q`$ such that $`|w_p\mathrm{}w_{r1}|>|U|+\mathrm{}`$ and $`|w_{s+1}\mathrm{}w_q|>|V|+\mathrm{}`$. By Lemma 37 we may assume $`r<s`$ and it is enough to find an exponential expression for

$$S=(u_r,w_r,v_r)\mathrm{}(u_s,w_s,v_s).$$

Note that the word $`u_rw_rw_{r+1}\mathrm{}w_sv_s`$ is a factor of $`W^e`$. Again, we may assume that $`w_rw_{r+1}\mathrm{}w_s>32d\mathrm{}`$. By switching to some conjugated word $`W^{}`$ if necessary, we may assume that $`u_rw_rw_{r+1}\mathrm{}w_sv_s`$ is a prefix of $`W^e`$. Moreover, by symmetry we may choose a positive interval $`[\alpha ,\beta ]`$ such that $`w_0[\alpha ,\beta ]=u_rw_rw_{r+1}\mathrm{}w_sv_s`$. Clearly, we have $`w_0[i,j]=w_0[i+|W|,j+|W|]`$ for all $`\alpha i<j\beta |W|`$. In particular, the critical word $`w_0[\alpha ,\alpha +2\mathrm{}]`$ appears as $`w_0[\alpha +|W|,\alpha +|W|+2\mathrm{}]`$ again. This means that there is some $`rt<s`$ such that $`|w_r\mathrm{}w_t|=|W|`$. More precisely, we can choose $`rt<t^{}s`$ and a maximal $`e^{}e`$ such that

$$S=\left((u_r,w_r,v_r)\mathrm{}(u_t,w_t,v_t)\right)^e^{}(u_t^{},w_t^{},v_t^{})\mathrm{}(u_s,w_s,v_s).$$

Since it holds $`e^{}\mathrm{exp}(w_0)`$, $`|w_r\mathrm{}w_t|=|W|`$, and $`|w_t^{}\mathrm{}w_s||W|`$, the existence of an admissible exponential expression for $`\beta (u,w,v)`$ follows. Hence $`\beta `$ is an admissible base change.

## 18 Passing from $`E_{\mathrm{}}`$ to $`E_\mathrm{},\mathrm{}^{}`$ for $`1\mathrm{}<\mathrm{}^{}2\mathrm{}`$

In the final step we have to show that there exists some projection $`\pi :\mathrm{\Gamma }_\mathrm{},\mathrm{}^{}^{}\mathrm{\Gamma }_{\mathrm{}}^{}`$ and some partial solution $`\delta :\mathrm{\Omega }_{\mathrm{}}\mathrm{\Gamma }_\mathrm{},\mathrm{}^{}^{}\mathrm{\Omega }_{\mathrm{}^{}}\mathrm{\Gamma }_\mathrm{},\mathrm{}^{}^{}\mathrm{\Gamma }_\mathrm{},\mathrm{}^{}^{}`$ such that $`\delta _{}(\pi ^{}(E_{\mathrm{}}))E_\mathrm{},\mathrm{}^{}`$. We don’t have to care about admissibility anymore.

For the projection we have to consider a letter in $`\mathrm{\Gamma }_\mathrm{},\mathrm{}^{}\mathrm{\Gamma }_{\mathrm{}}`$. Such a letter has the form $`(u,w,v)B_{\mathrm{}}`$ and we may define $`\pi (u,w,v)=w`$ since $`\mathrm{\Gamma }\mathrm{\Gamma }_{\mathrm{}}`$.

Clearly $`\pi (\overline{(u,w,v)})=\overline{\pi (u,w,v)}`$ and $`h_\mathrm{},\mathrm{}^{}(u,w,v)=h_{\mathrm{}^{}}(u,w,v)=h(w)=h_{\mathrm{}}(\pi (u,w,v))`$ are verified. Thus $`\pi :\mathrm{\Gamma }_\mathrm{},\mathrm{}^{}^{}\mathrm{\Gamma }_{\mathrm{}}^{}`$ defines a projection such that

$$\pi ^{}(E_{\mathrm{}})=(\mathrm{\Gamma }_\mathrm{},\mathrm{}^{},h_\mathrm{},\mathrm{}^{},\mathrm{\Omega }_{\mathrm{}},\rho _{\mathrm{}};L_{\mathrm{}}=R_{\mathrm{}}).$$

We have to define a partial solution $`\delta :\mathrm{\Omega }_{\mathrm{}}\mathrm{\Gamma }_\mathrm{},\mathrm{}^{}^{}\mathrm{\Omega }_{\mathrm{}^{}}\mathrm{\Gamma }_\mathrm{},\mathrm{}^{}^{}\mathrm{\Gamma }_\mathrm{},\mathrm{}^{}^{}`$ such that $`\delta (L_{\mathrm{}})=\beta (L_{\mathrm{}^{}})`$ and $`\delta (R_{\mathrm{}})=\beta (R_{\mathrm{}^{}})`$. For this, we have to consider a variable $`X\mathrm{\Omega }`$ with $`\mathrm{body}_{\mathrm{}}(\sigma (X))1`$. By symmetry, we may assume that $`X=x_i`$ for some $`1ig`$. Hence $`\sigma (X)=w_0[\mathrm{l}(i),\mathrm{r}(i)]`$.

Let $`\alpha =\mathrm{l}(i)+|\mathrm{head}_{\mathrm{}}(\sigma (X))|`$ and $`\beta =\mathrm{r}(i)|\mathrm{tail}_{\mathrm{}}(\sigma (X))|`$. Then $`\mathrm{l}(i)+\mathrm{}\alpha <\beta \mathrm{r}(i)\mathrm{}`$. Let $`(u_p,w_p,v_p)\mathrm{}(u_q,w_q,v_q)`$ be the minimal cover of $`[\alpha ,\beta ]`$ with respect to the $`\mathrm{}`$-factorization. We have $`w_p\mathrm{}w_q=\mathrm{body}_{\mathrm{}}(\sigma (X))`$.

For $`\mathrm{body}_{\mathrm{}^{}}(X)=1`$ we have $`X\mathrm{\Omega }_{\mathrm{}}\mathrm{\Omega }_{\mathrm{}^{}}`$ and we define

$$\delta (X)=(u_p,w_p,v_p)\mathrm{}(u_q,w_q,v_q).$$

Then $`\delta (X)B_{\mathrm{}}^{}`$ and $`h_{\mathrm{}}\delta (X)=\rho _{\mathrm{}}(X)`$ since $`\rho _{\mathrm{}}(X)=h(\mathrm{body}_{\mathrm{}}(\sigma (X)))`$. It is also clear that the definition does not depend on the choice of $`i`$, and we have $`\delta (\overline{X})=\overline{\delta (X)}`$.

Recall the definition of $`L_{\mathrm{}^{}}`$. Since $`\mathrm{body}_{\mathrm{}^{}}(\sigma (X))=1`$, there is a factor $`f_1\mathrm{}f_r`$ of $`L_{\mathrm{}^{}}`$ which belongs to $`\mathrm{\Gamma }_{\mathrm{}^{}}^{}`$ and $`f_1\mathrm{}f_r`$ covers $`[\alpha ,\beta ]`$ with respect to the $`\mathrm{}^{}`$-factorization $`F_{\mathrm{}^{}}(w_0)`$. It follows that $`\delta (X)`$ is a factor of $`\beta (f_1\mathrm{}f_r)`$, hence $`\delta (X)\mathrm{\Gamma }_\mathrm{},\mathrm{}^{}^{}`$ by definition of $`\mathrm{\Gamma }_\mathrm{},\mathrm{}^{}`$.

For $`\mathrm{body}_{\mathrm{}^{}}(X)1`$ we have $`X\mathrm{\Omega }_{\mathrm{}^{}}`$ and we find positions $`\mu <\nu `$ such that $`\mu =\mathrm{l}(i)+|\mathrm{head}_{\mathrm{}^{}}(\sigma (X))|`$ and $`\nu =\mathrm{r}(i)|\mathrm{tail}_{\mathrm{}^{}}(\sigma (X))|`$.

For some $`prsq`$ we have $`w_0[\alpha ,\mu ]=w_p\mathrm{}w_{r1}`$, $`w_0[\nu ,\beta ]=w_{s+1}\mathrm{}w_q`$, and $`\mathrm{body}_{\mathrm{}^{}}(\sigma (X))=w_r\mathrm{}w_s`$. We define

$$\delta (X)=(u_p,w_p,v_p)\mathrm{}(u_{r1},w_{r1},v_{r1})X(u_{s+1},w_{s+1},v_{s+1})\mathrm{}(u_q,w_q,v_q).$$

As above, we can verify that $`\delta (X)=UXV`$ with $`U,V\mathrm{\Gamma }_\mathrm{},\mathrm{}^{}^{}`$ such that $`\delta (\overline{X})=\overline{V}\overline{X}\overline{U}`$ and $`\rho _{\mathrm{}}(X)=h_\mathrm{},\mathrm{}^{}(U)\rho _{\mathrm{}^{}}(X)h_\mathrm{},\mathrm{}^{}(V)`$. Finally, $`\delta (L_{\mathrm{}})=L_{\mathrm{}^{}}`$ and $`\delta (R_{\mathrm{}})=R_{\mathrm{}^{}}`$. Hence $`\delta _{}(\pi ^{}(E_{\mathrm{}}))=\beta _{}(E_{\mathrm{}^{}})`$. This proves Theorem 5.

## 19 Conclusion

In this paper we were dealing with the existential theory, only. For free groups it is also known that the positive theory without constraints is decidable, see . Thus, one can allow also a mixture of existential and universal quantifiers, if there are no negations at all. Since a negation can be replaced with the help of an extra variable and some positive rational constraint, one might be tempted to prove that the positive theory of equations with rational constraints in free groups is decidable. But such a program must fail: Indeed, by  and  it is known that the positive $`^3`$-theory of word equations is unsolvable. Since $`\mathrm{\Sigma }^{}`$ is a rational subset of the free group $`F(\mathrm{\Sigma })`$, this theory can be encoded in the positive theory of equations with rational constraints in free groups, and the later is undecidable, too. On the other hand, a negation leads to a positive constraint of a very restricted type, so the interesting question remains under which type of constraints the positive theory becomes decidable.

### Acknowledgments

The research was partly supported by the German Research Foundation Deutsche Forschungsgemeinschaft, DFG. In addition, C. Gutiérrez thanks Centro de Modelamiento Matemático, FONDAP Matemáticas Discretas, for financial support.