Prolog Compilers| Prolog Environments| Prolog Examples | Prolog Books| Prolog FAQ| Contact

This is a simple example of a Prolog system. The code below provides a definition of planet, satellite and star and includes some facts about astronomical objects. So, a planet is defined as an object that orbits around a star and a satellite as an object that orbits around a planet. In our simple system, star is anything huge, luminous and made of plasma.

You can run queries on the system and see what the answers are. Additionally, you can enter your own Prolog code and play around with it.
Prolog code:
Query the system:  Show parse results
Result:
Query examples and their meaning:
  • satellite(phobos)   Is phobos a satellite?
  • satellite(X)           what are the satellites?
  • planet(X)              what are the planets?
  • orbits(X, Y)           which object orbit which?

The interesting point about the system is the ability to infer what it does not know directly. For example, if you read the Prolog code you see that we have a statement that says that Vega is a star. Now, despite we don't have a statement that says that the also the Sun is a star, the system knows it. It knows that by logic, by reasoning on what it knows. So if you run a query like star(vega) or star(sun) the system replies true, in both cases.


Back to Homepage