/// <summary> /// Checks that an automaton has no detached states that are unreachable /// from the initial state. /// </summary> public static void AssertNoDetachedStates(Automaton a) { int numStates = a.GetNumberOfStates(); a.ClearNumberedStates(); // force recomputation of cached numbered states Debug.Assert(numStates == a.GetNumberOfStates(), "automaton has " + (numStates - a.GetNumberOfStates()) + " detached states"); }
/// <summary> /// Checks that an automaton has no detached states that are unreachable /// from the initial state. /// </summary> public static void AssertNoDetachedStates(Automaton a) { int numStates = a.GetNumberOfStates(); a.ClearNumberedStates(); // force recomputation of cached numbered states if (Debugging.AssertsEnabled) { Debugging.Assert(numStates == a.GetNumberOfStates(), "automaton has {0} detached states", numStates - a.GetNumberOfStates()); } }
/// <summary> /// Returns <c>true</c> if the language of this automaton is finite. /// </summary> public static bool IsFinite(Automaton a) { if (a.IsSingleton) { return(true); } return(IsFinite(a.initial, new OpenBitSet(a.GetNumberOfStates()), new OpenBitSet(a.GetNumberOfStates()))); }
public virtual void TestAgainstBrzozowski() { int num = AtLeast(200); for (int i = 0; i < num; i++) { Automaton a = AutomatonTestUtil.RandomAutomaton(Random); AutomatonTestUtil.MinimizeSimple(a); Automaton b = (Automaton)a.Clone(); MinimizationOperations.Minimize(b); Assert.IsTrue(BasicOperations.SameLanguage(a, b)); Assert.AreEqual(a.GetNumberOfStates(), b.GetNumberOfStates()); Assert.AreEqual(a.GetNumberOfTransitions(), b.GetNumberOfTransitions()); } }