Your Federal Quarterly Tax Payments are due April 15th Get Help Now >>

boston-worskhop-may-04 by gegeshandong


									Using answer set programming
 to answer complex queries
                         Chitta Baral
   (joint work with Michael Gelfond and Richard Scherl)
                   Arizona State University
                      Tempe, AZ 86287
         Queries and Answers
• Answering queries with respect to databases:
  various query languages
  –   Relational databases: SQL3
  –   Object-Oriented Databases: OQL
  –   Web databases, XML Databases: XML-QL
  –   Prolog queries
• Natural language queries
  – Often translated to one of the above
• Complex Queries!
  – Need knowledge beyond that is present in the given
    data (or text) to answer.
  – Many can not be expressed in classical logics.
     Complex Query example –
         predictive query
• Text/Data: John is at home in Boston and
  has not bought a ticket to Paris yet.
• Query:
  – What happens if John tries to fly to Paris?
  – What happens if John buys a ticket to Paris
    and then tries to fly to Paris?
      Complex Query example:
        explanation query
• Text/Data: On Dec 10th John is at home in
  Boston and has not bought a ticket to
  Paris yet. On Dec 11th he is in Paris.
• Query:
  – Explain what might have happened in
    • Bought a ticket; gone to the airport; taken a flight to
      Complex Query Example:
          planning query
• Text/Data: On Dec 10th John is at home in
  Boston and has not bought a ticket to
  Paris yet.
• Query: What does John need to do to be
  in Paris on Dec 11th.
  – He needs to buy the ticket || get to the airport;
    fly to Paris.
      Complex Query Example:
       Counterfactual Query
• Text/Data: On Dec 10th John is at home in
  Boston. He made a plan to get to Paris by
  Dec 11th. He then bought a ticket. But on
  his way to the airport he got stuck in the
  traffic. The Boston to Paris flight did not
  make it.
• Query: What if John had not gotten stuck
  in the traffic?
      Complex Query Example:
       query about narratives
• Text/Data: John, who always carries his
  laptop with him, took a flight from Boston
  to Paris on the morning of Dec 11th.
• Queries:
  – Where is John on the evening of Dec 11th?
  – In which city is John’s laptop that evening?
      Complex Query Example:
         Causal queries
• Text/Data: On Dec 10th John is at home in
  Boston. He made a plan to get to Paris by
  Dec 11th. He then bought a ticket. But on
  his way to the airport he got stuck in the
  traffic. He reached the airport late and his
  flight had left.
• Queries:
  – What are the causes of John missing the
      Our approach to answer such
• Develop various knowledge modules in an
  appropriate knowledge representation and
  reasoning language.
  –   Travel module (includes flying, driving)
  –   Geography Module
  –   Time module
  –   Reasoning about actions module
  –   Planning module
  –   Explanation module
  –   Counterfactual module
  –   Cause finding module
Representation &
        What properties should an
    appropriate KR & R language have
•     Should be non-monotonic. So that the system can revise its earlier
      conclusion in light of new information.
•     Should have the ability to represent normative statements, exceptions,
      and default statements, and should be able to reason with them.
•     Should be expressive enough to express and answer problem solving
      queries such as planning queries, counterfactual queries,
      explanation queries and diagnostic queries.
•     Should have a simple and intuitive syntax so that domain experts (who
      may be non-computer scientists) can express knowledge using it.
•     Should have enough existing research (or building block results) about
      this language so that one does not have to start from scratch.
•     Should have interpreters or implementation of the language so that one
      can indeed represent and reason in this language. (I.e., it should not be
      just a theoretical language.)
•     Should have existing applications that have been built on this language
      so as to demonstrate the feasibility that applications can be indeed built
      using this language.
   AnsProlog – a suitable knowledge
representation and reasoning language
• AnsProlog – Programming in logic with answer sets
• Syntax: Set of statements of the form:
   A0 or … or Ak  B1, …, Bm, not C1, … not Cn.
• Intuitive meaning of the above statement:
   – If B1, …, Bm is known to be true and C1, …, Cn can be assumed
     to be false then at least one of A0 ,…, Ak must be true.
