julia> include("Monoids.jl")
julia> using .Monoids
julia> function example_monoid(n::Integer)
A = Alphabet([[Symbol('a', i) for i in 1:n]; [Symbol('b', i) for i in 1:n]])
F = FreeMonoid(A)
rels = let S = gens(F)
squares = [g^2=>one(g) for g in S]
@views a, b = S[1:n], S[n+1:end]
aibj = [a[i]*b[j] => b[j]*a[i] for i in 1:n for j in 1:n]
[squares; aibj]
end
return F/rels
end
example_monoid (generic function with 1 method)
julia> M = example_monoid(2)
monoid with 8 relations over Alphabet{Symbol}[:a1, :a2, :b1, :b2]
julia> a, b = M(rand(1:4, 20)), M(rand(1:4, 20))
(a1*a2*a1*a2*b1*b2*b1*b2*b1*b2, a2*a1*a2*a1*a2*b2*b1*b2)
julia> a*b
a2*b1*b2*b1
julia> b*a
a2*a1*a2*a1*a2*a1*a2*a1*a2*b2*b1*b2*b1*b2*b1*b2*b1*b2
julia> x = M(rand(1:4, 20)); isreduced(x)
false
julia> y = deepcopy(x); normalform!(y); isreduced(y)
true
julia> x === y
false
julia> x == y
true
See: https://gist.github.com/kalmarek/9475f36e768046cd7ef7fc08891bf553