{"id":19580780,"url":"https://github.com/mirzaim/finite-automata-project","last_synced_at":"2025-08-29T03:45:54.246Z","repository":{"id":257421922,"uuid":"858189504","full_name":"mirzaim/Finite-Automata-Project","owner":"mirzaim","description":"Finite automata (DFA and NFA) with functionality to convert NFAs to DFAs and check string acceptance.","archived":false,"fork":false,"pushed_at":"2024-09-16T13:19:24.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-26T12:16:03.476Z","etag":null,"topics":["dfa","dfa-simulator","finite-automata","finite-state-machine","nfa","nfa-to-dfa","nfa-to-dfa-conversion"],"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/mirzaim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-09-16T13:19:22.000Z","updated_at":"2024-09-16T13:23:39.000Z","dependencies_parsed_at":"2024-09-16T17:00:42.035Z","dependency_job_id":null,"html_url":"https://github.com/mirzaim/Finite-Automata-Project","commit_stats":null,"previous_names":["mirzaim/finite-automata-project"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mirzaim/Finite-Automata-Project","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirzaim%2FFinite-Automata-Project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirzaim%2FFinite-Automata-Project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirzaim%2FFinite-Automata-Project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirzaim%2FFinite-Automata-Project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mirzaim","download_url":"https://codeload.github.com/mirzaim/Finite-Automata-Project/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirzaim%2FFinite-Automata-Project/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272620868,"owners_count":24965620,"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","status":"online","status_checked_at":"2025-08-29T02:00:10.610Z","response_time":87,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","dfa-simulator","finite-automata","finite-state-machine","nfa","nfa-to-dfa","nfa-to-dfa-conversion"],"created_at":"2024-11-11T07:29:49.265Z","updated_at":"2025-08-29T03:45:54.208Z","avatar_url":"https://github.com/mirzaim.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Finite Automata Project\n\nThis project implements finite automata concepts in Python, including classes for Deterministic Finite Automata (DFA) and Nondeterministic Finite Automata (NFA), along with functionality to convert an NFA to an equivalent DFA. It also provides scripts to check if a given string is accepted by a DFA and to perform the NFA to DFA conversion using input files.\n\n## Project Structure\n\n```\nproject/\n├── check_dfa.py\n├── convert_nfa_to_dfa.py\n├── finite_state_machine.py\n├── graph.py\n├── DFA_Input_1.txt\n└── NFA_Input.txt\n```\n\n- **check_dfa.py**: Script to check if a given string is accepted by a DFA.\n- **convert_nfa_to_dfa.py**: Script to convert an NFA to an equivalent DFA.\n- **finite_state_machine.py**: Module containing the `DFA` and `NFA` classes.\n- **graph.py**: Module containing the `Graph`, `Node`, and `Edge` classes.\n- **DFA_Input_1.txt**: Sample input file defining a DFA.\n- **NFA_Input.txt**: Sample input file defining an NFA.\n\n## Usage\n\n### Checking if a String is Accepted by a DFA\n\n1. **Prepare the DFA Input File**: Define your DFA in a text file (e.g., `DFA_Input_1.txt`) following the specified format (see [DFA Input File Format](#dfa-input-file-format)).\n\n2. **Run the Script**:\n\n   ```bash\n   python check_dfa.py DFA_Input_1.txt\n   ```\n\n3. **Enter the Input String**: When prompted, enter the string you want to check.\n\n4. **View the Result**: The script will output whether the string is accepted or rejected by the DFA.\n\n### Converting an NFA to a DFA\n\n1. **Prepare the NFA Input File**: Define your NFA in a text file (e.g., `NFA_Input.txt`) following the specified format (see [NFA Input File Format](#nfa-input-file-format)).\n\n2. **Run the Script**:\n\n   ```bash\n   python convert_nfa_to_dfa.py NFA_Input.txt\n   ```\n\n3. **Output**: The script will convert the NFA to a DFA and write the result to `DFA_Output.txt`.\n\n## Input File Formats\n\n### DFA Input File Format\n\nThe DFA input file should have the following structure:\n\n```\n\u003calphabet symbols separated by spaces\u003e\n\u003cstates separated by spaces\u003e\n\u003cinitial state\u003e\n\u003cfinal states separated by spaces\u003e\n\u003ctransition function entries\u003e\n```\n\n- **Alphabet Symbols**: List all symbols in the DFA's alphabet.\n- **States**: List all states in the DFA.\n- **Initial State**: Specify the initial state.\n- **Final States**: List all accepting (final) states.\n- **Transition Function Entries**: Each entry defines a transition in the format:\n  ```\n  \u003ccurrent_state\u003e \u003cinput_symbol\u003e \u003cnext_state\u003e\n  ```\n\n### NFA Input File Format\n\nThe NFA input file should have the following structure:\n\n```\n\u003calphabet symbols separated by spaces\u003e\n\u003cstates separated by spaces\u003e\n\u003cinitial state\u003e\n\u003cfinal states separated by spaces\u003e\n\u003ctransition function entries\u003e\n```\n\n- **Alphabet Symbols**: List all symbols in the NFA's alphabet (include 'λ' for lambda transitions if any).\n- **States**: List all states in the NFA.\n- **Initial State**: Specify the initial state.\n- **Final States**: List all accepting (final) states.\n- **Transition Function Entries**: Each entry defines a transition in the format:\n  ```\n  \u003ccurrent_state\u003e \u003cinput_symbol\u003e \u003cnext_state\u003e\n  ```\n\n## Examples\n\n### Example DFA Input\n\n**File**: `DFA_Input_1.txt`\n\n```\na b\nQ0 Q1 Q2\nQ0\nQ1\nQ0 a Q1\nQ0 b Q1\nQ1 a Q2\nQ1 b Q2\nQ2 a Q2\nQ2 b Q2\n```\n\n### Example NFA Input\n\n**File**: `NFA_Input.txt`\n\n```\n0 1\nA B C\nA\nC\nA 1 A\nA 0 B\nA λ B\nA 0 C\nB 1 B\nB λ C\nC 0 C\nC 1 C\n```\n\n## Modules\n\n### graph.py\n\nContains the following classes:\n\n- **Graph**: Represents a directed graph, used to model the transitions in NFAs and DFAs.\n- **Node**: Represents a state in the automaton.\n- **Edge**: Represents a transition between states with a specific label (input symbol).\n\n### finite_state_machine.py\n\nContains the following classes:\n\n- **DFA**: Represents a Deterministic Finite Automaton.\n\n  **Methods**:\n  - `check(string)`: Checks if the given string is accepted by the DFA.\n  - `__str__()`: Returns a string representation of the DFA.\n\n- **NFA**: Represents a Nondeterministic Finite Automaton.\n\n  **Methods**:\n  - `addAlphabet(alphabet)`: Adds symbols to the NFA's alphabet.\n  - `addStates(states)`: Adds states to the NFA.\n  - `addFinalStates(final_states)`: Defines the NFA's final states.\n  - `addTransition(begin, label, end)`: Adds a transition to the NFA.\n  - `lambda_closure(states)`: Computes the lambda closure of a set of states.\n  - `delta(states, symbol)`: Computes the set of states reachable from the given states on the given input symbol.\n  - `convertToDFA()`: Converts the NFA to an equivalent DFA.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirzaim%2Ffinite-automata-project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmirzaim%2Ffinite-automata-project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirzaim%2Ffinite-automata-project/lists"}