Archive for the ‘bossam’ Category


August 18, 2007 6 comments

I am working on a new release of Bossam. The upcoming release features a newly designed API. The new API exposes more interfaces for accessing the knowledge object model. You’ll be able to create and manipulate fact and rule objects, which will open better support for programming in rules.

The new Bossam operates in push model, like SAX. It pushes derivations and inconsistencies to the listeners that listen to the events generated from the reasoner. Creating a reasoner and executing a reasoning session looks as follows.

// Create a reasoner with the OWL reasoning capability
IReasonerFactory f = ReasonerFactory.getInstance();
IReasoner r = f.createReasoner(ModelType.OWL);
// Read an OWL document specified in N3 from a URL, Syntax.N3,
// Set a listener for events from the reasoner
IReasonerListener l = new MyReasonerListener();
// Execute a reasoning session.
// Derivations are pushed to the listener;

The reasoner listener interface has three methods:

  • void onDerivation(IFact f): called when a new fact is derived.
  • void onDerivation(IRule r): called when a new rule is derived.
  • void onInconsistency(IExplanation e): called when an inconsistency is encountered.

As seen in the example code, it’s possible to specify the syntax and the content model when reading in knowledge. For example, if an OWL document specified in RDF/XML is given, it’s possible to read in the document in two ways: either as a plain RDF document or as an OWL document, as shown below.

  • Read the document as a plain RDF document:, Syntax.RDFXML, "http://.....");
  • Read the document as an OWL document:, Syntax.RDFXML, "http://....");

As such, the new Bossam release will come with new API set, which will not be compatible with the previous releases. Any opinions on the new API and the compatibility issue are welcomed.

The new release will also feature user-defined builtin functions and (limited but working) forgetting.

Stay tuned and let me know if you have any idea to be accompanied to the new release. Thanks!

Categories: bossam

Be sure to add all the JAR files to your project.

July 4, 2007 5 comments

When you build a Java application that uses bossam, you need to include all the JAR files distributed with bossam to the classpath of the Java application. You can find the JAR files under bin directory of the bossam release.

Categories: bossam

An error in the code sample for RDF/OWL Ontology Querying fixed

July 4, 2007 Leave a comment

I’ve just realized that the sample code I presented in my previous post has some error. The base namespace of the wine ontology is not correct in the code. I’ve just fixed it and the code correctly works!

Categories: bossam

Representing and Processing Time & Dates

February 20, 2007 Leave a comment

Time Data Types

(Some of the features explained in this post are available in the next Bossam release.)

With Bossam, time data can be represented and processed. The following time types supported.

Date (corresponds to xsd:date)

  • Syntax: yyyy-MM-dd
  • Example: 2004-10-09

Time (corresponds to xsd:time)

  • Syntax: HH:mm:ss
  • Example: 22:10:30

DateTime (corresponds to xsd:dateTime)

  • Syntax: yyyy-MM-dd'T'HH:mm:ss
  • Example: 2004-10-09T22:10:30

Time Duration (corresponds to xsd:duration)

(refer to XSD Duration on how to write time durations)

  • ex1) P10Y9M8DT10H9M8S represents 10 years 9 months 8 days 10 hours 9 minutes 8 seconds.
  • ex2) P10Y8DT10H represents 10 years 8 days 10 hours.
  • ex1) P10Y9M8D represents 10 years 9 months 8 days.
  • ex1) PT10H9S represents 10 hours 9 seconds.

Getting the Current Time/Date

Three builtin functions are available for getting the current time, current date, and current dateTime, as follows.
The namespace URI,, is the reserved namespace for designating Bossam’s builtin functions. Let’s assume func corresponds to

  • func:thisTime(): returns the current time
  • func:thisDate(): returns the current date
  • func:thisDateTime(): returns the current date-time

Builtin Functions for Comparing Date/Time

There are three builtin functions for processing time data.

  • func:after(time-const1,time-const2)
    • returns true if time-const1 follows time-const2
  • func:before(time-const1,time-const2)
    • returns true if time-const1 precedes time-const2
  • func:containedIn(time-const1,time-begin,time-end)
    • returns true if time-const1 is in the duration formed by time-begin and time-end

A sample rulebase utilizing time constants is shown below.

prefix xsd =;
prefix rdfs =;
prefix func =;
namespace is;
rulebase TimeConstants
 class Person;
 property birthdate for Person is xsd:date;
 individual John is Person and birthdate = 1970-10-05;
 individual Sam is Person and birthdate = 1970-05-05;

 rule r1 is
  birthdate(?x,?date1) and birthdate(?y,?date2)
  and [func:after(?date1,?date2) = true]

 rule r2 is
  birthdate(?x,?date1) and birthdate(?y,?date2)
  and [func:before(?date1,?date2) = true]

 fact f01 is beginsAt(MeetingA,2005-10-04T12:00:00);
 fact f02 is endsAt(MeetingA,2005-10-04T15:00:00);
 fact f03 is beginsAt(MeetingB,2005-10-04T14:00:00);
 fact f04 is endsAt(MeetingB,2005-10-04T17:00:00);
 fact f05 is beginsAt(MeetingC,2005-10-04T16:00:00);
 fact f06 is endsAt(MeetingC,2005-10-04T17:00:00);

 rule CompatibleMeetings is
  endsAt(?m1,?t1) and beginsAt(?m2,?t2)
  and [func:after(?t2,?t1) = true]

