Exemplo n.º 1
0
        public void TestBVAlgebraCharOperations()
        {
            var css          = new CharSetSolver();
            var regex        = new Regex("(?i:abc[^a-z])");
            var sr           = css.RegexConverter.ConvertToSymbolicRegex(regex, true);
            var mintermsList = new List <BDD>(sr.ComputeMinterms());
            var minterms     = mintermsList.ToArray();
            var all          = css.MkOr(minterms);

            Assert.IsTrue(all.IsFull);
            Assert.AreEqual(5, minterms.Length);
            var bva = new BVAlgebra(css, minterms);
            var bv1 = bva.MkBV(1, 2);
            var bv2 = bva.MkBV(2, 3, 4);
            var a   = bva.MkCharConstraint('A');
            var b   = bva.MkCharConstraint('b');
            var c   = bva.MkCharConstraint('C');
            var d   = bva.MkCharConstraint('6');
            var x   = bva.MkCharConstraint('x');

            Assert.AreEqual <ulong>(bva.atoms[bva.dtree.GetId('a')].first, a.first);
            Assert.AreEqual <ulong>(bva.atoms[bva.dtree.GetId('B')].first, b.first);
            Assert.AreEqual <ulong>(bva.atoms[bva.dtree.GetId('C')].first, c.first);
            Assert.AreEqual <ulong>(bva.atoms[bva.dtree.GetId('7')].first, d.first);
            Assert.AreEqual <ulong>(bva.atoms[bva.dtree.GetId('z')].first, x.first);
        }
Exemplo n.º 2
0
        public void TestBVAlgebraBasicOperations()
        {
            var css          = new CharSetSolver();
            var regexa       = new Regex("(?i:a)");
            var aut          = css.Convert("(?i:a)");
            var aut_minterms = css.RegexConverter.ConvertToSymbolicRegex(regexa, true).ComputeMinterms();
            var aut_bva      = new BVAlgebra(css, aut_minterms);
            var aut_BV       = aut.ReplaceAlgebra <BV>(aut_bva.MapPredToBV, aut_bva);
            //aut_BV.ShowGraph("aut_BV");
            var aut_BV_det = aut_BV.Determinize().Minimize();

            //aut_BV_det.ShowGraph("aut_BV_det");
            Assert.AreEqual <int>(2, aut_BV_det.StateCount);
            Assert.AreEqual <int>(3, aut_BV_det.MoveCount);
            var a_bv = aut_bva.MkCharConstraint('a');
            var a_id = aut_bva.GetIdOfChar('a');
            var A_id = aut_bva.GetIdOfChar('A');

            Assert.AreEqual <int>(a_id, A_id);
            Assert.AreEqual <BV>(a_bv, aut_bva.atoms[a_id]);
            Assert.AreEqual <int>(3, aut_BV_det.MoveCount);
            Assert.AreEqual <int>(2, aut_bva.atoms.Length);
        }