-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: mutual structures #4182
Comments
Lean (kernel included) considers an inductive type to be "structure-like" iff it is non-recursive, not indexed, and has a single constructor. Because structure types benefit from special treatments such as having primitive projections and eta-conversion, it would be unwise to blindly adopt that RFC. In particular, eta-conversion on recursive/mutual structures can lead to a form of undecidability of defeq that's quite hard to deal with. One possibility to handle this feature would be to allow the |
I felt silly once having had to write the projection functions for a almost-structure (it was recursive) by hand because I couldn't see |
Perhaps Lean could benefit from dissociating between structures and non-recursive structures then, including in the kernel. In particular, a recursive structure , could still benefit from having primitive projections, which are great for performance, without having eta-conversion. |
@arthur-adjedj can you enlighten me on how does structure eta conversion gets undecidable? |
Also, I believe some lean libraries already offer a way to automatically generate "projections" on non-structures, notably this one |
Consider the following (recursive) structure: structure Foo where
foo : Foo When comparing two arbitrary neutral terms, i.e variables
I believe Agda supports recursive records, as well as eta-expansion, and also uses typed conversion, which allows it to eta-expand neutrals. Does anyone know how it handles this issue ? |
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
Proposal
I think structures should work in mutual blocks. #2587 reports an error message related to this feature, and everyone commented in the issue expected this to work (I expect this to fulfill the "community feedback" requirement), but the issue is closed as it's not about making it work.
A simple example use case can also be found in #2587.
Impact
Add 👍 to issues you consider important. If others benefit from the changes in this proposal being added, please ask them to add 👍 to it.
The text was updated successfully, but these errors were encountered: