refactor(library/tactic/class_instance_synth): move has_expr_metavar_relaxed to util
This commit is contained in:
parent
c311e0aba6
commit
4c7a17cc4a
3 changed files with 22 additions and 20 deletions
|
@ -302,26 +302,6 @@ pair<expr, constraint> mk_class_instance_elaborator(std::shared_ptr<class_instan
|
|||
return mk_pair(m, c);
|
||||
}
|
||||
|
||||
/** \brief Similar to has_expr_metavar, but ignores metavariables occurring in the type
|
||||
of local constants */
|
||||
static bool has_expr_metavar_relaxed(expr const & e) {
|
||||
if (!has_expr_metavar(e))
|
||||
return false;
|
||||
bool found = false;
|
||||
for_each(e, [&](expr const & e, unsigned) {
|
||||
if (found || !has_expr_metavar(e))
|
||||
return false;
|
||||
if (is_metavar(e)) {
|
||||
found = true;
|
||||
return false;
|
||||
}
|
||||
if (is_local(e))
|
||||
return false; // do not visit type
|
||||
return true;
|
||||
});
|
||||
return found;
|
||||
}
|
||||
|
||||
constraint mk_class_instance_root_cnstr(std::shared_ptr<class_instance_context> const & C, local_context const & _ctx,
|
||||
expr const & m, bool is_strict, unifier_config const & cfg, delay_factor const & factor) {
|
||||
environment const & env = C->env();
|
||||
|
|
|
@ -477,4 +477,22 @@ expr infer_implicit_params(expr const & type, unsigned nparams, implicit_infer_k
|
|||
}
|
||||
lean_unreachable(); // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
bool has_expr_metavar_relaxed(expr const & e) {
|
||||
if (!has_expr_metavar(e))
|
||||
return false;
|
||||
bool found = false;
|
||||
for_each(e, [&](expr const & e, unsigned) {
|
||||
if (found || !has_expr_metavar(e))
|
||||
return false;
|
||||
if (is_metavar(e)) {
|
||||
found = true;
|
||||
return false;
|
||||
}
|
||||
if (is_local(e))
|
||||
return false; // do not visit type
|
||||
return true;
|
||||
});
|
||||
return found;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,6 +139,10 @@ enum class implicit_infer_kind { Implicit, RelaxedImplicit, None };
|
|||
*/
|
||||
expr infer_implicit_params(expr const & type, unsigned nparams, implicit_infer_kind k);
|
||||
|
||||
/** \brief Similar to has_expr_metavar, but ignores metavariables occurring in the type
|
||||
of local constants */
|
||||
bool has_expr_metavar_relaxed(expr const & e);
|
||||
|
||||
void initialize_library_util();
|
||||
void finalize_library_util();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue