Each property in RDF may have its own attributes about the domain and the range. The domain value restricts the class of subject in triple of the extension of the property and the range value restricts the range of the property value. See Figure 5.2.
To define a domain and a range of a property, use defProperty as follows.
gx-user(3): (defpackage vin)
#<The
vin package>
gx-user(4): (defProperty
vin::hasMaker
(rdfs:domain
vin::Wine)
(rdfs:range
vin::Winery))
Warning: Range entailX3 by rdfs:domain: vin::Wine rdf:type
rdfs:Class.
Warning: Range entailX3 by rdfs:range: vin::Winery rdf:type
rdfs:Class.
#<rdf:Property vin:hasMaker>
The defined domain and range value of property is retrieved by the accessor rdfs:domain and rdfs:range.
gx-user(6): (rdfs:domain
vin:hasMaker)
#<rdfs:Class vin:Wine>
gx-user(7): (rdfs:range
vin:hasMaker)
#<rdfs:Class vin:Winery>
gx-user(8): (rdfs:domain
rdfs:comment)
#<rdfs:Class rdfs:Resource>
gx-user(9): (rdfs:range
rdfs:comment)
#<rdfs:Class rdfs:Literal>
These accessor signals an error, if a property has no definition.
gx-user(10): (defProperty
vin::hasColor
(rdfs:range
vin::WineColor))
Warning: Range entailX3 by rdfs:range: vin::WineColor
rdf:type rdfs:Class.
#<rdf:Property vin:hasColor>
gx-user(11):
(rdfs:range vin:hasColor)
#<rdfs:Class vin:WineColor>
gx-user(12):
(rdfs:domain vin:hasColor)
Error: The slot rdfs:domain is unbound in the
object
#<rdf:Property vin:hasColor> of class #<rdfs:Class
rdf:Property>.
[condition type: unbound-slot]
You may use function range-value and domain-value without signaling an error, even if a property has no definition on domain or range value.
gx-user(13): (range-value
vin:hasColor)
#<rdfs:Class vin:WineColor>
gx-user(14):
(domain-value vin:hasColor)
nil
The domain and range value is inherited from the super-properties defined through rdfs:subPropertyOf. In the following example, function get-domain accesses and retrieves the domain value of superproperties of vin:hasColor.
gx-user(19): (defProperty
vin::hasColor
(rdfs:subPropertyOf
vin::hasWineDescriptor))
Warning: Range entailX3 by rdfs:subPropertyOf:
vin::hasWineDescriptor rdf:type rdf:Property.
#<rdf:Property
vin:hasColor>
gx-user(20): (get-domain
vin:hasColor)
nil
gx-user(21): (defProperty
vin:hasWineDescriptor
(rdfs:domain
vin:Wine))
#<rdf:Property vin:hasWineDescriptor>
gx-user(22):
(get-domain vin:hasColor)
#<rdfs:Class vin:Wine>
As mentioned in the description of get-domain and get-range above, any disjoint pair of domains and ranges with respect to a specific property causes the unsatisfiable condition error. The satisfiability checking is very important especially in OWL, because OWL provides users the definition of owl:disjointWith relation on concepts (classes), while RDF provides only the intrinsic disjoitness with respect to XML Schema data.
In the following demonstration, range-condition-unsatiafiable error happens, since xsd:float and xsd:integer are disjoint and both are defined as domains with respect to hasInteger property.
gx-user(2): (defProperty hasFloat (rdfs:range
xsd:float))
#<rdf:Property hasFloat>
gx-user(3): (defProperty
hasInteger (rdfs:range
xsd:integer)
(rdfs:subPropertyOf
hasFloat))
#<rdf:Property hasInteger>
gx-user(4): (defResource foo
(hasInteger 1))
Error: range condition unsatisfiable: disjoint clash:
#<rdfs:Datatype xsd:integer>
#<rdfs:Datatype xsd:float>
[condition type:
range-condition-unsatisfiable]
If domains and ranges involve some inclusiveness (gx:subtypep relation in RDF and subsumed-p relation in OWL) among them, the most specific concepts (classes) or MSCs are returned. Namely, the return value of get-domain and get-range is the most specific concept (if all concepts are related in the super-sub relation) or a list of the most specific concepts (if some concepts are independent in the super-sub relation).
After rebooting SWCLOS,
gx-user(2): (defProperty
hasInteger (rdfs:range xsd:integer))
#<rdf:Property
hasInteger>
gx-user(3): (defProperty
hasPositiveInteger
(rdfs:range
xsd:positiveInteger)
(rdfs:subPropertyOf
hasInteger))
#<rdf:Property hasPositiveInteger>
gx-user(4):
(get-range hasPositiveInteger)
#<rdfs:Datatype
xsd:positiveInteger>
gx-user(5): (subtypep xsd:positiveInteger
xsd:integer)
t
t
In this case, xsd:positiveInteger is chosen as range constraint of property subproperty hasPositiveInteger in two constraints, xsd:integer and xsd:positiveInteger, because xsd:positiveInteger is more specific than xsd:integer.