Loading...

PPT – Reasoning with Logic Programming PowerPoint presentation | free to download - id: 674eec-M2ZlN

The Adobe Flash plugin is needed to view this content

Reasoning with Logic Programming

- Luís Moniz Pereira
- José Júlio Alferes

Utrecht, August 1999

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 - taxonomies
- hypothetical reasoning
- abduction
- paraconsistent reasoning

- revision
- diagnosis
- updating
- actions

Course material

- The course comprises research of the last decade

on the use of Logic Programming for Knowledge

Representation and Reasoning - This is now a mature area of research
- It presents the basic formalism, proof

procedures, and application domains - It articulates work on semantics, methodologies

for KRR, belief revision, and knowledge updates - It shows open areas with research opportunities
- At the end, pointers to bibliography are provided

Course topics

- Overview of Logic Programs semantics
- Explicit negation semantics
- Paraconsistency
- Methodology for KR in LP
- Proof procedures
- Belief revision and abduction
- Updates of Logic Programs
- Modeling actions

LP for Knowledge Representation

- Due to its declarative nature, LP has become a

prime candidate for Knowledge Representation and

Reasoning - This has been more noticeable since its relations

to other NMR formalisms were established - For this usage of LP, a precise declarative

semantics was in order

Language

- A Normal Logic Programs P is a set of rules
- H A1, , An, not B1, not Bm (n,m ³ 0)
- where H, Ai and Bj are atoms
- Literal not Bj are called default literals
- When no rule in P has default literal, P is

called definite - The Herbrand base HP is the set of all

instantiated atoms from program P. - We will consider programs as possibly infinite

sets of instantiated rules.

Declarative Programming

- A logic program can be an executable

specification of a problem

member(X,XY). member(X,YL) member(X,L).

- Easier to program, compact code
- Adequate for building prototypes
- Given efficient implementations, why not use it

to program directly?

LP and Deductive Databases

- In a database, tables are viewed as sets of facts

- Other relations are represented with rules

LP and Deductive DBs (cont)

- LP allows to store, besides relations, rules for

deducing other relations - Note that default negation cannot be classical

negation in

- A form of Closed World Assumption (CWA) is needed

for inferring non-availability of connections

Default Rules

- The representation of default rules, such as
- All birds fly
- can be done via the non-monotonic operator not

The need for a semantics

- In all the previous examples, classical logic is

not an appropriate semantics - In the 1st, it does not derive not

member(3,1,2) - In the 2nd, it never concludes choosing another

company - In the 3rd, all abnormalities must be expressed
- The precise definition of a declarative semantics

for LPs is recognized as an important issue for

its use in KRR.

2-valued Interpretations

- A 2-valued interpretation I of P is a subset of

HP - A is true in I (ie. I(A) 1) iff A Î I
- Otherwise, A is false in I (ie. I(A) 0)

- Interpretations can be viewed as representing

possible states of knowledge. - If knowledge is incomplete, there might be in

some states atoms that are neither true nor false

3-valued Interpretations

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

where - HP T U F

Models

- Models can be defined via an evaluation function

Î - For an atom A, Î(A) I(A)
- For a formula F, Î(not F) 1 - Î(F)
- For formulas F and G
- Î((F,G)) min(Î(F), Î(G))
- Î(F G) 1 if Î(G) Î(F), and 0 otherwise

- I is a model of P iff, for all rule H B of P
- Î(H B) 1

Minimal Models Semantics

- The idea of this semantics is to minimize

positive information. What is implied as true by

the program is true everything else is false.

- pr(s),pr(e),ph(s),ph(e),aM(s),aM(e) is a model
- Lack of information that sampaio is a physicist,

should indicate that he isnt - The minimal model is pr(s),ph(e),aM(e)

Minimal Models Semantics

- Truth ordering For interpretations I and J, I

J iff for all atom A, I(A) J(A), i.e. - TI Í TJ and FI Ê FJ

- Every definite logic program has a least (truth

ordering) model.

- minimal models semantics An atom A is true in

(definite) P iff A belongs to its least model.

Otherwise, A is false in P.

TP operator

- The minimal models of a definite P can be

computed (bottom-up) via operator TP

- TP Let I be an interpretation of definite P.
- TP(I) H (H Body) Î P and Body Í I

- If P is definite, TP is monotone and continuous.

Its minimal fixpoint can be built by - I0 and In TP(In-1)

- The least model of definite P is TPw()

On Minimal Models

- SLD can be used as a proof procedure for the

minimal models semantics - If the is a SLD-derivation for A, then A is true
- Otherwise, A is false
- The semantics does not apply to normal programs
- p not q has two minimal models
- p and q
- There is no least model !

The idea of completion

- In LP one uses if but mean iff Clark78

- This doesnt imply that -1 is not a natural

number! - With this program we mean

- This is the idea of Clarks completion
- Syntactically transform ifs into iffs
- Use classical logic in the transformed theory to

provide the semantics of the program

Program completion

- The completion of P is the theory comp(P)

obtained by - Replace p(t) j by p(X) X t, j
- Replace p(X) j by p(X) Y j, where Y are the

original variables of the rule - Merge all rules with the same head into a single

one p(X) j1 Ú Ú jn - For every q(X) without rules, add q(X)
- Replace p(X) j by "X (p(X) Û j)

Completion Semantics

- 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

- Though completions definition is not that

simple, the idea behind it is quite simple - Also, it defines a non-classical semantics by

means of classical inference on a transformed

theory

SLDNF proof procedure

- By adopting completion, procedurally we have
- not is negation as finite failure
- In SLDNF proceed as in SLD. To prove not A
- If there is a finite derivation for A, fail not A
- If, after any finite number of steps, all

derivations for A fail, remove not A from the

resolvent (i.e. succeed not A) - SLDNF can be efficiently implemented (cf. Prolog)

SLDNF example

p p. q not p. a not b. b not c.

c

- According to completion
- comp(P) not a, b, not c
- comp(P) ¹ p, comp(P) ¹ not p
- comp(P) ¹ q, comp(P) ¹ not q

Problems with completion

- Some consistent programs may became inconsistent

p not p becomes p Û not p - Does not correctly deal with deductive closures

edge(a,b). edge(c,d). edge(d,c). reachable(a). re

achable(A) edge(A,B), reachable(B).

- Completion doesnt 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

Completion Problems (cont)

- Difficulty in representing equivalencies

abnormal(B) irregular(B) irregular(B)

abnormal(B)

bird(tweety). fly(B) bird(B), not abnormal(B).

- Completion doesnt conclude fly(tweety)!
- Without the rules on the left fly(tweety) is true
- An 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

Program stratification

- Minimal models dont have loop problems
- But are only applicable to definite programs
- Generalize Minimal Models to Normal LPs
- Divide the program into strata
- The 1st is a definite program. Compute its

minimal model - Eliminate all nots whose truth value was thus

obtained - The 2nd becomes definite. Compute its MM

Stratification example

- Least(P1) a, b, not p
- Processing this, P2 becomes
- c true
- d c, false
- Its minimal model, together with P1 is
- a, b, c, not d, not p
- Processing this, P3 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

P1

P

P2

P3

- The (desired) semantics for P is then
- a, b ,c, not d, e, not f, not p

Stratification

- Let S1Sn be such that S1 UU Sn HP, all the

Si are disjoint, and for all rules of P - A B1,,Bm, not C1,,not Ck
- if A Î Si then
- B1,,Bm Í Ui j1 Sj
- C1,,Ck Í Ui-1 j1 Sj
- Let Pi contain all rules of P whose head belongs

to Si. P1Pn is a stratification of P

Stratification (cont)

- A program may have several stratifications

or

- Or may have no stratification

b not a a not b

- A Normal Logic Program is stratified iff it

admits (at least) one stratification.

Semantics of stratified LPs

- Let IR be the restriction of interpretation I to

the atoms in R, and P1Pn be a stratification

of P. - Define the sequence
- M1 least(P1)
- Mi1 is the minimal models of Pi1 such that
- Mi1 (Uij1 Sj) Mi
- Mn is the standard model of P
- A is true in P iff A Î Mn
- Otherwise, A is false

Properties of Standard Model

- Let MP be the standard model of stratified P
- MP is unique (does not depend on the

stratification) - MP is a minimal model of P
- MP is supported

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

Perfect models

- The original definition of stratification (Apt et

al.) was made on predicate names rather than

atoms. - By 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

P1 even(0) P2 even(1) not even(0) ...

even(0) even(s(X)) not even(X)

- The program isnt stratified (even/1 depends

negatively on itself) but is locally stratified.

- Its perfect model is even(0),not

even(1),even(2),

Problems with stratification

- Perfect models are adequate for stratified LPs
- Newer semantics are generalization of it
- But 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 - No stratification is possible if P has
- pacifist(X) not hawk(X)
- hawk(Y) not pacifist(X)
- This 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

SLS procedure

- In perfect models not includes infinite failure
- SLS is a (theoretical) procedure for perfect

models based on possible infinite failure - No complete implementation is possible (how to

detect infinite failure?) - Sound approximations exist
- based on loop checking (with ancestors)
- based on tabulation techniques
- (cf. XSB-Prolog implementation)

Stable Models Idea

- The 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. - If the program is stratified, the results

coincide - A correct guess must coincide on the 1st strata
- and on the 2nd (given the 1st), and on the 3rd
- But this can be applied to non-stratified

programs

Stable Models Idea (cont)

- Guessing a model corresponds to assuming

default negations not. This type of reasoning is

usual in NMR - Assume some default literals
- Check in P the consequences of such assumptions
- If the consequences completely corroborate the

assumptions, they form a stable model - The stable models semantics is defined as the

intersection of all the stable models (i.e. what

follows, no matter what stable assumptions)

SMs preliminary example

a not b c a p not q b not a c b

q not r r

- Assume, e.g., not r and not p as true, and all

others as false. By processing this into P

a false c a p false b false c b

q true r

- Its least model is not a, not b, not c, not p,

q, r - So, it isnt a stable model
- By assuming not r, r becomes true
- not a is not assumed and a becomes false

SMs example (cont)

a not b c a p not q b not a c b

q not r r

- Now assume, e.g., not b and not q as true, and

all others as false. By processing this into P

a true c a p true b false c b q

false r

- Its least model is a, not b, c, p, not q, r
- I is a stable model
- The other one is not a, b, c, p, not q, r
- According to Stable Model Semantics
- c, r and p are true and q is false.
- a and b are undefined

Stable Models definition

- Let I be a (2-valued) interpretation of P. The

definite program P/I is obtained from P by - deleting all rules whose body has not A, and A Î

I - deleting from the body all the remaining default

literals - GP(I) least(P/I)

- M is a stable model of P iff M GP(M).
- A is true in P iff A belongs to all SMs of P
- A is false in P iff A doesnt belongs to any SMs

of P (i.e. not A belongs to all SMs of P).

Properties of SMs

- Stable models are minimal models
- Stable models are supported
- If P is locally stratified then its single stable

model is the perfect model - Stable models semantics assign meaning to (some)

non-stratified programs - E.g. the one in the example before

Importance of Stable Models

- Stable Models were an important contribution
- Introduced the notion of default negation (versus

negation as failure) - Allowed important connections to NMR. Started the

area of LPNMR - Allowed for a better understanding of the use of

LPs in Knowledge Representation - It is considered as THE semantics of LPs by a

significant part of the community.

But...

Cumulativity

- 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 programs meaning)

- This property is important for implementation
- without cumulativity, tabling methods cannot be

used

Relevance

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

- A semantics Sem is relevant iff for every P
- A Î Sem(P) iff A Î Sem(RelA(P))
- where RelA(P) contains all rules of P whose head

is A or some B on which A depends on.

- Only this property allows for the usual top-down

execution of logic programs.

Problems with SMs

- Dont provide a meaning to every program
- P a not a has no stable models
- Its non-cumulative and non-relevant

- The only SM is not a, c, b

a not b c not a b not a c not c

- 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 Relb(P) (non-relevance)
- The rules in Relb(P) are the 2 on the left
- Relb(P) has 2 SMs not a, b and a, not b

Problems with SMs (cont)

- Its computation is NP-Complete
- The intersection of SMs is non-supported

c is true but neither a nor b are true.

a not b c a b not a c b

- Note that the perfect model semantics
- is cumulative
- is relevant
- is supported
- its computation is polynomial

Well Founded Semantics

- Defined in GRS90, generalizes SMs to 3-valued

models. - Note that
- there are programs with no fixpoints of G
- but all have fixpoints of G2

P a not a

- G(a) and G() a
- There are no stable models

- But G2() and G2(a) a

Partial Stable Models

- A 3-valued intr. (T U not F) is a PSM of P iff
- T G2(T)
- T Í G(T)
- F HP - G(T)

The 2nd condition guarantees that no atom is both

true and false T Ç F

P a not a, has a single PSM

This program has 3 PSMs , a, not b and c,

b, not a The 3rd corresponds to the single SM

a not b c not a b not a c not c

WFS definition

- WF Model Every P has a knowledge ordering (i.e.

wrt Í) least PSM, obtainable by the transfinite

sequence - T0
- Ti1 G2(Ti)
- Td Ualtd Ta, for limit ordinals d
- Let T be the least fixpoint obtained.
- MP T U not (HP - G(T))
- is the well founded model of P.

Well Founded Semantics

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

