return d_iclosure_processed.find( r )!=d_iclosure_processed.end();
}
+//checks whether a type is reasonably small enough such that all of its domain elements can be enumerated
+bool TermDb::mayComplete( TypeNode tn ) {
+ std::map< TypeNode, bool >::iterator it = d_may_complete.find( tn );
+ if( it==d_may_complete.end() ){
+ bool mc = false;
+ if( !tn.isArray() && tn.getCardinality().isFinite() && !tn.getCardinality().isLargeFinite() ){
+ Node card = NodeManager::currentNM()->mkConst( Rational(tn.getCardinality().getFiniteCardinality()) );
+ Node oth = NodeManager::currentNM()->mkConst( Rational(1000) );
+ Node eq = NodeManager::currentNM()->mkNode( LEQ, card, oth );
+ eq = Rewriter::rewrite( eq );
+ mc = eq==d_true;
+ }
+ d_may_complete[tn] = mc;
+ return mc;
+ }else{
+ return it->second;
+ }
+}
+
void TermDb::setHasTerm( Node n ) {
Trace("term-db-debug2") << "hasTerm : " << n << std::endl;
//if( inst::Trigger::isAtomicTrigger( n ) ){
#include "theory/rep_set.h"
#include "theory/type_enumerator.h"
#include "theory/quantifiers/bounded_integers.h"
+#include "theory/quantifiers/term_database.h"
using namespace std;
using namespace CVC4;
}
}
-void RepSet::complete( TypeNode t ){
- if( d_type_complete.find( t )==d_type_complete.end() ){
+bool RepSet::complete( TypeNode t ){
+ std::map< TypeNode, bool >::iterator it = d_type_complete.find( t );
+ if( it==d_type_complete.end() ){
+ //remove all previous
+ for( unsigned i=0; i<d_type_reps[t].size(); i++ ){
+ d_tmap.erase( d_type_reps[t][i] );
+ }
+ d_type_reps[t].clear();
+ //now complete the type
d_type_complete[t] = true;
TypeEnumerator te(t);
while( !te.isFinished() ){
Trace("reps-complete") << d_type_reps[t][i] << " ";
}
Trace("reps-complete") << std::endl;
+ return true;
+ }else{
+ return it->second;
}
}
}
bool RepSetIterator::initialize(){
+ Trace("rsi") << "Initialize rep set iterator..." << std::endl;
for( size_t i=0; i<d_types.size(); i++ ){
d_index.push_back( 0 );
//store default index order
//store default domain
d_domain.push_back( RepDomain() );
TypeNode tn = d_types[i];
+ Trace("rsi") << "Var #" << i << " is type " << tn << "..." << std::endl;
if( tn.isSort() ){
if( !d_rep_set->hasType( tn ) ){
Node var = NodeManager::currentNM()->mkSkolem( "repSet", tn, "is a variable created by the RepSetIterator" );
//check if it is bound
if( d_owner.getKind()==FORALL && d_qe && d_qe->getBoundedIntegers() ){
if( d_qe->getBoundedIntegers()->isBoundVar( d_owner, d_owner[0][i] ) ){
- Trace("bound-int-rsi") << "Rep set iterator: variable #" << i << " is bounded integer." << std::endl;
+ Trace("rsi") << " variable is bounded integer." << std::endl;
d_enum_type.push_back( ENUM_RANGE );
}else{
inc = true;
if( inc ){
//check if it is otherwise bound
if( d_bounds[0].find(i)!=d_bounds[0].end() && d_bounds[1].find(i)!=d_bounds[1].end() ){
- Trace("bound-int-rsi") << "Rep set iterator: variable #" << i << " is bounded." << std::endl;
+ Trace("rsi") << " variable is bounded." << std::endl;
d_enum_type.push_back( ENUM_RANGE );
}else{
+ Trace("rsi") << " variable cannot be bounded." << std::endl;
Trace("fmf-incomplete") << "Incomplete because of integer quantification of " << d_owner[0][i] << "." << std::endl;
d_incomplete = true;
}
}
//enumerate if the sort is reasonably small, not an Array, the upper bound of 1000 is chosen arbitrarily for now
- }else if( !tn.isArray() && tn.getCardinality().isFinite() && !tn.getCardinality().isLargeFinite() &&
- tn.getCardinality().getFiniteCardinality().toUnsignedInt()<=1000 ){
+ }else if( d_qe->getTermDatabase()->mayComplete( tn ) ){
+ Trace("rsi") << " do complete, since cardinality is small (" << tn.getCardinality() << ")..." << std::endl;
d_rep_set->complete( tn );
}else{
+ Trace("rsi") << " variable cannot be bounded." << std::endl;
Trace("fmf-incomplete") << "Incomplete because of quantification of type " << tn << std::endl;
d_incomplete = true;
}