Disjunctive Answer Set Solvers via Templates

Answer set programming is a declarative programming paradigm oriented towards difficult combinatorial search problems. A fundamental task in answer set programming is to compute stable models, i.e., solutions of logic programs. Answer set solvers are the programs that perform this task. The problem of deciding whether a disjunctive program has a stable model is Σ^P_2-complete. The high complexity of reasoning within disjunctive logic programming is responsible for few solvers capable of dealing with such programs, namely DLV, GnT, Cmodels, CLASP and WASP. In this paper we show that transition systems introduced by Nieuwenhuis, Oliveras, and Tinelli to model and analyze satisfiability solvers can be adapted for disjunctive answer set solvers. Transition systems give a unifying perspective and bring clarity in the description and comparison of solvers. They can be effectively used for analyzing, comparing and proving correctness of search algorithms as well as inspiring new ideas in the design of disjunctive answer set solvers. In this light, we introduce a general template, which accounts for major techniques implemented in disjunctive solvers. We then illustrate how this general template captures solvers DLV, GnT and Cmodels. We also show how this framework provides a convenient tool for designing new solving algorithms by means of combinations of techniques employed in different solvers.

READ FULL TEXT VIEW PDF
POST COMMENT

Comments

There are no comments yet.

Authors

page 1

page 2

page 3

page 4

05/03/2011

Transition Systems for Model Generators - A Unifying Approach

A fundamental task for propositional logic is to compute models of propo...
01/06/2010

Abstract Answer Set Solvers with Learning

Nieuwenhuis, Oliveras, and Tinelli (2006) showed how to describe enhance...
07/17/2021

Constraint Answer Set Programming: Integrational and Translational (or SMT-based) Approaches

Constraint answer set programming or CASP, for short, is a hybrid approa...
03/09/2000

Fages' Theorem and Answer Set Programming

We generalize a theorem by Francois Fages that describes the relationshi...
01/26/2019

Strong Equivalence and Program's Structure in Arguing Essential Equivalence between Logic Programs

Answer set programming is a prominent declarative programming paradigm u...
12/20/2013

Abstract Modular Systems and Solvers

Integrating diverse formalisms into modular knowledge representation sys...
04/10/2021

Convergence of Adaptive, Randomized, Iterative Linear Solvers

Deterministic and randomized, row-action and column-action linear solver...
This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

Answer set programming [Marek and Truszczyński (1999), Niemelä (1999), Baral (2003), Eiter et al. (1997), Gelfond and Lifschitz (1988), Gelfond and Lifschitz (1991)] is a declarative programming paradigm oriented towards difficult combinatorial search problems. The idea of answer set programming (ASP) is to represent a given problem with a logic program, whose answer sets correspond to solutions of the problem (see e.g., lif99a). ASP has been applied to solve problems in various areas of science and technology including graph-theoretic problems arising in zoology and linguistics [Brooks et al. (2007)], team building problems in container terminal [Ricca et al. (2012)], and product configuration tasks [Soininen and Niemelä (1999)]. A fundamental task in ASP is to compute stable models of logic programs. Answer set solvers are the programs that perform this task. There were sixteen answer set solvers participating in the recent Fifth Answer Set Programming Competition111https://www.mat.unical.it/aspcomp2014/FrontPage#Participant_Teams.

Gelfond and Lifschitz introduced logic programs with disjunctive rules [Gelfond and Lifschitz (1991)]. The problem of deciding whether a disjunctive program has a stable model is -complete [Eiter and Gottlob (1993)]. The problem of deciding whether a non-disjunctive program has a stable model is NP-complete. The high complexity of reasoning within disjunctive logic programming stems from two sources: first, there is a potentially exponential number of candidate models, and, second, the hardness of checking whether a candidate model is a stable model of a propositional disjunctive logic program is co-NP-complete. Only five answer set systems can solve disjunctive programs: dlv [Leone et al. (2006)], gnt [Janhunen et al. (2006)], cmodels [Lierler (2005)], clasp [Gebser et al. (2013)] and wasp [Alviano et al. (2013)].

