- 8.1Built-Ins for Comparisons
- 8.2Math Built-Ins
- 8.3Built-Ins for Boolean Values
- 8.4Built-Ins for Strings
- 8.5Built-Ins for Date, Time and Duration
- 8.6Built-Ins for URIs
- 8.7Built-Ins for Lists

The set of built-ins for SWRL is motivated by a modular approach that will allow further extensions in future releases within a (hierarchical) taxonomy. At the same time, it will provide the flexibility for various implementations to select the modules to be supported with each version of SWRL.

SWRL's built-ins approach is also based on the reuse of existing built-ins in XQuery and XPath, which are themselves based on XML Schema Part 2: Datatypes.

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.

SWRL built-ins are used in builtin atoms. For example, swrlx:builtinAtom identifies a built-in using the swrlx:builtin attribute and lists its arguments as subelements.

Swrl built-ins are identified using the http://www.w3.org/2003/11/swrlb namespace.

- swrlb:equal
(from XQuery op:numeric-equal,
op:compare,
op:boolean-equal
op:yearMonthDuration-equal,
op:dayTimeDuration-equal,
op:dateTime-equal,
op:date-equal,
op:time-equal,
op:gYearMonth-equal,
op:gYear-equal,
op:gMonthDay-equal,
op:gMonth-equal,
op:gDay-equal,
op:anyURI-equal)

Satisfied iff the first argument and the second argument are the same. - swrlb:notEqual
(from swrlb:equal)

The negation of swrlb:equal. - swrlb:lessThan
(from XQuery op:numeric-less-than,
op:compare,
op:yearMonthDuration-less-than,
op:dayTimeDuration-less-than,
op:dateTime-less-than,
op:date-less-than,
op:time-less-than)

Satisfied iff the first argument and the second argument are both in some implemented type and the first argument is less than the second argument according to a type-specific ordering (partial or total), if there is one defined for the type. The ordering function for the type of untyped literals is the partial order defined as string ordering when the language tags are the same (or both missing) and incomparable otherwise. - swrlb:lessThanOrEqual
(from swrlb:lessThan, swrlb:equal)

Either less than, as above, or equal, as above. - swrlb:greaterThan
(from XQuery op:numeric-greater-than,
op:compare,
op:yearMonthDuration-greater-than,
op:dayTimeDuration-greater-than,
op:dateTime-greater-than,
op:date-greater-than,
op:time-greater-than)

Similarly to swrlb:lessThan. - swrlb:greaterThanOrEqual
(from swrlb:greaterThan, swrlb:equal)

Similarly to swrlb:lessThanOrEqual.

The following built-ins are defined for various numeric types. For the relation to be satisfied the arguments all have to belong to some numeric type for which the relation is defined.

- swrlb:add
(from XQuery op:numeric-add)

Satisfied iff the first argument is equal to the arithmetic sum of the second argument through the last argument. - swrlb:subtract
(from XQuery op:numeric-subtract)

Satisfied iff the first argument is equal to the arithmetic difference of the second argument minus the third argument. - swrlb:multiply
(from XQuery op:numeric-multiply)

Satisfied iff the first argument is equal to the arithmetic product of the second argument through the last argument. - swrlb:divide
(from XQuery op:numeric-divide)

Satisfied iff the first argument is equal to the arithmetic quotient of the second argument divided by the third argument. - swrlb:integerDivide
(from XQuery op:numeric-integer-divide)

Satisfied if the first argument is the arithmetic quotient of the second argument idiv the third argument. If the numerator is not evenly divided by the divisor, then the quotient is the xsd:integer value obtained, ignoring any remainder that results from the division (that is, no rounding is performed). - swrlb:mod
(from XQuery op:numeric-mod)

Satisfied if the first argument represents the remainder resulting from dividing the second argument, the dividend, by the third argument, the divisor. The operation a mod b for operands that are xsd:integer or xsd: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 - swrlb:pow

Satisfied iff the first argument is equal to the result of the second argument raised to the third argument power. - swrlb:unaryPlus
(from XQuery op:numeric-unary-plus)

