示例#1
0
void CNFMgr::convertFormulaToCNFPosAND(const ASTNode& varphi,
                                       ClauseList* defs) {
    //****************************************
    // (pos) AND ~> UNION
    //****************************************

    ASTVec::const_iterator it = varphi.GetChildren().begin();
    convertFormulaToCNF(*it, defs);
    ClauseList* psi = ClauseList::COPY(*(info[*it]->clausespos));

    for (it++; it != varphi.GetChildren().end(); it++) {
        convertFormulaToCNF(*it, defs);
        CNFInfo* x = info[*it];

        if (sharesPos(*x) == 1) {
            psi->insert(x->clausespos);
            delete (x->clausespos);
            x->clausespos = NULL;
            if (x->clausesneg == NULL) {
                delete x;
                info.erase(*it);
            }
        } else {
            ClauseList::INPLACE_UNION(psi, *(x->clausespos));
            reduceMemoryFootprintPos(*it);
        }
    }
    if (renameAllSiblings)
    {
        assert(((unsigned)psi->size()) == varphi.GetChildren().size());
    }

    info[varphi]->clausespos = psi;
} //End of convertFormulaToCNFPosAND()
示例#2
0
void CNFMgr::convertFormulaToCNFNegOR(const ASTNode& varphi,
                                      ClauseList* defs)
{
    //****************************************
    // (neg) OR ~> UNION NOT
    //****************************************
    ASTVec::const_iterator it = varphi.GetChildren().begin();
    convertFormulaToCNF(*it, defs);
    ClauseList* psi = ClauseList::COPY(*(info[*it]->clausesneg));
    reduceMemoryFootprintNeg(*it);
    for (it++; it != varphi.GetChildren().end(); it++) {
        convertFormulaToCNF(*it, defs);
        CNFInfo* x = info[*it];

        if (sharesNeg(*x) != 1) {
            ClauseList::INPLACE_UNION(psi, *(x->clausesneg));
            reduceMemoryFootprintNeg(*it);
        } else {
            // If this is the only use of "clausesneg", no reason to make a copy.
            psi->insert(x->clausesneg);
            // Copied from reduceMemoryFootprintNeg
            delete x->clausesneg;
            x->clausesneg = NULL;
            if (x->clausespos == NULL) {
                delete x;
                info.erase(*it);
            }
        }

    }

    info[varphi]->clausesneg = psi;
} //End of convertFormulaToCNFNegOR()