DeclareFunctionCommand::DeclareFunctionCommand(const std::string& id, Expr func, Type t) throw() :
DeclarationDefinitionCommand(id),
d_func(func),
- d_type(t) {
+ d_type(t),
+ d_printInModel(true),
+ d_printInModelSetByUser(false){
}
Expr DeclareFunctionCommand::getFunction() const throw() {
return d_type;
}
+bool DeclareFunctionCommand::getPrintInModel() const throw() {
+ return d_printInModel;
+}
+
+bool DeclareFunctionCommand::getPrintInModelSetByUser() const throw() {
+ return d_printInModelSetByUser;
+}
+
+void DeclareFunctionCommand::setPrintInModel( bool p ) {
+ d_printInModel = p;
+ d_printInModelSetByUser = true;
+}
+
void DeclareFunctionCommand::invoke(SmtEngine* smtEngine) throw() {
d_commandStatus = CommandSuccess::instance();
}
Command* DeclareFunctionCommand::exportTo(ExprManager* exprManager,
ExprManagerMapCollection& variableMap) {
- return new DeclareFunctionCommand(d_symbol, d_func.exportTo(exprManager, variableMap),
- d_type.exportTo(exprManager, variableMap));
+ DeclareFunctionCommand * dfc = new DeclareFunctionCommand(d_symbol, d_func.exportTo(exprManager, variableMap),
+ d_type.exportTo(exprManager, variableMap));
+ dfc->d_printInModel = d_printInModel;
+ dfc->d_printInModelSetByUser = d_printInModelSetByUser;
+ return dfc;
}
Command* DeclareFunctionCommand::clone() const {
- return new DeclareFunctionCommand(d_symbol, d_func, d_type);
+ DeclareFunctionCommand * dfc = new DeclareFunctionCommand(d_symbol, d_func, d_type);
+ dfc->d_printInModel = d_printInModel;
+ dfc->d_printInModelSetByUser = d_printInModelSetByUser;
+ return dfc;
}
std::string DeclareFunctionCommand::getCommandName() const throw() {
protected:
Expr d_func;
Type d_type;
+ bool d_printInModel;
+ bool d_printInModelSetByUser;
public:
DeclareFunctionCommand(const std::string& id, Expr func, Type type) throw();
~DeclareFunctionCommand() throw() {}
Expr getFunction() const throw();
Type getType() const throw();
+ bool getPrintInModel() const throw();
+ bool getPrintInModelSetByUser() const throw();
+ void setPrintInModel( bool p );
void invoke(SmtEngine* smtEngine) throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
Command* clone() const;
}
}
} else if(dynamic_cast<const DeclareFunctionCommand*>(c) != NULL) {
- Node n = Node::fromExpr( ((const DeclareFunctionCommand*)c)->getFunction() );
- if(n.getKind() == kind::SKOLEM) {
+ const DeclareFunctionCommand* dfc = (const DeclareFunctionCommand*)c;
+ Node n = Node::fromExpr( dfc->getFunction() );
+ if(dfc->getPrintInModelSetByUser()){
+ if(!dfc->getPrintInModel()){
+ return;
+ }
+ }else if(n.getKind() == kind::SKOLEM) {
// don't print out internal stuff
return;
}
if( options::sortInference() ){
//sort inference technique
- d_smt.d_theoryEngine->getSortInference()->simplify( d_assertionsToPreprocess );
+ SortInference * si = d_smt.d_theoryEngine->getSortInference();
+ si->simplify( d_assertionsToPreprocess );
+ for( std::map< Node, Node >::iterator it = si->d_model_replace_f.begin(); it != si->d_model_replace_f.end(); ++it ){
+ d_smt.setPrintFuncInModel( it->first, false );
+ d_smt.setPrintFuncInModel( it->second, true );
+ }
}
//if( options::quantConflictFind() ){
d_theoryEngine->setUserAttribute(attr, expr.getNode());
}
+void SmtEngine::setPrintFuncInModel( Node f, bool p ) {
+ Trace("setp-model") << "Set printInModel " << f << " to " << p << std::endl;
+ Expr fe = f.toExpr();
+ for( unsigned i=0; i<d_modelGlobalCommands.size(); i++ ){
+ Command * c = d_modelGlobalCommands[i];
+ DeclareFunctionCommand* dfc = dynamic_cast<DeclareFunctionCommand*>(c);
+ if(dfc != NULL) {
+ if( dfc->getFunction()==fe ){
+ dfc->setPrintInModel( p );
+ }
+ }
+ }
+ for( unsigned i=0; i<d_modelCommands->size(); i++ ){
+ Command * c = (*d_modelCommands)[i];
+ DeclareFunctionCommand* dfc = dynamic_cast<DeclareFunctionCommand*>(c);
+ if(dfc != NULL) {
+ if( dfc->getFunction()==fe ){
+ dfc->setPrintInModel( p );
+ }
+ }
+ }
+}
+
}/* CVC4 namespace */
*/
void setUserAttribute(const std::string& attr, Expr expr);
+ /**
+ * Set print function in model
+ */
+ void setPrintFuncInModel( Node f, bool p );
+
};/* class SmtEngine */
}/* CVC4 namespace */
ss << "io_" << op;
TypeNode typ = NodeManager::currentNM()->mkFunctionType( argTypes, retType );
d_symbol_map[op] = NodeManager::currentNM()->mkSkolem( ss.str(), typ, "op created during sort inference" );
+ Trace("setp-model") << "Function " << op << " is replaced with " << d_symbol_map[op] << std::endl;
+ d_model_replace_f[op] = d_symbol_map[op];
}else{
d_symbol_map[op] = op;
}
namespace CVC4 {
-class SortInference{
+class SortInference {
private:
//all subsorts
std::vector< int > d_sub_sorts;
void printSort( const char* c, int t );
//process
int process( Node n, std::map< Node, Node >& var_bound );
-
//for monotonicity inference
private:
void processMonotonic( Node n, bool pol, bool hasPol, std::map< Node, Node >& var_bound );
bool isWellSorted( Node n );
//get constraints for being well-typed according to computed sub-types
void getSortConstraints( Node n, SortInference::UnionFind& uf );
+public:
+ //list of all functions and the uninterpreted symbols they were replaced with
+ std::map< Node, Node > d_model_replace_f;
};
}