robot icon indicating copy to clipboard operation
robot copied to clipboard

relax is currently incomplete

Open cmungall opened this issue 1 year ago • 4 comments

A subClassOf B and R some C is currently shielded from relax.

This has a long chain of unintended consequences...

chatgpt suggests the following which I think is correct:

// Assuming ontology is already loaded into an OWLOntology object named 'ontology'
OWLDataFactory factory = OWLManager.getOWLDataFactory();

for (OWLSubClassOfAxiom axiom : ontology.getAxioms(AxiomType.SUBCLASS_OF)) {
    // Check if the RHS is an ObjectIntersectionOf
    if (axiom.getSuperClass() instanceof OWLObjectIntersectionOf) {
        OWLObjectIntersectionOf intersection = (OWLObjectIntersectionOf) axiom.getSuperClass();
        OWLClassExpression subclass = axiom.getSubClass();
        
        // Remove the original axiom
        ontology.removeAxiom(axiom);
        
        // Create and add new axioms for each part of the intersection
        for (OWLClassExpression part : intersection.getOperands()) {
            OWLSubClassOfAxiom newAxiom = factory.getOWLSubClassOfAxiom(subclass, part);
            ontology.addAxiom(newAxiom);
        }
    }
}

// Save the ontology or perform further processing

I don't think we need to worry about inner ANDs, so no need for conversion to NNF or anything

cmungall avatar Feb 09 '24 22:02 cmungall

For now I am relaxing in place using this

(perl, functional syntax, and ChatGPT... what could go wrong?)

cmungall avatar Feb 09 '24 22:02 cmungall

Additionally it would be useful to do relaxation of cardinality constraints too.

E.g.

id: UPa:UCR00783
name: H(2)O + ferricytochrome c + nitric oxide = H(+) + ferrocytochrome c + nitrite
namespace: reaction
xref: KEGG:R00783 "KEGG reaction"
xref: RHEA:15236 "Rhea reaction"
xref: METACYC:NITRITE-REDUCTASE-CYTOCHROME-RXN "MetaCyc REACTION" {source=Rhea,source=MetaCyc}
relationship: has_input_compound UPa:UPC00001 {cardinality="1"} ! UPa:UPC00001 ! H(2)O
relationship: has_input_compound UPa:UPC00125 {cardinality="1"} ! UPa:UPC00125 ! ferricytochrome c
relationship: has_input_compound UPa:UPC00533 {cardinality="1"} ! UPa:UPC00533 ! nitric oxide
relationship: has_output_compound UPa:UPC00080 {cardinality="1"} ! UPa:UPC00080 ! H(+)
relationship: has_output_compound UPa:UPC00088 {cardinality="1"} ! UPa:UPC00088 ! nitrite
relationship: has_output_compound UPa:UPC00126 {cardinality="1"} ! UPa:UPC00126 ! ferrocytochrome c
relationship: part_of UPa:UER00707 {cardinality="1", order="1", direction="RL"}

Should generate someValuesFrom on relaxation

cmungall avatar Mar 07 '24 01:03 cmungall

Is that really within the scope of relax though?

ROBOT currently defines the relax operation as being solely about removing equivalence axioms:

Robot can be used to relax Equivalence Axioms to weaker SubClassOf axioms. […] Many ontology make use of OWL EquivalenceAxioms, particularly during the development cycle. These are required for being able to use the reason command to classify an ontology. However, many downstream applications are not equipped to use these. […] The relax command allows us to capture some of the information in a form that is accessible to basic downstream applications.

gouttegd avatar Mar 10 '24 11:03 gouttegd

Relax is doing two things:

  1. Relaxing EquivalentClasses to SubClassOf
  2. Relaxing complex conjunctive expressions to individual SubClassOf axioms

So I think this is in scope.

I have now implemented some of this in #1188:

  • A subClassOf B and R some C can now optionally be processed the same way as A EquivalentTo B and R some C

Note: cardinality constraints of the type you mention where always processed the way @cmungall is saying; I didnt touch this code, but added a test that illustrates this.

matentzn avatar Mar 10 '24 17:03 matentzn