<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE Document [
  <!ENTITY ppl  "http://example.com/people#">
  <!ENTITY cpt  "http://example.com/concepts#">
  <!ENTITY dc   "http://purl.org/dc/terms/">
  <!ENTITY rif  "http://www.w3.org/2007/rif#">
  <!ENTITY func "http://www.w3.org/2007/rif-builtin-function#">
  <!ENTITY pred "http://www.w3.org/2007/rif-builtin-predicate#">
  <!ENTITY xs   "http://www.w3.org/2001/XMLSchema#">
]>

<Document
    xmlns="http://www.w3.org/2007/rif#"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <payload>
     <Group>
      <!-- <sentence> -->
      <!-- <Group> -->
       <!-- <id><Const type="xsd:string">purchaseRule</Const></id> -->
       <sentence>
       <Forall>
        <id><Const type="xsd:string">purchaseRule</Const></id>
        <declare><Var>customer</Var></declare>
        <declare><Var>purchaseYTD</Var></declare>
        <formula>
         <Implies>
          <if>
           <And>
            <formula>
             <Member>
              <instance><Var>customer</Var></instance>
              <class><Const type="rif:iri">http://example.com/2008/joe#customer.Customer</Const></class>
             </Member>
            </formula>
            <formula>
              <Frame>
               <object><Var>customer</Var></object>
               <slot ordered="yes"> 
                <Const type="rif:iri">purchaseYTD</Const>
                <Var>purchaseYTD</Var>
               </slot>
              </Frame>
             </formula> 
             <formula>
              <External>
               <content>
                <Atom>
                 <op><Const type="rif:iri">&pred;numeric-greater-than</Const></op>
                 <args ordered="yes">
                  <Var>purchaseYTD</Var>
                  <Const type="xsd:decimal">5000</Const>
                 </args>
                </Atom>
               </content>
              </External>
             </formula> 
            </And>
           </if>
           <then>
            <Do>
             <actions ordered="yes">
              <Modify>
               <target>
                <Frame>
                 <object>
                  <Var>customer</Var>
                 </object>
                 <slot ordered="yes">
                  <Const type="rif:iri">status</Const>
                  <Const type="xsd:string">Gold</Const>
                 </slot>
                </Frame>
               </target>
              </Modify>
             </actions>
            </Do>
           </then>
          </Implies>
         </formula>
        </Forall>
       <!-- </sentence> -->
       <!-- </Group> -->
       </sentence>
       
       
       
       
       <!-- <sentence> -->
        <!-- <Group> -->
         <!-- <id><Const type="xsd:string">DisplayStatus</Const></id> -->
         <sentence>
          <Forall>
           <id><Const type="xsd:string">DisplayStatus</Const></id>
       	   <declare><Var>customer</Var></declare>
       	    <declare><Var>name</Var></declare>
           <formula>
            <Implies>
             <if>
              <And>
               <formula>
                <Member>
                 <instance><Var>customer</Var></instance>
                 <class><Const type="rif:iri">http://example.com/2009/prd#customer.Customer</Const></class>
                </Member>
               </formula>
              <formula> 
               <Exists>
                <declare><Var>purchaseYTD</Var></declare>
                <declare><Var>s</Var></declare>
                <formula>
                 <And>
                  <formula>
                   <Frame>
                    <object><Var>customer</Var></object>
                    <slot ordered="yes"> 
                     <Const type="rif:iri">name</Const>
                     <Var>name</Var>
                    </slot>
                   </Frame>
                  </formula>
                 
                  <formula>
                   <Frame>
                    <object><Var>customer</Var></object>
                    <slot ordered="yes"> 
                     <Const type="rif:iri">status</Const>
                     <Var>s</Var>
                    </slot>
                   </Frame>
                  </formula>
                  <formula>
                   <External>
                    <content>
                     <Atom>
                      <op><Const type="rif:iri">&pred;numeric-equal</Const></op>
                      <args>
                       <Var>s</Var>
                       <Const type="xsd:string">Gold</Const>
                      </args>
                     </Atom>
                    </content>
                   </External>
                  </formula>        
                 </And>
                </formula>    
               </Exists>  
       	      </formula>   
             </And>
            </if>
            <then>
            <Do>
              <actions ordered="yes">
               <Execute>
  			    <target>
                 <Atom>
                  <op>
                   <Const type="rif:iri">http://www.w3.org/2007/rif-builtin-action#print</Const>
                  </op>
                  <args ordered="yes">
                   <External>
                    <content>
                     <Expr>
                      <op>
                       <Const type="rif:iri"> http://www.w3.org/2007/rif-builtin-function#concat</Const>
                      </op>
                      <args ordered="yes">
                       <!-- <Const type="xsd:string">status</Const> -->
                       <!-- <Const type="xsd:string"> of </Const>   -->
                       <Var>name</Var>
                       <Const type="xsd:string"> has Gold status </Const> 
                       <!-- <Var>s</Var> -->
                      </args>
                     </Expr>
                    </content>
                   </External>
                  </args>
                 </Atom>
                </target>
               </Execute>
              </actions>
             </Do>
            </then>
           </Implies>
          </formula>
         </Forall>
        </sentence>
       <!-- </Group> --> 
      <!-- </sentence> -->
     </Group>
    </payload>
 </Document>                