HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
symbolic_state.cpp
Go to the documentation of this file.
2 
3 namespace hal
4 {
5  namespace SMT
6  {
7  SymbolicState::SymbolicState(const std::vector<BooleanFunction>& variables)
8  {
9  for (const auto& v : variables)
10  {
11  if (v.is_variable())
12  {
13  this->variable.emplace(v.clone(), v.clone());
14  }
15  }
16  }
17 
19  {
20  auto it = this->variable.find(key);
21  return (it == this->variable.end()) ? key : it->second;
22  }
23 
24  std::unordered_map<std::string, const BooleanFunction*> SymbolicState::get_bindings() const
25  {
26  std::unordered_map<std::string, const BooleanFunction*> res;
27  for (const auto& [key, value] : this->variable)
28  {
29  const auto& key_node = key.get_top_level_node();
30  if (key_node.is_variable())
31  {
32  res.emplace(key_node.variable, &value);
33  }
34  }
35  return res;
36  }
37 
38  void SymbolicState::set(const BooleanFunction& key, const BooleanFunction& value)
39  {
40  if (key.is_variable())
41  {
42  this->variable.emplace(std::move(key), std::move(value));
43  }
44  }
45  } // namespace SMT
46 } // namespace hal
const BooleanFunction & get(const BooleanFunction &key) const
std::unordered_map< std::string, const BooleanFunction * > get_bindings() const
SymbolicState(const std::vector< BooleanFunction > &variables={})
void set(const BooleanFunction &key, const BooleanFunction &value)
Definition: defines.h:45