From: Ian Horrocks ([email protected])
Date: 01/27/04
Mike, The examples look good. Some comments on your comments in-line below... On January 6, Mike Dean writes: > Here are updates to my previous examples from [1] based on our 16 > December telecon: > > <!-- free shipping on orders over $50 --> > <ruleml:imp> > <ruleml:_body> > <swrlx:classAtom> > <owlx:Class owlx:name="Order"/> > <ruleml:var>order</ruleml:var> > </swrlx:classAtom> > <swrlx:datavaluedPropertyAtom swrlx:property="cost"> > <ruleml:var>order</ruleml:var> > <ruleml:var>cost</ruleml:var> > </swrlx:datavaluedPropertyAtom> > <swrlx:operationAtom swrlx:op="&op;numeric-greater-than"> > <ruleml:var>cost</ruleml:var> > <owlx:DataValue owlx:datatype="&xsd;integer">50</owlx:DataValue> > </swrlx:comparisonAtom> > </ruleml:_body> > <ruleml:_head> > <swrlx:datavaluedPropertyAtom swrlx:property="shipping"> > <ruleml:var>order</ruleml:var> > <owlx:DataValue owlx:datatype="&xsd;integer">0</owlx:DataValue> > </swrlx:datavaluedPropertyAtom> > </ruleml:_head> > </ruleml:imp> > > <!-- convert temperature from Fahrenheit to Celsius --> > <ruleml:imp> > <ruleml:_body> > <swrlx:datavaluedPropertyAtom swrlx:property="fahrenheitTemp"> > <ruleml:var>x</ruleml:var> > <ruleml:var>f</ruleml:var> > </swrlx:datavaluedPropertyAtom> > <swrlx:operationAtom swrlx:op="&op;numeric-subtract"> > <ruleml:var>i1</ruleml:var> > <ruleml:var>f</ruleml:var> > <owlx:DataValue owlx:datatype="&xsd;integer">32</owlx:DataValue> > </swrlx:operationAtom> > <swrlx:operationAtom swrlx:op="&op;numeric-multiply"> > <ruleml:var>i2</ruleml:var> > <ruleml:var>i1/ruleml:var> > <owlx:DataValue owlx:datatype="&xsd;integer">5</owlx:DataValue> > </swrlx:operationAtom> > <swrlx:operationAtom swrlx:op="&op;numeric-integer-divide"> > <ruleml:var>c</ruleml:var> > <ruleml:var>i2/ruleml:var> > <owlx:DataValue owlx:datatype="&xsd;integer">9</owlx:DataValue> > </swrlx:operationAtom> > </ruleml:_body> > <ruleml:_head> > <swrlx:datavaluedPropertyAtom swrlx:property="celsiusTemp"> > <ruleml:var>x</ruleml:var> > <ruleml:var>c</ruleml:var> > </swrlx:datavaluedPropertyAtom> > </ruleml:_head> > </ruleml:imp> > > This assumes that the binding pattern for each "operator" will be > defined in our documentation - implementations may also allow > user-defined operators. By convention, the arithmetic operators use > the first binding for the result of the calculation. I would still hesitate to describe this as the result of the calculation, although I am not able to suggest any better words at present. > Each operator > will also return true or false to indicate the success or failure of > the swrlx:operationAtom (false might be used in the arithmetic > operators to report overflow, divide by zero, etc.). Like other SWRL atoms, swrlx:operationAtom doesn't "return" anything - it is satisfied by a binding iff the resulting interpretation of the variables make the predicate true. E.g., in the case of the numeric-subtract atom in the Fahrenheit to Celsius example, the atom is satisfied by a binding B just in case B(i1) = B(f) - 32. Implementation issues such as overflow errors etc would need to be handled in the same way as any other implementation fault such as a memory fault due to excessively large/complex ontologies. > Since swrlx:operationAtom can return false, it should only appear > within ruleml:_body. Such a restriction isn't necessary if you think about the operation atoms in the way I suggest above. The rule is satisfied by an interpretation just in case the head atom is satisfied by every binding that satisfies all of the body atoms. This would, e.g, allow the Fahrenheit to Celsius example to be restated as: <ruleml:imp> <ruleml:_body> <swrlx:datavaluedPropertyAtom swrlx:property="fahrenheitTemp"> <ruleml:var>x</ruleml:var> <ruleml:var>f</ruleml:var> </swrlx:datavaluedPropertyAtom> <swrlx:datavaluedPropertyAtom swrlx:property="celsiusTemp"> <ruleml:var>x</ruleml:var> <ruleml:var>c</ruleml:var> </swrlx:datavaluedPropertyAtom> <swrlx:operationAtom swrlx:op="&op;numeric-subtract"> <ruleml:var>i1</ruleml:var> <ruleml:var>f</ruleml:var> <owlx:DataValue owlx:datatype="&xsd;integer">32</owlx:DataValue> </swrlx:operationAtom> <swrlx:operationAtom swrlx:op="&op;numeric-multiply"> <ruleml:var>i2</ruleml:var> <ruleml:var>i1/ruleml:var> <owlx:DataValue owlx:datatype="&xsd;integer">5</owlx:DataValue> </swrlx:operationAtom> </ruleml:_body> <ruleml:_head> <swrlx:operationAtom swrlx:op="&op;numeric-integer-divide"> <ruleml:var>c</ruleml:var> <ruleml:var>i2/ruleml:var> <owlx:DataValue owlx:datatype="&xsd;integer">9</owlx:DataValue> </swrlx:operationAtom> </ruleml:_head> </ruleml:imp> This means that if there is a binding B such that B(f) and B(c) are the fahrenheitTemp and celsiusTemp of B(x), B(i1) = B(f)-32 and B(i2) = i1*5, then it must also be true that B(c) = B(i2)/9. The whole thing might be easier to understand if we used rules to define a new binary predicated called, say, f2c which was true iff the relevant conversion ratio holds between the two arguments. E.g.: <ruleml:imp> <ruleml:_body> <swrlx:operationAtom swrlx:op="&op;numeric-subtract"> <ruleml:var>i1</ruleml:var> <ruleml:var>f</ruleml:var> <owlx:DataValue owlx:datatype="&xsd;integer">32</owlx:DataValue> </swrlx:operationAtom> <swrlx:operationAtom swrlx:op="&op;numeric-multiply"> <ruleml:var>i2</ruleml:var> <ruleml:var>i1/ruleml:var> <owlx:DataValue owlx:datatype="&xsd;integer">5</owlx:DataValue> </swrlx:operationAtom> <swrlx:operationAtom swrlx:op="&op;numeric-integer-divide"> <ruleml:var>c</ruleml:var> <ruleml:var>i2/ruleml:var> <owlx:DataValue owlx:datatype="&xsd;integer">9</owlx:DataValue> </swrlx:operationAtom> </ruleml:_body> <ruleml:_head> <swrlx:operationAtom swrlx:op="f2c"> <ruleml:var>f</ruleml:var> <ruleml:var>c</ruleml:var> </swrlx:operationAtom> </ruleml:_head> </ruleml:imp> <ruleml:imp> <ruleml:_body> <swrlx:operationAtom swrlx:op="f2c"> <ruleml:var>f</ruleml:var> <ruleml:var>c</ruleml:var> </swrlx:operationAtom> <swrlx:operationAtom swrlx:op="&op;numeric-subtract"> <ruleml:var>i1</ruleml:var> <ruleml:var>f</ruleml:var> <owlx:DataValue owlx:datatype="&xsd;integer">32</owlx:DataValue> </swrlx:operationAtom> <swrlx:operationAtom swrlx:op="&op;numeric-multiply"> <ruleml:var>i2</ruleml:var> <ruleml:var>i1/ruleml:var> <owlx:DataValue owlx:datatype="&xsd;integer">5</owlx:DataValue> </swrlx:operationAtom> </ruleml:_body> <ruleml:_head> <swrlx:operationAtom swrlx:op="&op;numeric-integer-divide"> <ruleml:var>c</ruleml:var> <ruleml:var>i2/ruleml:var> <owlx:DataValue owlx:datatype="&xsd;integer">9</owlx:DataValue> </swrlx:operationAtom> </ruleml:_head> </ruleml:imp> Then we could write the conversion rule as: <ruleml:imp> <ruleml:_body> <swrlx:datavaluedPropertyAtom swrlx:property="fahrenheitTemp"> <ruleml:var>x</ruleml:var> <ruleml:var>f</ruleml:var> </swrlx:datavaluedPropertyAtom> <swrlx:datavaluedPropertyAtom swrlx:property="celsiusTemp"> <ruleml:var>x</ruleml:var> <ruleml:var>c</ruleml:var> </swrlx:datavaluedPropertyAtom> </ruleml:_body> <ruleml:_head> <swrlx:operationAtom swrlx:op="f2c"> <ruleml:var>f</ruleml:var> <ruleml:var>c/ruleml:var> </swrlx:operationAtom> </ruleml:_head> </ruleml:imp> This may not make much sense in this context (where f2c may have no other application), but the ability to "define" new predicates in this way might be very useful in general. Regards, Ian > > Corresponding executable examples in N3 are now available at [2] and [3]. > > Mike > > [1] http://www.daml.org/listarchive/joint-committee/1580.html > > [2] http://www.daml.org/2003/06/ruletests/comparison-1.n3 > > [3] http://www.daml.org/2003/06/ruletests/translation-4.n3 >
This archive was generated by hypermail 2.1.4 : 01/27/04 EST