





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The concepts of stable and well-founded semantics in logic programming, focusing on the relationship between a program and its database (edb). It covers the uniqueness of stable models, the role of locally stratified models, and the comparison of complexities between stable and well-founded approaches.
Typology: Study notes
1 / 9
This page cannot be seen from the preview
Don't miss anything!






Relationships Among Semantics
If a program + EDB has a strati ed or p erfect (lo cally strati ed) mo del, then that is the unique stable mo del.
A program + EDB can have a unique stable mo del even if there is no p erfect mo del.
Example
p :- NOT q q :- NOT p p :- NOT p
Only fpg is a stable mo del.
Note that without the 3rd rule, b oth fpg and fq g are stable.
Why Strati ed Mo dels are Stable
Intuition to prove strati ed mo del M is stable:
Divide M into strata M 0 ; M 1 ; : : : (M 0 includes the EDB).
LFP of stratum 0 do es not involve negation, so its instantiated rules survive to the inference step of the GL transform, and exactly M 0 is inferred.
Thus, M 0 , and nothing else for stratum 0, is in GL(M ).
Consider what happ ens computing the strati ed mo del at stratum 1.
F Negated subgoals are resolved according to M 0.
F Instantiated rules with a negated memb er of M 0 e ectively disapp ear, and those with a negated nonmemb er of M 0 e ectively lose that subgoal.
Thus, the LFP for stratum 1 lo oks just like the GL transform for the relevant instantiated rules.
Example
Let's revisit the lo cally strati ed \Win" example:
whose relevant instantiated rules were:
r 1 : win(1) :- move(1,2) & NOT win(2) r 2 : win(1) :- move(1,3) & NOT win(3) r 3 : win(2) :- move(2,3) & NOT win(3)
Recall stratum 0 = w in(3) + EDB facts; stratum 1 = w in(2); stratum 2 = w in(1).
Also recall: the strati ed mo del is fw in(1); w in(2)g + the EDB; we must show this mo del is also stable.
Stratum 0: No relevant rules, so w in(3) is false. Likewise, w in(3) is not inferred in the GL pro cedure.
Stratum 1: Since w in(3) is false, the rules for stratum 1 b ecome: r 3 : win(2) :-
w in(2) is inferred, b oth in the strati ed and GL pro cedures.
Stratum 2: Since w in(2) is true and w in(3) is false, the rule for stratum 2 b ecomes: r 2 : win(1) :- Again, the same thing happ ens to this rule in the GL pro cedure, so we infer w in(1) in b oth strati ed and stable approaches.
Well-Founded Mo del
3-valued mo del: true, false, unknown.
WF mo del has p ositive facts like p(1) and negative facts like :p(1).
IDB ground atoms not mentioned are assumed to b e \unknown."
EDB ground atoms not mentioned are assumed false.
Two Mo des of Inference
2
Truth value of w in(1) and w in(2) is \unknown."
Example
p :- q q :- p r :- p & q s :- NOT p & NOT q
fp; q g is an unfounded set.
But fp; q ; r g is the largest unfounded set.
F Note: union of unfounded sets is unfounded, so there is always a largest.
WF mo del: f:p; :q ; :r; sg.
Alternating Fixed Point
In the limit, IDB ground atoms that converge to true are true. Those that converge to false are false. Those that oscillate are unknown.
Example
Rep eating ab ove \Win" example:
Rules pro cessed by (1) and (2):
win(1) :- NOT win(2) win(2) :- NOT win(1) win(2) :- NOT win(3) win(3) :- NOT win(4) win(4) :- NOT win(5) win(5) :- NOT win(6)
Using alternating xed p oint:
Round 0 1 2 3 4 5 w in(1) 0 1 0 1 0 1 w in(2) 0 1 0 1 0 1 w in(3) 0 1 0 1 1 1 w in(4) 0 1 0 0 0 0 w in(5) 0 1 1 1 1 1 w in(6) 0 0 0 0 0 0
Another Example
p :- q; q :- NOT p
Round 0 1 2 3 4 5 p 0 1 0 1 0 1 q 0 1 0 1 0 1
Round 0: Both are 0 as always.
Round 1: Rules simplify to p :- q; q :-. Infer b oth q and p.
Round 2: Rules simplify to p :- q. No inference p ossible!
Round 3 and later: Rep eats.
Conclude b oth p and q are \unknown."
Relationships Among Semantics
If there is a 2-valued WF mo del, it is the unique stable mo del.
If there is a p erfect mo del (i.e., program + EDB is lo cally strati ed), then this mo del is also the stable and WF mo del, and obviously is 2-valued.
There can b e a 3-valued WF mo del when there is no stable semantics (i.e., no unique stable mo del).
Example
Win program with EDB move(1,2), move(2,1).
Two stable mo dels, fw in(1)g and fw in(2)g. Thus, a stable semantics do es not exist.
However, the WF mo del exists and makes b oth w in(1) and w in(2) \unknown."
There can b e a unique stable mo del 6 = WF mo del.
5
Example
Consider a collection of buildings:
Buildings have either lounges or cafeterias, not b oth.
No adjacent buildings b oth have cafeterias.
If a building do es not have a cafeteria, then an adjacent building must have one. lounge(X) :- adj(X,Y) & cafeteria(Y) cafeteria(X) :- NOT lounge(X)
If we get rid of \cafeteria":
lounge(X) :- adj(X,Y) & NOT lounge(Y)
Lo oks just like \win."
Problem is really: nd a maximal indep endent set of buildings in which to put cafeterias.
The stable mo dels are the maximal indep endent sets.
But the WF mo del makes cafeteria(X) true i X is in every maximal indep endent set.
Comparison of Complexity for Stable Versus WF
It is NP-hard to tell whether a prop ositional logic program has a stable semantics, i.e., a unique stable mo del.
It is p olynomial to construct the WF mo del.
Same comments hold for rst-order logic, but with complexity measured in terms of the EDB size rather than the numb er of prop ositions.
Mo dularly Strati ed Semantics
Motivation: largest known class of Datalog- with-negation programs for which magic-sets (query optimization technique to b e discussed) works.
Must b e able to partition the rules into \mo dules," such that
Mo dularly strati ed semantics = what we get by computing lo cally strati ed semantics for mo dules, b ottom up.
Note mo dules are partially ordered by dep endence among their predicates, b ecause all recursion must take place within a single mo dule.
Example
Consider:
win(X) :- move(X,Y) & NOT win(Y)
with mov e relation fmov e(1; 2)g.
We might app ear to have a cycle in the instantiated rules r 1 : win(1) :- move(1,2) & NOT win(2) r 2 : win(2) :- move(2,1) & NOT win(1) But the fact that mov e(2; 1) is false removes r 2.
The only dep endence is w in(1)! w in(2), and this program + EDB is lo cally strati ed.
Example (Continued)
Next, supp ose we add an IDB predicate mov e 1 to b e identical to mov e: win(X) :- move1(X,Y) & NOT win(Y) move1(X,Y) :- move(X,Y)
Now, with the same EDB, we instantiate the w in rule as:
r 1 : win(1) :- move1(1,2) & NOT win(2) r 2 : win(2) :- move1(2,1) & NOT win(1)
It is not apparent that w in(2) do es not dep end on w in(1), so it lo oks like we have a cycle in the dep endency graph. F The di erence is that mov e 1 is IDB, while mov e is EDB.
This program + EDB is not lo cally strati ed.