WFS Properties

- Every program is assigned a meaning
- Every PSM extends one SM
- If WFM is total it coincides with the single SM
- It is sound wrt to the SMs semantics
- If P has stable models and A is true (resp.

false) in the WFM, it is also true (resp. false)

in the intersection of SMs - WFM coincides with the perfect model in locally

stratified programs (and with the least model in

definite programs)

More WFS Properties

- The WFM is supported
- WFS is cumulative and relevant
- Its computation is polynomial (on the number of

instantiated rules of P) - There are top-down proof-procedures, and sound

implementations - these are mentioned in the sequel

LP and Default Theories

- Let DP be the default theory obtained by

transforming - H B1,,Bn, not C1,, not Cm
- into B1,,Bn C1,, Cm
- H

- There is a one-to-one correspondence between the

SMs of P and the default extensions of DP

- If L Î WFM(P) then L belongs to every extension

of DP

LPs as defaults

- LPs can be viewed as sets of default rules
- Default literals are the justification
- can be assumed if it is consistent to do so
- are withdrawn if inconsistent
- In this reading of LPs, is not viewed as

implication. Instead, LP rules are viewed as

inference rules.

LP and Auto-Epistemic Logic

- Let TP be the AEL theory obtained by

transforming - H B1,,Bn, not C1,, not Cm
- into
- B1 Ù Ù Bn Ù L C1 Ù Ù L Cm Þ H

- There is a one-to-one correspondence between the

SMs of P and the (Moore) expansions of TP

- If L Î WFM(P) then L belongs to every expansion

of TP

LPs as AEL theories

- LPs can be viewed as theories that refer to their

own knowledge - Default negation not A is interpreted as A is

not known - The LP rule symbol is here viewed as material

implication

LP and AEB

- Let TP be the AEB theory obtained by

transforming - H B1,,Bn, not C1,, not Cm
- into
- B1 Ù Ù Bn Ù B C1 Ù Ù B CmÞ H

- There is a one-to-one correspondence between the

PSMs of P and the AEB expansions of TP

- A Î WFM(P) iff A is in every expansion of TP
- not A Î WFM(P) iff BA is in all expansions of TP

LPs as AEB theories

- LPs can be viewed as theories that refer to their

own beliefs - Default negation not A is interpreted as It is

believed that A is false - The LP rule symbol is also viewed as material

implication

Extended LPs

- In Normal LPs all the negative information is

implicit. Though thats desired in some cases

(e.g. the database with flight connections),

sometimes an explicit form of negation is needed

for Knowledge Representation - Penguins dont 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 -

Extended LP motivation

- 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

ELP motivation (cont)

- allows for greater expressivity
- If youre not sure that someone is not innocent,

then further investigation is needed - Can be represented by
- investigate(X) not innocent(X)
- extends the relation of LP to other NMR

formalisms. E.g - it can represent default rules with negative

conclusions and pre-requisites, and positive

justifications - it can represent normal default rules

Explicit versus Classical

- Classical complies with the excluded middle

principle (i.e. F v F is tautological) - This makes sense in mathematics
- What about in common sense knowledge?
- A is the the opposite of A.
- The excluded middle leaves no room for

undefinedness

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

hire(X) qualified(X) reject(X) qualified(X)

ELP Language

- An Extended Logic Program P is a set of rules
- L0 L1, , Lm, not Lm1, not Bn (n,m ³ 0)
- where the Li are objective literals
- An objective literal is an atoms A or its

explicit negation A - Literals not Lj are called default literals
- The Extended Herbrand base HP is the set of all

instantiated objective literals from program P - We will consider programs as possibly infinite

sets of instantiated rules.

ELP Interpretations

- An interpretation I of P is a set
- I T U not F
- where T and F are disjoint subsets of HP and
- L Î T Þ L Î F (Coherence Principle)
- i.e. if L is explicitly false, it must be

assumed false by default - I is total iff HP T U F
- I is consistent iff L L, L Í T
- In total consistent interpretations the Coherence

Principle is trivially satisfied

Answer sets

- It was the 1st semantics for ELPs

GelfondLifschitz90 - Generalizes stable models to ELPs

- 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

- Some programs have no consistent answer sets
- e.g. P a , a

Answer sets and Defaults

- Let DP be the default theory obtained by

transforming - L0 L1,,Lm, not Lm1,, not Ln
- into L1,,Lm Lm1,, Ln
- L0
- where A is (always) replaced by A

- There is a one-to-one correspondence between the

answer-sets of P and the default extensions of DP

Answer-sets and AEL

- Let TP be the AEL theory obtained by

transforming - L0 L1,,Lm, not Lm1,, not Ln
- into
- L1 Ù L L1 Ù Ù Lm Ù L Lm Ù
- Ù L Lm1 Ù Ù L Lm Þ (L0 Ù L L0)

- There is a one-to-one correspondence between the

answer-sets of P and the expansions of TP

The coherence principle

- Generalizing 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. - Coherence is not satisfied...
- Coherence must be imposed

Imposing Coherence

- Coherence is L Î T Þ L Î F, for objective L
- According to the WFS definition, everything is

false that doesnt belong to G(T) - To impose coherence, when applying G(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

WFSX definition

- The semi-normal version of P, Ps, is obtained by

adding not L to every rule of P with head L

- An interpretation (T U not F) is a PSM of ELP P

iff - T GPGPs(T)
- T Í GPs(T)
- F HP - GPs(T)

- The WFSX semantics is determined by the knowledge

ordering least PSM (wrt Í)

WFSX example

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)

T0 Gs(T0) p(a),p(a),h(a),p(b),h(b) T1

p(a) Gs(T1) p(a),h(a),p(b),h(b) T2

p(a),h(a) T3 T2

P pacifist(X) not hawk(X) hawk(X) not

pacifist(X) pacifist(a) pacifist(b)

The WFM is p(a),h(a), not p(a), p(b), not

h(a), not p(b), not h(b)

Properties of WFSX

- Complies with the coherence principle
- Coincides with WFS in normal programs
- If WFSX is total it coincides with the only

answer-set - It is sound wrt answer-sets
- It is supported, cumulative, and relevant
- Its computation is polynomial
- It has sound implementations (cf. below)

Inconsistent programs

- Some ELPs have no WFM. E.g. a , a
- What to do in these cases?
- Explosive approach everything follows from

contradiction - taken by answer-sets
- gives no information in the presence of

contradiction - Belief revision approach remove contradiction by

revising P - computationally expensive
- Paraconsistent approach isolate contradiction
- efficient
- allows to reason about the non-contradictory part

WFSXp definition

- The paraconsistent version of WFSx is obtained by

dropping the requirement that T and F are

disjoint, i.e. dropping T Í GPs(T)

- An interpretation, T U not F, is a PSMp P iff
- T GPGPs(T)
- F HP - GPs(T)

- The WFSXp semantics is determined by the

knowledge ordering least PSM (wrt Í)

WFSXp example

Ps c not b, not c a not a b a, not b

a not a d not e , not d

T0 Gs(T0) a,a,b,c,d T1

a,a,b,d Gs(T1) d T2 a,a,b,c,d T3 T2

P c not b a b a a d not e

The WFM is a,a,b,c,d, not a, not a, not b,

not b not c, not c, not d, not e

Surgery situation

- A patient arrives with sudden epigastric pain

abdominal tenderness signs of peritoneal

irritation - The rules for diagnosing are
- if he has sudden epigastric pain abdominal

tenderness, and signs of peritoneal irritation,

then he has perforation of a peptic ulcer or an

acute pancreatitis - the former requires surgery, the latter

therapeutic treatment - if he has high amylase levels, then a perforation

of a peptic ulcer can be exonerated - if he has Joberts manifestation, then

pancreatitis can be exonerated - In both situations, the pacient should not be

nourished, but should take H2 antagonists

LP representation

perforation pain, abd-tender, per-irrit, not

high-amylase pancreat pain, abd-tender,

per-irrit, not jobert nourish

perforation h2-ant perforation nourish

pancreat h2-ant pancreat surgery

perforation anesthesia 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

Results interpretation

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

- The symptoms are derived and non-contradictory
- Both perforation and pancreatitis are concluded
- He should not be fed (nourish), but take H2

antagonists - The information about surgery is contradictory
- Anesthesia though not explicitly contradictory

(anesthesia doesnt belong to WFM) relies on

contradiction (both anesthesia and not anesthesia

belong to WFM)

A methodology for KR

- WFSXp provides mechanisms for representing usual

KR problems - logic language
- non-monotonic mechanisms for defaults
- forms of explicitly representing negation
- paraconsistency handling
- ways of dealing with undefinedness
- In what follows, we propose a methodology for KR

using WFSXp

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)

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-dont-fly to

the birds-fly rule bf(X) penguin(X), pdf(X)

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

Taxonomy example

The taxonomy

- Mammal are animal
- Bats are mammals
- Birds are animal
- Penguins are birds
- Dead animals are animals

