Previous topic  Top  Next topic  Print this Topic



Before explaining the syntax and semantics in detail, we will give a first impression of ObjectLogic by presenting an ObjectLogic-program using ObjectLogic syntax. We will refer to the contents of this model in later sections of the documentation.

/* schema facts */






         name {1:*} *=> xsd#string,

         age {1:1} *=> xsd#integer,

         friend {0:*} *=> Person].


         owner {1:1} *=>  Person,

         admissibleDriver {1:*} *=>  Person].


         passenger {1:*} *=>  Person,

         seats {1:*} *=>  xsd#integer].


 /* facts */


         name -> "Peter",

         age -> 17].


         name -> "Paul",

         age -> 21,



         name -> "Mary",

         age -> 17].


         owner -> paul].


         owner -> paul].


 /* rules consisting of a rule head and a rule body */

 ?X[friend->?Y] :- ?Y:Person[friend->?X].

 ?X[admissibleDriver->?Y] :- ?X:Vehicle[owner->?Y].

 ?X[admissibleDriver->?Z] :- ?X:Vehicle[owner->?Y] AND ?Y:Person[friend->?Z].


 /* query */

 ?- ?X[admissibleDriver->?Y] AND ?X:Vehicle[owner->paul].


The first section of this example consists of a set of schema facts. The schema represents the classes and their relationships in an object-oriented way, for example, to indicate that car and bike are subclasses of vehicle. It also describes that every vehicle has an owner and potentially multiple admissible drivers, which are persons. The schema also defines that each person has a name and an age of type, string and integer, respectively.

The second section titled "facts", describes that some people belong to the class person and gives information about them, such as their name and age. Also it defines a relationship between the objects namely that Peter is the friend of Paul. According to the object-oriented paradigm, relationships between objects are represented as methods, e.g. applying the method friend to the object Paul yields the result object Peter. All these facts may be considered as the extensional database of the ObjectLogic program. Hence, they form the framework of an object base which is completed by some closure properties.

The rules in the third section of the example derive new information from the given object base. Evaluating these rules in a bottom-up way, new relationships between the objects, denoted by the methods friend and admissibleDriver, are added to the object base as intentional information.

The final section of the example contains a query to the object base. It is asking for all vehicles that are owned by Paul. For each such vehicle it also retrieves the admissible drivers.