You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Steve Vestal <st...@adventiumlabs.com> on 2017/09/24 14:35:08 UTC

Inferred transitive properties not appearing in deductions model

I have a few questions about reasoning in Jena.  Thanks in advance for
any answers or suggestions.

As background, here is a simple test case to infer transitive
relations between individuals.  Protege/Pellet will load this model
and infer that A transProp C.

<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.test.com/test#"
     xml:base="http://www.test.com/test"
     xmlns:t="http://www.test.com/test#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
    <owl:Ontology rdf:about="http://www.test.com/test"/>
    <owl:ObjectProperty rdf:about="http://www.test.com/test#simpleProp">
        <rdfs:subPropertyOf
rdf:resource="http://www.test.com/test#transProp"/>
    </owl:ObjectProperty>
    <owl:ObjectProperty rdf:about="http://www.test.com/test#transProp">
        <rdf:type
rdf:resource="http://www.w3.org/2002/07/owl#TransitiveProperty"/>
    </owl:ObjectProperty>
    <owl:NamedIndividual rdf:about="http://www.test.com/test#A">
        <simpleProp rdf:resource="http://www.test.com/test#B"/>
    </owl:NamedIndividual>
    <owl:NamedIndividual rdf:about="http://www.test.com/test#B">
        <simpleProp rdf:resource="http://www.test.com/test#C"/>
    </owl:NamedIndividual>
    <owl:NamedIndividual rdf:about="http://www.test.com/test#C"/>
</rdf:RDF>

Here is a fragment of the code I'm using with Jena 3.1.0.

// Preceded by code to set up mySystemInput to read the above.
OntModel mySystem = ModelFactory.createOntologyModel(
OntModelSpec.OWL_MEM_RULE_INF );
mySystem.read(mySystemInput, null);
Model deductionsModel = mySystem.getDeductionsModel();
StmtIterator deducedStatements = deductionsModel.listStatements();
// Followed by code to dump all the statements.
               
The deductionsModel I get does not include the transProp sentences that
are inferred by Protege/Pellet.

Question: The online page on reasoning suggests that the OWL reasoners
that come with Jena might not do all the inferencing that is expected
by the OWL standard.  On the other hand, an exchange on users@jena a
few years ago suggested that inferring transitive properties
would/should be done.  Is the above reasoner expected to make the
inference that Protege/Pellet makes?

Question: I also tried using the OWL_MEM_TRANS_INF reasonser.  In that case,
getDeductionsModel returns null.  Is that expected?  TODO functionality?
Is there a work-around?

Question: Should my next step be to integrate Pellet and use that as
the reasoner?


Re: Inferred transitive properties not appearing in deductions model

Posted by Dave Reynolds <da...@gmail.com>.
On 24/09/17 18:59, Dave Reynolds wrote:

> [1] It's actually more complex (and less clean) than that. The 
> subClassOf and subPropertyOf closures are computed by a dedicated 
> transitive engine which can compute the transitive reduction as well as 
> the closure.
> 
> There's also some hacky code hooks in the OWL rules which adds some 
> extra forward rules 
         ^^^^^^^
         backward

which are too hard to compute within the limitations
> of the forward rule engine.

Dave

