Presentation is loading. Please wait.

Presentation is loading. Please wait.

Reasoning with Logic Programming Luís Moniz Pereira José Júlio Alferes Utrecht, August 1999.

Similar presentations


Presentation on theme: "Reasoning with Logic Programming Luís Moniz Pereira José Júlio Alferes Utrecht, August 1999."— Presentation transcript:

1 Reasoning with Logic Programming Luís Moniz Pereira José Júlio Alferes Utrecht, August 1999

2 Course Aim To provide a logic programming integrated framework and working system, for representing knowledge and reason about classical AI topics and applications, such as: ytaxonomies yhypothetical reasoning yabduction yparaconsistent reasoning yrevision ydiagnosis yupdating yactions

3 Course material zThe course comprises research of the last decade on the use of Logic Programming for Knowledge Representation and Reasoning zThis is now a mature area of research zIt presents the basic formalism, proof procedures, and application domains zIt articulates work on semantics, methodologies for KRR, belief revision, and knowledge updates zIt shows open areas with research opportunities zAt the end, pointers to bibliography are provided

4 Course topics zOverview of Logic Programs semantics zExplicit negation semantics zParaconsistency zMethodology for KR in LP zProof procedures zBelief revision and abduction zUpdates of Logic Programs zModeling actions

5 LP for Knowledge Representation zDue to its declarative nature, LP has become a prime candidate for Knowledge Representation and Reasoning zThis has been more noticeable since its relations to other NMR formalisms were established zFor this usage of LP, a precise declarative semantics was in order

6 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.

7 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?

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

9 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

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

11 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.

12 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

13 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

14 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

15 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)}

16 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.

17 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  ({})

18 On Minimal Models 4SLD can be used as a proof procedure for the minimal models semantics: yIf the is a SLD-derivation for A, then A is true yOtherwise, A is false 8The semantics does not apply to normal programs:  p  not q has two minimal models: {p} and {q} There is no least model !

19 The idea of completion zIn LP one uses “if” but mean “iff” [Clark78] zThis doesn’t imply that -1 is not a natural number! zWith this program we mean: zThis is the idea of Clark’s completion: 3Syntactically transform if’s into iff’s 3Use classical logic in the transformed theory to provide the semantics of the program

20 Program completion zThe completion of P is the theory comp(P) obtained by:  Replace p(t)   by p(X)  X = t,   Replace p(X)   by p(X)   Y , where Y are the original variables of the rule  Merge all rules with the same head into a single one p(X)   1  …   n  For every q(X) without rules, add q(X)    Replace p(X)   by  X (p(X)   )

21 Completion Semantics zThough completion’s definition is not that simple, the idea behind it is quite simple zAlso, it defines a non-classical semantics by means of classical inference on a transformed theory D Let comp(P) be the completion of P where not is interpreted as classical negation:  A is true in P iff comp(P) |= A  A is false in P iff comp(P) |= not A

22 SLDNF proof procedure zBy adopting completion, procedurally we have: not is “negation as finite failure” zIn SLDNF proceed as in SLD. To prove not A: yIf there is a finite derivation for A, fail not A yIf, after any finite number of steps, all derivations for A fail, remove not A from the resolvent (i.e. succeed not A) zSLDNF can be efficiently implemented (cf. Prolog)

23 SLDNF example p  p. q  not p. a  not b. b  not c.  a  not b  b  not c  c XX  q  not p  p No success nor finite failure zAccording to completion:  comp(P) |= { not a, b, not c }  comp(P) |  p, comp(P) |  not p  comp(P) |  q, comp(P) |  not q

24 Problems with completion  Some consistent programs may became inconsistent: p  not p becomes p  not p zDoes not correctly deal with deductive closures edge(a,b).edge(c,d).edge(d,c). reachable(a). reachable(A)  edge(A,B), reachable(B).  Completion doesn’t conclude not reachable(c), due to the circularity caused by edge(c,d) and edge(d,c) *Circularity is a procedural concept, not a declarative one

25 Completion Problems (cont) zDifficulty in representing equivalencies: bird(tweety). fly(B)  bird(B), not abnormal(B). abnormal(B)  irregular(B) irregular(B)  abnormal(B)  Completion doesn’t conclude fly(tweety) !  Without the rules on the left fly(tweety) is true yAn explanation for this would be: “the rules on the left cause a loop”. *Again, looping is a procedural concept, not a declarative one *When defining declarative semantics, procedural concepts should be rejected

26 Program stratification zMinimal models don’t have “loop” problems zBut are only applicable to definite programs zGeneralize Minimal Models to Normal LPs: yDivide the program into strata yThe 1st is a definite program. Compute its minimal model yEliminate all nots whose truth value was thus obtained yThe 2nd becomes definite. Compute its MM y…y…

27 Stratification example  Least(P 1 ) = {a, b, not p} zProcessing this, P 2 becomes: c  true d  c, false zIts minimal model, together with P 1 is: {a, b, c, not d, not p} zProcessing this, P 3 becomes: e  a, true f  false p  p a  b b c  not p d  c, not a e  a, not d f  not c P1P1 P2P2 P3P3 P zThe (desired) semantics for P is then: {a, b,c, not d, e, not f, not p}

28 Stratification D Let S 1 ;…;S n be such that S 1 U…U S n = H P, all the S i are disjoint, and for all rules of P: A  B 1,…,B m, not C 1,…,not C k if A  S i then: {B 1,…,B m }  U i j=1 S j {C 1,…,C k }  U i-1 j=1 S j Let P i contain all rules of P whose head belongs to S i. P 1 ;…;P n is a stratification of P

29 Stratification (cont) zA program may have several stratifications: a b  a c  not a P1P1 P2P2 P3P3 P a b  a c  not a P1P1 P2P2 P or zOr may have no stratification: b  not a a  not b D A Normal Logic Program is stratified iff it admits (at least) one stratification.

30 Semantics of stratified LPs D Let I|R be the restriction of interpretation I to the atoms in R, and P 1 ;…;P n be a stratification of P. Define the sequence: M 1 = least(P 1 ) M i+1 is the minimal models of P i+1 such that: M i+1 | (U i j=1 S j ) = M i M n is the standard model of P A is true in P iff A  M n Otherwise, A is false

31 Properties of Standard Model Let M P be the standard model of stratified P 4M P is unique (does not depend on the stratification) 4M P is a minimal model of P 4M P is supported D A model M of program P is supported iff: A  M   (A  Body)  P : Body  M (true atoms must have a rule in P with true body)

32 Perfect models zThe original definition of stratification (Apt et al.) was made on predicate names rather than atoms. zBy abandoning the restriction of a finite number of strata, the definitions of Local Stratification and Perfect Models (Przymusinski) are obtained. This enlarges the scope of application: even(0) even(s(X))  not even(X) P1= {even(0)} P2= {even(1)  not even(0)}... zThe program isn’t stratified (even/1 depends negatively on itself) but is locally stratified.  Its perfect model is: {even(0),not even(1),even(2),…}

33 Problems with stratification zPerfect models are adequate for stratified LPs yNewer semantics are generalization of it zBut there are (useful) non-stratified LPs even(X)  zero(X)zero(0) even(Y)  suc(X,Y),not even(X)suc(X,s(X))  Is not stratified because (even(0)  suc(0,0),not even(0))  P zNo stratification is possible if P has: pacifist(X)  not hawk(X) hawk(Y)  not pacifist(X) zThis is useful in KR: “X is pacifist if it cannot be assume X is hawk, and vice-versa. If nothing else is said, it is undefined whether X is pacifist or hawk”

34 SLS procedure zIn perfect models not includes infinite failure zSLS is a (theoretical) procedure for perfect models based on possible infinite failure zNo complete implementation is possible (how to detect infinite failure?) zSound approximations exist: ybased on loop checking (with ancestors) ybased on tabulation techniques (cf. XSB-Prolog implementation)

35 Stable Models Idea zThe construction of perfect models can be done without stratifying the program. Simply guess the model, process it into P and see if its least model coincides with the guess. zIf the program is stratified, the results coincide: yA correct guess must coincide on the 1st strata; yand on the 2nd (given the 1st), and on the 3rd … zBut this can be applied to non-stratified programs…

36 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)

37 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

38 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

39 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).

40 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

41 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. But...

