Ejemplo n.º 1
0
        public void ConstraintDifferent()
        {
            var builder = new SimpleExprBuilder(true);

            var dummyV = SymbooglixLibTests.MapProxyTests.GetVariable("dummy", BPLType.Int);

            // Hack
            dummyV.SetMetadata((int)Symbooglix.Annotation.AnnotationIndex.PROGRAM_LOCATION, new ProgramLocation(dummyV));
            var v  = new SymbolicVariable("foo", dummyV);
            var id = builder.Identifier(v);

            var c0     = new Constraint(builder.Gt(id, builder.ConstantInt(0)));
            var c0Copy = new Constraint(builder.Gt(id, builder.ConstantInt(0)));
            var c1     = new Constraint(builder.Lt(id, builder.ConstantInt(10)));
            var c1diff = new Constraint(builder.Le(id, builder.ConstantInt(10)));

            var CM0 = new ConstraintManager();
            var CM1 = new ConstraintManager();

            CM0.AddConstraint(c0);
            CM0.AddConstraint(c1);
            CM1.AddConstraint(c0Copy);
            CM1.AddConstraint(c1diff);

            var queryExpr0 = builder.Eq(id, builder.ConstantInt(5));
            var queryExpr1 = builder.Eq(id, builder.ConstantInt(5));

            var query0 = new Symbooglix.Solver.Query(CM0, new Constraint(queryExpr0));
            var query1 = new Symbooglix.Solver.Query(CM1, new Constraint(queryExpr1));

            Assert.AreNotEqual(query0.GetHashCode(), query1.GetHashCode());

            Assert.IsFalse(query0.Equals(query1));
        }
Ejemplo n.º 2
0
        public void Arguments()
        {
            var tcDecl = new TypeCtorDecl(Token.NoToken, "fox", 1);
            var tc     = new CtorType(Token.NoToken, tcDecl, new List <Microsoft.Boogie.Type>()
            {
                Microsoft.Boogie.Type.Bool
            });
            var tcTypeIdent = new TypedIdent(Token.NoToken, "fox", tc);
            var gv          = new GlobalVariable(Token.NoToken, tcTypeIdent);

            // FIXME: The Symbolic constructor shouldn't really need the program location
            gv.SetMetadata <ProgramLocation>((int)AnnotationIndex.PROGRAM_LOCATION, new ProgramLocation(gv));
            var sym = new SymbolicVariable("y", gv);

            var builder = new SimpleExprBuilder(/*immutable=*/ true);
            var eq      = builder.Eq(sym.Expr, sym.Expr);

            Assert.IsNotInstanceOf <LiteralExpr>(eq); // Check that it wasn't constant folded

            using (var writer = new StringWriter())
            {
                var printer = GetPrinter(writer);
                printer.AddDeclarations(eq);
                printer.PrintSortDeclarations();
                Assert.AreEqual("(declare-sort @fox)\n", writer.ToString());
            }
        }
Ejemplo n.º 3
0
        public void MapWithTypeConstructorTypesNoArguments()
        {
            var tcDecl  = new TypeCtorDecl(Token.NoToken, "fox", 0);
            var tc      = new CtorType(Token.NoToken, tcDecl, new List <Microsoft.Boogie.Type>());
            var tcDecl2 = new TypeCtorDecl(Token.NoToken, "fox_two", 0);
            var tc2     = new CtorType(Token.NoToken, tcDecl2, new List <Microsoft.Boogie.Type>());
            var tcDecl3 = new TypeCtorDecl(Token.NoToken, "fox_three", 0);
            var tc3     = new CtorType(Token.NoToken, tcDecl3, new List <Microsoft.Boogie.Type>());
            var mapType = new MapType(
                Token.NoToken,
                new List <Microsoft.Boogie.TypeVariable>(),
                new List <Microsoft.Boogie.Type>()
            {
                tc, tc2
            },
                tc3);
            var mapTypeTypeIdent = new TypedIdent(Token.NoToken, "mapx", mapType);
            var gv = new GlobalVariable(Token.NoToken, mapTypeTypeIdent);

            // FIXME: The Symbolic constructor shouldn't really need the program location
            gv.SetMetadata <ProgramLocation>((int)AnnotationIndex.PROGRAM_LOCATION, new ProgramLocation(gv));
            var sym = new SymbolicVariable("y", gv);

            var builder = new SimpleExprBuilder(/*immutable=*/ true);
            var eq      = builder.Eq(sym.Expr, sym.Expr);

            Assert.IsNotInstanceOf <LiteralExpr>(eq); // Check that it wasn't constant folded

            using (var writer = new StringWriter()) {
                var printer = GetPrinter(writer);
                printer.AddDeclarations(eq);
                printer.PrintSortDeclarations();
                var str = writer.ToString().Trim();
                // Check we can see all the sort declarations we expect but don't depend on their order
                Assert.IsTrue(str.Contains("(declare-sort @fox)"));
                Assert.IsTrue(str.Contains("(declare-sort @fox_two)"));
                Assert.IsTrue(str.Contains("(declare-sort @fox_three)"));
            }
        }