Node ExprMiner::convertToSkolem(Node n)
{
- std::vector<Node> fvs;
- TermUtil::computeVarContains(n, fvs);
- if (fvs.empty())
+ if (d_skolems.empty())
{
- return n;
- }
- std::vector<Node> sfvs;
- std::vector<Node> 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<Node, Node>::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<SmtEngine>& checker,
protected:
/** the set of variables used by this class */
std::vector<Node> 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<Node> 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<Node, Node> d_fv_to_skolem;
/** convert */
Node convertToSkolem(Node n);