3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 00:55:31 +00:00

add recfun to API

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2018-10-27 11:41:18 -05:00
parent c5cbf985ca
commit 51a0022450
11 changed files with 191 additions and 42 deletions

View file

@ -1190,6 +1190,20 @@ void mk_model_example() {
std::cout << m.eval(a + b < 2)<< std::endl;
}
void recfun_example() {
std::cout << "recfun example\n";
context c;
expr x = c.int_const("x");
expr y = c.int_const("y");
expr b = c.bool_const("b");
sort I = c.int_sort();
sort B = c.bool_sort();
func_decl f = recfun("f", I, B, I);
expr_vector args(c);
args.push_back(x); args.push_back(b);
c.recdef(f, args, ite(b, x, f(x + 1, !b)));
prove(f(x,c.bool_val(false)) > x);
}
int main() {
@ -1239,6 +1253,7 @@ int main() {
consequence_example(); std::cout << "\n";
parse_example(); std::cout << "\n";
mk_model_example(); std::cout << "\n";
recfun_example(); std::cout << "\n";
std::cout << "done\n";
}
catch (exception & ex) {