}
return nm->mkNode(kind::FORALL, qchildren);
}
-
+
Node CegGrammarConstructor::convertToEmbedding( Node n, std::map< Node, Node >& synth_fun_vars ){
std::unordered_map<TNode, Node, TNodeHashFunction> visited;
std::unordered_map<TNode, Node, TNodeHashFunction>::iterator it;
Trace("sygus-grammar-def") << "Make grammar for " << types[i] << " " << unres_types[i] << std::endl;
std::vector<std::string> cnames;
std::vector<std::vector<CVC4::Type> > cargs;
+ /* Print callbacks for each constructor */
+ std::vector<std::shared_ptr<SygusPrintCallback>> pcs;
+ /* Weights for each constructor */
+ std::vector<int> weights;
Type unres_t = unres_types[i];
//add variables
for( unsigned j=0; j<sygus_vars.size(); j++ ){
ops[i].push_back( sygus_vars[j].toExpr() );
cnames.push_back( ss.str() );
cargs.push_back( std::vector< CVC4::Type >() );
+ pcs.push_back(nullptr);
+ weights.push_back(-1);
}
}
//add constants
ops[i].push_back( consts[j].toExpr() );
cnames.push_back( ss.str() );
cargs.push_back( std::vector< CVC4::Type >() );
+ pcs.push_back(nullptr);
+ weights.push_back(-1);
}
//ITE
CVC4::Kind k = kind::ITE;
cargs.back().push_back(unres_bt);
cargs.back().push_back(unres_t);
cargs.back().push_back(unres_t);
+ pcs.push_back(nullptr);
+ weights.push_back(-1);
if (types[i].isReal())
{
cargs.push_back(std::vector<CVC4::Type>());
cargs.back().push_back(unres_t);
cargs.back().push_back(unres_t);
+ pcs.push_back(nullptr);
+ weights.push_back(-1);
}
if (!types[i].isInteger())
{
cargs.push_back(std::vector<Type>());
cargs.back().push_back(unres_t);
cargs.back().push_back(unres_pos_int_t);
+ pcs.push_back(nullptr);
+ weights.push_back(-1);
}
}else if( types[i].isDatatype() ){
Trace("sygus-grammar-def") << "...add for constructors" << std::endl;
//Assert( type_to_unres.find(crange)!=type_to_unres.end() );
cargs.back().push_back( type_to_unres[crange] );
}
+ pcs.push_back(nullptr);
+ weights.push_back(-1);
}
}else{
std::stringstream sserr;
cargs.push_back( std::vector< CVC4::Type >() );
//Assert( type_to_unres.find(arg_type)!=type_to_unres.end() );
cargs.back().push_back( type_to_unres[arg_type] );
+ pcs.push_back(nullptr);
+ weights.push_back(-1);
}
}
Trace("sygus-grammar-def") << "...make datatype " << datatypes[i] << std::endl;
|| std::find(itexc->second.begin(), itexc->second.end(), opn)
== itexc->second.end())
{
- datatypes[i].addSygusConstructor(ops[i][j], cnames[j], cargs[j]);
+ datatypes[i].addSygusConstructor(
+ ops[i][j], cnames[j], cargs[j], pcs[j], weights[j]);
}
}
Trace("sygus-grammar-def")
ops.push_back(std::vector<Expr>());
std::vector<std::string> cnames;
std::vector<std::vector< Type > > cargs;
+ /* Print callbacks for each constructor */
+ std::vector<std::shared_ptr<SygusPrintCallback>> pcs;
+ /* Weights for each constructor */
+ std::vector<int> weights;
Trace("sygus-grammar-def") << "Make grammar for " << btype << " " << datatypes.back() << std::endl;
//add variables
for( unsigned i=0; i<sygus_vars.size(); i++ ){
ops.back().push_back( sygus_vars[i].toExpr() );
cnames.push_back( ss.str() );
cargs.push_back( std::vector< CVC4::Type >() );
+ pcs.push_back(nullptr);
+ weights.push_back(1);
}
}
//add constants
ops.back().push_back(consts[j].toExpr());
cnames.push_back(ss.str());
cargs.push_back(std::vector<CVC4::Type>());
+ pcs.push_back(nullptr);
+ weights.push_back(-1);
}
//add operators
for (unsigned i = 0; i < 4; i++)
cargs.back().push_back(unres_bt);
}
}
+ pcs.push_back(nullptr);
+ weights.push_back(-1);
}
//add predicates for types
for( unsigned i=0; i<types.size(); i++ ){
cargs.push_back( std::vector< CVC4::Type >() );
cargs.back().push_back(unres_types[i]);
cargs.back().push_back(unres_types[i]);
+ pcs.push_back(nullptr);
+ weights.push_back(-1);
//type specific predicates
if (types[i].isReal())
{
cargs.push_back( std::vector< CVC4::Type >() );
cargs.back().push_back(unres_types[i]);
cargs.back().push_back(unres_types[i]);
+ pcs.push_back(nullptr);
+ weights.push_back(-1);
}else if( types[i].isDatatype() ){
//add for testers
Trace("sygus-grammar-def") << "...add for testers" << std::endl;
cnames.push_back(dt[k].getTesterName());
cargs.push_back( std::vector< CVC4::Type >() );
cargs.back().push_back(unres_types[i]);
+ pcs.push_back(nullptr);
+ weights.push_back(-1);
}
}
}
Trace("sygus-grammar-def") << "...make datatype " << datatypes.back() << std::endl;
datatypes.back().setSygus( btype.toType(), bvl.toExpr(), true, true );
for( unsigned j=0; j<ops.back().size(); j++ ){
- datatypes.back().addSygusConstructor( ops.back()[j], cnames[j], cargs[j] );
+ datatypes.back().addSygusConstructor(
+ ops.back()[j], cnames[j], cargs[j], pcs[j], weights[j]);
}
//sorts.push_back( btype );
Trace("sygus-grammar-def") << "...finished make default grammar for " << fun << " " << range << std::endl;
-
+
if( startIndex>0 ){
CVC4::Datatype tmp_dt = datatypes[0];
datatypes[0] = datatypes[startIndex];
return TypeNode::fromType( types[0] );
}
-TypeNode CegGrammarConstructor::mkSygusTemplateTypeRec( Node templ, Node templ_arg, TypeNode templ_arg_sygus_type, Node bvl,
+TypeNode CegGrammarConstructor::mkSygusTemplateTypeRec( Node templ, Node templ_arg, TypeNode templ_arg_sygus_type, Node bvl,
const std::string& fun, unsigned& tcount ) {
if( templ==templ_arg ){
//Assert( templ_arg.getType()==sygusToBuiltinType( templ_arg_sygus_type ) );
}
}
-TypeNode CegGrammarConstructor::mkSygusTemplateType( Node templ, Node templ_arg, TypeNode templ_arg_sygus_type, Node bvl,
+TypeNode CegGrammarConstructor::mkSygusTemplateType( Node templ, Node templ_arg, TypeNode templ_arg_sygus_type, Node bvl,
const std::string& fun ) {
unsigned tcount = 0;
return mkSygusTemplateTypeRec( templ, templ_arg, templ_arg_sygus_type, bvl, fun, tcount );