Skip to content

SWRLTemporalBuiltInsBasic

Martin O'Connor edited this page Aug 12, 2016 · 3 revisions

Table of Contents

Basic Mode

The SWRL Temporal Built-In Library is one of the SWRLAPI's built-in libraries. It defines a set of built-ins that can be used in SWRL rules to perform temporal operations. This library supports both basic and advanced modes for working with temporal information. This document describes the use these temporal built-ins in the basic mode. Details of the advanced mode can be found here.

In this mode the temporal built-ins in this library work with temporal information specified by XML Schema date and dateTime types and determine if this information satisfies the relevant temporal predicate at a particular granularity.

Some built-ins in this library require a granularity argument. This argument can be supplied as an xsd:string. The possible values are: Years, Months, Days, Hours, Minutes, Seconds, and Milliseconds. Case is not significant.

If no granularity is specified, , the finest granularity supported by the library (i.e., milliseconds) is used. Incomplete XML Schema date and dateTime literal specifications are allowed. For example, 1998-12-02T12 is allowed as a dateTime value.

Temporal Built-ins

The following built-ins are defined in this library:

duration

A predicate that is satisfied if the first duration argument is equal to the difference between two XML Schema date or dateTime arguments at the granularity specified by the final argument. If the duration argument is unbound, it is assigned to the time difference between the two timestamps at the granularity specified by the final argument. A granularity argument is required for this built-in.

durationLessThan, durationEqualTo, durationGreaterThan

This predicate is satisfied if the the first duration argument is less than, equal to, or greater than the difference between two XML Schema date or date Time argument at the granularity specified by the final argument. All arguments must be bound and a granularity argument is required for this built-in.

notDurationLessThan, notDurationEqualTo, notDurationGreaterThan

These built-ins simply implement the inverse of the duration operators.

equals, before, after, meets, metBy, overlaps, overlappedBy, contains, during, starts, startedBy, finishes, finishedBy

These built-ins implement the standard Allen temporal operators and apply them to two intervals. Both of the intervals may be specified as a single timepoint, in which case they are converted into an interval with the same start and finish time. When used with xsd:date or xsd:dateTime types these built-ins take up to five arguments. The final optional argument specifies the granularity of the operation. If no granularity is specified, the finest granularity supported by the library (i.e., milliseconds) is used. The preceding arguments with either be two timestamps representing instances, or four timestamps representing the start and finish times of two intervals.

notEquals, notBefore, notAfter, notMeets, notMetBy, notOverlaps, notOverlappedBy, notContains, notDuring, notStarts, notStartedBy, notFinishes, notFinishedBy

These built-ins simply implement the inverse of the standard Allen operators. The argument structure is the same as that of the Allen operator built-ins.

add

This built-in returns true if the first timestamp argument is equal to the second timestamp argument plus the third count argument at the granularity specified by the fourth argument. If the first argument is unbound, it is assigned the result of the addition. A granularity argument is required for this built-in. E.g., temporal:add(?t, "1999-11-01T10:00", 4, "Years"). A negative count argument can be used to perform subtraction.

Current Time

The library also supports the notion of the current time. This time stamp can be specified using the value "now" as a time specification.

Examples

The following are some example uses of the built-ins defined in this library, all of which evaluate to true.

temporal:duration(2, "1999-11-01T10:00", "2001-02-01T11:12:12.000", "Years")

temporal:before("1999-11-01T10:00", "2000-02-01T11:12:12.000")

temporal:equals("1999-11-01T10:00", "1999-11-21T11:21", "Months")

temporal:before("1999-11-01T10:00", "2005-01-31T09:014")

temporal:overlaps("1999-11-01T10:00", "1999-12-11", "1999-12-01T09:014", "2000")

temporal:notBefore("2003", "2001")

temporal:notBefore("2003", "now")

temporal:duration(?d, "1999", "now", "Years")