Skip to content

Commit

Permalink
enable logging nla lemmas
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
  • Loading branch information
NikolajBjorner committed Apr 25, 2024
1 parent 2a4f0e7 commit bebcd94
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ast/sls/bv_sls_eval.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ namespace bv {

class sls_fixed;

class sls_eval_plugin {
public:
virtual ~sls_eval_plugin() {}

};

class sls_eval {
struct config {
unsigned m_prob_randomize_extract = 50;
Expand All @@ -40,6 +46,8 @@ namespace bv {
random_gen m_rand;
config m_config;

scoped_ptr_vector<sls_eval_plugin> m_plugins;



scoped_ptr_vector<sls_valuation> m_values; // expr-id -> bv valuation
Expand Down
22 changes: 22 additions & 0 deletions src/math/lp/nra_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Author: Nikolaj Bjorner, Lev Nachmanson
*/

#ifndef SINGLE_THREAD
#include <thread>
#endif
#include <fstream>
#include "math/lp/lar_solver.h"
#include "math/lp/nra_solver.h"
#include "nlsat/nlsat_solver.h"
Expand All @@ -11,6 +15,7 @@
#include "util/map.h"
#include "util/uint_set.h"
#include "math/lp/nla_core.h"
#include "smt/params/smt_params_helper.hpp"


namespace nra {
Expand Down Expand Up @@ -157,6 +162,23 @@ struct solver::imp {

TRACE("nra", m_nlsat->display(tout));

smt_params_helper p(m_params);
if (p.arith_nl_log()) {
static unsigned id = 0;
std::stringstream strm;

#ifndef SINGLE_THREAD
std::thread::id this_id = std::this_thread::get_id();
strm << "nla_" << this_id << "." << (++id) << ".smt2";
#else
strm << "nla_" << (++id) << ".smt2";
#endif
std::ofstream out(strm.str());
m_nlsat->display_smt2(out);
out << "(check-sat)\n";
out.close();
}

lbool r = l_undef;
try {
r = m_nlsat->check();
Expand Down
4 changes: 4 additions & 0 deletions src/nlsat/nlsat_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3863,6 +3863,10 @@ namespace nlsat {
return out;
}

std::ostream& solver::display_smt2(std::ostream & out) const {
return m_imp->display_smt2(out);
}

std::ostream& solver::display_smt2(std::ostream & out, literal_vector const& ls) const {
return display_smt2(out, ls.size(), ls.data());
}
Expand Down
2 changes: 2 additions & 0 deletions src/nlsat/nlsat_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ namespace nlsat {

std::ostream& display_smt2(std::ostream & out, literal_vector const& ls) const;

std::ostream& display_smt2(std::ostream & out) const;


/**
\brief Display variable
Expand Down
1 change: 1 addition & 0 deletions src/smt/params/smt_params_helper.pyg
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def_module_params(module_name='smt',
('arith.nl.propagate_linear_monomials', BOOL, True, 'propagate linear monomials'),
('arith.nl.optimize_bounds', BOOL, True, 'enable bounds optimization'),
('arith.nl.cross_nested', BOOL, True, 'enable cross-nested consistency checking'),
('arith.nl.log', BOOL, False, 'Log lemmas sent to nra solver'),
('arith.propagate_eqs', BOOL, True, 'propagate (cheap) equalities'),
('arith.propagation_mode', UINT, 1, '0 - no propagation, 1 - propagate existing literals, 2 - refine finite bounds'),
('arith.branch_cut_ratio', UINT, 2, 'branch/cut ratio for linear integer arithmetic'),
Expand Down

0 comments on commit bebcd94

Please sign in to comment.