acyclical lists in DAML+OIL

From: Ian Horrocks ([email protected])
Date: 06/27/01


Here is the promised sketch of how to do acyclical lists in
DAML+OIL. There are no doubt many syntax errors (can we have human
read/writeable syntax PLEASE!). I assumed the standard headers and
stuff. I made it generic so that it is easy to have different types of
list (different element types), but this does make it a little more
complex than would be required for the simple case.

Regards, Ian

<daml:TransitiveProperty rdf:ID="rest+"/>
<daml:ObjectProperty rdf:ID="first"/>
<daml:ObjectProperty rdf:ID="rest">
  <rdfs:subPropertyOf rdf:resource="#rest+"/>
</daml:ObjectProperty>

<daml:Class rdf:ID="Null">
  <rdfs:comment>
    Null marks end of list. It has no first or rest properties.
  </rdfs:comment>
  <rdfs:subClassOf>
    <daml:Restriction>
      <daml:onProperty rdf:resource="#first"/>
      <daml:toClass rdf:resource="http://www.daml.org/2001/03/daml+oil#Nothing"/>
    </daml:Restriction>
  </rdfs:subClassOf>
  <rdfs:subClassOf>
    <daml:Restriction>
      <daml:onProperty rdf:resource="#rest"/>
      <daml:toClass rdf:resource="http://www.daml.org/2001/03/daml+oil#Nothing"/>
    </daml:Restriction>
  </rdfs:subClassOf>
</daml:Class>

<daml:Class rdf:ID="Head">
  <rdfs:comment>
    Head marks the first element of a list and prevents cyclical lists.
  </rdfs:comment>
</daml:Class>

<daml:Class rdf:ID="Element">
  <rdfs:comment>
    A list element is either Null (end of list) or a first/rest structure.
  </rdfs:comment>
  <rdfs:subClassOf>
    <daml:unionOf rdf:parseType="daml:collection">
      <daml:Class rdf:about="#Null"/>
      <daml:Class>
        <daml:intersectionOf rdf:parseType="daml:collection">
          <daml:Restriction>
            <daml:onProperty rdf:resource="#first"/>
            <daml:hasClass rdf:resource="http://www.daml.org/2001/03/daml+oil#Thing"/>
          </daml:Restriction>
          <daml:Restriction>
            <daml:onProperty rdf:resource="#rest"/>
            <daml:hasClass>
              <daml:Class>
                <daml:intersectionOf rdf:parseType="daml:collection">
                  <daml:Class rdf:about="#Element"/>
                  <daml:Class>
                    <daml:complementOf rdf:resource="#Head"/>
                  </daml:Class>
                </daml:intersectionOf>
              </daml:Class>
            </daml:hasClass>
          </daml:Restriction>
          <daml:Restriction daml:maxCardinality="1">
            <daml:onProperty rdf:resource="#rest"/>
          </daml:Restriction>
          <daml:Restriction daml:maxCardinality="1">
            <daml:onProperty>
              <daml:ObjectProperty>
                <daml:inverseOf rdf:resource="#rest"/>
              </daml:ObjectProperty>
            </daml:onProperty>
          </daml:Restriction>
        </daml:intersectionOf>
      </daml:Class>
    </daml:unionOf>
  </rdfs:subClassOf>
</daml:Class>

<daml:Class rdf:ID="List">
  <rdfs:comment>
    Generic list.
  </rdfs:comment>
  <rdfs:subClassOf rdf:resource="#Head"/>
  <rdfs:subClassOf rdf:resource="#Element"/>
</daml:Class>

<daml:Class rdf:ID="ListC">
  <rdfs:comment>
    List all of whose elements are of type C.
  </rdfs:comment>
  <rdfs:subClassOf rdf:resource="#List"/>
  <rdfs:subClassOf>
    <daml:Restriction>
      <daml:onProperty rdf:resource="#first"/>
      <daml:toClass rdf:resource="#C"/>
    </daml:Restriction>
  </rdfs:subClassOf>
  <rdfs:subClassOf>
    <daml:Restriction>
      <daml:onProperty rdf:resource="#rest+"/>
      <daml:Restriction>
        <daml:onProperty rdf:resource="#first"/>
        <daml:toClass rdf:resource="#C"/>
      </daml:Restriction>
    </daml:Restriction>
  </rdfs:subClassOf>
</daml:Class>


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