This PR adds support for `structure` in `mutual` blocks, allowing inductive types defined by `inductive` and `structure` to be mutually recursive. The limitations are (1) that the parents in the `extends` clause must be defined before the `mutual` block and (2) mutually recursive classes are not allowed (a limitation shared by `class inductive`). There are also improvements to universe level inference for inductive types and structures. Breaking change: structure parents now elaborate with the structure in scope (fix: use qualified names or rename the structure to avoid shadowing), and structure parents no longer elaborate with autoimplicits enabled. Internally, this is a large refactor of both the `inductive` and `structure` commands. Common material is now in `Lean.Elab.MutualInductive`, and each command plugs into this mutual inductive elaboration framework with the logic specific to the respective command. For example, `structure` has code to add projections after the inductive types are added to the environment. Closes #4182
37 lines
1.5 KiB
Text
37 lines
1.5 KiB
Text
ctorUnivTooBig.lean:3:2-3:45: error: invalid universe level in constructor 'Bla.cons', parameter 'α' has type
|
||
Type u
|
||
at universe level
|
||
u+2
|
||
which is not less than or equal to the inductive type's resulting universe level
|
||
u+1
|
||
ctorUnivTooBig.lean:7:2-7:25: error: invalid universe level in constructor 'Foo.mk', parameter 'α' has type
|
||
Type
|
||
at universe level
|
||
2
|
||
which is not less than or equal to the inductive type's resulting universe level
|
||
1
|
||
ctorUnivTooBig.lean:12:2-12:34: error: invalid universe level in constructor 'Foo'.mk', parameter has type
|
||
Sort (max u v)
|
||
at universe level
|
||
max (u+1) (v+1)
|
||
which is not less than or equal to the inductive type's resulting universe level
|
||
u+1
|
||
Ex1.Member.head.{u} {α : Type u} {a : α} {as : List α} : Member a (a :: as)
|
||
ctorUnivTooBig.lean:35:2-35:27: error: invalid universe level in constructor 'Ex3.Member.head', parameter 'as' has type
|
||
List α
|
||
at universe level
|
||
u_1+1
|
||
which is not less than or equal to the inductive type's resulting universe level
|
||
max (u+1) (v+1)
|
||
ctorUnivTooBig.lean:41:2-41:27: error: invalid universe level in constructor 'Ex4.Member.head', parameter 'as' has type
|
||
List α
|
||
at universe level
|
||
u_1+1
|
||
which is not less than or equal to the inductive type's resulting universe level
|
||
u+2
|
||
ctorUnivTooBig.lean:47:2-47:27: error: invalid universe level in constructor 'Ex5.Member.head', parameter 'as' has type
|
||
List α
|
||
at universe level
|
||
u_1+1
|
||
which is not less than or equal to the inductive type's resulting universe level
|
||
2
|