Exemple #1
0
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);
}
Exemple #2
0
void
genProofModel(SatSolver& s)
{
   // Allocate and record variables; No Var ID for POs
   for (size_t i = 0, n = gates.size(); i < n; ++i) {
      Var v = s.newVar();
      gates[i]->setVar(v);
   }

   // Hard code the model construction here...
   // [2] AIG 4 1 2 ==> [2] = [0] & [1]
   s.addAigCNF(gates[2]->getVar(), gates[0]->getVar(), false,
               gates[1]->getVar(), false);
   // [4] AIG 5 1 3 ==> [4] = [0] & [3]
   s.addAigCNF(gates[4]->getVar(), gates[0]->getVar(), false,
               gates[3]->getVar(), false);
   // [5] AIG 6 !4 !5 ==> [5] = ![2] & ![4]
   s.addAigCNF(gates[5]->getVar(), gates[2]->getVar(), true,
               gates[4]->getVar(), true);
   // [7] AIG 7 !2 !3 ==> [7] = ![1] & ![3]
   s.addAigCNF(gates[7]->getVar(), gates[1]->getVar(), true,
               gates[3]->getVar(), true);
   // [8] AIG 8 !7 1 ==> [8] = ![7] & [0]
   s.addAigCNF(gates[8]->getVar(), gates[7]->getVar(), true,
               gates[0]->getVar(), false);
}
Exemple #3
0
// Solve whether two gates are fuctionally equivalent
// If they are equivalent, return true 
// else return false
bool
CirMgr::solveGateEqBySat(SatSolver& s, CirGate* g1, CirGate* g2, bool inverse){
   Var newV = s.newVar();
   vector<Var> vars;
   vars.push_back(g1->getVar());
   vars.push_back(g2->getVar());
   s.addXorCNF(newV, vars, inverse);
   s.assumeRelease();  // Clear assumptions
   s.assumeProperty(newV, true);
   return !s.assumpSolve();
}
Exemple #4
0
// convert all aigGates in dfs to clauses and put in satSolver
void
CirMgr::genProofModel(SatSolver& s)
{
   for (unsigned i=0, m=_dfsList.size(); i<m; ++i) {
      Var v = s.newVar();
      _dfsList[i]->setVar(v);
   }
   for (unsigned i=0, m=_dfsList.size(); i<m; ++i) {
      _dfsList[i]->genCNF(s);
   }
}