CBMC
graphml_witness.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Witnesses for Traces and Proofs
4 
5 Author: Daniel Kroening
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_GOTO_PROGRAMS_GRAPHML_WITNESS_H
13 #define CPROVER_GOTO_PROGRAMS_GRAPHML_WITNESS_H
14 
15 #include <xmllang/graphml.h>
16 
17 class code_assignt;
18 class exprt;
19 class goto_tracet;
20 class namespacet;
22 
24 {
25 public:
26  explicit graphml_witnesst(const namespacet &_ns)
27  : ns(_ns)
28  {
29  }
30 
31  void operator()(const goto_tracet &goto_trace);
32  void operator()(const symex_target_equationt &equation);
33 
34  const graphmlt &graph()
35  {
36  return graphml;
37  }
38 
39 protected:
40  const namespacet &ns;
42 
43  void remove_l0_l1(exprt &expr);
44  std::string convert_assign_rec(
45  const irep_idt &identifier,
46  const code_assignt &assign);
47 
48  template <typename T>
49  static void hash_combine(std::size_t &seed, const T &v)
50  {
51  std::hash<T> hasher;
52  seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
53  }
54 
55  template <typename S, typename T>
56  struct pair_hash // NOLINT(readability/identifiers)
57  {
58  std::size_t operator()(const std::pair<S, T> &v) const
59  {
60  std::size_t seed = 0;
61  hash_combine(seed, v.first);
62  hash_combine(seed, v.second);
63  return seed;
64  }
65  };
66  std::unordered_map<
67  std::pair<unsigned int, const irept::dt *>,
68  std::string,
69  pair_hash<unsigned int, const irept::dt *>>
71 };
72 
73 #endif // CPROVER_GOTO_PROGRAMS_GRAPHML_WITNESS_H
graphml_witnesst::graph
const graphmlt & graph()
Definition: graphml_witness.h:34
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:36
exprt
Base class for all expressions.
Definition: expr.h:55
graphml_witnesst::remove_l0_l1
void remove_l0_l1(exprt &expr)
Definition: graphml_witness.cpp:43
graphml.h
graphml_witnesst::cache
std::unordered_map< std::pair< unsigned int, const irept::dt * >, std::string, pair_hash< unsigned int, const irept::dt * > > cache
Definition: graphml_witness.h:70
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:90
graphml_witnesst::pair_hash
Definition: graphml_witness.h:56
graphml_witnesst::graphml_witnesst
graphml_witnesst(const namespacet &_ns)
Definition: graphml_witness.h:26
graphml_witnesst::graphml
graphmlt graphml
Definition: graphml_witness.h:41
graphml_witnesst::hash_combine
static void hash_combine(std::size_t &seed, const T &v)
Definition: graphml_witness.h:49
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
graphml_witnesst::operator()
void operator()(const goto_tracet &goto_trace)
counterexample witness
Definition: graphml_witness.cpp:288
goto_tracet
Trace of a GOTO program.
Definition: goto_trace.h:174
graphml_witnesst::convert_assign_rec
std::string convert_assign_rec(const irep_idt &identifier, const code_assignt &assign)
Definition: graphml_witness.cpp:75
graphml_witnesst::ns
const namespacet & ns
Definition: graphml_witness.h:40
graphml_witnesst
Definition: graphml_witness.h:23
code_assignt
A goto_instruction_codet representing an assignment in the program.
Definition: goto_instruction_code.h:22
graphml_witnesst::pair_hash::operator()
std::size_t operator()(const std::pair< S, T > &v) const
Definition: graphml_witness.h:58
graphmlt
Definition: graphml.h:43