}/* SubstitutionMap::internalSubstitute() */
-void SubstitutionMap::simplifyRHS(const SubstitutionMap& subMap)
-{
- // Put the new substitutions into the old ones
- NodeMap::iterator it = d_substitutions.begin();
- NodeMap::iterator it_end = d_substitutions.end();
- for(; it != it_end; ++ it) {
- d_substitutions[(*it).first] = subMap.apply((*it).second);
- }
-}
-
-
-void SubstitutionMap::simplifyRHS(TNode x, TNode t) {
- // Temporary substitution cache
- NodeCache tempCache;
- tempCache[x] = t;
-
- // Put the new substitution into the old ones
- NodeMap::iterator it = d_substitutions.begin();
- NodeMap::iterator it_end = d_substitutions.end();
- for(; it != it_end; ++ it) {
- d_substitutions[(*it).first] = internalSubstitute((*it).second, tempCache);
- }
- // it = d_substitutionsLazy.begin();
- // it_end = d_substitutionsLazy.end();
- // for(; it != it_end; ++ it) {
- // d_substitutionsLazy[(*it).first] = internalSubstitute((*it).second, tempCache);
- // }
-}
-
-
void SubstitutionMap::addSubstitution(TNode x, TNode t, bool invalidateCache)
{
Debug("substitution") << "SubstitutionMap::addSubstitution(" << x << ", " << t << ")" << endl;
}
}
-static bool check(TNode node,
- const SubstitutionMap::NodeMap& substitutions) CVC4_UNUSED;
-static bool check(TNode node, const SubstitutionMap::NodeMap& substitutions)
-{
- SubstitutionMap::NodeMap::const_iterator it = substitutions.begin();
- SubstitutionMap::NodeMap::const_iterator it_end = substitutions.end();
- Debug("substitution") << "checking " << node << endl;
- for (; it != it_end; ++it)
- {
- Debug("substitution") << "-- hasSubterm( " << (*it).first << " ) ?" << endl;
- if (expr::hasSubterm(node, (*it).first))
- {
- Debug("substitution") << "-- FAIL" << endl;
- return false;
- }
- }
- Debug("substitution") << "-- SUCCEED" << endl;
- return true;
-}
-
Node SubstitutionMap::apply(TNode t) {
Debug("substitution") << "SubstitutionMap::apply(" << t << ")" << endl;
Node result = internalSubstitute(t, d_substitutionCache);
Debug("substitution") << "SubstitutionMap::apply(" << t << ") => " << result << endl;
- // Assert(check(result, d_substitutions));
-
return result;
}
/** Has the cache been invalidated? */
bool d_cacheInvalidated;
- /** Whether to keep substitutions in solved form */
- bool d_solvedForm;
-
/** Internal method that performs substitution */
Node internalSubstitute(TNode t, NodeCache& cache);
CacheInvalidator d_cacheInvalidator;
public:
-
- SubstitutionMap(context::Context* context, bool substituteUnderQuantifiers = true, bool solvedForm = false) :
- d_substitutions(context),
- d_substitutionCache(),
- d_substituteUnderQuantifiers(substituteUnderQuantifiers),
- d_cacheInvalidated(false),
- d_solvedForm(solvedForm),
- d_cacheInvalidator(context, d_cacheInvalidated)
- {
+ SubstitutionMap(context::Context* context,
+ bool substituteUnderQuantifiers = true)
+ : d_substitutions(context),
+ d_substitutionCache(),
+ d_substituteUnderQuantifiers(substituteUnderQuantifiers),
+ d_cacheInvalidated(false),
+ d_cacheInvalidator(context, d_cacheInvalidated)
+ {
}
/**
return d_substitutions.empty();
}
- // NOTE [MGD]: removed clear() and swap() from the interface
- // when this data structure became context-dependent
- // because they weren't used---and it's not clear how they
- // should best interact with cache invalidation on context
- // pops.
-
- // Simplify right-hand sides of current map using the given substitutions
- void simplifyRHS(const SubstitutionMap& subMap);
-
- // Simplify right-hand sides of current map with lhs -> rhs
- void simplifyRHS(TNode lhs, TNode rhs);
-
- bool isSolvedForm() const { return d_solvedForm; }
-
/**
* Print to the output stream
*/