From: Andrew Reynolds Date: Wed, 26 Jan 2022 01:20:01 +0000 (-0600) Subject: More fixes and improvements for query generator (#7988) X-Git-Tag: cvc5-1.0.0~503 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7fd60d0f147b8afd5d6678b2eb6951409b2c8bea;p=cvc5.git More fixes and improvements for query generator (#7988) Includes proper printing of dumped benchmarks. --- diff --git a/src/smt/print_benchmark.cpp b/src/smt/print_benchmark.cpp index 778a431ab..e16b66139 100644 --- a/src/smt/print_benchmark.cpp +++ b/src/smt/print_benchmark.cpp @@ -36,6 +36,7 @@ void PrintBenchmark::printAssertions(std::ostream& out, } for (const Node& a : assertions) { + Assert(!expr::hasFreeVar(a)); expr::getTypes(a, types, typeVisited); } // print the declared types first diff --git a/src/theory/quantifiers/query_generator.cpp b/src/theory/quantifiers/query_generator.cpp index 05cc4c46b..d9e6954f6 100644 --- a/src/theory/quantifiers/query_generator.cpp +++ b/src/theory/quantifiers/query_generator.cpp @@ -20,6 +20,8 @@ #include #include "options/quantifiers_options.h" +#include "smt/env.h" +#include "smt/print_benchmark.h" #include "util/random.h" using namespace std; @@ -167,7 +169,7 @@ void QueryGenerator::checkQuery(Node qy, unsigned spIndex, std::ostream& out) if (options().quantifiers.sygusQueryGenDumpFiles == options::SygusQueryDumpFilesMode::ALL) { - dumpQuery(qy, spIndex); + dumpQuery(qy); } if (options().quantifiers.sygusQueryGenCheck) @@ -199,7 +201,7 @@ void QueryGenerator::checkQuery(Node qy, unsigned spIndex, std::ostream& out) { if (r.asSatisfiabilityResult().isSat() != Result::SAT) { - dumpQuery(qy, spIndex); + dumpQuery(qy); } } } @@ -207,36 +209,15 @@ void QueryGenerator::checkQuery(Node qy, unsigned spIndex, std::ostream& out) d_queryCount++; } -void QueryGenerator::dumpQuery(Node qy, unsigned spIndex) +void QueryGenerator::dumpQuery(Node qy) { - // Print the query and the query + its model (commented) to queryN.smt2 - std::vector pt; - d_sampler->getSamplePoint(spIndex, pt); - size_t nvars = d_vars.size(); - AlwaysAssert(pt.size() == d_vars.size()); + Node kqy = convertToSkolem(qy); + // Print the query to to queryN.smt2 std::stringstream fname; fname << "query" << d_queryCount << ".smt2"; std::ofstream fs(fname.str(), std::ofstream::out); - fs << "(set-logic ALL)" << std::endl; - for (unsigned i = 0; i < 2; i++) - { - for (size_t j = 0; j < nvars; j++) - { - Node x = d_vars[j]; - if (i == 0) - { - fs << "(declare-fun " << x << " () " << x.getType() << ")"; - } - else - { - fs << ";(define-fun " << x << " () " << x.getType() << " " << pt[j] - << ")"; - } - fs << std::endl; - } - } - fs << "(assert " << qy << ")" << std::endl; - fs << "(check-sat)" << std::endl; + smt::PrintBenchmark pb(&d_env.getPrinter()); + pb.printBenchmark(fs, d_env.getLogicInfo().getLogicString(), {}, {kqy}); fs.close(); } diff --git a/src/theory/quantifiers/query_generator.h b/src/theory/quantifiers/query_generator.h index 750459588..38c99b6f9 100644 --- a/src/theory/quantifiers/query_generator.h +++ b/src/theory/quantifiers/query_generator.h @@ -111,10 +111,9 @@ class QueryGenerator : public ExprMiner */ void checkQuery(Node qy, unsigned spIndex, std::ostream& out); /** - * Dumps query qy to the a file queryN.smt2 for the current counter N; - * spIndex specifies the sample point that satisfies it (for debugging). + * Dumps query qy to the a file queryN.smt2 for the current counter N */ - void dumpQuery(Node qy, unsigned spIndex); + void dumpQuery(Node qy); }; } // namespace quantifiers