feat(library/definitional/projection): add option for marking main premise as instance implicit (i.e., [] binder decorator)

This commit is contained in:
Leonardo de Moura 2014-10-31 13:03:29 -07:00
parent cae543e665
commit aaad9a3c43
2 changed files with 7 additions and 6 deletions

View file

@ -45,7 +45,7 @@ static bool is_prop(expr type) {
return is_sort(type) && is_zero(sort_level(type)); return is_sort(type) && is_zero(sort_level(type));
} }
environment mk_projections(environment const & env, name const & n, buffer<name> const & proj_names) { environment mk_projections(environment const & env, name const & n, buffer<name> const & proj_names, bool inst_implicit) {
// Given an inductive datatype C A (where A represent parameters) // Given an inductive datatype C A (where A represent parameters)
// intro : Pi A (x_1 : B_1[A]) (x_2 : B_2[A, x_1]) ..., C A // intro : Pi A (x_1 : B_1[A]) (x_2 : B_2[A, x_1]) ..., C A
// //
@ -73,7 +73,8 @@ environment mk_projections(environment const & env, name const & n, buffer<name>
params.push_back(param); params.push_back(param);
} }
expr C_A = mk_app(mk_constant(n, lvls), params); expr C_A = mk_app(mk_constant(n, lvls), params);
expr c = mk_local(ngen.next(), name("c"), C_A, binder_info()); binder_info c_bi = inst_implicit ? mk_inst_implicit_binder_info() : binder_info();
expr c = mk_local(ngen.next(), name("c"), C_A, c_bi);
buffer<expr> intro_type_args; // arguments that are not parameters buffer<expr> intro_type_args; // arguments that are not parameters
expr it = intro_type; expr it = intro_type;
while (is_pi(it)) { while (is_pi(it)) {
@ -132,7 +133,7 @@ static name mk_fresh_name(environment const & env, buffer<name> const & names, n
} }
} }
environment mk_projections(environment const & env, name const & n) { environment mk_projections(environment const & env, name const & n, bool inst_implicit) {
auto p = get_nparam_intro_rule(env, n); auto p = get_nparam_intro_rule(env, n);
unsigned num_params = p.first; unsigned num_params = p.first;
inductive::intro_rule ir = p.second; inductive::intro_rule ir = p.second;
@ -145,6 +146,6 @@ environment mk_projections(environment const & env, name const & n) {
i++; i++;
type = binding_body(type); type = binding_body(type);
} }
return mk_projections(env, n, proj_names); return mk_projections(env, n, proj_names, inst_implicit);
} }
} }

View file

@ -8,6 +8,6 @@ Author: Leonardo de Moura
#include "kernel/environment.h" #include "kernel/environment.h"
namespace lean { namespace lean {
environment mk_projections(environment const & env, name const & n, buffer<name> const & proj_names); environment mk_projections(environment const & env, name const & n, buffer<name> const & proj_names, bool inst_implicit = false);
environment mk_projections(environment const & env, name const & n); environment mk_projections(environment const & env, name const & n, bool inst_implicit = false);
} }