feat(library/blast/blast): create tmp_type_context that is compatible with blast

This commit is contained in:
Leonardo de Moura 2015-10-31 23:57:34 -07:00
parent e01f2ec6a5
commit f8916ed411
2 changed files with 43 additions and 0 deletions

View file

@ -534,6 +534,42 @@ scope_debug::scope_debug(environment const & env, io_state const & ios):
} }
scope_debug::~scope_debug() {} scope_debug::~scope_debug() {}
/** \brief We need to redefine infer_local and infer_metavar, because the types of hypotheses
and blast meta-variables are stored in the blast state */
class tmp_tctx : public tmp_type_context {
public:
tmp_tctx(environment const & env, io_state const & ios):
tmp_type_context(env, ios) {}
/** \brief Return the type of a local constant (local or not).
\remark This method allows the customer to store the type of local constants
in a different place. */
virtual expr infer_local(expr const & e) const {
state const & s = curr_state();
if (is_href(e)) {
branch const & b = s.get_main_branch();
hypothesis const * h = b.get(e);
lean_assert(h);
return h->get_type();
} else {
return mlocal_type(e);
}
}
virtual expr infer_metavar(expr const & m) const {
state const & s = curr_state();
metavar_decl const * d = s.get_metavar_decl(m);
lean_assert(d);
return d->get_type();
}
};
tmp_type_context_ptr mk_tmp_type_context() {
tmp_type_context_ptr r(new tmp_tctx(env(), ios()));
// TODO(Leo): set local context
return r;
}
} }
optional<expr> blast_goal(environment const & env, io_state const & ios, list<name> const & ls, list<name> const & ds, optional<expr> blast_goal(environment const & env, io_state const & ios, list<name> const & ls, list<name> const & ds,
goal const & g) { goal const & g) {

View file

@ -8,11 +8,13 @@ Author: Leonardo de Moura
#include <memory> #include <memory>
#include "kernel/environment.h" #include "kernel/environment.h"
#include "library/io_state.h" #include "library/io_state.h"
#include "library/tmp_type_context.h"
#include "library/blast/state.h" #include "library/blast/state.h"
namespace lean { namespace lean {
struct projection_info; struct projection_info;
class goal; class goal;
typedef std::unique_ptr<tmp_type_context> tmp_type_context_ptr;
namespace blast { namespace blast {
/** \brief Return the thread local environment being used by the blast tactic. */ /** \brief Return the thread local environment being used by the blast tactic. */
environment const & env(); environment const & env();
@ -76,6 +78,11 @@ public:
scope_debug(environment const & env, io_state const & ios); scope_debug(environment const & env, io_state const & ios);
~scope_debug(); ~scope_debug();
}; };
/** \brief Create a temporary type_context that is compatible with blast.
This temporary type context can acces the type of blast hypotheses
and meta-variables. */
tmp_type_context_ptr mk_tmp_type_context();
} }
optional<expr> blast_goal(environment const & env, io_state const & ios, list<name> const & ls, list<name> const & ds, optional<expr> blast_goal(environment const & env, io_state const & ios, list<name> const & ls, list<name> const & ds,
goal const & g); goal const & g);