3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00

Add simplification customization for SMTLIB2

Add the ability to customize incremental pre-processing simplification for the SMTLIB2 front-end. The main new capability is to use pre-processing tactics in incremental mode that were previously not available. The main new capabilities are
- solve-eqs
- reduce-args
- elim-unconstrained
There are several more. Documentation and exposed simplifiers are populated incrementally. The current set of supported simplifiers can be inspected by using z3 with the --simplifiers flag or referring to https://microsoft.github.io/z3guide/docs/strategies/simplifiers

Some pending features are:
- add the ability to update parameters to simplifiers similar to how tactics can be controlled using parameters.
- expose simplification solvers over the binary API.
This commit is contained in:
Nikolaj Bjorner 2023-01-30 22:38:51 -08:00
parent dd0decfe5d
commit 6022c17131
32 changed files with 370 additions and 69 deletions

View file

@ -98,6 +98,7 @@ void display_usage() {
std::cout << " -pmmd:name display Z3 module ('name') parameters in Markdown format.\n";
std::cout << " -pp:name display Z3 parameter description, if 'name' is not provided, then all module names are listed.\n";
std::cout << " -tactics[:name] display built-in tactics or if argument is given, display detailed information on tactic.\n";
std::cout << " -simplifiers[:name] display built-in simplifiers or if argument is given, display detailed information on simplifier.\n";
std::cout << " -probes display avilable probes.\n";
std::cout << " --" << " all remaining arguments are assumed to be part of the input file name. This option allows Z3 to read files with strange names such as: -foo.smt2.\n";
std::cout << "\nResources:\n";
@ -295,6 +296,12 @@ static void parse_cmd_line_args(std::string& input_file, int argc, char ** argv)
else
help_tactic(opt_arg, false);
}
else if (strcmp(opt_name, "simplifiers") == 0) {
if (!opt_arg)
help_simplifiers();
else
help_simplifier(opt_arg, false);
}
else if (strcmp(opt_name, "tacticsmd") == 0 && opt_arg)
help_tactic(opt_arg, true);
else if (strcmp(opt_name, "probes") == 0)

View file

@ -88,6 +88,22 @@ void help_tactics() {
std::cout << "- " << cmd->get_name() << " " << cmd->get_descr() << "\n";
}
void help_simplifiers() {
struct cmp {
bool operator()(simplifier_cmd* a, simplifier_cmd* b) const {
return a->get_name().str() < b->get_name().str();
}
};
cmd_context ctx;
ptr_vector<simplifier_cmd> cmds;
for (auto cmd : ctx.simplifiers())
cmds.push_back(cmd);
cmp lt;
std::sort(cmds.begin(), cmds.end(), lt);
for (auto cmd : cmds)
std::cout << "- " << cmd->get_name() << " " << cmd->get_descr() << "\n";
}
void help_tactic(char const* name, bool markdown) {
cmd_context ctx;
for (auto cmd : ctx.tactics()) {
@ -103,6 +119,25 @@ void help_tactic(char const* name, bool markdown) {
}
}
void help_simplifier(char const* name, bool markdown) {
cmd_context ctx;
for (auto cmd : ctx.simplifiers()) {
if (cmd->get_name() == name) {
auto fac = cmd->factory();
param_descrs descrs;
ast_manager& m = ctx.m();
default_dependent_expr_state st(m);
params_ref p;
scoped_ptr<dependent_expr_simplifier> s = fac(m, p, st);
s->collect_param_descrs(descrs);
if (markdown)
descrs.display_markdown(std::cout);
else
descrs.display(std::cout, 4);
}
}
}
void help_probes() {
struct cmp {
bool operator()(probe_info* a, probe_info* b) const {

View file

@ -21,7 +21,9 @@ Revision History:
unsigned read_smtlib_file(char const * benchmark_file);
unsigned read_smtlib2_commands(char const * command_file);
void help_tactics();
void help_simplifiers();
void help_probes();
void help_tactic(char const* name, bool markdown);
void help_simplifier(char const* name, bool markdown);