# Quadratic Word Equations with Length Constraints, Counter Systems, and Presburger Arithmetic with Divisibility

Word equations are a crucial element in the theoretical foundation of constraint solving over strings, which have received a lot of attention in recent years. A word equation relates two words over string variables and constants. Its solution amounts to a function mapping variables to constant strings that equate the left and right hand sides of the equation. While the problem of solving word equations is decidable, the decidability of the problem of solving a word equation with a length constraint (i.e., a constraint relating the lengths of words in the word equation) has remained a long-standing open problem. In this paper, we focus on the subclass of quadratic word equations, i.e., in which each variable occurs at most twice. We first show that the length abstractions of solutions to quadratic word equations are in general not Presburger-definable. We then describe a class of counter systems with Presburger transition relations which capture the length abstraction of a quadratic word equation with regular constraints. We provide an encoding of the effect of a simple loop of the counter systems in the theory of existential Presburger Arithmetic with divisibility (PAD). Since PAD is decidable, we get a decision procedure for quadratic words equations with length constraints for which the associated counter system is flat (i.e., all nodes belong to at most one cycle). We show a decidability result (in fact, also an NP algorithm with a PAD oracle) for a recently proposed NP-complete fragment of word equations called regular-oriented word equations, together with length constraints. Decidability holds when the constraints are additionally extended with regular constraints with a 1-weak control structure.

## Authors

• 14 publications
• 29 publications
05/23/2018

### Decidable Logics Combining Word Equations, Regular Expressions and Length Constraints

In this work, we consider the satisfiability problem in a logic that com...
06/29/2018

### Supercompiling String Programs Using Word Equations as Constraints

We describe a general parameterized scheme of program and constraint ana...
01/15/2021

### Solving one variable word equations in the free group in cubic time

A word equation with one variable in a free group is given as U = V, whe...
02/02/2018

### The Satisfiability of Extended Word Equations: The Boundary Between Decidability and Undecidability

