=Paper=
{{Paper
|id=Vol-533/paper-1
|storemode=property
|title=Stable versus Layered Logic Program Semantics
|pdfUrl=https://ceur-ws.org/Vol-533/02_LANMR09_invited_paper.pdf
|volume=Vol-533
|dblpUrl=https://dblp.org/rec/conf/lanmr/PereiraP09
}}
==Stable versus Layered Logic Program Semantics==
Stable versus Layered Logic Program Semantics
Luís Moniz Pereira and Alexandre Miguel Pinto
{lmp|amp}@di.fct.unl.pt
Centro de Inteligência Artificial (CENTRIA)
Universidade Nova de Lisboa, 2829-516 Caparica, Portugal
Abstract. For practical applications, the use of top-down query-driven proof-
procedures is convenient for an efficient use and computation of answers using
Logic Programs as knowledge bases. Additionally, abductive reasoning on de-
mand is intrinsically a top-down search method. A 2-valued semantics for Nor-
mal Logic Programs (NLPs) allowing for top-down query-solving is thus highly
desirable, but the Stable Models semantics (SM) does not allow it, for lack of the
relevance property. To overcome this limitation we introduced in [24], and review
here, a new 2-valued semantics for NLPs — the Layer Supported Models seman-
tics — which conservatively extends the SM semantics, enjoys relevance and
cumulativity, guarantees model existence, and respects the Well-Founded Model.
In this paper we also exhibit a transformation, TR, from one propositional NLP
into another, whose Layer Supported Models are precisely the Stable Models of
the transform, which can then be computed by extant Stable Model implemen-
tations, providing a tool for the immediate generalized use of the new semantics
and its applications.
In the context of abduction in Logic Programs, when finding an abductive solu-
tion for a query, one may want to check too whether some other literals become
true (or false) as a consequence, strictly within the abductive solution found, that
is without performing additional abductions, and without having to produce a
complete model to do so. That is, such consequence literals may consume, but
not produce, the abduced literals of the solution. To accomplish this mechanism,
we present the concept of Inspection Point in Abductive Logic Programs, and
show, by means of examples, how one can employ it to investigate side-effects of
interest (the inspection points) in order to help choose among abductive solutions.
Keywords: Stable Models, Layer Supported Models, Relevance, Layering, Ab-
duction, Side-effects, Program Transformation.
1 Introduction and Motivation
The semantics of Stable Models (SM) [14] is a cornerstone for the definition of some of
the most important results in logic programming of the past two decades, providing an
increase in logic programming declarativity and a new paradigm for program evalua-
tion. When we need to know the 2-valued truth value of all the literals in a logic program
for the problem we are modeling and solving, the only solution is to produce complete
models. Depending on the intended semantics, in such cases, tools like SModels [19] or
DLV [7] may be adequate because they can indeed compute whole models according to
the SM semantics. However, the lack of some important properties of language seman-
tics, like relevance, cumulativity and guarantee of model existence (enjoyed by, say,
Well-Founded Semantics [13] (WFS)), somewhat reduces its applicability in practice,
3
namely regarding abduction, creating difficulties in required pre- and post-processing.
But WFS in turn does not produce 2-valued models, though these are often desired, nor
guarantees 2-valued model existence.
SM semantics does not allow for top-down query-solving precisely because it does
not enjoy the relevance property — and moreover, does not guarantee the existence
of a model. Furthermore, frequently there is no need to compute whole models, like
its implementations do, but just the partial models that sustain the answer to a query.
Relevance would ensure these could be extended to whole models.
Furthermore, with SM semantics, in an abductive reasoning situation, computing
the whole model entails pronouncement about every abducible whether or not it is rel-
evant to the problem at hand, and subsequently filtering the irrelevant ones. When we
just want to find an existential answer to a query, we either compute a whole model
and check if it entails the query (the way SM semantics does), or, if the underlying
semantics we use enjoys the relevance property — which SM semantics do not — we
can simply use a top-down proof-procedure (à la Prolog), and abduce by need. In this
second case, the user does not pay the price of computing a whole model, nor the price
of abducing all possible abducibles or their negations, and then filtering irrelevant ones,
because the only abducibles considered will be those needed to answer the query.
To overcome these limitations we developed in [24] (reviewed here) a new 2-valued
semantics for NLPs — the Layer Supported Models (LSM) — which conservatively
extends the SMs, enjoys relevance and cumulativity, guarantees model existence, and
respects the Well-Founded Model (WFM) [13]. We say a semantics is a conservative
extension of another one if it gives the same semantics to programs as the latter, when-
ever the latter is defined, and also provides semantics to programs for which the latter
does not.
The LSM semantics builds upon the foundational step of the Layered Models se-
mantics presented in [27] by imposing a layered support requirement resulting in WFM
consonance. In [27], neither layered support nor WFM respect are required. Intuitively,
a program is conceptually partitioned into “layers” which are subsets of its rules, pos-
sibly involved in mutual loops. An atom is considered true if there is some rule for it
at some layer, where all the literals in its body which are supported by rules of lower
layers are also true. Otherwise that conclusion is false. That is, a rule in a layer must, to
be usable, have the support of rules in the layers below.
Although Stable Models is a great semantics with a simple definition, it nevertheless
fails to provide semantics for all normal programs. LSM coincides with Stable Models
whenever the latter is defined (no odd loops ou infinite chains), — [12] — and thus
can afford the same simple definition in that class of programs. The definition for the
class of all programs necessarily requires a more complex definition, essentially resting
on a required generalization of stratification — the layering — and then simply using
minimal models on successive layers.
The core reason SM semantics fails to guarantee model existence for every NLP is
that the stability condition it imposes on models is impossible to be complied with by
Odd Loops Over Negation (OLONs). An OLON is a loop with an odd number of default
negations in its circular call dependency path. In fact, the SM semantics community uses
4
that inability as a means to impose Integrity Constraints (ICs), such as a ← not a, X,
where the OLON over a prevents X from being true in any model.
The LSM semantics provides a semantics to all NLPs. In the a ← not a, X example
above, whenever X is true, the only LSM is {a, X}. For LSM semantics OLONs are not
ICs. ICs are implemented with rules for reserved atom f alsum, of the form f alsum ←
X, where X is the body of the IC we wish to prevent being true. This does not prevent
f alsum from being in some models. From a theoretical standpoint this means that the
LSM semantics does not include an IC compliance enforcement mechanism. ICs must
be dealt with in two possible ways: either by 1) a syntactic post-processing step, as a
“test phase” after the model generation “generate phase”; or by 2) embedding the IC
compliance in a query-driven (partial) model computation, where such method can be a
top-down query-solving one a la Prolog, since the LSM semantics enjoys relevance. In
this second case, the user must conjoin query goals with not f alsum. If inconsistency
examination is desired, like in the 1) case above, models including f alsum can be
discarded a posteriori. This is how LSM semantics separates OLON semantics from IC
compliance.
After notation and background definitions, we summarize the formal definition of
LSM semantics and its properties. Thereafter, in a section that may be skipped without
loss of continuity, we present a program transformation, TR, from one propositional
(or ground) NLP into another, whose Layer Supported Models are precisely the Stable
Models of the transform, which can be computed by extant Stable Model implementa-
tions, which also require grounding of programs. TR’s space and time complexities are
then examined. TR can be used to answer queries but is also of theoretical interest, for
it may be used to prove properties of programs, say. Moreover, TR can be employed in
combination with the top-down query procedure of XSB-Prolog, and be applied just to
the residual program corresponding to a query (in compliance with the relevance prop-
erty of Layer Supported Models). The XSB-XASP interface then allows the program
transform to be sent for Smodels for 2-valued evaluation. Thus, for existential query an-
swering there is no need to compute total models, but just the partial models that sustain
the answer to the query, or one might simply know a model exists without producing it;
relevance ensures these can be extended to total models.
In its specific implementation section we indicate how TR can be employed, in
combination with the top-down query procedure of XSB-Prolog, it being sufficient to
apply it solely to the residual program corresponding to a query (in compliance with
the relevance property of Layer Supported Model ). The XSB-XASP interface allows
the program transform to be sent for Smodels for 2-valued evaluation. Implementation
details and attending algorithms can be found in [25].
Next, issues of reasoning with logic programs are addressed in section 7 where,
in particular, we look at abductive reasoning and the nature of backward and forward
chaining in their relationship to the issues of query answering and of side-effects exam-
ination within an abductive framework. In section 8 we then introduce inspection points
to address such issues, illustrate their need and use with examples, and provide for them
a declarative semantics. The touchstone of enabling inspection points can be construed
as meta-abduction, by (meta-)abducing an “abduction" to check (i.e. to passively verify)
that a certain concrete abduction is indeed adopted in a purported abductive solution. In
5
section 8.2 we surmise their implementation, the latter’s workings being fully given and
exemplified in [23]. We have implemented inspection points on top of already existing
3- and 2-valued abduction solving systems — ABDUAL and XSB-XASP — in a way
that can be adopted by other systems too.
Our semantics can easily be extended to deal with Disjunctive Logic Programs (Dis-
jLPs) and Extended Logic Programs (ELPs, including explicit negation), by means of
the shifting rule and other well-known program transformations [1, 10, 15], thus provid-
ing a practical, comprehensive and advantageous alternative to SMs-based Answer-Set
Programming. Conclusions and future work close the paper.
2 Background Notation and Definitions
Definition 1. Logic Rule. A Logic Rule r has the general form
H ← B1 , . . . , Bn , not C1 , . . . , not Cm where H, the Bi and the Cj are atoms.
We call H the head of the rule — also denoted by head(r). And body(r) denotes the set
{B1 , . . . , Bn , not C1 , . . . , not Cm } of all the literals in the body of r. Throughout this
paper we will use ‘not ’ to denote default negation. When the body of the rule is empty,
we say the head of rule is a fact and we write the rule just as H. A Logic Program (LP
for short) P is a (possibly infinite) set of ground Logic Rules of the form in Definition 1.
In this paper we focus mainly on NLPs, those whose heads of rules are positive literals,
i.e., simple atoms; and there is default negation just in the bodies of the rules. Hence,
when we write simply “program” or “logic program” we mean an NLP.
3 Layering of Logic Programs
The well-known notion of stratification of LPs has been studied and used for decades
now. But the common notion of stratification does not cover all LPs, i.e., there are some
LPs which are non-stratified. The usual syntactic notions of dependency are mainly fo-
cused on atoms. They are based on a dependency graph induced by the rules of the
program. Useful these notions might be, for our purposes they are insufficient as they
leave out important structural information about the call-graph of P . To cover that in-
formation we also define below the notion of a rule’s dependency. Indeed, layering puts
rules in layers, not atoms. An atom B directly depends on atom A in P iff there is at
least one rule with head B and with A or not A in the body. An atom’s dependency is
just the transitive closure of the atom’s direct dependency. A rule directly depends on
atom B iff any of B or not B is in its body. A rule’s dependency is just the transitive
closure of the rule’s direct dependency. The Relevant part of P for some atom A, rep-
resented by RelP (A), is the subset of rules of P with head A plus the set of rules of P
whose heads the atom A depends on, cf. [9]. Likewise for the relevant part for an atom
A notion [9], we define and present the notion of relevant part for a rule r. The Relevant
part of P for rule r, represented by RelP (r), is the set containing the rule r itself plus
the set of rules relevant for each atom r depends on.
Definition 2. Parts of the body of a rule. Let r = H ← B1 , . . . , Bn , not C1 , . . . , not Cm
be a rule of P . Then, rl = {Bi , not Cj : Bi depends on H ∧ Cj depends on H}. Also,
rB = {Bi : Bi ∈ (body(r) \ rl )}, and rC = {Cj : not Cj ∈ (body(r) \ rl )}.
6
Definition 3. HighLayer function. The HighLayer function is defined over a set of
literals: its result is the highest layer number of all the rules for all the literals in the
set, or zero if the set is empty.
Definition 4. Layering of a Logic Program P . Given a logic program P a layering
function L/1 is just any function defined over the rules of P 0 , where P 0 is obtained from
P by adding a rule of the form H ← f alsum for every atom H with no rules in P ,
assigning each rule r ∈ P 0 a positive integer, such that:
– L(r) = 0 if f alsum ∈ body(r), otherwise
– L(r) ≥ max(HighLayer(rl ), HighLayer(rB ), (HighLayer(rC ) + 1))
A layering of program P is a partition P 1 , . . . , P n of P such that P i contains all rules
r having L(r) = i, i.e., those which depend only on the rules in the same layer or layers
below it.
This notion of layering does not correspond to any level-mapping [16], since the later is
defined over atoms, and the former is defined over rules. Also, due to the definition of
dependency, layering does not coincide with stratification [3], nor does it coincide with
the layer definition of [28]. However, when the program at hand is stratified (according
to [3]) it can easily be seen that its respective layering coincides with its stratification.
In this sense, layering, which is always defined, is a generalization of the stratification.
Amongst the several possible layerings of a program P we can always find the least
one, i.e., the layering with least number of layers and where the integers of the layers
are smallest. In the remainder of the paper when referring to the program’s layering we
mean such least layering (easily seen to be unique).
Example 1. Layering example. Consider the following program P , depicted along
with the layer numbers for its least layering:
c ← not d, not y, not a Layer 3
d ← not c
y ← not x b ← not x Layer 2
x ← not x b Layer 1
a ← f alsum Layer 0
Atom a has no rules so its now created unique rule a ← f alsum is placed in Layer
0. Atom b has a fact rule rb1 : its body is empty, and therefore all HighLayer(rbl 1 ),
HighLayer(rbB1 ), and HighLayer(rbC1 ) are 0 (zero). Hence, L(rb1 ) = max(0, 0, (0 +
1)) = max(0, 0, 1) = 1, where rb1 is the fact rule for b, placed in Layer 1.
The unique rule for x, rx is also placed in Layer 1 in the least layering of P because
HighLayer(rxl ) = L(rx ), HighLayer(rxB ) = 0, and HighLayer(rxC ) = 0. So,
L(rx ) = max(L(rx ), 0, (0 + 1)) = max(L(rx ), 0, 1) = 1, in the least layering.
The unique rule for c, rc is placed in Layer 3 because HighLayer(rcC ) = 2,
HighLayer(rcB ) = 0, and HighLayer(rcl ) = HighLayer(rd ) = 3. By the same
token, rd is placed in the same Layer 3. Both rb2 and ry are placed in Layer 2.
This program has two LSMs: {b, c, x}, and {b, d, x}.
7
The complexity of computing the Layering of a given ground NLP is conjectured
to be in the same order as that of the Tarjan’s Strongly Connected Components detec-
tion Algorithm, which is known to be linear in the number of nodes and edges on the
dependency graph: O(|N | + |E|).
4 Layer Supported Models Semantics
The Layer Supported Models semantics we now present is the result of the two new
notions we introduced: the layering, formally introduced in section 3, which is a gen-
eralization of stratification; and the layered support, as a generalization of classical
support. These two notions are the means to provide the desired 2-valued semantics
which respects the WFM, as we will see below.
An interpretation M of P is classically supported iff every atom a of M is classi-
cally supported in M , i.e., all the literals in the body of some rule for a are true under
M in order for a to be supported under M .
Definition 5. Layer Supported interpretation. An interpretation M of P is layer sup-
ported iff every atom a of M is layer supported in M , and this holds iff a has a rule r
where all literals in (body(r) \ rl ) are true in M . Otherwise, it follows that a is false.
Theorem 1. Classical Support implies Layered Support. Given an NLP P , an inter-
pretation M , and an atom a such that a ∈ M , if a is classically supported in M then a
is also layer supported in M .
Proof. Trivial from the definitions of classical support and layered support. t
u
In programs without odd loops layered supported models are classically supported too.
Example 2. Layered Unsupported Loop. Consider program P :
c ← not a a ← c, not b b
The only rule for b is in the first layer of P . Since it is a fact it is always true in
the WFM. Knowing this, the body of the rule for a is false because unsupported (both
classically and layered). Since it is the only rule for a, its truth value is false in the WFM,
and, consequently, c is true in the WFM. This is the intuitively desirable semantics for
P , which corresponds to its LSM semantics. LM and the LSM semantics differences
reside both in their layering notion and the layered support requisite of Def. 5. In this
example, if we used LM semantics, which does not exact layered support, there would
be two models: LM1 = {b, a} and LM2 = {b, c}. {b} is the only minimal model for
the first layer and there are two minimal model extensions for the second layer, as a is
not necessarily false in the LM semantics because Def. 5 is not adopted. Lack of layered
support lets LM semantics fail to comply with the WFM. Note that adding a rule like
b ← a would not affect the semantics of the program, according to LSM. This is so
because, such rule would be placed in the same layer with the rules for a and c, but
leaving the fact rule b in the strictly lower layer.
Intuitively, the minimal layer supported models up to and including a given layer,
respect the minimal layer supported models up to the layers preceding it. It follows triv-
ially that layer supported models are minimal models, by definition. This ensures the
8
truth assignment to atoms in loops in higher layers is consistent with the truth assign-
ments in loops in lower layers and that these take precedence in their truth labeling. As
a consequence of the layered support requirement, layer supported models of each layer
comply with the WFM of the layers equal to or below it. Combination of the (merely
syntactic) notion of layering and the (semantic) notion of layered support makes the
LSM semantics.
Definition 6. Layer Supported Model of P . Let P 1 , . . . , P n be the least layering of
P . A layer supported interpretation M is a Layer Supported Model of P iff
∀1≤i≤n M |≤i is a minimal layer supported model of ∪1≤j≤i P j
where M |≤i denotes the restriction of M to heads of rules in layers less or equal to i:
M |≤i ⊆ M ∩ {head(r) : L(r) ≤ i}
The Layer Supported semantics of a program is just the intersection of all of its
Layer Supported Models.
Example 3. Layer Supported Models semantics. Consider again the program from
example 1. Its LS models are {b, c, x}, and {b, d, x}. According to LSM semantics b
and x are true because they are in the intersection of all models. c and d are undefined,
and a and y are false.
Layered support is a more general notion than that of perfect models [30], with sim-
ilar structure. Perfect model semantics talks about “least models” rather than “minimal
models” because in strata there can be no loops and so there is always a unique least
model which is also the minimal one. Layers, as opposed to strata, may contain loops
and thus there is not always a least model, so layers resort to minimal models, and these
are guaranteed to exist (it is well known every NLP has minimal models).
The simple transformation step adding a rule of the form a ← f alsum for atoms a
with no rules in P enforces compliance with the Closed World Assumption (CWA).
The principle used by LSMs to provide semantics to any NLP — whether with
OLONs or not — is to accept all, and only, the minimal models that are layer supported,
i.e., that respect the layers of the program. The principle used by SMs to provide se-
mantics to only some NLPs is a “stability” (fixed-point) condition imposed on the SMs
by the Gelfond-Lifschitz operator.
In [27] the authors present an example (7) where three alternative joint vacation so-
lutions are found by the LM semantics, for a vacation problem modeled by an OLON.
The solutions found actually coincide with those found by the LSM semantics. We
recall now a syntactically similar example (from [29]) but with different intended se-
mantics, and show how it can be attained in LSM by means of ICs.
Example 4. Working example [29].
tired ← not sleep sleep ← not work work ← not tired
As in the example 7 of [27], the LSM semantics would provide three solutions for
the above program: {work, tired}, {work, sleep}, {sleep, tired}. Although some (or
even all!) of these solutions might be actually plausible in a real world case, they are not,
in general, the intended semantics for this example. With the LSM semantics, the way to
prune away some (or all) of these solutions is by means of ICs. For example, to eliminate
9
the {work, sleep} solution we would just need to add the IC f alsum ← work, sleep.
Again, an IC compliance mechanism, such as conjoining not f alsum to the query,
must be employed by the user in order to eliminate the undesired models.
Example 5. Jurisprudential reasoning. A murder suspect not preventively detained
is likely to destroy evidence, and in that case the suspect shall be preventively detained:
likely_destroy_evidence(murder_suspect) ←
not preventively_detain(murder_suspect)
preventively_detain(murder_suspect) ←
likely_destroy_evidence(murder_suspect)
There is no SM, and a single LSM = {preventively_detain(murder_suspect)}.
This jurisprudential reasoning is carried out without need for a murder_suspect to
exist now. Should we wish, LSM’s cumulativity (cf. below) allows adding the model
literal as a fact.
Example 6. Program with depth-unbound layering. A typical case of an infinitely
ground program (actually the only one with real theoretical interest, to the best of our
knowledge) was presented by François Fages in [12]. We repeat it here for illustration
and explanation.
p(X) ← p(s(X)) p(X) ← not p(s(X))
Ground (layered) version of this program, assuming there only one constant 0 (zero):
p(0) ← p(s(0)) p(0) ← not p(s(0))
p(s(0)) ← p(s(s(0))) p(s(0)) ← not p(s(s(0)))
p(s(s(0))) ← p(s(s(s(0)))) p(s(s(0))) ← not p(s(s(s(0))))
.. . .. .
. ← .. . ← ..
The only layer supported model of this program is {p(0), p(s(0)), p(s(s(0))) . . .}
or, in a non-ground form, {p(X)}. The theoretical interest of this program lies in that,
although it has no OLONs it still has no SMs either because no rule is supported (under
the usual notion of support), thereby showing there is a whole other class of NLPs to
which the SMs semantics provides no model, due to the notion of support used.
5 Properties of the Layer Supported Models semantics
Although the definition of the LSMs semantics is different from the LMs of [27], this
new refinement enjoys the desirable properties of the LMs semantics, namely: guaran-
tee of model existence, relevance, cumulativity, ([9]) and being a conservative extension
of the SMs semantics. Guarantee of existence ensures all normal programs have a se-
mantics; relevance allows for simple top-down querying concerning truth in a model
(like in Prolog) and is essential for abduction by need; and cumulativity means that
atoms true in the semantics can be added as facts without changing it — none of these
properties are enjoyed by Stable Models. A semantics is a conservative extension of
10
another one if it gives the same semantics to programs as the latter, whenever the latter
is defined, and also provides semantics to programs for which the latter does not, that is
the models of the semantics being extended are kept.
Moreover, and this is the main contribution of the LSMs semantics, it respects the
Well-Founded Model. It is not hard to recognize that the LM semantics [27] is the con-
servative generalization LSM semantics one obtains by removing the layered support
condition on interpretations prescribed in Definition 6.
The complexity analysis of this semantics is left out of this paper. Nonetheless, a
brief note is due. Model existence is guaranteed for every NLP, hence the complexity of
finding if one LSM exists is trivial, when compared to SMs semantics. Brave reasoning
— finding if there is any model of the program where some atom a is true — is an
intrinsically NP-hard task from the computational complexity point of view. But since
LSM semantics enjoys relevance, the computational scope of this task can be reduced
to consider only RelP (a), instead of the whole P . From a practical standpoint, this
can have a significant impact in the performance of concrete applications. Cautious
reasoning (finding out if some atom a is in all models) in the LSM semantics should
have the same computational complexity as in the SMs, i.e., coNP-complete.
5.1 Respect for the Well-Founded Model
Definition 7. Interpretation M of P respects the WFM of P . An interpretation M
respects the WFM of P iff M contains the set of all the true atoms of the WFM of P ,
and it contains no false atoms of the WFM of P .
Theorem S 2. Layer Supported Models respect the WFM. Let P be an NLP, and P ≤i
denote 1≤j≤i P , where P j is P ’s j layer. Each LSM M |≤i of P ≤i , where M ⊇
j
M |≤i , respects the WFM of P i ∪ M |