[ref] 36 Rewriting Systems

[Top] [Up] [Previous] [Next] [Index]

# 36 Rewriting Systems

### Sections

1. Operations on rewriting systems
2. Operations on elements of the algebra
3. Properties of rewriting systems
4. Developing rewriting systems

Rewriting systems in GAP are a framework for dealing with the very general task of rewriting elements of a free (or term) algebra in some normal form. Although most rewriting systems currently in use are string rewriting systems (where the algebra has only one binary operation which is associative) the framework in GAP is general enough to encompass the task of rewriting algebras of any signature from groups to semirings.

Rewriting systems are already implemented in GAP for finitely presented semigroups and for pc groups. The use of these particular rewriting systems is described in the corresponding chapters. We describe here only the general framework of rewriting systems with a particular emphasis on material which would be helpful for a developer implementing a rewriting system.

We fix some definitions and terminology for the rest of this chapter. Let T be a term algebra in some signature. A term rewriting system for T is a set of ordered pairs of elements of T of the form (l, r). Viewed as a set of relations, the rewriting system determines a presentation for a quotient algebra A of T.

When we take into account the fact that the relations are expressed as ordered pairs, we have a way of reducing the elements of T. Suppose an element u of T has a subword l and (l,r) is a rule of the rewriting system, then we can replace the subterm l of u by the term r and obtain a new word v. We say that we have rewritten u as v. Note that u and v represent the same element of A. If u can not be rewritten using any rule of the rewriting system we sat that u is reduced.

## 36.1 Operations on rewriting systems

- `IsRewritingSystem(` obj`) C`

  This is the category in which all rewriting systems lie.

- `Rules(` rws`) A`

  The rules comprising the rewriting system. Note that these may change through the life of the rewriting system, however they will always be a set of defining relations of the algebra described by the rewriting system.

- `OrderOfRewritingSystem(` rws`) A`
- `OrderingOfRewritingSystem(` rws`) A`

  return the ordering of the rewriting system rws.

- `ReducedForm(` rws`,` u`) O`

  Given an element u in the free (or term) algebra over which rws is defined, rewrite u by successive applications of the rules of rws until no further rewriting is possible, and return the resulting element of T.

- `IsConfluent(` rws`) P`
- `IsConfluent(` A`) P`

  return `true` if and only if the rewriting system rws is confluent. A rewriting system is confluent if, for every two words u and v in the free algebra T which represent the same element of the algebra A defined by rws, `ReducedForm(`rws`,`u`) = ReducedForm(`rws`,`v`)` as words in the free algebra T. This element is the unique normal form of the element represented by u.

  In its second form, if A is an algebra with a canonical rewriting system associated with it, `IsConfluent` checks whether that rewriting system is confluent.

  Also see IsConfluent!for pc groups.

- `ConfluentRws(` rws`) A`

  Return a new rewriting system defining the same algebra as rws which is confluent.

- `IsReduced(` rws`) P`

  A rewriting system is reduced if for each rule (l, r), l and r are both reduced.

- `ReduceRules(` rws`) O`

  Reduce rules and remove redundant rules to make rws reduced.

- `AddRule(` rws`,` rule`) O`

  Add rule to a rewriting system rws.

- `AddRuleReduced(` rws`,` rule`) O`

  Add rule to rewriting system rws. Performs a reduction operation on the resulting system, so that if rws is reduced it will remain reduced.

- `MakeConfluent(` rws`) O`

  Add rules (and perhaps reduce) in order to make rws confluent

- `GeneratorsOfRws(` rws`) A`

- `AddGenerators(` rws`,` gens`) O`

  ## 36.2 Operations on elements of the algebra

  In this section let u denote an element of the term algebra T representing [u] in the quotient algebra A.

- `ReducedProduct(` rws`,` u`,` v`) O`

  The result is w where [w] = [u][v] in A and w is in reduced form.

  The remaining operations are defined similarly when they are defined (as determined by the signature of the term algebra).

- `ReducedSum(` rws`,` left`,` right`) O`

- `ReducedOne(` rws`) O`

- `ReducedAdditiveInverse(` rws`,` obj`) O`

- `ReducedComm(` rws`,` left`,` right`) O`

- `ReducedConjugate(` rws`,` left`,` right`) O`

- `ReducedDifference(` rws`,` left`,` right`) O`

- `ReducedInverse(` rws`,` obj`) O`

- `ReducedLeftQuotient(` rws`,` left`,` right`) O`

- `ReducedPower(` rws`,` obj`,` pow`) O`

- `ReducedQuotient(` rws`,` left`,` right`) O`

- `ReducedScalarProduct(` rws`,` left`,` right`) O`

- `ReducedZero(` rws`) O`

  ## 36.3 Properties of rewriting systems

  The following properties may be used to identify the type of term algebra over which the rewriting system is defined.

- `IsBuiltFromAdditiveMagmaWithInverses(` obj`) P`

- `IsBuiltFromMagma(` obj`) P`

- `IsBuiltFromMagmaWithOne(` obj`) P`

- `IsBuiltFromMagmaWithInverses(` obj`) P`

- `IsBuiltFromSemigroup(` obj`) P`

- `IsBuiltFromGroup(` obj`) P`

  ## 36.4 Developing rewriting systems

  The key point to note about rewriting systems is that they have properties such as `IsConfluent` and attributes such as `Rules`, however they are rarely stored, but rather computed afresh each time they are asked for, from data stored in the private members of the rewriting system object. This is because a rewriting system often evolves through a session, starting with some rules which define the algebra A as relations, and then adding more rules to make the system confluent. For example, in the case of Knuth-Bendix rewriting systems (see Chapter Finitely Presented Semigroups and Monoids), the function `CreateKnuthBendixRewritingSystem` creating the rewriting system (in `kbsemi.gi`) uses

      kbrws := Objectify(NewType(rwsfam,
        IsMutable and IsKnuthBendixRewritingSystem and
        IsKnuthBendixRewritingSystemRep),
        rec(family:= fam,
        reduced:=false,
        tzrules:=List(relwco,i->
         [LetterRepAssocWord(i[1]),LetterRepAssocWord(i[2])]),
        pairs2check:=CantorList(Length(r)),
        ordering:=wordord,
        freefam:=freefam));

  In particular, since we don't use the filter `IsAttributeStoringRep` in the `Objectify`, whenever `IsConfluent` is called, the appropriate method to determine confluence is called.

  [Top] [Up] [Previous] [Next] [Index]

  GAP 4 manual
  May 2002