mirror of
https://github.com/Z3Prover/z3
synced 2025-12-15 16:58:58 +00:00
fix merge issues
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
2e7f80f597
commit
ce60a8c5c5
2 changed files with 316 additions and 301 deletions
|
|
@ -50,6 +50,8 @@ class finite_set_rewriter {
|
|||
br_status mk_intersect(unsigned num_args, expr * const * args, expr_ref & result);
|
||||
br_status mk_difference(expr * arg1, expr * arg2, expr_ref & result);
|
||||
br_status mk_subset(expr * arg1, expr * arg2, expr_ref & result);
|
||||
br_status mk_singleton(expr *arg1, expr_ref &result);
|
||||
br_status mk_in(expr *arg1, expr *arg2, expr_ref &result);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ Author:
|
|||
#include "ast/arith_decl_plugin.h"
|
||||
#include "ast/rewriter/finite_set_rewriter.h"
|
||||
|
||||
static void test_union_idempotent() {
|
||||
class finite_set_rewriter_test {
|
||||
void test_union_idempotent() {
|
||||
ast_manager m;
|
||||
reg_decl_plugins(m);
|
||||
|
||||
|
|
@ -44,7 +45,7 @@ static void test_union_idempotent() {
|
|||
ENSURE(result == s1);
|
||||
}
|
||||
|
||||
static void test_intersect_idempotent() {
|
||||
void test_intersect_idempotent() {
|
||||
ast_manager m;
|
||||
reg_decl_plugins(m);
|
||||
|
||||
|
|
@ -61,13 +62,14 @@ static void test_intersect_idempotent() {
|
|||
// Test set.intersect(s1, s1) -> s1
|
||||
app_ref intersect_app(fsets.mk_intersect(s1, s1), m);
|
||||
expr_ref result(m);
|
||||
br_status st = rw.mk_app_core(intersect_app->get_decl(), intersect_app->get_num_args(), intersect_app->get_args(), result);
|
||||
br_status st =
|
||||
rw.mk_app_core(intersect_app->get_decl(), intersect_app->get_num_args(), intersect_app->get_args(), result);
|
||||
|
||||
ENSURE(st == BR_DONE);
|
||||
ENSURE(result == s1);
|
||||
}
|
||||
|
||||
static void test_difference_same() {
|
||||
void test_difference_same() {
|
||||
ast_manager m;
|
||||
reg_decl_plugins(m);
|
||||
|
||||
|
|
@ -90,7 +92,7 @@ static void test_difference_same() {
|
|||
ENSURE(fsets.is_empty(result));
|
||||
}
|
||||
|
||||
static void test_subset_rewrite() {
|
||||
void test_subset_rewrite() {
|
||||
ast_manager m;
|
||||
reg_decl_plugins(m);
|
||||
|
||||
|
|
@ -109,7 +111,8 @@ static void test_subset_rewrite() {
|
|||
// Test set.subset(s1, s2) -> set.intersect(s1, s2) = s1
|
||||
app_ref subset_app(fsets.mk_subset(s1, s2), m);
|
||||
expr_ref result(m);
|
||||
br_status st = rw.mk_app_core(subset_app->get_decl(), subset_app->get_num_args(), subset_app->get_args(), result);
|
||||
br_status st =
|
||||
rw.mk_app_core(subset_app->get_decl(), subset_app->get_num_args(), subset_app->get_args(), result);
|
||||
|
||||
ENSURE(st == BR_REWRITE3);
|
||||
ENSURE(m.is_eq(result));
|
||||
|
|
@ -127,7 +130,7 @@ static void test_subset_rewrite() {
|
|||
ENSURE(rhs == s1);
|
||||
}
|
||||
|
||||
static void test_mk_app_core() {
|
||||
void test_mk_app_core() {
|
||||
ast_manager m;
|
||||
reg_decl_plugins(m);
|
||||
|
||||
|
|
@ -150,7 +153,7 @@ static void test_mk_app_core() {
|
|||
ENSURE(result == s1);
|
||||
}
|
||||
|
||||
static void test_union_with_empty() {
|
||||
void test_union_with_empty() {
|
||||
ast_manager m;
|
||||
reg_decl_plugins(m);
|
||||
|
||||
|
|
@ -168,19 +171,21 @@ static void test_union_with_empty() {
|
|||
// Test set.union(s1, empty) -> s1
|
||||
app_ref union_app1(fsets.mk_union(s1, empty_set), m);
|
||||
expr_ref result1(m);
|
||||
br_status st1 = rw.mk_app_core(union_app1->get_decl(), union_app1->get_num_args(), union_app1->get_args(), result1);
|
||||
br_status st1 =
|
||||
rw.mk_app_core(union_app1->get_decl(), union_app1->get_num_args(), union_app1->get_args(), result1);
|
||||
ENSURE(st1 == BR_DONE);
|
||||
ENSURE(result1 == s1);
|
||||
|
||||
// Test set.union(empty, s1) -> s1
|
||||
app_ref union_app2(fsets.mk_union(empty_set, s1), m);
|
||||
expr_ref result2(m);
|
||||
br_status st2 = rw.mk_app_core(union_app2->get_decl(), union_app2->get_num_args(), union_app2->get_args(), result2);
|
||||
br_status st2 =
|
||||
rw.mk_app_core(union_app2->get_decl(), union_app2->get_num_args(), union_app2->get_args(), result2);
|
||||
ENSURE(st2 == BR_DONE);
|
||||
ENSURE(result2 == s1);
|
||||
}
|
||||
|
||||
static void test_intersect_with_empty() {
|
||||
void test_intersect_with_empty() {
|
||||
ast_manager m;
|
||||
reg_decl_plugins(m);
|
||||
|
||||
|
|
@ -198,19 +203,21 @@ static void test_intersect_with_empty() {
|
|||
// Test set.intersect(s1, empty) -> empty
|
||||
app_ref intersect_app1(fsets.mk_intersect(s1, empty_set), m);
|
||||
expr_ref result1(m);
|
||||
br_status st1 = rw.mk_app_core(intersect_app1->get_decl(), intersect_app1->get_num_args(), intersect_app1->get_args(), result1);
|
||||
br_status st1 = rw.mk_app_core(intersect_app1->get_decl(), intersect_app1->get_num_args(),
|
||||
intersect_app1->get_args(), result1);
|
||||
ENSURE(st1 == BR_DONE);
|
||||
ENSURE(result1 == empty_set);
|
||||
|
||||
// Test set.intersect(empty, s1) -> empty
|
||||
app_ref intersect_app2(fsets.mk_intersect(empty_set, s1), m);
|
||||
expr_ref result2(m);
|
||||
br_status st2 = rw.mk_app_core(intersect_app2->get_decl(), intersect_app2->get_num_args(), intersect_app2->get_args(), result2);
|
||||
br_status st2 = rw.mk_app_core(intersect_app2->get_decl(), intersect_app2->get_num_args(),
|
||||
intersect_app2->get_args(), result2);
|
||||
ENSURE(st2 == BR_DONE);
|
||||
ENSURE(result2 == empty_set);
|
||||
}
|
||||
|
||||
static void test_difference_with_empty() {
|
||||
void test_difference_with_empty() {
|
||||
ast_manager m;
|
||||
reg_decl_plugins(m);
|
||||
|
||||
|
|
@ -228,19 +235,21 @@ static void test_difference_with_empty() {
|
|||
// Test set.difference(s1, empty) -> s1
|
||||
app_ref diff_app1(fsets.mk_difference(s1, empty_set), m);
|
||||
expr_ref result1(m);
|
||||
br_status st1 = rw.mk_app_core(diff_app1->get_decl(), diff_app1->get_num_args(), diff_app1->get_args(), result1);
|
||||
br_status st1 =
|
||||
rw.mk_app_core(diff_app1->get_decl(), diff_app1->get_num_args(), diff_app1->get_args(), result1);
|
||||
ENSURE(st1 == BR_DONE);
|
||||
ENSURE(result1 == s1);
|
||||
|
||||
// Test set.difference(empty, s1) -> empty
|
||||
app_ref diff_app2(fsets.mk_difference(empty_set, s1), m);
|
||||
expr_ref result2(m);
|
||||
br_status st2 = rw.mk_app_core(diff_app2->get_decl(), diff_app2->get_num_args(), diff_app2->get_args(), result2);
|
||||
br_status st2 =
|
||||
rw.mk_app_core(diff_app2->get_decl(), diff_app2->get_num_args(), diff_app2->get_args(), result2);
|
||||
ENSURE(st2 == BR_DONE);
|
||||
ENSURE(result2 == empty_set);
|
||||
}
|
||||
|
||||
static void test_subset_with_empty() {
|
||||
void test_subset_with_empty() {
|
||||
ast_manager m;
|
||||
reg_decl_plugins(m);
|
||||
|
||||
|
|
@ -258,19 +267,21 @@ static void test_subset_with_empty() {
|
|||
// Test set.subset(empty, s1) -> true
|
||||
app_ref subset_app1(fsets.mk_subset(empty_set, s1), m);
|
||||
expr_ref result1(m);
|
||||
br_status st1 = rw.mk_app_core(subset_app1->get_decl(), subset_app1->get_num_args(), subset_app1->get_args(), result1);
|
||||
br_status st1 =
|
||||
rw.mk_app_core(subset_app1->get_decl(), subset_app1->get_num_args(), subset_app1->get_args(), result1);
|
||||
ENSURE(st1 == BR_DONE);
|
||||
ENSURE(m.is_true(result1));
|
||||
|
||||
// Test set.subset(s1, s1) -> true
|
||||
app_ref subset_app2(fsets.mk_subset(s1, s1), m);
|
||||
expr_ref result2(m);
|
||||
br_status st2 = rw.mk_app_core(subset_app2->get_decl(), subset_app2->get_num_args(), subset_app2->get_args(), result2);
|
||||
br_status st2 =
|
||||
rw.mk_app_core(subset_app2->get_decl(), subset_app2->get_num_args(), subset_app2->get_args(), result2);
|
||||
ENSURE(st2 == BR_DONE);
|
||||
ENSURE(m.is_true(result2));
|
||||
}
|
||||
|
||||
static void test_in_singleton() {
|
||||
void test_in_singleton() {
|
||||
ast_manager m;
|
||||
reg_decl_plugins(m);
|
||||
|
||||
|
|
@ -298,7 +309,7 @@ static void test_in_singleton() {
|
|||
ENSURE(m.is_eq(result2));
|
||||
}
|
||||
|
||||
static void test_in_empty() {
|
||||
void test_in_empty() {
|
||||
ast_manager m;
|
||||
reg_decl_plugins(m);
|
||||
|
||||
|
|
@ -320,17 +331,19 @@ static void test_in_empty() {
|
|||
ENSURE(st == BR_DONE);
|
||||
ENSURE(m.is_false(result));
|
||||
}
|
||||
};
|
||||
|
||||
void tst_finite_set_rewriter() {
|
||||
test_union_idempotent();
|
||||
test_intersect_idempotent();
|
||||
test_difference_same();
|
||||
test_subset_rewrite();
|
||||
test_mk_app_core();
|
||||
test_union_with_empty();
|
||||
test_intersect_with_empty();
|
||||
test_difference_with_empty();
|
||||
test_subset_with_empty();
|
||||
test_in_singleton();
|
||||
test_in_empty();
|
||||
finite_set_rewriter_test test;
|
||||
test.test_union_idempotent();
|
||||
test.test_intersect_idempotent();
|
||||
test.test_difference_same();
|
||||
test.test_subset_rewrite();
|
||||
test.test_mk_app_core();
|
||||
test.test_union_with_empty();
|
||||
test.test_intersect_with_empty();
|
||||
test.test_difference_with_empty();
|
||||
test.test_subset_with_empty();
|
||||
test.test_in_singleton();
|
||||
test.test_in_empty();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue