feat(library/util): add is_app_of helper function
This commit is contained in:
parent
723a9e227a
commit
c19be9d9e7
2 changed files with 15 additions and 0 deletions
|
@ -21,6 +21,16 @@ Author: Leonardo de Moura
|
||||||
#include "library/projection.h"
|
#include "library/projection.h"
|
||||||
|
|
||||||
namespace lean {
|
namespace lean {
|
||||||
|
bool is_app_of(expr const & t, name const & f_name) {
|
||||||
|
expr const & fn = get_app_fn(t);
|
||||||
|
return is_constant(fn) && const_name(fn) == f_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_app_of(expr const & t, name const & f_name, unsigned nargs) {
|
||||||
|
expr const & fn = get_app_fn(t);
|
||||||
|
return is_constant(fn) && const_name(fn) == f_name && get_app_num_args(t) == nargs;
|
||||||
|
}
|
||||||
|
|
||||||
bool is_standard(environment const & env) {
|
bool is_standard(environment const & env) {
|
||||||
return env.prop_proof_irrel() && env.impredicative();
|
return env.prop_proof_irrel() && env.impredicative();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,11 @@ Author: Leonardo de Moura
|
||||||
#include "kernel/type_checker.h"
|
#include "kernel/type_checker.h"
|
||||||
|
|
||||||
namespace lean {
|
namespace lean {
|
||||||
|
/** \brief Return true iff t is a constant named f_name or an application of the form (f_name a_1 ... a_k) */
|
||||||
|
bool is_app_of(expr const & t, name const & f_name);
|
||||||
|
/** \brief Return true iff t is a constant named f_name or an application of the form (f_name a_1 ... a_nargs) */
|
||||||
|
bool is_app_of(expr const & t, name const & f_name, unsigned nargs);
|
||||||
|
|
||||||
typedef std::unique_ptr<type_checker> type_checker_ptr;
|
typedef std::unique_ptr<type_checker> type_checker_ptr;
|
||||||
/** \brief Unfold constant \c e or constant application (i.e., \c e is of the form (f ....),
|
/** \brief Unfold constant \c e or constant application (i.e., \c e is of the form (f ....),
|
||||||
where \c f is a constant */
|
where \c f is a constant */
|
||||||
|
|
Loading…
Reference in a new issue