mirror of
				https://github.com/Z3Prover/z3
				synced 2025-10-31 19:52:29 +00:00 
			
		
		
		
	type check distinct operator. fixes #62
Signed-off-by: Nikolaj Bjorner <nbjorner@hotmail.com>
This commit is contained in:
		
							parent
							
								
									f7d9438e7b
								
							
						
					
					
						commit
						620c11932b
					
				
					 3 changed files with 14 additions and 2 deletions
				
			
		|  | @ -1043,6 +1043,13 @@ func_decl * basic_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters | |||
|     case OP_DISTINCT: { | ||||
|         func_decl_info info(m_family_id, OP_DISTINCT); | ||||
|         info.set_pairwise(); | ||||
|         for (unsigned i = 1; i < arity; i++) {         | ||||
|             if (domain[i] != domain[0]) { | ||||
|                 std::ostringstream buffer; | ||||
|                 buffer << "Sort mismatch between first argument and argument " << (i+1); | ||||
|                 throw ast_exception(buffer.str().c_str()); | ||||
|             } | ||||
|         } | ||||
|         return m_manager->mk_func_decl(symbol("distinct"), arity, domain, m_bool_sort, info); | ||||
|     } | ||||
|     default: | ||||
|  | @ -2338,6 +2345,10 @@ quantifier * ast_manager::update_quantifier(quantifier * q, bool is_forall, unsi | |||
|                          num_patterns == 0 ? q->get_no_patterns() : 0); | ||||
| } | ||||
| 
 | ||||
| app * ast_manager::mk_distinct(unsigned num_args, expr * const * args) { | ||||
|     return mk_app(m_basic_family_id, OP_DISTINCT, num_args, args); | ||||
| } | ||||
| 
 | ||||
| app * ast_manager::mk_distinct_expanded(unsigned num_args, expr * const * args) { | ||||
|     if (num_args < 2) | ||||
|         return mk_true(); | ||||
|  |  | |||
|  | @ -2000,7 +2000,7 @@ public: | |||
|     app * mk_and(expr * arg1, expr * arg2, expr * arg3) { return mk_app(m_basic_family_id, OP_AND, arg1, arg2, arg3); } | ||||
|     app * mk_implies(expr * arg1, expr * arg2) { return mk_app(m_basic_family_id, OP_IMPLIES, arg1, arg2); } | ||||
|     app * mk_not(expr * n) { return mk_app(m_basic_family_id, OP_NOT, n); } | ||||
|     app * mk_distinct(unsigned num_args, expr * const * args) { return mk_app(m_basic_family_id, OP_DISTINCT, num_args, args); } | ||||
|     app * mk_distinct(unsigned num_args, expr * const * args); | ||||
|     app * mk_distinct_expanded(unsigned num_args, expr * const * args); | ||||
|     app * mk_true() { return m_true; } | ||||
|     app * mk_false() { return m_false; } | ||||
|  |  | |||
|  | @ -460,8 +460,9 @@ static void test_mk_distinct() { | |||
|   Z3_sort bv8 = Z3_mk_bv_sort(ctx, 8); | ||||
|   Z3_sort bv32 = Z3_mk_bv_sort(ctx, 32); | ||||
|   Z3_ast args[] = { Z3_mk_int64(ctx, 0, bv8), Z3_mk_int64(ctx, 0, bv32) }; | ||||
|   Z3_mk_distinct(ctx, 2, args); | ||||
|   Z3_ast d = Z3_mk_distinct(ctx, 2, args); | ||||
|   SASSERT(cb_called); | ||||
|    | ||||
| } | ||||
| 
 | ||||
| void tst_api() { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue