1 Introduction

Propositional satisfiability (or satisfiability) [6] and answer set programming [7] are two closely related subareas of Artificial Intelligence that are used to model and solve difficult combinatorial search problems. Satisfiability and answer set programming in the past decade have seen ever faster computational tools, and a growing list of successful applications. Satisfiability solvers are used as general purpose tools in areas such as hardware and software verification [5, 64]; planning [36, 66]; and scheduling [33]. Answer set programming [49, 59] is increasingly leaving its mark in tackling applications in science, humanities, and industry [7]. A space shuttle control system by Nogueira et al. [62] can be regarded as an early success story of this programming paradigm. Recent examples of answer set programming applications include a Linux package configuration tool [25] (that improves the experience of thousands Debian GNU/Linux users working with the operating system); large-scale biological networks repairs [19, 28]; and team building and scheduling [65]. Furthermore, the advances in algorithmic techniques developed in satisfiability are often borrowed and relied upon in other areas of automated reasoning including answer set programming, satisfiability modulo theory, first order model building, and constraint programming. At the same time, answer set programming tools offer remarkably sophisticated techniques for so-called model enumeration problem.

Propositional satisfiability (SAT) is the problem of determining whether a given propositional classical logic formula in conjunctive normal form (CNF formula) has a satisfying interpretation. These satisfying interpretations are called models of a formula. The problem of determining whether there exists a model for a propositional formula is NP-complete. Another relevant task to determining whether a formula is satisfiable is the task of enumerating/generating its models. Here we use the term SAT problem to denote both decision and enumeration problems. To summarize, propositional CNF formulas form the language of SAT, in other words, they form its key syntactic object. Satisfying interpretations of these formulas form the semantic objects of this paradigm. SAT solvers are the software systems that find satisfying interpretations for propositional formulas. To model a problem using SAT, propositional CNF formulas are used to encode problems specifications in a way that its satisfying interpretations correspond to the solutions of the problem. Then, to find solutions to a problem it is sufficient to use a SAT solver on a corresponding formula. Thus, SAT can be seen as a constraint programming paradigm [67].

Answer set programming (ASP) is a programming paradigm, whose key syntactic object is a logic program. A logic program is a collection of rules that in their form are reminiscent of implications in classical logic. Answer sets (stable models) [30] of a logic program form the semantic objects of ASP. These answer sets are reminiscent of satisfying interpretations of formulas in classical logic. The problem of determining whether there exists an answer set for a logic program is NP-complete. Answer set solvers are the software systems that enumerate answer sets for logic programs. Niemelä [59] and Marek and Truszczyński [49] proposed answer set programming as a declarative programming paradigm for solving difficult search problems. In this paradigm a logic program encodes problem specifications in a way that the answer sets of this program represent the solutions of the problem. As a result, to find solutions to a problem it is sufficient to use an answer set solver on a corresponding program. Thus, similarly to SAT, answer set programming can be seen as a constraint programming paradigm.

As mentioned earlier, the problems of determining whether there exists a model for a propositional formula or an answer set of a logic program is NP-complete. Therefore, SAT solvers and answer set solvers are nontrivial software systems tackling computationally difficult tasks. The Davis-Putnam-Logemann-Loveland (dpll) procedure [11] is a well-known backtrack-search method that explores interpretations to generate models of a propositional formula. The cdcl [50, 51, 81] algorithm is at the heart of most modern SAT solvers. On the one hand, the cdcl algorithm can be seen as an enhancement of dpll [61]. On the other hand, it has been shown that there are problems for which cdcl provides exponential speed up [4, 63]. Extensions of cdcl also form the basis of state-of-the art answer set solvers [2, 27, 31, 42]. Thus, the solving technology underlying the search for solutions is closely related in SAT and ASP.

Observed parallels between answer set programming and satisfiability naturally bring up a question: what is a fundamental difference between the two paradigms? This is the question that we address in this paper. A short answer that summarizes our discussion follows

Answer set programming provides a declarative constraint programming language, while SAT does not.

Typically, to use a SAT solver to compute solutions of a search program, a specialized program implemented in an imperative programming language is designed to generate specific propositional formulas that encode an instance of a problem. Propositional formula is an artifact in spirit of declarative programming: it provides specifications or, in other words, constraints of a problem. In contrast to imperative programming, where we provide instructions on steps to be executed in order to achieve a solution. Yet, propositional language of SAT solvers itself is incapable to serve the role of a declarative programming language. Encoding practical problems often requires thousands to millions of propositional clauses.Footnote 1 Indeed, propositional clauses are constructed by means of propositional (Boolean) atoms so that knowledge must be encoded in these basic binary terms. As a result, one not only has to design a SAT encoding of a problem, but also find means to generate this encoding.

Answer set programming relies on dialects of a logic programming language in spirit of Prolog. Thus, its language allows first-order atoms with variables. Simple ASP programs look like Prolog programs, while more complex programs may contain specialized expressions that are convenient for modeling different kinds of constraints including aggregates. To use an answer set solver to compute solutions of a search program, a logic program that captures specifications of a problem is designed. This way no imperative programming is required as a step in utilizing answer set programming technology. To draw a parallel to terminology used in programming languages, propositional CNF formulas of SAT can be viewed as a low-level programming language, whereas logic programs of ASP form a high-level programming language. The concept of elaboration tolerance was first mentioned in [52] as the ability of a computer program’s representation of a problem to accept changes in problem specifications without need to rewrite an entire program. Answer set programming provides a general purpose modeling language that supports elaboration tolerant solutions for search problems. In contrast, SAT lacks this property.

Answer set programming can be seen as a convenient declarative programming front-end for SAT-like technology. It is used to declaratively model problems’ specifications. An answer set solver is only one of the two main building blocks of a typical ASP system. A grounder is another block. A grounder is a software system that takes logic programs with variables as its input and produces propositional programs (programs whose logic rules may only contain propositional atoms) as its output. Propositional programs are crucial in devising efficient solving procedures, yet it is the logic programming language with variables that facilitates modeling and effective problem solving by means of answer set programming. Modern languages supported by ASP technology also support additional constructs, e.g., aggregates [20, 22], to facilitate concise modeling of problems. First-order logic is a counterpart of propositional logic that allows modeling with variables. In this paper we illustrate how a built-in closed world assumption (presumption that what is not currently known to be true is false) as well as an ability to express transitive closure makes logic programs a convenient modeling language for describing search problems that SAT and ASP commonly deal with. Classical first order formulas lack the closed world assumption and, more generally, are monotonic. Possibly this explains the fact that it is logic programs under answer set semantics – a nonmonotonic formalism – which built the basis for the declarative programming language utilizing SAT-like technology.

Before proceeding to the technical content of the paper we illustrate the effect of the built-in closed world assumption and the benefits of ASP as a nonmonotonic formalism on a toy bird-penguin domain. Consider the following knowledge:

birds normally fly

penguins do not fly

The first statement is an example of default—a statement that includes a word such as normally or usually. We can use this default to draw conclusions as long as they do not contradict our knowledge. The second statement presents an exception to the default birds normally fly: although penguins are birds they do not fly. ASP provides means to encode defaults and exceptions. For example, the following logic programming rules capture the two statements above:

$$ \begin{array}{l} \mathit{fly} (X) \leftarrow \mathit{bird} (X),\ not\ \mathit{abnormal\_fly} (X).\\ \mathit{abnormal\_fly} (X) \leftarrow \mathit{penguin} (X). \end{array} $$
(1)

The former rule states the default birds normally fly by saying that if an entity is a bird and not known to be abnormal with respect to the flying property, then this entity flies. The later rule states that if an entity is a penguin, then it is abnormal with respect to flying property. Adding

$$ \mathit{bird} (\mathit{tweety} ). $$
(2)

as a fact to program (1) allows us to conclude that a bird named t w e e t y flies, because the resulting program has a unique answer set consisting of atoms

$$\{\mathit{bird} (\mathit{tweety} ), \mathit{fly} (\mathit{tweety} )\}.$$

Indeed, there is no evidence for bird t w e e t y to be abnormal with respect to the flying property. This illustrates the built-in closed world assumption in ASP.

On the other hand, consider treating these rules in (1) and (2) as classical logic formulas that seemingly encode the same knowledge:

$$\begin{array}{l} \mathit{bird} (X)\wedge \neg \mathit{abnormal\_fly} (X) \rightarrow \mathit{fly} (X)\\ \mathit{penguin} (X) \rightarrow \mathit{abnormal\_fly} (X) \\ \mathit{bird} (\mathit{tweety} ) \end{array} $$

This set of formulas has several models: one suggesting that the bird named t w e e t y flies; and another one suggesting that the bird t w e e t y does not fly as it is abnormal with respect to the flying property.

Now let us add the fact p e n g u i n(t w e e t y) to the program constructed from the rules in (1) and (2). The new program will correctly identify t w e e t y as abnormal with respect to the flying property and withdraw the earlier conclusion that t w e e t y flies. Indeed, the only answer set of the resulting program is

$$\{penguin(tweety), bird(tweety), abnormal\_{fly}(tweety)\} .$$

This illustrates the benefits of ASP as a nonmonotonic formalism.

To demonstrate the elaboration tolerance of ASP, consider the case of learning more information about specific species of birds in bird-penguin domain. For example, in addition to the fact that penguins do not fly we learn that ostriches do not fly. We can extend program (1) with a new exception by adding the rule

$$\begin{array}{l} \mathit{abnormal\_fly} (X) \leftarrow \mathit{ostrich}(X). \end{array} $$

to capture new knowledge.

