From 652ec4ce51491511c04b266b8ab2826a933eabec Mon Sep 17 00:00:00 2001 From: cxzhong Date: Wed, 19 Nov 2025 19:29:39 +0800 Subject: [PATCH 1/2] Add tests for non-extendable D0L-language in WordMorphism --- src/sage/combinat/words/morphism.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/sage/combinat/words/morphism.py b/src/sage/combinat/words/morphism.py index fe77b50fcfd..874fe5fb4ef 100644 --- a/src/sage/combinat/words/morphism.py +++ b/src/sage/combinat/words/morphism.py @@ -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: @@ -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): From 8724bfb291cd9d30d72da9f28b34f827aa97dbca Mon Sep 17 00:00:00 2001 From: Chenxin Zhong Date: Wed, 19 Nov 2025 19:38:17 +0800 Subject: [PATCH 2/2] fix lint --- src/sage/combinat/words/morphism.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/combinat/words/morphism.py b/src/sage/combinat/words/morphism.py index 874fe5fb4ef..fae124378a8 100644 --- a/src/sage/combinat/words/morphism.py +++ b/src/sage/combinat/words/morphism.py @@ -2136,7 +2136,7 @@ def language(self, n, u=None): 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 @@ -2144,7 +2144,7 @@ def language(self, n, u=None): for k in range(len(v) - n + 1): L.add(v[k:k + n]) v = self(v) - + return L def conjugate(self, pos):