mirror of
https://github.com/Z3Prover/z3
synced 2025-06-20 21:03:39 +00:00
Polysat: unit testing minor changes (#5326)
* Use check instead of check_sat in tests * First steps at standalone entry point
This commit is contained in:
parent
8757f04d20
commit
9cc78ef98e
1 changed files with 31 additions and 17 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include "math/polysat/log.h"
|
#include "math/polysat/log.h"
|
||||||
#include "math/polysat/solver.h"
|
#include "math/polysat/solver.h"
|
||||||
#include "ast/ast.h"
|
#include "ast/ast.h"
|
||||||
|
#include "parsers/smt2/smt2parser.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace polysat {
|
namespace polysat {
|
||||||
|
@ -11,11 +12,7 @@ namespace polysat {
|
||||||
reslimit lim;
|
reslimit lim;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct scoped_solver : public solver_scope, public solver {
|
class scoped_solver : public solver_scope, public solver {
|
||||||
scoped_solver(std::string name): solver(lim), m_name(name) {
|
|
||||||
std::cout << "\nSTART: " << m_name << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
lbool m_last_result = l_undef;
|
lbool m_last_result = l_undef;
|
||||||
|
|
||||||
|
@ -44,6 +41,11 @@ namespace polysat {
|
||||||
return l_false;
|
return l_false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
scoped_solver(std::string name): solver(lim), m_name(name) {
|
||||||
|
std::cout << "\nSTART: " << m_name << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
void check() {
|
void check() {
|
||||||
m_last_result = check_rec();
|
m_last_result = check_rec();
|
||||||
std::cout << m_name << ": " << m_last_result << "\n";
|
std::cout << m_name << ": " << m_last_result << "\n";
|
||||||
|
@ -493,13 +495,13 @@ namespace polysat {
|
||||||
|
|
||||||
s.push();
|
s.push();
|
||||||
s.add_ult(a, quot3);
|
s.add_ult(a, quot3);
|
||||||
s.check_sat();
|
s.check();
|
||||||
s.expect_unsat();
|
s.expect_unsat();
|
||||||
s.pop();
|
s.pop();
|
||||||
|
|
||||||
s.push();
|
s.push();
|
||||||
s.add_ult(quot3 + em, a);
|
s.add_ult(quot3 + em, a);
|
||||||
s.check_sat();
|
s.check();
|
||||||
s.expect_unsat();
|
s.expect_unsat();
|
||||||
s.pop();
|
s.pop();
|
||||||
}
|
}
|
||||||
|
@ -566,13 +568,13 @@ namespace polysat {
|
||||||
|
|
||||||
s.push();
|
s.push();
|
||||||
s.add_ult(a, quot3);
|
s.add_ult(a, quot3);
|
||||||
s.check_sat();
|
s.check();
|
||||||
s.expect_unsat();
|
s.expect_unsat();
|
||||||
s.pop();
|
s.pop();
|
||||||
|
|
||||||
s.push();
|
s.push();
|
||||||
s.add_ult(quot3 + em, a);
|
s.add_ult(quot3 + em, a);
|
||||||
s.check_sat();
|
s.check();
|
||||||
s.expect_unsat();
|
s.expect_unsat();
|
||||||
s.pop();
|
s.pop();
|
||||||
}
|
}
|
||||||
|
@ -631,14 +633,14 @@ namespace polysat {
|
||||||
// first disjunct: (= idx #x00000000)
|
// first disjunct: (= idx #x00000000)
|
||||||
s.push();
|
s.push();
|
||||||
s.add_eq(idx);
|
s.add_eq(idx);
|
||||||
s.check_sat();
|
s.check();
|
||||||
s.expect_unsat();
|
s.expect_unsat();
|
||||||
s.pop();
|
s.pop();
|
||||||
|
|
||||||
// second disjunct: (bvule (bvsub second first) q)
|
// second disjunct: (bvule (bvsub second first) q)
|
||||||
s.push();
|
s.push();
|
||||||
s.add_ule(second - first, q);
|
s.add_ule(second - first, q);
|
||||||
s.check_sat();
|
s.check();
|
||||||
s.expect_unsat();
|
s.expect_unsat();
|
||||||
s.pop();
|
s.pop();
|
||||||
}
|
}
|
||||||
|
@ -697,17 +699,29 @@ void tst_polysat() {
|
||||||
// TBD also add test that loads from a file and runs the polysat engine.
|
// TBD also add test that loads from a file and runs the polysat engine.
|
||||||
// sketch follows below:
|
// sketch follows below:
|
||||||
|
|
||||||
|
|
||||||
void tst_polysat_argv(char** argv, int argc, int& i) {
|
void tst_polysat_argv(char** argv, int argc, int& i) {
|
||||||
// set up SMT2 parser to extract assertions
|
// set up SMT2 parser to extract assertions
|
||||||
// assume they are simple bit-vector equations (and inequations)
|
// assume they are simple bit-vector equations (and inequations)
|
||||||
// convert to solver state.
|
// convert to solver state.
|
||||||
// std::ifstream is(argv[0]);
|
if (argc != 2) {
|
||||||
|
std::cerr << "Usage: " << argv[0] << " FILE\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::ifstream is(argv[1]);
|
||||||
// cmd_context ctx(false, &m);
|
// cmd_context ctx(false, &m);
|
||||||
// ctx.set_ignore_check(true);
|
cmd_context ctx(false);
|
||||||
// VERIFY(parse_smt2_commands(ctx, is));
|
ctx.set_ignore_check(true);
|
||||||
// auto fmls = ctx.assertions();
|
VERIFY(parse_smt2_commands(ctx, is));
|
||||||
// trail_stack stack;
|
auto fmls = ctx.assertions();
|
||||||
// solver s(stack);
|
polysat::scoped_solver s("polysat");
|
||||||
|
for (expr* fm : fmls) {
|
||||||
|
// fm->get_kind()
|
||||||
|
if (is_app(fm)) {
|
||||||
|
// is_app_of
|
||||||
|
}
|
||||||
|
}
|
||||||
// polysat::internalize(s, fmls);
|
// polysat::internalize(s, fmls);
|
||||||
// std::cout << s.check() << "\n";
|
// std::cout << s.check() << "\n";
|
||||||
|
s.check();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue