seminar@krdb 2011 - montali - runtime reasoning with the event calculus: from theory to practice

Post on 09-Jan-2017

134 Views

Category:

Presentations & Public Speaking

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Outline

�  Event Calculus

�  Reasoning �  Proactive vs reactive

�  Cached Event Calculus �  Implementation

�  Applications: monitoring of �  Business constraints

�  Commitment-based business interactions

The Event Calculus

�  First formalization: Kowalski and Sergot, 1986 �  “Simple EC”

�  Temporal reasoning in classical logic

�  Deals with atomic events

�  No frame axioms: time periods, no global state, NAF

�  Extended versions: (Kowalski and Sadri, 1995) (Shanahan, 1999) (Miller and Shanahan, 2002) �  Events with durations, continuous fluents, trajectories, …

A logic-based framework for reasoning about events and their effects

Time, Events and Traces

�  Actions executed by agents

�  The execution of an action is represented by means of events occurring at time points (atomic events)

�  The time structure is linear and has an initial state

�  The (finite) set of events occurred during an instance of the system is a narrative or execution trace

0

event

event occurrence

Fluents and States

�  Events affect the state of the system through their effects �  Making some properties true

�  Making some properties false

�  Properties change over time, and are called fluents

�  Each fluent models a “partial” system’s state

0

fluent

Some applications 1/2

�  Active databases �  (Kowalski, 1992) and (Fernandes et al., 1997)

�  Commonsense reasoning �  Book by Mueller (2006)

�  Contains also a detailed description of the EC and of a SAT-based Discrete EC Reasoner

�  Cognitive robotics �  Shanahan et al.

�  see the Cognitive Robotics I and II projects:

http://www.iis.ee.ic.ac.uk/~m.witkowski/cogrob2/

Some applications 2/2

�  Normative aspects and legal reasoning �  Open Multi-Agent Systems

�  Specification of norms and “social constraints” (Artikis et al., 2009) �  Commitment-based interactions (Yolum and Singh, 2002), (Chesani et

al, 2009)

�  Specification of the normative states of contracts (Farrell et al., 2005)

�  Service Oriented Computing �  Formalization of BPEL (Rouached et al., 2008),(Galooul et al. 2010) �  WS-Agreement requirements (Mahbub and Spanoudakis, 2007)

�  Business Process Management �  Workflow modeling (Cicekli and Cicekli, 2006)

�  Monitoring of business constraints (Montali et al, 2011)

�  Clinical guidelines and BMK (Bottrighi et al, 2011)

An example

�  When a robot moves from room X to room Y, it is no more at X and it is now at Y, provided that the battery is non empty

�  When a robot executes a move, then the battery level decreases of one unit

An example

�  When a robot moves from room X to room Y, it is no more at X and it is now at Y, provided that the battery is non empty

�  When a robot executes a move, then the battery level decreases of one unit

Event Effect Context

Proof Theory and Reasoning Facilities

EC Framework

Logic-Based Framework

Logic-based language

Event Calculus Axiomatization

EC ontology

EC Specification Execution Trace Domain dependent

Domain independent

The Simple EC Ontology

1 2 3 4 5 6 7 8 9 10 11 12 13 14

initiates(a,f,3) terminates(b,f,12)

happens(a,3)

holdsat(f,7)

declip clip

0

f MVI (3,12] for f

a b

Simple EC Ontology with MVIs

holds_at(f,t) Fluent f holds at time t. !!! f does not hold at the time it is declipped, but holds at the time it is clipped

initially(f) Fluent f begins to hold from the initial state

happens(e,t) Event e occurs at time t

initiates(e,f,t) e has the capability of initiating f at time t. If f does not already hold at t, it is declipped and will start to hold from t+1.

terminates(e,f,t) e has the capability of terminating f at time t. If f holds at t, it is clipped and will cease to hold from t+1.

mvi(f,ts,te)

(ts,te] is a maximal validity interval for f : •  f uninterruptedly holds inside (ts,te] •  f is clipped at ts •  f is declipped at te

