On 28/01/15 14:06, Christophe FAGOT [intactile DESIGN] wrote:
Hi Andy,

thanks for your answer, and I’m ok for the graph being a set of triples, it is 
the (very good) reason explaining why only one triple is produced. But the 
reasoner is not in forward model. It is a forward-RETE model, which means that 
the forward rules have to work incrementally, allowing to add and remove 
triples and maintaining the consistency of the model.

So in the case described by Sébastien, the forward-RETE model should not remove 
the inferred triple since another rule has its body terms still validated. At 
least, this last rule should have been fired in order to indicate it that the 
triple which was not created previously (because it was still in the graph) is 
going to be removed, so this last rule should produce it again.

The RETE engine stops once a triple has been deduced by one route. If you attempt to track each possible route by which a triple could be deduced and reference count them all then you will get a combinatoric explosion in numbers of possible deduction paths and performance plummets (which is why naive truth maintenance never worked out).

The Jena engine works around this by not attempting to handle removals incrementally at all. A remove is supposed to mark the model as needing a new "prepare" stage and the entire deduction process is run from scratch again the next time you query the model.

That certainly used to work and I can't see why Sébastien's case would fail, though I don't see the code by which the results are getting accessed. I'm not in a position to test it from here.

Dave

Chris.

Christophe FAGOT, PhD
RESPONSABLE R&D INFORMATIQUE

intactile DESIGN
Création d’interfaces + subtiles
+33 (0)4 67 52 88 61
+33 (0)9 50 12 05 66
20 rue du carré du roi
34000 MONTPELLIER
France
www.intactile.com <http://intactile.com/>

Hugh MacLeod : "It's not what the software does, it's what the user does"

Les informations contenues dans cet email et ses documents attachés sont 
confidentielles. Elles sont exclusivement adressées aux destinataires 
explicitement désignés ci-dessus et ne peuvent être divulguées sans 
consentement de son auteur. Si vous n'êtes pas le destinataire de cet email 
vous ne devez pas employer, révéler, distribuer, copier, imprimer ou 
transmettre le contenu de cet email et devez le détruire immédiatement.

Le 28 janv. 2015 à 12:17, Andy Seaborne <[email protected]> a écrit :

(Dave is not around at the moment so I'll try to answer some parts of your 
question ...)

On 28/01/15 10:28, "Sébastien Boulet [intactile DESIGN]" wrote:
Hello,

I have two rules which could produce the same triple:

         String rules = "[r1: (?a eg:p ?b) -> (?a, eg:q, ?b)]" +
                        "[r2: (?a eg:r ?b) -> (?a, eg:q, ?b)]";

i have configured a GenericRuleReasoner in FORWARD_RETE mode.

         GenericRuleReasoner reasoner = new 
GenericRuleReasoner(Rule.parseRules(rules));
         reasoner.setMode(GenericRuleReasoner.FORWARD_RETE);
         InfModel model = ModelFactory.createInfModel(reasoner, 
ModelFactory.createDefaultModel());

When a triple satisfy the first rule and another triple satisfy the second rule:

                 Resource subject = model.createResource();
         Property predicateP = model.getProperty("urn:x-hp:eg/p");
         Literal literalA = model.createTypedLiteral("A");
         Property predicateR = model.getProperty("urn:x-hp:eg/r");

         model.add(subject, predicateP, literalA);
        model.add(subject, predicateR, literalA);

only one triple is deduced:

An RDF graph is a set of triples.

A set only has one of each thing in it.

If you
add(triple)
add(triple)

you will see only one triple in the output.  This is not to do with inference, 
it is to do with an RDF graph being a set.


<rdf:RDF
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
     xmlns:j.0="urn:x-hp:eg/" >
   <rdf:Description rdf:nodeID="A0">
     <j.0:r rdf:datatype="http://www.w3.org/2001/XMLSchema#string";>A</j.0:r>
     <j.0:p rdf:datatype="http://www.w3.org/2001/XMLSchema#string";>A</j.0:p>
     <j.0:q rdf:datatype="http://www.w3.org/2001/XMLSchema#string";>A</j.0:q>
   </rdf:Description>
</rdf:RDF>

When i remove the fist triple:

         model.remove(subject, predicateP, literalA);

  the sole deduced triple is removed even if the second rule is still satisfied:

You ran the reasoner in forward model - it included all deductions at the start 
and then does not run again until you ask it to.

To trigger it again:

InfModel.rebind()
"Cause the inference model to reconsult the underlying data to take into account 
changes."

or run in backward mode.

        Andy


<rdf:RDF
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
     xmlns:j.0="urn:x-hp:eg/" >
   <rdf:Description rdf:nodeID="A0">
     <j.0:r rdf:datatype="http://www.w3.org/2001/XMLSchema#string";>A</j.0:r>
   </rdf:Description>
</rdf:RDF>

is it the expected behavior ?
is there a workaround to deduce twice the same triple or at least to don’t 
remove the sole deduction ?

Thanks


Sébastien BOULET
LEAD DÉVELOPPEUR

intactile DESIGN
Création d’interfaces + subtiles
04 67 52 88 61
09 50 12 05 66
20 rue du carré du roi
34000 MONTPELLIER
France
www.intactile.com <http://intactile.com/>

Les informations contenues dans cet email et ses documents attachés sont 
confidentielles. Elles sont exclusivement adressées aux destinataires 
explicitement désignés ci-dessus et ne peuvent être divulguées sans 
consentement de son auteur. Si vous n'êtes pas le destinataire de cet email 
vous ne devez pas employer, révéler, distribuer, copier, imprimer ou 
transmettre le contenu de cet email et devez le détruire immédiatement.



Reply via email to