Pytomatas


NamePytomatas JSON
Version 1.1.4 PyPI version JSON
download
home_pagehttps://github.com/arhcoder/Pytomatas
SummarySimulates Automatons Acceptors DFA, NFA, PDA and Turing Machines
upload_time2023-06-05 02:39:04
maintainer
docs_urlNone
authorarhcoder
requires_python>=3.6
licenseMIT License
keywords automata automaton turing machine simulation dfa nfa pda tm python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 🤖 Pytomatas

**📌 Version 1.1.4**

<hr>

Pytomatas allows to simulate Acceptor Automata in the console with Python, implementing its characteristics using different definitions (mathematics included), with the following types:

* **[DFA](https://github.com/arhcoder/Pytomatas/blob/master/docs/dfa.md  "DFA") (Deterministic Finite Automaton)**;
* **[NFA](https://github.com/arhcoder/Pytomatas/blob/master/docs/nfa.md "NFA") (Non-deterministic Finite Automaton)**;
* **[PDA](https://github.com/arhcoder/Pytomatas/blob/master/docs/pda.md "PDA") (Push-Down Automaton)**;
* **[TM](https://github.com/arhcoder/Pytomatas/blob/master/docs/tm.md "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.

<br>

## 📍 Index

- **🛠 [Installation](#-installation)**;
- **💻 [Usage](#-usage)**;
  - **🧿 [First implementation](#-first-implementation)**;
  - **🧿 [Second implementation](#-second-implementation)**;
- **📓 [Documentation](#-documentation)**;
- **📚 [Examples](#-examples)**;
  - **🤖 [DFA](https://github.com/arhcoder/Pytomatas/blob/master/docs/dfa.md  "DFA")**;
  - **🤖 [NFA](https://github.com/arhcoder/Pytomatas/blob/master/docs/nfa.md "NFA")**;
  - **🤖 [PDA](https://github.com/arhcoder/Pytomatas/blob/master/docs/pda.md "PDA")**;
  - **🤖 [TM](https://github.com/arhcoder/Pytomatas/blob/master/docs/tm.md "TM")**;
  - **🔐 [Safebox](https://github.com/arhcoder/Pytomatas/blob/master/docs/xsafebox.md)**;
- **📁 [Repository](#-repository)**;
- **✍ [Contributing](#-contributing)**;
- **📜 [License](#-license)**;

<br>

## 🛠 Installation

You can install Pytomatas using pip:

```bash
pip install Pytomatas
```

<br>

## 💻 Usage

There are two ways in which automata can be implemented:
1. Creating the empty automaton and then adding the properties.
2. 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:**

```python
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:**

```python
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](#-Documentation  "Documentation")**.

* For more detailed usage instructions and examples, please refer to **[Examples](#-Examples  "Examples")**.

<br>

## 📓 Documentation

Go to **[THIS LINK](http://github.com/arhcoder/Pytomatas/blob/master/docs/automatas.md "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.

<br>

## 📚 Examples

1. **[DFA (Deterministic Finite Automaton)](https://github.com/arhcoder/Pytomatas/blob/master/docs/dfa.md  "DFA").**

2. **[NFA (Non-deterministic Finite Automaton)](https://github.com/arhcoder/Pytomatas/blob/master/docs/nfa.md "NFA").**

3. **[PDA (Push-Down Automaton)](https://github.com/arhcoder/Pytomatas/blob/master/docs/pda.md "PDA").**

4. **[TM (Turing Machine)](https://github.com/arhcoder/Pytomatas/blob/master/docs/tm.md "TM").**

5. **[Safebox Automata Implementation Project](https://github.com/arhcoder/Pytomatas/blob/master/docs/xsafebox.md).**

<br>

## 📁 Repository

Go to **[THIS LINK](https://github.com/arhcoder/Pytomatas)** to check out the source code.

<br>

## ✍ 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](https://github.com/arhcoder/Pytomatas)**.

<br>

## 📜 License

This project is licensed under the MIT License - see the **[LICENSE](https://github.com/arhcoder/Pytomatas/blob/master/LICENSE)** file for details.

<hr>

**Made with 💜 by @arhcoder**;

<br>


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/arhcoder/Pytomatas",
    "name": "Pytomatas",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "Automata,Automaton,Turing Machine,Simulation,DFA,NFA,PDA,TM,Python",
    "author": "arhcoder",
    "author_email": "arhcoder@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/44/dd/9e6ec13991e106ab75fc1ede95cc31df5a5467fe31efcf84ca8b72080832/Pytomatas-1.1.4.tar.gz",
    "platform": null,
    "description": "# \ud83e\udd16 Pytomatas\n\n**\ud83d\udccc Version 1.1.4**\n\n<hr>\n\nPytomatas allows to simulate Acceptor Automata in the console with Python, implementing its characteristics using different definitions (mathematics included), with the following types:\n\n* **[DFA](https://github.com/arhcoder/Pytomatas/blob/master/docs/dfa.md  \"DFA\") (Deterministic Finite Automaton)**;\n* **[NFA](https://github.com/arhcoder/Pytomatas/blob/master/docs/nfa.md \"NFA\") (Non-deterministic Finite Automaton)**;\n* **[PDA](https://github.com/arhcoder/Pytomatas/blob/master/docs/pda.md \"PDA\") (Push-Down Automaton)**;\n* **[TM](https://github.com/arhcoder/Pytomatas/blob/master/docs/tm.md \"TM\") (Turing Machine)**;\n\nWhat can do?\n\n- Create and manage various types of automaton: DFA, NFA, PDA, TM.\n- Visualize automata information in console.\n- Simulate automata acceptors based on strings.\n- Observe the processes of steps and transitions when introducing a string to the automaton.\n\n<br>\n\n## \ud83d\udccd Index\n\n- **\ud83d\udee0 [Installation](#-installation)**;\n- **\ud83d\udcbb [Usage](#-usage)**;\n  - **\ud83e\uddff [First implementation](#-first-implementation)**;\n  - **\ud83e\uddff [Second implementation](#-second-implementation)**;\n- **\ud83d\udcd3 [Documentation](#-documentation)**;\n- **\ud83d\udcda [Examples](#-examples)**;\n  - **\ud83e\udd16 [DFA](https://github.com/arhcoder/Pytomatas/blob/master/docs/dfa.md  \"DFA\")**;\n  - **\ud83e\udd16 [NFA](https://github.com/arhcoder/Pytomatas/blob/master/docs/nfa.md \"NFA\")**;\n  - **\ud83e\udd16 [PDA](https://github.com/arhcoder/Pytomatas/blob/master/docs/pda.md \"PDA\")**;\n  - **\ud83e\udd16 [TM](https://github.com/arhcoder/Pytomatas/blob/master/docs/tm.md \"TM\")**;\n  - **\ud83d\udd10 [Safebox](https://github.com/arhcoder/Pytomatas/blob/master/docs/xsafebox.md)**;\n- **\ud83d\udcc1 [Repository](#-repository)**;\n- **\u270d [Contributing](#-contributing)**;\n- **\ud83d\udcdc [License](#-license)**;\n\n<br>\n\n## \ud83d\udee0 Installation\n\nYou can install Pytomatas using pip:\n\n```bash\npip install Pytomatas\n```\n\n<br>\n\n## \ud83d\udcbb Usage\n\nThere are two ways in which automata can be implemented:\n1. Creating the empty automaton and then adding the properties.\n2. Creating the automaton by passing its characteristics as in the mathematical definition.\n\nExample of a DFA implementation...\n\n#### \ud83e\uddff First implementation\n\n**1. Creating empty automata and then give the data:**\n\n```python\nfrom Pytomatas.dfa import DFA\n\n# Creates a DFA called \"my_dfa\":\nmy_dfa = DFA()\n\n# Define to \"my_dfa\" a set of states names:\nmy_dfa.setStates( {\"q0\", \"q1\", \"qfinal\"} )\n\n# Define to \"my_dfa\" a set of states characters of the alphabet:\nmy_dfa.setAlphabet( {\"a\", \"b\"} )\n\n# Set the \"Initial state\" name of \"my_dfa\":\nmy_dfa.setInitial( \"q0\" )\n\n# Define to \"my_dfa\" the set of \"Final states\" names:\nmy_dfa.setFinals( {\"qfinal\", \"qf2\"} )\n\n# Add transitions to the DFA:\nmy_dfa.addTransition( (\"q0\", \"a\", \"q1\") )\nmy_dfa.addTransition( (\"q0\", \"b\", \"qfinal\") )\nmy_dfa.addTransition( (\"q1\", \"a\", \"q1\") )\nmy_dfa.addTransition( (\"q1\", \"b\", \"q1\") )\nmy_dfa.addTransition( (\"qfinal\", \"a\", \"qfinal\") )\nmy_dfa.addTransition( (\"qfinal\", \"b\", \"qfinal\") )\n\n# Add more data to the existing one already in the automata:\nmy_dfa.addSymbol(\"c\")\nmy_dfa.addState(\"qx\")\nmy_dfa.addState(\"finalState2\")\nmy_dfa.addFinal(\"finalState2\")\n\n# Prints the DFA information:\nmy_dfa.show()\n\n# Check if a string is accepted on the defined automata \"my_dfa\":\n# It returns True or False if the string is accepted or not:\nword = \"aaabb\"\nmy_dfa.accepts(word)\n\n# Checks if the string is accepted, but prints all the process and steps on transitions;\n# Shows the flow of states while reading the string;\nmy_dfa.accepts(word, stepByStep=True)\n```\n\n#### \ud83e\uddff Second implementation\n\n**2. Creating the automata passing the data:**\n\n```python\nfrom Pytomatas.dfa import DFA\n\n# Declare the States:\nQ = {\"q0\", \"qa\", \"q1\", \"qb\", \"q2\", \"qf\", \"qx\"}\n\n# Declare the Alphabet:\nA = {\"a\", \"b\"}\n\n# Declare the Initial (start) state:\nS = \"q0\"\n\n# Declare the Finals states:\nF = {\"q2\", \"q3\"}\n\n# Declare the Transitions:\nT = [\n\t(\"q0\", \"a\", \"qa\"),\n\t(\"q0\", \"b\", \"q1\"),\n\t(\"qa\", \"a\", \"qa\"),\n\t(\"qa\", \"b\", \"qb\"),\n\t(\"qf\", \"b\", \"qf\"),\n\t(\"qx\", \"a\", \"qx\"),\n\t(\"qx\", \"b\", \"qx\")\n]\n\n# Declare the Automata:\nmy_dfa = DFA(Q, A, T, S, F)\n\n# Show the automata information:\nmy_dfa.show()\n\n# Check if a string is accepted on the defined automata \"my_dfa\":\n# It returns True or False if the string is accepted or not:\nword = \"aaabb\"\nmy_dfa.accepts(word)\n\n# Checks if the string is accepted, but prints all the process and steps on transitions;\n# Shows the flow of states while reading the string;\n# It returns True or False if the string is accepted or not:\nmy_dfa.accepts(word, stepByStep=True)\n```\n\n#### \ud83d\uded1 NOTE: These are only implementation examples, not actual implementations, so they are not complete real automata definitions \ud83d\udc46\n\n* For more detailed information about the attributes and methods of the class, refer to **[Documentation](#-Documentation  \"Documentation\")**.\n\n* For more detailed usage instructions and examples, please refer to **[Examples](#-Examples  \"Examples\")**.\n\n<br>\n\n## \ud83d\udcd3 Documentation\n\nGo to **[THIS LINK](http://github.com/arhcoder/Pytomatas/blob/master/docs/automatas.md \"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.\n\n<br>\n\n## \ud83d\udcda Examples\n\n1. **[DFA (Deterministic Finite Automaton)](https://github.com/arhcoder/Pytomatas/blob/master/docs/dfa.md  \"DFA\").**\n\n2. **[NFA (Non-deterministic Finite Automaton)](https://github.com/arhcoder/Pytomatas/blob/master/docs/nfa.md \"NFA\").**\n\n3. **[PDA (Push-Down Automaton)](https://github.com/arhcoder/Pytomatas/blob/master/docs/pda.md \"PDA\").**\n\n4. **[TM (Turing Machine)](https://github.com/arhcoder/Pytomatas/blob/master/docs/tm.md \"TM\").**\n\n5. **[Safebox Automata Implementation Project](https://github.com/arhcoder/Pytomatas/blob/master/docs/xsafebox.md).**\n\n<br>\n\n## \ud83d\udcc1 Repository\n\nGo to **[THIS LINK](https://github.com/arhcoder/Pytomatas)** to check out the source code.\n\n<br>\n\n## \u270d Contributing\n\nContributions 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](https://github.com/arhcoder/Pytomatas)**.\n\n<br>\n\n## \ud83d\udcdc License\n\nThis project is licensed under the MIT License - see the **[LICENSE](https://github.com/arhcoder/Pytomatas/blob/master/LICENSE)** file for details.\n\n<hr>\n\n**Made with \ud83d\udc9c by @arhcoder**;\n\n<br>\n\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Simulates Automatons Acceptors DFA, NFA, PDA and Turing Machines",
    "version": "1.1.4",
    "project_urls": {
        "Author": "https://github.com/arhcoder",
        "Bug Tracker": "https://github.com/arhcoder/Pytomatas/issues",
        "Contribution": "https://github.com/arhcoder/Pytomatas/pulls",
        "Homepage": "https://github.com/arhcoder/Pytomatas",
        "Source": "https://github.com/arhcoder/Pytomatas"
    },
    "split_keywords": [
        "automata",
        "automaton",
        "turing machine",
        "simulation",
        "dfa",
        "nfa",
        "pda",
        "tm",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "087e6005ff2607a823b5efdae72971af79abbd338c7e0684cdb066a6f0a7ef41",
                "md5": "73cc7a2652944effc4b8e84161c7c01f",
                "sha256": "e3437047c1668e3cd00540b33b9a23d7435cd141913a9ce3444f3fa3fcb780f5"
            },
            "downloads": -1,
            "filename": "Pytomatas-1.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "73cc7a2652944effc4b8e84161c7c01f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 14457,
            "upload_time": "2023-06-05T02:39:02",
            "upload_time_iso_8601": "2023-06-05T02:39:02.235635Z",
            "url": "https://files.pythonhosted.org/packages/08/7e/6005ff2607a823b5efdae72971af79abbd338c7e0684cdb066a6f0a7ef41/Pytomatas-1.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "44dd9e6ec13991e106ab75fc1ede95cc31df5a5467fe31efcf84ca8b72080832",
                "md5": "951d90460817bc570f1b3bd06408ac34",
                "sha256": "5a63a8b5c2631934cabe54694f20706df7fd65cb9d9e23b313fc25afb7a8c169"
            },
            "downloads": -1,
            "filename": "Pytomatas-1.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "951d90460817bc570f1b3bd06408ac34",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 10877,
            "upload_time": "2023-06-05T02:39:04",
            "upload_time_iso_8601": "2023-06-05T02:39:04.008771Z",
            "url": "https://files.pythonhosted.org/packages/44/dd/9e6ec13991e106ab75fc1ede95cc31df5a5467fe31efcf84ca8b72080832/Pytomatas-1.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-05 02:39:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "arhcoder",
    "github_project": "Pytomatas",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pytomatas"
}
        
Elapsed time: 0.07343s