# 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.
[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 10 seconds.
Let us consider an arbitrary random.
(It is probable that
generate_DFA produces a strongly connected automaton, hence the sligthly convoluted code below. )
A = awalipy.generate_DFA(2,"ab") B = awalipy.generate_DFA(3,"ab") C = awalipy.generate_DFA(4,"ab") D = A.union(B).union(C) D.set_transition(0,2,"a") D.set_transition(5,2,"a") D.display()
sccs gives the list of the strongly connected components that is, a
[, , , , , , [8, 6, 5]]
scc_of(stt_id) gives the list of the states that may reach and may be reached from
E = D.copy() E.display()
for i in [5,6,7,8] : E.unset_initial(i) for i in [2,3,4] : E.unset_final(i) E.display()
[0, 1, 2, 3, 4]
accessible returns the restriction of tha tuatomaton to its accessible states (and
accessible_here does the same thing in place).
A state is
co-accessible if there is a path from it to a final state.
[0, 5, 6, 7, 8]
coaccessible returns the restriction of tha automaton to its co-accessible states (and
coaccessible_here does the same thing in place).
A state is useful if there it is both accessible and co-accessible.
trim returns the restriction of tha automaton to its co-accessible states (and
trim_here does the same thing in place).