[

# [

###### Abstract

Constraint answer set programming is a promising research direction that integrates answer set programming with constraint processing. It is often informally related to the field of satisfiability modulo theories. Yet, the exact formal link is obscured as the terminology and concepts used in these two research areas differ. In this paper, we connect these two research areas by uncovering the precise formal relation between them. We believe that this work will booster the cross-fertilization of the theoretical foundations and the existing solving methods in both areas. As a step in this direction we provide a translation from constraint answer set programs with integer linear constraints to satisfiability modulo linear integer arithmetic that paves the way to utilizing modern satisfiability modulo theories solvers for computing answer sets of constraint answer set programs.
Under consideration in Theory and Practice of Logic Programming (TPLP).

KEYWORDS: constraint answer set programming, constraint satisfaction processing, satisfiability modulo theories

On Relation between CASP and SMT]On Relation between Constraint Answer Set Programming and Satisfiability Modulo Theories111This is an extended version of the paper that appeared at IJCAI-2016 (Lierler and Susman, 2016).

Yuliya Lierler and Benjamin Susman]YULIYA LIERLER and BENJAMIN SUSMAN
Department of Computer Science, University of Nebraska at Omaha
Omaha, Nebraska 68182, USA

## 1 Introduction

Constraint answer set programming (CASP) (Elkabani et al., 2004; Mellarkod et al., 2008; Gebser et al., 2009; Balduccini, 2009; Lierler, 2014) is a promising research direction that integrates answer set programming, a powerful knowledge representation paradigm, with constraint processing. Typical answer set programming tools start their computation with grounding, a process that substitutes variables for passing constants in respective domains. Large domains often form an obstacle for classical answer set programming. CASP enables a mechanism to model constraints over large domains so that they are processed in a non-typical way for answer set programming tools by delegating their solving to constraint solver systems specifically designed to handle large and sometimes infinite domains. CASP solvers including clingcon (Gebser et al., 2009) and ezcsp  (Balduccini, 2009) already put CASP on the map of efficient automated reasoning tools.

Constraint answer set programming often cites itself as a related initiative to satisfiability modulo theories (SMT) solving (Barrett and Tinelli, 2014). Yet, the exact link is obscured as the terminology and concepts used in both fields differ. To add to the complexity of the picture several answer set programming modulo theories formalisms have been proposed. For instance, Liu et al. (2012), Janhunen et al. (2011), and Lee and Meng (2013) introduced logic programs modulo linear constraints, logic programs modulo difference constraints, and ASPMT programs respectively. Acyclicity programs (Bomanson et al., 2015) (or logic programs modulo acyclicity constraints) form another recently investigated formalism that parallels satisfiability modulo graphs framework developed within SMT (Gebser et al., 2014).

This work attempts to unify the terminology used in CASP and SMT so that the differences and similarities of logic programs with constraints versus logic programs modulo theories become apparent. At the same time, we introduce the notion of constraint formulas, which is similar to that of logic programs with constraints. We identify a special class of SMT theories that we call “uniform”. Commonly used theories in satisfiability modulo solving such as integer linear, difference logic, and linear arithmetics belong to uniform theories. This class of theories helps us to establish precise links (i) between CASP and SMT, and (ii) between constraint formulas and SMT formulas. We are able to then provide a formal description relating a family of distinct constraint answer set programming formalisms.

We show that this unified outlook allows us not only to better understand the landscape of CASP languages and systems, but also to foster new ideas for the design of CASP solvers and possibly SMT solvers. For example, theoretical results of this work establish a simple method for using SMT systems for computing answer sets of a broad class of tight constraint answer set programs. Susman and Lierler (2016) utilized this method in implementing an SMT-based solver for such programs. In the conclusion of this work, we rely on the concept of level ranking by Niemelä (2008) to develop a translation for nontight constraint answer set programs to SMT formulas so that an SMT solver can be used to compute answer sets of such programs.

##### Paper Outline

Section 2 is on preliminaries. It reviews concepts of logic programs, completion, (input) answer sets, and level ranking. Section 2.2 presents the details of generalized constraint satisfaction problem and links this notion to classical constraint satisfaction. The section on preliminaries concludes with formal definitions of linear and integer linear constraints. Section 3 introduces constraint answer set programs and constraint formulas. Next, in Section 4 we present satisfiability modulo theories and specify a class of uniform theories. Section 5 defines SMT formulas and ASPT programs. Uniform theories provide us with a ground to establish a formal link between CASP and SMT in Section 6 by relating SMT formulas with constraint formulas and ASPT programs with constraint answer set programs. Section 6 concludes by characterizing a family of distinct constraint answer set programming formalisms using the uniform terminology proposed in this work. Section 7 utilizes the generalization of level ranking to propose a method of using SMT solvers for computing answer sets of constraint answer set programs with integer constraints. Finally, we list the conclusions.

## 2 Preliminaries

This section starts by reviewing logic programs and the concept of an answer set. It also introduces programs’ completion. Next, the generalized constraint satisfaction problems are introduced and related to the classical constraint satisfaction problems studied in artificial intelligence.

### 2.1 Logic Programs and Completion

##### Syntax

A vocabulary is a set of propositional symbols also called atoms. As customary, a literal is an atom  or its negation, denoted . A (propositional) logic program, denoted by , over vocabulary  is a set of rules of the form

 a←b1,…,bℓ, not bℓ+1,…, not bm,  not  not bm+1,…, not  not bn (1)

where is an atom over or , and each , , is an atom in . We will sometimes use the abbreviated form for rule (1)

 a←B (2)

where stands for and is also called a body. Syntactically, we identify rule (1) with the propositional formula

 b1∧…∧bℓ∧¬bℓ+1∧…∧¬bm∧¬¬bm+1∧…∧¬¬bn→a (3)

and with the propositional formula

 b1∧…∧bℓ∧¬bℓ+1∧…∧¬bm∧¬¬bm+1∧…∧¬¬bn. (4)

Note that (i) the order of terms in (4) is immaterial, (ii) not is replaced with classical negation (), and (iii) comma is replaced with conjunction (). Expression

 b1∧…∧bℓ

in formula (4) is referred to as the positive part of the body and the remainder of (4) as the negative part of the body. Sometimes, we interpret semantically rule (1) and its body as propositional formulas, in these cases it is obvious that double negation in (3) and (4) can be dropped.

The expression is the head of the rule. When is , we often omit it and say that the head is empty. We write for the set of nonempty heads of rules in .

We call a rule whose body is empty a fact. In such cases, we drop the arrow. We sometimes may identify a set of atoms with the set of facts .

##### Semantics

We say a set  of atoms satisfies rule (1), if  satisfies the propositional formula (3), where we identify with an assignment over the atoms in  (3) in a natural way:

• any atom that occurs in maps to truth value and

• any atom in (3) but not in maps to truth value .

We say  satisfies a program , if  satisfies every rule in . In this case, we also say that is a model of . We may abbreviate satisfaction relation with symbol (to denote that a set of atoms satisfies a rule or a program or a formula).

The reduct of a program relative to a set of atoms is obtained by first removing all rules (1) such that does not satisfy negative part of the body , and replacing all remaining rules with . A set  of atoms is an answer set, if it is the minimal set that satisfies all rules of  (Lifschitz et al., 1999).

Ferraris and Lifschitz (2005) showed that a choice rule can be seen as an abbreviation for a rule (choice rules were introduced by Niemelä and Simons (2000) and are commonly used in answer set programming languages). We adopt this abbreviation in the rest of the paper.

###### Example 1

Consider the logic program from Balduccini and Lierler (2017):

 {switch}.lightOn← switch,not am.←not lightOn.{am}. (5)

Each rule in the program can be understood as follows:

• The action switch is exogenous.

• The light is on (lightOn) during the night (not am) when the action switch has occurred.

• The light must be on.

• It is night (not am) or morning (am)

Choice rules and in program (5) abbreviate rules

 switch←not not switch.am←not not am.

respectively. Consider set of atoms. The reduct of program (5) relative to this set follows:

 switch.lightOn← switch.

It is easy to see that set satisfies every rule of the reduct. Furthermore, this set is minimal among sets with this property. Thus, it is an answer set of program (5). In fact, it is the only answer set of this program. This answer set suggests that the only situation that satisfies the specifications of the problem is such that (i) it is currently night, (ii) the light has been switched on, and (iii) the light is on.

##### Completion

It is customary for a given vocabulary , to identify a set of atoms over with (i) a complete and consistent set of literals over constructed as , and respectively with (ii) an assignment function or interpretation that assigns truth value to every atom in  and  to every atom in .

By we denote the set of the bodies of all rules of  with head . For a program over vocabulary , the completion of  (Clark, 1978), denoted by , is the set of classical formulas that consists of the rules (1) in (recall that we identify rule (1) with implication (3)) and the implications

 a→⋁a←B∈ΠB (6)

for all atoms in . When set is empty, the implication (6) has the form . When a rule (2) is a fact , then we identify this rule with the clause consisting of a single atom .

###### Example 2

