Successfully reported this slideshow.
Upcoming SlideShare
×

# KELPS LPS - A Logic-Based Framework for Reactive System30 aug 2012

1,048 views

Published on

Programming with Logic without Logic Programming

Published in: Technology, Spiritual
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

### KELPS LPS - A Logic-Based Framework for Reactive System30 aug 2012

1. 1. A Logic-Based Framework for Reactive Systems or Programming with Logic without Logic Programming Robert Kowalski and Fariba Sadri Department of Computing Imperial College London
2. 2. Ambition:to unify • Programming • Databases • AI knowledge representation and problem-solving
3. 3. Outline• KELPS - a simplified kernel for reactive logic-based production-style systems• KELPS model-theoretic semantics• KELPS operational semantics• LPS = KELPS + LP• MALPS = Multi Agent LPS (The Dining Philosophers)• Related work (MetateM, Transaction Logic)• Conclusions
4. 4. KELPSPrograms are reactive rules with explicit timein the logical form: antecedent(X) consequent(X, Y)i.e. X [antecedent(X) Y consequent(X, Y)]whenever the antecedent is true in the past or present,then the consequent is true in the future.
5. 5. KELPS rules =Composite events + rules + composite actions pre-sensor detects possible fire in area A at time T1 ∧ smoke detector detects smoke in area A at time T2 ∧ |T1 – T2 | 60 sec ∧ max(T1, T2, T) activate local fire suppression in area A at time T3 ∧ T <T3 T + 10 sec ∧ fire in area A at time T4 ∧ T3 <T4 T3 + 30 sec ∧ send security guard to area A at time T5 ∧ T4 <T5 T4 + 10 sec∨ call fire department to area A at time T3‘∧ T <T3‘ T + 60 sec
6. 6. Syntax of reactive rules antecedent1 (X) ∧… ∧ antecedentn (X) consequent11 (X, Y) ∧… ∧ consequent1l1 (X, Y) ∨ … ∨ consequentm1 (X, Y) ∧… ∧ consequentmlm (X, Y)Each antecedenti (X) and consequenti j(X, Y) isa condition, event atom or temporal constraint:A condition is an FOL formula in the vocabulary of state predicates.An event atom is an atomic formula representing an event.An action atom is an event atom in which the event is an action.A temporal constraint has the form time1 < time2 or time1 ≤ time2,where at least one of time1 and time2 is a variable.
7. 7. Comparison with MetateM (Michael Fisher et al)Programs = reactive rules in modal temporal logic: ‘past and present formula’ implies ‘present or future formula’Computation = model generation.Model = possible worlds connected by an accessibility relation.States updated by frame axioms.
8. 8. Comparison with Transaction Logic (Bonner and Kifer) Programs = sequences of FOL queries and database updates. Computation = model generation. Model = possible worlds. Truth values relative to paths between possible worlds. States (databases) updated destructively.
9. 9. Reactive rules are like: integrity constraints condition-action rules event-condition-action rules “plans” in BDI agents.Reactive rules generate states using destructive updates.States are model-theoretic structures represented assets of atomic sentences (also called facts or fluents), like: program variables relational databases Herbrand models representations of the real world.The computational task is to generate a model in which all of thereactive rules are true.
10. 10. Operational Semantics: States are updated destructively.Model-theoretic semantics: Facts are time-stamped. ei Si Si+1 old-fact new-fact fact1 fact1 fact2 fact2 … … factn factn ti ti ti+1 = ti +εi
11. 11. Other semantics can be dealt with similarly ei Si Si+1 old-fact new-fact fact1 fact1 fact2 fact2 … … factn factn ti ti ti+1
12. 12. LPS = KELPS + LP Dialogue/parsing exampleReactive rule:sentence(T1, T2) sentence (T3, T4) T3 < T2 < T3 + 10Basic (or atomic events):word(my, 1, 2) word(name, 2, 3) word(is, 3, 4) word(bob, 4, 5)Composite events (or actions) represented by logic programs:adjective(T1, T2) word(my, T1, T2)adjective(T1, T2) word(your, T1, T2)noun(T1, T2) word(name, T1, T2) verb(T1, T2) word(is, T1, T2)noun(T1, T2) word(bob, T1, T2) noun(T1, T2) word(what, T1, T2)sentence(T1, T3) noun-phrase(T1, T2) verb-phrase(T2, T3)noun-phrase(T1, T3) adjective(T1, T2) noun(T2, T3)noun-phrase(T1, T2) noun(T1, T2)verb-phrase(T1, T3) verb(T1, T2) noun-phrase(T2, T3)verb-phrase(T1, T2) verb(T1, T2)
13. 13. Example: teleo-reactive programLet be a small number.methane-level(M, T) critical M alarm(T’) T < T’ T +methane-level(M, T) critical > M water-level(W, T) high < W pump(T’) T < T’ T +methane-level (M, T) critical > M water-level(W, T)low < W pump-active(T) pump(T’) T < T’ T +
14. 14. Non-modal time-free syntaxmethane-level(M) critical M : alarmmethane-level(M) critical > M water-level(W) high < W : pumpmethane-level (M) critical > M water-level(W)low < W pump-active : pump
15. 15. Model-theoretic Semantics: Facts are represented with time parameters. All states and events are combined into a single model.methane-level(M, T) critical M alarm(T’) T < T’ T +
16. 16. Outline• KELPS - a simplified KErnel for reactive Logic-based Production-style Systems• KELPS model-theoretic semantics• KELPS operational semantics• LPS = KELPS + LP• MALPS = Multi Agent LPS (The Dining Philosophers)• Related work (MetateM, Transaction Logic)• Conclusions
17. 17. KELPS model-theoretic semanticsGiven reactive rules R0, initial state S0, set of ground atomsAux defining auxiliary predicates, andsequence of sets of external events ex1,…, exi,….the computational task is to generate sets of actions a1,…, ai,…. such thatR0 is true in the Herbrand model: M = Aux S0* e1* S1* e2* … ei* Si* ei+1*…. ei = exi ai ei* = {happens(e, ti) | e ei at time ti} Si+1 = ( Si – {p | terminates(p, ei, ti) is true in Si} ) initiates and {p | initiates(p, ei, ti) is true in Si} terminates are defined by a Si* = {holds(p, ti) | p Si at time ti} “domain theory” D
18. 18. KELPS model-theoretic semanticsThe computational task is to generate sets of actions a1,…, ai,…. suchthat R0 is true in the Herbrand model: M = Aux S0* e1* S1* e2* … ei* Si* ei+1* ….Here R0 can be generalised to arbitrary sentences(or integrity constraints) of FOL.The operational semantics becomes more difficult.Frame axioms of the situation calculus (or event calculus) areemergent properties that are true in M.
19. 19. KELPS model-theoretic semanticsDefinition: ETholds holds(P, T) happens(E, T) initiates(E, P, T) holds(P, T2) holds(P, T1) happens(E, T2) next(T1, T2) ¬ terminates(E, P, T2)Theorem. The Herbrand model: Aux S0* e1* S1* e2* … ei* Si* ei+1*….Is contained in the weakly perfect modelof the weakly stratified logic program: ETholds D Aux S0* e1* e2* … ei* ei+1*….where D defines initiates, terminates, possible and next.
20. 20. Outline• KELPS - a simplified KErnel for reactive Logic-based Production-style Systems• KELPS model-theoretic semantics• KELPS operational semantics• LPS = KELPS + LP• MALPS = Multi Agent LPS (The Dining Philosophers)• Related work (MetateM, Transaction Logic)• Conclusions
21. 21. KELPS operational semantics is anobserve–decide–think –act cycle.The i-th cycle starts with state Si-1, goal state Gi,rules Ri and events ei at time ti .Logically, Gi is a conjunction of disjunctions of conjunctions.Each disjunction has the syntax of the consequents of reactive rules.Operationally, each conjunct is a separate thread.Each disjunct is an alternative partially executed conditional plan.
22. 22. KELPS operational semanticsStep 0. Observe. Use ei to transform state Si-1 into state Si.Step 1. Think. If earlier-antecedents(X) later-antecedents(X) consequent(X, Y)is in Ri and earlier-antecedents(x) is true in Aux ei* Si*,then simplify any temporal constraints in later-antecedents(x) consequent(x, Y)and add the result to Ri to obtain Ri+1.If later-antecedents(x) is empty, then add the result to Gi as a new thread.Step 2.1. Decide. Choose a set D of disjuncts from one or more threads in Gi.Step 2.2. Think. For every disjunct in D, choose a formearlier-consequents(Y) later-consequents(Y).If earlier-consequents(y) is true in Aux ei* Si*, thensimplify any temporal constraints in later-consequents(y)and add the result as an new disjunct to the same thread in D to obtain Gi+1.Step 2.3. Act. For every disjunct in D of a formactions(Z) other-consequents(Z), choose such a form,attempt to execute actions(Z) andadd any successfully executed instances actions(z) to ei+1.
23. 23. The operational semantics is sound with respect tothe model-theoretic semantics.Theorem 1. Soundness. Given a program R0 with domaintheory D , an initial state S0, goal state G0, and a sequence of setsof external events ex1,…, exn,…., suppose the OS generates apossibly infinite sequence: S0, R0, G0 , a1, … ,Si, Ri, Gi, ai+1, …. Let M be the perfect model of:D S0* e1* …. Si* ei+1* …..where ei = exi ai . Then R0 G0 is true in M if for every top-level goal G added to a goal state Gi as a new thread, there existsa goal state Gj such that i ≤ j and the empty disjunct (equivalentto true) is added a disjunct to the same thread as G in Gj.
24. 24. IncompletenessThe operational semantics is incomplete.It cannot preventively make a rule true by making itsantecedents false: attacks(X, me, T1) ¬ prepared-for-attack(me, T1) surrender(me, T2) T1 < T2 T1 +It cannot proactively make a reactive rule true by making itsconsequents true before its antecedents become true: enter-bus(me, T1) have-ticket(me, T2) T1 < T2 T1 +
25. 25. Outline• KELPS - a simplified KErnel for reactive Logic-based Production-style Systems• KELPS model-theoretic semantics• KELPS operational semantics• LPS = KELPS + LP• MALPS = Multi Agent LPS (The Dining Philosophers)• Related work (MetateM, Transaction Logic)• Conclusions
26. 26. LPS = KELPS + LP model-theoretic semanticsLet LP be a locally stratified logic program defining the auxiliarypredicates . LP = Ltimeless Lint Levent D. Ltimeless defines time-independent predicates. Lint defines intentional predicates. Lint defines composite events. D defines the domain theory. (Events initiate and terminate only extensional predicates.)The computational task is to generate actions a1,…, ai,…. such thatR0 is true in the perfect model of: LP S0* e1* S1* e2* … ei* Si* ei+1* ….
27. 27. Outline• KELPS - a simplified KErnel for reactive Logic-based Production-style Systems• KELPS model-theoretic semantics• KELPS operational semantics• LPS = KELPS + LP• MALPS = Multi Agent LPS (The Dining Philosophers)• Related work (MetateM, Transaction Logic)• Conclusions
28. 28. The Dining Philosophers