Python implementation of automata.
Project description
=========
Pythomata
=========
.. image:: https://img.shields.io/pypi/v/pythomata.svg
:target: https://pypi.python.org/pypi/pythomata
.. image:: https://img.shields.io/pypi/pyversions/pythomata.svg
:target: https://pypi.python.org/pypi/pythomata
.. image:: https://img.shields.io/badge/status-development-orange.svg
:target: https://img.shields.io/badge/status-development-orange.svg
.. image:: https://img.shields.io/travis/MarcoFavorito/pythomata.svg
:target: https://travis-ci.org/MarcoFavorito/pythomata
.. image:: https://readthedocs.org/projects/pythomata/badge/?version=latest
:target: https://pythomata.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://codecov.io/gh/MarcoFavorito/pythomata/branch/master/graph/badge.svg
:alt: Codecov coverage
:target: https://codecov.io/gh/MarcoFavorito/pythomata/branch/master/graph/badge.svg
Python implementation of automata.
* Free software: MIT license
* Documentation: https://pythomata.readthedocs.io.
Install
-------
.. code-block:: console
$ wget http://ftp.it.debian.org/debian/pool/main/g/graphviz/graphviz_2.38.0-17_amd64.deb
$ sudo dpkg -i graphviz_2.38.0-1~saucy_amd64.deb
$ sudo apt-get install -f
How to use
--------
* Define an automaton:
.. code-block:: python
a, b, c = Symbol("a"), Symbol("b"), Symbol("c")
alphabet = Alphabet({a, b, c})
states = frozenset({"s1", "s2", "s3"})
initial_state = "s1"
accepting_states = frozenset({"s3"})
transition_function = {
"s1": {
b : "s1",
a : "s2"
},
"s2": {
a : "s3",
b : "s1"
},
"s3":{
c : "s3"
}
}
dfa = DFA(alphabet, states, initial_state, accepting_states, transition_function)
* Test word acceptance:
.. code-block:: python
# a word is a list of symbols
word = [b, b, b, a, b, c]
dfa.word_acceptance(word) # True
# without the last symbol c, the final state is not reached
dfa.word_acceptance(word[:-1]) # False
* Operations such as minimization and trimming:
.. code-block:: python
dfa_minimized = dfa.minimize()
dfa_trimmed = dfa.trim()
* Print the automata:
.. code-block:: python
filepath = "./my_awesome_automaton"
dfa.minimize().trim().to_dot(filepath)
The output in .svg format is the following:
.. image:: https://github.com/MarcoFavorito/pythomata/tree/master/docs/my_awesome_automaton.svg
Features
--------
* Basic DFA and NFA support;
* Algorithms for DFA minimization and trimming;
* Algorithm for NFA determinization;
* Print automata in SVG format.
Credits
-------
This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
=======
History
=======
0.1.0 (2018-03-13)
------------------
* First release on PyPI.
0.1.1 (2018-03-15)
------------------
* Basic DFA and NFA support;
* Algorithms for DFA minimization and trimming;
* Algorithm for NFA determinization.
0.1.2 (2018-03-16)
------------------
* Minor bug fixes
0.1.3 (2018-03-16)
------------------
* Changes in word acceptance procedure for DFAs
Pythomata
=========
.. image:: https://img.shields.io/pypi/v/pythomata.svg
:target: https://pypi.python.org/pypi/pythomata
.. image:: https://img.shields.io/pypi/pyversions/pythomata.svg
:target: https://pypi.python.org/pypi/pythomata
.. image:: https://img.shields.io/badge/status-development-orange.svg
:target: https://img.shields.io/badge/status-development-orange.svg
.. image:: https://img.shields.io/travis/MarcoFavorito/pythomata.svg
:target: https://travis-ci.org/MarcoFavorito/pythomata
.. image:: https://readthedocs.org/projects/pythomata/badge/?version=latest
:target: https://pythomata.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://codecov.io/gh/MarcoFavorito/pythomata/branch/master/graph/badge.svg
:alt: Codecov coverage
:target: https://codecov.io/gh/MarcoFavorito/pythomata/branch/master/graph/badge.svg
Python implementation of automata.
* Free software: MIT license
* Documentation: https://pythomata.readthedocs.io.
Install
-------
.. code-block:: console
$ wget http://ftp.it.debian.org/debian/pool/main/g/graphviz/graphviz_2.38.0-17_amd64.deb
$ sudo dpkg -i graphviz_2.38.0-1~saucy_amd64.deb
$ sudo apt-get install -f
How to use
--------
* Define an automaton:
.. code-block:: python
a, b, c = Symbol("a"), Symbol("b"), Symbol("c")
alphabet = Alphabet({a, b, c})
states = frozenset({"s1", "s2", "s3"})
initial_state = "s1"
accepting_states = frozenset({"s3"})
transition_function = {
"s1": {
b : "s1",
a : "s2"
},
"s2": {
a : "s3",
b : "s1"
},
"s3":{
c : "s3"
}
}
dfa = DFA(alphabet, states, initial_state, accepting_states, transition_function)
* Test word acceptance:
.. code-block:: python
# a word is a list of symbols
word = [b, b, b, a, b, c]
dfa.word_acceptance(word) # True
# without the last symbol c, the final state is not reached
dfa.word_acceptance(word[:-1]) # False
* Operations such as minimization and trimming:
.. code-block:: python
dfa_minimized = dfa.minimize()
dfa_trimmed = dfa.trim()
* Print the automata:
.. code-block:: python
filepath = "./my_awesome_automaton"
dfa.minimize().trim().to_dot(filepath)
The output in .svg format is the following:
.. image:: https://github.com/MarcoFavorito/pythomata/tree/master/docs/my_awesome_automaton.svg
Features
--------
* Basic DFA and NFA support;
* Algorithms for DFA minimization and trimming;
* Algorithm for NFA determinization;
* Print automata in SVG format.
Credits
-------
This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
=======
History
=======
0.1.0 (2018-03-13)
------------------
* First release on PyPI.
0.1.1 (2018-03-15)
------------------
* Basic DFA and NFA support;
* Algorithms for DFA minimization and trimming;
* Algorithm for NFA determinization.
0.1.2 (2018-03-16)
------------------
* Minor bug fixes
0.1.3 (2018-03-16)
------------------
* Changes in word acceptance procedure for DFAs
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pythomata-0.1.4.post5.tar.gz
(53.1 kB
view details)
File details
Details for the file pythomata-0.1.4.post5.tar.gz
.
File metadata
- Download URL: pythomata-0.1.4.post5.tar.gz
- Upload date:
- Size: 53.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
965a2b002186e727b3dff0f8ce007ee08adc5050bad2cf8a425b331b1dcf8455
|
|
MD5 |
2a355eb4b3c22f425977487b2cc5ddef
|
|
BLAKE2b-256 |
93ebb163a4bb49f15423da029c266c6f36bac7b57fcbddd98ff73ba121465104
|