What would be the most complete finite automata library for Python, which is able to do the basic manipulations such as:
All the libraries that I'm finding are either incomplete or do not work plug-and-play-wise.
Automata is a Python 3 library which implements the structures and algorithms for finite automata, pushdown automata, and Turing machines. The library requires Python 3.7 or newer.
An nfa can be implemented by means of a recursive search from the start state for a path (directed by the symbols of the input string) to a final state. One problem with this implementation is that it could get into an infinite loop if there is a cycle of l transitions.
An example of a deterministic finite automaton that accepts only binary numbers that are multiples of 3. The state S0 is both the start state and an accept state. For example, the string "1001" leads to the state sequence S0, S1, S2, S1, S0, and is hence accepted.
python-automata
seems to be able to do all the things you're asking.
If you don't mind using a underlying C++ library you could try OpenFst with these Python bindings. PyFsa has the optimization algoritms you listed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With