<?xml version='1.0' encoding='ISO-8859-1'?> 
<!DOCTYPE uridef[
  <!ENTITY rdf     "http://www.w3.org/1999/02/22-rdf-syntax-ns">
  <!ENTITY rdfs    "http://www.w3.org/2000/01/rdf-schema">
  <!ENTITY xsd     "http://www.w3.org/2000/10/XMLSchema">
  <!ENTITY daml    "http://www.daml.org/2001/03/daml+oil">
  <!ENTITY dex     "http://www.daml.org/2001/03/daml+oil-ex">
  <!ENTITY exd     "http://www.daml.org/2001/03/daml+oil-ex-dt">
  <!ENTITY service "http://www.daml.org/services/daml-s/2001/05/Service.daml">
  <!ENTITY process "http://www.daml.org/services/daml-s/2001/05/Process.daml">
  <!ENTITY time    "http://www.ai.sri.com/~daml/ontologies/sri-basic/1-0/Time.daml">
  <!ENTITY congo   "http://www.daml.org/services/daml-s/2001/05/Congo.daml"> 
  <!ENTITY DEFAULT "http://www.daml.org/services/daml-s/2001/05/Congo.daml"> 
  <!ENTITY THIS    "http://www.daml.org/services/daml-s/2001/05/Congo.daml"> 
]>

<rdf:RDF
  xmlns:rdf =     "&rdf;#"
  xmlns:rdfs =    "&rdfs;#"
  xmlns:xsd =     "&xsd;#"
  xmlns:daml =    "&daml;#"
  xmlns:dex =     "&dex;#"
  xmlns:exd =     "&exd;#"
  xmlns:service = "&service;#"
  xmlns:process = "&process;#"
  xmlns:time =    "&time;#"
  xmlns =         "&congo;#"
>

<daml:Ontology rdf:about="">
  <daml:versionInfo>
    $Id: Congo.daml,v 1.5 2001/07/20 02:43:38 mdean Exp $
  </daml:versionInfo>
  <rdfs:comment>
      A B2C bookbuying example for DAML-S, illustrating a simple use of 
      the process model.  This is a sketch; not a complete example.

      The basic service is a buybook service from www.congo.com.  The
      service can be treated as ATOMIC; i.e., given certain inputs and
      parameters, the service provides certain outputs and has specific
      effects. The service can also be expanded to specify it as a composition
      of other component services. The atomic service is the CongoBuy
      Service which has preconditions, inputs, outputs and
      effects. The expanded version of the service, ExpandedCongoBuy,
      includes an arrangement of processes LocateBook, PutInCart, SignIn, 
      CreateAcct, CreateProfile, LoadProfile, SpecifyDeliveryDetails, 
      FinalizeBuy each with its own i/o spec. 

        Created by Srini Narayanan (srini@ai.sri.com).
        Modifications by David Martin, Terri Payne, Mark Burstein, Srini Narayanan.
  </rdfs:comment>
  <daml:imports rdf:resource="&daml;"/>
  <daml:imports rdf:resource="&time;"/>
  <daml:imports rdf:resource="&service;"/>
  <daml:imports rdf:resource="&process;"/>
</daml:Ontology>

<!--
NOTES ON LANGUAGE USE:
NOTE: This DAML code employs 2 proposed properties: 
daml:-sameValuesAs-
daml:-listOfInstancesOf-
which are not currently part of DAML+OIL.  (The beginning and ending
hyphens are meant to flag these as such.)
-->

<!--  DATA TYPES -->

<rdfs:Class rdf:ID="CreditCardTypes">
  <daml:oneOf rdf:parseType="daml:collection">
    <daml:Class rdf:ID="MasterCard"/>
    <CreditCardType rdf:ID="VISA"/>
    <CreditCardType rdf:ID="AmericanExpress"/>
    <CreditCardType rdf:ID="DiscoverCard"/>
   </daml:oneOf>
</rdfs:Class>

<rdfs:Class rdf:ID="PackageInstructions">
  <daml:oneOf rdf:parseType="daml:collection">
    <PackageInstructions rdf:ID="Giftwrap"/>
    <PackageInstructions rdf:ID="Ordinary"/>
  </daml:oneOf>
</rdfs:Class>

<rdfs:Class rdf:ID="DeliveryType">
  <daml:oneOf rdf:parseType="daml:collection">
    <DeliveryType rdf:ID="FedExOneDay"/>
    <DeliveryType rdf:ID="FedEx2-3day"/>
    <DeliveryType rdf:ID="UPS"/>
    <DeliveryType rdf:ID="OrdinaryMail"/>
  </daml:oneOf>
</rdfs:Class>

<rdfs:Class rdf:ID="ValidityType">
  <daml:oneOf rdf:parseType="daml:collection">
    <ValidityType rdf:ID="Valid"/>
    <ValidityType rdf:ID="Expired"/>
    <ValidityType rdf:ID="Invalid CC-Number"/>
    <ValidityType rdf:ID="Invalid CC-Type"/>
    <ValidityType rdf:ID="Authorization Refused"/>
  </daml:oneOf>
</rdfs:Class>

<rdfs:Class rdf:ID="BuyEffectType">
  <daml:oneOf rdf:parseType="daml:collection">
    <BuyEffectType rdf:ID ="OrderShipped"/>
    <BuyEffectType rdf:ID ="Failure"/>
  </daml:oneOf>
</rdfs:Class>

<!-- stub most of these for now -->

<rdfs:Class rdf:ID="Book">
  <rdfs:subClassOf rdf:resource="&daml;#Thing"/>
</rdfs:Class>

<rdfs:Class rdf:ID="EReceipt">
  <rdfs:subClassOf rdf:resource="&daml;#Thing"/>
</rdfs:Class>

<rdfs:Class rdf:ID="ShippingOrder">
  <rdfs:subClassOf rdf:resource="&daml;#Thing"/>
</rdfs:Class>

<rdfs:Class rdf:ID="SignInData">
  <rdfs:subClassOf rdf:resource="&daml;#Thing"/>
</rdfs:Class>

<rdf:Property rdf:ID="acctName">
  <rdfs:domain rdf:resource="#SignInData"/>
  <rdfs:range rdf:resource="&xsd;#string"/>
</rdf:Property>

<rdf:Property rdf:ID="password">
  <rdfs:domain rdf:resource="#SignInData"/>
  <rdfs:range rdf:resource="&xsd;#string"/>
</rdf:Property>

<rdfs:Class rdf:ID="ProfileInfo">
  <rdfs:subClassOf rdf:resource="&daml;#Thing"/>
</rdfs:Class>

<rdfs:Class rdf:ID="CreateAcctInfo">
 <daml:unionOf rdf:parseType="daml:collection">
    <daml:Class rdf:about="#SignInData"/>
    <daml:Class rdf:about="#ProfileInfo"/>
 </daml:unionOf>
</rdfs:Class>

<rdfs:Class rdf:ID="ENotify">
  <rdfs:subClassOf rdf:resource="&daml;#Thing"/>
</rdfs:Class>

<rdfs:Class rdf:ID="CreateAcctOutput">
 <daml:unionOf rdf:parseType="daml:collection">
    <daml:Class rdf:about="#CreateAcctInfo"/>
    <daml:Class rdf:about="#ENotify"/>
 </daml:unionOf>
</rdfs:Class>

<!-- Shopping cart
Holding the books is the Cart Class defined below 
various processes like like AddToCart, RemoveFromCart, itemInCart?, 
etc can be defined using the Cart Class as the structure manipulated.
So the ouput/effect of these processes would manipulate the cart to
add, delete items.  (These manipulations are not yet specified here.)
-->

<rdfs:Class rdf:ID="Cart">
  <daml:intersectionOf rdf:parseType="daml:collection">
    <daml:Class rdf:about="daml:List"/>
    <daml:Restriction>
      <daml:onProperty rdf:resource="daml:item"/>
      <daml:toClass rdf:resource="#Book"/>
    </daml:Restriction>
  </daml:intersectionOf>
</rdfs:Class>

<!-- THE BASIC SERVICE PROCESS -->

<rdfs:Class rdf:ID="CongoBuy">
  <rdfs:subClassOf rdf:resource="&process;#Process"/>
</rdfs:Class>

<!-- initial inputs -->

<rdf:Property rdf:ID="congoBookName">
  <rdfs:subPropertyOf rdf:resource="&process;#input"/>
  <rdfs:domain rdf:resource="#CongoBuy"/>
  <rdfs:range rdf:resource="&xsd;#string"/>
</rdf:Property>

<rdf:Property rdf:ID="congoSignInInfo">
  <rdfs:subPropertyOf rdf:resource="&process;#input"/>
  <rdfs:domain rdf:resource="#CongoBuy"/>
  <rdfs:range rdf:resource="#SignInData"/>
</rdf:Property>

<!-- Now for the parameters -->

<rdf:Property rdf:ID="creditCardValidity">
  <rdfs:subPropertyOf rdf:resource="&process;#parameter"/>
  <rdfs:domain rdf:resource="#CongoBuy"/>
  <rdfs:range rdf:resource="#ValidityType"/>
</rdf:Property>

<!-- 
2 Preconditions AccountExists and CreditExists.  The
range of the preconditions is a condition object with a
conditionValue property.  TBD: How to indicate that the conditionValue
(output) property of CreditExists holds the operative value.
-->

<rdfs:Class rdf:ID="CreditExists">
  <rdfs:subClassOf rdf:resource="&process;#Condition"/>
</rdfs:Class>

<rdfs:Class rdf:ID="AcctExists">
  <rdfs:subClassOf rdf:resource="&process;#Condition"/>
</rdfs:Class>

<rdf:Property rdf:ID="acctExistsPrecondition">
  <rdfs:subPropertyOf rdf:resource="&process;#precondition"/>
  <rdfs:domain rdf:resource="#CongoBuy"/>
  <rdfs:range rdf:resource="#AcctExists"/>
</rdf:Property>

<rdf:Property rdf:ID="creditExistsPrecondition">
  <rdfs:subPropertyOf rdf:resource="&process;#precondition"/>
  <rdfs:domain rdf:resource="#CongoBuy"/>
  <rdfs:range rdf:resource="#CreditExists"/>
</rdf:Property>

<!-- TWO OUTPUTS, E-RECEIPT AND SHIPPING-ORDER -->

<rdf:Property rdf:ID="eReceiptOutput">
  <rdfs:subPropertyOf rdf:resource="&process;#output"/>
  <rdfs:domain rdf:resource="#CongoBuy"/>
  <rdfs:range rdf:resource="#EReceipt"/>
</rdf:Property>

<rdf:Property rdf:ID="shippingOrderOutput">
  <rdfs:subPropertyOf rdf:resource="&process;#output"/>
  <rdfs:domain rdf:resource="#CongoBuy"/>
  <rdfs:range rdf:resource="#ShippingOrder"/>
</rdf:Property>

<!-- 
THE EFFECT IS EITHER ORDERSHIPPED OR FAILURE. Conditional
Effects would require an If-Then-Else range. TBD... 
-->

<rdf:Property rdf:ID="buyEffect">
  <rdfs:subPropertyOf rdf:resource="&process;#effect"/>
  <rdfs:domain rdf:resource="#CongoBuy"/>
  <rdfs:range rdf:resource="#BuyEffectType"/>
</rdf:Property>

<!-- SUBPROCESSES -->

<!-- If some other process has an input property which is the same as
an input to CongoBuy, -sameValuesAs- is used to specify the
equivalence. In the example below, the LocateBook process uses an input,
bookName, that's the same as the congoBookName input to CongoBuy.  -->

<rdfs:Class rdf:ID="LocateBook">
  <rdfs:subClassOf rdf:resource="&process;#Process"/>
</rdfs:Class>

<rdf:Property rdf:ID="bookName">
  <rdfs:subPropertyOf rdf:resource="&process;#input"/>
  <rdfs:domain rdf:resource="#LocateBook"/>
  <rdfs:range rdf:resource="&xsd;#string"/>
  <daml:-sameValuesAs- rdf:resource="#congoBookName"/>
</rdf:Property>


<!-- A very simple version of the put in cart event, in which the
cart is a bag of books (each item being a book). This illustrates
another way of specifying the input, using the anonymous subclass with
a restriction 
-->

<rdfs:Class rdf:ID="PutInCart">
 <rdfs:subClassOf rdf:resource="&process;#Process"/>
 <rdfs:subClassOf>
  <daml:Restriction>
   <daml:onProperty rdf:resource="&process;#input"/>
   <daml:-sameValuesAs- rdf:resource="#congoBookName"/>
  </daml:Restriction>
 </rdfs:subClassOf>
