http://ruleml.org/1.0/exa/Datalog/own.ruleml
<?xml version="1.0" encoding="UTF-8"?> <?xml-model href="http://www.ruleml.org/1.0/relaxng/datalog_relaxed.rnc"?> <!--<?xml-model href="http://www.ruleml.org/1.0/xsd/datalog.xsd" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema"?>--> <RuleML xmlns="http://ruleml.org/spec" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ruleml.org/spec http://www.ruleml.org/1.0/xsd/datalog.xsd"> <Assert mapClosure="universal"> <!-- start XML comment ... 这个例子的规则库中包含了4个规则. 第一和第二个规则是推断; 第三和第四个规则是事实. 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.
如果这个人从商人手中购买了这个东西,并且最终这个人拥有了这个东西 OrdLab Tree 如下: Implies~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * if * then * * * And~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Atom~~~~~~~~~~~~~~~~~~ | | * | | | | op * | | | | * | | Atom~~~~~~~~~~~~~~~~~~~~~~~~~~~ Atom~~~~~~~~~~~~~~~~~~ Rel Var Var * | | | * | | . . . op * | | | op * | | . . . * | | | * | | . . . Rel Var Var Var Rel Var Var own person object . . . . . . . . . . . . . . . . . . . . . buy person merchant object keep person object ... end XML comment --> <Implies> <if> <!-- 申明 ‘And‘ 联结--> <And> <Atom> <op><Rel>buy</Rel></op> <Var>person</Var> <Var>merchant</Var> <Var>object</Var> </Atom> <Atom> <op><Rel>keep</Rel></op> <Var>person</Var> <Var>object</Var> </Atom> </And> </if> <then> <Atom> <op><Rel>own</Rel></op> <Var>person</Var> <Var>object</Var> </Atom> </then> </Implies> <!-- The second rule implies that a person buys an object from a merchant
第二个规则的推断:一个人从商人手中购买一个东西 if the merchant sells the object to the person.
如果商人将这个东西卖给这个人
--> <Implies> <if> <Atom> <op><Rel>sell</Rel></op> <Var>merchant</Var> <Var>person</Var> <Var>object</Var> </Atom> </if> <then> <Atom> <op><Rel>buy</Rel></op> <Var>person</Var> <Var>merchant</Var> <Var>object</Var> </Atom> </then> </Implies> <!-- The third rule is a fact that asserts that
第三个规则是一个事实:John卖了XMLBible给Mary John sells XMLBible to Mary. --> <Atom> <op><Rel>sell</Rel></op> <Ind>John</Ind> <Ind>Mary</Ind> <Ind>XMLBible</Ind> </Atom> <!-- The fourth rule is a fact that asserts that
第四个规则是一个事实:Mary拥有XMLBible 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).
我们观察到这个事实是二元的:关系有两个参数。
RDF被看作是一种合理的知识表现形式,同样的、二元的,虽然它的参数类型有限制,比如第一个必须是资源
--> <Atom> <op><Rel>keep</Rel></op> <Ind>Mary</Ind> <Ind>XMLBible</Ind> </Atom> </Assert> </RuleML>