2014-08-01 01:35:57 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#include "kernel/type_checker.h"
|
|
|
|
#include "kernel/environment.h"
|
|
|
|
#include "library/module.h"
|
2015-11-07 19:41:24 +00:00
|
|
|
#include "library/constants.h"
|
2014-08-01 01:35:57 +00:00
|
|
|
|
|
|
|
namespace lean {
|
2014-09-23 17:45:14 +00:00
|
|
|
static name * g_l = nullptr;
|
|
|
|
static expr * g_sorry_type = nullptr;
|
|
|
|
|
|
|
|
void initialize_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)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void finalize_sorry() {
|
|
|
|
delete g_sorry_type;
|
|
|
|
delete g_l;
|
|
|
|
}
|
2014-08-01 01:35:57 +00:00
|
|
|
|
|
|
|
bool has_sorry(environment const & env) {
|
2015-11-07 19:41:24 +00:00
|
|
|
auto decl = env.find(get_sorry_name());
|
2014-09-23 17:45:14 +00:00
|
|
|
return decl && decl->get_type() == *g_sorry_type;
|
2014-08-01 01:35:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
environment declare_sorry(environment const & env) {
|
2015-11-07 19:41:24 +00:00
|
|
|
if (auto decl = env.find(get_sorry_name())) {
|
2014-09-23 17:45:14 +00:00
|
|
|
if (decl->get_type() != *g_sorry_type)
|
2014-08-01 01:35:57 +00:00
|
|
|
throw exception("failed to declare 'sorry', environment already has an object named 'sorry'");
|
|
|
|
return env;
|
|
|
|
} else {
|
2015-11-07 19:41:24 +00:00
|
|
|
return module::add(env, check(env, mk_constant_assumption(get_sorry_name(), list<name>(*g_l), *g_sorry_type)));
|
2014-08-01 01:35:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-07 19:41:24 +00:00
|
|
|
expr mk_sorry() { return mk_constant(get_sorry_name()); }
|
2014-10-01 01:01:55 +00:00
|
|
|
bool is_sorry(expr const & e) { return is_constant(e) && const_name(e) == get_sorry_name(); }
|
2014-08-01 01:35:57 +00:00
|
|
|
}
|