logic program semantics background

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

Upload: ivy-bradford

Post on 30-Dec-2015

35 views

Category:

Documents


2 download

DESCRIPTION

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

TRANSCRIPT

Logic Program Semantics Background

Luís Moniz Pereira

U.I. at Jakarta, Jan/Feb 2006

AI Centre, Universidade Nova de Lisboa

LanguageA 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 literalsWhen 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,[X|Y]).

member(X,[Y|L]) member(X,L).

Easier to program, compact codeAdequate for building prototypesGiven efficient implementations, why not

use it to “program” directly?

LP and Deductive Databases

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

),(

).,(

londonlisbonflight

adamlisbonflight

LondonLisbon

AdamLisbon

tofromflight

Other relations are represented with rules:

).,(),(

).,(),,(),(

).,(),(

BAconnectionnotBAherchooseAnot

BCconnectionCAflightBAconnection

BAflightBAconnection

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:

).,(),(

).,(),,(),(

).,(),(

BAconnectionnotBAherchooseAnot

BCconnectionCAflightBAconnection

BAflightBAconnection

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

).(

).(

).()(

).()(

.)(),()(

ppenguin

abird

PpenguinPabnormal

PpenguinPbird

AabnormalnotAbirdAflies

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

)(

)(

)()(

sampaiopresident

einsteinphysicist

XphysicistXaticianableMathem

{pr(s),pr(e),ph(s),ph(e),aM(s),aM(e)} is a modelLack of information that sampaio is a physicist, should

indicate that he isn’tThe minimal model is: {pr(s),ph(e),aM(e)}

Minimal Models Semantics

D[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

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.

TP operator

The minimal models of a definite P can be computed (bottom-up) via operator TP

D[TP] Let I be an interpretation of definite P.

TP(I) = {H: (H Body) P and Body I}

T If P is definite, TP is monotone and continuous. Its minimal fixpoint can be built by: I0 = {} and In = TP(In-1)

T The least model of definite P is TP({})

Stable Models Idea

The identification of models can be done by guessing a possible model, processing it into P and checking if its least model coincides with the guess.

This can be applied to non-stratified programs.

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 examplea not b c a p not qb 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 falseb false c b q true r

Its least model is {not a, not b, not c, not p, q, r} So, it isn’t a stable model:

By assuming not r, r becomes true not a is not assumed and a becomes false

SMs example (cont)a not b c a p not qb 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 trueb 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

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

DM is a stable model of P iff M = 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).

Properties of SMs

Stable models are minimal modelsStable models are supportedIf P is locally stratified then its single

stable model is the perfect modelStable 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 LP&NMR Allowed for a better understanding of the use

of LPs in Knowledge Representation

It is considered as THE semantics of LPs by a significant part of the community.

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 knowledgeLPs 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 EvolutionIn 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 situation, produce model(s) of the new situation.

If several models of the current situation exist, one has to proceed model by model.

Updates of Logic Programs

We’ve defined a program transformation to directly obtain Pu

P

M1

...

Mn

M1,1

M1,n1

Mn,nn

Mn,1

...

...

U

Pu

?

U

We’ve generalized MT’s approach to the 3-valued case

Updates of LPs by LPsWhen 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

Mu2 = {w} vs

{pf,s}

{tv,w}

Bodies are evaluated in the last state.

Generalized LPs

A generalized logic program P is a set of propositional Horn clauses

L L1 ,…, Ln

where L and Li are atoms from LK , i.e. of the

form A or ´not A´.

Program P is normal if no head of the clause in P

has form not A.

Generalized LP semantics

A set M is an interpretation of LK if for every atom A in K exactly one of A and not A is in M.

Definition:

An interpretation M of LK is a stable model of a generalized logic program P if M is the least model of the Horn theory P {not A: A M}.

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

Relation to stable models

Proposition:

An interpretation M of LK is a stable model of a generalized logic program P iff for every A LK

if P/M |- A then A M if A K M then P/M |- A

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.

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.

Update Example

Example:P : sleep not tv_on

watch_tv tv_on

tv_on

the only stable model is M = {tv_on, watch_tv} U : not tv_on power_failure

power_failure

the only update is MU = {power_failure, watch_tv}

the intended model is MI = {power_failure, sleep}

U2 : not power_failure

Update Example (2)

Example:

P : innocent not found_guilty

the only stable model is M = {innocent}

U : found_guilty

the only update is MU = {innocent, found_guilty}

the intended model is MI = {found_guilty}

Dynamic Program Updates Program P is semantically equivalent to the

programP’ : innocent the model MU = {innocent, found_guilty} is the only

reasonable model of the update of P’ by U.

DB’ depends not only on semantics of DB and update U (interpretation updates) but also on their syntax.

We propose a new approach to the problem of updating knowledge bases represented by logic programs that attempts to eliminate the drawbacks of the previous approaches

Dynamic Program Updates

How to update a logic program with another:A B1 , … , Bm , not C1, … , not Cn

not A B1 , … , Bm , not C1, … , not Cn

Program Update

Definition: Let P and U be generalized logic programs in the language L. By the update of P by U we mean the generalized logic program P U, consisting of the clauses:

(RP) Rewritten original program clauses:

AP B1 , … , Bm , C’1, … , C’n

A´P B1 , … , Bm , C’1, … , C’n

(RU) Rewritten updating program clauses:

AU B1 , … , Bm , C’1, … , C’n

A´U B1 , … , Bm , C’1, … , C’n

Translation into LP

(UR) Update rules:

A AU and not A A´U

(IR) Inheritance rules:

A AP , not A´U and A´ A´P , not AU

(DR) Default rules:

A´ not AP , not AU and not A A´

Example

Example:P : sleep not tv_on

watch_tv tv_on

tv_on U : not tv_on power_failure

power_failure

P U = (RP) (RU) (UR) (IR) (DR)

RP : sleepP tv_on´ RU : tv_on´U power_failure

watch_tvP tv_on power_failureU tv_onP

M = {power_failure, sleep} is the only stable model of P U

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

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

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.

Dynamic Program Updates

Definition:Let P = { Ps : s S } be a finite or infinite

sequence of generalized logic programs. The dynamic program update over the sequence of programs P and at the state s S is a logic program s P resulting from the successive updates.

Dynamic LP example

Example: P = { P1, P2, P3}

P1 : sleep not tv_on

watch_tv tv_on

tv_on

P2 : not tv_on power_failure

power_failure

P3 : not power_failure

M1 = {tv_on, watch_tv} is the unique stable model of program 1 P

Dynamic LP example (2)

M2 = {sleep, power_failure} is the unique stable model of the program 2P.

M3 = {tv_on, watch_tv} is the unique stable model of the program 3P.

Program 2P is semantically equivalent to

P1 P2.

Dynamic LP example (3)

Example: P = { P1, P2, P3, P4}

P1 : not fly(X) animal(X) P4 : animal(X) bird(X)

P2 : fly(X) bird(X) bird(X) penguin(X)

P3 : not fly(X) penguin(X) animal(pluto)

bird(duffy)

penguin(tweety)

Program 4 P has a unique stable model in which

fly(duffy) is true and both fly(pluto) and fly(tweety) are false.