The idea of completion In LP one uses “if” but mean “iff” [Clark78] This doesn’t imply that -1 is not a natural number! With this program we mean: This is the idea of Clark’s completion: Syntactically transform if’s into iff’s Use classical logic in the transformed theory to provide the semantics of the program ).())(( ).0( NnaturalNNs )()(:0)(YnNYsXYXX
Program completion The completion of P is the theory comp(P) obtained by: Replace p(t) by p(X) X = t, Replace p(X) by p(X) Y , where Y are the original variables of the rule Merge all rules with the same head into a single one p(X) 1 … n For every q(X) without rules, add q(X) Replace p(X) by X (p(X) )
Completion Semantics Though completion’s definition is not that simple, the idea behind it is quite simple Also, it defines a non-classical semantics by means of classical inference on a transformed theory D Let comp(P) be the completion of P where not is interpreted as classical negation: A is true in P iff comp(P) |= A A is false in P iff comp(P) |= not A
SLDNF proof procedure By adopting completion, procedurally we have: not is “negation as finite failure” In SLDNF proceed as in SLD. To prove not A: –If there is a finite derivation for A, fail not A –If, after any finite number of steps, all derivations for A fail, remove not A from the resolvent (i.e. succeed not A) SLDNF can be efficiently implemented (cf. Prolog)
SLDNF example p p. q not p. a not b. b not c. a not b b not c c XX q not p p No success nor finite failure According to completion: –comp(P) |= {not a, b, not c} –comp(P) | p, comp(P) | not p –comp(P) | q, comp(P) | not q
Problems with completion Some consistent programs may became inconsistent: p not p becomes p not p Does not correctly deal with deductive closures edge(a,b).edge(c,d).edge(d,c). reachable(a). reachable(A) edge(A,B), reachable(B). Completion doesn’t conclude not reachable(c), due to the circularity caused by edge(c,d) and edge(d,c) Circularity is a procedural concept, not a declarative one
Completion Problems (cont) Difficulty in representing equivalencies: bird(tweety). fly(B) bird(B), not abnormal(B). abnormal(B) irregular(B) irregular(B) abnormal(B) Completion doesn’t conclude fly(tweety)! –Without the rules on the left fly(tweety) is true –An explanation for this would be: “the rules on the left cause a loop”. Again, looping is a procedural concept, not a declarative one When defining declarative semantics, procedural concepts should be rejected
Program stratification Minimal models don’t have “loop” problems But are only applicable to definite programs Generalize Minimal Models to Normal LPs: –Divide the program into strata –The 1st is a definite program. Compute its minimal model –Eliminate all nots whose truth value was thus obtained –The 2nd becomes definite. Compute its MM –…
Stratification example Least(P 1 ) = {a, b, not p} Processing this, P 2 becomes: c true d c, false Its minimal model, together with P 1 is: {a, b, c, not d, not p} Processing this, P 3 becomes: e a, true f false p p a b b c not p d c, not a e a, not d f not c P1P1 P2P2 P3P3 P The (desired) semantics for P is then: {a, b,c, not d, e, not f, not p}
Stratification D Let S 1 ;…;S n be such that S 1 U…U S n = H P, all the S i are disjoint, and for all rules of P: A B 1,…,B m, not C 1,…,not C k if A S i then: {B 1,…,B m } U i j=1 S j {C 1,…,C k } U i-1 j=1 S j Let P i contain all rules of P whose head belongs to S i. P 1 ;…;P n is a stratification of P
Stratification (cont) A program may have several stratifications: a b a c not a P1P1 P2P2 P3P3 P a b a c not a P1P1 P2P2 P or Or may have no stratification: b not a a not b D A Normal Logic Program is stratified iff it admits (at least) one stratification.
Semantics of stratified LPs D Let I|R be the restriction of interpretation I to the atoms in R, and P 1 ;…;P n be a stratification of P. Define the sequence: M 1 = least(P 1 ) M i+1 is the minimal models of P i+1 such that: M i+1 | (U i j=1 S j ) = M i M n is the standard model of P A is true in P iff A M n Otherwise, A is false
Properties of Standard Model Let M P be the standard model of stratified P M P is unique (does not depend on the stratification) M P is a minimal model of P M P is supported D A model M of program P is supported iff: A M (A Body) P : Body M (true atoms must have a rule in P with true body)
Perfect models The original definition of stratification (Apt et al.) was made on predicate names rather than atoms. By abandoning the restriction of a finite number of strata, the definitions of Local Stratification and Perfect Models (Przymusinski) are obtained. This enlarges the scope of application: even(0) even(s(X)) not even(X) P1= {even(0)} P2= {even(1) not even(0)}... The program isn’t stratified (even/1 depends negatively on itself) but is locally stratified. Its perfect model is: {even(0),not even(1),even(2),…}
Problems with stratification Perfect models are adequate for stratified LPs –Newer semantics are generalization of it But there are (useful) non-stratified LPs even(X) zero(X)zero(0) even(Y) suc(X,Y),not even(X)suc(X,s(X)) Is not stratified because (even(0) suc(0,0),not even(0)) P No stratification is possible if P has: pacifist(X) not hawk(X) hawk(Y) not pacifist(X) This is useful in KR: “X is pacifist if it cannot be assume X is hawk, and vice-versa. If nothing else is said, it is undefined whether X is pacifist or hawk”
SLS procedure In perfect models not includes infinite failure SLS is a (theoretical) procedure for perfect models based on possible infinite failure No complete implementation is possible (how to detect infinite failure?) Sound approximations exist: –based on loop checking (with ancestors) –based on tabulation techniques (cf. XSB-Prolog implementation)
Stable Models Idea The construction of perfect models can be done without stratifying the program. Simply guess the model, process it into P and see if its least model coincides with the guess. If the program is stratified, the results coincide: –A correct guess must coincide on the 1st strata; –and on the 2nd (given the 1st), and on the 3rd … But this can be applied to non-stratified programs…
Stable Models Idea (cont) “Guessing a model” corresponds to “assuming default negations not”. This type of reasoning is usual in NMR –Assume some default literals –Check in P the consequences of such assumptions –If the consequences completely corroborate the assumptions, they form a stable model The stable models semantics is defined as the intersection of all the stable models (i.e. what follows, no matter what stable assumptions)
SMs: preliminary example a not bc a p not q b not ac b q not rr Assume, e.g., not r and not p as true, and all others as false. By processing this into P: a falsec a p false b falsec b q truer Its least model is {not a, not b, not c, not p, q, r} So, it isn’t a stable model: –By assuming not r, r becomes true –not a is not assumed and a becomes false
SMs example (cont) a not bc a p not q b not ac b q not rr Now assume, e.g., not b and not q as true, and all others as false. By processing this into P: a truec a p true b falsec b q falser Its least model is {a, not b, c, p, not q, r} I is a stable model The other one is {not a, b, c, p, not q, r} According to Stable Model Semantics: –c, r and p are true and q is false. –a and b are undefined
Stable Models definition D Let I be a (2-valued) interpretation of P. The definite program P/I is obtained from P by: deleting all rules whose body has not A, and A I deleting from the body all the remaining default literals P (I) = least(P/I) D M is a stable model of P iffM = P (M). A is true in P iff A belongs to all SMs of P A is false in P iff A doesn’t belongs to any SMs of P (i.e. not A “belongs” to all SMs of P).
Properties of SMs Stable models are minimal models Stable models are supported If P is locally stratified then its single stable model is the perfect model Stable models semantics assign meaning to (some) non-stratified programs –E.g. the one in the example before
Importance of Stable Models Stable Models are an important contribution: –Introduce the notion of default negation (versus negation as failure) –Allow important connections to NMR. Started the area of LP&NMR –Allow for a better understanding of the use of LPs in Knowledge Representation –Introduce a new paradigm (and accompanying implementations) of LP It is considered as THE semantics of LPs by a significant part of the community. But...
Cumulativity D A semantics Sem is cumulative iff for every P: if A Sem(P) and B Sem(P) then B Sem(P U {A}) (i.e. all derived atoms can be added as facts, without changing the program’s meaning) This property is important for implementations: –without cumulativity, tabling methods cannot be used
Relevance D A directly depends on B if B occur in the body of some rule with head A. A depends on B if A directly depends on B or there is a C such that A directly depends on C and C depends on B. D A semantics Sem is relevant iff for every P: A Sem(P) iff A Sem(Rel A (P)) where Rel A (P) contains all rules of P whose head is A or some B on which A depends on. Only this property allows for the usual top-down execution of logic programs.
Problems with SMs The only SM is {not a, c,b} a not bc not a b not ac not c Don’t provide a meaning to every program: –P = {a not a} has no stable models It’s non-cumulative and non-relevant: –However b is not true in P U {c} (non-cumulative) P U {c} has 2 SMs: {not a, b, c} and {a, not b, c} –b is not true in Rel b (P) (non-relevance) The rules in Rel b (P) are the 2 on the left Rel b (P) has 2 SMs: {not a, b} and {a, not b}
Problems with SMs (cont) Its computation is NP-Complete The intersection of SMs is non-supported: c is true but neither a nor b are true. a not bc a b not ac b Note that the perfect model semantics: –is cumulative –is relevant –is supported –its computation is polynomial