Stable-Unstable Semantics: Beyond NP with Normal Logic Programs

by   Bart Bogaerts, et al.

Standard answer set programming (ASP) targets at solving search problems from the first level of the polynomial time hierarchy (PH). Tackling search problems beyond NP using ASP is less straightforward. The class of disjunctive logic programs offers the most prominent way of reaching the second level of the PH, but encoding respective hard problems as disjunctive programs typically requires sophisticated techniques such as saturation or meta-interpretation. The application of such techniques easily leads to encodings that are inaccessible to non-experts. Furthermore, while disjunctive ASP solvers often rely on calls to a (co-)NP oracle, it may be difficult to detect from the input program where the oracle is being accessed. In other formalisms, such as Quantified Boolean Formulas (QBFs), the interface to the underlying oracle is more transparent as it is explicitly recorded in the quantifier prefix of a formula. On the other hand, ASP has advantages over QBFs from the modeling perspective. The rich high-level languages such as ASP-Core-2 offer a wide variety of primitives that enable concise and natural encodings of search problems. In this paper, we present a novel logic programming--based modeling paradigm that combines the best features of ASP and QBFs. We develop so-called combined logic programs in which oracles are directly cast as (normal) logic programs themselves. Recursive incarnations of this construction enable logic programming on arbitrarily high levels of the PH. We develop a proof-of-concept implementation for our new paradigm. This paper is under consideration for acceptance in TPLP.


page 1

page 2

page 3

page 4


Beyond NP: Quantifying over Answer Sets

Answer Set Programming (ASP) is a logic programming paradigm featuring a...

Inconsistency Proofs for ASP: The ASP-DRUPE Format

Answer Set Programming (ASP) solvers are highly-tuned and complex proced...

The Power of Non-Ground Rules in Answer Set Programming

Answer set programming (ASP) is a well-established logic programming lan...

Planning with Incomplete Information in Quantified Answer Set Programming

We present a general approach to planning with incomplete information in...

Abduction, ASP and Open Logic Programs

Open logic programs and open entailment have been recently proposed as a...

Translating NP-SPEC into ASP

NP-SPEC is a language for specifying problems in NP in a declarative way...

On Validating Boolean Optimizers

Boolean optimization finds a wide range of application domains, that mot...

1 Introduction

With the launch of the idea that stable models [Gelfond and Lifschitz (1988)] of a logic program can be used to encode search problems, a new programming paradigm, called Answer Set Programming (ASP) was born [Marek and Truszczyński (1999), Niemelä (1999), Lifschitz (1999)]. Nowadays, the fact that normal logic programs can effectively encode NP-complete decision and function problems is exploited in applications in many different domains such as robotics [Andres et al. (2015)]

, machine learning

[Janhunen et al. (2015), Bruynooghe et al. (2015)], phylogenetic inference [Koponen et al. (2015), Brooks et al. (2007)], product configuration [Tiihonen et al. (2003)], decision support for the Space Shuttle [Nogueira et al. (2001)], e-Tourism [Ricca et al. (2010)], and knowledge management [Grasso et al. (2009)].

Tackling search problems beyond NP with ASP requires one to use more expressive logic programs than the normal ones. To this end, the class of disjunctive programs [Gelfond and Lifschitz (1991)] is the most prominent candidate. As shown by Eiter and Gottlob (1995), the main decision problems associated to disjunctive programs are - and -complete, depending on the reasoning mode, i.e., credulous vs. cautious reasoning. But when it comes to applications, one encounters disjunctive encodings less frequently than encodings as normal logic programs. This is also witnessed by the benchmark problems submitted to ASP competitions Calimeri et al. (2016). Such a state of affairs is not due to a lack of application problems since many complete problems from the second level of the PH are known. Neither is it due to a lack of implementations, since state-of-the-art ASP solvers such as dlv Leone et al. (2006) and clasp Drescher et al. (2008); Gebser et al. (2015) offer a seamless support for disjunctive programs.

An explanation for the imbalance identified above can be found in the essentials of disjunctive logic programming when formalizing problems from the second level of the PH. There are results Ben-Eliyahu and Dechter (1994) showing that such programs must involve head cycles, i.e., cyclic positive dependencies established by the rules of the program that intertwine with the disjunctions in the program. Such dependencies may render disjunctive programs hard to understand and to maintain. Moreover, the existing generic encodings of complete problems from the second level of the PH as disjunctive programs are based on sophisticated saturation Eiter and Gottlob (1995) or meta-interpretation Gebser et al. (2011) techniques, which may turn an encoding inaccessible to a non-expert. Eiter and Polleres (2006) identify the limitations of subprograms that act as (co-)NP-oracles and are embedded in disjunctive programs using the saturation technique. Summarizing our observations, the access to the underlying oracle is somewhat cumbersome and difficult to detect from a given disjunctive program. Interestingly, the oracle is better visible in native implementations of disjunctive logic programs Janhunen et al. (2006); Drescher et al. (2008) where two ASP solvers cooperate: one is responsible for generating model candidates and the other for testing the minimality of candidates. In such an architecture, a successful minimality test amounts to showing that a certain subprogram has no stable models.

