Integrating Answer Set Programming and Constraint Logic Programming
Total Page:16
File Type:pdf, Size:1020Kb
Integrating Answer Set Programming and Constraint Logic Programming Veena S. Mellarkod and Michael Gelfond and Yuanlin Zhang {veena.s.mellarkod,mgelfond,yzhang}@cs.ttu.edu Texas Tech University Dedicated to Victor Marek on his 65th birthday as a specification for the sets of beliefs to be held by a ra- tional reasoner associated with Π. Such sets, called an- Abstract swer sets of Π, are represented by collections of ground literals. A rule (1) is viewed as a constraint which says We introduce a knowledge representation language that if literals lk+1, . , ln belong to an answer set A of AC(C) extending the syntax and semantics of ASP Π and none of the literals ln+1, . , lm belong to A then and CR-Prolog, give some examples of its use, and A must contain at least one of the literals l , . , l . To present an algorithm, ACsolver, for computing answer 1 k sets of AC(C) programs. The algorithm does not re- form answer sets of Π, the reasoner must satisfy Π’s quire full grounding of a program and combines “clas- rules together with the rationality principle which says: sical” ASP solving methods with constraint logic pro- “Believe nothing you are not forced to believe”. gramming techniques and CR-Prolog based abduction. The AC(C) based approach often allows to solve prob- Given a computational problem P , an ASP programmer lems which are impossible to solve by more traditional • Expresses information relevant to the problem in the ASP solving techniques. We belief that further inves- language of ASP; tigation of the language and development of more effi- cient and reliable solvers for its programs can help to • Reduces P to a query Q requesting computation of substantially expand the domain of applicability of the (parts of) answer sets of Π. answer set programming paradigm. • Uses inference engine, i.e., a collection of reasoning algorithms, to solve Q. 1 Introduction There is a number of inference engines available to an ASP programmer. If the corresponding program The work presented in this paper is aimed at further de- does not contain disjunction, classical negation or rules velopment of declarative programming paradigm based with empty heads and is acyclic (Apt & Bezem 1991), on Answer Set Prolog (ASP) (Gelfond & Lifschitz 1991; i.e., only allows naturally terminating recursion, then Baral 2003) and its extensions. The language has roots the classical SLDNF-resolution of Prolog (Clark 1978) in research on non-monotonic logic and semantics of de- and its variants (Chen, Swift, & Warren 1995) or fault negation of Prolog (for more details, see (Marek & fix-point computations of deductive databases (possi- Truszczynski 1993)). An ASP program Π is a collection bly augmented by constraint solving algorithms as in of rules of the form (Van Hentenryck 1989; Jaffar et al. 1992; Marriott l or ... or l ← l , . , l , not l ,..., not l (1) & Stuckey 1998)) can be used to answer the query 1 k k+1 n n+1 m Q. Presently, there are multiple applications of solv- where l’s are literals (statements of the form p(t) and ing various computational problems using these meth- ¬p(t)) over some signature Σ. Expression on the left ods. In the last decade we have witnessed the com- hand side of ← is called the head of the rule; that on ing of age of inference engines aimed at computing the the right hand side is called the rule’s body. Note that answer sets of Answer Set Prolog programs (Niemela both the body and the head of the rule can be empty. & Simons 1997; Niemela, Simons, & Soininen 2002; If the body of a rule is empty then the ← is omitted Leone et al. 2006; Eiter et al. 1997; Gebser et al. 2007; and the rule is referred to as a fact. Connectives or and Giunchiglia, Lierler, & Maratea 2006). These engines not are referred to as epistemic disjunction and default are often referred to as answer set solvers. Normally negation respectively; ¬ is often referred to as classical they start their work with grounding the program, i.e., or strong negation. An ASP program Π can be viewed instantiating its variables by ground terms. The re- sulting program has the same answer sets as the origi- Copyright c 2007, V. Mellarkod, M. Gelfond and Y. Zhang. nal one but is essentially propositional. The grounding All rights reserved. techniques employed by answer set solvers are rather sophisticated. Among other things they utilize algo- plications was related to insufficient expressive power rithms from deductive databases, and require a good of the language. For instance, in a typical diagnos- understanding of the relationship between various se- tic task one often needs to explain unusual behav- mantics of logic programming. The answer sets of ior of a system manifested by the inconsistency of an the grounded program are often computed using sub- ASP program encoding its normal behavior. This re- stantially modified and expanded satisfiability checking quires the ability to naturally mix the computation of algorithms. Another approach reduces the computa- answer sets of a program with some form of abduc- tion of answer sets to (possibly multiple) calls to ex- tive reasoning. We were not able to find a way to isting satisfiability solvers (Babovich & Maratea 2004; utilize the existing abductive logic programming sys- Giunchiglia, Lierler, & Maratea 2006; Lin & Zhao tems for such tasks, and opted for an introduction of a 2004). new language, CR-Prolog (Balduccini & Gelfond 2003; Balduccini 2007), which is capable of expressing rare The programming methodology based on the use of events which are ignored during a normal computation ASP solvers was originally advocated in (Marek & and only used if needed to restore consistency of the Truszczynski 1999; Niemela 1999). It proved to be use- program. Consider, for instance, a program Π0 consist- ful for finding solutions to a variety of programming ing of regular ASP rules tasks, ranging from building decision support systems for the Space Shuttle (Balduccini, Gelfond, & Nogueira ¬p ← not p 2006) and program configuration (Soininen & Niemella q ← ¬p 1998), to solving problems arising in bio-informatics (Baral et al. 2004), zoology and linguistics (Brooks et which say that p is normally believed to be false, and al. 2005). Though positive, this experience allowed to that if p is believed to be false then q must be believed to identify a number of problems and inadequacies of the be true. The program has a unique answer set {¬p, q}. ASP approach to declarative programming. Now let us expand Π0 by a consistency restoring rule (CR-rule) First it became clear that for a number of tasks which require the use of ASP solvers these solvers are not p ← + sufficiently efficient. This becomes immediately ob- vious if the program contains variables ranging over large domains. Even though ASP solvers use intel- which says that p is possible but so rare that it can be ligent grounding optimization techniques, ground in- ignored during the reasoning process unless it is needed stantiations of such a program can still be huge, which for restoring consistency. The resulting program Π1 can cause both memory and time problems and make still has one answer set {¬p, q}. The CR-rule above ASP solvers practically useless. The problem was par- remains unused. The situation changes if we expand tially addressed in (Baselice, Bonatti, & Gelfond 2005; Π1 by a new fact Mellarkod & Gelfond 2007) where the language of ASP and its reasoning mechanism were extended to partially ¬q avoid grounding of variables ranging over the large do- mains and to replace such grounding with the use of Since regular rules of the new program Π2 are inconsis- constraint solving techniques. In (Mellarkod & Gelfond tent, the reasoner associated with the program is forced 2007) an algorithm was implemented for a language al- to use the CR-rule. The resulting answer set is {p, ¬q}. lowing so called difference constraints which substan- tially expanded the scope of applicability of the ASP The expressive power and reasoning ability of CR- paradigm. In this paper we further expand this work Prolog proved to be useful in many situations beyond by designing a more powerful extension AC(C) of ASP diagnostic reasoning. CR-Prolog was also successfully and define an algorithm, ACsolver, for computing an- used in planning to produce higher quality plans than swer sets of programs in the new language. The algo- regular ASP (Balduccini 2004), for reasoning about in- rithm combines “classical” ASP solving methods with tentions, reasoning with weak constraints a la DLV, etc. constraint satisfaction techniques and SLDNF resolu- So we expand AC(C) by CR-rules and show an example tion. The prototype implementations of the solver were of their use adding CR-Prolog abduction to the plethora tested on a number of examples including planning and of reasoning techniques discussed above. scheduling tasks related to the space shuttle. The re- sults are mostly positive and, since the prototype imple- 2 Syntax and Semantics of AC(C) mentation allows many natural improvements, we have no doubt that a fully adequate solution will be produced 2.1 Answer Set Prolog soon. (It is worth noting that standard ASP methods Recall that terms, literals, and rules of program Π with are fully inadequate for this task). signature Σ(Π) are called ground if they contain no variables and no symbols for arithmetic functions. A The second difficulty of using ASP for a number of ap- program is called ground if all its rules are ground. In this section we briefly review the semantics of ground variable, X, takes on values from a unique sort de- programs of Answer Set Prolog.