3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-06 17:44:08 +00:00

expose name inclusion as optional

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2020-08-30 10:32:17 -07:00
parent dbe2c9b305
commit b992f59aad
5 changed files with 10 additions and 10 deletions

View file

@ -193,16 +193,16 @@ extern "C" {
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;
LOG_Z3_goal_to_dimacs_string(c, g);
LOG_Z3_goal_to_dimacs_string(c, g, include_names);
RESET_ERROR_CODE();
std::ostringstream buffer;
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");
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'
std::string result = buffer.str();
SASSERT(result.size() > 0);

View file

@ -2630,7 +2630,7 @@ namespace z3 {
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);
};
inline std::ostream & operator<<(std::ostream & out, goal const & g) { out << Z3_goal_to_string(g.ctx(), g); return out; }

View file

@ -225,9 +225,9 @@ namespace Microsoft.Z3
/// Goal to DIMACS formatted string conversion.
/// </summary>
/// <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>

View file

@ -5413,9 +5413,9 @@ class Goal(Z3PPObject):
"""Return a textual representation of the s-expression representing the 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 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):
"""Copy goal `self` to context `target`.

View file

@ -5840,9 +5840,9 @@ extern "C" {
preserve satisfiability, it should apply bit-blasting tactics.
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);
/*@}*/