Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Answer-set programming
1. ASP
Rules and Ontologies
Debugging in ASP
Answer-Set Programming
Basics, Combinations with Ontologies, and Debugging
Jörg Pührer
Knowledge Based Systems Group, Institute for Information Systems
Vienna University of Technology
Partially supported by the European Commission under
FP7 Project ONTORULE, Marie Curie Actions Project NET2,
and the Austrian Science Fund (FWF) P21698
Jörg Pührer Answer-Set Programming 1 / 71
2. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Context
We deal with answer-set programming (ASP)
Programming paradigm
Jörg Pührer Answer-Set Programming 2 / 71
3. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Context
We deal with answer-set programming (ASP)
Programming paradigm
Term coined by Lifschitz (1999)
Proposed by others people (Marek and Truszczyński, Niemelä)
at about the same time
Jörg Pührer Answer-Set Programming 2 / 71
4. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Context
We deal with answer-set programming (ASP)
Programming paradigm
Term coined by Lifschitz (1999)
Proposed by others people (Marek and Truszczyński, Niemelä)
at about the same time
Fruitful approach for declarative problem solving
Jörg Pührer Answer-Set Programming 2 / 71
5. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Context
We deal with answer-set programming (ASP)
Programming paradigm
Term coined by Lifschitz (1999)
Proposed by others people (Marek and Truszczyński, Niemelä)
at about the same time
Fruitful approach for declarative problem solving
Problem
?
Solution
Jörg Pührer Answer-Set Programming 2 / 71
6. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Declarative vs. Procedural Programming
In procedural programming, a problem is solved by writing a
program that corresponds to a recipe.
General Questions:
What steps do I need to take to solve the problem?
How do I solve it?
Jörg Pührer Answer-Set Programming 3 / 71
7. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Declarative vs. Procedural Programming
In procedural programming, a problem is solved by writing a
program that corresponds to a recipe.
General Questions:
What steps do I need to take to solve the problem?
How do I solve it?
Problem
Step 1
Program Recipe ...
Step n
Solution
Jörg Pührer Answer-Set Programming 3 / 71
8. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Declarative vs. Procedural Programming (ctd.)
In declarative programming, a problem is solved by writing a
program that corresponds to a description of the problem.
General Question:
What is the problem?
Jörg Pührer Answer-Set Programming 4 / 71
9. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Declarative vs. Procedural Programming (ctd.)
In declarative programming, a problem is solved by writing a
program that corresponds to a description of the problem.
General Question:
What is the problem?
Problem
Property 1
Program Description ...
Property n
Solution
Control flow is not provided in the program.
No algorithm is given for solving the problem.
Jörg Pührer Answer-Set Programming 4 / 71
10. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
ASP Big Picture
In Answer Set Programming (ASP), the problem is encoded in
terms of a logic theory - typically using logic programming rules.
Answer-Set Solver computes dedicated models of the theory.
They are called answer sets.
Jörg Pührer Answer-Set Programming 5 / 71
11. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
ASP Big Picture
In Answer Set Programming (ASP), the problem is encoded in
terms of a logic theory - typically using logic programming rules.
Answer-Set Solver computes dedicated models of the theory.
They are called answer sets.
Correspond one-to-one to the (multiple) solutions of the
problem.
Problem
H1 ← B 1
Answer-Set Program ...
Hn ← B n
Solver
Answer Set 1 ... Answer Set m
Solution 1 ... Solution m
Jörg Pührer Answer-Set Programming 5 / 71
12. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Answer Sets
Multiple Answer Sets:
Non-monotonic reasoning (use of default negation)
Ability to express non-determinism (guessing)
Sometimes useful: Preference relations between answer sets
Most used semantics:
Stable model semantics ( Answer-Set semantics)
Different modes of reasoning:
Model generation: compute 1, n, or all answer sets
Cautious reasoning: query holds in all answer sets
Brave reasoning: there is an answer set for which query holds
Jörg Pührer Answer-Set Programming 6 / 71
13. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Syntax
We deal with disjunctive logic programs (DLPs) under the
answer-set semantics, which are sets of rules of form:
a1 ∨ · · · ∨ al ← al+1 , . . . , am , not am+1 , . . . , not an
it must hold that n ≥ 1
all ai are literals over some fixed function-free first-order
language L
“not” denotes default negation (negation as failure)
a (strong) literal is either an atom or an atom preceded by
strong negation, −.
Jörg Pührer Answer-Set Programming 7 / 71
14. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Syntax (ctd.)
We deal with rules of form:
a1 ∨ · · · ∨ al ← al+1 , . . . , am , not am+1 , . . . , not an
We distinguish the following parts of rule r of the form above:
the head H(r ) = {a1 , · · · , al },
the body B(r ) = {al +1 , . . . , am , not am+1 , . . . , not an },
the positive body B+ (r ) = {al +1 , . . . , am }, and
the negative body B− (r ) = {am+1 , . . . , an }.
A rule r is
a fact if B(r ) = 0,
/
a constraint if H(r ) = 0,
/
normal if |H(r )| ≤ 1,
positive if B− (r ) = 0, or
/
Horn if it is both, normal and positive.
Jörg Pührer Answer-Set Programming 8 / 71
15. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Semantics
The answer-set semantics for disjunctive logic programs was
proposed by Gelfond and Lifschitz (1991).
Definition based on ground programs:
Rules do not contain variables
Semantics for a program P with variables based on the
program’s grounding gr (P):
Replace each non-ground rule r by all ground rules that can be
obtained from r by substituting variables by constants in the
Herbrand Universe of the program.
Jörg Pührer Answer-Set Programming 9 / 71
16. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Semantics (ctd.)
An interpretation is a consistent set I of ground literals
a is true iff a ∈ I.
Jörg Pührer Answer-Set Programming 10 / 71
17. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Semantics (ctd.)
An interpretation is a consistent set I of ground literals
a is true iff a ∈ I.
For a ground rule r ,
I |= B(r ) iff B+ (r ) ⊆ I and B− (r ) ∩ I = 0;
/
I |= H(r ) iff H(r ) ∩ I = 0;
/
I |= r iff (I |= B(r ) implies I |= H(r ))
I is a model of a ground program P iff I |= r for all r ∈ P.
Jörg Pührer Answer-Set Programming 10 / 71
18. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Semantics (ctd.)
The reduct of a ground program P w.r.t. I is the program
P I := {H(r ) ← B+ (r ) | r ∈ P and I ∩ B− (r ) = 0}
/
Jörg Pührer Answer-Set Programming 11 / 71
19. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Semantics (ctd.)
The reduct of a ground program P w.r.t. I is the program
P I := {H(r ) ← B+ (r ) | r ∈ P and I ∩ B− (r ) = 0}
/
I is an answer set of a program P if it is the minimal model of
gr (P)I
By AS(P), we denote the set of all answer sets of P.
Jörg Pührer Answer-Set Programming 11 / 71
20. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Semantics (ctd.)
Many alternative definitions
By means of propositional formulas (Lin and Zhao, 2004)
In terms of equilibrium logic and logic of here-and-there
(Pearce, 1996)
Using the FLP-reduct PFLP instead of P I (Faber, Leone, and
I
Pfeifer, 2004):
I is an answer set of a program P if it is a minimal model of
the rules r ∈ gr (Π) such that I |= B(r ).
Allows for intuitive handling of recursive aggregates.
...
Jörg Pührer Answer-Set Programming 12 / 71
21. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Small example
P ={ a(X ) ←not e(X ), d(X ),
e(X ) ←not a(X ), d(X ),
c(X , Y ) ←a(X ), a(Y ), not −b(X ),
d(1) ←,
d(2) ←}.
Jörg Pührer Answer-Set Programming 13 / 71
22. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Small example
P ={ a(X ) ←not e(X ), d(X ),
e(X ) ←not a(X ), d(X ),
c(X , Y ) ←a(X ), a(Y ), not −b(X ),
d(1) ←,
d(2) ←}.
The grounding of P is given by
gr (P) = { a(1) ←not e(1), d(1), a(2) ←not e(2), d(2),
e(1) ←not a(1), d(1), e(2) ←not a(2), d(2),
c(1, 1) ←a(1), a(1), not −b(1), c(2, 2) ←a(2), a(2), not −b(2),
c(1, 2) ←a(1), a(2), not −b(1), c(2, 1) ←a(2), a(1), not −b(2),
d(1) ←, d(2) ←}.
Jörg Pührer Answer-Set Programming 13 / 71
23. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Small example (ctd.)
P ={ a(X ) ←not e(X ), d(X ),
e(X ) ←not a(X ), d(X ),
c(X , Y ) ←a(X ), a(Y ), not −b(X ),
d(1) ←,
d(2) ←}.
Consider the interpretation I1 = {d(1), d(2)}
gr (P)I1 = { a(1) ←not e(1), d(1),
FLP a(2) ←not e(2), d(2),
e(1) ←not a(1), d(1), e(2) ←not a(2), d(2),
(
((( (
(((
((((( −b(1),
←
c(1, 1) a(1), a(1), not ←
((((( −b(2),
c(2, 2) a(2), a(2), not
(
((( (
(((
((((( −b(1),
←
c(1, 2) a(1), a(2), not ((((( −b(2),
←
c(2, 1) a(2), a(1), not
d(1) ←, d(2) ←}.
I1 is not a model of gr (P)I1 .
FLP
Jörg Pührer Answer-Set Programming 14 / 71
24. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Small example (ctd.)
P ={ a(X ) ←not e(X ), d(X ),
e(X ) ←not a(X ), d(X ),
c(X , Y ) ←a(X ), a(Y ), not −b(X ),
d(1) ←,
d(2) ←}.
Consider the interpretation I2 = {d(1), d(2), e(1), a(2), e(2), c(2, 2)}
gr (P)I2 = { not e(1), d(1),
( (
FLP a(1) ←((((( ←((((
a(2) not e(2), d(2),
(
(
e(1) ←not a(1), d(1), e(2) ←(((((
not a(2), d(2),
(
(((
←((((( −b(1),
c(1, 1) a(1), a(1), not c(2, 2) ←a(2), a(2), not −b(2),
(
((( (
(((
←((((( −b(1),
c(1, 2) a(1), a(2), not ←
((((( −b(2),
c(2, 1) a(2), a(1), not
d(1) ←, d(2) ←}.
I2 is a model of gr (P)I2
FLP .
Jörg Pührer Answer-Set Programming 15 / 71
25. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Small example (ctd.)
P ={ a(X ) ←not e(X ), d(X ),
e(X ) ←not a(X ), d(X ),
c(X , Y ) ←a(X ), a(Y ), not −b(X ),
d(1) ←,
d(2) ←}.
Consider the interpretation I2 = {d(1), d(2), e(1), a(2), e(2), c(2, 2)}
gr (P)I2 = { not e(1), d(1),
( (
FLP a(1) ←((((( ←((((
a(2) not e(2), d(2),
(
(
e(1) ←not a(1), d(1), e(2) ←(((((
not a(2), d(2),
(
(((
←((((( −b(1),
c(1, 1) a(1), a(1), not c(2, 2) ←a(2), a(2), not −b(2),
(
((( (
(((
←((((( −b(1),
c(1, 2) a(1), a(2), not ←
((((( −b(2),
c(2, 1) a(2), a(1), not
d(1) ←, d(2) ←}.
I2 is a model of gr (P)I2 but not minimal.
FLP
Jörg Pührer Answer-Set Programming 15 / 71
26. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Small example (ctd.)
P ={ a(X ) ←not e(X ), d(X ),
e(X ) ←not a(X ), d(X ),
c(X , Y ) ←a(X ), a(Y ), not −b(X ),
d(1) ←,
d(2) ←}.
Consider the interpretation I3 = {d(1), d(2), e(1), a(2), c(2, 2)}
gr (P)I3 = { not e(1), d(1),
(
FLP a(1) ←((((( a(2) ←not e(2), d(2),
(
e(1) ←not a(1), d(1), e(2) ←(((((
not a(2), d(2),
(
(((
←((((( −b(1),
c(1, 1) a(1), a(1), not c(2, 2) ←a(2), a(2), not −b(2),
(
((( (
(((
((((( −b(1),
←
c(1, 2) a(1), a(2), not ((((( −b(2),
←
c(2, 1) a(2), a(1), not
d(1) ←, d(2) ←}.
Jörg Pührer Answer-Set Programming 16 / 71
27. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Small example (ctd.)
P ={ a(X ) ←not e(X ), d(X ),
e(X ) ←not a(X ), d(X ),
c(X , Y ) ←a(X ), a(Y ), not −b(X ),
d(1) ←,
d(2) ←}.
Consider the interpretation I3 = {d(1), d(2), e(1), a(2), c(2, 2)}
gr (P)I3 = { not e(1), d(1),
(
FLP a(1) ←((((( a(2) ←not e(2), d(2),
(
e(1) ←not a(1), d(1), e(2) ←(((((
not a(2), d(2),
(
(((
←((((( −b(1),
c(1, 1) a(1), a(1), not c(2, 2) ←a(2), a(2), not −b(2),
(
((( (
(((
((((( −b(1),
←
c(1, 2) a(1), a(2), not ((((( −b(2),
←
c(2, 1) a(2), a(1), not
d(1) ←, d(2) ←}.
I3 is a minimal model of gr (P)I3 , hence I3 is an answer set of P.
FLP
Jörg Pührer Answer-Set Programming 16 / 71
28. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Small example (ctd.)
P ={ a(X ) ←not e(X ), d(X ),
e(X ) ←not a(X ), d(X ),
c(X , Y ) ←a(X ), a(Y ), not −b(X ),
d(1) ←,
d(2) ←}.
P has the following answer sets:
{d(1), d(2), a(1), a(2), c(1, 1), c(1, 2), c(2, 1), c(2, 2)},
{d(1), d(2), a(1), e(2), c(1, 1)},
{d(1), d(2), e(1), a(2), c(2, 2)},
{d(1), d(2), e(1), e(2)}
Jörg Pührer Answer-Set Programming 17 / 71
29. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Uniform Problem Encoding
Typically, answer-set programs are uniform problem encodings.
The program itself encodes the general problem,
whereas individual problem instances represented by facts can
be joined with the program on demand.
Problem Instance General Problem
F1 ← H1 ← B 1
... Set of Facts ∪ Answer-Set Program ...
Fl ← Hn ← B n
Solver
Answer Set 1 ... Answer Set m
Solution 1 ... Solution m
Jörg Pührer Answer-Set Programming 18 / 71
30. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Graph Colouring
Uniform problem encoding:
P1 = {another _col(V , C ) ←vertex (V ), col(C ), col(D),
col_of (V , D), C = D,
col_of (V , C ) ←vertex (V ), col(C ),
not another _col(V , C ),
←vertex (U), vertex (V ), edge(U, V ),
col_of (U, C ), col_of (V , C )}.
Input instance as set of facts:
F1 = {col(red), col(green), col(blue),
vertex (a), vertex (b), vertex (c), vertex (d), vertex (e),
edge(a, b), edge(a, c), edge(a, d),
edge(b, e), edge(c, d), edge(d, e)}.
Jörg Pührer Answer-Set Programming 19 / 71
31. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Graph Colouring (ctd.)
The answer sets of P1 ∪ F1 correspond to the solutions of the
problem instance.
{col_of (a, red), col_of (b, blue), col_of (c, blue), col_of (d, green), col_of (e, red), . . . }
Jörg Pührer Answer-Set Programming 20 / 71
32. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
Use
Complexity captured by uniform problem encodings:
normal logic programs: NP-hard problems
disjunctive logic programs: ΣP -hard problems
2
Applications of ASP
configuration, computer-aided verification, software testing,
health care, bio informatics, planning, music composition,
database repair, Semantic-Web reasoning, . . . .
Strengths:
Concise representation, elaboration tolerance,
non-determinism, use of recursion
Efficient solvers:
Clasp (University of Potsdam)
DLV (University of Calabria, Vienna University of Technology)
Jörg Pührer Answer-Set Programming 21 / 71
33. ASP Paradigm
Rules and Ontologies Syntax and Semantics
Debugging in ASP Applications
ASP Language Extensions
Many extensions have been proposed, partly motivated by
applications
Some are syntactic sugar, other strictly add expressiveness
Incomplete list:
optimisation: minimize/maximize statements, weak constraints
aggregates, cardinality constraints
templates (for macros)
function symbols (undecidability)
Frame Logic syntax
KR frontends (diagnosis, planning,...) in DLV
higher-order features (variables as predicates)
external atoms
Jörg Pührer Answer-Set Programming 22 / 71
34. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
ONTORULE ONTOR UL E
Project ONTORULE Ontologies meet Business Rules
Main Objectives:
Acquisition of ontologies and rules from the most appropriate
sources, including natural language documents
their separate management and maintenance
their transparent operationalisation in IT applications.
Consortium:
IBM France (Coordinator), Ontoprise, PNA, Fundación CTIC,
Audi, ArcelorMittal,
Free University of Bolzano, Vienna University of Technology,
Université Paris 13
Partially funded by the European Union’s 7th Framework
Programme (ICT-231875).
Jörg Pührer Answer-Set Programming 23 / 71
35. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
ONTORULE (ctd.) ONTOR UL E
Ontologies meet Business Rules
Project ONTORULE
Business Documents
Acquisition (e.g., NLP)
Business Vocabulary
Business Rules
Production Rules
OWL Ontology Rules
Logical Rules
Jörg Pührer Answer-Set Programming 24 / 71
36. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
ONTOR UL E
ONTORULE (ctd.)
Tasks led by TUWIEN: Ontologies meet Business Rules
in WP2 - Business Rules and Ontologies Ownership and
Management:
Consistency maintenance.
techniques to detect when the creation or modification of
rules and/or the ontology affects the overall consistency
focus on detecting inconsistencies across the rule/ontology
boundary
techniques for repairing detected inconsistencies
testing and debugging across the rule/ontology boundary
in WP3 - Execution and Inference:
Theoretical foundations for combining Logic Programs and
Ontologies
Complexity, expressiveness, and optimization of combinations
of LP and Ontologies
Jörg Pührer Answer-Set Programming 25 / 71
37. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
Formalisms combining Ontologies and Rules
Hybrid formalisms - Ontologies / Logical rules.
loosely coupled approaches
DL-programs
F-Logic#
tightly coupled approaches
SWRL and restrictions (DLP, Carin, DL-safe rules, Desription
Logic Rules)
R-hybrid KBs
F-hybrid KBs
Embedding approaches
hybrid MKNF KBs
Quantified Equilibrium Logic (QEL)
Jörg Pührer Answer-Set Programming 26 / 71
38. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
Ontologies and Rules in the Semantic Web
Why a “Semantic” Web?
Undoubtedly, the World Wide Web is one of the most significant
technical innovations of the last decades,
The WWW will be (and already is) strongly impacting, and
changing, our living, culture, and society.
Jörg Pührer Answer-Set Programming 27 / 71
39. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
Ontologies and Rules in the Semantic Web
Why a “Semantic” Web?
Undoubtedly, the World Wide Web is one of the most significant
technical innovations of the last decades,
The WWW will be (and already is) strongly impacting, and
changing, our living, culture, and society.
The WWW has been designed for human users, not for machines
Jörg Pührer Answer-Set Programming 27 / 71
40. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
Ontologies and Rules in the Semantic Web
Why a “Semantic” Web?
Undoubtedly, the World Wide Web is one of the most significant
technical innovations of the last decades,
The WWW will be (and already is) strongly impacting, and
changing, our living, culture, and society.
The WWW has been designed for human users, not for machines
To process the data and information out on the Web, semantic
annotation and description is needed.
Jörg Pührer Answer-Set Programming 27 / 71
41. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
Ontologies and Rules in the Semantic Web
Why a “Semantic” Web?
Undoubtedly, the World Wide Web is one of the most significant
technical innovations of the last decades,
The WWW will be (and already is) strongly impacting, and
changing, our living, culture, and society.
The WWW has been designed for human users, not for machines
To process the data and information out on the Web, semantic
annotation and description is needed.
The Semantic Web is the vision of such an enriched, future
generation Web
Logic and logic-based formalisms (should/might) play an important
role in this endeavor.
Jörg Pührer Answer-Set Programming 27 / 71
42. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
Building the Semantic Web (T. Berners-Lee, 04/2005)
RDF is the data model of the Semantic Web
RDF Schema semantically extends RDF by simple taxonomies and
hierarchies
OWL is a W3C standard, which builds on Description Logics
Rule languages: Rule Interchange Format (RIF) WG of W3C
Jörg Pührer Answer-Set Programming 28 / 71
43. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
ASP vs. Ontologies
ASP and OWL/DLs have related yet different underlying
settings
At the heart, the difference is between LP and Classical logic
Main Differences:
Closed vs. Open World Assumption (CWA/OWA)
Negation as failure vs. classical negation
Strong negation vs. classical negation
Unique names, equality
Jörg Pührer Answer-Set Programming 29 / 71
44. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
LP / Classical Logic: CWA vs. OWA
LP aims at building a single model, by closing the world
Reiter’s CWA:
If T |= A, then conclude ¬A, for ground atom A
FO logic / description logics keep the world open
In the Semantic Web, this is often reasonable
However, taking the agnostic stance of OWA may be not helpful for
drawing rational conclusions under incomplete information
Jörg Pührer Answer-Set Programming 30 / 71
45. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
LP / Classical Logic: NAF vs. Classical Negation
P: wine(X ) ← whiteWine(X ).
nonWhite(X ) ← not whiteWine(X ).
wine(myDrink).
T: ∀X . (whiteWine(X ) ⊃ wine(X )) ∧
∀X . (¬whiteWine(X ) ⊃ nonWhite(X )) ∧
wine(myDrink).
Jörg Pührer Answer-Set Programming 31 / 71
46. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
LP / Classical Logic: NAF vs. Classical Negation
P: wine(X ) ← whiteWine(X ).
nonWhite(X ) ← not whiteWine(X ).
wine(myDrink).
T: ∀X . (whiteWine(X ) ⊃ wine(X )) ∧
∀X . (¬whiteWine(X ) ⊃ nonWhite(X )) ∧
wine(myDrink).
Query nonWhite(myDrink)?
Jörg Pührer Answer-Set Programming 31 / 71
47. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
LP / Classical Logic: NAF vs. Classical Negation
P: wine(X ) ← whiteWine(X ).
nonWhite(X ) ← not whiteWine(X ).
wine(myDrink).
T: ∀X . (whiteWine(X ) ⊃ wine(X )) ∧
∀X . (¬whiteWine(X ) ⊃ nonWhite(X )) ∧
wine(myDrink).
Query nonWhite(myDrink)?
Conclude nonWhite(myDrink) from P.
Jörg Pührer Answer-Set Programming 31 / 71
48. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
LP / Classical Logic: NAF vs. Classical Negation
P: wine(X ) ← whiteWine(X ).
nonWhite(X ) ← not whiteWine(X ).
wine(myDrink).
T: ∀X . (whiteWine(X ) ⊃ wine(X )) ∧
∀X . (¬whiteWine(X ) ⊃ nonWhite(X )) ∧
wine(myDrink).
Query nonWhite(myDrink)?
Conclude nonWhite(myDrink) from P.
Do not conclude nonWhite(myDrink) from T .
Jörg Pührer Answer-Set Programming 31 / 71
49. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
LP / Classical Logic: Strong vs. Classical Negation
P: wine(X ) ← whiteWine(X ).
−wine(myDrink).
T: ∀X . (WhiteWine(X ) ⊃ Wine(X )) ∧
¬Wine(myDrink).
Jörg Pührer Answer-Set Programming 32 / 71
50. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
LP / Classical Logic: Strong vs. Classical Negation
P: wine(X ) ← whiteWine(X ).
−wine(myDrink).
T: ∀X . (WhiteWine(X ) ⊃ Wine(X )) ∧
¬Wine(myDrink).
Conclude ¬WhiteWine(myDrink) from T ;
Jörg Pührer Answer-Set Programming 32 / 71
51. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
LP / Classical Logic: Strong vs. Classical Negation
P: wine(X ) ← whiteWine(X ).
−wine(myDrink).
T: ∀X . (WhiteWine(X ) ⊃ Wine(X )) ∧
¬Wine(myDrink).
Conclude ¬WhiteWine(myDrink) from T ;
Do not conclude −whiteWine(myDrink) from P
Note: no contraposition in LP!
−whiteWine(X ) ← −wine(X ).
is not equivalent to
wine(X ) ← whiteWine(X ).
Jörg Pührer Answer-Set Programming 32 / 71
52. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
LP / Classical Logic: Unique Names, Equality
In LP, usally we have Unique Names Assumption (UNA):
Syntactically different ground terms are different objects.
Thus, usually only Herbrand interpretations are considered in LP
Ontology languages like OWL don’t make UNA, and allow to link
objects (owl:sameAs)
OWL considers also non-Herbrand interpretations
Further, related problems with existential quantifiers:
T: ∀X ∃Y . (Wine(X ) ⊃ hasColor (X , Y ))
(in DL Syntax, Wine ∃hasColor )
Simple skolemisation does not work in general
Jörg Pührer Answer-Set Programming 33 / 71
53. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
DL-programs
Recently, much effort has been put into the study of
combinations of rules and ontologies in the context of the
Semantic Web.
DL-programs have been proposed as a fruitful approach for
combining logic programs (LP) under the answer-set
semantics and description logic (DL) ontologies [Eiter et al.
2004,2008].
The interface beetween LP and DL is based on loose coupling.
Jörg Pührer Answer-Set Programming 34 / 71
54. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
Loose Coupling
The two components do not rely on a shared language or
common logical models.
Instead, they interact via dedicated atoms, called DL-atoms,
in the LP.
A DL-atom can be seen as a query to the ontology.
Bi-directional flow of information:
before the query is evaluated, predicates from the LP can be
temporarily imported to the DL.
this way, the DL-reasoner takes information into account that
has been derived by rules in the LP.
ASP Solver ? DL Engine
Jörg Pührer Answer-Set Programming 35 / 71
55. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
Syntax
A DL-atom a(t) has the form
DL[S1 op 1 p1 , . . . , Sm op m pm ; Q](t), where
m ≥ 0,
each Si is either a DL concept or a role predicate
op i ∈ { , ∪, ∩},
− −
pi is a unary, resp. binary, LP predicate symbol, and
Q(t) is a DL-query
We call γ = S1 op 1 p1 , . . . , Sm op m pm the input signature.
Intuitively,
op i = increases Si by the extension of pi ,
op i = ∪ increases ¬Si by the extension of pi , and
−
op i = ∩ constrains Si to pi .
−
Jörg Pührer Answer-Set Programming 36 / 71
56. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
Syntax (ctd.)
A DL-rule r is a normal rule of form:
a ← b1 , . . . , bk , not bk+1 , . . . , not bm , m ≥ k ≥ 0, where
a is a strong literal, and
b1 , . . . , bm are strong literals or DL-atoms.
“not” denotes default negation (negation as failure).
H(r ) = a, B+ (r ) = {b1 , . . . , bk }, B− (r ) = {bk +1 , . . . , bm },
B(r ) = {b1 , . . . , bk , not bk +1 , . . . , not bm }
A DL-program KB = (T , P) consists of a DL ontology T and
a finite set P of DL-rules.
The signatures of T and P have the same set F of (0-ary)
function symbols.
The grounding gr (P) of P is the set of all ground rules that
can be obtained by replacing variables of rules in P by
constants occurring in F .
Jörg Pührer Answer-Set Programming 37 / 71
57. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
Semantics
Let KB = (T , P) be a DL-program.
An interpretation for KB is a consistent set of strong literals
from gr (P).
A ground strong literal a is true under interpretation I
(I |=T a) iff a ∈ I.
Jörg Pührer Answer-Set Programming 38 / 71
58. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
Semantics (ctd.)
A ground DL-atom a = DL[S1 op 1 p1 , . . . , Sm op m pm ; Q](c) is
true under DL T (I |=T a) iff
T ∪ τI (a) |= Q(c), where
m
the extension of a under I is τI (a) = i =1 Ai (I) such that
Ai (I) = {Si (e) | pi (e) ∈ I}, for op i = ;
Ai (I) = {¬Si (e) | pi (e) ∈ I}, for op i = ∪;
−
Ai (I) = {¬Si (e) | pi (e) ∈ I}, for op i = ∩.
/ −
I |=T B+ (r ) iff I |=T a for all a ∈ B+ (r ).
I |=T B− (r ) iff I |=T a for all a ∈ B− (r ).
I |=T B(r ) iff I |=T B+ (r ) and I |=T B− (r ).
I |=T r iff I |=T H(r ) whenever I |=T B(r ).
I is a model of KB (I |= KB) iff I |=T r for all r ∈ gr (P).
Jörg Pührer Answer-Set Programming 39 / 71
59. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
Semantics (ctd.)
Answer sets defined analogously to answer-set programs using
the FLP-reduct
60. remember: introduced for an intuitive handling of
nonmonotone aggregates in ASP (Faber, Leone, Pfeifer 2004).
The FLP-reduct KB I FLP of DL-program KB = (T , P) relative
to I is the set of rules r ∈ gr (P) such that I |=T B(r ).
Definition
An interpretation I is an answer set of KB if it is a minimal model
of KB I .
FLP
The set of all answer sets of KB is denoted by AS(KB).
Originally, two different semantics have been defined (Eiter,
Lukasiewicz,Schindlauer, and Tompits 2004):
Strong Answer-Set semantics
Weak Answer-Set semantics
Jörg Pührer Answer-Set Programming 40 / 71
61. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
Example
A computer store obtains hardware from several vendors.
DL knowledge base Tex contains information about the
product range provided by each vendor.
For some parts, a shop may already be contracted as supplier.
Tex T-Box
≥ 1 provides shop; ∀provides.part;
Tex A-Box
provides(s1 , cpu); provides(s1 , case); provides(s2 , cpu);
provides(s3 , harddisk); provides(s3 , case);
supplies(s3 , case);
Jörg Pührer Answer-Set Programming 41 / 71
62. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
Example (ctd.)
DL-program KB ex = (Tex , Pex ) not-deterministically chooses a
vendor for each needed part.
LP part Pex :
needed(X ) ←DL[; part](X );
alreadyContracted(P) ←DL[; supplies](S, P), needed(P);
offer (S, P) ←DL[; provides](S, P), needed(P),
not alreadyContracted(P);
chosen(S, P) ←offer (S, P), not notChosen(S, P);
notChosen(S, P) ←offer (S, P), not chosen(S, P);
supplier (S, P) ←DL[supplies chosen; supplies](S, P), needed(P);
anySupplied(P) ←supplier (S, P);
←not needed(P), not anySupplied(P).
Jörg Pührer Answer-Set Programming 42 / 71
63. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
Example (ctd.)
KB ex has two answer sets, I1 and I2
both containing the same atoms of predicates needed, offer ,
alreadyContracted, and anySupplied:
I = {needed(cpu), needed(harddisk), needed(case), alreadyContracted(case),
offer (s1 , cpu), offer (s2 , cpu), offer (s3 , harddisk),
anySupplied(cpu), anySupplied(harddisk), anySupplied(case)}
The remaining atoms of I1 are given by
I1 I = {chosen(s1 , cpu), chosen(s3 , harddisk), notChosen(s2 , cpu),
supplier (s1 , cpu), supplier (s3 , harddisk), supplier (s3 , case)}
The remaining atoms of I2 are given by
I2 I = {chosen(s2 , cpu), chosen(s3 , harddisk), notChosen(s1 , cpu),
supplier (s2 , cpu), supplier (s3 , harddisk), supplier (s3 , case)}
Jörg Pührer Answer-Set Programming 43 / 71
64. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
Complexity of DL-programs
Theorem
Given and a dl-program KB = (T , P) with P in SHIF (D), deciding
whether KB has an answer set is complete for NEXP in the
general case, and complete for EXP when KB is positive or
stratified.
Jörg Pührer Answer-Set Programming 44 / 71
65. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
Tractable DL-programs
Tractable Reasoning with DL-programs (Heymans, Eiter, and
Xiao 2010)
Datalog-rewritable Description Logics
DL-program is translated to a “pure” logic program
Approximation of answer-set semantics: well-founded
semantics
new DL defined: LDL+
OWL2 fragments:
OWL 2 RL: fully datalog rewritable (strict subset of LDL+ )
OWL 2 EL: partly d. r. (neg. and existential qu. in axiom
r.h.s.)
OWL 2 QL: partly d. r. (neg. and existential qu. in axiom
r.h.s.)
Jörg Pührer Answer-Set Programming 45 / 71
66. ASP ONTORULE
Rules and Ontologies Ontologies and Rules
Debugging in ASP DL-Programs
HEX-programs
DL-programs where extended to HEX-programs (Eiter, Ianni,
Schindlauer, and Tompits 2005)
Nonmonotonic logic programs admitting higher-order atoms as
well as external atoms
Higher-order: Variables may appear in predicate position (does
not change expressibility)
External atoms extend DL-atoms: use of arbitrary sources
instead of queries to DL
Implemented in the DLVHEX system
SPARQL-queries can be translated to HEX-programs using
external atoms for RDF-import (Polleres 2007)
Jörg Pührer Answer-Set Programming 46 / 71
67. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Debugging in ASP
Problem: What if an answer-set program contains a bug?
Syntax is simple
Every syntactically correct program has well-defined semantics
68. Resulting answer sets differ from expected answer sets
Often the answer sets change drastically when a bug was
introduced.
Work on debugging in ASP has started recently:
Oetsch, Pührer, and Tompits (2010),
Pontelli and Son (2009),
Gebser et al. (2008),
Mikitiuk, Mosely, and Truszczyński (2007),
Brain et al. (2007),
Syrjänen (2006),
Brain and De Vos (2005)
Jörg Pührer Answer-Set Programming 47 / 71
69. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Debugging in ASP (ctd.)
Research has so far focused on declarative methods.
Two main motivations:
1. debugging systems should be independent of any particular
solving tool or solving method.
2. it is commonly argued that procedural-style debugging would
ruin the declarative nature of answer-set programs.
¯ destroys the view of a program as a description of a problem
¯ where no rule takes precedence
¯ and each of the rules is equally important as the others.
Jörg Pührer Answer-Set Programming 48 / 71
70. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Debugging in ASP (ctd.)
Research has so far focused on declarative methods.
Two main motivations:
1. debugging systems should be independent of any particular
solving tool or solving method.
2. it is commonly argued that procedural-style debugging would
ruin the declarative nature of answer-set programs.
¯ destroys the view of a program as a description of a problem
¯ where no rule takes precedence
¯ and each of the rules is equally important as the others.
Following a procedural debugging approach the program could
be seen as parameters for the solving algorithm.
Could compel the user to a programming style adjusted to the
algorithm rather than clarity of representation.
Jörg Pührer Answer-Set Programming 48 / 71
71. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Declarative Debugging in ASP
Most proposed approaches for debugging ASP follow the
scheme:
1. Take a declarative characterisation of the answer-set semantics.
2. Use it to explain an unexpected semantics of the given
program P.
Jörg Pührer Answer-Set Programming 49 / 71
72. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Declarative Debugging in ASP
Most proposed approaches for debugging ASP follow the
scheme:
1. Take a declarative characterisation of the answer-set semantics.
2. Use it to explain an unexpected semantics of the given
program P.
For example, answer sets can be characterised as
interpretations I such that
(i) all some rules in P are classically satisfied by I and
(ii) I contains no loop of P that is unfounded by P w.r.t. I.
Jörg Pührer Answer-Set Programming 49 / 71
73. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Declarative Debugging in ASP
Most proposed approaches for debugging ASP follow the
scheme:
1. Take a declarative characterisation of the answer-set semantics.
2. Use it to explain an unexpected semantics of the given
program P.
For example, answer sets can be characterised as
interpretations I such that
(i) all some rules in P are classically satisfied by I and
(ii) I contains no loop of P that is unfounded by P w.r.t. I.
For instance, a declarative debugging system could state:
I is not an answer set because rule r3 is not
classically satisfied by I!
Jörg Pührer Answer-Set Programming 49 / 71
74. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Declarative Debugging in ASP (ctd.)
Moreover, we could also receive answers like:
Jörg Pührer Answer-Set Programming 50 / 71
75. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Declarative Debugging in ASP (ctd.)
Moreover, we could also receive answers like:
I is not an answer set because rules r2 , r3 , r5 , r6 , r7 ,
r9 , r10 , r11 , r14 , r15 , r16 , r17 , r18 , r19 , r20 , r21 , r22 ,
r23 , r24 , r25 , r26 , r27 , r28 , r29 , r30 , r31 , r32 , r33 , r34 ,
r35 , r36 , r37 , r38 , r39 , r40 , r41 , r42 , r43 , r44 , r45 , r46 ,
r47 , r48 , r49 , r50 , r51 , r52 , r53 , r54 , r55 , r56 , r57 , r58 ,
r59 , r61 are not classically satisfied by I!
Jörg Pührer Answer-Set Programming 50 / 71
76. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Declarative Debugging in ASP (ctd.)
Moreover, we could also receive answers like:
I is not an answer set because rules r2 , r3 , r5 , r6 , r7 ,
r9 , r10 , r11 , r14 , r15 , r16 , r17 , r18 , r19 , r20 , r21 , r22 ,
r23 , r24 , r25 , r26 , r27 , r28 , r29 , r30 , r31 , r32 , r33 , r34 ,
r35 , r36 , r37 , r38 , r39 , r40 , r41 , r42 , r43 , r44 , r45 , r46 ,
r47 , r48 , r49 , r50 , r51 , r52 , r53 , r54 , r55 , r56 , r57 , r58 ,
r59 , r61 are not classically satisfied by I!
Problem:
¯ whole program is typically considered at once
¯ hard to identify the most useful information about a bug
Jörg Pührer Answer-Set Programming 50 / 71
77. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Declarative Debugging in ASP (ctd.)
Moreover, we could also receive answers like:
I is not an answer set because rules r2 , r3 , r5 , r6 , r7 ,
r9 , r10 , r11 , r14 , r15 , r16 , r17 , r18 , r19 , r20 , r21 , r22 ,
r23 , r24 , r25 , r26 , r27 , r28 , r29 , r30 , r31 , r32 , r33 , r34 ,
r35 , r36 , r37 , r38 , r39 , r40 , r41 , r42 , r43 , r44 , r45 , r46 ,
r47 , r48 , r49 , r50 , r51 , r52 , r53 , r54 , r55 , r56 , r57 , r58 ,
r59 , r61 are not classically satisfied by I!
Problem:
¯ whole program is typically considered at once
¯ hard to identify the most useful information about a bug
78. We need means to focus debugging information
Jörg Pührer Answer-Set Programming 50 / 71
79. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
The User’s Intuition
How would a user “manually” verify whether an interpretation
is an answer set?
Jörg Pührer Answer-Set Programming 51 / 71
80. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
The User’s Intuition
How would a user “manually” verify whether an interpretation
is an answer set?
Probably, by inspecting how the program’s rules step-by-step
built up the interpretation.
Jörg Pührer Answer-Set Programming 51 / 71
81. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
The User’s Intuition
How would a user “manually” verify whether an interpretation
is an answer set?
Probably, by inspecting how the program’s rules step-by-step
built up the interpretation.
Most likely, following an intuitive order according to the
semantics of the rules.
Jörg Pührer Answer-Set Programming 51 / 71
82. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
The User’s Intuition
How would a user “manually” verify whether an interpretation
is an answer set?
Probably, by inspecting how the program’s rules step-by-step
built up the interpretation.
Most likely, following an intuitive order according to the
semantics of the rules.
83. But what about the declarative view?
Jörg Pührer Answer-Set Programming 51 / 71
84. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
The User’s Intuition
How would a user “manually” verify whether an interpretation
is an answer set?
Probably, by inspecting how the program’s rules step-by-step
built up the interpretation.
Most likely, following an intuitive order according to the
semantics of the rules.
85. But what about the declarative view?
No rule takes precedence?
Jörg Pührer Answer-Set Programming 51 / 71
86. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
The User’s Intuition
How would a user “manually” verify whether an interpretation
is an answer set?
Probably, by inspecting how the program’s rules step-by-step
built up the interpretation.
Most likely, following an intuitive order according to the
semantics of the rules.
87. But what about the declarative view?
No rule takes precedence?
Each of the rules is equally important as the others?
Jörg Pührer Answer-Set Programming 51 / 71
88. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
The User’s Intuition (ctd.)
There are “natural” orders in which to consider rules.
For example, orders imposed by
stratification,
Guess Check components,
importance of subprograms w.r.t. the problem domain, or
the order in which the program is written.
Jörg Pührer Answer-Set Programming 52 / 71
89. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
The User’s Intuition (ctd.)
There are “natural” orders in which to consider rules.
For example, orders imposed by
stratification,
Guess Check components,
importance of subprograms w.r.t. the problem domain, or
the order in which the program is written.
90. We want to make use of these orders for debugging.
Jörg Pührer Answer-Set Programming 52 / 71
91. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Idea
aim at a debugging approach that allows the user to
build an answer set he or she has in mind by
stepwise adding further applicable rules.
emulation of a bottom-up generation of answer sets
considered interpretation grows monotonically
user serves as an oracle, choosing rules considered to be
supporting
bugs can be found when computation deviates from
expectations
Needed: A computation model for ASP that
is simple and intuitive
does not require a fix order in which to consider the rules
concentrates on computation steps interesting to the user
Jörg Pührer Answer-Set Programming 53 / 71
92. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
States
Definition
Let S be a set of ground (normal) rules. Then, the interpretation
induced by S is given by IS = r ∈S H(r ).
Definition
A set S of ground rules is self-supporting if IS |= B(r ), for all r ∈ S,
and stable if IS ∈ AS(S). A state of a normal program P is a set
S ⊆ gr (P) of ground rules which is self-supporting and stable.
Intuitively,
S contains the already considered ground rules (source code
level) and
IS contains the already derived literals (output level).
States serve as breakpoints.
Jörg Pührer Answer-Set Programming 54 / 71
93. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Computations
Definition
For a state S of a program P and a set S ⊆ gr (P) of ground rules,
S is a successor of S in P, symbolically S P S , if S = S ∪ {r },
for some rule r ∈ gr (P) S with
(i) IS |= B(r ),
(ii) H(r ) = 0, and
/
(iii) H(r ) ∩ (B− (r ) ∪ −
r ∈S B (r )∪ a∈IS a) = 0.
¯ /
The successor relation suffices to “step” from one state to another,
i.e., S is always self-supporting and stable, and hence a state of P.
Definition
A computation for a program P is a finite sequence C = S0 , . . . , Sn
of states such that, for all 0 ≤ i n, Si P Si+1 .
Jörg Pührer Answer-Set Programming 55 / 71
94. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Computations (ctd.)
Definition
A computation C = S0 , . . . , Sn for P
has failed at Step i if there is no answer set I of P such that
every rule r in Si is active under I (i.e., I |= B(r ));
is stuck if there is no successor of Sn in P but there is a rule
r ∈ gr (P) Sn that is active under ISn ;
is complete if, for each rule r ∈ gr (P) that is active under ISn ,
we have r ∈ Sn .
Intuitive meanings
failure: computation reached a point where no answer set of
the program can be reached
stuck: last state activated rules deriving literals that are
inconsistent with previously chosen active rules
complete: there are no more unconsidered active rules
Jörg Pührer Answer-Set Programming 56 / 71
95. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Computations (ctd.)
The following result guarantees the soundness of our stepping
framework.
Theorem
Let P be a program and C = S0 , . . . , Sn a complete computation for
P. Then, ISn is an answer set of P.
The computation model is also complete in the sense that
stepping, starting from an arbitrary state S0 of P as breakpoint,
can reach every answer set I ⊇ IS0 of P, where every rule in S0 is
active under I.
Theorem
Let I ∈ AS(P) be an answer set of program P and S0 a state of P
such that IS0 ⊆ I and every rule in S0 is active under I. Then, there
is a complete computation C = S0 , . . . , Sn with
Sn = {r ∈ gr (P) | I |= B(r )} and ISn = I.
Jörg Pührer Answer-Set Programming 57 / 71
96. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Maze Example
The problem of Maze Generation:
Consider an n × m grid where each cell is either a wall or
empty and there are two dedicated empty cells located at the
border,the maze’s entrance and its exit.
The maze grid has to satisfy the following conditions:
(i) border cells are walls (exception: entrance and exit)
(ii) there is a path from the entrance to every empty cell
(iii) for two diagonally adjacent walls, one of their common
neighbours is a wall
(iv) no 2 × 2 blocks of empty cells or walls
(v) no wall can be completely surrounded by empty cells
Jörg Pührer Answer-Set Programming 58 / 71
97. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Maze Example (ctd.)
Input of the problem: facts that specify
the size of the maze,
positions of the entrance and the exit, and
for an arbitrary subset of cells whether they are walls or empty.
Example input:
F = {row (1), row (2), row (3), row (4), row (5), col(1), col(2), col(3),
col(4), col(5), entrance(1, 2), exit(5, 4), wall(3, 3), empty (3, 4)}
Output: completion of the input to a valid maze structure.
Jörg Pührer Answer-Set Programming 59 / 71
98. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Maze Example (ctd.)
First step: identify border cells.
Our initial program is P0 = F ∪ PBdr , where PBdr is given by
maxcol(X ) ← col(X ), not col(X + 1),
maxrow (Y ) ← row (Y ), not row (Y + 1),
border (1, Y ) ← col(1), row (Y ),
border (X , Y ) ← row (Y ), maxcol(X ),
border (X , 1) ← col(X ), row (1),
border (X , Y ) ← col(X ), maxrow (Y ).
A set of facts is always a state.
Consider F as breakpoint.
We start stepping from F by choosing, e.g., the ground rule
r = maxcol(5) ← col(5), not col(6),
that is active under F , as next rule to add.
We obtain the computation C = F , F ∪ {r }.
Jörg Pührer Answer-Set Programming 60 / 71
99. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Maze Example (ctd.)
It is not feasible to step through all rules in the (exponential)
grounding of a program.
101. We need means to obtain such interesting states.
Jörg Pührer Answer-Set Programming 61 / 71
102. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Maze Example (ctd.)
It is not feasible to step through all rules in the (exponential)
grounding of a program.
104. We need means to obtain such interesting states.
Proposition
For programs P and P ⊆ P ∪ gr (P) such that I ∈ AS(P ), the set
of rules in gr (P ) that are active under I is a state of P.
Jörg Pührer Answer-Set Programming 61 / 71
105. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Maze Example (ctd.)
maxcol(X ) ← col(X ), not col(X + 1),
maxrow (Y ) ← row (Y ), not row (Y + 1),
border (1, Y ) ← col(1), row (Y ),
border (X , Y ) ← row (Y ), maxcol(X ),
border (X , 1) ← col(X ), row (1),
border (X , Y ) ← col(X ), maxrow (Y ).
We want to step through rules deriving the border /2 atoms.
Calculate an answer set of P0 ⊆ P0 that is given by
P0 = F ∪ {maxcol(X ) ← col(X ), not col(X + 1),
maxrow (Y ) ← row (Y ), not row (Y + 1)}.
Answer set given by I0 = F ∪ {maxcol(5), maxrow (5)}
The desired breakpoint S0 : the rules in gr (P0 ) active under I0 :
P0 = F ∪ {maxcol(5) ← col(5), not col(6),
maxrow (5) ← row (5), not row (6)
Jörg Pührer Answer-Set Programming 62 / 71
106. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Maze Example (ctd.)
During stepping one might want to jump several steps forward.
We extend the maze program P0 to P1 by adding the rule
rbw = wall(X , Y ) ← border (X , Y ), not entrance(X , Y ), not exit(X , Y )
Stepping from S1 that already contains all border atoms:
Jörg Pührer Answer-Set Programming 63 / 71
107. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Maze Example (ctd.)
During stepping one might want to jump several steps forward.
We extend the maze program P0 to P1 by adding the rule
rbw = wall(X , Y ) ← border (X , Y ), not entrance(X , Y ), not exit(X , Y )
Stepping from S1 that already contains all border atoms:
S2 = S1 ∪ {wall(1, 1) ← border (1, 1), not entrance(1, 1), not exit(1, 1)}
Jörg Pührer Answer-Set Programming 63 / 71
108. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Maze Example (ctd.)
During stepping one might want to jump several steps forward.
We extend the maze program P0 to P1 by adding the rule
rbw = wall(X , Y ) ← border (X , Y ), not entrance(X , Y ), not exit(X , Y )
Stepping from S1 that already contains all border atoms:
S2 = S1 ∪ {wall(1, 1) ← border (1, 1), not entrance(1, 1), not exit(1, 1)}
S3 = S2 ∪ {wall(1, 2) ← border (1, 2), not entrance(1, 2), not exit(1, 2)}
Jörg Pührer Answer-Set Programming 63 / 71
109. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Maze Example (ctd.)
During stepping one might want to jump several steps forward.
We extend the maze program P0 to P1 by adding the rule
rbw = wall(X , Y ) ← border (X , Y ), not entrance(X , Y ), not exit(X , Y )
Stepping from S1 that already contains all border atoms:
S2 = S1 ∪ {wall(1, 1) ← border (1, 1), not entrance(1, 1), not exit(1, 1)}
S3 = S2 ∪ {wall(1, 2) ← border (1, 2), not entrance(1, 2), not exit(1, 2)}
We want to continue from a state where rbw is fully considered.
Jörg Pührer Answer-Set Programming 63 / 71
110. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Maze Example (ctd.)
During stepping one might want to jump several steps forward.
We extend the maze program P0 to P1 by adding the rule
rbw = wall(X , Y ) ← border (X , Y ), not entrance(X , Y ), not exit(X , Y )
Stepping from S1 that already contains all border atoms:
S2 = S1 ∪ {wall(1, 1) ← border (1, 1), not entrance(1, 1), not exit(1, 1)}
S3 = S2 ∪ {wall(1, 2) ← border (1, 2), not entrance(1, 2), not exit(1, 2)}
We want to continue from a state where rbw is fully considered.
111. Compute an answer set I of program P1 given by
S3 ∪ {rbw }∪{← not l | l ∈ B+ (r ), r ∈ S3 } ∪ {← l | l ∈ B− (r ), r ∈ S3 }
Jörg Pührer Answer-Set Programming 63 / 71
112. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Maze Example (ctd.)
During stepping one might want to jump several steps forward.
We extend the maze program P0 to P1 by adding the rule
rbw = wall(X , Y ) ← border (X , Y ), not entrance(X , Y ), not exit(X , Y )
Stepping from S1 that already contains all border atoms:
S2 = S1 ∪ {wall(1, 1) ← border (1, 1), not entrance(1, 1), not exit(1, 1)}
S3 = S2 ∪ {wall(1, 2) ← border (1, 2), not entrance(1, 2), not exit(1, 2)}
We want to continue from a state where rbw is fully considered.
113. Compute an answer set I of program P1 given by
S3 ∪ {rbw }∪{← not l | l ∈ B+ (r ), r ∈ S3 } ∪ {← l | l ∈ B− (r ), r ∈ S3 }
The new state is given by the rules of gr (P0 ) active under I.
Jörg Pührer Answer-Set Programming 63 / 71
114. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Recap Debugging
Approach allows to follow intuitions on which rules to apply.
It is based on an intuitive and simple computation model.
Stepping can be useful in different scenarios
Stepping to an answer set
getting insights into the interplay of rules of a program
searching for a particular answer set
Unexpected results
Unintended answer sets
Absence of answer sets
Understanding someone else’s code
Challenge: Building an appropriate GUI for stepping approach
To be implemented in SeaLion, our IDE for ASP.
Jörg Pührer Answer-Set Programming 64 / 71
115. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Conclusion
Answer-set programming is a formalism for declarative
problem solving
Solvers become more and more efficient and expressive.
Combinations of logical rules and ontologies: e.g.,
DL-programs
An approach for debugging ASP programs has been
presented.
Future work:
Debugging of DL-programs and HEX-programs.
Jörg Pührer Answer-Set Programming 65 / 71
116. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
Bibliography
J. de Bruijn, D. Pearce, A. Polleres, and A. Valverde.
Quantified equilibrium logic and hybrid rules.
In M. Marchiori et al., editors, Proc. RR 2007, volume 4524 of LNCS, pp. 58–72. Springer, 2007.
F. M. Donini, D. Nardi, and R. Rosati.
Description logics of minimal knowledge and negation as failure.
ACM Trans. Comput. Log., 3(2):177–225, 2002.
W. Drabent and J. Maluszynski.
Well-founded semantics for hybrid rules.
In M. Marchiori et al., editors, Proc. RR 2007, volume 4524 of LNCS, pp. 1–15.
W. Faber, G. Pfeifer, N. Leone.
Semantics and complexity of recursive aggregates in answer set programming.
Artif. Intell., 175(1):278–298, 2011.
F. Lin, Y. Zhao.
ASSAT: computing answer sets of a logic program by SAT solvers.
Artif. Intell., 157(1-2):115–137, 2004.
T. Eiter, G. Ianni, A. Polleres, R. Schindlauer, and H. Tompits.
Reasoning with rules and ontologies.
In P. Barahona, et al., editors, Reasoning Web, Second International Summer School 2006, number 4126 in
LNCS, pp. 93–127. Springer, 2006.
T. Eiter, G. Ianni, R. Schindlauer, and H. Tompits.
dlvhex: A prover for semantic-web reasoning under the answer-set semantics.
In IEEE/WIC/ACM Int’l Conf. on Web Intelligence (WI 2006), pp. 1073–74. IEEE Computer Society, 2006.
More extend version at ALPSWS 2006.
T. Eiter, G. Ianni, R. Schindlauer, and H. Tompits.
A uniform integration of higher-order reasoning and external evaluations in answer-set programming.
In Proceedings IJCAI-2005, pp. 90–96. Professional Book Center, 2005.
Jörg Pührer Answer-Set Programming 66 / 71
117. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
T. Eiter, T. Lukasiewicz, R. Schindlauer, and H. Tompits.
Combining Answer Set Programming with Description Logics for the Semantic Web.
In D. Dubois, et al., editors, Proc. Ninth International Conf. on Principles of Knowledge Representation and
Reasoning (KR 2004), pp. 141–151. Morgan Kaufmann, 2004. Extended paper Tech. Rep. INFSYS
RR-1843-07-04, Inst. Inf.Sys., TU Vienna, January 2007.
T. Eiter, T. Lukasiewicz, R. Schindlauer, and H. Tompits.
Well-founded semantics for description logic programs in the Semantic Web.
In Proceedings RuleML-2004, volume 3323 of LNCS, pp. 81–97. Springer, 2004.
M. Gelfond and V. Lifschitz.
Classical negation in logic programs and disjunctive databases.
New Generation Computing, 9:365–385, 1991.
B. N. Grosof, I. Horrocks, R. Volz, and S. Decker.
Description logic programs: Combining logic programs with description logics.
In Proc. WWW-2003, pp. 48–57. ACM Press, 2003.
S. Heymans, L. Predoiu, C. Feier, J. de Bruijn, and D. van Nieuwenborgh.
G-hybrid knowledge bases.
In Proc. Workshop on Applications of Logic Programming in the Semantic Web and Semantic Web Services
(ALPSWS 2006), at FLOC/ICLP 2006, pp. 39–54, 2006. Online http://CEUR-WS.org/Vol-196/.
S. Heymans, D. Van Nieuwenborgh, and D. Vermeir.
Open answer set programming for the semantic web.
Journal of Applied Logic, 5(1):144–169, 2007.
S. Heymans and D. Vermeir.
Integrating ontology languages and answer set programming.
In DEXA Workshops, pp. 584–588. IEEE Computer Society, 2003.
S. Heymans and D. Vermeir.
Integrating semantic web reasoning and answer set programming.
In Proc. ASP-2003, pp. 194–208, 2003.
Jörg Pührer Answer-Set Programming 67 / 71
118. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
U. Hustadt, B. Motik, and U. Sattler.
Reducing SHIQ-description logic to disjunctive datalog programs.
In Proceedings KR-2004, pp. 152–162. AAAI Press, 2004.
G. Ianni, A. Martello, C. Panetta, and G. Terracina.
Faithful and effective querying of RDF ontologies using DLVdb .
In Proceedings ASP-2007, pp. 115–131, 2007.
M. Knorr, J. J. Alferes, and P. Hitzler.
A well-founded semantics for hybrid MKNF knowledge bases.
In Proc. 2007 International Workshop on Description Logics (DL2007), Bressanone, 2007, CEUR Workshop
Proc., 2007.
A. Y. Levy and M.-C. Rousset.
Combining Horn rules and description logics in CARIN.
Artificial Intelligence, 104(1–2):165–209, 1998.
V. Lifschitz.
Answer Set Programming and Plan Generation.
Artificial Intelligence, 138:39–54, 2002.
Seminal paper at ICLP’99 (invited talk), coining the term “Answer Set Programming”.
T. Lukasiewicz.
Fuzzy description logic programs under the answer set semantics for the Semantic Web.
In Proc. RuleML-2006, pp. 89–96. IEEE Computer Society, 2006.
Full paper in Fundamenta Informaticae, to appear.
T. Lukasiewicz.
Probabilistic description logic programs.
Int. J. Approx. Reasoning, 45(2):288–307, 2007.
V. W. Marek and M. Truszczyński.
Stable Models and an Alternative Logic Programming Paradigm.
In K. Apt, V. W. Marek, M. Truszczyński, and D. S. Warren, editors, The Logic Programming Paradigm –
A 25-Year Perspective, pp. 375–398. Springer Verlag, 1999.
Jörg Pührer Answer-Set Programming 68 / 71
119. ASP Context
Rules and Ontologies Framework
Debugging in ASP Application
B. Motik, I. Horrocks, R. Rosati, and U. Sattler.
Can OWL and logic programming live together happily ever after?
In I. F. Cruz, et al., editors, Proc. 5th International Semantic Web Conference (ISWC 2006), volume 4273
of Lecture Notes in Computer Science, pp. 501–514. Springer, 2006.
B. Motik and R. Rosati.
A faithful integration of description logics with logic programming.
In M. Veloso, editor, Proc. 20th International Joint Conference on Artificial Intelligence (IJCAI 2007 ), pp.
477–482. AAAI Press/IJCAI, 2007. Extended Paper: Closing Semantic Web Ontologies. Tech. Report, Univ.
Manchester, UK, 2006.
B. Motik, U. Sattler, and R. Studer.
Query answering for OWL-DL with rules.
J. Web Sem., 3(1):41–60, 2005.
I. Niemelä.
Logic Programming with Stable Model Semantics as Constraint Programming Paradigm.
Annals of Mathematics and Artificial Intelligence, 25(3–4):241–273, 1999.
J. Oetsch, J. Pührer, H. Tompits.
Stepping through an Answer-Set Program.
To appear LPNMR 2011.
J. Oetsch, J. Pührer, H. Tompits.
Catching the Ouroborus: Debugging of non-ground Answer-Set Programs.
ICLP 2010.
D. Pearce.
A New Logical Characterisation of Stable Models and Answer Sets.
NMELP 1996.
Jörg Pührer Answer-Set Programming 69 / 71