The Knuth–Bendix completion algorithm (named after Donald Knuth and Peter Bendix[1]) is a semi-decision[2] [3] algorithm for transforming a set of equations (over terms) into a confluent term rewriting system. When the algorithm succeeds, it effectively solves the word problem for the specified algebra.
Buchberger's algorithm for computing Gröbner bases is a very similar algorithm. Although developed independently, it may also be seen as the instantiation of Knuth–Bendix algorithm in the theory of polynomial rings.
For a set E of equations, its deductive closure is the set of all equations that can be derived by applying equations from E in any order.Formally, E is considered a binary relation, is its rewrite closure, and is the equivalence closure of .For a set R of rewrite rules, its deductive closure (∘) is the set of all equations that can be confirmed by applying rules from R left-to-right to both sides until they are literally equal.Formally, R is again viewed as a binary relation, is its rewrite closure, is its converse, and (∘) is the relation composition of their reflexive transitive closures (and).
For example, if are the group axioms, the derivation chain
demonstrates that a−1⋅(a⋅b) b is a member of Es deductive closure.If is a "rewrite rule" version of E, the derivation chains
demonstrate that (a−1⋅a)⋅b ∘ b is a member of Rs deductive closure.However, there is no way to derive a−1⋅(a⋅b) ∘ b similar to above, since a right-to-left application of the rule is not allowed.
The Knuth–Bendix algorithm takes a set E of equations between terms, and a reduction ordering (>) on the set of all terms, and attempts to construct a confluent and terminating term rewriting system R that has the same deductive closure as E.While proving consequences from E often requires human intuition, proving consequences from R does not.For more details, see Confluence (abstract rewriting)#Motivating examples, which gives an example proof from group theory, performed both using E and using R.
Given a set E of equations between terms, the following inference rules can be used to transform it into an equivalent convergent term rewrite system (if possible):[4] [5] They are based on a user-given reduction ordering (>) on the set of all terms; it is lifted to a well-founded ordering (▻) on the set of rewrite rules by defining if
Delete | ‹ E∪ | , R › | ⊢ | ‹ E | , R › | ||
Compose | ‹ E | , R∪ › | ⊢ | ‹ E | , R∪ › | if | |
Simplify | ‹ E∪ | , R › | ⊢ | ‹ E∪ | , R › | if | |
Orient | ‹ E∪ | , R › | ⊢ | ‹ E | , R∪ › | if | |
Collapse | ‹ E | , R∪ › | ⊢ | ‹ E∪ | , R › | if by with | |
Deduce | ‹ E | , R › | ⊢ | ‹ E∪ | , R › | if is a critical pair of R |
The following example run, obtained from the E theorem prover, computes a completion of the (additive) group axioms as in Knuth, Bendix (1970).It starts with the three initial equations for the group (neutral element 0, inverse elements, associativity), using f(X,Y)
for X+Y, and i(X)
for −X. The 10 starred equations turn out to constitute the resulting convergent rewrite system."pm" is short for "paramodulation", implementing deduce. Critical pair computation is an instance of paramodulation for equational unit clauses."rw" is rewriting, implementing compose, collapse, and simplify.Orienting of equations is done implicitly and not recorded.
Nr | ALIGN=RIGHT | Lhs | Rhs | Source | |||
1: | ALIGN=RIGHT | f(X,0) | = | X | initial("GROUP.lop", at_line_9_column_1) | ||
2: | ALIGN=RIGHT | f(X,i(X)) | = | 0 | initial("GROUP.lop", at_line_12_column_1) | ||
3: | ALIGN=RIGHT | f(f(X,Y),Z) | = | f(X,f(Y,Z)) | initial("GROUP.lop", at_line_15_column_1) | ||
5: | ALIGN=RIGHT | f(X,Y) | = | f(X,f(0,Y)) | pm(3,1) | ||
6: | ALIGN=RIGHT | f(X,f(Y,i(f(X,Y)))) | = | 0 | pm(2,3) | ||
7: | ALIGN=RIGHT | f(0,Y) | = | f(X,f(i(X),Y)) | pm(3,2) | ||
27: | ALIGN=RIGHT | f(X,0) | = | f(0,i(i(X))) | pm(7,2) | ||
36: | ALIGN=RIGHT | X | = | f(0,i(i(X))) | rw(27,1) | ||
46: | ALIGN=RIGHT | f(X,Y) | = | f(X,i(i(Y))) | pm(5,36) | ||
52: | ALIGN=RIGHT | f(0,X) | = | X | rw(36,46) | ||
60: | ALIGN=RIGHT | i(0) | = | 0 | pm(2,52) | ||
63: | ALIGN=RIGHT | i(i(X)) | = | f(0,X) | pm(46,52) | ||
64: | ALIGN=RIGHT | f(X,f(i(X),Y)) | = | Y | rw(7,52) | ||
67: | ALIGN=RIGHT | i(i(X)) | = | X | rw(63,52) | ||
74: | ALIGN=RIGHT | f(i(X),X) | = | 0 | pm(2,67) | ||
79: | ALIGN=RIGHT | f(0,Y) | = | f(i(X),f(X,Y)) | pm(3,74) | ||
83: | ALIGN=RIGHT | Y | = | f(i(X),f(X,Y)) | rw(79,52) | ||
134: | ALIGN=RIGHT | f(i(X),0) | = | f(Y,i(f(X,Y))) | pm(83,6) | ||
151: | ALIGN=RIGHT | i(X) | = | f(Y,i(f(X,Y))) | rw(134,1) | ||
165: | ALIGN=RIGHT | f(i(X),i(Y)) | = | i(f(Y,X)) | pm(83,151) |
An important case in computational group theory are string rewriting systems which can be used to give canonical labels to elements or cosets of a finitely presented group as products of the generators. This special case is the focus of this section.
The critical pair lemma states that a term rewriting system is locally confluent (or weakly confluent) if and only if all its critical pairs are convergent. Furthermore, we have Newman's lemma which states that if an (abstract) rewriting system is strongly normalizing and weakly confluent, then the rewriting system is confluent. So, if we can add rules to the term rewriting system in order to force all critical pairs to be convergent while maintaining the strong normalizing property, then this will force the resultant rewriting system to be confluent.
M=\langleX\midR\rangle
Although the choice of a canonical form can theoretically be made in an arbitrary fashion this approach is generally not computable. (Consider that an equivalence relation on a language can produce an infinite number of infinite classes.) If the language is well-ordered then the order < gives a consistent method for defining minimal representatives, however computing these representatives may still not be possible. In particular, if a rewriting system is used to calculate minimal representatives then the order < should also have the property:
A < B → XAY < XBY for all words A,B,X,Y
This property is called translation invariance. An order that is both translation-invariant and a well-order is called a reduction order.
From the presentation of the monoid it is possible to define a rewriting system given by the relations R. If A x B is in R then either A < B in which case B → A is a rule in the rewriting system, otherwise A > B and A → B. Since < is a reduction order a given word W can be reduced W > W_1 > ... > W_n where W_n is irreducible under the rewriting system. However, depending on the rules that are applied at each Wi → Wi+1 it is possible to end up with two different irreducible reductions Wn ≠ W'm of W. However, if the rewriting system given by the relations is converted to a confluent rewriting system via the Knuth–Bendix algorithm, then all reductions are guaranteed to produce the same irreducible word, namely the normal form for that word.
\langleX\midR\rangle
X
R
<
X
Pi=Qi
R
Qi<Pi
Pi → Qi
First, if any relation
Pi=Qi
Pi
Qi
Next, we add more reductions (that is, rewriting rules) to eliminate possible exceptions of confluence. Suppose that
Pi
Pj
Pi
Pj
Pi=BC
Pj=AB
Pi=AB
Pj=BC
Pi
Pj
Pi=B
Pj=ABC
Pi=ABC
Pj=B
Reduce the word
ABC
Pi
Pj
r1,r2
r1 ≠ r2
maxr1,r2 → minr1,r2
R
After adding a rule to
R
R
Repeat the procedure until all overlapping left sides have been checked.
Consider the monoid:
\langlex,y\midx3=y3=(xy)3=1\rangle
Our beginning three reductions are therefore
A suffix of
x3
x
(xy)3=xyxyxy
x3yxyxy
yxyxy
x2
yxyxy=x2
Similarly, using
xyxyxy3
xyxyx=y2
Both of these rules obsolete, so we remove it.
Next, consider
x3yxyx
yxyx=x2y2
Considering
xyxyx3
xyxy=y2x2
These obsolete rules and, so we remove them.
Now, we are left with the rewriting system
Checking the overlaps of these rules, we find no potential failures of confluence. Therefore, we have a confluent rewriting system, and the algorithm terminates successfully.
The order of the generators may crucially affect whether the Knuth–Bendix completion terminates. As an example, consider the free Abelian group by the monoid presentation:
\langlex,y,x-1,y-1|xy=yx,xx-1=x-1x=yy-1=y-1y=1\rangle.
The Knuth–Bendix completion with respect to lexicographic order
x<x-1<y<y-1
x<y<x-1<y-1
If Knuth–Bendix does not succeed, it will either run forever and produce successive approximations to an infinite complete system, or fail when it encounters an unorientable equation (i.e. an equation that it cannot turn into a rewrite rule). An enhanced version will not fail on unorientable equations and produces a ground confluent system, providing a semi-algorithm for the word problem.[7]
The notion of logged rewriting discussed in the paper by Heyworth and Wensley listed below allows some recording or logging of the rewriting process as it proceeds. This is useful for computing identities among relations for presentations of groups.