Mostrando las entradas con la etiqueta prolog. Mostrar todas las entradas
Mostrando las entradas con la etiqueta prolog. Mostrar todas las entradas

miércoles, marzo 05, 2008

What is Prolog?

Wikipedia says:
Prolog is a logic programming language. It is a general purpose language often associated with artificial intelligence and computational linguistics. It has a purely logical subset, called "pure Prolog", as well as a number of extralogical features.
I started to study Prolog in the University and I'm looking in the web for some resources. I found a lot! This are some of the links:

The book that we will use is The Art of Prolog of MIT Press.

One thing that surprise me a lot, was this:


% Declare a Graph

node(a).
node(b).
node(c).
node(d).
node(e).

link(a,b).
link(b,c).
link(b,d).
link(c,e).

exist_path(X,Y) :- link(X,Y).
exist_path(X,Y) :- link(X,Z),exist_path(Z,Y).



this code define a graph with a,b,c,d,e as nodes and [(a,b),(b,c),(b,d),(c,e)] as links.
exist_path is predicate, an define if exist a path from node X to node Y, if exist the result is TRUE, if not FAIL (FALSE).

This simple code leave me amazed!