SWI Prolog
Prolog is a general purpose logic programming language associated with artificial intelligence and computational linguistics. Prolog has its roots in formal logic, and unlike many other programming languages, Prolog is declarative: The program logic is expressed in terms of relations, represented as facts and rules. A computation is initiated by running a query over these relations. The language was first conceived by a group around Alain Colmerauer in Marseille, France, in the early 1970s and the first Prolog system was developed in 1972 by Colmerauer with Philippe Roussel
SWI-Prolog offers a comprehensive Free Software Prolog environment, licensed under the Lesser GNU Public License.The name SWI is derived from Sociaal-Wetenschappelijke Informatica ("Social Science Informatics"), the former name of the group at the University of Amsterdam, where Wielemaker is employed. It is allready available in Ubuntu/Debian repsitory and could be installed by
$ apt-get install swi-prolog
Example:
orbits(mercury,sun).
orbits(venus,sun).
orbits(earth,sun).
orbits(mars,sun).
orbits(moon, earth).
orbits(phobos, mars).
orbits(deimos, mars).
orbits(jupiter,sun).
orbits(ganymede,jupiter).
planet(P) :- orbits(P,sun).
satellite(S) :- orbits(S,P),
planet(P).
Save as solar.pl
Move to terminal and type prolog. It will give a prolog prompt(?- )in terminal
To run first type
?- consult(solar).
% test compiled 0.00 sec, -116 bytes
true.
?- planet(Who).
Who = mercury ;
Who = venus ;
Who = earth ;
Who = mars ;
Who = jupiter ;
false.
After each ; it will print the planets name until a false which indicates the end of list. "planet(Who)." specifies the query to the logic. Hope this helps