Ditto what CSFilm said. Prolog basically queries databases and attempts to match rules (known as predicates). One powerful aspect of it is that it backtracks if there are multiple matches to rules; this makes it possible to implement things concisely, albeit ineffeciently. For example, one could have a sort predicate that just generates a permutation of the list to be sorted, checks if it's sorted, and repeats the process until it is, due to backtracking.
A good example of Prolog's functionality can be illustrated in an append predicate. If we have the code
Quote:
append([], L2, L2).
append([Head|Tail1], L2, [Head|Tail3]) :- append(Tail1, L2, Tail3).
|
in our database, we can call something like
in an interactive interpreter (like SWI or GNU). This unifies X with the string "abcdef" because it is the result of appending "abc" and "def". This is simple enough, but if we instead replace the first two "parameters" of append with variables, and the result with the string "abcdef", we get all the possible lists that can comprise the string "abcdef". Here is a cut-and-paste example from the GNU Prolog interpreter:
Quote:
append(X, Y, "abcdef").
X = []
Y = [97,98,99,100,101,102] ? ;
X = [97]
Y = [98,99,100,101,102] ? ;
X = [97,98]
Y = [99,100,101,102] ? ;
X = [97,98,99]
Y = [100,101,102] ? ;
X = [97,98,99,100]
Y = [101,102] ? ;
X = [97,98,99,100,101]
Y = [102] ? ;
X = [97,98,99,100,101,102]
Y = [] ? ;
|
The characters are translated to their ASCII values, but I think you can get the idea of what's going on. Personally, I find the language non-intuitive because it isn't algorithmic like C or Java. Nevertheless, it is very useful for analytical linguists because languages are, after all, sets of rules.
Here is one
tutorial that looks helpful.