Prolog variables

Any word beginning with an upper-case letter is a Prolog variable, which is why I had to be careful to use lower-case initial letters in my earlier examples.

A variable isn’t a name, rather it’s a placeholder for information. Query essentially asks Prolog: tell me which of the individuals you know about is a male.

Prolog will answer:

It doesn’t only say that there is information about at least one male in database, it actually tells us who he is – it actually gave us the variable binding. We can access further information about other possibilities by typing the following simple query:

; means or – this query means: are there any more males? So Prolog begins working through the knowledge base again (it remembers where it got up to last time and starts from there) and sees that if it matches X with jan, then the query agrees perfectly with the second entry in the knowledge base etc.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please prove me that you are not spamer :) * Time limit is exhausted. Please reload CAPTCHA.