- Stable model semantics
The concept of a

**stable model**, or answer set, is used to define a declarative semantics for logic programs withnegation as failure . This is one of several standard approaches to the meaning of negation in logic programming, along with program completion and thewell-founded semantics . The stable model semantics is the basis ofanswer set programming .**Motivation**Research on the declarative semantics of negation in logic programming was motivated by the fact that the behavior of SLDNF resolution -- the generalization of

SLD resolution used byProlog in the presence of negation in the bodies of rules -- does not fully match thetruth tables familiar from classicalpropositional logic . Consider, for instance, the program:$p$

:$r\; leftarrow\; p,\; q$

:$s\; leftarrow\; p,\; hbox\{not\; \}\; q.$

Given this program, the query $p$ will succeed, because the program includes $p$ as a fact; the query $q$ will fail, because it does not occur in the head of any of the rules. The query $r$ will fail also, because the only rule with $r$ in the head contains the subgoal $q$ in its body; as we have seen, that subgoal fails. Finally, the query $s$ succeeds, because each of the subgoals $p$, $hbox\{not\; \}\; q$ succeeds. (The latter succeeds because the corresponding positive goal $q$ fails.) To sum up, the behavior of SLDNF resolution on the given program can be represented by the following truth assignment:

$p$ **T**$q$ **F**$r$ **F**$s$ **T**.On the other hand, the rules of the given program can be viewed as

propositional formula s if we identify the comma with conjunction $land,$ the symbol $hbox\{not\}$ with negation $eg,$ and agree to treat $F\; leftarrow\; G$ as the implication $G\; ightarrow\; F$ written backwards. For instance, the last rule of the given program is, from this point of view, alternative notation for the propositional formula:$p\; land\; eg\; q\; ightarrow\; s.$

If we calculate the truth values of the rules of the program for the truthassignment shown above then we will see that each rule gets the value

**T**. In other words, that assignment is amodel of the program. But this program has also other models, for instance$p$ **T**$q$ **T**$r$ **T**$s$ **F**.Thus one of the models of the given program is special in the sense that itcorrectly represents the behavior of SLDNF resolution. What are themathematical properties of that model that make it special? An answer tothis question is provided by the definition of a stable model.

**Relation to nonmonotonic logic**The meaning of negation in logic programs is closely related to two theories of nonmonotonic reasoning --

autoepistemic logic anddefault logic . The discovery of these relationships was a key step towards the invention of the stable model semantics.The syntax of autoepistemic logic uses a

modal operator that allows us to distinguish between what is true and what is believed.Michael Gelfond [1987] proposed to read $hbox\{not\}\; p$ in the body of a rule as "$p$ is not believed", and to understand a rule with negation as the corresponding formula of autoepistemic logic. The stable model semantics, in its basic form, can be viewed as a reformulation of this idea that avoids explicit references to autoepistemic logic.In default logic, a default is similar to an

inference rule , except that it includes, besides its premises and conclusion, a list offormulas called justifications. A default can be used to derive its conclusion under the assumption that its justifications are consistent. Nicole Bidoit and Christine Froidevaux [1987] proposed to treat negated atoms in the bodies of rules as justifications. For instance, the rule:$s\; leftarrow\; p,\; hbox\{not\; \}\; q$

can be understood as the default that allows us to derive $s$ from $p$ assuming that $eg\; q$ is consistent. The stable model semantics uses the same idea, but it does not explicitly refer to default logic.

**table models**The definition of a stable model below, reproduced from [Gelfond and Lifschitz, 1988] , uses two conventions. First, a truth assignment is identified with the set of atoms that get the value

**T**. For instance, the truth assignment$p$ **T**$q$ **F**$r$ **F**$s$ **T**is identified with the set $\{p,s\}$. This convention allows us to use the set inclusion relation to compare truth assignments with each other. The smallest of all truth assignments $emptyset$ is the one that makes every atom false; the largest truth assignment makes every atom true.

Second, a logic program with variables is viewed as shorthand for the set of all ground instances of its rules, that is, for the result of substituting variable-free terms for variables in the rules of the program in all possible ways. For instance, the logic programming definition of even numbers:$even(0)$

