Your SlideShare is downloading. ×
KELPS LPS - A Logic-Based Framework for Reactive System30 aug 2012
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

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

318
views

Published on

Programming with Logic without Logic Programming

Programming with Logic without Logic Programming

Published in: Technology, Spiritual

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
318
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 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. Ambition:to unify • Programming • Databases • AI knowledge representation and problem-solving
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. The Dining Philosophers
  • 29. The Dining Philosophers – solution in MALPS(multi-agent LPS)The initial state S0:available(fork0)available(fork1)available(fork2)available(fork3)available(fork4)Aux/Ltimelessadjacent(fork0, philosopher(0), fork1)adjacent(fork1, philosopher(1), fork2)adjacent(fork2, philosopher(2), fork3)adjacent(fork3, philosopher(3), fork4)adjacent(fork4, philosopher(4), fork0)
  • 30. Actions are defined by a domain specific event theoryD, specifying preconditions and the fluents that areinitiated and terminated. think(philosopher(I)) initiates thinking(philosopher(I)). eat(philosopher(I)) initiates eating(philosopher(I)) terminates thinking(philosopher(I)). pickup-forks(philosopher(I)) terminates available(F1) and available(F2) preconditions available(F1), available(F2) where adjacent(F1, philosopher(I), F2). putdown-forks(philosopher(I)) terminates eating(philosopher(I)) initiates available(F1), available(F2) where adjacent(F1, philosopher(I), F2) .
  • 31. The Dining Philosophers – with time-free syntax and auxiliary logic programtime-to-eat(philosopher(I)) dine(philosopher(I))dine(philosopher(I)) think(philosopher(I)), pickup-forks(philosopher(I)), eat(philosopher(I)), putdown-forks(philosopher(I)).
  • 32. 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
  • 33. Comparison with MetateM (Michael Fisher et al)Programs = reactive rules in modal temporal logic: ‘past and present formula’ implies ‘present or future formula’Computation = generate model of the reactive rules.Model = possible worlds connected by an accessibility relation.States updated by frame axioms.Interaction by message passing.
  • 34. Comparison with Transaction Logic (Bonner and Kifer) Programs = complex actions (and transactions) = sequences of FOL queries and actions. Computation = generate model of complex actions. Model = possible worlds. Truth values relative to paths in a collection of possible worlds. Reactive rule is true if, for every path over which the antecedents are true, there exists a later path over which the consequents are true. States updated destructively. Interaction via a global state.
  • 35. LPS: alternative external notationsTransaction Logic:P Q means P(T1) Q(T2) T1 < T2 or P(T1 , T2) Q(T3, T4) T2 < T3Modal temporal logic:P ◊Q means P(T1) Q(T2) T1 < T2.P Q means P(T) Q(T+1) or P(T1) Q(T2) T1 <T2 T1+ εGraphical notation: P R Qmeans P(T1) Q(T2) R(T3) T1 < T3 T2 < T39/6/2012 35
  • 36. Conclusions• KELPS simplifies LPS, by eliminating logic programming. It extends LPS, by including a form of composite events.• The operational semantics is based on destructive updates.• The model-theoretic semantics of KELPS is inspired by the minimal model semantics of logic programming.• The model-theory and operational semantics can be extended to deal with other “integrity constraints”.• KELPS gives a declarative semantics to imperative computing.• KELPS puts logic programming in its place.