/** * Checks whether there is a loop containing state. (This is sufficient since * there are never transitions to dead states.) */ // TODO: not great that this is recursive... in theory a // large automata could exceed java's stack so the maximum level of recursion is bounded to 1000 private static boolean isFinite(Transition scratch, Automaton a, int state, BitSet path, BitSet visited, int level) { if (level > MAX_RECURSION_LEVEL) { throw new IllegalArgumentException("input automaton is too large: " + level); } path.set(state); int numTransitions = a.initTransition(state, scratch); for(int t=0;t<numTransitions;t++) { a.getTransition(state, t, scratch); if (path.get(scratch.dest) || (!visited.get(scratch.dest) && !isFinite(scratch, a, scratch.dest, path, visited, level+1))) { return false; } } path.clear(state); visited.set(state); return true; }
/** * Returns true if the language of this automaton is finite. The * automaton must not have any dead states. */ public static boolean isFinite(Automaton a) { if (a.getNumStates() == 0) { return true; } return isFinite(new Transition(), a, 0, new BitSet(a.getNumStates()), new BitSet(a.getNumStates()), 0); }
this.finite = Operations.isFinite(automaton); } else { this.finite = finite;
/** * Checks whether there is a loop containing state. (This is sufficient since * there are never transitions to dead states.) */ // TODO: not great that this is recursive... in theory a // large automata could exceed java's stack private static boolean isFinite(Transition scratch, Automaton a, int state, BitSet path, BitSet visited) { path.set(state); int numTransitions = a.initTransition(state, scratch); for(int t=0;t<numTransitions;t++) { a.getTransition(state, t, scratch); if (path.get(scratch.dest) || (!visited.get(scratch.dest) && !isFinite(scratch, a, scratch.dest, path, visited))) { return false; } } path.clear(state); visited.set(state); return true; }
/** * Checks whether there is a loop containing state. (This is sufficient since * there are never transitions to dead states.) */ // TODO: not great that this is recursive... in theory a // large automata could exceed java's stack private static boolean isFinite(Transition scratch, Automaton a, int state, BitSet path, BitSet visited) { path.set(state); int numTransitions = a.initTransition(state, scratch); for(int t=0;t<numTransitions;t++) { a.getTransition(state, t, scratch); if (path.get(scratch.dest) || (!visited.get(scratch.dest) && !isFinite(scratch, a, scratch.dest, path, visited))) { return false; } } path.clear(state); visited.set(state); return true; }
/** * Checks whether there is a loop containing state. (This is sufficient since * there are never transitions to dead states.) */ // TODO: not great that this is recursive... in theory a // large automata could exceed java's stack so the maximum level of recursion is bounded to 1000 private static boolean isFinite(Transition scratch, Automaton a, int state, BitSet path, BitSet visited, int level) { if (level > MAX_RECURSION_LEVEL) { throw new IllegalArgumentException("input automaton is too large: " + level); } path.set(state); int numTransitions = a.initTransition(state, scratch); for(int t=0;t<numTransitions;t++) { a.getTransition(state, t, scratch); if (path.get(scratch.dest) || (!visited.get(scratch.dest) && !isFinite(scratch, a, scratch.dest, path, visited, level+1))) { return false; } } path.clear(state); visited.set(state); return true; }
/** * Returns true if the language of this automaton is finite. The * automaton must not have any dead states. */ public static boolean isFinite(Automaton a) { if (a.getNumStates() == 0) { return true; } return isFinite(new Transition(), a, 0, new BitSet(a.getNumStates()), new BitSet(a.getNumStates()), 0); }
/** * Returns true if the language of this automaton is finite. The * automaton must not have any dead states. */ public static boolean isFinite(Automaton a) { if (a.getNumStates() == 0) { return true; } return isFinite(new Transition(), a, 0, new BitSet(a.getNumStates()), new BitSet(a.getNumStates())); }
/** * Returns true if the language of this automaton is finite. The * automaton must not have any dead states. */ public static boolean isFinite(Automaton a) { if (a.getNumStates() == 0) { return true; } return isFinite(new Transition(), a, 0, new BitSet(a.getNumStates()), new BitSet(a.getNumStates())); }
this.finite = Operations.isFinite(automaton); } else { this.finite = finite;
this.finite = Operations.isFinite(automaton); } else { this.finite = finite;
this.finite = Operations.isFinite(automaton); } else { this.finite = finite;