If I have the following line:
Definition Foo : Set := list nat.
then I compile with no problems.
However, suppose I want to do the same with Coq.Lists.ListSet
, a library representing finite sets as lists:
(*Section first_definitions.
Variable A : Type.
Definition listset := list A.*)
Definition Bar : Set := listset nat.
I get the following error:
The term "listset nat" has type "Type" while it is expected to have type
"Set" (universe inconsistency).
listset
so that it lives in Set
instead of Type
? i.e. If I know I'm going to be using listset
with parameters of type Set
, is there a way to make it live in the Set
heirarchy somehow?listset
, but not for list
, when listset
is defined to be list
?Note: The actual type is called set
, but I've renamed it to listset
to avoid confusion with the sort Set
.
EDIT: =
replaced with :=
- Why does the error happen for listset, but not for list, when listset is defined to be list?
Because list
is a template universe polymorphic inductive definition (see About list.
), which in this case means that if list
is applied to a type in Set
, the result is still in Set
.
- Is there a way to "cast"
listset
so that it lives inSet
instead ofType
?
AFAIK, there is no way to make definitions template universe polymorphic, but you can make them universe polymorphic like so:
Polymorphic Definition listset (A : Type) : Type := list A.
Check listset nat : Set.
One more option is to use Set Universe Polymorphism
command so you won't need to prepend your definitions with the Polymorphic
keyword.
This feature has experimental status at the time of writing. And it does not apply retroactively, so I guess you would need to fork your own ListSet
.