To compare and contrast the SAT and ASP paradigms, we start the paper by introducing propositional satisfiability (Section 2) and propositional logic programs (Section 3). Section 4 introduces notion of completion. In Section 5, logic programs with variables are presented. We also discuss common modeling patterns used in SAT and answer set programming in Sections 236, and 7. We use graph coloring and Hamiltonian cycle search problems as runnings examples in this paper. Section 8 presents details on SAT and answer set solvers in the form that makes it easy to draw parallels between these systems. So-called effectively propositional logic is discussed in Section 9 as a counterpart to programs with variables of ASP for SAT formalism. Section 10 elaborates on related work and provides more links to literature.

2 Satisfiability and test modeling methodology

We consider atoms as customary in predicate logic. A literal is an atom or a negated atom. Ground literals and atoms are literals and, respectively, atoms that contain no variables. A clause is a non-empty disjunction of literals. We sometimes identify a clause with the set of its literals. We say that a clause is ground if it consists of ground literals. A formula is said to be in conjunctive normal form (CNF) if it is a conjunction of ground clauses (possibly the empty conjunction ⊤). A set M of literals is called consistent if there is no atom a such that M contains a and its complement ¬a. A signature is a set of ground atoms. A set M of literals over signature σ is complete if for every atom a in σ either a or ¬a (possibly both) occurs in M. An interpretation over signature σ is a complete and consistent set of literals over σ. For a formula F, by σ F we denote the signature composed of atoms that occur in F. We also call σ F the signature of F. We say that a clause C is satisfied by a consistent set M of literals (over σ), written MC, when MC. Let F be a CNF formula. Formula F is satisfied by an interpretation M over σ F , written MF, if M satisfies each conjunct (a clause) in F. We call such interpretations models. Formula F is satisfiable if it has models.

Consider a graph coloring problem GC :

A 3-coloring of a directed graph is a labeling of its vertexes with at most 3 colors such that no two vertexes sharing an edge have the same color.

For instance, see two specific graphs \(\mathcal {G}_1\) and \(\mathcal {G}_2\) in Fig. 1. It is easy to see that there are six distinct 3-colorings for graph \(\mathcal {G}_1\) including the following:

assigning color 1 to vertexes a and c, color 2 to vertex b, and color 3 to vertex d forms a 3-coloring of \({\mathcal {G}_1}\).

Fig. 1
figure 1

Sample graphs \(\mathcal {G}_1\) and \(\mathcal {G}_2\)

We denote this 3-coloring of graph \(\mathcal {G}_1\) by \(\mathcal {S}_{\mathcal {G}_1}\). Graph \(\mathcal {G}_2\) has no 3-colorings.

We now illustrate how the problem of finding a 3-coloring of a graph (V,E) can be encoded as a SAT problem. For every vertex vV and every color i∈{1,2,3}, we introduce an atom c v i that intuitively says that vertex v is assigned color i. The models of the formula

$$ \begin{array}{ll} \bigvee_{1\leq i\leq 3}c_{vi} &(v\in V),\\ \\ \neg c_{vi}\vee \neg c_{vj} &(v\in V,\ 1\leq i<j\leq 3),\\ \\ \neg c_{vi}\vee \neg c_{wi}\quad &(\{v,w\}\in E,\ 1\leq i\leq 3). \end{array} $$
(3)

are in one to one correspondence with the 3-colorings of the graph (V,E). The first line in (3) intuitively says that each vertex is assigned some colors. The second line says that it is impossible that a vertex is assigned two colors. The third line says that it is impossible that any two adjacent vertexes are assigned the same color.

Fig. 2
figure 2

SAT GC problem encoding for graph \(\mathcal {G}_1\)

The formula in spirit of (3) for graph \(\mathcal {G}_1\) consists of clauses given in Fig. 2. Horizontal lines separate the clauses that come from distinct ”schematic formulas” in (3). This formula has six satisfying interpretations including

$$\{c_{a1},~c_{b2},~c_{c1},~c_{d3}, ~\neg c_{a2},~\neg c_{a3}, ~\neg c_{b1},~\neg c_{b3}, ~\neg c_{c2},~\neg c_{c3}, ~\neg c_{d1},~\neg c_{d2} \}.$$

This model captures solution \(\mathcal {S}_{\mathcal {G}_1}\). To encode the 3-coloring problem for graph \(\mathcal {G}_2\) one has to extend the set of formulas in Fig. 2 by the following clauses

$$\neg c_{a1}\vee \neg c_{c1} ~~~ \neg c_{a2}\vee \neg c_{c2} ~~~ \neg c_{a3}\vee \neg c_{c3} $$

to account for a new edge. This formula is unsatisfiable, which says that it is impossible to color this graph in accordance with the constraints posed by 3-coloring problem.

A word test captures a common methodology to model a search problem using SAT. Interpretations over a signature of a CNF formula define space of possible solutions. Each clause of a CNF formula forms a constraint or, in other words, is part of a test that each solution to a problem has to satisfy. The specification (3) of the graph coloring problem is a fine example of this methodology. Indeed, each line in (3) corresponds to a group of constraints that an interpretation must satisfy in order to be a solution to the graph coloring problem.

3 Propositional logic programs and generate-and-test methodology

Answer set programming practitioners develop applications that rely on ASP languages, which go beyond propositional/ground atoms. Yet, common ASP solvers, smodels Footnote 2 [60, 71], clasp Footnote 3 [26, 27], wasp Footnote 4 [1, 2] to name a few, process propositional logic programs only. In this section we introduce such programs. Semantics of CNF formulas in earlier section is given by means of interpretations – sets of literals. Semantics of logic programs relies on the notion of answer sets, which are sets of atoms. A set X of atoms over some signature σ can be identified with an interpretation over σ:

$$\{a\mid a\in X\}\cup\{\neg a\mid a\in\sigma\setminus X\}.$$

A (propositional) logic program is a finite set of rules of the form

$$ \begin{array}{l} a_{0}\leftarrow a_{1},\dots, a_{k}, \mathit{not}\; a_{k+1},\dots, \mathit{not}\; a_{m}, \mathit{not}\;\mathit{not}\; a_{m+1},\dots,\mathit{not}\;\mathit{not}\; a_{n}, \end{array} $$
(4)

where a 0 is a ground atom or symbol ⊥; a 1,…,a n are ground atoms. We call rule (4) normal when m = n. A program is normal when it is composed of normal rules. The left hand side expression of rule (4) is called the head. The right hand side is called the body. Expressions

$$a_{1},\dots, a_{k}$$

and

$$\mathit{not}\; a_{k+1},\dots, \mathit{not}\; a_{m}, \mathit{not}\;\mathit{not}\; a_{m+1},\dots,\mathit{not}\;\mathit{not}\; a_{n}$$

constitute positive part and negative part of the body, respectively. We call rule (4)

  • a fact when its body is empty (we then drop ← from a rule);

  • a denial when its head is symbol ⊥ (we then drop ⊥ from a rule).

We call a program definite when it is composed of rules of the form

$$ a_0\leftarrow a_1,\dots, a_k. $$
(5)

For instance,

$$ \begin{array}{l} p\\ r\leftarrow p,q \end{array} $$
(6)

and

$$ \begin{array}{l} p\leftarrow \mathit{not}\ q\\ q\leftarrow \mathit{not}\ r \end{array} $$
(7)

are both normal programs, where program (6) is also definite.

We say that a set X of atoms is closed under a definite program π if for all rules (5) in π, a 0X whenever a 1,…,a k X. For example, sets {p}, {p,r}, and {p,q,r} are closed under definite program (6).

We say that a set X of atoms reduces rule (4), when X∩{a k+1,…,a m } = and {a m+1,…,a n }⊆X. For instance, sets {p} and {p,r} reduce the first rule

$$p\leftarrow \mathit{not}\ q$$

of program (7), while set {p,q,r} does not. Let π be a program. The reduct πX of π with respect to a set X of atoms is the set of rules (5) for all rules (4) in π such that X reduces (4). Note that πX is a definite program. A set X of atoms is an answer set of the program π if X is minimal among the sets of atoms that are closed under πX. For instance, let π1 denote program (7) and X 1 denote set {q}. The reduct \({\Pi }_{1}^{X_{1}}\) consists of a single fact q. Set {q} is the minimal set closed under \({\Pi }_{1}^{X_{1}}\). Consequently, X 1 is an answer set of π1. Let X 2 denote set {p}. The reduct \({\Pi }_{1}^{X_{2}}\) consists of two facts p and q. Set {p,q} is the minimal set closed under \({\Pi }_{1}^{X_{2}}\). Thus, {p} is not an answer set of π1.

To the set of atoms that occur in a program π, we refer as the signature of π. When convenient, we identify answer sets of π with interpretations over the signature of π. In these cases we refer to answer sets as stable models of π.

We now consider several special case programs in order to illustrate some interesting properties of answer sets. Let a program consist of facts only. The set of these facts form the only answer set of such a program. Intuitively, each fact states what is known and an answer set reflects this information by asserting that each atom mentioned as a fact is true, whereas anything else is false. Thus answer sets semantics follows closed world assumption (CWA) – presumption that what is not currently known to be true is false.

Consider a definite program. It is obvious that the reduct of a definite program π with respect to any set of atoms coincides with π. We can trivially simplify the definition of an answer set for a definite program π: A set X of atoms is an answer set of π if X is minimal among the sets of atoms that are closed under π. Consequently, definite programs without denials have a unique answer set. For instance, set {p} is the only answer set of definite program (6).

It is intuitive to argue that answer set semantics for logic programs generalizes CWA. This is a good place to note that an atom, which does not occur in the head of some rule in a program, will not be a part of any answer set of this program.

Closed world assumption has been recognized important in design of knowledge representation languages, thus it is not surprising that logic programs under answer set semantics “found their home” in knowledge representation and reasoning community and answer set programming is often positioned as a prominent knowledge representation and reasoning formalism.

Let a program consist of the rule

$$ p\leftarrow not\ not\ p. $$
(8)

This program has two answer sets and {p}. This rule can be used to “eliminate” CWA for an atom p. Intuitively, it states that an atom p may be a part of an answer set. Denecker et al. [13] elaborate on this observation.

The version of the language of logic programs that allows doubly negated atoms is a special case of programs with nested expressions introduced by Lifschitz et al. [46]. This extension of logic programs is essential. Choice rules [60] of the form

$$ \{a_0\}\leftarrow a_1,\dots, a_k, \mathit{not} \;a_{k+1},\dots, \mathit{not}\; a_m, $$
(9)

are important constructs of common ASP dialects. Ferraris and Lifschitz [18] show that a choice rule (9) can be seen as an abbreviation for a rule with doubly negated atoms of the form

$$a_{0}\leftarrow\ a_{1},\dots, a_{k}, \mathit{not}\; a_{k+1},\dots, \mathit{not}\; a_{m}, not\ not\ a_{0}. $$

In this work we adapt this abbreviation. The simplest choice rule

$$\{p\}$$

corresponds to rule (8).

Consider a denial ←p. Extending program (6) by this rule will result in a program that has no answer sets. In other words, denial ←p eliminates the only answer of (6). It is convenient to view any denial

$$ \leftarrow a_1,\dots, a_k, \mathit{not}\; a_{k+1},\dots, \mathit{not}\; a_m, \mathit{not}\;\mathit{not}\; a_{m+1},\dots,\mathit{not}\;\mathit{not} ~a_n, $$
(10)

as a clause

$$ \neg a_{1}\vee\dots\vee \neg a_k\vee a_{k+1}\vee\dots\vee a_m\vee \neg a_{m+1}\vee\dots\vee \neg a_n. $$
(11)

Then, we can state the general property about denials: stable models of a program satisfy the CNF formula composed of its denials. Furthermore, for a program π and a set Γ of denials the stable models of π∪Γ coincide with the stable models of π that satisfy Γ [43]. Consequently, denials can be seen as elements of classical logic in logic programs.

We now present how a propositional logic program under answer set semantics encodes the graph coloring problem GC so that answer sets of this program are in one to one correspondence with the 3-colorings of a given graph (V,E). As in case of SAT encoding (3), we take atoms of the form c v i to stand for an assertion that vertex v is assigned color i. Consider a following program

$$ \begin{array}{ll} \{c_{vi}\} &(v\in V, 1\leq i\leq 3)\\ \\ \leftarrow c_{vi}, c_{vj} \quad &(v\in V,\ 1\leq i<j\leq 3),\\ \\ \leftarrow c_{vi}, c_{wi} \quad &(\{v,w\}\in E,\ 1\leq i\leq 3),\\ \\ \leftarrow \mathit{not}\; c_{v1},\mathit{not}\; c_{v2}, \mathit{not}\; c_{v3}. \quad &(v\in V). \end{array} $$
(12)

A collection of choice rules for each vertex v captured by the first line in (12) intuitively says that vertex v may be assigned some colors. The second line says that it is impossible that a vertex is assigned two colors. The third line states that it is impossible that any two adjacent vertexes are assigned the same color. The last line states that it is impossible that a vertex is not assigned a color.

Fig. 3
figure 3

Logic program for 3-coloring for graph \(\mathcal {G}_1\)

Recall graph \(\mathcal {G}_1\) in Fig. 1. In Fig. 2 we illustrated SAT encoding stated in (3) for this graph. Figure 3 presents a logic program in spirit of (12) for \(\mathcal {G}_1\). Horizontal lines separate the clauses that come from distinct ”schematic rules” in (12). This program has six answer sets including

$$\{c_{a1},~c_{b2},~c_{c1},~c_{d3}\},$$

which captures solution \(\mathcal {S}_{\mathcal {G}_1}\). To encode the 3-coloring problem for graph \(\mathcal {G}_2\) one has to extend the set of rules in Fig. 3 with rules

$$\leftarrow c_{a1}, c_{c1} ~~~~~~~~~~ \leftarrow c_{a2}, c_{c2} ~~~~~~~~~~ \leftarrow c_{a3}, c_{c3}. $$

This program has no answer sets, which captures the fact that this graph has no 3-colorings.

Just as the SAT specification (3) of the graph coloring problem GC is a fine example of the test methodology by means of SAT, the ASP specification (12) illustrates the use of the so-called generate and test methodology within answer set programming paradigm. The generate part of the specification “defines” a collection of answer sets (interpretations) that can be seen as potential solutions. The test part consists of conditions that eliminate the answer sets of the generate part that do not correspond to solutions. The first line in (3) corresponds to generate, whereas the remaining lines correspond to test. Observe, how denials are used to formulate test.

It is interesting to note how the generate part is non-existent in SAT specifications. Any interpretation of the signature of a problem forms a potential solution in SAT: so in a sense the generate part is implicit. CWA present in answer set programming poses a need for the explicit generate part. Choice rules provide a convenient tool in ASP for formulating generate.

4 Completion

The SAT and ASP formulations (3) and (12) look closely related. This is not by chance. Fages [17] showed that for a large syntactic class of “tight” programs, their stable models coincide with the models of programs’ “completion“ – a propositional formula defined by Clark [10]. It turns out that

  1. i.

    the completion of program (12) is equivalent to formula (3) (in fact, a simple equivalent transformation on the completion of program (12) will result in formula (3)), and

  2. ii.

    program (12) is tight.

We now recall the definitions of tightness and Clark’s completion.

For any propositional program π, the dependency graph of π is the directed graph that

  • has all atoms occurring in π as its vertexes, and

  • for each rule (4) in π has an edge from a 0 to a i , where 1≤ik.

We say that a program is tight if its dependency graph is acyclic.

Sample programs (6) and (7) are tight. Figure 4 presents the dependency graph for these programs. The encoding (12) of the graph coloring GC problem is also a tight program as its dependency graph has no edges. Many practical logic programs are tight.

Fig. 4
figure 4

Sample dependency graphs for programs (6) and (7)

The simple non-tight program follows

$$ p\leftarrow p. $$
(13)

Indeed, its dependency graph consists of a single vertex p that has an edge from this vertex to itself.

Let us identify the rule (4) with the clause

$$\begin{array}{l} a_{0}\vee \neg a_{1}\vee \dots\vee \neg a_{k} \vee a_{k+1}\vee \dots\vee a_{m} \vee\neg a_{m+1}\vee{\dots} \vee\neg a_{n}. \end{array} $$

As before, in case if the rule is denial (10), then we identify this rule with the clause (11). This allows us to view a program π as a CNF formula. It is also convenient to identify the body

$$ \begin{array}{l} a_{1},\dots, a_{k}, \mathit{not}\; a_{k+1},\dots, \mathit{not}\; a_{m}, \mathit{not}\;\mathit{not} ~a_{m+1},\dots,\mathit{not}\;\mathit{not}~ a_{n}, \end{array} $$
(14)

of a rule (4) with the conjunction

$$a_{1}\wedge\dots\wedge a_{k}\wedge \neg a_{k+1}\wedge\dots\wedge \neg a_{m}\wedge a_{m+1}\wedge\dots\wedge a_{n}. $$

If a body is empty (for a rule that is a fact), we identify it with the empty conjunction ⊤.

The completion of a program π, c o m p(π), is a conjunction of

  • equivalences of the form

    $$ a\leftrightarrow \bigvee_{a \leftarrow B\in {\Pi}} B $$
    (15)

    for each atom a that occurs in π and

  • the clauses that correspond to denials of π.

If there is an atom a in a program π that never occurs in the head of any rule then we view (15) as the clause ¬a. Process of completion captures the intuition that the collection of rules in a program that share the same atom in their head defines this atom or, in other words, provides complete list of specifications under which this atom holds. Thus, the fact that a clause ¬a is added for any atom a that does not occur in any head of a program captures CWA explicitly: if there is no reason to deduce an atom a, it is then false.

Recall sample programs (6) and (7). The completion of the former program is

$$ \begin{array}{l} p\leftrightarrow\top\\ r\leftrightarrow p\wedge q\\ \neg q, \end{array} $$
(16)

while the completion of the latter is

$$ \begin{array}{l} p\leftrightarrow\neg q\\ q\leftrightarrow \neg r\\ \neg r. \end{array} $$
(17)

Consider another sample program

$$ \begin{array}{l} \{p\}\\ \{s\}\\ q\leftarrow\ not\ r\\ q\leftarrow r, s\\ \leftarrow q,\ not\ p. \end{array} $$
(18)

Its completion follows

$$ \begin{array}{l} p\leftrightarrow p\\ s\leftrightarrow s\\ q\leftrightarrow \neg r \vee (r\wedge s)\\ \neg r\\ \neg q\vee p. \end{array} $$
(19)

The only model of (16) is set {pqr}. The only model of (17) is set {¬p,qr}. There are two models of (19): sets {p,qrs} and {p,qr,s}. These models are also stable models of respective programs. This is not by chance. Programs (6), (7), and (18) are tight and hence their models of completion and stable models coincide.

The completion of program (13) consists of a single equivalence

$$p\leftrightarrow p. $$

This formula has two models {p} and {¬p}, while program (13) has only one stable model {¬p}. It is a general fact that any stable model of a program π is a model of c o m p(π). The converse does not hold generally (but in case of tight programs the converse also holds).

Recall program (12). Its completion is composed of (3) and equivalence

$$\begin{array}{ll} c_{vi}\leftrightarrow c_{vi} &(v\in V, 1\leq i\leq 3).\\ \end{array} $$

This formula is a tautology in propositional logic and can be safely dropped form the completion.

5 Programs with variables

As mentioned earlier, ASP practitioners develop applications that rely on languages, which go beyond propositional/ground atoms. Figure 5 presents a typical architecture of an answer set programming tool that encompasses two parts: a system called grounder and a system called solver. The former is responsible for eliminating variables in a program. The latter is responsible for finding answer sets of a respective propositional (ground) program. Systems lparse [74] and gringo Footnote 5 [23, 29] are two well known grounders that serve as front-ends for many solvers including smodels [71], clasp [27], and wasp [2].

Fig. 5
figure 5

Common Architecture of ASP Systems

In this section we refer to non-ground atoms that are constructed as customary in predicate logic: they may contain variables, object constants, and function symbols.

A logic program with variables is a finite set of rules of the form (4), where a 0 is symbol ⊥ or a non-ground atom; and a 1,…,a n are non-ground atoms. Grounding a logic program replaces each rule with all its instances obtained by substituting ground terms, formed from the object constants and function symbols occurring in the program, for all variables. For a program π, by g r o u n d(π) we denote the result of its grounding. (We use the convention common in logic programming: variables are represented by capitalized identifiers.) For example, let π be a program

$$ \begin{array}{l} \{a(1)\}~~ \{a(2)\}~~ \{b(1)\}\\ c(X)\leftarrow a(X), b(X), \end{array} $$
(20)

g r o u n d(π) follows

$$\begin{array} l \{a(1)\}~~\{a(2)\}~~\{b(1)\}\\ c(1)\leftarrow a(1), b(1)\\ c(2)\leftarrow a(2), b(2). \end{array} $$

The answer sets of a program π with variables are answer sets of g r o u n d(π) [30]. For instance, there are eight answer sets of program (20) including and set {a(1) b(1) c(1)}.

Given a program π with variables, grounders often produce a variable-free program that is smaller than g r o u n d(π), but still has the same answer sets as g r o u n d(π); we call any such program an image of π. For example, program

$$\begin{array}{l} \{a(1)\}~~ \{a(2)\}~~\{b(1)\}\\ c(1)\leftarrow a(1), b(1) \end{array} $$

is an image of (20).

When a program π with variables has at least one function symbol and at least one object constant, grounding results in infinite g r o u n d(π). Yet, even for an input program of this kind, grounders often find an image that is a finite propositional program (finite image). For instance, for program

$$ \begin{array}{l} p(0)\\ q(f(X))\leftarrow p(X) \end{array} $$
(21)

grounding results in infinite program outlined below

$$\begin{array}{l} p(0)\\ q(f(0))\leftarrow p(0)\\ q(f(f(0)))\leftarrow p(f(0))\\ q(f(f(f(0))))\leftarrow p(f(f(0)))\\ \cdots \end{array} $$

A finite image of program (21) follows

$$\begin{array}{l} p(0)\\ q(f(0))\leftarrow p(0). \end{array} $$

Program

$$\begin{array}{l} p(0)\\ q(f(0)) \end{array} $$

is another image of (21). In fact, given program (21) as an input grounders lparse and gringo will generate the latter image.

To produce images for input programs, grounders follow techniques exemplified by intelligent grounding [9]. Different grounders implement distinct procedures so that they may generate different images for the same input program. One can intuitively measure the quality of a produced image by its size so that the smaller the image is the better. A common syntactic restriction that grounders pose on input programs is “safety”. A program π is safe if every variable occurring in a rule of π also occurs in positive body of that rule. For instance, programs (20) and (21) are safe. The safety requirement suggests that positive body of a rule must contain information on the values that should be substituted for a variable in the process of grounding. Safety is instrumental in designing grounding techniques that utilize knowledge about the structure of a program for constructing smaller images [9]. The gringo grounder and the grounder of the dlv system expect programs to be safe. For programs with function symbols, to guarantee that the grounding process terminates, grounders pose additional syntactic restrictions (in other words, to guarantee that a grounder is able to construct a finite image). For example, grounder lparse expects given programs to belong to a so-called ω-restricted class [73]. Calautti et al. [8] defined a class of programs that is more general than ω-restricted class and for which bottom-up approaches for grounding implemented in dlv and gringo are guaranteed to terminate.

Often a set of propositional rules that follow a simple pattern can be represented concisely by means of logic programs with variables. We support this statement by an example. Recall program (12). We now capture atoms of the form c v i by expressions c(v,i), where c is a predicate symbol and v, i are object constants denoting a vertex v and color i respectively. Atom of the form v t x(v), intuitively, states that an object constant v is a vertex, while atom e(v,w) states that there is an edge from vertex v to vertex w in a given graph. Atom c o l o r(i) states that an object constant i represents a color. Recall graph coloring problem GC for an input graph (V,E). We now present a program with variables that encodes a solution to this problem. First, this program consists of facts that encode graph (V,E):

$$ \begin{array}{ll} vtx(v) \quad\quad\quad \quad~ &(v\in V)\\ e(v,w) \quad\quad\quad \quad~&(\{v,w\}\in E) \end{array} $$
(22)

Second, facts

$$ color(c) \quad\quad\quad \quad~ (c\in {1,2,3})\\ $$
(23)

enumerate three colors of the problem. The following rules conclude the description of the program:

$$\begin{array}{@{}rcl@{}} &&\{c(V,I)\}\leftarrow vtx(V),\ color(I) \end{array} $$
(24)
$$\begin{array}{@{}rcl@{}} &&\leftarrow c(V,I),\ c(V,J),\ I<J,\ vtx(V),\ color(I),\ color(J) \end{array} $$
(25)
$$\begin{array}{@{}rcl@{}} &&\leftarrow c(V,I),\ c(W,I),\ vtx(V),\ vtx(W),\ color(I),\ e(V,W) \end{array} $$
(26)
$$\begin{array}{@{}rcl@{}} &&\leftarrow \mathit{not} c(V,1),\mathit{not} c(V,2), \mathit{not} c(V,3),\ vtx(V) \quad \end{array} $$
(27)

These rules are the counterparts of groups of rules in propositional program (12). Indeed, rule (24) states that every vertex may be assigned some colors; rule (25) says that it is impossible that a vertex is assigned two colors; rule (26) says that it is impossible that any two adjacent vertexes are assigned the same color; and the last rule (27) states that it is impossible that a vertex is not assigned a color.

Programs with variables permit for a concise encoding of an instance of a search problem. Indeed, size of a program composed of rules (2227) is almost identical to the size of a given graph (V,E). There are |V|+|E|+7 rules in this program. On the other hand, the line

$$\begin{array}{ll} \leftarrow c_{vi}, c_{wi} \quad &(\{v,w\}\in E,\ 1\leq i\leq 3) \end{array} $$

of program (12) alone encapsulates 3|E| rules.

6 Modeling of search problems in ASP

Answer set programming provides a general purpose modeling language that supports elaboration tolerant solutions for search problems. We follow the lines of [7] in defining a search problem abstractly. A search problem P consists of a set of instances with each instance I assigned a finite set S P (I) of solutions. In answer set programming to solve a search problem P, we construct a program π P that captures problem specifications so that when extended with facts D I representing an instance I of the problem, the answer sets of π P D I are in one to one correspondence with members in S P (I). In other words, answer sets describe all solutions of problem P for the instance I. Thus solving of a search problem is reduced to finding a uniform encoding of its specifications by means of a logic program with variables.

For example, an instance of the graph coloring search problem GC is a graph. All 3-colorings for a given graph form its solutions set. Consider any graph (V,E). By D (V,E) we denote facts in (22) that encode graph (V,E). By π g c we denote a program composed of rules in (2327). This program captures specifications of 3-coloring problem so that answer sets of π g c D (V,E) correspond to solutions to instance graph (V,E) of a problem. Recall graphs \(\mathcal {G}_1\) and \(\mathcal {G}_2\) presented in Fig. 1. Facts \(D_{\mathcal {G}_1}\) representing \(\mathcal {G}_1\) follow

$$\begin{array}{l} vtx(a)~~vtx(b)~~vtx(c)~~vtx(d)~~ e(a,b)~~e(b,c)~~e(c,d)~~e(d,a)~~e(b,d). \end{array} $$

Program \({\Pi }_{gc}\cup D_{\mathcal {G}_1}\) has six answer sets, including

$$\begin{array}{l} \{vtx(a)~vtx(b)~vtx(c)~vtx(d)~\\ e(a,b)~e(b,c)~e(c,d)~e(d,a)~e(b,d)\\ color(1)~color(2)~color(3)\\ c(a,1)~c(b,2)~c(c,1)~c(d,3)\}, \end{array} $$

which captures solution \(\mathcal {S}_{\mathcal {G}_1}\). Similarly, we can use encoding π g c to establish whether 3-colorings exist for graph \(\mathcal {G}_2\). Facts \(D_{\mathcal {G}_2}\) representing \(\mathcal {G}_2\) consists of facts in \(D_{\mathcal {G}_1}\) and an additional fact e(a,c). Program \({\Pi }_{gc}\cup D_{\mathcal {G}_2}\) has no answer sets suggesting that no 3-colorings exist for graph \(\mathcal {G}_2\).

It is important to mention that the languages supported by ASP grounders and solvers go beyond rules presented here. For instance, gringo versions 4.5 + support such constructs as aggregates, cardinality expressions, intervals, pools [20, 22]. It is beyond the scope of this paper to formally discuss these constructs, but it is worth mentioning that they generally allow us more concise, intuitive, and elaboration tolerant encodings of problems. Also, they often permit to utilize more sophisticated and efficient procedures in solving [24]. It is interesting to mention pseudo-Boolean solvers [68] – systems closely related to SAT solvers. These systems implement specialized solving techniques for processing an extension of propositional CNF logic that supports expressions in spirit of cardinality constructs. Thus, it is well recognized that these constructs bring modeling and solving advances into formalisms.

For instance, a single rule

$$ \leftarrow \mathit{not} 1 \{c(V,I) : color(I)\} 1,\ vtx(V). \\ $$
(28)

can replace two rules (25) and (27) in program π g c . This shorter program will result in smaller groundings for instances of the GC problem paving the way to more efficient solving. Cardinality construct 1{c(V,I):c o l o r(I)}1 intuitively suggests us to count, for a given value of V the atoms of the form c(V,I) that belong to the answer set. Number 1 to the right and to the left of this aggregate expression tells us a specific condition on the count, in particular, that it has to be exactly 1. Cardinality expressions form only one example of multitude of constructs that gringo language offers for effective modeling of problem specifications.

In this section, we illustrated one essential difference between ASP and SAT. Propositional SAT language does not allow variables and thus for each considered graph a separate complete SAT encoding must be formulated. In case of ASP, it is possible to formulate a logic program in a way that to solve graph coloring problem it is sufficient to only specify details of a new graph in question. In introduction, we mentioned that typically to use a SAT solver to compute solutions for an instance of a search problem a specialized program in imperative language is written to generate specific propositional formula that encodes given instance as a CNF formula. Answer set programming provides another way to utilize SAT technology. For example, constructed logic program π g c with variables for solving graph coloring problem GC can be used to invoke a SAT solver for solving GC as follows. Consider some instance graph (V,E) encoded by means of the facts D (V,E). Applying a grounder on the union π g c D (V,E) results in a tight propositional program. Applying a SAT solver on a clausified completion of this propositional program allows us to enumerate the solutions to graph coloring problem for graph (V,E). In Section 8, we present details behind several modern answer set solvers. It is remarkable that several systems including cmodels Footnote 6 [31] and clasp compute answer sets of tight programs in a described fashion. In particular, for a tight program these systems start by computing a clausified completion. System cmodels then invokes a SAT solver (e.g., SAT solver minisat [15]) to find models of a computed formula. System clasp has an internal implementation of a SAT solver that is invoked on computed completion.

7 The generate-define-and-test modeling methodology of ASP

Section 3 presented how the generate and test methodology is applicable within answer set programming. Yet, an essential feature of logic programs is their ability to elegantly and concisely “define” predicates. Denecker [12] argues that normal logic programs provide a convenient language for expressing inductive definitions. He considers normal logic programs under parametrized well-founded semantics. Truszczyński [76] illustrates that for practical subset of logic programs answer set semantics and parametrized well-founded semantics coincide. Thus, logic programs under answer set semantics can be seen as a formalism that allows one to combine classical logic (recall our discussion about denials) with inductive definitions. Denecker et al. [13] elaborate on this subject and provide a detailed account on intuitive readings of connectives in logic programs. We direct interested readers to Denecker et al. work for the presentation of Tarskian informal semantics of logic programs.

The generate, define, and test is a typical methodology used by ASP practitioners in designing programs. Lifschitz [44] coined this term. It generalizes the generate and test methodology discussed earlier. The roles of the generate and test parts of a program stay the same so that, informally, generate defines a large collection of answer sets that could be seen as potential solutions, while test consists of rules that eliminate the answer sets of the generate part that do not correspond to solutions. The define section expresses additional, auxiliary concepts and connects the generate and test parts.

To illustrate the essence of define, consider a Hamiltonian cycle search problem:

Given a directed graph (V,E), the goal is to find a Hamiltonian cycle — a set of edges that induce in (V,E) a directed cycle going through each vertex exactly once.

This is an important combinatorial search problem related to Traveling Salesperson problem.

We now formalize the specifications of Hamiltonian cycle problem by means of generate, define, and test methodology. As in the encoding π g c of the graph coloring problem, we use expressions of the form v t x(v) and e(v,w) to encode an input graph. To formulate the generate part, we introduce a predicate symbol in so that the expression i n(v,w) states that edge (v,w) is part of found Hamiltonian cycle. Choice rule

$$ \{in(X,Y)\}\leftarrow e(X,Y) $$
(29)

forms the generate part of the problem. This rule states that any subset of edges of a given graph may form a Hamiltonian cycle. Answer sets of a program composed of this rule and a set of facts encoding an input graph will correspond to all subsets of edges of the graph. For instance, program composed of facts \(D_{\mathcal {G}_1}\) that encode directed graph \(\mathcal {G}_1\) introduced in Fig. 1 extended by rule (29) has 32 answer sets each representing a different subset of its edges.

In order to state the test part, an auxiliary concept of reachable is required so that we can capture the restriction that a found subset of edges of the graph is also a cycle. The define part follows

$$ \begin{array}{l} reachable(V,V)\leftarrow vtx(V)\\ reachable(U,W)\leftarrow in(U,V),~ reachable(V,W),\\ \quad\quad\quad \quad\quad\quad \quad\quad~~ vtx(U),~vtx(V),~vtx(W) \end{array} $$
(30)

These rules define transitive closure of the predicate in: all pairs of vertexes (u,v) such that v can be reached from u by following zero or more edges that are in. The in edges form a Hamiltonian cycle if and only if every pair of vertexes is in the transitive closure.

We are now ready to state the test part composed of three rules

$$ \begin{array}{l} \leftarrow in(U,V),~in(U,W),~V\neq W,~vtx(U),~vtx(V),~vtx(W)\\ \leftarrow in(U,V),~in(W,V),~U\neq W,~vtx(U),~vtx(V),~vtx(W)\\ \leftarrow \mathit{not}\; reachable(U,V),~vtx(U),~vtx(V). \end{array} $$
(31)

The former two rules state that no two selected edges start or end in the same vertex, respectively. The last rule states that it is impossible for a pair of vertexes not to belong to a transitive closure of the predicate in. In other words, a cycle formed by in-edges must include every vertex. Rules (29), (30), and (31) form a program π h c that captures specifications of Hamiltonian cycle search problem. Extending π h c with facts representing a directed graph results in a program whose answer sets describe all Hamiltonian cycles of this graph. For example, program \({\Pi }_{hc}\cup D_{\mathcal {G}_1}\) has only one answer set. Set

$$\begin{array}{l} \{ in(a,b)~in(b,c)~in(c,d)~in(d,a) \} \end{array} $$

contains all in-edges of that answer set stating that edges (a,b), (b,c), (c,d), and (d,a) form the only Hamiltonian cycle for graph \(\mathcal {G}_1\).

Concise encoding of transitive closure is a feature of answer set programming that constitutes an essential difference between ASP and SAT or effectively propositional logic — first-oder generalization of pure propositional satisfiability (discussed in more detail in Section 9). For instance, to solve Hamiltonian cycle problem, known encodings of reachability lead to propositional logic representations of larger size than these of respective propositional logic programs. East and Truszczyński [14] demonstrated that the performance of SAT solvers on propositional encodings of the Hamiltonian cycle problem lags dramatically behind that of the answer set solver aspps. Lierler and Lifschitz [41] say that effectively propositional logic reasoning can be described as the common part of classical first-order logic and logic programming under the answer set semantics. Transitive closure is not expressible by first-order formulas. Thus any subset of first-order logic taken as the language with variables for modeling search problems declaratively will fail at defining (directly) concepts that rely on transitive closure.

8 Satisfiability and answer set solving

Most modern answer set solvers are close relatives to SAT solvers based on the cdcl algorithm [51]. The cdcl algorithm can be seen as an enhancement of classical dpll procedure [11]. Clause learning and backjumping are features that distinguish cdcl from dpll. These techniques proved to be truly essential in building effective solvers. Yet, here we avoid describing these features and instead direct interested readers to [51, 61] for more details on learning and backjumping in SAT and to [27, 40] for more details on learning and backjumping in ASP. In practice, key ideas in learning and backjuming are identical for both SAT and ASP solvers. Thus, for our purposes it is sufficient to present dpll and then extend dpll to a procedure that can be used for finding answer sets of a program. We call this procedure aset. An aset algorithm is in the same relation to modern answer set solving algorithms as dpll to cdcl. By contrasting and comparing the dpll and aset algorithms we are able to point out key difference between SAT and ASP solving methods.

Answer set solvers, such as smodels [60], smodels c c [78], and dlv [38], are so-called native systems. They are based on specialized search procedures in spirit of the dpll algorithm. The core of dpll consists of performing three basic operations: decision, unit propagate, and backtrack. Unit propagate operation is based on a simple inference rule in propositional logic that given a CNF formula F allows to utilize knowledge about unit clauses (clauses that consist of a single literal) occurring in F or being inferred so far by the dpll procedure, in order to conclude new inferences. Native answer set solvers replace (or augment) unit propagate of dpll by specialized operations based on inference rules suitable in the context of logic programs. For example, smodels implements four propagators Unit Propagate , All Rules Cancelled , Backchain True , and Unfounded that we discuss in detail later in this section. Solver smodels c c extends the algorithm of smodels by backjumping and learning. Clause learning is an advanced solving technique that originated in SAT [51, 56] and proved to be extremely powerful in practice. The distinguishing feature about the answer set solver dlv is its ability to handle disjunctive answer set programs. In rules of such programs a disjunction of atoms in place of a single atom is allowed in heads. The problem of deciding whether a disjunctive program has an answer set is \({{\Sigma }^{P}_{2}}\)-complete [16].

Native answer set solvers form one core group of ASP systems. Another group is formed by so-called SAT-based answer set solvers. To explain intuitions behind the latter we present some auxiliary terminology.

In this section we use terms an atom, a literal, and a clause to refer to ground instances of these objects. For a set M of literals, by M + we denote atoms that occur positively in M. For example, {¬a,b}+={b}. For set σ of atoms and set M of literals, by M |σ we denote the maximal subset of M over σ. For example, {ab,c}|{a,b}={ab}. For a program π, by σ π we denote the set of all atoms occurring in π or, in other words, the signature of π.

There exists a number of transformations from logic programs under answer set semantics to SAT. Given a propositional logic program π, there are two kinds of transformations:

  • transformations that form a formula F π, which may contain “new atoms” so that

    • \(\{M^{+}_{|{\sigma _{\Pi }}}\mid M \text {is a model of } F_{\Pi }\}=\{M \mid M \text { is an answer set of } {\Pi } \}\), and

    • there are no distinct models M and M of F π such that \(M_{|{\sigma _{\Pi }}}^{+}={M'}_{|{\sigma _{\Pi }}}^{+}\).

  • transformations that preserve the vocabulary of π and form a formula F π so that M is a model of F π if and only if M + is an answer set of π.

Answer set solver lp2sat Footnote 7 [34, 35] is an example of a system that relies on a transformation of the former kind. It starts its computation by producing a SAT instance based on a given normal logic program. The length of the SAT instance as well as the transformation time are of order ||π||×l o g 2|σ π|, where ||π|| is the length of the program π. System lp2sat then invokes a SAT solver to compute models’ of the SAT instance that are in one to one correspondence with the answer sets of a given program.

Completion [10] is a remarkable transformation of the later kind for the large class of tight programs. As mentioned earlier, for these programs the models of program’s completion coincide with the stable models of a program. This fact is exploited in several state-of-the-art answer set solvers including clasp [27], cmodels [31], idp Footnote 8 [80]. For tight programs these solvers apply off-the-shelve SAT-solvers “as is” to clausified program’s completion.Footnote 9 Nontight logic programs can be translated into propositional formulas preserving their vocabulary only with exponential blow up in general case [45] (assuming \(P \nsubseteq NC^{1}/poly\), a conjecture from the theory of computational complexity that is widely believed to be true). One such transformation relies on extending program’s completion with so-called loop formulas [48]. Loop formulas play essential role in many modern answer set solvers, including clasp, cmodels, and idp, in case of non-tight programs. They are directly related to the concept of unfounded sets presented later [37].

The major benefit of the first approach exemplified by lp2sat is in the fact that it immediately benefits from any advances in SAT technology as it considers any SAT solver as a ”black box”. In other words, it communicates with a SAT solver via its input-output interface without interacting with any internal components of the system. Thus any new SAT solver can easily be integrated into the lp2sat framework. The second approach exemplified by clasp, cmodels, and idp requires development of specialized procedures. Systems cmodels and idp are implemented as extensions of the SAT solver minisat [15]. Although, these systems are able to utilize the sophisticated features of minisat, an appearance of any novel SAT solver does not translate into immediate advances for them. Yet, the inference related to loop formulas (or unfounded sets) implemented in these solvers proved to play an essential role in the success of the second approach. The answer set solver assat [47] is a proponent of a third intermediate approach. Similarly to the lp2sat framework, assat utilizes a SAT solver as a black box. Similarly to clasp and its peers, assat utilizes the concepts of completion and loop formula in its search. An execution of assat can be visualized as a sequence of calls to a SAT solver so that at each call completion of a program is extended with additional loop formulas, which permits a more precise description of the original problem. In the worst case scenario, it is possible that exponential number of loop formulas have to be added in this process and, respectively, a SAT solver must be called an exponential number of times.

In the rest of this section we present the dpll algorithm [11], a classical SAT procedure. We then provide an extension of this algorithm that captures the basis of modern answer set solvers including such solvers as smodels, cmodels, and clasp. We conclude by drawing a parallel between SAT and answer set solvers.

DPLL

Nieuwenhuis et al. [61] described dpll by means of a transition system that can be viewed as an abstract representation of the underlying dpll computation. This transition system captures what “states of computation” are, and what transitions between states are allowed. In this way, a transition system defines a directed graph such that every execution of the dpll procedure corresponds to a path in this graph. Some edges may correspond to unit propagation steps, some to decision, some to backtracking. We follow this approach for describing search algorithms. We now review the abstract dpll in the form convenient for our purposes.

For a set σ of atoms, a record relative to σ is a sequence M of distinct literals over σ, some possibly annotated by Δ, which marks them as decision literals. A state relative to σ is either a distinguished state FailState or a record relative to σ. For instance, the states relative to a singleton set {p} are

$$\begin{array}{l} {\textit{FailState}},\ \ \emptyset,\ \ p,\ \ \neg p, \ \ p^{{\Delta}},\ \ \neg p^{{\Delta}},\ \ p~\neg p,\ \ p^{{\Delta}}~\neg p,\\ p~\neg p^{{\Delta}},\ \ p^{{\Delta}}~\neg p^{{\Delta}},\ \ \neg p~p,\ \ \neg p^{{\Delta}}~p,\ \ \neg p~p^{{\Delta}},\ \ \neg p^{{\Delta}}~p^{{\Delta}}\text{.} \end{array} $$

Note how a sequence of literals such as p p or p p Δ does not form a record. Frequently, we consider M as a set of literals, ignoring both the annotations and the order among its elements. If neither a literal l nor its complement, written \(\overline {l}\), occurs in M, then l is unassigned by M. We say that M is inconsistent if both an atom a and its negation ¬a occur in it. For instance, states p Δ ¬p and p q ¬p are inconsistent. Also both q and ¬q are unassigned by state p Δ ¬p, whereas both of them are assigned by p q ¬p.

If C is a disjunction (conjunction) of literals then by \(\overline C\) we understand the conjunction (disjunction) of the complements of the literals occurring in C. In some situations, we will identify disjunctions and conjunctions of literals with the sets of these literals.

Each CNF formula F determines its DPLL graph dp F . The set of nodes of dp F consists of the states relative to the signature of F. The edges of the graph dp F are specified by four transition rules:

$$\begin{array}{lllll} {{\mathit{Unit Propagate} }:}& M ~\Rightarrow~ M~l & \text{if ~} \left\{ \begin{array}{l} C\in F,\ l\in C, \text{ and for every}\\ \text{literal}\, l^{\prime}\in C\, \text{so that}\, l^{\prime}\neq l,\\ \overline{l^{\prime}} \in M \end{array}\right. \\ \vspace{0.01em}\\ {{\mathit{Decide} }:}& M ~\Rightarrow~ M~l^{{\Delta}} & \text{if ~} l \text{~is unassigned by}~M \\ \vspace{.01em}\\ {{\mathit{Fail} }:}& M ~\Rightarrow~ {\mathit{FailState}} & \text{if ~} \left\{ \begin{array}{l} M\, \text{is inconsistent, and}\\ M\, \text{contains no decision literals} \end{array}\right. \\ \vspace{.01em}\\ {{\mathit{Backtrack} }:}& P~l^{{\Delta}}~Q\Rightarrow~ P~\overline{l} &\text{if ~} \left\{ \begin{array}{l} P~l^{{\Delta}}~Q\, \text{is inconsistent, and}\\ Q\, \text{contains no decision literals.} \end{array}\right. \end{array} $$

A node (state) in the graph is terminal if no edge originates in it.

The following proposition gathers key properties of the graph dp F .

Proposition 1

For any CNF formula F,

  1. (a)

    graph dp F is finite and acyclic,

  2. (b)

    any terminal state of dp F other than FailState is a model of F,

  3. (c)

    FailState is reachable from ∅ in dp F if and only if F is unsatisfiable.

Thus, to decide the satisfiability of a CNF formula F it is enough to find a path leading from node to a terminal node M. If M = FailState, F is unsatisfiable. Otherwise, F is satisfiable and M is a model of F.

For instance, let F 1={pqpr}. Below we show a path in \(\textsc {{dp}}_{F_{1}}\) with every edge annotated by the name of the transition rule that gives rise to this edge in the graph:

$$ \emptyset\quad \overset{\mathit{Decide} }{\Rightarrow}\quad p^{\Delta}\quad \overset{\mathit{Unit Propagate} }{\Rightarrow}\quad p^{\Delta}~r\quad \overset{\mathit{Decide} }{\Rightarrow}\quad p^{\Delta}~r~q^{\Delta}\text{.} $$
(32)

The state p Δ r q Δ is terminal. Thus, Proposition 1(b) asserts that F 1 is satisfiable and {p,r,q} is a model of F 1. Another path in \(\textsc {{dp}}_{F_{1}}\) that leads us to concluding that set {p,r,q} is a model of F 1 follows

$$ \emptyset\quad \overset{\mathit{Decide} }{\Rightarrow}\quad p^{\Delta}\quad \overset{\mathit{Decide} }{\Rightarrow}\quad p^{\Delta}~r^{\Delta}\quad \overset{\mathit{Decide} }{\Rightarrow}\quad p^{\Delta}~r^{\Delta}~q^{\Delta}\text{.} $$
(33)

We can view a path in the graph dp F as a description of a process of search for a model of a formula F by applying transition rules of the graph. Therefore, we can characterize an algorithm of a SAT solver that utilizes the inference rules of dp F by describing a strategy for choosing a path in dp F . A strategy can be based, in particular, on assigning priorities to some or all transition rules of dp F , so that a solver will never apply a transition rule in a state if a rule with higher priority is applicable to the same state. The dpll algorithm can be captured by the following priorities:

$$\begin{array} l \textit{Backtrack} ,\textit{Fail} >>\textit{Unit Propagate} >>\textit{Decide} \text{.} \end{array} $$

Note how path (32) in the graph \(\textsc {{dp}}_{F_{1}}\) respects priorities above, while path (33) does not. Thus dpll will never explore the latter search trajectory given input F 1.

Answer set solving

We are now ready to present an extension to the dpll algorithm that captures a family of backtrack search procedures for finding answer sets of a propositional logic program.

For a program π, we call an interpretation M over σ π a classical model of π if it is a model of the set of rules in π seen as clauses. For example, program (6) has three classical models {pqr}, {pq,r}, and {p,q,r}.

By B o d i e s(π,a) we denote the set of the bodies of all rules of program π with the head a (including the empty body). A set U of atoms occurring in a propositional program π is unfounded on a consistent set M of literals with respect to π if for every aU and every BB o d i e s(π,a), \(M\cap \overline {B}\neq \emptyset \) or UB pos, where B pos denotes positive part of the body B. For instance, set {r} is unfounded on set {pq,r} with respect to program (6), while set {q} is unfounded on {p,q,r} with respect to program (6).

We are now ready to restate the result from [39](@var1@Theorem 4.6@var1@) that relates the notions of unfounded set and stable models.Footnote 10 This result is crucial for understanding key inference rules used in propagators of modern answer set solvers.

Proposition 2

For a program π and an interpretation M over σ π , M is a stable model of π if and only if M is a classical model of π and no non-empty subset of M + is an unfounded set on M with respect to π.

This proposition gives an alternative characterization of stable models. For example, it asserts that (i) classical models of program (6) are the only interpretations that may be stable models of (6) and (ii) classical models {pq,r} and {p,q,r} are not stable models of the program due to unfounded sets {r} and {q} respectively, while classical model {pqr} is a stable model (since {p} is not an unfounded set on {pqr} with respect to program (6)).

By f:π→F we denote a function from a propositional logic program π to a CNF formula F. We say that function f approximates program π when

  • for any stable model N of π there is a model M of f(π) such that \(N=M_{|\sigma _{\Pi }}\),

  • any model M of f(π) is such that \(M_{|\sigma _{\Pi }}\) is a classical model of π.

The following proposition follows immediately from Proposition 2 and the definition of an approximating function.

Proposition 3

For a program π, a function f that approximates π, and an interpretation N over σ π , N is a stable model of π if and only if (i) there is a model M of f(π) such that \(N=M_{|\sigma _{\Pi }}\) and no non-empty subset of N + is an unfounded set on N with respect to π.

We define the transition graph aset f for a program π and a function f that approximates π as follows. The set of nodes of the graph aset f consists of the states relative to atoms occurring in f(π) and π. There are five transition rules that characterize the edges of aset f. The transition rules Unit Propagate , Decide , Fail , Backtrack of the graph dp f(π), and the transition rule

$$\begin{array}[t]{ll} {{\mathit{Unfounded} }: }& M\ ~\Rightarrow~ M~\neg a \text{~ if } \left\{ \begin{array}{l} a\in U\, \text{for a set}~U\, \text{unfounded on}\,~M\\ \text{with respect to}~{\Pi}\text{.} \end{array}\right. \end{array} $$

The graph aset f can be used for deciding whether a logic program has answer sets:

Proposition 4

For any program π and a function f that approximates π,

  1. (a)

    graph aset f,π is finite and acyclic,

  2. (b)

    for any terminal state M of aset f,π other than FailState, \(M^{+}_{|\sigma _{\Pi }}\) is an answer set of π,

  3. (c)

    FailState is reachable from ∅ in aset f,π if and only if π has no answer sets.

Obviously, any program approximates itself (recall that we identify rules with clauses). By f π we denote an identity function f π(π)=π. Extending graph \({\textsc {{aset}}}_{f_{\Pi },{\Pi }}\) with transition rules

$$\begin{array}[t]{l} {{\mathit{All Rules Cancelled} }: } M ~\Rightarrow~ M\ \neg a \text{~ if ~~} \overline B\cap M\neq \emptyset\, \text{for all}\, B\in Bodies({\Pi},a),\\ \\ {{\mathit{Backchain True} }: } M ~\Rightarrow~ M~l \text{~ if } \left\{ \begin{array}{l} a\leftarrow B\in {\Pi},\\ a\in M,\\ \overline {B'}\cap M\neq \emptyset\, \text{for all}\, B'\in Bodies({\Pi},a)\setminus \{B\}, \\ l\in B \end{array}\right. \end{array} $$

results in a graph that captures the computation procedure of answer set solver smodels. We denote the resulting graph by smπ. Similar statement to Proposition 4 holds for the graph smπ [40]. The system smodels assigns priorities to the inference rules of smπ as follows:

$$\begin{array} l \textit{Backtrack} ,\textit{Fail} >> \\ \textit{Unit Propagate} , \textit{All Rules Cancelled} , \textit{Backchain True} >>\\ \textit{Unfounded} >>\\ \textit{Decide} \text{.} \end{array} $$

We say that an edge MM in the graph smπ is singular if

  • the only transition rule justifying this edge is Unfounded , and

  • some edge MM can be justified by a transition rule other than Unfounded .

For instance, let π be the program

$$\begin{array}{l}</p><p class="noindent">p\leftarrow \ q\\ q\leftarrow \ r. \end{array} $$

The edge

$$\begin{array}{ll}</p><p class="noindent">p^{{\Delta}}~q^{{\Delta}}~\neg r^{{\Delta}}&\Rightarrow~(\textit{Unfounded} ,\ U=\{p,q\})\\ p^{{\Delta}}~q^{{\Delta}}~\neg r^{{\Delta}}~\neg p & \end{array} $$

in the graph smπ is singular, because the edge

$$\begin{array}{ll}</p><p class="noindent">p^{{\Delta}}~q^{{\Delta}}~\neg r^{{\Delta}}&\Rightarrow~(\textit{All Rules Cancelled} )\\ p^{{\Delta}}~q^{{\Delta}}~\neg r^{{\Delta}}~\neg q & \end{array} $$

belongs to smπ also.

From the point of view of actual execution of the smodels algorithm, singular edges of the graph smπ are inessential: smodels never follows a singular edge. By \({\textsc {{sm}}}^{-}_{\Pi }\) we denote the graph obtained from smπ by removing all singular edges.

It is easy to see that the completion of program π can also be seen as a conjunction of clauses in π and implications

$$ a\rightarrow \bigvee_{a \leftarrow B\in {\Pi}} B $$
(34)

for each atom a that occurs in π. Formulas (34) can be written as

$$ \neg a\vee \bigvee_{a \leftarrow B\in {\Pi}} B $$
(35)

for every atom a in π. C N FC o m p π is a function that maps program π into its completion converted to CNF using straightforward equivalent transformations. In other words, C N FC o m p π consists of clauses of two kinds:

  1. 1.

    the rules of the program seen as clauses, and

  2. 2.

    formulas (35) converted to CNF using the distributivity of disjunction over conjunction.Footnote 11

The following result from [40] illustrates that applying the smodels algorithm to a tight program π essentially amounts to applying dpll to its clausified completion C N FC o m p π. A similar relationship, in terms of pseudocode representations of smodels and dpll, was also established in [32].

Proposition 5

For any tight program π, the graph \({\textsc {{sm}}}^{-}_{\Pi }\) is equal to \({\textsc {{dp}}}_{\mathit {CNF-Comp}_{\Pi }}\).

For instance, let π be the program

$$\begin{array}{l} p\leftarrow q,\ not\ r\\ q. \end{array} $$

This program is tight. Its completion is

$$(p\leftrightarrow q\wedge\neg r)\wedge q\wedge \neg r, $$

and C N FC o m p π is

$$(p\vee\neg q\vee r)\wedge(\neg p\vee q)\wedge(\neg p\vee \neg r)\wedge q \wedge \neg r. $$

Proposition 5 asserts that, for this formula F, \({\textsc {{sm}}}^{-}_{\Pi }\) coincides with dp F .

Proposition 5 conveys that combination of completion of a program and unit propagate capture propagators All Rules Cancelled and Backchain True unique to the graph \({\textsc {{sm}}}^{-}_{\Pi }\). In a sense, these propagators are present implicitly in \({\textsc {{dp}}}_{\mathit {CNF-Comp}_{\Pi }}\).

Truszczyński and Lierler [42] generalize Proposition 5 to the case of arbitrary programs:

Proposition 6

For any program π, the graph \({\textsc {{sm}}}^{-}_{\Pi }\) is equal to aset CNF−Comp,π .

As mentioned earlier several answer set solvers, including cmodels and clasp, start their computation by forming program’s completion. It is clear that C N FC o m p π can be exponentially larger than C o m p(π). Systems cmodels and clasp define an ED-transformation procedure that converts implications (34) into a CNF formula by means of explicit definitions and avoids exponential growth. It is a special case of the Tseitin procedure [77] that efficiently transforms any given propositional formula to CNF form by adding new atoms corresponding to its subformulas. It does not produce a CNF equivalent to the input formula, but it gives us its conservative extension. The ED-transformation procedure adds explicit definitions for the disjunctive terms in (34) whenever they contain more than one atom. In other words, it introduces auxiliary atoms as abbreviations for these disjunctive terms. It then applies equivalent transformation to resulting formula and replaces these disjunctive terms by their corresponding auxiliary atoms. At last, the ED-transformation procedure converts this formula to CNF using straightforward equivalent transformations.

For instance, consider the program

$$\begin{array} l p\leftarrow\ q_{1},\ r_{1}\\ p\leftarrow\ q_{2},\ r_{2}\\ p\leftarrow\ s. \end{array} $$

For atom p, the implication (34) is

$$ p\rightarrow(q_1\wedge r_1)\vee(q_2\wedge r_2)\vee s. $$
(36)

First, ED-transformation introduces following explicit definitions

$$ \begin{array} l aux_1\leftrightarrow q_1\wedge r_1\\ aux_2\leftrightarrow q_2\wedge r_2 \end{array} $$
(37)

Second, ED-transformation turns implication (36) into the formula

$$ p\rightarrow aux_1 \vee aux_2\vee s\\ $$
(38)

that contains two auxiliary atoms a u x 1, a u x 2. Third, ED-transformation clausifies these formulas (37) and (38) as follows:

$$\begin{array} l \neg p\vee aux_{1} \vee aux_{2}\vee s\\ \neg aux_{1}\vee q_{1}\\ \neg aux_{1}\vee r_{1}\\ \neg q_{1}\vee \neg r_{1} \vee aux_{1} \\ \neg aux_{2}\vee q_{2}\\ \neg aux_{2}\vee r_{2}\\ \neg q_{2}\vee \neg r_{2} \vee aux_{2}. \end{array} $$

We now define for a program π, a function E DC o m p π that maps π into a CNF formula that is the completion C o m p(π) converted to CNF using the ED-transformation: It consists of clauses of two kinds

  1. 1.

    the rules of the program seen as clauses, and

  2. 2.

    formulas (34) converted to CNF using the ED-transformation.

The graph aset E D C o m p can be used to capture basic ideas behind such answer set solvers as cmodels and clasp. These solvers also implement backjumping and learning that are not captured by the graph aset E D C o m p. Yet, Nieuwenhuis et al. [61] and Lierler and Truszczyński [42] demonstrate how transition systems dp and aset, respectively can be extended to capture these features. Here we focus on basic variants of cmodels and clasp based on backtracking. Basic cmodels is modeled by the graph aset E D C o m p and the priorities:

$$\begin{array} l \textit{Backtrack} ,\textit{Fail} >>\textit{Unit Propagate} >>\textit{Decide} >>\textit{Unfounded} \text{.} \end{array} $$

Basic clasp is captured by aset E D C o m p and the priorities:

$$\begin{array} l \textit{Backtrack} ,\textit{Fail} >>\textit{Unit Propagate} >>\textit{Unfounded} >>\textit{Decide} \text{.} \end{array} $$

Proposition 6 asserts that systems smodels is characterized by the graph aset C N F C o m p. Furthermore, its priorities coincide with these of clasp. In this sense, system clasp is closer than cmodels to answer set solver smodels as clasp and smodels both apply inference rule Unfounded eagerly (unlike cmodels that uses this rule only on states that correspond to interpretations). Despite the similar look of graphs aset C N F C o m p and aset E D C o m p (indeed, E DC o m p and C N FC o m p serve a similar purpose), they are substantially different. Anger et al. [3] illustrated theoretically and experimentally that dpll applied to E DC o m p π is superior to dpll applied to C N FC o m p π.

Lierler and Truszczyński [42] provide a comprehensive account of major answer set solvers by means of transition systems. (Proposition 4 follows immediately from their work.) They use transition systems to contrast and compare various solvers in detail and include an account on such techniques as learning. Here we present a glimpse to these results that is sufficient to illustrates key differences between dp-based SAT solvers and aset-based ASP solvers, in particular, presence of additional propagators in answer set solvers:

  • presence of a propagator Unfounded is unique to ASP technology. Propagator Unfounded is responsible for taming recursive definitions, such as transitive closure, in solving.

  • explicit or implicit presence of propagators All Rules Cancelled and Backchain True in answer set solvers is a mechanism for effective processing of inductive definitions encoded in programs.

9 Effectively propositional logic (or direct first-order extension of SAT) for modeling search problems

Effectively propositional logic [70], also known as Bernays-Schönfinkel class and EPR, provides a generalization of pure propositional satisfiability. An EPR formula is the universal closure of a conjunction of clauses. The EPR language can be seen as an alternative to the language of logic programs with variables for developing concise formulations of search problems. For example, recall SAT representation (3). The EPR language allows us to generalize (3) as a set of the EPR clauses as follows. Consider any graph (V,E). Ground clauses consisting of single literals presented in (22) and a collection of ground clauses

$$ \neg e(v,w) \quad\quad \quad (\{v,w\}\;{\notin} E;~ v,w\in V) $$
(39)

encode the graph (V,E). We denote the collection of clauses in (22) and (39) by \(D^{\mathit {EPR}}_{(V,E)}\). Three ground clauses (23) enumerate three colors of the problem. The following EPR clauses conclude the description of the EPR encoding of GC problem:

$$\begin{array}{@{}rcl@{}} && c(V,1)\vee c(V,2) \vee c(V,3)\vee \neg vtx(V) \end{array} $$
(40)
$$\begin{array}{@{}rcl@{}} &&\neg c(V,I)\vee \neg c(V,J)\vee\neg color(I)\vee \neg color(J)\vee \neg vtx (V)\vee I\geq J \end{array} $$
(41)
$$\begin{array}{@{}rcl@{}} &&\neg c(V,I)\vee \neg c(W,I)\vee \neg vtx(V) \vee\neg vtx(W) \vee\neg color(I) \vee\neg e(V,W). \end{array} $$
(42)
$$\begin{array}{@{}rcl@{}} &&\neg color(V)\vee\neg vtx(V) \end{array} $$
(43)
$$\begin{array}{@{}rcl@{}} &&\neg e(V,W) \vee vtx(V) \end{array} $$
(44)
$$\begin{array}{@{}rcl@{}} &&\neg e(V,W) \vee vtx(W) \end{array} $$
(45)

By Γ g c , we denote the EPR formula composed of clauses (23,4045). EPR formula Γ g c captures specifications of graph coloring problem GC so that given a graph (V,E), Herbrand models of \({\Gamma }_{gc}\cup D^{\mathit {EPR}}_{(V,E)}\) correspond to 3-colorings of (V,E). The three clauses (4042) of the EPR encoding Γ g c are the counterparts of groups of clauses in propositional formula (3). Clause (40) says that each vertex is assigned some colors. Clause (41) states that it is impossible that a vertex is assigned two colors. Clause (42) says that it is impossible that any two adjacent vertexes are assigned the same color. The clauses (4345) in Γ g c intuitively say that (i) a set of object constants representing colors is disjoint from a set of object constants representing vertexes and (ii) edges are only possible between object constants that stand for vertexes. These clauses together with clauses (39) in \(D^{\mathit {EPR}}_{(V,E)}\) explicitly encode close world assumption for predicates color, vtx and e. Note how logic programming encoding π g c D (V,E) of graph coloring problem incorporated this assumption implicitly.

Software systems called EPR solvers or model builders can be used for finding models of EPR theories. The annual CADE ATP System Competition [72] contains the EPR division track promoting advances in such systems. Navaro-Perez and Voronkov [57, 58] illustrate how EPR theories can be used for modeling search problems in various domains including planning. Many of the EPR systems rely on two computational stages: grounding and solving by means of SAT.

10 Conclusions and related work

In this paper we illustrate how answer set programming can be seen as a convenient declarative programming language for utilizing SAT and SAT-like technology. It can be used to declaratively model problem’s specifications and allows for elaboration tolerant solutions that follow the generate, define, and test modeling methodology. We paid attention to essential component of answer set programming tool-set, namely, grounding. We also presented key accounts in design of answer set solvers and draw a parallel to the dpll procedure of SAT solvers. We believe that this comprehensive account on ASP versus SAT helps to understand the similarities and differences between these research directions and research concerns that fields pose. For instance, since answer set programming provides a programming language to their users, large body of research in the field concerns language features that go beyond logic programs discussed here. Such concerns are nonexistent in SAT.

Logic programs under answer set semantics is not the only formalism that serves a role of declarative programming front-end for SAT-like technology. For instance, East and Truszczyński [14], Ternovska and Mitchell [55, 75], Wittocx, Mariën, and Denecker [79, 80] introduce other formalisms. The aim of the efforts by Ternovska and Mitchell is to devise a declarative constraint programming framework that (i) takes the problem specification of a search problem formulated in classical first-order logic, (ii) performs the grounding and then (iii) uses a SAT solver to solve the ground formula. This framework implements model-expansion task introduced in [55]. Efforts by East and Truszczyński were inspired by answer set programming. They introduce a language that syntactically is closer to classical first-order logic than the language of logic programs. They then show how theories in this language can be (i) grounded, (ii) transformed into a propositional formula, and (iii) solved by means of SAT solvers. Systems by Wittocx, Maarten, and Denecker support the language called FO(ID) that extends classical first-order logic with inductive definitions [12]. Truszczyński [76] illustrates that despite syntactic and semantic differences between logic FO(ID) and logic programs under answer set semantics these frameworks are closely related and can be seen as different dialects of the same formalism. One property that all these languages share in common: they implement close world assumption – presumption that what is not currently known to be true is false. This observation hints that close world assumption is essential in design of logic-based declarative programming formalisms, in particular it allows effective grounding techniques. Also, Gebser et al. [21] propose another declarative approach, where the intended SAT clauses are specified in terms of logic rules with variables. This allows the user to write first-order specifications for intended clauses in a schematic way by exploiting term variables. They define the semantics of such specifications and provide an implementation harnessing ASP grounders to accomplish the grounding step of clauses. As we have seen grounding is an essential component of so far mentioned formalisms. Metodi and Codish [54] argue for another alternative declarative front-end for utilizing SAT technology. They propose to, first, use a general purpose constraint programming language BEE for formulating a problem. Second, these BEE specifications are translated into propositional CNF formulas so that SAT solvers are used to find solutions to a given problem.

The relation between propositional logic programs and propositional formulas in terms of expressiveness has been studied earlier in [35, 45, 69]. For example, Janhunen shows that translations from logic programs under answer set semantics to propositional formulas in classical logic cannot be done modularly. This is further underpinned by a complexity result given in [45]. In contrast, this paper focuses on key features of answer set programming that go beyond propositional logic programs. It highlights aspects of ASP, which form the basis for this prominent declarative programming paradigm. In particular, we note how the presence of first-order language enriched with numerous constructs enables effective modeling of search problem specifications. Also, an ability to express transitive closure by means of logic programs further enriches this modeling tool. Then, the language of logic programs is supported by two distinct processing tools: one responsible for grounding and another responsible for solving. Last but not least, we highlight the crucial role of a built-in closed world assumption that proved to be crucial not only in concise and intuitive modeling of problems, but also in the development of effective grounding and solving procedures.