In [20]:
# load the package badic (you can install it with "sage -pip install badic [--user]")
from badic import *
In [3]:
# take the beta-adic set with beta the Tribonnacci number, and all words over the alphabet {0,1}
m = BetaAdicSet(x^3-x^2-x-1, [0,1])
m = m.reduced()  # change the automaton to represent the same set of points
                 # but with each point represented by an unique word
m
Out[3]:
b-adic set with b root of x^3 - x^2 - x - 1, and an automaton of 4 states and 2 letters
In [6]:
# allow the user to draw what he want with the beta-adic set m
# !! this function works only if the SDL2 library was installed before installing the badic package !!
mud = m.user_draw()
mud
Out[6]:
b-adic set with b root of x^3 - x^2 - x - 1, and an automaton of 11 states and 2 letters
In [7]:
mud.plot()
Out[7]:
In [9]:
# compute a substitution describing the set drawn by the user
d = mud.substitution()
d
Out[9]:
{1: [8, 2, 7, 5],
 2: [8, 2, 3, 1, 3, 2, 7, 5],
 3: [8, 2, 7, 4, 6, 2, 7, 5],
 4: [8, 2, 7, 4, 6, 2, 7, 5, 8, 2, 3],
 5: [8, 2, 7, 4, 6, 2, 7, 5, 8, 2, 3, 1, 3, 2, 7, 5, 8, 2, 7, 4],
 6: [1, 3, 2, 7, 5, 8, 2, 7, 4, 6, 2, 7, 5],
 7: [8, 2, 7, 4, 6, 2, 7, 5, 8, 2, 7, 5],
 8: [6, 2, 7, 5, 8, 2, 7, 4, 6, 2, 7, 5],
 9: [9, 2, 7, 5, 8, 2, 7, 4, 6, 2, 7, 5]}
In [11]:
# check that the Rauzy fractal of the substitution computed corresponds to what was expected
s = WordMorphism(d)
s.rauzy_fractal_plot()
Out[11]:
In [ ]:
 
In [21]:
# define a beta-adic set with an infinity of pieces going to zero
# the automaton given describe the set of words 0^*1000{0,1}^*
mi = BetaAdicSet(m.b, dag.AnyWord([0]).concat(dag.Word([1,0,0,0]).concat(dag.AnyWord([0,1])))).proj(m)
mi.plot()
Out[21]:
In [23]:
# automaton of this beta-adic set
mi.a.plot()
Out[23]:
In [30]:
mi
Out[30]:
b-adic set with b root of x^3 - x^2 - x - 1, and an automaton of 17 states and 2 letters
In [18]:
d = mi.substitution()
d
Out[18]:
{'a': ['c'],
 'b': ['b', 'a'],
 'c': ['d'],
 'd': ['h'],
 'e': ['g', 'i'],
 'f': ['j', 'm', 'a'],
 'g': ['f', 'm', 'a'],
 'h': ['b', 'e'],
 'i': ['l'],
 'j': ['b', 'm', 'a'],
 'k': ['g', 'a'],
 'l': ['f', 'e'],
 'm': ['g', 'k', 'a']}
In [19]:
s = WordMorphism(d)
s.rauzy_fractal_plot()
Out[19]:
In [ ]: