{"id":22729066,"url":"https://github.com/giovanniberti/logicamente","last_synced_at":"2025-04-13T21:50:44.859Z","repository":{"id":93125429,"uuid":"170531162","full_name":"giovanniberti/logicamente","owner":"giovanniberti","description":"A first-order logic theorem prover with SLD resolution.","archived":false,"fork":false,"pushed_at":"2019-02-13T15:29:26.000Z","size":32,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T12:11:11.907Z","etag":null,"topics":["first-order-logic","logic","prolog","python","sld"],"latest_commit_sha":null,"homepage":"","language":"Python","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/giovanniberti.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}},"created_at":"2019-02-13T15:29:18.000Z","updated_at":"2021-11-01T12:07:06.000Z","dependencies_parsed_at":"2023-03-13T17:20:01.669Z","dependency_job_id":null,"html_url":"https://github.com/giovanniberti/logicamente","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giovanniberti%2Flogicamente","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giovanniberti%2Flogicamente/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giovanniberti%2Flogicamente/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giovanniberti%2Flogicamente/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/giovanniberti","download_url":"https://codeload.github.com/giovanniberti/logicamente/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248788855,"owners_count":21161726,"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":["first-order-logic","logic","prolog","python","sld"],"created_at":"2024-12-10T17:19:26.434Z","updated_at":"2025-04-13T21:50:44.837Z","avatar_url":"https://github.com/giovanniberti.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# logicamente\nA first-order logic theorem prover.\n\n## Dependencies\n\n- Python 3.7 (for `@dataclass` decorator)\n- pyparsing 2.3.1\n\nAvailable on pip, install with `pip install pyparsing`\n\n## Running\nJust\n\n```\npython3 main.py\n```\n\nThe program asks for a Prolog-like knowledge base file and for a query.\n\nThere's an included example file called `underground`\n\nExample usage:\n\n```\n$ python main.py\n\ninput file: ./underground\n\ninput query: reachable(tottenham_court_road,leicester_square, R)\n\nbackward_chain{ (reachable(tottenham_court_road, leicester_square, R)) }: True\n\nresult: (reachable(tottenham_court_road, leicester_square, (list())))\n```\n\n## Knowledge base quick start\n\n- Variables: upper case + `_`\n\n- Literals: lower case + `_`\n\n- N-ary relations are supported, name same as literals\n\n- `(A \u0026 B) =\u003e C` (implication) becomes `C :- A, B`\n\n- Body of clause\n\n- Lists: brackets, comma-separated `[a, B, foo(bar, Q)]`\n\n- Every clause must end with `.`\n\n- Clauses are resolved using the order provided in the KB file.\nIf there is a cycle it will be detected and can be corrected by changing the clauses' order.\n\n- C-style comments supported\n\nExample:\n\n```\n/* file: happy.pl */\nsmiles(P, Q) :- happy(P).\nhappy(P) :- loves(P, Q), rested(P).\n\nrested(johnny).\nloves(mary, johnny).\n\nloves(P,Q) :- loves(Q,P).\n```\n\n```\n$ python main.py\ninput file: happy.pl\ninput query: happy(X)\nbackward_chain{ (happy(X)) }: True\nresult: (happy(johnny))\n\n```\n\n---\n\nThanks to: https://stackoverflow.com/a/28398903 for Python implementation of Visitor pattern! :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiovanniberti%2Flogicamente","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgiovanniberti%2Flogicamente","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiovanniberti%2Flogicamente/lists"}