- Normally animals dont fly
- Normally bats fly
- Normally birds fly
- Normally penguins dont fly
- Normally dead animals dont fly

The elements

- Pluto is a mammal
- Joe is a penguin

- Tweety is a bird
- Dracula is a dead bat

The preferences

- Dead bats dont fly though bats do
- Dead birds dont fly though birds do
- Dracula is an exception to the above
- In general, more specific information is preferred

The taxonomy

Definite rules

flies

Default rules

Negated default rules

animal

bird

mammal

dead animal

penguin

bat

pluto

tweety

dracula

joe

Taxonomy representation

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)

Taxonomy animal(X) mammal(X) mammal(X)

bat(X) animal(X) bird(X) bird(X)

penguin(X) deadAn(X) dead(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)

Taxonomy results

SLX Proof procedure for WFSXp

- SLX (SL with eXplicit negation) is a top-down

procedure for WFSXp - Here we only present an AND-trees

characterization - The proof procedure details are in AP96
- Is similar to SLDNF
- Nodes are either successful or failed
- Resolution with program rules and resolution of

default literals by failure of their complements

are as in SLDNF - In SLX, failure doesnt mean falsity. It simply

means non-verity (i.e. false or undefined)

Success and failure

- A finite tree is successful if its root is

successful, and failed if its root is failed - The status of a node is determined by
- A leaf labeled with an objective literal is

failed - A leaf with true is successful
- An intermediate node is successful if all its

children are successful, and failed otherwise

(i.e. at least one of its children is failed)

Negation as Failure?

- As in SLS, to solve infinite positive recursion,

infinite trees are (by definition) failed - Can 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

- This is the basis of SLX. It defines
- T-Trees for proving truth
- TU-Trees for proving truth or undefinedness

T and TU-trees

- They differ in that literals involved in

recursion through negation, and so undefined in

WFSXp, are failed in T-Trees and successful in

TU-Trees

x

a not b b not a

x

x

x

Explicit negation in SLX

- -literals are treated as atoms
- To impose coherence, the semi-normal program is

used in TU-trees

x

x

a not b b not a a

x

x

x

Explicit negation in SLX (2)

- In TU-trees L also fails if L succeeds true
- I.e. if not L fails as true-or-undefined

a

not a

x

x

x

c not c b not c b a b

x

x

x

x

x

x

x

Paraconsistent example

b not a a a

T and TU-trees definition

- 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 L1,,Lm, not Lm1,, not Ln
- In a T-tree the children of A are L1,,Lm, not

Lm1,, not Ln - In a TU-tree A has, additionally, the child not

A - Nodes labeled with default literals are leafs

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)

Properties of SLX

- SLX is sound and (theoretically) complete wrt

WFSXp. - Even ignoring rules concerning explicit negation,

SLX is sound and (theoretically) complete wrt

WFS. - See AP96 for the definition of a refutation

procedure based on the AND-trees

characterization, and for all proofs and details

Infinite trees example

x

x

x

Negative recursion example

Guaranteeing termination

- The method is not effective, because of loops
- To 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
- the root tree has no global ancestors
- the global ancestors of T, a subsidiary tree of

leaf n of T, are the global ancestors of T plus

the local ancestors of n - global ancestors are divided into those occurring

in T-trees and those occurring in TU-trees

Pruning rules

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

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

Pruning rules (2)

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

Pruning examples

a not b b not a a

x

x

b

a

c not c b not c b a b

not a

x

x

x

x

x

Non-ground case

- The characterization and pruning rules apply to

allowed non-ground programs, with ground queries - It is well known that pruning rules do not

generalize to general programs with variables

p(X)

- What to do?
- If fail, the answers are incomplete
- If proceed then loop

p(X) p(Y) p(a)

p(Y)

p(Z)

Tabling

- To guarantee termination in non-ground programs,

instead of ancestors and pruning rules,

tabulation mechanisms are required - when there is a possible loop, suspend the

literal and try alternative solutions - when a solution is found, store it in a table
- resume suspended nodes with new solutions in the

table - apply an algorithm to determine completion of the

process, i.e. when no more solutions exist, and

fail the corresponding suspended nodes

Tabling example

p(X) p(Y) p(a)

- Weve implemented SLX with tabulation mechanisms
- Weve made use of the XSB-Prolog tabling

implementation - SLX with tabling is available with XSB-Prolog

Version 2.0 - Try it at

p(X)

1) suspend

X a

p(Y)

2) resume

Y a

http//www.cs.sunysb.edu/sbprolog/xsb-page.html

