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)); }
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"); }
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"); }
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 }