Towards a logic for union types 1. Introduction - CiteSeerX

2 downloads 0 Views 232KB Size Report
The proposed system is Intersection and Union Logic (IUL), an extension of .... A bridge from a logical system to a type assignment system (`a la Curry) is a ...
Fundamenta Informaticae XX (2009) 1–28 IOS Press

Towards a logic for union types Yiorgos Stavrinos [email protected]

Anastasia Veneti [email protected] Graduate Program in Logic, Algorithms, and Computation Department of Mathematics University of Athens GR-15784 Zografou, Greece

Abstract. We examine a logical foundation for the intersection and union types assignment system (IUT). The proposed system is Intersection and Union Logic (IUL), an extension of Intersection Logic (IL) with the canonical rules for union. We investigate two different formalisms for IUL, as well as its properties and its relation with minimal intuitionistic logic. Keywords: intersection and union types, intersection logics, kits, molecules

1. Introduction Intersection Logic (IL) is introduced by S. Ronchi Della Rocca and L. Roversi in [9, 8] as a logical foundation for the intersection types assignment system, in the perspective of a Curry-Howard correspondence. This logic deals with tree structures, called kits, that offer a good geometric depiction of its content. An equivalent system is Intersection Synchronous Logic (ISL), introduced by E. Pimentel, S. Ronchi Della Rocca, and L. Roversi in [6, 7], which uses flattened structures called molecules. These logics are also studied in [11, 10] where they are proved equivalent. In [9, 6] it is shown that any IL (or ISL) deduction Π groups together a finite set of intuitionistic deductions which have the same form with respect to implication, namely the form of Π. Conversely, any set of intuitionistic deductions with the same form can be merged into an IL (or ISL) deduction with this very form. The relation of IL and ISL with minimal intuitionistic logic is further elaborated in [11]. The present work proposes an extension of IL with the canonical rules for union, called Intersection and Union Logic (IUL)1 . This logical system is meant as a logical interpretation of the Intersec1

The present work completely supersedes the one in [12].

1

2

Y. Stavrinos, A. Veneti / Towards a logic for union types

tion and Union Types assignment system (IUT) presented by F. Barbanera, M. Dezani-Ciancaglini, and U. de’Liguoro in [1]. We define IUL using kits with union formulas as leaves, i.e. formulas built from union besides implication and intersection, and we add union introduction/elimination rules to the ones of IL. We investigate IUL’s relation with minimal intuitionistic logic ML following the pattern in [11]. The type system IUT differs substantially from the simple types assignment system. While the disjunction elimination rule (∨E) in the simple types system allows minor premises from subdeductions with different structures, captured by different terms M1 and M2 , the union elimination rule (∪E) in IUT is characterized by isomorphically structured minor premises that type the same term M . Moreover, while the conclusion of the former rule defines the case construct, the conclusion of the latter embodies a substitution operation. Γ⊢N :σ∨τ

Γ, x : σ ⊢ M1 : ρ

Γ, y : τ ⊢ M2 : ρ

Γ ⊢ case(N, λx.M1 , λy.M2 ) : ρ Γ ⊢ N : σ∪τ

Γ, x : σ ⊢ M : ρ

Γ, x : τ ⊢ M : ρ

Γ ⊢ M [N/x] : ρ

(∨E)

(∪E)

To form the union elimination rule (∪E) of IUL, we use the kit structure to join together the isomorphic minor premises of the union elimination rule of IUT. If σ and τ are formulas, the notation [σ, τ ] stands for a kit with two leaves σ and τ , while any formula denotes a single-node kit. Then, a simplified form of the rule is given by: ⊢ σ∪τ

[σ, τ ] ⊢ [ρ, ρ] ⊢ρ

(∪E)

This is the same idea as the one presented in [9] in forming the intersection introduction rule of IL. As a consequence, union elimination in IUL has a single minor premise. To associate IUL to IUT, we use a decoration of its deductions with untyped λ-terms which brings about a substitution operation in the case of the elimination of union. We then prove a theorem relating IUL to ML, namely that any IUL deduction Π represents a finite set of ML deductions which share the implicative structure of Π. We also examine the potential equivalence classes of IUL deductions and pick up the problems induced by attempting to interchange certain rules. We next study an equivalent formalism for IUL using the molecules of ISL. These structures reveal characteristics of the union elimination rule that were concealed by the complicated kit notation. It is exactly this comparison of formalisms, i.e. kits versus molecules, that makes explicit why the latter are easier to manipulate, more informative, and thus preferable over the former. Through the formalism of molecules, we test the converse of the theorem proved for the logics IUL and ML using kits; in particular, we investigate how we can get an IUL deduction starting from an appropriate ML deduction. To this end, we need a lemma merging two identically decorated IUL deductions in one. However, we show by an example that this merging cannot always be effected due to the different decompositions of the substitution involved in union elimination. Noting that IUL forms a conservative extension of IL and also taking into account the fact that union is the dual connective of intersection, we would expect a logic for union to behave well in all aspects that intersection logic does. However, when we attempt to commute certain IUL rules or join together identically decorated IUL deductions, we find that the inclusion of union differentiates the system in a quite significant way. The extension is not trivial and therefore its study is meaningful and worthy of attention.

Y. Stavrinos, A. Veneti / Towards a logic for union types

3

As already mentioned, we choose to develop the formalisms of kits and molecules for a logic corresponding to union types. This choice, as opposed to the Hilbert axiomatization of the Relevant Logic proposed in [4], is motivated by an interest in the structural proof theory of the logic. Another approach is the Hyperformulae Logic of [3] which uses the so-called hyperformulae to represent isomorphic deductions. This logical system has a syntax easier than that of kits, but more complicated than that of molecules. So, since we aim to spotlight the advantages of a compact formalism, we opt to focus on the comparison of kits with molecules. In section 2, we present minimal intuitionistic logic and relate it to IUT. In section 3, we define IUL with kits, as well as the above mentioned decoration of IUL deductions. In section 4, we prove the transition from IUL to ML, while in section 5, we give a brief explanation why commutations of certain IUL rules do not behave symmetrically. In section 6, we present IUL using the formalism of molecules and in section 7, we prove the equivalence of the two formalisms for IUL. In section 8, we examine the transition from ML to IUL employing molecules. Finally, in section 9, we discuss the new information concerning the union rule that is brought up by the molecule formalism. In the appendix we interrelate type assignment systems and logical systems through a term-erasure operation and we elaborate on commutations of IUL rules. Throughout this work, we use the notions, definitions, and formal machinery of [9, 6].

2. Minimal logic ML and type assignment system IUT We present minimal intuitionistic logic ML and type assignment system IUT in natural deduction style. Aiming to relate ML to IUT, we define a non-standard decoration of ML deductions with untyped λ-terms and we conclude that only a proper subset of minimal logic admits such a decoration. Therefore, it cannot offer a logical foundation to IUT. Minimal logic ML has formulas generated by the grammar σ ::= α | σ → σ | σ ∧ σ | σ ∨ σ, where α belongs to a denumerable set of propositional variables. It derives judgements ∆ ⊢ σ, where the context ∆ is a multiset of formulas. Its rules are exhibited in Figure 1. The notation ∆, σ stands for the multiset-union of ∆ and {σ} and the letter s for l(eft) or r(ight). σ∈∆ (Ax) ∆⊢σ ∆, σ ⊢ τ ∆⊢σ→τ

(→ I)

∆⊢σ→τ ∆⊢τ

∆⊢σ ∆ ⊢ τ (∧I) ∆⊢σ∧τ ∆ ⊢ σs ∆ ⊢ σl ∨ σr

(∨I s )

∆⊢ σ∨τ

∆ ⊢ σ (→ E)

∆ ⊢ σl ∧ σr ∆ ⊢ σs ∆, σ ⊢ ρ

(∧E s ) ∆, τ ⊢ ρ

∆⊢ρ

(∨E)

Figure 1. Minimal intuitionistic logic ML. The type assignment system IUT assigns intersection and union types to terms of the untyped λ-calculus. Its types are given by the grammar σ ::= α | σ → σ | σ ∩ σ | σ ∪ σ, where α belongs to a denumerable set of type variables. It derives judgements Γ ⊢ M : σ, where the context

4

Y. Stavrinos, A. Veneti / Towards a logic for union types

Γ is a finite set of type assignments to distinct variables. Its rules are shown in Figure 2. We denote Γ, x : σ the set-union of Γ and {x : σ}. x:σ∈Γ (Ax) Γ⊢x:σ Γ, x : σ ⊢ M : τ Γ ⊢ λx.M : σ → τ

(→ I)

Γ⊢M :σ→τ Γ ⊢ N : σ (→ E) Γ ⊢ MN : τ

Γ⊢M :σ Γ ⊢ M : τ (∩I) Γ ⊢ M : σ∩τ Γ ⊢ M : σs Γ ⊢ M : σl ∪ σr Γ⊢N :σ∪τ

Γ, x : σ ⊢ M : ρ

Γ ⊢ M : σl ∩ σr Γ ⊢ M : σs

(∩E s )

(∪I s ) Γ, x : τ ⊢ M : ρ

Γ ⊢ M [N/x] : ρ

(∪E)

Figure 2. Intersection and union types assignment system IUT. A bridge from a logical system to a type assignment system (`a la Curry) is a decoration of the former with untyped λ-terms. Decorating ML deductions in a standard way, i.e. encoding all rules, produces deductions in λ∧∨ → , the simple types assignment system with implication, conjunction, and disjunction, according to the Curry-Howard correspondence. However, we search for a decoration that, along with converting ∧ to ∩ and ∨ to ∪, would transform a ML deduction to one of IUT. The very rules of IUT dictate that we introduce a decoration which encodes the implication, ignores the conjunction and the introduction of disjunction and induces a substitution operation in the case of the elimination of disjunction. We call such a decoration of ML non-standard. Definition 2.1. (Non-standard decoration of ML) (i) Let ∆ = {σ1 , . . . , σm } be a ML context. For any set {x1 , . . . , xm } of distinct variables and any bijection χ : {1, . . . , m} → {1, . . . , m}, we get a decoration ∆∗ = {xχ(1) : σ1 , . . . , xχ(m) : σm } of ∆ with dom(∆∗ ) = {x1 , . . . , xm }. Without loss of generality, we denote an arbitrary decoration of ∆ as {x1 : σ1 , . . . , xm : σm }. (ii) A ML deduction Π that concludes by proving ∆ ⊢ σ , denoted Π : ∆ ⊢ σ or even Π : ∆ = σ1 , . . . , σm ⊢ σ, can be associated to an untyped λ-term T∆∗ (Π) which depends on the structure of Π and on the decoration of ∆. A decoration of Π : ∆ ⊢ σ is denoted Π∗ : ∆∗ ⊢ T∆∗ (Π) : σ and is defined inductively. We follow [9, 6, 7] in decorating the axiom, the implication, and the conjunction. The disjunction rules are shown below.



Π1 : ∆ ⊢ σs Π : ∆ ⊢ σl ∨ σr

(∨I s )



Π∗1 : ∆∗ ⊢ M : σs Π∗ : ∆∗ ⊢ M : σl ∨ σr

(∨I s )∗

where T∆∗ (Π) ≡ T∆∗ (Π1 ) ≡ M .



Π1 : ∆ ⊢ σ ∨ τ

Π2 : ∆ , σ ⊢ ρ Π:∆⊢ρ

Π3 : ∆ , τ ⊢ ρ

(∨E)



Y. Stavrinos, A. Veneti / Towards a logic for union types

Π∗1 : ∆∗ ⊢ N : σ ∨ τ

Π∗2 : ∆∗ , x : σ ⊢ M : ρ

Π∗3 : ∆∗ , x : τ ⊢ M : ρ

Π∗ : ∆∗ ⊢ M [N/x] : ρ

5

(∨E)∗

