String Operations on Words

Eliminate(u, x, v) : SgpFPElt, SgpFPElt, SgpFPElt -> SgpFPElt
Given words u and v, and a generator x, belonging to a semigroup S, return the word obtained from u by replacing each occurrence of x by v.
Match(u, v, f) : SgpFPElt, SgpFPElt, RngIntElt -> BoolElt, RngIntElt
Suppose u and v are words belonging to the same semigroup S, and that f is an integer such that 1 ≤f ≤# u. If v is a subword of u, the function returns true, as well as the least integer l such that:
(a)
l≥f; and,
(b)
v appears as a subword of u, starting at the l-th letter of u.

If no such l is found, Match returns only false.

Random(S, m, n) : SgpFP, RngIntElt, RngIntElt -> SgpFPElt
A random word of length l in the generators of the semigroup S, where m ≤l ≤n.
RotateWord(u, n) : SgpFPElt, RngIntElt -> SgpFPElt
The word obtained by cyclically permuting the word u by n places. If n is positive, the rotation is from left to right, while if n is negative the rotation is from right to left. In the case where n is zero, the function returns u.
Substitute(u, f, n, v) : SgpFPElt, RngIntElt, SgpFPElt, RngIntElt -> SgpFPElt
Given words u and v belonging to a semigroup S, and non-negative integers f and n, this function replaces the substring of u of length n, starting at position f, by the word v. Thus, if u = xi1 ... xif ... x_(if + n - 1) ... xim then the substring xif ... x_(if + n - 1) is replaced by v. If u and v belong to a monoid M and the function is invoked with v = Id(M), then the substring xif ... x_(if + n - 1) of u is deleted.
Subword(u, f, n) : SgpFPElt, RngIntElt, RngIntElt -> SgpFPElt
The subword of the word u comprising the n consecutive letters commencing at the f-th letter of u.
ElementToSequence(u) : SgpFPElt -> [ SgpFPElt ]
Eltseq(u) : SgpFPElt -> [ SgpFPElt ]
The sequence obtained by decomposing u into the indices of its constituent generators. Thus, if u = xi1 ... xim, then the sequence constructed by ElementToSequence is [i1, i2, ..., im].
V2.28, 13 July 2023