Satisfied iff the first argument is equal to the second argument with its sign unchanged. - swrlb:unaryMinus
(from XQuery op:numeric-unary-minus)

Satisfied iff the first argument is equal to the second argument with its sign reversed. - swrlb:abs
(from XQuery fn:abs)

Satisfied iff the first argument is the absolute value of the second argument. - swrlb:ceiling
(from XQuery fn:ceiling)

Satisfied iff the first argument is the smallest number with no fractional part that is greater than or equal to the second argument. - swrlb:floor
(from XQuery fn:floor)

Satisfied iff the first argument is the largest number with no fractional part that is less than or equal to the second argument. - swrlb:round
(from XQuery fn:round)

Satisfied iff the first argument is equal to the nearest number to the second argument with no fractional part. - swrlb:roundHalfToEven
(from XQuery fn:round-half-to-even)

Satisfied iff the first argument is equal to the second argument rounded to the given precision. If the fractional part is exactly half, the result is the number whose least significant digit is even. - swrlb:sin

Satisfied iff the first argument is equal to the sine of the radian value the second argument. - swrlb:cos

Satisfied iff the first argument is equal to the cosine of the radian value the second argument. - swrlb:tan

Satisfied iff the first argument is equal to the tangent of the radian value the second argument.

- swrlb:booleanNot
(from XQuery fn:not)

Satisfied iff the first argument is true and the second argument is false, or vice versa.

The following built-ins are defined for strings (only), i.e., not untyped literals with language tags.

- swrlb:stringEqualIgnoreCase

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

Satisfied iff the first argument is equal to the string resulting from the concatenation of the strings the second argument through the last argument. - swrlb:substring
(from XQuery fn:substring)

Satisfied iff the first argument is equal to the substring of optional length the fourth argument starting at character offset the third argument in the string the second argument. - swrlb:stringLength
(from XQuery fn:string-length)

Satisfied iff the first argument is equal to the length of the second argument. - swrlb:normalizeSpace
(from XQuery fn:normalize-space)

Satisfied iff the first argument is equal to the whitespace-normalized value of the second argument. - swrlb:upperCase
(from XQuery fn:upper-case)

Satisfied iff the first argument is equal to the upper-cased value of the second argument. - swrlb:lowerCase
(from XQuery fn:lower-case)

Satisfied iff the first argument is equal to the lower-cased value of the second argument. - swrlb:translate
(from XQuery fn:translate)

Satisfied iff the first argument is equal to the second argument with occurrences of characters contained in the third argument replaced by the character at the corresponding position in the string the fourth argument. - swrlb:contains
(from XQuery fn:contains)

Satisfied iff the first argument contains the second argument (case sensitive). - swrlb:containsIgnoreCase

Satisfied iff the first argument contains the second argument (case ignored). - swrlb:startsWith
(from XQuery fn:starts-with)

Satisfied iff the first argument starts with the second argument. - swrlb:endsWith
(from XQuery fn:ends-with)

Satisfied iff the first argument ends with the second argument. - swrlb:substringBefore
(from XQuery fn:substring-before)

Satisfied iff the first argument is the characters of the second argument that precede the characters of the third argument. - swrlb:substringAfter
(from XQuery fn:substring-after)

Satisfied iff the first argument is the characters of the second argument that follow the characters of the third argument. - swrlb:matches
(from XQuery fn:matches)

Satisfied iff the first argument matches the regular expression the second argument. - swrlb:replace
(from XQuery fn:replace)

Satisfied iff the first argument is equal to the value of the second argument with every substring matched by the regular expression the third argument replaced by the replacement string the fourth argument. - swrlb:tokenize
(from XQuery fn:tokenize)

Satisfied iff the first argument is a sequence of one or more strings whose values are substrings of the second argument separated by substrings that match the regular expression the third argument.

The following built-ins are defined for the XML Schema date, time, and duration datatypes, only, as appropriate.

- swrlb:yearMonthDuration
(from XQuery xdt:yearMonthDuration)

Satisfied iff the first argument is the xsd:duration representation consisting of the year the second argument and month the third argument. - swrlb:dayTimeDuration
(from XQuery xdt:dayTimeDuration)

Satisfied iff the first argument is the xsd:duration representation consisting of the days the second argument, hours the third argument, minutes the fourth argument, and seconds the fifth argument. - swrlb:dateTime

Satisfied iff the first argument is the xsd:dateTime representation consisting of the year the second argument, month the third argument, day the fourth argument, hours the fifth argument, minutes the sixth argument, seconds the seventh argument, and timezone the eighth argument. - swrlb:date

Satisfied iff the first argument is the xsd:date representation consisting of the year the second argument, month the third argument, day the fourth argument, and timezone the fifth argument. - swrlb:time

Satisfied iff the first argument is the xsd:time representation consisting of the hours the second argument, minutes the third argument, seconds the fourth argument, and timezone the fifth argument. - swrlb:addYearMonthDurations
(from XQuery op:add-yearMonthDurations)

Satisfied iff the yearMonthDuration the first argument is equal to the arithmetic sum of the yearMonthDuration the second argument through the yearMonthDuration the last argument. - swrlb:subtractYearMonthDurations
(from XQuery op:subtract-yearMonthDurations)

Satisfied iff the yearMonthDuration the first argument is equal to the arithmetic difference of the yearMonthDuration the second argument minus the yearMonthDuration the third argument. - swrlb:multiplyYearMonthDuration
(from XQuery op:multiply-yearMonthDuration)

Satisfied iff the yearMonthDuration the first argument is equal to the arithmetic product of the yearMonthDuration the second argument multiplied by the third argument. - swrlb:divideYearMonthDuration
(from XQuery op:divide-yearMonthDuration)

Satisfied iff the yearMonthDuration the first argument is equal to the arithmetic remainder of the yearMonthDuration the second argument divided by the third argument. - swrlb:addDayTimeDurations
(from XQuery op:add-dayTimeDurations)

Satisfied iff the dayTimeDuration the first argument is equal to the arithmetic sum of the dayTimeDuration the second argument through the dayTimeDuration the last argument. - swrlb:subtractDayTimeDurations
(from XQuery op:subtract-dayTimeDurations)

Satisfied iff the dayTimeDuration the first argument is equal to the arithmetic difference of the dayTimeDuration the second argument minus the dayTimeDuration the third argument. - swrlb:multiplyDayTimeDuration
(from XQuery op:multiply-dayTimeDuration)

Satisfied iff the dayTimeDuration the first argument is equal to the arithmetic product of the dayTimeDuration the second argument multiplied by the third argument. - swrlb:divideDayTimeDuration
(from XQuery op:divide-dayTimeDuration)

Satisfied iff the dayTimeDuration the first argument is equal to the arithmetic remainder of the dayTimeDuration the second argument divided by the third argument. - swrlb:subtractDates
(from XQuery op:subtract-dates)

Satisfied iff the dayTimeDuration the first argument is equal to the arithmetic difference of the xsd:date the second argument minus the xsd:date the third argument. - swrlb:subtractTimes
(from XQuery op:subtract-times)

Satisfied iff the dayTimeDuration the first argument is equal to the arithmetic difference of the xsd:time the second argument minus the xsd:time the third argument. - swrlb:addYearMonthDurationToDateTime
(from XQuery op:add-yearMonthDuration-to-dateTime)

Satisfied iff the xsd:dateTime the first argument is equal to the arithmetic sum of the xsd:dateTime the second argument plus the yearMonthDuration the third argument. - swrlb:addDayTimeDurationToDateTime
(from XQuery op:add-dayTimeDuration-to-dateTime)

Satisfied iff the xsd:dateTime the first argument is equal to the arithmetic sum of the xsd:dateTime the second argument plus the dayTimeDuration the third argument. - swrlb:subtractYearMonthDurationFromDateTime
(from XQuery op:subtract-yearMonthDuration-from-dateTime)

Satisfied iff the xsd:dateTime the first argument is equal to the arithmetic difference of the xsd:dateTime the second argument minus the yearMonthDuration the third argument. - swrlb:subtractDayTimeDurationFromDateTime
(from XQuery op:subtract-dayTimeDuration-from-dateTime)

Satisfied iff the xsd:dateTime the first argument is equal to the arithmetic difference of the xsd:dateTime the second argument minus the dayTimeDuration the third argument. - swrlb:addYearMonthDurationToDate
(from XQuery op:add-yearMonthDuration-to-date)

Satisfied iff the xsd:date the first argument is equal to the arithmetic sum of the xsd:date the second argument plus the yearMonthDuration the third argument. - swrlb:addDayTimeDurationToDate
(from XQuery op:add-dayTimeDuration-to-date)

Satisfied iff the xsd:date the first argument is equal to the arithmetic sum of the xsd:date the second argument plus the dayTimeDuration the third argument. - swrlb:subtractYearMonthDurationFromDate
(from XQuery op:subtract-yearMonthDuration-from-date)

Satisfied iff the xsd:date the first argument is equal to the arithmetic difference of the xsd:date the second argument minus the yearMonthDuration the third argument. - swrlb:subtractDayTimeDurationFromDate
(from XQuery op:subtract-dayTimeDuration-from-date)

Satisfied iff the xsd:date the first argument is equal to the arithmetic difference of the xsd:date the second argument minus the yearMonthDuration the third argument. - swrlb:addDayTimeDurationToTime
(from XQuery op:add-dayTimeDuration-to-time)

Satisfied iff the xsd:time the first argument is equal to the arithmetic sum of the xsd:time the second argument plus the dayTimeDuration the third argument. - swrlb:subtractDayTimeDurationFromTime
(from XQuery op:subtract-dayTimeDuration-from-time)

Satisfied iff the xsd:time the first argument is equal to the arithmetic difference of the xsd:time the second argument minus the dayTimeDuration the third argument. - swrlb:subtractDateTimesYieldingYearMonthDuration
(from XQuery fn:subtract-dateTimes-yielding-yearMonthDuration)

Satisfied iff the yearMonthDuration the first argument is equal to the arithmetic difference of the xsd:dateTime the second argument minus the xsd:dateTime the third argument. - swrlb:subtractDateTimesYieldingDayTimeDuration
(from XQuery fn:subtract-dateTimes-yielding-dayTimeDuration)

Satisfied iff the dayTimeDuration the first argument is equal to the arithmetic difference of the xsd:dateTime the second argument minus the xsd:dateTime the third argument.

The following built-ins are defined for the XML Schema datatypes related to URIs.

- swrlb:resolveURI
(from XQuery op:resolve-uri)

Satisfied iff the URI reference the first argument is equal to the value of the URI reference the second argument resolved relative to the base URI the third argument. - swrlb:anyURI

Satisfied iff the first argument is a URI reference consisting of the scheme the second argument, host the third argument, port the fourth argument, path the fifth argument, query the sixth argument, and fragment the seventh argument.

The following built-ins are defined for RDF-style lists. (Note that these built-ins are not usable in OWL DL or OWL Lite as RDF-style lists can only be used as OWL data in OWL Full.)

- swrlb:listConcat
(from Common Lisp append)

Satisfied iff the first argument is a list representing the concatenation of the lists the second argument through the last argument. - swrlb:listIntersection

Satisfied iff the first argument is a list containing elements found in both the list the second argument and the list the third argument. - swrlb:listSubtraction

Satisfied iff the first argument is a list containing the elements of the list the second argument that are not members of the list the third argument. - swrlb:member

Satisfied iff the first argument is a member of the list the second argument. - swrlb:length
(from Common Lisp list-length)

Satisfied iff the first argument is the length of the list the second argument (number of members of the list). - swrlb:first
(from rdf:first)

Satisfied iff the first argument is the first member of the list the second argument. - swrlb:rest
(from rdf:rest)

Satisfied iff the first argument is a list containing all members of the list the second argument except the first member (the head). - swrlb:sublist

Satisfied iff the list the first argument contains the list the second argument. - swrlb:empty
(from rdf:nil)

Satisfied iff the list the first argument is an empty list.