In other formalisms, the second level of the PH is reached differently. For instance, quantified Boolean formulas (QBFs) Stockmeyer and Meyer (1973), record the interface between existentially and universally quantified subtheories, intuitively corresponding to the generating and testing programs mentioned above, explicitly in the quantifier prefix of the theory. From a modelling perspective, on one hand, QBFs support the natural formalization of subproblems as subtheories and the quantifications introduced for variables essentially identify the oracles involved. On the other hand, logic programs also have some advantages over QBFs. Most prominently, they allow for the natural encodings of inductive definitions, not to forget about default negation, aggregates and first-order features available in logic programming. The rich high-level modelling languages such as ASP-Core-2 Calimeri et al. (2013) offer a wide variety of primitives that are not available for QBFs and require substantial elaboration if expressed as part of a QBF.

In this paper, we present a novel logic programming–based modeling paradigm that combines the best features of ASP and QBF. We introduce the notion of a combined logic program which explicitly integrates a normal logic program as an oracle to another program. The semantics of combined programs is formalized as stable-unstable models whose roots can be recognized from earlier work of Eiter and Polleres (2006). Our design directly reflects the generate-and-test methodology discussed above, enabling one to encode problems up to the second level of the PH. Compared to disjunctive programs, our approach is thus closer to QBFs and if the same design is applied recursively, our new formalism can be adapted to tackle problems arbitrarily high in the PH, in analogy to QBFs. We develop a proof-of-concept solver for our new formalism on top of the recently introduced solver sat-to-sat Janhunen et al. (2016), which is based on an architecture of two interacting, conflict-driven clause learning (CDCL) SAT solvers. The solver capable of searching for stable-unstable models is obtained using the methodology of Bogaerts et al. (2016a), who automatically translate a second-order specification, combined with data that represents the involved ground programs in a reified form, into a sat-to-sat specification. The details of the solver architecture are hidden from the user so that a user experience similar to native ASP solvers is obtained, where the user inputs two logic programs in a familiar syntax and the solver produces answer sets.

The rest of this paper is structured as follows. In Section 2, we discuss related work in more detail. We recall some basic notions of logic programs in Section 3. Afterwards, in Section 4, we present our new logic programming methodology. We illustrate how it can be used to tackle some problems from the second level of the PH in Section 5. In Section 6, we show how our new formalism can be implemented on top of sat-to-sat. We show how our formalism naturally extends beyond the second level of the PH in Section 7 and conclude the paper in Section 8.

2 Related Work

A fundamental technique to encode -complete problems as disjunctive programs is known as saturation. The technique goes back to the -completeness proof for the existence of stable models in the case of disjunctive programs Eiter and Gottlob (1995). Although saturation can be applied in a very systematic fashion to some programs of interest, Eiter and Polleres (2006) identify the impossibility of having negation as a central limitation of oracles encoded by saturation, rendering the oracle call to a bare minimality check rather than showing that an oracle program has no stable models. This limitation can be partially circumvented using meta-interpretation Eiter and Polleres (2006); Gebser et al. (2011), but these techniques do not necessarily decrease the conceptual complexity of disjunctive programming from the user’s perspective.

The approach of Eiter and Polleres (2006) is perhaps most closely related to our work. They present a transformation of two head-cycle free (HCF) disjunctive logic programs , where and form the generating and testing programs, into a disjunctive program . In our terminology, the stable-unstable models of the combined program are in one-to-one correspondence with the stable models of . Thus, their approach is based on essentially the same base definition. However, their transformation counts on meta-interpretation and is encoded as a disjunctive meta program to capture the intended semantics of . A similar meta-encoding can be obtained using the approach of Gebser et al. (2011), but stable-unstable semantics is not explicit in their work. Since these meta programming approaches use disjunctive logic programs as the back end formalism, they are inherently confined to the second level of the PH. Our approach, on the other hand, easily generalizes for the classes of the entire PH, as to be shown in Section 7. Moreover, when Eiter and Polleres (2006) translate into a disjunctive logic program the essential structural distinction between and is lost. Many disjunctive answer set solvers Janhunen et al. (2006); Drescher et al. (2008) try to recover this interface due to their internal data structures. In our approach, the generate-and-test structure of the original problem is explicitly present in the input presented to the solver.

While meta programming can be viewed as a front-end to disjunctive logic programming, the goal of our work is to foster the idea of generate-and-test programs as a basis for a logic programming methodology that complexity-wise covers the entire PH. In this paper, we present a proof-of-concept implementation based on the recursive sat-to-sat solver architecture Janhunen et al. (2016); Bogaerts et al. (2016b). It is reasonable to expect that such an architecture can be realized in the future using native ASP solvers as building blocks, too, thus eliminating the need for second-order interpretation.

Another formalization of a similar idea was worked out by Eiter et al. (1997), based on the theory of generalized quantifiers Mostowski (1957); Lindström (1966). The semantics we propose for combined logic programs can be obtained as a special case of a (stratified) logic program with generalized quantifiers Eiter et al. (1997). One important difference is that in our approach, the interaction between the two programs is fixed: one program serves as generator and the second as a tester program. The approach of Eiter et al. (1997) is more general in the sense that it allows for other types of interaction as well. The price to pay for this generality is that the interaction between programs needs to be specified explicitly by users, resulting in a more error-prone modelling process. Moreover, in our approach, the input expected from the user is a set of source files in a familiar syntax (ASP-Core-2), requiring no syntactic extension for quantification.

3 Preliminaries: Logic Programming

In this section, we recall some preliminaries from logic programming. The new semantics is only formulated for propositional programs but, in practice, the users are not expected to write propositional programs. Instead, they are supposed to use grounders, such as the state-of-the-art grounder Gringo, to transform first-order programs to propositional ones.

A vocabulary is a set of symbols, also called atoms; vocabularies are denoted by . A literal is an atom or its negation. A logic program over vocabulary is a set of rules of form


where ’s, ’s, and ’s are atoms in . We call the head of , denoted , and the body of , denoted . A program is normal (resp. positive) if (resp. ) for all rules in . If , we simply write .

An interpretation of a vocabulary is a subset of . An interpretation is a model of a logic program if, for all rules in , whenever is satisfied by , so is . The reduct of with respect to , denoted , is the program that consists of rules for all rules of the form (1) in such that for all . An interpretation is a stable model of if it is a -minimal model of Gelfond and Lifschitz (1988).

Parameterized logic programs have been implicitly present in the literature for a long time, by assigning a meaning to intensional databases. They have been made explicit in various forms Gelfond and Przymusinska (1996); Oikarinen and Janhunen (2006); Denecker and Vennekens (2007); Denecker et al. (2012). We briefly recall the basics. Assume that and is a logic program over such that no atoms from occur in the head of a rule in . We call a parameterized stable model of with respect to parameters if is a stable model of . Parameters are also known as external, open, or input atoms.

From time to time, we use syntactic extensions such as choice rules, constraints, and cardinality atoms in this paper. A cardinality atom (with being literals and ) is satisfied by if . A choice rule is a rule with a cardinality atom in the head. A constraint is a rule with an empty head. An interpretation satisfies a constraint if it does not satisfy . These language constructs can all be translated to normal rules Bomanson and Janhunen (2013). We also sometimes use the colon syntax for conditional literals as a way to succinctly specify a set of literals in the body of a rule or in a cardinality atom Gebser et al. (2015).

4 Stable-Unstable Semantics

The design goal of our new formalism is to isolate the logic program that is acting as an oracle for another program. Thus, we would like to find a stable model for a program while showing the non-existence of stable models for the oracle program given . Following this intuition, we formalize the pair of a generating program and a testing program as follows.111The terminology goes back to GnT, one of the early solvers developed for disjunctive programs Janhunen et al. (2006).

Definition 4.1 (Combined logic program)

A combined logic program is pair of normal logic programs and with vocabularies and such that is parameterized by and is parameterized by .

The vocabulary of the program is ; it consists of all symbols that are “visible” to the outside. Symbols in are considered to be quantified internally. The use of normal programs in the definition of combined logic programs, or combined programs for short, is a design decision aiming at programs that are easily understandable (compared to, for instance, disjunctive programs with head-cycles). In principle, our theory also works when replacing normal programs with another class of programs. Our next objective is to define the semantics of combined programs which should not be a surprise given the above intuitions.

Definition 4.2 (Stable-unstable model)

Given a combined program with vocabularies and , a -interpretation is a stable-unstable model of if the following two conditions hold:

  1. is a parameterized stable model of with respect to (the parameters of ) and

  2. there is no parameterized stable model of that coincides with on (i.e., such that ).

The fact that a -interpretation is a stable-unstable model of is denoted . Note that the testing program stands for the non-existence of stable models. If , the programs truly interact. Otherwise, we call independent.

Example 4.3

Let and where has vocabulary and parameters , and has vocabulary and parameters . The stable models of and are, respectively, and . Notice that . The combined program has parameters and has only one stable-unstable model since all other stable models of coincide with a stable model of on .

Theorem 4.4

Deciding the existence of a stable-unstable model for a finite combined program is -complete in general, and -complete for independent combined programs.

The theorem is a straightforward consequence of known complexity results. The membership in follows directly from the definition of and the fact that deciding whether a normal logic program has a stable model is NP-complete Marek and Truszczyński (1999). For hardness in the general case, we recall that Janhunen et al. (2006) have shown that any disjunctive logic program can be represented as a pair of normal programs whose stable-unstable models essentially capture the stable models of .

In the case of an independent input , the decision problem conjoins an NP-complete problem (showing that has a stable model) and a co-NP-complete problem (showing that has no stable models). Thus, membership in is immediate. The hardness is implied by Niemelä’s reduction 1999 that translates a set of clauses into a normal logic program , when applied to instances of the -complete SAT-UNSAT problem.

Example 4.5

Any of the form with a Boolean formula in DNF can be encoded as a combined program as follows. Let be a logic program that expresses the choice of a truth value for every variable in using two normal rules and where is new. Also, let be a logic program that similarly chooses truth values for every in and contains for each conjunction in the DNF a rule where is a new atom that is true if is satisfied. Moreover, let have the rule . This rule enforces that must be false in models of . As such corresponds to the sentence . Since , we thus find that is valid iff has a stable-unstable model.

