3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-25 10:05:32 +00:00

added facility to persist model transformations

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2017-11-02 00:05:52 -05:00
commit fd49a0c89c
195 changed files with 3601 additions and 2139 deletions

View file

@ -34,7 +34,7 @@ Revision History:
namespace smtlib {
solver::solver():
m_ast_manager(m_params.m_proof ? PGM_FINE : PGM_DISABLED,
m_ast_manager(m_params.m_proof ? PGM_ENABLED : PGM_DISABLED,
m_params.m_trace ? m_params.m_trace_file_name.c_str() : 0),
m_ctx(0),
m_error_code(0) {

View file

@ -1,5 +1,6 @@
z3_add_component(smt2parser
SOURCES
marshal.cpp
smt2parser.cpp
smt2scanner.cpp
COMPONENT_DEPENDENCIES

View file

@ -0,0 +1,50 @@
/*++
Copyright (c) 2017 Arie Gurfinkel
Module Name:
marshal.cpp
Abstract:
marshaling and unmarshaling of expressions
--*/
#include "parsers/smt2/marshal.h"
#include <sstream>
#include "cmd_context/cmd_context.h"
#include "parsers/smt2/smt2parser.h"
#include "util/vector.h"
#include "ast/ast_smt_pp.h"
#include "ast/ast_pp.h"
#include "ast/ast_util.h"
std::ostream &marshal(std::ostream &os, expr_ref e, ast_manager &m) {
ast_smt_pp pp(m);
pp.display_smt2(os, e);
return os;
}
std::string marshal(expr_ref e, ast_manager &m) {
std::stringstream ss;
marshal(ss, e, m);
return ss.str();
}
expr_ref unmarshal(std::istream &is, ast_manager &m) {
cmd_context ctx(false, &m);
ctx.set_ignore_check(true);
if (!parse_smt2_commands(ctx, is)) { return expr_ref(0, m); }
ptr_vector<expr>::const_iterator it = ctx.begin_assertions();
ptr_vector<expr>::const_iterator end = ctx.end_assertions();
unsigned size = static_cast<unsigned>(end - it);
return expr_ref(mk_and(m, size, it), m);
}
expr_ref unmarshal(std::string s, ast_manager &m) {
std::istringstream is(s);
return unmarshal(is, m);
}

View file

@ -0,0 +1,27 @@
/*++
Copyright (c) 2017 Arie Gurfinkel
Module Name:
marshal.h
Abstract:
marshaling and unmarshaling of expressions
--*/
#ifndef _SPACER_MARSHAL_H_
#define _SPACER_MARSHAL_H_
#include <string>
#include <iostream>
#include "ast/ast.h"
std::ostream &marshal(std::ostream &os, expr_ref e, ast_manager &m);
std::string marshal(expr_ref e, ast_manager &m);
expr_ref unmarshal(std::string s, ast_manager &m);
expr_ref unmarshal(std::istream &is, ast_manager &m);
#endif

View file

@ -446,7 +446,10 @@ namespace smt2 {
m_ctx.regular_stream()<< "line " << line << " column " << pos << ": " << escaped(msg, true) << "\")" << std::endl;
}
if (m_ctx.exit_on_error()) {
exit(1);
// WORKAROUND: ASan's LeakSanitizer reports many false positives when
// calling `exit()` so call `_Exit()` instead which avoids invoking leak
// checking.
_Exit(1);
}
}
@ -1880,6 +1883,8 @@ namespace smt2 {
// the resultant expression is on the top of the stack
TRACE("let_frame", tout << "let result expr: " << mk_pp(expr_stack().back(), m()) << "\n";);
expr_ref r(m());
if (expr_stack().empty())
throw parser_exception("invalid let expression");
r = expr_stack().back();
expr_stack().pop_back();
// remove local declarations from the stack