76
Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London ICCL Summer School Dresden August 2008

Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Embed Size (px)

Citation preview

Page 1: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

1

Abductive Logic Programming

(ALP) and its Application in Agents and Multi-agent

SystemsFariba Sadri

Imperial College LondonICCL Summer School Dresden

August 2008

Page 2: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

2

Contents

• ALP recap• ALP and agents• Abductive planning via abductive event

calculus (AEC)• Dynamic planning with AEC• Abductive proof procedures – IFF and CIFF• Hierarchical Planning• Reactivity• Plan repair• Dialogues and Negotiation

Page 3: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

3

Abductive Logic ProgrammingRecap from Bob Kowalski’s

SlidesAbductive Logic Programs <P, A, IC> have three components:

• P is a normal logic program. • A is a set of abducible predicates.• IC, the set of integrity constraints.

Often, ICs are expressed as conditionals: If A1 &...& An then B A1 &...& An B

or as denials:not (A1 &...& An & not B) A1 &...& An & not B

false

Normally, P is not allowed to contain any clauses whose conclusion contains an abducible predicate.

(This restriction can be made without loss of generality.)

Page 4: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

4

ALP Semantics Recap from Bob Kowalski’s Slides

Semantics:Given an abductive logic program,

< P,A,IC >, an abductive answer for a goal G is a set Δ of ground atoms in terms of the abducible predicates such that:

G holds in P ΔIC holds in P Δ or P Δ IC

is consistent.

Page 5: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

5

Abduction is normally used to explain observations

Recap from Bob Kowalski’s Slides

Program P: Grass is wet if it rainedGrass is wet if the sprinkler was onThe sun was shining

Abducible predicates A: it rained, the sprinkler was on

Integrity constraint: it rained & the sun was shining false

Observation: Grass is wet

Two potential explanations: it rained, the sprinkler was on

The only explanation that satisfies the integrity constraint is

the sprinkler was on.

Page 6: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

6

ALP and Agents

Some references: Two ALP-based agent models:

R.A. Kowalski, F. Sadri, From logic programming towards multi-agent systems. In Annals of Mathematics and Artificial Intelligence Volume 25, pages 391-419  (1999)

Later developments of this model in later papers by Bob Kowalski

A. Kakas. P. Mancarella, F. Sadri, K. Stathis, F. Toni. Computational logic foundations of KGP agents, Journal of Artificial Intelligence Research. To appear

Page 7: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

7

ALP and Agents

Agents can be seen as ALPs• Logic Programs represent beliefs

(more elaborate beliefs than Agent0 or AgentSpeak)

• Abducibles represent observations and actions

• Integrity Constraints represent– Condition-action rules for reactivity– Plan repair rules– Communication policies– Obligations and prohibitions

Page 8: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

8

ALP and Agents

Abductive Logic Programs used for • Planning • Reactivity• Plan repair• Negotiation

Page 9: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

9

ALP and AgentsA small planning example

P: have(X) if buy(X)have(X) if borrow(X)

A: buy, borrow, register (actions)IC: buy(X) & no-money false

buy(tv) register(tv)Goal: have(tv)

Δ1: buy(tv) & register(tv) (Plan 1)Δ2: borrow(pc) (Plan 2)If P also includes no-money then

The only solution (only plan) is Δ2: borrow(pc).

Page 10: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

10

ALP for PlanningAbductive Event Calculus (AEC)Some ReferencesOriginal Event CalculusR.A. Kowalski and M.J. Sergot (1986)A logic-based calculus of events. New Generation

Computing, 4(1), 67-95.

Abductive Event calculusP. Mancarella, F. Sadri, G. Terreni, F. Toni (2004)

Planning partially for situated agents. In Leite, Torroni (eds.), Computational Logic in Multi-agent Systems, CLIMA V, Lecture Notes in Computer Science, Springer, 230-248.

Also papers by M. Shanahan.

Page 11: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

11

ALP for PlanningAbductive Event Calculus (AEC)

