MkParams() публичный Метод

Creates a new ParameterSet.
public MkParams ( ) : Params
Результат Params
Пример #1
0
    public void Run()
    {
        Dictionary<string, string> cfg = new Dictionary<string, string>() { { "AUTO_CONFIG", "true" } };

        using (Context ctx = new Context(cfg))
        {
            RealExpr x = ctx.MkRealConst("x");
            RealExpr y = ctx.MkRealConst("y");

            Params ps = ctx.MkParams();
            ps.Add(":som", true);

            Expr q = ctx.MkPower(ctx.MkAdd(x, y), ctx.MkReal(3));
            q = q.Simplify(ps);

            Console.WriteLine(ps);
            Console.WriteLine(q);

            ps = ctx.MkParams();
            ps.Add(":mul-to-power", true);

            q = q.Simplify(ps);

            Console.WriteLine(ps);
            Console.WriteLine(q);
        }
    }
Пример #2
0
    public void Run()
    {
        Dictionary<string, string> cfg = new Dictionary<string, string>() { };

        using (Context ctx = new Context(cfg))
        {
            FuncDecl f = ctx.MkFuncDecl("f", ctx.IntSort, ctx.IntSort);
            FuncDecl g = ctx.MkFuncDecl("g", ctx.IntSort, ctx.IntSort);

            IntExpr a = ctx.MkIntConst("a");
            IntExpr b = ctx.MkIntConst("b");
            IntExpr c = ctx.MkIntConst("c");

            IntExpr x = ctx.MkIntConst("x");

            Solver s = ctx.MkSolver();
            Params p = ctx.MkParams();
            p.Add("AUTO_CONFIG", false);
            p.Add("MBQI", false);
            s.Parameters = p;

            s.Assert(ctx.MkForall(new Expr[] { x }, ctx.MkEq(f[g[x]], x), 1, new Pattern[] { ctx.MkPattern(f[g[x]]) }));
            s.Assert(ctx.MkEq(a, g[b]));
            s.Assert(ctx.MkEq(b, c));
            s.Assert(ctx.MkDistinct(f[a], c));

            Console.WriteLine(s);
            Console.WriteLine(s.Check());
        }
    }
Пример #3
0
        static void Prove(Z3.Context ctx, BoolExpr f, bool useMBQI = false, params BoolExpr[] assumptions)
        {
            Console.WriteLine("Proving: " + f);
            Solver s = ctx.MkSolver();
            Params p = ctx.MkParams();

            p.Add("mbqi", useMBQI);
            s.Parameters = p;
            foreach (BoolExpr a in assumptions)
            {
                s.Assert(a);
            }
            s.Assert(ctx.MkNot(f));
            Status q = s.Check();

            switch (q)
            {
            case Status.UNKNOWN:
                Console.WriteLine("Unknown because: " + s.ReasonUnknown);
                break;

            case Status.SATISFIABLE:
                throw new Exception("Test failed");

            case Status.UNSATISFIABLE:
                Console.WriteLine("OK, proof: " + s.Proof);
                break;
            }
        }
Пример #4
0
    public void Run()
    {
        Dictionary<string, string> cfg = new Dictionary<string, string>() {
            { "AUTO_CONFIG", "true" } };

        using (Context ctx = new Context(cfg))
        {
            BitVecExpr x = ctx.MkBVConst("x", 16);
            BitVecExpr y = ctx.MkBVConst("y", 16);

            Params p = ctx.MkParams();
            p.Add(":mul2concat", true);

            Tactic t = ctx.Then(ctx.UsingParams(ctx.MkTactic("simplify"), p),
                                ctx.MkTactic("solve-eqs"),
                                ctx.MkTactic("bit-blast"),
                                ctx.MkTactic("aig"),
                                ctx.MkTactic("sat"));
            Solver s = ctx.MkSolver(t);

            s.Assert(ctx.MkEq(ctx.MkBVAdd(ctx.MkBVMul(x, ctx.MkBV(32, 16)), y), ctx.MkBV(13, 16)));
            s.Assert(ctx.MkBVSLT(ctx.MkBVAND(x, y), ctx.MkBV(10, 16)));
            s.Assert(ctx.MkBVSGT(y, ctx.MkBV(-100, 16)));

            Console.WriteLine(s.Check());
            Model m = s.Model;
            Console.WriteLine(m);

            Console.WriteLine(ctx.MkBVAdd(ctx.MkBVMul(x, ctx.MkBV(32, 16)), y) + " == " + m.Evaluate(ctx.MkBVAdd(ctx.MkBVMul(x, ctx.MkBV(32, 16)), y)));
            Console.WriteLine(ctx.MkBVAND(x, y) + " == " + m.Evaluate(ctx.MkBVAND(x, y)) );
        }
    }
Пример #5
0
    public static void Main()
    {
        Context ctx = new Context();

        Params p = ctx.MkParams();
        p.Add("blah", "blah"); // Invalid parameter.

        Solver s = ctx.MkSolver();
        s.Parameters = p;
        s.Check(); // Complains by throwing an assertion (OK).
    }
Пример #6
0
    public static void Main()
    {
        Context ctx = new Context();

        Params p = ctx.MkParams();
        p.Add("blah", "blah"); // invalid parameter name

        Tactic t1 = ctx.MkTactic("smt");
        Tactic t2 = ctx.UsingParams(t1, p);
        Solver s = ctx.MkSolver(t2);
        s.Check();
    }
Пример #7
0
    public static void Main()
    {
        Context ctx = new Context();

        Params p = ctx.MkParams();
        p.Add("smt.arith.nl", true);
        p.Add("smt.arith.nl.rounds", 42);

        Solver s = ctx.MkSolver();
        s.Parameters = p;
        Console.WriteLine(s); // says "(solver)"

        s = ctx.MkSimpleSolver();
        s.Parameters = p;
        Console.WriteLine(s); // should also say "(solver)"
    }
Пример #8
0
    public void Run()
    {
        Dictionary<string, string> cfg = new Dictionary<string, string>() { { "AUTO_CONFIG", "true" } };

        using (Context ctx = new Context(cfg))
        {
            RealExpr x = ctx.MkRealConst("x");
            RealExpr y = ctx.MkRealConst("y");

            Params ps = ctx.MkParams();
            ps.Add(":arith-lhs", true);

            Expr q = ctx.MkEq(x, ctx.MkAdd(y, ctx.MkReal(2)));
            q = q.Simplify(ps);

            Console.WriteLine(ps);
            Console.WriteLine(q);
        }
    }
Пример #9
0
    public void Run()
    {
        Dictionary<string, string> cfg = new Dictionary<string, string>() {
            { "AUTO_CONFIG", "true" } };

        using (Context ctx = new Context(cfg))
        {
            Params p = ctx.MkParams();
            p.Add(":arith-lhs", true);
            p.Add(":som", true);

            Solver s = ctx.Then(ctx.With(ctx.MkTactic("simplify"), p),
                                ctx.MkTactic("normalize-bounds"),
                                ctx.MkTactic("lia2pb"),
                                ctx.MkTactic("pb2bv"),
                                ctx.MkTactic("bit-blast"),
                                ctx.MkTactic("sat")).Solver;

            IntExpr x = ctx.MkIntConst("x");
            IntExpr y = ctx.MkIntConst("y");
            IntExpr z = ctx.MkIntConst("z");

            s.Assert(new BoolExpr[] { ctx.MkGt(x, ctx.MkInt(0)),
                                      ctx.MkLt(x, ctx.MkInt(10)),
                                      ctx.MkGt(y, ctx.MkInt(0)),
                                      ctx.MkLt(y, ctx.MkInt(10)),
                                      ctx.MkGt(z, ctx.MkInt(0)),
                                      ctx.MkLt(z, ctx.MkInt(10)),
                                      ctx.MkEq(ctx.MkAdd(ctx.MkMul(ctx.MkInt(3), y),
                                                         ctx.MkMul(ctx.MkInt(2), x)), z) });

            Console.WriteLine(s.Check());
            Console.WriteLine(s.Model);

            s.Reset();

            s.Assert(ctx.MkEq(ctx.MkAdd(ctx.MkMul(ctx.MkInt(3), y),
                                        ctx.MkMul(ctx.MkInt(2), x)), z));

            Console.WriteLine(s.Check());
        }
    }
