Improves performance on ground conjectures with recursive functions. We use the evalutator to (partially) evaluate bodies of recursive functions, instead of relying on substitution+rewriting.
Node Evaluator::eval(TNode n,
const std::vector<Node>& args,
- const std::vector<Node>& vals)
+ const std::vector<Node>& vals) const
{
Trace("evaluator") << "Evaluating " << n << " under substitution " << args
<< " " << vals << std::endl;
TNode n,
const std::vector<Node>& args,
const std::vector<Node>& vals,
- std::unordered_map<TNode, Node, NodeHashFunction>& evalAsNode)
+ std::unordered_map<TNode, Node, NodeHashFunction>& evalAsNode) const
{
std::unordered_map<TNode, EvalResult, TNodeHashFunction> results;
std::vector<TNode> queue;
Node Evaluator::reconstruct(
TNode n,
std::unordered_map<TNode, EvalResult, TNodeHashFunction>& eresults,
- std::unordered_map<TNode, Node, NodeHashFunction>& evalAsNode)
+ std::unordered_map<TNode, Node, NodeHashFunction>& evalAsNode) const
{
if (n.getNumChildren() == 0)
{
*/
Node eval(TNode n,
const std::vector<Node>& args,
- const std::vector<Node>& vals);
+ const std::vector<Node>& vals) const;
private:
/**
TNode n,
const std::vector<Node>& args,
const std::vector<Node>& vals,
- std::unordered_map<TNode, Node, NodeHashFunction>& evalAsNode);
+ std::unordered_map<TNode, Node, NodeHashFunction>& evalAsNode) const;
/** reconstruct
*
* This function reconstructs the result of evaluating n using a combination
Node reconstruct(
TNode n,
std::unordered_map<TNode, EvalResult, TNodeHashFunction>& eresults,
- std::unordered_map<TNode, Node, NodeHashFunction>& evalAsNode);
+ std::unordered_map<TNode, Node, NodeHashFunction>& evalAsNode) const;
};
} // namespace theory
const std::vector<Node>& args = itf->second.d_args;
if (!args.empty())
{
- // invoke it on arguments
- sbody = sbody.substitute(
- args.begin(), args.end(), children.begin(), children.end());
- // rewrite it
- sbody = Rewriter::rewrite(sbody);
+ // invoke it on arguments using the evaluator
+ sbody = d_eval.eval(sbody, args, children);
if (Trace.isOn("fd-eval-debug2"))
{
Trace("fd-eval-debug2")
Trace("fd-eval-debug2")
<< "FunDefEvaluator: results in " << sbody << "\n";
}
+ Assert(!sbody.isNull());
}
// our result is the result of the body
visited[cur] = sbody;
#include <map>
#include <vector>
#include "expr/node.h"
+#include "theory/evaluator.h"
namespace CVC4 {
namespace theory {
};
/** maps functions to the above information */
std::map<Node, FunDefInfo> d_funDefMap;
+ /** evaluator utility */
+ Evaluator d_eval;
};
} // namespace quantifiers