3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-20 12:53:38 +00:00

pull unstable

Signed-off-by: Nikolaj Bjorner <nbjorner@hotmail.com>
This commit is contained in:
Nikolaj Bjorner 2015-04-01 14:57:11 -07:00
commit 52619b9dbb
337 changed files with 24943 additions and 30606 deletions

View file

@ -213,12 +213,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_dec_ref(ctx.nCtx, obj);
}
@ -227,10 +229,8 @@ namespace Microsoft.Z3
internal override void IncRef(IntPtr o)
{
// Console.WriteLine("AST IncRef()");
if (Context == null)
throw new Z3Exception("inc() called on null context");
if (o == IntPtr.Zero)
throw new Z3Exception("inc() called on null AST");
if (Context == null || o == IntPtr.Zero)
return;
Context.AST_DRQ.IncAndClear(Context, o);
base.IncRef(o);
}
@ -238,10 +238,8 @@ namespace Microsoft.Z3
internal override void DecRef(IntPtr o)
{
// Console.WriteLine("AST DecRef()");
if (Context == null)
throw new Z3Exception("dec() called on null context");
if (o == IntPtr.Zero)
throw new Z3Exception("dec() called on null AST");
if (Context == null || o == IntPtr.Zero)
return;
Context.AST_DRQ.Add(o);
base.DecRef(o);
}

View file

@ -128,12 +128,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_ast_map_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_ast_map_dec_ref(ctx.nCtx, obj);
}

View file

@ -105,12 +105,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_ast_vector_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_ast_vector_dec_ref(ctx.nCtx, obj);
}

View file

@ -85,12 +85,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_apply_result_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_apply_result_dec_ref(ctx.nCtx, obj);
}

View file

