Exercise 1: Six coins are lying on the table in the following order
head head head tail tail tail
In one move, two adjacent coins may be turned. We search for a sequence of moves which transfers the coins into the situation
tail head tail head tail head
Formulate a logic program to solve this puzzle.
Exercise 2: Formulate the following puzzle in predicate logic clauses, and use the answer generation method to solve it:
Tom, Mike, and John are members of the alpine club. Each member of the alpine club is either skier or climber or both. No climber likes the rain and all skiers like the snow. Mikae likes everything that Tom dislikes, and vice versa. Mike and John like the snow.
Is there a member of the alpine club who is climber but no skier, and who is this?
Exercise 3: The logic program for addition described above can also be used for subtraction. How?
Exercise 4: Formulate a different logic program for addition which is based on the following recursive presentation"
x + 0 = x
x + y' = x' + y
Compute again what the result of 3 + 2 is.
Exercise 5: Write a logic program that simplifies formulas by eliminating useless multiplicative factors that are 1, and additive terms that are
0. (This program could be combined with the above program for differentiation.) The program we are looking for should be able to perform the following computation.
Using as input the goal clause?-
?- simpzify(1 * A + (B + (0 + x))*1, C).
leads to the result
simplify (1 * A + (B + (0 + x))*1, A + (B + x)).