feat: "implement" sorry using panic

This commit is contained in:
Leonardo de Moura 2021-01-13 06:56:25 -08:00
parent 3ca0aef098
commit f6e5b13591
3 changed files with 5 additions and 6 deletions

View file

@ -166,6 +166,7 @@ structure Subtype {α : Sort u} (p : α → Prop) where
@[reducible] def namedPattern {α : Sort u} (x a : α) : α := a
/- Auxiliary axiom used to implement `sorry`. -/
@[extern "lean_sorry", neverExtract]
axiom sorryAx (α : Sort u) (synthetic := true) : α
theorem eqFalseOfNeTrue : {b : Bool} → Not (Eq b true) → Eq b false

View file

@ -10,7 +10,6 @@ Author: Leonardo de Moura
#include "kernel/kernel_exception.h"
#include "library/max_sharing.h"
#include "library/trace.h"
#include "library/sorry.h"
#include "library/time_task.h"
#include "library/compiler/util.h"
#include "library/compiler/lcnf.h"
@ -158,10 +157,6 @@ bool is_main_fn_type(expr const & type) {
}
}
static bool has_synthetic_sorry(constant_info const & cinfo) {
return cinfo.is_definition() && has_synthetic_sorry(cinfo.get_value());
}
#define trace_compiler(k, ds) lean_trace(k, trace_comp_decls(ds););
environment compile(environment const & env, options const & opts, names cs) {
@ -190,7 +185,6 @@ environment compile(environment const & env, options const & opts, names cs) {
lean_assert(!is_extern_constant(env, get_real_name(c)));
constant_info cinfo = env.get(c);
if (!cinfo.is_definition() && !cinfo.is_opaque()) return env;
if (has_synthetic_sorry(cinfo)) return env;
}
time_task t("compilation", opts);

View file

@ -58,6 +58,10 @@ extern "C" object * lean_panic_fn(object * default_val, object * msg) {
return default_val;
}
extern "C" object * lean_sorry(uint8) {
lean_panic("executing sorry");
}
extern "C" size_t lean_object_byte_size(lean_object * o) {
if (lean_is_mt(o) || lean_is_st(o) || lean_is_persistent(o)) {
/* Recall that multi-threaded, single-threaded and persistent objects are stored in the heap.