Table of Content. Basic Syntax Elements. Using Namespaces in ObjectLogic Expressions. Numbers, Comparisons and Arithmetic

Страницы работы

25 страниц (Word-файл)

Фрагмент текста работы

ObjectLogic Tutorial

ontoprise GmbH

An der Raumfabrik 33a

76227 Karlsruhe Germany http://www.ontoprise.com

Table of Content

Example................................................................................................................................................5

Syntax Basic Statements................................................................................................................................................6

Schema Level Statements..........................................................................................................................................................................................6

Subclass-of Statements .......................................................................................................................................................................6

Classes Without Any Methods .......................................................................................................................................................................6

Signature Statements .......................................................................................................................................................................6

Instance Level Statements..........................................................................................................................................................................................7

Instance-of Statements .......................................................................................................................................................................7

Signature Statements on Instance Level .......................................................................................................................................................................7

F-Molecules..........................................................................................................................................................................................8

Predicates..........................................................................................................................................................................................9

Basic Syntax Elements................................................................................................................................................10

Terms..........................................................................................................................................................................................10

Lists..........................................................................................................................................................................................11

Examples..........................................................................................................................................................................................11

Namespaces in ObjectLogic..........................................................................................................................................................................................12

Declaring Namespaces .......................................................................................................................................................................12

Default Namespace .......................................................................................................................................................................12

Using Namespaces in ObjectLogic Expressions .......................................................................................................................................................................12

Querying for Namespaces .......................................................................................................................................................................13

Built-in Features................................................................................................................................................14

Numbers, Comparisons and Arithmetic..........................................................................................................................................................................................14

String Handling..........................................................................................................................................................................................14

Aggregations..........................................................................................................................................................................................15

Calculating salaries .......................................................................................................................................................................15

Simple counting example .......................................................................................................................................................................16

ObjectLogic Counting Example .......................................................................................................................................................................17

Handling of Duplicates..........................................................................................................................................................................................18

Rules and Queries................................................................................................................................................19

Rules..........................................................................................................................................................................................19

Queries..........................................................................................................................................................................................20

Range Restriction................................................................................................................................................21

Quantifier Scoping................................................................................................................................................22

Modules................................................................................................................................................23


About this document

There is an Online Help and a user manual available. The Online Help can be accessed via the Help / Help Contents menu. The user manual is available as a PDF on the Web page http://www.otc.ontoprise.com/download and can be downloaded free of charge.

The documentation describes the software on a Windows operating system with the browser Mozilla Firefox. You can access the information using the table of contents, the index and the full text search. If you cannot find the answer to your question in the helpsystem, visit free training center at http://otc.ontoprise.com, area "support", to get in touch with the support team.

Example

1  Example

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 */

Car:Vehicle.

Boat:Vehicle.

Bike:Vehicle.

Person[ name {1:*} *=> xsd#string, age {1:1} *=> xsd#integer, friend {0:*} *=> Person].

Vehicle[ owner {1:1} *=>  Person, admissibleDriver {1:*} *=>  Person].

Car[ passenger {1:*} *=>  Person, seats {1:*} *=>  xsd#integer].

/* facts */ peter:Person[ name -> "Peter", age -> 17]. paul:Person[ name -> "Paul", age -> 21, friend->peter]. mary:Person[ name -> "Mary", age -> 17]. bike26:Bike[ owner -> paul]. car74:Car[ 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.


2  Syntax Basic Statements

According to the logic-programming paradigm, ObjectLogic also provides the notion of predicates which represent the atomic pieces of knowledge (statements), which can be true or false. Since ObjectLogic is also based on the object-oriented paradigm, it not only provides plain predicates (as e.g. known from Prolog) but also offers epistemological primitives for modeling in an object-oriented way, i.e. subclasses, and instancesof relations but also specifications of the signatures for methods or the definition of the values for method applications.

In this section we present the different kinds of statements

Похожие материалы

Информация о работе