This is probably super trivial, but I can't find any information about what the ':>' symbol means in Coq. What is the difference between: U : Type and W :> Type ?
Asked
Active
Viewed 183 times
4
-
It's a duplicate of [this question](https://stackoverflow.com/q/41191707/2747511). I used this query to find it: https://stackoverflow.com/search?q=%5Bcoq%5D+colon+greater+than – Anton Trunov Jul 18 '18 at 14:39
-
I apologize for the duplication. I searched with the symbol as is, not in words "colon greater than" – Yasmine Shaorda Jul 18 '18 at 16:17
-
No worries :) It can be hard to look for syntax. – Anton Trunov Jul 18 '18 at 16:28
1 Answers
2
It depends on where the symbol occurs. If it is inside a record declaration, for instance, it instructs Coq to add the corresponding record projection as a coercion.
Concretely, suppose that we have the following definition of a type with an operation:
Record foo := Foo {
sort :> Type;
op : sort -> sort -> sort
}.
We can now write the following function, which applies the operation of the structure twice:
Definition bar (T : foo) (x y z : T) : T :=
op foo x (op foo y z).
By using the :>
symbol, we have instructed Coq to read the definition of bar
as the following one:
Definition bar' (T : foo) (x y z : sort T) : sort T :=
op foo x (op foo y z).
That is, Coq understands that every T : foo
can appear in a position where it expects a type, by wrapping it around the sort
projection. Had we used :
instead of :>
, only bar'
would be accepted by Coq, and bar
would raise a type error.
![](../../users/profiles/1633770.webp)
Arthur Azevedo De Amorim
- 20,312
- 2
- 26
- 35
-
You might want to add a note about Class, where it instead means existing instance. Note also you can use > after Record to get the same effect on the constructor rather than the fields. – Jason Gross Jul 18 '18 at 14:28