weak EC

Common sense law of inertia

Specification of a system 1/2

� Description of the initial state of the system

�  Initiates and terminates axioms relating domain-dependent events with domain-specific fluents

� Test of holds_at predicates for context-dependent effects

� The specification is given by a set of clauses

� The definition can be omitted when true

initially(F):- definition. initiates(E,F,T):- definition.

terminates(E,F,T):- definition.

Specification of a system 1/2

�  What about the definitions?

�  We are in a FO setting à variables �  Variables are universally quantified with scope the entire close

�  initiates(a,f,T) states that a can initiate f at any time

�  The definitions of clauses are a conjunction of literals and may contain �  Other predicates taken from the EC ontology

�  holds_at predicates represent a context

�  Constructs made available by the underlying logical language à Horn fragment of FOL + NAF

An example

�  When a robot moves from room X to room Y, it is no more at X and it is now at Y, provided that the battery is non empty

�  When a robot executes a move, then the battery level decreases of one unit

�  Events: move(R,X,Y)

�  Fluents: at(R,X) blevel(R,L)

An example

�  When a robot moves from room X to room Y, it is no more at X and it is now at Y, provided that the battery is non empty

initiates(move(R,X,Y),at(Y),T):- holds_at(blevel(R,L),T), L > 0.

terminates(move(R,X,Y),at(X),T):- holds_at(blevel(R,L),T), L > 0.

An example

�  When a robot executes a move, then the battery level decreases of one unit

initiates(move(R,X,Y),blevel(R,New),T):- holds_at(blevel(R,Old),T), Old > 0, New = Old - 1.

terminates(move(R,X,Y), blevel(R,Old),T):- holds_at(blevel(R,Old),T), L > 0.

Species of Inference

�  Pierce differentiated the genus of reasoning into three species of inference �  Deductive reasoning

�  Application of a general rule to a particular case, inferring a specific result

�  Inductive reasoning �  Synthesis of a general rule starting from particular cases

and results

�  Abductive reasoning �  Synthesis of a case (explanation/case) from a general rule

and a particular result (observation)

EC Abductive Reasoning

�  Goal: generate possible execution traces (plans) that lead to a desired state of affairs, according to an EC specification

�  Example

�  Which sequence of actions leads the robot to room2, giving an initial situation where it is in room1 with battery=5 ?

events' effects[initiates/terminates]

validity of fluents[holds_at]

ECabductive reasoning

initial state[initially]

trace[happens]

EC Proactive Reasoning

�  A form of deductive reasoning

�  Given a narrative, answers queries over the validity of fluents

�  Example: giving a sequence of wall-e’s movements… ?- holds_at(blevel(wall-e,L),T), L < 5.

events' effects[initiates/terminates]

ECproactive reasoning

initial state[initially]

trace[happens]

validity of fluents[holds_at]

Axiomatization in Prolog

�  The simple EC can be simply formalized in the Horn fragment of FOL, augmented with negation as failure (Kowalski and Sergot, 1986)

�  The formalization focuses on fluents’ transitions �  it centres around intervals in which

�  A fluent switches from false to true (is declipped)

�  A fluent switches from true to false (is clipped)

Semantics of holds_at

�  Fluent F holds at time T if �  F has been declipped in the past

�  At the beginning of the execution (initially)

�  When an event occurred initiating it

�  F has not been clipped in between

holds_at(F,T):- happens(E,Ts), Ts<T, inititates(E,F,Ts), ¬clipped(Ts,F,T).

holds_at(F,T):- initially(F), ¬clipped(0,F,T). T

F

0

T Ts

F

E

Semantics of clipped

�  F is clipped inside a time interval [T1, T2) if an event occurs inside the interval and terminates F

clipped(T1,F,T2):- happens(E,T), T ≥ T1, T < T2,

terminates(E,F,T).

Reasoning with Prolog

�  Given �  An EC specification (KBdom)

�  The axiomatization of holds_at and clipped (KBEC)

�  An execution trace (T)

�  A query Q

