This document contains a proposal for a Semantic Web Rule Language (SWRL) based on a combination of the OWL DL and OWL Lite sublanguages of the OWL Web Ontology Language with the Unary/Binary Datalog RuleML sublanguages of the Rule Markup Language. SWRL includes a high-level abstract syntax for Horn-like rules in both the OWL DL and OWL Lite sublanguages of OWL. A model-theoretic semantics is given to provide the formal meaning for OWL ontologies including rules written in this abstract syntax. An XML syntax based on RuleML and the OWL XML Presentation Syntax as well as an RDF concrete syntax based on the OWL RDF/XML exchange syntax are also given, along with several examples.
This document was approved by the Joint Committee on 18 November 2003.
Comments on this document are invited. Discussion should take place on [email protected]. A repository of issues is being maintained here.
This document contains a proposal for a Semantic Web Rule Language (SWRL) based on a combination of the OWL DL and OWL Lite sublanguages of the OWL Web Ontology Language with the Unary/Binary Datalog RuleML sublanguages of the Rule Markup Language. The proposal extends the set of OWL axioms to include Horn-like rules. It thus enables Horn-like rules to be combined with an OWL knowledge base. A high-level abstract syntax is provided that extends the OWL abstract syntax described in the OWL Semantics and Abstract Syntax document [OWL S&AS]. An extension of the OWL model-theoretic semantics is also given to provide a formal meaning for OWL ontologies including rules written in this abstract syntax.
The proposed rules are of the form of an implication between an antecedent (body) and consequent (head). The intended meaning can be read as: whenever the conditions specified in the antecedent hold, then the conditions specified in the consequent must also hold.
Both the antecedent (body) and consequent (head) consist of zero or more atoms. An empty antecedent is treated as trivially true (i.e. satisfied by every interpretation), so the consequent must also be satisfied by every interpretation; an empty consequent is treated as trivially false (i.e., not satisfied by any interpretation), so the antecedent must also not be satisfied by any interpretation. Multiple atoms are treated as a conjunction. Note that rules with conjunctive consequents could easily be transformed (via the Lloyd-Topor transformations [Lloyd87]) into multiple rules each with an atomic consequent.
Atoms in these rules can be of the form C(x), P(x,y), sameAs(x,y) or differentFrom(x,y), where C is an OWL description, P is an OWL property, and x,y are either variables, OWL individuals or OWL data values. It is easy to see that OWL DL becomes undecidable when extended in this way as rules can be used to simulate role value maps [Schmidt-Schauß89].
An XML syntax is also given for these rules based on RuleML and the OWL XML presentation syntax. Furthermore, an RDF concrete syntax based on the OWL RDF/XML exchange syntax is presented. The rule syntaxes are illustrated with several running examples. Finally, we give usage suggestions and cautions.
The syntax for SWRL in this section abstracts from any exchange syntax for OWL and thus facilitates access to and evaluation of the language. This syntax extends the abstract syntax of OWL described in the OWL Semantcs and Abstract Syntax document [OWL S&AS]. Even this abstract syntax is not particularly readable for rules. Examples will thus often be given in an informal syntax. This informal syntax will neither be given an exact syntax nor a mapping to any of the fully-specified syntaxes for SWRL.
The abstract syntax is specified here by means of a version of Extended BNF, very similar to the EBNF notation used for XML [XML]. Terminals are quoted; non-terminals are bold and not quoted. Alternatives are either separated by vertical bars (|) or are given in different productions. Components that can occur at most once are enclosed in square brackets ([…]); components that can occur any number of times (including zero) are enclosed in braces ({…}). Whitespace is ignored in the productions here.
Names in the abstract syntax are RDF URI references [RDF Concepts]. These names may be abbreviated into qualified names, using one of the following namespace names:
Namespace name | Namespace |
---|---|
rdf | http://www.w3.org/1999/02/22-rdf-syntax-ns# |
rdfs | http://www.w3.org/2000/01/rdf-schema# |
xsd | http://www.w3.org/2001/XMLSchema# |
owl | http://www.w3.org/2002/07/owl# |
The meaning of each construct in the abstract syntax is informally described when it is introduced. The formal meaning of these constructs is given in Section 3 via an extension of the OWL DL model-theoretic semantics [OWL S&AS].
An OWL ontology in the abstract syntax contains a sequence of axioms and facts. Axioms may be of various kinds, e.g., subClass axioms and equivalentClass axioms. It is proposed to extend this with rule axioms.
axiom ::= rule
A rule axiom consists of an antecedent (body) and a consequent (head), each of which consists of a (posibly empty) set of atoms.
rule ::= 'Implies(' { annotation } antecedent consequent ')' antecedent ::= 'Antecedent(' { atom } ')' consequent ::= 'Consequent(' { atom } ')'
Informally, a rule may be read as meaning that if the antecedent holds (is "true"), then the consequent must also hold. An empty antecedent is treated as trivially holding (true), and an empty consequent is treated as trivially not holding (false). Rules with an empty antecedent can thus be used to provide unconditional facts; however such unconditional facts are better stated in OWL itself, i.e., without the use of the rule construct. Non-empty antecedents and consequents hold iff all of their constituent atoms hold, i.e., they are treated as conjunctions of their atoms. As mentioned above, rules with conjunctive consequents could easily transformed (via the Lloyd-Topor transformations [Lloyd87]) into multiple rules each with an atomic consequent.
atom ::= description '(' i-object ')' | individualvaluedPropertyID '(' i-object i-object ')' | datavaluedPropertyID '(' i-object d-object ')' | sameAs '(' i-object i-object ')' | differentFrom '(' i-object i-object ')'
Atoms can be of the form C(x), P(x,y), sameAs(x,y) or differentFrom(x,y), where C is an OWL description, P is an OWL property, and x,y are either variables, OWL individuals or OWL data values. In the context of OWL Lite, descriptions in atoms of the form C(x) may be restricted to class names.
Informally, an atom C(x) holds if x is an instance of the class description C, an atom P(x,y) holds if x is related to y by property P, an atom sameAs(x,y) holds if x is interpreted as the same object as y, and an atom differentFrom(x,y) holds if x and y are interpreted as different objects. Note that the latter two forms can be seen as "syntactic sugar": they are convenient, but do not increase the expressive power of the language (i.e., such (in)equalities can already be expressed using the combined power of OWL and rules without explicit (in)equality atoms).
i-object ::= i-variable | individualID d-object ::= d-variable | dataLiteral
Atoms may refer to individuals, data literals, individual variables or data variables. Variables are treated as universally quantified, with their scope limited to a given rule. As usual, only variables that occur in the antecedent of a rule may occur in the consequent (a condition usually referred to as "safety"). This safety condition does not, in fact, restrict the expressive power of the language (because existentials can already be captured using OWL someValuesFrom restrictions).
i-variable ::= 'I-variable(' URIreference ')' d-variable ::= 'D-variable(' URIreference ')'
While the abstract EBNF syntax is consistent with the OWL specification, and is useful for defining XML and RDF serialisations, it is rather verbose and not particularly easy to read. In the following we will, therefore, often use a relatively informal "human readable" form similar to that used in many published works on rules.
In this syntax, a rule has the form:
antecedent ⇒ consequent
where both antecedent and consequent are conjunctions of atoms written a1 ∧ ... ∧ an. Variables are indicated using the standard convention of prefixing them with a question mark (e.g., ?x). Using this syntax, a rule asserting that the composition of parent and brother properties implies the uncle property would be written:
parent(?x,?y) ∧ brother(?y,?z) ⇒ uncle(?x,?z)
The model-theoretic semantics for SWRL is a straightforward extension of the semantics for OWL given in the OWL Semantics and Abstract Syntax document [OWL S&AS]. The basic idea is that we define bindings, extensions of OWL interpretations that also map variables to elements of the domain. A rule is satisfied by an interpretation iff every binding that satisfies the antecedent also satisfies the consequent. The semantic conditions relating to axioms and ontologies are unchanged, e.g., an interpretation satisfies an ontology iff it satisfies every axiom (including rules) and fact in the ontology.
From the OWL Semantics and Abstract Syntax document we recall that an abstract OWL interpretation is a tuple of the form
I = <R, EC, ER, L, S, LV>
where R is a set of resources, LV ⊆ R is a set of literal values, EC is a mapping from classes and datatypes to subsets of R and LV respectively, ER is a mapping from properties to binary relations on R, L is a mapping from typed literals to elements of LV, and S is a mapping from individual names to elements of EC(owl:Thing).
Given an abstract OWL interpretation Ι, a binding B(Ι) is an abstract OWL interpretation that extends Ι such that S maps i-variables to elements of EC(owl:Thing) and L maps d-variables to elements of LV respectively. An atom is satisfied by an interpretation Ι under the conditions given in the Interpretation Conditions Table, where C is an OWL DL description, P is an OWL DL individualvalued property, Q is an OWL DL datavalued property, x,y are variables or OWL individuals, and z is a variable or an OWL data value.
Atom | Condition on Interpretation |
---|---|
C(x) | S(x) ∈ EC(C) |
P(x,y) | <S(x),S(y)> ∈ ER(P) |
Q(x,z) | <S(x),L(z)> ∈ ER(Q) |
sameAs(x,y) | S(x) = S(y) |
differentFrom(x,y) | S(x) ≠ S(y) |
A binding B(Ι) satisfies an antecedent A iff A is empty or B(Ι) satisfies every atom in A. A binding B(Ι) satisfies a consequent C iff C is not empty and B(Ι) satisfies every atom in C. A rule is satisfied by an interpretation Ι iff for every binding B such that B(Ι) satisfies the antecedent, B(Ι) also satisfies the consequent.
The semantic conditions relating to axioms and ontologies are unchanged. In particular, an interpretation satisfies an ontology iff it satisfies every axiom (including rules) and fact in the ontology; an ontology is consistent iff it is satisfied by at least one interpretation; an ontology O2 is entailed by an ontology O1 iff every interpretation that satisfies O1 also satisfies O2.
A simple use of these rules would be to assert that the combination of the hasParent and hasBrother properties implies the hasUncle property. Informally, this rule could be written as:
hasParent(?x1,?x2) ∧ hasBrother(?x2,?x3) ⇒ hasUncle(?x1,?x3)
In the abstract syntax the rule would be written like:
Implies(Antecedent(hasParent(I-variable(x1) I-variable(x2)) hasBrother(I-variable(x2) I-variable(x3))) Consequent(hasUncle(I-variable(x1) I-variable(x3))))
From this rule, if John has Mary as a parent and Mary has Bill has a brother then John has Bill as an uncle.
An even simpler rule would be to assert that Students are Persons, as in Student(?x1) ⇒ Person(?x1).
Implies(Antecedent(Student(I-variable(x1))) Consequent(Person(I-variable(x1))))
However, this kind of use for rules in OWL just duplicates the OWL subclass facility. It is logically equivalent to write instead
Class(Student partial Person)
or
SubClassOf(Student Person)
which would make the information directly available to an OWL reasoner.
A very common use for rules is to move property values from one individual to a related individual, as in the following example that expresses the fact that the style of an art object is the same as the style of the creator.
Artist(?x) & artistStyle(?x,?y) & Style(?y) & creator(?z,?x) ⇒ style/period(?z,?y)
Implies(Antecedent(Artist(I-variable(x)) artistStyle(I-variable(x) I-variable(y)) Style(I-variable(y)) creator(I-variable(z) I-variable(x))) Consequent(style/period(I-variable(z) I-variable(y))))
It is useful to include OWL descriptions in rules, instead of using named classes. The above rule could be augmented with a separate rule to provide information about exclusivity of style (assuming that style is not always exclusive).
Artist(?x) & (≤1 artistStyle)(?x) & creator(?z,?x) ⇒ (≤1 style/period)(?z)
Implies(Antecedent(Artist(I-variable(x)) (restriction(artistStyle maxCardinality(1)))(I-variable(x)) Style(I-variable(y)) creator(I-variable(z) I-variable(x))) Consequent((restriction(style/period maxCardinality(1)))(I-variable(z))))
The XML Concrete Syntax is a combination of the OWL Web Ontology Language XML Presentation Syntax [OWL XML] with the RuleML XML syntax [RuleML]. This has several advantages:
The Ontology root element of the OWL XML Presentation Syntax is extended to include "imp" (implication rule) and "var" (variable declaration) axioms as found under the rulebase root of RuleML.
<swrlx:Ontology swrlx:name = xsd:anyURI > Content: (owlx:VersionInfo | owlx:PriorVersion | owlx:BackwardCompatibleWith | owlx:IncompatibleWith | owlx:Imports | owlx:Annotation | owlx:Class[axiom] | owlx:EnumeratedClass(D,F) | owlx:SubClassOf(D,F) | owlx:EquivalentClasses | owlx:DisjointClasses(D,F) | owlx:DatatypeProperty | owlx:ObjectProperty | owlx:SubPropertyOf | owlx:EquivalentProperties | owlx:Individual[axiom] | owlx:SameIndividual | owlx:DifferentIndividuals | ruleml:imp[axiom] | ruleml:var[axiom])* </swrlx:Ontology>
Attribute: | swrlx:name - refers to a name of this ontology, which is the base URI of this element. |
Note: | This is the root element of OWL documents in the XML presentation syntax, while rdf:RDF is used as the document root for OWL in RDF/XML. |
We then simply need to add the relevant syntax for variables and rules.
Variable (var) axioms are statements about variables, indicating that the given string is to be used as a variable.
A var axiom simply defines the existence of a variable. This is taken from the RuleML namespace. For example:
<ruleml:var>x1</ruleml:var>
Rule axioms (imp elements) are similar to SubClassOf axioms. They are taken from the RuleML namespace. A rule axiom can be read as a logical implication between the antecedent (_body) and consequent (_head). Like SubClassOf axioms, rules may include annotations.
<ruleml:imp> Content: ( owlx:Annotation*, _body, _head ) </ruleml:imp>
Parents: | swrlx:Ontology |
Note: | This element allows one to say that every binding that satisfies the _body of the rule must also satisfy the _head of the rule. |
Both _body and _head are lists of atoms and are read as the conjunction of the component atoms.
Atoms can be formed from unary predicates (classes), binary predicates (properties), equalities or inequalities.
Content: (swrlx:classAtom | swrlx:individualPropertyAtom | swrlx:datavaluedPropertyAtom | swrlx:sameIndividualAtom | swrlx:differentIndividualsAtom)
Parents: | ruleml:_body, ruleml:_head |
Class atoms consist of a description and either an individual name or a variable name.
<swrlx:classAtom> Content: ( owlx:description, swrlx:iObject ) </swrlx:classAtom>
Parents: | swrlx:atom |
The description in a class atom may be a class name, or may be a complex description using boolean combinations, restrictions, etc. For example:
<swrlx:classAtom> <owlx:Class owlx:name="Person" /> <ruleml:var>x1</ruleml:var> </swrlx:classAtom> <swrlx:classAtom> <owlx:IntersectionOf> <owlx:Class owlx:name="Person" /> <owlx:ObjectRestriction owlx:property="hasParent"> <owlx:someValuesFrom owlx:class="Physician" /> </owlx:ObjectRestriction> </owlx:IntersectionOf> <ruleml:var>x2</ruleml:var> </swrlx:classAtom>
Property atoms consist of a property name and two elements that can be individual names, variable names or data values.
<swrlx:individualPropertyAtom swrlx:property = xsd:anyURI {required} > Content: ( swrlx:iObject, swrlx:iObject ) </swrlx:individualPropertyAtom>
Attribute: | swrlx:property - a reference to an individual property name |
Parents: | swrlx:atom |
<swrlx:datavaluedPropertyAtom swrlx:property = xsd:anyURI {required} > Content: ( swrlx:iObject, swrlx:dObject ) </swrlx:datavaluedPropertyAtom>
Attribute: | swrlx:property - a reference to an datavalued property name |
Parents: | swrlx:atom |
As OWL does not support complex property descriptions, a property atom takes only a property name. For example:
<swrlx:individualPropertyAtom swrlx:property="hasParent"> <ruleml:var>x1</ruleml:var> <owlx:Individual owlx:name="John" /> </swrlx:individualPropertyAtom> <swrlx:datavaluedPropertyAtom swrlx:property="grade"> <ruleml:var>x1</ruleml:var> <owlx:DataValue owlx:datatype="&xsd;integer">4</owlx:DataValue> </swrlx:datavaluedPropertyAtom>
Same (different) individual atoms assert equality (inequality) between sets of individual and variable names.
<swrlx:sameIndividualAtom> Content: ( swrlx:iObject* ) </swrlx:sameIndividualAtom>
Parents: | swrlx:atom |
<swrlx:differentIndividualsAtom> Content: ( swrlx:iObject* ) </swrlx:differentIndividualsAtom>
Parents: | swrlx:atom |
Note that (in)equalities can be asserted between arbitrary combinations of variable names and individual names. For example:
<swrlx:sameIndividualAtom> <ruleml:var>x1</ruleml:var> <ruleml:var>x2</ruleml:var> <owlx:Individual owlx:name="Clinton" /> <owlx:Individual owlx:name="Bill_Clinton" /> </swrlx:sameIndividualAtom>
Content: ( owlx:Individual[ID] | ruleml:var[ID] )
Content: ( owlx:DataValue | ruleml:var[ID] )
Parents: | swrlx:datavaluedPropertyAtom |
<ruleml:var>xsd:string</ruleml:var>
Parents: | swrlx:iObject, swrlx:dObject |
Note: | This element is used for solely referring to a variable ID, and does not actually define any variable, unlike a var axiom. |
We can use SWRL to assert that the combination of the hasParent and hasBrother properties implies the hasUncle property:
<ruleml:imp> <ruleml:_body> <swrlx:individualPropertyAtom swrlx:property="hasParent"> <ruleml:var>x1</ruleml:var> <ruleml:var>x2</ruleml:var> </swrlx:individualPropertyAtom> <swrlx:individualPropertyAtom swrlx:property="hasBrother"> <ruleml:var>x2</ruleml:var> <ruleml:var>x3</ruleml:var> </swrlx:individualPropertyAtom> </ruleml:_body> <ruleml:_head> <swrlx:individualPropertyAtom swrlx:property="hasUncle"> <ruleml:var>x1</ruleml:var> <ruleml:var>x3</ruleml:var> </swrlx:individualPropertyAtom> </ruleml:_head> </ruleml:imp>
An alternative formulation for the hasUncle rule given in Example 5.1-1 would be to assert that if x1 hasParent x2, x2 hasSibling x3, and x3 hasSex male, then x1 hasUncle x3:
<ruleml:imp> <ruleml:_body> <swrlx:individualPropertyAtom swrlx:property="hasParent"> <ruleml:var>x1</ruleml:var> <ruleml:var>x2</ruleml:var> </swrlx:individualPropertyAtom> <swrlx:individualPropertyAtom swrlx:property="hasSibling"> <ruleml:var>x2</ruleml:var> <ruleml:var>x3</ruleml:var> <swrlx:individualPropertyAtom swrlx:property="hasSex"> <ruleml:var>x3</ruleml:var> <owlx:Individual owlx:name="#male" /> </swrlx:individualPropertyAtom> </ruleml:_body> <ruleml:_head> <swrlx:individualPropertyAtom swrlx:property="hasUncle"> <ruleml:var>x1</ruleml:var> <ruleml:var>x3</ruleml:var> </swrlx:individualPropertyAtom> </ruleml:_head> </ruleml:imp>
The following example is due to Guus Schreiber, and is based on ontologies used in an image annotation demo.
The rule expresses the fact that, given knowledge about the AAT style of certain ULAN artists (e.g., van Gogh is an Impressionist painter), we can derive the style of an art object (represented with the VRA element "style/period") from the value of the creator of the art object (represented by the VRA element "creator", a subproperty of dc:creator):
<ruleml:imp> <ruleml:_body> <swrlx:classAtom> <owlx:Class owlx:name="&ulan;Artist" /> <ruleml:var>x</ruleml:var> </swrlx:classAtom> <swrlx:classAtom> <owlx:Class owlx:name="&aat;Style" /> <ruleml:var>y</ruleml:var> </swrlx:classAtom> <swrlx:individualPropertyAtom swrlx:property="&aatulan;artistStyle"> <ruleml:var>x</ruleml:var> <ruleml:var>y</ruleml:var> </swrlx:individualPropertyAtom> <swrlx:individualPropertyAtom swrlx:property="&vra;creator"> <ruleml:var>x</ruleml:var> <ruleml:var>z</ruleml:var> </swrlx:individualPropertyAtom> </ruleml:_body> <ruleml:_head> <swrlx:individualPropertyAtom swrlx:property="&vra;style/period"> <ruleml:var>z</ruleml:var> <ruleml:var>y</ruleml:var> </swrlx:individualPropertyAtom> </ruleml:_head> </ruleml:imp>
The following is taken from an extended example due to Mike Dean. It expresses the fact that for every Airport there is a map Point that has the same location (latitude and longitude) as the Airport and that is an object of "layer" (a map DrawingLayer). Moreover, this map point has the Airport as an underlyingObject and has the Airport name as its Label
Note how the expressive power of SWRL allows "existentials" to be expressed in the head of a ruleit is asserted that, for every airport, there must exist such a map point.
<!-- Background knowledge about airports and maps: --> <owlx:DatatypeProperty owlx:name="latitude"/> <owlx:DatatypeProperty owlx:name="longitude"/> <owlx:SubClassOf> <owlx:sub> <owlx:class="Location" /> </owlx:sub> <owlx:super> <owlx:IntersectionOf> <owlx:ObjectRestriction owlx:property="latitude"> <owlx:allValuesFrom owlx:datatype="&xsd;double"/> </owlx:ObjectRestriction> <owlx:ObjectRestriction owlx:property="longitude"> <owlx:allValuesFrom owlx:datatype="&xsd;double"/> </owlx:ObjectRestriction> </owlx:IntersectionOf> </owlx:super> </owlx:SubClassOf> <owlx:Individual owlx:name="&airport;GEG"> <owlx:type owlx:name="&airport-ont;Airport" /> <owlx:DataPropertyValue swrlx:property="airport-ont:name"> <owlx:DataValue owlx:datatype="&xsd;string">Spokane Intl</owlx:DataValue> </owlx:DataPropertyValue> <owlx:ObjectPropertyValue owlx:property="location"> <owlx:Individual> <owlx:DataPropertyValue owlx:property="latitude"> <owlx:DataValue>47.6197</owlx:DataValue> </owlx:DataPropertyValue> <owlx:DataPropertyValue owlx:property="longitude"> <owlx:DataValue>-117.5336</owlx:DataValue> </owlx:DataPropertyValue> </owlx:Individual> </owlx:ObjectPropertyValue> </owlx:Individual> <owlx:Individual owlx:name="layer"> <owlx:type owlx:name="↦DrawingLayer" /> </owlx:Individual> <owlx:Individual owlx:name="map"> <owlx:type owlx:name="↦Map" /> <owlx:DataPropertyValue owlx:property="↦name"> <owlx:DataValue owlx:datatype="&xsd;string">Airports</owlx:DataValue> </owlx:DataPropertyValue> <owlx:ObjectPropertyValue owlx:property="map:layer"> <owlx:Individual owlx:name="layer"/> </owlx:ObjectPropertyValue> </owlx:Individual> <!-- A map:Location has latitude and longitude, both of which are doubles: --> <owlx:SubClassOf> <owlx:sub> <owlx:class="↦Location" /> </owlx:sub> <owlx:super> <owlx:IntersectionOf> <owlx:ObjectRestriction owlx:property="↦latitude"> <owlx:someValuesFrom owlx:datatype="&xsd;double"/> </owlx:ObjectRestriction> <owlx:ObjectRestriction owlx:property="↦latitude"> <owlx:allValuesFrom owlx:datatype="&xsd;double"/> </owlx:ObjectRestriction> <owlx:ObjectRestriction owlx:property="↦longitude"> <owlx:someValuesFrom owlx:datatype="&xsd;double"/> </owlx:ObjectRestriction> <owlx:ObjectRestriction owlx:property="↦longitude"> <owlx:allValuesFrom owlx:datatype="&xsd;double"/> </owlx:ObjectRestriction> </owlx:IntersectionOf> </owlx:super> </owlx:SubClassOf> <!-- If a map:Location is the sameLocation as another location, then it has the same values for latitude and longitude. --> <ruleml:imp> <ruleml:_body> <swrlx:classAtom> <owlx:Class owlx:name="↦Location" /> <ruleml:var>maploc</ruleml:var> </swrlx:classAtom> <swrlx:individualPropertyAtom swrlx:property="sameLocation"> <ruleml:var>loc</ruleml:var> <ruleml:var>maploc</ruleml:var> </swrlx:individualPropertyAtom> <swrlx:datavaluedPropertyAtom swrlx:property="latitude"> <ruleml:var>loc</ruleml:var> <ruleml:var>lat</ruleml:var> </swrlx:datavaluedPropertyAtom> <swrlx:datavaluedPropertyAtom swrlx:property="longitude"> <ruleml:var>loc</ruleml:var> <ruleml:var>lon</ruleml:var> </swrlx:datavaluedPropertyAtom> </ruleml:_body> <ruleml:_head> <swrlx:datavaluedPropertyAtom swrlx:property="↦latitude"> <ruleml:var>maploc</ruleml:var> <ruleml:var>lat</ruleml:var> </swrlx:datavaluedPropertyAtom> <swrlx:datavaluedPropertyAtom swrlx:property="↦longitude"> <ruleml:var>maploc</ruleml:var> <ruleml:var>lon</ruleml:var> </swrlx:datavaluedPropertyAtom> </ruleml:_head> </ruleml:imp> <!-- Wherever an Airport is located, there is some map:Location that is the sameLocation as the Airport's location, and that is the location of a map Point that is an object of the map:DrawingLayer "layer": --> <owlx:ObjectProperty owlx:name="↦location" owlx:inverseOf="↦isLocationOf" /> <owlx:ObjectProperty owlx:name="↦object" owlx:inverseOf="↦isObjectOf" /> <ruleml:imp> <ruleml:_body> <swrlx:classAtom> <owlx:Class owlx:name="&airport-ont;Airport" /> <ruleml:var>airport</ruleml:var> </swrlx:classAtom> <swrlx:individualPropertyAtom swrlx:property="location"> <ruleml:var>airport</ruleml:var> <ruleml:var>loc</ruleml:var> </swrlx:individualPropertyAtom> <swrlx:datavaluedPropertyAtom swrlx:property="latitude"> <ruleml:var>loc</ruleml:var> <ruleml:var>lat</ruleml:var> </swrlx:datavaluedPropertyAtom> <swrlx:datavaluedPropertyAtom swrlx:property="longitude"> <ruleml:var>loc</ruleml:var> <ruleml:var>lon</ruleml:var> </swrlx:datavaluedPropertyAtom> </ruleml:_body> <ruleml:_head> <swrlx:classAtom> <owlx:ObjectRestriction owlx:property="sameLocation"> <owlx:someValuesFrom> <owlx:IntersectionOf> <owlx:class="↦Location" /> <owlx:ObjectRestriction owlx:property="↦isLocationOf"> <owlx:someValuesFrom> <owlx:IntersectionOf> <owlx:class="↦Point" /> <owlx:ObjectRestriction owlx:property="↦isObjectOf"> <owlx:someValuesFrom> <owlx:OneOf> <owlx:Individual owlx:name="#layer" /> </owlx:OneOf> </owlx:someValuesFrom> </owlx:ObjectRestriction owlx:property="↦isObjectOf"> </owlx:IntersectionOf> </owlx:someValuesFrom> </owlx:ObjectRestriction owlx:property="↦isLocationOf"> </owlx:IntersectionOf> </owlx:someValuesFrom> </owlx:ObjectRestriction> <ruleml:var>loc</ruleml:var> </swrlx:classAtom> </ruleml:_head> </ruleml:imp> <!-- The map:Point whose map:location is the map:Location of an Airport has the airport as a map:underlyingObject and has a map:label which is the name of the Airport. --> <ruleml:imp> <ruleml:_body> <swrlx:classAtom> <owlx:Class owlx:name="&airport-ont;Airport" /> <ruleml:var>airport</ruleml:var> </swrlx:classAtom> <swrlx:individualPropertyAtom swrlx:property="location"> <ruleml:var>airport</ruleml:var> <ruleml:var>loc</ruleml:var> </swrlx:individualPropertyAtom> <swrlx:individualPropertyAtom swrlx:property="sameLocation"> <ruleml:var>loc</ruleml:var> <ruleml:var>maploc</ruleml:var> </swrlx:individualPropertyAtom> <swrlx:individualPropertyAtom swrlx:property="↦location"> <ruleml:var>point</ruleml:var> <ruleml:var>maploc</ruleml:var> </swrlx:individualPropertyAtom> <swrlx:datavaluedPropertyAtom swrlx:property="&airport-ont;name"> <ruleml:var>airport</ruleml:var> <ruleml:var>name</ruleml:var> </swrlx:datavaluedPropertyAtom> </ruleml:_body> <ruleml:_head> <swrlx:individualPropertyAtom swrlx:property="↦underlyingObject"> <ruleml:var>point</ruleml:var> <ruleml:var>airport</ruleml:var> </swrlx:individualPropertyAtom> <swrlx:datavaluedPropertyAtom swrlx:property="↦label"> <ruleml:var>point</ruleml:var> <ruleml:var>name</ruleml:var> </swrlx:datavaluedPropertyAtom> </ruleml:_head> </ruleml:imp>
In this section we present an RDF concrete syntax for the rules. It is straightforward to provide such an RDF concrete syntax for rules, but the presence of variables in rules goes beyond the RDF Semantics. We do not yet know if the intended semantics of the resultant RDF graphs can be described as a semantic extension of RDF.
An RDF Schema for SWRL is swrl.rdf. An OWL ontology for SWRL is swrl.owl. Each of these provides only a partial description of the syntax for SWRL; the OWL ontology is more complete than the RDF Schema.
Translation from the XML Concrete Syntax to RDF/XML could be easily accomplished by extending the XSLT transformation for the OWL XML Presentation syntax [OWL XML].
These examples illustrate a suitable rules extension of the OWL RDF/XML syntax. The first example is a repetition of Example 5.1-2 using RDF/XML syntax:
<swrl:Variable rdf:ID="x1"/> <swrl:Variable rdf:ID="x2"/> <swrl:Variable rdf:ID="x3"/> <ruleml:Imp> <ruleml:body rdf:parseType="Collection"> <swrl:individualPropertyAtom> <swrl:propertyPredicate rdf:resource="⪚hasParent"/> <swrl:argument1 rdf:resource="#x1" /> <swrl:argument2 rdf:resource="#x2" /> </swrl:individualPropertyAtom> <swrl:individualPropertyAtom> <swrl:propertyPredicate rdf:resource="⪚hasSibling"/> <swrl:argument1 rdf:resource="#x2" /> <swrl:argument2 rdf:resource="#x3" /> </swrl:individualPropertyAtom> <swrl:individualPropertyAtom> <swrl:propertyPredicate rdf:resource="⪚hasSex"/> <swrl:argument1 rdf:resource="#x3" /> <swrl:argument2 rdf:resource="#male" /> </swrl:individualPropertyAtom> </ruleml:body> <ruleml:head rdf:parseType="Collection"> <swrl:individualPropertyAtom> <swrl:propertyPredicate rdf:resource="⪚hasUncle"/> <swrl:argument1 rdf:resource="#x1" /> <swrl:argument2 rdf:resource="#x3" /> </swrl:individualPropertyAtom> </ruleml:head> </ruleml:Imp>
This example is a repetition of Example 5.1-3 using RDF/XML syntax:
<swrl:Variable rdf:ID="x"/> <swrl:Variable rdf:ID="y"/> <swrl:Variable rdf:ID="z"/> <ruleml:Imp> <ruleml:body rdf:parseType="Collection"> <swrl:classAtom> <swrl:classPredicate rdf:resource="&ulan;Artist"/> <swrl:argument1 rdf:resource="#x" /> </swrl:classAtom> <swrl:classAtom> <swrl:classPredicate rdf:resource="&aat;Style"/> <swrl:argument1 rdf:resource="#y" /> </swrl:classAtom> <swrl:individualPropertyAtom> <swrl:propertyPredicate rdf:resource="&aatulan;artistStyle"/> <swrl:argument1 rdf:resource="#x" /> <swrl:argument2 rdf:resource="#y" /> </swrl:individualPropertyAtom> <swrl:individualPropertyAtom> <swrl:propertyPredicate rdf:resource="&vra;creator"/> <swrl:argument1 rdf:resource="#x" /> <swrl:argument2 rdf:resource="#z" /> </swrl:individualPropertyAtom> </ruleml:body> <ruleml:head rdf:parseType="Collection"> <swrl:individualPropertyAtom> <swrl:propertyPredicate rdf:resource="&vra;style/period"/> <swrl:argument1 rdf:resource="#z" /> <swrl:argument2 rdf:resource="#y" /> </swrl:individualPropertyAtom> </ruleml:head> </ruleml:Imp>
This example is a repetition of the complex rule from Example 5.1-4 using RDF/XML syntax:
<swrl:Variable rdf:ID="airport"/> <swrl:Variable rdf:ID="loc"/> <swrl:Variable rdf:ID="name"/> <swrl:Variable rdf:ID="lat"/> <swrl:Variable rdf:ID="lon"/> <ruleml:Imp> <ruleml:body rdf:parseType="Collection"> <swrl:classAtom> <swrl:classPredicate rdf:resource="&airport-ont;Airport"/> <swrl:argument1 rdf:resource="#airport" /> </swrl:classAtom> <swrl:individualPropertyAtom> <swrl:propertyPredicate rdf:resource="#location"/> <swrl:argument1 rdf:resource="#airport" /> <swrl:argument2 rdf:resource="#loc" /> </swrl:individualPropertyAtom> <swrl:datavaluedPropertyAtom> <swrl:propertyPredicate rdf:resource="#latitude"/> <swrl:argument1 rdf:resource="#loc" /> <swrl:argument2 rdf:resource="#lat" /> </swrl:datavaluedPropertyAtom> <swrl:datavaluedPropertyAtom> <swrl:propertyPredicate rdf:resource="#longitude"/> <swrl:argument1 rdf:resource="#loc" /> <swrl:argument2 rdf:resource="#lon" /> </swrl:datavaluedPropertyAtom> </ruleml:body> <ruleml:head rdf:parseType="Collection"> <swrl:classAtom> <swrl:classPredicate> <owl:Restriction> <owl:onProperty rdf:resource="#sameLocation"/> <owl:someValuesFrom> <owl:intersectionOf rdf:parseType="Collection"> <owl:Class rdf:about="↦Location"/> <owl:Restriction> <owl:onProperty rdf:resource="↦isLocationOf"/> <owl:someValuesFrom> <owl:intersectionOf rdf:parseType="Collection"> <owl:Class rdf:about="↦Point"/> <owl:Restriction> <owl:onProperty rdf:resource="↦isObjectOf"/> <owl:someValuesFrom> <owl:oneOf rdf:parseType="Collection"> <owl:Item rdf:resource="#layer"/> </owl:oneOf> </owl:someValuesFrom> </owl:Restriction> </owl:intersectionOf rdf:parseType="Collection"> </owl:someValuesFrom> </owl:Restriction> </owl:intersectionOf rdf:parseType="Collection"> </owl:someValuesFrom> </owl:Restriction> </swrl:classPredicate> <swrl:argument1 rdf:resource="#airport" /> </swrl:classAtom> </ruleml:head> </ruleml:Imp>
The general intent of this proposal is to extend OWL DL, and thus to use OWL constructs wherever possible.
If users are making extensive use of rules, they may want to restrict the form or expressiveness of the rules they employ, in order to increase interoperability, reusability, extensibility, computational scaleability, or ease of implementation.
A useful restriction in the form of the rules is to limit antecedent and consequent classAtoms to be named classes, where the classes are defined purely in OWL (in the same document or in external OWL documents). Adhering to this format makes it easier to translate rules to or from existing (or future) rule systems, including:
Adhering to this form also maximises reuse and interoperability of the ontology knowledge in the rules with other OWL-speaking systems that do not necessarily support SWRL.
Users also may want to restrict the expressiveness of the OWL classes and descriptions appearing in rules. One useful restriction on expressivity is Description Logic Programs [Grosof et al 2003] which, e.g., prohibits existentially-quantified knowledge in consequents. Suitably-restricted SWRL rules can be straightforwardly extended to enable procedural attachments and/or nonmonotonic reasoning (negation-as-failure and/or prioritised conflict handling) of the kinds supported in CCI rule systems and in RuleML [RuleML] which facilitates interoperability between those CCI rule systems. Such adherence may thus facilitate combining SWRL knowledge with knowledge from those other rules languages. Suitable restrictions can also improve the empirical tractability of reasoning with rules.
A longer, more detailed version of the above usage suggestions and cautions is available at http://www.daml.org/listarchive/joint-committee/1491.html.
This document was produced as part of the DARPA DAML Program, and has benefited from extensive discussion in the Joint US/EU ad hoc Agent Markup Language Committee, with contributions from Sandro Hawke and Pat Hayes being worthy of particular mention. It has also benefited from the close cooperation of the RuleML initiative, and input from the Semantic Web Services Initiative (SWSI).