where T∆∗ (Π) ≡ M [N/x], if T∆∗ , x:σ (Π2 ) ≡ T∆∗ , x:τ (Π3 ) ≡ M , otherwise T∆∗ (Π) is undefined. Note that, if Π : ∆ ⊢ σ is decorated to Π∗ : ∆∗ ⊢ M : σ, then F V (M ) ⊆ dom(∆∗ ). It is important to emphasize that not every ML deduction admits a non-standard decoration. Definition 2.2. (ML→ ) We define ML→ to be the set of ML deductions that admit a non-standard decoration. For a ML deduction to be in ML→ , all its (∧I) instances must have isomorphic premises, i.e. decoratable non-standardly by the same λ-term, and all its (∨E) instances must have isomorphic minor premises. The isomorphic deductions share some kind of similar shape with respect to implication. Any deduction in ML→ will give an IUT deduction, when decorated non-standardly and ∧, ∨ are converted to ∩, ∪, respectively. Conversely, any IUT deduction will give a deduction in ML→ , if λ-terms are erased and ∩, ∪ are converted to ∧, ∨, respectively (see appendix A). Example 2.1. Let α, β, γ be distinct propositional variables. If ∆1 = {(α → β) ∧ (γ → β), α ∨ γ},

∆2 = {α → β, γ → β, α ∨ γ}

and Π1 , Π2 are the following ML deductions

∆1 ⊢ α ∨ γ

∆1 , α ⊢ (α → β) ∧ (γ → β) ∆1 , α ⊢ α → β ∆1 , α ⊢ α Π10 : ∆1 , α ⊢ β Π 1 : ∆1 ⊢ β

∆2 ⊢ α ∨ γ

∆2 , α ⊢ α → β ∆2 , α ⊢ α Π20 : ∆2 , α ⊢ β Π 2 : ∆2 ⊢ β

∆1 , γ ⊢ (α → β) ∧ (γ → β) ∆1 , γ ⊢ γ → β ∆1 , γ ⊢ γ Π11 : ∆1 , γ ⊢ β (∨E)

∆2 , γ ⊢ γ → β ∆2 , γ ⊢ γ Π21 : ∆2 , γ ⊢ β (∨E)

then Π1 is in ML→ , while Π2 isn’t. In order to give a (non-standard) decoration of the deductions, we start by decorating the corresponding contexts. If ∆∗1 = {x : (α → β) ∧ (γ → β), y : α ∨ γ}, then T∆∗1 , z:α (Π10 ) ≡ xz ≡ T∆∗1 , z:γ (Π11 ), so that T∆∗1 (Π1 ) ≡ xz[y/z] ≡ xy. On the other hand, if ∆∗2 = {x : α → β, y : γ → β, z : α ∨ γ}, then T∆∗2 , v:α (Π20 ) ≡ xv 6≡ yv ≡ T∆∗2 , v:γ (Π21 ), so that T∆∗2 (Π2 ) is undefined2.

3. Intersection and union logic IUL We present intersection and union logic IUL in natural deduction style. It is an extension of intersection logic IL (see [9]) with union. It aims to express ML→ as a logic of its own and thus offer a logical foundation to IUT. To relate IUL to ML→ , we define a non-standard decoration of IUL deductions with untyped λ-terms. 2

In IUT, the type (α → β) → (γ → β) → α ∪ γ → β is not inhabited.

6

Y. Stavrinos, A. Veneti / Towards a logic for union types

Definition 3.1. (IUL) (i) A kit is a binary tree K ::= σ | [K, K] with leaves σ ::= α | σ → σ | σ ∩ σ | σ ∪ σ, where α belongs to a denumerable set of propositional variables. (ii) Two kits H, K overlap, denoted H ≃ K, if they share the same tree structure, but may differ on the names of their leaves. (iii) A path is a finite string built over the alphabet {l, r}. The subtree of a kit K at path p, denoted K p , is the subtree of K rooted at the end of p in K. The set of terminal paths of a kit K is denoted P T (K). Two paths p and q of K are different, if they split on a node of K. (iv) If H ≃ K, then H → K denotes a kit overlapping with H, K and such that (H → K)p ≡ H p → K p , for every p ∈ P T (H → K). (v) The notation H[p := K] stands for the kit resulting from the substitution of K for H p in H. If ps is a path in H, the pruning of H at path ps, denoted H\ps , is defined as H[p := H ps ]. If q and p are paths in H, the left (resp. right) doubling of subtree H q at path p, denoted H q/pl (resp. H q/pr ), is defined as H[p := [H q , H p ]] (resp. H[p := [H p , H q ]]). (vi) The deductive system IUL derives judgements ∆ ⊢ K, where the context ∆ is a multiset of kits and K is a kit, all overlapping. Its rules are shown in Figure 3. From this point on, the index i in contexts runs from 1 to m, i.e. Ki stands for K1 , . . . , Km . K ∈ ∆ (∀ H ∈ ∆, H ≃ K) ∆⊢K Hi ⊢ H (ps is a path in H) Hi \ps ⊢ H\ps ∆,H ⊢ K ∆⊢H→K

Hi ⊢ H (p, q are paths in H)

(P )

Hi q/ps ⊢ H q/ps

(D)

∆⊢H →K ∆ ⊢ H (→ E) ∆⊢K

(→ I)

Hi [p := [σi , σi ]] ⊢ H[p := [σ, τ ]] Hi [p := σi ] ⊢ H[p := σ ∩ τ ]

∆ ⊢ H[p := σl ∩ σr ]

(∩I)

∆ ⊢ H[p := σs ] ∆ ⊢ H[p := σl ∪ σr ] Hi [p := σi ] ⊢ K[p := σ ∪ τ ]

(Ax)

∆ ⊢ H[p := σs ]

(∩E s )

(∪I s )

Hi [p := [σi , σi ]], K[p := [σ, τ ]] ⊢ H[p := [ρ, ρ]] Hi [p := σi ] ⊢ H[p := ρ]

Figure 3.

(∪E)

Intersection and union logic IUL.

Remark 3.1. (i) The inclusion of extra structural rules (P ) and (D) to the system is motivated by purely technical reasons, i.e. reasons concerning the manipulation of the tree structure. Rule (D) iterates H q at path pl (resp. pr), while moving H p at pr (resp. pl). If q and p are terminal paths of H and moreover q ≡ p, then the left or right doubling of leaf H q ≡ σ at path p is H p/pl ≡ H p/pr ≡ H[p := [σ, σ]]. This gives as a special case: Hi [p := σi ] ⊢ H[p := σ] Hi [p := [σi , σi ]] ⊢ H[p := [σ, σ]]

(D)

Y. Stavrinos, A. Veneti / Towards a logic for union types

7

It is this version of (D) that we will use in order to allow for certain rules to be permuted (see section 5 and appendix B). However, we will need the more general version for the proof of Theorem 7.2. (ii) Rule (∪E) exploits the tree structure to join together the isomorphic minor premises of rule (∨E) in ML→ . (iii) Implicative rules affect all terminal paths (leaves) of the kits involved and are called global. On the other hand, the notation “ [p := ]” used in intersection and union rules shows that these rules act on specific paths; in particular, on the terminal path p in rules (∩E s ), (∪I s ) and on the terminal paths pl and pr in rules (∩I), (∪E). So, we would normally call intersection and union rules local. However, a more thorough investigation of rule globality and locality (see section 9) will show that such a classification is not accurate in the case of (∪E). We next define a non-standard decoration of IUL deductions which encodes the implication, brings about a substitution in the case of union elimination, and ignores all other rules. Definition 3.2. (Non-standard decoration of IUL) (i) For any IUL context ∆ = {H1 , . . . , Hm }, we can define a decoration ∆⋆ with distinct variables {x1 , . . . , xm } in the manner described in Definition 2.1(i). It is dom(∆⋆ ) = {x1 , . . . , xm }. (ii) A decoration of Π : ∆ ⊢ K is denoted Π⋆ : ∆⋆ ⊢ T∆⋆ (Π) : K and is defined inductively. We follow [9] in decorating the axiom, pruning, implication and intersection rules. The decoration of doubling and union rules is demonstrated below.



Π1 : ∆1 ⊢ H Π : ∆ ⊢ H q/ps

(D)



Π⋆1 : ∆⋆1 ⊢ M : H Π⋆ : ∆⋆ ⊢ M : H q/ps

(D)⋆

where, if xi : Hi is in ∆⋆1 , then xi : Hi q/ps is in ∆⋆ , and T∆⋆ (Π) ≡ T∆⋆1 (Π1 ) ≡ M . •

Π1 : ∆ ⊢ H[p := σs ] Π : ∆ ⊢ H[p := σl ∪ σr ]

(∪I s )



Π⋆1 : ∆⋆ ⊢ M : H[p := σs ] ⋆



Π : ∆ ⊢ M : H[p := σl ∪ σr ]

(∪I s )⋆

where T∆⋆ (Π) ≡ T∆⋆ (Π1 ) ≡ M .



Π1 : ∆ ⊢ K[p := σ ∪ τ ]

Π2 : ∆2 , K[p := [σ, τ ]] ⊢ H[p := [ρ, ρ]] Π : ∆ ⊢ H[p := ρ]

Π⋆1 : ∆⋆ ⊢ N : K[p := σ ∪ τ ]

(∪E)

Π⋆2 : ∆⋆2 , x : K[p := [σ, τ ]] ⊢ M : H[p := [ρ, ρ]]

Π⋆ : ∆⋆ ⊢ M [N/x] : H[p := ρ]



(∪E)⋆

where, if xi : Hi [p := σi ] is in ∆⋆ , then xi : Hi [p := [σi , σi ]] is in ∆⋆2 , and T∆⋆ (Π) ≡ M [N/x]. Note that if Π : ∆ ⊢ K is decorated to Π⋆ : ∆⋆ ⊢ M : K, then F V (M ) ⊆ dom(∆⋆ ). Every IUL deduction admits a decoration. In ML, the premises of (∧I) and the minor premises of (∨E) needed to be decorated by the same term for the decoration to move on to the conclusion. In IUL, though, the kit structure is utilized precisely for merging the isomorphic premises of (∧I) and

8

Y. Stavrinos, A. Veneti / Towards a logic for union types

the isomorphic minor premises of (∨E), so that (∩I) has a single premise and (∪E) has a single minor premise. Hence, the decoration passes on the conclusion at all instances of (∩I) and (∪E). In appendix A, we define a kit assignment system IUK from which we can retrieve IUL by erasure of λ-terms. Conversely, any deduction in IUL will give an IUK deduction, when decorated. We will use the non-standard decorations of ML and IUL to establish a relation between IUL and ML→ (Theorem 4.1) and we will use the erasure of λ-terms defined on IUT and IUK together with Theorem 4.1 to establish a relation between IUK and IUT (Theorem A.1).

4. Relating IUL to ML→ In this section, we show that any deduction Π in IUL provides a finite set of deductions in ML→ , each sharing the implicative structure of Π. If K is a kit and p a terminal path, then any leaf σ ≡ K p can give a ML formula σ ′ ≡ (K p )′ by conversion of intersection and union to conjunction and disjunction, respectively. To avoid explicitly denoting conversions by a function ( )′ , though, in what follows we denote σ (or K p ) the ML formula corresponding to the leaf σ ≡ K p , assuming the use of notation is modulo conversion of connectives. Theorem 4.1. Let Π : ∆ = K1 , . . . , Km ⊢ K be in IUL . For every p ∈ P T (K), there exists (modulo conversion of connectives) a deduction Πp : ∆p = (K1 )p , . . . , (Km )p ⊢ K p in ML→ , such that T(∆p )∗ (Πp ) ≡ T∆⋆ (Π), for any decoration ∆⋆ = {x1 : K1 , . . . , xm : Km } and its corresponding (∆p )∗ = {x1 : (K1 )p , . . . , xm : (Km )p }.

