rule_set * mk_coalesce::operator()(rule_set const & source, model_converter_ref& mc, proof_converter_ref& pc) {
     m_pc = 0;
     ref<replace_proof_converter> rpc;
     if (pc) {
         rpc = alloc(replace_proof_converter, m);
         m_pc = rpc.get();
     }
     rule_set* rules = alloc(rule_set, m_ctx);
     rule_set::decl2rules::iterator it = source.begin_grouped_rules(), end = source.end_grouped_rules();
     for (; it != end; ++it) {
         rule_ref_vector d_rules(rm);
         d_rules.append(it->m_value->size(), it->m_value->c_ptr());
         for (unsigned i = 0; i < d_rules.size(); ++i) {
             rule_ref r1(d_rules[i].get(), rm);
             for (unsigned j = i + 1; j < d_rules.size(); ++j) {
                 if (same_body(*r1.get(), *d_rules[j].get())) {
                     merge_rules(r1, *d_rules[j].get());
                     d_rules[j] = d_rules.back();
                     d_rules.pop_back();
                     --j;
                 }
             }
             rules->add_rule(r1.get());
         }
     }
     if (pc) {
         pc = concat(pc.get(), rpc.get());
     }
     return rules;
 }
Beispiel #2
0
    void mk_coalesce::merge_rules(rule_ref& tgt, rule const& src) {
        SASSERT(same_body(*tgt.get(), src));
        m_sub1.reset();
        m_sub2.reset();
        m_idx = 0;
        app_ref pred(m), head(m);
        expr_ref fml1(m), fml2(m), fml(m);
        app_ref_vector tail(m);
        ptr_vector<sort> sorts1, sorts2;
        expr_ref_vector conjs1(m), conjs(m);
        rule_ref res(rm);
        bool_rewriter bwr(m);
        svector<bool> is_neg;
        tgt->get_vars(sorts1);
        src.get_vars(sorts2);

        mk_pred(head, src.get_head(), tgt->get_head()); 
        for (unsigned i = 0; i < src.get_uninterpreted_tail_size(); ++i) {
            mk_pred(pred, src.get_tail(i), tgt->get_tail(i));
            tail.push_back(pred);
            is_neg.push_back(src.is_neg_tail(i));
        }           
        extract_conjs(m_sub1, src, fml1);
        extract_conjs(m_sub2, *tgt.get(),  fml2);
        bwr.mk_or(fml1, fml2, fml);
        SASSERT(is_app(fml));
        tail.push_back(to_app(fml));
        is_neg.push_back(false);
        res = rm.mk(head, tail.size(), tail.c_ptr(), is_neg.c_ptr(), tgt->name());
        if (m_ctx.generate_proof_trace()) {
            src.to_formula(fml1);
            tgt->to_formula(fml2);
            res->to_formula(fml);
#if 0
            sort* ps = m.mk_proof_sort();
            sort* domain[3] = { ps, ps, m.mk_bool_sort() };
            func_decl* merge = m.mk_func_decl(symbol("merge-clauses"), 3, domain, ps);  // TBD: ad-hoc proof rule
            expr* args[3] = { m.mk_asserted(fml1), m.mk_asserted(fml2), fml };
            // ...m_pc->insert(m.mk_app(merge, 3, args));
#else
            svector<std::pair<unsigned, unsigned> > pos;
            vector<expr_ref_vector> substs;
            proof* p = src.get_proof();
            p = m.mk_hyper_resolve(1, &p, fml, pos, substs);
            res->set_proof(m, p);
#endif
        }
        tgt = res;
    }
Beispiel #3
0
 rule_set * mk_coalesce::operator()(rule_set const & source) {
     rule_set* rules = alloc(rule_set, m_ctx);
     rules->inherit_predicates(source);
     rule_set::decl2rules::iterator it = source.begin_grouped_rules(), end = source.end_grouped_rules();
     for (; it != end; ++it) {
         rule_ref_vector d_rules(rm);
         d_rules.append(it->m_value->size(), it->m_value->c_ptr());
         for (unsigned i = 0; i < d_rules.size(); ++i) {
             rule_ref r1(d_rules[i].get(), rm);
             for (unsigned j = i + 1; j < d_rules.size(); ++j) {
                 if (same_body(*r1.get(), *d_rules[j].get())) {
                     merge_rules(r1, *d_rules[j].get());
                     d_rules[j] = d_rules.back();
                     d_rules.pop_back();
                     --j;
                 }
             }
             rules->add_rule(r1.get());
         }
     }
     return rules;
 }