# judgmental subtyping systems with intersection types and modal 2012-07-02آ judgmental subtyping...

Post on 27-Apr-2020

0 views

Embed Size (px)

TRANSCRIPT

Noname manuscript No. (will be inserted by the editor)

Judgmental subtyping systems with intersection types and modal types

Jeongbong Seo · Sungwoo Park

Received: date / Accepted: date

Abstract We study how to extend modal type systems based on modal logic S4 or S5 with a subtyping system based on intersection types. In the presence of four type constructors →, ∧ , �, and 3, the traditional approach using a binary subtyping relation does not work well because of lack of orthogonality in subtyping rules and presence of a transitivity rule. We adopt the idea from the judgmental formulation of modal logic [15] and use subtyping judgments whose definitions express those notions internalized into type constructors directly at the level of judgments. The resultant judgmental subtyping systems admit cut rules similarly to a sequent calculus for intuitionistic logic and play a key role in designing and verifying the relational subtyping systems based on the binary subtyping relation. We use the proof assistant Coq to prove the admissibility of the cut rules and the equivalence between the two kinds of subtyping systems. The lesson from our study is that by using subtyping judgments instead of the binary subtyping relation, we can overcome the limitation usually associated with the syntactic approach to formulating subtyping systems.

1 Introduction

In designing programming languages for network environments, the spatial interpretation of modal logic has inspired a number of type systems via the Curry-Howard correspondence. The basic idea is to interpret necessity modal types �A as types of mobile terms which are valid at every node in the network, and possibility modal types 3A as types of local terms which are valid at some node in the network. The underlying modal logic, such as S4 or S5,

Jeongbong Seo · Sungwoo Park Pohang University of Science and Technology San 31 Hyojadong Namgu Pohang Gyungbuk, 790-784, Republic of Korea Tel.: +82-54-279-2386 Fax.: +82-54-279-2299 E-mail: {baramseo,gla}@postech.ac.kr

2

regulates the interaction between modal types, and we obtain via the Curry- Howard correspondence a modal type system that is suitable for distributed programming languages such as λrpc[8] and Lambda 5 [12] or task description languages such as MTSN (Modal Type System for Networks) [2].

This paper studies how to extend such modal type systems based on modal logic S4 or S5 with a subtyping system based on intersection types. An inter- section type A∧B is inhabited by those terms that can have both types A and B simultaneously, and thus has A and B as its supertypes. It provides a lim- ited form of polymorphism that is a good compromise between expressiveness and simplicity in the presence of modal types, as illustrated below:

– A distributed programming language may assign a modal intersection type �((int→ int) ∧ (float→float)) to a mobile polymorphic function in order to specialize it for two base types int and float. Assigning a modal polymorphic type �(∀α.α→α) instead would increase the utility of the function, but would also considerably complicate type inference because polymorphic types are no longer in prenex form.

– A task description language may use a modal intersection type 3((PDF→PS) ∧ (PS→PDF)) for a local service that converts between PDF and PS files. Without intersec- tion types, we would instead use a modal sum type 3((PDF ∨ PS)→(PDF ∨ PS)), which is less accurate.

Thus a subtyping system based on intersection types is particularly useful as an extension to modal type systems into which a general form of polymorphism is too expensive to incorporate.

The use of a subtyping relation A ≤ B as in the traditional approach, how- ever, is not an ideal decision for designing such a subtyping system because two inherent problems, lack of orthogonality in subtyping rules and presence of a transitivity rule, are seriously exacerbated by four independent type con- structors (→ , ∧ , �, and 3). Lack of orthogonality arises because a single subtyping rule may have to analyze multiple type constructors that interact with each other. When mixing the four type constructors, however, we find it difficult even to recognize the interaction between different type constructors, let alone to propose a corresponding subtyping rule. In our study of a subtyp- ing system based on modal logic S4, for example, we discover the need for the following subtyping rule only during the proof of its equivalence with another subtyping system:

�C ∧A ≤ B �C ∧3A ≤ 3B R-box-dia-K

Moreover the use of a subtyping relation gives rise to distributivity rules, in conjunction with which a transitivity rule makes it particularly difficult to reason about the subtyping system and to derive a decision procedure for the subtyping relation.

Instead of using a binary relation between two types, we adopt the idea from the judgmental formulation of modal logic [15] and use subtyping judg- ments whose definitions express those notions internalized into type construc- tors directly at the level of judgments and thus do not depend on any type

3