�  Verifying whether T leads to Q corresponds to check whether

KBdom ∪KBEC ∪T satisfies Q �  Which in turn can be verified by means of a Prolog SLDNF

derivation

�  Prolog performs backward, proactive reasoning starting from Q

Example

�  KBdom: initially(f). terminates(a,f,T). initiates(b,f,T).

�  T: happens(a,2). happens(b,6). �  Q: ?-holds_at(f,8) YES!

1 2 3 4 5 6 7 8 0

f

a b

Example – SLDNF derivation

holds_at(f,8)

initially(f) /\ ¬clipped(0,f,8)

¬clipped(0,f,8)

clipped(0,f,8)

happens(E,T) /\ T≥0 /\ T<8 /\ terminates(E,f,T)

2≥0 /\ 2<8 /\ terminates(a,f,2)

terminates(a,f,2)

happens(E,T) /\ T<8 ¬clipped(T,f,8)

… E/a,T/2

false

true

2<8 ¬clipped(2,f,8)

clipped(0,f,8)

happens(E,T) /\ T≥2 /\ T<8 /\ terminates(E,f,T)

2≥0 /\ 2<8 /\ terminates(a,f,2)

terminates(a,f,2)

… E/a,T/2

false

true

E/a,T/2

E/b,T/6

clipped(0,f,8)

happens(E,T) /\ T≥6 /\ T<8 /\ terminates(E,f,T)

2≥6 /\ …

E/a,T/2

true

false

6<8 ¬clipped(6,f,8)

E/b,T/6

6≥6 /\ 6<8 /\ terminates(b,f,6)

terminates(b,f,6)

false

EC Reactive Reasoning

�  Dynamically growing trace à narrative updates

�  Interest in showing the evolution of all fluents à ?- “extract all the maximal validity intervals of fluents”

events' effects[initiates/terminates]

ECreactive

reasoning

initial state[initially]

partial trace[happens]

evolution of fluents[holds_at]

Ongoing/Future Work

�  Integration between procedural and declarative knowledge in the clinical setting

Is Proactive Reactive?

�  Chittaro and Montanari [1994]: No!

�  Narrative update is constant, but the query must be executed from scratch

�  No possibility of reusing the previously inferred results

�  Idea: Cached Event Calculus

Cached Event Calculus Chittaro and Montanari, 1995

�  Caches the current result for future use

�  Extends/revises it as new events are acquired �  Complexity moved from the query to the narrative update

�  What is cached? The Maximal Validity Intervals (MVIs) �  Reasoning shifts from transitions to levels of fluents

�  (Simple) query complexity: linear in the size of the cached MVIs

holds_at(F,T):- mvi(F,T1,T2), gt(T,T1), le(T,T2).

Axiomatizations

�  Cached Event Calculus (Prolog) [Chittaro and Montanari, 1995] �  Prolog-based, with assert/retract

�  Reactive Event Calculus (SCIFF) �  [Chesani et al, 2010] Based on an ALP framework

�  Declarative semantics à formal properties

�  Reactive Event Calculus (Prolog): light-weight CEC �  Embedded in JAVA à jREC

�  Naïve management of out-of-order events �  “Roll-back and re-execute”

REC - Idea

�  A new event occurrence is acquired: happens(e,t)

�  Hp: t is greater than the events occurred so far �  If not, roll-back + replay

�  Steps 1.  Assert happens(e,t)

2.  Extract all the effects caused by e at time t declip(F,T):-

happens(E,T), initiates(E,F,T), \+ holds_at(F,T).

clip(F,T):-

happens(E,T), terminates(E,F,T), holds_at(F,T).

REC - Idea

3.  For each fluent f to be declipped a)  Assert MVI for f (t,inf]

4.  For each fluent f to be clipped

a)  Retract MVI for f (ts,inf]

b)  Assert MVI for f (ts,t]

t e

f t e

f

t e

f t e

f

jREC

jREC

TuProlog

l-CEC

model Set model

Evaluate trace

U

Reset

events' effects[initiates/terminates]

