fix(kernel/abstract): bug in abstract for telescopes

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2014-05-16 17:47:04 -07:00
parent e6c52d17a6
commit 6dedb480ec
2 changed files with 5 additions and 2 deletions

View file

@ -26,14 +26,15 @@ expr abstract(expr const & e, unsigned s, unsigned n, expr const * subst) {
});
}
expr abstract(expr const & e, unsigned n, expr const * subst) { return abstract(e, 0, n, subst); }
expr abstract(expr const & e, expr const & s, unsigned i) { return abstract(e, i, 1, &s); }
telescope abstract(telescope const & t, expr const & s, unsigned i) {
if (is_nil(t)) {
return t;
} else {
binder const & b = head(t);
return telescope(b.update_type(abstract(b.get_type(), i, 1, &s)),
abstract(head(t), s, i+1));
return telescope(b.update_type(abstract(b.get_type(), s, i)),
abstract(tail(t), s, i+1));
}
}

View file

@ -19,6 +19,8 @@ namespace lean {
expr abstract(expr const & e, unsigned n, expr const * s);
inline expr abstract(expr const & e, expr const & s) { return abstract(e, 1, &s); }
inline expr abstract(expr const & e, std::initializer_list<expr> const & l) { return abstract(e, l.size(), l.begin()); }
/** \brief Replace s with variable #i in the given telescope. \pre s is closed */
expr abstract(expr const & e, expr const & s, unsigned i);
/**
\brief Replace s with variable #i in the given telescope.