feat(library/util): add auxiliary recognizers

This commit is contained in:
Leonardo de Moura 2015-11-06 19:06:41 -08:00
parent 2d04156959
commit 01bde866d6
2 changed files with 20 additions and 0 deletions

View file

@ -580,6 +580,20 @@ bool is_eq_rec_core(expr const & e) {
return is_constant(fn) && const_name(fn) == get_eq_rec_name();
}
bool is_eq_rec(environment const & env, expr const & e) {
expr const & fn = get_app_fn(e);
if (!is_constant(fn))
return false;
return is_standard(env) ? const_name(fn) == get_eq_rec_name() : const_name(fn) == get_eq_nrec_name();
}
bool is_eq_drec(environment const & env, expr const & e) {
expr const & fn = get_app_fn(e);
if (!is_constant(fn))
return false;
return is_standard(env) ? const_name(fn) == get_eq_drec_name() : const_name(fn) == get_eq_rec_name();
}
bool is_eq(expr const & e) {
expr const & fn = get_app_fn(e);
return is_constant(fn) && const_name(fn) == get_eq_name();

View file

@ -162,6 +162,12 @@ expr mk_subsingleton_elim(type_checker & tc, expr const & h, expr const & x, exp
/** \brief Return true iff \c e is a term of the form (eq.rec ....) */
bool is_eq_rec_core(expr const & e);
/** \brief Return true iff \c e is a term of the form (eq.rec ....) in the standard library,
and (eq.nrec ...) in the HoTT library. */
bool is_eq_rec(environment const & env, expr const & e);
/** \brief Return true iff \c e is a term of the form (eq.drec ....) in the standard library,
and (eq.rec ...) in the HoTT library. */
bool is_eq_drec(environment const & env, expr const & e);
bool is_eq(expr const & e);
bool is_eq(expr const & e, expr & lhs, expr & rhs);