mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
fixes
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
16555d4886
commit
2746528aab
19 changed files with 186 additions and 106 deletions
|
@ -178,4 +178,18 @@ extern "C" {
|
|||
Z3_CATCH_RETURN("");
|
||||
}
|
||||
|
||||
Z3_string Z3_API Z3_goal_to_dimacs_string(Z3_context c, Z3_goal g) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_goal_to_dimacs_string(c, g);
|
||||
RESET_ERROR_CODE();
|
||||
std::ostringstream buffer;
|
||||
to_goal_ref(g)->display_dimacs(buffer);
|
||||
// Hack for removing the trailing '\n'
|
||||
std::string result = buffer.str();
|
||||
SASSERT(result.size() > 0);
|
||||
result.resize(result.size()-1);
|
||||
return mk_c(c)->mk_external_string(result);
|
||||
Z3_CATCH_RETURN("");
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -139,6 +139,10 @@ extern "C" {
|
|||
SET_ERROR_CODE(Z3_PARSER_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
bool initialized = to_solver(s)->m_solver.get() != 0;
|
||||
if (!initialized)
|
||||
init_solver(c, s);
|
||||
ptr_vector<expr>::const_iterator it = ctx->begin_assertions();
|
||||
ptr_vector<expr>::const_iterator end = ctx->end_assertions();
|
||||
for (; it != end; ++it) {
|
||||
|
|
|
@ -208,6 +208,15 @@ namespace Microsoft.Z3
|
|||
return Native.Z3_goal_to_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Goal to DIMACS formatted string conversion.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of the Goal.</returns>
|
||||
public string ToDimacs()
|
||||
{
|
||||
return Native.Z3_goal_to_dimacs_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Goal to BoolExpr conversion.
|
||||
/// </summary>
|
||||
|
|
|
@ -4971,6 +4971,10 @@ 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):
|
||||
"""Return a textual representation of the goal in DIMACS format."""
|
||||
return Z3_goal_to_dimacs_string(self.ctx.ref(), self.goal)
|
||||
|
||||
def translate(self, target):
|
||||
"""Copy goal `self` to context `target`.
|
||||
|
||||
|
@ -6300,7 +6304,7 @@ class Solver(Z3PPObject):
|
|||
|
||||
def from_file(self, filename):
|
||||
"""Parse assertions from a file"""
|
||||
Z3_solver_from_file(self.ctx.ref(), self.solver)
|
||||
Z3_solver_from_file(self.ctx.ref(), self.solver, filename)
|
||||
|
||||
def from_string(self, s):
|
||||
"""Parse assertions from a string"""
|
||||
|
|
|
@ -5568,6 +5568,13 @@ extern "C" {
|
|||
*/
|
||||
Z3_string Z3_API Z3_goal_to_string(Z3_context c, Z3_goal g);
|
||||
|
||||
/**
|
||||
\brief Convert a goal into a DIMACS formatted string.
|
||||
|
||||
def_API('Z3_goal_to_dimacs_string', STRING, (_in(CONTEXT), _in(GOAL)))
|
||||
*/
|
||||
Z3_string Z3_API Z3_goal_to_dimacs_string(Z3_context c, Z3_goal g);
|
||||
|
||||
/*@}*/
|
||||
|
||||
/** @name Tactics and Probes */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue