feat(library/app_builder): add mk_sorry method
This commit is contained in:
parent
c16423194c
commit
5a48a2cebe
8 changed files with 19 additions and 9 deletions
|
@ -527,6 +527,10 @@ optional<expr> app_builder::mk_eq_drec(expr const & C, expr const & H1, expr con
|
|||
return m_ptr->mk_eq_drec(C, H1, H2);
|
||||
}
|
||||
|
||||
optional<expr> app_builder::mk_sorry(expr const & type) {
|
||||
return mk_app(get_sorry_name(), type);
|
||||
}
|
||||
|
||||
void app_builder::set_local_instances(list<expr> const & insts) {
|
||||
m_ptr->m_ctx->set_local_instances(insts);
|
||||
}
|
||||
|
|
|
@ -106,6 +106,9 @@ public:
|
|||
because eq.rec is a dependent eliminator in HoTT. */
|
||||
optional<expr> mk_eq_drec(expr const & C, expr const & H1, expr const & H2);
|
||||
|
||||
/** \brief Create (@sorry type) */
|
||||
optional<expr> mk_sorry(expr const & type);
|
||||
|
||||
/** \brief Set the local instances. This method is relevant when we want to expose local class instances
|
||||
to the app_builder.
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ name const * g_rat_divide = nullptr;
|
|||
name const * g_rat_of_num = nullptr;
|
||||
name const * g_sigma = nullptr;
|
||||
name const * g_sigma_mk = nullptr;
|
||||
name const * g_sorry = nullptr;
|
||||
name const * g_string = nullptr;
|
||||
name const * g_string_empty = nullptr;
|
||||
name const * g_string_str = nullptr;
|
||||
|
@ -245,6 +246,7 @@ void initialize_constants() {
|
|||
g_rat_of_num = new name{"rat", "of_num"};
|
||||
g_sigma = new name{"sigma"};
|
||||
g_sigma_mk = new name{"sigma", "mk"};
|
||||
g_sorry = new name{"sorry"};
|
||||
g_string = new name{"string"};
|
||||
g_string_empty = new name{"string", "empty"};
|
||||
g_string_str = new name{"string", "str"};
|
||||
|
@ -403,6 +405,7 @@ void finalize_constants() {
|
|||
delete g_rat_of_num;
|
||||
delete g_sigma;
|
||||
delete g_sigma_mk;
|
||||
delete g_sorry;
|
||||
delete g_string;
|
||||
delete g_string_empty;
|
||||
delete g_string_str;
|
||||
|
@ -560,6 +563,7 @@ name const & get_rat_divide_name() { return *g_rat_divide; }
|
|||
name const & get_rat_of_num_name() { return *g_rat_of_num; }
|
||||
name const & get_sigma_name() { return *g_sigma; }
|
||||
name const & get_sigma_mk_name() { return *g_sigma_mk; }
|
||||
name const & get_sorry_name() { return *g_sorry; }
|
||||
name const & get_string_name() { return *g_string; }
|
||||
name const & get_string_empty_name() { return *g_string_empty; }
|
||||
name const & get_string_str_name() { return *g_string_str; }
|
||||
|
|
|
@ -90,6 +90,7 @@ name const & get_rat_divide_name();
|
|||
name const & get_rat_of_num_name();
|
||||
name const & get_sigma_name();
|
||||
name const & get_sigma_mk_name();
|
||||
name const & get_sorry_name();
|
||||
name const & get_string_name();
|
||||
name const & get_string_empty_name();
|
||||
name const & get_string_str_name();
|
||||
|
|
|
@ -83,6 +83,7 @@ rat.divide
|
|||
rat.of_num
|
||||
sigma
|
||||
sigma.mk
|
||||
sorry
|
||||
string
|
||||
string.empty
|
||||
string.str
|
||||
|
|
|
@ -25,6 +25,7 @@ Author: Leonardo de Moura
|
|||
#include "library/module.h"
|
||||
#include "library/noncomputable.h"
|
||||
#include "library/sorry.h"
|
||||
#include "library/constants.h"
|
||||
#include "library/kernel_serializer.h"
|
||||
#include "library/unfold_macros.h"
|
||||
#include "library/decl_stats.h"
|
||||
|
|
|
@ -7,14 +7,13 @@ Author: Leonardo de Moura
|
|||
#include "kernel/type_checker.h"
|
||||
#include "kernel/environment.h"
|
||||
#include "library/module.h"
|
||||
#include "library/constants.h"
|
||||
|
||||
namespace lean {
|
||||
static name * g_sorry_name = nullptr;
|
||||
static name * g_l = nullptr;
|
||||
static expr * g_sorry_type = nullptr;
|
||||
|
||||
void initialize_sorry() {
|
||||
g_sorry_name = new name("sorry");
|
||||
g_l = new name("l");
|
||||
g_sorry_type = new expr(mk_pi("A", mk_sort(mk_param_univ(*g_l)), mk_var(0), binder_info(true)));
|
||||
}
|
||||
|
@ -22,25 +21,23 @@ void initialize_sorry() {
|
|||
void finalize_sorry() {
|
||||
delete g_sorry_type;
|
||||
delete g_l;
|
||||
delete g_sorry_name;
|
||||
}
|
||||
|
||||
bool has_sorry(environment const & env) {
|
||||
auto decl = env.find(*g_sorry_name);
|
||||
auto decl = env.find(get_sorry_name());
|
||||
return decl && decl->get_type() == *g_sorry_type;
|
||||
}
|
||||
|
||||
environment declare_sorry(environment const & env) {
|
||||
if (auto decl = env.find(*g_sorry_name)) {
|
||||
if (auto decl = env.find(get_sorry_name())) {
|
||||
if (decl->get_type() != *g_sorry_type)
|
||||
throw exception("failed to declare 'sorry', environment already has an object named 'sorry'");
|
||||
return env;
|
||||
} else {
|
||||
return module::add(env, check(env, mk_constant_assumption(*g_sorry_name, list<name>(*g_l), *g_sorry_type)));
|
||||
return module::add(env, check(env, mk_constant_assumption(get_sorry_name(), list<name>(*g_l), *g_sorry_type)));
|
||||
}
|
||||
}
|
||||
|
||||
expr mk_sorry() { return mk_constant(*g_sorry_name); }
|
||||
name const & get_sorry_name() { return *g_sorry_name; }
|
||||
expr mk_sorry() { return mk_constant(get_sorry_name()); }
|
||||
bool is_sorry(expr const & e) { return is_constant(e) && const_name(e) == get_sorry_name(); }
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ environment declare_sorry(environment const & env);
|
|||
|
||||
/** \brief Return the constant \c sorry */
|
||||
expr mk_sorry();
|
||||
name const & get_sorry_name();
|
||||
/** \brief Return true iff \c e is a sorry expression */
|
||||
bool is_sorry(expr const & e);
|
||||
void initialize_sorry();
|
||||
|
|
Loading…
Reference in a new issue