using namespace CVC4::theory::quantifiers;
//priority levels :
-//1 : user patterns (when user-pat!={resort,ignore}), auto-gen patterns (for non-user pattern quantifiers)
-//2 : user patterns (when user-pat=resort ), auto gen patterns (for user pattern quantifiers, when user-pat=use)
+//1 : user patterns (when user-pat!={resort,ignore}), auto-gen patterns (for non-user pattern quantifiers, or when user-pat={ignore,resort})
+//2 : user patterns (when user-pat=resort), auto gen patterns (for user pattern quantifiers when user-pat=use)
//3 :
//4 :
//5 : full saturate quantifiers
+// user-pat=interleave alternates between use and resort
//#define MULTI_TRIGGER_FULL_EFFORT_HALF
if( e==0 ){
return STATUS_UNFINISHED;
}else{
- int peffort = options::userPatternsQuant()==USER_PAT_MODE_RESORT ? 2 : 1;
+ int peffort = d_quantEngine->getInstUserPatMode()==USER_PAT_MODE_RESORT ? 2 : 1;
if( e<peffort ){
return STATUS_UNFINISHED;
}else if( e==peffort ){
d_counter[f]++;
Trace("inst-alg") << "-> User-provided instantiate " << f << "..." << std::endl;
- if( options::userPatternsQuant()==USER_PAT_MODE_RESORT ){
+ if( d_quantEngine->getInstUserPatMode()==USER_PAT_MODE_RESORT ){
int matchOption = 0;
for( unsigned i=0; i<d_user_gen_wait[f].size(); i++ ){
Trigger * t = Trigger::mkTrigger( d_quantEngine, f, d_user_gen_wait[f][i], matchOption, true, Trigger::TR_RETURN_NULL, options::smartTriggers() );
d_quantEngine->getPhaseReqTerms( f, nodes );
//check match option
int matchOption = 0;
- if( options::userPatternsQuant()==USER_PAT_MODE_RESORT ){
+ if( d_quantEngine->getInstUserPatMode()==USER_PAT_MODE_RESORT ){
d_user_gen_wait[f].push_back( nodes );
}else{
d_user_gen[f].push_back( Trigger::mkTrigger( d_quantEngine, f, nodes, matchOption, true, Trigger::TR_MAKE_NEW, options::smartTriggers() ) );
}
int InstStrategyAutoGenTriggers::process( Node f, Theory::Effort effort, int e ){
- if( hasUserPatterns( f ) && options::userPatternsQuant()==USER_PAT_MODE_TRUST ){
+ UserPatMode upMode = d_quantEngine->getInstUserPatMode();
+ if( hasUserPatterns( f ) && upMode==USER_PAT_MODE_TRUST ){
return STATUS_UNKNOWN;
}else{
- int peffort = ( hasUserPatterns( f ) && options::userPatternsQuant()!=USER_PAT_MODE_IGNORE && options::userPatternsQuant()!=USER_PAT_MODE_RESORT ) ? 2 : 1;
+ int peffort = ( hasUserPatterns( f ) && upMode!=USER_PAT_MODE_IGNORE && upMode!=USER_PAT_MODE_RESORT ) ? 2 : 1;
if( e<peffort ){
return STATUS_UNFINISHED;
}else{
}
}
-
-void InstStrategyLocalTheoryExt::processResetInstantiationRound( Theory::Effort effort ){
- //reset triggers
- for( std::map< Node, Trigger* >::iterator it = d_lte_trigger.begin(); it != d_lte_trigger.end(); ++it ){
- it->second->resetInstantiationRound();
- it->second->reset( Node::null() );
- }
-}
-
-int InstStrategyLocalTheoryExt::process( Node f, Theory::Effort effort, int e ) {
- if( e<3 ){
- return STATUS_UNFINISHED;
- }else if( e==3 ){
- if( isLocalTheoryExt( f ) ){
- std::map< Node, Trigger* >::iterator it = d_lte_trigger.find( f );
- if( it!=d_lte_trigger.end() ){
- Trigger * tr = it->second;
- //process the trigger
- Trace("process-trigger") << " LTE process ";
- tr->debugPrint("process-trigger");
- Trace("process-trigger") << "..." << std::endl;
- InstMatch baseMatch( f );
- int numInst = tr->addInstantiations( baseMatch );
- Trace("process-trigger") << " Done, numInst = " << numInst << "." << std::endl;
- d_quantEngine->getInstantiationEngine()->d_statistics.d_instantiations_lte += numInst;
- }
- }
- }
- return STATUS_UNKNOWN;
-}
-
+/* TODO?
bool InstStrategyLocalTheoryExt::isLocalTheoryExt( Node f ) {
std::map< Node, bool >::iterator itq = d_quant.find( f );
if( itq==d_quant.end() ){
return itq->second;
}
}
+*/
void InstStrategyFreeVariable::processResetInstantiationRound( Theory::Effort effort ){
void addUserNoPattern( Node f, Node pat );
};/* class InstStrategyAutoGenTriggers */
-
-class InstStrategyLocalTheoryExt : public InstStrategy {
-private:
- /** have we registered quantifier, value is whether it is an LTE term */
- std::map< Node, bool > d_quant;
- /** triggers for each quantifier */
- std::map< Node, inst::Trigger* > d_lte_trigger;
-private:
- /** process functions */
- void processResetInstantiationRound( Theory::Effort effort );
- int process( Node f, Theory::Effort effort, int e );
-public:
- InstStrategyLocalTheoryExt( QuantifiersEngine* qe ) : InstStrategy( qe ){}
- /** identify */
- std::string identify() const { return std::string("LocalTheoryExt"); }
- /** is local theory quantifier? */
- bool isLocalTheoryExt( Node f );
-};
-
-
class InstStrategyFreeVariable : public InstStrategy{
private:
/** guessed instantiations */
using namespace CVC4::theory::inst;
InstantiationEngine::InstantiationEngine( QuantifiersEngine* qe ) :
-QuantifiersModule( qe ), d_isup(NULL), d_i_ag(NULL), d_i_lte(NULL), d_i_fs(NULL), d_i_splx(NULL), d_i_cegqi( NULL ){
+QuantifiersModule( qe ), d_isup(NULL), d_i_ag(NULL), d_i_fs(NULL), d_i_splx(NULL), d_i_cegqi( NULL ){
}
InstantiationEngine::~InstantiationEngine() {
delete d_i_ag;
delete d_isup;
- delete d_i_lte;
delete d_i_fs;
delete d_i_splx;
delete d_i_cegqi;
d_instStrategies.push_back( d_i_ag );
}
- //local theory extensions TODO?
- //if( options::localTheoryExt() ){
- // d_i_lte = new InstStrategyLocalTheoryExt( d_quantEngine );
- // d_instStrategies.push_back( d_i_lte );
- //}
-
//full saturation : instantiate from relevant domain, then arbitrary terms
if( options::fullSaturateQuant() ){
d_i_fs = new InstStrategyFreeVariable( d_quantEngine );
class InstStrategyUserPatterns;
class InstStrategyAutoGenTriggers;
-class InstStrategyLocalTheoryExt;
class InstStrategyFreeVariable;
class InstStrategySimplex;
class InstStrategyCegqi;
InstStrategyUserPatterns* d_isup;
/** auto gen triggers; only kept for destructor cleanup */
InstStrategyAutoGenTriggers* d_i_ag;
- /** local theory extensions */
- InstStrategyLocalTheoryExt * d_i_lte;
/** full saturate */
InstStrategyFreeVariable * d_i_fs;
/** simplex (cbqi) */
USER_PAT_MODE_RESORT,
/** ignore user patterns */
USER_PAT_MODE_IGNORE,
+ /** interleave use/resort for user patterns */
+ USER_PAT_MODE_INTERLEAVE,
} UserPatMode;
typedef enum {
ignore \n\
+ Ignore user-provided patterns. \n\
\n\
+interleave \n\
++ Alternate between use/resort. \n\
+\n\
";
static const std::string triggerSelModeHelp = "\
Trigger selection modes currently supported by the --trigger-sel option:\n\
return USER_PAT_MODE_RESORT;
} else if(optarg == "ignore") {
return USER_PAT_MODE_IGNORE;
+ } else if(optarg == "interleave") {
+ return USER_PAT_MODE_INTERLEAVE;
} else if(optarg == "help") {
puts(userPatModeHelp.c_str());
exit(1);
return performCheck;
}
+quantifiers::UserPatMode QuantifiersEngine::getInstUserPatMode() {
+ if( options::userPatternsQuant()==quantifiers::USER_PAT_MODE_INTERLEAVE ){
+ return d_ierCounter%2==0 ? quantifiers::USER_PAT_MODE_USE : quantifiers::USER_PAT_MODE_RESORT;
+ }else{
+ return options::userPatternsQuant();
+ }
+}
+
void QuantifiersEngine::flushLemmas(){
if( !d_lemmas_waiting.empty() ){
//take default output channel if none is provided
#include "util/hash.h"
#include "theory/quantifiers/inst_match.h"
#include "theory/quantifiers/quant_util.h"
+#include "theory/quantifiers/modes.h"
#include "expr/attribute.h"
#include "util/statistics_registry.h"
int getNumLemmasWaiting() { return (int)d_lemmas_waiting.size(); }
/** get needs check */
bool getInstWhenNeedsCheck( Theory::Effort e );
+ /** get user pat mode */
+ quantifiers::UserPatMode getInstUserPatMode();
/** set instantiation level attr */
static void setInstantiationLevelAttr( Node n, uint64_t level );
public: