eq::EqClassIterator ieqc_i = eq::EqClassIterator( r, ee );\r
while( !ieqc_i.isFinished() ){\r
TNode n = (*ieqc_i);\r
- if( isHandledTerm( n ) ){\r
- d_op_arg_index[r].addTerm( this, n );\r
+ if( getTermDatabase()->hasTermCurrent( n ) ){\r
+ if( isHandledTerm( n ) ){\r
+ d_op_arg_index[r].addTerm( this, n );\r
+ }\r
}\r
++ieqc_i;\r
}\r
eq::EqClassIterator eqc_i = eq::EqClassIterator( r, ee );\r
while( !eqc_i.isFinished() ){\r
TNode n = (*eqc_i);\r
- if( !n.getAttribute(NoMatchAttribute()) && ( n.getKind()!=EQUAL || isFalse ) ){\r
+ if( getTermDatabase()->hasTermCurrent( n ) && !n.getAttribute(NoMatchAttribute()) && ( n.getKind()!=EQUAL || isFalse ) ){\r
if( firstTime ){\r
Trace("sg-gen-eqc") << "e" << d_em[r] << " : { " << std::endl;\r
firstTime = false;\r
//check constraints\r
for( std::map< Node, bool >::iterator it = d_tconstraints.begin(); it != d_tconstraints.end(); ++it ){\r
//apply substitution to the tconstraint\r
- Node cons = it->first.substitute( p->getQuantifiersEngine()->getTermDatabase()->d_vars[d_q].begin(),\r
- p->getQuantifiersEngine()->getTermDatabase()->d_vars[d_q].end(),\r
+ Node cons = it->first.substitute( p->getTermDatabase()->d_vars[d_q].begin(),\r
+ p->getTermDatabase()->d_vars[d_q].end(),\r
terms.begin(), terms.end() );\r
cons = it->second ? cons : cons.negate();\r
if( !entailmentTest( p, cons, p->d_effort==QuantConflictFind::effort_conflict ) ){\r
if( d_type==typ_var && p->d_effort==QuantConflictFind::effort_mc && !d_matched_basis ){\r
d_matched_basis = true;\r
Node f = getOperator( d_n );\r
- TNode mbo = p->getQuantifiersEngine()->getTermDatabase()->getModelBasisOpTerm( f );\r
+ TNode mbo = p->getTermDatabase()->getModelBasisOpTerm( f );\r
if( qi->setMatch( p, d_qni_var_num[0], mbo ) ){\r
success = true;\r
d_qni_bound[0] = d_qni_var_num[0];\r
\r
Node MatchGen::getOperator( QuantConflictFind * p, Node n ) {\r
if( isHandledUfTerm( n ) ){\r
- return p->getQuantifiersEngine()->getTermDatabase()->getOperator( n );\r
+ return p->getTermDatabase()->getOperator( n );\r
}else{\r
return Node::null();\r
}\r
while( !eqcs_i.isFinished() ){\r
//nEqc++;\r
Node r = (*eqcs_i);\r
- TypeNode rtn = r.getType();\r
- if( options::qcfMode()==QCF_MC ){\r
- std::map< TypeNode, std::vector< TNode > >::iterator itt = d_eqcs.find( rtn );\r
- if( itt==d_eqcs.end() ){\r
- Node mb = getQuantifiersEngine()->getTermDatabase()->getModelBasisTerm( rtn );\r
- if( !getEqualityEngine()->hasTerm( mb ) ){\r
- Trace("qcf-warn") << "WARNING: Model basis term does not exist!" << std::endl;\r
- Assert( false );\r
- }\r
- Node mbr = getRepresentative( mb );\r
- if( mbr!=r ){\r
- d_eqcs[rtn].push_back( mbr );\r
+ if( getTermDatabase()->hasTermCurrent( r ) ){\r
+ TypeNode rtn = r.getType();\r
+ if( options::qcfMode()==QCF_MC ){\r
+ std::map< TypeNode, std::vector< TNode > >::iterator itt = d_eqcs.find( rtn );\r
+ if( itt==d_eqcs.end() ){\r
+ Node mb = getTermDatabase()->getModelBasisTerm( rtn );\r
+ if( !getEqualityEngine()->hasTerm( mb ) ){\r
+ Trace("qcf-warn") << "WARNING: Model basis term does not exist!" << std::endl;\r
+ Assert( false );\r
+ }\r
+ Node mbr = getRepresentative( mb );\r
+ if( mbr!=r ){\r
+ d_eqcs[rtn].push_back( mbr );\r
+ }\r
+ d_eqcs[rtn].push_back( r );\r
+ d_model_basis[rtn] = mb;\r
+ }else{\r
+ itt->second.push_back( r );\r
}\r
- d_eqcs[rtn].push_back( r );\r
- d_model_basis[rtn] = mb;\r
}else{\r
- itt->second.push_back( r );\r
+ d_eqcs[rtn].push_back( r );\r
}\r
- }else{\r
- d_eqcs[rtn].push_back( r );\r
}\r
++eqcs_i;\r
}\r
return true;
}
+void TermDb::setHasTerm( Node n ) {
+ if( inst::Trigger::isAtomicTrigger( n ) ){
+ if( d_has_map.find( n )==d_has_map.end() ){
+ d_has_map[n] = true;
+ for( unsigned i=0; i<n.getNumChildren(); i++ ){
+ setHasTerm( n[i] );
+ }
+ }
+ }else{
+ for( unsigned i=0; i<n.getNumChildren(); i++ ){
+ setHasTerm( n[i] );
+ }
+ }
+}
+
void TermDb::reset( Theory::Effort effort ){
int nonCongruentCount = 0;
int congruentCount = 0;
d_arg_reps.clear();
d_func_map_trie.clear();
d_func_map_eqc_trie.clear();
- /*
+
//compute has map
+ /*
d_has_map.clear();
eq::EqualityEngine* ee = d_quantEngine->getMasterEqualityEngine();
eq::EqClassesIterator eqcs_i = eq::EqClassesIterator( ee );
while( !eqcs_i.isFinished() ){
TNode r = (*eqcs_i);
+ bool addedFirst = false;
+ Node first;
eq::EqClassIterator eqc_i = eq::EqClassIterator( r, ee );
while( !eqc_i.isFinished() ){
- d_has_map[(*eqc_i)] = true;
+ TNode n = (*eqc_i);
+ if( first.isNull() ){
+ first = n;
+ }else{
+ if( !addedFirst ){
+ addedFirst = true;
+ setHasTerm( first );
+ }
+ setHasTerm( n );
+ }
++eqc_i;
}
++eqcs_i;
}
+ for (TheoryId theoryId = THEORY_FIRST; theoryId < THEORY_LAST; ++theoryId) {
+ Theory* theory = d_quantEngine->getTheoryEngine()->d_theoryTable[theoryId];
+ if (theory && d_quantEngine->getTheoryEngine()->d_logicInfo.isTheoryEnabled(theoryId)) {
+ context::CDList<Assertion>::const_iterator it = theory->facts_begin(), it_end = theory->facts_end();
+ for (unsigned i = 0; it != it_end; ++ it, ++i) {
+ Trace("ajr-temp") << "Set has term " << (*it).assertion << std::endl;
+ setHasTerm( (*it).assertion );
+ }
+ }
+ }
*/
+
+
//rebuild d_func/pred_map_trie for each operation, this will calculate all congruent terms
for( std::map< Node, std::vector< Node > >::iterator it = d_op_map.begin(); it != d_op_map.end(); ++it ){
d_op_nonred_count[ it->first ] = 0;
alreadyCongruentCount++;
}
}else{
+ Trace("term-db-stats-debug") << n << " is not relevant." << std::endl;
nonRelevantCount++;
}
}
}
Trace("term-db-stats") << "TermDb: Reset" << std::endl;
Trace("term-db-stats") << "Congruent/Non-Congruent/Non-Relevant = ";
- Trace("term-db-stats") << congruentCount << "(" << alreadyCongruentCount << ") / " << nonCongruentCount << " / " << nonRelevantCount << std::endl;
+ Trace("term-db-stats") << nonCongruentCount << " / " << congruentCount << " (" << alreadyCongruentCount << ") / " << nonRelevantCount << std::endl;
if( Debug.isOn("term-db") ){
Debug("term-db") << "functions : " << std::endl;
for( std::map< Node, std::vector< Node > >::iterator it = d_op_map.begin(); it != d_op_map.end(); ++it ){
std::map< Node, std::map< TypeNode, Node > > d_par_op_map;
/** count number of ground terms per operator (user-context dependent) */
NodeIntMap d_op_ccount;
+ /** set has term */
+ void setHasTerm( Node n );
public:
TermDb( context::Context* c, context::UserContext* u, QuantifiersEngine* qe );
~TermDb(){}