Skip to content

Include SubObjectPropertyOf axioms when reducing. #1248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Bug was fixed that caused logical axioms with axiom annotations not to be processed correctly when merging axiom annotations [#1223]
- Correctly merge unannotated and annotated duplicated axioms [#1239]
- Fix reading of default queries from embedded Jar resources [#1212]
- Subproperties being ignored when evaluating redundancy in `reduce` [#1014], [#1208]

## [1.9.7] - 2024-10-30

Expand Down
40 changes: 40 additions & 0 deletions docs/examples/reduced-redundant-over-subproperties.ofn
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Prefix(:=<http://purl.obolibrary.org/obo/test.owl#>)
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)


Ontology(<http://purl.obolibrary.org/obo/test.owl>

Declaration(Class(<http://purl.obolibrary.org/obo/Kupffer_cell>))
Declaration(Class(<http://purl.obolibrary.org/obo/liver>))
Declaration(Class(<http://purl.obolibrary.org/obo/liver_lobule>))
Declaration(ObjectProperty(<http://purl.obolibrary.org/obo/located_in>))
Declaration(ObjectProperty(<http://purl.obolibrary.org/obo/overlaps>))
Declaration(ObjectProperty(<http://purl.obolibrary.org/obo/part_of>))
############################
# Object Properties
############################

# Object Property: <http://purl.obolibrary.org/obo/part_of> (<http://purl.obolibrary.org/obo/part_of>)

SubObjectPropertyOf(<http://purl.obolibrary.org/obo/part_of> <http://purl.obolibrary.org/obo/overlaps>)


############################
# Classes
############################

# Class: <http://purl.obolibrary.org/obo/Kupffer_cell> (<http://purl.obolibrary.org/obo/Kupffer_cell>)

SubClassOf(<http://purl.obolibrary.org/obo/Kupffer_cell> ObjectSomeValuesFrom(<http://purl.obolibrary.org/obo/located_in> <http://purl.obolibrary.org/obo/liver_lobule>))

# Class: <http://purl.obolibrary.org/obo/liver_lobule> (<http://purl.obolibrary.org/obo/liver_lobule>)

SubClassOf(<http://purl.obolibrary.org/obo/liver_lobule> ObjectSomeValuesFrom(<http://purl.obolibrary.org/obo/part_of> <http://purl.obolibrary.org/obo/liver>))


SubObjectPropertyOf(ObjectPropertyChain(<http://purl.obolibrary.org/obo/located_in> <http://purl.obolibrary.org/obo/part_of>) <http://purl.obolibrary.org/obo/located_in>)
)
42 changes: 42 additions & 0 deletions docs/examples/redundant-over-subproperties.ofn
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Prefix(:=<http://purl.obolibrary.org/obo/test.owl#>)
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)


Ontology(<http://purl.obolibrary.org/obo/test.owl>

Declaration(Class(<http://purl.obolibrary.org/obo/Kupffer_cell>))
Declaration(Class(<http://purl.obolibrary.org/obo/liver>))
Declaration(Class(<http://purl.obolibrary.org/obo/liver_lobule>))
Declaration(ObjectProperty(<http://purl.obolibrary.org/obo/located_in>))
Declaration(ObjectProperty(<http://purl.obolibrary.org/obo/overlaps>))
Declaration(ObjectProperty(<http://purl.obolibrary.org/obo/part_of>))
############################
# Object Properties
############################

# Object Property: <http://purl.obolibrary.org/obo/part_of> (<http://purl.obolibrary.org/obo/part_of>)

SubObjectPropertyOf(<http://purl.obolibrary.org/obo/part_of> <http://purl.obolibrary.org/obo/overlaps>)


############################
# Classes
############################

# Class: <http://purl.obolibrary.org/obo/Kupffer_cell> (<http://purl.obolibrary.org/obo/Kupffer_cell>)

SubClassOf(<http://purl.obolibrary.org/obo/Kupffer_cell> ObjectSomeValuesFrom(<http://purl.obolibrary.org/obo/located_in> <http://purl.obolibrary.org/obo/liver>))
SubClassOf(<http://purl.obolibrary.org/obo/Kupffer_cell> ObjectSomeValuesFrom(<http://purl.obolibrary.org/obo/located_in> <http://purl.obolibrary.org/obo/liver_lobule>))

# Class: <http://purl.obolibrary.org/obo/liver_lobule> (<http://purl.obolibrary.org/obo/liver_lobule>)

SubClassOf(<http://purl.obolibrary.org/obo/liver_lobule> ObjectSomeValuesFrom(<http://purl.obolibrary.org/obo/overlaps> <http://purl.obolibrary.org/obo/liver>))
SubClassOf(<http://purl.obolibrary.org/obo/liver_lobule> ObjectSomeValuesFrom(<http://purl.obolibrary.org/obo/part_of> <http://purl.obolibrary.org/obo/liver>))


SubObjectPropertyOf(ObjectPropertyChain(<http://purl.obolibrary.org/obo/located_in> <http://purl.obolibrary.org/obo/part_of>) <http://purl.obolibrary.org/obo/located_in>)
)
21 changes: 20 additions & 1 deletion docs/reduce.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,23 @@ Available options for `reduce`:
### Warning

Reciprocal subclass axioms (e.g. `A SubClassOf B`, `B SubClassOf A`), entailing equivalence between `A` and `B`, may be removed by `reduce`. In this case it is important to
assert an equivalence axiom (`A EquivalentTo B`) using the `reason` command before running reduce.
assert an equivalence axiom (`A EquivalentTo B`) using the `reason` command before running reduce.

### Subproperties and property chains

For backwards compatibility reasons, by default subObjectPropertyOf axioms are ignored when evaluating the redundancy of subClassOf axioms. This means that, given the following example:

```
C SubClassOf P some D
C SubClassOf Q some D
P SubObjectPropertyOf Q
```

the first subClassOf axiom would by default _not_ be considered redundant and therefore _not_ be removed.

To force the `reduce` command to factor in subproperties (including property chains) when evaluating redundancy, use the `--include-subproperties` option:

robot reduce --reasoner ELK \
--input redundant-over-subproperties.ofn \
--include-subproperties true \
--output results/reduced-redundant-over-subproperties.ofn
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public ReduceCommand() {
"preserve annotated axioms when removing redundant subclass axioms");
o.addOption(
"c", "named-classes-only", true, "only reduce subclass axioms between named classes");
o.addOption(
"s",
"include-subproperties",
true,
"take subproperties into account to evaluate redundancy");
o.addOption("i", "input", true, "reduce ontology from a file");
o.addOption("I", "input-iri", true, "reduce ontology from an IRI");
o.addOption("o", "output", true, "save reduceed ontology to a file");
Expand Down
17 changes: 15 additions & 2 deletions robot-core/src/main/java/org/obolibrary/robot/ReduceOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public static Map<String, String> getDefaultOptions() {
Map<String, String> options = new HashMap<>();
options.put("preserve-annotated-axioms", "false");
options.put("named-classes-only", "false");
options.put("include-subproperties", "false");
return options;
}

Expand Down Expand Up @@ -87,7 +88,9 @@ public static void reduce(
if (namedClassesOnly) {
reduceNamedOnly(ontology, reasonerFactory, preserveAnnotatedAxioms);
} else {
reduceAllClassExpressions(ontology, reasonerFactory, preserveAnnotatedAxioms);
boolean includeSubproperties = OptionsHelper.optionIsTrue(options, "include-subproperties");
reduceAllClassExpressions(
ontology, reasonerFactory, preserveAnnotatedAxioms, includeSubproperties);
}
}

Expand All @@ -97,21 +100,31 @@ public static void reduce(
* @param ontology The ontology to reduce.
* @param reasonerFactory The reasoner factory to use.
* @param preserveAnnotatedAxioms Whether to not remove redundant, but annotated, axioms.
* @param includeSubproperties Whether to include subPropertyOf axioms (including property chains)
* for evaluating redundancy.
* @throws OWLOntologyCreationException on ontology problem
*/
private static void reduceAllClassExpressions(
OWLOntology ontology, OWLReasonerFactory reasonerFactory, boolean preserveAnnotatedAxioms)
OWLOntology ontology,
OWLReasonerFactory reasonerFactory,
boolean preserveAnnotatedAxioms,
boolean includeSubproperties)
throws OWLOntologyCreationException {

OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLDataFactory dataFactory = manager.getOWLDataFactory();

// we treat an axiom as redundant if its is redundant within the
// subClassOf graph, including OP characteristic axioms (e.g. transitivity)
// and subproperty axioms
OWLOntology subOntology = manager.createOntology();
for (OWLAxiom a : ontology.getAxioms(Imports.INCLUDED)) {
if (a instanceof OWLSubClassOfAxiom || a instanceof OWLObjectPropertyCharacteristicAxiom) {
manager.addAxiom(subOntology, a);
} else if (includeSubproperties
&& (a instanceof OWLSubObjectPropertyOfAxiom
|| a instanceof OWLSubPropertyChainOfAxiom)) {
manager.addAxiom(subOntology, a);
}
}

Expand Down