PROLOG - Part 8

There is logic behind everything and every rule. We sometimes negate this but every thing and every happening has a logic and reason behind it.**

PROLOG Internals

In my last post I wrote about cut, fail and repeat. This time I am going to expand the understanding on internals and data structures.

Terms can be constants, variables or a structure.

  • A constant may be an atom or a number - which can be an integer or real number. We defined atom some posts ago. :)
  • A variable is a string of letters, digits and / or underscores starting with a upper-case letter or an underscore.
  • A structure represents an atomic preposition of predicates. Structures have the form blub(t1,t2,t3,...,tn) where blub is our atom and t1,t2,…,tn are our parameters. n is also the arity of our term.

Keep in mind: there is no type declaration in PROLOG. The interpreter will figure it out for you. :)

Read More

PROLOG - Part 7

Because proofs are boring. That is a given!

Controlling PROLOG

In my last post I introduced the concept of backtracking and as promised, this time I will be writing about cut, fail and repeat.

Cut

There are two main reasons to understand and use the cut feature:

Read More

PROLOG - Part 6

Logic: The art of thinking and reasoning in strict accordance with the limitations and incapacities of the human misunderstanding. Ambrose Bierce

Power PROLOG \o/

In my last post we finally wrote our “Hello World!” in PROLOG. I hope you all bare with me, so we can finally start to explore the fun and powerful features of PROLOG. In this post, I am going to write about Backtracking.

Backtracking

When PROLOG is looking for instances that satisfies a clause, it will, whenever it is needed, perform what we call Backtrack.

Read More