<?xml version="1.0" standalone="no"?>
<!DOCTYPE rulebase SYSTEM "http://www.dfki.de/ruleml/dtd/0.8/ruleml-datalog.dtd">


<!--  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  -->
<!--  The RuleML Discount Example using Datalog                    -->
<!--  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  -->



<rulebase>


<!--  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  -->
<!--  Rule label: discountrule1                                    -->
<!--  The discount for a customer buying a product is 5.0 percent  -->
<!--  if the customer is premium and the product is regular.       -->
<!--  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  -->

<imp>
  <_rlab><ind>discountrule1</ind></_rlab>
  <_head>
    <atom>
      <_opr><rel>discount</rel></_opr>
      <var>customer</var>
      <var>product</var>
      <ind>"5.0 percent"</ind>
    </atom>
  </_head>
  <_body>
    <and>
      <atom>
        <_opr><rel>premium</rel></_opr>
        <var>customer</var>
      </atom>
      <atom>
        <_opr><rel>regular</rel></_opr>
        <var>product</var>
      </atom>
    </and>
  </_body>
</imp>

<!--  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  -->
<!--  Rule label: statusrule1                                      -->
<!--  A customer is premium if                                     -->
<!--  their spending has been high in the previous year.           -->
<!--  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  -->

<imp>
  <_rlab><ind>statusrule1</ind></_rlab>
  <_head>
    <atom>
      <_opr><rel>premium</rel></_opr>
      <var>customer</var>
    </atom>
  </_head>
  <_body>
    <atom>
      <_opr><rel>spending</rel></_opr>
      <var>customer</var>
      <ind>"high"</ind>
      <ind>"previous year"</ind>
    </atom>
  </_body>
</imp>

<!--  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  -->
<!--  FACT 1: A Honda is regular.                                  -->
<!--  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  -->

<fact>
 <_head>
  <atom>
    <_opr><rel>regular</rel></_opr>
    <ind>"Honda"</ind>
  </atom>
 </_head>
</fact>

<!--  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  -->
<!--  FACT 2: Peter Miller's spending has been high                -->
<!--          in the previous year.                                -->
<!--  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  -->

<fact>
 <_head>
  <atom>
    <_opr><rel>spending</rel></_opr>
    <ind>"Peter Miller"</ind>
    <ind>"high"</ind>
    <ind>"previous year"</ind>
  </atom>
 </_head>
</fact>

</rulebase>
