Local Stratification and Stable Models in Logic Programming, Study notes of Database Programming

The concept of local stratification and stable models in logic programming. It covers the process of instantiating rules, building dependency graphs, and computing the locally stratified model. The document also discusses the concept of stable models and their intuitive definition, as well as the gelfond-lefschetz transformation for inferring facts using stable models.

Typology: Study notes

2011/2012

Uploaded on 07/15/2012

salagame
salagame 🇮🇳

4

(3)

36 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Local Stratication
Instantiate
rules; i.e., substitute all
possible constants for variables, but reject
instantiations that cause some EDB subgoal
to be false.
Ground atom
= atom with no variables.
Build dependency graph at the level of ground
atoms by instantiating the rules.
Whether program + EDB is lo cally stratied
depends not only on program, but on EDB.
Program + EDB is
locally stratied
i no
negative cycles in dep endency graph.
Example
Win program with boards
f
1
;
2
;
3
g
and moves 1
!
2, 2
!
3, and 1
!
3.
1 2 3
The following three instantiations are the only
ones that cannot be ruled out immediately by
a false
move
subgoal:
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)
The Dep endency Graph
win(1)
win(2)
win(3)
move(1,3)move(1,2) move(2,3)
,,
,
The three
move
ground atoms and
win
(3)
are in stratum 0;
win
(2) is in stratum 1, and
win
(1) is in stratum 2.
1
docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Local Stratification and Stable Models in Logic Programming and more Study notes Database Programming in PDF only on Docsity!

Lo cal Strati cation

 Instantiate rules; i.e., substitute all p ossible constants for variables, but reject instantiations that cause some EDB subgoal to b e false.

F Ground atom = atom with no variables.

 Build dep endency graph at the level of ground atoms by instantiating the rules.

 Whether program + EDB is lo cally strati ed dep ends not only on program, but on EDB.

 Program + EDB is local ly strati ed i no negative cycles in dep endency graph.

Example

Win program with b oards f 1 ; 2 ; 3 g and moves 1! 2, 2! 3, and 1! 3.

 The following three instantiations are the only ones that cannot b e ruled out immediately by a false mov e subgoal: 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)

The Dep endency Graph

win(1)

win(2)

win(3)

move(1,2) move(1,3) move(2,3)

 The three mov e ground atoms and w in(3) are in stratum 0; w in(2) is in stratum 1, and w in(1) is in stratum 2.

Computing the Lo cally Strati ed Mo del

Compute local ly strati ed (\perfect") mo del b ottom-up, deciding on the truth or falseho o d of atoms by computing the LFP of each stratum in turn.

Example

Stratum 0: We nd w in(3) is false.

Stratum 1: That lets us use r 3 to infer w in(2) is true.

Stratum2: We then use r 2 to infer w in(1) is true.

Stable Mo dels

Intuitively, mo del M is \stable" if when you apply the rules to M you get exactly M back.

Example

\Win" rule:

win(X) :- move(X,Y) & NOT win(Y)

with EDB 1! 2, 2! 3, 1! 3.

 M = EDB + fw in(1); w in(2)g is stable.

 The three useful instantiations are 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)

 M makes only the b o dies of r 2 and r 3 true, letting us infer exactly M.

 Note you get the EDB facts \for free" in this pro cess.

Gelfond-Lifschitz Transform

Formal notion of applying rules to a mo del M.

  1. Instantiate rules in all p ossible ways.
  2. Delete instantiated rules with a (nonnegated) EDB subgoal that is not in M or with a false arithmetic subgoal.

F Rememb er, EDB is part of M.

r 2 : win(1) :- move(1,3) r 3 : win(2) :- move(2,3)

 After step (5):

r 2 : win(1) :- r 3 : win(2) :-

 Thus, GL(M ) = fw in(1); w in(2)g + EDB = M.

 M is a stable mo del.

Example

Consider the \program":

p(X) :- p(X)

 ; is the only stable mo del.

 Why? The only instantiated rules are of the form p(a) :- p(a).

F The GL transform do esn't a ect these, no matter what M is. F Thus, there is no way to infer any p(a).

Example

For any Datalog program without negation, the unique LFP is the only stable mo del.

 Why? To test whether M is stable, we compute GL(M ).

F Since there is no negation in b o dies, the surviving instantiated rules are exactly the ones with true EDB subgoals. F Thus, GL infers exactly the LFP for the EDB p ortion of M , regardless of what M is.

F If we start with the LFP, we infer it, so that mo del is stable; if we start with another mo del, we still infer the LFP, so that mo del is not stable.

Prop ositional Stable Mo dels

It is often useful to nd prop ositional examples.

 No EDB in prop ositional logic.

 Thus, only steps (3) and (4), plus the nal inference, are relevant for the GL transform.

Example

p :- q; q :- NOT r; r :- s; s :- NOT p

 M = fp; q g.

 After step (3):

p :- q; q :- NOT r; r :- s

 After step (4):

p :- q; q :- ; r :- s

 Inference: GL(M ) = fp; q g = M.

Multiple Stable Mo dels Possible

Notice that fr; sg is also a stable mo del of the ab ove rules.