mirror of
https://github.com/Z3Prover/z3
synced 2025-04-08 10:25:18 +00:00
merge duality changes with unstable
This commit is contained in:
commit
d815af9f0f
|
@ -1,5 +1,7 @@
|
|||
#include<vector>
|
||||
#include"z3++.h"
|
||||
|
||||
|
||||
using namespace z3;
|
||||
|
||||
/**
|
||||
|
|
|
@ -90,12 +90,12 @@ int main(int argc, const char **argv) {
|
|||
|
||||
/* Read an interpolation problem */
|
||||
|
||||
int num;
|
||||
unsigned num;
|
||||
Z3_ast *constraints;
|
||||
int *parents = 0;
|
||||
unsigned *parents = 0;
|
||||
const char *error;
|
||||
bool ok;
|
||||
int num_theory;
|
||||
unsigned num_theory;
|
||||
Z3_ast *theory;
|
||||
|
||||
ok = Z3_read_interpolation_problem(ctx, &num, &constraints, tree_mode ? &parents : 0, filename, &error, &num_theory, &theory);
|
||||
|
@ -144,7 +144,7 @@ int main(int argc, const char **argv) {
|
|||
|
||||
if(!incremental_mode){
|
||||
/* In non-incremental mode, we just pass the constraints. */
|
||||
result = Z3_interpolate(ctx, num, constraints, (unsigned int *)parents, options, interpolants, &model, 0, false, num_theory, theory);
|
||||
result = Z3_L_UNDEF; // FIXME: Z3_interpolate(ctx, num, constraints, parents, options, interpolants, &model, 0, false, num_theory, theory);
|
||||
}
|
||||
else {
|
||||
|
||||
|
@ -165,7 +165,7 @@ int main(int argc, const char **argv) {
|
|||
for(int i = 0; i < num; i++){
|
||||
asserted[i] = constraints[i];
|
||||
Z3_assert_cnstr(ctx,constraints[i]); // assert one constraint
|
||||
result = Z3_interpolate(ctx, num, &asserted[0], (unsigned int *)parents, options, interpolants, &model, 0, true, 0, 0);
|
||||
result = Z3_L_UNDEF; // FIXME: Z3_interpolate(ctx, num, &asserted[0], parents, options, interpolants, &model, 0, true, 0, 0);
|
||||
if(result == Z3_L_FALSE){
|
||||
for(unsigned j = 0; j < num-1; j++)
|
||||
/* Since we want the interpolant formulas to survive a "pop", we
|
||||
|
|
|
@ -75,7 +75,7 @@ def init_project_def():
|
|||
# dll_name='foci2',
|
||||
# export_files=['foci2stub.cpp'])
|
||||
# add_lib('interp', ['solver','foci2'])
|
||||
API_files = ['z3_api.h', 'z3_algebraic.h', 'z3_polynomial.h', 'z3_rcf.h']
|
||||
API_files = ['z3_api.h', 'z3_algebraic.h', 'z3_polynomial.h', 'z3_rcf.h', 'z3_interp.h']
|
||||
add_lib('api', ['portfolio', 'user_plugin', 'smtparser', 'realclosure', 'interp'],
|
||||
includes2install=['z3.h', 'z3_v1.h', 'z3_macros.h'] + API_files)
|
||||
add_exe('shell', ['api', 'sat', 'extra_cmds'], exe_name='z3')
|
||||
|
|
|
@ -455,7 +455,7 @@ def display_help(exit_code):
|
|||
print(" -v, --vsproj generate Visual Studio Project Files.")
|
||||
if IS_WINDOWS:
|
||||
print(" -n, --nodotnet do not generate Microsoft.Z3.dll make rules.")
|
||||
print(" -j, --java generate Java bindinds.")
|
||||
print(" -j, --java generate Java bindings.")
|
||||
print(" --staticlib build Z3 static library.")
|
||||
if not IS_WINDOWS:
|
||||
print(" -g, --gmp use GMP.")
|
||||
|
@ -587,7 +587,7 @@ def set_z3py_dir(p):
|
|||
raise MKException("Python bindings directory '%s' does not exist" % full)
|
||||
Z3PY_SRC_DIR = full
|
||||
if VERBOSE:
|
||||
print("Python bindinds directory was detected.")
|
||||
print("Python bindings directory was detected.")
|
||||
|
||||
_UNIQ_ID = 0
|
||||
|
||||
|
@ -1801,7 +1801,7 @@ def def_module_params(module_name, export, params, class_name=None, description=
|
|||
out.write(' {}\n')
|
||||
out.write(' static void collect_param_descrs(param_descrs & d) {\n')
|
||||
for param in params:
|
||||
out.write(' d.insert("%s", %s, "%s", "%s");\n' % (param[0], TYPE2CPK[param[1]], param[3], pyg_default(param)))
|
||||
out.write(' d.insert("%s", %s, "%s", "%s","%s");\n' % (param[0], TYPE2CPK[param[1]], param[3], pyg_default(param), module_name))
|
||||
out.write(' }\n')
|
||||
if export:
|
||||
out.write(' /*\n')
|
||||
|
@ -2522,7 +2522,11 @@ def mk_vs_proj(name, components):
|
|||
f.write(' <ClCompile>\n')
|
||||
f.write(' <Optimization>Disabled</Optimization>\n')
|
||||
f.write(' <PreprocessorDefinitions>WIN32;_DEBUG;Z3DEBUG;_TRACE;_MP_INTERNAL;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n')
|
||||
f.write(' <MinimalRebuild>true</MinimalRebuild>\n')
|
||||
if VS_PAR:
|
||||
f.write(' <MinimalRebuild>false</MinimalRebuild>\n')
|
||||
f.write(' <MultiProcessorCompilation>true</MultiProcessorCompilation>\n')
|
||||
else:
|
||||
f.write(' <MinimalRebuild>true</MinimalRebuild>\n')
|
||||
f.write(' <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n')
|
||||
f.write(' <WarningLevel>Level3</WarningLevel>\n')
|
||||
f.write(' <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\n')
|
||||
|
@ -2556,7 +2560,11 @@ def mk_vs_proj(name, components):
|
|||
f.write(' <ClCompile>\n')
|
||||
f.write(' <Optimization>Disabled</Optimization>\n')
|
||||
f.write(' <PreprocessorDefinitions>WIN32;_NDEBUG;_MP_INTERNAL;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n')
|
||||
f.write(' <MinimalRebuild>true</MinimalRebuild>\n')
|
||||
if VS_PAR:
|
||||
f.write(' <MinimalRebuild>false</MinimalRebuild>\n')
|
||||
f.write(' <MultiProcessorCompilation>true</MultiProcessorCompilation>\n')
|
||||
else:
|
||||
f.write(' <MinimalRebuild>true</MinimalRebuild>\n')
|
||||
f.write(' <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n')
|
||||
f.write(' <WarningLevel>Level3</WarningLevel>\n')
|
||||
f.write(' <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\n')
|
||||
|
|
|
@ -108,6 +108,7 @@ INOUT = 2
|
|||
IN_ARRAY = 3
|
||||
OUT_ARRAY = 4
|
||||
INOUT_ARRAY = 5
|
||||
OUT_MANAGED_ARRAY = 6
|
||||
|
||||
# Primitive Types
|
||||
VOID = 0
|
||||
|
@ -131,13 +132,13 @@ def is_obj(ty):
|
|||
|
||||
Type2Str = { VOID : 'void', VOID_PTR : 'void*', INT : 'int', UINT : 'unsigned', INT64 : '__int64', UINT64 : '__uint64', DOUBLE : 'double',
|
||||
STRING : 'Z3_string', STRING_PTR : 'Z3_string_ptr', BOOL : 'Z3_bool', SYMBOL : 'Z3_symbol',
|
||||
PRINT_MODE : 'Z3_ast_print_mode', ERROR_CODE : 'Z3_error_code',
|
||||
PRINT_MODE : 'Z3_ast_print_mode', ERROR_CODE : 'Z3_error_code'
|
||||
}
|
||||
|
||||
Type2PyStr = { VOID_PTR : 'ctypes.c_void_p', INT : 'ctypes.c_int', UINT : 'ctypes.c_uint', INT64 : 'ctypes.c_longlong',
|
||||
UINT64 : 'ctypes.c_ulonglong', DOUBLE : 'ctypes.c_double',
|
||||
STRING : 'ctypes.c_char_p', STRING_PTR : 'ctypes.POINTER(ctypes.c_char_p)', BOOL : 'ctypes.c_bool', SYMBOL : 'Symbol',
|
||||
PRINT_MODE : 'ctypes.c_uint', ERROR_CODE : 'ctypes.c_uint',
|
||||
PRINT_MODE : 'ctypes.c_uint', ERROR_CODE : 'ctypes.c_uint'
|
||||
}
|
||||
|
||||
# Mapping to .NET types
|
||||
|
@ -148,11 +149,11 @@ Type2Dotnet = { VOID : 'void', VOID_PTR : 'IntPtr', INT : 'int', UINT : 'uint',
|
|||
# Mapping to Java types
|
||||
Type2Java = { VOID : 'void', VOID_PTR : 'long', INT : 'int', UINT : 'int', INT64 : 'long', UINT64 : 'long', DOUBLE : 'double',
|
||||
STRING : 'String', STRING_PTR : 'StringPtr',
|
||||
BOOL : 'boolean', SYMBOL : 'long', PRINT_MODE : 'int', ERROR_CODE : 'int' }
|
||||
BOOL : 'boolean', SYMBOL : 'long', PRINT_MODE : 'int', ERROR_CODE : 'int'}
|
||||
|
||||
Type2JavaW = { VOID : 'void', VOID_PTR : 'jlong', INT : 'jint', UINT : 'jint', INT64 : 'jlong', UINT64 : 'jlong', DOUBLE : 'jdouble',
|
||||
STRING : 'jstring', STRING_PTR : 'jobject',
|
||||
BOOL : 'jboolean', SYMBOL : 'jlong', PRINT_MODE : 'jint', ERROR_CODE : 'jint' }
|
||||
BOOL : 'jboolean', SYMBOL : 'jlong', PRINT_MODE : 'jint', ERROR_CODE : 'jint'}
|
||||
|
||||
|
||||
next_type_id = FIRST_OBJ_ID
|
||||
|
@ -224,6 +225,10 @@ def _out_array2(cap, sz, ty):
|
|||
def _inout_array(sz, ty):
|
||||
return (INOUT_ARRAY, ty, sz, sz);
|
||||
|
||||
def _out_managed_array(sz,ty):
|
||||
return (OUT_MANAGED_ARRAY, ty, 0, sz)
|
||||
|
||||
|
||||
def param_kind(p):
|
||||
return p[0]
|
||||
|
||||
|
@ -254,12 +259,14 @@ def param2dotnet(p):
|
|||
return "out IntPtr"
|
||||
else:
|
||||
return "[In, Out] ref %s" % type2dotnet(param_type(p))
|
||||
if k == IN_ARRAY:
|
||||
elif k == IN_ARRAY:
|
||||
return "[In] %s[]" % type2dotnet(param_type(p))
|
||||
if k == INOUT_ARRAY:
|
||||
elif k == INOUT_ARRAY:
|
||||
return "[In, Out] %s[]" % type2dotnet(param_type(p))
|
||||
if k == OUT_ARRAY:
|
||||
elif k == OUT_ARRAY:
|
||||
return "[Out] %s[]" % type2dotnet(param_type(p))
|
||||
elif k == OUT_MANAGED_ARRAY:
|
||||
return "[Out] out %s[]" % type2dotnet(param_type(p))
|
||||
else:
|
||||
return type2dotnet(param_type(p))
|
||||
|
||||
|
@ -268,7 +275,7 @@ def param2java(p):
|
|||
if k == OUT:
|
||||
if param_type(p) == INT or param_type(p) == UINT:
|
||||
return "IntPtr"
|
||||
elif param_type(p) == INT64 or param_type(p) == UINT64 or param_type(p) >= FIRST_OBJ_ID:
|
||||
elif param_type(p) == INT64 or param_type(p) == UINT64 or param_type(p) == VOID_PTR or param_type(p) >= FIRST_OBJ_ID:
|
||||
return "LongPtr"
|
||||
elif param_type(p) == STRING:
|
||||
return "StringPtr"
|
||||
|
@ -276,8 +283,13 @@ def param2java(p):
|
|||
print("ERROR: unreachable code")
|
||||
assert(False)
|
||||
exit(1)
|
||||
if k == IN_ARRAY or k == INOUT_ARRAY or k == OUT_ARRAY:
|
||||
elif k == IN_ARRAY or k == INOUT_ARRAY or k == OUT_ARRAY:
|
||||
return "%s[]" % type2java(param_type(p))
|
||||
elif k == OUT_MANAGED_ARRAY:
|
||||
if param_type(p) == UINT:
|
||||
return "UIntArrayPtr"
|
||||
else:
|
||||
return "ObjArrayPtr"
|
||||
else:
|
||||
return type2java(param_type(p))
|
||||
|
||||
|
@ -466,6 +478,8 @@ def mk_dotnet_wrappers():
|
|||
dotnet.write('out ');
|
||||
else:
|
||||
dotnet.write('ref ')
|
||||
elif param_kind(param) == OUT_MANAGED_ARRAY:
|
||||
dotnet.write('out ');
|
||||
dotnet.write('a%d' % i)
|
||||
i = i + 1
|
||||
dotnet.write(');\n');
|
||||
|
@ -522,6 +536,8 @@ def mk_java():
|
|||
java_native.write(' public static class IntPtr { public int value; }\n')
|
||||
java_native.write(' public static class LongPtr { public long value; }\n')
|
||||
java_native.write(' public static class StringPtr { public String value; }\n')
|
||||
java_native.write(' public static class ObjArrayPtr { public long[] value; }\n')
|
||||
java_native.write(' public static class UIntArrayPtr { public int[] value; }\n')
|
||||
java_native.write(' public static native void setInternalErrorHandler(long ctx);\n\n')
|
||||
if IS_WINDOWS or os.uname()[0]=="CYGWIN":
|
||||
java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java').dll_name)
|
||||
|
@ -676,9 +692,11 @@ def mk_java():
|
|||
if param_type(param) == INT or param_type(param) == UINT:
|
||||
java_wrapper.write(' jenv->GetIntArrayRegion(a%s, 0, (jsize)a%s, (jint*)_a%s);\n' % (i, param_array_capacity_pos(param), i))
|
||||
else:
|
||||
java_wrapper.write(' GETLONGAREGION(%s, a%s, 0, a%s, _a%s);\n' % (type2str(param_type(param)), i, param_array_capacity_pos(param), i))
|
||||
java_wrapper.write(' GETLONGAREGION(%s, a%s, 0, a%s, _a%s);\n' % (type2str(param_type(param)), i, param_array_capacity_pos(param), i))
|
||||
elif k == IN and param_type(param) == STRING:
|
||||
java_wrapper.write(' Z3_string _a%s = (Z3_string) jenv->GetStringUTFChars(a%s, NULL);\n' % (i, i))
|
||||
elif k == OUT_MANAGED_ARRAY:
|
||||
java_wrapper.write(' %s * _a%s = 0;\n' % (type2str(param_type(param)), i))
|
||||
i = i + 1
|
||||
# invoke procedure
|
||||
java_wrapper.write(' ')
|
||||
|
@ -697,6 +715,8 @@ def mk_java():
|
|||
java_wrapper.write('&_a%s' % i)
|
||||
elif k == OUT_ARRAY or k == IN_ARRAY or k == INOUT_ARRAY:
|
||||
java_wrapper.write('_a%s' % i)
|
||||
elif k == OUT_MANAGED_ARRAY:
|
||||
java_wrapper.write('&_a%s' % i)
|
||||
elif k == IN and param_type(param) == STRING:
|
||||
java_wrapper.write('_a%s' % i)
|
||||
else:
|
||||
|
@ -732,6 +752,8 @@ def mk_java():
|
|||
java_wrapper.write(' jfieldID fid = jenv->GetFieldID(mc, "value", "J");\n')
|
||||
java_wrapper.write(' jenv->SetLongField(a%s, fid, (jlong) _a%s);\n' % (i, i))
|
||||
java_wrapper.write(' }\n')
|
||||
elif k == OUT_MANAGED_ARRAY:
|
||||
java_wrapper.write(' *(jlong**)a%s = (jlong*)_a%s;\n' % (i, i))
|
||||
i = i + 1
|
||||
# return
|
||||
if result == STRING:
|
||||
|
@ -932,6 +954,9 @@ def def_API(name, result, params):
|
|||
elif ty == INT64:
|
||||
log_c.write(" I(0);\n")
|
||||
exe_c.write("in.get_int64_addr(%s)" % i)
|
||||
elif ty == VOID_PTR:
|
||||
log_c.write(" P(0);\n")
|
||||
exe_c.write("in.get_obj_addr(%s)" % i)
|
||||
else:
|
||||
error("unsupported parameter for %s, %s" % (name, p))
|
||||
elif kind == IN_ARRAY or kind == INOUT_ARRAY:
|
||||
|
@ -953,22 +978,43 @@ def def_API(name, result, params):
|
|||
log_c.write(" Au(a%s);\n" % sz)
|
||||
exe_c.write("in.get_uint_array(%s)" % i)
|
||||
else:
|
||||
error ("unsupported parameter for %s, %s" % (name, p))
|
||||
error ("unsupported parameter for %s, %s" % (ty, name, p))
|
||||
elif kind == OUT_ARRAY:
|
||||
sz = param_array_capacity_pos(p)
|
||||
log_c.write(" for (unsigned i = 0; i < a%s; i++) { " % sz)
|
||||
sz_p = params[sz]
|
||||
sz_p_k = param_kind(sz_p)
|
||||
tstr = type2str(ty)
|
||||
if sz_p_k == OUT or sz_p_k == INOUT:
|
||||
sz_e = ("(*a%s)" % sz)
|
||||
else:
|
||||
sz_e = ("a%s" % sz)
|
||||
log_c.write(" for (unsigned i = 0; i < %s; i++) { " % sz_e)
|
||||
if is_obj(ty):
|
||||
log_c.write("P(0);")
|
||||
log_c.write(" }\n")
|
||||
log_c.write(" Ap(a%s);\n" % sz)
|
||||
exe_c.write("reinterpret_cast<%s*>(in.get_obj_array(%s))" % (type2str(ty), i))
|
||||
log_c.write(" Ap(%s);\n" % sz_e)
|
||||
exe_c.write("reinterpret_cast<%s*>(in.get_obj_array(%s))" % (tstr, i))
|
||||
elif ty == UINT:
|
||||
log_c.write("U(0);")
|
||||
log_c.write(" }\n")
|
||||
log_c.write(" Au(a%s);\n" % sz)
|
||||
log_c.write(" Au(%s);\n" % sz_e)
|
||||
exe_c.write("in.get_uint_array(%s)" % i)
|
||||
else:
|
||||
error ("unsupported parameter for %s, %s" % (name, p))
|
||||
elif kind == OUT_MANAGED_ARRAY:
|
||||
sz = param_array_size_pos(p)
|
||||
sz_p = params[sz]
|
||||
sz_p_k = param_kind(sz_p)
|
||||
tstr = type2str(ty)
|
||||
if sz_p_k == OUT or sz_p_k == INOUT:
|
||||
sz_e = ("(*a%s)" % sz)
|
||||
else:
|
||||
sz_e = ("a%s" % sz)
|
||||
log_c.write(" for (unsigned i = 0; i < %s; i++) { " % sz_e)
|
||||
log_c.write("P(0);")
|
||||
log_c.write(" }\n")
|
||||
log_c.write(" Ap(%s);\n" % sz_e)
|
||||
exe_c.write("reinterpret_cast<%s**>(in.get_obj_array(%s))" % (tstr, i))
|
||||
else:
|
||||
error ("unsupported parameter for %s, %s" % (name, p))
|
||||
i = i + 1
|
||||
|
|
|
@ -208,7 +208,7 @@ extern "C" {
|
|||
MK_BINARY(Z3_mk_xor, mk_c(c)->get_basic_fid(), OP_XOR, SKIP);
|
||||
MK_NARY(Z3_mk_and, mk_c(c)->get_basic_fid(), OP_AND, SKIP);
|
||||
MK_NARY(Z3_mk_or, mk_c(c)->get_basic_fid(), OP_OR, SKIP);
|
||||
MK_UNARY(Z3_mk_interp, mk_c(c)->get_basic_fid(), OP_INTERP, SKIP);
|
||||
MK_UNARY(Z3_mk_interpolant, mk_c(c)->get_basic_fid(), OP_INTERP, SKIP);
|
||||
|
||||
Z3_ast mk_ite_core(Z3_context c, Z3_ast t1, Z3_ast t2, Z3_ast t3) {
|
||||
expr * result = mk_c(c)->m().mk_ite(to_expr(t1), to_expr(t2), to_expr(t3));
|
||||
|
|
|
@ -106,10 +106,4 @@ extern "C" {
|
|||
Z3_CATCH;
|
||||
}
|
||||
|
||||
Z3_bool Z3_API Z3_get_param_value(Z3_context c, Z3_string param_id, Z3_string* param_value) {
|
||||
LOG_Z3_get_param_value(c, param_id, param_value);
|
||||
// TODO
|
||||
return Z3_FALSE;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -128,6 +128,7 @@ namespace api {
|
|||
for (unsigned i = 0; i < m_replay_stack.size(); ++i) {
|
||||
dealloc(m_replay_stack[i]);
|
||||
}
|
||||
m_ast_trail.reset();
|
||||
}
|
||||
reset_parser();
|
||||
dealloc(m_solver);
|
||||
|
@ -342,24 +343,21 @@ namespace api {
|
|||
|
||||
void context::push() {
|
||||
get_smt_kernel().push();
|
||||
if (!m_user_ref_count) {
|
||||
m_ast_lim.push_back(m_ast_trail.size());
|
||||
m_replay_stack.push_back(0);
|
||||
}
|
||||
m_ast_lim.push_back(m_ast_trail.size());
|
||||
m_replay_stack.push_back(0);
|
||||
}
|
||||
|
||||
void context::pop(unsigned num_scopes) {
|
||||
for (unsigned i = 0; i < num_scopes; ++i) {
|
||||
if (!m_user_ref_count) {
|
||||
unsigned sz = m_ast_lim.back();
|
||||
m_ast_lim.pop_back();
|
||||
dealloc(m_replay_stack.back());
|
||||
m_replay_stack.pop_back();
|
||||
while (m_ast_trail.size() > sz) {
|
||||
m_ast_trail.pop_back();
|
||||
}
|
||||
unsigned sz = m_ast_lim.back();
|
||||
m_ast_lim.pop_back();
|
||||
dealloc(m_replay_stack.back());
|
||||
m_replay_stack.pop_back();
|
||||
while (m_ast_trail.size() > sz) {
|
||||
m_ast_trail.pop_back();
|
||||
}
|
||||
}
|
||||
SASSERT(num_scopes <= get_smt_kernel().get_scope_level());
|
||||
get_smt_kernel().pop(num_scopes);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -60,6 +60,7 @@ extern "C" {
|
|||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
mk_c(c)->save_ast_trail(r);
|
||||
RETURN_Z3(of_expr(r));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
@ -263,6 +264,7 @@ extern "C" {
|
|||
RESET_ERROR_CODE();
|
||||
CHECK_NON_NULL(f, 0);
|
||||
expr * e = to_func_interp_ref(f)->get_else();
|
||||
mk_c(c)->save_ast_trail(e);
|
||||
RETURN_Z3(of_expr(e));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
@ -301,6 +303,7 @@ extern "C" {
|
|||
LOG_Z3_func_entry_get_value(c, e);
|
||||
RESET_ERROR_CODE();
|
||||
expr * v = to_func_entry_ref(e)->get_result();
|
||||
mk_c(c)->save_ast_trail(v);
|
||||
RETURN_Z3(of_expr(v));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
|
|
@ -40,6 +40,11 @@ extern "C" {
|
|||
params_ref p = s->m_params;
|
||||
mk_c(c)->params().get_solver_params(mk_c(c)->m(), p, proofs_enabled, models_enabled, unsat_core_enabled);
|
||||
s->m_solver = (*(s->m_solver_factory))(mk_c(c)->m(), p, proofs_enabled, models_enabled, unsat_core_enabled, s->m_logic);
|
||||
|
||||
param_descrs r;
|
||||
s->m_solver->collect_param_descrs(r);
|
||||
context_params::collect_solver_param_descrs(r);
|
||||
p.validate(r);
|
||||
s->m_solver->updt_params(p);
|
||||
}
|
||||
|
||||
|
@ -102,6 +107,7 @@ extern "C" {
|
|||
if (!initialized)
|
||||
init_solver(c, s);
|
||||
to_solver_ref(s)->collect_param_descrs(descrs);
|
||||
context_params::collect_solver_param_descrs(descrs);
|
||||
if (!initialized)
|
||||
to_solver(s)->m_solver = 0;
|
||||
descrs.display(buffer);
|
||||
|
@ -119,6 +125,7 @@ extern "C" {
|
|||
if (!initialized)
|
||||
init_solver(c, s);
|
||||
to_solver_ref(s)->collect_param_descrs(d->m_descrs);
|
||||
context_params::collect_solver_param_descrs(d->m_descrs);
|
||||
if (!initialized)
|
||||
to_solver(s)->m_solver = 0;
|
||||
Z3_param_descrs r = of_param_descrs(d);
|
||||
|
@ -130,14 +137,19 @@ extern "C" {
|
|||
Z3_TRY;
|
||||
LOG_Z3_solver_set_params(c, s, p);
|
||||
RESET_ERROR_CODE();
|
||||
|
||||
if (to_solver(s)->m_solver) {
|
||||
bool old_model = to_solver(s)->m_params.get_bool("model", true);
|
||||
bool new_model = to_param_ref(p).get_bool("model", true);
|
||||
if (old_model != new_model)
|
||||
to_solver_ref(s)->set_produce_models(new_model);
|
||||
param_descrs r;
|
||||
to_solver_ref(s)->collect_param_descrs(r);
|
||||
context_params::collect_solver_param_descrs(r);
|
||||
to_param_ref(p).validate(r);
|
||||
to_solver_ref(s)->updt_params(to_param_ref(p));
|
||||
}
|
||||
to_solver(s)->m_params = to_param_ref(p);
|
||||
to_solver(s)->m_params.append(to_param_ref(p));
|
||||
Z3_CATCH;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ extern "C" {
|
|||
LOG_Z3_pop(c, num_scopes);
|
||||
RESET_ERROR_CODE();
|
||||
CHECK_SEARCHING(c);
|
||||
if (num_scopes > mk_c(c)->get_smt_kernel().get_scope_level()) {
|
||||
if (num_scopes > mk_c(c)->get_num_scopes()) {
|
||||
SET_ERROR_CODE(Z3_IOB);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -222,6 +222,9 @@ extern "C" {
|
|||
Z3_TRY;
|
||||
LOG_Z3_tactic_using_params(c, t, p);
|
||||
RESET_ERROR_CODE();
|
||||
param_descrs r;
|
||||
to_tactic_ref(t)->collect_param_descrs(r);
|
||||
to_param_ref(p).validate(r);
|
||||
tactic * new_t = using_params(to_tactic_ref(t), to_param_ref(p));
|
||||
RETURN_TACTIC(new_t);
|
||||
Z3_CATCH_RETURN(0);
|
||||
|
@ -447,6 +450,9 @@ extern "C" {
|
|||
Z3_TRY;
|
||||
LOG_Z3_tactic_apply_ex(c, t, g, p);
|
||||
RESET_ERROR_CODE();
|
||||
param_descrs pd;
|
||||
to_tactic_ref(t)->collect_param_descrs(pd);
|
||||
to_param_ref(p).validate(pd);
|
||||
Z3_apply_result r = _tactic_apply(c, t, g, to_param_ref(p));
|
||||
RETURN_Z3(r);
|
||||
Z3_CATCH_RETURN(0);
|
||||
|
|
|
@ -85,6 +85,8 @@ namespace z3 {
|
|||
friend std::ostream & operator<<(std::ostream & out, exception const & e) { out << e.msg(); return out; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\brief Z3 global configuration object.
|
||||
*/
|
||||
|
@ -269,8 +271,9 @@ namespace z3 {
|
|||
object(object const & s):m_ctx(s.m_ctx) {}
|
||||
context & ctx() const { return *m_ctx; }
|
||||
void check_error() const { m_ctx->check_error(); }
|
||||
friend void check_context(object const & a, object const & b) { assert(a.m_ctx == b.m_ctx); }
|
||||
friend void check_context(object const & a, object const & b);
|
||||
};
|
||||
inline void check_context(object const & a, object const & b) { assert(a.m_ctx == b.m_ctx); }
|
||||
|
||||
class symbol : public object {
|
||||
Z3_symbol m_sym;
|
||||
|
@ -282,7 +285,7 @@ namespace z3 {
|
|||
Z3_symbol_kind kind() const { return Z3_get_symbol_kind(ctx(), m_sym); }
|
||||
std::string str() const { assert(kind() == Z3_STRING_SYMBOL); return Z3_get_symbol_string(ctx(), m_sym); }
|
||||
int to_int() const { assert(kind() == Z3_INT_SYMBOL); return Z3_get_symbol_int(ctx(), m_sym); }
|
||||
friend std::ostream & operator<<(std::ostream & out, symbol const & s) {
|
||||
friend std::ostream & operator<<(std::ostream & out, symbol const & s) {
|
||||
if (s.kind() == Z3_INT_SYMBOL)
|
||||
out << "k!" << s.to_int();
|
||||
else
|
||||
|
@ -291,6 +294,7 @@ namespace z3 {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
class params : public object {
|
||||
Z3_params m_params;
|
||||
public:
|
||||
|
@ -309,7 +313,9 @@ namespace z3 {
|
|||
void set(char const * k, unsigned n) { Z3_params_set_uint(ctx(), m_params, ctx().str_symbol(k), n); }
|
||||
void set(char const * k, double n) { Z3_params_set_double(ctx(), m_params, ctx().str_symbol(k), n); }
|
||||
void set(char const * k, symbol const & s) { Z3_params_set_symbol(ctx(), m_params, ctx().str_symbol(k), s); }
|
||||
friend std::ostream & operator<<(std::ostream & out, params const & p) { out << Z3_params_to_string(p.ctx(), p); return out; }
|
||||
friend std::ostream & operator<<(std::ostream & out, params const & p) {
|
||||
out << Z3_params_to_string(p.ctx(), p); return out;
|
||||
}
|
||||
};
|
||||
|
||||
class ast : public object {
|
||||
|
@ -325,14 +331,19 @@ namespace z3 {
|
|||
ast & operator=(ast const & s) { Z3_inc_ref(s.ctx(), s.m_ast); if (m_ast) Z3_dec_ref(ctx(), m_ast); m_ctx = s.m_ctx; m_ast = s.m_ast; return *this; }
|
||||
Z3_ast_kind kind() const { Z3_ast_kind r = Z3_get_ast_kind(ctx(), m_ast); check_error(); return r; }
|
||||
unsigned hash() const { unsigned r = Z3_get_ast_hash(ctx(), m_ast); check_error(); return r; }
|
||||
friend std::ostream & operator<<(std::ostream & out, ast const & n) { out << Z3_ast_to_string(n.ctx(), n.m_ast); return out; }
|
||||
friend std::ostream & operator<<(std::ostream & out, ast const & n) {
|
||||
out << Z3_ast_to_string(n.ctx(), n.m_ast); return out;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Return true if the ASTs are structurally identical.
|
||||
*/
|
||||
friend bool eq(ast const & a, ast const & b) { return Z3_is_eq_ast(a.ctx(), a, b) != 0; }
|
||||
friend bool eq(ast const & a, ast const & b);
|
||||
};
|
||||
|
||||
inline bool eq(ast const & a, ast const & b) { return Z3_is_eq_ast(a.ctx(), a, b) != 0; }
|
||||
|
||||
|
||||
/**
|
||||
\brief A Z3 sort (aka type). Every expression (i.e., formula or term) in Z3 has a sort.
|
||||
*/
|
||||
|
@ -570,6 +581,7 @@ namespace z3 {
|
|||
return expr(a.ctx(), r);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Return an expression representing <tt>a and b</tt>.
|
||||
|
||||
|
@ -585,6 +597,7 @@ namespace z3 {
|
|||
return expr(a.ctx(), r);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Return an expression representing <tt>a and b</tt>.
|
||||
The C++ Boolean value \c b is automatically converted into a Z3 Boolean constant.
|
||||
|
@ -636,21 +649,10 @@ namespace z3 {
|
|||
a.check_error();
|
||||
return expr(a.ctx(), r);
|
||||
}
|
||||
friend expr implies(expr const & a, bool b) { return implies(a, a.ctx().bool_val(b)); }
|
||||
friend expr implies(bool a, expr const & b) { return implies(b.ctx().bool_val(a), b); }
|
||||
friend expr implies(expr const & a, bool b);
|
||||
friend expr implies(bool a, expr const & b);
|
||||
|
||||
/**
|
||||
\brief Create the if-then-else expression <tt>ite(c, t, e)</tt>
|
||||
|
||||
\pre c.is_bool()
|
||||
*/
|
||||
friend expr ite(expr const & c, expr const & t, expr const & e) {
|
||||
check_context(c, t); check_context(c, e);
|
||||
assert(c.is_bool());
|
||||
Z3_ast r = Z3_mk_ite(c.ctx(), c, t, e);
|
||||
c.check_error();
|
||||
return expr(c.ctx(), r);
|
||||
}
|
||||
friend expr ite(expr const & c, expr const & t, expr const & e);
|
||||
|
||||
friend expr distinct(expr_vector const& args);
|
||||
|
||||
|
@ -716,15 +718,9 @@ namespace z3 {
|
|||
/**
|
||||
\brief Power operator
|
||||
*/
|
||||
friend expr pw(expr const & a, expr const & b) {
|
||||
assert(a.is_arith() && b.is_arith());
|
||||
check_context(a, b);
|
||||
Z3_ast r = Z3_mk_power(a.ctx(), a, b);
|
||||
a.check_error();
|
||||
return expr(a.ctx(), r);
|
||||
}
|
||||
friend expr pw(expr const & a, int b) { return pw(a, a.ctx().num_val(b, a.get_sort())); }
|
||||
friend expr pw(int a, expr const & b) { return pw(b.ctx().num_val(a, b.get_sort()), b); }
|
||||
friend expr pw(expr const & a, expr const & b);
|
||||
friend expr pw(expr const & a, int b);
|
||||
friend expr pw(int a, expr const & b);
|
||||
|
||||
friend expr operator/(expr const & a, expr const & b) {
|
||||
check_context(a, b);
|
||||
|
@ -891,6 +887,38 @@ namespace z3 {
|
|||
expr substitute(expr_vector const& dst);
|
||||
|
||||
};
|
||||
|
||||
inline expr implies(expr const & a, bool b) { return implies(a, a.ctx().bool_val(b)); }
|
||||
inline expr implies(bool a, expr const & b) { return implies(b.ctx().bool_val(a), b); }
|
||||
|
||||
inline expr pw(expr const & a, expr const & b) {
|
||||
assert(a.is_arith() && b.is_arith());
|
||||
check_context(a, b);
|
||||
Z3_ast r = Z3_mk_power(a.ctx(), a, b);
|
||||
a.check_error();
|
||||
return expr(a.ctx(), r);
|
||||
}
|
||||
inline expr pw(expr const & a, int b) { return pw(a, a.ctx().num_val(b, a.get_sort())); }
|
||||
inline expr pw(int a, expr const & b) { return pw(b.ctx().num_val(a, b.get_sort()), b); }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\brief Create the if-then-else expression <tt>ite(c, t, e)</tt>
|
||||
|
||||
\pre c.is_bool()
|
||||
*/
|
||||
|
||||
inline expr ite(expr const & c, expr const & t, expr const & e) {
|
||||
check_context(c, t); check_context(c, e);
|
||||
assert(c.is_bool());
|
||||
Z3_ast r = Z3_mk_ite(c.ctx(), c, t, e);
|
||||
c.check_error();
|
||||
return expr(c.ctx(), r);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Wraps a Z3_ast as an expr object. It also checks for errors.
|
||||
|
@ -1404,22 +1432,28 @@ namespace z3 {
|
|||
t1.check_error();
|
||||
return tactic(t1.ctx(), r);
|
||||
}
|
||||
friend tactic repeat(tactic const & t, unsigned max=UINT_MAX) {
|
||||
Z3_tactic r = Z3_tactic_repeat(t.ctx(), t, max);
|
||||
t.check_error();
|
||||
return tactic(t.ctx(), r);
|
||||
}
|
||||
friend tactic with(tactic const & t, params const & p) {
|
||||
Z3_tactic r = Z3_tactic_using_params(t.ctx(), t, p);
|
||||
t.check_error();
|
||||
return tactic(t.ctx(), r);
|
||||
}
|
||||
friend tactic try_for(tactic const & t, unsigned ms) {
|
||||
Z3_tactic r = Z3_tactic_try_for(t.ctx(), t, ms);
|
||||
t.check_error();
|
||||
return tactic(t.ctx(), r);
|
||||
}
|
||||
friend tactic repeat(tactic const & t, unsigned max);
|
||||
friend tactic with(tactic const & t, params const & p);
|
||||
friend tactic try_for(tactic const & t, unsigned ms);
|
||||
};
|
||||
|
||||
inline tactic repeat(tactic const & t, unsigned max=UINT_MAX) {
|
||||
Z3_tactic r = Z3_tactic_repeat(t.ctx(), t, max);
|
||||
t.check_error();
|
||||
return tactic(t.ctx(), r);
|
||||
}
|
||||
|
||||
inline tactic with(tactic const & t, params const & p) {
|
||||
Z3_tactic r = Z3_tactic_using_params(t.ctx(), t, p);
|
||||
t.check_error();
|
||||
return tactic(t.ctx(), r);
|
||||
}
|
||||
inline tactic try_for(tactic const & t, unsigned ms) {
|
||||
Z3_tactic r = Z3_tactic_try_for(t.ctx(), t, ms);
|
||||
t.check_error();
|
||||
return tactic(t.ctx(), r);
|
||||
}
|
||||
|
||||
|
||||
class probe : public object {
|
||||
Z3_probe m_probe;
|
||||
|
|
|
@ -3527,28 +3527,11 @@ namespace Microsoft.Z3
|
|||
/// Only a few configuration parameters are mutable once the context is created.
|
||||
/// An exception is thrown when trying to modify an immutable parameter.
|
||||
/// </remarks>
|
||||
/// <seealso cref="GetParamValue"/>
|
||||
public void UpdateParamValue(string id, string value)
|
||||
{
|
||||
Native.Z3_update_param_value(nCtx, id, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a configuration parameter.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Returns null if the parameter value does not exist.
|
||||
/// </remarks>
|
||||
/// <seealso cref="UpdateParamValue"/>
|
||||
public string GetParamValue(string id)
|
||||
{
|
||||
IntPtr res = IntPtr.Zero;
|
||||
if (Native.Z3_get_param_value(nCtx, id, out res) == 0)
|
||||
return null;
|
||||
else
|
||||
return Marshal.PtrToStringAnsi(res);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal
|
||||
|
|
|
@ -323,6 +323,14 @@ namespace Microsoft.Z3
|
|||
|
||||
#endregion
|
||||
|
||||
#region Interpolation
|
||||
/// <summary>
|
||||
/// Indicates whether the term is marked for interpolation.
|
||||
/// </summary>
|
||||
/// <remarks></remarks>
|
||||
public bool IsInterpolant { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_INTERP; } }
|
||||
#endregion
|
||||
|
||||
#region Arithmetic Terms
|
||||
/// <summary>
|
||||
/// Indicates whether the term is of integer sort.
|
||||
|
@ -791,7 +799,7 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
/// <remarks>A label literal has a set of string parameters. It takes no arguments.</remarks>
|
||||
public bool IsLabelLit { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_LABEL_LIT; } }
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Proof Terms
|
||||
/// <summary>
|
||||
|
|
162
src/api/dotnet/InterpolationContext.cs
Normal file
162
src/api/dotnet/InterpolationContext.cs
Normal file
|
@ -0,0 +1,162 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// The InterpolationContext is suitable for generation of interpolants.
|
||||
/// </summary>
|
||||
/// <remarks>For more information on interpolation please refer
|
||||
/// too the C/C++ API, which is well documented.</remarks>
|
||||
[ContractVerification(true)]
|
||||
class InterpolationContext : Context
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
public InterpolationContext() : base() { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <remarks><seealso cref="Context.Context(Dictionary<string, string>)"/></remarks>
|
||||
public InterpolationContext(Dictionary<string, string> settings) : base(settings) { }
|
||||
|
||||
#region Terms
|
||||
/// <summary>
|
||||
/// Create an expression that marks a formula position for interpolation.
|
||||
/// </summary>
|
||||
public BoolExpr MkInterpolant(BoolExpr a)
|
||||
{
|
||||
Contract.Requires(a != null);
|
||||
Contract.Ensures(Contract.Result<BoolExpr>() != null);
|
||||
|
||||
CheckContextMatch(a);
|
||||
return new BoolExpr(this, Native.Z3_mk_interpolant(nCtx, a.NativeObject));
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Computes an interpolant.
|
||||
/// </summary>
|
||||
/// <remarks>For more information on interpolation please refer
|
||||
/// too the function Z3_get_interpolant in the C/C++ API, which is
|
||||
/// well documented.</remarks>
|
||||
Expr[] GetInterpolant(Expr pf, Expr pat, Params p)
|
||||
{
|
||||
Contract.Requires(pf != null);
|
||||
Contract.Requires(pat != null);
|
||||
Contract.Requires(p != null);
|
||||
Contract.Ensures(Contract.Result<Expr>() != null);
|
||||
|
||||
CheckContextMatch(pf);
|
||||
CheckContextMatch(pat);
|
||||
CheckContextMatch(p);
|
||||
|
||||
ASTVector seq = new ASTVector(this, Native.Z3_get_interpolant(nCtx, pf.NativeObject, pat.NativeObject, p.NativeObject));
|
||||
uint n = seq.Size;
|
||||
Expr[] res = new Expr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = Expr.Create(this, seq[i].NativeObject);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Computes an interpolant.
|
||||
/// </summary>
|
||||
/// <remarks>For more information on interpolation please refer
|
||||
/// too the function Z3_compute_interpolant in the C/C++ API, which is
|
||||
/// well documented.</remarks>
|
||||
Z3_lbool ComputeInterpolant(Expr pat, Params p, out ASTVector interp, out Model model)
|
||||
{
|
||||
Contract.Requires(pat != null);
|
||||
Contract.Requires(p != null);
|
||||
Contract.Ensures(Contract.ValueAtReturn(out interp) != null);
|
||||
Contract.Ensures(Contract.ValueAtReturn(out model) != null);
|
||||
|
||||
CheckContextMatch(pat);
|
||||
CheckContextMatch(p);
|
||||
|
||||
IntPtr i = IntPtr.Zero, m = IntPtr.Zero;
|
||||
int r = Native.Z3_compute_interpolant(nCtx, pat.NativeObject, p.NativeObject, ref i, ref m);
|
||||
interp = new ASTVector(this, i);
|
||||
model = new Model(this, m);
|
||||
return (Z3_lbool)r;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a string summarizing cumulative time used for interpolation.
|
||||
/// </summary>
|
||||
/// <remarks>For more information on interpolation please refer
|
||||
/// too the function Z3_interpolation_profile in the C/C++ API, which is
|
||||
/// well documented.</remarks>
|
||||
public string InterpolationProfile()
|
||||
{
|
||||
return Native.Z3_interpolation_profile(nCtx);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks the correctness of an interpolant.
|
||||
/// </summary>
|
||||
/// <remarks>For more information on interpolation please refer
|
||||
/// too the function Z3_check_interpolant in the C/C++ API, which is
|
||||
/// well documented.</remarks>
|
||||
public int CheckInterpolant(Expr[] cnsts, uint[] parents, Expr[] interps, out string error, Expr[] theory)
|
||||
{
|
||||
Contract.Requires(cnsts.Length == parents.Length);
|
||||
Contract.Requires(cnsts.Length == interps.Length + 1);
|
||||
IntPtr n_err_str;
|
||||
int r = Native.Z3_check_interpolant(nCtx,
|
||||
(uint)cnsts.Length,
|
||||
Expr.ArrayToNative(cnsts),
|
||||
parents,
|
||||
Expr.ArrayToNative(interps),
|
||||
out n_err_str,
|
||||
(uint)theory.Length,
|
||||
Expr.ArrayToNative(theory));
|
||||
error = Marshal.PtrToStringAnsi(n_err_str);
|
||||
return r;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads an interpolation problem from a file.
|
||||
/// </summary>
|
||||
/// <remarks>For more information on interpolation please refer
|
||||
/// too the function Z3_read_interpolation_problem in the C/C++ API, which is
|
||||
/// well documented.</remarks>
|
||||
public int ReadInterpolationProblem(string filename, out Expr[] cnsts, out uint[] parents, out string error, out Expr[] theory)
|
||||
{
|
||||
uint num = 0, num_theory = 0;
|
||||
IntPtr[] n_cnsts;
|
||||
IntPtr[] n_theory;
|
||||
IntPtr n_err_str;
|
||||
int r = Native.Z3_read_interpolation_problem(nCtx, ref num, out n_cnsts, out parents, filename, out n_err_str, ref num_theory, out n_theory);
|
||||
error = Marshal.PtrToStringAnsi(n_err_str);
|
||||
cnsts = new Expr[num];
|
||||
parents = new uint[num];
|
||||
theory = new Expr[num_theory];
|
||||
for (int i = 0; i < num; i++)
|
||||
cnsts[i] = Expr.Create(this, n_cnsts[i]);
|
||||
for (int i = 0; i < num_theory; i++)
|
||||
theory[i] = Expr.Create(this, n_theory[i]);
|
||||
return r;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes an interpolation problem to a file.
|
||||
/// </summary>
|
||||
/// <remarks>For more information on interpolation please refer
|
||||
/// too the function Z3_write_interpolation_problem in the C/C++ API, which is
|
||||
/// well documented.</remarks>
|
||||
public void WriteInterpolationProblem(string filename, Expr[] cnsts, uint[] parents, Expr[] theory)
|
||||
{
|
||||
Contract.Requires(cnsts.Length == parents.Length);
|
||||
Native.Z3_write_interpolation_problem(nCtx, (uint)cnsts.Length, Expr.ArrayToNative(cnsts), parents, filename, (uint)theory.Length, Expr.ArrayToNative(theory));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,12 +19,12 @@
|
|||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\Debug\</OutputPath>
|
||||
<OutputPath>..\..\..\..\..\cwinter\bugs\z3bugs\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>..\Debug\Microsoft.Z3.XML</DocumentationFile>
|
||||
<DocumentationFile>C:\cwinter\bugs\z3bugs\Debug\Microsoft.Z3.XML</DocumentationFile>
|
||||
<CodeContractsEnableRuntimeChecking>False</CodeContractsEnableRuntimeChecking>
|
||||
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
|
||||
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
|
||||
|
@ -254,7 +254,7 @@
|
|||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<OutputPath>..\..\..\..\..\cwinter\bugs\z3bugs\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DebugType>full</DebugType>
|
||||
|
@ -266,7 +266,7 @@
|
|||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<DocumentationFile>bin\x86\Debug\Microsoft.Z3.XML</DocumentationFile>
|
||||
<DocumentationFile>C:\cwinter\bugs\z3bugs\Debug\Microsoft.Z3.XML</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
|
@ -352,6 +352,7 @@
|
|||
<Compile Include="FuncDecl.cs" />
|
||||
<Compile Include="FuncInterp.cs" />
|
||||
<Compile Include="Goal.cs" />
|
||||
<Compile Include="InterpolationContext.cs" />
|
||||
<Compile Include="IntExpr.cs" />
|
||||
<Compile Include="IntNum.cs" />
|
||||
<Compile Include="IntSort.cs" />
|
||||
|
|
|
@ -58,6 +58,16 @@ namespace Microsoft.Z3
|
|||
Native.Z3_params_set_double(Context.nCtx, NativeObject, name.NativeObject, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a parameter setting.
|
||||
/// </summary>
|
||||
public void Add(Symbol name, string value)
|
||||
{
|
||||
Contract.Requires(value != null);
|
||||
|
||||
Native.Z3_params_set_symbol(Context.nCtx, NativeObject, name.NativeObject, Context.MkSymbol(value).NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a parameter setting.
|
||||
/// </summary>
|
||||
|
@ -103,6 +113,16 @@ namespace Microsoft.Z3
|
|||
Native.Z3_params_set_symbol(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, value.NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a parameter setting.
|
||||
/// </summary>
|
||||
public void Add(string name, string value)
|
||||
{
|
||||
Contract.Requires(value != null);
|
||||
|
||||
Native.Z3_params_set_symbol(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, Context.MkSymbol(value).NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A string representation of the parameter set.
|
||||
/// </summary>
|
||||
|
|
|
@ -74,9 +74,10 @@ namespace Microsoft.Z3
|
|||
Contract.Requires(name != null);
|
||||
|
||||
IntPtr t = IntPtr.Zero;
|
||||
IntPtr[] f = new IntPtr[numFields];
|
||||
NativeObject = Native.Z3_mk_tuple_sort(ctx.nCtx, name.NativeObject, numFields,
|
||||
Symbol.ArrayToNative(fieldNames), AST.ArrayToNative(fieldSorts),
|
||||
ref t, new IntPtr[numFields]);
|
||||
ref t, f);
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from AST.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
AST.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ASTDecRefQueue.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from ASTMap.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ASTMap.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from ASTVector.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ASTVector.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from AlgebraicNum.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
AlgebraicNum.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from ApplyResult.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ApplyResult.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ApplyResultDecRefQueue.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from ArithExpr.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
* **/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ArithExpr.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from ArithSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ArithSort.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from ArrayExpr.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ArrayExpr.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from ArraySort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ArraySort.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
AstMapDecRefQueue.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
AstVectorDecRefQueue.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from BitVecExpr.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
BitVecExpr.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from BitVecNum.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
BitVecNum.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,20 @@
|
|||
/**
|
||||
* This file was automatically generated from BitVecSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
BitVecSort.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from BoolExpr.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
BoolExpr.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from BoolSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
BoolSort.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from Constructor.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Constructor.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from ConstructorList.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ConstructorList.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from Context.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Context.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
@ -2904,27 +2915,13 @@ public class Context extends IDisposable
|
|||
* configuration parameters can be obtained using the Z3 executable:
|
||||
* <code>z3.exe -ini?</code> Only a few configuration parameters are mutable
|
||||
* once the context is created. An exception is thrown when trying to modify
|
||||
* an immutable parameter. </remarks> <seealso cref="GetParamValue"/>
|
||||
* an immutable parameter. </remarks>
|
||||
**/
|
||||
public void updateParamValue(String id, String value) throws Z3Exception
|
||||
{
|
||||
Native.updateParamValue(nCtx(), id, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a configuration parameter. <remarks> Returns null if the parameter
|
||||
* value does not exist. </remarks> <seealso cref="UpdateParamValue"/>
|
||||
**/
|
||||
public String getParamValue(String id) throws Z3Exception
|
||||
{
|
||||
Native.StringPtr res = new Native.StringPtr();
|
||||
boolean r = Native.getParamValue(nCtx(), id, res);
|
||||
if (!r)
|
||||
return null;
|
||||
else
|
||||
return res.value;
|
||||
}
|
||||
|
||||
long m_ctx = 0;
|
||||
|
||||
long nCtx()
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from DatatypeExpr.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
DatatypeExpr.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from DatatypeSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
DatatypeSort.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from EnumSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
EnumSort.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from Expr.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Expr.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from FiniteDomainSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FiniteDomainSort.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from Fixedpoint.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Fixedpoint.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FixedpointDecRefQueue.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from FuncDecl.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FuncDecl.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from FuncInterp.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FuncInterp.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FuncInterpDecRefQueue.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FuncInterpEntryDecRefQueue.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
/**
|
||||
* Global.java
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Global.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from Goal.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Goal.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
GoalDecRefQueue.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from IDecRefQueue.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
IDecRefQueue.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from IntExpr.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
IntExpr.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from IntNum.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
IntNum.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from IntSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
IntSort.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from IntSymbol.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
IntSymbol.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
183
src/api/java/InterpolationContext.java
Normal file
183
src/api/java/InterpolationContext.java
Normal file
|
@ -0,0 +1,183 @@
|
|||
/**
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
InterpolationContext.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import java.util.Map;
|
||||
import java.lang.String;
|
||||
|
||||
import com.microsoft.z3.Native.IntPtr;
|
||||
import com.microsoft.z3.Native.UIntArrayPtr;
|
||||
import com.microsoft.z3.enumerations.Z3_lbool;
|
||||
|
||||
/** <summary>
|
||||
* The InterpolationContext is suitable for generation of interpolants.
|
||||
* </summary>
|
||||
* <remarks>For more information on interpolation please refer
|
||||
* too the C/C++ API, which is well documented.</remarks>
|
||||
**/
|
||||
public class InterpolationContext extends Context
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
**/
|
||||
public InterpolationContext() throws Z3Exception
|
||||
{
|
||||
m_ctx = Native.mkInterpolationContext(0);
|
||||
initContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* <remarks><seealso cref="Context.Context(Dictionary<string, string>)"/></remarks>
|
||||
**/
|
||||
public InterpolationContext(Map<String, String> settings) throws Z3Exception
|
||||
{
|
||||
long cfg = Native.mkConfig();
|
||||
for (Map.Entry<String, String> kv : settings.entrySet())
|
||||
Native.setParamValue(cfg, kv.getKey(), kv.getValue());
|
||||
m_ctx = Native.mkInterpolationContext(cfg);
|
||||
Native.delConfig(cfg);
|
||||
initContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an expression that marks a formula position for interpolation.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public BoolExpr MkInterpolant(BoolExpr a) throws Z3Exception
|
||||
{
|
||||
checkContextMatch(a);
|
||||
return new BoolExpr(this, Native.mkInterpolant(nCtx(), a.getNativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes an interpolant.
|
||||
* <remarks>For more information on interpolation please refer
|
||||
* too the function Z3_get_interpolant in the C/C++ API, which is
|
||||
* well documented.</remarks>
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
Expr[] GetInterpolant(Expr pf, Expr pat, Params p) throws Z3Exception
|
||||
{
|
||||
checkContextMatch(pf);
|
||||
checkContextMatch(pat);
|
||||
checkContextMatch(p);
|
||||
|
||||
ASTVector seq = new ASTVector(this, Native.getInterpolant(nCtx(), pf.getNativeObject(), pat.getNativeObject(), p.getNativeObject()));
|
||||
int n = seq.size();
|
||||
Expr[] res = new Expr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = Expr.create(this, seq.get(i).getNativeObject());
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes an interpolant.
|
||||
* <remarks>For more information on interpolation please refer
|
||||
* too the function Z3_compute_interpolant in the C/C++ API, which is
|
||||
* well documented.</remarks>
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
Z3_lbool ComputeInterpolant(Expr pat, Params p, ASTVector interp, Model model) throws Z3Exception
|
||||
{
|
||||
checkContextMatch(pat);
|
||||
checkContextMatch(p);
|
||||
|
||||
Native.LongPtr n_i = new Native.LongPtr();
|
||||
Native.LongPtr n_m = new Native.LongPtr();
|
||||
int r = Native.computeInterpolant(nCtx(), pat.getNativeObject(), p.getNativeObject(), n_i, n_m);
|
||||
interp = new ASTVector(this, n_i.value);
|
||||
model = new Model(this, n_m.value);
|
||||
return Z3_lbool.fromInt(r);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a string summarizing cumulative time used for interpolation.
|
||||
/// </summary>
|
||||
/// <remarks>For more information on interpolation please refer
|
||||
/// too the function Z3_interpolation_profile in the C/C++ API, which is
|
||||
/// well documented.</remarks>
|
||||
public String InterpolationProfile() throws Z3Exception
|
||||
{
|
||||
return Native.interpolationProfile(nCtx());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks the correctness of an interpolant.
|
||||
/// </summary>
|
||||
/// <remarks>For more information on interpolation please refer
|
||||
/// too the function Z3_check_interpolant in the C/C++ API, which is
|
||||
/// well documented.</remarks>
|
||||
public int CheckInterpolant(Expr[] cnsts, int[] parents, Expr[] interps, String error, Expr[] theory) throws Z3Exception
|
||||
{
|
||||
Native.StringPtr n_err_str = new Native.StringPtr();
|
||||
int r = Native.checkInterpolant(nCtx(),
|
||||
cnsts.length,
|
||||
Expr.arrayToNative(cnsts),
|
||||
parents,
|
||||
Expr.arrayToNative(interps),
|
||||
n_err_str,
|
||||
theory.length,
|
||||
Expr.arrayToNative(theory));
|
||||
error = n_err_str.value;
|
||||
return r;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads an interpolation problem from a file.
|
||||
/// </summary>
|
||||
/// <remarks>For more information on interpolation please refer
|
||||
/// too the function Z3_read_interpolation_problem in the C/C++ API, which is
|
||||
/// well documented.</remarks>
|
||||
public int ReadInterpolationProblem(String filename, Expr[] cnsts, int[] parents, String error, Expr[] theory) throws Z3Exception
|
||||
{
|
||||
Native.IntPtr n_num = new Native.IntPtr();
|
||||
Native.IntPtr n_num_theory = new Native.IntPtr();
|
||||
Native.ObjArrayPtr n_cnsts = new Native.ObjArrayPtr();
|
||||
Native.UIntArrayPtr n_parents = new Native.UIntArrayPtr();
|
||||
Native.ObjArrayPtr n_theory = new Native.ObjArrayPtr();
|
||||
Native.StringPtr n_err_str = new Native.StringPtr();
|
||||
int r = Native.readInterpolationProblem(nCtx(), n_num, n_cnsts, n_parents, filename, n_err_str, n_num_theory, n_theory);
|
||||
int num = n_num.value;
|
||||
int num_theory = n_num_theory.value;
|
||||
error = n_err_str.value;
|
||||
cnsts = new Expr[num];
|
||||
parents = new int[num];
|
||||
theory = new Expr[num_theory];
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
cnsts[i] = Expr.create(this, n_cnsts.value[i]);
|
||||
parents[i] = n_parents.value[i];
|
||||
}
|
||||
for (int i = 0; i < num_theory; i++)
|
||||
theory[i] = Expr.create(this, n_theory.value[i]);
|
||||
return r;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes an interpolation problem to a file.
|
||||
/// </summary>
|
||||
/// <remarks>For more information on interpolation please refer
|
||||
/// too the function Z3_write_interpolation_problem in the C/C++ API, which is
|
||||
/// well documented.</remarks>
|
||||
public void WriteInterpolationProblem(String filename, Expr[] cnsts, int[] parents, String error, Expr[] theory) throws Z3Exception
|
||||
{
|
||||
Native.writeInterpolationProblem(nCtx(), cnsts.length, Expr.arrayToNative(cnsts), parents, filename, theory.length, Expr.arrayToNative(theory));
|
||||
}
|
||||
}
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from ListSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ListSort.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from Log.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Log.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from Model.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Model.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ModelDecRefQueue.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from ParamDescrs.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ParamDescrs.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ParamDescrsDecRefQueue.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,20 @@
|
|||
/**
|
||||
* This file was automatically generated from Params.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Params.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
@ -28,6 +40,17 @@ public class Params extends Z3Object
|
|||
Native.paramsSetDouble(getContext().nCtx(), getNativeObject(),
|
||||
name.getNativeObject(), value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a parameter setting.
|
||||
**/
|
||||
public void add(Symbol name, String value) throws Z3Exception
|
||||
{
|
||||
|
||||
Native.paramsSetSymbol(getContext().nCtx(), getNativeObject(),
|
||||
name.getNativeObject(),
|
||||
getContext().mkSymbol(value).getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a parameter setting.
|
||||
|
@ -75,6 +98,17 @@ public class Params extends Z3Object
|
|||
.mkSymbol(name).getNativeObject(), value.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a parameter setting.
|
||||
**/
|
||||
public void add(String name, String value) throws Z3Exception
|
||||
{
|
||||
|
||||
Native.paramsSetSymbol(getContext().nCtx(), getNativeObject(),
|
||||
getContext().mkSymbol(name).getNativeObject(),
|
||||
getContext().mkSymbol(value).getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* A string representation of the parameter set.
|
||||
**/
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ParamDecRefQueue.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from Pattern.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Pattern.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from Probe.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Probe.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ProbeDecRefQueue.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from Quantifier.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Quantifier.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from RatNum.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
RatNum.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from RealExpr.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
RealExpr.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from RealSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
RealSort.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from RelationSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
RelationSort.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from SetSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
SetSort.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from Solver.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Solver.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
SolverDecRefQueue.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from Sort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Sort.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from Statistics.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Statistics.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
StatisticsDecRefQueue.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from Status.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Status.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from StringSymbol.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
StringSymbol.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from Symbol.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Symbol.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from Tactic.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Tactic.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
TacticDecRefQueue.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from TupleSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
TupleSort.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from UninterpretedSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
UninterpretedSort.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from Version.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Version.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from Z3Exception.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Z3Exception.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
/**
|
||||
* This file was automatically generated from Z3Object.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Z3Object.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
|
|
@ -297,6 +297,11 @@ class AstRef(Z3PPObject):
|
|||
"""Return a pointer to the corresponding C Z3_ast object."""
|
||||
return self.ast
|
||||
|
||||
def get_id(self):
|
||||
"""Return unique identifier for object. It can be used for hash-tables and maps."""
|
||||
return Z3_get_ast_id(self.ctx_ref(), self.as_ast())
|
||||
|
||||
|
||||
def ctx_ref(self):
|
||||
"""Return a reference to the C context where this AST node is stored."""
|
||||
return self.ctx.ref()
|
||||
|
@ -447,6 +452,10 @@ class SortRef(AstRef):
|
|||
def as_ast(self):
|
||||
return Z3_sort_to_ast(self.ctx_ref(), self.ast)
|
||||
|
||||
def get_id(self):
|
||||
return Z3_get_ast_id(self.ctx_ref(), self.as_ast())
|
||||
|
||||
|
||||
def kind(self):
|
||||
"""Return the Z3 internal kind of a sort. This method can be used to test if `self` is one of the Z3 builtin sorts.
|
||||
|
||||
|
@ -585,6 +594,9 @@ class FuncDeclRef(AstRef):
|
|||
def as_ast(self):
|
||||
return Z3_func_decl_to_ast(self.ctx_ref(), self.ast)
|
||||
|
||||
def get_id(self):
|
||||
return Z3_get_ast_id(self.ctx_ref(), self.as_ast())
|
||||
|
||||
def as_func_decl(self):
|
||||
return self.ast
|
||||
|
||||
|
@ -730,6 +742,9 @@ class ExprRef(AstRef):
|
|||
def as_ast(self):
|
||||
return self.ast
|
||||
|
||||
def get_id(self):
|
||||
return Z3_get_ast_id(self.ctx_ref(), self.as_ast())
|
||||
|
||||
def sort(self):
|
||||
"""Return the sort of expression `self`.
|
||||
|
||||
|
@ -1524,6 +1539,9 @@ class PatternRef(ExprRef):
|
|||
def as_ast(self):
|
||||
return Z3_pattern_to_ast(self.ctx_ref(), self.ast)
|
||||
|
||||
def get_id(self):
|
||||
return Z3_get_ast_id(self.ctx_ref(), self.as_ast())
|
||||
|
||||
def is_pattern(a):
|
||||
"""Return `True` if `a` is a Z3 pattern (hint for quantifier instantiation.
|
||||
|
||||
|
@ -1586,6 +1604,9 @@ class QuantifierRef(BoolRef):
|
|||
def as_ast(self):
|
||||
return self.ast
|
||||
|
||||
def get_id(self):
|
||||
return Z3_get_ast_id(self.ctx_ref(), self.as_ast())
|
||||
|
||||
def sort(self):
|
||||
"""Return the Boolean sort."""
|
||||
return BoolSort(self.ctx)
|
||||
|
@ -4448,7 +4469,7 @@ def args2params(arguments, keywords, ctx=None):
|
|||
A ':' is added to the keywords, and '_' is replaced with '-'
|
||||
|
||||
>>> args2params(['model', True, 'relevancy', 2], {'elim_and' : True})
|
||||
(params model 1 relevancy 2 elim_and 1)
|
||||
(params model true relevancy 2 elim_and true)
|
||||
"""
|
||||
if __debug__:
|
||||
_z3_assert(len(arguments) % 2 == 0, "Argument list must have an even number of elements.")
|
||||
|
@ -6011,6 +6032,24 @@ class Solver(Z3PPObject):
|
|||
"""
|
||||
return Z3_solver_to_string(self.ctx.ref(), self.solver)
|
||||
|
||||
def to_smt2(self):
|
||||
"""return SMTLIB2 formatted benchmark for solver's assertions"""
|
||||
es = self.assertions()
|
||||
sz = len(es)
|
||||
sz1 = sz
|
||||
if sz1 > 0:
|
||||
sz1 -= 1
|
||||
v = (Ast * sz1)()
|
||||
for i in range(sz1):
|
||||
v[i] = es[i].as_ast()
|
||||
if sz > 0:
|
||||
e = es[sz1].as_ast()
|
||||
else:
|
||||
e = BoolVal(True, self.ctx).as_ast()
|
||||
return Z3_benchmark_to_smtlib_string(self.ctx.ref(), "benchmark generated from python API", "", "unknown", "", sz1, v, e)
|
||||
|
||||
|
||||
|
||||
def SolverFor(logic, ctx=None):
|
||||
"""Create a solver customized for the given logic.
|
||||
|
||||
|
@ -6960,7 +6999,7 @@ def substitute(t, *m):
|
|||
if isinstance(m, tuple):
|
||||
m1 = _get_args(m)
|
||||
if isinstance(m1, list):
|
||||
m = _get_args(m1)
|
||||
m = m1
|
||||
if __debug__:
|
||||
_z3_assert(is_expr(t), "Z3 expression expected")
|
||||
_z3_assert(all([isinstance(p, tuple) and is_expr(p[0]) and is_expr(p[1]) and p[0].sort().eq(p[1].sort()) for p in m]), "Z3 invalid substitution, expression pairs expected.")
|
||||
|
@ -7253,19 +7292,19 @@ def parse_smt2_file(f, sorts={}, decls={}, ctx=None):
|
|||
dsz, dnames, ddecls = _dict2darray(decls, ctx)
|
||||
return _to_expr_ref(Z3_parse_smtlib2_file(ctx.ref(), f, ssz, snames, ssorts, dsz, dnames, ddecls), ctx)
|
||||
|
||||
def Interp(a,ctx=None):
|
||||
def Interpolant(a,ctx=None):
|
||||
"""Create an interpolation operator.
|
||||
|
||||
The argument is an interpolation pattern (see tree_interpolant).
|
||||
|
||||
>>> x = Int('x')
|
||||
>>> print Interp(x>0)
|
||||
>>> print Interpolant(x>0)
|
||||
interp(x > 0)
|
||||
"""
|
||||
ctx = _get_ctx(_ctx_from_ast_arg_list([a], ctx))
|
||||
s = BoolSort(ctx)
|
||||
a = s.cast(a)
|
||||
return BoolRef(Z3_mk_interp(ctx.ref(), a.as_ast()), ctx)
|
||||
return BoolRef(Z3_mk_interpolant(ctx.ref(), a.as_ast()), ctx)
|
||||
|
||||
def tree_interpolant(pat,p=None,ctx=None):
|
||||
"""Compute interpolant for a tree of formulas.
|
||||
|
@ -7304,10 +7343,10 @@ def tree_interpolant(pat,p=None,ctx=None):
|
|||
|
||||
>>> x = Int('x')
|
||||
>>> y = Int('y')
|
||||
>>> print tree_interpolant(And(Interp(x < 0), Interp(y > 2), x == y))
|
||||
>>> print tree_interpolant(And(Interpolant(x < 0), Interpolant(y > 2), x == y))
|
||||
[Not(x >= 0), Not(y <= 2)]
|
||||
|
||||
>>> g = And(Interp(x<0),x<2)
|
||||
>>> g = And(Interpolant(x<0),x<2)
|
||||
>>> try:
|
||||
... print tree_interpolant(g).sexpr()
|
||||
... except ModelRef as m:
|
||||
|
@ -7342,11 +7381,11 @@ def binary_interpolant(a,b,p=None,ctx=None):
|
|||
If parameters p are supplied, these are used in creating the
|
||||
solver that determines satisfiability.
|
||||
|
||||
>>> x = Int('x')
|
||||
>>> print binary_interpolant(x<0,x>2)
|
||||
x <= 2
|
||||
x = Int('x')
|
||||
print binary_interpolant(x<0,x>2)
|
||||
Not(x >= 0)
|
||||
"""
|
||||
f = And(Interp(a),b)
|
||||
f = And(Interpolant(a),b)
|
||||
return tree_interpolant(f,p,ctx)[0]
|
||||
|
||||
def sequence_interpolant(v,p=None,ctx=None):
|
||||
|
@ -7375,6 +7414,6 @@ def sequence_interpolant(v,p=None,ctx=None):
|
|||
"""
|
||||
f = v[0]
|
||||
for i in range(1,len(v)):
|
||||
f = And(Interp(f),v[i])
|
||||
f = And(Interpolant(f),v[i])
|
||||
return tree_interpolant(f,p,ctx)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ class Z3Exception(Exception):
|
|||
def __init__(self, value):
|
||||
self.value = value
|
||||
def __str__(self):
|
||||
return repr(self.value)
|
||||
return str(self.value)
|
||||
|
||||
class ContextObj(ctypes.c_void_p):
|
||||
def __init__(self, context): self._as_parameter_ = context
|
||||
|
|
|
@ -27,6 +27,7 @@ Notes:
|
|||
#include"z3_algebraic.h"
|
||||
#include"z3_polynomial.h"
|
||||
#include"z3_rcf.h"
|
||||
#include"z3_interp.h"
|
||||
|
||||
#undef __in
|
||||
#undef __out
|
||||
|
|
376
src/api/z3_api.h
376
src/api/z3_api.h
|
@ -1375,6 +1375,16 @@ extern "C" {
|
|||
although some parameters can be changed using #Z3_update_param_value.
|
||||
All main interaction with Z3 happens in the context of a \c Z3_context.
|
||||
|
||||
In contrast to #Z3_mk_context_rc, the life time of Z3_ast objects
|
||||
are determined by the scope level of #Z3_push and #Z3_pop.
|
||||
In other words, a Z3_ast object remains valid until there is a
|
||||
call to Z3_pop that takes the current scope below the level where
|
||||
the object was created.
|
||||
|
||||
Note that all other reference counted objects, including Z3_model,
|
||||
Z3_solver, Z3_func_interp have to be managed by the caller.
|
||||
Their reference counts are not handled by the context.
|
||||
|
||||
\conly \sa Z3_del_context
|
||||
|
||||
\conly \deprecated Use #Z3_mk_context_rc
|
||||
|
@ -1452,15 +1462,6 @@ extern "C" {
|
|||
*/
|
||||
void Z3_API Z3_update_param_value(__in Z3_context c, __in Z3_string param_id, __in Z3_string param_value);
|
||||
|
||||
/**
|
||||
\brief Return the value of a context parameter.
|
||||
|
||||
\sa Z3_global_param_get
|
||||
|
||||
def_API('Z3_get_param_value', BOOL, (_in(CONTEXT), _in(STRING), _out(STRING)))
|
||||
*/
|
||||
Z3_bool_opt Z3_API Z3_get_param_value(__in Z3_context c, __in Z3_string param_id, __out_opt Z3_string_ptr param_value);
|
||||
|
||||
#ifdef CorML4
|
||||
/**
|
||||
\brief Interrupt the execution of a Z3 procedure.
|
||||
|
@ -1769,7 +1770,7 @@ extern "C" {
|
|||
Z3_sort Z3_API Z3_mk_tuple_sort(__in Z3_context c,
|
||||
__in Z3_symbol mk_tuple_name,
|
||||
__in unsigned num_fields,
|
||||
__in_ecount(num_fields) Z3_symbol const field_names[],
|
||||
__in_ecount(num_fields) Z3_symbol const field_names[],
|
||||
__in_ecount(num_fields) Z3_sort const field_sorts[],
|
||||
__out Z3_func_decl * mk_tuple_decl,
|
||||
__out_ecount(num_fields) Z3_func_decl proj_decl[]);
|
||||
|
@ -2106,17 +2107,7 @@ END_MLAPI_EXCLUDE
|
|||
def_API('Z3_mk_not', AST, (_in(CONTEXT), _in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_not(__in Z3_context c, __in Z3_ast a);
|
||||
|
||||
/**
|
||||
\brief \mlh mk_interp c a \endmlh
|
||||
Create an AST node marking a formula position for interpolation.
|
||||
|
||||
The node \c a must have Boolean sort.
|
||||
|
||||
def_API('Z3_mk_interp', AST, (_in(CONTEXT), _in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_interp(__in Z3_context c, __in Z3_ast a);
|
||||
|
||||
/**
|
||||
\brief \mlh mk_ite c t1 t2 t2 \endmlh
|
||||
Create an AST node representing an if-then-else: <tt>ite(t1, t2,
|
||||
|
@ -4907,8 +4898,7 @@ END_MLAPI_EXCLUDE
|
|||
__in_ecount(num_sorts) Z3_sort const sorts[],
|
||||
__in unsigned num_decls,
|
||||
__in_ecount(num_decls) Z3_symbol const decl_names[],
|
||||
__in_ecount(num_decls) Z3_func_decl const decls[]
|
||||
);
|
||||
__in_ecount(num_decls) Z3_func_decl const decls[]);
|
||||
|
||||
/**
|
||||
\brief Similar to #Z3_parse_smtlib2_string, but reads the benchmark from a file.
|
||||
|
@ -4917,13 +4907,12 @@ END_MLAPI_EXCLUDE
|
|||
*/
|
||||
Z3_ast Z3_API Z3_parse_smtlib2_file(__in Z3_context c,
|
||||
__in Z3_string file_name,
|
||||
__in unsigned num_sorts,
|
||||
__in_ecount(num_sorts) Z3_symbol const sort_names[],
|
||||
__in_ecount(num_sorts) Z3_sort const sorts[],
|
||||
__in unsigned num_decls,
|
||||
__in_ecount(num_decls) Z3_symbol const decl_names[],
|
||||
__in_ecount(num_decls) Z3_func_decl const decls[]
|
||||
);
|
||||
__in unsigned num_sorts,
|
||||
__in_ecount(num_sorts) Z3_symbol const sort_names[],
|
||||
__in_ecount(num_sorts) Z3_sort const sorts[],
|
||||
__in unsigned num_decls,
|
||||
__in_ecount(num_decls) Z3_symbol const decl_names[],
|
||||
__in_ecount(num_decls) Z3_func_decl const decls[]);
|
||||
|
||||
#ifdef ML4only
|
||||
#include <mlx_parse_smtlib.idl>
|
||||
|
@ -6610,6 +6599,13 @@ END_MLAPI_EXCLUDE
|
|||
/**
|
||||
\brief Create a new (incremental) solver.
|
||||
|
||||
The function #Z3_solver_get_model retrieves a model if the
|
||||
assertions is satisfiable (i.e., the result is \c
|
||||
Z3_L_TRUE) and model construction is enabled.
|
||||
The function #Z3_solver_get_model can also be used even
|
||||
if the result is \c Z3_L_UNDEF, but the returned model
|
||||
is not guaranteed to satisfy quantified assertions.
|
||||
|
||||
def_API('Z3_mk_simple_solver', SOLVER, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_solver Z3_API Z3_mk_simple_solver(__in Z3_context c);
|
||||
|
@ -6747,8 +6743,11 @@ END_MLAPI_EXCLUDE
|
|||
\brief Check whether the assertions in a given solver are consistent or not.
|
||||
|
||||
The function #Z3_solver_get_model retrieves a model if the
|
||||
assertions are not unsatisfiable (i.e., the result is not \c
|
||||
Z3_L_FALSE) and model construction is enabled.
|
||||
assertions is satisfiable (i.e., the result is \c
|
||||
Z3_L_TRUE) and model construction is enabled.
|
||||
Note that if the call returns Z3_L_UNDEF, Z3 does not
|
||||
ensure that calls to #Z3_solver_get_model succeed and any models
|
||||
produced in this case are not guaranteed to satisfy the assertions.
|
||||
|
||||
The function #Z3_solver_get_proof retrieves a proof if proof
|
||||
generation was enabled when the context was created, and the
|
||||
|
@ -7059,7 +7058,7 @@ END_MLAPI_EXCLUDE
|
|||
\mlonly then a valid model is returned. Otherwise, it is unsafe to use the returned model.\endmlonly
|
||||
\conly The caller is responsible for deleting the model using the function #Z3_del_model.
|
||||
|
||||
\conly \remark In constrast with the rest of the Z3 API, the reference counter of the
|
||||
\conly \remark In contrast with the rest of the Z3 API, the reference counter of the
|
||||
\conly model is incremented. This is to guarantee backward compatibility. In previous
|
||||
\conly versions, models did not support reference counting.
|
||||
|
||||
|
@ -7172,6 +7171,11 @@ END_MLAPI_EXCLUDE
|
|||
\brief Delete a model object.
|
||||
|
||||
\sa Z3_check_and_get_model
|
||||
|
||||
\conly \remark The Z3_check_and_get_model automatically increments a reference count on the model.
|
||||
\conly The expected usage is that models created by that method are deleted using Z3_del_model.
|
||||
\conly This is for backwards compatibility and in contrast to the rest of the API where
|
||||
\conly callers are responsible for managing reference counts.
|
||||
|
||||
\deprecated Subsumed by Z3_solver API
|
||||
|
||||
|
@ -7675,314 +7679,6 @@ END_MLAPI_EXCLUDE
|
|||
Z3_ast Z3_API Z3_get_context_assignment(__in Z3_context c);
|
||||
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
@name Interpolation
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/** \brief This function generates a Z3 context suitable for generation of
|
||||
interpolants. Formulas can be generated as abstract syntx trees in
|
||||
this context using the Z3 C API.
|
||||
|
||||
Interpolants are also generated as AST's in this context.
|
||||
|
||||
If cfg is non-null, it will be used as the base configuration
|
||||
for the Z3 context. This makes it possible to set Z3 options
|
||||
to be used during interpolation. This feature should be used
|
||||
with some caution however, as it may be that certain Z3 options
|
||||
are incompatible with interpolation.
|
||||
|
||||
def_API('Z3_mk_interpolation_context', CONTEXT, (_in(CONFIG),))
|
||||
|
||||
*/
|
||||
|
||||
Z3_context Z3_API Z3_mk_interpolation_context(__in Z3_config cfg);
|
||||
|
||||
/** Compute an interpolant from a refutation. This takes a proof of
|
||||
"false" from a set of formulas C, and an interpolation
|
||||
pattern. The pattern pat is a formula combining the formulas in C
|
||||
using logical conjunction and the "interp" operator (see
|
||||
#Z3_mk_interp). This interp operator is logically the identity
|
||||
operator. It marks the sub-formulas of the pattern for which interpolants should
|
||||
be computed. The interpolant is a map sigma from marked subformulas to
|
||||
formulas, such that, for each marked subformula phi of pat (where phi sigma
|
||||
is phi with sigma(psi) substituted for each subformula psi of phi such that
|
||||
psi in dom(sigma)):
|
||||
|
||||
1) phi sigma implies sigma(phi), and
|
||||
|
||||
2) sigma(phi) is in the common uninterpreted vocabulary between
|
||||
the formulas of C occurring in phi and those not occurring in
|
||||
phi
|
||||
|
||||
and moreover pat sigma implies false. In the simplest case
|
||||
an interpolant for the pattern "(and (interp A) B)" maps A
|
||||
to an interpolant for A /\ B.
|
||||
|
||||
The return value is a vector of formulas representing sigma. The
|
||||
vector contains sigma(phi) for each marked subformula of pat, in
|
||||
pre-order traversal. This means that subformulas of phi occur before phi
|
||||
in the vector. Also, subformulas that occur multiply in pat will
|
||||
occur multiply in the result vector.
|
||||
|
||||
In particular, calling Z3_get_interpolant on a pattern of the
|
||||
form (interp ... (interp (and (interp A_1) A_2)) ... A_N) will
|
||||
result in a sequence interpolant for A_1, A_2,... A_N.
|
||||
|
||||
Neglecting interp markers, the pattern must be a conjunction of
|
||||
formulas in C, the set of premises of the proof. Otherwise an
|
||||
error is flagged.
|
||||
|
||||
Any premises of the proof not present in the pattern are
|
||||
treated as "background theory". Predicate and function symbols
|
||||
occurring in the background theory are treated as interpreted and
|
||||
thus always allowed in the interpolant.
|
||||
|
||||
Interpolant may not necessarily be computable from all
|
||||
proofs. To be sure an interpolant can be computed, the proof
|
||||
must be generated by an SMT solver for which interpoaltion is
|
||||
supported, and the premises must be expressed using only
|
||||
theories and operators for which interpolation is supported.
|
||||
|
||||
Currently, the only SMT solver that is supported is the legacy
|
||||
SMT solver. Such a solver is available as the default solver in
|
||||
#Z3_context objects produced by #Z3_mk_interpolation_context.
|
||||
Currently, the theories supported are equality with
|
||||
uninterpreted functions, linear integer arithmetic, and the
|
||||
theory of arrays (in SMT-LIB terms, this is AUFLIA).
|
||||
Quantifiers are allowed. Use of any other operators (including
|
||||
"labels") may result in failure to compute an interpolant from a
|
||||
proof.
|
||||
|
||||
Parameters:
|
||||
|
||||
\param c logical context.
|
||||
\param pf a refutation from premises (assertions) C
|
||||
\param pat an interpolation pattern over C
|
||||
\param p parameters
|
||||
|
||||
def_API('Z3_get_interpolant', AST_VECTOR, (_in(CONTEXT), _in(AST), _in(AST), _in(PARAMS)))
|
||||
*/
|
||||
|
||||
Z3_ast_vector Z3_API Z3_get_interpolant(__in Z3_context c, __in Z3_ast pf, __in Z3_ast pat, __in Z3_params p);
|
||||
|
||||
/* Compute an interpolant for an unsatisfiable conjunction of formulas.
|
||||
|
||||
This takes as an argument an interpolation pattern as in
|
||||
#Z3_get_interpolant. This is a conjunction, some subformulas of
|
||||
which are marked with the "interp" operator (see #Z3_mk_interp).
|
||||
|
||||
The conjunction is first checked for unsatisfiability. The result
|
||||
of this check is returned in the out parameter "status". If the result
|
||||
is unsat, an interpolant is computed from the refutation as in #Z3_get_interpolant
|
||||
and returned as a vector of formulas. Otherwise the return value is
|
||||
an empty formula.
|
||||
|
||||
See #Z3_get_interpolant for a discussion of supported theories.
|
||||
|
||||
The advantage of this function over #Z3_get_interpolant is that
|
||||
it is not necessary to create a suitable SMT solver and generate
|
||||
a proof. The disadvantage is that it is not possible to use the
|
||||
solver incrementally.
|
||||
|
||||
Parameters:
|
||||
|
||||
\param c logical context.
|
||||
\param pat an interpolation pattern
|
||||
\param p parameters for solver creation
|
||||
\param status returns the status of the sat check
|
||||
\param model returns model if satisfiable
|
||||
|
||||
Return value: status of SAT check
|
||||
|
||||
def_API('Z3_compute_interpolant', INT, (_in(CONTEXT), _in(AST), _in(PARAMS), _out(AST_VECTOR), _out(MODEL)))
|
||||
*/
|
||||
|
||||
Z3_lbool Z3_API Z3_compute_interpolant(__in Z3_context c, __in Z3_ast pat, __in Z3_params p, __out Z3_ast_vector *interp, __out Z3_model *model);
|
||||
|
||||
|
||||
/** Constant reprepresenting a root of a formula tree for tree interpolation */
|
||||
#define IZ3_ROOT SHRT_MAX
|
||||
|
||||
/** This function uses Z3 to determine satisfiability of a set of
|
||||
constraints. If UNSAT, an interpolant is returned, based on the
|
||||
refutation generated by Z3. If SAT, a model is returned.
|
||||
|
||||
If "parents" is non-null, computes a tree interpolant. The tree is
|
||||
defined by the array "parents". This array maps each formula in
|
||||
the tree to its parent, where formulas are indicated by their
|
||||
integer index in "cnsts". The parent of formula n must have index
|
||||
greater than n. The last formula is the root of the tree. Its
|
||||
parent entry should be the constant IZ3_ROOT.
|
||||
|
||||
If "parents" is null, computes a sequence interpolant.
|
||||
|
||||
\param ctx The Z3 context. Must be generated by iz3_mk_context
|
||||
\param num The number of constraints in the sequence
|
||||
\param cnsts Array of constraints (AST's in context ctx)
|
||||
\param parents The parents vector defining the tree structure
|
||||
\param options Interpolation options (may be NULL)
|
||||
\param interps Array to return interpolants (size at least num-1, may be NULL)
|
||||
\param model Returns a Z3 model if constraints SAT (may be NULL)
|
||||
\param labels Returns relevant labels if SAT (may be NULL)
|
||||
\param incremental
|
||||
|
||||
VERY IMPORTANT: All the Z3 formulas in cnsts must be in Z3
|
||||
context ctx. The model and interpolants returned are also
|
||||
in this context.
|
||||
|
||||
The return code is as in Z3_check_assumptions, that is,
|
||||
|
||||
Z3_L_FALSE = constraints UNSAT (interpolants returned)
|
||||
Z3_L_TRUE = constraints SAT (model returned)
|
||||
Z3_L_UNDEF = Z3 produced no result, or interpolation not possible
|
||||
|
||||
Currently, this function supports integer and boolean variables,
|
||||
as well as arrays over these types, with linear arithmetic,
|
||||
uninterpreted functions and quantifiers over integers (that is
|
||||
AUFLIA). Interpolants are produced in AUFLIA. However, some
|
||||
uses of array operations may cause quantifiers to appear in the
|
||||
interpolants even when there are no quantifiers in the input formulas.
|
||||
Although quantifiers may appear in the input formulas, Z3 may give up in
|
||||
this case, returning Z3_L_UNDEF.
|
||||
|
||||
If "incremental" is true, cnsts must contain exactly the set of
|
||||
formulas that are currently asserted in the context. If false,
|
||||
there must be no formulas currently asserted in the context.
|
||||
Setting "incremental" to true makes it posisble to incrementally
|
||||
add and remove constraints from the context until the context
|
||||
becomes UNSAT, at which point an interpolant is computed. Caution
|
||||
must be used, however. Before popping the context, if you wish to
|
||||
keep the interolant formulas, you *must* preserve them by using
|
||||
Z3_persist_ast. Also, if you want to simplify the interpolant
|
||||
formulas using Z3_simplify, you must first pop all of the
|
||||
assertions in the context (or use a different context). Otherwise,
|
||||
the formulas will be simplified *relative* to these constraints,
|
||||
which is almost certainly not what you want.
|
||||
|
||||
|
||||
Current limitations on tree interpolants. In a tree interpolation
|
||||
problem, each constant (0-ary function symbol) must occur only
|
||||
along one path from root to leaf. Function symbols (of arity > 0)
|
||||
are considered to have global scope (i.e., may appear in any
|
||||
interpolant formula).
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
Z3_lbool Z3_API Z3_interpolate(__in Z3_context ctx,
|
||||
__in int num,
|
||||
__in_ecount(num) Z3_ast *cnsts,
|
||||
__in_ecount(num) unsigned *parents,
|
||||
__in Z3_params options,
|
||||
__out_ecount(num-1) Z3_ast *interps,
|
||||
__out Z3_model *model,
|
||||
__out Z3_literals *labels,
|
||||
__in int incremental,
|
||||
__in int num_theory,
|
||||
__in_ecount(num_theory) Z3_ast *theory);
|
||||
|
||||
/** Return a string summarizing cumulative time used for
|
||||
interpolation. This string is purely for entertainment purposes
|
||||
and has no semantics.
|
||||
|
||||
\param ctx The context (currently ignored)
|
||||
|
||||
def_API('Z3_interpolation_profile', STRING, (_in(CONTEXT),))
|
||||
*/
|
||||
|
||||
Z3_string Z3_API Z3_interpolation_profile(__in Z3_context ctx);
|
||||
|
||||
/**
|
||||
\brief Read an interpolation problem from file.
|
||||
|
||||
\param ctx The Z3 context. This resets the error handler of ctx.
|
||||
\param filename The file name to read.
|
||||
\param num Returns length of sequence.
|
||||
\param cnsts Returns sequence of formulas (do not free)
|
||||
\param parents Returns the parents vector (or NULL for sequence)
|
||||
\param error Returns an error message in case of failure (do not free the string)
|
||||
|
||||
Returns true on success.
|
||||
|
||||
File formats: Currently two formats are supported, based on
|
||||
SMT-LIB2. For sequence interpolants, the sequence of constraints is
|
||||
represented by the sequence of "assert" commands in the file.
|
||||
|
||||
For tree interpolants, one symbol of type bool is associated to
|
||||
each vertex of the tree. For each vertex v there is an "assert"
|
||||
of the form:
|
||||
|
||||
(implies (and c1 ... cn f) v)
|
||||
|
||||
where c1 .. cn are the children of v (which must precede v in the file)
|
||||
and f is the formula assiciated to node v. The last formula in the
|
||||
file is the root vertex, and is represented by the predicate "false".
|
||||
|
||||
A solution to a tree interpolation problem can be thought of as a
|
||||
valuation of the vertices that makes all the implications true
|
||||
where each value is represented using the common symbols between
|
||||
the formulas in the subtree and the remainder of the formulas.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
int Z3_API Z3_read_interpolation_problem(__in Z3_context ctx,
|
||||
__out int *num,
|
||||
__out_ecount(*num) Z3_ast **cnsts,
|
||||
__out_ecount(*num) int **parents,
|
||||
__in const char *filename,
|
||||
__out const char **error,
|
||||
__out int *num_theory,
|
||||
__out_ecount(*num_theory) Z3_ast **theory);
|
||||
|
||||
|
||||
|
||||
/** Check the correctness of an interpolant. The Z3 context must
|
||||
have no constraints asserted when this call is made. That means
|
||||
that after interpolating, you must first fully pop the Z3
|
||||
context before calling this. See Z3_interpolate for meaning of parameters.
|
||||
|
||||
\param ctx The Z3 context. Must be generated by Z3_mk_interpolation_context
|
||||
\param num The number of constraints in the sequence
|
||||
\param cnsts Array of constraints (AST's in context ctx)
|
||||
\param parents The parents vector (or NULL for sequence)
|
||||
\param interps The interpolant to check
|
||||
\param error Returns an error message if interpolant incorrect (do not free the string)
|
||||
|
||||
Return value is Z3_L_TRUE if interpolant is verified, Z3_L_FALSE if
|
||||
incorrect, and Z3_L_UNDEF if unknown.
|
||||
|
||||
*/
|
||||
|
||||
int Z3_API Z3_check_interpolant(Z3_context ctx, int num, Z3_ast *cnsts, int *parents, Z3_ast *interps, const char **error,
|
||||
int num_theory, Z3_ast *theory);
|
||||
|
||||
/** Write an interpolation problem to file suitable for reading with
|
||||
Z3_read_interpolation_problem. The output file is a sequence
|
||||
of SMT-LIB2 format commands, suitable for reading with command-line Z3
|
||||
or other interpolating solvers.
|
||||
|
||||
\param ctx The Z3 context. Must be generated by z3_mk_interpolation_context
|
||||
\param num The number of constraints in the sequence
|
||||
\param cnsts Array of constraints
|
||||
\param parents The parents vector (or NULL for sequence)
|
||||
\param filename The file name to write
|
||||
|
||||
*/
|
||||
|
||||
void Z3_API Z3_write_interpolation_problem(Z3_context ctx,
|
||||
int num,
|
||||
Z3_ast *cnsts,
|
||||
int *parents,
|
||||
const char *filename,
|
||||
int num_theory,
|
||||
Z3_ast *theory);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
277
src/api/z3_interp.h
Normal file
277
src/api/z3_interp.h
Normal file
|
@ -0,0 +1,277 @@
|
|||
/*++
|
||||
Copyright (c) 2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
z3_interp.h
|
||||
|
||||
Abstract:
|
||||
|
||||
API for interpolation
|
||||
|
||||
Author:
|
||||
|
||||
Kenneth McMillan (kenmcmil)
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef _Z3_INTERPOLATION_H_
|
||||
#define _Z3_INTERPOLATION_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
/**
|
||||
@name Interpolation
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
\brief \mlh mk_interp c a \endmlh
|
||||
Create an AST node marking a formula position for interpolation.
|
||||
|
||||
The node \c a must have Boolean sort.
|
||||
|
||||
def_API('Z3_mk_interpolant', AST, (_in(CONTEXT), _in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_interpolant(__in Z3_context c, __in Z3_ast a);
|
||||
|
||||
|
||||
/** \brief This function generates a Z3 context suitable for generation of
|
||||
interpolants. Formulas can be generated as abstract syntax trees in
|
||||
this context using the Z3 C API.
|
||||
|
||||
Interpolants are also generated as AST's in this context.
|
||||
|
||||
If cfg is non-null, it will be used as the base configuration
|
||||
for the Z3 context. This makes it possible to set Z3 options
|
||||
to be used during interpolation. This feature should be used
|
||||
with some caution however, as it may be that certain Z3 options
|
||||
are incompatible with interpolation.
|
||||
|
||||
def_API('Z3_mk_interpolation_context', CONTEXT, (_in(CONFIG),))
|
||||
|
||||
*/
|
||||
|
||||
Z3_context Z3_API Z3_mk_interpolation_context(__in Z3_config cfg);
|
||||
|
||||
/** Compute an interpolant from a refutation. This takes a proof of
|
||||
"false" from a set of formulas C, and an interpolation
|
||||
pattern. The pattern pat is a formula combining the formulas in C
|
||||
using logical conjunction and the "interp" operator (see
|
||||
#Z3_mk_interpolant). This interp operator is logically the identity
|
||||
operator. It marks the sub-formulas of the pattern for which interpolants should
|
||||
be computed. The interpolant is a map sigma from marked subformulas to
|
||||
formulas, such that, for each marked subformula phi of pat (where phi sigma
|
||||
is phi with sigma(psi) substituted for each subformula psi of phi such that
|
||||
psi in dom(sigma)):
|
||||
|
||||
1) phi sigma implies sigma(phi), and
|
||||
|
||||
2) sigma(phi) is in the common uninterpreted vocabulary between
|
||||
the formulas of C occurring in phi and those not occurring in
|
||||
phi
|
||||
|
||||
and moreover pat sigma implies false. In the simplest case
|
||||
an interpolant for the pattern "(and (interp A) B)" maps A
|
||||
to an interpolant for A /\ B.
|
||||
|
||||
The return value is a vector of formulas representing sigma. The
|
||||
vector contains sigma(phi) for each marked subformula of pat, in
|
||||
pre-order traversal. This means that subformulas of phi occur before phi
|
||||
in the vector. Also, subformulas that occur multiply in pat will
|
||||
occur multiply in the result vector.
|
||||
|
||||
In particular, calling Z3_get_interpolant on a pattern of the
|
||||
form (interp ... (interp (and (interp A_1) A_2)) ... A_N) will
|
||||
result in a sequence interpolant for A_1, A_2,... A_N.
|
||||
|
||||
Neglecting interp markers, the pattern must be a conjunction of
|
||||
formulas in C, the set of premises of the proof. Otherwise an
|
||||
error is flagged.
|
||||
|
||||
Any premises of the proof not present in the pattern are
|
||||
treated as "background theory". Predicate and function symbols
|
||||
occurring in the background theory are treated as interpreted and
|
||||
thus always allowed in the interpolant.
|
||||
|
||||
Interpolant may not necessarily be computable from all
|
||||
proofs. To be sure an interpolant can be computed, the proof
|
||||
must be generated by an SMT solver for which interpoaltion is
|
||||
supported, and the premises must be expressed using only
|
||||
theories and operators for which interpolation is supported.
|
||||
|
||||
Currently, the only SMT solver that is supported is the legacy
|
||||
SMT solver. Such a solver is available as the default solver in
|
||||
#Z3_context objects produced by #Z3_mk_interpolation_context.
|
||||
Currently, the theories supported are equality with
|
||||
uninterpreted functions, linear integer arithmetic, and the
|
||||
theory of arrays (in SMT-LIB terms, this is AUFLIA).
|
||||
Quantifiers are allowed. Use of any other operators (including
|
||||
"labels") may result in failure to compute an interpolant from a
|
||||
proof.
|
||||
|
||||
Parameters:
|
||||
|
||||
\param c logical context.
|
||||
\param pf a refutation from premises (assertions) C
|
||||
\param pat an interpolation pattern over C
|
||||
\param p parameters
|
||||
|
||||
def_API('Z3_get_interpolant', AST_VECTOR, (_in(CONTEXT), _in(AST), _in(AST), _in(PARAMS)))
|
||||
*/
|
||||
|
||||
Z3_ast_vector Z3_API Z3_get_interpolant(__in Z3_context c, __in Z3_ast pf, __in Z3_ast pat, __in Z3_params p);
|
||||
|
||||
/* Compute an interpolant for an unsatisfiable conjunction of formulas.
|
||||
|
||||
This takes as an argument an interpolation pattern as in
|
||||
#Z3_get_interpolant. This is a conjunction, some subformulas of
|
||||
which are marked with the "interp" operator (see #Z3_mk_interpolant).
|
||||
|
||||
The conjunction is first checked for unsatisfiability. The result
|
||||
of this check is returned in the out parameter "status". If the result
|
||||
is unsat, an interpolant is computed from the refutation as in #Z3_get_interpolant
|
||||
and returned as a vector of formulas. Otherwise the return value is
|
||||
an empty formula.
|
||||
|
||||
See #Z3_get_interpolant for a discussion of supported theories.
|
||||
|
||||
The advantage of this function over #Z3_get_interpolant is that
|
||||
it is not necessary to create a suitable SMT solver and generate
|
||||
a proof. The disadvantage is that it is not possible to use the
|
||||
solver incrementally.
|
||||
|
||||
Parameters:
|
||||
|
||||
\param c logical context.
|
||||
\param pat an interpolation pattern
|
||||
\param p parameters for solver creation
|
||||
\param status returns the status of the sat check
|
||||
\param model returns model if satisfiable
|
||||
|
||||
Return value: status of SAT check
|
||||
|
||||
def_API('Z3_compute_interpolant', INT, (_in(CONTEXT), _in(AST), _in(PARAMS), _out(AST_VECTOR), _out(MODEL)))
|
||||
*/
|
||||
|
||||
Z3_lbool Z3_API Z3_compute_interpolant(__in Z3_context c,
|
||||
__in Z3_ast pat,
|
||||
__in Z3_params p,
|
||||
__out Z3_ast_vector *interp,
|
||||
__out Z3_model *model);
|
||||
|
||||
/** Return a string summarizing cumulative time used for
|
||||
interpolation. This string is purely for entertainment purposes
|
||||
and has no semantics.
|
||||
|
||||
\param ctx The context (currently ignored)
|
||||
|
||||
|
||||
def_API('Z3_interpolation_profile', STRING, (_in(CONTEXT),))
|
||||
*/
|
||||
|
||||
Z3_string Z3_API Z3_interpolation_profile(__in Z3_context ctx);
|
||||
|
||||
/**
|
||||
\brief Read an interpolation problem from file.
|
||||
|
||||
\param ctx The Z3 context. This resets the error handler of ctx.
|
||||
\param filename The file name to read.
|
||||
\param num Returns length of sequence.
|
||||
\param cnsts Returns sequence of formulas (do not free)
|
||||
\param parents Returns the parents vector (or NULL for sequence)
|
||||
\param error Returns an error message in case of failure (do not free the string)
|
||||
|
||||
Returns true on success.
|
||||
|
||||
File formats: Currently two formats are supported, based on
|
||||
SMT-LIB2. For sequence interpolants, the sequence of constraints is
|
||||
represented by the sequence of "assert" commands in the file.
|
||||
|
||||
For tree interpolants, one symbol of type bool is associated to
|
||||
each vertex of the tree. For each vertex v there is an "assert"
|
||||
of the form:
|
||||
|
||||
(implies (and c1 ... cn f) v)
|
||||
|
||||
where c1 .. cn are the children of v (which must precede v in the file)
|
||||
and f is the formula assiciated to node v. The last formula in the
|
||||
file is the root vertex, and is represented by the predicate "false".
|
||||
|
||||
A solution to a tree interpolation problem can be thought of as a
|
||||
valuation of the vertices that makes all the implications true
|
||||
where each value is represented using the common symbols between
|
||||
the formulas in the subtree and the remainder of the formulas.
|
||||
|
||||
def_API('Z3_read_interpolation_problem', INT, (_in(CONTEXT), _out(UINT), _out_managed_array(1, AST), _out_managed_array(1, UINT), _in(STRING), _out(STRING), _out(UINT), _out_managed_array(6, AST)))
|
||||
|
||||
*/
|
||||
|
||||
int Z3_API Z3_read_interpolation_problem(__in Z3_context ctx,
|
||||
__out unsigned *num,
|
||||
__out Z3_ast *cnsts[],
|
||||
__out unsigned *parents[],
|
||||
__in Z3_string filename,
|
||||
__out_opt Z3_string_ptr error,
|
||||
__out unsigned *num_theory,
|
||||
__out Z3_ast *theory[]);
|
||||
|
||||
|
||||
|
||||
/** Check the correctness of an interpolant. The Z3 context must
|
||||
have no constraints asserted when this call is made. That means
|
||||
that after interpolating, you must first fully pop the Z3
|
||||
context before calling this. See Z3_interpolate for meaning of parameters.
|
||||
|
||||
\param ctx The Z3 context. Must be generated by Z3_mk_interpolation_context
|
||||
\param num The number of constraints in the sequence
|
||||
\param cnsts Array of constraints (AST's in context ctx)
|
||||
\param parents The parents vector (or NULL for sequence)
|
||||
\param interps The interpolant to check
|
||||
\param error Returns an error message if interpolant incorrect (do not free the string)
|
||||
|
||||
Return value is Z3_L_TRUE if interpolant is verified, Z3_L_FALSE if
|
||||
incorrect, and Z3_L_UNDEF if unknown.
|
||||
|
||||
def_API('Z3_check_interpolant', INT, (_in(CONTEXT), _in(UINT), _in_array(1, AST), _in_array(1, UINT), _in_array(1, AST), _out(STRING), _in(UINT), _in_array(6, AST)))
|
||||
*/
|
||||
|
||||
int Z3_API Z3_check_interpolant(__in Z3_context ctx,
|
||||
__in unsigned num,
|
||||
__in_ecount(num) Z3_ast cnsts[],
|
||||
__in_ecount(num) unsigned parents[],
|
||||
__in_ecount(num - 1) Z3_ast *interps,
|
||||
__out_opt Z3_string_ptr error,
|
||||
__in unsigned num_theory,
|
||||
__in_ecount(num_theory) Z3_ast theory[]);
|
||||
|
||||
/** Write an interpolation problem to file suitable for reading with
|
||||
Z3_read_interpolation_problem. The output file is a sequence
|
||||
of SMT-LIB2 format commands, suitable for reading with command-line Z3
|
||||
or other interpolating solvers.
|
||||
|
||||
\param ctx The Z3 context. Must be generated by z3_mk_interpolation_context
|
||||
\param num The number of constraints in the sequence
|
||||
\param cnsts Array of constraints
|
||||
\param parents The parents vector (or NULL for sequence)
|
||||
\param filename The file name to write
|
||||
|
||||
def_API('Z3_write_interpolation_problem', VOID, (_in(CONTEXT), _in(UINT), _in_array(1, AST), _in_array(1, UINT), _in(STRING), _in(UINT), _in_array(5, AST)))
|
||||
*/
|
||||
|
||||
void Z3_API Z3_write_interpolation_problem(__in Z3_context ctx,
|
||||
__in unsigned num,
|
||||
__in_ecount(num) Z3_ast cnsts[],
|
||||
__in_ecount(num) unsigned parents[],
|
||||
__in Z3_string filename,
|
||||
__in unsigned num_theory,
|
||||
__in_ecount(num_theory) Z3_ast theory[]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
|
@ -314,8 +314,8 @@ func_decl * float_decl_plugin::mk_binary_decl(decl_kind k, unsigned num_paramete
|
|||
symbol name;
|
||||
switch (k) {
|
||||
case OP_FLOAT_REM: name = "remainder"; break;
|
||||
case OP_FLOAT_MIN: name = "min"; break;
|
||||
case OP_FLOAT_MAX: name = "max"; break;
|
||||
case OP_FLOAT_MIN: name = "fp.min"; break;
|
||||
case OP_FLOAT_MAX: name = "fp.max"; break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
|
@ -581,8 +581,9 @@ void float_decl_plugin::get_op_names(svector<builtin_name> & op_names, symbol co
|
|||
op_names.push_back(builtin_name("isSubnormal", OP_FLOAT_IS_SUBNORMAL));
|
||||
op_names.push_back(builtin_name("isSignMinus", OP_FLOAT_IS_SIGN_MINUS));
|
||||
|
||||
op_names.push_back(builtin_name("min", OP_FLOAT_MIN));
|
||||
op_names.push_back(builtin_name("max", OP_FLOAT_MAX));
|
||||
// Disabled min/max, clashes with user-defined min/max functions
|
||||
// op_names.push_back(builtin_name("min", OP_FLOAT_MIN));
|
||||
// op_names.push_back(builtin_name("max", OP_FLOAT_MAX));
|
||||
|
||||
op_names.push_back(builtin_name("asFloat", OP_TO_FLOAT));
|
||||
|
||||
|
|
|
@ -911,18 +911,34 @@ void bit_blaster_tpl<Cfg>::mk_shl(unsigned sz, expr * const * a_bits, expr * con
|
|||
out_bits.push_back(a_bits[i]);
|
||||
}
|
||||
else {
|
||||
expr_ref_vector eqs(m());
|
||||
mk_eqs(sz, b_bits, eqs);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
out_bits.append(sz, a_bits);
|
||||
|
||||
unsigned i = 0;
|
||||
expr_ref_vector new_out_bits(m());
|
||||
for (; i < sz; ++i) {
|
||||
checkpoint();
|
||||
expr_ref out(m());
|
||||
mk_ite(eqs.get(i), a_bits[0], m().mk_false(), out);
|
||||
for (unsigned j = 1; j <= i; j++) {
|
||||
unsigned shift_i = 1 << i;
|
||||
if (shift_i >= sz) break;
|
||||
for (unsigned j = 0; j < sz; ++j) {
|
||||
expr_ref new_out(m());
|
||||
mk_ite(eqs.get(i - j), a_bits[j], out, new_out);
|
||||
out = new_out;
|
||||
expr* a_j = m().mk_false();
|
||||
if (shift_i <= j) a_j = out_bits[j-shift_i].get();
|
||||
mk_ite(b_bits[i], a_j, out_bits[j].get(), new_out);
|
||||
new_out_bits.push_back(new_out);
|
||||
}
|
||||
out_bits.push_back(out);
|
||||
out_bits.reset();
|
||||
out_bits.append(new_out_bits);
|
||||
new_out_bits.reset();
|
||||
}
|
||||
expr_ref is_large(m());
|
||||
is_large = m().mk_false();
|
||||
for (; i < sz; ++i) {
|
||||
mk_or(is_large, b_bits[i], is_large);
|
||||
}
|
||||
for (unsigned j = 0; j < sz; ++j) {
|
||||
expr_ref new_out(m());
|
||||
mk_ite(is_large, m().mk_false(), out_bits[j].get(), new_out);
|
||||
out_bits[j] = new_out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -939,19 +955,32 @@ void bit_blaster_tpl<Cfg>::mk_lshr(unsigned sz, expr * const * a_bits, expr * co
|
|||
out_bits.push_back(m().mk_false());
|
||||
}
|
||||
else {
|
||||
expr_ref_vector eqs(m());
|
||||
mk_eqs(sz, b_bits, eqs);
|
||||
out_bits.resize(sz);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
out_bits.append(sz, a_bits);
|
||||
unsigned i = 0;
|
||||
for (; i < sz; ++i) {
|
||||
checkpoint();
|
||||
expr_ref out(m());
|
||||
mk_ite(eqs.get(i), a_bits[sz-1], m().mk_false(), out);
|
||||
for (unsigned j = 1; j <= i; j++) {
|
||||
expr_ref_vector new_out_bits(m());
|
||||
unsigned shift_i = 1 << i;
|
||||
if (shift_i >= sz) break;
|
||||
for (unsigned j = 0; j < sz; ++j) {
|
||||
expr_ref new_out(m());
|
||||
mk_ite(eqs.get(i - j), a_bits[sz - j - 1], out, new_out);
|
||||
out = new_out;
|
||||
expr* a_j = m().mk_false();
|
||||
if (shift_i + j < sz) a_j = out_bits[j+shift_i].get();
|
||||
mk_ite(b_bits[i], a_j, out_bits[j].get(), new_out);
|
||||
new_out_bits.push_back(new_out);
|
||||
}
|
||||
out_bits.set(sz - i - 1, out);
|
||||
out_bits.reset();
|
||||
out_bits.append(new_out_bits);
|
||||
}
|
||||
expr_ref is_large(m());
|
||||
is_large = m().mk_false();
|
||||
for (; i < sz; ++i) {
|
||||
mk_or(is_large, b_bits[i], is_large);
|
||||
}
|
||||
for (unsigned j = 0; j < sz; ++j) {
|
||||
expr_ref new_out(m());
|
||||
mk_ite(is_large, m().mk_false(), out_bits[j].get(), new_out);
|
||||
out_bits[j] = new_out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -968,20 +997,32 @@ void bit_blaster_tpl<Cfg>::mk_ashr(unsigned sz, expr * const * a_bits, expr * co
|
|||
out_bits.push_back(a_bits[sz-1]);
|
||||
}
|
||||
else {
|
||||
expr_ref_vector eqs(m());
|
||||
mk_eqs(sz, b_bits, eqs);
|
||||
out_bits.resize(sz);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
out_bits.append(sz, a_bits);
|
||||
unsigned i = 0;
|
||||
for (; i < sz; ++i) {
|
||||
checkpoint();
|
||||
expr_ref out(m());
|
||||
out = a_bits[sz-1];
|
||||
for (unsigned j = 1; j <= i; j++) {
|
||||
expr_ref_vector new_out_bits(m());
|
||||
unsigned shift_i = 1 << i;
|
||||
if (shift_i >= sz) break;
|
||||
for (unsigned j = 0; j < sz; ++j) {
|
||||
expr_ref new_out(m());
|
||||
mk_ite(eqs.get(i - j), a_bits[sz - j - 1], out, new_out);
|
||||
out = new_out;
|
||||
expr* a_j = a_bits[sz-1];
|
||||
if (shift_i + j < sz) a_j = out_bits[j+shift_i].get();
|
||||
mk_ite(b_bits[i], a_j, out_bits[j].get(), new_out);
|
||||
new_out_bits.push_back(new_out);
|
||||
}
|
||||
TRACE("bit_blaster", tout << (sz - i - 1) << " :\n" << mk_pp(out, m()) << "\n";);
|
||||
out_bits.set(sz - i - 1, out);
|
||||
out_bits.reset();
|
||||
out_bits.append(new_out_bits);
|
||||
}
|
||||
expr_ref is_large(m());
|
||||
is_large = m().mk_false();
|
||||
for (; i < sz; ++i) {
|
||||
mk_or(is_large, b_bits[i], is_large);
|
||||
}
|
||||
for (unsigned j = 0; j < sz; ++j) {
|
||||
expr_ref new_out(m());
|
||||
mk_ite(is_large, a_bits[sz-1], out_bits[j].get(), new_out);
|
||||
out_bits[j] = new_out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue