3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-02 09:20:22 +00:00

use namespace, add util with discriminators

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2023-08-08 16:02:43 -07:00
parent 78b8072bb4
commit b7d2ba471e
4 changed files with 63 additions and 50 deletions

View file

@ -55,5 +55,5 @@ void reg_decl_plugins(ast_manager & m) {
if (!m.get_plugin(m.mk_family_id(symbol("specrels")))) if (!m.get_plugin(m.mk_family_id(symbol("specrels"))))
m.register_plugin(symbol("specrels"), alloc(special_relations_decl_plugin)); m.register_plugin(symbol("specrels"), alloc(special_relations_decl_plugin));
if (!m.get_plugin(m.mk_family_id(symbol("synth")))) if (!m.get_plugin(m.mk_family_id(symbol("synth"))))
m.register_plugin(symbol("synth"), alloc(synth_decl_plugin)); m.register_plugin(symbol("synth"), alloc(synth::plugin));
} }

View file

@ -19,10 +19,11 @@ Author:
#include "ast/synth_decl_plugin.h" #include "ast/synth_decl_plugin.h"
namespace synth {
synth_decl_plugin::synth_decl_plugin() {} plugin::plugin() {}
func_decl * synth_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, func_decl * plugin::mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
unsigned arity, sort * const * domain, sort * range) { unsigned arity, sort * const * domain, sort * range) {
auto& m = *m_manager; auto& m = *m_manager;
if (!range) if (!range)
@ -36,10 +37,10 @@ func_decl * synth_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters
symbol name; symbol name;
switch (k) { switch (k) {
case OP_SYNTH_DECLARE_OUTPUT: case OP_DECLARE_OUTPUT:
name = "synthesiz3"; name = "synthesiz3";
break; break;
case OP_SYNTH_DECLARE_GRAMMAR: case OP_DECLARE_GRAMMAR:
default: default:
NOT_IMPLEMENTED_YET(); NOT_IMPLEMENTED_YET();
} }
@ -47,12 +48,13 @@ func_decl * synth_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters
return m.mk_func_decl(name, arity, domain, range, info); return m.mk_func_decl(name, arity, domain, range, info);
} }
void synth_decl_plugin::get_op_names(svector<builtin_name> & op_names, symbol const & logic) { void plugin::get_op_names(svector<builtin_name> & op_names, symbol const & logic) {
if (logic == symbol::null) { if (logic == symbol::null) {
op_names.push_back(builtin_name("synthesiz3", OP_SYNTH_DECLARE_OUTPUT)); op_names.push_back(builtin_name("synthesiz3", OP_DECLARE_OUTPUT));
} }
} }
}

View file

@ -19,19 +19,20 @@ Author:
#include "ast/ast.h" #include "ast/ast.h"
namespace synth {
enum synth_op_kind { enum op_kind {
OP_SYNTH_DECLARE_OUTPUT, OP_DECLARE_OUTPUT,
OP_SYNTH_DECLARE_GRAMMAR, OP_DECLARE_GRAMMAR,
LAST_SYNTH_OP LAST_OP
}; };
class synth_decl_plugin : public decl_plugin { class plugin : public decl_plugin {
public: public:
synth_decl_plugin(); plugin();
decl_plugin * mk_fresh() override { plugin * mk_fresh() override {
return alloc(synth_decl_plugin); return alloc(plugin);
} }
func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
@ -42,5 +43,15 @@ public:
sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) override { return nullptr; } sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) override { return nullptr; }
}; };
class util {
ast_manager& m;
family_id m_fid;
public:
util(ast_manager& m): m(m), m_fid(m.get_family_id("synth")) {}
bool is_synthesiz3(expr* e) { return is_app_of(e, m_fid, OP_DECLARE_OUTPUT); }
bool is_grammar(expr* e) { return is_app_of(e, m_fid, OP_DECLARE_GRAMMAR); }
};
}

View file

@ -826,7 +826,7 @@ void cmd_context::init_manager_core(bool new_manager) {
register_plugin(symbol("fpa"), alloc(fpa_decl_plugin), logic_has_fpa()); register_plugin(symbol("fpa"), alloc(fpa_decl_plugin), logic_has_fpa());
register_plugin(symbol("datalog_relation"), alloc(datalog::dl_decl_plugin), !has_logic()); register_plugin(symbol("datalog_relation"), alloc(datalog::dl_decl_plugin), !has_logic());
register_plugin(symbol("specrels"), alloc(special_relations_decl_plugin), !has_logic()); register_plugin(symbol("specrels"), alloc(special_relations_decl_plugin), !has_logic());
register_plugin(symbol("synth"), alloc(synth_decl_plugin), !has_logic()); register_plugin(symbol("synth"), alloc(synth::plugin), !has_logic());
} }
else { else {
// the manager was created by an external module // the manager was created by an external module