Several formal approaches have been used to describe and compare search procedures implemented in answer set solvers. These approaches range from a pseudo-code representation of the procedures [Giunchiglia and Maratea (2005), Giunchiglia et al. (2008)], to tableau calculi [Gebser and Schaub (2006), Gebser and Schaub (2013)], to abstract frameworks via transition systems [Lierler (2008), Lierler (2011), Lierler and Truszczynski (2011)]. The latter method originates from the work by nie06, where authors propose to use transition systems to describe the Davis-Putnam-Logemann-Loveland (dpll) procedure [Davis et al. (1962)]. Nieuwenhuis et al. introduce an abstract framework called dpll graph, that captures what states of computation are, and what transitions between states are allowed. Every execution of the dpll procedure corresponds to a path in the dpll graph. Some edges may correspond to unit propagation steps, some to branching, some to backtracking.

Such an abstract way of presenting algorithms simplifies their analysis. This approach has been adapted [Lierler (2011), Lierler and Truszczynski (2011)] to describing answer set solvers for non-disjunctive programs including smodels, cmodels, and clasp. This type of graphs has been used to relate algorithms in precise mathematical terms. Indeed, once we represent algorithms via graphs, comparing the graphs translates into studying the relationships of underlying algorithms. More generally, the unifying perspective of transition systems brings clarity in the description and comparison of solvers. Practically, such graph representations may serve as an effective tool for analyzing, comparing, proving correctness of, and reasoning formally about the underlying search algorithms. It may also inspire new ideas in the design of solvers.

In this paper we present transition systems that suit multiple disjunctive answer set solvers. We define a general framework, a graph template, which accounts for major techniques implemented in disjunctive answer set solvers excluding backjumping and learning. We study formal properties of this template and we use the template to describe gnt, cmodels and dlv implementing plain backtracking. We then show how a graph template facilitates a design of new solving algorithms by means of combinations of techniques employed in different solvers. For instance, we present a new abstract solver that can be seen as a hybrid between cmodels and gnt. We also present how different solvers may be compared by means of transition systems. In particular, we illustrate a close relationship between answer set solvers dlv and cmodels through the related graphs. The fact that proposed framework does not account for backjumping and learning is one of the reasons that prevents us from capturing such advanced disjunctive answer set solvers as clasp and wasp. It is a direction of future work to investigate how the proposed framework can be adjusted to accommodate these solvers in full generality.

The paper is structured as follows. Section 2 introduces required preliminaries. Section 3 presents a first abstract solver related to cmodels. Section 4 defines our general template that accounts for techniques implemented in disjunctive solvers, and Section 5 uses this template to define abstract frameworks for disjunctive solvers. Proofs are presented in Section 6. Section 7 discusses related work and concludes with the final remarks.

The current paper builds on the content presented by blm14. It enhances the earlier work by introducing notions of a graph template, “propagator conditions”, and “approximating pairs“ that allow to more uniformly account for major techniques implemented in disjunctive answer set solvers. Complete proofs of the formal results are also provided.

2 Preliminaries

2.1 Formulas, Logic Programs, and Program’s Completion

Formulas.

Atoms are Boolean variables over . The symbols and are the and the constants, respectively. The letter denotes a literal, that is an atom or its negation , and is the complement of , i.e., literal for and literal for . Propositional formulas are logical expressions defined over atoms and symbols , in usual way. A finite disjunction of literals is a clause. We identify an empty clause with the symbol . A conjunction (resp. a disjunction) of literals will sometimes be seen as a set, containing each of its literals. Since a clause is identified with a set of its literals, there are no repetition of literals in a clause. A CNF formula is a finite conjunction (alternatively, a set) of clauses. Since a CNF formula is identified with a set of clauses, there are no repetition of clauses in a CNF formula.

