For a majority of main stream project work, the most common paradigms developers will make use of are object-oriented or imperative programming type approaches. However, when the need is to solve logic based problems, i.e., define the logic but not the detailed control flow [procedural instructions], then using the declarative approach makes Prolog an excellent choice. By doing so, the problem domain can be expressed as facts and rules instead of a logical sequence of instructions where we only need to ask the questions and let the program solve for the solutions.

There is an introductory course to Prolog that explains the idea very neatly. Learn Prolog Now. “Prolog enables the computer to logically deduce new facts about the situations we describe, and gives its deductions back to us as answers.”

There are several important ramifications to using a language like Prolog, but one reason most notably ranking near the top of the list is that it allows for rapid prototyping because it’s such a high-level language.

As I write this, one of the projects underway is a “contextual biblical search tool” of sorts. To give an idea of how facts can be incredibly abstract in support of RAD (rapid application development), here are a few facts within our knowledge base.

created('God', 'heavens').
created('God', 'earth').

beginning('earth', 'without shape').
beginning('earth' 'empty').

said('God', 'Let there be light.').

Now we’d like to ask a question in the relation of created by using the variable X. I.e., “who created the heavens?”

?- created(X, 'heavens').

And Prolog will unify X with the following.

X = 'God'.

Or ask, “what was the earth like in the beginning?”

?- beginning('earth', X).
X = without shape;
X = empty.

We haven’t even begun to scratch the surface of what Prolog is capable of and though this example is extremely simplified, to understand how this result was returned is one of the most fundamental concepts of the Prolog strategy. Namely, Unification and Proof Search.

If you’re working in a domain rich with knowledge and would like to get started as soon as possible and by-pass a lot of preliminary work, Prolog makes an excellent tool of choice. The programming is very high-level, but like everything else, it’s all in the details. Invest the time to learn it, and doing proof-of-concept will compliment your designs specifications in ways you may not have imagined.

Would you like to be notified of future posts?

Gary is the principal software developer at NeuroQuest Software. An accomplished developer with over 26 years of experience largely dedicated to Open Source, his former position was spent working with NASA for nearly 15 years.