Knowledge Representation for the Semantic Web [2Ex] Lecture 6
Total Page:16
File Type:pdf, Size:1020Kb
Introduction Horn Logic Programming Negation in Logic Programs Answer Set Semantics Knowledge Representation for the Semantic Web Lecture 6: Answer Set Programming I Daria Stepanova partially based on slides by Thomas Eiter D5: Databases and Information Systems Max Planck Institute for Informatics WS 2017/18 1 / 45 Introduction Horn Logic Programming Negation in Logic Programs Answer Set Semantics Unit Outline Introduction Horn Logic Programming Negation in Logic Programs Answer Set Semantics 2 / 45 Introduction Horn Logic Programming Negation in Logic Programs Answer Set Semantics French Phrases, Italian Soda Six people sit at a round table. Each drinks a different kind of soda. Each plans to visit a different French-speaking country. The person who is planning a trip to Quebec, who drank either blueberry or lemon soda, didn't sit in seat number one. Jeanne didn't sit next to the person who enjoyed the kiwi soda. The person who has a plane ticket to Belgium, who sat in seat four or seat five, didn't order the cherry soda. ::: Question: What is each of them drinking, and where is each of them going? 3 / 45 Introduction Horn Logic Programming Negation in Logic Programs Answer Set Semantics 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. 4 / 45 + – a rule r, if Head(r) S = whenever Body (r) S and Body−(r) S = ; ∩ 6 ∅ ⊆ ∩ ∅ – a logic program (I is a model of ), if it satisfies all rules r of . P P P Definition 8. A model I of a logic program is called minimal, if there is no model I0 of , such that I0 I. P P ⊂ The semantics of ASP programs is given in terms of answer sets (or stable models). Definition 9. Given a positive logic program , an interpretation I is an answer set (stable model) of if I = and P P | P there does not exist I0 I, such that I0 = . AS( ) denotes the set of all answer sets. ⊂ | P P The notion of answer sets for logic programs with negation is defined using the Gelfond-Lifshitz reduct. Definition 10. Given a logic program and an interpretation I of the Gelfond-Lifshitz (GL-)reduct denoted by I is P P PGL constructed from ground( ) by P – deleting all rules r from ground( ) s.t. Body−(r) I = , and P ∩ 6 ∅ – deleting the negative body for all of the remaining rules. Note that for any program and interpretation the GL-reduct is positive. The definition of answer sets for arbitrary logic programs is then as follows: Definition 11. An answer set of a program is an interpretation I HB , such that I is an answer set of the positive P ⊆ P program I . PGL The availability of advanced reasoners makes the ASP formalism applicable to solving practical tasks. The standard reasoner comprises two components: a grounder and a solver. The list of the most well-known grounders include: dlv4, gringo5, lparse6, etc. Among the solvers one can mention dlv, clasp7, claspd8, gnt9. Potassco10 represents a collection of ASP reasoning tools, combining clasp and gringo into a system architecture. We now present an exampleIntroduction that illustratesHorn Logic Programming the basic notionsNegation of in the Logic Answer Programs Set ProgrammingAnswer Set Semantics that we have inroduced. Example 10. Consider a graph 3-colourability problem,Graph in 3-colouring which we are given a graph and three colours, e.g. red, blue and green, and we aim at finding the assignment of colours to the nodes of a graph in such a way that no adjacent nodes share the same color. The encoding of this problem is as follows. 2 3 1 4 6 5 (1) node(1 ... 6 ); (2) edge(1 , 2 ); ... (8) edge(5 , 6 ); Task: (9) coloured(V , red) not coloured(V , blue), not coloured(V , green), node(V ); Colour← the nodes of the graph in three colors such that none of the two (10) coloured(V , green) not coloured(V , blue), not coloured(V , red), node(V ); I = adjacent← nodes share the same colour. P (11) coloured(V , blue) not coloured(V , green), not coloured(V , red), node(V ); ← (12) coloured(V , C), coloured(V , C 0),C = C0; ⊥ ← 6 (13) coloured(V , C), coloured(V 0, C), edge(V , V 0) 5 / 45 ⊥ ← The facts of the programs describe the nodes and edges of the graph from above. The rules (9)-(11) state that each P node has to be colored in at least one of the three colours. The constraint (12) forbids the nodes to be colored in more then one color, while the constraint (13) says that two nodes connected via an edge must have different colours. 4 http://www.dlvsystem.com/ 5 http://potassco.sourceforge.net/ 6 http://www.tcs.hut.fi/Software/smodels/ 7 http://potassco.sourceforge.net/ 8 http://www.cs.uni-potsdam.de/claspD/ 9 http://www.tcs.hut.fi/Software/gnt/ 10 http://potassco.sourceforge.net/ Introduction Horn Logic Programming Negation in Logic Programs Answer Set Semantics Wanted! A general-purpose approach for modeling and solving these and many other problems. Issues: Diverse domains Spatial and temporal reasoning Constraints Incomplete information Frame problem Proposal: Answer-set programming (ASP) paradigm! 6 / 45 Introduction Horn Logic Programming Negation in Logic Programs Answer Set Semantics Answer Set Programming Answer Set Programming (ASP) is a recent problem solving approach, based on declarative programming. The term was coined by Vladimir Lifschitz [1999,2002]. Proposed by other people at about the same time, e.g., by Marek and Truszczy´nski[1999] and Niemel¨a[1999]. It has roots in knowledge representation, logic programming, and nonmonotonic reasoning. At an abstract level, ASP relates to SAT solving and constraint satisfaction problems (CSPs). 7 / 45 Introduction Horn Logic Programming Negation in Logic Programs Answer Set Semantics Answer Set Programming (cont'd) Important logic programming method Developed in the early 1990s by Gelfond and Lifschitz. Left: Michael Gelfond (Texas Tech Univ., Lubbock) Right: Vladimir Lifschitz (Univ. of Texas, Austin) Both are graduates from the Steklov Mathematical Institute, St.Petersburg (then: Leningrad). 8 / 45 Introduction Horn Logic Programming Negation in Logic Programs Answer Set Semantics Answer Set Programming (cont'd) ASP is an approach to declarative programming, combining a rich yet simple modeling language with high-performance solving capacities ASP has its roots in deductive databases logic programming with negation knowledge representation and nonmonotonic reasoning constraint solving (in particular, SATisfiability testing) ASP allows for solving all search problems in NP (and NPNP) in a uniform way 9 / 45 Introduction Horn Logic Programming Negation in Logic Programs Answer Set Semantics Answer Set Programming (cont'd) ASP is an approach to declarative programming, combining a rich yet simple modeling language with high-performance solving capacities ASP has its roots in deductive databases logic programming with negation knowledge representation and nonmonotonic reasoning constraint solving (in particular, SATisfiability testing) ASP allows for solving all search problems in NP (and NPNP) in a uniform way 9 / 45 Introduction Horn Logic Programming Negation in Logic Programs Answer Set Semantics Declarative Programming 10 / 45 Introduction Horn Logic Programming Negation in Logic Programs Answer Set Semantics Answer Set Programming (cont'd) ASP is an approach to declarative programming, combining a rich yet simple modeling language with high-performance solving capacities ASP has its roots in deductive databases logic programming with negation knowledge representation and nonmonotonic reasoning constraint solving (in particular, SATisfiability testing) ASP allows for solving all search problems in NP (and NPNP) in a uniform way 11 / 45 Introduction Horn Logic Programming Negation in Logic Programs Answer Set Semantics Nonmonotonic Reasoning Nonmonotonicity means that conclusions may be invalidated in the light of new information. More specifically, an inference relation j= is nonmonotonic if it violates the monotonicity principle: if T j= φ and T ⊆ T 0, then T 0 j= φ. Note: inference in description logics is monotonic. Example: Monotonicity of description logics T = fBird v Flier; Bird(tweety)g T j= F lier(tweety) T 0 = T [ f:Flier(tweety)g T 0 j= F lier(tweety) (actually T 0 is inconsistent) 12 / 45 Introduction Horn Logic Programming Negation in Logic Programs Answer Set Semantics Nonmonotonic Reasoning Nonmonotonicity means that conclusions may be invalidated in the light of new information. More specifically, an inference relation j= is nonmonotonic if it violates the monotonicity principle: if T j= φ and T ⊆ T 0, then T 0 j= φ. Note: inference in description logics is monotonic. Example: Nonmonotonic inference If bird(x) holds and there is no evidence for :flies(x), then infer flies(x). I.e., if bird(x), assume flies(x) by default. 12 / 45 Introduction Horn Logic Programming Negation in Logic Programs Answer Set Semantics ASP Systems ASP gains increasing importance for knowledge representation High expressiveness Efficient solvers available: DLV, clasp,... Source: Wikipedia (Dec 6, 2017) 13 / 45 Fundamental characteristics: models, not proofs, represent solutions; requires techniques to compute models (rather than techniques to compute proofs) Introduction Horn Logic Programming Negation in Logic Programs Answer Set Semantics ASP: General Idea ASP are logic programs; Their semantics adheres to the multiple preferred models approach: given as a selection of the collection of all classical models; selected (intended) models are called stable models or answer sets. 14 / 45 Introduction Horn Logic Programming Negation in Logic Programs Answer Set Semantics ASP: General Idea ASP are logic programs; Their semantics adheres to the multiple preferred models approach: given as a selection of the collection of all classical models; selected (intended) models are called stable models or answer sets.