**From:** *stabet@comcast.net*

**Date:** 01/27/04

**Previous message:**Mike Dean: "RE: datatype comparisons and arithmetic conversions"**Messages sorted by:**[ date ] [ thread ] [ subject ] [ author ] [ attachment ]**Mail actions:**[ respond to this message ] [ mail a new topic ]

Hi everyone, attached, please find the latest update to the built-ins document, now in html (as section 8 of the proposal). thanks, Said

- 8.1Built-Ins for Handling XML Data Types
- 8.2Math Operators and Functions
- 8.3Built-In Functions and Operators over Boolean Values
- 8.4Built-In Functions on Strings
- 8.5Built-In Functions and Operators on Date, Time and Duration
- 8.6Built-In Functions for QNames and URIs
- 8.7Built-Ins for Lists
- 8.8Built-ins for module handling
- 8.9Other Possible Built-Ins

The proposed hierarchy of built-ins for SWRL is motivated by a modular approach that will allow further extensions in future releases of SWRL. At the same time, it will provide the flexibility for various implementations to select the level of hierarchy to be support with each version of SWRL.

SWRL's built-ins approach is also based on the reuse of existing built-ins in XQuery and XPath, themselves derived from XML data types part 2 built-ins. Some other built-ins are specific to SWRL, OWL, and RuleML, dealing with fact and rule prioritization.

This system of built-ins should also help in the interoperation of SWRL with other Web formalisms by providing an extensible, modular built-ins infrastructure for Semantic Web Languages, Web Services, and Web applications.While we suggest to have a top level distinction between the following two categories:

- Side-effect free built-ins
- Side-effect full built-ins

the SWRL language will only provide support for side-effect free built-ins.

Even though the taxonomy may appear to be quite large, users only need to load the relevant ones.

Like in OWL, our approach is to integrate XML Schema Part 2: Datatypes and reuse operators and functions from XQuery 1.0 and XPath 2.0

The swrl presentation and XML/RDF syntax defines an abstraction layer on top of operators and functions. Comparison operators should be singled out as they return boolean values. They are defined as predicates in OWL.

Operators:- op:numeric-add

Backs up the "+" operator and returns the arithmetic sum of its operands - op:numeric-subtract

Backs up the "-" operator and returns the arithmetic difference of its operands - op:numeric-multiply

Backs up the "*" operator and returns the arithmetic product of its operands - op:numeric-divide

Backs up the "div" operator and returns the arithmetic quotient of its operands - op:numeric-integer-divide

Backs up the "idiv" operator and returns the arithmetic quotient of its operands: ($arg1 idiv $arg2). If the numerator is not evenly divided by the divisor, then the quotient is the xs:integer value obtained, ignoring any remainder that results from the division (that is, no rounding is performed). - op:numeric-mod

Backs up the "mod" operator. Informally, this function returns the remainder resulting from dividing $arg1, the dividend, by $arg2, the divisor. The operation a mod b for operands that are xs:integer or xs:decimal, or types derived from them, produces a result such that (a idiv b)*b+(a mod b) is equal to a and the magnitude of the result is always less than the magnitude of b. This identity holds even in the special case that the dividend is the negative integer of largest possible magnitude for its type and the divisor is -1 (the remainder is 0). It follows from this rule that the sign of the result is the sign of the dividend - op:numeric-unary-plus

Backs up the unary "+" operator and returns its operand with the sign unchanged: (+ $arg). Semantically, this operation performs no operation - op:numeric-unary-minus

Backs up the unary "-" operator and returns its operand with the sign reversed: (- $arg). If $arg is positive, its negative is returned; if it is negative, its positive is returned

Comparison predicates:

- op:numeric-equal

Satisified iff the value of $arg1 is equal to the value of $arg2. - op:numeric-less-than

Satisfied iff $arg1 is less than $arg2 - op:numeric-greater-than

Satisfied iff $arg1 is greater than $arg2

Built-In Functions:

- fn:abs

Returns the absolute value of the argument - fn:ceiling

Satisfied iff the output value is the smallest number with no fractional part that is greater than or equal to the argument - fn:floor

Satisfied iff the output value is the largest number with no fractional part that is less than or equal to the argument. - fn:round

Satisfied iff the output value is rounded to the nearest number with no fractional part. - fn:round-half-to-even

Takes a number and a precision. It is satisfied iff the output value is a number rounded to the given precision. If the fractional part is exactly half, the result is the number whose least significant digit is even.

