coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Greg Morrisett <morrisett AT gmail.com>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] injectivity of inductive type implies False
- Date: Fri, 3 Mar 2017 08:25:30 -0500
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=morrisett AT gmail.com; spf=Pass smtp.mailfrom=morrisett AT gmail.com; spf=None smtp.helo=postmaster AT mail-ua0-f174.google.com
- Ironport-phdr: 9a23:siWcthHdlFBaof22A8ixi51GYnF86YWxBRYc798ds5kLTJ78p8uwAkXT6L1XgUPTWs2DsrQf2reQ6PyrBDVIyK3CmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBxrwKxd+KPjrFY7OlcS30P2594HObwlSijewZbN/IA+4oAjeucUbgZZuIbstxxXUpXdFZ/5Yzn5yK1KJmBb86Maw/Jp9/ClVpvks6c1OX7jkcqohVbBXAygoPG4z5M3wqBnMVhCP6WcGUmUXiRVHHQ7I5wznU5jrsyv6su192DSGPcDzULs5Vyiu47ttRRT1jioMKjw3/3zNisFojq1brhKvqRJ8zYDJfo+aKOFzcbnBcd4AX2dNQtpdWi5HD4ihb4UPFe0BPeNAoof8vVsBsxS+DhSrCuPo0D9InH723bYk3OQ9DQHNwQstH9cJsHTOttX1NbwSXv6pzKnU1jjDYPZW1i386IjMaBwuvfaMXbdpfMfX1EIhFBvFg02OpYD5Oz6ZzOcAvmiB4+Z+SO6iiXQrpxxzrzWgwMonl5PHiZgPyl/e8CV02IY1KsO8SE58edOkFYFftyCeN4dvX8MtWX1ktD80yrEbu5O2czIGyJsgxx7YZPyHd5aH7gj/W+aWJDd0nHNleLShiBau6UWs1PHwW82u3FtJridJiMfAum0P2hDJ98SKSPRw8l+k2TmV1gDT7u9EIVozlareM5Mhx7kwloAJsUTCBS/5hln2jLONe0Ur/+in8eXnYrH8qpCAMI90jxnyMr4ylcynHeQ4Lg8OUnCH9uS7zb3v5FH2QLFXjvItiaTZq5DbJcEDpqGjGQNV04Aj6wy+Dzi8ytgYk2MHfxp5f0eMiJGsMFXTKtj5C+2+ihKiimRF3ffDa5L7D5qFC3/Zirb6cKphoxpZzxApzMtS+458BbQIIfa1UUj04o+LRiQlOhC5lr60QO520ZkTDDqC
While I don't completely disagree with what you're saying, I think you're confusing abstraction and nominal typing. Abstraction supports the kind of refactoring and parallel development to which you're referring --- I can give a single point of definition that supports easy change. e.g.,
Definition complex : Set := (Q * Q).
Definition add (c1 c2:complex) := (* e.g., cartesian addition *)
... development using complex and add ...
or better yet:
Section Complex.
Parameter complex : Set.
Parameter add : complex -> complex -> complex.
... development using complex and add
End Complex.
since this prevents me from using the definitional equality for the complex type and add operation. A third option would be to abstract over a type-class, a module, etc. No nominal types needed.
And, since abstraction is (typically) scoped, it doesn't have to be "global" in the sense you suggested. In the Section example above, there's no conflict with the names I've chosen outside the scope of the Section. If anything, it's the *nominal* stuff that's problematic from a scoping standpoint since it doesn't alpha-vary the way that abstracted variables do.
Finally, nominal types require the meta-theory to support some notion of freshness or gensyming which makes the meta-theory imperative --- something that I find ironic in the context of type-theory. This, in turn, makes it difficult to support internalizing the meta-theory, and to support abstraction, requires us to add linguistic features such as sharing constraints (i.e., path aliases) in order to support certain naturally occurring patterns (e.g., the diamond pattern for module abstraction.)
And, when we want to write polytypic definitions (e.g., the deriving clauses for a Haskell data type, or the decidable_equality for a Coq inductive), we can't just write the definition once and for all based on structure.
I'll agree that some judicious use of nominal/generative types is useful in practice, but languages such as Java go overboard and fail to provide the structural definitions that are just as, if not more important. Personally, I wish that Coq, ML, Haskell, etc. would give me the option when declaring an inductive/datatype as to whether or not I want it to be generative. That is, I'd prefer to have a separation between an abstraction and a stamped, generative definition.
-Greg
On Fri, Mar 3, 2017 at 7:47 AM, Marco Servetto <marco.servetto AT gmail.com> wrote:
> The tension between structural and nominal typing is an old one. I would
> nominal typing as an extension [..] a nominal type is a type
> with a name (or a stamp) and that there is an implicit coercion between
> nominal types and types.
While many seams to fancy this encoding of nominal type, this approach
is failing to capture their most important feature: allowing proper
development using libraries (or just different teams).
This is hard in structural typing since it logically assumes that any
method/field name to have a global meaning.
In practice, this prevents from any semantic preserving "method
rename" refactor to be applied. The names of fields/methods are like
global variables that can not be alpha-renamed, and that seams to go
against the most fundamental principles of functional programming.
Note how putting fancy contracts on methods does not help here, since
the empty contract would still be a subtype of the chosen one, still
preventing alpha renaming (in a library setting)
Nominal(sub) typing in its purest form allows for each method to be
introduced in exactly one point (and possibly overridden/implemented
somewhere else)
In this way, that method name is properly logically scoped under such
(for example) interface declaration.
(Yes, Java and other "nominal" languages have some issues here and
there still preventing proper alpha renaming... :-( )
- Re: [Coq-Club] injectivity of inductive type implies False, Cristóbal Camarero Coterillo, 02/28/2017
- Re: [Coq-Club] injectivity of inductive type implies False, Abhishek Anand, 03/01/2017
- <Possible follow-up(s)>
- Re: [Coq-Club] injectivity of inductive type implies False, Cristóbal Camarero Coterillo, 03/02/2017
- Re: [Coq-Club] injectivity of inductive type implies False, Thorsten Altenkirch, 03/03/2017
- Re: [Coq-Club] injectivity of inductive type implies False, Marco Servetto, 03/03/2017
- Re: [Coq-Club] injectivity of inductive type implies False, Greg Morrisett, 03/03/2017
- Re: [Coq-Club] injectivity of inductive type implies False, Thorsten Altenkirch, 03/17/2017
- Re: [Coq-Club] injectivity of inductive type implies False, Marco Servetto, 03/20/2017
- Re: [Coq-Club] injectivity of inductive type implies False, Thorsten Altenkirch, 03/17/2017
- Re: [Coq-Club] injectivity of inductive type implies False, Greg Morrisett, 03/03/2017
- Re: [Coq-Club] injectivity of inductive type implies False, Marco Servetto, 03/03/2017
- Re: [Coq-Club] injectivity of inductive type implies False, Thorsten Altenkirch, 03/03/2017
Archive powered by MHonArc 2.6.18.