coq-club AT inria.fr
Subject: The Coq mailing list
List archive
[Coq-Club] Coq 8.2: detection of impossible clause in dependent pattern-matching
chronological Thread
- From: Nadeem Abdul Hamid <nadeem AT acm.org>
- To: coq-club AT pauillac.inria.fr
- Subject: [Coq-Club] Coq 8.2: detection of impossible clause in dependent pattern-matching
- Date: Wed, 29 Oct 2008 23:19:36 -0400
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:content-type:content-transfer-encoding :mime-version:subject:date:x-mailer:sender; b=N1kwEOR8JWSHZuM90QJyByrSjU0llZWNFFwEyrrYnwm86mjhLepbz7jPP5EIea2PzO wx6+wOlWdMkbQLfKZ8VpCPHGMEFLcBIBeSuIVlnDh+ISs9gceq2xu6xa/b8IzpcNI7tZ gpc4s4i9zi9vprjGgDwOdBEfmVtxfSZ9lqJgM=
- List-archive: <http://pauillac.inria.fr/pipermail/coq-club/>
This is a nice improvement, as I just discovered with the following example:
Inductive vec (A:Set) : nat -> Set :=
| vnil : vec A 0
| vcons : forall n, A -> vec A n -> vec A (S n).
Definition vhead (A:Set) (n:nat) (v:vec A (S n)) : A :=
match v with
| vnil => 0 (* never happen -- can return anything!!! *)
| vcons _ b _ => b
end.
My question is: how does this work? I tried to look in the manual but couldn't find any documentation for this behavior. It seems like you can put any return value in the vnil case and it infers a dependent return type; but it used to be you had to use some messy reasoning about absurdity of equalities or something to get the match expression to typecheck with all the cases...
This new feature is pleasantly surprising, but it would be even nicer now to be able to just not have to list that case in the matching at all, as in:
Definition vhead (A:Set) (n:nat) (v:vec A (S n)) : A :=
match v with
| vcons _ b _ => b
end.
I know, you try to make people happy and they only ask for more...
Thanks, :-)
--- nadeem
- [Coq-Club] Coq 8.2: detection of impossible clause in dependent pattern-matching, Nadeem Abdul Hamid
Archive powered by MhonArc 2.6.16.