22
Logic Programming Logic Programming for Evolving Agents for Evolving Agents J.J. Alferes J.J. Alferes [email protected] [email protected] , , J.A. Leite J.A. Leite [email protected] [email protected] , , L.M. Pereira L.M. Pereira [email protected] [email protected] A. Brogi A. Brogi [email protected] [email protected]

Logic Programming for Evolving Agents

  • Upload
    jace

  • View
    37

  • Download
    0

Embed Size (px)

DESCRIPTION

Logic Programming for Evolving Agents. J.J. Alferes [email protected] , J.A. Leite [email protected] , L.M. Pereira [email protected] A. Brogi [email protected]. Logic Programming for agents. LP paradigm provides: - PowerPoint PPT Presentation

Citation preview

Page 1: Logic Programming for Evolving Agents

Logic Programming Logic Programming for Evolving Agentsfor Evolving Agents

J.J. Alferes J.J. Alferes [email protected]@di.fct.unl.pt,,J.A. LeiteJ.A. Leite [email protected]@di.fct.unl.pt,,L.M. Pereira L.M. Pereira [email protected]@di.fct.unl.pt

A. Brogi A. Brogi [email protected]@di.unipi.it

Page 2: Logic Programming for Evolving Agents

Logic Programming for Logic Programming for agentsagents

LP paradigm provides:LP paradigm provides: Well-defined, general, integrative framework for Well-defined, general, integrative framework for

specifying agents’ knowledge and behaviorspecifying agents’ knowledge and behavior Procedures (and accompanying implementations) Procedures (and accompanying implementations)

for executing agentsfor executing agents To the latter accrues recent LP To the latter accrues recent LP

