4 4 −Mother (x , y ) | Parent ( x , y ) . [ c l a u s i f y ( 1 ) ] .
5 5 Mother ( El i z a b e t h I I , C ha rl e s ) . [ assumption ] .
6 7 −Father ( x , y ) | Parent ( x , y ) . [ c l a u s i f y ( 1 ) ] .
7 8 Father ( Charle s , William ) . [ assumption ] .
8 10 −Parent ( x , y ) | −Parent (y , z ) | Grandparent ( x , z ) . [ c l a u s i f y ( 2 ) ] .
9 11 William = DukeOfCambridge . [ assumption ] .
10 12 DukeOfCambridge = William . [ copy ( 1 1 ) , f l i p ( a ) ] .
11 13 Queen = E l i z a b e t h I I . [ assumption ] .
12 14 −Grandparent ( Queen , DukeOfCambridge ) . [ deny ( 3 ) ] .
13 15 −Grandparent ( El i z a b e t h I I , William ) . [ copy ( 1 4 ) , r e w r i t e ( [ 1 3 ( 1 ) , 1 2 ( 2 ) ] ) ] .
14 16 Parent ( E l i z a b e t h I I , Cha r le s ) . [ r e s o l v e ( 4 , a , 5 , a ) ] .
15 18 Parent ( Charles , William ) . [ r e s o l v e ( 7 , a , 8 , a ) ] .
16 20 −Parent ( Charles , William ) . [ ur ( 1 0 , a , 1 6 , a , c , 1 5 , a ) ] .
17 21 $F . [ r e s o l v e (2 0 , a , 1 8 , a ) ] .
Run the example and take a look at the proof, which is copied in Listing 8.2. Clause
15 (15 -Grandparent(ElisabethII,William). [copy(14),rewrite([13(1),12(2)])].) is
obtained from clause 14 by applying demodulation (aka rewriting), using clause 13 and 12. As
stated in the Prover9 documentation [18], demodulation is the process of using a set of oriented
equations to rewrite (simplify, canonicalize) terms. The first part, [13(1), tells that the left
side of clause 13 (i.e., Queen) gets replaced by its right side (ElizabethII) inside clause 14.
The part 12(2) says that DukeOfCambridge is replaced by William. The numbers 1 and 2
indicate the position of rewriting (although this is not fully documented in Prover9).
The ability to deal with equality adds some power to Mace4. Another improvement would
be the possibility to do simple arithmetic. By doing set(arithmetic), you give Mace4 access
to operators like +,*,/ or <.>,<=,>=. A full description of operators is given in [18].
We consider Einstein’s riddle again, but this time using arithmetic operators and properties.
The implementation in alligatorBeer2.in follows the approach in [18]. First, we do:
set(arithmetic).
assign(domain_size, 5).
which will allow us define the ”right neighbor” relation and to tell the five houses are
numbered as {0,1,2,3,4} respectively. Then, we specify that objects in the same category are
mutually distinct:
list(distinct).
[Alligator,Bulldog,Cat,Donkey,Eagle]. % pets are distinct
[Aston_Martin,Bugatti,Cadillac,Dacia,Edonis]. % cars are distinct
...
end_of_list.
To define neighbors, we write:
right_neighbor(x,y) <-> x+1 = y.
neighbors(x,y) <-> right_neighbor(x,y) | right_neighbor(y,x). % y left/right
The clues are simply written like this:
Austrian = Amber.
Exercise 8.5 Solve the puzzle written in this new manner, by typing
mace4 -c -f alligatorBeer1.in | interpformat
Can you tell who drinks beer?
55