5.5 Exercises
Exercise 5.1 How does Prolog respond to the following queries?
- X = 3*4.
- X is 3*4.
- 4 is X.
- X = Y.
- 3 is 1+2.
- 3 is +(1,2).
- 3 is X+2.
- X is 1+2.
- 1+2 is 1+2.
- is(X,+(1,2)).
- 3+2 = +(3,2).
- *(7,5) = 7*5.
- *(7,+(3,2)) = 7*(3+2).
- *(7,(3+2)) = 7*(3+2).
- 7*3+2 = *(7,+(3,2)).
- *(7,(3+2)) = 7*(+(3,2)).
- Define a 2-place predicate increment that holds only when its second argument is an integer one larger than its first argument. For example, increment(4,5) should hold, but increment(4,6) should not.
- Define a 3-place predicate sum that holds only when its third argument is the sum of the first two arguments. For example, sum(4,5,9) should hold, but sum(4,6,12) should not.