I want to add a custom rule to the OWL-2-RL ruleset (builtin_owl2-rl.pie) that establishes a isOppositeDirectionOf
object property between vectors that are in opposite direction to each other. I would think it should look something like this:
Id: oppositeDirectionVector_rule
v1 <rdf:type> <cad:Vector>
v1 <cad:x> v1x // example data property for v1x: "1.0"^^xsd:double
v1 <cad:y> v1y
v1 <cad:z> v1z
v2 <rdf:type> <cad:Vector>
v2 <cad:x> -v1x
v2 <cad:y> -v1y
v2 <cad:z> -v1z
-------------------------------
v1 <cad:isOppositeDirectionOf> v2
Without the minuses, this rule does work to create isSameVectorAs
object properties.
Is there a way I can use basic arithmetic functions on data properties in rules?
You cannot use basic arithmetic functions in the rules. Due performance reasons the GraphDB rule engine works with the internal database identifiers, but not the actual RDF values i.e. internal id 10001
instead of "1"^^xsd:double
. Thus, the only supported variable comparison operations are if the two internal identifiers are equal or not equal.
Edit following the comment below: GraphDB's Plugin API is the only mechanism to integrate your code with the database. A plugin can materialize for every statement with ?s <cad:x> ?o
predicate a new statement ?s <cad:oppositeX> -?o
. Unfortunately, it should handle also the deletes.