More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Knowledge Representation for the Semantic Web Lecture 7: Answer Set Programming II Daria Stepanova partially based on slides by Thomas Eiter D5: Databases and Information Systems Max Planck Institute for Informatics WS 2017/18 1 / 39
More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Unit Outline More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers 2 / 39
❼ ❼ ❼ ❼ More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Strong Negation ❼ Default negation “ not a ” means “ a cannot be proved (derived) using rules,” and that a is false by default (believed to be false). 3 / 39
❼ ❼ More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Strong Negation ❼ Default negation “ not a ” means “ a cannot be proved (derived) using rules,” and that a is false by default (believed to be false). ❼ Strong negation ¬ a (also − a ) means that a is (provably) false ❼ Both default and strong negation can be used in ASP 3 / 39
More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Strong Negation ❼ Default negation “ not a ” means “ a cannot be proved (derived) using rules,” and that a is false by default (believed to be false). ❼ Strong negation ¬ a (also − a ) means that a is (provably) false ❼ Both default and strong negation can be used in ASP “At a railroad crossing, cross the rails if no train approaches.” We may encode this scenario using one of the following two rules: walk ← at ( X ) , crossing ( X ) , not train approaches ( X ) . ( r 1 ) walk ← at ( X ) , crossing ( X ) , − train approaches ( X ) . ( r 2 ) ❼ r 1 fires if there is no information that a train approaches. ❼ r 2 fires if it is explictly known that no train approaches. 3 / 39
More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Constraints ❼ Constraints are rules with empty head which exclude invalid models. ← q 1 , . . . , q m , not r 1 , . . . , not r n . kills answer sets that ❼ contain q 1 , . . . , q m , and ❼ do not contain r 1 , . . . , r n . 4 / 39
More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Constraints ❼ Constraints are rules with empty head which exclude invalid models. ← q 1 , . . . , q m , not r 1 , . . . , not r n . kills answer sets that ❼ contain q 1 , . . . , q m , and ❼ do not contain r 1 , . . . , r n . An equivalent version of the above rule is with a fresh predicate p : p ← q 1 , . . . , q m , not r 1 , . . . , not r n , not p. 4 / 39
More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Constraints ❼ Constraints are rules with empty head which exclude invalid models. ← q 1 , . . . , q m , not r 1 , . . . , not r n . kills answer sets that ❼ contain q 1 , . . . , q m , and ❼ do not contain r 1 , . . . , r n . An equivalent version of the above rule is with a fresh predicate p : p ← q 1 , . . . , q m , not r 1 , . . . , not r n , not p. Example: adjacent nodes cannot be colored with the same color ⊥ ← edge ( X , Y ) , colored ( X , Z ) , colored ( Y , Z ) . 4 / 39
❼ More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Disjunction The use of disjunction is natural ❼ to express indefinite knowledge: female ( X ) ∨ male ( X ) ← person ( X ) . broken ( left arm , robot1 ) ∨ broken ( right arm , robot1 ) . 5 / 39
More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Disjunction The use of disjunction is natural ❼ to express indefinite knowledge: female ( X ) ∨ male ( X ) ← person ( X ) . broken ( left arm , robot1 ) ∨ broken ( right arm , robot1 ) . ❼ to express a “guess” and to create non-determinism. ok ( C ) ∨ − ok ( C ) ← component ( C ) . 5 / 39
❼ ❼ More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Minimality ❼ Semantics: disjunction is minimal (different from classical logic): a ∨ b ∨ c. 6 / 39
❼ ❼ More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Minimality ❼ Semantics: disjunction is minimal (different from classical logic): a ∨ b ∨ c. Minimal models: { a } , { b } , and { c } . 6 / 39
❼ More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Minimality ❼ Semantics: disjunction is minimal (different from classical logic): a ∨ b ∨ c. Minimal models: { a } , { b } , and { c } . ❼ Actually subset minimal: a ∨ b. a ∨ c. 6 / 39
❼ More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Minimality ❼ Semantics: disjunction is minimal (different from classical logic): a ∨ b ∨ c. Minimal models: { a } , { b } , and { c } . ❼ Actually subset minimal: a ∨ b. a ∨ c. Minimal models: { a } and { b, c } . 6 / 39
❼ More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Minimality ❼ Semantics: disjunction is minimal (different from classical logic): a ∨ b ∨ c. Minimal models: { a } , { b } , and { c } . ❼ Actually subset minimal: a ∨ b. a ∨ c. Minimal models: { a } and { b, c } . a ∨ b. a ← b. 6 / 39
❼ More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Minimality ❼ Semantics: disjunction is minimal (different from classical logic): a ∨ b ∨ c. Minimal models: { a } , { b } , and { c } . ❼ Actually subset minimal: a ∨ b. a ∨ c. Minimal models: { a } and { b, c } . a ∨ b. a ← b. Models: { a } and { a, b } , but only { a } is minimal. 6 / 39
More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Minimality ❼ Semantics: disjunction is minimal (different from classical logic): a ∨ b ∨ c. Minimal models: { a } , { b } , and { c } . ❼ Actually subset minimal: a ∨ b. a ∨ c. Minimal models: { a } and { b, c } . a ∨ b. a ← b. Models: { a } and { a, b } , but only { a } is minimal. ❼ But minimality is not necessarily exclusive: a ∨ b. b ∨ c. a ∨ c. 6 / 39
More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Minimality ❼ Semantics: disjunction is minimal (different from classical logic): a ∨ b ∨ c. Minimal models: { a } , { b } , and { c } . ❼ Actually subset minimal: a ∨ b. a ∨ c. Minimal models: { a } and { b, c } . a ∨ b. a ← b. Models: { a } and { a, b } , but only { a } is minimal. ❼ But minimality is not necessarily exclusive: a ∨ b. b ∨ c. a ∨ c. Minimal models: { a, b } , { a, c } , and { b, c } . 6 / 39
❼ ❼ ❼ ❼ ❼ More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Extended Logic Programs with Disjunctions Extended Logic Programs An extended disjunctive logic program (EDLP) is a finite set of rules a 1 ∨ · · · ∨ a k ← b 1 , . . . , b m , not c 1 , . . . , not c n ( k, m, n ≥ 0) (1) where all a i , b j , c l are atoms or strongly negated atoms. 7 / 39
❼ ❼ ❼ ❼ More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Extended Logic Programs with Disjunctions Extended Logic Programs An extended disjunctive logic program (EDLP) is a finite set of rules a 1 ∨ · · · ∨ a k ← b 1 , . . . , b m , not c 1 , . . . , not c n ( k, m, n ≥ 0) (1) where all a i , b j , c l are atoms or strongly negated atoms. Semantics: ❼ Stable models (answer sets) of EDLPs are defined similarly as for LPs, viewing − p as a new predicate. 7 / 39
❼ More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Extended Logic Programs with Disjunctions Extended Logic Programs An extended disjunctive logic program (EDLP) is a finite set of rules a 1 ∨ · · · ∨ a k ← b 1 , . . . , b m , not c 1 , . . . , not c n ( k, m, n ≥ 0) (1) where all a i , b j , c l are atoms or strongly negated atoms. Semantics: ❼ Stable models (answer sets) of EDLPs are defined similarly as for LPs, viewing − p as a new predicate. ❼ Differences: ❼ I must not contain atoms p ( c 1 , . . . , c n ) , − p ( c 1 , . . . , c n ) (consistency) ❼ I is a model of ground rule (1), if either { b 1 , . . . , b m } � I or { a 1 , . . . , a k , c 1 , . . . , c n } ∩ I � = ∅ . 7 / 39
More about Logic Programs ASP Paradigm Programming Techniques Answer Set Solvers Extended Logic Programs with Disjunctions Extended Logic Programs An extended disjunctive logic program (EDLP) is a finite set of rules a 1 ∨ · · · ∨ a k ← b 1 , . . . , b m , not c 1 , . . . , not c n ( k, m, n ≥ 0) (1) where all a i , b j , c l are atoms or strongly negated atoms. Semantics: ❼ Stable models (answer sets) of EDLPs are defined similarly as for LPs, viewing − p as a new predicate. ❼ Differences: ❼ I must not contain atoms p ( c 1 , . . . , c n ) , − p ( c 1 , . . . , c n ) (consistency) ❼ I is a model of ground rule (1), if either { b 1 , . . . , b m } � I or { a 1 , . . . , a k , c 1 , . . . , c n } ∩ I � = ∅ . ❼ Condition “ M is the least model of P M ” is replaced by “ M is a minimal model of P M ” ( P M may have multiple minimal models). 7 / 39
Recommend
More recommend