CBMC
axioms.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Axioms
4 
5 Author: Daniel Kroening, dkr@amazon.com
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_CPROVER_AXIOMS_H
13 #define CPROVER_CPROVER_AXIOMS_H
14 
15 #include <util/std_expr.h> // IWYU pragma: keep
16 
17 #include "sentinel_dll.h"
18 #include "state.h"
19 
20 #include <map>
21 #include <set>
22 #include <unordered_map>
23 #include <unordered_set>
24 #include <vector>
25 
27 
28 class axiomst
29 {
30 public:
32  decision_proceduret &__dest,
33  const std::unordered_set<symbol_exprt, irep_hash> &__address_taken,
34  bool __verbose,
35  const namespacet &__ns)
36  : dest(__dest), address_taken(__address_taken), verbose(__verbose), ns(__ns)
37  {
38  }
39 
40  void set_to_true(exprt);
41  void set_to_false(exprt);
42  void emit();
43 
44  exprt translate(exprt) const;
45 
46 protected:
48  const std::unordered_set<symbol_exprt, irep_hash> &address_taken;
49  bool verbose = false;
50  const namespacet &ns;
51 
52  std::vector<exprt> constraints;
53 
56  std::unordered_map<exprt, symbol_exprt, irep_hash> replacement_map;
57  std::map<irep_idt, std::size_t> counters;
58 
59  void node(const exprt &);
60 
61  std::set<address_of_exprt> address_of_exprs;
62 
63  std::set<object_address_exprt> object_address_exprs;
64 
65  std::set<state_ok_exprt> ok_exprs;
66  void add(const state_ok_exprt &);
67  void ok_fc();
68 
69  std::set<evaluate_exprt> evaluate_exprs;
70  void evaluate_fc();
71 
72  std::set<state_is_cstring_exprt> is_cstring_exprs;
73  void add(const state_is_cstring_exprt &, bool recursive);
74  void is_cstring_fc();
75 
76  std::set<state_is_dynamic_object_exprt> is_dynamic_object_exprs;
77  void is_dynamic_object_fc();
78 
79  std::set<state_live_object_exprt> live_object_exprs;
80  void live_object();
81  void live_object_fc();
82 
83  std::set<state_writeable_object_exprt> writeable_object_exprs;
84  void writeable_object();
85  void writeable_object_fc();
86 
87  std::set<state_object_size_exprt> object_size_exprs;
88  void object_size();
89  void object_size_fc();
90 
91  std::set<state_is_sentinel_dll_exprt> is_sentinel_dll_exprs;
93 
94  std::set<initial_state_exprt> initial_state_exprs;
95  void initial_state();
96 };
97 
98 static inline axiomst &operator<<(axiomst &axioms, exprt src)
99 {
100  axioms.set_to_true(std::move(src));
101  return axioms;
102 }
103 
104 #endif // CPROVER_CPROVER_AXIOMS_H
static axiomst & operator<<(axiomst &axioms, exprt src)
Definition: axioms.h:98
Definition: axioms.h:29
void is_dynamic_object_fc()
Definition: axioms.cpp:219
std::set< address_of_exprt > address_of_exprs
Definition: axioms.h:61
std::set< state_ok_exprt > ok_exprs
Definition: axioms.h:65
std::unordered_map< exprt, symbol_exprt, irep_hash > replacement_map
Definition: axioms.h:56
std::set< object_address_exprt > object_address_exprs
Definition: axioms.h:63
std::set< state_live_object_exprt > live_object_exprs
Definition: axioms.h:79
std::set< evaluate_exprt > evaluate_exprs
Definition: axioms.h:69
void object_size()
Definition: axioms.cpp:241
bool verbose
Definition: axioms.h:49
void object_size_fc()
Definition: axioms.cpp:278
std::set< state_is_dynamic_object_exprt > is_dynamic_object_exprs
Definition: axioms.h:76
std::set< state_is_sentinel_dll_exprt > is_sentinel_dll_exprs
Definition: axioms.h:91
std::set< initial_state_exprt > initial_state_exprs
Definition: axioms.h:94
std::set< state_writeable_object_exprt > writeable_object_exprs
Definition: axioms.h:83
void live_object_fc()
Definition: axioms.cpp:126
void emit()
Definition: axioms.cpp:749
const namespacet & ns
Definition: axioms.h:50
void live_object()
Definition: axioms.cpp:108
void ok_fc()
Definition: axioms.cpp:298
std::map< irep_idt, std::size_t > counters
Definition: axioms.h:57
exprt translate(exprt) const
Definition: axioms.cpp:350
void set_to_true(exprt)
Definition: axioms.cpp:29
void is_cstring_fc()
Definition: axioms.cpp:85
void evaluate_fc()
Definition: axioms.cpp:58
void set_to_false(exprt)
Definition: axioms.cpp:34
axiomst(decision_proceduret &__dest, const std::unordered_set< symbol_exprt, irep_hash > &__address_taken, bool __verbose, const namespacet &__ns)
Definition: axioms.h:31
void initial_state()
Definition: axioms.cpp:324
std::set< state_is_cstring_exprt > is_cstring_exprs
Definition: axioms.h:72
void writeable_object()
Definition: axioms.cpp:146
const std::unordered_set< symbol_exprt, irep_hash > & address_taken
Definition: axioms.h:48
decision_proceduret & dest
Definition: axioms.h:47
std::set< state_object_size_exprt > object_size_exprs
Definition: axioms.h:87
std::vector< exprt > constraints
Definition: axioms.h:52
void is_sentinel_dll()
exprt replace(exprt)
Definition: axioms.cpp:359
void add(const state_ok_exprt &)
Definition: axioms.cpp:628
void writeable_object_fc()
Definition: axioms.cpp:197
void node(const exprt &)
Definition: axioms.cpp:399
An interface for a decision procedure for satisfiability problems.
Base class for all expressions.
Definition: expr.h:56
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:94
The type of an expression, extends irept.
Definition: type.h:29
API to expression classes.