July, 2018
Multirole Logic and Multiparty Channels
Abstract
We identify multirole logic as a new form of logic in which conjunction/disjunction is interpreted as an ultrafilter on some underlying set of roles and the notion of negation is generalized to endomorphisms on this set. We formulate both multirole logic (MRL) and linear multirole logic (LMRL) as natural generalizations of classical logic (CL) and classical linear logic (CLL), respectively. Among various meta-properties established for MRL and LMRL, we obtain one named multiparty cut-elimination stating that every cut involving one or more sequents (as a generalization of a binary cut involving exactly two sequents) can be eliminated, thus extending the celebrated result of cut-elimination by Gentzen. As a side note, we also give an ultrafilter-based interpretation for intuitionism, formulating MRLJ as a natural generalization of intuitionistic logic (IL). An immediate application of LMRL can be found in a formulation of session types for channels that support multiparty communication in distributed programming. We present a multi-threaded lambda-calculus (MTLC) where threads communicate on linearly typed multiparty channels that are directly rooted in LMRL, establishing for MTLC both type preservation and global progress. The primary contribution of the paper consists of both identifying multirole logic as a new form of logic and establishing a theoretical foundation for it, and the secondary contribution lies in applying multirole logic to the practical domain of distributed programming.
1 Introduction
While the first and foremost inspiration for multirole logic originates from studies on multiparty session types in distributed programming, it seems natural in retrospective to introduce multirole logic by exploring the well-known duality between conjunction and disjunction in classical logic. For instance, in a two-sided presentation of the classical sequent calculus (LK), we have the following rules for conjunction and disjunction:
where and range over sequents (that are essentially multisets of formulas). One possible explanation of this duality is to think of the availability of two roles and such that the left side of a sequent judgment (of the form ) plays role while the right side does role . In addition, there are two logical connectives and ; is given a conjunction-like interpretation by the side playing role and disjunction-like interpretation by the other side playing role , where ranges over and . With this explanation, it seems entirely natural for us to introduce more roles into classical logic.
Multirole logic is parameterized over a chosen underlying set of roles, which may be infinite, and we use to refer to this set. We use to range over role sets, which are just subsets of . Given any role set , we use for the complement of in . Also, we use for the disjoint union of and (where is assumed).
For the moment, let us assume that consists all of the natural numbers less than for some given . Intuitively, a conjunctive multirole logic is one in which there is a logical connective for each such that is given a conjunction-like interpretation by a side playing role and a disjunction-like interpretation otherwise. If we think of the universal quantifier as an infinite form of conjunction, then what is said about can be readily applied to as well. In fact, additive, multiplicative, and exponential connectives in linear logic [\citenameGirard, 1987] can all be treated in a similar manner. Dually, a disjunctive multirole logic can be formulated (by giving a disjunction-like interpretation if the side plays the role and a conjunction-like interpretation otherwise). We primarily focus on conjunctive multirole logic in this paper.
Given a formula and a set of roles, we write for an i-formula, which is some sort of interpretation of based on . For instance, the interpretation of based on is conjunction-like if holds, and it is disjunction-like otherwise. A crucial point, which we take from studies on multiparty session types, is that interpretation should be based on sets of roles rather than just individual roles. In other words, one side is allowed to play multiple roles simultaneously. A sequent in multirole logic is a multiset of i-formulas, and such a sequent is inherently many-sided as each appearing in represents precisely one side. As can be readily expected, the (binary) cut-rule in (either conjunctive or disjunctive) multirole logic is of the following form:
The cut-rule can be interpreted as some sort of communication between two parties in distributed programming [\citenameAbramsky, 1994, \citenameBellin & Scott, 1994, \citenameCaires & Pfenning, 2010, \citenameWadler, 2012]. For communication between multiple parties, it seems natural to seek a generalization of the cut-rule that involves more than two sequents. In conjunctive multirole logic, the admissibility of the following rule, which is given the name , can be established:
In disjunctive multirole logic, the admissibility of the following rule, which is given the name , can be established:
We may use the name mp-cut to refer to either mp-cut-conj or mp-cut-disj, which itself is a shorthand for multiparty-cut.
In classical logic, the negation operator is clearly one of a kind. With respect to negation, the conjunction and disjunction operators behave dually, and the universal and existential quantifiers behave dually as well. For the moment, let us write for the negation of . It seems rather natural to interpret as . Unfortunately, such an interpretation of negation immediately breaks for any (and it breaks as well). What we discover regarding negation is a bit of surprise: The notion of negation can be generalized to endomorphisms on the underlying set of roles. For instance, if maps to for , then the negation operator based on is of order , that is, and are equivalent for any formula in MRL (which is a multirole version of CL)
Furthermore, we incorporate the notion of multirole into intuitionistic logic as well as linear logic, formulating MRLJ and LMRL as multirole versions of IL and CLL, respectively. An immediate application of multirole logic can be found in the practical domain of distributed programming, where we make direct use of LMRL in a design of linearly typed channels for supporting communication between multiple parties.
The rest of the paper is organized as follows. In Section 2, we formulate MRL, a multirole version of first-order classical predicate logic, and then mention some key meta-properties of MRL. In particular, we formally state the admissibility of a cut-rule (mp-cut) involving sequents for any . In Section 3, we present an ultrafilter-based interpretation for intuitionism, formulating MRLJ as a multirole version of first-order intuitionistic predicate logic. We move onto formulating LMRL in Section 4 as a multirole version of first-order linear classical predicate logic. In Section 5, we point out a profound relation between LMRL and session types for multiparty channels. Subsequently, we present in Section 6 and Section 7 a multi-threaded lambda-calculus equipped with linearly typed channels for multiparty communication, where the types for channels are directly rooted in LMRL, and briefly mention some implementation work in Section 8. Lastly, we compare with some closely related work and then conclude.
2 MRL: Multirole Logic
Let be the underlying (possibly infinite) set of roles for the multirole logic MRL presented in this section. Strictly speaking, this MRL should be referred to as first-order classical multirole predicate logic.
Definition 2.1
A filter on is a subset of the power set of such that
-
•
-
•
and implies
-
•
and implies
A filter on is an ultrafilter if either or holds for every subset of . We use to range over ultrafilters on . When there is no risk of confusion, we may simply use for the principal ultrafilter at , which is defined as . If is finite, then it can be readily proven that each on is a principal filter at some element .
Definition 2.2
Given an endomorphism on , that is, a mapping from to itself, we use for the set (image of under ) and for the set (pre-image of under ). Clearly, and , and is distributive over the following operations on sets: union, intersection, and complement.
Proposition 2.1
Given and , we use for the set . It is clear that is a filter (as is). If is an ultrafilter, then is also an ultrafilter.
Given an endomorphism on , we use for a unary connective. Given an ultrafilter on , we use for a binary connective and for a quantifier. Note that we may equally choose the name for (and for ) as the meaning of the named connective (quantifier) solely comes from the ultrafilter .
We use for first-order terms, which are standard (and thus not formulated explicitly for brevity). The formulas in MRL are defined as follows:
where ranges over pre-defined primitive formulas. Instead of writing something like , we write , where is a bound variable. Given a formula , a term and a variable , we use for the result of substituting for in and treat it as a proper subformula of . For notational convenience, we may also write for , for , and for .
Note that there is no connective for implication in MRL. If desired, one may simply treat as . We are only to introduce as a primitive connective corresponding to implication for each given pair of and when formulating an intuitionistic version of MRL.
Given a formula and a set of roles, is referred to as an i-formula (for interpretation of based on ). Let us use for multisets of i-formulas, which are also referred to as sequents. The inference rules for MRL are listed in Figure 1. In the rule (-pos), means that does not have any free occurrences in i-formulas contained inside . Please note that a sequent in this formulation is many-sided (rather than one-sided) as every appearing represents precisely one side.
Let us use for the size of , which is the number of connectives contained in , and use for derivations of sequents, which are just trees containing nodes that are applications of inference rules. Given a derivation , stands for the tree height of . When writing , we mean that is a derivation of , that is, is the conclusion of . We may use the following format to present an inference rule:
where for are the premisses of the rule and the conclusion. Such an inference rule is said to be admissible if its conclusion is derivable whenever its premisses are. Given two i-formulas and , we write to mean that the rule is admissible. And we write if holds for any role set . For instance, for any ultrafilter and formulas and , we have . In addition, we write for both and , and for both and .
As a new form of logic, MRL may not seem intuitive. We present as follows some simple properties to facilitate the understanding of MRL.
Proposition 2.2
For each injective endomorphism on , we have for any formula and role set .
Proof 2.1.
By the rule (), we have . Since is injective, we have .
Given an endomorphism on , we refer to as a permutation if it is actually a bijection and use for the inverse permutation of . Please note that for any role set .
Proposition 2.2.
Given any A, we have for each permutation on .
Proof 2.3.
This proposition follows from Proposition 2.2 as for any role set .
Given two endomorphisms and on , we write for a composition of and such that for . The set of permutations on forms a group where the group unit is the identity function , and the group inverse of is , and the group product of and is . Given a natural number , is defined to be if and if . The order of , if exists, is the least positive integer such that .
Proposition 2.4.
Assume that is finite. For each permutation on , we have for some .
Proof 2.5.
By a theorem of Lagrange, every permutation on a finite is of some order (such that divides for being the cardinality of ). By Proposition 2.2, we have . Since , we have (for any ). In other words, we have . For any , we have (by Lemma 2.13); we can derive by Proposition 2.2. Assume that is derivable. By cut-elimination (Lemma 2.8), we can derive . Hence, we have .
The classical sequent calculus LK of Gentzen is a special case of MRL where . In a two-sided formulation of LK, let us assume that the left side plays role and the right side does role ; the negation operator is for , that is, and ; the conjunction operator is , where refers to the principal ultrafilters at , and the disjunction operator is ; the universal quantifier is , and the existential quantifier is . Clearly, the order of the permutation is . Therefore, we have .
Proposition 2.6.
Given a permutation and an endomorphism , we write for the endomorphism . We have the following equivalences:
Proof 2.7.
The (straightforward) proof details are omitted for brevity. Notice that the two De Morgan’s laws in classical propositional logic are unified in (2). Also, please notice that the fact is captured in (4) that conjunction is distributive over disjunction and vice versa.
Clearly, Proposition 2.6 suggests that many notions of duality in mathematics can and should be revisited in the context of multirole logic.
2.1 Cut-Elimination for MRL
We establish in this section that MRL enjoys a form of cut-elimination possibly involving sequents for any . Essentially, we are to prove the following lemma:
Lemma 2.8 (mp-cut).
Let be subsets of for some . If holds, then the following inference rule (mp-cut) is admissible in MRL:
Let us first present some crucial properties of MRL as follows:
Lemma 2.9.
The following rule is admissible in MRL:
Proof 2.10.
By structural induction on . Note that we need the fact in the case where is of the form .
Let us use for a sequent that contains an indefinite number of occurrences of .
Lemma 2.11.
(Splitting of Roles) The following rule is admissible in MRL:
Proof 2.12.
We can directly prove the admissibility of the following rule by structural induction on :
Please note that the opposition of Lemma 2.11 is not valid, that is, the rule is not admissible.
Lemma 2.13.
Assume . The following rule is admissible in MRL:
Lemma 2.15.
(1-cut) The following rule is admissible in MRL:
Proof 2.16.
We can directly prove the admissibility of the following rule by structural induction on :
Note that Lemma 2.15 can be seen as a special form of cut-elimination where only one sequent is involved.
Lemma 2.17.
(2-cut with residual) Assume that and are disjoint. Then the following rule (2-cut-residual) is admissible in MRL:
Proof 2.18.
We omit the proof for this lemma as it can be done in essentially the same manner as is the presented proof of Lemma 4.9 (which is simply the counterpart of the current lemma expressed in the setting of linear multirole logic).
Proof 2.19.
This given proof of Lemma 2.8 clearly indicates that multiparty cut-elimination builds on top of Lemma 2.15 (1-cut) and Lemma 2.17 (2-cut-residual). In particular, one may see Lemma 2.15 and Lemma 2.17 as two fundamental meta-properties of a logic.
It should be clear that the rule (2-cut) (that is, the special case of (mp-cut) for sequents) plus Lemma 2.11 implies the rule (2-cut-residual): Assume we have and for some and such that and are disjoint; by applying Lemma 2.11 to , we have ; by applying (2-cut) to and , we have .
Also, it should be clear that the rule (3-cut) (that is, the special case of (mp-cut) for sequents) immediately implies the rule (2-cut-residual): Assume we have and for some and such that and are disjoint; we also have for by Lemma 2.13; therefore we have by (3-cut) (as ). This is a useful observation as what we actually implement in practice is the rule (3-cut) (for LMRL).
3 MRLJ: Intuitionistic MRL
If in classical logic the most prominent logical connective is negation, then it is implication in intuitionistic logic. Given an endomorphism and an ultrafilter (on ), we introduce a logical connective in MRLJ (for representing the notion of implication). The formulas in MRLJ are defined as follows:
We may also write for .
Definition 3.1.
Given an ultrafilter , a sequent is -intuitionistic if there is at most one i-formula in such that holds. An inference rule is -intuitionistic if and are -intuitionistic.
Intuitionistic multirole logic is parameterized over a fixed ultrafilter on . In MRLJ, we refer to this ultrafilter as . Every inference rule in Figure 1 is also an inference rule in MRLJ if it is -intuitionistic. In addition, we have the following rules for handling implication:
The intuitionistic sequent calculus LJ of Gentzen is a special case of MRLJ where and is the principal filter at ; the implication connective is for and being the principal filter at . As an example, the well-known fact that implies in LJ can be generalized in MRLJ as follows:
Proposition 3.2.
Given two permutations and , we have .
Proof 3.3.
It is a routine to verify that the following sequent is derivable in MRLJ for any role set :
Assume that is derivable. We have by cut-elimination (Lemma 3.6). Hence, holds. By symmetry, we thus have obtained .
In LJ, can be internalized as if . This form of internalization can be generalized in MRLJ as follows:
Proposition 3.4.
Assume that is derivable for and and . Then holds.
Proof 3.5.
It is a routine to verify that the following sequent is derivable in MRLJ:
Assume that is derivable. By cut-elimination for MRLJ (Lemma 3.6), we can derive . Hence, we have .
Lemma 3.6 (mp-cut).
Let be subsets of for some . If holds, then the following inference rule (mp-cut) is admissible in MRLJ:
where it is assumed that each is -intuitionistic for .
Proof 3.7.
The lemma can be proven in essentially the same fashion as is Lemma 2.8.
We see the very ability to incorporate intuitionism into multirole logic as solid evidence in support of multirole being an inherent notion in logic.
4 LMRL: Linear Multirole Logic
In this section, we generalize classical linear logic (CLL) to linear multirole logic (LMRL), which is to guide subsequently a design of linearly typed channels for multiparty communication in distributed programming.
Let be the full set of roles for LMRL. For each endomorphism on , we assume a corresponding unary connective (generalized negation). For each ultrafilter on , we assume two binary connectives and (corresponding to / and / in linear logic, respectively) and a unary connective (corresponding to / in linear logic) and a quantifier (corresponding to /). The formulas in LMRL are defined as follows:
We may write to mean for some , and to mean that each i-formula in is of the form .
The inference rules for LMRL are listed in Figure 2. Note that there are one rule for each , and one positive rule and two negative rules for each , and one positive rule and one negative rule for each , and one positive rule and three negative rules for each , and one positive rule and one negative rule for each . Let us take the rule (-neg-l) as an example; the i-formula is referred to as the major i-formula of the rule. Let us take the rule (-pos) as another example; the i-formula is referred to as the major i-formula of the rule. The major i-formulas for the other rules (excluding the rule (Id)) should be clear as well. For the rule (Id), each is referred to as a major i-formula.
Please recall that is for the size of that is, the number of connectives contained in , and for a derivation tree and for the height of the tree. Also, we use for a derivation of .
The following lemmas in LMRL are the counterparts of of a series of lemmas (Lemma 2.9, Lemma 2.11, Lemma 2.13, Lemma 2.15, Lemma 2.17, and Lemma 2.8) in MRL.
Lemma 4.1.
The following rule is admissible in LMRL:
Proof 4.2.
By structural induction on .
Given an i-formula , let us use for a sequent consisting of only if is not of the form for or some repeated occurrences of otherwise (that is, if is of the form for ).
Lemma 4.3.
(Splitting of Roles) The following rule is admissible in LMRL:
Proof 4.4.
We can directly prove the admissibility of the following rule by structural induction on :
Lemma 4.5.
Assume . The following rule is admissible in LMRL:
Lemma 4.7.
(1-cut) The following rule is admissible in LMRL:
Proof 4.8.
We can directly prove the admissibility of the following rule by structural induction on :
Lemma 4.9.
(2-cut with residual) Assume that and are disjoint. Then the following rule is admissible in LMRL:
Proof 4.10.
The proof for this lemma is given in Section 4.1.
Lemma 4.11 (mp-cut).
Let be subsets of for some . If holds, then the following inference rule (mp-cut) is admissible in LMRL:
Proof 4.12.
By following some recent work on encoding cut-elimination as reduction in variants of -calculus [\citenameCaires & Pfenning, 2010, \citenameWadler, 2012], we can readily formulate a variant of -calculus in which process reduction follows precisely the strategy employed in the proof of Lemma 4.9 for reducing the complexity of a cut-formula. Alternatively, we can interpret formulas in LMRL as session types for channels in a multi-threaded lambda-calculus and various meta-properties of LMRL as certain (primitive) functions on channels. We take the alternative here as it is closer to the goal of implementing session-typed multiparty channels for practical use.
4.1 Proof of Lemma 4.9
Due to the presence of the the structural rules (-neg-weaken) and (-neg-contract), we need to prove a strengthened version of Lemma 4.9 stating that the following rule is admissible in LMRL:
where we use for a sequent consisting of only if is not of the form for or some repeated occurrences of if is of the form for . The proof strategy we use is essentially adopted from the one in a proof of cut-elimination for classical linear logic (CLL) [\citenameTroelstra, 1992]. Please see Section A.1 in Appendix for details.
5 LMRL and Session Types
In broad terms, a session is a sequence of interactions between two or more concurrently running processes and a session type is a form of type for specifying or classifying the interactions in a session. In this section, we are to illustrate a profound relation between LMRL and session types by mostly relying on (informal) explanation and examples. In particular, we are to outline the manner in which logical connectives in LMRL and various type constructors for session types are related.
We use and in the rest of this section both for formulas in LMRL and for session types (which are formally defined in Section 7). We use CH for (logical) channels supporting communication between multiple parties (processes) involved in a session. How such channels can be implemented based on some forms of physical channels is beyond the scope of this paper. It is entirely possible that distinct logical channels can share one underlying physical channel.
We assume that each channel CH consists of one or more endpoints and each process holding one endpoint can communicate with the processes holding the other endpoints (of the same channel). We use to denote one endpoint of CH, where is a role set (that is, a subset of ). At any given time, if CH consists of endpoints , then . We say that a channel CH is of some session type if each endpoint can be assigned the type (where chan is some linear type constructor). We may write to mean for some role set . We see this view of a channel and its endpoints as a style of interpretation for Lemma 4.5.
Note that a process can only hold an endpoint of a channel (rather than a channel per se). Also note that each endpoint is a linear value and it can be consumed by a function call in the sense that the endpoint becomes unavailable for any subsequent use.
5.1 Primitive formulas
Let us use act for both a primitive formula in LMRL and a primitive session type. For each act, there is a function chan_sync of the following type:
where refers to the standard unit type. Assume that a channel CH of some session type act consists of endpoints and each endpoint is held by one process. When the (distinct) processes are calling chan_sync simultaneously on the endpoints (for ), some actions specified by act happen with respect to the role sets . It is certainly possible that the actions specified by a particular act can take place asynchronously, but there is no attempt to formally address this issue here.
As an example, let be a primitive formula for any given role . Assume that CH is of the session type . Then the specified action by a call of chan_sync on an endpoint can be described as follows:
-
•
Assume . Then consumes after broadcasting a message to the rest of the endpoints of CH.
-
•
Assume . Then consumes after receiving a message (sent from the endpoint for the only containing ).
Clearly, we may also have a primitive formula for any given role . The action specified by is opposite to what is specified by : The endpoint for the only containing receives a message from each of the other endpoints.
As another example, let be a primitive formula for any given pair of distinct roles and . Assume that CH is of the session type . Then the specified action by a call of chan_sync on can be described as follows:
-
•
Assume and . Then simply consumes .
-
•
Assume and . Then consumes after sending a message to the endpoint for the only containing .
-
•
Assume and . Then consumes after receiving a message (sent from the endpoint for the only containing ).
-
•
Assume and . Then simply consumes .
In other words, specifies a form of point-to-point messaging from the endpoint to the endpoint for and containing and , respectively.
5.2 Generalized Negation
Given an endomorphism on , there is a unary connective in LMRL that generalizes the notion of negation. The meaning of as a session type is given by the following function for eliminating the session type constructor :
Given an endpoint of type , chan_neg turns this endpoint into one of type . In other words, means that the process holding an endpoint needs to change the role set attached to the endpoint into the role set . In the case where is a permutation, simply means for a process to permute according to the roles it plays (e.g., server and client switch roles).
5.3 Additive conjunction/disjunction
Given a role , there is a binary connective in LMRL for the principal ultrafilter at (that consists of all of the role sets containing ). Let us write for this . Also, we may write to mean for some and to mean for some . For each CH of session type , there is exactly one endpoint of type and each of the other endpoints is of type . Intuitively, a process holding an endpoint of type can issue an order to turn the type of the endpoint into either or while any process holding an endpoint of type turns the type of the endpoint into either or by following an issued order.
Given two (linear) types and , let us write for the linear sum type of and . The following functions are for eliminating the session type constructor :
Assume that a channel CH is of session type and it consists of endpoints of the following types: . Without loss of generality, we may assume that . If there are one process calling chan_aconj_l (chan_aconj_r) on and processes calling chan_adisj on for , then these calls all return; the one calling chan_aconj_l (chan_aconj_r) obtains the same but its type changes to (); each of the other processes obtains a value of the type that is formed by attaching a tag to to indicate whether is given the type or . A direct implementation can simply be requiring the process calling chan_aconj_l (chan_aconj_r) on to send (via the underlying physical channel for CH) the tag 0 (1) to the other processes calling chan_adisj on for .
It should be noted that the meaning of based on a reading of is eliminatory (rather than introductory). Basically, the introductory meaning of a type is based on how a value of the type can be formed while the eliminatory meaning of the type is based on how a value of the type can be used. For instance, assume that is a sum type ; a value of can be formed by either left-injecting a value of type or right-injecting a value of type ; a value of can be eliminated by performing case analysis on the value. Introductorily, means to offer choice and choice while means to choose either or .
5.4 Multiplicative conjunction/disjunction
Given a role , there is a binary connective in LMRL for the principal ultrafilter at . Let us write for this . Also, we may write to mean for some and to mean for some . For each CH of session type , there is exactly one endpoint of type and each of the other endpoints is of type . Intuitively, a process holding an endpoint of type turns it into two endpoints of types and for being used in any interleaving order while any process holding an endpoint of type turns it into two endpoints of types and for being used concurrently. In other words, a process holding an endpoint of type can choose to interleave the interactions specified by and in any order while any process holding an endpoint of type must be able to handle any chosen order of interleaving of interactions specified by and .
Given two (linear) types and , let us write for the linear product type of and . We can introduce the following functions for eliminating the session type constructor :
Assume that a channel CH is of session type and it consists of endpoints of the following types: . Without loss of generality, we may assume that . If there are one process calling chan_mconj on and processes calling either chan_mdisj_l or chan_mdisj_r on for and some functions, then these calls all return; the one calling chan_mconj on returns a pair of endpoints and of types and , respectively; each of those processes calling chan_mdisj_l on (for some ) and some function obtains a pair of endpoints and and then keeps as the return value while passing to the function and initiating a thread to execute the function call; each of those processes calling chan_mdisj_r does analogously.
We do not specify the manner in which and are actually created or obtained as there are many possibilities in practice. For instance, it is possible to use CH for after requiring the process holding the endpoint to create a fresh channel so that the process keeps the endpoint for itself and sends each (via CH) to the process holding , where ranges from to . With this implementation strategy, () is often interpreted as output and then behave as (input and then behave as ) [\citenameWadler, 2012]. However, we see this interpretation as a form of convenience (rather than a logical consequence derived from LMRL). For instance, we can certainly have a different implementation that chooses a particular (e.g., ) and requires the process holding for the only containing to create and then sends its endpoints elsewhere. As far as we can see, LMRL specifies in the case of whether the two obtained endpoints and should be used interleavingly or concurrently but it does not specify how these two endpoints are actually obtained.
5.5 Session concatenation
Given two session types and , a process holding an endpoint of type for some can turn it into two endpoints of types and ) and then use them in any interleaving order it desires. We can have as a variant of : A process holding an endpoint of type for some can turn it into two endpoints of types and ) but is required to finish using the one of type before starting to use the other. There is actually no need in this case for the process to hold two endpoints simultaneously: We can introduce the following function chan_append that uses an endpoint of type first as an endpoint of type and then as an endpoint of type :
Note that (instead of ) occurs in the type of chan_append. Unlike chan_mconj (for ), chan_append is not required to send new endpoints to other processes and thus there is no difference between and even if and are distinct. In essence, the function chan_append takes an endpoint of type and a function; it first treats the endpoint as one of type and calls the function on it; the value returned by the function call is then paired with as the return value (of the call to chan_append).
Given two distinct roles and , we used to mean messaging from to . We now use to mean a value of type sent from to . We can introduce the following function for sending:
where it is assumed that and , and the following function for receiving:
where it is assumed that and . In the case where there are only two roles and , we may choose to write for and for . If one desires, one can even write for and for (or for and for ). In this case, it is fine to interpret as output/input, and it is also fine to interpret as input/output.
5.6 More session constructors
We may introduce a primitive formula nil for which the specified action is simply doing nothing. Given a role and a session type , we define as and define recursively as . Assume . A process holding an endpoint of type can choose to perform a session specified by on or simply terminate the use of . A process holding an endpoint of type can choose to perform a session specified by repeatedly.
Example 1. Let us assume the availability of 3 roles: Seller(0), Buyer1(1) and Buyer2(2). A description of the one-seller-and-two-buyers (S0B1B2) protocol due to [\citenameHonda et al., 2008] can essentially be given as follows: Buyer1 sends a book title to Seller; Seller replies a price quote to both Buyer1 and Buyer2; Buyer1 tells Buyer2 how much he can contribute; if Buyer2 is willing to pay for the remaining part, she sends Seller a proof of payment and Seller sends her a receipt for the sale (and the session ends); if Buyer2 is not willing, she terminates the session. Following is an encoding of the S0B1B2 protocol as a session type:
title(1, 0)@quote(0, 1)@quote(0, 2)@ contrib(1, 2)@option(2, proof(2, 0)@receipt(0, 2))
where title(1, 0)
means sending the title from role 1 to role 0;
quote(0, 1)
means sending the price quote from role 0 to role
1; contrib(1, 2)
means sending the amount of contribution of
Buyer1 from role 1 to role 2; etc.
Example 2. Let us assume the availability of three roles: Client(0), Server(1), and Verifier(2). A protocol for login involving three parties can be described as follows: Client sends userid to Server; Server sends the received userid to Verifier; Verifier queries Client an indefinite number of times; Verifier sends the verification result to Server. Following is an encoding of this protocol as a session type:
userid(0,1)@userid(1,2)@ repseq(2,query(2,0)@answer(0,2))@result(2,1)
where
userid(0,1)
and userid(1,2)
mean sending a userid from role 0 to role 1
and from role 1 to role 2, respectively;
query(2,0)
means sending a query question from role 2 to role 0;
answer(0,2)
means sending an answer (to the received question)
from role 0 to role 2; result(2,1)
means sending a result from
role 2 to role 1 (to indicate success or failure of verification).
Example 3. Let us assume the availability of three roles: Judge(0), Contestant1(1), and Contestant2(2). A protocol for some kind of contest involving three parties can be described as follows: Judge broadcasts a query to Contestant1 and Contestant2; each contestant sends his or her answer to Judge and then receives a score from Judge. Following is an encoding of this protocol as a session type:
query(0)@(mconj(0, answer(1,0)@score(0,1), answer(2,0)@score(0,2)))
where query(0)
means broadcasting a query from role 0 to all of
the other roles; the syntax mconj(0, ...)
means ;
answer(1,0)
means sending an answer from role 1 to role 0 and
score(0,1)
means sending a score from role 0 to role 1;
answer(2,0)
and score(0,2)
mean similarly. Let be
for . At some moment, Judge holds two
endpoints of types and
, and he can certainly use them in two
concurrently running threads (but is not required to do so). On the
other hand, Contestant1 holds two endpoints of types
and at the same moment
and is required to use them concurrently. And the same can be said about
Contestant2.
5.7 Splitting an endpoint
Lemma 4.3 corresponds to a function for splitting a given endpoint:
When applied to an endpoint and a function, chan_split initiates a thread to call the function on the endpoint (for it being used as ) and then returns the endpoint (for it to be used as ).
In the context of session-typed multiparty channels, the inadmissibility of the following inference rule (for disjoint and ) should be clear:
We cannot simply merge two given endpoints and as and may not be the same channel. If they happen to be the same channel, then allowing a process to hold both and can potentially lead to deadlocking.
5.8 Multiparty cut-elimination
Lemma 4.7 corresponds to the following function that can be called to eliminate any endpoint :
Lemma 4.11 (or more precisely, its proof) indicates the existence of a generic method for forwarding messages between three endpoints of certain matching types:
where is assumed and each endpoint belongs to a distinct channel. The following chan_2_cut can be seen a special case of chan_3_cut where , and :
When applied to three endpoints for , chan_3_cut behaves in the following manner: Suppose that a message for role is received at ; we have as holds; if , the received message is sent via the endpoint to the process holding for some satisfying ; if , the received message is sent via the endpoint to the process holding for some satisfying . After chan_3_cut is called on , and , all of the other endpoints of , and are considered belonging to one single channel. Implementing chan_3_cut consists of a crucial step in implementation of multiparty channels.
5.9 Modality and Quantification
The exponentials in linear logic are modal connectives. Given a role , there is a connective in LMRL for the principal ultrafilter at . Let us write for this . Essentially, for any given can be replaced with , which is recursively defined as . As a session type, means that a sequence of interactions specified by can be repeated concurrently (while means sequential repetition).
Given a role , there is also a quantifier for in LMRL for the principal ultrafilter at . Let us write for this , which is supposed to be used for constructing dependent session types (that are not studied here).
6 : Linearly typed Multi-threaded -calculus
While what is presented in Section 5 may sound intuitive, it is not formal. In this section and the next, we formulate a design of linearly typed channels for multiparty communication where the types are directly rooted in LMRL. This formulation itself is standard and the contribution it brings to this paper is mostly technical.
We first present a multi-threaded lambda-calculus equipped with a simple linear type system, setting up the basic machinery for further development. Some syntax of is given in Figure 3. We use and for sequences of expressions and values, respectively. We use rc for constant resources and for constants, which include both constant constructors cc and constant functions cf. We treat resources in abstractly and will later introduce communication channels as a concrete form of resources. The meaning of various standard forms of expressions in should be intuitively clear. We may refer to a closed expression (containing no free variables) as a program.
We use and for (non-linear) types and (linear) viewtypes, respectively. Note that a type is always considered a viewtype and a viewtype is referred to as a true viewtype if it is not a type. We use and for base types and base viewtypes, respectively. For instance, int and bool are base types for integers and booleans, respectively. We also assume the availability of integer constants and sets of integer constants for forming types. For instance, we may have a singleton type for each integer , which can only be assigned to a dynamic expression of value equal to .
For a simplified presentation, we do not introduce any concrete base viewtypes in . We assume a signature SIG for assigning a viewtype to each constant resource rc and a constant type (c-type) schema of the form to each constant. For instance, we may have a constant function iadd of the following c-type schema:
where and are meta-variables ranging over integer constants. Each occurrence of iadd in a program is given a c-type that is an instance of the c-type schema assigned to iadd.
Let and be two viewtypes. The type constructor is based on multiplicative conjunction in linear logic. Intuitively, if a resource is assigned the viewtype , then the resource is a conjunction of two resources of viewtypes and . The type constructor is essentially based on linear implication in linear logic. Given a function of the viewtype and a value of the viewtype , applying the function to the value yields a result of the viewtype while the function itself is consumed. If the function is of the type , then applying the function does not consume it. The subscript in is often dropped, that is, is assumed to be by default. The meaning of various forms of types and viewtypes is to be made clear and precise when the rules are presented for assigning viewtypes to expressions in .
There is a special constant function thread_create in for thread creation, which is assigned the following interesting c-type:
A function of the type is a procedure that takes no arguments and returns no result (when its evaluation terminates). Given that is a true viewtype, a procedure of this type may contain resources and thus must be called exactly once. The operational semantics of thread_create is to be formally defined later.
A variety of mappings, finite or infinite, are to be introduced in the rest of the presentation. We use for the empty mapping and for the finite mapping that maps to for . Given a mapping , we write for the domain of . If , we use for the mapping that extends with a link from to . If , we use for the mapping obtained from removing the link from to in , and for , that is, the mapping obtained from replacing the link from to in with another link from to .
We define a function in Figure 4 to compute the multiset (that is, bag) of constant resources in a given expression. Note that denotes the multiset union. In the type system of , it is to be guaranteed that equals whenever an expression of the form is constructed, and this justifies being defined as .
We use to range over finite multisets of resources. Therefore, can also be regarded as a mapping from resources to natural numbers: means that there are occurrences of rc in . It is clear that we may not combine resources arbitrarily. For instance, we may want to exclude the combination of one resource stating integer 0 at a location L and another one stating integer 1 at the same location. We fix an abstract collection of finite multisets of resources and assume the following:
-
•
.
-
•
For any and , if and , where is the subset relation on multisets.
We say that is a valid multiset of resources if holds.
In order to formalize threads, we introduce a notion of pools. Conceptually, a pool is just a collection of programs (that is, closed expressions). We use for pools, which are formally defined as finite mappings from thread ids (represented as natural numbers) to (closed) expressions in such that is always in the domain of such mappings. Given a pool and , we refer to as a thread in whose id equals tid. In particular, we refer to as the main thread in . The definition of is extended as follows to compute the multiset of resources in a given pool:
We are to define a relation on pools in Section 6.2 to simulate multi-threaded program execution.
6.1 Static Semantics
We use for a typing context that assigns (non-linear) types to variables and for a typing context that assigns (linear) viewtypes to variables. Any typing context can be regarded as a finite mapping as each variable can occur at most once. Given and satisfying , we write for the union of and . The same notation also applies to linear typing contexts (). Given and , we can form a combined typing context if . Given , we may write for either or (if is actually a type).
A typing judgment in is of the form , meaning that can be assigned the viewtype under . The typing rules for are listed in Figure 5. In the rule (ty-cst), the following judgment requires that the c-type be an instance of the c-type schema assigned to in SIG:
By inspecting the typing rules in Figure 5, we can readily see that a closed value cannot contain any resources if the value itself can be assigned a type (rather than a linear type). More formally, we have the following proposition:
Proposition 6.1.
If is derivable, then .
This proposition plays a fundamental role in : The rules in Figure 5 are actually so formulated in order to make the proposition hold.
The following lemma, which is often referred to as Lemma of Canonical Forms, relates the form of a value to its type:
Lemma 6.2.
Assume that is derivable.
-
•
If , then is of the form .
-
•
If , then is of the form rc or .
-
•
If , then is .
-
•
If or , then is of the form .
-
•
If or , then is of the form .
Proof 6.3.
By an inspection of the rules in Figure 5.
We use for substitution on variables :
For each , we define the multiset of resources in as the union of for . Given an expression , we use for the result of applying to . We write to mean the following:
-
•
, and
-
•
is derivable for each , and
-
•
there exists a linear typing context for each such that is derivable, and
-
•
is the union of for .
The following lemma, which is often referred to as Substitution Lemma, is needed to establish the soundness of the type system of :
Lemma 6.4.
Assume and . Then is derivable and .
Proof 6.5.
By induction on the derivation of .
6.2 Dynamic Semantics
The evaluation contexts in are defined below:
Given an evaluation context and an expression , we use for the expression obtained from replacing the only hole in with .
Definition 6.6.
We define pure redexes and their reducts as follows.
-
•
is a pure redex whose reduct is .
-
•
is a pure redex whose reduct is .
-
•
is a pure redex whose reduct is .
-
•
is a pure redex whose reduct is .
-
•
is a pure redex whose reduct is .
-
•
is a pure redex whose reduct is .
-
•
is a pure redex whose reduct is .
Evaluating calls to constant functions is of particular importance in . Assume that cf is a constant function of arity . The expression is an ad-hoc redex if cf is defined at , and any value of is a reduct of . For instance, is an ad hoc redex and is its sole reduct. In contrast, is not a redex as it is undefined. We can even have non-deterministic constant functions. For instance, we may assume that the ad-hoc redex can evaluate to both 0 and 1.
Let be a well-typed expression of the form and holds for some valid (that is, ). We always assume that there exists a reduct in for such that . By doing so, we are able to give a presentation with much less clutter.
Definition 6.7.
Given expressions and , we write if and for some and such that is a redex, is a reduct of , and we may say that evaluates or reduces to purely if is a pure redex.
Note that resources may be generated as well as consumed when ad-hoc reductions occur. This is an essential issue in any linear type system designed to support practical programming.
Definition 6.8.
Given two pools and , the relation
is defined according to the following
rules:
If a pool evaluates to another pool by the rule (PR0), then one thread in evaluates to its counterpart in and the rest stay the same; if by the rule (PR1), then a fresh thread is created; if by the rule (PR2), then a thread (that is not the main thread) is terminated.
From this point on, we always (implicitly) assume that holds whenever is well-typed. The soundness of the type system of rests upon the following two theorems:
Theorem 6.9.
(Subject Reduction on Pools) Assume that is derivable and holds for some satisfying . Then is also derivable.
Proof 6.10.
By structural induction on the derivation of . Note that Lemma 6.4 is needed.
Theorem 6.11.
(Progress Property on Pools) Assume that is derivable. Then we have the following possibilities:
-
•
is a singleton mapping for some , or
-
•
holds for some satisfying .
Proof 6.12.
By structural induction on the derivation of . Note that Lemma 6.2 is needed. Essentially, we can readily prove that for any is either a value or of the form for some evaluation context and redex . If is a value for some , then this value must be and the rule (PR2) can be used to reduce . If is of the form for some redex , then the rule (PR0) can be used to reduce .
7 : Extending with multiparty channels
There is no support for communication between threads in , making uninteresting as a multi-threaded language. We extend to with support for synchronous communication channels in this section. Supporting asynchronous communication channels is certainly possible but would result in a more involved theoretical development. In order to assign types to channels, we introduce session types as follows:
where and range over distinct roles. For a simplified presentation, we use to mean messaging from role to role (rather than for specifying a value of viewtype being sent from to ). As for , its meaning is explained in Section 5.4. For brevity, we skip session types of the form .
Given a role set and a session type , we can form a base viewtype for an endpoint and refer to as the role set attached to this endpoint. A process holding an endpoint of type is supposed to implement all of the roles in .
The function chan_create for creating a channel of two endpoints is assigned the following c-type schema:
In order to construct a channel of 3 or more endpoints, we can make use of chan_3_cut. Assume that each has two endpoints and for . If and are disjoint, then calling chan_create on returns an endpoint such that the three endpoints , , and form a new channel.
Please recall that the function chan_sync for msg is given the following c-type schema:
Given an endpoint , chan_sync sends a message at if and , and it receives a message if and , and it does nothing otherwise.
There are no new typing rules in over . In any type derivation of , the types assigned to the endpoints of any channel CH are required to match in the sense that there exists such that these types are of form for . Clearly, this can be seen as some kind of coherence requirement. For evaluating pools in , we have the following additional rules:
Due to the symmetry between chan_mdisj_l and chan_mdisj_r, we only consider the former in the following presentation. Another rule for evaluating pools in is given as follows:
where and are two new channels, and , and are newly created thread ids.
For brevity, we omit rules for other primitive functions on channels (e.g., chan_2_cut and chan_3_cut), which can be formulated by following (PR5).
Theorem 6.9 (Subject Reduction) can be readily established for . As for Theorem 6.11, we need some special treatment due to the presence of session-typed primitive functions such as chan_create, chan_mconj, chan_mdisj_l, etc.
A partial (ad hoc) redex in is an expression of one of the following forms: , , . We can immediately prove in that each well-typed program is either a value or of the form for some evaluation context and expression such that is either a redex or a partial redex. We refer to an expression as a blocked one if it is of the form for some partial redex . A set of partial redexes are said to be matching if
-
•
it consists of for , or
-
•
it consists of the following:
for .
A set of blocked expressions are matching if their partial redexes form a matching set. Clearly, a pool containing a set of matching blocked expressions can evaluate according to the rule (PR4) or (PR5). Therefore, a pool is deadlocked only when there is no subset of matching expressions among the entire set of blocked expressions.
Definition 7.1.
Assume there are channels in a pool such that each channel consists of endpoints for . Let us use for and for . In addition, let us use for the number of threads in holding at least one endpoint. We say that is relaxed if holds.
Lemma 7.2.
If is obtained from evaluating an initial pool containing no channels, then is relaxed.
Proof 7.3.
By a careful inspection on the evaluation rules (PR3), (PR4) and (PR5).
Theorem 7.4.
(Progress Property on Pools) Assume that is derivable. If is relaxed, then either is a singleton mapping for some or holds for some .
Proof 7.5.
Assume there are channels in for some such that each channel consists of endpoints for . Note that holds as is relaxed. Assume that each thread in is a blocked expression. By the pigeonhole principle, there must be blocked expressions involving for some . Since is well-typed, these blocked expressions form a matching set, allowing to evaluate to some according to the rule (PR4) or (PR5).
Note that Theorem 7.4 establishes a form of global progress in the sense that multiple threads must coordinate in order to make progress in evaluation.
Assume that we start with a well-typed pool containing no channels. By Lemma 7.2, any pool that is reduced from is relaxed. With subject reduction for and Theorem 7.4, we can conclude that either evaluates to a singleton mapping for some or the evaluation goes on forever.
Please assume for the moment that we would like to add into a function of the name chan2_create of the following type schema:
One may think of chan2_create as a “reasonable” generalization of chan_create that creates in a single call two endpoints instead of one. Unfortunately, adding chan2_create into can potentially cause a deadlock. For instance, a thread may wait for a message on the first of the two endpoints returned from a call to chan2_create while the newly created thread waits for a message on the second argument of the function passed to create it, resulting in a deadlocked situation where neither of the two threads is able to send to the other one. Clearly, a pool cannot be relaxed if it contains two threads and two channels such that each channel consist of endpoints.
8 Implementing Multiparty Channels
We have implemented in ATS [\citenameXi, 2008] the session-typed multiparty channels presented in this paper. As far as typechecking is of the concern, the only considerable complication comes from the need for solving constraints that involve various common set operations (on role sets). We currently export such constraints for them to be solved with an external constraint-solver based on Z3 [\citenamede Moura & Bjørner, 2008].
The first implementation is based on shared memory, which is used to construct ATS programs that compile to C. Another implementation is based on processes in Erlang, which is for use in ATS programs that compile to Erlang (so as to take advantage of the infrastructural support for distributed programming in Erlang). For taking a peek at a running implementation of Example 1 in Section 5.6, please visit the following link:
http://pastebin.com/JmZRukRi
where the code should be accessible to someone familiar with ML-like syntax. To facilitate understanding of this example, we outline as follows some key steps involved in building a 3-party session that makes genuine use of non-singleton role sets.
8.1 A Sketch for Building a 3-Party Session
Building a session often requires explicit coordination between the involved parties during the phase of setting-up. In practice, designing and implementing coordination between 3 or more parties is generally considered a difficult issue. By building a multiparty channel based on 2-party channels, we only need to be concerned with two-party coordination, which is usually much easier to handle.
Given a role set and a session type , we introduce a type that can be assigned to a value representing some form of persistent service. With such a service, channels of type can be created repeatedly. A built-in function service_create is assigned the following type for creating a service:
In contrast with chan_create for creating a channel, service_create requires that its argument be a non-linear function (so that this function can be called repeatedly). A client may call the following function to obtain a channel to communicate with a server that provides the requested service:
Suppose we want to build a 3-party session involving 3 roles: 0, 1, and 2. We may assume that there are two services of types and available to a party (planning to implement role 2); this party can call service_request on the two services (which are just two names) to obtain two channels and of types and , respectively; it then calls to obtain a channel of type for communicating with two servers providing the requested services. There are certainly many other ways of building a multiparty channel by passing around 2-party channels.
9 Related Work and Conclusion
Multirole as a logical notion generalizes the notion of duality in logic. One may compare multirole to the notion of linearity in linear logic [\citenameGirard, 1987] as multirole/linearity can often be incorporated into an existing logic to form a multirole/linear version of the logic. In this sense, multirole may be referred to as a logical aspect. For instance, it should not be surprising if modal operators can be generalized to ultrafilters as well even though we have not yet formulated any multirole modal logic.
The admissibility of (binary) cut-rule in classical logic and intuitionistic logic goes back to Gentzen’s seminal work on LK and LJ [\citenameGentzen, 1935]. We hereby generalize cut-rule to 1-cut and 2-cut-with-residual, which in turn yield a cut-rule (mp-cut) involving sequents for any . The proof we give for the admissibility of 2-cut-with-residual is directly based on one for the admissibility of cut-rule in classical linear logic [\citenameTroelstra, 1992].
Session types were introduced by Honda [\citenameHonda, 1993] and further extended subsequently [\citenameTakeuchi et al., 1994, \citenameHonda et al., 1998]. There have since been extensive theoretical studies on session types in the literature(e.g., [\citenameCastagna et al., 2009, \citenameGay & Vasconcelos, 2010, \citenameToninho et al., 2011, \citenameVasconcelos, 2012, \citenameLindley & Morris, 2015]). Multiparty session types, as a generalization of (dyadic) session types, were introduced by Honda and others [\citenameHonda et al., 2008], together with the notion of global types, local types, projection and coherence.
The session types presented in Section 7 are global. In the future, we plan to introduce projection of global session types into local ones. For instance, the local session type for Contestant1 in Example 3 should be given as follows:
query(0)@(mconj(0, answer(1,0)@score(0,1), nil))
as there is no need for Contestant1(1) to learn the protocol that solely specifies communication between Judge(0) and Contestant2(2). Naturally, a set of local session types are coherent if they can be projected from a global session type with respect to some role sets satisfying .
In [\citenameCarbone et al., 2017], a Curry-Howard correspondence is proposed between a language for programming multiparty sessions and a generalization of CLL, where propositions correspond to the local behavior of a party, proofs to processes, and proof normalization to executing communications. In particular, Multiparty Classical Processes (MCP) is developed that generalizes the duality in CLL to a new notion of n-ary compatibility (referred to as coherence) and the cut rule of CLL to a new rule for composing processes. Compared with MCP, we see that our work on multirole logic presents a fundamentally different approach to generalizing the notion of duality in logic (not just in CLL). For instance, we give an interpretation of based on LMRL as interleaving of and in arbitrary order and as behaving like and concurrently while MCP interprets and as input and output, respectively. There is little in common between LMRL and MCP except for both sharing a similar motivation on generalizing duality in logic.
There is also very recent work on encoding multiparty session types based on binary session types [\citenameCaires & Pérez, 2016], which relies on an arbiter process to mediate communications between multiple parties while preserving global sequencing information. We see that this form of mediating (formulated based on automata theory) is closely related to performing a multiparty cut.
Probably is most closely related to SILL [\citenameToninho et al., 2013], a functional programming language that adopts via a contextual monad a computational interpretation of intuitionistic linear sequent calculus as session-typed processes. The approach we use to establish global progress for can be seen as an adaptation of one used in SILL for the same purpose. Unlike , there are only binary channels in SILL and the support of linear types in SILL is not direct and only monadic values (representing open process expressions) can be linear.
Also, is related to previous work on incorporating session types into a multi-threaded functional language [\citenameVasconcelos et al., 2004], where a type safety theorem is established to ensure that the evaluation of a well-typed program can never lead to a so-called faulty configuration. However, this theorem does not imply global progress as a program that is not of faulty configuration can still deadlock. Also, we point out that is related to recent work on assigning an operational semantics to a variant of GV [\citenameLindley & Morris, 2015], which takes a similar approach to establishing deadlock-freedom (that is, global progress).
Given MRLJ and LMRL, it seems straightforward to formulate LMRLJ as a multirole version of intuitionistic linear logic. As session types can also be directly based on intuitionistic linear propositions [\citenameCaires & Pfenning, 2010], it is only natural to also study multiparty channels in LMRLJ.
There are a variety of programming issues that need to be addressed in order to facilitate the use of session types in practice. Currently, session types are often represented as datatypes in ATS, and programming with such session types tends to involve writing a very significant amount of boilerplate code (as can be seen in the lengthy implementation of the S0B1B2 example). In the presence of large and complex session types, writing such code can be tedious and error-prone. Naturally, we are interested in developing some meta-programming support for generating such code automatically. Also, we are in the process of designing and implementing session combinators (in a spirit similar to parsing combinators [\citenameHutton, 1992]) that can be conveniently called to assemble subsessions into a coherent whole.
Appendix A Appendix
A.1 Proof of Lemma 4.9
Assume and . We proceed by induction on (the size of ) and , lexicographically ordered. For brevity, we are to focus only on the most interesting case where there is one occurrence of in that is the major formula of the last rule applied in , where ranges over and . For this case, we have several subcases covering all the possible forms that may take.
A.1.1 Assume that is a primitive formula
It is a simple (but very meaningful) routine to verify that the sequent follows from an application of the rule (Id).
A.1.2 Assume that is pf the form
Then is of the following form for each of the cases and :
By induction hypothesis on and , we obtain a derivation:
Note that the . By applying the rule () to , we derive .
A.1.3 Assume that is of the form
We have three possibilities: and , or and , or and .
-
•
Assume and . Then is of the following form:
and is of the following form:
By the induction hypothesis on and , we have a derivation:
By the induction hypothesis on and , we have a derivation:
By applying the rule (-neg) to , we derive .
-
•
Assume and . Then this case is analogous to the previous one.
-
•
Assume and . Then is of the following form for each of the cases and :
By the induction hypothesis on and , we obtain a derivation:
By the induction hypothesis on and , we obtain a derivation:
By applying the rule (-pos) to and , we derive .
A.1.4 Assume that is of the form
We have three possibilities: and , or and , or and .
-
•
Assume and . Then is of the following form:
and is of the following form for being either or :
where the last applied rule in is (-neg-l) or (-neg-r). By induction hypothesis on and , we obtain a derivation:
By applying to either (-neg-l) or (-neg-r), we derive .
-
•
Assume and . Then this case is analogous to the previous one.
-
•
Assume and . Then is of the following form for each of the cases and :
By the induction hypothesis on and , we obtain a derivation:
By the induction hypothesis on and , we obtain a derivation:
By applying the rule (-pos) to and , we derive .
A.1.5 Assume that is of the form
This is the most involved subcase. We have three possibilities: and , or and , or and .
-
•
Assume and . Then is of the following form:
There are the following three possibilities for :
-
–
is of the following form:
We obtain a derivation of by the induction hypothesis on and .
-
–
is of the following form:
By the induction hypothesis on and , we obtain a derivation:
By the induction hypothesis on and , we obtain a derivation:
By applying the rule (-neg-contract) to repeatedly, we derive .
-
–
is of the following form:
We obtain a derivation of by the induction hypothesis on and .
-
–
-
•
Assume and . This subcase is completely analogous to the previous one.
-
•
Assume and . Then is of the following form for each of the cases and :
We obtain by the induction hypothesis on and . We then obtain a derivation of by applying the rule (-pos) to .
A.1.6 Assume that is of the form
We have three possibilities: and , or and , or and .
-
•
Assume and . Then is of the following form:
where does not have any free occurrences in , and is of the following form:
Let be , which is a derivation of obtained from substituting for every free occurrence of in . Clearly, is of the same height as . By the induction hypothesis on and , we have a derivation:
By applying the rule (-neg) to , we have a derivation of .
-
•
Assume and . Then this case is analogous to the previous one.
-
•
Assume and . Then is of the following form for each of the cases and :
where does not have free occurrences in . By the induction hypothesis on and , we have a derivation:
By applying the rule (-pos) to , we obtain a derivation of .
All of the cases are covered where the cut-formula is the major formula of both and . For brevity, we omit the cases where the cut-formula is not the major formula of either or , which can be trivially handled [\citenameTroelstra, 1992].
References
- [\citenameAbramsky, 1994] Abramsky, Samson. (1994). Proofs as processes. Theor. comput. sci., 135(1), 5–9.
- [\citenameBellin & Scott, 1994] Bellin, Gianluigi, & Scott, Philip J. (1994). On the pi-calculus and linear logic. Theor. comput. sci., 135(1), 11–65.
- [\citenameCaires & Pérez, 2016] Caires, Luís, & Pérez, Jorge A. (2016). Multiparty session types within a canonical binary theory, and beyond. Pages 74–95 of: Formal Techniques for Distributed Objects, Components, and Systems - 36th IFIP WG 6.1 International Conference, FORTE 2016, Held as Part of the 11th International Federated Conference on Distributed Computing Techniques, DisCoTec 2016, Heraklion, Crete, Greece, June 6-9, 2016, Proceedings.
- [\citenameCaires & Pfenning, 2010] Caires, Luís, & Pfenning, Frank. (2010). Session types as intuitionistic linear propositions. Pages 222–236 of: CONCUR 2010 - Concurrency Theory, 21th International Conference, CONCUR 2010, Paris, France, August 31-September 3, 2010. Proceedings.
- [\citenameCarbone et al., 2017] Carbone, Marco, Montesi, Fabrizio, Schürmann, Carsten, & Yoshida, Nobuko. (2017). Multiparty session types as coherence proofs. Acta inf.
- [\citenameCastagna et al., 2009] Castagna, Giuseppe, Dezani-Ciancaglini, Mariangiola, Giachino, Elena, & Padovani, Luca. (2009). Foundations of session types. Pages 219–230 of: Proceedings of the 11th International ACM SIGPLAN Conference on Principles and Practice of Declarative Programming, September 7-9, 2009, Coimbra, Portugal.
- [\citenamede Moura & Bjørner, 2008] de Moura, Leonardo Mendonça, & Bjørner, Nikolaj. (2008). Z3: an efficient SMT solver. Pages 337–340 of: Tools and Algorithms for the Construction and Analysis of Systems, 14th International Conference, TACAS 2008, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2008, Budapest, Hungary, March 29-April 6, 2008. Proceedings.
- [\citenameGay & Vasconcelos, 2010] Gay, Simon J., & Vasconcelos, Vasco Thudichum. (2010). Linear type theory for asynchronous session types. J. funct. program., 20(1), 19–50.
- [\citenameGentzen, 1935] Gentzen, Gerhard. (1935). Untersuchungen über das logische Schlieen. Mathematische zeitschrift, 39, 176–210, 405–431.
- [\citenameGirard, 1987] Girard, Jean-Yves. (1987). Linear logic. Theoretical computer science, 50(1), 1–101.
- [\citenameHonda, 1993] Honda, Kohei. (1993). Types for dyadic interaction. Pages 509–523 of: CONCUR ’93, 4th International Conference on Concurrency Theory, Hildesheim, Germany, August 23-26, 1993, Proceedings.
- [\citenameHonda et al., 1998] Honda, Kohei, Vasconcelos, Vasco, & Kubo, Makoto. (1998). Language primitives and type discipline for structured communication-based programming. Pages 122–138 of: Programming Languages and Systems - ESOP’98, 7th European Symposium on Programming, Held as Part of the European Joint Conferences on the Theory and Practice of Software, ETAPS’98, Lisbon, Portugal, March 28 - April 4, 1998, Proceedings.
- [\citenameHonda et al., 2008] Honda, Kohei, Yoshida, Nobuko, & Carbone, Marco. (2008). Multiparty asynchronous session types. Pages 273–284 of: Proceedings of the 35th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2008, San Francisco, California, USA, January 7-12, 2008.
- [\citenameHutton, 1992] Hutton, Graham. (1992). Higher-order functions for parsing. J. funct. program., 2(3), 323–343.
- [\citenameLindley & Morris, 2015] Lindley, Sam, & Morris, J. Garrett. (2015). A semantics for propositions as sessions. Pages 560–584 of: Programming Languages and Systems - 24th European Symposium on Programming, ESOP 2015, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2015, London, UK, April 11-18, 2015. Proceedings.
- [\citenameTakeuchi et al., 1994] Takeuchi, Kaku, Honda, Kohei, & Kubo, Makoto. (1994). An interaction-based language and its typing system. Pages 398–413 of: PARLE ’94: Parallel Architectures and Languages Europe, 6th International PARLE Conference, Athens, Greece, July 4-8, 1994, Proceedings.
- [\citenameToninho et al., 2011] Toninho, Bernardo, Caires, Luís, & Pfenning, Frank. (2011). Dependent session types via intuitionistic linear type theory. Pages 161–172 of: Proceedings of the 13th International ACM SIGPLAN Conference on Principles and Practice of Declarative Programming, July 20-22, 2011, Odense, Denmark.
- [\citenameToninho et al., 2013] Toninho, Bernardo, Caires, Luís, & Pfenning, Frank. (2013). Higher-order processes, functions, and sessions: A monadic integration. Pages 350–369 of: Programming Languages and Systems - 22nd European Symposium on Programming, ESOP 2013, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2013, Rome, Italy, March 16-24, 2013. Proceedings.
- [\citenameTroelstra, 1992] Troelstra, Anne S. (1992). Lectures on linear logic. CSLI Lecture Notes, vol. 29. Stanford, California: Center for the Study of Language and Information.
- [\citenameVasconcelos, 2012] Vasconcelos, Vasco T. (2012). Fundamentals of session types. Inf. comput., 217, 52–70.
- [\citenameVasconcelos et al., 2004] Vasconcelos, Vasco Thudichum, Ravara, António, & Gay, Simon J. (2004). Session types for functional multithreading. Pages 497–511 of: CONCUR 2004 - Concurrency Theory, 15th International Conference, London, UK, August 31 - September 3, 2004, Proceedings.
- [\citenameWadler, 2012] Wadler, Philip. (2012). Propositions as sessions. Pages 273–286 of: ACM SIGPLAN International Conference on Functional Programming, ICFP’12, Copenhagen, Denmark, September 9-15, 2012.
- [\citenameXi, 2008] Xi, Hongwei. (2008). The ATS Programming Language System. Available at: http://www.ats-lang.org/.