1 / 44

Logic Program Semantics Background

Logic Program Semantics Background. Luís Moniz Pereira. AI Centre, Universidade Nova de Lisboa. U.I. at Jakarta, Jan/Feb 2006. Language. A Normal Logic Programs P is a set of rules: H ¬ A 1 , …, A n , not B 1 , … not B m (n,m ³ 0) where H, A i and B j are atoms

Download Presentation

Logic Program Semantics Background

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. Logic Program Semantics Background Luís Moniz Pereira AI Centre, Universidade Nova de Lisboa U.I. at Jakarta, Jan/Feb 2006

  2. Language • A Normal Logic Programs P is a set of rules: H ¬A1, …, An, not B1, … not Bm (n,m ³ 0) where H, Ai and Bj are atoms • Literal not Bj are called default literals • When no rule in P has default literal, P is called definite • The Herbrand base HP is the set of all instantiated atoms from program P. • We will consider programs as possibly infinite sets of instantiated rules.

  3. Declarative Programming • A logic program can be an executable specification of a problem member(X,[X|Y]). member(X,[Y|L])¬ member(X,L). • Easier to program, compact code • Adequate for building prototypes • Given efficient implementations, why not use it to “program” directly?

  4. LP and Deductive Databases • In a database, tables are viewed as sets of facts: • Other relations are represented with rules:

  5. LP and Deductive DBs (cont) • LP allows to store, besides relations, rules for deducing other relations • Note that default negation cannot be classical negation in: • A form of Closed World Assumption (CWA) is needed for inferring non-availability of connections

  6. Default Rules • The representation of default rules, such as “All birds fly” can be done via the non-monotonic operator not

  7. The need for a semantics • In all the previous examples, classical logic is not an appropriate semantics • In the 1st, it does not derive not member(3,[1,2]) • In the 2nd, it never concludes choosing another company • In the 3rd, all abnormalities must be expressed • The precise definition of a declarative semantics for LPs is recognized as an important issue for its use in KRR.

  8. 2-valued Interpretations • A 2-valued interpretation I of P is a subset of HP • A is true in I (ie. I(A) = 1) iff AÎ I • Otherwise, A is false in I (ie. I(A) = 0) • Interpretations can be viewed as representing possible states of knowledge. • If knowledge is incomplete, there might be in some states atoms that are neither true nor false

  9. 3-valued Interpretations • A 3-valued interpretation I of P is a set I = T U not F where T and F are disjoint subsets of HP • A is true in I iff A Î T • A is false in I iff AÎ F • Otherwise, A is undefined (I(A) = 1/2) • 2-valued interpretations are a special case, where: HP = T U F

  10. Models • Models can be defined via an evaluation function Î: • For an atom A, Î(A) = I(A) • For a formula F, Î(not F) = 1 - Î(F) • For formulas F and G: • Î((F,G)) = min(Î(F), Î(G)) • Î(F ¬ G)= 1 if Î(G) £ Î(F), and = 0 otherwise • I is a model of P iff, for all rule H ¬ B of P: Î(H ¬ B) = 1

  11. Minimal Models Semantics • The idea of this semantics is to minimize positive information. What is implied as true by the program is true; everything else is false. • {pr(s),pr(e),ph(s),ph(e),aM(s),aM(e)}is a model • Lack of information that sampaio is a physicist, should indicate that he isn’t • The minimal model is: {pr(s),ph(e),aM(e)}

  12. Minimal Models Semantics • [Truth ordering] For interpretations I and J, I £ J iff for all atom A, I(A) £ J(A), i.e. TIÍ TJ and FIÊ FJ • Every definite logic program has a least (truth ordering) model. • [minimal models semantics] An atom A is true in (definite) P iff A belongs to its least model. Otherwise, A is false in P.

  13. TP operator • The minimal models of a definite P can be computed (bottom-up) via operator TP • [TP] Let I be an interpretation of definite P. TP(I) = {H: (H ¬ Body) Î P and Body Í I} • If P is definite, TP is monotone and continuous. Its minimal fixpoint can be built by: • I0 = {} and In = TP(In-1) • The least model of definite P is TP­w({})

  14. Stable Models Idea • The identification of models can be done by guessing a possible model, processing it into P and checking if its least model coincides with the guess. • This can be applied to non-stratified programs.

  15. Stable Models Idea (cont) • “Guessing a model” corresponds to “assuming default negations not”. This type of reasoning is usual in NMR • Assume some default literals • Check in P the consequences of such assumptions • If the consequences completely corroborate the assumptions, they form a stable model • The stable models semantics is defined as the intersection of all the stable models (i.e. what follows, no matter what stable assumptions)

  16. SMs: preliminary example a ¬ not b c ¬ a p ¬ not q b ¬ not a c ¬ b q ¬ not r r • Assume, e.g., not r and not p as true, and all others as false. By processing this into P: a ¬false c ¬ a p ¬false b ¬false c ¬ b q ¬true r • Its least model is {not a, not b, not c, not p, q, r} • So, it isn’t a stable model: • By assuming not r, r becomes true • not a is not assumed and a becomes false

  17. SMs example (cont) a ¬ not b c ¬ a p ¬ not q b ¬ not a c ¬ b q ¬ not r r • Now assume, e.g., not b and not q as true, and all others as false. By processing this into P: a ¬true c ¬ a p ¬true b ¬false c ¬ b q ¬false r • Its least model is {a, not b, c, p, not q, r} • I is a stable model • The other one is {not a, b, c, p, not q, r} • According to Stable Model Semantics: • c, r and p are true and q is false. • a and b are undefined

  18. Stable Models definition • Let I be a (2-valued) interpretation of P. The definite program P/I is obtained from P by: • deleting all rules whose body has not A, and AÎ I • deleting from the body all the remaining default literals GP(I) = least(P/I) • M is a stable model of P iff M = GP(M). • A is true in P iff A belongs to all SMs of P • A is false in P iff A doesn’t belongs to any SMs of P (i.e. not A “belongs” to all SMs of P).

  19. Properties of SMs • Stable models are minimal models • Stable models are supported • If P is locally stratified then its single stable model is the perfect model • Stable models semantics assign meaning to (some) non-stratified programs • E.g. the one in the example before

  20. Importance of Stable Models Stable Models were an important contribution: • Introduced the notion of default negation (versus negation as failure) • Allowed important connections to NMR. Started the area of LP&NMR • Allowed for a better understanding of the use of LPs in Knowledge Representation It is considered as THE semantics of LPs by a significant part of the community.

  21. LP representing a static world • The work on LP allows the (non-monotonic) addition of new knowledge. • But: • Much of the work does not consider this evolution of knowledge • LPs represent a static knowledge of a given world in a given situation. • The issues of how to add new information to a logic program are less studied.

  22. Knowledge Evolution • In real situations knowledge evolves by: • completing it with new information (revision) • changing it according to the changes in the world itself (updates) • I know that I have a flight booked for London (either for Heathrow or for Gatwick). • I learn that it is not for Heathrow (revision) • I conclude my flight is for Gatwick • I learn that flights for Heathrow were canceled (update) • Either I have a flight for Gatwick or no flight at all

  23. Model Updates • Updates are usually performed model by model. • Marek and Truszczynski defined a language for defining updates: in(A0) | out(A0)  in(A1), …, out(An) • Given an update program and a model of the current situation, produce model(s) of the new situation. • If several models of the current situation exist, one has to proceed model by model.

  24. M1,1 U ? ... M1 M1,n1 ... Pu Mn Mn,1 ... Mn,nn U Updates of Logic Programs • We’ve defined a program transformation to directly obtain Pu P • We’ve generalized MT’s approach to the 3-valued case

  25. Updates of LPs by LPs • When updating LPs, doing it model by model is not desired. It loses the directional information of the LP arrow. P: sleep  not tv_on. watch  tv_on. tv_on. M = {tv,w} Mu = {pf,w} vs {pf,s} U: not tv_on  p_failure. p_failure. U2: not p_failure. Mu2 = {w} vs {tv,w} • Bodies are evaluated in the last state.

  26. Generalized LPs • A generalized logic program P is a set of propositional Horn clauses L  L1 ,…, Ln where L and Liare atoms from LK , i.e. of the form A or ´not A´. • Program P is normal if no head of the clause in P has form not A.

  27. Generalized LP semantics • A set M is an interpretation of LK if for every atom A in K exactly one of A and not A is in M. • Definition: An interpretation M of LK is a stable model of a generalized logic program P if M is the least model of the Horn theory P {not A: A  M}.

  28. Generalized LPs example • Example: K = { a,b,c,d,e} P : a  not b c  b e  not d not d  a, not c d  not e this program has exactly one stable model: M = Least(Pnot {b, c, d}) = {a, e, not b, not c, not d} N = {not a, not e, b, c, d} is not a stable model since N  Least(P {not a, not e})

  29. Relation to stable models • Proposition: An interpretation M of LK is a stable model of a generalized logic program P iff for every ALK • if P/M |- A then A M • if A K  M then P/M |- A whereP/M denotes Gelfond-Lifschitz transform of P wrt M • Conclusion: The class of stable models of generalized logic programs extends the class of stable models of normal programs.

  30. Drawbacks of Interpretation Updates • How to update a logic program P by a logic program U obtaining as a result a new, updated logic program P  U. • Interpretation update approach (H.Katsuno and A.Mendelzon, M.Winslett) :models ofDB’ = updated models ofDB • Drawbacks of this approach: • all the models of DB have to be computed and updated separately • no natural way to compute DB’ (DB’ may not exist) • produces counter-intuitive results when intensional part of DB is allowed to be updated.

  31. Update Example • Example: P : sleep  not tv_on watch_tv  tv_on tv_on  • the only stable model is M = {tv_on, watch_tv} U : not tv_on  power_failure power_failure  • the only update is MU = {power_failure, watch_tv} • the intended model is MI = {power_failure, sleep} U2 : notpower_failure 

  32. Update Example (2) • Example: P : innocent  not found_guilty • the only stable model is M = {innocent} U : found_guilty  • the only update is MU = {innocent, found_guilty} • the intended model is MI = {found_guilty}

  33. Dynamic Program Updates • Program P is semantically equivalent to the program P’ : innocent  the model MU = {innocent, found_guilty} is the only reasonable model of the update of P’ by U. • DB’ depends not only on semantics of DB and update U (interpretation updates) but also on their syntax. • We propose a new approach to the problem of updating knowledge bases represented by logic programs that attempts to eliminate the drawbacks of the previous approaches

  34. Dynamic Program Updates • How to update a logic program with another: A  B1 , … , Bm , not C1, … , not Cn not A B1 , … , Bm , not C1, … , not Cn

  35. Program Update • Definition: Let P and U be generalized logic programs in the language L. By the update of P by U we mean the generalized logic program P U, consisting of the clauses: • (RP) Rewritten original program clauses: AP B1 , … , Bm , C’1, … , C’n A´P  B1 , … , Bm , C’1, … , C’n • (RU) Rewritten updating program clauses: AU B1 , … , Bm , C’1, … , C’n A´U  B1 , … , Bm , C’1, … , C’n

  36. Translation into LP • (UR) Update rules: A  AUand not A  A´U • (IR) Inheritance rules: A  AP , not A´U and A´  A´P , not AU • (DR) Default rules: A´  not AP , not AU and not A  A´

  37. Example • Example: P : sleep  not tv_on watch_tv  tv_on tv_on  U : not tv_on  power_failure power_failure  • P U = (RP)  (RU)  (UR)  (IR)  (DR) RP : sleepP tv_on´ RU : tv_on´U power_failure watch_tvP tv_on power_failureU tv_onP • M = {power_failure, sleep}is the only stable model of P  U

  38. Semantic characterization • Definition: Let M be a model of the program U in the language L. • Def [M] = {not A : M |= Body, (A Body) P U} • Rej [M] = {A Body  P :  (not A  Body’) U and M |= Body’} {not A Body P : (A  Body’) U and M|= Body’} • Res [M] = P  U – Rej [M].

  39. Equivalence to LP translation • Theorem: An interpretation N is a stable model of the update program P  U iff N is an extension of a model M of U such that: M = Least(Res [M] Def [M]) • Conclusion: If N is a stable model of P  U then its restriction M to the language L is a stable model of Res [M].

  40. Properties • Proposition: If M is a stable model of the union P  U of programs P and U , then its extension N is a stable model of the update program P  U. Thus, the semantics of the program P U is always weaker than or equal to the semantics of P  U. • If either P or U is empty, or if both P and U are normal programs, then semantics of P  U and P U coincide.

  41. Dynamic Program Updates • Definition: Let P = { Ps :s S } be a finite or infinite sequence of generalized logic programs. The dynamic program update over the sequence of programs P and at the state s S is a logic program s P resulting from the successive updates.

  42. Dynamic LP example • Example: P = { P1, P2, P3} P1 : sleep  not tv_on watch_tv  tv_on tv_on  P2 : not tv_on  power_failure power_failure  P3: notpower_failure  • M1 = {tv_on, watch_tv} is the unique stable model of program 1 P

  43. Dynamic LP example (2) • M2 = {sleep, power_failure} is the unique stable model of the program 2P. • M3 = {tv_on, watch_tv} is the unique stable model of the program 3P. • Program 2P is semantically equivalent to P1 P2.

  44. Dynamic LP example (3) • Example: P = { P1, P2, P3, P4} P1 : not fly(X)  animal(X) P4 : animal(X)  bird(X) P2 : fly(X)  bird(X) bird(X)  penguin(X) P3 : not fly(X)  penguin(X) animal(pluto)  bird(duffy)  penguin(tweety)  • Program 4 P has a unique stable model in which fly(duffy) is true and both fly(pluto) and fly(tweety) are false.

More Related