Now we will extend the definition of propositional image toclingorules of the forms
{A1;. . .;Am}. (5.35)
and
{A1;. . .;Am} :- B1, . . . , Bn. (5.36) whereA1, . . . , Amare atoms, andB1, . . . , Bnare as in the previous section—atoms, possibly prefixed with one or two negations, and comparisons.
As noted in Section 5.4, the law of excluded middle p∨ ¬p has two stable models, ∅
and {p}. Consequently it can serve as the propositional image of the choice rule {p}.
We will apply this idea to arbitrary rules of forms (5.35) and (5.36) using the following notation. For any set Ω of ground atoms,V(Ω) will stand for the set of all ground atoms
p(v1, . . . , vk) such that for some atomp(t1, . . . , tk) from Ω,v1, . . . , vkare values oft1, . . . , tk, respectively. The propositional image of the head of ground rules (5.35), (5.36) is defined as the conjunction of the formulasA∨ ¬A for all atomsA inV({A1, . . . , Am}).
For example,
V({p(1), q(1..3)}) ={p(1), q(1), q(2), q(3)}.
It follows that the propositional image of the rule
{p(1); q(1..3)} :- not r(5).
is
(p(1)∨ ¬p(1))∧(q(1)∨ ¬q(1))∧(q(2)∨ ¬q(2))∧(q(3)∨ ¬q(3)) ← ¬r(5).
5.7. CLINGO PROGRAMS WITH CHOICE 95
{p(a)}.
q(X) :- p(X).
(b) Find the reduct of this propositional image relative to the interpretation
{q(a)}. (5.37)
(c) Simplify the reduct. (d) Find the minimal model of the reduct and determine whether interpretation (5.37) is a stable model of the program.
Exercise 5.20. Do the same for the program
p(a).
{q(X)} :- p(X).
and the interpretation
{p(a)}. (5.38)
In Section 5.4 we asserted that replacing the group of rules
p, not p. q, not q. r, not r.
(5.39)
with the choice rule
{p; q; r}.
does not affect the stable models of a program. We can now explain why: the propositional image
(p∨ ¬p)∧(q∨ ¬q)∧(r∨ ¬r) (5.40) of the choice rule is the conjunction of the propositional images of rules (5.39).
Now we will extend the definition of the propositional image to choice rules with cardi- nality bounds. For any finite set Π of formulas, Π∧ stands for the conjunction of all elements of Π. For any finite set Ω of atomic formulas and any nonnegative integer z, by Ω>z we denote the disjunction of the formulas Π∧ over all subsets Π of Ω that havez+ 1 elements. This formula expresses that the number of atomic formulas that are assigned the valuetrue is greater than z. For example, the expression
{p, q, r}>1
stands for the formula
(p∧q)∨(p∧r)∨(q∧r).
We define the propositional image of a ground choice rule with an upper bound
as the pair of propositional rules: the propositional image of choice rule (5.35) as defined above and the constraint
⊥ ←V({A1, . . . , Am})>u. (5.41) For example, the propositional image of the rule
{p; q; r} 1.
consists of rule (5.40) and constraint
⊥ ←(p∧q)∨(p∧r)∨(q∧r).
Exercise 5.21. Find the propositional image of the rule
{p(1..2,1..2)} 2.
For any finite set Ω of atomic formulas and any nonnegative integerz, Ω<z will denote the conjunction of the formulas ¬Π∧ over all subsets Π of Ω that have z elements. This formula expressed that the number of atomic formulas that are assigned the valuetrue is less thanz. For example, the expression
{p, q, r}<2
stands for the formula
¬(p∧q)∧ ¬(p∧r)∧ ¬(q∧r).
We define the propositional image of a ground choice rule with a lower bound
l {A1;. . .;Am}.
as the propositional image of choice rule (5.35) plus the constraint
⊥ ←V({A1, . . . , Am})<l. (5.42) For example, the propositional image of the rule
2 {p; q; r}.
consists of rule (5.40) and constraint
⊥ ← ¬(p∧q)∧ ¬(p∧r)∧ ¬(q∧r).
The propositional image of a ground choice rule with two bounds
l {A1;. . .;Am} u.
5.7. CLINGO PROGRAMS WITH CHOICE 97
Exercise 5.22. Find the propositional image of the rule
{p(1..2,1..2)} = 2.
For a ground choice rule of one of the forms
{A1;. . .;Am} u :- B1, . . . , Bn.
l {A1;. . .;Am} :- B1, . . . , Bn.
l {A1;. . .;Am} u :- B1, . . . , Bn.
the propositional image is defined in a similar way: it consists of the propositional image of choice rule (5.36) and one or two constraints. The constraints are (5.41) and (5.42) modified by appending the propositional image ofB1, . . . , Bn to their bodies.
As an example, consider the program
letter(a). letter(b).
{p(X,1..2)} = 1 :- letter(X).
(5.43)
We would like to determine whether the interpretation
{letter(a), letter(b), p(a,2), p(b,1)} (5.44) is one of its stable models. The propositional image of the program consists of the rules
letter(a), letter(b), (p(v,1)∨ ¬p(v,1))∧(p(v,2)∨ ¬p(v,2))←letter(v), ⊥ ←p(v,1)∧p(v,2)∧letter(v), ⊥ ← ¬p(v,1)∧ ¬p(v,2)∧letter(v) (5.45)
for all v inS∪Z. One way to proceed is to find the reduct of (5.45) relative to interpreta- tion (5.44). Alternatively, we can use here Theorem on Constraints: an interpretation is a stable model of program (5.45) if and only if it is a stable model of the first three lines of the program and does not satisfy the bodies of the constraints in the last two lines. The use of Theorem on Constraints makes the calculation a little easier, because it does not require computing the reducts of the constraints. The reduct of the first three lines of (5.45) is
letter(a),
letter(b),
(p(a,1)∨ >)∧(p(a,2)∨ ⊥)←letter(a),
(p(b,1)∨ ⊥)∧(p(b,2)∨ >)←letter(b),
or, after simplification,
letter(a),
letter(b),
p(a,2)←letter(a), p(b,1)←letter(b).
This is a definite program, and its minimal model is (5.44). Consequently (5.44) is a stable model of the first three lines of (5.45). Since this interpretation does not satisfy the bodies of the constraints in the last two lines of (5.45), it is a stable model of the entire program (5.45) as well.
Exercise 5.23. Consider the program obtained from (5.43) by adding the rule
{p(c,1)}.
Determine whether interpretation (5.44) is a stable model of the extended program.