{
// compute variables in itm->first, these are not eligible for
// elimination
- std::vector<Node> bvs;
- TermUtil::getBoundVars(m.first, bvs);
- for (TNode v : bvs)
+ std::unordered_set<Node, NodeHashFunction> fvs;
+ expr::getFreeVariables(m.first, fvs);
+ for (const Node& v : fvs)
{
Trace("var-elim-ineq-debug")
<< "...ineligible " << v
**/
#include "theory/quantifiers/single_inv_partition.h"
+#include "expr/node_algorithm.h"
#include "theory/quantifiers/term_util.h"
using namespace CVC4;
Trace("si-prt-debug") << "...normalized invocations to " << cr
<< std::endl;
// now must check if it has other bound variables
- std::vector<Node> bvs;
- TermUtil::getBoundVars(cr, bvs);
+ std::unordered_set<Node, NodeHashFunction> fvs;
+ expr::getFreeVariables(cr, fvs);
// bound variables must be contained in the single invocation variables
- for (const Node& bv : bvs)
+ for (const Node& bv : fvs)
{
if (std::find(d_si_vars.begin(), d_si_vars.end(), bv)
== d_si_vars.end())
{
- // getBoundVars also collects functions in the rare case that we are
- // synthesizing a function with 0 arguments, take this into account
- // here.
+ // getFreeVariables also collects functions in the rare case that
+ // we are synthesizing a function with 0 arguments, take this into
+ // account here.
if (std::find(d_input_funcs.begin(), d_input_funcs.end(), bv)
== d_input_funcs.end())
{
Trace("si-prt") << "...not single invocation." << std::endl;
singleInvocation = false;
// rename bound variables with maximal overlap with si_vars
- std::vector<Node> bvs;
- TermUtil::getBoundVars(cr, bvs);
+ std::unordered_set<Node, NodeHashFunction> fvs;
+ expr::getFreeVariables(cr, fvs);
std::vector<Node> terms;
std::vector<Node> subs;
- for (unsigned j = 0; j < bvs.size(); j++)
+ for (const Node& v : fvs)
{
- TypeNode tn = bvs[j].getType();
- Trace("si-prt-debug") << "Fit bound var #" << j << " : " << bvs[j]
- << " with si." << std::endl;
+ TypeNode tn = v.getType();
+ Trace("si-prt-debug")
+ << "Fit bound var: " << v << " with si." << std::endl;
for (unsigned k = 0; k < d_si_vars.size(); k++)
{
if (tn == d_arg_types[k])
if (std::find(subs.begin(), subs.end(), d_si_vars[k])
== subs.end())
{
- terms.push_back(bvs[j]);
+ terms.push_back(v);
subs.push_back(d_si_vars[k]);
Trace("si-prt-debug") << " ...use " << d_si_vars[k]
<< std::endl;
Trace("si-prt") << ".....got si=" << singleInvocation
<< ", result : " << cr << std::endl;
d_conjuncts[2].push_back(cr);
- TermUtil::getBoundVars(cr, d_all_vars);
+ std::unordered_set<Node, NodeHashFunction> fvs;
+ expr::getFreeVariables(cr, fvs);
+ d_all_vars.insert(d_all_vars.end(), fvs.begin(), fvs.end());
if (singleInvocation)
{
// replace with single invocation formulation
else
{
bool ret = true;
- // if( TermUtil::hasBoundVarAttr( n ) ){
for (unsigned i = 0; i < n.getNumChildren(); i++)
{
if (!processConjunct(n[i], visited, args, terms, subs))
}
}
-void TermUtil::getBoundVars2( Node n, std::vector< Node >& vars, std::map< Node, bool >& visited ) {
- if( visited.find( n )==visited.end() ){
- visited[n] = true;
- if( n.getKind()==BOUND_VARIABLE ){
- if( std::find( vars.begin(), vars.end(), n )==vars.end() ) {
- vars.push_back( n );
- }
- }
- for( unsigned i=0; i<n.getNumChildren(); i++ ){
- getBoundVars2( n[i], vars, visited );
- }
- }
-}
-
Node TermUtil::getRemoveQuantifiers2( Node n, std::map< Node, Node >& visited ) {
std::map< Node, Node >::iterator it = visited.find( n );
if( it!=visited.end() ){
return !getBoundVarAttr(n).isNull();
}
-void TermUtil::getBoundVars( Node n, std::vector< Node >& vars ) {
- std::map< Node, bool > visited;
- return getBoundVars2( n, vars, visited );
-}
-
//remove quantifiers
Node TermUtil::getRemoveQuantifiers( Node n ) {
std::map< Node, Node > visited;
//quantified simplify
Node TermUtil::getQuantSimplify( Node n ) {
- std::vector< Node > bvs;
- getBoundVars( n, bvs );
- if( bvs.empty() ) {
+ std::unordered_set<Node, NodeHashFunction> fvs;
+ expr::getFreeVariables(n, fvs);
+ if (fvs.empty())
+ {
return Rewriter::rewrite( n );
- }else{
- Node q = NodeManager::currentNM()->mkNode( FORALL, NodeManager::currentNM()->mkNode( BOUND_VAR_LIST, bvs ), n );
- q = Rewriter::rewrite( q );
- return getRemoveQuantifiers( q );
}
+ std::vector<Node> bvs;
+ bvs.insert(bvs.end(), fvs.begin(), fvs.end());
+ NodeManager* nm = NodeManager::currentNM();
+ Node q = nm->mkNode(FORALL, nm->mkNode(BOUND_VAR_LIST, bvs), n);
+ q = Rewriter::rewrite(q);
+ return getRemoveQuantifiers(q);
}
/** get the i^th instantiation constant of q */
static bool hasBoundVarAttr( Node n );
private:
- /** get bound vars */
- static void getBoundVars2( Node n, std::vector< Node >& vars, std::map< Node, bool >& visited );
/** get bound vars */
static Node getRemoveQuantifiers2( Node n, std::map< Node, Node >& visited );
public:
- //get the bound variables in this node
- static void getBoundVars( Node n, std::vector< Node >& vars );
//remove quantifiers
static Node getRemoveQuantifiers( Node n );
//quantified simplify (treat free variables in n as quantified and run rewriter)
regress1/sygus/abv.sy
regress1/sygus/array_search_5-Q-easy.sy
regress1/sygus/bvudiv-by-2.sy
- regress1/sygus/car_3.lus.sy
regress1/sygus/cegar1.sy
regress1/sygus/cegis-unif-inv-eq-fair.sy
regress1/sygus/cegisunif-depth1.sy
regress1/rewriterules/why3_vstte10_max_sum_harness2.smt2
regress1/sets/setofsets-disequal.smt2
regress1/simple-rdl-definefun.smt2
+ # does not solve after minor modification to search
+ regress1/sygus/car_3.lus.sy
regress1/sygus/Base16_1.sy
regress1/sygus/enum-test.sy
regress1/sygus/inv_gen_fig8.sy