Пример #10
0
        /// <summary>
        /// Constructs a Z3 solver to be used.
        /// </summary>
        internal void ConstructSolver(Z3BaseParams parameters)
        {
            // If Z3 is there already, kill it
            if (_context != null)
            {
                DestructSolver(false);
            }

            _context = new Context();
            _optSolver = _context.MkOptimize();
            var p = _context.MkParams();

            switch (parameters.OptKind)
            {
                case OptimizationKind.BoundingBox:
                    p.Add("priority", _context.MkSymbol("box"));
                    break;
                case OptimizationKind.Lexicographic:
                    p.Add("priority", _context.MkSymbol("lex"));
                    break;
                case OptimizationKind.ParetoOptimal:
                    p.Add("priority", _context.MkSymbol("pareto"));
                    break;
                default:
                    Debug.Assert(false, String.Format("Unknown optimization option {0}", parameters.OptKind));
                    break;
            }

            switch (parameters.CardinalityAlgorithm)
            {
                case CardinalityAlgorithm.FuMalik:
                    p.Add("maxsat_engine", _context.MkSymbol("fu_malik"));
                    break;
                case CardinalityAlgorithm.CoreMaxSAT:
                    p.Add("maxsat_engine", _context.MkSymbol("core_maxsat"));
                    break;
                default:
                    Debug.Assert(false, String.Format("Unknown cardinality algorithm option {0}", parameters.CardinalityAlgorithm));
                    break;
            }

            switch (parameters.PseudoBooleanAlgorithm)
            {
                case PseudoBooleanAlgorithm.WeightedMaxSAT:
                    p.Add("wmaxsat_engine", _context.MkSymbol("wmax"));
                    break;
                case PseudoBooleanAlgorithm.IterativeWeightedMaxSAT:
                    p.Add("wmaxsat_engine", _context.MkSymbol("iwmax"));
                    break;
                case PseudoBooleanAlgorithm.BisectionWeightedMaxSAT:
                    p.Add("wmaxsat_engine", _context.MkSymbol("bwmax"));
                    break;
                case PseudoBooleanAlgorithm.WeightedPartialMaxSAT2:
                    p.Add("wmaxsat_engine", _context.MkSymbol("wpm2"));
                    break;
                default:
                    Debug.Assert(false, String.Format("Unknown pseudo-boolean algorithm option {0}", parameters.PseudoBooleanAlgorithm));
                    break;
            }

            switch (parameters.ArithmeticStrategy)
            {
                case ArithmeticStrategy.Basic:
                    p.Add("engine", _context.MkSymbol("basic"));
                    break;
                case ArithmeticStrategy.Farkas:
                    p.Add("engine", _context.MkSymbol("farkas"));
                    break;
                default:
                    Debug.Assert(false, String.Format("Unknown arithmetic strategy option {0}", parameters.ArithmeticStrategy));
                    break;
            }

            _optSolver.Parameters = p;
        }
Пример #11
0
        static void Disprove(Context ctx, BoolExpr f, bool useMBQI = false, params BoolExpr[] assumptions)
        {
            Console.WriteLine("Disproving: " + f);
            Solver s = ctx.MkSolver();
            Params p = ctx.MkParams();
            p.Add("mbqi", useMBQI);
            s.Parameters = p;
            foreach (BoolExpr a in assumptions)
                s.Assert(a);
            s.Assert(ctx.MkNot(f));
            Status q = s.Check();

            switch (q)
            {
                case Status.UNKNOWN:
                    Console.WriteLine("Unknown because: " + s.ReasonUnknown);
                    break;
                case Status.SATISFIABLE:
                    Console.WriteLine("OK, model: " + s.Model);
                    break;
                case Status.UNSATISFIABLE:
                    throw new TestFailedException();
            }
        }
Пример #12
0
 public Params Params()
 => Context.MkParams();