py-aiger-dfa


Namepy-aiger-dfa JSON
Version 0.4.4 PyPI version JSON
download
home_pagehttps://github.com/mvcisback/py-aiger-dfa
SummaryLibrary for moving between sequential circuits AIGs and DFAs.
upload_time2024-07-01 05:35:33
maintainerNone
docs_urlNone
authorMarcell Vazquez-Chanlatte
requires_python<4.0,>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # py-aiger-dfa
Python library for converting between AIG circuits and DFAs.

[![Build Status](https://cloud.drone.io/api/badges/mvcisback/py-aiger-dfa/status.svg)](https://cloud.drone.io/mvcisback/py-aiger-dfa)
[![Docs](https://img.shields.io/badge/API-link-color)](https://mvcisback.github.io/py-aiger-dfa)
[![codecov](https://codecov.io/gh/mvcisback/py-aiger-dfa/branch/master/graph/badge.svg)](https://codecov.io/gh/mvcisback/py-aiger-dfa)
[![PyPI version](https://badge.fury.io/py/py-aiger-dfa.svg)](https://badge.fury.io/py/py-aiger-dfa)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-generate-toc again -->
**Table of Contents**

- [Installation](#installation)
- [Usage](#usage)
    - [DFA to AIG](#dfa-to-aig)
    - [AIG to DFA](#aig-to-dfa)

<!-- markdown-toc end -->


# Installation

If you just need to use `aiger_dfa`, you can just run:

`$ pip install py-aiger-dfa`

For developers, note that this project uses the
[poetry](https://poetry.eustace.io/) python package/dependency
management tool. Please familarize yourself with it and then
run:

`$ poetry install`

# Usage

The main entry points for using this library are the `dfa2aig` and
`aig2dfa` functions. DFAs are represented using the
[dfa](https://github.com/mvcisback/dfa) package. Familiarity with the
`dfa`, `py-aiger`, and `py-aiger-bv` packages is assumed.


## DFA to AIG

An example of going from a `DFA` to an `AIG` object
is shown below.

```python
from dfa import DFA
from aiger_dfa import dfa2aig

my_dfa = DFA(
    start=0,
    inputs={0, 1},
    label=lambda s: (s % 4) == 3,
    transition=lambda s, c: (s + c) % 4,
)
my_aig, relabels, valid = dfa2aig(my_dfa)
```

Now `circ` is an `AIG` and `relabels` is a mapping from the inputs,
states, and outputs of `my_dfa` to their **1-hot** encoded
counterparts in `my_aig`.

`relabels` has the following schema:

```python
relabels = {
    'inputs': .. , #  Mapping from input alphabet -> py-aiger input.
    'outputs': .. , # Mapping from py-aiger output -> output alphabet.
    'states': .. , # Mapping from state space -> py-aiger latches.
}
```

Finally, `valid` is another aiger circuit which tests if all inputs
are 1-hot encoded.

## AIG to DFA

We also support converting a sequential circuit (AIG) to a [Moore
Machine](https://en.wikipedia.org/wiki/Moore_machine) (DFA) using
`aig2dfa`. Using the same example:

```python
from aiger_dfa import aig2dfa

my_dfa2 = aig2dfa(my_aig, relabels=relabels)
```

Note that the output of a sequential circuit (AIG) is dependent on the
state **AND** the action (a [Mealy
Machine](https://en.wikipedia.org/wiki/Mealy_machine)). 

We use the standard Mealy ↦ Moore reduction where one introduces a
1-step delay on the output. The default initial output is `None`, but
can be set using the `initial_label` argument.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mvcisback/py-aiger-dfa",
    "name": "py-aiger-dfa",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Marcell Vazquez-Chanlatte",
    "author_email": "mvc@linux.com",
    "download_url": "https://files.pythonhosted.org/packages/29/8d/8aea163ac11cd2961938392cd37135a9dc1a9a89b5e17adaa4618545743e/py_aiger_dfa-0.4.4.tar.gz",
    "platform": null,
    "description": "# py-aiger-dfa\nPython library for converting between AIG circuits and DFAs.\n\n[![Build Status](https://cloud.drone.io/api/badges/mvcisback/py-aiger-dfa/status.svg)](https://cloud.drone.io/mvcisback/py-aiger-dfa)\n[![Docs](https://img.shields.io/badge/API-link-color)](https://mvcisback.github.io/py-aiger-dfa)\n[![codecov](https://codecov.io/gh/mvcisback/py-aiger-dfa/branch/master/graph/badge.svg)](https://codecov.io/gh/mvcisback/py-aiger-dfa)\n[![PyPI version](https://badge.fury.io/py/py-aiger-dfa.svg)](https://badge.fury.io/py/py-aiger-dfa)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-generate-toc again -->\n**Table of Contents**\n\n- [Installation](#installation)\n- [Usage](#usage)\n    - [DFA to AIG](#dfa-to-aig)\n    - [AIG to DFA](#aig-to-dfa)\n\n<!-- markdown-toc end -->\n\n\n# Installation\n\nIf you just need to use `aiger_dfa`, you can just run:\n\n`$ pip install py-aiger-dfa`\n\nFor developers, note that this project uses the\n[poetry](https://poetry.eustace.io/) python package/dependency\nmanagement tool. Please familarize yourself with it and then\nrun:\n\n`$ poetry install`\n\n# Usage\n\nThe main entry points for using this library are the `dfa2aig` and\n`aig2dfa` functions. DFAs are represented using the\n[dfa](https://github.com/mvcisback/dfa) package. Familiarity with the\n`dfa`, `py-aiger`, and `py-aiger-bv` packages is assumed.\n\n\n## DFA to AIG\n\nAn example of going from a `DFA` to an `AIG` object\nis shown below.\n\n```python\nfrom dfa import DFA\nfrom aiger_dfa import dfa2aig\n\nmy_dfa = DFA(\n    start=0,\n    inputs={0, 1},\n    label=lambda s: (s % 4) == 3,\n    transition=lambda s, c: (s + c) % 4,\n)\nmy_aig, relabels, valid = dfa2aig(my_dfa)\n```\n\nNow `circ` is an `AIG` and `relabels` is a mapping from the inputs,\nstates, and outputs of `my_dfa` to their **1-hot** encoded\ncounterparts in `my_aig`.\n\n`relabels` has the following schema:\n\n```python\nrelabels = {\n    'inputs': .. , #  Mapping from input alphabet -> py-aiger input.\n    'outputs': .. , # Mapping from py-aiger output -> output alphabet.\n    'states': .. , # Mapping from state space -> py-aiger latches.\n}\n```\n\nFinally, `valid` is another aiger circuit which tests if all inputs\nare 1-hot encoded.\n\n## AIG to DFA\n\nWe also support converting a sequential circuit (AIG) to a [Moore\nMachine](https://en.wikipedia.org/wiki/Moore_machine) (DFA) using\n`aig2dfa`. Using the same example:\n\n```python\nfrom aiger_dfa import aig2dfa\n\nmy_dfa2 = aig2dfa(my_aig, relabels=relabels)\n```\n\nNote that the output of a sequential circuit (AIG) is dependent on the\nstate **AND** the action (a [Mealy\nMachine](https://en.wikipedia.org/wiki/Mealy_machine)). \n\nWe use the standard Mealy \u21a6 Moore reduction where one introduces a\n1-step delay on the output. The default initial output is `None`, but\ncan be set using the `initial_label` argument.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Library for moving between sequential circuits AIGs and DFAs.",
    "version": "0.4.4",
    "project_urls": {
        "Homepage": "https://github.com/mvcisback/py-aiger-dfa",
        "Repository": "https://github.com/mvcisback/py-aiger-dfa"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0b92b16e854fdfee173477d55ad350343a4c86bd1ac3fd9717097e6fe80cfdb5",
                "md5": "389e8821641e01617438cafad862170b",
                "sha256": "0020ef5562592337ef8ab5a6070b5ef66b63391fdac812c49c20f90014578264"
            },
            "downloads": -1,
            "filename": "py_aiger_dfa-0.4.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "389e8821641e01617438cafad862170b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 7993,
            "upload_time": "2024-07-01T05:35:31",
            "upload_time_iso_8601": "2024-07-01T05:35:31.923642Z",
            "url": "https://files.pythonhosted.org/packages/0b/92/b16e854fdfee173477d55ad350343a4c86bd1ac3fd9717097e6fe80cfdb5/py_aiger_dfa-0.4.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "298d8aea163ac11cd2961938392cd37135a9dc1a9a89b5e17adaa4618545743e",
                "md5": "e902a5eca6c132a3694a28d9a0add53b",
                "sha256": "b83f42ccad739c75129b34951f3031de681a3e224291566af06c16c92ee378ca"
            },
            "downloads": -1,
            "filename": "py_aiger_dfa-0.4.4.tar.gz",
            "has_sig": false,
            "md5_digest": "e902a5eca6c132a3694a28d9a0add53b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 6483,
            "upload_time": "2024-07-01T05:35:33",
            "upload_time_iso_8601": "2024-07-01T05:35:33.608909Z",
            "url": "https://files.pythonhosted.org/packages/29/8d/8aea163ac11cd2961938392cd37135a9dc1a9a89b5e17adaa4618545743e/py_aiger_dfa-0.4.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-01 05:35:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mvcisback",
    "github_project": "py-aiger-dfa",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "py-aiger-dfa"
}
        
Elapsed time: 0.31156s