🤖 Pytomatas
📌 Version 1.1.4
Pytomatas allows to simulate Acceptor Automata in the console with Python, implementing its characteristics using different definitions (mathematics included), with the following types:
- DFA (Deterministic Finite Automaton);
- NFA (Non-deterministic Finite Automaton);
- PDA (Push-Down Automaton);
- TM (Turing Machine);
What can do?
- Create and manage various types of automaton: DFA, NFA, PDA, TM.
- Visualize automata information in console.
- Simulate automata acceptors based on strings.
- Observe the processes of steps and transitions when introducing a string to the automaton.
📍 Index
- 🛠 Installation;
- 💻 Usage;
- 📓 Documentation;
- 📚 Examples;
- 📁 Repository;
- ✍ Contributing;
- 📜 License;
🛠 Installation
You can install Pytomatas using pip:
pip install Pytomatas
💻 Usage
There are two ways in which automata can be implemented:
- Creating the empty automaton and then adding the properties.
- Creating the automaton by passing its characteristics as in the mathematical definition.
Example of a DFA implementation...
🧿 First implementation
1. Creating empty automata and then give the data:
from Pytomatas.dfa import DFA
# Creates a DFA called "my_dfa":
my_dfa = DFA()
# Define to "my_dfa" a set of states names:
my_dfa.setStates( {"q0", "q1", "qfinal"} )
# Define to "my_dfa" a set of states characters of the alphabet:
my_dfa.setAlphabet( {"a", "b"} )
# Set the "Initial state" name of "my_dfa":
my_dfa.setInitial( "q0" )
# Define to "my_dfa" the set of "Final states" names:
my_dfa.setFinals( {"qfinal", "qf2"} )
# Add transitions to the DFA:
my_dfa.addTransition( ("q0", "a", "q1") )
my_dfa.addTransition( ("q0", "b", "qfinal") )
my_dfa.addTransition( ("q1", "a", "q1") )
my_dfa.addTransition( ("q1", "b", "q1") )
my_dfa.addTransition( ("qfinal", "a", "qfinal") )
my_dfa.addTransition( ("qfinal", "b", "qfinal") )
# Add more data to the existing one already in the automata:
my_dfa.addSymbol("c")
my_dfa.addState("qx")
my_dfa.addState("finalState2")
my_dfa.addFinal("finalState2")
# Prints the DFA information:
my_dfa.show()
# Check if a string is accepted on the defined automata "my_dfa":
# It returns True or False if the string is accepted or not:
word = "aaabb"
my_dfa.accepts(word)
# Checks if the string is accepted, but prints all the process and steps on transitions;
# Shows the flow of states while reading the string;
my_dfa.accepts(word, stepByStep=True)
🧿 Second implementation
2. Creating the automata passing the data:
from Pytomatas.dfa import DFA
# Declare the States:
Q = {"q0", "qa", "q1", "qb", "q2", "qf", "qx"}
# Declare the Alphabet:
A = {"a", "b"}
# Declare the Initial (start) state:
S = "q0"
# Declare the Finals states:
F = {"q2", "q3"}
# Declare the Transitions:
T = [
("q0", "a", "qa"),
("q0", "b", "q1"),
("qa", "a", "qa"),
("qa", "b", "qb"),
("qf", "b", "qf"),
("qx", "a", "qx"),
("qx", "b", "qx")
]
# Declare the Automata:
my_dfa = DFA(Q, A, T, S, F)
# Show the automata information:
my_dfa.show()
# Check if a string is accepted on the defined automata "my_dfa":
# It returns True or False if the string is accepted or not:
word = "aaabb"
my_dfa.accepts(word)
# Checks if the string is accepted, but prints all the process and steps on transitions;
# Shows the flow of states while reading the string;
# It returns True or False if the string is accepted or not:
my_dfa.accepts(word, stepByStep=True)
🛑 NOTE: These are only implementation examples, not actual implementations, so they are not complete real automata definitions 👆
-
For more detailed information about the attributes and methods of the class, refer to Documentation.
-
For more detailed usage instructions and examples, please refer to Examples.
📓 Documentation
Go to THIS LINK to see the documentation on all the features of the different types of automata, the functions they have, and examples of their implementation.
📚 Examples
📁 Repository
Go to THIS LINK to check out the source code.
✍ Contributing
Contributions are welcome! If you encounter any issues, have suggestions, or would like to contribute to the project, please feel free to open an issue or submit a pull request on this repository.
📜 License
This project is licensed under the MIT License - see the LICENSE file for details.
Made with 💜 by @arhcoder;
Metadata
Release files for Pytomatas 1.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Pytomatas-1.1.4.tar.gz | 10.9 kB | Without provenance | Details for Pytomatas-1.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| Pytomatas-1.1.4-py3-none-any.whl | Python 3 | none | any | Details for Pytomatas-1.1.4-py3-none-any.whl |
Total release size: 25.3 kB
Release files / Pytomatas-1.1.4.tar.gz
| Download URL | Pytomatas-1.1.4.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a63a8b5c2631934cabe54694f20706df7fd65cb9d9e23b313fc25afb7a8c169
|
|
BLAKE2b-256 checksum How to use checksums |
44dd9e6ec13991e106ab75fc1ede95cc31df5a5467fe31efcf84ca8b72080832
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / Pytomatas-1.1.4-py3-none-any.whl
| Download URL | Pytomatas-1.1.4-py3-none-any.whl |
|---|---|
| Size | 14.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e3437047c1668e3cd00540b33b9a23d7435cd141913a9ce3444f3fa3fcb780f5
|
|
BLAKE2b-256 checksum How to use checksums |
087e6005ff2607a823b5efdae72971af79abbd338c7e0684cdb066a6f0a7ef41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Security for Pytomatas 1.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.