implementations for non-monotonic implementations for non-monotonic reasoning, such as:reasoning, such as: XSB-Prolog XSB-Prolog (http://xsb.sourceforge.net/)(http://xsb.sourceforge.net/) DLVDLV (http://www.dbai.tuwien.ac.at/proj/dlv/)(http://www.dbai.tuwien.ac.at/proj/dlv/) smodelssmodels (http://www.tcs.hut.fi/Software/smodels/)(http://www.tcs.hut.fi/Software/smodels/)

Page 3: Logic Programming for Evolving Agents

LP for evolving agentsLP for evolving agents LP can be seen as a good representation language LP can be seen as a good representation language

for static knowledgefor static knowledge In a dynamic environment, typical of the agency In a dynamic environment, typical of the agency

paradigm, classical LP is less than adequate. paradigm, classical LP is less than adequate. Lacks:Lacks: Means of integrating knowledge updates from external Means of integrating knowledge updates from external

sources (be it from user changes in the rules describing sources (be it from user changes in the rules describing agent behavior, or simply from environment events)agent behavior, or simply from environment events)

Means for describing rules about the transition Means for describing rules about the transition between statesbetween states

Means for describing self-updates, and self-evolution of Means for describing self-updates, and self-evolution of a program, and combining self-updates with external a program, and combining self-updates with external onesones

Page 4: Logic Programming for Evolving Agents

Updates of LPs by LPsUpdates of LPs by LPs

Dynamic Logic ProgrammingDynamic Logic Programming (DLP) (DLP) [ALPPP] was introduced to address some of [ALPPP] was introduced to address some of these concernsthese concerns

It gives meaning to sequences of LPsIt gives meaning to sequences of LPs Intuitively a sequence of LPs is the result of Intuitively a sequence of LPs is the result of

updating Pupdating P11 with the rules in P with the rules in P22, …, … Inertia is applied to rules rather than to Inertia is applied to rules rather than to

literalsliterals Older rules conflicting with newer Older rules conflicting with newer

applicable rules are rejectedapplicable rules are rejected

Page 5: Logic Programming for Evolving Agents

What was still missing What was still missing By then we knew how to give meaning to By then we knew how to give meaning to

sequences of LPssequences of LPs But how to come up with those sequences?But how to come up with those sequences?

Changes maybe additions or retractionsChanges maybe additions or retractions Updates maybe conditional on a present stateUpdates maybe conditional on a present state Some rules may represent (persistent) lawsSome rules may represent (persistent) laws

Since LP can be used to describe Since LP can be used to describe knowledge states and also sequences of knowledge states and also sequences of updating states, it’s only fit that LP is used updating states, it’s only fit that LP is used too to describe transitions, and thus come too to describe transitions, and thus come up with such sequences up with such sequences

Page 6: Logic Programming for Evolving Agents

SummarySummary Here we present EVOLP, a language Here we present EVOLP, a language

generalizing LP to deal with updates and generalizing LP to deal with updates and evolution. evolution.

We illustrate EVOLP’s usage by We illustrate EVOLP’s usage by specifying an e-mail Personal Assistant specifying an e-mail Personal Assistant AgentAgent

For the implementation of EVOLP and For the implementation of EVOLP and the example, and also other the example, and also other implementations on updates (viz. DLP), implementations on updates (viz. DLP), see:see:http://centria.di.fct.unl.pt/~jja/updates/http://centria.di.fct.unl.pt/~jja/updates/

Page 7: Logic Programming for Evolving Agents

What do we need in What do we need in EVOLPEVOLP

Programs must be allowed to evolvePrograms must be allowed to evolve Meaning of programs should be sequences of Meaning of programs should be sequences of

sets of literals, representing evolutionssets of literals, representing evolutions Needed a construct to assert new informationNeeded a construct to assert new information notnots in the heads to allow newer to supervene s in the heads to allow newer to supervene

older rulesolder rules Program evolution may me influenced by Program evolution may me influenced by

the outsidethe outside Allow external eventsAllow external events … … written in the language of programswritten in the language of programs

Page 8: Logic Programming for Evolving Agents

EVOLP Syntax EVOLP Syntax

EVOLP rules are Generalized LP rules EVOLP rules are Generalized LP rules (possibly with (possibly with notnots in heads) plus special s in heads) plus special predicate predicate assert/1assert/1

The argument of The argument of assertassert is an EVOLP rule is an EVOLP rule (i.e. arbitrary nesting of (i.e. arbitrary nesting of assertassert is allowed) is allowed)

Examples:Examples:assert( a ← not b) ← d, not eassert( a ← not b) ← d, not e

not a ← not assert( assert(a ← b)← not b), cnot a ← not assert( assert(a ← b)← not b), c EVOLP programs are sets of EVOLP rulesEVOLP programs are sets of EVOLP rules

Page 9: Logic Programming for Evolving Agents

Meaning of Self-evolving Meaning of Self-evolving LPsLPs

Determined by sequences of sets of literalsDetermined by sequences of sets of literals Each sequence represents a possible evolutionEach sequence represents a possible evolution The nThe nthth set in a sequence represents what is set in a sequence represents what is

true/false after n steps in that evolutiontrue/false after n steps in that evolution The first set in sequences is a SM of the LP, The first set in sequences is a SM of the LP,

where assert/1 literals are viewed as normal where assert/1 literals are viewed as normal onesones

If If assert(Rule)assert(Rule) belongs to the n belongs to the nthth set, then set, then (n+1)(n+1)thth sets must consider the addition of sets must consider the addition of RuleRule

Page 10: Logic Programming for Evolving Agents

Intuitive exampleIntuitive example

a ←a ←assert(b ←) assert(b ←) assert(c ←) ← bassert(c ←) ← b

At the beginning At the beginning aa is true, and so is is true, and so is assert(b assert(b ←)←)

Therefore, rule Therefore, rule b ← b ← is assertedis asserted At 2At 2ndnd step, step, bb becomes true, and so does becomes true, and so does

assert(c ←) assert(c ←) Therefore, rule Therefore, rule c ← c ← is assertedis asserted At 3At 3rdrd step, step, cc becomes true. becomes true.

<< {a, assert(b ←)},{a, assert(b ←)},{a, b, assert(b ←), assert(c ←)},{a, b, assert(b ←), assert(c ←)},{a, b, c, assert(b ←), assert(c ←)}{a, b, c, assert(b ←), assert(c ←)} >>

Page 11: Logic Programming for Evolving Agents

Self-evolution definitionsSelf-evolution definitions

An An evolution interpretationevolution interpretation of of PP over over LL is a is a sequence sequence <I<I11,…,I,…,Inn>> of sets of atoms from of sets of atoms from LLasas

The The evolution traceevolution trace of of <I<I11,…,I,…,Inn>> is is <P<P11,,…,P…,Pnn>>::

PP11 = P = P and and PPii = {R | assert(R) = {R | assert(R) I Ii-1i-1}} (2 ≤ i ≤ n)(2 ≤ i ≤ n)

Evolution traces contains the programs Evolution traces contains the programs imposed by interpretationsimposed by interpretations

We have now to check whether each nWe have now to check whether each nthth set set complies with the programs up to n-1complies with the programs up to n-1

Page 12: Logic Programming for Evolving Agents

Evolution Stable ModelsEvolution Stable Models

<I<I11,…,I,…,Inn>>, with trace , with trace <P<P11,…,P,…,Pnn>>, is an , is an evolution stable modelevolution stable model of of PP, iff, iff

1 ≤ i ≤ n1 ≤ i ≤ n, , IIii is a SM of the DLP: is a SM of the DLP: PP1 1 … …PPii

I is a stable model of I is a stable model of PP1 1 … …PPnn iff iff

I = least( (I = least( (PPii – Rej(I)) – Rej(I)) Def(I) ) Def(I) )

where:where: Def(I) = {not A | Def(I) = {not A | A ← Body) A ← Body) PPii, Body , Body I} I}

Rej(I) = {LRej(I) = {L00 ← Bd in Pi | ← Bd in Pi | not Lnot L00 ← Bd’) ← Bd’) Pj, Pj,

i < j ≤ n, and Bd’ i < j ≤ n, and Bd’ I} I}

Page 13: Logic Programming for Evolving Agents

Simple exampleSimple example <{a, assert(b ← a)}, {a, b,c,assert(not a ←)}, <{a, assert(b ← a)}, {a, b,c,assert(not a ←)},

{assert( b ← a)}>{assert( b ← a)}> is an evolution SM of P: is an evolution SM of P:

a ←a ← assert(not a ←) ← bassert(not a ←) ← bassert(b ← a) ← not cassert(b ← a) ← not c c ← assert(not a c ← assert(not a ←)←)

The trace is The trace is <P,{b ← a},{not a ←}><P,{b ← a},{not a ←}>

a,assert(b ← a)

assert(b ← a)a, b, c,

assert(not a ←)

Page 14: Logic Programming for Evolving Agents

Event-aware programsEvent-aware programs Events may come from the outside:Events may come from the outside:

Observations of facts or rulesObservations of facts or rules Assertion orderAssertion order

Both can be written in EVOLP languageBoth can be written in EVOLP language An An event sequenceevent sequence is a sequence of sets of is a sequence of sets of

EVOLP rules.EVOLP rules. <I<I11,…,I,…,Inn>>, with trace , with trace <P<P11,…,P,…,Pnn>>, is an , is an

evolution SMevolution SM of of PP givengiven <E<E11,…,E,…,Ekk>>, iff, iff

1 ≤ i ≤ n1 ≤ i ≤ n, , IIii is a SM of the DLP: is a SM of the DLP:

PP1 1 PP2 2 … …PPi i E Eii))

Page 15: Logic Programming for Evolving Agents

Simple exampleSimple example The program says that: whenever The program says that: whenever cc, assert , assert a ← a ←

bb The events were: 1The events were: 1stst cc was perceived; 2 was perceived; 2ndnd an an

order to assert order to assert bb; 3; 3rdrd an order to assert an order to assert not anot a

P: assert(a ← b) ← cP: assert(a ← b) ← cEvents: <{c ← }, {assert(b ←)}, {assert(not a Events: <{c ← }, {assert(b ←)}, {assert(not a ←)}>←)}>

c,assert(a ←← b)

assert(b ←←)b, a,

assert(not a ←←)b

Page 16: Logic Programming for Evolving Agents

Email agent coreEmail agent core

Personal assistant agent for e-mail Personal assistant agent for e-mail management able to:management able to: Perform basic actions of sending, receiving, Perform basic actions of sending, receiving,

deleting messagesdeleting messages Storing and moving messages between foldersStoring and moving messages between folders Filtering spam messagesFiltering spam messages Sending automatic replies and forwardingSending automatic replies and forwarding Notifying the user of special situationsNotifying the user of special situations

All of this may depend on user specified All of this may depend on user specified criteriacriteria

The specification may change dynamicallyThe specification may change dynamically

Page 17: Logic Programming for Evolving Agents

EVOLP for e-mail EVOLP for e-mail AssistantAssistant

If the user specifies, once and for all, a If the user specifies, once and for all, a consistent set of policies triggering actions, consistent set of policies triggering actions, then any existing (commercial) assistant would then any existing (commercial) assistant would do the job.do the job.

But if we allow the user to update its policies, But if we allow the user to update its policies, and to specify both positive (e.g. “…and to specify both positive (e.g. “…must be must be deleted”deleted”) and negative (e.g. ) and negative (e.g. “…must not be “…must not be deleted”deleted”) instances, soon the union of all ) instances, soon the union of all policies becomes inconsistentpolicies becomes inconsistent

We cannot expect the user to debug the set of We cannot expect the user to debug the set of policy rules so as to invalidate all the old rules policy rules so as to invalidate all the old rules (instances) contravened by newer ones.(instances) contravened by newer ones.

Some automatic way to resolve inconsistencies Some automatic way to resolve inconsistencies due to updates is needed.due to updates is needed.

Page 18: Logic Programming for Evolving Agents

EVOLP for e-mail Assistant EVOLP for e-mail Assistant (cont)(cont)

EVOLP provides an automatic way of EVOLP provides an automatic way of removing inconsistencies due to updates:removing inconsistencies due to updates: With EVOLP the user simply states whatever new With EVOLP the user simply states whatever new

is to be done, and let the agent automatically is to be done, and let the agent automatically determine which old rules may persist and which determine which old rules may persist and which not.not.

We are not presupposing the user is We are not presupposing the user is contradictory, but just that he keeps updating its contradictory, but just that he keeps updating its profileprofile

EVOLP further allows:EVOLP further allows: Postponed addition of rules, depending on user Postponed addition of rules, depending on user

specified criteriaspecified criteria Dynamic changes in policies, triggered by Dynamic changes in policies, triggered by

internal and/or external conditionsinternal and/or external conditions Commands that span over various statesCommands that span over various states ……

Page 19: Logic Programming for Evolving Agents

An EVOLP e-mail An EVOLP e-mail AssistantAssistant

In the following we show some policy In the following we show some policy rules of the EVOLP e-mail assistant.rules of the EVOLP e-mail assistant. A more complete set of rules, and the results A more complete set of rules, and the results

given by EVOLP, can be found in the paper.given by EVOLP, can be found in the paper. Basic predicates:Basic predicates:

New messages come as events of the form:New messages come as events of the form:newmsg(Identifier, From, Subject, Body)newmsg(Identifier, From, Subject, Body)

Messages are stored via predicates:Messages are stored via predicates:msg(Identifier, From, Subj, Body, TimeStamp)msg(Identifier, From, Subj, Body, TimeStamp)andand

in(Identifier, FolderName)in(Identifier, FolderName)

Page 20: Logic Programming for Evolving Agents

Simple e-mail EVOLP Simple e-mail EVOLP rulesrules

By default messages are stored in the inbox:By default messages are stored in the inbox:assert(msg(M,F,S,B,T)) ← newmsg(M,F,S,B), time(T), assert(msg(M,F,S,B,T)) ← newmsg(M,F,S,B), time(T),

not delete(M). not delete(M).

assert(in(M,inbox)) ← newmsg(M,F,S,B), not delete(M).assert(in(M,inbox)) ← newmsg(M,F,S,B), not delete(M).

assert(not in(M,F)) ← delete(M), in(M,F).assert(not in(M,F)) ← delete(M), in(M,F). Spam messages are to be deleted:Spam messages are to be deleted:

delete(M) ← newmsg(M,F,S,B), spam(F,S,B).delete(M) ← newmsg(M,F,S,B), spam(F,S,B). The definition of spam can be done by LP rules:The definition of spam can be done by LP rules:

spam(F,S,B) ← contains(S,credit).spam(F,S,B) ← contains(S,credit). This definition can later be updated:This definition can later be updated:

not spam(F,S,B) ← contains(F,my_accountant). not spam(F,S,B) ← contains(F,my_accountant).

Page 21: Logic Programming for Evolving Agents

More e-mail EVOLP rulesMore e-mail EVOLP rules Messages can be automatically moved to other folders. When Messages can be automatically moved to other folders. When

that happens (not shown here) the user wants to be notified: that happens (not shown here) the user wants to be notified:

notify(M) notify(M) ←← newmsg(M,F,S,B), assert(in(M,F)), assert(not newmsg(M,F,S,B), assert(in(M,F)), assert(not in(M,inbox)).in(M,inbox)).

When a message is marked both for deletion and automatic When a message is marked both for deletion and automatic move to another folder, the deletion should prevail:move to another folder, the deletion should prevail:

not assert(in(M,F)) ← move(M,F), delete(M). not assert(in(M,F)) ← move(M,F), delete(M).

The user is organizing a conference, assigning papers to The user is organizing a conference, assigning papers to referees. After receipt of a referee’s acceptance, a new rule is referees. After receipt of a referee’s acceptance, a new rule is to be added, which forwards to the referee any messages to be added, which forwards to the referee any messages about assigned papers: about assigned papers:

assert(send(R,S,B1) ← newmsg(M1,F,S,B1), contains(S,Id), assert(send(R,S,B1) ← newmsg(M1,F,S,B1), contains(S,Id), assign(Id,R)) assign(Id,R)) ← newmsg(M2,R,Id,B2), ← newmsg(M2,R,Id,B2), contains(B2,accept).contains(B2,accept).

Page 22: Logic Programming for Evolving Agents

ConclusionsConclusions

We’ve presented EVOLP, and We’ve presented EVOLP, and illustrated its usage in an agent illustrated its usage in an agent applicationapplication

EVOLP is a declarative, concise, EVOLP is a declarative, concise, simple and quite powerful language simple and quite powerful language to reason about agents that evolveto reason about agents that evolve

EVOLP: a firm formal basis in which EVOLP: a firm formal basis in which to express, implement, and reason to express, implement, and reason about evolving agentsabout evolving agents