public void MSOFirstLastSucc() { 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 first = new MSOFirst("x"); MSOFormula last = new MSOLast("y"); MSOFormula succ = new MSOSucc("x", "y"); MSOFormula and = new MSOAnd(new MSOAnd(first, last), succ); MSOFormula formula = new MSOExistsFO("x", new MSOExistsFO("y", and)); Assert.IsTrue(formula.CheckUseOfVars()); var dfa = formula.getDFA(al, solver); var test = solver.Convert(@"^(a|b){2}$"); Assert.IsTrue(dfa.IsEquivalentWith(test, solver)); string file = "../../../MSOZ3Test/DotFiles/ab"; solver.SaveAsDot(dfa, "aut", file); //extension .dot is added automatically when missing }
public void MSOLe() { 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. all y. x<=y and a(x) MSOFormula formula = new MSOExistsFO("x", new MSOAnd( new MSOLabel("x", 'a'), new MSOForallFO("y", new MSOOr( new MSOEqual("x", "y"), new MSOLess("y", "x"))))); Assert.IsTrue(formula.CheckUseOfVars()); var dfa = formula.getDFA(al, solver); var test = solver.Convert(@"^(a|b)*a$"); Assert.IsTrue(dfa.IsEquivalentWith(test, solver)); string file = "../../../MSOZ3Test/DotFiles/endsina"; solver.SaveAsDot(dfa, "aut", file); //extension .dot is added automatically when missing }
public override MSOFormula ToMSO(FreshGen fg, string V) { int c = fg.get(); string x = "_x_" + c.ToString(); string y = "_y_" + c.ToString(); string X = "_X_" + c.ToString(); int i = str.Length - 1; string z_i, z_im; MSOFormula phi = null; phi = new MSOLabel("z0", str[0]); while (i > 0) { z_i = "z" + i.ToString(); z_im = "z" + (i - 1).ToString(); phi = new MSOExistsFO(z_i, new MSOAnd(new MSOSucc(z_im, z_i), new MSOAnd(new MSOLabel(z_i, str[i]), phi))); i--; } return(new MSOForallFO("z0", new MSOIff(new MSOBelong("z0", V), phi))); }
public void MSO2a2b() { 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); MSOFormula formula1 = new MSOExistsFO("x1", new MSOExistsFO("x2", new MSOAnd( new MSOAnd( new MSOLabel("x1", 'a'), new MSOLabel("x2", 'a')), new MSONot( new MSOEqual("x1", "x2"))))); MSOFormula formula2 = new MSOExistsFO("x1", new MSOExistsFO("x2", new MSOAnd( new MSOAnd( new MSOLabel("x1", 'b'), new MSOLabel("x2", 'b')), new MSONot( new MSOEqual("x1", "x2"))))); MSOFormula formula = new MSOAnd(formula1, formula2); Assert.IsTrue(formula.CheckUseOfVars()); var WS1S = formula.ToWS1S(solver); var dfa = WS1S.getDFA(al, solver); var timer = new Stopwatch(); var tt = 100; var acc = 0L; for (int k = 0; k < tt; k++) { timer.Reset(); timer.Start(); dfa = WS1S.getDFA(al, solver); timer.Stop(); acc += timer.ElapsedMilliseconds; } Console.WriteLine("time: " + acc / tt + " ms"); //var test = solver.Convert(@"^(a|b)$"); //Assert.IsTrue(dfa.IsEquivalentWith(test, solver)); string file = "../../../MSOZ3Test/DotFiles/a2b2"; solver.SaveAsDot(dfa, "aut", file); //extension .dot is added automatically when missing }
public override MSOFormula ToMSO(FreshGen fg, string v) { switch (op) { case PDLStringPosOperator.FirstOcc: { int i = str.Length - 1; string z_i, z_im; MSOFormula phi = null; //new MSOForallFO("x", new MSOEqual("x", "x")); //TODO make sure input string is non empty that is i/=0 phi = new MSOLabel("z0", str[0]); while (i > 0) { z_i = "z" + i.ToString(); z_im = "z" + (i - 1).ToString(); phi = new MSOExistsFO(z_i, new MSOAnd(new MSOSucc(z_im, z_i), new MSOAnd(new MSOLabel(z_i, str[i]), phi))); i--; } return(new MSOAnd(new MSOForallFO("z0", new MSOIf(phi, new MSOLessEq(v, "z0"))), new MSOExistsFO("z0", new MSOAnd(phi, new MSOEqual(v, "z0"))))); } case PDLStringPosOperator.LastOcc: { int i = str.Length - 1; string z_i, z_im; MSOFormula phi = null; //new MSOForallFO("x", new MSOEqual("x", "x")); //TODO make sure input string is non empty that is i/=0 phi = new MSOLabel("z0", str[0]); while (i > 0) { z_i = "z" + i.ToString(); z_im = "z" + (i - 1).ToString(); phi = new MSOExistsFO(z_i, new MSOAnd(new MSOSucc(z_im, z_i), new MSOAnd(new MSOLabel(z_i, str[i]), phi))); i--; } return(new MSOAnd(new MSOForallFO("z0", new MSOIf(phi, new MSOLessEq("z0", v))), new MSOExistsFO("z0", new MSOAnd(phi, new MSOEqual(v, "z0"))))); } default: throw new PDLException("undefined operator"); } }
public override MSOFormula Contains(FreshGen fg, string v) { string zi, ziPrev, z0 = "_z0"; int i = str.Length - 1; MSOFormula phi = new MSOTrue(); while (i > 0) { zi = "_z" + i.ToString(); ziPrev = "_z" + (i - 1).ToString(); phi = new MSOExistsFO(zi, new MSOAnd(phi, new MSOAnd(new MSOLabel(zi, str[i]), new MSOSucc(ziPrev, zi)))); i--; } phi = new MSOExistsFO(z0, new MSOAnd(phi, new MSOAnd(new MSOLabel(z0, str[0]), new MSOEqual(z0, v)))); return(phi); }