diff --git a/src/library/blast/forward/pattern.cpp b/src/library/blast/forward/pattern.cpp index dc215184b..02650121b 100644 --- a/src/library/blast/forward/pattern.cpp +++ b/src/library/blast/forward/pattern.cpp @@ -141,6 +141,7 @@ struct hi_entry { struct hi_state { name_set m_no_patterns; + name_set m_lemma_names; hi_lemmas m_lemmas; }; @@ -154,6 +155,16 @@ deserializer & operator>>(deserializer & d, multi_pattern & mp) { return d; } +static optional get_hi_lemma_name(expr const & H) { + if (is_lambda(H)) + return get_hi_lemma_name(binding_body(H)); + expr const & f = get_app_fn(H); + if (is_constant(f)) + return optional(const_name(f)); + else + return optional(); +} + struct hi_config { typedef hi_entry entry; typedef hi_state state; @@ -162,6 +173,8 @@ struct hi_config { if (e.m_no_pattern) { s.m_no_patterns.insert(*e.m_no_pattern); } else { + if (auto n = get_hi_lemma_name(e.m_lemma.m_proof)) + s.m_lemma_names.insert(*n); for (multi_pattern const & mp : e.m_lemma.m_multi_patterns) { for (expr const & p : mp) { lean_assert(is_app(p)); @@ -326,7 +339,9 @@ hi_lemma mk_hi_lemma_core(tmp_type_context & ctx, fun_info_manager & fm, expr co unsigned priority) { // TODO(Leo): std::cout << H << "\n"; - return hi_lemma(); + hi_lemma r; + r.m_proof = H; // fix + return r; } hi_lemma mk_hi_lemma(tmp_type_context & ctx, fun_info_manager & fm, expr const & H) { @@ -346,6 +361,10 @@ environment add_hi_lemma(environment const & env, name const & c, unsigned prior persistent); } +bool is_hi_lemma(environment const & env, name const & c) { + return hi_ext::get_state(env).m_lemma_names.contains(c); +} + /** pattern_le */ struct pattern_le_fn { tmp_type_context & m_ctx; diff --git a/src/library/blast/forward/pattern.h b/src/library/blast/forward/pattern.h index 5d20b7990..ea161737a 100644 --- a/src/library/blast/forward/pattern.h +++ b/src/library/blast/forward/pattern.h @@ -54,6 +54,9 @@ typedef rb_multi_map hi_lemmas; /** \brief Add the given theorem as a heuristic instantiation lemma in the current environment. */ environment add_hi_lemma(environment const & env, name const & c, unsigned priority, bool persistent); +/** \brief Return true iff \c c was added as a heuristic instantiation lemma */ +bool is_hi_lemma(environment const & env, name const & c); + /** \brief Retrieve the active set of heuristic instantiation lemmas. */ hi_lemmas get_hi_lemma_index(environment const & env);