Пример #1
0
        /// <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");
        }
Пример #2
0
        /// <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());
            }
        }
Пример #3
0
 /// <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())));
 }
Пример #4
0
        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());
            }
        }