public void WS1SFormula() { 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 WS1SUnaryPred("Y", solver.MkCharConstraint(false, 'b')); WS1SFormula f3 = new WS1SSucc("X", "Y"); WS1SFormula phi = new WS1SAnd(new WS1SAnd(f1, f2), f3); WS1SFormula psi = new WS1SSucc("Y", "Z"); WS1SFormula formula = new WS1SExists("X", new WS1SExists("Y", new WS1SAnd(phi, new WS1SNot(new WS1SExists("Z", psi))))); StringBuilder sb = new StringBuilder(); formula.ToString(sb); Console.WriteLine(sb.ToString()); var dfa = formula.getDFA(al, solver); var test = solver.Convert(@"^(a|b)*ab$"); string file = "../../../MSOZ3Test/DotFiles/endsinab"; solver.SaveAsDot(dfa, "aut", file); //extension .dot is added automatically when missing Assert.IsTrue(dfa.IsEquivalentWith(test, solver)); }
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 }
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); }
public void TestWS1S_SuccDef_GetAutomaton() { var solver = new CharSetSolver(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 ca = new CartesianAlgebraBDD <BDD>(solver); var aut_xSyDef = xSyDef.GetAutomaton(ca, x, y); var aut_xLTzLTy = xLTzLTy.GetAutomaton(ca, x, y, z); var aut_Ez = Ez.GetAutomaton(ca, x, y); var aut_notEz = notEz.GetAutomaton(ca, x, y); var aut_xLTy = xLTy.GetAutomaton(ca, 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.GetAutomaton(ca, x, y); var equiv = aut_xSyPrim.IsEquivalentWith(aut_xSyDef, ca); Assert.IsTrue(equiv); }
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); }
public void BooleanAlgebraZ3_test2() { var ctx = new Context(); var sort = ctx.IntSort; var solver = new Z3BoolAlg(ctx, sort); var alg = new BDDAlgebra <BoolExpr>(solver); var x = new Variable("x", true); var y = new Variable("y", true); var z = new Variable("z", true); var xLTy = new WS1SLt <BoolExpr>(x, y); var xLTzLTy = (new WS1SLt <BoolExpr>(x, z)) & (new WS1SLt <BoolExpr>(z, y)); var Ez = new WS1SExists <BoolExpr>(z, xLTzLTy); var notEz = new WS1SNot <BoolExpr>(Ez); var xSyDef = new WS1SAnd <BoolExpr>(xLTy, notEz); var aut_xSyDef = xSyDef.GetAutomaton(alg, x, y); var aut_xLTzLTy = xLTzLTy.GetAutomaton(alg, x, y, z); var aut_Ez = Ez.GetAutomaton(alg, x, y); var aut_notEz = notEz.GetAutomaton(alg, x, y); var aut_xLTy = xLTy.GetAutomaton(alg, 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 <BoolExpr>(x, y, 1); var aut_xSyPrim = xSyPrim.GetAutomaton(alg, x, y); var equiv = aut_xSyPrim.IsEquivalentWith(aut_xSyDef, alg); Assert.IsTrue(equiv); }
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"); }
//Automaton<T> Restrict<T>(Automaton<IMonadicPredicate<BDD, T>> autom) //{ // List<Move<T>> moves = new List<Move<T>>(); // foreach (var move in autom.GetMoves()) // moves.Add(new Move<T>(move.SourceState, move.TargetState, move.Label.ProjectSecond())); // var res = Automaton<T>.Create(autom.InitialState, autom.GetFinalStates(), moves); // return res; //} public void TestWS1S_UseOfCharRangePreds <T>(IBoolAlgMinterm <T> solver, T isDigit, T isWordLetter, IRegexConverter <T> regexConverter) { var ca = new CartesianAlgebraBDD <T>(solver); 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 WS1SAnd <T>(new WS1SAnd <T>(new WS1SNot <T>(new WS1SEq <T>(x, y)), new WS1SSingleton <T>(x)), new WS1SSingleton <T>(y)); //there is a set X containing x and y and all positions z in X have characters that satisfy isWordLetter var phi = new WS1SExists <T>(X, new WS1SAnd <T>( new WS1SAnd <T>(new WS1SSubset <T>(x, X), new WS1SSubset <T>(y, X)), new WS1SNot <T>(new WS1SExists <T>(z, new WS1SNot <T>( new WS1SOr <T>(new WS1SNot <T>(new WS1SAnd <T>(new WS1SSingleton <T>(z), new WS1SSubset <T>(z, X))), new WS1SPred <T>(isWordLetter, z))))))); var psi2 = new WS1SAnd <T>(xy, phi); var atLeast2wEE = new WS1SExists <T>(x, new WS1SExists <T>(y, psi2)); var psi1 = new WS1SAnd <T>(new WS1SSingleton <T>(x), new WS1SPred <T>(isDigit, x)); var aut_psi1 = psi1.GetAutomaton(ca, x); //aut_psi1.ShowGraph("SFA(psi1)"); var atLeast1d = new WS1SExists <T>(x, psi1); var psi = new WS1SAnd <T>(atLeast2wEE, atLeast1d); var aut1 = psi.GetAutomaton(ca); //var aut_atLeast1d = atLeast1d.GetAutomaton(solver); var aut2 = regexConverter.Convert(@"\w.*\w", System.Text.RegularExpressions.RegexOptions.Singleline).Intersect(regexConverter.Convert(@"\d"), solver); //aut1.ShowGraph("aut1"); //aut2.ShowGraph("aut2"); bool equiv = aut2.IsEquivalentWith(BasicAutomata.Restrict(aut1), solver); Assert.IsTrue(equiv); //solver.ShowGraph(aut_atLeast1d, "aut_atLeast1d"); var aut_psi2 = psi2.GetAutomaton(ca, x, y); // var aut_atLeast2wEE = atLeast2wEE.GetAutomaton(ca, "x", "y"); // var aut_atLeast2wEE2 = atLeast2wEE.GetAutomaton(solver); //aut_psi2.ShowGraph("SFA(psi2)"); //aut_atLeast2wEE.ShowGraph("aut_atLeast2wEE"); //aut_atLeast2wEE2.ShowGraph("aut_atLeast2wEE2"); //solver.ShowGraph(aut_atLeast2wEE2, "aut_atLeast2wEE2"); }
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 WS1SSubset() { 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 WS1SUnaryPred("Y1", solver.MkCharConstraint(false, 'b')); WS1SFormula f3 = new WS1SUnaryPred("Z", solver.MkCharConstraint(false, 'a')); WS1SFormula f = new WS1SAnd(f1, new WS1SAnd(f2, f3)); WS1SFormula s1 = new WS1SSucc("X", "Y1"); WS1SFormula s2 = new WS1SSucc("Y2", "Z"); WS1SFormula s3 = new WS1SSubset("Y1", "Y2"); WS1SFormula s = new WS1SAnd(new WS1SAnd(s1, s2), s3); WS1SFormula phi = new WS1SExists("X", new WS1SExists("Y1", new WS1SExists("Y2", new WS1SExists("Z", new WS1SAnd(f, s))))); WS1SFormula phit = new WS1SExists("X", new WS1SExists("Y", new WS1SSubset("X", "Y"))); var dd = phit.getDFA(al, solver); //solver.SaveAsDot(phit.getDFA(al, solver), "bla","bla.dot"); var dfa = phi.getDFA(al, solver); var test = solver.Convert(@"^(a|b)*aba(a|b)*$"); Assert.IsTrue(dfa.IsEquivalentWith(test, solver)); string file = "../../../MSOZ3Test/DotFiles/aba"; solver.SaveAsDot(dfa, "aut", file); //extension .dot is added automatically when missing }
public static void MintermTest() { var sw = new Stopwatch(); using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"..\msomintermp1s1.txt")) { for (int size = 2; size < kminterm; size++) { // Tsolve no force var s1 = new CharSetSolver(BitWidth.BV64); var solver = new CartesianAlgebraBDD <BDD>(s1); WS1SFormula <BDD> phi = new WS1STrue <BDD>(); for (int k = 1; k < size; k++) { var leq = new WS1SLt <BDD>(new Variable <BDD>("x" + (k - 1)), new Variable <BDD>("x" + k)); phi = new WS1SAnd <BDD>(phi, leq); } for (int k = 0; k < size; k++) { var axk = new WS1SPred <BDD>(s1.MkBitTrue(k), new Variable <BDD>("x" + k)); phi = new WS1SAnd <BDD>(phi, axk); } for (int k = size - 1; k >= 0; k--) { phi = new WS1SExists <BDD>(new Variable <BDD>("x" + k), phi); } sw.Restart(); for (int t = 0; t < numTests; t++) { phi.GetAutomaton(solver); } sw.Stop(); var t1 = sw.ElapsedMilliseconds; file.WriteLine((double)t1 / numTests); Console.WriteLine((double)t1 / numTests); } } using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"..\msomintermp2s1.txt")) { for (int size = 2; size < kminterm; size++) { // Tsolve force var s1 = new CharSetSolver(BitWidth.BV64); var solver = new CartesianAlgebraBDD <BDD>(s1); WS1SFormula <BDD> phi = new WS1STrue <BDD>(); for (int k = 0; k < size; k++) { var axk = new WS1SPred <BDD>(s1.MkBitTrue(k), new Variable <BDD>("x" + k)); phi = new WS1SAnd <BDD>(phi, axk); } for (int k = size - 1; k >= 0; k--) { phi = new WS1SExists <BDD>(new Variable <BDD>("x" + k), phi); } var t1 = 60000L; if (size <= maxmint) { sw.Restart(); for (int t = 0; t < numTests; t++) { phi.GetAutomaton(solver); } sw.Stop(); t1 = sw.ElapsedMilliseconds; } file.WriteLine((double)t1 / numTests); Console.WriteLine((double)t1 / numTests); } } using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"..\msomintermp1s2.txt")) { for (int size = 2; size < kminterm; size++) { // Tsolve solver 2 var solver = new CharSetSolver(BitWidth.BV64); var alg = new BDDAlgebra <BDD>(solver); WS1SFormula <BDD> phi = new WS1STrue <BDD>(); for (int k = 1; k < size; k++) { var leq = new WS1SLt <BDD>(new Variable <BDD>("x" + (k - 1)), new Variable <BDD>("x" + k)); phi = new WS1SAnd <BDD>(phi, leq); } for (int k = 0; k < size; k++) { var axk = new WS1SPred <BDD>(solver.MkBitTrue(k), new Variable <BDD>("x" + k)); phi = new WS1SAnd <BDD>(phi, axk); } for (int k = size - 1; k >= 0; k--) { phi = new WS1SExists <BDD>(new Variable <BDD>("x" + k), phi); } var t1 = 60000L; sw.Restart(); for (int t = 0; t < numTests; t++) { phi.GetAutomaton(alg); } sw.Stop(); t1 = sw.ElapsedMilliseconds; file.WriteLine((double)t1 / numTests); Console.WriteLine((double)t1 / numTests); } } using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"..\msomintermp2s2.txt")) { for (int size = 2; size < kminterm; size++) { var solver = new CharSetSolver(BitWidth.BV64); var alg = new BDDAlgebra <BDD>(solver); //Tforce sol 2 WS1SFormula <BDD> phi = new WS1STrue <BDD>(); for (int k = 0; k < size; k++) { var axk = new WS1SPred <BDD>(solver.MkBitTrue(k), new Variable <BDD>("x" + k)); phi = new WS1SAnd <BDD>(phi, axk); } for (int k = size - 1; k >= 0; k--) { phi = new WS1SExists <BDD>(new Variable <BDD>("x" + k), phi); } var t1 = 60000L; if (size <= maxmint) { sw.Restart(); for (int t = 0; t < numTests; t++) { phi.GetAutomaton(alg); } sw.Stop(); t1 = sw.ElapsedMilliseconds; } file.WriteLine((double)t1 / numTests); Console.WriteLine((double)t1 / numTests); } } using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"..\msominterm.txt")) { for (int size = 2; size < kminterm; size++) { //Tminterm var solver = new CharSetSolver(BitWidth.BV64); BDD[] predicates = new BDD[size]; solver.GenerateMinterms(); for (int k = 0; k < size; k++) { predicates[k] = solver.MkBitTrue(k); } var t1 = 60000L * numTests; if (size <= maxmint) { sw.Restart(); for (int t = 0; t < numTests; t++) { var mint = solver.GenerateMinterms(predicates).ToList(); } sw.Stop(); t1 = sw.ElapsedMilliseconds; } file.WriteLine((double)t1 / numTests); Console.WriteLine((double)t1 / numTests); } } }
//public static void POPLTestsInt() //{ // var sw = new Stopwatch(); // using (System.IO.StreamWriter file = // new System.IO.StreamWriter(@"..\mso-int.txt")) // { // for (int to = 2; to < kpopl; to++) // { // // T1 // var ctx = new Context(); // var sort = ctx.IntSort; // var solver = new BooleanAlgebraZ3(ctx, sort); // var alg = new BDDAlgebra<BoolExpr>(solver); // var pred = new MSOPredicate<BoolExpr>(ctx.MkEq(solver.x, ctx.MkNumeral(42, sort)), "x"); // WS1SFormula<BoolExpr> phi = new WS1STrue<BoolExpr>(); // for (int k = 1; k < to; k++) // { // var leq = new WS1SLt<BoolExpr>(new Variable<BDD>("x" + (k - 1)), new Variable<BDD>("x" + k)); // phi = new WS1SAnd<BoolExpr>(phi, leq); // } // for (int k = to - 1; k >= 0; k--) // { // phi = new WS1SExists<BoolExpr>(new Variable<BDD>("x" + k), phi); // } // sw.Restart(); // for (int t = 0; t < numTests; t++) // { // phi.GetAutomaton(solver); // } // sw.Stop(); // var t1 = sw.ElapsedMilliseconds; // //T2 // ctx = new Context(); // sort = ctx.IntSort; // solver = new BooleanAlgebraZ3(ctx, sort); // alg = new BDDAlgebra<BoolExpr>(solver); // pred = new MSOPredicate<BoolExpr>(ctx.MkEq(solver.x, ctx.MkNumeral(42, sort)), "x"); // phi = new WS1STrue<BoolExpr>(); // for (int k = 1; k < to; k++) // { // var leq = new WS1SLt<BoolExpr>(new Variable<BDD>("x" + (k - 1)), new Variable<BDD>("x" + k)); // phi = new WS1SAnd<BoolExpr>(phi, leq); // } // for (int k = 0; k < to; k++) // { // var axk = new WS1SPred<BoolExpr>( // ctx.MkLe((IntExpr)solver.x, (IntExpr)ctx.MkNumeral(42+k, sort)), // "x" + k); // phi = new WS1SAnd<BoolExpr>(phi, axk); // } // for (int k = to - 1; k >= 0; k--) // { // phi = new WS1SExists<BoolExpr>(new Variable<BDD>("x" + k), phi); // } // sw.Restart(); // for (int t = 0; t < numTests; t++) // { // phi.GetAutomaton(solver); // } // sw.Stop(); // var t2 = sw.ElapsedMilliseconds; // // T3 // ctx = new Context(); // sort = ctx.IntSort; // solver = new BooleanAlgebraZ3(ctx, sort); // alg = new BDDAlgebra<BoolExpr>(solver); // pred = new MSOPredicate<BoolExpr>(ctx.MkEq(solver.x, ctx.MkNumeral(42, sort)), "x"); // phi = new WS1STrue<BoolExpr>(); // for (int k = 1; k < to; k++) // { // var leq = new WS1SLt<BoolExpr>(new Variable<BDD>("x" + (k - 1)), new Variable<BDD>("x" + k)); // phi = new WS1SAnd<BoolExpr>(phi, leq); // } // for (int k = 0; k < to; k++) // { // var axk = new WS1SPred<BoolExpr>(ctx.MkLe((IntExpr)solver.x, (IntExpr)ctx.MkNumeral(42+k, sort)), new Variable<BDD>("x" + k)); // phi = new WS1SAnd<BoolExpr>(phi, axk); // } // for (int k = to - 1; k >= 0; k--) // { // phi = new WS1SExists<BoolExpr>(new Variable<BDD>("x" + k), phi); // } // var exycy = new WS1SExists<BoolExpr>(new Variable<BDD>("y"), new WS1SPred<BoolExpr>( // ctx.MkLe((IntExpr)solver.x, (IntExpr)ctx.MkNumeral(1000, sort)), new Variable<BDD>("y"))); // phi = new WS1SAnd<BoolExpr>(phi, exycy); // sw.Restart(); // for (int t = 0; t < numTests; t++) // { // phi.GetAutomaton(solver); // } // sw.Stop(); // var t3 = sw.ElapsedMilliseconds; // //T4 // ctx = new Context(); // sort = ctx.IntSort; // solver = new BooleanAlgebraZ3(ctx, sort); // alg = new BDDAlgebra<BoolExpr>(solver); // pred = new MSOPredicate<BoolExpr>(ctx.MkEq(solver.x, ctx.MkNumeral(42, sort)), "x"); // phi = new WS1STrue<BoolExpr>(); // for (int k = 1; k < to; k++) // { // var leq = new WS1SLt<BoolExpr>(new Variable<BDD>("x" + (k - 1)), new Variable<BDD>("x" + k)); // var axk = new WS1SPred<BoolExpr>(ctx.MkLe((IntExpr)solver.x, (IntExpr)ctx.MkNumeral(42+k, sort)), new Variable<BDD>("x" + (k - 1))); // var cxk = new WS1SPred<BoolExpr>(ctx.MkLe((IntExpr)solver.x, (IntExpr)ctx.MkNumeral(1000, sort)), new Variable<BDD>("x" + (k - 1))); // var inter = new WS1SOr<BoolExpr>(new WS1SAnd<BoolExpr>(leq, axk), cxk); // phi = new WS1SAnd<BoolExpr>(phi, inter); // } // for (int k = to - 1; k >= 0; k--) // { // phi = new WS1SExists<BoolExpr>(new Variable<BDD>("x" + k), phi); // } // exycy = new WS1SExists<BoolExpr>(new Variable<BDD>("y"), new WS1SPred<BoolExpr>( // ctx.MkLe((IntExpr)solver.x, (IntExpr)ctx.MkNumeral(1000, sort)), // "y")); // phi = new WS1SAnd<BoolExpr>(phi, exycy); // var t4 = 60000L * numTests; // if (to <= maxmphipop) // { // sw.Restart(); // for (int t = 0; t < numTests; t++) // { // phi.GetAutomaton(solver); // } // sw.Stop(); // t4 = sw.ElapsedMilliseconds; // } // file.WriteLine(to + "," + (double)t1 / numTests + "," + (double)t2 / numTests + "," + (double)t3 / numTests + "," + (double)t4 / numTests); // Console.WriteLine(to + "," + (double)t1 / numTests + "," + (double)t2 / numTests + "," + (double)t3 / numTests + "," + (double)t4 / numTests); // } // } //} public static void POPLTestsOld() { var sw = new Stopwatch(); using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"..\msobddold.txt")) { for (int to = 2; to < kpopl; to++) { // T1 var s1 = new CharSetSolver(BitWidth.BV64); WS1SFormula phi = new WS1STrue(); for (int k = 1; k < to; k++) { var leq = new WS1SLt("x" + (k - 1), "x" + k); phi = new WS1SAnd(phi, leq); } for (int k = to - 1; k >= 0; k--) { phi = new WS1SExists("x" + k, phi); } sw.Restart(); for (int t = 0; t < numTests; t++) { phi.getAutomaton(s1); } sw.Stop(); var t1 = sw.ElapsedMilliseconds; //T2 s1 = new CharSetSolver(BitWidth.BV64); phi = new WS1STrue(); for (int k = 1; k < to; k++) { var leq = new WS1SLt("x" + (k - 1), ("x" + k)); phi = new WS1SAnd(phi, leq); } for (int k = 0; k < to; k++) { var axk = new WS1SPred(s1.MkCharConstraint('a', false), "x" + k); phi = new WS1SAnd(phi, axk); } for (int k = to - 1; k >= 0; k--) { phi = new WS1SExists("x" + k, phi); } sw.Restart(); for (int t = 0; t < numTests; t++) { phi.getAutomaton(s1); } sw.Stop(); var t2 = sw.ElapsedMilliseconds; // T3 s1 = new CharSetSolver(BitWidth.BV64); phi = new WS1STrue(); for (int k = 1; k < to; k++) { var leq = new WS1SLt("x" + (k - 1), ("x" + k)); phi = new WS1SAnd(phi, leq); } for (int k = 0; k < to; k++) { var axk = new WS1SPred(s1.MkCharConstraint('a', false), ("x" + k)); phi = new WS1SAnd(phi, axk); } for (int k = to - 1; k >= 0; k--) { phi = new WS1SExists(("x" + k), phi); } var exycy = new WS1SExists(("y"), new WS1SPred(s1.MkCharConstraint('c', false), ("y"))); phi = new WS1SAnd(phi, exycy); sw.Restart(); for (int t = 0; t < numTests; t++) { phi.getAutomaton(s1); } sw.Stop(); var t3 = sw.ElapsedMilliseconds; //T4 s1 = new CharSetSolver(BitWidth.BV64); phi = new WS1STrue(); for (int k = 1; k < to; k++) { var leq = new WS1SLt(("x" + (k - 1)), ("x" + k)); var axk = new WS1SPred(s1.MkCharConstraint('a', false), ("x" + (k - 1))); var cxk = new WS1SPred(s1.MkCharConstraint('c', false), ("x" + (k - 1))); var inter = new WS1SOr(new WS1SAnd(leq, axk), cxk); phi = new WS1SAnd(phi, inter); } for (int k = to - 1; k >= 0; k--) { phi = new WS1SExists(("x" + k), phi); } exycy = new WS1SExists(("y"), new WS1SPred(s1.MkCharConstraint('c', false), ("y"))); phi = new WS1SAnd(phi, exycy); var t4 = 60000L * numTests; if (to <= maxmphipopold) { sw.Restart(); for (int t = 0; t < numTests; t++) { phi.getAutomaton(s1); } sw.Stop(); t4 = sw.ElapsedMilliseconds; } file.WriteLine(to + "," + (double)t1 / numTests + "," + (double)t2 / numTests + "," + (double)t3 / numTests + "," + (double)t4 / numTests); Console.WriteLine(to + "," + (double)t1 / numTests + "," + (double)t2 / numTests + "," + (double)t3 / numTests + "," + (double)t4 / numTests); } } }