diff --git a/src/library/util.cpp b/src/library/util.cpp index 36478d064..1c2927b26 100644 --- a/src/library/util.cpp +++ b/src/library/util.cpp @@ -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(); diff --git a/src/library/util.h b/src/library/util.h index 37ea8af4c..a0fc233ef 100644 --- a/src/library/util.h +++ b/src/library/util.h @@ -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);