public void Run() { Dictionary<string, string> cfg = new Dictionary<string, string>() { { "AUTO_CONFIG", "true" } }; using (Context ctx = new Context(cfg)) { IntExpr[] X = new IntExpr[5]; for (uint i = 0; i < 5; i++) X[i] = ctx.MkIntConst(string.Format("x_{0}", i)); RealExpr[] Y = new RealExpr[5]; for (uint i = 0; i < 5; i++) Y[i] = ctx.MkRealConst(string.Format("y_{0}", i)); BoolExpr[] P = new BoolExpr[5]; for (uint i = 0; i < 5; i++) P[i] = ctx.MkBoolConst(string.Format("p_{0}", i)); foreach (Expr x in X) Console.WriteLine(x); foreach (Expr x in Y) Console.WriteLine(x); foreach (Expr x in P) Console.WriteLine(x); foreach (ArithExpr y in Y) Console.WriteLine(ctx.MkPower(y, ctx.MkReal(2))); ArithExpr[] Yp = new ArithExpr[Y.Length]; for (uint i = 0; i < Y.Length; i++) Yp[i] = ctx.MkPower(Y[i], ctx.MkReal(2)); Console.WriteLine(ctx.MkAdd(Yp)); } }
/// <summary> /// Translates an ASTVector into a RealExpr[] /// </summary> public RealExpr[] ToRealExprArray() { uint n = Size; RealExpr[] res = new RealExpr[n]; for (uint i = 0; i < n; i++) { res[i] = (RealExpr)Expr.Create(this.Context, this[i].NativeObject); } return(res); }
/// <summary> /// Coerce a real to an integer. /// </summary> /// <remarks> /// The semantics of this function follows the SMT-LIB standard for the function to_int. /// The argument must be of real sort. /// </remarks> public IntExpr MkReal2Int(RealExpr t) { Contract.Requires(t != null); Contract.Ensures(Contract.Result<IntExpr>() != null); CheckContextMatch(t); return new IntExpr(this, Native.Z3_mk_real2int(nCtx, t.NativeObject)); }
/// <summary> /// Creates an expression that checks whether a real number is an integer. /// </summary> public BoolExpr MkIsInteger(RealExpr t) { Contract.Requires(t != null); Contract.Ensures(Contract.Result<BoolExpr>() != null); CheckContextMatch(t); return new BoolExpr(this, Native.Z3_mk_is_int(nCtx, t.NativeObject)); }
/// <summary> /// Conversion of a real-sorted significand and an integer-sorted exponent into a term of FloatingPoint sort. /// </summary> /// <remarks> /// Produces a term that represents the conversion of sig * 2^exp into a /// floating-point term of sort s. If necessary, the result will be rounded /// according to rounding mode rm. /// </remarks> /// <param name="rm">RoundingMode term.</param> /// <param name="exp">Exponent term of Int sort.</param> /// <param name="sig">Significand term of Real sort.</param> /// <param name="s">FloatingPoint sort.</param> public BitVecExpr MkFPToFP(FPRMExpr rm, IntExpr exp, RealExpr sig, FPSort s) { Contract.Ensures(Contract.Result<BitVecExpr>() != null); return new BitVecExpr(this, Native.Z3_mk_fpa_to_fp_int_real(this.nCtx, rm.NativeObject, exp.NativeObject, sig.NativeObject, s.NativeObject)); }
/// <summary> /// Conversion of a term of real sort into a term of FloatingPoint sort. /// </summary> /// <remarks> /// Produces a term that represents the conversion of term t of real sort into a /// floating-point term of sort s. If necessary, the result will be rounded according /// to rounding mode rm. /// </remarks> /// <param name="rm">RoundingMode term.</param> /// <param name="t">term of Real sort.</param> /// <param name="s">FloatingPoint sort.</param> public FPExpr MkFPToFP(FPRMExpr rm, RealExpr t, FPSort s) { Contract.Ensures(Contract.Result<FPExpr>() != null); return new FPExpr(this, Native.Z3_mk_fpa_to_fp_real(this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject)); }
/// <summary> /// Translates an ASTVector into a RealExpr[] /// </summary> public RealExpr[] ToRealExprArray() { uint n = Size; RealExpr[] res = new RealExpr[n]; for (uint i = 0; i < n; i++) res[i] = (RealExpr)Expr.Create(this.Context, this[i].NativeObject); return res; }