<?xml version="1.0" encoding="UTF-8"?>
<rulebase
xmlns="http://www.ruleml.org/0.86/xsd"
xsi:schemaLocation="http://www.ruleml.org/0.86/xsd http://www.ruleml.org/0.86/xsd/datalog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
<Rulebase xmlns="http://www.ruleml.org/0.87/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ruleml.org/0.87/xsd http://www.ruleml.org/0.87/xsd/datalog.xsd">
<!-- start XML comment ...
This example rulebase contains four rules.
The first and second rules are implications; the third and fourth ones are facts.
In English:
The first rule implies that a person owns an object
if that person buys the object from a merchant and the person keeps the object.
As an OrdLab Tree:
imp~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* *
head * body *
* *
atom~~~~~~~~~~~~~~~~~~ and~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* | | | |
opr * | | | |
* | | | |
rel var var atom~~~~~~~~~~~~~~~~~~~~~~~~~~~ atom~~~~~~~~~~~~~~~~~~
. . . * | | | * | |
. . . opr * | | | opr * | |
. . . * | | | * | |
own person object rel var var var rel var var
. . . . . . .
. . . . . . .
. . . . . . .
buy person merchant object keep person object
... end XML comment -->
<impImp>
<_head>
<atomAtom>
<_opr><rel>opr><Rel>own</rel></_Rel></opr>
<var>Var>person</varVar>
<var>Var>object</varVar>
</atomAtom>
</_head>
<_body>
<!-- explicit 'and' -->
<andAnd>
<atomAtom>
<_opr><rel>opr><Rel>buy</rel></_Rel></opr>
<var>Var>person</varVar>
<var>Var>merchant</varVar>
<var>Var>object</varVar>
</atomAtom>
<atomAtom>
<_opr><rel>opr><Rel>keep</rel></_Rel></opr>
<var>Var>person</varVar>
<var>Var>object</varVar>
</atomAtom>
</andAnd>
</_body>
</impImp>
<!-- The second rule implies that a person buys an object from a merchant
if the merchant sells the object to the person. -->
<impImp>
<_head>
<atomAtom>
<_opr><rel>opr><Rel>buy</rel></_Rel></opr>
<var>Var>person</varVar>
<var>Var>merchant</varVar>
<var>Var>object</varVar>
</atomAtom>
</_head>
<_body>
<atomAtom>
<_opr><rel>opr><Rel>sell</rel></_Rel></opr>
<var>Var>merchant</varVar>
<var>Var>person</varVar>
<var>Var>object</varVar>
</atomAtom>
</_body>
</impImp>
<!-- The third rule is a fact that asserts that
John sells XMLBible to Mary. -->
<factFact>
<_head>
<atomAtom>
<_opr><rel>opr><Rel>sell</rel></_Rel></opr>
<ind Ind>John</indInd>
<ind>Ind>Mary</indInd>
<ind>Ind>XMLBible</indInd>
</atomAtom>
</_head>
</factFact>
<!-- The fourth rule is a fact that asserts that
Mary keeps XMLBible.
Observe that this fact is binary - i.e., there are two arguments
for the relation. RDF viewed as a logical knowledge representation
is, likewise, binary, although its arguments have type restrictions,
e.g., the first must be a resource (basically, a URI). Some of the
DTD's on the RuleML website handle URL's/URI's (UR's); see especially
urc-datalog.dtd for inferencing with RDF-like facts -->
<factFact>
<_head>
<atomAtom>
<_opr><rel>opr><Rel>keep</rel></_Rel></opr>
<ind>Ind>Mary</indInd>
<ind>Ind>XMLBible</indInd>
</atomAtom>
</_head>
</factFact>
</rulebase></Rulebase>