21 using System.Diagnostics.Contracts;
23 namespace Microsoft.Z3
28 [ContractVerification(
true)]
38 Contract.Ensures(Contract.Result<
string>() != null);
40 return Native.Z3_solver_get_help(Context.nCtx, NativeObject);
51 Contract.Requires(value != null);
53 Context.CheckContextMatch(value);
54 Native.Z3_solver_set_params(Context.nCtx, NativeObject, value.NativeObject);
74 get {
return Native.Z3_solver_get_num_scopes(Context.nCtx, NativeObject); }
83 Native.Z3_solver_push(Context.nCtx, NativeObject);
91 public void Pop(uint n = 1)
93 Native.Z3_solver_pop(Context.nCtx, NativeObject, n);
102 Native.Z3_solver_reset(Context.nCtx, NativeObject);
110 Contract.Requires(constraints != null);
111 Contract.Requires(Contract.ForAll(constraints, c => c != null));
113 Context.CheckContextMatch(constraints);
116 Native.Z3_solver_assert(Context.nCtx, NativeObject, a.NativeObject);
141 Contract.Requires(constraints != null);
142 Contract.Requires(Contract.ForAll(constraints, c => c != null));
143 Contract.Requires(Contract.ForAll(ps, c => c != null));
144 Context.CheckContextMatch(constraints);
145 Context.CheckContextMatch(ps);
146 if (constraints.Length != ps.Length)
149 for (
int i = 0 ; i < constraints.Length; i++)
166 Contract.Requires(constraint != null);
167 Contract.Requires(p != null);
168 Context.CheckContextMatch(constraint);
169 Context.CheckContextMatch(p);
171 Native.Z3_solver_assert_and_track(Context.nCtx, NativeObject, constraint.NativeObject, p.NativeObject);
177 public uint NumAssertions
182 return assertions.Size;
193 Contract.Ensures(Contract.Result<
BoolExpr[]>() != null);
196 return assertions.ToBoolExprArray();
211 if (assumptions == null || assumptions.Length == 0)
217 case Z3_lbool.Z3_L_TRUE:
return Status.SATISFIABLE;
218 case Z3_lbool.Z3_L_FALSE:
return Status.UNSATISFIABLE;
219 default:
return Status.UNKNOWN;
234 IntPtr x = Native.Z3_solver_get_model(Context.nCtx, NativeObject);
235 if (x == IntPtr.Zero)
253 IntPtr x = Native.Z3_solver_get_proof(Context.nCtx, NativeObject);
254 if (x == IntPtr.Zero)
257 return Expr.Create(
Context, x);
273 Contract.Ensures(Contract.Result<
Expr[]>() != null);
276 return core.ToBoolExprArray();
283 public string ReasonUnknown
287 Contract.Ensures(Contract.Result<
string>() != null);
289 return Native.Z3_solver_get_reason_unknown(Context.nCtx, NativeObject);
300 Contract.Ensures(Contract.Result<
Statistics>() != null);
311 return Native.Z3_solver_to_string(Context.nCtx, NativeObject);
318 Contract.Requires(ctx != null);
321 internal class DecRefQueue : IDecRefQueue
323 public DecRefQueue() : base() { }
324 public DecRefQueue(uint move_limit) : base(move_limit) { }
325 internal override void IncRef(Context ctx, IntPtr obj)
327 Native.Z3_solver_inc_ref(ctx.nCtx, obj);
330 internal override void DecRef(Context ctx, IntPtr obj)
332 Native.Z3_solver_dec_ref(ctx.nCtx, obj);
336 internal override void IncRef(IntPtr o)
338 Context.Solver_DRQ.IncAndClear(Context, o);
342 internal override void DecRef(IntPtr o)
344 Context.Solver_DRQ.Add(o);
static int Z3_solver_check_assumptions(Z3_context a0, Z3_solver a1, uint a2, [In] Z3_ast[] a3)
void AssertAndTrack(BoolExpr constraint, BoolExpr p)
Assert a constraint into the solver, and track it (in the unsat) core using the Boolean constant p...
void AssertAndTrack(BoolExpr[] constraints, BoolExpr[] ps)
Assert multiple constraints into the solver, and track them (in the unsat) core using the Boolean con...
static Z3_ast_vector Z3_solver_get_assertions(Z3_context a0, Z3_solver a1)
Status Check(params Expr[] assumptions)
Checks whether the assertions in the solver are consistent or not.
void Add(params BoolExpr[] constraints)
Alias for Assert.
Objects of this class track statistical information about solvers.
static Z3_stats Z3_solver_get_statistics(Z3_context a0, Z3_solver a1)
void Assert(params BoolExpr[] constraints)
Assert a constraint (or multiple) into the solver.
static Z3_param_descrs Z3_solver_get_param_descrs(Z3_context a0, Z3_solver a1)
Z3_lbool
Lifted Boolean type: false, undefined, true.
void Push()
Creates a backtracking point.
static void Z3_solver_assert_and_track(Z3_context a0, Z3_solver a1, Z3_ast a2, Z3_ast a3)
override string ToString()
A string representation of the solver.
void Reset()
Resets the Solver.
static int Z3_solver_check(Z3_context a0, Z3_solver a1)
A Params objects represents a configuration in the form of Symbol/value pairs.
A ParamDescrs describes a set of parameters.
A Model contains interpretations (assignments) of constants and functions.
The main interaction with Z3 happens via the Context.
The exception base class for error reporting from Z3
The abstract syntax tree (AST) class.
Internal base class for interfacing with native Z3 objects. Should not be used externally.
void Pop(uint n=1)
Backtracks n backtracking points.
static Z3_ast_vector Z3_solver_get_unsat_core(Z3_context a0, Z3_solver a1)