private Set<Explanation<E>> getReconstitutedLaconicJustifications() {
        // Simple, but not particularly efficient

        // What we do is examine the subclass axioms in an explanation
        // We merge axioms that have the same LHS and same source checker.  Although the
        // explanations that we operate on are already laconic, we end up producing explanations
        // that will be closer to the asserted axioms
        Map<OWLAxiom, Set<OWLAxiom>> sourceAxioms2OPlus = new HashMap<OWLAxiom, Set<OWLAxiom>>();

        for (Explanation<E> exp : allPreviouslyFoundJustifications) {
            for (OWLAxiom ax : exp.getAxioms()) {
                if (ont.containsAxiom(ax)) {
                    sourceAxioms2OPlus.put(ax, computeOPlus(Collections.singleton(ax)));
                }
            }
        }

        Set<Explanation<E>> reconstituedExplanations = new HashSet<Explanation<E>>();
        for (Explanation<E> laconicExp : foundLaconicJustifications) {
            // SubClass -> Source Axiom -> SubClass Axiom
            Map<OWLClass, Map<OWLAxiom, Set<OWLSubClassOfAxiom>>> lhs2SubClassAxiom = new HashMap<OWLClass, Map<OWLAxiom, Set<OWLSubClassOfAxiom>>>();

            Set<OWLAxiom> reconstituedAxioms = new HashSet<OWLAxiom>();
            for (OWLAxiom laconicAx : laconicExp.getAxioms()) {
                if (laconicAx instanceof OWLSubClassOfAxiom) {
                    OWLSubClassOfAxiom sca = (OWLSubClassOfAxiom) laconicAx;
                    if (sca.getSubClass().isAnonymous()) {
                        // We only merge stuff with a common NAMED lhs
                        reconstituedAxioms.add(sca);
                        continue;
                    }
                    Map<OWLAxiom, Set<OWLSubClassOfAxiom>> source2AxiomMap = lhs2SubClassAxiom.get(sca.getSubClass().asOWLClass());
                    if (source2AxiomMap == null) {
                        source2AxiomMap = new HashMap<OWLAxiom, Set<OWLSubClassOfAxiom>>();
                        lhs2SubClassAxiom.put(sca.getSubClass().asOWLClass(), source2AxiomMap);
                    }
                    for (OWLAxiom sourceAx : sourceAxioms2OPlus.keySet()) {
                        if (sourceAxioms2OPlus.get(sourceAx).contains(sca)) {
                            Set<OWLSubClassOfAxiom> subClassAxioms = source2AxiomMap.get(sourceAx);
                            if (subClassAxioms == null) {
                                subClassAxioms = new HashSet<OWLSubClassOfAxiom>();
                                source2AxiomMap.put(sourceAx, subClassAxioms);
                            }
                            subClassAxioms.add(sca);
                        }
                    }
                }
                else {
                    reconstituedAxioms.add(laconicAx);
                }
            }
            // Right, now we have sorted everything, we merge axioms that have a common LHS and common source
            Set<OWLSubClassOfAxiom> consumedAxioms = new HashSet<OWLSubClassOfAxiom>();
            for (OWLClass lhs : lhs2SubClassAxiom.keySet()) {
                Map<OWLAxiom, Set<OWLSubClassOfAxiom>> source2SubClassAxiom = lhs2SubClassAxiom.get(lhs);
                for (OWLAxiom source : source2SubClassAxiom.keySet()) {
                    Set<OWLClassExpression> rightHandSides = new HashSet<OWLClassExpression>();
                    for (OWLSubClassOfAxiom subClassAx : source2SubClassAxiom.get(source)) {
                        if (!consumedAxioms.contains(subClassAx)) {
                            rightHandSides.add(subClassAx.getSuperClass());
                            consumedAxioms.add(subClassAx);
                        }
                    }
                    if (rightHandSides.size() == 1) {
                        reconstituedAxioms.add(man.getOWLDataFactory().getOWLSubClassOfAxiom(lhs, rightHandSides.iterator().next()));
                    }
                    else if (rightHandSides.size() > 1) {
                        OWLObjectIntersectionOf conjunction = man.getOWLDataFactory().getOWLObjectIntersectionOf(rightHandSides);
                        reconstituedAxioms.add(man.getOWLDataFactory().getOWLSubClassOfAxiom(lhs, conjunction));
                    }
                }
            }
            Explanation<E> explanation = new Explanation<E>(laconicExp.getEntailment(), reconstituedAxioms);
            reconstituedExplanations.add(explanation);

        }
        return reconstituedExplanations;
    }