For a conjunction (resp. a disjunction) of literals, by we denote the disjunction (resp. the conjunction) of the complements of the elements of . For example, denotes , while denotes . For a set  of literals, by we denote the disjunction of its elements and the conjunction of its elements; by we denote the set of atoms occurring in . For a set of sets of literals by we denote the set of atoms occurring in the elements of . For example, and . For a set  of literals, by we denote atoms that occur positively in . For instance, . For a set of atoms and a set  of literals, by we denote the maximal subset of over . For example, .

A (truth) assignment to a set of atoms is a function from to . An assignment satisfies a formula if evaluates to under this assignment. We call an assignment that satisfies formula a satisfying assignment or a (classical) model for . If evaluates to under an assignment, we say that this assignment contradicts . If has no model we say that is unsatisfiable. For sets and  of atoms such that , we identify with an assignment to as follows: if then maps to , while if then maps to . We also identify a consistent set of literals (i.e., a set that does not contain both a literal and its complement) with an assignment to as follows: if then maps to , while if then maps to . The set is a complete set of literals over the set of atoms if ; hence a consistent and complete set of literals over represents an assignment to .

Logic Programs.

A head is a (possibly empty) disjunction of atoms. A body is an expression of the form

(1)

where are atoms, and is the negation-as-failure operator. We identify body (1) with the following conjunction of literals

Expressions and are called positive and negative parts of the body, respectively. Recall that we sometimes view a conjunction of literals as a set containing all of its literals. Thus, given body we may write an expression , which means that atom occurs in the positive part of the body. Similarly, an expression means that the atom (or, in other words, expression ) occurs in the negative part of the body.

A disjunctive rule is an expression of the form , where is a head and is a body. If is empty we drop it from the expression. A disjunctive logic program is a finite set of disjunctive rules. We call a rule non-disjunctive if its head contains no more than one atom. A program is non-disjunctive if it consists of non-disjunctive rules. By we denote the set of atoms occurring in a logic program . If we understand as a classical logic implication, we can see any rule as logically equivalent to clause  (if is an empty clause then we view the rule as the clause ). This allows us to view a program as a CNF formula when useful. Conversely, we identify CNF formulas with logic programs: syntactically, every clause in a given formula is seen as a rule . For instance is seen as a rule .

The presented definition of a logic program accounts for propositional programs only. Indeed, all modern disjunctive answer set solvers consider propositional programs only. In practice, answer set programmers devise programs with variables. Software systems called grounders [Syrjänen (2001), Perri et al. (2007)] are used to take a logic program with variables as its input and produce a propositional program as its output so that the resulting propositional program has the same answer sets as the input program.

Reduct and Supporting Rules.

In the following definition we write rules in the form where denotes the positive part of the body, whereas denotes the negative part of the body. The reduct of a disjunctive program with respect to a set of atoms is obtained from  by deleting each rule  such that and replacing each remaining rule  with . A set  of atoms is an answer set of a program  if  is minimal among the sets of atoms that satisfy .

For a program , an atom , and a set of literals, we call any rule in a supporting rule for with respect to when .

A consistent and complete set of literals over is

  1. a classical model of if satisfies every rule in ;

  2. a supported model of if is a classical model of and for every atom there is a supporting rule for with respect to ;

  3. a stable model of program if is an answer set of .

Completion.

The completion of a program is the formula that consists of and the formulas

(2)

This formula has the property that any stable model of is a classical model of . The converse does not hold in general.

For a program and a consistent set of literals over , a set of atoms over is said to be unfounded [Leone et al. (1997)] on with respect to the program when for each atom and each rule such that , either of the following conditions hold

  1. ,

  2. , or

  3. .

We restate Theorem 4.6 from leo97 that relates the notions of unfounded set and stable model.

Theorem 1

For a program  and a consistent and complete set of literals over , is a stable model of if and only if is a classical model of and no non-empty subset of is an unfounded set on  with respect to .

This theorem is crucial for understanding key computational ideas behind modern answer set solvers.

2.2 Abstract dpll

The Davis–Putnam–Logemann–Loveland (dpll) algorithm from dav62 is a well-known method that exhaustively explores sets of literals to generate classical models of a propositional formula. Most satisfiability and non-disjunctive answer set solvers are based on variations of the dpll procedure that is a classical backtrack search-based algorithm. We now review the abstract transition system for dpll proposed by nie06, which is an alternative to common pseudo-code descriptions of backtrack search-based algorithms. For our purposes it is convenient to state dpll as the procedure applied to a logic program in order to find its classical models.

For a set of atoms, a record relative to  is a string composed of literals over or the symbol  so that there are no repetitions, and some literals may be annotated as . The annotated literals are called decision literals. Figure 1 presents the set of all records relative to the singleton set . We say that a record is inconsistent if it contains both a literal and its complement , or if it contains , and consistent otherwise. For instance, only five records in Figure 1, namely , , , and , are consistent. We will sometime view a record as the set containing all its elements disregarding their annotations. For example, a record is identified with the set . A basic state relative to  is either

  1. a record relative to ,

  2. where is a record relative to , or

  3. the distinguished state .

Figure 1: Records relative to .

Each program determines its dpll graph . The set of nodes of consists of the basic states relative to . A node in the graph is terminal if no edge originates from it. The state is called initial. The edges of the graph are specified by the transition rules presented in Figure 2.

Intuitively, every state of the dpll graph represents some hypothetical state of the dpll computation whereas a path in the graph is a description of a process of search for a classical model of a given program. The rule asserts that we can add a literal that is a logical consequence of our previous decisions and the given program. The rule asserts that we make an arbitrary decision to add a literal or, in other words, to assign a value to an atom. Since this decision is arbitrary, we are allowed to backtrack at a later point. The rule asserts that the present state of computation is inconsistent but can be fixed: at some point in the past we added a decision literal whose value we can now reverse. The rule asserts that the current state of computation has failed and cannot be fixed. The rule asserts that the current state of computation corresponds to a successful outcome.

We say that a graph checks a set of sets of literals when all the following conditions hold:

  1. is finite and acyclic;

  2. Any terminal state in is either or of the form ;

  3. If a state is reachable from the initial state in then ;

  4. is reachable from the initial state in if and only if is empty.

Figure 2: Transitions of the graph .
Proposition 1

For any program , the graph checks the classical models of .

Thus, to decide the satisfiability of a program  it is enough to find a path leading from node to a terminal node. If it is , then has no classical models. Otherwise, has classical models. For instance, let be

Figure 3 presents two paths in from the node to the node . Every edge is annotated on the left by the name of the transition rule that gives rise to this edge in . The node is terminal. Thus, Proposition 1 asserts that is satisfiable and is a classical model of .

Figure 3: Examples of paths in .

A path in the graph is a description of a process of search for a classical model of a program . The process is captured via applications of transition rules. Therefore, we can characterize the algorithm of a solver that utilizes the transition rules of by describing a strategy for choosing a path. A strategy can be based on assigning priorities to transition rules of so that a solver never applies a rule in a node if a rule with higher priority is applicable to the same node. The dpll procedure is captured by the priorities ordered as we stated rules in Figure 2. For instance, transition rule  has the highest priority. In Figure 3, the path on the left complies with the dpll priorities: Thus, it corresponds to an execution of the dpll procedure. The path on the right does not: it uses when is applicable. The proof of Proposition 1 follows the lines of the proof of Theorem 2.13 in nie06222This work defines a different dpll graph, avoiding the reference to the transition rule . The presence of this rule in this presentation is important for the generalizations of the dpll graph we introduce in the sequel..

Abstract Answer Set Solver for Non-disjunctive Programs.

lier10 illustrated that extending  by a transition rule

captures a backtrack-search procedure for finding answer sets of non-disjunctive programs. Many answer set solvers for such programs can be seen as extensions of this procedure [Lierler and Truszczynski (2011)].

