1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-11-19 14:35:28 +01:00

move rewrite_from_left!(v, w, ::Alphabet) to KnuthBendix.jl

This commit is contained in:
Marek Kaluba 2021-05-07 18:15:02 +02:00
parent 4c8eccf72b
commit 6e14d30903
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15

View File

@ -47,31 +47,3 @@ Defaults to the rewriting in the free group.
end
return KnuthBendix.rewrite_from_left!(res, word(g), rewriting(parent(g)))
end
"""
free_rewrite!(v::AbstractWord, w::AbstractWord, A::Alphabet)
Append `w` to `v` applying free reductions as defined by the inverses of `A`.
"""
free_rewrite!(v::AbstractWord, w::AbstractWord, A::Alphabet) =
KnuthBendix.rewrite_from_left!(v, w, A)
function KnuthBendix.rewrite_from_left!(
v::AbstractWord,
w::AbstractWord,
A::Alphabet
)
while !isone(w)
if isone(v)
push!(v, popfirst!(w))
else
# the first check is for monoids only
if KnuthBendix.hasinverse(last(v), A) && inv(A, last(v)) == first(w)
pop!(v)
popfirst!(w)
else
push!(v, popfirst!(w))
end
end
end
return v
end