private Set < Explanation < E > > getReconstitutedLaconicJustifications ( ) { Map < OWLAxiom , Set < OWLAxiom > > sourceAxioms2OPlus = new HashMap < OWLAxiom , Set < OWLAxiom > > ( ) ; for ( Explanation < E > exp : allPreviouslyFoundJustifications ) { for ( OWLAxiom ax : exp . getAxioms ( ) ) { if ( ont . containsAxiom ( ax ) ) { sourceAxioms2OPlus . put ( ax , computeOPlus ( Collections . singleton ( ax ) ) ) ; } } } Set < Explanation < E > > reconstituedExplanations = new HashSet < Explanation < E > > ( ) ; for ( Explanation < E > laconicExp : foundLaconicJustifications ) { Map < OWLClass , Map < OWLAxiom , Set < OWLSubClassOfAxiom > > > lhs2SubClassAxiom = new HashMap < OWLClass , Map < OWLAxiom , Set < OWLSubClassOfAxiom > > > ( ) ; Set < OWLAxiom > reconstituedAxioms = new HashSet < OWLAxiom > ( ) ; for ( OWLAxiom laconicAx : laconicExp . getAxioms ( ) ) { if ( laconicAx instanceof OWLSubClassOfAxiom ) { OWLSubClassOfAxiom sca = ( OWLSubClassOfAxiom ) laconicAx ; if ( sca . getSubClass ( ) . isAnonymous ( ) ) { reconstituedAxioms . add ( sca ) ; continue ; } Map < OWLAxiom , Set < OWLSubClassOfAxiom > > source2AxiomMap = lhs2SubClassAxiom . get ( sca . getSubClass ( ) . asOWLClass ( ) ) ; if ( source2AxiomMap == null ) { source2AxiomMap = new HashMap < OWLAxiom , Set < OWLSubClassOfAxiom > > ( ) ; lhs2SubClassAxiom . put ( sca . getSubClass ( ) . asOWLClass ( ) , source2AxiomMap ) ; } for ( OWLAxiom sourceAx : sourceAxioms2OPlus . keySet ( ) ) { if ( sourceAxioms2OPlus . get ( sourceAx ) . contains ( sca ) ) { Set < OWLSubClassOfAxiom > subClassAxioms = source2AxiomMap . get ( sourceAx ) ; if ( subClassAxioms == null ) { subClassAxioms = new HashSet < OWLSubClassOfAxiom > ( ) ; source2AxiomMap . put ( sourceAx , subClassAxioms ) ; } subClassAxioms . add ( sca ) ; } } } else { reconstituedAxioms . add ( laconicAx ) ; } } Set < OWLSubClassOfAxiom > consumedAxioms = new HashSet < OWLSubClassOfAxiom > ( ) ; for ( OWLClass lhs : lhs2SubClassAxiom . keySet ( ) ) { Map < OWLAxiom , Set < OWLSubClassOfAxiom > > source2SubClassAxiom = lhs2SubClassAxiom . get ( lhs ) ; for ( OWLAxiom source : source2SubClassAxiom . keySet ( ) ) { Set < OWLClassExpression > rightHandSides = new HashSet < OWLClassExpression > ( ) ; for ( OWLSubClassOfAxiom subClassAx : source2SubClassAxiom . get ( source ) ) { if ( ! consumedAxioms . contains ( subClassAx ) ) { rightHandSides . add ( subClassAx . getSuperClass ( ) ) ; consumedAxioms . add ( subClassAx ) ; } } if ( rightHandSides . size ( ) == 1 ) { reconstituedAxioms . add ( man . getOWLDataFactory ( ) . getOWLSubClassOfAxiom ( lhs , rightHandSides . iterator ( ) . next ( ) ) ) ; } else if ( rightHandSides . size ( ) > 1 ) { OWLObjectIntersectionOf conjunction = man . getOWLDataFactory ( ) . getOWLObjectIntersectionOf ( rightHandSides ) ; reconstituedAxioms . add ( man . getOWLDataFactory ( ) . getOWLSubClassOfAxiom ( lhs , conjunction ) ) ; } } } Explanation < E > explanation = new Explanation < E > ( laconicExp . getEntailment ( ) , reconstituedAxioms ) ; reconstituedExplanations . add ( explanation ) ; } return reconstituedExplanations ; }
Reconstitutes axioms in laconic justifications
@return A set of justifications whose axioms are reconstituted