ontodev / robot

ROBOT is an OBO Tool
http://robot.obolibrary.org
BSD 3-Clause "New" or "Revised" License
259 stars 73 forks source link

Add a --include-indirect option to materialize #1213

Open cmungall opened 1 month ago

cmungall commented 1 month ago

From slack:

Hi all, I have a question about the use of the materialize command. Let's consider the following axioms:

car SubclassOf has part some wheel
convertible SubclassOf car

I would like to assert the inferred axiom:

convertible SubclassOf has part some wheel

My comprehension is that I should use the materialize command like this: robot materialize -i input.owl --reasoner ELK --term IRI:convertible -o output.owl

However, I don't see any difference between input and output (Robot v1.9.6)

cmungall commented 1 month ago

My response:

Materialize still produces an ontology that is in some sense non-redundant. It lacks the analog of --include-indirect in reason

However, we should clarify the intended semantics. the words "direct" and "redundant" are often used imprecisely

consider:

car SubclassOf has part some wheel
convertible SubclassOf car
wheel SubClassOf has part some hubcap
Transitive(has part)

visualized as:

image

Would you also expect to see convertible has-part hubcap?

This is in some sense the most straightforward scenario and is the output of relation-graph

If you want the most specific relationships materialized, currently this is only handled by OAK:

runoak -i car.db relationships .all --non-redundant-entailed

subject predicate object subject_label predicate_label object_label
EXAMPLE:car BFO:0000051 EXAMPLE:wheel car has part wheel
EXAMPLE:convertible BFO:0000051 EXAMPLE:wheel convertible has part wheel
EXAMPLE:convertible rdfs:subClassOf EXAMPLE:car convertible None car
EXAMPLE:wheel BFO:0000051 EXAMPLE:hubcap wheel has part hubcap

runoak -i car.db relationships .all --include-entailed

subject predicate object subject_label predicate_label object_label
EXAMPLE:car BFO:0000051 EXAMPLE:hubcap car has part hubcap
EXAMPLE:car BFO:0000051 EXAMPLE:wheel car has part wheel
EXAMPLE:car rdfs:subClassOf EXAMPLE:car car None car
EXAMPLE:convertible BFO:0000051 EXAMPLE:hubcap convertible has part hubcap
EXAMPLE:convertible BFO:0000051 EXAMPLE:wheel convertible has part wheel
EXAMPLE:convertible rdfs:subClassOf EXAMPLE:car convertible None car
EXAMPLE:convertible rdfs:subClassOf EXAMPLE:convertible convertible None convertible
EXAMPLE:hubcap rdfs:subClassOf EXAMPLE:hubcap hubcap None hubcap
EXAMPLE:wheel BFO:0000051 EXAMPLE:hubcap wheel has part hubcap
EXAMPLE:wheel rdfs:subClassOf EXAMPLE:wheel wheel None wheel
cmungall commented 1 month ago

Note: it's OK to close this as out of scope, as robot doesn't have a very graphy view of the universe, but I wanted to capture the discussion where it won't be swallowed by the slack memory vortex

cmungall commented 1 month ago

An alternative is the plain reason command with emr as the reasoner:

robot reason --include-indirect true --reasoner emr -i car.owl -o car2.owl

this includes things like 'car has-part hubcap`

souzadevinicius commented 1 month ago

I want to start a bit with robot development, so I decided to pick this issue. However, it didn't work, the key is this:

Set<OWLClassExpression> sces = emr.getSuperClassExpressions(c, !includeIndirect);

@cmungall you know how better how emr works. Can you help me with that?

pfabry commented 1 month ago

An alternative is the plain reason command with emr as the reasoner:

robot reason --include-indirect true --reasoner emr -i car.owl -o car2.owl

this includes things like 'car has-part hubcap`

Unfortunately, this adds also a lot of "noise" such as 'convertible subClassOf owl:thing'

balhoff commented 2 weeks ago

One option would be to use relation-graph and then merge the output using ROBOT:

relation-graph --ontology-file input.owl --mode OWL --output-file relations.nt --property 'http://purl.obolibrary.org/obo/RO_0002162' --output-subclasses false

or leave off the property argument if you want all properties materialized.