Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/sage/combinat/words/morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -2092,6 +2092,15 @@ def language(self, n, u=None):
...
word: 1010010001,
word: 1010010100]
Test non-extendable D0L-language (Thue-Morse with cube axiom).
This ensures factors from the axiom and early iterations are included::
sage: m = WordMorphism('0->01,1->10')
sage: Word('000') in m.language(3, Word('000'))
True
sage: Word('010101') in m.language(6, Word('000'))
True
"""
W = self.domain()
if self.codomain() != W:
Expand Down Expand Up @@ -2123,10 +2132,19 @@ def language(self, n, u=None):
# of two letter words
L2 = (w for w in self._language_naive(3, u) if len(w) == 2)
L = set()
for u in L2:
v = im[u[0]] + im[u[1]]
for v in L2:
w = im[v[0]] + im[v[1]]
for k in range(len(w) - n + 1):
L.add(w[k:k + n])

# Also add factors from the axiom and early iterations
# to handle non-extendable elements in the D0L-language
v = u
for _ in range(p + 1):
for k in range(len(v) - n + 1):
L.add(v[k:k + n])
v = self(v)

return L

def conjugate(self, pos):
Expand Down
Loading