Content deleted Content added
No edit summary |
Olexa Riznyk (talk | contribs) m Fixing style/layout errors |
||
Line 1:
The concept of a '''stable model''', or answer set, is used to define a declarative semantics for [[Logic programming|logic programs]] with [[negation as failure]].
[[answer set programming]].
==Motivation==
Research on the declarative semantics of negation in logic programming was motivated by the fact that the behavior of [[SLD resolution#SLDNF|SLDNF]]
:<math>p\ </math>
Line 9:
:<math>s \leftarrow p,\ \hbox{not } q.</math>
Given this program, the query <math>p</math> will succeed, because the program includes <math>p</math> as a fact; the query <math>q</math> will fail, because it does not occur in the head of any of the rules.
{| cellpadding=5 style="width:18em"
Line 23:
|}
On the other hand, the rules of the given program can be viewed as [[propositional formula]]s if we identify the comma with conjunction <math>\land
:<math>p \land \neg q \rightarrow s.</math>
If we calculate the [[truth value]]s of the rules of the program for the truth assignment shown above then we will see that each rule gets the value '''T'''. In other words, that assignment is a [[model theory|model]] of the program. But this program has also other models, for instance
{| cellpadding=5 style="width:18em"
Line 43 ⟶ 41:
|}
Thus one of the models of the given program is special in the sense that it correctly represents the behavior of SLDNF resolution.
==Relation to nonmonotonic logic==
The meaning of negation in logic programs is closely related to two theories of [[Nonmonotonic logic|nonmonotonic reasoning]] —
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 <math>\hbox{not}\ p</math> in the body of a rule as "<math>p</math> 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 of formulas called justifications. A default can be used to derive its conclusion under the assumption that its justifications are consistent with what is currently believed. Nicole Bidoit and Christine Froidevaux [1987] proposed to treat negated atoms in the bodies of rules as justifications. For instance, the rule
:<math>s \leftarrow p,\ \hbox{not } q</math>
can be understood as the default that allows us to derive <math>s</math> from <math>p</math> assuming that <math>\neg q</math> is consistent.
==Stable models==
The definition of a stable model below, reproduced from [Gelfond and Lifschitz, 1988], uses two conventions.
{| cellpadding=5 style="width:18em"
Line 76 ⟶ 71:
|}
is identified with the set <math>\{p,s\}</math>.
Second, a logic program with variables is viewed as shorthand for the set of all [[Ground expression|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▼
▲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
:<math>even(0)\ </math>
Line 87 ⟶ 83:
:<math>0,\ s(0),\ s(s(0)),\dots.</math>
in all possible ways.
:<math>even(0)\ </math>
Line 103 ⟶ 99:
:<math>A \leftarrow B_{1},\dots,B_{m},\hbox{not } C_{1},\dots,\hbox{not } C_{n}</math>
where <math>A,B_{1},\dots,B_{m},C_{1},\dots,C_{n}</math> are ground atoms.
For any set <math>I</math> of ground atoms, the ''reduct'' of <math>P</math> relative to <math>I</math> is the set of rules without negation obtained from <math>P</math> by first dropping every rule such that at least one of the atoms <math>C_i</math> in its body
Line 110 ⟶ 105:
:<math>B_{1},\dots,B_{m},\hbox{not } C_{1},\dots,\hbox{not } C_{n}</math>
belongs to <math>I</math>, and then dropping the parts <math>\hbox{not } C_{1},\dots,\hbox{not } C_{n}</math> from the bodies of all remaining rules.
We say that <math>I</math> is a ''stable model'' of <math>P</math> if <math>I</math> is the stable model of the reduct of <math>P</math> relative to <math>I</math>.
===Example===
To illustrate these
:<math>p\ </math>
Line 133 ⟶ 127:
:<math>s \leftarrow p.</math>
(Indeed, since <math>q\not\in\{p,s\}</math>, the reduct is obtained from the program by dropping the part <math>\hbox{not } q.\ </math>)
Checking in the same way the other 15 sets consisting of the atoms <math>p,\ q,\ r,\ s</math> shows that this program has no other stable models. For instance, the reduct of the program relative to <math>\{p,q,r\}</math> is
Line 145 ⟶ 139:
===Programs without a unique stable model===
A program with negation may have many stable models or no stable models.
:<math>p \leftarrow \hbox{not } q</math>
Line 151 ⟶ 145:
:<math>q \leftarrow \hbox{not } p</math>
has two stable models <math>\{p\}</math>, <math>\{q\}</math>.
:<math>p \leftarrow \hbox{not } p</math>
Line 157 ⟶ 151:
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.
But the use of stable models in [[answer set programming]] provides a different perspective on such programs.
==Properties of the stable model semantics==
Line 170 ⟶ 163:
where <math>A,B_{1},\dots,B_{m},C_{1},\dots,C_{n}</math> are ground atoms.
''Head atoms:'' If an atom <math>A</math> belongs to a stable model of a logic program <math>P</math> then <math>A</math> is the head of one of the rules of <math>P</math>.▼
▲If an atom <math>A</math> belongs to a stable model of a logic program <math>P</math> then <math>A</math> is the head of one of the rules of <math>P</math>.
''Minimality:'' Any stable model of a logic program <math>P</math> is minimal among the models of <math>P</math> relative to set inclusion.
''The antichain property:'' If <math>I</math> and <math>J</math> are stable models of the same logic program then <math>I</math> is not a proper subset of <math>J</math>.
▲If <math>I</math> and <math>J</math> are stable models of the same logic program then <math>I</math> is not a proper subset of <math>J</math>. 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]].▼
▲Testing whether a finite ground logic program has a stable model is [[NP-complete]].
==Relation to other theories of negation as failure==
Line 185 ⟶ 175:
===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 [[Negation as failure#Completion semantics|completion]] [Marek and Subrahmanian, 1989].
:<math>p \leftarrow p</math>
is the [[tautology (logic)|tautology]] <math>p \leftrightarrow p</math>.
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.
===Well-founded semantics===
The [[well-founded semantics|well-founded model]] of a logic program partitions all ground atoms into three sets: true, false and unknown.
:<math>p \leftarrow \hbox{not } q</math>
Line 205 ⟶ 195:
:<math>r\leftarrow q</math>
has two stable models, <math>\{p,r\}</math> and <math>\{q,r\}</math>.
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.
==Strong negation==
Line 213 ⟶ 203:
===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.
In the context of logic programming, this idea leads to the need to distinguish between two kinds of negation
:<math>\hbox{Cross} \leftarrow \hbox{not Train}</math>
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.
:<math>\hbox{Cross} \leftarrow \,\sim\hbox{Train}.</math>
Line 231 ⟶ 221:
:<math>A \leftarrow B_{1},\dots,B_{m},\hbox{not } C_{1},\dots,\hbox{not } C_{n}</math>
to be either an atom or an atom prefixed with the strong negation symbol.
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.
For instance, the program
Line 245 ⟶ 235:
:<tt><math>\sim r\leftarrow \hbox{not }p</math></tt>
has two stable models, <math>\{p,r\}\ </math> and <math>\ \{q,r,\sim r\}</math>.
===Closed world assumption===
Line 253 ⟶ 243:
:<math>\sim p(X_1,\dots,X_n)\leftarrow\hbox{not }p(X_1,\dots,X_n)</math>
(the relation <math>p\ </math> does not hold for a tuple <math>X_1,\dots,X_n</math> if there is no evidence that it does).
:<math>p(a,b)\ </math>
Line 275 ⟶ 265:
==Programs with constraints==
The stable model semantics has been generalized to many kinds of logic programs other than collections of "traditional" rules discussed
:<math>A \leftarrow B_{1},\dots,B_{m},\hbox{not } C_{1},\dots,\hbox{not } C_{n}</math>
where <math>A,B_{1},\dots,B_{m},C_{1},\dots,C_{n}</math> are atoms.
:<math>\leftarrow B_{1},\dots,B_{m},\hbox{not } C_{1},\dots,\hbox{not } C_{n}.</math>
Recall that a traditional rule can be viewed as alternative notation for a propositional formula if we identify the comma with conjunction <math>\land
:<math>\neg(B_{1}\land\cdots\land B_{m}\land\neg C_{1}\land\cdots\land\neg C_{n}).</math>
We can now extend the definition of a stable model to programs with constraints.
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
The [[#Properties of the stable model semantics|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 <math>P</math> affects the collection of stable models of <math>P</math> in a very simple way: it eliminates the stable models that violate the constraint.
==Disjunctive programs==
Line 301 ⟶ 291:
:<math>A_1;\dots;A_k \leftarrow B_{1},\dots,B_{m},\hbox{not } C_{1},\dots,\hbox{not } C_{n}</math>
(the semicolon is viewed as alternative notation for disjunction <math>\lor</math>).
For example, the set <math>\{p,r\}</math> is a stable model of the disjunctive program
Line 317 ⟶ 307:
The program above has one more stable model, <math>\{q\}</math>.
As in the case of traditional programs, each element of any stable model of a disjunctive program <math>P</math> is a head atom of <math>P</math>, in the sense that it occurs in the head of one of the rules of <math>P</math>.
==Stable models of a set of propositional formulas==
Rules, and even [[#Disjunctive programs|disjunctive rules]], have a rather special syntactic form, in comparison with arbitrary [[propositional formula]]s.
Pearce's formulation looks very different from the [[#Definition|original definition of a stable model]]. Instead of reducts, it refers to ''equilibrium logic''
===General definition of a stable model===
According to [Ferraris, 2005], the ''reduct'' of a propositional formula <math>F</math> relative to a set <math>I</math> of atoms is the formula obtained from <math>F</math> by replacing each maximal subformula that is not satisfied by <math>I</math> with the logical constant <math>\bot</math> (false).
For instance, the reduct of the set
Line 337 ⟶ 327:
:<math>\{p,\ \bot\rightarrow \bot,\ p \land \neg\bot \rightarrow s\}.</math>
Since <math>\{p,s\}</math> is a model of the reduct, and the proper subsets of that set are not models of the reduct, <math>\{p,s\}</math> is a stable model of the given set of formulas.
We [[#Example|have seen]] that <math>\{p,s\}</math> is also a stable model of the same formula, written in logic programming notation, in the sense of the [[#Definition|original definition]].
===Properties of the general stable model semantics===
The theorem asserting that all elements of any stable model of a program <math>P</math> are head atoms of <math>P</math> can be extended to sets of propositional formulas, if we define head atoms as follows.
The [[#Properties of the stable model semantics|minimality and the antichain property of stable models]] of a traditional program do not hold in the general case.
:<math>p\lor\neg p</math>
has two stable models, <math>\empty</math> and <math>\{p\}</math>.
Testing whether a finite set of propositional formulas has a stable model is [[Polynomial hierarchy|<math>\Sigma_2^{\rm P}</math>-complete]], as in the case of [[#Disjunctive programs|disjunctive programs]].
Line 359 ⟶ 349:
==References==
* N. Bidoit and C. Froidevaux [1987] ''Minimalism subsumes default logic and circumscription''.
* T. {{Not a typo|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]''.
* M. van Emden and [[Robert Kowalski|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''.
* P. Ferraris [2005] ''Answer sets for propositional theories''.
* P. Ferraris and V. Lifschitz [2005] ''[http://www.cs.utexas.edu/users/vl/papers/mfasp.ps Mathematical foundations of answer set programming]''.
* M. Gelfond [1987] ''[http://www.cs.ttu.edu/~mgelfond/papers/autoepistemic.pdf On stratified autoepistemic theories]''. In: Proceedings of AAAI-87, pages 207-211.
|