# Word problem (mathematics)

In mathematics and computer science, a word problem for a set S with respect to a system of finite encodings of its elements is the algorithmic problem of deciding whether two given representatives represent the same element of the set. The problem is commonly encountered in abstract algebra, where given a presentation of an algebraic structure by generators and relators, the problem is to determine if two expressions represent the same element; a prototypical example is the word problem for groups. Less formally, the word problem in an algebra is: given a set of identities E, and two expressions x and y, is it possible to transform x into y using the identities in E as rewriting rules in both directions? While answering this question may not seem hard, the remarkable (and deep) result that emerges, in many important cases, is that the problem is undecidable.

Many, if not most all, undecidable problems in mathematics can be posed as word problems; see the list of undecidable problems for many examples.

## Background and motivation

Many occasions arise in mathematics where one wishes to use a finite amount of information to describe an element of a (typically infinite) set; this issue is particularly apparent in computational mathematics. Traditional models of computation (such as the Turing machine) have storage capacity which is unbounded, so it is in principle possible to perform computations with the elements of infinite sets. On the other hand, since the amount of storage space in use at any one time is finite, we need each element to have a finite representation.

For various reasons, it is not always possible or desirable to use a system of unique encodings, that is, one in which every element has a single encoding; when using an encoding system without uniqueness, the question naturally arises of whether there is an algorithm which, given as input two encodings, decides whether they represent the same element. Such an algorithm is called a solution to the word problem for the encoding system.

## The word problem in combinatorial calculus

The simplest example of an undecidable word problem occurs in combinatory logic: when are two strings of combinators equivalent? Because combinators encode all possible Turing machines, and the equivalence of two Turing machines is undecidable, it follows that the equivalence of two strings of combinators is undecidable.

Likewise, one has essentially the same problem in (untyped) lambda calculus: given two distinct lambda expressions, there is no algorithm which can discern whether they are equivalent or not; equivalence is undecidable. For several typed variants of the lambda calculus, equivalence is decidable by comparison of normal forms.

## The word problem in universal algebra

In algebra, one often studies infinite algebras which are generated (under the finitary operations of the algebra) by finitely many elements. In this case, the elements of the algebra have a natural system of finite encoding as expressions in terms of the generators and operations; the word problem here is thus to determine, given two such expressions, whether they represent the same element of the algebra.

Roughly speaking, the word problem in an algebra is: given a set E of identities (an equational theory), and two terms s and t, is it possible to transform s into t using the identities in E as rewriting rules in both directions?.[1] A proper extension of the word problem is known as the unification problem (a.k.a. the equation solving problem). While the former asks whether two terms are equal, the latter asks whether they have instances that are equal; as a common example, "${\displaystyle 2+3{\stackrel {?}{=}}8+(-3)}$" is a word problem in the integer group ℤ, while "${\displaystyle 2+x{\stackrel {?}{=}}8+(-x)}$" is a unification problem in the same group; since the former terms happen to be equal in ℤ, the latter problem has the substitution ${\displaystyle \{x\mapsto 3\}}$ as a solution.

Substitutions may be ordered into a partial order, thus, unification is the act of finding a join on a lattice.[clarification needed] In this sense, the word problem on a lattice has a solution, namely, the set of all equivalent words is the free lattice.[clarification needed]

One of the most deeply studied cases of the word problem is in the theory of semigroups and groups. There are many groups for which the word problem is not decidable, in that there is no Turing machine that can determine the equivalence of two arbitrary words in a finite time.

The word problem on ground terms is not decidable.[2][clarification needed]

The word problem on free Heyting algebras is difficult;[3] the only known results are that the free Heyting algebra on one generator is infinite, and that the free complete Heyting algebra on one generator exists (and has one more element than the free Heyting algebra).

## Example: A term rewriting system to decide the word problem in the free group

Bläsius and Bürckert [4] demonstrate the Knuth–Bendix algorithm on an axiom set for groups; the algorithm yields a confluent and noetherian term rewrite system that transforms every term into a unique normal form.[5] The rewrite rules are numbered incontiguous since some rules became redundant and were deleted during the algorithm run; the equality of two terms follows from the axioms if and only if both terms are transformed into literally the same normal form term. For example, the terms

${\displaystyle ((a^{-1}\cdot a)\cdot (b\cdot b^{-1}))^{-1}{\stackrel {R2}{\rightsquigarrow }}(1\cdot (b\cdot b^{-1}))^{-1}{\stackrel {R13}{\rightsquigarrow }}(1\cdot 1)^{-1}{\stackrel {R1}{\rightsquigarrow }}1^{-1}{\stackrel {R8}{\rightsquigarrow }}1}$, and
${\displaystyle b\cdot ((a\cdot b)^{-1}\cdot a){\stackrel {R17}{\rightsquigarrow }}b\cdot ((b^{-1}\cdot a^{-1})\cdot a){\stackrel {R3}{\rightsquigarrow }}b\cdot (b^{-1}\cdot (a^{-1}\cdot a)){\stackrel {R2}{\rightsquigarrow }}b\cdot (b^{-1}\cdot 1){\stackrel {R11}{\rightsquigarrow }}b\cdot b^{-1}{\stackrel {R13}{\rightsquigarrow }}1}$

share the same normal form, viz. ${\displaystyle 1}$; therefore both terms are equal in every group. As another example, the term ${\displaystyle 1\cdot (a\cdot b)}$ and ${\displaystyle b\cdot (1\cdot a)}$ has the normal form ${\displaystyle a\cdot b}$ and ${\displaystyle b\cdot a}$, respectively. Since the normal forms are literally different, the original terms cannot be equal in every group. In fact, they are usually different in non-abelian groups.

 A1 ${\displaystyle 1\cdot x}$ ${\displaystyle =x}$ A2 ${\displaystyle x^{-1}\cdot x}$ ${\displaystyle =1}$ A3 ${\displaystyle (x\cdot y)\cdot z}$ ${\displaystyle =x\cdot (y\cdot z)}$
 R1 ${\displaystyle 1\cdot x}$ ${\displaystyle \rightsquigarrow x}$ R2 ${\displaystyle x^{-1}\cdot x}$ ${\displaystyle \rightsquigarrow 1}$ R3 ${\displaystyle (x\cdot y)\cdot z}$ ${\displaystyle \rightsquigarrow x\cdot (y\cdot z)}$ R4 ${\displaystyle x^{-1}\cdot (x\cdot y)}$ ${\displaystyle \rightsquigarrow y}$ R8 ${\displaystyle 1^{-1}}$ ${\displaystyle \rightsquigarrow 1}$ R11 ${\displaystyle x\cdot 1}$ ${\displaystyle \rightsquigarrow x}$ R12 ${\displaystyle (x^{-1})^{-1}}$ ${\displaystyle \rightsquigarrow x}$ R13 ${\displaystyle x\cdot x^{-1}}$ ${\displaystyle \rightsquigarrow 1}$ R14 ${\displaystyle x\cdot (x^{-1}\cdot y)}$ ${\displaystyle \rightsquigarrow y}$ R17 ${\displaystyle (x\cdot y)^{-1}}$ ${\displaystyle \rightsquigarrow y^{-1}\cdot x^{-1}}$