mirror of
https://github.com/Z3Prover/z3
synced 2025-05-02 05:15:52 +00:00
update lookahead to include extensions
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
83635eb826
commit
f3b0ede6e8
13 changed files with 1855 additions and 1944 deletions
|
@ -542,14 +542,15 @@ extern "C" {
|
|||
}
|
||||
|
||||
|
||||
int Z3_read_interpolation_problem(Z3_context ctx, unsigned *_num, Z3_ast *cnsts[], unsigned *parents[], const char *filename, Z3_string_ptr error, unsigned *ret_num_theory, Z3_ast *theory[]){
|
||||
int Z3_read_interpolation_problem(Z3_context ctx, Z3_ast_vector cnsts, unsigned* _num, unsigned* parents[], const char *filename, Z3_string_ptr error, Z3_ast_vector theory){
|
||||
|
||||
hash_map<std::string, std::string> file_params;
|
||||
get_file_params(filename, file_params);
|
||||
|
||||
unsigned num_theory = 0;
|
||||
if (file_params.find("THEORY") != file_params.end())
|
||||
if (file_params.find("THEORY") != file_params.end()) {
|
||||
num_theory = atoi(file_params["THEORY"].c_str());
|
||||
}
|
||||
|
||||
Z3_ast_vector assertions = iZ3_parse(ctx, filename, error);
|
||||
if (assertions == 0)
|
||||
|
@ -559,23 +560,15 @@ extern "C" {
|
|||
num_theory = Z3_ast_vector_size(ctx, assertions);
|
||||
unsigned num = Z3_ast_vector_size(ctx, assertions) - num_theory;
|
||||
|
||||
read_cnsts.resize(num);
|
||||
read_parents.resize(num);
|
||||
read_theory.resize(num_theory);
|
||||
|
||||
for (unsigned j = 0; j < num_theory; j++)
|
||||
read_theory[j] = Z3_ast_vector_get(ctx, assertions, j);
|
||||
for (unsigned j = 0; j < num; j++)
|
||||
read_cnsts[j] = Z3_ast_vector_get(ctx, assertions, j + num_theory);
|
||||
for (unsigned j = 0; theory && j < num_theory; j++)
|
||||
Z3_ast_vector_push(ctx, theory, Z3_ast_vector_get(ctx, assertions, j));
|
||||
|
||||
for (unsigned j = 0; j < num; j++)
|
||||
Z3_ast_vector_push(ctx, cnsts, Z3_ast_vector_get(ctx, assertions, j + num_theory));
|
||||
|
||||
if (ret_num_theory)
|
||||
*ret_num_theory = num_theory;
|
||||
if (theory)
|
||||
*theory = &read_theory[0];
|
||||
|
||||
if (!parents){
|
||||
*_num = num;
|
||||
*cnsts = &read_cnsts[0];
|
||||
Z3_ast_vector_dec_ref(ctx, assertions);
|
||||
return true;
|
||||
}
|
||||
|
@ -586,7 +579,7 @@ extern "C" {
|
|||
hash_map<Z3_ast, int> pred_map;
|
||||
|
||||
for (unsigned j = 0; j < num; j++){
|
||||
Z3_ast lhs = 0, rhs = read_cnsts[j];
|
||||
Z3_ast lhs = 0, rhs = Z3_ast_vector_get(ctx, cnsts, j);
|
||||
|
||||
if (Z3_get_decl_kind(ctx, Z3_get_app_decl(ctx, Z3_to_app(ctx, rhs))) == Z3_OP_IMPLIES){
|
||||
Z3_app app1 = Z3_to_app(ctx, rhs);
|
||||
|
@ -627,7 +620,7 @@ extern "C" {
|
|||
read_error << "formula " << j + 1 << ": should be (implies {children} fmla parent)";
|
||||
goto fail;
|
||||
}
|
||||
read_cnsts[j] = lhs;
|
||||
Z3_ast_vector_set(ctx, cnsts, j, lhs);
|
||||
Z3_ast name = rhs;
|
||||
if (pred_map.find(name) != pred_map.end()){
|
||||
read_error << "formula " << j + 1 << ": duplicate symbol";
|
||||
|
@ -646,7 +639,6 @@ extern "C" {
|
|||
}
|
||||
|
||||
*_num = num;
|
||||
*cnsts = &read_cnsts[0];
|
||||
*parents = &read_parents[0];
|
||||
Z3_ast_vector_dec_ref(ctx, assertions);
|
||||
return true;
|
||||
|
|
|
@ -133,19 +133,16 @@ namespace Microsoft.Z3
|
|||
/// 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;
|
||||
uint num = 0;
|
||||
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);
|
||||
ASTVector _cnsts = new ASTVector(this);
|
||||
ASTVector _theory = new ASTVector(this);
|
||||
|
||||
int r = Native.Z3_read_interpolation_problem(nCtx, _cnsts.NativeObject, ref num, out parents, filename, out n_err_str, _theory.NativeObject);
|
||||
error = Marshal.PtrToStringAnsi(n_err_str);
|
||||
cnsts = new Expr[num];
|
||||
cnsts = _cnsts.ToExprArray();
|
||||
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]);
|
||||
theory = _theory.ToExprArray();
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
@ -207,18 +207,17 @@ extern "C" {
|
|||
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)))
|
||||
def_API('Z3_read_interpolation_problem', INT, (_in(CONTEXT), _in(AST_VECTOR), _out(UINT), _out_managed_array(2, UINT), _in(STRING), _out(STRING), _in(AST_VECTOR)))
|
||||
|
||||
*/
|
||||
|
||||
int Z3_API Z3_read_interpolation_problem(Z3_context ctx,
|
||||
unsigned *num,
|
||||
Z3_ast *cnsts[],
|
||||
unsigned *parents[],
|
||||
Z3_ast_vector cnsts,
|
||||
unsigned* num,
|
||||
unsigned* parents[],
|
||||
Z3_string filename,
|
||||
Z3_string_ptr error,
|
||||
unsigned *num_theory,
|
||||
Z3_ast *theory[]);
|
||||
Z3_ast_vector theory);
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue