{"id":26010535,"url":"https://github.com/jdonszelmann/logictester","last_synced_at":"2026-04-21T04:31:58.933Z","repository":{"id":114826580,"uuid":"147874606","full_name":"jdonszelmann/logictester","owner":"jdonszelmann","description":"This is a little library which test logical expressions (based on and will be updated with the delft R\u0026L CSE course)","archived":false,"fork":false,"pushed_at":"2018-09-08T10:12:00.000Z","size":37,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-05T22:51:33.552Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdonszelmann.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":"2018-09-07T21:04:10.000Z","updated_at":"2018-10-13T13:30:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"c59cefde-e308-4945-b3d8-aa2219739c12","html_url":"https://github.com/jdonszelmann/logictester","commit_stats":null,"previous_names":["jdonszelmann/logictester"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jdonszelmann/logictester","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdonszelmann%2Flogictester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdonszelmann%2Flogictester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdonszelmann%2Flogictester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdonszelmann%2Flogictester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdonszelmann","download_url":"https://codeload.github.com/jdonszelmann/logictester/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdonszelmann%2Flogictester/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32076897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T02:38:07.213Z","status":"ssl_error","status_checked_at":"2026-04-21T02:38:06.559Z","response_time":128,"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":[],"created_at":"2025-03-05T22:51:09.664Z","updated_at":"2026-04-21T04:31:58.928Z","avatar_url":"https://github.com/jdonszelmann.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Logic Tester\n\nthis little library can test your logic expressions.\n\nto write a testable logic expression, one can use the following replacements for the default binary connectives:\n\n| python | bianry connective | \n| --- | --- |\n| not\t(Not(a,b))\t| \t\t¬\t\t\t\t|\n| and\t(And(a,b))\t| \t\t^\t\t\t\t|\n| or \t(Or(a,b))\t| \t\tv \t\t\t\t|\n| Xor(a,b)\t\t\t| \t\t⊕ \t\t\t\t|\n| Xnor(a,b)\t\t\t| \t\t⇔\t\t\t\t|\n| Implies(a,b)\t\t| \t\t-\u003e\t\t\t\t|\n\nTo start testing a logical expression, one writes a function like this, with as many parameters as will be used in the expression (This is important):\n\n```python\nfrom logictester import *\n\n\ndef test1(a,b,c,d):\n\treturn Implies(a,b and c) or (c and Xor(a,d))\n\n```\n\nit's important that the result of this expression will be returned. within the function you wrote you can do anything as long as the return value is a boolean. In most cases a one-line function as above will suffice.\n\nnow comes the magic:\n\nto generate a truth table of this expression, call the logic function with as the first and only argument the function:\n```python\nlogic(test1)\n```\n\nso you get:\n \n```python\nfrom logictester import *\n\ndef test1(a,b,c,d):\n\treturn Implies(a,b and c) or (c and Xor(a,d))\n\n\nprint(logic(test1))\n```\n\nthe truth table of this function will be printed like this:    \na b c d | o  \n0 0 0 0 | True  \n0 0 0 1 | True  \n0 0 1 0 | True  \n0 0 1 1 | True  \n0 1 0 0 | True  \n0 1 0 1 | True  \n0 1 1 0 | True  \n0 1 1 1 | True  \n1 0 0 0 | False  \n1 0 0 1 | False  \n1 0 1 0 | True  \n1 0 1 1 | False  \n1 1 0 0 | False  \n1 1 0 1 | False  \n1 1 1 0 | True  \n1 1 1 1 | True  \nTrue count:  11  \nFalse count:  5  \n\nthe ammount of arguments to the logic_tester is arbitrary. it will automatically be determined. This doesn't mean any number of arguments is possible. this is due to the fact that the algorithm used is O(2^n) which is *SLOW*. so to not-overflow your terminal and keep execution time reasonable, be reasonable with the ammount of arguments.\n\n---\n\nOne can also test for equivalence of two functions with logictester. this can be done as follows: \n\n```python\n\nfrom logictester import *\n\ndef test1(a,b,c,d):\n\treturn Implies(a,b and c) or (c and Xor(a,d))\n\ndef test2(a,b,c,d):\n\treturn Implies(a,b and c) or (d and a)\n\ndef test3(a,b,c,d):\n\treturn Implies(a,b and c) or d\n\n\nprint(is_equivalent(test1,test2)) \t\n#will return False\n\nprint(is_equivalent(test2,test3))\n#will return True\n\nprint(logic(test2) == logic(test3))\n#works too. will also return True\n\n```\n\n---\n\nOne can find the differences between two expressions (which is actually used to test for equivalence. if there are no differences the expressions are equivalent) by using the find_differences funtion on the logic object:\n\n\n```python\n\nfrom logictester import *\n\ndef test1(a,b,c,d):\n\treturn Implies(a,b and c) or (c and Xor(a,d))\n\ndef test2(a,b,c,d):\n\treturn Implies(a,b and c) or (d and a)\n\ndef test3(a,b,c,d):\n\treturn Implies(a,b and c) or d\n\n\nprint(logic(test1).find_differences(test2)) \t\n#will return [(1, 0, 0, 1), (1, 0, 1, 0), (1, 0, 1, 1), (1, 1, 0, 1)]\n#since these are the input cases in which test1 and test2 differ\n\nprint(logic(test2).find_differences(test3))\n#will return an empty list ([])\n```\n\n---\n\nlogic tester now also includes autmatic simplification and generation of logic expressions. to use this feature just make a new expression function, use logic() on it and use the find_expression method. this method will be the simpelest possible disjunctive normal form of the expression. (bugesting needed, haven't proven the working but i'm yet to find a casse in which is doesnt work.)\n\n```python\nfrom logictester import *\n\ndef test1(a,b,c,d):\n\treturn Implies(a,b and c) or d\n\n\nprint(logic(test1).find_expression())\n#prints (a) v (¬a ^ ¬d) v (¬a ^ ¬b ^ ¬c ^ d)\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdonszelmann%2Flogictester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdonszelmann%2Flogictester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdonszelmann%2Flogictester/lists"}