## an exercise with math equations…

I’ve just found out that I can write complex math equations using Latex syntax on WP. Here’s my first try:

Wow! Great! Learned this from this blog post.

## Representing and Processing Time & Dates

### 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, http://www.etri.re.kr/2003/10/bossam-builtin#, is the reserved namespace for designating Bossam’s builtin functions. Let’s assume func corresponds to http://www.etri.re.kr/2003/10/bossam-builtin#.*

`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`

- returns true if time-const1 follows
`func:before(time-const1,time-const2)`

- returns true if time-const1 precedes
`time-const2`

- returns true if time-const1 precedes
`func:containedIn(time-const1,time-begin,time-end)`

- returns true if
`time-const1`

is in the duration formed by`time-begin`

and`time-end`

- returns true if

A sample rulebase utilizing time constants is shown below.

prefix xsd = http://www.w3.org/2001/XMLSchema#; prefix rdfs = http://www.w3.org/2000/01/rdf-schema#; prefix func = http://www.etri.re.kr/2003/10/bossam-builtin#; namespace is http://etri.re.kr/2003/10/Bossam#; 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 if birthdate(?x,?date1) and birthdate(?y,?date2) and [func:after(?date1,?date2) = true] then isYoungerThan(?x,?y); rule r2 is if birthdate(?x,?date1) and birthdate(?y,?date2) and [func:before(?date1,?date2) = true] then isOlderThan(?x,?y); 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 if endsAt(?m1,?t1) and beginsAt(?m2,?t2) and [func:after(?t2,?t1) = true] then Compatible(?m1,?m2); }

### 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]);

## Creating OwlTrMReasoner

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 r.silentRun();

## Rule Generating Rules

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

rule r is if father(?x,?y) then 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!

## Bossam 0.9b45 Released

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: http://projects.semwebcentral.org/projects/bossam/

## A new Bossam on Feb. 5

A new Bossam release is planned on Feb. 5, 2007.

The new release will include better OWL DL reasoning supports:

- Enhanced coverage on classification based on boolean compositions of classes
- Enhanced coverage on classification based on nominals (
`owl:oneOf`

)

Also, a new rule construct is introduced: **rule-generating rules (RGR)**. With RGR, it’s possible to assert a rule at the consequent as shown below.

rule r is

if causality(?cause, ?result)

then

assert if ?cause then ?result;

RGR will help representing more complex knowledge and optimizing knowledge structure!

Also on performance-side, the RETE core of Bossam is well optimized and it gives a lot better performance than before!

## [BUG] `xsd:boolean`

value reading error

A bug in reading `xsd:boolean`

value is reported.

Boolean value literals – `"true", "false"`

– which are of type `xsd:boolean`

are misinterpreted by Bossam.

The bug-fix will be included in the next build which will be released on Feb. 05, 2007. Thanks.

(note) Fixed by 0.9b45 release. (2007/02/08)