int main() { initCircuit(); SatSolver solver; solver.initialize(); // genProofModel(solver); bool result; // k = Solve(Gate(5) ^ !Gate(8)) Var newV = solver.newVar(); solver.addXorCNF(newV, gates[5]->getVar(), false, gates[8]->getVar(), true); solver.assumeRelease(); // Clear assumptions solver.assumeProperty(newV, true); // k = 1 result = solver.assumpSolve(); reportResult(solver, result); cout << endl << endl << "======================" << endl; // k = Solve(Gate(3) & !Gate(7)) newV = solver.newVar(); solver.addAigCNF(newV, gates[3]->getVar(), false, gates[7]->getVar(), true); solver.assumeRelease(); // Clear assumptions solver.assumeProperty(newV, true); // k = 1 result = solver.assumpSolve(); reportResult(solver, result); }
void CirMgr::cec() { solveBuf(); SatSolver solver; solver.initialize(); genProofModel(solver); // cout << endl; for (int i=0; i<(int)_fecGrps.size(); ++i){ for (unsigned j=1, n=_fecGrps[i]->size(); j<n; ++j){ unsigned g1Num = _fecGrps[i]->at(0); unsigned g2Num = _fecGrps[i]->at(j); CirGate* g1 = getGateById(g1Num/2); CirGate* g2 = getGateById(g2Num/2); assert(g1 != 0 && g2 != 0); // already solve g1 == g2; if (g2->getEqGate() == g1) continue; bool inv = ((g1Num%2) ^ (g2Num%2)); // cursorToPrevLine(); cursorClearAfter(); // cout << _fecGrps.size() << " FEC groups left, " // << "solving " << setw(6) << g1->getId() // << " with " << setw(6) << g2->getId() << " ...... "; if (solveGateEqBySat(solver, g1, g2, inv)){ // cout << "Equivalence!!" << endl; g2->setEqGate(g1); solver.addBufCNF(g1->getVar(), g2->getVar(), inv); } else{ // cout << "UnEquivalence!!" << endl; doSimBySAT(solver); i = -1; break; } } // finish solving one group } }