Introduction to DAML: Part II
Pages: 1, 2, 3
Non-exclusive combinations
One can also express non-exclusive boolean combinations of classes.
<daml:Class rdf:ID="CampingGear">
<rdfs:label>Camping Gear</rdfs:label>
<rdfs:comment>An item designed for use while camping</rdfs:comment>
</daml:Class>
<daml:Class rdf:ID="HikingGear">
<rdfs:label>Hiking Gear</rdfs:label>
<rdfs:comment>An item designed for use while hiking</rdfs:comment>
</daml:Class>
<daml:Class rdf:ID="FamilyProduct">
<rdfs:label>Family Product</rdfs:label>
<rdfs:comment>An item designed for family use</rdfs:comment>
<daml:unionOf parseType="daml:collection">
<daml:Class rdf:about="#CampingGear"/>
<daml:Class rdf:about="#HikingGear"/>
</daml:unionOf>
</daml:Class>
A product is a family product if and only if it is either hiking
gear or camping gear. A class expression establishes a set of
resources: those which are types of the class given in the
expression. daml:unionOf is a standard union of the sets
defined by each of the listed class expressions.
<daml:Class rdf:ID="HikingGear">
<rdfs:label>Hiking Gear</rdfs:label>
<rdfs:comment>An item designed for use while hiking</rdfs:comment>
</daml:Class>
<daml:Class rdf:ID="Footwear">
<rdfs:label>Footwear</rdfs:label>
<rdfs:comment>An item worn on the feet</rdfs:comment>
</daml:Class>
<daml:Class rdf:ID="HikingShoes">
<rdfs:label>Hiking Shoes</rdfs:label>
<rdfs:comment>An item worn on the feet while hiking</rdfs:comment>
<daml:intersectionOf parseType="daml:collection">
<daml:Class rdf:about="#HikingGear"/>
<daml:Class rdf:about="#Footwear"/>
</daml:intersectionOf>
</daml:Class>
A product is classified as hiking shoes if and only if it is hiking gear and it is also footwear. This is also standard intersection of the sets defined by the listed class expressions.
We mentioned that a class expression can be more than a simple URI reference. Enumerations, which we covered in the last article, and these boolean class expressions can also be used as class expressions.
More Power To Properties
Let's have a look at some of the additional statements DAML+OIL allows us to make about properties.
Inverse properties
Inverse properties are quite common. If A is the father of B, then B is the child of A. The properties "father" and "child" are the inverse of each other. DAML+OIL allows one to declare this systematically, so that you are free to only assert one property, and its inverse is inferred.
<daml:ObjectProperty rdf:ID="gear">
<rdfs:label>gear</rdfs:label>
<rdfs:comment>Indicates a product that is used in association
with an activity</rdfs:comment>
<daml:domain rdf:resource="#Activity"/>
<daml:range rdf:resource="#Product"/>
</daml:ObjectProperty>
<daml:ObjectProperty rdf:ID="usedFor">
<rdfs:label>used for</rdfs:label>
<rdfs:comment>Indicates an activity for which a product
is designed</rdfs:comment>
<daml:inverseOf rdf:resource="#gear"/>
<daml:domain rdf:resource="#Product"/>
<daml:range rdf:resource="#Activity"/>
</daml:ObjectProperty>
Only one of the properties need carry the
daml:inverseOf property, as it is reflexive. Also note
that the range of one property is the domain of its inverse and vice
versa.
Transitivity
Another important specialization of properties in DAML+OIL is
transitivity. For instance, the ancestor of your ancestor is also your
ancestor. There is at least one common transitive property built into
RDFS: daml:subClassOf. If class A is a subclass of B, and
class B is a subclass of C, then class A must be a subclass of
C. DAML+OIL allows one to give this behavior to any object property
one wishes. Suppose that we decide to model the interest groups
relevant to Super Sports customers. (Like all useful ontologies, ours
already begins to expand beyond its initial scopeg.)
<daml:TransitiveProperty rdf:ID="member">
<rdfs:label>member</rdfs:label>
<rdfs:comment>Indicates a group which a person or
another group has joined</rdfs:comment>
</daml:TransitiveProperty>
<daml:Class rdf:ID="Person">
<rdfs:label>Person</rdfs:label>
<rdfs:comment>An individual human being</rdfs:comment>
</daml:Class>
<daml:Class rdf:ID="Organization">
<rdfs:label>Organization</rdfs:label>
<rdfs:comment>An collection of affiliated human
beings</rdfs:comment>
</daml:Class>
<!-- Instances. Assume appropriate default
XML namespace declaration -->
<Organization rdf:ID="AmericanCrossCountrySkiers">
<rdfs:label>American Cross Country Skiers (AXCS)</rdfs:label>
<rdfs:comment>An association that serves U.S. Master
(age 30 and older) cross country skiers with a wide
range of education, promotion and communication
programs. </rdfs:comment>
</Organization>
<Organization rdf:ID="BoulderNordicClub">
<rdfs:label>Boulder Nordic Club (BNC)</rdfs:label>
<rdfs:comment>A club organized to support cross
country skiing in the Boulder area</rdfs:comment>
<member rdf:resource="#AmericanCrossCountrySkiers"/>
</Organization>
<Person rdf:ID="jsmith">
<rdfs:label>Mr. John Smith</rdfs:label>
<rdfs:comment>Mr. John Smith is a cross-country
skier from Boulder, Colorado</rdfs:comment>
<member rdf:resource="#BoulderNordicClub"/>
</Person>
If a DAML+OIL agent, given this information, were asked whether John Smith is a member of AXCS, the answer would be "yes", even though this is not directly stated. The affirmative is given by inference from the fact that John is a member of BNC, BNC is a member of AXCS, and "member" is a transitive property. This works regardless of the fact that the transitive property spans different classes (Person and Organization).