Presentation is loading. Please wait.

Presentation is loading. Please wait.

Logic Program Semantics Background Luís Moniz Pereira U.I. at Jakarta, Jan/Feb 2006 AI Centre, Universidade Nova de Lisboa.

Similar presentations


Presentation on theme: "Logic Program Semantics Background Luís Moniz Pereira U.I. at Jakarta, Jan/Feb 2006 AI Centre, Universidade Nova de Lisboa."— Presentation transcript:

1 Logic Program Semantics Background Luís Moniz Pereira U.I. at Jakarta, Jan/Feb 2006 AI Centre, Universidade Nova de Lisboa

2 Language zA 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 zLiteral not B j are called default literals zWhen no rule in P has default literal, P is called definite z The Herbrand base H P is the set of all instantiated atoms from program P. zWe will consider programs as possibly infinite sets of instantiated rules.

3 Declarative Programming zA logic program can be an executable specification of a problem member(X,[X|Y]). member(X,[Y|L])  member(X,L). zEasier to program, compact code zAdequate for building prototypes zGiven efficient implementations, why not use it to “program” directly?

4 LP and Deductive Databases zIn a database, tables are viewed as sets of facts: zOther relations are represented with rules:

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

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

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

8 2-valued Interpretations zA 2-valued interpretation I of P is a subset of H P  A is true in I (ie. I(A) = 1) iff A  I yOtherwise, A is false in I (ie. I(A) = 0) zInterpretations can be viewed as representing possible states of knowledge. zIf knowledge is incomplete, there might be in some states atoms that are neither true nor false

9 3-valued Interpretations zA 3-valued interpretation I of P is a set I = T U not F where T and F are disjoint subsets of H P  A is true in I iff A  T  A is false in I iff A  F yOtherwise, A is undefined (I(A) = 1/2) z2-valued interpretations are a special case, where: H P = T U F

