mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 12:08:18 +00:00
expose name inclusion as optional
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
dbe2c9b305
commit
b992f59aad
|
@ -193,16 +193,16 @@ extern "C" {
|
||||||
Z3_CATCH_RETURN("");
|
Z3_CATCH_RETURN("");
|
||||||
}
|
}
|
||||||
|
|
||||||
Z3_string Z3_API Z3_goal_to_dimacs_string(Z3_context c, Z3_goal g) {
|
Z3_string Z3_API Z3_goal_to_dimacs_string(Z3_context c, Z3_goal g, bool include_names) {
|
||||||
Z3_TRY;
|
Z3_TRY;
|
||||||
LOG_Z3_goal_to_dimacs_string(c, g);
|
LOG_Z3_goal_to_dimacs_string(c, g, include_names);
|
||||||
RESET_ERROR_CODE();
|
RESET_ERROR_CODE();
|
||||||
std::ostringstream buffer;
|
std::ostringstream buffer;
|
||||||
if (!to_goal_ref(g)->is_cnf()) {
|
if (!to_goal_ref(g)->is_cnf()) {
|
||||||
SET_ERROR_CODE(Z3_INVALID_ARG, "If this is not what you want, then preprocess by optional bit-blasting and applying tseitin-cnf");
|
SET_ERROR_CODE(Z3_INVALID_ARG, "If this is not what you want, then preprocess by optional bit-blasting and applying tseitin-cnf");
|
||||||
RETURN_Z3(nullptr);
|
RETURN_Z3(nullptr);
|
||||||
}
|
}
|
||||||
to_goal_ref(g)->display_dimacs(buffer, true);
|
to_goal_ref(g)->display_dimacs(buffer, include_names);
|
||||||
// Hack for removing the trailing '\n'
|
// Hack for removing the trailing '\n'
|
||||||
std::string result = buffer.str();
|
std::string result = buffer.str();
|
||||||
SASSERT(result.size() > 0);
|
SASSERT(result.size() > 0);
|
||||||
|
|
|
@ -2630,7 +2630,7 @@ namespace z3 {
|
||||||
return expr(ctx(), Z3_mk_and(ctx(), n, args.ptr()));
|
return expr(ctx(), Z3_mk_and(ctx(), n, args.ptr()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string dimacs() const { return std::string(Z3_goal_to_dimacs_string(ctx(), m_goal)); }
|
std::string dimacs(bool include_names = true) const { return std::string(Z3_goal_to_dimacs_string(ctx(), m_goal, include_names)); }
|
||||||
friend std::ostream & operator<<(std::ostream & out, goal const & g);
|
friend std::ostream & operator<<(std::ostream & out, goal const & g);
|
||||||
};
|
};
|
||||||
inline std::ostream & operator<<(std::ostream & out, goal const & g) { out << Z3_goal_to_string(g.ctx(), g); return out; }
|
inline std::ostream & operator<<(std::ostream & out, goal const & g) { out << Z3_goal_to_string(g.ctx(), g); return out; }
|
||||||
|
|
|
@ -225,9 +225,9 @@ namespace Microsoft.Z3
|
||||||
/// Goal to DIMACS formatted string conversion.
|
/// Goal to DIMACS formatted string conversion.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A string representation of the Goal.</returns>
|
/// <returns>A string representation of the Goal.</returns>
|
||||||
public string ToDimacs()
|
public string ToDimacs(bool include_names = true)
|
||||||
{
|
{
|
||||||
return Native.Z3_goal_to_dimacs_string(Context.nCtx, NativeObject);
|
return Native.Z3_goal_to_dimacs_string(Context.nCtx, NativeObject, include_names);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -5413,9 +5413,9 @@ class Goal(Z3PPObject):
|
||||||
"""Return a textual representation of the s-expression representing the goal."""
|
"""Return a textual representation of the s-expression representing the goal."""
|
||||||
return Z3_goal_to_string(self.ctx.ref(), self.goal)
|
return Z3_goal_to_string(self.ctx.ref(), self.goal)
|
||||||
|
|
||||||
def dimacs(self):
|
def dimacs(self, include_names = True):
|
||||||
"""Return a textual representation of the goal in DIMACS format."""
|
"""Return a textual representation of the goal in DIMACS format."""
|
||||||
return Z3_goal_to_dimacs_string(self.ctx.ref(), self.goal)
|
return Z3_goal_to_dimacs_string(self.ctx.ref(), self.goal, include_names)
|
||||||
|
|
||||||
def translate(self, target):
|
def translate(self, target):
|
||||||
"""Copy goal `self` to context `target`.
|
"""Copy goal `self` to context `target`.
|
||||||
|
|
|
@ -5840,9 +5840,9 @@ extern "C" {
|
||||||
preserve satisfiability, it should apply bit-blasting tactics.
|
preserve satisfiability, it should apply bit-blasting tactics.
|
||||||
Quantifiers and theory atoms will not be encoded.
|
Quantifiers and theory atoms will not be encoded.
|
||||||
|
|
||||||
def_API('Z3_goal_to_dimacs_string', STRING, (_in(CONTEXT), _in(GOAL)))
|
def_API('Z3_goal_to_dimacs_string', STRING, (_in(CONTEXT), _in(GOAL), _in(BOOL)))
|
||||||
*/
|
*/
|
||||||
Z3_string Z3_API Z3_goal_to_dimacs_string(Z3_context c, Z3_goal g);
|
Z3_string Z3_API Z3_goal_to_dimacs_string(Z3_context c, Z3_goal g, bool include_names);
|
||||||
|
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue