Integrating Dependent and Linear Types

This wasn't posted yet, that I could find. Sorry if this is a dupe. Neelk doesn't self-promote, I guess. :-)

Abstract

In this paper, we show how to integrate linear types with type dependency, by extending the linear/non-linear calculus of Benton to support type dependency. Next, we give an application of this calculus by giving a proof-theoretic account of imperative programming, which requires extending the calculus with computationally irrelevant quantification, proof irrelevance, and a monad of computations. We show the soundness of our theory by giving a realizability model in the style of Nuprl, which permits us to validate not only the B laws for each type, but also the n laws.

These extensions permit us to decompose Hoare triples into a collection of simpler type-theoretic connectives, yielding a rich equational theory for dependently-typed higher-order imperative programs. Furthermore, both the type theory and its model are relatively simple, even when all of the extensions are considered.

Personally I find the abstract a little over my head, but am excited when I read stuff like, "We would like to fully integrate dependent and linear type theory. Linear type theory would permit us to extend the Curry-Howard correspondence to (for example) imperative programs, and type dependency permits giving very precise types to describe the precise functional behavior of those programs."

Funny how the 'Fair Reactive' paper was just recently mentioned on the ATS list.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Proof-irrelevance modality

What an awesome use of a proof-irrelevance modality to introduce propositions that depend on linear resources. That'll open up a world of design techniques for me.

Our preliminary experience is that equality is the most challenging issue for us. [...] another possibility is to move to something like observational type theory.

Very recently, Vàkàr has proposed an extension of Linear LF [...] and in future work we will see if his semantics applies to our syntax.

I was actually going to suggest connections to observational typing or Linear LF semantics, but I see that's been anticipated. :)

Thanks...

...linear proof irrelevance shows up all over the place in systems aimed at practical use: ATS, Fstar, alias types, typestate systems, and the calculus of capabilities all have some version of linear proof irrelevance.

In this regard, our contribution is realizing that since lots of people have had this idea, it's worth formalizing as an independent concept. :)

I didn't read carefully

Oops, I misinterpreted what was going on with this technique.

I've been hoping for a system that would unify dependent typing with a more resource-conscious model. If type information is a resource available at compile time, then since types depend on type information, types must depend on resources. Linear logic encourages a certain interpretation of "resource," but I haven't seen a system where a type can depend on a linear variable.

As I went casually through this paper, I think in my wishful thinking, I misunderstood the [A] syntax to mean "Linear variables can be abused in here because this expression is strictly hypothetical." I misinterpreted [e |-> X] as an intuitionistic term with a linear subterm e, and it's actually the opposite of that.

...linear proof irrelevance shows up all over the place in systems aimed at practical use: ATS, Fstar, alias types, typestate systems, and the calculus of capabilities all have some version of linear proof irrelevance.

Thanks a lot for the list. I did read the part about ATS in your paper, but in my misinterpretation, I didn't make the connection.

Idris too

Idris (a dependently typed programming language) also quite recently got support for uniqueness types which I believe is similar to linear types. I don't know enough about this topic to make a comparison, but maybe some expert can give some insight about the differences and the benefits of either solution.

concurrent clean

see Concurrent Clean re: uniqueness types documentation. too bad it is dead. (the ide it came with was pretty sad, anyway, in my limited experience.)

See...

I've been hoping for a system that would unify dependent typing with a more resource-conscious model. If type information is a resource available at compile time, then since types depend on type information, types must depend on resources. Linear logic encourages a certain interpretation of "resource," but I haven't seen a system where a type can depend on a linear variable.

Both Fstar and Spiwack's Dependent L permit restricted forms of what you want. Fstar includes a proof-irrelevant universe, and proof-irrelevant types may mention linear variables (even nonlinearly). Dependent L permits types to depend upon (roughly speaking) linear values. For reasons which are presently unclear to me, both of these setups seem to rely upon the evaluation order being explicit.

Linearity and evaluation order

Both Fstar and Spiwack's Dependent L permit restricted forms of what you want.

Awesome! I'll go have a look at some point.

For reasons which are presently unclear to me, both of these setups seem to rely upon the evaluation order being explicit.

I'm obviously more than a little overeager to say ill-informed things about this stuff, but I'll say that makes sense to me. If the evaluation order is sequentialized, then we essentially have an implicit conduit for carrying linear resources through the steps of evaluation, and this conduit can be the store-passing basis for some imperative side effects. For instance, we can have operators that take an in-out linear variable and do anything to it, since any two in-out variable occurrences have a deterministic ordering. To restore referential transparency, it might be useful to design the syntax so the only in-out variables are for things that leave the linear resource alone anyway, merely siphoning off some information about its current state.

If I want to be able to treat information itself as a resource, even this siphoning is a form of impurity for me. I like the idea of siphoning only for proof-irrelevant purposes, i.e. at a time when the siphoned information's existence is still merely hypothetical. Sounds like I should look at Fstar and Dependent L.

Speaking of evaluation order, the paper contains this:

If we had given a general fixpoint operator fix x. e, even with an irrelevant termination metric, then looping computations would be definable. (This is connected to the ability of intersection types to detect evaluation order.)

This paper taught me some things about intersection types already, but how do they detect evaluation order?

Linearity and evaluation order, continued

To restore referential transparency, it might be useful to design the syntax so the only in-out variables are for things that leave the linear resource alone anyway, merely siphoning off some information about its current state.

I've realized I don't know why evaluation order would matter here after all.

Evaluation order matters for the more impure version of what I was talking about. However, if a variable is never imperatively re-bound, then all its occurrences do indeed refer to an unambiguous moment in the linear resource's history even without the help of evaluation order.

Both Fstar and Spiwack's Dependent L permit restricted forms of what you want.

I looked into these a little this past week, and I'll probably come back to them. Fstar in particular looks like just what I was asking for.

I'm still figuring out the kind of information control I'm looking for. After I looked into Fstar, my exploration wandered into bunched typing and hybrid logic. I've started implementation of something that combines multiplicative linear logic and hybrid logic. I shouldn't make any claims yet, but it seems to be clear sailing for now. :)