> On 24/09/17 17:21, Steve Vestal wrote:
>> This appears to have been a misunderstanding of what the deductions
>> model contains.  A dump of the full model includes the expected inferred
>> transitive relations.
>>
>> What does the deductions model contain, relative to the input ontology
>> and the inferred sentences?
>>
>>
>> On 9/24/2017 9:35 AM, Steve Vestal wrote:
>>> I have a few questions about reasoning in Jena.  Thanks in advance for
>>> any answers or suggestions.
>>>
>>> As background, here is a simple test case to infer transitive
>>> relations between individuals.  Protege/Pellet will load this model
>>> and infer that A transProp C.
>>>
>>> <?xml version="1.0"?>
>>> <rdf:RDF xmlns="http://www.test.com/test#"
>>>       xml:base="http://www.test.com/test"
>>>       xmlns:t="http://www.test.com/test#"
>>>       xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>>>       xmlns:owl="http://www.w3.org/2002/07/owl#"
>>>       xmlns:xml="http://www.w3.org/XML/1998/namespace"
>>>       xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
>>>       xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
>>>      <owl:Ontology rdf:about="http://www.test.com/test"/>
>>>      <owl:ObjectProperty 
>>> rdf:about="http://www.test.com/test#simpleProp">
>>>          <rdfs:subPropertyOf
>>> rdf:resource="http://www.test.com/test#transProp"/>
>>>      </owl:ObjectProperty>
>>>      <owl:ObjectProperty rdf:about="http://www.test.com/test#transProp">
>>>          <rdf:type
>>> rdf:resource="http://www.w3.org/2002/07/owl#TransitiveProperty"/>
>>>      </owl:ObjectProperty>
>>>      <owl:NamedIndividual rdf:about="http://www.test.com/test#A">
>>>          <simpleProp rdf:resource="http://www.test.com/test#B"/>
>>>      </owl:NamedIndividual>
>>>      <owl:NamedIndividual rdf:about="http://www.test.com/test#B">
>>>          <simpleProp rdf:resource="http://www.test.com/test#C"/>
>>>      </owl:NamedIndividual>
>>>      <owl:NamedIndividual rdf:about="http://www.test.com/test#C"/>
>>> </rdf:RDF>
>>>
>>> Here is a fragment of the code I'm using with Jena 3.1.0.
>>>
>>> // Preceded by code to set up mySystemInput to read the above.
>>> OntModel mySystem = ModelFactory.createOntologyModel(
>>> OntModelSpec.OWL_MEM_RULE_INF );
>>> mySystem.read(mySystemInput, null);
>>> Model deductionsModel = mySystem.getDeductionsModel();
>>> StmtIterator deducedStatements = deductionsModel.listStatements();
>>> // Followed by code to dump all the statements.
>>> The deductionsModel I get does not include the transProp sentences that
>>> are inferred by Protege/Pellet.
>>>
>>> Question: The online page on reasoning suggests that the OWL reasoners
>>> that come with Jena might not do all the inferencing that is expected
>>> by the OWL standard.  On the other hand, an exchange on users@jena a
>>> few years ago suggested that inferring transitive properties
>>> would/should be done.  Is the above reasoner expected to make the
>>> inference that Protege/Pellet makes?
>>>
>>> Question: I also tried using the OWL_MEM_TRANS_INF reasonser.  In 
>>> that case,
>>> getDeductionsModel returns null.  Is that expected?  TODO functionality?
>>> Is there a work-around?
>>>
>>> Question: Should my next step be to integrate Pellet and use that as
>>> the reasoner?
>>>
>>
> 


Re: Inferred transitive properties not appearing in deductions model

Posted by Dave Reynolds <da...@gmail.com>.
The Jena rule reasoner is more or less[1] a hybrid of a forward chaining 
engine and a tabled backward chaining engine.

The forward engine can compute deductions which are stored in the 
deductions model, it can also add new backward rules. In effect you can 
write forward rules to "compile" parts of an ontology into a set of 
backward rules.

The default OWL rule sets use such a mix of forward and backward 
chaining rules. That way the cost of computing some of the inferences is 
deferred to query time. If you are going to list the complete model 
contents anyway then this has no advantage. However, in many cases you 
might only be asking specific queries in which case some of the 
deductions may never need to be materialized.

If you write your own rule set and use pure forward rules then the 
deductions model will contain all of the rule closure.

Dave

[1] It's actually more complex (and less clean) than that. The 
subClassOf and subPropertyOf closures are computed by a dedicated 
transitive engine which can compute the transitive reduction as well as 
the closure.

There's also some hacky code hooks in the OWL rules which adds some 
extra forward rules which are too hard to compute within the limitations 
of the forward rule engine.

On 24/09/17 17:21, Steve Vestal wrote:
> This appears to have been a misunderstanding of what the deductions
> model contains.  A dump of the full model includes the expected inferred
> transitive relations.
> 
> What does the deductions model contain, relative to the input ontology
> and the inferred sentences?
> 
> 
> On 9/24/2017 9:35 AM, Steve Vestal wrote:
>> I have a few questions about reasoning in Jena.  Thanks in advance for
>> any answers or suggestions.
>>
>> As background, here is a simple test case to infer transitive
>> relations between individuals.  Protege/Pellet will load this model
>> and infer that A transProp C.
>>
>> <?xml version="1.0"?>
>> <rdf:RDF xmlns="http://www.test.com/test#"
>>       xml:base="http://www.test.com/test"
>>       xmlns:t="http://www.test.com/test#"
>>       xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>>       xmlns:owl="http://www.w3.org/2002/07/owl#"
>>       xmlns:xml="http://www.w3.org/XML/1998/namespace"
>>       xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
>>       xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
>>      <owl:Ontology rdf:about="http://www.test.com/test"/>
>>      <owl:ObjectProperty rdf:about="http://www.test.com/test#simpleProp">
>>          <rdfs:subPropertyOf
>> rdf:resource="http://www.test.com/test#transProp"/>
>>      </owl:ObjectProperty>
>>      <owl:ObjectProperty rdf:about="http://www.test.com/test#transProp">
>>          <rdf:type
>> rdf:resource="http://www.w3.org/2002/07/owl#TransitiveProperty"/>
>>      </owl:ObjectProperty>
>>      <owl:NamedIndividual rdf:about="http://www.test.com/test#A">
>>          <simpleProp rdf:resource="http://www.test.com/test#B"/>
>>      </owl:NamedIndividual>
>>      <owl:NamedIndividual rdf:about="http://www.test.com/test#B">
>>          <simpleProp rdf:resource="http://www.test.com/test#C"/>
>>      </owl:NamedIndividual>
>>      <owl:NamedIndividual rdf:about="http://www.test.com/test#C"/>
>> </rdf:RDF>
>>
>> Here is a fragment of the code I'm using with Jena 3.1.0.
>>
>> // Preceded by code to set up mySystemInput to read the above.
>> OntModel mySystem = ModelFactory.createOntologyModel(
>> OntModelSpec.OWL_MEM_RULE_INF );
>> mySystem.read(mySystemInput, null);
>> Model deductionsModel = mySystem.getDeductionsModel();
>> StmtIterator deducedStatements = deductionsModel.listStatements();
>> // Followed by code to dump all the statements.
>>                 
>> The deductionsModel I get does not include the transProp sentences that
>> are inferred by Protege/Pellet.
>>
>> Question: The online page on reasoning suggests that the OWL reasoners
>> that come with Jena might not do all the inferencing that is expected
>> by the OWL standard.  On the other hand, an exchange on users@jena a
>> few years ago suggested that inferring transitive properties
>> would/should be done.  Is the above reasoner expected to make the
>> inference that Protege/Pellet makes?
>>
>> Question: I also tried using the OWL_MEM_TRANS_INF reasonser.  In that case,
>> getDeductionsModel returns null.  Is that expected?  TODO functionality?
>> Is there a work-around?
>>
>> Question: Should my next step be to integrate Pellet and use that as
>> the reasoner?
>>
> 


