{"id":25709425,"url":"https://github.com/coderatul/dfa-simulator","last_synced_at":"2025-02-25T09:34:16.324Z","repository":{"id":279052040,"uuid":"937583775","full_name":"coderatul/DFA-Simulator","owner":"coderatul","description":"A Python tool for simulating Deterministic Finite Automata (DFAs) by reading transition tables from Excel files. It checks if input strings are accepted, supports verbose output for detailed DFA information, and ensures all transitions are defined. Object-oriented, user-friendly, and ideal for theoretical computer science education.","archived":false,"fork":false,"pushed_at":"2025-02-23T13:24:27.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-23T13:34:18.159Z","etag":null,"topics":["dfa","hacktoberfest","scientific-computing","simulator","theory-of-computation","toc"],"latest_commit_sha":null,"homepage":"","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/coderatul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2025-02-23T12:27:31.000Z","updated_at":"2025-02-23T13:25:34.000Z","dependencies_parsed_at":"2025-02-23T13:34:22.195Z","dependency_job_id":"1f14ec0b-ae12-4bf6-bc95-c43417ca678e","html_url":"https://github.com/coderatul/DFA-Simulator","commit_stats":null,"previous_names":["coderatul/dfa-simulator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderatul%2FDFA-Simulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderatul%2FDFA-Simulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderatul%2FDFA-Simulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderatul%2FDFA-Simulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderatul","download_url":"https://codeload.github.com/coderatul/DFA-Simulator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240641457,"owners_count":19833836,"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":["dfa","hacktoberfest","scientific-computing","simulator","theory-of-computation","toc"],"created_at":"2025-02-25T09:32:37.275Z","updated_at":"2025-02-25T09:34:16.273Z","avatar_url":"https://github.com/coderatul.png","language":"Python","readme":"# DFA Simulator 🖥️⚙️🔄\n\n## Overview\n\nThe DFA Simulator is a Python tool for simulating Deterministic Finite Automata (DFAs) by reading their transition tables from an Excel file and checking if input strings are accepted by the DFA. It provides an object-oriented implementation with optional verbose output to display the DFA's 5-tuples (Q, Σ, δ, q0, F), and the result that wether a string belongs to DFA m/c or not\n\nwhere,\n - Q : set of state(s)\n - Σ : set of input Alphabets\n - δ : transition function (Q x Σ = Q)\n - q0 : initial state\n - F : set of final state(s)\n\n## Features 📌\n\n- Reads DFA transition tables from an Excel file.\n- Ensures all transitions are defined for every state and input symbol (DFA requirement).\n- Offers verbose and non-verbose modes for output control.\n- Includes error handling for invalid input, missing transitions, and file issues.\n- Object-oriented design for maintainability and extensibility.\n\n## Usage\n\n### Preparing the Excel File\n\n- Modify the pre-existing excel file `dfa_transitions.xlsx` according to your DFA\n\n![example of excel structure](https://github.com/user-attachments/assets/45e87190-3c0b-48ac-863b-fa51d8cc970a)\n\n\n**Points to Take Care of While Entering Data:** 📋\n- *Representing ε* : ε(string with length 0), is represented using '' (empty string)\n- *Initial State Marker* : Use the marker \"--\u003e\" to indicate the start state. To prevent Excel\n      from interpreting \"--\u003e\" as a formula, enter it with an escape sequence (_e.g., precede it with\n      a single quote: '--\u003e_). This ensures Excel treats it as plain text.\n- *Input Alphabet* : The input alphabet (Σ) may increase by adding new columns for additional\n      symbols. All alphabet symbols are treated as strings by deafult, (_e.g, 1,2.. are treated as string_)\n- _DFA Requirement_ : Since this script supports only DFAs, ensure a transition is defined for\n      every state in Q and every symbol in Σ. Missing transitions will raise an error.\n\n## Few examples 📋\n- Transition table for a DFA, which accepts only those strings, which starts and ends with the same i/p symbol `a`, over the `Σ = {a,b}` is there in the file `dfa_transitions.xlxs` as an example\n\ntransition table in Excel would look like\n\n|        |        | Input Alphabets|    |\n|--------|--------|----------------|----|\n|        | States |                |    |\n|        |        | a              | b  |\n| →      | q0     | q1             | ds |\n| *      | q1     | q1             | q2 |\n|        | q2     | q1             | q2 |\n|        | ds     | ds             | ds |\n\n- **q0**: Start state\n- **q1***: Final state\n- **ds**: Dead state (just a convention)\n\n### Example 1: Non-Verbose Output for a Valid String\n```python\n# DFA Simulation\nfrom dfa_simulator import DFASimulator\n\ndfa = DFASimulator('dfa_transitions.xlsx')\nw = input(\"Enter a string: \")\nresult = dfa.check_string(w)\n```\n**Output:**\n```\nEnter a string: aaaa\nAccepted\n```\n\u003e **Accepted** because the string starts with 'a' and ends with 'a'.\n\n---\n\n### Example 2: Non-Verbose Output for an Invalid String\n```python\n# DFA Simulation\nfrom dfa_simulator import DFASimulator\n\ndfa = DFASimulator('dfa_transitions.xlsx')\nw = input(\"Enter a string: \")\nresult = dfa.check_string(w)\n```\n**Output:**\n```\nEnter a string: bbbba\nRejected\n```\n\u003e **Rejected** because the string starts with 'b' and ends with 'a', not matching the requirement.\n\n---\n\n### Example 3: Verbose Output for a Valid String\n```python\n# DFA Simulation with Verbose Output\nfrom dfa_simulator import DFASimulator\n\ndfa = DFASimulator('dfa_transitions.xlsx')\nw = input(\"Enter a string: \")\nresult = dfa.check_string(w, verbose=True)\n```\n**Output:**\n```\nQ (States): {'q0', 'q1', 'q2', 'ds'}\nSigma (Input Alphabet): {'a', 'b'}\nq0 (Start State): q0\nF (Final States): {'q1'}\nTransition Function (δ): {('q0', 'a'): 'q1', ('q0', 'b'): 'q2', ('q1', 'a'): 'q1', ('q1', 'b'): 'ds', ('q2', 'a'): 'ds', ('q2', 'b'): 'q2', ('ds', 'a'): 'ds', ('ds', 'b'): 'ds'}\nResult for string 'aaaa': Accepted\nAccepted\n```\n\u003e **Accepted** because the string starts with 'a', ends with 'a', and all transitions are valid.\n\n---\n\n### Example 4: Verbose Output for an Invalid String\n```python\n# DFA Simulation with Verbose Output\nfrom dfa_simulator import DFASimulator\n\ndfa = DFASimulator('dfa_transitions.xlsx')\nw = input(\"Enter a string: \")\nresult = dfa.check_string(w, verbose=True)\n```\n**Output:**\n```\nQ (States): {'q0', 'q1', 'q2', 'ds'}\nSigma (Input Alphabet): {'a', 'b'}\nq0 (Start State): q0\nF (Final States): {'q1'}\nTransition Function (δ): {('q0', 'a'): 'q1', ('q0', 'b'): 'q2', ('q1', 'a'): 'q1', ('q1', 'b'): 'ds', ('q2', 'a'): 'ds', ('q2', 'b'): 'q2', ('ds', 'a'): 'ds', ('ds', 'b'): 'ds'}\nResult for string 'ab': Rejected\nRejected\n```\n\u003e **Rejected** because the string starts with 'a' but ends with 'b', not meeting the requirement.\n\n---\n\n### Example 5: Non-Verbose Output for an Empty String\n```python\n# DFA Simulation\nfrom dfa_simulator import DFASimulator\n\ndfa = DFASimulator('dfa_transitions.xlsx')\nw = input(\"Enter a string: \")\nresult = dfa.check_string(w)\n```\n**Output:**\n```\nEnter a string:\nRejected\n```\n\u003e **Rejected** because the empty string doesn't start or end with 'a', and the start state 'q0' is not a final state.\n\n---\n\n### Example 6: Verbose Output for an Invalid Symbol\n```python\n# DFA Simulation with Verbose Output\nfrom dfa_simulator import DFASimulator\n\ndfa = DFASimulator('dfa_transitions.xlsx')\nw = input(\"Enter a string: \")\nresult = dfa.check_string(w, verbose=True)\n```\n**Output:**\n```\nQ (States): {'q0', 'q1', 'q2', 'ds'}\nSigma (Input Alphabet): {'a', 'b'}\nq0 (Start State): q0\nF (Final States): {'q1'}\nTransition Function (δ): {('q0', 'a'): 'q1', ('q0', 'b'): 'q2', ('q1', 'a'): 'q1', ('q1', 'b'): 'ds', ('q2', 'a'): 'ds', ('q2', 'b'): 'q2', ('ds', 'a'): 'ds', ('ds', 'b'): 'ds'}\nResult for string 'ac': Rejected\nRejected\n```\n\u003e **Rejected** because 'c' is not in the alphabet {a, b}.\n\n---\n\n\n\n\n\n    \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderatul%2Fdfa-simulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderatul%2Fdfa-simulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderatul%2Fdfa-simulator/lists"}