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:
parent
4c8eccf72b
commit
6e14d30903
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user