return n;
}
+Node DatatypesRewriter::expandApplySelector(Node n)
+{
+ Assert(n.getKind() == APPLY_SELECTOR);
+ Node selector = n.getOperator();
+ // APPLY_SELECTOR always applies to an external selector, cindexOf is
+ // legal here
+ size_t cindex = utils::cindexOf(selector);
+ const DType& dt = utils::datatypeOf(selector);
+ const DTypeConstructor& c = dt[cindex];
+ Node selector_use;
+ TypeNode ndt = n[0].getType();
+ if (options::dtSharedSelectors())
+ {
+ size_t selectorIndex = utils::indexOf(selector);
+ Trace("dt-expand") << "...selector index = " << selectorIndex << std::endl;
+ Assert(selectorIndex < c.getNumArgs());
+ selector_use = c.getSelectorInternal(ndt, selectorIndex);
+ }
+ else
+ {
+ selector_use = selector;
+ }
+ NodeManager* nm = NodeManager::currentNM();
+ Node sel = nm->mkNode(kind::APPLY_SELECTOR_TOTAL, selector_use, n[0]);
+ if (options::dtRewriteErrorSel())
+ {
+ return sel;
+ }
+ Node tester = c.getTester();
+ Node tst = nm->mkNode(APPLY_TESTER, tester, n[0]);
+ SkolemManager* sm = nm->getSkolemManager();
+ TypeNode tnw = nm->mkFunctionType(ndt, n.getType());
+ Node f = sm->mkSkolemFunction(SkolemFunId::SELECTOR_WRONG, tnw, selector);
+ Node sk = nm->mkNode(kind::APPLY_UF, f, n[0]);
+ Node ret = nm->mkNode(kind::ITE, tst, sel, sk);
+ Trace("dt-expand") << "Expand def : " << n << " to " << ret << std::endl;
+ return ret;
+}
+
TrustNode DatatypesRewriter::expandDefinition(Node n)
{
NodeManager* nm = NodeManager::currentNM();
{
case kind::APPLY_SELECTOR:
{
- Node selector = n.getOperator();
- // APPLY_SELECTOR always applies to an external selector, cindexOf is
- // legal here
- size_t cindex = utils::cindexOf(selector);
- const DType& dt = utils::datatypeOf(selector);
- const DTypeConstructor& c = dt[cindex];
- Node selector_use;
- TypeNode ndt = n[0].getType();
- if (options::dtSharedSelectors())
- {
- size_t selectorIndex = utils::indexOf(selector);
- Trace("dt-expand") << "...selector index = " << selectorIndex
- << std::endl;
- Assert(selectorIndex < c.getNumArgs());
- selector_use = c.getSelectorInternal(ndt, selectorIndex);
- }
- else
- {
- selector_use = selector;
- }
- Node sel = nm->mkNode(kind::APPLY_SELECTOR_TOTAL, selector_use, n[0]);
- if (options::dtRewriteErrorSel())
- {
- ret = sel;
- }
- else
- {
- Node tester = c.getTester();
- Node tst = nm->mkNode(APPLY_TESTER, tester, n[0]);
- SkolemManager* sm = nm->getSkolemManager();
- TypeNode tnw = nm->mkFunctionType(ndt, n.getType());
- Node f =
- sm->mkSkolemFunction(SkolemFunId::SELECTOR_WRONG, tnw, selector);
- Node sk = nm->mkNode(kind::APPLY_UF, f, n[0]);
- ret = nm->mkNode(kind::ITE, tst, sel, sk);
- Trace("dt-expand") << "Expand def : " << n << " to " << ret
- << std::endl;
- }
+ ret = expandApplySelector(n);
}
break;
case APPLY_UPDATER:
*/
#include "theory/quantifiers/ematching/candidate_generator.h"
+
#include "expr/dtype.h"
#include "expr/dtype_cons.h"
#include "options/quantifiers_options.h"
#include "smt/smt_engine.h"
#include "smt/smt_engine_scope.h"
+#include "theory/datatypes/datatypes_rewriter.h"
#include "theory/quantifiers/first_order_model.h"
#include "theory/quantifiers/quantifiers_state.h"
#include "theory/quantifiers/term_database.h"
// NOTE: could use qs.getValuation().getPreprocessedTerm(mpat); when
// expand definitions is eliminated, however, this also requires avoiding
// term formula removal.
- Node mpatExp = smt::currentSmtEngine()->expandDefinitions(mpat);
+ Node mpatExp = datatypes::DatatypesRewriter::expandApplySelector(mpat);
Trace("sel-trigger") << "Expands to: " << mpatExp << std::endl;
if (mpatExp.getKind() == ITE)
{