cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
boolbv_power.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module:
4
5
Author: Daniel Kroening, kroening@kroening.com
6
7
\*******************************************************************/
8
9
#include <
util/mathematical_expr.h
>
10
11
#include "
boolbv.h
"
12
13
bvt
boolbvt::convert_power
(
const
power_exprt
&expr)
14
{
15
const
typet
&type = expr.
type
();
16
17
std::size_t width=
boolbv_width
(type);
18
19
if
(type.
id
()==ID_unsignedbv ||
20
type.
id
()==ID_signedbv)
21
{
22
// Let's do the special case 2**x
23
bvt
base =
convert_bv
(expr.
base
());
24
bvt
exponent =
convert_bv
(expr.
exponent
());
25
26
literalt
eq_2 =
27
bv_utils
.equal(base,
bv_utils
.build_constant(2, base.size()));
28
29
bvt
one=
bv_utils
.build_constant(1, width);
30
bvt
shift =
bv_utils
.shift(one,
bv_utilst::shiftt::SHIFT_LEFT
, exponent);
31
32
bvt
nondet=
prop
.new_variables(width);
33
34
return
bv_utils
.select(eq_2, shift, nondet);
35
}
36
37
return
conversion_failed
(expr);
38
}
boolbv.h
boolbvt::convert_bv
virtual const bvt & convert_bv(const exprt &expr, const std::optional< std::size_t > expected_width={})
Convert expression to vector of literalts, using an internal cache to speed up conversion if availabl...
Definition
boolbv.cpp:40
boolbvt::convert_power
virtual bvt convert_power(const power_exprt &expr)
Definition
boolbv_power.cpp:13
boolbvt::bv_utils
bv_utilst bv_utils
Definition
boolbv.h:121
boolbvt::conversion_failed
bvt conversion_failed(const exprt &expr)
Print that the expression of x has failed conversion, then return a vector of x's width.
Definition
boolbv.cpp:95
boolbvt::boolbv_width
virtual std::size_t boolbv_width(const typet &type) const
Definition
boolbv.h:106
bv_utilst::shiftt::SHIFT_LEFT
@ SHIFT_LEFT
Definition
bv_utils.h:75
exprt::type
typet & type()
Return the type of the expression.
Definition
expr.h:85
irept::id
const irep_idt & id() const
Definition
irep.h:388
literalt
Definition
literal.h:26
power_exprt
Exponentiation.
Definition
mathematical_expr.h:94
power_exprt::base
const exprt & base() const
Definition
mathematical_expr.h:104
power_exprt::exponent
const exprt & exponent() const
Definition
mathematical_expr.h:114
prop_conv_solvert::prop
propt & prop
Definition
prop_conv_solver.h:130
typet
The type of an expression, extends irept.
Definition
type.h:29
bvt
std::vector< literalt > bvt
Definition
literal.h:201
mathematical_expr.h
API to expression classes for 'mathematical' expressions.
solvers
flattening
boolbv_power.cpp
Generated by
1.17.0