Hi Joshua,
Yes, you are right I made a mistake with the grammar. The rule is on the
body, not in the head, sorry.
“...body? I also don't see what the problem would be with your r5:
[r5: (?x exa:sportPartner ?y),
(?x rdf:type exa:SeaMan),
(?y rdf:type exa:SeaMan) ->
(?x exa:seaPartner3 ?y)]
“
The problem is that doesn´t work, because the rule is in the body of the
forward rule. My problem is: I want to associate a certainty factor to a
conclusion. So, my approach was to create a blank node with the triple
plus the certainty factor:
(r1 is a rule)
(?f r1 ?e),
(?f p1 ?p),
(?e p2 ?p),
makeTemp(?bn) ->
(?bn rdf:subject ?f),
(?bn rdf:predicate p3),
(?bn rdf:object ?e),
(?bn exa:certainty "0.9"^^xsd:decimal).
This rule doesn’t work because I have a rule in the body. However, if I
materialize r1 then everything is ok.
I also tried with a functor, like:
(?bn p3 t(?f, ?e, "0.9"^^xsd:decimal)) <-
(?f r1 ?e),
(?f p1 ?p),
(?e p2 ?p),
makeTemp(?bn).
But I can’t get the values outside the rules, with the Sparql for
instance.
Miguel
On 14/03/14 01:21, "Joshua TAYLOR" <[email protected]> wrote:
>On Thu, Mar 13, 2014 at 3:05 PM, Miguel Bento Alves
><[email protected]> wrote:
>> I¹m doing some tests with jena reasoner and I concluded, that I cannot
>>have
>> a rule in the head of a forward rule. In a forward rule I only can have
>> assert data, not deducted data.
>>
>> I¹m right? Why the reason?
>
>
>You most certainly can have rules in the heads of forward rules.
>E.g., from Jena's RDFS forward backward reasoner, there's this rule:
>
> [rdfs2: (?p rdfs:domain ?c) -> [(?x rdf:type ?c) <- (?x ?p ?y)] ]
>
>You mention a situation like
>
> c1, c2 -> c3, c4 - where c1 is a rule.
>
>First, that would be a rule in the body, not in the head, since the
>grammar [1] is
>
>bare-rule
> := term, ... term -> hterm, ... hterm // forward rule
> or bhterm <- term, ... term // backward rule
>
>and hterm means "head term". So you're actually asking about whether a
>rule can appear as a body in a forward chaining rule. According to
>the grammar, it cannot, since the production for term is
>
>term
> := (node, node, node) // triple pattern
> or (node, node, functor) // extended triple pattern
> or builtin(node, ... node) // invoke procedural primitive
>
>Can you give an example of what such a thing would be useful for? It
>doesn't make much sense to me to have a rule as a precondition in a
>rule. What would it mean to use a rule as a precondition? None of
>your examples show a rule used a as a precondition or a post condition
>in a rule. Can you give an example where you'd want a rule in the
>body? I also don't see what the problem would be with your r5:
>
> [r5: (?x exa:sportPartner ?y),
> (?x rdf:type exa:SeaMan),
> (?y rdf:type exa:SeaMan) ->
> (?x exa:seaPartner3 ?y)]
>
>If ?x has a ?y as a sportPartner, and both and ?x and ?y are instances
>of SeaMan, then ?x has ?y as a seaPartner3. What's the matter with
>that?
>
>//JT
>
>[1] http://jena.apache.org/documentation/inference/#RULEsyntax
>--
>Joshua Taylor, http://www.cs.rpi.edu/~tayloj/