42 Cumulativity D A semantics Sem is cumulative iff for every P: if A  Sem(P) and B  Sem(P) then B  Sem(P U {A}) (i.e. all derived atoms can be added as facts, without changing the program’s meaning) zThis property is important for implementation: ywithout cumulativity, tabling methods cannot be used

43 Relevance D A directly depends on B if B occurs in the body of some rule with head A. A depends on B if A directly depends on B or there is a C such that A directly depends on C and C depends on B. D A semantics Sem is relevant iff for every P: A  Sem(P) iff A  Sem(Rel A (P)) where Rel A (P) contains all rules of P whose head is A or some B on which A depends on. zOnly this property allows for the usual top-down execution of logic programs.

44 Problems with SMs The only SM is {not a, c, b} a  not bc  not a b  not ac  not c zDon’t provide a meaning to every program:  P = {a  not a} has no stable models zIt’s non-cumulative and non-relevant:  However b is not true in P U { c } (non-cumulative)  P U { c } has 2 SMs: {not a, b, c} and {a, not b, c}  b is not true in Rel b (P) (non-relevance) xThe rules in Rel b (P) are the 2 on the left  Rel b (P) has 2 SMs: {not a, b} and {a, not b}

45 Problems with SMs (cont) zIts computation is NP-Complete zThe intersection of SMs is non-supported: c is true but neither a nor b are true. a  not bc  a b  not ac  b zNote that the perfect model semantics: yis cumulative yis relevant yis supported yits computation is polynomial

46 Well Founded Semantics zDefined in [GRS90], generalizes SMs to 3- valued models. zNote that:  there are programs with no fixpoints of   but all have fixpoints of  2 P = {a  not a}  ({a}) = {} and  ({}) = {a} There are no stable models  But:   ({}) = {} and   ({ a }) = { a }

47 Partial Stable Models D A 3-valued intr. (T U not F) is a PSM of P iff: T =  2 (T) T   (T) F = H P -  (T) The 2nd condition guarantees that no atom is both true and false: T  F = {} P = {a  not a}, has a single PSM: {} a  not bc  not a b  not ac  not c This program has 3 PSMs: {}, {a, not b} and {c, b, not a} The 3rd corresponds to the single SM

48 WFS definition T [WF Model] Every P has a knowledge ordering (i.e. wrt  ) least PSM, obtainable by the transfinite sequence:  T 0 = {}  T i+1 =  2 (T i )  T  = U  <  T , for limit ordinals  Let T be the least fixpoint obtained. M P = T U not (H P -  (T)) is the well founded model of P.

49 Well Founded Semantics zLet M be the well founded model of P:  A is true in P iff A  M  A is false in P iff not A  M  Otherwise (i.e. A  M and not A  M) A is undefined in P

50 WFS Properties zEvery program is assigned a meaning zEvery PSM extends one SM yIf WFM is total it coincides with the single SM zIt is sound wrt to the SMs semantics yIf P has stable models and A is true (resp. false) in the WFM, it is also true (resp. false) in the intersection of SMs zWFM coincides with the perfect model in locally stratified programs (and with the least model in definite programs)

51 More WFS Properties zThe WFM is supported zWFS is cumulative and relevant zIts computation is polynomial (on the number of instantiated rules of P) zThere are top-down proof-procedures, and sound implementations ythese are mentioned in the sequel

52 LP and Default Theories D Let  P be the default theory obtained by transforming: H  B 1,…,B n, not C 1,…, not C m into: B 1,…,B n : ¬C 1,…, ¬C m H T There is a one-to-one correspondence between the SMs of P and the default extensions of  P T If L  WFM(P) then L belongs to every extension of  P

53 LPs as defaults zLPs can be viewed as sets of default rules zDefault literals are the justification: ycan be assumed if it is consistent to do so yare withdrawn if inconsistent  In this reading of LPs,  is not viewed as implication. Instead, LP rules are viewed as inference rules.

54 LP and Auto-Epistemic Logic D Let  P be the AEL theory obtained by transforming: H  B 1,…,B n, not C 1,…, not C m into: B 1  …  B n  ¬ L C 1  …  ¬ L C m  H T There is a one-to-one correspondence between the SMs of P and the (Moore) expansions of  P T If L  WFM(P) then L belongs to every expansion of  P

55 LPs as AEL theories zLPs can be viewed as theories that refer to their own knowledge zDefault negation not A is interpreted as “A is not known” zThe LP rule symbol is here viewed as material implication

56 LP and AEB D Let  P be the AEB theory obtained by transforming: H  B 1,…,B n, not C 1,…, not C m into: B 1  …  B n  B ¬C 1  …  B ¬C m  H T There is a one-to-one correspondence between the PSMs of P and the AEB expansions of  P T A  WFM(P) iff A is in every expansion of  P not A  WFM(P) iff B ¬A is in all expansions of  P

57 LPs as AEB theories zLPs can be viewed as theories that refer to their own beliefs zDefault negation not A is interpreted as “It is believed that A is false” zThe LP rule symbol is also viewed as material implication

58 Extended LPs zIn Normal LPs all the negative information is implicit. Though that’s desired in some cases (e.g. the database with flight connections), sometimes an explicit form of negation is needed for Knowledge Representation  “Penguins don’t fly” could be: noFly(X)  penguin(X)  This does not relate fly(X) and noFly(X) in: fly(X)  bird(X) noFly(X)  penguin(X) For establishing such relations, and representing negative information a new form of negation is needed in LP: Explicit negation - ¬

59 Extended LP: motivation z¬ is also needed in bodies: “Someone is guilty if is not innocent”  cannot be represented by: guilty(X)  not innocent(X)  This would imply guilty in the absence of information about innocent  Instead, guilty(X)  ¬innocent(X) only implies guilty(X) if X is proven not to be innocent  The difference between not p and ¬p is essential whenever the information about p cannot be assumed to be complete

60 ELP motivation (cont) z¬ allows for greater expressivity: “If you’re not sure that someone is not innocent, then further investigation is needed” yCan be represented by: investigate(X)  not ¬innocent(X) z¬ extends the relation of LP to other NMR formalisms. E.g yit can represent default rules with negative conclusions and pre-requisites, and positive justifications yit can represent normal default rules

61 Explicit versus Classical ¬ zClassical ¬ complies with the “excluded middle” principle (i.e. F v ¬F is tautological) yThis makes sense in mathematics yWhat about in common sense knowledge? z¬A is the the opposite of A. zThe “excluded middle” leaves no room for undefinedness hire(X)  qualified(X) reject(X)  ¬ qualified(X) The “excluded middle” implies that every X is either hired or rejected It leaves no room for those about whom further information is need to determine if they are qualified

62 ELP Language zAn Extended Logic Program P is a set of rules: L 0   L 1, …, L m, not L m+1, … not B n (n,m  0) where the L i are objective literals zAn objective literal is an atoms A or its explicit negation ¬A zLiterals not L j are called default literals z The Extended Herbrand base H P is the set of all instantiated objective literals from program P zWe will consider programs as possibly infinite sets of instantiated rules.

63 ELP Interpretations zAn interpretation I of P is a set I = T U not F where T and F are disjoint subsets of H P and ¬L  T  L  F (Coherence Principle) i.e. if L is explicitly false, it must be assumed false by default zI is total iff H P = T U F  I is consistent iff ¬  L: {L, ¬L}  T yIn total consistent interpretations the Coherence Principle is trivially satisfied

64 Answer sets zIt was the 1st semantics for ELPs [Gelfond&Lifschitz90] zGeneralizes stable models to ELPs D Let M - be a stable model of the normal P - obtained by replacing in the ELP P every ¬ A by a new atom A -. An answer-set M of P is obtained by replacing A - by ¬ A in M - A is true in an answer set M iff A  S A is false iff ¬A  S Otherwise, A is unknown zSome programs have no consistent answer sets:  e.g. P = {a  ¬ a  }

65 Answer sets and Defaults D Let  P be the default theory obtained by transforming: L 0  L 1,…,L m, not L m+1,…, not L n into: L 1,…,L m : ¬L m+1,…, ¬L n L 0 where ¬¬A is (always) replaced by A T There is a one-to-one correspondence between the answer-sets of P and the default extensions of  P

66 Answer-sets and AEL D Let  P be the AEL theory obtained by transforming: L 0  L 1,…,L m, not L m+1,…, not L n into: L 1  L L 1  …  L m  L L m   ¬ L L m+1  …  ¬ L L m  L 0  L L 0  T There is a one-to-one correspondence between the answer-sets of P and the expansions of  P

67 The coherence principle zGeneralizing WFS in the same way yields unintuitive results: pacifist(X)  not hawk(X) hawk(X)  not pacifist(X) ¬ pacifist(a)  Using the same method the WFS is: {¬pacifist(a)}  Though it is explicitly stated that a is non-pacifist, not pacifist(a) is not assumed, and so hawk(a) cannot be concluded. zCoherence is not satisfied... Ü Coherence must be imposed

68 Imposing Coherence  Coherence is: ¬L  T  L  F, for objective L  According to the WFS definition, everything is false that doesn’t belong to  (T)  To impose coherence, when applying  (T) simply delete all rules for the objective complement of literals in T “If L is explicitly true then when computing undefined literals forget all rules with head ¬L”

69 WFSX definition D The semi-normal version of P, P s, is obtained by adding not ¬L to every rule of P with head L D An interpretation (T U not F) is a PSM of ELP P iff: T =  P  Ps (T) T   Ps (T) F = H P -  Ps (T) T The WFSX semantics is determined by the knowledge ordering least PSM (wrt  )

70 WFSX example P:pacifist(X)  not hawk(X) hawk(X)  not pacifist(X) ¬ pacifist(a) pacifist(b) Ps:pacifist(X)  not hawk(X), not ¬pacifist(X) hawk(X)  not pacifist(X ), not ¬hawk(X) ¬pacifist(a)  not pacifist(a) pacifist(b) ← not ¬pacifist(b) T 0 = {}  s (T 0 ) = {¬p(a),p(a),h(a),p(b),h(b)} T 1 = {¬p(a)}  s (T 1 ) = {¬p(a),h(a),p(b),h(b)} T 2 = {¬p(a),h(a)} T 3 = T 2 The WFM is: {¬p(a),h(a), not p(a), p(b), not ¬h(a), not ¬p(b), not ¬h(b)}

71 Properties of WFSX zComplies with the coherence principle zCoincides with WFS in normal programs zIf WFSX is total it coincides with the only answer-set zIt is sound wrt answer-sets zIt is supported, cumulative, and relevant zIts computation is polynomial zIt has sound implementations (cf. below)

72 Inconsistent programs  Some ELPs have no WFM. E.g. { a  ¬ a  } zWhat to do in these cases? Explosive approach: everything follows from contradiction xtaken by answer-sets xgives no information in the presence of contradiction Belief revision approach: remove contradiction by revising P xcomputationally expensive Paraconsistent approach: isolate contradiction xefficient xallows to reason about the non-contradictory part

73 WFSXp definition  The paraconsistent version of WFSx is obtained by dropping the requirement that T and F are disjoint, i.e. dropping T   Ps (T) D An interpretation, T U not F, is a PSMp P iff: T =  P  Ps (T) F = H P -  Ps (T) T The WFSXp semantics is determined by the knowledge ordering least PSM (wrt  )

74 WFSXp example P:c  not ba b  a ¬ a d  not e Ps:c  not b, not ¬c a  not ¬a b  a, not ¬b ¬a  not a d  not e, not ¬d T 0 = {}  s (T 0 ) = {¬a,a,b,c,d} T 1 = {¬a,a,b,d}  s (T 1 ) = {d} T 2 = {¬a,a,b,c,d} T 3 = T 2 The WFM is: {¬a,a,b,c,d, not a, not ¬a, not b, not ¬b not c, not ¬c, not ¬d, not e}

75 Surgery situation zA patient arrives with: sudden epigastric pain; abdominal tenderness; signs of peritoneal irritation zThe rules for diagnosing are: yif he has sudden epigastric pain abdominal tenderness, and signs of peritoneal irritation, then he has perforation of a peptic ulcer or an acute pancreatitis ythe former requires surgery, the latter therapeutic treatment yif he has high amylase levels, then a perforation of a peptic ulcer can be exonerated yif he has Jobert’s manifestation, then pancreatitis can be exonerated yIn both situations, the pacient should not be nourished, but should take H 2 antagonists

76 LP representation perforation  pain, abd-tender, per-irrit, not high-amylase pancreat  pain, abd-tender, per-irrit, not jobert ¬nourish  perforationh2-ant  perforation ¬nourish  pancreat h2-ant  pancreat surgery  perforationanesthesia  surgery ¬surgery  pancreat pain. per-irrit. ¬high-amylase. abd-tender. ¬jobert. The WFM is: {pain, abd-tender, per-irrit, ¬high-am, ¬jobert, not ¬pain, not ¬abd-tender, not ¬per-irrit, not high-am, not jobert, ¬nourish, h2-ant, not nourish, not ¬h2-ant, surgery, ¬surgery, not surgery, not ¬surgery, anesthesia, not anesthesia, not ¬anesthesia }

77 Results interpretation zThe symptoms are derived and non-contradictory  Both perforation and pancreatitis are concluded  He should not be fed ( ¬nourish ), but take H 2 antagonists  The information about surgery is contradictory  Anesthesia though not explicitly contradictory ( ¬anesthesia doesn’t belong to WFM) relies on contradiction (both anesthesia and not anesthesia belong to WFM) The WFM is: {pain, abd-tender, per-irrit, ¬high-am, ¬jobert, …, ¬nourish, h2-ant, not nourish, not ¬h2-ant, surgery, ¬surgery, not surgery, not ¬surgery,anesthesia, not anesthesia, not ¬anesthesia }

78 A methodology for KR zWFSXp provides mechanisms for representing usual KR problems: ylogic language ynon-monotonic mechanisms for defaults yforms of explicitly representing negation yparaconsistency handling yways of dealing with undefinedness zIn what follows, we propose a methodology for KR using WFSXp

79 Representation method (1) Definite rules If A then B:  B  A  penguins are birds: bird(X)  penguin(X) Default rules Normally if A then B:  B  A, rule_name, not ¬ B rule_name  not ¬ rule_name  birds normally fly: fly(X)  bird(X), bf(X), not ¬fly(X) bf(X)  not ¬bf(X)

80 Representation method (2) Exception to default rules Under conditions COND do not apply rule RULE:  ¬ RULE  COND  Penguins are an exception to the birds-fly rule ¬bf(X)  penguin(X) Preference rules Under conditions COND prefer rule RULE + to RULE - :  ¬ RULE -  COND, RULE +  for penguins, prefer the penguins-don’t-fly to the birds-fly rule: ¬bf(X)  penguin(X), pdf(X)

81 Representation method (3) Hypotethical rules “If A then B” may or not apply:  B  A, rule_name, not ¬ B rule_name  not ¬ rule_name ¬ rule_name  not rule_name xquakers might be pacifists: pacifist(X)  quaker(X), qp(X), not ¬pacifist(X) qp(X)  not ¬qp(X) ¬qp(X)  not qp(X) For a quaker, there is a PSM with pacifist, another with not pacifist. In the WFM pacifist is undefined

82 Taxonomy example zMammal are animal zBats are mammals zBirds are animal zPenguins are birds zDead animals are animals z Normally animals don’t fly z Normally bats fly z Normally birds fly z Normally penguins don’t fly z Normally dead animals don’t fly The taxonomy: zPluto is a mammal zJoe is a penguin zTweety is a bird zDracula is a dead bat The elements: zDead bats don’t fly though bats do zDead birds don’t fly though birds do zDracula is an exception to the above zIn general, more specific information is preferred The preferences:

83 The taxonomy flies animal bird penguin mammal bat dead animal plutotweetydraculajoe Definite rules Default rules Negated default rules

84 Taxonomy representation Taxonomy animal(X)  mammal(X) mammal(X)  bat(X) animal(X)  bird(X) bird(X)  penguin(X) deadAn(X)  dead(X) Default rules ¬flies(X)  animal(X), adf(X), not flies(X) adf(X)  not ¬adf(X) flies(X)  bat(X), btf(X), not ¬flies(X) btf(X)  not ¬btf(X) flies(X)  bird(X), bf(X), not ¬flies(X) bf(X)  not ¬bf(X) ¬flies(X)  penguin(X), pdf(X), not flies(X) pdf(X)  not ¬pdf(X) ¬flies(X)  deadAn(X), ddf(X), not flies(X) ddf(X)  not ¬ddf(X) Facts mammal(pluto). bird(tweety). deadAn(dracula). penguin(joe). bat(dracula). Explicit preferences ¬btf(X)  deadAn(X), bat(X), r1(X) r1(X)  not ¬r1(X) ¬bf(X)  deadAn(X), bird(X), r2(X) r2(X)  not ¬r2(X) ¬r1(dracula) Implicit preferences ¬adf(X)  bat(X), btf(X) ¬adf(X)  bird(X), bf(X) ¬bf(X)  penguin(X), pdf(X)

85 Taxonomy results

86 SLX: Proof procedure for WFSXp zSLX (SL with eXplicit negation) is a top-down procedure for WFSXp yHere we only present an AND-trees characterization yThe proof procedure details are in [AP96] zIs similar to SLDNF yNodes are either successful or failed yResolution with program rules and resolution of default literals by failure of their complements are as in SLDNF zIn SLX, failure doesn’t mean falsity. It simply means non-verity (i.e. false or undefined)

87 Success and failure zA finite tree is successful if its root is successful, and failed if its root is failed zThe status of a node is determined by: yA leaf labeled with an objective literal is failed yA leaf with true is successful yAn intermediate node is successful if all its children are successful, and failed otherwise (i.e. at least one of its children is failed)

88 Negation as Failure? zAs in SLS, to solve infinite positive recursion, infinite trees are (by definition) failed zCan a NAF rule be used? YES True of not A succeeds if true-or-undefined of A fails True-or-undefined of not A succeeds if true of A fails zThis is the basis of SLX. It defines: yT-Trees for proving truth yTU-Trees for proving truth or undefinedness

89 T and TU-trees zThey differ in that literals involved in recursion through negation, and so undefined in WFSXp, are failed in T-Trees and successful in TU-Trees a  not b b  not a … b not a TU b not a TU a not b T a T x x x x

90 Explicit negation in SLX z¬-literals are treated as atoms zTo impose coherence, the semi-normal program is used in TU-trees a  not b b  not a ¬a b not a x a not b not¬a ¬a¬a true x b not a ¬a¬a true … x x a not b not ¬a x

91 Explicit negation in SLX (2) zIn TU-trees: L also fails if ¬L succeeds true zI.e. if not ¬L fails as true-or-undefined c  not c b  not c ¬b a  b not a x ¬b¬b true c not c ¬a¬a b not¬b a not ¬a x x x c not c c c c … x x x x x x

92 Paraconsistent example b  not a ¬a a b not ¬b not b x not a a true x a x not ¬a ¬ a true x b not a

93 T and TU-trees definition D T-Trees (resp TU-trees) are AND-trees labeled by literals, constructed top-down from the root by expanding nodes with the rules Nodes labeled with objective literal A If there are no rules for A, the node is a leaf Otherwise, non-deterministically select a rule for A A  L 1,…,L m, not L m+1,…, not L n In a T-tree the children of A are L 1,…,L m, not L m+1,…, not L n In a TU-tree A has, additionally, the child not ¬A Nodes labeled with default literals are leafs

94 Success and Failure All infinite trees are failed. A finite tree is successful if its root is successful and failed if its root is failed. The status of nodes is determined by: A leaf node labeled with true is successful A leaf node labeled with an objective literal is failed A leaf node of a T-tree (resp. TU) labeled with not A is successful if all TU-trees (resp. T) with root A (subsidiary tree) are failed; and failed otherwise An intermediate node is successful if all its children are successful; and failed otherwise After applying these rules, some nodes may remain undetermined (recursion through not). Undetermined nodes in T-trees (resp.TU) are by definition failed (resp. successful)

95 Properties of SLX zSLX is sound and (theoretically) complete wrt WFSXp. zEven ignoring rules concerning explicit negation, SLX is sound and (theoretically) complete wrt WFS. zSee [AP96] for the definition of a refutation procedure based on the AND- trees characterization, and for all proofs and details

96 Infinite trees example s  not p, not q, not r p  not s, q, not r q  r, not p r  p, not q WFM is {s, not p, not q, not r} not pnot qnot r s x p q not s r not q not r r not p p q not snot r r not p p not q x x q r not p p not q q not snot r

97 Negative recursion example q  not p(0), not s p(N)  not p(s(N)) s  true WFM = {s, not q} s … not p(0) not q p(0) not p(1) q not s x x p(1) not p(2) p(2) not p(3) x x x x true not p(0) … p(0) not p(1) p(1) not p(2) p(2) not p(3) x x x

98 Guaranteeing termination zThe method is not effective, because of loops zTo guarantee termination in ground programs: Local ancestors of node n are literals in the path from n to the root, exclusive of n Global ancestors are assigned to trees: xthe root tree has no global ancestors xthe global ancestors of T, a subsidiary tree of leaf n of T’, are the global ancestors of T’ plus the local ancestors of n xglobal ancestors are divided into those occurring in T-trees and those occurring in TU-trees

99 Pruning rules zFor cyclic positive recursion: Rule 1 If the label of a node belongs to its local ancestors, then the node is marked failed, and its children are ignored zFor recursion through negation: Rule 2 If a literal L in a T-tree occurs in its global T-ancestors then it is marked failed and its children are ignored

100 Pruning rules (2) L L Rule 1 L L … Rule 2

101 Other sound rules Rule 3 If a literal L in a T-tree occurs in its global TU-ancestors then it is marked failed, and its children are ignored Rule 4 If a literal L in a TU-tree occurs in its global T-ancestors then it is marked successful, and its children are ignored Rule 5 If a literal L in a TU-tree occurs in its global TU-ancestors then it is marked successful, and its children are ignored

102 Pruning examples a  not b b  not a ¬a b not a x a not b not ¬a ¬a¬a true x c  not c b  not c ¬b a  b not a x ¬b¬b true c not c ¬a¬a b not ¬b a not ¬a x x x x x Rule 3 b Rule 2 x

103 Non-ground case zThe characterization and pruning rules apply to allowed non-ground programs, with ground queries zIt is well known that pruning rules do not generalize to general programs with variables: p(X)  p(Y) p(a) p(X) p(Y) What to do? If “fail”, the answers are incomplete If “proceed” then loop p(Z)

104 Tabling zTo guarantee termination in non-ground programs, instead of ancestors and pruning rules, tabulation mechanisms are required ywhen there is a possible loop, suspend the literal and try alternative solutions ywhen a solution is found, store it in a table yresume suspended nodes with new solutions in the table yapply an algorithm to determine completion of the process, i.e. when no more solutions exist, and fail the corresponding suspended nodes

105 Tabling example zWe’ve implemented SLX with tabulation mechanisms zWe’ve made use of the XSB- Prolog tabling implementation zSLX with tabling is available with XSB-Prolog Version 2.0 zTry it at: p(X)  p(Y) p(a) p(X) p(Y) 1) suspend X = a 2) resume Y = a X = _ Table for p(X) http://www.cs.sunysb.edu/~sbprolog/xsb-page.html

106 Floundering zAnother (well known) problem when generalizing for non-ground LPs is floundering zTabling doesn’t help here a  not p(X) p(a) p(X) X = a a not p(X) x x Incorrect! zTo solve floundering we’ve been working on constructive negation methods zA preliminary implementation exists zBut a lot remains to be done!

107 LP for KRR (review) zMuch work has been done: 4Semantics of LP (allow LPs to be viewed as NMR formalisms) 4Extensions with: explicit negation, abduction, paraconsistency, disjunction, ICs, epistemic operators, … 4Formal relations to other formalisms (e.g. default logic, AEL, …) 4Techniques to represent and reason about knowledge using LPs

108 LP and Non-Monotonicity zThese works focus on non-monotonicity: yLP includes a non-monotonic form of default negation not L is true if L cannot (now) be proven zThis feature is used for representing incomplete knowledge: With incomplete knowledge, assume hypotheses, and jump to conclusions. If (later) the conclusions are proven false, withdraw some hypotheses to regain consistency.

109 Typical example zAll birds fly. Penguins are an exception: flies(X)  bird(X), not ab(X).bird(a) . ab(X)  penguin(X). zIf later we learn penguin(a): yAdd: penguin(a). yGoes back on the assumption not ab(a). yNo longer concludes flies(a). This program concludes flies(a), by assuming not ab(a).

110 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.

111 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

112 Logic Programs Revision zThe problem: yA LP represents consistent incomplete knowledge; yNew factual information comes. yHow to incorporate the new information? z The solution: yAdd the new facts to the program yIf the union is consistent this is the result yOtherwise restore consistency to the union zThe new problem: yHow to restore consistency to an inconsistent program?

113 Simple revision example (1) P:flies(X)  bird(X), not ab(X).bird(a) . ab(X)  penguin(X). We learn penguin(a). P  {penguin(a)} is consistent. Nothing more to be done. We learn instead ¬flies(a). P  {¬flies(a)} is inconsistent. What to do? Since the inconsistency rests on the assumption not ab(a), remove that assumption (e.g. by adding the fact ab(a), or forcing it undefined with ab(a)  u) obtaining a new program P’. y If an assumption supports contradiction, then go back on that assumption.

114 Simple revision example (2) P:flies(X)  bird(X), not ab(X).bird(a) . ab(X)  penguin(X). y If an assumption supports contradiction, then go back on that assumption. If later we learn flies(a). P’  {flies(a)} is inconsistent. The contradiction does not depend on assumptions. Cannot remove contradiction! y Some programs are non-revisable.

115 What to remove? zWhich assumptions should be removed? normalWheel  not flatTyre, not brokenSpokes. flatTyre  leakyValve. ¬ normalWheel  wobblyWheel. flatTyre  puncturedTube. wobblyWheel .  Contradiction can be removed by either dropping not flatTyre or not brokenSpokes  We’d like to delve deeper in the model and (instead of not flatTyre ) either drop not leakyValve or not puncturedTube.

116 Revisables Revisables = not {leakyValve, punctureTube, brokenSpokes} Revisions in this case are {not lv}, {not pt}, and {not bs} zSolution: yDefine a set of revisables: normalWheel  not flatTyre, not brokenSpokes. flatTyre  leakyValve. ¬ normalWheel  wobblyWheel. flatTyre  puncturedTube. wobblyWheel .

117 Integrity Constraints zFor convenience, instead of: ¬ normalWheel  wobblyWheel we may use the denial:   normalWheel, wobblyWheel zWe’ve further generalized ICs into: L 1  …  L n  L n+1  …  L m where L i s are literals (possibly not L).

118 ICs and Contradiction zIn an ELP with ICs, add for every atom A:   A, ¬A zA program P is contradictory iff P   where  is the paraconsistent derivation of SLX

119 Algorithm for 3-valued revision zFind all derivations for , collecting for each one the set of revisables supporting it. Each is a support set. zCompute the minimal hitting sets of the support sets. Each is a removal set. zA revision of P is obtained by adding {A  u: A  R} where R is a removal set of P.

120 Example Rev = not {a,b,c}   p, q p  not a. q  not b, r. r  not b. r  not c.  pq not arnot b not c Support sets are:{not a, not b}and {not a, not b, not c}. Removal sets are: {not a} and {not b}.

121 Simple diagnosis example inv(G,I,0)  node(I,1), not ab(G). inv(G,I,1)  node(I,0), not ab(G). node(b,V)  inv(g1,a,V). node(a,1). ¬node(b,0). %Fault model inv(G,I,0)  node(I,0), ab(G). inv(G,I,1)  node(I,1), ab(G). a=1 b0b0 g1 The only revision is: P U {ab(g1)  u} It does not conclude node(b,1). zIn diagnosis applications (when fault models are considered) 3-valued revision is not enough.

122 2-valued Revision zIn diagnosis one often wants the IC: ab(X) v not ab(X)  yWith these ICs (that are not denials), 3- valued revision is not enough. zA two valued revision is obtained by adding facts for revisables, in order to remove contradiction. zFor 2-valued revision the algorithm no longer works…

123 Example zIn 2-valued revision: ysome removals must be deleted; ythe process must be iterated.   p.   a.   b, not c. p  not a, not b.  a X p not a not b b not c X The only support is {not a, not b}. Removals are {not a} and {not b}. P U {a} is contradictory (and unrevisable). P U {b} is contradictory (though revisable). But:

124 Algorithm for 2-valued revision 1Let Revs={{}} 2For every element R of Revs: yAdd it to the program and compute removal sets. yRemove R from Revs yFor each removal set RS: yAdd R U not RS to Revs 3Remove non-minimal sets from Revs 4Repeat 2 and 3 until reaching a fixed point of Revs. zThe revisions are the elements of the final Revs.

125 Choose {b}. The removal set of P U {b} is {not c}. Add {b, c} to Rev. Choose {b,c}. The removal set of P U {b,c} is {}. Add {b, c} to Rev. Choose {}. Removal sets of P U {} are {not a} and {not b}. Add them to Rev. Example of 2-valued revision   p.   a.   b, not c. p  not a, not b. Rev 0 = {{}} Rev 1 = {{a}, {b}} Choose {a}. P U {a} has no removal sets. Rev 2 = {{b}} Rev 3 = {{b,c}} The fixed point had been reached. P U {b,c} is the only revision. = Rev 4

126 REVISE zThe algorithm with various optimizations had been implemented - REVISE system. yRevise also has: xThe possibility of defining a partial ordering of preferences among revisables. xAssociate probabilities to revisables. xAlso computes revisions with minimal cardinality. Try it at: http://www.soi.city.ac.uk/homes/msch/revise/revise.html http://www.soi.city.ac.uk/homes/msch/revise/revise.html yOptimizations include: xPruning of the search space. xMaking use of preferences and probabilities.

127 Generalizations zThe framework was generalized to encompass: yGeneral ICs yMixed 2 and 3-valued revisions (according to ICs) zThis required: yNotion of program state (revisables literals may change) yComplex notion of distance between two states, for minimal change

128 Revision and Diagnosis zIn model based diagnosis one has: ya program P with the model of a system (the correct and, possibly, incorrect behaviors) ya set of observations O inconsistent with P (or not explained by P). zThe diagnoses of the system are the revisions of P U O. zWe’ve shown how to perform mixed consistency and abduction based diagnosis.

129 Diagnosis Example 1 1 1 1 0 c1=0 c3=0 c6=0 c7=0 c2=0 0 1 g10 g11 g16 g19 g22 g23

130 Diagnosis Program Observables obs(out(inpt0, c1), 0). obs(out(inpt0, c2), 0). obs(out(inpt0, c3), 0). obs(out(inpt0, c6), 0). obs(out(inpt0, c7), 0). obs(out(nand, g22), 0). obs(out(nand, g23), 1). Predicted and observed values cannot be different  obs(out(G, N), V1), val(out(G, N), V2), V1  V2. Connections conn(in(nand, g10, 1), out(inpt0, c1)). conn(in(nand, g10, 2), out(inpt0, c3)). … conn(in(nand, g23, 1), out(nand, g16)). conn(in(nand, g23, 2), out(nand, g19)). Value propagation val( in(T,N,Nr), V )  conn( in(T,N,Nr), out(T2,N2) ), val( out(T2,N2), V ). val( out(inpt0, N), V )  obs( out(inpt0, N), V ). Normal behavior val( out(nand,N), V )  not ab(N), val( in(nand,N,1), W1), val( in(nand,N,2), W2), nand_table(W1,W2,V). Abnormal behavior val( out(nand,N), V )  ab(N), val( in(nand,N,1), W1), val( in(nand,N,2), W2), and_table(W1,W2,V). Run

131 Diagnosis Example c1=0 c3=0 c6=0 c7=0 c2=0 0 1 g10 g11 g16 g19 g22 g23 Revision are:{ab(g23)}, {ab(g19)}, and {ab(g16),ab(g22)} 1 1 1 1 1 0 1 1 0 1 1 0 1 1 1 0 1 0

132 Revision and Debugging zDeclarative debugging can be seen as diagnosis of a program. zThe components are: yrule instances (that may be incorrect). ypredicate instances (that may be uncovered) zThe (partial) intended meaning can be added as ICs. zIf the program with ICs is contradictory, revisions are the possible bugs.

133 Debugging Transformation zAdd to the body of each possibly incorrect rule r(X) the literal not incorrect(r(X)). zFor each possibly uncovered predicate p(X) add the rule: p(X)  uncovered(p(X)). zFor each goal G that you don’t want to prove add:   G. zFor each goal G that you want to prove add:   not G.

134 Debugging example a  not b b  not c WFM = {not a, b, not c} b should be false a  not b, not incorrect(a  not b) b  not c, not incorrect(b  not c) a  uncovered(a) b  uncovered(b) c  uncovered(c)   b Revisables are incorrect/1 and uncovered/1 Revision is: {incorrect(b  not c)} {uncovered(c)} BUT a should be false! Add   a Revisions now are: {inc(b  not c), inc(a  not b)} {unc(c ), inc(a  not b)} BUT c should be true! Add   not c The only revision is: {unc(c ), inc(a  not b)}

135 Abduction as Revision zFor abductive queries: yDeclare as revisable all the abducibles yIf the abductive query is Q, add the IC:   not Q yThe revision of the program are the abductive solutions of Q.

136 Current and Future Work zMuch has to be done regarding algorithms for computing revisions, and their implementations. yInterleave the computation of supports and removals. yAdd tabulation yHeuristics in the computation of removals yDistribute the algorithm (?)

137 Example Rev = not {a,b,c}   p, q p  not a. r  not b. q  not b, r. r  not c.  p not a q rnot b not c Removal sets are: {not a {not b } } yWhat if there were several suspended? yWhich one to resume first? (heuristics) yHow to traverse the tree?

138 Ongoing Implementation zImplemented with PVM-Prolog on a “farm” of alphas. zQuite preliminary Revision Module Tabulation Manager...... resume node (parts of) the tree revisions Distributed tabulation system

139 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

140 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.

141 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

142 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.

143 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.

144 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 }.

145 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 })

146 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.

147 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.

148 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 

149 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 }

150 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

151 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

152 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

153 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´

154 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

155 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 ].

156 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 ].

157 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.

158 Relation to interpretation updates  Theorem: Program updates generalize interpretation updates Let I be any interpretation and U any updating program in the language L. An interpretation J is an update of I by U ( in the sense of W.Marek and M.Truszczynski ) iff J is a stable model of the program update P I  U, where P I = { A  : A  I }  { not A  : not A  I }

159 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 consisting of:  (RP) Rewritten program clauses: A Ps  B 1, …, B m, C’ 1, …, C’ n A´ Ps  B 1, …, B m, C’ 1, …, C’ n  (UR) Update rules: A s  A ps and A´ s  A´ Ps

160 Translation into LPs  (IR) Inheritance rules: A s  A s-1, not A´ Ps and A´ s  A´ s-1, not A Ps  (DR) Default rules: A´ 0   (CS) Current state rules: A  A s and not A  A´ s

161 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

162 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.

163 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.

164 Properties  Theorem: Let P 1 and P 2 be arbitrary generalized logic programs and let S = { 1,2 }. The dynamic program update  2 { P 1, P 2 } at state s = 2 is semantically equivalent to the program update P 1  P 2.  Dynamic program updates describe the evolution of a logic program which undergoes a sequence of modifications.  This opens up the possibility of incremental design and evolution of logic programs, leading to the paradigm of dynamic logic programming.

165 Current and future work  Explore applicability of dynamic logic programming for:  Representing the evolution of software specifications  Reasoning about concurrent actions and active and temporal databases.  Preference based approaches to knowledge representation.

166 Current and future work zImplementation available at: http://www-ssdi.di.fct.unl.pt/~jja/updates/ zGeneralizations to: y3-valued case (W.F. Semantics) yActive rules: ( A  B )  C whenever C, add A  B to the update program yMixing revision and updates xIn some cases an update may require revision of previous knowledge xE.g. when an observation changes its value.

167 Current and Future Work (2) zThe current implementation already has: y3-valued semantics yquerying states other than the last one ybackground rules zImplementational issues: ygarbage collection yre-use of results from previous stages

168 Equivalent 2-valued semantics  Definition: Let P - be the normal program obtained from the generalized P by replacing every negative head not A by the new atom A -. Let I - be such that I - =  P- (I) and for no A, {A,A - }  I -. Then the interpretation I, obtained from I - by removing all the new atoms, is a stable model of P.

169 Generalization to 3-values zThe same technique doesn’t work in this case a  not b b  not a not a  zWith that technique the WFM would be {not a} zOne has to guarantee that, when A - holds, default not A must also hold zIn the alternating fixpoint definition of WFS, this is achieved by, while calculating non-false atoms, removing all rules for A when A - holds.

170 3-valued semantics ]Definition: The semi-normal version P s - of program P - is obtained by adding not A - (resp. not A) to the body of every rule with head A (resp. A - ). ]Definition: Let I be such that: I =  P- (  Ps- (I)) and I   Ps- (I). Let M = T U not F, where T is obtained from I by removing atoms of the form A -, and F is the set of atoms A not in  Ps- (I). Then M is a Partial Stable Model of P. The knowledge-least M is the Well Founded Model of P

171 Application Domains zA program has knowledge true at a state. zDifferent states may represent: ydifferent time points - reasoning about time ydifferent priorities - preferences ydifferent viewpoints - combining knowledge zMaintenance of software specifications yLP for software specification yDynamic LP for representing evolution of software specification

172 LUPS update language - Syntax  The language L in which our object-level knowledge is expressed is called the object language. Its formulae are generalized logic program rules of the form: A  B 1  B k  not C 1  not C m not A  B 1  B k  not C 1  not C m where A’s and B’s are objective atomic formulae.  Queries also have the form of logic program queries: holds {B1  Bk  not C1  not Cm } ?

173 Knowledge states  Knowledge states KS represent dynamically evolving states of our knowledge. They undergo change due to update actions.  In the initial, default knowledge state KS 0 all predicates are false by default, i.e., KS 0 semantically implies not A, for all objective A’s.

174 Knowledge state updating zGiven the current knowledge state KS, its successor knowledge state KS[U] is produced as a result of the occurrence of a non-empty set U of parallel updates. Each of the updates can be viewed as a (parallel) action. Thus consecutive knowledge states are obtained as: KS n = KS 0 [U 1 ][U 2 ]...[U n ], where U n represents consecutive sets of updates. We denote this state by: KS n =U 0  U 1 ...  U n. using the meta-language extending the object language L.

175 Knowledge state updating  An update (defined precisely below) is either an assertion or a retraction of some formula (clause) A  B 1  B k  not C 1  not C m not A  B 1  B k  not C 1  not C m.  An update action may be subject to some preconditions being true in the current knowledge state KS n = U 0  U 1 ...  U n.  Update actions do NOT modify the current or any of the previous knowledge states. They only affect future states, beginning with the successor state KS[U].  It is assumed we always know what the current state is.

176 Queries  Our goal has been to provide both declarative as well as procedural semantics for dynamic updates, allowing us to answer both declaratively and procedurally any query about either the current or any of the ancestor knowledge states.  Queries involving a knowledge state KS -- either the current one KS n = U 0  U 1 ...  U n or one of the ancestor states KSm = U0  U1 ...  Um, where m<n -- are of the form: holds {B 1  B k  not C 1  not C m } at KS ?  If the query involves the current state we skip the state reference and ask: holds {B 1  B k  not C 1  not C m } ?

177 Update actions They cause changes to the current knowledge state, leading to a successor state. They are called assertions, with form: assert{A  B 1  B k  notC 1  notC m } when {D 1  D n  notE 1  notE p } assert{notA  B 1  B k  notC 1  notC m } when {D 1  D n  notE 1  notE p } The meaning of the assert rule is that if the precondition when {D 1  D n  notE 1  notE p } is true in the current knowledge state then the rule A  B 1  B k  notC 1  notC m is true in the next state, and persists from then on by inertia, until defeated by some future update or retracted.

178 Update actions  A  B 1  B k  notC 1  notC m can be preceded with the keyword “ event ”, indicating that the added rule is non-inertial, i.e. a one-time event that is not assumed to hold true by inertia after the successor state, viz.: assert event {A  B 1  B k } when {C 1  C m }. zWhen the set of preconditions is empty then we just skip the whole keyword: when {...} assert [event] {A  B 1  B k }

179 Persistent update actions z While many updates represent newly incoming information such as: assert {republican-congress} and thus are one-time, non-persistent actions, many of them are likely to be persistent, i.e., to remain in force till cancelled. For example, an update like: assert {wake-up} when {alarm-sounds} or assert {jail <- abortion} when {rep_congress & rep_president} may be always true, or at least true until cancelled. Such updates allow our system to dynamically change without any truly new updates being received.

180 Persistent update actions z For example, the update : assert {set_hands(time)} when {get_hands(htime) & get_time(time) & (time - htime)>  } defines a perpetually operating clock whose hands move to the correct time position whenever the difference between their actual position and the current time is sufficiently large.

181 Persistent updates zIn order to be able to specify such persistent updates (laws) we introduce the syntax: always [event] {A  B 1  B k } when {C 1  C m } coupled with: cancel {A  B 1  B k } when {C 1  C m } zThe first statement means that, in addition to any newly arriving updates, we are supposed to also keep firing this persistent update. The second one cancels this persistent update. It cancels both inertial and non-inertial updates.

182 Persistent updates zFor example we may have: always {set_hands(time)} when {get_hands(htime)& get_time(time) & (time-htime)>  }. followed by, if the clock gets broken: cancel {set_hands(time)} when {get_hands(htime)& get_time(time) & (time-htime)>  }.

183 Persistent updates zThe existence of persistent actions requires that we also need a “trivial” update action NO_UP (no update), which does not define any truly new updates but simply signifies the click of the clock and thus triggers all the already defined persistent updates to fire thus resulting in a modified knowledge state. zSuch “no-operation” update is needed to ensure that the system continues to evolve even when no truly new updates are specified. zSuch a trivial update may be represented by: assert {true}.

184 Persistent updates zConsequently, the set U of updates is effectively a union of two sets UN and UP. UN represents a non-empty set of new updates (possibly just a NO_UP ), while UP represents the set of all currently active persistent updates, i.e. those persistent updates that were not cancelled until now, from the time they were asserted: U = UN + UP, where UN <> 0. zNon-empty UN triggers the update transformation and leads to a successor knowledge state.

185 Retraction Actions zFor syntactic sugar, we also add a retraction statement: retract [event] {A  B 1  B k } when {D 1  D n } Its semantic meaning is that, subject to the precondition D 1  D n, the update of A  B 1  B k is either retracted from now on, or just retracted temporarily in the next state (a non- inertial retract).

186 Retraction Actions zIts procedural meaning is that anytime an update: assert {A  B 1  B k } when {C 1  C n } occurs, it is augmented with an additional premise: not retract {A  B1  Bk}, so that what is actually asserted is: assert {A  B 1  B k  not retract {A  B1  Bk} } when {C 1  C n } and its addition is coupled with the update: assert {not retract {A  B1  Bk} }.

187 Retraction Actions zThe statement retract [event] {A  B 1  B k } when {D 1  D n } is then equivalent to the assertion: assert [event] {retract {A  B1  Bk} } when {D 1  D n }. zHaving such retractions is not just convenient, but demonstrates we are providing a rigorous declarative and procedural semantics to assert/retract operations.

188 Retraction Actions zCanceling an update is not equivalent to retracting an update. Canceling simply means it will no longer be added to UP but it does not cancel the effect of its previous application(s). zHowever, retracting an update causes any of its persistent updates to be cancelled as well. Otherwise, a contradiction would result. zAlso, note that “ retract event... ” does not mean retracting of an event, because events persist only for one time and thus do not require retraction. It represents a temporary removal of an update from the successor state (i.e. a temporary retraction event).

189 Implementation of LUPS zA translation into Dynamic Logic Programming has been defined zWith this, a translation into Extended Logic Programming is obtained zBoth the translation and an interpreter for LUPS have been implemented. zThe implementation is available at: http://centria.di.fct.unl.pt/~jja/lups.p

190 An Update Scenario 1. Once Republicans take over both Congress and the Presidency they establish the law stating that abortions are punishable by jail. 2. Once Democrats take over both Congress and the Presidency they abolish such a law. 3. In the meantime, there are no changes in the law because always either the president or the congress vetoes such changes. 4. Performing an abortion is an event, i.e., a non-inertial update.

191 An Update Scenario - update history (1) A democratic congress and republican president (Reagan) (2) Event: Mary performs abortion. (3) Republican Congress is elected. Republican President remains in office: Bush. (4) Event: Kate performs abortion. (5) Clinton is elected president. (6) Event: Ann performs abortion. (7) Gore is elected president and Democratic Congress is in place (year 2000?) (8) Event: Susan performs abortion.

192 An Update Scenario - specification z Specification in the language of dynamic updates (LUPS): (a) Persistent update rules: always {Jail(X)  Abn(X)} when {(RepC & RepP)} always {not Jail(X)  Abn(X)} when {notRepC & notRepP} z Alternatively, instead of the second clause we can use a retract statement: retract {Jail(X)  Abn(X)} when {notRepC & notRepP}. They state that we are always supposed to update the current state with the rule Jail(X) <- Abn(X) provided RepC and RepP holds true and that we are supposed to assert the opposite or just retract this rule provided notRepC and notRepP holds true.

193 An Update Scenario - specification z Sequence of non-persistent update actions: 1. assert {RepP}. assert {not RepC}. % can be skipped; true by default 2. assert event{Abn(Mary)}. assert {RepC}. 4. assert event{Abn(Kate)}. assert {not RepP}. % or, retract {RepP} 6. assert event{Abn(Ann)}. 7. assert {not RepC}. % or, retract {RepC} 8. assert event{Abn(Susan)}. z In the meantime we could have a lot of NO_UP update events, representing clicks of the clock or any other irrelevant updates.

194 Declarative and Procedural Semantics - meta-language z We define the declarative and procedural semantics by describing a translation of the statements of LUPS into a GLP written in the meta-language. Using a specific declarative semantics with such GLP programs, leads to the precise declarative semantics for our dynamic updates. z The translation uses the meta-language employing the following symbols: A(s), A(s,t), -A(s,t), A*(s,t), -A*(s,t).  These symbols are to be defined for any propositional symbol A in the objective language L.

195 Declarative and Procedural Semantics - meta-language  In addition, they should be available for the special propositional symbols: retract {A  B1  Bk} and cancel {A  B1  Bk} that are not used in the objective language and are defined for all generalized LP clauses A  B 1  B k in the objective language. They therefore represent clause labels and are used for retraction and cancellation of updates. As usual, we assume that all of the above symbols are mutually distinct.

196 Declarative and Procedural Semantics - the GLP translation zThe Generalized Logic Program U 0 Describing the Default Knowledge State KR 0 The program consists of the following clauses: zInertia rules (for any s>=0 and t>=s): A(s,t)  A * (s, t) -A(s,t)  -A * (s, t) A(s,t)  A (s-1, t), not -A * (s, t) -A(s,t)  -A (s-1, t), not A * (s, t)

197 Declarative and Procedural Semantics - the GLP translation zCurrent state rules (for any s): A(s)  A(s,s) not A(s)  -A(s,s). Note: we are assuming that all states are consistent. zDefault knowledge state rules: -A(0,t), for all A’s and t>=0.

198 Declarative and Procedural Semantics - the GLP translation zThe dynamic update program U0  U1 ...  Us  Us+1 describing the successor knowledge state KR s+1 : zThe update program U0  U1 ...  Us  Us+1 is obtained from the program U0  U1 ...  Us describing KRs by augmenting it with the following additional rules, corresponding to each of the newly received update actions.

199 Declarative and Procedural Semantics - assert rules z A. Translation of assert rules: assert {A  B 1  B k } when {C 1  C m } is translated into two GLP clauses in the meta-language: (1) A * (s+1,t)  B 1 (t,t),...,B k (t,t), -retract {A  B1  Bk} (t,t), C 1 (s,s),..., C m (s,s). The update A  B 1  B k is added at s+1 provided the condition C 1  C m is true at s. It will remain in force by inertia for all t >= s+1 unless the predicate retract {A  B1  Bk} (t,t) becomes true. (2) -retract* {A  B1  Bk} (s+1,t)  C 1 (s,s),..., C m (s,s). Beginning with s+1 the predicate -retract {A  B1  Bk} (t,t ) is true and will remain true by inertia for all t >= s+1.

200 Declarative and Procedural Semantics - retract rules z B. Translation of retract rules: retract {A  B 1  B k } when {C 1  C m } into the two GLP clauses in the meta-language: (1) retract * {A  B1  Bk} (s+1,t)  C 1 (s,s),…,C m (s,s). The update A  B 1  B k is retracted at state s+1 provided the condition C 1  C m is true at the state s. It will remain retracted by inertia for all t >= s+1. (2) cancel * {A  B1  Bk} (s+1,t)  C 1 (s,s),…, C m (s,s). z Retractions also cancel persistent update rules (i.e., retractions take precedence over persistence).