10 Models zModels can be defined via an evaluation function Î: yFor an atom A, Î(A) = I(A) yFor a formula F, Î(not F) = 1 - Î(F) yFor formulas F and G: xÎ((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 zThe 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 D [Truth ordering] For interpretations I and J, I  J iff for all atom A, I(A)  J(A), i.e. T I  T J and F I  F J T Every definite logic program has a least (truth ordering) model. D [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 T P operator zThe minimal models of a definite P can be computed (bottom-up) via operator T P D [T P ] Let I be an interpretation of definite P. T P (I) = {H: (H  Body)  P and Body  I} T If P is definite, T P is monotone and continuous. Its minimal fixpoint can be built by:  I 0 = {} and I n = T P (I n-1 ) T The least model of definite P is T P  ({})

14 Stable Models Idea zThe 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. zThis can be applied to non-stratified programs.

15 Stable Models Idea (cont) z“Guessing a model” corresponds to “assuming default negations not”. This type of reasoning is usual in NMR yAssume some default literals yCheck in P the consequences of such assumptions yIf the consequences completely corroborate the assumptions, they form a stable model zThe 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 bc  a p  not q b  not ac  b q  not rr  Assume, e.g., not r and not p as true, and all others as false. By processing this into P: a  falsec  a p  false b  falsec  b q  truer  Its least model is {not a, not b, not c, not p, q, r} zSo, it isn’t a stable model: yBy assuming not r, r becomes true ynot a is not assumed and a becomes false

17 SMs example (cont) a  not bc  a p  not q b  not ac  b q  not rr  Now assume, e.g., not b and not q as true, and all others as false. By processing this into P: a  truec  a p  true b  falsec  b q  falser  Its least model is {a, not b, c, p, not q, r} zI 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 D 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  P (I) = least(P/I) D M is a stable model of P iffM =  P (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 3Stable models are minimal models 3Stable models are supported 3If P is locally stratified then its single stable model is the perfect model 3Stable models semantics assign meaning to (some) non-stratified programs yE.g. the one in the example before

20 Importance of Stable Models Stable Models were an important contribution: yIntroduced the notion of default negation (versus negation as failure) yAllowed important connections to NMR. Started the area of LP&NMR yAllowed 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 zThe work on LP allows the (non- monotonic) addition of new knowledge. z But: yMuch of the work does not consider this evolution of knowledge xLPs represent a static knowledge of a given world in a given situation. xThe issues of how to add new information to a logic program are less studied.

22 Knowledge Evolution zIn real situations knowledge evolves by: ycompleting it with new information (revision) ychanging 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). y I learn that it is not for Heathrow (revision) y I conclude my flight is for Gatwick y I learn that flights for Heathrow were canceled (update) y Either I have a flight for Gatwick or no flight at all

23 Model Updates zUpdates are usually performed model by model. zMarek and Truszczynski defined a language for defining updates: in(A 0 ) | out(A 0 )  in(A 1 ), …, out(A n ) yGiven an update program and a model of the current situation, produce model(s) of the new situation. yIf several models of the current situation exist, one has to proceed model by model.

24 Updates of Logic Programs zWe’ve defined a program transformation to directly obtain P u P M1M1... MnMn M 1,1 M 1,n1 M n,nn M n,1... U PuPu ? U zWe’ve generalized MT’s approach to the 3- valued case

25 Updates of LPs by LPs zWhen 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. U:not tv_on  p_failure. p_failure. U2:not p_failure. M = {tv,w} Mu = {pf,w} vs Mu 2 = {w} vs {pf,s} {tv,w} zBodies are evaluated in the last state.

26 Generalized LPs  A generalized logic program P is a set of propositional Horn clauses L  L 1,…, L n where L and L i are atoms from L K, 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 L K if for every atom A in K exactly one of A and not A is in M.  Definition: An interpretation M of L K 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 L K is a stable model of a generalized logic program P iff for every A  L K  if P/M |- A then A  M  if A  K  M then P/M |- A where P/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 of DB’ = updated models of DB  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 M U = { power_failure, watch_tv }  the intended model is M I = { power_failure, sleep } U 2 : not power_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 M U = { innocent, found_guilty }  the intended model is M I = { found_guilty }

33 Dynamic Program Updates  Program P is semantically equivalent to the program P’ : innocent  the model M U = { 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. z 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 zHow to update a logic program with another: A  B 1, …, B m, not C 1, …, not C n not A  B 1, …, B m, not C 1, …, not C n

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: A P  B 1, …, B m, C’ 1, …, C’ n A´ P  B 1, …, B m, C’ 1, …, C’ n  (RU) Rewritten updating program clauses: A U  B 1, …, B m, C’ 1, …, C’ n A´ U  B 1, …, B m, C’ 1, …, C’ n

36 Translation into LP  (UR) Update rules: A  A U and not A  A´ U  (IR) Inheritance rules: A  A P, not A´ U and A´  A´ P, not A U  (DR) Default rules: A´  not A P, not A U 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 : sleep P  tv_on´RU : tv_on´ U  power_failure watch_tv P  tv_on power_failure U  tv_on P   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 = { P s : 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 = { P 1, P 2, P 3 } P 1 : sleep  not tv_on watch_tv  tv_on tv_on  P 2 : not tv_on  power_failure power_failure  P 3 : not power_failure   M 1 = { tv_on, watch_tv } is the unique stable model of program  1 P

43 Dynamic LP example (2)  M 2 = { sleep, power_failure } is the unique stable model of the program  2 P.  M 3 = { tv_on, watch_tv } is the unique stable model of the program  3 P.  Program  2 P is semantically equivalent to P 1  P 2.

44 Dynamic LP example (3)  Example: P = { P 1, P 2, P 3, P 4 } P 1 : not fly(X)  animal(X) P 4 : animal(X)  bird(X) P 2 : fly(X)  bird(X) bird(X)  penguin(X) P 3 : 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.


Download ppt "Logic Program Semantics Background Luís Moniz Pereira U.I. at Jakarta, Jan/Feb 2006 AI Centre, Universidade Nova de Lisboa."

Similar presentations


Ads by Google