SlideShare a Scribd company logo
1 of 138
Download to read offline
An Answer Set Programming Tutorial

                                             Minh Dao-Tran

                                 Institut für Informationsysteme, TU Wien

Supported by Austrian Science Fund (FWF) project P20841, and the Marie Curie action IRSES
                                  under Grant No. 2476

Based on slides from Thomas Eiter, Giovambattista Ianni, Thomas Krennwallner in the Reasoning Web Summer School 2009
                                           and slides from Torsten Schaub



                                            DERI, July 2011
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
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
An Answer Set Programming Tutorial   1. Introduction


 Knapsack Problem




     Minh Dao-Tran                                DERI, July 2011   3/33
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
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
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
An Answer Set Programming Tutorial   2. Horn Logic Programming    2.1 Positive Logic Programs


 Positive Logic Programs
   Definition (Positive Logic Program)
   A positive logic program P is a finite set of clauses (rules) in the form

                                            a ← b1 , . . . , bm

   where a, b1 , . . . , bm are atoms of a first-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
An Answer Set Programming Tutorial   2. Horn Logic Programming    2.1 Positive Logic Programs


 Positive Logic Programs
   Definition (Positive Logic Program)
   A positive logic program P is a finite set of clauses (rules) in the form

                                            a ← b1 , . . . , bm

   where a, b1 , . . . , bm are atoms of a first-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
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
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
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
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
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
An Answer Set Programming Tutorial   2. Horn Logic Programming    2.1 Positive Logic Programs


 Herbrand Models



   Definition (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
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
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
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
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
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.

   Definition
   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
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.

   Definition
   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
An Answer Set Programming Tutorial   2. Horn Logic Programming    2.2 Minimal Model Semantics


 Computation
   The minimal model can be computed via fixpoint 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
An Answer Set Programming Tutorial   2. Horn Logic Programming    2.2 Minimal Model Semantics


 Computation
   The minimal model can be computed via fixpoint 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
An Answer Set Programming Tutorial   2. Horn Logic Programming    2.2 Minimal Model Semantics


 Computation
   The minimal model can be computed via fixpoint 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
An Answer Set Programming Tutorial   2. Horn Logic Programming    2.2 Minimal Model Semantics


 Computation
   The minimal model can be computed via fixpoint 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
An Answer Set Programming Tutorial   2. Horn Logic Programming    2.2 Minimal Model Semantics


 Computation
   The minimal model can be computed via fixpoint 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
An Answer Set Programming Tutorial   3. Stable Logic Programming


 Negation in Logic Programs
   Why negation?

           Natural linguistic concept
           Facilitates convenient, declarative descriptions (definitions)
           E.g., "Men who are not husbands are singles.”




     Minh Dao-Tran                              DERI, July 2011            13/33
An Answer Set Programming Tutorial      3. Stable Logic Programming


 Negation in Logic Programs
   Why negation?

           Natural linguistic concept
           Facilitates convenient, declarative descriptions (definitions)
           E.g., "Men who are not husbands are singles.”

   Definition
   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 first-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
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
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
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
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
An Answer Set Programming Tutorial   3. Stable Logic Programming


 Stable Models

   Definition (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
An Answer Set Programming Tutorial   3. Stable Logic Programming


 Stable Models

   Definition (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
An Answer Set Programming Tutorial   3. Stable Logic Programming


 Stable Models

   Definition (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”.
   Definition (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
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
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
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
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
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
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
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
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
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
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.


   Definition (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
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
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
An Answer Set Programming Tutorial   4. Extensions                 4.1 Disjunction


 Disjunction
   The use of disjunction is natural to express indefinite knowledge.




     Minh Dao-Tran                               DERI, July 2011                     21/33
An Answer Set Programming Tutorial   4. Extensions                 4.1 Disjunction


 Disjunction
   The use of disjunction is natural to express indefinite knowledge.


   Example

           female(X) ∨ male(X) ← person(X).

           single(dilbert) ∨ husband(dilbert) ← man(dilbert).




     Minh Dao-Tran                               DERI, July 2011                     21/33
An Answer Set Programming Tutorial   4. Extensions                 4.1 Disjunction


 Disjunction
   The use of disjunction is natural to express indefinite 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
An Answer Set Programming Tutorial   4. Extensions                 4.1 Disjunction


 Disjunction
   The use of disjunction is natural to express indefinite 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
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
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
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
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
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
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
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
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)
                                     


              flies(X) ←              DL[Flier flies; Bird](X),
   P=
                                     not DL[Flier flies; ¬Flier](X).




     Minh Dao-Tran                                  DERI, July 2011                             27/33
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)
                                     


              flies(X) ←              DL[Flier flies; Bird](X),
   P=
                                     not DL[Flier flies; ¬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
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)
                                     


              flies(X) ←              DL[Flier flies; Bird](X),
   P=
                                     not DL[Flier flies; ¬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         flies; ¬Flier](X).

     Minh Dao-Tran                                  DERI, July 2011                             27/33
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
An Answer Set Programming Tutorial   7. Playing with ASP


 xkcd Knapsack


    order(Food) ∨ skip(Food) ← menu(Food, _).
    ok ← 825 ≤ #sum{Price : order(Food), menu(Food, Price)} ≤ 825.
            ← not ok.

    menu(mixed_fruit, 215).
    menu(french_fries, 275).
    menu(side_salad, 335).
    menu(host_wings, 355).
    menu(mozzarella_sticks, 420).
    menu(samples_place, 580).



     Minh Dao-Tran                               DERI, July 2011     34/33
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
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
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
An Answer Set Programming Tutorial     7. Playing with ASP


 Choosing wine
   Assume that we have a Wine ontology and specification 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
An Answer Set Programming Tutorial     7. Playing with ASP


 Choosing wine
   Assume that we have a Wine ontology and specification 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
An Answer Set Programming Tutorial     7. Playing with ASP


 Choosing wine
   Assume that we have a Wine ontology and specification 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
An Answer Set Programming Tutorial     7. Playing with ASP


 Choosing wine
   Assume that we have a Wine ontology and specification 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
An Answer Set Programming Tutorial     7. Playing with ASP


 Choosing wine
   Assume that we have a Wine ontology and specification 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
An Answer Set Programming Tutorial     7. Playing with ASP


 Choosing wine
   Assume that we have a Wine ontology and specification 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
An Answer Set Programming Tutorial     7. Playing with ASP


 Choosing wine
   Assume that we have a Wine ontology and specification 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
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
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.
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 infinite stable models.
    Artificial 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.
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.
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 Artificial 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).
References V


   Omar El-Khatib, Enrico Pontelli, and Tran Cao Son.
   Justification 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 finite model
   computation.
   AI Commun., 24(2):195–212, 2011.
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.
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.
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.
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, Artificial Intelligence and Reasoning
   (LPAR 2007), number 4790 in LNCS, pages 514–530. Springer, 2007.
   Extended Paper to appear in ACM Trans. Computational Logic.
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.
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.
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
An Answer Set Programming Tutorial   8. References                8.1 ASP Performance


 The 3rd ASP Competition - Scoring




     Minh Dao-Tran                              DERI, July 2011                         51/33
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
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 verification,
                   configuration, 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
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
               • unification - basic mechanism to manipulate data structures

           Extensive use of recursion



     Minh Dao-Tran                              DERI, July 2011                                       54/33
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
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
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

           Satisfied e.g. by the answer set semantics of logic programs

     Minh Dao-Tran                                  DERI, July 2011                                       56/33
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
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
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
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
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
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
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
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
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
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
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
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 “stratified programs”
           Different selection principles for non-stratified programs
     Minh Dao-Tran                              DERI, July 2011                                       59/33
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
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
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
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
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
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
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
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.

   Definition
   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
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.

   Definition
   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
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.

   Definition
   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
An Answer Set Programming Tutorial      8. References                  8.6 TP operator


 Computation

   The minimal model can be computed via fixpoint iteration.

   Definition (TP Operator)
   Let TP : 2HB(P) → 2HB(P) be defined 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
An Answer Set Programming Tutorial      8. References                  8.6 TP operator


 Computation

   The minimal model can be computed via fixpoint iteration.

   Definition (TP Operator)
   Let TP : 2HB(P) → 2HB(P) be defined 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 fixpoint, lfp(TP ), and the sequence TP ,                        i ≥ 0,
   converges to lfp(TP ).

     Minh Dao-Tran                                 DERI, July 2011                             63/33
An Answer Set Programming Tutorial   8. References                8.7 Answer Set Programming Systems for Debi


 Answer Set Programming Systems for Debian/Ubuntu




     Minh Dao-Tran                              DERI, July 2011                                     64/33
An Answer Set Programming Tutorial   8. References                8.7 Answer Set Programming Systems for Debi


 Answer Set Programming Systems for Debian/Ubuntu




     Minh Dao-Tran                              DERI, July 2011                                     65/33
An Answer Set Programming Tutorial   8. References                8.7 Answer Set Programming Systems for Debi


 Answer Set Programming Systems for Debian/Ubuntu




     Minh Dao-Tran                              DERI, July 2011                                     66/33
An Answer Set Programming Tutorial   8. References                8.7 Answer Set Programming Systems for Debi


 Answer Set Programming Systems for Debian/Ubuntu




     Minh Dao-Tran                              DERI, July 2011                                     67/33
An Answer Set Programming Tutorial   8. References                8.7 Answer Set Programming Systems for Debi


 Answer Set Programming Systems for Debian/Ubuntu




     Minh Dao-Tran                              DERI, July 2011                                     68/33
An Answer Set Programming Tutorial   8. References                8.7 Answer Set Programming Systems for Debi


 Answer Set Programming Systems for Debian/Ubuntu




     Minh Dao-Tran                              DERI, July 2011                                     69/33

More Related Content

What's hot

Reinforcement Learning and Neuroscience
Reinforcement Learning and NeuroscienceReinforcement Learning and Neuroscience
Reinforcement Learning and NeuroscienceMichael Bosello
 
Composing (Im)politeness in Dependent Type Semantics
Composing (Im)politeness in Dependent Type SemanticsComposing (Im)politeness in Dependent Type Semantics
Composing (Im)politeness in Dependent Type SemanticsDaisuke BEKKI
 
An Unorthodox View on Memetic Algorithms
An Unorthodox View on Memetic AlgorithmsAn Unorthodox View on Memetic Algorithms
An Unorthodox View on Memetic AlgorithmsNatalio Krasnogor
 
Truth as a logical connective?
Truth as a logical connective?Truth as a logical connective?
Truth as a logical connective?Shunsuke Yatabe
 
Jarrar.lecture notes.aai.2012s.descriptionlogic
Jarrar.lecture notes.aai.2012s.descriptionlogicJarrar.lecture notes.aai.2012s.descriptionlogic
Jarrar.lecture notes.aai.2012s.descriptionlogicSinaInstitute
 
Fuzzy Sets Introduction With Example
Fuzzy Sets Introduction With ExampleFuzzy Sets Introduction With Example
Fuzzy Sets Introduction With Exampleraisnasir
 
Jarrar: Description Logic
Jarrar: Description LogicJarrar: Description Logic
Jarrar: Description LogicMustafa Jarrar
 

What's hot (9)

Reinforcement Learning and Neuroscience
Reinforcement Learning and NeuroscienceReinforcement Learning and Neuroscience
Reinforcement Learning and Neuroscience
 
Composing (Im)politeness in Dependent Type Semantics
Composing (Im)politeness in Dependent Type SemanticsComposing (Im)politeness in Dependent Type Semantics
Composing (Im)politeness in Dependent Type Semantics
 
UWB semeval2016-task5
UWB semeval2016-task5UWB semeval2016-task5
UWB semeval2016-task5
 
An Unorthodox View on Memetic Algorithms
An Unorthodox View on Memetic AlgorithmsAn Unorthodox View on Memetic Algorithms
An Unorthodox View on Memetic Algorithms
 
www.ijerd.com
www.ijerd.comwww.ijerd.com
www.ijerd.com
 
Truth as a logical connective?
Truth as a logical connective?Truth as a logical connective?
Truth as a logical connective?
 
Jarrar.lecture notes.aai.2012s.descriptionlogic
Jarrar.lecture notes.aai.2012s.descriptionlogicJarrar.lecture notes.aai.2012s.descriptionlogic
Jarrar.lecture notes.aai.2012s.descriptionlogic
 
Fuzzy Sets Introduction With Example
Fuzzy Sets Introduction With ExampleFuzzy Sets Introduction With Example
Fuzzy Sets Introduction With Example
 
Jarrar: Description Logic
Jarrar: Description LogicJarrar: Description Logic
Jarrar: Description Logic
 

Viewers also liked

Viewers also liked (8)

50120140503001
5012014050300150120140503001
50120140503001
 
Contexts for Quantification
Contexts for QuantificationContexts for Quantification
Contexts for Quantification
 
Pargram2011
Pargram2011Pargram2011
Pargram2011
 
Lasers, Landscapes and Muddy Boots: Visualizing Laser Scanning Data Using Gam...
Lasers, Landscapes and Muddy Boots: Visualizing Laser Scanning Data Using Gam...Lasers, Landscapes and Muddy Boots: Visualizing Laser Scanning Data Using Gam...
Lasers, Landscapes and Muddy Boots: Visualizing Laser Scanning Data Using Gam...
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Slides
SlidesSlides
Slides
 
2006trip report
2006trip report2006trip report
2006trip report
 
Invariant-Free Clausal Temporal Resolution
Invariant-Free Clausal Temporal ResolutionInvariant-Free Clausal Temporal Resolution
Invariant-Free Clausal Temporal Resolution
 

Similar to Answer Set Programming Tutorial: Modeling Problems Declaratively

Chapter 3 projection
Chapter 3 projectionChapter 3 projection
Chapter 3 projectionNBER
 
GDSC SSN - solution Challenge : Fundamentals of Decision Making
GDSC SSN - solution Challenge : Fundamentals of Decision MakingGDSC SSN - solution Challenge : Fundamentals of Decision Making
GDSC SSN - solution Challenge : Fundamentals of Decision MakingGDSCSSN
 
Tro07 sparse-solutions-talk
Tro07 sparse-solutions-talkTro07 sparse-solutions-talk
Tro07 sparse-solutions-talkmpbchina
 
Nsu module 01-logic-final
Nsu module 01-logic-finalNsu module 01-logic-final
Nsu module 01-logic-finalSOURAV
 
10 logic+programming+with+prolog
10 logic+programming+with+prolog10 logic+programming+with+prolog
10 logic+programming+with+prologbaran19901990
 
Functions D1 Notes
Functions D1 NotesFunctions D1 Notes
Functions D1 Notesguest19cd1f
 
Functions D1 Notes
Functions D1 NotesFunctions D1 Notes
Functions D1 Notesguest19cd1f
 
kgpresentation.pdf
kgpresentation.pdfkgpresentation.pdf
kgpresentation.pdfssuser4cd9a9
 
Jarrar.lecture notes.aai.2011s.ch8.fol.introduction
Jarrar.lecture notes.aai.2011s.ch8.fol.introductionJarrar.lecture notes.aai.2011s.ch8.fol.introduction
Jarrar.lecture notes.aai.2011s.ch8.fol.introductionPalGov
 
POPL 2012 Presentation
POPL 2012 PresentationPOPL 2012 Presentation
POPL 2012 Presentationagarwal1975
 
final report.doc
final report.docfinal report.doc
final report.docbutest
 
Ontological Conjunctive Query Answering over Large Knowledge Bases
Ontological Conjunctive Query Answering over Large Knowledge BasesOntological Conjunctive Query Answering over Large Knowledge Bases
Ontological Conjunctive Query Answering over Large Knowledge BasesUniversity of New South Wales
 

Similar to Answer Set Programming Tutorial: Modeling Problems Declaratively (20)

Chapter 3 projection
Chapter 3 projectionChapter 3 projection
Chapter 3 projection
 
GDSC SSN - solution Challenge : Fundamentals of Decision Making
GDSC SSN - solution Challenge : Fundamentals of Decision MakingGDSC SSN - solution Challenge : Fundamentals of Decision Making
GDSC SSN - solution Challenge : Fundamentals of Decision Making
 
Semantics
SemanticsSemantics
Semantics
 
Tro07 sparse-solutions-talk
Tro07 sparse-solutions-talkTro07 sparse-solutions-talk
Tro07 sparse-solutions-talk
 
Chaps 1-3-ai-prolog
Chaps 1-3-ai-prologChaps 1-3-ai-prolog
Chaps 1-3-ai-prolog
 
Nsu module 01-logic-final
Nsu module 01-logic-finalNsu module 01-logic-final
Nsu module 01-logic-final
 
10 logic+programming+with+prolog
10 logic+programming+with+prolog10 logic+programming+with+prolog
10 logic+programming+with+prolog
 
Recursion (in Python)
Recursion (in Python)Recursion (in Python)
Recursion (in Python)
 
Functions D1 Notes
Functions D1 NotesFunctions D1 Notes
Functions D1 Notes
 
Functions D1 Notes
Functions D1 NotesFunctions D1 Notes
Functions D1 Notes
 
The NLP Muppets revolution!
The NLP Muppets revolution!The NLP Muppets revolution!
The NLP Muppets revolution!
 
kgpresentation.pdf
kgpresentation.pdfkgpresentation.pdf
kgpresentation.pdf
 
Jarrar.lecture notes.aai.2011s.ch8.fol.introduction
Jarrar.lecture notes.aai.2011s.ch8.fol.introductionJarrar.lecture notes.aai.2011s.ch8.fol.introduction
Jarrar.lecture notes.aai.2011s.ch8.fol.introduction
 
Pdf5
Pdf5Pdf5
Pdf5
 
POPL 2012 Presentation
POPL 2012 PresentationPOPL 2012 Presentation
POPL 2012 Presentation
 
ppt
pptppt
ppt
 
ppt
pptppt
ppt
 
Stochastic Processes Homework Help
Stochastic Processes Homework Help Stochastic Processes Homework Help
Stochastic Processes Homework Help
 
final report.doc
final report.docfinal report.doc
final report.doc
 
Ontological Conjunctive Query Answering over Large Knowledge Bases
Ontological Conjunctive Query Answering over Large Knowledge BasesOntological Conjunctive Query Answering over Large Knowledge Bases
Ontological Conjunctive Query Answering over Large Knowledge Bases
 

More from net2-project

Random Manhattan Indexing
Random Manhattan IndexingRandom Manhattan Indexing
Random Manhattan Indexingnet2-project
 
Extracting Information for Context-aware Meeting Preparation
Extracting Information for Context-aware Meeting PreparationExtracting Information for Context-aware Meeting Preparation
Extracting Information for Context-aware Meeting Preparationnet2-project
 
Vector spaces for information extraction - Random Projection Example
Vector spaces for information extraction - Random Projection ExampleVector spaces for information extraction - Random Projection Example
Vector spaces for information extraction - Random Projection Examplenet2-project
 
Borders of Decidability in Verification of Data-Centric Dynamic Systems
Borders of Decidability in Verification of Data-Centric Dynamic SystemsBorders of Decidability in Verification of Data-Centric Dynamic Systems
Borders of Decidability in Verification of Data-Centric Dynamic Systemsnet2-project
 
Exchanging OWL 2 QL Knowledge Bases
Exchanging OWL 2 QL Knowledge BasesExchanging OWL 2 QL Knowledge Bases
Exchanging OWL 2 QL Knowledge Basesnet2-project
 
Federation and Navigation in SPARQL 1.1
Federation and Navigation in SPARQL 1.1Federation and Navigation in SPARQL 1.1
Federation and Navigation in SPARQL 1.1net2-project
 
Mining Semi-structured Data: Understanding Web-tables – Building a Taxonomy f...
Mining Semi-structured Data: Understanding Web-tables – Building a Taxonomy f...Mining Semi-structured Data: Understanding Web-tables – Building a Taxonomy f...
Mining Semi-structured Data: Understanding Web-tables – Building a Taxonomy f...net2-project
 
Extending DBpedia (LOD) using WikiTables
Extending DBpedia (LOD) using WikiTablesExtending DBpedia (LOD) using WikiTables
Extending DBpedia (LOD) using WikiTablesnet2-project
 
Tailoring Temporal Description Logics for Reasoning over Temporal Conceptual ...
Tailoring Temporal Description Logics for Reasoning over Temporal Conceptual ...Tailoring Temporal Description Logics for Reasoning over Temporal Conceptual ...
Tailoring Temporal Description Logics for Reasoning over Temporal Conceptual ...net2-project
 
Managing Social Communities
Managing Social CommunitiesManaging Social Communities
Managing Social Communitiesnet2-project
 
Data Exchange over RDF
Data Exchange over RDFData Exchange over RDF
Data Exchange over RDFnet2-project
 
Exchanging more than Complete Data
Exchanging more than Complete DataExchanging more than Complete Data
Exchanging more than Complete Datanet2-project
 
Exchanging More than Complete Data
Exchanging More than Complete DataExchanging More than Complete Data
Exchanging More than Complete Datanet2-project
 
Answer-set programming
Answer-set programmingAnswer-set programming
Answer-set programmingnet2-project
 
Evolving web, evolving search
Evolving web, evolving searchEvolving web, evolving search
Evolving web, evolving searchnet2-project
 
SPARQL1.1 Tutorial, given in UChile by Axel Polleres (DERI)
SPARQL1.1 Tutorial, given in UChile by Axel Polleres (DERI)SPARQL1.1 Tutorial, given in UChile by Axel Polleres (DERI)
SPARQL1.1 Tutorial, given in UChile by Axel Polleres (DERI)net2-project
 

More from net2-project (17)

Random Manhattan Indexing
Random Manhattan IndexingRandom Manhattan Indexing
Random Manhattan Indexing
 
Extracting Information for Context-aware Meeting Preparation
Extracting Information for Context-aware Meeting PreparationExtracting Information for Context-aware Meeting Preparation
Extracting Information for Context-aware Meeting Preparation
 
Vector spaces for information extraction - Random Projection Example
Vector spaces for information extraction - Random Projection ExampleVector spaces for information extraction - Random Projection Example
Vector spaces for information extraction - Random Projection Example
 
Borders of Decidability in Verification of Data-Centric Dynamic Systems
Borders of Decidability in Verification of Data-Centric Dynamic SystemsBorders of Decidability in Verification of Data-Centric Dynamic Systems
Borders of Decidability in Verification of Data-Centric Dynamic Systems
 
Exchanging OWL 2 QL Knowledge Bases
Exchanging OWL 2 QL Knowledge BasesExchanging OWL 2 QL Knowledge Bases
Exchanging OWL 2 QL Knowledge Bases
 
Federation and Navigation in SPARQL 1.1
Federation and Navigation in SPARQL 1.1Federation and Navigation in SPARQL 1.1
Federation and Navigation in SPARQL 1.1
 
Mining Semi-structured Data: Understanding Web-tables – Building a Taxonomy f...
Mining Semi-structured Data: Understanding Web-tables – Building a Taxonomy f...Mining Semi-structured Data: Understanding Web-tables – Building a Taxonomy f...
Mining Semi-structured Data: Understanding Web-tables – Building a Taxonomy f...
 
Extending DBpedia (LOD) using WikiTables
Extending DBpedia (LOD) using WikiTablesExtending DBpedia (LOD) using WikiTables
Extending DBpedia (LOD) using WikiTables
 
Tailoring Temporal Description Logics for Reasoning over Temporal Conceptual ...
Tailoring Temporal Description Logics for Reasoning over Temporal Conceptual ...Tailoring Temporal Description Logics for Reasoning over Temporal Conceptual ...
Tailoring Temporal Description Logics for Reasoning over Temporal Conceptual ...
 
Managing Social Communities
Managing Social CommunitiesManaging Social Communities
Managing Social Communities
 
Data Exchange over RDF
Data Exchange over RDFData Exchange over RDF
Data Exchange over RDF
 
Exchanging more than Complete Data
Exchanging more than Complete DataExchanging more than Complete Data
Exchanging more than Complete Data
 
Exchanging More than Complete Data
Exchanging More than Complete DataExchanging More than Complete Data
Exchanging More than Complete Data
 
Answer-set programming
Answer-set programmingAnswer-set programming
Answer-set programming
 
Evolving web, evolving search
Evolving web, evolving searchEvolving web, evolving search
Evolving web, evolving search
 
XSPARQL Tutorial
XSPARQL TutorialXSPARQL Tutorial
XSPARQL Tutorial
 
SPARQL1.1 Tutorial, given in UChile by Axel Polleres (DERI)
SPARQL1.1 Tutorial, given in UChile by Axel Polleres (DERI)SPARQL1.1 Tutorial, given in UChile by Axel Polleres (DERI)
SPARQL1.1 Tutorial, given in UChile by Axel Polleres (DERI)
 

Recently uploaded

Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 

Answer Set Programming Tutorial: Modeling Problems Declaratively

  • 1. An Answer Set Programming Tutorial Minh Dao-Tran Institut für Informationsysteme, TU Wien Supported by Austrian Science Fund (FWF) project P20841, and the Marie Curie action IRSES under Grant No. 2476 Based 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. 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. 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. An Answer Set Programming Tutorial 1. Introduction Knapsack Problem Minh Dao-Tran DERI, July 2011 3/33
  • 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. 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. 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. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.1 Positive Logic Programs Positive Logic Programs Definition (Positive Logic Program) A positive logic program P is a finite set of clauses (rules) in the form a ← b1 , . . . , bm where a, b1 , . . . , bm are atoms of a first-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. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.1 Positive Logic Programs Positive Logic Programs Definition (Positive Logic Program) A positive logic program P is a finite set of clauses (rules) in the form a ← b1 , . . . , bm where a, b1 , . . . , bm are atoms of a first-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. 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. 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. 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. 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. 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. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.1 Positive Logic Programs Herbrand Models Definition (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. 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. 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. 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. 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. 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. Definition 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. 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. Definition 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. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.2 Minimal Model Semantics Computation The minimal model can be computed via fixpoint 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. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.2 Minimal Model Semantics Computation The minimal model can be computed via fixpoint 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. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.2 Minimal Model Semantics Computation The minimal model can be computed via fixpoint 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. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.2 Minimal Model Semantics Computation The minimal model can be computed via fixpoint 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. An Answer Set Programming Tutorial 2. Horn Logic Programming 2.2 Minimal Model Semantics Computation The minimal model can be computed via fixpoint 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. An Answer Set Programming Tutorial 3. Stable Logic Programming Negation in Logic Programs Why negation? Natural linguistic concept Facilitates convenient, declarative descriptions (definitions) E.g., "Men who are not husbands are singles.” Minh Dao-Tran DERI, July 2011 13/33
  • 28. An Answer Set Programming Tutorial 3. Stable Logic Programming Negation in Logic Programs Why negation? Natural linguistic concept Facilitates convenient, declarative descriptions (definitions) E.g., "Men who are not husbands are singles.” Definition 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 first-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. 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. 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. 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. 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. An Answer Set Programming Tutorial 3. Stable Logic Programming Stable Models Definition (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. An Answer Set Programming Tutorial 3. Stable Logic Programming Stable Models Definition (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. An Answer Set Programming Tutorial 3. Stable Logic Programming Stable Models Definition (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”. Definition (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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. Definition (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. 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. 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. An Answer Set Programming Tutorial 4. Extensions 4.1 Disjunction Disjunction The use of disjunction is natural to express indefinite knowledge. Minh Dao-Tran DERI, July 2011 21/33
  • 49. An Answer Set Programming Tutorial 4. Extensions 4.1 Disjunction Disjunction The use of disjunction is natural to express indefinite knowledge. Example female(X) ∨ male(X) ← person(X). single(dilbert) ∨ husband(dilbert) ← man(dilbert). Minh Dao-Tran DERI, July 2011 21/33
  • 50. An Answer Set Programming Tutorial 4. Extensions 4.1 Disjunction Disjunction The use of disjunction is natural to express indefinite 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. An Answer Set Programming Tutorial 4. Extensions 4.1 Disjunction Disjunction The use of disjunction is natural to express indefinite 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. 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. 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. 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. 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. 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. 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. 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. 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)   flies(X) ← DL[Flier flies; Bird](X), P= not DL[Flier flies; ¬Flier](X). Minh Dao-Tran DERI, July 2011 27/33
  • 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)   flies(X) ← DL[Flier flies; Bird](X), P= not DL[Flier flies; ¬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. 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)   flies(X) ← DL[Flier flies; Bird](X), P= not DL[Flier flies; ¬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 flies; ¬Flier](X). Minh Dao-Tran DERI, July 2011 27/33
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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
  • 78. An Answer Set Programming Tutorial 7. Playing with ASP xkcd Knapsack order(Food) ∨ skip(Food) ← menu(Food, _). ok ← 825 ≤ #sum{Price : order(Food), menu(Food, Price)} ≤ 825. ← not ok. menu(mixed_fruit, 215). menu(french_fries, 275). menu(side_salad, 335). menu(host_wings, 355). menu(mozzarella_sticks, 420). menu(samples_place, 580). Minh Dao-Tran DERI, July 2011 34/33
  • 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. 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. 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. An Answer Set Programming Tutorial 7. Playing with ASP Choosing wine Assume that we have a Wine ontology and specification 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. An Answer Set Programming Tutorial 7. Playing with ASP Choosing wine Assume that we have a Wine ontology and specification 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. An Answer Set Programming Tutorial 7. Playing with ASP Choosing wine Assume that we have a Wine ontology and specification 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. An Answer Set Programming Tutorial 7. Playing with ASP Choosing wine Assume that we have a Wine ontology and specification 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. An Answer Set Programming Tutorial 7. Playing with ASP Choosing wine Assume that we have a Wine ontology and specification 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. An Answer Set Programming Tutorial 7. Playing with ASP Choosing wine Assume that we have a Wine ontology and specification 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. An Answer Set Programming Tutorial 7. Playing with ASP Choosing wine Assume that we have a Wine ontology and specification 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. 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. 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. 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 infinite stable models. Artificial 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. 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. 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 Artificial 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. References V Omar El-Khatib, Enrico Pontelli, and Tran Cao Son. Justification 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 finite model computation. AI Commun., 24(2):195–212, 2011.
  • 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. 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. 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. 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, Artificial Intelligence and Reasoning (LPAR 2007), number 4790 in LNCS, pages 514–530. Springer, 2007. Extended Paper to appear in ACM Trans. Computational Logic.
  • 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. 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. 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. 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. 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. 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 verification, configuration, 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. 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 • unification - basic mechanism to manipulate data structures Extensive use of recursion Minh Dao-Tran DERI, July 2011 54/33
  • 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. 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. 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 Satisfied e.g. by the answer set semantics of logic programs Minh Dao-Tran DERI, July 2011 56/33
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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 “stratified programs” Different selection principles for non-stratified programs Minh Dao-Tran DERI, July 2011 59/33
  • 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. 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. 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. 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. 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. 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. 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. 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. Definition 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. 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. Definition 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. 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. Definition 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. An Answer Set Programming Tutorial 8. References 8.6 TP operator Computation The minimal model can be computed via fixpoint iteration. Definition (TP Operator) Let TP : 2HB(P) → 2HB(P) be defined 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. An Answer Set Programming Tutorial 8. References 8.6 TP operator Computation The minimal model can be computed via fixpoint iteration. Definition (TP Operator) Let TP : 2HB(P) → 2HB(P) be defined 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 fixpoint, lfp(TP ), and the sequence TP , i ≥ 0, converges to lfp(TP ). Minh Dao-Tran DERI, July 2011 63/33
  • 133. An Answer Set Programming Tutorial 8. References 8.7 Answer Set Programming Systems for Debi Answer Set Programming Systems for Debian/Ubuntu Minh Dao-Tran DERI, July 2011 64/33
  • 134. An Answer Set Programming Tutorial 8. References 8.7 Answer Set Programming Systems for Debi Answer Set Programming Systems for Debian/Ubuntu Minh Dao-Tran DERI, July 2011 65/33
  • 135. An Answer Set Programming Tutorial 8. References 8.7 Answer Set Programming Systems for Debi Answer Set Programming Systems for Debian/Ubuntu Minh Dao-Tran DERI, July 2011 66/33
  • 136. An Answer Set Programming Tutorial 8. References 8.7 Answer Set Programming Systems for Debi Answer Set Programming Systems for Debian/Ubuntu Minh Dao-Tran DERI, July 2011 67/33
  • 137. An Answer Set Programming Tutorial 8. References 8.7 Answer Set Programming Systems for Debi Answer Set Programming Systems for Debian/Ubuntu Minh Dao-Tran DERI, July 2011 68/33
  • 138. An Answer Set Programming Tutorial 8. References 8.7 Answer Set Programming Systems for Debi Answer Set Programming Systems for Debian/Ubuntu Minh Dao-Tran DERI, July 2011 69/33