The completion of logic program (5) consists of formulas

 ¬¬switch→switch,switch∧¬am→lightOn,¬lightOn→⊥,¬¬am→am,switch→¬¬switch,lightOn→switch∧¬am,am→¬¬am. (7)

It is easy to see that this completion is equivalent to the set of formulas

 lightOn↔switch∧¬am,lightOn. (8)

The set is the only model of (8). (Unless the signature of a formula is explicitly stated, we consider the set of atoms occurring in the formula to implicitly specify its signature.) Note that set coincides with the only answer set of program (5).

##### Tightness

Any answer set of a program is also a model of its completion. The converse does not always hold. Yet, for the large class of logic programs, called tight, their answer sets coincide with models of their completion (Fages, 1994; Erdem and Lifschitz, 2001). Tightness is a syntactic condition on a program that can be verified by means of program’s dependency graph.

The dependency graph of  is the directed graph such that

• the vertices of are the atoms occurring in , and

• for every rule (1) in  whose head is not , has an edge from atom to each atom in positive part of its body.

A program is called tight if its dependency graph is acyclic.

For example, the dependence graph of program (5) consists of three nodes, namely, , , and and a single edge from to . This program is obviously tight.

##### Level Rankings

Niemelä (2008) characterized answer sets of "normal" logic programs in terms of "level rankings". Normal programs consist of rules of the form (1), where and is an atom. Thus, such constructs as choice rules and so-called denials (rules with empty head) are not covered by normal programs. We generalize the concept of level ranking to programs considered in this paper that are more general than normal ones.

We start by introducing some notation. By we denote the set of natural numbers. For a rule (2), by we denote its positive part and sometimes identify it with the set of atoms that occur in it, i.e., (recall that in (2) stands for the right hand side of the arrow in rule (1)). For a program , by we denote the set of atoms occurring in it.

###### Definition 1

For a logic program and a set of atoms over , a function lr: is a level-ranking of for when for each , there is in such that  satisfies  and for every it holds that .

Niemelä (2008) observed that for an arbitrary normal logic programs, a model of its completion is also an answer set for this program when there is a level ranking of for the program. We generalize this result beyond normal programs.

###### Theorem 1

For a program and a set of atoms that is a model of its completion , is an answer set of if and only if there is a level ranking of for .

{proof}

The proof largely follows the lines of the proof of Theorem 1 from Niemelä (2008) but utilizes the terminology used in this paper. We start by defining an operator for a program and a set over as follows:

 TΠ(I)={a∣a←B∈Π,I satisfies B}.

For this operator we define

 TΠ↑0=∅

and for

 TΠ↑(i+1)=TΠ(TΠ↑i)

Left-to-right: Assume is an answer set of . We can construct a level ranking lr of  for using the operator. As is an answer set of , we know that and for each there is a unique such that , but . We consider . We now illustrate that lr is indeed a level ranking. For there is a rule of the form (1) such that and satisfies . Consequently, for every in , . Thus, . Also, from the way the reduct is constructed it follows that satisfies body of rule .

Right-to-left: Assume that there is a level ranking lr of for . We show that then is the minimal model of , which implies that is an answer set of . Since is a model of the completion of it follows that is also a model of . Indeed, recall the construction process of completion. From the construction of it follows that is also a model of . Proof by contradiction. Assume that there is a set of atoms such that is a model of  and hence is not a minimal model of . Consider now an atom with the smallest level ranking . Since lr is a level ranking of for , it follows that there is a rule in such that and for every , it holds that . As we considered atom in with the smallest level ranking it follows that . By construction, rule belongs to . We derive that  satisfies , but does not contain . This contradicts out assumption that  satisfies  as it does not satisfy rule .

### 2.2 Generalized Constraint Satisfaction Problems

In this section we present a primitive constraint as defined by Marriott and Stuckey ([Section 1.1]mar98). We refer to this concept as a constraint, dropping the word “primitive”. We use constraints to define a generalized constraint satisfaction problem that Marriott and Stuckey refer to as “constraint”. We then review constraint satisfaction problems as commonly defined in artificial intelligence literature and illustrate that they form a special case of generalized constraint satisfaction problems. We finally introduce linear constraints and linear constraint satisfaction problems.

##### Signature, c-vocabulary, constraint atoms

We adopt the following convention: for a function  and an element , by we denote the value that function maps  to, in other words, . A domain is a nonempty set of elements (or values). A signature  is a set of variables, predicate symbols, and function symbols (or f-symbols). Predicate and function symbols are associated with a positive integer called arity. By , , and  we denote the subsets of that contain all variables, all predicate symbols, and all f-symbols respectively.

For instance, we can define signature by saying that and are variables,  is a predicate symbol of arity , and  is a predicate symbol of arity . Then, , , .

Let be a domain. For a set of variables, we call a total function a valuation. For a set  of predicate symbols, we call a total function on  an r-denotation, when it maps each -ary predicate symbol of into an -ary relation on . For a set of f-symbols, we call a total function on an f-denotation, when it maps each -ary f-symbol of into a function .

Table 1 presents sample definitions of a domain, valuations, and r-denotations. In the remainder of the paper we frequently refer to these sample valuations, and r-denotations.

A constraint vocabulary (c-vocabulary) is a pair , where  is a signature and  is a domain. A term over a c-vocabulary  is either

• a variable in ,

• a domain element in , or

• an expression , where is an f-symbol of arity in and are terms over

A constraint atom over a c-vocabulary is an expression

 P(t1,…,tn), (9)

where is a predicate symbol from of arity  and  are terms over . A constraint literal over a c-vocabulary is either a constraint atom (9) or an expression

 ¬P(t1,…,tn), (10)

where is a constraint atom over .

For instance, expressions

 ¬E(s),  ¬E(2),  Q(r,s)

are constraint literals over c-vocabulary , where and are defined in Table 1.

It is due to notice that syntactically, constraint literals are similar to ground literals of predicate logic. (In predicate logic, variables as defined here are referred to as object constants or function symbols of arity .) The only difference is that here domain elements are allowed to form a term. For instance, an expression is a constraint atom over , where is a term formed from a domain element. In predicate logic, domain elements are not part of a signature over which atoms are formed.

We now proceed to introducing satisfaction relation for constraint literals. Let be a c-vocabulary, be a valuation, be a r-denotation, and  be a f-denotation. First, we define recursively a value that valuation assigns to a term over with respect to . We denote this value by  and compute it as follows:

• for a term that is a variable in , ,

• for a term that is a domain element in , is itself,

• for a term of the form , is defined recursively by the formula

 f(t1,…,tn)ν,ϕ=fϕ(tν,ϕ1,…,tν,ϕn).

Second, we define what it means for valuation to be a solution of a constraint literal with respect to given r- and f-denotations. We say that satisfies (is a solution to) constraint literal (9) over  with respect to  and  when . Let be an n-ary relation on . By we denote complement relation of constructed as . Valuation satisfies (is a solution to) constraint literal of the form (10) with respect to  and  when

For instance, consider declarations of valuations  and , and r-denotations  and  in Table 1. Valuation  satisfies constraint literal  with respect to , while valuation  does not satisfy this constraint literal with respect to .

##### Lexicon, constraints, generalized constraint satisfaction problem

We are now ready to define constraints, their syntax and semantics. To begin we introduce a lexicon, which is a tuple , where is a c-vocabulary, is a r-denotation, and is a f-denotation. For a lexicon , we call any function that is valuation, a valuation over . We omit the last element of the lexicon tuple if the signature of the lexicon contains no f-symbols. A constraint is defined over lexicon . Syntactically, it is a constraint literal over (lexicon , respectively). Semantically, we say that valuation over  satisfies (is a solution to) the constraint when satisfies  with respect to  and .

For instance, Table 2 presents definitions of sample lexicons , , and constraints , , , and  using the earlier declarations from Table 1. Valuation from Table 1 is a solution to , , , but not a solution to . Valuation  from Table 1 is not a solution to , and . In fact, constraint has no solutions. We sometimes omit the explicit mention of the lexicon when talking about constraints: we then may identify a constraint with its syntactic form of a constraint literal.

###### Definition 2

A generalized constraint satisfaction problem (GCSP) is a finite set of constraints over a lexicon . We say that a valuation  over  satisfies (is a solution to) the GCSP  when  is a solution to every constraint in .

For example, consider a set  of constraints. Any subset of this set forms a GCSP, including subsets and . Sample valuation over lexicon  (where stems from Tables 1) satisfies the GCSP , but does not satisfy the GCSP .

##### From GCSP to Constraint Satisfaction Problem

We now define a constraint satisfaction problem (CSP) as customary in classical literature on artificial intelligence. We then explain in which sense generalized constraint satisfaction problems generalize CSPs.

We say that a lexicon is finite-domain if it is defined over a c-vocabulary that refers to a domain whose set of elements is finite. Trivially, lexicons  and  defined in Table 2 are finite-domain lexicons. Consider a special case of a constraint of the form (9) over finite-domain lexicon , so that each is a variable. (For instance, constraints , , and  satisfy the stated requirements, while does not.) In this case, we can identify constraint (9) over with the pair

 ⟨(t1,…,tn),Pρ⟩. (11)

A constraint satisfaction problem (CSP) is a set of pairs (11), where and of the finite-domain lexicon  are called the variables and the domain of CSP, respectively. Saying that valuation  over  satisfies (9) is the same as saying that  The latter is the way in which a solution to expressions (11) in CSP is typically defined. As in the definition of semantics of GCSP, a valuation is a solution to a CSP problem when it is a solution to every pair (11) in .

In conclusion, GCSP generalizes CSP by

• elevating the finite-domain restriction, and

• allowing us more elaborate syntactic expressions (e.g., recall f-symbols).

#### 2.2.1 Linear and Integer Linear Constraints

We now define “numeric” signatures and lexicons and introduce a set of constraints referred to as linear, which are commonly used in practice. A numeric signature is a signature that satisfies the following requirements

• its only predicate symbols are , , , , , of arity 2, and

• its only f-symbols are , of arity .

We use the symbol to denote a numeric signature.

Symbols and denote the sets of integers and real numbers respectively. Let and be r-denotation and f-denotation respectively, where they map their predicate and function symbols into usual arithmetic relations and operations over integers. Similarly, and denote r-denotation and f-denotation respectively, defined over the reals. We can now define the following lexicons

• an integer lexicon of the form ,

• a numeric lexicon of the form .

A (numeric) linear expression has the form

 a1x1+⋯+anxn, (12)

where are real numbers and are variables over real numbers. When () we may omit it from the expression. We view expression (12) as an abbreviation for the following term

 +(×(a1,x1),+(×(a2,x2),⋯+(×(an−1,xn−1),×(an,xn))…),

over some c-vocabulary , where contains as its variables. For instance, is an abbreviation for the expression

An integer linear expression has the form (12), where are integers, and are variables over integers.

We call a constraint linear (integer linear) when it is defined over some numeric (integer) lexicon and has the form

 ⋈(e,k) (13)

where is a linear (integer linear) expression, is a real number (an integer), and belongs to . We can write (13) as an expression in usual infix notation .

We call a GCSP a (integer) linear constraint satisfaction problem when it is composed of (integer) linear constraints. For instance, consider integer linear constraint satisfaction problem composed of two constraints and (here signature is implicitly defined by restricting its variable to contain ). It is easy to see that this problem has no solutions. On the other hand, linear constraint satisfaction problem composed of the same two constraints and has an infinite number of solutions, including valuation that assigns to .

## 3 Constraint Answer Set Programs and Constraint Formulas

In this section we introduce constraint answer set programs, which merge the concepts of logic programming and generalized constraint satisfaction problems. We also present a similar concept of “constraint formulas”, which merges the concepts of propositional formulas and generalized constraint satisfaction problems. First, we introduce input answer sets, followed by constraint answer set programs and input completion. Second, we present constraint formulas. Finally, we demonstrate the close connection between the constraint answer set programs and constraint formulas using the concept of input completion and tightness condition.

### 3.1 Constraint Answer Set Programs

We start by introducing a concept in spirit of an input answer set by Lierler and Truszczynski (2011).222Similar concepts to input answer sets have been noted by Gelfond and Przymusinska (1996), Oikarinen and Janhunen (2006), and Denecker and Vennekens (2007)). In particular, we consider input answer sets “relative to input vocabularies”. We then extend the definition of completion and restate the result by Erdem and Lifshitz (2001) for the case of input answer sets. The concept of an input answer set is essential for introducing constraint answer set programs. Constraint answer set programs (and constraint formulas) are defined over two disjoint vocabularies so that atoms stemming from those vocabularies “behave” differently. Input answer set semantics allows us to account for these differences.

###### Definition 3

For a logic program over vocabulary , a set  of atoms over is an input answer set of relative to vocabulary so that when is an answer set of the program

 Π∪(X∩ι).

To illustrate the concept of an input answer set consider program

 lightOn← switch,not am.←not lightOn.

This program has a unique input answer set relative to input vocabulary .

Let and be two disjoint vocabularies. We refer to their elements as regular and irregular atoms respectively.

###### Definition 4

A constraint answer set program (CAS program) over the vocabulary is a triple , where

• is a logic program over the vocabulary such that ,

• is a set of constraints over some lexicon , and

• is an injective function from the set of irregular atoms to the set of constraints.

For a CAS program over the vocabulary so that is the lexicon of the constraints in , a set is an answer set of if

1. is an input answer set of relative to , and

2. the following GCSP over has a solution

 {γ(a)∣a∈X∩σi}∪{¬γ(a)∣a∈(At(Π)∩σi)∖X}. (14)

Note that may result in expression of the form that we identify with . (We use this convention across the paper.)

These definitions are generalizations of CAS programs introduced by Gebser et al. (2009) as they

• refer to the concept of GCSP in place of CSP in the original definition, and

• allow for more general syntax of logic rules (e.g. choice rules are covered by the presented definition).

This is a good place to note a restriction on the form of the rules in a CAS program. This restriction states that an irregular atom may not form a head of a rule. There is a body of research including, for example, work by Bartholomew and Lee (2012),  Lifschitz (2012), and Balduccini (2013) that investigates variants of semantics of CAS-like programs, where analogous to irregular atoms are allowed in the heads. Lifting this restriction proves to be nontrivial. Traditional CASP systems, such as clingcon or ezcsp, restrict their attention to programs discussed here.

It is worthwhile to remark on the second condition in the definition of an answer set for CAS programs. This condition requires the existence of a solution to a constructed GCSP problem, and ignores a form of a particular solution to this GCSP or a possibility of multiple solutions. We now define a concept of an extended answer set that takes a solution to a constructed GCSP problem into account:

###### Definition 5

For a CAS program over the vocabulary so that is the lexicon of the constraints in , a set and valuation from variables in the signature of to the domain of , a pair is an extended answer set of if is an answer set of and is a solution to GCSP (14).

CASP systems, such as clingcon or ezcsp, allow the user to select whether he is interested in computing answer sets or extended answer sets of a given CAS program. In the rest of the paper we focus on the notion of an answer set, but generalizing concepts and results introduced later to the notion of extended answer set is not difficult.

In the sequel we adopt the following notation. To distinguish irregular atoms from the constraints to which these atoms are mapped, we use bars to denote that an expression is an irregular atom. For instance, and denote irregular atoms. Whereas inequalities (constraints) and , respectively, provide natural mappings for these atoms. We assume such natural mappings in this presentation.

###### Example 3

Let us consider sample constraint answer set program. We first define the integer lexicon :

 (15)

Second, we define a CAS program

 P1=⟨Π1,BL3,γ1⟩ (16)

over integer lexicon , where

• is the program

 {switch}.lightOn← switch,not am.←not lightOn.{am}.←not am,|x<12|.←am,|x≥12|.←|x<0|.←|x>23|. (17)

The set of irregular atoms of  is . The remaining atoms form the regular set. The first four lines of program are identical to these of logic program (5). The last four lines of the program state:

• It must be when , where is understood as the hours.

• It is impossible for it to be when .

• Variable must be nonnegative.

• Variable must be less than or equal to .

• is the set of all integer linear constraints over integer lexicon , which obviously includes constraints ,

Consider the set

 {switch, lightOn,|x≥12|} (18)

over . This set is the only input answer set of relative to its irregular atoms. Also, the integer linear constraint satisfaction problem with constraints

 {γ1(|x≥12|),¬γ1(|x<12|),¬γ1(|x<0|),¬γ1(|x>23|)}={x≥12,¬x<12,¬x<0,¬x>23}

has a solution. There are 12 valuations relative to integer lexicon for , which satisfy this GCSP: . It follows that set (18) is an answer set of . Pair is one of the twelve extended answer sets of .

#### 3.1.1 On Grounding

In practice, CASP languages similarly to ASP languages, allow for non-constraint variables. Gebser et al. (2009) present a program written in the language supported by CASP solver clingcon for the so called bucket problem. We list a rule from that program to illustrate the notion of non-constraint variables333A rule is taken form the site documenting system clingcon: http://www.cs.uni-potsdam.de/clingcon/examples/bucket_torsten.lp .:

:- volume(B,T+1) $!= volume(B,T)$+ A, pour(B,T,A),
bucket(B), time(T), amount(A).


Non-constraint variables of these rules are , , and . The sign marks the irregular atoms. Rules of the kind are interpreted as shorthands for the set of rules without non-constraint variables, called ground rules. Ground rules are obtained by replacing every non-constraint variable in the rules by suitable terms not containing non-constraint variables. For instance, if suitable terms for non-constraint variable in the sample rule above range over a single value ; suitable terms for range over two values and ; and suitable terms for range over two values and , then the clingcon rule above is instantiated as follows:

:- volume(a,1) $!= volume(a,0)$+ 1, pour(a,0,1),
bucket(a), time(0), amount(1).
:- volume(a,2) $!= volume(a,1)$+ 1, pour(a,1,1),
bucket(a), time(1), amount(1).
:- volume(a,1) $!= volume(a,0)$+ 2, pour(a,0,2),
bucket(a), time(0), amount(2).
:- volume(a,2) $!= volume(a,1)$+ 2, pour(a,1,2),
bucket(a), time(1), amount(2).