Domain Independent Rules

holds_at(F,T2) happens(A,T1), T1<T2,

initiates(A, T1, F),

¬clipped(T1, F, T2)

holds_at(F,T) initially(F), 0T,

¬clipped(0,F,T)

clipped(T1,F,T2) happens(A,T),

terminates(A,T,F), T1T<T2

Page 12: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

12

ALP for PlanningAbductive Event Calculus (AEC)

holds_at(¬F,T2) happens(A,T1), T1<T2,

terminates(A, T1, F),

¬declipped(T1, F, T2)

holds_at(¬F,T) initially(¬F), 0T,

¬declipped(0,F,T)

declipped(T1,F,T2) happens(A,T),

initiates(A,T,F), T1T<T2

Page 13: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

13

AEC Domain dependent rules

Example:

initially(¬have(money))initiates(buy(X), T, have(X) )

¬X=moneyinitiates(borrow(X), T, have(X))terminates(buy(X), T, have(money) )precondition(buy(X), have(money))

Page 14: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

14

AEC Domain dependent rules

Another Example Actions can be communicative actions : tell(Ag1, Ag2, Content, D)

initially(no-info(tr-ag, arrival(tr101))

initiates(tell(X, tr-ag, inform(Q,I), D),T,have-info(tr-ag,Q,I)) holds_at(trustworthy(X),T)

terminates(tell(X, tr-ag, inform(Q,I), D),T,no-info(tr-ag,Q)) holds_at(trustworthy(X),T)

precondition(tell(tr-ag,X, inform(Q,I), D), have-info(tr-ag,Q,I))

Page 15: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

15

AEC

• Abducible happens• Domain Independent Integrity Constraintsholds_at(F,T) & holds_at(F,T) falsehappens(A,T)&

precondition(A,P)holds_at(P,T)• and any Domain Dependent Integrity

ConstraintsFor example:holds_at(open-shop, T) T≥9 & T≤18happens(tell(a, Ag, accept(R), D), T) & happens(tell(a, Ag, refuse(R), D), T) false

Page 16: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

16

ALP with Constraints

• Notice that AEC has times and constraint predicates, T1<T2, T1T2, T1=T2, etc.

• We can extend the notion of abductive answer to cater for these, in the spirit of Constraint Logic Programming (CLP).

• Structure R consisting of – a domain D(R) and – a set of constraint predicates and – an assignment of relations on D(R) for each

such constraint predicate.

Page 17: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

17

ALP with ConstraintsSemantics

Given an ALP with constraints, < P,A,IC,R>, an abductive answer for a goal G

is a Δ=(D, C) such thatD is in terms of the abducible predicates, andfor all groundings of the variables in G, D, C

such that satisfies C (according to R)G holds in P DIC holds in P D or P D IC is consistent.

Page 18: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

18

Back to AEC

Given AEC and a goal Gholds_at(g1, T1) & holds_at(g2, T2) & … &

holds_at(gn, Tn) an answer for G is a parially ordered plan for

achieving G.That is an answer for G is a = (As, TC)As is a set of happens atoms, and TC is a set of temporal constraints, and is an abductive answer to G wrt AEC with

constraints.

Page 19: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

19

Example

Domain dependent part : initially(¬have(money))initiates(buy(X), T, have(X) )

¬X=moneyinitiates(borrow(X), T, have(X))terminates(buy(X), T, have(money) )precondition(buy(X), have(money))happens(buy(X), T) T≥9 & T≤18

Page 20: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

20

Example cntd.

Goal: holds_at(have(pc), T) & T<12One answer (plan): 1= (happens(borrow(pc), T1),

T1<T<12)2= (happens(borrow(money),T1),

happens(buy(pc), T2) T1<T2, T29, T2<T<12)

Page 21: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

21

Example cntd.Goal: holds_at(have(pc), T) & holds_at(have(tv), T) How many answers (plans) are there ????Some answers are:1=(happens(borrow(pc),T1),

happens(borrow(tv),T2), T1<T, T2<T)

2=(happens(borrow(money),T1),happens(buy(pc), T2),happens(borrow(money),T3),happens(buy(tv), T4),T1<T2, T29, T2 ≤18, T2<T3, T3<T4, T49, T4

≤18, T4<T)

Page 22: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

22

Agent Cycle

Messages Goals + ALPEnvironment +

ObservationsEffects of actions

Observe ActReason

Page 23: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

23

An ALP agent cycle with explicit time

to cycle at time T,record any observations at time T,resume thinking, giving priority to forward reasoning with the new observations,evaluate to false any alternatives containing sub-goals that are not marked as observations but are atomic actions to be performed at an earlier time,select sub-goals, that are not marked as observations, from among those that are atomic actions to be performed at times consistent with the current time,attempt to perform the selected actions,record the success or failure of the performed actions and mark the records as observations,cycle at time T+ n, where n is small.

 Note selecting an action involves both selecting an alternative branch of the search space and prioritising conjoint subgoals.

Page 24: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

24

Agent Cycle

Now consider using AEC in an agent cycle.

We will have:• Observations• Plan execution• Interleaved planning and plan execution

So we have to extend the AEC theory for this dynamic setting.

Page 25: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

25

(Dynamic) AECBridge Rules

Bridge rules for connecting the AEC theory to observations:

holds_at(F,T2) observed(F,T1), T1 T2,

¬clipped(T1,F,T2)

holds_at(¬F,T2) observed(¬F,T1), T1 T2,

¬declipped(T1,F,T2)happens(A,T) executed(A,T)happens(A,T) observed(_, A[T], _)happens(A, T) assume_happens(A, T)clipped(T1,F,T2) observed(¬F,T), T1T<T2

declipped(T1,F,T2) observed(F,T), T1T<T2

Page 26: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

26

(Dynamic) AEC

Abducible assume_happens

As well as abducibles we can also have a set of observables. These are fluents (or fluent literals) that can only be proved by being observed. The agent cannot plan to achieve them.

In the KGP architecture they are called sensing goals.

E.g. shop is openit is raining.

Page 27: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

27

Observations

In general observations can involve:• Observable predicates• Abducible predicates• Defined predicates – in which case

the observation may be explained through abductions.

Page 28: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

28

(Dynamic) AEC

Modify the set of domain independent integrity constraints:

holds_at(F,T) & holds_at(F,T) falseassume_happens(A,T) &

precondition(A,P) holds_at(P,T)

assume_happens(A,T) & ¬executed(A,T), time_now(T’) T>T’

Page 29: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

29

Example

Domain dependent part : initially(¬have(money))initiates(buy(X), T, have(X) )

¬X=moneyinitiates(borrow(X), T, have(X))terminates(buy(X), T, have(money) )precondition(buy(X), have(money))precondition(buy(X), open-shop)

observable

Page 30: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

30

Example cntd.

Goal: holds_at(have(pc), T) & T<12The agent can consider two alternative

plans, to borrow pcto buy pc.

Then an observation ¬open-shop(maybe a notice saying the shop is

closed all day or until further notice) makes the agent focus on the first plan.

Page 31: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

31

Proof Procedures for Abductive Logic Programs

(with constraints)Some references:CIFF:Endriss U., Mancarella P., Sadri F., Terreni

G., Toni F., Abductive logic programming with CIFF: system description.

The CIFF proof procedure for abductive logic programming with constraints.

Both in Proceedings of Jelia 2004.

Page 32: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

32

Proof ProceduresEndriss U., Mancarella P., Sadri F., Terreni

G., Toni F., The CIFF proof procedure for abductive logic programming with constraints: theory, implementation and experiments. Forthcoming.

A-System:Kakas A., Van Nuffelen B., Denecker M., A-

system: problem solving through abduction. In Proceedings of the 17th Internationla Joint Conference on Artificial Intelligence, 2001, 591-596.

Page 33: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

33

Proof Procedure : CIFF

• Builds on earlier work by Fung and Kowalski: The IFF proof procedure for abductive logic programming. Journal of Logic Programming, 1997.

• CIFF adds constraint satisfaction and a few other features for efficiency and extended applicability.

• Here we review the IFF proof procedure.

Page 34: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

34

IFF

Roughly speaking : Given ALP <P,A,IC> :IFF reasons forwards with IC and

backwards with the selective completion of P (wrt non-abducibles).

Page 35: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

35

IFF – Selective CompletionExample of selective completion wrt non-abducibles):

P: have(X) if buy(X)have(X) if borrow(X)

A: buy, borrow (actions)IC: buy(X) & no-money falseSelective completion of P is:

have(X) iff buy(X) or borrow(X)no-money iff false

i.e. the abducibles are open predicates, the rest are completed.

We can also designate the observables as open predicates.

Page 36: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

36

IFF – Backward reasoning

(Unfolding) Backward reasoning (Unfolding) uses

iff-definitions to reduce atomic goals(and observations) to disjunctions of

conjunctions of sub-goals.E.G.A goal have(pc) will be unfolded tobuy(pc) or borrow(pc).

Page 37: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

37

IFF – Forward reasoning

(Propagation) Forward reasoning (Propagation) tests and actively maintains

consistency and the integrity constraintsby matching a new observation or new atomic goal p with a condition of an implicational goal p & q r to derive the new implicational goal q r.   q can be reduced to subgoals by backward reasoning (unfolding)

or can be removed by forward reasoning (propagation). 

r is added as a new goal (after p & q has been removed).r can then trigger forward reasoning or can be reduced to sub-goals.

 r is (in general) a disjunction of conjunctions of sub-goals.

Page 38: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

38

IFF – Forward reasoning

(Propagation)In the example propagation will give:[buy(pc) & (no-money false)] or

borrow(pc).

Suppose now we observe no-money.Another propagation step will give[buy(pc) & false] or borrow(pc).

Page 39: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

39

IFF – Some Other Inference Rules

 • Logical equivalences replace a subformula by another

formula which is both logically equivalent and simpler.These include the following equivalences used as rewrite rules:

•  

G & true iff G G & false iff falseD or true iff true D or false iff D.[true D] iff D [false D] iff true

• Splitting uses distributivity to replace a formula of the form•  

(D or D') & G by (D & G) or (D'& G) • Factoring “unifies two atomic subgoals P(t) & P(s)

replacing them by the equivalent formula•  

[P(t) & s=t] or [P(t) & P(s) & s t]

Page 40: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

40

IFF - Negation

Two versions:• Negation re-writing:

¬P is re-written as p false.• Combining negation re-writing and

negation as failure:Some negative literals are

marked These are evaluated using special inference rules that provide the effect of NAF.

Page 41: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

41

IFF - Search SpaceThe search space is represented by a logical

formula, e. g.

[happens(borrow(money), T1) & happens(buy(pc), T2) & T1<T2 & happens(borrow(tv), T3) & precondition(buy(pc),P) holds_at(P,T2)]

or[happens(borrow(pc),T)] &

happens(happens(borrow(tv),T’)]

Each disjunct is analogous to an alternative branch of a prolog-like search space.

Page 42: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

42

Notice - 1

• Propagation together with unfolding allows ECA or condition-action rule type of behaviour.

E & C A E & C G

trigger via propagationevaluate via propagation or unfoldingfires the action or goal

Page 43: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

43

Notice - 2Factoring allows repeating actions at a later stage if an earlier

attempt has not been effective.Scenario: e-shopping – logged on with one credit card, choose

item, then card fails because there are not enough funds.

Given :happens(logon(Card), T1) & happens(logon(visa), 5) &

Rest(Card)

planned action recorded observation

factoring obtains:[happens(logon(Card), T) & Card=visa &T=5 & Rest(Card)] or [happens(logon(Card), T) & happens(logon(visa), 5) & (T5 or

Cardvisa) & Rest(Card)]

