bool CNF::redundant(const Watched& ws) const { return ( (ws.isBin() && ws.red()) || (ws.isTri() && ws.red()) || (ws.isClause() && cl_alloc.ptr(ws.get_offset())->red() ) ); }
bool CNF::redundant_or_removed(const Watched& ws) const { if (ws.isBin() || ws.isTri()) { return ws.red(); } assert(ws.isClause()); const Clause* cl = cl_alloc.ptr(ws.get_offset()); return cl->red() || cl->getRemoved(); }
ClOffset GateFinder::find_pair_for_and_gate_reduction( const Watched& ws , const size_t minSize , const size_t maxSize , const cl_abst_type general_abst , const OrGate& gate , const bool only_irred ) { //Only long clauses if (!ws.isClause()) return CL_OFFSET_MAX; const ClOffset this_cl_offs = ws.get_offset(); Clause& this_cl = *solver->cl_alloc.ptr(this_cl_offs); if ((ws.getAbst() | general_abst) != general_abst || (this_cl.red() && only_irred) || (!this_cl.red() && gate.red) || this_cl.size() > solver->conf.maxGateBasedClReduceSize || this_cl.size() > maxSize //Size must be smaller or equal to maxSize || this_cl.size() < minSize //Size must be larger or equal than minsize || sizeSortedOcc[this_cl.size()].empty()) //this bracket for sizeSortedOcc must be non-empty { //cout << "Not even possible, this clause cannot match any other" << endl; return CL_OFFSET_MAX; } if (!check_seen_and_gate_against_cl(this_cl, gate)) return CL_OFFSET_MAX; const cl_abst_type this_cl_abst = calc_abst_and_set_seen(this_cl, gate); const ClOffset other_cl_offs = findAndGateOtherCl( sizeSortedOcc[this_cl.size()] //in this occur list that contains clauses of specific size , ~(gate.lit2) //this is the LIT that is meant to be in the clause , this_cl_abst //clause MUST match this abst , gate.red , only_irred ); //Clear 'seen' from bits set *(simplifier->limit_to_decrease) -= this_cl.size(); for (const Lit lit: this_cl) { seen[lit.toInt()] = 0; } return other_cl_offs; }
size_t CNF::cl_size(const Watched& ws) const { switch(ws.getType()) { case watch_binary_t: return 2; case CMSat::watch_tertiary_t: return 3; case watch_clause_t: { const Clause* cl = cl_alloc.ptr(ws.get_offset()); return cl->size(); } default: assert(false); return 0; } }
string CNF::watched_to_string(Lit otherLit, const Watched& ws) const { std::stringstream ss; switch(ws.getType()) { case watch_binary_t: ss << otherLit << ", " << ws.lit2(); if (ws.red()) { ss << "(red)"; } break; case CMSat::watch_tertiary_t: ss << otherLit << ", " << ws.lit2() << ", " << ws.lit3(); if (ws.red()) { ss << "(red)"; } break; case watch_clause_t: { const Clause* cl = cl_alloc.ptr(ws.get_offset()); for(size_t i = 0; i < cl->size(); i++) { ss << (*cl)[i]; if (i + 1 < cl->size()) ss << ", "; } if (cl->red()) { ss << "(red)"; } break; } default: assert(false); break; } return ss.str(); }
void FeaturesCalc::for_one_clause( const Watched& cl , const Lit lit , Function func_each_cl , Function2 func_each_lit ) const { unsigned neg_vars = 0; unsigned pos_vars = 0; unsigned size = 0; switch (cl.getType()) { case CMSat::watch_binary_t: { if (cl.red()) { //only irred cls break; } if (lit > cl.lit2()) { //only count once break; } pos_vars += !lit.sign(); pos_vars += !cl.lit2().sign(); size = 2; neg_vars = size - pos_vars; func_each_cl(size, pos_vars, neg_vars); func_each_lit(lit, size, pos_vars, neg_vars); func_each_lit(cl.lit2(), size, pos_vars, neg_vars); break; } case CMSat::watch_tertiary_t: { if (cl.red()) { //only irred cls break; } if (lit > cl.lit2()) { //only count once break; } assert(cl.lit2() < cl.lit3()); pos_vars += !lit.sign(); pos_vars += !cl.lit2().sign(); pos_vars += !cl.lit3().sign(); size = 3; neg_vars = size - pos_vars; func_each_cl(size, pos_vars, neg_vars); func_each_lit(lit, size, pos_vars, neg_vars); func_each_lit(cl.lit2(), size, pos_vars, neg_vars); func_each_lit(cl.lit3(), size, pos_vars, neg_vars); break; } case CMSat::watch_clause_t: { const Clause& clause = *solver->cl_alloc.ptr(cl.get_offset()); if (clause.red()) { //only irred cls break; } if (clause[0] < clause[1]) { //only count once break; } for (const Lit cl_lit : clause) { pos_vars += !cl_lit.sign(); } size = clause.size(); neg_vars = size - pos_vars; func_each_cl(size, pos_vars, neg_vars); for (const Lit cl_lit : clause) { func_each_lit(cl_lit, size, pos_vars, neg_vars); } break; } case CMSat::watch_idx_t: { // This should never be here assert(false); exit(-1); break; } } }