Program: 9900
Project: 9900
Buggy source:
/** 
 * This is a recursive method that builds a hitting set tree to obtain all justifications for an unsatisfiable class.
 * @param mups                The current justification for the current class. Thiscorresponds to a node in the hitting set tree.
 * @param allMups             All of the MUPS that have been found - this set gets populatedover the course of the tree building process. Initially this should just contain the first justification
 * @param satPaths            Paths that have been completed.
 * @param currentPathContents The contents of the current path. Initially this should be anempty set.
 */
private void constructHittingSetTree(OWLDescription unsatClass,Set<OWLAxiom> mups,Set<Set<OWLAxiom>> allMups,Set<Set<OWLAxiom>> satPaths,Set<OWLAxiom> currentPathContents,int maxExplanations) throws OWLException {
  if (log.isLoggable(Level.FINE))   log.fine("String_Node_Str" + allMups.size() + "String_Node_Str"+ mups);
  if (progressMonitor.isCancelled()) {
    return;
  }
  List<OWLAxiom> orderedMups=getOrderedMUPS(new ArrayList<OWLAxiom>(mups),allMups);
  while (!orderedMups.isEmpty()) {
    if (progressMonitor.isCancelled()) {
      return;
    }
    OWLAxiom axiom=orderedMups.get(0);
    orderedMups.remove(0);
    if (allMups.size() == maxExplanations) {
      if (log.isLoggable(Level.FINE))       log.fine("String_Node_Str" + maxExplanations + "String_Node_Str");
      return;
    }
    if (log.isLoggable(Level.FINE))     log.fine("String_Node_Str" + axiom + "String_Node_Str"+ currentPathContents.size()+ "String_Node_Str"+ currentPathContents);
    Set<OWLOntology> ontologies=OntologyUtils.removeAxiom(axiom,getReasoner().getLoadedOntologies(),getOntologyManager());
    Set<OWLEntity> sig=getSignature(axiom);
    List<OWLDeclarationAxiom> temporaryDeclarations=new ArrayList<OWLDeclarationAxiom>(sig.size());
    for (    OWLEntity e : sig) {
      boolean referenced=false;
      for (Iterator<OWLOntology> i=ontologies.iterator(); !referenced && i.hasNext(); ) {
        for (Iterator<OWLAxiom> j=i.next().getReferencingAxioms(e).iterator(); !referenced && j.hasNext(); ) {
          OWLAxiom a=j.next();
          referenced=a.isLogicalAxiom() || (a instanceof OWLDeclarationAxiom);
        }
      }
      if (!referenced) {
        OWLDeclarationAxiom declaration=getOntologyManager().getOWLDataFactory().getOWLDeclarationAxiom(e);
        temporaryDeclarations.add(declaration);
      }
    }
    for (    OWLDeclarationAxiom decl : temporaryDeclarations) {
      OntologyUtils.addAxiom(decl,getReasoner().getLoadedOntologies(),getOntologyManager());
    }
    currentPathContents.add(axiom);
    boolean earlyTermination=false;
    for (    Set<OWLAxiom> satPath : satPaths) {
      if (currentPathContents.containsAll(satPath)) {
        earlyTermination=true;
        if (log.isLoggable(Level.FINE))         log.fine("String_Node_Str");
        break;
      }
    }
    if (!earlyTermination) {
      Set<OWLAxiom> newMUPS=null;
      for (      Set<OWLAxiom> foundMUPS : allMups) {
        Set<OWLAxiom> foundMUPSCopy=new HashSet<OWLAxiom>(foundMUPS);
        foundMUPSCopy.retainAll(currentPathContents);
        if (foundMUPSCopy.isEmpty()) {
          newMUPS=foundMUPS;
          break;
        }
      }
      if (newMUPS == null) {
        newMUPS=getExplanation(unsatClass);
      }
      if (newMUPS.contains(axiom)) {
        throw new OWLRuntimeException("String_Node_Str" + axiom);
      }
      if (!newMUPS.isEmpty()) {
        allMups.add(newMUPS);
        progressMonitor.foundExplanation(newMUPS);
        constructHittingSetTree(unsatClass,newMUPS,allMups,satPaths,currentPathContents,maxExplanations);
        orderedMups=getOrderedMUPS(orderedMups,allMups);
      }
 else {
        if (log.isLoggable(Level.FINE))         log.fine("String_Node_Str");
        satPaths.add(new HashSet<OWLAxiom>(currentPathContents));
      }
    }
    currentPathContents.remove(axiom);
    if (log.isLoggable(Level.FINE))     log.fine("String_Node_Str" + axiom);
    for (    OWLDeclarationAxiom decl : temporaryDeclarations) {
      OntologyUtils.removeAxiom(decl,getReasoner().getLoadedOntologies(),getOntologyManager());
    }
    OntologyUtils.addAxiom(axiom,ontologies,getOntologyManager());
  }
}

Fixed version (ground truth):
/** 
 * This is a recursive method that builds a hitting set tree to obtain all justifications for an unsatisfiable class.
 * @param mups                The current justification for the current class. Thiscorresponds to a node in the hitting set tree.
 * @param allMups             All of the MUPS that have been found - this set gets populatedover the course of the tree building process. Initially this should just contain the first justification
 * @param satPaths            Paths that have been completed.
 * @param currentPathContents The contents of the current path. Initially this should be anempty set.
 */
private void constructHittingSetTree(OWLDescription unsatClass,Set<OWLAxiom> mups,Set<Set<OWLAxiom>> allMups,Set<Set<OWLAxiom>> satPaths,Set<OWLAxiom> currentPathContents,int maxExplanations) throws OWLException {
  logger.debug("String_Node_Str" + allMups.size() + "String_Node_Str"+ mups);
  if (progressMonitor.isCancelled()) {
    return;
  }
  List<OWLAxiom> orderedMups=getOrderedMUPS(new ArrayList<OWLAxiom>(mups),allMups);
  while (!orderedMups.isEmpty()) {
    if (progressMonitor.isCancelled()) {
      logger.debug("String_Node_Str");
      return;
    }
    OWLAxiom axiom=orderedMups.get(0);
    orderedMups.remove(0);
    if (allMups.size() == maxExplanations) {
      logger.debug("String_Node_Str" + maxExplanations + "String_Node_Str");
      return;
    }
    logger.debug("String_Node_Str" + axiom + "String_Node_Str"+ currentPathContents.size()+ "String_Node_Str"+ currentPathContents);
    Set<OWLOntology> ontologies=OntologyUtils.removeAxiom(axiom,getReasoner().getLoadedOntologies(),getOntologyManager());
    Set<OWLEntity> sig=getSignature(axiom);
    List<OWLDeclarationAxiom> temporaryDeclarations=new ArrayList<OWLDeclarationAxiom>(sig.size());
    for (    OWLEntity e : sig) {
      boolean referenced=false;
      for (Iterator<OWLOntology> i=ontologies.iterator(); !referenced && i.hasNext(); ) {
        for (Iterator<OWLAxiom> j=i.next().getReferencingAxioms(e).iterator(); !referenced && j.hasNext(); ) {
          OWLAxiom a=j.next();
          referenced=a.isLogicalAxiom() || (a instanceof OWLDeclarationAxiom);
        }
      }
      if (!referenced) {
        OWLDeclarationAxiom declaration=getOntologyManager().getOWLDataFactory().getOWLDeclarationAxiom(e);
        temporaryDeclarations.add(declaration);
      }
    }
    for (    OWLDeclarationAxiom decl : temporaryDeclarations) {
      OntologyUtils.addAxiom(decl,getReasoner().getLoadedOntologies(),getOntologyManager());
    }
    currentPathContents.add(axiom);
    boolean earlyTermination=false;
    for (    Set<OWLAxiom> satPath : satPaths) {
      if (currentPathContents.containsAll(satPath)) {
        earlyTermination=true;
        logger.debug("String_Node_Str");
        break;
      }
    }
    if (!earlyTermination) {
      Set<OWLAxiom> newMUPS=null;
      for (      Set<OWLAxiom> foundMUPS : allMups) {
        Set<OWLAxiom> foundMUPSCopy=new HashSet<OWLAxiom>(foundMUPS);
        foundMUPSCopy.retainAll(currentPathContents);
        if (foundMUPSCopy.isEmpty()) {
          newMUPS=foundMUPS;
          break;
        }
      }
      if (newMUPS == null) {
        newMUPS=getExplanation(unsatClass);
      }
      if (newMUPS.contains(axiom)) {
        throw new OWLRuntimeException("String_Node_Str" + axiom);
      }
      if (!newMUPS.isEmpty()) {
        allMups.add(newMUPS);
        progressMonitor.foundExplanation(newMUPS);
        constructHittingSetTree(unsatClass,newMUPS,allMups,satPaths,currentPathContents,maxExplanations);
        orderedMups=getOrderedMUPS(orderedMups,allMups);
      }
 else {
        logger.debug("String_Node_Str");
        satPaths.add(new HashSet<OWLAxiom>(currentPathContents));
      }
    }
    currentPathContents.remove(axiom);
    logger.debug("String_Node_Str" + axiom);
    for (    OWLDeclarationAxiom decl : temporaryDeclarations) {
      OntologyUtils.removeAxiom(decl,getReasoner().getLoadedOntologies(),getOntologyManager());
    }
    OntologyUtils.addAxiom(axiom,ontologies,getOntologyManager());
  }
}