mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 01:25:31 +00:00
Merge branch 'master' into polysat
This commit is contained in:
commit
20b5455d08
669 changed files with 26145 additions and 20652 deletions
|
@ -247,7 +247,7 @@ namespace datalog {
|
|||
{
|
||||
relation_base* b1 = br.mk_full(nullptr, sig);
|
||||
relation_base* b2 = br.mk_full(nullptr, sig);
|
||||
unsigned x0x3[2] = { 0, 3 };
|
||||
// unsigned x0x3[2] = { 0, 3 };
|
||||
unsigned x1x3[2] = { 1, 3 };
|
||||
unsigned x2x3[2] = { 2, 3 };
|
||||
scoped_ptr<relation_mutator_fn> id1 = br.mk_filter_identical_fn(*b1, 2, x1x3);
|
||||
|
|
|
@ -124,7 +124,7 @@ static void test3() {
|
|||
SASSERT(g.inconsistent());
|
||||
ptr_vector<int> js;
|
||||
g.begin_explain();
|
||||
g.explain<int>(js);
|
||||
g.explain<int>(js, nullptr);
|
||||
g.end_explain();
|
||||
for (int* j : js)
|
||||
std::cout << "conflict: " << *j << "\n";
|
||||
|
|
|
@ -26,8 +26,8 @@ Revision History:
|
|||
|
||||
struct int_hash_proc { unsigned operator()(int x) const { return x * 3; } };
|
||||
typedef int_hashtable<int_hash_proc, default_eq<int> > int_set;
|
||||
typedef std::unordered_set<int> safe_int_set;
|
||||
// typedef safe_int_set int_set;
|
||||
typedef std::unordered_set<int> safe_int_set;
|
||||
|
||||
inline bool contains(int_set & h, int i) {
|
||||
// return h.find(i) != h.end();
|
||||
|
|
|
@ -5,7 +5,7 @@ Copyright (c) 2015 Microsoft Corporation
|
|||
--*/
|
||||
|
||||
|
||||
#include "tactic/horn_subsume_model_converter.h"
|
||||
#include "ast/converters/horn_subsume_model_converter.h"
|
||||
#include "ast/arith_decl_plugin.h"
|
||||
#include "model/model_smt2_pp.h"
|
||||
#include "ast/reg_decl_plugins.h"
|
||||
|
|
|
@ -1899,7 +1899,7 @@ void find_dir_and_file_name(std::string a, std::string & dir, std::string& fn) {
|
|||
void process_test_file(std::string test_dir, std::string test_file_name, argument_parser & args_parser, std::string out_dir, unsigned max_iters, unsigned time_limit, unsigned & successes, unsigned & failures, unsigned & inconclusives);
|
||||
|
||||
void solve_some_mps(argument_parser & args_parser) {
|
||||
unsigned max_iters, time_limit;
|
||||
unsigned max_iters = UINT_MAX, time_limit = UINT_MAX;
|
||||
get_time_limit_and_max_iters_from_parser(args_parser, time_limit);
|
||||
unsigned successes = 0;
|
||||
unsigned failures = 0;
|
||||
|
|
|
@ -392,9 +392,29 @@ static void test11() {
|
|||
|
||||
}
|
||||
|
||||
static void test12() {
|
||||
opt::model_based_opt::def d1, d2, d3, d4;
|
||||
typedef opt::model_based_opt::var var;
|
||||
d1.m_vars.push_back(var(1, rational(4)));
|
||||
d1.m_vars.push_back(var(2, rational(3)));
|
||||
d1.m_vars.push_back(var(3, rational(5)));
|
||||
d1.m_coeff = rational(8);
|
||||
d1.m_div = rational(7);
|
||||
std::cout << d1 << "\n";
|
||||
d2.m_vars.push_back(var(3, rational(2)));
|
||||
d2.m_vars.push_back(var(4, rational(2)));
|
||||
d2.m_div = rational(3);
|
||||
d2.m_coeff = rational(5);
|
||||
std::cout << d2 << "\n";
|
||||
d1.substitute(2, d2);
|
||||
std::cout << d1 << "\n";
|
||||
}
|
||||
|
||||
// test with mix of upper and lower bounds
|
||||
|
||||
void tst_model_based_opt() {
|
||||
test12();
|
||||
return;
|
||||
test10();
|
||||
check_random_ineqs();
|
||||
test1();
|
||||
|
|
|
@ -93,6 +93,7 @@ static void test_datatypes() {
|
|||
int_list = Z3_mk_list_sort(ctx, Z3_mk_string_symbol(ctx, "int_list"), int_ty,
|
||||
&nil_decl, &is_nil_decl, &cons_decl, &is_cons_decl, &head_decl, &tail_decl);
|
||||
|
||||
(void) int_list;
|
||||
nil = Z3_mk_app(ctx, nil_decl, 0, nullptr);
|
||||
|
||||
Z3_ast a = Z3_simplify(ctx, Z3_mk_app(ctx, is_nil_decl, 1, &nil));
|
||||
|
@ -166,6 +167,7 @@ static void test_array() {
|
|||
Z3_ast n4 = Z3_mk_numeral(ctx, "4", i);
|
||||
Z3_ast s1 = Z3_mk_const(ctx, Z3_mk_string_symbol(ctx,"s1"), i);
|
||||
Z3_ast s2 = Z3_mk_const(ctx, Z3_mk_string_symbol(ctx,"s2"), i);
|
||||
(void) s2;
|
||||
|
||||
Z3_ast c1 = Z3_mk_const_array(ctx, i, n1);
|
||||
Z3_ast x1 = Z3_mk_store(ctx, Z3_mk_store(ctx, c1, n2, n3), n1, n4);
|
||||
|
@ -175,6 +177,7 @@ static void test_array() {
|
|||
Z3_ast xs[4] = { x1, x2, x3, x4};
|
||||
Z3_ast exy = Z3_mk_eq(ctx, x2, x1);
|
||||
Z3_ast rxy = Z3_simplify(ctx, exy);
|
||||
(void)rxy;
|
||||
|
||||
TRACE("simplifier", tout << Z3_ast_to_string(ctx, rxy) << "\n";);
|
||||
TRACE("simplifier", tout << Z3_ast_to_string(ctx, Z3_simplify(ctx, Z3_mk_eq(ctx, x2, x3))) << "\n";);
|
||||
|
@ -195,6 +198,8 @@ static void test_array() {
|
|||
|
||||
Z3_ast sel1 = Z3_mk_select(ctx, x1, n1);
|
||||
Z3_ast sel2 = Z3_mk_select(ctx, x1, n4);
|
||||
(void)sel1;
|
||||
(void)sel2;
|
||||
|
||||
TRACE("simplifier",
|
||||
tout << Z3_ast_to_string(ctx, Z3_simplify(ctx, sel1)) << "\n";
|
||||
|
|
|
@ -64,6 +64,108 @@ void test_parseprint(char const* spec) {
|
|||
Z3_del_context(ctx);
|
||||
}
|
||||
|
||||
void test_eval(Z3_context ctx, Z3_string spec, bool shouldFail) {
|
||||
std::cout << "spec:\n" << spec << "\n";
|
||||
|
||||
std::string resp;
|
||||
bool failed = false;
|
||||
try {
|
||||
resp = Z3_eval_smtlib2_string(ctx, spec);
|
||||
}
|
||||
catch (std::runtime_error& e) {
|
||||
resp = e.what();
|
||||
failed = true;
|
||||
}
|
||||
catch (...) {
|
||||
resp = "unknown exception";
|
||||
failed = true;
|
||||
}
|
||||
|
||||
std::cout << "response:\n" << resp << "\n";
|
||||
|
||||
if (shouldFail != failed) {
|
||||
if (shouldFail)
|
||||
throw std::runtime_error("should have failed");
|
||||
else
|
||||
throw std::runtime_error("should have succeeded");
|
||||
}
|
||||
}
|
||||
|
||||
void throwError(Z3_context c, Z3_error_code e) {
|
||||
throw std::runtime_error(Z3_get_error_msg(c, e));
|
||||
}
|
||||
|
||||
void test_repeated_eval() {
|
||||
// Z3_eval_smtlib2_string reuses the parser and the scanner
|
||||
// when called repeteadly on the same context.
|
||||
//
|
||||
// These tests rehearse that earlier calls do not interfere
|
||||
// with the result of later calls if the SMT queries are independent.
|
||||
|
||||
char const* spec1 =
|
||||
"(push)\n"
|
||||
"(declare-datatypes (T) ((list (nil) (cons (car T) (cdr list)))))\n"
|
||||
"(declare-const x Int)\n"
|
||||
"(declare-const l (list Int))\n"
|
||||
"(declare-fun f ((list Int)) Bool)\n"
|
||||
"(assert (f (cons x l)))\n"
|
||||
"(check-sat)\n"
|
||||
"(pop)\n";
|
||||
|
||||
char const* spec2 =
|
||||
"(push)\n"
|
||||
"(declare-const a (Array Int Int))\n"
|
||||
"(declare-const b (Array (Array Int Int) Bool))\n"
|
||||
"(assert (select b a))\n"
|
||||
"(assert (= b ((as const (Array (Array Int Int) Bool)) true)))\n"
|
||||
"(assert (= b (store b a true)))\n"
|
||||
"(declare-const b1 (Array Bool Bool))\n"
|
||||
"(declare-const b2 (Array Bool Bool))\n"
|
||||
"(assert (= ((as const (Array Bool Bool)) false) ((_ map and) b1 b2)))\n"
|
||||
"(check-sat)\n"
|
||||
"(pop)\n";
|
||||
|
||||
char const* spec3 =
|
||||
"(push)\n"
|
||||
"(declare-const a@ (Array Int Int))\n"
|
||||
"(declare-const b (Array (Array Int Int) Bool))\n"
|
||||
"(assert (select b a))\n"
|
||||
"(check-sat)\n"
|
||||
"(pop)\n";
|
||||
|
||||
char const* spec4 =
|
||||
"(push)\n"
|
||||
"(declare-const a (Array Int Int))\n"
|
||||
"(declare-const b# (Array (Array Int Int) Bool))\n"
|
||||
"(assert (select b a))\n"
|
||||
"(check-sat)\n"
|
||||
"(pop)\n";
|
||||
|
||||
Z3_context ctx = Z3_mk_context(nullptr);
|
||||
Z3_set_error_handler(ctx, throwError);
|
||||
std::cout << "testing Z3_eval_smtlib2_string\n";
|
||||
|
||||
try {
|
||||
test_eval(ctx, spec1, false);
|
||||
std::cout << "successful call after successful call\n";
|
||||
test_eval(ctx, spec2, false);
|
||||
std::cout << "failing call after successful call\n";
|
||||
test_eval(ctx, spec3, true);
|
||||
std::cout << "failing call after failing call\n";
|
||||
test_eval(ctx, spec4, true);
|
||||
std::cout << "successful call after failing call\n";
|
||||
test_eval(ctx, spec1, false);
|
||||
}
|
||||
catch(...) {
|
||||
std::cout << "Error: uncaught exception\n";
|
||||
throw;
|
||||
}
|
||||
|
||||
std::cout << "done evaluating\n";
|
||||
|
||||
Z3_del_context(ctx);
|
||||
}
|
||||
|
||||
void tst_smt2print_parse() {
|
||||
|
||||
// test basic datatypes
|
||||
|
@ -126,6 +228,8 @@ void tst_smt2print_parse() {
|
|||
|
||||
test_parseprint(spec6);
|
||||
|
||||
// Test ?
|
||||
// Test ?
|
||||
|
||||
test_repeated_eval();
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue