Webeks.net - freelance programming
freelance programming - php, Joomla, Zend ...
Home :: Articles :: Programming :: Prolog :: Prolog knowledge base

Prolog knowledge base

Written by Miha

In Prolog there are three basic constructs: facts, rules, and queries. A collection of facts and rules is called a knowledge base (or a database).
The main advantage of Prolog is simple questions asking about the information stored in the knowledge base.

 

Prolog knowledge base example - facts

parent(tea, jan).
parent(rok, jan).
parent(rok, ida).
parent(jan, ana).
parent(jan, eva).
parent(eva, vid).
female(tea).
female(ida).
female(ana).
female(eva).
male(rok).
male(jan).
male(vid).

Prolog query example

female(tea).

Prolog answers

yes

Prolog knowledge base example - rules

mother(tea,jan):-female(tea), parent(tea, jan).

Tea is Jans mother if she is female and his parent.

 


blog comments powered by Disqus