Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Replace reach with _language_naive
Browse files Browse the repository at this point in the history
  • Loading branch information
mrejmon committed May 21, 2021
1 parent 9c216e0 commit da0536b
Showing 1 changed file with 4 additions and 28 deletions.
32 changes: 4 additions & 28 deletions src/sage/combinat/words/morphism.py
Expand Up @@ -3446,7 +3446,8 @@ def impl():

if w is None:
w = self._morph
f = self.restrict_domain(self.reach(w))
reach = self._language_naive(2, self._domain(w))
f = self.restrict_domain([x[0] for x in reach])
f._codomain = f._domain
g, _, k, _ = f.simplify_injective()
g._codomain = g._domain
Expand Down Expand Up @@ -3502,7 +3503,8 @@ def infinite_repetitions_growing(self, w=None):
"""
if w is None:
w = self._morph
f = self.restrict_domain(self.reach(w))
reach = self._language_naive(2, self._domain(w))
f = self.restrict_domain([x[0] for x in reach])
f._codomain = f._domain
g, _, k, _ = f.simplify_injective()
g._codomain = g._domain
Expand Down Expand Up @@ -3540,32 +3542,6 @@ def infinite_repetitions_growing(self, w=None):

return result

def reach(self, w):
r"""
Return the set of letters which occur in words of
`\{m^n(w) | n \ge 0\}`, where `m` is this morphism and `w` is a word
(finite iterable is enough) inputted as a parameter.
Requires this morphism to be an endomorphism.
EXAMPLES::
sage: sorted(WordMorphism('a->ac,b->ce,c->bd,d->d,e->').reach('c'))
['b', 'c', 'd', 'e']
"""
if not self.is_endomorphism():
raise TypeError(f'self ({self}) is not an endomorphism')

visited = set(w)
todo = list(visited)
while todo:
a = todo.pop()
for b in self.image(a):
if b not in visited:
visited.add(b)
todo.append(b)
return visited

def simplify(self, Z=None):
r"""
If this morphism is simplifiable, return morphisms `h` and `k` such that
Expand Down

0 comments on commit da0536b

Please sign in to comment.