mirror of
				https://github.com/Z3Prover/z3
				synced 2025-10-31 11:42:28 +00:00 
			
		
		
		
	Merge branch 'unstable' of https://git01.codeplex.com/z3 into unstable
This commit is contained in:
		
						commit
						ab761c4c32
					
				
					 5 changed files with 32 additions and 70 deletions
				
			
		|  | @ -325,9 +325,20 @@ namespace datalog { | ||||||
|         return res; |         return res; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     /**
 | ||||||
|  |        \brief Default method for complementation. | ||||||
|  | 
 | ||||||
|  |        It assumes that the compiler creates only tables with | ||||||
|  |        at most one column (0 or 1 columns).        | ||||||
|  |        Complementation of tables with more than one columns | ||||||
|  |        is transformed into a cross product of complements and/or | ||||||
|  |        difference.  | ||||||
|  | 
 | ||||||
|  |      */ | ||||||
|     table_base * table_base::complement(func_decl* p, const table_element * func_columns) const { |     table_base * table_base::complement(func_decl* p, const table_element * func_columns) const { | ||||||
|         const table_signature & sig = get_signature(); |         const table_signature & sig = get_signature(); | ||||||
|         SASSERT(sig.functional_columns()==0 || func_columns!=0); |         SASSERT(sig.functional_columns()==0 || func_columns!=0); | ||||||
|  |         SASSERT(sig.first_functional() <= 1); | ||||||
| 
 | 
 | ||||||
|         table_base * res = get_plugin().mk_empty(sig); |         table_base * res = get_plugin().mk_empty(sig); | ||||||
| 
 | 
 | ||||||
|  | @ -335,16 +346,14 @@ namespace datalog { | ||||||
|         fact.resize(sig.first_functional()); |         fact.resize(sig.first_functional()); | ||||||
|         fact.append(sig.functional_columns(), func_columns); |         fact.append(sig.functional_columns(), func_columns); | ||||||
| 
 | 
 | ||||||
|         if(sig.first_functional()==0) { |         if (sig.first_functional() == 0) { | ||||||
|             if(empty()) { |             if (empty()) { | ||||||
|                 res->add_fact(fact); |                 res->add_fact(fact); | ||||||
|             } |             } | ||||||
|             return res; |             return res; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if(sig.first_functional()!=1) { //now we support only tables with one non-functional column
 |         VERIFY(sig.first_functional() == 1); | ||||||
|             NOT_IMPLEMENTED_YET(); |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         uint64 upper_bound = get_signature()[0]; |         uint64 upper_bound = get_signature()[0]; | ||||||
|         bool empty_table = empty(); |         bool empty_table = empty(); | ||||||
|  | @ -356,51 +365,13 @@ namespace datalog { | ||||||
|             warning_msg(buffer.str().c_str()); |             warning_msg(buffer.str().c_str()); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         for(table_element i=0; i<upper_bound; i++) { |         for(table_element i = 0; i < upper_bound; i++) { | ||||||
|             fact[0]=i; |             fact[0] = i; | ||||||
|             if(empty_table || !contains_fact(fact)) { |             if(empty_table || !contains_fact(fact)) { | ||||||
|                 res->add_fact(fact); |                 res->add_fact(fact); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         return res; |         return res; | ||||||
| #if 0 |  | ||||||
|         svector<unsigned> var_arg_indexes(arity); |  | ||||||
|         var_arg_indexes.fill(0); |  | ||||||
| 
 |  | ||||||
|         svector<unsigned> var_arg_domain_sizes = s; |  | ||||||
| 
 |  | ||||||
|         unsigned var_cnt=var_arg_indexes.size(); |  | ||||||
|         table_fact fact; |  | ||||||
|         fact.resize(arity); |  | ||||||
|         fact.fill(0); |  | ||||||
|         unsigned depth=arity; |  | ||||||
| 
 |  | ||||||
|         while(true) { |  | ||||||
|             if(depth==arity) { |  | ||||||
|                 SASSERT(!res->contains_fact(fact)); |  | ||||||
|                 if(empty_table || !contains_fact(fact)) { |  | ||||||
|                     res->add_fact(fact); |  | ||||||
|                 } |  | ||||||
|                 depth--; |  | ||||||
|             } |  | ||||||
|             else if(fact[depth]==s[depth]-1) { |  | ||||||
|                 val_indexes[depth]=0; |  | ||||||
|                 if(depth==0) { |  | ||||||
|                     break; |  | ||||||
|                 } |  | ||||||
|                 depth--; |  | ||||||
|             } |  | ||||||
|             else { |  | ||||||
|                 SASSERT(val_indexes[depth]<var_arg_domain_sizes[depth]); |  | ||||||
|                 unsigned arg_idx = var_arg_indexes[depth]; |  | ||||||
|                 unsigned val_idx = val_indexes[depth]++; |  | ||||||
|                 head_args[arg_idx]=ctx.get_arith().mk_numeral(rational(val_idx), true); |  | ||||||
|                 depth++; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         return res; |  | ||||||
| #endif |  | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     void table_base::display(std::ostream & out) const { |     void table_base::display(std::ostream & out) const { | ||||||
|  | @ -468,23 +439,21 @@ namespace datalog { | ||||||
|         expr_ref_vector disjs(m); |         expr_ref_vector disjs(m); | ||||||
|         expr_ref_vector conjs(m); |         expr_ref_vector conjs(m); | ||||||
|         dl_decl_util util(m); |         dl_decl_util util(m); | ||||||
|  |         bool_rewriter brw(m); | ||||||
|         table_fact fact; |         table_fact fact; | ||||||
|         iterator it = begin(); |         iterator it = begin(); | ||||||
|         iterator iend = end(); |         iterator iend = end(); | ||||||
|         for(; it!=iend; ++it) { |         for(; it != iend; ++it) { | ||||||
|             const row_interface & r = *it;    |             const row_interface & r = *it;    | ||||||
|             r.get_fact(fact); |             r.get_fact(fact); | ||||||
|             conjs.reset(); |             conjs.reset(); | ||||||
|             for (unsigned i = 0; i < fact.size(); ++i) { |             for (unsigned i = 0; i < fact.size(); ++i) { | ||||||
|                 conjs.push_back(m.mk_eq(m.mk_var(i, sig[i]), util.mk_numeral(fact[i], sig[i]))); |                 conjs.push_back(m.mk_eq(m.mk_var(i, sig[i]), util.mk_numeral(fact[i], sig[i]))); | ||||||
|             } |             } | ||||||
|             switch(conjs.size()) { |             brw.mk_and(conjs.size(), conjs.c_ptr(), fml); | ||||||
|             case 0: disjs.push_back(m.mk_true()); break; |             disjs.push_back(fml); | ||||||
|             case 1: disjs.push_back(conjs[0].get()); break; |  | ||||||
|             default: disjs.push_back(m.mk_and(conjs.size(), conjs.c_ptr())); break; |  | ||||||
|             } |  | ||||||
|         } |         } | ||||||
|         bool_rewriter(m).mk_or(disjs.size(), disjs.c_ptr(), fml);         |         brw.mk_or(disjs.size(), disjs.c_ptr(), fml);         | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -325,7 +325,6 @@ namespace datalog { | ||||||
|         TRACE("dl", m_hb.display(tout);); |         TRACE("dl", m_hb.display(tout);); | ||||||
|         SASSERT(is_sat == l_true); |         SASSERT(is_sat == l_true); | ||||||
|         unsigned basis_size = m_hb.get_basis_size(); |         unsigned basis_size = m_hb.get_basis_size(); | ||||||
|         bool first_initial = true; |  | ||||||
|         for (unsigned i = 0; i < basis_size; ++i) { |         for (unsigned i = 0; i < basis_size; ++i) { | ||||||
|             bool is_initial; |             bool is_initial; | ||||||
|             vector<rational> soln; |             vector<rational> soln; | ||||||
|  | @ -378,7 +377,6 @@ namespace datalog { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     void mk_karr_invariants::update_body(rule_set& rules, rule& r){ |     void mk_karr_invariants::update_body(rule_set& rules, rule& r){ | ||||||
|         func_decl* p = r.get_decl();         |  | ||||||
|         unsigned utsz = r.get_uninterpreted_tail_size(); |         unsigned utsz = r.get_uninterpreted_tail_size(); | ||||||
|         unsigned tsz  = r.get_tail_size(); |         unsigned tsz  = r.get_tail_size(); | ||||||
|         app_ref_vector tail(m); |         app_ref_vector tail(m); | ||||||
|  |  | ||||||
|  | @ -243,15 +243,14 @@ namespace datalog { | ||||||
| 
 | 
 | ||||||
|     relation_plugin & relation_manager::get_appropriate_plugin(const relation_signature & s) { |     relation_plugin & relation_manager::get_appropriate_plugin(const relation_signature & s) { | ||||||
|         relation_plugin * res = try_get_appropriate_plugin(s); |         relation_plugin * res = try_get_appropriate_plugin(s); | ||||||
|         if(!res) { |         if (!res) { | ||||||
|             throw default_exception("no suitable plugin found for given relation signature"); |             throw default_exception("no suitable plugin found for given relation signature"); | ||||||
|             throw 0; |  | ||||||
|         } |         } | ||||||
|         return *res; |         return *res; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     table_plugin * relation_manager::try_get_appropriate_plugin(const table_signature & t) { |     table_plugin * relation_manager::try_get_appropriate_plugin(const table_signature & t) { | ||||||
|         if(m_favourite_table_plugin && m_favourite_table_plugin->can_handle_signature(t)) { |         if (m_favourite_table_plugin && m_favourite_table_plugin->can_handle_signature(t)) { | ||||||
|             return m_favourite_table_plugin; |             return m_favourite_table_plugin; | ||||||
|         } |         } | ||||||
|         table_plugin_vector::iterator tpit = m_table_plugins.begin(); |         table_plugin_vector::iterator tpit = m_table_plugins.begin(); | ||||||
|  | @ -346,7 +345,7 @@ namespace datalog { | ||||||
|             return p->mk_empty(s); |             return p->mk_empty(s); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if(mk_empty_table_relation(s, res)) { |         if (mk_empty_table_relation(s, res)) { | ||||||
|             return res; |             return res; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | @ -884,10 +883,10 @@ namespace datalog { | ||||||
|             SASSERT(plugin->can_handle_signature(res_sign)); |             SASSERT(plugin->can_handle_signature(res_sign)); | ||||||
|             table_base * res = plugin->mk_empty(res_sign); |             table_base * res = plugin->mk_empty(res_sign); | ||||||
| 
 | 
 | ||||||
|             unsigned t1cols=t1.get_signature().size(); |             unsigned t1cols = t1.get_signature().size(); | ||||||
|             unsigned t2cols=t2.get_signature().size(); |             unsigned t2cols = t2.get_signature().size(); | ||||||
|             unsigned t1first_func=t1.get_signature().first_functional(); |             unsigned t1first_func = t1.get_signature().first_functional(); | ||||||
|             unsigned t2first_func=t2.get_signature().first_functional(); |             unsigned t2first_func = t2.get_signature().first_functional(); | ||||||
| 
 | 
 | ||||||
|             table_base::iterator els1it = t1.begin(); |             table_base::iterator els1it = t1.begin(); | ||||||
|             table_base::iterator els1end = t1.end(); |             table_base::iterator els1end = t1.end(); | ||||||
|  |  | ||||||
|  | @ -169,7 +169,6 @@ class horn_tactic : public tactic { | ||||||
|             SASSERT(g->is_well_sorted()); |             SASSERT(g->is_well_sorted()); | ||||||
|             mc = 0; pc = 0; core = 0; |             mc = 0; pc = 0; core = 0; | ||||||
|             tactic_report report("horn", *g); |             tactic_report report("horn", *g); | ||||||
|             bool produce_models = g->models_enabled(); |  | ||||||
|             bool produce_proofs = g->proofs_enabled(); |             bool produce_proofs = g->proofs_enabled(); | ||||||
| 
 | 
 | ||||||
|             if (produce_proofs) { |             if (produce_proofs) { | ||||||
|  |  | ||||||
|  | @ -31,9 +31,6 @@ Revision History: | ||||||
| #include"dl_sparse_table.h" | #include"dl_sparse_table.h" | ||||||
| #include"dl_table.h" | #include"dl_table.h" | ||||||
| #include"dl_table_relation.h" | #include"dl_table_relation.h" | ||||||
| #ifndef _EXTERNAL_RELEASE |  | ||||||
| #include"dl_skip_table.h" |  | ||||||
| #endif |  | ||||||
| 
 | 
 | ||||||
| namespace datalog { | namespace datalog { | ||||||
|     |     | ||||||
|  | @ -44,16 +41,16 @@ namespace datalog { | ||||||
|           m_answer(m),  |           m_answer(m),  | ||||||
|           m_cancel(false),  |           m_cancel(false),  | ||||||
|           m_last_result_relation(0) { |           m_last_result_relation(0) { | ||||||
|  | 
 | ||||||
|  |         // register plugins for builtin tables
 | ||||||
|  | 
 | ||||||
|         get_rmanager().register_plugin(alloc(sparse_table_plugin, get_rmanager())); |         get_rmanager().register_plugin(alloc(sparse_table_plugin, get_rmanager())); | ||||||
|         get_rmanager().register_plugin(alloc(hashtable_table_plugin, get_rmanager())); |         get_rmanager().register_plugin(alloc(hashtable_table_plugin, get_rmanager())); | ||||||
|         get_rmanager().register_plugin(alloc(bitvector_table_plugin, get_rmanager())); |         get_rmanager().register_plugin(alloc(bitvector_table_plugin, get_rmanager())); | ||||||
|         get_rmanager().register_plugin(alloc(equivalence_table_plugin, get_rmanager())); |         get_rmanager().register_plugin(alloc(equivalence_table_plugin, get_rmanager())); | ||||||
| 
 | 
 | ||||||
| #ifndef _EXTERNAL_RELEASE |  | ||||||
|         get_rmanager().register_plugin(alloc(skip_table_plugin, get_rmanager())); |  | ||||||
| #endif |  | ||||||
| 
 | 
 | ||||||
|         //register plugins for builtin relations
 |         // register plugins for builtin relations
 | ||||||
| 
 | 
 | ||||||
|         get_rmanager().register_plugin(alloc(bound_relation_plugin, get_rmanager())); |         get_rmanager().register_plugin(alloc(bound_relation_plugin, get_rmanager())); | ||||||
|         get_rmanager().register_plugin(alloc(interval_relation_plugin, get_rmanager())); |         get_rmanager().register_plugin(alloc(interval_relation_plugin, get_rmanager())); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue