Exemplo n.º 1
0
        public void Mona2AutomatonTest3(bool singletonSetSemantics)
        {
            BDDAlgebra solver = new BDDAlgebra();

            string      source1 = @"
m2l-str;
var1 x,y;
y = x + 2;
";
            string      source2 = @"
m2l-str;
var1 x,y;
ex1 z: x<z & z<y;
x < y & ~ex1 z1,z2: x<z1 & z1<y & x<z2 & z2<y & z1 ~= z2;
";
            MonaProgram pgm1    = MonaParser.Parse(source1);
            var         mso1    = pgm1.ToMSO();
            var         aut1    = mso1.GetAutomaton(solver, 0, singletonSetSemantics);

            //aut1.ShowGraph("aut1");

            MonaProgram pgm2 = MonaParser.Parse(source2);
            var         mso2 = pgm2.ToMSO();
            var         aut2 = mso2.GetAutomaton(solver, 0, singletonSetSemantics);

            //aut2.ShowGraph("aut2");

            Assert.IsTrue(aut1.IsEquivalentWith(aut2));
        }
Exemplo n.º 2
0
        public void Mona2AutomatonTest_pred3()
        {
            BDDAlgebra solver = new BDDAlgebra();

            string source1 =
                @"m2l-str;
pred belongs(var1 x, var2 X) = x in X;
pred subs(var2 X, Y) = all1 x: belongs(x,X) => belongs(x,Y);
pred equal(var2 X,Y) = subs(X,Y) & subs(Y,X);
var2 X, Y;
equal(X,Y);
";

            string source2 =
                @"m2l-str;
var2 Y, X;
Y = X;
";

            MonaProgram pgm1 = MonaParser.Parse(source1);
            var         mso1 = pgm1.ToMSO();
            var         aut1 = mso1.GetAutomaton(solver);

            MonaProgram pgm2 = MonaParser.Parse(source2);
            var         mso2 = pgm2.ToMSO();
            var         aut2 = mso2.GetAutomaton(solver);

            Assert.IsTrue(aut1.IsEquivalentWith(aut2));
        }
Exemplo n.º 3
0
        public void Mona2AutomatonTest_pred1(bool useSingletonSetSemantics)
        {
            BDDAlgebra solver = new BDDAlgebra();

            string source1 =
                @"m2l-str;
pred succ(var1 x,y) = x < y & ~ex1 z:(x < z & z < y);
var1 x,y,z;
succ(x,y) & succ(y,z);
";

            string source2 =
                @"m2l-str;
var1 x,y,z;
y = x+1 & z = y + 1;
";

            MonaProgram pgm1 = MonaParser.Parse(source1);
            var         mso1 = pgm1.ToMSO();
            var         aut1 = mso1.GetAutomaton(solver, 0, useSingletonSetSemantics);

            MonaProgram pgm2 = MonaParser.Parse(source2);
            var         mso2 = pgm2.ToMSO();
            var         aut2 = mso2.GetAutomaton(solver, 0, useSingletonSetSemantics);

            Assert.IsTrue(aut1.IsEquivalentWith(aut2));
        }
Exemplo n.º 4
0
        public void Mona2AutomatonTest2()
        {
            BDDAlgebra solver = new BDDAlgebra();

            string      source1 = @"
m2l-str;
var1 x,y;
y = x + 1;
";
            string      source2 = @"
m2l-str;
var1 x,y;
x < y & ~ex1 z: x<z & z<y;
";
            MonaProgram pgm1    = MonaParser.Parse(source1);
            var         mso1    = pgm1.ToMSO();
            var         aut1    = mso1.GetAutomaton(solver);

            //aut1.ShowGraph("aut1");

            MonaProgram pgm2 = MonaParser.Parse(source2);
            var         mso2 = pgm2.ToMSO();
            var         aut2 = mso2.GetAutomaton(solver);

            //aut2.ShowGraph("aut2");

            Assert.IsTrue(aut1.IsEquivalentWith(aut2));
        }
