feat(kernel/inductive): add get_num_minor_premises and get_num_type_formers APIs
This commit is contained in:
parent
2bc034da2c
commit
7240a1a640
2 changed files with 26 additions and 0 deletions
|
@ -971,6 +971,24 @@ optional<unsigned> get_num_indices(environment const & env, name const & n) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
optional<unsigned> get_num_type_formers(environment const & env, name const & n) {
|
||||||
|
if (auto decls = is_inductive_decl(env, n)) {
|
||||||
|
return some(length(std::get<2>(*decls)));
|
||||||
|
} else {
|
||||||
|
return optional<unsigned>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
optional<unsigned> get_num_minor_premises(environment const & env, name const & n) {
|
||||||
|
inductive_env_ext const & ext = get_extension(env);
|
||||||
|
if (auto it = ext.m_elim_info.find(get_elim_name(n))) {
|
||||||
|
unsigned num_Cs = *get_num_type_formers(env, n);
|
||||||
|
return some(it->m_num_ACe - it->m_num_params - num_Cs);
|
||||||
|
} else {
|
||||||
|
return optional<unsigned>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
optional<name> is_intro_rule(environment const & env, name const & n) {
|
optional<name> is_intro_rule(environment const & env, name const & n) {
|
||||||
inductive_env_ext const & ext = get_extension(env);
|
inductive_env_ext const & ext = get_extension(env);
|
||||||
if (auto it = ext.m_intro_info.find(n))
|
if (auto it = ext.m_intro_info.find(n))
|
||||||
|
|
|
@ -72,6 +72,14 @@ bool is_elim_meta_app(type_checker & tc, expr const & e);
|
||||||
If \c n is not an inductive datatype in \c env, then return none.
|
If \c n is not an inductive datatype in \c env, then return none.
|
||||||
*/
|
*/
|
||||||
optional<unsigned> get_num_indices(environment const & env, name const & n);
|
optional<unsigned> get_num_indices(environment const & env, name const & n);
|
||||||
|
/** \brief Return the number of minor premises in the given inductive datatype.
|
||||||
|
If \c n is not an inductive datatype in \c env, then return none.
|
||||||
|
*/
|
||||||
|
optional<unsigned> get_num_minor_premises(environment const & env, name const & n);
|
||||||
|
/** \brief Return the number of type formers in the given inductive datatype.
|
||||||
|
If \c n is not an inductive datatype in \c env, then return none.
|
||||||
|
*/
|
||||||
|
optional<unsigned> get_num_type_formers(environment const & env, name const & n);
|
||||||
|
|
||||||
/** \brief Return the eliminator/recursor associated with an inductive datatype */
|
/** \brief Return the eliminator/recursor associated with an inductive datatype */
|
||||||
name get_elim_name(name const & n);
|
name get_elim_name(name const & n);
|
||||||
|
|
Loading…
Reference in a new issue