public void WS1SNot()
        {
            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 WS1SUnaryPred("X", solver.MkCharConstraint(false, 'a'));
            WS1SFormula f2 = new WS1SSingleton("X");
            WS1SFormula f  = new WS1SAnd(f1, f2);

            WS1SFormula phi = new WS1SNot(new WS1SExists("X", f));

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

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

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

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

            solver.SaveAsDot(dfa, "aut", file);   //extension .dot  is added automatically when missing
        }
Пример #2
0
        public void TestWS1S_NotLt()
        {
            var solver = new CharSetSolver(BitWidth.BV7);
            var ca     = new CartesianAlgebraBDD <BDD>(solver);
            var x      = new Variable("x", true);
            var y      = new Variable("y", true);
            var fo     = new WS1SSingleton <BDD>(x) & new WS1SSingleton <BDD>(y);
            var aut_fo = fo.GetAutomaton(ca, x, y);
            WS1SFormula <BDD> not_xLTy = new WS1SNot <BDD>(new WS1SLt <BDD>(x, y));

            not_xLTy = new WS1SAnd <BDD>(not_xLTy, fo); //*
            WS1SFormula <BDD> xEQy = new WS1SEq <BDD>(x, y);

            xEQy = new WS1SAnd <BDD>(xEQy, fo); //*
            var yGTx         = new WS1SLt <BDD>(y, x);
            var xEQy_or_yGTx = new WS1SAnd <BDD>(new WS1SOr <BDD>(xEQy, yGTx), fo);
            var aut_not_xLTy = not_xLTy.GetAutomaton(ca, x, y);
            var B            = xEQy_or_yGTx.GetAutomaton(ca, x, y);
            var c_aut_xLTy   = (new WS1SLt <BDD>(x, y)).GetAutomaton(ca, x, y).Complement(ca).Determinize(ca).Minimize(ca);
            //c_aut_xLTy = c_aut_xLTy.Intersect(aut_fo, ca).Determinize(ca).Minimize(ca); //*
            //aut_not_xLTy.ShowGraph("aut_not_xLTy");
            //B.ShowGraph("x_geq_y");
            //c_aut_xLTy.ShowGraph("c_aut_xLTy");
            var equiv1 = aut_not_xLTy.IsEquivalentWith(B, ca);

            //var equiv2 = aut_not_xLTy.IsEquivalentWith(c_aut_xLTy, ca);
            Assert.IsTrue(equiv1);
            //Assert.IsTrue(equiv2);
        }
Пример #3
0
 public void TestWS1S_Member()
 {
     var solver            = new CharSetSolver(BitWidth.BV7);
     var ca                = new CartesianAlgebraBDD <BDD>(solver);
     var x                 = new Variable("x", false);
     var y                 = new Variable("y", false);
     var fo_x              = new WS1SSingleton <BDD>(x);
     WS1SFormula <BDD> xSy = new WS1SSubset <BDD>(x, y);
     var mem               = new WS1SAnd <BDD>(xSy, fo_x);
     var aut_mem           = mem.GetAutomaton(ca, x, y);
     //aut_mem.ShowGraph("aut_mem");
 }
Пример #4
0
        public void TestWS1S_Equal()
        {
            var solver             = new CharSetSolver(BitWidth.BV7);
            var ca                 = new CartesianAlgebraBDD <BDD>(solver);
            var x                  = new Variable("x", false);
            var y                  = new Variable("y", false);
            var fo_x               = new WS1SSingleton <BDD>(x);
            var fo_y               = new WS1SSingleton <BDD>(y);
            WS1SFormula <BDD> fo   = fo_x & fo_y;
            WS1SFormula <BDD> xSy  = new WS1SSubset <BDD>(x, y);
            WS1SFormula <BDD> ySx  = new WS1SSubset <BDD>(y, x);
            WS1SFormula <BDD> yEQx = xSy & ySx;

            yEQx = yEQx & fo;
            var aut_yEQx = yEQx.GetAutomaton(ca, x, y);
            //aut_yEQx.ShowGraph("aut_yEQx");
        }
Пример #5
0
 public void TestWS1S_NotLabel()
 {
     var solver = new CharSetSolver(BitWidth.BV7);
     //var x1 = new Variable("x1", false);
     var x    = new Variable("x", false);
     var pred = new WS1SPred <BDD>(solver.MkCharConstraint('c'), x);
     var fo_x = new WS1SSingleton <BDD>(x);
     var ca   = new CartesianAlgebraBDD <BDD>(solver);
     var lab  = new WS1SAnd <BDD>(pred, fo_x);
     WS1SFormula <BDD> not_lab = new WS1SNot <BDD>(lab);
     var not_lab_actual        = new WS1SAnd <BDD>(not_lab, fo_x);
     var aut_not_lab           = not_lab_actual.GetAutomaton(ca, x);
     var aut_not_lab_prelim    = not_lab.GetAutomaton(ca, x);
     var c_aut_lab             = lab.GetAutomaton(ca, x).Complement(ca).Minimize(ca);
     //c_aut_lab.ShowGraph("c_aut_lab");
     //aut_not_lab.ShowGraph("aut_not_lab");
     //aut_not_lab_prelim.ShowGraph("aut_not_lab_prelim");
     //TBD: equivalence
 }
        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));
        }