Page 44: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

44

Notice – 2 cntd.

• So if Rest(Card) fails with Card=visa &T=5 the 2nd disjunct allows further attempts:– either to logon with a different card at a

later time– or to logon with visa at a later time

• Notice also that any work done in Rest(Card) in the first attempt is saved and available in the 2nd disjunct, for example choice of item to buy.

Page 45: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

45

Semantics• Let D be a conjunction of definitions in iff-form• Let G be a goal, i.e.conjunction of literals• Let IC be a set on integrity constraints• Let O be a conjunction of positive and negative

observations, including actions successfully or unsuccessfully performed by the agent.

 G & O is an answer iff all the below hold: 

G and O are both conjunctions of formulae in the abducible and constraint (e.g.=) (or observable) predicates

• D & G & O |= G• D & O |= O• D & G & O |= IC.

Page 46: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

46

AEC for Hierarchical Planning

• So far you have seen AEC formalised for planning from 1st principles.

• This may not be ideal in an agent setting.

• AEC lends itself to formalising plan libraries, macro-actions and hierarchical and progressive planning.

• We will look at some of these through examples.

Page 47: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

47

AEC for Hierarchical Planning

A Reference:M. Shanahan, An abductive event

calculus planner. The Journal of Logic Programming, Vol 44, 2000, 207-239

Page 48: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

48

AEC for Hierarchical PlanningExample (from Shanahan’s

paper)Robot mail delivery domainPrimitive actionsinitiates(pickup(P), T, got(P))

holds_at(in(R),T), holds_at(in(P,R),T), initiates(putdown(P),T, in(P,R))

holds_at(in(R),T), holds_at(got(P),T)initiates(gothrough(D), T, in(R1))

holds_at(in(R2),T), connects(D,R2,R1)terminates(gothrough(D), T, in(R))

holds_at(in(R),T)

Page 49: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

49

AEC for Hierarchical PlanningExample cntd.

Compound actionhappens(shiftPack(P,R1,R2,R3),T1,T6)

happens(goToRoom(R1,R2),T1,T2), ¬clipped(T2,in(R2),T3), ¬clipped(T1,in(P,R2),T3), happens(pickup(P),T3), happens(goToRoom(R2,R3),T4,T5), ¬clipped(T3,got(P),T6), ¬clipped(T5,in(R3),T6), happened(putdown(P),T6),

T2<T3<T4, T5<T6

Page 50: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

50

AEC for Hierarchical PlanningExample cntd.

goToRoom(R1,R2) maintain effect

pickup(P) maintain effect

goToRoom(R2,R3) maintain effect

putdown(P)

shiftPack

(P,

R1,

R2,

R3)

Page 51: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

51

AEC for Hierarchical PlanningExample cntd.

initiates(shiftPack(P,R1,R2,R3),T, in(P,R3)) holds_at(in(R1), T), holds_at(in(P,R2),T)

Verifiable:The effects of compound actions should

follow from the effects of their sub-actions. This can be verified formally, or, in this case by inspection.

Page 52: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

52

AEC for Hierarchical PlanningExample cntd.

happens(goToRoom(R,R),T,T)happens(goToRoom(R1,R3),T1,T3)

connects(D,R1,R2), happens(gothrough(D),T1), ¬clipped(T1,in(R2),T2), T1<T2

happens(goToRoom(R2,R3),T2,T3) initiates(goToRoom(R1,R2),T,in(R2))

holds_at(in(R1),T)Conditional and recursive compound

action

Page 53: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

53

AEC for Hierarchical Planningin agent model

Hierarchical planning in the agent model allows :• Building heuristics and expertise into planning • Generating actions in progressive order – first

action first (as opposed to regressive order – last action first).

Progressive planning fits well within an agent cycle: • A partial plan can be executed and give useful

results. • Observe effect of actions and the state of the

environment to decide whether it is worth continuing with that plan.

Page 54: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

54

ALP for Reactivity

• To specify reactions to the changes/events in the environment, similar to condition-action rules