X a

X _

Floundering

- Another (well known) problem when generalizing

for non-ground LPs is floundering - Tabling doesnt help here

p(X)

a

a not p(X) p(a)

x

X a

not p(X)

x

- To solve floundering weve been working on

constructive negation methods - A preliminary implementation exists
- But a lot remains to be done!

LP for KRR (review)

- Much work has been done
- Semantics of LP (allow LPs to be viewed as NMR

formalisms) - Extensions with explicit negation, abduction,

paraconsistency, disjunction, ICs, epistemic

operators, - Formal relations to other formalisms (e.g.

default logic, AEL, ) - Techniques to represent and reason about

knowledge using LPs

LP and Non-Monotonicity

- These works focus on non-monotonicity
- LP includes a non-monotonic form of default

negation - not L is true if L cannot (now) be proven
- This 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.

Typical example

- All birds fly. Penguins are an exception

flies(X) ? bird(X), not ab(X). bird(a) ?. ab(X)

? penguin(X).

This program concludes flies(a), by assuming not

ab(a).

- If later we learn penguin(a)
- Add penguin(a).
- Goes back on the assumption not ab(a).
- No longer concludes flies(a).

LP representing a static world

- The work on LP allows the (non-monotonic)

addition of new knowledge. - But
- Much of the work does not consider this evolution

of knowledge - LPs represent a static knowledge of a given world

in a given situation. - The issues of how to add new information to a

logic program are less studied.

Knowledge Evolution

- In real situations knowledge evolves by
- completing it with new information (revision)
- changing it according to the changes in the world

itself (updates)

- I know that I have a flight booked for London

(either for Heathrow or for Gatwick). - I learn that it is not for Heathrow (revision)
- I conclude my flight is for Gatwick
- I learn that flights for Heathrow were canceled

(update) - Either I have a flight for Gatwick or no flight

at all

Logic Programs Revision

- The problem
- A LP represents consistent incomplete knowledge
- New factual information comes.
- How to incorporate the new information?

- The solution
- Add the new facts to the program
- If the union is consistent this is the result
- Otherwise restore consistency to the union

- The new problem
- How to restore consistency to an inconsistent

program?

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.

- If an assumption supports contradiction, then go

back on that assumption.

Simple revision example (2)

P flies(X) ? bird(X), not ab(X). bird(a)

?. ab(X) ? penguin(X).

If later we learn flies(a). P ? flies(a) is

inconsistent. The contradiction does not depend

on assumptions. Cannot remove contradiction!

- If an assumption supports contradiction, then go

back on that assumption.

- Some programs are non-revisable.

What to remove?

- Which 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 - Wed like to delve deeper in the model and

(instead of not flatTyre) either drop - not leakyValve or not puncturedTube.

Revisables

normalWheel ? not flatTyre, not

brokenSpokes. flatTyre ? leakyValve.

normalWheel ? wobblyWheel. flatTyre ?

puncturedTube. wobblyWheel ?.

- Solution
- Define a set of revisables

Revisables not leakyValve, punctureTube,

brokenSpokes Revisions in this case are not

lv, not pt, and not bs

Integrity Constraints

- For convenience, instead of
- normalWheel ? wobblyWheel
- we may use the denial
- ? ? normalWheel, wobblyWheel
- Weve further generalized ICs into
- L1 ? ? Ln ? Ln1 ? ? Lm
- where Lis are literals (possibly not L).

ICs and Contradiction

- In an ELP with ICs, add for every atom A
- ? ? A, A
- A program P is contradictory iff
- P ?? ?
- where ?? is the paraconsistent derivation of SLX

Algorithm for 3-valued revision

- Find all derivations for ?, collecting for each

one the set of revisables supporting it. Each is

a support set. - Compute the minimal hitting sets of the support

sets. Each is a removal set. - A revision of P is obtained by adding
- A ? u A ? R
- where R is a removal set of P.

Example

Rev not a,b,c ? ? p, q p ? not a. q ? not b,

r. r ? not b. r ? not c.

Support sets are

not a, not b

and not a, not b, not c.

Removal sets are not a and not b.

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

The only revision is P U ab(g1) ? u It does

not conclude node(b,1).

- In diagnosis applications (when fault models are

considered) 3-valued revision is not enough.

2-valued Revision

- In diagnosis one often wants the IC
- ab(X) v not ab(X) ?
- With these ICs (that are not denials), 3-valued

revision is not enough. - A two valued revision is obtained by adding facts

for revisables, in order to remove contradiction. - For 2-valued revision the algorithm no longer

works

Example

? ? p. ? ? a. ? ? b, not c. p ? not a, not b.

The only support is not a, not b. Removals are

not a and not b.

- In 2-valued revision
- some removals must be deleted
- the process must be iterated.

Algorithm for 2-valued revision

- Let Revs
- For every element R of Revs
- Add it to the program and compute removal sets.
- Remove R from Revs
- For each removal set RS
- Add R U not RS to Revs
- Remove non-minimal sets from Revs
- Repeat 2 and 3 until reaching a fixed point of

Revs. - The revisions are the elements of the final Revs.

Example of 2-valued revision

? ? p. ? ? a. ? ? b, not c. p ? not a, not b.

Rev0

Rev1 a, b

Rev2 b

Rev3 b,c

Rev4

- Choose . Removal sets of P U are not a

and not b. Add them to Rev.

- Choose a. P U a has no removal sets.

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

- The fixed point had been reached. P U b,c is

the only revision.

REVISE

- The algorithm with various optimizations had been

implemented - REVISE system. - Revise also has
- The possibility of defining a partial ordering of

preferences among revisables. - Associate probabilities to revisables.
- Also computes revisions with minimal cardinality.

- Optimizations include
- Pruning of the search space.
- Making use of preferences and probabilities.

Try it at http//www.soi.city.ac.uk/homes/msch/r

evise/revise.html

Generalizations

- The framework was generalized to encompass
- General ICs
- Mixed 2 and 3-valued revisions (according to ICs)
- This required
- Notion of program state (revisables literals may

change) - Complex notion of distance between two states,

for minimal change

Revision and Diagnosis

- In model based diagnosis one has
- a program P with the model of a system (the

correct and, possibly, incorrect behaviors) - a set of observations O inconsistent with P (or

not explained by P). - The diagnoses of the system are the revisions of

P U O. - Weve shown how to perform mixed consistency and

abduction based diagnosis.

Diagnosis Example

Diagnosis Program

Run

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

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

Predicted and observed values cannot be

different ?? obs(out(G, N), V1), val(out(G, N),

V2), V1 ? V2.

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

Diagnosis Example

, ab(g19)

, and ab(g16),ab(g22)

Revision are

ab(g23)

Revision and Debugging

- Declarative debugging can be seen as diagnosis of

a program. - The components are
- rule instances (that may be incorrect).
- predicate instances (that may be uncovered)
- The (partial) intended meaning can be added as

ICs. - If the program with ICs is contradictory,

revisions are the possible bugs.

Debugging Transformation

- Add to the body of each possibly incorrect rule

r(X) the literal not incorrect(r(X)). - For each possibly uncovered predicate p(X) add

the rule - p(X) ? uncovered(p(X)).
- For each goal G that you dont want to prove add

? ? G. - For each goal G that you want to prove add ?

? not G.

Debugging example

WFM not a, b, not c b should be false

a not b b not 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)

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

BUT c should be true! Add ? not c The only

revision is unc(c ), inc(a not b)

Revision is incorrect(b not c) uncovered(c)

Abduction as Revision

- For abductive queries
- Declare as revisable all the abducibles
- If the abductive query is Q, add the IC
- ? ? not Q
- The revision of the program are the abductive

solutions of Q.

Current and Future Work

- Much has to be done regarding algorithms for

computing revisions, and their implementations. - Interleave the computation of supports and

removals. - Add tabulation
- Heuristics in the computation of removals
- Distribute the algorithm (?)

Example

Rev not a,b,c ? ? p, q p ? not a. r ? not

b. q ? not b, r. r ? not c.

not a

Removal sets are

not b

- What if there were several suspended?
- Which one to resume first? (heuristics)
- How to traverse the tree?

Ongoing Implementation

Distributed tabulation system

Revision Module

resume node

revisions

Tabulation Manager

. . .

(parts of) the tree

- Implemented with PVM-Prolog on a farm of

alphas. - Quite preliminary

Knowledge Evolution

- In real situations knowledge evolves by
- completing it with new information (revision)
- changing it according to the changes in the world

itself (updates)

- I know that I have a flight booked for London

(either for Heathrow or for Gatwick). - I learn that it is not for Heathrow (revision)
- I conclude my flight is for Gatwick
- I learn that flights for Heathrow were canceled

(update) - Either I have a flight for Gatwick or no flight

at all

Model Updates

- Updates are usually performed model by model.
- Marek and Truszczynski defined a language for

defining updates - in(A0) out(A0) ? in(A1), , out(An)
- Given an update program and a model of the

current situatio