z3 - using of z3_update_term function for term updating -


the following code changes 2 3 in expression e1.

context z3_cont; expr x = z3_cont.int_const("x"); expr e1 = (x==2); expr e2 = (x==3); z3_ast ee[2]; ee[0]=e1.arg(0); ee[1]=e2.arg(1); e1 = to_expr(z3_cont,z3_update_term(z3_cont,e1,2,ee)); 

is possible easier? unfortunately, code e1.arg(1) = e2.arg(1) doesn't work. second question how change expressions on arbitrary depth of z3_ast, example e1.arg(1).arg(0) = e2.arg(1).arg(1)?

you can use z3_substitute api. here example:

void substitute_example() {     std::cout << "substitute example\n";     context c;     expr x(c);     x = c.int_const("x");     expr f(c);     f = (x == 2) || (x == 1);     std::cout << f << std::endl;      expr two(c), three(c);     2   = c.int_val(2);     3 = c.int_val(3);     z3_ast from[] = { 2 };     z3_ast to[]   = { 3 };     expr new_f(c);     // replaces expressions in in f.      // third argument size of arrays , to.     new_f = to_expr(c, z3_substitute(c, f, 1, from, to));      std::cout << new_f << std::endl; } 

update if want substitute x == 2 x == 3 in formula, should write.

void substitute_example() {     std::cout << "substitute example\n";     context c;     expr x(c), y(c);     x = c.int_const("x");     y = c.int_const("y");     expr f(c);     f = (x == 2) || (y == 2);     std::cout << f << std::endl;      expr from(c), to(c);      = x == 2;        = x == 3;     z3_ast _from[] = { };     z3_ast _to[]   = { };     expr new_f(c);     // replaces expressions in in f.      // third argument size of arrays , to.     new_f = to_expr(c, z3_substitute(c, f, 1, _from, _to));      std::cout << new_f << std::endl; } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -