const exprt qbf_squolem_coret::f_get(literalt l) { if(squolem->isUniversal(l.var_no())) { assert(l.var_no()!=0); variable_mapt::const_iterator it=variable_map.find(l.var_no()); if(it==variable_map.end()) throw "Variable map error"; const exprt &sym=it->second.first; unsigned index=it->second.second; exprt extract_expr(ID_extractbit, typet(ID_bool)); extract_expr.copy_to_operands(sym); typet uint_type(ID_unsignedbv); uint_type.set(ID_width, 32); extract_expr.copy_to_operands(from_integer(index, uint_type)); if(l.sign()) extract_expr.negate(); return extract_expr; } function_cachet::const_iterator it=function_cache.find(l.var_no()); if(it!=function_cache.end()) { #if 0 std::cout << "CACHE HIT for " << l.dimacs() << std::endl; #endif if(l.sign()) return not_exprt(it->second); else return it->second; } else { WitnessStack *wsp = squolem->getModelFunction(Literal(l.dimacs())); exprt res; if(wsp==NULL || wsp->empty()) { // res=exprt(ID_nondet_bool, typet(ID_bool)); res=false_exprt(); // just set it to zero } else if(wsp->pSize<=wsp->nSize) res=f_get_cnf(wsp); else res=f_get_dnf(wsp); function_cache[l.var_no()] = res; if(l.sign()) return not_exprt(res); else return res; } }
tvt satcheck_lingelingt::l_get(literalt a) const { if(a.is_constant()) return tvt(a.sign()); tvt result; if(a.var_no()>lglmaxvar(solver)) return tvt(tvt::TV_UNKNOWN); const int val=lglderef(solver, a.dimacs()); if(val>0) result=tvt(true); else if(val<0) result=tvt(false); else return tvt(tvt::TV_UNKNOWN); return result; }
/// Returns true if an assumed literal is in conflict if the formula is UNSAT. /// /// NOTE: if the literal is not in the assumption it causes an /// assertion failure in lingeling. bool satcheck_lingelingt::is_in_conflict(literalt a) const { assert(!a.is_constant()); return lglfailed(solver, a.dimacs())!=0; }
void satcheck_lingelingt::set_frozen(literalt a) { if(!a.is_constant()) lglfreeze(solver, a.dimacs()); }