Stable Models: Vladimir Lifschitz, University of Texas
Stable Models: Vladimir Lifschitz, University of Texas
1 Propositional Formulas
Assume that we are given a set σ of symbols called atomic propositions. Formulas
over σ are built from atomic propositions and the logical constants ⊥ (falsity)
and > (truth) using the connectives ¬ (negation), ∧ (conjunction), ∨ (disjunction),
and ← (implication). Note that implications are written here “backwards”: q ← p
(“q if p”) instead of p → q (“if p then q”). Implication binds weaker than the other
connectives; for instance,
p←q∧r (1)
is understood as shorthand for the formula p ← (q ∧ r).
If one of the truth values false, true is assigned to each atomic proposition
then the truth values of other formulas are defined as follows. The truth value
of ⊥ is false; the truth value of > is true. For propositional connectives, we use
the following truth tables:
F ¬F
false true
true false
F G F ∧G F ∨G F ←G
false false false false true
false true false true false
true false false true true
true true true true true
1
gets the value true for an interpretation I then we say that I satisfies F , or that I
is a model of F . For instance, the empty set ∅ satisfies formula (1), because that
formula gets the value true when all atomic propositions p, q, r get the value false.
Exercise S.1.1. Assuming that σ = {p, q, r}, find all interpretations that do not
satisfy formula (1).
Exercise S.1.2. Find a formula that is satisfied by {p} and by {q} but is not
satisfied by {p, q}.
We say that an interpretation I is a model of a set Γ of formulas if I satisfies
all formulas in Γ.
Exercise S.1.3. Assuming that σ = {p, q, r}, find all models of the set
{p ← q ∧ r, q ← p, r ← p}.
Exercise S.1.4. Assuming that σ = {p, q, r, s}, find all models of the set
{p ← q, q ← r, r ← s, s ← p}.
(b) p1 ← p2 .
Exercise S.1.6. Assuming that σ is the infinite set {p0 , p1 , p2 , . . . }, find all models
of the infinite sets
(a) {p1 , ¬p2 , p3 , ¬p4 , . . . },
2
2 Equivalence
Two formulas or sets of formulas are equivalent to each other if they have the
same models. For instance, the set {p, q ← p} is equivalent to the formula p ∧ q.
When two formulas or sets of formulas are not equivalent, this fact can be
demonstrated by a counterexample—an interpretation that satisfies one of them
but not the other. For instance, the formula p ∧ q ∧ r is not equivalent to p ∧ q
because the interpretation {p, q} satisfies the former but not the latter.
Exercise S.2.1. Determine whether the given formulas or sets of formulas are
equivalent. If they are not, give a counterexample.
(a) {p ← q, q ← r} and p ← r.
(b) p ← ¬q.
(c) p ∧ ¬p.
(d) p ∨ q ← r ∧ >.
(e) p ∨ q ← r ∧ ⊥.
(b) p ← q ∧ r ∧ ¬q.
3
A formula is satisfiable if it is satisfied by at least one interpretation, and
unsatisfiable otherwise. In other words, an unsatisfiable formula is a formula
equivalent to ⊥. About a set Γ of formulas we say that it is satisfiable if there
exists an interpretation that satisfies all formulas in Γ.
Exercise S.2.4. The set of all formulas of the form A ← F , where A is an atomic
proposition, is satisfiable. True or false?
If Γ is a finite set of formulas then we can form the conjunction and the
disjunction of all elements of Γ. We will use this terminology even when Γ is
empty; the conjunction of the empty set of formulas is understood as >, and the
disjunction as ⊥. This is similar to the convention adopted in algebra: the sum
of the empty set of numbers is understood as 0, and the product of the empty set
of numbers (for instance, 20 and 0!) is understood as 1. It is clear that any finite
set of formulas is equivalent to the conjunction of all its elements.
3 Minimal Models
“Minimal models” that we are going to talk about now are closely related to stable
models, but the definition is simpler.
About a model I of a formula F we say that it is minimal if no other model
of F is a subset of I. For instance, if σ = {p, q} then the formula p∨q has 3 models:
The first two are minimal, and the third is not. For sets of formulas, the definition
of a minimal model is similar: a model I of Γ is called minimal if no other model
of Γ is a subset of I.
Exercise S.3.1. (a) Assuming that σ = {p, q, r, s}, find all models of the program
{p ∨ q, r ← p, s ← q}.
{p ← q, q ∨ r}.
Exercise S.3.3. Describe (a) models of the empty set of formulas, (b) minimal
models of the empty set.
Exercise S.3.4. For the case when Γ is a set of atoms, describe (a) models of Γ,
(b) minimal models of Γ.
Exercise S.3.5. Find a propositional rule that has exactly 4 minimal models.
4
Exercise S.3.6. It is clear that if two formulas or sets of formulas are equivalent
then they have the same minimal models. But the converse is not true: two
formulas may have the same minimal models even though they are not equivalent
to each other. Find such a pair of formulas.
A propositional rule will be called definite if
(ii) its body (if it has one) does not contain negation.
A propositional program is definite if all its rules are definite. A definite program
has a unique minimal model, and we can construct it by accumulating, step by
step, the atomic propositions that need to be included to satisfy all rules of the
program. For instance, let Γ be the program
p, (2)
q ← p ∧ r, (3)
r ← p ∨ t, (4)
s ← r ∧ t. (5)
p1 ∧ p2 ← q1 ∨ q2 ,
q1 ← r1 ∨ r2 ,
r1 ,
(b)
p ← q1 ∧ q2 ,
q1 ← r1 ∨ r2 ,
q2 ← p ∨ q1 ,
r1 .
5
Exercise S.3.8. Let Γ be the program
{p1 ← p2 ∧ p3 , p2 ← p3 ∧ p4 , . . . , p8 ← p9 ∧ p10 }.
For each of the following programs, describe the step-by-step process of construct-
ing its minimal model.
(a) Γ,
(b) Γ ∪ {p5 },
(c) Γ ∪ {p5 , p6 }.
It is clear that condition (i) in the definition of a definite rule is essential: if we
drop it then the claim that every definite program has a unique minimal model
will become incorrect. Rule p∨q can serve as a counterexample. Indeed, it satisfies
condition (ii), because it has no body, and it has 2 minimal models.
Exercise S.3.9. Condition (ii) in the definition of a definite rule is essential also.
Give a counterexample illustrating this fact.
Exercise S.3.10. Let
Γ = {p1 ← p2 , p2 ← p3 , p3 ← p4 , p4 ← p5 , . . . },
∆ = {p2 ← p1 , p3 ← p2 , p4 ← p3 , p5 ← p4 , . . . }.
For each of the following programs, describe the step-by-step process of construct-
ing its minimal model.
(a) Γ ∪ {p3 },
(b) ∆ ∪ {p3 }.
6
clingo rules Propositional rules
:- ←
comma in the body ∧
comma in the head ∨
not ¬
#false ⊥
#true >
sometimes to disjunction, depending on where it occurs in the rule. The line that
shows how negation is represented in a clingo program is not relevant at this
point, because we are talking about positive programs here, but it will be needed
later.
To instruct clingo to find the stable models of the propositional program
from Exercise S.3.1, we rewrite the program in the syntax of clingo:
p,q.
r :- p.
s :- q.
% clingo S31.lp
then clingo will generate one of the two stable models of the program and stop
without looking for the other one. The command line
% clingo S31.lp 2
will instruct clingo to find both stable models, and in the output we will see:
Answer: 1
s q
Answer: 2
r p
Nothing will change if we replace 2 in the command line by any larger integer,
because this program has only 2 stable models. Number 0 would be understood
as the instruction to find all stable models.
Rewriting rule (4) in the syntax of clingo is less straightforward, because the
body of this rule is a disjunction, and in the (current version of) clingo there is no
7
symbol for disjunction in the body. But this rule can be replaced by an equivalent
pair of simpler rules; see Exercise S.2.1(c).
Exercise S.4.1. (a) Rewrite program (2)–(5) in the syntax of clingo. (b) Use
clingo to find its stable model.
Exercise S.4.2. (a) Rewrite the program from Exercise S.3.6(a) in the syntax of
clingo. (b) Use clingo to find its stable model.
Exercise S.4.3. Use clingo to find the number of stable models of the program
p ∨ q,
r ∨ s,
s1 ∨ s2 ← s,
⊥ ← p ∧ s1.
H1 , . . . , Hm . (7)
8
For any program Π consisting of such rules we will describe a positive proposi-
tional program called the propositional image of Π. By the stable models of Π we
mean the stable models of the propositional image of Π, that is to say, its minimal
models (Section 4). Atomic propositions in the propositional image are ground
atoms of the form p(v1 , . . . , vk ), where each vi is a symbolic constant or an integer.
The set of all symbolic constants will be denoted by S, and the set of all
integers by Z. If R is a rule of type (6) or (7), then an instance of R is any rule
obtained from R by substituting values from the set S ∪ Z for all its variables.
Since that set is infinite, any rule containing at least one variable has infinitely
many instances. For example, the instances of rule (8) are the rules
for all v0 , v1 , v2 ∈ S ∪ Z.
The propositional image of a program consists of the instances of its rules
transformed into propositional formulas
(i) by replacing the symbol :- and all commas in the head and the body by
propositional connectives as shown in Table 1, and dropping the period at
the end of the rule;
(ii) by replacing each comparison t1 ≺ t2 in the head and in the body by > if it
is true, and by ⊥ if it is false;
(iii) by replacing the head of the rule by ⊥ if it is empty, and replacing the body
by > if it is empty.
For instance, the propositional images of facts (9) are the atomic propositions
t(austin, 88), t(dallas, 95), t(houston, 90), t(san antonio, 85). (11)
if v1 > v2 , and
warm(v0 ) ← t(v0 , v1 ) ∧ t(austin, v2 ) ∧ ⊥ (13)
otherwise. Consequently the propositional image of clingo program (8), (9) con-
sists of propositional rules (11)–(13).
This program is definite, so that is has a unique minimal model, and that
model can be constructed by accumulating the atoms that need to be included
to satisfy all its rules (Section 3). Before doing that, we will simplify the pro-
gram. Formulas (13) are tautologies and can be dropped, and in formula (12)
9
the conjunctive term > can be dropped, so that (11)–(13) is equivalent to the
propositional program consisting of rules (11) and
To satisfy these rules, we need to include, first of all, atoms (11). After that,
among the infinitely many rules (14) there will be 2 that are not satisfied:
and
warm(houston) ← t(houston, 90) ∧ t(austin, 88).
Once the heads
warm(dallas), warm(houston) (15)
of these rules are added, the construction of the minimal model is completed.
This calculation justifies the assertion in Programming with CLINGO that
atoms (11), (15) form the only stable model of clingo program (8), (9).
Exercise S.5.1. (a) Find the propositional image of the program
p(0,1).
p(1,2).
q(X,Y) :- p(X,Y), X>0, Y>0.
(b) Simplify it. (c) Describe the step-by-step process of constructing its minimal
model.
Exercise S.5.2. (a) Find the propositional image of the program consisting of
rules (4), (5), (8) from Programming with CLINGO. (b) Describe the step-by-step
process of constructing its minimal model.
Exercise S.5.3. (a) Find the propositional image of the program
p(1),p(2),p(3).
:- p(X), X>2.
10
clingo terms Algebraic notation
m*n m·n
m/n bm/nc
m\n m − n · bm/nc
m**n bmn c
p(2*2).
• n1 is a value of t1 ,
• n2 is a value of t2 ,
• n1 ≤ n ≤ n2 .
For instance, the only value of 2*2 is 4, because the only value of 2 is 2, and
2 · 2 = 4. The set of values of 2/0 is empty, because division by 0 is undefined.
The set of values of 2*a is empty as well, because the only value of the symbolic
constant a is not an integer. The same goes for 2..a.
11
Expression Propositional image
atom p(t1 , . . . , tk ) conjunction of all formulas of the form p(v1 , . . . , vk )
in the head where vi is a value of ti (i = 1, . . . , k)
atom p(t1 , . . . , tk ) disjunction of all formulas of the form p(v1 , . . . , vk )
in the body where vi is a value of ti (i = 1, . . . , k)
comparison t1 ≺ t2 > if for every value v1 of t1 and every
in the head value v2 of t2 , v1 ≺ v2 ; ⊥ otherwise
comparison t1 ≺ t2 > if for some value v1 of t1 and some
in the body value v2 of t2 , v1 ≺ v2 ; ⊥ otherwise
(a) 6..5.
(b) a..(a+1).
(c) 2**(-2).
The syntax of clingo allows us to use the interval symbol in the scope of
arithmetic operations. For instance, (1..3)*2 is a term; its values, according to
the definition above, are 2, 4, and 6.
Exercise S.6.2. Find all values of the term (2..4)*(2..4).
Exercise S.6.3. Find a ground term (a) with the values 1, 3, 9; (b) with the
values 22, 32, 42.
(ii0 ) by replacing each atom and each comparison in every rule by its propositional
image as described in Table 3.
12
According to Table 3, the same expression may correspond to different formulas
depending on whether it occurs in the head or in the body. For instance,
• the propositional image of the atom p(1..2) in the head of a rule is the
conjunction p(1) ∧ p(2), but the propositional image of the same atom in the
body of a rule is the disjunction p(1) ∨ p(2);
• the propositional image of the atom p(1/0) in the head is the empty con-
junction >, but the propositional image of the same atom in the body is the
empty disjunction ⊥;
(This is rule (6) from Programming with CLINGO, with the upper bound 10
replaced by 3.) Its propositional image consists of the rules
13
other rules can be equivalently written as
p(2).
p(a).
q(X+1) :- p(X).
The rules in the last line are tautologies and can be dropped. The stable model
of the program is {p(2), p(a), q(3)}.
Exercise S.7.1. For each of the given rules, finds its propositional image.
(a) square(1..2,1..2).
(b) square(austin..san_antonio,austin..san_antonio).
p(1/N) :- N=0..1.
p(1..3).
q(X) :- p(X), X=2..4.
(b) Simplify it. (c) Describe the step-by-step process of constructing its minimal
model.
Exercise S.7.4. Do the same for the program
p(1,1..2).
q(X,Y) :- p(X,Y), X!=Y.
q(X,Y) :- q(Y,X).
14
p(1..3).
q(N-1..N+1) :- p(N).
8 Safety
In some cases, the propositional image of a clingo program has an infinite stable
model. This often happens when the head of one the rules contains a variable that
doesn’t occur in the body. Consider, for instance, the one-rule program p(X). Its
propositional image is the set of atoms p(v) for all v ∈ S ∪ Z. That infinite set is
its own stable model.
Exercise S.8.1. (a) Find the propositional image of the one-rule program p(2*X).
(b) Find its stable model.
Exercise S.8.2. (a) Find the propositional image of the program
p(a).
q(X,Y) :- p(X).
(b) Describe the step-by-step process of constructing its minimal model.
It is impossible, of course, to display infinitely many atoms in a finite amount
of time, and it is not surprising that the algorithm used by clingo for generating
stable models is not applicable to rules like these. Given a rule containing a
variable that doesn’t occur in its body, clingo produces an error message saying
that the variable is “unsafe.”
In some cases, a variable is considered unsafe even though it does occur in the
body. For instance, clingo produces an unsafe variable message for each of the
rules
p(X) :- X>0. (18)
and
q(X) :- p((-1)**X). (19)
There is a good reason for this: programs containing one of these rules may have
infinite stable models.
Exercise S.8.3. (a) Find the propositional image of the one-rule program (18).
(b) Find its stable model.
Exercise S.8.4. (a) Find the propositional image of the program consisting of
the fact
15
p(1).
and rule (19). (b) Describe the step-by-step process of constructing its minimal
model.
The program
p(1).
(20)
p(N+2) :- p(N).
has an infinite stable model too, but it is not considered unsafe. Given this
program, (the current version of) clingo dies and has to be restarted. The
difference between this program and the examples discussed earlier is that the
set of ground atoms generated in the process of constructing its minimal model
remains finite at each step; the minimal model is infinite only because the number
of steps is infinite. This is similar to the program from Exercise S.3.10(b).
Exercise S.8.5. (a) Find the propositional image of program (20). (b) Describe
the step-by-step process of constructing its minimal model.
9 Negation as Failure
Our next goal is to extend the definition of a stable model from Section 4 to propo-
sitional programs that contain negation. In this section, we discuss informally a
few examples.
The program
p,
q,
r ← p,
s←q
is positive definite, and its stable model can be formed by accumulating the atomic
propositions that are needed to satisfy all rules: we include p and q to satisfy the
first two rules, and then add r and s to satisfy the other two. The stable model
is {p, q, r, s}. Consider the modification of that program in which the conjunctive
term ¬s is added to the body of the third rule:
p, (21)
q, (22)
r ← p ∧ ¬s, (23)
s ← q. (24)
16
We think of this conjunctive term as a restriction on the process of accumulating
atomic propositions in the process of constructing the stable model. Rule (23)
instructs us to add r to the model if p is included under the condition that
s is not included in the model and will not be included in the future. (25)
Since the program contains rules (22) and (24), the model that we are building will
include s, so that rule (23) is “disabled.” The stable model of program (21)–(24)
is {p, q, s}.
Exercise S.9.1. (a) Rewrite propositional program (21)–(24) as a clingo pro-
gram. (b) Check that the stable model generated by clingo is indeed {p, q, s}.
Consider now the program consisting of only three rules (21)–(23). Since the
heads of the rules of this program don’t contain s, condition (25) is satisfied, and,
in accordance with rule (23), we add r. The stable model of program (21)–(23) is
{p, q, r}.
The idea that formulas beginning with negation in the body of a rule repre-
sent restrictions that can “disable” the use of that rule for accumulating atomic
propositions can be expressed by saying that we understand the negation symbol
as negation as failure. (Condition (25) says that the attempt to justify includ-
ing s in the model will fail.) This explanation of negation as failure is somewhat
vague, because it is circular: which rules are disabled depends on which atomic
propositions are going to be included in the model, and the other way around.
The definition of a stable model in the next section makes the idea of negation
as failure precise. But there are many cases when the meaning of the informal
explanation above is sufficiently clear.
Exercise S.9.2. (a) Use the process described above to find the stable model of
program (21), (23), (24). (b) Check whether your answer agrees with the output
of clingo.
Exercise S.9.3. (a) Use the process described above to find the stable model of
the program
p ← ¬q, (26)
q ← ¬r. (27)
(b) Check whether your answer agrees with the output of clingo.
The last example in this section is the program
p ← ¬q, (28)
q ← ¬p. (29)
17
Which of the atomic propositions p, q will we include in the process of constructing
its stable model? There are two ways to answer this question. We can include p;
then rule (29) is “disabled”, so that q is not included, and rule (28) justifies the
presence of p in the model. On the other hand, not including p is a reasonable
option as well; then rule (29) justifies including q, rule (28) is “disabled,” and this
fact justifies not including p. So program (28), (29) has two stable models, {p}
and {q}.
¬p ← ¬(q ∧ ¬r)
has two critical parts: the head ¬p and the body ¬(q ∧ ¬r). (The subformula
¬r is not critical because it is contained in a larger subformula that begins with
negation.)
Let F be a formula, and let I be an interpretation. The reduct F I of F relative
to I is the formula obtained from F by substituting > for each critical part that is
satisfied by I, and substituting ⊥ for each critical part that is not satisfied by I.
The reduct ΓI of a propositional program Γ relative to I is the positive program
obtained from Γ by the same process.
If I is a minimal model of the reduct ΓI then we say that I is a stable model
of Γ.
For instance, let Γ be program (21)–(24), and let I be {p, q, s}. Since the
critical part ¬q of the third rule is not satisfied by I, the reduct ΓI is
p,
q,
(30)
r ← p ∧ ⊥,
s ← q.
This program is definite, and its only minimal model is {p, q, s}—exactly the
interpretation I. Consequently I is a stable model of (21)–(24).
The interepretation {p, q} is not a stable model of (21)–(24). Indeed, the
18
reduct of the program relative to this interpretation is
p,
q,
(31)
r ← p ∧ >,
s ← q,
and {p, q} is not a model of this reduct—it doesn’t satisfy the last two rules.
Interpretation {p, q, r, s} is not a stable model of (21)–(24) either. Indeed, the
reduct of the program relative to this interpretation is (30), and {p, q, r, s} is not
minimal among the models of (30).
It is easy to show, in fact, that program (21)–(24) has no stable models other
than {p, q, s}. Take any interpretation I different from {p, q, s}, and consider two
cases. Case 1: s ∈ I. The reduct of the program relative to I is (30). The only
minimal model of the reduct is {p, q, s}, and it is different from I. Consequently I
is not stable. Case 2: s 6∈ I. The reduct of the program relative to I is (31), and
the only minimal model of the reduct is {p, q, r, s}. Since this model contains s,
it is different from I, so that I is not stable.
Exercise S.10.1. Find the reduct of each of the given rules relative to {p}, and
simplify it.
(a) p ← q ∧ ¬r,
(b) p ← ¬q ∧ ¬r,
Exercise S.10.2. (a) Prove that {p, q, r} is a stable model of program (21)–(23).
(b) Prove that program (21)–(23) has no other stable models.
Exercise S.10.3. Determine whether the interpretation {p, q} is a stable model
of program (28), (29).
Let’s find now all stable models of the program
p ∨ q, (32)
r ← ¬p. (33)
p ∨ q,
r ← ⊥.
19
It has two minimal models, {p} and {q}. The former satisfies the condition p ∈ I
that characterizes Case 1, so that it is a stable model of (32), (33). Case 2: p 6∈ I.
The reduct of (32), (33) relative to I is
p ∨ q,
r ← >.
It has two minimal models, {p, r} and {q, r}. The latter satisfies the condition
p 6∈ I that characterizes Case 2, so that it is a stable model of (32), (33). We
conclude that this program has two stable models, {p} and {q, r}.
Exercise S.10.4. (a) Find all stable models of the program
p ∨ q,
r ∨ ¬s ← p.
(b) Check whether your answer agrees with the output of clingo.
Exercise S.10.5. Do the same for the program
p,
⊥ ← p ∧ ¬q.
p ← ¬q,
q ← ¬p,
r ← p,
r ← q.
Exercise S.10.7. Find all stable models of each of the following one-rule pro-
grams:
(a) p ← ¬p,
(b) p ← ¬¬p,
(c) p ∨ ¬p.
11 Strong Equivalence
If two sets of formulas are equivalent to each other then they have the same models
(this is the definition of equivalence, see Section 2), and consequently the same
minimal models. With the concept of a stable model, however, the situation is
20
different: two equivalent propositional programs can have different stable models.
For instance, the one-rule programs
are equivalent to each other. But the only stable model of the first of them is
{p}; the only stable model of the second is {q}; the third has two stable models.
Another example: even though the program
p,
(35)
q←p
is equivalent to the program from Exercise S.10.5, these two programs have dif-
ferent stable models: {p, q} is a stable model of the former, but not of the latter.
We say that a propositional rule R1 is strongly equivalent to a propositional
rule R2 if replacing R1 by R2 in any propositional program does not change the
collection of its stable models. For example, the first of rules (34) is not strongly
equivalent to either of the other two rules. The second rule of the program from
Exercise S.10.5 is not strongly equivalent to the second of rules (35).
In some cases, the fact that two rules are not strongly equivalent to each other
can be established by comparing the stable models of these rules viewed as one-
rule programs. But sometimes we have to look at the result of replacing one rule
by the other in a program containing additional rules. For instance, if we consider
the second rule from Exercise S.10.5 and the second of rules (35) in isolation then
we will see that they have the same stable model, ∅. To argue that these rules are
not strongly equivalent, we need to look at them in the presence of an additional
rule—for instance, p.
Exercise S.11.1. Prove that ¬¬p is not strongly equivalent to p.
Exercise S.11.2. Prove that ¬q ← ¬p is not strongly equivalent to p ← q.
On the other hand, we can sometimes see that a given rule is strongly equivalent
to a simpler rule. Being able to recognize such cases is useful, because it may help
us simplify a program before calculating its stable models.
We can assert that propositional rules R1 and R2 are strongly equivalent when-
ever we can show that, for every interpretation I, the reduct R1I is equivalent to
the reduct R2I . Indeed, if R1I is always equivalent to R2I then replacing R1 by R2 in
a program doesn’t affect the set of models of any of its reducts, and consequently
doesn’t affect the set of the minimal models of any reduct. And the set of minimal
models of the reduct relative to I is what determines whether I is a stable model.
It is clear, for instance, that if two equivalent rules are positive then they are
strongly equivalent. Indeed, if R1 and R2 are positive and equivalent to each
other then R1I is R1 , R2I is R2 , so that R1I is equivalent to R2I . In other words, the
21
stable models of a program are not affected by equivalent transformations that
turn positive rules into positive rules.
Exercise S.11.3. Prove that p ∨ q is strongly equivalent to q ∨ p.
Any rule of the form F ← G ∧ H is strongly equivalent to F ← H ∧ G. Indeed,
(F ← G ∧ H)I is F I ← GI ∧ H I ,
(F ← H ∧ G)I is F I ← H I ∧ GI ,
and these two reducts are equivalent. In other words, changing the order of con-
junctive terms in the body of a rule doesn’t affect the set of stable models.
Any rule of the form F ← G ∧ > is strongly equivalent to F ← G. Indeed,
(F ← G ∧ >)I is F I ← GI ∧ >,
(F ← G)I is F I ← GI ,
and these two reducts are equivalent. In other words, dropping the conjunctive
term > from the body of a rule doesn’t affect the set of stable models.
Exercise S.11.4. F ∧ (G ∨ H) is strongly equivalent to (F ∧ G) ∨ (F ∧ H). True
or false?
Let us check now that ¬¬¬p is strongly equivalent to ¬p. Consider any inter-
pretation I. If p ∈ I then both formulas have the same reduct:
(¬¬¬p)I = ⊥, (¬p)I = ⊥.
22
is strongly tautological, because its reduct
F I ← GI ∧ ⊥
p(a).
q(a).
r(X) :- p(X), not q(X).
p(a),
q(a),
r(v) ← p(v) ∧ ¬q(v) for all v ∈ S ∪ Z.
p(a),
q(a),
r(a) ← p(a) ∧ ⊥,
r(v) ← p(v) ∧ > for all v ∈ S ∪ Z \ {a},
23
or, equivalently,
p(a),
q(a),
r(v) ← p(v) for all v ∈ S ∪ Z \ {a}.
(c) Simlplify the reduct. (d) Find the minimal model of the reduct to determine
whether (37) is a stable model of the program.
Consider now the program consisting of two rules:
and
prime(N) :- N=2..5, not composite(N). (39)
(Programming with CLINGO, Listing 1, with n = 5.) We will check that the
interpretation
{prime(2), prime(3), composite(4), prime(5)} (40)
is a stable model of this program.
The propositional image Γ of the program consists of the rules
composite(4) ← > ∧ > ∧ >,
prime(2) ← > ∧ ¬composite(2),
prime(3) ← > ∧ ¬composite(3), (41)
prime(4) ← > ∧ ¬composite(4),
prime(5) ← > ∧ ¬composite(5)
and infinitely many propositional rules containing at least one conjunctive term ⊥
in the body. It’s useful to note that rules (41) are strongly equivalent to the rules
composite(4),
prime(2) ← ¬composite(2),
prime(3) ← ¬composite(3), (42)
prime(4) ← ¬composite(4),
prime(5) ← ¬composite(5),
24
and that all other rules of Γ are strongly tautological (Section 11). We conclude
that Γ has the same stable models as the finite program (42). The reduct of (42)
relative to (40) consists of the rules
and is equivalent to (40). The only minimal model of that set of atoms is (40)
itself.
Exercise S.12.2. (a) Find the propositional image of the program
p(1..3).
q(X) :- X=2..4, not p(X).
(b) Simplify it using strongly equivalent transformations. (c) Find the reduct of
the simplified propositional image relative to the interpretation
(d) Simplify the reduct. (e) Find the minimal model of the reduct to determine
whether (43) is a stable model of the program.
We will now extend the definition of propositional image to choice rules with
head of the form
{p(t1 , . . . , tk )}. (44)
The propositional image of (44) is the conjunction of all formulas of the form
p(v1 , . . . , vk ) ∨ ¬p(v1 , . . . , vk )
{p(a)}.
is the disjunction p(a) ∨ ¬p(a). This is essentially the formula that we saw in
Exercise S.10.7(c); its stable models are ∅ and {p(a)}.
Consider now the choice rule
{p(1..10)}.
25
Its propositional image is
Any subset I of the set {p(1), . . . , p(10)} is a stable model of (45). Indeed, the
reduct of (45) relative to I is the conjunction of the formulas p(k)∨⊥ for all atoms
p(k) from I, and p(k) ∨ > for all atoms p(k) from {p(1), . . . , p(10)} \ I. Formula
p(k) ∨ ⊥ is equivalent to p(k); formula p(k) ∨ > is a tautology. Consequently the
reduct is equivalent to the conjunction of the elements of I, and its minimal model
is I.
Exercise S.12.3. (a) Find the propositional image of the program
{p(a)}.
q(X) :- p(X).
(b) Find the reduct of this propositional image relative to the interpretation
{q(a)}. (46)
(c) Simplify the reduct. (d) Find the minimal model of the reduct to determine
whether (46) is a stable model of the program.
We observed in Section 8 that a variable that occurs in the head of a rule but
doesn’t occur in the body is considered unsafe, and that programs including such
rules often have infinite stable models. The same can be said about a variable
that does occur in the body, but only in negated atoms, such as X in the second
rule of the program
p(a).
(47)
q(X) :- not p(X).
Exercise S.12.4. Check that the set consisting of the atom p(a) and the atoms
q(v) for all v ∈ S ∪ Z \ {a} is a stable model of program (47).
Answers to Exercises
26
(b) The set {p1 , p2 , . . . , p8 } has 28 subsets. A subset of that set satisfies p1 ← p2
unless it includes p2 but does not include p1 . The number of such exceptional
subsets is 26 . It follows that the number of models of p1 ← p2 is 28 − 26 , or 192.
S.1.6. (a) {p1 , p3 , p5 , . . . } and {p0 , p1 , p3 , p5 , . . . }. (b) ∅, {p0 }, {p0 , p1 }.
S.2.1. (a): not equivalent; for example, {q} satisfies p ← r but does not satisfy
the first of the formulas p ← q, q ← r. (b)–(e): equivalent.
S.2.2. (a) ¬p. (b) p ∨ q. (c) ⊥. (d) p ∨ q ← r. (e) >.
S.2.3. Both (a) and (b).
S.2.4. True: any such set is satisfied by the set of all atomic propositions.
S.3.1. (a) {p, r}, {q, s}, {p, r, s}, {q, r, s}, {p, q, r, s}. (b) {p, r} and {q, s}.
S.3.2. {p, q} and {r}.
S.3.3. (a) All interpretations are models. (b) The only minimal model is ∅.
S.3.4. (a) All sets of interpretations containing Γ are models. (b) The only
minimal model is Γ itself.
S.3.5. p ∨ q ∨ r ∨ s.
S.3.6. p ← q and q ← p.
S.3.7. (a) Step 1: include r1 ; step 2: add q1 ; step 3: add p1 and p2 . Minimal
model: {p1 , p2 , q1 , r1 }. (b) Step 1: include r1 ; step 2: add q1 ; step 3: add q2 ;
step 4: add p. Minimal model: {p, q1 , q2 , r1 }.
S.3.8. (a) Minimal model: ∅. (b) Step 1: include p5 . Minimal model: {p5 }.
(c) Step 1: include p5 and p6 ; step 2: add p4 ; step 3: add p3 ; step 4: add p2 ;
step 5: add p1 . Minimal model: {p1 , . . . , p6 }.
S.3.9. p ← ¬q.
S.3.10. (a) Step 1: include p3 ; step 2: add p2 ; step 3: add p1 . Minimal model:
{p1 , p2 , p3 }. (b) Step 1: include p3 ; step 2: add p4 ; step 3: add p5 ; and so on.
Minimal model: {p3 , p4 , . . . }.
S.4.1. (a)
p.
q :- p, r.
r :- p.
r :- t.
s :- r, t.
S.4.2. (a)
27
p1 :- q1.
p2 :- q1.
p1 :- q2.
p2 :- q2.
q1 :- r1.
q1 :- r2.
r1.
S.5.1. (a)
p(0, 1),
p(1, 2),
q(v1 , v2 ) ← p(v1 , v2 ) ∧ > ∧ > for all v1 , v2 ∈S∪Z such that v1 , v2 > 0,
q(v1 , v2 ) ← p(v1 , v2 ) ∧ ⊥ ∧ > for all v1 , v2 ∈S∪Z such that v1 ≤ 0, v2 > 0,
q(v1 , v2 ) ← p(v1 , v2 ) ∧ > ∧ ⊥ for all v1 , v2 ∈S∪Z such that v1 > 0, v2 ≤ 0,
q(v1 , v2 ) ← p(v1 , v2 ) ∧ ⊥ ∧ ⊥ for all v1 , v2 ∈S∪Z such that v1 , v2 ≤ 0.
(b)
p(0, 1),
p(1, 2),
q(v1 , v2 ) ← p(v1 , v2 ) for all v1 , v2 ∈ S ∪ Z such that v1 , v2 > 0.
(c) Step 1: include p(0, 1) and p(1, 2). Step 2: add q(1, 2).
S.5.2. (a)
parent(ann, bob),
parent(bob, carol),
parent(bob, dan),
child(v1 , v2 ) ← parent(v2 , v1 ) for all v1 , v2 ∈ S ∪ Z,
ancestor(v1 , v2 ) ← parent(v1 , v2 ) for all v1 , v2 ∈ S ∪ Z,
ancestor(v1 , v3 ) ← ancestor(v1 , v2 ) ∧ ancestor(v2 , v3 ) for all v1 , v2 , v3 ∈ S ∪ Z.
Step 2: add
Step 3: add
ancestor(ann, carol), ancestor(ann, dan). (50)
Minimal model: atoms (48)–(50).
28
S.5.3. (a)
p(1) ∨ p(2) ∨ p(3),
⊥ ← p(v) ∧ > for all v ∈ S ∪ Z such that v > 2,
⊥ ← p(v) ∧ ⊥ for all v ∈ S ∪ Z such that v ≤ 2.
(b) The formulas in the second line can be equivalently rewritten as ¬p(v), and the
formulas in the last line are tautologies. It follows this set of formulas is equivalent
to
p(1) ∨ p(2) ∨ p(3),
(51)
¬p(v) for all v ∈ S ∪ Z such that v > 2.
Since the set of formulas in the second line includes ¬p(3), the formula in the first
line can be equivalently replaced by p(1) ∨ p(2). (c) Set (51) has two minimal
models, {p(1)} and {p(2)}.
S.6.1. (a) and (b).
S.6.2. 4, 6, 8, 9, 12, 16.
S.6.3. (a) 3**(0..2); (b) 10*(2..4)+2.
S.7.1. (a) square(1, 1) ∧ square(1, 2) ∧ square(2, 1) ∧ square(2, 2). (b) >.
S.7.2. (a)
p(−1) ← ⊥,
p(0) ← ⊥,
p(1) ← >,
> ← ⊥.
(b) p(1).
S.7.3. (a)
p(1) ∧ p(2) ∧ p(3),
q(2) ← p(2) ∧ >,
q(3) ← p(3) ∧ >,
q(4) ← p(4) ∧ >,
q(v) ← p(v) ∧ ⊥ for all v ∈ S ∪ Z \ {2, 3, 4}.
(b)
p(1) ∧ p(2) ∧ p(3),
q(2) ← p(2),
q(3) ← p(3),
q(4) ← p(4).
(c) Step 1: include p(1), p(2), p(3). Step 2: add q(2) and q(3).
29
S.7.4. (a)
(b)
(c) Step 1: include p(1, 1), p(1, 2). Step 2: add q(1, 2). Step 3: add q(2, 1).
S.7.5. (a)
(b) The rules in the last line are tautologies and can be dropped.
(c) Step 1: include p(1), p(2), p(3). Step 2: add q(0), q(1), q(2), q(3), q(4).
S.7.6. (a)
p(1) ∧ p(2) ∧ p(3),
> ← p(1),
⊥ ← p(v) for all v ∈ S ∪ Z \ {1}.
(b) Since the set of formulas in the last line includes ⊥ ← p(2), the propositional
image is unsatisfiable, and consequently has no minimal models.
S.8.1. (a)
p(m) for all even numbers m,
>.
(b) The set of atoms p(m) for all even numbers m.
S.8.2. (a)
p(a),
q(v1 , v2 ) ← p(v1 ) for all v1 , v2 ∈ S ∪ Z.
(b) Step 1: include p(a). Step 2: Add q(a, v) for all v ∈ S ∪ Z.
S.8.3. (a)
p(v) ← > for all v ∈ S ∪ Z such that v > 0,
p(v) ← ⊥ for all v ∈ S ∪ Z such that v ≤ 0.
30
(b) The set of atoms p(v) for all v ∈ S ∪ Z such that v > 0.
S.8.4. (a)
p(1),
q(n) ← p(m) for all n ∈ Z, where m is the value of (−1)n ,
q(v) ← ⊥ for all v ∈ S.
(b) Step 1: Include p(1). Step 2: Add q(n) for all even numbers n.
S.8.5. (a)
p(1),
p(m) ← p(n) for all n ∈ Z, where m is the value of n + 2,
> ← p(v) for all v ∈ S.
(b) Step 1: include p(1). Step 2: add p(3). Step 3: add p(5), and so on. Stable
model: {p(1), p(3), p(5), . . . }.
S.9.1. (a)
p.
q.
r :- p, not s.
s :- q.
S.9.2. (a) Atomic proposition q is not going to be included in the stable model,
because it doesn’t occur in the head of any rule. From this we can conclude that s
is not going to be included either, because the only rule with s in the head has the
body q. Consequently condition (25) is satisfied, and the stable model is {p, r}.
S.9.3. (a) Atomic proposition r is not going to be included in the stable model,
because it doesn’t occur in the head of any rule. It follows that in accordance with
rule (27), the stable model will include q. From that we conclude that rule (26) is
“disabled,” and there is no justification for adding p. The stable model is {q}.
S.10.1. (a) p ← q ∧ >, equivalent to p ← q. (b) p ← > ∧ >, equivalent to p.
(a) p ← ⊥ ∧ >, equivalent to >.
S.10.2. (a) The reduct of (21)–(23) relative to {p, q, r} is
p,
q, (52)
r ← p ∧ >,
and the only minimal model of the reduct is {p, q, r}. (b) Take any interpretation I
different from {p, q, r}, and consider two cases. Case 1: s ∈ I. The reduct of the
31
program relative to I is
p,
q,
r ← p ∧ ⊥,
and its minimal model {p, q} doesn’t contain s. Case 2: s 6∈ I. The reduct is (52),
and its only minimal model {p, q, r} is different from I.
S.10.3. No. The reduct consists of two tautologies
p ← ⊥,
q ← ⊥,
p ∨ q,
r ∨ ⊥ ← p.
It has two minimal models, {p, r} and {q}. Neither satisfies the condition that
characterizes Case 1. Case 2: s 6∈ I. The reduct is
p ∨ q,
r ∨ > ← p.
Its minimal models are {p} and {q}. Both satisfy the condition that characterizes
Case 2, so that both are stable models of the given program.
S.10.5. Take any interpretation I, and consider two cases. Case 1: q ∈ I. The
reduct is
p,
⊥ ← p ∧ ⊥.
The second line is a tautology, so that the only minimal model of this program is
{p}. It does not satisfy the condition characterizing Case 1. Case 2: q 6∈ I. The
reduct is
p,
⊥ ← p ∧ >.
This program is inconsistent. Consequently the given program has no stable mod-
els.
32
S.10.6. (a) Take any interpretation I, and consider four cases. Case 1: p, q ∈ I.
The reduct is
p ← ⊥,
q ← ⊥,
r ← p,
r ← q.
The minimal model ∅ doesn’t satisfy the condition characterizing this case. Case 2:
p ∈ I, q 6∈ I. The reduct is
p ← >,
q ← ⊥,
r ← p,
r ← q.
The minimal model {p, r} satisfies the condition characterizing this case, so that
{p, r} is a stable model of the given program. Case 3: p 6∈ I, q ∈ I. A similar
calculation gives the stable model {q, r}. Case 4: p, q 6∈ I. The reduct is
p ← >,
q ← >,
r ← p,
r ← q.
The minimal model {p, q, r} doesn’t satisfy the condition characterizing this case.
Consequently the given program has two stable models, {p, r} and {q, r}.
S.10.7. (a) If p ∈ I then the reduct is p ← ⊥, and its minimal model is ∅. If p 6∈ I
then the reduct is p ← >, and its minimal model is {p}. Neither model satisfies
the condition characterizing the corresponding case, so that the program has no
stable models. (b) If p ∈ I then the reduct is p ← >, and its minimal model
is {p}. This is a stable model of the given program. If p 6∈ I then the reduct is
p ← ⊥, and its minimal model is ∅. This is a stable model as well. (c) If p ∈ I
then the reduct is p ∨ ⊥, and its minimal model is {p}. This is a stable model of
the given program. If p 6∈ I then the reduct is p ∨ >, and its minimal model is ∅.
This is a stable model as well.
S.11.1. The stable model {p} of the one-rule program p is not a stable model of
the one-rule program ¬¬p. Indeed, the reduct of ¬¬p relative to {p} is >, and
{p} is not a minimal model of >.
S.11.2. Consider the programs
q,
(53)
¬q ← ¬p
33
and
q,
p ← q.
The stable model {p, q} of the latter is not a stable model of the former. Indeed,
the reduct of (53) relative to {p, q} is
q,
⊥ ← ⊥,
(F ∧ (G ∨ H))I is F I ∧ (GI ∨ H I ),
((F ∧ G) ∨ (F ∧ H))I is (F I ∧ GI ) ∨ (F I ∧ H I ),
34
(d) The minimal model {p(a), q(b), r(a)} is different from (37). Consequently (37)
is not a stable model of the program.
S.12.2. (a)
p(1) ∧ p(2) ∧ p(3),
q(2) ← > ∧ ¬p(2),
q(3) ← > ∧ ¬p(3),
q(4) ← > ∧ ¬p(4),
q(v) ← ⊥ ∧ ¬p(v) (v ∈ S ∪ Z \ {2, 3, 4}).
(b)
p(1) ∧ p(2) ∧ p(3),
q(2) ← ¬p(2),
q(3) ← ¬p(3),
q(4) ← ¬p(4).
(c)
p(1) ∧ p(2) ∧ p(3),
q(2) ← ⊥,
q(3) ← ⊥,
q(4) ← >.
(d)
p(1) ∧ p(2) ∧ p(3),
q(4).
(e) The minimal model {p(1), p(2), p(3), q(4)} is the same as (43). It follows
that (43) is a stable model of the program.
S.12.3. (a)
p(a) ∨ ¬p(a),
q(v) ← p(v) (v ∈ S ∪ Z).
(b)
p(a) ∨ >,
q(v) ← p(v) (v ∈ S ∪ Z).
(c)
q(v) ← p(v) (v ∈ S ∪ Z).
(d) The minimal model ∅ is different from (46). Consequently (46) is not a stable
model of the program.
S.12.4. The propositional image of program (47) is
p(a),
q(v) ← ¬p(v) for all v ∈ S ∪ Z.
35
Its reduct relative to the given set of atoms is
p(a),
q(a) ← ⊥,
q(v) ← > for all v ∈ S ∪ Z,
or, equivalently,
p(a),
q(v) for all v ∈ S ∪ Z
This set of atoms is its own minimal model.
36