answer set solving in practice
play

Answer Set Solving in Practice Torsten Schaub University of Potsdam - PowerPoint PPT Presentation

Answer Set Solving in Practice Torsten Schaub University of Potsdam torsten@cs.uni-potsdam.de Potassco Slide Packages are licensed under a Creative Commons Attribution 3.0 Unported License. Torsten Schaub (KRR@UP) Answer Set Solving in


  1. Semantics Some “logical” remarks Positive rules are also referred to as definite clauses Definite clauses are disjunctions with exactly one positive atom: a 0 ∨ ¬ a 1 ∨ · · · ∨ ¬ a m A set of definite clauses has a (unique) smallest model Horn clauses are clauses with at most one positive atom Every definite clause is a Horn clause but not vice versa Non-definite Horn clauses can be regarded as integrity constraints A set of Horn clauses has a smallest model or none This smallest model is the intended semantics of such sets of clauses Given a positive program P , Cn ( P ) corresponds to the smallest model of the set of definite clauses corresponding to P Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 41 / 538

  2. Semantics Some “logical” remarks Positive rules are also referred to as definite clauses Definite clauses are disjunctions with exactly one positive atom: a 0 ∨ ¬ a 1 ∨ · · · ∨ ¬ a m A set of definite clauses has a (unique) smallest model Horn clauses are clauses with at most one positive atom Every definite clause is a Horn clause but not vice versa Non-definite Horn clauses can be regarded as integrity constraints A set of Horn clauses has a smallest model or none This smallest model is the intended semantics of such sets of clauses Given a positive program P , Cn ( P ) corresponds to the smallest model of the set of definite clauses corresponding to P Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 41 / 538

  3. Semantics Basic idea Consider the logical formula Φ and its three q ∧ ( q ∧ ¬ r → p ) Φ (classical) models: { p , q } , { q , r } , and { p , q , r } Formula Φ has one stable model, P Φ q ← often called answer set: ← q , ∼ r p { p , q } Informally, a set X of atoms is a stable model of a logic program P if X is a (classical) model of P and if all atoms in X are justified by some rule in P Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 42 / 538

  4. Semantics Basic idea Consider the logical formula Φ and its three q ∧ ( q ∧ ¬ r → p ) Φ (classical) models: { p , q } , { q , r } , and { p , q , r } Formula Φ has one stable model, P Φ q ← often called answer set: ← q , ∼ r p { p , q } Informally, a set X of atoms is a stable model of a logic program P if X is a (classical) model of P and if all atoms in X are justified by some rule in P Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 42 / 538

  5. Semantics Basic idea Consider the logical formula Φ and its three q ∧ ( q ∧ ¬ r → p ) Φ (classical) models: { p , q } , { q , r } , and { p , q , r } ❍❍❍❍❍❍❍❍❍ Formula Φ has one stable model, P Φ q ← often called answer set: ❥ p �→ 1 ← q , ∼ r p �→ q 1 { p , q } r �→ 0 Informally, a set X of atoms is a stable model of a logic program P if X is a (classical) model of P and if all atoms in X are justified by some rule in P Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 42 / 538

  6. Semantics Basic idea Consider the logical formula Φ and its three q ∧ ( q ∧ ¬ r → p ) Φ (classical) models: { p , q } , { q , r } , and { p , q , r } Formula Φ has one stable model, P Φ q ← often called answer set: ← q , ∼ r p { p , q } Informally, a set X of atoms is a stable model of a logic program P if X is a (classical) model of P and if all atoms in X are justified by some rule in P Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 42 / 538

  7. Semantics Basic idea Consider the logical formula Φ and its three q ∧ ( q ∧ ¬ r → p ) Φ (classical) models: { p , q } , { q , r } , and { p , q , r } Formula Φ has one stable model, P Φ q ← often called answer set: ← q , ∼ r p { p , q } Informally, a set X of atoms is a stable model of a logic program P if X is a (classical) model of P and if all atoms in X are justified by some rule in P Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 42 / 538

  8. Semantics Basic idea Consider the logical formula Φ and its three q ∧ ( q ∧ ¬ r → p ) Φ (classical) models: { p , q } , { q , r } , and { p , q , r } Formula Φ has one stable model, P Φ q ← often called answer set: ← q , ∼ r p { p , q } Informally, a set X of atoms is a stable model of a logic program P if X is a (classical) model of P and if all atoms in X are justified by some rule in P Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 42 / 538

  9. Semantics Basic idea Consider the logical formula Φ and its three q ∧ ( q ∧ ¬ r → p ) Φ (classical) models: { p , q } , { q , r } , and { p , q , r } Formula Φ has one stable model, P Φ q ← often called answer set: ← q , ∼ r p { p , q } Informally, a set X of atoms is a stable model of a logic program P if X is a (classical) model of P and if all atoms in X are justified by some rule in P Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 42 / 538

  10. Semantics Basic idea Consider the logical formula Φ and its three q ∧ ( q ∧ ¬ r → p ) Φ (classical) models: { p , q } , { q , r } , and { p , q , r } Formula Φ has one stable model, P Φ q ← often called answer set: ← q , ∼ r p { p , q } Informally, a set X of atoms is a stable model of a logic program P if X is a (classical) model of P and if all atoms in X are justified by some rule in P Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 42 / 538

  11. Semantics Formal definition Stable models of normal programs The reduct, P X , of a program P relative to a set X of atoms is defined by P X = { h ( r ) ← B ( r ) + | r ∈ P and B ( r ) − ∩ X = ∅} A set X of atoms is a stable model of a program P , if Cn ( P X ) = X Remarks Cn ( P X ) is the ⊆ –smallest (classical) model of P X Each atom in X is justified by an “applying rule from P” Set X is stable under “applying rules from P” Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 43 / 538

  12. Semantics Formal definition Stable models of normal programs The reduct, P X , of a program P relative to a set X of atoms is defined by P X = { h ( r ) ← B ( r ) + | r ∈ P and B ( r ) − ∩ X = ∅} A set X of atoms is a stable model of a program P , if Cn ( P X ) = X Remarks Cn ( P X ) is the ⊆ –smallest (classical) model of P X Each atom in X is justified by an “applying rule from P” Set X is stable under “applying rules from P” Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 43 / 538

  13. Semantics Formal definition Stable models of normal programs The reduct, P X , of a program P relative to a set X of atoms is defined by P X = { h ( r ) ← B ( r ) + | r ∈ P and B ( r ) − ∩ X = ∅} A set X of atoms is a stable model of a program P , if Cn ( P X ) = X Remarks Cn ( P X ) is the ⊆ –smallest (classical) model of P X Each atom in X is justified by an “applying rule from P” Set X is stable under “applying rules from P” Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 43 / 538

  14. Semantics Formal definition Stable models of normal programs The reduct, P X , of a program P relative to a set X of atoms is defined by P X = { h ( r ) ← B ( r ) + | r ∈ P and B ( r ) − ∩ X = ∅} A set X of atoms is a stable model of a program P , if Cn ( P X ) = X Remarks Cn ( P X ) is the ⊆ –smallest (classical) model of P X Each atom in X is justified by an “applying rule from P” Set X is stable under “applying rules from P” Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 43 / 538

  15. Semantics A closer look at P X Alternatively, given a set X of atoms from P , P X is obtained from P by deleting 1 each rule having ∼ a in its body with a ∈ X and then 2 all negative atoms of the form ∼ a in the bodies of the remaining rules Note Only negative body literals are evaluated Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 44 / 538

  16. Semantics A closer look at P X Alternatively, given a set X of atoms from P , P X is obtained from P by deleting 1 each rule having ∼ a in its body with a ∈ X and then 2 all negative atoms of the form ∼ a in the bodies of the remaining rules Note Only negative body literals are evaluated Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 44 / 538

  17. Examples Outline 1 Syntax 2 Semantics 3 Examples 4 Reasoning 5 Language 6 Variables Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 45 / 538

  18. Examples Example one P = { p ← p , q ← ∼ p } P X Cn ( P X ) X { } ← { q } p p ✘ q ← { p } p ← p ∅ { q } ← { q } p p ✔ q ← { p , q } p ← p ∅ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 46 / 538

  19. Examples Example one P = { p ← p , q ← ∼ p } P X Cn ( P X ) X { } ← { q } p p ✘ q ← { p } p ← p ∅ { q } ← { q } p p ✔ q ← { p , q } p ← p ∅ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 46 / 538

  20. Examples Example one P = { p ← p , q ← ∼ p } P X Cn ( P X ) X { } ← { q } p p ✘ q ← { p } p ← p ∅ { q } ← { q } p p ✔ q ← { p , q } p ← p ∅ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 46 / 538

  21. Examples Example one P = { p ← p , q ← ∼ p } P X Cn ( P X ) X { } ← { q } p p ✘ q ← { p } p ← p ∅ { q } ← { q } p p ✔ q ← { p , q } p ← p ∅ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 46 / 538

  22. Examples Example one P = { p ← p , q ← ∼ p } P X Cn ( P X ) X { } ← { q } p p ✘ q ← { p } p ← p ∅ ✘ { q } ← { q } p p ✔ q ← { p , q } p ← p ∅ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 46 / 538

  23. Examples Example one P = { p ← p , q ← ∼ p } P X Cn ( P X ) X { } ← { q } p p ✘ q ← { p } p ← p ∅ ✘ { q } ← { q } p p ✔ q ← { p , q } p ← p ∅ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 46 / 538

  24. Examples Example one P = { p ← p , q ← ∼ p } P X Cn ( P X ) X { } ← { q } p p ✘ q ← { p } p ← p ∅ ✘ { q } ← { q } p p ✔ q ← { p , q } p ← p ∅ ✘ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 46 / 538

  25. Examples Example one P = { p ← p , q ← ∼ p } P X Cn ( P X ) X { } ← { q } p p ✘ q ← { p } p ← p ∅ ✘ { q } ← { q } p p ✔ q ← { p , q } p ← p ∅ ✘ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 46 / 538

  26. Examples Example one P = { p ← p , q ← ¬ p } P X Cn ( P X ) X { } ← { q } p p ✘ q ← { p } p ← p ∅ ✔ { q } ← { q } p p ✔ q ← { p , q } p ← p ∅ ✔ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 46 / 538

  27. Examples Example two P = { p ← ∼ q , q ← ∼ p } P X Cn ( P X ) X { } ← { p , q } p ✘ q ← { p } p ← { p } ✔ { q } { q } ✔ q ← { p , q } ∅ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 47 / 538

  28. Examples Example two P = { p ← ∼ q , q ← ∼ p } P X Cn ( P X ) X { } ← { p , q } p ✘ q ← { p } p ← { p } ✔ { q } { q } ✔ q ← { p , q } ∅ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 47 / 538

  29. Examples Example two P = { p ← ∼ q , q ← ∼ p } P X Cn ( P X ) X { } ← { p , q } p ✘ q ← { p } p ← { p } ✔ { q } { q } ✔ q ← { p , q } ∅ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 47 / 538

  30. Examples Example two P = { p ← ∼ q , q ← ∼ p } P X Cn ( P X ) X { } ← { p , q } p ✘ q ← { p } p ← { p } ✔ { q } { q } ✔ q ← { p , q } ∅ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 47 / 538

  31. Examples Example two P = { p ← ∼ q , q ← ∼ p } P X Cn ( P X ) X { } ← { p , q } p ✘ q ← { p } p ← { p } ✔ { q } { q } ✔ q ← { p , q } ∅ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 47 / 538

  32. Examples Example two P = { p ← ∼ q , q ← ∼ p } P X Cn ( P X ) X { } ← { p , q } p ✘ q ← { p } p ← { p } ✔ { q } { q } ✔ q ← { p , q } ∅ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 47 / 538

  33. Examples Example two P = { p ← ∼ q , q ← ∼ p } P X Cn ( P X ) X { } ← { p , q } p ✘ q ← { p } p ← { p } ✔ { q } { q } ✔ q ← { p , q } ∅ ✘ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 47 / 538

  34. Examples Example two P = { p ← ∼ q , q ← ∼ p } P X Cn ( P X ) X { } ← { p , q } p ✘ q ← { p } p ← { p } ✔ { q } { q } ✔ q ← { p , q } ∅ ✘ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 47 / 538

  35. Examples Example two P = { p ← ¬ q , q ← ¬ p } P X Cn ( P X ) X { } ← { p , q } p ✘ q ← { p } p ← { p } ✔ { q } { q } ✔ q ← { p , q } ∅ ✔ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 47 / 538

  36. Examples Example three P = { p ← ∼ p } P X Cn ( P X ) X { } p ← { p } ✘ { p } ∅ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 48 / 538

  37. Examples Example three P = { p ← ∼ p } P X Cn ( P X ) X { } p ← { p } ✘ { p } ∅ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 48 / 538

  38. Examples Example three P = { p ← ∼ p } P X Cn ( P X ) X { } p ← { p } ✘ { p } ∅ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 48 / 538

  39. Examples Example three P = { p ← ∼ p } P X Cn ( P X ) X { } p ← { p } ✘ { p } ∅ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 48 / 538

  40. Examples Example three P = { p ← ∼ p } P X Cn ( P X ) X { } p ← { p } ✘ { p } ∅ ✘ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 48 / 538

  41. Examples Example three P = { p ← ∼ p } P X Cn ( P X ) X { } p ← { p } ✘ { p } ∅ ✘ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 48 / 538

  42. Examples Example three P = { p ← ¬ p } P X Cn ( P X ) X { } p ← { p } ✘ { p } ∅ ✔ Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 48 / 538

  43. Examples Some properties A logic program may have zero, one, or multiple stable models If X is a stable model of a logic program P , then X ⊆ h ( P ) If X is a stable model of a logic program P , then X is a (classical) model of P If X and Y are stable models of a normal program P , then X �⊂ Y Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 49 / 538

  44. Examples Some properties A logic program may have zero, one, or multiple stable models If X is a stable model of a logic program P , then X ⊆ h ( P ) If X is a stable model of a logic program P , then X is a (classical) model of P If X and Y are stable models of a normal program P , then X �⊂ Y Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 49 / 538

  45. Examples Some properties A logic program may have zero, one, or multiple stable models If X is a stable model of a logic program P , then X ⊆ h ( P ) If X is a stable model of a logic program P , then X is a (classical) model of P If X and Y are stable models of a normal program P , then X �⊂ Y Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 49 / 538

  46. Examples Some properties A logic program may have zero, one, or multiple stable models If X is a stable model of a logic program P , then X ⊆ h ( P ) If X is a stable model of a logic program P , then X is a (classical) model of P If X and Y are stable models of a normal program P , then X �⊂ Y Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 49 / 538

  47. Examples Exemplars Logic program Answer sets { a } a. {} a :- b. { a,b } a :- b. b. {} a :- b. b :- a. { a } a :- not c. { c } a :- not c. c. { a } , { c } a :- not c. c :- not a. a :- not a. Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 50 / 538

  48. Reasoning Outline 1 Syntax 2 Semantics 3 Examples 4 Reasoning 5 Language 6 Variables Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 51 / 538

  49. Reasoning Reasoning modes Problem Solution ✻ Modeling Interpreting ❄ ✲ Logic Program Stable Models Solving Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 52 / 538

  50. Reasoning Reasoning modes Satisfiability Enumeration † Projection † Intersection ‡ Union ‡ Optimization and combinations of them † without solution recording ‡ without solution enumeration Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 53 / 538

  51. Language Outline 1 Syntax 2 Semantics 3 Examples 4 Reasoning 5 Language 6 Variables Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 54 / 538

  52. Language Extended syntax Problem Solution ✻ Modeling Interpreting ❄ ✲ Logic Program Stable Models Solving Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 55 / 538

  53. Language Language constructs Variables p(X) :- q(X) Conditional literals p :- q(X) : r(X) Disjunction p(X) ; q(X) :- r(X) Integrity constraints :- q(X), p(X) Choice 2 { p(X,Y) : q(X) } 7 :- r(Y) Aggregates s(Y) :- r(Y), 2 #sum { X : p(X,Y), q(X) } 7 Optimization Weak constraints : ∼ q(X), p(X,C) [C] Statements #minimize { C : q(X), p(X,C) } Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 56 / 538

  54. Language Language constructs Variables p(X) :- q(X) Conditional literals p :- q(X) : r(X) Disjunction p(X) ; q(X) :- r(X) Integrity constraints :- q(X), p(X) Choice 2 { p(X,Y) : q(X) } 7 :- r(Y) Aggregates s(Y) :- r(Y), 2 #sum { X : p(X,Y), q(X) } 7 Optimization Weak constraints : ∼ q(X), p(X,C) [C] Statements #minimize { C : q(X), p(X,C) } Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 56 / 538

  55. Language Language constructs Variables p(X) :- q(X) Conditional literals p :- q(X) : r(X) Disjunction p(X) ; q(X) :- r(X) Integrity constraints :- q(X), p(X) Choice 2 { p(X,Y) : q(X) } 7 :- r(Y) Aggregates s(Y) :- r(Y), 2 #sum { X : p(X,Y), q(X) } 7 Optimization Weak constraints : ∼ q(X), p(X,C) [C] Statements #minimize { C : q(X), p(X,C) } Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 56 / 538

  56. Language Language constructs Variables p(X) :- q(X) Conditional literals p :- q(X) : r(X) Disjunction p(X) ; q(X) :- r(X) Integrity constraints :- q(X), p(X) Choice 2 { p(X,Y) : q(X) } 7 :- r(Y) Aggregates s(Y) :- r(Y), 2 #sum { X : p(X,Y), q(X) } 7 Optimization Weak constraints : ∼ q(X), p(X,C) [C] Statements #minimize { C : q(X), p(X,C) } Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 56 / 538

  57. Language Language constructs Variables p(X) :- q(X) Conditional literals p :- q(X) : r(X) Disjunction p(X) ; q(X) :- r(X) Integrity constraints :- q(X), p(X) Choice 2 { p(X,Y) : q(X) } 7 :- r(Y) Aggregates s(Y) :- r(Y), 2 #sum { X : p(X,Y), q(X) } 7 Optimization Weak constraints : ∼ q(X), p(X,C) [C] Statements #minimize { C : q(X), p(X,C) } Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 56 / 538

  58. Language Language constructs Variables p(X) :- q(X) Conditional literals p :- q(X) : r(X) Disjunction p(X) ; q(X) :- r(X) Integrity constraints :- q(X), p(X) Choice 2 { p(X,Y) : q(X) } 7 :- r(Y) Aggregates s(Y) :- r(Y), 2 #sum { X : p(X,Y), q(X) } 7 Optimization Weak constraints : ∼ q(X), p(X,C) [C] Statements #minimize { C : q(X), p(X,C) } Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 56 / 538

  59. Language Language constructs Variables p(X) :- q(X) Conditional literals p :- q(X) : r(X) Disjunction p(X) ; q(X) :- r(X) Integrity constraints :- q(X), p(X) Choice 2 { p(X,Y) : q(X) } 7 :- r(Y) Aggregates s(Y) :- r(Y), 2 #sum { X : p(X,Y), q(X) } 7 Optimization Weak constraints : ∼ q(X), p(X,C) [C] Statements #minimize { C : q(X), p(X,C) } Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 56 / 538

  60. Language Language constructs Variables p(X) :- q(X) Conditional literals p :- q(X) : r(X) Disjunction p(X) ; q(X) :- r(X) Integrity constraints :- q(X), p(X) Choice 2 { p(X,Y) : q(X) } 7 :- r(Y) Aggregates s(Y) :- r(Y), 2 #sum { X : p(X,Y), q(X) } 7 Optimization Weak constraints : ∼ q(X), p(X,C) [C] Statements #minimize { C : q(X), p(X,C) } Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 56 / 538

  61. Language Language constructs Variables p(X) :- q(X) Conditional literals p :- q(X) : r(X) Disjunction p(X) ; q(X) :- r(X) Integrity constraints :- q(X), p(X) Choice 2 { p(X,Y) : q(X) } 7 :- r(Y) Aggregates s(Y) :- r(Y), 2 #sum { X : p(X,Y), q(X) } 7 Optimization Weak constraints : ∼ q(X), p(X,C) [C] Statements #minimize { C : q(X), p(X,C) } Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 56 / 538

  62. Language Language constructs Variables p(X) :- q(X) Conditional literals p :- q(X) : r(X) Disjunction p(X) ; q(X) :- r(X) Integrity constraints :- q(X), p(X) Choice 2 { p(X,Y) : q(X) } 7 :- r(Y) Aggregates s(Y) :- r(Y), 2 #sum { X : p(X,Y), q(X) } 7 Optimization Weak constraints : ∼ q(X), p(X,C) [C] Statements #minimize { C : q(X), p(X,C) } Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 56 / 538

  63. Language Language constructs Variables p(X) :- q(X) Conditional literals p :- q(X) : r(X) Disjunction p(X) ; q(X) :- r(X) Integrity constraints :- q(X), p(X) Choice 2 { p(X,Y) : q(X) } 7 :- r(Y) Aggregates s(Y) :- r(Y), 2 #sum { X : p(X,Y), q(X) } 7 Multi-objective optimization Weak constraints : ∼ q(X), p(X,C) [C@42] Statements #minimize { C@42 : q(X), p(X,C) } Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 56 / 538

  64. Variables Outline 1 Syntax 2 Semantics 3 Examples 4 Reasoning 5 Language 6 Variables Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 57 / 538

  65. Variables Example d ( a ) d ( c ) d ( d ) p ( a , b ) p ( b , c ) p ( c , d ) p ( X , Z ) ← p ( X , Y ) , p ( Y , Z ) q ( a ) q ( b ) q ( X ) ← ∼ r ( X ) , d ( X ) r ( X ) ← ∼ q ( X ) , d ( X ) s ( X ) ← ∼ r ( X ) , p ( X , Y ) , q ( Y ) Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 58 / 538

  66. Variables Example d ( a ) d ( c ) d ( d ) p ( a , b ) p ( b , c ) p ( c , d ) p ( X , Z ) ← p ( X , Y ) , p ( Y , Z ) q ( a ) q ( b ) q ( X ) ← ∼ r ( X ) , d ( X ) r ( X ) ← ∼ q ( X ) , d ( X ) s ( X ) ← ∼ r ( X ) , p ( X , Y ) , q ( Y ) Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 58 / 538

  67. Variables Grounding instantiation Let P be a logic program Let T be a set of (variable-free) terms Let A be a set of (variable-free) atoms constructible from T A variable-free atom is also called ground Ground instances of r ∈ P : Set of variable-free rules obtained by replacing all variables in r by elements from T : ground ( r ) = { r θ | θ : var ( r ) → T and var ( r θ ) = ∅} where var ( r ) stands for the set of all variables occurring in r ; θ is a (ground) substitution Ground instantiation of P : ground ( P ) = � r ∈ P ground ( r ) Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 59 / 538

  68. Variables Grounding instantiation Let P be a logic program Let T be a set of variable-free terms (also called Herbrand universe) Let A be a set of (variable-free) atoms constructible from T (also called alphabet or Herbrand base) A variable-free atom is also called ground Ground instances of r ∈ P : Set of variable-free rules obtained by replacing all variables in r by elements from T : ground ( r ) = { r θ | θ : var ( r ) → T and var ( r θ ) = ∅} where var ( r ) stands for the set of all variables occurring in r ; θ is a (ground) substitution Ground instantiation of P : ground ( P ) = � r ∈ P ground ( r ) Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 59 / 538

  69. Variables Grounding instantiation Let P be a logic program Let T be a set of (variable-free) terms Let A be a set of (variable-free) atoms constructible from T A variable-free atom is also called ground Ground instances of r ∈ P : Set of variable-free rules obtained by replacing all variables in r by elements from T : ground ( r ) = { r θ | θ : var ( r ) → T and var ( r θ ) = ∅} where var ( r ) stands for the set of all variables occurring in r ; θ is a (ground) substitution Ground instantiation of P : ground ( P ) = � r ∈ P ground ( r ) Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 59 / 538

  70. Variables Grounding instantiation Let P be a logic program Let T be a set of (variable-free) terms Let A be a set of (variable-free) atoms constructible from T A variable-free atom is also called ground Ground instances of r ∈ P : Set of variable-free rules obtained by replacing all variables in r by elements from T : ground ( r ) = { r θ | θ : var ( r ) → T and var ( r θ ) = ∅} where var ( r ) stands for the set of all variables occurring in r ; θ is a (ground) substitution Ground instantiation of P : ground ( P ) = � r ∈ P ground ( r ) Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 59 / 538

  71. Variables Grounding instantiation Let P be a logic program Let T be a set of (variable-free) terms Let A be a set of (variable-free) atoms constructible from T A variable-free atom is also called ground Ground instances of r ∈ P : Set of variable-free rules obtained by replacing all variables in r by elements from T : ground ( r ) = { r θ | θ : var ( r ) → T and var ( r θ ) = ∅} where var ( r ) stands for the set of all variables occurring in r ; θ is a (ground) substitution Ground instantiation of P : ground ( P ) = � r ∈ P ground ( r ) Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 59 / 538

  72. Variables An example P = { r ( a , b ) ← , r ( b , c ) ← , t ( X , Y ) ← r ( X , Y ) } T = { a , b , c } � r ( a , a ) , r ( a , b ) , r ( a , c ) , r ( b , a ) , r ( b , b ) , r ( b , c ) , r ( c , a ) , r ( c , b ) , r ( c , c ) , � A = t ( a , a ) , t ( a , b ) , t ( a , c ) , t ( b , a ) , t ( b , b ) , t ( b , c ) , t ( c , a ) , t ( c , b ) , t ( c , c )   r ( a , b ) ← ,     r ( b , c ) ← ,       ground ( P ) = t ( a , a ) ← r ( a , a ) , t ( b , a ) ← r ( b , a ) , t ( c , a ) ← r ( c , a ) , t ( a , b ) ← r ( a , b ) , t ( b , b ) ← r ( b , b ) , t ( c , b ) ← r ( c , b ) ,         t ( a , c ) ← r ( a , c ) , t ( b , c ) ← r ( b , c ) , t ( c , c ) ← r ( c , c )   Grounding aims at reducing the ground instantiation Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 60 / 538

  73. Variables An example P = { r ( a , b ) ← , r ( b , c ) ← , t ( X , Y ) ← r ( X , Y ) } T = { a , b , c } � r ( a , a ) , r ( a , b ) , r ( a , c ) , r ( b , a ) , r ( b , b ) , r ( b , c ) , r ( c , a ) , r ( c , b ) , r ( c , c ) , � A = t ( a , a ) , t ( a , b ) , t ( a , c ) , t ( b , a ) , t ( b , b ) , t ( b , c ) , t ( c , a ) , t ( c , b ) , t ( c , c )   r ( a , b ) ← ,     r ( b , c ) ← ,       ground ( P ) = t ( a , a ) ← r ( a , a ) , t ( b , a ) ← r ( b , a ) , t ( c , a ) ← r ( c , a ) , t ( a , b ) ← r ( a , b ) , t ( b , b ) ← r ( b , b ) , t ( c , b ) ← r ( c , b ) ,         t ( a , c ) ← r ( a , c ) , t ( b , c ) ← r ( b , c ) , t ( c , c ) ← r ( c , c )   Grounding aims at reducing the ground instantiation Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 60 / 538

  74. Variables An example P = { r ( a , b ) ← , r ( b , c ) ← , t ( X , Y ) ← r ( X , Y ) } T = { a , b , c } � r ( a , a ) , r ( a , b ) , r ( a , c ) , r ( b , a ) , r ( b , b ) , r ( b , c ) , r ( c , a ) , r ( c , b ) , r ( c , c ) , � A = t ( a , a ) , t ( a , b ) , t ( a , c ) , t ( b , a ) , t ( b , b ) , t ( b , c ) , t ( c , a ) , t ( c , b ) , t ( c , c )   r ( a , b ) ← ,     r ( b , c ) ← ,       ground ( P ) = t ( a , a ) ← r ( a , a ) , t ( b , a ) ← r ( b , a ) , t ( c , a ) ← r ( c , a ) , t ( a , b ) ← r ( a , b ) , t ( b , b ) ← r ( b , b ) , t ( c , b ) ← r ( c , b ) ,         t ( a , c ) ← r ( a , c ) , t ( b , c ) ← r ( b , c ) , t ( c , c ) ← r ( c , c )   Grounding aims at reducing the ground instantiation Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 60 / 538

  75. Variables An example P = { r ( a , b ) ← , r ( b , c ) ← , t ( X , Y ) ← r ( X , Y ) } T = { a , b , c } � r ( a , a ) , r ( a , b ) , r ( a , c ) , r ( b , a ) , r ( b , b ) , r ( b , c ) , r ( c , a ) , r ( c , b ) , r ( c , c ) , � A = t ( a , a ) , t ( a , b ) , t ( a , c ) , t ( b , a ) , t ( b , b ) , t ( b , c ) , t ( c , a ) , t ( c , b ) , t ( c , c )   r ( a , b ) ← ,     r ( b , c ) ← ,       ground ( P ) = t ( a , a ) ← r ( a , a ) , t ( b , a ) ← r ( b , a ) , t ( c , a ) ← r ( c , a ) , t ( a , b ) ← , t ( b , b ) ← r ( b , b ) , t ( c , b ) ← r ( c , b ) ,         t ( a , c ) ← r ( a , c ) , t ( b , c ) ← r ( b , c ) , t ( c , c ) ← r ( c , c )   Grounding aims at reducing the ground instantiation Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 60 / 538

  76. Variables An example P = { r ( a , b ) ← , r ( b , c ) ← , t ( X , Y ) ← r ( X , Y ) } T = { a , b , c } � r ( a , a ) , r ( a , b ) , r ( a , c ) , r ( b , a ) , r ( b , b ) , r ( b , c ) , r ( c , a ) , r ( c , b ) , r ( c , c ) , � A = t ( a , a ) , t ( a , b ) , t ( a , c ) , t ( b , a ) , t ( b , b ) , t ( b , c ) , t ( c , a ) , t ( c , b ) , t ( c , c )   r ( a , b ) ← ,     r ( b , c ) ← ,       ground ( P ) = t ( a , a ) ← r ( a , a ) , t ( b , a ) ← r ( b , a ) , t ( c , a ) ← r ( c , a ) , t ( a , b ) ← , t ( b , b ) ← r ( b , b ) , t ( c , b ) ← r ( c , b ) ,         t ( a , c ) ← r ( a , c ) , t ( b , c ) ← r ( b , c ) , t ( c , c ) ← r ( c , c )   Grounding aims at reducing the ground instantiation Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 60 / 538

  77. Variables Safety A normal rule is safe, if each of its variables also occurs in some positive body literal A normal program is safe, if all of its rules are safe Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 61 / 538

  78. Variables Example d ( a ) d ( c ) d ( d ) p ( a , b ) p ( b , c ) p ( c , d ) p ( X , Z ) ← p ( X , Y ) , p ( Y , Z ) q ( a ) q ( b ) q ( X ) ← ∼ r ( X ) r ( X ) ← ∼ q ( X ) , d ( X ) s ( X ) ← ∼ r ( X ) , p ( X , Y ) , q ( Y ) Torsten Schaub (KRR@UP) Answer Set Solving in Practice October 20, 2018 62 / 538

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend