1

I'm trying to write the following ML code as Coq code: (This ML code comes from the book "computational category theory" by Ryheard and Burstall)

datatype ’a Set_Arrow = 
      set_arrow of (’a Set)*(’a->’a)*(’a Set)

fun set_s(set_arrow(a,_,_)) = a

This is what I came up with:  

Definition setArrow := (Set, Set -> Set, Set).

Definition setSource (arrow: setArrow ): Set :=
  match arrow with
    |(a,b,c) => a
  end.

and this is the error that came up:

Error: The term "setArrow" has type "(Type * Type * Type)%type"
which should be Set, Prop or Type.

I don't know why this error appears but I think is due to the way I constructed the tuple. I've been reading the documentation regarding tuples and how to construct new non-inductive datatypes in Coq, but I haven't found how to properly do it.

frafle
  • 15
  • 4

1 Answers1

0

The following worked for me

Definition setArrow := (Set * (Set -> Set) * Set)%type.

Definition setSource (arrow: setArrow ): Set :=
  match arrow with
    |(a,b,c) => a
  end.

* is the constructor for Pair at the type level, whereas , is how you build concrete instances

A Question Asker
  • 3,339
  • 7
  • 31
  • 39