Program: 42162
Project: 42162
Buggy source:
/** 
 * Returns true if the SAFA accepts the input list
 * @param input
 * @param ba
 * @return true if accepted false otherwise
 * @throws TimeoutException
 */
public static <P,S>SFA<P,S> getReverseSFA(SAFA<P,S> aut,BooleanAlgebra<P,S> ba) throws TimeoutException {
  Collection<SFAMove<P,S>> transitions=new ArrayList<SFAMove<P,S>>();
  Integer initialState=0;
  Collection<Integer> finalStates=new ArrayList<Integer>();
  HashMap<HashSet<Integer>,Integer> reached=new HashMap<HashSet<Integer>,Integer>();
  LinkedList<HashSet<Integer>> toVisit=new LinkedList<HashSet<Integer>>();
  HashSet<Integer> init=new HashSet<>(aut.finalStates);
  reached.put(init,0);
  toVisit.add(init);
  while (!toVisit.isEmpty()) {
    HashSet<Integer> currentState=toVisit.removeFirst();
    int currentStateID=reached.get(currentState);
    ArrayList<SAFAInputMove<P,S>> movesToCurr=new ArrayList<>();
    ArrayList<P> predicatesToCurr=new ArrayList<>();
    if (currentState.contains(aut.initialState))     finalStates.add(currentStateID);
    for (    SAFAInputMove<P,S> t : aut.getInputMoves())     if (t.to.hasModel(currentState)) {
      movesToCurr.add(t);
      predicatesToCurr.add(t.guard);
    }
    Collection<Pair<P,ArrayList<Integer>>> minterms=ba.GetMinterms(predicatesToCurr);
    for (    Pair<P,ArrayList<Integer>> minterm : minterms) {
      ArrayList<Integer> moveBits=minterm.second;
      HashSet<Integer> fromState=new HashSet<Integer>();
      for (int moveIndex=0; moveIndex < moveBits.size(); moveIndex++)       if (moveBits.get(moveIndex) == 1)       fromState.add(movesToCurr.get(moveIndex).from);
      if (fromState.size() > 0) {
        int fromSt=getStateId(fromState,reached,toVisit);
        transitions.add(new SFAInputMove<P,S>(currentStateID,fromSt,minterm.first));
      }
    }
  }
  SFA<P,S> rev=SFA.MkSFA(transitions,initialState,finalStates,ba);
  rev.setIsDet(true);
  return rev;
}

Fixed version (ground truth):
/** 
 * Returns true if the SAFA accepts the input list
 * @param input
 * @param ba
 * @return true if accepted false otherwise
 * @throws TimeoutException
 */
public static <P,S>SFA<P,S> getReverseSFA(SAFA<P,S> aut,BooleanAlgebra<P,S> ba) throws TimeoutException {
  Collection<SFAMove<P,S>> transitions=new ArrayList<SFAMove<P,S>>();
  Integer initialState=0;
  Collection<Integer> finalStates=new ArrayList<Integer>();
  HashMap<HashSet<Integer>,Integer> reached=new HashMap<HashSet<Integer>,Integer>();
  LinkedList<HashSet<Integer>> toVisit=new LinkedList<HashSet<Integer>>();
  HashSet<Integer> init=new HashSet<>(aut.finalStates);
  reached.put(init,0);
  toVisit.add(init);
  while (!toVisit.isEmpty()) {
    HashSet<Integer> currentState=toVisit.removeFirst();
    int currentStateID=reached.get(currentState);
    ArrayList<SAFAInputMove<P,S>> movesToCurr=new ArrayList<>();
    ArrayList<P> predicatesToCurr=new ArrayList<>();
    if (aut.initialState.hasModel(currentState))     finalStates.add(currentStateID);
    for (    SAFAInputMove<P,S> t : aut.getInputMoves())     if (t.to.hasModel(currentState)) {
      movesToCurr.add(t);
      predicatesToCurr.add(t.guard);
    }
    Collection<Pair<P,ArrayList<Integer>>> minterms=ba.GetMinterms(predicatesToCurr);
    for (    Pair<P,ArrayList<Integer>> minterm : minterms) {
      ArrayList<Integer> moveBits=minterm.second;
      HashSet<Integer> fromState=new HashSet<Integer>();
      for (int moveIndex=0; moveIndex < moveBits.size(); moveIndex++)       if (moveBits.get(moveIndex) == 1)       fromState.add(movesToCurr.get(moveIndex).from);
      if (fromState.size() > 0) {
        int fromSt=getStateId(fromState,reached,toVisit);
        transitions.add(new SFAInputMove<P,S>(currentStateID,fromSt,minterm.first));
      }
    }
  }
  SFA<P,S> rev=SFA.MkSFA(transitions,initialState,finalStates,ba);
  rev.setIsDet(true);
  return rev;
}