Unformatted text preview: Relationships Among Semantics If a program + EDB has a strati ed or perfect
locally strati ed model, then that is the unique
stable model.
A program + EDB can have a unique stable
model even if there is no perfect model. Example
p : NOT q
q : NOT p
p : NOT p Only fpg is a stable model.
Note that without the 3rd rule, both fpg and
fqg are stable. Why Strati ed Models are Stable Intuition to prove strati ed model M is stable:
Divide M into strata M0 ; M1; : : : M0 includes
the EDB.
LFP of stratum 0 does not involve negation,
so its instantiated rules survive to the
inference step of the GL transform, and
exactly M0 is inferred.
Thus, M0 , and nothing else for stratum 0, is
in GLM .
Consider what happens computing the
strati ed model at stratum 1.
3 Negated subgoals are resolved according
to M0 .
3 Instantiated rules with a negated member
of M0 e ectively disappear, and those
with a negated nonmember of M0
e ectively lose that subgoal.
Thus, the LFP for stratum 1 looks just like
the GL transform for the relevant instantiated
rules. Example Let's revisit the locally strati ed Win" example:
1
2
3
whose relevant instantiated rules were:
1 r1: win1 : move1,2 & NOT win2
r2: win1 : move1,3 & NOT win3
r3: win2 : move2,3 & NOT win3
Recall stratum 0 = win3 + EDB facts;
stratum 1 = win2; stratum 2 = win1.
Also recall: the strati ed model is
fwin1; win2g + the EDB; we must show
this model is also stable.
Stratum 0: No relevant rules, so win3 is
false. Likewise, win3 is not inferred in the
GL procedure.
Stratum 1: Since win3 is false, the rules for
stratum 1 become:
r3: win2 :win2 is inferred, both in the strati ed and
GL procedures.
Stratum 2: Since win2 is true and win3 is
false, the rule for stratum 2 becomes:
r2: win1 :Again, the same thing happens to this rule
in the GL procedure, so we infer win1 in both
strati ed and stable approaches. WellFounded Model
3valued model: true, false, unknown.
WF model has positive facts like p1 and
negative facts like :p1.
IDB ground atoms not mentioned are assumed
to be unknown."
EDB ground atoms not mentioned are
assumed false. Two Modes of Inference 1. If body is true, infer head.
2. Look for unfounded sets : If, after instantiating
rules in all possible ways and eliminating
those with a known false subgoal, there is
a set U of positive ground atoms such that
every rule with a member of U in the head has
a member of U as one of its subgoals, then U
is unfounded.
3 We cannot prove any member of U ,
because we would have to prove another
2 member rst.
3 In WF semantics, we infer the negation of
all members of U .
Repeat inference modes until no new
inferences of either type are possible. Example Win" rule with EDB 1 ! 2, 2 ! 1, 2 ! 3 ! 4 !
5 ! 6.
1 2 3 4 5 6 Start by instantiating the Win rule
winX : moveX,Y & NOT winY in all possible ways.
3 Eliminate rules with false bodies.
3 Also eliminate true subgoals from
remaining bodies.
3 For convenience, eliminate rules whose
head has already been inferred.
win1
win2
win2
win3
win4
win5 :::::: NOT
NOT
NOT
NOT
NOT
NOT win2
win1
win3
win4
win5
win6 Round 1: No positive inferences. Largest
unfounded set = fwin6g. Infer :win6.
Round 2: Infer win5. Delete last two rules. One
now has a false subgoal, the other an alreadyinferred head.
win1
win2
win2
win3 :::: NOT
NOT
NOT
NOT win2
win1
win3
win4 Largest unfounded set = fwin4g. Infer :win4.
Round 3: Infer win3, delete last two rules.
win1 : NOT win2
win2 : NOT win1 Now, no unfounded sets, so done.
WF model is
fwin3; win5; :win4; :win6g
3 Truth value of win1 and win2 is
unknown." Example
p
q
r
s :::: q
p
p&q
NOT p & NOT q fp; qg is an unfounded set.
But fp; q; rg is the largest unfounded set.
3 Note: union of unfounded sets is
unfounded, so there is always a largest.
WF model: f:p; :q; :r; sg. Alternating Fixed Point
1. Instantiate rules in all possible ways.
2. Eliminate rules with false EDB or arithmetic
subgoal; eliminate true EDB and arithmetic
subgoals from remaining rules for convenience.
3. Initialize all IDB ground atoms to false.
4. Repeatedly evaluate IDB subgoals by applying
the GL transform to the model consisting of
the EDB + an IDB based on the previous
round's true false decisions.
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
Repeating above Win" example:
1
2
3
4
Rules processed by 1 and 2:
win1
win2
win2
win3
win4
win5 :::::: NOT
NOT
NOT
NOT
NOT
NOT win2
win1
win3
win4
win5
win6 Using alternating xed point:
4 5 6 Round
win1
win2
win3
win4
win5
win6 0
0
0
0
0
0
0 1
1
1
1
1
1
0 2
0
0
0
0
1
0 3
1
1
1
0
1
0 4
0
0
1
0
1
0 5
1
1
1
0
1
0 Another Example
p : q; q : NOT p Round
p
q 012345
010101
010101 Round 0: Both are 0 as always.
Round 1: Rules simplify to p : q; q :.
Infer both q and p.
Round 2: Rules simplify to p : q. No
inference possible!
Round 3 and later: Repeats.
Conclude both p and q are unknown." Relationships Among Semantics
If there is a 2valued WF model, it is the
unique stable model.
If there is a perfect model i.e., program +
EDB is locally strati ed, then this model is
also the stable and WF model, and obviously
is 2valued.
There can be a 3valued WF model when
there is no stable semantics i.e., no unique
stable model. Example Win program with EDB move1,2, move2,1.
Two stable models, fwin1g and fwin2g.
Thus, a stable semantics does not exist.
However, the WF model exists and makes
both win1 and win2 unknown."
There can be a unique stable model 6= WF
model.
5 Example
p : NOT q
q : NOT p
p : NOT p WF model makes p, q unknown."
fpg is the only stable model.
There can be a 2valued WF model when
there is no locally strati ed model. Example
winX : moveX,Y & NOT winY with move de ned by
1 2 3 4 There is a cycle among 1, 2, and 3, so this
program and EDB is not locally strati ed.
However, the WF model is 2valued,
intuitively because the cycle is not followed
from board 3 on best play.
win1
win2
win3
win3 :::: NOT
NOT
NOT
NOT Round
win1
win2
win3
win4 win2
win3
win1
win4 0
0
0
0
0 1
1
1
1
0 2
0
0
1
0 3
1
0
1
0 4
1
0
1
0 Comparisons Between Stable and WF
Approaches
In win" program, true = forced win; false =
forced loss; unknown = draw with best play.
However, in cafeteria" example to follow, the
rules are the same but the intuitive semantics
favors the stable approach.
6 Example
Consider a collection of buildings:
Buildings have either lounges or cafeterias, not
both.
No adjacent buildings both have cafeterias.
If a building does not have a cafeteria, then an
adjacent building must have one.
loungeX : adjX,Y & cafeteriaY
cafeteriaX : NOT loungeX If we get rid of cafeteria":
loungeX : adjX,Y & NOT loungeY Looks just like win."
Problem is really: nd a maximal independent
set of buildings in which to put cafeterias.
The stable models are the maximal
independent sets.
But the WF model makes cafeteriaX true
i X is in every maximal independent set. Comparison of Complexity for Stable Versus
WF
It is NPhard to tell whether a propositional
logic program has a stable semantics, i.e., a
unique stable model.
It is polynomial to construct the WF model.
Same comments hold for rstorder logic,
but with complexity measured in terms of
the EDB size rather than the number of
propositions. Modularly Strati ed Semantics
Motivation: largest known class of Datalogwithnegation programs for which magicsets
query optimization technique to be discussed
works.
Must be able to partition the rules into
modules," such that
1. All recursion is within a module.
7 2. All modules have locally strati ed
semantics with respect to the EDB and
the previously computed models for any
lower modules.
3 I.e., treat all true facts belonging to lower
modules as if they were EDB facts.
Modularly strati ed semantics = what we get
by computing locally strati ed semantics for
modules, bottom up.
Note modules are partially ordered by
dependence among their predicates, because
all recursion must take place within a single
module. Example
Consider: winX : moveX,Y & NOT winY with move relation fmove1; 2g.
We might appear to have a cycle in the
instantiated rules
r1: win1 : move1,2 & NOT win2
r2: win2 : move2,1 & NOT win1
But the fact that move2; 1 is false removes
r2.
The only dependence is win1 ! win2, and
this program + EDB is locally strati ed. Example Continued
Next, suppose we add an IDB predicate
move1 to be identical to move:
winX : move1X,Y & NOT winY
move1X,Y : moveX,Y Now, with the same EDB, we instantiate the win
rule as:
r1: win1 : move11,2 & NOT win2
r2: win2 : move12,1 & NOT win1
It is not apparent that win2 does not
depend on win1, so it looks like we have a
cycle in the dependency graph.
3 The di erence is that move1 is IDB,
while move is EDB.
This program + EDB is not locally strati ed.
8 However, the program + EDB is modularly
strati ed, because we can group move and
move1 into a module and win into a higher
module.
Module for move and move1: We rst
compute the locally strati ed model for
move1, which is fmove11; 2g.
Module for win: We discover that r2 can be
removed, because move12; 1 is known to be
false.
Thus, there is no cycle, and the win module is
also locally strati ed.
Thus, the whole program + EDB is modularly
strati ed. Summary of Semantics
De nition A above de nition B means that
every program + EDB that has a semantics in
B
1. Has a semantics according to A, and
2. The meaning chosen model is the same
for both A and B .
Stable
semantics Wellfounded
semantics
Twovalued
wellfounded
semantics
Modularly
strati ed
semantics
Locally
strati ed
negation
Strati ed
negation
No negation
9 ...
View
Full Document
 Spring '09
 Logic, EDB, Stable model semantics, WF model

Click to edit the document details