Trace("ambqi-check-debug2") << "Construct compose..." << std::endl;\r
std::vector< unsigned > entry;\r
std::vector< bool > entry_def;\r
- if( f ){\r
+ if( f && varChCount>0 ){\r
AbsDef unorm;\r
unorm.construct_compose( m, q, n, f, children, bchildren, vchildren, entry, entry_def );\r
//normalize\r
}else{\r
construct_compose( m, q, n, f, children, bchildren, vchildren, entry, entry_def );\r
}\r
+ Assert( is_normalized() );\r
+ //if( !is_normalized() ){\r
+ // std::cout << "NON NORMALIZED DEFINITION" << std::endl;\r
+ // exit( 10 );\r
+ //}\r
return true;\r
}else if( varChCount==1 && n.getKind()==EQUAL ){\r
Trace("ambqi-check-debug2") << "Expand variable child..." << std::endl;\r
}\r
}\r
\r
+void AbsDef::negate() {\r
+ for( std::map< unsigned, AbsDef >::iterator it = d_def.begin(); it != d_def.end(); ++it ){\r
+ it->second.negate();\r
+ }\r
+ if( d_value==0 ){\r
+ d_value = 1;\r
+ }else if( d_value==1 ){\r
+ d_value = 0;\r
+ }\r
+}\r
+\r
Node AbsDef::getFunctionValue( FirstOrderModelAbs * m, TNode op, std::vector< Node >& vars, unsigned depth ) {\r
if( depth==vars.size() ){\r
TypeNode tn = op.getType();\r
}\r
}\r
\r
+bool AbsDef::is_normalized() {\r
+ for( std::map< unsigned, AbsDef >::iterator it1 = d_def.begin(); it1 != d_def.end(); ++it1 ){\r
+ if( !it1->second.is_normalized() ){\r
+ return false;\r
+ }\r
+ for( std::map< unsigned, AbsDef >::iterator it2 = d_def.begin(); it2 != d_def.end(); ++it2 ){\r
+ if( it1->first!=it2->first && (( it1->first & it2->first )!=0) ){\r
+ return false;\r
+ }\r
+ }\r
+ }\r
+ return true;\r
+}\r
+\r
AbsMbqiBuilder::AbsMbqiBuilder( context::Context* c, QuantifiersEngine* qe ) :\r
QModelBuilder( c, qe ){\r
d_true = NodeManager::currentNM()->mkConst( true );\r
\r
bool AbsMbqiBuilder::doCheck( FirstOrderModelAbs * m, TNode q, AbsDef & ad, TNode n ) {\r
Assert( n.getKind()!=FORALL );\r
- std::map< unsigned, AbsDef > children;\r
- std::map< unsigned, int > bchildren;\r
- std::map< unsigned, int > vchildren;\r
- int varChCount = 0;\r
- for( unsigned i=0; i<n.getNumChildren(); i++ ){\r
- if( n[i].getKind()==FORALL ){\r
- bchildren[i] = AbsDef::val_unk;\r
- }else if( n[i].getKind() == BOUND_VARIABLE ){\r
- varChCount++;\r
- vchildren[i] = m->getVariableId( q, n[i] );\r
- }else if( m->hasTerm( n[i] ) ){\r
- bchildren[i] = m->getRepresentativeId( n[i] );\r
- }else{\r
- if( !doCheck( m, q, children[i], n[i] ) ){\r
+ if( n.getKind()==NOT ){\r
+ doCheck( m, q, ad, n[0] );\r
+ ad.negate();\r
+ return true;\r
+ }else{\r
+ std::map< unsigned, AbsDef > children;\r
+ std::map< unsigned, int > bchildren;\r
+ std::map< unsigned, int > vchildren;\r
+ int varChCount = 0;\r
+ for( unsigned i=0; i<n.getNumChildren(); i++ ){\r
+ if( n[i].getKind()==FORALL ){\r
bchildren[i] = AbsDef::val_unk;\r
- children.erase( i );\r
+ }else if( n[i].getKind() == BOUND_VARIABLE ){\r
+ varChCount++;\r
+ vchildren[i] = m->getVariableId( q, n[i] );\r
+ }else if( m->hasTerm( n[i] ) ){\r
+ bchildren[i] = m->getRepresentativeId( n[i] );\r
+ }else{\r
+ if( !doCheck( m, q, children[i], n[i] ) ){\r
+ bchildren[i] = AbsDef::val_unk;\r
+ children.erase( i );\r
+ }\r
}\r
}\r
- }\r
- //convert to pointers\r
- std::map< unsigned, AbsDef * > pchildren;\r
- for( std::map< unsigned, AbsDef >::iterator it = children.begin(); it != children.end(); ++it ){\r
- pchildren[it->first] = &it->second;\r
- }\r
- //construct the interpretation\r
- Trace("ambqi-check-debug") << "Compute Interpretation of " << n << " " << n.getKind() << std::endl;\r
- if( n.getKind() == APPLY_UF || n.getKind() == VARIABLE || n.getKind() == SKOLEM ){\r
- Node op;\r
- if( n.getKind() == APPLY_UF ){\r
- op = n.getOperator();\r
- }else{\r
- op = n;\r
+ //convert to pointers\r
+ std::map< unsigned, AbsDef * > pchildren;\r
+ for( std::map< unsigned, AbsDef >::iterator it = children.begin(); it != children.end(); ++it ){\r
+ pchildren[it->first] = &it->second;\r
}\r
- //uninterpreted compose\r
- if( m->d_models_valid[op] ){\r
- ad.construct( m, q, n, m->d_models[op], pchildren, bchildren, vchildren, varChCount );\r
- }else{\r
- Trace("ambqi-check-debug") << "** Cannot produce interpretation for " << n << " (no function model)" << std::endl;\r
+ //construct the interpretation\r
+ Trace("ambqi-check-debug") << "Compute Interpretation of " << n << " " << n.getKind() << std::endl;\r
+ if( n.getKind() == APPLY_UF || n.getKind() == VARIABLE || n.getKind() == SKOLEM ){\r
+ Node op;\r
+ if( n.getKind() == APPLY_UF ){\r
+ op = n.getOperator();\r
+ }else{\r
+ op = n;\r
+ }\r
+ //uninterpreted compose\r
+ if( m->d_models_valid[op] ){\r
+ ad.construct( m, q, n, m->d_models[op], pchildren, bchildren, vchildren, varChCount );\r
+ }else{\r
+ Trace("ambqi-check-debug") << "** Cannot produce interpretation for " << n << " (no function model)" << std::endl;\r
+ return false;\r
+ }\r
+ }else if( !ad.construct( m, q, n, NULL, pchildren, bchildren, vchildren, varChCount ) ){\r
+ Trace("ambqi-check-debug") << "** Cannot produce interpretation for " << n << " (variables are children of interpreted symbol)" << std::endl;\r
return false;\r
}\r
- }else if( !ad.construct( m, q, n, NULL, pchildren, bchildren, vchildren, varChCount ) ){\r
- Trace("ambqi-check-debug") << "** Cannot produce interpretation for " << n << " (variables are children of interpreted symbol)" << std::endl;\r
- return false;\r
+ Trace("ambqi-check-try") << "Interpretation for " << n << " is : " << std::endl;\r
+ ad.debugPrint("ambqi-check-try", m, q[0] );\r
+ ad.simplify( m, q[0] );\r
+ Trace("ambqi-check-debug") << "(Simplified) Interpretation for " << n << " is : " << std::endl;\r
+ ad.debugPrint("ambqi-check-debug", m, q[0] );\r
+ Trace("ambqi-check-debug") << std::endl;\r
+ return true;\r
}\r
- Trace("ambqi-check-try") << "Interpretation for " << n << " is : " << std::endl;\r
- ad.debugPrint("ambqi-check-try", m, q[0] );\r
- ad.simplify( m, q[0] );\r
- Trace("ambqi-check-debug") << "(Simplified) Interpretation for " << n << " is : " << std::endl;\r
- ad.debugPrint("ambqi-check-debug", m, q[0] );\r
- Trace("ambqi-check-debug") << std::endl;\r
- return true;\r
}\r