• To specify plan repair steps

• To specify interaction policies

Page 55: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

55

specify reactions to the environment

ALP allows and extends the active behaviour provided by ECA/Condition-Action rules and gives it semantics.

Page 56: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

56

ALP for Reactivity

Domain Dependent Integrity Constraints in the ALP can be specified and used to achieve reactive behaviour.

Triggers, Other-Conditions

Reaction

Conjunction of: Conjunction of: Observations holds_at(F,T)Executed actions happens(A,T) Planned actions temporal constraints

Page 57: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

57

Examples

Informal syntaxin room R at time T & alarm sounds in

R at T leave R at T+1(Smart Home Ambient Intelligence AmI-

See for example work by Augusto et al on agent-based ECA-based AmI)

P leaves kitchen at T & gas is on at T & ¬ X enters kitchen by T+15

raise alarm at T+15

Page 58: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

58

Plan Repair

Most agent models that have plan repair use (ad hoc) ECA/Condition-Action rules for this purpose (see, for example 2APL/3APL).

A reference for 3APL:M. Dastani, B, van Riemsdijk, F. Dignum, J-J.

Meyer, A programming language for cognitive agents goal directed 3APL. Proceedings of the First Workshop on Programming Multiagent Systems: Languages, frameworks, techniques, and tools (ProMAS03) to be held at AAMAS'03, Melbourne, July 2003.

Page 59: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

59

Plan Repair

An example from 2APL:Goto(R2,R1);X <- not pos(R2) and

pos(R3)| {goto(R3,R1);X}

