/// <summary> /// Computes an interpolant. /// </summary> /// <remarks>For more information on interpolation please refer /// too the function Z3_get_interpolant in the C/C++ API, which is /// well documented.</remarks> public BoolExpr[] GetInterpolant(Expr pf, Expr pat, Params p) { Contract.Requires(pf != null); Contract.Requires(pat != null); Contract.Requires(p != null); Contract.Ensures(Contract.Result<Expr>() != null); CheckContextMatch(pf); CheckContextMatch(pat); CheckContextMatch(p); ASTVector seq = new ASTVector(this, Native.Z3_get_interpolant(nCtx, pf.NativeObject, pat.NativeObject, p.NativeObject)); return seq.ToBoolExprArray(); }
/// <summary> /// Computes an interpolant. /// </summary> /// <remarks>For more information on interpolation please refer /// too the function Z3_compute_interpolant in the C/C++ API, which is /// well documented.</remarks> Z3_lbool ComputeInterpolant(Expr pat, Params p, out ASTVector interp, out Model model) { Contract.Requires(pat != null); Contract.Requires(p != null); Contract.Ensures(Contract.ValueAtReturn(out interp) != null); Contract.Ensures(Contract.ValueAtReturn(out model) != null); CheckContextMatch(pat); CheckContextMatch(p); IntPtr i = IntPtr.Zero, m = IntPtr.Zero; int r = Native.Z3_compute_interpolant(nCtx, pat.NativeObject, p.NativeObject, ref i, ref m); interp = new ASTVector(this, i); model = new Model(this, m); return (Z3_lbool)r; }
/// <summary> /// Computes an interpolant. /// </summary> /// <remarks>For more information on interpolation please refer /// too the function Z3_get_interpolant in the C/C++ API, which is /// well documented.</remarks> Expr[] GetInterpolant(Expr pf, Expr pat, Params p) { Contract.Requires(pf != null); Contract.Requires(pat != null); Contract.Requires(p != null); Contract.Ensures(Contract.Result<Expr>() != null); CheckContextMatch(pf); CheckContextMatch(pat); CheckContextMatch(p); ASTVector seq = new ASTVector(this, Native.Z3_get_interpolant(nCtx, pf.NativeObject, pat.NativeObject, p.NativeObject)); uint n = seq.Size; Expr[] res = new Expr[n]; for (uint i = 0; i < n; i++) res[i] = Expr.Create(this, seq[i].NativeObject); return res; }
/// <summary> /// Retrieve fixed assignments to the set of variables in the form of consequences. /// Each consequence is an implication of the form /// /// relevant-assumptions Implies variable = value /// /// where the relevant assumptions is a subset of the assumptions that are passed in /// and the equality on the right side of the implication indicates how a variable /// is fixed. /// </summary> /// <remarks> /// <seealso cref="Model"/> /// <seealso cref="UnsatCore"/> /// <seealso cref="Proof"/> /// </remarks> public Status Consequences(IEnumerable <BoolExpr> assumptions, IEnumerable <Expr> variables, out BoolExpr[] consequences) { ASTVector result = new ASTVector(Context); ASTVector asms = new ASTVector(Context); ASTVector vars = new ASTVector(Context); foreach (var asm in assumptions) { asms.Push(asm); } foreach (var v in variables) { vars.Push(v); } Z3_lbool r = (Z3_lbool)Native.Z3_solver_get_consequences(Context.nCtx, NativeObject, asms.NativeObject, vars.NativeObject, result.NativeObject); consequences = result.ToBoolExprArray(); return(lboolToStatus(r)); }
/// <summary> /// Computes an interpolant. /// </summary> /// <remarks>For more information on interpolation please refer /// too the function Z3_get_interpolant in the C/C++ API, which is /// well documented.</remarks> Expr[] GetInterpolant(Expr pf, Expr pat, Params p) { Contract.Requires(pf != null); Contract.Requires(pat != null); Contract.Requires(p != null); Contract.Ensures(Contract.Result <Expr>() != null); CheckContextMatch(pf); CheckContextMatch(pat); CheckContextMatch(p); ASTVector seq = new ASTVector(this, Native.Z3_get_interpolant(nCtx, pf.NativeObject, pat.NativeObject, p.NativeObject)); uint n = seq.Size; Expr[] res = new Expr[n]; for (uint i = 0; i < n; i++) { res[i] = Expr.Create(this, seq[i].NativeObject); } return(res); }
/// <summary> /// The finite set of distinct values that represent the interpretation for sort <paramref name="s"/>. /// </summary> /// <seealso cref="Sorts"/> /// <param name="s">An uninterpreted sort</param> /// <returns>An array of expressions, where each is an element of the universe of <paramref name="s"/></returns> public Expr[] SortUniverse(Sort s) { Contract.Requires(s != null); Contract.Ensures(Contract.Result<Expr[]>() != null); ASTVector nUniv = new ASTVector(Context, Native.Z3_model_get_sort_universe(Context.nCtx, NativeObject, s.NativeObject)); uint n = nUniv.Size; Expr[] res = new Expr[n]; for (uint i = 0; i < n; i++) res[i] = Expr.Create(Context, nUniv[i].NativeObject); return res; }
/// <summary> /// Retrieve fixed assignments to the set of variables in the form of consequences. /// Each consequence is an implication of the form /// /// relevant-assumptions Implies variable = value /// /// where the relevant assumptions is a subset of the assumptions that are passed in /// and the equality on the right side of the implication indicates how a variable /// is fixed. /// </summary> /// <remarks> /// <seealso cref="Model"/> /// <seealso cref="UnsatCore"/> /// <seealso cref="Proof"/> /// </remarks> public Status Consequences(IEnumerable<BoolExpr> assumptions, IEnumerable<Expr> variables, out BoolExpr[] consequences) { ASTVector result = new ASTVector(Context); ASTVector asms = new ASTVector(Context); ASTVector vars = new ASTVector(Context); foreach (var asm in assumptions) asms.Push(asm); foreach (var v in variables) vars.Push(v); Z3_lbool r = (Z3_lbool)Native.Z3_solver_get_consequences(Context.nCtx, NativeObject, asms.NativeObject, vars.NativeObject, result.NativeObject); consequences = result.ToBoolExprArray(); return lboolToStatus(r); }
/// <summary> /// Similar to ParseFile. Instead it takes as argument a string. /// </summary> public BoolExpr[] ParseString(string s) { ASTVector av = new ASTVector(Context, Native.Z3_fixedpoint_from_string(Context.nCtx, NativeObject, s)); return(av.ToBoolExprArray()); }
/// <summary> /// Parse an SMT-LIB2 file with fixedpoint rules. /// Add the rules to the current fixedpoint context. /// Return the set of queries in the file. /// </summary> public BoolExpr[] ParseFile(string file) { ASTVector av = new ASTVector(Context, Native.Z3_fixedpoint_from_file(Context.nCtx, NativeObject, file)); return(av.ToBoolExprArray()); }
/// <summary> /// Retrieve an upper bound for the objective handle. /// </summary> private Expr[] GetUpperAsVector(uint index) { using ASTVector v = new ASTVector(Context, Native.Z3_optimize_get_upper_as_vector(Context.nCtx, NativeObject, index)); return(v.ToExprArray()); }
BoolExpr[] ToBoolExprs(ASTVector v) { uint n = v.Size; BoolExpr[] res = new BoolExpr[n]; for (uint i = 0; i < n; i++) res[i] = new BoolExpr(Context, v[i].NativeObject); return res; }
/// <summary> /// Retrieve a lower bound for the objective handle. /// </summary> private ArithExpr[] GetLowerAsVector(uint index) { ASTVector v = new ASTVector(Context, Native.Z3_optimize_get_lower_as_vector(Context.nCtx, NativeObject, index)); return(v.ToArithExprArray()); }
/// <summary> /// Similar to ParseFile. Instead it takes as argument a string. /// </summary> public BoolExpr[] ParseString(string s) { ASTVector av = new ASTVector(Context, Native.Z3_fixedpoint_from_string(Context.nCtx, NativeObject, s)); return av.ToBoolExprArray(); }
/// <summary> /// Parse an SMT-LIB2 file with fixedpoint rules. /// Add the rules to the current fixedpoint context. /// Return the set of queries in the file. /// </summary> public BoolExpr[] ParseFile(string file) { ASTVector av = new ASTVector(Context, Native.Z3_fixedpoint_from_file(Context.nCtx, NativeObject, file)); return av.ToBoolExprArray(); }
/// <summary> /// The finite set of distinct values that represent the interpretation for sort <paramref name="s"/>. /// </summary> /// <seealso cref="Sorts"/> /// <param name="s">An uninterpreted sort</param> /// <returns>An array of expressions, where each is an element of the universe of <paramref name="s"/></returns> public Expr[] SortUniverse(Sort s) { Contract.Requires(s != null); Contract.Ensures(Contract.Result<Expr[]>() != null); ASTVector av = new ASTVector(Context, Native.Z3_model_get_sort_universe(Context.nCtx, NativeObject, s.NativeObject)); return av.ToExprArray(); }