PROLOG - Part 5

Against logic there is no armor like ignorance.

I/O in PROLOG

Until the last post, we saw how to build rules and query facts. But all we can see as “answer” until now are some ‘yes’ or ‘false’. Pretty boring hum… But as in other languages, PROLOG also offers I/O support: please meet the methods read() and write().

Finally our PROLOG “Hello world!”

Read More

PROLOG - Part 4

“Bad reasoning as well as good reasoning is possible; and this fact is the foundation of the practical side of logic.” Charles Sanders Peirce

Including rules

Until the last post, we have been working with simple clauses. In this post I am giving an introduction the concept of rules.

Back to our family example

Right now we have a list of parents. If we want, we can also implement the same list for children, exchanging the order of the names inside the property. OR we can do it a bit better: Using rules!

Read More

PROLOG - Part 3

Logic will get you from A to B. Imagination will take you everywhere.

More theory …

After last post theoretical questions were open and the time for the writing was out. I will try to answer some of them now =)

First order logic and Unification

First-order logic (FOL) or also called predicate logic has one or more arguments for each predicate and utilizes quantifiers (“for all” and “at least one”). First-order logic is simple but enough to formalize all classic mathematics. A first-order theorem, for example, consists in a set of axioms and sentences that we can reduce from them.

PROLOG is based on FOL and for that, in PROLOG one has the first-order unification algorithm implicit. Unification in logic is nothing more than an algorithmic process to solve systems of symbolic expressions. The solution of an unification problem is like a map of symbolic values for each variable in the system.

Read More