You are on page 1of 1

% ­­­­­ Facts ­­­­­

% Things that orbit the sun
orbits(mercury, sun).
orbits(venus,   sun).
orbits(earth,   sun).
orbits(mars,    sun).

% Things that orbit the earth
orbits(moon, earth).

% Things that orbit mars
orbits(phobos, mars).
orbits(deimos, mars).

% ­­­­­ Propositions ­­­­­

% P is a planet if P orbits the sun
planet(P) :­ orbits(P, sun).

% S is a satellite if S orbits P, and P is a planet
satellite(S) :­ orbits(S, P), planet(P).

% Try:
%  trace.
%  satellite(phobos).
%
% Also try:
%  satellite(S).

You might also like