exit( 11 );\r
}\r
//check if it is in the range\r
- bool inRange = true;\r
- for( unsigned b=0; b<2; b++ ){\r
- if( !m->isStar( it->first[b] ) ){\r
- if( ( b==0 && it->first[b].getConst<Rational>() > inst[index].getConst<Rational>() ) ||\r
- ( b==1 && it->first[b].getConst<Rational>() <= inst[index].getConst<Rational>() ) ){\r
- inRange = false;\r
- break;\r
- }\r
- }\r
- }\r
- if( inRange ){\r
+ if( m->isInRange(inst[index], it->first ) ){\r
int gindex = it->second.getGeneralizationIndex(m, inst, index+1);\r
if( minIndex==-1 || (gindex!=-1 && gindex<minIndex) ){\r
minIndex = gindex;\r
std::vector< Node > nc;\r
nc.push_back( cc.getOperator() );\r
for( unsigned j=0; j< cc.getNumChildren(); j++){\r
- nc.push_back(m->getStar(cc[j].getType()));\r
+ nc.push_back(m->getStarElement(cc[j].getType()));\r
}\r
cond[cond.size()-1] = NodeManager::currentNM()->mkNode( APPLY_UF, nc );\r
//re-add the entries\r
d_false = NodeManager::currentNM()->mkConst(false);\r
}\r
\r
+bool FullModelChecker::optBuildAtFullModel() {\r
+ //need to build after full model has taken effect if we are constructing interval models\r
+ // this is because we need to have a constant in all integer equivalence classes\r
+ return options::fmfFmcInterval();\r
+}\r
+\r
void FullModelChecker::processBuildModel(TheoryModel* m, bool fullModel){\r
FirstOrderModelFmc * fm = ((FirstOrderModelFmc*)m)->asFirstOrderModelFmc();\r
- if( fullModel ){\r
- //make function values\r
- for( std::map<Node, Def * >::iterator it = fm->d_models.begin(); it != fm->d_models.end(); ++it ){\r
- m->d_uf_models[ it->first ] = getFunctionValue( fm, it->first, "$x" );\r
- }\r
- TheoryEngineModelBuilder::processBuildModel( m, fullModel );\r
- //mark that the model has been set\r
- fm->markModelSet();\r
- //debug the model\r
- debugModel( fm );\r
- }else{\r
+ if( fullModel==optBuildAtFullModel() ){\r
Trace("fmc") << "---Full Model Check reset() " << std::endl;\r
fm->initialize( d_considerAxioms );\r
d_quant_models.clear();\r
bool hasNonStar = false;\r
for( unsigned i=0; i<c.getNumChildren(); i++) {\r
Node ri = fm->getUsedRepresentative( c[i]);\r
+ if( !ri.getType().isSort() && !ri.isConst() ){\r
+ Trace("fmc-warn") << "Warning : model has non-constant argument in model " << ri << std::endl;\r
+ }\r
children.push_back(ri);\r
if( !options::fmfFmcInterval() || !ri.getType().isInteger() ){\r
if (fm->isModelBasisTerm(ri) ) {\r
entry_children.push_back(ri);\r
}\r
Node n = NodeManager::currentNM()->mkNode( APPLY_UF, children );\r
- Node nv = fm->getUsedRepresentative( v);\r
+ Node nv = fm->getUsedRepresentative( v );\r
+ if( !nv.getType().isSort() && !nv.isConst() ){\r
+ Trace("fmc-warn") << "Warning : model has non-constant value in model " << nv << std::endl;\r
+ }\r
Node en = (useSimpleModels() && hasNonStar) ? n : NodeManager::currentNM()->mkNode( APPLY_UF, entry_children );\r
if( std::find(conds.begin(), conds.end(), n )==conds.end() ){\r
Trace("fmc-model-debug") << "- add " << n << " -> " << nv << " (entry is " << en << ")" << std::endl;\r
Trace("fmc-model") << std::endl;\r
}\r
}\r
+ if( fullModel ){\r
+ //make function values\r
+ for( std::map<Node, Def * >::iterator it = fm->d_models.begin(); it != fm->d_models.end(); ++it ){\r
+ m->d_uf_models[ it->first ] = getFunctionValue( fm, it->first, "$x" );\r
+ }\r
+ TheoryEngineModelBuilder::processBuildModel( m, fullModel );\r
+ //mark that the model has been set\r
+ fm->markModelSet();\r
+ //debug the model\r
+ debugModel( fm );\r
+ }\r
}\r
\r
void FullModelChecker::debugPrintCond(const char * tr, Node n, bool dispStar) {\r
riter.d_bounds[b][i] = c[i][b];\r
}\r
}\r
+ }else if( !fm->isStar(c[i]) ){\r
+ riter.d_bounds[0][i] = c[i];\r
+ riter.d_bounds[1][i] = QuantArith::offset( c[i], 1 );\r
}\r
}\r
//initialize\r
if (eq[0]==eq[1]){\r
d.addEntry(fm, mkCond(cond), d_true);\r
}else{\r
- int j = getVariableId(f, eq[0]);\r
- int k = getVariableId(f, eq[1]);\r
TypeNode tn = eq[0].getType();\r
- if( !fm->d_rep_set.hasType( tn ) ){\r
- getSomeDomainElement( fm, tn ); //to verify the type is initialized\r
- }\r
- for (unsigned i=0; i<fm->d_rep_set.d_type_reps[tn].size(); i++) {\r
- Node r = fm->getUsedRepresentative( fm->d_rep_set.d_type_reps[tn][i] );\r
- cond[j+1] = r;\r
- cond[k+1] = r;\r
- d.addEntry( fm, mkCond(cond), d_true);\r
+ if( tn.isSort() ){\r
+ int j = getVariableId(f, eq[0]);\r
+ int k = getVariableId(f, eq[1]);\r
+ if( !fm->d_rep_set.hasType( tn ) ){\r
+ getSomeDomainElement( fm, tn ); //to verify the type is initialized\r
+ }\r
+ for (unsigned i=0; i<fm->d_rep_set.d_type_reps[tn].size(); i++) {\r
+ Node r = fm->getUsedRepresentative( fm->d_rep_set.d_type_reps[tn][i] );\r
+ cond[j+1] = r;\r
+ cond[k+1] = r;\r
+ d.addEntry( fm, mkCond(cond), d_true);\r
+ }\r
+ d.addEntry( fm, mkCondDefault(fm, f), d_false);\r
+ }else{\r
+ d.addEntry( fm, mkCondDefault(fm, f), Node::null());\r
}\r
- d.addEntry( fm, mkCondDefault(fm, f), d_false);\r
}\r
}\r
\r
}\r
}else{\r
if( !v.isNull() ){\r
- if (curr.d_child.find(v)!=curr.d_child.end()) {\r
- Trace("fmc-uf-process") << "follow value..." << std::endl;\r
- doUninterpretedCompose2(fm, f, entries, index+1, cond, val, curr.d_child[v]);\r
- }\r
- Node st = fm->getStarElement(v.getType());\r
- if (curr.d_child.find(st)!=curr.d_child.end()) {\r
- Trace("fmc-uf-process") << "follow star..." << std::endl;\r
- doUninterpretedCompose2(fm, f, entries, index+1, cond, val, curr.d_child[st]);\r
+ if( options::fmfFmcInterval() && v.getType().isInteger() ){\r
+ for (std::map<Node, EntryTrie>::iterator it = curr.d_child.begin(); it != curr.d_child.end(); ++it) {\r
+ if( fm->isInRange( v, it->first ) ){\r
+ doUninterpretedCompose2(fm, f, entries, index+1, cond, val, it->second);\r
+ }\r
+ }\r
+ }else{\r
+ if (curr.d_child.find(v)!=curr.d_child.end()) {\r
+ Trace("fmc-uf-process") << "follow value..." << std::endl;\r
+ doUninterpretedCompose2(fm, f, entries, index+1, cond, val, curr.d_child[v]);\r
+ }\r
+ Node st = fm->getStarElement(v.getType());\r
+ if (curr.d_child.find(st)!=curr.d_child.end()) {\r
+ Trace("fmc-uf-process") << "follow star..." << std::endl;\r
+ doUninterpretedCompose2(fm, f, entries, index+1, cond, val, curr.d_child[st]);\r
+ }\r
}\r
}\r
}\r
}\r
\r
void FullModelChecker::mkCondDefaultVec( FirstOrderModelFmc * fm, Node f, std::vector< Node > & cond ) {\r
+ Trace("fmc-debug") << "Make default vec, intervals = " << options::fmfFmcInterval() << std::endl;\r
//get function symbol for f\r
cond.push_back(d_quant_cond[f]);\r
for (unsigned i=0; i<f[0].getNumChildren(); i++) {\r
\r
\r
bool FullModelChecker::useSimpleModels() {\r
- return options::fmfFullModelCheckSimple();\r
+ return options::fmfFmcSimple();\r
}\r
\r
void FullModelChecker::makeIntervalModel( FirstOrderModelFmc * fm, Node op, std::vector< int > & indices, int index,\r
void QModelBuilder::debugModel( FirstOrderModel* fm ){
//debug the model: cycle through all instantiations for all quantifiers, report ones that are not true
if( Trace.isOn("quant-model-warn") ){
+ Trace("quant-model-warn") << "Testing quantifier instantiations..." << std::endl;
+ int tests = 0;
+ int bad = 0;
for( int i=0; i<fm->getNumAssertedQuantifiers(); i++ ){
Node f = fm->getAssertedQuantifier( i );
std::vector< Node > vars;
vars.push_back( f[0][j] );
}
RepSetIterator riter( d_qe, &(fm->d_rep_set) );
- riter.setQuantifier( f );
- while( !riter.isFinished() ){
- std::vector< Node > terms;
- for( int i=0; i<riter.getNumTerms(); i++ ){
- terms.push_back( riter.getTerm( i ) );
+ if( riter.setQuantifier( f ) ){
+ while( !riter.isFinished() ){
+ tests++;
+ std::vector< Node > terms;
+ for( int i=0; i<riter.getNumTerms(); i++ ){
+ terms.push_back( riter.getTerm( i ) );
+ }
+ Node n = d_qe->getInstantiation( f, vars, terms );
+ Node val = fm->getValue( n );
+ if( val!=fm->d_true ){
+ Trace("quant-model-warn") << "******* Instantiation " << n << " for " << std::endl;
+ Trace("quant-model-warn") << " " << f << std::endl;
+ Trace("quant-model-warn") << " Evaluates to " << val << std::endl;
+ bad++;
+ }
+ riter.increment();
}
- Node n = d_qe->getInstantiation( f, vars, terms );
- Node val = fm->getValue( n );
- if( val!=fm->d_true ){
- Trace("quant-model-warn") << "******* Instantiation " << n << " for " << std::endl;
- Trace("quant-model-warn") << " " << f << std::endl;
- Trace("quant-model-warn") << " Evaluates to " << val << std::endl;
+ Trace("quant-model-warn") << "Tested " << tests << " instantiations";
+ if( bad>0 ){
+ Trace("quant-model-warn") << ", " << bad << " failed" << std::endl;
}
- riter.increment();
+ Trace("quant-model-warn") << "." << std::endl;
+ }else{
+ Trace("quant-model-warn") << "Warning: Could not test quantifier " << f << std::endl;
}
}
}