/// <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); }
/// <summary> /// Apply the probe to a goal. /// </summary> public double this[Goal g] { get { Contract.Requires(g != null); return Apply(g); } }
/// <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); } }
/// <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)); } }
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; }
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(); }