mirror of
https://github.com/Z3Prover/z3
synced 2025-04-25 10:05:32 +00:00
Merge branch 'unstable' of https://git01.codeplex.com/z3 into bvsls
This commit is contained in:
commit
1f29b3e0a9
205 changed files with 4767 additions and 2541 deletions
|
@ -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
|
@ -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.
|
||||
|
@ -1286,6 +1314,26 @@ namespace z3 {
|
|||
expr_vector assertions() const { Z3_ast_vector r = Z3_solver_get_assertions(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
|
||||
expr proof() const { Z3_ast r = Z3_solver_get_proof(ctx(), m_solver); check_error(); return expr(ctx(), r); }
|
||||
friend std::ostream & operator<<(std::ostream & out, solver const & s) { out << Z3_solver_to_string(s.ctx(), s); return out; }
|
||||
|
||||
std::string to_smt2(char const* status = "unknown") {
|
||||
array<Z3_ast> es(assertions());
|
||||
Z3_ast const* fmls = es.ptr();
|
||||
Z3_ast fml = 0;
|
||||
unsigned sz = es.size();
|
||||
if (sz > 0) {
|
||||
--sz;
|
||||
fml = fmls[sz];
|
||||
}
|
||||
else {
|
||||
fml = ctx().bool_val(true);
|
||||
}
|
||||
return std::string(Z3_benchmark_to_smtlib_string(
|
||||
ctx(),
|
||||
"", "", status, "",
|
||||
sz,
|
||||
fmls,
|
||||
fml));
|
||||
}
|
||||
};
|
||||
|
||||
class goal : public object {
|
||||
|
@ -1404,22 +1452,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));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -254,7 +254,7 @@
|
|||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<OutputPath>..\x86\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>..\x86\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>
|
||||
|
|
|
@ -12,7 +12,7 @@ using System.Security.Permissions;
|
|||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft Corporation")]
|
||||
[assembly: AssemblyProduct("Z3")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft Corporation 2006")]
|
||||
[assembly: AssemblyCopyright("Copyright (C) 2006-2014 Microsoft Corporation")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
|
9
src/api/dotnet/Readme.NET35
Normal file
9
src/api/dotnet/Readme.NET35
Normal file
|
@ -0,0 +1,9 @@
|
|||
The default Z3 bindings for .NET are built for the .NET framework version 4.
|
||||
Should the need arise, it is also possible to build them for .NET 3.5; the
|
||||
instructions are as follows:
|
||||
|
||||
In the project properties of Microsoft.Z3.csproj:
|
||||
- Under 'Application': Change Target framework to .NET Framework 3.5
|
||||
- Under 'Build': Add FRAMEWORK_LT_4 to the condidional compilation symbols
|
||||
- Remove the reference to System.Numerics
|
||||
- Install the NuGet Package "Microsoft Code Contracts for Net3.5"
|
|
@ -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;
|
||||
|
||||
|
@ -13,28 +24,12 @@ import com.microsoft.z3.enumerations.Z3_ast_kind;
|
|||
**/
|
||||
public class AST extends Z3Object
|
||||
{
|
||||
/**
|
||||
* Comparison operator. <param name="a">An AST</param> <param name="b">An
|
||||
* AST</param>
|
||||
*
|
||||
* @return True if <paramref name="a"/> and <paramref name="b"/> are from
|
||||
* the same context and represent the same sort; false otherwise.
|
||||
**/
|
||||
/* Overloaded operators are not translated. */
|
||||
|
||||
/**
|
||||
* Comparison operator. <param name="a">An AST</param> <param name="b">An
|
||||
* AST</param>
|
||||
*
|
||||
* @return True if <paramref name="a"/> and <paramref name="b"/> are not
|
||||
* from the same context or represent different sorts; false
|
||||
* otherwise.
|
||||
**/
|
||||
/* Overloaded operators are not translated. */
|
||||
|
||||
/**
|
||||
* Object comparison.
|
||||
**/
|
||||
* <param name="o">another AST</param>
|
||||
**/
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
AST casted = null;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -29,7 +40,7 @@ public class Expr extends AST
|
|||
/**
|
||||
* Returns a simplified version of the expression
|
||||
* A set of
|
||||
* parameters <param name="p" /> to configure the simplifier
|
||||
* parameters <param name="p">a Params object</param> to configure the simplifier
|
||||
* <seealso cref="Context.SimplifyHelp"/>
|
||||
**/
|
||||
public Expr simplify(Params p) throws Z3Exception
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -38,8 +50,7 @@ public final class Global
|
|||
/**
|
||||
* Get a global (or module) parameter.
|
||||
* <remarks>
|
||||
* Returns null if the parameter <param name="id"/> does not exist.
|
||||
* The caller must invoke #Z3_global_param_del_value to delete the value returned at \c param_value.
|
||||
* Returns null if the parameter <param name="id">parameter id</param> does not exist.
|
||||
* This function cannot be invoked simultaneously from different threads without synchronization.
|
||||
* The result string stored in param_value is stored in a shared location.
|
||||
* </remarks>
|
||||
|
@ -58,7 +69,7 @@ public final class Global
|
|||
* <remarks>
|
||||
* This command will not affect already created objects (such as tactics and solvers)
|
||||
* </remarks>
|
||||
* @seealso SetParameter
|
||||
* <seealso cref="SetParameter"/>
|
||||
**/
|
||||
public static void resetParameters()
|
||||
{
|
||||
|
|
|
@ -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,3 +1,6 @@
|
|||
Java bindings
|
||||
-------------
|
||||
|
||||
The Java bindings will be included in the Z3 build if it is configured with
|
||||
the option --java to python scripts/mk_make.py. This will produce the
|
||||
com.microsoft.z3.jar package in the build directory.
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -14,27 +25,10 @@ import com.microsoft.z3.enumerations.Z3_sort_kind;
|
|||
**/
|
||||
public class Sort extends AST
|
||||
{
|
||||
/**
|
||||
* Comparison operator. <param name="a">A Sort</param> <param name="b">A
|
||||
* Sort</param>
|
||||
*
|
||||
* @return True if <paramref name="a"/> and <paramref name="b"/> are from
|
||||
* the same context and represent the same sort; false otherwise.
|
||||
**/
|
||||
/* Overloaded operators are not translated. */
|
||||
|
||||
/**
|
||||
* Comparison operator. <param name="a">A Sort</param> <param name="b">A
|
||||
* Sort</param>
|
||||
*
|
||||
* @return True if <paramref name="a"/> and <paramref name="b"/> are not
|
||||
* from the same context or represent different sorts; false
|
||||
* otherwise.
|
||||
**/
|
||||
/* Overloaded operators are not translated. */
|
||||
|
||||
/**
|
||||
* Equality operator for objects of type Sort. <param name="o"></param>
|
||||
* Equality operator for objects of type Sort. <param name="o"/>
|
||||
*
|
||||
* @return
|
||||
**/
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
Manifest-Version: 1.0
|
||||
Created-By: 4.3.0 (Microsoft Research LTD.)
|
||||
Created-By: 4.3.2 (Microsoft Research LTD.)
|
||||
|
|
|
@ -1,463 +0,0 @@
|
|||
######################################################
|
||||
# Copyright (c) 2012 Microsoft Corporation
|
||||
#
|
||||
# Auxiliary scripts for generating Java bindings
|
||||
# from the managed API.
|
||||
#
|
||||
# Author: Christoph M. Wintersteiger (cwinter)
|
||||
######################################################
|
||||
|
||||
|
||||
###
|
||||
# DO NOT USE THIS SCRIPT!
|
||||
# This script creates a rough draft of a Java API from
|
||||
# the managed API, but does not automated the process.
|
||||
###
|
||||
|
||||
CS="../dotnet/"
|
||||
EXT=".cs"
|
||||
EXCLUDE=["Enumerations.cs", "Native.cs", "AssemblyInfo.cs"]
|
||||
OUTDIR="com/Microsoft/Z3/"
|
||||
ENUMS_FILE = "Enumerations.cs"
|
||||
|
||||
import os
|
||||
import fileinput
|
||||
import string
|
||||
import re
|
||||
|
||||
EXCLUDE_METHODS = [ [ "Context.cs", "public Expr MkNumeral(ulong" ],
|
||||
[ "Context.cs", "public Expr MkNumeral(uint" ],
|
||||
[ "Context.cs", "public RatNum MkReal(ulong" ],
|
||||
[ "Context.cs", "public RatNum MkReal(uint" ],
|
||||
[ "Context.cs", "public IntNum MkInt(ulong" ],
|
||||
[ "Context.cs", "public IntNum MkInt(uint" ],
|
||||
[ "Context.cs", "public BitVecNum MkBV(ulong" ],
|
||||
[ "Context.cs", "public BitVecNum MkBV(uint" ],
|
||||
]
|
||||
|
||||
ENUMS = []
|
||||
|
||||
def mk_java_bindings():
|
||||
print "Generating Java bindings (from C# bindings in " + CS + ")..."
|
||||
print "Finding enumerations in " + ENUMS_FILE + "..."
|
||||
find_enums(ENUMS_FILE)
|
||||
for root, dirs, files in os.walk(CS):
|
||||
for fn in files:
|
||||
if not fn in EXCLUDE and fn.endswith(EXT):
|
||||
translate(fn)
|
||||
|
||||
def subst_getters(s, getters):
|
||||
for g in getters:
|
||||
s = s.replace(g, g + "()")
|
||||
|
||||
def type_replace(s):
|
||||
s = s.replace(" bool", " boolean")
|
||||
s = s.replace("(bool", "(boolean")
|
||||
s = s.replace("uint", "int")
|
||||
s = s.replace("ulong", "long")
|
||||
s = s.replace("string", "String")
|
||||
s = s.replace("IntPtr", "long")
|
||||
s = s.replace("Dictionary<", "Map<")
|
||||
s = s.replace("UInt64", "long")
|
||||
s = s.replace("Int64", "long")
|
||||
s = s.replace("List<long>", "LinkedList<Long>")
|
||||
s = s.replace("System.Exception", "Exception")
|
||||
return s
|
||||
|
||||
def rename_native(s):
|
||||
while s.find("Native.Z3") != -1:
|
||||
i0 = s.find("Native.Z3")
|
||||
i1 = s.find("(", i0)
|
||||
c0 = s[:i0]
|
||||
c1 = s[i0:i1]
|
||||
c1 = c1.replace("Native.Z3_", "Native.")
|
||||
c2 = s[i1:]
|
||||
lc_callback = lambda pat: pat.group("id").upper()
|
||||
c1 = re.sub("_(?P<id>\w)", lc_callback, c1)
|
||||
s = c0 + c1 + c2
|
||||
return s
|
||||
|
||||
def find_enums(fn):
|
||||
for line in fileinput.input(os.path.join(CS, fn)):
|
||||
s = string.rstrip(string.lstrip(line))
|
||||
if s.startswith("public enum"):
|
||||
ENUMS.append(s.split(" ")[2])
|
||||
|
||||
|
||||
def enum_replace(line):
|
||||
for e in ENUMS:
|
||||
if line.find("case") != -1:
|
||||
line = line.replace(e + ".", "")
|
||||
elif line.find("== (int)") != -1 or line.find("!= (int)") != -1:
|
||||
line = re.sub("\(int\)" + e + "\.(?P<id>[A-Z0-9_]*)", e + ".\g<id>.toInt()", line)
|
||||
elif line.find("==") != -1 or line.find("!=") != -1:
|
||||
line = re.sub(e + "\.(?P<id>[A-Z0-9_]*)", e + ".\g<id>", line)
|
||||
else:
|
||||
# line = re.sub("\(\(" + e + "\)(?P<rest>.*\(.*)\)", "(" + e + ".values()[\g<rest>])", line)
|
||||
line = re.sub("\(" + e + "\)(?P<rest>.*\(.*\))", e + ".fromInt(\g<rest>)", line)
|
||||
return line
|
||||
|
||||
def replace_generals(a):
|
||||
a = re.sub(" NativeObject", " NativeObject()", a)
|
||||
a = re.sub("\.NativeObject", ".NativeObject()", a)
|
||||
a = re.sub("(?P<h>[\.\(])Id", "\g<h>Id()", a)
|
||||
a = a.replace("(Context ==", "(Context() ==")
|
||||
a = a.replace("(Context,", "(Context(),")
|
||||
a = a.replace("Context.", "Context().")
|
||||
a = a.replace(".nCtx", ".nCtx()")
|
||||
a = a.replace("(nCtx", "(nCtx()")
|
||||
a = re.sub("Context\(\).(?P<id>[^_]*)_DRQ", "Context().\g<id>_DRQ()", a)
|
||||
a = re.sub("ASTKind", "ASTKind()", a)
|
||||
a = re.sub("IsExpr(?P<f>[ ;])", "IsExpr()\g<f>", a)
|
||||
a = re.sub("IsNumeral(?P<f>[ ;])", "IsNumeral()\g<f>", a)
|
||||
a = re.sub("IsInt(?P<f>[ ;])", "IsInt()\g<f>", a)
|
||||
a = re.sub("IsReal(?P<f>[ ;])", "IsReal()\g<f>", a)
|
||||
a = re.sub("IsVar(?P<f>[ ;\)])", "IsVar()\g<f>", a)
|
||||
a = re.sub("FuncDecl.DeclKind", "FuncDecl().DeclKind()", a)
|
||||
a = re.sub("FuncDecl.DomainSize", "FuncDecl().DomainSize()", a)
|
||||
a = re.sub("(?P<h>[=&]) Num(?P<id>[a-zA-Z]*)", "\g<h> Num\g<id>()", a)
|
||||
a = re.sub("= Denominator", "= Denominator()", a)
|
||||
a = re.sub(", BoolSort(?P<f>[\)\.])", ", BoolSort()\g<f>", a)
|
||||
a = re.sub(", RealSort(?P<f>[\)\.])", ", RealSort()\g<f>", a)
|
||||
a = re.sub(", IntSort(?P<f>[\)\.])", ", IntSort()\g<f>", a)
|
||||
a = a.replace("? 1 : 0", "? true : false")
|
||||
if a.find("Native.") != -1 and a.find("!= 0") != -1:
|
||||
a = a.replace("!= 0", "")
|
||||
if a.find("Native.") != -1 and a.find("== 0") != -1:
|
||||
a = a.replace("== 0", "^ true")
|
||||
return a
|
||||
|
||||
def translate(filename):
|
||||
tgtfn = OUTDIR + filename.replace(EXT, ".java")
|
||||
print "Translating " + filename + " to " + tgtfn
|
||||
tgt = open(tgtfn, "w")
|
||||
in_header = 0
|
||||
in_class = 0
|
||||
in_static_class = 0
|
||||
in_javadoc = 0
|
||||
lastindent = 0
|
||||
skip_brace = 0
|
||||
in_getter = ""
|
||||
in_getter_type = ""
|
||||
in_unsupported = 0
|
||||
getters = []
|
||||
in_bracket_op = 0
|
||||
in_getter_get = 0
|
||||
in_getter_set = 0
|
||||
had_ulong_res = 0
|
||||
in_enum = 0
|
||||
missing_foreach_brace = 0
|
||||
foreach_opened_brace = 0
|
||||
for line in fileinput.input(os.path.join(CS, filename)):
|
||||
s = string.rstrip(string.lstrip(line))
|
||||
if in_javadoc:
|
||||
if s.startswith("///"):
|
||||
lastindent = line.find(s);
|
||||
if s.startswith("/// </summary>"):
|
||||
pass
|
||||
else:
|
||||
a = line
|
||||
a = a.replace("<c>", "<code>")
|
||||
a = a.replace("</c>", "</code>")
|
||||
a = a.replace("///"," *")
|
||||
a = a.replace("<returns>","@return ")
|
||||
a = a.replace("</returns>","")
|
||||
tgt.write(a)
|
||||
else:
|
||||
t = ""
|
||||
for i in range(0, lastindent):
|
||||
t += " "
|
||||
tgt.write(t + " **/\n")
|
||||
in_javadoc = 0
|
||||
|
||||
# for i in range(0, len(EXCLUDE_METHODS)):
|
||||
# if filename == EXCLUDE_METHODS[i][0] and s.startswith(EXCLUDE_METHODS[i][1]):
|
||||
# tgt.write(t + "/* Not translated because it would translate to a function with clashing types. */\n")
|
||||
# in_unsupported = 1
|
||||
# break
|
||||
|
||||
|
||||
if in_unsupported:
|
||||
if s == "}":
|
||||
in_unsupported = 0
|
||||
elif not in_javadoc:
|
||||
if not in_header and s.find("/*++") != -1:
|
||||
in_header = 1
|
||||
tgt.write("/**\n")
|
||||
elif in_header and s.startswith("--*/"):
|
||||
in_header = 0
|
||||
tgt.write(" * This file was automatically generated from " + filename + " \n")
|
||||
tgt.write(" **/\n")
|
||||
tgt.write("\npackage com.Microsoft.Z3;\n\n")
|
||||
tgt.write("import java.math.BigInteger;\n")
|
||||
tgt.write("import java.util.*;\n")
|
||||
tgt.write("import java.lang.Exception;\n")
|
||||
tgt.write("import com.Microsoft.Z3.Enumerations.*;\n")
|
||||
elif in_header == 1:
|
||||
# tgt.write(" * " + line.replace(filename, tgtfn))
|
||||
pass
|
||||
elif s.startswith("using"):
|
||||
if s.find("System.Diagnostics.Contracts") == -1:
|
||||
tgt.write("/* " + s + " */\n")
|
||||
elif s.startswith("namespace"):
|
||||
pass
|
||||
elif s.startswith("public") and s.find("operator") != -1 and (s.find("==") != -1 or s.find("!=") != -1):
|
||||
t = ""
|
||||
for i in range(0, line.find(s)+1):
|
||||
t += " "
|
||||
tgt.write(t + "/* Overloaded operators are not translated. */\n")
|
||||
in_unsupported = 1
|
||||
elif s.startswith("public enum"):
|
||||
tgt.write(line.replace("enum", "class"))
|
||||
in_enum = 1
|
||||
elif in_enum == 1:
|
||||
if s == "}":
|
||||
tgt.write(line)
|
||||
in_enum = 0
|
||||
else:
|
||||
line = re.sub("(?P<id>.*)\W*=\W*(?P<val>[^\n,])", "public static final int \g<id> = \g<val>;", line)
|
||||
tgt.write(line.replace(",",""))
|
||||
elif s.startswith("public class") or s.startswith("internal class") or s.startswith("internal abstract class"):
|
||||
a = line.replace(":", "extends").replace("internal ", "")
|
||||
a = a.replace(", IComparable", "")
|
||||
a = type_replace(a)
|
||||
tgt.write(a)
|
||||
in_class = 1
|
||||
in_static_class = 0
|
||||
elif s.startswith("public static class") or s.startswith("abstract class"):
|
||||
tgt.write(line.replace(":", "extends").replace("static", "final"))
|
||||
in_class = 1
|
||||
in_static_class = 1
|
||||
elif s.startswith("/// <summary>"):
|
||||
tgt.write(line.replace("/// <summary>", "/**"))
|
||||
in_javadoc = 1
|
||||
elif skip_brace and s == "{":
|
||||
skip_brace = 0
|
||||
elif ((s.find("public") != -1 or s.find("protected") != -1) and s.find("class") == -1 and s.find("event") == -1 and s.find("(") == -1) or s.startswith("internal virtual IntPtr NativeObject") or s.startswith("internal Context Context"):
|
||||
if (s.startswith("new")):
|
||||
s = s[3:]
|
||||
s = s.replace("internal virtual", "")
|
||||
s = s.replace("internal", "")
|
||||
tokens = s.split(" ")
|
||||
# print "TOKENS: " + str(len(tokens))
|
||||
if len(tokens) == 3:
|
||||
in_getter = tokens[2]
|
||||
in_getter_type = type_replace((tokens[0] + " " + tokens[1]))
|
||||
if in_static_class:
|
||||
in_getter_type = in_getter_type.replace("static", "")
|
||||
lastindent = line.find(s)
|
||||
skip_brace = 1
|
||||
getters.append(in_getter)
|
||||
elif len(tokens) == 4:
|
||||
if tokens[2].startswith("this["):
|
||||
in_bracket_op = 1
|
||||
in_getter = type_replace(tokens[2]).replace("this[", "get(")
|
||||
in_getter += " " + tokens[3].replace("]", ")")
|
||||
in_getter_type = type_replace(tokens[0] + " " + tokens[1])
|
||||
else:
|
||||
in_getter = tokens[3]
|
||||
in_getter_type = type_replace(tokens[0] + " " + tokens[1] + " " + tokens[2])
|
||||
if in_static_class:
|
||||
in_getter_type = in_getter_type.replace("static", "")
|
||||
lastindent = line.find(s)
|
||||
skip_brace = 1
|
||||
getters.append(in_getter)
|
||||
else:
|
||||
in_getter = tokens[2]
|
||||
in_getter_type = type_replace(tokens[0] + " " + tokens[1])
|
||||
if tokens[2].startswith("this["):
|
||||
lastindent = line.find(s)
|
||||
t = ""
|
||||
for i in range(0, lastindent): t += " "
|
||||
tgt.write(t + "/* operator this[] not translated */\n ")
|
||||
in_unsupported = 1
|
||||
else:
|
||||
if in_static_class:
|
||||
in_getter_type = in_getter_type.replace("static", "")
|
||||
rest = s[s.find("get ") + 4:-1]
|
||||
subst_getters(rest, getters)
|
||||
rest = type_replace(rest)
|
||||
rest = rename_native(rest)
|
||||
rest = replace_generals(rest)
|
||||
rest = enum_replace(rest)
|
||||
t = ""
|
||||
for i in range(0, lastindent):
|
||||
t += " "
|
||||
tgt.write(t + in_getter_type + " " + in_getter + "() " + rest + "\n")
|
||||
if rest.find("}") == -1:
|
||||
in_getter_get = 1
|
||||
else:
|
||||
getters.append(in_getter)
|
||||
in_getter = ""
|
||||
in_getter_type = ""
|
||||
print "ACC: " + s + " --> " + in_getter
|
||||
elif s.find("{ get {") != -1:
|
||||
line = type_replace(line)
|
||||
line = line.replace("internal ", "")
|
||||
d = line[0:line.find("{ get")]
|
||||
rest = line[line.find("{ get")+5:]
|
||||
rest = rest.replace("} }", "}")
|
||||
rest = re.sub("Contract.\w+\([\s\S]*\);", "", rest)
|
||||
subst_getters(rest, getters)
|
||||
rest = rename_native(rest)
|
||||
rest = replace_generals(rest)
|
||||
rest = enum_replace(rest)
|
||||
if in_bracket_op:
|
||||
tgt.write(d + rest)
|
||||
else:
|
||||
tgt.write(d + "()" + rest)
|
||||
print "ACC: " + s + " --> " + in_getter
|
||||
elif in_getter != "" and s.startswith("get"):
|
||||
t = ""
|
||||
for i in range(0, lastindent):
|
||||
t += " "
|
||||
if len(s) > 3: rest = s[3:]
|
||||
else: rest = ""
|
||||
subst_getters(rest, getters)
|
||||
rest = type_replace(rest)
|
||||
rest = rename_native(rest)
|
||||
rest = replace_generals(rest)
|
||||
rest = enum_replace(rest)
|
||||
if in_bracket_op:
|
||||
tgt.write(t + in_getter_type + " " + in_getter + " " + rest + "\n")
|
||||
else:
|
||||
tgt.write(t + in_getter_type + " " + in_getter + "() " + rest + "\n")
|
||||
if rest.find("}") == -1:
|
||||
in_getter_get = 1
|
||||
elif in_getter != "" and s.startswith("set"):
|
||||
t = ""
|
||||
for i in range(0, lastindent):
|
||||
t += " "
|
||||
if len(s) > 3: rest = type_replace(s[3:])
|
||||
else: rest = ""
|
||||
subst_getters(rest, getters)
|
||||
rest = rest.replace("(Integer)value", "Integer(value)")
|
||||
rest = type_replace(rest)
|
||||
rest = rename_native(rest)
|
||||
rest = replace_generals(rest)
|
||||
rest = enum_replace(rest)
|
||||
ac_acc = in_getter_type[:in_getter_type.find(' ')]
|
||||
ac_type = in_getter_type[in_getter_type.find(' ')+1:]
|
||||
if in_bracket_op:
|
||||
in_getter = in_getter.replace("get", "set").replace(")", "")
|
||||
tgt.write(t + ac_acc + " void " + in_getter + ", " + ac_type + " value) " + rest + "\n")
|
||||
else:
|
||||
tgt.write(t + ac_acc + " void set" + in_getter + "(" + ac_type + " value) " + rest + "\n")
|
||||
if rest.find("}") == -1:
|
||||
in_getter_set = 1
|
||||
elif in_getter != "" and in_getter_get == 1 and s == "}":
|
||||
tgt.write(line)
|
||||
in_getter_get = 0
|
||||
elif in_getter != "" and in_getter_set == 1 and s == "}":
|
||||
tgt.write(line)
|
||||
in_getter_set = 0
|
||||
elif in_getter != "" and in_getter_get == 0 and in_getter_set == 0 and s == "}":
|
||||
in_getter = ""
|
||||
in_getter_type == ""
|
||||
in_bracket_op = 0
|
||||
skip_brace = 0
|
||||
elif s.startswith("uint ") and s.find("=") == -1:
|
||||
line = line.replace("uint", "Integer", line)
|
||||
line = re.sub("(?P<n>\w+)(?P<c>[,;])", "\g<n>\g<c>", line)
|
||||
tgt.write(line);
|
||||
elif (not in_class and (s.startswith("{") or s.startswith("}"))) or s.startswith("[") or s.startswith("#"):
|
||||
# tgt.write("// Skipping: " + s)
|
||||
pass
|
||||
elif line == "}\n":
|
||||
pass
|
||||
else:
|
||||
# indent = line.find(s)
|
||||
# tgt.write("// LINE: " + line)
|
||||
if line.find(": base") != -1:
|
||||
line = re.sub(": base\((?P<p>[^\{]*)\)", "{ super(\g<p>);", line)
|
||||
line = line[4:]
|
||||
obraces = line.count("{")
|
||||
cbraces = line.count("}")
|
||||
mbraces = obraces - cbraces
|
||||
# tgt.write("// obraces = " + str(obraces) + "\n")
|
||||
if obraces == 1:
|
||||
skip_brace = 1
|
||||
else:
|
||||
for i in range(0, mbraces):
|
||||
line = line.replace("\n", "}\n")
|
||||
if (s.find("public") != -1 or s.find("protected") != -1 or s.find("internal") != -1) and s.find("(") != -1:
|
||||
line = re.sub(" = [\w.]+(?P<d>[,;\)])", "\g<d>", line)
|
||||
a = type_replace(line)
|
||||
a = enum_replace(a)
|
||||
a = re.sub("(?P<d>[\(, ])params ", "\g<d>", a)
|
||||
a = a.replace("base.", "super.")
|
||||
a = re.sub("Contract.\w+\([\s\S]*\);", "", a)
|
||||
a = rename_native(a)
|
||||
a = re.sub("~\w+\(\)", "protected void finalize()", a)
|
||||
|
||||
if missing_foreach_brace == 1:
|
||||
# a = a.replace("\n", " // checked " + str(foreach_opened_brace) + "\n")
|
||||
if foreach_opened_brace == 0 and a.find("{") != -1:
|
||||
foreach_opened_brace = 1
|
||||
elif foreach_opened_brace == 0 and a.find("}") == -1:
|
||||
a = a.replace("\n", "}}\n")
|
||||
foreach_opened_brace = 0
|
||||
missing_foreach_brace = 0
|
||||
elif foreach_opened_brace == 1 and a.find("}") != -1:
|
||||
a = a.replace("\n", "}}\n")
|
||||
foreach_opened_brace = 0
|
||||
missing_foreach_brace = 0
|
||||
|
||||
# if a.find("foreach") != -1:
|
||||
# missing_foreach_brace = 1
|
||||
# a = re.sub("foreach\s*\((?P<t>[\w <>,]+)\s+(?P<i>\w+)\s+in\s+(?P<w>\w+)\)",
|
||||
# "{ Iterator fe_i = \g<w>.iterator(); while (fe_i.hasNext()) { \g<t> \g<i> = (long)fe_i.next(); ",
|
||||
# a)
|
||||
a = re.sub("foreach\s*\((?P<t>[\w <>,]+)\s+(?P<i>\w+)\s+in\s+(?P<w>\w+)\)",
|
||||
"for (\g<t> \g<i>: \g<w>)",
|
||||
a)
|
||||
if a.find("long o: m_queue") != -1:
|
||||
a = a.replace("long", "Long")
|
||||
a = a.replace("readonly ", "")
|
||||
a = a.replace("const ", "final ")
|
||||
a = a.replace("String ToString", "String toString")
|
||||
a = a.replace(".ToString", ".toString")
|
||||
a = a.replace("internal ", "")
|
||||
a = a.replace("new static", "static")
|
||||
a = a.replace("new public", "public")
|
||||
a = a.replace("override ", "")
|
||||
a = a.replace("virtual ", "")
|
||||
a = a.replace("o as AST", "(AST) o")
|
||||
a = a.replace("o as Sort", "(Sort) o")
|
||||
a = a.replace("other as AST", "(AST) other")
|
||||
a = a.replace("o as FuncDecl", "(FuncDecl) o")
|
||||
a = a.replace("IntPtr obj", "long obj")
|
||||
a = a.replace("IntPtr o", "long o")
|
||||
a = a.replace("new long()", "0")
|
||||
a = a.replace("long.Zero", "0")
|
||||
a = a.replace("object o", "Object o")
|
||||
a = a.replace("object other", "Object other")
|
||||
a = a.replace("IntPtr res = IntPtr.Zero;", "Native.IntPtr res = new Native.IntPtr();")
|
||||
a = a.replace("out res", "res")
|
||||
a = a.replace("GC.ReRegisterForFinalize(m_ctx);", "")
|
||||
a = a.replace("GC.SuppressFinalize(this);", "")
|
||||
a = a.replace(".Length", ".length")
|
||||
a = a.replace("m_queue.Count", "m_queue.size()")
|
||||
a = a.replace("m_queue.Add", "m_queue.add")
|
||||
a = a.replace("m_queue.Clear", "m_queue.clear")
|
||||
a = a.replace("for (long ", "for (int ")
|
||||
a = a.replace("ReferenceEquals(Context, ctx)", "Context() == ctx")
|
||||
a = a.replace("BigInteger.Parse", "new BigInteger")
|
||||
if had_ulong_res == 0 and a.find("ulong res = 0") != -1:
|
||||
a = a.replace("ulong res = 0;", "LongPtr res = new LongPtr();")
|
||||
elif had_ulong_res == 1:
|
||||
a = a.replace("ref res)", "res)")
|
||||
if a.find("return res;") != -1:
|
||||
a = a.replace("return res;", "return res.value;")
|
||||
had_ulong_res = 0
|
||||
a = a.replace("lock (", "synchronized (")
|
||||
if in_static_class:
|
||||
a = a.replace("static", "")
|
||||
a = re.sub("ref (?P<id>\w+)", "\g<id>", a)
|
||||
subst_getters(a, getters)
|
||||
a = re.sub("NativeObject = (?P<rest>.*);", "setNativeObject(\g<rest>);", a)
|
||||
a = replace_generals(a)
|
||||
tgt.write(a)
|
||||
tgt.close()
|
||||
|
||||
mk_java_bindings()
|
|
@ -1,5 +1,5 @@
|
|||
/*++
|
||||
Copyright (c) 2010 Microsoft Corporation
|
||||
Copyright (c) Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ Z3 exceptions:
|
|||
... n = x + y
|
||||
... except Z3Exception as ex:
|
||||
... print("failed: %s" % ex)
|
||||
failed: 'sort mismatch'
|
||||
failed: sort mismatch
|
||||
"""
|
||||
from z3core import *
|
||||
from z3types import *
|
||||
|
@ -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`.
|
||||
|
||||
|
@ -1383,7 +1398,7 @@ def BoolVector(prefix, sz, ctx=None):
|
|||
return [ Bool('%s__%s' % (prefix, i)) for i in range(sz) ]
|
||||
|
||||
def FreshBool(prefix='b', ctx=None):
|
||||
"""Return a fresh Bolean constant in the given context using the given prefix.
|
||||
"""Return a fresh Boolean constant in the given context using the given prefix.
|
||||
|
||||
If `ctx=None`, then the global context is used.
|
||||
|
||||
|
@ -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)
|
||||
|
@ -3792,6 +3813,18 @@ def RepeatBitVec(n, a):
|
|||
_z3_assert(is_bv(a), "Second argument must be a Z3 Bitvector expression")
|
||||
return BitVecRef(Z3_mk_repeat(a.ctx_ref(), n, a.as_ast()), a.ctx)
|
||||
|
||||
def BVRedAnd(a):
|
||||
"""Return the reduction-and expression of `a`."""
|
||||
if __debug__:
|
||||
_z3_assert(is_bv(a), "First argument must be a Z3 Bitvector expression")
|
||||
return BitVecRef(Z3_mk_bvredand(a.ctx_ref(), a.as_ast()), a.ctx)
|
||||
|
||||
def BVRedOr(a):
|
||||
"""Return the reduction-or expression of `a`."""
|
||||
if __debug__:
|
||||
_z3_assert(is_bv(a), "First argument must be a Z3 Bitvector expression")
|
||||
return BitVecRef(Z3_mk_bvredor(a.ctx_ref(), a.as_ast()), a.ctx)
|
||||
|
||||
#########################################
|
||||
#
|
||||
# Arrays
|
||||
|
@ -4448,7 +4481,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 +6044,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.
|
||||
|
||||
|
@ -6127,7 +6178,7 @@ class Fixedpoint(Z3PPObject):
|
|||
Z3_fixedpoint_add_rule(self.ctx.ref(), self.fixedpoint, head.as_ast(), name)
|
||||
else:
|
||||
body = _get_args(body)
|
||||
f = self.abstract(Implies(And(body),head))
|
||||
f = self.abstract(Implies(And(body, self.ctx),head))
|
||||
Z3_fixedpoint_add_rule(self.ctx.ref(), self.fixedpoint, f.as_ast(), name)
|
||||
|
||||
def rule(self, head, body = None, name = None):
|
||||
|
@ -6155,7 +6206,7 @@ class Fixedpoint(Z3PPObject):
|
|||
if sz == 1:
|
||||
query = query[0]
|
||||
else:
|
||||
query = And(query)
|
||||
query = And(query, self.ctx)
|
||||
query = self.abstract(query, False)
|
||||
r = Z3_fixedpoint_query(self.ctx.ref(), self.fixedpoint, query.as_ast())
|
||||
return CheckSatResult(r)
|
||||
|
@ -6174,7 +6225,7 @@ class Fixedpoint(Z3PPObject):
|
|||
name = ""
|
||||
name = to_symbol(name, self.ctx)
|
||||
body = _get_args(body)
|
||||
f = self.abstract(Implies(And(body),head))
|
||||
f = self.abstract(Implies(And(body, self.ctx),head))
|
||||
Z3_fixedpoint_update_rule(self.ctx.ref(), self.fixedpoint, f.as_ast(), name)
|
||||
|
||||
def get_answer(self):
|
||||
|
@ -6960,7 +7011,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 +7304,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 +7355,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 +7393,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 +7426,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
|
||||
|
|
|
@ -23,7 +23,19 @@ Notes:
|
|||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
#endif // __cplusplus
|
||||
|
||||
/**
|
||||
\defgroup capi C API
|
||||
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
@name Algebraic Numbers API
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
\brief Return Z3_TRUE if \c can be used as value in the Z3 real algebraic
|
||||
|
@ -218,6 +230,8 @@ extern "C" {
|
|||
*/
|
||||
int Z3_API Z3_algebraic_eval(__in Z3_context c, __in Z3_ast p, __in unsigned n, __in Z3_ast a[]);
|
||||
|
||||
/*@}*/
|
||||
/*@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
|
|
381
src/api/z3_api.h
381
src/api/z3_api.h
|
@ -771,7 +771,6 @@ typedef enum
|
|||
|
||||
The premises of the rules is a sequence of clauses.
|
||||
The first clause argument is the main clause of the rule.
|
||||
One literal from the second, third, .. clause is resolved
|
||||
with a literal from the first (main) clause.
|
||||
|
||||
Premises of the rules are of the form
|
||||
|
@ -1143,8 +1142,8 @@ typedef enum {
|
|||
- Z3_FILE_ACCESS_ERRROR: A file could not be accessed.
|
||||
- Z3_INVALID_USAGE: API call is invalid in the current state.
|
||||
- Z3_INTERNAL_FATAL: An error internal to Z3 occurred.
|
||||
- Z3_DEC_REF_ERROR: Trying to decrement the reference counter of an AST that was deleted or the reference counter was not initialized\mlonly.\endmlonly\conly with #Z3_inc_ref.
|
||||
- Z3_EXCEPTION: Internal Z3 exception. Additional details can be retrieved using \mlonly #Z3_get_error_msg. \endmlonly \conly #Z3_get_error_msg_ex.
|
||||
- Z3_DEC_REF_ERROR: Trying to decrement the reference counter of an AST that was deleted or the reference counter was not initialized \mlonly.\endmlonly \conly with #Z3_inc_ref.
|
||||
- Z3_EXCEPTION: Internal Z3 exception. Additional details can be retrieved using #Z3_get_error_msg.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
|
@ -1287,8 +1286,6 @@ extern "C" {
|
|||
|
||||
\sa Z3_global_param_set
|
||||
|
||||
The caller must invoke #Z3_global_param_del_value to delete the value returned at \c param_value.
|
||||
|
||||
\remark This function cannot be invoked simultaneously from different threads without synchronization.
|
||||
The result string stored in param_value is stored in shared location.
|
||||
|
||||
|
@ -1462,15 +1459,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.
|
||||
|
@ -1779,7 +1767,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[]);
|
||||
|
@ -2116,17 +2104,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,
|
||||
|
@ -4010,6 +3988,12 @@ END_MLAPI_EXCLUDE
|
|||
|
||||
/**
|
||||
\brief Return a unique identifier for \c t.
|
||||
The identifier is unique up to structural equality. Thus, two ast nodes
|
||||
created by the same context and having the same children and same function symbols
|
||||
have the same identifiers. Ast nodes created in the same context, but having
|
||||
different children or different functions have different identifiers.
|
||||
Variables and quantifiers are also assigned different identifiers according to
|
||||
their structure.
|
||||
\mlonly \remark Implicitly used by [Pervasives.compare] for values of type [ast], [app], [sort], [func_decl], and [pattern]. \endmlonly
|
||||
|
||||
def_API('Z3_get_ast_id', UINT, (_in(CONTEXT), _in(AST)))
|
||||
|
@ -4018,6 +4002,8 @@ END_MLAPI_EXCLUDE
|
|||
|
||||
/**
|
||||
\brief Return a hash code for the given AST.
|
||||
The hash code is structural. You can use Z3_get_ast_id interchangably with
|
||||
this function.
|
||||
\mlonly \remark Implicitly used by [Hashtbl.hash] for values of type [ast], [app], [sort], [func_decl], and [pattern]. \endmlonly
|
||||
|
||||
def_API('Z3_get_ast_hash', UINT, (_in(CONTEXT), _in(AST)))
|
||||
|
@ -4917,8 +4903,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.
|
||||
|
@ -4927,13 +4912,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>
|
||||
|
@ -6620,6 +6604,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);
|
||||
|
@ -6757,8 +6748,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
|
||||
|
@ -7069,7 +7063,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.
|
||||
|
||||
|
@ -7182,6 +7176,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
|
||||
|
||||
|
@ -7685,314 +7684,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
|
||||
|
||||
|
||||
|
|
293
src/api/z3_interp.h
Normal file
293
src/api/z3_interp.h
Normal file
|
@ -0,0 +1,293 @@
|
|||
/*++
|
||||
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
|
||||
|
||||
/**
|
||||
\defgroup capi C API
|
||||
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
@name Interpolation API
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
\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)
|
||||
\param num_theory Number of theory terms
|
||||
\param theory Theory terms
|
||||
|
||||
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)
|
||||
\param num_theory Number of theory terms
|
||||
\param theory Theory terms
|
||||
|
||||
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
|
||||
\param num_theory Number of theory terms
|
||||
\param theory Theory terms
|
||||
|
||||
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
|
|
@ -24,6 +24,19 @@ Notes:
|
|||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
/**
|
||||
\defgroup capi C API
|
||||
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
|
||||
|
||||
/**
|
||||
@name Polynomials API
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
\brief Return the nonzero subresultants of \c p and \c q with respect to the "variable" \c x.
|
||||
|
||||
|
@ -38,6 +51,9 @@ extern "C" {
|
|||
Z3_ast_vector Z3_API Z3_polynomial_subresultants(__in Z3_context c, __in Z3_ast p, __in Z3_ast q, __in Z3_ast x);
|
||||
|
||||
|
||||
/*@}*/
|
||||
/*@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif // __cplusplus
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue