示例#1
0
        public static IReverse[] GenerateDoubleReverses() {
            var automats = KnownAutomat.GetTypes<IReverse>();
            var ret = new List<IReverse>(automats.Count());

            foreach (var a in automats)
                ret.Add((IReverse)((IReverse)a.Reverse()).Reverse());

            return ret.ToArray();
        }
示例#2
0
        public static IAutomat[] GenerateKleeneStern() {
            var automats = KnownAutomat.GetTypes<IKleeneStern>();
            var ret = new List<IAutomat>(automats.Count());

            foreach (var a in automats)
                ret.Add(a.KleeneStern());

            return ret.ToArray();
        }
示例#3
0
        public static IAutomat[] GenerateComplements() {
            var automats = KnownAutomat.GetTypes<IComplement>();
            var ret = new List<IAutomat>(automats.Count);

            foreach (var a in automats)
                ret.Add(a.Complement());

            return ret.ToArray();
        }
示例#4
0
        public static IAcceptWord[] GenerateConcats() {
            var automats = KnownAutomat.GetTypes<IConcat>();
            var ret = new List<IAcceptWord>(automats.Count * automats.Count);

            foreach (var a1 in automats)
                foreach (var a2 in automats)
                    try {
                        ret.Add(a1.Concat(a2));
                    } catch (System.NotSupportedException) { } catch (System.NotImplementedException) { }
            return ret.ToArray();
        }
示例#5
0
 public static void TestDFAPumpbar() {
     var dfas = KnownAutomat.GetDFAModels();
     foreach (var dfa in dfas) {
         for (int i = 0; i < 10; i++) {
             var rnd = Serpen.Uni.Utils.RND.Next(1, 20);
             var pb = PumpingLemma.TestPumpbar(dfa, rnd);
             if (pb != PumpResult.Pumpable) {
                 System.Console.WriteLine($"Not {rnd}-pumpbar {pb} {dfa}");
             }
         }
     }
 }
示例#6
0
        /// <summary>
        /// Returns a list of all KnowAutomat NEA_ Fields, current not dyn methods
        /// </summary>
        /// <returns></returns>
        public static Finite.NFA[] GetNFAModels(int randomCount = RND_AUTOMAT_COUNT)
        {
            var list = GetTypes <Finite.NFA>();

            list.Add(KnownAutomat.NEA_XlastIsOne(5));

            for (int i = 0; i < randomCount; i++)
            {
                list.Add(Finite.NFA.GenerateRandom());
            }

            return(list.ToArray());
        }
示例#7
0
        public static void TestMinimizedDeaIsMHCount() {
            var dfas = KnownAutomat.GetDFAModels();
            foreach (var dfa in dfas) {
                DFA dmin = ((DFA)dfa.PurgeStates()).Minimize();
                var mheqs = dfa.FindMNEqClasses();
                if (dmin.StatesCount != mheqs.Count) {
                    dmin.SaveAutomatImageToTemp();
                    Utils.DebugMessage($"DFA min {dmin.StatesCount} != MH {mheqs.Count}", dfa, Uni.Utils.eDebugLogLevel.Always);
                    dmin = null;
                }

            }
        }
示例#8
0
        /// <summary>
        /// Returns a list of all KnowAutomat DEA_ Fields, current not dyn methods
        /// </summary>
        /// <returns></returns>
        public static Finite.DFA[] GetDFAModels(int randomCount = RND_AUTOMAT_COUNT)
        {
            var list = GetTypes <Finite.DFA>();

            list.Add(KnownAutomat.DEA_BinFreq(3, 5));
            list.Add(KnownAutomat.DEA_ContainsOnes(6));
            list.Add(KnownAutomat.DEA_EndsWithNulls(4));

            for (int i = 0; i < randomCount; i++)
            {
                list.Add(Finite.DFA.GenerateRandom());
            }
            return(list.ToArray());
        }
示例#9
0
        public static IAutomat[] GenerateIntersects() {
            var automats = KnownAutomat.GetTypes<IIntersect>();
            var ret = new List<IAutomat>(automats.Count() * automats.Count());

            foreach (var a1 in automats)
                foreach (var a2 in automats)
                    if (a1.GetType() == a2.GetType())
                        if (a1.SameAlphabet(a2))
                            try {
                                ret.Add(a1.Intersect(a2));
                            } catch (System.NotImplementedException) { }

            return ret.ToArray();
        }
示例#10
0
        public static IAcceptWord[] GenerateUnions() {
            var automats = KnownAutomat.GetTypes<IUnion>();
            var ret = new List<IAcceptWord>(automats.Count() * automats.Count());

            foreach (var a1 in automats)
                foreach (var a2 in automats)
                    if (a1.GetType() == a2.GetType())
                        if (a1.SameAlphabet(a2))
                            try {
                                ret.Add(a1.Union(a2));
                            } catch (System.NotImplementedException) { } catch (System.NotSupportedException) { }


            return ret.ToArray();
        }
示例#11
0
        public static IAcceptWord[] GenerateJoins() {
            var automats = KnownAutomat.GetTypes<IJoin>();
            var ret = new List<IAcceptWord>(automats.Count * automats.Count);

            foreach (var a1 in automats)
                foreach (var a2 in automats)
                    if (a1.GetType() == a2.GetType())
                        if (!(a1 is DFA d) || a1.SameAlphabet(a2)) {
                            try {
                                ret.Add(a1.Join(a2));
                            } catch (System.NotImplementedException) { } catch (System.NotSupportedException) { } // because of SPDA
                        }

            return ret.ToArray();
        }
示例#12
0
 public static void AllChomskeyAlgEquals() {
     foreach (CFGrammer cfg in KnownAutomat.GetCFGs(1000))
         TestEqualWithWords(cfg.ToChomskyNF(AlgSourceMode.K1659), cfg.ToChomskyNF(AlgSourceMode.EAFK));
 }
示例#13
0
 public static IAcceptWord[][] CastToEveryPossibility() => CastToEveryPossibility(KnownAutomat.GetAllAutomats());
示例#14
0
 public static void ExportAllAutomatBitmaps() => ExportAllAutomatBitmaps(KnownAutomat.GetAllAutomats());