# load the package badic (you can install it with "sage -pip install badic [--user]")
from badic import *
# 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
# 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
mud.plot()
# compute a substitution describing the set drawn by the user
d = mud.substitution()
d
# check that the Rauzy fractal of the substitution computed corresponds to what was expected
s = WordMorphism(d)
s.rauzy_fractal_plot()
# 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()
# automaton of this beta-adic set
mi.a.plot()
mi
d = mi.substitution()
d
s = WordMorphism(d)
s.rauzy_fractal_plot()