feat: infer Prop
for inductive
/structure
when defining syntactic subsingletons
#5517
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A
Prop
-valued inductive type is a syntactic subsingleton if it has at most one constructor and all the arguments to the constructor are inProp
. Such types have large elimination, so they could be defined inType
orProp
without any trouble, though users tend to expect that such types define aProp
and need to learn to insert: Prop
.Currently, the default universe for types is
Type
. This PR adds a heuristic: if a type is a syntactic subsingleton with exactly one constructor, and the constructor has at least one parameter, then theinductive
command will prefer creating aProp
instead of aType
. Forstructure
, we ask for at least one field.More generally, for mutual inductives, each type needs to be a syntactic subsingleton, at least one type must have one constructor, and at least one constructor must have at least one parameter. The motivation for this restriction is that every inductive type starts with a zero constructors and each constructor starts with zero fields, and stubbed-out types shouldn't be
Prop
.Thanks to @arthur-adjedj for the investigation in #2695 and to @digama0 for formulating the heuristic.
Closes #2690