1 / 36

Advanced Data Modeling Minimal Models

Advanced Data Modeling Minimal Models. Steffen Staab. TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A A A. Overview. Logic as query language. Grounding. Minimal Herbrand models. Completion. Logic as query language. Given:

Télécharger la présentation

Advanced Data Modeling Minimal Models

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. Advanced Data ModelingMinimal Models Steffen Staab TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAAA

  2. Overview • Logic as query language. • Grounding. • Minimal Herbrand models. • Completion.

  3. Logic as query language Given: • first-order formula A[x1, …, xn] • Herbrand interpretation I • This first-order formula can be considered as a definition of a relation RA on T nΣ as follows: (t1, … , tn)  RA := I |= A[t1, … , tn]

  4. Clauses as definitions We say that a clause p(t1, … , tm) :- L1 , … , Ln defines the relation symbol p. Let C be a set of clauses and p be a relation symbol. We call the definition of p in C the set of all clauses in C that define p.

  5. Principles of semantics A deductivedatabaseis a setofclauses. This setofclausesisregardedas a collectionofdefinitionsofrelations. The semanticsdefinesthemeaningofthesedefinitionsbyassociatingwiththem an interpretation, or a classofinterpretations. Query answeringisbased on thesemantics.

  6. Two key assumptions • theuniquenameassumption: eachnamedenotes a uniqueobject. • theclosedworldassumption: • a negative statementA holdsifthecorresponding positive oneA does not hold. Bothassumptionsare not supportedby (Tarskian) modelsfor first-order logics (why not?)  Onesolution: minimal models

  7. Minimal Herbrand Models Let I be a Herbrand model of a set of formulas S. We call I a minimal Herbrand model of S if it is minimal w.r.t. the subset relation, i.e. for every Herbrand model I´of S of the same signature we have I  I´ I is called the least Herbrand model of S if for every Herbrand model I´ of S of the same signature we have I  I´.

  8. Does every set of formulas S have a least Herbrand model?

  9. Does every set of formulas S have a least Herbrand model? Counterexample for normal clauses: person(a). man(X) :- person(X), not woman(X). woman(X) :- person(X), not man(X).

  10. Does every set of formulas S have a least Herbrand model? What about definite clauses?

  11. Instance and variant Let E, E´ be a pair of terms or formulas. E´ is an instance of E, denoted E > E´, if there exists a substitution θ: such that Eθ: = E´. ground instance: instance that is ground, E´ is a variant of E if E´ is an instance of E and E is an instance of E´.

  12. Examples • P(x,a) is instance of P(x,y) because of P(x,y)[y|a] • P(b,a) is a ground instance • P(x,y) and P(u,v) are variants of each other, because of • [x|u, y|v] and • [u|x, v|y]

  13. Grounding • Let C be a set of clauses and Σ be any signature containing all symbols used in C. The grounding of C w.r.t. Σ, denoted C* is the set of all ground instances of the signature Σ of clauses in C. • Lemma. Let I be a Herbrand interpretation and C be a set of clauses. Then I |= C if and only if I |= C*.

  14. General proof scheme calculus First order formula First order Consequences (all possible ways of) grounding lifting calculus Propositional formula Propositional Consequences

  15. Proof

  16. Logic with equality • Additional atomicformulass = t, where s, t areterms. • Abbreviation: x y := (x = y). • Unlikeotherrelations, thesemanticsof s = t ispredefined in all Herbrandinterpretations: I |= s = t if s coincideswith t.

  17. Example valid formulas • f(x1, … , xn) = f(y1, … yn) ! x1 = y1Æ … Æ xn = yn • f(x1, … , xn)  g(y1, … , yn) • f(x1, … ,xn)  c • d  c • A[t] $8x(x = t ! A[x])

  18. Semantics of definitions Consider a definition of a relation r What is the meaning of this definition? Is there a largest Herbrand model? Especially in the light of negation as failure?

  19. Idea of completion man(hans). man(adam). person(eva). woman(X) :- person(X), not man(X). Is eva a woman? She might be a man and we just don‘t know! Minimal model says that she is not a woman! (no minimal model) Trick: Completion: man(X)  (X=hans X=adam). woman(X)  X=eva. I.e. hans and adam are the only men.

  20. Idea of Completion man(hans). man(X) :- lovesBeer(X,Y). Completion: man(X)  X=hans (Y: X=U lovesBeer(U,Y)) A man is a man onlyif he ishansorif he lovessomebrandofbeer.

  21. Completion. Step 1. Replace every clause by an equivalent one such that the arguments of r are x1, …, xn: Given: r(t1, … , tn) :- G Replace by: r(x1, … , xn) :- x1 = t1 … xn = tn G

  22. Completion. Step 2. If there are variables y1, … , yk occurring in a body but not in the head, apply  to these variables, i.e., Given r(x1, … , xn) :- G Modify to r(x1, … , xn) :-  y1 …  yk G

  23. Completion. Step 3. If there are several definitions, replace them by one Given r(x1, … ,xn) :- G1 … r(x1, … , xn) :- Gm Replace by r(x1, … , xn) :- G1 … Gm

  24. Completion. Step 4. Replace :- by $: Given r(x1, … , xn) :- G1Ç … Ç Gm Replace by r(x1, … , xn) $ G1Ç … Ç Gm The formula r(x1, … , xn) $ G1Ç … Ç Gm is called the completed definition of the original set of clauses.

  25. Example r(u,v):-p(u,1,z). r(v,u):-p(2,u,z). r(x,y) :- x=uy=v p(u,1,z). r(x,y) :- x=v y=up(2,v,z). r(x,y) :- z,u,v x=uy=v p(u,1,z). r(x,y) :- z,u,v x=uy=v p(2,v,z). r(x,y)  (z,u,v x=uy=v p(u,1,z)) (z,u,v x=uy=v p(2,v,z))

  26. Properties • All steps preserve Herbrand models, except for the last one. • Why? • Gives a unique semantics to non-recursive definitions • What about recursive definitions? • Logic programming semantics and first-order semantics coincide for definite programs

  27. Recursive definitions odd(1). even(f(X)) :- odd(X). odd(f(X)) :- even(X). Completion: odd(X) X=1 Y(X=f(Y) even(Y)). even(X) Y(X=f(Y) odd(Y)).

  28. Recursive definitions person(adam). person(eva). woman(X) :- person(X), not man(X). man(X) :- person(X), not woman(X). Completion: woman(X) Y(Y=X person(Y) not man(Y)). man(X) Y(Y=X person(Y) not woman(Y)). Semantics not unique in logicprogramming: Models are I={woman(adam),woman(eva),person(adam),person(eva)} I={man(adam),man(eva), person(adam),person(eva)} I={woman(adam),man(eva), person(adam),person(eva)} I={man(adam),woman(eva), person(adam),person(eva)} Whatisthesemantics in firstorderlogics?

  29. Recursive definitions person(adam). person(eva). woman(X) :- person(X), not man(X). man(X) :- person(X), not woman(X). Completion: woman(X) Y(Y=X person(Y) not man(Y)). man(X) Y(Y=X person(Y) not woman(Y)). Semantics not unique in logicprogramming: Models are I={woman(adam),woman(eva),person(adam),person(eva)} I={man(adam),man(eva), person(adam),person(eva)} I={woman(adam),man(eva), person(adam),person(eva)} I={man(adam),woman(eva), person(adam),person(eva)} Whatisthesemantics in firstorderlogics? Models are: womanI={}=manI

  30. Simple characterization of completion Let C be a definition of r, I be a Herbrand model of the corresponding completed definition, and r(t1, … , tn) be a ground atom. Then I |= r(t1, … , tn) , (r(t1, … , tn) :- L1, … , Lm) C* (I |= L1 …  Ln):

  31. Immediate consequence operator TC(I) := { A | thereexists(A :- G)C* such that I |= G } Fixpoint: an interpretation such that TC(I) = I.

  32. Definite clauses have the least model Let C be a setof definite clauses. Define I0 := {} In+1 := TC(In), for all n0, I:= i=0Ii ThenIisthe least fixpointof TCand also the least Herbrandmodelof C.

  33. Non-recursive databases Let C be a non-recursivedatabaseand K be an arbitraryinterpretation. Define I0 := K In+1 := TC(In), for all n 0, I := i=0Ii ThenIistheonlyfixpointof TC. Moreover, forsomenwehaveI= In.

  34. Non-recursive sets of clauses • Let C be a set of clauses. • Its dependency graph consists of pairs p ! r such that p occurs in the body of a clause which defines r in C. • A set of clauses is non-recursive if the dependency graph contains no cycles.

  35. Non-recursive sets of clauses Let C be a set of clauses. Its dependency graph consists of pairs p ! r such that p occurs in the body of a clause which defines r in C. A set of clauses is non-recursive if the dependency graph contains no cycles. Person(a). Woman(X) :- Person(X), Not Man(X). Man(X) :- Person(X), Not Woman(X). Person Man Woman

  36. Non-recursive sets of clauses Dependencygraphof C consistsofpairs p !r such that p occurs in thebodyof a clausewhichdefinesr in C. C is non-recursiveifthedependencygraphcontainsnocycles. A relation p depends on a relationq in C ifthereexists a pathoflength1 fromqto p in thedependencygraphof C. A setofclausesis non-recursiveifandonlyifnorelationdepends on itself.

More Related