CBMC
scratch_program.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Loop Acceleration
4 
5 Author: Matt Lewis
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_SCRATCH_PROGRAM_H
13 #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_SCRATCH_PROGRAM_H
14 
15 #include <memory>
16 
17 #include <util/make_unique.h>
18 #include <util/symbol_table.h>
19 
22 
23 #include <goto-symex/goto_symex.h>
26 
27 #include <solvers/smt2/smt2_dec.h>
28 
30 #include <solvers/sat/satcheck.h>
31 
32 #include "path.h"
33 
34 // Wrapper around goto_symext to make initialize_entry_point_state available.
36 {
38  message_handlert &mh,
40  symex_target_equationt &_target,
41  const optionst &options,
44  : goto_symext(
45  mh,
47  _target,
48  options,
51  {
52  }
53 
54  std::unique_ptr<statet>
56  {
58  }
59 };
60 
62 {
63 public:
65  symbol_tablet &_symbol_table,
66  message_handlert &mh,
67  guard_managert &guard_manager)
68  : constant_propagation(true),
69  symbol_table(_symbol_table),
72  equation(mh),
73  path_storage(),
75  symex(mh, symbol_table, equation, options, path_storage, guard_manager),
76  satcheck(util_make_unique<satcheckt>(mh)),
77  satchecker(ns, *satcheck, mh),
78  z3(ns, "accelerate", "", "", smt2_dect::solvert::Z3, mh),
79  checker(&z3) // checker(&satchecker)
80  {
81  }
82 
84  void append(goto_programt &program);
85  void append_path(patht &path);
86  void append_loop(goto_programt &program, goto_programt::targett loop_header);
87 
88  targett assign(const exprt &lhs, const exprt &rhs);
89  targett assume(const exprt &guard);
90 
91  bool check_sat(bool do_slice, guard_managert &guard_manager);
92 
93  bool check_sat(guard_managert &guard_manager)
94  {
95  return check_sat(true, guard_manager);
96  }
97 
98  exprt eval(const exprt &e);
99 
100  void fix_types();
101 
103 
104 protected:
105  std::unique_ptr<goto_symex_statet> symex_state;
114 
115  std::unique_ptr<propt> satcheck;
119  static optionst get_default_options();
120 };
121 
122 #endif // CPROVER_GOTO_INSTRUMENT_ACCELERATE_SCRATCH_PROGRAM_H
scratch_programt::symex_symbol_table
symbol_tablet symex_symbol_table
Definition: scratch_program.h:108
path.h
symex_target_equation.h
scratch_programt::ns
namespacet ns
Definition: scratch_program.h:109
symbol_tablet
The symbol table.
Definition: symbol_table.h:13
path_fifot
FIFO save queue: paths are resumed in the order that they were saved.
Definition: path_storage.h:183
optionst
Definition: options.h:22
decision_proceduret
Definition: decision_procedure.h:20
path_storaget
Storage for symbolic execution paths to be resumed later.
Definition: path_storage.h:37
goto_symext::path_storage
path_storaget & path_storage
Symbolic execution paths to be resumed later.
Definition: goto_symex.h:788
goto_programt::instructionst
std::list< instructiont > instructionst
Definition: goto_program.h:584
scratch_programt::checker
decision_proceduret * checker
Definition: scratch_program.h:118
scratch_programt::symex
scratch_program_symext symex
Definition: scratch_program.h:113
goto_symext::guard_manager
guard_managert & guard_manager
Used to create guards.
Definition: goto_symex.h:248
scratch_programt::options
optionst options
Definition: scratch_program.h:112
exprt
Base class for all expressions.
Definition: expr.h:55
scratch_programt::symbol_table
symbol_tablet & symbol_table
Definition: scratch_program.h:107
scratch_programt::scratch_programt
scratch_programt(symbol_tablet &_symbol_table, message_handlert &mh, guard_managert &guard_manager)
Definition: scratch_program.h:64
scratch_programt::append
void append(goto_programt::instructionst &instructions)
Definition: scratch_program.cpp:94
goto_symext::initialize_entry_point_state
std::unique_ptr< statet > initialize_entry_point_state(const get_goto_functiont &get_goto_function)
Initialize the symbolic execution and the given state with the beginning of the entry point function.
Definition: symex_main.cpp:403
path_storage.h
Storage of symbolic execution paths to resume.
scratch_program_symext::scratch_program_symext
scratch_program_symext(message_handlert &mh, const symbol_tablet &outer_symbol_table, symex_target_equationt &_target, const optionst &options, path_storaget &path_storage, guard_managert &guard_manager)
Definition: scratch_program.h:37
scratch_programt::constant_propagation
bool constant_propagation
Definition: scratch_program.h:102
bv_pointers.h
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:90
guard_expr_managert
This is unused by this implementation of guards, but can be used by other implementations of the same...
Definition: guard_expr.h:19
util_make_unique
std::unique_ptr< T > util_make_unique(Ts &&... ts)
Definition: make_unique.h:19
scratch_programt::append_loop
void append_loop(goto_programt &program, goto_programt::targett loop_header)
Definition: scratch_program.cpp:195
make_unique.h
goto_symext::outer_symbol_table
const symbol_tablet & outer_symbol_table
The symbol table associated with the goto-program being executed.
Definition: goto_symex.h:234
scratch_programt::functions
goto_functionst functions
Definition: scratch_program.h:106
scratch_programt
Definition: scratch_program.h:61
scratch_programt::fix_types
void fix_types()
Definition: scratch_program.cpp:140
scratch_programt::eval
exprt eval(const exprt &e)
Definition: scratch_program.cpp:89
goto_symex.h
goto_symext
The main class for the forward symbolic simulator.
Definition: goto_symex.h:34
smt2_dec.h
scratch_programt::check_sat
bool check_sat(guard_managert &guard_manager)
Definition: scratch_program.h:93
bv_pointerst
Definition: bv_pointers.h:18
scratch_programt::assume
targett assume(const exprt &guard)
Definition: scratch_program.cpp:109
message_handlert
Definition: message.h:27
scratch_programt::z3
smt2_dect z3
Definition: scratch_program.h:117
scratch_programt::equation
symex_target_equationt equation
Definition: scratch_program.h:110
scratch_programt::satcheck
std::unique_ptr< propt > satcheck
Definition: scratch_program.h:115
scratch_programt::append_path
void append_path(patht &path)
Definition: scratch_program.cpp:163
symex_target_equationt
Inheriting the interface of symex_targett this class represents the SSA form of the input program as ...
Definition: symex_target_equation.h:33
goto_program.h
scratch_program_symext
Definition: scratch_program.h:35
goto_programt::instructions
instructionst instructions
The list of instructions in the goto program.
Definition: goto_program.h:592
satcheck.h
goto_functionst
A collection of goto functions.
Definition: goto_functions.h:24
scratch_programt::symex_state
std::unique_ptr< goto_symex_statet > symex_state
Definition: scratch_program.h:105
patht
std::list< path_nodet > patht
Definition: path.h:44
scratch_program_symext::initialize_entry_point_state
std::unique_ptr< statet > initialize_entry_point_state(const get_goto_functiont &get_goto_function)
Definition: scratch_program.h:55
goto_symext::get_goto_function
static get_goto_functiont get_goto_function(abstract_goto_modelt &goto_model)
Return a function to get/load a goto function from the given goto model Create a default delegate to ...
Definition: symex_main.cpp:493
smt2_dect
Decision procedure interface for various SMT 2.x solvers.
Definition: smt2_dec.h:27
goto_functions.h
goto_programt
A generic container class for the GOTO intermediate representation of one function.
Definition: goto_program.h:72
goto_symext::get_goto_functiont
std::function< const goto_functionst::goto_functiont &(const irep_idt &)> get_goto_functiont
The type of delegate functions that retrieve a goto_functiont for a particular function identifier.
Definition: goto_symex.h:82
scratch_programt::get_default_options
static optionst get_default_options()
Definition: scratch_program.cpp:221
scratch_programt::satchecker
bv_pointerst satchecker
Definition: scratch_program.h:116
scratch_programt::check_sat
bool check_sat(bool do_slice, guard_managert &guard_manager)
Definition: scratch_program.cpp:24
symbol_table.h
Author: Diffblue Ltd.
scratch_programt::assign
targett assign(const exprt &lhs, const exprt &rhs)
Definition: scratch_program.cpp:102
goto_programt::targett
instructionst::iterator targett
Definition: goto_program.h:586
scratch_programt::path_storage
path_fifot path_storage
Definition: scratch_program.h:111