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:
parent
78b8072bb4
commit
b7d2ba471e
4 changed files with 63 additions and 50 deletions
|
@ -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));
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,40 +19,42 @@ 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)
|
||||||
range = m.mk_bool_sort();
|
range = m.mk_bool_sort();
|
||||||
|
|
||||||
if (!m.is_bool(range))
|
if (!m.is_bool(range))
|
||||||
m.raise_exception("range of synthesis declaration is Bool");
|
m.raise_exception("range of synthesis declaration is Bool");
|
||||||
|
|
||||||
if (num_parameters > 0)
|
if (num_parameters > 0)
|
||||||
m.raise_exception("no parameters are expected");
|
m.raise_exception("no parameters are expected");
|
||||||
|
|
||||||
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();
|
||||||
|
}
|
||||||
|
func_decl_info info(m_family_id, k, num_parameters, parameters);
|
||||||
|
return m.mk_func_decl(name, arity, domain, range, info);
|
||||||
}
|
}
|
||||||
func_decl_info info(m_family_id, k, num_parameters, parameters);
|
|
||||||
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,28 +19,39 @@ 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,
|
||||||
unsigned arity, sort * const * domain, sort * range) override;
|
unsigned arity, sort * const * domain, sort * range) override;
|
||||||
|
|
||||||
void get_op_names(svector<builtin_name> & op_names, symbol const & logic) override;
|
void get_op_names(svector<builtin_name> & op_names, symbol const & logic) override;
|
||||||
|
|
||||||
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); }
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue