8.  Domain and Range

8.1  Adding Domain and Range Constraints

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

rdfs:domain property
[Accessor]
provides an access method for the domain value of property. This method signals an error, if the value is unbound.

rdfs:range property
[Accessor]
provides an access method for the range value of property. This method signals an error, if the value is unbound.

domain-value property
[Function]
returns the domain value of property. This function returns cl:nil, if the value is unbound.

range-value property
[Function]
returns the range value of property. This function returns cl:nil, if the value is unbound.

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>

get-domain property
[Function]
This function searches domains that are directly defined and inherited from its super properties and returns the most specific domain values. So, the return value may be a single value or a list of values. This function returns cl:nil if any defined domain is not found after the exhaustive search. However, note that cl:nil for domain value means rdfs:Resource in fact by RDFS semantics. If a disjoint pair of values found, domain-condition-unsatiafiable error is signaled.

collect-domains properties
[Function]
collects domains from each of properties using get-domain. A property must be a symbol.

domainp property domain
[Function]
returns true if property's domain is a subclass of domain, or if some of property's super-properties has a subclass of domain.

get-range property
[Function]
returns the range value from property and its super-properties. The inheritance rule is same as get-domain. This function may signal range-condition-unsatiafiable error.

collect-ranges properties
[Function]
collects ranges from each of properties using get-range. A property must be a symbol.

rangep property range
[Function]
returns true if property's range is a subclass of range, or if some of property's super-properties has a subclass of range.

8.2  Domain and Range Constraints Satisfaction

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.


Author:
Seiji Koide. Copyright (c) 2005, 2006 GALAXY EXPRESS CORPORATION. Feb. 2006
Copyright (c) 2007-2010 Seiji Koide. Oct.2010