# We disable autosave for technical reasons.
# Replace 0 by 120 in next line to restore default.
%autosave 0
Autosave disabled
import awalipy # If import fails, check that 
               # Python version used as Jupyter
               # kernel matches the one
               # Awalipy was compiled with.
[Warning] The python module awalipy relies on compilation executed "on-the-fly" depending on the context (type of weights, of labels, etc.). As a result, the very first call to a given function in a given context may take up to one minute.
(a1 is one of the example automaton in the library.)
A1 = awalipy.load("a1")
A1.display()
A2 = A1.determinize()
A2.display()
The minization process is called with the method min_quotient.
A3 = A2.min_quotient()
A3.display()
The epsilon-removal process is called with the method proper().
B = awalipy.Automaton("ab",size=5,allow_eps=True)
s = B.states()
B.set_initial(0)
B.add_transition(s[0],s[1],'a')
B.add_transition(s[1],s[0],'a')
B.add_transition(s[0],s[0],'b')
B.add_transition(s[1],s[1],'b')
B.add_transition(s[2],s[3],'a')
B.add_transition(s[3],s[4],'a')
B.add_transition(s[4],s[2],'a')
B.add_transition(s[2],s[4],'b')
B.add_transition(s[4],s[3],'b')
B.add_transition(s[3],s[2],'b')
B.add_transition(s[0],s[2],"\\e")
B.add_transition(s[2],s[0],"\\e")
B.set_final(2)
B.display()
B2 = B.proper()
B2.display()
The method minimal_automaton() gives the minimal DFA equivalent to its arguments. Determinizing and removing epsilon transition if necessary.
Let us take back the automaton B.
B.display()
...and call the method minimal_automaton().
B.minimal_automaton().display()
C1 = awalipy.load("evena")
C2 = awalipy.load("oddb")
C1.display()
C2.display()
C is the (intersection) product of C1 with C2.
C = awalipy.product(C1,C2)
C.display()
When standard operation is used, the "history" of each state is stored and may be displayed.
C.display(history=True)
Recalling the operands C1 and C2
C1.display()
C2.display()
The function union() simply puts the two automata side by side.
D = C1.sum(C2)
D.display()
Determinizing and minimizing D
D.minimal_automaton().display(history=True)
Recalling the operands C1 and C2
C1.display()
C2.display()
Concatenating by C1 and C2. Result may be non-deterministic.
E = C1.concatenate(C2)
E.display()
F = E.minimal_automaton()
F.display()
G = F.complement()
G.display()