HAL
boolean_function.cpp
Go to the documentation of this file.
2 
3 namespace hal
4 {
6  {
7  py::class_<BooleanFunction> py_boolean_function(m,
8  "BooleanFunction",
9  R"(
10  A BooleanFunction represents a symbolic expression (e.g., ``A & B``) in order to abstract the (semantic) functionality of a single netlist gate (or even a complex subcircuit comprising multiple gates) in a formal manner. To this end, the ``BooleanFunction`` class is able to construct and display arbitrarily-nested expressions, enable symbolic simplification (e.g., simplify ``A & 0`` to ``0``), and translate Boolean functions to the SAT / SMT solver domain to use the solve constraint formulas.
11  )");
12 
13  py::enum_<BooleanFunction::Value> py_boolean_function_value(py_boolean_function, "Value", R"(
14  Represents the logic value that a Boolean function operates on.
15  )");
16 
17  py_boolean_function_value.value("ZERO", BooleanFunction::Value::ZERO, R"(Represents a logical 0.)")
18  .value("ONE", BooleanFunction::Value::ONE, R"(Represents a logical 1.)")
19  .value("Z", BooleanFunction::Value::Z, R"(Represents a high-impedance value.)")
20  .value("X", BooleanFunction::Value::X, R"(Represents an undefined value.)")
21  .export_values();
22 
23  py_boolean_function_value.def("__str__", [](const BooleanFunction::Value& v) { return BooleanFunction::to_string(v); }, R"(
24  Translates the Boolean function value into its string representation.
25 
26  :returns: The value as a string.
27  :rtype: str
28  )");
29 
30  py_boolean_function.def_static(
31  "build",
32  [](const std::vector<BooleanFunction::Node>& nodes) -> std::optional<BooleanFunction> {
33  std::vector<BooleanFunction::Node> nodes_cloned;
34  for (const auto& node : nodes)
35  {
36  nodes_cloned.push_back(node.clone());
37  }
38 
39  auto res = BooleanFunction::build(std::move(nodes_cloned));
40  if (res.is_ok())
41  {
42  return res.get();
43  }
44  else
45  {
46  log_error("python_context", "{}", res.get_error().get());
47  return std::nullopt;
48  }
49  },
50  py::arg("nodes"),
51  R"(
52  Builds a Boolean function from a list of nodes.
53 
54  :param list[hal_py.BooleanFunction.Node] nodes: The nodes to build the Boolean function from.
55  :returns: The Boolean function on success, None otherwise.
56  :rtype: hal_py.BooleanFunction or None
57  )");
58 
59  py_boolean_function.def_static(
60  "to_string",
61  [](const std::vector<BooleanFunction::Value>& value, u8 base = 2) -> std::optional<std::string> {
62  auto res = BooleanFunction::to_string(value, base);
63  if (res.is_ok())
64  {
65  return res.get();
66  }
67  else
68  {
69  log_error("python_context", "{}", res.get_error().get());
70  return std::nullopt;
71  }
72  },
73  py::arg("value"),
74  py::arg("base") = 2,
75  R"(
76  Convert the given bit-vector to its string representation in the given base.
77 
78  :param list[hal_py.BooleanFunction.Value] value: The value as a bit-vector.
79  :param int base: The base that the values should be converted to. Valid values are 2 (default), 8, 10, and 16.
80  :returns: A string representing the values in the given base on success, None otherwise.
81  :rtype: str or None
82  )");
83 
84  py_boolean_function.def_static(
85  "to_u64",
86  [](const std::vector<BooleanFunction::Value>& value) -> std::optional<u64> {
87  auto res = BooleanFunction::to_u64(value);
88  if (res.is_ok())
89  {
90  return res.get();
91  }
92  else
93  {
94  log_error("python_context", "{}", res.get_error().get());
95  return std::nullopt;
96  }
97  },
98  py::arg("value"),
99  R"(
100  Convert the given bit-vector to its unsigned 64-bit integer representation.
101 
102  :param list[hal_py.BooleanFunction.Value] value: The value as a bit-vector.
103  :returns: A 64-bit integer representing the values on success, None otherwise.
104  :rtype: int or None
105  )");
106 
107  py_boolean_function.def(py::init<>(), R"(
108  Constructs an empty / invalid Boolean function.
109  )");
110 
111  py_boolean_function.def_static("Var", &BooleanFunction::Var, py::arg("name"), py::arg("size") = 1, R"(
112  Creates a multi-bit Boolean function of the given bit-size comprising only a variable of the specified name.
113 
114  :param str name: The name of the variable.
115  :param int size: The bit-size. Defaults to 1.
116  :returns: The BooleanFunction.
117  :rtype: hal_py.BooleanFunction
118  )");
119 
120  py_boolean_function.def_static("Const", py::overload_cast<const BooleanFunction::Value&>(&BooleanFunction::Const), py::arg("value"), R"(
121  Creates a constant single-bit Boolean function from a value.
122 
123  :param hal_py.BooleanFunction.Value value: The value.
124  :returns: The Boolean function.
125  :rtype: hal_py.BooleanFunction
126  )");
127 
128  py_boolean_function.def_static("Const", py::overload_cast<const std::vector<BooleanFunction::Value>&>(&BooleanFunction::Const), py::arg("value"), R"(
129  Creates a constant multi-bit Boolean function from a list of values.
130 
131  :param list[hal_py.BooleanFunction.Value] value: The list of values.
132  :returns: The Boolean function.
133  :rtype: hal_py.BooleanFunction
134  )");
135 
136  py_boolean_function.def_static("Const", py::overload_cast<u64, u16>(&BooleanFunction::Const), py::arg("value"), py::arg("size"), R"(
137  Creates a constant multi-bit Boolean function of the given bit-size from an integer value.
138 
139  :param int value: The integer value.
140  :param int size: The bit-size.
141  :returns: The Boolean function.
142  :rtype: hal_py.BooleanFunction
143  )");
144 
145  py_boolean_function.def_static("Index", &BooleanFunction::Index, py::arg("index"), py::arg("size"), R"(
146  Creates an index for a Boolean function of the given bit-size from an integer value.
147 
148  :param int index: The integer value.
149  :param int size: The bit-size.
150  :returns: The Boolean function.
151  :rtype: hal_py.BooleanFunction
152  )");
153 
154  py_boolean_function.def_static(
155  "And",
156  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
157  auto res = BooleanFunction::And(std::move(p0), std::move(p1), size);
158  if (res.is_ok())
159  {
160  return res.get();
161  }
162  else
163  {
164  log_error("python_context", "{}", res.get_error().get());
165  return std::nullopt;
166  }
167  },
168  py::arg("p0"),
169  py::arg("p1"),
170  py::arg("size"),
171  R"(
172  Joins two Boolean functions by applying an AND operation.
173  Requires both Boolean functions to be of the specified bit-size and produces a new Boolean function of the same bit-size.
174 
175  :param hal_py.BooleanFunction p0: First Boolean function.
176  :param hal_py.BooleanFunction p1: Second Boolean function.
177  :param int size: Bit-size of the operation.
178  :returns: The joined Boolean function on success, None otherwise.
179  :rtype: hal_py.BooleanFunction or None
180  )");
181 
182  py_boolean_function.def_static(
183  "Or",
184  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
185  auto res = BooleanFunction::Or(std::move(p0), std::move(p1), size);
186  if (res.is_ok())
187  {
188  return res.get();
189  }
190  else
191  {
192  log_error("python_context", "{}", res.get_error().get());
193  return std::nullopt;
194  }
195  },
196  py::arg("p0"),
197  py::arg("p1"),
198  py::arg("size"),
199  R"(
200  Joins two Boolean functions by applying an OR operation.
201  Requires both Boolean functions to be of the specified bit-size and produces a new Boolean function of the same bit-size.
202 
203  :param hal_py.BooleanFunction p0: First Boolean function.
204  :param hal_py.BooleanFunction p1: Second Boolean function.
205  :param int size: Bit-size of the operation.
206  :returns: The joined Boolean function on success, None otherwise.
207  :rtype: hal_py.BooleanFunction or None
208  )");
209 
210  py_boolean_function.def_static(
211  "Not",
212  [](BooleanFunction p0, u16 size) -> std::optional<BooleanFunction> {
213  auto res = BooleanFunction::Not(std::move(p0), size);
214  if (res.is_ok())
215  {
216  return res.get();
217  }
218  else
219  {
220  log_error("python_context", "{}", res.get_error().get());
221  return std::nullopt;
222  }
223  },
224  py::arg("p0"),
225  py::arg("size"),
226  R"(
227  Negates the given Boolean function.
228  Requires the Boolean function to be of the specified bit-size and produces a new Boolean function of the same bit-size.
229 
230  :param hal_py.BooleanFunction p0: The Boolean function to negate.
231  :param int size: Bit-size of the operation.
232  :returns: The negated Boolean function on success, None otherwise.
233  :rtype: hal_py.BooleanFunction or None
234  )");
235 
236  py_boolean_function.def_static(
237  "Xor",
238  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
239  auto res = BooleanFunction::Xor(std::move(p0), std::move(p1), size);
240  if (res.is_ok())
241  {
242  return res.get();
243  }
244  else
245  {
246  log_error("python_context", "{}", res.get_error().get());
247  return std::nullopt;
248  }
249  },
250  py::arg("p0"),
251  py::arg("p1"),
252  py::arg("size"),
253  R"(
254  Joins two Boolean functions by applying an XOR operation.
255  Requires both Boolean functions to be of the specified bit-size and produces a new Boolean function of the same bit-size.
256 
257  :param hal_py.BooleanFunction p0: First Boolean function.
258  :param hal_py.BooleanFunction p1: Second Boolean function.
259  :param int size: Bit-size of the operation.
260  :returns: The joined Boolean function on success, None otherwise.
261  :rtype: hal_py.BooleanFunction or None
262  )");
263 
264  py_boolean_function.def_static(
265  "Add",
266  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
267  auto res = BooleanFunction::Add(std::move(p0), std::move(p1), size);
268  if (res.is_ok())
269  {
270  return res.get();
271  }
272  else
273  {
274  log_error("python_context", "{}", res.get_error().get());
275  return std::nullopt;
276  }
277  },
278  py::arg("p0"),
279  py::arg("p1"),
280  py::arg("size"),
281  R"(
282  Joins two Boolean functions by applying an ADD operation.
283  Requires both Boolean functions to be of the specified bit-size and produces a new Boolean function of the same bit-size.
284 
285  :param hal_py.BooleanFunction p0: First Boolean function.
286  :param hal_py.BooleanFunction p1: Second Boolean function.
287  :param int size: Bit-size of the operation.
288  :returns: The joined Boolean function on success, None otherwise.
289  :rtype: hal_py.BooleanFunction or None
290  )");
291 
292  py_boolean_function.def_static(
293  "Sub",
294  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
295  auto res = BooleanFunction::Sub(std::move(p0), std::move(p1), size);
296  if (res.is_ok())
297  {
298  return res.get();
299  }
300  else
301  {
302  log_error("python_context", "{}", res.get_error().get());
303  return std::nullopt;
304  }
305  },
306  py::arg("p0"),
307  py::arg("p1"),
308  py::arg("size"),
309  R"(
310  Joins two Boolean functions by applying an SUB operation.
311  Requires both Boolean functions to be of the specified bit-size and produces a new Boolean function of the same bit-size.
312 
313  :param hal_py.BooleanFunction p0: First Boolean function.
314  :param hal_py.BooleanFunction p1: Second Boolean function.
315  :param int size: Bit-size of the operation.
316  :returns: The joined Boolean function on success, None otherwise.
317  :rtype: hal_py.BooleanFunction or None
318  )");
319 
320  py_boolean_function.def_static(
321  "Mul",
322  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
323  auto res = BooleanFunction::Mul(std::move(p0), std::move(p1), size);
324  if (res.is_ok())
325  {
326  return res.get();
327  }
328  else
329  {
330  log_error("python_context", "{}", res.get_error().get());
331  return std::nullopt;
332  }
333  },
334  py::arg("p0"),
335  py::arg("p1"),
336  py::arg("size"),
337  R"(
338  Joins two Boolean functions by applying an MUL operation.
339  Requires both Boolean functions to be of the specified bit-size and produces a new Boolean function of the same bit-size.
340 
341  :param hal_py.BooleanFunction p0: First Boolean function.
342  :param hal_py.BooleanFunction p1: Second Boolean function.
343  :param int size: Bit-size of the operation.
344  :returns: The joined Boolean function on success, None otherwise.
345  :rtype: hal_py.BooleanFunction or None
346  )");
347 
348  py_boolean_function.def_static(
349  "Sdiv",
350  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
351  auto res = BooleanFunction::Sdiv(std::move(p0), std::move(p1), size);
352  if (res.is_ok())
353  {
354  return res.get();
355  }
356  else
357  {
358  log_error("python_context", "{}", res.get_error().get());
359  return std::nullopt;
360  }
361  },
362  py::arg("p0"),
363  py::arg("p1"),
364  py::arg("size"),
365  R"(
366  Joins two Boolean functions by applying an SDIV operation.
367  Requires both Boolean functions to be of the specified bit-size and produces a new Boolean function of the same bit-size.
368 
369  :param hal_py.BooleanFunction p0: First Boolean function.
370  :param hal_py.BooleanFunction p1: Second Boolean function.
371  :param int size: Bit-size of the operation.
372  :returns: The joined Boolean function on success, None otherwise.
373  :rtype: hal_py.BooleanFunction or None
374  )");
375 
376  py_boolean_function.def_static(
377  "Udiv",
378  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
379  auto res = BooleanFunction::Udiv(std::move(p0), std::move(p1), size);
380  if (res.is_ok())
381  {
382  return res.get();
383  }
384  else
385  {
386  log_error("python_context", "{}", res.get_error().get());
387  return std::nullopt;
388  }
389  },
390  py::arg("p0"),
391  py::arg("p1"),
392  py::arg("size"),
393  R"(
394  Joins two Boolean functions by applying an UDIV operation.
395  Requires both Boolean functions to be of the specified bit-size and produces a new Boolean function of the same bit-size.
396 
397  :param hal_py.BooleanFunction p0: First Boolean function.
398  :param hal_py.BooleanFunction p1: Second Boolean function.
399  :param int size: Bit-size of the operation.
400  :returns: The joined Boolean function on success, None otherwise.
401  :rtype: hal_py.BooleanFunction or None
402  )");
403 
404  py_boolean_function.def_static(
405  "Srem",
406  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
407  auto res = BooleanFunction::Srem(std::move(p0), std::move(p1), size);
408  if (res.is_ok())
409  {
410  return res.get();
411  }
412  else
413  {
414  log_error("python_context", "{}", res.get_error().get());
415  return std::nullopt;
416  }
417  },
418  py::arg("p0"),
419  py::arg("p1"),
420  py::arg("size"),
421  R"(
422  Joins two Boolean functions by applying an SREM operation.
423  Requires both Boolean functions to be of the specified bit-size and produces a new Boolean function of the same bit-size.
424 
425  :param hal_py.BooleanFunction p0: First Boolean function.
426  :param hal_py.BooleanFunction p1: Second Boolean function.
427  :param int size: Bit-size of the operation.
428  :returns: The joined Boolean function on success, None otherwise.
429  :rtype: hal_py.BooleanFunction or None
430  )");
431 
432  py_boolean_function.def_static(
433  "Urem",
434  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
435  auto res = BooleanFunction::Urem(std::move(p0), std::move(p1), size);
436  if (res.is_ok())
437  {
438  return res.get();
439  }
440  else
441  {
442  log_error("python_context", "{}", res.get_error().get());
443  return std::nullopt;
444  }
445  },
446  py::arg("p0"),
447  py::arg("p1"),
448  py::arg("size"),
449  R"(
450  Joins two Boolean functions by applying an UREM operation.
451  Requires both Boolean functions to be of the specified bit-size and produces a new Boolean function of the same bit-size.
452 
453  :param hal_py.BooleanFunction p0: First Boolean function.
454  :param hal_py.BooleanFunction p1: Second Boolean function.
455  :param int size: Bit-size of the operation.
456  :returns: The joined Boolean function on success, None otherwise.
457  :rtype: hal_py.BooleanFunction or None
458  )");
459 
460  py_boolean_function.def_static(
461  "Slice",
462  [](BooleanFunction p0, BooleanFunction p1, BooleanFunction p2, u16 size) -> std::optional<BooleanFunction> {
463  auto res = BooleanFunction::Slice(std::move(p0), std::move(p1), std::move(p2), size);
464  if (res.is_ok())
465  {
466  return res.get();
467  }
468  else
469  {
470  log_error("python_context", "{}", res.get_error().get());
471  return std::nullopt;
472  }
473  },
474  py::arg("p0"),
475  py::arg("p1"),
476  py::arg("p2"),
477  py::arg("size"),
478  R"(
479  Returns the slice ``[i:j]`` of a Boolean function specified by a start index ``i`` and an end index ``j`` beginning at 0.
480  Note that slice ``[i:j]`` includes positions ``i`` and ``j`` as well.
481 
482  :param hal_py.BooleanFunction p0: Boolean function to slice.
483  :param hal_py.BooleanFunction p1: Boolean function of type ``Index`` encoding start index ``i``.
484  :param hal_py.BooleanFunction p2: Boolean function of type ``Index`` encoding end index ``j``.
485  :param int size: Bit-size of the resulting Boolean function slice, i.e., ``j - i + 1``.
486  :returns: The Boolean function slice on success, None otherwise.
487  :rtype: hal_py.BooleanFunction or None
488  )");
489 
490  py_boolean_function.def_static(
491  "Concat",
492  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
493  auto res = BooleanFunction::Concat(std::move(p0), std::move(p1), size);
494  if (res.is_ok())
495  {
496  return res.get();
497  }
498  else
499  {
500  log_error("python_context", "{}", res.get_error().get());
501  return std::nullopt;
502  }
503  },
504  py::arg("p0"),
505  py::arg("p1"),
506  py::arg("size"),
507  R"(
508  Concatenates two Boolean functions of bit-sizes ``n`` and ``m`` to form a single Boolean function of bit-size ``n + m``.
509 
510  :param hal_py.BooleanFunction p0: First Boolean function (MSBs).
511  :param hal_py.BooleanFunction p1: Second Boolean function (LSBs).
512  :param int size: Bit-size of the concatenated Boolean function, i.e., ``n + m``.
513  :returns: The concatenated Boolean function on success, None otherwise.
514  :rtype: hal_py.BooleanFunction or None
515  )");
516 
517  py_boolean_function.def_static(
518  "Zext",
519  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
520  auto res = BooleanFunction::Zext(std::move(p0), std::move(p1), size);
521  if (res.is_ok())
522  {
523  return res.get();
524  }
525  else
526  {
527  log_error("python_context", "{}", res.get_error().get());
528  return std::nullopt;
529  }
530  },
531  py::arg("p0"),
532  py::arg("p1"),
533  py::arg("size"),
534  R"(
535  Zero-extends a Boolean function to the specified bit-size.
536 
537  :param hal_py.BooleanFunction p0: Boolean function to extend.
538  :param hal_py.BooleanFunction p1: Boolean function of type ``Index`` encoding the bit-size of the zero-extended result.
539  :param int size: Bit-size of the zero-extended Boolean function.
540  :returns: The zero-extended Boolean function on success, None otherwise.
541  :rtype: hal_py.BooleanFunction or None
542  )");
543 
544  py_boolean_function.def_static(
545  "Sext",
546  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
547  auto res = BooleanFunction::Sext(std::move(p0), std::move(p1), size);
548  if (res.is_ok())
549  {
550  return res.get();
551  }
552  else
553  {
554  log_error("python_context", "{}", res.get_error().get());
555  return std::nullopt;
556  }
557  },
558  py::arg("p0"),
559  py::arg("p1"),
560  py::arg("size"),
561  R"(
562  Sign-extends a Boolean function to the specified bit-size.
563 
564  :param hal_py.BooleanFunction p0: Boolean function to extend.
565  :param hal_py.BooleanFunction p1: Boolean function of type ``Index`` encoding the bit-size of the sign-extended result.
566  :param int size: Bit-size of the sign-extended Boolean function.
567  :returns: The sign-extended Boolean function on success, None otherwise.
568  :rtype: hal_py.BooleanFunction or None
569  )");
570 
571  py_boolean_function.def_static(
572  "Shl",
573  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
574  auto res = BooleanFunction::Shl(std::move(p0), std::move(p1), size);
575  if (res.is_ok())
576  {
577  return res.get();
578  }
579  else
580  {
581  log_error("python_context", "{}", res.get_error().get());
582  return std::nullopt;
583  }
584  },
585  py::arg("p0"),
586  py::arg("p1"),
587  py::arg("size"),
588  R"(
589  Shifts a Boolean function to the left by the specified number of bits.
590 
591  :param hal_py.BooleanFunction p0: Boolean function to shift.
592  :param hal_py.BooleanFunction p1: Boolean function of type ``Index`` encoding the number of bits to shift.
593  :param int size: Bit-size of the shifted Boolean function.
594  :returns: The shifted Boolean function on success, None otherwise.
595  :rtype: hal_py.BooleanFunction or None
596  )");
597 
598  py_boolean_function.def_static(
599  "Lshr",
600  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
601  auto res = BooleanFunction::Lshr(std::move(p0), std::move(p1), size);
602  if (res.is_ok())
603  {
604  return res.get();
605  }
606  else
607  {
608  log_error("python_context", "{}", res.get_error().get());
609  return std::nullopt;
610  }
611  },
612  py::arg("p0"),
613  py::arg("p1"),
614  py::arg("size"),
615  R"(
616  Logically shifts a Boolean function to the right by the specified number of bits.
617 
618  :param hal_py.BooleanFunction p0: Boolean function to shift.
619  :param hal_py.BooleanFunction p1: Boolean function of type ``Index`` encoding the number of bits to shift.
620  :param int size: Bit-size of the shifted Boolean function.
621  :returns: The shifted Boolean function on success, None otherwise.
622  :rtype: hal_py.BooleanFunction or None
623  )");
624 
625  py_boolean_function.def_static(
626  "Ashr",
627  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
628  auto res = BooleanFunction::Ashr(std::move(p0), std::move(p1), size);
629  if (res.is_ok())
630  {
631  return res.get();
632  }
633  else
634  {
635  log_error("python_context", "{}", res.get_error().get());
636  return std::nullopt;
637  }
638  },
639  py::arg("p0"),
640  py::arg("p1"),
641  py::arg("size"),
642  R"(
643  Arithmetically shifts a Boolean function to the right by the specified number of bits.
644 
645  :param hal_py.BooleanFunction p0: Boolean function to shift.
646  :param hal_py.BooleanFunction p1: Boolean function of type ``Index`` encoding the number of bits to shift.
647  :param int size: Bit-size of the shifted Boolean function.
648  :returns: The shifted Boolean function on success, None otherwise.
649  :rtype: hal_py.BooleanFunction or None
650  )");
651 
652  py_boolean_function.def_static(
653  "Rol",
654  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
655  auto res = BooleanFunction::Rol(std::move(p0), std::move(p1), size);
656  if (res.is_ok())
657  {
658  return res.get();
659  }
660  else
661  {
662  log_error("python_context", "{}", res.get_error().get());
663  return std::nullopt;
664  }
665  },
666  py::arg("p0"),
667  py::arg("p1"),
668  py::arg("size"),
669  R"(
670  Rotates a Boolean function to the left by the specified number of bits.
671 
672  :param hal_py.BooleanFunction p0: Boolean function to rotate.
673  :param hal_py.BooleanFunction p1: Boolean function of type ``Index`` encoding the number of bits to rotate.
674  :param int size: Bit-size of the rotated Boolean function.
675  :returns: The rotated Boolean function on success, None otherwise.
676  :rtype: hal_py.BooleanFunction or None
677  )");
678 
679  py_boolean_function.def_static(
680  "Ror",
681  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
682  auto res = BooleanFunction::Ror(std::move(p0), std::move(p1), size);
683  if (res.is_ok())
684  {
685  return res.get();
686  }
687  else
688  {
689  log_error("python_context", "{}", res.get_error().get());
690  return std::nullopt;
691  }
692  },
693  py::arg("p0"),
694  py::arg("p1"),
695  py::arg("size"),
696  R"(
697  Rotates a Boolean function to the right by the specified number of bits.
698 
699  :param hal_py.BooleanFunction p0: Boolean function to rotate.
700  :param hal_py.BooleanFunction p1: Boolean function of type ``Index`` encoding the number of bits to rotate.
701  :param int size: Bit-size of the rotated Boolean function.
702  :returns: The rotated Boolean function on success, None otherwise.
703  :rtype: hal_py.BooleanFunction or None
704  )");
705 
706  py_boolean_function.def_static(
707  "Eq",
708  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
709  auto res = BooleanFunction::Eq(std::move(p0), std::move(p1), size);
710  if (res.is_ok())
711  {
712  return res.get();
713  }
714  else
715  {
716  log_error("python_context", "{}", res.get_error().get());
717  return std::nullopt;
718  }
719  },
720  py::arg("p0"),
721  py::arg("p1"),
722  py::arg("size"),
723  R"(
724  Joins two Boolean functions by an equality check that produces a single-bit result.
725 
726  :param hal_py.BooleanFunction p0: First Boolean function.
727  :param hal_py.BooleanFunction p1: Second Boolean function.
728  :param int size: Bit-size of the operation (always =1).
729  :returns: The joined Boolean function on success, None otherwise.
730  :rtype: hal_py.BooleanFunction or None
731  )");
732 
733  py_boolean_function.def_static(
734  "Sle",
735  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
736  auto res = BooleanFunction::Sle(std::move(p0), std::move(p1), size);
737  if (res.is_ok())
738  {
739  return res.get();
740  }
741  else
742  {
743  log_error("python_context", "{}", res.get_error().get());
744  return std::nullopt;
745  }
746  },
747  py::arg("p0"),
748  py::arg("p1"),
749  py::arg("size"),
750  R"(
751  Joins two Boolean functions by a signed less-than-equal check that produces a single-bit result.
752 
753  :param hal_py.BooleanFunction p0: First Boolean function.
754  :param hal_py.BooleanFunction p1: Second Boolean function.
755  :param int size: Bit-size of the operation (always =1).
756  :returns: The joined Boolean function on success, None otherwise.
757  :rtype: hal_py.BooleanFunction or None
758  )");
759 
760  py_boolean_function.def_static(
761  "Slt",
762  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
763  auto res = BooleanFunction::Slt(std::move(p0), std::move(p1), size);
764  if (res.is_ok())
765  {
766  return res.get();
767  }
768  else
769  {
770  log_error("python_context", "{}", res.get_error().get());
771  return std::nullopt;
772  }
773  },
774  py::arg("p0"),
775  py::arg("p1"),
776  py::arg("size"),
777  R"(
778  Joins two Boolean functions by a signed less-than check that produces a single-bit result.
779 
780  :param hal_py.BooleanFunction p0: First Boolean function.
781  :param hal_py.BooleanFunction p1: Second Boolean function.
782  :param int size: Bit-size of the operation (always =1).
783  :returns: The joined Boolean function on success, None otherwise.
784  :rtype: hal_py.BooleanFunction or None
785  )");
786 
787  py_boolean_function.def_static(
788  "Ule",
789  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
790  auto res = BooleanFunction::Ule(std::move(p0), std::move(p1), size);
791  if (res.is_ok())
792  {
793  return res.get();
794  }
795  else
796  {
797  log_error("python_context", "{}", res.get_error().get());
798  return std::nullopt;
799  }
800  },
801  py::arg("p0"),
802  py::arg("p1"),
803  py::arg("size"),
804  R"(
805  Joins two Boolean functions by an unsigned less-than-equal check that produces a single-bit result.
806 
807  :param hal_py.BooleanFunction p0: First Boolean function.
808  :param hal_py.BooleanFunction p1: Second Boolean function.
809  :param int size: Bit-size of the operation (always =1).
810  :returns: The joined Boolean function on success, None otherwise.
811  :rtype: hal_py.BooleanFunction or None
812  )");
813 
814  py_boolean_function.def_static(
815  "Ult",
816  [](BooleanFunction p0, BooleanFunction p1, u16 size) -> std::optional<BooleanFunction> {
817  auto res = BooleanFunction::Ult(std::move(p0), std::move(p1), size);
818  if (res.is_ok())
819  {
820  return res.get();
821  }
822  else
823  {
824  log_error("python_context", "{}", res.get_error().get());
825  return std::nullopt;
826  }
827  },
828  py::arg("p0"),
829  py::arg("p1"),
830  py::arg("size"),
831  R"(
832  Joins two Boolean functions by an unsigned less-than check that produces a single-bit result.
833 
834  :param hal_py.BooleanFunction p0: First Boolean function.
835  :param hal_py.BooleanFunction p1: Second Boolean function.
836  :param int size: Bit-size of the operation (always =1).
837  :returns: The joined Boolean function on success, None otherwise.
838  :rtype: hal_py.BooleanFunction or None
839  )");
840 
841  py_boolean_function.def_static(
842  "Ite",
843  [](BooleanFunction p0, BooleanFunction p1, BooleanFunction p2, u16 size) -> std::optional<BooleanFunction> {
844  auto res = BooleanFunction::Ite(std::move(p0), std::move(p1), std::move(p2), size);
845  if (res.is_ok())
846  {
847  return res.get();
848  }
849  else
850  {
851  log_error("python_context", "{}", res.get_error().get());
852  return std::nullopt;
853  }
854  },
855  py::arg("p0"),
856  py::arg("p1"),
857  py::arg("p2"),
858  py::arg("size"),
859  R"(
860  Joins three Boolean functions by an if-then-else operation with p0 as the condition, p1 as true-case, and p2 as false-case.
861  Requires ``p1`` to be of bit-size 1 and both Boolean functions ``p1`` and ``p2`` to be of the same bit-size.
862  Produces a new Boolean function of the specified bit-size that must be equal to the size of ``p1`` and ``p2``.
863 
864  :param hal_py.BooleanFunction p0: Boolean function condition.
865  :param hal_py.BooleanFunction p1: Boolean function for ``true``-case.
866  :param hal_py.BooleanFunction p1: Boolean function for ``false``-case.
867  :param int size: Bit-size of the operation, i.e., size of ``p1`` and ``p2``.
868  :returns: The joined Boolean function on success, None otherwise.
869  :rtype: hal_py.BooleanFunction or None
870  )");
871 
872  py_boolean_function.def(py::self & py::self, R"(
873  Joins two Boolean functions by an AND operation.
874  Requires both Boolean functions to be of the same bit-size.
875 
876  **Warning:** fails if the Boolean functions have different bit-sizes.
877 
878  :returns: The joined Boolean Bunction.
879  :rtype: hal_py.BooleanFunction
880  )");
881 
882  py_boolean_function.def(py::self &= py::self, R"(
883  Joins two Boolean functions by an AND operation in-place.
884  Requires both Boolean functions to be of the same bit-size.
885 
886  **Warning:** fails if the Boolean functions have different bit-sizes.
887 
888  :returns: The joined Boolean Bunction.
889  :rtype: hal_py.BooleanFunction
890  )");
891 
892  py_boolean_function.def(py::self | py::self, R"(
893  Joins two Boolean functions by an OR operation.
894  Requires both Boolean functions to be of the same bit-size.
895 
896  **Warning:** fails if the Boolean functions have different bit-sizes.
897 
898  :returns: The joined Boolean Bunction.
899  :rtype: hal_py.BooleanFunction
900  )");
901 
902  py_boolean_function.def(py::self |= py::self, R"(
903  Joins two Boolean functions by an OR operation in-place.
904  Requires both Boolean functions to be of the same bit-size.
905 
906  **Warning:** fails if the Boolean functions have different bit-sizes.
907 
908  :returns: The joined Boolean Bunction.
909  :rtype: hal_py.BooleanFunction
910  )");
911 
912  py_boolean_function.def(~py::self, R"(
913  Negates the Boolean function.
914 
915  :returns: The negated Boolean function.
916  :rtype: hal_py.BooleanFunction
917  )");
918 
919  py_boolean_function.def(py::self ^ py::self, R"(
920  Joins two Boolean functions by an XOR operation.
921  Requires both Boolean functions to be of the same bit-size.
922 
923  **Warning:** fails if the Boolean functions have different bit-sizes.
924 
925  :returns: The joined Boolean Bunction.
926  :rtype: hal_py.BooleanFunction
927  )");
928 
929  py_boolean_function.def(py::self ^= py::self, R"(
930  Joins two Boolean functions by an XOR operation in-place.
931  Requires both Boolean functions to be of the same bit-size.
932 
933  **Warning:** fails if the Boolean functions have different bit-sizes.
934 
935  :returns: The joined Boolean Bunction.
936  :rtype: hal_py.BooleanFunction
937  )");
938 
939  py_boolean_function.def(py::self + py::self, R"(
940  Joins two Boolean functions by an ADD operation.
941  Requires both Boolean functions to be of the same bit-size.
942 
943  **Warning:** fails if the Boolean functions have different bit-sizes.
944 
945  :returns: The joined Boolean Bunction.
946  :rtype: hal_py.BooleanFunction
947  )");
948 
949  py_boolean_function.def(py::self += py::self, R"(
950  Joins two Boolean functions by an ADD operation in-place.
951  Requires both Boolean functions to be of the same bit-size.
952 
953  **Warning:** fails if the Boolean functions have different bit-sizes.
954 
955  :returns: The joined Boolean Bunction.
956  :rtype: hal_py.BooleanFunction
957  )");
958 
959  py_boolean_function.def(py::self - py::self, R"(
960  Joins two Boolean functions by an SUB operation.
961  Requires both Boolean functions to be of the same bit-size.
962 
963  **Warning:** fails if the Boolean functions have different bit-sizes.
964 
965  :returns: The joined Boolean Bunction.
966  :rtype: hal_py.BooleanFunction
967  )");
968 
969  py_boolean_function.def(py::self -= py::self, R"(
970  Joins two Boolean functions by an SUB operation in-place.
971  Requires both Boolean functions to be of the same bit-size.
972 
973  **Warning:** fails if the Boolean functions have different bit-sizes.
974 
975  :returns: The joined Boolean Bunction.
976  :rtype: hal_py.BooleanFunction
977  )");
978 
979  py_boolean_function.def(py::self * py::self, R"(
980  Joins two Boolean functions by an MUL operation.
981  Requires both Boolean functions to be of the same bit-size.
982 
983  **Warning:* fails if the Boolean functions have different bit-sizes.
984 
985  :returns: The joined Boolean Bunction.
986  :rtype: hal_py.BooleanFunction
987  )");
988 
989  py_boolean_function.def(py::self *= py::self, R"(
990  Joins two Boolean functions by an MUL operation in-place.
991  Requires both Boolean functions to be of the same bit-size.
992 
993  **Warning:** fails if the Boolean functions have different bit-sizes.
994 
995  :returns: The joined Boolean Bunction.
996  :rtype: hal_py.BooleanFunction
997  )");
998 
999  py_boolean_function.def(py::self == py::self, R"(
1000  Checks whether two Boolean functions are equal.
1001 
1002  :returns: True if both Boolean functions are equal, False otherwise.
1003  :rtype: bool
1004  )");
1005 
1006  py_boolean_function.def(py::self != py::self, R"(
1007  Checks whether two Boolean functions are unequal.
1008 
1009  :returns: True if both Boolean functions are unequal, False otherwise.
1010  :rtype: bool
1011  )");
1012 
1013  py_boolean_function.def(py::self < py::self, R"(
1014  Checks whether this Boolean function is 'smaller' than the ``other`` Boolean function.
1015 
1016  :returns: True if this Boolean function is 'smaller', False otherwise.
1017  :rtype: bool
1018  )");
1019 
1020  py_boolean_function.def("is_empty", &BooleanFunction::is_empty, R"(
1021  Checks whether the Boolean function is empty.
1022 
1023  :returns: True if the Boolean function is empty, False otherwise.
1024  :rtype: bool
1025  )");
1026 
1027  py_boolean_function.def("clone", &BooleanFunction::clone, R"(
1028  Clones the Boolean function.
1029 
1030  :returns: The cloned Boolean function.
1031  :rtype: hal_py.BooleanFunction
1032  )");
1033 
1034  py_boolean_function.def_property_readonly("size", &BooleanFunction::size, R"(
1035  The bit-size of the Boolean function.
1036 
1037  :type: int
1038  )");
1039 
1040  py_boolean_function.def("get_size", &BooleanFunction::size, R"(
1041  Returns the bit-size of the Boolean function.
1042 
1043  :returns: The bit-size of the Boolean function.
1044  :rtype: int
1045  )");
1046 
1047  py_boolean_function.def("is", &BooleanFunction::is, py::arg("type"), R"(
1048  Checks whether the top-level node of the Boolean function is of a specific type.
1049 
1050  :param int type: The type to check for.
1051  :returns: True if the node is of the given type, False otherwise.
1052  :rtype: bool
1053  )");
1054 
1055  py_boolean_function.def("is_variable", &BooleanFunction::is_variable, R"(
1056  Checks whether the top-level node of the Boolean function is of type ``Variable`` and holds a specific variable name.
1057 
1058  :returns: True if the top-level node of the Boolean function is of type Variable, False otherwise.
1059  :rtype: bool
1060  )");
1061 
1062  py_boolean_function.def("has_variable_name", &BooleanFunction::has_variable_name, R"(
1063  Checks whether the top-level node of the Boolean function is of type Variable and holds a specific variable name.
1064 
1065  :param int value: The variable name to check for.
1066  :returns: True if the top-level node of the Boolean function is of type Variable and holds the given variable name, False otherwise.
1067  :rtype: bool
1068  )");
1069 
1070  py_boolean_function.def(
1071  "get_variable_name",
1072  [](const BooleanFunction& self) -> std::optional<std::string> {
1073  auto res = self.get_variable_name();
1074  if (res.is_ok())
1075  {
1076  return res.get();
1077  }
1078  else
1079  {
1080  log_error("python_context", "{}", res.get_error().get());
1081  return std::nullopt;
1082  }
1083  },
1084  R"(
1085  Get the variable name of the top-level node of the Boolean function of type Variable.
1086 
1087  :returns: The variable name on success, None otherwise.
1088  :rtype: str or None
1089  )");
1090 
1091  py_boolean_function.def("is_constant", &BooleanFunction::is_constant, R"(
1092  Checks whether the top-level node of the Boolean function is of type Constant.
1093 
1094  :returns: True if the top-level node of the Boolean function is of type Constant, False otherwise.
1095  :rtype: bool
1096  )");
1097 
1098  py_boolean_function.def("has_constant_value", py::overload_cast<const std::vector<BooleanFunction::Value>&>(&BooleanFunction::has_constant_value, py::const_), R"(
1099  Checks whether the top-level node of the Boolean function is of type Constant and holds a specific value.
1100 
1101  :param list[hal_py.BooleanFunction.Value] value: The constant value to check for.
1102  :returns: True if the top-level node of the Boolean function is of type Constant and holds the given value, False otherwise.
1103  :rtype: bool
1104  )");
1105 
1106  py_boolean_function.def("has_constant_value", py::overload_cast<u64>(&BooleanFunction::has_constant_value, py::const_), R"(
1107  Checks whether the top-level node of the Boolean function is of type Constant and holds a specific value.
1108 
1109  :param int value: The constant value to check for.
1110  :returns: True if the top-level node of the Boolean function is of type Constant and holds the given value, False otherwise.
1111  :rtype: bool
1112  )");
1113 
1114  py_boolean_function.def(
1115  "get_constant_value",
1116  [](const BooleanFunction& self) -> std::optional<std::vector<BooleanFunction::Value>> {
1117  auto res = self.get_constant_value();
1118  if (res.is_ok())
1119  {
1120  return res.get();
1121  }
1122  else
1123  {
1124  log_error("python_context", "{}", res.get_error().get());
1125  return std::nullopt;
1126  }
1127  },
1128  R"(
1129  Get the constant value of the top-level node of the Boolean function of type Constant as a list of ``hal_py.BooleanFunction.Value``.
1130 
1131  :returns: The constant value on success, None otherwise.
1132  :rtype: list[hal_py.BooleanFunction.Value] or None
1133  )");
1134 
1135  py_boolean_function.def(
1136  "get_constant_value_u64",
1137  [](const BooleanFunction& self) -> std::optional<u64> {
1138  auto res = self.get_constant_value_u64();
1139  if (res.is_ok())
1140  {
1141  return res.get();
1142  }
1143  else
1144  {
1145  log_error("python_context", "{}", res.get_error().get());
1146  return std::nullopt;
1147  }
1148  },
1149  R"(
1150  Get the constant value of the top-level node of the Boolean function of type Constant as long as it has a size <= 64-bit.
1151 
1152  :returns: The constant value on success, None otherwise.
1153  :rtype: int or None
1154  )");
1155 
1156  py_boolean_function.def("is_index", &BooleanFunction::is_index, R"(
1157  Checks whether the top-level node of the Boolean function is of type Index.
1158 
1159  :returns: True if the top-level node of the Boolean function is of type Index, False otherwise.
1160  :rtype: bool
1161  )");
1162 
1163  py_boolean_function.def("has_index_value", &BooleanFunction::has_index_value, R"(
1164  Checks whether the top-level node of the Boolean function is of type Index and holds a specific value.
1165 
1166  :param int value: The index value to check for.
1167  :returns: True if the top-level node of the Boolean function is of type Index and holds the given value, False otherwise.
1168  :rtype: bool
1169  )");
1170 
1171  py_boolean_function.def(
1172  "get_index_value",
1173  [](const BooleanFunction& self) -> std::optional<u16> {
1174  auto res = self.get_index_value();
1175  if (res.is_ok())
1176  {
1177  return res.get();
1178  }
1179  else
1180  {
1181  log_error("python_context", "{}", res.get_error().get());
1182  return std::nullopt;
1183  }
1184  },
1185  R"(
1186  Get the index value of the top-level node of the Boolean function of type Index.
1187 
1188  :returns: The index value on success, None otherwise.
1189  :rtype: int or None
1190  )");
1191 
1192  py_boolean_function.def_property_readonly("top_level_node", &BooleanFunction::get_top_level_node, R"(
1193  The top-level node of the Boolean function.
1194 
1195  **Warning:** fails if the Boolean function is empty.
1196 
1197  :type: hal_py.BooleanFunction.Node
1198  )");
1199 
1200  py_boolean_function.def("get_top_level_node", &BooleanFunction::get_top_level_node, R"(
1201  Returns the top-level node of the Boolean function.
1202 
1203  **Warning:** fails if the Boolean function is empty.
1204 
1205  :returns: The top-level node.
1206  :rtype: hal_py.BooleanFunction.Node
1207  )");
1208 
1209  py_boolean_function.def_property_readonly("length", &BooleanFunction::length, R"(
1210  The number of nodes in the Boolean function.
1211 
1212  :type: int
1213  )");
1214 
1215  py_boolean_function.def("get_length", &BooleanFunction::length, R"(
1216  Returns the number of nodes in the Boolean function.
1217 
1218  :returns: The number of nodes.
1219  :rtype: int
1220  )");
1221 
1222  py_boolean_function.def("nodes", &BooleanFunction::get_nodes, R"(
1223  The reverse polish notation list of the Boolean function nodes.
1224 
1225  :type: list[hal_py.BooleanFunction.Node]
1226  )");
1227 
1228  py_boolean_function.def("get_nodes", &BooleanFunction::get_nodes, R"(
1229  Returns the reverse polish notation list of the Boolean function nodes.
1230 
1231  :returns: A list of nodes.
1232  :rtype: list[hal_py.BooleanFunction.Node]
1233  )");
1234 
1235  py_boolean_function.def_property_readonly("parameters", &BooleanFunction::get_parameters, R"(
1236  The parameter list of the top-level node of the Boolean function.
1237 
1238  :type: list[hal_py.BooleanFunction]
1239  )");
1240 
1241  py_boolean_function.def("get_parameters", &BooleanFunction::get_parameters, R"(
1242  Returns the parameter list of the top-level node of the Boolean function.
1243 
1244  :returns: A vector of Boolean functions.
1245  :rtype: list[hal_py.BooleanFunction]
1246  )");
1247 
1248  py_boolean_function.def_property_readonly("variable_names", &BooleanFunction::get_variable_names, R"(
1249  The set of variable names used by the Boolean function.
1250 
1251  :type: set[str]
1252  )");
1253 
1254  py_boolean_function.def("get_variable_names", &BooleanFunction::get_variable_names, R"(
1255  Returns the set of variable names used by the Boolean function.
1256 
1257  :returns: A set of variable names.
1258  :rtype: set[str]
1259  )");
1260 
1261  py_boolean_function.def("__str__", [](const BooleanFunction& f) { return f.to_string(); }, R"(
1262  Translates the Boolean function into its string representation.
1263 
1264  :returns: The Boolean function as a string.
1265  :rtype: str
1266  )");
1267 
1268  py_boolean_function.def_static(
1269  "from_string",
1270  [](const std::string& expression) -> BooleanFunction {
1271  auto res = BooleanFunction::from_string(expression);
1272  if (res.is_ok())
1273  {
1274  return res.get();
1275  }
1276  else
1277  {
1278  log_error("python_context", "{}", res.get_error().get());
1279  return BooleanFunction();
1280  }
1281  },
1282  py::arg("expression"),
1283  R"(
1284  Parses a Boolean function from a string expression.
1285 
1286  :param str expression: Boolean function string.
1287  :returns: The Boolean function on success, an empty Boolean function otherwise.
1288  :rtype: hal_py.BooleanFunction
1289  )");
1290 
1291  py_boolean_function.def("simplify", &BooleanFunction::simplify, R"(
1292  Simplifies the Boolean function.
1293 
1294  :returns: The simplified Boolean function.
1295  :rtype: hal_py.BooleanFunction
1296  )");
1297 
1298  py_boolean_function.def(
1299  "substitute", py::overload_cast<const std::string&, const std::string&>(&BooleanFunction::substitute, py::const_), py::arg("old_variable_name"), py::arg("new_variable_name"), R"(
1300  Substitute a variable name with another one, i.e., renames the variable.
1301  The operation is applied to all instances of the variable in the function.
1302 
1303  :param str old_variable_name: The old variable name to substitute.
1304  :param str new_variable_name: The new variable name.
1305  :returns: The resulting Boolean function.
1306  :rtype: hal_py.BooleanFunction
1307  )");
1308 
1309  py_boolean_function.def(
1310  "substitute",
1311  [](const BooleanFunction& self, const std::string& variable_name, const BooleanFunction& function) -> std::optional<BooleanFunction> {
1312  auto res = self.substitute(variable_name, function);
1313  if (res.is_ok())
1314  {
1315  return res.get();
1316  }
1317  else
1318  {
1319  log_error("python_context", "{}", res.get_error().get());
1320  return std::nullopt;
1321  }
1322  },
1323  py::arg("variable_name"),
1324  py::arg("function"),
1325  R"(
1326  Substitute a variable with another Boolean function.
1327  The operation is applied to all instances of the variable in the function.
1328 
1329  :param str variable_name: The variable to substitute.
1330  :param hal_py.BooleanFunction function: The function replace the variable with.
1331  :returns: The resulting Boolean function on success, None otherwise.
1332  :rtype: hal_py.BooleanFunction or None
1333  )");
1334 
1335  py_boolean_function.def("substitute",
1336  py::overload_cast<const std::map<std::string, std::string>&>(&BooleanFunction::substitute, py::const_),
1337  py::arg("substitutions"),
1338  R"(
1339  Substitute multiple variable names with different names at once, i.e., rename the variables.
1340  The operation is applied to all instances of the variable in the function.
1341 
1342  :param dict[str,str] substitutions: A dict from old variable names to new variable names.
1343  :returns: The resulting Boolean function.
1344  :rtype: hal_py.BooleanFunction
1345  )");
1346 
1347  py_boolean_function.def(
1348  "substitute",
1349  [](const BooleanFunction& self, const std::map<std::string, BooleanFunction>& substitutions) -> std::optional<BooleanFunction> {
1350  auto res = self.substitute(substitutions);
1351  if (res.is_ok())
1352  {
1353  return res.get();
1354  }
1355  else
1356  {
1357  log_error("python_context", "{}", res.get_error().get());
1358  return std::nullopt;
1359  }
1360  },
1361  py::arg("substitutions"),
1362  R"(
1363  Substitute multiple variables with other boolean functions at once.
1364  The operation is applied to all instances of the variable in the function.
1365 
1366  :param dict substitutions: A map from the variable names to the function to replace the variable with.
1367  :returns: The resulting Boolean function on success, None otherwise.
1368  :rtype: hal_py.BooleanFunction or None
1369  )");
1370 
1371  py_boolean_function.def(
1372  "evaluate",
1373  [](const BooleanFunction& self, const std::unordered_map<std::string, BooleanFunction::Value>& inputs) -> std::optional<BooleanFunction::Value> {
1374  auto res = self.evaluate(inputs);
1375  if (res.is_ok())
1376  {
1377  return res.get();
1378  }
1379  else
1380  {
1381  log_error("python_context", "{}", res.get_error().get());
1382  return std::nullopt;
1383  }
1384  },
1385  py::arg("inputs"),
1386  R"(
1387  Evaluates a Boolean function comprising only single-bit variables using the given input values.
1388 
1389  :param dict[str,hal_py.BooleanFunction.Value] inputs: A dict from variable name to input value.
1390  :returns: The resulting value on success, None otherwise.
1391  :rtype: hal_py.BooleanFunction.Value or None
1392  )");
1393 
1394  py_boolean_function.def(
1395  "evaluate",
1396  [](const BooleanFunction& self, const std::unordered_map<std::string, std::vector<BooleanFunction::Value>>& inputs) -> std::optional<std::vector<BooleanFunction::Value>> {
1397  auto res = self.evaluate(inputs);
1398  if (res.is_ok())
1399  {
1400  return res.get();
1401  }
1402  else
1403  {
1404  log_error("python_context", "{}", res.get_error().get());
1405  return std::nullopt;
1406  }
1407  },
1408  py::arg("inputs"),
1409  R"(
1410  Evaluates a Boolean function comprising multi-bit variables using the given input values.
1411 
1412  :param dict[str,list[hal_py.BooleanFunction.Value]] inputs: A dict from variable name to a list of input values.
1413  :returns: A vector of values on success, None otherwise.
1414  :rtype: list[hal_py.BooleanFunction.Value] or None
1415  )");
1416 
1417  py_boolean_function.def(
1418  "compute_truth_table",
1419  [](const BooleanFunction& self, const std::vector<std::string>& ordered_variables, bool remove_unknown_variables) -> std::optional<std::vector<std::vector<BooleanFunction::Value>>> {
1420  auto res = self.compute_truth_table(ordered_variables, remove_unknown_variables);
1421  if (res.is_ok())
1422  {
1423  return res.get();
1424  }
1425  else
1426  {
1427  log_error("python_context", "{}", res.get_error().get());
1428  return std::nullopt;
1429  }
1430  },
1431  py::arg("ordered_variables") = std::vector<std::string>(),
1432  py::arg("remove_unknown_variables") = false,
1433  R"(
1434  Computes the truth table outputs for a Boolean function that comprises <= 10 single-bit variables.
1435 
1436  **Warning:** The generation of the truth table is exponential in the number of parameters.
1437 
1438  :param list[str] ordered_variables: A list describing the order of input variables used to generate the truth table. Defaults to an empty list.
1439  :param bool remove_unknown_variables: Set True to remove variables from the truth table that are not present within the Boolean function, False otherwise. Defaults to False.
1440  :returns: A list of values representing the truth table output on success, None otherwise.
1441  :rtype: list[list[hal_py.BooleanFunction.Value]] or None
1442  )");
1443 
1444  py_boolean_function.def(
1445  "get_truth_table_as_string",
1446  [](const BooleanFunction& self, const std::vector<std::string>& ordered_variables, std::string function_name, bool remove_unknown_variables) -> std::optional<std::string> {
1447  auto res = self.get_truth_table_as_string(ordered_variables, function_name, remove_unknown_variables);
1448  if (res.is_ok())
1449  {
1450  return res.get();
1451  }
1452  else
1453  {
1454  log_error("python_context", "{}", res.get_error().get());
1455  return std::nullopt;
1456  }
1457  },
1458  py::arg("ordered_variables") = std::vector<std::string>(),
1459  py::arg("function_name") = std::string(""),
1460  py::arg("remove_unknown_variables") = false,
1461  R"(
1462  Prints the truth table for a Boolean function that comprises <= 10 single-bit variables.
1463 
1464  **Warning:** The generation of the truth table is exponential in the number of parameters.
1465 
1466  :param list[str] ordered_variables: A list describing the order of input variables used to generate the truth table. Defaults to an empty list.
1467  :param str function_name: The name of the Boolean function to be printed as header of the output columns.
1468  :param bool remove_unknown_variables: Set True to remove variables from the truth table that are not present within the Boolean function, False otherwise. Defaults to False.
1469  :returns: A string representing the truth table on success, None otherwise.
1470  :rtype: str or None
1471  )");
1472 
1473  py::class_<BooleanFunction::Node> py_boolean_function_node(py_boolean_function, "Node", R"(
1474  Node refers to an abstract syntax tree node of a Boolean function. A node is an abstract base class for either an operation (e.g., AND, XOR) or an operand (e.g., a signal name variable).
1475  )");
1476 
1477  py_boolean_function_node.def_readwrite("type", &BooleanFunction::Node::type, R"(
1478  The type of the node.
1479 
1480  :type: int
1481  )");
1482 
1483  py_boolean_function_node.def_readwrite("size", &BooleanFunction::Node::size, R"(
1484  The bit-size of the node.
1485 
1486  :type: int
1487  )");
1488 
1489  py_boolean_function_node.def_readwrite("constant", &BooleanFunction::Node::constant, R"(
1490  The (optional) constant value of the node.
1491 
1492  :type: list[hal_py.BooleanFunction.Value]
1493  )");
1494 
1495  py_boolean_function_node.def_readwrite("index", &BooleanFunction::Node::index, R"(
1496  The (optional) index value of the node.
1497 
1498  :type: int
1499  )");
1500 
1501  py_boolean_function_node.def_readwrite("variable", &BooleanFunction::Node::variable, R"(
1502  The (optional) variable name of the node.
1503 
1504  :type: str
1505  )");
1506 
1507  py_boolean_function_node.def_static("Operation", BooleanFunction::Node::Operation, py::arg("type"), py::arg("size"), R"(
1508  Constructs an 'operation' node.
1509 
1510  :param int type: The type of the operation.
1511  :param int size: The bit-size of the operation.
1512  :returns: The node.
1513  :rtype: hal_py.BooleanFunction.Node
1514  )");
1515 
1516  py_boolean_function_node.def_static("Constant", BooleanFunction::Node::Constant, py::arg("value"), R"(
1517  Constructs a 'constant' node.
1518 
1519  :param list[hal_py.BooleanFunction.Value] value: The constant value of the node.
1520  :returns: The node.
1521  :rtype: hal_py.BooleanFunction.Node
1522  )");
1523 
1524  py_boolean_function_node.def_static("Index", BooleanFunction::Node::Index, py::arg("index"), py::arg("size"), R"(
1525  Constructs an 'index' node.
1526 
1527  :param int value: The index value of the node.
1528  :param int size: The bit-size of the node.
1529  :returns: The node.
1530  :rtype: hal_py.BooleanFunction.Node
1531  )");
1532 
1533  py_boolean_function_node.def_static("Variable", BooleanFunction::Node::Variable, py::arg("variable"), py::arg("size"), R"(
1534  Constructs a 'variable' node.
1535 
1536  :param int value: The variable name of the node.
1537  :param int size: The bit-size of the node.
1538  :returns: The node.
1539  :rtype: hal_py.BooleanFunction.Node
1540  )");
1541 
1542  py_boolean_function_node.def(py::self == py::self, R"(
1543  Checks whether two Boolean function nodes are equal.
1544 
1545  :returns: True if both Boolean function nodes are equal, False otherwise.
1546  :rtype: bool
1547  )");
1548 
1549  py_boolean_function_node.def(py::self != py::self, R"(
1550  Checks whether two Boolean function nodes are unequal.
1551 
1552  :returns: True if both Boolean function nodes are unequal, False otherwise.
1553  :rtype: bool
1554  )");
1555 
1556  py_boolean_function_node.def(py::self < py::self, R"(
1557  Checks whether this Boolean function node is 'smaller' than the ``other`` Boolean function node.
1558 
1559  :returns: True if this Boolean function node is 'smaller', False otherwise.
1560  :rtype: bool
1561  )");
1562 
1563  py_boolean_function_node.def("clone", &BooleanFunction::Node::clone, R"(
1564  Clones the Boolean function node.
1565 
1566  :returns: The cloned Boolean function node.
1567  :rtype: hal_py.BooleanFunction.Node
1568  )");
1569 
1570  py_boolean_function_node.def("__str__", [](const BooleanFunction::Node& n) { return n.to_string(); }, R"(
1571  Translates the Boolean function node into its string representation.
1572 
1573  :returns: The Boolean function node as a string.
1574  :rtype: str
1575  )");
1576 
1577  py_boolean_function_node.def_property_readonly("arity", &BooleanFunction::Node::get_arity, R"(
1578  The arity of the Boolean function node, i.e., the number of parameters.
1579 
1580  :type: int
1581  )");
1582 
1583  py_boolean_function_node.def("get_arity", &BooleanFunction::Node::get_arity, R"(
1584  Returns the arity of the Boolean function node, i.e., the number of parameters.
1585 
1586  :returns: The arity.
1587  :rtype: int
1588  )");
1589 
1590  py_boolean_function_node.def_static("get_arity_of_type", &BooleanFunction::Node::get_arity_of_type, py::arg("type"), R"(
1591  Returns the arity for a Boolean function node of the given type, i.e., the number of parameters.
1592 
1593  :returns: The arity.
1594  :rtype: int
1595  )");
1596 
1597  py_boolean_function_node.def("is", &BooleanFunction::Node::is, py::arg("type"), R"(
1598  Checks whether the Boolean function node is of a specific type.
1599 
1600  :param int type: The type to check for.
1601  :returns: True if the node is of the given type, False otherwise.
1602  :rtype: bool
1603  )");
1604 
1605  py_boolean_function_node.def("is_constant", &BooleanFunction::Node::is_constant, R"(
1606  Checks whether the Boolean function node is of type Constant.
1607 
1608  :returns: True if the Boolean function node is of type Constant, False otherwise.
1609  :rtype: bool
1610  )");
1611 
1612  py_boolean_function_node.def("has_constant_value", py::overload_cast<const std::vector<BooleanFunction::Value>&>(&BooleanFunction::Node::has_constant_value, py::const_), py::arg("value"), R"(
1613  Checks whether the Boolean function node is of type Constant and holds a specific value.
1614 
1615  :param list[hal_py.BooleanFunction.Value] value: The value to check for.
1616  :returns: True if the Boolean function node is of type Constant and holds the given value, False otherwise.
1617  :rtype: bool
1618  )");
1619 
1620  py_boolean_function_node.def("has_constant_value", py::overload_cast<u64>(&BooleanFunction::Node::has_constant_value, py::const_), py::arg("value"), R"(
1621  Checks whether the Boolean function node is of type Constant and holds a specific value.
1622 
1623  :param int value: The value to check for.
1624  :returns: True if the Boolean function node is of type Constant and holds the given value, False otherwise.
1625  :rtype: bool
1626  )");
1627 
1628  py_boolean_function_node.def(
1629  "get_constant_value",
1630  [](const BooleanFunction::Node& self) -> std::optional<std::vector<BooleanFunction::Value>> {
1631  if (const auto res = self.get_constant_value(); res.is_ok())
1632  {
1633  return res.get();
1634  }
1635  else
1636  {
1637  log_error("python_context", "could not get constant value:\n{}", res.get_error().get());
1638  return std::nullopt;
1639  }
1640  },
1641  R"(
1642  Get the constant value of the node of type ``Constant`` as a list of ``hal_py.BooleanFunction.Value``.
1643 
1644  :returns: The constant value on success, None otherwise.
1645  :rtype: list[hal_py.BooleanFunction.Value] or None
1646  )");
1647 
1648  py_boolean_function_node.def(
1649  "get_constant_value_u64",
1650  [](const BooleanFunction::Node& self) -> std::optional<u64> {
1651  if (const auto res = self.get_constant_value_u64(); res.is_ok())
1652  {
1653  return res.get();
1654  }
1655  else
1656  {
1657  log_error("python_context", "could not get constant value:\n{}", res.get_error().get());
1658  return std::nullopt;
1659  }
1660  },
1661  R"(
1662  Get the constant value of the node of type ``Constant`` as long as it has a size <= 64-bit.
1663 
1664  :returns: The constant value on success, None otherwise.
1665  :rtype: int or None
1666  )");
1667 
1668  py_boolean_function_node.def("is_index", &BooleanFunction::Node::is_index, R"(
1669  Checks whether the Boolean function node is of type Index.
1670 
1671  :returns: True if the Boolean function node is of type Index, False otherwise.
1672  :rtype: bool
1673  )");
1674 
1675  py_boolean_function_node.def("has_index_value", &BooleanFunction::Node::has_index_value, py::arg("value"), R"(
1676  Checks whether the Boolean function node is of type Index and holds a specific value.
1677 
1678  :param int value: The value to check for.
1679  :returns: True if the Boolean function node is of type Index and holds the given value, False otherwise.
1680  :rtype: bool
1681  )");
1682 
1683  py_boolean_function_node.def(
1684  "get_index_value",
1685  [](const BooleanFunction::Node& self) -> std::optional<u64> {
1686  if (const auto res = self.get_index_value(); res.is_ok())
1687  {
1688  return res.get();
1689  }
1690  else
1691  {
1692  log_error("python_context", "could not get index value:\n{}", res.get_error().get());
1693  return std::nullopt;
1694  }
1695  },
1696  R"(
1697  Get the index value of node of type ``Index``.
1698 
1699  :returns: The index value on success, None otherwise.
1700  :rtype: int or None
1701  )");
1702 
1703  py_boolean_function_node.def("is_variable", &BooleanFunction::Node::is_variable, R"(
1704  Checks whether the Boolean function node is of type Variable.
1705 
1706  :returns: True if the Boolean function node is of type Variable, False otherwise.
1707  :rtype: bool
1708  )");
1709 
1710  py_boolean_function_node.def("has_variable_name", &BooleanFunction::Node::has_variable_name, py::arg("variable_name"), R"(
1711  Checks whether the Boolean function node is of type Variable and holds a specific variable name.
1712 
1713  :param str variable_name: The variable name to check for.
1714  :returns: True if the Boolean function node is of type Variable and holds the given variable name, False otherwise.
1715  :rtype: bool
1716  )");
1717 
1718  py_boolean_function_node.def(
1719  "get_variable_name",
1720  [](const BooleanFunction::Node& self) -> std::optional<std::string> {
1721  if (const auto res = self.get_variable_name(); res.is_ok())
1722  {
1723  return res.get();
1724  }
1725  else
1726  {
1727  log_error("python_context", "could not get variable name:\n{}", res.get_error().get());
1728  return std::nullopt;
1729  }
1730  },
1731  R"(
1732  Get the variable name of node of type ``Variable``.
1733 
1734  :returns: The variable name on success, None otherwise.
1735  :rtype: str or None
1736  )");
1737 
1738  py_boolean_function_node.def("is_operation", &BooleanFunction::Node::is_operation, R"(
1739  Checks whether the Boolean function node is an operation node.
1740 
1741  :returns: True if the Boolean function node is an operation node, False otherwise.
1742  :rtype: bool
1743  )");
1744 
1745  py_boolean_function_node.def("is_operand", &BooleanFunction::Node::is_operand, R"(
1746  Checks whether the Boolean function node is an operand node.
1747 
1748  :returns: True if the Boolean function node is an operand node, False otherwise.
1749  :rtype: bool
1750  )");
1751 
1752  py_boolean_function_node.def("is_commutative", &BooleanFunction::Node::is_commutative, R"(
1753  Checks whether the Boolean function node is commutative.
1754 
1755  :returns: True if the Boolean function node is commutative, False otherwise.
1756  :rtype: bool
1757  )");
1758 
1759  py::class_<BooleanFunction::NodeType> py_boolean_function_node_type(py_boolean_function, "NodeType", R"(
1760  Holds all node types available in a Boolean function.
1761  )");
1762 
1763  py_boolean_function_node_type.def_readonly_static("And", &BooleanFunction::NodeType::And);
1764  py_boolean_function_node_type.def_readonly_static("Or", &BooleanFunction::NodeType::Or);
1765  py_boolean_function_node_type.def_readonly_static("Not", &BooleanFunction::NodeType::Not);
1766  py_boolean_function_node_type.def_readonly_static("Xor", &BooleanFunction::NodeType::Xor);
1767 
1768  py_boolean_function_node_type.def_readonly_static("Add", &BooleanFunction::NodeType::Add);
1769  py_boolean_function_node_type.def_readonly_static("Sub", &BooleanFunction::NodeType::Sub);
1770  py_boolean_function_node_type.def_readonly_static("Mul", &BooleanFunction::NodeType::Mul);
1771  py_boolean_function_node_type.def_readonly_static("Sdiv", &BooleanFunction::NodeType::Sdiv);
1772  py_boolean_function_node_type.def_readonly_static("Udiv", &BooleanFunction::NodeType::Udiv);
1773  py_boolean_function_node_type.def_readonly_static("Srem", &BooleanFunction::NodeType::Srem);
1774  py_boolean_function_node_type.def_readonly_static("Urem", &BooleanFunction::NodeType::Urem);
1775 
1776  py_boolean_function_node_type.def_readonly_static("Concat", &BooleanFunction::NodeType::Concat);
1777  py_boolean_function_node_type.def_readonly_static("Slice", &BooleanFunction::NodeType::Slice);
1778  py_boolean_function_node_type.def_readonly_static("Zext", &BooleanFunction::NodeType::Zext);
1779  py_boolean_function_node_type.def_readonly_static("Sext", &BooleanFunction::NodeType::Sext);
1780 
1781  py_boolean_function_node_type.def_readonly_static("Shl", &BooleanFunction::NodeType::Shl);
1782  py_boolean_function_node_type.def_readonly_static("Lshr", &BooleanFunction::NodeType::Lshr);
1783  py_boolean_function_node_type.def_readonly_static("Ashr", &BooleanFunction::NodeType::Ashr);
1784  py_boolean_function_node_type.def_readonly_static("Rol", &BooleanFunction::NodeType::Rol);
1785  py_boolean_function_node_type.def_readonly_static("Ror", &BooleanFunction::NodeType::Ror);
1786 
1787  py_boolean_function_node_type.def_readonly_static("Eq", &BooleanFunction::NodeType::Eq);
1788  py_boolean_function_node_type.def_readonly_static("Sle", &BooleanFunction::NodeType::Sle);
1789  py_boolean_function_node_type.def_readonly_static("Slt", &BooleanFunction::NodeType::Slt);
1790  py_boolean_function_node_type.def_readonly_static("Ule", &BooleanFunction::NodeType::Ule);
1791  py_boolean_function_node_type.def_readonly_static("Ult", &BooleanFunction::NodeType::Ult);
1792  py_boolean_function_node_type.def_readonly_static("Ite", &BooleanFunction::NodeType::Ite);
1793 
1794  py_boolean_function_node_type.def_readonly_static("Constant", &BooleanFunction::NodeType::Constant);
1795  py_boolean_function_node_type.def_readonly_static("Index", &BooleanFunction::NodeType::Index);
1796  py_boolean_function_node_type.def_readonly_static("Variable", &BooleanFunction::NodeType::Variable);
1797  }
1798 } // namespace hal
static Result< BooleanFunction > Slt(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
bool has_index_value(u16 index) const
static Result< BooleanFunction > Ite(BooleanFunction &&p0, BooleanFunction &&p1, BooleanFunction &&p2, u16 size)
static Result< BooleanFunction > Eq(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
static BooleanFunction Var(const std::string &name, u16 size=1)
static Result< BooleanFunction > Xor(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
const BooleanFunction::Node & get_top_level_node() const
static Result< BooleanFunction > Add(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
std::set< std::string > get_variable_names() const
static Result< BooleanFunction > Lshr(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
bool has_constant_value(const std::vector< Value > &value) const
static Result< BooleanFunction > Zext(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
static Result< BooleanFunction > Mul(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
bool has_variable_name(const std::string &variable_name) const
static Result< BooleanFunction > Ule(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
static Result< BooleanFunction > Sub(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
static Result< BooleanFunction > Sext(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
static Result< BooleanFunction > Udiv(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
static Result< BooleanFunction > Concat(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
static Result< BooleanFunction > Ult(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
static BooleanFunction Index(u16 index, u16 size)
static Result< BooleanFunction > Sle(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
static Result< BooleanFunction > build(std::vector< Node > &&nodes)
static Result< BooleanFunction > from_string(const std::string &expression)
static Result< BooleanFunction > Slice(BooleanFunction &&p0, BooleanFunction &&p1, BooleanFunction &&p2, u16 size)
const std::vector< BooleanFunction::Node > & get_nodes() const
bool is(u16 type) const
BooleanFunction simplify() const
BooleanFunction clone() const
Value
represents the type of the node
static Result< BooleanFunction > Or(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
static Result< BooleanFunction > Urem(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
static Result< BooleanFunction > Ror(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
static Result< BooleanFunction > Sdiv(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
static std::string to_string(Value value)
static BooleanFunction Const(const BooleanFunction::Value &value)
static Result< BooleanFunction > Ashr(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
static Result< u64 > to_u64(const std::vector< BooleanFunction::Value > &value)
static Result< BooleanFunction > Not(BooleanFunction &&p0, u16 size)
static Result< BooleanFunction > And(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
std::vector< BooleanFunction > get_parameters() const
BooleanFunction substitute(const std::string &old_variable_name, const std::string &new_variable_name) const
static Result< BooleanFunction > Shl(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
static Result< BooleanFunction > Rol(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
static Result< BooleanFunction > Srem(BooleanFunction &&p0, BooleanFunction &&p1, u16 size)
uint16_t u16
Definition: defines.h:40
uint8_t u8
Definition: defines.h:39
void boolean_function_init(py::module &m)
#define log_error(channel,...)
Definition: log.h:78
const Module * module(const Gate *g, const NodeBoxes &boxes)
n
Definition: test.py:6
std::vector< BooleanFunction::Value > constant
The (optional) constant value of the node.
u16 type
The type of the node.
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
static Node Index(u16 index, u16 size)
u16 index
The (optional) index value of the node.
static Node Variable(const std::string variable, u16 size)