Comments on: A refinement type by any other name http://www.weaselhat.com/2015/03/16/a-refinement-type-by-any-other-name/ Thu, 27 Jan 2022 18:47:05 +0000 hourly 1 https://wordpress.org/?v=6.3.2 By: Frank Pfenning http://www.weaselhat.com/2015/03/16/a-refinement-type-by-any-other-name/comment-page-1/#comment-46639 Fri, 20 Mar 2015 01:10:08 +0000 http://www.weaselhat.com/?p=531#comment-46639 “Type refinement” is a long-term research program that I started in the late 1980’s. My goals in this enterprise have drifted somewhat over time, but I would summarize them as (a) capture more precise properties of programs that we already know to be well-typed in a simpler discipline in order to catch more errors, and (b) retain the good theoretical and practical properties of the simpler disciplines such as effective type checking. Of course, (c) you want all the other good things like usability, modularity, elegance, etc., just as for any system of types.

The first system we came up with was heavily influenced by four things: those pesky “inexhaustive pattern match” warnings in ML, John Reynolds’ work on intersection types that solved a deep problem for us, abstract interpretation, and order-sorted typing that was investigated for logic programming at the time. Since we (that is, Tim Freeman and I) didn’t see anything on the horizon satisfying (a), (b), and (c), we called them just “refinement types”. With a crystal ball, we should have called them “datasort refinements”, and that’s what I like to use now. “Index refinements” (the work with Hongwei Xi) were also designed to satisfy (a), (b), and (c), so they are an example of “type refinement” (the research program), but distinct from “refinement types” in their original meaning as datasort refinements.

General subset types aren’t quite an example of what we meant, because type checking with arbitrary subset types is both undecidable and impractical. But subset types {x:T|P(x)} could satisfy our goals as long as P is drawn from a tractable domain and the whole system that includes them hangs together.

]]>
By: Taro Sekiyama http://www.weaselhat.com/2015/03/16/a-refinement-type-by-any-other-name/comment-page-1/#comment-46635 Wed, 18 Mar 2015 05:04:08 +0000 http://www.weaselhat.com/?p=531#comment-46635 Yes, our work doesn’t answer Jana’s question (but I think it may indicate possibility for doing so). To relate “type refinement” to “datasort refinement” (in the sense of Freeman–Pfenning), I think we need at least two mechanisms. One is subtyping, which is pointed out by Jana. The other is an join-like operator of two type refinements. (A such operator isn’t trivial in our setting because each refinement can refine the datatype different from the other.)

]]>
By: Jana Dunfield http://www.weaselhat.com/2015/03/16/a-refinement-type-by-any-other-name/comment-page-1/#comment-46630 Tue, 17 Mar 2015 23:17:41 +0000 http://www.weaselhat.com/?p=531#comment-46630 I’ve never been able to understand the first paper, but I should probably keep trying.

I’ve only read an earlier version of the second paper, so take this with double the usual grains of salt, but I’m pretty sure it doesn’t have datasort refinements. They talk about “refinements on data constructors”, but I would say they’re translating refinement types (or index refinements) into refinement types. If you look at slist2 in the introduction, it still has {x:T|e} types; it’s just formulated differently than their slist1. (slist2 is very close to Xi’s DML. The difference is that in DML, you’d index slist2 by its smallest element, rather than talk about “head xs” inside e; you also need some kind of hack to get the effect of indexing SNil by +∞.) In fact, you can’t express the sortedness of a list with just datasorts; you’d need as many datasorts as you have integers.

They also don’t have subtyping; without subtyping, datasorts wouldn’t be worth much.

]]>
By: Michael Greenberg http://www.weaselhat.com/2015/03/16/a-refinement-type-by-any-other-name/comment-page-1/#comment-46629 Tue, 17 Mar 2015 12:53:58 +0000 http://www.weaselhat.com/?p=531#comment-46629 In reply to Jana Dunfield.

Atkey, Johann, and Ghani relate type refinements and dependent inductive types in When is a Type Refinement an Inductive Type?. More recently, Sekiyama, Nishida, and Igarashi move statically and dynamically between datasort refinements and index refinements in Manifest Contracts for Datatypes. I’m not sure if either of those quite fit the bill of what you’ve been wondering, but they’re both great papers in any case.

The confusion makes sense—datasort refinements are identifying subsets, index refinements are also identifying subsets. But the techniques involved in using the two are so different. I agree with you: it’s worth keeping the nomenclature clear.

]]>
By: Jana Dunfield http://www.weaselhat.com/2015/03/16/a-refinement-type-by-any-other-name/comment-page-1/#comment-46627 Tue, 17 Mar 2015 04:08:29 +0000 http://www.weaselhat.com/?p=531#comment-46627 This is perpetually vexing. I’ve had to explain in several different reviews that Freeman and Pfenning did not invent refinement types in the way that the term is now used. I think people see “Refinement types” in the title of that paper and assume it must be about {x:Ï„|P(x)}. (Aside: It’s been widely believed for years that you can encode a datasort refinement system as an index refinement system, but AFAIK no one’s actually done it.)

CMU’s invention of “type refinement” as a notion for a wide range of stuff including datasort refinements didn’t catch on. It’s possible that trying to simultaneously rename “refinement type” to “datasort refinement” *and* introduce a new term “type refinement” was doomed, but why did “refinement type” have to get mutated in place?

(By a strange coincidence, I was just thinking about whether indexed types *are* refinement types in the current sense. Or, rather, whether refinement types are indexed types. I think they probably are, via singletons and the guarded/asserting types from my thesis, but I haven’t worked it out, so I’m just blowing smoke, so far.)

]]>