fix(frontends/lean/structure_cmd): effect of "include" command in the structure command
closes #438
This commit is contained in:
parent
74b8499fa9
commit
33e562a7ce
4 changed files with 42 additions and 7 deletions
|
@ -298,19 +298,27 @@ struct structure_cmd_fn {
|
||||||
tmp_locals.append(m_params);
|
tmp_locals.append(m_params);
|
||||||
for (expr const & parent : m_parents)
|
for (expr const & parent : m_parents)
|
||||||
tmp_locals.push_back(mk_local(m_ngen.next(), parent));
|
tmp_locals.push_back(mk_local(m_ngen.next(), parent));
|
||||||
expr tmp = Pi_as_is(include_vars, Pi(tmp_locals, m_type, m_p), m_p);
|
|
||||||
list<expr> ctx = m_p.locals_to_context();
|
expr_struct_set dep_set;
|
||||||
|
for (expr const & v : include_vars) {
|
||||||
|
::lean::collect_locals(mlocal_type(v), dep_set);
|
||||||
|
dep_set.insert(v);
|
||||||
|
}
|
||||||
|
buffer<expr> all_include_vars;
|
||||||
|
sort_locals(dep_set, m_p, all_include_vars);
|
||||||
|
|
||||||
|
expr tmp = Pi_as_is(all_include_vars, Pi(tmp_locals, m_type, m_p), m_p);
|
||||||
level_param_names new_ls;
|
level_param_names new_ls;
|
||||||
expr new_tmp;
|
expr new_tmp;
|
||||||
std::tie(new_tmp, new_ls) = m_p.elaborate_type(tmp, ctx);
|
std::tie(new_tmp, new_ls) = m_p.elaborate_type(tmp, list<expr>());
|
||||||
levels new_meta_ls = map2<level>(new_ls, [](name const & n) { return mk_meta_univ(n); });
|
levels new_meta_ls = map2<level>(new_ls, [](name const & n) { return mk_meta_univ(n); });
|
||||||
new_tmp = instantiate_univ_params(new_tmp, new_ls, new_meta_ls);
|
new_tmp = instantiate_univ_params(new_tmp, new_ls, new_meta_ls);
|
||||||
new_tmp = update_locals(new_tmp, include_vars);
|
new_tmp = update_locals(new_tmp, all_include_vars);
|
||||||
new_tmp = update_locals(new_tmp, m_params);
|
new_tmp = update_locals(new_tmp, m_params);
|
||||||
buffer<expr> explicit_params;
|
buffer<expr> explicit_params;
|
||||||
explicit_params.append(m_params);
|
explicit_params.append(m_params);
|
||||||
m_params.clear();
|
m_params.clear();
|
||||||
m_params.append(include_vars);
|
m_params.append(all_include_vars);
|
||||||
m_params.append(explicit_params);
|
m_params.append(explicit_params);
|
||||||
new_tmp = update_parents(new_tmp);
|
new_tmp = update_parents(new_tmp);
|
||||||
m_type = new_tmp;
|
m_type = new_tmp;
|
||||||
|
@ -518,7 +526,6 @@ struct structure_cmd_fn {
|
||||||
|
|
||||||
/** \brief Elaborate new fields, and copy them to m_fields */
|
/** \brief Elaborate new fields, and copy them to m_fields */
|
||||||
void elaborate_new_fields(buffer<expr> & new_fields) {
|
void elaborate_new_fields(buffer<expr> & new_fields) {
|
||||||
list<expr> ctx = m_p.locals_to_context();
|
|
||||||
expr dummy = mk_Prop();
|
expr dummy = mk_Prop();
|
||||||
unsigned j = m_parents.size();
|
unsigned j = m_parents.size();
|
||||||
while (j > 0) {
|
while (j > 0) {
|
||||||
|
@ -528,7 +535,7 @@ struct structure_cmd_fn {
|
||||||
expr tmp = Pi_as_is(m_params, Pi_as_is(m_fields, Pi(new_fields, dummy, m_p), m_p), m_p);
|
expr tmp = Pi_as_is(m_params, Pi_as_is(m_fields, Pi(new_fields, dummy, m_p), m_p), m_p);
|
||||||
level_param_names new_ls;
|
level_param_names new_ls;
|
||||||
expr new_tmp;
|
expr new_tmp;
|
||||||
std::tie(new_tmp, new_ls) = m_p.elaborate_type(tmp, ctx);
|
std::tie(new_tmp, new_ls) = m_p.elaborate_type(tmp, list<expr>());
|
||||||
for (auto new_l : new_ls)
|
for (auto new_l : new_ls)
|
||||||
m_level_names.push_back(new_l);
|
m_level_names.push_back(new_l);
|
||||||
new_tmp = update_locals(new_tmp, m_params);
|
new_tmp = update_locals(new_tmp, m_params);
|
||||||
|
|
12
tests/lean/438.lean
Normal file
12
tests/lean/438.lean
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import algebra.group
|
||||||
|
open algebra
|
||||||
|
|
||||||
|
attribute Group.struct [coercion]
|
||||||
|
|
||||||
|
section
|
||||||
|
parameters {P₀ : Type} [P : group P₀]
|
||||||
|
include P
|
||||||
|
|
||||||
|
structure lambda_morphism := (comm : _ = _)
|
||||||
|
|
||||||
|
end
|
15
tests/lean/438.lean.expected.out
Normal file
15
tests/lean/438.lean.expected.out
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
438.lean:10:41: error: don't know how to synthesize placeholder
|
||||||
|
P₀ : Type,
|
||||||
|
P : group P₀
|
||||||
|
⊢ Type
|
||||||
|
438.lean:10:39: error: don't know how to synthesize placeholder
|
||||||
|
P₀ : Type,
|
||||||
|
P : group P₀
|
||||||
|
⊢ ?M_1
|
||||||
|
438.lean:10:43: error: don't know how to synthesize placeholder
|
||||||
|
P₀ : Type,
|
||||||
|
P : group P₀
|
||||||
|
⊢ ?M_1
|
||||||
|
438.lean:10:2: error: failed to add declaration 'lambda_morphism.mk' to environment, type has metavariables
|
||||||
|
Π {P₀ : Type} {P : group P₀},
|
||||||
|
?M_2 = ?M_3 → lambda_morphism P₀ P
|
|
@ -14,6 +14,7 @@ section
|
||||||
universe variable l
|
universe variable l
|
||||||
variable A : Type.{l}
|
variable A : Type.{l}
|
||||||
variable Ha : decidable_eq A
|
variable Ha : decidable_eq A
|
||||||
|
include Ha
|
||||||
variable E : Type₂
|
variable E : Type₂
|
||||||
include E
|
include E
|
||||||
-- include Ha
|
-- include Ha
|
||||||
|
|
Loading…
Reference in a new issue