Morphic words

This modules implements morphic words (letter-to-letter coding of fixed point of a morphism).

AUTHORS:

  • Jana Lepsova (January 2021): initial version

EXAMPLES:

Creation of the fixed point of a morphism:

sage: m = WordMorphism('a->abc,b->baba,c->ca')
sage: w = m.fixed_point('a'); w
word: abcbabacababaabcbabaabccaabcbabaabcbabaa...
sage: w.length()
+Infinity
>>> from sage.all import *
>>> m = WordMorphism('a->abc,b->baba,c->ca')
>>> w = m.fixed_point('a'); w
word: abcbabacababaabcbabaabccaabcbabaabcbabaa...
>>> w.length()
+Infinity

Computing the \(n\)-th letter of a fixed point is fast as it is using the abstract numeration system associated to the morphism and the starting letter, see chapter 3 of the book [BR2010b]:

sage: w[10000000]                                                                   # needs sage.modules
'b'
>>> from sage.all import *
>>> w[Integer(10000000)]                                                                   # needs sage.modules
'b'
class sage.combinat.words.morphic.WordDatatype_morphic(parent, morphism, letter, coding=None, length=+Infinity)[source]

Bases: WordDatatype_callable

Datatype for a morphic word defined by a morphism, a starting letter and a coding.

representation(n)[source]

Return the representation of the integer n in the numeration system associated to the morphism.

INPUT:

  • n – nonnegative integer

OUTPUT: list

EXAMPLES:

sage: m = WordMorphism('a->ab,b->a')
sage: w = m.fixed_point('a')
sage: w.representation(5)                                                   # needs sage.modules
[1, 0, 0, 0]
>>> from sage.all import *
>>> m = WordMorphism('a->ab,b->a')
>>> w = m.fixed_point('a')
>>> w.representation(Integer(5))                                                   # needs sage.modules
[1, 0, 0, 0]

When the morphic word is finite:

sage: m = WordMorphism("a->ab,b->,c->cdab,d->dcab")
sage: w = m.fixed_point("a")
sage: w.representation(0)                                                   # needs sage.modules
[]
sage: w.representation(1)                                                   # needs sage.modules
[1]
sage: w.representation(2)                                                   # needs sage.modules
Traceback (most recent call last):
...
IndexError: index (=2) out of range, the fixed point is finite and has length 2
>>> from sage.all import *
>>> m = WordMorphism("a->ab,b->,c->cdab,d->dcab")
>>> w = m.fixed_point("a")
>>> w.representation(Integer(0))                                                   # needs sage.modules
[]
>>> w.representation(Integer(1))                                                   # needs sage.modules
[1]
>>> w.representation(Integer(2))                                                   # needs sage.modules
Traceback (most recent call last):
...
IndexError: index (=2) out of range, the fixed point is finite and has length 2