coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Jan-Oliver Kaiser <janno AT mpi-sws.org>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Problem with dependent match statement
- Date: Fri, 15 Sep 2017 10:19:58 +0200
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=janno AT mpi-sws.org; spf=Pass smtp.mailfrom=janno AT mpi-sws.org; spf=None smtp.helo=postmaster AT jupiter.mpi-klsb.mpg.de
- Ironport-phdr: 9a23:6J9nTRLrAKROP9i3lNmcpTZWNBhigK39O0sv0rFitYgXL/TxwZ3uMQTl6Ol3ixeRBMOAtKIC1rKempujcFJDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBWB6kG1uDUVA1D0MRd/DuXzAI/bycqthM6o/JiGQQxOwR25YK1/Nl2VpATKu9Ne1YlrLKA24h7Roz5TZP8QwnlncwHA1y3g79u9qcYwux9bvOgsopZN
The easiest way I know to make Coq notice the correct type of f is this:
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.
Or, more succinctly:
Fixpoint tabulate (n : nat) (A : Set) : forall (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.
I don't know how to complete the definition, though.
Best,
Janno
On 09/15/2017 08:49 AM, Terrell, Jeffrey wrote:
Hi,
In the second branch of the match statement below, I expected f to be of type Fin
(S m) -> A. However, it’s reported to be of type Fin n -> A.
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) : Vec A n :=
match n as n0 return (Vec A n0) with |
0 => vzero A |
S m => vcons A m (f (fzero m)) ...
end.
From a purely syntactic point of view, I can see why this is the case.
However, I’m not sure how to obtain a function of the required type to apply
to (fzero m).
Regards,
Jeff.
- [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.