File tree 1 file changed +14
-11
lines changed
1 file changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -166,32 +166,35 @@ namespace hal
166
166
m.def (
167
167
" simplify" ,
168
168
[](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);
175
171
176
- auto res = z3_utils::simplify (expr. get () );
172
+ auto res = z3_utils::simplify_local (expr);
177
173
if (res.is_error ())
178
174
{
179
175
log_error (" python_context" , " {}" , res.get_error ().get ());
180
176
return std::nullopt;
181
177
}
182
178
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 ())
185
181
{
186
- return bf .get ();
182
+ return bf_s .get ();
187
183
}
188
184
else
189
185
{
190
186
log_error (" python_context" , " {}" , res.get_error ().get ());
191
187
return std::nullopt;
192
188
}
193
189
},
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
+ )" );
195
198
196
199
#ifndef PYBIND11_MODULE
197
200
return m.ptr ();
You can’t perform that action at this time.
0 commit comments