% problem-set/puzzles/miscell/steamroller.ver2.clauses
% created : 07/07/88
% revised : 07/07/88

% description:
%
% This run solves "Schubert's Steamroller Puzzle" using UR-resolution.
%
%                 Schubert's Steamroller Puzzle
%
%     Wolves, foxes, birds, caterpillars, and snails are animals,
%         and there are some of each of them.
%     Also, there are some grains, and grains are plants.
%     Every animal either likes to eat all plants or all animals much
%         smaller than itself that like to eat some plants.
%     Caterpillars and snails are much smaller than birds, which are
%         much are much smaller than foxes, which in turn are much
%         smaller than wolves.
%     Wolves do not like to eat foxes or grains, while birds like to
%         eat caterpillars, but not snails.
%     Caterpillars and snails like to eat some plants.
%     Show that there is an animal that likes to eat a grain-eating
%         animal.

% representation:
%
% A special trick has been used to solve this puzzle.
% Instead of checking (using predicates) whether, for instance,
% something is an animal and a fox, animal(fox(x)) has been used as a 
% nested function, even though this is not within the problem.

-Smaller(animal(x3),animal(x1))| -eats(animal(x3),plant(x4))
 |  eats(animal(x1),plant(x2))| eats(animal(x1),animal(x3)).
-eats(animal(x),animal(y))|  -eats(animal(y),plant(Grain(z))).
-eats(animal(Wolf(x1)),animal(Fox(x2))).
-eats(animal(Wolf(x1)),plant(Grain(x2))).
-eats(animal(Bird(x1)),animal(Snail(x2))).
eats(animal(Bird(x1)),animal(Caterpillar(x2))).
eats(animal(Caterpillar(x1)),plant(p1(animal(Caterpillar(x1))))).
eats(animal(Snail(x1)),plant(p2(animal(Snail(x1))))).
Smaller(animal(Caterpillar(x1)),animal(Bird(x2))).
Smaller(animal(Snail(x1)),animal(Bird(x2))).
Smaller(animal(Bird(x1)),animal(Fox(x2))).
Smaller(animal(Fox(x1)),animal(Wolf(x2))).
Grain(Stalky).