Proof: By induction on Π. The most interesting cases are shown. • Case (∩I): Π1 : ∆1 = Hi [p := [σi , σi ]] ⊢ H[p := [σ, τ ]] Π : ∆ = Hi [p := σi ] ⊢ H[p := σ ∩ τ ] Suppose q ∈ P T (H[p := σ ∩ τ ]). We distinguish two subcases. (1) If q 6≡ p, then q ∈ P T (H[p := [σ, τ ]]). So, by the IH (induction hypothesis), there exists Πq1 : ∆q1 = (Hi [p := [σi , σi ]])q ⊢ (H[p := [σ, τ ]])q in ML→ , such that T(∆q1 )∗ (Πq1 ) ≡ T∆⋆1 (Π1 ), for any decoration. But (Hi [p := [σi , σi ]])q ≡ (Hi [p := σi ])q and (H[p := [σ, τ ]])q ≡ (H[p := σ ∩ τ ])q , so ∆q1 = ∆q and Πq1 ≡ Πq . Hence, Πq is in ML→ and T(∆q )∗ (Πq ) ≡ T(∆q1 )∗ (Πq1 ) ≡ T∆⋆1 (Π1 ) ≡ T∆⋆ (Π), for any decoration. (2) If q ≡ p, then pl, pr ∈ P T (H[p := [σ, τ ]]). So, by the IH, there exist pl Πpl 1 : ∆1 = σi ⊢ σ

pr Πpr 1 : ∆1 = σi ⊢ τ

pr in ML→ , such that T(∆pl )∗ (Πpl (Π1 ) ≡ T(∆pr ∗ (Π 1 ) ≡ T∆⋆ 1 ), for any decoration. Applying (∧I) 1 1 ) 1

pr pl pr p p → → on Πpl and 1 , Π1 , we get Π : ∆ = σi ⊢ σ ∧ τ in ML , since Π1 and Π1 are both in ML

Y. Stavrinos, A. Veneti / Towards a logic for union types

9

pr pl p pr T(∆pl )∗ (Πpl ∗ (Π1 ) ≡ 1 ) ≡ T(∆1 )∗ (Π1 ), for any decoration. We also have T(∆p )∗ (Π ) ≡ T(∆pl 1 1 ) T∆⋆1 (Π1 ) ≡ T∆⋆ (Π), for any decoration.

• Case (∪E): Π1 : ∆ = Hi [p := σi ] ⊢ K[p := σ ∪ τ ] Π2 : ∆2 = Hi [p := [σi , σi ]], K[p := [σ, τ ]] ⊢ H[p := [ρ, ρ]] Π : ∆ = Hi [p := σi ] ⊢ H[p := ρ]

Suppose q ∈ P T (H[p := ρ]). Then q ∈ P T (K[p := σ ∪ τ ]). We distinguish again two subcases. (1) If q 6≡ p, then q ∈ P T (H[p := [ρ, ρ]]) and (Hi [p := [σi , σi ]])q ≡ (Hi [p := σi ])q ≡ φi , (K[p := [σ, τ ]])q ≡ (K[p := σ ∪ τ ])q ≡ ζ, and (H[p := [ρ, ρ]])q ≡ (H[p := ρ])q ≡ ξ. By the IH Πq1 : ∆q = φi ⊢ ζ

Πq2 : ∆q2 = φi , ζ ⊢ ξ

are in ML→ , T(∆q )∗ (Πq1 ) ≡ T∆⋆ (Π1 ), for any decoration, and T(∆q2 )∗ (Πq2 ) ≡ T∆⋆2 (Π2 ), for any decoration. Then, Πq ≡ S(Πq1 , Πq2 ) : ∆q = φi ⊢ ξ, where S(Πq1 , Πq2 ) denotes the substitution of Πq1 for appropriate axioms in Πq2 (see [9, Lemma 1]). If we decorate Πq1 and Πq2 non-standardly, we get (Πq1 )∗ : {xi : φi } ⊢ N : ζ and (Πq2 )∗ : {xi : φi , x : ζ} ⊢ M : ξ in IUT, where N ≡ T(∆q )∗ (Πq1 ) and M ≡ T(∆q2 )∗ (Πq2 ). By the Substitution Lemma3 , we then have {xi : φi } ⊢ M [N/x] : ξ q ∗

which is actually (Π ) . So, Π is in ML→ and T(∆q )∗ (Πq ) ≡ M [N/x]. Using the non-standard decoration of IUL, we get M [N/x] ≡ T∆⋆ (Π), so that T(∆q )∗ (Πq ) ≡ T∆⋆ (Π), for any decoration. q

(2) If q ≡ p, then pl, pr ∈ P T (H[p := [ρ, ρ]]) and, by the IH, there exist Πp1 : ∆p = σi ⊢ σ ∨ τ

pl Πpl 2 : ∆2 = σi , σ ⊢ ρ

pr Πpr 2 : ∆2 = σi , τ ⊢ ρ

⋆ in ML→ , such that T(∆p )∗ (Πp1 ) ≡ T∆⋆ (Π1 ), for any decoration, and T(∆pl )∗ (Πpl 2 ) ≡ T∆2 (Π2 ) ≡ 2

pr p pl pr p p T(∆pr ∗ (Π 2 ), for any decoration. Applying (∨E) on Π1 , Π2 , Π2 , we get Π : ∆ = σi ⊢ ρ, which 2 ) pr pl is in ML→ , since the three premises are in ML→ and also T(∆pl)∗ (Π2 ) ≡ T(∆pr ∗ (Π 2 ), for any 2 ) 2

p decoration. In addition, if M ≡ T(∆pl )∗ (Πpl 2 ) and N ≡ T(∆p )∗ (Π1 ), then, using the non-standard 2 decorations of ML and IUL, we have T(∆p )∗ (Πp ) ≡ M [N/x] ≡ T∆⋆ (Π), for any decoration. (This case will be discussed further in section 9.) ⊓ ⊔

Definition 4.1. Let Π : ∆ ⊢ K be in IUL and ML(Π) = {Πp | p ∈ P T (K)}. Any deduction Πp in ML(Π) will be refered to as a ML projection of Π. Example 4.1. Suppose α, β, γ, δ, ζ, η, θ are propositional variables and σ ≡ α ∩ β, τ ≡ γ ∩ δ, ρ ≡ (δ → η) ∩ (ζ → η). If ∆0 = { [σ, τ ], [α → θ, ρ] }, ∆1 = { [σ, [τ, τ ]], [α → θ, [ρ, ρ]], [α, [δ, ζ]] }, and Π is the following IUL deduction, ∆0 ⊢ [σ, τ ] ∆0 ⊢ [α, δ]

(∩E)

Π0 : ∆0 ⊢ [α, δ ∪ ζ]

(∪I)

∆1 ⊢ [α → θ, [ρ, ρ]] ∆1 ⊢ [α → θ, [δ → η, ζ → η]]

Π1 : ∆1 ⊢ [θ, [η, η]] ∆0 ⊢ [θ, η]

Π : [σ, τ ] ⊢ [(α → θ) → θ, ρ → η] 3

(∩E)

(→ I)

See [1, Lemma 1.4]: If Γ, x : ζ ⊢ M : ξ and Γ ⊢ N : ζ, then Γ ⊢ M [N/x] : ξ.

∆1 ⊢ [α, [δ, ζ]] (∪E)

(→ E)

10

Y. Stavrinos, A. Veneti / Towards a logic for union types

then Π has two ML projections Πl : σ ⊢ (α → θ) → θ and Πr : τ ⊢ ρ → η. Following the left path in Π, we arrive at a substitution operation S(Πl0 , Πl1 ), which is carried out to give Πl .

σ, α → θ ⊢ σ

(∧E)

σ, α → θ, α ⊢ α → θ

σ, α → θ, α ⊢ α

Πl : σ, α → θ ⊢ α Πl : σ, α → θ, α ⊢ θ . . .0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1. . . . . . . . . . . . . . . . . . . . . S(Πl0 , Πl1 ) : σ, α → θ ⊢ θ

σ, α → θ ⊢ σ σ, α → θ ⊢ α → θ

σ, α → θ ⊢ α

S(Πl0 , Πl1 ) : σ, α → θ ⊢ θ Πl : σ ⊢ (α → θ) → θ

(→ E)

[substitution]

(∧E) (→ E)

(→ I)

On the other hand, the (∪E) rule in Π, which is applied on path r, is translated to a (∨E) rule in Πr .

τ, ρ ⊢ τ τ, ρ ⊢ δ

(∧E)

τ, ρ ⊢ δ ∨ ζ

(∨I)

τ, ρ, δ ⊢ ρ τ, ρ, δ ⊢ δ → η

(∧E)

τ, ρ, ζ ⊢ ρ τ, ρ, δ ⊢ δ

τ, ρ, δ ⊢ η τ, ρ ⊢ η Πr : τ ⊢ ρ → η

(→ E)

τ, ρ, ζ ⊢ ζ → η

(∧E)

τ, ρ, ζ ⊢ η

τ, ρ, ζ ⊢ ζ

(→ E)

(∨E)

(→ I)

The terms decorating Π, Πl , and Πr are identical, given corresponding context decorations. In particular, it is T{x:[σ,τ ]}(Π) ≡ T{x:σ} (Πl ) ≡ T{x:τ } (Πr ) ≡ λy.yx. It is worth noting that, since the concluding judgement J ≡ [σ, τ ] ⊢ [(α → θ) → θ, ρ → η] of Π does not involve union and IUL is a conservative extension of IL, we can also prove J in IL. Moreover, the term decorating J in IL is identical to the one decorating it in IUL, given the same context decoration. Remark 4.1. Let α, β, γ, δ be propositional variables and consider the IUL deduction Π and its left ML projection Πl , as shown below. A : [α, β], [α, γ], [α, δ] ⊢ [α, β] [α, β], [α, γ] ⊢ [α → α, δ → β]

(→ I)

Π : [α, β] ⊢ [α → α → α, γ → δ → β]

(→ I)

Al : {α, α, α} ⊢ α {α, α} ⊢ α → α

(→ I)

Πl : {α} ⊢ α → α → α

(→ I)

This example clarifies why we prefer to define ML contexts as multisets rather than sets (which is the context formalism in [8]). This way, any judgement of Πl is the exact left print of the corresponding judgement of Π; for example, Al and A. Consequently, corresponding judgements have the same context cardinality. Had we defined ML contexts as sets, Πl would have been:

Y. Stavrinos, A. Veneti / Towards a logic for union types

{α} ⊢ α

11

(→ I)

{α} ⊢ α → α

Πl : {α} ⊢ α → α → α

(→ I)

Obviously, to retain the left print relation between Πl and Π, which guarantees structural similarity, we would have had to use set-theoretically redundant representations of the singleton {α}, for example, {α} = {α} ∪ {α} ∪ {α}. In addition, context cardinality correspondence would have been lost. A similar argument in favour of multisets, concerning ML contexts as well as IUL contexts, is given in the appendix (see Remark A.3).

5. Commuting the local rules This section records the attempt to define equivalence classes of IUL deductions, so that equivalent deductions have the same axioms and conclusion, but differ in the order of application of consecutive local rules concerning different paths. We examine the case of (∩I, ∪E) and show that the attempt to interchange these rules induces additional differentiations between desirably equivalent deductions. Exhibiting specific kits to avoid clumsy formalization, we see that the interchange relation, denoted ֒→, is not symmetric. Additional rules (Pruning and Doubling) are used along with interchanging and restrictions are imposed on certain leaves. In particular, to reorder (∩I, ∪E) an extra rule (D) is required: [[σ, σ], [τ, τ ]], [[ψ, ψ], [ρ, φ]] ⊢ [[ζ, ξ], [η, η]] [σ, [τ, τ ]], [ψ, [ρ, φ]] ⊢ [ζ ∩ ξ, [η, η]]

[σ, τ ] ⊢ [ψ, ρ ∪ φ]

[σ, τ ] ⊢ [ζ ∩ ξ, η] [σ, τ ] ⊢ [ψ, ρ ∪ φ] [[σ, σ], τ ] ⊢ [[ψ, ψ], ρ ∪ φ]

(D)l

(∩I)l

֒→

(∪E)r

[[σ, σ], [τ, τ ]], [[ψ, ψ], [ρ, φ]] ⊢ [[ζ, ξ], [η, η]]

[[σ, σ], τ ] ⊢ [[ζ, ξ], η] [σ, τ ] ⊢ [ζ ∩ ξ, η]

(∪E)r

(∩I)l

On the other hand, to reorder (∪E, ∩I) an extra rule (P ) is required, as well as a restriction on certain leaves: [[σ, σ], τ ] ⊢ [[ψ, ψ], ρ ∪ φ]

[[σ, σ], [τ, τ ]], [[ψ, ψ], [ρ, φ]] ⊢ [[ζ, ξ], [η, η]] [[σ, σ], τ ] ⊢ [[ζ, ξ], η] [σ, τ ] ⊢ [ζ ∩ ξ, η]

[[σ, σ], τ ] ⊢ [[ψ, ψ], ρ ∪ φ] [σ, τ ] ⊢ [ψ, ρ ∪ φ]

(P )ls

(∪E)r

֒→

(∩I)l

[[σ, σ], [τ, τ ]], [[ψ, ψ], [ρ, φ]] ⊢ [[ζ, ξ], [η, η]] [σ, [τ, τ ]], [ψ, [ρ, φ]] ⊢ [ζ ∩ ξ, [η, η]]

[σ, τ ] ⊢ [ζ ∩ ξ, η]

(∩I)l

(∪E)r

12

Y. Stavrinos, A. Veneti / Towards a logic for union types

The two leaves ψ (in sub-kit [ψ, ψ]) must be identical, so that (∩I) can be applied when the rules are interchanged. This is indeed a restriction, since, in general, we would apply (∪E) and then (∩I) for different such leaves. Similar difficulties are encountered in the attempt to interchange (∪E, ∪E). All other pairs of local rules, though, commute symmetrically (see appendix B). The study of rule commutations forces us to conclude that we cannot define equivalence classes of IUL deductions following the method of [9]. In this paper, Ronchi and Roversi first introduce the deductive system pre Intersection Logic (pIL) and then define an IL deduction as an equivalence class of pIL deductions which differ only in the order of application of consecutive intersection rules concerning different paths. In the system we propose, though, an analogous two-step definition is not feasible, since additional rules interfere in some commutation cases resulting in a non-symmetric behaviour of the relation in question and thus preventing the formation of equivalence classes. An alternative presentation of the commutations using proof terms as a shorthand for trees of judgements would definitely save space, but may require proof terms of high complexity, since particular paths of the kits should be taken into account. Solutions on notational problems of this kind may be obtained by using explicitly typed calculi as in [14] and [5].

6. A union logic with molecules In this section, we present an alternative version for intersection and union logic, denoted IUL(m) . This logical system is an extension with union of intersection synchronous logic ISL (see [6, 7]) and is also intended as a logical foundation for IUT. Its main structures are multisets called molecules which are easier to manipulate than kits. The tree structure of kits in an IUL judgement ∆ ⊢ K is flattened revealing interesting information on rule locality and globality, as we will explain in section 9. Definition 6.1. (IUL(m) ) (i) Formulas of IUL(m) are generated by the grammar σ ::= α | σ → σ | σ ∩ σ | σ ∪ σ, where α belongs to a denumerable set of propositional variables. (ii) An atom, denoted A, is a pair (Γ ; σ), where the context Γ is a finite sequence of formulas and σ is a formula. (iii) A molecule, denoted M or N , is a finite multiset of atoms of the same context cardinality. We denote [A1 , . . . , An ] a molecule consisting of atoms A1 , . . . , An . We may also write [Aj | 1 6 j 6 n] or [Aj ]j6n or even [Aj ]j . (iv) The deductive system IUL(m) derives molecules. Its rules are depicted in Figure 4. The need for explicit structural rules of weakening (W ) and exchange (X) is explained in [6, 7]. In rule (D), we denote 2N the molecule resulting from N by doubling the multiplicity of each atom. As pointed out for rule (∪E) in IUL, rule (∪E) in IUL(m) also aims to join together the isomorphic minor premises of (∨E) in ML→ . This is achieved by placing them both in the same molecule; all atoms in a molecule are identically decorated (see Definition 6.2). We define a non-standard decoration of IUL(m) deductions dictated by the very rules of IUT. It will be used in the theorems proving the equivalence of IUL and IUL(m) (Theorems 7.1 and 7.2) and in the theorem relating IUL(m) to ML→ (Theorem 7.3).

Y. Stavrinos, A. Veneti / Towards a logic for union types

[(σj ; σj )]j

M

(Ax)

M

S M N (D) S M 2N

(P )

[(Γj1 , ρj , τj , Γj2 ; σj )]j

(W )

[(Γj , τj ; σj )]j

[(Γj ; σj → τj )]j

N

M

[(Γj ; σj )]j

[(Γj , σj ; τj )]j

S

[(Γj1 , τj , ρj , Γj2 ; σj )]j [(Γj ; σj → τj )]j

(→ I)

(X)

[(Γj ; σj )]j

[(Γj ; τj )]j

S

[(Γ ; σ), (Γ ; τ )] (∩I) S M [(Γ ; σ ∩ τ )]

M

13

(→ E)

S

[(Γ ; σl ∩ σr )] (∩E s ) S M [(Γ ; σs )]

S M [(Γ ; σs )] (∪I s ) S M [(Γ ; σl ∪ σr )] [(Γ ; σ ∪ τ )]

S

[(Γj ; φj )]j

[(Γ, σ ; ρ), (Γ, τ ; ρ)] S [(Γ ; ρ)] [(Γj ; ψj )]j

Figure 4.

S

[(Γj , φj ; ψj )]j

(∪E)

Intersection and union logic IUL(m) .

Definition 6.2. (Non-standard decoration of IUL(m) ) (i) For any atom (Γ ; τ ), where Γ ≡ σ1 , . . . , σm , and any sequence v ≡ x1 , . . . , xm of distinct variables, a decoration of Γ with respect to v is Γv ≡ x1 : σ1 , . . . , xm : σm . j (ii) Let Π be an IUL(m) deduction proving M ≡ [(Γj ; τj )]j , where Γj ≡ σ1j , . . . , σm , and v ≡ x1 , . . . , xm be a sequence of distinct variables. Then, Π can be inductively associated to a decorated deduction proving Mv (Π) : Mv , where Mv (Π) is a λ-term and Mv ≡ [(Γvj ; τj )]j . We follow [6, 7] in decorating the axiom, pruning, weakening, exchange, implication and intersection rules. Doubling and the union rules are shown decorated below.

S Π1 : M N (D) • S Π : M 2N

S M : Mv Nv S M : Mv (2N )v



where Mv (Π) ≡ Mv (Π1 ) ≡ M . S Π1 : M [(Γ ; σs )] (∪I s ) • S Π : M [(Γ ; σl ∪ σr )]



S M : Mv [(Γv ; σs )] S M : Mv [(Γv ; σl ∪ σr )]

where Mv (Π) ≡ Mv (Π1 ) ≡ M . •

Π1 : [(Γ ; σ ∪ τ )]

N : [(Γv ; σ ∪ τ )]

S

S

[(Γj ; φj )]j

Π2 : [(Γ, σ ; ρ), (Γ, τ ; ρ)] S Π : [(Γ ; ρ)] [(Γj ; ψj )]j

[(Γvj ; φj )]j

S

[(Γj , φj ; ψj )]j

M : [(Γv , x : σ ; ρ), (Γv , x : τ ; ρ)] S M [N/x] : [(Γv ; ρ)] [(Γvj ; ψj )]j

S

(∪E)



[(Γvj , x : φj ; ψj )]j

14

Y. Stavrinos, A. Veneti / Towards a logic for union types

where Mv (Π) ≡ M [N/x]. If Π : M gives M : Mv when decorated, then F V (M ) ⊆ {x1 , . . . , xm }. Like in IUL, every IUL(m) deduction admits a decoration, since (∩I) has a single premise and (∪E) has a single minor premise.

7. Equivalence of IUL and IUL(m) We prove the equivalence of IUL and IUL(m) , while spotting corresponding features of the two systems. Theorem 7.1. Let Π : ∆ = {K1 , . . . , Km } ⊢ K be an IUL deduction with PT (K) = {p1 , . . . , pn }. p1 pn Then, there exists Π′ : [(K1p1 , . . . , Km ; K p1 ), . . . , (K1pn , . . . , Km ; K pn )] in IUL(m) , such that ′ ⋆ Mx1 ,...,xm (Π ) ≡ T{x1 :K1 ,...,xm :Km } (Π), for every decoration ∆ = {x1 : K1 , . . . , xm : Km }.

Proof: By induction on Π. We show three characteristic cases. • Case (P ): Without loss of generality, we consider pruning at path pl. Π1 : {H1 , . . . , Hm } ⊢ H Π : {H1 \pl , . . . , Hm \pl } ⊢ H\pl Suppose the notation Ki ≡ Hi \pl (1 6 i 6 m), K ≡ H\pl and let PT (H) = {q1 , . . . , qν , plt1 , . . . , pltµ , pru1 , . . . , pruκ } where ν + µ = n. Then: (i) PT (K) = {q1 , . . . , qν , pt1 , . . . , ptµ } q

q

(ii) Hi j ≡ Ki j , H qj ≡ K qj (1 6 i 6 m, 1 6 j 6 ν) pltj

(iii) Hi

pt

≡ Ki j , H pltj ≡ K ptj (1 6 i 6 m, 1 6 j 6 µ)

By the IH, there exists Π′1 : M

S

N in IUL(m) , where

q1 qν M ≡ [(H1q1 , . . . , Hm ; H q1 ), . . . , (H1qν , . . . , Hm ; H qν ), plt

plt1 pltµ (H1plt1 , . . . , Hm ; H plt1 ), . . . , (H1 µ , . . . , Hm ; H pltµ )] pru1 pru pru1 pruκ N ≡ [(H1 , . . . , Hm ; H pru1 ), . . . , (H1 κ , . . . , Hm ; H pruκ )]

such that Mx1 ,...,xm (Π′1 ) ≡ T{x1 :H1 ,...,xm :Hm } (Π1 ), for every {x1 : H1 , . . . , xm : Hm }. Applying (P ) on Π′1 , we get Π′ : M and, by (ii) and (iii), we have that M ≡

q1 qν [(K1q1 , . . . , Km ; K q1 ), . . . , (K1qν , . . . , Km ; K qν ), pt

pt1 ptµ (K1pt1 , . . . , Km ; K pt1 ), . . . , (K1 µ , . . . , Km ; K ptµ )]

Y. Stavrinos, A. Veneti / Towards a logic for union types

15

It is Mx1 ,...,xm (Π′ ) ≡ Mx1 ,...,xm (Π′1 ) ≡ T{x1 :H1 ,...,xm :Hm } (Π1 ) ≡ T{x1 :K1 ,...,xm :Km } (Π), for every {x1 : K1 , . . . , xm : Km }. • Case (D): Without loss of generality, we consider the left doubling at path p. Π1 : {H1 , . . . , Hm } ⊢ H Π : {H1 q/pl , . . . , Hm q/pl } ⊢ H q/pl Consider q and p different and suppose the notation Ki ≡ Hi q/pl (1 6 i 6 m) and K ≡ H q/pl . Let PT (H) = {w1 , . . . , wν , qt1 , . . . , qtµ , pu1 , . . . , puκ }. Then: (i) PT (K) = {w1 , . . . , wν , qt1 , . . . , qtµ , plt1 , . . . , pltµ , pru1 , . . . , pruκ }, where ν + 2µ + κ = n. wj

≡ Ki j , H wj ≡ K wj (1 6 i 6 m, 1 6 j 6 ν)

qtj

≡ Ki

puj

≡ Ki

(ii) Hi (iii) Hi

w

qtj

pltj

≡ Ki

, H qtj ≡ K qtj ≡ K pltj (1 6 i 6 m, 1 6 j 6 µ)

pruj

, H puj ≡ K pruj (1 6 i 6 m, 1 6 j 6 κ) S S By the IH, there exists Π′1 : M1 M2 M3 in IUL(m) , where (iv) Hi

w1 wν M1 ≡ [(H1w1 , . . . , Hm ; H w1 ), . . . , (H1wν , . . . , Hm ; H wν )] qt

qt1 qtµ M2 ≡ [(H1qt1 , . . . , Hm ; H qt1 ), . . . , (H1 µ , . . . , Hm ; H qtµ )]

M3 ≡

pu1 [(H1pu1 , . . . , Hm

puκ ; H pu1 ), . . . , (H1puκ , . . . , Hm ; H puκ )]

such that Mx1 ,...,xm (Π′1 ) ≡ S T{x1 :H1 ,...,x S m :Hm } (Π1 ), for every {x1 : H1 , . . . , xm : Hm }. Applying (D) on Π′1 , we get Π′ : M1 2M2 M3 , where w1 wν M1 ≡ [(K1w1 , . . . , Km ; K w1 ), . . . , (K1wν , . . . , Km ; K wν )]

2M2 ≡ M3 ≡

by (ii)

qt qt1 qtµ [(K1qt1 , . . . , Km ; K qt1 ), . . . , (K1 µ , . . . , Km ; K qtµ ), plt plt1 pltµ (K1plt1 , . . . , Km ; K plt1 ), . . . , (K1 µ , . . . , Km ; K pltµ )] by (iii) pru1 pruκ pru1 pru1 pruκ [(K1 , . . . , Km ; K ), . . . , (K1 , . . . , Km ; K pruκ )] by

(iv)

It is Mx1 ,...,xm (Π′ ) ≡ Mx1 ,...,xm (Π′1 ) ≡ T{x1 :H1 ,...,xm :Hm } (Π1 ) ≡ T{x1 :K1 ,...,xm :Km } (Π), for every {x1 : K1 , . . . , xm : Km }. The result is similarly shown when q (resp. p) is a substring of p (resp. q). • Case (∪E): Π1 : Hi [p := σi ] ⊢ L[p := σ ∪ τ ]

Π2 : Hi [p := [σi , σi ]], L[p := [σ, τ ]] ⊢ H[p := [ρ, ρ]]

Π : Hi [p := σi ] ⊢ H[p := ρ] To simplify, suppose the notation Ki ≡ Hi [p := σi ], Ei ≡ Hi [p := [σi , σi ]] (1 6 i 6 m), G ≡ L[p := σ ∪ τ ], E ≡ L[p := [σ, τ ]], F ≡ H[p := [ρ, ρ]], and K ≡ H[p := ρ], so that the rule can be rewritten as Π1 : Ki ⊢ G

Π2 : Ei , E ⊢ F

Π : Ki ⊢ K

16

Y. Stavrinos, A. Veneti / Towards a logic for union types

If PT (F ) = {q1 , . . . , qk , pl, pr}, where k + 1 = n, then: (i) PT (K) = PT (G) = {q1 , . . . , qk , p} q

q

(ii) Ei j ≡ Ki j , E qj ≡ Gqj , F qj ≡ K qj (1 6 i 6 m, 1 6 j 6 k) (iii) Eips ≡ Kip ≡ σi , F ps ≡ K p ≡ ρ (1 6 i 6 m, s ∈ {l, r}) (iv) E pl ≡ σ, E pr ≡ τ, Gp ≡ σ ∪ τ S By the IH, there exist Π′1 : M [(σ1 , . . . , σm ; σ ∪ τ )], where q1 qk M ≡ [(K1q1 , . . . , Km ; Gq1 ), . . . , (K1qk , . . . , Km ; Gqk )]

and Π′2 : N

S

[(σ1 , . . . , σm , σ ; ρ), (σ1 , . . . , σm , τ ; ρ)], where q1 qk N ≡ [(E1q1 , . . . , Em , E q1 ; F q1 ), . . . , (E1qk , . . . , Em , E qk ; F qk )]

such that Mx1 ,...,xm (Π′1 ) ≡ N ≡ T{x1 :K1 ,...,xm :Km } (Π1 ), for every {x1 : K1 , . . . , xm : Km }, and Mx1 ,...,xm ,x (Π′2 ) ≡ M ≡ T{x1 :E1 ,...,xm :Em ,x:E} (Π2 ), for every {x1 : E1 , . . . , xm : Em , x : E}. q1 qk By (ii), we have that N ≡ [(K1q1 , S . . . , Km , Gq1 ; K q1 ), . . . , (K1qk , . . . , Km , Gqk ; K qk )]. Applying (∪E) on Π′1 , Π′2 , we get Π′ : M′ [(σ1 , . . . , σm ; ρ)], where q1 qk M′ ≡ [(K1q1 , . . . , Km ; K q1 ), . . . , (K1qk , . . . , Km ; K qk )]

It is Mx1 ,...,xm (Π′ ) ≡ M [N/x] ≡ T{x1 :K1 ,...,xm :Km } (Π), for every {x1 : K1 , . . . , xm : Km }.

⊓ ⊔

1 n Proposition 7.1. Let M ≡ [(σ11 , . . . , σm ; τ1 ), . . . , (σ1n , . . . , σm ; τn )] be a molecule of n > 1 atoms of context-cardinality m > 0. Then, there exists a sequence of m + 1 overlapping kits p K1 , . . . , Km , K with n terminal paths p1 , . . . , pn , such that Ki j ≡ σij and K pj ≡ τj (1 6 i 6 m, 1 6 j 6 n).

Proof: By induction on n.

⊓ ⊔

Definition 7.1. The sequence K1 , . . . , Km , K of overlapping kits set out in Proposition 7.1 will be called a kit-representation of M. It is obvious that a kit-representation of a molecule M is not unique; different kit-representations of M have different tree structures. 1 n Theorem 7.2. Consider an IUL(m) deduction Π : M ≡ [(σ11 , . . . , σm ; τ1 ), . . . , (σ1n , . . . , σm ; τn )] with n > 1 and m > 0. For every kit-representation K1 , . . . , Km , K of M, there exists Π′ : {K1 , . . . , Km } ⊢ K in IUL, such that T{x1 :K1 ,...,xm :Km } (Π′ ) ≡ Mx1 ,...,xm (Π), for every decoration {x1 : K1 , . . . , xm : Km }.

Proof: By induction on Π. The most interesting cases are described.

Y. Stavrinos, A. Veneti / Towards a logic for union types

• Case (P ): S Π1 : M N Π:M j n+j where M ≡ [(σ1j , . . . , σm ; τj ) | 1 6 j 6 n] and N ≡ [(σ1n+j , . . . , σm ; τn+j ) | 1 6 j 6 k].

Let K1 , . . . , Km , K be a kit-representation of M and H1 , . . . , Hm , H a kit-representation of N . Then, [K1 , H1 ], . . . , [Km , Hm ], [K, H] is a kit-representation of M ∪ N . So, by the IH, there exists Π′1 : {[K1 , H1 ], . . . , [Km , Hm ]} ⊢ [K, H] in IUL, such that T{x1 :[K1 ,H1 ],...,xm :[Km ,Hm ]} (Π′1 ) ≡ Mx1 ,...,xm (Π1 ), for every {x1 : [K1 , H1 ], . . . , xm : [Km , Hm ]}. Applying (P ) on Π′1 at path l, we get Π′ : {K1 , . . . , Km } ⊢ K. It is T{x1 :K1 ,...,xm :Km } (Π′ ) ≡ T{x1 :[K1 ,H1 ],...,xm :[Km ,Hm ]} (Π′1 ) ≡ Mx1 ,...,xm (Π1 ) ≡ Mx1 ,...,xm (Π), for every {x1 : K1 , . . . , xm : Km }. • Case (D): S Π1 : M N S Π : M 2N j n+j where M ≡ [(σ1j , . . . , σm ; τj ) | 1 6 j 6 n] and N ≡ [(σ1n+j , . . . , σm ; τn+j ) | 1 6 j 6 k]. S Let K1 , . . . , Km , K be a kit-representation of M 2N , i.e. a sequence of overlapping kits of n+2k terminal paths. By k successive prunings S of all sequence members at appropriate paths, we get a kit-representation H1 , . . . , Hm , H of M N , i.e. a kit sequence of n+k terminal paths. By the IH, there exists Π′1 : {H1 , . . . , Hm } ⊢ H in IUL, such that T{x1 :H1 ,...,xm :Hm } (Π′1 ) ≡ Mx1 ,...,xm (Π1 ), for every {x1 : H1 , . . . , xm : Hm }. Applying k doublings on Π′1 , i.e. duplicating appropriate leaves at appropriate paths, we get Π′ : {K1 , . . . , Km } ⊢ K. It is T{x1 :K1 ,...,xm :Km } (Π′ ) ≡ T{x1 :H1 ,...,xm :Hm } (Π′1 ) ≡ Mx1 ,...,xm (Π1 ) ≡ Mx1 ,...,xm (Π), for every {x1 : K1 , . . . , xm : Km }.

• Case (∪E): Π1 : [(Γ ; σ ∪ τ )]

S

[(Γj ; φj )]j

Π2 : [(Γ, σ ; ρ), (Γ, τ ; ρ)] S Π : [(Γ ; ρ)] [(Γj ; ψj )]j

S

[(Γj , φj ; ψj )]j

j where Γ ≡ σ1 , . . . , σm and Γj ≡ σ1j , . . . , σm , for 1 6 j 6 n. S Let K1 , . . . , Km , K be a kit-representation of [(Γ ; ρ)] [(Γj ; ψj )]j . The kits have n + 1 terminal p paths q, p1 , . . . , pn , such that Kiq ≡ σi , Ki j ≡ σij , K q ≡ ρ and K pj ≡ ψj (1 6 i 6 m,S1 6 j 6 n). Then K1 , . . . , Km , K[q := σ ∪ τ ][pj := φj ] is a kit-representation of [(Γ ; σ ∪ τ )] [(Γj ; φj )]j and H1 , . . . , Hm , K[q := [σ, τ ]][pj := φSj ], K[q := [ρ, ρ]], where Hi ≡ Ki [q := [σi , σi ]], is a kit-representation of [(Γ, σ ; ρ), (Γ, τ ; ρ)] [(Γj , φj ; ψj )]j . By the IH, there exist IUL deductions

Π′1 : K1 , . . . , Km ⊢ K[q := σ ∪ τ ][pj := φj ] Π′2 : H1 , . . . , Hm , K[q := [σ, τ ]][pj := φj ] ⊢ K[q := [ρ, ρ]] | {z } H such that T{x1 :K1 ,...,xm :Km } (Π′1 ) ≡ N ≡ Mx1 ,...,xm (Π1 ), for every {x1 : K1 , . . . , xm : Km }, and T{x1 :H1 ,...,xm :Hm ,x:H} (Π′2 ) ≡ M ≡ Mx1 ,...,xm ,x (Π2 ), for every {x1 : H1 , . . . , xm : Hm , x : H}. Applying (∪E) at q on Π′1 , Π′2 , we get Π′ : K1 , . . . , Km ⊢ K, such that T{x1 :K1 ,...,xm :Km } (Π′ ) ≡ M [N/x] ≡ Mx1 ,...,xm (Π), for every {x1 : K1 , . . . , xm : Km }. ⊓ ⊔

17

18

Y. Stavrinos, A. Veneti / Towards a logic for union types

Remark 7.1. Theorem 7.1 indicates that each terminal path of the kits in the conclusion of Π gives rise to an atom in the molecule proved by Π′ . Conversely, Proposition 7.1 indicates that all formulas in an atom of M are leaves at the same terminal path in a kit-representation of M. Therefore, terminal paths in IUL correspond to atoms in IUL(m) . In addition, it is easy to see, in both Theorems 7.1 and 7.2, that the context cardinality of the judgement proved by an IUL deduction coincides with the atom context cardinality of the molecule proved by the corresponding IUL(m) deduction. Since the logical systems IUL and IUL(m) are proved equivalent, we can now restate Theorem 4.1 in the molecule framework. j Theorem 7.3. Let Π : [(σ1j , . . . , σm ; τj ) | 1 6 j 6 n] be in IUL(m) . For every j ∈ {1, . . . , n}, j there exists (modulo conversion of connectives) a deduction Πj : σ1j , . . . , σm ⊢ τj in ML→ , such j j j j that T{x1 : σj ,...,xm : σm } (Π ) ≡ Mx1 ,...,xm (Π), for every decoration {x1 : σ1 , . . . , xm : σm }. 1

