}
}
-struct sortCegVarOrder {
- bool operator() (Node i, Node j) {
- TypeNode it = i.getType();
- TypeNode jt = j.getType();
- return ( it!=jt && jt.isSubtypeOf( it ) ) || ( it==jt && i<j );
- }
-};
-
-
void CegInstantiator::registerCounterexampleLemma( std::vector< Node >& lems, std::vector< Node >& ce_vars ) {
Trace("cbqi-reg") << "Register counterexample lemma..." << std::endl;
d_input_vars.clear();
Trace("cbqi-debug") << "Determine variable order..." << std::endl;
if (!d_vars.empty())
{
- TypeNode tn0 = d_vars[0].getType();
- bool doSort = false;
std::map<Node, unsigned> voo;
- for (unsigned i = 0; i < d_vars.size(); i++)
+ bool doSort = false;
+ std::vector<Node> vars;
+ std::map<TypeNode, std::vector<Node> > tvars;
+ for (unsigned i = 0, size = d_vars.size(); i < size; i++)
{
voo[d_vars[i]] = i;
d_var_order_index.push_back(0);
- if (d_vars[i].getType() != tn0)
+ TypeNode tn = d_vars[i].getType();
+ if (tn.isInteger())
{
doSort = true;
+ tvars[tn].push_back(d_vars[i]);
+ }
+ else
+ {
+ vars.push_back(d_vars[i]);
}
}
if (doSort)
{
Trace("cbqi-debug") << "Sort variables based on ordering." << std::endl;
- sortCegVarOrder scvo;
- std::sort(d_vars.begin(), d_vars.end(), scvo);
+ for (std::pair<const TypeNode, std::vector<Node> >& vs : tvars)
+ {
+ vars.insert(vars.end(), vs.second.begin(), vs.second.end());
+ }
+
Trace("cbqi-debug") << "Consider variables in this order : " << std::endl;
- for (unsigned i = 0; i < d_vars.size(); i++)
+ for (unsigned i = 0; i < vars.size(); i++)
{
- d_var_order_index[voo[d_vars[i]]] = i;
- Trace("cbqi-debug") << " " << d_vars[i] << " : " << d_vars[i].getType()
- << ", index was : " << voo[d_vars[i]] << std::endl;
+ d_var_order_index[voo[vars[i]]] = i;
+ Trace("cbqi-debug") << " " << vars[i] << " : " << vars[i].getType()
+ << ", index was : " << voo[vars[i]] << std::endl;
+ d_vars[i] = vars[i];
}
Trace("cbqi-debug") << std::endl;
}