coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Jacques-Henri Jourdan <jacques-henri.jourdan AT normalesup.org>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Differences between [let '(...)] and [let (...)]?
- Date: Mon, 17 Oct 2016 12:54:52 +0200
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=jacques-henri.jourdan AT normalesup.org; spf=Neutral smtp.mailfrom=jacques-henri.jourdan AT normalesup.org; spf=None smtp.helo=postmaster AT ulminfo.fr
- Ironport-phdr: 9a23:5tOxLBWLNCf+inX077U6FyUjHmnV8LGtZVwlr6E/grcLSJyIuqrYZR2Bt8tkgFKBZ4jH8fUM07OQ6PG6HzFaqsze+DBaKdoXCE9D0Z1X1yUbQ+e7SmTDZMbwaCI7GMkQHHRExFqcdXZvJcDlelfJqWez5zNBUj/2NA5yO/inUtWK15f/hKiO/MjYZBwNjz6ga5tzKg+3pEPfrJo4m4xnf4Q4wQLUr2ANW+lQ32IgB1WOhRr14I/k/pdo6jldoLch+shaUOP4eLkiQbVeJDIhKWU84MDwqAGFShGAsChPGl4KmwZFVlCWpCrxWY3853P3
An essential difference Hugo forgot to mention is that let (...) = ... in works with any inductive type with only one constructor (and not just with pair).
--
JH
On 10/17/2016 12:44 PM, Hugo Herbelin wrote:
Hi Jason,
On Thu, Oct 13, 2016 at 06:58:19PM +0000, Jason Gross wrote:
What's the difference between [let '(a, b) := x in y] and [let (a, b) := x inThey follow slightly different paths for type-checking. The
y]? I had in my head that the first was better, but the first results in
typechecking failures in 8.4 and anomalies in 8.6 (https://coq.inria.fr/bugs/
show_bug.cgi?id=5140), so now I'm curious what the actual differences betwen
them are.
former is directly interpreted as a "match" with one clause
(i.e. [let 'pattern := t in u] is syntactic sugar for
[match t with pattern => u end]). The latter is typed-checked
in an ad hoc way and translated to a "match" only afterwards.
A consequence is that the former case takes benefit of the more
general algorithm used in "match", as the following working
example shows:
Require Import Vector.
Import VectorNotations.
Definition hd n (v:t nat (S n)) := let 'a::_ := v in a.
As far as I understand the situation, the bug that you mention is
indirect: typing the former is demanding more from the
unification algorithm and, in #5140, this met a (actually already
fixed) bug in the type class inference algorithm.
As far as the precise example of destructing a single non nested
pair (in type "prod") is concerned, as you do, the extra power of
the "match" compilation algorithm may not be needed. So, the
second form might be as good. However, if ever some unification
of both forms had to be done, I believe that only the former
would be kept, with the latter being reduced to a particular case
of the former with an anonymous constructor (something like
re-interpreting [let (var1, ..., varn) := t in u] as
[let '(_ var1 ... varn) := t in u]).
Best,
Hugo
- [Coq-Club] Differences between [let '(...)] and [let (...)]?, Jason Gross, 10/13/2016
- Re: [Coq-Club] Differences between [let '(...)] and [let (...)]?, Hugo Herbelin, 10/17/2016
- Re: [Coq-Club] Differences between [let '(...)] and [let (...)]?, Jacques-Henri Jourdan, 10/17/2016
- Re: [Coq-Club] Differences between [let '(...)] and [let (...)]?, Hugo Herbelin, 10/17/2016
Archive powered by MHonArc 2.6.18.