</rdfs:Class>

<!-- Sign in is a process that requires input of signin info -->

<rdfs:Class rdf:ID="SignIn">
 <rdfs:subClassOf rdf:resource="&process;#Process"/>
</rdfs:Class>

<rdf:Property rdf:ID="signInInfo">
  <rdfs:subPropertyOf rdf:resource="&process;#input"/>
  <rdfs:domain rdf:resource="#SignIn"/>
  <rdfs:range rdf:resource="#SignInData"/>
  <daml:-sameValuesAs- rdf:resource="#congoSignInInfo"/>
</rdf:Property>

<!-- CreateAcct requires input of profile and signin info -->

<rdfs:Class rdf:ID="CreateAcct">
  <rdfs:subClassOf rdf:resource="&process;#Process"/>
</rdfs:Class>

<rdf:Property rdf:ID="inCreateAcctInfo">
  <rdfs:subPropertyOf rdf:resource="&process;#input"/>
  <rdfs:domain rdf:resource="#CreateAcct"/>
  <rdfs:range rdf:resource="#CreateAcctInfo"/>
</rdf:Property>

<rdf:Property rdf:ID="outCreateAcctOutput">
  <rdfs:subPropertyOf rdf:resource="&process;#output"/>
  <rdfs:domain rdf:resource="#CreateAcct"/>
  <rdfs:range rdf:resource="#CreateAcctOutput"/>
</rdf:Property>

<!-- 
Load Profile wants to place a restriction that not only 
the account, but the profile exists. This could be a value of
the account exists property. A bit of a kludge, should be
changed 
-->

<rdfs:Class rdf:ID="LoadProfile">
  <rdfs:subClassOf rdf:resource="&process;#Process"/>
   <rdfs:subClassOf>
    <daml:Restriction>
      <daml:onProperty rdf:resource="&process;#precondition"/>
      <daml:toClass rdf:resource ="#ProfileExists"/>
     </daml:Restriction>
   </rdfs:subClassOf>
</rdfs:Class>

<rdfs:Class rdf:ID="ProfileExists">
 <rdfs:subClassOf rdf:resource="&process;#Condition"/>
 <rdfs:subClassOf>
   <daml:Restriction>
     <daml:onProperty rdf:resource="&process;#Value"/>
     <daml:toValue rdf:ID ="True"/>
   </daml:Restriction>
 </rdfs:subClassOf>
</rdfs:Class>

<!-- SpecifyPaymentMethod -->

<rdfs:Class rdf:ID="SpecifyPaymentMethod">
  <rdfs:subClassOf rdf:resource="&process;#Process"/>
</rdfs:Class>

<rdf:Property rdf:ID="creditCardNumber">
  <rdfs:comment>NOTE:---INTEGER IS NOT SUPPORTED YET IN DAML-L </rdfs:comment>
  <rdfs:subPropertyOf rdf:resource="&process;#input"/>
  <rdfs:domain rdf:resource="#SpecifyPaymentMethod"/>
  <rdfs:range rdf:resource="&xsd;#decimal"/>
</rdf:Property>

<rdf:Property rdf:ID="creditCardType">
  <rdfs:subPropertyOf rdf:resource="&process;#input"/>
  <rdfs:domain rdf:resource="#SpecifyPaymentMethod"/>
  <rdfs:range rdf:resource="#CreditCardTypes"/>   
</rdf:Property>

<rdf:Property rdf:ID="creditCardExpirationDate">
  <rdfs:subPropertyOf rdf:resource="&process;#input"/>
  <rdfs:domain rdf:resource="#SpecifyPaymentMethod"/>
  <rdfs:range rdf:resource="&time;#Time"/>
</rdf:Property>


<!-- SpecifyDeliveryDetails -->

<rdfs:Class rdf:ID="SpecifyDeliveryDetails">
  <rdfs:subClassOf rdf:resource="&process;#Process"/>
</rdfs:Class>

<!-- ADDRESS IS A LITERAL FOR THE TIME BEING -->

<rdf:Property rdf:ID="inDeliveryAddress">
  <rdfs:subPropertyOf rdf:resource="&process;#input"/>
  <rdfs:domain rdf:resource="#SpecifyDeliveryDetails"/>
  <rdfs:range rdf:resource="&xsd;#string"/>
</rdf:Property>

<rdf:Property rdf:ID="inPackageInstructions">
  <rdfs:subPropertyOf rdf:resource="&process;#input"/>
  <rdfs:domain rdf:resource="#SpecifyDeliveryDetails"/>
  <rdfs:range rdf:resource="#PackageInstructions"/>
</rdf:Property>

<rdf:Property rdf:ID="inDeliveryType">
  <rdfs:subPropertyOf rdf:resource="&process;#input"/>
  <rdfs:domain rdf:resource="#SpecifyDeliveryDetails"/>
  <rdfs:range rdf:resource="#DeliveryType"/>
</rdf:Property>

<!-- FinalizeBuy -->

<rdfs:Class rdf:ID="FinalizeBuy">
  <rdfs:subClassOf rdf:resource="&process;#Process"/>
</rdfs:Class>

<!-- 
Now for the class to class expand case. This is much more
complicated since it has to specify the process schema including
alternatives, conditional executions, etc. Also, individual items in
the composition are now classes of processes, not instances. 

We will build the overall expand class recursively in a top-down
manner. The basic idea is that the "components" property (itself a bag
of Processes) specifies the individual classes that correspond to
elements of the bag. These individual classes may themselves be
composite processes (sequence, alternative, if-then-else, etc.) and
hence their "components" property details the decomposition at this
level.  Finally we bottom out when the components of a composite process are
simple processes (without components).

In the Congo example we assume the following basic structure for the
composition. The main steps are to locate a book and to then buy it. While
(for exposition) we assume that the locate book is a simple process
(without components), the buying of a book involves a sequence of
subprocesses that correspond to selecting a method of buying,
specifying the details of delivery (address, wrapping type, etc.) and
finalizing the buy process. These are the component subprocesses of the
sequence corresponding to the expanded buying process. The "method of
buying" process is itself a composite process involving a top level choice
between one-shot buying or a detailed buying sequence. While the one-shot
buy is a simple process (by definition) the detailed buying sequence involves
a sequence of component sub-processes corresponding to putting the
book into a cart, followed by a signing-in choice, followed by a method of 
payment selection. The signing-in choice process is itself a composite process
which offers the alternatives of signing in as a new user (creating an
account) or using a stored profile instead. Each of these processes is itself
composite, bottoming out in a sequence for simple processes corresponding to
signing in or creating a new account/profile.
-->

<!-- Expand and Collapse relations for the CongoBuy Process -->

<rdf:Description about="#CongoBuy">
   <process:expand rdf:resource="#ExpandedCongoBuy"/>
</rdf:Description>

<!-- 
The top level process is a sequence whose components are a simple
process, LocateBook and a composite process CongoBuyBook
-->

<rdfs:Class rdf:ID="ExpandedCongoBuy">   
  <daml:intersectionOf rdf:parseType="daml:collection">
    <rdfs:Class rdf:about="process:Sequence"/>
    <daml:Restriction> 
      <daml:onProperty rdf:resource="process:components"/>
      <daml:toClass>
        <daml:-listOfInstancesOf- rdf:parseType="daml:collection">
          <rdfs:Class rdf:about="#LocateBook"/>
          <rdfs:Class rdf:about="#CongoBuyBook"/>
        </daml:-listOfInstancesOf->
      </daml:toClass>
    </daml:Restriction>
  </daml:intersectionOf>
</rdfs:Class>

<!-- CongoBuyBook is a sequence whose components are a composite
process, TopLevelBuyChoice, followed by two simple processes
SpecifyDeliveryDetails, and then FinalizeBuy -->


<rdfs:Class rdf:ID="CongoBuyBook">           
  <daml:intersectionOf rdf:parseType="daml:collection">
    <daml:Class rdf:about="process:Sequence"/>
    <daml:Restriction> 
      <daml:onProperty rdf:resource="process:components"/>
      <daml:toClass>
        <daml:-listOfInstancesOf- rdf:parseType="daml:collection">
          <rdfs:Class rdf:about="#TopLevelBuyChoice"/>
          <rdfs:Class rdf:about="#SpecifyDeliveryDetails"/>
          <rdfs:Class rdf:about="#FinalizeBuy"/>
        </daml:-listOfInstancesOf->
      </daml:toClass>
    </daml:Restriction>
  </daml:intersectionOf>
</rdfs:Class>

<!-- 
TopLevelBuyChoice is a choice process whose components are a simple
process, OneShotBuy, or the composite process BuySequence 
-->

<rdfs:Class rdf:ID="TopLevelBuyChoice">           
  <daml:intersectionOf rdf:parseType="daml:collection">
    <rdfs:Class rdf:about="process:Choice"/>
    <daml:Restriction> 
      <daml:onProperty rdf:resource="process:components"/>
      <daml:toClass>
        <daml:-listOfInstancesOf- rdf:parseType="daml:collection">
          <rdfs:Class rdf:about="#OneShotBuy"/>
          <rdfs:Class rdf:about="#BuySequence"/>
        </daml:-listOfInstancesOf->
      </daml:toClass>
    </daml:Restriction>
  </daml:intersectionOf>
</rdfs:Class>

<!-- 
BuySequence is a sequence whose components are a simple
process PutInCart, followed by a composite process SignInAlternatives, followed
by a simple process SpecifyPaymentMethod 
-->

<rdfs:Class rdf:ID="BuySequence">           
  <daml:intersectionOf rdf:parseType="daml:collection">
    <rdfs:Class rdf:about="process:Sequence"/>
    <daml:Restriction> 
      <daml:onProperty rdf:resource="process:components"/>
      <daml:toClass>
        <daml:-listOfInstancesOf- rdf:parseType="daml:collection">
          <rdfs:Class rdf:about="#PutInCart"/>
          <rdfs:Class rdf:about="#SignInAlternatives"/>
          <rdfs:Class rdf:about="#SpecifyPaymentMethod"/>
        </daml:-listOfInstancesOf->
      </daml:toClass>
    </daml:Restriction>
  </daml:intersectionOf>
</rdfs:Class>


<!-- SignInAlternatives is a choice whose components are a composite
process CreateProfileSequence and a composite process SignInSequence 
-->

<rdfs:Class rdf:ID="SignInAlternatives">           
  <daml:intersectionOf rdf:parseType="daml:collection">
    <rdfs:Class rdf:about="process:Choice"/>
    <daml:Restriction> 
      <daml:onProperty rdf:resource="process:components"/>
      <daml:toClass>
        <daml:-listOfInstancesOf- rdf:parseType="daml:collection">
          <rdfs:Class rdf:about="#CreateProfileSequence"/>
          <rdfs:Class rdf:about="#SignInSequence"/>
        </daml:-listOfInstancesOf->
      </daml:toClass>
    </daml:Restriction>
  </daml:intersectionOf>
</rdfs:Class>

<!-- 
SignInSequence is a sequence whose components are a simple process SignIn
followed by a simple process LoadProfile 
-->

<rdfs:Class rdf:ID="SignInSequence">
  <daml:intersectionOf rdf:parseType="daml:collection">
    <rdfs:Class rdf:about="process:Sequence"/>
    <daml:Restriction> 
      <daml:onProperty rdf:resource="process:components"/>
      <daml:toClass>
        <daml:-listOfInstancesOf- rdf:parseType="daml:collection">
          <rdfs:Class rdf:about="#SignIn"/>
          <rdfs:Class rdf:about="#LoadProfile"/>
        </daml:-listOfInstancesOf->
      </daml:toClass>
    </daml:Restriction>
  </daml:intersectionOf>
</rdfs:Class>


<!-- 
CreateProfileSequence is a sequence whose components are a simple process 
CreateAccount followed by a simple process CreateProfile (of course this
can/should be expanded) followed by a simple process LoadProfile 
-->

<rdfs:Class rdf:ID="CreateProfileSequence">           
  <daml:intersectionOf rdf:parseType="daml:collection">
    <rdfs:Class rdf:about="process:Sequence"/>
    <daml:Restriction> 
      <daml:onProperty rdf:resource="process:components"/>
      <daml:toClass>
        <daml:-listOfInstancesOf- rdf:parseType="daml:collection">
          <rdfs:Class rdf:about="#CreateAccount"/>
          <rdfs:Class rdf:about="#CreateProfile"/>
          <rdfs:Class rdf:about="#LoadProfile"/>
        </daml:-listOfInstancesOf->
      </daml:toClass>
    </daml:Restriction>
  </daml:intersectionOf>
</rdfs:Class>


</rdf:RDF>