"fn:not" is a function built-in where fn:not(true) returns false and fn:not(false) returns true.

One operator and one function are proposed:

- op:boolean-equal
- fn:boolean-not

The following built-in functions are proposed:

- fn:compare

Compares two input string arguments $string1 and $string2. Satisfied iff the output value is -1, 0, or 1, depending on whether the value of the $string1 is respectively less than, equal to, or greater than the value of $string2. - fn:string-less-than

Satisfied iff the first string argument is less than the second string argument when ordered according to Unicode(tm) code order - fn:string-greater-than

Satisfied iff the first string argument is greater than the second string argument when ordered according to Unicode(tm) code order - fn:string-equal

Satisfied iff the first string argument is the same as the second string argument (case sensitive). - fn:string-equal-ignore-case

Satisfied iff the first string argument is the same as the second string argument (upper/lower case ignored) - fn:string-concat

Satisfied iff the output value is a string resulting in the concatenation of two or more strings. - fn:substring

Satisfied iff the output value is the string located at a specified location in an input string - fn:string-length

Satisfied iff the output value is the length of the string argument. - fn:normalize-space

Satisfied iff the output value is the whitespace-normalized value of the argument. - fn:upper-case

Satisfied iff the output value is the upper-cased value of the argument. - fn:lower-case

Satisfied iff the output value is the lower-cased value of the argument. - fn:translate

Satisfied iff the output value is the first string argument with occurrences of characters contained in the second argument replaced by the character at the corresponding position in the third argument. - fn:contains

Satisfied iff the output value is the first string argument contains the second string argument (case sensitive) - fn:contains-ignore-case

Satisfied iff the output value is the first string argument contains the second string argument (case ignored) - fn:starts-with

Satisfied iff the output value is the first string argument starts with the second string argument. - fn:ends-with

Satisfied iff the output value is the first string argument ends with the second string argument. - fn:substring-before

Satisfied iff the output value is the collation units of the first string argument that precede in that string the collation units of the second string argument. - fn:substring-after

Satisfied iff the output value is the collation units of the first string argument that follow in that string the collation units of the second string argument. - fn:matches

Satisfied iff the output value is the value of the first argument is matched by the regular expression that is the value of the second argument. - fn:replace

Satisfied iff the output value is the value of the first argument with every substring matched by the regular expression that is the value of the second argument replaced by the replacement string that is the value of the third argument. - fn:tokenize

Satisfied iff the output value is a sequence of one or more strings whose values are substrings of the value of the first argument separated by substrings that match the regular expression that is the value of the second argument. - fn:string-diff

Satisfied iff the output value is the string representing the diff between the two inpur string arguments (case sensitive) - fn:string-diff-ignore-case

Satisfied iff the output value is the string representing the diff between the two inpur string arguments (case ignored)

The following set of built-ins is directly imported from XQuery. They are built-in operations on the date and time types as defined in XML Schema Part 2 Datatypes.

Details on each operation can be found here

Base Operators:

- op:yearMonthDuration-equal
- op:yearMonthDuration-less-than
- op:yearMonthDuration-greater-than
- op:dayTimeDuration-equal
- op:dayTimeDuration-less-than
- op:dayTimeDuration-greater-than
- op:dateTime-equal
- op:dateTime-less-than
- op:dateTime-greater-than
- op:date-equal
- op:date-less-than
- op:date-greater-than
- op:time-equal
- op:time-less-than
- op:time-greater-than
- op:gYearMonth-equal
- op:gYear-equal
- op:gMonthDay-equal
- op:gMonth-equal
- op:gDay-equal

Accessors for Date, Time and Duration:

- fn:get-years-from-yearMonthDuration
- fn:get-months-from-yearMonthDuration
- fn:get-days-from-dayTimeDuration
- fn:get-hours-from-dayTimeDuration
- fn:get-minutes-from-dayTimeDuration
- fn:get-seconds-from-dayTimeDuration
- fn:get-year-from-dateTime
- fn:get-month-from-dateTime
- fn:get-day-from-dateTime
- fn:get-hours-from-dateTime
- fn:get-minutes-from-dateTime
- fn:get-seconds-from-dateTime
- fn:get-timezone-from-dateTime
- fn:get-year-from-date
- fn:get-month-from-date
- fn:get-day-from-date
- fn:get-timezone-from-date
- fn:get-hours-from-time
- fn:get-minutes-from-time
- fn:get-seconds-from-time
- fn:get-timezone-from-time

Advanced Built-In Operators

- op:add-yearMonthDurations
- op:subtract-yearMonthDurations
- op:multiply-yearMonthDuration
- op:divide-yearMonthDuration
- op:add-dayTimeDurations
- op:subtract-dayTimeDurations
- op:multiply-dayTimeDuration
- op:divide-dayTimeDuration
- op:subtract-dates
- op:subtract-times
- op:add-yearMonthDuration-to-dateTime
- op:add-dayTimeDuration-to-dateTime
- op:subtract-yearMonthDuration-from-dateTime
- op:subtract-dayTimeDuration-from-dateTime
- op:add-yearMonthDuration-to-date
- op:add-dayTimeDuration-to-date
- op:subtract-yearMonthDuration-from-date
- op:subtract-dayTimeDuration-from-date
- op:add-dayTimeDuration-to-time
- op:subtract-dayTimeDuration-from-time

Advanced Built-In Functions

- fn:subtract-dateTimes-yielding-yearMonthDuration
- fn:subtract-dateTimes-yielding-dayTimeDuration

In the previous telecon, we decided to leave the QNames built-ins out. Here is a list of proposed operators and functions:

- fn:resolve-uri
- op:anyURI-equal

Satisfied iff $arg1 and $arg2 compare equal on a codepoint-by-codepoint basis. Otherwise, returns FALSE. - fn:uri-protocol

Satisfied iff the output value is the URI protocol as a string - fn:uri-host

Satisfied iff the output value is a string containing the fully qualified DNS host name or IP address of the server specified in the URI - fn:uri-port

Satisfied iff the output value is the integer port number of the input URI argument - fn:uri-fragment

Satisfied iff the output value is a URI fragment as a string

There are three basic operators:

- op:list-concatenation

Satisfied iff the output value is a list representing the concatenation of the two input list arguments. - op:list-intersection

Satisfied iff the output value is a list representing the intersection of the two input list arguments. - op:list-subtraction

Satisfied iff the output value is a list containing the elements of the first list argument that are not member of the second list argument.

Built-ins functions for lists:

- fn:member

Satisfied iff the output value is the first argument is a member of the second argument (a list) - fn:length

Satisfied iff the output value is the length of the list (number of elements member of the of the list) - fn:head

Satisfied iff the output value is the first member of the list argument - fn:tail

Satisfied iff the output value is a list containing all members of the list argument except the first element (the head). - fn:sublist

Satisfied iff the output value is the first list argument contains the second list argument. - fn:contains

Satisfied iff the output value is the first list argument contains the second list argument.

The following functions may be introduced to manipulate modules in SWRL:

- fn:declareModule

This is a constructor allowing the creation of new modules. It is not fully side-effect free - fn:setModule

This is a side-effectfull built-in function - fn:getModuleInfo

Returns the detailed info given a declared module name. (We need to clarify what info is returned) - fn:listModules

Returns the list of declared modules

This section focuses on built-ins extensions including, as listed below, various classes of built-ins, some of them outside the SWRL Kernel, and others are implementation and API level built-ins.

- Control Built-ins: side-effectfull
- Database Built-ins
- Term Comparison Built-ins
- Term Manipulation Built-ins
- Stream I/O Built-ins
- Character I/O Built-ins
- Term I/O Built-ins
- Event Handling Built-ins
- Debugging Built-ins
- Arrays and Global Variable Built-ins
- Coroutining Built-ins
- External Interface Built-ins (imports)
- Prolog Environment Built-ins
- Compiler Directives Built-Ins
- Operating System Built-Ins
- Sorting Library predicates Built-ins

It could also be allowed to extend the Taxonomy by defining further built-ins on the level of the implementation language of the SWRL built-ins.

**NOTE: **Built-ins for sequences and nodes are not currently supported in SWRL. They can be left as optional for the specification implementations.

**Next message:**Mike Dean: "Joint Committee telecon today 3 February"**Previous message:**Mike Dean: "RE: datatype comparisons and arithmetic conversions"**Messages sorted by:**[ date ] [ thread ] [ subject ] [ author ] [ attachment ]**Mail actions:**[ respond to this message ] [ mail a new topic ]

*
This archive was generated by hypermail 2.1.4
: 01/27/04 EST
*