-
Notifications
You must be signed in to change notification settings - Fork 450
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
structure
sometimes makes a Type
not a Prop
.
#2690
Comments
Looking into the related implementation, this seems to be an intended design decision and not a bug. In particular, some classes such as |
I don't see how you can read intentionality into that uncommented code. Certainly this is the function that would need to be changed and it does not do what is suggested in this issue, but there is no indication that this is a deliberate design or that it is not written in this way to avoid a certain other issue. |
I first experimented with having the same rules apply to both inductives and inductives (it was also easier to do so since they shared the same bit of code),
That bit of code seems to have been made with the purpose of making things live in |
Things should live in Type as a fallback. But the fallback doesn't need to be taken if there is <= 1 constructor and all the constructor arguments are Props or recursive, since then it would be a large eliminating type even if it lived in Prop. |
That was my reasoning as well, but that would change not only the type of structures, but also of a lot of inductives, so I'm hesitant on doing that. |
I'm inclined to lift the universe using |
…c subsingletons A `Prop`-valued inductive type is a syntactic subsingleton if it has at most one constructor and all the arguments to the constructor are in `Prop`. Such types have large elimination, so they could be defined in `Type` or `Prop` without any trouble, though users tend to expect that such types define a `Prop` and need to learn to insert `: Prop` manually. 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 the `inductive` command will prefer creating a `Prop` instead of a `Type`. For `structure`, 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. Thanks to @arthur-adjedj for the investigation in leanprover#2695. Closes leanprover#2690
…c subsingletons A `Prop`-valued inductive type is a syntactic subsingleton if it has at most one constructor and all the arguments to the constructor are in `Prop`. Such types have large elimination, so they could be defined in `Type` or `Prop` without any trouble, though users tend to expect that such types define a `Prop` and need to learn to insert `: Prop` manually. 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 the `inductive` command will prefer creating a `Prop` instead of a `Type`. For `structure`, 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. Thanks to @arthur-adjedj for the investigation in leanprover#2695. Closes leanprover#2690
…c subsingletons (#5517) A `Prop`-valued inductive type is a syntactic subsingleton if it has at most one constructor and all the arguments to the constructor are in `Prop`. Such types have large elimination, so they could be defined in `Type` or `Prop` without any trouble, though users tend to expect that such types define a `Prop` 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 the `inductive` command will prefer creating a `Prop` instead of a `Type`. For `structure`, 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
Prerequisites
Description
Structures which should be
Prop
s (because all their fields are Props) sometimes come out asType
s and Lean needs to be explicitly told that they areProp
s.Steps to Reproduce
Expected behavior:
foo α : Prop
Actual behavior:
foo α : Type
Versions
This bug has existed since Lean 3 and the community has been using the obvious workaround for years ("when you randomly notice an instance of this, typically because a new user is confused on Zulip, just tell the structure that it's a Prop explicitly")
[Output of
lean --version
in the folder that the issue occured in]Lean (version 4.2.0-rc1, commit a62d2fd, Release)
[OS version]
Ubuntu 22.04
Impact
Very minor, occasionally confusing, little more than annoying once you know about it.
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
The text was updated successfully, but these errors were encountered: