Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Subtyping and sig.

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Subtyping and sig.


chronological Thread 
  • From: "gallais @ ensl.org" <guillaume.allais AT ens-lyon.org>
  • To: Guillaume Yziquel <guillaume.yziquel AT citycable.ch>
  • Cc: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] Subtyping and sig.
  • Date: Tue, 21 Feb 2012 21:23:34 +0000
  • Authentication-results: mr.google.com; spf=pass (google.com: domain of sbleune AT gmail.com designates 10.204.153.26 as permitted sender) smtp.mail=sbleune AT gmail.com; dkim=pass header.i=sbleune AT gmail.com

Hi Guillaume,

Have you tried declaring a coercion ?

==================================
Definition pos := {n : nat | n >= 1}.
Definition posnat (p : pos) : nat := proj1_sig p.

Coercion posnat : pos >-> nat.

Definition suc (n : pos) := S n.
==================================

Cheers,

--
gallais



On 21 February 2012 21:07, Guillaume Yziquel
<guillaume.yziquel AT citycable.ch>
 wrote:
> Hi. Got a newbie question:
>
> How do you deal with 'subtyping' when using the { .. | .. } notation?
> Typically, how would one deal with this situation?
>
>        Coq < Definition pos := {n : nat | n >= 1}.
>        pos is defined
>
>        Coq < Definition suc (n : pos) := S n.
>        Toplevel input, characters 30-31:
>        > Definition suc (n : pos) := S n.
>        >                               ^
>        Error: In environment
>        n : pos
>        The term "n" has type "pos" while it is expected to have type
>        "nat".
>
> --
>     Guillaume Yziquel




Archive powered by MhonArc 2.6.16.

Top of Page