It follows from Theorem 4.4 that the theoretical expressiveness of combined programs equals that of s. There are, however, several reasons why one would prefer combined programs. Firstly, logic programs are equipped with rich, high-level, first-order modeling languages. Secondly, logic programs allow for natural encodings of inductive definitions. These reasons are comparable to the advantages of logic programs on the first level of the hierarchy in contrast with pure SAT. For instance, the former can naturally express reachability in digraphs, while the latter requires a non-trivial encoding, which is non-linear in the size of the input graph. The advantage of combined programs over s is analogous when solving problems on the second level. The expressive power of inductive definitions and the high-level modeling language are available both in and in . We exploit this when presenting examples in the next section.

5 Applications

The goal of this section is to present some applications of stable-unstable programming. We will focus on modelling aspects, i.e., how certain application problems can be represented. The programs to be presented are non-ground (and may also use some constructs present in ASP-Core-2, such as arithmetic) while the stable-unstable semantics was formulated for ground programs only. However, in practice, input programs are first grounded and thus covered by the propositional semantics. Hence, the user has all high-level primitives of ASP at his/her disposal.

5.1 Winning Strategies for Parity Games

Parity games, to be detailed below, have been studied intensively in computer aided verification since they correspond to model checking problems in the -calculus. We show how to represent parity game instances as combined programs. A parity game consists of a finite graph , where is a set of nodes, a set of arcs, an initial node, and partition into two subsets, respectively owned by an existential and a universal player, and assigns a priority to each node. All nodes are assumed to have at least one outgoing arc. A play in a parity game is an infinite path in starting from . We denote such a play by a function . A play is generated by setting and, at each step , asking the player who owns node to choose a following node such that . The existential player wins if is an even number. Otherwise, the universal player wins. A strategy for a player is a function that takes a finite path in with and returns a node such that . A play conforms to if, whenever , it holds that . A strategy is a winning strategy for if wins all plays that conform to . A strategy is called positional if only depends on . Two important properties of parity games are that (i) exactly one player has a winning strategy and (ii) a player has a winning strategy if and only if it has a positional winning strategy Emerson and Jutla (1991).

Using the above properties, we provide an intuitive axiomatization to capture winning strategies of the existential player in a given parity game. The generator program is simple: it guesses a (positional) strategy (called ) for player . The test program is more involved. It guesses a positional strategy (called ) for player and accepts if it wins against . To perform the acceptance test, we define the set of nodes that appear infinitely often on the unique play that conforms to both strategies. We reject if the minimum priority of nodes in is an even number. Hence, has a stable-unstable model if can find a positional strategy for the existential player such that cannot find any positional strategy to defeat . The entire programs can be found below.

Deciding if a parity game has a winning strategy for the existential player has been encoded in difference logic and in SAT Heljanko et al. (2012). We see two reasons why our encoding as a combined program can still be of interest. First, it is an intuitive encoding that corresponds directly to the problem definition. Second, to the best of our knowledge, it is the first encoding whose size is linear in the size of the graph, i.e., . The existing difference logic encoding has size and the existing SAT encoding (which is developed on top of the difference logic encoding) has size Heljanko et al. (2012).

5.2 Conformant Planning

(Classical) planning is the task of generating a plan (i.e., a sequence of actions) that realizes a certain goal given a complete description of the world. Conformant planning is the task of generating a plan that reaches a given goal given a partial description of the world (certain facts about the initial state and/or actions’ effects are unknown). In this section, we focus on deterministic conformant planning problems: problems where the state of the world at any time is completely determined by the initial state and the actions taken. It is well-known that deciding if a conformant plan exists is a -complete decision problem.

To encode conformant planning problems in our formalism, we assume a vocabulary is given. Here, , and represent a sequence of actions, the state of the world over time, and the initial state of the world, respectively. We also assume that contains an atom with intended interpretation that the goal of the planning problem is reached at some time. Furthermore, we assume that is partitioned in and , where are the atoms subject to uncertainty (to which our plan should be conformant). Let be a logic program containing a rule for each . Intuitively, the program guesses a sequence of actions. Similarly, let us introduce a program containing a rule for each . Furthermore, we assume the availability of a program that defines the atoms in (including ) deterministically in terms of and . Also, let be a program that contains a rule for each , such that is a precondition of . With these building blocks, we can easily encode conformant planning as a combined program

This program is parameterized by . To see that it encodes the conformant planning problem, we notice that stable-unstable models of this program are stable models of , i.e., sequences of actions. Furthermore, models of the testing program are interpretations of the atoms in such that in this world, either one of the preconditions on the actions is not satisfied or the goal is not reached. I.e., models of the testing program amount to showing that the sequence of actions is not a conformant plan. The stable-unstable semantics dictates that there can be no such counterexample.

In the above, we described and only informally since these components have already been worked out in the literature. More precisely, many classical planning encodings use exactly those components, combining them to a program of the form

These components (or very similar) are used for instance by Lifschitz (1999), Leone et al. (2001), and by Bogaerts et al. (2014). This illustrates that our encoding of conformant planning stays very close to the existing encodings of classical planning problems in ASP. On the other hand, native conformant planning encodings in ASP are often based on saturation Leone et al. (2001). After applying saturation, it is very hard to spot the original components.

5.3 Points of No Return: A Generic Problem Combining Logic and Graphs

We now present a generic problem that connects graphs with logic. Let be a directed multi-graph: is a set of nodes, is an initial node and is a set of arcs labeled with Boolean formulas. We use to denote that is an arc from to labeled with . There may be multiple arcs between and with different labels. We call a node a point of no return if (i) contains a path such that is satisfiable and (ii) the preceding path in cannot be extended with a path such that is satisfiable. Thus, points of no return are nodes that can be reached from in a way that makes unreachable from (i.e., reaching back from would violate a constraint of the path from to ).

Proposition 5.1

Given a finite labeled graph as above and a node , it is a -complete problem to decide if is a point of no return.

Membership in is obvious. We present a reduction from to support hardness. Consider an formula . This formula is equivalent to

Now, construct a graph with nodes …, …, and following labeled arcs:

Observe that, setting and , we have that is a point of no return if and only if is valid.

To model the problem of checking whether a node is point of no return as a combined program, we assume that each arc is labeled by a literal and that there is at most one arc between every two nodes. Our programs easily generalize to the general case. To allow for multiple arcs between two nodes, it suffices to introduce explicit identifiers for arcs. To allow more complex labeling formulas, we can introduce Tseitin predicates for subformulas and use standard meta-interpreter approaches to model the truth of such a formula; see for instance (Gebser et al., 2011, Section 3).

We use unary predicates and to respectively interpret the initial node and the point of no return . Herbrand functions and map atoms (represented as constants) to literals. The predicate holds if there is an arc between nodes and labeled with literal . In (and ), we use predicates (and ) such that () holds if the arc from to is chosen in the path (the path respectively). The programs contain constraints ensuring that the selected edges indeed form paths from to (respectively from to ), using an additional predicate () and that the formulas associated to the respective paths are satisfiable. Thus, encodes that there exists a path from to and encodes that this path can be extended to a cycle back to . As such, the combined program indeed models that is a point of no return. The entire combined program can be found below.

6 Implementation

Next, we present a prototype implementation of a solver for the stable-unstable semantics.

6.1 Preliminaries: sat-to-sat

We assume familiarity with the basics of second-order logic (SO). Our implementation is based on a recently introduced solver, called sat-to-sat Janhunen et al. (2016). The sat-to-sat architecture combines multiple SAT solvers to tackle problems from any level of the PH, essentially acting like a QBF solver Bogaerts et al. (2016b). We do not give details on the inner workings of sat-to-sat, but rather refer the reader to the original papers for details. What matters for the current paper is that Bogaerts et al. (2016a) presented a high-level (second-order) interface to sat-to-sat. The idea is that in order to obtain a solver for a new paradigm, it suffices to give a second-order theory that describes the semantics of the formalism declaratively. Bogaerts et al. showed, e.g., how to obtain a solver for (disjunctive) logic programming using this idea.

Following Bogaerts et al. (2016a), we describe a logic program by means of predicates , , , , and with intended interpretation that holds for all rules , holds for all atoms , holds for all parameters, means that is an atom in the head of rule , that is a positive literal in the body of and that is the atom of a negative literal in the body of . With this vocabulary, augmented with a predicate with intended meaning that holds for all atoms true in some interpretation, we describe the parameterized stable semantics for disjunctive logic programs with the theory :

The first part of this theory expresses that is interpreted as a model of : the constraint expresses that the interpretation is a subset of the vocabulary and the second constraint expresses that whenever the body of a rule is satisfied in , so is at least one of its head atoms. The constraint expresses that is -minimal: there cannot be an interpretation that agrees with on the parameters and that is a model of the reduct of with respect to . In other words, whenever satisfies all positive literals in the body of a rule and satisfies all negative literals in the body of , must also satisfy some atom in the head of .

Theorem 6.1 (Theorem 4.1 of Bogaerts et al. (2016a))

Let be a (disjunctive) logic program and an interpretation that interprets according to . Then, if and only if is a parameterized stable model of .

From Theorem 6.1, it follows that feeding to sat-to-sat results in a solver for disjunctive logic programs. The same theory also works for normal logic programs.

6.2 An Implementation on Top of sat-to-sat

In order to obtain a solver for our new paradigm in the spirit of Bogaerts et al. (2016a), we need to provide a second order specification of our semantics. A first observation is that we can reuse the theory from the previous section, both to enforce that is a stable model of and that there exists no stable model of that coincides with on the shared vocabulary. When translating the definition of stable-unstable models to second-order logic, we obtain the following theory

where abbreviates a second-order theory obtained from by replacing all free occurrences of by .

Theorem 6.2

Let be a combined logic program and an interpretation that interprets according to and according to . Then, if and only if is a stable-unstable model of .

Theorem 6.1 ensures that the first sentence of this theory is equivalent with the condition of being a stable model of . Also, the second sentence states that one cannot have an interpretation that coincides with on shared atoms (those that are in both and ) and is a stable model of . This is exactly the definition of the stable-unstable semantics.

