2013-07-24 07:32:01 +00:00
|
|
|
/*
|
2014-07-15 04:34:45 +00:00
|
|
|
Copyright (c) 2013-2014 Microsoft Corporation. All rights reserved.
|
2013-07-24 07:32:01 +00:00
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#pragma once
|
2013-10-26 18:07:06 +00:00
|
|
|
#include <tuple>
|
2013-09-13 03:04:10 +00:00
|
|
|
#include "util/buffer.h"
|
2013-12-07 22:59:21 +00:00
|
|
|
#include "util/interrupt.h"
|
2013-09-13 03:04:10 +00:00
|
|
|
#include "kernel/expr.h"
|
|
|
|
#include "kernel/expr_maps.h"
|
|
|
|
|
2013-07-24 07:32:01 +00:00
|
|
|
namespace lean {
|
2013-08-28 17:47:19 +00:00
|
|
|
/**
|
2014-07-15 04:34:45 +00:00
|
|
|
\brief Apply <tt>f</tt> to the subexpressions of a given expression.
|
2013-07-24 07:32:01 +00:00
|
|
|
|
2014-07-15 04:34:45 +00:00
|
|
|
f is invoked for each subexpression \c s of the input expression e.
|
|
|
|
In a call <tt>f(s, n)</tt>, n is the scope level, i.e., the number of
|
2014-04-17 19:41:06 +00:00
|
|
|
bindings operators that enclosing \c s. The replaces only visits children of \c e
|
2014-07-15 04:34:45 +00:00
|
|
|
if f return none_expr.
|
2013-07-24 07:32:01 +00:00
|
|
|
*/
|
2014-07-15 04:34:45 +00:00
|
|
|
expr replace(expr const & e, std::function<optional<expr>(expr const &, unsigned)> const & f);
|
2014-07-19 11:53:01 +00:00
|
|
|
inline expr replace(expr const & e, std::function<optional<expr>(expr const &)> const & f) {
|
|
|
|
return replace(e, [&](expr const & e, unsigned) { return f(e); });
|
|
|
|
}
|
2013-07-24 07:32:01 +00:00
|
|
|
}
|