From c783a90bc4dbf43a2d054a4e04ae0cae280bea30 Mon Sep 17 00:00:00 2001 From: Andrew Reynolds Date: Tue, 17 Aug 2021 00:24:39 -0500 Subject: [PATCH] Improve conversion to skolems in expression miner (#7019) Work towards a new expression miner for caching satisfiability queries. --- src/theory/quantifiers/expr_miner.cpp | 37 +++++++-------------------- src/theory/quantifiers/expr_miner.h | 8 +++--- 2 files changed, 14 insertions(+), 31 deletions(-) diff --git a/src/theory/quantifiers/expr_miner.cpp b/src/theory/quantifiers/expr_miner.cpp index 72605e9d1..0f46fa790 100644 --- a/src/theory/quantifiers/expr_miner.cpp +++ b/src/theory/quantifiers/expr_miner.cpp @@ -38,38 +38,19 @@ void ExprMiner::initialize(const std::vector& vars, SygusSampler* ss) Node ExprMiner::convertToSkolem(Node n) { - std::vector fvs; - TermUtil::computeVarContains(n, fvs); - if (fvs.empty()) + if (d_skolems.empty()) { - return n; - } - std::vector sfvs; - std::vector sks; - // map to skolems - NodeManager* nm = NodeManager::currentNM(); - SkolemManager* sm = nm->getSkolemManager(); - for (unsigned i = 0, size = fvs.size(); i < size; i++) - { - Node v = fvs[i]; - // only look at the sampler variables - if (std::find(d_vars.begin(), d_vars.end(), v) != d_vars.end()) + NodeManager* nm = NodeManager::currentNM(); + SkolemManager* sm = nm->getSkolemManager(); + for (const Node& v : d_vars) { - sfvs.push_back(v); - std::map::iterator itf = d_fv_to_skolem.find(v); - if (itf == d_fv_to_skolem.end()) - { - Node sk = sm->mkDummySkolem("rrck", v.getType()); - d_fv_to_skolem[v] = sk; - sks.push_back(sk); - } - else - { - sks.push_back(itf->second); - } + Node sk = sm->mkDummySkolem("rrck", v.getType()); + d_skolems.push_back(sk); + d_fv_to_skolem[v] = sk; } } - return n.substitute(sfvs.begin(), sfvs.end(), sks.begin(), sks.end()); + return n.substitute( + d_vars.begin(), d_vars.end(), d_skolems.begin(), d_skolems.end()); } void ExprMiner::initializeChecker(std::unique_ptr& checker, diff --git a/src/theory/quantifiers/expr_miner.h b/src/theory/quantifiers/expr_miner.h index 36fae1549..79d0c6650 100644 --- a/src/theory/quantifiers/expr_miner.h +++ b/src/theory/quantifiers/expr_miner.h @@ -62,13 +62,15 @@ class ExprMiner protected: /** the set of variables used by this class */ std::vector d_vars; - /** pointer to the sygus sampler object we are using */ - SygusSampler* d_sampler; /** - * Maps to skolems for each free variable that appears in a check. This is + * The set of skolems corresponding to the above variables. These are * used during initializeChecker so that query (which may contain free * variables) is converted to a formula without free variables. */ + std::vector d_skolems; + /** pointer to the sygus sampler object we are using */ + SygusSampler* d_sampler; + /** Maps to skolems for each free variable based on d_vars/d_skolems. */ std::map d_fv_to_skolem; /** convert */ Node convertToSkolem(Node n); -- 2.30.2