mirror of
				https://github.com/Z3Prover/z3
				synced 2025-10-31 11:42:28 +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
				
			
		|  | @ -34,7 +34,7 @@ where the signature is defined in finite_set_decl_plugin.h. | |||
| */ | ||||
| class finite_set_rewriter { | ||||
|     finite_set_util  m_util; | ||||
|     public: | ||||
| public: | ||||
|     finite_set_rewriter(ast_manager & m, params_ref const & p = params_ref()): | ||||
|         m_util(m) { | ||||
|     } | ||||
|  | @ -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); | ||||
| 
 | ||||
|  | @ -42,9 +43,9 @@ static void test_union_idempotent() { | |||
| 
 | ||||
|         ENSURE(st == BR_DONE); | ||||
|         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); | ||||
| 
 | ||||
|  | @ -88,9 +90,9 @@ static void test_difference_same() { | |||
| 
 | ||||
|         ENSURE(st == BR_DONE); | ||||
|         ENSURE(fsets.is_empty(result)); | ||||
| } | ||||
|     } | ||||
| 
 | ||||
| static void test_subset_rewrite() { | ||||
|     void test_subset_rewrite() { | ||||
|         ast_manager m; | ||||
|         reg_decl_plugins(m); | ||||
| 
 | ||||
|  | @ -109,25 +111,26 @@ 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)); | ||||
| 
 | ||||
|         // Check that result is an equality
 | ||||
|     app* eq = to_app(result); | ||||
|         app *eq = to_app(result); | ||||
|         ENSURE(eq->get_num_args() == 2); | ||||
| 
 | ||||
|         // The left side should be set.intersect(s1, s2)
 | ||||
|     expr* lhs = eq->get_arg(0); | ||||
|         expr *lhs = eq->get_arg(0); | ||||
|         ENSURE(fsets.is_intersect(lhs)); | ||||
| 
 | ||||
|         // The right side should be s1
 | ||||
|     expr* rhs = eq->get_arg(1); | ||||
|         expr *rhs = eq->get_arg(1); | ||||
|         ENSURE(rhs == s1); | ||||
| } | ||||
|     } | ||||
| 
 | ||||
| static void test_mk_app_core() { | ||||
|     void test_mk_app_core() { | ||||
|         ast_manager m; | ||||
|         reg_decl_plugins(m); | ||||
| 
 | ||||
|  | @ -148,9 +151,9 @@ static void test_mk_app_core() { | |||
| 
 | ||||
|         ENSURE(st == BR_DONE); | ||||
|         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); | ||||
| 
 | ||||
|  | @ -296,9 +307,9 @@ static void test_in_singleton() { | |||
|         br_status st2 = rw.mk_app_core(in_app2->get_decl(), in_app2->get_num_args(), in_app2->get_args(), result2); | ||||
|         ENSURE(st2 == BR_REWRITE1); | ||||
|         ENSURE(m.is_eq(result2)); | ||||
| } | ||||
|     } | ||||
| 
 | ||||
| static void test_in_empty() { | ||||
|     void test_in_empty() { | ||||
|         ast_manager m; | ||||
|         reg_decl_plugins(m); | ||||
| 
 | ||||
|  | @ -319,18 +330,20 @@ static void test_in_empty() { | |||
|         br_status st = rw.mk_app_core(in_app->get_decl(), in_app->get_num_args(), in_app->get_args(), result); | ||||
|         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