{"id":16338222,"url":"https://github.com/rohaquinlop/automathon","last_synced_at":"2025-04-05T18:06:42.291Z","repository":{"id":39977349,"uuid":"343469870","full_name":"rohaquinlop/automathon","owner":"rohaquinlop","description":"A Python library for simulating and visualizing finite automata","archived":false,"fork":false,"pushed_at":"2025-01-21T15:37:21.000Z","size":802,"stargazers_count":66,"open_issues_count":3,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T14:58:34.289Z","etag":null,"topics":["automata","dfa","epsilon-nfa","nfa","pypi","python","python-automaton","python-library","python3","sigma","visualization"],"latest_commit_sha":null,"homepage":"https://rohaquinlop.github.io/automathon/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rohaquinlop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"rohaquinlop"}},"created_at":"2021-03-01T15:46:49.000Z","updated_at":"2025-03-23T05:41:34.000Z","dependencies_parsed_at":"2024-02-16T05:22:18.797Z","dependency_job_id":"82ee4018-ebdb-4ba1-8724-ccf3a3717482","html_url":"https://github.com/rohaquinlop/automathon","commit_stats":{"total_commits":138,"total_committers":1,"mean_commits":138.0,"dds":0.0,"last_synced_commit":"910b79e86a2b8821d0a0eca7ea6890315f97ea20"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohaquinlop%2Fautomathon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohaquinlop%2Fautomathon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohaquinlop%2Fautomathon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohaquinlop%2Fautomathon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rohaquinlop","download_url":"https://codeload.github.com/rohaquinlop/automathon/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247378140,"owners_count":20929296,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automata","dfa","epsilon-nfa","nfa","pypi","python","python-automaton","python-library","python3","sigma","visualization"],"created_at":"2024-10-10T23:49:57.377Z","updated_at":"2025-04-05T18:06:42.273Z","avatar_url":"https://github.com/rohaquinlop.png","language":"Python","funding_links":["https://github.com/sponsors/rohaquinlop"],"categories":[],"sub_categories":[],"readme":"# automathon\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://rohaquinlop.github.io/automathon/\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/rohaquinlop/automathon/main/docs/img/logo-vector.svg\" alt=\"automathon\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cem\u003eA Python library for simulating and visualizing finite automata.\u003c/em\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/rohaquinlop/automathon\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://github.com/rohaquinlop/automathon/actions/workflows/main.yml/badge.svg?branch=main\" alt=\"Test\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://sonarcloud.io/summary/new_code?id=rohaquinlop_automathon\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://sonarcloud.io/api/project_badges/measure?project=rohaquinlop_automathon\u0026metric=alert_status\" alt=\"Quality Gate\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://pypi.org/project/automathon\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/v/automathon?color=%2334D058\u0026label=pypi%20package\" alt=\"Package version\"\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n**Documentation**: \u003ca href=\"https://rohaquinlop.github.io/automathon/\" target=\"_blank\"\u003ehttps://rohaquinlop.github.io/automathon/\u003c/a\u003e\n\n**Source Code**: \u003ca href=\"https://github.com/rohaquinlop/automathon\" target=\"_blank\"\u003ehttps://github.com/rohaquinlop/automathon\u003c/a\u003e\n\n**PyPI**: \u003ca href=\"https://pypi.org/project/automathon/\" target=\"_blank\"\u003ehttps://pypi.org/project/automathon/\u003c/a\u003e\n\n---\n\n## Requirements\n\n- Python \u003e= 3.10\n- You also need to install Graphviz on your computer ([download page](https://www.graphviz.org/download/), [installation procedure for Windows](https://forum.graphviz.org/t/new-simplified-installation-procedure-on-windows/224), [archived versions](https://www2.graphviz.org/Archive/stable/)).Make sure that the directory containing the **dot** executable is on your systems’ path.\n\n## Installation\n\n```bash\npip install automathon\n```\n\n### Upgrade\n\n```bash\npip install automathon --upgrade\n```\n\n## Example\n\nHere is are some examples about what you can do with **automathon**, you can\ncheck the documentation about [Deterministic Finite Automata](https://rohaquinlop.github.io/automathon/dfa/) and\n[Non-Deterministic Finite Automata](https://rohaquinlop.github.io/automathon/nfa/) to know more about the functions and\nmethods that are available.\n\n### DFA - Deterministic Finite Automata\n\n![DFA Visualization](https://github.com/rohaquinlop/automathon/assets/50106623/81efada9-3c68-4611-bb5c-53dcaf7987f1)\n\nThis image was created using **automathon**.\n\nLet's create the previous automata using the library:\n\n```python\nfrom automathon import DFA\nq = {'q0', 'q1', 'q2'}\nsigma = {'0', '1'}\ndelta = { 'q0' : {'0' : 'q0', '1' : 'q1'},\n          'q1' : {'0' : 'q2', '1' : 'q0'},\n          'q2' : {'0' : 'q1', '1' : 'q2'}\n        }\ninitial_state = 'q0'\nf = {'q0'}\n\nautomata = DFA(q, sigma, delta, initial_state, f)\n```\n\n#### Verify if the automata is valid\n\n```python\nautomata.is_valid()    # True\n```\n\nIn this case, the automata is valid but if it wasn't, the library would raise an\nexception with the error message.\n\n#### Errors\n\nErrors that the library can raise are:\n\n- **SigmaError**:\n  - The automata contain an initial state, or a final state that's not defined in Q.\n  - The automata contain a delta transition that's not defined in Q nor Sigma.\n\n- **InputError**:\n  - The automata is trying to consume a letter that's not defined in sigma.\n\n#### Verify if the automata accept a given string\n\n```python\nautomata.accept(\"001001\")  # True\nautomata.accept(\"00100\")   # False\n```\n\n#### Get the automata's complement\n\n```python\nnot_automata = automata.complement()\nnot_automata.accept(\"00100\")    #True\n```\n\nNote that this function returns a new automata, it doesn't modify the original\none.\n\n#### Visualize the automata\nFor both, [DFA](https://rohaquinlop.github.io/automathon/dfa/) and [NFA](https://rohaquinlop.github.io/automathon/nfa/), the view method enables to visualize the automaton, receives as parameter a String as the file name for the png and svg files.\n\nMore information about the graphviz attributes [here](https://www.graphviz.org/doc/info/attrs.html).\n\n![DFA Visualization](https://github.com/rohaquinlop/automathon/assets/50106623/81efada9-3c68-4611-bb5c-53dcaf7987f1)\n```python\n# Default styling\nautomata.view(\"DFA Visualization\")\n\n# You can decide between png and svg file formats\n# If you want to add custom styling, you can use the following\n\nautomata.view(\n    file_name=\"DFA Custom Styling\",\n    file_format=\"png\" or \"svg\",\n    node_attr={'fontsize': '20'},\n    edge_attr={'fontsize': '20pt'}\n)\n```\n\nIf you want to explore more about the functions and methods of the DFA class,\nyou can check the [DFA documentation](https://rohaquinlop.github.io/automathon/dfa/). And if you want to know more about\nthe NFA class, you can check the [NFA documentation](https://rohaquinlop.github.io/automathon/nfa/).\n\n### NFA - Non-Deterministic Finite Automata\n\n![](http://www.r9paul.org/wp-content/uploads/2008/12/nfa_example.jpg)\n\nImage taken from: [r9paul.org](http://www.r9paul.org/blog/2008/nondeterministic-finite-state-machine/)\n\n#### Representing the previous automata\n\n```python\nfrom automathon import NFA\n\n## Epsilon Transition is denoted by '' -\u003e Empty string\nq = {'q1', 'q2', 'q3', 'q4'}\nsigma = {'0', '1'}\ndelta = {\n    'q1' : {\n            '0' : {'q1'},\n            '1' : {'q1', 'q2'}\n            },\n    'q2' : {\n            '0' : {'q3'},\n            '' : {'q3'}\n            },\n    'q3' : {\n            '1' : {'q4'},\n            },\n    'q4' : {\n            '0' : {'q4'},\n            '1' : {'q4'},\n            },\n}\ninitial_state = 'q1'\nf = {'q4'}\n\nautomata = NFA(q, sigma, delta, initial_state, f)\n```\n\n#### Verify if the automata is valid\n\n```python\nautomata.is_valid()  # True\n```\n\n#### Verify if the automata accept a string\n\n```python\nautomata.accept(\"0000011\")   #True\nautomata.accept(\"000001\")    #False\n```\n\n#### Get the automata's complement\n\n```python\nnot_automata = automata.complement()\nnot_automata.accept(\"000001\")    #True\n```\n\n#### Visualize the automata\n\n![NFA Visualization](https://github.com/rohaquinlop/automathon/assets/50106623/966f4389-7862-4e5f-a5f4-c007c3a836b4)\n```python\n# Default styling\nautomata.view(\"NFA Visualization\")\n\n# You can decide between png and svg file formats\n# If you want to add custom styling, you can use the following\n\nautomata.view(\n    file_name=\"NFA Custom Styling\",\n    file_format=\"png\" or \"svg\",\n    node_attr={'fontsize': '20'},\n    edge_attr={'fontsize': '20pt'}\n)\n```\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frohaquinlop%2Fautomathon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frohaquinlop%2Fautomathon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frohaquinlop%2Fautomathon/lists"}