Exemplo n.º 5
0
        //LTL over finite traces
        private static void AutomatarkMsoFormulasTest(string inputDir, string outFile)
        {
            Console.WriteLine("fileName , generic-bdd, product");
            using (System.IO.StreamWriter file =
                       new System.IO.StreamWriter(outFile))
            {
                var files = new List <string>(Directory.EnumerateFiles(inputDir, "*.mona", SearchOption.AllDirectories));
                files.Sort((s1, s2) => cmp(s1, s2));
                foreach (string fileName in files)
                {
                    string      contents = File.ReadAllText(fileName);
                    MonaProgram pgm1     = MonaParser.Parse(contents);
                    phi = pgm1.ToMSO();

                    var bv7 = new CharSetSolver(BitWidth.BV7);
                    bddSolver = new BDDAlgebra <BDD>(bv7);
                    var sw = new Stopwatch();
                    sw.Restart();
                    Thread t = new Thread(BDDSolver);
                    t.Start();
                    long t1 = 5000;
                    if (!t.Join(TimeSpan.FromSeconds(5)))
                    {
                        t.Abort();
                        t1 = 5000;
                    }
                    else
                    {
                        sw.Stop();
                        t1 = sw.ElapsedMilliseconds;
                    }

                    bv7        = new CharSetSolver(BitWidth.BV7);
                    cartSolver = new CartesianAlgebraBDD <BDD>(bv7);

                    sw.Restart();
                    t = new Thread(CartesianSolver);
                    t.Start();
                    long t2 = 5000;
                    if (!t.Join(TimeSpan.FromSeconds(5)))
                    {
                        t.Abort();
                        t2 = 5000;
                    }
                    else
                    {
                        sw.Stop();
                        t2 = sw.ElapsedMilliseconds;
                    }

                    //if (t2 > 5000)
                    //    t2 = 5000;

                    file.WriteLine(fileName + "," + (double)t1 / numTests + "," + (double)t2 / numTests);
                    Console.WriteLine(fileName + "," + (double)t1 / numTests + "," + (double)t2 / numTests);
                }
            }
        }
Exemplo n.º 6
0
 //[TestMethod]
 public void MonaParserTest_parse_ltl()
 {
     foreach (string fileName in Directory.EnumerateFiles(@"C:\github\automatark\m2l-str\", "*.mona", SearchOption.AllDirectories))
     {
         MonaProgram pgm = MonaParser.ParseFromFile(fileName);
         Assert.IsTrue(pgm.declarations.Count > 0);
         var mso = pgm.ToMSO();
     }
 }
Exemplo n.º 7
0
 //[TestMethod]
 public void MonaParserTest_parse_mona()
 {
     foreach (string fileName in Directory.EnumerateFiles(@"C:\github\automatark\ws1s\", "*.mona", SearchOption.AllDirectories))
     {
         MonaProgram pgm = MonaParser.ParseFromFile(fileName);
         Assert.IsTrue(pgm.declarations.Count > 0);
         // horn_trans??.mona : stackoverflow
         if (!fileName.Contains("horn_trans"))
         {
             var mso = pgm.ToMSO();
         }
     }
 }
Exemplo n.º 8
0
        public void Mona2AutomatonTest4()
        {
            BDDAlgebra solver = new BDDAlgebra();

            string source1 = @"
m2l-str;
var2 X,Y;
Y = X;
";
            string source2 = @"
m2l-str;
var2 X,Y;
all1 z: z in X <=> z in Y;
";

            string source3 = @"
m2l-str;
var2 X,Y;
Y sub X & X sub Y;
";

            string      source4 = @"
m2l-str;
var2 X,Y;
Y\X = empty & X\Y = empty;
";
            MonaProgram pgm1    = MonaParser.Parse(source1);
            var         mso1    = pgm1.ToMSO();
            var         aut1    = mso1.GetAutomaton(solver);

            //aut1.ShowGraph("aut1");

            MonaProgram pgm2 = MonaParser.Parse(source2);
            var         mso2 = pgm2.ToMSO();
            var         aut2 = mso2.GetAutomaton(solver);

            //aut2.ShowGraph("aut2");

            MonaProgram pgm3 = MonaParser.Parse(source3);
            var         mso3 = pgm3.ToMSO();
            var         aut3 = mso3.GetAutomaton(solver);

            MonaProgram pgm4 = MonaParser.Parse(source4);
            var         mso4 = pgm4.ToMSO();
            var         aut4 = mso4.GetAutomaton(solver);

            Assert.IsTrue(aut1.IsEquivalentWith(aut2));
            Assert.IsTrue(aut1.IsEquivalentWith(aut3));
            Assert.IsTrue(aut1.IsEquivalentWith(aut4));
        }
Exemplo n.º 9
0
        public void Mona2AutomatonTest1()
        {
            string      source = @"
m2l-str;
var1 x,y;
x < y;
";
            MonaProgram pgm    = MonaParser.Parse(source);
            var         mso    = pgm.ToMSO();
            BDDAlgebra  solver = new BDDAlgebra();
            var         aut    = mso.GetAutomaton(solver);

            //aut.ShowGraph();
            Assert.IsTrue(aut.StateCount == 3);
        }
Exemplo n.º 10
0
        public void Mona2AutomatonTest_pred2()
        {
            BDDAlgebra solver = new BDDAlgebra();

            string source =
                @"m2l-str;
pred succ(var1 x,y) = x < y & ~ex1 z:(x < z & z < y);
var1 x,y,z;
succ(x,y) & succ(y,z);
";

            MonaProgram pgm1 = MonaParser.Parse(source);
            var         mso1 = pgm1.ToMSO();
            var         aut1 = mso1.GetAutomaton(solver, 0, true);

            MonaProgram pgm2 = MonaParser.Parse(source);
            var         mso2 = pgm2.ToMSO();
            var         aut2 = mso2.GetAutomaton(solver, 0, false);

            Assert.IsFalse(aut1.IsEquivalentWith(aut2));
        }