An Improved Version of Hmelevskii’s Theorem on Three-Variable Word Equations
Abstract
Hmelevskii proved in 1971 that every constant-free three-variable word equation has a parametric solution. We prove an improved version of this result by showing that every such equation has a parametric solution using only three numerical parameters and with only two levels of nesting. This means that the structure of the solution sets of these equations is considerably simpler than has been known before.
Keywords and phrases:
Combinatorics on words, word equation, parametric word2012 ACM Subject Classification:
Mathematics of computing Combinatorics on wordsFunding:
Supported by the Research Council of Finland under grant 339311.Editors:
Meena Mahajan, Florin Manea, Annabelle McIver, and Nguyễn Kim ThắngSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction
The study of word equations is interesting from the point of view of algebra and combinatorics, and also from the point of view of several more applied topics, such as string solvers [3] and document spanners [7]. Two very common (and closely related) research questions about word equations are studying the complexity of the satisfiability problem, that is, the problem of determining whether a given equation has a solution, and studying the structure of solution sets. These questions can be studied for different restricted subfamilies or for various generalizations of word equations. We give here some examples of existing results.
The satisfiability problem of word equations is known to be in NSPACE() [12]. It is also known to be NP-hard, but it is an open question whether it is in NP. There are many generalized versions of word equations for which the satisfiability problem is undecidable, see, for example, [4]. An interesting open question is the decidability of the satisfiability of word equations with length constraints. On the other hand, many easier variants can be solved in polynomial time, e.g., [11, 6, 5].
Strong results about the structure of solution sets exist for many subfamilies of word equations. It is a folklore result that constant-free equations on one or two variables have only periodic solutions. Constant-free equations on three variables are much more complicated, but they always have a so-called parametric solution, as proved by Hmelevskii [10]. Constant-free equations on four variables, on the other hand, do not always have parametric solutions; this was also proved in [10]. For one-variable equations with constants, it is known that if the solution set is infinite, then the possible values for the variable are exactly the words in a language of the form [14], and if the solution set is finite, there are at most three solutions [16]. There are also results about the solution sets of arbitrary word equations or some of their generalizations, such as [2].
In this article, we concentrate on constant-free equations on three variables, with the goal of giving an improved, more precise version of the above-mentioned result of Hmelevskii. Although the statement of the old result is strong and elegant, there are a couple of weaknesses: First, the original proof, and even the simpler version of that proof in [13, 18], is very long and hard to read. Second, the parametric words that arise from the proof can be very complicated. For example, the number of numerical parameters and the nesting level can be estimated to be logarithmic with respect to the length of the equation, see [17, 18].
We prove as our main result that every constant-free equation on three variables has a parametric solution using only three numerical parameters and with nesting level at most two. This result was essentially conjectured in [19], and a similar result was proved for the subfamily of so-called unbalanced equations.
Our approach is very different from the one used by Hmelevskii, and it is not reliant on the results in [10]. On the other hand, we make extensive use of some other existing results, both old and recent, like the ones in [1, 19].
The structure of the article is as follows. In Section 2, we give many necessary definitions and state some existing results. In Section 3, we define a particular free group morphism and prove several lemmas related to it. This morphism then allows us to reformulate a result that was proved in [19]. The reformulation essentially combines six cases into one, making the result much easier to apply. On the other hand, the fact that the morphism is a free group morphism instead of a free monoid morphism leads to some complications. In Section 4, we give modified versions of some earlier results. The results are very close to the original ones, and large parts of the proofs are the same as in the original articles, but some changes are necessary to make the results work for our purposes. Section 5 contains the most important part of the proof of the main theorem. In this section, we find simple parametric representations for certain sets, and these can then be used as building blocks for a parametric solution of an arbitrary three-variable equation, as is finally done in Section 6.
2 Preliminaries
Let denote the set of nonnegative integers.
The set of all words over an alphabet is denoted by . This set, together with the concatenation operation, is a free monoid. The empty word, denoted by , is the neutral element of this monoid.
A word is a factor of a word if there exist words such that . Words and are conjugates if there exist words such that and .
The free monoid can be extended to a free group, which we denote by . We are mostly interested in free monoids, but occasionally we have to refer to free groups. Morphisms over free groups, in particular, are a useful tool in certain parts of this article.
A mapping is a G-morphism if for all . The morphism is uniquely defined by the values for . The set of all G-morphisms is denoted by .
If and for all (and, consequently, for all ), then is called an M-morphism. The set of all M-morphisms is denoted by .
A morphism is periodic if there exists such that for all , and nonperiodic otherwise.
Remark 1.
Usually when studying words, morphisms are defined as mappings such that for all . Every such mapping can be extended to an M-morphism in a unique way, and conversely, every M-morphism can be restricted to such a mapping. We use M-morphism so that we do not have to talk about extensions and restrictions.
2.1 Equations
Let be an alphabet of variables and let be an alphabet of constants. A constant-free word equation on is a pair , where , and a solution of is an M-morphism such that . The equation is nontrivial if .
A system of equations is a set of equations. A solution of a system is an M-morphism that satisfies all equations in the system.
The set of all solutions of an equation or system is denoted by , and the set of all equations satisfied by a morphism is denoted by . Equations or systems are equivalent if , and morphisms are equivalent if .
In this article, we are interested in the three-variable case. From now on, let be an alphabet of three variables, let be a nonunary alphabet of constants and let be two distinct letters.
We use the shorthand notation , where , for the morphism defined by , , .
Example 2.
Consider the equation . For all and , the morphism is a solution of :
Similarly, is a solution for all . It would be quite easy to show that there are no other solutions, so
Here we are using the notation . We frequently write solution sets or other sets of morphisms in this kind of form.
2.2 Parametric Words
Let be the set of functions of the form
where and . For , let be the set of functions of the form
where , , and for all .
The elements of
are called parametric words with word parameters and numerical parameters. For a parametric word , the smallest such that is called the nesting level of . We have , so is the set of parametric words with nesting level at most .
Example 3.
The function defined by is a parametric word in .
Next we define parametric representations and solutions. To simplify notation, we concentrate on the three-variable case. A finite set
of triples of parametric words in is a parametric representation of the set of morphisms
The family of all such sets of triples is denoted by . For a three-variable equation , a parametric representation of is called a parametric solution of .
Example 4.
The equation in Example 2 has a parametric solution
where
Here and the other parametric words are in , so the parametric solution is in .
It is usually not necessary to explicitly define the parametric words, since they can be directly seen from expressions like or .
Hmelevskii [10] proved that every constant-free three-variable word equation has a parametric solution. These parametric solutions use two word parameters, except that trivial equations have a parametric solution in . This is connected to the famous defect theorem, according to which words satisfying a nontrivial relation can be expressed as products of words (see [8] for more on the defect theorem and its variations). The number of numerical parameters and nesting level were not analyzed in [10], but a logarithmic upper bound follows from the proofs in [17, 18], leading to the next theorem.
Theorem 5.
For every nontrivial constant-free three-variable word equation , there exist such that has a parametric solution in . Moreover, and are logarithmic with respect to the length of .
The following lemma is well-known, see Example 5.1.2 and the proof of Theorem 5.1.3 in [18] for an explanation.
Lemma 6.
The set of periodic solutions of a constant-free three-variable equation has a parametric representation in .
2.3 Classification of Morphisms
Budkina and Markov [1] classified all three-generator subsemigroups of a free semigroup. This result has been used in many places, often reformulated in terms of morphisms and equations. We copy here the formulation that was used in [19]. An essentially equivalent result was proved independently by Spehner [20, 21], see [9] for a good comparison of these results.
Theorem 7 (Budkina and Markov [1]).
Every nonperiodic morphism in that satisfies a nontrivial equation is equivalent, up to a permutation of the variables, to a morphism of one of the following types:
-
BM1.
where .
-
BM2.
where and and .
-
BM3.
where and and .
-
BM4.
where and and and .
-
BM5.
where and and and .
-
BM6.
where and and
3 The Morphism
Let be defined by
This particular morphism happens to be very useful for us. Specifically, it allows us to combine several lemmas that were proved in [19] into a single theorem (Theorem 12) that looks simpler and, crucially, is much easier to use in the later parts of the article.
First, we need some definitions and lemmas related to the behaviour of . These are important when formulating, proving and using Theorem 12. In particular, for a word , we want to characterize the integers such that is a word. This characterization is provided in Lemma 11.
Lemma 8.
The morphism has the following properties:
-
has an inverse morphism defined by
-
For all ,
-
For all ,
In particular,
Proof.
Straightforward computation.
We need to study the question of when is a word, or when is an M-morphism. For that purpose, we give some additional definitions.
A word is called an alternating block, or just block for short, if neither nor is a factor of . In other words, is an alternating block if and only if it is a nonempty factor of some word in .
An alternating block decomposition (ABD) of is a sequence of alternating blocks such that and for all , the last letter of is the same as the first letter of .
Lemma 9.
Every word has a unique ABD.
Proof.
We split in the middle of every occurrence of the factors and . This gives an ABD, and no other way of splitting into factors can give an ABD.
For a word with an ABD , we define its -degree
and -degree
For and for such that , we define
Example 10.
The word has the ABD . We have and .
Lemma 11.
For all and , the following equivalence holds:
Proof.
Let the ABD of be . By Lemma 8, every block that is not of the form with or of the form with is mapped to a word that begins and ends with the same letter as . In particular, if , then for all and therefore .
If , then there is at least one such that with . For all such , . If , then ends with and thus ends with either or . Similarly, if , then begins with either or . This means that when we calculate as the product of the images of the blocks, no cancellation can happen. Therefore, the reduced form of still has in it, and is not in .
The case is analogous to the case .
The next theorem shows why we are interested in the morphism : It allows us to give a greatly simplified formulation of certain old results. This is then useful when applying the theorem.
Theorem 12.
Let be a morphism of one of the types BM1–BM6. Let be the set of periodic solutions of . Then
| (1) |
Proof.
Let and . First, we check that is an M-morphism (instead of being just a G-morphism): implies for all , so we can use Lemma 11 to see that for all , and it follows that . If , then and thus . This shows that and that the right-hand side of (1) is a subset of the left-hand side.
The fact that every nonperiodic morphism in is in
follows from the results in [19]: Theorem 5.2 gives an equivalent equation for each , and Lemmas 6.1–6.6 then solve these equations. In each case, it can be easily checked that the formulas that give the nonperiodic solutions match . This shows that the left-hand side of (1) is a subset of the right-hand side.
4 Modified Versions of Previous Results
In [19], some ideas for proving a stronger version of Hmelevskii’s theorem were discussed, and a couple of theorems were proved that could possibly point towards such a result. We were not able to use those theorems directly as they were stated. Instead, we prove here slightly modified versions of them. The changes to both the theorems and their proofs are mostly very small.
We also need a slightly modified version of Lemma 24 in [15]. We give this in the next lemma without proof, because the original proof in [15] works also for this modified statement.
Lemma 13.
Let be the set of morphisms in the classes BM2, BM4, BM5. Let be a nontrivial constant-free equation on . If has more than one element, then there exist such that
The next lemma is a modified version of Theorem 8.1 in [19].
Lemma 14.
Let contain a representative of every equivalence class of nonperiodic morphisms that satisfy a nontrivial equation. Let be a nontrivial constant-free equation on . Let be such that
Let be the set of periodic solutions of . Then
Proof.
Every nonperiodic is equivalent to some , and then .
On the other hand, if for some , then and thus .
The next lemma is a modified version of Theorem 8.2 in [19].
Lemma 15.
Let be a nontrivial constant-free equation on . Let be the set of morphisms that are, up to a permutation of the variables, of one of the types BM1–BM6. Then there exist sets such that
| (2) |
and every is either a finite set or, up to a permutation of the variables, of one of the following forms:
| (3) | ||||
| (4) |
Proof.
Let be the set of morphisms of the types BM1, BM3, BM6. Let be similar sets for the different permutations of the variables. Let be the set of morphisms of the types BM2, BM4, BM5. Let be similar sets for the different permutations of the variables (we need only three permutations instead of six because of symmetry). Then . If we can find suitable sets such that
| (5) |
then (2) follows.
Morphisms in can be written as for some . It was proved in [15] that can have such a solution for at most one pair . If we fix and and replace by and by in , we get a nontrivial one-variable equation with constants, and solving this one-variable equation gives us the possible values for . It is known that if such an equation has infinitely many solutions, then there are such that for each , the morphism that maps the remaining variable to is a solution, and there are no other solutions, see [14]. Thus we get a set that is either finite or of the form (3) and satisfies (5). Similarly, we can find sets .
5 Parametric Representations for Certain Sets
Our intention is to use the set from Lemma 15 as the set in Lemma 14. This leads us to study the sets with the help of Theorem 12. The purpose of Lemma 16 is to handle the case where is a finite set. Similarly, Lemma 17 is used for the case where is of the form (3), and Lemma 19 is used for the case where is of the form (4). After proving these three lemmas, we put all the pieces together in Theorem 20 in the next section.
Lemma 16.
Let . The set
has a parametric representation in .
Proof.
For a fixed , the set
clearly has a parametric representation in , and the same is then true for a finite union of such sets. This takes care of the case where is finite. If is infinite and , then the ABDs of do not contain blocks of the form , and therefore maps every block either to itself, or, in the case of blocks of the form , to . This means that can be written in the form
| (6) |
where do not depend on , and and can be written in a similar form. Thus we get a parametric representation in .
The following idea that was used in the proof of Lemma 16 is useful also later: If , that is, the ABD of does not contain blocks of the form , then can be written in the form (6), and it essentially corresponds to a parametric word in . We use this kind of reasoning in the following lemmas without explaining it in detail like above.
Lemma 17.
Let , and . The set
| (7) |
has a parametric representation in .
Proof.
If , then for all and the set (7) is
which has a parametric representation in . For the rest of the proof, assume that or . Then for all .
Let us first assume that some conjugate of begins and ends with the same letter . Let this conjugate be , where . We can write (7) as
Here, we can use Lemma 16 for the first two sets, so it is enough to consider the third set. For , . Here begins and ends with , is either empty or ends with , and is either empty or begins with . Therefore, the ABD of consists of the ABD of followed by copies of the ABD of followed by the ABD of . For all , , which does not depend on . If is finite, then we have a finite union of sets of the form
In each set, is a constant. We can write and . Then runs through all natural numbers and we can think of it as a numerical parameter. Thus we get a parametric representation in . If is infinite, then we have
where and if and if . Thus we can think of and as numerical parameters, and we get a parametric representation in .
Let us then consider the case where no conjugate of begins and ends with the same letter. This means that . There are four subcases:
-
,
-
,
-
, ,
-
, .
The first three are simple: In all these subcases, , and (7) can be written simply as
which has a parametric representation in .
The fourth subcase is the most complicated one. Example 18 illustrates this case for some particular values of and . It might be easier to get the basic idea from that example than from the general proof below.
Let and . Then . Let . Let be such that and . Let be such that and . Then and
We have and therefore we can rewrite the condition using the following sequence of equivalences:
At this point, are fixed, while depend on . However, since there are only finitely many possible values for , we can consider these separately. If we fix , then and are also fixed. The part of (7) corresponding to a particular value of is
Here, the first set of the union is a finite union of sets, one for each value of . We can think of as the only numerical parameter and write , and we get a parametric representation in . In the second set of the union, on the other hand, we can write and , and then and run through all natural numbers independently of each other, so we can think of them as numerical parameters. Thus we get a parametric representation in . Combining all these parametric representations for all values of gives a parametric representation for (7).
Example 18.
Consider Lemma 17 with , , , . We have
Here we have split the set in two parts corresponding to even and odd . Then, in the end, we have replaced with in the first part, noticing that for all , there exists such that . Similarly, we have replaced by in the second part. We can think of and as numerical parameters, and we get a parametric representation in .
Lemma 19.
Let and . The set
| (8) |
has a parametric representation in .
Proof.
First, let . If , then , so we can write (8) as
The four sets corresponding to have parametric representations in by Lemma 16, and the last set has a parametric representation in .
Then, let . For each of , there are two cases depending on whether it is zero or positive. While this technically leads to a total of 16 cases, these are all quite similar, so we give here only the case : We can write
where , and run through all natural numbers independently of each other, so we can think of them as three numerical parameters, and we get a parametric representation in .
Finally, let . We can write (8) as
We explain here how to get a parametric representation for the last of these four sets; the first three can be handled in a similar way. For , we can write
Every word that is being mapped by here has infinite -degree. We can think of , and as numerical parameters, and we get a parametric representation in .
6 Main Result
We are now ready to prove our main result.
Theorem 20.
Every nontrivial constant-free word equation on has a parametric solution in .
Proof.
Let be the set of periodic solutions of . Let and be as in Lemma 15. We can then use Lemma 14 with . This, together with Theorem 12, gives
Note that the sets in Theorem 12 are subsets of the set in this proof, so they can be ignored here.
The set has a parametric representation in by Lemma 6. To complete the proof of the theorem, it suffices to show that each of the sets
has a parametric representation in . If is a finite set, this follows from Lemma 16, if is of the form (3), this follows from Lemma 17, and if is of the form (4), this follows from Lemma 19.
7 Conclusion
In this article, we have proved that every nontrivial constant-free word equation on three variables has a parametric solution with at most three numerical parameters and with nesting level at most two. This is a much more exact version of the old result of Hmelevskii. Several interesting questions remain:
-
Is the result optimal, that is, does there exist a constant-free word equation on three variables that does not have a parametric solution with less than three numerical parameters or with nesting level less than two?
-
A parametric solution was defined as a set of triples. How large does this set need to be, that is, how many triples do we need, at most? Can we give a fixed finite bound, or does this depend on the length of the equation?
-
What is the complexity of finding a parametric solution for a given constant-free equation on three variables?
References
- [1] L. G. Budkina and Al. A. Markov. -semigroups with three generators. Akademiya Nauk SSSR. Matematicheskie Zametki, 14:267–277, 1973.
- [2] Laura Ciobanu, Volker Diekert, and Murray Elder. Solution sets for equations over free groups are EDT0L languages. International Journal of Algebra and Computation, 26(5):843–886, 2016. doi:10.1142/S0218196716500363.
- [3] Joel D. Day. Word equations in the context of string solving. In Proceeding of the 26th DLT, volume 13257 of LNCS, pages 13–32. Springer, 2022. doi:10.1007/978-3-031-05578-2_2.
- [4] Joel D. Day, Vijay Ganesh, Paul He, Florin Manea, and Dirk Nowotka. The satisfiability of word equations: decidable and undecidable theories. In Reachability problems, volume 11123 of LNCS, pages 15–29. Springer, 2018. doi:10.1007/978-3-030-00250-3_2.
- [5] Joel D. Day, Florin Manea, and Dirk Nowotka. The hardness of solving simple word equations. In Proceedings of the 42nd MFCS, volume 83 of LIPIcs, pages 18:1–14. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2017. doi:10.4230/LIPIcs.MFCS.2017.18.
- [6] Robert Da̧browski and Wojtek Plandowski. Solving two-variable word equations (extended abstract). In Proceedings of the 31st ICALP, volume 3142 of LNCS, pages 408–419. Springer, 2004. doi:10.1007/978-3-540-27836-8_36.
- [7] Dominik D. Freydenberger and Mario Holldack. Document spanners: from expressive power to decision problems. Theory of Computing Systems, 62:854–898, 2017. doi:10.1007/s00224-017-9770-0.
- [8] Tero Harju and Juhani Karhumäki. Many aspects of defect theorems. Theoretical Computer Science, 324(1):35–54, 2004. doi:10.1016/j.tcs.2004.03.051.
- [9] Tero Harju and Dirk Nowotka. On the independence of equations in three variables. Theoretical Computer Science, 307(1):139–172, 2003. doi:10.1016/S0304-3975(03)00098-7.
- [10] Ju. I. Hmelevskiĭ. Equations in free semigroups. American Mathematical Society, 1976. Translated by G. A. Kandall from the Russian original: Trudy Mat. Inst. Steklov. 107 (1971).
- [11] Artur Jeż. One-variable word equations in linear time. Algorithmica, 74(1):1–48, 2016. doi:10.1007/s00453-014-9931-3.
- [12] Artur Jeż. Word equations in non-deterministic linear space. Journal of Computer and System Sciences, 123:122–142, 2022. doi:10.1016/j.jcss.2021.08.001.
- [13] Juhani Karhumäki and Aleksi Saarela. An analysis and a reproof of Hmelevskii’s theorem. In Proceedings of the 12th DLT, volume 5257 of LNCS, pages 467–478. Springer, 2008. doi:10.1007/978-3-540-85780-8_37.
- [14] Markku Laine and Wojciech Plandowski. Word equations with one unknown. International Journal of Foundations of Computer Science, 22(2):345–375, 2011. doi:10.1142/S0129054111008088.
- [15] Dirk Nowotka and Aleksi Saarela. One-variable word equations and three-variable constant-free word equations. International Journal of Foundations of Computer Science, 29(5):935–950, 2018. doi:10.1142/S0129054118420121.
- [16] Dirk Nowotka and Aleksi Saarela. An optimal bound on the solution sets of one-variable word equations and its consequences. SIAM Journal on Computing, 51(1):1–18, 2022. doi:10.1137/20M1310448.
- [17] Aleksi Saarela. On the complexity of Hmelevskii’s theorem and satisfiability of three unknown equations. In Proceedings of the 13th DLT, volume 5583 of LNCS, pages 443–453. Springer, 2009. doi:10.1007/978-3-642-02737-6_36.
- [18] Aleksi Saarela. Word equations and related topics: independence, decidability and characterizations. PhD thesis, University of Turku, 2012. URL: http://urn.fi/URN:ISBN:978-952-12-2737-0.
- [19] Aleksi Saarela. On the solution sets of three-variable word equations. Theory of Computing Systems, 68:1556–1571, 2024. doi:10.1007/s00224-024-10193-9.
- [20] Jean-Claude Spehner. Quelques problémes d’extension, de conjugaison et de présentation des sous-monoïdes d’un monoïde libre. PhD thesis, Univ. Paris, 1976.
- [21] Jean-Claude Spehner. Les systemes entiers d’équations sur un alphabet de 3 variables. In Semigroups Theory and Applications, volume 1320 of LNM, pages 342–357. Springer, 1988. doi:10.1007/BFb0083443.
