{"id":22340503,"url":"https://github.com/dankolesnikov/dfatoturingmachine","last_synced_at":"2026-02-08T15:02:18.460Z","repository":{"id":67650269,"uuid":"109792252","full_name":"dankolesnikov/DFAtoTuringMachine","owner":"dankolesnikov","description":"Turing Machine that simulates behavior of any Deterministic Finite Automata","archived":false,"fork":false,"pushed_at":"2017-12-13T06:20:36.000Z","size":12360,"stargazers_count":3,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-22T12:52:07.366Z","etag":null,"topics":["deterministic-finite-automata","dfa","theoretical-computer-science","theory-of-computation","turing-machine"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dankolesnikov.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":"2017-11-07T05:46:49.000Z","updated_at":"2025-04-27T20:42:07.000Z","dependencies_parsed_at":"2023-05-16T09:15:23.289Z","dependency_job_id":null,"html_url":"https://github.com/dankolesnikov/DFAtoTuringMachine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dankolesnikov/DFAtoTuringMachine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dankolesnikov%2FDFAtoTuringMachine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dankolesnikov%2FDFAtoTuringMachine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dankolesnikov%2FDFAtoTuringMachine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dankolesnikov%2FDFAtoTuringMachine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dankolesnikov","download_url":"https://codeload.github.com/dankolesnikov/DFAtoTuringMachine/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dankolesnikov%2FDFAtoTuringMachine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29234154,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-08T14:18:14.570Z","status":"ssl_error","status_checked_at":"2026-02-08T14:18:14.071Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["deterministic-finite-automata","dfa","theoretical-computer-science","theory-of-computation","turing-machine"],"created_at":"2024-12-04T07:11:53.560Z","updated_at":"2026-02-08T15:02:13.452Z","avatar_url":"https://github.com/dankolesnikov.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Turing Machine\n\u003e Turing Machine that takes an encoded DFA and prints out A to accept or R to reject the string input \n\n![](readme_pics/header.png)\n\n# Description\nThis Standard Turing Machine simulates behavior of any Deterministic Finite Automata that is properly encoded. The machine will return A or R for accepting or rejecting a string. Run the FinalRelease.jff in the the transducer mode of JFLAP program. Please be aware of potential bugs in this machine. \n\n## Deterministic Finite Automata (DFA) Fundamentals\nDFA can be mathematically defined as M = (Q,Σ,δ,q\u003csub\u003e0\u003c/sub\u003e,F), where:\n* Q - List of states \n* Σ - Alphabet\n* δ - Transition function\n* q\u003csub\u003e0\u003c/sub\u003e - Initial state\n* F - List of final(accepting) states \n\n### Example: \nL = {b\u003csup\u003en\u003c/sup\u003ea\u003csup\u003em\u003c/sup\u003e} where n \u0026#8805; 0 and m = 0 or 1\n\n![](readme_pics/example_dfa.png)\n\n\nMachine M constructed above can be mathematically broken down to:\n\n* Q = {q\u003csub\u003e2\u003c/sub\u003e,q\u003csub\u003e5\u003c/sub\u003e,q\u003csub\u003e9\u003c/sub\u003e}\n* Σ = {a,b}\n* q\u003csub\u003e0\u003c/sub\u003e = q\u003csub\u003e2\u003c/sub\u003e\n* F = {q\u003csub\u003e2\u003c/sub\u003e,q\u003csub\u003e5\u003c/sub\u003e}\n\nTransition function δ of the constructed DFA above will be:\n* δ(q\u003csub\u003e2\u003c/sub\u003e, b) = q\u003csub\u003e2\u003c/sub\u003e\n* δ(q\u003csub\u003e2\u003c/sub\u003e, a) = q\u003csub\u003e5\u003c/sub\u003e\n* δ(q\u003csub\u003e5\u003c/sub\u003e, b) = q\u003csub\u003e9\u003c/sub\u003e\n* δ(q\u003csub\u003e5\u003c/sub\u003e, a) = q\u003csub\u003e9\u003c/sub\u003e\n* δ(q\u003csub\u003e9\u003c/sub\u003e, b) = q\u003csub\u003e9\u003c/sub\u003e\n* δ(q\u003csub\u003e9\u003c/sub\u003e, a) = q\u003csub\u003e9\u003c/sub\u003e\n\nLet input string w = aab\n\n## Encoding a DFA \n\nWe will encode all element of M and w in unary numbers.\n\n\u003cb\u003eQ = {q2, q5, q9}\u003c/b\u003e\n\u003cbr\u003eThe first element of Q is encoded as 1, the second one as 11 and so forth.\nSo, the encoded version of Q would be: Q = {1, 11, 111}\n\n\u003cb\u003eq\u003csub\u003e0\u003c/sub\u003e\u003c/b\u003e\n\u003cbr\u003eWe always put the initial state as the first element of Q. So, q\u003csub\u003e0\u003c/sub\u003e (e.g. q\u003csub\u003e2\u003c/sub\u003e in the example) is always encoded as 1.\n\n\u003cb\u003eΣ = {a, b}\u003c/b\u003e\n\u003cbr\u003eThe first element of Σ is encoded as 1, the second one as 11 and so forth. So, the encoded version of Σ would be: Σ = {1, 11}\n\n\u003cb\u003eF = {q\u003csub\u003e2\u003c/sub\u003e, q\u003csub\u003e5\u003c/sub\u003e}\u003c/b\u003e\n\u003cbr\u003eThe set of final states follows the same codes of Q. So, the encoded version of F would be F = {1, 11}.\n\n\n\u003cb\u003eδ(q\u003csub\u003e0\u003c/sub\u003e, x) = q\u003csub\u003ej\u003c/sub\u003e\u003c/b\u003e\n\u003cbr\u003eThe elements of sub-rules are encoded by the same codes of Q and Σ and are formatted as the following figure shows. We use '0' (zero) as the separator between the elements.\n\n![](readme_pics/separators_dfa.png)\n\n\nNote that q\u003csub\u003e5\u003c/sub\u003e and b have the same code (i.e. 11), but their locations in the string give them different meaning.\n\u003cbr\u003eAll sub-rules of the example have been encoded in the following table. \n\n![](readme_pics/table_dfa.png)\n\n\n\u003cb\u003eInput string w = bba\u003c/b\u003e\n\nThe symbols of the input string are encoded by the codes of Σ and are separated by '0' (zero). So, the encoded version of w would be: w = 1101101\n\u003cbr\u003eLet's put all together and construct the TM's input string that contains the DFA's description and its input string.\n\n\n\n![](readme_pics/encoded_dfa.png)\n\n#### Final Result\n\nAfter applying all of the rules of encoding our DFA will look like this:\n\n```sh\n1101101D101101D101011D110110111D11010111D1110110111D111010111F1011\n```\n\n### Technical Notes\n1. The order of the elements of Q does not matter. The only restriction would be the first element that must be the q\u003csub\u003e0\u003c/sub\u003e of the DFA.\n2. The order of the elements of Σ does not matter.\n3. We don't need to put Q and Σ in the TM's input string because we just need to use their codes in δ, w, and F.\n4. We assume that the input string of the TM is 100% correct. It means, M and w are encoded and formatted correctly. Therefore, your  TM is not supposed to have any error checking or error reporting.\n5. Test your Turing machine as a transducer option of JFLAP.\n6. There are bugs in this machine.\n\n## Usage\n\nUse JFLAP 7 provided in the repository. Run inputs in transducer mode.\n\n## Meta\n\nDanil Kolesnikov – danil.kolesnikov@sjsu.edu\n\nDistributed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdankolesnikov%2Fdfatoturingmachine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdankolesnikov%2Fdfatoturingmachine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdankolesnikov%2Fdfatoturingmachine/lists"}