{"id":18746774,"url":"https://github.com/phohenecker/asp-wrapper","last_synced_at":"2025-11-24T00:30:15.352Z","repository":{"id":121811228,"uuid":"132789771","full_name":"phohenecker/asp-wrapper","owner":"phohenecker","description":"A wrapper for accessing ASP solvers from Python.","archived":false,"fork":false,"pushed_at":"2018-07-25T09:14:01.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-28T20:46:08.339Z","etag":null,"topics":["answer-set-programming","python3","wrapper"],"latest_commit_sha":null,"homepage":null,"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/phohenecker.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-05-09T17:16:03.000Z","updated_at":"2018-07-25T09:14:02.000Z","dependencies_parsed_at":"2024-07-24T08:33:57.991Z","dependency_job_id":null,"html_url":"https://github.com/phohenecker/asp-wrapper","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/phohenecker%2Fasp-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phohenecker%2Fasp-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phohenecker%2Fasp-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phohenecker%2Fasp-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phohenecker","download_url":"https://codeload.github.com/phohenecker/asp-wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239629489,"owners_count":19671302,"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":["answer-set-programming","python3","wrapper"],"created_at":"2024-11-07T16:26:52.689Z","updated_at":"2025-11-24T00:30:15.296Z","avatar_url":"https://github.com/phohenecker.png","language":"Python","readme":"asp-wrapper\n===========\n\n\nThis repository provides a solution for a common scenario in which you have an answer set program in place that you wish\nto run from within your Python code together with additional facts.\nSuch a program could, e.g., specify a fixed set of rules that you would like to employ for reasoning about different\nscenarios that should be specified from within a Python application.\nTo that end, the package `aspwrapper` specifies an abstract base class,\n[`BaseSolver`](src/main/python/aspwrapper/base_solver.py#L41),\nfor wrappers that encapsulate access to answer set solvers.\nAt the current time, there exists only one implementation of this base class for\n[DLV](http://www.dlvsystem.com/dlv/),\nyet similar wrappers for other solvers are straightforward to implement.\n\n\nInstallation\n------------\n\nThis package can be installed via pip:\n```\npip install git+https://github.com/phohenecker/asp-wrapper\n```\n\n\nHow To Use It\n-------------\n\nSuppose that you would like to use the following very simple answer set program that specifies logical inference over\nsuperheroes and villains, and which is stored in the local file `heroes.asp`:\n\n```\n% all superheros and villains are persons\nperson(P) :- superhero(P) .\nperson(P) :- villain(P)   .\n\n% superheroes fight villains\nsuperhero(S) :- fights(S, _) .\nvillain(V)   :- fights(_, V) .\n```\n\nLet's assume further that you would like to run this answer set program together with the fact `fights(batman,joker)`.\nIn this case, you could use the following code:  \n\n```python\nimport aspwrapper\n\n# create an instance representing the DLV solver\nsolver = aspwrapper.DlvSolver(\"/path/to/dlv/binary\")\n\n# a set of facts consisting of the single literal fights(batman, joker)\nfacts = [aspwrapper.Literal(\"fights\", [\"batman\", \"joker\"])]\n\n# this set of facts has one according answer set\nanswer_sets = solver.run(\"heroes.asp\", facts)\nfor a in answer_sets:\n    print(a)\n```\n\nThe output of the code above is the following:\n\n```\n\u003e\u003e\u003e for a in answer_sets:\n...     print(a)\nAnswerSet(\n\tfacts      = { fights(batman,joker) },\n\tinferences = { villain(joker), person(joker), superhero(batman), person(batman) }\n)\n```\n\nIf you would like to try this by yourself, then have a look at the [`examples`](examples) folder, which contains the\ncode for this very example.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphohenecker%2Fasp-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphohenecker%2Fasp-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphohenecker%2Fasp-wrapper/lists"}