To help to map these rules into the syntax used earlier, we rewrite the first one using notation of this paper:

 ←|volume(a,1)≠volume(a,0)+1|,pour(a,0,1),bucket(a),time(0),amount(1).

Expressions , , and stand for constraint variables in the signature of integer lexicon of this program. System clingcon supports integer linear constraints, where a constraint atom is naturally mapped into integer linear constraint .

The process of replacing non-ground rules by their ground counterparts is called grounding and is well understood in ASP (Gebser et al., 2007; Calimeri et al., 2008). The availability of non-constraint variables makes modeling in CASP an attractive and easy process. In fact, this feature distinguishes greatly CASP and SMT paradigms. An SMT-LIB language (Barrett et al., 2015) is a standard language for interfacing major SMT solvers. This language does not provide a user with convenient modeling capabilities. There is an underlying assumption that code in SMT-LIB is to be generated by special-purpose programs.

Since grounding is a stand-alone process in CASP and a non-ground program is viewed as a shorthand for ground programs the focus of this paper is on the later.

#### 3.1.2 Input Completion

Similar to how completion was defined in Section 2, we now define an input completion which is relative to an (input) vocabulary.

###### Definition 6

For a program over vocabulary , the input-completion of relative to vocabulary  so that , denoted by , is defined as the set of formulas in propositional logic that consists of the rules (3) in and the implications (6) for all atoms  occurring in .

###### Example 4

Here we illustrate the concept of input completion. Consider program from Example 3. Its input completion relative to a vocabulary consisting of its irregular atoms  consists of formulas in (7) and formulas in

 ¬am∧|x<12|→⊥am∧|x≥12|→⊥.|x<0|→⊥.|x>23|→⊥. (19)

It is easy to see that is equivalent to the union of (8) and (19). The set is the only model of this input completion. Note that this model coincides with the input answer set of relative to the set of its irregular atoms.

The observation that we made last in the preceding example is an instance of the general fact captured by the following theorem.

###### Theorem 2

For a tight program over vocabulary and vocabulary so that , a set  of atoms from  is an input answer set of  relative to  if and only if satisfies the program’s input-completion .

Furthermore, for any program any of its input answer sets is also a model of its input-completion.

###### Theorem 3

For a program over vocabulary and vocabulary so that , if a set  of atoms from  is an input answer set of  relative to  then satisfies the program’s input-completion .

To prove these theorems it is useful to state the following lemma.

###### Lemma 1

For a program over vocabulary and vocabulary so that , a set  of atoms over  is a model of formula if and only if it is a model of

{proof}

Since we identify rules (2) in with respective implications  we may write symbol  to denote not only a set of rules but also a set of respective implications.

We can write as the union of

 Π, (20)

implications

 {a→⋁B∈Bodies(Π,a)B | a∈hd(Π)}, (21)

and

 {a→⊥ | a∉hd(Π) and a∈σ∖ι}. (22)

Note that expression (22) can be written as

 {a→⊥ | a∉hd(Π) and a∉ι and a∈σ}. (23)

Similarly, we can write as a union of (20),

 (X∩ι) (24)
 {a→⋁B∈Bodies(Π∪(X∩ι),a)B | a∈hd(Π)} (25)
 {a→⊥ | a∉hd(Π) and a∉(X∩ι) and a∈σ} (26)

Left-to-right: Assume . It consists of (20), (21), and (23) by construction. Trivially, satisfies (24). Thus we are left to show that satisfies (25) and (26). Note that (21) and (25) coincide since for all atoms as . Consequently,  satisfies (25). Observe set (26) can be written as the union of set (23) and set

 {a→⊥ | a∉hd(Π) and a∈(ι∖X) and a∈σ}. (27)

Trivially, satisfies (27) as any atom that satisfies condition is such that . It also satisfies (23). Consequently, satisfies (26).

Right-to-left: Assume is a model of Set  satisfies (20), (24), (25), and (26). Since satisfies (25), it satisfies (21) (as they coincide as argued above). Since satisfies (26), also satisfies (23) (Recall set (26) can be written as the union of set (23) and set (27)). Consequently, .

{proof}

[Proof of Theorem 2] We are given that is tight. Since only consists of facts, it follows that  is tight also.

Left-to-right: Assume is an input answer set of a program relative to . By Definition 3 is an answer set of . It is well known that an answer set of a program is also a model of its completion. Thus,  is a model of . By Lemma 1 is a model of .

Right-to-left: Assume . By Lemma 1, is a model of completion . By results by Fages (1994) and Erdem and Lifshitz (2001), is the answer set of the program . By Definition 3, is an input answer set of  relative to . Direction Left-to-right of the proof of Theorem 2 serves as a proof for Theorem 3 also.

### 3.2 Constraint Formula

Just as we defined constraint answer set programs, we can define constraint formulas.

For a propositional formula , by we denote the set of atoms occurring in it.

###### Definition 7

A constraint formula over the vocabulary is a triple , where

• is a propositional formula over the vocabulary ,

• is a set of constraints over some lexicon , and

• is an injective function from the set  of irregular atoms to the set of constraints.

For a constraint formula over the vocabulary such that is the lexicon of the constraints in , a set is a model of if

1. is a model of , and

2. the following GCSP over has a solution

 {γ(a)|a∈X∩σi}∪{¬γ(a)|a∈(At(F)∩σi)∖X}.
###### Example 5

Similar to the CAS program from Example 3, we can define a constraint formula

 F1=⟨IComp(Π1,{|x<12|,|x≥12|,|x<0|,|x>23|}),BL3,γ1⟩

relative to integer lexicon . We understand , , and as in Example 3. Example 4 illustrates how input completion is formed. The set

 {switch,lightOn,|x≥12|}

is the only model of .

Following theorem captures a relation between CAS programs and constraint formulas. This theorem is an immediate consequence of Theorem 2.

###### Theorem 4

For a CAS program over the vocabulary and a set of atoms over , when is tight, is an answer set of if and only if is a model of constraint formula over .

We note that Example 3 and Example 5 demonstrate this property. In the future we will abuse the term "tight". We will refer to CAS program as tight when its first member has this property.

## 4 Satisfiability Modulo Theories

First, in this section we introduce the notion of a “theory” in satisfiability modulo theories (SMT) (Barrett and Tinelli, 2014). Second, we present the definition of a “restriction formula” and state the conditions under which such formulas are satisfied by a given interpretation. These formulas are syntactically restricted classical ground predicate logic formulas. To be precise, a restriction formula corresponds to a conjunction of ground literals. The presented notions of interpretation and satisfaction are usual, but are stated in terms convenient for our purposes.

###### Definition 8

An interpretation  for a signature , or -interpretation, is a tuple where

• is a domain,

• is a valuation,

• is a r-denotation, and

• is a f-denotation.

For a signature , a -theory is a set of interpretations over .

For signatures that contain no f-symbols, we omit the reference to the last element of the interpretation tuple. For instance, for signature  from Table 1, consider the following sample interpretations:

 (28)

Any subset of interpretations exemplifies a unique -theory.

As mentioned earlier, in literature on predicate logic and SMT, the terms object constant and function symbol of arity  are commonly used to refer to elements in the signature that we call variables. Here we use the terms that stem from definitions related to constraint satisfaction processing to facilitate uncovering the precise link between CASP-like formalisms and SMT-like formalisms. It is typical for predicate logic signatures to contain propositional symbols (predicate symbols of arity ). It is easy to extend the notion of signature introduced here to allow propositional symbols. Yet it will complicate the presentation, which is the reason we avoid this extension.

A restriction formula over a signature is a finite set of constraint literals over a c-vocabulary . A sample restriction formula over follows

 {¬E(s),¬Q(r,s)}. (29)

We now introduce the semantics of restriction formulas. Let  be a -interpretation. To each term  over a c-vocabulary , assigns a value that we denote by . We say that interpretation  satisfies restriction formula  over , when  satisfies every constraint literal in  with respect to  and . For instance, interpretation satisfies restriction formula (29), while does not satisfy (29).

We say that a restriction formula over signature is satisfiable in a -theory , or is -satisfiable, when there is an element of the set that satisfies . For example, restriction formula (29) is satisfiable in any -theory that contains interpretation . On the other hand, restriction formula (29) is not satisfiable in -theory .

To conclude the introduction to the concept of -theory: from the semantical perspective, it is a collection of -interpretations; from the syntactic perspective, the theory is the collection of restriction formulas satisfied by these models.

### 4.1 Uniform Theories and Link to Generalized Constraint Satisfaction Processing

The presented definition of a theory (Definition 8) places no restrictions on the domains, r-denotations, or f-denotations being identical across the interpretations defining a theory. In practice, such restrictions are very common in SMT. We now define “uniform” theories that follow these typical restrictions. We will then show how restriction formulas interpreted over uniform theories can practically be seen as GCSPs.

###### Definition 9

For a signature , we call a -theory uniform over lexicon  when

1. all interpretations in are of the form (note how valuation is the only not fixed element in the interpretations), and

2. for every possible valuation , there is an interpretation