ECreactive

reasoning

initial state[initially]

partial trace[happens]

evolution of fluents[holds_at]

EC in the BPM Setting

Action Activity

Event Event in the activity lifecycle (start, complete, …)

System instance Case

Initial state Beginning of the case

Event occurrence Audit trail entry

Narrative Execution trace

Fluent Property characterizing an aspect of the case

Operational Decision Support with Wil van der Aalst, Fabrizio Maggi, Federico Chesani, Paola Mello

�  Runtime support to running processes �  Check

�  Predict

�  Recommend

PAIS OSService

... ...event log business

constraintsprocessmodels

request

response

Monitoring Business Constraints

�  Runtime compliance checking of business constraints, reporting their status as events occur

�  Desiderata

�  Expressive constraints with metric temporal constraints,

data, data-aware conditions

�  The system cannot be controlled à continuous support

�  System health metrics à catch and count violations

ConDec++

�  Study of all the ConDec [Pesic and van der Aalst, 2006] constraints extended with metric time constraints

�  Extension with non-atomic activities and data

�  Example: The respondent bank must always be added to the black list in case its due diligence evaluation fails

ResultBank

Result = failedadd to.Bank = diligence.Bank,

diligence evaluation

add to black list

Bank

add to.O = diligence.O

Formalization in the EC

�  Formalization of the activity lifecycle

�  Notion of constraint instance �  At each time, a constraint instance can be pending, satisfied

or violated �  Transitions determined by the occurrence of events �  Example

�  Complete evaluation with result = failure generates a new pending instance of the constraint

�  The instance becomes satisfied if the same responsible successfully adds the involved bank to the black list

�  The instance becomes violated if the case is completed and it is still pending

activeinitialcompleted

canceledts (start)

tc (complete)

tx (cancel)

Monitoring Outcome

ResultBank

Result = failedadd to.Bank = diligence.Bank,

diligence evaluation

add to black list

Bank

add to.O = diligence.O

MoBuCon ProM implementation

Commitments and Interactions with Federico Chesani, Paola Mello, Paolo Torroni

�  Social Commitments [Castelfranchi, 1995], [Singh, 1998] for modeling interaction in open systems �  MAS, SOA, Business interactions, …

�  Open systems à interacting entities are �  Heterogeneous �  Autonomous

�  Interaction: focus on commitments established by agents �  not by fixing specific courses of interaction in advance

�  C(x,y,p) à debtor agent (x) committed towards a creditor agent (y) to bring about some desired property (p)

Commitment Life Cycle

�  Agents perform actions, traced by means of events

�  Event occurrences �  Have effects (initiate/terminate fluents) �  (in)directly trigger operations on commitments

�  Each operation results in a commitment state change

�  States of all commitments: normative state of the interaction

�  When a customer c pays seller s for an order, s becomes committed to deliver that order (make the order delivered) à payment creates C(s,c,orderDelivered)

Simplified Life Cycle

active

violated

satisfied

create

C(s,c,orderDelivered)

pay(c,s) sendByAirMail(s,c)

orderDelivered

Monitoring Commitments

�  Model business contracts and protocols by means of commitments �  Timed extensions to deal with deadlines and properties

that must be maintained true

�  Use the EC formalization of the commitment life cycle �  Extension of [Singh and Yolum, 2000]

�  Track the normative state of contract by monitoring a running interaction with jREC

�  Demo!

Conclusion

�  EC is an expressive and computational framework for reason about event-based systems

�  Monitoring with the EC requires suitable reactive reasoners �  jREC is a practical solution to tackle this issue

�  Applications in the BPM context �  Monitoring Business Constraints �  Tracking Commitment-Based Interactions

Ongoing/Future Work

�  Integration between declarative and procedural knowledge in clinical guidelines

�  Experimental assessment: first experiments encouraging

�  Complexity investigation �  Starting from Chittaro and Montanari’s work �  Focusing on specific classes of EC programs

�  New application in the context of artifact-centric business processes �  Formalization of the GSM paradigm?

top related