int InstStrategyAutoGenTriggers::process( Node f, Theory::Effort effort, int e ){ int peffort = f.getNumChildren()==3 ? 2 : 1; //int peffort = f.getNumChildren()==3 ? 2 : 1; //int peffort = 1; if( e<peffort ){ return STATUS_UNFINISHED; }else{ bool gen = false; if( e==peffort ){ if( d_counter.find( f )==d_counter.end() ){ d_counter[f] = 0; gen = true; }else{ d_counter[f]++; gen = d_regenerate && d_counter[f]%d_regenerate_frequency==0; } }else{ gen = true; } if( gen ){ generateTriggers( f ); } Debug("quant-uf-strategy") << "Try auto-generated triggers... " << d_tr_strategy << " " << e << std::endl; //Notice() << "Try auto-generated triggers..." << std::endl; for( std::map< Trigger*, bool >::iterator itt = d_auto_gen_trigger[f].begin(); itt != d_auto_gen_trigger[f].end(); ++itt ){ Trigger* tr = itt->first; if( tr ){ bool processTrigger = itt->second; if( effort!=Theory::EFFORT_LAST_CALL && tr->isMultiTrigger() ){ #ifdef MULTI_TRIGGER_FULL_EFFORT_HALF processTrigger = d_counter[f]%2==0; #endif } if( processTrigger ){ //if( tr->isMultiTrigger() ) Debug("quant-uf-strategy-auto-gen-triggers") << " Process " << (*tr) << "..." << std::endl; InstMatch baseMatch; int numInst = tr->addInstantiations( baseMatch ); //if( tr->isMultiTrigger() ) Debug("quant-uf-strategy-auto-gen-triggers") << " Done, numInst = " << numInst << "." << std::endl; if( d_tr_strategy==Trigger::TS_MIN_TRIGGER ){ d_quantEngine->getInstantiationEngine()->d_statistics.d_instantiations_auto_gen_min += numInst; }else{ d_quantEngine->getInstantiationEngine()->d_statistics.d_instantiations_auto_gen += numInst; } if( tr->isMultiTrigger() ){ d_quantEngine->d_statistics.d_multi_trigger_instantiations += numInst; } //d_quantEngine->d_hasInstantiated[f] = true; } } } Debug("quant-uf-strategy") << "done." << std::endl; //Notice() << "done" << std::endl; } return STATUS_UNKNOWN; }
int InstStrategyAutoGenTriggers::process( Node f, Theory::Effort effort, int e ){ if( f.getNumChildren()==3 && options::userPatternsQuant()==USER_PAT_MODE_TRUST ){ return STATUS_UNKNOWN; }else{ int peffort = ( f.getNumChildren()==3 && options::userPatternsQuant()!=USER_PAT_MODE_IGNORE ) ? 2 : 1; //int peffort = 1; if( e<peffort ){ return STATUS_UNFINISHED; }else{ int status = STATUS_UNKNOWN; bool gen = false; if( e==peffort ){ if( d_counter.find( f )==d_counter.end() ){ d_counter[f] = 0; gen = true; }else{ d_counter[f]++; gen = d_regenerate && d_counter[f]%d_regenerate_frequency==0; } }else{ gen = true; } if( gen ){ generateTriggers( f, effort, e, status ); if( d_auto_gen_trigger[f].empty() && f.getNumChildren()==2 ){ Trace("no-trigger") << "Could not find trigger for " << f << std::endl; } } Trace("inst-alg") << "-> Auto-gen instantiate " << f << "..." << std::endl; //if( e==4 ){ // d_processed_trigger.clear(); // d_quantEngine->getEqualityQuery()->setLiberal( true ); //} Debug("quant-uf-strategy") << "Try auto-generated triggers... " << d_tr_strategy << " " << e << std::endl; //Notice() << "Try auto-generated triggers..." << std::endl; for( std::map< Trigger*, bool >::iterator itt = d_auto_gen_trigger[f].begin(); itt != d_auto_gen_trigger[f].end(); ++itt ){ Trigger* tr = itt->first; if( tr ){ bool processTrigger = itt->second; if( processTrigger && d_processed_trigger[f].find( tr )==d_processed_trigger[f].end() ){ d_processed_trigger[f][tr] = true; //if( tr->isMultiTrigger() ) Trace("process-trigger") << " Process "; tr->debugPrint("process-trigger"); Trace("process-trigger") << "..." << std::endl; InstMatch baseMatch( f ); int numInst = tr->addInstantiations( baseMatch ); //if( tr->isMultiTrigger() ) Trace("process-trigger") << " Done, numInst = " << numInst << "." << std::endl; if( d_tr_strategy==Trigger::TS_MIN_TRIGGER ){ d_quantEngine->getInstantiationEngine()->d_statistics.d_instantiations_auto_gen_min += numInst; }else{ d_quantEngine->getInstantiationEngine()->d_statistics.d_instantiations_auto_gen += numInst; } if( tr->isMultiTrigger() ){ d_quantEngine->d_statistics.d_multi_trigger_instantiations += numInst; } //d_quantEngine->d_hasInstantiated[f] = true; } } } //if( e==4 ){ // d_quantEngine->getEqualityQuery()->setLiberal( false ); //} Debug("quant-uf-strategy") << "done." << std::endl; //Notice() << "done" << std::endl; return status; } } }
int InstStrategyAutoGenTriggers::process( Node f, Theory::Effort effort, int e ){ UserPatMode upMode = d_quantEngine->getInstUserPatMode(); if( hasUserPatterns( f ) && upMode==USER_PAT_MODE_TRUST ){ return STATUS_UNKNOWN; }else{ int peffort = ( hasUserPatterns( f ) && upMode!=USER_PAT_MODE_IGNORE && upMode!=USER_PAT_MODE_RESORT ) ? 2 : 1; if( e<peffort ){ return STATUS_UNFINISHED; }else{ Trace("inst-alg") << "-> Auto-gen instantiate " << f << "..." << std::endl; bool gen = false; if( e==peffort ){ if( d_counter.find( f )==d_counter.end() ){ d_counter[f] = 0; gen = true; }else{ d_counter[f]++; gen = d_regenerate && d_counter[f]%d_regenerate_frequency==0; } }else{ gen = true; } if( gen ){ generateTriggers( f ); if( d_counter[f]==0 && d_auto_gen_trigger[0][f].empty() && d_auto_gen_trigger[1][f].empty() && f.getNumChildren()==2 ){ Trace("trigger-warn") << "Could not find trigger for " << f << std::endl; } } //if( e==4 ){ // d_processed_trigger.clear(); // d_quantEngine->getEqualityQuery()->setLiberal( true ); //} if( options::triggerActiveSelMode()!=TRIGGER_ACTIVE_SEL_ALL ){ int max_score = -1; Trigger * max_trigger = NULL; for( std::map< Trigger*, bool >::iterator itt = d_auto_gen_trigger[0][f].begin(); itt != d_auto_gen_trigger[0][f].end(); ++itt ){ int score = itt->first->getActiveScore(); if( options::triggerActiveSelMode()==TRIGGER_ACTIVE_SEL_MIN ){ if( score>=0 && ( score<max_score || max_score<0 ) ){ max_score = score; max_trigger = itt->first; } }else{ if( score>max_score ){ max_score = score; max_trigger = itt->first; } } d_auto_gen_trigger[0][f][itt->first] = false; } if( max_trigger!=NULL ){ d_auto_gen_trigger[0][f][max_trigger] = true; } } bool hasInst = false; for( unsigned r=0; r<2; r++ ){ for( std::map< Trigger*, bool >::iterator itt = d_auto_gen_trigger[r][f].begin(); itt != d_auto_gen_trigger[r][f].end(); ++itt ){ Trigger* tr = itt->first; if( tr ){ bool processTrigger = itt->second; if( processTrigger && d_processed_trigger[f].find( tr )==d_processed_trigger[f].end() ){ d_processed_trigger[f][tr] = true; Trace("process-trigger") << " Process "; tr->debugPrint("process-trigger"); Trace("process-trigger") << "..." << std::endl; InstMatch baseMatch( f ); int numInst = tr->addInstantiations( baseMatch ); hasInst = numInst>0 || hasInst; Trace("process-trigger") << " Done, numInst = " << numInst << "." << std::endl; d_quantEngine->d_statistics.d_instantiations_auto_gen += numInst; if( r==1 ){ d_quantEngine->d_statistics.d_multi_trigger_instantiations += numInst; } if( d_quantEngine->inConflict() ){ break; } } } } if( d_quantEngine->inConflict() || ( hasInst && options::multiTriggerPriority() ) ){ break; } } //if( e==4 ){ // d_quantEngine->getEqualityQuery()->setLiberal( false ); //} return STATUS_UNKNOWN; } } }