90 likes | 265 Views
Normal Programs with Cardinality Constraints. C = L {a 1 , ..., a n , not b 1 , ..., not b m } U L lower bound, U upper bound (missing L: 0, missing U: n+m) Lit(C) = {a 1 , ..., a n , not b 1 , ..., not b m } intuition: at least L, at most U literals must be true
E N D
Normal Programs with Cardinality Constraints C = L {a1, ..., an, not b1, ..., not bm} U L lower bound, U upper bound (missing L: 0, missing U: n+m) Lit(C) = {a1, ..., an, not b1, ..., not bm} intuition: at least L, at most U literals must be true rules built from constraints: C0 <- C1, ..., Cn example: 2{a1, a2, a3}2 <- 1{not b1, not b2}, 2{c1, c2, c3, c4}3 at least one b not in model and 2 or 3 c‘s in => 2 a‘s in. normal programs: all constraints of the form 1{a}1 oder 1{not a}1
Satisfaction of constraints in set of literals S S |= a iff a S, S|= not a iff a S. S |= C iff L W(C,S) U, where W(C,S) = | {l Lit(C) : S |= l}| rule C0 <- C1, ..., Cn satisfied in S iff some body constraint not satisfied or C0 satisfied (integrity constraints: first option only) Example: 1{a,b}1 <- 1 {a, not b, not c} 2 S = {a,b}. body satisfied, head not => rule not satisfied S = {a, c}. body and head constraint and thus rule satisfied
Stablemodels Standard approach: guess S, evaluate „not“ wrt S => reduced program, check whether S minimal model of reduced program Here: reduction to Horn constraint rules: no „not“, no upper bounds, single head atom => Cn(P) smallest set closed under rules Example: a <- 1 {a} b <- c <- 2 {b,d}, 1 {b,a} d <- 1 {a,b,c} Cn(P) = {b} Cn(P) = {b, d, c}
Constraint reduction C = L {a1, ..., an, not b1, ..., not bm} U CS = L´{a1, …, an}where L´ = L - |{not b Lit(C) : S |= not b}| Example: S = {q}, C = 3 {not q, not r, p} 4, reduct: 2 {p} P program, S set of atoms. Reduct PS: {p <- C1S, ..., CnS: C0 <- C1, ..., Cn P, p Lit(C0) S,for all Ci = Li{a1,…}Ui, i {1, …, n}, W(Ci,S) Ui} Def.: S stable model of P iff 1. S satisfies all rules in P 2. S = Cn(PS)
Examples 1 {a1, a2, a3} 1 <- stable models: {a1}, {a2}, {a3} 1 {a1, a2, a3} 1 <- 1 {a1,b} 2 single stable model: empty set {a1, a2, a3} <- stable models: alle subsets of the three a‘s rules of this form are also called choice rules
Weight Constraints C = L {a1 = wa1, ..., an = wan, not b1 = wb1, …, not bm = wbm} U arbitrary weights (card. constraints weight 1 for all literals) implemented in Smodels: integers weight of l in C: w(C)(l) necessary changes: W(C,S) = l Lit(C),S |= l w(C)(l) and in definition of constraint reduct: L’ = L - not p Lit(C) and S |= not p w(C)(l)
Smodels optimization constructs minimize{a1 = wa1, ..., an = wan, not b1 = wb1, …, not bm = wbm} stable model computed by Smodels minimizes l in L and S |= l w(C)(l) (L = {a1, ..., an, not b1, ..., not bm}) maximize analogously multiple optimization statements: optimize first one, among optimal models optimize second one etc.
Smodels optimization example {a1, a2, a3} <- minimize {a1 = 1}minimize {a2 = 1}minimize {a3 = 1} 1. { } 2. { a3} 3. { a2 } 4. { a2 a3} 5. {a1 } 6. {a1 a3} 7. {a1 a2 } 8. {a1 a2 a3}
Notation 1{teaches(L,C) : lecturer(L)}1 <- course(C) to obtain ground instantiation: instatiate C, replace each instatiation of the form 1{teaches(L,c1) : lecturer(L)}1 <- course(c1) with 1{teaches(l1,c1), ..., teaches(ln,c1)}1 <- course(c1) where l1, ..., ln are the known lecturers