当前位置: 首页>>代码示例>>C#>>正文


C# CharSetSolver.Convert方法代码示例

本文整理汇总了C#中CharSetSolver.Convert方法的典型用法代码示例。如果您正苦于以下问题:C# CharSetSolver.Convert方法的具体用法?C# CharSetSolver.Convert怎么用?C# CharSetSolver.Convert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CharSetSolver的用法示例。


在下文中一共展示了CharSetSolver.Convert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: YieldTypeChecker

        static YieldTypeChecker()
        {
            yieldTypeCheckerAutomatonSolver = new CharSetSolver(BitWidth.BV7);
            yieldTypeCheckerAutomaton =
                Automaton<BvSet>.MkProduct(yieldTypeCheckerAutomatonSolver.Convert(yieldTypeCheckerRegex),
                                           yieldTypeCheckerAutomatonSolver.Convert(@"^[1-9A-D]*$"), // result of product with this Automaton provides us 
                //an automaton that has (*) existence alphanum chars in our property automaton 
                                           yieldTypeCheckerAutomatonSolver);

            minimizedTypeCheckerAutomaton = yieldTypeCheckerAutomaton.Determinize(yieldTypeCheckerAutomatonSolver).Minimize(yieldTypeCheckerAutomatonSolver);
#if DEBUG && !DEBUG_DETAIL
            yieldTypeCheckerAutomatonSolver.ShowGraph(minimizedTypeCheckerAutomaton, "minimizedPropertyAutomaton.dgml");
#endif
        }
开发者ID:Chenguang-Zhu,项目名称:ICE-C5,代码行数:14,代码来源:YieldTypeChecker.cs

示例2: intEq2

        public void intEq2()
        {
            var solver = new CharSetSolver(BitWidth.BV64);

            List<char> alph = new List<char> { 'a', 'b', 'c' };
            HashSet<char> al = new HashSet<char>(alph);

            PDLPred phi = new PDLIntEq(new PDLAllPos(), 2);

            StringBuilder sb = new StringBuilder();


            phi.ToMSO(new FreshGen()).ToString(sb);

            System.Console.WriteLine(sb);

            var dfa = phi.GetDFA(al, solver);

            var test = solver.Convert(@"^(a|b|c){2}$");

            Assert.IsTrue(dfa.IsEquivalentWith(test, solver));

            ////string file = "../../../TestPDL/DotFiles/IntEq2";

            //solver.SaveAsDot(dfa, "aut", file);

        }
开发者ID:AutomataTutor,项目名称:automatatutor-backend,代码行数:27,代码来源:PDLTest.cs

示例3: MoveSequence

 public MoveSequence(string regex)
 {
     solver = new CharSetSolver(BitWidth.BV7);
     moveAutomaton = solver.Convert("^(" + regex + ")$").Determinize(solver).Minimize(solver);
     currentState = 0;
     //solver.ShowGraph(moveAutomaton, "D");
     //ComputeDeadStates();
 }
开发者ID:mhusinsky,项目名称:prepose,代码行数:8,代码来源:MoveSequence.cs

示例4: TestLoopThatStartsWith0

 public void TestLoopThatStartsWith0()
 {
     string regex = @"(w(a|bc){0,2})";
     CharSetSolver css = new CharSetSolver(BitWidth.BV7);
     var aut = css.Convert(regex,RegexOptions.Singleline,true);
     //css.ShowGraph(aut, "CornerCase");
     var str = "w.-J_";
     var actual = css.Accepts(aut, str);
     var expected = Regex.IsMatch(str, regex);
     Assert.AreEqual(expected, actual);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:11,代码来源:MiscRegexConversionTests.cs

示例5: Main

        static void Main(string[] args)
        {
            HashSet<char> al = new HashSet<char>(new char[]{'a','b'});
            CharSetSolver solver = new CharSetSolver(BitWidth.BV64);
            string rexpr = "a|b";

            var escapedRexpr = string.Format("^{0}$", rexpr);
            Automaton<BDD> aut = null;
            try
            {
                aut = solver.Convert(escapedRexpr);
            }
            catch (AutomataException e)
            {
                throw new PDLException("The input is not a well formatted regular expression."+e.Message);
            }

            var diff = aut.Minus(solver.Convert("^c$"), solver);
            if (!diff.IsEmpty)
                throw new PDLException("The regular expression should only accept strings over (a|b)*.");

            var auttt =  new Pair<HashSet<char>, Automaton<BDD>>(al, aut);
        }
开发者ID:AutomataTutor,项目名称:automatatutor-backend,代码行数:23,代码来源:Program.cs

示例6: TestNFA2

 public void TestNFA2()
 {
     CharSetSolver solver = new CharSetSolver(BitWidth.BV7);
     var a = solver.MkCharConstraint('a');
     var na = solver.MkNot(a);
     var nfa = Automaton<BDD>.Create(solver, 0, new int[] { 1 }, new Move<BDD>[] { new Move<BDD>(0, 1, solver.True), new Move<BDD>(0, 2, solver.True), new Move<BDD>(2, 1, solver.True), new Move<BDD>(1, 1, a), new Move<BDD>(1, 2, na) });
     var min_nfa = nfa.Minimize();
     nfa.isDeterministic = true; //pretend that nfa is equivalent, causes the deterministic version to be executed that provides the wrong result
     var min_nfa_wrong = nfa.Minimize();
     nfa.isDeterministic = false;
     min_nfa_wrong.isDeterministic = false;
     //min_nfa.ShowGraph("min_nfa");
     //min_nfa_wrong.ShowGraph("min_nfa_wrong");
     //min_nfa.Determinize().Minimize().ShowGraph("min_nfa1");
     //nfa.Determinize().Minimize().ShowGraph("dfa");
     //nfa.ShowGraph("nfa");
     //min_nfa_wrong.Determinize().Minimize().ShowGraph("min_nfa2");
     Assert.IsFalse(min_nfa.IsEquivalentWith(min_nfa_wrong));
     Assert.IsTrue(min_nfa.IsEquivalentWith(nfa));
     //concrete witness "abab" distinguishes nfa from min_nfa_wrong
     Assert.IsTrue(solver.Convert("^abab$").Intersect(nfa).IsEmpty);
     Assert.IsFalse(solver.Convert("^abab$").Intersect(min_nfa_wrong).IsEmpty);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:23,代码来源:MinimizationTests.cs

示例7: EDTest2

        public void EDTest2()
        {
            CharSetSolver solver = new CharSetSolver();
            string a = "aa";

            var aut = solver.Convert("^(a|b){3}$").Determinize().Minimize();

            int dist;
            var output = EditDistance.GetClosestElement(a, aut, solver, out dist);

            Console.WriteLine("string: {0}, distance: {1}", output, dist);
            Assert.IsTrue(dist == 1);

            output = EditDistance.GetClosestElement("bc", aut, solver, out dist);
            Console.WriteLine("string: {0}, distance: {1}", output, dist);
            Assert.IsTrue(dist == 2);
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:17,代码来源:EditDistanceTest.cs

示例8: EDTestNew

        public void EDTestNew()
        {
            CharSetSolver solver = new CharSetSolver();
            string a = "absabaasd";

            var aut = solver.Convert("^((ab|b){1,2}cc)*$").Determinize().Minimize();

            int dist;
            var output = EditDistance.GetClosestElement(a, aut, solver, out dist);

            Console.WriteLine("string: {0}, distance: {1}", output, dist);
            Assert.IsTrue(dist == 5);

            output = EditDistance.GetClosestElement("aba", aut, solver, out dist);
            Console.WriteLine("string: {0}, distance: {1}", output, dist);
            Assert.IsTrue(dist == 2);
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:17,代码来源:EditDistanceTest.cs

示例9: WS1SSingleton

        public void WS1SSingleton()
        {
            var solver = new CharSetSolver(BitWidth.BV64);  //new solver using ASCII encoding

            List<char> alph = new List<char> { 'a', 'b' };
            HashSet<char> al = new HashSet<char>(alph);

            WS1SFormula f1 = new WS1SSingleton("X");
            WS1SFormula phi = new WS1SExists("X", f1);

            var dfa = phi.getDFA(al, solver);

            var test = solver.Convert(@"^(a|b)+$").Determinize(solver).Minimize(solver);

            string file = "../../../MSOZ3Test/DotFiles/singletona";

            solver.SaveAsDot(dfa, "aut", file);   //extension .dot  is added automatically when missing

            Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
        }
开发者ID:AutomataTutor,项目名称:automatatutor-backend,代码行数:20,代码来源:EMSOTest.cs

示例10: FirstLast

        public void FirstLast()
        {
            var solver = new CharSetSolver(BitWidth.BV64);

            List<char> alph = new List<char> { 'a', 'b' };
            HashSet<char> al = new HashSet<char>(alph);

            PDLPred phi = new PDLIsSuccessor(new PDLFirst(), new PDLLast());

            var dfa = phi.GetDFA(al, solver);

            var test = solver.Convert(@"^(a|b){2}$");

            Assert.IsTrue(dfa.IsEquivalentWith(test, solver));

            //string file = "../../../TestPDL/DotFiles/FirstLast";

            //solver.SaveAsDot(dfa, "aut", file);

        }
开发者ID:AutomataTutor,项目名称:automatatutor-backend,代码行数:20,代码来源:PDLTest.cs

示例11: Exists

        public void Exists()
        {
            var solver = new CharSetSolver(BitWidth.BV64);

            List<char> alph = new List<char> { 'a', 'b' };
            HashSet<char> al = new HashSet<char>(alph);

            PDLPred phi = new PDLExistsFO("x", new PDLAtPos('a', new PDLPosVar("x")));

            var dfa = phi.GetDFA(al, solver);

            var test = solver.Convert(@"^b*a(a|b)*$");

            Assert.IsTrue(dfa.IsEquivalentWith(test, solver));

            ////string file = "../../../TestPDL/DotFiles/exists";

            ////solver.SaveAsDot(dfa, "aut", file);

        }
开发者ID:AutomataTutor,项目名称:automatatutor-backend,代码行数:20,代码来源:PDLTest.cs

示例12: TestC4Cregexes

 //[TestMethod]
 public void TestC4Cregexes()
 {
     string[] regexes = File.ReadAllLines(@"..\..\..\Samples\C4C\mathiasbynens_url_regex.txt");
     CharSetSolver css = new CharSetSolver(BitWidth.BV7);
     var notsupportedcases = new HashSet<int>(new int[] {
       1, //uses require (?=)
       4, //uses prevent (?!)
       9, //uses lazy a*?
       11, //uses prevent (?!)
     });
     for (int i = 0; i < regexes.Length; i++)
     {
         if (!notsupportedcases.Contains(i))
         {
             string regex = regexes[i];
             var aut = css.Convert(regex);
             CheckValidity(css, aut, new Regex(regex, RegexOptions.Singleline));
         }
     }
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:21,代码来源:MiscRegexConversionTests.cs

示例13: WS1SSucc

        public void WS1SSucc()
        {
            var solver = new CharSetSolver(BitWidth.BV64);  //new solver using ASCII encoding

            List<char> alph = new List<char> { 'a', 'b' };
            HashSet<char> al = new HashSet<char>(alph);

            WS1SFormula f3 = new WS1SSucc("X", "Y");

            WS1SFormula phi = new WS1SExists("X", new WS1SExists("Y", f3));

            var dfa = phi.getDFA(al, solver);

            var test = solver.Convert(@"^(a|b){2,}$");

            string file = "../../../MSOZ3Test/DotFiles/containsab";

            solver.SaveAsDot(dfa, "aut", file);   //extension .dot  is added automatically when missing

            Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
        }
开发者ID:AutomataTutor,项目名称:automatatutor-backend,代码行数:21,代码来源:EMSOTest.cs

示例14: SCCTest1

        public void SCCTest1()
        {
            CharSetSolver solver = new CharSetSolver();

            var aut = solver.Convert("^a(ab)*$").Determinize().Minimize();

            var sccs = GraphAlgorithms.GetStronglyConnectedComponents(aut);
            List<int> total = new List<int>();
            foreach (var scc in sccs)
            {
                Console.WriteLine();
                foreach (var st in scc)
                {
                    total.Add(st);
                    Console.Write(st + ",");
                }
            }

            Assert.IsTrue(sccs.ToArray().Length == 2);
            Assert.IsTrue(total.Count == aut.StateCount);
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:21,代码来源:SCCTest.cs

示例15: MSOLast

        public void MSOLast()
        {
            var solver = new CharSetSolver(BitWidth.BV64);  //new solver using ASCII encoding

            List<char> alph = new List<char> { 'a', 'b' };
            HashSet<char> al = new HashSet<char>(alph);

            //ex x. first(x)
            MSOFormula formula = new MSOExistsFO("x", new MSOLast("x"));

            Assert.IsTrue(formula.CheckUseOfVars());

            var dfa = formula.getDFA(al, solver);

            var test = solver.Convert(@"^(a|b)+$");

            Assert.IsTrue(dfa.IsEquivalentWith(test, solver));

            string file = "../../../MSOZ3Test/DotFiles/exlast";

            solver.SaveAsDot(dfa, "aut", file);   //extension .dot  is added automatically when missing
        }
开发者ID:AutomataTutor,项目名称:automatatutor-backend,代码行数:22,代码来源:MSOTest.cs


注:本文中的CharSetSolver.Convert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。