Exemplo n.º 1
0
        public void TestWS1S_GetAutomatonBDD_eq_GetAutomaton()
        {
            var solver        = new CharSetSolver(BitWidth.BV7);
            var nrOfLabelBits = (int)BitWidth.BV7;
            var isDigit       = solver.MkCharSetFromRegexCharClass(@"\d");
            var isLetter      = solver.MkCharSetFromRegexCharClass(@"(c|C)");
            var x             = new Variable("x", false);
            var y             = new Variable("y", false);
            var z             = new Variable("z", false);
            var X             = new Variable("X", false);
            //there are at least two distinct positions x and y
            var xy = (new WS1SNot <BDD>(new WS1SEq <BDD>(x, y)) & new WS1SSingleton <BDD>(x) & new WS1SSingleton <BDD>(y));
            //there is a set X containing x and y and all positions z in X have characters that satisfy isWordLetter
            var x_sub_X    = new WS1SSubset <BDD>(x, X);
            var y_sub_X    = new WS1SSubset <BDD>(y, X);
            var z_sub_X    = new WS1SSubset <BDD>(z, X);
            var isletter_z = new WS1SPred <BDD>(isLetter, z);
            var psi        = new WS1SExists <BDD>(X, (x_sub_X & y_sub_X & ~(new WS1SExists <BDD>(z, ~(~(new WS1SSingleton <BDD>(z) & z_sub_X) | isletter_z)))));

            var atLeast2w   = xy & psi;
            var atLeast2wEE = new WS1SExists <BDD>(x, (new WS1SExists <BDD>(y, atLeast2w)));
            var autBDD      = atLeast2w.GetAutomatonBDD(solver, nrOfLabelBits, x, y);
            var ca          = new CartesianAlgebraBDD <BDD>(solver);
            var autPROD     = atLeast2w.GetAutomaton(ca, x, y);
            //autBDD.ShowGraph("autBDD");
            //autPROD.ShowGraph("autPROD");
            var aut_atLeast2wEE1 = BasicAutomata.Restrict(atLeast2wEE.GetAutomaton(ca));
            var aut_atLeast2wEE2 = atLeast2wEE.GetAutomatonBDD(solver, nrOfLabelBits);

            //aut_atLeast2wEE1.ShowGraph("aut_atLeast2wEE1");
            //aut_atLeast2wEE2.ShowGraph("aut_atLeast2wEE2");
            Assert.IsTrue(aut_atLeast2wEE1.IsEquivalentWith(aut_atLeast2wEE2, solver));
        }
Exemplo n.º 2
0
        public void TestWS1S_SuccDef_GetAutomatonBDD()
        {
            var solver        = new CharSetSolver(BitWidth.BV7);
            var nrOfLabelBits = (int)BitWidth.BV7;
            var x             = new Variable("x", true);
            var y             = new Variable("y", true);
            var z             = new Variable("z", true);
            var xLTy          = new WS1SLt <BDD>(x, y);
            var xLTzLTy       = (new WS1SLt <BDD>(x, z)) & (new WS1SLt <BDD>(z, y));
            var Ez            = new WS1SExists <BDD>(z, xLTzLTy);
            var notEz         = new WS1SNot <BDD>(Ez);
            var xSyDef        = new WS1SAnd <BDD>(xLTy, notEz);

            var aut_xSyDef  = xSyDef.GetAutomatonBDD(solver, nrOfLabelBits, x, y);
            var aut_xLTzLTy = xLTzLTy.GetAutomatonBDD(solver, nrOfLabelBits, x, y, z);
            var aut_Ez      = Ez.GetAutomatonBDD(solver, nrOfLabelBits, x, y).Determinize(solver).Minimize(solver);
            var aut_notEz   = notEz.GetAutomatonBDD(solver, nrOfLabelBits, x, y);
            var aut_xLTy    = xLTy.GetAutomatonBDD(solver, nrOfLabelBits, x, y);

            //aut_xSyDef.ShowGraph("aut_xSyDEf");
            //aut_xLTzLTy.ShowGraph("aut_xLTzLTy");
            //aut_Ez.ShowGraph("aut_Ez");
            //aut_notEz.ShowGraph("aut_notEz");

            var xSyPrim     = new WS1SSuccN <BDD>(x, y, 1);
            var aut_xSyPrim = xSyPrim.GetAutomatonBDD(solver, nrOfLabelBits, x, y);
            var equiv       = aut_xSyPrim.IsEquivalentWith(aut_xSyDef, solver);

            Assert.IsTrue(equiv);
        }