@ -32,11 +32,6 @@ namespace Microsoft.Z3
{
#region Internal
/// <summary> Constructor for ArithExpr </summary>
internal protected ArithExpr(Context ctx)
: base(ctx)
{
Contract.Requires(ctx != null);
}
internal ArithExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{

View file

@ -32,11 +32,6 @@ namespace Microsoft.Z3
{
#region Internal
/// <summary> Constructor for ArrayExpr </summary>
internal protected ArrayExpr(Context ctx)
: base(ctx)
{
Contract.Requires(ctx != null);
}
internal ArrayExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{

View file

@ -41,7 +41,6 @@ namespace Microsoft.Z3
#region Internal
/// <summary> Constructor for BitVecExpr </summary>
internal protected BitVecExpr(Context ctx) : base(ctx) { Contract.Requires(ctx != null); }
internal BitVecExpr(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
#endregion
}

View file

@ -32,8 +32,6 @@ namespace Microsoft.Z3
{
#region Internal
/// <summary> Constructor for BoolExpr </summary>
internal protected BoolExpr(Context ctx) : base(ctx) { Contract.Requires(ctx != null); }
/// <summary> Constructor for BoolExpr </summary>
internal BoolExpr(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
#endregion
}

View file

@ -3493,6 +3493,805 @@ namespace Microsoft.Z3
}
#endregion
#region Floating-Point Arithmetic
#region Rounding Modes
#region RoundingMode Sort
/// <summary>
/// Create the floating-point RoundingMode sort.
/// </summary>
public FPRMSort MkFPRoundingModeSort()
{
Contract.Ensures(Contract.Result<FPRMSort>() != null);
return new FPRMSort(this);
}
#endregion
#region Numerals
/// <summary>
/// Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode.
/// </summary>
public FPRMExpr MkFPRoundNearestTiesToEven()
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPRMExpr(this, Native.Z3_mk_fpa_round_nearest_ties_to_even(nCtx));
}
/// <summary>
/// Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode.
/// </summary>
public FPRMNum MkFPRNE()
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPRMNum(this, Native.Z3_mk_fpa_rne(nCtx));
}
/// <summary>
/// Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode.
/// </summary>
public FPRMNum MkFPRoundNearestTiesToAway()
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPRMNum(this, Native.Z3_mk_fpa_round_nearest_ties_to_away(nCtx));
}
/// <summary>
/// Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode.
/// </summary>
public FPRMNum MkFPRNA()
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPRMNum(this, Native.Z3_mk_fpa_rna(nCtx));
}
/// <summary>
/// Create a numeral of RoundingMode sort which represents the RoundTowardPositive rounding mode.
/// </summary>
public FPRMNum MkFPRoundTowardPositive()
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPRMNum(this, Native.Z3_mk_fpa_round_toward_positive(nCtx));
}
/// <summary>
/// Create a numeral of RoundingMode sort which represents the RoundTowardPositive rounding mode.
/// </summary>
public FPRMNum MkFPRTP()
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPRMNum(this, Native.Z3_mk_fpa_rtp(nCtx));
}
/// <summary>
/// Create a numeral of RoundingMode sort which represents the RoundTowardNegative rounding mode.
/// </summary>
public FPRMNum MkFPRoundTowardNegative()
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPRMNum(this, Native.Z3_mk_fpa_round_toward_negative(nCtx));
}
/// <summary>
/// Create a numeral of RoundingMode sort which represents the RoundTowardNegative rounding mode.
/// </summary>
public FPRMNum MkFPRTN()
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPRMNum(this, Native.Z3_mk_fpa_rtn(nCtx));
}
/// <summary>
/// Create a numeral of RoundingMode sort which represents the RoundTowardZero rounding mode.
/// </summary>
public FPRMNum MkFPRoundTowardZero()
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPRMNum(this, Native.Z3_mk_fpa_round_toward_zero(nCtx));
}
/// <summary>
/// Create a numeral of RoundingMode sort which represents the RoundTowardZero rounding mode.
/// </summary>
public FPRMNum MkFPRTZ()
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPRMNum(this, Native.Z3_mk_fpa_rtz(nCtx));
}
#endregion
#endregion
#region FloatingPoint Sorts
/// <summary>
/// Create a FloatingPoint sort.
/// </summary>
/// <param name="ebits">exponent bits in the FloatingPoint sort.</param>
/// <param name="sbits">significand bits in the FloatingPoint sort.</param>
public FPSort MkFPSort(uint ebits, uint sbits)
{
Contract.Ensures(Contract.Result<FPSort>() != null);
return new FPSort(this, ebits, sbits);
}
/// <summary>
/// Create the half-precision (16-bit) FloatingPoint sort.
/// </summary>
public FPSort MkFPSortHalf()
{
Contract.Ensures(Contract.Result<FPSort>() != null);
return new FPSort(this, Native.Z3_mk_fpa_sort_half(nCtx));
}
/// <summary>
/// Create the half-precision (16-bit) FloatingPoint sort.
/// </summary>
public FPSort MkFPSort16()
{
Contract.Ensures(Contract.Result<FPSort>() != null);
return new FPSort(this, Native.Z3_mk_fpa_sort_16(nCtx));
}
/// <summary>
/// Create the single-precision (32-bit) FloatingPoint sort.
/// </summary>
public FPSort MkFPSortSingle()
{
Contract.Ensures(Contract.Result<FPSort>() != null);
return new FPSort(this, Native.Z3_mk_fpa_sort_single(nCtx));
}
/// <summary>
/// Create the single-precision (32-bit) FloatingPoint sort.
/// </summary>
public FPSort MkFPSort32()
{
Contract.Ensures(Contract.Result<FPSort>() != null);
return new FPSort(this, Native.Z3_mk_fpa_sort_32(nCtx));
}
/// <summary>
/// Create the double-precision (64-bit) FloatingPoint sort.
/// </summary>
public FPSort MkFPSortDouble()
{
Contract.Ensures(Contract.Result<FPSort>() != null);
return new FPSort(this, Native.Z3_mk_fpa_sort_double(nCtx));
}
/// <summary>
/// Create the double-precision (64-bit) FloatingPoint sort.
/// </summary>
public FPSort MkFPSort64()
{
Contract.Ensures(Contract.Result<FPSort>() != null);
return new FPSort(this, Native.Z3_mk_fpa_sort_64(nCtx));
}
/// <summary>
/// Create the quadruple-precision (128-bit) FloatingPoint sort.
/// </summary>
public FPSort MkFPSortQuadruple()
{
Contract.Ensures(Contract.Result<FPSort>() != null);
return new FPSort(this, Native.Z3_mk_fpa_sort_quadruple(nCtx));
}
/// <summary>
/// Create the quadruple-precision (128-bit) FloatingPoint sort.
/// </summary>
public FPSort MkFPSort128()
{
Contract.Ensures(Contract.Result<FPSort>() != null);
return new FPSort(this, Native.Z3_mk_fpa_sort_128(nCtx));
}
#endregion
#region Numerals
/// <summary>
/// Create a NaN of sort s.
/// </summary>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFPNaN(FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPNum(this, Native.Z3_mk_fpa_nan(nCtx, s.NativeObject));
}
/// <summary>
/// Create a floating-point infinity of sort s.
/// </summary>
/// <param name="s">FloatingPoint sort.</param>
/// <param name="negative">indicates whether the result should be negative.</param>
public FPNum MkFPInf(FPSort s, bool negative)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPNum(this, Native.Z3_mk_fpa_inf(nCtx, s.NativeObject, negative ? 1 : 0));
}
/// <summary>
/// Create a floating-point zero of sort s.
/// </summary>
/// <param name="s">FloatingPoint sort.</param>
/// <param name="negative">indicates whether the result should be negative.</param>
public FPNum MkFPZero(FPSort s, bool negative)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPNum(this, Native.Z3_mk_fpa_zero(nCtx, s.NativeObject, negative ? 1 : 0));
}
/// <summary>
/// Create a numeral of FloatingPoint sort from a float.
/// </summary>
/// <param name="v">numeral value.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFPNumeral(float v, FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPNum(this, Native.Z3_mk_fpa_numeral_float(nCtx, v, s.NativeObject));
}
/// <summary>
/// Create a numeral of FloatingPoint sort from a float.
/// </summary>
/// <param name="v">numeral value.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFPNumeral(double v, FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPNum(this, Native.Z3_mk_fpa_numeral_double(nCtx, v, s.NativeObject));
}
/// <summary>
/// Create a numeral of FloatingPoint sort from an int.
/// </summary>
/// <param name="v">numeral value.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFPNumeral(int v, FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPNum(this, Native.Z3_mk_fpa_numeral_int(nCtx, v, s.NativeObject));
}
/// <summary>
/// Create a numeral of FloatingPoint sort from a sign bit and two integers.
/// </summary>
/// <param name="sgn">the sign.</param>
/// <param name="sig">the significand.</param>
/// <param name="exp">the exponent.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFPNumeral(bool sgn, uint sig, int exp, FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPNum(this, Native.Z3_mk_fpa_numeral_int_uint(nCtx, sgn ? 1 : 0, exp, sig, s.NativeObject));
}
/// <summary>
/// Create a numeral of FloatingPoint sort from a sign bit and two 64-bit integers.
/// </summary>
/// <param name="sgn">the sign.</param>
/// <param name="sig">the significand.</param>
/// <param name="exp">the exponent.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFPNumeral(bool sgn, Int64 exp, UInt64 sig, FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPNum(this, Native.Z3_mk_fpa_numeral_int64_uint64(nCtx, sgn ? 1 : 0, exp, sig, s.NativeObject));
}
/// <summary>
/// Create a numeral of FloatingPoint sort from a float.
/// </summary>
/// <param name="v">numeral value.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFP(float v, FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return MkFPNumeral(v, s);
}
/// <summary>
/// Create a numeral of FloatingPoint sort from a float.
/// </summary>
/// <param name="v">numeral value.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFP(double v, FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return MkFPNumeral(v, s);
}
/// <summary>
/// Create a numeral of FloatingPoint sort from an int.
/// </summary>
/// <param name="v">numeral value.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFP(int v, FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return MkFPNumeral(v, s);
}
/// <summary>
/// Create a numeral of FloatingPoint sort from a sign bit and two integers.
/// </summary>
/// <param name="sgn">the sign.</param>
/// <param name="exp">the exponent.</param>
/// <param name="sig">the significand.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFP(bool sgn, int exp, uint sig, FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return MkFPNumeral(sgn, exp, sig, s);
}
/// <summary>
/// Create a numeral of FloatingPoint sort from a sign bit and two 64-bit integers.
/// </summary>
/// <param name="sgn">the sign.</param>
/// <param name="exp">the exponent.</param>
/// <param name="sig">the significand.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFP(bool sgn, Int64 exp, UInt64 sig, FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return MkFPNumeral(sgn, exp, sig, s);
}
#endregion
#region Operators
/// <summary>
/// Floating-point absolute value
/// </summary>
/// <param name="t">floating-point term</param>
public FPExpr MkFPAbs(FPExpr t)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_abs(this.nCtx, t.NativeObject));
}
/// <summary>
/// Floating-point negation
/// </summary>
/// <param name="t">floating-point term</param>
public FPExpr MkFPNeg(FPExpr t)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_neg(this.nCtx, t.NativeObject));
}
/// <summary>
/// Floating-point addition
/// </summary>
/// <param name="rm">rounding mode term</param>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public FPExpr MkFPAdd(FPRMExpr rm, FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_add(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Floating-point subtraction
/// </summary>
/// <param name="rm">rounding mode term</param>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public FPExpr MkFPSub(FPRMExpr rm, FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_sub(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Floating-point multiplication
/// </summary>
/// <param name="rm">rounding mode term</param>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public FPExpr MkFPMul(FPRMExpr rm, FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_mul(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Floating-point division
/// </summary>
/// <param name="rm">rounding mode term</param>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public FPExpr MkFPDiv(FPRMExpr rm, FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_div(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Floating-point fused multiply-add
/// </summary>
/// <remarks>
/// The result is round((t1 * t2) + t3)
/// </remarks>
/// <param name="rm">rounding mode term</param>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
/// <param name="t3">floating-point term</param>
public FPExpr MkFPFMA(FPRMExpr rm, FPExpr t1, FPExpr t2, FPExpr t3)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_fma(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject, t3.NativeObject));
}
/// <summary>
/// Floating-point square root
/// </summary>
/// <param name="rm">rounding mode term</param>
/// <param name="t">floating-point term</param>
public FPExpr MkFPSqrt(FPRMExpr rm, FPExpr t)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_sqrt(this.nCtx, rm.NativeObject, t.NativeObject));
}
/// <summary>
/// Floating-point remainder
/// </summary>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public FPExpr MkFPRem(FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_rem(this.nCtx, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Floating-point roundToIntegral. Rounds a floating-point number to
/// the closest integer, again represented as a floating-point number.
/// </summary>
/// <param name="rm">term of RoundingMode sort</param>
/// <param name="t">floating-point term</param>
public FPExpr MkFPRoundToIntegral(FPRMExpr rm, FPExpr t)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_round_to_integral(this.nCtx, rm.NativeObject, t.NativeObject));
}
/// <summary>
/// Minimum of floating-point numbers.
/// </summary>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public FPExpr MkFPMin(FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_min(this.nCtx, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Maximum of floating-point numbers.
/// </summary>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public FPExpr MkFPMax(FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_max(this.nCtx, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Floating-point less than or equal.
/// </summary>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public BoolExpr MkFPLEq(FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_leq(this.nCtx, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Floating-point less than.
/// </summary>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public BoolExpr MkFPLt(FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_lt(this.nCtx, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Floating-point greater than or equal.
/// </summary>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public BoolExpr MkFPGEq(FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_geq(this.nCtx, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Floating-point greater than.
/// </summary>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public BoolExpr MkFPGt(FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_gt(this.nCtx, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Floating-point equality.
/// </summary>
/// <remarks>
/// Note that this is IEEE 754 equality (as opposed to standard =).
/// </remarks>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public BoolExpr MkFPEq(FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_eq(this.nCtx, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Predicate indicating whether t is a normal floating-point number.
/// </summary>
/// <param name="t">floating-point term</param>
public BoolExpr MkFPIsNormal(FPExpr t)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_is_normal(this.nCtx, t.NativeObject));
}
/// <summary>
/// Predicate indicating whether t is a subnormal floating-point number.
/// </summary>
/// <param name="t">floating-point term</param>
public BoolExpr MkFPIsSubnormal(FPExpr t)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_is_subnormal(this.nCtx, t.NativeObject));
}
/// <summary>
/// Predicate indicating whether t is a floating-point number with zero value, i.e., +0 or -0.
/// </summary>
/// <param name="t">floating-point term</param>
public BoolExpr MkFPIsZero(FPExpr t)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_is_zero(this.nCtx, t.NativeObject));
}
/// <summary>
/// Predicate indicating whether t is a floating-point number representing +oo or -oo.
/// </summary>
/// <param name="t">floating-point term</param>
public BoolExpr MkFPIsInfinite(FPExpr t)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_is_infinite(this.nCtx, t.NativeObject));
}
/// <summary>
/// Predicate indicating whether t is a NaN.
/// </summary>
/// <param name="t">floating-point term</param>
public BoolExpr MkFPIsNaN(FPExpr t)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_is_nan(this.nCtx, t.NativeObject));
}
/// <summary>
/// Predicate indicating whether t is a negative floating-point number.
/// </summary>
/// <param name="t">floating-point term</param>
public BoolExpr MkFPIsNegative(FPExpr t)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_is_negative(this.nCtx, t.NativeObject));
}
/// <summary>
/// Predicate indicating whether t is a positive floating-point number.
/// </summary>
/// <param name="t">floating-point term</param>
public BoolExpr MkFPIsPositive(FPExpr t)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_is_positive(this.nCtx, t.NativeObject));
}
#endregion
#region Conversions to FloatingPoint terms
/// <summary>
/// Create an expression of FloatingPoint sort from three bit-vector expressions.
/// </summary>
/// <remarks>
/// This is the operator named `fp' in the SMT FP theory definition.
/// Note that sgn is required to be a bit-vector of size 1. Significand and exponent
/// are required to be greater than 1 and 2 respectively. The FloatingPoint sort
/// of the resulting expression is automatically determined from the bit-vector sizes
/// of the arguments.
/// </remarks>
/// <param name="sgn">bit-vector term (of size 1) representing the sign.</param>
/// <param name="sig">bit-vector term representing the significand.</param>
/// <param name="exp">bit-vector term representing the exponent.</param>
public FPExpr MkFP(BitVecExpr sgn, BitVecExpr sig, BitVecExpr exp)
{
Contract.Ensures(Contract.Result<FPExpr>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_fp(this.nCtx, sgn.NativeObject, sig.NativeObject, exp.NativeObject));
}
/// <summary>
/// Conversion of a single IEEE 754-2008 bit-vector into a floating-point number.
/// </summary>
/// <remarks>
/// Produces a term that represents the conversion of a bit-vector term bv to a
/// floating-point term of sort s. The bit-vector size of bv (m) must be equal
/// to ebits+sbits of s. The format of the bit-vector is as defined by the
/// IEEE 754-2008 interchange format.
/// </remarks>
/// <param name="bv">bit-vector value (of size m).</param>
/// <param name="s">FloatingPoint sort (ebits+sbits == m)</param>
public FPExpr MkFPToFP(BitVecExpr bv, FPSort s)
{
Contract.Ensures(Contract.Result<FPExpr>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_to_fp_bv(this.nCtx, bv.NativeObject, s.NativeObject));
}
/// <summary>
/// Conversion of a FloatingPoint term into another term of different FloatingPoint sort.
/// </summary>
/// <remarks>
/// Produces a term that represents the conversion of a floating-point term t to 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">FloatingPoint term.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPExpr MkFPToFP(FPRMExpr rm, FPExpr t, FPSort s)
{
Contract.Ensures(Contract.Result<FPExpr>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_to_fp_float(this.nCtx, rm.NativeObject, t.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>
/// Conversion of a 2's complement signed bit-vector term into a term of FloatingPoint sort.
/// </summary>
/// <remarks>
/// Produces a term that represents the conversion of the bit-vector term t into a
/// floating-point term of sort s. The bit-vector t is taken to be in signed
/// 2's complement format (when signed==true, otherwise unsigned). If necessary, the
/// result will be rounded according to rounding mode rm.
/// </remarks>
/// <param name="rm">RoundingMode term.</param>
/// <param name="t">term of bit-vector sort.</param>
/// <param name="s">FloatingPoint sort.</param>
/// <param name="signed">flag indicating whether t is interpreted as signed or unsigned bit-vector.</param>
public FPExpr MkFPToFP(FPRMExpr rm, BitVecExpr t, FPSort s, bool signed)
{
Contract.Ensures(Contract.Result<FPExpr>() != null);
if (signed)
return new FPExpr(this, Native.Z3_mk_fpa_to_fp_signed(this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
else
return new FPExpr(this, Native.Z3_mk_fpa_to_fp_unsigned(this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
}
/// <summary>
/// Conversion of a floating-point number to another FloatingPoint sort s.
/// </summary>
/// <remarks>
/// Produces a term that represents the conversion of a floating-point term t to a different
/// FloatingPoint sort s. If necessary, rounding according to rm is applied.
/// </remarks>
/// <param name="s">FloatingPoint sort</param>
/// <param name="rm">floating-point rounding mode term</param>
/// <param name="t">floating-point term</param>
public FPExpr MkFPToFP(FPSort s, FPRMExpr rm, FPExpr t)
{
Contract.Ensures(Contract.Result<FPExpr>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_to_fp_float(this.nCtx, s.NativeObject, rm.NativeObject, t.NativeObject));
}
#endregion
#region Conversions from FloatingPoint terms
/// <summary>
/// Conversion of a floating-point term into a bit-vector.
/// </summary>
/// <remarks>
/// Produces a term that represents the conversion of the floating-poiunt term t into a
/// bit-vector term of size sz in 2's complement format (signed when signed==true). If necessary,
/// the result will be rounded according to rounding mode rm.
/// </remarks>
/// <param name="rm">RoundingMode term.</param>
/// <param name="t">FloatingPoint term</param>
/// <param name="sz">Size of the resulting bit-vector.</param>
/// <param name="signed">Indicates whether the result is a signed or unsigned bit-vector.</param>
public BitVecExpr MkFPToBV(FPRMExpr rm, FPExpr t, uint sz, bool signed)
{
Contract.Ensures(Contract.Result<BitVecExpr>() != null);
if (signed)
return new BitVecExpr(this, Native.Z3_mk_fpa_to_sbv(this.nCtx, rm.NativeObject, t.NativeObject, sz));
else
return new BitVecExpr(this, Native.Z3_mk_fpa_to_ubv(this.nCtx, rm.NativeObject, t.NativeObject, sz));
}
/// <summary>
/// Conversion of a floating-point term into a real-numbered term.
/// </summary>
/// <remarks>
/// Produces a term that represents the conversion of the floating-poiunt term t into a
/// real number. Note that this type of conversion will often result in non-linear
/// constraints over real terms.
/// </remarks>
/// <param name="t">FloatingPoint term</param>
public RealExpr MkFPToReal(FPExpr t)
{
Contract.Ensures(Contract.Result<RealExpr>() != null);
return new RealExpr(this, Native.Z3_mk_fpa_to_real(this.nCtx, t.NativeObject));
}
#endregion
#region Z3-specific extensions
/// <summary>
/// Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.
/// </summary>
/// <remarks>
/// The size of the resulting bit-vector is automatically determined. Note that
/// IEEE 754-2008 allows multiple different representations of NaN. This conversion
/// knows only one NaN and it will always produce the same bit-vector represenatation of
/// that NaN.
/// </remarks>
/// <param name="t">FloatingPoint term.</param>
public BitVecExpr MkFPToIEEEBV(FPExpr t)
{
Contract.Ensures(Contract.Result<BitVecExpr>() != null);
return new BitVecExpr(this, Native.Z3_mk_fpa_to_ieee_bv(this.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));
}
#endregion
#endregion // Floating-point Arithmetic
#region Miscellaneous
/// <summary>
@ -3543,17 +4342,7 @@ namespace Microsoft.Z3
public ParamDescrs SimplifyParameterDescriptions
{
get { return new ParamDescrs(this, Native.Z3_simplify_get_param_descrs(nCtx)); }
}
/// <summary>
/// Enable/disable printing of warning messages to the console.
/// </summary>
/// <remarks>Note that this function is static and effects the behaviour of
/// all contexts globally.</remarks>
public static void ToggleWarningMessages(bool enabled)
{
Native.Z3_toggle_warning_messages((enabled) ? 1 : 0);
}
}
#endregion
#region Error Handling
@ -3653,38 +4442,101 @@ namespace Microsoft.Z3
}
readonly private AST.DecRefQueue m_AST_DRQ = new AST.DecRefQueue();
readonly private ASTMap.DecRefQueue m_ASTMap_DRQ = new ASTMap.DecRefQueue();
readonly private ASTVector.DecRefQueue m_ASTVector_DRQ = new ASTVector.DecRefQueue();
readonly private ApplyResult.DecRefQueue m_ApplyResult_DRQ = new ApplyResult.DecRefQueue();
readonly private FuncInterp.Entry.DecRefQueue m_FuncEntry_DRQ = new FuncInterp.Entry.DecRefQueue();
readonly private FuncInterp.DecRefQueue m_FuncInterp_DRQ = new FuncInterp.DecRefQueue();
readonly private Goal.DecRefQueue m_Goal_DRQ = new Goal.DecRefQueue();
readonly private Model.DecRefQueue m_Model_DRQ = new Model.DecRefQueue();
readonly private Params.DecRefQueue m_Params_DRQ = new Params.DecRefQueue();
readonly private ParamDescrs.DecRefQueue m_ParamDescrs_DRQ = new ParamDescrs.DecRefQueue();
readonly private Probe.DecRefQueue m_Probe_DRQ = new Probe.DecRefQueue();
readonly private Solver.DecRefQueue m_Solver_DRQ = new Solver.DecRefQueue();
readonly private Statistics.DecRefQueue m_Statistics_DRQ = new Statistics.DecRefQueue();
readonly private Tactic.DecRefQueue m_Tactic_DRQ = new Tactic.DecRefQueue();
readonly private Fixedpoint.DecRefQueue m_Fixedpoint_DRQ = new Fixedpoint.DecRefQueue();
readonly private Optimize.DecRefQueue m_Optimize_DRQ = new Optimize.DecRefQueue();
readonly private ASTMap.DecRefQueue m_ASTMap_DRQ = new ASTMap.DecRefQueue(10);
readonly private ASTVector.DecRefQueue m_ASTVector_DRQ = new ASTVector.DecRefQueue(10);
readonly private ApplyResult.DecRefQueue m_ApplyResult_DRQ = new ApplyResult.DecRefQueue(10);
readonly private FuncInterp.Entry.DecRefQueue m_FuncEntry_DRQ = new FuncInterp.Entry.DecRefQueue(10);
readonly private FuncInterp.DecRefQueue m_FuncInterp_DRQ = new FuncInterp.DecRefQueue(10);
readonly private Goal.DecRefQueue m_Goal_DRQ = new Goal.DecRefQueue(10);
readonly private Model.DecRefQueue m_Model_DRQ = new Model.DecRefQueue(10);
readonly private Params.DecRefQueue m_Params_DRQ = new Params.DecRefQueue(10);
readonly private ParamDescrs.DecRefQueue m_ParamDescrs_DRQ = new ParamDescrs.DecRefQueue(10);
readonly private Probe.DecRefQueue m_Probe_DRQ = new Probe.DecRefQueue(10);
readonly private Solver.DecRefQueue m_Solver_DRQ = new Solver.DecRefQueue(10);
readonly private Statistics.DecRefQueue m_Statistics_DRQ = new Statistics.DecRefQueue(10);
readonly private Tactic.DecRefQueue m_Tactic_DRQ = new Tactic.DecRefQueue(10);
readonly private Fixedpoint.DecRefQueue m_Fixedpoint_DRQ = new Fixedpoint.DecRefQueue(10);
readonly private Optimize.DecRefQueue m_Optimize_DRQ = new Optimize.DecRefQueue(10);
internal AST.DecRefQueue AST_DRQ { get { Contract.Ensures(Contract.Result<AST.DecRefQueue>() != null); return m_AST_DRQ; } }
internal ASTMap.DecRefQueue ASTMap_DRQ { get { Contract.Ensures(Contract.Result<ASTMap.DecRefQueue>() != null); return m_ASTMap_DRQ; } }
internal ASTVector.DecRefQueue ASTVector_DRQ { get { Contract.Ensures(Contract.Result<ASTVector.DecRefQueue>() != null); return m_ASTVector_DRQ; } }
internal ApplyResult.DecRefQueue ApplyResult_DRQ { get { Contract.Ensures(Contract.Result<ApplyResult.DecRefQueue>() != null); return m_ApplyResult_DRQ; } }
internal FuncInterp.Entry.DecRefQueue FuncEntry_DRQ { get { Contract.Ensures(Contract.Result<FuncInterp.Entry.DecRefQueue>() != null); return m_FuncEntry_DRQ; } }
internal FuncInterp.DecRefQueue FuncInterp_DRQ { get { Contract.Ensures(Contract.Result<FuncInterp.DecRefQueue>() != null); return m_FuncInterp_DRQ; } }
internal Goal.DecRefQueue Goal_DRQ { get { Contract.Ensures(Contract.Result<Goal.DecRefQueue>() != null); return m_Goal_DRQ; } }
internal Model.DecRefQueue Model_DRQ { get { Contract.Ensures(Contract.Result<Model.DecRefQueue>() != null); return m_Model_DRQ; } }
internal Params.DecRefQueue Params_DRQ { get { Contract.Ensures(Contract.Result<Params.DecRefQueue>() != null); return m_Params_DRQ; } }
internal ParamDescrs.DecRefQueue ParamDescrs_DRQ { get { Contract.Ensures(Contract.Result<ParamDescrs.DecRefQueue>() != null); return m_ParamDescrs_DRQ; } }
internal Probe.DecRefQueue Probe_DRQ { get { Contract.Ensures(Contract.Result<Probe.DecRefQueue>() != null); return m_Probe_DRQ; } }
internal Solver.DecRefQueue Solver_DRQ { get { Contract.Ensures(Contract.Result<Solver.DecRefQueue>() != null); return m_Solver_DRQ; } }
internal Statistics.DecRefQueue Statistics_DRQ { get { Contract.Ensures(Contract.Result<Statistics.DecRefQueue>() != null); return m_Statistics_DRQ; } }
internal Tactic.DecRefQueue Tactic_DRQ { get { Contract.Ensures(Contract.Result<Tactic.DecRefQueue>() != null); return m_Tactic_DRQ; } }
internal Fixedpoint.DecRefQueue Fixedpoint_DRQ { get { Contract.Ensures(Contract.Result<Fixedpoint.DecRefQueue>() != null); return m_Fixedpoint_DRQ; } }
internal Optimize.DecRefQueue Optimize_DRQ { get { Contract.Ensures(Contract.Result<Optimize.DecRefQueue>() != null); return m_Optimize_DRQ; } }
/// <summary>
/// AST DRQ
/// </summary>
public IDecRefQueue AST_DRQ { get { Contract.Ensures(Contract.Result<AST.DecRefQueue>() != null); return m_AST_DRQ; } }
/// <summary>
/// ASTMap DRQ
/// </summary>
public IDecRefQueue ASTMap_DRQ { get { Contract.Ensures(Contract.Result<ASTMap.DecRefQueue>() != null); return m_ASTMap_DRQ; } }
/// <summary>
/// ASTVector DRQ
/// </summary>
public IDecRefQueue ASTVector_DRQ { get { Contract.Ensures(Contract.Result<ASTVector.DecRefQueue>() != null); return m_ASTVector_DRQ; } }
/// <summary>
/// ApplyResult DRQ
/// </summary>
public IDecRefQueue ApplyResult_DRQ { get { Contract.Ensures(Contract.Result<ApplyResult.DecRefQueue>() != null); return m_ApplyResult_DRQ; } }
/// <summary>
/// FuncEntry DRQ
/// </summary>
public IDecRefQueue FuncEntry_DRQ { get { Contract.Ensures(Contract.Result<FuncInterp.Entry.DecRefQueue>() != null); return m_FuncEntry_DRQ; } }
/// <summary>
/// FuncInterp DRQ
/// </summary>
public IDecRefQueue FuncInterp_DRQ { get { Contract.Ensures(Contract.Result<FuncInterp.DecRefQueue>() != null); return m_FuncInterp_DRQ; } }
/// <summary>
/// Goal DRQ
/// </summary>
public IDecRefQueue Goal_DRQ { get { Contract.Ensures(Contract.Result<Goal.DecRefQueue>() != null); return m_Goal_DRQ; } }
/// <summary>
/// Model DRQ
/// </summary>
public IDecRefQueue Model_DRQ { get { Contract.Ensures(Contract.Result<Model.DecRefQueue>() != null); return m_Model_DRQ; } }
/// <summary>
/// Params DRQ
/// </summary>
public IDecRefQueue Params_DRQ { get { Contract.Ensures(Contract.Result<Params.DecRefQueue>() != null); return m_Params_DRQ; } }
/// <summary>
/// ParamDescrs DRQ
/// </summary>
public IDecRefQueue ParamDescrs_DRQ { get { Contract.Ensures(Contract.Result<ParamDescrs.DecRefQueue>() != null); return m_ParamDescrs_DRQ; } }
/// <summary>
/// Probe DRQ
/// </summary>
public IDecRefQueue Probe_DRQ { get { Contract.Ensures(Contract.Result<Probe.DecRefQueue>() != null); return m_Probe_DRQ; } }
/// <summary>
/// Solver DRQ
/// </summary>
public IDecRefQueue Solver_DRQ { get { Contract.Ensures(Contract.Result<Solver.DecRefQueue>() != null); return m_Solver_DRQ; } }
/// <summary>
/// Statistics DRQ
/// </summary>
public IDecRefQueue Statistics_DRQ { get { Contract.Ensures(Contract.Result<Statistics.DecRefQueue>() != null); return m_Statistics_DRQ; } }
/// <summary>
/// Tactic DRQ
/// </summary>
public IDecRefQueue Tactic_DRQ { get { Contract.Ensures(Contract.Result<Tactic.DecRefQueue>() != null); return m_Tactic_DRQ; } }
/// <summary>
/// FixedPoint DRQ
/// </summary>
public IDecRefQueue Fixedpoint_DRQ { get { Contract.Ensures(Contract.Result<Fixedpoint.DecRefQueue>() != null); return m_Fixedpoint_DRQ; } }
/// <summary>
/// Optimize DRQ
/// </summary>
public IDecRefQueue Optimize_DRQ { get { Contract.Ensures(Contract.Result<Optimize.DecRefQueue>() != null); return m_Fixedpoint_DRQ; } }
internal long refCount = 0;

View file

@ -32,11 +32,6 @@ namespace Microsoft.Z3
{
#region Internal
/// <summary> Constructor for DatatypeExpr </summary>
internal protected DatatypeExpr(Context ctx)
: base(ctx)
{
Contract.Requires(ctx != null);
}
internal DatatypeExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{

View file

@ -44,6 +44,16 @@ namespace Microsoft.Z3
}
}
/// <summary>
/// Retrieves the inx'th constant declaration in the enumeration.
/// </summary>
/// <param name="inx"></param>
/// <returns></returns>
public FuncDecl ConstDecl(uint inx)
{
return new FuncDecl(Context, Native.Z3_get_datatype_sort_constructor(Context.nCtx, NativeObject, inx));
}
/// <summary>
/// The constants in the enumeration.
/// </summary>
@ -61,7 +71,17 @@ namespace Microsoft.Z3
}
/// <summary>
/// The test predicates for the constants in the enumeration.
/// Retrieves the inx'th constant in the enumeration.
/// </summary>
/// <param name="inx"></param>
/// <returns></returns>
public Expr Const(uint inx)
{
return Context.MkApp(ConstDecl(inx));
}
/// <summary>
/// The test predicates (recognizers) for the constants in the enumeration.
/// </summary>
public FuncDecl[] TesterDecls
{
@ -76,9 +96,19 @@ namespace Microsoft.Z3
}
}
/// <summary>
/// Retrieves the inx'th tester/recognizer declaration in the enumeration.
/// </summary>
/// <param name="inx"></param>
/// <returns></returns>
public FuncDecl TesterDecl(uint inx)
{
return new FuncDecl(Context, Native.Z3_get_datatype_sort_recognizer(Context.nCtx, NativeObject, inx));
}
#region Internal
internal EnumSort(Context ctx, Symbol name, Symbol[] enumNames)
: base(ctx)
: base(ctx, IntPtr.Zero)
{
Contract.Requires(ctx != null);
Contract.Requires(name != null);

View file

@ -1311,7 +1311,7 @@ namespace Microsoft.Z3
#region Relational Terms
/// <summary>
/// Indicates whether the term is of an array sort.
/// Indicates whether the term is of relation sort.
/// </summary>
public bool IsRelation
{
@ -1448,6 +1448,281 @@ namespace Microsoft.Z3
/// Indicates whether the term is a less than predicate over a finite domain.
/// </summary>
public bool IsFiniteDomainLT { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FD_LT; } }
#endregion
#region Floating-point terms
/// <summary>
/// Indicates whether the terms is of floating-point sort.
/// </summary>
public bool IsFP
{
get { return Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) == (uint)Z3_sort_kind.Z3_FLOATING_POINT_SORT; }
}
/// <summary>
/// Indicates whether the terms is of floating-point rounding mode sort.
/// </summary>
public bool IsFPRM
{
get { return Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) == (uint)Z3_sort_kind.Z3_ROUNDING_MODE_SORT; }
}
/// <summary>
/// Indicates whether the term is a floating-point numeral
/// </summary>
public bool IsFPNumeral { get { return IsFP && IsNumeral; } }
/// <summary>
/// Indicates whether the term is a floating-point rounding mode numeral
/// </summary>
public bool IsFPRMNumeral { get { return IsFPRM && IsNumeral; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToEven
/// </summary>
public bool IsFPRMRoundNearestTiesToEven{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToAway
/// </summary>
public bool IsFPRMRoundNearestTiesToAway{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardNegative
/// </summary>
public bool IsFPRMRoundTowardNegative{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_NEGATIVE; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardPositive
/// </summary>
public bool IsFPRMRoundTowardPositive{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_POSITIVE; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardZero
/// </summary>
public bool IsFPRMRoundTowardZero{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_ZERO; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToEven
/// </summary>
public bool IsFPRMExprRNE{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToAway
/// </summary>
public bool IsFPRMExprRNA { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardNegative
/// </summary>
public bool IsFPRMExprRTN { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_NEGATIVE; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardPositive
/// </summary>
public bool IsFPRMExprRTP { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_POSITIVE; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardZero
/// </summary>
public bool IsFPRMExprRTZ { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_ZERO; } }
/// <summary>
/// Indicates whether the term is a floating-point rounding mode numeral
/// </summary>
public bool IsFPRMExpr {
get {
return IsApp &&
(FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY||
FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN ||
FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_POSITIVE ||
FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_NEGATIVE ||
FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_ZERO);
}
}
/// <summary>
/// Indicates whether the term is a floating-point +oo
/// </summary>
public bool IsFPPlusInfinity{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_PLUS_INF; } }
/// <summary>
/// Indicates whether the term is a floating-point -oo
/// </summary>
public bool IsFPMinusInfinity{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_MINUS_INF; } }
/// <summary>
/// Indicates whether the term is a floating-point NaN
/// </summary>
public bool IsFPNaN { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_NAN; } }
/// <summary>
/// Indicates whether the term is a floating-point +zero
/// </summary>
public bool IsFPPlusZero { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_PLUS_ZERO; } }
/// <summary>
/// Indicates whether the term is a floating-point -zero
/// </summary>
public bool IsFPMinusZero { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_MINUS_ZERO; } }
/// <summary>
/// Indicates whether the term is a floating-point addition term
/// </summary>
public bool IsFPAdd { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_ADD; } }
/// <summary>
/// Indicates whether the term is a floating-point subtraction term
/// </summary>
public bool IsFPSub { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_SUB; } }
/// <summary>
/// Indicates whether the term is a floating-point negation term
/// </summary>
public bool IsFPNeg { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_NEG; } }
/// <summary>
/// Indicates whether the term is a floating-point multiplication term
/// </summary>
public bool IsFPMul { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_MUL; } }
/// <summary>
/// Indicates whether the term is a floating-point divison term
/// </summary>
public bool IsFPDiv { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_DIV; } }
/// <summary>
/// Indicates whether the term is a floating-point remainder term
/// </summary>
public bool IsFPRem { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_REM; } }
/// <summary>
/// Indicates whether the term is a floating-point term absolute value term
/// </summary>
public bool IsFPAbs { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_ABS; } }
/// <summary>
/// Indicates whether the term is a floating-point minimum term
/// </summary>
public bool IsFPMin { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_MIN; } }
/// <summary>
/// Indicates whether the term is a floating-point maximum term
/// </summary>
public bool IsFPMax { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_MAX; } }
/// <summary>
/// Indicates whether the term is a floating-point fused multiply-add term
/// </summary>
public bool IsFPFMA { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_FMA; } }
/// <summary>
/// Indicates whether the term is a floating-point square root term
/// </summary>
public bool IsFPSqrt { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_SQRT; } }
/// <summary>
/// Indicates whether the term is a floating-point roundToIntegral term
/// </summary>
public bool IsFPRoundToIntegral { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_ROUND_TO_INTEGRAL; } }
/// <summary>
/// Indicates whether the term is a floating-point equality term
/// </summary>
public bool IsFPEq { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_EQ; } }
/// <summary>
/// Indicates whether the term is a floating-point less-than term
/// </summary>
public bool IsFPLt { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_LT; } }
/// <summary>
/// Indicates whether the term is a floating-point greater-than term
/// </summary>
public bool IsFPGt { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_GT; } }
/// <summary>
/// Indicates whether the term is a floating-point less-than or equal term
/// </summary>
public bool IsFPLe { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_LE; } }
/// <summary>
/// Indicates whether the term is a floating-point greater-than or erqual term
/// </summary>
public bool IsFPGe { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_GE; } }
/// <summary>
/// Indicates whether the term is a floating-point isNaN predicate term
/// </summary>
public bool IsFPisNaN { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_NAN; } }
/// <summary>
/// Indicates whether the term is a floating-point isInf predicate term
/// </summary>
public bool IsFPisInf { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_INF; } }
/// <summary>
/// Indicates whether the term is a floating-point isZero predicate term
/// </summary>
public bool IsFPisZero { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_ZERO; } }
/// <summary>
/// Indicates whether the term is a floating-point isNormal term
/// </summary>
public bool IsFPisNormal { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_NORMAL; } }
/// <summary>
/// Indicates whether the term is a floating-point isSubnormal predicate term
/// </summary>
public bool IsFPisSubnormal { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_SUBNORMAL; } }
/// <summary>
/// Indicates whether the term is a floating-point isNegative predicate term
/// </summary>
public bool IsFPisNegative { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_NEGATIVE; } }
/// <summary>
/// Indicates whether the term is a floating-point isPositive predicate term
/// </summary>
public bool IsFPisPositive { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_POSITIVE; } }
/// <summary>
/// Indicates whether the term is a floating-point constructor term
/// </summary>
public bool IsFPFP { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_FP; } }
/// <summary>
/// Indicates whether the term is a floating-point conversion term
/// </summary>
public bool IsFPToFp { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_TO_FP; } }
/// <summary>
/// Indicates whether the term is a floating-point conversion from unsigned bit-vector term
/// </summary>
public bool IsFPToFpUnsigned { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_TO_FP_UNSIGNED; } }
/// <summary>
/// Indicates whether the term is a floating-point conversion to unsigned bit-vector term
/// </summary>
public bool IsFPToUBV { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_TO_UBV; } }
/// <summary>
/// Indicates whether the term is a floating-point conversion to signed bit-vector term
/// </summary>
public bool IsFPToSBV { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_TO_SBV; } }
/// <summary>
/// Indicates whether the term is a floating-point conversion to real term
/// </summary>
public bool IsFPToReal { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_TO_REAL; } }
/// <summary>
/// Indicates whether the term is a floating-point conversion to IEEE-754 bit-vector term
/// </summary>
public bool IsFPToIEEEBV { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_TO_IEEE_BV; } }
#endregion
#endregion
@ -1489,10 +1764,6 @@ namespace Microsoft.Z3
/// <summary>
/// Constructor for Expr
/// </summary>
internal protected Expr(Context ctx) : base(ctx) { Contract.Requires(ctx != null); }
/// <summary>
/// Constructor for Expr
/// </summary>
internal protected Expr(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
#if DEBUG
@ -1541,7 +1812,9 @@ namespace Microsoft.Z3
{
case Z3_sort_kind.Z3_INT_SORT: return new IntNum(ctx, obj);
case Z3_sort_kind.Z3_REAL_SORT: return new RatNum(ctx, obj);
case Z3_sort_kind.Z3_BV_SORT: return new BitVecNum(ctx, obj);
case Z3_sort_kind.Z3_BV_SORT: return new BitVecNum(ctx, obj);
case Z3_sort_kind.Z3_FLOATING_POINT_SORT: return new FPNum(ctx, obj);
case Z3_sort_kind.Z3_ROUNDING_MODE_SORT: return new FPRMNum(ctx, obj);
}
}
@ -1552,7 +1825,9 @@ namespace Microsoft.Z3
case Z3_sort_kind.Z3_REAL_SORT: return new RealExpr(ctx, obj);
case Z3_sort_kind.Z3_BV_SORT: return new BitVecExpr(ctx, obj);
case Z3_sort_kind.Z3_ARRAY_SORT: return new ArrayExpr(ctx, obj);
case Z3_sort_kind.Z3_DATATYPE_SORT: return new DatatypeExpr(ctx, obj);
case Z3_sort_kind.Z3_DATATYPE_SORT: return new DatatypeExpr(ctx, obj);
case Z3_sort_kind.Z3_FLOATING_POINT_SORT: return new FPExpr(ctx, obj);
case Z3_sort_kind.Z3_ROUNDING_MODE_SORT: return new FPRMExpr(ctx, obj);
}
return new Expr(ctx, obj);

