3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-09-04 00:58:07 +00:00

reorganization of rule_set structure

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2013-04-08 13:50:56 -07:00
parent 5915533170
commit 8f46179def
65 changed files with 778 additions and 10668 deletions

View file

@ -21,11 +21,8 @@ Revision History:
#include <sstream>
#include"ast_pp.h"
#include "rewriter.h"
#include "rewriter_def.h"
#include"dl_mk_subsumption_checker.h"
#include"dl_table_relation.h"
@ -82,7 +79,7 @@ namespace datalog {
void mk_subsumption_checker::on_discovered_total_relation(func_decl * pred, rule * r) {
//this should be rule marking a new relation as total
SASSERT(!m_total_relations.contains(pred));
SASSERT(!r || pred==r->get_head()->get_decl());
SASSERT(!r || pred==r->get_decl());
SASSERT(!r || is_total_rule(r));
m_total_relations.insert(pred);
@ -102,7 +99,7 @@ namespace datalog {
rule_set::iterator rend = rules.end();
for(rule_set::iterator rit = rules.begin(); rit!=rend; ++rit) {
rule * r = *rit;
func_decl * head_pred = r->get_head()->get_decl();
func_decl * head_pred = r->get_decl();
if(is_total_rule(r) && !m_total_relations.contains(head_pred)) {
on_discovered_total_relation(head_pred, r);
new_discovered = true;
@ -196,10 +193,10 @@ namespace datalog {
for(rule_set::iterator rit = rbegin; rit!=rend; ++rit) {
rule * r = *rit;
func_decl * head_pred = r->get_head()->get_decl();
func_decl * head_pred = r->get_decl();
if(m_total_relations.contains(head_pred)) {
if(!m_context.is_output_predicate(head_pred) ||
if(!orig.is_output_predicate(head_pred) ||
total_relations_with_included_rules.contains(head_pred)) {
//We just skip definitions of total non-output relations as
//we'll eliminate them from the problem.
@ -217,7 +214,7 @@ namespace datalog {
modified = true;
}
tgt.add_rule(totality_rule);
SASSERT(totality_rule->get_head()->get_decl()==head_pred);
SASSERT(totality_rule->get_decl()==head_pred);
}
else {
modified = true;
@ -250,24 +247,23 @@ namespace datalog {
return modified;
}
void mk_subsumption_checker::scan_for_relations_total_due_to_facts() {
void mk_subsumption_checker::scan_for_relations_total_due_to_facts(rule_set const& source) {
relation_manager& rm = m_context.get_rel_context().get_rmanager();
decl_set candidate_preds;
m_context.collect_predicates(candidate_preds);
decl_set const& candidate_preds = m_context.get_predicates();
decl_set::iterator end = candidate_preds.end();
for(decl_set::iterator it = candidate_preds.begin(); it!=end; ++it) {
func_decl * pred = *it;
if(m_total_relations.contains(pred)) { continue; } //already total
if (m_total_relations.contains(pred)) { continue; } //already total
relation_base * rel = rm.try_get_relation(pred);
if(!rel || !rel->knows_exact_size()) { continue; }
if (!rel || !rel->knows_exact_size()) { continue; }
unsigned arity = pred->get_arity();
if(arity>30) { continue; }
if (arity > 30) { continue; }
//for now we only check booleans domains
for(unsigned i=0; i<arity; i++) {
@ -307,7 +303,7 @@ namespace datalog {
rule_set::iterator rend = rules.end();
for(rule_set::iterator rit = rules.begin(); rit!=rend; ++rit) {
rule * r = *rit;
func_decl * pred = r->get_head()->get_decl();
func_decl * pred = r->get_decl();
if(r->get_tail_size()!=0) { continue; }
@ -337,7 +333,7 @@ namespace datalog {
m_have_new_total_rule = false;
collect_ground_unconditional_rule_heads(source);
scan_for_relations_total_due_to_facts();
scan_for_relations_total_due_to_facts(source);
scan_for_total_rules(source);
m_have_new_total_rule = false;
@ -361,6 +357,7 @@ namespace datalog {
transform_rules(*old, *res);
dealloc(old);
}
res->inherit_predicates(source);
return res;
}