#include "expr/datatype.h"
#include "options/quantifiers_options.h"
+#include "smt/smt_engine.h"
+#include "smt/smt_engine_scope.h"
#include "theory/quantifiers/ce_guided_conjecture.h"
#include "theory/quantifiers/term_database_sygus.h"
#include "theory/quantifiers/term_util.h"
: d_dt(Datatype(type_name))
{
d_tn = src_tn;
+ d_t = src_tn.toType();
/* Create an unresolved type */
d_unres_t = NodeManager::currentNM()
->mkSort(type_name, ExprManager::SORT_FLAG_PLACEHOLDER)
std::string type_name = ss.str();
/* Add to global accumulators */
tos.push_back(TypeObject(tn, type_name));
- const Datatype& dt = static_cast<DatatypeType>(tn.toType()).getDatatype();
+ const Datatype& dt = static_cast<DatatypeType>(tos.back().d_t).getDatatype();
tn_to_unres[tn] = tos.back().d_unres_t;
/* Visit types of constructor arguments */
for (const DatatypeConstructor& cons : dt)
Node sygus_vars)
{
const Datatype& dt =
- static_cast<DatatypeType>(tos[ind].d_tn.toType()).getDatatype();
+ static_cast<DatatypeType>(tos[ind].d_t).getDatatype();
Trace("sygus-grammar-normalize")
<< "Normalizing integer type " << tos[ind].d_tn << " from datatype\n"
<< dt << std::endl;
for (unsigned i = 0, size = tos.size(); i < size; ++i)
{
const Datatype& dt =
- static_cast<DatatypeType>(tos[i].d_tn.toType()).getDatatype();
+ static_cast<DatatypeType>(tos[i].d_t).getDatatype();
Trace("sygus-grammar-normalize")
<< "Rebuild " << tos[i].d_tn << " from " << dt << std::endl;
/* Collect information to rebuild constructors */
<< "...for " << cons.getName() << std::endl;
/* Recover the sygus operator to not lose reference to the original
* operator (NOT, ITE, etc) */
- tos[i].d_ops.push_back(cons.getSygusOp());
+ Node exp_sop_n = Node::fromExpr(
+ smt::currentSmtEngine()->expandDefinitions(cons.getSygusOp()));
+ tos[i].d_ops.push_back(Rewriter::rewrite(exp_sop_n));
+ Trace("sygus-grammar-normalize")
+ << "\tOriginal op: " << cons.getSygusOp()
+ << "\n\tExpanded one: " << exp_sop_n
+ << "\n\tRewritten one: " << tos[i].d_ops.back() << std::endl;
tos[i].d_cons_names.push_back(cons.getName());
+ tos[i].d_pcb.push_back(cons.getSygusPrintCallback());
tos[i].d_cons_args_t.push_back(std::vector<Type>());
for (const DatatypeConstructorArg& arg : cons)
{
dt.getSygusAllowAll());
for (unsigned j = 0, size_d_ops = tos[i].d_ops.size(); j < size_d_ops; ++j)
{
- tos[i].d_dt.addSygusConstructor(
- tos[i].d_ops[j], tos[i].d_cons_names[j], tos[i].d_cons_args_t[j]);
+ tos[i].d_dt.addSygusConstructor(tos[i].d_ops[j].toExpr(),
+ tos[i].d_cons_names[j],
+ tos[i].d_cons_args_t[j],
+ tos[i].d_pcb[j]);
}
Trace("sygus-grammar-normalize")
<< "...built datatype " << tos[i].d_dt << std::endl;
/* The original typenode this TypeObject is built from */
TypeNode d_tn;
+ /* The type represented by d_tn */
+ Type d_t;
/* Operators for each constructor. */
- std::vector<Expr> d_ops;
+ std::vector<Node> d_ops;
/* Names for each constructor. */
std::vector<std::string> d_cons_names;
+ /* Print callbacks for each constructor */
+ std::vector<std::shared_ptr<SygusPrintCallback>> d_pcb;
/* List of argument types for each constructor */
std::vector<std::vector<Type>> d_cons_args_t;
/* Unresolved type placeholder */