HAL  v4.5.0-133-g64838ea8d
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
smt.cpp
Go to the documentation of this file.
2 
3 namespace hal
4 {
6  {
7  auto py_smt = m.def_submodule("SMT", R"(
8  SMT solver functions.
9  )");
10 
11  py::enum_<SMT::SolverType> py_smt_solver_type(py_smt, "SolverType", R"(
12  Identifier for the SMT solver type.
13  )");
14 
15  py_smt_solver_type.value("Z3", SMT::SolverType::Z3, R"(Z3 SMT solver.)")
16  .value("Boolector", SMT::SolverType::Boolector, R"(Boolector SMT solver.)")
17  .value("Bitwuzla", SMT::SolverType::Bitwuzla, R"(Bitwuzla SMT solver.)")
18  .value("Unknown", SMT::SolverType::Unknown, R"(Unknown (unsupported) SMT solver.)")
19  .export_values();
20 
21  py::enum_<SMT::SolverCall> py_smt_solver_call(py_smt, "SolverCall", R"(
22  Identifier for how the SMT solver is invoked.
23  )");
24 
25  py_smt_solver_call.value("Binary", SMT::SolverCall::Binary, R"(Call the solver binary in a subprocess.)")
26  .value("Library", SMT::SolverCall::Library, R"(Call the solver through the library linked into HAL.)")
27  .export_values();
28 
29  py::class_<SMT::QueryConfig> py_smt_query_config(py_smt, "QueryConfig", R"(
30  Represents the data structure to configure an SMT query.
31  )");
32 
33  py_smt_query_config.def(py::init<>(), R"(
34  Constructs a new query configuration.
35  )");
36 
37  py_smt_query_config.def_readwrite("solver", &SMT::QueryConfig::solver, R"(
38  The SMT solver identifier.
39 
40  :type: hal_py.SMT.SolverType
41  )");
42 
43  py_smt_query_config.def_readwrite("local", &SMT::QueryConfig::local, R"(
44  Controls whether the SMT query is performed on a local or a remote machine.
45 
46  :type: bool
47  )");
48 
49  py_smt_query_config.def_readwrite("generate_model", &SMT::QueryConfig::generate_model, R"(
50  Controls whether the SMT solver should generate a model in case formula is satisfiable.
51 
52  :type: bool
53  )");
54 
55  py_smt_query_config.def_readwrite("timeout_in_seconds", &SMT::QueryConfig::timeout_in_seconds, R"(
56  The timeout after which the SMT solver is killed in seconds.
57 
58  :type: int
59  )");
60 
61  py_smt_query_config.def("with_solver", &SMT::QueryConfig::with_solver, py::arg("solver"), R"(
62  Sets the solver type to the desired SMT solver.
63 
64  :param hal_py.SMT.SolverType solver: The solver type identifier.
65  :returns: The updated SMT query configuration.
66  :rtype: hal_py.SMT.QueryConfig
67  )");
68 
69  py_smt_query_config.def("with_call", &SMT::QueryConfig::with_call, py::arg("call"), R"(
70  Sets the call type to the desired target.
71 
72  :param hal_py.SMT.SolverCall call: The solver call.
73  :returns: The updated SMT query configuration.
74  :rtype: hal_py.SMT.QueryConfig
75  )");
76 
77  py_smt_query_config.def("with_local_solver", &SMT::QueryConfig::with_local_solver, R"(
78  Activates local SMT solver execution.
79 
80  :returns: The updated SMT query configuration.
81  :rtype: hal_py.SMT.QueryConfig
82  )");
83 
84  py_smt_query_config.def("with_remote_solver", &SMT::QueryConfig::with_remote_solver, R"(
85  Indicates that the SMT solver runs on a remote machine.
86 
87  :returns: The updated SMT query configuration.
88  :rtype: hal_py.SMT.QueryConfig
89  )");
90 
91  py_smt_query_config.def("with_model_generation", &SMT::QueryConfig::with_model_generation, R"(
92  Indicates that the SMT solver should generate a model in case the formula is satisfiable.
93 
94  :returns: The updated SMT query configuration.
95  :rtype: hal_py.SMT.QueryConfig
96  )");
97 
98  py_smt_query_config.def("without_model_generation", &SMT::QueryConfig::without_model_generation, R"(
99  Indicates that the SMT solver should not generate a model.
100 
101  :returns: The updated SMT query configuration.
102  :rtype: hal_py.SMT.QueryConfig
103  )");
104 
105  py_smt_query_config.def("with_timeout", &SMT::QueryConfig::with_timeout, py::arg("seconds"), R"(
106  Sets a timeout in seconds that terminates an SMT query after the specified time has passed.
107 
108  :param int seconds: The timeout in seconds.
109  :returns: The updated SMT query configuration.
110  :rtype: hal_py.SMT.QueryConfig
111  )");
112 
113  py_smt_query_config.def("to_string", &SMT::QueryConfig::to_string, R"(
114  Translates the SMT query configuration into its string representation.
115 
116  :returns: A string representing the SMT query configuration.
117  :rtype: str
118  )");
119 
120  py_smt_query_config.def("__str__", [](const SMT::QueryConfig& config) { return config.to_string(); }, R"(
121  Translates the SMT query configuration into its string representation.
122 
123  :returns: A string representing the SMT query configuration.
124  :rtype: str
125  )");
126 
127  py::class_<SMT::Constraint> py_smt_constraint(py_smt, "Constraint", R"(
128  Represents a constraint to the SMT query.
129  A constraint is either an assignment of two Boolean functions or a single Boolean function, e.g., an equality check or similar.
130  )");
131 
132  py_smt_constraint.def_readwrite("constraint", &SMT::Constraint::constraint, R"(
133  A constraint that is either an assignment of two Boolean functions or a single Boolean function, e.g., an equality check or similar.
134 
135  :type: hal_py.BooleanFunction or tuple(hal_py.BooleanFunction, hal_py.BooleanFunction)
136  )");
137 
138  py_smt_constraint.def(py::init([](BooleanFunction constraint) { return new SMT::Constraint(std::move(constraint)); }), py::arg("constraint"), R"(
139  Constructs a new constraint from one Boolean function that evaluates to a single bit.
140 
141  :param hal_py.BooleanFunction constraint: The constraint function.
142  )");
143 
144  py_smt_constraint.def(py::init([](BooleanFunction lhs, BooleanFunction rhs) { return new SMT::Constraint(std::move(lhs), std::move(rhs)); }), py::arg("lhs"), py::arg("rhs"), R"(
145  Constructs a new equality constraint from two Boolean functions.
146 
147  :param hal_py.BooleanFunction lhs: The left-hand side of the equality constraint.
148  :param hal_py.BooleanFunction rhs: The right-hand side of the equality constraint.
149  )");
150 
151  py_smt_constraint.def("is_assignment", &SMT::Constraint::is_assignment, R"(
152  Checks whether the constraint is an assignment constraint.
153 
154  :returns: ``True`` if the constraint is an assignment, ``False`` otherwise.
155  :rtype: bool
156  )");
157 
158  py_smt_constraint.def(
159  "get_assignment",
160  [](const SMT::Constraint& self) -> std::optional<std::pair<BooleanFunction, BooleanFunction>> {
161  auto res = self.get_assignment();
162  if (res.is_ok())
163  {
164  return *res.get();
165  }
166  else
167  {
168  log_error("python_context", "{}", res.get_error().get());
169  return std::nullopt;
170  }
171  },
172  R"(
173  Returns the assignment constraint as a pair of Boolean functions.
174 
175  :returns: The assignment constraint on success, ``None`` otherwise.
176  :rtype: tuple(hal_py.BooleanFunction,hal_py.BooleanFunction) or None
177  )");
178 
179  py_smt_constraint.def(
180  "get_function",
181  [](const SMT::Constraint& self) -> std::optional<const BooleanFunction*> {
182  auto res = self.get_function();
183  if (res.is_ok())
184  {
185  return res.get();
186  }
187  else
188  {
189  log_error("python_context", "{}", res.get_error().get());
190  return std::nullopt;
191  }
192  },
193  R"(
194  Returns the function constraint.
195 
196  :returns: The function constraint on success, ``None`` otherwise.
197  :rtype: hal_py.BooleanFunction or None
198  )");
199 
200  py_smt_constraint.def("to_string", &SMT::Constraint::to_string, R"(
201  Translates the SMT constraint into its string representation.
202 
203  :returns: A string representing the SMT constraint.
204  :rtype: str
205  )");
206 
207  py_smt_constraint.def("__str__", [](const SMT::Constraint& constraint) { return constraint.to_string(); }, R"(
208  Translates the SMT constraint into its string representation.
209 
210  :returns: A string representing the SMT constraint.
211  :rtype: str
212  )");
213 
214  py::enum_<SMT::SolverResultType> py_smt_result_type(py_smt, "SolverResultType", R"(
215  Result type of an SMT solver query.
216  )");
217 
218  py_smt_result_type.value("Sat", SMT::SolverResultType::Sat, R"(The list of constraints is satisfiable.)")
219  .value("UnSat", SMT::SolverResultType::UnSat, R"(The list of constraints is not satisfiable.)")
220  .value("Unknown", SMT::SolverResultType::Unknown, R"(A result could not be obtained, e.g., due to a time-out.)")
221  .export_values();
222 
223  py::class_<SMT::Model> py_smt_model(py_smt, "Model", R"(
224  Represents a list of assignments for variable nodes that yield a satisfiable assignment for a given list of constraints.
225  )");
226 
227  py_smt_model.def(py::init<const std::map<std::string, std::tuple<u64, u16>>&>(), py::arg("model") = std::map<std::string, std::tuple<u64, u16>>(), R"(
228  Constructs a new model from a map of variable names to value and bit-size.
229 
230  :param dict[str,tuple(int,int)] model: A dict from variable name to value and bit-size.
231  )");
232 
233  py_smt_model.def(py::self == py::self, R"(
234  Checks whether two SMT models are equal.
235 
236  :returns: ``True`` if both models are equal, ``False`` otherwise.
237  :rtype: bool
238  )");
239 
240  py_smt_model.def(py::self != py::self, R"(
241  Checks whether two SMT models are unequal.
242 
243  :returns: ``True`` if both models are unequal, ``False`` otherwise.
244  :rtype: bool
245  )");
246 
247  py_smt_model.def_readwrite("model", &SMT::Model::model, R"(
248  A dict from variable identifiers to a (1) value and (2) its bit-size.
249 
250  :type: dict(str,tuple(int,int))
251  )");
252 
253  py_smt_model.def_static(
254  "parse",
255  [](const std::string& model_str, const SMT::SolverType& solver) -> std::optional<SMT::Model> {
256  auto res = SMT::Model::parse(model_str, solver);
257  if (res.is_ok())
258  {
259  return res.get();
260  }
261  else
262  {
263  log_error("python_context", "{}", res.get_error().get());
264  return std::nullopt;
265  }
266  },
267  py::arg("model_str"),
268  py::arg("solver"),
269  R"(
270  Parses an SMT-Lib model from a string output by a solver of the given type.
271 
272  :param str model_str: The SMT-Lib model string.
273  :param hal_py.SMT.SolverType solver: The solver that computed the model.
274  :returns: The model on success, ``None`` otherwise.
275  :rtype: hal_py.SMT.Model or None
276  )");
277 
278  py_smt_model.def(
279  "evaluate",
280  [](const SMT::Model& self, const BooleanFunction& bf) -> std::optional<BooleanFunction> {
281  auto res = self.evaluate(bf);
282  if (res.is_ok())
283  {
284  return res.get();
285  }
286  else
287  {
288  log_error("python_context", "{}", res.get_error().get());
289  return std::nullopt;
290  }
291  },
292  py::arg("bf"),
293  R"(
294  Evaluates the given Boolean function by replacing all variables contained in the model with their corresponding value and simplifying the result.
295 
296  :param hal_py.BooleanFunction bf: The Boolean function to evaluate.
297  :returns: The evaluated function on success, ``None`` otherwise.
298  :rtype: hal_py.BooleanFunction or None
299  )");
300 
301  py_smt_model.def("to_string", &SMT::Model::to_string, R"(
302  Translates the SMT model into its string representation.
303 
304  :returns: A string representing the SMT model.
305  :rtype: str
306  )");
307 
308  py_smt_model.def("__str__", [](const SMT::Model& model) { return model.to_string(); }, R"(
309  Translates the SMT model into its string representation.
310 
311  :returns: A string representing the SMT model.
312  :rtype: str
313  )");
314 
315  py::class_<SMT::SolverResult> py_smt_result(py_smt, "SolverResult", R"(
316  Represents the result of an SMT query.
317  )");
318 
319  py_smt_result.def_readwrite("type", &SMT::SolverResult::type, R"(
320  Result type of the SMT query.
321 
322  :type: hal_py.SMT.ResultType
323  )");
324 
325  py_smt_result.def_readwrite("model", &SMT::SolverResult::model, R"(
326  The (optional) model that is only available if type == SMT.ResultType.Sat and model generation is enabled.
327 
328  :type: hal_py.SMT.Model
329  )");
330 
331  py_smt_result.def_static("Sat", &SMT::SolverResult::Sat, py::arg("model") = std::optional<SMT::Model>(), R"(
332  Creates a satisfiable result with an optional model.
333 
334  :param hal_py.SMT.Model model: Optional model for satisfiable formula.
335  :returns: The result.
336  :rtype: hal_py.SMT.SolverResult
337  )");
338 
339  py_smt_result.def_static("UnSat", &SMT::SolverResult::UnSat, R"(
340  Creates an unsatisfiable result.
341 
342  :returns: The result.
343  :rtype: hal_py.SMT.SolverResult
344  )");
345 
346  py_smt_result.def_static("Unknown", &SMT::SolverResult::Unknown, R"(
347  Creates an unknown result.
348 
349  :returns: The result.
350  :rtype: hal_py.SMT.SolverResult
351  )");
352 
353  py_smt_result.def("is", &SMT::SolverResult::is, py::arg("type"), R"(
354  Checks whether the result is of a specific type.
355 
356  :param hal_py.SMT.ResultType type: The type to check.
357  :returns: ``True`` in case result matches the given type, ``False`` otherwise.
358  :rtype: bool
359  )");
360 
361  py_smt_result.def("is_sat", &SMT::SolverResult::is_sat, R"(
362  Checks whether the result is satisfiable.
363 
364  :returns: ``True`` in case result is satisfiable, ``False`` otherwise.
365  :rtype: bool
366  )");
367 
368  py_smt_result.def("is_unsat", &SMT::SolverResult::is_unsat, R"(
369  Checks whether the result is unsatisfiable.
370 
371  :returns: ``True`` in case result is unsatisfiable, ``False`` otherwise.
372  :rtype: bool
373  )");
374 
375  py_smt_result.def("is_unknown", &SMT::SolverResult::is_unknown, R"(
376  Checks whether the result is unknown.
377 
378  :returns: ``True`` in case result is unknown, ``False`` otherwise.
379  :rtype: bool
380  )");
381 
382  py_smt_result.def("to_string", &SMT::SolverResult::to_string, R"(
383  Translates the SMT result into its string representation.
384 
385  :returns: A string representing the SMT result.
386  :rtype: str
387  )");
388 
389  py_smt_result.def("__str__", [](const SMT::SolverResult& result) { return result.to_string(); }, R"(
390  Translates the SMT result into its string representation.
391 
392  :returns: A string representing the SMT result.
393  :rtype: str
394  )");
395 
396  py::class_<SMT::Solver> py_smt_solver(py_smt, "Solver", R"(
397  Provides an interface to query SMT solvers for a list of constraints, i.e. statements that have to be equal. To this end, we translate constraints to a SMT-LIB v2 string representation and query solvers with a defined configuration, i.e., chosen solver, model generation etc.
398  )");
399 
400  py_smt_solver.def(py::init<std::vector<SMT::Constraint>>(), py::arg("constraints") = std::vector<SMT::Constraint>(), R"(
401  Constructs an solver with an optional list of constraints.
402 
403  :param list[hal_py.SMT.Constraint] constraints: The (optional) list of constraints.
404  )");
405 
406  py_smt_solver.def_property_readonly("constraints", &SMT::Solver::get_constraints, R"(
407  The list of constraints.
408 
409  :type: list[hal_py.SMT.Constraint]
410  )");
411 
412  py_smt_solver.def("get_constraints", &SMT::Solver::get_constraints, R"(
413  Returns the list of constraints.
414 
415  :returns: The list of constraints.
416  :rtype: list[hal_py.SMT.Constraint]
417  )");
418 
419  py_smt_solver.def("with_constraint", &SMT::Solver::with_constraint, py::arg("constraint"), R"(
420  Adds a constraint to the SMT solver.
421 
422  :param hal_py.SMT.Constraint constraint: The constraint.
423  :returns: The updated SMT solver.
424  :rtype: hal_py.SMT.Solver
425  )");
426 
427  py_smt_solver.def("with_constraints", &SMT::Solver::with_constraints, py::arg("constraints"), R"(
428  Adds a list of constraints to the SMT solver.
429 
430  :param list[hal_py.SMT.Constraint] constraints: The constraints.
431  :returns: The updated SMT solver.
432  :rtype: hal_py.SMT.Solver
433  )");
434 
435  py_smt_solver.def_static("has_local_solver_for", &SMT::Solver::has_local_solver_for, py::arg("type"), py::arg("call"), R"(
436  Checks whether a SMT solver of the given type is available on the local machine.
437 
438  :param hal_py.SMT.SolverType type: The SMT solver type.
439  :param hal_py.SMT.SolverCall call: The solver call.
440  :returns: ``True`` if an SMT solver of the requested type is available, ``False`` otherwise.
441  :rtype: bool
442  )");
443 
444  py_smt_solver.def(
445  "query",
446  [](const SMT::Solver& self, const SMT::QueryConfig& config = SMT::QueryConfig()) -> std::optional<SMT::SolverResult> {
447  auto res = self.query(config);
448  if (res.is_ok())
449  {
450  return res.get();
451  }
452  else
453  {
454  log_error("python_context", "{}", res.get_error().get());
455  return std::nullopt;
456  }
457  },
458  py::arg("config") = SMT::QueryConfig(),
459  R"(
460  Queries an SMT solver with the specified query configuration.
461 
462  :param hal_py.SMT.QueryConfig config: The SMT solver query configuration.
463  :returns: The result on success, a string error message otherwise.
464  :rtype: hal_py.SMT.Result or str
465  )");
466 
467  py_smt_solver.def(
468  "query_local",
469  [](const SMT::Solver& self, const SMT::QueryConfig& config) -> std::optional<SMT::SolverResult> {
470  auto res = self.query_local(config);
471  if (res.is_ok())
472  {
473  return res.get();
474  }
475  else
476  {
477  log_error("python_context", "{}", res.get_error().get());
478  return std::nullopt;
479  }
480  },
481  py::arg("config"),
482  R"(
483  Queries a local SMT solver with the specified query configuration.
484 
485  :param hal_py.SMT.QueryConfig config: The SMT solver query configuration.
486  :returns: The result on success, a string error message otherwise.
487  :rtype: hal_py.SMT.Result or str
488  )");
489 
490  py_smt_solver.def(
491  "to_smt2",
492  [](const SMT::Solver& self, const SMT::QueryConfig& config) -> std::optional<std::string> {
493  auto res = self.to_smt2(config);
494  if (res.is_ok())
495  {
496  return res.get();
497  }
498  log_error("python_context", "{}", res.get_error().get());
499  return std::nullopt;
500  },
501  py::arg("config"),
502  R"(
503  Translate the constraints of the solver into an smt2 representation of the query.
504 
505  :param hal_py.SMT.QueryConfig config: The SMT solver query configuration.
506  :returns: The smt2 representation on success, ``None`` otherwise.
507  :rtype: str or None
508  )");
509 
510  py_smt_solver.def_static(
511  "query_local_with_smt2",
512  [](const SMT::QueryConfig& config, const std::string& smt2) -> std::optional<SMT::SolverResult> {
513  auto res = SMT::Solver::query_local_with_smt2(config, smt2);
514  if (res.is_ok())
515  {
516  return res.get();
517  }
518  else
519  {
520  log_error("python_context", "{}", res.get_error().get());
521  return std::nullopt;
522  }
523  },
524  py::arg("config"),
525  py::arg("smt2"),
526  R"(
527  Queries a local SMT solver with the specified query configuration and the provided smt2 representation of the query.
528 
529  :param hal_py.SMT.QueryConfig config: The SMT solver query configuration.
530  :param str smt2: The SMT solver query as smt2 string.
531  :returns: The result on success, a string error message otherwise.
532  :rtype: hal_py.SMT.Result or str
533  )");
534 
535  py_smt_solver.def("query_remote", &SMT::Solver::query_remote, py::arg("config"), R"(
536  Queries a remote SMT solver with the specified query configuration.
537 
538  WARNING: This function is not yet implemented.
539 
540  :param hal_py.SMT.QueryConfig config: The SMT solver query configuration.
541  :returns: The result on success, a string error message otherwise.
542  :rtype: hal_py.SMT.Result or str
543  )");
544 
545  py::class_<SMT::SymbolicState> py_smt_symbolic_state(py_smt, "SymbolicState", R"(
546  Represents the data structure that keeps track of symbolic variable values (e.g., required for symbolic simplification).
547  )");
548 
549  py_smt_symbolic_state.def(py::init<const std::vector<BooleanFunction>&>(), py::arg("variables") = std::vector<BooleanFunction>(), R"(
550  Constructs a symbolic state and (optionally) initializes the variables.
551 
552  :param list[hal_py.BooleanFunction] variables: The (optional) list of variables.
553  )");
554 
555  py_smt_symbolic_state.def("get", &SMT::SymbolicState::get, py::arg("key"), R"(
556  Looks up a Boolean function in the symbolic state.
557 
558  :param hal_py.BooleanFunction key: The Boolean function to look up.
559  :returns: The Boolean function from the symbolic state or the key itself if it is not contained in the symbolic state.
560  :rtype: hal_py.BooleanFunction
561  )");
562 
563  py_smt_symbolic_state.def("set", &SMT::SymbolicState::set, py::arg("key"), py::arg("value"), R"(
564  Sets a Boolean function equivalent in the symbolic state.
565 
566  :param hal_py.BooleanFunction key: The Boolean function.
567  :param hal_py.BooleanFunction value: The equivalent Boolean function.
568  )");
569 
570  py::class_<SMT::SymbolicExecution> py_smt_symbolic_execution(py_smt, "SymbolicExecution", R"(
571  Represents the symbolic execution engine that handles the evaluation and simplification of Boolean function abstract syntax trees.
572  )");
573 
574  py_smt_symbolic_execution.def_readwrite("state", &SMT::SymbolicExecution::state, R"(
575  The current symbolic state.
576 
577  :type: hal_py.SMT.SymbolicState
578  )");
579 
580  py_smt_symbolic_execution.def(py::init<const std::vector<BooleanFunction>&>(), py::arg("variables") = std::vector<BooleanFunction>(), R"(
581  Creates a symbolic execution engine and (optionally) initializes the variables.
582 
583  :param list[hal_py.BooleanFunction] variables: The (optional) list of variables.
584  )");
585 
586  py_smt_symbolic_execution.def(
587  "evaluate",
588  [](const SMT::SymbolicExecution& self, const BooleanFunction& function) -> std::optional<BooleanFunction> {
589  auto res = self.evaluate(function);
590  if (res.is_ok())
591  {
592  return res.get();
593  }
594  log_error("python_context", "{}", res.get_error().get());
595  return std::nullopt;
596  },
597  py::arg("function"),
598  R"(
599  Evaluates a Boolean function within the symbolic state of the symbolic execution.
600 
601  :param hal_py.BooleanFunction function: The Boolean function to evaluate.
602  :returns: The evaluated Boolean function on success, ``None`` otherwise.
603  :rtype: hal_py.BooleanFunction or None
604  )");
605 
606  py_smt_symbolic_execution.def(
607  "evaluate",
608  [](SMT::SymbolicExecution& self, const SMT::Constraint& constraint) -> bool {
609  auto res = self.evaluate(constraint);
610  if (res.is_ok())
611  {
612  return true;
613  }
614  log_error("python_context", "{}", res.get_error().get());
615  return false;
616  },
617  py::arg("constraint"),
618  R"(
619  Evaluates an equality constraint and applies it to the symbolic state of the symbolic execution.
620 
621  :param hal_py.SMT.Constraint constraint: The equality constraint to evaluate.
622  :returns: ``True`` on success, ``False`` otherwise.
623  :rtype: bool
624  )");
625  }
626 } // namespace hal
static std::string to_string(Value value)
static bool has_local_solver_for(SolverType type, SolverCall call)
Definition: solver.cpp:375
Solver & with_constraints(const std::vector< Constraint > &constraints)
Definition: solver.cpp:361
const std::vector< Constraint > & get_constraints() const
Definition: solver.cpp:370
static Result< SolverResult > query_local_with_smt2(const QueryConfig &config, const std::string &smt2)
Definition: solver.cpp:429
Result< SolverResult > query_remote(const QueryConfig &config) const
Definition: solver.cpp:440
Solver & with_constraint(const Constraint &constraint)
Definition: solver.cpp:355
SymbolicState state
The current symbolic state.
const BooleanFunction & get(const BooleanFunction &key) const
void set(const BooleanFunction &key, const BooleanFunction &value)
void smt_init(py::module &m)
Definition: smt.cpp:5
#define log_error(channel,...)
Definition: log.h:78
SolverType
Definition: types.h:47
const Module * module(const Gate *g, const NodeBoxes &boxes)
Definition: defines.h:45
std::string to_string() const
Definition: types.cpp:173
bool is_assignment() const
Definition: types.cpp:180
std::variant< BooleanFunction, std::pair< BooleanFunction, BooleanFunction > > constraint
A constraint that is either an assignment of two Boolean functions or a single Boolean function,...
Definition: types.h:164
static Result< Model > parse(const std::string &model_str, const SolverType &solver)
Definition: types.cpp:234
std::map< std::string, std::tuple< u64, u16 > > model
maps variable identifiers to a (1) value and (2) its bit-size.
Definition: types.h:243
std::string to_string() const
Definition: types.cpp:227
bool generate_model
Controls whether the SMT solver should generate a model in case formula is satisfiable.
Definition: types.h:76
QueryConfig & with_remote_solver()
Definition: types.cpp:107
SolverType solver
The SMT solver identifier.
Definition: types.h:70
u64 timeout_in_seconds
The timeout after which the SMT solver is killed in seconds.
Definition: types.h:78
QueryConfig & without_model_generation()
Definition: types.cpp:119
QueryConfig & with_model_generation()
Definition: types.cpp:113
std::string to_string() const
Definition: types.cpp:143
QueryConfig & with_local_solver()
Definition: types.cpp:101
QueryConfig & with_timeout(u64 seconds)
Definition: types.cpp:125
QueryConfig & with_solver(SolverType solver)
Definition: types.cpp:89
QueryConfig & with_call(SolverCall call)
Definition: types.cpp:95
static SolverResult Unknown()
Definition: types.cpp:323
std::string to_string() const
Definition: types.cpp:365
std::optional< Model > model
The (optional) model that is only available if type == SMT::ResultType::Sat and model generation is e...
Definition: types.h:322
static SolverResult Sat(const std::optional< Model > &model={})
Definition: types.cpp:313
bool is_sat() const
Definition: types.cpp:333
bool is(const SolverResultType &type) const
Definition: types.cpp:328
bool is_unsat() const
Definition: types.cpp:338
static SolverResult UnSat()
Definition: types.cpp:318
SolverResultType type
Result type of the SMT query.
Definition: types.h:320
bool is_unknown() const
Definition: types.cpp:343