Content uploaded by Pedro Cabalar
Author content
All content in this area was uploaded by Pedro Cabalar on Oct 13, 2014
Content may be subject to copyright.
Existential quantifiers in the rule body
Pedro Cabalar?
Department of Computer Science,
Corunna University (Corunna, Spain),
cabalar@udc.es
Abstract. In this paper we consider a simple syntactic extension of
Answer Set Programming (ASP) for dealing with (nested) existential
quantifiers and double negation in the rule bodies, in a close way to
the recent proposal RASPL-1. The semantics for this extension just re-
sorts to Equilibrium Logic (or, equivalently, to the General Theory of
Stable Models), which provides a logic-programming interpretation for
any arbitrary theory in the syntax of Predicate Calculus. We present a
translation of this syntactic class into standard logic programs with vari-
ables (either disjunctive or normal, depending on the input rule heads),
as those allowed by current ASP solvers. The translation relies on the
introduction of auxiliary predicates and the main result shows that it
preserves strong equivalence modulo the original signature.
1 Introduction
One of the traditional limitations of Answer Set Programming (ASP) in the
past has been the need of resorting to a ground instantitation of program rules.
Starting from the original definition of Stable Models [1] in terms of a proposi-
tional language, ASP solvers were designed following a two step process: first,
removing variables in favour of all their ground instances; and second, comput-
ing the stable models of the resulting ground program. Variables were somehow
an “external” element that was not directly treated in the semantics. It is not
surprising, in this way, that quantification was not paid too much attention in
the past although, paradoxically, most practical applications of ASP deal in one
way or another with some limited use of quantified variables, using auxiliary
predicates to capture the intended meaning.
This general picture has experienced a drastical change in the last years
thanks to the introduction of Quantified Equilibrium Logic [2] (QEL) or the
equivalent definition of stable models for first-order formulas proposed in [3].
These approaches provide a logic-programming interpretation for any arbitrary
first-order theory, so that syntactic restrictions do not play a role in the seman-
tic definition any more. Some recent results have been obtained in applying this
semantics to programs with variables, without resorting to grounding. For in-
stance, [4] treats the problem of strong equivalence, whereas in [5] QEL is used
?This research was partially supported by Spanish MEC project TIN-2006-15455-
C03-02 and Xunta de Galicia project INCITE08-PXIB105159PR.
to analyse rule redundancy and the completeness of rule subsumption under
a given substitution. On the other hand, much work remains to be done yet
in exploring the intuition, under a logic-programming perspective, of the QEL
interpretation of formulas with arbitrary syntax or belonging to new syntac-
tic classes. Several works have followed this direction: we can mention [6], that
has studied the extension of the concept of safety for arbitrary theories; [7],
which considers an extension for dealing with partial functions; or [8], that pro-
poses a logic-programming language RASPL-1 for counting and choice that can
be translated into first-order expressions under QEL by introducing existential
quantifiers and double negations in the rule bodies.
In this paper we analyse an extension of logic programs with variables where,
similarly to first-order theories resulting from the RASPL-1 translation, we in-
troduce existential quantifiers and double negations in the rule bodies, further
allowing a way of nesting these new constructs (something not considered in [8]).
We provide some intutitions of the utility of this extension and explain how these
features are already used in the current ASP programming style by a suitable in-
troduction of auxiliary predicates. In fact, we propose an automated translation
that relies on this technique of auxiliary predicates and reduces the proposed
extension to regular logic programs with variables as those accepted by current
ASP grounding tools. This translation is shown to be strongly equivalent (mod-
ulo the original language without the auxiliary predicates). Apart from providing
a more readable and compact representation, the advantage of dealing with the
extended syntax is avoiding a potential source of errors in the introduction of
auxiliary predicates, not only due to a possible programmer’s mistake in the
formulation, but especially because auxiliary predicates must be guaranteed to
be hidden and limited to their original use.
The rest of the paper is organised as follows. In the next section we introduce
some motivating examples and explain the paper goals. In Section 3 we provide
an overview of Quantified Equilibrium Logic to proceed in the next section with
the introduction of the syntactic subclass we study in this paper. Section 5
presents the translation of this class into regular logic programs, proving its
correctnes. Section 6 discusses some related work and finally, Section 7 concludes
the paper.
2 Motivation
Example 1. Given the extent of predicates person(X), parent(X, Y ) (Xis a
parent of Y) and married(X, Y ) which is a symmetric relation, suppose we
want to represent that a person is happy, happy(X), when all his/her offsprings
are married. ut
A typical piece of program representing this problem in ASP would probably
look like:
has spouse(Y)←married(Y, Z )
has single offs(X)←parent(X, Y ),not has spouse(Y)
happy(X)←person(X),not has single offs(X)
Notice how predicates has spouse and has single offs are not in the problem
enunciate. Furthermore, their name suggest that we are capturing an existential
quantifier: note how in the first two rules, we have a free variable in the body that
does not occur in the head. In other words, a more compact way of representing
this program could just be:
happy(X)←person(X),not ∃Y(parent(X, Y ),not ∃Z married(Y , Z)) (1)
We will show that, in fact, both representations are strongly equivalent under
QEL if we restrict the use of the auxiliary predicates has spouse and has single offs
to the above mentioned rules. Notice, however, the importance of this second
representation. We, not only, get a more readable formula and avoid auxiliary
predicates not included in the original problem: we also avoid a possible mis-
take in the use of these predicates in another part or module of the program,
something that could radically change their intended meaning for the example.
As another typical example of an implicit existential quantifier, consider the
frequent formalisation of the inertia default in ASP:
holds(F, V, do(A, S)) ←holds(F, V, S ),not ab(F, V, A, S) (2)
ab(F, V, A, S)←holds(F, W, do(A, S)), W 6=V(3)
where the complete rule bodies would also include the atoms action(A), situation(S),
fluent(F), range(F, V ) and range(F, W ) to specify the sorts of each variable1.
Again, predicate ab is introduced to capture the meaning: “there exists a value
for Fother than V.” In other words, the formula could have been written instead
as:
holds(F, V, do(A, S)) ←holds(F, V, S ),not ∃W(holds(F, W, do(A, S)), W 6=V)
Something similar happens with choice-like pairs of rules for generating pos-
sible solutions. They typically have the form of even negative loops, like in the
example:
in(X)←vertex(X),not out(X)
out(X)←vertex(X),not in(X)
⊥ ← in(X), in(Y), X 6=Y, not edge(X, Y ),not edge(Y , X)
1Grounders like lparse allow avoiding the repetitive definition of variable sorts by
specifying general sorted variables with macros of the form #domain action(A).
intended for generating a clique2in terms of predicate in(X). It seems clear
that predicate out(X) is auxiliary and thus its use should be limited to this pair
of rules (adding other rules with out(X) as a head may change the intended
meaning). An alternative to this kind of “generating” loops is using a cardinality
constraint (as defined in [9]) of the form:
{in(X)} ← vertex(X)
whose intuitive meaning is, for each vertex X, pick 0 or 1 atoms in the set
{in(X)}. As explained in [8] the formula above is (strongly) equivalent to:
in(X)←vertex(X)∧ ¬¬in(X) (4)
The informal reading of a formula like ¬¬αin the body is that “it is consistent
to assume α.” It is perhaps interesting to note that, as shown in [10], a double
negation in the body can be moved (maintaining strong equivalence) to a single
negation in the head, as follows:
in(X)∨ ¬in(X)←vertex(X)
and it is well-known [11,12] that head negations can be ruled out in favour of
auxiliary predicates, eventually returning to the same formulation we had with
the out(X) predicate. Once again, the interest of the extended syntax is that it
can be translated into traditional logic programs while it avoids the explicit use
of auxiliary predicates which become hidden in the translation.
3 Overview of Quantified Equilibrium Logic
Following [5], Quantified Equilibirum Logic (QEL) is defined in terms of a models
selection criterion for the intermediate logic of Quantified Here-and-There. In the
paper, we will deal with a version of this logic dealing with static domains and
decidable equality, calling it QHT for short.
Let L=hC, F, P ibe a first-order language where Cis a set of constants,F
a set of functions and Pa set of predicates. First-order formulae for Lare built
up in the usual way, with the same syntax of classical predicate calculus. As in
Intuitionistic Calculus, the formula ¬ϕwill actually stand for ϕ→ ⊥. We write
Atoms(C, P ) to stand for the set of atomic sentences built with predicates in P
and constants in C. Similarly, T erms(C, F ) denote the set of ground terms built
from functions in Fand constants in C.
We will adopt a logical writing for logic programming connectives, so that
constructions like (α, β), (not α) and (α←β) are respectively written as (α∧β),
(¬α) and (β→α). We also adopt lower-case letters for variables and functions,
and upper-case for predicates and constants. In this way, a rule like (2) becomes
the formula:
Holds(f, v, s)∧ ¬Ab(f, v, a, s)→Holds(f , v, do(a, s))
2A clique is a set of vertices that are pairwise adjacent.
We use boldface letters x,yto denote tuples of variables, and similarly dfor
tuples of domain elements.
The corresponding semantics for QHT is described as follows.
Definition 1 (QHT-interpretation). A QHT-interpretation for a language
L=hC, F, P iis a tuple h(D, σ), H, T iwhere:
1. Dis a nonempty set of constant names identifying each element in the inter-
pretation universe. For simplicity, we take the same name for the constant
and the universe element.
2. σ:T erms(D∪C, F )→Dassigns a constant in Dto any term built with
functions in Fand constants in the extended set of constants C∪D. It must
satisfy: σ(d) = dfor all d∈D.
3. Hand Tare sets of ground atomic sentences such that H⊆T⊆Atoms(D, P ).
ut
An interpretation of the form h(D, σ), T , Tiis said to be total and can be seen
as the classical first-order interpretation h(D, σ), T i. In fact, we will indistinctly
use both notations. Furthermore, given any arbitrary M=h(D, σ), H, T iwe will
define a corresponding total (or classical) interpretation MT
def
=h(D, σ), T i.
Satisfaction of formulas is recursively defined as follows. Given an interpre-
tation M=h(D, σ), H, T i, the following statements are true:
–M |=p(t1, . . . , tn) if p(σ(t1), . . . , σ(tn)) ∈H.
–M |=t1=t2if σ(t1) = σ(t2).
–M 6|=⊥.
–M |=α∧βif M |=αand M |=β. Disjunction ∨is analogous.
–M |=α→βif both:
(i) M 6|=αor M |=βand
(ii) MT|=α→βin classical logic
–M |=∀x α(x) if both:
(i) M |=α(d), for each d∈Dand
(ii) MT|=∀x α(x) in classical logic
–M |=∃x α(x) if for some d∈D,M |=α(d). ut
In the proofs, we will make use of the following property:
Proposition 1. If M |=ϕthen MT|=ϕ.ut
Nonmonotonic entailment is obtained by introducing a models-minimisation
criterion. Let us define the following ordering relation among interpretations
Definition 2. We say that an interpretation M=h(D, σ), H, T iis smaller
than an interpretation M0=h(D, σ), H 0, T i, written MM0, when H⊆H0.
ut
That is, to be comparable, Mand M0must only differ in their Hcomponent, so
that MM0iff H⊆H0. Notice that, as a consequence, MMT. As usual,
we write M≺M0when MM0and M 6=M0(that is H⊂H0).
We say that Mis a model of a theory Γif Msatisfies all the formulas in
Γ. If Mis total, it is easy to check that: M |=Γiff MT|=Γin classical logic.
The next definition introduces the idea of minimal models for QHT.
Definition 3 (Equilibrium model). A total model Mof a theory Γis an
equilibrium model if there is no smaller model M0≺ M of Γ.ut
Note that an equilibrium model is a total model, i.e., a classical model of Γ.
We name Quantified Equilibrium Logic (QEL) the logic induced by equilibrium
models.
Given an interpretation Mfor a given language, and a sublanguage L, we
write M|Lto denote the projection of Mmodulo L. We say that two theories
Γ1, Γ2for language L0are strongly equivalent with respect to a given sublanguage
Lof L0, written Γ1≡L
sΓ2, when for any theory Γin L, the sets of equilibrium
models (modulo L) for Γ1∪Γand Γ2∪Γcoincide. When L=L0we just write
Γ1≡sΓ2and, in fact, this has been proved [13] to correspond to the QHT-
equivalence of Γ1and Γ2.
AHerbrand QHT-interpretation M=h(D, σ), H, T iis such that Dcorre-
sponds to T erms(C, F ) and σ=id, where id is the identity relation. In [13] it
was shown that Mis a Herbrand equilibrium model of a logic program Πiff T
is a stable model of the (possibly infinite) ground program grD(Π) obtained by
replacing all variables by all terms in Din all possible ways.
4 Bodies with existential quantifiers
In this section we introduce the syntactic extension of logic programs we are
interested in. We define a body as conjunction of conditions being a condition,
in its turn, recursively defined as:
i) an atom P(t) where tis a tuple of terms;
ii) an equality atom t=t0with t, t0terms;
iii) ∃x(ψ) where xis a tuple of variables and ψis a body in its turn;
iv) ¬Cwhere Cis a condition;
Conditions of the form i) and ii) are called atoms. A literal is also a condition,
with the form of an atom or its negation; the rest of conditions are called non-
literal. A literal like ¬(t=t0) will be abbreviated as t6=t0. Without loss of
generality, we can assume that we handle two consecutive negations at most,
since ¬¬¬C↔ ¬Cis a QHT-tautology. Conditions beginning (resp. not begin-
ning) with ¬are said to be negative (resp. positive). Given a body B, we define
its positive (resp. negative )part,B+(resp. B−) as the conjunction of positive
(resp. negative) conditions in B. We assume that ∃x1. . . xnψis a shorthand
notation for ∃x1. . . ∃xnψ.
Arule is an expression like B→Hd where H d is a (possibly empty) dis-
junction of atoms (called the rule head) and Bis a body. We assume that an
empty disjunction corresponds to ⊥. All free variables in a rule are implicitly
universally quantified. The following are examples of rules:
P(x)∧ ¬¬Q(x)∧ ¬∃yR(x, y)∧ ∃z¬R(y, z )→S(x)∨R(x, x) (5)
P erson(x)∧ ¬∃y(P arent(x, y)∧ ¬∃z Married(y, z)) →H appy(x) (6)
V ertex(x)∧ ¬¬In(x)→In(x) (7)
V ertex(x)∧ ¬∃y(Edge(x, y)∧ ∃z(E dge(y , z))) →P(x) (8)
Rules (6) and (7) are just different ways of writing (1) and (4) respectively.
Rule (8) would intuitively mean, for instance, that P(x) holds for any vertex x
that is terminal or exclusively connected to terminal nodes. A rule is said to be
normal if Hd just contains one atom. If Hd =⊥the rule receives the name of
constraint. A rule is said to be regular if its body is a conjunction of literals (i.e.
it does not contain double negations or existential quantifiers).
A set of rules of the general form above will be called a logic program with
existential quantifiers in the body or ∃-logic program, for short. A program is
said to be normal when all its rules are normal. The same applies for regular
program.
5 A translation into regular logic programs
The translation of a rule r:B→Hd into a regular logic program r∗will consist
in recursively translating all the negative conditions in the rule body Bwith
respect to its positive part B+. This will possibly generate a set of additional
rules dealing with new auxiliary predicates.
Definition 4 (Translation of conditions). We define the translation of a
condition Cwith respect to a positive body B+as a pair hC•, Π (C, B+)iwhere
C•is a formula and Π(C, B+)a set of rules.
1. If Cis a literal or has the form ∃xα(x)then C•=C,Π(C, B+) = ∅.
2. Otherwise, the condition has the form C=¬α(x)being xthe free variables
in C. Then C•=¬Aux(x)and Π(C, B+)=(B+∧α(x)→Aux(x))∗where
Aux is a new fresh predicate and ∗is the translation of rules in Definition 5.
ut
The translation of a conjunction of conditions Dwith respect to a positive
body B+is defined as expected hD•, Π(D , B+)iwhere D•is the conjunction of
all C•for each Cin D, and Π(D, B+) the union of all rules Π(C, B +) for each
Cin D.
Definition 5 (Translation of a rule). The translation of a rule r, written r∗
is done in two steps:
i) We begin replacing all the positive conditions ∃xϕin the body of rby ϕ[x/y]
being ya tuple of new fresh variables3and repeat this step until no condition
of this form is left. Let B→Hd denote the resulting rule.
ii) We then obtain the set of rules:
r∗def
={Hd ←B+∧(B−)•} ∪ Π(B−, B+)
ut
3The introduction of new variables ycan be omitted when xdoes not occur free in
the rest of the rule.
The translation of an ∃-logic program Πis denoted Π∗and corresponds to
the logic program Sr∈Πr∗as expected. As an example of translation, consider
the rule r1= (6). We would have:
r∗
1={P erson(x)∧ ¬Aux1(x)→Happy(x)} ∪ Π(B(r1)−, P erson(x))
where B(r1)−=¬∃y(P arent(x, y)∧ ¬∃z(M arried(y, z))) and so,
Π(B(r1)−, P erson(x)) contains the translation of the rule:
P erson(x)∧ ∃y(P arent(x, y)∧ ¬∃z(Married(y, z))) →Aux1(x)
We remove the positive existential quantifier4to obtain r2:
P arent(x, y)∧ ¬∃z(M arried(y, z)) ∧P er son(x)→Aux1(x)
and now
r∗
2={P arent(x, y)∧P er son(x)∧ ¬Aux2(x, y)→Aux1(x)}
∪Π(B(r2)−, P arent(x, y)∧P erson(x))
This yields the rule
P arent(x, y)∧P er son(x)∧ ∃z(Married(y, z )) →Aux2(x, y)
in which, again, we would just remove the positive existential quantifier. To sum
up, the final complete translation r∗
1would be the (regular) logic program:
P erson(x)∧ ¬Aux1(x)→Happy(x)
P arent(x, y)∧P er son(x)∧ ¬Aux2(x, y)→Aux1(x)
P arent(x, y)∧P er son(x)∧Married(y, z )→Aux2(x, y)
We can informally read Aux2(x, y) as “yis a married child of x” and Aux1(x)
as “xhas some single child.”
It is easy to see that the translation is modular (we translate each rule inde-
pendently) and that its size is polynomial with respect to the original input.
Proposition 2. Given a rule rcontaining Aatoms in its body and Nsubfor-
mulas of one of the forms (¬∃xα)or (¬¬α), the translation r∗contains N+ 1
regular rules whose bodies contain at most A+Natoms in their body. ut
It might be thought that, as we always have a way of removing positive
existential quantifiers, these are unnecessary. However, we must take into account
that they are useful when nested in another expression. For instance, rule (8)
would be translated as:
V ertex(x)∧ ¬Aux(x)→P(x)
V ertex(x)∧Edge(x, y)∧E dge(y , z)→Aux(x)
4As yis not free in the rest of the formula, there is no need to change it by a new
variable, in this case.
but note the difference with respect to a rule like5:
V ertex(x)∧V ertex(z)∧ ¬∃y(Edge(x, y )∧Edge(y, z )) →P(x)
whose meaning is drastically different (zis now implicitly universally quantified).
This is reflected in the corresponding translation:
V ertex(x)∧V ertex(z)∧ ¬Aux(x, z )→P(x)
V ertex(x)∧V ertex(z)∧Edge(x, y )∧Edge(y, z )→Aux(x, z)
Note how Aux(x, z) depends also on znow, capturing the meaning “there is
an intermediate node between xand z.” In this way, P(x) would be true, for
instance, if we just had any unrelated zwithout incoming edges.
As an example with double negation, it can be easily checked that the trans-
lation of rule (7) becomes the program:
V ertex(x)∧ ¬Aux(x)→In(x)
V ertex(x)∧ ¬In(x)→Aux(x)
The intuition behind a double negation of an existential operator can be
understood with the following example. Consider the rule:
¬¬∃x(V ertex(x)∧M arked(x)) →P
expressing that Pholds when it is consistent to assume that there exists a
marked vertex. The tranlsation would be the program Π1:
¬Aux1→P V ertex(x)∧M arked(x)→Aux2
¬Aux2→Aux1
so that, Aux2means “there exists a marked vertex”, Aux1that “there does
not exist a marked vertex” (i.e., all vertices are marked) and so Pwould mean
“I cannot prove there does not exist a marked vertex.” It is perhaps worth to
observe the difference with respect to program Π2just consisting of:
V ertex(x)∧M arked(x)→P
where Pchecks the existence of a marked node. Programs Π1and Π2are
not strongly equivalent (modulo non-auxiliary predicates). For instance, if we
consider the addition of program Π, consisting of the facts V ertex(1) and
V ertex(2)}plus the rules
P→Marked(1) Marked(1) →P
program Π2∪Πhas one stable model {V ertex(1), V ertex(2)}whereas Π1∪Π
has a second stable model {V ertex(1), V ertex(2), M arked(1), P }(modulo non-
auxiliary predicates).
5We included in this example an extra condition V ertex(z) just to keep handling a
safe rule, something we will discuss later.
5.1 Proof of correctness
To prove our main result, we will use several QHT valid equivalences (many of
them already commented in [14]) and introduce several lemmas. For instance,
we will frequently make use of the following QHT valid formula (see [14])
α→(β→γ)↔(α∧β→γ) (9)
Similarly, the following is a QHT-theorem:
α∧ ¬(α∧β)↔α∧ ¬β(10)
whose proof can be obtained from transformations in [10, 14].
Lemma 1. Let Mbe an equilibrium model of Γ, and M |=α. Then Mis an
equilibrium model of Γ∪ {α}.ut
Theorem 1 (Equivalent subformula replacement). Given the equivalence:
∀x(α(x)↔β(x)) (11)
where xis the set of free variables in αor β, and a given formula γcontaining
a subformula α(t), then (11) implies:
γ↔γ[α(t)/β(t)]
ut
Theorem 2 (Defined predicate removal). Let Γ1be a theory for language
L,αa formula in that signature and Aux a predicate not in L. If Γ2is Γ1plus
∀x(Aux(x)↔α(x)) (12)
then Γ1≡L
sΓ2.ut
Lemma 2. Let M1=h(D, σ), H, T ibe a model of the formulas
∀x(α(x)→Aux(x)) (13)
∀x(¬Aux(x)→β(x)) (14)
where αand βdo not contain predicate Aux, and let M2=h(D, σ), H 0, T ibe
such that H\H0={Aux(d)|d∈ D} for some non-empty set of tuples of domain
elements Dsatisfying M1|=Aux(d)and M16|=α(d). Then M2|= (13) ∪(14).
ut
Theorem 3. Let Ldenote a signature not containing predicate Aux, and let
α(x), β(x)be a pair of formulas for L. Given Γ1= (13) ∪(14) and Γ2consisting
of Γ1plus:
∀x(Aux(x)→α(x)) (15)
then Γ1≡L
sΓ2.ut
Theorem 4. Let Γ1be a theory consisting of the single formula
∀xα(x)∧ ¬β(x)→γ(x)(16)
for language L, being xa tuple with all the variables that occur free in the
antecedent or in the consequent. Then Γ1≡L
sΓ2where Γ2is the pair of formulas:
∀xα(x)∧ ¬Aux(x)→γ(x)(17)
∀xα(x)∧β(x)→Aux(x)(18)
and Aux(x)is a fresh auxiliary predicate not included in L.ut
Lemma 3. Let xbe a variable that does not occur free in β. Then, the following
is a QHT-tautology:
(∃x α(x)→β)↔ ∀x(α(x)→β) (19)
ut
Theorem 5 (Main result). Let Πbe an ∃-logic program for language L. Then
Π≡L
sΠ∗.ut
Theorem 6. If Πis a disjunctive (resp. normal) ∃-logic program then Π∗is a
disjunctive (resp. normal) regular logic program. ut
The reason for making the definition of new auxiliary predicates depend on
the positive body of the original rule has to do with the following property, that
will guarantee a correct grounding of the program resulting from the translation.
Definition 6 (Restricted variable). A variable Xis said to be restricted in
a conjunction of literals βby a positive literal Ain βwhen Xoccurs in Aand
one of the following holds:
1. Ahas the form p(t);
2. Ahas the form X=Yor Y=Xand, in its turn, Yis restricted by a
different positive literal A0in β.
We just say that Xis restricted in βif it is restricted by some Ain β.ut
Definition 7 (Safe rule). A rule r:B→Hd is said to be safe when both:
a) Any free variable occurring in ralso occurs free and restricted in B.
b) For any condition ∃x ϕ in B,xoccurs free and restricted in ϕ.ut
For instance, rule (6) is safe: its only free variable xoccurs in the positive body
P erson(x). In fact, all the rules we used in the previous sections are safe. How-
ever, rules like:
¬¬Mark(x)→Mark(x)
∃y Q(y)→P(x)
∃x¬P(x)→A
are not safe. Notice that, for regular programs (i.e. those exclusively containing
literal conditions) only case a) of Definition 7 is applicable and, in fact, this
coincides with the usual concept of safe rule in ASP.
Theorem 7. If Πis safe then Π∗is safe. ut
6 Related work
As commented in the Introduction, this work is directly related to the recently
introduced language RASPL-1 [8]. In fact, that language is defined in terms
of a translation into first order sentences that fit into the syntax extension we
study here (existential quantifiers and double negations in the body). To put an
example (extracted from [8]), the RASPL-1 program:
{q(x)} ← p(x)⊥←{x:q(x)}1
that can be read “give the choice for q(x) per each p(x) but do not take just 0
or 1 atoms for q”, actually corresponds to the ∃-logic program:
p(x)∧ ¬¬q(x)→q(x)¬∃xy(q(x)∧q(y)∧x6=y)→ ⊥
In fact, it is always possible to represent an existential quantifier in the body
∃x α(x) using the RASPL-1 construct 1 {x:α(x)}provided that α(x) is some
literal. In this sense, one of the contributions of this paper is the possibility of
recursively nesting quantifiers or double negations inside them. Notice that this
is quite comfortable, for instance, in rules like (6) or (8). On the other hand, we
provide here a translation of these ∃-logic programs into regular logic programs
with new hidden auxiliary predicates, preserving strong equivalence modulo the
original language.
The use of ∃-logic programs was actually forwarded in [7] where an extension
of QEL for dealing with partial functions was introduced. The paper considered
a syntactic subclass of logic programs with partial functions, providing a trans-
lation that removed functions in favour of predicates with an extra parameter
(this transformation is usually called flattening). The result of this translation,
however, fell in the class of ∃-logic programs, dealing with negations in the head
(i.e. double negations in the body) and possibly nested existential quantifiers in
the body. The main result of the current paper was conjectured in [7].
A less related approach that has also considered the use of body quantifiers
is [15], although the semantics was only defined for stratified programs.
7 Conclusions
We have presented an extension of logic programming that allows dealing with
(possibly nested) existential quantifiers and double negations in the rule bodies.
We have shown how this new syntactic class captures several typical represen-
tation problems in ASP allowing a more compact and readable formulation and
avoiding the use of auxiliary predicates. In fact, we presented a translation that
reduces this new syntax to that of regular logic programs by automatically gen-
erating these auxiliary predicates, which are kept hidden to avoid programmer’s
errors.
Several open topics are left for future work. For instance, the direct use of
universal quantifiers is not so straightforward. To understand why, notice that
a rule like ∀x(P(x)→Q(x)) →His not strongly equivalent to ¬∃x(P(x)∧
¬Q(x)) →Hand its behaviour is related to nested implications, something that
in principle is not so clear (see the translation of a nested implication in [14]).
With the current formalism, we can just deal with a limited version of ∀since
¬∃x(P(x)∧ ¬Q(x)) is strongly equivalent to ¬¬∀x(P(x)→Q(x)). Another
interesting topic for future study is the use of existential quantifiers in the rule
heads.
References
1. Gelfond, M., Lifschitz, V.: The stable model semantics for logic programming. In:
Proc. of the 5th Intl. Conf. on Logic Programming. (1988) 1070–1080
2. Pearce, D., Valverde, A.: Towards a first order equilibrium logic for nonmonotonic
reasoning. In: Proc. of the 9th European Conf. on Logics in AI (JELIA’04). (2004)
147–160
3. Ferraris, P., Lee, J., Lifschitz, V.: A new perspective on stable models. In: Proc.
of the International Joint Conference on Artificial Intelligence (IJCAI’07). (2004)
372–379
4. Lifschitz, V., Pearce, D., Valverde, A.: A characterization of strong equivalence for
logic programs with variables. In: Proc. of the 9th Intl. Conf. on Logic Program-
ming and Nonmonotonic Reasoning (LPNMR’07). (2007) 188–200
5. Pearce, D., Valverde, A.: Quantified equilibrium logic and foundations for an-
swer set programming. In: Proc. of the 24th Intl. Conf. on Logic Programming
(ICLP’08). (2008) 547–560
6. Lee, J., Lifschitz, V., Palla, R.: Safe formulas in the general theory of stable models
(preliminary report). In: Proc. of the 24th Intl. Conf. on Logic Programming
(ICLP’08). (2008) 672–676
7. Cabalar, P.: Partial functions and equality in answer set programming. In: Proc.
of the 24th Intl. Conf. on Logic Programming (ICLP’08). (2008) 392–406
8. Lee, J., Lifschitz, V., Palla, R.: A reductive semantics for counting and choice
in answer set programming. In: Proc. of the 23rd AAAI Conference on Artificial
Intelligence. (2008) 472–479
9. Syrj¨anen, T.: Cardinality constraint programs. In: Proc. of the 9th European Conf.
on Logics in Artificial Intelligence (JELIA’04). (2004) 187–199
10. Lifschitz, V., Tang, L.R., Turner, H.: Nested expressions in logic programs. Ann.
Math. Artif. Intell. 25(3-4) (1999) 369–389
11. Inoue, K., Sakama, C.: Negation as failure in the head. J. Log. Program. 35(1)
(1998) 39–78
12. Janhunen, T.: On the effect of default negation on the expressiveness of disjunctive
rules. In: Proc. of the 6th Intl. Conf. on Logic Programming and Nonmonotonic
Reasoning. (2001) 93–106
13. Pearce, D., Valverde, A.: Quantified equilibrium logic and the first order logic of
here-and-there. Technical Report MA-06-02, University of M´alaga, Spain (2006)
14. Cabalar, P., Pearce, D., Valverde, A.: Reducing propositional theories in equilib-
rium logic to logic programs. In: 12th Portuguese Conference on Artificial Intelli-
gence (EPIA 2005). (2005) 4–17
15. Eiter, T., Gottlob, G., Veith, H.: Modular logic programming and generalized
quantifiers. In: Proc. of the 4th Intl. Conf. on Logic Programming and Nonmono-
tonic Reasoning (LPNMR’97). (1997) 290–309
Appendix. Proofs
Proof (Proposition 2). It is easy to see that, excepting for the first step, in
which the original rule ris considered, each time we introduce a new rule is
for univoquely defining an auxiliary predicate Aux(x) that corresponds to one
of the subexpressions of the form ¬∃xαor ¬¬αthat occurred in r. So, the
total number of rules is N+ 1. As for the body size of each rule, we always go
keeping a (usually strict) subset of the original number of atoms Aoccurring in
r, plus additional literals ¬Aux(x) corresponding to replaced conditions of the
form ¬∃xαor ¬¬α. As a result, we get the upper bound N+A.ut
Proof (Lemma 1). Obviously, M |=Γ∪ {α}. There cannot be a smaller model
M0≺ M for Γ∪ {α}, because it would also be a model of Γand this would
contradict minimality of Mfor Γ.ut
Proof (Theorem 1). It is easy to check that, given any tuple dof domain elements
and any model M=h(D, σ), H, T i,M |= (11) implies that:
1. M |=α(d) iff M |=β(d)
2. MT|=α(d) iff MT|=β(d)
Looking at the satisfaction of formulas, this means that for any model of (11),
α(t) and β(t) for any tuple of terms tare semantically equivalent and can be
interchanged. ut
Proof (Theorem 2). Let Γdenote an arbitrary theory for Land take Man
equilibrium model of Γ∪Γ1and signature L. We will show that there exists
an equilibrium model M0of Γ∪Γ2such that M0|L=M. It is clear we can
take M0equal to Mfor all predicates in Land fix the extent of Aux such
that M0|=Aux(d) iff M |=α(d) for any tuple of elements d. Obviously, by
construction, M0|=Γ∪Γ2. It must also be minimal, since any M00 ≺ M0that
M00 |=Γ∪Γ2is also a model of Γ∪Γ1and this would contradict the minimality
of Mfor that theory.
For the other direction, take some M0=h(D, σ), T 0iequilibrium model of
Γ∪Γ2. Clearly, M0|=Γ∪Γ1and, since this theory does not contain Aux,
its projection M0|L=M=h(D, σ), T imust also be a model for Γ∪Γ1. Take
another model of this theory, M2=h(D, σ), H, T iwith H⊂T, that is M2≺ M.
But then, we can construct M0
2=h(D, σ), H 0, T 0isuch that H0consists of Hand
the set of atoms Aux(d) for which M2|=α(d). Notice that H0must be a subset
of T0because M2|=α(d) implies M |=α(d) and this implies M0|=α(d),
that together with M0|= (12) implies and M0|=Aux(d). But as H⊂Twe
get H0⊂T0and so M0
2≺ M0. On the other hand, by construction of M0
2
together with M0|= (12), we obtain M0
2|= (12). In this way, M0
2|=Γ∪Γ2
while M0
2≺ M0reaching a contradiction with minimality of M0for this theory.
ut
Proof (Lemma 2). Note first that, for any tuple d6∈ D,M1and M2coincide
both for Aux(d), α(d) and β(d). Then M1|= (13) and M1|= (14) allow us
to conclude M2|=α(d)→Aux(d) and M2|=¬Aux(d)→β(d), respectively.
We remain to prove that the same holds for tuples d∈ D. Consider MT=
h(D, σ), T i, that is, the total model above M1and M2. For any d∈ D, we
have M1|=Aux(d) and thus MT|=Aux(d), but then M26|=¬Aux(d). On
the other hand, M1|= (14) also implies MT|= (14) and, in particular, MT|=
¬Aux(d)→β(d). The latter, together with M26|=¬Aux(d), implies M2|=
¬Aux(d)→β(d), for any d∈ D.
Similarly, M1|= (13) implies MT|= (13) and, in particular, MT|=α(d)→
Aux(d) for d∈ D. On the other hand, as M1and M2do not differ for α(d),
we conclude M26|=α(d), and thus, M2|=α(d)→Aux(d). ut
Proof (Theorem 3). Let Γdenote an arbitrary theory for Land take M=
h(D, σ), T ian equilibrium model of Γ∪Γ1. For proving that Mis equilibrium
model of Γ∪Γ2, by Lemma 1, it suffices to show that M |= (15). Assume this
does not hold. As Mis a total model, this just means that for some tuple of
domain elements d,M |=Aux(d) and M 6|=α(d). Let us take now a model
M0=h(D, σ), H, T iwhere His equal to Texcepting that the extension of Aux
does not include the tuple d. Notice that H⊂Tand M0≺ M. In fact, we can
observe that Lemma 2 is applicable taking M1=M,M2=M0and D={d}to
conclude M0|= (13) ∪(14), i.e., M0|=Γ1. Furthermore, as M0only differs from
Min Aux,M0|=Γ. But this contradicts the minimality of Mas equilibrium
model of Γ∪Γ1.
For the other direction, let Mbe an equilibrium model of Γ∪Γ2. Since
Γ1⊂Γ2, obviously M |=Γ∪Γ1. We remain to prove that Mis minimal. Suppose
we had some other model M0≺ M of Γ∪Γ1. If M0|= (15) we would have
M0|=Γ∪Γ2and this would contradict the minimality of Mfor that theory. So,
assume M06|= (15). Let Dbe the set of tuples dfor which M06|=Aux(d)→α(d)
(note that this set cannot be empty). As M |= (15) we must have M0|=Aux(d)
and M06|=α(d) for all d∈ D. Now take M00 equal to M0excepting that, for all
d∈ D,M00 6|=Aux(d). We can apply Lemma 2 taking M1=M0,M2=M00
and Dto conclude M00 |= (13) ∪(14), i.e., M00 |=Γ1. Furthermore, as M00
only differs from M0in the extent of Aux, we obtain M00 |=Γ∪Γ1. Now, as
M00 6|=Aux(d) and we have M |= (15) we conclude M00 |=Aux(d)→α(d). For
tuples c6∈ D we had M0|=Aux(c)→α(c) by definition of D, but M0and M00
coincide in Aux(c) and α(c). As a result, M00 |= (15) too, and since M00 ≺ M
we obtain a contradiction with minimality of Mfor Γ∪Γ2.ut
Proof (Theorem 4). By (9), the formula (17) is strongly equivalent to:
∀x¬Aux(x)→(α(x)→γ(x)) (20)
so that, we can apply Theorem 3 on Γ2to transform the implication in (18) into
a double implication:
∀xα(x)∧β(x)↔Aux(x)(21)
As a result, Γ2is strongly equivalent (modulo L) to the theory consisting of (17)
and (21). By Theorem 1, this is strongly equivalent, in its turn, to (21) plus:
∀xα(x)∧ ¬(α(x)∧β(x)) →γ(x)(22)
Due to (10), the latter is strongly equivalent to (16). Finally, by Theorem 2, we
can remove (21), since it is a definition for predicate Aux which does not belong
to L.ut
Proof (Lemma 3). As (19) is a classical tautology, we remain to prove that,
for any interpretation M=h(D, σ), H, T i,M |=∃x α(x)→βiff M |=
∀x(α(x)→β). For the left to right direction, assume M |=∃x α(x)→βbut
M 6|=∀x(α(x)→β). The latter means there exists some element dfor which
M 6|=α(d)→β. Since M |=∃x α(x)→βwe have that MTalso satisfies that
formula and so MT|=∀x(α(x)→β) since it is a classically equivalent formula.
Therefore, the only possibility is M |=α(d) and M 6|=β. But from the former
we get M |=∃x α(x) and this contradicts M |=∃x α(x)→β.
For the right to left direction, suppose M |=∀x(α(x)→β). As MTalso satis-
fies that formula it must also satisfy the classically equivalent formula ∃x α(x)→
β. We remain to prove that M |=∃x α(x) implies M |=β. Assume that the
former holds. Then, for some element d,M |=α(d). As M |=∀x(α(x)→β), in
particular, M |=α(d)→β, but this together with M |=α(d) implies M |=β.
ut
Proof (Theorem 5. Main result). We prove the result by induction on the suc-
cessive application of ·∗in each group of newly generated rules. If a rule ris
regular it can be easily checked that r∗=rand the result of strong equivalence
is straightforward. If rcontains a double negation or an existential quantifier,
we will show that the two steps in Definition 5 preserve strong equivalence. Step
i) is the result of the successive application of Lemma 3, that allows us to re-
move a positive existential quantifier in the body, provided that the quantified
variable does not occur free in the rest of the formula. Notice that this lemma
can be applied to a larger body like ∃x α(x)∧γ→β(again, with xnot free
in γ) because the latter is QHT-equivalent to ∃x α(x)→(γ→β). For Step ii),
consider any rule r:B→Hd with some non-literal negative condition ¬β1(x).
We can write ras B+(x)∧ ¬β1(x)∧B0(x)→Hd(x), being B0(x) the rest of
conjuncts in the negative body, that is, B−(x) excepting ¬β1(x). This expression
can be equivalently written as B+(x)∧ ¬β1(x)→(B0(x)→Hd(x)) and so, we
can apply Theorem 4 taking α(x) to be the positive body B+(x), and γ(x) the
implication B0(x)→Hd(x) to conclude that ris strongly equivalent (modulo its
original language L) to the conjunction of B+(x)∧ ¬Aux1(x)∧B0(x)→Hd(x)
plus B+(x)∧β1(x)→Aux1(x) being Aux1a new fresh predicate. We can repeat
this step for the rest of non-literal negative conditions in B−until the original
rule becomes B+(x)∧ ¬Aux1(x)∧ · · · ∧ ¬Auxn(x)∧B00(x)→Hd(x), i.e., what
we called B+∧(B−)•→Hd in Definition 5. Finally, the correctness of the
translation of the newly generated rules B+(x)∧βi(x)→Auxi(x) follows from
the induction hypothesis. Note that termination of this inductive transformation
·∗is guaranteed by observing that in each step, we reduce the size of new rule
bodies, replacing negative non-literal conditions by smaller expressions. ut
Proof (Theorem 6). First, observe that all the rules generated in the transla-
tion either repeat one of the original rule heads in Πor just contain one atom
Aux(x). Thus, if the original program was disjunctive (resp. normal) then Π∗
will be disjunctive (resp. normal). Second, just notice that the translation is re-
cursively repeated until rule bodies exclusively contain literal conditions, so the
final program will be a regular logic program in the usual sense. ut
Proof (Theorem 7). It suffices to observe that the rules generated in each trans-
lation step preserves safety with respect to Definition 7. Assume we start from
a safe rule and obtain its translation following the steps in Definition 5. In Step
i) of that definition, each time we remove ∃xϕ and replace it by ϕ[x/y] we are
introducing a new free variable yin the rule that must satisfy condition a) in
Definition 7 to maintain safety. But this is guaranteed because the original rule
was safe and so, xoccurred free and outside the scope of negation in ϕ. There-
fore, ywill occur free and outside the scope of negation in ϕ[x/y], which is part
of the resulting rule body. This means that the resulting rule satisfies a) in Def-
inition 7 for variable ywhile the status of the rest of variables in the rule has
not changed.
Now, take the rule r:B→Hd that results from iterating Step i) which,
as we have seen, preserves safety. Notice that rdoes not contain quantified
expressions outside the scope of negation, so that B+is just a conjunction of
atoms. It can be easily observed that each rule r0:B+∧(B−)•→Hd does
not introduce new free variables with respect to B→Hd (it just replaced any
negative condition like ¬α(x) in B−by a new atom ¬Aux(x)) while it maintains
the original positive body B+. So, as the original rule rwas safe, all free variables
in r0also satisfy condition a) in Definition 7, while b) is not applicable because
r0is regular (its body exclusively consists of literals). Similarly, rules like r00 :
B+∧α(x)→Aux(x) in Π(B−, B+) do not introduce new free variables with
respect to reither, while they maintain the same positive body B+, so they will
satisfy a) in Definition 7. On the other hand, any quantified condition like ∃y ϕ
that occurs in α(x) also occurred in a condition ¬α(x) in r. As rwas safe, ∃y ϕ
will satisfy b) in Definition 7, so that rule r00 is safe too. ut