-
Notifications
You must be signed in to change notification settings - Fork 637
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
Don't make Prop inductives template to control eliminator generation #18867
Conversation
@coqbot run full ci |
probably should do this one in this PR, the other points can wait for followups |
60b725e
to
87946ff
Compare
Should be in reasonable shape now. |
Instead we register those Prop inductives which should have dependent eliminators in a table. Next: - separate the code from compute_template_inductive - provide a way for users to declare explicit Prop inductives with default dependent elim (eg `#[dep_elim] Inductive foo : Prop := .` and/or some option) - stop automatically putting inductives in Prop when declared with explicit Type (with deprecation phase)
AFAICT it's only incorrect for sort poly inductives and the code is probably broken for sort poly inductives but it's still more robust this way.
(the candidate set is what varies)
This slightly changes behaviour: an inductive which is lowered to Prop with explicit `#[universes(template=no)]` or auto template turned off now has default dependent eliminators. It is unlikely that anyone relies on this. This also makes record syntax inductives use the default dep elim table (although by default it's unused since records don't generate schemes by default) (NB univ poly inductives uses lbound=Set so never lower to Prop (`not (check_leq evd Sorts.set s)` in `is_prop_candidate`) and so are unchanged)
This makes it match destArity such that `if isArity c then destArity c` is safe.
It's only used for Reduction.dest_arity in a branch where we just checked Term.isArity, so we can use Term.destArity instead.
No need to pass an optional pointer to the inferred sort (which is incorrect when lowering to Prop) around, we just need a boolean to tell if the syntax was the kind we allow for template poly. This allows to get rid of special handling of prop lowering in the auto template branch of compute_template_inductive. This changes behaviour for records: ~~~coq Polymorphic Definition typ := Type. Record foo (A:Type) : typ := { x : A }. ~~~ would be made template poly and now is not.
a2fb782
to
d386865
Compare
ping @coq/vernac-maintainers |
I forgot to assign... Even though I'm not a vernac maintainer officially I think this is right in my ballpark. |
PS there has been some talk about relaxing the typing rules for template inductives so that they don't induce constraints with the default instance when fully applied (eg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a welcome cleanup that paves the way out of the template tarpit.
@coqbot merge now |
@ppedrot: Please take care of the following overlays:
|
Adapt to coq/coq#18867 (inductive_sort_family doesn't exist)
Adapt to coq/coq#18867 (cominductive returns default dep elim)
Instead we register those Prop inductives which should have dependent eliminators in a table.
Next:
separate the code from compute_template_inductivedone#[dep_elim] Inductive foo : Prop := .
and/or some option)Overlays: