Skip to main content

Python library for converting binary decision diagrams to automata.

Project description

bdd2dfa

Build Status codecov PyPI version License: MIT

A simple python wrapper around Binary Decision Diagrams (BDDs) to interpret them as Deterministic Finite Automata (DFAs).

The package takes as input a BDD from the dd package and returns a DFA from the dfa package.

Formally, the resulting DFA objects are quasi-reduced BDDs (QDDs) where the label of non-leaf states in the original BDD is None and all leaves self loop.

Table of Contents

Installation

If you just need to use bdd2dfa, you can just run:

$ pip install bdd2dfa

For developers, note that this project uses the poetry python package/dependency management tool. Please familarize yourself with it and then run:

$ poetry install

Usage

# Create BDD

from dd import BDD

manager.declare('x', 'y', 'z')
x, y, z = map(manager.var, 'xyz')
bexpr = x & y & z


# Convert to DFA

from bdd2dfa import to_dfa

dfa = to_dfa(bexpr)

assert len(dfa.states()) == 7

assert dfa.label([1, 1, 1, 1])      # BDD rejects.
assert not dfa.label([0, 1, 1, 1])  # BDD accepts.
assert dfa.label([1, 1]) is None    # Non-leaf node.

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

bdd2dfa-0.2.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

bdd2dfa-0.2.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file bdd2dfa-0.2.0.tar.gz.

File metadata

  • Download URL: bdd2dfa-0.2.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.3 CPython/3.8.1 Linux/5.5.0-1-MANJARO

File hashes

Hashes for bdd2dfa-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0fbe92a3d24ea3296e7defb716fb16bdbe7ab1b8fd3c5e4e04d80b28eb3fbb0f
MD5 8160d7ec68edd00e227e194646784a63
BLAKE2b-256 740e5003f2ce7f97453eb1e627bb82ff0c244b910471264b11e41506773beab0

See more details on using hashes here.

File details

Details for the file bdd2dfa-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: bdd2dfa-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.3 CPython/3.8.1 Linux/5.5.0-1-MANJARO

File hashes

Hashes for bdd2dfa-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1aafccce6e0388689d13241f6ba5dfd77c73fef260730da2fcd7ab25055f3fea
MD5 6506ccd8c3efa99f1438930467f618cb
BLAKE2b-256 3941415cc0c9d22278916b387241931b1203a3d6ed9b9ce07ca1e93e8ea18879

See more details on using hashes here.

Supported by

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