Automata in Python.
Project description
automatata
Automata in Python!
Usage
Here's a Discrete Finite Automaton that accepts words that contain an even number of "a"s and "b"s.
from automatata.models.dfa import DFA
evens = DFA(
language={"a", "b"},
edges={
0: {
"a": 1,
"b": 1,
},
1: {
"a": 0,
"b": 0,
},
},
start=0,
goal={0},
)
assert evens.valid("")
assert not evens.valid("a")
assert evens.valid("ab")
assert evens.valid("ba")
assert not evens.valid("aba")
assert not evens.valid("aab")
assert not evens.valid("abb")
for i in range(10):
for p in permutations("a"*i + "b"+i):
assert evens.valid(p)
assert evens.valid("aaaabb")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
automatata-0.0.1.tar.gz
(2.9 kB
view hashes)
Built Distribution
Close
Hashes for automatata-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bdb4a78b03b123c29694582ebaf51771627b274d8c4ecbaf801564a53800ffb |
|
MD5 | 2ed72bae48b1ef5e2359f8a7627ef392 |
|
BLAKE2b-256 | addfab91d205ee6e8ecf1f6f76453c05407ca4b0885c86b53b162fc3f0127015 |