feat(kernel/abstract): add more Pi functions for simplifying the creation Pi-expressions

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2014-05-18 13:15:00 -07:00
parent fcf94ad7c2
commit 08aa4afb3e
2 changed files with 14 additions and 1 deletions

View file

@ -56,4 +56,14 @@ expr FName(std::initializer_list<std::pair<expr const &, expr const &>> const &
MkBinder(Fun);
MkBinder(Pi);
expr Pi(unsigned num, expr const * locals, expr const & b) {
expr r = b;
unsigned i = num;
while (i > 0) {
--i;
r = mk_pi(local_pp_name(locals[i]), mlocal_type(locals[i]), abstract(r, locals[i]));
}
return r;
}
}

View file

@ -55,7 +55,10 @@ inline expr Pi(expr const & n, expr const & t, expr const & b, binder_info const
}
inline expr Pi(std::pair<expr const &, expr const &> const & p, expr const & b) { return Pi(p.first, p.second, b); }
expr Pi(std::initializer_list<std::pair<expr const &, expr const &>> const & l, expr const & b);
/** \brief Create a Pi-expression by abstracting the given local constants over b */
expr Pi(unsigned num, expr const * locals, expr const & b);
template<typename T> expr Pi(T const & locals, expr const & b) { return Pi(locals.size(), locals.data(), b); }
inline expr Pi(expr const & local, expr const & b) { return Pi(1, &local, b); }
/**
- \brief Create a Let expression (Let x := v in b), the term b is abstracted using abstract(b, x).
-*/