Simulates Automatons Acceptors DFA, NFA, PDA and Turing Machines
Reason this release was yanked:
The README has no the correct text of version
Project description
🤖 Pytomatas
📌 Version 1.1.1
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;
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
Built Distribution
Hashes for Pytomatas-1.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d307aaadc9bef79639584d08e3071feb3fb23966bd32a2d1ed85aeacdc73354 |
|
MD5 | 08da8514f10ba5dedfe43e0a41cd1b7c |
|
BLAKE2b-256 | 3f8a888da2f8763ea7ee6360db07c86ace4bcd7536bd6d66de393f71152cecb9 |