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 University of Texas at Dallas madrid institute for advanced studies in software development technologies
www.software.imdea.org Motivation • Commonsense Reasoning ( CR ) requires the ability to model Example: 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 Turning a light switch on and off. applied to modeling the event calculus. madrid institute for advanced studies in software development technologies 1 / 11
www.software.imdea.org Our Proposal Based on s(CASP) [Arias et al. 2018] achieves more conciseness Example: and expressiveness than other approaches because dense #include ' ../bec_theory ' . domains can be faithfully modeled as continuous quantities. initiates(turn_on,light_on,T). trajectory(light_on , T1 , light_red , T2) :- terminates(turn_off,light_on,T). T2 #>= T1 , T2 #< T1+2. initiallyN(light_on). • The s(CASP) system is an implementation of Constraint happens(turn_on, 1/2). Answer Set Programming over first order predicates: happens(turn_off, 4). • It combines ASP and constraints. happens(turn_on, 6). • It features predicates, constraints among non-ground variables ?- holds(light_on, 2). and uninterpreted functions. • It has a top-down, query-driven execution strategy. madrid institute for advanced studies in software development technologies 2 / 11
www.software.imdea.org Background • s(ASP) [Marple et al. 2017] is a top-down, goal-driven ASP Default vs Classical negation: system that can evaluate ASP programs with function • We can cross the railway tracks symbols without grounding them. in the absence of information • s(CASP) [Arias et al. 2018] adds constraints, to s(ASP). about an approaching train. • The constraints relate variables. cross:- not train. • They are kept and used during execution and in answers. • It is okay to cross the railway if • A s(CASP) program is a set of clauses: we know explicitly that no train is a:- c a , b 1 , ... , b m , not b m + 1 , ... , not b n . approaching. • s(CASP) resolves negated atoms not b i against dual rules . cross:- -train. • The dual program is not interpreted under SLD semantics in order to handle the different kind of loops that can appear. • The execution starts with a query : ?- c q , l 1 , ... , l m , madrid institute for advanced studies in software development technologies 3 / 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 ( f 1 , t 1 , f 2 , t 2 ) if f 1 is initiated by an event that occurs at t 1 , then f 2 is true at t 2 StoppedIn ( t 1 , f , t 2 ) f is stopped between t 1 and t 2 StartedIn ( t 1 , f , t 2 ) f is started between t 1 and t 2 HoldsAt ( f , t ) fluent f is true at time t Table: Basic event calculus (BEC) predicates ( e = event, f , f 1 , f 2 = fluents, t , t 1 , t 2 = timepoints) madrid institute for advanced studies in software development technologies 4 / 11
www.software.imdea.org Event Calculus basics II StoppedIn ( t 1 , f , t 2 ) ≡ ∃ e , t ( Happens ( e , t ) ∧ t 1 < t < t 2 ∧ ( Terminates ( e , f , t ) ∨ Releases ( e , f , t ) ) ) BEC1. StartedIn ( t 1 , f , t 2 ) ≡ ∃ e , t ( Happens ( e , t ) ∧ t 1 < t < t 2 ∧ ( Initiates ( e , f , t ) ∨ Releases ( e , f , t ) ) ) BEC2. HoldsAt ( f 2 , t 2 ) ← Happens ( e , t 1 ) ∧ Initiates ( e , f 1 , t 1 ) ∧ Trajectory ( f 1 , t 1 , f 2 , t 2 ) ∧¬ StoppedIn ( t 1 , f 1 , t 2 ) BEC3. HoldsAt ( f , t ) ← InitiallyP ( f ) ∧¬ StoppedIn ( 0 , f , t ) BEC4. ¬ HoldsAt ( f , t ) ← InitiallyN ( f ) ∧¬ StartedIn ( 0 , f , t ) BEC5. HoldsAt ( f , t 2 ) ← Happens ( e , t 1 ) ∧ Initiates ( e , f , t 1 ) ∧ t 1 < t 2 ∧¬ StoppedIn ( t 1 , f , t 2 ) BEC6. ¬ HoldsAt ( f , t 2 ) ← Happens ( e , t 1 ) ∧ Terminates ( e , f , t 1 ) ∧ t 1 < t 2 ∧¬ StartedIn ( t 1 , f , t 2 ) BEC7. Table: Formalization of BEC axioms [Mueller 2014] . madrid institute for advanced studies in software development technologies 5 / 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: t 1 < t 2 becomes T1 #< T2 , and in s(CASP) #< is handled by CLP(Q), a linear constraint solver. D ( x ) ≡ ∃ yB ( x , y ) is written as ∀ x ( D ( x ) ← ∃ yB ( x , y )) and s(CASP) Definitions: performs Clark’s completion [Clark 1978] . ∀ x ( H ( x ) ← ∃ y ( A ( y ) ∧ ¬ B ( x , y ) ∧ x < y )) Rules with positive head: is translated into h(X) :- X #< Y , a(Y) , not b(X , Y) . ∀ x ( ¬ H ( x ) ← ∃ yB ( x , y )) is translated into -h(X) :- b(X , Y) and the Rule with negative head: global constraint :- -h(X) , h(X) , added to detect inconsistency. ∀ x [ H ( x ) ← ∃ y ( ( A ( x , y ) ∨ B ( x , y )) ∧ C ( x , y ) )] in translated into Rule with disjunctive bodies: 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 6 / 11
www.software.imdea.org Event Calculus translated into s(CASP) II %% BEC1 startedIn(T1,F,T2) :- %% BEC5 stoppedIn(T1,F,T2) :- T1 #< T, T #< T2, -holdsAt(F,T) :- T1 #< T, T #< T2, releases(E,F,T), 0 #< T, initiallyN(F), terminates(E,F,T), happens(E,T). not startedIn(0,F,T). happens(E,T). %% BEC3 %% BEC6 stoppedIn(T1,F,T2) :- holdsAt(F2,T2) :- holdsAt(F,T) :- T1 #< T, T #< T2, initiates(E,F1,T1), T1 #< T, initiates(E,F,T1), releases(E,F,T), happens(E,T1), happens(E,T1), happens(E,T). trajectory(F1,T1,F2,T2), not stoppedIn(T1,F,T). %% BEC2 not stoppedIn(T1,F1,T2). %% BEC7 startedIn(T1,F,T2) :- %% BEC4 -holdsAt(F,T) :- T1 #< T, T #< T2, holdsAt(F,T) :- T1 #< T, terminates(E,F,T1), initiates(E,F,T), 0 #< T, initiallyP(F), happens(E,T1), happens(E,T). not stoppedIn(0,F,T). not startedIn(T1,F,T). Figure: Basic Event Calculus (BCE) modeled in s(CASP) madrid institute for advanced studies in software development technologies 7 / 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). releases(tapOn,level(0),T) :- happens(tapOn,T). max_level(16) :- not max_level(10). trajectory(filling,T1,level(X2),T2) :- initiallyP(level(0)). T1 #< T2, X2 #= X+T2-T1, X2 #=< Max, happens(overflow,T). max_level(Max), holdsAt(level(X),T1). happens(tapOn,5). trajectory(filling,T1,level(overflow),T2) :- initiates(tapOn,filling,T). T1 #< T2, X2 #= X+T2-T1, X2 #> Max, terminates(tapOff,filling,T). max_level(Max), holdsAt(level(X),T1). initiates(overflow,spilling,T) :- trajectory(spilling,T1,leak(X),T2) :- max_level(Max), holdsAt(level(Max), T). 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 8 / 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 of 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: returns two models: • ?- holdsAt(spilling , T) 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 9 / 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 Queries s(CASP) s(ASP) checks conditions when variables are 233 8,320 holdsAt(light_on,2) instantiated enough. 314 7,952 -holdsAt(light_on,5) • The instantiation simulate grounding which for 231 8,214 holdsAt(light_red,2) queries involving rational numbers need a 229 8,577 holdsAt(light_green,3) specific version of the programs. 234 51,548 holdsAt(light_red,9/4) Table: Run time (ms) comparison for the light scenario. madrid institute for advanced studies in software development technologies 10 / 11
Recommend
More recommend