Exemple #1
0
tvt cvc_convt::l_get(literalt l) const
{
    if(l.is_true()) return tvt(true);
    if(l.is_false()) return tvt(false);
    assert(l.var_no()<boolean_assignment.size());
    return tvt(boolean_assignment[l.var_no()]^l.sign());
}
Exemple #2
0
tvt satcheck_minisat2_baset<T>::l_get(literalt a) const
{
  if(a.is_true())
    return tvt(true);
  else if(a.is_false())
    return tvt(false);

  tvt result;

  if(a.var_no()>=(unsigned)solver->model.size())
    return tvt(tvt::TV_UNKNOWN);

  using Minisat::lbool;

  if(solver->model[a.var_no()]==l_True)
    result=tvt(true);
  else if(solver->model[a.var_no()]==l_False)
    result=tvt(false);
  else
    return tvt(tvt::TV_UNKNOWN);
  
  if(a.sign()) result=!result;

  return result;
}
Exemple #3
0
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;
  }
}
Exemple #4
0
qbf_squolem_coret::modeltypet qbf_squolem_coret::m_get(literalt a) const
{
  if(squolem->modelIsTrue(a.var_no()))
    return M_TRUE;
  else if(squolem->modelIsFalse(a.var_no()))
    return M_FALSE;
  else if(squolem->modelIsComplex(a.var_no()))
    return M_COMPLEX;
  else
    return M_DONTCARE;
}
Exemple #5
0
std::string cvc_propt::cvc_literal(literalt l)
{
  if(l==const_literal(false))
    return "FALSE";
  else if(l==const_literal(true))
    return "TRUE";

  if(l.sign())
    return "(NOT l"+i2string(l.var_no())+")";  

  return "l"+i2string(l.var_no());
}
Exemple #6
0
std::string dplib_propt::dplib_literal(literalt l)
{
  if(l==const_literal(false))
    return "FALSE";
  else if(l==const_literal(true))
    return "TRUE";

  if(l.sign())
    return "(NOT l"+std::to_string(l.var_no())+")";

  return "l"+std::to_string(l.var_no());
}
Exemple #7
0
tvt qbf_squolem_coret::l_get(literalt a) const
{
  if(a.is_true())
    return tvt(tvt::TV_TRUE);
  else if(a.is_false())
    return tvt(tvt::TV_FALSE);
  else if(squolem->modelIsTrue(a.var_no()))
    return tvt(tvt::TV_TRUE);
  else if(squolem->modelIsFalse(a.var_no()) ||
          squolem->modelIsDontCare(a.var_no()))
    return tvt(tvt::TV_FALSE);
  else
    return tvt(tvt::TV_UNKNOWN);
}
Exemple #8
0
tvt z3_propt::l_get(literalt a) const
{
  tvt result=tvt(false);
  std::string literal;
  Z3_ast z3_literal;
  size_t found;

  if(a.is_true())
    return tvt(true);
  else if(a.is_false())
    return tvt(false);

  literal = "l"+i2string(a.var_no());

  map_prop_varst::const_iterator cache_result=map_prop_vars.find(literal.c_str());
  if(cache_result!=map_prop_vars.end())
  {
    //std::cout << "Cache hit on " << cache_result->first << "\n";
	z3_literal = cache_result->second;
    Z3_app app = Z3_to_app(z3_ctx, z3_literal);
    Z3_func_decl d = Z3_get_app_decl(z3_ctx, app);
    literal = Z3_func_decl_to_string(z3_ctx, d);

    found=literal.find("true");

    if (found!=std::string::npos)
      result=tvt(true);
    else
      result=tvt(false);
  }

  if (a.sign()) result=!result;

  return result;
}
literalt qbf_bdd_coret::lor(literalt a, literalt b)
{
  literalt nl = new_variable();
  
  std::cout << "LOR2" << std::endl;
  
  BDD abdd(*bdd_variable_map[a.var_no()]);
  BDD bbdd(*bdd_variable_map[b.var_no()]);
  
  if(a.sign()) abdd = ~abdd;
  if(b.sign()) bbdd = ~bbdd;
  
  *bdd_variable_map[nl.var_no()] |= abdd | bbdd;
  
  return nl;
}
Exemple #10
0
tvt boolector_propt::l_get(literalt a) const
{
  tvt result=tvt(false);
  std::string literal;
  BtorExp *boolector_literal;
  size_t found;

  if(a.is_true())
    return tvt(true);
  else if(a.is_false())
    return tvt(false);

  literal_cachet::const_iterator cache_result=literal_cache.find(a.var_no());
  if(cache_result!=literal_cache.end())
    boolector_literal = cache_result->second;
  else
	return tvt(tvt::TV_UNKNOWN);

  literal = boolector_bv_assignment(boolector_ctx, boolector_literal);
  found=literal.find("1");

  if (found!=std::string::npos)
    result=tvt(true);
  else
	result=tvt(false);

  if (a.sign()) result=!result;

  return result;
}
tvt satcheck_booleforce_baset::l_get(literalt a) const
{
  assert(status==SAT);

  if(a.is_true())
    return tvt(true);
  else if(a.is_false())
    return tvt(false);

  tvt result;
  unsigned v=a.var_no();

  assert(v<no_variables());

  int r=booleforce_deref(v);

  if(r>0)
    result=tvt(true);
  else if(r<0)
    result=tvt(false);
  else
    result=tvt(tvt::tv_enumt::TV_UNKNOWN);

  if(a.sign())
    result=!result;

  return result;
}
Exemple #12
0
void qbf_squolem_coret::set_quantifier(
  const quantifiert::typet type,
  const literalt l)
{
  qdimacs_cnft::set_quantifier(type, l);
  squolem->requantifyVariable(l.var_no(), type==quantifiert::UNIVERSAL);
}
void satcheck_minisat1_baset::set_assignment(literalt a, bool value)
{
  unsigned v=a.var_no();
  bool sign=a.sign();
  solver->model.growTo(v+1);
  value^=sign;
  solver->model[v]=lbool(value);
}
Exemple #14
0
void satcheck_glucose_simplifiert::set_frozen(literalt a)
{
  if(!a.is_constant())
  {
    add_variables();
    solver->setFrozen(a.var_no(), true);
  }
}
void smt1_propt::set_assignment(literalt literal, bool value)
{
  if(literal.is_true() || literal.is_false()) return;

  unsigned v=literal.var_no();
  assert(v<assignment.size());
  assignment[v]=tvt(value);
}
Exemple #16
0
bool satcheck_minisat2_baset<T>::is_in_conflict(literalt a) const
{
  int v=a.var_no();

  for(int i=0; i<solver->conflict.size(); i++)
    if(var(solver->conflict[i])==v)
      return true;

  return false;
}
Exemple #17
0
bool qdimacs_cnft::is_quantified(const literalt l) const
{
  for(quantifierst::const_iterator it=quantifiers.begin();
      it!=quantifiers.end();
      it++)
    if(it->var_no==l.var_no())
      return true;

  return false;
}
tvt smt1_propt::l_get(literalt literal) const
{
  if(literal.is_true()) return tvt(true);
  if(literal.is_false()) return tvt(false);

  unsigned v=literal.var_no();
  if(v>=assignment.size()) return tvt(tvt::TV_UNKNOWN);
  tvt r=assignment[v];
  return literal.sign()?!r:r;
}
Exemple #19
0
void satcheck_minisat2_baset<T>::set_assignment(literalt a, bool value)
{
  assert(!a.is_constant());

  unsigned v=a.var_no();
  bool sign=a.sign();

  // MiniSat2 kills the model in case of UNSAT
  solver->model.growTo(v+1);
  value^=sign;
  solver->model[v]=Minisat::lbool(value);
}
Exemple #20
0
bool qdimacs_cnft::find_quantifier(const literalt l, quantifiert &q) const
{
  for(quantifierst::const_iterator it=quantifiers.begin();
      it!=quantifiers.end();
      it++)
    if(it->var_no==l.var_no())
    {
      q=*it;
      return true;
    }

  return false;
}
tvt satcheck_minisat1_baset::l_get(literalt a) const
{
  if(a.is_true())
    return tvt(true);
  else if(a.is_false())
    return tvt(false);

  tvt result;

  assert(a.var_no()!=0);
  assert(a.var_no()<(unsigned)solver->model.size());

  if(solver->model[a.var_no()]==l_True)
    result=tvt(true);
  else if(solver->model[a.var_no()]==l_False)
    result=tvt(false);
  else
    result=tvt(tvt::TV_UNKNOWN);
  
  if(a.sign()) result=!result;

  return result;
}
std::string smt1_propt::smt1_literal(literalt l)
{
  if(l==const_literal(false))
    return "false";
  else if(l==const_literal(true))
    return "true";
    
  std::string v="B"+i2string(l.var_no());

  if(l.sign())
    return "(not "+v+")";  

  return v;
}
Exemple #23
0
void cvc_convt::convert_literal(const literalt l)
{
    if(l==const_literal(false))
        out << "FALSE";
    else if(l==const_literal(true))
        out << "TRUE";

    if(l.sign())
        out << "(NOT ";

    out << "l" << l.var_no();

    if(l.sign())
        out << ")";
}
Exemple #24
0
void qdimacs_cnft::set_quantifier(
  const quantifiert::typet type,
  const literalt l)
{
  for(quantifierst::iterator it=quantifiers.begin();
      it!=quantifiers.end();
      it++)
    if(it->var_no==l.var_no())
    {
      it->type=type;
      return;
    }

  // variable not found - let's add a new quantifier.
  add_quantifier(type, l);
}
Exemple #25
0
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;
}
tvt satcheck_precosatt::l_get(literalt a) const
{
  if(a.is_constant())
    return tvt(a.sign());

  tvt result;

  if(a.var_no()>solver->getMaxVar())
    return tvt(tvt::tv_enumt::TV_UNKNOWN);

  const int val=solver->val(precosat_lit(a));
  if(val>0)
    result=tvt(true);
  else if(val<0)
    result=tvt(false);
  else
    return tvt(tvt::tv_enumt::TV_UNKNOWN);

  return result;
}
Exemple #27
0
void boolbv_mapt::set_literal(
  const irep_idt &identifier,
  const unsigned bit,
  const typet &type,
  literalt literal)
{
  assert(literal.is_constant() ||
         literal.var_no()<prop.no_variables());

  map_entryt &map_entry=get_map_entry(identifier, type);
  assert(bit<map_entry.literal_map.size());

  if(map_entry.literal_map[bit].is_set)
  {
    prop.set_equal(map_entry.literal_map[bit].l, literal);
    return;
  }

  map_entry.literal_map[bit].is_set=true;
  map_entry.literal_map[bit].l=literal;
}
Exemple #28
0
void aigt::print(
  std::ostream& out,
  literalt a) const
{
  if(a==const_literal(false))
  {
    out << "FALSE";
    return;
  }
  else if(a==const_literal(true))
  {
    out << "TRUE";
    return;
  }

  literalt::var_not node_nr=a.var_no();

  {
    const aig_nodet &node=nodes[node_nr];

    if(node.is_and())
    {
      if(a.sign()) out << "!(";
      print(out, node.a);
      out << " & ";
      print(out, node.b);
      if(a.sign()) out << ")";
    }
    else if(node.is_var())
    {
      if(a.sign()) out << "!";
      out << label(node_nr);\
    }
    else
    {
      if(a.sign()) out << "!";
      out << "unknown(" << node_nr << ")";
    }
  }
}
Exemple #29
0
void aigt::output_dot_edge(
  std::ostream& out,
  nodest::size_type v,
  literalt l) const
{
  if(l.is_true())
  {
    out << "TRUE -> " << v;
  }
  else if(l.is_false())
  {
    out << "TRUE -> " << v;
    out << " [arrowhead=odiamond]";
  }
  else
  {
    out << l.var_no() << " -> " << v;
    if(l.sign()) out << " [arrowhead=odiamond]";
  }

  out << "\n";
}
Exemple #30
0
Z3_ast z3_propt::z3_literal(literalt l)
{
  Z3_ast literal_l;
  std::string literal_s;

  if(l==const_literal(false))
    return Z3_mk_false(z3_ctx);
  else if(l==const_literal(true))
    return Z3_mk_true(z3_ctx);

  literal_s = "l"+i2string(l.var_no());
#ifdef DEBUG
  std::cout << "literal_s: " << literal_s << "\n";
#endif
  literal_l = z3_api.mk_bool_var(z3_ctx, literal_s.c_str());

  if(l.sign())
  {
    return Z3_mk_not(z3_ctx, literal_l);
  }

  return literal_l;
}