the daml example

From: Deborah Mcguinness (dlm@ksl.stanford.edu)
Date: 01/09/01


We are updating our parser to take in the new daml+oil and in our efforts ran
into the following problem.
This is from jessica (my colleague) where we were having issues with the
namespace.
she suggests a solution.
note this is in addition to the namespace problem that ian posted the fix for.




The namespace error in this document results from the default
namespace being set to the daml+oil URI instead of the daml+oil-ex
URI. In the definition of Adam, 

<Person rdf:ID="Adam">
  <rdfs:label>Adam</rdfs:label>
  <rdfs:comment>Adam is a person.</rdfs:comment>
</Person>

the default namespace causes the word 'Person' to be read in as the
fully-qualified name
http://www.daml.org/2000/12/daml+oil#Person. Person is not defined in
daml+oil.daml. As a result, Adam is
declared to be of a type that does not exist. 

The actual intent is to refer to the Person defined in this
document, which is http://www.daml.org/2000/10/daml+oil-ex#Person. The
same error occurs in the definition of the enumerated class Height.

I suggest that the error be corrected by changing the default
namespace to the URI of daml+oil-ex.daml. In addition, any
usage of resources defined in daml+oil.daml should specifically use
the daml namespace.

I have implemented this solution below.
----------------------------------------

<rdf:RDF
  xmlns:rdf ="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  xmlns     ="http://www.daml.org/2000/12/daml+oil-ex#"
  xmlns:daml="http://www.daml.org/2000/12/daml+oil#"
  >

<daml:Ontology rdf:about="">
  <daml:versionInfo>$Id: daml+oil-ex.daml,v 1.1 2001/01/02 18:44:47 mdean Exp $</daml:versionInfo>
  <rdfs:comment>An example ontology</rdfs:comment>
  <daml:imports rdf:resource="http://www.daml.org/2000/12/daml+oil"/>
</daml:Ontology>

<rdfs:Class rdf:ID="Animal">
  <rdfs:label>Animal</rdfs:label>
  <rdfs:comment>
    This class of animals is illustrative of a number of ontological idioms.
  </rdfs:comment>
</rdfs:Class>

<!-- FvH: moved cardinality restriction on parent "out of line" -->
<!-- to simplify first class def + to illustrate out-of-line statements -->

<rdfs:Class rdf:ID="Male">
  <rdfs:subClassOf rdf:resource="#Animal"/>
</rdfs:Class>

<rdfs:Class rdf:ID="Female">
  <rdfs:subClassOf rdf:resource="#Animal"/>
  <daml:disjointWith rdf:resource="#Male"/>
</rdfs:Class>

<rdfs:Class rdf:ID="Man">
  <rdfs:subClassOf rdf:resource="#Person"/>
  <rdfs:subClassOf rdf:resource="#Male"/>
</rdfs:Class>

<rdfs:Class rdf:ID="Woman">
  <rdfs:subClassOf rdf:resource="#Person"/>
  <rdfs:subClassOf rdf:resource="#Female"/>
</rdfs:Class>

<rdf:Property rdf:ID="parent">
  <rdfs:domain rdf:resource="#Animal"/>
</rdf:Property>

<!-- FvH: changed range of father to Male -->
<!-- made exposition easier (and makes more sense in the example as well) -->

<rdf:Property rdf:ID="father">
  <rdfs:subPropertyOf rdf:resource="#parent"/>
  <rdfs:range rdf:resource="#Male"/>
</rdf:Property>

<!-- FvH: changed cardinality restrictions everywhere to alternative RDF notation to avoid exposed content -->

<rdfs:Class rdf:ID="Person">
  <rdfs:subClassOf rdf:resource="#Animal"/>
  <daml:restrictedBy>
    <daml:Restriction>
      <daml:onProperty rdf:resource="#parent"/>
      <daml:toClass rdf:resource="#Person"/>
    </daml:Restriction>
  </daml:restrictedBy>
  <daml:restrictedBy>
    <daml:Restriction daml:cardinality="1">
      <daml:onProperty rdf:resource="#father"/>
    </daml:Restriction>
  </daml:restrictedBy>
</rdfs:Class>

<rdfs:Class rdf:about="#Animal">
  <rdfs:comment>
    Animals have exactly two parents, ie:
    if x is an animal, then it has exactly 2 parents (but NOT vice versa).
  </rdfs:comment>
  <daml:restrictedBy>
    <daml:Restriction daml:cardinality="2">
      <daml:onProperty rdf:resource="#parent"/>
    </daml:Restriction>
  </daml:restrictedBy>
</rdfs:Class>

<!-- FvH: used spouse as an example of a maxcardinality constraint -->

<rdfs:Class rdf:about="#Person">
  <daml:restrictedBy>
    <daml:Restriction daml:maxcardinality="1">
      <daml:onProperty rdf:resource="#spouse"/>
    </daml:Restriction>
  </daml:restrictedBy>
</rdfs:Class>

<!-- FvH: introduced FullTimeOccupation as an example of a qualified cardinality constraint -->

<rdfs:Class rdf:about="#Person">
  <daml:restrictedBy>
    <daml:Restriction daml:maxcardinalityQ="1">
      <daml:onProperty rdf:resource="#occupation"/>
      <daml:hasClassQ rdf:resource="#FullTimeOccupation"/>
    </daml:Restriction>
  </daml:restrictedBy>
</rdfs:Class>


<!-- FvH: modifed range of mother to be female (similar to range of father = male) -->

<daml:UniqueProperty rdf:ID="mother">
  <rdfs:subPropertyOf rdf:resource="#parent"/>
  <rdfs:range rdf:resource="#Female"/>
</daml:UniqueProperty>

<rdf:Property rdf:ID="child">
  <daml:inverseOf rdf:resource="#parent"/>
</rdf:Property>

<daml:TransitiveProperty rdf:ID="ancestor">
  <rdfs:label>ancestor</rdfs:label>
</daml:TransitiveProperty>

<daml:TransitiveProperty rdf:ID="descendant"/>

<rdf:Property rdf:ID="mom">
  <daml:samePropertyAs rdf:resource="#mother"/>
</rdf:Property>

<rdfs:Class rdf:ID="Car">
  <rdfs:comment>no car is a person</rdfs:comment>
  <rdfs:subClassOf>
    <rdfs:Class>
      <daml:complementOf rdf:resource="#Person"/>
    </rdfs:Class>
  </rdfs:subClassOf>
</rdfs:Class>

<!-- @@CAVEAT: daml:collection is an extension of RDF 1.0 syntax;
     don't expect existing tools to support it.
     @@TODO: specify how it works, implement it. -->

<!-- FvH: added example of pairwise Disjoint set of classes --> 

<!-- JSJ: Changed the Class references below from begin tags
     empty tags. -->

<daml:Disjoint parseType="daml:collection">
  <rdfs:Class rdf:about="#Car"/>
  <rdfs:Class rdf:about="#Person"/>
  <rdfs:Class rdf:about="#Plant"/>
</daml:Disjoint>

<rdfs:Class rdf:about="#Person">
  <rdfs:comment>every person is a man or a woman</rdfs:comment>
  <daml:disjointUnionOf parseType="daml:collection">
    <rdfs:Class rdf:about="#Man"/>
    <rdfs:Class rdf:about="#Woman"/>
  </daml:disjointUnionOf>
</rdfs:Class>

<rdfs:Class rdf:ID="TallMan">
  <daml:intersectionOf parseType="daml:collection">
    <rdfs:Class rdf:about="#TallThing"/>
    <rdfs:Class rdf:about="#Man"/>
  </daml:intersectionOf>
</rdfs:Class>

<!-- FvH: introduced MarriedPerson to illustrate idiomatic use of intersectionOf for biconditional definitions -->

<rdfs:Class rdf:ID="MarriedPerson">
  <daml:intersectionOf parseType="daml:collection">
    <rdfs:Class rdf:about="#Person"/>
    <daml:Restriction daml:cardinality="1">
      <daml:onProperty rdf:resource="#spouse"/>
    </daml:Restriction>
  </daml:intersectionOf>
</rdfs:Class>

<!-- FvH: introduced example for sameClassAss -->

<rdfs:Class rdf:ID="HumanBeing">
  <daml:sameClassAs rdf:resource="#Person">
</rdfs:Class>

<Person rdf:ID="Adam">
  <rdfs:label>Adam</rdfs:label>
  <rdfs:comment>Adam is a person.</rdfs:comment>
</Person>

<rdf:Property rdf:ID="height">
  <rdfs:range rdf:resource="#Height"/>
</rdf:Property>

<rdfs:Class rdf:ID="Height">
  <daml:oneOf parseType="daml:collection">
    <Height rdf:ID="short"/>
    <Height rdf:ID="medium"/>
    <Height rdf:ID="tall"/>
  </daml:oneOf>
</rdfs:Class>

<!-- TallThing is EXACTLY the class of things whose height is tall -->

<rdfs:Class rdf:ID="TallThing">
  <daml:sameClassAs>
    <daml:Restriction>
      <daml:onProperty rdf:resource="#height"/>
      <daml:hasValue rdf:resource="#tall"/>
    </daml:Restriction>
  </daml:sameClassAs>
</rdfs:Class>

<!-- @@ need example of hasClass qualification -->

<!-- @@ example of subProperty, label, comment, etc. from RDF/RDFS -->

</rdf:RDF>


This archive was generated by hypermail 2.1.4 : 04/02/02 EST