A Glimpse of Answer Set Programming.
ABSTRACT sentation and reasoning. To solve a problem, a programmer designs a logic program so that models of the program determine solutions to the problem. ASP has been identi ed in the late 1990s as a subarea of logic programming and is becoming one of the fastest growing elds in knowledge representation and declarative programming. Major advantages of ASP are (1) its simplicity, (2) its ability to model e ectively incomplete speci cations and closure constraints, and (3) its relation to constraint satisfaction and propositional satis ability, which allows one to take advantage of advances in these areas when designing solvers for ASP systems.

Conference Paper: Rapid prototyping of OpenCV image processing applications using ASP.
[Show abstract] [Hide abstract]
ABSTRACT: Image processing is becoming more and more present in our everyday life. With the requirements of minia turization, lowpower, performance in order to provide some intelligent processing directly into the camera, embedded camera will dominate the image processing landscape in the future. While the common approach of developing such embedded systems is to use sequentially operating processors, image processing algorithms are inherently parallel, thus hardware devices like FP GAs provide a perfect match to develop highly efficient systems. Unfortunately hardware development is more difficult and there are less experts available compared to software. Automatizing the design process will leverage the existing infrastructure, thus providing faster time to market and quick investigation of new algorithms. We exploit ASP (answer set programming) for system synthesis with the goal of genarating an optimal hardware software partitioning, a viable communication structure and the corresponding scheduling, from an image processing application.Proceedings of the 22nd IEEE International Symposium on Rapid System Prototyping, RSP 2011, Karlsruhe, Germany, 2427 May, 2011; 01/2011  [Show abstract] [Hide abstract]
ABSTRACT: No Yes01/2008;  SourceAvailable from: Blai Bonet
Article: Heuristics for planning with penalties and rewards formulated in logic and computed through circuits
[Show abstract] [Hide abstract]
ABSTRACT: The automatic derivation of heuristic functions for guiding the search for plans is a fundamental technique in planning. The type of heuristics that have been considered so far, however, deal only with simple planning models where costs are associated with actions but not with states. In this work we address this limitation by formulating a more expressive planning model and a corresponding heuristic where preferences in the form of penalties and rewards are associated with fluents as well. The heuristic, that is a generalization of the wellknown deleterelaxation heuristic, is admissible, informative, but intractable. Exploiting a correspondence between heuristics and preferred models, and a property of formulas compiled in dDNNF, we show however that if a suitable relaxation of the domain, expressed as the strong completion of a logic program with no time indices or horizon is compiled into dDNNF, the heuristic can be computed for any search state in time that is linear in the size of the compiled representation. This representation defines an evaluation network or circuit that maps states into heuristic values in lineartime. While this circuit may have exponential size in the worst case, as for OBDDs, this is not necessarily so. We report empirical results, discuss the application of the framework in settings where there are no goals but just preferences, and illustrate the versatility of the account by developing a new heuristic that overcomes limitations of deletebased relaxations through the use of valid but implicit plan constraints. In particular, for the Traveling Salesman Problem, the new heuristic captures the exact cost while the deleterelaxation heuristic, which is also exponential in the worst case, captures only the Minimum Spanning Tree lower bound.Artificial Intelligence. 01/2008;
Page 1
A Glimpse of Answer Set Programming
Christian Anger and Kathrin Konczak and Thomas Linke and Torsten Schaub
Answer Set Programming (ASP) is a declarative paradigm for solving search problems appearing in knowledge repre
sentation and reasoning. To solve a problem, a programmer designs a logic program so that models of the program
determine solutions to the problem. ASP has been identified in the late 1990s as a subarea of logic programming and is
becoming one of the fastest growing fields in knowledge representation and declarative programming. Major advantages
of ASP are (1) its simplicity, (2) its ability to model effectively incomplete specifications and closure constraints, and
(3) its relation to constraint satisfaction and propositional satisfiability, which allows one to take advantage of advances
in these areas when designing solvers for ASP systems.
1Introduction
Answer Set Programming (ASP) emerged in the late 1990s
as a new logic programming paradigm [22, 34, 35, 28], ha
ving its roots in nonmonotonic reasoning, deductive databa
ses and logic programming with negation as failure. Since its
inception, it has been regarded as the computational embo
diment of nonmonotonic reasoning and a primary candidate
for an effective knowledge representation tool. This view has
been boosted by the emergence of highly efficient solvers
for ASP [50, 17]. It now seems hard to dispute that ASP
brought new life to logic programming and nonmonotonic
reasoning research and has become a major driving force for
these two fields, helping to dispel gloomy prophecies of their
impending demise.
The basic idea of ASP is to represent a given compu
tational problem by a logic program whose answer sets cor
respond to solutions, and then use an answer set solver for
finding answer sets of the program. This approach is close
ly related to the one pursued in propositional satisfiability
checking (SAT), where problems are encoded as propositio
nal theories whose models represent the solutions to the gi
ven problem. Even though syntactically, ASP programs look
like Prolog programs, they are treated by rather different
computational mechanisms. Indeed, the usage of model ge
neration instead of query evaluation can be seen as a recent
trend in the encompassing field of knowledge representation
and reasoning. ASP is particularly suited for solving difficult
combinatorial search problems. Among these, we find appli
cations to plan generation, product configuration, diagnosis,
and graphtheoretical problems.
2 Background
We restrict the formal development of ASP to propositional
(normal) logic programs consisting of rules of the form
p0 ← p1,...,pm,not pm+1,...,not pn ,
(1)
where n ≥ m ≥ 0, and each pi (0 ≤ i ≤ n) is an atom.
Given such a rule r, we let head(r) denote the head, p0, of r
and body(r) the body, {p1,...,pm, not pm+1,...,not pn},
of r. Also, let body+(r) = {p1,...,pm} and body−(r) =
{pm+1,...,pn}. The intuitive reading of such a rule is that
of a constraint on an answer set: If all atoms in body+(r)
are included in the set and no atom in body−(r) is in it, then
head(r) must be included in the answer set.
Answer sets as such are defined via a reduction to negation
asfailurefree programs: A logic program is called basic if
body−(r) = ∅ for all its rules. A set of atoms X is closed
under a basic program Π if for any r ∈ Π, head(r) ∈ X
whenever body+(r) ⊆ X. The smallest set of atoms which
is closed under a basic program Π is denoted by Cn(Π) and
constitutes the answer set of Π.
For the general case, we need the concept of a reduct of
a program Π relative to a set X of atoms:
ΠX= {head(r) ← body+(r)  r ∈ Π,body−(r) ∩ X = ∅}.
With these formalities at hand, we can define answer set
semantics for logic programs: A set X of atoms is an answer
set of a program Π if Cn(ΠX) = X. This definition is due
to [22], where the term stable model is used; the idea traces
back to [45]. In fact, one may regard an answer set as a
model of a program Π that is somehow “stable” under Π.
In other words, an answer set is closed under the rules of Π,
and it is “grounded in Π”, that is, each of its atoms has a
derivation using “applicable” rules from Π.
For illustration, consider the program
Π = {p ← p, q ← not p} .
Among the four candidate sets, we find a single answer set,
{q}, as can be verified by means of the following table:
X
ΠX
∅
q
←
{p}
{q}
q
←
{p,q}
Cn(ΠX)
{q}
p
←
p
p
p
←
←
p
p
∅
{q}
p
←
p
∅
Seite 1
Page 2
A noteworthy fact is that posing the query p or q to Π in a
Prolog system leads to nonterminating situation due to its
topdown approach.
Analogously, we may check that the program
Π1 = {p ← not q, q ← not p}
has the two answer sets {p} and {q}.
X
∅
ΠX
p
q
p
q
Cn(ΠX)
{p,q}←
←
←
←
{p}
{q}
{p,q}
{p}
{q}
∅
The two rules in Π1 are mutually exclusive and capture an
indefinite situation: p can be added unless q has been added
and vice versa. We show in the next section how this can be
exploited in modeling problems in ASP.
Unlike the previous examples,
Π2 = {p ← not p}
admits no answer set. Interestingly, Π2 offers a straightfor
ward way to model integrity constraints of form
← p1,...,pm,not pm+1,...,not pn .
(2)
This can be done by introducing a new atom f and replacing
(2) by rule f ← not f,p1,...,pm,not pm+1,...,not pn .
Whenever the integrity constraint in (2) is violated by a can
didate set this set is eliminated by the effect observed on
program Π2. The usefulness of integrity constraints can be
observed by adding ← p to program Π1. In fact, the integri
ty constraints ← p eliminates the original answer set {p} of
Π1, so that Π1∪ {← p} yields a single answer set {q}.
Although general ASP is principally computationally com
plete, that is, it can simulate arbitrary Turing machines [6],
one usually deals with decidable fragments. Commonly, we
consider rules with variables that are taken as abbreviations
for all ground instances over a finite set of constants. The
propositional fragment of ASP defined above allows for en
coding all decision and search problems within NP [48, 33].
3Modeling
The basic approach to writing programs in ASP follows a
“generateandtest” strategy. First, one writes a group of
rules whose answer sets would correspond to candidate solu
tions. Then, one adds a second group of rules, mainly consi
sting of integrity constraints, that eliminates candidates re
presenting invalid solutions.
As an example consider the wellknown nqueens pro
blem. The goal is to place n queens on an n×n chessboard
so that no two queens appear on the same row, column, or
diagonal. Let us represent the positioning of the queens by
atoms of the form q(i,j), where 1 ≤ i,j ≤ n. That is, an
atom q(i,j) represents that a queen is at position (i,j).
Let us first give a “generator”. To this end, we build
upon the nondeterministic behavior observed on program
Π1. Also, we introduce an auxiliary atom q?(i,j) indicating
that there is no queen at (i,j). Finally, we need a “domain
predicate” d indicating the dimension of the chessboard. Ac
cordingly, we obtain:
q(X,Y )
q?(X,Y )
←
←
d(X),d(Y ),not q?(X,Y )
(3)
d(X),d(Y ),not q(X,Y )
(4)
So, taking a 1×1 chessboard by adding d(1), we obtain from
(3) and (4) two answer sets, {q(1,1),d(1)} and {q?(1,1),d(1)},
just as with program Π1. Accordingly, we obtain by adding
d(1) and d(2) a 2×2 chessboard, generating 16 answer sets,
among which we find:
{q?(1,1),q?(1,2),q?(2,1),q?(2,2),d(1),d(2)}
(5)
{q(1,1),q?(1,2),q?(2,1),q?(2,2),d(1),d(2)}
q
(6)
{q(1,1),q?(1,2),q?(2,1),q(2,2),d(1),d(2)}
q
q
(7)
{q(1,1),q(1,2),q(2,1),q(2,2),d(1),d(2)}
q
q
q
q
(8)
Now, the “tester” must eliminate candidate sets in which
queens are positioned on the same row, column, or diago
nal. This can be done by means of the following integrity
constraints:
←
q(X,Y ),q(X?,Y ),X??= X,
d(X),d(Y ),d(X?),d(Y?)
q(X,Y ),q(X,Y?),Y??= Y,
d(X),d(Y ),d(X?),d(Y?)
q(X,Y ),q(X?,Y?),X − X? = Y − Y?,
X??= X,Y??= Y,d(X),d(Y ),d(X?),d(Y?)
(9)
←
(10)
←
(11)
In fact, all rules rule out candidate set (8). Rule (11) eli
minates set (7). However, none of them accounts for the
requirement that n queens must be put on the board. This
can be achieved by the following pair of rules.
←
←
d(X),hasq(X)
hasq(X)d(X),d(Y ),q(X,Y )
The two latter rules eliminate candidate sets (5) and (6).
4 Language Extensions
Classical negation. Normal logic programs provide negati
ve information implicitly through the closed world assump
tion [44]. Consider the following rule: cross ← not train.
If train is not derivable, the atom cross becomes true. But
this may lead to a disaster because you have no explicit infor
mation that there really is no train. An alternative would be
to use an explicit negation operator ¬. Then we can express
the previous rule as follows: cross ← ¬train.
Seite 2
Page 3
An atom p or a negated atom ¬p is called a literal.
Logic programs with literals are called extended logic pro
grams [22]. An extended logic program is contradictory [5]
if complementary literals, e.g. train and ¬train, are deri
vable. In that case, one obtains exactly one answer set, viz
the set of all literals. If a program is not contradictory, the
definition of answer sets of extended logic programs carries
over from normal programs.
Classical negation can be eliminated by a polynomial
transformation, replacing each negated atom ¬p by a new
atom p?and adding the rules,
q ← p,p?
and
q?← p,p?,
(12)
for each atom p and q. The rules in (12) generate the set of
all literals in case of contradictory programs. For preserving
only consistent answer sets, we may add constraints ← p,p?
for each atom p, instead of the rules in (12).
Disjunctive logic programs extend normal programs by dis
junctive information in the head of a rule [22]. More precisely,
the head of a rule is a disjunction q0;...;qk for atoms qi,
where 0 ≤ i ≤ k. E.g. p;q expresses that “p is true or q
is true”. Letting head(r) = {q0,...,qk}, a set of atoms
X is closed under a basic program Π if for any r ∈ Π,
head(r) ∩ X ?= ∅ whenever body+(r) ⊆ X. The definition
of ΠXcarries over from normal programs. An answer set X
of a disjunctive logic program is a ⊆ minimal set of atoms
being closed under ΠX. For example, the disjunctive logic
program Π = {p;q ←} has the answer sets {p} and {q}.
The set {p,q} is closed under Π{p,q}, but it is not an answer
set of Π since it is not ⊆minimal. Observe that adding the
rules p ← and q ← to Π makes {p,q} the only answer set
of Π ∪ {p ←,q ←}. If we use disjunction in the nqueens
problem, rules (3) and (4) can be replaced by one rule:
q(X,Y ); q?(X,Y )
←
d(X),d(Y )
The usage of disjunction raises the complexity of the un
derlying decision problems, e.g. deciding whether there exists
an answer set X for a given atom p such that p ∈ X is ΣP
complete [18].
2
Nested logic programs are logic programs where the bodies
and heads of rules may contain arbitrary boolean expressions
formed from propositional atoms and the symbols ? (true)
and ⊥ (false) using negationasfailure (not), conjunction
(,), and disjunction (;) [30]. Answer sets are similarly defined
as for disjunctive programs under regard that every boolean
expression must be satisfied in the sense of classical logic and
that the reduct ΠXis operating on boolean expressions. For
illustration, consider nested program Π = {(p;not p) ←}.
Taking X = ∅, we obtain Π∅= {(p;?) ←} as reduct and ∅
as the only ⊆ minimal set being closed under Π∅, that is,
the boolean expression (p;?) is trivially satisfied by X = ∅.
For X = {p}, we get Π{p}= {(p;⊥) ←} and {p} as the
⊆minimal set satisfying the expression (p;⊥). Hence, ∅ and
{p} are the answer sets of nested program {(p;not p) ←}.
In the nqueens problem, rules (3) and (4) can be replaced
by q(X,Y ); not q(X,Y ) ← d(X),d(Y ) , where the usage
of nested expressions avoids using auxiliary predicate q?.
Nested programs can be polynomially translated into dis
junctive programs [39].
Cardinality constraints are extended literals [49]. They are
of the form l {q1,...,qm} u, for m ≥ 1, where l,u are
lower and upper bounds on the cardinality of subsets of
{q1,...,qm} satisfied in an encompassing answer set. They
can appear in the head or in the body of a rule. A car
dinality constraint is satisfied in an answer set X, if the
number of atoms from {q1,...,qm} belonging to X is bet
ween l and u. To ensure in the nqueens problem that ex
actly one queen is in every column j, we use the expres
sion 1{q(1,j),...,q(n,j)}1, which can be abbreviated by
1{q(X,j) : d(X)}1, a socalled conditional literal [49]. Hence,
the nqueens problem can be encoded with three rules, na
mely rule (11) and
1{q(X,Y ) : d(X)}1
1{q(X,Y ) : d(Y )}1
←
←
d(Y )
(13)
d(X),
(14)
where rules (13) and (14) ensure that there is exactly one
queen in every column and row, respectively.
Deciding whether a normal program with cardinality cons
traints has an answer set is NPcomplete [49].
Preferences. The notion of preference is pervasive in common
sense reasoning, e.g. in decision making, in part because
preferences constitute a very natural and effective way of
resolving indeterminate situations. In the following, we will
exemplarily consider preferences among rules and socalled
ordered disjunctions.
Rule preferences. A logic program with (static) prefe
rences is a pair (Π,<) where Π is a logic program and < is a
strict partial order among rules of Π expressing that one rule
has higher priority than another rule. Also, dynamic prefe
rences can be modeled by taking a special purpose predicate
prec instead of an external order <. In both cases, the idea
is to apply a rule r only if the “question of applicability” has
been settled for all higher preferred rules r?. See [47, 14] for
a survey on strategies for rule preferences.
Ordered disjunctions allow to represent alternative, ran
ked options in the head of rules [10]. p × q is an ordered
disjunction which means: if possible p, but if p is impossi
ble then at least q. Ordered disjunctions can be used, e.g.
for the problem of composing a menu. You can choose bet
ween meat or vegetarian food. In case of choosing meat
you would prefer wine over mineral water, otherwise you
prefer mineral water over wine. These preferences can be
modeled with ordered disjunctions as follows:
meat × vegetarian
wine × water
water × wine
←
←
←
meat
not meat
This program has answer set {meat,wine}. But in the case
where meat is not possible, e.g. adding the integrity cons
traint ← meat, the answer set is {vegetarian,water}.
Further preference handling approaches in answer set
programming are preferences among literals [46], ordered
Seite 3
Page 4
choice logic programs [8], the preference description langua
ge PDL [9] for specifying complex preferences structures in
optimization problems, and consistencyrestoring rules [4].
Other language extensions include aggregate functions [15],
like sum, count, or min, weak constraints [27] as a variant
of integrity constraints, and weight constraints [49] as an
extension of cardinality constraints.
5 Systems
In recent years, several systems for answer sets computation
have become available, including smodels [50, 49], dlv [17,
27], noMoRe [38, 32], assat [2, 31], and cmodels [12]. Most
of the currently known ASP systems are designed to compute
answer sets for propositional logic programs. In order to deal
with programs containing variables, the systems rely on a
two phase implementation consisting of:
1. elimination of variables for obtaining propositional pro
grams and handling special system dependent langua
ge extensions (see Section 4); and
2. computation of answer sets for propositional programs.
Before detailing the second phase, we shortly report on the
main tools for variable elimination, socalled grounders. Current
ly, most ASP systems utilize lparse (the grounder coming
with the smodels system) or the grounder included in dlv.
Both grounders allow for parsing disjunctive logic programs
with classical negation along with their specific language ex
tensions.
The remainder of this section describes the second pha
se, dealing with answer set generation of propositional logic
programs. For simplicity, we deal with normal programs only.
In this case, answer sets are (sub)sets of atoms occurring in
a given program as heads of rules. A partial model is defined
as a 3valued truth assignment for the atoms of a program
with truth values true, false and undefined. Such a 3valued
model is total if it contains no undefined atoms. General
ly, the answer set computation in the second phase aims at
extending a given partial model to a total one which is an
answer set (or determining that this is impossible). The com
putation can be decomposed into alternating deterministic
and nondeterministic parts. We start with the partial model
where all atoms are undefined. Then we try to extend it to an
answer set by computing its deterministic consequences by
means of propagation techniques. These techniques extend
the partial model by increasing the number of atoms being
true or false, respectively. If the obtained model is total, then
it is returned as an answer set. If the model is contradictory,
in the sense that an atom has been assigned both true and
false, then we have detected a situation admitting no ans
wer sets. Otherwise, we must nondeterministically choose
an undefined atom and “branch” on its possible truth va
lues true and false. This is done by a case analysis which
recursively applies the described procedure once to the par
tial model where the chosen atom is assigned true and again
to the partial model where the chosen atom is false1.
1The above procedure is similar to the DavisPutnam
LogemannLoveland procedure [13] for SAT solvers.
Observe that all ASP solvers additionally utilize some
heuristics to guide their choices. The actual heuristics is cru
cial for the overall system performance, since the number
of choices determines the depth of the (exponential) search
tree. For a detailed discussion of different ASP heuristics
including experimental results see [20].
The smodels system. The basic smodels algorithm can be
described as follows:
smodels(L,U)
1 expand(L,U)
2 if L ?⊆ U then return fail
3 if L = U then exit with L
4 A ← select(U \ L)
5 smodels(L ∪ {A},U)
6 smodels(L,U \ {A})
It computes an answer set between lower bound L and up
per bound U, or determines that this is impossible. That
is, the two sets L and U aim at capturing all answer sets
X such that L ⊆ X ⊆ U. Observe that partial models are
represented through two sets of atoms L and U, where L
contains all true atoms and U contains all atoms not yet
known to be false (that is, true or undefined); false atoms
are implicitly given by Atm(Π)\U.2First, smodels compu
tes deterministic consequences of a partial model at hand by
calling its propagation procedure expand (Line 1). Observe
that expand is based on propagation rules which generalize
the wellfounded semantics [53]. In fact, if a call to expand
produces sets L and U such that L is not a subset of U,
then it follows that there is no answer set between the in
itially given bounds (Line 2). On the other hand, if L = U
after a call to expand (Line 3), then L is an answer set of
the underlying logic program. More precisely, expand tries
to enlarge lower bound L and, at the same time, it tries to
make upper bound U smaller in such a way that no answer
set is lost. That is, for all answer sets X of a program we
have if condition L ⊆ X ⊆ U holds before calling expand,
then it also holds after the execution of expand. If neces
sary, smodels then chooses an undefined atom A (Line 4)
and calls itself recursively, first (Line 5) to try to find an
answer set between L ∪ {A} and U, that is, setting A true,
and second (Line 6) to find an answer set between L and
U \ {A}, that is, setting A false. Initially, smodels is called
with ∅ and Atm(Π). This guarantees that all answer sets of
Π are found via backtracking.
The dlv system [17] extents the computation of answer
sets to disjunctive logic programs and dlv specific language
extensions, e.g. aggregate functions and weak constraints.
Its core algorithm is similar to the one of smodels. The
propagation of dlv also relies on computing wellfounded
semantics plus backpropagation mechanisms that allow for
additionally marking atoms as being “eventually true”.
The systems assat and cmodels. These two ASP solvers
operate by reducing the problem of answer set computa
tion to the satisfiability problem of propositional formulas
(via Clark’s completion [11]) and by invoking a SAT solver
2Atm(Π) denotes the set of all atoms occurring in Π.
Seite 4
Page 5
to generate answer sets. The fact that answer sets of the
syntactically restricted class of tight programs correspond
to classical models of its completion was discovered by Fa
ges [21] and used for answer set computation in [2, 12]. For
handling the general case correctly, socalled loop formulas
have to be added [31]. However, complexity considerations
show that an exponential growth in size is likely to be unavoi
dable, whenever logic programs are mapped into equivalent
propositional formulas [29].
The noMoRe system [38] relies on a graphbased approach.
It has its roots in default logic [45], where extensions are
often characterized through their (unique) set of generating
default rules. Accordingly, noMoRe characterizes answer sets
by means of their set of generating rules. For determining
whether a rule belongs to this set, we must verify that each
positive body atom is derivable and that no negative body
atom is derivable. In fact, an atom is derivable if the set
of generating rules includes a rule having the atom as its
head; or conversely, an atom is not derivable if there is no
rule among the generating rules that has the atom as its
head. Consequently, the formation of the set of generating
rules amounts to resolving positive and negative dependen
cies among rules. For capturing these dependencies, noMoRe
takes advantage of the concept of a rule dependency graph,
wherein each node represents a rule of the underlying pro
gram and two types of edges stand for the aforementioned
positive and negative rule dependencies, respectively. Answer
sets now can be expressed by total nonstandard 2colorings
of the rule dependency graph [32, 26], such that, whether a
rule belongs to a set of generating rules or not, is indicated
through its color.
Other systems. In addition to the above presented ASP sy
stems there are other systems available, among them we
find the plp system [40] for preference handling, XSB [43]
for computing wellfounded semantics, the quip [42] sy
stem dealing with ASP through quantified boolean formulas,
nlp [36] a frontend for nested logic programs, psmodels [41]
an implementation of ordered disjunctions, and gnt [23] an
system for disjunctive logic programs based on smodels.
In order to foster further development of ASP the auto
mated benchmarking system asparagus [1, 7] was launched.
Its two principal goals are to provide an infrastructure for
accumulating challenging benchmarks, and to facilitate exe
cuting ASP solvers under the same conditions, guaranteeing
reproducible and reliable performance results.
6 Applications
ASP has been applied in multiple areas, e.g. product confi
guration [52, 51], planning [28, 16] and diagnosis [3].
In product configuration one derives a valid configuration
from predefined components, some restrictions on these, and
a set of customer requirements. One example is the configu
ration of PCs. Take program
computer ←
(15)
1 {ide disk,scsi disk} ← computer
german layout;us layout ← computer
scsi controller ← scsi disk
expressing in rule (16) that a computer has an IDE or a SCSI
disk and either a German or US layout keyboard in (17). If
it does have a SCSI disk, rule (18) states that it also needs
a SCSI controller. The answer sets of this program repre
sent all possible configurations. If you now add the customer
requirements (German keyboard, no SCSI disk)
(16)
(17)
(18)
← scsi disk
german layout ←
the remaining, single answer set
{computer,ide disk,german layout}
represents the only valid configuration.
This easy, highly declarative way of dealing with confi
guration tasks is used e.g. for the configuration of Debian
Linux [51].
Planning within ASP is another area that has been exten
sively studied during the last few years. Consider the blocks
world domain where we want to move blocks from an initi
al situation to a goal situation. In ASP, we can express the
problem in the following way. We start with the generator:
{mv(B,L,T) : bl(B) : loc(L)} 1 ← t(T),T < last
which generates possible moves (mv) of blocks (bl) to cer
tain locations3(loc) for all discrete time steps (t) before time
step last (see rule (19)).
(19)
on(B,L,T + 1) ← mv(B,L,T),bl(B),loc(L),
t(T),T < last
(20)
on(B,L,T + 1) ← on(B,L,T),
(21)
not ¬on(B,L,T + 1),
bl(B),loc(L),t(T),T < last
¬on(B,L1,T) ← on(B,L,T),L ?= L1,bl(B),
loc(L),loc(L1),t(T),T < last
(22)
We describe the effect of a move action in (20) by saying
that if block B is moved to location L at time T, it will
be on that location at the next time step T + 1. Inertia
(21) expresses that a block stays on a location, unless it
does not (¬on). The information that a block is not on a
certain location is represented by rule (22), which expresses
uniqueness of location (no block can be at two locations at
the same time).
Now let us look at the tester part of our program.
← 2 {on(B1,B,T) : bl(B1)},bl(B),t(T)
← mv(B,L,T),on(B1,B,T),bl(B),bl(B1),
loc(L),t(T),T < last
(23)
(24)
3Possible locations are the blocks themselves and the table.
Seite 5
Page 6
Integrity constraint (23) expresses that no two blocks
can be on top of the same block (though they can both be
on the table). Via constraint (24) we express that a block
can only be moved, if there is no block on top of it.
We have now described the blocks world domain with
just six rules. Now we only need to specify our initial (i.e. at
time step 0) and goal (at time step last) situations. E.g., we
start with two towers with two blocks each:
on(1,2,0) ←
on(3,4,0) ←
on(2,table,0) ←
on(4,table,0) ←
To specify our goal situation of just one big tower, we use
integrity constraints. We disallow all answer sets (possible
plans) where the blocks are not in the desired position at
the last time step:
← not on(4,3,last)
← not on(2,1,last)
← not on(3,2,last)
← not on(1,table,last)
The last thing we need to do is to fix the macro last to a
specific number of time steps, representing the length of the
plans to be investigated. For the situation above, we could
e.g. use last = 3, which would give us all possible plans of
length three, i.e., {mv(4,table,0),mv(3,2,1),mv(4,3,2)} .
We have refrained from giving explicit instantiations of
the domain predicates bl and t, which would also be needed.
Other Applications of ASP include the Reaction Control
System of the Space Shuttle [37], which has primary respon
sibility for maneuvering the aircraft while in space. Also, ASP
has been employed e.g. for Constraint Programming [35], for
certain issues pertaining Petri nets [24], for cryptanalysis [25]
and for research in historical linguistics [19].
Acknowledgments. The authors were supported by DFG un
der grants FOR 375/1 and SCHA 550/6 as well as WASP
project IST200137004. We would like to thank G. Brewka,
V. Lifschitz, I. Niemel¨ a, and M. Truszczy´ nski whose materi
als provided an extremely valuable source for this paper.
Literatur
[1] http://asparagus.cs.unipotsdam.de.
[2] http://assat.cs.ust.hk.
[3] M. Balduccini and M. Gelfond. Diagnostic reasoning
with Aprolog. Theory and Practice of Logic Program
ming, 3(45):425–461, 2003.
[4] M. Balduccini and M. Gelfond. Logic programs with
consistencyrestoring rules. In P. Doherty, J. McCarthy,
and M.A. Williams, editors, International Symposium
on Logical Formalization of Commonsense Reasoning,
AAAI Spring Symposium Series, 2003.
[5] C. Baral. Knowledge representation, reasoning and de
clarative problem solving with Answer sets. Cambridge
University Press, 2003.
[6] P. Bonatti. Reasoning with infinite stable models. Ar
tificial Intelligence, 156(1):75–111, 2004.
[7] P. Borchert, C. Anger, T. Schaub, and M. Truszczy´ nski.
Towards systematic benchmarking in answer set pro
gramming. In V. Lifschitz and I. Niemel¨ a, editors, Pro
ceedings of the International Conference on Logic Pro
gramming and Nonmonotonic Reasoning, pages 3–7.
Springer, 2004.
[8] M. Brain and M. De Vos. Implementing oclp as a front
end for answer set solvers: From theory to practice. In
M. De Vos and A. Provetti, editors, Proceedings of the
International Workshop on Answer Set Programming,
2003. CEUR Workshop Proceedings.
[9] G. Brewka. Complex preferences for answer set optimi
zation. In D. Dubois, Chr. Welty, and M.A. Williams,
editors, Proceedings of the International Conference on
Principles of Knowledge Representation and Reasoning,
pages 213–223. AAAI Press, 2004.
[10] G. Brewka, I. Niemel¨ a, and T. Syrj¨ anen. Logic programs
with ordered disjunction. Computational Intelligence,
20(2):335–357, May 2004.
[11] K. Clark. Negation as failure. In H. Gallaire and J. Min
ker, editors, Logic and Data Bases, pages 293–322. Ple
num Press, 1978.
[12] http://www.cs.utexas.edu/users/tag/cmodels.html.
[13] M. Davis and H. Putnam. A computing procedure for
quantification theory. Journal of the ACM, 7:201–215,
1960.
[14] J. Delgrande, T. Schaub, H. Tompits, and K. Wang.
A classification and survey of preference handling ap
proaches in nonmonotonic reasoning. Computational
Intelligence, 20(2):308–334, 2004.
[15] T. Dell’Armi, W. Faber, G. Ielpa, N. Leone, and G. Pfei
fer. Aggregate functions in disjunctive logic program
ming: Semantics, complexity, and implementation in
dlv. In G. Gottlob and T. Walsh, editors, Proceedings
of the International Joint Conference on Artificial Intel
ligence, pages 847–852. Morgan Kaufmann, 2003.
[16] Y. Dimopoulos, B. Nebel, and J. K¨ ohler.
planning problems in nonmonotonic logic programs. In
S. Steel and R. Alami, editors, Proceedings of the Euro
pean Conference on Planning, pages 169–181. Springer,
1997.
[17] http://www.dbai.tuwien.ac.at/proj/dlv.
[18] T. Eiter and G. Gottlob. On the computational cost of
disjunctive logic programming: Propositional case. An
nals of Mathematics and Artificial Intelligence, 15:289–
323, 1995.
[19] E. Erdem, V. Lifschitz, L. Nakhleh, and D. Ringe. Re
constructing the evolutionary history of indoeuropean
languages using answer set programming.
ceedings of the International Symposium on Practi
cal Aspects of Declarative Languages, pages 160–176,
2003.
[20] W. Faber, N. Leone, and G. Pfeifer. Experimenting with
heuristics for answer set programming. In B. Nebel, edi
tor, Proceedings of the International Joint Conference
on Artificial Intelligence, pages 635–640. Morgan Kauf
mann, 2001.
Encoding
In Pro
Seite 6
Page 7
[21] F. Fages. Consistency of clark’s completion and the
existence of stable models. Journal of Methods of Logic
in Computer Science, 1:51–60, 1994.
[22] M. Gelfond and V. Lifschitz. Classical negation in logic
programs and disjunctive databases. New Generation
Computing, 9:365–385, 1991.
[23] http://www.tcs.hut.fi/Software/gnt.
[24] K. Heljanko. Using logic programs with stable model
semantics to solve deadlock and reachability problems
for 1safe petri nets. In Proceedings of the International
Conference on Tools and Algorithms for the Construc
tion and Analysis of Systems, pages 218–223, 1999.
[25] M. Hietalahti, F. Massacci, and I. Niemel¨ a.
challenge problem for nonmonotonic reasoning systems.
In Proceedings of the International Workshop on Non
Monotonic Reasoning, 2000.
[26] K. Konczak, T. Linke, and T. Schaub. Graphs and co
lorings for answer set programming: Abridged report.
In V. Lifschitz and I. Niemel¨ a, editors, Proceedings of
the International Conference on Logic Programming
and Nonmonotonic Reasoning, pages 127–140. Sprin
ger, 2004.
[27] N. Leone, W. Faber, G. Pfeifer, T. Eiter, G. Gottlob,
C. Koch, C. Mateis, S. Perri, and F. Scarcello. The
DLV system for knowledge representation and reaso
ning. ACM Transactions on Computational Logic, 2004.
To appear.
[28] V. Lifschitz. Answer set planning. Artificial Intelligence,
138(12):39–54, 2002.
[29] V. Lifschitz and A. Razborov. Why are there so many
loop formulas? ACM Transactions on Computational
Logic. To appear.
[30] V. Lifschitz, L. Tang, and H. Turner. Nested expressions
in logic programs. Annals of Mathematics and Artificial
Intelligence, 25(34):369–389, 1999.
[31] F. Lin and Y. Zhao. Assat: Computing answer sets of
a logic program by sat solvers. Artificial Intelligence,
157:115–137, 2004.
[32] T. Linke. Graph theoretical characterization and com
putation of answer sets. In B. Nebel, editor, Procee
dings of the International Joint Conference on Artificial
Intelligence, pages 641–645. Morgan Kaufmann, 2001.
[33] V. Marek and J. Remmel. On the expressibility of sta
ble logic programming.
M. Truszczy´ nski, editors, Proceedings of the Interna
tional Conference on Logic Programming and Nonmo
notonic Reasoning, pages 107–120. Springer, 2001.
[34] V. Marek and M. Truszczy´ nski. Stable models and an
alternative logic programming paradigm.
W. Marek, M. Truszczy´ nski, and D. Warren, editors,
The Logic Programming Paradigm: a 25Year Perspec
tive, pages 375–398. Springer, 1999.
[35] I. Niemel¨ a. Logic programs with stable model semantics
as a constraint programming paradigm. Annals of Ma
thematics and Artificial Intelligence, 25(3,4):241–273,
1999.
[36] http://www.cs.unipotsdam.de/∼torsten/nlp.
Des: A
In T. Eiter, W. Faber, and
In K. Apt,
[37] M. Nogueira, M. Balduccini, M. Gelfond, R. Watson,
and M. Barry. An AProlog decision support system
for the Space Shuttle. In Proceedings of the Interna
tional Symposium on Practical Aspects of Declarative
Languages, pages 169–183, 2001.
[38] http://www.cs.unipotsdam.de/∼linke/nomore.
[39] D. Pearce, V. Sarsakov, T. Schaub, H. Tompits, and
S. Woltran. A polynomial translation of logic programs
with nested expressions into disjunctive logic programs.
In P. Stuckey, editor, Proceedings of the Internatio
nal Conference on Logic Programming, pages 405–420.
Springer, 2002.
[40] http://www.cs.unipotsdam.de/∼torsten/plp.
[41] http://www.tcs.hut.fi/Software/smodels/priority.
[42] http://www.kr.tuwien.ac.at/research/quip.html.
[43] P. Rao, K. F. Sagonas, T. Swift, D. S. Warren, and
J. Freire. XSB: A system for effciently computing wfs.
In J. Dix, U. Furbach, and A. Nerode, editors, Pro
ceedings of the International Conference on Logic Pro
gramming and Nonmonotonic Reasoning, pages 431–
441. Springer, 1997.
[44] R. Reiter. On closed world data bases. In H. Gallaire
and J. Minker, editors, Logic and Databases, pages 55–
76. Plenum Press, 1978.
[45] R. Reiter. A logic for default reasoning. Artificial Intel
ligence, 13(12):81–132, 1980.
[46] C. Sakama and K. Inoue. Prioritized logic programming
and its application to commonsense reasoning. Artificial
Intelligence, 123(12):185–222, 2000.
[47] T. Schaub and K. Wang. A semantic framework for
preference handling in answer set programming. Theory
and Practice of Logic Programming, 3(45):569–607,
2003.
[48] J. Schlipf. The expressive powers of the logic program
ming semantics. Journal of Computer and Systems
Sciences, 51:64–86, 1995.
[49] P. Simons, I. Niemel¨ a, and T. Soininen. Extending and
implementing the stable model semantics. Artificial In
telligence, 138(12):181–234, 2002.
[50] http://www.tcs.hut.fi/Software/smodels.
[51] T. Soininen and I. Niemel¨ a. Developing a declarative
rule language for applications in product configuration.
In Proceedings of the First International Workshop on
Practical Aspects of Declarative Languages, pages 305–
319, 1999.
[52] T. Soininen, I. Niemel¨ a, J. Tiihonen, and R. Sulo
nen. Representing configuration knowledge with weight
constraint rules. In Proceedings of the AAAI Spring
Symposium on Answer Set Programming, 2001.
[53] A. van Gelder, K. Ross, and J. S. Schlipf. The well
founded semantics for general logic programs. Journal
of the ACM, 38(3):620–650, 1991.
Contact
Chr. Anger, K. Konczak, Th. Linke, and T. Schaub
Universit¨ at Potsdam, Institut f¨ ur Informatik
AugustBebelStraße 89, D14482 Potsdam
{christian,konczak,linke,torsten}@cs.unipotsdam.de
http://www.cs.unipotsdam.de/wv/
Seite 7
View other sources
Hide other sources
 Available from unipotsdam.de
 Available from Torsten Schaub · May 17, 2014