예제 #1
0
PropResult HyperEngine::prop_tri_clause_with_acestor_info(
    watch_subarray_const::const_iterator i
    , const Lit lit1
    , PropBy& confl
) {
    const Lit lit2 = i->lit2();
    lbool val2 = value(lit2);

    //literal is already satisfied, nothing to do
    if (val2 == l_True)
        return PROP_NOTHING;

    const Lit lit3 = i->lit3();
    lbool val3 = value(lit3);

    //literal is already satisfied, nothing to do
    if (val3 == l_True)
        return PROP_NOTHING;

    if (val2 == l_False && val3 == l_False) {
        return handle_prop_tri_fail(i, lit1, confl);
    }

    if (val2 == l_Undef && val3 == l_False) {
        return propTriHelperComplex(lit2, ~lit1, lit3, i->red());
    }

    if (val3 == l_Undef && val2 == l_False) {
        return propTriHelperComplex(lit3, ~lit1,  lit2, i->red());
    }

    return PROP_NOTHING;
}
예제 #2
0
inline bool PropEngine::propTriClauseAnyOrder(
    watch_subarray_const::const_iterator i
    , const Lit lit1
    , PropBy& confl
) {
    const Lit lit2 = i->lit2();
    lbool val2 = value(lit2);

    //literal is already satisfied, nothing to do
    if (val2 == l_True)
        return true;

    const Lit lit3 = i->lit3();
    lbool val3 = value(lit3);

    //literal is already satisfied, nothing to do
    if (val3 == l_True)
        return true;

    if (val2 == l_False && val3 == l_False) {
        #ifdef VERBOSE_DEBUG_FULLPROP
        cout << "Conflict from "
            << lit1 << " , "
            << i->lit2() << " , "
            << i->lit3() << endl;
        #endif //VERBOSE_DEBUG_FULLPROP
        confl = PropBy(~lit1, i->lit3(), i->red());

        //Update stats
        if (i->red())
            lastConflictCausedBy = ConflCausedBy::trired;
        else
            lastConflictCausedBy = ConflCausedBy::triirred;

        failBinLit = i->lit2();
        qhead = trail.size();
        return false;
    }
    if (val2 == l_Undef && val3 == l_False) {
        propTriHelperAnyOrder<update_bogoprops>(
            lit1
            , lit2
            , lit3
            , i->red()
        );
        return true;
    }

    if (val3 == l_Undef && val2 == l_False) {
        propTriHelperAnyOrder<update_bogoprops>(
            lit1
            , lit3
            , lit2
            , i->red()
        );
        return true;
    }

    return true;
}
예제 #3
0
inline bool PropEngine::propBinaryClause(
    watch_subarray_const::const_iterator i
    , const Lit p
    , PropBy& confl
) {
    const lbool val = value(i->lit2());
    if (val == l_Undef) {
        #ifdef STATS_NEEDED
        if (i->red())
            propStats.propsBinRed++;
        else
            propStats.propsBinIrred++;
        #endif

        enqueue<update_bogoprops>(i->lit2(), PropBy(~p, i->red()));
    } else if (val == l_False) {
        //Update stats
        if (i->red())
            lastConflictCausedBy = ConflCausedBy::binred;
        else
            lastConflictCausedBy = ConflCausedBy::binirred;

        confl = PropBy(~p, i->red());
        failBinLit = i->lit2();
        qhead = trail.size();
        return false;
    }

    return true;
}
inline bool SolutionExtender::propBinaryClause(
    watch_subarray_const::const_iterator i
    , const Lit p
) {
    const lbool val = value(i->lit2());
    if (val == l_Undef) {
        #ifdef VERBOSE_DEBUG_RECONSTRUCT
        cout
        << "c Due to cl "
        << ~p << ", " << i->lit2()
        << " propagate enqueueing "
        << i->lit2() << endl;
        #endif
        enqueue(i->lit2());
    } else if (val == l_False){
        return false;
    }

    return true;
}
예제 #5
0
inline PropResult PropEngine::propNormalClause(
    watch_subarray_const::const_iterator i
    , watch_subarray::iterator &j
    , const Lit p
    , PropBy& confl
) {
    //Blocked literal is satisfied, so clause is satisfied
    if (value(i->getBlockedLit()) == l_True) {
        *j++ = *i;
        return PROP_NOTHING;
    }

    //Dereference pointer
    propStats.bogoProps += 4;
    const ClOffset offset = i->get_offset();
    Clause& c = *cl_alloc.ptr(offset);

    PropResult ret = prop_normal_helper(c, offset, j, p);
    if (ret != PROP_TODO)
        return ret;

    // Did not find watch -- clause is unit under assignment:
    *j++ = *i;
    if (value(c[0]) == l_False) {
        return handle_normal_prop_fail(c, offset, confl);
    }

    //Update stats
    #ifdef STATS_NEEDED
    c.stats.propagations_made++;
    if (c.red())
        propStats.propsLongRed++;
    else
        propStats.propsLongIrred++;
    #endif

    enqueue(c[0], PropBy(offset));
    update_glue(c);

    return PROP_SOMETHING;
}
inline bool SolutionExtender::propTriClause(
    watch_subarray_const::const_iterator i
    , const Lit p
) {
    const Lit lit2 = i->lit2();
    lbool val2 = value(lit2);

    //literal is already satisfied, nothing to do
    if (val2 == l_True)
        return true;

    const Lit lit3 = i->lit3();
    lbool val3 = value(lit3);

    //literal is already satisfied, nothing to do
    if (val3 == l_True)
        return true;

    if (val2 == l_False && val3 == l_False) {
        return false;
    }
    if (val2 == l_Undef && val3 == l_False) {
        #ifdef VERBOSE_DEBUG_RECONSTRUCT
        cout
        << "c Due to cl "
        << ~p << ", "
        << i->lit2() << ", "
        << i->lit3()
        << " propagate enqueueing "
        << lit2 << endl;
        #endif
        enqueue(lit2);
        return true;
    }

    if (val3 == l_Undef && val2 == l_False) {
        #ifdef VERBOSE_DEBUG_RECONSTRUCT
        cout
        << "c Due to cl "
        << ~p << ", "
        << i->lit2() << ", "
        << i->lit3()
        << " propagate enqueueing "
        << lit3 << endl;
        #endif
        enqueue(lit3);
        return true;
    }

    return true;
}
예제 #7
0
PropResult PropEngine::handle_prop_tri_fail(
    watch_subarray_const::const_iterator i
    , Lit lit1
    , PropBy& confl
) {
    #ifdef VERBOSE_DEBUG_FULLPROP
    cout << "Conflict from "
        << lit1 << " , "
        << i->lit2() << " , "
        << i->lit3() << endl;
    #endif //VERBOSE_DEBUG_FULLPROP
    confl = PropBy(~lit1, i->lit3(), i->red());

    //Update stats
    if (i->red())
        lastConflictCausedBy = ConflCausedBy::trired;
    else
        lastConflictCausedBy = ConflCausedBy::triirred;

    failBinLit = i->lit2();
    qhead = trail.size();
    return PROP_FAIL;
}
예제 #8
0
inline
bool PropEngine::propNormalClauseAnyOrder(
    watch_subarray_const::const_iterator i
    , watch_subarray::iterator &j
    , const Lit p
    , PropBy& confl
) {
    //Blocked literal is satisfied, so clause is satisfied
    const Lit blocker = i->getBlockedLit();
    if (value(blocker) == l_True) {
        *j++ = *i;
        return true;
    }
    if (update_bogoprops) {
        propStats.bogoProps += 4;
    }
    const ClOffset offset = i->get_offset();
    Clause& c = *cl_alloc.ptr(offset);

    #ifdef SLOW_DEBUG
    assert(!c.getRemoved());
    assert(!c.freed());
    #endif

    #ifdef STATS_NEEDED
    c.stats.clause_looked_at++;
    c.stats.visited_literals++;
    #endif

    // Make sure the false literal is data[1]:
    if (c[0] == ~p) {
        std::swap(c[0], c[1]);
    }

    assert(c[1] == ~p);

    // If 0th watch is true, then clause is already satisfied.
    const Lit first = c[0];
    if (first != blocker && value(first) == l_True) {
        *j = Watched(offset, first);
        j++;
        return true;
    }

    // Look for new watch:
    #ifdef STATS_NEEDED
    uint numLitVisited = 2;
    #endif
    for (Lit *k = c.begin() + 2, *end2 = c.end()
        ; k != end2
        ; k++
        #ifdef STATS_NEEDED
        , numLitVisited++
        #endif
    ) {
        //Literal is either unset or satisfied, attach to other watchlist
        if (value(*k) != l_False) {
            c[1] = *k;
            //propStats.bogoProps += numLitVisited/10;
            #ifdef STATS_NEEDED
            c.stats.visited_literals+= numLitVisited;
            #endif
            *k = ~p;
            watches[c[1].toInt()].push(Watched(offset, c[0]));
            return true;
        }
    }
    #ifdef STATS_NEEDED
    //propStats.bogoProps += numLitVisited/10;
    c.stats.visited_literals+= numLitVisited;
    #endif

    // Did not find watch -- clause is unit under assignment:
    *j++ = *i;
    if (value(first) == l_False) {
        confl = PropBy(offset);
        #ifdef VERBOSE_DEBUG_FULLPROP
        cout << "Conflict from ";
        for(size_t i = 0; i < c.size(); i++) {
            cout  << c[i] << " , ";
        }
        cout << endl;
        #endif //VERBOSE_DEBUG_FULLPROP

        //Update stats
        #ifdef STATS_NEEDED
        c.stats.conflicts_made++;
        c.stats.sum_of_branch_depth_conflict += decisionLevel() + 1;
        #endif
        if (c.red())
            lastConflictCausedBy = ConflCausedBy::longred;
        else
            lastConflictCausedBy = ConflCausedBy::longirred;

        qhead = trail.size();
        return false;
    } else {

        //Update stats
        #ifdef STATS_NEEDED
        c.stats.propagations_made++;
        if (c.red())
            propStats.propsLongRed++;
        else
            propStats.propsLongIrred++;
        #endif
        enqueue<update_bogoprops>(c[0], PropBy(offset));
        update_glue(c);
    }

    return true;
}