Commentary on listOfInstancesOf


This note provides documentation for the property listOfInstancesOf, which is defined in Process.daml, and also describes some unresolved issues about its use.

Description

This property is commented, in Process.daml, as follows:

    The range is a list of classes.

    This property is defined similarly to DAML+OIL properties having List
    as range, such as daml:oneOf and daml:intersectionOf, and is meant
    to be used similarly, with parseType=collection.

    "Class listOfInstancesOf X Y Z" (for example) is used to indicate the class
    of lists having an instance of class X as their first member, an instance
    of class Y as their second member, and an instance of class Z as their
    third member.

    An instance of listOfInstancesOf represents an anonymous class, as
    explained here:
      http://www.daml.org/services/daml-s/0.9/listOfInstancesOf.html.

    Note that listOfInstancesOf is provided as "syntactic sugar"; that is,
    it isn't required to express the intended anonymous class definition.
    It is provided to allow for shorter, more readable expressions in process
    definitions.

We emphasize here that listOfInstancesOf isn't required in any process definition.  That is, one can always give the longer form, expressed purely using DAML+OIL restrictions and list constructs, as explained below.

listOfInstancesOf is a valid DAML+OIL property, and an instance of it, expressed with parseType=collection, will be parsed by any DAML+OIL parser.  However, there is some concern, due to the documentation of parseType=collection in the DAML+OIL reference manual, that DAML+OIL parsers and tools are not clearly guaranteed to maintain the order of the elements expressed in this way.     See Unresolved Issues, below, for additional information on these points.
 

Example

This use of listOfInstancesOf appears in CongoProcess.daml, in the definition of FullCongoBuy:

(A)

 <daml:Class>
   <daml:listOfInstancesOf rdf:parseType="daml:collection">
     <daml:Class rdf:about="#LocateBook"/>
     <daml:Class rdf:about="#CongoBuyBook"/>
   </daml:listOfInstancesOf>
 </daml:Class>
A DAML+OIL parser would expand the listOfInstancesOf construct above, into the following, as mandated by the spec of DAML+OIL:

(B)

<daml:Class>
  <daml:listOfInstancesOf>
    <daml:List>
      <daml:first rdf:resource="#LocateBook"/>
      <daml:rest>
        <daml:List>
          <daml:first rdf:resource="#CongoBuyBook"/>
          <daml:rest rdf:resource="http://www.daml.org/2001/03/daml+oil#nil"/>
        </daml:List>
      </daml:rest>
    </daml:List>
  </daml:listOfInstancesOf>
</daml:Class>
Any tool or component that processes DAML-S is required to further "expand" the above into the following:
(C)
  <daml:Class>
    <rdfs:subClassOf>
      <daml:Restriction>
        <daml:onProperty rdf:resource="&daml;#first"/>
        <daml:toClass rdf:resource="#LocateBook"/>
      </daml:Restriction>
    </rdfs:subClassOf>
    <rdfs:subClassOf>
      <daml:Restriction>
        <daml:onProperty rdf:resource="&daml;#rest"/>
        <daml:toClass>
          <daml:Class>
            <rdfs:subClassOf>
              <daml:Restriction>
                <daml:onProperty rdf:resource="&daml:#first"/>
                <daml:toClass rdf:resource="#CongoBuyBook"/>
              </daml:Restriction>
            </rdfs:subClassOf>
            <rdfs:subClassOf>
              <daml:Restriction>
                <daml:onProperty rdf:resource="&daml;rest"/>
                <daml:hasValue rdf:resource="&daml;nil"/>
              </daml:Restriction>
            </rdfs:subClassOf>
          </daml:Class>
        </daml:toClass>
      </daml:Restriction>
    </rdfs:subClassOf>
  </daml:Class>

Unresolved issues

There is an ongoing discussion in the DAML-S Coalition, as to the usefulness and appropriateness of listOfInstancesOf, and two unresolved issues about it are summarized here. As illustrated above, the purpose of listOfInstancesOf is simply to allow for a compact way of representing a rather lengthy nested Restriction, similarly to the way that Lisp provides the familiar parenthesized list notation, as a shorthand for the canonical "consed pair" construction.  Unfortunately, it is somewhat difficult to achieve its intended effect, using the existing features of DAML+OIL.  We expect a more clear-cut approach to be possible in the future, using OWL or some other descendant of DAML+OIL.

Maintenance of order

If one uses listOfInstancesOf in a process definition (with parseType=collection) , one would like to have an affirmative answer to the following question:

Can I feel confident that a DAML+OIL-compliant parser or tool will maintain the order of elements given inside a parseType=collection construct, when it's used in specifying an instance of a user-defined property?

Because of the way parseType=collection is described in the DAML+OIL reference document, we do not feel that one can give a clear-cut affirmative answer to the above.  (However, some members of the DAML-S coalition feel that one can answer "yes, for all practical purposes".)

Some discussion of this issue can be found on the www-rdf-logic mailing list archives, starting with this message:

http://lists.w3.org/Archives/Public/www-rdf-logic/2002Sep/0016.html

Requirements on DAML-S tools

listOfInstancesOf is similar, in some respects, to a macro in a programming language such as Lisp.  To achieve its intended effect, listOfInstancesOf must be "expanded" properly, by whatever DAML-S tool or processor reads it.  As of this writing, no DAML-S-specific components are known to handle this construct.  Therefore, if you are working with a DAML-S processing component that reads your process definitions, it may be advantageous to avoid the use of listOfInstancesOf for the time being.

There is an ongoing discussion on the question of whether this particular expansion represents a reasonable requirement on a tool or component that processes DAML-S code (that is, the expansion that results in (C), above, from (B)).