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 LPNMR – May 18, 2011 supported by: Austrian Science Fund (FWF) project P20841 and Vienna Science and Technology Fund (WWTF) project ICT08-020
Outline ◮ Answer Set Programming ‘on one slide’ ◮ HEX basics ◮ Old HEX evaluation Example ◮ Improved HEX evaluation Example ◮ Formalism Improvements ◮ Implementation Improvements ◮ Benchmark Results 1 / 15
Answer Set Programming [Gelfond and Lifschitz, 1991] Atoms of the form p ( t 1 , . . . , t k ) . Rules of the form α 1 ∨ · · · ∨ α k ← β 1 , . . . , β n , not β n + 1 , . . . , not β m . Program P is a set of rules. Herbrand base HB P is the set of all ground atoms using constants of P . Interpretation I ⊆ HB P . I | = grnd ( P ) iff I satisfies all ground rules. I | = rule body iff positive atoms are in I and negative atoms are not. I | = rule iff some α i ∈ I , or I does not satisfy the rule body. 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 iff I is a minimal model of fP I . 2 / 15
HEX Syntax and Semantics [Eiter et al. , 2005] Example Program (IDB): r 1 : plan ( a ) ∨ plan ( b ) ← need ( p , C ) ← & cost [ plan ]( C ) r 2 : r 3 : use ( X ) ∨ use ( Y ) ← plan ( P ) , choose ( P , X , Y ) need ( u , C ) ← & cost [ use ]( C ) r 4 : c 5 : ← need ( _ , money ) External Atom: ◮ & g [ x ]( y ) ◮ with input list x = x 1 , . . . , x n and output list y = y 1 , . . . , y m 3 / 15
HEX Syntax and Semantics [Eiter et al. , 2005] Example Program (IDB): r 1 : plan ( a ) ∨ plan ( b ) ← need ( p , C ) ← & cost [ plan ]( C ) r 2 : r 3 : use ( X ) ∨ use ( Y ) ← plan ( P ) , choose ( P , X , Y ) need ( u , C ) ← & cost [ use ]( C ) r 4 : c 5 : ← need ( _ , money ) External Atom: ◮ & g [ x ]( y ) ◮ with input list x = x 1 , . . . , x n and output list y = y 1 , . . . , y m ◮ I | = & g [ x ]( y ) iff oracle function f & g ( I , x , y ) is true ◮ intuitively: f & g is true iff y is an output of & g for input I and x 3 / 15
HEX Example EDB: { choose ( a , c , d ) , choose ( b , e , f ) } Example Program (IDB): r 1 : plan ( a ) ∨ plan ( b ) ← need ( p , C ) ← & cost [ plan ]( C ) r 2 : r 3 : use ( X ) ∨ use ( Y ) ← plan ( P ) , choose ( P , X , Y ) need ( u , C ) ← & cost [ use ]( C ) r 4 : c 5 : ← need ( _ , money ) External Atom: ◮ & cost [ p ]( money ) is true if p / 1 is true for a or f , ◮ & cost [ p ]( time ) is true if p / 1 is true for b , c , d , or e , ◮ & cost [ p ]( X ) is false for all other X -es. 3 / 15
HEX Example EDB: { choose ( a , c , d ) , choose ( b , e , f ) } Example Program (IDB): r 1 : plan ( a ) ∨ plan ( b ) ← need ( p , C ) ← & cost [ plan ]( C ) r 2 : r 3 : use ( X ) ∨ use ( Y ) ← plan ( P ) , choose ( P , X , Y ) need ( u , C ) ← & cost [ use ]( C ) r 4 : c 5 : ← need ( _ , money ) External Atom: ◮ & cost [ p ]( money ) is true if p / 1 is true for a or f , ◮ & cost [ p ]( time ) is true if p / 1 is true for b , c , d , or e , ◮ & cost [ p ]( X ) is false for all other X -es. In our example . . . { plan ( a ) } | = & cost [ plan ]( money ) { plan ( a ) } �| = & cost [ plan ]( time ) { plan ( b ) } �| = & cost [ plan ]( money ) { plan ( b ) } | = & cost [ plan ]( time ) 3 / 15
HEX Example EDB: { choose ( a , c , d ) , choose ( b , e , f ) } Example Program (IDB): r 1 : plan ( a ) ∨ plan ( b ) ← need ( p , C ) ← & cost [ plan ]( C ) r 2 : r 3 : use ( X ) ∨ use ( Y ) ← plan ( P ) , choose ( P , X , Y ) need ( u , C ) ← & cost [ use ]( C ) r 4 : c 5 : ← need ( _ , money ) Answer Set Candidates (Guesses, without EDB): ◮ { plan ( a ) , & cost [ plan ]( money ) , need ( p , money ) , use ( c ) , & cost [ use ]( time ) , need ( u , time ) } ◮ { plan ( a ) , & cost [ plan ]( money ) , need ( p , money ) , use ( d ) , & cost [ use ]( time ) , need ( u , time ) } ◮ { plan ( b ) , & cost [ plan ]( time ) , need ( p , time ) , use ( e ) , & cost [ use ]( time ) , need ( u , time ) } ◮ { plan ( b ) , & cost [ plan ]( time ) , need ( p , time ) , use ( f ) , & cost [ use ]( money ) , need ( u , money ) } 3 / 15
HEX Example (Answer Sets) EDB: { choose ( a , c , d ) , choose ( b , e , f ) } Example Program (IDB): r 1 : plan ( a ) ∨ plan ( b ) ← need ( p , C ) ← & cost [ plan ]( C ) r 2 : r 3 : use ( X ) ∨ use ( Y ) ← plan ( P ) , choose ( P , X , Y ) need ( u , C ) ← & cost [ use ]( C ) r 4 : c 5 : ← need ( _ , money ) Answer Set Candidates (Guesses, without EDB): ◮ { plan ( a ) , & cost [ plan ]( money ) , need ( p , money ) , use ( c ) , & cost [ use ]( time ) , need ( u , time ) } ◮ { plan ( a ) , & cost [ plan ]( money ) , need ( p , money ) , use ( d ) , & cost [ use ]( time ) , need ( u , time ) } ◮ { plan ( b ) , & cost [ plan ]( time ) , need ( p , time ) , ⇐ Answer Set use ( e ) , & cost [ use ]( time ) , need ( u , time ) } ◮ { plan ( b ) , & cost [ plan ]( time ) , need ( p , time ) , use ( f ) , & cost [ use ]( money ) , need ( u , money ) } 3 / 15
HEX evaluation (old strategy) (1) calculate models of largest possible program part which does not depend on (not yet calculated) external atoms (2) calculate external atoms that depend on (1) (3) replace external atoms by result of (2) and goto (1) 4 / 15
HEX evaluation (old strategy) (1) calculate models of largest possible program part which does not depend on (not yet calculated) external atoms (2) calculate external atoms that depend on (1) (3) replace external atoms by result of (2) and goto (1) r 1 : plan ( a ) ∨ plan ( b ) . r 3 : use ( X ) ∨ use ( Y ) ← u 1 r 1 : plan ( a ) ∨ plan ( b ) . plan ( P ) , choose ( P , X , Y ) . r 2 : need ( p , C ) ← derives: plan / 1 , use / 1 & cost [ plan ]( C ) . r 3 : use ( X ) ∨ use ( Y ) ← r 2 : need ( p , C ) ← & cost [ plan ]( C ) plan ( P ) , choose ( P , X , Y ) . u 2 r 4 : need ( u , C ) ← & cost [ use ]( C ) r 4 : need ( u , C ) ← derives: need / 2 & cost [ use ]( C ) . c 5 : ← need ( _ , money ) . c 5 : ← need ( _ , money ) u 3 derives nothing 4 / 15
HEX model building (old strategy) “Model Graph” “Evaluation Graph” r 1 : plan ( a ) ∨ plan ( b ) . r 3 : use ( X ) ∨ use ( Y ) ← plan ( P ) , choose ( P , X , Y ) . r 2 : need ( p , C ) ← & cost [ plan ]( C ) r 4 : need ( u , C ) ← & cost [ use ]( C ) c 5 : ← need ( _ , money ) 5 / 15
HEX model building (old strategy) “Model Graph” “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 ( P ) , choose ( P , X , Y ) . = { plan ( b ) , use ( e ) } m 3 O : − = { plan ( b ) , use ( f ) } m 4 I : 1 I : 2 m 5 = m 1 m 6 = m 2 I : 3 I : 4 m 7 = m 3 m 8 = m 4 r 2 : need ( p , C ) ← & cost [ plan ]( C ) r 4 : need ( u , C ) ← & cost [ use ]( C ) c 5 : ← need ( _ , money ) 5 / 15
HEX model building (old strategy) “Model Graph” “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 ( P ) , choose ( P , X , Y ) . = { plan ( b ) , use ( e ) } m 3 O : − = { plan ( b ) , use ( f ) } m 4 I : 1 I : 2 m 5 = m 1 m 6 = m 2 I : 3 I : 4 m 7 = m 3 m 8 = m 4 r 2 : need ( p , C ) ← O : 5 = { need ( p , money ) , need ( u , time ) } m 9 & cost [ plan ]( C ) O : 6 = { need ( p , money ) , need ( u , time ) } m 10 r 4 : need ( u , C ) ← O : 7 & cost [ use ]( C ) = { need ( p , time ) , need ( u , time ) } m 11 O : 8 = { need ( p , time ) , need ( u , money ) } m 12 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 ) 5 / 15
Recommend
More recommend