:$even(s(X))leftarrow\; hbox\{not\; \}\; even(X)$

is understood as the result of replacing $X$ in this program by the ground terms

:$0,\; s(0),\; s(s(0)),dots.$

in all possible ways. The result is the infinite ground program

:$even(0)$

:$even(s(0))leftarrow\; hbox\{not\; \}\; even(0)$

:$even(s(s(0)))leftarrow\; hbox\{not\; \}\; even(s(0))$

:$dots$

**Definition**Let $P$ be a set of rules of the form

:$A\; leftarrow\; B\_\{1\},dots,B\_\{m\},hbox\{not\; \}\; C\_\{1\},dots,hbox\{not\; \}\; C\_\{n\}$

where $A,B\_\{1\},dots,B\_\{m\},C\_\{1\},dots,C\_\{n\}$ are ground atoms. If $P$ does not contain negation ($n=0$ inevery rule of the program) then, by definition, the only stable model of $P$ is its model that is minimal relative to set inclusion. [

*This approach to the semantics of logic programs without negation is due to Maarten van Emden and*] (Any program without negation has exactly one minimal model.) To extend this definition to the case of programs with negation, we need the auxiliary concept of the reduct, defined as follows.Robert Kowalski [1976] .For any set $I$ of ground atoms, the "reduct" of $P$ relative to $I$ is the set of rules without negation obtained from $P$ by first dropping every rule such that at least one of the atoms $C\_i$ in its body

:$B\_\{1\},dots,B\_\{m\},hbox\{not\; \}\; C\_\{1\},dots,hbox\{not\; \}\; C\_\{n\}$

belongs to $I$, and then dropping the parts$hbox\{not\; \}\; C\_\{1\},dots,hbox\{not\; \}\; C\_\{n\}$ from the bodies of all remaining rules.

We say that $I$ is a "stable model" of $P$ if $I$ is the stable model of the reduct of $P$ relative to $I$. (Since the reduct does not contain negation, its stable model has been already defined.) As the term "stable model" suggests, every stable model of $P$ is a model of $P$.

**Example**To illustrate these definitions, let us check that $\{p,s\}$ is a stable model of the program

:$p$

:$r\; leftarrow\; p,\; q$

:$s\; leftarrow\; p,\; hbox\{not\; \}\; q.$

The reduct of this program relative to $\{p,s\}$ is

:$p$

:$r\; leftarrow\; p,\; q$

:$s\; leftarrow\; p.$

(Indeed, since $q\; otin\{p,s\}$, the reduct is obtained from the program by dropping the part $hbox\{not\; \}\; q.$) The stable model of the reduct is $\{p,s\}$. (Indeed, this set of atoms satisfies every rule of the reduct, and it has no proper subsets with the same property.) Thus after computing the stable model of the reduct we arrived at the same set $\{p,s\}$ that we started with. Consequently, that set is a stable model.

Checking in the same way the other 15 sets consisting of the atoms $p,\; q,\; r,\; s$ shows that this program has no other stable models. For instance, the reduct of the program relative to $\{p,q,r\}$ is

:$p$

:$r\; leftarrow\; p,\; q.$

The stable model of the reduct is $\{p\}$, which is different from the set $\{p,q,r\}$ that we started with.

**Programs without a unique stable model**A program with negation may have many stable models or no stable models. For instance, the program

:$p\; leftarrow\; hbox\{not\; \}\; q$

:$q\; leftarrow\; hbox\{not\; \}\; p$

has two stable models $\{p\}$, $\{q\}$. The one-rule program

:$p\; leftarrow\; hbox\{not\; \}\; p$

has no stable models.

If we think of the stable model semantics as a description of the behavior of

Prolog in the presence of negation then programs without a unique stable model can be judged unsatisfactory: they do not provide an unambiguous specification for Prolog-style query answering. For instance, the two programs above are not reasonable as Prolog programs -- SLDNF resolution does not terminate on them.But the use of stable models in

answer set programming provides a different perspective on such programs. In that programming paradigm, a given search problem is represented by a logic program so that the stable models of the program correspond to solutions.Then programs with many stable models correspond to problems with many solutions, and programs without stable models correspond to unsolvable problems. For instance, theeight queens puzzle has 92 solutions; to solve it using answer set programming, we encode it by a logic program with 92 stable models. From this point of view, logic programs with exactly one stable model are rather special in answer set programming, like polynomials with exactly one root in algebra.**Properties of the stable model semantics**In this section, as in the definition of a stable model above, by a logic program we mean a set of rules of the form

:$A\; leftarrow\; B\_\{1\},dots,B\_\{m\},hbox\{not\; \}\; C\_\{1\},dots,hbox\{not\; \}\; C\_\{n\}$

where $A,B\_\{1\},dots,B\_\{m\},C\_\{1\},dots,C\_\{n\}$ are ground atoms.

"Head atoms:"If an atom $A$ belongs to a stable model of a logic program $P$ then $A$ is the head of one of the rules of $P$.

"Minimality:" Any stable model of a logic program $P$ is minimal among the models of $P$ relative to set inclusion.

"The antichain property:"If $I$ and $J$ are stable models of the same logic program then $I$ is not a proper subset of $J$. In other words, the set of stable models of a program is an

antichain ."NP-completeness:"Testing whether a finite ground logic program has a stable model is

NP-complete .**Relation to other theories of negation as failure****Program completion**Any stable model of a finite ground program is not only a model of the program itself, but also a model of its completion [Marek and Subrahmanian, 1989] . The converse, however, is not true. For instance, the completion of the one-rule program

:$p\; leftarrow\; p$

is the tautology $p\; leftrightarrow\; p$. The model $emptyset$ of this tautology is stable, but its other model $\{p\}$ is not. François Fages [1994] found a syntactic condition on logic programs that eliminates such counterexamples and guarantees the stability of every model of the program's completion. The programs that satisfy his condition are called "tight".

Fangzhen Lin and Yuting Zhao [2004] showed how to make the completion of a nontight program stronger so that all its nonstable models will be eliminated. The additional formulas that they add to the completion are called "loop formulas".

**Well-founded semantics**The well-founded model of a logic program partitions all ground atoms into three sets: true, false and unknown. If an atom is true in the well-founded model of $P$ then it belongs to every stable model of $P$. The converse, generally, does not hold. For instance, the program

:$p\; leftarrow\; hbox\{not\; \}\; q$

:$q\; leftarrow\; hbox\{not\; \}\; p$

:$rleftarrow\; p$

:$rleftarrow\; q$

has two stable models, $\{p,r\}$ and $\{q,r\}$. Even though $r$ belongs to both of them, its value in the well-founded model is "unknown".

Furthermore, if an atom is false in the well-founded model of a program then it does not belong to any of its stable models. Thus the well-founded model of a logic program provides a lower bound on the intersection of its stable models and an upper bound on their union.

**trong negation****Representing incomplete information**From the perspective of

knowledge representation , a set of ground atoms can be thought of as a description of a complete state of knowledge: the atoms that belong to the set are known to be true, and the atoms that do not belong to the set are known to be false. A possibly "incomplete" state of knowledge can be described using a consistent but possibly incomplete set of literals; if an atom $p$ does not belong to the set and its negation does not belong to the set either then it is not known whether $p$ is true.In the context of logic programming, this idea leads to the need to distinguish between two kinds of negation -- "

negation as failure ", discussed above, and "strong negation", which is denoted here by $sim$. [*Gelfond and Lifschitz [1991] call the second negation "classical" and denote it by $eg$.*] The following example, illustrating the difference between the two kinds of negation, belongs to John McCarthy. A school bus may cross railway tracks under the condition that there is no approaching train. If we do not necessarily know whether a train is approaching then the rule using negation as failure:$hbox\{Cross\}\; leftarrow\; hbox\{not\; Train\}$

is not an adequate representation of this idea: it says that it's okay to cross "in the absence of information" about an approaching train. The weaker rule, that uses strong negation in the body, is preferable:

:$hbox\{Cross\}\; leftarrow\; ,simhbox\{Train\}.$

It says that it's okay to cross if we "know" that no train is approaching.

**Coherent stable models**To incorporate strong negation in the theory of stable models, Gelfond and Lifschitz [1991] allowed each of the expressions $A$, $B\_i$, $C\_i$ in a rule

:$A\; leftarrow\; B\_\{1\},dots,B\_\{m\},hbox\{not\; \}\; C\_\{1\},dots,hbox\{not\; \}\; C\_\{n\}$

to be either an atom or an atom prefixed with the strong negation symbol. Instead of stable models, this generalization uses "answer sets", which may include both atoms and atoms prefixed with strong negation.

An alternative approach [Ferraris and Lifschitz, 2005] treats strong negation as a part of an atom, and it does not require any changes in the definition of a stable model. In this theory of strong negation, we distinguish between atoms of two kinds, "positive" and "negative", and assume that each negative atom is an expression of the form $sim\; A$, where $A$ is a positive atom. A set of atoms is called "coherent" if it does not contain "complementary" pairs of atoms $A,sim\; A$. Coherent stable models of a program are identical to its consistent answer sets in the sense of [Gelfond and Lifschitz, 1991] .

For instance, the program

:$p\; leftarrow\; hbox\{not\; \}\; q$

:$q\; leftarrow\; hbox\{not\; \}\; p$

:$r$

:

`$sim\; rleftarrow\; hbox\{not\; \}p$`has two stable models, $\{p,r\}$ and $\{q,r,sim\; r\}$. The first model is coherent; the second is not, because it contains both the atom $r$ and the atom $sim\; r$.

**Closed world assumption**According to [Gelfond and Lifschitz, 1991] , the

closed world assumption for a predicate $p$ can be expressed by the rule:$sim\; p(X\_1,dots,X\_n)leftarrowhbox\{not\; \}p(X\_1,dots,X\_n)$

(the relation $p$ does not hold for a tuple $X\_1,dots,X\_n$ if there is no evidence that it does). For instance, the stable model of the program

:$p(a,b)$

:$p(c,d)$

:$sim\; p(X,Y)leftarrowhbox\{not\; \}p(X,Y)$

consists of 2 positive atoms

:$p(a,b),\; p(c,d)$

and 14 negative atoms

:$sim\; p(a,a),\; sim(a,c),\; dots$

-- the strong negations of all other positive ground atoms formed from $p,\; a,\; b,\; c,\; d$.

A logic program with strong negation can include the closed world assumption rules for some of its predicates and leave the other predicates in the realm of the

open world assumption .**Programs with constraints**The stable model semantics has been generalized to many kinds of logic programs other than collections of "traditional" rules discussed above -- rules of the form

:$A\; leftarrow\; B\_\{1\},dots,B\_\{m\},hbox\{not\; \}\; C\_\{1\},dots,hbox\{not\; \}\; C\_\{n\}$

where $A,B\_\{1\},dots,B\_\{m\},C\_\{1\},dots,C\_\{n\}$ are atoms. One simple extension allows programs to contain "constraints" -- rules with the empty head:

:$leftarrow\; B\_\{1\},dots,B\_\{m\},hbox\{not\; \}\; C\_\{1\},dots,hbox\{not\; \}\; C\_\{n\}.$

Recall that a traditional rule can be viewed as alternative notation for a propositional formula if we identify the comma with conjunction $land,$ the symbol $hbox\{not\}$ with negation $eg,$ and agree to treat $F\; leftarrow\; G$ as the implication $G\; ightarrow\; F$ written backwards. To extend this convention to constraints, we identify a constraint with the negation of the formula corresponding to its body:

:$eg(B\_\{1\}landcdotsland\; B\_\{m\}land\; eg\; C\_\{1\}landcdotsland\; eg\; C\_\{n\}).$

We can now extend the definition of a stable model to programs with constraints. As in the case of traditional programs, we begin with programs that do not contain negation. Such a program may be inconsistent; then we say that it has no stable models. If such a program $P$ is consistent then $P$ has a unique minimal model, and that model is considered the only stable model of $P$.

Next, stable models of arbitrary programs with constraints are defined using reducts, formed in the same way as in the case of traditional programs (see the definition of a stable model above.) A set $I$ of atoms is a "stable model" of a program $P$ with constraints if the reduct of $P$ relative to $I$ has a stable model, and that stable model equals $I$.

The properties of the stable model semantics stated above for traditional programs hold in the presence of constraints as well.

Constraints play an important role in

answer set programming because adding a constraint to a logic program $P$ affects the collection of stable models of $P$ in a very simple way: it eliminates the stable models that violate the constraint. In other words, for any program $P$ with constraints and any constraint $C$, the stable models of $Pcup\{C\}$ can be characterized as the stable models of $P$ that satisfy $C$.**Disjunctive programs**In a "disjunctive rule", the head may be the disjunction of several atoms:

:$A\_1;dots;A\_k\; leftarrow\; B\_\{1\},dots,B\_\{m\},hbox\{not\; \}\; C\_\{1\},dots,hbox\{not\; \}\; C\_\{n\}$

(the semicolon is viewed as alternative notation for disjunction $lor$). Traditional rules correspond to $k=1$, and constraints to $k=0$. To extend the stable model semantics to disjunctive programs [Gelfond and Lifschitz, 1991] , we first define that in the absence of negation ($n=0$ in each rule) the stable models of a program are its minimal models. The definition of the reduct for disjunctive programs remains the same as before. A set $I$ of atoms is a "stable model" of $P$ if $I$ is a stable model of the reduct of $P$ relative to $I$.

For example, the set $\{p,r\}$ is a stable model of the disjunctive program

:$p;q$

:$rleftarrow\; hbox\{not\}\; q$

because it is one of two minimal models of the reduct

:$p;q$

:$r.$

The program above has one more stable model, $\{q\}$.

As in the case of traditional programs, each element of any stable model of a disjunctive program $P$ is a head atom of $P$, in the sense that it occurs in the head of one of the rules of $P$. As in the traditional case, the stable models of a disjunctive program are minimal and form an antichain. Testing whether a finite disjunctive program has a stable model is $Sigma\_2^\{\; m\; P\}$-complete [Eiter and Gottlob, 1993] .

**table models of a set of propositional formulas**Rules, and even disjunctive rules, have a rather special syntactic form, in comparison with arbitrary

propositional formula s. Each disjunctive rule is essentially an implication such that its antecedent (the body of the rule) is a conjunction of literals, and itsconsequent (head) is a disjunction of atoms. David Pearce [1997] and Paolo Ferraris [2005] showed how to extend the definition of a stable model to sets of arbitrary propositional formulas. This generalization has applications toanswer set programming .Pearce's formulation looks very different from the original definition of a stable model. Instead of reducts, it refers to "equilibrium logic" -- a system of

nonmonotonic logic based on Kripke models. Ferraris's formulation, on the other hand, is based on reducts, although the process of constructing the reduct that it uses differs from the one described above. The two approaches to defining stable models for sets of propositional formulas are equivalent to each other.**General definition of a stable model**According to [Ferraris, 2005] , the "reduct" of a propositional formula $F$ relative to a set $I$ of atoms is the formula obtained from $F$ by replacing each maximal subformula that is not satisfied by $I$ with the logical constant $ot$ (false). The "reduct" of a set $P$ of propositional formulas relative to $I$ consists of the reducts of all formulas from $P$ relative to $I$. As in the case of disjunctive programs, we say that a set $I$ of atoms is a "stable model" of $P$ if $I$ is minimal (with respect to set inclusion) among the models of the reduct of $P$ relative to $I$.

For instance, the reduct of the set

:$\{p,\; pland\; q\; ightarrow\; r,\; p\; land\; eg\; q\; ightarrow\; s\}$

relative to $\{p,s\}$ is

:$\{p,\; ot\; ightarrow\; ot,\; p\; land\; egot\; ightarrow\; s\}.$

Since $\{p,s\}$ is a model of the reduct, and the proper subsets of that set are not models of the reduct,$\{p,s\}$ is a stable model of the given set of formulas.