52
src/api/dotnet/FPExpr.cs Normal file
View file

@ -0,0 +1,52 @@
/*++
Copyright (c) 2013 Microsoft Corporation
Module Name:
FPExpr.cs
Abstract:
Z3 Managed API: Floating Point Expressions
Author:
Christoph Wintersteiger (cwinter) 2013-06-10
Notes:
--*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// FloatingPoint Expressions
/// </summary>
public class FPExpr : Expr
{
/// <summary>
/// The number of exponent bits.
/// </summary>
public uint EBits { get { return ((FPSort)Sort).EBits; } }
/// <summary>
/// The number of significand bits.
/// </summary>
public uint SBits { get { return ((FPSort)Sort).EBits; } }
#region Internal
/// <summary> Constructor for FPExpr </summary>
internal FPExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
}
#endregion
}
}

103
src/api/dotnet/FPNum.cs Normal file
View file

@ -0,0 +1,103 @@
/*++
Copyright (c) 2013 Microsoft Corporation
Module Name:
FPNum.cs
Abstract:
Z3 Managed API: Floating Point Numerals
Author:
Christoph Wintersteiger (cwinter) 2013-06-10
Notes:
--*/
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// FloatiungPoint Numerals
/// </summary>
[ContractVerification(true)]
public class FPNum : FPExpr
{
/// <summary>
/// Retrieves the sign of a floating-point literal
/// </summary>
/// <remarks>
/// Remarks: returns true if the numeral is negative
/// </remarks>
public bool Sign
{
get
{
int res = 0;
if (Native.Z3_fpa_get_numeral_sign(Context.nCtx, NativeObject, ref res) == 0)
throw new Z3Exception("Sign is not a Boolean value");
return res != 0;
}
}
/// <summary>
/// The significand value of a floating-point numeral as a string
/// </summary>
/// <remarks>
/// The significand s is always 0 &lt; s &lt; 2.0; the resulting string is long
/// enough to represent the real significand precisely.
/// </remarks>
public string Significand
{
get
{
return Native.Z3_fpa_get_numeral_significand_string(Context.nCtx, NativeObject);
}
}
/// <summary>
/// Return the exponent value of a floating-point numeral as a string
/// </summary>
public string Exponent
{
get
{
return Native.Z3_fpa_get_numeral_exponent_string(Context.nCtx, NativeObject);
}
}
/// <summary>
/// Return the exponent value of a floating-point numeral as a signed 64-bit integer
/// </summary>
public Int64 ExponentInt64
{
get
{
Int64 result = 0;
if (Native.Z3_fpa_get_numeral_exponent_int64(Context.nCtx, NativeObject, ref result) == 0)
throw new Z3Exception("Exponent is not a 64 bit integer");
return result;
}
}
#region Internal
internal FPNum(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
}
#endregion
/// <summary>
/// Returns a string representation of the numeral.
/// </summary>
public override string ToString()
{
return Native.Z3_get_numeral_string(Context.nCtx, NativeObject);
}
}
}

