Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement fully-declarative Horn logic? [closed]

I would like to formalize some knowledge and execute queries in what may referred to as fully-declarative Horn logic (or, fully-declarative Prolog). Could anyone provide some guidelines on how to implement it? I briefly recap the fine description from the link above:

The formal language is that of (the core of) Prolog: a "program" is a set of rules and facts as in Prolog (including functions and variables and basically, containing only user defined predicates).

In contrast to Prolog, however, I am looking for an implementation that is sound and complete with respect to the standard declarative semantics of logic programs --- the least Herbrand model (i.e., the inductively defined set of ground terms). In theoretical work on logic programming this is usually the object of study, and it is well known that a sound and complete answer to queries can be attained (in the "recursively-enumerable" sense), for example, using SLD-resolution subject to the following conditions:

  • fair search for matching rules (e.g., Prolog's depth-first search is not fair);
  • unification with "occurs-check" (checking that a variable doesn't occur in a term with which it is unified).

I am looking for a concise implementation that would build on existing capabilities, rather than inventing the wheel. Two of the more promising directions that I see are implementing it as a meta-interpreter of Prolog, or as part of some theorem prover. Could anyone with practical knowledge in these domains provide some guideline on how to implement it? Can it be easily implemented in miniKanren?


My intentions are to formalize some knowledge in a fully-declarative manner. The crucial characteristics of such a formalization is that it precisely corresponds to the mathematical notion of (monotone) induction, so that the knowledge and it's properties can be easily reasoned about with inductive arguments.

like image 826
amka66 Avatar asked Jul 28 '15 11:07

amka66


2 Answers

It is an easy exercise to implement a prover for Horn logic in a few lines of Prolog. Start with the Vanilla Meta-interpreter, then modify it to use the standard unify_with_occurs_check/2 predicate for all unifications, and to use a complete search procedure - iterative deepening depth first search is the simplest to implement.

See @mat's page A Couple of Meta-interpreters in Prolog for some inspiration.

like image 145
Michael Ben Yosef Avatar answered Sep 27 '22 18:09

Michael Ben Yosef


More pointers:

  • Datalog has declarative semantics, but as a "Prolog without function symbols" it is not Prolog. See the excellent intro "What You Always Wanted to Know About Datalog (And Never Dared to Ask)" by Ceri, Gottlob and Tanca, 1989. Available via CiteSeerX

  • Implementations of Prolog that use tabling instead of depth-first search for added declarativeness (plus other nice features as I understand), like XSB.

like image 27
David Tonhofer Avatar answered Sep 27 '22 17:09

David Tonhofer