Proceedings of the Twenty-Fifth International Joint Conference on Artificial Intelligence (IJCAI-16)

Constraint Answer Set Programming versus Satisfiability Modulo Theories ⇤

Yuliya Lierler and Benjamin Susman University of Nebraska at Omaha [email protected] and [email protected]

Abstract logic programs with constraints versus logic programs mod- ulo theories become apparent. At the same time, we intro- Constraint answer set programming is a promising duce the notion of constraint formulas, which are similar to research direction that integrates answer set pro- that of logic programs with constraints. We identify a spe- gramming with constraint processing. It is often in- cial class of SMT theories that we call “uniform”. Commonly formally related to the field of Satisfiability Modulo used theories in satisfiability modulo solving such as integer Theories. Yet, the exact formal link is obscured as linear, difference logic, and linear arithmetics belong to uni- the terminology and concepts used in these two re- form theories. This class of theories helps us to establish pre- search areas differ. In this paper, we make the link cise links (i) between constraint formulas and SMT formulas, between these two areas precise. and (ii) between CASP and SMT. We are able to then provide a formal description relating a family of distinct constraint Introduction answer set programming formalisms. Constraint answer set programming (CASP) [Mellarkod et We believe that this unified outlook allows us not only to al., 2008; Gebser et al., 2009; Balduccini, 2009; Lierler, better understand the landscape of CASP languages and sys- 2014] is a promising research direction that integrates answer tems, but also to foster new ideas for CASP solvers design set programming (ASP), a powerful knowledge representa- as well as SMT solvers design. For example, theoretical re- tion paradigm, with constraint processing. Typical answer set sults of this work establish the method for using SMT sys- programing tools start their computation with grounding, a tems for computing answer sets of a broad class of “tight” process that substitutes variables for passing constants in re- constraint answer set programs. Similarly, CASP technology spective domains. Thus large domains often form an obsta- can be used to solve certain classes of SMT problems. cle for classical ASP. CASP enables a mechanism to model The outline of the paper is as follows. We start by review- constraints over large domains so that they are processed in ing concepts of logic programs, completion, and (input) an- a non-typical way for ASP tools by delegating their solving swer sets. We then present (i) generalized constraint satisfac- to constraint solver systems specifically designed to handle tion problems, (ii) constraint answer set programs, and (iii) large and sometimes infinite-domains. CASP solvers includ- constraint formulas. Next we introduce satisfiability modulo ing CLINGCON [Gebser et al., 2009] and EZCSP [Balduccini, theories and respective SMT formulas. We define a class of 2009] already put CASP on the map of efficient automated uniform theories and establish links between CASP and SMT. reasoning tools. The paper concludes by relating a family of distinct constraint Constraint answer set programming often cites itself as answer set programming formalisms. a related initiative to Satisfiability Modulo Theories (SMT) solving [Barrett and Tinelli, 2014]. Yet, the exact link is ob- Logic Programs, Completion, and Input scured as the terminology and concepts used in both fields differ. To add to the complexity of the picture several answer Answer Sets set programming modulo theories formalisms have been pro- A vocabulary is a set of propositional symbols also called posed. For instance, Liu et.al. [2012], Janhunen et.al [2011], atoms. As customary, a literal is an atom a or its negation, and Lee and Meng [2013] introduced logic programs mod- denoted a.A(propositional) logic program, denoted by ⇧, ulo linear constraints, logic programs modulo difference con- over vocabulary¬ is a set of rules of the form straints, and ASPMT programs respectively. In this work we attempt to unify the terminology used in a b1,...,b`,notb`+1,..., notbm, (1) CASP and SMT so that the differences and similarities of where a is an atom over or , and each bi, 1 i m, is ⇤We would like to thank Martin Brain for the discussions that ?   lead us to undertake this research. We are also grateful to Vladimir an atom in . We will sometime use the abbreviated form for Lifschitz, Cesare Tinelli, and Mirek Truszczynski for the conversa- a rule (1) tions related to the topic of this paper. a B (2)

