270 likes | 333 Vues
naturalN. (. 0. ). ¬. naturalN. (. s. (. N. )). naturalN. (. N. ). (. (. ). ). Û. =. Ú. $. =. Ù. nN. (. X. ). X. 0. Y. :. X. s. (. Y. ). nN. (. Y. ). The idea of completion. In LP one uses “if” but mean “iff” [Clark78].
E N D
naturalN ( 0 ). ¬ naturalN ( s ( N )) naturalN ( N ). ( ( ) ) Û = Ú $ = Ù nN ( X ) X 0 Y : X s ( Y ) nN ( Y ) 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
Program completion • The completion of P is the theory comp(P) obtained by: • Replace p(t) ¬j by p(X) ¬ X = t, j • Replace p(X) ¬j by p(X) ¬$Y j, where Y are the original variables of the rule • Merge all rules with the same head into a single one p(X) ¬j1Ú … Újn • For every q(X) without rules, add q(X) ¬^ • Replace p(X) ¬j by "X (p(X) Ûj)
Completion Semantics • 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 • 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
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, failnot 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)
¬ a ¬ q ¬ not b ¬ not p ¬ p ¬ b ¬ p X ¬ not c ¬ p No success nor finite failure X SLDNF example p ¬ p. q ¬ not p. a ¬ not b. b ¬ not c. ¬ c • 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: abnormal(B) ¬ irregular(B) irregular(B) ¬ abnormal(B) bird(tweety). fly(B) ¬ bird(B), not 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 p ¬ p a ¬ b b c ¬ not p d ¬ c, not a e ¬ a, not d f ¬ not c • Least(P1) = {a, b, not p} • Processing this, P2 becomes: c ¬true d ¬ c, false • Its minimal model, together with P1 is: {a, b, c, not d, not p} • Processing this, P3 becomes: e ¬ a, true f ¬false P1 P P2 P3 • The (desired) semantics for P is then: {a, b ,c, not d, e, not f, not p}
Stratification • Let S1;…;Sn be such that S1 U…U Sn = HP, all the Si are disjoint, and for all rules of P: A ¬ B1,…,Bm, not C1,…,not Ck if A Î Si then: • {B1,…,Bm} Í Uij=1 Sj • {C1,…,Ck} Í Ui-1j=1 Sj Let Pi contain all rules of P whose head belongs to Si. P1;…;Pn is a stratification of P
P1 P1 a b ¬ a c ¬ not a a b ¬ a c ¬ not a P2 P P P2 P3 Stratification (cont) • A program may have several stratifications: or • Or may have no stratification: b ¬ not a a ¬ not b • A Normal Logic Program is stratified iff it admits (at least) one stratification.
Semantics of stratified LPs • Let I|R be the restriction of interpretation I to the atoms in R, and P1;…;Pn be a stratification of P. Define the sequence: • M1 = least(P1) • Mi+1 is the minimal models of Pi+1 such that: Mi+1| (Uij=1 Sj) = Mi Mn is the standard model of P • A is true in P iff A Î Mn • Otherwise, A is false
Properties of Standard Model Let MP be the standard model of stratified P • MP is unique (does not depend on the stratification) • MP is a minimal model of P • MP is supported • 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: P1= {even(0)} P2= {even(1) ¬ not even(0)} ... even(0) even(s(X)) ¬ not even(X) • 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) • Thisis 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 b c ¬ a p ¬ not q b ¬ not a c ¬ b q ¬ not r r • Assume, e.g., not r and not p as true, and all others as false. By processing this into P: a ¬false c ¬ a p ¬false b ¬false c ¬ b q ¬true r • 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 b c ¬ a p ¬ not q b ¬ not a c ¬ b q ¬ not r r • Now assume, e.g., not b and not q as true, and all others as false. By processing this into P: a ¬true c ¬ a p ¬true b ¬false c ¬ b q ¬false r • 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 • 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 GP(I) = least(P/I) • M is a stable model of P iff M = GP(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 • 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 • 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. • A semantics Sem is relevant iff for every P: AÎSem(P) iff AÎSem(RelA(P)) where RelA(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 • Don’t provide a meaning to every program: • P = {a ¬ not a} has no stable models • It’s non-cumulative and non-relevant: The only SM is {not a, c,b} a ¬ not b c ¬ not a b ¬ not a c ¬ not c • 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 Relb(P) (non-relevance) • The rules in Relb(P) are the 2 on the left • Relb(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 b c ¬ a b ¬ not a c ¬ b • Note that the perfect model semantics: • is cumulative • is relevant • is supported • its computation is polynomial