270 Donald E. Knuth and Peter B. Bendix Case 4. a = fpal. . .ad, p =j&. . .pd. Here there is no solution of (2.7) unless p = 4, so we may assume p = q and d = d’. Now (2.7) is equivalent to the system of d simultaneous equations S(81, * a -9 8,; Uj) = S(61, . . e) 8,; pj) (2.10) for 1s je d. If d = 0, the general solution is of course to take k = n, 01 = Vl, . . .) a, = v,. Suppose we have obtained the general solution of the system (2.10) for 1 e j < r, where 0 < r -= d; we will show how to extend this to a solution of (2.10) for 1
272 Donald E. Knuth and Peter B. Bendix Word problems in universal algebras 273 we present here a method for solving certain word problems which are general enough to be of wide interest. The principal restriction is that we require all of the relations to be comparable in the sense of $ 2: we require that 3. w (? (3.4) for each relation in R. In such a case we say R is a set of reductions. It follows from Theorem 2 that a + x’ implies a =- a’. (3.5) 4. The completeness theorem. Let R be a set of reductions. We say a word a is irreducible with respect to R if there is no a’ such that a --) a’. It is not difficult to design an algorithm which determines whether or not a given word is irreducible with respect to R. If R = {(II, ol), . . . , (I,, em)}, we must verify that no subword of a has the form of Al, or 22,. . . , or A,,,. If a is reducible with respect to R, the algorithm just outlined can be extended so that it finds some a’ for which a + a’. Now the same procedure can be applied to x’, and if it is reducible we can find a further word a”, andsoon.Wehavea+a’-a”-+...; so by (3.5) and the corollary to Theorem 2, this process eventually terminates. Thus, there is an algorithm which, given any word a and any set of reductions R, finds an irreducible word a0 such that a = ao, with respect to R. We have therefore shown that each word is equivalent to at least one irreducible word. It would be very pleasant if we could also show that each word is equivalent to at most one irreducible word; for then the algorithm above solves the word problem! Take any two words a and p, and use the given algorithm to find irreducible a0 and PO. If a s /3, then a0 = DO, so by hypothesis a0 must be equal to PO. If a + /?, then a0 f PO, so a0 must be unequal to PO. In effect, a0 and /&, are canonical representatives of the equivalence classes. This pleasant state of affairs is of course not true for every set of reductions R, but we will see that it is true for surprisingly many sets and therefore it is an important property worthy of a special name. Let us say R is a complete set of reductions if no two distinct irreducible words are equivalent, with respect to R. We will show in the next section that there is an algorithm to determine whether or not a given set of reductions is complete. First we need to characterize the completeness condition in a more useful way. Let “+*” denote the reflexive transitive completion of “+“, so that a +*p means that there are words ao, al,. . . , a,, for some n 3 0 such that a = a,,, xj+aj+l for On, and a,=lQ. THEOREM 4. A set of reductions R is complete if and only if the following “lattice condition” is satisfied: Jfx-x’anda-a” there exists a wordy such that a’ + *y and a” - * y. Proof. If x + a’ and a -+ XI’, we can find irreducible words aA and aA’ such that a’-+* x; and a’+* 31;‘. Since aA E a;‘, we may take y = ah = aA’ if R is complete. Conversely let us assume that the lattice condition holds; we will show that R is complete. First, we show that if a -+* a0 and a -+* aA, wherea,-, and aA are irreducible, we must have a0 = a;. For if not, the set of all x which violate this property has no infinite decreasing sequence so there must be a “smallest” a (with respect to the Z- relation) such that a -* ao, SC+ *aA f ao, where both a0 and aA are irreducible. Clearly a is not itself irreducible, since otherwise a0 = x = a;. So we must have a + x0, a $ aA, and there must be elements al, a; such that a + al +* ao, a - a; +* a:. By the lattice condition there is a word y such that al +* y and xi -+ * y. Furthermore there is an irreducible word y. such that y +* ~0. Now by (3.5), a > al, so (by the way we chose a) we must have a0 = ~0. Similarly the fact that a r Z; implies that ah = yo. This contradicts the assumption that a0 $ ah. NOW to show that R is complete, we will prove the following fact: Vu G t!$a+*ao,andB-* /IO, where a0 and /?o are irreducible, then a0 = PO. Let the derivation of the relation a G /I be a = og+q++. . . ++o,, = B, where “u5’ denotes “+” or “+ “. If n = 0, we have a = ,B, hence a0 = PO by the proof in the preceding paragraph. If n = 1, we have either a -+ /? or B * a, and again the result holds by the preceding paragraph. Finally if n =- 1, let ol+* o;, where 0; is irreducible. By induction on n, we have 0; = jo, and also 01 = ao. Therefore R and the proof are both complete. 5. The superposition process. Our immediate goal, in view of Theorem 4, is to design an algorithm which is capable of testing whether or not the “lattice condition” is satisfied for all words. En terms of the definitions already given, the hypothesis that a - a’ and a --f a” has the following detailed meaning: There are subwords p1 and pz of a, so that 3: has the form a = q&y1 = y2;32y)2. (5.1) There are also relations (]%I, gl), (1.2, 02) in R, and words 81, . . ., e,, 0’1, . . .: o,, such that and p1 = Wl, . . .> 8,; Rl), p2 = S(Ol, . . ., 0,; 3.2) (5.2) a’ = q1S(6J1, . . . . 8,; pl)yl, a" = ~~S(o.1, . . . . 0,; ~2)w2. (5.3) The lattice condition will hold if we can find a word y such that a’ +* y and a” -.* y. Several possibilities arise, depending on the relative positions of t% and p2 in (5.1). If b1 and ,19~ are disjoint (have no common symbols), then