Complex Optimization in Answer Set Programming

Preference handling and optimization are indispensable means for addressing non-trivial applications in Answer Set Programming (ASP). However, their implementation becomes difficult whenever they bring about a significant increase in computational co…

Authors: Martin Gebser, Rol, Kaminski

Under consider ation for publicat ion in Theory and Practice of Logic Prog ramming 1 Complex Optimizati o n in Answer Set Pr ogr amming Martin Gebser and Roland Kaminski and T orsten Schaub ∗ Institut f ¨ ur Informatik, Univer sit ¨ at P otsdam submitte d [TBA]; re vised [TBA]; accept ed [TBA] Abstract Preference handling and optimization are indispensab le mean s for addressing non-trivial applications in Answer Set Programming (ASP). Ho wev er , the ir implementation becomes difficult whenev er they bring about a significant increase in computational complexity . As a consequence, existing ASP systems do not of fer co mplex o ptimization capacities, sup porting, for instance, inc lusion-based min- imization or Pareto efficiency . Rather, such complex criteria are typically addressed by resorting to dedicated modeling techniques, like saturation . Unlike the ease of comm on ASP modeling, ho we ver , these techniques are rather inv olved and hardly usable by ASP laymen. W e address this problem by de veloping a general implementation technique by means of meta-programming , thus reusing exist- ing ASP systems to capture v arious forms of qu alitative p references among answer sets. In this way , complex p references and optimization capacities become readily av ailable for ASP applications. 1 Introduction Preferences are often an ind ispensable means in modelin g since they allow for identi- fying preferred solutions amon g all feasible ones. Acco rdingly , many forms of prefer- ences have already foun d their way into sy stems for An swer Set Programming (ASP; (Baral 2003)). For in stance, smo dels provides o ptimization statements for expressing co st function s on sets of weigh ted literals (Simons et al. 2002), an d dlv (Leone et al. 2006) of- fers weak constraints for the same pu rpose. Further a pproach es (Delgra nde et al. 2003; Eiter et al. 2003) allow for e xpressing various types of preferences among rules. Unlike this, n o read ily app licable imp lementation techniq ues are av ailable for qualitati ve pref- erences among answer sets, like inclusion minimality , Pareto-based pr eferences a s u sed in (Sakam a and Inoue 2000; Brewka et al. 2004), or mo re co mplex com binations a s pro - posed in (Bre wka 2004). This shortcomin g is due to their high er expressiv eness leading to a significant increase in compu tational complexity , lifting decision pro blems (for no rmal logic program s) from the first to the second level of the po lynomial tim e hierarchy (cf . (Garey and J ohnso n 1979)). Rou ghly sp eaking, prefer ences amon g a nswer sets combine an NP with a c oNP p roblem. Th e first o ne defines f easible solution s, while the seco nd one ensure s th at there ar e no better solutions accordin g to th e pref erences at hand . For implementin g such problems, Eiter and Gottlob in vented in (19 95) the saturation tech- nique, using th e elev ated comp lexity of d isjunctive log ic p rogram ming. In stark contrast ∗ Affili ated with Simon Fraser Univ ersity , Canad a, and Griffith Uni versity , Australia. 2 Martin Ge b ser and Rola nd Kaminski and T orsten S chaub to the e ase of commo n ASP mod eling (e. g., strategic comp anies can be “n aturally” en - coded ( Leone et al. 2006) in disjunctive ASP), h owe ver , the saturatio n tech nique is rathe r in volved and hardly usable by ASP laymen . For taking this burden of intricate mod eling off the user, we pro pose a gen eral, saturation-b ased im plementation tech nique captu ring various forms o f q ualitative pr efer- ences am ong answer sets. This is driven by the desire to gu arantee immediate a vailability and thus to stay within the realm of ASP rather than to build separate (imperative) c om- ponen ts. T o this en d, we take advantage of recent advances in ASP groun ding technology , admitting an easy use of meta-modelin g tec hniques. The idea is to reinterpret existing o pti- mization statements in or der to express complex pref erences am ong answer sets. While, f or instance in smodels , the meaning of # minimize is to compute answer s ets incurr ing min- imum costs, we may alternatively use it for selecting inclusion-m inimal on es. In contrast to the identification of minimal mod els, in ves tigated by Janhunen and Oikarinen in (20 04; 2008), a major challenge lies in guara nteeing th e stability prope rty o f imp licit counterex- amples, which mu st be mor e prefer red answer sets rather tha n (arbitr ary) models. For this purpo se, we develop a refined m eta-prog ram qu alifying answer sets as viable counterex- amples. Unlike the approach of Eiter and Polleres (2006), our encoding a voids “guessing” a level ma pping to describ e the form ation of a co unterexample, but directly d enies mod - els f or which there is no such construction . Notably , our meta-p rogram s apply to (reified) extended log ic prog rams ( Simons et al. 2002), po ssibly including choice rules and # su m constraints, and we are unaw are of any existing me ta-encodin g of their answer sets, neither as candidates nor as counterexamp les refuting optima lity . 2 Background W e consider extended logic progra ms (Simo ns et al. 2002) allowing for (pro per) disjun c- tions in heads of rules (Gelfond and Lifschitz 1991). A rule r is of the following form: H ← B 1 , . . . , B m , ∼ B m +1 , . . . , ∼ B n . By he ad ( r ) = H and b o dy ( r ) = { B 1 , . . . , B m , ∼ B m +1 , . . . , ∼ B n } , we denote the head and the body o f r , r espectively , where “ ∼ ” stands for default n egation. The head H is a disjunction a 1 ∨ · · · ∨ a k over atoms a 1 , . . . , a k , belonging to some a lphabet A , or a # sum constraint L # sum [ ℓ 1 = w 1 , . . . , ℓ k = w k ] U . In th e latter , ℓ i = a i or ℓ i = ∼ a i is a literal and w i a non- ne gative integer weight f or a i ∈ A and 1 ≤ i ≤ k ; L an d U are integers providing a lower and an upper bound. Either o r both of L and U can be omitted, in which case they ar e iden tified with the (trivial) bou nds 0 an d ∞ , respectively . A r ule r such th at he a d ( r ) = ⊥ ( H is the empty d isjunction) is an i ntegrity constraint . Each bod y co mpone nt B i is either an atom or a # s um con straint for 1 ≤ i ≤ n . If b o dy ( r ) = ∅ , r is called a fact , and we skip “ ← ” when wr iting facts belo w . F or a set { B 1 , . . . , B m , ∼ B m +1 , . . . , ∼ B n } , a disjunction a 1 ∨ · · · ∨ a k , and a # sum co nstraint L # sum [ ℓ 1 = w 1 , . . . , ℓ k = w k ] U , we let { B 1 , . . . , B m , ∼ B m +1 , . . . , ∼ B n } + = { B 1 , . . . , B m } , ( a 1 ∨ · · · ∨ a k ) + = { a 1 , . . . , a k } , and ( L # sum [ ℓ 1 = w 1 , . . . , ℓ k = w k ] U ) + = [ ℓ i = w i | 1 ≤ i ≤ k , ℓ i ∈ A ] . Note that th e elements of a # sum co nstraint form a multiset, possibly con taining duplicates. For some S = { a 1 , . . . , a k } o r S = [ a 1 = w 1 , . . . , a k = w k ] , we define atom ( S ) = { a 1 , . . . , a k } . Complex Optimization in A nswer Set Pr ogramming 3 A (Her brand) interpr etation is rep resented by th e set X ⊆ A of its entailed atom s. The satisfaction relation “ | = ” on rules r is ind uctively defined as follows: • X | = ∼ B if X 6| = B , • X | = ( a 1 ∨ · · · ∨ a k ) if { a 1 , . . . , a k } ∩ X 6 = ∅ , • X | = ( L # su m [ ℓ 1 = w 1 , . . . , ℓ k = w k ] U ) if L ≤ P 1 ≤ i ≤ k,X | = ℓ i w i ≤ U , • X | = b o dy ( r ) if X | = ℓ for all ℓ ∈ b o dy ( r ) , an d • X | = r if X | = he ad ( r ) o r X 6| = b o dy ( r ) . A logic pr ogram Π is a set of rules r , and X is a model of Π if X | = r for e very r ∈ Π . The reduct of the head H of a rule r wrt X is H X = { a 1 ∨ · · · ∨ a k } if H = a 1 ∨ · · · ∨ a k , and H X = atom ( H + ) ∩ X if H = L # sum [ ℓ 1 = w 1 , . . . , ℓ k = w k ] U . Fur thermor e, the reduct o f some (p ositiv e) bod y element B ∈ b o dy ( r ) + is B X = B if B ∈ A , and B X =  L − P 1 ≤ i ≤ k,ℓ i = ∼ a i ,a i / ∈ X w i  # sum B + if B = L # sum [ ℓ 1 = w 1 , . . . , ℓ k = w k ] U . The r educt of Π wrt X is the f ollowing log ic program : Π X =  H ← B X 1 , . . . , B X m | r ∈ Π , X | = b o dy ( r ) , H ∈ he ad ( r ) X , b o dy ( r ) + = { B 1 , . . . , B m }  . That is, for all ru les r ∈ Π whose b odies are satisfied wrt X , the reduct is obtained by replacing # sum c onstraints in head s w ith individual atoms belong ing to X and b y elim i- nating negative compon ents in bodies, whe re lower b ound s o f residua l # sum constra ints (with trivial upper bo unds) are reduced accordin gly . Finally , X is an a nswer set of Π if X is a mode l o f Π such that no prop er subset of X is a model of Π X . I n view of the latter condition , n ote that an answer set is a minimal mo del of its own reduct. The definition o f answer sets p rovided ab ove ap plies to logic p rogram s con taining ex- tended constructs ( # sum constraints) under “choice semantics” ( Simons et al. 2002), while additionally allowing fo r disjun ctions un der minim al-model semantics (wrt a r educt). W e use these features to embed extend ed con structs of an objec t progr am into a disjunc ti ve meta-pro gram, so that their combin ation y ields optimal answer sets of t he object progra m. T o this end, we reinterpr et # mi nimiz e statements of the following form: # minimi ze [ ℓ 1 = w 1 @ J 1 , . . . , ℓ k = w k @ J k ] . (1) Like with # sum con straints, ev ery ℓ i is a literal and every w i an integer weight for 1 ≤ i ≤ k , wh ile J i additionally provides an integer priority level . 1 Priorities allow for representing a seque nce o f lexicograph ically o rdered # minimi ze ob jecti ves, whe re greater levels are mo re significant th an smaller o nes. By default, a # mi nimiz e statement distinguishes optimal answer sets o f a prog ram Π in the following way . For any X ⊆ A and integer J , let Σ X J denote the s um of weig hts w over all occurre nces o f weigh ted literals ℓ = w @ J in (1) such that X | = ℓ . An answer set X o f Π is dominated if th ere is an answer set Y of Π such that Σ Y J < Σ X J and Σ Y J ′ = Σ X J ′ for all J ′ > J , an d optimal otherwise. In the follo wing, we assume that every logic p rogram is accompanied with o ne (p ossibly 1 Explicit priority lev els are supported in recent version s of the grounder gringo (Gebser et al. ). This av oids a dependenc y of priorit ies on input order , which is considered by lparse (Syrj ¨ anen ) if sev eral # minimiz e statemen ts are provide d. Priority lev els are also supported by dlv (Leone et al. 2006) in weak constraint s. Fur- thermore, we admit negati v e weights in # minimize stat ements, where they cannot raise semantic probl ems (cf. (Ferraris 2005)) going along with the re writing of # sum constraints suggested in (Simons et al. 2002). 4 Martin Ge b ser and Rola nd Kaminski and T orsten S chaub empty) # min imize statement of the for m (1). I nstead of the d efault semantics, we con- sider Pareto efficiency wrt prior ity le vels J , weigh ts w , and several d istinct op timization criteria. I n vie w o f th is, we use le vels fo r in ducing a lexicograph ic order, while weights are used for group ing literals (r ather than su mmation). Pareto im provement then builds u pon a two-dimensional structure of orderings among answer sets , indu ced by J a nd w . In turn , each such pair ing is associated with some of th e following ord erings. By Y ≤ w J X , we denote that the cardin ality o f the multiset of occu rrences of ℓ = w @ J in (1) such that Y | = ℓ is n ot g reater than the o ne o f the corresp onding multiset fo r X | = ℓ . Further more, we write Y ⊆ w J X if, for any weighted liter al ℓ = w @ J occurring in (1), Y | = ℓ implies X | = ℓ . As d etailed in th e extend ed version of this paper (Gebser et al. 20 11), we addi- tionally conside r the appro ach o f (Sakama and Inoue 2000) and d enote by Y  w J X that Y is prefer able to X acco rding to a (given) prefer ence relatio n  am ong literals ℓ such that ℓ = w @ J occu rs in (1). Giv en a lo gic p rogram Π and a collection M of r elations o f the for m ⋄ w J for p riority levels J , weights w , a nd ⋄ ∈ {≤ , ⊆ , } , an answer set Y o f Π dominates an answer set X of Π wrt M if there are a priority lev el J an d a weight w such that X ⋄ w J Y does not h old for ⋄ w J ∈ M , while Y ⋄ w ′ J ′ X ho lds fo r all ⋄ w ′ J ′ ∈ M where J ′ ≥ J . In turn , an answer set X of Π is optimal wrt M if there is no answer set Y of Π that dominates X wrt M . As an example, consider the following prog ram, referred to by Π 0 : 1 { p, t } ← 1 { r , s, ∼ t } 2 . (2) { q , r } 1 ← 1 { p, t } . (3) s ← ∼ q , ∼ r. (4) This p rogram ha s five answer sets, viz. { p, q } , { p, r } , { p, s } , { p, s , t } , an d { s, t } . (Sets { a 1 , . . . , a k } in (2) an d ( 3) are u sed as shorthands for # sum [ a 1 = 1 , . . . , a k = 1 ] .) I n addition, let Π 1 denote the unio n o f Π 0 with the following # minimi ze statemen t: # minimi ze [ p = 1@ 1 , q = 1 @1 , r = 1@1 , s = 1@1] . (5) This statement s pecifies that all atoms o f Π 0 except for t are subject to minimization . Pass- ing Π 1 to gringo and an answer set solver like smodels yields the single ≤ 1 1 -minimal a nswer set { s , t } . Note, howe ver , that Π 0 has three ⊆ 1 1 -minimal answer sets , namely { p, q } , { p, r } , and { s, t } . They cannot be computed directly from Π 1 via any a v ailable ASP system. W e implemen t the complex o ptimization criter ia d escribed a bove b y meta-interp retation in disjunctive ASP . For transparency , we provide meta-prog rams as true ASP co de in the first-order input lang uage of gring o (Gebser et al. ), including not an d | a s tokens for ∼ and ∨ , respectively , as well as { a 1 , . . . , a k } as shorthan d f or # sum [ a 1 =1, . . . , a k =1] . Further co nstructs are inform ally introd uced b y n eed in the remainder of this paper . Note that o ur (disjun ctiv e) meta-pr ograms ap ply to an extended o bject p rogram th at do es not include proper disjunctions (ov er more than one atom). Unless stated otherwise, we belo w use the term e xtended program to refer to a logic program without proper disjunctions. 3 Basic Meta-Modeling For reinter preting # m inimiz e statements b y me ans of ASP , we take advantage o f r ecent advances in ASP groun ding, admittin g an easy u se of meta-m odeling techniqu es. T o be Complex Optimization in A nswer Set Pr ogramming 5 1 rule(pos(sum(1,0,2)),pos(conjunction(0))). % 1 { p, t } :- 1 { r, s, not t } 2. 2 wlist(0,0,pos(atom(p)),1). wlist(0,1,pos(atom(t)),1). 3 set(0,pos(sum(1,1,2))). 4 wlist(1,0,pos(atom(r)),1). wlist(1,1,pos(atom(s)),1). wlist(1,2,neg(atom(t)),1). 6 rule(pos(sum(0,2,1)),pos(conjunction(1))). % { q, r } 1 :- 1 { p, t }. 7 wlist(2,0,pos(atom(q)),1). wlist(2,1,pos(atom(r)),1). 8 set(1,pos(sum(1,0,2))). 10 rule(pos(atom(s)),pos(conjunction(2))). % s :- not q, not r. 11 set(2,neg(atom(q))). set(2,neg(atom(r))). 13 scc(0,pos(atom(p))). scc(0,pos(atom(r))). scc(0,pos(atom(t))). 14 scc(0,pos(conjunction(0))). scc(0,pos(sum(1,1,2))). 15 scc(0,pos(conjunction(1))). scc(0,pos(sum(1,0,2))). 17 minimize(1,3). % #minimize [ p = 1 @ 1, q = 1 @ 1, r = 1 @ 1, s = 1 @ 1 ]. 18 wlist(3,0,pos(atom(p)),1). wlist(3,1,pos(atom(q)),1). 19 wlist(3,2,pos(atom(r)),1). wlist(3,3,pos(atom(s)),1). Listing 1. Facts describ ing a reified e xtended logic progr am. precise, we rely upo n th e unrestricted usage of fun ction sy mbols and pro gram r eification as provided by gringo (Gebser et al. ). The latter allows f or turning an input progr am along with a # minimi ze statement into facts representin g the structure of their ground instanti- ation. For illustrating the f ormat output by gringo , consid er the facts in Line 1 –15 of Listing 1, obtained by callin g gringo with option --reify on pro gram Π 0 . Let us detail the rep re- sentation o f the rule in (2) indu cing the facts in Lin e 1 –4. The pr edicate ru le/2 is used to link the r ule head a nd body . By con vention, both are positive rule elemen ts, as ind icated via the fun ctor pos/1 . Furtherm ore, the term sum(1,0,2 ) tells us th at the head is a # s um constraint with lo wer bound 1 and (tri vial) upper bo und 2 over a list labeled 0 of we ighted literals. In fact, the included liter als are provid ed via th e facts over wl ist/4 given in Line 2, whose first arguments are 0 . While the secon d arguments, 0 and 1 , are simply indexes (enabling the representation of duplicates in m ultisets), the third on es provid e lit- erals, p an d t , each h aving the (default) weight 1 , as gi ven in the fourth ar gumen ts. Ag ain by co n vention, the body of each ru le is a conjun ction, where the term conjunction(0) in L ine 1 re fers to the set labeled 0 . Its single elemen t, a positiv e # s um constraint with lower boun d 1 and u pper b ound 2 over a list lab eled 1 , is provid ed by the fact in L ine 3 . The cor respondin g weighted litera ls ar e descr ibed by the facts in Line 4; ob serve that the negativ e literal not t is represented in terms o f the functor ne g/1 , applied to atom(t) . The ru les in (3) and (4) are rep resented analo gously in Line 6–8 and 10–11, respectively . It is still interesting to no te that recurr ences of lists of weighted liter als ( and sets) can r euse labels in troduce d before, a s done in Line 8 by r eferring to 0 . In fact, gringo identifies repe- titions o f structu ral entities and reuses labels. In ad dition to the ru les of Π 0 , th e ele ments of non-tr i vial strongly connected com ponents of its positive dependen cy graph (cf. (6) b elow) are pr ovided in Lin e 13– 15. Albeit their usag e is explained in th e next section , note already that the members of the only such comp onent, labeled 0 , in clude atoms as well as (po si- ti ve) body elem ents, i.e., con junctions and # sum constraints, con necting the com ponent. Indeed , th e existence of facts over scc/2 tells u s that Π 0 is not tight (cf. (Fages 1994)). 6 Martin Ge b ser and Rola nd Kaminski and T orsten S chaub 1 % extract rule elements 3 litb(B) :- rule(_,B). 4 litb(E) :- litb(pos(conjunction(S))), set(S,E). 5 litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). 7 eleb(P) :- litb(pos(P)). 8 eleb(N) :- litb(neg(N)). 10 elem(E) :- eleb(E). 11 elem(E) :- rule(pos(E),_). 12 elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). 13 elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). 15 % generate answer set from reified rules 17 hold(conjunction(S)) :- eleb(conjunction(S)), 18 hold(P) : set(S,pos(P)), 19 not hold(N) : set(S,neg(N)). 20 hold(sum(L,S,U)) :- eleb(sum(L,S,U)), 21 L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), 22 not hold(N) = W : wlist(S,Q,neg(N),W) ] U. 24 hold(atom(A)) :- rule(pos(atom(A)), pos( B)), hold(B). 25 L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), 26 not hold(N) = W : wlist(S,Q,neg(N),W) ] U 27 :- rule(pos(sum(L,S,U)),pos(B)), hold(B). 28 :- rule(pos(false), pos(B)), hold(B). 30 % project output to atoms of answer set 32 #hide. #show hold(atom(A)). Listing 2. Basic m eta-prog ram ( m eta.lp ) for reified extended lo gic progra ms. Now , we may compu te all five answer sets of Π 0 (given in p 0.lp ) by c ombinin g the facts in Line 1–15 of Listing 1 with the basic meta-program in Listing 2 ( meta.lp ): 2 gringo --reify p0.lp | gringo meta.lp - | clasp 0 Each an swer set o f the meta-p rogram applied to a reified prog ram c orrespon ds to an an- swer set of the reified p rogram . Mor e precisely , a set X of atoms is an answer set of the reified pro gram if f th e meta-progr am y ields an an swer set Y such that X = { a | hold(atom( a ) ) ∈ Y } , e.g., h old(atom( q )) stands f or q . As indicated in the com - ments (preced ed by % ), our meta-prog ram consists of three parts. Amo ng th e ru le e lements extracted in Line 3 –13, only those occu rring within bo dies, id entified via eleb/1 , are relev ant to the generatio n o f an swer sets sp ecified in Line 17–2 8. (Ad ditional head ele- ments, gi ven by elem/1 , are of interest in the ne xt s ection.) In fact, answer set g eneration follows the struc ture of reified p rograms, iden tifying con junctions and # sum con straints that h old 3 to fu rther d eriv e atoms occurr ing in rule h eads, either singular or within # s um constraints (cf. Line 24–27) . Line 28 deals w ith integrity constrain ts repr esented via the constant f alse in heads of reified rules. The last part in Line 32 restricts the o utput of the meta-pro gram’ s answer sets to the representatio ns o f original input atoms. Finally , no te that meta.lp do es not inspect facts representing a reified # minim ize statement, such as the ones in L ine 17–19 o f Listing 1 stemming from the statemen t in (5). 2 Follo win g Unix customs, the minus symbol “ - ” stands for the output of “ gringo --reify p0.lp . ” 3 The “ : ” connecti ve e xpands to the list of all insta nces of its left-hand side such that corresponding instances of litera ls on the right-hand side hold (cf. (Syrj ¨ anen ) and (Gebser et al. )). Complex Optimization in A nswer Set Pr ogramming 7 Such facts over minimize/2 pr ovide a priority lev el as the first argument and the lab el of a list of weig hted literals, like the o nes referred to from within terms of functor sum/3 , as the seco nd argum ent. Rather th an simp ly m irroring the standard meaning of # mi nimize statements ( by enc oding them an alogou sly to rules; cf. Line 1 7–28 of L isting 2), we suppo rt flexible customizatio ns. In f act, the next section presents our m eta-prog rams im plementing preferen ce relations and Pareto ef ficiency , as described in the backgrou nd. 4 Advanced Meta-Modeling Giv en th e re ification o f extend ed lo gic p rogram s and the encoding o f their answer sets in meta.lp , o ur approach to com plex op timization is based on the idea that an an swer set generated v ia meta.lp is optimal (an d thus acceptable) only if it is not dominated b y any other answer set. For implem enting ou r app roach, we exploit the capabilities of disjunctive ASP to comp actly represent the space o f all pote ntial co unterexamp les, viz. an swer sets dominatin g a candidate answer set at hand. T o this end, we encode the subtasks of 1. guessing an answer set as a potential counterexam ple and 2. verifying that the counterexamp le dominates a candidate answer set. A can didate answer set pa sses bo th phases if it turns o ut to be in feasible to guess a coun- terexample that d ominates it. For expressing the non-existence of cou nterexamples, we make use of an err or-indicating atom bot and saturation (Eiter and Go ttlob 1995), d eriv- ing all ato ms rep resenting the space o f coun terexamples from bot . Since the semantics of disjun cti ve ASP is based on minim ization, saturation ma kes sur e that bot is derived only if it is inevitable, i.e., if it is imp ossible to con struct a cou nterexample. Ho wever , via an integrity co nstraint, we c an stipu late bot (an d thus the non-existence of coun terexam- ples) to h old, yet witho ut p roviding any derivation of bot . In v iew of su ch a con straint and saturation, a successful can didate a nswer set is accompanied b y all atoms re presenting counterexam ples. Given that the reduct drops negati ve literals, the necessity that all atoms representin g c ounterexamp les ar e true imp lies that we cann ot use their default negation in any m eaningfu l way . Hence , we below encode potential counterexamp les, i.e., answer sets of extended p rograms, and (n on-)d ominanc e of a candidate an swer set in d isjunctive ASP without taking advantage of default negation ( used in meta.lp ). For encoding the first sub task of g uessing a co unterexample, we rely o n a cha racteriza- tion o f an swer sets in terms of an immed iate co nsequen ce o perator T (cf. ( Lloyd 1987)), defined as follows for a logic program Π an d a set X ⊆ A of atoms: T Π ( X ) = { he ad ( r ) | r ∈ Π , X | = b o dy ( r ) } . Fu rthermor e, an iterative version of T can be d efined in the fol- lowing way: T 0 Π ( X ) = X and T i +1 Π ( X ) = T i Π ( X ) ∪ T Π ( T i Π ( X )) . In the context of an extended prog ram Π , po ssibly inc luding c hoice ru les, default n egation, and up per bo unds of weight constraints, we are interested in the least fixpoint of T app lied wr t the redu ct Π X . Since a fixpoint is reached in at most | atom (Π) | application s of T , wh ere atom (Π) ⊆ A denotes the set of atom s occurr ing in Π , the least fixp oint is given by T | atom (Π) | Π X ( ∅ ) . As pointed out in (Liu an d Y ou 2010), a model X of an extended pr ogram Π is an a nswer set of Π iff T | atom (Π) | Π X ( ∅ ) = X . Fur thermore , Liu an d Y ou (201 0) show that X violates the lo op formula of some atom o r loop if X is a model, but n ot an an swer set o f Π . This proper ty motiv ates a “localization” of T on the basis of (circula r) positi ve depend encies. 8 Martin Ge b ser and Rola nd Kaminski and T orsten S chaub The (p ositive) dep endency graph of an extended pr ogram Π is given by the fo llowing pair of nodes and directed edges:  atom (Π) , { ( a, b ) | r ∈ Π , a ∈ atom ( he ad ( r ) + ) , B ∈ b o dy ( r ) + , b ∈ atom ( B + ) }  . (6) A strongly connected compon ent ( SCC) is a maxima l su bgraph of the depend ency grap h of Π such that all n odes are pairwisely co nnected via path s. An SC C is tri vial if it does not contain any edge, and n on-trivial otherwise. No te tha t th e SCCs of the d epende ncy graph of Π induce a partition of atom (Π) such that e very atom and e very loop of Π is contained in some part. Hence, we can make use of the partition to apply T separately to each part. Pr oposition 1 Let Π be an extended lo gic p rogram , C 1 , . . . , C k be the sets of atom s belo nging to the SCCs of the depend ency grap h of Π , and X ⊆ atom (Π) . Then, we hav e that T | atom (Π) | Π X ( ∅ ) = X iff S 1 ≤ j ≤ k ( T | C j | Π X ( X \ C j ) ∩ C j ) = X . The above prope rty is used in ou r encod ing of answer sets (as co unterexamp les) in dis- junctive ASP . In a nu tshell, it combines the follo wing parts: 1. guessing an interp retation, 2. deriving the error-indicating atom bot if the interpretation is no t a supported model (where each true atom occurs positively in the h ead of some r ule whose b ody holds), 3. deriving bo t if the true atoms of some non-trivial SCC ar e no t acyclicly deriv able (checked via determining the complement of a fixpoint of T ) , and 4. saturating in terpretation s that do n ot corr espond to an swer sets by deriving all tru th assignments (for atoms) from bot . Note that the third part, check ing acyclic deri vability , concentrates on atoms of non- trivial SCCs, while checking support in the second part is already sufficient fo r tri vial SCCs. The meta-pro gram in Listing 3 implemen ts t he sketched idea. In the following, we con- centrate on describing its crucial featu res. F or ev aluating support, the meta-ru les in Line 3 and 4 collect atoms having a positi ve occurrence in the head of a rule along with the rule’ s bod y . Note that, f or atoms co ntained in a # sum constraint in th e head, the asso- ciated bound s and weights are inessential in the context of support. On the other hand, the meta-rule in L ine 6 sums th e weights of all literals in a # sum co nstraint; this is n eeded to ev aluate bo unds in the sequel, wher e (n on-reified ) default n egation and u pper bou nds (acting negati vely) ar e inapplicable in vie w of saturation. The meta- rules in Line 10 –29 generate an interp retation by gu essing some truth value for eac h ato m (Line 10 ) and evaluating f urther constructs o ccurring in a reified pr ogram accordin gly (Lin e 12 –29). While the special constant fals e (u sed as head of integrity constraints) ho lds in no in terpretation ( fail (false) is a fact) and the e valuation o f conjunc tions is straightforward, m ore car e is required for e valuating # sum co nstraints. For instance, the case that a # sum co nstraint holds is in the meta-rule in Line 19–23 identified via sufficiently m any literals th at hold to achieve th e lower b ound L and also sufficiently many literals th at do not hold to fill th e gap b etween the u pper b ound U and the sum T of all weigh ts. Note th at the latter condition is encoded by th e lower bo und T-U , r ather than taking U as an upper bound (as done in meta.lp ). The complementary cases that a # sum constraint does not hold are described in the same mann er in Line 24–29, where the lower Complex Optimization in A nswer Set Pr ogramming 9 1 % extract supports of atoms and sums of weight lists’ weights 3 supp(atom(A),B) :- rule(pos(atom(A)), pos (B)). 4 supp(atom(A),B) :- rule(pos(sum(_,S,_)),pos(B)), wlist(S,_,pos(atom(A)),_). 6 sum(S,T) :- elem(sum(_,S,_)), T = #sum [ wlist(S,Q,_,W) = W ]. 8 % generate interpretation 10 true(atom(A)) | fail(atom(A)) :- elem(atom(A)). 12 fail(false). 14 true(conjunction(S)) :- elem(conjunction(S)), 15 true(P) : set(S,pos(P)), fail(N) : set(S,neg(N)). 16 fail(conjunction(S)) :- elem(conjunction(S)), set(S,pos(P)), fail(P). 17 fail(conjunction(S)) :- elem(conjunction(S)), set(S,neg(N)), true(N). 19 true(sum(L,S,U)) :- elem(sum(L,S,U)), sum(S,T), 20 L #sum [ true(P) = W : wlist(S,Q,pos(P),W), 21 fail(N) = W : wlist(S,Q,neg(N),W) ], 22 T-U #sum [ fail(P) = W : wlist(S,Q,pos(P),W), 23 true(N) = W : wlist(S,Q,neg(N),W) ]. 24 fail(sum(L,S,U)) :- elem(sum(L,S,U)), sum(S,T), 25 T-L+1 #sum [ fail(P) = W : wlist(S,Q,pos(P),W), 26 true(N) = W : wlist(S,Q,neg(N),W) ]. 27 fail(sum(L,S,U)) :- elem(sum(L,S,U)), 28 U+1 #sum [ true(P) = W : wlist(S,Q,pos(P),W), 29 fail(N) = W : wlist(S,Q,neg(N),W) ]. 31 % verify supported model properties 33 bot :- rule(pos(H),pos(B)), true(B), fail(H). 34 bot :- true(atom(A)), fail(B) : supp(atom(A),B). 36 % verify acyclic derivability 38 step(C,Z) :- scc(C,_), Z = #sum [ scc(C,pos(atom(A))) ]. 40 sccw(A) :- scc(C,pos(atom(A))), 41 fail(B) : supp(atom(A),B) : not scc(C,pos(B)). 43 wait(E,D-1) :- scc(C,pos(E)), fail(E), step(C,Z), D = 1..Z. 45 wait(atom(A),0) :- scc(C,pos(atom(A))). 46 wait(atom(A),D) :- scc(C,pos(atom(A))), sccw(A), step(C,Z), D = 1..Z, 47 wait(B,D-1) : supp(atom(A),B) : scc(C,pos(B)). 49 wait(sum(L,S,U),D-1) :- scc(C,pos(sum(L,S,U))), sum(S,T), step(C,Z), D = 1..Z, 50 T-L+1 #sum [ fail(P) = W : wlist(S,Q,pos(P),W) : not scc(C,pos(P)), 51 wait(P,D-1) = W : wlist(S,Q,pos(P),W) : scc(C,pos(P)), 52 true(N) = W : wlist(S,Q,neg(N),W) ]. 54 wait(conjunction(S),D-1) :- scc(C,pos(conjunction(S))), set(S,pos(P)), 55 scc(C,pos(P)), wait(P,D-1), step(C,Z), D = 1..Z. 57 bot :- scc(C,pos(atom(A))), true(atom(A)), wait(atom(A),Z), step(C,Z). 59 % saturate interpretations that are not answer sets 61 true(atom(A)) :- elem(atom(A)), bot. 62 fail(atom(A)) :- elem(atom(A)), bot. Listing 3. Disjun ctiv e meta-pro gram ( metaD.lp ) for reified extended logic programs. bound T-L+1 (or U+1 ) for weights o f literals that do not hold (or hold) is used to indicate a violated lo wer (or uppe r) bound of the reified # sum constraint. Giv en an interpretation of atoms an d the correspondin g truth v alues of further constru cts in an extended prog ram, the meta-rules in Lin e 33 and 34 a re used to de riv e b ot if the 10 Martin Ge b ser and Rola nd Kaminski and T orsten S chaub interpretatio n do es not provide us with a sup ported model. T o avoid such a d eriv ation of bot , e very rule of the reified program must be satis fied, an d e very true atom m ust have a positi ve occurrenc e in the head o f some rule whose body holds. It rem ains to ch eck th e acyclic d eriv ability of atoms belong ing to non-tr i vial SCCs. T o this end , the meta- rule in L ine 3 8 determ ines the nu mber Z of atoms in an SCC labele d C as the max imum step at which a fixpoin t of T , applied locally to C , is reached . Further- more, the meta-rule in Line 40–41 deriv es sccw(A) if the ato m referred to by A does not have a d eriv ation external to C . (Recall that the p ositiv e b ody elem ents of rules in ternally connectin g an SCC, i.e., rules co ntributing the SCC’ s edges to the depen dency graph, are marked by facts over scc/2 ; cf. Listing 1.) The ac yclic deriv ability of atoms indicated by sccw(A) is of par ticular interest in the sequel. In fact, our en coding identifies the com- plement of a fixpo int o f T in term s of atoms A fo r wh ich wait(atom(A),Z) is deriv ed. T o ac complish th is, th e me ta-rule in Line 45 m arks all atoms of C as underived at step 0 . As encoded via the meta- rule in Line 46– 47, an atom A stays un derived at a later step D if there is no extern al deriv ation of A ( sc cw(A) hold s) and th e bo dies B o f all compo nent- internal suppo rts of A are yet under iv ed at step D-1 ( wait(B,D-1) holds). The latter is checked via the meta-rules in Line 49– 52 and 54–5 5, r espectiv ely . The form er ap plies to # sum con straints an d id entifies cases where th e weig hts of literals th at do not h old alon g with the ones of yet underiv ed atoms of C exceed T-L , so that the lo wer bound L is not yet established. Sim ilarly , th e underiv ability o f a conjunction is recognized via a yet underived positive body element internal to the compo nent C . Also note that the falsity of elements of C is p ropaga ted via the meta-rule in L ine 43 , so that false atoms, # sum con straints, and con junction s do not contribute to d eriv ations of ato ms of C . As mention ed above, the compleme nt o f a fixpoin t of T contains the atoms A such that wait(atom(A ),Z) is ev entually der iv ed. If any such atom A is true, failure to constru ct an answer set is in di- cated by deriving bot via the meta-rule in Line 57. Finally , saturatio n of interpretations that do not co rrespon d to answer sets is acco m- plished via the meta- rules in Line 6 1 an d 6 2 o f Listing 3. T hey make sur e that bot is in- cluded in an answer set of the meta-program only if it is ine vitable wrt e very in terpretation . When considerin g th e encoding part in Listing 3 in iso lation, it like me ta.lp describes answer sets of a reified program , an d bot is d erived only if there is no such answer set. Our meta- progra ms meta.lp and metaD .lp in Listing 2 and 3 h av e n ot y et con sid- ered facts mi nimize(J,S) in re ified progr ams, r eflecting input # minimize stateme nts. In fact, com plex op timization is add ressed by the meta-program metaO.lp , shown in Listing 4. It allows f or separate optimiza tion criter ia p er prio rity level J and we ight W (in facts wlist(S, Q,E,W) ). Particular cr iteria can b e provided via the user pred icate optimize(J,W ,O) , where the values card , in cl , an d pr ef for O refer to minimal- ity r egarding cardinality , inclusion, and preferen ce (Sakama and Inoue 2000), resp ectiv ely , among the in volved liter als E . Such criteria are reflected via instances of c xopt(J,W,O) , derived via the rules in Line 7 and 8–9, where card is taken by default if no criterion is provided by the user . At each prio rity le vel J , P areto impr ovement of a counterexam- ple ( constructed v ia the rules in metaD. lp ) over all weigh ts W an d criteria O such that cxopt(J,W,O) ho lds is used for de ciding wh ether a candidate a nswer set (co nstructed via th e rules in meta.lp ) is optimal. T o this end, similarity at a prior ity level J is indicated by deriving equal(J) from equal (J,W,O) over all i nstances of cxopt(J,W,O) v ia Complex Optimization in A nswer Set Pr ogramming 11 1 % extract (complex) optimization criteria per priority level and weight 2 % (relative to user predicate optimize/3; cardinality taken by default; 3 % Pareto improveme nt over weights used for comparison at a priority level) 5 cxopt(card). cxopt(incl). cxopt(pref). 7 cxopt(J,W,O) :- minimize(J,S), wlist(S,_,_,W), cxopt(O), optimize(J,W,O). 8 cxopt(J,W,card) :- minimize(J,S), wlist(S,_,_,W), 9 not optimize(J,W,O) : optimize(J,W,O). 11 % verify dominance 13 equal(J) :- cxopt(J,_,_), equal(J,W,O) : cxopt(J,W,O). 15 chain(J1,J2) :- cxopt(J1;J2,_,_), J2 < J1, 16 not cxopt(J3,W,O) : cxopt(J3,W,O) : J2 < J3 : J3 < J1. 18 check(J2) :- cxopt(J2,_,_), not chain(J1,J2) : chain(J1,J2). 19 check(J2) :- chain(J1,J2), check(J1), equal(J1). 21 bot :- not cxopt(J,W,O) : cxopt(J,W,O). 22 bot :- check(J1), worse(J1). 23 bot :- check(J1), equal(J1), not chain(J1,J2) : chain(J1,J2). 25 % require non-existence of dominating answer set 27 :- not bot. 29 % check inclusion criteria 31 ndiff(pos(P)) :- cxopt(J,W,incl), minimize(J,S), wlist(S,_,pos(P),W), 32 true(P). 33 ndiff(pos(P)) :- cxopt(J,W,incl), minimize(J,S), wlist(S,_,pos(P),W), 34 not hold(P). 35 ndiff(neg(N)) :- cxopt(J,W,incl), minimize(J,S), wlist(S,_,neg(N),W), 36 fail(N). 37 ndiff(neg(N)) :- cxopt(J,W,incl), minimize(J,S), wlist(S,_,neg(N),W), 38 hold(N). 40 equal(J,W,incl) :- cxopt(J,W,incl), minimize(J,S), ndiff(E) : wlist(S,_,E,W). 42 worse(J) :- cxopt(J,W,incl), minimize(J,S), wlist(S,_,pos(P),W), 43 true(P), not hold(P). 44 worse(J) :- cxopt(J,W,incl), minimize(J,S), wlist(S,_,neg(N),W), 45 fail(N), hold(N). Listing 4. Meta-pr ogram for com plex optimization ( metaO. lp ) on reified logic progra ms. the rule in Lin e 13. Fu rthermor e, the rules in L ine 15– 19 are used to ch ain successive pri- ority levels, where a gr eater level J1 is more significant than its smaller neighbor J 2 , and to signal whether a prior ity level J2 is taken into acco unt. The latter is the case if equal(J1) has been deri ved at all m ore significant priority le vels J1 . If it turns out that a can didate answer set is not re futed by a dominating counter example, we derive b ot via the r ules in Line 2 1, 22, and 23: the first rule applies if there are no op timization crite- ria at all, the second one checks wh ether the co unterexample is worse (o r in comparab le), as indicated by worse(J1) at an inspected prior ity level J1 , a nd the third one detects lack of P areto improvement f rom equality at the lo west priority level. Finally , the integrity constraint in Line 27 stipulates bot to hold. Along with satura tion ( in metaD. lp ), th is implies th at a cand idate answer set (co nstructed via the rules in met a.lp ) is acce pted only if there is no dom inating co unterexample, thu s selecting exactly the op timal an swer sets of an input pr ogram. The de scribed rules serve the general purpo se of identify ing un- 12 Martin Ge b ser and Rola nd Kaminski and T orsten S chaub dominated answer sets, and th e rem ainder of metaO .lp defines eq ual(J,W,O) and worse(J) r elativ e to particular optimization criteria. Inclusion- based minim ization, in dicated via cxop t(J,W,incl) , is imp lemented b y the rules in Line 31 –45. The test for equality , attested by deriving e qual(J,W,inc l) via the rule in Line 40, is acco mplished b y checking wheth er a candidate answer set and a (co mparab le) counterexample agree o n all in volved literals E ; otherwise, ndif f(E) is not derived v ia the rules in Line 3 1–38. Furthermor e, th e coun terexample is inc omparab le to the candidate an swer set if it includes some liter al n ot shared by the latter; in s uch a case, worse(J) is deri ved via the r ules in Line 42–4 3 an d 44–4 5. In fact, the three ⊆ 1 1 -minimal answer s ets of Π 1 (given in p1. lp ), co nsisting of the rules in (2)– (4) an d the # minimi ze statement in (5) can now b e computed in the following w ay: gringo --reify p1.lp | gringo meta.lp metaD.lp metaO.lp \ <(echo "optimize(1,1,incl).") - | claspD 0 Observe that claspD (Dr escher et al. 2008), the disjun ctiv e extension of cla sp (Gebser et al. 2007), is used for solvin g the p roper disjunctive groun d pro gram obtained from gringo . In addition to inclusion -based min imization, metaO.lp implements compar isons wrt cardinality (Simo ns et al. 2002) an d literal preferen ces (Saka ma and Inoue 2000), acti- vatable via facts of the fo rm optimize(J ,W,card) and o ptimize(J,W, pref) (along with p refer(E1,E2) ) , respectively . For space reason s, the details ar e om itted here; they can be found in the extended v ersion of this paper (Gebser et al. 2011). The lat- ter also provid es formal results and argumen ts demonstrating the corr ectness of our meta- progr amming tech nique wrt the specification of optimal answer sets in the backgrou nd. Regarding the computational complexity of tas ks that can b e addressed using our meta- progr amming a pproach to o ptimization, we first note that deciding whether ther e is an optimal an swer set is in NP , as the existence of some answer set (d ecidable b y me ans of meta.lp o nly) is sufficient fo r conclud ing that there is also an optima l on e. Howe ver , th e inherent complexity beco mes mo re sen sible if we consider th e question of wh ether some atom a belo ngs to an optima l a nswer set. T o d ecide it, one can au gment the reified inp ut progr am (b ut n ot the inp ut pro gram itself), meta .lp , metaD.l p , and m etaO.lp with the integrity con straint :- not hold(atom( a )) . Then, se veral complex o ptimization criteria at a single p riority level 1 lead to comp leteness for Σ P 2 , the second lev el o f the polyno mial time h ierarchy , thus showing th at disjunctiv e ASP is appropriate t o implemen t them. T o see this, n ote th at deciding w hether an a tom a b elongs to som e answer set o f a positiv e d isjunctive logic progra m is Σ P 2 -complete (Eiter and Gottlob 1995). When dis- junctions a 1 ∨ · · · ∨ a k in the heads of rules are rewritten to 1 # sum [ a 1 = 1 , . . . , a k = 1 ] , the q uestion o f wh ether an ato m a belo ngs to an answer set of the or iginal pr ogram can be addressed by reifying the rewritten p rogram , addin g the in tegrity co nstraint :- not hold(atom( a ) ) , and ap plying meta.lp , met aD.lp , and met aO.lp wrt several o p- timization criter ia. For on e, we can include a # m inimiz e statem ent over all ato ms of the input prog ram, each associated with a d ifferent weight, to exploit the Pareto im provement implemented in met aO.lp for r efuting a can didate answer set inclu ding a if it does not correspo nd to a minimal m odel, i.e. , an answer set of the orig inal p rogram . Alternativ ely , we can include a # minimi ze statement over all a toms of th e inp ut p rogram , each hav- Complex Optimization in A nswer Set Pr ogramming 13 ing the weight 1 , and augment the meta- progr am with the f act optimize(1,1,incl ) . W e could also use a # mi nimize statement over a ll atoms a i of the input pro gram alo ng with their ne gation, each ha ving the weight 1 , and ad d the f acts op timize(1,1,p ref) as well as prefer(neg(atom ( a i )),pos(atom( a i ))) . In view of these reduction s, we co nclude that P areto efficiency , inclusion , and litera l pr eferences ind ependen tly captur e computatio nal tasks located at the second level of the p olyno mial time hierarchy , and ou r meta-pro grams allow for addr essing th em via an extend ed pro gram alo ng with facts ( and possibly also integrity constraints) steering optimization relati ve to its reificatio n. 5 Ap plications: A Case Study While the approach of Eiter and Polleres ( 2006) con sists of co mbining two sep arate logic progr ams, one for “guessing” and a second on e f or “checking, ” into a disjuncti ve pro - gram ad dressing bo th task s, our meta-pro gramming technique app lies to a single (reified) input prog ram alon g with complex optimization criteria. In fact, we provide a generic implementatio n of such criteria on top of extend ed program s enco ding solu tion spaces. Hence, our m eta-prog ramming tech nique allows f or a con venient represen tation of rea- soning task s in which testing the op timality o f solu tions to an underly ing problem in NP lifts the com plexity to Σ P 2 -hardn ess. Respecti ve f ormalisms includ e or dinary , parallel, as well as prioritized circumscrip tion (McCarthy 1980; Lifschitz 198 5), minimal con sistency- based diag nosis (Reiter 1987), and p referred extensions of argumentatio n framew orks (Dung 1995). Sim ilarly , P areto efficiency is an impor tant optimality co ndition in decision making (Chev aleyre et al. 2007) and system design ( Gries 2004). In the following, we il- lustrate th e app lication of our app roach on the examp le of an existing r eal-world applica - tion: repair wrt large gene-regulatory ne tworks (Gebser et al. 2010). Listing 5 sho ws a simplified version of the repair en coding given in (Gebser et al. 20 10). It ap plies to a regula tory network, a directed graph with (partially ) labeled edg es, repre - sented by facts of the predicates vertex/1 , edge/2 , and obs elabel/3 , where a la- bel S is 1 (activation) or -1 (inh ibition). In ad dition, the data o f e xperim ents lab eled P a re provided by facts of the predicates exp/1 , inp/2 denoting input vertices (subject to per- turbation s), and ob s vlabel/3 , wh ere a lab el S is ag ain 1 (increase) or -1 (d ecrease). The regulato ry network is co nsistent with the experiment data if ther e are to tal labelin gs of edges an d vertices (for each experimen t P ) such that the label of every no n-inpu t ver- tex V is explain ed b y th e influence of som e of its r egulators U , wher e the influ ence is the produ ct S * T of the edge label S and the lab el T of U ( in exper iment P ). I n th e pr actice of systems b iology , regulatory networks and expe riment data often turn out to be mutu ally in- consistent, which m akes it highly n on-trivial to draw biologically meanin gful conclusions in an autom ated way . T o address this shortage, several repair o perations were devised in (Gebser et al. 2010), which can be enabled via f acts o f the form repa ir(K,J,W) , where K indicates a cer tain kind of admissible r epair oper ations, J a priority le vel, and W a weight. The repair oper ations R to app ly are selected via the rule in L ine 14 of Listing 5, an d their effects are prop agated v ia the rules in Line 18–2 9, thu s o btaining total ed ge an d vertex labelings witnessing the reestablishment of co nsistency . Gi ven that applica tions o f repair operation s modify a regulatory network or experimen t data, we are in terested in applying few operation s o nly , which is expr essed by the # minimize statement in Line 33. 14 Martin Ge b ser and Rola nd Kaminski and T orsten S chaub 1 % auxiliary concepts 3 sign(-1;1). 4 complement(S,-S) :- sign(S). 6 % construct candidate repair 8 pos(aedge(U,V), J,W) :- repair(aedge,J,W), vertex(U;V), U != V. 9 pos(eflip(U,V,S),J,W) :- repair(eflip,J,W), obs_elabel(U,V,S). 10 pos(ivert(V), J,W) :- repair(ivert,J,W), vertex(V). 11 pos(pvert(P,V), J,W) :- repair(pvert,J,W), exp(P), vertex(V). 12 pos(vflip(P,V,S),J,W) :- repair(vflip,J,W), obs_vlabel(P,V,S). 14 { apply(R) } :- pos(R,_,_). 16 % construct consistent total labelings 18 elabel(U,V,S) :- not apply(eflip(U,V,S)), obs_elabel(U,V,S). 19 elabel(U,V,T) :- apply(eflip(U,V,S)), complement(S,T). 20 elabel(U,V,S) :- apply(aedge(U,V)), not elabel(U,V,T), complement(S,T). 21 elabel(U,V,S) :- edge(U,V), not elabel(U,V,T), complement(S,T). 23 vlabel(P,V,S) :- not apply(vflip(P,V,S)), obs_vlabel(P,V,S). 24 vlabel(P,V,T) :- apply(vflip(P,V,S)), complement(S,T). 25 vlabel(P,V,S) :- not vlabel(P,V,T), complement(S,T), exp(P), vertex(V). 27 inf(P,V,S * T) :- elabel(U,V,S), vlabel(P,U,T), not inp(P,V). 29 :- vlabel(P,V,S), not inf(P,V,S), not inp(P,V), not apply(ivert(V);pvert(P,V)). 31 % optimize repair 33 #minimize [ apply(R) = W @ J : pos(R,J,W) ]. Listing 5. E ncoding of repair wrt regulatory ne tworks and expe riment data ( repair.lp ). A reasonable repair configuration could consist of facts of the follo wing form: repair(ivert ,J 1 ,W 1 ). admitting to turn vertices into inputs in all experimen ts. repair(eflip ,J 2 ,W 2 ). admitting network modifications by flipping edge labels. repair(pvert ,J 3 ,W 3 ). admitting to turn vertices into inputs in specific experim ents. repair(vflip ,J 4 ,W 4 ). admitting data modifications by flipping vertex labels. While the kinds of r epair referr ed to by ivert and eflip o perate prima rily on a network (in vie w o f incompleteness or incorrec tness), the ones denoted by pvert and vflip mainly add ress the d ata (which can be noisy). If we penalize all repair oper ations uni- formly via J = J 1 = J 2 = J 3 = J 4 and W = W 1 = W 2 = W 3 = W 4 , the in stantiation of th e # minimi ze statement in Line 33 repr esents ordinary cardinality- based o ptimization, as- sembled in solvers like clasp an d smodels . Ho wever , by adding optimiz e(J,W,incl) as a fact, we can easily switch to in clusion-b ased minimization an d use a disjunctive solver like cla spD to solve the more comp lex p roblem. While our meta-pro grams enable such a shift of optimization criteria by m eans of a dding just on e fact, a direct disjunc ti ve en- coding o f inclusio n-based minimization has been pr ovided in (Gebser et al. 20 10); note that th e latter is by far mo re inv olved than the basic rep air encod ing in Listing 5. Fu rther- more, our meta-prog ramming appro ach allows us to d istinguish between different kind s of repair ope rations (withou t prior itizing them) an d optim ize wrt P areto efficiency . T o accom- plish this, one only nee ds to pick unequa l values for W 1 , . . . , W 4 , where card inality-based minimization wr t eac h W i can selecti vely be replaced by inclusion v ia providin g a fact optimize(J,W i ,incl) . Finally , we can choose to rank kinds o f r epair operations b y Complex Optimization in A nswer Set Pr ogramming 15 providing d ifferent priority le vels J 1 , . . . , J 4 . In this r espect, the flexibility gained due to me ta-prog ramming allo ws fo r deployin g and c omparin g different optimization criter ia, e.g., regarding the accuracy of resulting predictions (cf. (Gebser et al. 2010)). For g iving an account of the pr actical cap abilities of o ur m eta-prog ramming appro ach, we emp irically comp ared it to the direct encod ing of in clusion-based min imization in (Gebser et al. 2010). T o this en d, we ran gringo version 3.0 .3 and claspD version 1.1 on 100 in stances wrt thr ee kind s of admissible repair operation s, resulting in 30 0 run s each with o ur meta- progr ams an d with the direct e ncoding . All r uns have been pe rformed se- quentially on a m achine e quipped with Intel Xeon E552 0 pro cessors and 48 GB main memory und er L inux, imposing a time limit of 4 000 sec p er run. T o our own sur prise, more ru ns wer e com pleted in tim e with the meta- progra ms than with the d irect en coding : 219 versus 1 50. 4 The d isadvantages o f the direct encoding sh ow th at f urther gear ing would be required to improve solv ing ef ficiency , which adds to the dif ficulty of furnishing a func- tional saturation-based encoding. I n vie w of th is, we conclude that ou r m eta-prog ramming approa ch to co mplex optimization is an eligible and viable alternati ve. Ho we ver , en hance- ments of disjunctive ASP solvers boosting its performan ce would still be desirable. 6 Discussion Our integral ap proach to modeling co mplex o ptimization criteria in ASP brin gs about a number of individual contr ibutions. T o begin with, we introduce the reification capaci- ties of ou r g round er gringo along with the assoc iated meta-en coding, paving the way to the imme diate av ailability of meta-m odeling techniq ues. In fact, the full version of the basic meta-enco ding in Listing 1, ob tainable at (metasp ), covers the com plete languag e of gringo , in cluding d isjunctions and d iv erse agg regates. Moreover, our meta-modeling technique s provide a general account of saturatio n and, thus, abolish its co mpulsory repli- cation fo r expressing complex pref erences. Of particular in terest is the stability pr operty of an swer sets servin g as implicit counterexamples. Unlike the appro ach of Eiter an d Polleres (2 006), our en coding av oids “g uessing” level mapping s. Also, our target lan - guage in volves cho ice rules and # sum constraints (Simo ns et al. 2002), and we are un- aware of any pre-existing meta-enco ding of cor respond ing answer sets, ne ither as candi- dates nor as counterexam ples. Like wise, related meta- progr amming appro aches for gen- erating consequen ces of logic program s (Faber and W oltran 20 09) or explanation s wrt de- bugging qu eries (Oetsch et al. 2010) do not con sider su ch aggregates (but disjunctions in object programs) . W e exploit the two-dimensionality of # minim ize statements by using le vels an d weights f or com bining a lexicograp hic ranking with Pareto efficiency . At each level, group s of literals sharing the same weight can be compar ed wrt in clusion. This is ex- tended in (Gebser et al. 2011) by cardinality-based min imization and the f ramework of (Sakama and Inoue 2000), relying on a prefer ence relation among literals (gi ven in ad- dition to # mi nimize statements); the augm ented encod ing is also av ailable at (metasp ). In fact, th e app roach o f Section 4 allows for captur ing the special cases of parallel an d 4 All instance s and detaile d results are av ail able at (metasp ). 16 Martin Ge b ser and Rola nd Kaminski and T orsten S chaub prioritized circumscr iption, in vestigated b y Janhu nen and Oikarinen in (200 4; 2008). An interesting future extension is the en coding of optimality cond itions f or logic pr ograms with orde red disjunction (Bre wka et al. 2004), whose custom -made implementation in the prototy pe psmodels interleav es two smodels or acles for accomplishing a generate- and-test approa ch similar to the idea of our me ta-progr ams. Ultim ately , our ap proach could serve as an imp lementation platf orm fo r answer set optimization (Brewka et a l. 2003) an d th e preferen ce description lan guage pr oposed in (Brewka 2004). Last but not least, our m eta- progr ams furnish a rich and readily available source o f Σ P 2 -hard c hallenge p roblems, fos- tering the dev elopmen t o f ASP solvers f or disjunctive log ic programming . Acknowledgments. This work was par tly fund ed by DFG gra nt SCHA 550/8- 2. W e ar e grateful to T omi Janhunen , I lkka Niemel ¨ a, and the referees for their helpful comments. References B A R A L , C . 2003. Knowledge Repr esentation , Reasoning and Declarative Pr oblem Solving . Cam- bridge Univ ersity Press. B R E W K A , G . 2004. Answer sets: From con straint programming to wards qualitati ve optimization. In Pr oceedings of the Seve nth International Confer ence on Logic Pr ogr amming and Nonmonotonic Reasoning (LP N MR’04) , V . Lifschitz and I. Niemel ¨ a, E ds. Lecture Notes in Artifi cial Intelligence, vol. 2923 . Springer-V erlag, 34–46. B R E W K A , G . , N I E M E L ¨ A , I . , A N D S Y R J ¨ A N E N , T. 2004. Logic programs with ordered disjunction. Computational Intelligence 20, 2, 335–357 . B R E W K A , G . , N I E M E L ¨ A , I . , A N D T R U S Z C Z Y N S K I , M . 2003. A nswer set optimization. In Pro- ceedings of the Eighteenth International J oint Conferen ce on Artificial Intelligence (IJCA I’03) , G. Gottlob and T . W alsh, Eds. M organ Kaufmann Publishers, 867–8 72. C H E V A L E Y R E , Y . , E N D R I S S , U ., L A N G , J . , A N D M AU D E T , N . 2007. A short introduction to com- putational social choice. In Pr oceedings of the T hirty-thir d Conferen ce on Curr ent Tr ends in Theory and Practice of Computer Science ( SOFSEM’07) , J. v an Leeuwen, G. Italiano, W . van der Hoek, C. Meinel, H. S ack, and F . Plasil, E ds. Lecture Notes in Computer S cience, vol. 4362. Springer-V erlag, 51–69 . D E L G R A N D E , J . , S C H AU B , T . , A N D T O M P I T S , H . 2003. A framew ork for co mpiling preference s in logic programs. Theory and Practice of Logic P r ogr amming 3, 2, 129–187 . D R E S C H E R , C . , G E B S E R , M . , G R OT E , T., K A U F M A N N , B . , K ¨ O N I G , A ., O S T R O W S K I , M . , A N D S C H AU B , T. 2008 . Conflict-driven disjuncti ve answer set solv ing. In P r oceedings of the Eleventh International Confer ence on P rinciples of Knowledg e Repr esentation and Reasoning (KR’08) , G. Brewka and J. Lang, Eds. AAAI Press, 422 –432. D U N G , P. 1995. O n the acceptability of arguments and its fundamental role in nonmon otonic rea- soning, logic programming and n -person games. Artificial Intelligence 77, 2, 321– 357. E I T E R , T. , F A B E R , W . , L E O N E , N . , A N D P F E I F E R , G . 2003. Computing preferred answer sets by meta-interpretation in answer set prog ramming. Theory and Practice of L ogic Pr ogr amming 3, 4- 5, 463–498 . E I T E R , T. A N D G O T T L O B , G . 1995. On the computational cost of disjunctiv e logic programming: Propositional case. Annals of Mathematics and Artificial Intellige nce 15, 3-4, 289–323. E I T E R , T. A N D P O L L E R E S , A . 2006. T owards automated integ ration of guess and check programs in answer set programming: a meta-interpreter and applications. T heory and P ractice of Logic Pr ogr amming 6, 1-2, 23–60. F A B E R , W. A N D W O LT R A N , S . 2009. Manifold answer-set programs for meta-reasoning. In P ro- ceedings of the T enth Internationa l Confer ence on Logic Pro gr amming and Nonmonotonic R ea- Complex Optimization in A nswer Set Pr ogramming 17 soning (LPN MR’09) , E. Erdem, F . Lin, and T . S chaub, Eds. L ecture Notes i n Artificial Intelligence, vol. 5753 . Springer-V erlag, 115–128. F AG E S , F. 1994. Consistenc y of Clark’ s completion and the existence of stable models. Jou rnal of Methods of Logic in Computer Science 1 , 51–60. F E R R A R I S , P . 2005. Answer sets for proposition al t heories. In P r oceeding s of the Eighth Interna- tional Confer ence on Logic Pr ogr amming and Nonmon otonic Reasoning (LPNMR’05) , C. B aral, G. Greco, N. Leone, and G. T erracina, Eds. L ecture Notes in Artificial Intelligence, vol. 3662. Springer-V erlag, 119–1 31. G A R E Y , M . A N D J O H N S O N , D . 1979. Computers and Intractability: A Guide t o the Theory of NP-Completeness . W . Freeman and Co. G E B S E R , M ., G U Z I O L O W S K I , C . , I V A N C H E V , M ., S C H AU B , T. , S I E G E L , A . , T H I E L E , S . , A N D V E B E R , P. 2010. Repair and prediction (under inconsistenc y) in l arge biological networks with answer set programming. In Pr oceedings of the T welfth International C onfer ence on Principles of Knowledge Represen tation and Reasoning (KR’10) , F . Lin and U. Satt ler, Eds. AAAI Press, 497–50 7. G E B S E R , M ., K A M I N S K I , R . , K AU F M A N N , B . , O S T R O W S K I , M . , S C H AU B , T., A N D T H I E L E , S . A user’ s guide to gringo , clasp , clingo , and iclingo . A vailable at http://potassco.sou rceforge.net . G E B S E R , M . , K A M I N S K I , R . , A N D S C H AU B , T. 2011. Complex optimization in answer set pro- gramming: Extended version. A v ailable at (metasp ). ( This i s an ex tended version of the paper at hand. ) G E B S E R , M . , K AU F M A N N , B . , N E U M A N N , A . , A N D S C H AU B , T. 2 007. Conflict-driv en answer set solving. In P r oceedings of t he T wen tieth Internation al Joint Conferen ce on Artificial Intellige nce (IJCAI’07) , M. V eloso, Ed. AAAI Press/T he MIT Press, 386– 392. G E L F O N D , M . A N D L I F S C H I T Z , V . 1991. Classical negation i n logic programs and disjuncti ve databases. New Generation Computing 9 , 365–385. G R I E S , M . 2004. Methods for ev aluating and cov ering the design space during early design dev el- opment. Inte gration 38, 2, 131– 183. J A N H U N E N , T . A N D O I K A R I N E N , E . 200 4. Capturing parallel circumscription with disjunctiv e logic programs. In Pr oceedings of the Ninth Eur opea n Confere nce on Logics in Artificial Intelligence (JELIA’04 ) , J. Alferes and J. Leite, Eds. Lecture Notes in Computer Science, v ol. 3229. Springer- V erlag, 134–146. L E O N E , N . , P F E I F E R , G . , F A B E R , W . , E I T E R , T., G O T T L O B , G . , P E R R I , S . , A N D S C A R C E L L O , F. 2006. The DL V system for knowledge representation and reasoning. ACM Tr ansactions on Computational Logic 7, 3, 499–562 . L I F S C H I T Z , V . 1985. Computing circumscription. In Pr oceedings of the Ninth International Joint Confer ence on Arti ficial Intelligence (IJCAI’85) , A. Joshi, Ed. Morgan Kaufmann Publishers, 121– 127. L I U , G . A N D Y O U , J . 2010. Level mapping induced loop formulas for weight constraint and aggre- gate logic programs. Fundamenta Informaticae 101, 3, 237–255. L L O Y D , J . 1987. F oundations of L ogic Pr ogr amming , 2nd ed. Symbolic Computation. S pringer- V erlag. M C C A RT H Y , J . 1980. Circumscription — a form of nonmonotonic reasoning. Artificial Intelli - gence 13, 1-2, 27–39 . M E TA S P . http://www. cs.uni-potsdam .de/wv/metasp . O E T S C H , J . , P ¨ U H R E R , J . , A N D T O M P I T S , H . 2010. Catching the ouroboros: On debug ging non- ground answer-se t programs. Theory and Practice of Logic Pr o gramming . T w enty-sixth Interna- tional Confer ence on Logic Pr ogr amming (ICLP ’10) Special Issue 10, 4-6, 513–529. O I K A R I N E N , E . A N D J A N H U N E N , T. 2008. Implementing prioritized circumsc ription by co mputing 18 Martin Ge b ser and Rola nd Kaminski and T orsten S chaub disjuncti ve stable models. In Proc eedings of the Thirteenth International Confer ence on Artificial Intelligence: Methodolog y , Systems, and Applications (A IMSA ’08) , D. Doche v, M. Pistore, and P . Tra verso, Eds. Lecture Notes in Artificial Intelligence , vol. 5253. Springer-V erlag, 167–18 0. R E I T E R , R . 1987. A theory of diagnosis from fi rst principles. Art ificial Intelligence 32, 1, 57–96. S A K A M A , C . A N D I N O U E , K . 2000. Prioritized logic programming and its application to common- sense reasoning. Artificial Intelligence 123, 1-2, 185–222 . S I M O N S , P ., N I E M E L ¨ A , I . , A N D S O I N I N E N , T. 200 2. Extending and impleme nting the stable mo del semantics. Artificial Intelligence 138, 1-2, 181–234. S Y R J ¨ A N E N , T. L parse 1.0 user’ s man ual. A vailable at http://www.tcs.hut. fi/Software/s models/lparse.ps.gz .

Original Paper

Loading high-quality paper...

Comments & Academic Discussion

Loading comments...

Leave a Comment