feat(library/util): add more auxiliary procedures
This commit is contained in:
parent
187f4483e9
commit
8c63045492
2 changed files with 21 additions and 0 deletions
|
@ -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);
|
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<expr> args;
|
||||||
|
get_app_args(e, args);
|
||||||
|
return args.size() == 3 && args[1] == args[2];
|
||||||
|
}
|
||||||
|
|
||||||
void mk_telescopic_eq(type_checker & tc, buffer<expr> const & t, buffer<expr> const & s, buffer<expr> & eqs) {
|
void mk_telescopic_eq(type_checker & tc, buffer<expr> const & t, buffer<expr> const & s, buffer<expr> & eqs) {
|
||||||
lean_assert(t.size() == s.size());
|
lean_assert(t.size() == s.size());
|
||||||
lean_assert(std::all_of(s.begin(), s.end(), is_local));
|
lean_assert(std::all_of(s.begin(), s.end(), is_local));
|
||||||
|
|
|
@ -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_eq(type_checker & tc, expr const & lhs, expr const & rhs);
|
||||||
expr mk_refl(type_checker & tc, expr const & a);
|
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.
|
/** \brief Create a telescope equality for HoTT library.
|
||||||
This procedure assumes eq supports dependent elimination.
|
This procedure assumes eq supports dependent elimination.
|
||||||
|
|
Loading…
Reference in a new issue