# We disable autosave for technical reasons.
# Replace 0 by 120 in next line to restore default.
%autosave 0
import awalipy # If import fails, check that
# Python version used as Jupyter
# kernel matches the one
# Awalipy was compiled with.
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)
B.set_initial(0)
B.add_transition(0,1,'a')
B.add_transition(1,0,'a')
B.add_transition(0,0,'b')
B.add_transition(1,1,'b')
B.add_transition(2,3,'a')
B.add_transition(3,4,'a')
B.add_transition(4,2,'a')
B.add_transition(2,4,'b')
B.add_transition(4,3,'b')
B.add_transition(3,2,'b')
B.add_transition(0,2,"\\e")
B.add_transition(2,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 = awalipy.union(C1,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 = awalipy.concatenate(C1,C2)
E.display()
F = E.minimal_automaton()
F.display()
G = F.complement()
G.display()