---
title: "Elementary Operators for Words"
canonical: "https://docs.magma-maths.org/v2.30-1/FinitelyPresentedGroups/FinitelyPresentedSemigroups/operation.html"
source: "https://docs.magma-maths.org/v2.30-1/FinitelyPresentedGroups/FinitelyPresentedSemigroups/operation.md"
part: "Finitely Presented Groups"
chapter: "Finitely Presented Semigroups"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Finitely Presented Groups", "source": "https://docs.magma-maths.org/v2.30-1/FinitelyPresentedGroups/index-finitely-presented-groups.md"}
  - {"title": "Finitely Presented Semigroups", "source": "https://docs.magma-maths.org/v2.30-1/FinitelyPresentedGroups/FinitelyPresentedSemigroups/index-finitely-presented-semigroups.md"}
prev: {"title": "The Construction of Free Semigroups and their Elements", "source": "https://docs.magma-maths.org/v2.30-1/FinitelyPresentedGroups/FinitelyPresentedSemigroups/creation.md"}
next: {"title": "Specification of a Presentation", "source": "https://docs.magma-maths.org/v2.30-1/FinitelyPresentedGroups/FinitelyPresentedSemigroups/presentation.md"}
intrinsics:
  - {"name": "*", "signature": "u * v: SgpFPElt, SgpFPElt -> SgpFPElt"}
  - {"name": "^", "signature": "u ^ n: SgpFPElt, RngIntElt -> SgpFPElt"}
  - {"name": "!", "signature": "G ! Q: SgpFP, [ SgpFPElt ] -> SgpFPElt"}
  - {"name": "#", "signature": "# u: SgpFPElt -> RngIntElt"}
  - {"name": "eq", "signature": "u eq v: SgpFPElt, SgpFPElt -> BoolElt"}
  - {"name": "ne", "signature": "u ne v: SgpFPElt, SgpFPElt -> BoolElt"}
  - {"name": "lt", "signature": "u lt v: SgpFPElt, SgpFPElt -> BoolElt"}
  - {"name": "le", "signature": "u le v: SgpFPElt, SgpFPElt -> BoolElt"}
  - {"name": "ge", "signature": "u ge v: SgpFPElt, SgpFPElt -> BoolElt"}
  - {"name": "gt", "signature": "u gt v: SgpFPElt, SgpFPElt -> BoolElt"}
  - {"name": "IsOne", "signature": "IsOne(u): MonFPElt -> BoolElt"}
---

# Elementary Operators for Words

## Multiplication and Exponentiation

The word operations defined here may be applied either to the words of a free semigroup or the words of a semigroup with non-trivial relations.

<a id="operation-op-times-sgpfpelt-sgpfpelt"></a>
### `u * v: SgpFPElt, SgpFPElt -> SgpFPElt`

Given words $u$ and $v$ belonging to the same fp-semigroup $S$, return the product of $u$ and $v$.

<a id="operation-op-pow-sgpfpelt-rngintelt"></a>
### `u ^ n: SgpFPElt, RngIntElt -> SgpFPElt`

The $n$-th power of the word $u$, where $n$ is a positive integer.

<a id="operation-op-sgpfp-sgpfpelt"></a>
### `G ! Q: SgpFP, [ SgpFPElt ] -> SgpFPElt`

Given a sequence $Q$ of words belonging to the fp-semigroup $G$, return the product $Q[1] Q[2] \cdots Q[n]$ of the terms of $Q$ as a word in $G$.

## The Length of a Word

<a id="operation-operation-sgpfpelt-rngintelt"></a>
### `# u: SgpFPElt -> RngIntElt`

The length of the word $u$.

## Equality and Comparison

The words of an fp-semigroup $S$ are ordered first by length and then lexicographically. The lexicographic ordering is determined by the following ordering on the generators:

$$
S.1  <  S.2 < S.3 < S.4 < \cdots
$$

Here, $u$ and $v$ are words belonging to some common fp-semigroup.

<a id="operation-op-eq-sgpfpelt-sgpfpelt"></a>
### `u eq v: SgpFPElt, SgpFPElt -> BoolElt`

Returns `true` if the words $u$ and $v$ are identical (as elements of the appropriate free semigroup), `false` otherwise.

<a id="operation-op-ne-sgpfpelt-sgpfpelt"></a>
### `u ne v: SgpFPElt, SgpFPElt -> BoolElt`

Returns `true` if the words $u$ and $v$ are not identical (as elements of the appropriate free semigroup), `false` otherwise.

<a id="operation-op-lt-sgpfpelt-sgpfpelt"></a>
### `u lt v: SgpFPElt, SgpFPElt -> BoolElt`

Returns `true` if the word $u$ precedes the word $v$, with respect to the ordering defined above for elements of an fp-semigroup, `false` otherwise.

<a id="operation-op-le-sgpfpelt-sgpfpelt"></a>
### `u le v: SgpFPElt, SgpFPElt -> BoolElt`

Returns `true` if the word $u$ either precedes, or is equal to, the word $v$, with respect to the ordering defined above for elements of an fp-semigroup, `false` otherwise.

<a id="operation-op-ge-sgpfpelt-sgpfpelt"></a>
### `u ge v: SgpFPElt, SgpFPElt -> BoolElt`

Returns `true` if the word $u$ either follows, or is equal to, the word $v$, with respect to the ordering defined above for elements of an fp-semigroup, `false` otherwise.

<a id="operation-op-gt-sgpfpelt-sgpfpelt"></a>
### `u gt v: SgpFPElt, SgpFPElt -> BoolElt`

Returns `true` if the word $u$ follows the word $v$, with respect to the ordering defined above for elements of an fp-semigroup.

<a id="function-isone-monfpelt"></a>
### `IsOne(u): MonFPElt -> BoolElt`

Returns `true` if the word $u$, belonging to the monoid $M$, is the identity word, `false` otherwise.
