Modeling and Reasoning in Event Calculus Using Goal-Directed - - PowerPoint PPT Presentation

modeling and reasoning in event calculus using goal
SMART_READER_LITE
LIVE PREVIEW

Modeling and Reasoning in Event Calculus Using Goal-Directed - - PowerPoint PPT Presentation

Sept, 2019 [PROLE-2019] Modeling and Reasoning in Event Calculus Using Goal-Directed Constraint Answer Set Programming J. Arias 1 , 2 M. Carro 1 , 2 Z. Chen 3 G. Gupta 3 1 IMDEA Software Institute, 2 Universidad Polit ecnica de Madrid 3


slide-1
SLIDE 1

Modeling and Reasoning in Event Calculus Using Goal-Directed Constraint Answer Set Programming

Sept, 2019 [PROLE-2019]

  • J. Arias1,2
  • M. Carro1,2
  • Z. Chen3
  • G. Gupta3

1IMDEA Software Institute, 2Universidad Polit´

ecnica de Madrid 3University of Texas at Dallas

madrid institute for advanced studies in software development technologies

slide-2
SLIDE 2

1 / 11

www.software.imdea.org

Motivation

  • Commonsense Reasoning (CR) requires the ability to model

continuous characteristics of the world.

  • Event Calculus (EC) is a formalism that represent continuous

change and capture the law of inertia.

  • Answer Set Programming (ASP) is a logic programming

paradigm and has been used to model the Event Calculus. However,...

  • classical implementations of ASP are limited to variables

ranging over discrete and bound domains.

  • and other proposals such as ASPMT [Lee and Meng 2013] and

PDDL+ [Fox and Long 2002; Balduccini et al. 2016] have not been applied to modeling the event calculus. Example: Turning a light switch on and off.

madrid institute for advanced studies in software development technologies

slide-3
SLIDE 3

2 / 11

www.software.imdea.org

Our Proposal

Based on s(CASP) [Arias et al. 2018] achieves more conciseness and expressiveness than other approaches because dense domains can be faithfully modeled as continuous quantities. trajectory(light_on, T1, light_red, T2) :- T2 #>= T1, T2 #< T1+2.

  • The s(CASP) system is an implementation of Constraint

Answer Set Programming over first order predicates:

  • It combines ASP and constraints.
  • It features predicates, constraints among non-ground variables

and uninterpreted functions.

  • It has a top-down, query-driven execution strategy.

Example:

#include '../bec_theory'. initiates(turn_on,light_on,T). terminates(turn_off,light_on,T). initiallyN(light_on). happens(turn_on, 1/2). happens(turn_off, 4). happens(turn_on, 6). ?- holds(light_on, 2). madrid institute for advanced studies in software development technologies

slide-4
SLIDE 4

3 / 11

www.software.imdea.org

Background

  • s(ASP) [Marple et al. 2017] is a top-down, goal-driven ASP

system that can evaluate ASP programs with function symbols without grounding them.

  • s(CASP) [Arias et al. 2018] adds constraints, to s(ASP).
  • The constraints relate variables.
  • They are kept and used during execution and in answers.
  • A s(CASP) program is a set of clauses:

a:- ca,b1,...,bm,not bm+1,...,not bn.

  • s(CASP) resolves negated atoms not bi against dual rules.
  • The dual program is not interpreted under SLD semantics in
  • rder to handle the different kind of loops that can appear.
  • The execution starts with a query: ?- cq,l1,...,lm,

Default vs Classical negation:

  • We can cross the railway tracks

in the absence of information about an approaching train. cross:- not train.

  • It is okay to cross the railway if

we know explicitly that no train is approaching. cross:- -train.

madrid institute for advanced studies in software development technologies

slide-5
SLIDE 5

4 / 11

www.software.imdea.org

Event Calculus basics I

Predicate Meaning InitiallyN(f) fluent f is false at time 0 InitiallyP(f) fluent f is true at time 0 Happens(e,t) event e occurs at time t Initiates(e,f,t) if e happens at time t, f is true and not released from the commonsense law of inertia after t Terminates(e,f,t) if e occurs at time t, f is false and not released from the commonsense law of inertia after t Releases(e,f,t) if e occurs at time t, f is released from the commonsense law of inertia after t Trajectory(f1,t1,f2,t2) if f1 is initiated by an event that occurs at t1, then f2 is true at t2 StoppedIn(t1,f,t2) f is stopped between t1 and t2 StartedIn(t1,f,t2) f is started between t1 and t2 HoldsAt(f,t) fluent f is true at time t Table: Basic event calculus (BEC) predicates (e = event, f, f1, f2 = fluents, t, t1, t2 = timepoints) madrid institute for advanced studies in software development technologies

slide-6
SLIDE 6

5 / 11

www.software.imdea.org

Event Calculus basics II

BEC1. StoppedIn(t1,f,t2) ≡

∃e,t ( Happens(e,t) ∧ t1 < t < t2 ∧( Terminates(e,f,t) ∨ Releases(e,f,t) ) )

BEC2. StartedIn(t1,f,t2) ≡

∃e,t ( Happens(e,t) ∧ t1 < t < t2 ∧( Initiates(e,f,t) ∨ Releases(e,f,t) ) )

BEC3. HoldsAt(f2,t2) ← Happens(e,t1) ∧ Initiates(e,f1,t1) ∧ Trajectory(f1,t1,f2,t2) ∧¬StoppedIn(t1,f1,t2) BEC4. HoldsAt(f,t) ← InitiallyP(f) ∧¬StoppedIn(0,f,t) BEC5.

¬HoldsAt(f,t) ←

InitiallyN(f) ∧¬StartedIn(0,f,t) BEC6. HoldsAt(f,t2) ← Happens(e,t1) ∧ Initiates(e,f,t1) ∧ t1 < t2 ∧¬StoppedIn(t1,f,t2) BEC7.

¬HoldsAt(f,t2) ←

Happens(e,t1) ∧ Terminates(e,f,t1) ∧ t1 < t2 ∧¬StartedIn(t1,f,t2) Table: Formalization of BEC axioms [Mueller 2014]. madrid institute for advanced studies in software development technologies

slide-7
SLIDE 7

6 / 11

www.software.imdea.org

Event Calculus translated into s(CASP) I

Atoms and Constants: Uniqueness of Names [Shanahan 1999] is assumed by default in s(CASP). Constraints: t1 < t2 becomes T1 #< T2, and in s(CASP) #< is handled by CLP(Q), a linear constraint solver. Definitions: D(x) ≡ ∃yB(x,y) is written as ∀x(D(x) ← ∃yB(x,y)) and s(CASP) performs Clark’s completion [Clark 1978]. Rules with positive head:

∀x(H(x) ← ∃y(A(y) ∧ ¬B(x,y) ∧ x < y))

is translated into h(X) :- X #< Y, a(Y), not b(X,Y). Rule with negative head:

∀x(¬H(x) ← ∃yB(x,y)) is translated into -h(X) :- b(X,Y) and the

global constraint :- -h(X),h(X), added to detect inconsistency. Rule with disjunctive bodies:

∀x[H(x) ← ∃y( (A(x,y) ∨ B(x,y)) ∧ C(x,y) )] in translated into

h(X) :- a(X,Y), c(X,Y) and h(X) :- b(X,Y), c(X,Y).

Table: Translation of the BEC theory. madrid institute for advanced studies in software development technologies

slide-8
SLIDE 8

7 / 11

www.software.imdea.org

Event Calculus translated into s(CASP) II

%% BEC1 stoppedIn(T1,F,T2) :- T1 #< T, T #< T2, terminates(E,F,T), happens(E,T). stoppedIn(T1,F,T2) :- T1 #< T, T #< T2, releases(E,F,T), happens(E,T). %% BEC2 startedIn(T1,F,T2) :- T1 #< T, T #< T2, initiates(E,F,T), happens(E,T). startedIn(T1,F,T2) :- T1 #< T, T #< T2, releases(E,F,T), happens(E,T). %% BEC3 holdsAt(F2,T2) :- initiates(E,F1,T1), happens(E,T1), trajectory(F1,T1,F2,T2), not stoppedIn(T1,F1,T2). %% BEC4 holdsAt(F,T) :- 0 #< T, initiallyP(F), not stoppedIn(0,F,T). %% BEC5

  • holdsAt(F,T) :-

0 #< T, initiallyN(F), not startedIn(0,F,T). %% BEC6 holdsAt(F,T) :- T1 #< T, initiates(E,F,T1), happens(E,T1), not stoppedIn(T1,F,T). %% BEC7

  • holdsAt(F,T) :-

T1 #< T, terminates(E,F,T1), happens(E,T1), not startedIn(T1,F,T). Figure: Basic Event Calculus (BCE) modeled in s(CASP) madrid institute for advanced studies in software development technologies

slide-9
SLIDE 9

8 / 11

www.software.imdea.org

Example: Continuous Change I.

A vessel is filled with water from a tap [Shanahan 1999]. When the water level reaches the rim, it starts spilling.

#include 'bec_theory'. max_level(10) :- not max_level(16). max_level(16) :- not max_level(10). initiallyP(level(0)). happens(overflow,T). happens(tapOn,5). initiates(tapOn,filling,T). terminates(tapOff,filling,T). initiates(overflow,spilling,T) :- max_level(Max), holdsAt(level(Max), T). releases(tapOn,level(0),T) :- happens(tapOn,T). trajectory(filling,T1,level(X2),T2) :- T1 #< T2, X2 #= X+T2-T1, X2 #=< Max, max_level(Max), holdsAt(level(X),T1). trajectory(filling,T1,level(overflow),T2) :- T1 #< T2, X2 #= X+T2-T1, X2 #> Max, max_level(Max), holdsAt(level(X),T1). trajectory(spilling,T1,leak(X),T2) :- holdsAt(filling, T2), T1 #< T2, X #= T2-T1. Figure: Encoding of a event calculus narrative with continuous change. madrid institute for advanced studies in software development technologies

slide-10
SLIDE 10

9 / 11

www.software.imdea.org

Example: Continuous Change II.

Deduction: determines whether a state of the world is possible

  • ?- holdsAt(level(H),15/2)

is true when H=5/2.

  • ?- holdsAt(level(5/2),T)

is true when T=15/2. Abductive reasoning: tries to determine a plausible sequence

  • f events / actions that reaches a final state
  • ?- holdsAt(level(14),19)

returns a single model with a vessel size of 16. By adding #abducible happens(tapOff,U) to the program:

  • ?- holdsAt(spilling,T)

returns two models: T>15, happens(tapOn,5), not happens(TapOff,U), 5<U<15, max_level(10) T>21, happens(tapOn,5), not happens(TapOff,U), 5<U<21, max_level(16)

madrid institute for advanced studies in software development technologies

slide-11
SLIDE 11

10 / 11

www.software.imdea.org

Evaluation

  • We evaluate the advantage of providing

constraints over continuous domains.

  • We compare our proposal w.r.t. s(ASP) which

checks conditions when variables are instantiated enough.

  • The instantiation simulate grounding which for

queries involving rational numbers need a specific version of the programs.

Queries s(CASP) s(ASP) holdsAt(light_on,2) 233 8,320

  • holdsAt(light_on,5)

314 7,952 holdsAt(light_red,2) 231 8,214 holdsAt(light_green,3) 229 8,577 holdsAt(light_red,9/4) 234 51,548 Table: Run time (ms) comparison for the light scenario. madrid institute for advanced studies in software development technologies

slide-12
SLIDE 12

11 / 11

www.software.imdea.org

Conclusions

  • s(CASP) can capture the notion of continuous change in EC

thanks to its grounding-free top-down evaluation strategy.

  • It can also represent complex models and answer queries in

a flexible manner thanks to the use of constraints.

  • The modeling is more elegant and faithful compared to other

approaches.

  • Explanations for observations via abduction are also

generated for free.

  • Our future work includes applying the s(CASP) system to

solving planning problems where a generated plan must obey real-time constraints.

madrid institute for advanced studies in software development technologies

slide-13
SLIDE 13

11 / 11

www.software.imdea.org

Conclusions

  • s(CASP) can capture the notion of continuous change in EC

thanks to its grounding-free top-down evaluation strategy.

  • It can also represent complex models and answer queries in

a flexible manner thanks to the use of constraints.

  • The modeling is more elegant and faithful compared to other

approaches.

  • Explanations for observations via abduction are also

generated for free.

  • Our future work includes applying the s(CASP) system to

solving planning problems where a generated plan must obey real-time constraints.

THANKS

madrid institute for advanced studies in software development technologies

slide-14
SLIDE 14

12 / 11

www.software.imdea.org

Bibliography I

Arias, J., Carro, M., Salazar, E., Marple, K., and Gupta, G. (2018). Constraint answer set programming without

  • grounding. Theory and Practice of Logic Programming, 18(3-4):337–354.

Balduccini, M., Magazzeni, D., and Maratea, M. (2016). PDDL+ planning via constraint answer set programming. CoRR, abs/1609.00030. Clark, K. L. (1978). Negation as Failure. In Gallaire, H. and Minker, J., editors, Logic and Data Bases. Plenum. Fox, M. and Long, D. (2002). PDDL+: Modeling continuous time dependent effects. In Proceedings of the 3rd International NASA Workshop on Planning and Scheduling for Space, volume 4, page 34. Lee, J. and Meng, Y. (2013). Answer set programming modulo theories and reasoning about continuous changes. In IJCAI 2013, pages 990–996. Marple, K., Salazar, E., and Gupta, G. (2017). Computing Stable Models of Normal Logic Programs Without

  • Grounding. CoRR, abs/1709.00501.

Mueller, E. T. (2014). Commonsense reasoning: an event calculus based approach. Morgan Kaufmann. Shanahan, M. (1999). The Event Calculus Explained. In Artificial Intelligence Today, pages 409–430. madrid institute for advanced studies in software development technologies