if( validRegionIndex!=-1 ){
combineRegions( validRegionIndex, i );
if( addSplit( d_regions[validRegionIndex], out )!=0 ){
+ Trace("uf-ss-debug") << "Minimize model : combined regions, found split. " << std::endl;
return false;
}
}else{
}
}
}
+ Assert( validRegionIndex!=-1 );
if( addSplit( d_regions[validRegionIndex], out )!=0 ){
+ Trace("uf-ss-debug") << "Minimize model : found split. " << std::endl;
return false;
}
+ Trace("uf-ss-debug") << "Minimize success. " << std::endl;
}
}
return true;
StrongSolverTheoryUF::StrongSolverTheoryUF(context::Context* c, context::UserContext* u, OutputChannel& out, TheoryUF* th) :
d_out( &out ), d_th( th ), d_conflict( c, false ), d_rep_model(), d_aloc_com_card( u, 0 ), d_com_card_assertions( c ),
-d_card_assertions_eqv_lemma( u )
+d_card_assertions_eqv_lemma( u ), d_rel_eqc( c )
{
if( options::ufssDiseqPropagation() ){
d_deq_prop = new DisequalityPropagator( th->getQuantifiersEngine(), this );
return d_th->getOutputChannel();
}
+/** ensure eqc */
+void StrongSolverTheoryUF::ensureEqc( SortModel* c, Node a ) {
+ if( !hasEqc( a ) ){
+ d_rel_eqc[a] = true;
+ Trace("uf-ss-solver") << "StrongSolverTheoryUF: New eq class " << a << " : " << a.getType() << std::endl;
+ c->newEqClass( a );
+ if( options::ufssSymBreak() ){
+ d_sym_break->newEqClass( a );
+ }
+ Trace("uf-ss-solver") << "StrongSolverTheoryUF: Done New eq class." << std::endl;
+ }
+}
+
+void StrongSolverTheoryUF::ensureEqcRec( Node n ) {
+ if( !hasEqc( n ) ){
+ SortModel* c = getSortModel( n );
+ if( c ){
+ ensureEqc( c, n );
+ }
+ for( unsigned i=0; i<n.getNumChildren(); i++ ){
+ ensureEqcRec( n[i] );
+ }
+ }
+}
+
+/** has eqc */
+bool StrongSolverTheoryUF::hasEqc( Node a ) {
+ return d_rel_eqc.find( a )!=d_rel_eqc.end() && d_rel_eqc[a];
+}
+
/** new node */
void StrongSolverTheoryUF::newEqClass( Node n ){
SortModel* c = getSortModel( n );
if( c ){
- Trace("uf-ss-solver") << "StrongSolverTheoryUF: New eq class " << n << " : " << n.getType() << std::endl;
- c->newEqClass( n );
- if( options::ufssSymBreak() ){
- d_sym_break->newEqClass( n );
- }
- Trace("uf-ss-solver") << "StrongSolverTheoryUF: Done New eq class." << std::endl;
+ //do nothing
}
}
/** merge */
void StrongSolverTheoryUF::merge( Node a, Node b ){
+ //TODO: ensure they are relevant
SortModel* c = getSortModel( a );
if( c ){
- Trace("uf-ss-solver") << "StrongSolverTheoryUF: Merge " << a << " " << b << " : " << a.getType() << std::endl;
- c->merge( a, b );
- Trace("uf-ss-solver") << "StrongSolverTheoryUF: Done Merge." << std::endl;
+ ensureEqc( c, a );
+ if( hasEqc( b ) ){
+ Trace("uf-ss-solver") << "StrongSolverTheoryUF: Merge " << a << " " << b << " : " << a.getType() << std::endl;
+ c->merge( a, b );
+ Trace("uf-ss-solver") << "StrongSolverTheoryUF: Done Merge." << std::endl;
+ }else{
+ //c->assignEqClass( b, a );
+ d_rel_eqc[b] = true;
+ }
}else{
if( options::ufssDiseqPropagation() ){
d_deq_prop->merge(a, b);
void StrongSolverTheoryUF::assertDisequal( Node a, Node b, Node reason ){
SortModel* c = getSortModel( a );
if( c ){
+ ensureEqc( c, a );
+ ensureEqc( c, b );
Trace("uf-ss-solver") << "StrongSolverTheoryUF: Assert disequal " << a << " " << b << " : " << a.getType() << std::endl;
//Assert( d_th->d_equalityEngine.getRepresentative( a )==a );
//Assert( d_th->d_equalityEngine.getRepresentative( b )==b );
/** assert a node */
void StrongSolverTheoryUF::assertNode( Node n, bool isDecision ){
Trace("uf-ss") << "Assert " << n << " " << isDecision << std::endl;
+ ensureEqcRec( n );
bool polarity = n.getKind() != kind::NOT;
TNode lit = polarity ? n : n[0];
if( lit.getKind()==CARDINALITY_CONSTRAINT ){