Providing an ASCII representation of to the second-order interface of sat-to-sat immediately results in a solver that generates stable-unstable models of a combined logic program. Our implementation, which is available online222, consists only of the second-order theory above and some marshaling (to support ASP-Core-2 format and to exploit the symbol table to identify which atoms from different programs are actually the same). The overall workflow of our tool is as follows. We take, as input, three logic programs: (a non-ground generate program), (a non-ground test program) and (an instance). We then use Gringo Gebser et al. (2007) to ground and . Next, we interpret , , , , and (for ) according to the reified representation of the two resulting ground programs. Such an interpretation is fed to sat-to-sat along with the ASCII representation of ; sat-to-sat uses these to compute stable-unstable models of the original combined program .

The implementation described above is proof-of-concept by nature and we plan to implement this technique natively on top of the clasp solver Drescher et al. (2008); Gebser et al. (2015). In spite of its prototypical nature, the current implementation is based on a state-of-the-art architecture shared by many QBF solvers and thus expected to perform reasonably well. This is especially the case when we go beyond the complexity class in the next section.

7 Beyond with Normal Logic Programs

In this section, we show how the ideas of this paper generalize to capture the entire PH. To this end, the definition of a combined logic program is turned into a recursive definition of -combined programs where the parameter reflects the depth of the combination.

Definition 7.1 (-combined program)
  1. For , a -combined program is defined as a normal program over a vocabulary , parameterized by a vocabulary .

  2. For , a -combined program is a pair where is a normal program over a vocabulary , parameterized by a vocabulary and is a -combined program over a vocabulary , parameterized by .

Note that combined programs (Definition 4.1) directly correspond to -combined programs with . Similarly, the semantics of -combined programs also directly generalizes Definition 4.2:

Definition 7.2 (Stable-unstable models for -combined programs)

A stable model of is also called a stable-unstable model of a -combined program . Let be a -combined program with over a vocabulary , parameterized by , where has vocabulary . A -interpretation is a stable-unstable model of , if

  1. is a parameterized stable model of and

  2. there is no stable-unstable model of such that .

Example 7.3 (Example 4.3 continued)

Consider program over vocabulary . Program has one stable model, namely . This model is also a stable-unstable model of the -combined program since it does not coincide with a stable-unstable model of on .

The complexity of deciding whether a -combined program has a stable-unstable model depends on the depth of the combination.

Theorem 7.4

It is -complete to decide if a finite -combined program has a stable-unstable model.

[Proof sketch.] The case follows from the results of Marek and Truszczyński (1999) and Theorem 4.4 corresponds to . Using either one as the base case, it can be proven inductively that the decision problem in question is NP-complete assuming the availability of an oracle from the class , effectively a -combined program in our constructions. Thus, steps in recursion depth match with the levels of the PH (in analogy to the number of quantifier alternations in QBFs).

8 Conclusion

In this paper, we propose combined logic programs subject to the stable-unstable semantics as an alternative paradigm to disjunctive logic programs for programming on the second level of the polynomial hierarchy. We deploy normal logic programs as the base syntax for combined programs, but other equally complex classes can be exploited analogously. Our methodology surpasses the need for saturation and meta-interpretation techniques that have previously been used to encode oracles within disjunctive logic programs. The use of the new paradigm is illustrated in terms of application problems and we also present a proof-of-concept implementation on top of the solver sat-to-sat. Moreover, we show how combined programs provide a gateway to programming on any level of the polynomial hierarchy with normal logic programs using the idea of recursive combination to depth . In this sense, our formalism can be seen as a hybrid between QBFs and logic programs, combining desirable features from both.


  • Andres et al. (2015) Andres, B., Rajaratnam, D., Sabuncu, O., and Schaub, T. 2015. Integrating ASP into ROS for reasoning in robots. In Proceedings of the 13th International Conference on Logic Programming and Non-monotonic Reasoning, LPNMR 2015. Lecture Notes in Computer Science, vol. 9345. Springer, Lexington, Kentucky, USA, 69–82.
  • Ben-Eliyahu and Dechter (1994) Ben-Eliyahu, R. and Dechter, R. 1994. Propositional semantics for disjunctive logic programs. Ann. Math. Artif. Intell. 12, 1–2, 53–87.
  • Bogaerts et al. (2016a) Bogaerts, B., Janhunen, T., and Tasharrofi, S. 2016a. Declarative solver development: Case studies. In Proceedings of the 15th International Conference on Principles of Knowledge Representation and Reasoning, KR 2016. AAAI Press, Cape Town, South Africa, 74–83.
  • Bogaerts et al. (2016b) Bogaerts, B., Janhunen, T., and Tasharrofi, S. 2016b. Solving QBF instances with nested SAT solvers. In Proceedings of the AAAI-16 Workshop on Beyond NP. AAAI Press, Phoenix, Arizona, 307–313.
  • Bogaerts et al. (2014) Bogaerts, B., Jansen, J., Bruynooghe, M., De Cat, B., Vennekens, J., and Denecker, M. 2014. Simulating dynamic systems using linear time calculus theories. TPLP 14, 4–5 (7), 477–492.
  • Bomanson and Janhunen (2013) Bomanson, J. and Janhunen, T. 2013. Normalizing cardinality rules using merging and sorting constructions. In Proceedings of the 12th International Conference on Logic Programming and Non-monotonic Reasoning, LPNMR 2013. Lecture Notes in Computer Science, vol. 8148. Springer, Corunna, Spain, 187–199.
  • Brooks et al. (2007) Brooks, D. R., Erdem, E., Erdogan, S. T., Minett, J. W., and Ringe, D. 2007. Inferring phylogenetic trees using answer set programming.

    J. Autom. Reasoning

     39, 4, 471–511.
  • Bruynooghe et al. (2015) Bruynooghe, M., Blockeel, H., Bogaerts, B., De Cat, B., De Pooter, S., Jansen, J., Labarre, A., Ramon, J., Denecker, M., and Verwer, S. 2015. Predicate logic as a modeling language: modeling and solving some machine learning and data mining problems with IDP3. TPLP 15, 6 (November), 783–817.
  • Calimeri et al. (2013) Calimeri, F., Faber, W., Gebser, M., Ianni, G., Kaminski, R., Krennwallner, T., Leone, N., Ricca, F., and Schaub, T. 2013. ASP-Core-2 input language format. Tech. rep., ASP Standardization Working Group.
  • Calimeri et al. (2016) Calimeri, F., Gebser, M., Maratea, M., and Ricca, F. 2016. Design and results of the fifth answer set programming competition. Artif. Intell. 231, 151–181.
  • Denecker et al. (2012) Denecker, M., Lierler, Y., Truszczyński, M., and Vennekens, J. 2012. A Tarskian informal semantics for answer set programming. In Technical Communications of the 28th International Conference on Logic Programming, ICLP 2012. LIPIcs, vol. 17. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, Budapest, Hungary, 277–289.
  • Denecker and Vennekens (2007) Denecker, M. and Vennekens, J. 2007. Well-founded semantics and the algebraic theory of non-monotone inductive definitions. In Proceedings of the 9th International Conference on Logic Programming and Non-monotonic Reasoning, LPNMR 2007. Lecture Notes in Computer Science, vol. 4483. Springer, Tempe, Arizona, USA, 84–96.
  • Drescher et al. (2008) Drescher, C., Gebser, M., Grote, T., Kaufmann, B., König, A., Ostrowski, M., and Schaub, T. 2008. Conflict-driven disjunctive answer set solving. In Proceedings of the 11th International Conference on Principles of Knowledge Representation and Reasoning, KR 2008. AAAI Press, Sydney, Australia, 422–432.
  • Eiter and Gottlob (1995) Eiter, T. and Gottlob, G. 1995. On the computational cost of disjunctive logic programming: Propositional case. Ann. Math. Artif. Intell. 15, 3-4, 289–323.
  • Eiter et al. (1997) Eiter, T., Gottlob, G., and Veith, H. 1997. Modular logic programming and generalized quantifiers. In Proceedings of the 4th International Conference on Logic Programming and Non-monotonic Reasoning, LPNMR 1997. Lecture Notes in Computer Science, vol. 1265. Springer, Dagstuhl Castle, Germany, 289–308.
  • Eiter and Polleres (2006) Eiter, T. and Polleres, A. 2006. Towards automated integration of guess and check programs in answer set programming: a meta-interpreter and applications. TPLP 6, 1-2, 23–60.
  • Emerson and Jutla (1991) Emerson, E. A. and Jutla, C. S. 1991. Tree automata, mu-calculus and determinacy. In Proceedings of the 32nd Annual Symposium on Foundations of Computer Science, FOCS 1991. IEEE Computer Society, San Juan, Puerto Rico, 368–377.
  • Gebser et al. (2015) Gebser, M., Harrison, A., Kaminski, R., Lifschitz, V., and Schaub, T. 2015. Abstract gringo. TPLP 15, 4-5, 449–463.
  • Gebser et al. (2015) Gebser, M., Kaminski, R., Kaufmann, B., Romero, J., and Schaub, T. 2015. Progress in clasp series 3. In Proceedings of the 13th International Conference on Logic Programming and Non-monotonic Reasoning, LPNMR 2015. Lecture Notes in Computer Science, vol. 9345. Springer, Lexington, Kentucky, USA, 368–383.
  • Gebser et al. (2011) Gebser, M., Kaminski, R., and Schaub, T. 2011. Complex optimization in answer set programming. TPLP 11, 4-5, 821–839.
  • Gebser et al. (2007) Gebser, M., Schaub, T., and Thiele, S. 2007. GrinGo: A new grounder for Answer Set Programming. In Proceedings of the 9th International Conference on Logic Programming and Non-monotonic Reasoning, LPNMR 2007. Lecture Notes in Computer Science, vol. 4483. Springer, Tempe, Arizona, USA, 266–271.
  • Gelfond and Lifschitz (1988) Gelfond, M. and Lifschitz, V. 1988. The stable model semantics for logic programming. In Proceedings of the Fifth International Conference on Logic Programming, ICLP 1988. MIT Press, Seattle, Washington, USA, 1070–1080.
  • Gelfond and Lifschitz (1991) Gelfond, M. and Lifschitz, V. 1991. Classical negation in logic programs and disjunctive databases. New Generation Computing 9, 3/4, 365–385.
  • Gelfond and Przymusinska (1996) Gelfond, M. and Przymusinska, H. 1996. Towards a theory of elaboration tolerance: Logic programming approach. Int. J. of Soft. Eng. and Knowl. Eng. 6, 1, 89–112.
  • Grasso et al. (2009) Grasso, G., Iiritano, S., Leone, N., and Ricca, F. 2009. Some DLV applications for knowledge management. In Proceedings of the 10th International Conference on Logic Programming and Non-monotonic Reasoning, LPNMR 2009. Lecture Notes in Computer Science, vol. 5753. Springer, Potsdam, Germany, 591–597.
  • Heljanko et al. (2012) Heljanko, K., Keinänen, M., Lange, M., and Niemelä, I. 2012. Solving parity games by a reduction to SAT. J. Comput. Syst. Sci. 78, 2, 430–440.
  • Janhunen et al. (2015) Janhunen, T., Gebser, M., Rintanen, J., Nyman, H., Pensar, J., and Corander, J. 2015. Learning discrete decomposable graphical models via constraint optimization. Statistics and Computing. Advance access.
  • Janhunen et al. (2006) Janhunen, T., Niemelä, I., Seipel, D., Simons, P., and You, J. 2006. Unfolding partiality and disjunctions in stable model semantics. ACM Trans. Comput. Log. 7, 1, 1–37.
  • Janhunen et al. (2016) Janhunen, T., Tasharrofi, S., and Ternovska, E. 2016. sat-to-sat: Declarative extension of SAT solvers with new propagators. In

    Proceedings of the 30th AAAI Conference on Artificial Intelligence, AAAI 2016

    . AAAI Press, Phoenix, Arizona, USA, 978–984.
  • Koponen et al. (2015) Koponen, L., Oikarinen, E., Janhunen, T., and Säilä, L. 2015. Optimizing phylogenetic supertrees using answer set programming. TPLP 15, 4-5, 604–619.
  • Leone et al. (2006) Leone, N., Pfeifer, G., Faber, W., Eiter, T., Gottlob, G., Perri, S., and Scarcello, F. 2006. The DLV system for knowledge representation and reasoning. ACM Trans. Comput. Log. 7, 3, 499–562.
  • Leone et al. (2001) Leone, N., Rosati, R., and Scarcello, F. 2001. Enhancing answer set planning. In Proceedings of the IJCAI-01 Workshop on Planning under Uncertainty and Incomplete Information. Seattle, Washington, USA.
  • Lifschitz (1999) Lifschitz, V. 1999. Answer set planning. In Proceedings of the 16th International Conference on Logic Programming, ICLP 1999. MIT Press, Las Cruses, New Mexico, USA, 23–37.
  • Lindström (1966) Lindström, P. 1966. First order predicate logic with generalized quantifiers. Theoria 32, 3, 186–195.
  • Marek and Truszczyński (1999) Marek, V. and Truszczyński, M. 1999. Stable models and an alternative logic programming paradigm. In The Logic Programming Paradigm: A 25-Year Perspective. Springer-Verlag, Berlin Heidelberg, 375–398.
  • Mostowski (1957) Mostowski, A. 1957. On a generalization of quantifiers. Fundamenta Mathematicae 44, 1, 12–36.
  • Niemelä (1999) Niemelä, I. 1999. Logic programs with stable model semantics as a constraint programming paradigm. Ann. Math. Artif. Intell. 25, 3-4, 241–273.
  • Nogueira et al. (2001) Nogueira, M., Balduccini, M., Gelfond, M., Watson, R., and Barry, M. 2001. An A-Prolog decision support system for the space shuttle. In Proceedings of the 3rd International Symposium on Practical Aspects of Declarative Languages, PADL 2001. Lecture Notes in Computer Science, vol. 1990. Springer, Las Vegas, Nevada, USA, 169–183.
  • Oikarinen and Janhunen (2006) Oikarinen, E. and Janhunen, T. 2006. Modular equivalence for normal logic programs. In Proceedings of the 17th European Conference on Artificial Intelligence, ECAI 2006. IOS Press, Riva del Garda, Italy, 412–416.
  • Ricca et al. (2010) Ricca, F., Dimasi, A., Grasso, G., Ielpa, S. M., Iiritano, S., Manna, M., and Leone, N. 2010. A logic-based system for e-tourism. Fundam. Inform. 105, 1-2, 35–55.
  • Stockmeyer and Meyer (1973) Stockmeyer, L. J. and Meyer, A. R. 1973. Word problems requiring exponential time: Preliminary report. In

    Proceedings of the 5th Annual ACM Symposium on Theory of Computing, STOC 1973

    . ACM, Austin, Texas, USA, 1–9.
  • Tiihonen et al. (2003) Tiihonen, J., Soininen, T., Niemelä, I., and Sulonen, R. 2003. A practical tool for mass-customising configurable products. In Proceedings of the 14th International Conference on Engineering Design, ICED 2003. Design Society, Stockholm, 1290–1299.