Re: Inferred transitive properties not appearing in deductions model

Posted by Steve Vestal <st...@adventiumlabs.com>.
This appears to have been a misunderstanding of what the deductions
model contains.  A dump of the full model includes the expected inferred
transitive relations.

What does the deductions model contain, relative to the input ontology
and the inferred sentences?


On 9/24/2017 9:35 AM, Steve Vestal wrote:
> I have a few questions about reasoning in Jena.  Thanks in advance for
> any answers or suggestions.
>
> As background, here is a simple test case to infer transitive
> relations between individuals.  Protege/Pellet will load this model
> and infer that A transProp C.
>
> <?xml version="1.0"?>
> <rdf:RDF xmlns="http://www.test.com/test#"
>      xml:base="http://www.test.com/test"
>      xmlns:t="http://www.test.com/test#"
>      xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>      xmlns:owl="http://www.w3.org/2002/07/owl#"
>      xmlns:xml="http://www.w3.org/XML/1998/namespace"
>      xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
>      xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
>     <owl:Ontology rdf:about="http://www.test.com/test"/>
>     <owl:ObjectProperty rdf:about="http://www.test.com/test#simpleProp">
>         <rdfs:subPropertyOf
> rdf:resource="http://www.test.com/test#transProp"/>
>     </owl:ObjectProperty>
>     <owl:ObjectProperty rdf:about="http://www.test.com/test#transProp">
>         <rdf:type
> rdf:resource="http://www.w3.org/2002/07/owl#TransitiveProperty"/>
>     </owl:ObjectProperty>
>     <owl:NamedIndividual rdf:about="http://www.test.com/test#A">
>         <simpleProp rdf:resource="http://www.test.com/test#B"/>
>     </owl:NamedIndividual>
>     <owl:NamedIndividual rdf:about="http://www.test.com/test#B">
>         <simpleProp rdf:resource="http://www.test.com/test#C"/>
>     </owl:NamedIndividual>
>     <owl:NamedIndividual rdf:about="http://www.test.com/test#C"/>
> </rdf:RDF>
>
> Here is a fragment of the code I'm using with Jena 3.1.0.
>
> // Preceded by code to set up mySystemInput to read the above.
> OntModel mySystem = ModelFactory.createOntologyModel(
> OntModelSpec.OWL_MEM_RULE_INF );
> mySystem.read(mySystemInput, null);
> Model deductionsModel = mySystem.getDeductionsModel();
> StmtIterator deducedStatements = deductionsModel.listStatements();
> // Followed by code to dump all the statements.
>                
> The deductionsModel I get does not include the transProp sentences that
> are inferred by Protege/Pellet.
>
> Question: The online page on reasoning suggests that the OWL reasoners
> that come with Jena might not do all the inferencing that is expected
> by the OWL standard.  On the other hand, an exchange on users@jena a
> few years ago suggested that inferring transitive properties
> would/should be done.  Is the above reasoner expected to make the
> inference that Protege/Pellet makes?
>
> Question: I also tried using the OWL_MEM_TRANS_INF reasonser.  In that case,
> getDeductionsModel returns null.  Is that expected?  TODO functionality?
> Is there a work-around?
>
> Question: Should my next step be to integrate Pellet and use that as
> the reasoner?
>