mirror of
https://github.com/Z3Prover/z3
synced 2025-04-14 21:08:46 +00:00
merge
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
commit
05738702d6
|
@ -718,17 +718,11 @@ def mk_install_tactic_cpp_internal(h_files_full_path, path):
|
|||
fullname, line))
|
||||
raise e
|
||||
# First pass will just generate the tactic factories
|
||||
idx = 0
|
||||
for data in ADD_TACTIC_DATA:
|
||||
fout.write('MK_SIMPLE_TACTIC_FACTORY(__Z3_local_factory_%s, %s);\n' % (idx, data[2]))
|
||||
idx = idx + 1
|
||||
fout.write('#define ADD_TACTIC_CMD(NAME, DESCR, FACTORY) ctx.insert(alloc(tactic_cmd, symbol(NAME), DESCR, alloc(FACTORY)))\n')
|
||||
fout.write('#define ADD_TACTIC_CMD(NAME, DESCR, CODE) ctx.insert(alloc(tactic_cmd, symbol(NAME), DESCR, [](ast_manager &m, const params_ref &p) { return CODE; }))\n')
|
||||
fout.write('#define ADD_PROBE(NAME, DESCR, PROBE) ctx.insert(alloc(probe_info, symbol(NAME), DESCR, PROBE))\n')
|
||||
fout.write('void install_tactics(tactic_manager & ctx) {\n')
|
||||
idx = 0
|
||||
for data in ADD_TACTIC_DATA:
|
||||
fout.write(' ADD_TACTIC_CMD("%s", "%s", __Z3_local_factory_%s);\n' % (data[0], data[1], idx))
|
||||
idx = idx + 1
|
||||
fout.write(' ADD_TACTIC_CMD("%s", "%s", %s);\n' % data)
|
||||
for data in ADD_PROBE_DATA:
|
||||
fout.write(' ADD_PROBE("%s", "%s", %s);\n' % data)
|
||||
fout.write('}\n')
|
||||
|
|
|
@ -73,7 +73,7 @@ Type2PyStr = { VOID_PTR : 'ctypes.c_void_p', INT : 'ctypes.c_int', UINT : 'ctype
|
|||
|
||||
# Mapping to .NET types
|
||||
Type2Dotnet = { VOID : 'void', VOID_PTR : 'IntPtr', INT : 'int', UINT : 'uint', INT64 : 'Int64', UINT64 : 'UInt64', DOUBLE : 'double',
|
||||
FLOAT : 'float', STRING : 'string', STRING_PTR : 'byte**', BOOL : 'bool', SYMBOL : 'IntPtr',
|
||||
FLOAT : 'float', STRING : 'string', STRING_PTR : 'byte**', BOOL : 'byte', SYMBOL : 'IntPtr',
|
||||
PRINT_MODE : 'uint', ERROR_CODE : 'uint' }
|
||||
|
||||
# Mapping to Java types
|
||||
|
|
|
@ -121,9 +121,7 @@ extern "C" {
|
|||
|
||||
Z3_bool Z3_API Z3_is_algebraic_number(Z3_context c, Z3_ast a) {
|
||||
LOG_Z3_is_algebraic_number(c, a);
|
||||
Z3_bool r = mk_c(c)->autil().is_irrational_algebraic_numeral(to_expr(a)) ? Z3_TRUE : Z3_FALSE;
|
||||
IF_VERBOSE(10, verbose_stream() << r << "\n");
|
||||
return r;
|
||||
return mk_c(c)->autil().is_irrational_algebraic_numeral(to_expr(a)) ? Z3_TRUE : Z3_FALSE;
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_get_algebraic_number_lower(Z3_context c, Z3_ast a, unsigned precision) {
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace Microsoft.Z3
|
|||
(!Object.ReferenceEquals(a, null) &&
|
||||
!Object.ReferenceEquals(b, null) &&
|
||||
a.Context.nCtx == b.Context.nCtx &&
|
||||
Native.Z3_is_eq_ast(a.Context.nCtx, a.NativeObject, b.NativeObject));
|
||||
0 != Native.Z3_is_eq_ast(a.Context.nCtx, a.NativeObject, b.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace Microsoft.Z3
|
|||
{
|
||||
Contract.Requires(k != null);
|
||||
|
||||
return Native.Z3_ast_map_contains(Context.nCtx, NativeObject, k.NativeObject);
|
||||
return 0 != Native.Z3_ast_map_contains(Context.nCtx, NativeObject, k.NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace Microsoft.Z3
|
|||
get
|
||||
{
|
||||
UInt64 res = 0;
|
||||
if (Native.Z3_get_numeral_uint64(Context.nCtx, NativeObject, ref res) == false)
|
||||
if (Native.Z3_get_numeral_uint64(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not a 64 bit unsigned");
|
||||
return res;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ namespace Microsoft.Z3
|
|||
get
|
||||
{
|
||||
int res = 0;
|
||||
if (Native.Z3_get_numeral_int(Context.nCtx, NativeObject, ref res) == false)
|
||||
if (Native.Z3_get_numeral_int(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not an int");
|
||||
return res;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ namespace Microsoft.Z3
|
|||
get
|
||||
{
|
||||
Int64 res = 0;
|
||||
if (Native.Z3_get_numeral_int64(Context.nCtx, NativeObject, ref res) == false)
|
||||
if (Native.Z3_get_numeral_int64(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not an int64");
|
||||
return res;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ namespace Microsoft.Z3
|
|||
get
|
||||
{
|
||||
uint res = 0;
|
||||
if (Native.Z3_get_numeral_uint(Context.nCtx, NativeObject, ref res) == false)
|
||||
if (Native.Z3_get_numeral_uint(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not a uint");
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -1963,7 +1963,7 @@ namespace Microsoft.Z3
|
|||
Contract.Ensures(Contract.Result<IntExpr>() != null);
|
||||
|
||||
CheckContextMatch(t);
|
||||
return new IntExpr(this, Native.Z3_mk_bv2int(nCtx, t.NativeObject, (signed)));
|
||||
return new IntExpr(this, Native.Z3_mk_bv2int(nCtx, t.NativeObject, (byte)(signed ? 1 : 0)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1980,7 +1980,7 @@ namespace Microsoft.Z3
|
|||
|
||||
CheckContextMatch(t1);
|
||||
CheckContextMatch(t2);
|
||||
return new BoolExpr(this, Native.Z3_mk_bvadd_no_overflow(nCtx, t1.NativeObject, t2.NativeObject, (isSigned)));
|
||||
return new BoolExpr(this, Native.Z3_mk_bvadd_no_overflow(nCtx, t1.NativeObject, t2.NativeObject, (byte)(isSigned ? 1 : 0)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -2031,7 +2031,7 @@ namespace Microsoft.Z3
|
|||
|
||||
CheckContextMatch(t1);
|
||||
CheckContextMatch(t2);
|
||||
return new BoolExpr(this, Native.Z3_mk_bvsub_no_underflow(nCtx, t1.NativeObject, t2.NativeObject, (isSigned)));
|
||||
return new BoolExpr(this, Native.Z3_mk_bvsub_no_underflow(nCtx, t1.NativeObject, t2.NativeObject, (byte)(isSigned ? 1 : 0)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -2080,7 +2080,7 @@ namespace Microsoft.Z3
|
|||
|
||||
CheckContextMatch(t1);
|
||||
CheckContextMatch(t2);
|
||||
return new BoolExpr(this, Native.Z3_mk_bvmul_no_overflow(nCtx, t1.NativeObject, t2.NativeObject, (isSigned)));
|
||||
return new BoolExpr(this, Native.Z3_mk_bvmul_no_overflow(nCtx, t1.NativeObject, t2.NativeObject, (byte)(isSigned ? 1 : 0)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -3135,7 +3135,9 @@ namespace Microsoft.Z3
|
|||
public BitVecNum MkBV(bool[] bits)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BitVecNum>() != null);
|
||||
return (BitVecNum)Expr.Create(this, Native.Z3_mk_bv_numeral(nCtx, (uint)bits.Length, bits));
|
||||
byte[] _bits = new byte[bits.Length];
|
||||
for (int i = 0; i < bits.Length; ++i) _bits[i] = (byte)(bits[i] ? 1 : 0);
|
||||
return (BitVecNum)Expr.Create(this, Native.Z3_mk_bv_numeral(nCtx, (uint)bits.Length, _bits));
|
||||
}
|
||||
|
||||
|
||||
|
@ -4184,7 +4186,7 @@ namespace Microsoft.Z3
|
|||
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));
|
||||
return new FPNum(this, Native.Z3_mk_fpa_inf(nCtx, s.NativeObject, (byte)(negative ? 1 : 0)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -4195,7 +4197,7 @@ namespace Microsoft.Z3
|
|||
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));
|
||||
return new FPNum(this, Native.Z3_mk_fpa_zero(nCtx, s.NativeObject, (byte)(negative ? 1 : 0)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -4241,7 +4243,7 @@ namespace Microsoft.Z3
|
|||
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, exp, sig, s.NativeObject));
|
||||
return new FPNum(this, Native.Z3_mk_fpa_numeral_int_uint(nCtx, (byte)(sgn ? 1 : 0), exp, sig, s.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -4254,7 +4256,7 @@ namespace Microsoft.Z3
|
|||
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, exp, sig, s.NativeObject));
|
||||
return new FPNum(this, Native.Z3_mk_fpa_numeral_int64_uint64(nCtx, (byte)(sgn ? 1 : 0), exp, sig, s.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -179,7 +179,7 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public bool IsNumeral
|
||||
{
|
||||
get { return Native.Z3_is_numeral_ast(Context.nCtx, NativeObject) ; }
|
||||
get { return Native.Z3_is_numeral_ast(Context.nCtx, NativeObject) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -188,7 +188,7 @@ namespace Microsoft.Z3
|
|||
/// <returns>True if the term is well-sorted, false otherwise.</returns>
|
||||
public bool IsWellSorted
|
||||
{
|
||||
get { return Native.Z3_is_well_sorted(Context.nCtx, NativeObject) ; }
|
||||
get { return Native.Z3_is_well_sorted(Context.nCtx, NativeObject) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -239,7 +239,7 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public bool IsAlgebraicNumber
|
||||
{
|
||||
get { return Native.Z3_is_algebraic_number(Context.nCtx, NativeObject); }
|
||||
get { return 0 != Native.Z3_is_algebraic_number(Context.nCtx, NativeObject); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -256,7 +256,7 @@ namespace Microsoft.Z3
|
|||
return (IsExpr &&
|
||||
Native.Z3_is_eq_sort(Context.nCtx,
|
||||
Native.Z3_mk_bool_sort(Context.nCtx),
|
||||
Native.Z3_get_sort(Context.nCtx, NativeObject)) );
|
||||
Native.Z3_get_sort(Context.nCtx, NativeObject)) != 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -423,7 +423,7 @@ namespace Microsoft.Z3
|
|||
{
|
||||
get
|
||||
{
|
||||
return (Native.Z3_is_app(Context.nCtx, NativeObject) &&
|
||||
return (Native.Z3_is_app(Context.nCtx, NativeObject) != 0 &&
|
||||
(Z3_sort_kind)Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject))
|
||||
== Z3_sort_kind.Z3_ARRAY_SORT);
|
||||
}
|
||||
|
@ -789,7 +789,7 @@ namespace Microsoft.Z3
|
|||
/// Check whether expression is a string constant.
|
||||
/// </summary>
|
||||
/// <returns>a Boolean</returns>
|
||||
public bool IsString { get { return IsApp && Native.Z3_is_string(Context.nCtx, NativeObject); } }
|
||||
public bool IsString { get { return IsApp && Native.Z3_is_string(Context.nCtx, NativeObject) != 0; } }
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve string corresponding to string constant.
|
||||
|
@ -1336,7 +1336,7 @@ namespace Microsoft.Z3
|
|||
{
|
||||
get
|
||||
{
|
||||
return (Native.Z3_is_app(Context.nCtx, NativeObject) &&
|
||||
return (Native.Z3_is_app(Context.nCtx, NativeObject) != 0 &&
|
||||
Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject))
|
||||
== (uint)Z3_sort_kind.Z3_RELATION_SORT);
|
||||
}
|
||||
|
@ -1458,7 +1458,7 @@ namespace Microsoft.Z3
|
|||
{
|
||||
get
|
||||
{
|
||||
return (Native.Z3_is_app(Context.nCtx, NativeObject) &&
|
||||
return (Native.Z3_is_app(Context.nCtx, NativeObject) != 0 &&
|
||||
Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) == (uint)Z3_sort_kind.Z3_FINITE_DOMAIN_SORT);
|
||||
}
|
||||
}
|
||||
|
@ -1789,7 +1789,7 @@ namespace Microsoft.Z3
|
|||
[Pure]
|
||||
internal override void CheckNativeObject(IntPtr obj)
|
||||
{
|
||||
if (Native.Z3_is_app(Context.nCtx, obj) == false &&
|
||||
if (Native.Z3_is_app(Context.nCtx, obj) == 0 &&
|
||||
Native.Z3_get_ast_kind(Context.nCtx, obj) != (uint)Z3_ast_kind.Z3_VAR_AST &&
|
||||
Native.Z3_get_ast_kind(Context.nCtx, obj) != (uint)Z3_ast_kind.Z3_QUANTIFIER_AST)
|
||||
throw new Z3Exception("Underlying object is not a term");
|
||||
|
@ -1822,11 +1822,10 @@ namespace Microsoft.Z3
|
|||
IntPtr s = Native.Z3_get_sort(ctx.nCtx, obj);
|
||||
Z3_sort_kind sk = (Z3_sort_kind)Native.Z3_get_sort_kind(ctx.nCtx, s);
|
||||
|
||||
if ( // Z3_sort_kind.Z3_REAL_SORT == sk &&
|
||||
Native.Z3_is_algebraic_number(ctx.nCtx, obj)) // is this a numeral ast?
|
||||
if (0 != Native.Z3_is_algebraic_number(ctx.nCtx, obj)) // is this a numeral ast?
|
||||
return new AlgebraicNum(ctx, obj);
|
||||
|
||||
if (Native.Z3_is_numeral_ast(ctx.nCtx, obj))
|
||||
if (Native.Z3_is_numeral_ast(ctx.nCtx, obj) != 0)
|
||||
{
|
||||
|
||||
switch (sk)
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace Microsoft.Z3
|
|||
get
|
||||
{
|
||||
int res = 0;
|
||||
if (Native.Z3_fpa_get_numeral_sign(Context.nCtx, NativeObject, ref res) == false)
|
||||
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;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ namespace Microsoft.Z3
|
|||
get
|
||||
{
|
||||
UInt64 result = 0;
|
||||
if (Native.Z3_fpa_get_numeral_significand_uint64(Context.nCtx, NativeObject, ref result) == false)
|
||||
if (Native.Z3_fpa_get_numeral_significand_uint64(Context.nCtx, NativeObject, ref result) == 0)
|
||||
throw new Z3Exception("Significand is not a 64 bit unsigned integer");
|
||||
return result;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public string Exponent(bool biased = true)
|
||||
{
|
||||
return Native.Z3_fpa_get_numeral_exponent_string(Context.nCtx, NativeObject, biased);
|
||||
return Native.Z3_fpa_get_numeral_exponent_string(Context.nCtx, NativeObject, (byte)(biased ? 1 : 0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -120,7 +120,7 @@ namespace Microsoft.Z3
|
|||
public Int64 ExponentInt64(bool biased = true)
|
||||
{
|
||||
Int64 result = 0;
|
||||
if (Native.Z3_fpa_get_numeral_exponent_int64(Context.nCtx, NativeObject, ref result, biased) == false)
|
||||
if (Native.Z3_fpa_get_numeral_exponent_int64(Context.nCtx, NativeObject, ref result, (byte)(biased? 1 : 0)) == 0)
|
||||
throw new Z3Exception("Exponent is not a 64 bit integer");
|
||||
return result;
|
||||
}
|
||||
|
@ -133,43 +133,43 @@ namespace Microsoft.Z3
|
|||
/// </remarks>
|
||||
public BitVecExpr ExponentBV(bool biased = true)
|
||||
{
|
||||
return new BitVecExpr(Context, Native.Z3_fpa_get_numeral_exponent_bv(Context.nCtx, NativeObject, biased));
|
||||
return new BitVecExpr(Context, Native.Z3_fpa_get_numeral_exponent_bv(Context.nCtx, NativeObject, (byte)(biased ? 1 : 0)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the numeral is a NaN.
|
||||
/// </summary>
|
||||
public bool IsNaN { get { return Native.Z3_fpa_is_numeral_nan(Context.nCtx, NativeObject) ; } }
|
||||
public bool IsNaN { get { return Native.Z3_fpa_is_numeral_nan(Context.nCtx, NativeObject) != 0; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the numeral is a +oo or -oo.
|
||||
/// </summary>
|
||||
public bool IsInf { get { return Native.Z3_fpa_is_numeral_inf(Context.nCtx, NativeObject) ; } }
|
||||
public bool IsInf { get { return Native.Z3_fpa_is_numeral_inf(Context.nCtx, NativeObject) != 0; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the numeral is +zero or -zero.
|
||||
/// </summary>
|
||||
public bool IsZero{ get { return Native.Z3_fpa_is_numeral_zero(Context.nCtx, NativeObject) ; } }
|
||||
public bool IsZero{ get { return Native.Z3_fpa_is_numeral_zero(Context.nCtx, NativeObject) != 0; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the numeral is normal.
|
||||
/// </summary>
|
||||
public bool IsNormal { get { return Native.Z3_fpa_is_numeral_normal(Context.nCtx, NativeObject) ; } }
|
||||
public bool IsNormal { get { return Native.Z3_fpa_is_numeral_normal(Context.nCtx, NativeObject) != 0; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the numeral is subnormal.
|
||||
/// </summary>
|
||||
public bool IsSubnormal { get { return Native.Z3_fpa_is_numeral_subnormal(Context.nCtx, NativeObject) ; } }
|
||||
public bool IsSubnormal { get { return Native.Z3_fpa_is_numeral_subnormal(Context.nCtx, NativeObject) != 0; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the numeral is positive.
|
||||
/// </summary>
|
||||
public bool IsPositive { get { return Native.Z3_fpa_is_numeral_positive(Context.nCtx, NativeObject) ; } }
|
||||
public bool IsPositive { get { return Native.Z3_fpa_is_numeral_positive(Context.nCtx, NativeObject) != 0; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the numeral is negative.
|
||||
/// </summary>
|
||||
public bool IsNegative { get { return Native.Z3_fpa_is_numeral_negative(Context.nCtx, NativeObject) ; } }
|
||||
public bool IsNegative { get { return Native.Z3_fpa_is_numeral_negative(Context.nCtx, NativeObject) != 0; } }
|
||||
|
||||
#region Internal
|
||||
internal FPNum(Context ctx, IntPtr obj)
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace Microsoft.Z3
|
|||
get
|
||||
{
|
||||
UInt64 res = 0;
|
||||
if (Native.Z3_get_numeral_uint64(Context.nCtx, NativeObject, ref res) == false)
|
||||
if (Native.Z3_get_numeral_uint64(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not a 64 bit unsigned");
|
||||
return res;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ namespace Microsoft.Z3
|
|||
get
|
||||
{
|
||||
int res = 0;
|
||||
if (Native.Z3_get_numeral_int(Context.nCtx, NativeObject, ref res) == false)
|
||||
if (Native.Z3_get_numeral_int(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not an int");
|
||||
return res;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ namespace Microsoft.Z3
|
|||
get
|
||||
{
|
||||
Int64 res = 0;
|
||||
if (Native.Z3_get_numeral_int64(Context.nCtx, NativeObject, ref res) == false)
|
||||
if (Native.Z3_get_numeral_int64(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not an int64");
|
||||
return res;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ namespace Microsoft.Z3
|
|||
get
|
||||
{
|
||||
uint res = 0;
|
||||
if (Native.Z3_get_numeral_uint(Context.nCtx, NativeObject, ref res) == false)
|
||||
if (Native.Z3_get_numeral_uint(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not a uint");
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace Microsoft.Z3
|
|||
(!Object.ReferenceEquals(a, null) &&
|
||||
!Object.ReferenceEquals(b, null) &&
|
||||
a.Context.nCtx == b.Context.nCtx &&
|
||||
Native.Z3_is_eq_func_decl(a.Context.nCtx, a.NativeObject, b.NativeObject));
|
||||
Native.Z3_is_eq_func_decl(a.Context.nCtx, a.NativeObject, b.NativeObject) != 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace Microsoft.Z3
|
|||
public static string GetParameter(string id)
|
||||
{
|
||||
IntPtr t;
|
||||
if (Native.Z3_global_param_get(id, out t) == false)
|
||||
if (Native.Z3_global_param_get(id, out t) == 0)
|
||||
return null;
|
||||
else
|
||||
return Marshal.PtrToStringAnsi(t);
|
||||
|
@ -91,7 +91,7 @@ namespace Microsoft.Z3
|
|||
/// all contexts globally.</remarks>
|
||||
public static void ToggleWarningMessages(bool enabled)
|
||||
{
|
||||
Native.Z3_toggle_warning_messages(enabled);
|
||||
Native.Z3_toggle_warning_messages((byte)(enabled ? 1 : 0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public bool Inconsistent
|
||||
{
|
||||
get { return Native.Z3_goal_inconsistent(Context.nCtx, NativeObject) ; }
|
||||
get { return Native.Z3_goal_inconsistent(Context.nCtx, NativeObject) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -163,7 +163,7 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public bool IsDecidedSat
|
||||
{
|
||||
get { return Native.Z3_goal_is_decided_sat(Context.nCtx, NativeObject) ; }
|
||||
get { return Native.Z3_goal_is_decided_sat(Context.nCtx, NativeObject) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -171,7 +171,7 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public bool IsDecidedUnsat
|
||||
{
|
||||
get { return Native.Z3_goal_is_decided_unsat(Context.nCtx, NativeObject) ; }
|
||||
get { return Native.Z3_goal_is_decided_unsat(Context.nCtx, NativeObject) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -251,7 +251,7 @@ namespace Microsoft.Z3
|
|||
internal Goal(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
|
||||
internal Goal(Context ctx, bool models, bool unsatCores, bool proofs)
|
||||
: base(ctx, Native.Z3_mk_goal(ctx.nCtx, (models), (unsatCores), (proofs)))
|
||||
: base(ctx, Native.Z3_mk_goal(ctx.nCtx, (byte)(models ? 1 : 0), (byte)(unsatCores ? 1 : 0), (byte)(proofs ? 1 : 0)))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace Microsoft.Z3
|
|||
get
|
||||
{
|
||||
UInt64 res = 0;
|
||||
if (Native.Z3_get_numeral_uint64(Context.nCtx, NativeObject, ref res) == false)
|
||||
if (Native.Z3_get_numeral_uint64(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not a 64 bit unsigned");
|
||||
return res;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ namespace Microsoft.Z3
|
|||
get
|
||||
{
|
||||
int res = 0;
|
||||
if (Native.Z3_get_numeral_int(Context.nCtx, NativeObject, ref res) == false)
|
||||
if (Native.Z3_get_numeral_int(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not an int");
|
||||
return res;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ namespace Microsoft.Z3
|
|||
get
|
||||
{
|
||||
Int64 res = 0;
|
||||
if (Native.Z3_get_numeral_int64(Context.nCtx, NativeObject, ref res) == false)
|
||||
if (Native.Z3_get_numeral_int64(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not an int64");
|
||||
return res;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ namespace Microsoft.Z3
|
|||
get
|
||||
{
|
||||
uint res = 0;
|
||||
if (Native.Z3_get_numeral_uint(Context.nCtx, NativeObject, ref res) == false)
|
||||
if (Native.Z3_get_numeral_uint(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not a uint");
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace Microsoft.Z3
|
|||
return null;
|
||||
else
|
||||
{
|
||||
if (Native.Z3_is_as_array(Context.nCtx, n) == false)
|
||||
if (Native.Z3_is_as_array(Context.nCtx, n) == 0)
|
||||
throw new Z3Exception("Argument was not an array constant");
|
||||
IntPtr fd = Native.Z3_get_as_array_func_decl(Context.nCtx, n);
|
||||
return FuncInterp(new FuncDecl(Context, fd));
|
||||
|
@ -227,7 +227,7 @@ namespace Microsoft.Z3
|
|||
Contract.Ensures(Contract.Result<Expr>() != null);
|
||||
|
||||
IntPtr v = IntPtr.Zero;
|
||||
if (Native.Z3_model_eval(Context.nCtx, NativeObject, t.NativeObject, (completion), ref v) == false)
|
||||
if (Native.Z3_model_eval(Context.nCtx, NativeObject, t.NativeObject, (byte)(completion ? 1 : 0), ref v) == (byte)0)
|
||||
throw new ModelEvaluationFailedException();
|
||||
else
|
||||
return Expr.Create(Context, v);
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace Microsoft.Z3
|
|||
{
|
||||
Contract.Requires(name != null);
|
||||
|
||||
Native.Z3_params_set_bool(Context.nCtx, NativeObject, name.NativeObject, (value));
|
||||
Native.Z3_params_set_bool(Context.nCtx, NativeObject, name.NativeObject, (byte)(value ? 1 : 0));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public Params Add(string name, bool value)
|
||||
{
|
||||
Native.Z3_params_set_bool(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, (value));
|
||||
Native.Z3_params_set_bool(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, (byte)(value ? 1 : 0));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public bool IsUniversal
|
||||
{
|
||||
get { return Native.Z3_is_quantifier_forall(Context.nCtx, NativeObject); }
|
||||
get { return 0 != Native.Z3_is_quantifier_forall(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -41,7 +41,7 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public bool IsExistential
|
||||
{
|
||||
get { return Native.Z3_is_quantifier_exists(Context.nCtx, NativeObject); }
|
||||
get { return 0 != Native.Z3_is_quantifier_exists(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -193,7 +193,7 @@ namespace Microsoft.Z3
|
|||
|
||||
if (noPatterns == null && quantifierID == null && skolemID == null)
|
||||
{
|
||||
NativeObject = Native.Z3_mk_quantifier(ctx.nCtx, (isForall) , weight,
|
||||
NativeObject = Native.Z3_mk_quantifier(ctx.nCtx, (byte)(isForall ? 1 : 0) , weight,
|
||||
AST.ArrayLength(patterns), AST.ArrayToNative(patterns),
|
||||
AST.ArrayLength(sorts), AST.ArrayToNative(sorts),
|
||||
Symbol.ArrayToNative(names),
|
||||
|
@ -201,7 +201,7 @@ namespace Microsoft.Z3
|
|||
}
|
||||
else
|
||||
{
|
||||
NativeObject = Native.Z3_mk_quantifier_ex(ctx.nCtx, (isForall), weight,
|
||||
NativeObject = Native.Z3_mk_quantifier_ex(ctx.nCtx, (byte)(isForall ? 1 : 0), weight,
|
||||
AST.GetNativeObject(quantifierID), AST.GetNativeObject(skolemID),
|
||||
AST.ArrayLength(patterns), AST.ArrayToNative(patterns),
|
||||
AST.ArrayLength(noPatterns), AST.ArrayToNative(noPatterns),
|
||||
|
@ -229,14 +229,14 @@ namespace Microsoft.Z3
|
|||
|
||||
if (noPatterns == null && quantifierID == null && skolemID == null)
|
||||
{
|
||||
NativeObject = Native.Z3_mk_quantifier_const(ctx.nCtx, (isForall) , weight,
|
||||
NativeObject = Native.Z3_mk_quantifier_const(ctx.nCtx, (byte)(isForall ? 1 : 0) , weight,
|
||||
AST.ArrayLength(bound), AST.ArrayToNative(bound),
|
||||
AST.ArrayLength(patterns), AST.ArrayToNative(patterns),
|
||||
body.NativeObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
NativeObject = Native.Z3_mk_quantifier_const_ex(ctx.nCtx, (isForall), weight,
|
||||
NativeObject = Native.Z3_mk_quantifier_const_ex(ctx.nCtx, (byte)(isForall ? 1 : 0), weight,
|
||||
AST.GetNativeObject(quantifierID), AST.GetNativeObject(skolemID),
|
||||
AST.ArrayLength(bound), AST.ArrayToNative(bound),
|
||||
AST.ArrayLength(patterns), AST.ArrayToNative(patterns),
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace Microsoft.Z3
|
|||
(!Object.ReferenceEquals(a, null) &&
|
||||
!Object.ReferenceEquals(b, null) &&
|
||||
a.Context == b.Context &&
|
||||
Native.Z3_is_eq_sort(a.Context.nCtx, a.NativeObject, b.NativeObject));
|
||||
0 != Native.Z3_is_eq_sort(a.Context.nCtx, a.NativeObject, b.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -134,9 +134,9 @@ namespace Microsoft.Z3
|
|||
{
|
||||
Entry e;
|
||||
string k = Native.Z3_stats_get_key(Context.nCtx, NativeObject, i);
|
||||
if (Native.Z3_stats_is_uint(Context.nCtx, NativeObject, i) )
|
||||
if (Native.Z3_stats_is_uint(Context.nCtx, NativeObject, i) != 0)
|
||||
e = new Entry(k, Native.Z3_stats_get_uint_value(Context.nCtx, NativeObject, i));
|
||||
else if (Native.Z3_stats_is_double(Context.nCtx, NativeObject, i) )
|
||||
else if (Native.Z3_stats_is_double(Context.nCtx, NativeObject, i) != 0)
|
||||
e = new Entry(k, Native.Z3_stats_get_double_value(Context.nCtx, NativeObject, i));
|
||||
else
|
||||
throw new Z3Exception("Unknown data entry value");
|
||||
|
|
|
@ -32,14 +32,6 @@ Notes:
|
|||
#include "cmd_context/cmd_context_to_goal.h"
|
||||
#include "cmd_context/echo_tactic.h"
|
||||
|
||||
tactic_cmd::~tactic_cmd() {
|
||||
dealloc(m_factory);
|
||||
}
|
||||
|
||||
tactic * tactic_cmd::mk(ast_manager & m) {
|
||||
return (*m_factory)(m, params_ref());
|
||||
}
|
||||
|
||||
probe_info::probe_info(symbol const & n, char const * d, probe * p):
|
||||
m_name(n),
|
||||
m_descr(d),
|
||||
|
|
|
@ -19,30 +19,28 @@ Notes:
|
|||
#define TACTIC_CMDS_H_
|
||||
|
||||
#include "ast/ast.h"
|
||||
#include "util/params.h"
|
||||
#include "util/cmd_context_types.h"
|
||||
#include "util/ref.h"
|
||||
|
||||
class tactic;
|
||||
class probe;
|
||||
class tactic_factory;
|
||||
|
||||
typedef tactic* (*tactic_factory)(ast_manager&, const params_ref&);
|
||||
|
||||
class tactic_cmd {
|
||||
symbol m_name;
|
||||
char const * m_descr;
|
||||
tactic_factory * m_factory;
|
||||
symbol m_name;
|
||||
char const * m_descr;
|
||||
tactic_factory m_factory;
|
||||
public:
|
||||
tactic_cmd(symbol const & n, char const * d, tactic_factory * f):
|
||||
m_name(n), m_descr(d), m_factory(f) {
|
||||
SASSERT(m_factory);
|
||||
}
|
||||
|
||||
~tactic_cmd();
|
||||
tactic_cmd(symbol const & n, char const * d, tactic_factory f):
|
||||
m_name(n), m_descr(d), m_factory(f) {}
|
||||
|
||||
symbol get_name() const { return m_name; }
|
||||
|
||||
char const * get_descr() const { return m_descr; }
|
||||
|
||||
tactic * mk(ast_manager & m);
|
||||
tactic * mk(ast_manager & m) { return m_factory(m, params_ref()); }
|
||||
};
|
||||
|
||||
void install_core_tactic_cmds(cmd_context & ctx);
|
||||
|
|
|
@ -25,8 +25,6 @@ class tactic;
|
|||
|
||||
tactic * mk_qfnra_nlsat_tactic(ast_manager & m, params_ref const & p = params_ref());
|
||||
|
||||
MK_SIMPLE_TACTIC_FACTORY(qfnra_nlsat_fct, mk_qfnra_nlsat_tactic(m, p));
|
||||
|
||||
/*
|
||||
ADD_TACTIC("qfnra-nlsat", "builtin strategy for solving QF_NRA problems using only nlsat.", "mk_qfnra_nlsat_tactic(m, p)")
|
||||
*/
|
||||
|
|
|
@ -200,6 +200,9 @@ theory_seq::theory_seq(ast_manager& m, theory_seq_params const & params):
|
|||
m_reset_cache(false),
|
||||
m_eq_id(0),
|
||||
m_find(*this),
|
||||
m_overlap(m),
|
||||
m_overlap2(m),
|
||||
m_len_prop_lvl(-1),
|
||||
m_factory(nullptr),
|
||||
m_exclude(m),
|
||||
m_axioms(m),
|
||||
|
@ -217,9 +220,6 @@ theory_seq::theory_seq(ast_manager& m, theory_seq_params const & params):
|
|||
m_atoms_qhead(0),
|
||||
m_new_solution(false),
|
||||
m_new_propagation(false),
|
||||
m_len_prop_lvl(-1),
|
||||
m_overlap(m),
|
||||
m_overlap2(m),
|
||||
m_mk_aut(m) {
|
||||
m_prefix = "seq.p.suffix";
|
||||
m_suffix = "seq.s.prefix";
|
||||
|
@ -416,9 +416,9 @@ bool theory_seq::branch_binary_variable(eq const& e) {
|
|||
expr_ref Y1(mk_skolem(symbol("seq.left"), x, y), m);
|
||||
expr_ref Y2(mk_skolem(symbol("seq.right"), x, y), m);
|
||||
ys.push_back(Y1);
|
||||
expr_ref ysY1(mk_concat(ys));
|
||||
expr_ref xsE(mk_concat(xs));
|
||||
expr_ref Y1Y2(mk_concat(Y1, Y2));
|
||||
expr_ref ysY1 = mk_concat(ys);
|
||||
expr_ref xsE = mk_concat(xs);
|
||||
expr_ref Y1Y2 = mk_concat(Y1, Y2);
|
||||
dependency* dep = e.dep();
|
||||
propagate_eq(dep, ~lit, x, ysY1);
|
||||
propagate_eq(dep, ~lit, y, Y1Y2);
|
||||
|
@ -525,9 +525,9 @@ bool theory_seq::eq_unit(expr* const& l, expr* const &r) const {
|
|||
unsigned_vector theory_seq::overlap(expr_ref_vector const& ls, expr_ref_vector const& rs) {
|
||||
SASSERT(!ls.empty() && !rs.empty());
|
||||
unsigned_vector res;
|
||||
expr* l = mk_concat(ls);
|
||||
expr* r = mk_concat(rs);
|
||||
expr* pair = m.mk_eq(l,r);
|
||||
expr_ref l = mk_concat(ls);
|
||||
expr_ref r = mk_concat(rs);
|
||||
expr_ref pair(m.mk_eq(l,r), m);
|
||||
if (m_overlap.find(pair, res)) {
|
||||
return res;
|
||||
}
|
||||
|
@ -536,7 +536,7 @@ unsigned_vector theory_seq::overlap(expr_ref_vector const& ls, expr_ref_vector c
|
|||
if (eq_unit(ls[i], rs.back())) {
|
||||
bool same = true;
|
||||
if (i >= 1) {
|
||||
for (unsigned j = i-1; j>=0 && rs.size()+j-i>=1; --j) {
|
||||
for (unsigned j = i - 1; rs.size() + j >= 1 + i; --j) {
|
||||
if (!eq_unit(ls[j], rs[rs.size()+j-i-1])) {
|
||||
same = false;
|
||||
break;
|
||||
|
@ -557,9 +557,9 @@ unsigned_vector theory_seq::overlap(expr_ref_vector const& ls, expr_ref_vector c
|
|||
unsigned_vector theory_seq::overlap2(expr_ref_vector const& ls, expr_ref_vector const& rs) {
|
||||
SASSERT(!ls.empty() && !rs.empty());
|
||||
unsigned_vector res;
|
||||
expr* l = mk_concat(ls);
|
||||
expr* r = mk_concat(rs);
|
||||
expr* pair = m.mk_eq(l,r);
|
||||
expr_ref l = mk_concat(ls);
|
||||
expr_ref r = mk_concat(rs);
|
||||
expr_ref pair(m.mk_eq(l,r), m);
|
||||
if (m_overlap2.find(pair, res)) {
|
||||
return res;
|
||||
}
|
||||
|
@ -568,7 +568,7 @@ unsigned_vector theory_seq::overlap2(expr_ref_vector const& ls, expr_ref_vector
|
|||
if (eq_unit(ls[i],rs[0])) {
|
||||
bool same = true;
|
||||
unsigned j = i+1;
|
||||
while (j<ls.size() && j-i<rs.size()) {
|
||||
while (j < ls.size() && j-i < rs.size()) {
|
||||
if (!eq_unit(ls[j], rs[j-i])) {
|
||||
same = false;
|
||||
break;
|
||||
|
@ -583,8 +583,9 @@ unsigned_vector theory_seq::overlap2(expr_ref_vector const& ls, expr_ref_vector
|
|||
return result;
|
||||
}
|
||||
|
||||
bool theory_seq::branch_ternary_variable_base(dependency* dep, unsigned_vector indexes,
|
||||
expr* const& x, expr_ref_vector const& xs, expr* const& y1, expr_ref_vector const& ys, expr* const& y2) {
|
||||
bool theory_seq::branch_ternary_variable_base(
|
||||
dependency* dep, unsigned_vector indexes,
|
||||
expr* const& x, expr_ref_vector const& xs, expr* const& y1, expr_ref_vector const& ys, expr* const& y2) {
|
||||
context& ctx = get_context();
|
||||
bool change = false;
|
||||
for (auto ind : indexes) {
|
||||
|
@ -611,7 +612,7 @@ bool theory_seq::branch_ternary_variable_base(dependency* dep, unsigned_vector i
|
|||
propagate_eq(dep, lits, y2, xs2E, true);
|
||||
if (ind > ys.size()) {
|
||||
expr_ref xs1E(m_util.str.mk_concat(ind-ys.size(), xs.c_ptr()), m);
|
||||
expr_ref xxs1E(mk_concat(x, xs1E), m);
|
||||
expr_ref xxs1E = mk_concat(x, xs1E);
|
||||
propagate_eq(dep, lits, xxs1E, y1, true);
|
||||
}
|
||||
else if (ind == ys.size()) {
|
||||
|
@ -619,7 +620,7 @@ bool theory_seq::branch_ternary_variable_base(dependency* dep, unsigned_vector i
|
|||
}
|
||||
else {
|
||||
expr_ref ys1E(m_util.str.mk_concat(ys.size()-ind, ys.c_ptr()), m);
|
||||
expr_ref y1ys1E(mk_concat(y1, ys1E), m);
|
||||
expr_ref y1ys1E = mk_concat(y1, ys1E);
|
||||
propagate_eq(dep, lits, x, y1ys1E, true);
|
||||
}
|
||||
return true;
|
||||
|
@ -662,12 +663,12 @@ bool theory_seq::branch_ternary_variable(eq const& e, bool flag1) {
|
|||
return true;
|
||||
|
||||
// x ++ xs = y1 ++ ys ++ y2 => x = y1 ++ ys ++ z, z ++ xs = y2
|
||||
expr_ref xsE(mk_concat(xs), m);
|
||||
expr_ref ysE(mk_concat(ys), m);
|
||||
expr_ref y1ys(mk_concat(y1, ysE));
|
||||
expr_ref xsE = mk_concat(xs);
|
||||
expr_ref ysE = mk_concat(ys);
|
||||
expr_ref y1ys = mk_concat(y1, ysE);
|
||||
expr_ref Z(mk_skolem(m_seq_align, y2, xsE, x, y1ys), m);
|
||||
expr_ref ZxsE(mk_concat(Z, xsE), m);
|
||||
expr_ref y1ysZ(mk_concat(y1ys, Z), m);
|
||||
expr_ref ZxsE = mk_concat(Z, xsE);
|
||||
expr_ref y1ysZ = mk_concat(y1ys, Z);
|
||||
if (indexes.empty()) {
|
||||
TRACE("seq", tout << "one case\n";);
|
||||
TRACE("seq", display_equation(tout, e););
|
||||
|
@ -727,7 +728,7 @@ bool theory_seq::branch_ternary_variable_base2(dependency* dep, unsigned_vector
|
|||
propagate_eq(dep, lits, y1, xs1E, true);
|
||||
if (xs.size() - ind > ys.size()) {
|
||||
expr_ref xs2E(m_util.str.mk_concat(xs.size()-ind-ys.size(), xs.c_ptr()+ind+ys.size()), m);
|
||||
expr_ref xs2x(mk_concat(xs2E, x), m);
|
||||
expr_ref xs2x = mk_concat(xs2E, x);
|
||||
propagate_eq(dep, lits, xs2x, y2, true);
|
||||
}
|
||||
else if (xs.size() - ind == ys.size()) {
|
||||
|
@ -735,7 +736,7 @@ bool theory_seq::branch_ternary_variable_base2(dependency* dep, unsigned_vector
|
|||
}
|
||||
else {
|
||||
expr_ref ys1E(m_util.str.mk_concat(ys.size()-xs.size()+ind, ys.c_ptr()+xs.size()-ind), m);
|
||||
expr_ref ys1y2(mk_concat(ys1E, y2), m);
|
||||
expr_ref ys1y2 = mk_concat(ys1E, y2);
|
||||
propagate_eq(dep, lits, x, ys1y2, true);
|
||||
}
|
||||
return true;
|
||||
|
@ -777,12 +778,12 @@ bool theory_seq::branch_ternary_variable2(eq const& e, bool flag1) {
|
|||
return true;
|
||||
|
||||
// xs ++ x = y1 ++ ys ++ y2 => xs ++ z = y1, x = z ++ ys ++ y2
|
||||
expr_ref xsE(mk_concat(xs), m);
|
||||
expr_ref ysE(mk_concat(ys), m);
|
||||
expr_ref ysy2(mk_concat(ysE, y2), m);
|
||||
expr_ref xsE = mk_concat(xs);
|
||||
expr_ref ysE = mk_concat(ys);
|
||||
expr_ref ysy2 = mk_concat(ysE, y2);
|
||||
expr_ref Z(mk_skolem(m_seq_align, x, ysy2, y1, xsE), m);
|
||||
expr_ref xsZ(mk_concat(xsE, Z), m);
|
||||
expr_ref Zysy2(mk_concat(Z, ysy2), m);
|
||||
expr_ref xsZ = mk_concat(xsE, Z);
|
||||
expr_ref Zysy2 = mk_concat(Z, ysy2);
|
||||
if (indexes.empty()) {
|
||||
TRACE("seq", tout << "one case\n";);
|
||||
TRACE("seq", display_equation(tout, e););
|
||||
|
@ -851,9 +852,9 @@ bool theory_seq::branch_quat_variable(eq const& e) {
|
|||
SASSERT(!xs.empty() && !ys.empty());
|
||||
|
||||
xs.push_back(x2);
|
||||
expr_ref xsx2(mk_concat(xs), m);
|
||||
expr_ref xsx2 = mk_concat(xs);
|
||||
ys.push_back(y2);
|
||||
expr_ref ysy2(mk_concat(ys), m);
|
||||
expr_ref ysy2 = mk_concat(ys);
|
||||
expr_ref x1(x1_l, m);
|
||||
expr_ref y1(y1_l, m);
|
||||
expr_ref sub(mk_sub(m_util.str.mk_length(x1_l), m_util.str.mk_length(y1_l)), m);
|
||||
|
@ -870,8 +871,8 @@ bool theory_seq::branch_quat_variable(eq const& e) {
|
|||
TRACE("seq", tout << "false branch\n";);
|
||||
TRACE("seq", display_equation(tout, e););
|
||||
expr_ref Z1(mk_skolem(m_seq_align, ysy2, xsx2, x1, y1), m);
|
||||
expr_ref y1Z1(mk_concat(y1, Z1), m);
|
||||
expr_ref Z1xsx2(mk_concat(Z1, xsx2), m);
|
||||
expr_ref y1Z1 = mk_concat(y1, Z1);
|
||||
expr_ref Z1xsx2 = mk_concat(Z1, xsx2);
|
||||
literal_vector lits;
|
||||
lits.push_back(~lit2);
|
||||
dependency* dep = e.dep();
|
||||
|
@ -883,8 +884,8 @@ bool theory_seq::branch_quat_variable(eq const& e) {
|
|||
TRACE("seq", tout << "true branch\n";);
|
||||
TRACE("seq", display_equation(tout, e););
|
||||
expr_ref Z2(mk_skolem(m_seq_align, xsx2, ysy2, y1, x1), m);
|
||||
expr_ref x1Z2(mk_concat(x1, Z2), m);
|
||||
expr_ref Z2ysy2(mk_concat(Z2, ysy2), m);
|
||||
expr_ref x1Z2 = mk_concat(x1, Z2);
|
||||
expr_ref Z2ysy2 = mk_concat(Z2, ysy2);
|
||||
literal_vector lits;
|
||||
lits.push_back(lit2);
|
||||
dependency* dep = e.dep();
|
||||
|
@ -1385,8 +1386,8 @@ bool theory_seq::branch_variable_mb() {
|
|||
for (auto elem : len2) l2 += elem;
|
||||
if (l1 != l2) {
|
||||
TRACE("seq", tout << "lengths are not compatible\n";);
|
||||
expr_ref l(mk_concat(e.ls()), m);
|
||||
expr_ref r(mk_concat(e.rs()), m);
|
||||
expr_ref l = mk_concat(e.ls());
|
||||
expr_ref r = mk_concat(e.rs());
|
||||
expr_ref lnl(m_util.str.mk_length(l), m), lnr(m_util.str.mk_length(r), m);
|
||||
propagate_eq(e.dep(), lnl, lnr, false);
|
||||
change = true;
|
||||
|
|
|
@ -293,7 +293,7 @@ namespace smt {
|
|||
typedef hashtable<rational, rational::hash_proc, rational::eq_proc> rational_set;
|
||||
|
||||
ast_manager& m;
|
||||
theory_seq_params const & m_params;
|
||||
theory_seq_params const& m_params;
|
||||
dependency_manager m_dm;
|
||||
solution_map m_rep; // unification representative.
|
||||
bool m_reset_cache; // invalidate cache.
|
||||
|
@ -442,7 +442,7 @@ namespace smt {
|
|||
expr_ref mk_empty(sort* s) { return expr_ref(m_util.str.mk_empty(s), m); }
|
||||
expr_ref mk_concat(unsigned n, expr*const* es) { return expr_ref(m_util.str.mk_concat(n, es), m); }
|
||||
expr_ref mk_concat(expr_ref_vector const& es, sort* s) { if (es.empty()) return mk_empty(s); return mk_concat(es.size(), es.c_ptr()); }
|
||||
expr* mk_concat(expr_ref_vector const& es) { SASSERT(!es.empty()); return m_util.str.mk_concat(es.size(), es.c_ptr()); }
|
||||
expr_ref mk_concat(expr_ref_vector const& es) { SASSERT(!es.empty()); return expr_ref(m_util.str.mk_concat(es.size(), es.c_ptr()), m); }
|
||||
expr_ref mk_concat(ptr_vector<expr> const& es) { SASSERT(!es.empty()); return mk_concat(es.size(), es.c_ptr()); }
|
||||
expr_ref mk_concat(expr* e1, expr* e2) { return expr_ref(m_util.str.mk_concat(e1, e2), m); }
|
||||
expr_ref mk_concat(expr* e1, expr* e2, expr* e3) { return expr_ref(m_util.str.mk_concat(e1, e2, e3), m); }
|
||||
|
|
|
@ -19,6 +19,7 @@ Author:
|
|||
Notes:
|
||||
|
||||
--*/
|
||||
#include "solver/tactic2solver.h"
|
||||
#include "solver/solver_na2as.h"
|
||||
#include "tactic/tactic.h"
|
||||
#include "ast/ast_translation.h"
|
||||
|
@ -31,6 +32,8 @@ Notes:
|
|||
option for applications trying to solve many easy queries that a
|
||||
similar to each other.
|
||||
*/
|
||||
|
||||
namespace {
|
||||
class tactic2solver : public solver_na2as {
|
||||
expr_ref_vector m_assertions;
|
||||
unsigned_vector m_scopes;
|
||||
|
@ -258,6 +261,7 @@ unsigned tactic2solver::get_num_assertions() const {
|
|||
expr * tactic2solver::get_assertion(unsigned idx) const {
|
||||
return m_assertions.get(idx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
solver * mk_tactic2solver(ast_manager & m,
|
||||
|
@ -270,6 +274,7 @@ solver * mk_tactic2solver(ast_manager & m,
|
|||
return alloc(tactic2solver, m, t, p, produce_proofs, produce_models, produce_unsat_cores, logic);
|
||||
}
|
||||
|
||||
namespace {
|
||||
class tactic2solver_factory : public solver_factory {
|
||||
ref<tactic> m_tactic;
|
||||
public:
|
||||
|
@ -284,24 +289,23 @@ public:
|
|||
};
|
||||
|
||||
class tactic_factory2solver_factory : public solver_factory {
|
||||
scoped_ptr<tactic_factory> m_factory;
|
||||
tactic_factory m_factory;
|
||||
public:
|
||||
tactic_factory2solver_factory(tactic_factory * f):m_factory(f) {
|
||||
tactic_factory2solver_factory(tactic_factory f):m_factory(f) {
|
||||
}
|
||||
|
||||
~tactic_factory2solver_factory() override {}
|
||||
|
||||
solver * operator()(ast_manager & m, params_ref const & p, bool proofs_enabled, bool models_enabled, bool unsat_core_enabled, symbol const & logic) override {
|
||||
tactic * t = (*m_factory)(m, p);
|
||||
return mk_tactic2solver(m, t, p, proofs_enabled, models_enabled, unsat_core_enabled, logic);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
solver_factory * mk_tactic2solver_factory(tactic * t) {
|
||||
return alloc(tactic2solver_factory, t);
|
||||
}
|
||||
|
||||
solver_factory * mk_tactic_factory2solver_factory(tactic_factory * f) {
|
||||
solver_factory * mk_tactic_factory2solver_factory(tactic_factory f) {
|
||||
return alloc(tactic_factory2solver_factory, f);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,12 +23,14 @@ Notes:
|
|||
#define TACTIC2SOLVER_H_
|
||||
|
||||
#include "util/params.h"
|
||||
|
||||
class ast_manager;
|
||||
class tactic;
|
||||
class tactic_factory;
|
||||
class solver;
|
||||
class solver_factory;
|
||||
|
||||
typedef tactic* (*tactic_factory)(ast_manager&, const params_ref&);
|
||||
|
||||
solver * mk_tactic2solver(ast_manager & m,
|
||||
tactic * t = nullptr,
|
||||
params_ref const & p = params_ref(),
|
||||
|
@ -39,6 +41,6 @@ solver * mk_tactic2solver(ast_manager & m,
|
|||
|
||||
|
||||
solver_factory * mk_tactic2solver_factory(tactic * t);
|
||||
solver_factory * mk_tactic_factory2solver_factory(tactic_factory * f);
|
||||
solver_factory * mk_tactic_factory2solver_factory(tactic_factory f);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -178,11 +178,12 @@ private:
|
|||
if (m_bv.is_bv_mul(p)) {
|
||||
expr_ref rest(m);
|
||||
for (expr* arg : *to_app(p)) {
|
||||
if (arg != v)
|
||||
if (arg != v) {
|
||||
if (rest)
|
||||
rest = m_bv.mk_bv_mul(rest, arg);
|
||||
else
|
||||
rest = arg;
|
||||
}
|
||||
}
|
||||
if (!rest) return false;
|
||||
|
||||
|
@ -251,24 +252,45 @@ private:
|
|||
if (m_arith.is_mul(p) && m_arith.is_real(p)) {
|
||||
expr_ref rest(m);
|
||||
for (expr* arg : *to_app(p)) {
|
||||
if (arg != v)
|
||||
if (arg != v) {
|
||||
if (rest)
|
||||
rest = m_arith.mk_mul(rest, arg);
|
||||
else
|
||||
rest = arg;
|
||||
}
|
||||
}
|
||||
if (!rest) return false;
|
||||
expr_ref zero(m_arith.mk_numeral(rational::zero(), false), m);
|
||||
expr_ref zero(m_arith.mk_real(0), m);
|
||||
new_v = m.mk_ite(m.mk_eq(zero, rest), zero, v);
|
||||
if (mc) {
|
||||
ensure_mc(mc);
|
||||
expr_ref def(m_arith.mk_div(v, rest), m);
|
||||
(*mc)->add(v, def);
|
||||
}
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
expr* e1 = nullptr, *e2 = nullptr;
|
||||
|
||||
// t / v -> if t = 0 then 0 else v
|
||||
// inverse: t = 0 then 1 else v / t
|
||||
if (m_arith.is_div(p, e1, e2) && e2 == v) {
|
||||
expr_ref zero(m_arith.mk_real(0), m);
|
||||
new_v = m.mk_ite(m.mk_eq(zero, e1), zero, v);
|
||||
if (mc) {
|
||||
ensure_mc(mc);
|
||||
expr_ref def(m.mk_ite(m.mk_eq(zero, e1), m_arith.mk_real(1), m_arith.mk_div(e1, v)), m);
|
||||
(*mc)->add(v, def);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// v / t unless t != 0
|
||||
if (m_arith.is_div(p, e1, e2) && e1 == v) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m.is_eq(p, e1, e2)) {
|
||||
if (mc && has_diagonal(e1)) {
|
||||
ensure_mc(mc);
|
||||
|
@ -294,12 +316,15 @@ private:
|
|||
bool has_diagonal(expr* e) {
|
||||
return
|
||||
m_bv.is_bv(e) ||
|
||||
m.is_bool(e);
|
||||
m.is_bool(e) ||
|
||||
m_arith.is_int_real(e);
|
||||
}
|
||||
|
||||
expr * mk_diagonal(expr* e) {
|
||||
if (m_bv.is_bv(e)) return m_bv.mk_bv_neg(e);
|
||||
if (m.is_bool(e)) return m.mk_not(e);
|
||||
if (m_arith.is_int(e)) return m_arith.mk_add(m_arith.mk_int(1), e);
|
||||
if (m_arith.is_real(e)) return m_arith.mk_add(m_arith.mk_real(1), e);
|
||||
UNREACHABLE();
|
||||
return e;
|
||||
}
|
||||
|
|
|
@ -119,21 +119,6 @@ tactic * mk_fail_if_undecided_tactic();
|
|||
tactic * mk_report_verbose_tactic(char const * msg, unsigned lvl);
|
||||
tactic * mk_trace_tactic(char const * tag);
|
||||
|
||||
class tactic_factory {
|
||||
public:
|
||||
virtual ~tactic_factory() {}
|
||||
virtual tactic * operator()(ast_manager & m, params_ref const & p) = 0;
|
||||
};
|
||||
|
||||
#define MK_TACTIC_FACTORY(NAME, CODE) \
|
||||
class NAME : public tactic_factory { \
|
||||
public: \
|
||||
virtual ~NAME() {} \
|
||||
virtual tactic * operator()(ast_manager & m, params_ref const & p) { CODE } \
|
||||
};
|
||||
|
||||
#define MK_SIMPLE_TACTIC_FACTORY(NAME, ST) MK_TACTIC_FACTORY(NAME, return ST;)
|
||||
|
||||
void exec(tactic & t, goal_ref const & in, goal_ref_buffer & result);
|
||||
lbool check_sat(tactic & t, goal_ref & g, model_ref & md, labels_vec & labels, proof_ref & pr, expr_dependency_ref & core, std::string & reason_unknown);
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ namespace sat {
|
|||
SASSERT(m.mk_ite(v1,v0,v0) == v0);
|
||||
SASSERT(m.mk_ite(v0,!v0,v1) == (!v0 && v1));
|
||||
SASSERT(m.mk_ite(v0,v1,!v0) == (!v0 || v1));
|
||||
SASSERT(!(v0 && v1) == (!v0 || !v1));
|
||||
SASSERT(!(v0 || v1) == (!v0 && !v1));
|
||||
SASSERT((!(v0 && v1)) == (!v0 || !v1));
|
||||
SASSERT((!(v0 || v1)) == (!v0 && !v1));
|
||||
}
|
||||
|
||||
static void test3() {
|
||||
|
|
|
@ -21,6 +21,7 @@ Revision History:
|
|||
#include "util/region.h"
|
||||
#include "util/string_buffer.h"
|
||||
#include "util/z3_omp.h"
|
||||
#include <cstring>
|
||||
|
||||
symbol symbol::m_dummy(TAG(void*, nullptr, 2));
|
||||
const symbol symbol::null;
|
||||
|
@ -60,7 +61,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
internal_symbol_table* g_symbol_table = nullptr;
|
||||
static internal_symbol_table* g_symbol_table = nullptr;
|
||||
|
||||
void initialize_symbols() {
|
||||
if (!g_symbol_table) {
|
||||
|
@ -140,27 +141,7 @@ bool lt(symbol const & s1, symbol const & s2) {
|
|||
return false;
|
||||
}
|
||||
SASSERT(!s1.is_numerical() && !s2.is_numerical());
|
||||
char const * str1 = s1.bare_str();
|
||||
char const * str2 = s2.bare_str();
|
||||
while (true) {
|
||||
if (*str1 < *str2) {
|
||||
return true;
|
||||
}
|
||||
else if (*str1 == *str2) {
|
||||
str1++;
|
||||
str2++;
|
||||
if (!*str1) {
|
||||
SASSERT(*str2); // the strings can't be equal.
|
||||
return true;
|
||||
}
|
||||
if (!*str2) {
|
||||
SASSERT(*str1); // the strings can't be equal.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
SASSERT(*str1 > *str2);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
auto cmp = strcmp(s1.bare_str(), s2.bare_str());
|
||||
SASSERT(cmp != 0);
|
||||
return cmp < 0;
|
||||
}
|
||||
|
|
|
@ -83,8 +83,7 @@ public:
|
|||
// It is the inverse of c_ptr().
|
||||
// It was made public to simplify the implementation of the C API.
|
||||
static symbol mk_symbol_from_c_ptr(void const * ptr) {
|
||||
symbol s(ptr);
|
||||
return s;
|
||||
return symbol(ptr);
|
||||
}
|
||||
unsigned hash() const {
|
||||
if (m_data == nullptr) return 0x9e3779d9;
|
||||
|
@ -93,7 +92,7 @@ public:
|
|||
}
|
||||
bool contains(char c) const;
|
||||
unsigned size() const;
|
||||
char const * bare_str() const { SASSERT(!is_numerical()); return is_numerical() ? "" : m_data; }
|
||||
char const * bare_str() const { SASSERT(!is_numerical()); return m_data; }
|
||||
friend std::ostream & operator<<(std::ostream & target, symbol s) {
|
||||
SASSERT(!s.is_marked());
|
||||
if (GET_TAG(s.m_data) == 0) {
|
||||
|
|
Loading…
Reference in a new issue