View file

@ -0,0 +1,42 @@
/*++
Copyright (c) 2013 Microsoft Corporation
Module Name:
FPRMExpr.cs
Abstract:
Z3 Managed API: Floating Point Expressions over Rounding Modes
Author:
Christoph Wintersteiger (cwinter) 2013-06-10
Notes:
--*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// FloatingPoint RoundingMode Expressions
/// </summary>
public class FPRMExpr : Expr
{
#region Internal
/// <summary> Constructor for FPRMExpr </summary>
internal FPRMExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
}
#endregion
}
}

100
src/api/dotnet/FPRMNum.cs Normal file
View file

@ -0,0 +1,100 @@
/*++
Copyright (c) 2013 Microsoft Corporation
Module Name:
FPRMExpr.cs
Abstract:
Z3 Managed API: Floating Point Rounding Mode Numerals
Author:
Christoph Wintersteiger (cwinter) 2013-06-10
Notes:
--*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// Floating-point rounding mode numerals
/// </summary>
public class FPRMNum : FPRMExpr
{
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToEven
/// </summary>
public bool isRoundNearestTiesToEven { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToEven
/// </summary>
public bool isRNE { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToAway
/// </summary>
public bool isRoundNearestTiesToAway { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToAway
/// </summary>
public bool isRNA { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardPositive
/// </summary>
public bool isRoundTowardPositive { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_POSITIVE; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardPositive
/// </summary>
public bool isRTP { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_POSITIVE; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardNegative
/// </summary>
public bool isRoundTowardNegative { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_NEGATIVE; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardNegative
/// </summary>
public bool isRTN { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_NEGATIVE; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardZero
/// </summary>
public bool isRoundTowardZero { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_ZERO; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardZero
/// </summary>
public bool isRTZ { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_ZERO; } }
/// <summary>
/// Returns a string representation of the numeral.
/// </summary>
public override string ToString()
{
return Native.Z3_get_numeral_string(Context.nCtx, NativeObject);
}
#region Internal
/// <summary> Constructor for FPRMNum </summary>
internal FPRMNum(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
}
#endregion
}
}

View file

@ -0,0 +1,43 @@
/*++
Copyright (c) 2013 Microsoft Corporation
Module Name:
FPRMSort.cs
Abstract:
Z3 Managed API: Rounding Mode Sort
Author:
Christoph Wintersteiger (cwinter) 2013-06-10
Notes:
--*/
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// The FloatingPoint RoundingMode sort
/// </summary>
public class FPRMSort : Sort
{
#region Internal
internal FPRMSort(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
}
internal FPRMSort(Context ctx)
: base(ctx, Native.Z3_mk_fpa_rounding_mode_sort(ctx.nCtx))
{
Contract.Requires(ctx != null);
}
#endregion
}
}

52
src/api/dotnet/FPSort.cs Normal file
View file

@ -0,0 +1,52 @@
/*++
Copyright (c) 2013 Microsoft Corporation
Module Name:
FPSort.cs
Abstract:
Z3 Managed API: Floating Point Sorts
Author:
Christoph Wintersteiger (cwinter) 2013-06-10
Notes:
--*/
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// FloatingPoint sort
/// </summary>
public class FPSort : Sort
{
/// <summary>
/// The number of exponent bits.
/// </summary>
public uint EBits { get { return Native.Z3_fpa_get_ebits(Context.nCtx, NativeObject); } }
/// <summary>
/// The number of significand bits.
/// </summary>
public uint SBits { get { return Native.Z3_fpa_get_sbits(Context.nCtx, NativeObject); } }
#region Internal
internal FPSort(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
}
internal FPSort(Context ctx, uint ebits, uint sbits)
: base(ctx, Native.Z3_mk_fpa_sort(ctx.nCtx, ebits, sbits))
{
Contract.Requires(ctx != null);
}
#endregion
}
}

View file

@ -348,12 +348,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_fixedpoint_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_fixedpoint_dec_ref(ctx.nCtx, obj);
}

View file

@ -91,12 +91,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_func_entry_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_func_entry_dec_ref(ctx.nCtx, obj);
}
@ -197,12 +199,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_func_interp_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_func_interp_dec_ref(ctx.nCtx, obj);
}

