0

What happens if we put a variable in the head of a GenericRuleReasoner, which does not appear in the body of the rule?

For instance if we have the following rule :

rule1: (?x rdf:type :Person) -> (?y :father ?x)

The rule says that every person has a father. Suppose we have a triple :a rdf:type :Person How does the reasoner behaves here? Will it create a new triple with blank node like _x :father :a ?

Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58
riad
  • 361
  • 1
  • 9
  • 19
  • "The rule says that every person has a father. " Why do you say that? Whether it says that depends on what Jena does with that rule. If you want "a new triple with blank node like _x :father :a", then you just need to write `(?x rdf:type :Person), makeTemp(?y) -> (?y :father ?x)`. It's all described in the documentation. – Joshua Taylor Sep 23 '14 at 02:40

1 Answers1

1

I think it will complain about that. It is, after all, ambiguous: do you mean 'there is a ?y such that...' or 'for any ?y ....'?

From what you say it's clear that you expect former, the existential version, because that's what introducing a bNode does. So try:

rule1: makeTemp(?y), (?x rdf:type ex:Person)  -> (?y ex:fatherOf ?x)

or

rule1: makeInstance(?y, ex:father, ?x), (?x rdf:type ex:Person) -> (?y ex:fatherOf ?x)

the latter of which will give you a consistent father node, whereas the former simply introduces a bNode.

user205512
  • 8,798
  • 29
  • 28