if( !hasEqcInfo( n ) ){
if( doMake ){
//add to labels
- NodeList* lbl = new(getSatContext()->getCMM()) NodeList( true, getSatContext(), false,
- ContextMemoryAllocator<TNode>(getSatContext()->getCMM()) );
- d_labels.insertDataFromContextMemory( n, lbl );
+ d_labels[ n ] = 0;
std::map< Node, EqcInfo* >::iterator eqc_i = d_eqc_info.find( n );
EqcInfo* ei;
if( n.getKind()==APPLY_CONSTRUCTOR ){
ei->d_constructor = n;
}
+
//add to selectors
- NodeList* sel = new(getSatContext()->getCMM()) NodeList( true, getSatContext(), false,
- ContextMemoryAllocator<TNode>(getSatContext()->getCMM()) );
- d_selector_apps.insertDataFromContextMemory( n, sel );
+ d_selector_apps[n] = 0;
+
return ei;
}else{
return NULL;
Trace("datatypes-debug") << "Check for splits " << e << endl;
do {
d_addedFact = false;
+ bool added_split = false;
std::map< TypeNode, Node > rec_singletons;
eq::EqClassesIterator eqcs_i = eq::EqClassesIterator( &d_equalityEngine );
while( !eqcs_i.isFinished() ){
//doSendLemma( lemma );
d_out->lemma( lemma, false, false, true );
}
- return;
+ added_split = true;
+ if( !options::dtBlastSplits() ){
+ return;
+ }
}
}else{
Trace("dt-split-debug") << "Do not split constructor for " << n << " : " << n.getType() << " " << dt.getNumConstructors() << std::endl;
}
++eqcs_i;
}
+ if( added_split ){
+ return;
+ }
Trace("datatypes-debug") << "Flush pending facts..." << std::endl;
flushPendingFacts();
/*
//merge labels
- NodeListMap::iterator lbl_i = d_labels.find( t2 );
+ NodeIntMap::iterator lbl_i = d_labels.find( t2 );
if( lbl_i != d_labels.end() ){
Trace("datatypes-debug") << " merge labels from " << eqc2 << " " << t2 << std::endl;
- NodeList* lbl = (*lbl_i).second;
- for( NodeList::const_iterator j = lbl->begin(); j != lbl->end(); ++j ){
- Node tt = (*j).getKind()==kind::NOT ? (*j)[0] : (*j);
+ int n_label = (*lbl_i).second;
+ for( int i=0; i<n_label; i++ ){
+ Assert( i<(int)d_labels_data[ t2 ].size() );
+ Node t = d_labels_data[ t2 ][i];
+ Node tt = t.getKind()==kind::NOT ? t[0] : t;
Node t_arg;
int tindex = DatatypesRewriter::isTester( tt, t_arg );
Assert( tindex!=-1 );
- addTester( tindex, *j, eqc1, t1, t_arg );
+ addTester( tindex, t, eqc1, t1, t_arg );
if( d_conflict ){
Trace("datatypes-debug") << " conflict!" << std::endl;
return;
}
}
+
}
//merge selectors
if( !eqc1->d_selectors && eqc2->d_selectors ){
eqc1->d_selectors = true;
checkInst = true;
}
- NodeListMap::iterator sel_i = d_selector_apps.find( t2 );
+ NodeIntMap::iterator sel_i = d_selector_apps.find( t2 );
if( sel_i != d_selector_apps.end() ){
Trace("datatypes-debug") << " merge selectors from " << eqc2 << " " << t2 << std::endl;
- NodeList* sel = (*sel_i).second;
- for( NodeList::const_iterator j = sel->begin(); j != sel->end(); ++j ){
- addSelector( *j, eqc1, t1, eqc2->d_constructor.get().isNull() );
+ int n_sel = (*sel_i).second;
+ for( int j=0; j<n_sel; j++ ){
+ addSelector( d_selector_apps_data[t2][j], eqc1, t1, eqc2->d_constructor.get().isNull() );
}
}
if( checkInst ){
}
Node TheoryDatatypes::getLabel( Node n ) {
- NodeListMap::iterator lbl_i = d_labels.find( n );
+ NodeIntMap::iterator lbl_i = d_labels.find( n );
if( lbl_i != d_labels.end() ){
- NodeList* lbl = (*lbl_i).second;
- if( !(*lbl).empty() && (*lbl)[ (*lbl).size() - 1 ].getKind()!=kind::NOT ){
- return (*lbl)[ (*lbl).size() - 1 ];
+ unsigned n_lbl = (*lbl_i).second;
+ if( n_lbl>0 && d_labels_data[n][ n_lbl-1 ].getKind()!=kind::NOT ){
+ return d_labels_data[n][ n_lbl-1 ];
}
}
return Node::null();
}
bool TheoryDatatypes::hasTester( Node n ) {
- NodeListMap::iterator lbl_i = d_labels.find( n );
+ NodeIntMap::iterator lbl_i = d_labels.find( n );
if( lbl_i != d_labels.end() ){
- return !(*(*lbl_i).second).empty();
+ return (*lbl_i).second>0;
}else{
return false;
}
if( lindex!=-1 ){
pcons[ lindex ] = true;
}else{
- NodeListMap::iterator lbl_i = d_labels.find( n );
+ NodeIntMap::iterator lbl_i = d_labels.find( n );
if( lbl_i != d_labels.end() ){
- NodeList* lbl = (*lbl_i).second;
- for( NodeList::const_iterator i = lbl->begin(); i != lbl->end(); i++ ) {
- Assert( (*i).getKind()==NOT );
- //pcons[ Datatype::indexOf( (*i)[0].getOperator().toExpr() ) ] = false;
- int tindex = DatatypesRewriter::isTester( (*i)[0] );
+ int n_lbl = (*lbl_i).second;
+ for( int i=0; i<n_lbl; i++ ){
+ Node t = d_labels_data[n][i];
+ Assert( t.getKind()==NOT );
+ //pcons[ Datatype::indexOf( t[0].getOperator().toExpr() ) ] = false;
+ int tindex = DatatypesRewriter::isTester( t[0] );
Assert( tindex!=-1 );
pcons[ tindex ] = false;
}
}
void TheoryDatatypes::getSelectorsForCons( Node r, std::map< int, bool >& sels ) {
- NodeListMap::iterator sel_i = d_selector_apps.find( r );
+ NodeIntMap::iterator sel_i = d_selector_apps.find( r );
if( sel_i != d_selector_apps.end() ){
- NodeList* sel = (*sel_i).second;
- for( NodeList::const_iterator j = sel->begin(); j != sel->end(); j++ ){
- int sindex = Datatype::indexOf( (*j).getOperator().toExpr() );
+ int n_sel = (*sel_i).second;
+ for( int j=0; j<n_sel; j++ ){
+ int sindex = Datatype::indexOf( d_selector_apps_data[r][j].getOperator().toExpr() );
sels[sindex] = true;
}
}
}
}else{
//otherwise, scan list of labels
- NodeListMap::iterator lbl_i = d_labels.find( n );
+ NodeIntMap::iterator lbl_i = d_labels.find( n );
Assert( lbl_i != d_labels.end() );
- NodeList* lbl = (*lbl_i).second;
- for( NodeList::const_iterator i = lbl->begin(); i != lbl->end(); i++ ) {
- Assert( (*i).getKind()==NOT );
- j = *i;
+ int n_lbl = (*lbl_i).second;
+ for( int i=0; i<n_lbl; i++ ){
+ Node ti = d_labels_data[n][i];
+ Assert( ti.getKind()==NOT );
+ j = ti;
jt = j[0];
//int jtindex = Datatype::indexOf( jt.getOperator().toExpr() );
int jtindex = DatatypesRewriter::isTester( jt );
}
if( !makeConflict ){
Debug("datatypes-labels") << "Add to labels " << t << std::endl;
- lbl->push_back( t );
+ //lbl->push_back( t );
+ d_labels[n] = n_lbl + 1;
+ if( n_lbl<(int)d_labels_data[n].size() ){
+ d_labels_data[n][n_lbl] = t;
+ }else{
+ d_labels_data[n].push_back( t );
+ }
+ n_lbl++;
+
const Datatype& dt = ((DatatypeType)(t_arg.getType()).toType()).getDatatype();
- Debug("datatypes-labels") << "Labels at " << lbl->size() << " / " << dt.getNumConstructors() << std::endl;
+ Debug("datatypes-labels") << "Labels at " << n_lbl << " / " << dt.getNumConstructors() << std::endl;
if( tpolarity ){
instantiate( eqc, n );
}else{
//check if we have reached the maximum number of testers
// in this case, add the positive tester
//this should not be done for sygus, since cases may be limited
- if( lbl->size()==dt.getNumConstructors()-1 && !dt.isSygus() ){
+ if( n_lbl==(int)dt.getNumConstructors()-1 && !dt.isSygus() ){
std::vector< bool > pcons;
getPossibleCons( eqc, n, pcons );
int testerIndex = -1;
//we must explain why each term in the set of testers for this equivalence class is equal
std::vector< Node > eq_terms;
NodeBuilder<> nb(kind::AND);
- for( NodeList::const_iterator i = lbl->begin(); i != lbl->end(); i++ ) {
- nb << (*i);
- Assert( (*i).getKind()==NOT );
+ //for( NodeList::const_iterator i = lbl->begin(); i != lbl->end(); i++ ) {
+
+ for( int i=0; i<n_lbl; i++ ){
+ Node ti = d_labels_data[n][i];
+ nb << ti;
+ Assert( ti.getKind()==NOT );
Node t_arg2;
- DatatypesRewriter::isTester( (*i)[0], t_arg2 );
+ DatatypesRewriter::isTester( ti[0], t_arg2 );
//Assert( tindex!=-1 );
if( std::find( eq_terms.begin(), eq_terms.end(), t_arg2 )==eq_terms.end() ){
eq_terms.push_back( t_arg2 );
void TheoryDatatypes::addSelector( Node s, EqcInfo* eqc, Node n, bool assertFacts ) {
Trace("dt-collapse-sel") << "Add selector : " << s << " to eqc(" << n << ")" << std::endl;
//check to see if it is redundant
- NodeListMap::iterator sel_i = d_selector_apps.find( n );
+ NodeIntMap::iterator sel_i = d_selector_apps.find( n );
Assert( sel_i != d_selector_apps.end() );
if( sel_i != d_selector_apps.end() ){
- NodeList* sel = (*sel_i).second;
- for( NodeList::const_iterator j = sel->begin(); j != sel->end(); ++j ){
- Node ss = *j;
+ int n_sel = (*sel_i).second;
+ for( int j=0; j<n_sel; j++ ){
+ Node ss = d_selector_apps_data[n][j];
if( s.getOperator()==ss.getOperator() && ( s.getKind()!=DT_HEIGHT_BOUND || s[1]==ss[1] ) ){
Trace("dt-collapse-sel") << "...redundant." << std::endl;
return;
}
}
//add it to the vector
- sel->push_back( s );
+ //sel->push_back( s );
+ d_selector_apps[n] = n_sel + 1;
+ if( n_sel<(int)d_selector_apps_data[n].size() ){
+ d_selector_apps_data[n][n_sel] = s;
+ }else{
+ d_selector_apps_data[n].push_back( s );
+ }
+
eqc->d_selectors = true;
}
if( assertFacts && !eqc->d_constructor.get().isNull() ){
Trace("datatypes-debug") << "Add constructor : " << c << " to eqc(" << n << ")" << std::endl;
Assert( eqc->d_constructor.get().isNull() );
//check labels
- NodeListMap::iterator lbl_i = d_labels.find( n );
+ NodeIntMap::iterator lbl_i = d_labels.find( n );
if( lbl_i != d_labels.end() ){
size_t constructorIndex = Datatype::indexOf(c.getOperator().toExpr());
- NodeList* lbl = (*lbl_i).second;
- for( NodeList::const_iterator i = lbl->begin(); i != lbl->end(); i++ ) {
- if( (*i).getKind()==NOT ){
- int tindex = DatatypesRewriter::isTester( (*i)[0] );
+ int n_lbl = (*lbl_i).second;
+ for( int i=0; i<n_lbl; i++ ){
+ Node t = d_labels_data[n][i];
+ if( t.getKind()==NOT ){
+ int tindex = DatatypesRewriter::isTester( t[0] );
Assert( tindex!=-1 );
if( tindex==(int)constructorIndex ){
- Node n = *i;
std::vector< TNode > assumptions;
- explain( *i, assumptions );
- explainEquality( c, (*i)[0][0], true, assumptions );
+ explain( t, assumptions );
+ explainEquality( c, t[0][0], true, assumptions );
d_conflictNode = mkAnd( assumptions );
Trace("dt-conflict") << "CONFLICT: Tester merge eq conflict : " << d_conflictNode << std::endl;
d_out->conflict( d_conflictNode );
}
}
//check selectors
- NodeListMap::iterator sel_i = d_selector_apps.find( n );
+ NodeIntMap::iterator sel_i = d_selector_apps.find( n );
if( sel_i != d_selector_apps.end() ){
- NodeList* sel = (*sel_i).second;
- for( NodeList::const_iterator j = sel->begin(); j != sel->end(); ++j ){
+ int n_sel = (*sel_i).second;
+ for( int j=0; j<n_sel; j++ ){
+ Node s = d_selector_apps_data[n][j];
//collapse the selector
- collapseSelector( *j, c );
+ collapseSelector( s, c );
}
}
eqc->d_constructor.set( c );
if( hasLabel( ei, eqc ) ){
Trace( c ) << getLabel( eqc );
}else{
- NodeListMap::iterator lbl_i = d_labels.find( eqc );
+ NodeIntMap::iterator lbl_i = d_labels.find( eqc );
if( lbl_i != d_labels.end() ){
- NodeList* lbl = (*lbl_i).second;
- for( NodeList::const_iterator j = lbl->begin(); j != lbl->end(); j++ ){
- Trace( c ) << *j << " ";
+ for( int j=0; j<(*lbl_i).second; j++ ){
+ Trace( c ) << d_labels_data[eqc][j] << " ";
}
}
}
Trace( c ) << std::endl;
Trace( c ) << " Selectors : " << ( ei->d_selectors ? "yes, " : "no " );
- NodeListMap::iterator sel_i = d_selector_apps.find( eqc );
+ NodeIntMap::iterator sel_i = d_selector_apps.find( eqc );
if( sel_i != d_selector_apps.end() ){
- NodeList* sel = (*sel_i).second;
- for( NodeList::const_iterator j = sel->begin(); j != sel->end(); j++ ){
- Trace( c ) << *j << " ";
+ for( int j=0; j<(*sel_i).second; j++ ){
+ Trace( c ) << d_selector_apps_data[eqc][j] << " ";
}
}
Trace( c ) << std::endl;
}
void EqualityInference::addToExplanationEqc( std::vector< Node >& exp, Node eqc ) {
- NodeListMap::iterator re_i = d_rep_exp.find( eqc );
+ NodeIntMap::iterator re_i = d_rep_exp.find( eqc );
if( re_i!=d_rep_exp.end() ){
- for( unsigned i=0; i<(*re_i).second->size(); i++ ){
- addToExplanation( exp, (*(*re_i).second)[i] );
+ for( int i=0; i<(*re_i).second; i++ ){
+ addToExplanation( exp, d_rep_exp_data[eqc][i] );
}
}
//for( unsigned i=0; i<d_eqci[n]->d_rep_exp.size(); i++ ){
}
void EqualityInference::addToExplanationEqc( Node eqc, std::vector< Node >& exp_to_add ) {
- NodeListMap::iterator re_i = d_rep_exp.find( eqc );
- NodeList* re;
+ NodeIntMap::iterator re_i = d_rep_exp.find( eqc );
+ int n_re = 0;
if( re_i != d_rep_exp.end() ){
- re = (*re_i).second;
- }else{
- re = new(d_c->getCMM()) NodeList( true, d_c, false, context::ContextMemoryAllocator<TNode>(d_c->getCMM()) );
- d_rep_exp.insertDataFromContextMemory( eqc, re );
+ n_re = (*re_i).second;
}
+ d_rep_exp[eqc] = n_re + exp_to_add.size();
for( unsigned i=0; i<exp_to_add.size(); i++ ){
- re->push_back( exp_to_add[i] );
+ if( n_re<(int)d_rep_exp_data[eqc].size() ){
+ d_rep_exp_data[eqc][n_re] = exp_to_add[i];
+ }else{
+ d_rep_exp_data[eqc].push_back( exp_to_add[i] );
+ }
+ n_re++;
}
//for( unsigned i=0; i<exp_to_add.size(); i++ ){
// eqci->d_rep_exp.push_back( exp_to_add[i] );
void EqualityInference::addToUseList( Node used, Node eqc ) {
#if 1
- NodeListMap::iterator ul_i = d_uselist.find( used );
- NodeList* ul;
+ NodeIntMap::iterator ul_i = d_uselist.find( used );
+ int n_ul = 0;
if( ul_i != d_uselist.end() ){
- ul = (*ul_i).second;
- }else{
- ul = new(d_c->getCMM()) NodeList( true, d_c, false, context::ContextMemoryAllocator<TNode>(d_c->getCMM()) );
- d_uselist.insertDataFromContextMemory( used, ul );
+ n_ul = (*ul_i).second;
}
+ d_uselist[ used ] = n_ul + 1;
Trace("eq-infer-debug") << " add to use list : " << used << " -> " << eqc << std::endl;
- (*ul).push_back( eqc );
+ if( n_ul<(int)d_uselist_data[used].size() ){
+ d_uselist_data[used][n_ul] = eqc;
+ }else{
+ d_uselist_data[used].push_back( eqc );
+ }
#else
std::map< Node, EqcInfo * >::iterator itu = d_eqci.find( used );
EqcInfo * eqci_used;
//go through all equivalence classes that may refer to v_solve
std::map< Node, bool > processed;
processed[v_solve] = true;
- NodeListMap::iterator ul_i = d_uselist.find( v_solve );
+ NodeIntMap::iterator ul_i = d_uselist.find( v_solve );
if( ul_i != d_uselist.end() ){
- NodeList* ul = (*ul_i).second;
- Trace("eq-infer-debug") << " use list size = " << ul->size() << std::endl;
- for( unsigned j=0; j<ul->size(); j++ ){
- Node r = (*ul)[j];
+ int n_ul = (*ul_i).second;
+ Trace("eq-infer-debug") << " use list size = " << n_ul << std::endl;
+ for( int j=0; j<n_ul; j++ ){
+ Node r = d_uselist_data[v_solve][j];
//Trace("eq-infer-debug") << " use list size = " << eqci_solved->d_uselist.size() << std::endl;
//for( unsigned j=0; j<eqci_solved->d_uselist.size(); j++ ){
// Node r = eqci_solved->d_uselist[j];