/// <summary> /// Return a set of cubes. /// </summary> public IEnumerable <BoolExpr[]> Cube() { using ASTVector cv = new ASTVector(Context); if (CubeVariables != null) { foreach (var b in CubeVariables) { cv.Push(b); } } while (true) { var lvl = BacktrackLevel; BacktrackLevel = uint.MaxValue; using ASTVector r = new ASTVector(Context, Native.Z3_solver_cube(Context.nCtx, NativeObject, cv.NativeObject, lvl)); var v = r.ToBoolExprArray(); CubeVariables = cv.ToBoolExprArray(); if (v.Length == 1 && v[0].IsFalse) { break; } yield return(v); if (v.Length == 0) { break; } } }
/// <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_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> /// 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) { using ASTVector result = new ASTVector(Context); using ASTVector asms = new ASTVector(Context); using 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> /// 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> /// 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(); }