Joshua

Thanks for explaining. I clearly misunderstood your output :-). 

This is very helpful. I will explore this idea to get at possible derivations.

Thanks.
~ Niranjan

On Aug 14, 2013, at 9:55 AM, Joshua TAYLOR wrote:

> On Wed, Aug 14, 2013 at 12:12 PM, Niranjan Balasubramanian
> <[email protected]> wrote:
>> Thanks for this example. From your output it seems that rule 1is derives the 
>> statement (:iron, :conducts, :electricity) and rule 2 derives (:iron, 
>> :conductorof, :electricity)
>> 
>> I am more interested in finding out the possible ways in which the query 
>> statement:  (:iron, :conductorOf, :electricity) can be derived.
>> 
>> Given the following rules:
>> 
>> @prefix : http://myexample.org/
>> [rule1: (?a :conductorOf :electricity) <- (?a rdf:type :Metal) print(rule1 
>> ?a )]
>> [rule2: (?x :conductorOf ?z) <- (?x :conducts ?z) print( rule2 ?x ?z )]
>> (:iron rdf:type :Metal) <- .
>> (:iron :conducts :electricity) <- .
>> 
>> I'd expect to see both rule 1 and rule 2 as two possible derivations.
> 
> I think you've misunderstood my code, or its output.  I used the same
> rules that you provided. Both rule1 and rule2 derive triples that have
> :conductorOf as their predicate:
> 
>  "[rule1: (?a :conductorOf :electricity) <- (?a rdf:type :Metal)
> print( rule1 ?a )]\n" +
>  "[rule2: (?x :conductorOf ?z) <- (?x :conducts ?z) print( rule2 ?x ?z )]\n" +
> 
> When these rules fire, they are producing triples of the form
> 
>  ?subject :conductorOf ?object
> 
> Thus, the lines from the output
> 
>  rule1 http://myexample.org/iron
>  rule2 http://myexample.org/iron http://myexample.org/electricity
> 
> indicate that rule1 was fired with ?a bound to :iron, producing the
> triple ":iron :conductorOf :electricity", and that rule2 was fired
> with ?x bound to :iron, and ?z bound to :electricity, producing the
> triple ":iron :conductorOf :electricity".   So it is not the case that
> "rule 1is derives the statement (:iron, :conducts, :electricity) and
> rule 2 derives (:iron, :conductorof, :electricity)".  Instead, the
> output correspond to the two ways that that triple can be derived.
> 
>> As Dave Reynolds pointed out in his reply this seems not doable with Jena as 
>> it stops inference as soon as the answer is found.
> 
> If you ask specifically for the triple "iron conductorOf electricity",
> the rule engine will stop as soon as one derivation is found.
> However, if you ask for all triples (as I did in my example), the
> rules for both derivations will fire (and so we saw output for both
> rule1 and rule2).
> 
> I agree that this method is nor perfect, as you do not get the
> *entire* derivation, but just the final step of it, but it does
> provide *some* way of finding out the different ways in which a triple
> of interest can be derived.
> 
> //JT
> -- 
> Joshua Taylor, http://www.cs.rpi.edu/~tayloj/

Reply via email to