1 / 15

Datalog as Resolution with Predicate Calculus

Datalog as Resolution with Predicate Calculus. Horn Clause. For resolution, the premises are in CNF. CNF: (…  …  …)  (…  …  …)  …  (…  …  …) Each (…  …  …) is a clause. A horn clause is a disjunction of literals that contains at most one positive (non-negative) literal.

clancy
Télécharger la présentation

Datalog as Resolution with Predicate Calculus

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Datalog asResolution with Predicate Calculus

  2. Horn Clause • For resolution, the premises are in CNF. • CNF: (…  …  …)  (…  …  …)  …  (…  …  …) • Each (…  …  …) is a clause. • A horn clause is a disjunction of literals that contains at most one positive (non-negative) literal. • Horn clause: P  Q  R • Horn clause: P • Horn clause: P • Not a horn clause: P  Q  R  too many positive literals • Note that, in general, a horn clause is an implication with a conjunction of all positive literals on the lhs and one positive (non-negated) literal on the rhs. • Horn clause: P  Q  R  Q  R  P  (Q  R)  P  (Q  R)  P • Degenerate cases: • Horn clause: P  F  P  T  P  T  P • Horn clause: P  P  F  P  F • Horn clause: P1  P2  …  Pn  (P1  P2  …  Pn)  F  P1  P2  …  Pn  F • Not a horn clause: P  Q  R  R  P  Q R  (P  Q)

  3. Horn Clauses as Datalog Rules • One positive literal and one or more negative literals. • e.g. P  Q  R  (Q  R)  P • These are the Datalog rules. • One positive literal and no negative literals. • i.e. P  T  P • “We see P by itself as being true.” • These are the Datalog facts. • No positive literal. • P  P  F or P1  P2  …  Pn  P1  P2  …  Pn  F • “When the consequent is false, we wonder what’s going on.” • These are the Datalog queries  either one query or several.

  4. Horn Clauses with Variables and Quantifiers • For horn clauses in Datalog, we put all clauses in Prenex Normal Form. • Further, to be a valid horn clause, all variables must be universally quantified. • Sample horn clauses with variables and quantifiers: xyz(P(x,y)  Q(x,z)  R(z)) x(R(x)) • Now we discard the universal quantifiers but don’t forget them. One consequence is that variables are local to their own horn clause (i.e. the x’s in P and Q are the same x, but the x’s in P and R are different). P(x,y)  Q(x,z)  R(z) R(x) • We then convert the horn clauses to implications with all positive literals. P(x,y)  Q(x,z)  R(z) R(x)  F • Finally, we modify the syntax so that it corresponds to Datalog. R(z) :- P(x,y),Q(x,z) R(x)?

  5. Instantiation & Resolution • Because every variable is universally quantified, we can instantiate it to any (and every) constant in the domain. (We are in context of a derivation, so all statements are true either by assumption, premise, or by a rule of inference.) R(a) :- P(x,y),Q(x,a) Sza R(a)? Sxa • So, we’re asking if R(a) is true, but the rule says that R(a) is true if P(x,y)  Q(x,a) is true. Formally, we are doing resolution P(x,y)  Q(x,a)  R(a) R(a) P(x,y)  Q(x,a) • We can resolve only when the complementary literals are instantiated identically (unified). R(a)  P(x,y)  Q(x,a) R(a) P(x,y)  Q(x,a)

  6. Example If R(x,y)  P(x,z)  Q(z,y) P(a,b) Q(b,j) Q(b,k) Then R(a,j) 1. P(x,z)  Q(z,y)  R(x,y) 2. P(a,b) 3. Q(b,j) 4. Q(b,k) 5. R(a,j) conclusion unification 6. P(a,z)  Q(z,j)  R(a,j) UI, Sxa Syj 7. P(a,z)  Q(z,j) res 5,6 unification 8. P(a,b)  Q(b,j) Szb 9. Q(b,j) res 2,8 10. (succeed!) res 9,3 Domain = {a,b,j,k}

  7. Example  Same, but with Meaning If aunt(x,y) sister(x,z)  parent(z,y) sister(ann,bob) parent(bob,jay) parent(bob,kay) Then aunt(ann,jay) 1. sister(x,z)  parent(z,y)  aunt(x,y) 2. sister(ann,bob) 3. parent(bob,jay) 4. parent(bob,kay) 5. aunt(ann,jay) conclusion 6. sister(ann,z)  parent(z,jay)  aunt(ann,jay) UI, Sxann Syjay 7. sister(ann,z)  parent(z,jay) res 5,6 8. sister(ann,bob)  parent(bob,jay) Szbob 9. sister(ann,bob) res 3,8 10. (succeed!) res 2,9 Domain = {ann,bob,jay,kay}

  8. Example  in Datalog Notation Facts: sister('ann','bob'). parent('bob','jay'). parent('bob','kay'). Rules: aunt(x,y) :- sister(x,z), parent(z,y). Queries: aunt('ann','jay')? Observe: for aunt('ann','jay') we have exactly the previous proof! Output: yes.

  9. Example  with Variables What do we do for aunt('ann',x)? • Try all proofs with all substitutions from the domain  if a substituted value v for x works, output v. • What’s the domain? Usual choice is all constants in the facts = {'ann', 'bob', 'jay', 'kay'} Try first to prove aunt('ann','ann'). (Assume support strategy) 1. aunt('ann','ann') conclusion 2. aunt('ann','ann') :- sister('ann',z), parent(z,'ann'). Sxann Now observe that the resolution of 1 & 2 is sister('ann',z)  parent(z,'ann') (sp)a  (sp)a And that this is only F if both sister('ann',z) and parent(z,'ann') are T. Thus, we can essentially start over and prove these using resolution one at a time as sub-proofs.

  10. 3a. sister('ann',z) conclusion 3b. sister('ann','ann') Szann 3c. (fail!) can’t resolve, no fact: sister('ann','ann') 1. aunt('ann',x) conclusion 2. aunt('ann','ann') Sxann 3. aunt('ann','ann') :- sister('ann',z), parent(z,'ann'). SxannSyann So, we try the next element of the domain for z, namely, bob. 3a. sister('ann',z) conclusion 3b. sister('ann','bob') Szbob 3c. (succeed!) resolution with fact: sister('ann','bob') Great! Let’s try the 2nd half with bob (the z’s must be the same). 3d. parent(z,'ann') conclusion 3e. parent('bob','ann') Szbob 3f. (fail!) again, no fact: parent('bob','ann') In fact, z='jay', z='kay' all fail on both sister and parent. So, we backtrack to step 2 and try the next element of the domain for x, namely, 'bob'.

  11. Continuing… 2. aunt('ann','bob') conclusion w/Sxbob 3. aunt('ann','bob') :- sister('ann',z), parent(z,'bob'). SxannSybob 3a. sister('ann',z) conclusion 3b. sister('ann','ann') Szann 3c. (fail!) no fact: sister('ann','ann') So, we try the next element of the domain for z, namely, bob. 3a. sister('ann',z) conclusion 3b. sister('ann','bob') Szbob 3c. (succeed!) res with fact: sister('ann','bob') 3d. parent(z,'bob') conclusion 3e. parent('bob','bob') Szbob 3f. (fail!) no fact: parent('bob','bob') Further, z='jay' fails, z='kay' fails, so, we backtrack again.

  12. Continuing with next element in domain for x, namely 'jay' … 2. aunt('ann','jay') Sxjay 3. aunt('ann','jay') :- sister('ann',z), parent(z,'jay'). SxannSyjay 3a. sister('ann',z) conclusion 3b. sister('ann','ann') Szann 3c. (fail!) no fact: sister('ann','ann') 3a. sister('ann',z) conclusion 3b. sister('ann','bob') Szbob 3c. (succeed!) res with fact: sister('ann','bob') 3d. parent(z,'jay') conclusion 3e. parent('bob','jay') Szbob 3f. (succeed!) res with fact: parent('bob','jay') So, both sub-proofs are satisfied and we output “x='jay'”. Are there any more? From what point do we continue?

  13. We can continue from as if we had failed, choosing the next element in domain for z, namely 'jay' … 3a. sister('ann',z) conclusion 3b. sister('ann','jay') Szjay 3c. (fail!) no fact: sister('ann','jay') 3a. sister('ann',z) conclusion 3b. sister('ann','kay') Szkay 3c. (fail!) no fact: sister('ann','kay') So, we again backtrack to step 2 and the next element for x … (Alternatively, since we have succeeded, we can jump back to the query and try the next element of the domain at that level.)

  14. Try to resolve using last element of domain for x, namely, 'kay' … 2. aunt('ann','kay') Sxkay 3. aunt('ann','kay') :- sister('ann',z), parent(z,'kay'). SxannSykay 3a. sister('ann',z) conclusion 3b. sister('ann','ann') Szann 3c. (fail!) no fact: sister('ann','ann') 3a. sister('ann',z) conclusion 3b. sister('ann','bob') Szbob 3c. (succeed!) res with fact: sister('ann','bob') 3d. parent(z,'kay') conclusion 3e. parent('bob','kay') Szbob 3f. (succeed!) res with fact: parent('bob','kay') So, we output “x='kay'”. Continuing, as if we had failed, we try z = 'jay' and z = 'kay', which both fail. (Alternatively, since we succeeded, we can jump back to the query and try the next element of the domain at that level.) We’ve tried all possible substitutions, so we’re done.

  15. Sx=y Sz 'ann' High-Level Overview Sx'ann' 'ann' 'ann' Fail (sister) 'bob' Fail (parent) 'jay' Fail (sister) 'kay' Fail (sister) 'bob' 'ann' Fail (sister) 'bob' Fail (parent) 'jay' Fail (sister) 'kay' Fail (sister) 'jay' 'ann' Fail (sister) Facts: sister('ann','bob'). parent('bob','jay'). parent('bob','kay'). Rules: aunt(x,y) :- sister(x,z), parent(z,y). Queries: aunt('ann',x)? 'bob' Succeeds! 'jay' Fail (sister) 'kay' Fail (sister) 'kay' 'ann' Fail (sister) 'bob' Succeeds! 'jay' Fail (sister) 'kay' Fail (sister)

More Related