Pushing Efficient Evaluation of HEX Programs by Modular Decomposition Thomas Eiter Michael Fink Giovambattista Ianni Thomas Krennwallner Peter Schüller KBS Group – Institut für Informationssysteme, Technische Universität Wien Dipartimento di Matematica, Università della Calabria IJCAI – July 20, 2011 – Barcelona Best Paper Track – LPNMR 2011 – Vancouver supported by: Austrian Science Fund (FWF) project P20841 and Vienna Science and Technology Fund (WWTF) project ICT08-020
Motivation and Overview Motivation: ◮ HEX extends Answer Set Programming ◮ supports external atoms for external knowledge/computations ◮ drawbacks of previous HEX evaluation algorithm ⇒ applications called for efficiency improvements 1 / 17
Motivation and Overview Motivation: ◮ HEX extends Answer Set Programming ◮ supports external atoms for external knowledge/computations ◮ drawbacks of previous HEX evaluation algorithm ⇒ applications called for efficiency improvements This work: ◮ novel HEX evaluation formalism ⇒ evaluation graph + model graph ◮ implementation + experimental evaluation ⇒ can even outperform standard ASP solvers 1 / 17
Answer Set Programming [Gelfond and Lifschitz, 1991] Programs are sets of rules of the form α 1 ∨ · · · ∨ α k ← β 1 , . . . , β n , not β n + 1 , . . . , not β m where not is negation-as-failure and α i , β j are atoms of the form p ( t 1 , . . . , t k ) . Herbrand base HB P is the set of all ground atoms using constants of P Interpretation I ⊆ HB P � positive atoms β 1 , . . . , β n are in I , and I | = rule body iff negative atoms β n + 1 , . . . , β m are not in I I | = rule iff some head atom α i is in I , or the rule body is not satisfied I | = P iff I | = grnd ( P ) iff I satisfies all ground rules of program P FLP reduct [Faber et al. , 2011] of P wrt. I : fP I is the set of ground rules of P where I satisfies the rule body I is an answer set of P iff I is a ⊆ -minimal model of fP I 2 / 17
HEX Syntax and Semantics [Eiter et al. , 2005] Program (choose a plan, choose a usage, determine resource needs): { choose ( a , c , d ) ← , choose ( b , e , f ) ← } EDB r 1 : plan ( a ) ∨ plan ( b ) ← r 2 : need ( p , C ) ← & res [ plan ]( C ) IDB r 3 : use ( X ) ∨ use ( Y ) ← plan ( P ) , choose ( P , X , Y ) r 4 : need ( u , C ) ← & res [ use ]( C ) c 5 : ← need ( _ , money ) External Atom: ◮ & g [ x ]( y ) ◮ input list x = x 1 , . . . , x n and output list y = y 1 , . . . , y m of terms ◮ I | = & g [ x ]( y ) iff oracle function f & g ( I , x , y ) is true 3 / 17
HEX Example Program (choose a plan, choose a usage, determine resource needs): { choose ( a , c , d ) ← , choose ( b , e , f ) ← } EDB r 1 : plan ( a ) ∨ plan ( b ) ← r 2 : need ( p , C ) ← & res [ plan ]( C ) IDB r 3 : use ( X ) ∨ use ( Y ) ← plan ( P ) , choose ( P , X , Y ) r 4 : need ( u , C ) ← & res [ use ]( C ) c 5 : ← need ( _ , money ) External Atom: ◮ I | = & res [ p ]( money ) if p ( C ) ∈ I for C ∈ { a , f } , ◮ I | = & res [ p ]( time ) if p ( C ) ∈ I for C ∈ { b , c , d , e } , ◮ I �| = & res [ p ]( X ) otherwise. 4 / 17
HEX Example Program (choose a plan, choose a usage, determine resource needs): { choose ( a , c , d ) ← , choose ( b , e , f ) ← } EDB r 1 : plan ( a ) ∨ plan ( b ) ← r 2 : need ( p , C ) ← & res [ plan ]( C ) IDB r 3 : use ( X ) ∨ use ( Y ) ← plan ( P ) , choose ( P , X , Y ) r 4 : need ( u , C ) ← & res [ use ]( C ) c 5 : ← need ( _ , money ) External Atom: ◮ I | = & res [ p ]( money ) if p ( C ) ∈ I for C ∈ { a , f } , ◮ I | = & res [ p ]( time ) if p ( C ) ∈ I for C ∈ { b , c , d , e } , ◮ I �| = & res [ p ]( X ) otherwise. In our example . . . { plan ( a ) } | { plan ( a ) } �| = & res [ plan ]( money ) = & res [ plan ]( time ) { plan ( b ) } �| = & res [ plan ]( money ) { plan ( b ) } | = & res [ plan ]( time ) 4 / 17
HEX Example Program (choose a plan, choose a usage, determine resource needs): { choose ( a , c , d ) ← , choose ( b , e , f ) ← } EDB r 1 : plan ( a ) ∨ plan ( b ) ← r 2 : need ( p , C ) ← & res [ plan ]( C ) IDB r 3 : use ( X ) ∨ use ( Y ) ← plan ( P ) , choose ( P , X , Y ) r 4 : need ( u , C ) ← & res [ use ]( C ) c 5 : ← need ( _ , money ) Guessed Interpretations: ◮ { plan ( a ) , & res [ plan ]( money ) , need ( p , money ) , use ( c ) , & res [ use ]( time ) , need ( u , time ) } ◮ { plan ( a ) , & res [ plan ]( money ) , need ( p , money ) , use ( d ) , & res [ use ]( time ) , need ( u , time ) } ◮ { plan ( b ) , & res [ plan ]( time ) , need ( p , time ) , use ( e ) , & res [ use ]( time ) , need ( u , time ) } ◮ { plan ( b ) , & res [ plan ]( time ) , need ( p , time ) , use ( f ) , & res [ use ]( money ) , need ( u , money ) } 5 / 17
HEX Example Program (choose a plan, choose a usage, determine resource needs): { choose ( a , c , d ) ← , choose ( b , e , f ) ← } EDB r 1 : plan ( a ) ∨ plan ( b ) ← r 2 : need ( p , C ) ← & res [ plan ]( C ) IDB r 3 : use ( X ) ∨ use ( Y ) ← plan ( P ) , choose ( P , X , Y ) r 4 : need ( u , C ) ← & res [ use ]( C ) c 5 : ← need ( _ , money ) Guessed Interpretations: ◮ { plan ( a ) , & res [ plan ]( money ) , need ( p , money ) , use ( c ) , & res [ use ]( time ) , need ( u , time ) } ◮ { plan ( a ) , & res [ plan ]( money ) , need ( p , money ) , use ( d ) , & res [ use ]( time ) , need ( u , time ) } ◮ { plan ( b ) , & res [ plan ]( time ) , need ( p , time ) , ⇐ Answer Set use ( e ) , & res [ use ]( time ) , need ( u , time ) } ◮ { plan ( b ) , & res [ plan ]( time ) , need ( p , time ) , use ( f ) , & res [ use ]( money ) , need ( u , money ) } 5 / 17
HEX evaluation (previous strategy) (1) calculate models of all program parts that do not depend on external computations that still need to be done (2) do external computations that depend on (1) (3) replace evaluated external atoms by result of (2) and restart at (1) 6 / 17
HEX evaluation (previous strategy) (1) calculate models of all program parts that do not depend on external computations that still need to be done (2) do external computations that depend on (1) (3) replace evaluated external atoms by result of (2) and restart at (1) r 1 : plan ( a ) ∨ plan ( b ) . r 3 : use ( X ) ∨ use ( Y ) ← r 1 : plan ( a ) ∨ plan ( b ) . u 1 plan ( P ) , choose ( P , X , Y ) . r 2 : need ( p , C ) ← ⇒ plan / 1 , use / 1 & res [ plan ]( C ) . r 3 : use ( X ) ∨ use ( Y ) ← plan ( P ) , choose ( P , X , Y ) . r 2 : need ( p , C ) ← & res [ plan ]( C ) r 4 : need ( u , C ) ← u 2 r 4 : need ( u , C ) ← & res [ use ]( C ) & res [ use ]( C ) . ⇒ need / 2 c 5 : ← need ( _ , money ) . u 3 c 5 : ← need ( _ , money ) 6 / 17
HEX model building (previous strategy) Models “Evaluation Graph” O : − = { plan ( a ) , use ( c ) } m 1 r 1 : plan ( a ) ∨ plan ( b ) . O : − = { plan ( a ) , use ( d ) } m 2 r 3 : use ( X ) ∨ use ( Y ) ← O : − = { plan ( b ) , use ( e ) } plan ( P ) , choose ( P , X , Y ) . m 3 O : − m 4 = { plan ( b ) , use ( f ) } I : 1 I : 2 = m 1 = m 2 m 5 m 6 I : 3 I : 4 = m 3 = m 4 m 7 m 8 r 2 : need ( p , C ) ← & res [ plan ]( C ) r 4 : need ( u , C ) ← & res [ use ]( C ) c 5 : ← need ( _ , money ) 7 / 17
HEX model building (previous strategy) Models “Evaluation Graph” O : − = { plan ( a ) , use ( c ) } m 1 r 1 : plan ( a ) ∨ plan ( b ) . O : − = { plan ( a ) , use ( d ) } m 2 r 3 : use ( X ) ∨ use ( Y ) ← O : − = { plan ( b ) , use ( e ) } plan ( P ) , choose ( P , X , Y ) . m 3 O : − m 4 = { plan ( b ) , use ( f ) } I : 1 I : 2 = m 1 = m 2 m 5 m 6 I : 3 I : 4 = m 3 = m 4 m 7 m 8 r 2 : need ( p , C ) ← O : 5 = { need ( p , money ) , need ( u , time ) } m 9 & res [ plan ]( C ) O : 6 = { need ( p , money ) , need ( u , time ) } m 10 r 4 : need ( u , C ) ← O : 7 & res [ use ]( C ) = { need ( p , time ) , need ( u , time ) } m 11 O : 8 m 12 = { need ( p , time ) , need ( u , money ) } I : 9 I : 10 m 13 = m 9 m 14 = m 10 I : 11 I : 12 m 15 = m 11 m 16 = m 12 c 5 : ← need ( _ , money ) 7 / 17
HEX model building (previous strategy) Models “Evaluation Graph” O : − = { plan ( a ) , use ( c ) } m 1 r 1 : plan ( a ) ∨ plan ( b ) . O : − = { plan ( a ) , use ( d ) } m 2 r 3 : use ( X ) ∨ use ( Y ) ← O : − = { plan ( b ) , use ( e ) } plan ( P ) , choose ( P , X , Y ) . m 3 O : − m 4 = { plan ( b ) , use ( f ) } I : 1 I : 2 = m 1 = m 2 m 5 m 6 I : 3 I : 4 = m 3 = m 4 m 7 m 8 r 2 : need ( p , C ) ← O : 5 = { need ( p , money ) , need ( u , time ) } m 9 & res [ plan ]( C ) O : 6 = { need ( p , money ) , need ( u , time ) } m 10 r 4 : need ( u , C ) ← O : 7 & res [ use ]( C ) = { need ( p , time ) , need ( u , time ) } m 11 O : 8 m 12 = { need ( p , time ) , need ( u , money ) } I : 9 I : 10 m 13 = m 9 m 14 = m 10 I : 11 I : 12 m 15 = m 11 m 16 = m 12 c 5 : ← need ( _ , money ) O : 15 = ∅ m 17 7 / 17
Recommend
More recommend