From ebc6ec2eb5348b438b154f531791e8cab5deeb07 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 19 Mar 2018 13:33:58 -0700 Subject: [PATCH] fix #1547 by rewriting legacy recognizers to SMT-LIB2.6 style recognizers which are assumed by theory_datatype Signed-off-by: Nikolaj Bjorner --- src/ast/datatype_decl_plugin.cpp | 4 ++++ src/ast/datatype_decl_plugin.h | 1 + src/ast/rewriter/datatype_rewriter.cpp | 3 +++ src/interp/iz3interp.cpp | 12 ++++++------ src/interp/iz3translate.cpp | 4 ++-- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/ast/datatype_decl_plugin.cpp b/src/ast/datatype_decl_plugin.cpp index 44f824959..f685c70d5 100644 --- a/src/ast/datatype_decl_plugin.cpp +++ b/src/ast/datatype_decl_plugin.cpp @@ -821,6 +821,10 @@ namespace datatype { return d; } + app* util::mk_is(func_decl * c, expr *f) { + return m.mk_app(get_constructor_is(c), 1, &f); + } + func_decl * util::get_recognizer_constructor(func_decl * recognizer) const { SASSERT(is_recognizer(recognizer)); return to_func_decl(recognizer->get_parameter(0).get_ast()); diff --git a/src/ast/datatype_decl_plugin.h b/src/ast/datatype_decl_plugin.h index e644ccbda..f32e9990d 100644 --- a/src/ast/datatype_decl_plugin.h +++ b/src/ast/datatype_decl_plugin.h @@ -362,6 +362,7 @@ namespace datatype { bool is_recognizer(app * f) const { return is_recognizer0(f) || is_is(f); } bool is_accessor(app * f) const { return is_app_of(f, m_family_id, OP_DT_ACCESSOR); } bool is_update_field(app * f) const { return is_app_of(f, m_family_id, OP_DT_UPDATE_FIELD); } + app* mk_is(func_decl * c, expr *f); ptr_vector const * get_datatype_constructors(sort * ty); unsigned get_datatype_num_constructors(sort * ty); unsigned get_datatype_num_parameter_sorts(sort * ty); diff --git a/src/ast/rewriter/datatype_rewriter.cpp b/src/ast/rewriter/datatype_rewriter.cpp index f0a95929b..194668b9c 100644 --- a/src/ast/rewriter/datatype_rewriter.cpp +++ b/src/ast/rewriter/datatype_rewriter.cpp @@ -23,6 +23,9 @@ br_status datatype_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr switch(f->get_decl_kind()) { case OP_DT_CONSTRUCTOR: return BR_FAILED; case OP_DT_RECOGNISER: + SASSERT(num_args == 1); + result = m_util.mk_is(m_util.get_recognizer_constructor(f), args[0]); + return BR_REWRITE1; case OP_DT_IS: // // simplify is_cons(cons(x,y)) -> true diff --git a/src/interp/iz3interp.cpp b/src/interp/iz3interp.cpp index 3d1d84f3c..41c968bd8 100644 --- a/src/interp/iz3interp.cpp +++ b/src/interp/iz3interp.cpp @@ -255,12 +255,12 @@ public: catch (const char *msg) { throw interpolation_failure(msg); } - catch (const iz3translation::unsupported &) { - TRACE("iz3", tout << "unsupported\n";); + catch (const iz3translation::unsupported & ex) { + TRACE("iz3", tout << "unsupported " << "\n";); throw interpolation_error(); } - catch (const iz3proof::proof_error &) { - TRACE("iz3", tout << "proof error\n";); + catch (const iz3proof::proof_error & ex) { + TRACE("iz3", tout << "proof error " << "\n";); throw interpolation_error(); } profiling::timer_stop("Proof translation"); @@ -306,8 +306,8 @@ public: catch (const char *msg) { throw interpolation_failure(msg); } - catch (const iz3translation::unsupported &) { - TRACE("iz3", tout << "unsupported\n";); + catch (const iz3translation::unsupported & ex) { + TRACE("iz3", tout << "unsupported " << "\n";); throw interpolation_error(); } catch (const iz3proof::proof_error &) { diff --git a/src/interp/iz3translate.cpp b/src/interp/iz3translate.cpp index 9680ec95e..44bac0643 100644 --- a/src/interp/iz3translate.cpp +++ b/src/interp/iz3translate.cpp @@ -2029,8 +2029,8 @@ public: case PR_IFF_FALSE: { // turns ~p into p <-> false, noop for us if(is_local(con)) res = args[0]; - else - throw_unsupported(con); + else + throw_unsupported(proof); break; } case PR_COMMUTATIVITY: {