3 A Two-Layer Abstract Solver

The problem of deciding whether a disjunctive program has a stable model is -complete [Eiter and Gottlob (1993)]. This translates into the following:  (i) there is an exponential number of possible candidate models, and (ii) the problem of deciding whether a candidate model is an answer set of a disjunctive logic program is co-NP-complete. The latter condition differentiates algorithms of answer set solvers for disjunctive programs from the procedures for non-disjunctive programs. Indeed, the problem of deciding whether a candidate model is an answer set of a non-disjunctive program is tractable.

A common architecture of a disjunctive answer set solver is composed of two layers corresponding to the two above conditions: a generate layer and a test layer, each typically based on dpll-like procedures. In particular:

  • The generate layer is used to obtain a set of candidates that are potentially stable models.

  • The test layer is used to verify whether a candidate (produced by the generate layer) is a stable model of the given program.

We now proceed to present a graph that captures such two-layer architecture. It is based on instances of the dpll procedure for both its generating task and its testing task. We then illustrate how the transition system can be used to capture the disjunctive answer set solver cmodels in its basic form.

3.1 A Two-Layer Abstract Solver via dpll

Figure 4: The transition rules of the graph .

We start by extending the notion of a basic state to accommodate for generate and test layers. We call symbols and labels. A state relative to sets  and  of atoms is either

  1. [noitemsep]

  2. a pair , where and  are records relative to  and , respectively, and is a label (either symbol or ),

  3. , where is a record relative to , or

  4. the distinguished state .

We say that a set of literals covers a program if . We say that a function from a program to another program is a generating (program) function if for any program , . We call a function from a program  and a consistent set of literals covering to a non-disjunctive program  a witness (program) function. Intuitively, a program resulting from a witness function is a witness (program) with respect to  and . For a program and a witness function , by we denote the union of for all possible consistent and complete sets of literals over .

We are now ready to define a graph for a generating function , a witness function and a program . The set of nodes of consists of the states relative to sets and . The state is called initial. The edges of the graph are specified by the transition rules presented in Figure 4. The graph can be used for deciding whether a program has a classical model such that the witness is unsatisfiable.

Proposition 2

For any generating function , any witness function and any program , the graph checks the classical models of such that is unsatisfiable.

Informal Account of the Two-Layer Abstract Solver.

Each of the rules of the graph is placed into one of the three groups Left, Right, and Crossing. The left-rules of capture the generate layer that applies the dpll procedure to the program produced by the generating function. The right-rules of capture the test layer that applies the dpll procedure to the computed witness program. The label (resp. ) suggests that currently the computation is within the generate (resp. test) layer. The left-hand-side (resp. right-hand-side ) of the state records the computation state due to the generate (resp. test) layer. The crossing rules form a bridge between the two layers.

It turns out that the left-rules no longer apply to a state of the form only when is a classical model of . Thus, when a classical model of is found, then the is used and a witness program with respect to is computed. If no classical model is found for the witness program, then rule applies, which brings us to a terminal state , suggesting that represents a solution to a given search problem. It turns out that no right-rules applies in a state of the form only when is a classical model for the witness program. Thus, the set of literals is not such that is unsatisfiable and the dpll procedure of the generate layer, embodied by the left-rules, proceeds with the search, after backtracking through . In the case when cannot be applied, it follows that no other candidate can be found by the generate layer, so the transition leading to is the only available one from such a state.

3.2 Abstract basic cmodels

We now relate the graph to the procedure dp-assat-proc from lie05. This procedure forms the basis of the answer set solver cmodels. Yet, it does not account for backjumping and learning techniques, implemented in cmodels.

Given a disjunctive program , the answer set solver cmodels starts its computation by computing a CNF formula that corresponds to the clausified program completion of . The dpll procedure is then applied to . The test layer of the cmodels computation relies on the programs produced by a witness program function called that intuitively tests minimality of found models of completion.

To be complete in our presentation, we now review the details of and functions [Lierler (2010)]. To construct , cmodels introduces an auxiliary atom for every body  occurring in . The atom is an explicit definition for , it is true if and only if is true. Also every disjunctive rule gives rise to as many auxiliary variables as there are atoms in the head of the rule: for a disjunctive rule and every atom , an auxiliary atom is equivalent to a conjunction , where is . Formulas (3) and (4) present the definitions of and for a program . The first four lines of the definition of the CNF formula concern clausification of the introduced explicit definitions, namely and . The last two lines encode clausified completion with the use of and .

(3)
(4)

Intuitively, cmodels uses the program as an approximation of during the generate-layer computation. Indeed, any stable model of is also a classical model of . The converse does not always hold. Thus, classical models of must be checked. For a classical model of , a program produced by has no classical models iff is a stable model of . In fact, any model  of is such that it satisfies the reduct , while . In such case, is not an answer set of by definition and, consequently, is not a stable model of .

By we denote the graph . Proposition 3 below illustrates that the graph can be used for deciding whether a given program has a stable model, similarly as the graph can be used for deciding whether has a classical model.

Proposition 3

For any program , the graph checks the stable models of .

The graph captures the search procedure of dp-assat-proc of cmodels. The dp-assat-proc algorithm follows the priorities on its transition rules as they are ordered in Figure 4. We often use this convention when describing other procedures in the sequel.

4 Graph Templates

The differences in design choices of disjunctive answer set solvers obscure the understanding of their similarities. In blm14, transition systems exemplified by the graph were used to capture several disjunctive solvers, namely, cmodels, gnt and dlv implementing backtracking. The transitions systems made the similarities that these solvers share explicit. For example, all solvers are based on a two-layer approach in the spirit of the dp-assat-proc algorithm. In this work, we make an additional move towards a unifying framework for capturing two-layer methods. We introduce a graph template that we then use to encompass disjunctive solvers cmodels, gnt and dlv.

4.1 A Single Layer Graph Template

In the next section we will define a graph template suitable for capturing two-layer computation of disjunctive answer set solvers. As a step in this direction, we describe here a simpler graph template that can be used to capture the dpll procedure by encapsulating the dpll graph. We also show that this template can encapsulate a graph capturing the computation underlying the algorithm of answer set solver smodels for non-disjunctive programs.

Template.

A function from a program and a set of literals over to a set of literals over is called a propagator condition or, shortly, p-condition. Figure 5 presents four p-conditions, namely, , , , and . For a set of p-conditions, a program and a set  of literals, by we denote the set of literals . Intuitively, if each image through a p-condition is a set of possible outcomes, this set represents the union of the possible outcomes through .

Figure 5: Propagator conditions.
Definition 1

Given a a program and a set  of p-conditions, a dpll graph template is a graph of which nodes are the basic states relative to and edges are specified by the transition rules , , , presented in Figure 2 and the transition rule

(5)

For instance, the instantiation of the dpll graph template results in the dpll graph . Indeed, by definition these graphs share the same nodes as well as their rules , , , and coincide. Then, one can see that if and only if the transition rule in is applicable in and supports the transition to a state , which shows that the rule and the rule coincide when .

Instantiation.

We call types the elements of the set . In the following, by -model, -model and -model we denote classical, supported, and stable models, respectively. We also use letter to denote a variable over set of types. We say that a set of p-conditions is -sound if for any program , for any set of literals, and for any -model of  such that , it also holds that . Note that any -sound set of p-conditions is -sound, and any -sound set of p-conditions is -sound. We say that a set of p-conditions is -complete when for any program  and any consistent and complete set of literals over , set is a -model of if and only if . For a type , we say that a set of p-conditions is -enforcing if is both -sound and -complete.

Next theorem summarizes properties of several sets of p-conditions:

Theorem 2

The following statements hold:

  1. The set is -enforcing;

  2. All the subsets of that contain are -enforcing; and

  3. All the subsets of that contain are –enforcing.

We are now ready to state the main result of this section.

Theorem 3

For any program , any type , and any -enforcing set of p-conditions , the graph checks the -models of .

Theorems 2 and 3 give rise to families of valid solvers for deciding where classical, supported, or stable models exist for a program. For instance, for a non-disjunctive program , the graph coincides with the graph sm [Lierler (2011)] that captures computation of answer set solver smodels [Simons et al. (2002)]. The graph coincides with the graph atleast [Lierler (2011)] that provides a procedure for deciding whether a non-disjunctive program has supported models. For a disjunctive program  the same single layer graph forms a procedure for deciding whether has a stable model. Note, however, that generally the problem of deciding whether is np-complete for the case when is disjunctive.

4.2 A Two-Layer Graph Template

We extend here the approach of Section 4.1 to capture two-layer methodology of disjunctive solvers.

Figure 6: Transition rules of the graph template .
Definition 2

Given a program , sets and of p-conditions, a generating function , and a witness function , a two-layer template graph is a graph defined as follows:

  • The set of nodes is, as in the previous two-layer graphs, the set of states relative to and ; and

  • The transition rules are the rules presented in Figure 4 except the rules and , that are replaced by the rules and presented in Figure 6.

Description of the Template.

We call the state initial. Note how the rules and in refer to the parameters , , and of the graph template. Varying these parameters will allow us to specify transition systems that capture different disjunctive answer set solvers. Intuitively, the parameters and are sets of p-conditions defining a propagation rule on generate and test side of computation, respectively.

The instantiation of the two-layer graph template results in . Indeed, the graphs share the same nodes. Also their rules , , , , , and coincide. It is easy to see that a literal is in if and only if the transition rule in is applicable in and supports the transition to a state . Thus, the transition rule supports the transition from to if and only if the transition rule supports the same transition. A similar statement holds for the case of and .

Recall that in Section 3.2 we showed that cmodels implementing backtracking can be defined using the graph . The fact that instantiation coincides with illustrates that the introduced template is sufficient for capturing existing solvers. Next section demonstrates that the proposed template is suitable for capturing gnt and dlv.

Instantiation: Approximating and Ensuring Pairs.

In the definition of the two-layer template graph we pose no restrictions on its four key parameters: sets , of p-conditions, and generating and witness functions , . In practice, when this template is utilized to model, characterize, and elicit disjunctive solvers these four parameters exhibit specific properties. We now introduce terminology that allows us to specify essential properties of these parameters that will translate into correctness of solvers captured by properly instantiated template. On the one hand, we introduce the conditions on generating and witness functions under which we call these functions ”approximating“ and ”ensuring“, respectively. On the other hand, we couple these conditions with restrictions on sets of p-conditions so that we can speak of (i) approximating-pair for a set of p-conditions and a generating function , and (ii) ensuring-pair for a set of p-conditions and a witness function . For such pairs, the template instantiation results in a graph that checks stable models of . As a result, when we characterize such solvers as gnt and dlv by means of the two-layer template we focus on (i) specifying their generating and witness function as well as their sets of p-conditions, and (ii) illustrating that they form proper approximating and ensuring pairs. This also brings us to the realization that an inception of a novel solver can be triggered by a creation of a novel approximation and ensuring pairs or their combinations. We now make these ideas precise.

For types and , we say that a generating function is -approximating with respect to type if for any program :

  1. For any stable model of there is a -model of such that ; and

  2. For any -model of , is a -model of .

Consider the generating function that returns a CNF formula, which stands for the completion converted to CNF using straightforward equivalent transformations. In other words, consists of clauses of two kinds

  1. the rules of the program written as clauses , and

  2. formulas of from (2) converted to CNF using the distributivity of disjunction over conjunction.333It is essential that repetitions are not removed in the process of clausification. For instance,

The function is -approximating with respect to . Indeed,

  1. any stable model of a program is also a -model of , and

  2. any -model of is a -model of .

Since any supported model is also a classical model, the function is also -approximating with respect to . Note that when a generating function is -approximating with respect to , then enumerating all -models of results in enumerating some -models of modulo a restriction to .

For types and , and a witness function , we say that is -ensuring with respect to when for any set  of literals covering such that is -model of , is a stable model of if and only if results in a program that has no -model.

For instance, the witness function  is -ensuring with respect to . Since any -model is also a -model, the function is also -ensuring with respect to . It is easy to see that when a witness function is -ensuring with respect to , then given any -model  of a program we may use the function to test that is also a stable model of . Indeed, an application of resulting in a program that has no -models translates into the statement that is a stable model of .

These newly defined concepts of approximating and ensuring functions provide the following characterization for the set of stable models of a program .

Proposition 4

For any types , and , generating function that is -approximating with respect to , witness function that is -ensuring with respect to , and program , the set of all stable models of is

We now introduce the notion of ensuring and approximating pairs that permit an operational use of generating and witness functions, by matching them with a relevant set of propagators. We call a pair of a set of p-conditions and a generating function an approximating-pair with respect to if for some type , the set is -enforcing and the function is -approximating with respect to . For example, the pair is an approximating-pair with respect to as well as to . The is also an approximating-pair with respect to as well as to .

We call a pair of a set of p-conditions and a witness function an ensuring-pair with respect to if for some type , the set is -enforcing and the function is -ensuring with respect to . For example, the pair is an ensuring-pair with respect to any defined type.

We are now ready to state the main result of this section.

Theorem 4

For any program , any type , any approximating-pair with respect to , and any ensuring-pair with respect to , the graph checks the stable models of .

Theorem 4 illustrates how the template can serve as a framework for defining transitions systems that result in correct algorithms for deciding whether a program has a stable model. The facts that is an approximating-pair with respect to and that is an ensuring-pair with respect to , together with Theorem 4, subsume the result of Proposition 3.

We now state propositions that capture interesting properties about states of the graph . The former proposition concerns states with the label , the latter concerns states with the label .

Proposition 5

For any type , generating function , witness function , -enforcing set of p-conditions , set of p-conditions , and program , if no left-rule is applicable in some state in reachable from the initial state, then is a -model of .

Proposition 6

For any types and , generating function witness function , -enforcing set of p-conditions , -enforcing set of p-conditions , program , and a state in reachable from the initial state, the following conditions hold:

  1. is defined,

  2. is a set of literals over ,

  3. is a -model of , and

  4. If no right-rule is applicable to then is a -model of .

5 Applications of the Template

Section 3.2 illustrates how cmodels implementing backtracking can be defined using the graph , while the previous section states that the instantiation of the two-layer graph template results in . Thus, this template is suitable for capturing computations of cmodels. In this section, we show how the template also captures the solvers gnt and dlv without backjumping. Then, we discuss how the framework facilitates the design of new abstract solvers and their comparison, by means of inspecting the structures of the related graphs.

Abstract gnt.

We now show how the procedure underlying disjunctive solver gnt can be captured by the two-layer template. Unlike solver cmodels that uses the dpll procedure for generating and testing, system gnt uses the smodels procedure for respective tasks. Recall that the smodels procedure finds stable models for non-disjunctive logic programs, while the dpll procedure finds classical models. The graph sm (Section 4.1) captures the computation underlying smodels just as the graph captures the computation underlying dpll. It forms a basis for devising the transition system suitable to describe gnt. The graph describing the general structure of gnt is obtained from the graph template that rely on the set of p-contitions.444The graph template corresponds to the graph defined in [Brochenin et al. (2014)].

jan06 define the generating function and the witness function  used in gnt. We present these definitions in (6) and (7).555The presented functions and capture the essence of functions and defined by Janhunen et al., but they are not identical. Our language of disjunctive programs includes rules with empty heads. This allows us a more concise description. For a disjunctive program , by we denote the set of non-disjunctive rules of , by we denote the set of disjunctive rules . For each atom in