mirror of
https://github.com/Z3Prover/z3
synced 2025-09-04 09:07:40 +00:00
adding unit test for arith_plugin
This commit is contained in:
parent
65a8c162f5
commit
5c71824f2b
11 changed files with 89 additions and 17 deletions
|
@ -38,6 +38,7 @@ add_executable(test-z3
|
|||
dl_util.cpp
|
||||
doc.cpp
|
||||
egraph.cpp
|
||||
euf_arith_plugin.cpp
|
||||
euf_bv_plugin.cpp
|
||||
escaped.cpp
|
||||
ex.cpp
|
||||
|
|
53
src/test/euf_arith_plugin.cpp
Normal file
53
src/test/euf_arith_plugin.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*++
|
||||
Copyright (c) 2023 Microsoft Corporation
|
||||
|
||||
--*/
|
||||
|
||||
#include "util/util.h"
|
||||
#include "util/timer.h"
|
||||
#include "ast/euf/euf_egraph.h"
|
||||
#include "ast/euf/euf_arith_plugin.h"
|
||||
#include "ast/reg_decl_plugins.h"
|
||||
#include "ast/ast_pp.h"
|
||||
#include <iostream>
|
||||
|
||||
static euf::enode* get_node(euf::egraph& g, expr* e) {
|
||||
auto* n = g.find(e);
|
||||
if (n)
|
||||
return n;
|
||||
euf::enode_vector args;
|
||||
for (expr* arg : *to_app(e))
|
||||
args.push_back(get_node(g, arg));
|
||||
return g.mk(e, 0, args.size(), args.data());
|
||||
}
|
||||
|
||||
//
|
||||
static void test1() {
|
||||
ast_manager m;
|
||||
reg_decl_plugins(m);
|
||||
euf::egraph g(m);
|
||||
g.add_plugins();
|
||||
arith_util a(m);
|
||||
sort_ref I(a.mk_int(), m);
|
||||
|
||||
expr_ref x(m.mk_const("x", I), m);
|
||||
expr_ref y(m.mk_const("y", I), m);
|
||||
auto* nx = get_node(g, a.mk_add(a.mk_add(y, y), a.mk_add(x, x)));
|
||||
auto* ny = get_node(g, a.mk_add(a.mk_add(y, x), x));
|
||||
TRACE("plugin", tout << "before merge\n" << g << "\n");
|
||||
g.merge(nx, ny, nullptr);
|
||||
|
||||
TRACE("plugin", tout << "before propagate\n" << g << "\n");
|
||||
g.propagate();
|
||||
TRACE("plugin", tout << "after propagate\n" << g << "\n");
|
||||
g.merge(get_node(g, a.mk_add(x, a.mk_add(y, y))), get_node(g, a.mk_add(y, x)), nullptr);
|
||||
g.propagate();
|
||||
std::cout << g << "\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
void tst_euf_arith_plugin() {
|
||||
enable_trace("plugin");
|
||||
test1();
|
||||
}
|
|
@ -11,7 +11,7 @@ Copyright (c) 2023 Microsoft Corporation
|
|||
#include "ast/ast_pp.h"
|
||||
#include <iostream>
|
||||
|
||||
euf::enode* get_node(euf::egraph& g, expr* e) {
|
||||
static euf::enode* get_node(euf::egraph& g, expr* e) {
|
||||
auto* n = g.find(e);
|
||||
if (n)
|
||||
return n;
|
||||
|
|
|
@ -271,4 +271,5 @@ int main(int argc, char ** argv) {
|
|||
TST(totalizer);
|
||||
TST(distribution);
|
||||
TST(euf_bv_plugin);
|
||||
TST(euf_arith_plugin);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue