Successfully reported this slideshow.
Upcoming SlideShare
×

# Exchanging More than Complete Data

1,192 views

Published on

Published in: Technology
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

### Exchanging More than Complete Data

1. 1. An Answer Set Programming Tutorial Minh Dao-Tran Institut für Informationsysteme, TU WienSupported by Austrian Science Fund (FWF) project P20841, and the Marie Curie action IRSES under Grant No. 2476Based on slides from Thomas Eiter, Giovambattista Ianni, Thomas Krennwallner in the Reasoning Web Summer School 2009 and slides from Torsten Schaub DERI, July 2011
2. 2. An Answer Set Programming Tutorial Outline 1. Introduction 2. Horn Logic Programming 2.1 Positive Logic Programs 2.2 Minimal Model Semantics 3. Stable Logic Programming 4. Extensions 4.1 Disjunction 4.2 Integrity Constraints 5. Answer Set for the Semantic Web 5.1 DL-Programs 5.2 HEX-Programs 6. Future Directions of ASP Minh Dao-Tran DERI, July 2011 1/33
3. 3. An Answer Set Programming Tutorial 1. Introduction Introduction Answer Set Programming (ASP) is a recent problem solving approach ASP has its roots in: • (logic-based) knowledge representation and reasoning • (deductive) databases • constraint solving, SAT solving • logic programming (with negation) ASP allows for solving all search problems in NP (and NPNP ) in a uniform way Minh Dao-Tran DERI, July 2011 2/33
4. 4. An Answer Set Programming Tutorial 1. Introduction Knapsack Problem Minh Dao-Tran DERI, July 2011 3/33
5. 5. An Answer Set Programming Tutorial 1. Introduction Sudoku 6 1 4 5 8 3 5 6 2 1 8 4 7 6 6 3 7 9 1 4 5 2 7 2 6 9 4 5 8 7 Task: Fill in the grid so that every row, every column, and every 3x3 box contains the digits 1 through 9. Minh Dao-Tran DERI, July 2011 4/33
6. 6. An Answer Set Programming Tutorial 1. Introduction Wanted! A general-purpose, declarative approach for modeling and solving these and many other problems. Declarative: • “What is the problem?” instead of • “How to solve the problem?” Minh Dao-Tran DERI, July 2011 5/33
7. 7. An Answer Set Programming Tutorial 1. Introduction Wanted! A general-purpose, declarative approach for modeling and solving these and many other problems. Declarative: • “What is the problem?” instead of • “How to solve the problem?” Proposal: Answer Set Programming (ASP) paradigm! Minh Dao-Tran DERI, July 2011 5/33
8. 8. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.1 Positive Logic Programs Positive Logic Programs Deﬁnition (Positive Logic Program) A positive logic program P is a ﬁnite set of clauses (rules) in the form a ← b1 , . . . , bm where a, b1 , . . . , bm are atoms of a ﬁrst-order language L. a is the head of the rule b1 , . . . , bm is the body of the rule. If m = 0, the rule is a fact (written shortly a) Minh Dao-Tran DERI, July 2011 6/33
9. 9. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.1 Positive Logic Programs Positive Logic Programs Deﬁnition (Positive Logic Program) A positive logic program P is a ﬁnite set of clauses (rules) in the form a ← b1 , . . . , bm where a, b1 , . . . , bm are atoms of a ﬁrst-order language L. a is the head of the rule b1 , . . . , bm is the body of the rule. If m = 0, the rule is a fact (written shortly a) Example prof (supervisor(X)) ← phd_student(X). poor(X) ← phd_student(X). phd_student(Y) ← phd_student(X), couple(X, Y). Minh Dao-Tran DERI, July 2011 6/33
10. 10. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.1 Positive Logic Programs Herbrand Semantics by an Example A logic program P: prof (supervisor(X)) ← phd_student(X). phd_student(peter). poor(X) ← phd_student(X). couple(peter, jane). phd_student(Y) ← phd_student(X), couple(X, Y). Constant symbols: peter, jane; Function symbols: supervisor. Minh Dao-Tran DERI, July 2011 7/33
11. 11. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.1 Positive Logic Programs Herbrand Semantics by an Example A logic program P: prof (supervisor(X)) ← phd_student(X). phd_student(peter). poor(X) ← phd_student(X). couple(peter, jane). phd_student(Y) ← phd_student(X), couple(X, Y). Constant symbols: peter, jane; Function symbols: supervisor. Herbrand Universe peter, supervisor(peter), supervisor(supervisor(peter)), . . . , HU(P) = jane, supervisor(jane), supervisor(supervisor(jane)), . . . Minh Dao-Tran DERI, July 2011 7/33
12. 12. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.1 Positive Logic Programs Herbrand Semantics by an Example A logic program P: prof (supervisor(X)) ← phd_student(X). phd_student(peter). poor(X) ← phd_student(X). couple(peter, jane). phd_student(Y) ← phd_student(X), couple(X, Y). Constant symbols: peter, jane; Function symbols: supervisor. Herbrand Universe peter, supervisor(peter), supervisor(supervisor(peter)), . . . , HU(P) = jane, supervisor(jane), supervisor(supervisor(jane)), . . . Herbrand Base    phd_student(peter), phd_student(jane), phd_student(supervisor(peter)), . . . ,    prof (peter), prof (jane), prof (supervisor(peter)), prof (supervisor(jane)), . . . ,   HB(P) =  poor(peter), poor(jane), poor(supervisor(peter)), poor(supervisor(jane)), . . . ,    couple(peter, jane), couple(peter, supervisor(peter)), couple(jane, jane), . . .   Minh Dao-Tran DERI, July 2011 7/33
13. 13. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.1 Positive Logic Programs Herbrand Semantics by an Example A logic program P: prof (supervisor(X)) ← phd_student(X). phd_student(peter). poor(X) ← phd_student(X). couple(peter, jane). phd_student(Y) ← phd_student(X), couple(X, Y). Constant symbols: peter, jane; Function symbols: supervisor. Herbrand Universe peter, supervisor(peter), supervisor(supervisor(peter)), . . . , HU(P) = jane, supervisor(jane), supervisor(supervisor(jane)), . . . Herbrand Base    phd_student(peter), phd_student(jane), phd_student(supervisor(peter)), . . . ,    prof (peter), prof (jane), prof (supervisor(peter)), prof (supervisor(jane)), . . . ,   HB(P) =  poor(peter), poor(jane), poor(supervisor(peter)), poor(supervisor(jane)), . . . ,    couple(peter, jane), couple(peter, supervisor(peter)), couple(jane, jane), . . .   Herbrand Interpretation I1 = ∅ I2 = HB(P) I3 = {phd_student(peter), phd_student(jane), couple(peter, jane), prof (supervisor(peter))} Minh Dao-Tran DERI, July 2011 7/33
14. 14. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.1 Positive Logic Programs Grounding Grounding a rule r = poor(X) ← phd_student(X). A ground instance of r is obtained by replacing its variables by terms from HU P .     poor(peter) ← phd_student(peter).   poor(jane) ← phd_student(jane).     grnd(r) = poor(supervisor(peter)) ← phd_student(supervisor(peter)).     . .   .   Grounding a program grnd(P) = r∈P grnd(r) Minh Dao-Tran DERI, July 2011 8/33
15. 15. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.1 Positive Logic Programs Herbrand Models Deﬁnition (Model, satisfaction) An interpretation I is a (Herbrand) model of a a ground (variable-free) rule r = a ← b1 , . . . , bm , if either {b1 , . . . , bm } I or a ∈ I ; (I |= r) a rule r, if I |= r for every r ∈ grnd(r); (I |= r) a program P, if I |= r for every rule r in P. (I |= P) Minh Dao-Tran DERI, July 2011 9/33
16. 16. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.1 Positive Logic Programs Example (Program P) prof (supervisor(X)) ← phd_student(X). phd_student(peter). poor(X) ← phd_student(X). couple(peter, jane). phd_student(Y) ← phd_student(X), couple(X, Y). Which of the following interpretations are models of P? I1 = ∅ I2 = HB(P) phd_student(peter), couple(peter, jane), phd_student(jane), I3 = poor(peter), poor(jane), prof (supervisor(peter)) Minh Dao-Tran DERI, July 2011 10/33
17. 17. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.1 Positive Logic Programs Example (Program P) prof (supervisor(X)) ← phd_student(X). phd_student(peter). poor(X) ← phd_student(X). couple(peter, jane). phd_student(Y) ← phd_student(X), couple(X, Y). Which of the following interpretations are models of P? I1 = ∅ no I2 = HB(P) phd_student(peter), couple(peter, jane), phd_student(jane), I3 = poor(peter), poor(jane), prof (supervisor(peter)) Minh Dao-Tran DERI, July 2011 10/33
18. 18. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.1 Positive Logic Programs Example (Program P) prof (supervisor(X)) ← phd_student(X). phd_student(peter). poor(X) ← phd_student(X). couple(peter, jane). phd_student(Y) ← phd_student(X), couple(X, Y). Which of the following interpretations are models of P? I1 = ∅ no I2 = HB(P) yes phd_student(peter), couple(peter, jane), phd_student(jane), I3 = poor(peter), poor(jane), prof (supervisor(peter)) Minh Dao-Tran DERI, July 2011 10/33
19. 19. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.1 Positive Logic Programs Example (Program P) prof (supervisor(X)) ← phd_student(X). phd_student(peter). poor(X) ← phd_student(X). couple(peter, jane). phd_student(Y) ← phd_student(X), couple(X, Y). Which of the following interpretations are models of P? I1 = ∅ no I2 = HB(P) yes phd_student(peter), couple(peter, jane), phd_student(jane), I3 = no poor(peter), poor(jane), prof (supervisor(peter)) Minh Dao-Tran DERI, July 2011 10/33
20. 20. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.2 Minimal Model Semantics Minimal Model Semantics Prefer models with true-part as small as possible. Deﬁnition A model I of P is minimal, if there exists no model J of P such that J ⊂ I . Minh Dao-Tran DERI, July 2011 11/33
21. 21. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.2 Minimal Model Semantics Minimal Model Semantics Prefer models with true-part as small as possible. Deﬁnition A model I of P is minimal, if there exists no model J of P such that J ⊂ I . Theorem Every logic program P has a single minimal model (called the least model), denoted LM(P). Minh Dao-Tran DERI, July 2011 11/33
22. 22. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.2 Minimal Model Semantics Computation The minimal model can be computed via ﬁxpoint iteration. Example prof (supervisor(X)) ← phd_student(X). phd_student(peter). poor(X) ← phd_student(X). couple(peter, jane). phd_student(Y) ← phd_student(X), couple(X, Y). 0 TP = ∅ Minh Dao-Tran DERI, July 2011 12/33
23. 23. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.2 Minimal Model Semantics Computation The minimal model can be computed via ﬁxpoint iteration. Example prof (supervisor(X)) ← phd_student(X). phd_student(peter). poor(X) ← phd_student(X). couple(peter, jane). phd_student(Y) ← phd_student(X), couple(X, Y). 0 TP = ∅ 1 TP = {phd_student(peter), couple(peter, jane)} Minh Dao-Tran DERI, July 2011 12/33
24. 24. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.2 Minimal Model Semantics Computation The minimal model can be computed via ﬁxpoint iteration. Example prof (supervisor(X)) ← phd_student(X). phd_student(peter). poor(X) ← phd_student(X). couple(peter, jane). phd_student(Y) ← phd_student(X), couple(X, Y). 0 TP = ∅ 1 TP = {phd_student(peter), couple(peter, jane)} 2 phd_student(peter), couple(peter, jane), phd_student(jane), TP = poor(peter), prof (supervisor(peter)) Minh Dao-Tran DERI, July 2011 12/33
25. 25. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.2 Minimal Model Semantics Computation The minimal model can be computed via ﬁxpoint iteration. Example prof (supervisor(X)) ← phd_student(X). phd_student(peter). poor(X) ← phd_student(X). couple(peter, jane). phd_student(Y) ← phd_student(X), couple(X, Y). 0 TP = ∅ 1 TP = {phd_student(peter), couple(peter, jane)} 2 phd_student(peter), couple(peter, jane), phd_student(jane), TP = poor(peter), prof (supervisor(peter))    phd_student(peter), couple(peter, jane), phd_student(jane),  3 TP = poor(peter), prof (supervisor(peter)), poor(jane), prof (supervisor(jane))   Minh Dao-Tran DERI, July 2011 12/33
26. 26. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.2 Minimal Model Semantics Computation The minimal model can be computed via ﬁxpoint iteration. Example prof (supervisor(X)) ← phd_student(X). phd_student(peter). poor(X) ← phd_student(X). couple(peter, jane). phd_student(Y) ← phd_student(X), couple(X, Y). 0 TP = ∅ 1 TP = {phd_student(peter), couple(peter, jane)} 2 phd_student(peter), couple(peter, jane), phd_student(jane), TP = poor(peter), prof (supervisor(peter))    phd_student(peter), couple(peter, jane), phd_student(jane),  3 TP = poor(peter), prof (supervisor(peter)), poor(jane), prof (supervisor(jane))   4 3 TP = TP Minh Dao-Tran DERI, July 2011 12/33
27. 27. An Answer Set Programming Tutorial 3. Stable Logic Programming Negation in Logic Programs Why negation? Natural linguistic concept Facilitates convenient, declarative descriptions (deﬁnitions) E.g., "Men who are not husbands are singles.” Minh Dao-Tran DERI, July 2011 13/33
28. 28. An Answer Set Programming Tutorial 3. Stable Logic Programming Negation in Logic Programs Why negation? Natural linguistic concept Facilitates convenient, declarative descriptions (deﬁnitions) E.g., "Men who are not husbands are singles.” Deﬁnition A normal logic program is a set of rules of the form a ← b1 , . . . , bm , not c1 , . . . , not cn (n, m ≥ 0) (1) where a and all bi , cj are atoms in a ﬁrst-order language L. not is called “negation as failure”, “default negation”, or “weak negation” Things get more complex! Minh Dao-Tran DERI, July 2011 13/33
29. 29. An Answer Set Programming Tutorial 3. Stable Logic Programming Stable model semantics First, for variable-free (ground) programs P Treat “not ” specially Intuitively, literals not a are a source of “contradiction” or “unstability”. Minh Dao-Tran DERI, July 2011 14/33
30. 30. An Answer Set Programming Tutorial 3. Stable Logic Programming Stable model semantics First, for variable-free (ground) programs P Treat “not ” specially Intuitively, literals not a are a source of “contradiction” or “unstability”. Example (Dilbert, program P2 ) man(dilbert). (f1 ) single(dilbert) ← man(dilbert), not husband(dilbert). (r1 ) husband(dilbert) ← man(dilbert), not single(dilbert). (r2 ) Minh Dao-Tran DERI, July 2011 14/33
31. 31. An Answer Set Programming Tutorial 3. Stable Logic Programming Stable model semantics First, for variable-free (ground) programs P Treat “not ” specially Intuitively, literals not a are a source of “contradiction” or “unstability”. Example (Dilbert, program P2 ) man(dilbert). (f1 ) single(dilbert) ← man(dilbert), not husband(dilbert). (r1 ) husband(dilbert) ← man(dilbert), not single(dilbert). (r2 ) M = {man(dilbert)}, get {man(dilbert), single(dilbert), husband(dilbert)} Minh Dao-Tran DERI, July 2011 14/33
32. 32. An Answer Set Programming Tutorial 3. Stable Logic Programming Stable model semantics First, for variable-free (ground) programs P Treat “not ” specially Intuitively, literals not a are a source of “contradiction” or “unstability”. Example (Dilbert, program P2 ) man(dilbert). (f1 ) single(dilbert) ← man(dilbert), not husband(dilbert). (r1 ) husband(dilbert) ← man(dilbert), not single(dilbert). (r2 ) M = {man(dilbert), single(dilbert), husband(dilbert)}, get {man(dilbert)}. Minh Dao-Tran DERI, July 2011 14/33
33. 33. An Answer Set Programming Tutorial 3. Stable Logic Programming Stable Models Deﬁnition (Gelfond-Lifschitz Reduct PM 1988) The GL-reduct (simply reduct) of a ground program P w.r.t. an interpretation M , denoted PM , is the program obtained from P by 1 removing rules with not a in the body for each a ∈ M ; and 2 removing literals not a from all other rules. Minh Dao-Tran DERI, July 2011 15/33
34. 34. An Answer Set Programming Tutorial 3. Stable Logic Programming Stable Models Deﬁnition (Gelfond-Lifschitz Reduct PM 1988) The GL-reduct (simply reduct) of a ground program P w.r.t. an interpretation M , denoted PM , is the program obtained from P by 1 removing rules with not a in the body for each a ∈ M ; and 2 removing literals not a from all other rules. Intuition: M makes an assumption about what is true and what is false. The reduct PM incorporates this assumptions. As a “not ”-free program, PM derives positive facts, given by LM(PM ). If this coincides with M , then the assumption of M is “stable”. Minh Dao-Tran DERI, July 2011 15/33
35. 35. An Answer Set Programming Tutorial 3. Stable Logic Programming Stable Models Deﬁnition (Gelfond-Lifschitz Reduct PM 1988) The GL-reduct (simply reduct) of a ground program P w.r.t. an interpretation M , denoted PM , is the program obtained from P by 1 removing rules with not a in the body for each a ∈ M ; and 2 removing literals not a from all other rules. Intuition: M makes an assumption about what is true and what is false. The reduct PM incorporates this assumptions. As a “not ”-free program, PM derives positive facts, given by LM(PM ). If this coincides with M , then the assumption of M is “stable”. Deﬁnition (stable model) An interpretation M of P is a stable model of P, if M = LM(PM ). Minh Dao-Tran DERI, July 2011 15/33
36. 36. An Answer Set Programming Tutorial 3. Stable Logic Programming Example (P2 cont’d) man(dilbert). (f1 ) single(dilbert) ← man(dilbert), not husband(dilbert). (r1 ) husband(dilbert) ← man(dilbert), not single(dilbert). (r2 ) Candidate interpretations: M1 = {man(dilbert), single(dilbert)}, M2 = {man(dilbert), husband(dilbert)}, M3 = {man(dilbert), single(dilbert), husband(dilbert)}, M4 = {man(dilbert)} Minh Dao-Tran DERI, July 2011 16/33
37. 37. An Answer Set Programming Tutorial 3. Stable Logic Programming Example (P2 cont’d) man(dilbert). (f1 ) single(dilbert) ← man(dilbert), not husband(dilbert). (r1 ) husband(dilbert) ← man(dilbert), not single(dilbert). (r2 ) Candidate interpretations: M1 = {man(dilbert), single(dilbert)}, M2 = {man(dilbert), husband(dilbert)}, M3 = {man(dilbert), single(dilbert), husband(dilbert)}, M4 = {man(dilbert)} M1 and M2 are stable models. Minh Dao-Tran DERI, July 2011 16/33
38. 38. An Answer Set Programming Tutorial 3. Stable Logic Programming Example (P2 cont’d) man(dilbert). (f1 ) single(dilbert) ← man(dilbert), not husband(dilbert). (r1 ) husband(dilbert) ← man(dilbert), not single(dilbert). (r2 ) M1 = {man(dilbert), single(dilbert)}: Minh Dao-Tran DERI, July 2011 17/33
39. 39. An Answer Set Programming Tutorial 3. Stable Logic Programming Example (P2 cont’d) man(dilbert). (f1 ) single(dilbert) ← man(dilbert), not husband(dilbert). (r1 ) husband(dilbert) ← man(dilbert), not single(dilbert). (r2 ) M1 = {man(dilbert), single(dilbert)}: reduct PM1 : 2 man(dilbert). single(dilbert) ← man(dilbert). The least model of PM1 is {man(dilbert), single(dilbert)} = M1 . 2 Minh Dao-Tran DERI, July 2011 17/33
40. 40. An Answer Set Programming Tutorial 3. Stable Logic Programming Example (P2 cont’d) man(dilbert). (f1 ) single(dilbert) ← man(dilbert), not husband(dilbert). (r1 ) husband(dilbert) ← man(dilbert), not single(dilbert). (r2 ) M1 = {man(dilbert), single(dilbert)}: reduct PM1 : 2 man(dilbert). single(dilbert) ← man(dilbert). The least model of PM1 is {man(dilbert), single(dilbert)} = M1 . 2 M2 = {man(dilbert), husband(dilbert)}: by symmetry of husband and single, also M2 is stable. Minh Dao-Tran DERI, July 2011 17/33
41. 41. An Answer Set Programming Tutorial 3. Stable Logic Programming Example (P2 cont’d) man(dilbert). (f1 ) single(dilbert) ← man(dilbert), not husband(dilbert). (r1 ) husband(dilbert) ← man(dilbert), not single(dilbert). (r2 ) M3 = {man(dilbert), single(dilbert), husband(dilbert)}: Minh Dao-Tran DERI, July 2011 18/33
42. 42. An Answer Set Programming Tutorial 3. Stable Logic Programming Example (P2 cont’d) man(dilbert). (f1 ) single(dilbert) ← man(dilbert), not husband(dilbert). (r1 ) husband(dilbert) ← man(dilbert), not single(dilbert). (r2 ) M3 = {man(dilbert), single(dilbert), husband(dilbert)}: PM3 is 2 man(dilbert). LM(PM3 ) = {man(dilbert)} = M3 . 2 Minh Dao-Tran DERI, July 2011 18/33
43. 43. An Answer Set Programming Tutorial 3. Stable Logic Programming Example (P2 cont’d) man(dilbert). (f1 ) single(dilbert) ← man(dilbert), not husband(dilbert). (r1 ) husband(dilbert) ← man(dilbert), not single(dilbert). (r2 ) M3 = {man(dilbert), single(dilbert), husband(dilbert)}: PM3 is 2 man(dilbert). LM(PM3 ) = {man(dilbert)} = M3 . 2 M4 = {man(dilbert)}: Minh Dao-Tran DERI, July 2011 18/33
44. 44. An Answer Set Programming Tutorial 3. Stable Logic Programming Example (P2 cont’d) man(dilbert). (f1 ) single(dilbert) ← man(dilbert), not husband(dilbert). (r1 ) husband(dilbert) ← man(dilbert), not single(dilbert). (r2 ) M3 = {man(dilbert), single(dilbert), husband(dilbert)}: PM3 is 2 man(dilbert). LM(PM3 ) = {man(dilbert)} = M3 . 2 M4 = {man(dilbert)}: PM4 is 2 man(dilbert). single(dilbert) ← man(dilbert). husband(dilbert) ← man(dilbert). LM(PM4 ) = {man(dilbert), single(dilbert), husband(dilbert)} = M4 . 2 Minh Dao-Tran DERI, July 2011 18/33
45. 45. An Answer Set Programming Tutorial 3. Stable Logic Programming Programs with Variables As for positive programs, view a program rule as a shorthand for all its ground instances. Recall: grnd(P) is the grounding of program P. Deﬁnition (stable model, general case) An interpretation M of P is a stable model of P, if M is a stable model of grnd(P). Minh Dao-Tran DERI, July 2011 19/33
46. 46. An Answer Set Programming Tutorial 4. Extensions Extensions Many extensions exist, partly motivated by applications Some are syntactic sugar, other strictly add expressiveness Incomplete list: • disjunction • integrity constraints • strong negation • nested expressions • cardinality constraints (Smodels) • optimization: weight constraints, minimize (Smodels); weak constraints (DLV) • aggregates (Smodels, DLV) • templates (for macros), external functions (DLVHEX) • Frame Logic syntax (for Semantic Web) • preferences: e.g., PLP, LOPDs • KR frontends (diagnosis, inheritance, planning,...) in DLV Comprehensive survey: [Niemelä (ed.), 2005] Minh Dao-Tran DERI, July 2011 20/33
47. 47. An Answer Set Programming Tutorial 4. Extensions Extensions Many extensions exist, partly motivated by applications Some are syntactic sugar, other strictly add expressiveness Incomplete list: • disjunction • integrity constraints • strong negation • nested expressions • cardinality constraints (Smodels) • optimization: weight constraints, minimize (Smodels); weak constraints (DLV) • aggregates (Smodels, DLV) • templates (for macros), external functions (DLVHEX) • Frame Logic syntax (for Semantic Web) • preferences: e.g., PLP, LOPDs • KR frontends (diagnosis, inheritance, planning,...) in DLV Comprehensive survey: [Niemelä (ed.), 2005] Minh Dao-Tran DERI, July 2011 20/33
48. 48. An Answer Set Programming Tutorial 4. Extensions 4.1 Disjunction Disjunction The use of disjunction is natural to express indeﬁnite knowledge. Minh Dao-Tran DERI, July 2011 21/33
49. 49. An Answer Set Programming Tutorial 4. Extensions 4.1 Disjunction Disjunction The use of disjunction is natural to express indeﬁnite knowledge. Example female(X) ∨ male(X) ← person(X). single(dilbert) ∨ husband(dilbert) ← man(dilbert). Minh Dao-Tran DERI, July 2011 21/33
50. 50. An Answer Set Programming Tutorial 4. Extensions 4.1 Disjunction Disjunction The use of disjunction is natural to express indeﬁnite knowledge. Example female(X) ∨ male(X) ← person(X). single(dilbert) ∨ husband(dilbert) ← man(dilbert). Disjunction is natural for expressing a “guess” and to create non-determinism Minh Dao-Tran DERI, July 2011 21/33
51. 51. An Answer Set Programming Tutorial 4. Extensions 4.1 Disjunction Disjunction The use of disjunction is natural to express indeﬁnite knowledge. Example female(X) ∨ male(X) ← person(X). single(dilbert) ∨ husband(dilbert) ← man(dilbert). Disjunction is natural for expressing a “guess” and to create non-determinism Example ok(C) ∨ notok(C) ← component(C). Minh Dao-Tran DERI, July 2011 21/33
52. 52. An Answer Set Programming Tutorial 4. Extensions 4.2 Integrity Constraints Integrity Constraints Adding fail ← b1 , . . . , bm , not c1 , . . . , not cn , not fail. to P “kills” all stable models of P that • contain b1 , . . . , bm , and • do not contain c1 , . . . , cn This is convenient to eliminate scenarios which does not satisfy integrity constraints. Minh Dao-Tran DERI, July 2011 22/33
53. 53. An Answer Set Programming Tutorial 4. Extensions 4.2 Integrity Constraints Integrity Constraints Adding fail ← b1 , . . . , bm , not c1 , . . . , not cn , not fail. to P “kills” all stable models of P that • contain b1 , . . . , bm , and • do not contain c1 , . . . , cn This is convenient to eliminate scenarios which does not satisfy integrity constraints. Short: Integrity Constraint ← b1 , . . . , bm , not c1 , . . . , not cn . Minh Dao-Tran DERI, July 2011 22/33
54. 54. An Answer Set Programming Tutorial 4. Extensions 4.2 Integrity Constraints Example (P2 cont’d) man(dilbert). (f1 ) single(dilbert) ∨ husband(dilbert) ← man(dilbert). (r1 ) ← husband(X), not wedding_ring(X). (c1 ) The constraint c1 eliminates models in which there is no evidence for a husband having a wedding ring. Single stable model: M1 = {man(dilbert), single(dilbert)} Minh Dao-Tran DERI, July 2011 23/33
55. 55. An Answer Set Programming Tutorial 5. Answer Set for the Semantic Web Answer Set Solvers DLV1 http://www.dbai.tuwien.ac.at/proj/dlv/ Smodels2 http://www.tcs.hut.fi/Software/smodels/ GnT http://www.tcs.hut.fi/Software/gnt/ Cmodels http://www.cs.utexas.edu/users/tag/cmodels/ ASSAT http://assat.cs.ust.hk/ NoMore(++) http://www.cs.uni-potsdam.de/~linke/nomore/ Platypus http://www.cs.uni-potsdam.de/platypus/ clasp http://www.cs.uni-potsdam.de/clasp/ XASP http://xsb.sourceforge.net/, distributed with XSB aspps http://www.cs.engr.uky.edu/ai/aspps/ ccalc http://www.cs.utexas.edu/users/tag/cc/ 1 + many extensions, e.g., DLVEX, DLVHEX, DLVDB , DLT, DLV-Complex 2 + Smodels_cc Minh Dao-Tran DERI, July 2011 24/33
56. 56. An Answer Set Programming Tutorial 5. Answer Set for the Semantic Web Answer Set Programming Systems for Debian/Ubuntu Easy to install: • \$ sudo add-apt-repository ppa:tkren/asp • \$ sudo apt-get update • \$ sudo apt-get install clasp gringo potassco-guide dlv-installer With the next version of Ubuntu in October 2011, clasp and gringo will be built in More details at http://www.kr.tuwien.ac.at/staff/tkren/deb.html Minh Dao-Tran DERI, July 2011 25/33
57. 57. An Answer Set Programming Tutorial 5. Answer Set for the Semantic Web 5.1 DL-Programs DL-Programs A clean approach to combine description logics and logic programs under answer set semantics A dl-program consists of two parts: a logic program P, a description logic knowledge base L L is accessible from P by means of dl-atoms. ASP Solver ? DL Engine Minh Dao-Tran DERI, July 2011 26/33
58. 58. An Answer Set Programming Tutorial 5. Answer Set for the Semantic Web 5.1 DL-Programs The famous tweety example    Flier ¬NonFlier, Penguin Bird,  L= Penguin NonFlier, —————– Bird Flier Bird(tweety), Penguin(joe)   Minh Dao-Tran DERI, July 2011 27/33
59. 59. An Answer Set Programming Tutorial 5. Answer Set for the Semantic Web 5.1 DL-Programs The famous tweety example    Flier ¬NonFlier, Penguin Bird,  L= Penguin NonFlier, —————– Bird Flier Bird(tweety), Penguin(joe)   ﬂies(X) ← DL[Flier ﬂies; Bird](X), P= not DL[Flier ﬂies; ¬Flier](X). Minh Dao-Tran DERI, July 2011 27/33
60. 60. An Answer Set Programming Tutorial 5. Answer Set for the Semantic Web 5.1 DL-Programs The famous tweety example    Flier ¬NonFlier, Penguin Bird,  L= Penguin NonFlier, —————– Bird Flier Bird(tweety), Penguin(joe)   ﬂies(X) ← DL[Flier ﬂies; Bird](X), P= not DL[Flier ﬂies; ¬Flier](X). The dl-atom device Can specify a query to L: DL[Bird](X) DL[Bird](tweety) true for y s.t. L |= Bird(tweety). Minh Dao-Tran DERI, July 2011 27/33
61. 61. An Answer Set Programming Tutorial 5. Answer Set for the Semantic Web 5.1 DL-Programs The famous tweety example    Flier ¬NonFlier, Penguin Bird,  L= Penguin NonFlier, —————– Bird Flier Bird(tweety), Penguin(joe)   ﬂies(X) ← DL[Flier ﬂies; Bird](X), P= not DL[Flier ﬂies; ¬Flier](X). The dl-atom device Can specify a query to L: DL[Bird](X) DL[Bird](tweety) true for y s.t. L |= Bird(tweety). Can push knowledge to L before querying: DL[Flier ﬂies; ¬Flier](X). Minh Dao-Tran DERI, July 2011 27/33
62. 62. An Answer Set Programming Tutorial 5. Answer Set for the Semantic Web 5.2 HEX-Programs HEX-programs Extends dl-programs from one-to-one coupling to many-one. • Outer Knowledge sources are not constrained to DL knowledge bases only. Minh Dao-Tran DERI, July 2011 28/33
63. 63. An Answer Set Programming Tutorial 5. Answer Set for the Semantic Web 5.2 HEX-Programs HEX-programs Extends dl-programs from one-to-one coupling to many-one. • Outer Knowledge sources are not constrained to DL knowledge bases only. P can interface multiple external sources of knowledge of any sort via so called external atoms Minh Dao-Tran DERI, July 2011 28/33
64. 64. An Answer Set Programming Tutorial 5. Answer Set for the Semantic Web 5.2 HEX-Programs HEX-programs Extends dl-programs from one-to-one coupling to many-one. • Outer Knowledge sources are not constrained to DL knowledge bases only. P can interface multiple external sources of knowledge of any sort via so called external atoms P has higher order atoms Minh Dao-Tran DERI, July 2011 28/33
65. 65. An Answer Set Programming Tutorial 5. Answer Set for the Semantic Web 5.2 HEX-Programs An example subRelation(brotherOf , relativeOf ). brotherOf (john, al). relativeOf (john, joe). brotherOf (al, mick). invites(john, X) ∨ skip(X) ← X = john, &reach[relativeOf , john](X). R(X, Y) ← subRelation(P, R), P(X, Y). someInvited ← invites(john, X). ← not someInvited. ← &degs[invites](Min, Max), Max > 2. Example Input: Some data about John’s neighborhood Output: Possible picks for persons John might want to invite, according to some constraints Minh Dao-Tran DERI, July 2011 29/33
66. 66. An Answer Set Programming Tutorial 5. Answer Set for the Semantic Web 5.2 HEX-Programs An example subRelation(brotherOf , relativeOf ). brotherOf (john, al). relativeOf (john, joe). brotherOf (al, mick). invites(john, X) ∨ skip(X) ← X = john, &reach[relativeOf , john](X). R(X, Y) ← subRelation(P, R), P(X, Y). someInvited ← invites(john, X). ← not someInvited. ← &degs[invites](Min, Max), Max > 2. Example Input: Some data about John’s neighborhood Output: Possible picks for persons John might want to invite, according to some constraints Minh Dao-Tran DERI, July 2011 29/33
67. 67. An Answer Set Programming Tutorial 5. Answer Set for the Semantic Web 5.2 HEX-Programs An example subRelation(brotherOf , relativeOf ). brotherOf (john, al). relativeOf (john, joe). brotherOf (al, mick). invites(john, X) ∨ skip(X) ← X = john, &reach[relativeOf , john](X). R(X, Y) ← subRelation(P, R), P(X, Y). someInvited ← invites(john, X). ← not someInvited. ← &degs[invites](Min, Max), Max > 2. Example Input: Some data about John’s neighborhood Output: Possible picks for persons John might want to invite, according to some constraints Minh Dao-Tran DERI, July 2011 29/33
68. 68. An Answer Set Programming Tutorial 5. Answer Set for the Semantic Web 5.2 HEX-Programs An example subRelation(brotherOf , relativeOf ). brotherOf (john, al). relativeOf (john, joe). brotherOf (al, mick). invites(john, X) ∨ skip(X) ← X = john, &reach[relativeOf , john](X). R(X, Y) ← subRelation(P, R), P(X, Y). someInvited ← invites(john, X). ← not someInvited. ← &degs[invites](Min, Max), Max > 2. Example Input: Some data about John’s neighborhood Output: Possible picks for persons John might want to invite, according to some constraints Minh Dao-Tran DERI, July 2011 29/33
69. 69. An Answer Set Programming Tutorial 5. Answer Set for the Semantic Web 5.2 HEX-Programs Higher order atoms subRelation(brotherOf , relativeOf ). R(X, Y) ← subRelation(P, R), P(X, Y). brotherOf (john, al). relativeOf (john, joe). brotherOf (al, mick). The device of higher order atoms Predicate names can be variables Constants can appear both as terms values or as predicate values Minh Dao-Tran DERI, July 2011 30/33
70. 70. An Answer Set Programming Tutorial 5. Answer Set for the Semantic Web 5.2 HEX-Programs Higher order atoms subRelation(brotherOf , relativeOf ). R(X, Y) ← subRelation(P, R), P(X, Y). brotherOf (john, al). relativeOf (john, joe). brotherOf (al, mick). The device of higher order atoms Predicate names can be variables Constants can appear both as terms values or as predicate values Minh Dao-Tran DERI, July 2011 30/33
71. 71. An Answer Set Programming Tutorial 5. Answer Set for the Semantic Web 5.2 HEX-Programs Higher order atoms subRelation(brotherOf , relativeOf ). R(X, Y) ← subRelation(P, R), P(X, Y). brotherOf (john, al). relativeOf (john, joe). brotherOf (al, mick). The device of higher order atoms Predicate names can be variables Constants can appear both as terms values or as predicate values Minh Dao-Tran DERI, July 2011 30/33
72. 72. An Answer Set Programming Tutorial 5. Answer Set for the Semantic Web 5.2 HEX-Programs Higher order atoms subRelation(brotherOf , relativeOf ). R(X, Y) ← subRelation(P, R), P(X, Y). brotherOf (john, al). relativeOf (john, joe). brotherOf (al, mick). The device of higher order atoms Predicate names can be variables Constants can appear both as terms values or as predicate values Allows (comfortable) meta-reasoning subRelation(brotherOf , relativeOf ). R(X, Y) ← subRelation(P, R), P(X, Y). Minh Dao-Tran DERI, July 2011 30/33
73. 73. An Answer Set Programming Tutorial 5. Answer Set for the Semantic Web 5.2 HEX-Programs Higher order atoms subRelation(brotherOf , relativeOf ). R(X, Y) ← subRelation(P, R), P(X, Y). brotherOf (john, al). relativeOf (john, joe). brotherOf (al, mick). The device of higher order atoms Predicate names can be variables Constants can appear both as terms values or as predicate values Allows (comfortable) meta-reasoning subRelation(brotherOf , relativeOf ). ⇒ relativeOf (X, Y) ← brotherOf (X, Y). R(X, Y) ← subRelation(P, R), P(X, Y). Minh Dao-Tran DERI, July 2011 30/33
74. 74. An Answer Set Programming Tutorial 5. Answer Set for the Semantic Web 5.2 HEX-Programs External atoms &reach[relativeOf , john](X) (2) &degs[invites](Min, Max) (3) The device of external atoms Each external predicate is tied to a corresponding evaluation function E.g. &reach corresponds to f&reach . For a given interpretation I , I |= &reach[relativeOf , john](x) if f&reach (I, relativeOf , john) = 1 Minh Dao-Tran DERI, July 2011 31/33
75. 75. An Answer Set Programming Tutorial 6. Future Directions of ASP Current state-of-the-art Semantics Introduction of Function Symbols [Syrjänen, 2001],[Bonatti, 2004],[Calimeri et al., 2008],[Šimkus and Eiter, 2007],[Eiter and Šimkus, 2009] Modularity [Dao-Tran et al., 2009],[Janhunen et al., 2007],[Oikarinen and Janhunen, 2008],[Tari et al., 2005],[Balduccini, 2007],[Baral et al., 2006],[Calimeri and Ianni, 2006],[Polleres et al., 2006],[Analyti et al., 2008] Study of equivalence [Lifschitz et al., 2001],[Gelfond, 2008],[Eiter et al., 2007],[Eiter et al., 2004],[Woltran, 2008] Minh Dao-Tran DERI, July 2011 32/33
76. 76. An Answer Set Programming Tutorial 6. Future Directions of ASP Current state-of-the-art Semantics Introduction of Function Symbols [Syrjänen, 2001],[Bonatti, 2004],[Calimeri et al., 2008],[Šimkus and Eiter, 2007],[Eiter and Šimkus, 2009] Modularity [Dao-Tran et al., 2009],[Janhunen et al., 2007],[Oikarinen and Janhunen, 2008],[Tari et al., 2005],[Balduccini, 2007],[Baral et al., 2006],[Calimeri and Ianni, 2006],[Polleres et al., 2006],[Analyti et al., 2008] Study of equivalence [Lifschitz et al., 2001],[Gelfond, 2008],[Eiter et al., 2007],[Eiter et al., 2004],[Woltran, 2008] Engineering Debuggers [El-Khatib et al., 2005],[Brain and Vos, 2005] and in-database evaluation [Terracina et al., 2008] See the SEA workshop series http://sea07.cs.bath.ac.uk/ Minh Dao-Tran DERI, July 2011 32/33
77. 77. An Answer Set Programming Tutorial 6. Future Directions of ASP Current state-of-the-art II Scalability Intelligent and lazy grounders [Calimeri et al., 2008],[Gebser et al., 2008],[Palù et al., 2008], [Lefévre and Nicolas, 2008] Incremental reasoning [Gebser et al., 2011] See the Answer Set Programming competition http://www.cs.kuleuven.be/∼dtai/events/ASP-competition/ https://www.mat.unical.it/aspcomp2011 Minh Dao-Tran DERI, July 2011 33/33
79. 79. An Answer Set Programming Tutorial 7. Playing with ASP Graph 3-Coloring r(X) ∨ g(X) ∨ b(X) ← node(X). ← edge(X, Y), r(X), r(Y). ← edge(X, Y), g(X), g(Y). ← edge(X, Y), b(X), b(Y). node(a). node(b). node(c). edge(a, b). edge(b, c). edge(a, c). Minh Dao-Tran DERI, July 2011 35/33
80. 80. An Answer Set Programming Tutorial 7. Playing with ASP Hamilton Path/Cycle inPath(X, Y) ∨ outPath(X, Y) ← edge(X, Y). ← inPath(X, Y), inPath(X, Y1 ), Y = Y1 . ← inPath(X, Y), inPath(X1 , Y), X = X1 . ← node(X), not reached(X). reached(X) ← start(X). reached(X) ← reached(Y), inPath(Y, X). Minh Dao-Tran DERI, July 2011 36/33
81. 81. An Answer Set Programming Tutorial 7. Playing with ASP Hamilton Path/Cycle inPath(X, Y) ∨ outPath(X, Y) ← edge(X, Y). ← inPath(X, Y), inPath(X, Y1 ), Y = Y1 . ← inPath(X, Y), inPath(X1 , Y), X = X1 . ← node(X), not reached(X). ← not start_reached. reached(X) ← start(X). reached(X) ← reached(Y), inPath(Y, X). start_reached ← start(Y), inPath(X, Y). Minh Dao-Tran DERI, July 2011 36/33
82. 82. An Answer Set Programming Tutorial 7. Playing with ASP Choosing wine Assume that we have a Wine ontology and speciﬁcation of who prefer which type of wine. person(“axel”). preferredWine(“axel”, “SweetWine”). person(“gibbi”). preferredWine(“gibbi”, “DessertWine”). person(“roman”). preferredWine(“roman”, “ItalianWine”). Minh Dao-Tran DERI, July 2011 37/33
83. 83. An Answer Set Programming Tutorial 7. Playing with ASP Choosing wine Assume that we have a Wine ontology and speciﬁcation of who prefer which type of wine. person(“axel”). preferredWine(“axel”, “SweetWine”). person(“gibbi”). preferredWine(“gibbi”, “DessertWine”). person(“roman”). preferredWine(“roman”, “ItalianWine”). isA(X, “SweetWine”) ← DL[SweetWine](X). isA(X, “DessertWine”) ← DL[DessertWine](X). isA(X, “ItalianWine”) ← DL[ItalianWine](X). Minh Dao-Tran DERI, July 2011 37/33
84. 84. An Answer Set Programming Tutorial 7. Playing with ASP Choosing wine Assume that we have a Wine ontology and speciﬁcation of who prefer which type of wine. person(“axel”). preferredWine(“axel”, “SweetWine”). person(“gibbi”). preferredWine(“gibbi”, “DessertWine”). person(“roman”). preferredWine(“roman”, “ItalianWine”). isA(X, “SweetWine”) ← DL[SweetWine](X). isA(X, “DessertWine”) ← DL[DessertWine](X). isA(X, “ItalianWine”) ← DL[ItalianWine](X). compliantBottle(X, Z) ← preferredWine(X, Y), isA(Z, Y). Minh Dao-Tran DERI, July 2011 37/33
85. 85. An Answer Set Programming Tutorial 7. Playing with ASP Choosing wine Assume that we have a Wine ontology and speciﬁcation of who prefer which type of wine. person(“axel”). preferredWine(“axel”, “SweetWine”). person(“gibbi”). preferredWine(“gibbi”, “DessertWine”). person(“roman”). preferredWine(“roman”, “ItalianWine”). isA(X, “SweetWine”) ← DL[SweetWine](X). isA(X, “DessertWine”) ← DL[DessertWine](X). isA(X, “ItalianWine”) ← DL[ItalianWine](X). compliantBottle(X, Z) ← preferredWine(X, Y), isA(Z, Y). bottleChosen(X) ∨ nonbottleChosen(X) ← compliantBottle(_, X). Minh Dao-Tran DERI, July 2011 37/33
86. 86. An Answer Set Programming Tutorial 7. Playing with ASP Choosing wine Assume that we have a Wine ontology and speciﬁcation of who prefer which type of wine. person(“axel”). preferredWine(“axel”, “SweetWine”). person(“gibbi”). preferredWine(“gibbi”, “DessertWine”). person(“roman”). preferredWine(“roman”, “ItalianWine”). isA(X, “SweetWine”) ← DL[SweetWine](X). isA(X, “DessertWine”) ← DL[DessertWine](X). isA(X, “ItalianWine”) ← DL[ItalianWine](X). compliantBottle(X, Z) ← preferredWine(X, Y), isA(Z, Y). bottleChosen(X) ∨ nonbottleChosen(X) ← compliantBottle(_, X). hasBottleChosen(X) ← bottleChosen(Z), compliantBottle(X, Z). Minh Dao-Tran DERI, July 2011 37/33
87. 87. An Answer Set Programming Tutorial 7. Playing with ASP Choosing wine Assume that we have a Wine ontology and speciﬁcation of who prefer which type of wine. person(“axel”). preferredWine(“axel”, “SweetWine”). person(“gibbi”). preferredWine(“gibbi”, “DessertWine”). person(“roman”). preferredWine(“roman”, “ItalianWine”). isA(X, “SweetWine”) ← DL[SweetWine](X). isA(X, “DessertWine”) ← DL[DessertWine](X). isA(X, “ItalianWine”) ← DL[ItalianWine](X). compliantBottle(X, Z) ← preferredWine(X, Y), isA(Z, Y). bottleChosen(X) ∨ nonbottleChosen(X) ← compliantBottle(_, X). hasBottleChosen(X) ← bottleChosen(Z), compliantBottle(X, Z). ← person(X), not hasBottleChosen(X). Minh Dao-Tran DERI, July 2011 37/33
88. 88. An Answer Set Programming Tutorial 7. Playing with ASP Choosing wine Assume that we have a Wine ontology and speciﬁcation of who prefer which type of wine. person(“axel”). preferredWine(“axel”, “SweetWine”). person(“gibbi”). preferredWine(“gibbi”, “DessertWine”). person(“roman”). preferredWine(“roman”, “ItalianWine”). isA(X, “SweetWine”) ← DL[SweetWine](X). isA(X, “DessertWine”) ← DL[DessertWine](X). isA(X, “ItalianWine”) ← DL[ItalianWine](X). compliantBottle(X, Z) ← preferredWine(X, Y), isA(Z, Y). bottleChosen(X) ∨ nonbottleChosen(X) ← compliantBottle(_, X). hasBottleChosen(X) ← bottleChosen(Z), compliantBottle(X, Z). ← person(X), not hasBottleChosen(X). ← bottleChosen(X).[1 : 1] Minh Dao-Tran DERI, July 2011 37/33
89. 89. An Answer Set Programming Tutorial 7. Playing with ASP People whom Axel knows triple(X, Y, Z) ← &rdf [“foaf .axel.rdf ”](X, Y, Z). knownbyAxelbyName(X) ← triple(ID, “foaf : name”, “Axel Polleres”), triple(ID, “foaf : knows”, ID2), triple(ID2, “foaf : name”, X). Minh Dao-Tran DERI, July 2011 38/33
90. 90. References I Anastasia Analyti, Grigoris Antoniou, and Carlos Viegas Damásio. A principled framework for modular web rule bases and its semantics. In Proceedings of the 11th International Conference on Principles of Knowledge Representation and Reasoning (KR2008). AAAI Press, September 2008. Marcello Balduccini. Modules and Signature Declarations for A-Prolog: Progress Report. In Marina de Vos and Torsten Schaub, editors, Informal Proceedings of the 1st International Workshop on Software Engineering for Answer Set Programming, Tempe, AZ (USA), May 2007, 2007. Available at http://sea07.cs.bath.ac.uk/downloads/ sea07-proceedings.pdf.
91. 91. References II Chitta Baral, Juraj Dzifcak, and Hiro Takahashi. Macros, Macro calls and Use of Ensembles in Modular Answer Set Programming. In Proceedings of the 22th International Conference on Logic Programming (ICLP 2006), number 4079 in LNCS, pages 376–390. Springer, 2006. Piero A. Bonatti. Reasoning with inﬁnite stable models. Artiﬁcial Intelligence, 156(1):75–111, 2004. Martin Brain and Marina De Vos. Debugging logic programs under the answer set semantics. In Answer Set Programming, 2005.
92. 92. References III Francesco Calimeri and Giovambattista Ianni. Template programs for Disjunctive Logic Programming: An operational semantics. AI Communications, 19(3):193–206, 2006. Francesco Calimeri, Susanna Cozza, Giovambattista Ianni, and Nicola Leone. Computable Functions in ASP: Theory and Implementation. In Logic Programming, 24th International Conference, ICLP 2008, Udine, Italy, December 9-13 2008, Proceedings, volume 5366 of LNCS, pages 407–424. Springer, 2008. Minh Dao-Tran, Thomas Eiter, Michael Fink, and Thomas Krennwallner. Modular nonmonotonic logic programming revisited. In P. Hill and D.S. Warren, editors, Proceedings 25th International Conference on Logic Programming (ICLP 2009), volume 5649 of LNCS, pages 145–159. Springer, July 2009.
93. 93. References IV Thomas Eiter and Mantas Šimkus. Bidirectional answer set programs with function symbols. In C. Boutilier, editor, Proceedings of the 21st International Joint Conference on Artiﬁcial Intelligence (IJCAI-09). AAAI Press/IJCAI, 2009. T. Eiter, M. Fink, H. Tompits, and S. Woltran. Simplifying logic programs under uniform and strong equivalence. In Ilkka Niemelä and Vladimir Lifschitz, editors, Proceedings of the 7th International Conference on Logic Programming and Nonmonotonic Reasoning (LPNMR 2004), number 2923 in LNCS, pages 87–99. Springer, 2004. Thomas Eiter, Michael Fink, and Stefan Woltran. Semantical Characterizations and Complexity of Equivalences in Answer Set Programming. ACM Trans. Comput. Log., 8(3), 2007. Article 17 (53 + 11 pages).
94. 94. References V Omar El-Khatib, Enrico Pontelli, and Tran Cao Son. Justiﬁcation and debugging of answer set programs in asp. In AADEBUG, pages 49–58, 2005. Martin Gebser, Roland Kaminski, Benjamin Kaufmann, Max Ostrowski, Torsten Schaub, and Sven Thiele. Engineering an Incremental ASP Solver. In M.G. de La Banda and E. Pontelli, editors, Proceedings 24th International Conference on Logic Programming (ICLP 2008), number 5366 in LNCS, pages 190–205. Springer, 2008. Martin Gebser, Orkunt Sabuncu, and Torsten Schaub. An incremental answer set programming based system for ﬁnite model computation. AI Commun., 24(2):195–212, 2011.
95. 95. References VI Michael Gelfond and Vladimir Lifschitz. The Stable Model Semantics for Logic Programming. In Logic Programming: Proceedings Fifth Intl Conference and Symposium, pages 1070–1080, Cambridge, Mass., 1988. MIT Press. Michael Gelfond and Vladimir Lifschitz. Classical Negation in Logic Programs and Disjunctive Databases. New Generation Computing, 9:365–385, 1991. M. Gelfond. Answer sets. In B. Porter F. van Harmelen, V. Lifschitz, editor, Handbook of Knowledge Representation, chapter 7, pages 285–316. Elsevier, 2008.
96. 96. References VII Tomi Janhunen, Emilia Oikarinen, Hans Tompits, and Stefan Woltran. Modularity Aspects of Disjunctive Stable Models. In Proceedings of the 9th International Conference on Logic Programming and Nonmonotonic Reasoning, volume 4483 of LNCS, pages 175–187. Springer, May 2007. Claire Lefévre and Pascal Nicolas. Integrating grounding in the search process for answer set computing. In ASPOCP: Answer Set Programming and Other Constraint Paradigms, pages 89–103, 2008. Vladimir Lifschitz, David Pearce, and Agustín Valverde. Strongly equivalent logic programs. ACM Trans. Comput. Log., 2(4):526–541, 2001.
97. 97. References VIII Ilkka Niemelä (ed.). Language Extensions and Software Engineering for ASP. Technical Report WP3, Working Group on Answer Set Programming (WASP), IST-FET-2001-37004, September 2005. Available at http://www.tcs.hut.fi/Research/Logic/wasp/ wp3/wasp-wp3-web/. Emilia Oikarinen and Tomi Janhunen. Achieving compositionality of the stable model semantics for Smodels programs. Theory and Practice of Logic Programming, 8(5–6):717–761, November 2008. A. Dal Palù, A. Dovier, E. Pontelli, and G. Rossi. Gasp: Answer set programming with lazy grounding. In LaSh 2008: LOGIC AND SEARCH - Computation of structures from declarative descriptions, 2008.
98. 98. References IX Axel Polleres, Cristina Feier, and Andreas Harth. Rules with Contextually Scoped Negation. In Proceedings of the 3rd European Conference on Semantic Web (ESWC 2006), volume 4011 of LNCS, pages 332–347. Springer, 2006. Mantas Šimkus and Thomas Eiter. FDNC: Decidable non-monotonic disjunctive logic programs with function symbols. In N. Dershowitz and A. Voronkov, editors, Proceedings 14th International Conference on Logic for Programming, Artiﬁcial Intelligence and Reasoning (LPAR 2007), number 4790 in LNCS, pages 514–530. Springer, 2007. Extended Paper to appear in ACM Trans. Computational Logic.
99. 99. References X Tommi Syrjänen. Omega-restricted logic programs. In Proceedings of the 6th International Conference on Logic Programming and Nonmonotonic Reasoning, Vienna, Austria, September 2001. Springer-Verlag. Luis Tari, Chitta Baral, and Saadat Anwar. A Language for Modular Answer Set Programming: Application to ACC Tournament Scheduling. In Proceedings of the 3Proceedings of the 3rd International ASP’05 Workshop, Bath, UK, 27th–29th July 2005, volume 142 of CEUR Workshop Proceedings, pages 277–293. CEUR WS, July 2005. Giorgio Terracina, Nicola Leone, Vincenzino Lio, and Claudio Panetta. Experimenting with recursive queries in database and logic programming systems. TPLP, 8(2):129–165, 2008.
100. 100. References XI Allen Van Gelder, Kenneth A. Ross, and John S. Schlipf. The Well-Founded Semantics for General Logic Programs. Journal of the ACM, 38(3):620–650, 1991. Stefan Woltran. A common view on strong, uniform, and other notions of equivalence in answer-set programming. Theory and Practice of Logic Programming, 8(2):217–234, 2008.
101. 101. An Answer Set Programming Tutorial 8. References 8.1 ASP Performance The 3rd ASP Competition Results from https://www.mat.unical.it/aspcomp20111 Input size (plain text of facts): Reachability: 0.5 — 20 MB Grammar Based Information Extraction: 1.5 — 5 MB 1 Many thanks to Giovambattista Ianni for insightful analysis of the results. Minh Dao-Tran DERI, July 2011 50/33
102. 102. An Answer Set Programming Tutorial 8. References 8.1 ASP Performance The 3rd ASP Competition - Scoring Minh Dao-Tran DERI, July 2011 51/33
103. 103. An Answer Set Programming Tutorial 8. References 8.1 ASP Performance clasp Benchmarking http://www.cs.uni-potsdam.de/clasp/?page=experiments Check some of the well-known problems: HamiltonianCycle, HamiltonianPath, Su-DoKu, TowersOfHanoiCompetition Minh Dao-Tran DERI, July 2011 52/33
104. 104. An Answer Set Programming Tutorial 8. References 8.2 What is ASP good for? What is ASP good for? Combinatorial search problems (some with substantial amount of data): • For instance, auctions, bio-informatics, computer-aided veriﬁcation, conﬁguration, constraint satisfaction, diagnosis, information integration, planning and scheduling, security analysis, semantic web, wire-routing, zoology and linguistics, and many more A favorite application : Using ASP as a basis for a decision support system for NASA’s space shuttle (Gelfond et al., Texas Tech) And more: • Automatic synthesis of multiprocessor systems • Inconsistency detection, diagnosis, repair, and prediction in large biological networks • Home monitoring for risk prevention in ambient assisted living • General game playing Minh Dao-Tran DERI, July 2011 53/33
105. 105. An Answer Set Programming Tutorial 8. References 8.3 What is the difference compared to Prolog? Logic Programming – Prolog revisited Prolog = “Programming in Logic” Basic data structures: terms Programs: rules and facts Computing: Queries (goals) • Proofs provide answers • SLD-resolution • uniﬁcation - basic mechanism to manipulate data structures Extensive use of recursion Minh Dao-Tran DERI, July 2011 54/33
106. 106. An Answer Set Programming Tutorial 8. References 8.3 What is the difference compared to Prolog? Prolog – Truly Declarative Programming? Example parent(John, Mary). parent(Mary, James). ancestor(X, Y) : − parent(X, Y). ancestor(X, Z) : − parent(X, Y), ancestor(Y, Z). vs. parent(John, Mary). parent(Mary, James). ancestor(X, Z) : − ancestor(Y, Z), parent(X, Y). ancestor(X, Y) : − parent(X, Y). Query: ?- ancestor(John,W) Minh Dao-Tran DERI, July 2011 55/33
107. 107. An Answer Set Programming Tutorial 8. References 8.3 What is the difference compared to Prolog? Desiderata Relieve the programmer from several concerns. It is desirable that the order of program rules does not matter; the order of subgoals in a rule does not matter; termination is not subject to such order. Minh Dao-Tran DERI, July 2011 56/33
108. 108. An Answer Set Programming Tutorial 8. References 8.3 What is the difference compared to Prolog? Desiderata Relieve the programmer from several concerns. It is desirable that the order of program rules does not matter; the order of subgoals in a rule does not matter; termination is not subject to such order. “Pure” declarative programming Prolog does not satisfy these desiderata Satisﬁed e.g. by the answer set semantics of logic programs Minh Dao-Tran DERI, July 2011 56/33
109. 109. An Answer Set Programming Tutorial 8. References 8.3 What is the difference compared to Prolog? Programs with Negation Prolog: “not X ” means “Negation as Failure (to prove to X )” Different from negation in classical logic! Minh Dao-Tran DERI, July 2011 57/33
110. 110. An Answer Set Programming Tutorial 8. References 8.3 What is the difference compared to Prolog? Programs with Negation Prolog: “not X ” means “Negation as Failure (to prove to X )” Different from negation in classical logic! Example (Program P3 ) man(dilbert). single(X) : − man(X), not husband(X). husband(X) : − fail. Minh Dao-Tran DERI, July 2011 57/33
111. 111. An Answer Set Programming Tutorial 8. References 8.3 What is the difference compared to Prolog? Programs with Negation Prolog: “not X ” means “Negation as Failure (to prove to X )” Different from negation in classical logic! Example (Program P3 ) man(dilbert). single(X) : − man(X), not husband(X). husband(X) : − fail. Query: ? − single(X). Minh Dao-Tran DERI, July 2011 57/33
112. 112. An Answer Set Programming Tutorial 8. References 8.3 What is the difference compared to Prolog? Programs with Negation Prolog: “not X ” means “Negation as Failure (to prove to X )” Different from negation in classical logic! Example (Program P3 ) man(dilbert). single(X) : − man(X), not husband(X). husband(X) : − fail. Query: ? − single(X). Answer: X = dilbert. Minh Dao-Tran DERI, July 2011 57/33
113. 113. An Answer Set Programming Tutorial 8. References 8.3 What is the difference compared to Prolog? Example (cont’d) Modifying the last rule of P3 , we get P4 : man(dilbert). single(X) ← man(X), not husband(X). husband(X) ← man(X), not single(X). Result in Prolog ???? Minh Dao-Tran DERI, July 2011 58/33
114. 114. An Answer Set Programming Tutorial 8. References 8.3 What is the difference compared to Prolog? Example (cont’d) Modifying the last rule of P3 , we get P4 : man(dilbert). single(X) ← man(X), not husband(X). husband(X) ← man(X), not single(X). Result in Prolog ???? Problem: not a single intuitive model! Minh Dao-Tran DERI, July 2011 58/33
115. 115. An Answer Set Programming Tutorial 8. References 8.3 What is the difference compared to Prolog? Example (cont’d) Modifying the last rule of P3 , we get P4 : man(dilbert). single(X) ← man(X), not husband(X). husband(X) ← man(X), not single(X). Result in Prolog ???? Problem: not a single intuitive model! Two intuitive Herbrand models: M1 = {man(dilbert), single(dilbert)}, and M2 = {man(dilbert), husband(dilbert)} . Which one to choose? Minh Dao-Tran DERI, July 2011 58/33
116. 116. An Answer Set Programming Tutorial 8. References 8.4 Semantics of Logic Programs With Negatio Semantics of Logic Programs With Negation “War of Semantics” in Logic Programming (1980/90s): Meaning of programs like the Dilbert example above Minh Dao-Tran DERI, July 2011 59/33
117. 117. An Answer Set Programming Tutorial 8. References 8.4 Semantics of Logic Programs With Negatio Semantics of Logic Programs With Negation “War of Semantics” in Logic Programming (1980/90s): Meaning of programs like the Dilbert example above Great Schism: Single model vs. multiple model semantics Minh Dao-Tran DERI, July 2011 59/33
118. 118. An Answer Set Programming Tutorial 8. References 8.4 Semantics of Logic Programs With Negatio Semantics of Logic Programs With Negation “War of Semantics” in Logic Programming (1980/90s): Meaning of programs like the Dilbert example above Great Schism: Single model vs. multiple model semantics To date: • Well-Founded Semantics [Van Gelder et al., 1991] Partial model: man(dilbert) is true, single(dilbert), husband(dilbert) are unknown Minh Dao-Tran DERI, July 2011 59/33
119. 119. An Answer Set Programming Tutorial 8. References 8.4 Semantics of Logic Programs With Negatio Semantics of Logic Programs With Negation “War of Semantics” in Logic Programming (1980/90s): Meaning of programs like the Dilbert example above Great Schism: Single model vs. multiple model semantics To date: • Well-Founded Semantics [Van Gelder et al., 1991] Partial model: man(dilbert) is true, single(dilbert), husband(dilbert) are unknown • Answer Set (alias Stable Model) Semantics by Gelfond and Lifschitz [1988,1991]. Alternative models: M1 = {man(dilbert), single(dilbert)}, M2 = {man(dilbert), husband(dilbert)}. Minh Dao-Tran DERI, July 2011 59/33
120. 120. An Answer Set Programming Tutorial 8. References 8.4 Semantics of Logic Programs With Negatio Semantics of Logic Programs With Negation “War of Semantics” in Logic Programming (1980/90s): Meaning of programs like the Dilbert example above Great Schism: Single model vs. multiple model semantics To date: • Well-Founded Semantics [Van Gelder et al., 1991] Partial model: man(dilbert) is true, single(dilbert), husband(dilbert) are unknown • Answer Set (alias Stable Model) Semantics by Gelfond and Lifschitz [1988,1991]. Alternative models: M1 = {man(dilbert), single(dilbert)}, M2 = {man(dilbert), husband(dilbert)}. Agreement for so-called “stratiﬁed programs” Different selection principles for non-stratiﬁed programs Minh Dao-Tran DERI, July 2011 59/33
121. 121. An Answer Set Programming Tutorial 8. References 8.5 Minimality Minimality Semantics: disjunction is minimal (different from classical logic): a ∨ b ∨ c. Minimal models: {a}, {b}, and {c}. Minh Dao-Tran DERI, July 2011 60/33
122. 122. An Answer Set Programming Tutorial 8. References 8.5 Minimality 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}. Minh Dao-Tran DERI, July 2011 60/33
123. 123. An Answer Set Programming Tutorial 8. References 8.5 Minimality 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. Minh Dao-Tran DERI, July 2011 60/33
124. 124. An Answer Set Programming Tutorial 8. References 8.5 Minimality 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}. Minh Dao-Tran DERI, July 2011 60/33
125. 125. An Answer Set Programming Tutorial 8. References 8.5 Minimality Minimal Model Semantics A logic program has multiple models in general. Select one of these models as the canonical model. Commonly accepted: truth of an atom in model I should be “founded” by clauses. Minh Dao-Tran DERI, July 2011 61/33
126. 126. An Answer Set Programming Tutorial 8. References 8.5 Minimality Minimal Model Semantics A logic program has multiple models in general. Select one of these models as the canonical model. Commonly accepted: truth of an atom in model I should be “founded” by clauses. Example Given P2 = {a ← b. b ← c. c}, truth of a in the model I = {a, b, c} is “founded.” Minh Dao-Tran DERI, July 2011 61/33
127. 127. An Answer Set Programming Tutorial 8. References 8.5 Minimality Minimal Model Semantics A logic program has multiple models in general. Select one of these models as the canonical model. Commonly accepted: truth of an atom in model I should be “founded” by clauses. Example Given P2 = {a ← b. b ← c. c}, truth of a in the model I = {a, b, c} is “founded.” Given P2 = {a ← b. b ← a. c}, truth of a in the model I = {a, b, c} is not founded. Minh Dao-Tran DERI, July 2011 61/33
128. 128. An Answer Set Programming Tutorial 8. References 8.5 Minimality Minimal Model Semantics (cont’d) Semantics: Prefer models with true-part as small as possible. Deﬁnition A model I of P is minimal, if there exists no model J of P such that J ⊂ I . Minh Dao-Tran DERI, July 2011 62/33
129. 129. An Answer Set Programming Tutorial 8. References 8.5 Minimality Minimal Model Semantics (cont’d) Semantics: Prefer models with true-part as small as possible. Deﬁnition A model I of P is minimal, if there exists no model J of P such that J ⊂ I . Theorem Every logic program P has a single minimal model (called the least model), denoted LM(P). Minh Dao-Tran DERI, July 2011 62/33
130. 130. An Answer Set Programming Tutorial 8. References 8.5 Minimality Minimal Model Semantics (cont’d) Semantics: Prefer models with true-part as small as possible. Deﬁnition A model I of P is minimal, if there exists no model J of P such that J ⊂ I . Theorem Every logic program P has a single minimal model (called the least model), denoted LM(P). Example For P1 = { a ← b. b ← c. c }, we have LM(P1 ) = {a, b, c}. For P2 = { a ← b. b ← a. c }, we have LM(P2 ) = {c}. Minh Dao-Tran DERI, July 2011 62/33
131. 131. An Answer Set Programming Tutorial 8. References 8.6 TP operator Computation The minimal model can be computed via ﬁxpoint iteration. Deﬁnition (TP Operator) Let TP : 2HB(P) → 2HB(P) be deﬁned as there exists some a ← b1 , . . . , bm TP (I) = a . in grnd(P) such that {b1 , . . . , bm } ⊆ I 0 i+1 i We let denote TP = ∅, TP = TP (TP ), i ≥ 0. Minh Dao-Tran DERI, July 2011 63/33
132. 132. An Answer Set Programming Tutorial 8. References 8.6 TP operator Computation The minimal model can be computed via ﬁxpoint iteration. Deﬁnition (TP Operator) Let TP : 2HB(P) → 2HB(P) be deﬁned as there exists some a ← b1 , . . . , bm TP (I) = a . in grnd(P) such that {b1 , . . . , bm } ⊆ I 0 i+1 i We let denote TP = ∅, TP = TP (TP ), i ≥ 0. Fundamental result: Theorem i TP has a least ﬁxpoint, lfp(TP ), and the sequence TP , i ≥ 0, converges to lfp(TP ). Minh Dao-Tran DERI, July 2011 63/33