An example from 3APL:G(on(X,Y))<- B(tooheavy(X) and

¬heavy(Z)) | G(on(Z,Y)

Page 60: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

60

Plan Repair

Using ALP we can• Formalise and use such ad hoc (active) rules

for plan repair – examples seen earlier• Achieve the behaviour of such rules just by

executing AEC – example on next slide• Derive such specialised plan repair rules

from the general AEC theory and then use them explicitly – example on slide after next

• Simulate TR-Program type of behaviour by manipulating the search space and search strategy – work in progress

Page 61: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

61

Plan Repair

Achieve the behaviour of such rules just by executing AEC:

Example:Goto(R2,R1);X <- not pos(R2) and

pos(R3)| {goto(R3,R1);X}In AEC there will be a goal, e.g pos(r1)

requiring an action goto(Y,r1) with a precondition pos(Y).

Page 62: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

62

Plan Repair

pos(r1)goto(Y,r1)pos(Y), goto(Y,r1)Y=r2, ¬clipped(pos(r2)), goto(Y,r1)

observe(pos(r3))This entails clipped(pos(r2))

and pos(r3)Y=r3, ¬clipped(pos(r3)), goto(Y,r1)

Page 63: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

63

Plan RepairDeriving specialised plan repair rules from the general AEC

theory

E-shopping Example using simplified notation :logged on with one credit card, choose item, then card fails

because there are not enough funds. We want to use another card, but first we have to logout the first card.

Specialised plan repair rulelogon(Card1,T1) & logged-on(Card2, T2) & T2<T1

logout(Card2, T3) & T2<T3<T1Such a rule is derivable from AEC and domain-dependent rules precondition(logon(Card), ¬logged-on(Card’))terminates(logout(Card), T, logged-on(Card))

Page 64: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

64

Plan RepairHow? Briefly : Givenhappens(logon(Card1),T1)holds(¬logged-on(Card2), T1)

using the precondition ICholds(logged-on(Card2),T1) false

using the F and ¬F cannot hold together IChappens(logon(Card2),T2) & T2<T1 & ¬clipped(T2, logged-on(Card2),

T1) falseusing definition of holds

happens(logon(Card2),T2) & T2<T1clipped(T2,logged-on(Card2),T1)using negation re-writing

happens(logon(Card2),T2) & T2<T1 happens(logoout(Card2),T3) & T2<T3<T1

using definition of clipped and terminates So:happens(logon(Card1),T1) & happens(logon(Card2),T2) & T2<T1

happens(logoout(Card2),T3) & T2<T3<T1

Page 65: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

65

ALP for negotiationSome references:Sadri F., Toni F., Torroni P.:An abductive logic programming architecture for negotiating

agents, Jelia 02.Minimally intrusive negotiating agents for resource sharing,

IJCAI 03.Dialogues for negotation: agent varieties and dialogue

sequences, ATAL 01.

Endriss U., Maudet N., Sadri F., Toni F.: Protocol conformance for logic-based agents, IJCAI 03.

F. Sadri: Multi-agent Cooperative Planning and Information Gathering, 11th International Workshop CIA 2007 on Cooperative Information Agents, September 2007, LNAI series by Springer Verlag.

Page 66: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

66

ALP for negotiation

• Dialogues between agents as a means of interaction

• Often based on fixed protocols (rules of interaction)

• Negotiation is one form of dialogue• Others include (Classification of

dialogues [Walton & Krabbe, 1995])– Persuation– Information seeking

Page 67: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

67

ALP for negotiation

Negotiation:• Negotiation is “the process by which a

group of agents communicate with each other to try and come to a mutually acceptable agreement on some matter”.[Bussman & Muller 1992]

• One reason agents may negotiate is for resource sharing and allocation.

Page 68: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

68

ALP for negotiationGeneral Idea 1

Agent1 has a plan requiring resources A,B. It has A,E, and is missing B.

Agent2 has a plan requiring resources D,E. It has B,C,D, and is missing E.

Can you give me B?

Yes, if you give me E.

Page 69: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

69

ALP for negotiationGeneral Idea 2

Can you give me B? No, why do you want B?

I have a goal G and a plan bla bla and I need B for it. Well, You can solve G with plan bla’ bla’ which needs C but not B. I

can give you C if you give me E.

Page 70: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

70

ALP for negotiationGeneral Idea 3

Can you give me B from 9 to 5?

No, I can give it to you at 9 but I need it back at 3.

Page 71: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

71

ALP for negotiation Communication language

Communication languagetell(Ag1,Ag2,Content,D)

Content can be :request request(give(R)) request(give(R),

(Ts,Te)accept refusepromise promise(R, (T1,T2), (T3,T4))Change change(promise(R, (T1,T2), (T3,T4)))Challenge challenge(request(give(R)))....

Page 72: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

72

ALP for negotiation Interaction Policies

Expressed as integrity constraints of the form

Pi & C Pi+1

Dialogue moveIntended meaning:If the agent receives a move pi and the

conditions C are satisfied in its KB then it generates a move Pi+1.

Page 73: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

73

ALP for negotiation Interaction Policies Examples

observed(C, tell(C,a,request(R),D,T1),T) & holds_at(have(R),T1) & holds_at(¬need(R),T1) happens(tell(a,C,accept(request(R)),D,T1),T2) & T+5>T2>T observed(C, tell(C,a,request(R),D,T1),T) & holds_at(need(R),T1) happens(tell(a,C,refuse(request(R)),D,T1),T2) & T+5>T2>T

observed(C, tell(C,a,request(R),D,T1),T) & holds_at(¬have(R),T1) happens(tell(a,C,refuse(request(R)),D,T1),T2) & T+5>T2>T

Page 74: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

74

Interaction Protocols

These policies conform to the following simple protocol

request accept

refuse

Page 75: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

75

Interaction Protocols

request refuse

accept

promise

change promise accept promise

Page 76: Fariba Sadri ICCL 08 ALP 1 Abductive Logic Programming (ALP) and its Application in Agents and Multi-agent Systems Fariba Sadri Imperial College London

Fariba Sadri ICCL 08 ALP

76

ALP for negotiation

Considerations :• Policies conforming to protocols• Characterising weak/strong

conformance• Properties of conversations induced

by policies, for example:– Termination of conversations– Success of policies in ensuring a resource

sharing solution is found if one exists