Inheritance: Z3Object
Ejemplo n.º 1
0
        /// <summary>
        /// Execute the probe over the goal. 
        /// </summary>
        /// <returns>A probe always produce a double value.
        /// "Boolean" probes return 0.0 for false, and a value different from 0.0 for true.</returns>
        public double Apply(Goal g)
        {
            Contract.Requires(g != null);

            Context.CheckContextMatch(g);
            return Native.Z3_probe_apply(Context.nCtx, NativeObject, g.NativeObject);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Apply the probe to a goal.
        /// </summary>
        public double this[Goal g]
        {
            get {
            Contract.Requires(g != null);

            return Apply(g); }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Apply the tactic to a goal.
        /// </summary>
        public ApplyResult this[Goal g]
        {
            get
            {
                Contract.Requires(g != null);
                Contract.Ensures(Contract.Result<ApplyResult>() != null);

                return Apply(g);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Execute the tactic over the goal. 
        /// </summary>
        public ApplyResult Apply(Goal g, Params p = null)
        {
            Contract.Requires(g != null);
            Contract.Ensures(Contract.Result<ApplyResult>() != null);

            Context.CheckContextMatch(g);
            if (p == null)
                return new ApplyResult(Context, Native.Z3_tactic_apply(Context.nCtx, NativeObject, g.NativeObject));
            else
            {
                Context.CheckContextMatch(p);
                return new ApplyResult(Context, Native.Z3_tactic_apply_ex(Context.nCtx, NativeObject, g.NativeObject, p.NativeObject));
            }
        }
Ejemplo n.º 5
0
        static ApplyResult ApplyTactic(Context ctx, Tactic t, Goal g)
        {
            Console.WriteLine("\nGoal: " + g);

            ApplyResult res = t.Apply(g);
            Console.WriteLine("Application result: " + res);

            Status q = Status.UNKNOWN;
            foreach (Goal sg in res.Subgoals)
                if (sg.IsDecidedSat) q = Status.SATISFIABLE;
                else if (sg.IsDecidedUnsat) q = Status.UNSATISFIABLE;

            switch (q)
            {
                case Status.UNKNOWN:
                    Console.WriteLine("Tactic result: Undecided");
                    break;
                case Status.SATISFIABLE:
                    Console.WriteLine("Tactic result: SAT");
                    break;
                case Status.UNSATISFIABLE:
                    Console.WriteLine("Tactic result: UNSAT");
                    break;
            }

            return res;
        }
Ejemplo n.º 6
0
        static void SolveTactical(Context ctx, Tactic t, Goal g, Status sat)
        {
            Solver s = ctx.MkSolver(t);
            Console.WriteLine("\nTactical solver: " + s);

            foreach (BoolExpr a in g.Formulas)
                s.Assert(a);
            Console.WriteLine("Solver: " + s);

            if (s.Check() != sat)
                throw new TestFailedException();
        }