Proof: By Theorems 7.2 and 4.1.

⊓ ⊔

Example 7.1. Consider the IUL deduction Π : [σ, τ ] ⊢ [(α → θ) → θ, ρ → η] and its ML projections Πl : σ ⊢ (α → θ) → θ and Πr : τ ⊢ ρ → η as in Example 4.1. Deduction Π′ , shown below, which results from subdeductions Π′0 , Π′1 by (∪E),

[(σ ; σ), (τ ; τ )] [(σ, α → θ ; σ), (τ, ρ ; τ )] [(σ, α → θ ; α), (τ, ρ ; δ)]

(W ) (∩E) (∪I)

Π′0 : [(σ, α → θ ; α), (τ, ρ ; δ ∪ ζ)]

[(α → θ ; α → θ), (ρ ; ρ), (ρ ; ρ)]

(W )

[(α → θ, σ, α ; α → θ), (ρ, τ, δ ; ρ), (ρ, τ, ζ ; ρ)]

[(α ; α), (δ ; δ), (ζ ; ζ)]

(X)

[(σ, α → θ, α ; α → θ), (τ, ρ, δ ; ρ), (τ, ρ, ζ ; ρ)]

(∩E)

[(σ, α → θ, α ; α → θ), (τ, ρ, δ ; δ → η), (τ, ρ, ζ ; ζ → η)]

[(α, σ, α → θ ; α), (δ, τ, ρ ; δ), (ζ, τ, ρ ; ζ)] [(σ, α → θ, α ; α), (τ, ρ, δ ; δ), (τ, ρ, ζ ; ζ)]

(W ) (X) (→E)

Π′1 : [(σ, α → θ, α ; θ), (τ, ρ, δ ; η), (τ, ρ, ζ ; η)]

Π′0

Π′1

[(σ, α → θ ; θ), (τ, ρ ; η)]

(∪E)

Π′ : [(σ ; (α → θ) → θ), (τ ; ρ → η)]

(→ I)

is the IUL(m) deduction derived from Π according to Theorem 7.1. It gives two ML deductions Π1 ≡ Πl and Π2 ≡ Πr and its decoration is identical to Π’s, for every context decoration {x : [σ, τ ]}. In particular, it is Mx (Π′ ) ≡ T{x:[σ,τ ]}(Π) ≡ λy.yx.

Y. Stavrinos, A. Veneti / Towards a logic for union types

19

8. Relating ML→ to IUL(m) The aim of this section is to spotlight the problems evolving in the attempt to express the converse of Theorem 7.3. Suppose Π : ∆ = σ1 , . . . , σm ⊢ ρ is in ML→ . We would like to show that there exists (modulo ˜ : [(σ1 , . . . , σm ; ρ)] in IUL(m) , such that Mx1 ,...,xm (Π) ˜ ≡ conversion of connectives) a deduction Π T{x1 :σ1 ,...,xm :σm } (Π), for every decoration {x1 : σ1 , . . . , xm : σm }. Suppose we proceed by induction on Π and let us consider the case of (∧I). Π1 : ∆ = σ1 , . . . , σm ⊢ σ

Π2 : ∆ = σ1 , . . . , σm ⊢ τ

Π : ∆ = σ1 , . . . , σm ⊢ σ ∧ τ

(∧I)

