2015-09-16 14:49:39 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
2015-09-28 23:40:19 +00:00
|
|
|
#include "kernel/for_each_fn.h"
|
2015-09-16 14:49:39 +00:00
|
|
|
#include "library/blast/state.h"
|
2015-09-25 21:43:42 +00:00
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
namespace blast {
|
|
|
|
state::state():m_next_mref_index(0) {}
|
2015-09-28 23:40:19 +00:00
|
|
|
|
|
|
|
expr state::mk_metavar(hypothesis_idx_buffer const & ctx, expr const & type) {
|
|
|
|
hypothesis_idx_set ctx_as_set;
|
|
|
|
for (unsigned const & hidx : ctx)
|
|
|
|
ctx_as_set.insert(hidx);
|
|
|
|
for_each(type, [&](expr const & e, unsigned) {
|
|
|
|
if (!has_lref(e))
|
|
|
|
return false;
|
|
|
|
if (is_lref(e)) {
|
|
|
|
lean_assert(ctx_as_set.contains(lref_index(e)));
|
|
|
|
m_main.fix_hypothesis(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true; // continue search
|
|
|
|
});
|
|
|
|
unsigned idx = m_next_mref_index;
|
2015-09-25 21:43:42 +00:00
|
|
|
m_next_mref_index++;
|
2015-09-28 23:40:19 +00:00
|
|
|
m_metavar_decls.insert(idx, metavar_decl(to_list(ctx), ctx_as_set, type));
|
|
|
|
return blast::mk_mref(idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
expr state::mk_metavar(expr const & type) {
|
|
|
|
hypothesis_idx_buffer ctx;
|
|
|
|
m_main.get_sorted_hypotheses(ctx);
|
|
|
|
return mk_metavar(ctx, type);
|
2015-09-25 21:43:42 +00:00
|
|
|
}
|
|
|
|
}}
|