• No results found

p∨ ¬p (5.23)

has two stable models,∅ and {p}. Indeed, the reduct of (5.23) relative to∅ isp∨ >, which is equivalent to>; the minimal model of the reduct is empty. The reduct of (5.23) relative to{p} isp∨ ⊥, which is equivalent top; the minimal model of the reduct is {p}.

In rule (5.23), negation occurs in the head, and not in the body as in the examples that we have seen before. clingo does not object against negation in the head. It will accept program (5.23) if we rewrite it as

p, not p.

and it will produce two stable models for it, in accordance with the calculation above. In other words,clingoviews this rule as synonymous to the choice rule{p}.

Exercise 5.11. (a) Find all stable models of the program

p∨q, r∨ ¬s←p.

(b) Check that the result of your calculation is in agreement with the output ofclingo. Formula (5.23) is known in logic as the law of excluded middle. (Any proposition p is either true or false, there is nothing in the middle.) This formula plays an important role in the theory of stable models because of its close relation to choice rules, and also because of the following fact:

Theorem on Excluded Middle. An interpretationI is a model of a propositional pro- gram Π if and only if I is a stable model of the program obtained from Π by adding the rulesp∨ ¬p for all atomic formulas p.

For example, an interpretation I is a model of the propositional program from Exer- cise 4.3 (page 62) if and only if it is a stable model of the program obtained from it by adding the rules

p∨ ¬p, q∨ ¬q, r∨ ¬r.

That means that the question from Exercise 4.3 can be answered by running clingo on the program p :- q, r. q :- p. r :- p. p, not p. q, not q. r, not r.

5.4. EXCLUDED MIDDLE AND DOUBLE NEGATION 89

I reduct relative toI s(I) fixpoint?

∅ {p← ⊥} ∅ X

{p} {p← >} {p} X

Table 5.3: Fixpoints of the stability operators of program (5.24).

We will see in Section 5.7 that the choice rule

{p; q; r}.

has the same meaning as the last three rules of the program above. Consequently it can be used instead of those rules.

In the special case when Π is empty, Theorem on Excluded Middle describes the stable models of a set of rules the form p∨ ¬p: they are arbitrary subsets of the set of atomic propositions occurring in the rules.

Exercise 5.12. Use clingo to verify your answers to Exercises 4.3, 4.4, 4.5(a), 4.5(b), 4.13(a).

The formula

p← ¬¬p (5.24)

is known asthe law of double negation. From Table 5.3 we see that it has the same stable models as the law of excluded middle: ∅ and {p}. Thus there is an essential difference between rule (5.24) and the positive rule p←p, which is obtained from it by dropping the double negation. The latter has only one stable model—the minimal model ∅. The fact that an equivalent transformation, such as dropping a double negation in a propositional rule, may affect the set of stable models of a program is important. When we want to find models, or minimal models, of a set of formulas, we often start by simplifying it—replacing it by an equivalent set of formulas that is simpler. But if our goal is to findstablemodels of a propositional program then simplifying the program may lead to a wrong answer. Some transformations of rules are “strongly” equivalent, in the sense that they do not affect the set of stable models; but dropping a double negation in front of an atomic formula is not one of them. (Simplifying the reduct before calculating its minimal models is permissible, of course; we are talking here about simplifying the program itself.)

It is often useful to know which equivalent transformations of propositional rules are strongly equivalent, and which are not, and we will talk about this in Section 5.8. For the time being, it is sufficient to remember two facts. First, the set of stable models of a program is not affected by the simplifications shown in Table 4.1 (page 64). Second, the set of stable models does not change if we break a rule with a conjunction in the head into several rules, corresponding to the conjunctive terms. For instance, replacing p∧q∧r by three rulesp,q,r is a strongly equivalent transformation, and so is replacingp∧q∧r←s

by

The input language ofclingo allows rules with two negations in a row. It will accept, for instance, program (5.24) if we rewrite it as

p :- not not p.

and it will produce the two stable models shown in Table 5.3.

The designers ofclingodecided, however, against permittingthreenegations in a row. There is a good reason for that, as we will see in Section 5.8.