coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: "Terrell, Jeffrey" <jeffrey.terrell AT kcl.ac.uk>
- To: "coq-club AT inria.fr" <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] Problem with dependent match statement
- Date: Fri, 15 Sep 2017 09:12:40 +0000
- Accept-language: en-GB, en-US
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=jeffrey.terrell AT kcl.ac.uk; spf=Pass smtp.mailfrom=jeffrey.terrell AT kcl.ac.uk; spf=Pass smtp.helo=postmaster AT EUR01-VE1-obe.outbound.protection.outlook.com
- Ironport-phdr: 9a23:jSLEsRBAvotw4EA7zrMTUyQJP3N1i/DPJgcQr6AfoPdwSP3zrsbcNUDSrc9gkEXOFd2Crakb26yL6+jJYi8p39WoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6i760TlHUB74LE9+Ivn/Mo/UlcW+ke6osdWHaAJRwTG5fLlaLROsrAyXuNNA0qV4LaNkgCfEuGFFf+ASjUFlK1yJkge2rpOy8ZBt6SlB/e4s7dRNVaHSfK88C7VTSiklZTNmrPb3vAXOGFPcrkAXVX8bx0JF
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
Thanks everyone.
Regards,
Jeff.
Sent from my iPhone
> On 15 Sep 2017, at 09:38, Dominique Larchey-Wendling
> <dominique.larchey-wendling AT loria.fr>
> wrote:
>
> May I suggest writing tabulate in "proof style" and then look
> at the generated code :
>
> Inductive Fin : nat -> Set :=
> fzero : forall n : nat, Fin (S n) |
> fsuc : forall n : nat, Fin n -> Fin (S n).
>
> Inductive Vec (A : Set) : nat -> Set :=
> vzero : Vec A 0 |
> vcons : forall n : nat, A -> Vec A n -> Vec A (S n).
>
> Fixpoint tabulate (n : nat) (A : Set) (f : Fin n -> A) { struct n } :
> Vec A n.
> Proof.
> destruct n as [ | n ].
> exact (@vzero _).
> apply vcons.
> exact (f (fzero _)).
> exact (tabulate _ _ (fun x => f (fsuc _ x))).
> Defined.
>
> Print tabulate.
>
> You get exactly what Jan-Oliver Kaiser wrote:
>
>> Fixpoint tabulate (n : nat) (A : Set) (f : Fin n -> A) : Vec A n :=
>> match n as n0 return (Fin n0 -> A) -> (Vec A n0) with
>> | 0 => fun _ => vzero A
>> | S m => fun f => vcons A m (f (fzero m)) _
>> end f.
>
> More generally, with dependent pattern matching, using
> tactics to design computational terms could give very
> useful hints.
>
> Best,
>
> Dominique
>
- [Coq-Club] Problem with dependent match statement, Terrell, Jeffrey, 09/15/2017
- RE: [Coq-Club] Problem with dependent match statement, Soegtrop, Michael, 09/15/2017
- Re: [Coq-Club] Problem with dependent match statement, Jan-Oliver Kaiser, 09/15/2017
- Re: [Coq-Club] Problem with dependent match statement, Dominique Larchey-Wendling, 09/15/2017
- Re: [Coq-Club] Problem with dependent match statement, Terrell, Jeffrey, 09/15/2017
- RE: [Coq-Club] Problem with dependent match statement, Soegtrop, Michael, 09/15/2017
- Re: [Coq-Club] Problem with dependent match statement, Dominique Larchey-Wendling, 09/15/2017
- RE: [Coq-Club] Problem with dependent match statement, Soegtrop, Michael, 09/15/2017
- Re: [Coq-Club] Problem with dependent match statement, Terrell, Jeffrey, 09/16/2017
- RE: [Coq-Club] Problem with dependent match statement, Soegtrop, Michael, 09/18/2017
- Re: [Coq-Club] Problem with dependent match statement, Terrell, Jeffrey, 09/21/2017
- RE: [Coq-Club] Problem with dependent match statement, Soegtrop, Michael, 09/22/2017
- Re: [Coq-Club] Problem with dependent match statement, Terrell, Jeffrey, 09/16/2017
- RE: [Coq-Club] Problem with dependent match statement, Soegtrop, Michael, 09/15/2017
- Re: [Coq-Club] Problem with dependent match statement, Dominique Larchey-Wendling, 09/15/2017
- Re: [Coq-Club] Problem with dependent match statement, Dominique Larchey-Wendling, 09/15/2017
Archive powered by MHonArc 2.6.18.