201 Declarative and Procedural Semantics - persistent rules z C. Translation of persistent assert rules: always {A  B 1  B k } when {C 1  C m } is translated into three GLP clauses in the meta-language: (1) -cancel * {A  B1  Bk} (s+1,v). the update rule persists from for all v >= s+1 by inertia. (2) A * (q+1,t)  B 1 (t,t),…,B k (t,t),-retract {A  B1  Bk} (t,t), -cancel {A  B1  Bk} (q+1,q+1),C 1 (q,q),…,C m (q,q). Rule A  B 1  B k is added for any q+1>=s+1 if it persists at q+1 and C 1  C m is satisfied at q. It remains true by inertia for t>=q+1. (3)-retract * {A  B1  Bk} (q+1,t)  -cancel {A  B1  Bk} (q+1,q+1), C 1 (q,q),…,C m (q,q). If these conditions are met at q+1>=s+1 they also cause -retract {A  B1  Bk} (t,t) to become true by inertia for t>=q+1.

202 Declarative and Procedural Semantics - cancellation rules zD. Translation of cancellation rules: cancel {A  B 1  B k } when {C 1  C m } is translated into a GLP clause in the meta-language: cancel * {A  B1  Bk} (s+1,t)  C 1 (s,s),…, C m (s,s). The persistent update rule is cancelled at the state s+1 and will remain cancelled by inertia for all t >= s+1.

203 Declarative and Procedural Semantics - event rules zE. Translation of (non-retractable) assert event rules: assert event {A  B 1  B k } when {C 1  C m } is translated into a GLP clause in the meta-language: (1) A * (s+1,s+1)  B 1 (s+1, s+1),…,B k (s+1, s+1), C 1 (s, s),…, C m (s, s). zF. Translation of retract event rules: retract event {A  B 1  B k } when {C 1  C m } is translated into two GLP clauses in the meta-language: (1) retract * {A  B1  Bk} (s+1,s+1)  C 1 (s,s),…,C m (s,s ). (2) cancel * {A  B1  Bk} (s+1,s+1)  C 1 (s,s),…,C m (s,s).

204 Declarative and Procedural Semantics - persistent event rules z G. Translation of persistent assert event rules: always event {A  B 1  B k } when {C 1  C m } is translated into two GLP clauses in the meta-language: (1) -cancel * {A  B1  Bk} (s+1,v). The update rule from now on for all v >= s+1 by inertia. (2) A * (q+1,q+1)  B 1 (q+1,q+1),…,B k (q+1,q+1), -cancel {A  B1  Bk} (q+1,q+1), C 1 (q,q),…,C m (q,q).  An event update A  B 1  B k is added at any q+1>=s+1 if the rule remains persistent at q+1 and condition C 1  C m is satisfied at q. It will not remain true by inertia.

205 LUPS examples z Now we present a variety of examples of application of LUPS to the representation of updates, and of actions as updates. Indeed, actions can be described by persistent updates (laws) which relate the state where the actions happened with the successor state where the consequences hold. z In the examples we assume all persistent commands not explicitily linked to a knowledge state to belong to U1. z Whenever a knowledge state Ui is referred, which was not previously defined, it is assumed equal to assert(true).

206 LUPS examples - Twice fined z A car-driver looses his licence after a second fine. He can regain the licence if he undergoes a refresher course at the drivers school. z To represent this problem it is necessary to introduce a new predicate, probation, which holds after the first fine takes place. The fine action is represented by two persistent update commands: always {probation} when {fined}. always {not licence} when {fined,probation}. The first means probation is true after a fine, and the second that the driver looses his licence after a fine, if on probation.

207 LUPS examples - Twice fined z The attend_school action is represented by the two persistent update commands: always {licence} when {attend_school}. always {not probation} when {attend_school}. meaning that after attending school the driver has a licence and he is not in a probation state. z Imagine the sequence of non-persistent update commands: U1 : assert event {attend_school} U2 : assert event {fine} U3 : assert event {fine} U4 : assert event {attend_school} As intended, licence holds in states 2,3,5 and not licence in state 4 (after two fines).

208 LUPS examples - Timers z Timers are started by action on_for(N), meaning the timer will be on for the next N states. This notion is captured by the three persistent rules: always event {on_for(M)} when {on_for(N), N>0, minus(N,1,M)} the timer is on for M states if it was on for N=M+1 states in the previous one. Timers are on if they are on_for(N), where N>0 : always {on 0} and switched off when N=0, i.e.: always {not on <- on_for(0)} z Consider the sequence of updates: U1 : assert event {on_for(2)} As intended, on holds in state 1, 2 and not on holds in state 3.

209 LUPS examples - Suitcase z The suitcase has two latches, opens whenever both are up, and there is an action of toggling applicable to each latch. This is represented by three persistent commands: always {open <- up(l1), up(l2)} always {up(L)} when {not up(L), toggle(L)} always {not up(L)} when {up(L), toggle(L)} Initially l1 is down, l2 is up, and the suitcase is closed: U1= { assert{not up(l1)}, assert{up(l2)}, assert{not open} }

210 LUPS examples - Suitcase z Suppose there are now two simultaneous toggling actions: U2 = { assert event {toggle(l1)}, assert event {toggle(l2)} } and afterwards there is yet another l2 toggling action: U3 = { assert event {toggle(l2)} } z In knowledge state 3 we'll have up(l1), not up(l2 ) and the suitcase is not open. z Only after 3 will latch l2 be up and the suitcase open.

211 LUPS examples - Contradictory advice --- 3-valued updating z An agent receives advice from two sources, father and mother. The agent's expected behaviour is to perform an action, unless contradicted by other advice. These persistent update commands model the desired behaviour: always {do(A) <- father_advises(A), not dont(A)} always {dont(A) <- mother_advises(no A), not do(A)} z Suppose father advises buying stocks, but mother not to: U1= { assert event {father_advises(buy)}, assert event {mother_advises(no buy)} } In this situation, do(buy) and do(no buy ) become undefined, and the agent does not perform any action.

212 LUPS examples - Conscientious objector --- a rule update example z A person is conscripted if he is draftable and healthy. He is draftable when he reaches a certain age. Then the law changes: he is not conscripted if a conscientious objector. U1 : always {draftable(X)} when {of_age(X)} assert { conscripted(X) <- draftable(X), healthy(X) } U2 : assert {healthy(a)}. assert {conscientious_objector(a)}. assert {healthy(b)}. assert {conscientious_objector(b)}. assert {of_age(b)}. U4 : assert { not conscripted(X)<- draftable(X),conscientious_objector(X) }. U5 : assert {of_age(a)}. In state 3, b is conscripted, but after U4 his situation changes and not conscripted takes hold. But a is never conscripted.

213 Bibliography (1) zMost of the work covered by this course is detailed in: y[AP96] J.J. Alferes and L.M. Pereira. Reasoning with Logic Programming. Springer LNAI 1111, 1996 zSee references there for the original definitions zFor more on semantics of normal LPs see: y[PP90] H. Przymusinska and T. Przymusinski. Semantic issues in deductive databases and logic programs. In R. Banerji ed, Formal Techniques in AI, a Sourcebook. North Holland, 1990 zFor more on derivation procedures: y[AB94] K. Apt and R. Bol. Logic Programming and Negation: A survey. In Journal of L.P., 1994

214 Bibliography (2) zFor more on LP for KRR: y[BG94] C. Baral and M. Gelfond. Logic Programming and Knowledge Representation. In Journal of L.P., 1994 zFor relation with NMR e structural properties: y[BDK97] G. Brewka, J. Dix and K. Konolige. Nonmonotonic Reasoning: an overview. CSLI Publications, 1997 zMore on our LP belief revision approach in: y[ADP95] J. J. Alferes and C. V. Damásio and L. M. Pereira, A Logic Programming System for Non-monotonic Reasoning, Journal of Automated Reasoning (14), 1995

215 Bibliography (3) zFor more on LP update: y[MT96] V. Marek and M. Truszczynski. Revision specifications by means of programs. In JELIA’94, Springer LNAI 838, 1994 y[ALPPP98] J.J. Alferes, J. Leite, L.M. Pereira, H. Przymusinska and T. Przymusinski. Dynamic Logic Programming. In KR’98, Morgan Kaufmann, 1998 zAnother good entry point for these questions is: y[DPP97] J. Dix, L.M. Pereira, T. Przymusinski. Prolegomena to Logic Programming and Non-Monotonic Reasoning. In Non- Monotonic Extensions of Logic Programming. Springer LNAI 1216, 1997


Download ppt "Reasoning with Logic Programming Luís Moniz Pereira José Júlio Alferes Utrecht, August 1999."

Similar presentations


Ads by Google