An Experimental Comparison of Constraint Logic Programming and Answer Set Programming Agostino Dovier Andrea Formisano Enrico Pontelli Universita` di Udine, Universita` di Perugia New Mexico State University Dip. di Matematica e Informatica Dip. di Matematica e Informatica Dept. of Computer Science [email protected] [email protected] [email protected] Abstract are encoded as atomic formulae and relationships as pro- gram rules. It is well-known (Marek & Truszczynski 1991; Answer Set Programming (ASP) and Constraint Logic Baral 2003) that, given a propositional normal logic pro- Programming over finite domains (CLP(FD)) are two gram P , deciding whether P admits an answer set (Gel- declarative programming paradigms that have been ex- fond & Lifschitz 1988) is a NP-complete problem. As a tensively used to encode applications involving search, optimization, and reasoning (e.g., commonsense rea- consequence, any NP-complete problem can be encoded soning and planning). This paper presents experimen- as a propositional normal logic program under answer set tal comparisons between the declarative encodings of semantics. Answer-set solvers are programs designed to various computationally hard problems in both frame- compute the answer sets of normal logic programs. Some works. The objective is to investigate how the solvers solvers provide also syntactic extensions to facilitate pro- in the two domains respond to different problems, high- gram development—e.g., limited forms of aggregation (Si- lighting strengths and weaknesses of their implementa- mons 2000)—and classes of optimization statements, used tions, and suggesting criteria for choosing one approach to select answer sets that maximize or minimize an objec- over the other. Ultimately, the work in this paper is ex- tive function dependent on the content of the answer set. pected to lay the foundations for transfer of technology between the two domains, e.g., suggesting ways to use 1 An alternative framework, frequently adopted to handle CLP(FD) in the execution of ASP. NP-complete, combinatorial, and optimization problems, is CLP(FD) (Jaffar & Maher 1994; Marriott & Stuckey 1998). In this context, a finite domain of objects (typically integers) Introduction is associated to each variable in the problem specification, The objective of this work is to experimentally compare and the problem-derived relationships between such vari- the use of two distinct logic-based paradigms, tradition- ables are encoded as constraints (e.g., s = t, s<t). This ally recognized as excellent tools to tackle computation- type of framework supports the natural and declarative en- ally hard problems and to encode AI applications (such as coding of search strategies and NP-complete problems. In- planning, scheduling, and optimization problems). The two deed, a rich literature has been developed presenting appli- paradigms considered are Answer Set Programming (ASP) cations of CLP(FD) to a variety of search and optimization (Baral 2003) and Constraint Logic Programming over Finite problems (Marriott & Stuckey 1998), and several efficient Domains (CLP(FD)) (Marriott & Stuckey 1998). The moti- implementations have been developed. vation for this investigation, originally described in (Dovier, Formisano, & Pontelli 2005), arises from the successful use In this paper, we summarize the outcome of a study aimed of both paradigms in dealing with various classes of com- at comparing these two declarative approaches in solving binatorial problems, and the need to better understand their combinatorial problems. The study has been originally pre- respective strengths and weaknesses. Ultimately, we hope sented in (Dovier, Formisano, & Pontelli 2005). We ad- this work will indicate methods for integration and coopera- dress a set of computationally hard problems—in particu- tion between the two paradigms. lar, we mainly consider decision problems known to be NP- complete. We formalize each problem, both in CLP(FD) ASP is a paradigm deriving from logic programming and in ASP, by taking advantage of the specific features under answer set semantics, where problem components available in each logical framework, and attempting to en- code the various problems in the most declarative way possi- Copyright c 2007, Association for the Advancement of Artificial ble. In particular, we adopt a constraint-and-generate strat- Intelligence (www.aaai.org). All rights reserved. 1This study has been originally presented in ICLP 2005 egy (Marriott & Stuckey 1998) for the construction of the (Dovier, Formisano, & Pontelli 2005). This research is par- CLP(FD) programs, while in ASP we exploit the natural tially supported by MIUR projects PRIN05-015491 and FIRB03- generate-and-test approach (Baral 2003). Whenever possi- RBNE03B8KK, and by NSF grants CNS-0220590, CNS-0454066, ble, we make use of encodings of these problems that have and HRD-0420407. been presented and widely accepted in the literature. 1622 Overview of the Computational Models V is a denumerable collection of variables, and Π is a finite Constraint Logic Programming is a programming paradigm set of predicate symbols. The set of terms is F∪V, and an that is particularly well suited for encoding combinatorial atom is a formula of the type p(t1,...,tk), where p ∈ Π and optimization problems. CLP naturally merges two declar- t1,...,tk are terms. An ASP program is a finite collection ative paradigms: constraint satisfaction and logic program- of rules, where rules are of the form ming. Let Σ be a logic language signature Σ=F, V, Π ∪ h :− a1,...,am,notb1,...,notbn h, a ,...,a ,b ,...,b ΠC , where F is a finite set of function and constant sym- where 1 m 1 n are atoms. Each program is bols, V is a denumerable collection of variables, and Π∪ΠC viewed as a syntactic sugar representing the set of ground F is a finite set of predicate symbols (with Π and ΠC dis- instances of its rules (computed using the constants in ). joint). A constraint is a first-order formula over F, V, ΠC . A special type of rules are the so called constraints—rules Typically, constraints are conjunctions of literals, e.g., 0 < with an empty head; in this case, the head of the rule is im- X, X < 3,X + Y =4. Following the traditional logic pro- plicitly assumed to be false. gramming notation, a comma indicates a conjunction, capi- Given a ground program P , the answer set semantics tal letters denote variables, and the symbol :− denotes the characterizes the semantics of P in terms of a collection implication ←. CLP lets a programmer use different classes of minimal models (called answer sets). A set of ground atoms M is an answer set if M is the unique minimal model of constraints and domains to encode problems. For com- M binatorial problems, it is common to use finite domain con- of the program P , containing the rules h :− a1,...,ak straints, namely arithmetic constraints between arithmetic such that h :− a1,...,ak,notb1,...,notbh is in P and expressions, where each variable is associated to a finite do- {b1,...,bh}∩M = ∅. In ASP, each problem is mod- main of possible values. In this case the interpretation of eled as a collection of rules, in such a way that the solu- variables, expressions, and constraints is over Z. tions to the problem correspond one-to-one to the answer A CLP program over Σ is a finite set of rules of the form sets of the program. An ASP Solver is a program that com- 1 1 m m putes all the answer sets of a given ASP program. A solver p(s1,...,sn):− C, q1(t ,...,t ),...,qm(t ,...,t ) 1 n1 1 nm can be seen as a theorem prover, or model builder, enhanced i with several built-in heuristics to guide the exploration of where C is a constraint, si and t are (F, V)-terms, and j the search space. Most ASP solvers rely on variations of p, q1,...,qm are predicate symbols of Π. Observe that a CLP program without constraints is a Prolog program. the DPLL procedure (Davis, Logemann, & Loveland 1962). CLP programs are commonly developed using a Such solvers are often equipped with a front-end that trans- constrain-and-generate technique, where an initial deter- forms a collection of non-propositional normal logic pro- ministic phase imposes a number of constraints, and a non- gramming clauses (with limited use of function symbols) to finite deterministic phase generates/explores the solution space. In a set of ground instances of such clauses. the constraint phase, in particular, a finite domain of val- ues is assigned to each variable. For instance, the constraint The Experimental Framework domain([A,B,C],1,5) assigns the set of admissible val- The experimental studies, originally reported in (Dovier, ues {1,2,3,4,5} to the variables A, B, and C. The built-in Formisano, & Pontelli 2005), have been conducted us- predicate labeling implements the non-deterministic gen- ing both CLP(FD) implementations and ASP solvers. erate phase through some form of search space exploration. The CLP(FD) programs have been designed for SICStus Each time a variable is assigned a value, a deterministic Prolog—and adapted to run also on GNU-Prolog, B-Prolog, propagation stage is executed, removing from the domains and ECLiPSe. The ASP programs have been designed to of the other variables those values that are incompatible with be processed by lparse, the grounding preprocessor used the assignments already performed. Various options, affect- by both the SMODELS and the CMODELS systems. The ing, for instance, the variable selection criteria, the ordering CMODELS system makes use of a SAT solver to compute of the attempted values, etc., can be used to guide the search. answer sets—in our experiments we mainly used mChaff The main structure of a program using this programming (Moskewicz et al. 2001) and Simo (Giunchiglia, Lierler, style is the following: & Maratea 2006).
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages4 Page
-
File Size-