coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Vincent Laporte <vincent.laporte AT gmail.com>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Dependent match on two vectors
- Date: Wed, 10 Oct 2018 14:16:36 +0000
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=vincent.laporte AT gmail.com; spf=Pass smtp.mailfrom=vincent.laporte AT gmail.com; spf=None smtp.helo=postmaster AT mail-wr1-f51.google.com
- Ironport-phdr: 9a23:J9eYTx3vTVXMDlLPsmDT+DRfVm0co7zxezQtwd8Zse0TLfad9pjvdHbS+e9qxAeQG9mDtLQc06L/iOPJYSQ4+5GPsXQPItRndiQuroEopTEmG9OPEkbhLfTnPGQQFcVGU0J5rTngaRAGUMnxaEfPrXKs8DUcBgvwNRZvJuTyB4Xek9m72/q99pHPYQhEniaxba9vJxiqsAvdsdUbj5F/Iagr0BvJpXVIe+VSxWx2IF+Yggjx6MSt8pN96ipco/0u+dJOXqX8ZKQ4UKdXDC86PGAv5c3krgfMQA2S7XYBSGoWkx5IAw/Y7BHmW5r6ryX3uvZh1CScIMb7S60/Vza/4KdxUBLmiDoJOSA38G/UhMJ/gq1UrxC9qBJw2IPUfIKYOeBicq/Bc94XR2xMVdtRWSxbBYO8apMCAOUAPeZes4byuV0OrQejDgeqHuzv0jhIhmXq3aIkzu8sFh/G3A0mH90SrnvUqsn1OL0WUe+v1KnIyi/Db+9I1jrm54jIdwouofCIXb5qbcXRzkwvGhrDg16NqoLlJyuY2voRv2Wf9eZtVuKih3Q5pw1vvzSj3MchhpTRio4I1FzJ8T91zJgpKdGiTEN3fcSoHZVSuiycKoB4WNktQ3tytyY/0rAGuYC0fCwNyJk/wh7Qcf2Hc4yR7hPtTuadPC50hHxldb6inRqy/k+gyurzVsmwzllGtDZKkt7JtnwV1hzT7NaISudl80u/xTqC0xrf5+JELEwui6bXNYMtzqQwm5YOqUjDGzX5mETyjK+YbEUk/e2o5vz5YrXnoJ+TK5F7igfiMqg0nsywG/w4Mg8UX2iH5+uxz7Lj/UjjT7VLiv06iLXWsJffJcgDvK62HxdV0po/6xa4FzqpzNMYnWAeIF1ZfBKHkpPmNkrVIPH4CPe/m06jnC1qx/DAJL3hA4/CImLNkLf7Lv5B7BtXzxN2xtRC7bpVDKsAKbT9QBzfrtvdWyE4NQe5xfqvLNxl0ZkCVCrbHK6fO67UrRmM7/ooOfWBTIAQsTf5bfMi4qi93jcChVYBcPzxjtMsY3eiE6E+ehTLUT/Xmt4EVFwykE87Re3uhkeFVGcKNXm3VqM4oDo8DdD/VNuRdsWWmLWEmRyDMNhOfGkfUwKDFH7pc8OPXPJeMHvPcP8kqSQNUP2ac6Fk1Ryqs1Wnmb9uL+6R5TdB8Jy+jZ564OrckRx0/jtxXZyQ
- Openpgp: preference=signencrypt
Hi Vincent,
As a complement to Dominique’s suggestion, here is an other
implementation that do not require any (interactive) proof of false: you
can provide dummy values (of any inhabited type) in unreachable
branches. Also, by generalizing the recursive call before destructing
the second argument, you get a chance to type-check it again in the
final branch.
Fixpoint vprod (n: nat) (v: vec nat n) : vec nat n → nat :=
match v with
| vnil => λ _, 0
| vcons n' h t =>
λ v',
match v' in vec _ i return match i with O => unit | S j => (vec nat
j → nat) → nat end with
| vnil => tt
| vcons _ h' t' => λ rec, h * h' + rec t'
end (vprod n' t)
end.
Also, there are other definitions of the type vec that are much more
convenient to work with (e.g., a list packed with a proof that its size
is n).
Cheers,
--
Vincent.
- [Coq-Club] Dependent match on two vectors, Vincent Siles, 10/10/2018
- Re: [Coq-Club] Dependent match on two vectors, Dominique Larchey-Wendling, 10/10/2018
- Re: [Coq-Club] Dependent match on two vectors, Vincent Laporte, 10/10/2018
- Re: [Coq-Club] Dependent match on two vectors, Vincent Siles, 10/10/2018
- Re: [Coq-Club] Dependent match on two vectors, Dominique Larchey-Wendling, 10/10/2018
- Re: [Coq-Club] Dependent match on two vectors, Vincent Siles, 10/10/2018
- Re: [Coq-Club] Dependent match on two vectors, Vincent Laporte, 10/10/2018
- Re: [Coq-Club] Dependent match on two vectors, Dominique Larchey-Wendling, 10/10/2018
Archive powered by MHonArc 2.6.18.