constructors. Our subtyping system based on modal logic S4 uses two subtyp- ing judgments where subtyping contexts Γ and Σ are collections of types:

– A subtyping judgment Γ | Σ � C can be interpreted as corresponding to a subtyping relation (

∧ Ai∈Γ �Ai) ∧ (

∧ Bj∈Σ Bj) ≤ C and thus exploits those

notions internalized into � and ∧. – Another subtyping judgment Γ | Σ ÷ C can be interpreted as correspond-

ing to a subtyping relation ( ∧ Ai∈Γ �Ai) ∧ (

∧ Bj∈Σ Bj) ≤ 3C and thus ex-

ploits those notions internalized into �, 3, and ∧.

Our subtyping system based on modal logic S5 uses a single subtyping judg- ment ∆ | Γ | Σ � C which uses ∆ as a collection of subtyping contexts and can be interpreted as corresponding to a subtyping relation

( ∧

Σk∈∆ 3(

∧ Ckl ∈Σk

Ckl )) ∧ ( ∧ Ai∈Γ

�Ai) ∧ ( ∧

Bj∈Σ Bj) ≤ C.

By designing every subtyping rule so that it deals with at most one type constructor, we obtain a subtyping system in which all subtyping rules are orthogonal. Transitivity is also implicit and deriving a decision procedure is straightforward.

Given a set of type constructors and their logical properties, we formulate two subtyping systems: a relational subtyping system using the subtyping re- lation A ≤ B and a judgmental subtyping system using subtyping judgments. The relational subtyping system explicitly includes a transitivity rule whereas the judgmental subtyping system admits cut rules similarly to a sequent cal- culus for intuitionistic logic. Then we prove the admissibility of the cut rules and the equivalence between the two subtyping systems. In addition, we use the proof assistant Coq to mechanize these proofs.

Instead of presenting all subtyping systems at once, we develop pairs of relational and judgmental subtyping systems in an incremental way.

– We begin with base subtyping systems which include only two type con- structors → and ∧ (Section 2). The study of base subtyping systems illustrates the disadvantage of the relational subtyping system and the dif- ficulty of embedding the transitivity rule, as well as the advantage of the judgmental subtyping system due to orthogonality in subtyping rules and the admissibility of the cut rule. It also outlines the development of the metatheory in subsequent subtyping systems, in particular the proof of the admissibility of the cut rules.

– Next we extend the base subtyping systems to develop subtyping systems based on modal logic S4 (Section 3), first considering modalities � and 3 individually (Sections 3.1 and 3.2) and then putting both together to account for their interaction (Section 3.3). Here we explain how axioms in modal logic S4 relate to subtyping relations, and show that the judgmental subtyping system is easier to verify than the relational subtyping system.

– Finally we develop subtyping systems based on modal logic S5 (Section 4). Here we reuse the relational subtyping system based on modal logic S4

4

Base relational subtyping system with → and ∧ :

A ≤ A R-refl A ≤ C C ≤ B

A ≤ B R-trans

C ≤ A B ≤ D A→B ≤ C→D R-fun (A→B) ∧ (A→C) ≤ A→(B ∧ C) R-fun-dist

A ∧B ≤ A R-and-l1 A ∧B ≤ B R-and-l2 A ≤ B A ≤ C A ≤ B ∧ C R-and-r

Extension with � in modal logic S4:

�A ≤ A R-box-T �A ≤ ��A R-box-4 A ≤ B

�A ≤ �B R-box-K

�A ∧ �B ≤ �(A ∧B) R-box-dist

Extension with 3 in modal logic S4:

A ≤ 3A R-dia-T 33A ≤ 3A R-dia-4 A ≤ B

3A ≤ 3B R-dia-K

Interaction between � and 3 in modal logic S4:

�C ∧A ≤ B �C ∧3A ≤ 3B R-box-dia-K

Extension with � and 3 in modal logic S5:

3A ≤ �3A R-dia-5 3�A ≤ �A R-box-5

Fig. 1 Relational subtyping system with four type constructors→, ∧, �, and 3

by extending it with two new subtyping rules, but design the judgmental subtyping system afresh by introducing a new subtyping judgment.

We discuss related work in Section 5 and conclude in Section 6. The lesson from our study is that by using subtyping judgments instead of subtyping re- lations, we can take full advantage of the syntactic approach to formulating a subtyping system (which develops a system of inference rules) while simul- taneously overcoming the limitation associated wit

Recommended