feat(library/definitional): automatically add attribute [unfold-c] to cases_on, brec_on and rec_on

see #496
This commit is contained in:
Leonardo de Moura 2015-03-27 19:11:35 -07:00
parent 75621df52b
commit 1b15036dba
3 changed files with 9 additions and 0 deletions

View file

@ -15,6 +15,7 @@ Author: Leonardo de Moura
#include "library/module.h"
#include "library/bin_app.h"
#include "library/util.h"
#include "library/normalize.h"
namespace lean {
static void throw_corrupted(name const & n) {
@ -146,6 +147,7 @@ static environment mk_below(environment const & env, name const & n, bool ibelow
opaque, rec_decl.get_module_idx(), use_conv_opt);
environment new_env = module::add(env, check(env, new_d));
new_env = set_reducible(new_env, below_name, reducible_status::Reducible);
new_env = add_unfold_c_hint(new_env, below_name, nparams + nindices + ntypeformers);
return add_protected(new_env, below_name);
}
@ -331,6 +333,7 @@ static environment mk_brec_on(environment const & env, name const & n, bool ind)
opaque, rec_decl.get_module_idx(), use_conv_opt);
environment new_env = module::add(env, check(env, new_d));
new_env = set_reducible(new_env, brec_on_name, reducible_status::Reducible);
new_env = add_unfold_c_hint(new_env, brec_on_name, nparams + nindices + ntypeformers);
return add_protected(new_env, brec_on_name);
}

View file

@ -14,6 +14,7 @@ Author: Leonardo de Moura
#include "library/protected.h"
#include "library/reducible.h"
#include "library/constants.h"
#include "library/normalize.h"
namespace lean {
static void throw_corrupted(name const & n) {
@ -126,6 +127,7 @@ environment mk_cases_on(environment const & env, name const & n) {
// Add indices and major-premise to rec_params
for (unsigned i = 0; i < num_idx_major; i++)
cases_on_params.push_back(rec_params[num_params + num_types + num_minors + i]);
unsigned cases_on_major_idx = cases_on_params.size() - 1;
// Add minor premises to rec_params and rec_args
i = num_params + num_types;
@ -181,6 +183,7 @@ environment mk_cases_on(environment const & env, name const & n) {
opaque, rec_decl.get_module_idx(), use_conv_opt);
environment new_env = module::add(env, check(env, new_d));
new_env = set_reducible(new_env, cases_on_name, reducible_status::Reducible);
new_env = add_unfold_c_hint(new_env, cases_on_name, cases_on_major_idx);
return add_protected(new_env, cases_on_name);
}
}

View file

@ -13,6 +13,7 @@ Author: Leonardo de Moura
#include "library/module.h"
#include "library/reducible.h"
#include "library/protected.h"
#include "library/normalize.h"
namespace lean {
environment mk_rec_on(environment const & env, name const & n) {
@ -43,6 +44,7 @@ environment mk_rec_on(environment const & env, name const & n) {
new_locals.push_back(locals[i]);
for (unsigned i = 0; i < idx_major_sz; i++)
new_locals.push_back(locals[AC_sz + minor_sz + i]);
unsigned rec_on_major_idx = new_locals.size() - 1;
for (unsigned i = 0; i < minor_sz; i++)
new_locals.push_back(locals[AC_sz + i]);
expr rec_on_type = Pi(new_locals, rec_type);
@ -58,6 +60,7 @@ environment mk_rec_on(environment const & env, name const & n) {
rec_on_type, rec_on_val,
opaque, rec_decl.get_module_idx(), use_conv_opt)));
new_env = set_reducible(new_env, rec_on_name, reducible_status::Reducible);
new_env = add_unfold_c_hint(new_env, rec_on_name, rec_on_major_idx);
return add_protected(new_env, rec_on_name);
}
}