Expressions on Time Data

Simple addition and subtraction on time and duration can be processed.

Calculating Time Difference

By subtracting a time from another time, it’s possible to calculate the difference between the two time points. Some examples follow:

  • 2005-10-20 - 2005-09-10 gives P0Y0M40DT0H0M0S which is 40 days.
  • 23:10:20 - 10:30:40 gives P0Y0M0DT12H39M40S which is 12 hours 39 minutes 40 seconds.
  • 2007-12-31T24:00:00 - 2007-02-20T10:48:18 gives P0Y0M314DT13H11M42S which is 314 days 13 hours 11 minutes 42 seconds.

As such, it’s possible to get a time difference between two points in time.

Forwarding and Backwarding Times

By adding a duration to a time, we get a forwarded time. By subtracting a duration from a time, we get a bacwarded time. Addition examples follow:

  • 0003-12-10 + P1Y1M1D gives 0005-01-11.
  • 0003-12-10 + P13M9D gives 0005-01-19.
  • 12:10:20 + PT1H1M1S gives 13:11:21.
  • 12:10:20 + PT13H20M30S gives 01:30:50.
  • 0003-12-10T12:10:20 + P1Y1M1DT1H1M1S gives 0005-01-11T13:11:21.
  • 0003-12-10T12:10:20 + P1Y13M2DT13H20M30S gives 0006-01-13T01:30:50.

Subtraction examples follow:

  • 0003-12-10 - P1Y1M1D gives 0002-11-09.
  • 0003-12-10 - P13M9D gives 0002-11-01.
  • 12:10:20 - PT1H1M1S gives 11:09:19.
  • 12:10:20 - PT13H20M30S gives 22:49:50.
  • 0003-12-10T12:10:20 - P1Y1M1DT1H1M1S gives 0002-11-09T11:09:19.
  • 0003-12-10T12:10:20 - P1Y13M2DT13H20M30S gives 0001-11-07T22:49:50.

Some rule examples are as follows.

fact f is time(2002-10-10);
fact g is time(2002-12-31);
rule r is
   if time(?t1) and time(?t2)
   then result([?t1 - ?t2]);

fact f is time(2002-10-10);
fact g is duration(P10Y3M);
rule r is
   if time(?t) and duration(?d)
   then result([?t - ?d]);

fact f is time(12:30:00);
fact g is duration(PT1H30M);
rule r is
   if time(?t) and duration(?d)
   then result([?t + ?d]);

fact f is time(2002-10-10T12:30:00);
fact g is duration(P10DT1H30M);
rule r is
   if time(?t) and duration(?d)
   then result([?t - ?d]);
Categories: bossam, manual

Creating OwlTrMReasoner

February 7, 2007 3 comments

OwlTrMReasoner is a new OWL-DL reasoner added to Bossam. This reasoner is the most recommended OWL reasoner among the reasoners provided by Bossam. The following is the sample codes for creating and utilizing the reasoner.

// Create a reasoner
IReasonerFactory factory = ReasonerFactory.getInstance();
IReasoner r = factory.createOwlDlTrMReasoner();
// Load an ontology
r.load(IReasoner.OWL, "....");
// Perform a silent reasoning session, 
//  which does not return conclusions
Categories: bossam, manual

Rule Generating Rules

February 7, 2007 Leave a comment

Bossam supports asserting rules at the consequent of rules. Here’s a simple example.

rule r is
   if father(?x,?y)
      assert if Man(?x) then hasChild(?x);

The pattern at the consequent part is called the rule template. Instead of deriving facts, RGRs generate rule instances from the rule templates.

I believe that RGR will be very useful for encoding dynamic & complex knowledge. Also, RGR is an essential tool for performance optimization because it’s possible to reduce the number of facts by utilizing RGRs.

Hope RGRs be of a useful toy for Bossam users!

Categories: bossam, manual

Bossam 0.9b45 Released

February 7, 2007 1 comment

This release includes several enhancements and new features. (1) The RETE core of Bossam is redesigned and it shows a significant improvement. (2) A more elaborated and advanced OWL reasoner, OwlDlTrMReasoner, is added. This reasoner performs OWL reasoning based on elaborated translation and meta-rules. It covers a lot more of OWL reasoning than OwlDlTrHReasoner. Performance measures against famous ontologies and LUBM will soon be posted. (3) It’s possible to assert a rule at the head of rules. These rules, called rule-generating rules (RGR), enable writing more complex & dynamic knowledge and optimizing knowledge structure and performance.

Binary download is available at:

Categories: bossam, news