Skip to content

Commit 54faa98

Browse files
committed
fix z3 utils pybind
1 parent 77c37f8 commit 54faa98

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

plugins/z3_utils/python/python_bindings.cpp

+14-11
Original file line numberDiff line numberDiff line change
@@ -166,32 +166,35 @@ namespace hal
166166
m.def(
167167
"simplify",
168168
[](const BooleanFunction& bf) -> std::optional<BooleanFunction> {
169-
auto expr = z3_utils::from_bf(bf);
170-
if (expr.is_error())
171-
{
172-
log_error("python_context", "{}", expr.get_error().get());
173-
return std::nullopt;
174-
}
169+
auto ctx = z3::context();
170+
auto expr = z3_utils::from_bf(bf, ctx);
175171

176-
auto res = z3_utils::simplify(expr.get());
172+
auto res = z3_utils::simplify_local(expr);
177173
if (res.is_error())
178174
{
179175
log_error("python_context", "{}", res.get_error().get());
180176
return std::nullopt;
181177
}
182178

183-
auto bf = z3_utils::to_bf(res.get());
184-
if (bf.is_ok())
179+
auto bf_s = z3_utils::to_bf(res.get());
180+
if (bf_s.is_ok())
185181
{
186-
return bf.get();
182+
return bf_s.get();
187183
}
188184
else
189185
{
190186
log_error("python_context", "{}", res.get_error().get());
191187
return std::nullopt;
192188
}
193189
},
194-
)
190+
py::arg("bf"),
191+
R"(
192+
Simplifies a Boolean function using the Z3 solver.
193+
This is done by using the Z3 solver to simplify the function and then converting it back to a Boolean function.
194+
:param hal_py.BooleanFunction bf: The Boolean function to simplify.
195+
:returns: The simplified Boolean function on success, None otherwise.
196+
:rtype: hal_py.BooleanFunction or None
197+
)");
195198

196199
#ifndef PYBIND11_MODULE
197200
return m.ptr();

0 commit comments

Comments
 (0)