View file

@ -82,6 +82,40 @@ namespace Microsoft.Z3
public static void ResetParameters()
{
Native.Z3_global_param_reset_all();
}
}
/// <summary>
/// Enable/disable printing of warning messages to the console.
/// </summary>
/// <remarks>Note that this function is static and effects the behaviour of
/// all contexts globally.</remarks>
public static void ToggleWarningMessages(bool enabled)
{
Native.Z3_toggle_warning_messages((enabled) ? 1 : 0);
}
/// <summary>
/// Enable tracing messages tagged as `tag' when Z3 is compiled in debug mode.
/// </summary>
/// <remarks>
/// It is a NOOP otherwise.
/// </remarks>
/// <param name="tag">trace tag</param>
public static void EnableTrace(string tag)
{
Native.Z3_enable_trace(tag);
}
/// <summary>
/// Disable tracing messages tagged as `tag' when Z3 is compiled in debug mode.
/// </summary>
/// <remarks>
/// It is a NOOP otherwise.
/// </remarks>
/// <param name="tag">trace tag</param>
public static void DisableTrace(string tag)
{
Native.Z3_disable_trace(tag);
}
}
}

View file

@ -219,12 +219,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_goal_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_goal_dec_ref(ctx.nCtx, obj);
}

View file

@ -25,8 +25,11 @@ using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// DecRefQueue interface
/// </summary>
[ContractClass(typeof(DecRefQueueContracts))]
internal abstract class IDecRefQueue
public abstract class IDecRefQueue
{
#region Object invariant
@ -38,14 +41,25 @@ namespace Microsoft.Z3
#endregion
readonly internal protected Object m_lock = new Object();
readonly internal protected List<IntPtr> m_queue = new List<IntPtr>();
internal const uint m_move_limit = 1024;
readonly private Object m_lock = new Object();
readonly private List<IntPtr> m_queue = new List<IntPtr>();
private uint m_move_limit;
public abstract void IncRef(Context ctx, IntPtr obj);
public abstract void DecRef(Context ctx, IntPtr obj);
internal IDecRefQueue(uint move_limit = 1024)
{
m_move_limit = move_limit;
}
public void IncAndClear(Context ctx, IntPtr o)
/// <summary>
/// Sets the limit on numbers of objects that are kept back at GC collection.
/// </summary>
/// <param name="l"></param>
public void SetLimit(uint l) { m_move_limit = l; }
internal abstract void IncRef(Context ctx, IntPtr obj);
internal abstract void DecRef(Context ctx, IntPtr obj);
internal void IncAndClear(Context ctx, IntPtr o)
{
Contract.Requires(ctx != null);
@ -53,7 +67,7 @@ namespace Microsoft.Z3
if (m_queue.Count >= m_move_limit) Clear(ctx);
}
public void Add(IntPtr o)
internal void Add(IntPtr o)
{
if (o == IntPtr.Zero) return;
@ -63,7 +77,7 @@ namespace Microsoft.Z3
}
}
public void Clear(Context ctx)
internal void Clear(Context ctx)
{
Contract.Requires(ctx != null);
@ -79,12 +93,12 @@ namespace Microsoft.Z3
[ContractClassFor(typeof(IDecRefQueue))]
abstract class DecRefQueueContracts : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
internal override void IncRef(Context ctx, IntPtr obj)
{
Contract.Requires(ctx != null);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Contract.Requires(ctx != null);
}

View file

@ -1,5 +1,5 @@
/*++
Copyright (<c>) 2012 Microsoft Corporation
Copyright (c) 2012 Microsoft Corporation
Module Name:
@ -32,11 +32,6 @@ namespace Microsoft.Z3
{
#region Internal
/// <summary> Constructor for IntExpr </summary>
internal protected IntExpr(Context ctx)
: base(ctx)
{
Contract.Requires(ctx != null);
}
internal IntExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{

View file

@ -13,7 +13,7 @@ namespace Microsoft.Z3
/// <remarks>For more information on interpolation please refer
/// too the C/C++ API, which is well documented.</remarks>
[ContractVerification(true)]
class InterpolationContext : Context
public class InterpolationContext : Context
{
/// <summary>

View file

@ -113,9 +113,9 @@ namespace Microsoft.Z3
}
}
#region Internal
#region Internal
internal ListSort(Context ctx, Symbol name, Sort elemSort)
: base(ctx)
: base(ctx, IntPtr.Zero)
{
Contract.Requires(ctx != null);
Contract.Requires(name != null);

View file

@ -342,6 +342,12 @@
<Compile Include="ConstructorList.cs" />
<Compile Include="DatatypeExpr.cs" />
<Compile Include="DatatypeSort.cs" />
<Compile Include="FPExpr.cs" />
<Compile Include="FPNum.cs" />
<Compile Include="FPRMExpr.cs" />
<Compile Include="FPRMNum.cs" />
<Compile Include="FPRMSort.cs" />
<Compile Include="FPSort.cs" />
<Compile Include="Global.cs" />
<Compile Include="IDecRefQueue.cs" />
<Compile Include="Enumerations.cs" />

View file

@ -291,12 +291,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_model_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_model_dec_ref(ctx.nCtx, obj);
}

View file

@ -269,12 +269,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_optimize_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_optimize_dec_ref(ctx.nCtx, obj);
}

View file

@ -87,12 +87,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_param_descrs_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_param_descrs_dec_ref(ctx.nCtx, obj);
}

View file

@ -23,7 +23,7 @@ using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// A ParameterSet represents a configuration in the form of Symbol/value pairs.
/// A Params objects represents a configuration in the form of Symbol/value pairs.
/// </summary>
[ContractVerification(true)]
public class Params : Z3Object
@ -142,12 +142,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_params_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_params_dec_ref(ctx.nCtx, obj);
}

View file

@ -73,12 +73,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_probe_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_probe_dec_ref(ctx.nCtx, obj);
}

View file

@ -160,7 +160,7 @@ namespace Microsoft.Z3
#region Internal
[ContractVerification(false)] // F: Clousot ForAll decompilation gets confused below. Setting verification off until I fixed the bug
internal Quantifier(Context ctx, bool isForall, Sort[] sorts, Symbol[] names, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null)
: base(ctx)
: base(ctx, IntPtr.Zero)
{
Contract.Requires(ctx != null);
Contract.Requires(sorts != null);
@ -203,7 +203,7 @@ namespace Microsoft.Z3
[ContractVerification(false)] // F: Clousot ForAll decompilation gets confused below. Setting verification off until I fixed the bug
internal Quantifier(Context ctx, bool isForall, Expr[] bound, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null)
: base(ctx)
: base(ctx, IntPtr.Zero)
{
Contract.Requires(ctx != null);
Contract.Requires(body != null);

View file

@ -32,11 +32,6 @@ namespace Microsoft.Z3
{
#region Internal
/// <summary> Constructor for RealExpr </summary>
internal protected RealExpr(Context ctx)
: base(ctx)
{
Contract.Requires(ctx != null);
}
internal RealExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{

View file

@ -328,12 +328,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_solver_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_solver_dec_ref(ctx.nCtx, obj);
}

View file

@ -116,8 +116,7 @@ namespace Microsoft.Z3
#region Internal
/// <summary>
/// Sort constructor
/// </summary>
internal protected Sort(Context ctx) : base(ctx) { Contract.Requires(ctx != null); }
/// </summary>
internal Sort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
#if DEBUG
@ -146,6 +145,8 @@ namespace Microsoft.Z3
case Z3_sort_kind.Z3_UNINTERPRETED_SORT: return new UninterpretedSort(ctx, obj);
case Z3_sort_kind.Z3_FINITE_DOMAIN_SORT: return new FiniteDomainSort(ctx, obj);
case Z3_sort_kind.Z3_RELATION_SORT: return new RelationSort(ctx, obj);
case Z3_sort_kind.Z3_FLOATING_POINT_SORT: return new FPSort(ctx, obj);
case Z3_sort_kind.Z3_ROUNDING_MODE_SORT: return new FPRMSort(ctx, obj);
default:
throw new Z3Exception("Unknown sort kind");
}

View file

@ -189,12 +189,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_stats_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_stats_dec_ref(ctx.nCtx, obj);
}

View file

@ -112,14 +112,19 @@ namespace Microsoft.Z3
Contract.Requires(ctx != null);
}
/// <summary>
/// DecRefQueue
/// </summary>
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_tactic_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_tactic_dec_ref(ctx.nCtx, obj);
}

View file

@ -68,7 +68,7 @@ namespace Microsoft.Z3
#region Internal
internal TupleSort(Context ctx, Symbol name, uint numFields, Symbol[] fieldNames, Sort[] fieldSorts)
: base(ctx)
: base(ctx, IntPtr.Zero)
{
Contract.Requires(ctx != null);
Contract.Requires(name != null);