From 8c630454929d462a5a66f59f60cbf610949318b9 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Fri, 19 Dec 2014 21:57:22 -0800 Subject: [PATCH] feat(library/util): add more auxiliary procedures --- src/library/util.cpp | 18 ++++++++++++++++++ src/library/util.h | 3 +++ 2 files changed, 21 insertions(+) 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.