Fixes #4228. That benchmark now times out.
{
terms.push_back(d_rd->getRDomain(f, i)->d_terms[childIndex[i]]);
Trace("inst-alg-rd")
- << " " << d_rd->getRDomain(f, i)->d_terms[childIndex[i]]
+ << " (rd) " << d_rd->getRDomain(f, i)->d_terms[childIndex[i]]
<< std::endl;
}
else
<< " " << term_db_list[ftypes[i]][childIndex[i]]
<< std::endl;
}
+ Assert(terms[i].getType().isComparableTo(ftypes[i]));
}
if (ie->addInstantiation(f, terms))
{
// Ensure the type is correct, this for instance ensures that real terms
// are cast to integers for { x -> t } where x has type Int and t has
// type Real.
- terms[i] = quantifiers::TermUtil::ensureType(terms[i], tn);
+ terms[i] = ensureType(terms[i], tn);
if (mkRep)
{
// pick the best possible representative for instantiation, based on past
}
}
+Node Instantiate::ensureType(Node n, TypeNode tn)
+{
+ Trace("inst-add-debug2") << "Ensure " << n << " : " << tn << std::endl;
+ TypeNode ntn = n.getType();
+ Assert(ntn.isComparableTo(tn));
+ if (ntn.isSubtypeOf(tn))
+ {
+ return n;
+ }
+ if (tn.isInteger())
+ {
+ return NodeManager::currentNM()->mkNode(TO_INTEGER, n);
+ }
+ return Node::null();
+}
+
Instantiate::Statistics::Statistics()
: d_instantiations("Instantiate::Instantiations_Total", 0),
d_inst_duplicate("Instantiate::Duplicate_Inst", 0),
bool addedLem = true);
/** remove instantiation from the cache */
bool removeInstantiationInternal(Node q, std::vector<Node>& terms);
+ /**
+ * Ensure that n has type tn, return a term equivalent to it for that type
+ * if possible.
+ */
+ static Node ensureType(Node n, TypeNode tn);
/** pointer to the quantifiers engine */
QuantifiersEngine* d_qe;
Node q = d_qe->getTermUtil()->getInstConstAttr( n );
//merge the RDomains
unsigned id = n.getAttribute(InstVarNumAttribute());
+ Assert(q[0][id].getType() == n.getType());
Trace("rel-dom-debug") << n << " is variable # " << id << " for " << q;
Trace("rel-dom-debug") << " with body : " << d_qe->getTermUtil()->getInstConstantBody( q ) << std::endl;
RDomain * rq = getRDomain( q, id );
d_rel_dom_lit[hasPol][pol][n].d_merge = false;
int varCount = 0;
int varCh = -1;
+ TermUtil* tu = d_qe->getTermUtil();
for( unsigned i=0; i<n.getNumChildren(); i++ ){
if( n[i].getKind()==INST_CONSTANT ){
- d_rel_dom_lit[hasPol][pol][n].d_rd[i] = getRDomain( q, n[i].getAttribute(InstVarNumAttribute()), false );
+ // must get the quantified formula this belongs to, which may be
+ // different from q
+ Node qi = tu->getInstConstAttr(n[i]);
+ unsigned id = n[i].getAttribute(InstVarNumAttribute());
+ d_rel_dom_lit[hasPol][pol][n].d_rd[i] = getRDomain(qi, id, false);
varCount++;
varCh = i;
}else{
}
}
-Node TermUtil::ensureType( Node n, TypeNode tn ) {
- TypeNode ntn = n.getType();
- Assert(ntn.isComparableTo(tn));
- if( ntn.isSubtypeOf( tn ) ){
- return n;
- }else{
- if( tn.isInteger() ){
- return NodeManager::currentNM()->mkNode( TO_INTEGER, n );
- }
- return Node::null();
- }
-}
-
int TermUtil::getTermDepth( Node n ) {
if (!n.hasAttribute(TermDepthAttribute()) ){
int maxDepth = -1;
std::vector<Node>& vars);
public:
- /** ensure type */
- static Node ensureType( Node n, TypeNode tn );
//general utilities
// TODO #1216 : promote these?