So far we have been considering mainly the structures for representation of knowledge. Yet in the section of inheritance we had one example of the derivation of new facts from existing facts. Inheritance of attribute values from a class to its subclass is the most common type of inference one can encounter in ontologies application. However, there are many other types of inferences. In our everyday experience we often relate different attributes of an object. For example if we know that X is the father of Y, we may conclude that Y is the son or the daughter of X.
Consider the following knowledge base (adopted from ....):
henry:man
tim:man[father->henry].
theo:man[father->henry].
paul:man[father->tim].
peter:man[father->tim].
mike:man[father->theo].
john:man[father->paul].
jack:man[father->paul].
cliff:man[father->peter].
abe:man[father->mike].
This in some sense a patriarchal family tree is built around the attribute "father". Here is a graphical representation of the same knowledge base:

dot-code
A human looking at this picture can identify instances of various family
ties - sons, brothers, uncles, nephews, ancestors, descendants. Is there
any easier way to to transferthis knowledge to computer program? For instance, can we
declare a kind of general rule like "
if X is a father of a man Y then Y is a son of X
". The answer is "yes". Logic programming in general and F-Logic
specifically allows us to introduce such rules. To declare the
abovementioned rule F-logic employs the following notation:
F[son->>S] :- S:man[father->F].
The sign ':-' stands for 'if'. A rule "A:-B." suggest that "A is true when B is true"; alternatively you can read it as "A is true because B is true" . In this case A is called the head of rule and B is called the body of the rule. Here head of the rule has label "define" . The body of the rule has label "conditions". Both are outlined in separate frames. Here is the graphic form of the father -son rule:

Here is a slightly
more complex rule that defines the attribute "brother".
X[brother->>Y] :- X[father->Z], Y:man[father->Z], not X=Y.
This rule suggests that Y is a brother of X if both have common father Z, and X is not the same as Y.
Here is the graphic form of the same rule:

The same with explicit logical connections

Any assertion A can be true due to various reasons. Therefore, it is
possible to have simultaneously two or more rules of the form "A:-B.",
" A:-C". Sometimes we need to intentionally combine the rules with the same
head to achieve desired result. As an example consider the following recursive
definition of the attribute ancestor.
X[ancestor->>Y] :- X[father->Y].
X[ancestor->>Y] :- X[ancestor->>Z[father->Y]].
The first rule suggests that Y is an ancestor of X if Y is the father of X. The second (recursive) rule suggests that Y is an ancestor of X if there is Z - ancestor of X, and Y is the father of Z. Here is the graphic form for these couple of rules:
![]() |
![]() |
We can load our knowledge base- all facts and the rules into F-Logic engine such as Flora (if we use Flora we need to change "not" into "tnot"). Having done so we can query our knowledge base . Here are the examples of the queries:
Query 1: ?- F[son->>S].

F-Logic engine performs inference according to specified rules and outputs all the matches for the query which can be deduced from the given knowledge base.
Query2: ?-X[brother->>Y].

?-X[ancestor->>Y].

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