* @param a input automaton
* @return resulting automaton
*/
@Override
public Automaton op(Automaton a) {
Automaton b = new Automaton();
Map<State, State> map = new HashMap<State, State>();
for (State s : a.getStates()) {
State ss = new State();
map.put(s, ss);
}
State initial = new State();
b.setInitialState(initial);
map.get(a.getInitialState()).setAccept(true);
Set<StatePair> epsilons = new HashSet<StatePair>();
for (State s : a.getStates()) {
State ss = map.get(s);
if (s.isAccept()) {
epsilons.add(new StatePair(initial, ss));
}
for (Transition t : s.getTransitions()) {
State pp = map.get(t.getDest());
pp.addTransition(new Transition(t.getMin(), t.getMax(), ss));
}
}
b.setDeterministic(false);
b.addEpsilons(epsilons);
b.minimize();
return b;
}