1181 where B stands for b1,...,b`,notb`+1,..., notbm, and is set of ⇧ relative to ◆ if and only if X satisfies program’s input- also called a body. We sometimes identify B with the propo- completion IComp(⇧,◆). sitional formula b1 ... b` b`+1 ... bm and note that the order of its terms^ is^ immaterial.^¬ ^ The^ expression¬ a is the Constraint Answer Set Programs head of the rule. When a is , we often omit it and say that ? We start this section by presenting primitive constraints as de- the head is empty. We write hd(⇧) for the set of nonempty fined by Marriott and Stuckey [1998, Section 1.1] using the heads of rules in ⇧. We refer the reader to the paper by Gel- notation convenient for our purposes. We refer to this con- fond and Lifschitz [1988] for details on the definition of an cept as a constraint dropping the word “primitive”. We use answer set. constraints to define a notion of a generalized constraint sat- We call a rule whose body is empty a fact. In such cases, isfaction problem that Marriott and Stuckey refer to as “con- we drop the arrow. We sometimes may identify a set X of straint”. We then review constraint satisfaction problems as atoms with a set of facts a. a X . Also, it is customary { | 2 } commonly defined in artificial intelligence literature and il- for a given vocabulary , to identify a set X of atoms over lustrate that they are special case of generalized constraint with (i) a complete and consistent set of literals over con- satisfaction problems. structed as X a a X , and respectively with (ii) an assignment function[{¬ | or2 interpretation\ } that assigns truth value Constraints and Generalized Constraint Satisfaction true to every atom in X and false to every atom in X. Problem We adopt the following convention: for a func- ⌫ ⇧ \ tion ⌫ and an element x, by x we denote the value that func- For a program over vocabulary , the completion ⌫ of ⇧ [Clark, 1978], denoted by Comp(⇧), is the set of clas- tion ⌫ maps x to (in other words, x = ⌫(x)). A domain is sical formulas that consists of the implications B a for all a nonempty set of elements (values). A signature ⌃ is a set rules (2) in ⇧ and the implications ! of variables, function symbols (or f-symbols), and predicate symbols. Function and predicate symbols are associated with a B (3) a positive integer called arity. By ⌃ v, ⌃ r, and ⌃ f we de- ! | | | a B ⇧ note the subsets of ⌃ that contain all variables, all predicate _2 symbols, and all f-symbols respectively. for all atoms a in . For instance, we can define signature ⌃1 = s, r, E, Q by It is well known that for the large class of logic programs, saying that s and r are variables, E is a predicate{ symbol} of referred to as “tight” programs, its answer sets coincide with arity 1, and Q is a predicate symbol of arity 2. Then, ⌃1 v = models of its completion, as shown by Fages [1994]. Tight- | s, r , ⌃1 r = E,Q , ⌃1 f = . ness is a syntactic condition on a program that can be verified { Let} D be| a{ domain.} For| a set; V of variables, we call a by means of program’s dependency graph. The dependency function ⌫ : V D a [V,D] valuation. For a set F of f- graph of ⇧ is the directed graph G such that (i) the vertices symbols, we call! a total function on F an [F, D] f-denotation, of G are the atoms occurring in ⇧, and (ii) for every rule (1) when it maps an n-ary f-symbol into a function Dn D. For in ⇧ whose head is not , G has an edge from atom a to each ! ? a set R of predicate symbols, we call a total function on R an atom b1,...,b`. A program is called tight if its dependency [R, D] r-denotation, when it maps an n-ary predicate symbol graph is acyclic. into an n-ary relation on D. We now introduce a generalization of a concept of an in- A table below presents definitions of sample domain D1, [ ] put answer set by Lierler and Truszczynski 2011 . In this valuations ⌫1, ⌫2, and r-denotations ⇢1 and ⇢2. work, we consider input answer sets relative to input vocab- D1 1, 2, 3 ularies. We then extend the definition of completion so that { } ⌫1 ⌫1 ⌫1 [⌃1 v,D1] valuation, where s = r =1 we can state the result by Fages for the case of input answer | ⌫2 ⌫2 ⌫2 [⌃1 v,D1] valuation, where s =2and r =1 sets. These concepts are essential for introducing constraint | answer set programs and constraint formulas as they are de- ⇢1 [⌃1 r,D1] r-denotation, where E| ⇢1 = 1 ,Q⇢1 = 1, 1 , 2, 2 , 3, 3 fined over two disjoint vocabularies so that atoms stemming {h i} {h i h i h i} from those vocabularies “behave” differently. Input answer ⇢2 [⌃1 r,D1] r-denotation, where E| ⇢2 = 2 , 3 , Q⇢2 = Q⇢1 . set semantics allows us to account for these differences. {h i h i} A constraint vocabulary (c-vocabulary) is a pair [⌃,D], Definition 1 For a logic program ⇧ over vocabulary ,a ⌃ D set X of atoms over is an input answer set of ⇧ relative where is a signature and is a domain. A term over a c-vocabulary [⌃,D] is either a variable in ⌃ v, a domain el- to vocabulary ◆ when X is an answer set of the program | ⇧ ((X ◆) hd✓ (⇧)). ement in D, or an expression f(t1,...,tn), where f is an f- [ \ \ symbol of arity n in ⌃ f and t1,...,tn are terms over [⌃,D] Definition 2 For a program ⇧ over vocabulary , the input- A constraint atom over| a c-vocabulary [⌃,D] is an expres- completion of ⇧ relative to vocabulary ◆ , denoted by ✓ sion IComp(⇧,◆), is defined as the set of propositional formulas P (t1,...,tn), (4) (formulas in propositional logic) that consists of the implica- where P is a predicate symbol from ⌃ r of arity n and tions B a for all rules (2) in ⇧ and the implications (3) | t ,...,t are terms over [⌃,D].Aconstraint literal over a for all atoms! a occurring in ( ◆) hd(⇧). 1 n \ [ c-vocabulary [⌃,D] is either a constraint atom (4) or an ex- Theorem 1 For a tight program ⇧ over vocabulary and pression vocabulary ◆ , a set X of atoms from is an input answer P (t ,...,t ), (5) ✓ ¬ 1 n

1182 where P (t1,...,tn) is a constraint atom over [⌃,D]. For in- From GCSP to Constraint Satisfaction Problem We say stance, expressions E(s), E(2), and Q(r, s) are constraint that a lexicon is finite-domain if it is defined over a c- ¬ ¬ literals over [⌃1,D1]. vocabulary that refers to a domain whose set of elements is Let [⌃,D] be a c-vocabulary, ⌫ be a [⌃ v,D] valuation, finite. Trivially, lexicons 1 and 2 are finite-domain. Con- | L L be a [⌃ f ,D] f-denotation, and ⇢ be a [⌃ r,D] r-denotation. sider a special case of a constraint of the form (4) over finite- | | ⌫ domain lexicon =([⌃,D],⇢) so that each ti is a variable. First, we define recursively a value that valuation assigns to L a term ⌧ over [⌃,D] w.r.t. . We denote this value by ⌧ ⌫,. For (For instance, constraints c1, c2, and c3 satisfy the stated re- ⌫, ⌫ a term that is a variable x in ⌃ v, x = x . For a term that quirements, while c4 does not.) In this case, we can syntacti- | is a domain element d in D, d⌫, is d itself. For a term ⌧ of cally identify (4) with the pair ⌫, ⇢ the form f(t1,...,tn), ⌧ is defined recursively by the for- (t1,...,tn),P . (6) ⌫, ⌫, ⌫, h i mula f(t1,...,tn) = f (t1 ,...,tn ). Second, we de- A constraint satisfaction problem (CSP) is a set of pairs (6), fine what it means for valuation to be a solution of a constraint where ⌃ v and D of the finite-domain lexicon are called literal w.r.t. given f- and r-denotations. We say that ⌫ satis- variables| and domain of CSP, respectively. SayingL that val- fies (is a solution to) constraint literal (4) over [⌃,D] w.r.t. uation ⌫ over satisfies (4) is the same as saying that and ⇢ when t⌫,,...,t⌫, P ⇢. Let be an n-ary relation t⌫ ,...,t⌫ LP ⇢. The latter is the way in which a solu- h 1 n i2 R h 1 ni2 on D. By we denote complement relation of constructed tion to expressions (6) in CSP is typically defined. As in the as Dn .R Valuation ⌫ satisfies (is a solution to)Rconstraint lit- definition of semantics of GCSP, a valuation is a solution to a \R eral of the form (5) w.r.t. and ⇢ when t⌫,,...,t⌫, P ⇢. CSP problem C when it is a solution to every pair (6) in C. h 1 n i2 In conclusion, GCSP generalizes CSP by (i) elevating the re- For instance, valuation ⌫1 satisfies constraint literal Q(r, s) striction of finite-domain, and (ii) allowing us more elaborate w.r.t. ⇢1, while valuation ⌫2 does not satisfy this constraint syntactic expressions (e.g., recall f-symbols). literal w.r.t. ⇢2 (when a signature contains no function sym- bols no reference to f-denotation is necessary in the defini- Constraint Answer Set Programs and Constraint Formu- tions above). las Let r and i be two disjoint vocabularies. We refer to We are now ready to define constraints, their syntax and their elements as regular and irregular atoms respectively. semantics. To begin we introduce a lexicon, which is a tuple For a program ⇧, by At(⇧) we denote the set of atoms occur- ([⌃,D],⇢,), where [⌃,D] is a c-vocabulary, ⇢ is [⌃ r,D] ring in it. Similarly, for a propositional formula F , by At(F ) | r-denotation, and is [⌃ f ,D] f-denotation. For a lexicon we denote the set of its atoms. | =([⌃,D],⇢,), we call any function that is [⌃ v,D] valu- Definition 4 A constraint answer set program (CAS program) ation,L a valuation over . We will omit the last element| of the L over the vocabulary = r i is a triple ⇧, , , tuple if the signature ⌃ of the lexicon contains no f-symbols. where ⇧ is a logic program over[ the vocabulary hsuchB thati A constraint is defined over lexicon =([⌃,D],⇢,). Syn- hd(⇧) = , is a set of constraints over the same lexi- L \ i ; B tactically, it is a constraint literal over [⌃,D] (lexicon , re- con, and is an injective function from the set i of irregular spectively). Semantically, we say that valuation ⌫ over L sat- L atoms to the set of constraints. isfies (is a solution to) the constraint c when ⌫ satisfies c w.r.t. For a CAS programB P = ⇧, , over the vocabulary h B i and ⇢. For instance, the table below presents definitions of = r i so that is the lexicon of the constraints in ,a sample lexicons 1, 2, and constraints c1, c2, c3, and c4. set X [ is an answerL set of P if B L L ✓ X At(⇧) 1 ([⌃1,D1],⇢1) L • X is✓ an input answer set of ⇧ relative to , and 2 ([⌃1,D1],⇢2) • i cL a literal Q(r, s) over lexicon the following GCSP over has a solution 1 L1 • L c2 a literal Q(r, s) over lexicon 2 (a) a X i (a) a (At(⇧) i) X . c a literal E(s) over lexicon L { | 2 \ }[{¬ | 2 \ \ } 3 ¬ L2 Note that (a) may result in expression of the form c4 a literal E(2) over lexicon 2. ¬ ¬ L P (t1,...,tn) that we identify with P (t1,...,tn). (We use ¬¬ Valuation ⌫1 is a solution to c1, c2, c3, but not a solution to c4. this convention across the paper.) Valuation ⌫2 is not a solution to c1, c2, c3, and c4. In fact, These definitions are generalizations of CAS programs in- constraint c4 has no solutions. We sometimes omit the explicit troduced by Gebser et al. [2009] as they refer to the concept mention of the lexicon when talking about constraints: we of GCSP in place of CSP in the original definition. then may identify a constraint with its syntactic form of a Just as we defined constraint answer set programs, we can constraint literal. define constraint formulas. Definition 3 A generalized constraint satisfaction prob- Definition 5 A constraint formula over the vocabulary = lem (GCSP) is a finite set of constraints over a lexicon r i is a triple F, , , where F is a propositional for- C mula[ over the vocabularyh B i, is a set of constraints over the =([⌃,D],⇢,). We say that a valuation ⌫ over satis- B fiesL (is a solution to) GCSP when ⌫ is a solution toL every same lexicon, and is an injective function from the set i of constraint in . C irregular atoms to the set of constraints. C For a constraint formulaB = F, , over the vocabu- F h B i For example, any subset of set c2,c3,c4 of constraints lary = r i so that is the lexicon of the constraints in forms a GCSP. { } , a set X [ is a modelLof if B ✓ F

1183 X At(F ) SMT and ASPT Programs We now introduce SMT for- • X is✓ a model of F , and mulas that merge the concepts of propositional formulas and • the following GCSP over has a solution ⌃-theories. Then, we present ASPT programs that merge the • L concepts of logic programs and ⌃-theories. (a) a X i (a) a (At(F ) i) X . { | 2 \ }[{¬ | 2 \ \ } Definition 6 An SMT formula P over vocabulary Following theorem captures a relation between CAS pro- = r i is a triple F, T, µ , where F is a proposi- grams and constraint formulas. tional formula[ over , T ish a ⌃-theory,i and µ is an injective Theorem 2 For a CAS program P = ⇧, , over the vo- function from irregular atoms i to constraint literals over h B i c-vocabulary [⌃, ]. cabulary = r i and a set X of atoms over , when ⇧ ; is tight, X is an answer[ set of P if and only if X is a model of For an SMT formula F, T, µ over , a set X is its h i ✓ constraint formula IComp(⇧, ), , over = . model if h i B i r [ i X At(F ), Satisfiability Modulo Theories versus • X is✓ a model of F , and • the following restriction formula Constraint Formulas • First, in this section we introduce the notion of a “theory” µ(a) a X i µ(a) a (At(F ) i) X . in Satisfiability Modulo Theories (SMT) [Barrett and Tinelli, { | 2 \ }[{¬ | 2 \ \ } 2014]. Second, we present the definition of a “restriction for- is satisfiable in ⌃-theory T . mula” and state the conditions under which such formulas are In the literature on SMT, a more sophisticated syntax than satisfied by a given interpretation. These formulas are syn- SMT formulas provide is typically discussed. Yet, SMT tactically restricted classical ground predicate logic formu- solvers often rely on the so called propositional abstractions las. The presented notions of interpretation and satisfaction of predicate logic formulas [Barrett and Tinelli, 2014, Section are usual, but are stated in terms convenient for our purposes. 1.1], which, in their most commonly used case, coincide with This facilitates uncovering the precise link between CASP- SMT formulas discussed here. like formalisms and SMT-like formalisms. We note that in literature on SMT, the term “object constant” or “function Definition 7 A logic program modulo theories or ASPT pro- symbol of arity 0” is commonly used to refer to elements in gram P over vocabulary = r i is a triple ⇧,T,µ , the signature that we call variables. where ⇧ is a logic program over [, T is a ⌃-theory.h and iµ An interpretation I for a signature ⌃, or ⌃-interpretation, is an injective function from irregular atoms i to constraint is a tuple (D,⌫,⇢,) where literals over c-vocabulary [⌃, ]. ; D is a domain, For an ASPT program ⇧,T,µ over , a set X is its • model if h i ✓ ⌫ is a [⌃ v,D] valuation, • | ⇢ is a [⌃ r,D] r-denotation, and X At(⇧), • | • ✓ is a [⌃ f ,D] f-denotation. X is an input answer set of ⇧ relative to i, and • | • the following restriction formula For signatures that contains no f-symbols, we omit the refer- • ence to the last element of the interpretation tuple. µ(a) a X i µ(a) a (At(⇧) i) X . For a signature ⌃,a⌃-theory is a set of interpreta- { | 2 \ }[{¬ | 2 \ \ } tions over ⌃. For instance, for signature ⌃1, by 1 and 2 is satisfiable in ⌃-theory T . I I we denote the following sample interpretations (D1,⌫1,⇢1) and (D ,⌫ ,⇢ ) respectively. Any subset of interpretations 1 2 1 Uniform Theories The presented definition of a ⌃-theory , exemplifies a unique ⌃ -theory. {I1 I2} 1 places no restrictions on the domains, r-denotations, or f- A restriction formula over signature ⌃ is a finite set of denotations being identical across the interpretations defining constraint literals over c-vocabulary [⌃, ]. Consider a ⌃- ; a theory. In practice, such restrictions are very common in interpretation I =(D,⌫,⇢,). To each term ⌧ over a c- SMT. We now define so called “uniform” theories that follow vocabulary [⌃, ], I assigns a value ⌧ ⌫, that we denote by ⌧ I . ; these typical restrictions. We will then show how restriction We say that I satisfies restriction formula over ⌃ when ⌫ formulas interpreted over uniform theories can practically be satisfies every constraint literal in w.r.t. and ⇢. For in- seen as syntactic variants of GCSPs. This connection brings stance, a sample restriction formula over ⌃1 follows us to a straightforward relation between SMT formulas over E(s), Q(r, s) . (7) uniform theories and constraint formulas as well as between {¬ ¬ } CAS programs and ASPT programs. In the following section, Interpretation 2 satisfies this formula, while 1 does not. we list several common SMT fragments such as satisfiability We say thatI a restriction formula over signatureI ⌃ is sat- modulo difference logic and satisfiability modulo linear arith- isfiable in a ⌃-theory T , or is T -satisfiable, when there is an metic whose theories are, in fact, uniform theories. We then element of the set T that satisfies . For example, restriction use these findings to relate several ASP modulo theories ap- formula (7) is satisfiable in any ⌃1-theory that contains inter- proaches such as ASP(DL) introduced in [Liu et al., 2012] pretation 2. On the other hand, restriction formula (7) is not and ASP(LC) introduced in [Liu et al., 2012] to CASP ap- satisfiableI in ⌃ -theory . proaches. 1 {I1}

1184 Definition 8 For a signature ⌃, we call a ⌃-theory T uni- interpreted using the uniform theory T over the same lexi- form over lexicon =([⌃,D],⇢,) when (i) all interpreta- con apparent: the question whether a given GCSP over tions in T are of theL form (D,⌫,⇢,) (note how valuation ⌫ is has aL solution translates into the question whether the set ofL the only not fixed element in the interpretations), and (ii) for constraint literals of GCSP forming a restriction formula is every possible [⌃ v,D] valuation ⌫, there is an interpretation T -satisfiable. Furthermore, any solution to such GCSP is also (D,⌫,⇢,) in T .| an interpretation in T that satisfies the respective restriction formula, and the other way around. We then relate SMT for- To illustrate a concept of a uniform theory, a table be- mulas “modulo uniform theories” and constraint formulas, as low defines sample domain D , valuations ⌫ and ⌫ , and 2 3 4 well as ASPT programs and CAS programs. r-denotation ⇢3. Theorem 3 For a lexicon =([⌃,D],⇢,), a set of D2 1, 2 L { } ⌫3 ⌫3 constraint literals over c-vocabulary [⌃,D], a uniform ⌃- ⌫3 [⌃1 v,D2] valuation, where s =1and r =2 | ⌫4 ⌫4 theory T over lexicon , the following holds ⌫4 [⌃1 v,D2] valuation, where s = r =2 L | ⇢ [⌃ ,D ] r-denotation, where 1. for any [⌃ v,D] valuation ⌫, there is an interpretation ⌫ 3 1 r 2 | E|⇢3 = 2 ,Q⇢3 = 1, 1 , 2, 2 in T , {h i} {h i h i} 2. [⌃ v,D] valuation ⌫ is a solution to GCSP over lex- Valuations ⌫1 and ⌫2 can be seen not only as [⌃1 v,D1] valu- icon| if and only if interpretation ⌫ in T satisfies re- | L ations but also as [⌃1 v,D2] valuations. The set striction formula . | 3. GCSP over lexicon has a solution if and only if (D2,⌫1,⇢3), (D2,⌫2,⇢3), (D2,⌫3,⇢3), (D2,⌫4,⇢3) L { } restriction formula is T -satisfiable. of ⌃1 interpretations is an example of a uniform theory over Let denote a lexicon ([⌃,D],⇢,). By we denote the lexicon ([⌃1,D2],⇢3). We denote this theory by T1. On the set ofL all constraints over . By T we denoteBL the uniform other hand, the set ⌃-theory over . L L L (D2,⌫1,⇢3), (D2,⌫2,⇢3), (D2,⌫3,⇢3), (D1,⌫4,⇢3) For a lexicon =([⌃,D],⇢,), a vocabulary { } Theorem 4 = X L X of ⌃ interpretations is an example of a non-uniform theory. r i, and a set of atoms over , set is a model of 1 [ F, T ,µ X Indeed, the condition (i) of Definition 8 does not hold for SMT formula over if and only if is a model of a constraint formulah L F,i ,µ over (where µ is identified this theory: the last interpretation refers to a different domain h BL i than the others. Also, neither of ⌃ -theories , , is with the function from irregular atoms to constraints over 1 {I1} {I1 I2} in a trivial way.) L uniform over lexicon ([⌃1,D1],⇢1). In this case, the condi- tion (ii) of Definition 8 does not hold. This theorem illustrates that for uniform theories the lan- It is easy to see that for uniform theories we can identify guage of SMT formulas and constraint formulas coincide. Or, their interpretations of the form (D,⌫,⇢,) with their sec- that the language of constraint formulas is a special case of ond element valuation ⌫. The other three elements are fixed SMT formulas that are defined over uniform theories. We now by the lexicon over which the uniform theory is defined. In show similar relation between CAS and ASPT programs. the following we will sometimes use this convention. For ex- Theorem 5 For a lexicon =([⌃,D],⇢,), a vocabulary ample, we may refer to interpretation (D2,⌫1,⇢3) of uniform L = r i, and a set X of atoms over , set X is a model of theory T1 as ⌫1. ASPT program[ ⇧,T ,µ over if and only if X is a model For uniform ⌃-theory T over lexicon ([⌃,D],⇢,) we can of a CAS formulah ⇧,L ,µi over . extend the syntax of restriction formulas by saying that a re- h BL i striction formula is defined over c-vocabulary [⌃,D] as a fi- nite set of constraint literals over [⌃,D] (earlier we consid- SMT and CASP Connection ered constraint literals over [⌃, ]). The earlier definition of This section starts by introducing numeric signatures and lex- semantics is still applicable. In the; following for the uniform icons, and particular uniform theories. These definitions al- theories we assume such a more general syntax. Similarly, we low us to precisely define the languages used by various con- can extend the definition of SMT formula given a constraint straint answer set solvers. We conclude with the discussion of ⌃-theory T over lexicon ([⌃,D],⇢,) as follows: an SMT the variety of solving techniques used in formula P over vocabulary = is a triple F, T, µ , community. r [ i h i where F is a propositional formula over , T is a ⌃-theory, Let Z and R denote the sets of integers and real num- and µ is an injective function from irregular atoms i to con- bers respectively. We say that a signature is numeric when straint literals over c-vocabulary [⌃,D]. Note how µ-mapping it satisfies the following requirements (i) its only f-symbols refers do the domain of lexicon now in place of an empty set are +, of arity 2, and (ii) its only predicate symbols are in the earlier definition. The definition of ASPT program can <, >, ⇥, , =, = of arity 2. We use the symbol to de-  6 A be extended in the same style. For the case of uniform theo- note a numeric signature. Let and ⇢ be [ +, , Z] f- Z Z { ⇥} ries we will assume the definition of SMT formulas as stated denotation and [ <, >, , , =, = , Z] r-denotation respec- in this paragraph. The same applies to the case of ASPT pro- tively, where they{ map their function6 } and predicate sym- grams modulo uniform theories. bols into usual arithmetic operations and relations over in- We now present a theorem that makes the connection be- tegers. We call any lexicon of the form ([ , Z],⇢ , ) inte- A Z Z tween GCSPs over some lexicon and restriction formulas ger. Similarly, and ⇢ denote [ +, , R] f-denotation and L R R { ⇥}

1185 [ <, >, , , =, = , R] r-denotation respectively, where they Solver Language {  6 } map their function and predicate symbols into usual arith- CLINGCON [Gebser et al., 2009] ASPT(IL)⇤ metic operations and relations over reals. We call any lexicon EZCSP [Balduccini, 2009] ASPT(IL)⇤ of the form ([ , R],⇢ , ) numeric. A R R ASPT(IL) Such commonly used theories in SMT as linear real arith- ASPT(L) metic, linear integer arithmetic, and integer difference logic MINGO [Liu et al., 2012] ASPT(L) are uniform. To be more precise, linear real arithmetic is an DINGO [Janhunen et al., 2011] ASPT(DL) example of a uniform theory over a numeric lexicon. This arithmetic poses syntactic conditions on restriction formulas Table 1: Solvers Categorization that it interprets. Namely, literals in these restriction formulas must correspond to linear constraints. Similarly, linear inte- ger arithmetic and integer difference logic are examples of ⇧, , , both CLINGCON and EZCSP first use an answer uniform theories over integer lexicons. Literals in restriction h B i formulas in these arithmetics must correspond to integer lin- set solver to compute an input answer set of ⇧. Second, ear constraints. Furthermore, the difference logic is a special they contact a theory solver to verify whether respective case of integer linear arithmetic posing yet additional syntac- constraint satisfaction problem has a solution. In case of tic restrictions [Nieuwenhuis and Oliveras, 2005]. CLINGCON, finite domain constraint solver GECODE is used EZCSP We call any ASPT program ⇧,T,µ over r i as a theory solver. System uses constraint logic pro- h i [ gramming tools such as BPROLOG [Zhou, 2012],SICSTUS an ASPT(L) program if T is the uniform theory over [Carlsson and Fruehwirth, 2014], and SWI PRO- • a numeric lexicon and µ maps irregular atoms into i LOG [Wielemaker et al., 2012]. These tools provide EZCSP linear constraints. with the ability to work with three different kinds of con- an ASPT(IL) program if T is the uniform theory over straints: finite-domain integer, integer-linear, and linear con- • an integer lexicon and µ maps irregular atoms into i straints. To process ASPT(L) programs, the solver MINGO integer linear constraints. translates these programs into mixed integer programming an ASPT(DL) program if T is the uniform theory over expressions and then uses the solver CPLEX [IBM, 2009] to • an integer lexicon and µ maps irregular atoms into i solve these formulas. To process ASPT(DL) programs DINGO difference logic constraints. translates these programs into SMT(DL) formulas and applies In the same style, we can define SMT(L), SMT(IL), and the SMT solver Z3 [De Moura and Bjørner, 2008] to find their SMT(DL) formulas. models. From Theorem 5, CAS programs of the form ⇧, ⇤ , , The diversity of solving approaches used in CASP h BL i where is a numeric lexicon and ⇤ is the set of all lin- paradigms suggests that solutions of the kind are available ear constraintsL over , are essentiallyBL the same objects as L for SMT technology. Typical SMT architecture is in a style ASPT(L) programs. Similarly, it follows that CAS programs of systems CLINGON and EZCSP. At a high-level abstraction, of the form ⇧, ⇤ , , where is an integer lexicon and ⇤ one may summarize common architectures of SMT solvers is the set ofh allB integerL i linearL constraints over , are essen-BL L as satisfiability-based solvers augmented with theory solvers. tially the same objects as ASPT(IL) programs. Theory solvers are typically implemented within an SMT Obviously, Theorems 2 and 4 pave the way for using SMT solver and are as such custom solutions. The fact that CLIN- systems that solve SMT(L) and SMT(IL) problems as is for GON and EZCSP use tools available from the constraint pro- solving tight ASPT(L) and ASPT(IL) programs respectively. gramming community suggests that these tools could be of It is sufficient to compute the input completion of the pro- use in SMT community also. The solution exhibited by sys- gram relative to irregular atoms. This observation has been tem MINGO, where mixed integer programming is used for utilized in work by Lee and Meng [2013] and Janhunen et solving ASPT(L) programs, hints that a similar strategy can al. [2011]. Furthermore, Janhunen et al. propose a transla- be implemented for solving SMT(L) formulas. These ideas tion of ASPT(DL) programs into SMT(DL) formulas. Sys- have recently been explored in [King et al., 2014]. tem DINGO utilizes this translation by invoking SMT solver Z3 for finding models for ASPT(DL) programs. It is a di- rection of future work to generalize these results to arbitrary Conclusions theories. In this paper we unified the terminology stemming from the Outlook on Constraint Answer Set Solvers Table 1 fields of CASP and SMT solving. This unification helped us presents the landscape of current constraint answer set solvers identify the special class of so called uniform theories widely using the unified terminology of this section. The star anno- used in SMT practice. Given such theories, CASP and SMT tating language ASPT(IL) denotes that the solver supporting⇤ solving share more in common than meets the eye. We ex- this language requires the specification of finite ranges for its pect this work to be a strong building that will bolster variables (since finite-domain constraint solvers are used as the cross-fertilization between three different, even if related, underlying solving technology). automated reasoning communities: CASP, constraint (satis- At a high-level abstraction, one may summarize the ar- faction processing) programming, and SMT. In the future, we chitectures of the CLINGCON and EZCSP solvers as ASP- would like to investigate a similar link to a related formalism based solvers plus theory solver. Given a CAS program of HEX-programs [Eiter et al., 2012].

1186 References International Joint Conference on Artificial Intelligence [Balduccini, 2009] Marcello Balduccini. Representing con- (IJCAI-13), Beijing, China, August 3-9, 2013, 2013. straint satisfaction problems in answer set programming. [Lierler and Truszczynski, 2011] Yuliya Lierler and In Proceedings of ICLP Workshop on Answer Set Pro- Miroslaw Truszczynski. Transition systems for model gramming and Other Computing Paradigms (ASPOCP), generators — a unifying approach. Theory and Practice https://www.mat.unical.it/ASPOCP09/, 2009. of Logic Programming, 27th International Conference on Logic Programming (ICLP’11) Special Issue, 11, issue [Barrett and Tinelli, 2014] Clark Barrett and Cesare Tinelli. 4-5, 2011. Satisfiability modulo theories. In Edmund Clarke, Tom Henzinger, and Helmut Veith, editors, Handbook of Model [Lierler, 2014] Yuliya Lierler. Relating constraint answer set Checking. Springer, 2014. programming languages and algorithms. Artificial Intelli- gence, 207C:1–22, 2014. [Carlsson and Fruehwirth, 2014] Mats Carlsson and Thom Fruehwirth. Sicstus PROLOG User’s Manual 4.3. Books [Liu et al., 2012] Guohua Liu, Tomi Janhunen, and Ilkka On Demand - Proquest, 2014. Niemela. Answer set programming via mixed integer pro- gramming. In Knowledge Representation and Reasoning [Clark, 1978] Keith Clark. Negation as failure. In Herve Conference, 2012. Gallaire and Jack Minker, editors, Logic and Data Bases, pages 293–322. Plenum Press, New York, 1978. [Marriott and Stuckey, 1998] Kim Marriott and Peter J. Stuckey. Programming with Constraints: An Introduction. [ ] De Moura and Bjørner, 2008 Leonardo De Moura and MIT Press, 1998. Nikolaj Bjørner. Z3: An efficient smt solver. In Proceed- ings of the Theory and Practice of Software, 14th Interna- [Mellarkod et al., 2008] Veena S. Mellarkod, Michael Gel- tional Conference on Tools and Algorithms for the Con- fond, and Yuanlin Zhang. Integrating answer set program- struction and Analysis of Systems, pages 337–340, 2008. ming and constraint logic programming. Annals of Math- ematics and Artificial Intelligence, 53(1):251–287, 2008. [Eiter et al., 2012] Thomas Eiter, Michael Fink, Thomas Krennwallner, and Christoph Redl. Conflict-driven ASP [Nieuwenhuis and Oliveras, 2005] Robert Nieuwenhuis and solving with external sources. TPLP, 12(4-5):659–679, Albert Oliveras. Dpll(t) with exhaustive theory propaga- 2012. tion and its application to difference logic. In Proceedings of the 17th International Conference on Computer Aided [Fages, 1994] Franc¸ois Fages. Consistency of Clark’s com- Verification (CAV’05), volume 3576 of LNCS. Springer, pletion and existence of stable models. Journal of Methods 2005. of Logic in Computer Science, 1:51–60, 1994. [Wielemaker et al., 2012] Jan Wielemaker, Tom Schrijvers, [Gebser et al., 2009] Martin Gebser, Max Ostrowski, and Markus Triska, and Torbjorn¨ Lager. SWI-Prolog. Theory Torsten Schaub. Constraint answer set solving. In Pro- and Practice of Logic Programming, 12(1-2):67–96, 2012. ceedings of 25th International Conference on Logic Pro- gramming (ICLP), pages 235–249. Springer, 2009. [Zhou, 2012] Neng-fa Zhou. The language features and ar- chitecture of b-prolog. Theory and Practice of Logic Pro- [Gelfond and Lifschitz, 1988] Michael Gelfond and gramming, 12(1-2):189–218, January 2012. Vladimir Lifschitz. The for logic programming. In Robert Kowalski and Kenneth Bowen, editors, Proceedings of International Logic Pro- gramming Conference and Symposium, pages 1070–1080. MIT Press, 1988. [IBM, 2009] IBM. IBM ILOG AMPL Version 12.1 User’s Guide, 2009. http://www.ibm.com/software/ commerce/optimization/cplex-optimizer/. [Janhunen et al., 2011] Tomi Janhunen, Guohua Liu, and Ilkka Niemela. Tight integration of non-ground answer set programming and satisfiability modulo theories. In Pro- ceedings of the 1st Workshop on Grounding and Transfor- mations for Theories with Variables, 2011. [King et al., 2014] Tim King, Clark Barrett, and Cesare Tinelli. Leveraging linear and mixed integer programming for smt. In Proceedings of the 14th Conference on Formal Methods in Computer-Aided Design, FMCAD ’14, pages 24:139–24:146, Austin, TX, 2014. FMCAD Inc. [Lee and Meng, 2013] Joohyung Lee and Yunsong Meng. Answer set programming modulo theories and reasoning about continuous changes. In Proceedings of the 23rd

1187