If a function take Z
as arguments, it should also be possible to take any subset of Z
, right? For example, Zmod
takes two Z
and return Z
. Can I improve on this method with subset types without reimplementing it?
I want this:
Definition Z_gt0 := {z | z > 0}.
Definition mymod (n1 n2 : Z_gt0) :=
Zmod n1 n2.
But Coq complains that n1 is expected to have type Z
, of course. How can I make it work with Z_gt0
? Coerce?
This question is related to my other one here: Random nat stream and subset types in Coq
Edit: proj1_sig
might do the trick, thanks Coq IRC channel!