Skip to main content

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


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)

Uploaded Source

Built Distribution

automatata-0.0.1-py3-none-any.whl (3.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page