Difference between revisions of "DTB"
AxelPolleres (Talk  contribs) 
AxelPolleres (Talk  contribs) (→Datatypes) 

(One intermediate revision by one user not shown)  
Line 130:  Line 130:  
<li><span id="rdfPlainLiteralspace" class="anchor"><tt>rdf:PlainLiteral</tt></span> (<tt><nowiki>http://</nowiki>www.w3.org/1999/02/22rdfsyntaxns#text </tt>, short name: <tt>text</tt>).</li>  <li><span id="rdfPlainLiteralspace" class="anchor"><tt>rdf:PlainLiteral</tt></span> (<tt><nowiki>http://</nowiki>www.w3.org/1999/02/22rdfsyntaxns#text </tt>, short name: <tt>text</tt>).</li>  
</ul>  </ul>  
−  
<p>The <tt>rdf:PlainLiteral</tt> symbol space represents text strings with a language tag attached. The lexical space of <tt>rdf:PlainLiteral</tt> is defined in the document <nowiki>[</nowiki>[[#refrdfPlainLiteralRDFPLAINLITERAL]]].</p>  <p>The <tt>rdf:PlainLiteral</tt> symbol space represents text strings with a language tag attached. The lexical space of <tt>rdf:PlainLiteral</tt> is defined in the document <nowiki>[</nowiki>[[#refrdfPlainLiteralRDFPLAINLITERAL]]].</p>  
−  
−  
−  
<ul>  <ul>  
<li><span id="rdfxmlliteralspace" class="anchor"><tt>rdf:XMLLiteral</tt></span> (<tt><nowiki>http://</nowiki>www.w3.org/1999/02/22rdfsyntaxns#XMLLiteral</tt>, short name: <tt>XMLLiteral</tt>).  <li><span id="rdfxmlliteralspace" class="anchor"><tt>rdf:XMLLiteral</tt></span> (<tt><nowiki>http://</nowiki>www.w3.org/1999/02/22rdfsyntaxns#XMLLiteral</tt>, short name: <tt>XMLLiteral</tt>).  
Line 153:  Line 149:  
<p>We will often refer to constant symbols that come from a particular symbol space, <tt>X</tt>, as <tt>X</tt> '''''constants''''', where <tt>X</tt> is the (short) name of the respective symbol space. For instance the constants in the symbol space <tt>rif:iri</tt> will be referred to as '''''IRI constants''''' or <tt>rif:iri</tt> '''''constants''''' and the constants found in the symbol space <tt>rif:local</tt> as '''''local constants'''''  <p>We will often refer to constant symbols that come from a particular symbol space, <tt>X</tt>, as <tt>X</tt> '''''constants''''', where <tt>X</tt> is the (short) name of the respective symbol space. For instance the constants in the symbol space <tt>rif:iri</tt> will be referred to as '''''IRI constants''''' or <tt>rif:iri</tt> '''''constants''''' and the constants found in the symbol space <tt>rif:local</tt> as '''''local constants'''''  
−  or <tt>rif:local</tt> '''''constants'''''.</p>  +  or <tt>rif:local</tt> '''''constants'''''.</p> 
−  +  
=== <span id="secshortcutsconstants" class="anchor">Shortcuts for Constants in RIF's Presentation Syntax</span> ===  === <span id="secshortcutsconstants" class="anchor">Shortcuts for Constants in RIF's Presentation Syntax</span> ===  
Line 277:  Line 272:  
* The value space and the lexicaltovaluespace mapping for <tt>rdf:PlainLiteral</tt> are defined in the document <nowiki>[</nowiki>[[#refrdfPlainLiteralRDFPLAINLITERAL]]].  * The value space and the lexicaltovaluespace mapping for <tt>rdf:PlainLiteral</tt> are defined in the document <nowiki>[</nowiki>[[#refrdfPlainLiteralRDFPLAINLITERAL]]].  
* The value space and lexicaltovaluespace mapping for the datatype <tt>rdf:XMLLiteral</tt> is defined in RDF <nowiki>[</nowiki>[[#refrdfconceptsRDFCONCEPTS]]].  * The value space and lexicaltovaluespace mapping for the datatype <tt>rdf:XMLLiteral</tt> is defined in RDF <nowiki>[</nowiki>[[#refrdfconceptsRDFCONCEPTS]]].  
−  
−  
= Syntax and Semantics of Builtins =  = Syntax and Semantics of Builtins = 
Revision as of 15:37, 9 June 2009
__NUMBEREDHEADINGS__
 Document title:
 RIF Datatypes and BuiltIns 1.0 (Second Edition)
 Editors
 Axel Polleres, DERI
 Harold Boley, National Research Council Canada
 Michael Kifer, State University of New York at Stony Brook
 Abstract
 This document, developed by the Rule Interchange Format (RIF) Working Group, specifies a list of datatypes, builtin functions and builtin predicates expected to be supported by RIF dialects such as the RIF Core Dialect, the RIF Basic Logic Dialect, and the RIF Production Rules Dialect. Each dialect supporting a superset or subset of the datatypes, builtin functions and builtin predicates defined here shall specify these additions or restrictions. Some of the datatypes are adopted from [XMLSCHEMA2]. A large part of the definitions of the listed functions and operators are adopted from [XPathFunctions]. The rdf:PlainLiteral datatype as well as functions and operators associated with that datatype are adopted from [RDFPLAINLITERAL].
 Status of this Document
 @@update This is an automatically generated Mediawiki page, made from some sort of W3Cstyle spec.
Copyright © 2009 W3C^{®} (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
Contents
 1 Constants, Symbol Spaces, and Datatypes
 2 Syntax and Semantics of Builtins
 3 List of RIF Builtin Predicates and Functions
 3.1 Predicates for all Datatypes
 3.2 Guard Predicates for Datatypes
 3.3 Negative Guard Predicates for Datatypes
 3.4 Datatype Conversion and Casting
 3.5 Numeric Functions and Predicates
 3.5.1 Numeric Functions
 3.5.2 Numeric Predicates
 3.5.2.1 pred:numericequal (adapted from op:numericequal)
 3.5.2.2 pred:numericlessthan (adapted from op:numericlessthan)
 3.5.2.3 pred:numericgreaterthan (adapted from op:numericgreaterthan)
 3.5.2.4 pred:numericnotequal
 3.5.2.5 pred:numericlessthanorequal
 3.5.2.6 pred:numericgreaterthanorequal
 3.6 Functions and Predicates on Boolean Values
 3.7 Functions and Predicates on Strings
 3.7.1 Functions on Strings
 3.7.1.1 func:compare (adapted from fn:compare)
 3.7.1.2 func:concat (adapted from fn:concat)
 3.7.1.3 func:stringjoin (adapted from fn:stringjoin)
 3.7.1.4 func:substring (adapted from fn:substring)
 3.7.1.5 func:stringlength (adapted from fn:stringlength)
 3.7.1.6 func:uppercase (adapted from fn:uppercase)
 3.7.1.7 func:lowercase (adapted from fn:lowercase)
 3.7.1.8 func:encodeforuri (adapted from fn:encodeforuri)
 3.7.1.9 func:iritouri (adapted from fn:iritouri)
 3.7.1.10 func:escapehtmluri (adapted from fn:escapehtmluri)
 3.7.1.11 func:substringbefore (adapted from fn:substringbefore)
 3.7.1.12 func:substringafter (adapted from fn:substringafter)
 3.7.1.13 func:replace (adapted from fn:replace)
 3.7.2 Predicates on Strings
 3.7.1 Functions on Strings
 3.8 Functions and Predicates on Dates, Times, and Durations
 3.8.1 Functions on Dates, Times, and Durations
 3.8.1.1 func:yearfromdateTime (adapted from fn:yearfromdateTime)
 3.8.1.2 func:monthfromdateTime (adapted from fn:monthfromdateTime)
 3.8.1.3 func:dayfromdateTime (adapted from fn:dayfromdateTime)
 3.8.1.4 func:hoursfromdateTime (adapted from fn:hoursfromdateTime)
 3.8.1.5 func:minutesfromdateTime (adapted from fn:minutesfromdateTime)
 3.8.1.6 func:secondsfromdateTime (adapted from fn:secondsfromdateTime)
 3.8.1.7 func:yearfromdate (adapted from fn:yearfromdate)
 3.8.1.8 func:monthfromdate (adapted from fn:monthfromdate)
 3.8.1.9 func:dayfromdate (adapted from fn:dayfromdate)
 3.8.1.10 func:hoursfromtime (adapted from fn:hoursfromtime)
 3.8.1.11 func:minutesfromtime (adapted from fn:minutesfromtime)
 3.8.1.12 func:secondsfromtime (adapted from fn:secondsfromtime)
 3.8.1.13 func:yearsfromduration (adapted from fn:yearsfromduration)
 3.8.1.14 func:monthsfromduration (adapted from fn:monthsfromduration)
 3.8.1.15 func:daysfromduration (adapted from fn:daysfromduration)
 3.8.1.16 func:hoursfromduration (adapted from fn:hoursfromduration)
 3.8.1.17 func:minutesfromduration (adapted from fn:minutesfromduration)
 3.8.1.18 func:secondsfromduration (adapted from fn:secondsfromduration)
 3.8.1.19 func:timezonefromdateTime (adapted from fn:timezonefromdateTime)
 3.8.1.20 func:timezonefromdate (adapted from fn:timezonefromdate)
 3.8.1.21 func:timezonefromtime (adapted from fn:timezonefromtime)
 3.8.1.22 func:subtractdateTimes (adapted from op:subtractdateTimes)
 3.8.1.23 func:subtractdates (adapted from op:subtractdates)
 3.8.1.24 func:subtracttimes (adapted from op:subtracttimes)
 3.8.1.25 func:addyearMonthDurations (adapted from op:addyearMonthDurations)
 3.8.1.26 func:subtractyearMonthDurations (adapted from op:subtractyearMonthDurations)
 3.8.1.27 func:multiplyyearMonthDuration (adapted from op:multiplyyearMonthDuration)
 3.8.1.28 func:divideyearMonthDuration (adapted from op:divideyearMonthDuration)
 3.8.1.29 func:divideyearMonthDurationbyyearMonthDuration (adapted from op:divideyearMonthDurationbyyearMonthDuration)
 3.8.1.30 func:adddayTimeDurations (adapted from op:adddayTimeDurations)
 3.8.1.31 func:subtractdayTimeDurations (adapted from op:subtractdayTimeDurations)
 3.8.1.32 func:multiplydayTimeDuration (adapted from op:multiplydayTimeDuration)
 3.8.1.33 func:dividedayTimeDuration (adapted from op:dividedayTimeDuration)
 3.8.1.34 func:dividedayTimeDurationbydayTimeDuration (adapted from op:dividedayTimeDurationbydayTimeDuration)
 3.8.1.35 func:addyearMonthDurationtodateTime (adapted from op:addyearMonthDurationtodateTime)
 3.8.1.36 func:addyearMonthDurationtodate (adapted from op:addyearMonthDurationtodate)
 3.8.1.37 func:adddayTimeDurationtodateTime (adapted from op:adddayTimeDurationtodateTime)
 3.8.1.38 func:adddayTimeDurationtodate (adapted from op:adddayTimeDurationtodate)
 3.8.1.39 func:adddayTimeDurationtotime (adapted from op:adddayTimeDurationtotime)
 3.8.1.40 func:subtractyearMonthDurationfromdateTime (adapted from op:subtractyearMonthDurationfromdateTime)
 3.8.1.41 func:subtractyearMonthDurationfromdate (adapted from op:subtractyearMonthDurationfromdate)
 3.8.1.42 func:subtractdayTimeDurationfromdateTime (adapted from op:subtractdayTimeDurationfromdateTime)
 3.8.1.43 func:subtractdayTimeDurationfromdate (adapted from op:subtractdayTimeDurationfromdate)
 3.8.1.44 func:subtractdayTimeDurationfromtime (adapted from op:subtractdayTimeDurationfromtime)
 3.8.2 Predicates on Dates, Times, and Durations
 3.8.2.1 pred:dateTimeequal (adapted from op:dateTimeequal)
 3.8.2.2 pred:dateTimelessthan (adapted from op:dateTimelessthan)
 3.8.2.3 pred:dateTimegreaterthan (adapted from op:dateTimegreaterthan)
 3.8.2.4 pred:dateequal (adapted from op:dateequal)
 3.8.2.5 pred:datelessthan (adapted from op:datelessthan)
 3.8.2.6 pred:dategreaterthan (adapted from op:dategreaterthan)
 3.8.2.7 pred:timeequal (adapted from op:timeequal)
 3.8.2.8 pred:timelessthan (adapted from op:timelessthan)
 3.8.2.9 pred:timegreaterthan (adapted from op:timegreaterthan)
 3.8.2.10 pred:durationequal (adapted from op:durationequal)
 3.8.2.11 pred:dayTimeDurationlessthan (adapted from op:dayTimeDurationlessthan)
 3.8.2.12 pred:dayTimeDurationgreaterthan (adapted from op:dayTimeDurationgreaterthan)
 3.8.2.13 pred:yearMonthDurationlessthan (adapted from op:yearMonthDurationlessthan)
 3.8.2.14 pred:yearMonthDurationgreaterthan (adapted from op:yearMonthDurationgreaterthan)
 3.8.2.15 pred:dateTimenotequal
 3.8.2.16 pred:dateTimelessthanorequal
 3.8.2.17 pred:dateTimegreaterthanorequal
 3.8.2.18 pred:datenotequal
 3.8.2.19 pred:datelessthanorequal
 3.8.2.20 pred:dategreaterthanorequal
 3.8.2.21 pred:timenotequal
 3.8.2.22 pred:timelessthanorequal
 3.8.2.23 pred:timegreaterthanorequal
 3.8.2.24 pred:durationnotequal
 3.8.2.25 pred:dayTimeDurationlessthanorequal
 3.8.2.26 pred:dayTimeDurationgreaterthanorequal
 3.8.2.27 pred:yearMonthDurationlessthanorequal
 3.8.2.28 pred:yearMonthDurationgreaterthanorequal
 3.8.1 Functions on Dates, Times, and Durations
 3.9 Functions and Predicates on rdf:XMLLiterals
 3.10 Functions and Predicates on rdf:PlainLiteral
 3.10.1 Functions on rdf:PlainLiteral
 3.10.1.1 func:PlainLiteralfromstringlang (adapted from plfn:PlainLiteralfromstringlang)
 3.10.1.2 func:stringfromPlainLiteral (adapted from plfn:stringfromPlainLiteral)
 3.10.1.3 func:langfromPlainLiteral (adapted from plfn:langfromPlainLiteral)
 3.10.1.4 func:PlainLiteralcompare (adapted from plfn:compare)
 3.10.1.5 func:PlainLiterallength (adapted from plfn:length)
 3.10.2 Predicates on rdf:PlainLiteral
 3.10.1 Functions on rdf:PlainLiteral
 3.11 Functions and Predicates on RIF Lists
 3.11.1 Position Numbering
 3.11.2 Item Comparison
 3.11.3 Predicates on RIF Lists
 3.11.4 Functions on RIF Lists
 3.11.4.1 func:makelist
 3.11.4.2 func:count (adapted from fn:count)
 3.11.4.3 func:get
 3.11.4.4 func:sublist (adapted from fn:subsequence)
 3.11.4.5 func:append
 3.11.4.6 func:concatenate (adapted from fn:concatenate)
 3.11.4.7 func:insertbefore (adapted from fn:insertbefore)
 3.11.4.8 func:remove (adapted from fn:remove)
 3.11.4.9 func:reverse (adapted from fn:reverse)
 3.11.4.10 func:indexof (adapted from fn:indexof)
 3.11.4.11 func:union (adapted from fn:union)
 3.11.4.12 func:distinctvalues (adapted from fn:distinctvalues)
 3.11.4.13 func:intersect (adapted from fn:intersect)
 3.11.4.14 func:except (adapted from fn:except)
 4 References
 5 Appendix: Schemas for Externally Defined Terms
1 Constants, Symbol Spaces, and Datatypes
1.1 Constants and Symbol Spaces
Each constant (that is, each nonkeyword symbol) in RIF belongs to a particular symbol space. A constant in a particular RIF symbol space has the following presentation syntax:
"literal"^^<symbolSpaceIri>
where literal is called the lexical part of the symbol, and symbolSpaceIri is the (absolute or relative) IRI identifying the symbol space. Here literal is a Unicode string that must be an element in the lexical space of the symbol space identified by the IRI symbolSpaceIri.
1.2 The Base and Prefix Directives
Since IRI typically require long strings of characters, many Web languages have special provisions for abbreviating these strings. One popular technique is called compact URI [CURIE], and RIF uses a similar technique by allowing RIF documents to have the directives Base and Prefix.

A base directive has the form Base(iri), where iri is a Unicode string in the form of an absolute IRI [RFC3987].
The Base directive defines a syntactic shortcut for expanding relative IRIs into full IRIs.

A prefix directive has the form Prefix(p v), where p is called a prefix and v is its expansion.
A prefix is an alphanumeric string an expansion is a string that forms an IRI.
(An alphanumeric string is a sequence of ASCII characters, where each character is a letter, a digit, or an underscore "_", and the first character is a letter.)
The basic idea is that in certain contexts prefixes can be used instead of their much longer expansions, and this provides for a much more concise and simple notation.
The precise way in which these directives work is explained in Section Shortcuts for Constants in RIF's Presentation Syntax.
To avoid writing down long IRIs, this document will assume that the following Prefix directives have been specified in all the RIF documents under consideration:
 Prefix(xs http://www.w3.org/2001/XMLSchema#). This prefix stands for the XML Schema namespace URI.
 Prefix(rdf http://www.w3.org/1999/02/22rdfsyntaxns#). This prefix stands for the RDF URI.
 Prefix(rif http://www.w3.org/2007/rif#). The rif prefix stands for the RIF URI.
 Prefix(func http://www.w3.org/2007/rifbuiltinfunction#). This prefix expands into a URI used for RIF builtin functions.
 Prefix(pred http://www.w3.org/2007/rifbuiltinpredicate#). This is the prefix used for RIF builtin predicates.
Using these prefixes and the shorthand mechanism defined in Section Shortcuts for Constants in RIF's Presentation Syntax, we can, for example, abbreviate a constant such as "http://www.example.org"^^<http://www.w3.org/2007/rif#iri> into "http://www.example.org"^^rif:iri.
1.2.1 Symbol Spaces
Formally, we define symbol spaces as follows.
Definition (Symbol space). A symbol space is a named subset of the set of all constants, Const in RIF. Each symbol in Const belongs to exactly one symbol space.
Each symbol space has an associated lexical space, a unique IRI identifying it and a short name. More precisely,
 The lexical space of a symbol space is a nonempty set of Unicode character strings.
 The identifier of a symbol space is a sequence of Unicode characters that form an absolute IRI.
 Different symbol spaces supported by a dialect cannot share the same identifier or short name.
The identifiers of symbol spaces are not themselves constant symbols in RIF.
For convenience we will often use symbol space identifiers to refer to the actual symbol spaces (for instance, we may use "symbol space xs:string" instead of "symbol space identified by xs:string").
RIF dialects are expected to include the symbol spaces listed in the following. However, rule sets that are exchanged through RIF can use additional symbol spaces.
In the following list we introduce short names for some of the symbol spaces. Short names are NCNames, typically the character sequence after the last '/' or '#' in the symbol space IRI (similar to the XML local name part of a QName). Short names are used for the predicates in Sections Guard Predicates for Datatypes and Negative Guard Predicates for Datatypes below.
 xs:anyURI (http://www.w3.org/2001/XMLSchema#anyURI), short name: anyURI)
 xs:base64Binary (http://www.w3.org/2001/XMLSchema#base64Binary), short name: base64Binary)
 xs:boolean (http://www.w3.org/2001/XMLSchema#boolean), short name: boolean)
 xs:date (http://www.w3.org/2001/XMLSchema#date), short name: date
 xs:dateTime (http://www.w3.org/2001/XMLSchema#dateTime), short name: dateTime)
 xs:dateTimeStamp (http://www.w3.org/2001/XMLSchema#dateTimeStamp), short name: dateTimeStamp)
 xs:double (http://www.w3.org/2001/XMLSchema#double, short name: double)
 xs:float (http://www.w3.org/2001/XMLSchema#float, short name: float)
 xs:hexBinary (http://www.w3.org/2001/XMLSchema#hexBinary), short name: hexBinary)
 xs:decimal (http://www.w3.org/2001/XMLSchema#decimal, short name: decimal)
 xs:integer (http://www.w3.org/2001/XMLSchema#integer, short name: integer)
 xs:long (http://www.w3.org/2001/XMLSchema#long, short name: long)
 xs:int (http://www.w3.org/2001/XMLSchema#int, short name: int)
 xs:short (http://www.w3.org/2001/XMLSchema#short, short name: short)
 xs:byte (http://www.w3.org/2001/XMLSchema#byte), short name:byte)
 xs:nonNegativeInteger (http://www.w3.org/2001/XMLSchema#xs:nonNegativeInteger), short name: nonNegativeInteger)
 xs:positiveInteger (http://www.w3.org/2001/XMLSchema#xs:positiveInteger), short name: positiveInteger)
 xs:unsignedLong (http://www.w3.org/2001/XMLSchema#unsignedLong, short name: unsignedLong)
 xs:unsignedInt (http://www.w3.org/2001/XMLSchema#unsignedInt, short name: unsignedInt)
 xs:unsignedShort (http://www.w3.org/2001/XMLSchema#unsignedShort, short name: unsignedShort)
 xs:unsignedByte (http://www.w3.org/2001/XMLSchema#unsignedByte, short name: unsignedByte)
 xs:nonPositiveInteger (http://www.w3.org/2001/XMLSchema#xs:nonPositiveInteger), short name: nonPositiveInteger)
 xs:negativeInteger (http://www.w3.org/2001/XMLSchema#negativeInteger, short name: negativeInteger)
 xs:string (http://www.w3.org/2001/XMLSchema#string, short name: string)
 xs:normalizedString (http://www.w3.org/2001/XMLSchema#xs:normalizedString), short name: normalizedString)
 xs:token (http://www.w3.org/2001/XMLSchema#xs:token), short name: token)
 xs:language (http://www.w3.org/2001/XMLSchema#language, short name: language)
 xs:Name (http://www.w3.org/2001/XMLSchema#Name, short name: Name)
 xs:NCName (http://www.w3.org/2001/XMLSchema#NCName, short name: NCName)
 xs:NMTOKEN (http://www.w3.org/2001/XMLSchema#NMTOKEN), short name: NMTOKEN)
 xs:time (http://www.w3.org/2001/XMLSchema#time, short name: time)
The lexical spaces of the above symbol spaces are defined in the document [XMLSCHEMA2].
 xs:dayTimeDuration (http://www.w3.org/2001/XMLSchema#dayTimeDuration, short name: dayTimeDuration)
 xs:yearMonthDuration (http://www.w3.org/2001/XMLSchema#yearMonthDuration, short name: yearMonthDuration)
These two symbol spaces represent two subtypes of the XML Schema datatype xs:duration with welldefined value spaces, since xs:duration does not have a welldefined value space (this may be corrected in later revisions of XML Schema datatypes, in which case the revised datatype would be suitable for RIF DTB). The lexical spaces of the above symbol spaces are defined in the document [XDM].
 rdf:PlainLiteral (http://www.w3.org/1999/02/22rdfsyntaxns#text , short name: text).
The rdf:PlainLiteral symbol space represents text strings with a language tag attached. The lexical space of rdf:PlainLiteral is defined in the document [RDFPLAINLITERAL].
 rdf:XMLLiteral (http://www.w3.org/1999/02/22rdfsyntaxns#XMLLiteral, short name: XMLLiteral).
The rdf:XMLLiteral symbol space represents XML content. The lexical space of rdf:XMLLiteral is defined in the document [RDFCONCEPTS].
 rif:iri (http://www.w3.org/2007/rif#iri, for internationalized resource identifiers or IRIs).
Constants in the rif:iri symbol space are intended to be used in a way similar to RDF resources [RDFSCHEMA]. The lexical space consists of all absolute IRIs as specified in [RFC3987]; it is unrelated to the XML primitive type xs:anyURI.
 rif:local (http://www.w3.org/2007/rif#local, for constant symbols that are not visible outside of the RIF document in which they occur).
Constants in the rif:local symbol space are local to the RIF documents in which they occur. This means that occurrences of the same rif:local constant in different documents are viewed as unrelated distinct constants, but occurrences of the same rif:local constant in the same document must refer to the same object. The lexical space of rif:local is the same as the lexical space of xs:string.
Note that, by the associated lexical space, not all Unicode strings are syntactically valid lexical parts for all symbol spaces. That is, for instance "1.2"^^xs:decimal and "1"^^xs:integer are syntactically valid constant because 1.2 and 1 are members of the lexical space of symbol spaces xs:decimal and xs:integer, respectively. On the other hand, "a+2"^^xs:decimal is not a syntactically valid constant, since a+2 is not part of the lexical space of xs:decimal.
We will often refer to constant symbols that come from a particular symbol space, X, as X constants, where X is the (short) name of the respective symbol space. For instance the constants in the symbol space rif:iri will be referred to as IRI constants or rif:iri constants and the constants found in the symbol space rif:local as local constants or rif:local constants.
1.2.2 Shortcuts for Constants in RIF's Presentation Syntax
Besides the basic notion
"literal"^^<identifier>
RIF's presentation syntax introduces several shortcuts for particular symbol spaces, in order to make the presentation syntax more readable. RIF's presentation syntax for constants is defined by the following EBNF.
ANGLEBRACKIRI ::= IRI_REF SYMSPACE ::= ANGLEBRACKIRI  CURIE CURIE ::= PNAME_LN  PNAME_NS Const ::= '"' UNICODESTRING '"^^' SYMSPACE  CONSTSHORT CONSTSHORT ::= ANGLEBRACKIRI // shortcut for "..."^^rif:iri  CURIE // shortcut for "..."^^rif:iri  '"' UNICODESTRING '"' // shortcut for "..."^^xs:string  NumericLiteral // shortcut for "..."^^xs:integer,xs:decimal,xs:double  '_' LocalName // shortcut for "..."^^rif:local  '"' UNICODESTRING '"' '@' languageTag // shortcut for "...@..."^^rdf:PlainLiteral
The EBNF grammar relies on reuse of nonterminals defined in the following grammar productions from other documents:
 PNAME_LN, cf. http://www.w3.org/TR/rdfsparqlquery/#rPNAME_LN
 PNAME_NS, cf. http://www.w3.org/TR/rdfsparqlquery/#rPNAME_NS
 languageTag, cf. http://www.w3.org/2007/OWL/wiki/InternationalizedStringSpec#AbbreviationsGrammar
 NumericLiteral, cf. http://www.w3.org/TR/rdfsparqlquery/#rNumericLiteral
 IRI_REF, cf. http://www.w3.org/TR/rdfsparqlquery/#rIRI_REF
 LocalName, cf. http://www.w3.org/TR/2006/RECxmlnames1120060816/#NTLocalPart
 UNICODESTRING, any Unicode string where quotes are escaped and additionally all the other escape sequences defined in http://www.w3.org/TR/rdfsparqlquery/#grammarEscapes and http://www.w3.org/TR/rdfsparqlquery/#codepointEscape.
In this grammar, CURIE stands for compact IRIs [CURIE], which are used to abbreviate symbol space IRIs. For instance, one can write "http://www.example.org"^^rif:iri instead of "http://www.example.org"^^<http://www.w3.org/2007/rif#iri>, where rif is a prefix defined in Section Base and Prefix Directives.
Apart from compact IRIs, there exist convenient shortcut notations for constants in specific symbol spaces, namely for constants in the symbol spaces rif:iri, xs:string, xs:integer, xs:decimal, xs:double, and rif:local:

Constants in the the symbol space rif:iri can be abbreviated in two ways, either by simply using an absolute or relative IRI enclosed in angle brackets, or by writing a compact IRI. The symbol space identifier is dropped in both of these alternatives. For instance <http://www.example.org/xyz> is a valid abbreviation for "http://www.example.org/xyz"^^rif:iri and , ex:xyz is a valid abbreviation for this constant, if the directive
Prefix(ex http://www.example.org/)
is present in the RIF document in question.
 Constants in the symbol space xs:string can be abbreviated by simply using quoted strings, i.e. "My String!" is a valid abbreviation for the constant "My String!"^^xs:string (which in turn is itself an abbreviation for "My String!"^^<http://www.w3.org/2001/XMLSchema#string>).
 Numeric constants can be abbreviated using the grammar rules for NumericLiterals from the [SPARQL] grammar: Integers can be written directly (without quotation marks and explicit symbol space identifier) and are interpreted as constants in the symbol space xs:integer; decimal numbers for which there is '.' in the number but no exponent are interpreted as constants in the symbol space xs:decimal; and numbers with exponents are interpreted as xs:double. For instance, one could use 1.2 and 1 as shortcuts for "1.2"^^xs:decimal and "1"^^xs:integer, respectively. However, there is no shortcut for "1"^^xs:decimal.
 The shortcut notation for rif:local applies to only a subset of the lexical space of syntactically valid lexical parts of constants in this symbol space: We allow "_"prefixed Unicode strings which are also valid XML NCNames as defined in [XMLNS]. For other constants in the rif:local symbol space one has to use the long notation. That is, for instance _myLocalConstant is a valid abbreviation for the constant "myLocalConstant"^^rif:local, whereas "http://www.example.org"^^rif:local cannot be abbreviated.
1.2.3 Relative IRIs
Relative IRIs in RIF documents are resolved with respect to the base IRI. Relative IRIs are combined with base IRIs as per Uniform Resource Identifier (URI): Generic Syntax [RFC3986] using only the basic algorithm in Section 5.2. Neither SyntaxBased Normalization nor SchemeBased Normalization (described in Sections 6.2.2 and 6.2.3 of RFC3986) are performed. Characters additionally allowed in IRI references are treated in the same way that unreserved characters are treated in URI references, per Section 6.5 of Internationalized Resource Identifiers (IRIs) [RFC3987].
Base IRIs are specified using the Base directive described in Section Base and Prefix Directives. At most one base directive per document is allowed. In the XML syntax, base IRIs are specified using the attribute xml:base.
For instance, the constant <./xyz> or "./xyz"^^rif:iri are both valid abbreviations in RIF for the constant http://www.example.org/xyz"^^rif:iri, if the following directive is present in the document:
Base(http://www.example.org)
1.3 Datatypes
Datatypes in RIF are symbol spaces which have special semantics. That is, each datatype is characterized by a fixed lexical space, value space and lexicaltovaluemapping.
Definition (Datatype). A datatype is a symbol space that has
 an associated set, called the value space, and
 a mapping from the lexical space of the symbol space to the value space, called lexicaltovaluespace mapping. ☐
Semantic structures are always defined with respect to a particular set of datatypes, denoted by DTS. In a concrete dialect, DTS always includes the datatypes supported by that dialect. RIF dialects are expected to support the following datatypes. However, RIF dialects may include additional datatypes. Subitems in the following lists indicate derived datatypes.
 xs:anyURI
 base64Binary
 xs:boolean
 xs:date
 xs:dateTime
 xs:dateTimeStamp
 xs:double
 xs:float
 xs:hexBinary
 xs:decimal
 xs:integer
 xs:long
 xs:int
 xs:short
 xs:byte
 xs:short
 xs:int
 nonNegativeInteger
 positiveInteger
 xs:unsignedLong
 xs:unsignedInt
 xs:unsignedShort
 xs:unsignedByte
 xs:unsignedShort
 xs:unsignedInt
 xs:unsignedLong
 positiveInteger
 nonPositiveInteger
 negativeInteger
 xs:long
 xs:integer
 xs:string
 xs:normalizedString
 xs:token
 xs:language
 xs:Name
 xs:NCName
 xs:NMTOKEN
 xs:token
 xs:normalizedString
 xs:time
 xs:dayTimeDuration
 xs:yearMonthDuration
 rdf:PlainLiteral
 rdf:XMLLiteral
Their value spaces and the lexicaltovaluespace mappings are defined as follows:
 For the XML Schema datatypes of RIF, namely all RIF datatypes within the xs: namespace, except xs:dayTimeDuration and xs:yearMonthDuration, the value spaces and the lexicaltovaluespace mappings are defined in the XML Schema specification [XMLSCHEMA2].
 The value spaces and the lexicaltovaluespace mappings for the datatypes xs:dayTimeDuration and xs:yearMonthDuration are defined in the XQuery 1.0 and XPath 2.0 Data Model [XDM].
 The value space and the lexicaltovaluespace mapping for rdf:PlainLiteral are defined in the document [RDFPLAINLITERAL].
 The value space and lexicaltovaluespace mapping for the datatype rdf:XMLLiteral is defined in RDF [RDFCONCEPTS].
2 Syntax and Semantics of Builtins
2.1 Syntax of Builtins
A RIF builtin function or predicate is a special case of externally defined terms, which are defined in RIF Framework for Logic Dialects and also reproduced in the direct definition of RIF Basic Logic Dialect (RIFBLD).
In RIF's presentation syntax builtin predicates and functions are syntactically represented as external terms of the form:
'External' '(' Expr ')'
where Expr is a positional term as defined in RIF Framework for Logic Dialects (see also in RIF Basic Logic Dialect). For RIF's normative syntax, see the XML Serialization Framework in RIFFLD, or, specifically for RIFBLD, see XML Serialization Syntax for RIFBLD.
RIFFLD introduces the notion of an external schema to describe both the syntax and semantics of exernally defined terms. In the special case of a RIF builtin, external schemas have an especially simple form. A builtin named f that takes n arguments has the schema
( ?X_{1} ... ?X_{n}; f(?X_{1} ... ?X_{n}) )
Here f(?X_{1} ... ?X_{n}) is the actual positional term that is used to refer to the builtin (in expressions of the form External(f(?X_{1} ... ?X_{n}))) and ?X_{1} ... ?X_{n} is the list of all variables in that term.
Note that RIFBLD allows additional forms of builtins, which includes namedargument terms.
RIFFLD defines a very general notion of external terms and schemas, but RIFBLD and the present document use more restricted notions. For convenience, we present a complete definition of these restricted notions in Appendix: Schemas for Externally Defined Terms.
2.2 Semantics of Builtins
The semantics of external terms is defined using two mappings: I_{external} and I_{truth} ο I_{external}.

I_{external}. This mapping takes an external schema, σ, and returns a mapping, I_{external}(σ).
If σ represents a builtin function, I_{external}(σ) must be that function.
For each builtin function with external schema σ, the present document specifies the mapping I_{external}(σ).

I_{truth}. This mapping takes an element of the domain of interpretation and returns a truth value.
In RIF logical semantics, this mapping is used to assign truth values to formulas. In the special case of RIF builtins, it is used to assign truth values to RIF builtin predicates. The builtin predicates can have the truth values t or f only.
For a builtin predicate with schema σ, RIFFLD and RIFBLD require that the truthvalued mapping I_{truth} ο I_{external}(σ) must agree with the specification of the corresponding builtin predicate.
For each RIF builtin predicate with schema σ, the present document specifies I_{truth} ο I_{external}(σ).
3 List of RIF Builtin Predicates and Functions
This section provides a catalogue defining the syntax and semantics of a list of builtin predicates and functions in RIF. For each builtin, the following is defined:
 The name of the builtin.
 The external schema of the builtin.

For a builtin function, how it maps its arguments into a result.
As explained in Section Semantics of Builtins, this corresponds to the mapping I_{external}(σ) in the formal semantics of RIFFLD and RIFBLD, where σ is the external schema of the builtin.

For a builtin predicate, its truth value when the arguments are substituted with values in the domain.
As explained in Section Semantics of Builtins, this corresponds to the mapping I_{truth} ο I_{external}(σ) in the formal semantics of RIFFLD and RIFBLD, where σ is the external schema of the builtin.

The domains for the arguments of the builtin.
Typically, builtin functions and predicates are defined over the value spaces of appropriate datatypes, i.e. the domains of the arguments. When an argument falls outside of its domain, it is understood as an error. Since this document defines a modeltheoretic semantics for RIF builtins, which does not support the notion of an error, the definitions leave the values of the builtin predicates and functions unspecified in such cases. This means that if one or more of the arguments is not in its domain, the value of I_{external}(σ)(a_{1} ... a_{n}) is unspecified. In particular, this means it can vary from one implementation to another. Similarly, I_{truth} ο I_{external}(σ)(a_{1} ... a_{n}) is unspecified when an argument is not in its domain.
This indeterminacy in case of an error implies that applications should not make any assumptions about the values of builtins in such situations. Implementations are even allowed to abort in such cases and the only safe way to communicate rule sets that contain builtins among RIFcompliant systems is to use datatype guards.
Many builtin functions and predicates described below are adapted from [XPathFunctions] and, when appropriate, we will refer to the definitions in that specification in order to avoid copying them.
3.1 Predicates for all Datatypes
3.1.1 Comparison for Literals
RIF supports identity for typed literals through the "=" predicate in all dialects that extend RIFCORE. Identity for typed literals is defined as being the same point in the value space for that type. Certain datatypes use more specific notions of equality that allow for multiple points in the value space to be considered equal. For these datatype specific notions of equality, see the supported predicates for each datatype.
Since the basic RIF dialects do not support negation, dialects that extend RIFCORE define a builtin for checking the nonidentity of two typed literals.
3.1.1.1 pred:literalnotidentical

Schema:
( ?arg_{1} ?arg_{2}; pred:literalnotidentical( ?arg_{1} ?arg_{2} ) )

Domain:
This predicate does not depend on a specific domain.

Mapping:
I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:literalnotidentical( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = t if and only if s_{1} and s_{2} are both in the value spaces of some datatypes in DTS and s_{1} ≠ s_{2}. This includes the case where s_{1} and s_{2} are of disjoint types.
I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:literalnotidentical( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = f otherwise. This includes the case where s_{1} or s_{2} are not in the value spaces of datatypes in DTS.
3.2 Guard Predicates for Datatypes
RIF defines guard predicates for all datatypes in Section Datatypes.

Schema: The schemas for these predicates have the general form
( ?arg_{1}; pred:isliteralDATATYPE ( ?arg_{1} ) )
Here, DATATYPE is the short name for a datatype. For instance, we use pred:isliteralstring for the guard predicate for xs:string, pred:isliteralPlainLiteral for the guard predicate for rif:text, or pred:isliteralXMLLiteral for the guard predicate forrdf:XMLLiteral. Parties defining their own datatypes to be used in RIF exchanged rules may define their own guard predicates for these datatypes. Labels used for such additional guard predicates for datatypes not mentioned in the present document MAY follow a similar naming convention where applicable without creating ambiguities with predicate names defined in the present document. Particularly, upcoming W3C specifications MAY  but 3rd party dialects MUST NOT  reuse the pred: namespace for such guard predicates.

Domain:
Guard predicates do not depend on a specific domain.

Mapping:
I_{truth} ο I_{external}( ?arg_{1}; pred:isliteralDATATYPE ( ?arg_{1} ) )(s_{1}) = t if and only if s_{1} is in the value space of DATATYPE and f otherwise.
Accordingly, the following schemas are defined.
 ( ?arg_{1}; pred:isliteralanyURI( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralbase64Binary( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralboolean( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteraldate ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteraldateTime ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteraldateTimeStamp ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteraldouble ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralfloat ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralhexBinary ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteraldecimal ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralinteger( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliterallong ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralint( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralshort( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralbyte( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnonNegativeInteger( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralpositiveInteger( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralunsignedLong( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralunsignedInt( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralunsignedShort( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralunsignedByte( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnonPositiveInteger( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnegativeInteger( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralPlainLiteral ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralstring ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnormalizedString ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteraltoken ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliterallanguage ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralName ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralNCName ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralNMTOKEN ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteraltime ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteraldayTimeDuration ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralyearMonthDuration ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralXMLLiteral ( ?arg_{1} ) )
Future dialects may extend this list of guards to other datatypes, but RIF does not require guards for all datatypes.
3.3 Negative Guard Predicates for Datatypes
Likewise, RIF defines negative guard predicates for all datatypes in Section Datatypes.

Schema: The schemas for negative guards have the general form
( ?arg_{1}; pred:isliteralnotDATATYPE ( ?arg_{1} ) )
Here, DATATYPE is the short name for one of the datatypes mentioned in this document. For instance, we use pred:isliteralnotString for the negative guard predicate for xs:string, pred:isliteralnotPlainLiteral for the negative guard predicate for rif:text, or pred:isliteralnotXMLLiteral for the negative guard predicate for rdf:XMLLiteral. Parties defining their own datatypes to be used in RIF exchanged rules may define their own negative guard predicates for these datatypes. Labels used for such additional negative guard predicates for datatypes not mentioned in the present document MAY follow a similar naming convention where applicable without creating ambiguities with predicate names defined in the present document. Particularly, upcoming W3C specifications MAY, but 3rd party dialects MUST NOT reuse, the pred: namespace for such negative guard predicates.

Domain:
Negative guard predicates do not depend on a specific domain.

Mapping:
I_{truth} ο I_{external}( ?arg_{1}; pred:isliteralnotDATATYPE ( ?arg_{1} ) )(s_{1}) = t if and only if s_{1} is in the value space of one of the datatypes in DTS but not in the value space of the datatype with shortname DATATYPE, and f otherwise.
Accordingly, the following schemas are defined.
 ( ?arg_{1}; pred:isliteralnotanyURI( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotbase64Binary( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotboolean( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotdate ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotdateTime ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotdateTimeStamp ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotdouble ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotfloat ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnothexBinary ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotdecimal ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotinteger( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotlong ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotint( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotshort( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotbyte( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotnonNegativeInteger( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotpositiveInteger( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotunsignedLong( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotunsignedInt( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotunsignedShort( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotunsignedByte( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotnonPositiveInteger( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotnegativeInteger( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotPlainLiteral ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotstring ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotnormalizedString ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnottoken ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotlanguage ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotName ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotNCName ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotNMTOKEN ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnottime ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotdayTimeDuration ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotyearMonthDuration ( ?arg_{1} ) )
 ( ?arg_{1}; pred:isliteralnotXMLLiteral ( ?arg_{1} ) )
Future dialects may extend this list of negative guards to other datatypes, but RIF does not require negative guards for all datatypes.
3.4 Datatype Conversion and Casting
In the following, we adapt several cast functions according to the conversions defined in Section 17.1 of [XPathFunctions]. Note that some of these conversions are only partially defined, which affects the domains of these cast functions.
Likewise we define a conversion predicate useful for converting between rif:iri constants and strings, as well as a predicate to check the datatype of a constant.
3.4.1 Casting to XML Schema Datatypes
The casting functions in Section 17.1 of [XPathFunctions] define mappings from source values SV, which are data values, annotated with source types ST, to target values TV, annotated with target types TT. The data values V we consider are not necessarily explicitly annotated with types. However, one can view the datatypes D_{1},...,D_{n} whose value spaces include a data value V as the types of V. We assume in the following that any of the data types D_{1},...,D_{n} is used as the annotation of the source value SV; the conversions in [XPathFunctions] are defined equivalently for all such datatypes.

Schema: The schemas for casting functions have the general form
( ?arg; DATATYPEIRI ( ?arg ) )
Here, DATATYPEIRI is the IRI identifying a datatype. For instance, we use xs:string(?V) for casting to xs:string. Parties defining their own datatypes to be used in RIF exchanged rules may define their own casting funcitons for these datatypes. Labels used for such additional guard predicates for datatypes not mentioned in the present document MAY follow the same naming convention using the IRI identifying a datatype as function name for the casting function.

Domain:
The domain for casting functions to XML schema datatypes depends on where the casting is defined according to Section 17.1 of [XPathFunctions]: for all the casting functions to XML schema datatypes the domain of ?arg is at most the set of all data values in the value spaces of XML schema datatypes such that the conversion to DATATYPEIRI does not raise a type error or ab invalid value for cast/constructor error [err:FORG0001] or an invalid lexical value error [err:FOCA0002] according to Section 17.1 of [XPathFunctions]. We will mention additional constraints on the domain for casts to specific datatypes below separately.

Mapping: The mappings for casting functions to XML schema datatypes are defined as follows:
I_{external}( ?arg; DATATYPEIRI ( ?arg ) )(SV) = TV, which is a value the value space of the datatype with IRI DATATYPEIRI in derived from a type of SV, as defined in Section 17.1 of [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified. We will mention additional constraints on the mappings for casts to specific datatypes below separately.
Accordingly, the following schemas are defined:
 ( ?arg; xs:anyURI ( ?arg ) )
Additional restriction on the Domain: Note that unlike [XPathFunctions] the extent to which an implementation validates the lexical form of xs:anyURI is not implementation dependent, but RIF requires all lexical forms of xs:anyURI appearing as constants in the xs:string symbol space to be castable to xs:anyURI.
 ( ?arg; xs:base64Binary( ?arg ) )
 ( ?arg; xs:boolean( ?arg ) )
 ( ?arg; xs:date ( ?arg ) )
Additional restriction on the Domain: The domain where this function is specified in RIF is further restricted to data values in the value spaces of XML schema datatypes such that the conversion to xs:date does not result in a value from the xs:date value space outside what [http://www.w3.org/TR/xmlschema112/#dtminimallyconforming minimal conformance] as defined in Section 5.4 of [XMLSCHEMA2] requires for xs:date.
 ( ?arg; xs:dateTime ( ?arg ) )
Additional restriction on the Domain: The domain where this functions is specified in RIF is further restricted to data values in the value spaces of XML schema datatypes such that the conversion to xs:date does not result in a value from the xs:dateTime value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for xs:dateTime.
 ( ?arg; xs:dateTimeStamp ( ?arg ) )
Additional restriction on the Domain: Since xs:dateTimeStamp is a derived type of dateTime the domain if this function is the same as for casting to xs:dateTime with the additional restriction that casting to xs:dateTimeStamp is only defined for values such that the conversion to xs:dateTime has a nonempty timezone component.
 ( ?arg; xs:double ( ?arg ) )
 ( ?arg; xs:float ( ?arg ) )
 ( ?arg; xs:hexBinary ( ?arg ) )

( ?arg; xs:decimal ( ?arg ) )
Additional restriction on the Domain: The domain where this functions is specified in RIF is further restricted to data values in the value spaces of XML schema datatypes such that the conversion to xs:decimal does not result in a value from the xs:decimal value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for xs:decimal.

( ?arg; xs:integer( ?arg ) )
Additional restriction on the Domain: The domain where this functions is specified in RIF is further restricted to data values in the value spaces of XML schema datatypes such that the conversion to xs:integer does not result in a value from the xs:integer value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for xs:integer.
 ( ?arg; xs:long ?arg ) )
 ( ?arg; xs:int( ?arg ) )
 ( ?arg; xs:short( ?arg ) )
 ( ?arg; xs:byte( ?arg ) )
 ( ?arg; xs:nonNegativeInteger( ?arg ) )
 ( ?arg; xs:positiveInteger( ?arg ) )
 ( ?arg; xs:unsignedLong( ?arg ) )
 ( ?arg; xs:unsignedInt( ?arg ) )
 ( ?arg; xs:unsignedShort( ?arg ) )
 ( ?arg; xs:unsignedByte( ?arg ) )
 ( ?arg; xs:nonPositiveInteger( ?arg ) )
 ( ?arg; xs:negativeInteger( ?arg ) )

( ?arg; xs:string ( ?arg ) )
Additional restrictions on the Domain:
 Note that conversions from xs:float and xs:double to xs:string according to Section 17.1.1 of [XPathFunctions] may vary between implementations. Thus, the domain where this functions is specified in RIF is further restricted for data values in the value spaces of XML schema datatypes such that the conversion to xs:string is nonambiguous in a minimally conformant implementation as defined in Section 5.4 of [XMLSCHEMA2].
 RIF additionally includes values in the rdf:XMLLiteral value space to the domain.
Additional remark on the mapping:
If SV is a value in the value space of rdf:XMLLiteral, then I_{external}( ?arg; xs:string( ?arg ) )(SV) = TV such that TV is the string in the lexical space of rdf:XMLLiteral correspoding to SV (cf. [RDFCONCEPTS]).  ( ?arg; xs:normalizedString ( ?arg ) )
 ( ?arg; xs:token ( ?arg ) )
 ( ?arg; xs:language ( ?arg ) )
 ( ?arg; xs:Name ( ?arg ) )
 ( ?arg; xs:NCName ( ?arg ) )
 ( ?arg; xs:NMTOKEN ( ?arg ) )
 ( ?arg; xs:time ( ?arg ) )
 ( ?arg; xs:dayTimeDuration ( ?arg ) )
 ( ?arg; xs:yearMonthDuration ( ?arg ) )
3.4.2 Casting to rdf:XMLLiteral

Schema:
( ?arg; rdf:XMLLiteral ( ?arg ) )

Domain:
The intersection of the value space of xs:string with the lexical space of rdf:XMLLiteral, i.e. an xs:string can be cast to rdf:XMLLiteral if and only if its value is in the lexical space of rdf:XMLLiteral as defined in Resource Description Framework (RDF): Concepts and Abstract Syntax

Mapping:
I_{external}( ?arg; xs:XMLLiteral ( ?arg ) )(s) = s' such that s' is the XMLLiteral corresponding to the given string s.
If the argument value is outside of its domain, the value of the function is left unspecified.
3.4.3 Casting to rdf:PlainLiteral

Schema:
( ?arg; rdf:PlainLiteral ( ?arg ) )

Domain:
The union of the value spaces of XML schema datatypes.

Mapping:
Since the value space of xs:string is included in the value space of rdf:PlainLiteral, the mapping is defined in precisely the same way as for casts to xs:string.
3.4.4 pred:iristring
Conversions from rif:iri to xs:string and vice versa cannot be defined by the casting functions as above since rif:iri is not a datatype with a welldefined value space.
To this end, since conversions from IRIs (resources) to strings are a needed feature for instance for conversions between RDF formats (see example below), we introduce a builtin predicate which supports such conversions.

Schema:
( ?arg_{1} ?arg_{2}; pred:iristring ( ?arg_{1}, ?arg_{2} ) )

Domains:
The first argument is not restricted by a specific domain, the second argument is the value space of xs:string.

Mapping:
I_{external}( ?arg_{1} ?arg_{2}; pred:iristring ( ?arg_{1} ?arg_{2} ) )(iri_{1} str_{1}) = t if and only if str_{1} is a string in the lexical space of rif:iri and iri_{1} is an element of the domain such that I( "str_{1}"^^rif:iri ) = iri_{1} holds in the current interpretation.
Note that this definition restricts allowed RIF interpretations in such a way that the interpretation of pred:iristring always needs to comply with respect to the symbols in the rif:iri symbol space for the first argument and elements of the xs:string value space for the second argument. The truth value of the predicate is left unspecified for other elements of the domain.
This predicate could be usable for instance to map telephone numbers between an RDF Format for vCard (http://www.w3.org/TR/vcardrdf) and FOAF (http://xmlns.com/foaf/0.1/). vCard stores telephone numbers as string literals, whereas FOAF uses resources, i.e., URIs with the tel: URIscheme. So, a mapping from FOAF to vCard would need to convert the tel: URI to a string and then cut off the first four characters ("tel:"). Such a mapping expressed in RIF could involve e.g. a rule as follows:
... Prefix( VCard http://www.w3.org/TR/vcardrdf#) Prefix( foaf http://xmlns.com/foaf/0.1/) ... Forall ?X ?foafTelIri ?foafTelString ( ?X[ VCard:tel > External( func:substring( ?foafTelString 4 ) ] : And ( ?X[ foaf:phone > ?foafTelIri ] External( pred:iristring( ?foafTelIri ?foafTelString ) ) )
3.5 Numeric Functions and Predicates
The following functions and predicates are adapted from the respective numeric functions and operators in [XPathFunctions].
3.5.1 Numeric Functions
The following numeric binary builtin functions func:numericadd, func:numericsubtract, func:numericmultiply, func:numericdivide, func:numericintegerdivide, and func:numericmod are defined in accordance with their corresponding operators in [XPathFunctions].

Schema:
The schemas for these predicates have the general form
(?arg_{1} ?arg_{2}; func:numericBINOP(?arg_{1} ?arg_{2}))

Domains:
The domain of these functions is made up of pairs of values from value spaces of xs:integer, xs:double, xs:float, or xs:decimal for both arguments such that op:numericBINOP as defined in [XPathFunctions] after type promotion does not result in a numeric operation overflow/underflow error err:FOAR0002, division by zero error err:FOAR0001, or a value from the xs:decimal value spaces expressible with sixteen total digits, i.e., RIF requires minimal conformance as defined in Section 5.4 of [XMLSCHEMA2].

Mapping:
I_{external}( ?arg_{1} ?arg_{2}; func:numericBINOP(?arg_{1} ?arg_{2}) )(a_{1} a_{2}) = res such that res is the result of op:numericBINOP(a_{1}, a_{2}) as defined in [XPathFunctions], in case both a_{1} and a_{2} belong to their domains.
If an argument value is outside of its domain, the value of the function is left unspecified.
Accordingly, the following schemas are defined:
 (?arg_{1} ?arg_{2}; func:numericadd( ?arg_{1} ?arg_{2}) ) (adapted from op:numericadd)
 (?arg_{1} ?arg_{2}; func:numericsubtract( ?arg_{1} ?arg_{2}) ) (adapted from op:numericsubtract)
 (?arg_{1} ?arg_{2}; func:numericmultiply( ?arg_{1} ?arg_{2}) ) (adapted from op:numericmultiply)
 (?arg_{1} ?arg_{2}; func:numericdivide( ?arg_{1} ?arg_{2}) ) (adapted from op:numericdivide)
 (?arg_{1} ?arg_{2}; func:numericintegerdivide( ?arg_{1} ?arg_{2}) ) (adapted from op:numericintegerdivide)
 (?arg_{1} ?arg_{2}; func:numericmod( ?arg_{1} ?arg_{2}) ) (adapted from op:numericintegermod)
3.5.2 Numeric Predicates
3.5.2.1 pred:numericequal (adapted from op:numericequal)

Schema:
(?arg_{1} ?arg_{2}; pred:numericequal(?arg_{1} ?arg_{2}))

Domains:
The value spaces of xs:integer, xs:double, xs:float, or xs:decimal for both arguments.

Mapping:
When both s_{1} and s_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:numericequal(?arg_{1} ?arg_{2}) )(a_{1} a_{2}) = t if and only if op:numericequal(a_{1}, a_{2}) returns true, as defined in [XPathFunctions], f otherwise.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
3.5.2.2 pred:numericlessthan (adapted from op:numericlessthan)

Schema:
(?arg_{1} ?arg_{2}; pred:numericlessthan( ?arg_{1} ?arg_{2}) )

Domains:
The value spaces of xs:integer, xs:double, xs:float, or xs:decimal for both arguments.

Mapping:
When both s_{1} and s_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:numericlessthan(?arg_{1} ?arg_{2}) )(a_{1} a_{2}) = t if and only if op:numericlessthan(a_{1}, a_{2}) returns true, as defined in [XPathFunctions], f otherwise.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
3.5.2.3 pred:numericgreaterthan (adapted from op:numericgreaterthan)

Schema:
(?arg_{1} ?arg_{2}; pred:numericgreaterthan( ?arg_{1} ?arg_{2}) )

Domains:
The value spaces of xs:integer, xs:double, xs:float, or xs:decimal for both arguments.

Mapping:
When both s_{1} and s_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:numericgreaterthan(?arg_{1} ?arg_{2}) )(a_{1} a_{2}) = t if and only if op:numericgreaterthan(a_{1}, a_{2}) returns true, as defined in [XPathFunctions], f otherwise.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
3.5.2.4 pred:numericnotequal

Schema:
(?arg_{1} ?arg_{2}; pred:numericnotequal( ?arg_{1} ?arg_{2}) )
The predicate pred:numericnotequal has the same domains as pred:numericequal and is true whenever pred:numericequal is false and false otherwise.
3.5.2.5 pred:numericlessthanorequal

Schema:
(?arg_{1} ?arg_{2}; pred:numericlessthanorequal( ?arg_{1} ?arg_{2}) )
The predicate pred:numericlessthanorequal has the same domains as pred:numericequal and is true whenever pred:numericequal is true or pred:numericlessthan is true and false otherwise.
3.5.2.6 pred:numericgreaterthanorequal

Schema:
(?arg_{1} ?arg_{2}; pred:numericgreaterthanorequal( ?arg_{1} ?arg_{2}) )
The predicate pred:numericgreaterthanorequal has the same domains as pred:numericequal and is true whenever pred:numericequal is true or pred:numericgreaterthan is true and false otherwise.
3.6 Functions and Predicates on Boolean Values
The following functions and predicates are adapted from the respective functions and operators on boolean values in [XPathFunctions].
3.6.1 Functions on Boolean Values
3.6.1.1 func:not (adapted from fn:not)

Schema:
(?arg ; func:not( ?arg ) )

Domain:
The value space of xs:boolean for ?arg.

Mapping:
I_{external}( ?arg ; func:numericmod(?arg) )(a_{1}) = res such that res is the result of fn:not(a_{1}) as defined in [XPathFunctions], in case a_{1} belongs to its domain.
If the argument value is outside of its domain, the value of the function is left unspecified.
3.6.2 Predicates on Boolean Values
3.6.2.1 pred:booleanequal (adapted from op:booleanequal)

Schema:
(?arg_{1} ?arg_{2}; pred:booleanequal(?arg_{1} ?arg_{2}))

Domains:
The value space of xs:boolean for both arguments.

Mapping:
When both a_{1} and a_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:booleanequal(?arg_{1} ?arg_{2}) )(a_{1} a_{2}) = t if and only if op:booleanequal(a_{1}, a_{2}) returns true, as defined in [XPathFunctions], f otherwise.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
The following builtin predicates pred:booleanlessthan and pred:booleangreaterthan are defined analogously with respect to their corresponding operators in [XPathFunctions].
3.6.2.2 pred:booleanlessthan (adapted from op:booleanlessthan)

Schema:
(?arg_{1} ?arg_{2}; pred:booleanlessthan( ?arg_{1} ?arg_{2}) )

Domains:
The value space of xs:boolean for both arguments.

Mapping:
When both a_{1} and a_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:booleanlessthan(?arg_{1} ?arg_{2}) )(a_{1} a_{2}) = t if and only if op:booleanlessthan(a_{1}, a_{2}) returns true, as defined in [XPathFunctions], f otherwise.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
3.6.2.3 pred:booleangreaterthan (adapted from op:booleangreaterthan)

Schema:
(?arg_{1} ?arg_{2}; pred:booleangreaterthan( ?arg_{1} ?arg_{2}) )

Domains:
The value space of xs:boolean for both arguments.

Mapping:
When both a_{1} and a_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:booleangreaterthan(?arg_{1} ?arg_{2}) )(a_{1} a_{2}) = t if and only if op:booleangreaterthan(a_{1}, a_{2}) returns true, as defined in [XPathFunctions], f otherwise.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
3.7 Functions and Predicates on Strings
The following functions and predicates are adapted from the respective functions and operators on strings in [XPathFunctions].
3.7.1 Functions on Strings
3.7.1.1 func:compare (adapted from fn:compare)

Schema:
( ?comparand_{1} ?comparand_{2}; func:compare(?comparand_{1} ?comparand_{2}) )
( ?comparand_{1} ?comparand_{2} ?collation; func:compare(?comparand_{1} ?comparand_{2} ?collation) )

Domains:
The value space of xs:string for ?comparand_{1} and ?comparand_{2}; the domain of ?collation is empty.

Mapping:
I_{external}( ?comparand_{1} ?comparand_{2}; func:compare(?comparand_{1} ?comparand_{2}) )(s_{1} s_{2}) = res such that res = 1, 0, or 1 (from the value space of xs:integer), depending on whether the value of the s_{1} is respectively less than, equal to, or greater than the value of s_{2} according to the default codepoint collation as defined in Section 7.3.1 of [XPathFunctions]. I.e., this function computes the result of fn:compare(s_{1}, s_{2}) as defined in [XPathFunctions], in case all arguments belong to their domains, where the default behavior in RIF is the codepoint collation.
If an argument value is outside of its domain, the value of the function is left unspecified. Note that specifically the defined domain for the ?collation argument is empty in RIF. That means RIF does not prescribe any specific collation apart from the default codepoint collation and  consequently  the result of this function with a given collation argument is not defined by RIF and may vary between implementations.
3.7.1.2 func:concat (adapted from fn:concat)

Schemata:
( ?arg_{1}; func:concat( ?arg_{1} ) )
( ?arg_{1} ?arg_{2}; func:concat(?arg_{1} ?arg_{2} ) )
...
( ?arg_{1} ?arg_{2} ... ?arg_{n}; func:concat(?arg_{1} ?arg_{2} ... ?arg_{n} ) )

Domains:
Following the definition of fn:concat this function accepts xs:anyAtomicType arguments and casts them to xs:string. Thus, the domain for all arguments is the union of all values castable to xs:string as defined in Section Datatype Conversion and Casting above.

Mapping:
I_{external}( ?arg_{1} ... ?arg_{n}; func:concat(?arg_{1} ... ?arg_{n}) )(s_{1} ... s_{n}) = res such that res is the result of fn:concat(s_{1} ... s_{n}) as defined in [XPathFunctions], in case all arguments belong to their domains.
If an argument value is outside of its domain, the value of the function is left unspecified.
3.7.1.3 func:stringjoin (adapted from fn:stringjoin)

Schemata:
( ?arg_{1} ?arg_{2}; func:stringjoin(?arg_{1} ?arg_{2} ) )
( ?arg_{1} ?arg_{2} ?arg_{3}; func:stringjoin(?arg_{1} ?arg_{2} ?arg_{3} ) )
...
( ?arg_{1} ?arg_{2} ... ?arg_{n}; func:stringjoin(?arg_{1} ?arg_{2} ... ?arg_{n} ) )

Domains:
The value space of xs:string for all arguments.

Mapping:
I_{external}( ?arg_{1} ... ?arg_{n}; func:stringjoin(?arg_{1} ... ?arg_{n}) )(s_{1} ... s_{n}) = res such that res is the result of fn:stringjoin(s_{1} ... s_{n}) as defined in [XPathFunctions], in case all arguments belong to their domains.
If an argument value is outside of its domain, the value of the function is left unspecified.
3.7.1.4 func:substring (adapted from fn:substring)

Schemata:
( ?sourceString ?startingLoc; func:substring( ?sourceString ?startingLoc) )
( ?sourceString ?startingLoc ?length ; func:substring( ?sourceString ?startingLoc ?length) )

Domains:
The value space of xs:string for ?sourceString and the union of the value spaces of xs:integer, xs:double, xs:float and xs:decimal for the remaining two arguments.

Mapping:
I_{external}( ?sourceString ?startingLoc ?length; func:substring( ?sourceString ?startingLoc ?length ) )(src loc len) = res such that res is the result of fn:substring(src loc len) as defined in [XPathFunctions], in case all arguments belong to their domains.
If an argument value is outside of its domain, the value of the function is left unspecified.
3.7.1.5 func:stringlength (adapted from fn:stringlength)

Schema:
( ?arg ; func:stringlength( ?arg ) )

Domain:
The value space of xs:string for ?arg.

Mapping:
I_{external}( ?arg; func:stringlength( ?arg ) )(s) = res such that res is the result of fn:stringlength(s) as defined in [XPathFunctions], in case the argument belongs to its domain.
If the argument value is outside of its domain, the value of the function is left unspecified.
3.7.1.6 func:uppercase (adapted from fn:uppercase)

Schema:
( ?arg ; func:uppercase( ?arg ) )

Domain:
The value space of xs:string for ?arg.

Mapping:
I_{external}( ?arg; func:uppercase( ?arg ) )(s) = res such that res is the result of fn:uppercase(s) as defined in [XPathFunctions], in case the argument belongs to its domain.
If the argument value is outside of its domain, the value of the function is left unspecified.
3.7.1.7 func:lowercase (adapted from fn:lowercase)

Schema:
( ?arg ; func:lowercase( ?arg ) )

Domain:
The value space of xs:string for ?arg.

Mapping:
I_{external}( ?arg; func:lowercase( ?arg ) )(s) = res such that res is the result of fn:lowercase(s) as defined in [XPathFunctions], in case the argument belongs to its domain.
If the argument value is outside of its domain, the value of the function is left unspecified.
3.7.1.8 func:encodeforuri (adapted from fn:encodeforuri)

Schema:
( ?arg ; func:encodeforuri( ?arg ) )

Domain:
The value space of xs:string for ?arg.

Mapping:
I_{external}( ?arg; func:encodeforuri( ?arg ) )(s) = res such that res is the result of fn:encodeforuri(s) as defined in [XPathFunctions], in case the argument belongs to its domain.
If the argument value is outside of its domain, the value of the function is left unspecified.
3.7.1.9 func:iritouri (adapted from fn:iritouri)

Schema:
( ?iri ; func:iritouri ( ?arg ) )

Domain:
The value space of xs:string for ?arg.

Mapping:
I_{external}( ?arg; func:iritouri( ?arg ) )(s) = res such that res is the result of fn:iritouri(s) as defined in [XPathFunctions], in case the argument belongs to its domain.
If the argument value is outside of its domain, the value of the function is left unspecified.
3.7.1.10 func:escapehtmluri (adapted from fn:escapehtmluri)

Schema:
( ?uri ;func:escapehtmluri( ?arg ) )

Domain:
The value space of xs:string for ?arg.

Mapping:
I_{external}( ?arg; func:escapehtmluri( ?arg ) )(s) = res such that res is the result of fn:escapehtmluri(s) as defined in [XPathFunctions], in case the argument belongs to its domain.
If the argument value is outside of its domain, the value of the function is left unspecified.
3.7.1.11 func:substringbefore (adapted from fn:substringbefore)

Schema:
( ?arg_{1} ?arg_{2}; func:substringbefore( ?arg_{1} ?arg_{2} ) )
( ?arg_{1} ?arg_{2} ?collation; func:substringbefore( ?arg_{1} ?arg_{2} ?collation ) )

Domains:
The value space of xs:string for ?arg_{1} and ?arg_{2}; the domain of ?collation is empty.

Mapping:
I_{external}( ?arg_{1} ?arg_{2}; func:substringbefore(?arg_{1} ?arg_{2}) )(s_{1} s_{2}) = res, such that res is the substring of s_{1} that precedes in the value of ?s_{1} the first occurrence of a sequence of collation units that provides a minimal match to the collation units of s_{2} according to the default codepoint collation as defined in Section 7.3.1 of [XPathFunctions].
If any argument value is outside of its domain, the value of the function is left unspecified. Note that specifically the defined domain for the ?collation argument is empty in RIF. That means RIF does not prescribe any specific collation apart from the default codepoint collation and  consequently  the result of this function with a given collation argument is not defined by RIF and may vary between implementations.
3.7.1.12 func:substringafter (adapted from fn:substringafter)

Schema:
( ?arg_{1} ?arg_{2}; func:substringafter( ?arg_{1} ?arg_{2} ) )
( ?arg_{1} ?arg_{2} ?collation; func:substringafter( ?arg_{1} ?arg_{2} ?collation ) )

Domains:
The value space of xs:string for ?arg_{1} and ?arg_{2}; the domain of ?collation is empty.

Mapping:
I_{external}( ?arg_{1} ?arg_{2}; func:substringafter(?arg_{1} ?arg_{2}) )(s_{1} s_{2}) = res, such that res is the substring of s_{1} that follows in the value of ?s_{1} the first occurrence of a sequence of collation units that provides a minimal match to the collation units of s_{2} according to the default codepoint collation as defined in Section 7.3.1 of [XPathFunctions].
If any argument value is outside of its domain, the value of the function is left unspecified. Note that specifically the defined domain for the ?collation argument is empty in RIF. That means RIF does not prescribe any specific collation apart from the default codepoint collation and  consequently  the result of this function with a given collation argument is not defined by RIF and may vary between implementations.
3.7.1.13 func:replace (adapted from fn:replace)

Schema:
( ?input ?pattern ?replacement; func:replace( ?input ?pattern ?replacement ) )
( ?input ?pattern ?replacement ?flags; func:replace( ?input ?pattern ?replacement ?flags ) )

Domains:
The value space of xs:string for the first three arguments and all values in the value space of xs:string that are valid flags following Section 7.6.1.1 of [XPathFunctions] for ?flags.

Mapping:
I_{external} ( ?input ?pattern ?replacement ?flags; func:replace( ?input ?pattern ?replacement ?flags ) ) (i p r f ) = res, such that res is the result of fn:replace(i p r f) as defined in [XPathFunctions], in case the arguments belongs to their domains.
If any argument value is outside of its domain, the value of the function is left unspecified.
3.7.2 Predicates on Strings
3.7.2.1 pred:contains (adapted from fn:contains)

Schema:
( ?arg_{1} ?arg_{2}; pred:contains( ?arg_{1} ?arg_{2} ) )
( ?arg_{1} ?arg_{2} ?collation ; pred:contains( ?arg_{1} ?arg_{2} ?collation ) )

Domains:
The value space of xs:string for ?arg_{1} and ?a_{2}; the domain of ?collation is empty.

Mapping:
When all arguments belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:contains(?arg_{1} ?arg_{2}) )(s_{1} s_{2}) = t if and only if fn:contains(s_{1}, s_{2}) returns true, as defined in [XPathFunctions], f otherwise. I.e., this function returns true or false indicating whether or not ?s_{1} contains (at the beginning, at the end, or anywhere within) at least one sequence of collation units that provides a minimal match to the collation units in the value of ?s_{2}, according to the default codepoint collation as defined in Section 7.3.1 of [XPathFunctions].
If an argument value is outside of its domain, the truth value of the function is left unspecified. Note that specifically the defined domain for the ?collation argument is empty in RIF. That means RIF does not prescribe any specific collation apart from the default codepoint collation and  consequently  the result of this function with a given collation argument is not defined by RIF and may vary between implementations.
3.7.2.2 pred:startswith (adapted from fn:startswith)

Schema:
( ?arg_{1} ?arg_{2}; pred:startswith( ?arg_{1} ?arg_{2} )
( ?arg_{1} ?arg_{2} ?collation; pred:startswith( ?arg_{1} ?arg_{2} ?collation)

Domains:
The value space of xs:string for ?arg_{1} and ?a_{2}; the domain of ?collation is empty.

Mapping:
When all arguments belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:startswith(?arg_{1} ?arg_{2}) )(s_{1} s_{2}) = t if and only if fn:startswith(s_{1}, s_{2}) returns true, as defined in [XPathFunctions], f otherwise.
If an argument value is outside of its domain, the value of the function is left unspecified.
3.7.2.3 pred:endswith (adapted from fn:endswith)

Schema:
(?arg_{1} ?arg_{2}; fn:endswith( ?arg_{1} ?arg_{2} ) )
(?arg_{1} ?arg_{2} ?collation; fn:endswith( ?arg_{1} ?arg_{2} ?collation) )

Domains:
The value space of xs:string for ?arg_{1} and ?a_{2}; the domain of ?collation is empty.

Mapping:
When all arguments belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:endswith(?arg_{1} ?arg_{2}) )(s_{1} s_{2}) = t if and only if fn:endswith(s_{1}, s_{2}) returns true, as defined in [XPathFunctions], f otherwise.
If an argument value is outside of its domain, the value of the function is left unspecified.
3.7.2.4 pred:matches (adapted from fn:matches)

Schema:
( ?input ?pattern; pred:matches( ?input ?pattern) )
( ?input ?pattern ?flags; pred:matches( ?input ?pattern ?flags ) )

Domains:
The value space of xs:string for the first two arguments and all values in the value space of xs:string that are valid flags following Section 7.6.1.1 of [XPathFunctions] for ?flags.

Mapping:
When all arguments belong to their domains, I_{truth} ο I_{external}( ?input ?pattern ?flags; pred:matches(?input ?pattern ?flags) )(i p f) = t if and only if pred:matches( i p f ) returns true, as defined in [XPathFunctions], f otherwise.
If an argument value is outside of its domain, the value of the function is left unspecified.
3.8 Functions and Predicates on Dates, Times, and Durations
If not stated otherwise, in the following we define schemas for functions and operators defined on the date, time and duration datatypes in [XPathFunctions].
As defined in Section 3.3.2 Dates and Times, xs:dateTime, xs:date, xs:time, xs:gYearMonth, xs:gYear, xs:gMonthDay, xs:gMonth, xs:gDay values, referred to collectively as date/time values, are represented as seven components or properties: year, month, day, hour, minute, second and timezone. The value of the first five components are xs:integers. The value of the second component is an xs:decimal and the value of the timezone component is an xs:dayTimeDuration. For all the date/time datatypes, the timezone property is optional and may or may not be present. Depending on the datatype, some of the remaining six properties must be present and some must be absent. Absent, or missing, properties are represented by the empty sequence. This value is referred to as the local value in that the value is in the given timezone. Before comparing or subtracting xs:dateTime values, this local value must be translated or normalized to UTC.
3.8.1 Functions on Dates, Times, and Durations
3.8.1.1 func:yearfromdateTime (adapted from fn:yearfromdateTime)

Schema:
( ?arg ; func:yearfromdateTime( ?arg ) )

Domain:
The value space of xs:dateTime for ?arg.

Mapping:
I_{external}( ?arg ; func:yearfromdateTime( ?arg ) )(s) = res
such that res is the result of fn:yearfromdateTime(s) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified.
Note that we we slightly deviate here from the original definition of fn:yearfromdateTime which says: "If ?arg is the empty sequence, returns the empty sequence." The RIF version of func:yearfromdateTime does not support "empty sequences".
3.8.1.2 func:monthfromdateTime (adapted from fn:monthfromdateTime)

Schema:
( ?arg ; func:monthfromdateTime( ?arg ) )

Domain:
The value space of xs:dateTime for ?arg.

Mapping:
I_{external}( ?arg ; func:monthfromdateTime( ?arg ) )(s) = res
such that res is the result of fn:monthfromdateTime(s) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified.
3.8.1.3 func:dayfromdateTime (adapted from fn:dayfromdateTime)

Schema:
( ?arg ; func:dayfromdateTime( ?arg ) )

Domain:
The value space of xs:dateTime for ?arg.

Mapping:
I_{external}( ?arg ; func:dayfromdateTime( ?arg ) )(s) = res
such that res is the result of fn:dayfromdateTime(s) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified.
3.8.1.4 func:hoursfromdateTime (adapted from fn:hoursfromdateTime)

Schema:
( ?arg ; func:hoursfromdateTime( ?arg ) )

Domain:
The value space of xs:dateTime for ?arg.

Mapping:
I_{external}( ?arg ; func:hourfromdateTime( ?arg ) )(s) = res
such that res is the result of fn:hourfromdateTime(s) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified.
3.8.1.5 func:minutesfromdateTime (adapted from fn:minutesfromdateTime)

Schema:
( ?arg ; func:minutesfromdateTime( ?arg ) )

Domain:
The value space of xs:dateTime for ?arg.

Mapping:
I_{external}( ?arg ; func:minutesfromdateTime( ?arg ) )(s) = res
such that res is the result of fn:minutesfromdateTime(s) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified.
3.8.1.6 func:secondsfromdateTime (adapted from fn:secondsfromdateTime)

Schema:
( ?arg ; func:secondsfromdateTime( ?arg ) )

Domain:
The value space of xs:dateTime for ?arg.

Mapping:
I_{external}( ?arg ; func:secondsfromdateTime( ?arg ) )(s) = res
such that res is the result of fn:secondsfromdateTime(s) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified.
3.8.1.7 func:yearfromdate (adapted from fn:yearfromdate)

Schema:
( ?arg ; func:yearfromdate( ?arg ) )

Domain:
The value space of xs:date for ?arg.

Mapping:
I_{external}( ?arg ; func:yearfromdate( ?arg ) )(s) = res
such that res is the result of fn:yearfromdate(s) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified.
3.8.1.8 func:monthfromdate (adapted from fn:monthfromdate)

Schema:
( ?arg ; func:monthfromdate( ?arg ) )

Domain:
The value space of xs:date for ?arg.

Mapping:
I_{external}( ?arg ; func:monthfromdate( ?arg ) )(s) = res
such that res is the result of fn:monthfromdate(s) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified.
3.8.1.9 func:dayfromdate (adapted from fn:dayfromdate)

Schema:
( ?arg ; func:dayfromdate( ?arg ) )

Domain:
The value space of xs:date for ?arg.

Mapping:
I_{external}( ?arg ; func:dayfromdate( ?arg ) )(s) = res
such that res is the result of fn:dayfromdate(s) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified.
3.8.1.10 func:hoursfromtime (adapted from fn:hoursfromtime)

Schema:
( ?arg ; func:hoursfromtime( ?arg ) )

Domain:
The value space of xs:time for ?arg.

Mapping:
I_{external}( ?arg ; func:hoursfromtime( ?arg ) )(s) = res
such that res is the result of fn:hoursfromtime(s) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified.
3.8.1.11 func:minutesfromtime (adapted from fn:minutesfromtime)

Schema:
( ?arg ; func:minutesfromtime( ?arg ) )

Mapping:
I_{external}( ?arg ; func:minutesfromtime( ?arg ) )(s) = res
such that res is the result of fn:minutesfromtime(s) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified.
3.8.1.12 func:secondsfromtime (adapted from fn:secondsfromtime)

Schema:
( ?arg ; func:secondsfromtime( ?arg ) )

Domain:
The value space of xs:time for ?arg.

Mapping:
I_{external}( ?arg ; func:secondsfromtime( ?arg ) )(s) = res
such that res is the result of fn:secondsfromtime(s) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified.
3.8.1.13 func:yearsfromduration (adapted from fn:yearsfromduration)

Schema:
( ?arg ; func:yearsfromduration( ?arg ) )

Domain:
The value space of xs:yearMonthDuration for ?arg.

Mapping:
I_{external}( ?arg ; func:yearsfromduration( ?arg ) )(s) = res
such that res is the result of fn:yearsfromduration(s) as defined in [XPathFunctions].
3.8.1.14 func:monthsfromduration (adapted from fn:monthsfromduration)

Schema:
( ?arg ; func:monthsfromduration( ?arg ) )

Domain:
The value space of xs:yearMonthDuration for ?arg.

Mapping:
I_{external}( ?arg ; func:monthsfromduration( ?arg ) )(s) = res
such that res is the result of fn:monthsfromduration(s) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified.
3.8.1.15 func:daysfromduration (adapted from fn:daysfromduration)

Schema:
( ?arg ; func:daysfromduration( ?arg ) )

Domain:
The value space of xs:dayTimeDuration for ?arg.

Mapping:
I_{external}( ?arg ; func:daysfromduration( ?arg ) )(s) = res
such that res is the result of fn:daysfromduration(s) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified.
3.8.1.16 func:hoursfromduration (adapted from fn:hoursfromduration)

Schema:
( ?arg ; func:hoursfromduration( ?arg ) )

Domain:
The value space of xs:dayTimeDuration for ?arg.

Mapping:
I_{external}( ?arg ; func:hoursfromduration( ?arg ) )(s) = res
such that res is the result of fn:hoursfromduration(s) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified.
3.8.1.17 func:minutesfromduration (adapted from fn:minutesfromduration)

Schema:
( ?arg ; func:minutesfromduration( ?arg ) )

Domain:
The value space of xs:dayTimeDuration for ?arg.

Mapping:
I_{external}( ?arg ; func:minutesfromduration( ?arg ) )(s) = res
such that res is the result of fn:minutesfromduration(s) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified.
3.8.1.18 func:secondsfromduration (adapted from fn:secondsfromduration)

Schema:
( ?arg ; func:secondsfromduration( ?arg ) )

Domain:
The value space of xs:dayTimeDuration for ?arg.

Mapping:
I_{external}( ?arg ; func:secondsfromduration( ?arg ) )(s) = res
such that res is the result of fn:secondsfromduration(s) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified.
3.8.1.19 func:timezonefromdateTime (adapted from fn:timezonefromdateTime)

Schema:
( ?arg ; func:timezonefromdateTime( ?arg ) )

Domain:
The value space of xs:dateTimeStamp.

I_{external}( ?arg ; func:timezonefromdateTime( ?arg ) )(s) = res
such that res is the result of fn:timezonefromdateTime(s) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified. Note that RIF restricts the domain of this function to xs:dateTimeStamp instead of xs:dateTime, i.e. RIF leaves the return value for xs:dateTime values without a timezone unspecified.
The following two functions are defined analogously for domains xs:date and xs:time
3.8.1.20 func:timezonefromdate (adapted from fn:timezonefromdate)

Schema:
( ?arg ; func:timezonefromdate( ?arg ) )

Domain:
The values of value space xs:date with a timezone component.

I_{external}( ?arg ; func:timezonefromdate( ?arg ) )(s) = res
such that res is the result of fn:timezonefromdate(s) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified. Note that RIF restricts the domain of this function to xs:date values with a timezone component, i.e. RIF leaves the return value for xs:date values without a timezone unspecified.
3.8.1.21 func:timezonefromtime (adapted from fn:timezonefromtime)

Schema:
( ?arg ; func:timezonefromtime( ?arg ) )

Domain:
The values of value space xs:time with a timezone component.

I_{external}( ?arg ; func:timezonefromtime( ?arg ) )(s) = res
such that res is the result of fn:timezonefromtime(s) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified. Note that RIF restricts the domain of this function to xs:time values with a timezone component, i.e. RIF leaves the return value for xs:time values without a timezone unspecified.
3.8.1.22 func:subtractdateTimes (adapted from op:subtractdateTimes)

Schema:
( ?arg_{1} ?arg_{2}; func:subtractdateTimes( ?arg_{1} ?arg_{2} ) )

Domain:
The value space of xs:dateTimeStamp for both arguments.

I_{external}( ?arg_{1} ?arg_{2}; func:subtractdateTimes( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:subtractdateTimes(s_{1} s_{2}) as defined in [XPathFunctions].
If the argument value is outside of its domain, the value of the function is left unspecified. Note that RIF restricts the domain of this function to xs:dateTimeStamps instead of xs:dateTime, i.e. RIF leaves the return value for xs:dateTime arguments values without a timezone unspecified.
3.8.1.23 func:subtractdates (adapted from op:subtractdates)

Schema:
( ?arg_{1} ?arg_{2}; func:subtractdates( ?arg_{1} ?arg_{2} ) )

Domain:
The value space of xs:date with given timezone for both arguments.

I_{external}( ?arg_{1} ?arg_{2}; func:subtractdates( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:subtractdates(s_{1} s_{2}) as defined in [XPathFunctions].
If any argument value is outside of its domain, the value of the function is left unspecified. Note that RIF restricts the domain of this function to xs:dates with explicit timezone, i.e. RIF leaves the return value for xs:date arguments values without a timezone unspecified.
3.8.1.24 func:subtracttimes (adapted from op:subtracttimes)

Schema:
( ?arg_{1} ?arg_{2}; func:subtracttimes( ?arg_{1} ?arg_{2} ) )

Domain:
The value space of xs:time with given timezone for both arguments.

I_{external}( ?arg_{1} ?arg_{2}; func:subtracttimes( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:subtracttimes(s_{1} s_{2}) as defined in [XPathFunctions].
If any argument value is outside of its domain, the value of the function is left unspecified. Note that RIF restricts the domain of this function to xs:times with explicit timezone, i.e. RIF leaves the return value for xs:date arguments values without a timezone unspecified.
3.8.1.25 func:addyearMonthDurations (adapted from op:addyearMonthDurations)

Schema:
( ?arg_{1} ?arg_{2}; func:addyearMonthDurations( ?arg_{1} ?arg_{2} ) )

Domain:
The domain of this functions is made up of pairs of values from value spaces of xs:yearMonthDuration for both ?arg_{1} and ?arg_{2} such that fn:addyearMonthDurations does not result in a duration operation overflow/underflow error err:FODT0002 or in a value from the xs:yearMonthDuration value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for durations.

I_{external}( ?arg_{1} ?arg_{2}; func:addyearMonthDurations( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:addyearMonthDurations(s_{1} s_{2}) as defined in [XPathFunctions].
If any argument value is outside of its domain, the value of the function is left unspecified.
3.8.1.26 func:subtractyearMonthDurations (adapted from op:subtractyearMonthDurations)

Schema:
( ?arg_{1} ?arg_{2}; func:subtractyearMonthDurations( ?arg_{1} ?arg_{2} ) )

Domain:
The domain of this functions is made up of pairs of values from value spaces of xs:yearMonthDuration for both ?arg_{1} and ?arg_{2} such that fn:subtractyearMonthDurations does not result in a duration operation overflow/underflow error err:FODT0002 or in a value from the xs:yearMonthDuration value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for durations.

I_{external}( ?arg_{1} ?arg_{2}; func:subtractyearMonthDurations( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:subtractyearMonthDurations(s_{1} s_{2}) as defined in [XPathFunctions].
If any argument value is outside of its domain, the value of the function is left unspecified.
3.8.1.27 func:multiplyyearMonthDuration (adapted from op:multiplyyearMonthDuration)

Schema:
( ?arg_{1} ?arg_{2}; func:multiplyyearMonthDuration( ?arg_{1} ?arg_{2} ) )

Domain:
The domain of this functions is made up of pairs of values from value spaces of xs:yearMonthDuration for ?arg_{1} and xs:integer, xs:double, xs:float, or xs:decimal for ?arg_{2} such that fn:multiplyyearMonthDurations does not result in a duration operation overflow/underflow error err:FODT0002, NaN supplied as double value error err:FOCA0005, or in a value from the xs:yearMonthDuration value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for durations.

I_{external}( ?arg_{1} ?arg_{2}; func:multiplyyearMonthDurations( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:multiplyyearMonthDurations(s_{1} s_{2}) as defined in [XPathFunctions].
If the arguments are outside of the domain, the value of the function is left unspecified.
3.8.1.28 func:divideyearMonthDuration (adapted from op:divideyearMonthDuration)

Schema:
( ?arg_{1} ?arg_{2} ; func:divideyearMonthDuration( ?arg_{1} ?arg_{2} ) )

Domain:
The domain of this functions is made up of pairs of values from value spaces of xs:yearMonthDuration for ?arg_{1} and xs:integer, xs:double, xs:float, or xs:decimal for ?arg_{2} such that fn:divideyearMonthDuration does not result in a duration operation overflow/underflow error err:FODT0002, NaN supplied as double value error err:FOCA0005, or in a value from the xs:yearMonthDuration value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for durations.

I_{external}( ?arg_{1} ?arg_{2}; func:divideyearMonthDuration( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:divideyearMonthDuration(s_{1} s_{2}) as defined in [XPathFunctions].
If the arguments are outside of the domain, the value of the function is left unspecified.
3.8.1.29 func:divideyearMonthDurationbyyearMonthDuration (adapted from op:divideyearMonthDurationbyyearMonthDuration)

Schema:
( ?arg_{1} ?arg_{2}; func:divideyearMonthDurationbyyearMonthDuration( ?arg_{1} ?arg_{2} ) )

Domain:
The domain of this functions is made up of pairs of values from value spaces of xs:yearMonthDuration for both ?arg_{1} and ?arg_{2} such that fn:divideyearMonthDurationbyyearMonthDuration does not result in a duration operation overflow/underflow error err:FODT0002 or in a value from the xs:yearMonthDuration value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for durations.

I_{external}( ?arg_{1} ?arg_{2}; func:divideyearMonthDurationbyyearMonthDuration( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:divideyearMonthDurationbyyearMonthDuration(s_{1} s_{2}) as defined in [XPathFunctions].
If the arguments are outside of the domain, the value of the function is left unspecified.
3.8.1.30 func:adddayTimeDurations (adapted from op:adddayTimeDurations)

Schema:
( ?arg_{1} ?arg_{2}; func:adddayTimeDurations( ?arg_{1} ?arg_{2} ) )

Domain:
The domain of this functions is made up of pairs of values from value space of xs:dayTimeDuration for ?arg_{1} and ?arg_{2} such that fn:adddayTimeDurations does not result in a duration operation overflow/underflow error err:FODT0002 or in a value from the xs:dayTimeDuration value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for durations.

I_{external}( ?arg_{1} ?arg_{2}; func:adddayTimeDurations( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:adddayTimeDurations(s_{1} s_{2}) as defined in [XPathFunctions].
If the arguments are outside of the domain, the value of the function is left unspecified.
3.8.1.31 func:subtractdayTimeDurations (adapted from op:subtractdayTimeDurations)

Schema:
( ?arg_{1} ?arg_{2}; func:subtractdayTimeDurations( ?arg_{1} ?arg_{2} ) )

Domain:
The domain of this functions is made up of pairs of values from value space of xs:dayTimeDuration for ?arg_{1} and ?arg_{2} such that fn:subtractdayTimeDurations does not result in a duration operation overflow/underflow error err:FODT0002 or in a value from the xs:dayTimeDuration value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for durations.

I_{external}( ?arg_{1} ?arg_{2}; func:subtractdayTimeDurations( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:subtractdayTimeDurations(s_{1} s_{2}) as defined in [XPathFunctions].
If the arguments are outside of the domain, the value of the function is left unspecified.
3.8.1.32 func:multiplydayTimeDuration (adapted from op:multiplydayTimeDuration)

Schema:
( ?arg_{1} ?arg_{2}; func:multiplydayTimeDuration( ?arg_{1} ?arg_{2} ) )

Domain:
The domain of this functions is made up of pairs of values from value spaces of xs:dayTimeDuration for ?arg_{1} and xs:integer, xs:double, xs:float, or xs:decimal for ?arg_{2} such that fn:multiplydayTimeDurations does not result in a duration operation overflow/underflow error err:FODT0002, NaN supplied as double value error err:FOCA0005, or in a value from the xs:dayTimeDuration value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for durations.

I_{external}( ?arg_{1} ?arg_{2}; func:multiplydayTimeDurations( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:multiplydayTimeDurations(s_{1} s_{2}) as defined in [XPathFunctions].
If the arguments are outside of the domain, the value of the function is left unspecified.
3.8.1.33 func:dividedayTimeDuration (adapted from op:dividedayTimeDuration)

Schema:
( ?arg_{1} ?arg_{2} ; func:dividedayTimeDuration( ?arg_{1} ?arg_{2} ) )

Domain:
The domain of this functions is made up of pairs of values from value spaces of xs:dayTimeDuration for ?arg_{1} and xs:integer, xs:double, xs:float, or xs:decimal for ?arg_{2} such that fn:dividedayTimeDuration does not result in a duration operation overflow/underflow error err:FODT0002, NaN supplied as double value error err:FOCA0005, or in a value from the xs:dayTimeDuration value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for durations.

I_{external}( ?arg_{1} ?arg_{2}; func:dividedayTimeDuration( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:dividedayTimeDuration(s_{1} s_{2}) as defined in [XPathFunctions].
If the arguments are outside of the domain, the value of the function is left unspecified.
3.8.1.34 func:dividedayTimeDurationbydayTimeDuration (adapted from op:dividedayTimeDurationbydayTimeDuration)

Schema:
( ?arg_{1} ?arg_{2}; func:dividedayTimeDurationbydayTimeDuration( ?arg_{1} ?arg_{2} ) )

Domain:
The domain of this functions is made up of pairs of values from value spaces of xs:dayTimeDuration for both ?arg_{1} and ?arg_{2} such that fn:dividedayTimeDurationbydayTimeDuration does not result in a duration operation overflow/underflow error err:FODT0002 or in a value from the xs:dayTimeDuration value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for durations.

I_{external}( ?arg_{1} ?arg_{2}; func:dividedayTimeDurationbydayTimeDuration( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:dividedayTimeDurationbydayTimeDuration(s_{1} s_{2}) as defined in [XPathFunctions].
If the arguments are outside of the domain, the value of the function is left unspecified.
3.8.1.35 func:addyearMonthDurationtodateTime (adapted from op:addyearMonthDurationtodateTime)

Schema:
( ?arg_{1} ?arg_{2} ; func:addyearMonthDurationtodateTime( ?arg_{1} ?arg_{2} ) )

Domain:
The domain of this functions is made up of pairs of values from value spaces of xs:dateTime for ?arg_{1} and xs:yearMonthDuration for ?arg_{2} such that fn:addyearMonthDurationtodateTime does not result in a date/time operation overflow/underflow error err:FODT0001 or in a value from the xs:dateTime value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for durations.

I_{external}( ?arg_{1} ?arg_{2}; func:addyearMonthDurationtodateTime( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:addyearMonthDurationtodateTime(s_{1} s_{2}) as defined in [XPathFunctions].
If the arguments are outside of the domain, the value of the function is left unspecified.
3.8.1.36 func:addyearMonthDurationtodate (adapted from op:addyearMonthDurationtodate)

Schema:
( ?arg_{1} ?arg_{2} ; func:addyearMonthDurationtodate( ?arg_{1} ?arg_{2} ) )

Domain:
The domain of this functions is made up of pairs of values from value spaces of xs:date for ?arg_{1} and xs:yearMonthDuration for ?arg_{2} such that fn:addyearMonthDurationtodate does not result in a date/time operation overflow/underflow error err:FODT0001 or in a value from the xs:date value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for durations.

I_{external}( ?arg_{1} ?arg_{2}; func:addyearMonthDurationtodate( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:addyearMonthDurationtodate(s_{1} s_{2}) as defined in [XPathFunctions].
If the arguments are outside of the domain, the value of the function is left unspecified.
3.8.1.37 func:adddayTimeDurationtodateTime (adapted from op:adddayTimeDurationtodateTime)

Schema:
( ?arg_{1} ?arg_{2} ; func:adddayTimeDurationtodateTime( ?arg_{1} ?arg_{2} ) )

Domain:
The domain of this functions is made up of pairs of values from value spaces of xs:dateTime for ?arg_{1} and xs:dayTimeDuration for ?arg_{2} such that fn:adddayTimehDurationtodateTime does not result in a date/time operation overflow/underflow error err:FODT0001 or in a value from the xs:dateTime value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for durations.

I_{external}( ?arg_{1} ?arg_{2}; func:adddayTimeDurationtodateTime( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:adddayTimeDurationtodateTime(s_{1} s_{2}) as defined in [XPathFunctions].
If the arguments are outside of the domain, the value of the function is left unspecified.
3.8.1.38 func:adddayTimeDurationtodate (adapted from op:adddayTimeDurationtodate)

Schema:
( ?arg_{1} ?arg_{2} ; func:adddayTimeDurationtodate( ?arg_{1} ?arg_{2} ) )

Domain:
The domain of this functions is made up of pairs of values from value spaces of xs:date for ?arg_{1} and xs:dayTimeDuration for ?arg_{2} such that fn:adddayTimehDurationtodate does not result in a date/time operation overflow/underflow error err:FODT0001 or in a value from the xs:date value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for durations.

I_{external}( ?arg_{1} ?arg_{2}; func:adddayTimeDurationtodate( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:adddayTimeDurationtodate(s_{1} s_{2}) as defined in [XPathFunctions].
If the arguments are outside of the domain, the value of the function is left unspecified.
3.8.1.39 func:adddayTimeDurationtotime (adapted from op:adddayTimeDurationtotime)

Schema:
( ?arg_{1} ?arg_{2} ; func:adddayTimeDurationtotime( ?arg_{1} ?arg_{2} ) )

Domain:
The domain of this functions is made up of pairs of values from value spaces of xs:time for ?arg_{1} and xs:dayTimeDuration for ?arg_{2} such that fn:adddayTimehDurationtotime does not result in a date/time operation overflow/underflow error err:FODT0001 or in a value from the xs:time value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for durations.

I_{external}( ?arg_{1} ?arg_{2}; func:adddayTimeDurationtotime( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:adddayTimeDurationtotime(s_{1} s_{2}) as defined in [XPathFunctions].
If the arguments are outside of the domain, the value of the function is left unspecified.
3.8.1.40 func:subtractyearMonthDurationfromdateTime (adapted from op:subtractyearMonthDurationfromdateTime)

Schema:
( ?arg_{1} ?arg_{2} ; func:subtractyearMonthDurationfromdateTime( ?arg_{1} ?arg_{2} ) )

Domain:
The domain of this functions is made up of pairs of values from value spaces of xs:dateTime for ?arg_{1} and xs:yearMonthDuration for ?arg_{2} such that fn:subtractyearMonthDurationfromdateTime does not result in a date/time operation overflow/underflow error err:FODT0001 or in a value from the xs:dateTime value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for durations.

I_{external}( ?arg_{1} ?arg_{2}; func:subtractyearMonthDurationfromdateTime( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:subtractyearMonthDurationfromdateTime(s_{1} s_{2}) as defined in [XPathFunctions].
If the arguments are outside of the domain, the value of the function is left unspecified.
3.8.1.41 func:subtractyearMonthDurationfromdate (adapted from op:subtractyearMonthDurationfromdate)

Schema:
( ?arg_{1} ?arg_{2} ; func:subtractyearMonthDurationfromdate( ?arg_{1} ?arg_{2} ) )

Domain:
The domain of this functions is made up of pairs of values from value spaces of xs:date for ?arg_{1} and xs:yearMonthDuration for ?arg_{2} such that fn:subtractyearMonthDurationfromdate does not result in a date/time operation overflow/underflow error err:FODT0001 or in a value from the xs:date value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for durations.

I_{external}( ?arg_{1} ?arg_{2}; func:subtractyearMonthDurationfromdate( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:subtractyearMonthDurationfromdate(s_{1} s_{2}) as defined in [XPathFunctions].
If the arguments are outside of the domain, the value of the function is left unspecified.
3.8.1.42 func:subtractdayTimeDurationfromdateTime (adapted from op:subtractdayTimeDurationfromdateTime)

Schema:
( ?arg_{1} ?arg_{2} ; func:subtractdayTimeDurationfromdateTime( ?arg_{1} ?arg_{2} ) )

Domain:
The domain of this functions is made up of pairs of values from value spaces of xs:dateTime for ?arg_{1} and xs:dayTimeDuration for ?arg_{2} such that fn:subtractdayTimehDurationfromdateTime does not result in a date/time operation overflow/underflow error err:FODT0001 or in a value from the xs:dateTime value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for durations.

I_{external}( ?arg_{1} ?arg_{2}; func:subtractdayTimeDurationfromdateTime( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:subtractdayTimeDurationfromdateTime(s_{1} s_{2}) as defined in [XPathFunctions].
If the arguments are outside of the domain, the value of the function is left unspecified.
3.8.1.43 func:subtractdayTimeDurationfromdate (adapted from op:subtractdayTimeDurationfromdate)

Schema:
( ?arg_{1} ?arg_{2} ; func:subtractdayTimeDurationfromdate( ?arg_{1} ?arg_{2} ) )

Domain:
The domain of this functions is made up of pairs of values from value spaces of xs:date for ?arg_{1} and xs:dayTimeDuration for ?arg_{2} such that fn:subtractdayTimehDurationfromdate does not result in a date/time operation overflow/underflow error err:FODT0001 or in a value from the xs:date value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for durations.

I_{external}( ?arg_{1} ?arg_{2}; func:subtractdayTimeDurationfromdate( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:subtractdayTimeDurationfromdate(s_{1} s_{2}) as defined in [XPathFunctions].
If the arguments are outside of the domain, the value of the function is left unspecified.
3.8.1.44 func:subtractdayTimeDurationfromtime (adapted from op:subtractdayTimeDurationfromtime)

Schema:
( ?arg_{1} ?arg_{2} ; func:subtractdayTimeDurationfromtime( ?arg_{1} ?arg_{2} ) )

Domain:
The domain of this functions is made up of pairs of values from value spaces of xs:time for ?arg_{1} and xs:dayTimeDuration for ?arg_{2} such that fn:subtractdayTimehDurationfromtime does not result in a date/time operation overflow/underflow error err:FODT0001 or in a value from the xs:time value space outside what minimal conformance as defined in Section 5.4 of [XMLSCHEMA2] requires for durations.

I_{external}( ?arg_{1} ?arg_{2}; func:subtractdayTimeDurationfromtime( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = res
such that res is the result of fn:subtractdayTimeDurationfromTime_{1} s_{2}) as defined in [XPathFunctions].
If the arguments are outside of the domain, the value of the function is left unspecified.
3.8.2 Predicates on Dates, Times, and Durations
3.8.2.1 pred:dateTimeequal (adapted from op:dateTimeequal)

Schema:
( ?arg_{1} ?arg_{2}; pred:dateTimeequal( ?arg_{1} ?arg_{2}) )

Domains:
The value space of xs:dateTime for both arguments.

Mapping:
When both s_{1} and s_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:dateTimeequal( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = t
if and only if op:dateTimeequal(s_{1}, s_{2}) returns true, as defined in [XPathFunctions], f in case false is returned.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
3.8.2.2 pred:dateTimelessthan (adapted from op:dateTimelessthan)

Schema:
( ?arg_{1} ?arg_{2}; pred:dateTimelessthan(?arg_{1} ?arg_{2} ) )

Domains:
The value space of xs:dateTime for both arguments.

Mapping:
When both s_{1} and s_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:dateTimelessthan( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = t
if and only if op:dateTimelessthan(s_{1}, s_{2}) returns true, as defined in [XPathFunctions], f in case false is returned.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
3.8.2.3 pred:dateTimegreaterthan (adapted from op:dateTimegreaterthan)

Schema:
( ?arg_{1} ?arg_{2}; pred:dateTimegreaterthan(?arg_{1} ?arg_{2} ) )

Domains:
The value space of xs:dateTime for both arguments.

Mapping:
When both s_{1} and s_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:dateTimegreaterthan( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = t
if and only if op:dateTimegreaterthan(s_{1}, s_{2}) returns true, as defined in [XPathFunctions], f in case false is returned.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
3.8.2.4 pred:dateequal (adapted from op:dateequal)

Schema:
( ?arg_{1} ?arg_{2}; pred:dateequal( ?arg_{1} ?arg_{2}) )

Domains:
The value space of xs:date for both arguments.

Mapping:
When both s_{1} and s_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:dateequal( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = t
if and only if op:dateequal(s_{1}, s_{2}) returns true, as defined in [XPathFunctions], f in case false is returned.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
3.8.2.5 pred:datelessthan (adapted from op:datelessthan)

Schema:
( ?arg_{1} ?arg_{2}; pred:datelessthan(?arg_{1} ?arg_{2} ) )

Domains:
The value space of xs:date for both arguments.

Mapping:
When both s_{1} and s_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:datelessthan( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = t
if and only if op:datelessthan(s_{1}, s_{2}) returns true, as defined in [XPathFunctions], f in case false is returned.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
3.8.2.6 pred:dategreaterthan (adapted from op:dategreaterthan)

Schema:
( ?arg_{1} ?arg_{2}; pred:dategreaterthan(?arg_{1} ?arg_{2} ) )

Domains:
The value space of xs:date for both arguments.

Mapping:
When both s_{1} and s_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:dategreaterthan( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = t
if and only if op:dategreaterthan(s_{1}, s_{2}) returns true, as defined in [XPathFunctions], f in case false is returned.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
3.8.2.7 pred:timeequal (adapted from op:timeequal)

Schema:
( ?arg_{1} ?arg_{2}; pred:timeequal( ?arg_{1} ?arg_{2}) )

Domains:
The value space of xs:time for both arguments.

Mapping:
When both s_{1} and s_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:timeequal( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = t
if and only if op:timeequal(s_{1}, s_{2}) returns true, as defined in [XPathFunctions], f in case false is returned.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
3.8.2.8 pred:timelessthan (adapted from op:timelessthan)

Schema:
( ?arg_{1} ?arg_{2}; pred:timelessthan(?arg_{1} ?arg_{2} ) )

Domains:
The value space of xs:time for both arguments.

Mapping:
When both s_{1} and s_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:timelessthan( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = t
if and only if op:timelessthan(s_{1}, s_{2}) returns true, as defined in [XPathFunctions], f in case false is returned.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
3.8.2.9 pred:timegreaterthan (adapted from op:timegreaterthan)

Schema:
( ?arg_{1} ?arg_{2}; pred:timegreaterthan(?arg_{1} ?arg_{2} ) )

Domains:
The value space of xs:time for both arguments.

Mapping:
When both s_{1} and s_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:timegreaterthan( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = t
if and only if op:timegreaterthan(s_{1}, s_{2}) returns true, as defined in [XPathFunctions], f in case false is returned.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
3.8.2.10 pred:durationequal (adapted from op:durationequal)

Schema:
( ?arg_{1} ?arg_{2}; pred:durationequal( ?arg_{1} ?arg_{2}) )

Domains:
The union of the value spaces of xs:dayTimeDuration and xs:yearMonthDuration for both arguments.
Mapping:
When both s_{1} and s_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:durationequal( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = t
if and only if op:durationequal(s_{1}, s_{2}) returns true, as defined in [XPathFunctions], f in case false is returned.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
3.8.2.11 pred:dayTimeDurationlessthan (adapted from op:dayTimeDurationlessthan)

Schema:
( ?arg_{1} ?arg_{2}; pred:dayTimeDurationlessthan(?arg_{1} ?arg_{2} ) )

Domains:
The value space of xs:dayTimeDuration for both arguments.

Mapping:
When both s_{1} and s_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:dayTimeDurationlessthan( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = t
if and only if op:dayTimeDurationlessthan(s_{1}, s_{2}) returns true, as defined in [XPathFunctions], f in case false is returned.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
3.8.2.12 pred:dayTimeDurationgreaterthan (adapted from op:dayTimeDurationgreaterthan)

Schema:
( ?arg_{1} ?arg_{2}; pred:dayTimeDurationgreaterthan(?arg_{1} ?arg_{2} ) )

Domains:
The value space of xs:dayTimeDuration for both arguments.

Mapping:
When both s_{1} and s_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:dayTimeDurationgreaterthan( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = t
if and only if op:dayTimeDurationgreaterthan(s_{1}, s_{2}) returns true, as defined in [XPathFunctions], f in case false is returned.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
3.8.2.13 pred:yearMonthDurationlessthan (adapted from op:yearMonthDurationlessthan)

Schema:
( ?arg_{1} ?arg_{2}; pred:yearMonthDurationlessthan(?arg_{1} ?arg_{2} ) )

Domains:
The value space of xs:yearMonthDuration for both arguments.

Mapping:
When both s_{1} and s_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:yearMonthDurationlessthan( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = t
if and only if op:yearMonthDurationlessthan(s_{1}, s_{2}) returns true, as defined in [XPathFunctions], f in case false is returned.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
3.8.2.14 pred:yearMonthDurationgreaterthan (adapted from op:yearMonthDurationgreaterthan)

Schema:
( ?arg_{1} ?arg_{2}; pred:yearMonthDurationgreaterthan(?arg_{1} ?arg_{2} ) )

Domains:
The value space of xs:yearMonthDuration for both arguments.

Mapping:
When both s_{1} and s_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:yearMonthDurationgreaterthan( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = t
if and only if op:yearMonthDurationgreaterthan(s_{1}, s_{2}) returns true, as defined in [XPathFunctions], f in case false is returned.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
3.8.2.15 pred:dateTimenotequal

Schema:
(?arg_{1} ?arg_{2}; pred:dateTimenotequal( ?arg_{1} ?arg_{2}) )
The predicate pred:dateTimenotequal has the same domains as pred:dateTimeequal and is true whenever pred:dateTimeequal is false.
3.8.2.16 pred:dateTimelessthanorequal

Schema:
(?arg_{1} ?arg_{2}; pred:dateTimelessthanorequal( ?arg_{1} ?arg_{2}) )
The predicate pred:dateTimelessthanorequal has the same domains as pred:dateTimeequal and is true whenever pred:dateTimeequal is true or pred:dateTimelessthan is true.
3.8.2.17 pred:dateTimegreaterthanorequal

Schema:
(?arg_{1} ?arg_{2}; pred:dateTimegreaterthanorequal( ?arg_{1} ?arg_{2}) )
The predicate pred:dateTimegreaterthanorequal has the same domains as pred:dateTimeequal and is true whenever pred:dateTimeequal is true or pred:dateTimegreaterthan is true.
3.8.2.18 pred:datenotequal

Schema:
(?arg_{1} ?arg_{2}; pred:datenotequal( ?arg_{1} ?arg_{2}) )
The predicate pred:datenotequal has the same domains as pred:dateequal and is true whenever pred:dateequal is false.
3.8.2.19 pred:datelessthanorequal

Schema:
(?arg_{1} ?arg_{2}; pred:datelessthanorequal( ?arg_{1} ?arg_{2}) )
The predicate pred:datelessthanorequal has the same domains as pred:dateequal and is true whenever pred:dateequal is true or pred:datelessthan is true.
3.8.2.20 pred:dategreaterthanorequal

Schema:
(?arg_{1} ?arg_{2}; pred:dategreaterthanorequal( ?arg_{1} ?arg_{2}) )
The predicate pred:dategreaterthanorequal has the same domains as pred:dateequal and is true whenever pred:dateequal is true or pred:dategreaterthan is true.
3.8.2.21 pred:timenotequal

Schema:
(?arg_{1} ?arg_{2}; pred:timenotequal( ?arg_{1} ?arg_{2}) )
The predicate pred:timenotequal has the same domains as pred:timeequal and is true whenever pred:timeequal is false.
3.8.2.22 pred:timelessthanorequal

Schema:
(?arg_{1} ?arg_{2}; pred:timelessthanorequal( ?arg_{1} ?arg_{2}) )
The predicate pred:timelessthanorequal has the same domains as pred:timeequal and is true whenever pred:timeequal is true or pred:timelessthan is true.
3.8.2.23 pred:timegreaterthanorequal

Schema:
(?arg_{1} ?arg_{2}; pred:timegreaterthanorequal( ?arg_{1} ?arg_{2}) )
The predicate pred:timegreaterthanorequal has the same domains as pred:timeequal and is true whenever pred:timeequal is true or pred:timegreaterthan is true.
3.8.2.24 pred:durationnotequal

Schema:
(?arg_{1} ?arg_{2}; pred:durationnotequal( ?arg_{1} ?arg_{2}) )
The predicate pred:durationequal has the same domains as pred:durationequal and is true whenever pred:durationequal is false.
3.8.2.25 pred:dayTimeDurationlessthanorequal

Schema:
(?arg_{1} ?arg_{2}; pred:dayTimeDurationlessthanorequal( ?arg_{1} ?arg_{2}) )
The predicate pred:dayTimeDurationlessthanorequal has the same domains as pred:dayTimeDurationlessthan and is true whenever pred:durationequal is true or pred:dayTimeDurationlessthan is true.
3.8.2.26 pred:dayTimeDurationgreaterthanorequal

Schema:
(?arg_{1} ?arg_{2}; pred:dayTimeDurationgreaterthan( ?arg_{1} ?arg_{2}) )
The predicate pred:dayTimeDurationgreaterthanorequal has the same domains as pred:dayTimeDurationgreaterthan and is true whenever pred:durationequal is true or pred:dayTimeDurationgreaterthan is true.
3.8.2.27 pred:yearMonthDurationlessthanorequal

Schema:
(?arg_{1} ?arg_{2}; pred:yearMonthDurationlessthanorequal( ?arg_{1} ?arg_{2}) )
The predicate pred:yearMonthDurationlessthanorequal has the same domains as pred:yearMonthDurationlessthan and is true whenever pred:durationequal is true or pred:yearMonthDurationlessthan is true.
3.8.2.28 pred:yearMonthDurationgreaterthanorequal

Schema:
(?arg_{1} ?arg_{2}; pred:yearMonthDurationgreaterthan( ?arg_{1} ?arg_{2}) )
The predicate pred:yearMonthDurationgreaterthanorequal has the same domains as pred:yearMonthDurationgreaterthan and is true whenever pred:durationequal is true or pred:yearMonthDurationgreaterthan is true.
3.9 Functions and Predicates on rdf:XMLLiterals
3.9.1 pred:XMLLiteralequal

Schema:
( ?arg_{1} ?arg_{2}; pred:XMLLiteralequal( ?arg_{1} ?arg_{2}) )

Domains:
The value space of rdf:XMLLiteral for both arguments.

Mapping:
When both s_{1} and s_{2} belong to their domains, I_{truth} ο I_{external}( ?arg_{1} ?arg_{2}; pred:XMLLiteralequal( ?arg_{1} ?arg_{2} ) )(s_{1} s_{2}) = t
if and only if s_{1} = s_{2}, f otherwise.
If an argument value is outside of its domain, the truth value of the function is left unspecified.
3.9.2 pred:XMLLiteralnotequal

Schema:
(?arg_{1} ?arg_{2}; pred:XMLLiteralnotequal( ?arg_{1} ?arg_{2}) )
The predicate pred:timenotequal has the same domains as pred:XMLLiteralequal and is true whenever pred:XMLLiteralequal is false.
3.10 Functions and Predicates on rdf:PlainLiteral
The following functions and predicates are adapted from the respective functions and operators in [RDFPLAINLITERAL].
Editor's Note: Issues which are still open in the rdf:PlainLiteral specification might imply future changes on the functions and predicates defined here. For instance plfn:compare and plfn:length are curently marked AT RISK. We could subsume these functions under a single func:compare and func:compare function, instead of defining separate functions for xs:string and rdf:PlainLiteral, or drop them alltogether for redundancy. Moreover, references and links to the [RDFPLAINLITERAL] document will be updated in future versions of this document.
3.10.1 Functions on rdf:PlainLiteral
3.10.1.1 func:PlainLiteralfromstringlang (adapted from plfn:PlainLiteralfromstringlang)

Schema:
(?arg_{1} ?arg_{2} ; func:PlainLiteralfromstringlang( ?arg_{1} ?arg_{2} ) )

Domains:
The value space of xs:string for ?arg_{1} and the intersection of the elements of the value space of xs:string which represent valid language tags according to [BCP47] for ?arg_{2}.

Mapping:
I_{external}((?arg_{1} ?arg_{2} ; func:PlainLiteralfromstringlang( ?arg_{1} ?arg_{2} ) )(s l) = res such that res is the pair < s, l > in the value space of rdf:PlainLiteral.
If any argument value is outside of its domain, the value of the function is left unspecified.
3.10.1.2 func:stringfromPlainLiteral (adapted from plfn:stringfromPlainLiteral)

Schema:
(?arg ; func:stringfromPlainLiteral( ?arg ) )

Domain:
The value space of rdf:PlainLiteral for ?arg.

Mapping:
I_{external}(?arg ; func:stringfromPlainLiteral( ?arg ) )(t) = res such that res is the string part s of t if t is a pair < s, l > or res = t if t is a string value.
If the argument value is outside of its domain, the value of the function is left unspecified.
3.10.1.3 func:langfromPlainLiteral (adapted from plfn:langfromPlainLiteral)

Schema:
(?arg ; func:langfromPlainLiteral( ?arg ) )

Domain:
The value space of rdf:PlainLiteral for ?arg.

Mapping:
I_{external}(?arg ; func:langfromPlainLiteral( ?arg ) )(t) = l such that l is the language tag string of t if t is a pair < s, l > and ""^^xs:string if t is a string value.
If the argument value is outside of its domain, the value of the function is left unspecified.
3.10.1.4 func:PlainLiteralcompare (adapted from plfn:compare)

Schema:
( ?comparand_{1} ?comparand_{2}; func:PlainLiteralcompare(?comparand_{1} ?comparand_{2}) )
( ?comparand_{1} ?comparand_{2} ?collation; func:PlainLiteralcompare(?comparand_{1} ?comparand_{2} ?collation) )

Domains:
The value space of rdf:PlainLiteral for ?comparand_{1} and $comparand_{2}, and the empty set for ?collation.

Mapping:
I_{external}( ?comparand_{1} ?comparand_{2}; func:PlainLiteralcompare(?comparand_{1} ?comparand_{2}) )(t_{1} t_{2}) = res such that, whenever t_{1}=( s_{1}, l ) and t_{2}=( s_{2}, l ) are two pairs with the same language tag l in the value space ofrdf:PlainLiteral, or two string values t_{1}=s_{1} and t_{2}=s_{2}, respectively, then res = 1, 0, or 1 (from the value space of xs:integer), depending on whether the value of s_{1} is respectively less than, equal to, or greater than the value of s_{2} according to the default codepoint collation as defined in Section 7.3.1 of [XPathFunctions].
In case an argument value is outside of its domain, or if the language tags of the values for ?comparand_{1} and $comparand_{2} differ, the function value is left unspecified. That means RIF does not prescribe any specific collation apart from the default codepoint collation and  consequently  the result of this function with a given collation argument is not defined by RIF and may vary between implementations.
3.10.1.5 func:PlainLiterallength (adapted from plfn:length)

Schema:
( ?arg ; func:PlainLiterallength( ?arg ) )

Domain:
The value space of rdf:PlainLiteral for ?arg.

Mapping:
I_{external}( ?arg ; func:PlainLiterallength( ?arg ) )(s) = res such that res is a value in the value space of xs:integer equal to the length in characters of the string part s of the argument if it is a pair ( s,l ), or the argument is a string value s, respectively.
If the argument value is outside of its domain, the value of the function is left unspecified.
3.10.2 Predicates on rdf:PlainLiteral
3.10.2.1 pred:matcheslanguagerange (adapted from plfn:matcheslanguagerange)

Schema:
( ?input ?range; pred:matcheslanguagerange( ?input ?range) )

Domains:
The value space of rdf:PlainLiteral for ?input and the values of value space xs:string that correspond to valid language tags according to [BCP47] for ?range.

Mapping:
Whenever both arguments are within their domains, <p>I_{external} ( ?input ?range; pred:matcheslanguagerange( ?input ?range) )(i r) = t if and only if plfn:matcheslanguagerange(i r) as specified in [RDFPLAINLITERAL] returns true, f otherwise.
If an argument value is outside of its domain, the truth value of the predicate is left unspecified.
3.11 Functions and Predicates on RIF Lists
RIF Lists are similar to list and array types in many systems, as well as XPath/XQuery Sequences [XPathFunctions]. They differ from XPath as follows:
 They are called "lists" instead of sequences (so the "subsequence" function is called "sublist")
 Positions (indexes) count from zero, instead of one, and negative indexes are defined to count back from the end of the list
 They are not limited to containing only atomic data; in particular, they may contain other lists.
3.11.1 Position Numbering
The positions in a list are numbered starting with the first item being zero. When a negative position number is provided to a builtin, the length of the list is added to it before it is used, so it effectively counts backward from the end of the list. (Position 1 is the last item in the list, etc.)
3.11.2 Item Comparison
List items are compared for equality (as required by many of these builtins) using normal RIF equality testing, not datatype equality (eg numericequal).
Several list builtins need to establish inequality in order to compute a result. If all the compared items are literals or lists, this is not a problem, but if they are rif:local or rif:iri terms, the knowledge base is unlikely to contain inequality information. This may lead to counterintuitive results. For example, the empty ruleset does not entail indexof(list(eg:foo eg:bar), eg:foo) == list(0), because the empty ruleset provides no indication whether eg:foo = eg:bar.
3.11.3 Predicates on RIF Lists
3.11.3.1 pred:islist

Schema:
(?object; pred:islist(?object))

Domains:
?object: unrestricted

Informal Mapping
A guard predicate, true if ?object is a list, and false otherwise.

Examples
islist(List(0 1 2 3)) = True islist(1) = False islist(List(0 1 2 List(3 4))) = True
3.11.3.2 pred:listcontains

Schema:
(?list ?matchvalue; pred:listcontains(?list ?matchvalue))

Domains:
?list: D_{list}
?matchvalue: unrestricted

Informal Mapping
True only if ?item is in ?list.
If an argument value is outside of its domain, the value of the function is left unspecified.

Examples
listcontains(List(0 1 2 3 4) 2) = True listcontains(List(0 1 2 3 4 5 2 2) 2) = True listcontains(List(2 2 3 4 5 2 2) 1) = False listcontains(List() 1) = False listcontains(List(0 1 2 3 List(7 8)) List(7 8)) = True listcontains(List(0 1 2 3 List(7 8)) List(7 7)) = False
3.11.4 Functions on RIF Lists
3.11.4.1 func:makelist

Schema:
(?item0 ... ?itemn; func:makelist(?item0 ... ?itemn))

Domains:
?item0: unrestricted
...
?itemn: unrestricted

Informal Mapping
Returns a list of the arguments item0, ... itemn, in the same order they appear as arguments.

Note
This function is useful in RIF Core because the List construction operator is syntactically prohibited from being used with variables.

Examples
makelist(0 1 2) = List(0 1 2) makelist() = List() makelist(0) = List(0) makelist(0 1 List(20 21)) = List(0 1 List(20 21)) makelist(List(0 1)) = List(List(0 1))
3.11.4.2 func:count (adapted from fn:count)

Schema:
(?list; func:count(?list))

Domains:
?list: D_{list}

Informal Mapping
Returns the number of entries in the list (the length of the list).
If an argument value is outside of its domain, the value of the function is left unspecified.

Examples
count(List(0 1 2 3 4)) = 5 count(List(0)) = 1 count(List(0 0 0)) = 3 count(List()) = 0
3.11.4.3 func:get

Schema:
(?list ?position; func:get(?list ?position))

Domains:
?list: D_{list}
?position: value space of xs:int

Informal Mapping
Returns the item at the given position in the list
If an argument value is outside of its domain, the value of the function is left unspecified.

Examples
get(List(0 1 2 3 4) 0) = 0 get(List(0 1 2 3 4) 1) = 1 get(List(0 1 2 3 4) 4) = 4 get(List(0 1 2 3 4) 1) = 4 get(List(0 1 2 3 4) 5) = 0 get(List(0 1 2 3 4) 10) = (unspecified) get(List(0 1 2 3 4) 5) = (unspecified)
3.11.4.4 func:sublist (adapted from fn:subsequence)

Schema:
(?list ?start ?stop; func:sublist(?list ?start ?stop))
(?list ?start; func:sublist(?list ?start))

Domains:
?list: D_{list}
?start: value space of xs:int
?stop: value space of xs:int

Informal Mapping
Returns a list, containing (in order) the items starting at position 'start' and continuing up to, but not including, the 'stop' position. The 'stop' position may be omitted, in which case it defaults to the length of the list.
If an argument value is outside of its domain, the value of the function is left unspecified.

Note
This differs from xpath's subsequence function in using a 'stop' position parameter instead of a 'length' parameter (in addition to the name change, the zerobased indexing, and allowing negative indexes).

Examples
sublist(List(0 1 2 3 4) 0 0) = List() sublist(List(0 1 2 3 4) 0 1) = List(0) sublist(List(0 1 2 3 4) 0 4) = List(0 1 2 3) sublist(List(0 1 2 3 4) 0 5) = List(0 1 2 3 4) sublist(List(0 1 2 3 4) 0 10) = List(0 1 2 3 4) sublist(List(0 1 2 3 4) 0 2) = List(0 1 2) sublist(List(0 1 2 3 4) 2 4) = List(2 3) sublist(List(0 1 2 3 4) 2 2) = List(2) sublist(List(0 1 2 3 4) 0) = List(0 1 2 3 4) sublist(List(0 1 2 3 4) 3) = List(3 4) sublist(List(0 1 2 3 4) 2) = List(3 4)
3.11.4.5 func:append

Schema:
(?list ?item1 ... ?itemn; func:append(?list ?item1 ... ?itemn))

Domains:
?list: D_{list}
?item1: unrestricted
...
?itemn: unrestricted

Informal Mapping
Returns a list consisting of all the items in list_{1}, followed by itemi, for each i, 1 <= i <= n.
If an argument value is outside of its domain, the value of the function is left unspecified.

Examples
append(List(0 1 2) 3) = List(0 1 2 3) append(List(0 1 2) 3 4) = List(0 1 2 3 4) append(List(1 1) List(1) List(1) List(List(1))) = List(1 1 List(1) List(1) List(List(1))) append(List() 1) = List(1)
3.11.4.6 func:concatenate (adapted from fn:concatenate)

Schema:
(?list_{1} ... ?list_{n}; func:concatenate(?list_{1} ... ?list_{n}))
 Domains:

Informal Mapping
Returns a list consisting of all the items in list_{1}, followed by all the items in list_{i}, for each i <= n.
If an argument value is outside of its domain, the value of the function is left unspecified.

Examples
concatenate(List(0 1 2) List(3 4 5)) = List(0 1 2 3 4 5) concatenate(List(1 1) List(1) List(1)) = List(1 1 1 1) concatenate(List()) = List() concatenate(List() List(1) List() List(2)) = List(1 2)
3.11.4.7 func:insertbefore (adapted from fn:insertbefore)

Schema:
(?list_{1} ?position ?newitem; func:insertbefore(?list_{1} ?position ?newitem))

Domains:
?list1: D_{list}
?position: value space of xs:int
?newitem: unrestricted

Informal Mapping
Return a list which is ?list_{1}, except that ?newitem is inserted at the given ?position, with the item (if any) that was at that position, and all following items, shifted down one position.
If an argument value is outside of its domain, the value of the function is left unspecified.

Examples
insertbefore(List(0 1 2 3 4) 0 99) = List(99 0 1 2 3 4) insertbefore(List(0 1 2 3 4) 1 99) = List(0 99 1 2 3 4) insertbefore(List(0 1 2 3 4) 5 99) = (unspecified) insertbefore(List(0 1 2 3 4) 1 99) = List(0 1 2 3 99 4) insertbefore(List(0 1 2 3 4) 5 99) = List(99 0 1 2 3 4) insertbefore(List(0 1 2 3 4) 10 99) = (unspecified)
3.11.4.8 func:remove (adapted from fn:remove)

Schema:
(?list_{1} ?position; func:remove(?list_{1} ?position))

Domains:
?list1: D_{list}
?position: value space of xs:int

Informal Mapping
Returns a list which is list_{1} except that the item at the given ?position has been removed.
If an argument value is outside of its domain, the value of the function is left unspecified.

Examples
remove(List(0 1 2 3 4) 0) = List(1 2 3 4) remove(List(0 1 2 3 4) 1) = List(0 2 3 4) remove(List(0 1 2 3 4) 4) = List(0 1 2 3) remove(List(0 1 2 3 4) 5) = (unspecified) remove(List(0 1 2 3 4) 6) = (unspecified) remove(List(0 1 2 3 4) 1) = List(0 1 2 3) remove(List(0 1 2 3 4) 5) = List(1 2 3 4) remove(List(0 1 2 3 4) 6) = (unspecified)
3.11.4.9 func:reverse (adapted from fn:reverse)

Schema:
(?list_{1}; func:reverse(?list_{1}))

Domains:
?list1: D_{list}

Informal Mapping
Return a list with all the items in list_{1}, but in reverse order
If an argument value is outside of its domain, the value of the function is left unspecified.

Examples
reverse(List(0 1 2 3 4)) = List(4 3 2 1 0) reverse(List(1)) = List(1) reverse(List()) = List()
3.11.4.10 func:indexof (adapted from fn:indexof)

Schema:
(?list ?matchvalue; func:indexof(?list ?matchvalue))

Domains:
?list: D_{list}
?matchvalue: unrestricted

Informal Mapping
Returns the ascending list of all integers, i>=0, such that get(list_{1},i) = match_value
If an argument value is outside of its domain, the value of the function is left unspecified.

Examples
indexof(List(0 1 2 3 4) 2) = List(2) indexof(List(0 1 2 3 4 5 2 2) 2) = List(2 6 7) indexof(List(2 2 3 4 5 2 2) 2) = List(0 1 5 6) indexof(List(2 2 3 4 5 2 2) 1) = List()
3.11.4.11 func:union (adapted from fn:union)

Schema:
(?list_{1} ... ?list_{n}; func:union(?list_{1} ... ?list_{n}))
 Domains:

Informal Mapping
Returns a list containing all the items in list_{1}, ..., list_{n}, in the same order, but with all duplicates removed. Equivalent to distinct_values(concatenate(list_{1}, ..., list_{n})).
If an argument value is outside of its domain, the value of the function is left unspecified.

Examples
union(List(0 1 2 4) List(3 4 5 6)) = List(0 1 2 4 3 5 6) union(List(0 1 2 3) List(4)) = List(0 1 2 3 4) union(List(0 1 2 3) List(3)) = List(0 1 2 3)
3.11.4.12 func:distinctvalues (adapted from fn:distinctvalues)

Schema:
(?list_{1}; func:distinctvalues(?list_{1}))

Domains:
?list1: D_{list}

Informal Mapping
Returns a list which contains exactly those items which are in list_{1}, in the same order, except that additional occurances of any item are deleted.
If an argument value is outside of its domain, the value of the function is left unspecified.

Examples
distinctvalues(List(0 1 2 3 4)) = List(0 1 2 3 4) distinctvalues(List(0 1 2 3 4 0 4)) = List(0 1 2 3 4) distinctvalues(List(3 3 3)) = List(3)
3.11.4.13 func:intersect (adapted from fn:intersect)

Schema:
(?list_{1} ... ?list_{n}; func:intersect(?list_{1} ... ?list_{n}))
 Domains:

Informal Mapping
Returns a list which contains exactly those items which are list_{i} for i <= n. The order of the items in the returned is the same as the order in list_{1}.
If an argument value is outside of its domain, the value of the function is left unspecified.

Examples
intersect(List(0 1 2 3 4) List(1 3)) = List(1 3) intersect(List(0 1 2 3 4) List(3 1)) = List(1 3) intersect(List(0 1 2 3 4) List()) = List() intersect(List(0 1 2 3 4) List(0 1 2 3 4 5 6)) = List(0 1 2 3 4)
3.11.4.14 func:except (adapted from fn:except)

Schema:
(?list_{1} ?list_{2}; func:except(?list_{1} ?list_{2}))
 Domains:

Informal Mapping
Returns a list which contains exactly those items which are in list_{1} and not in list_{2}. The order of the items is the same as in list_{1}.
If an argument value is outside of its domain, the value of the function is left unspecified.

Examples
except(List(0 1 2 3 4) List(1 3)) = List(0 2 4) except(List(0 1 2 3 4) List()) = List(0 1 2 3 4) except(List(0 1 2 3 4) List(0 1 2 3 4)) = List()
4 References
 [BCP47]
 BCP 47  Tags for the Identification of Languages, A. Phillips, M. Davis, IETF, Sep 2006, ftp://ftp.rfceditor.org/innotes/bcp/bcp47.txt.
 [CURIE]
 CURIE Syntax 1.0, M. Birbeck, S. McCarron, W3C Working Draft, 6 May 2008, http://www.w3.org/TR/2007/WDcurie20071126/. Latest version available at http://www.w3.org/TR/curie/.
 [RDFCONCEPTS]
 Resource Description Framework (RDF): Concepts and Abstract Syntax, G. Klyne, J. Carroll (Editors), W3C Recommendation, 10 February 2004, http://www.w3.org/TR/2004/RECrdfconcepts20040210/. Latest version available at http://www.w3.org/TR/rdfconcepts/.
 [RDFSEMANTICS]
 RDF Semantics, P. Hayes, Editor, W3C Recommendation, 10 February 2004, http://www.w3.org/TR/2004/RECrdfmt20040210/. Latest version available at http://www.w3.org/TR/rdfmt/.
 [RDFSCHEMA]
 RDF Vocabulary Description Language 1.0: RDF Schema, B. McBride, Editor, W3C Recommendation 10 February 2004, http://www.w3.org/TR/2004/RECrdfschema20040210/. Latest version available at http://www.w3.org/TR/rdfschema/.
 [RDFPLAINLITERAL]
 rdf:PlainLiteral: A Datatype for RDF Plain Literals, J. Bao, S. Hawke, B. Motik, P.F. PatelSchneider, A. Polleres (Editors), W3C Working Draft. Latest version available at http://www.w3.org/2007/OWL/wiki/InternationalizedStringSpec/ (Reference will be adapted at publication time.).
 [RFC3986]
 RFC 3986  Uniform Resource Identifier (URI): Generic Syntax, T. BernersLee, R. Fielding, L. Masinter, IETF, January 2005, http://www.ietf.org/rfc/rfc3986.txt.
 [RFC3987]
 RFC 3987  Internationalized Resource Identifiers (IRIs), M. Duerst and M. Suignard, IETF, January 2005, http://www.ietf.org/rfc/rfc3987.txt.
 [RIFBLD]
 RIF Basic Logic Dialect, Boley H. and Kifer M. (Editors), W3C Rule Interchange Format Working Group Draft. Latest Version available at http://www.w3.org/2005/rules/wiki/BLD.
 [RIFCore]
 RIF Core Dialect, Boley H., Hallmark G., Kifer M., Paschke A., Polleres A., Reynolds, D. (Editors), W3C Rule Interchange Format Working Group Draft. Latest Version available at http://www.w3.org/2005/rules/wiki/Core.
 [RIFFLD]
 RIF Framework for Logic Dialects, Boley H. and Kifer M. (Editors), W3C Rule Interchange Format Working Group Draft. Latest Version available at http://www.w3.org/2005/rules/wiki/FLD.
 [RIFPRD]
 RIF Production Rule Dialect, de Sainte Marie C., Paschke A., Hallmark G. (Editors), W3C Rule Interchange Format Working Group Draft. Latest Version available at http://www.w3.org/2005/rules/wiki/PRD.
 [SPARQL]
 SPARQL Query Language for RDF, E. Prud'hommeaux, A. Seaborne (Editors), W3C Recommendation, World Wide Web Consortium, 12 January 2008, http://www.w3.org/TR/2008/RECrdfsparqlquery20080115/. Latest version available at http://www.w3.org/TR/rdfsparqlquery/.
 [XDM]
 XQuery 1.0 and XPath 2.0 Data Model (XDM), M. Fernández, A. Malhotra, J. Marsh, M. Nagy, N. Walsh (Editors), W3C Recommendation, World Wide Web Consortium, 23 January 2007. This version is http://www.w3.org/TR/2007/RECxpathdatamodel20070123/. Latest version available at http://www.w3.org/TR/xpathdatamodel/.
 [XMLNS]
 Namespaces in XML 1.1 (Second Edition), T. Bray, D. Hollander, A. Layman, R. Tobin (Editors), W3C Recommendation, World Wide Web Consortium, 16 August 2006, http://www.w3.org/TR/2006/RECxmlnames1120060816/. Latest version available at http://www.w3.org/TR/xmlnames11/.
 [XML Schema Datatypes]
 W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes. David Peterson, Shudi Gao, Ashok Malhotra, C. M. SperbergMcQueen, and Henry S. Thompson, eds. W3C Recommendation, 5 April 2012, http://www.w3.org/TR/2012/RECxmlschema11220120405/. Latest version available as http://www.w3.org/TR/xmlschema112/.
 [XPathFunctions]
 XQuery 1.0 and XPath 2.0 Functions and Operators, A. Malhotra, J. Melton, N. Walsh (Editors), W3C Recommendation, World Wide Web Consortium, 23 January 2007, http://www.w3.org/TR/2007/RECxpathfunctions20070123/. Latest version available at http://www.w3.org/TR/xpathfunctions/.
5 Appendix: Schemas for Externally Defined Terms
The RIF Framework for Logic Dialects introduces a general notion of externally defined terms and their schemes. However, RIFBLD and the present document use only restricted kinds of external terms. To make this document selfcontained, this appendix provides a complete description of these restricted notions.
In RIFFLD, an external term is an expression of the form External(id τ), where id is a term that identifies the source that defines the term τ and τ itself can be a constant, a positional or namedarguments term, a frame, an equality, or a classification term. In RIFBLD, only positional and namedargument terms are allowed as τ, and RIFDTB builtins can only be positional terms. So, only a restricted kind of external terms is used: External(τ), where τ has one of the aforementioned forms. If τ is a term of the form p(...) then External(τ) is treated as a shorthand for External(p τ), but this extended 2argument form of External itself is not allowed in RIFBLD.
External schemas serve as templates for externally defined terms. These schemas determine which externally defined terms are acceptable in a RIF dialect. Externally defined terms include RIF builtins, but are more general. They are designed to also accommodate the ideas of procedural attachments and querying of external data sources.
Definition (Schema for external term). An external schema is a statement of the form (?X_{1} ... ?X_{n}; τ) where
 τ is a positional or a namedargument term.
 ?X_{1} ... ?X_{n} is a list of all distinct variables that occur in τ
The names of the variables in an external schema are immaterial, but their order is important. For instance, (?X ?Y; ?X[foo>?Y]) and (?V ?W; ?V[foo>?W]) are considered to be indistinguishable, but (?X ?Y; ?X[foo>?Y]) and (?Y ?X; ?X[foo>?Y]) are viewed as different schemas.
Note that RIFFLD defines external schemas as triples (id; ?X_{1} ... ?X_{n}; τ), where id is the identifying term for the schema's source. However, since RIFBLD uses a simplified version of externally defined terms in which id is determined by the predicate/function name in τ, the idpart is omitted in the above simplified version of external schemas.
A term t is an instance of an external schema (?X_{1} ... ?X_{n}; τ) iff t can be obtained from τ by a simultaneous substitution ?X_{1}/s_{1} ... ?X_{n}/s_{n} of the variables ?X_{1} ... ?X_{n} with terms s_{1} ... s_{n}, respectively. Some of the terms s_{i} can be variables themselves. For example, ?Z[foo>f(a ?P)] is an instance of (?X ?Y; ?X[foo>?Y]) by the substitution ?X/?Z ?Y/f(a ?P). ☐
Observe that a variable cannot be an instance of an external schema, since τ in the above definition cannot be a variable. It will be seen later that this implies that a term of the form External(?X) is not wellformed in RIF.
The intuition behind the notion of an external schema, such as (?X ?Y; ?X["foo"^^xs:string>?Y]) or (?V; "pred:isTime"^^rif:iri(?V)), is that ?X["foo"^^xs:string>?Y] or "pred:isTime"^^rif:iri(?V) are invocation patterns for querying external sources, and instances of those schemas correspond to concrete invocations. Thus, External("http://foo.bar.com"^^rif:iri["foo"^^xs:string>"123"^^xs:integer]) and External("pred:isTime"^^rif:iri("22:33:44"^^xs:time) are examples of invocations of external terms  one querying an external source and another invoking a builtin.
Definition (Coherent set of external schemas).
A set of external schemas is coherent if there is no term, t, that is an instance of two distinct schemas in the set. ☐
The intuition behind this notion is to ensure that any use of an external term is associated with at most one external schema. This assumption is relied upon in the definition of the semantics of externally defined terms. Note that the coherence condition is easy to verify syntactically and that it implies that schemas like (?X ?Y; ?X[foo>?Y]) and (?Y ?X; ?X[foo>?Y]), which differ only in the order of their variables, cannot be in the same coherent set.
It is important to keep in mind that external schemas are not part of the language in RIF, since they do not appear anywhere in RIF statements. Instead, they are best thought of as part of the grammar of the language.