theory/quantifiers/conjecture_generator.cpp \
theory/quantifiers/ce_guided_instantiation.h \
theory/quantifiers/ce_guided_instantiation.cpp \
+ theory/quantifiers/fun_def_process.h \
+ theory/quantifiers/fun_def_process.cpp \
theory/quantifiers/options_handlers.h \
theory/arith/theory_arith_type_rules.h \
theory/arith/type_enumerator.h \
PARSER_STATE->warning(ss.str());
}
// do nothing
- } else if(attr==":axiom" || attr==":conjecture" || attr==":sygus" || attr==":synthesis") {
+ } else if(attr==":axiom" || attr==":conjecture" || attr==":fun-def" || attr==":sygus" || attr==":synthesis") {
if(hasValue) {
std::stringstream ss;
ss << "warning: Attribute " << attr << " does not take a value (ignoring)";
PARSER_STATE->warning(ss.str());
}
- std::string attr_name = attr;
- attr_name.erase( attr_name.begin() );
- //will set the attribute on auxiliary var (preserves attribute on formula through rewriting)
- Type t = EXPR_MANAGER->booleanType();
- Expr avar = PARSER_STATE->mkVar(attr_name, t);
- retExpr = MK_EXPR(kind::INST_ATTRIBUTE, avar);
- Command* c = new SetUserAttributeCommand( attr_name, avar );
- c->setMuted(true);
- PARSER_STATE->preemptCommand(c);
+ bool success = true;
+ if( attr==":fun-def" ){
+ if( ( expr.getKind()!=kind::EQUAL && expr.getKind()!=kind::IFF ) || expr[0].getKind()!=kind::APPLY_UF ){
+ success = false;
+ }else{
+ for( unsigned i=0; i<expr[0].getNumChildren(); i++ ){
+ if( expr[0][i].getKind()!=kind::BOUND_VARIABLE ){
+ success = false;
+ }
+ }
+ }
+ if( !success ){
+ std::stringstream ss;
+ ss << "warning: Function definition should be an equality whose LHS is an uninterpreted function applied to variables.";
+ PARSER_STATE->warning(ss.str());
+ }
+ }
+ if( success ){
+ std::string attr_name = attr;
+ attr_name.erase( attr_name.begin() );
+ //will set the attribute on auxiliary var (preserves attribute on formula through rewriting)
+ Type t = EXPR_MANAGER->booleanType();
+ Expr avar = PARSER_STATE->mkVar(attr_name, t);
+ retExpr = MK_EXPR(kind::INST_ATTRIBUTE, avar);
+ Command* c = new SetUserAttributeCommand( attr_name, avar );
+ c->setMuted(true);
+ PARSER_STATE->preemptCommand(c);
+ }
} else {
PARSER_STATE->attributeNotSupported(attr);
}
--- /dev/null
+/********************* */
+/*! \file fun_def_process.cpp
+ ** \verbatim
+ ** Original author: Andrew Reynolds
+ ** Major contributors: Morgan Deters
+ ** Minor contributors (to current version): Kshitij Bansal
+ ** This file is part of the CVC4 project.
+ ** Copyright (c) 2009-2014 New York University and The University of Iowa
+ ** See the file COPYING in the top-level source directory for licensing
+ ** information.\endverbatim
+ **
+ ** \brief Sort inference module
+ **
+ ** This class implements pre-process steps for well-defined functions
+ **/
+
+#include <vector>
+
+#include "theory/quantifiers/fun_def_process.h"
+#include "theory/rewriter.h"
+
+using namespace CVC4;
+using namespace std;
+using namespace CVC4::theory;
+using namespace CVC4::theory::quantifiers;
+using namespace CVC4::kind;
+
+
+void FunDefFmf::simplify( std::vector< Node >& assertions, bool doRewrite ) {
+
+}
--- /dev/null
+/********************* */
+/*! \file fun_def_process.h
+ ** \verbatim
+ ** Original author: Andrew Reynolds
+ ** Major contributors: Morgan Deters
+ ** Minor contributors (to current version): none
+ ** This file is part of the CVC4 project.
+ ** Copyright (c) 2009-2014 New York University and The University of Iowa
+ ** See the file COPYING in the top-level source directory for licensing
+ ** information.\endverbatim
+ **
+ ** \brief Pre-process steps for well-defined functions
+ **/
+
+#include "cvc4_private.h"
+
+#ifndef __CVC4__QUANTIFIERS_FUN_DEF_PROCESS_H
+#define __CVC4__QUANTIFIERS_FUN_DEF_PROCESS_H
+
+#include <iostream>
+#include <string>
+#include <vector>
+#include <map>
+#include "expr/node.h"
+#include "expr/type_node.h"
+
+namespace CVC4 {
+namespace theory {
+namespace quantifiers {
+
+//find finite models for well-defined functions
+class FunDefFmf {
+public:
+ FunDefFmf(){}
+ ~FunDefFmf(){}
+
+ void simplify( std::vector< Node >& assertions, bool doRewrite = false );
+};
+
+
+}
+}
+}
+
+#endif
d_patTerms[0][f].clear();
d_patTerms[1][f].clear();
std::vector< Node > patTermsF;
- Trigger::collectPatTerms( d_quantEngine, f, d_quantEngine->getTermDatabase()->getInstConstantBody( f ), patTermsF, d_tr_strategy, d_user_no_gen[f], true );
+ if( d_quantEngine->getTermDatabase()->isQAttrFunDef( f ) && options::quantFunWellDefined() ){
+ Node bd = d_quantEngine->getTermDatabase()->getInstConstantBody( f );
+ Assert( bd.getKind()==EQUAL || bd.getKind()==IFF );
+ Assert( bd[0].getKind()==APPLY_UF );
+ patTermsF.push_back( bd[0] );
+ }else{
+ Trigger::collectPatTerms( d_quantEngine, f, d_quantEngine->getTermDatabase()->getInstConstantBody( f ), patTermsF, d_tr_strategy, d_user_no_gen[f], true );
+ }
Trace("auto-gen-trigger") << "Collected pat terms for " << d_quantEngine->getTermDatabase()->getInstConstantBody( f ) << ", no-patterns : " << d_user_no_gen[f].size() << std::endl;
Trace("auto-gen-trigger") << " ";
for( int i=0; i<(int)patTermsF.size(); i++ ){
option triggerSelMode --trigger-sel CVC4::theory::quantifiers::TriggerSelMode :default CVC4::theory::quantifiers::TRIGGER_SEL_DEFAULT :read-write :include "theory/quantifiers/modes.h" :handler CVC4::theory::quantifiers::stringToTriggerSelMode :handler-include "theory/quantifiers/options_handlers.h"
selection mode for triggers
+option quantFunWellDefined --quant-fun-wd bool :default false
+ assume that function defined by quantifiers are well defined
+
# Whether to consider terms in the bodies of quantifiers for matching
option registerQuantBodyTerms --register-quant-body-terms bool :default false
consider ground terms within bodies of quantified formulas for matching
Trace("quant-attr-debug") << "Set conjecture " << n << std::endl;
ConjectureAttribute ca;
n.setAttribute( ca, true );
+ }else if( attr=="fun-def" ){
+ Trace("quant-attr-debug") << "Set function definition " << n << std::endl;
+ FunDefAttribute fda;
+ n.setAttribute( fda, true );
}else if( attr=="sygus" ){
Trace("quant-attr-debug") << "Set sygus " << n << std::endl;
SygusAttribute ca;
Trace("quant-attr") << "Attribute : conjecture : " << q << std::endl;
d_qattr_conjecture[q] = true;
}
+ if( avar.getAttribute(FunDefAttribute()) ){
+ Trace("quant-attr") << "Attribute : function definition : " << q << std::endl;
+ d_qattr_fundef[q] = true;
+ }
if( avar.getAttribute(SygusAttribute()) ){
//should be nested existential
Assert( q[1].getKind()==NOT );
}
}
+bool TermDb::isQAttrFunDef( Node q ) {
+ std::map< Node, bool >::iterator it = d_qattr_fundef.find( q );
+ if( it==d_qattr_fundef.end() ){
+ return false;
+ }else{
+ return it->second;
+ }
+}
+
bool TermDb::isQAttrSygus( Node q ) {
std::map< Node, bool >::iterator it = d_qattr_sygus.find( q );
if( it==d_qattr_sygus.end() ){
struct ConjectureAttributeId {};
typedef expr::Attribute< ConjectureAttributeId, bool > ConjectureAttribute;
+/** Attribute true for function definition quantifiers */
+struct FunDefAttributeId {};
+typedef expr::Attribute< FunDefAttributeId, bool > FunDefAttribute;
+
/** Attribute true for quantifiers that are SyGus conjectures */
struct SygusAttributeId {};
typedef expr::Attribute< SygusAttributeId, bool > SygusAttribute;
private:
std::map< Node, bool > d_qattr_conjecture;
std::map< Node, bool > d_qattr_axiom;
+ std::map< Node, bool > d_qattr_fundef;
std::map< Node, bool > d_qattr_sygus;
std::map< Node, bool > d_qattr_synthesis;
std::map< Node, int > d_qattr_rr_priority;
bool isQAttrConjecture( Node q );
/** is axiom */
bool isQAttrAxiom( Node q );
+ /** is function definition */
+ bool isQAttrFunDef( Node q );
/** is sygus conjecture */
bool isQAttrSygus( Node q );
/** is synthesis conjecture */
d_baseDecLevel = -1;
out.handleUserAttribute( "axiom", this );
out.handleUserAttribute( "conjecture", this );
+ out.handleUserAttribute( "fun-def", this );
out.handleUserAttribute( "sygus", this );
out.handleUserAttribute( "synthesis", this );
out.handleUserAttribute( "quant-inst-max-level", this );