diff --git a/src/library/util.cpp b/src/library/util.cpp index d4d1e714f..2ad2410a6 100644 --- a/src/library/util.cpp +++ b/src/library/util.cpp @@ -312,6 +312,24 @@ expr mk_heq(type_checker & tc, expr const & lhs, expr const & rhs) { return mk_app(mk_constant(*g_heq_name, {lvl}), A, lhs, B, rhs); } +bool is_eq_rec(expr const & e) { + expr const & fn = get_app_fn(e); + return is_constant(fn) && const_name(fn) == *g_eq_rec_name; +} + +bool is_eq(expr const & e) { + expr const & fn = get_app_fn(e); + return is_constant(fn) && const_name(fn) == *g_eq_name; +} + +bool is_eq_a_a(expr const & e) { + if (!is_eq(e)) + return false; + buffer args; + get_app_args(e, args); + return args.size() == 3 && args[1] == args[2]; +} + void mk_telescopic_eq(type_checker & tc, buffer const & t, buffer const & s, buffer & eqs) { lean_assert(t.size() == s.size()); lean_assert(std::all_of(s.begin(), s.end(), is_local)); diff --git a/src/library/util.h b/src/library/util.h index 86ebcfc51..b8637b9d7 100644 --- a/src/library/util.h +++ b/src/library/util.h @@ -94,6 +94,9 @@ expr mk_pr2(type_checker & tc, expr const & p, bool prop); expr mk_eq(type_checker & tc, expr const & lhs, expr const & rhs); expr mk_refl(type_checker & tc, expr const & a); +bool is_eq_rec(expr const & e); +bool is_eq(expr const & e); +bool is_eq_a_a(expr const & e); /** \brief Create a telescope equality for HoTT library. This procedure assumes eq supports dependent elimination.