coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Adam Chlipala <adamc AT hcoop.net>
- To: Jeff Vaughan <jeff AT seas.harvard.edu>
- Cc: Coq List <coq-club AT pauillac.inria.fr>
- Subject: Re: [Coq-Club] Pattern matching on vectors
- Date: Thu, 08 Oct 2009 19:00:01 -0400
- List-archive: <http://pauillac.inria.fr/pipermail/coq-club/>
Jeff Vaughan wrote:
Vectors are defined as follows:
Set Implicit Arguments.
Inductive vector (A: Type): nat -> Type :=
| vnil: vector A O
| vcons: forall len, A -> vector A len -> vector A (S len).
Implicit Arguments vnil [A].
And I would like to prove, for instance, this lemma:
Lemma openVector: forall A n (v: vector A (S n)),
exists a, exists v0, v = vcons a v0.
This is one of my favorite examples, because it's easy to prove directly with a proof term:
Definition openVector A n (v: vector A (S n))
: exists a, exists v0, v = vcons a v0 :=
match v in vector _ N return match N return vector A N -> Prop with
| O => fun _ => True
| S n => fun v => exists a, exists v0, v = vcons a v0
end v with
| vnil => I
| vcons _ a v0 => ex_intro _ a (ex_intro _ v0 (refl_equal _))
end.
I could try to "explain" what's going on here, but it's probably better to treat this code as a koan and come to your own understanding. :)
- [Coq-Club] Pattern matching on vectors, Jeff Vaughan
- Message not available
- Re: [Coq-Club] Pattern matching on vectors, Jeff Vaughan
- Re: [Coq-Club] Pattern matching on vectors, Adam Chlipala
- Re: [Coq-Club] Pattern matching on vectors,
Laurent Théry
- Re: [Coq-Club] Pattern matching on vectors,
Benedikt . AHRENS
- Re: [Coq-Club] Pattern matching on vectors, Jeff Vaughan
- Re: [Coq-Club] Pattern matching on vectors, Matthieu Sozeau
- Re: [Coq-Club] Pattern matching on vectors for dummies, Jean-Francois Monin
- Re: [Coq-Club] Pattern matching on vectors,
Benedikt . AHRENS
- Re: [Coq-Club] Pattern matching on vectors, Adam Koprowski
- Message not available
Archive powered by MhonArc 2.6.16.