Exercises for Section 12.3
12.3.1
Answer
- kill(I,D,X) :- defines(I,X) & defines(D,X)
- out(D,D,X) :- defines(D,X)
- out(I,D,X) :- in(I,D,X) & NOT kill (I,D,X)
- in(I,D,X) :- out(J,D,X) & pred(J,I,X)
12.3.2
Answer
- kill(I,X,O,Y) :- defines(I,X) OR defines(I,Y)
- out(I,X,O,Y) :- eval(I,X,O,Y)
- out(I,X,O,Y) :- in(I,X,O,Y) & NOT kill(I,X,O,Y)
- in(I,X,O,Y) :- out(J,X,O,Y) & pred(J,I)
12.3.3
Answer
- out(I,X) :- in(J,X) & pred(I,J)
- in(I,X) :- use(I,X) & NOT defines(I,X)
12.3.5
Answer
a)
R1: Path(1,2) Path(2,3) Path(3,4) Path(4,1) Path(4,5) Path(5,6)
R2: Path(1,3) Path(2,4) Path(3,1) Path(3,5) Path(4,6)
R3: Path(1,4) Path(1,5) Path(2,1) Path(2,5) Path(3,6) Path(4,3) Path(2,6) Path(3,2)
R4: Path(1,6) Path(4,2)
b) Same to above