Pythomata
Python implementation of automata theory.
Links
- GitHub: https://github.com/whitemech/pythomata
- PyPI: https://pypi.org/project/pythomata/
- Documentation: https://whitemech.github.io/pythomata
- Changelog: https://whitemech.github.io/pythomata/release-history/
- Issue Tracker:https://github.com/whitemech/pythomata/issues
- Download: https://pypi.org/project/pythomata/#files
Install
- from PyPI:
pip install pythomata
- or, from source (e.g.
developbranch):
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:
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:
# 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:
dfa_minimized = dfa.minimize()
dfa_trimmed = dfa.trim()
- Translate into a
graphviz.Digraphinstance:
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 for detailed instructions depending on your system.
The output looks like the following:
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
License
Pythomata is released under the GNU Lesser General Public License v3.0 or later (LGPLv3+).
Copyright 2018-2020 WhiteMech
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,FiniteAutomatonetc. DFAandNFArenamedSimpleDFAandSimpleNFA, respectively.- Introduced
SymbolicAutomatonandSymbolicDFA, 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.
Release files for pythomata 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pythomata-0.3.2.tar.gz | 55.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pythomata-0.3.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 79.0 kB
Release files / pythomata-0.3.2.tar.gz
| Download URL | pythomata-0.3.2.tar.gz |
|---|---|
| Size | 55.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
10a31e6fffed84f1eacdf8820b9f3af5a7dbaf329d936bf7c4618f464b22fed5
|
|
BLAKE2b-256 checksum How to use checksums |
936f8498fbc63ee7d77454f255077ee65aaa58429037c5f3f4e985f596ee2ef9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5
|
Release files / pythomata-0.3.2-py2.py3-none-any.whl
| Download URL | pythomata-0.3.2-py2.py3-none-any.whl |
|---|---|
| Size | 23.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
b6e1a4bb2ba9bff2f7f0e9b3f357d512b4a633bfd9ba8f63a59d89556396f784
|
|
BLAKE2b-256 checksum How to use checksums |
02077db8eec01fff0519b2ed05515f21ee7bd93af5e93e21b5da24eeaba62f22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5
|