The study of word equations (or the existential theory of equations over...
09/07/2021

### Program Specialization as a Tool for Solving Word Equations

The paper focuses on the automatic generating of the witnesses for the w...
07/23/2020

### On Solving Word Equations via Program Transformation

The paper presents an experiment of solving word equations via specializ...
10/17/2011

### Period-halving Bifurcation of a Neuronal Recurrence Equation

We study the sequences generated by neuronal recurrence equations of the...
##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

Reasoning about strings is a fundamental problem in computer science and mathematics. The full first order theory over strings and concatenation is undecidable. A seminal result by Makanin [26] (see also [12, 18]) shows that the satisfiability problem for the existential fragment is decidable, by showing an algorithm to check satisfiability of word equations. Precisely, a word equation consists of two words and over an alphabet of constants and variables. Such an equation is satisfiable if there is a mapping from the variables to strings over the constants such that and are syntactically identical.

An original motivation for studying word equations was to show undecidability of Hilbert’s 10th problem (see, e.g., [28]). While Makanin’s later result shows that word equations could not, by themselves, show undecidability, Matiyasevich in 1968 considered an extension of word equations with length constraints as a possible route to showing undecidability of Hilbert’s 10th problem [28]. A length constraint constrains the solution of a word equation by requiring a linear relationship to hold on the lengths of words in a solution . For example, a length constraint might require that a solution maps variable and variable to words of the same length. The decidability of word equations with length constraints remains open.

In recent years, reasoning about strings with length constraints has found renewed interest through applications in program verification and reasoning about security vulnerabilities. The focus of most research has been on developing practical string solvers [34, 32, 6, 1, 24, 3, 14, 15, 19, 36, 35, 8, 17, 33]. These solvers are sound but make no claims of completeness. Relatively few results are known about the decidability status of strings with length and other constraints (see [10] for an overview of the results in this area). The main idea in most existing decidability results is the encoding of length constraints into Presburger arithmetic [16, 10]. However, the length abstraction of a word equation, that is, the set of possible lengths of variables in its solutions, need not be Presburger definable. (Indeed, this was Matiyasevich’s motivation in studying this problem as a way to prove undecidability of Hilbert’s 10th problem.)

In this paper, we consider the case of quadratic word equations, in which each variable can appear at most twice [22, 13], together with length and regularity constraints. For quadratic word equations, there is a simpler decision procedure (called the Nielsen transform or Levi’s method) based on a non-deterministic proof tree construction. The technique can be extended to handle regular constraints [13]. However, we show that already for this class (even for a simple equation like , where are variables and are constants), the length abstraction need not be Presburger-definable. Thus, techniques based on Presburger encodings are not sufficient to prove decidability.

Our first observation in this paper is a connection between the problem of quadratic word equations with length constraints and a class of counter systems with Presburger transitions. Informally, the counter system has control states corresponding to the nodes of the proof tree constructed by Levi’s method, and a counter standing for the length each word variable. Each step of Levi’s method may decrease at most one counter. Thus, from any initial state, the counter system terminates. We show that the set of initial counter values which can lead to a successful leaf (i.e., one containing the trivial equation ) is precisely the length abstraction of the word equation.

Our second observation is that the reachability relation for a simple loop of the counter system can be encoded in the existential theory of Presburger arithmetic with divisibility . The encoding is non-trivial in the presence of regular constraints, and depends on structural results on semilinear sets. As is decidable [25, 21], we obtain a technique to symbolically represent the reachability relation for flat counter systems, in which each node belongs to at most one loop.

Moreover, the same encoding shows decidability for word equations with length constraints, provided the proof tree is associated with flat counter systems. In particular, we show that the class of regular-oriented word equations, introduced by [11], have flat proof trees. Thus, the satisfiability problem for quadratic regular-oriented word equations with length constraints is decidable (and in NEXP).111 In fact, the decision procedure is NP with an oracle access to a decision procedure for Presburger arithmetic with decidability. The best complexity bounds for the latter are NEXP and NP-hardness [21].

While our decidability result is for a simple subclass, this class is already non-trivial without length and regular constraints: satisfiability of regular-oriented word equations is NP-complete [11]. Our result generalizes previous decidability results [10]. Moreover, we believe that the techniques introduced in this paper, such as the connection between acceleration and word equations, and the use of existential Presburger with divisibility, can open the way to more sophisticated decision procedures or tools based on acceleration designed for counter systems.

## 2 Preliminaries

General notation: Let be the set of all natural numbers. For integers , we use to denote the set of integers. If , let denote . We use to denote the component-wise ordering on , i.e., iff for all . If and , we write .

If is a set, we use to denote the set of all finite sequences over . The length of is . The empty sequence is denoted by . Notice that forms a monoid with the concatenation operator . If is a prefix of , we write . Additionally, if (i.e. a strict prefix of ), we write . Note that the operator is overloaded here, but the meaning should be clear from the context.

Words and Automata: We assume basic familiarity with word combinatorics and automata theory. Fix a (finite) alphabet . For each finite word , we write , where , to denote the segment . We write for the empty word.

Two words and are conjugates if there exist words and such that and . Equivalently, for some and for the cyclic permutation􏲄operation , defined as , and for and .

Given a nondeterministic finite automaton (NFA) , a run of on is a function with that obeys the transition relation . We may also denote the run by the word over the alphabet . The run is said to be accepting if , in which case we say that the word is accepted by . The language of is the set of words in accepted by . In the sequel, for we will write to denote the NFA with initial state replaced by and final is replaced by .

Word equations: Let be a (finite) alphabet of constants and a set of variables; we assume . A word equation is an expression of the form , where . A system of word equations is a nonempty set of word equations. The length of a system of word equations is the length . A system is called quadratic if each variable occurs at most twice in all. A solution to a system of word equations is a homomorphism which maps each to itself that equates the l.h.s. and r.h.s. of each equation, i.e., for each .

For each variable , we shall use to denote a formal variable that stands for the length of variable . Let be the set . A length constraint is a formula in Presburger arithmetic whose free variables are in .

A solution to a system of word equations with a length constraint is a homomorphism which maps each to itself such that for each and moreover holds. That is, the homomorphism maps each variable to a word in such that each word equation is satisfied, and the lengths of these words satisfy the length constraint.

The satisfiability problem for word equations with length constraints asks, given a system of word equations and a length constraint, whether it has a solution.

We also consider the extension of the problem with regular constraints. For a system of word equations, a variable , and a regular language , a regular constraint imposes the additional restriction that any solution must satisfy . Given a system of word equations, a length constraint, and a set of regular constraints, the satisfiability problem asks if there is a solution satisfying the word equation, the length constraints, as well as the regular constraints.

In the sequel, for clarity of exposition, we restrict our discussion to a system consisting of a single word equation (w.l.o.g.).

Linear arithmetic with divisibility: Let be a first-order language with equality, with binary relation symbol , and with terms being linear polynomials with integer coefficients. We write , , etc., for terms in integer variables . Atomic formulas in Presburger arithmetic have the form or . The language of Presburger arithmetic with divisibility extends the language with a binary relation (for divides). An atomic formula has the form have the form or of , where and are linear polynomials with integer coefficients. The full first order theory of is undecidable, but the existential fragment is decidable [25, 21].

Note that the divisibility predicate is not expressible in Presburger arithmetic: a simple way to see this is that is not a semi-linear set.

Counter systems: In this paper, we specifically use the term “counter systems” to mean counter systems with Presburger transition relations (e.g. see [4]). These more general transition relations can be simulated by standard Minsky’s counter machines, but they are more useful for coming up with decidable subclasses of counter systems. A counter system is a tuple , where is a finite set of counters, is a finite set of control states, and is a finite set of transitions of the form , where and is a Presburger formula with free variables . A configuration of is a tuple .

The semantics of counter systems is given as a transition system. A transition system is a tuple , where is a set of configurations and is a binary relation over . A path in is a sequence of configurations .

A counter system generates the transition system , where is the set of all configurations of , and if there exists a transition such that is satisfiable.

In the sequel, we will be needing the notion of flat counter systems [7, 23, 5, 4]. Given a counter system , the control structure of is an edge-labeled directed graph with the set of nodes and the set . The counter system is flat if each node is contained in at most one simple cycle.

## 3 Solving Quadratic Word Equations

We start by recalling a simple textbook recipe (called Nielsen transformation, a.k.a., Levi’s Method) [12, 22] for solving quadratic word equations, both for the cases with and without regular constraints. We then discuss the length abstractions of solutions to quadratic word equations, and provide several natural examples that are not Presburger-definable.

### 3.1 Nielsen transformation

We will define a rewriting relation between quadratic word equations . Let be an equation of the form with and . Then, there are several possible :

• Rules for erasing an empty prefix variable. These rules can be applied if (symmetrically, ). In this case, we can nondeterministically guess that be the empty word . That is, is . The symmetric case of is similar.

• Rules for removing a nonempty prefix. These rules are applicable if each of and is either a constant or a variable that we nondeterministically guess to be a nonempty word. There are several cases:

(P1)

(syntactic equality). In this case, is .

(P2)

and . In this case, is .

(P3)

and . In this case, is .

(P4)

. In this case, we nondeterministically guess if or . In the former case, the equation is . In the latter case, the equation is is .

Note that the transformation keeps an equation quadratic.

###### Proposition 1

is solvable iff . Furthermore, checking if is solvable is in PSPACE.

See [12] for a proof. Roughly speaking, the proof uses the fact that each step either decreases the size of the equation, or the length of a length-minimal solution. It runs in PSPACE (in fact, linear space) because each rewriting does not increase the size of the equation.

### 3.2 Handling regular constraints

Nielsen transformation easily extends to quadratic word equations with regular constraints (e.g. see [13]). We assume that a regular constraint is given as an NFA representing . [If and are the initial and final states (respectively) of an NFA , we can be more explicit and write instead of .]

Our rewriting relation now works over a pair consisting of an equation and a set of regular constraints over variables in . Let be an equation of the form with and . We now define by extending the definition of without regular constraints. In particular, it has to be the case that and additionally do the following:

• Rules for erasing an empty prefix variable . When applied, ensure that each regular constraint in satisfies . Define as minus all regular constraints of the form .

• Rules for removing a nonempty prefix. For (P1), we have set to be minus all constraints of the form if is a variable. For (P2)–(P4), assume that is ; the other case is symmetric. For each regular constraint , we nondeterministically guess a state , and add and to . In the case when , we could immediately perform the check : a positive outcome implies removing this constraint from , while on a negative outcome our algorithm simply fails on this branch. For any variable that is distinct from , we add all regular constraints in to .

###### Proposition 2

is solvable iff . Furthermore, checking if is solvable is in PSPACE.

Note that this is still a PSPACE algorithm because it never creates a new NFA or adds new states to existing NFA in the regular constraints, but rather adds a regular constraint to a variable , where is an NFA that is already in the regular constraint.

### 3.3 Generating all solutions using Nielsen transformation

One result that we will need in this paper is that Nielsen transformation is able to generate all solutions of quadratic word equations with regular constraints. To clarify this, we extend the definition of so that each a configuration or in the graph of is also annotated by an assignment of the variables to concrete strings. We write if and is the modification from according to the operation used to obtain from . That is, suppose that and and and . In this case, but since we have taken off the prefix from . This definition for the case with regular constraints is identical.

###### Proposition 3

where has the empty domain iff is a solution of .

This proposition immediately follows from the proof of correctness of Nielsen transformation for quadratic word equations [12].

### 3.4 Length abstractions and semilinearity

Given a quadratic word equation with constants and variables , its length abstraction is defined as follows

 {Len}(E)={(|σ(x1)|,…,|σ(xk)|):σ is a solution to E},

namely the set of tuples of numbers corresponding to lengths of solutions to .

###### Example 1

Consider the quadratic equation , where and contains at least two letters and . We will show that its length abstraction can be captured by the Presburger formula . Observe that each must satisfy by a length argument on . Conversely, we will show that each triple satisfying must be in . To this end, we will define a solution to such that . Consider . Let for some and . Let be a prefix of of length . Define . Therefore, is a prefix of . That is, for some , it is the case that . Letting suffices to make satisfy . Also, , which satisfies the formula . ∎

However, it turns out that Presburger Arithmetic is not sufficient for capturing length abstractions of quadratic word equations.

###### Theorem 3.1

There is a quadratic word equation whose length abstraction is not Presburger-definable.

To this end, we show that the length abstraction of , where and , is not Presburger definable.

###### Lemma 1

The length abstraction coincides with tuples of numbers satisfying the expression defined as:

 |x|=|y| ∨ (|x|=0∧|y|≡0(mod2))∨(|y|=0∧|x|≡0(mod2)) ∨ (|x|,|y|>0∧gcd(|x|+2,|y|+2)>1)

Observe that this would imply non-Presburger-definability: for otherwise, since the first three disjuncts are Presburger-definable, the last disjunct would also be Presburger-definable, which is not the case since the property that two numbers are relatively prime is not Presburger-definable. Note however, that the expression is definable in existential Presburger arithmetic with divisibility.

Let us prove this lemma. Let . We first show that given any numbers satisfying , there are solutions to with for each . If they satisfy the first disjunct in (i.e. ), then set to an arbitrary word . If they satisfy the second disjunct, then and so set . The same goes with the third disjunct. For the fourth disjunct (assuming the first three disjuncts are false), let . Define so that for . It follows that .

We now prove the converse. So, we are given a solution to and let , . Assume to the contrary that is false and that and are the shortest such solutions. We have several cases to consider:

• . Then, , contradicting that is false.

• . Then, and so , which implies that . Contradicting that is false.

• . Same as previous item and that .

• . Since is false, we have . It cannot be the case that since then, comparing prefixes of , the letter at position would be on l.h.s. and on r.h.s., which is a contradiction. Therefore . Let , i.e., but with its prefix of length removed. By Nielsen transformation, we have . It cannot be the case that ; for, otherwise, implies and so , implying that 2 divides both and , contradicting that . Therefore, . Since , we have a shorter solution to , contradicting minimality.

• . Same as previous item.

## 4 Reduction to Counter Systems

In this section, we will provide an algorithm for computing a counter system from , where is a quadratic word equation and is a set of regular constraints. We will first describe this algorithm for the case without regular constraints, after which we show the extension to the case with regular constraints.

Given the quadratic word equation , we show how to compute a counter system such that the following theorem holds.

###### Theorem 4.1

The length abstraction of coincides with .

Before defining , we define some notation. Define the following formulas:

Note that the symbol in the guard of denotes syntactic equality (i.e. not equality in Preburger Arithmetic). We omit mention of the free variables and when they are clear from the context.

We now define the counter system. Given a quadratic word equation with constants and variables , we define a counter system as follows. The counters will be precisely all variables that appear in , i.e., . The control states are precisely all equations that can be rewritten from using Nielsen transformation, i.e., . The set is finite (at most exponential in ) as per our discussion in the previous section.

We now define the transition relation . We use to enumerate in some order. Given with , we then add the transition , where is defined as follows:

• If applies a rule for erasing an empty prefix variable , then .

• If applies a rule for removing a nonempty prefix:

• If (P1) is applied, then .

• If (P2) is applied, then .

• If (P3) is applied, then .

• If (P4) is applied and , then . If , then .

Observe that if , then and . In addition, if , then . This implies the following lemma.

###### Lemma 2

The counter system terminates from every configuration .

The proof of Theorem 4.1 immediately follows from Proposition 3 that Nielsen transformation generates all solutions.

#### Extension to the case with regular constraints:

In this extension, we will only need to assert that the counter values belong to the length abstractions of the regular constraints, which are effectively semilinear due to Parikh’s Theorem [29]. Given a quadratic word equation with a set of regular constraints, we define the counter system as follows. Let . Let . Let be the finite set of all configurations reachable from , i.e., . Given , we add the transition as follows. Suppose that was added to by . Then,

 Φ′:=Φ∧⋀x∈¯x⎛⎝x∈{Len}(⋂(x∈L)∈SL)∧x′∈{Len}(⋂(x∈L)∈S′L)⎞⎠.

The size of the NFA for is exponential in the number of constraints of the form in (of which there are polynomially many). The constraint is well-known to be effectively semilinear [29], and in fact we can compute using the algorithm of Chrobak-Martinez [9, 27, 30] in polynomial time two finite sets of integers and an integer such that, for each , is true iff . Note that is a fintie union of arithmetic progressions (with period 0 and/or ). In fact, each number (resp. the number ) is at most quadratic in the size of the NFA, and so it is a polynomial 222Note that we mean polynomial in the size of the NFA, which can be exponential in . size even when they are written in unary. Therefore, treating as an existential Presburger formula with one free variable (an existential quantifier is needed to guess the coefficient such that for some ), the resulting is a polynomial-sized existential Presburger formula.

###### Theorem 4.2

The length abstraction of coincides with .

As for the case without regular constraints, the proof of Theorem 4.1 immediately follows from Proposition 3 that Nielsen transformation generates all solutions.

## 5 Decidability via Linear Arithmetic with Divisibility

### 5.1 Accelerating a 1-variable-reducing cycle

Consider a counter system with , and for some the transition relation consists of precisely the following transition , for each , such that is either (with a variable distinct from ) or . Such a counter system is said to be a 1-variable-reducing cycle.

###### Lemma 3

There exists a polynomial-time algorithm which given a 1-variable-reducing cycle and two states computes an formula in existential Presburger with divisibility such that iff is satisfiable.

This lemma can be seen as a special case of the acceleration lemma for flat parametric counter automata [7] (where all variables other than are treated as parameters). However, its proof is in fact quite simple. Without loss of generality, we assume that and , for some . Any path can be decomposed into the cycle and the simple path of length . Therefore, the reachability relation can be expressed as

 ∃\rm z0,⋯,\rm zi−1:φq0,q0(% \rm x,\rm z0)∧Φ0(\rm z0,\rm z1)∧⋯∧Φi−1(\rm zi−1,\rm y).

Thus, it suffices to show that is expressible in . Define a multiset of counter decrements as follows:

• The number of the integer constant 1 can contain is defined as the number of such that .

• For each variable , the number of times could appear in is defined as the number of such that .

For any variable/constant , we will write to denote the number of times appears in . Therefore, for some we have , or equivalently

 n∑eM(e)=y−y′

The formula can be defined as follows:

 φq0,q0:= (∑eM(e))∣(y−y′)∧y′≤y∧⋀x∈V∖{y}x′=x.

Handling unary Presburger guards: Recalling our reduction for the case with regular constraints from Section 4 reveals that we also need unary Presburger guards on the counters. We will show how to extend our aforementioned acceleration lemma to handle such guards. As we will see shortly, we will need a bit of the theory of semilinear sets.

As before, our counter system has counters , and the control structure is a simple cycle of length , i.e., the transitions in are precisely for some Presburger formula , for each . We say that is 1-variable-reducing with unary Presburger guards if there exists a counter such that each is of the form , where is either (with a variable distinct from ) or , and is a conjunction of formulas of the form , where both and are finite sets of natural numbers and . For each counter , we use to denote the set of conjuncts in that refers to the counter .

###### Lemma 4

There exists a polynomial-time algorithm which given a 1-variable-reducing cycle with unary Presburger guards and two states computes an formula in existential Presburger with divisibility such that iff is satisfiable.

Unlike Lemma 3, this lemma does not immediately follow from the results of [7] on flat parametric counter automata. To prove this, let us first take the formula from Lemma 3 applied to , which is obtained from by first removing the unary Presburger guards. We can insert these unary Presburger guards to , but this is not enough because we need to make sure that all “intermediate” values of have to also satisfy the Presburger guards corresponding to on that control state. More precisely, let the counter decrement in be (which can either be a variable distinct from or 1). For , we use to denote . Write for . Then, we can write

 λq0,q0 := ¯x′=¯x∨(φq0,q0∧n−1⋀i=0ψi(¯x)∧ηq0,q0) ηq0,q0 := ∀k:y′+(k+1)f(¯x)≤y⟶ ⎛⎜⎝n−1⋀i=0⋀(αi∈A∪A′+bN)∈ψi,yy′+kf(¯x)+αi∈A∪(A′+bN)⎞⎟⎠

This is a correct expression that captures the reachability relation , but the problem is that it has a universal quantifier and therefore is not a formula of . To fix this problem, we will need to exploit the semilinear structure of unary Presburger guards. To this end, we first notice that, by taking the big conjunction over and the big conjuncton over out, the formula is equivalent to:

 ηq0,q0 ≡ n−1⋀i=0⋀(αi∈A∪A′+bN)∈ψi,y∀k:y′+(k+1)f(¯x)≤y⟶ (y′+kf(¯x)+αi∈A∪(A′+bN))

Therefore, it suffices to rewrite each conjunct as an existential Presburger formula, for each and constraint . To this end, let and let denote . We claim that

 C(¯x) ≡ a⋀i=0y′+if(¯x)+αi≤y→y′+if(¯x)+αi∈A∪(A′+bN) ∧a+N+1⋀i=a+1y′+if(¯x)+αi≤y→y′+if(¯x)+αi∈A′+bN.

Simply put, we distinguish the cases when is “small” (i.e., less than the maximum threshold that can keep this number in an arithmetic progression with 0 period), and when this number is “big” (i.e. must be in an arithmetic progression with a nonzero period). To prove this equivalence, it suffices to show that if with and , then we can find such that . Suppose to the contrary that such does not exist. Then, since there are numbers in between and , by pigeonhole principle there is an arithmetic progression and two different numbers such that , for . Let . Note that denotes the difference between and , and this difference is of the form , for some positive integer . We now find a number with for some positive integer . Since for some , it must be the case that for , contradicting that .

We have proven correctness, and what remains is to analyse the size of the formula . To this end, it suffices to show that each formula is of polynomial size. This is in fact the case since there are at most polynomially many numbers in and and that the size of all numbers in are of polynomial size even when they are written in unary.

### 5.2 An extension to flat control structures and an acceleration scheme

The following generalisation to flat control structures is an easy corollary of Lemma 3 and 4.

###### Theorem 5.1

There exists a polynomial-time algorithm which, given a flat Presburger counter system , each of whose simple cycle is 1-variable-reducing with unary Presburger guards and two states , computes an formula in existential Presburger with divisibility such that iff is satisfiable.

Indeed, to prove this theorem, we can simply use Lemma 4 to accelerate all cycles and the fact that transition relations expressed in existential Presburger with divisibility is closed under composition.

### 5.3 Application to word equations with length constraints

Theorem 5.1 gives rise to a simple and sound (but not complete) technique for solving quadratic word equations with length constraints: given a quadratic word equation with regular constraints, if the counter system is flat, each of whose simple cycle is 1-variable-reducing with unary Presburger guards, then apply the decision procedure from Theorem 5.1. In this section, we show completeness of this method for the class of regular-oriented word equations recently defined in [11], which can be extended with regular constraints given as 1-weak NFA [2]. A word equation is regular if each variable occurs at most once on each side of the equation. Observe that is regular, but is not. It is easy to see that a regular word equation is quadratic. A word equation is said to be oriented if there is a total ordering on such that the occurrences of variables on each side of the equation preserve , i.e., if