# Pythomata
[![](https://img.shields.io/pypi/v/pythomata.svg)](https://pypi.python.org/pypi/pythomata)
[![](https://img.shields.io/travis/whitemech/pythomata.svg)](https://travis-ci.org/whitemech/pythomata)
[![](https://img.shields.io/pypi/pyversions/pythomata.svg)](https://pypi.python.org/pypi/pythomata)
[![](https://img.shields.io/badge/docs-mkdocs-9cf)](https://www.mkdocs.org/)
[![](https://img.shields.io/badge/status-development-orange.svg)](https://img.shields.io/badge/status-development-orange.svg)
[![codecov](https://codecov.io/gh/whitemech/pythomata/branch/master/graph/badge.svg)](https://codecov.io/gh/whitemech/pythomata)
[![](https://img.shields.io/badge/flake8-checked-blueviolet)](https://img.shields.io/badge/flake8-checked-blueviolet)
[![](https://img.shields.io/badge/mypy-checked-blue)](https://img.shields.io/badge/mypy-checked-blue)
[![](https://img.shields.io/badge/license-LGPLv3%2B-blue)](./LICENSE)
Python implementation of automata theory.
## Links
- GitHub: [https://github.com/whitemech/pythomata](https://github.com/whitemech/pythomata)
- PyPI: [https://pypi.org/project/pythomata/](https://pypi.org/project/pythomata/)
- Documentation: [https://whitemech.github.io/pythomata](https://whitemech.github.io/pythomata)
- Changelog: [https://whitemech.github.io/pythomata/release-history/](https://whitemech.github.io/pythomata/release-history/)
- Issue Tracker:[https://github.com/whitemech/pythomata/issues](https://github.com/whitemech/pythomata/issues)
- Download: [https://pypi.org/project/pythomata/#files](https://pypi.org/project/pythomata/#files)
## Install
- from [PyPI](https://pypi.org/project/pythomata/):
```
pip install pythomata
```
- or, from source (e.g. `develop` branch):
```
pip install git+https://github.com/whitemech/pythomata.git@develop
```
- or, clone the repository and install:
```
git clone htts://github.com/whitemech/pythomata.git
cd pythomata
pip install .
```
## How to use
* Define an automaton:
```python
from pythomata import SimpleDFA
alphabet = {"a", "b", "c"}
states = {"s1", "s2", "s3"}
initial_state = "s1"
accepting_states = {"s3"}
transition_function = {
"s1": {
"b" : "s1",
"a" : "s2"
},
"s2": {
"a" : "s3",
"b" : "s1"
},
"s3":{
"c" : "s3"
}
}
dfa = SimpleDFA(states, alphabet, initial_state, accepting_states, transition_function)
```
* Test word acceptance:
```python
# a word is a list of symbols
word = "bbbac"
dfa.accepts(word) # True
# without the last symbol c, the final state is not reached
dfa.accepts(word[:-1]) # False
```
* Operations such as minimization and trimming:
```python
dfa_minimized = dfa.minimize()
dfa_trimmed = dfa.trim()
```
* Translate into a [`graphviz.Digraph`](https://graphviz.readthedocs.io/en/stable/api.html#graphviz.Digraph)
instance:
```python
graph = dfa.minimize().trim().to_graphviz()
```
To print the automaton:
```
graph.render("path_to_file")
```
For that you will need to install Graphviz.
Please look at their [download page](https://graphviz.gitlab.io/download/)
for detailed instructions depending on your system.
The output looks like the following:
<p align="center">
<img width="150" height="300" src="./images/my_awesome_automaton.svg" />
</p>
## Features
* Basic DFA and NFA support;
* Algorithms for DFA minimization and trimming;
* Algorithm for NFA determinization;
* Translate automata into Graphviz objects.
* Support for Symbolic Automata.
## Tests
To run the tests:
```
tox
```
To run only the code style checks:
```
tox -e flake8 -e mypy
```
## Docs
To build the docs:
```
mkdocs build
```
To view documentation in a browser
```
mkdocs serve
```
and then go to [http://localhost:8000](http://localhost:8000)
## License
Pythomata is released under the GNU Lesser General Public License v3.0 or later (LGPLv3+).
Copyright 2018-2020 [WhiteMech](https://whitemech.github.io)
# Release History
## 0.3.2 (2020-03-22)
* Bug fixing and minor improvements.
## 0.3.1 (2020-02-28)
* Improved CI: using GitHub actions instead of Travis.
* Included many other checks: `safety`, `black`, `liccheck`.
* Improved documentation.
## 0.3.0 (2020-02-09)
* Main refactoring of the APIs.
* Introduce interfaces for better abstractions: `Alphabet`, `FiniteAutomaton` etc.
* `DFA` and `NFA` renamed `SimpleDFA` and `SimpleNFA`, respectively.
* Introduced `SymbolicAutomaton` and `SymbolicDFA`, where the guards
on transitions are propositoinal formulas.
## 0.2.0 (2019-09-30)
* Refactoring of the repository
## 0.1.0 (2019-04-13)
* Basic support for DFAs and NFAs.
* Algorithms for DFA minimization and trimming.
* Algorithm for NFA determinization.
Raw data
{
"_id": null,
"home_page": "https://github.com/whitemech/pythomata.git",
"name": "pythomata",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "pythomata",
"author": "Marco Favorito, Francesco Fuggitti",
"author_email": "marco.favorito@gmail.com, francesco.fuggitti@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/93/6f/8498fbc63ee7d77454f255077ee65aaa58429037c5f3f4e985f596ee2ef9/pythomata-0.3.2.tar.gz",
"platform": "",
"description": "# Pythomata\n\n\n[![](https://img.shields.io/pypi/v/pythomata.svg)](https://pypi.python.org/pypi/pythomata)\n[![](https://img.shields.io/travis/whitemech/pythomata.svg)](https://travis-ci.org/whitemech/pythomata)\n[![](https://img.shields.io/pypi/pyversions/pythomata.svg)](https://pypi.python.org/pypi/pythomata)\n[![](https://img.shields.io/badge/docs-mkdocs-9cf)](https://www.mkdocs.org/)\n[![](https://img.shields.io/badge/status-development-orange.svg)](https://img.shields.io/badge/status-development-orange.svg)\n[![codecov](https://codecov.io/gh/whitemech/pythomata/branch/master/graph/badge.svg)](https://codecov.io/gh/whitemech/pythomata)\n[![](https://img.shields.io/badge/flake8-checked-blueviolet)](https://img.shields.io/badge/flake8-checked-blueviolet)\n[![](https://img.shields.io/badge/mypy-checked-blue)](https://img.shields.io/badge/mypy-checked-blue)\n[![](https://img.shields.io/badge/license-LGPLv3%2B-blue)](./LICENSE)\n\nPython implementation of automata theory.\n\n## Links\n\n- GitHub: [https://github.com/whitemech/pythomata](https://github.com/whitemech/pythomata)\n- PyPI: [https://pypi.org/project/pythomata/](https://pypi.org/project/pythomata/)\n- Documentation: [https://whitemech.github.io/pythomata](https://whitemech.github.io/pythomata)\n- Changelog: [https://whitemech.github.io/pythomata/release-history/](https://whitemech.github.io/pythomata/release-history/)\n- Issue Tracker:[https://github.com/whitemech/pythomata/issues](https://github.com/whitemech/pythomata/issues)\n- Download: [https://pypi.org/project/pythomata/#files](https://pypi.org/project/pythomata/#files)\n\n\n## Install\n\n- from [PyPI](https://pypi.org/project/pythomata/):\n```\npip install pythomata\n```\n- or, from source (e.g. `develop` branch):\n```\npip install git+https://github.com/whitemech/pythomata.git@develop\n```\n\n- or, clone the repository and install:\n```\ngit clone htts://github.com/whitemech/pythomata.git\ncd pythomata\npip install .\n```\n\n## How to use\n\n* Define an automaton:\n\n```python\nfrom pythomata import SimpleDFA\nalphabet = {\"a\", \"b\", \"c\"}\nstates = {\"s1\", \"s2\", \"s3\"}\ninitial_state = \"s1\"\naccepting_states = {\"s3\"}\ntransition_function = {\n \"s1\": {\n \"b\" : \"s1\",\n \"a\" : \"s2\"\n },\n \"s2\": {\n \"a\" : \"s3\",\n \"b\" : \"s1\"\n },\n \"s3\":{\n \"c\" : \"s3\"\n }\n}\ndfa = SimpleDFA(states, alphabet, initial_state, accepting_states, transition_function)\n```\n\n* Test word acceptance:\n\n```python\n# a word is a list of symbols\nword = \"bbbac\"\ndfa.accepts(word) # True\n\n# without the last symbol c, the final state is not reached\ndfa.accepts(word[:-1]) # False\n```\n\n* Operations such as minimization and trimming:\n\n```python\ndfa_minimized = dfa.minimize()\ndfa_trimmed = dfa.trim()\n```\n\n* Translate into a [`graphviz.Digraph`](https://graphviz.readthedocs.io/en/stable/api.html#graphviz.Digraph)\n instance:\n\n```python\ngraph = dfa.minimize().trim().to_graphviz()\n```\n\nTo print the automaton:\n```\ngraph.render(\"path_to_file\")\n```\n\nFor that you will need to install Graphviz.\nPlease look at their [download page](https://graphviz.gitlab.io/download/)\nfor detailed instructions depending on your system.\n\nThe output looks like the following:\n\n<p align=\"center\">\n <img width=\"150\" height=\"300\" src=\"./images/my_awesome_automaton.svg\" />\n</p>\n\n\n## Features\n\n\n* Basic DFA and NFA support;\n* Algorithms for DFA minimization and trimming;\n* Algorithm for NFA determinization;\n* Translate automata into Graphviz objects.\n* Support for Symbolic Automata.\n\n\n## Tests\n\nTo run the tests:\n```\ntox\n```\nTo run only the code style checks:\n```\ntox -e flake8 -e mypy\n```\n## Docs\n\nTo build the docs:\n\n```\nmkdocs build\n```\n\nTo view documentation in a browser\n\n```\nmkdocs serve\n```\n\nand then go to [http://localhost:8000](http://localhost:8000)\n\n\n## License\n\nPythomata is released under the GNU Lesser General Public License v3.0 or later (LGPLv3+).\n\nCopyright 2018-2020 [WhiteMech](https://whitemech.github.io)\n\n\n\n# Release History\n\n## 0.3.2 (2020-03-22)\n\n* Bug fixing and minor improvements.\n\n## 0.3.1 (2020-02-28)\n\n* Improved CI: using GitHub actions instead of Travis.\n* Included many other checks: `safety`, `black`, `liccheck`.\n* Improved documentation.\n\n## 0.3.0 (2020-02-09)\n\n* Main refactoring of the APIs.\n* Introduce interfaces for better abstractions: `Alphabet`, `FiniteAutomaton` etc.\n* `DFA` and `NFA` renamed `SimpleDFA` and `SimpleNFA`, respectively.\n* Introduced `SymbolicAutomaton` and `SymbolicDFA`, where the guards\n on transitions are propositoinal formulas.\n\n## 0.2.0 (2019-09-30)\n\n* Refactoring of the repository\n\n## 0.1.0 (2019-04-13)\n\n* Basic support for DFAs and NFAs.\n* Algorithms for DFA minimization and trimming.\n* Algorithm for NFA determinization.\n\n\n",
"bugtrack_url": null,
"license": "LGPL-3.0-or-later",
"summary": "A Python package for automata theory.",
"version": "0.3.2",
"project_urls": {
"Homepage": "https://github.com/whitemech/pythomata.git"
},
"split_keywords": [
"pythomata"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "02077db8eec01fff0519b2ed05515f21ee7bd93af5e93e21b5da24eeaba62f22",
"md5": "d71b1a2bcb29fa03524bfa139aa11923",
"sha256": "b6e1a4bb2ba9bff2f7f0e9b3f357d512b4a633bfd9ba8f63a59d89556396f784"
},
"downloads": -1,
"filename": "pythomata-0.3.2-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "d71b1a2bcb29fa03524bfa139aa11923",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 23580,
"upload_time": "2020-03-22T00:08:42",
"upload_time_iso_8601": "2020-03-22T00:08:42.820889Z",
"url": "https://files.pythonhosted.org/packages/02/07/7db8eec01fff0519b2ed05515f21ee7bd93af5e93e21b5da24eeaba62f22/pythomata-0.3.2-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "936f8498fbc63ee7d77454f255077ee65aaa58429037c5f3f4e985f596ee2ef9",
"md5": "8ca412fb3626a546e0cbc031f9013cc9",
"sha256": "10a31e6fffed84f1eacdf8820b9f3af5a7dbaf329d936bf7c4618f464b22fed5"
},
"downloads": -1,
"filename": "pythomata-0.3.2.tar.gz",
"has_sig": false,
"md5_digest": "8ca412fb3626a546e0cbc031f9013cc9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 55459,
"upload_time": "2020-03-22T00:08:44",
"upload_time_iso_8601": "2020-03-22T00:08:44.762081Z",
"url": "https://files.pythonhosted.org/packages/93/6f/8498fbc63ee7d77454f255077ee65aaa58429037c5f3f4e985f596ee2ef9/pythomata-0.3.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2020-03-22 00:08:44",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "whitemech",
"github_project": "pythomata",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "pythomata"
}