free.spad line 110 [edit on github]
The free monoid on a set S is the monoid of finite products of the form reduce(*, [ where the si ^ ni])si's are in S, and the ni's are nonnegative integers. The multiplication is not commutative. When S is an OrderedSet, then FreeMonoid(S) has order: for two elements x and y the relation x < y holds if either length(x) < length(y) holds or if these lengths are equal and if x is smaller than y w.r.t. the lexicographical ordering induced by S.
x * s returns the product of x by s on the right.
s * x returns the product of x by s on the left.
s ^ n returns the product of s by itself n times.
divide(x, y) returns the left and right exact quotients of x by y, i.e. [l, r] such that x = l * y * r, "failed" if x is not of the form l * y * r.
factors(a1^e1, ..., an^en) returns [[a1, e1], ..., [an, en]].
first(x) returns the first letter of x.
hclf(x, y) returns the highest common left factor of x and y, i.e. the largest d such that x = d a and y = d b.
hcrf(x, y) returns the highest common right factor of x and y, i.e. the largest d such that x = a d and y = b d.
length(x) returns the length of x.
lexico(x, y) returns true iff x is smaller than y w.r.t. the pure lexicographical ordering induced by S.
lquo(x, y) returns the exact left quotient of x by y i.e. q such that x = y * q, "failed" if x is not of the form y * q.
lquo(x, s) returns the exact left quotient of x by s.
mapExpon(f, a1^e1 ... an^en) returns a1^f(e1) ... an^f(en).
mapGen(f, a1^e1 ... an^en) returns f(a1)^e1 ... f(an)^en.
mirror(x) returns the reversed word of x.
nthExpon(x, n) returns the exponent of the n^th monomial of x.
nthFactor(x, n) returns the factor of the n^th monomial of x.
overlap(x, y) returns [l, m, r] such that x = l * m, y = m * r and l and r have no overlap, i.e. overlap(l, r) = [l, 1, r].
rest(x) returns x except the first letter.
rquo(x, y) returns the exact right quotient of x by y i.e. q such that x = q * y, "failed" if x is not of the form q * y.
rquo(x, s) returns the exact right quotient of x by s.
size(x) returns the number of monomials in x.
varList(x) returns the list of variables of x.