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
29 lines
1.2 KiB
Text
29 lines
1.2 KiB
Text
struct1.lean:9:14-9:17: error: invalid resulting type, expecting 'Type _' or 'Prop'
|
|
struct1.lean:12:20-12:29: error: expected structure
|
|
struct1.lean:15:28-15:33: warning: field 'x' from 'B' has already been declared
|
|
struct1.lean:16:1-16:2: error: field 'x' has been declared in parent structure
|
|
struct1.lean:17:30-17:35: warning: duplicate parent structure 'A', skipping
|
|
struct1.lean:19:27-19:33: error: parent field type mismatch, field 'x' from parent 'B' has type
|
|
Bool : Type
|
|
but is expected to have type
|
|
Nat : Type
|
|
struct1.lean:30:1-30:2: error: field 'x' has already been declared
|
|
struct1.lean:33:1-33:2: error: field 'x' has been declared in parent structure
|
|
struct1.lean:36:6-36:10: error: type mismatch
|
|
true
|
|
has type
|
|
Bool : Type
|
|
but is expected to have type
|
|
Nat : Type
|
|
struct1.lean:39:5-39:9: error: omit field 'x' type to set default value
|
|
struct1.lean:42:12-42:16: error: type mismatch
|
|
true
|
|
has type
|
|
Bool : Type
|
|
but is expected to have type
|
|
Nat : Type
|
|
struct1.lean:45:0-45:13: error: invalid 'private' constructor in a 'private' structure
|
|
struct1.lean:48:0-48:15: error: invalid 'protected' constructor in a 'private' structure
|
|
struct1.lean:51:0-51:19: error: invalid 'protected' field in a 'private' structure
|
|
S : Type
|
|
S.mk2 (x : Nat) : S
|