ABSTRACT
This paper presents stableKanren, a miniKanren extension with normal logic programming support under stable model semantics. MiniKanren is a relational programming solver implemented atop Scheme via shallow embedding, which means the predicate in each rule is encoded as a goal function directly. The solver utilizes the pattern matching macro in Scheme to transform the input goal function and form a static search stream through continuations to achieve the essential features, resolution and unification, in Prolog. However, the static stream only works on monotonic reasoning. Even though the core miniKanren is designed to be easily modified and extended with new features, none of the existing extensions support solving normal logic programs. Also, no normal logic program solvers are based on a functional programming language. We identify and categorize the roles of resolution and unification in top-down solving. And we realize that a dynamic search stream is needed to support non-monotonic reasoning. So we evolve both resolution and unification with new roles, and we exploit the advantages of using macros and continuations further to weave the information generated during runtime into future streams dynamically. We create multiple innovative macros to compile the normal logic program into a program with its complement form, obtain the domain of a variable under different contexts, and generate the new search stream during solving. And we use the coinductive resolution to handle the loop in the normal logic program. In future work, we plan to apply bottom-up optimization to improve our top-down system performance and support various input rules.
- Dirk Abels, Julian Jordi, Max Ostrowski, Torsten Schaub, Ambra Toletti, and Philipp Wanko. 2021. Train Scheduling with Hybrid Answer Set Programming. Theory and Practice of Logic Programming 21, 3 (2021), 317–347. https://doi.org/10.1017/S1471068420000046Google ScholarCross Ref
- William E. Byrd. 2009. Relational Programming in Minikanren: Techniques, Applications, and Implementations. Ph. D. Dissertation. USA. Advisor(s) Friedman, Daniel P. AAI3380156.Google Scholar
- Keith L. Clark. 1978. Negation as Failure. Logic and Data Bases (1978), 293–322. https://doi.org/10.1007/978-1-4684-3384-5_11Google ScholarCross Ref
- Carmine Dodaro and Marco Maratea. 2017. Nurse Scheduling via Answer Set Programming. In Logic Programming and Nonmonotonic Reasoning, Marcello Balduccini and Tomi Janhunen (Eds.). Springer International Publishing, Cham, 301–307.Google Scholar
- D.P. Friedman, W.E. Byrd, and O. Kiselyov. 2005. The Reasoned Schemer. MIT Press. https://books.google.com/books?id=_xciAQAAIAAJGoogle Scholar
- Daniel P. Friedman, William E. Byrd, Oleg Kiselyov, and Jason Hemann. 2018. The Reasoned Schemer (2nd ed.). The MIT Press.Google Scholar
- Daniel P. Friedman and Matthias Felleisen. 1996. The Little Schemer (4th Ed.). MIT Press, Cambridge, MA, USA.Google Scholar
- Martin Gebser, Benjamin Kaufmann, André Neumann, and Torsten Schaub. 2007. Conflict-Driven Answer Set Solving. In Proceedings of the 20th International Joint Conference on Artifical Intelligence (Hyderabad, India) (IJCAI’07). Morgan Kaufmann Publishers Inc., San Francisco, CA, USA, 386–392.Google ScholarDigital Library
- Michael Gelfond and Vladimir Lifschitz. 1988. The stable model semantics for logic programming.. In ICLP/SLP, Vol. 88. Cambridge, MA, 1070–1080.Google Scholar
- Gopal Gupta, Ajay Bansal, Richard Min, Luke Simon, and Ajay Mallya. 2007. Coinductive Logic Programming and Its Applications. In Proceedings of the 23rd International Conference on Logic Programming (Porto, Portugal) (ICLP’07). Springer-Verlag, Berlin, Heidelberg, 27–44.Google ScholarDigital Library
- Michael Hanus, Herbert Kuchen, and Juan Jose Moreno-Navarro. 1995. Curry: A truly functional logic language. In Proc. ILPS, Vol. 95. 95–107.Google Scholar
- Jason Hemann and Daniel Friedman. 2017. A Framework for Extending microKanren with Constraints. Electronic Proceedings in Theoretical Computer Science 234 (01 2017). https://doi.org/10.4204/EPTCS.234.10Google ScholarCross Ref
- Intl. Organization for Standardization.1995. ISO/IEC 13211-1:1995: Information technology — Programming languages — Prolog — Part 1: General core. 199 pages. https://www.iso.org/standard/21413.htmlGoogle Scholar
- Intl. Organization for Standardization. 2000. ISO/IEC 13211-2:2000: Information technology — Programming languages — Prolog — Part 2: Modules. https://www.iso.org/standard/20775.htmlGoogle Scholar
- Roland Kaminski, Torsten Schaub, and Philipp Wanko. 2017. A Tutorial on Hybrid Answer Set Solving with clingo. Springer International Publishing, Cham, 167–203. https://doi.org/10.1007/978-3-319-61033-7_6Google ScholarCross Ref
- John W. Lloyd. 1987. Foundations of Logic Programming, 2nd Edition. Springer. https://doi.org/10.1007/978-3-642-83189-8Google ScholarCross Ref
- Kyle Marple, Elmer Salazar, and Gopal Gupta. 2017. Computing Stable Models of Normal Logic Programs Without Grounding. CoRR abs/1709.00501 (2017). arxiv:1709.00501http://arxiv.org/abs/1709.00501Google Scholar
- John McCarthy. 1960. Programs with Common Sense. Technical Report. Cambridge, MA, USA.Google Scholar
- Richard Min and Gopal Gupta. 2010. Coinductive Logic Programming with Negation. In Logic-Based Program Synthesis and Transformation, Danny De Schreye (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 97–112.Google Scholar
- Evgenii Moiseenko. 2019. Constructive negation for minikanren. In ICFP 2019, The miniKanren and Relational Programming Workshop.Google Scholar
- Raymond Reiter. 1981. On closed world data bases. In Readings in artificial intelligence. Elsevier, 119–140.Google Scholar
- J. A. Robinson and E. E. Sibert. 1982. LogLisp: Motivation, Design and Implementation. K.L. Clark and S.-A. Tarnlund (Eds.): Logic Programming, Academic Press, New York, 229–314.Google Scholar
- Zoltan Somogyi, Fergus J Henderson, and Thomas Charles Conway. 1995. Mercury, an efficient purely declarative logic programming language. Australian Computer Science Communications 17 (1995), 499–512.Google Scholar
- Miroslaw Truszczynski. 2012. Connecting first-order ASP and the logic FO (ID) through reducts. Correct Reasoning: Essays on Logic-Based AI in Honour of Vladimir Lifschitz (2012), 543–559.Google Scholar
- Philip Wadler. 1985. How to replace failure by a list of successes a method for exception handling, backtracking, and pattern matching in lazy functional languages. In Functional Programming Languages and Computer Architecture, Jean-Pierre Jouannaud (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 113–128.Google ScholarDigital Library
Index Terms
- stableKanren: Integrating Stable Model Semantics with miniKanren
Recommendations
miniKanren, live and untagged: quine generation via relational interpreters (programming pearl)
Scheme '12: Proceedings of the 2012 Annual Workshop on Scheme and Functional ProgrammingWe present relational interpreters for several subsets of Scheme, written in the pure logic programming language miniKanren. We demonstrate these interpreters running "backwards"---that is, generating programs that evaluate to a specified value---and ...
Epistemic foundation of stable model semantics
Stable model semantics has become a very popular approach for the management of negation in logic programming. This approach relies mainly on the closed world assumption to complete the available knowledge and its formulation has its basis in the so-...
Interdefinability of defeasible logic and logic programming under the well-founded semantics
We provide a method of translating theories of Nute's defeasible logic into logic programs, and a corresponding translation in the opposite direction. Under certain natural restrictions, the conclusions of defeasible theories under the ambiguity ...
Comments