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/symbol_table.h>
18 
21 
22 #include <goto-symex/goto_symex.h>
25 
26 #include <solvers/smt2/smt2_dec.h>
27 
29 #include <solvers/sat/satcheck.h>
30 
31 #include "path.h"
32 
33 // Wrapper around goto_symext to make initialize_entry_point_state available.
35 {
37  message_handlert &mh,
39  symex_target_equationt &_target,
40  const optionst &options,
43  : goto_symext(
44  mh,
46  _target,
47  options,
50  {
51  }
52 
53  std::unique_ptr<statet>
55  {
57  }
58 };
59 
61 {
62 public:
64  symbol_table_baset &_symbol_table,
65  message_handlert &mh,
66  guard_managert &guard_manager)
67  : constant_propagation(true),
68  symbol_table(_symbol_table),
71  equation(mh),
72  path_storage(),
74  symex(mh, symbol_table, equation, options, path_storage, guard_manager),
75  satcheck(std::make_unique<satcheckt>(mh)),
76  satchecker(ns, *satcheck, mh),
77  z3(ns, "accelerate", "", "", smt2_dect::solvert::Z3, mh),
78  checker(&z3) // checker(&satchecker)
79  {
80  }
81 
83  void append(goto_programt &program);
84  void append_path(patht &path);
85  void append_loop(goto_programt &program, goto_programt::targett loop_header);
86 
87  targett assign(const exprt &lhs, const exprt &rhs);
88  targett assume(const exprt &guard);
89 
90  bool check_sat(bool do_slice, guard_managert &guard_manager);
91 
92  bool check_sat(guard_managert &guard_manager)
93  {
94  return check_sat(true, guard_manager);
95  }
96 
97  exprt eval(const exprt &e);
98 
99  void fix_types();
100 
102 
103 protected:
104  std::unique_ptr<goto_symex_statet> symex_state;
113 
114  std::unique_ptr<propt> satcheck;
118  static optionst get_default_options();
119 };
120 
121 #endif // CPROVER_GOTO_INSTRUMENT_ACCELERATE_SCRATCH_PROGRAM_H
static exprt guard(const exprt::operandst &guards, exprt cond)
An interface for a decision procedure for satisfiability problems.
Base class for all expressions.
Definition: expr.h:56
A collection of goto functions.
A generic container class for the GOTO intermediate representation of one function.
Definition: goto_program.h:73
instructionst instructions
The list of instructions in the goto program.
Definition: goto_program.h:622
instructionst::iterator targett
Definition: goto_program.h:614
std::list< instructiont > instructionst
Definition: goto_program.h:612
The main class for the forward symbolic simulator.
Definition: goto_symex.h:37
const symbol_table_baset & outer_symbol_table
The symbol table associated with the goto-program being executed.
Definition: goto_symex.h:249
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:492
path_storaget & path_storage
Symbolic execution paths to be resumed later.
Definition: goto_symex.h:810
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:397
guard_managert & guard_manager
Used to create guards.
Definition: goto_symex.h:263
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:93
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:94
FIFO save queue: paths are resumed in the order that they were saved.
Definition: path_storage.h:184
Storage for symbolic execution paths to be resumed later.
Definition: path_storage.h:38
goto_functionst functions
scratch_programt(symbol_table_baset &_symbol_table, message_handlert &mh, guard_managert &guard_manager)
bool check_sat(guard_managert &guard_manager)
bool check_sat(bool do_slice, guard_managert &guard_manager)
scratch_program_symext symex
targett assume(const exprt &guard)
void append_loop(goto_programt &program, goto_programt::targett loop_header)
targett assign(const exprt &lhs, const exprt &rhs)
symbol_tablet symex_symbol_table
static optionst get_default_options()
void append(goto_programt::instructionst &instructions)
decision_proceduret * checker
std::unique_ptr< goto_symex_statet > symex_state
bv_pointerst satchecker
symbol_table_baset & symbol_table
exprt eval(const exprt &e)
void append_path(patht &path)
path_fifot path_storage
std::unique_ptr< propt > satcheck
symex_target_equationt equation
Decision procedure interface for various SMT 2.x solvers.
Definition: smt2_dec.h:28
The symbol table base class interface.
The symbol table.
Definition: symbol_table.h:14
Inheriting the interface of symex_targett this class represents the SSA form of the input program as ...
Goto Programs with Functions.
Concrete Goto Program.
Symbolic Execution.
Loop Acceleration.
std::list< path_nodet > patht
Definition: path.h:44
Storage of symbolic execution paths to resume.
This is unused by this implementation of guards, but can be used by other implementations of the same...
Definition: guard_expr.h:20
std::unique_ptr< statet > initialize_entry_point_state(const get_goto_functiont &get_goto_function)
scratch_program_symext(message_handlert &mh, const symbol_table_baset &outer_symbol_table, symex_target_equationt &_target, const optionst &options, path_storaget &path_storage, guard_managert &guard_manager)
Author: Diffblue Ltd.
Generate Equation using Symbolic Execution.