refactor(library/tactic/goal): move goal => local_context conversion to goal class
This commit is contained in:
parent
f10424d729
commit
18808d133e
3 changed files with 12 additions and 3 deletions
|
@ -5,6 +5,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
|||
Author: Leonardo de Moura
|
||||
*/
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
#include "util/buffer.h"
|
||||
#include "util/sstream.h"
|
||||
#include "util/sexpr/option_declarations.h"
|
||||
|
@ -34,6 +35,13 @@ bool get_pp_compact_goals(options const & o) {
|
|||
return o.get_bool(*g_pp_compact_goals, LEAN_DEFAULT_PP_COMPACT_GOALS);
|
||||
}
|
||||
|
||||
local_context goal::to_local_context() const {
|
||||
buffer<expr> hyps;
|
||||
get_hyps(hyps);
|
||||
std::reverse(hyps.begin(), hyps.end());
|
||||
return local_context(to_list(hyps));
|
||||
}
|
||||
|
||||
format goal::pp(formatter const & fmt) const {
|
||||
return pp(fmt, substitution());
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ Author: Leonardo de Moura
|
|||
#include "kernel/formatter.h"
|
||||
#include "kernel/environment.h"
|
||||
#include "library/io_state_stream.h"
|
||||
#include "library/local_context.h"
|
||||
|
||||
namespace lean {
|
||||
/**
|
||||
|
@ -71,6 +72,8 @@ public:
|
|||
*/
|
||||
list<expr> to_context() const;
|
||||
|
||||
local_context to_local_context() const;
|
||||
|
||||
/** \brief Apply given substitution to goal */
|
||||
goal instantiate(substitution const & s) const;
|
||||
|
||||
|
|
|
@ -472,9 +472,7 @@ class rewrite_fn {
|
|||
|
||||
void update_goal(goal const & g) {
|
||||
m_g = g;
|
||||
buffer<expr> hyps;
|
||||
g.get_hyps(hyps);
|
||||
m_ctx = local_context(to_list(hyps));
|
||||
m_ctx = m_g.to_local_context();
|
||||
}
|
||||
|
||||
expr mk_meta(expr const & type) {
|
||||
|
|
Loading…
Reference in a new issue