Node sbody = d_base_body.substitute(
candidates.begin(), candidates.end(), vals.begin(), vals.end());
Trace("cegis-sample-debug2") << "Sample " << sbody << std::endl;
- // do eager unfolding
- std::map<Node, Node> visited_n;
- sbody = d_qe->getTermDatabaseSygus()->getEagerUnfold(sbody, visited_n);
- Trace("cegis-sample") << "Sample (after unfolding): " << sbody << std::endl;
+ // do eager rewriting
+ sbody = Rewriter::rewrite(sbody);
+ Trace("cegis-sample") << "Sample (after rewriting): " << sbody << std::endl;
NodeManager* nm = NodeManager::currentNM();
for (unsigned i = 0, size = d_cegis_sampler.getNumSamplePoints(); i < size;
return unfold(en, vtm, exp, false);
}
-Node TermDbSygus::getEagerUnfold( Node n, std::map< Node, Node >& visited ) {
- std::map< Node, Node >::iterator itv = visited.find( n );
- if( itv==visited.end() ){
- Trace("cegqi-eager-debug") << "getEagerUnfold " << n << std::endl;
- Node ret;
- if (n.getKind() == DT_SYGUS_EVAL)
- {
- TypeNode tn = n[0].getType();
- Trace("cegqi-eager-debug") << "check " << n[0].getType() << std::endl;
- if( tn.isDatatype() ){
- const Datatype& dt = ((DatatypeType)(tn).toType()).getDatatype();
- if( dt.isSygus() ){
- Trace("cegqi-eager") << "Unfold eager : " << n << std::endl;
- Node bTerm = sygusToBuiltin( n[0], tn );
- Trace("cegqi-eager") << "Built-in term : " << bTerm << std::endl;
- std::vector< Node > vars;
- std::vector< Node > subs;
- Node var_list = Node::fromExpr( dt.getSygusVarList() );
- Assert(var_list.getNumChildren() + 1 == n.getNumChildren());
- for( unsigned j=0; j<var_list.getNumChildren(); j++ ){
- vars.push_back( var_list[j] );
- }
- for( unsigned j=1; j<n.getNumChildren(); j++ ){
- Node nc = getEagerUnfold( n[j], visited );
- subs.push_back( nc );
- Assert(subs[j - 1].getType().isComparableTo(
- var_list[j - 1].getType()));
- }
- Assert(vars.size() == subs.size());
- bTerm = bTerm.substitute( vars.begin(), vars.end(), subs.begin(), subs.end() );
- Trace("cegqi-eager") << "Built-in term after subs : " << bTerm << std::endl;
- Trace("cegqi-eager-debug") << "Types : " << bTerm.getType() << " " << n.getType() << std::endl;
- Assert(n.getType().isComparableTo(bTerm.getType()));
- ret = bTerm;
- }
- }
- }
- if( ret.isNull() ){
- if( n.getKind()!=FORALL ){
- bool childChanged = false;
- std::vector< Node > children;
- for( unsigned i=0; i<n.getNumChildren(); i++ ){
- Node nc = getEagerUnfold( n[i], visited );
- childChanged = childChanged || n[i]!=nc;
- children.push_back( nc );
- }
- if( childChanged ){
- if( n.getMetaKind() == kind::metakind::PARAMETERIZED ){
- children.insert( children.begin(), n.getOperator() );
- }
- ret = NodeManager::currentNM()->mkNode( n.getKind(), children );
- }
- }
- if( ret.isNull() ){
- ret = n;
- }
- }
- visited[n] = ret;
- return ret;
- }else{
- return itv->second;
- }
-}
-
Node TermDbSygus::evaluateBuiltin(TypeNode tn,
Node bn,
std::vector<Node>& args,