<?xml version="1.0" encoding="UTF-8"?>

<Assert
xmlns="http://www.ruleml.org/0.89/xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ruleml.org/0.89/xsd
http://www.ruleml.org/0.89/xsd/hornlogeq.xsd">

<!--
The function symbol "owner" could be user-defined by a rule
or 'directed Equaluation' owner(car17) = john. Now, the first premise of
the 'functional Datalog' rule
buy(Person,Object) <- pay(Person,owner(Object)) and take(Person,Object)
is an "owner" function call nested into a "pay" relation call. With
additional facts pay(fred,john) and take(fred,car17) also asserted,
the "buy" relation call buy(fred,car17) would be computed thus:

buy(fred,car17)
pay(fred,owner(car17)) and take(fred,car17)
pay(fred,john)         and true
true                   and true
true

So, owner(car17) _computes_ the actual owner individual, rather than
just _denoting_ it, as a cterm with a constructor symbol "owner"
would. For this corresponding cterm in the first premise, we would
have used square brackets like pay(Person,owner[car17]), but then one
asserted fact would have to be the non-Datalog pay(fred,owner[car17]).
Now, the above 'functional Datalog' rule can be flattened, obtaining

buy(Person,Object) <- Own = owner(Object) and pay(Person,Own)
                      and take(Person,Object)

This flattened version, along with the directed Equaluation and facts, can
be marked up in the current RuleML as follows:
-->

<And mapClosure="universal">

    <Equal>
      <Nano>
        <opf><Fun>owner</Fun></opf>
        <Ind>car17</Ind>
      </Nano>
      <Ind>john</Ind>
    </Equal>

<Implies>
 <head>
  <Atom>
    <opr><Rel>buy</Rel></opr>
    <Var>person</Var>
    <Var>object</Var>
  </Atom>
 </head>
 <body>
  <And>
    <Equal>
      <Var>own</Var>
      <Nano>
        <opf><Fun>owner</Fun></opf>
        <Var>object</Var>
      </Nano>
    </Equal>
    <Atom>
      <opr><Rel>pay</Rel></opr>
      <Var>person</Var>
      <Var>own</Var>
    </Atom>
    <Atom>
      <opr><Rel>take</Rel></opr>
      <Var>person</Var>
      <Var>object</Var>
    </Atom>
  </And>
 </body>
</Implies>


  <Atom>
    <opr><Rel>pay</Rel></opr>
    <Ind>fred</Ind>
    <Ind>john</Ind>
  </Atom>

  <Atom>
    <opr><Rel>take</Rel></opr>
    <Ind>fred</Ind>
    <Ind>car17</Ind>
  </Atom>

</And>

</Assert>
