CBMC
bv_refinement.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Abstraction Refinement Loop
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_SOLVERS_REFINEMENT_BV_REFINEMENT_H
13 #define CPROVER_SOLVERS_REFINEMENT_BV_REFINEMENT_H
14 
16 
17 #define MAX_STATE 10000
18 
20 {
21 private:
22  struct configt
23  {
24  bool output_xml = false;
26  unsigned max_node_refinement=5;
28  bool refine_arrays=true;
30  bool refine_arithmetic=true;
31  };
32 public:
33  struct infot:public configt
34  {
35  const namespacet *ns=nullptr;
36  propt *prop=nullptr;
38  };
39 
40  explicit bv_refinementt(const infot &info);
41 
43 
44  std::string decision_procedure_text() const override
45  {
46  return "refinement loop with "+prop.solver_text();
47  }
48 
49 protected:
50 
51  // Refine array
52  void finish_eager_conversion_arrays() override;
53 
54  // Refine arithmetic
55  bvt convert_mult(const mult_exprt &expr) override;
56  bvt convert_div(const div_exprt &expr) override;
57  bvt convert_mod(const mod_exprt &expr) override;
58  bvt convert_floatbv_op(const ieee_float_op_exprt &) override;
59 
60 private:
61  // the list of operator approximations
62  struct approximationt final
63  {
64  public:
65  explicit approximationt(std::size_t _id_nr):
66  no_operands(0),
67  under_state(0),
68  over_state(0),
69  id_nr(_id_nr)
70  {
71  }
72 
74  std::size_t no_operands;
75 
78 
79  std::vector<exprt> under_assumptions;
80  std::vector<exprt> over_assumptions;
81 
82  // the kind of under- or over-approximation
84 
85  std::string as_string() const;
86 
89 
90  std::size_t id_nr;
91  };
92 
94  approximationt &add_approximation(const exprt &expr, bvt &bv);
95  bool conflicts_with(approximationt &approximation);
96  void check_SAT(approximationt &approximation);
97  void check_UNSAT(approximationt &approximation);
98  void initialize(approximationt &approximation);
99  void get_values(approximationt &approximation);
100  void check_SAT();
101  void check_UNSAT();
104 
105  // MEMBERS
106 
107  bool progress;
108  std::list<approximationt> approximations;
109 
110 protected:
111  // use gui format
113 };
114 
115 #endif // CPROVER_SOLVERS_REFINEMENT_BV_REFINEMENT_H
bv_refinementt::convert_div
bvt convert_div(const div_exprt &expr) override
Definition: refine_arithmetic.cpp:100
bv_refinementt::configt::max_node_refinement
unsigned max_node_refinement
Max number of times we refine a formula node.
Definition: bv_refinement.h:26
bv_refinementt::configt::output_xml
bool output_xml
Definition: bv_refinement.h:24
bv_refinementt::conflicts_with
bool conflicts_with(approximationt &approximation)
check if an under-approximation is part of the conflict
Definition: refine_arithmetic.cpp:454
mp_integer
BigInt mp_integer
Definition: smt_terms.h:17
propt::solver_text
virtual const std::string solver_text()=0
bv_refinementt::approximationt::expr
exprt expr
Definition: bv_refinement.h:73
bv_refinementt::approximationt::over_assumptions
std::vector< exprt > over_assumptions
Definition: bv_refinement.h:80
bvt
std::vector< literalt > bvt
Definition: literal.h:201
bv_refinementt::arrays_overapproximated
void arrays_overapproximated()
check whether counterexample is spurious
Definition: refine_arrays.cpp:36
bv_refinementt::add_approximation
approximationt & add_approximation(const exprt &expr, bvt &bv)
Definition: refine_arithmetic.cpp:484
bv_refinementt::infot
Definition: bv_refinement.h:33
bv_refinementt::check_SAT
void check_SAT()
Definition: bv_refinement_loop.cpp:120
bv_refinementt::configt::refine_arithmetic
bool refine_arithmetic
Enable arithmetic refinement.
Definition: bv_refinement.h:30
exprt
Base class for all expressions.
Definition: expr.h:55
bv_refinementt::decision_procedure_text
std::string decision_procedure_text() const override
Return a textual description of the decision procedure.
Definition: bv_refinement.h:44
bv_refinementt::bv_refinementt
bv_refinementt(const infot &info)
Definition: bv_refinement_loop.cpp:13
bv_refinementt::approximationt::op1_bv
bvt op1_bv
Definition: bv_refinement.h:76
div_exprt
Division.
Definition: std_expr.h:1096
bv_refinementt::approximationt::id_nr
std::size_t id_nr
Definition: bv_refinement.h:90
bv_refinementt::approximationt::approximationt
approximationt(std::size_t _id_nr)
Definition: bv_refinement.h:65
bv_pointers.h
bv_refinementt::convert_mult
bvt convert_mult(const mult_exprt &expr) override
Definition: refine_arithmetic.cpp:52
bv_refinementt::approximations
std::list< approximationt > approximations
Definition: bv_refinement.h:108
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:90
bv_refinementt::initialize
void initialize(approximationt &approximation)
Definition: refine_arithmetic.cpp:468
bv_refinementt::dec_solve
decision_proceduret::resultt dec_solve() override
Run the decision procedure to solve the problem.
Definition: bv_refinement_loop.cpp:24
bv_refinementt::approximationt::add_under_assumption
void add_under_assumption(literalt l)
Definition: refine_arithmetic.cpp:32
bv_refinementt::approximationt::add_over_assumption
void add_over_assumption(literalt l)
Definition: refine_arithmetic.cpp:25
bv_refinementt::approximationt
Definition: bv_refinement.h:62
bv_refinementt::approximationt::op2_value
mp_integer op2_value
Definition: bv_refinement.h:77
bv_refinementt::infot::prop
propt * prop
Definition: bv_refinement.h:36
bv_refinementt::infot::message_handler
message_handlert * message_handler
Definition: bv_refinement.h:37
mult_exprt
Binary multiplication Associativity is not specified.
Definition: std_expr.h:1051
bv_pointerst
Definition: bv_pointers.h:18
message_handlert
Definition: message.h:27
bv_refinementt::check_UNSAT
void check_UNSAT()
Definition: bv_refinement_loop.cpp:134
bv_refinementt::approximationt::op0_value
mp_integer op0_value
Definition: bv_refinement.h:77
bv_refinementt::approximationt::result_bv
bvt result_bv
Definition: bv_refinement.h:76
bv_refinementt::progress
bool progress
Definition: bv_refinement.h:107
bv_refinementt
Definition: bv_refinement.h:19
decision_proceduret::resultt
resultt
Result of running the decision procedure.
Definition: decision_procedure.h:43
bv_refinementt::approximationt::over_state
unsigned over_state
Definition: bv_refinement.h:83
bv_refinementt::prop_solve
resultt prop_solve()
Definition: bv_refinement_loop.cpp:87
bv_refinementt::configt
Definition: bv_refinement.h:22
bv_refinementt::convert_mod
bvt convert_mod(const mod_exprt &expr) override
Definition: refine_arithmetic.cpp:118
bv_refinementt::config_
configt config_
Definition: bv_refinement.h:112
propt
TO_BE_DOCUMENTED.
Definition: prop.h:22
bv_refinementt::get_values
void get_values(approximationt &approximation)
Definition: refine_arithmetic.cpp:136
bv_refinementt::approximationt::op2_bv
bvt op2_bv
Definition: bv_refinement.h:76
bv_refinementt::convert_floatbv_op
bvt convert_floatbv_op(const ieee_float_op_exprt &) override
Definition: refine_arithmetic.cpp:39
bv_refinementt::freeze_lazy_constraints
void freeze_lazy_constraints()
freeze symbols for incremental solving
Definition: refine_arrays.cpp:107
literalt
Definition: literal.h:25
ieee_float_op_exprt
IEEE floating-point operations These have two data operands (op0 and op1) and one rounding mode (op2)...
Definition: floatbv_expr.h:363
bv_refinementt::approximationt::under_state
unsigned under_state
Definition: bv_refinement.h:83
bv_refinementt::infot::ns
const namespacet * ns
Definition: bv_refinement.h:35
bv_refinementt::approximationt::op1_value
mp_integer op1_value
Definition: bv_refinement.h:77
bv_refinementt::approximationt::no_operands
std::size_t no_operands
Definition: bv_refinement.h:74
bv_refinementt::configt::refine_arrays
bool refine_arrays
Enable array refinement.
Definition: bv_refinement.h:28
bv_refinementt::approximationt::op0_bv
bvt op0_bv
Definition: bv_refinement.h:76
bv_refinementt::approximationt::result_value
mp_integer result_value
Definition: bv_refinement.h:77
bv_refinementt::approximationt::under_assumptions
std::vector< exprt > under_assumptions
Definition: bv_refinement.h:79
mod_exprt
Modulo defined as lhs-(rhs * truncate(lhs/rhs)).
Definition: std_expr.h:1167
prop_conv_solvert::prop
propt & prop
Definition: prop_conv_solver.h:130
bv_refinementt::finish_eager_conversion_arrays
void finish_eager_conversion_arrays() override
generate array constraints
Definition: refine_arrays.cpp:21
bv_refinementt::approximationt::as_string
std::string as_string() const
Definition: refine_arithmetic.cpp:529