38 #include <unordered_map>
87 static std::string to_string(Value value);
104 static Result<u64> to_u64(
const std::vector<BooleanFunction::Value>& value);
113 friend std::ostream&
operator<<(std::ostream& os, Value v);
155 static BooleanFunction Const(
const std::vector<BooleanFunction::Value>& value);
623 bool is_empty()
const;
656 bool is_variable()
const;
664 bool has_variable_name(
const std::string& variable_name)
const;
678 bool is_constant()
const;
686 bool has_constant_value(
const std::vector<Value>& value)
const;
694 bool has_constant_value(
u64 value)
const;
715 bool is_index()
const;
723 bool has_index_value(
u16 index)
const;
752 const std::vector<BooleanFunction::Node>& get_nodes()
const;
759 std::vector<BooleanFunction> get_parameters()
const;
766 std::set<std::string> get_variable_names()
const;
814 BooleanFunction substitute(
const std::string& old_variable_name,
const std::string& new_variable_name)
const;
833 BooleanFunction substitute(
const std::map<std::string, std::string>& substitutions)
const;
850 Result<Value> evaluate(
const std::unordered_map<std::string, Value>& inputs)
const;
879 Result<std::string> get_truth_table_as_string(
const std::vector<std::string>& ordered_variables = {}, std::string function_name =
"",
bool remove_unknown_variables =
false)
const;
890 [[deprecated(
"Will be removed in a future version. Use z3_utils::from_bf() in the z3_utils plugin instead.")]] z3::expr to_z3(z3::context& context,
891 const std::map<std::string, z3::expr>& var2expr = {})
const;
899 explicit BooleanFunction(std::vector<BooleanFunction::Node>&& nodes);
909 template<
typename...
T,
typename = std::enable_if_t<std::conjunction_v<std::is_same<T, BooleanFunction>...>>>
910 explicit BooleanFunction(BooleanFunction::Node&& node, T&&... p)
913 ((size += p.size()), ...);
914 this->m_nodes.reserve(size);
916 (this->m_nodes.insert(this->m_nodes.end(), p.m_nodes.begin(), p.m_nodes.end()), ...);
917 this->m_nodes.emplace_back(std::move(node));
927 explicit BooleanFunction(BooleanFunction::Node&& node, std::vector<BooleanFunction>&& p);
934 std::string to_string_in_reverse_polish_notation()
const;
943 static Result<std::string> default_printer(
const BooleanFunction::Node& node, std::vector<std::string>&& operands);
952 static Result<std::string> algebraic_printer(
const BooleanFunction::Node& node, std::vector<std::string>&& operands);
957 static Result<BooleanFunction> validate(BooleanFunction&&
function);
960 std::vector<u32> compute_node_coverage()
const;
967 std::vector<BooleanFunction::Node> m_nodes{};
1022 static Node Constant(
const std::vector<BooleanFunction::Value> value);
1214 Node(
u16 _type,
u16 _size, std::vector<BooleanFunction::Value> _constant,
u16 _index, std::string
variable);
Value
represents the type of the node
BooleanFunction Slt(const std::vector< BooleanFunction::Value > &p0, const std::vector< BooleanFunction::Value > &p1)
BooleanFunction Or(const std::vector< BooleanFunction::Value > &p0, const std::vector< BooleanFunction::Value > &p1)
BooleanFunction Not(const std::vector< BooleanFunction::Value > &p)
BooleanFunction Sle(const std::vector< BooleanFunction::Value > &p0, const std::vector< BooleanFunction::Value > &p1)
BooleanFunction Ite(const std::vector< BooleanFunction::Value > &p0, const std::vector< BooleanFunction::Value > &p1, const std::vector< BooleanFunction::Value > &p2)
BooleanFunction Ule(const std::vector< BooleanFunction::Value > &p0, const std::vector< BooleanFunction::Value > &p1)
BooleanFunction Ult(const std::vector< BooleanFunction::Value > &p0, const std::vector< BooleanFunction::Value > &p1)
BooleanFunction Mul(const std::vector< BooleanFunction::Value > &p0, const std::vector< BooleanFunction::Value > &p1)
BooleanFunction Sub(const std::vector< BooleanFunction::Value > &p0, const std::vector< BooleanFunction::Value > &p1)
BooleanFunction Add(const std::vector< BooleanFunction::Value > &p0, const std::vector< BooleanFunction::Value > &p1)
BooleanFunction Xor(const std::vector< BooleanFunction::Value > &p0, const std::vector< BooleanFunction::Value > &p1)
BooleanFunction And(const std::vector< BooleanFunction::Value > &p0, const std::vector< BooleanFunction::Value > &p1)
std::ostream & operator<<(std::ostream &os, BooleanFunction::Value v)
std::vector< BooleanFunction::Value > constant
The (optional) constant value of the node.
u16 type
The type of the node.
bool is_operation() const
u16 size
The bit-size of the node.
static u16 get_arity_of_type(u16 type)
static Node Constant(const std::vector< BooleanFunction::Value > value)
bool has_index_value(u16 value) const
std::string variable
The (optional) variable name of the node.
bool has_variable_name(const std::string &variable_name) const
static Node Operation(u16 type, u16 size)
bool has_constant_value(const std::vector< Value > &value) const
bool is_commutative() const
std::string to_string() const
Result< std::vector< Value > > get_constant_value() const
static Node Index(u16 index, u16 size)
Result< u16 > get_index_value() const
bool operator!=(const Node &other) const
bool operator==(const Node &other) const
bool operator<(const Node &other) const
u16 index
The (optional) index value of the node.
static Node Variable(const std::string variable, u16 size)
Result< std::string > get_variable_name() const
Result< u64 > get_constant_value_u64() const
static constexpr u16 Constant
static constexpr u16 Srem
static constexpr u16 Udiv
static constexpr u16 Sdiv
static constexpr u16 Urem
static constexpr u16 Lshr
static constexpr u16 Sext
static constexpr u16 Ashr
static constexpr u16 Index
static constexpr u16 Concat
static constexpr u16 Slice
static constexpr u16 Zext
static constexpr u16 Variable