0

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?

7
  • And I would also like to know if its possible to create new instances (also called individuals in Protégé) via custom rules in .pie files. I have only seen corollaries (what's below the ---- line of a rule) being used to establish new links between existing things. Commented Nov 13, 2018 at 11:35
  • I understand Constraint, but what is [Cut] and [Context] mean next to an Axiom (what's above the ---- line of a rule)? I can't seem to google that... Commented Nov 13, 2018 at 11:37
  • Context is just used to restrict the result of one rule to others is input if the share the same context. Commented Nov 13, 2018 at 13:54
  • The syntax you used is clearly wrong. And given that something like BIND isn't possible, I don't think its currently possible. Or at least, it's not mentioned in the docs, you could try whether it works nevertheless. Commented Nov 13, 2018 at 13:56
  • The only solution I see right now is to use a SPARQL Update query. Clearly, it's unclear how to combine this with the rule inference given that a fix-point iteration is usually done, thus, a single SPARQL query might lead to an incomplete result (very likely in my opinion, but depends on the rest of the data). Running it after the OWL RL materialization, then re-run the OWL RL materialization and compare the number triples in the triple store - that would be my way. Commented Nov 13, 2018 at 13:59

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I see, thanks @vassil_momtchev. Do you think there might be a chance to understand these internal ID mappings? Then I could try to use those to trigger something if one value is "1"^^xsd:double and the other one is the negative version of it "-1"^^xsd:double by comparing their internal IDs instead of actually applying arithmetics.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.