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.1.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: bdd2dfa-0.1.0.tar.gz
  • Upload date:
  • Size: 3.6 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.1.0.tar.gz
Algorithm Hash digest
SHA256 17135244ba2ee22c7704adf10fad9d7b2085fc634c005261780ee152c21a44ac
MD5 0e236fbead951d92963e7561bfce2828
BLAKE2b-256 c61716b45e0b6961856b89df26fa9171fbfa06d76ecc0653eb5977d8fc78eb22

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bdd2dfa-0.1.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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d538311f65863b37fb8ef77bfdead63bdae55d11851add4852885f9800362d0e
MD5 66f76ac2cd015d31f3c342e93f0d3580
BLAKE2b-256 bab297ec47f276f79b1ce22146f50a4ea4853dc73bf924ded2e062f1be313a09

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