I am trying to get the explanations for inferences (like in Protégé with Pellet) using OWL API and Openllet Reasoner. (Previously here, I used OWL API + Pellet, but @Ignazio suggested to use newer version of OWL API, so I wrote new code using OWL API 5.5.0 and Openllet 2.6.5 - Maven: com.github.galigator.openllet:openllet-examples:2.6.5)
But I am receiving Exception in thread "main" org.semanticweb.owlapi.model.OWLRuntimeException: Explanation contains removed axiom:...
As you can see in Explanation pic, the exception appears because of this SWRL rule:
new:Triangle(?t) ^ new:angle_c(?t, ?c) ^ new:angle_b(?t, ?b) ^ new:angle_a(?t, ?a) ^ new:has_angle_of(?a, ?v1) ^ new:has_angle_of(?b, ?v2) ^ swrlb:add(?v3, ?v1, ?v2) ^ swrlb:subtract(?v4, 180, ?v3) -> new:has_angle_of(?c, ?v4)
This is my code:
package org.example;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Set;
import org.semanticweb.owlapi.model.*;
import openllet.owlapi.OpenlletReasoner;
import openllet.owlapi.OpenlletReasonerFactory;
import openllet.owlapi.explanation.PelletExplanation;
import openllet.owlapi.explanation.io.manchester.ManchesterSyntaxExplanationRenderer;
import org.semanticweb.owlapi.apibinding.OWLManager;
public class Main {
private static final String file = "file:/folder/new.owl";
private static final String NS = "http://www.semanticweb.org/oliver/ontologies/new.owl#";
public static void main(String[] args) throws OWLOntologyCreationException, OWLException, IOException {
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology ontology = manager.loadOntology(IRI.create(file));
OWLDataFactory dataFactory = manager.getOWLDataFactory();
OpenlletReasoner reasoner = OpenlletReasonerFactory.getInstance().createReasoner(ontology);
PelletExplanation explanationGenerator = new PelletExplanation(reasoner);
ManchesterSyntaxExplanationRenderer renderer = new ManchesterSyntaxExplanationRenderer();
PrintWriter out = new PrintWriter(System.out);
renderer.startRendering(out);
OWLIndividual angle = dataFactory.getOWLNamedIndividual(IRI.create(NS + "angle_C"));
OWLDataPropertyExpression hasAngle = dataFactory.getOWLDataProperty(IRI.create(NS + "has_angle_of"));
OWLAxiom axiom = dataFactory.getOWLDataPropertyAssertionAxiom(hasAngle, angle, 105);
System.out.println(axiom);
System.out.println(ontology.getAxioms(AxiomType.SWRL_RULE));
Set<Set<OWLAxiom>> explanations = explanationGenerator.getEntailmentExplanations(axiom);
renderer.render(explanations);
renderer.endRendering();
}
}
Maybe someone has an idea, why both OWL API with Pellet and OWL API with Openllet are showing this exception? Files like ontology, owlapi+pellet and owlapi+openllet are here.

