Upload
wyoming-snider
View
36
Download
6
Embed Size (px)
DESCRIPTION
An Event-Condition-Action Logic Programming Language. J. J. Alferes F. Banti A. Brogi. Overview. Event Condition Action (ECA) languages. Updates of (ECA) rules. Dynamic Logic Programs (DyLPs). Evolving Reactive Algebraic (ERA) Programs. Syntax Semantics Example of usage. - PowerPoint PPT Presentation
Citation preview
1
An Event-An Event-Condition-Action Condition-Action
Logic Logic Programming Programming
LanguageLanguageJ. J. Alferes F. Banti A. BrogiJ. J. Alferes F. Banti A. Brogi
2
OverviewOverview Event Condition Action (ECA) languages.Event Condition Action (ECA) languages. Updates of (ECA) rules. Updates of (ECA) rules. Dynamic Logic Programs (DyLPs).Dynamic Logic Programs (DyLPs). Evolving Reactive Algebraic (ERA) Evolving Reactive Algebraic (ERA)
Programs.Programs. SyntaxSyntax SemanticsSemantics
Example of usage.Example of usage. Parallel with DALI.Parallel with DALI. Future works.Future works.
3
Event Condition Action Event Condition Action languageslanguages
Fundamental construct: ECA rulesFundamental construct: ECA rules
OnOn Event Event ifif Condition Condition dodo ActionAction When an Event occurs, under some When an Event occurs, under some
Conditions, execute a given Action.Conditions, execute a given Action.
ExampleExample
OnOn callE(Call,Emp) callE(Call,Emp) ifif office(Emp, N) office(Emp, N) dodo forw(Call,N).forw(Call,N). Events and Actions can be simple or Events and Actions can be simple or complexcomplex,,
resulting from the combination of basic resulting from the combination of basic ones.ones.
4
Updates of ECA rules.Updates of ECA rules. Problem:Problem:
How to update the behaviour of an ECA System?How to update the behaviour of an ECA System? Example:Example:
Suppose that, whenever an employer is in a Suppose that, whenever an employer is in a working meeting, the phone call must not be working meeting, the phone call must not be forwarded to him.forwarded to him.
Solution:Solution: To allow the system to assert new rules and To allow the system to assert new rules and
to encode exceptions to existing ECA rules.to encode exceptions to existing ECA rules. Inhibition rulesInhibition rules: Rules that specifies when actions : Rules that specifies when actions
are not executed. are not executed. Example:Example:
WhenWhen callE(Call,Emp), meeting(Emp,) callE(Call,Emp), meeting(Emp,) do do not not forw(Call,N).forw(Call,N).
5
Logic Programs UpdatesLogic Programs Updates
We consider sequences P1, ... , Pn (We consider sequences P1, ... , Pn (Pi) of LPs ) of LPs called Dynamic Logic Programs (DLPs)called Dynamic Logic Programs (DLPs) P1 is the is the initial programinitial program, while the others , while the others Pis are s are updates updates
Basic language: generalized logic programsBasic language: generalized logic programs The head of a rule can be either a positive or negative The head of a rule can be either a positive or negative
literal.literal. Common ideas: Common ideas:
Stable model approach Stable model approach Causal rejection principle: Causal rejection principle: A rule is rejected iff there is a
more recent rule whose body is satisfied and is in conflict with the old one. (i.e. the two rules has complementary (i.e. the two rules has complementary heads).heads).
6
Syntax of ERASyntax of ERA
ECA rules: ECA rules: OnOn Event Event ifif Condition Condition dodo Action Action Data and inference rules: L. LData and inference rules: L. L00 ← L1, …Ln. Every Li is an atom or the negation of an atom.Every Li is an atom or the negation of an atom. Inhibition rules: Inhibition rules: WhenWhen B B dodo not Action. not Action.
B is a conjunction of literals and events.B is a conjunction of literals and events. Event is a literal representing a simple or complex Event is a literal representing a simple or complex
event.event. Complex event are obtained by an algebra of operators.Complex event are obtained by an algebra of operators.
Condition is a conjunction of literals.Condition is a conjunction of literals. Action is an atom representing a simple or complex Action is an atom representing a simple or complex
action.action. Complex actions are obtained by an algebra of operators.Complex actions are obtained by an algebra of operators.
7
Syntax of ERASyntax of ERA
Syntax of events:Syntax of events:
e::= ee::= ebb |e |e11 ٧٧ ee22| e| e11 ٨٨ ee22| A(e| A(e11, e, e22,e,e33)| e)| edefdef.. Syntax of basic and complex actions:Syntax of basic and complex actions:
aabb::= a::= axx| raise(e| raise(ebb)| assert(r)| retract(r)| define(d). )| assert(r)| retract(r)| define(d).
a::= aa::= abb| a| a11 ►► a a22 | a | a11||a||a22 | IF(C, a | IF(C, a11, a, a22) | a) | adefdef.. Event and action definitions:Event and action definitions:
eedefdef is e. is e.
aadefdef is a. is a.
8
Semantics of ERASemantics of ERA Events are atoms occurring in LP Ei called input Events are atoms occurring in LP Ei called input
programs and represent external inputs and internal programs and represent external inputs and internal events.events.
Inference system based on the refined semantics of Inference system based on the refined semantics of DyLPs. DyLPs.
If an atom “Action” corresponding to an action is If an atom “Action” corresponding to an action is inferred, the corresponding action is executed.inferred, the corresponding action is executed.
Replace Replace OnOn Event Event ifif Condition Condition dodo Action Action with: with:
ActionAction ← Condition, Event. Replace Replace WhenWhen B B dodo not Action with: not Action with: not not ActionAction ← B. Replace eReplace edefdef is e is e andand aadefdef is a with: is a with:
aadefdef ← e and eedefdef ← e..
9
Semantics of ERA(cont.)Semantics of ERA(cont.)
Add inference rules for deriving literals: Add inference rules for deriving literals:
ee11 ٧٧ ee22 ← e e11. e. e11٧٧ ee22 ← e e22.. ee11 ٨٨ ee22 ← e e11 ,,ee22.. The semantics of actions is given by a The semantics of actions is given by a
transition system describing step by step how transition system describing step by step how the execution of an action affects a program.the execution of an action affects a program.
The execution of a complex action may The execution of a complex action may require several steps formed by basic actions.require several steps formed by basic actions.
< < P, E, Epp, E, Eii.E.EFF> → > → GG < <P’, E, Epp’’..E..Eii, E, EFF
’’>>
10
ExampleExampleOnOn callE(Call,Emp) callE(Call,Emp) ifif office(Emp, N) office(Emp, N) dodo forw(Call,N). forw(Call,N).
assert(r)assert(r)
r : Whenr : When callE(Call,emp), meeting(emp) callE(Call,emp), meeting(emp) do do not forw(Call,N).not forw(Call,N).
New behaviour: every call to emp is New behaviour: every call to emp is forwarded to his mobile phone.forwarded to his mobile phone.
assert(r1) assert(r1) ►► assert(r2). assert(r2). r1: r1: WhenWhen callE(Call, emp) callE(Call, emp) dodo not forw(Call, N). not forw(Call, N).r2 : r2 : OnOn callE(Call,emp), mobile(emp,m) callE(Call,emp), mobile(emp,m) dodo forw(Call,m). forw(Call,m).
Return to previous behaviour: retract(r1) Return to previous behaviour: retract(r1) ►► retract(r2).retract(r2).
11
Related work: DALIRelated work: DALI
E:> Cond, A1, A2,…,An. E:> Cond, A1, A2,…,An.
Dali is a LP-like language for Dali is a LP-like language for programming agents. programming agents.
A1:> Cond, A3, A4, ... A1:> Cond, A3, A4, ... A1:> A5, A6,…. A1:> A5, A6,…. It is possible to define complex It is possible to define complex actions.actions.
E is always a basic event, no event E is always a basic event, no event algebra.algebra.
It is not possible to update rules.It is not possible to update rules.
Unlike ERA, DALI is implemented. Unlike ERA, DALI is implemented.
12
Future worksFuture works Transaction ERA.Transaction ERA.
To provide the possibility to execute To provide the possibility to execute actions as transactions.actions as transactions.
Local transactions are Local transactions are ACIDACID..
Transactions involving external Transactions involving external iterations relays on iterations relays on compensationcompensation..
Possibility to use ACID sub-Possibility to use ACID sub-transactions and compensation in the transactions and compensation in the same transaction. same transaction.
13
Thanks!Thanks!
14
Future worksFuture works A A dynamic ruledynamic rule is of the form is of the form effect(F effect(F ← Body) Body) ← Cond.Cond.
It means: if Cond is true in this state, then F It means: if Cond is true in this state, then F ← Body Body is a rule in the next state (and only in that one). is a rule in the next state (and only in that one).
Cond are conjunctions of fluent or action literals.Cond are conjunctions of fluent or action literals.
effect(F effect(F ← Body) Body) ← CondCond is a macro for: is a macro for: F ← Body, event(F ← Body). assert(event(F ← Cond). ) ← Cond.assert( not event(F ← Cond). ) ← event(F ← Cond) , not assert(event(F ← Cond)).
An An inertial declarationinertial declaration is of the form is of the form inertial(I)inertial(I) ,where I is a set of fluents which ,where I is a set of fluents which means: all the fluents in I are inertial, i.e. means: all the fluents in I are inertial, i.e. their truth value is preserved from one state their truth value is preserved from one state to the next one unless changed by the effect to the next one unless changed by the effect of an action.of an action.
Inertial(I)Inertial(I) is a macro for: is a macro for:
assert(prev(F)) assert(prev(F)) ← F. F. assert(not prev(F)) assert(not prev(F)) ← not F. not F.
15
Example: The Yale Example: The Yale shooting problem shooting problem
There is a single-shot gun which is initially There is a single-shot gun which is initially unloaded, and some turkeys.unloaded, and some turkeys. We can load the gun and shoot to one of the We can load the gun and shoot to one of the
turkeys. If we shoot, there is a bang, the gun turkeys. If we shoot, there is a bang, the gun becomes unloaded, we can hit the turkey or miss becomes unloaded, we can hit the turkey or miss it, if we hit a turkey it dies.it, if we hit a turkey it dies.
A turkey moves iff it is alive.A turkey moves iff it is alive.I: initialize{loaded, moving(X),dead(X) missed(X), hit(X)}
D: effect(loaded.) ← load. inertial (loaded) effect(not loaded.) ← shoot(X). inertial (dead(X)) effect (bang.) ← shoot(X). moving(X) ← not dead(X).
effect(hit(X) ← not missed(X) ) ← shoot(X). dead(X) ←hit(X). effect (missed(X) ← not hit(X) ) ← shoot(X).
16
Comparisons with other Comparisons with other worksworks
We compared EAPs with the existing We compared EAPs with the existing action description languages action description languages AA , , B B and the (definite fragment of) and the (definite fragment of) C .C .
For every language we find a For every language we find a linearlinear and modular and modular translationtranslation into EAPs: into EAPs:
Hence EAPs are Hence EAPs are at least as at least as expressiveexpressive as the considered as the considered languages.languages.
17
Describing changes Describing changes In practical situations, it may happen that the very In practical situations, it may happen that the very
rules of the domain change with timerules of the domain change with time EAPs are of Evolp programs. So, they can be EAPs are of Evolp programs. So, they can be
updated by external events.updated by external events. It is possible to update static rules and the It is possible to update static rules and the
descriptions of the effects of an action.descriptions of the effects of an action. We consider again the Yale shooting problem.We consider again the Yale shooting problem. Let us now consider that after some shots, we Let us now consider that after some shots, we
acquire rubber bullets. We can now either load the acquire rubber bullets. We can now either load the gun with normal bullets or with a rubber bullet, if gun with normal bullets or with a rubber bullet, if we shoot with a rubber loaded gun, we never kill a we shoot with a rubber loaded gun, we never kill a turkey.turkey.
E1: assert(initialize (rubber_loaded))D1: effect (not dead(X) ← hit(X)) ← rubber _loaded. effect (not rubber _loaded) ← shoot(X).
E2: assert(D1)Inertial(rubber_loaded)
18
Describing changes Describing changes (cont.)(cont.)
We use a new macro construct We use a new macro construct not effect(r) not effect(r) to prevent the to prevent the effects of an actions under some conditionseffects of an actions under some conditions
Suppose the cylinder of the gun becomes dirty and, Suppose the cylinder of the gun becomes dirty and, whenever one shoots, the gun may either work properly or whenever one shoots, the gun may either work properly or fail.fail.
If it fails the shoot action has no real effectIf it fails the shoot action has no real effect..
E1: assert(initialize{ fails, work}) D2: effect (fails ← not work.) ← shoot(X). effect (work ← not fails.) ← shoot(X). effect (loaded ← fails.) ← loaded. effect(rubber_loaded ← fails) ← rubber_ loaded.
effect(loaded←fails)← loaded.
E2: assert(D2) not bang ← fails. not missed(X) ← fails. not hit(X) ← fails.
19
ConclusionsConclusions
Starting for the language for LP updates Starting for the language for LP updates Evolp,Evolp, we have defined the new action description we have defined the new action description language language EAPs.EAPs.
We have shown how to use EAPs by an We have shown how to use EAPs by an example.example.
We have compared EAPs with existing work by We have compared EAPs with existing work by showing showing translations oftranslations of action languages action languages AA , , BB and and CC into EAPsinto EAPs..
We have shown peculiar capabilities of EAPs to We have shown peculiar capabilities of EAPs to handle handle changes in the ruleschanges in the rules of the considered of the considered domain and provided an example of such domain and provided an example of such usage.usage.