d_im(*this, c, u, d_state, d_sk_cache, out, d_statistics),
d_pregistered_terms_cache(u),
d_registered_terms_cache(u),
+ d_registeredTypesCache(u),
d_functionsTerms(c),
d_has_str_code(false),
d_rewriter(&d_statistics.d_rewrites),
d_zero = NodeManager::currentNM()->mkConst( Rational( 0 ) );
d_one = NodeManager::currentNM()->mkConst( Rational( 1 ) );
d_neg_one = NodeManager::currentNM()->mkConst(Rational(-1));
- d_emptyString = Word::mkEmptyWord(CONST_STRING);
d_true = NodeManager::currentNM()->mkConst( true );
d_false = NodeManager::currentNM()->mkConst( false );
nm->mkNode(AND, nm->mkNode(LEQ, d_zero, t), nm->mkNode(LT, t, card));
Node k = nm->mkBoundVar(nm->stringType());
Node bvl = nm->mkNode(BOUND_VAR_LIST, k);
- node = nm->mkNode(CHOICE,
- bvl,
- nm->mkNode(ITE,
- cond,
- t.eqNode(nm->mkNode(STRING_TO_CODE, k)),
- k.eqNode(d_emptyString)));
+ Node emp = Word::mkEmptyWord(node.getType());
+ node = nm->mkNode(
+ CHOICE,
+ bvl,
+ nm->mkNode(
+ ITE, cond, t.eqNode(nm->mkNode(STRING_TO_CODE, k)), k.eqNode(emp)));
}
return node;
bool polarity;
TNode atom;
-
- if (!done() && !d_equalityEngine.hasTerm(d_emptyString))
- {
- preRegisterTerm( d_emptyString );
- }
-
// Trace("strings-process") << "Theory of strings, check : " << e << std::endl;
Trace("strings-check-debug")
<< "Theory of strings, check : " << e << std::endl;
return;
}
d_registered_terms_cache.insert(n);
+ // ensure the type is registered
+ registerType(tn);
NodeManager* nm = NodeManager::currentNM();
Debug("strings-register") << "TheoryStrings::registerTerm() " << n
<< ", effort = " << effort << std::endl;
}
}
+void TheoryStrings::registerType(TypeNode tn)
+{
+ if (d_registeredTypesCache.find(tn) != d_registeredTypesCache.end())
+ {
+ return;
+ }
+ d_registeredTypesCache.insert(tn);
+ if (tn.isStringLike())
+ {
+ // preregister the empty word for the type
+ Node emp = Word::mkEmptyWord(tn);
+ if (!d_equalityEngine.hasTerm(emp))
+ {
+ preRegisterTerm(emp);
+ }
+ }
+}
+
void TheoryStrings::checkRegisterTermsNormalForms()
{
const std::vector<Node>& seqc = d_bsolver.getStringEqc();
typedef context::CDHashMap<Node, int, NodeHashFunction> NodeIntMap;
typedef context::CDHashMap<Node, Node, NodeHashFunction> NodeNodeMap;
typedef context::CDHashSet<Node, NodeHashFunction> NodeSet;
+ typedef context::CDHashSet<TypeNode, TypeNodeHashFunction> TypeNodeSet;
public:
TheoryStrings(context::Context* c, context::UserContext* u,
// preReg cache
NodeSet d_pregistered_terms_cache;
NodeSet d_registered_terms_cache;
+ /** The types that we have preregistered */
+ TypeNodeSet d_registeredTypesCache;
std::vector< Node > d_empty_vec;
private:
* effort, the call to this method does nothing.
*/
void registerTerm(Node n, int effort);
+ /** Register type
+ *
+ * Ensures the theory solver is setup to handle string-like type tn. In
+ * particular, this includes:
+ * - Calling preRegisterTerm on the empty word for tn
+ */
+ void registerType(TypeNode tn);
// Symbolic Regular Expression
private: