negation in logic programming
play

Negation in logic programming Ex .: Old example program P f on family - PowerPoint PPT Presentation

Definite programs General programs Definite programs General programs NAF, CWA comp ( P ) Programs do not have any negative consequences. But sometimes we need them. Negation in logic programming Ex .: Old example program P f on family


  1. Definite programs General programs Definite programs General programs NAF, CWA comp ( P ) Programs do not have any negative consequences. But sometimes we need them. Negation in logic programming Ex .: Old example program P f on family relations. Summary We would like to derive ¬ child ( a, b ) when P f � | = child ( a, b ) . Two approaches TDDD08 tutorial 1. CWA (closed world assumption) P ⊢ CWA ¬ A whenever P � | = A ( A – ground atom) Włodzimierz Drabent i.e. M P | = ¬ A For TDDD08 Link¨ oping University (Sweden) 2. NAF (negation as finite failure) ( A – atom) P ⊢ NAF ¬ A whenever P � | = A Version 0.6 compiled on October 5, 2020 and an SLD-tree for A is finite (finitely failed tree) 1 / 18 3 / 18 Definite programs General programs Definite programs General programs NAF, CWA comp ( P ) Outline Difference CWA, NAF ◮ Negation and definite logic programs ◮ NAF, CWA ◮ Program completion Ex .: P = { p ← p } P ⊢ CWA ¬ p P �⊢ NAF ¬ p ◮ General logic programs ◮ SLDNF-resolution (generalizing NAF) ◮ Generalizing CWA ◮ Stratified programs & standard models ◮ Stable model semantics 2 / 18 4 / 18

  2. Definite programs General programs NAF, CWA comp ( P ) Definite programs General programs NAF, CWA comp ( P ) CWA, NAF – declarative semantics Program completion, roughly t 1 ) ← � p ( � B 1 equivalent 1 to · · · p ( V 1 , . . . , V k ) ← β one axiom CWA characterized by the least Herbrand model M P t n ) ← � p ( � B n Then the completion contains p ( V 1 , . . . , V k ) ↔ β NAF characterized by the completion of the program, comp ( P ) (for each predicate p in the program) As = occurs in β , the completion includes axioms for equality, called CET CET assures that distinct ground terms are not equal 1 in a certain sense 5 / 18 7 / 18 Definite programs General programs NAF, CWA comp ( P ) Definite programs General programs NAF, CWA comp ( P ) Program completion comp ( P ) works as expected NAF characterized by the completion of the program, comp ( P ) comp ( P ) describes NAF and the standard positive answers: Main idea (roughly): Th .: (Soundness and completeness) comp ( P ) is P with ← converted into ↔ . For any definite program and query P, Q so that comp ( P ) also says that A is false when not implied by the program P ⊢ NAF ¬ Q iff comp ( P ) | = ¬ Q P | = Q iff comp ( P ) | = Q iff Q is a computed Ex .: p ( a ) ← q ( X ) p ( V ) ↔ V = a, ∃ X. q ( X ) ∨ answer of P � p ( f ( Y )) ← r ( Y ) ∃ Y. ( V = f ( Y ) , r ( Y )) 6 / 18 8 / 18

  3. Definite programs General programs SLDNF Generalizing CWA Stratified SMS Definite programs General programs SLDNF Generalizing CWA Stratified SMS General logic programs Declarative/logic characterization of SLDNF-resolution SLDNF-resolution is sound w.r.t. comp ( P ) : Th .: P, Q - general program and query We would like to have negation in queries and programs. Q is an SLDNF-computed answer for P ⇒ comp ( P ) | = Q E.g. A query grandchild ( X , adam ) , ¬ descendant ( X , bill ) A finitely failed tree for Q ⇒ comp ( P ) | = ¬ Q General programs – But comp ( P ) does not describe SLDNF-resolution well also negated atoms (negative literals) allowed in clause bodies It implies too much ·· ⌢ ☞ A “right” semantics: comp ( P ) in a certain 3-valued logic NAF � SLDNF-resolution, natural generalization of SLD-resolution Equivalently, a modified completion (in standard logic, cf. old slides) CWA � . . . For such semantics, SLDNF-resolution sound, and complete for non-floundering queries. 9 / 18 11 / 18 Definite programs General programs SLDNF Generalizing CWA Stratified SMS Definite programs General programs SLDNF Generalizing CWA Stratified SMS SLDNF-resolution Generalizing CWA WFS (well-founded semantics) Like SLD-resolution: derivations, answers, SLDNF-trees general programs ↑ When ¬ A selected in a query Q , build an SLDNF-tree for A . 3 cases: CWA − → standard model definite programs stratified programs answer A obtained 2 A finitely fails otherwise ↓ ( A false, ¬ A true) ( A true, ¬ A false) ( A – ? ) Q Q Q stable model semantics | ×   general programs NAF � � no children, Q with ¬ A removed definite programs � �   ↓ no children, “failed leaf”   ↓   floundering   ASP (answer set programming)   3v completion sem.,     (SLDNF-resolution) disjunctive programs A finitely fails = SLDNF-tree finite, no answers, no floundering   (with rules H 1 ∨ · · · ∨ H m ← B 1 , . . . , B n ) general programs 2 most general answer 10 / 18 12 / 18

  4. Definite programs General programs SLDNF Generalizing CWA Stratified SMS Definite programs General programs SLDNF Generalizing CWA Stratified SMS Stratified programs Generalizing CWA for stratified programs The standard model of P constructed strata-wise Main feature - no recursion through negation. Strata: P 1 , . . . , P n A sequence of minimal Herbrand models: Program divided into strata. M i – the standard model of P 1 ∪ · · · ∪ P i Each predicate defined in a single stratum. M i \ M i − 1 contains only predicate symbols defined in P i A predicate in a positive body literal – defined in the same or an earlier stratum Constructed similarly to least Herbrand model, M i = � ∞ j =1 ( T P i ) j ( M i − 1 ) A predicate in a negative body literal – defined in an earlier stratum Details, example – [Nilsson,Małuszyński] Ch.4.4 Another approach, example – sli.10c.neg. ∗ 13 / 18 15 / 18 Definite programs General programs SLDNF Generalizing CWA Stratified SMS Definite programs General programs SLDNF Generalizing CWA Stratified SMS Example, stratified program Stable model semantics (SMS) Main idea: Guess an Herbrand interpretation I . � go well together ( X, Y ) ← ¬ incompatible ( X, Y ) . P 3 = Use I to evaluate negative literals of P � P I . � incompatible ( X, Y ) ← ¬ likes ( X, Y ) . P I – definite program, called the reduct of P w.r.t. I . P 2 = incompatible ( X, Y ) ← ¬ likes ( Y, X ) . If the the least Herbrand model of P I is I  likes ( X, Y ) ← harmless ( Y ) .  A | P I |  likes ( X, Y ) ← eats ( X, Y ) . M P I = { A ∈ B = A } = I  P 1 = harmless ( rabbit ) . then I is a stable model of P .   eats ( python, rabbit ) .  P I is ground ( P ) without Details: ◮ each rule with some ¬ A , s.t. I | = A ◮ each ¬ A , s.t. I | = ¬ A 14 / 18 16 / 18

  5. Definite programs General programs SLDNF Generalizing CWA Stratified SMS Stable model semantics (SMS) Stratified program: unique stable model = standard model 17 / 18 Definite programs General programs SLDNF Generalizing CWA Stratified SMS Stable model semantics (SMS) Different pragmatics than the rest of Logic Programming: LP: problem solutions – program answers SMS: problem solutions – stable models of programs SMS usable only if the universe finite no function symbols, no data structures 18 / 18

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