Ejemplo n.º 1
0
void contractor_int::prune(contractor_status & cs) {
    DREAL_LOG_DEBUG << "contractor_int::prune";
    if (m_input.empty()) {
        return;
    }
    // ======= Proof =======
    thread_local static box old_box(cs.m_box);
    if (cs.m_config.nra_proof) { old_box = cs.m_box; }
    unsigned i = 0;
    ibex::IntervalVector & iv = cs.m_box.get_values();
    for (Enode * e : cs.m_box.get_vars()) {
        if (e->hasSortInt()) {
            thread_local static ibex::Interval old_iv(iv[i]);
            old_iv = iv[i];
            iv[i] = ibex::integer(iv[i]);
            if (old_iv != iv[i]) {
                cs.m_output.add(i);
            }
            if (iv[i].is_empty()) {
                cs.m_box.set_empty();
                break;
            }
        }
        i++;
    }
    // ======= Proof =======
    if (cs.m_config.nra_proof) {
        output_pruning_step(old_box, cs, "integer pruning");
    }
    return;
}
Ejemplo n.º 2
0
void contractor_ibex_polytope::prune(contractor_status & cs) {
    DREAL_LOG_DEBUG << "contractor_ibex_polytope::prune";
    if (!m_ctc) {
        return;
    }
    DREAL_THREAD_LOCAL static box old_box(cs.m_box);
    old_box = cs.m_box;
    m_ctc->contract(cs.m_box.get_values());
    // setup output
    vector<bool> diff_dims = cs.m_box.diff_dims(old_box);
    for (unsigned i = 0; i < diff_dims.size(); i++) {
        if (diff_dims[i]) {
            cs.m_output.add(i);
        }
    }
    if (!diff_dims.empty()) {
        cs.m_used_constraints.insert(m_ctrs.begin(), m_ctrs.end());
    }

    // ======= Proof =======
    if (cs.m_config.nra_proof) {
        DREAL_THREAD_LOCAL static ostringstream ss;
        for (auto const & ctr : m_ctrs) {
            Enode const * const e = ctr->get_enode();
            ss << (e->getPolarity() == l_False ? "!" : "") << e << ";";
        }
        output_pruning_step(old_box, cs, ss.str());
        ss.str(string());
    }
    return;
}
Ejemplo n.º 3
0
box contractor_int::prune(box b, SMTConfig & config) const {
    // ======= Proof =======
    thread_local static box old_box(b);
    if (config.nra_proof) { old_box = b; }

    m_input  = ibex::BitSet::empty(b.size());
    m_output = ibex::BitSet::empty(b.size());
    unsigned i = 0;
    ibex::IntervalVector & iv = b.get_values();
    for (Enode * e : b.get_vars()) {
        if (e->hasSortInt()) {
            auto old_iv = iv[i];
            iv[i] = ibex::integer(iv[i]);
            if (old_iv != iv[i]) {
                m_input.add(i);
                m_output.add(i);
            }
            if (iv[i].is_empty()) {
                b.set_empty();
                break;
            }
        }
        i++;
    }

    // ======= Proof =======
    if (config.nra_proof) {
        output_pruning_step(config.nra_proof_out, old_box, b, config.nra_readable_proof, "integer pruning");
    }
    return b;
}
Ejemplo n.º 4
0
void contractor_ibex_fwdbwd::prune(contractor_status & cs) {
    DREAL_LOG_DEBUG << "contractor_ibex_fwdbwd::prune";
    auto ctc = get_ctc(std::this_thread::get_id(), true);
    if (!ctc) {
        return;
    }

    DREAL_THREAD_LOCAL static box old_box(cs.m_box);
    if (cs.m_config.nra_proof) {
        old_box = cs.m_box;
    }
    if (m_numctr->f.nb_arg() == 0) {
        auto eval_result = m_ctr->eval(cs.m_box);
        if (eval_result.first == l_False) {
            cs.m_box.set_empty();
            return;
        } else {
            return;
        }
    }
    DREAL_THREAD_LOCAL static ibex::IntervalVector old_iv(cs.m_box.get_values());
    old_iv = cs.m_box.get_values();
    assert(m_numctr->f.nb_arg() >= 0 &&
           static_cast<unsigned>(m_numctr->f.nb_arg()) <= cs.m_box.size());
    DREAL_LOG_DEBUG << "Before pruning using ibex_fwdbwd(" << *m_numctr << ")";
    DREAL_LOG_DEBUG << cs.m_box;
    DREAL_LOG_DEBUG << "ibex interval = " << cs.m_box.get_values() << " (before)";
    DREAL_LOG_DEBUG << "function = " << ctc->f;
    DREAL_LOG_DEBUG << "domain   = " << ctc->d;
    ctc->contract(cs.m_box.get_values());
    DREAL_LOG_DEBUG << "ibex interval = " << cs.m_box.get_values() << " (after)";
    // cerr << output.empty() << used_constraints.empty() << " ";
    auto & new_iv = cs.m_box.get_values();
    bool changed = false;
    for (unsigned i = 0; i < cs.m_box.size(); ++i) {
        if (get_input().contain(i) && old_iv[i] != new_iv[i]) {
            cs.m_output.add(i);
            changed = true;
        }
    }
    if (changed || cs.m_box.is_empty()) {
        // only add used_constraints if there is any change
        cs.m_used_constraints.insert(m_ctr);
    }
    DREAL_LOG_DEBUG << "After pruning using ibex_fwdbwd(" << *m_numctr << ")";
    DREAL_LOG_DEBUG << cs.m_box;
    if (cs.m_config.nra_proof) {
        // ======= Proof =======
        DREAL_THREAD_LOCAL static ostringstream ss;
        Enode const * const e = m_ctr->get_enode();
        ss << (e->getPolarity() == l_False ? "!" : "") << e;
        output_pruning_step(old_box, cs, ss.str());
        ss.str(string());
    }
    return;
}
Ejemplo n.º 5
0
void contractor_ibex_newton::prune(contractor_status & cs) {
    DREAL_LOG_DEBUG << "contractor_ibex_newton::prune";
    if (!m_ctc) {
        return;
    }

    // ======= Proof =======
    DREAL_THREAD_LOCAL static box old_box(cs.m_box);
    if (cs.m_config.nra_proof) {
        old_box = cs.m_box;
    }
    if (m_var_array.size() == 0) {
        auto eval_result = m_ctr->eval(cs.m_box);
        if (eval_result.first == l_False) {
            cs.m_box.set_empty();
            return;
        } else {
            return;
        }
    }
    assert(m_var_array.size() - cs.m_box.size() == 0);
    DREAL_LOG_DEBUG << "Before pruning using ibex_newton(" << *m_numctr << ")";
    DREAL_LOG_DEBUG << cs.m_box;
    DREAL_LOG_DEBUG << "ibex interval = " << cs.m_box.get_values() << " (before)";
    DREAL_LOG_DEBUG << "function = " << m_ctc->f;
    m_ctc->contract(cs.m_box.get_values());
    DREAL_LOG_DEBUG << "ibex interval = " << cs.m_box.get_values() << " (after)";
    // Set up output
    ibex::BitSet const * const ctc_output = m_ctc->output;
    bool changed = false;
    for (int i = ctc_output->min(); i <= ctc_output->max(); i++) {
        if ((*ctc_output)[i]) {
            cs.m_output.add(cs.m_box.get_index(m_var_array[i].name));
            changed = true;
        }
    }
    if (changed) {
        // only add used_constraints if there is any change
        cs.m_used_constraints.insert(m_ctr);
    }
    DREAL_LOG_DEBUG << "After pruning using ibex_newton(" << *m_numctr << ")";
    DREAL_LOG_DEBUG << cs.m_box;

    // ======= Proof =======
    if (cs.m_config.nra_proof) {
        DREAL_THREAD_LOCAL static ostringstream ss;
        Enode const * const e = m_ctr->get_enode();
        ss << (e->getPolarity() == l_False ? "!" : "") << e;
        output_pruning_step(old_box, cs, ss.str());
        ss.str(string());
    }
    return;
}
Ejemplo n.º 6
0
box contractor_eval::prune(box b, SMTConfig & config) const {
    pair<lbool, ibex::Interval> eval_result = m_nl_ctr->eval(b);
    if (eval_result.first == l_False) {
        // ======= Proof =======
        if (config.nra_proof) {
            box old_box = b;
            b.set_empty();
            stringstream ss;
            Enode const * const e = m_nl_ctr->get_enode();
            ss << (e->getPolarity() == l_False ? "!" : "") << e;
            output_pruning_step(config.nra_proof_out, old_box, b, config.nra_readable_proof, ss.str());
        } else {
            b.set_empty();
        }
        m_used_constraints.insert(m_nl_ctr);
    }
    return b;
}
Ejemplo n.º 7
0
void contractor_eval::prune(contractor_status & cs) {
    DREAL_LOG_DEBUG << "contractor_eval::prune";
    pair<lbool, ibex::Interval> eval_result = m_nl_ctr->eval(cs.m_box);
    if (eval_result.first == l_False) {
        // ======= Proof =======
        if (cs.m_config.nra_proof) {
            box const old_box = cs.m_box;
            cs.m_box.set_empty();
            ostringstream ss;
            Enode const * const e = m_nl_ctr->get_enode();
            ss << (e->getPolarity() == l_False ? "!" : "") << e;
            output_pruning_step(old_box, cs, ss.str());
        } else {
            cs.m_box.set_empty();
            cs.m_output.fill();
        }
        cs.m_used_constraints.insert(m_nl_ctr);
    }
    return;
}