Logic and Prolog

 A system of logic comprises a set of rules which allow to make a right conclusion from the right facts. Logic has a long history. The earliest  form of logic, as well-known in the West, is Aristotelian Logic. Before that, the first known  system of logic was developed in India by Nyaya-Vaiseshika   philosophical school. Various forms of logic have been used for data representation. They all share one important property - that every logic-based representation is designed to facilitate inference of new facts from existing facts.

The First Order Logic, sometimes called simply Predicate Logic, is widely used as a language of modern mathematics. The representation of the knowledge in Predicate Logic  is based on the following ideas:

 1. Every object (real or abstract) has a unique name

2. Predicates are used to describe properties of objects and relations between them. For example notation farmer(roel) may assert the fact "roel is a farmer"; notation likes(roel,roels_bicycle) means "roel likes roels_bicycle". Here "roel" and "roels_bicycle" are unique names for particular objects of the real world - "Roel" and "Roel's bicycle".  In F-Logic those words which start from capitals denote variables. Therefore, (may Roel excuse us) we have to always start object and class names with small letters.

3. Complex expressions are built with the help of  object variables  , quantifiers , and logical symbols .  There are just two quantifiers (forall x) and (exists x).  Logical symbols usually include at least four: & (read it as 'and'), \/ (or),  ~ (not) , and -> (read it as 'follows'  or as if...then...)    Here are the examples of their use.  The expression

(forall x) (organic_farmer(x)-->farmer(x))

states that "for every  x , if x is an organic farmer , then x is also a farmer".; or "every organic farmer is a farmer".

The expression

(forall x) (farmer(x) --> (exists y)(farm(y)&owns(x,y)))

states that for any farmer  (x) there is a farm (y) which this farmer owns.

As we can see logic-based paradigm for knowledge representation differs from Object Oriented paradigm. Although here we also have objects  like roel, roels_bycicle, and classes like farmer(x), or organic_farmer(x), all properties of objects are stored externally in the form of relations.  Say the relation color(roels_bycicle, black ) may represent an attribute "color"  of the object "roels_bycicle" . However, this relation is not bundled with this object; it is independent. The specific paradigm of knowledge representation  where knowledge is represented in the form of a relation is called relational. The term Relational Database means just that. Prolog is another example of a relational language.

First Order Logic can express almost any assertion about real or abstract objects. But it is not decidable. It is said that a system of logic is not decidable if   there is no any generic algorithm which would allow finding whether a given  expression is a logical consequence of certain given axioms. This implies  that Predicate Logic in its pure form is not of much use in computer applications. Numerous decidable systems of logic were  derived from Predicate Logic. One of such systems was a source of inspiration for PROLOG (which stands for PROgramming in LOGic). Prolog was the first declarative language. Unlike procedural ones, declarative languages do not tell computer "what to do",  rather they tell "what things are". Prolog uses such declarative statements for proving or refuting a given query expressed in terms of Predicate Logic. Prolog often serves as a  language for deductive databases.

More to come......

For more information on logic and PROLOG read Alison Cawsey online book "Databases and Artificial Intelligence".

Here are the direct links: A Chapter on Predicate logic    A Chapter on Prolog

 

Top      |  Previous   |   Next

 

C 2003 S. Krivov  Send your comments to skrivov@zoo.uvm.edu