Since Π is in ML→ , both Π1 and Π2 are in ML→ and moreover T∆∗ (Π1 ) ≡ T∆∗ (Π2 ), for every ˜ 1 : [(σ1 , . . . , σm ; σ)] decoration ∆∗ = {x1 : σ1 , . . . , xm : σm }. By the IH, we would get Π ˜ 2 : [(σ1 , . . . , σm ; τ )] in IUL(m) , such that Mx1 ,...,xm (Π˜1 ) ≡ T{x :σ ,...,x :σ } (Π1 ) and and Π 1 1 m m ˜ 2 ) ≡ T{x :σ ,...,x :σ } (Π2 ), for every decoration {x1 : σ1 , . . . , xm : σm }. Hence, we Mx1 ,...,xm (Π 1 1 m m ˜ 1 ) ≡ Mx1 ,...,xm (Π ˜ 2 ), for every ˜ 1 and Π ˜ 2 with Mx1 ,...,xm (Π would have two IUL(m) deductions Π sequence x1 , . . . , xm . We would like to be able to join together these deductions in a single IUL(m) deduction with the same implicative form as each of them. In general, we would appreciate a lemma stating the following claim: j n+j ˜ 1 : [(σ j , . . . , σm ˜ 2 : [(σ n+j , . . . , σm Claim 8.1. If Π ; σj ) | 1 6 j 6 n] and Π ; σn+j ) | 1 6 j 6 k] 1 1 ˜ 1 ) ≡ Mx1 ,...,xm (Π ˜ 2 ), for every sequence x1 , . . . , xm , then there exists are such that Mx1 ,...,xm (Π ˜ : [(σ j , . . . , σ j ; σj ) | 1 6 j 6 n + k], such that Mx1 ,...,xm (Π) ˜ ≡ Mx1 ,...,xm (Π ˜ 1 ), for every Π m 1 sequence x1 , . . . , xm .

This could be schematically represented as: j M : [(x : σ j , . . . , x : σm ; σ ) | 1 6 j 6 n] M : [(x : σ n+j , . . . , x : σ n+j ; σ ) | 1 6 j 6 k] . . . . . . . . 1. . . . .1. . . . . . . m . . . . . . . . . .j. . . . . . . . . . . . . . . . . . . . . . . . . . 1. . . . .1. . . . . . . . . .m. . . . .m. . . . . .n+j ................. j j M : [(x1 : σ1 , . . . , xm : σm ; σj ) | 1 6 j 6 n + k]

˜ 1 ) ≡ Mx1 ,...,xm (Π ˜ 2 )” might However, the example below illustrates that the condition “Mx1 ,...,xm (Π ˜ 1 and Π ˜ 2 to be joined together. not be sufficient for Π Example 8.1. Let σ1 ≡ (σ ∪ τ ) ∩ α, σ ≡ ρ ∩ β, τ ≡ γ ∩ ρ, τ1 ≡ φ ∩ δ, and τ2 ≡ (ζ ∪ ξ) ∩ ε. The ˜ 1 : [(σ1 , σ2 ; ρ)] and Π ˜ 2 : [(τ1 , τ2 ; φ)], which we show decorated, are such that IUL(m) deductions Π ˜ ˜ Mx,y (Π1 ) ≡ Mx,y (Π2 ) ≡ x .

x : [(σ1x ; σ1 )] x : [ ((σ1 , σ2 ) x,y ; σ1 ) ] x : [ ((σ1 , σ2 ) x,y ; σ ∪ τ ) ]

(W ) (∩E)

z : [(σ z ; σ), (τ z ; τ )] z : [ ((σ1 , σ2 , σ) x,y,z ; σ), ((σ1 , σ2 , τ ) x,y,z ; τ ) ] z : [ ((σ1 , σ2 , σ) x,y,z ; ρ), ((σ1 , σ2 , τ ) x,y,z ; ρ) ]

z [x/z] : [ ((σ1 , σ2 ) x,y ; ρ) ] | {z } x

(W, X) (∩E) (∪E)

20

Y. Stavrinos, A. Veneti / Towards a logic for union types

y : [(τ2y ; τ2 )]

(W, X)

y : [ ((τ1 , τ2 ) x,y ; τ2 ) ] y : [ ((τ1 , τ2 ) x,y ; ζ ∪ ξ) ]

(∩E)

x : [(τ1x ; τ1 ), (τ1x ; τ1 )] x : [ ((τ1 , τ2 , ζ) x,y,z ; τ1 ), ( (τ1 , τ2 , ξ) x,y,z ; τ1 ) ] x : [ ((τ1 , τ2 , ζ) x,y,z ; φ), ( (τ1 , τ2 , ξ) x,y,z ; φ) ]

(W ) (∩E) (∪E)

x [y/z] : [ ((τ1 , τ2 ) x,y ; φ) ] | {z } x

˜ : [(σ1 , σ2 ; ρ), (τ1 , τ2 ; φ)] in a bottom-up manner fails. Such However, any attempt to construct Π an attempt is demonstrated below.

N0 z }| { [(σ1 ; σ1 ), (τ1 ; τ2 )] [(σ1 , σ2 ; σ1 ), (τ1 , τ2 ; τ2 )] {z } | M0

N1 z }| { [(σ ; σ), (τ ; τ ), (ζ ; τ1 ), (ξ ; τ1 )]

(W )

(∩E)

[(σ1 , σ2 , σ ; σ), (σ1 , σ2 , τ ; τ ), (τ1 , τ2 , ζ ; τ1 ), (τ1 , τ2 , ξ ; τ1 )] {z } | M1

(W,X)

(∩E)

[(σ , σ ; σ ∪ τ ), (τ , τ ; ζ ∪ ξ)] [(σ , σ , σ ; ρ), (σ , σ , τ ; ρ), (τ , τ , ζ ; φ), (τ , τ , ξ ; φ)] . . . 1. . . .2. . . . . . . . . . . 1. . . 2. . . . . . . . . . . . . . . . . . . . .1. . . 2. . . . . . . . . . .1. . .2. . . . . . . . . .1. . .2. . . . . . . . . .1. . .2. . . . . . . (∪E)† ˜ : [(σ1 , σ2 ; ρ), (τ1 , τ2 ; φ)] Π

For this to work, we would need to have a notion of (∪E) applied in parallel on different groups of atoms; let us denote it (∪E)† . In the present example, though, even if (∪E)† was valid, we wouldn’t end up with IUL(m) axioms. This is because the formulas to the right of “;” in molecules M0 and M1 do not appear at the same positions in the contexts (sequences) to the left of “;”. Considering M0 , for example, formula σ1 in atom (σ1 , σ2 ; σ1 ) appears first in the context, while formula τ2 in atom (τ1 , τ2 ; τ2 ) appears second. As a consequence, any attempt to apply weakening and exchange rules bottom-up to reach axioms fails. As shown above, for example, applying weakening to M0 gives N0 , which is not an axiom, while applying exchange twice and then weakening twice to M1 gives N1 , which is not an axiom either. We could also apply weakening twice to M1 to get [(σ1 ; σ), (σ1 ; τ ), (τ1 ; τ1 ), (τ1 ; τ1 )], which again is not an axiom. It is obvious that any other combination of structural rules applied bottom-up to M0 , M1 would fail to give axioms. This problem is reflected termwise from the fact that different variables decorate corresponding premises of (∪E) ˜ 1 and Π ˜ 2 . This, in turn, reduces to the fact that two different kinds of substitution occur in the in Π ˜ 1 , while a pseudo-substitution two decorated deductions: a proper substitution z[x/z] decorates Π ˜ 2 . The variable x resulting from both substitution operations cannot but decorate x[y/z] decorates Π ˜1 different premises of (∪E) in the two deductions. In particular, it decorates the major premise of Π ˜ 2. and the minor premise of Π The above example depicts a well known problem with union types that stems from the ambiguity in how the substitution in (∪E) is decomposed (see [1, 14]).

9. Rule locality and globality We examine rule locality and globality in IUL and IUL(m) and explain how the flattening of kits to molecules vitiates the belief that (∪E) is local.

Y. Stavrinos, A. Veneti / Towards a logic for union types

In IUL, rule locality or globality depends on the number of terminal paths modified by a rule. In particular, rules (→ I), (→ E) affecting all terminal paths (leaves) are pronounced global, while rules (∩I), (∩E), (∪I), (∪E), (P ), (D) acting on specific terminal paths are pronounced local. The notation “ [p := ]” is taken to indicate a local rule, so (∪E) is hastily characterized local. The equivalence of IUL and IUL(m) reveals that terminal paths correspond to atoms. So, it is natural that rule locality or globality in IUL(m) depends on the number of atoms modified by a rule. In IUL(m) , it is easy to see that (→ I), (→ E), (W ), (X) are global, while (∩I), (∩E), (∪I), (P ), (D) are local. The crucial question is how to classify rule (∪E), is it local or global? Let A1 ≡ (Γ ; σ ∪ τ ), A2 ≡ (Γ, σ ; ρ), A3 ≡ (Γ, τ ; ρ), A ≡ (Γ ; ρ), Bj ≡ (Γj ; φj ), Cj ≡ (Γj , φj ; ψj ), and Dj ≡ (Γj ; ψj ). Then (∪E) of IUL(m) can be rewritten as:

[A1 ]

S

[ Bj ]j [A]

[A2 , A3 ] S

[ Dj ]j

S

[ Cj ]j

(∪E)

The rule works locally on atoms A1 , A2 , and A3 to give atom A and globally on the Bj ’s and Cj ’s to give the Dj ’s. It performs a proper union elimination on the former group of atoms and substitutions on the latter. Therefore, it could be infered that it displays both local and global characteristics. Another question then arises: since systems IUL and IUL(m) are proved equivalent, is (∪E) of IUL truly local? As presented in Figure 3, the rule exclusively concerns itself with what happens at path p, which, as already mentioned, is the reason for classifying it as local. However, if we try to rewrite it following what happens at any path q different from p, we get:

Hi [p := σi ][q := γi ] ⊢ K[p := σ ∪ τ ][q := φ] Hi [p := [σi , σi ]][q := γi ], K[p := [σ, τ ]][q := φ] ⊢ H[p := [ρ, ρ]][q := ψ] Hi [p := σi ][q := γi ] ⊢ H[p := ρ][q := ψ]

Collecting leaves at path q from all kits in the major premise, we construct an atom (Γ ; φ), where Γ ≡ γ1 , . . . , γm . Acting likewise on the minor premise and the conclusion, we construct atoms (Γ, φ ; ψ) and (Γ ; ψ), respectively. Constructing atoms from terminal paths, which was actually the method followed to reveal the form of (∪E) in IUL(m) , makes it explicit that the rule carries out a substitution operation at any path q different from p. This was demonstrated in Theorem 4.1 (Case (∪E), subcase (1)) and also in Example 4.1 where (∪E) was applied on path r and a substitution operation was required for the formation of Πl . So, global characteristics are present in (∪E) of IUL, too, notwhithstanding that the awkward formalism of kits inhibits their detection. By inference, the use of molecules reveals the globality inherent in (∪E) resetting the issue of rule locality or globality. This issue is further studied and settled in [13], a work in progress, where we present a union logic in sequent calculus style. Using this style, we find that locality and globality of the union elimination rule are nicely separated in the left union rule and the cut rule, respectively. As rule classification becomes explicit, commutations of local rules work fine, so that equivalence classes of deductions can be defined.

21

22

Y. Stavrinos, A. Veneti / Towards a logic for union types

10. Conclusion and related work In this work, we seek for a logical interpretation of the intersection and union types assignment system IUT. Our first approach goes along the lines of Intersection Logic [9] by adding the obvious rules for union. We show that the resulting system IUL groups together deductions of minimal intuitionistic logic that admit the same non-standard decoration, i.e. deductions decorated within IUT. On the other hand, we point out some interesting issues posed by the presence of union in the system. The extra structural rules of Pruning and Doubling are needed to achieve commutation of certain pairs of local rules, but still not all commutations behave symmetrically. In addition, studying the relation of minimal logic ML to IUL brings out topics, like the decomposition of substitution, that require further investigation. Kits, being tree structures, are hard to manipulate. In our second approach, we use the formalism of molecules to define IUL(m) and make apparent a certain kind of globality inherent in the union elimination rule. However, since intersection and union should maintain their purely local behaviour, we somehow need to split the union elimination rule in two rules: one keeping its local aspect and another keeping its global aspect. This idea is worked out in [13] where a sequent calculus system with molecules is proposed. In this system, the above mentioned issues of IUL seem to get well solved. In the literature of intersection types there are different proposals aiming to give a logical meaning to intersection and union. The systems presented in this literature can be categorized as subject-based or predicate-based depending on whether they put the emphasis on the calculus (the assignment system) or on the logic. Systems a` la Church, like Λt∧ of [5], the typed calculus of [2], the flow types system λCIL of [14], or the branching types system λB of [15], are subject-based and build on explicitly typed calculi. These calculi may be proved useful in encoding commutations of rules of IUL, as well as the different decompositions of substitution. We may benefit from solutions proposed in [14], although the required term calculus might get very complicated because the terms will also have to depend on paths. As far as predicate-based systems are concerned, the molecules of ISL and the hyperformulae of HL [3] “linearize” the kits’ tree structure. The advantage of these systems is that they have a much simpler presentation so as to express the union rule, but the terms decorating their proofs are still untyped λ-terms. The Relevant logic of [4] is another interesting approach giving a logical foundation to intersection and union types, but in the context of a Hilbert-style logic with combinators decorating the proofs. Finally, the system with (generalized) typed kits of [8], although retaining the defects of the kit formalism, combines the good characteristics of both categories.

Acknowledgements We are grateful to Simona Ronchi Della Rocca for her valuable comments on the issue of locality/globality of the union elimination rule and to the anonymous referees for their useful remarks and suggestions.

References [1] Barbanera F., Dezani-Ciancaglini M., and de’Liguoro U., Intersection and Union Types: Syntax and Semantics, Information and Computation 119, pp. 202–230, Academic Press, 1995.

Y. Stavrinos, A. Veneti / Towards a logic for union types

23

[2] Bono V., Venneri B., and Bettini L., A Typed Lambda Calculus with Intersection Types, Theoretical Computer Science 398, pp. 95–113, Elsevier, 2008. [3] Capitani B., Loreti M., and Venneri B., Hyperformulae, Parallel Deductions, and Intersection Types, Proceedings of ICALP’01 Workshop: BOTH 2001, Electronic Notes in Theoretical Computer Science 50(2), pp. 178–195, 2001. [4] Dezani-Ciancaglini M., Ghilezan S., and Venneri B., The “Relevance” of Intersection and Union Types, Notre Dame Journal of Formal Logic 38(2), pp. 246–269, 1997. [5] Liquori L. and Ronchi della Rocca S., Intersection-Types a` la Church, Information and Computation 205(9), pp. 1371–1386, Elsevier, 2007. [6] Pimentel E., Ronchi della Rocca S., and Roversi L., Intersection Types: a Proof-Theoretical Approach, ICALP’05 Workshop, Proceedings of Structures and Deduction, pp. 189–204, 2005. [7] Pimentel E., Ronchi della Rocca S., and Roversi L., Intersection Types from a prooftheoretic perspective, 4th Workshop on Intersection Types and Related Systems, Torino, 2008. (http://imft.ftn.ns.ac.yu/ITRS08/itrs08 5 epsrdrlr.pdf) [8] Ronchi della Rocca S., Intersection Typed λ-calculus, Proceedings of 2nd Workshop on Intersection Types and Related Systems, Electronic Notes in Theoretical Computer Science 70(1), pp. 163–181, Elsevier Science, 2002. [9] Ronchi della Rocca S. and Roversi L., Intersection Logic, Proceedings of CSL’01, Lecture Notes in Computer Science 2142, pp. 414–428, Springer-Verlag, 2001. [10] Stavrinos Y. and Veneti A., Of kits and molecules, Panhellenic Logic Symposium, pp. 125–131, University (http://www.math.ntua.gr/∼gstav/kmpls07.pdf)

Proceedings of 6th of Thessaly, 2007.

[11] Veneti A., On a Logical Foundation of the Intersection Types Assignment System: Intersection Logics, Master’s Thesis, Graduate Program in Logic, Algorithms, and Computation (MPLA), University of Athens, 2007. (http://mpla.math.uoa.gr/msc/ files/A.Veneti.pdf) [12] Veneti A. and Stavrinos Y., Towards an intersection and union 4th Workshop on Intersection Types and Related Systems, Torino, (http://imft.ftn.ns.ac.yu/ITRS08/itrs08 6 avys.pdf)

logic, 2008.

[13] Veneti A. and Stavrinos Y., A Sequent Calculus for Intersection and Union Logic, Local Proceedings of 4th Conference on Computability in Europe, p. 514(524), University of Athens, 2008. (http://www.cs.swan.ac.uk/cie08/cie2008-local.pdf) [14] Wells J.B., Dimock A., Muller R., and Turbak F., A Calculus with Polymorphic and Polyvariant Flow Types, Journal of Functional Programming 12(3), pp. 183–227, Cambridge University Press, 2002. [15] Wells J.B. and Haack C., Branching Types, Proceedings of 11th European Symposium on Programming, Lecture Notes in Computer Science 2305, pp. 115–132, Springer-Verlag, 2002.

24

Y. Stavrinos, A. Veneti / Towards a logic for union types

A.

Erasure

In this section, we give the formalism of the erasure operation, which allows us to convert assignment systems to logics. Together with decorations, which make conversions from logics to assignment systems, they offer a full picture of system relations in the area discussed (see appendix C). Erasures have simpler notation than decorations and are easily defined by induction. However, in the present work we emphasize on the logics side and therefore we privilege the decoration operations. We first define an erasure operation Et that converts IUT deductions to ML deductions by erasing all term information. This conversion is modulo appropriate modifications on connectives. Definition A.1. (Erasure Et ) (i) Let (−)e be a function from IUT contexts to ML contexts defined as ({x1 : σ1 , . . . , xn : σn })e = {σ1 , . . . , σn }. (ii) Every deduction Π : Γ ⊢ M : σ in IUT can be associated through an inductive algorithm to a deduction Et (Π) : Γe ⊢ σ in ML. We show the basis and some inductive cases. •







x:σ∈Γ (Ax) Π:Γ⊢x:σ Π1 : Γ, x : σ ⊢ M : τ Π : Γ ⊢ λx.M : σ → τ Π1 : Γ ⊢ M : σ

σ ∈ Γe (Ax) Et (Π) : Γe ⊢ σ



(→ I)

Π2 : Γ ⊢ M : τ

Π: Γ ⊢ M : σ∩τ Π1 : Γ ⊢ N : σ ∪ τ

Et (Π1 ) : Γe ⊢ σ ∨ τ

Et (Π1 ) : Γe , σ ⊢ τ



Et (Π) : Γe ⊢ σ → τ (∩I) ⇒

Π2 : Γ, x : σ ⊢ M : ρ

(→ I)

Et (Π1 ) : Γe ⊢ σ

Et (Π2 ) : Γe ⊢ τ

Et (Π) : Γe ⊢ σ ∧ τ Π3 : Γ, x : τ ⊢ M : ρ

Π : Γ ⊢ M [N/x] : ρ Et (Π2 ) : Γe , σ ⊢ ρ Et (Π) : Γe ⊢ ρ

Et (Π3 ) : Γe , τ ⊢ ρ

(∪E)

(∧I)



(∨E)

Remark A.1. (i) The operation Et is not one-to-one. For example, the distinct IUT axioms x : σ ⊢ x : σ and y : σ ⊢ y : σ both correspond to the ML axiom σ ⊢ σ. (ii) Moreover, Et is not onto ML. For an example, consider the ML deduction Π2 of Example 2.1. (iii) In fact, Et is onto ML→ . For any Π : ∆ = σ1 , . . . , σm ⊢ τ in ML→ , there exists Π∗ : ∆∗ = {x1 : σ1 , . . . , xm : σm } ⊢ T∆∗ (Π) : τ in IUT, such that Et (Π∗ ) ≡ Π. (iv) Had we defined Et from deductions in the simple types system λ∧∨ → to deductions in ML, then it would have been onto ML. We proceed to define an assignment system IUK, where kits take the role of types. It builds on IUL by including term annotations. It is actually the non-standard decoration of IUL seen as an assignment system.

Y. Stavrinos, A. Veneti / Towards a logic for union types

25

Definition A.2. (IUK) The kit assignment system IUK assigns kits to terms of the untyped λ-calculus. (i) An IUK context is a finite set {x1 : H1 , . . . , xm : Hm } of kit assignments to distinct variables. (ii) The system IUK proves judgements Γ ⊢ M : K, where Γ is an IUK context and K is a kit. Figure 5 presents its rules. x:K ∈Γ (Ax) Γ⊢x:K xi : Hi ⊢ M : H xi : Hi \

ps

⊢ M : H\

Γ, x : H ⊢ M : K

ps

(→ I)

Γ ⊢ λx.M : H → K

(P )

xi : Hi ⊢ M : H xi : Hi q/ps ⊢ M : H q/ps

Γ⊢M :H →K Γ ⊢ N : H (→ E) Γ ⊢ MN : K

xi : Hi [p := [σi , σi ]] ⊢ M : H[p := [σ, τ ]] xi : Hi [p := σi ] ⊢ M : H[p := σ ∩ τ ]

(∩I)

Γ ⊢ M : H[p := σs ] Γ ⊢ M : H[p := σl ∪ σr ] xi : Hi [p := σi ] ⊢ N : K[p := σ ∪ τ ]

(D)

Γ ⊢ M : H[p := σl ∩ σr ] Γ ⊢ M : H[p := σs ]

(∩E s )

(∪I s )

xi : Hi [p := [σi , σi ]], x : K[p := [σ, τ ]] ⊢ M : H[p := [ρ, ρ]]

xi : Hi [p := σi ] ⊢ M [N/x] : H[p := ρ]

(∪E)

Figure 5. Kit assignment system IUK. We now define an erasure operation Ek from IUK deductions to IUL deductions that erases the term annotations in a natural way. Definition A.3. (Erasure Ek ) (i) Suppose (−)e is a function from IUK contexts to IUL contexts defined as ({x1 : H1 , . . . , xm : Hm })e = {H1 , . . . , Hm }. (ii) Every Π : Γ ⊢ M : K in IUK can be inductively associated to a deduction Ek (Π) : Γe ⊢ K in IUL. The process is similar to the one described in Definition A.1. We show the basis and one inductive case. •



x:K ∈Γ (Ax) Π:Γ⊢x:K Π1 : Γ ⊢ M : H → K

K ∈ Γe (Ax) Ek (Π) : Γe ⊢ K



Π2 : Γ ⊢ N : H

Π : Γ ⊢ MN : K

Ek (Π1 ) : Γe ⊢ H → K

Ek (Π2 ) : Γe ⊢ H

Ek (Π) : Γe ⊢ K

(→ E)

(→ E)



26

Y. Stavrinos, A. Veneti / Towards a logic for union types

Remark A.2. (i) The operation Ek is not one-to-one for the same reason that Et isn’t. (ii) Contrarily to Et not being onto ML, Ek is onto IUL. For any Π : ∆ = K1 , . . . , Km ⊢ K in IUL, there exists Π⋆ : ∆⋆ = {x1 : K1 , . . . , xm : Km } ⊢ T∆⋆ (Π) : K in IUK, such that Ek (Π⋆ ) ≡ Π. Remark A.3. Consider the IUT deduction Π and its erasure Et (Π) shown below. A : {x : α, y : α, z : α} ⊢ x : α {x : α, y : α} ⊢ λz.x : α → α

(→ I)

Π : {x : α} ⊢ λy.λz.x : α → α → α

(→ I)

Et (A) : {α, α, α} ⊢ α {α, α} ⊢ α → α

(→ I)

Et (Π) : {α} ⊢ α → α → α

(→ I)

This example is yet another argument in favour of the choice to define ML contexts as multisets rather than sets. This way, any judgement of Et (Π) is the exact term-free analogue of the corresponding judgement of Π; for example, A and Et (A). Consequently, corresponding judgements have the same context cardinality. Had we defined ML contexts as sets, Et (Π) would have been: {α} ⊢ α {α} ⊢ α → α

(→ I)

Et (Π) : {α} ⊢ α → α → α

(→ I)

As in the case of projections, to retain the same number of occurrences of α in corresponding contexts, which guarantees the structural similarity between Π and Et (Π) required by Definition A.1, we would have had to represent the singleton {α} as a union of {α}’s. Even so, though, we would have lost context cardinality correspondence. This argument adjusted to IUK and Ek explains our choice to define IUL contexts as multisets, as well. Using the erasure operations Et , Ek and Theorem 4.1, we can state a theorem relating IUK to IUT. Theorem A.1. Let Π : {x1 : K1 , . . . , xm : Km } ⊢ M : K be in IUK . For every p ∈ P T (K), p there exists Πp : {x1 : K1p , . . . , xm : Km } ⊢ M : K p in IUT, such that (Ek (Π))p ≡ Et (Πp ).

Proof: By induction on Π.

⊓ ⊔

Remark A.4. Both (Ek (Π))p and Et (Πp ) are deductions in ML→ .

B. Commutations of rules In this section, we examine with examples the behaviour of pairs of local rules as far as commuting is concerned. The pairs (∩I, ∩E), (∩E, ∩E), (∩E, ∪I), (∪I, ∪I), (∩I, ∪I), (∩I, ∩I), (∩E, ∪E), and (∪I, ∪E) can be interchanged symmetrically. On the contrary, the pairs (∩I, ∪E) and (∪E, ∪E) cannot. Commuting pairs: The cases of (∩I, ∩E) and (∩E, ∩E) can be found in [9]. The rest are shown below. The interchange relation “∼” is symmetric.

Y. Stavrinos, A. Veneti / Towards a logic for union types

Γ ⊢ [σ ∩ τ, ρ]

(∩E)l

Γ ⊢ [σ, ρ]

(∪I)r

Γ ⊢ [σ, ρ ∪ φ]

Γ ⊢ [σ, ρ]

Γ ⊢ [σ ∩ τ, ρ] ∼

Γ ⊢ [σ ∪ τ, ρ]

Γ ⊢ [σ ∪ τ, ρ ∪ φ]

[[σ, σ], τ ] ⊢ [[ζ, ξ], ρ] [σ, τ ] ⊢ [ζ ∩ ξ, ρ]

(∪I)r

[σ, τ ] ⊢ [ζ ∩ ξ, ρ ∪ φ]

[[σ, σ], [τ, τ ]] ⊢ [[ζ, ξ], [ρ, φ]] [σ, [τ, τ ]] ⊢ [ζ ∩ ξ, [ρ, φ]]

(∩I)l

(∩I)r

[σ, τ ] ⊢ [ζ ∩ ξ, ρ ∩ φ]

(∩E)l

Γ ⊢ [σ, ρ] ∼

(∪I)r

(∩I)l

(∪I)r

Γ ⊢ [σ ∩ τ, ρ ∪ φ] Γ ⊢ [σ, ρ ∪ φ]

(∪I)l

(∪I)r

Γ ⊢ [σ, ρ ∪ φ]

Γ ⊢ [σ ∪ τ, ρ ∪ φ]



[[σ, σ], τ ] ⊢ [[ζ, ξ], ρ ∪ φ] [σ, τ ] ⊢ [ζ ∩ ξ, ρ ∪ φ]



[σ, τ ] ⊢ [ζ ∩ ξ, ρ ∩ φ]

(∩E)l

(∪E)r

[σ, [τ, τ ]], [ψ, [ρ, φ]] ⊢ [ζ ∩ ξ, [η, η]] [σ, τ ] ⊢ [ζ ∩ ξ, η] [σ, τ ] ⊢ [ζ, η]

[σ, [τ, τ ]], [ψ, [ρ, φ]] ⊢ [ζ ∪ ξ, [η, η]] [σ, τ ] ⊢ [ζ ∪ ξ, η] [σ, [τ, τ ]], [ψ, [ρ, φ]] ⊢ [ζ, [η, η]] [σ, τ ] ⊢ [ζ, η] [σ, τ ] ⊢ [ζ ∪ ξ, η]

(∩I)r (∩I)l



(∪E)r

(∩E)l

[σ, [τ, τ ]], [ψ, [ρ, φ]] ⊢ [ζ, [η, η]]

[σ, τ ] ⊢ [ψ, ρ ∪ φ]

(∩I)l

[[σ, σ], τ ] ⊢ [[ζ, ξ], ρ ∩ φ]

[σ, τ ] ⊢ [ζ, η]

[σ, τ ] ⊢ [ψ, ρ ∪ φ]

(∪I)r

[[σ, σ], [τ, τ ]] ⊢ [[ζ, ξ], [ρ, φ]]

[σ, [τ, τ ]], [ψ, [ρ, φ]] ⊢ [ζ, [η, η]]

[σ, τ ] ⊢ [ψ, ρ ∪ φ]

(∪I)l

[[σ, σ], τ ] ⊢ [[ζ, ξ], ρ]

[σ, [τ, τ ]], [ψ, [ρ, φ]] ⊢ [ζ ∩ ξ, [η, η]] [σ, τ ] ⊢ [ψ, ρ ∪ φ]

27

(∪I)l (∪E)r



(∪E)r

(∪I)l

Non-commuting pairs: The case of (∩I, ∪E) was discussed in detail in section 5. In the case of (∪E, ∪E) shown below, additional rules (Doubling and an admissible Weakening), as well as restrictions on certain leaves are called up to achieve commutation. The interchange relation “֒→” is not symmetric.

28

Y. Stavrinos, A. Veneti / Towards a logic for union types

[σ, [τ, τ ]], [ρ, [φ, χ]] ⊢ [ψ ∪ ω, [θ, θ]] [σ, τ ] ⊢ [ρ, φ ∪ χ]

[[σ, σ], [τ, τ ]], [[ρ, ρ], [φ, χ]], [[ψ, ω], [θ, θ]] ⊢ [[ζ, ζ], [ξ, ξ]]

[σ, [τ, τ ]], [ρ, [φ, χ]] ⊢ [ζ, [ξ, ξ]] [σ, τ ] ⊢ [ζ, ξ]

[σ, τ ] ⊢ [ρ, φ ∪ χ]

(∪E)r

[σ, [τ, τ ]], [ρ, [φ, χ]] ⊢ [ψ ∪ ω, [θ, θ]]

֒→

(∪E)l

[σ, τ ] ⊢ [ψ ∪ ω, θ] [σ, τ ] ⊢ [ζ, ξ]

(∪E)r

Π

(∪E)l

where Π is the following deduction: [σ, τ ] ⊢ [ρ, φ ∪ χ]

(D)l [[σ, σ], τ ] ⊢ [[ρ, ρ], φ ∪ χ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (W ) [[σ, σ], τ ], [[ψ, ω], θ] ⊢ [[ρ, ρ], φ ∪ χ] [[σ, σ], [τ, τ ]], [[ψ, ω], [θ, θ], [[ρ, ρ], [φ, χ]] ⊢ [[ζ, ζ], [ξ, ξ]] Π : [[σ, σ], τ ], [[ψ, ω], θ] ⊢ [[ζ, ζ], ξ]

(∪E)r

To reorder (∪E)l and (∪E)r , the two leaves θ (in sub-kit [θ, θ]) must be identical, so that (∪E)r can be applied (twice) in the transformed deduction. We thus restrict the premises of (∪E)l , since, in general, we would apply the rule for different such leaves.

C.

An overall figure

We end up by giving, in Figure 6, an overall picture of the four systems presented in this article, i.e. ML→ , IUL, IUT, and IUK, interrelated by decorations and erasures. Theorems 4.1 and A.1 are located at the logics level and assignment systems level, respectively.

Y. Stavrinos, A. Veneti / Towards a logic for union types

29

formulas ML kits ML→

IUL Theorem 4.1. -

Logics:

6

decoration ( )⋆

6

erasure Ek

decoration ( )∗

?

erasure Et ?

λ∧∨ →

IUK

IUT Theorem A.1. -

Assignment systems:

kits Figure 6. Logics and assignment systems.

types