本文整理汇总了C++中bvt::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ bvt::begin方法的具体用法?C++ bvt::begin怎么用?C++ bvt::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bvt
的用法示例。
在下文中一共展示了bvt::begin方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lcnf
void cvc_propt::lcnf(const bvt &bv)
{
if(bv.empty()) return;
bvt new_bv;
std::set<literalt> s;
new_bv.reserve(bv.size());
for(bvt::const_iterator it=bv.begin(); it!=bv.end(); it++)
{
if(s.insert(*it).second)
new_bv.push_back(*it);
if(s.find(lnot(*it))!=s.end())
return; // clause satisfied
assert(it->var_no()<_no_variables);
}
assert(!new_bv.empty());
out << "%% lcnf" << std::endl;
out << "ASSERT ";
for(bvt::const_iterator it=new_bv.begin(); it!=new_bv.end(); it++)
{
if(it!=new_bv.begin()) out << " OR ";
out << cvc_literal(*it);
}
out << ";" << std::endl << std::endl;
}
示例2: get_literals
void boolbv_mapt::get_literals(
const irep_idt &identifier,
const typet &type,
const unsigned width,
bvt &literals)
{
map_entryt &map_entry=get_map_entry(identifier, type);
assert(literals.size()==width);
Forall_literals(it, literals)
{
literalt &l=*it;
const unsigned bit=it-literals.begin();
assert(bit<map_entry.literal_map.size());
map_bitt &mb=map_entry.literal_map[bit];
if(mb.is_set)
{
l=mb.l;
continue;
}
l=prop.new_variable();
mb.is_set=true;
mb.l=l;
#ifdef DEBUG
std::cout << "NEW: " << identifier << ":" << bit
<< "=" << l << std::endl;
#endif
}
示例3: lcnf
void dplib_propt::lcnf(const bvt &bv)
{
if(bv.empty())
return;
bvt new_bv;
std::set<literalt> s;
new_bv.reserve(bv.size());
for(bvt::const_iterator it=bv.begin(); it!=bv.end(); it++)
{
if(s.insert(*it).second)
new_bv.push_back(*it);
if(s.find(!*it)!=s.end())
return; // clause satisfied
assert(it->var_no()<=_no_variables);
}
assert(!new_bv.empty());
out << "// lcnf\n";
out << "AXIOM ";
for(bvt::const_iterator it=new_bv.begin(); it!=new_bv.end(); it++)
{
if(it!=new_bv.begin())
out << " | ";
out << dplib_literal(*it);
}
out << ";\n\n";
}
示例4:
void z3_propt::eliminate_duplicates(const bvt &bv, bvt &dest)
{
std::set<literalt> s;
dest.reserve(bv.size());
for(bvt::const_iterator it=bv.begin(); it!=bv.end(); it++)
{
if(s.insert(*it).second)
dest.push_back(*it);
}
}
示例5: lor
literalt cvc_propt::lor(const bvt &bv)
{
out << "%% lor" << std::endl;
literalt literal=def_cvc_literal();
forall_literals(it, bv)
{
if(it!=bv.begin()) out << " OR ";
out << cvc_literal(*it);
}
out << ";" << std::endl << std::endl;
return literal;
}
示例6: lor
literalt dplib_propt::lor(const bvt &bv)
{
out << "// lor\n";
literalt literal=def_dplib_literal();
forall_literals(it, bv)
{
if(it!=bv.begin())
out << " | ";
out << dplib_literal(*it);
}
out << "\n\n";
return literal;
}
示例7: assert
bool z3_propt::process_clause(const bvt &bv, bvt &dest)
{
dest.clear();
// empty clause! this is UNSAT
if(bv.empty()) return false;
std::set<literalt> s;
dest.reserve(bv.size());
for(bvt::const_iterator it=bv.begin();
it!=bv.end();
it++)
{
literalt l=*it;
// we never use index 0
assert(l.var_no()!=0);
if(l.is_true())
return true; // clause satisfied
if(l.is_false())
continue;
if(l.var_no()>=_no_variables)
std::cout << "l.var_no()=" << l.var_no() << " _no_variables=" << _no_variables << std::endl;
assert(l.var_no()<_no_variables);
// prevent duplicate literals
if(s.insert(l).second)
dest.push_back(l);
if(s.find(lnot(l))!=s.end())
return true; // clause satisfied
}
return false;
}
示例8: if
void smt1_propt::lcnf(const bvt &bv)
{
out << std::endl;
out << ":assumption ; lcnf" << std::endl;
out << " ";
if(bv.empty())
out << "false ; the empty clause";
else if(bv.size()==1)
out << smt1_literal(bv.front());
else
{
out << "(or";
for(bvt::const_iterator it=bv.begin(); it!=bv.end(); it++)
out << " " << smt1_literal(*it);
out << ")";
}
out << std::endl;
}
示例9: convert_mult
void boolbvt::convert_mult(const exprt &expr, bvt &bv)
{
unsigned width=boolbv_width(expr.type());
if(width==0)
return conversion_failed(expr, bv);
bv.resize(width);
const exprt::operandst &operands=expr.operands();
if(operands.size()==0)
throw "mult without operands";
const exprt &op0=expr.op0();
bool no_overflow=expr.id()=="no-overflow-mult";
if(expr.type().id()==ID_fixedbv)
{
if(op0.type()!=expr.type())
throw "multiplication with mixed types";
bv=convert_bv(op0);
if(bv.size()!=width)
throw "convert_mult: unexpected operand width";
unsigned fraction_bits=
to_fixedbv_type(expr.type()).get_fraction_bits();
// do a sign extension by fraction_bits bits
bv=bv_utils.sign_extension(bv, bv.size()+fraction_bits);
for(exprt::operandst::const_iterator it=operands.begin()+1;
it!=operands.end(); it++)
{
if(it->type()!=expr.type())
throw "multiplication with mixed types";
bvt op=convert_bv(*it);
if(op.size()!=width)
throw "convert_mult: unexpected operand width";
op=bv_utils.sign_extension(op, bv.size());
bv=bv_utils.signed_multiplier(bv, op);
}
// cut it down again
bv.erase(bv.begin(), bv.begin()+fraction_bits);
return;
}
else if(expr.type().id()==ID_floatbv)
{
if(op0.type()!=expr.type())
throw "multiplication with mixed types";
bv=convert_bv(op0);
if(bv.size()!=width)
throw "convert_mult: unexpected operand width";
float_utilst float_utils(prop);
float_utils.spec=to_floatbv_type(expr.type());
for(exprt::operandst::const_iterator it=operands.begin()+1;
it!=operands.end(); it++)
{
if(it->type()!=expr.type())
throw "multiplication with mixed types";
const bvt &op=convert_bv(*it);
if(op.size()!=width)
throw "convert_mult: unexpected operand width";
bv=float_utils.mul(bv, op);
}
return;
}
else if(expr.type().id()==ID_unsignedbv ||
expr.type().id()==ID_signedbv)
{
if(op0.type()!=expr.type())
throw "multiplication with mixed types";
bv_utilst::representationt rep=
expr.type().id()==ID_signedbv?bv_utilst::SIGNED:
bv_utilst::UNSIGNED;
bv=convert_bv(op0);
if(bv.size()!=width)
throw "convert_mult: unexpected operand width";
for(exprt::operandst::const_iterator it=operands.begin()+1;
it!=operands.end(); it++)
//.........这里部分代码省略.........
示例10: type_conversion
bool boolbvt::type_conversion(
const typet &src_type, const bvt &src,
const typet &dest_type, bvt &dest)
{
bvtypet dest_bvtype=get_bvtype(dest_type);
bvtypet src_bvtype=get_bvtype(src_type);
if(src_bvtype==IS_C_BIT_FIELD)
return type_conversion(
c_bit_field_replacement_type(to_c_bit_field_type(src_type), ns), src, dest_type, dest);
if(dest_bvtype==IS_C_BIT_FIELD)
return type_conversion(
src_type, src, c_bit_field_replacement_type(to_c_bit_field_type(dest_type), ns), dest);
std::size_t src_width=src.size();
std::size_t dest_width=boolbv_width(dest_type);
if(dest_width==0 || src_width==0)
return true;
dest.clear();
dest.reserve(dest_width);
if(dest_type.id()==ID_complex)
{
if(src_type==dest_type.subtype())
{
forall_literals(it, src)
dest.push_back(*it);
// pad with zeros
for(std::size_t i=src.size(); i<dest_width; i++)
dest.push_back(const_literal(false));
return false;
}
else if(src_type.id()==ID_complex)
{
// recursively do both halfs
bvt lower, upper, lower_res, upper_res;
lower.assign(src.begin(), src.begin()+src.size()/2);
upper.assign(src.begin()+src.size()/2, src.end());
type_conversion(ns.follow(src_type.subtype()), lower, ns.follow(dest_type.subtype()), lower_res);
type_conversion(ns.follow(src_type.subtype()), upper, ns.follow(dest_type.subtype()), upper_res);
assert(lower_res.size()+upper_res.size()==dest_width);
dest=lower_res;
dest.insert(dest.end(), upper_res.begin(), upper_res.end());
return false;
}
}
if(src_type.id()==ID_complex)
{
assert(dest_type.id()!=ID_complex);
if(dest_type.id()==ID_signedbv ||
dest_type.id()==ID_unsignedbv ||
dest_type.id()==ID_floatbv ||
dest_type.id()==ID_fixedbv ||
dest_type.id()==ID_c_enum ||
dest_type.id()==ID_c_enum_tag ||
dest_type.id()==ID_bool)
{
// A cast from complex x to real T
// is (T) __real__ x.
bvt tmp_src(src);
tmp_src.resize(src.size()/2); // cut off imag part
return type_conversion(src_type.subtype(), tmp_src, dest_type, dest);
}
}
switch(dest_bvtype)
{
case IS_RANGE:
if(src_bvtype==IS_UNSIGNED ||
src_bvtype==IS_SIGNED ||
src_bvtype==IS_C_BOOL)
{
mp_integer dest_from=to_range_type(dest_type).get_from();
if(dest_from==0)
{
// do zero extension
dest.resize(dest_width);
for(std::size_t i=0; i<dest.size(); i++)
dest[i]=(i<src.size()?src[i]:const_literal(false));
return false;
}
}
else if(src_bvtype==IS_RANGE) // range to range
{
mp_integer src_from=to_range_type(src_type).get_from();
mp_integer dest_from=to_range_type(dest_type).get_from();
if(dest_from==src_from)
{
// do zero extension, if needed
dest=bv_utils.zero_extension(src, dest_width);
return false;
//.........这里部分代码省略.........
示例11: convert_floatbv_op
void boolbvt::convert_floatbv_op(const exprt &expr, bvt &bv)
{
const exprt::operandst &operands=expr.operands();
if(operands.size()!=3)
throw "operator "+expr.id_string()+" takes three operands";
const exprt &op0=expr.op0(); // first operand
const exprt &op1=expr.op1(); // second operand
const exprt &op2=expr.op2(); // rounding mode
bvt bv0=convert_bv(op0);
bvt bv1=convert_bv(op1);
bvt bv2=convert_bv(op2);
const typet &type=ns.follow(expr.type());
if(op0.type()!=type || op1.type()!=type)
{
std::cerr << expr.pretty() << std::endl;
throw "float op with mixed types";
}
float_utilst float_utils(prop);
float_utils.set_rounding_mode(bv2);
if(type.id()==ID_floatbv)
{
float_utils.spec=to_floatbv_type(expr.type());
if(expr.id()==ID_floatbv_plus)
bv=float_utils.add_sub(bv0, bv1, false);
else if(expr.id()==ID_floatbv_minus)
bv=float_utils.add_sub(bv0, bv1, true);
else if(expr.id()==ID_floatbv_mult)
bv=float_utils.mul(bv0, bv1);
else if(expr.id()==ID_floatbv_div)
bv=float_utils.div(bv0, bv1);
else if(expr.id()==ID_floatbv_rem)
bv=float_utils.rem(bv0, bv1);
else
assert(false);
}
else if(type.id()==ID_vector || type.id()==ID_complex)
{
const typet &subtype=ns.follow(type.subtype());
if(subtype.id()==ID_floatbv)
{
float_utils.spec=to_floatbv_type(subtype);
std::size_t width=boolbv_width(type);
std::size_t sub_width=boolbv_width(subtype);
if(sub_width==0 || width%sub_width!=0)
throw "convert_floatbv_op: unexpected vector operand width";
std::size_t size=width/sub_width;
bv.resize(width);
for(std::size_t i=0; i<size; i++)
{
bvt tmp_bv0, tmp_bv1, tmp_bv;
tmp_bv0.assign(bv0.begin()+i*sub_width, bv0.begin()+(i+1)*sub_width);
tmp_bv1.assign(bv1.begin()+i*sub_width, bv1.begin()+(i+1)*sub_width);
if(expr.id()==ID_floatbv_plus)
tmp_bv=float_utils.add_sub(tmp_bv0, tmp_bv1, false);
else if(expr.id()==ID_floatbv_minus)
tmp_bv=float_utils.add_sub(tmp_bv0, tmp_bv1, true);
else if(expr.id()==ID_floatbv_mult)
tmp_bv=float_utils.mul(tmp_bv0, tmp_bv1);
else if(expr.id()==ID_floatbv_div)
tmp_bv=float_utils.div(tmp_bv0, tmp_bv1);
else
assert(false);
assert(tmp_bv.size()==sub_width);
assert(i*sub_width+sub_width-1<bv.size());
std::copy(tmp_bv.begin(), tmp_bv.end(), bv.begin()+i*sub_width);
}
}
else
return conversion_failed(expr, bv);
}
else
return conversion_failed(expr, bv);
}