• Semantics
   – A set of atoms A is an answer set of a program P if A is the
     minimal model of the program PA obtained by using A to remove
     all literals of the form not C.
       • If C is in A then remove that rule and if C is not in A then remove
         not C from that rule’s body
   – {a  not b; b  not a} {a} = {a }
   AnsProlog Program example:
    illustrating non-monotonicity
T1 fly(X)  bird(X), not ab(X).
T2 bird(X)  penguin(X).
T3 ab(X)  penguin(X).
T4 bird(tweety).
{T1, T2, T3, T4} |= fly(tweety).
{T1, T2,T3, T4, penguin(tweety)} |= ~
Transitive Closure in AnsProlog
ancestor(X,Y)  ancestor(X,Z), parent(Z,Y).
ancestor(X,Y)  parent(X,Y).
          Planning using AnsProlog
•   initially ~f.   initially ~g.   b causes f if g.     a causes g.    finally f.

        a;b is a plan that achieves the goal.

•   Planning: All answer sets encode a plan.

     – Describing the initial state.                   ~ holds(f, 1).   ~holds(g, 1).
     – Describing effect of actions.
                                          holds(f,T+1) occurs(b,T), holds(g,T).
                                          holds(g,T+1) occurs(a,T).

     – Describing what does not change.
                                   holds(f,T+1) holds(f,T), not ~holds(f,T+1).
                                   ~holds(f,T+1) ~holds(f,T), not holds(f,T+1).
     – Enumerating possible plans.
                                   other-occurs(A,T) occurs(B,T), A =\= B.
                                   occurs(A,T)  not other-occurs(A,T).

     – Eliminating answer sets which do not encode a plan.
                                    not holds(f, plan-length+1).
         AnsProlog vs Prolog
• Differences:
  – Prolog is sensitive to ordering of rules and ordering of
    literals in the body of rules.
  – Inappropriate ordering leads to infinite loops. (Thus
    Prolog is not declarative; hence not a knowledge
    representation language)
  – Prolog stumbles with recursion through negation
• Similarities: For certain subclasses Prolog can
  be thought of as a top-down engine for
       AnsProlog vs other KR & R
• AnsProlog has a simple syntax and semantics
• Syntax has structure that allows defining sub-classes
• More expressive than propositional and first-order logic;
  propositional AnsProlog is as expressive as default logic.
  Yet much simpler.
• It has the largest body of support structure (theoretical
  results as well as implementations) among the various
  knowledge representation languages
   – Description logic comes close. But its focus is very narrow,
     namely representing and reasoning about ontologies.
• …
  Building blocks for AnsProlog
• Subclasses and their properties.
  – Definite, normal, extended, disjunctive.
  – Acyclic, signed, stratified, call-consistent, order-
• Properties
  –   Existence of consistent answer sets.
  –   Existence of unique answer sets.
  –   Complexity of entailment.
  –   Expressibility of the entailment relation.
  –   Relation between the literals in an answer set and the
Building blocks for AnsProlog- cont.
 – Transforming programs.
 – Equivalence of programs.
 – Formal relation with other languages.
   (classical logic, default logic, etc.)
 – Splitting programs – modular analysis, and
   computation of answer sets.
 – Systematic building of programs from
   components: program composition.
 Examples of specific properties
• Expressibility
   – Function-free AnsProlog without disjunctions: P1P
   – Function-free AnsProlog: P2 P.
   – AnsProlog: P11
• Relation between literals in an answer set and
  the program.
   – If ‘f’ is in an answer set ‘A’ of a program P, then there
     must be a rule in P such that …
   – If an answer set ‘A’ of a program P satisfies the body
     of a rule ‘r’ of P then, the head of that rule …
          Some existing AnsProlog
• Reasoning
   – Reasoning with incomplete information, default reasonong.
   – Reasoning with preferences and priorities, inheritance
• Declarative problem solving
   –   Planning, job-shop scheduling, tournament scheduling.
   –   Abductive reasoning, explanation generations, diagnosis.
   –   Combinatorial graph problems.
   –   Combinatorial optimizations, combinatorial auctions.
   –   Product configuration.
• Software Engineering: Specification is the program.
  (rapid prototyping)
Ilustration of

To top