4

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 ?

Yasmine Shaorda
  • 353
  • 1
  • 6

1 Answers1

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.

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