We have seen that $\{p,s\}$ is also a stable model of the same formula, written in logic programming notation, in the sense of the original definition. This is an instance of a general fact: in application to a set of (formulas corresponding to) traditional rules, the definition of a stable model according to Ferraris is equivalent to the original definition. The same is true, more generally, for programs with constraints and for disjunctive programs.

**Properties of the general stable model semantics**The theorem asserting that all elements of any stable model of a program $P$ are head atoms of $P$ can be extended to sets of propositional formulas, if we define head atoms as follows. An atom $A$ is a "head atom" of a set $P$ of propositional formulas if at least one occurrence of $A$ in a formula from $P$ is neither in the scope of a negation nor in the antecedent of an implication. (We assume here that equivalence is treated as an abbreviation, not a primitive connective.)

The minimality and the antichain property of stable models of a traditional program do not hold in the general case. For instance, (the singleton set consisting of) the formula

:$plor\; eg\; p$

has two stable models, $empty$ and $\{p\}$. The latter is not minimal, and it is a proper superset of the former.

Testing whether a finite set of propositional formulas has a stable model is $Sigma\_2^\{\; m\; P\}$-complete, as in the case of disjunctive programs.

**Notes****References*** N. Bidoit and C. Froidevaux [1987] "Minimalism subsumes default logic and circumscription". In: Proceedings of LICS-87, pages 89-97.

* T. Eiter and G. Gottlob [1993] " [

*http://www.kr.tuwien.ac.at/staff/eiter/et-archive/ilps93.ps.gz Complexity results for disjunctive logic programming and application to nonmonotonic logics*] ". In: Proceedings of ILPS-93, pages 266-278.* M. van Emden and R. Kowalski [1976] " [

*http://www.doc.ic.ac.uk/~rak/papers/kowalski-van_emden.pdf The semantics of predicate logic as a programming language*] ". Journal of ACM, Vol. 23, pages 733-742.* F. Fages [1994] "Consistency of Clark's completion and existence of stable models". Journal of Methods of Logic in Computer Science, Vol. 1, pages 51-60.

* P. Ferraris [2005] "Answer sets for propositional theories". In: Proceedings of LPNMR-05, pages 119-131.

* P. Ferraris and V. Lifschitz [2005] " [

*http://www.cs.utexas.edu/users/vl/papers/mfasp.ps Mathematical foundations of answer set programming*] ". In: We Will Show Them! Essays in Honour of Dov Gabbay, King's College Publications, pages 615-664.* M. Gelfond [1987] " [

*http://www.cs.ttu.edu/~mgelfond/papers/autoepistemic.pdf On stratified autoepistemic theories*] ". In: Proceedings of AAAI-87, pages 207-211.* M. Gelfond and V. Lifschitz [1988] " [

*http://www.cs.utexas.edu/users/vl/papers/stable.ps The stable model semantics for logic programming*] ". In: Proceedings of the Fifth International Conference on Logic Programming (ICLP), pages 1070-1080.* M. Gelfond and V. Lifschitz [1991] " [

*http://www.cs.utexas.edu/users/vl/papers/clnegdd.ps Classical negation in logic programs and disjunctive databases*] ". New Generation Computing, Vol. 9, pages 365-385.* S. Hanks and D. McDermott [1987] "Nonmonotonic logic and temporal projection". Artificial Intelligence, Vol. 33, pages 379-412.

* F. Lin and Y. Zhao [2004] " [

*http://www.cs.ust.hk/faculty/flin/papers/assat-aij-revised.pdf ASSAT: Computing answer sets of a logic program by SAT solvers*] ". Artificial Intelligence, Vol. 157, pages 115-137.* V. Marek and V.S. Subrahmanian [1989] "The relationship between logic program semantics and non-monotonic reasoning". In: Proceedings of ICLP-89, pages 600-617.

* D. Pearce [1997] "A new logical characterization of stable models and answer sets". In: Non-Monotonic Extensions of Logic Programming (Lecture Notes in Artificial Intelligence 1216), pages 57-70.

* R. Reiter [1980] "A logic for default reasoning". Artificial Intelligence, Vol. 13, pages 81-132.

**See also***

Answer set programming

*Logic programming

*Negation as failure

*Wikimedia Foundation.
2010.*