coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Dominique Larchey-Wendling <dominique.larchey-wendling AT loria.fr>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Problem with dependent match statement
- Date: Fri, 15 Sep 2017 10:38:16 +0200
- Organization: LORIA
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.