1504.04311v1

7
arXiv:1504.04311v1 [cs.LO] 16 Apr 2015 Keywords higher category theory, concurrency, message-passing, types, Curry-Howard ABSTRACT We present an approach to modeling computational calculi using higher category theory. Specifically we present a fully abstract semantics for the π-calculus. The interpretation is consistent with Curry-Howard, interpreting terms as typed morphisms, while simul- taneously providing an explicit interpretation of the rewrite rules of standard operational presentations as 2-morphisms. One of the key contributions, inspired by catalysis in chemical reactions, is a method of re- stricting the application of 2-morphisms interpreting rewrites to specific contexts. Submission to arXiv

description

logic-journal

Transcript of 1504.04311v1

  • arX

    iv:1

    504.

    0431

    1v1

    [cs.L

    O] 1

    6 Apr

    2015

    Keywordshigher category theory, concurrency, message-passing,types, Curry-Howard

    ABSTRACTWe present an approach to modeling computationalcalculi using higher category theory. Specifically wepresent a fully abstract semantics for the -calculus.The interpretation is consistent with Curry-Howard,interpreting terms as typed morphisms, while simul-taneously providing an explicit interpretation of therewrite rules of standard operational presentations as2-morphisms. One of the key contributions, inspiredby catalysis in chemical reactions, is a method of re-stricting the application of 2-morphisms interpretingrewrites to specific contexts.

    Submission to arXiv

  • Higher category models of the pi-calculus

    Michael StayGoogle

    [email protected]

    L.G. MeredithBiosimilarity, LLC

    [email protected]

    1. INTRODUCTIONOne of the major distinctions in programming lan-guage semantics has been the division between de-notational and operational semantics. In the formercomputations are interpreted as mathematical objectswhichmore often than notcompletely unfold thecomputational dynamics, and are thus infinitary inform. In the latter computations are interpreted interms of rewrite rules operating on finite syntacticstructure. Historically, categorical semantics for pro-gramming languages, even variations such as gamessemantics [6] which capture much more of the inten-sional structure of computations, are distinctly deno-tational in flavor [11]. Meanwhile, operational seman-tics continues to dominate in the presentation of cal-culi underlying programming languages used in prac-tice [5] [3] [13].

    Motivated, in part, by the desire to make a closer con-nection between theory and practice, many efforts inthe programming language semantics, and in concur-rency theory communities have begun to investigatemore direct categorical interpretations of operationalsemantics. This paper finds its place in this lattercontext, providing a fully abstract interpretation ofthe -calculus in terms of a higher categorical modelof its operational semantics. In particular, while itremains faithful to a Curry-Howard orientation, mod-eling terms as typed morphisms, it models the com-putational dynamics of the calculus, its rewrite rules,as 2-morphisms. One of the goals has been to pro-vide a modular semantics to address a range of fea-tures and modeling options typically associated withthe -calculus. For example, a significant bifurcation

    occurs in the treatment of names with Milners origi-nal calculus hiding all internal structure of names [10],while the -calculus variant provides a reflective ver-sion in which names are the codes of processes [8].The semantics presented here is capable of providinga categorical interpretation of both variants.

    Of particular interest to theoreticians and implementers,the semantics shines light on a key difference betweenthe categorical and computational machinery it inter-prets. The latter is intrinsically lazy in the sense thatall contexts where rewrites can apply must be explic-itly spelled out (cf the context rules in section 2.1.4),while the former is intrinsically eager; in fact, one ofthe contributions of the paper is the delineation ofan explicit control mechanism to prevent unwantedrewrites that would otherwise create an insurmount-able divergence between the two formalisms.

    1.0.1 Related workThis paper draws inspiration from [15] and [2], butalso seeks a more direct account of what works inmodern day operational semantics. In his seminalpaper [9] Milner provided the template still used to-day for specifying computational calculi, presentingthe -calculus in terms of a freely generated algebraquotiented by a structural equivalence relation that isthen subject to some rewrite rules. This constitutesthe modern view of structured operational semantics[12]. In the latter part of his research Milner focusedon finding a satisfying relationship between a categor-ical presentation of the rewrite rules and the notionof bisimulation [4]. While this work did not explic-itly employ higher categorical techniques, it spawned avariety of 2-categorical investigations designed to cap-ture and recast bisimulation equivalences in terms of2-morphisms [14]. Hirschowitz has developed an evenmore ambitious program of categorifying the whole ofthe operational semantics framework from the presen-tation of higher order syntax (or terms with bindingconstructors like -calculus or -calculus), to rewriterules [1].

  • The present work is primarily focused on providing adirect account of the -calculus. The modularity ofthe semantics arises from wanting to give a clean de-sign and clear shape to the present account, ratherthan an attempt to provide a framework for interpret-ing a number of computational calculi. The fact thatthe techniques do apply to a number of calculi wasa side effect of this process. Moreover, our particu-lar reconciliation of operational laziness with categor-ical eagerness introduces an explicit resource sensitiv-ity, which we have not seen before in the theoreticalliterature, yet is remarkably similar to resource con-straints in actual implementations of concurrent anddistributed computations.

    1.0.2 Organization of the rest of the paperIn the remainder of the paper we present the core frag-ment of the calculus we model followed by a mani-fest of the categorical equipment needed to faithfullymodel it. Then we give the semantics function ansketch a proof that the interpretation is fully abstract.

    2. THE CALCULUSOne notable feature of the -calculus is its ability tosuccinctly and faithfully model a number of phenom-ena of concurrent and distributed computing. Compe-tition for resources amongst autonomously executingprocesses is a case in point. The expression

    x?(y) P | x!(u) | x?(v) Q

    is made by composing three processes, two of which,x?(y) P and x?(v) Q are seeking input fromchannel x before they launch their respective contin-uations, P and/or Q; while the third, x!(u), is sup-plying output on that same said channel. Only one ofthe input-guarded processes will win, receiving u andbinding it to the input variable, y, or respectively, vin the body of the corresponding continuation whilethe loser remains in the input-guarded state await-ing input along channel x. The calculus is equinan-imous, treating both outcomes as equally likely, andin this regard is unlike its sequential counterpart, the-calculus, in that it is not confluent. There is noguarantee that the different branches of computationmust eventually converge. Note that just adding anew-scope around the expression

    (new x)(x?(y) P | x!(u) | x?(v) Q)

    ensures that the competition is for a local resource,hidden from any external observer.

    2.1 Our running process calculus2.1.1 Syntax

    P ::= 0 stopped process| x?(y1, . . . , yn) P input| x!(y1, . . . , yn) output| (new x)P new channel| P |Q parallel

    Due to space limitations we do not treat replication,!P .

    2.1.2 Free and bound namesFN (0) :=

    FN (x?(y1, . . . , yn) P ) :=

    {x} (FN (P ) \ {y1, . . . yn})

    FN (x!(y1, . . . , yn)) := {x, y1, . . . , yn}

    FN ((new x)P ) := FN (P ) \ {x}

    FN (P |Q) := FN (P ) FN (Q)

    An occurrence of x in a process P is bound if it is notfree. The set of names occurring in a process (boundor free) is denoted by N (P ).

    2.1.3 Structural congruenceThe structural congruence of processes, noted , is theleast congruence containing -equivalence, , mak-ing (P, |, 0) into commutative monoids and satisfying

    (new x)(new x)P (new x)P

    (new x)(new y)P (new y)(new x)P

    ((new x)P ) |Q (new x)(P |Q)

    2.1.4 Operational Semantics|~y| = |~z|

    x?(~y) P | x!(~z) P{~z/~y}(Comm)

    In addition, we have the following context rules:

    P P

    P |Q P |Q(Par)

    P P

    (new x)P (new x)P (New)

    P P P Q Q Q

    P Q(Equiv)

    2.1.5 Bisimulation

  • Definition 2.1.1. An observation relation, is thesmallest relation satisfying the rules below.

    x!(~y) x(Out-barb)

    P x or Q x

    P |Q x(Par-barb)

    Notice that x?(y) P has no barb. Indeed, in -calculus as well as other asynchronous calculi, an ob-server has no direct means to detect if a sent messagehas been received or not.

    Definition 2.1.2. An barbed bisimulation, is a sym-metric binary relation S between agents such that P S Qimplies:

    1. If P P then Q Q and P S Q.

    2. If P x, then Q x.

    P is barbed bisimilar to Q, written P

    Q, if P S Qfor some barbed bisimulation S.

    3. CATEGORICAL MACHINERYWe take our models in 2-categories with an underlyingsymmetric monoidal closed category; the 2-categoriesCat (categories, functors, and natural transformations)and Rel (sets, relations, and implications) are exam-ples. We denote the monoidal unit object by I , thetensor product by , the nth tensor power of an ob-ject X by Xn, and the internal hom by a lollipop.

    4. THE INTERPRETATIONGiven the abstract syntax of a term calculus like thatin section 2.1.1, we introduce an object in our 2-categoryfor each parameter of the calculus. We introduce 1-morphisms for each term constructor, 2-morphisms foreach reduction relation, and equations for structuralequivalence; we also add 1-morphisms to mark con-texts in which reductions may occur.

    The -calculus is parametric in a set of names and aset of processes, so we have objects N and P . Sincenames can be reused in the -calculus, we also add1-morphisms and equations to make N be a cocom-mutative comonoid. We denote comultiplication by: N N N and counit by : N I. If the ten-sor product is the cartesian product, I is the terminalobject, N is a comonoid in a unique way, and and are duplication and deletion, respectively.

    In the -calculus, all reductions occur at the topmostcontext, so we have one unary morphism from P toP . There are some benefits to constructing the topcontext marker out of the existing binary morphism| : PP P and a unary morphism COMM : I P ;well talk about some of the benefits in the conclusion.

    The theory of the -calculus is the free symmetricmonoidal closed 2-category on

    objects N for names and P for processes,

    N P

    1-morphisms : N N N and : N I,

    N

    NN

    N

    1-morphisms | : P P P and 0: I P ,

    |

    P

    PP

    0

    P

    1-morphism ?n : N (Nn P) P and

    !n : N Nn P for each natural number

    n 0,

    ?n

    P

    NNn P

    !n

    P

    NNn

    1-morphisms fresh : I P and COMM : I P

    fresh

    P

    COMM

    P

  • (Note that the equations governing new in sec-tion 2.1.3 are satisfied up to tensoring with ascalar due to the naturality of the unitors andbraiding in the symmetric monoidal 2-category.)For convenience we write [[x]] for

    x

    N

    which picks out x from N .

    equations making (P , |, 0) into a commutativemonoid,

    equations making (N,, ) into a cocommuta-tive comonoid, and

    a 2-morphism commn encoding the COMM rulefor each natural number n 0.

    !n

    N Nn

    ?n

    Nn P

    COMM

    |

    |

    P P

    P

    P

    P

    commn

    N

    Nn

    Nn P

    COMM

    |

    P P

    P

    ev

    4.1 Semantics

    [[Q]]top :=

    FN (Q)

    [[Q]] COMM

    |P P

    P

    N|FN (Q)|

    [[0]] :=0

    P

    [[x?(y1, . . . , yn) Q]] :=

    ?n

    P

    N

    curryn([[Q]])

    Nn P

    [[x!(y1, . . . , yn)]] :=

    !n

    P

    NNn

    [[(new x)Q]] :=fresh

    [[Q]]

    N

    P

    [[Q |Q]] :=

    [[Q]] [[Q]]

    |P P

    P

  • For example, [[(new y)(new x)x?(y1, . . . , yn) Q]]topwhere z is free in Q is

    ?n

    |

    P

    fresh

    Ncurryn([[Q]])

    Nn P

    COMM

    P

    fresh

    N

    z

    N

    4.1.1 Bisimulation againIn this setting we can provide a direct interpretation ofobservation and bisimulation. Roughly speaking, [[P ]]reduces to [[Q]] just when we can apply the 2-morphismcommn to the former to produce the latter. Since allnon-trivial 2-morphisms are generated by commn, sin-gle step reductions [[P ]] [[Q]] correspond precisely tothe decomposion of a [[P ]] in terms of a context func-tor C, such that [[P ]] = C[src(commn)], and [[Q]] =C[trgt(commn)]. More generally, the interpretationof a term context [[K]] is a functor from one hom cate-gory to another: the functor takes an appropriate mor-phism f to fill the hole and returns a new morphism[[K]][f ]; similarly, it takes a 2-morphism : f f

    between appropriate morphisms and whiskers and/ortensors with identity 2-morphisms to produce a new2-morphism [[K]][].

    Likewise, we can transport the notion of observabilityto the categorical setting as a relation, , between 1-morphisms (not necessarily in the same hom-category).More precisely,

    [[x!(y1, . . . , yn)]] [[x]]

    [[P ]] [[x]] or [[Q]] [[x]] implies [[P ]] | [[Q]] [[x]]

    Taken together these two notions provide an immedi-ate lifting of the syntactic notion of bisimulation to acorresponding semantic notion, which we write, .

    4.1.2 Full abstractionTheorem 4.1.1 (full abstraction). P

    Q [[P ]] [[Q]]

    Proof : immediate.

    5. CONCLUSIONS AND FUTURE WORKWe presented a fully abstract higher categorical se-mantics for the -calculus. Our semantics can be seenas a natural extension of Curry-Howard in the cate-gorical setting: if terms are taken to be 1-morphisms,then rewrites between terms should be 2-morphisms.Such an approach is natural from another perspectivein that it makes comparison with operational seman-tics considerably simpler, at least conceptually. Tothat end, we have already applied the approach tomodels of other milestone computational calculi, suchas the lazy -calculus, with some initial success andhope to report on that in subsequent papers.

    Perhaps more importantly, establishing connectionslike this between two different computational frame-works should allow for transport of other key concep-tual tools. Here, we were able to transport a versionbisimulation to the categorical setting in a simple andstraightforward manner. It would be quite interestingto be able to transport categorical notions of typingback to the process setting. For example, Mellies andZeilbergers refinement types [7], expressed as func-tors, suggest an intriguing approach to a more cate-gorical account of behavioral types.

    Finally, the use of COMM to control commn basedrewrites is strongly reminiscent of the distinction be-tween logical, or virtual concurrency such as may befound in a threads package or operating system pro-cess abstraction, versus actual hardware resources. Al-lowing more than one COMM resource provides, onthe one hand a very natural account of so-called trueconcurrency semantics, and on the other the means toreason about these very practical situations which wehope to investigate in future work.

    Acknowledgments. We would like to acknowledgeTom Hirschowitz for asking some thoughtful and stim-ulating questions about earlier versions of this work.

    6. REFERENCES[1] Cartesian closed 2-categories and permutation

    equivalence in higher-order rewriting, LogicalMethods in Computer Science 9(3:10)2013,122.

    [2] Barney P. Hilken, Towards a proof theory ofrewriting: The simply typed 2lambda-calculus,Theor. Comput. Sci. 170 (1996), no. 1-2,407444.

    [3] Atsushi Igarashi, Benjamin C. Pierce, andPhilip Wadler, Featherwieght java: A minimalcore calculus for java and GJ, Proceedings ofthe 1999 ACM SIGPLAN Conference on

  • Object-Oriented Programming Systems,Languages & Applications (OOPSLA 99),Denver, Colorado, USA, November 1-5, 1999.(Brent Hailpern, Linda M. Northrop, andA. Michael Berman, eds.), ACM, 1999,pp. 132146.

    [4] James J. Leifer and Robin Milner, Derivingbisimulation congruences for reactive systems,CONCUR 2000 - Concurrency Theory, 11thInternational Conference, University Park, PA,USA, August 22-25, 2000, Proceedings (CatusciaPalamidessi, ed.), Lecture Notes in ComputerScience, vol. 1877, Springer, 2000, pp. 243258.

    [5] Sergio Maffeis, John C. Mitchell, and AnkurTaly, An operational semantics for javascript,Programming Languages and Systems, 6thAsian Symposium, APLAS 2008, Bangalore,India, December 9-11, 2008. Proceedings(G. Ramalingam, ed.), Lecture Notes inComputer Science, vol. 5356, Springer, 2008,pp. 307325.

    [6] Guy McCusker, Games and full abstraction forFPC, Proceedings, 11th Annual IEEESymposium on Logic in Computer Science, NewBrunswick, New Jersey, USA, July 27-30, 1996,IEEE Computer Society, 1996, pp. 174183.

    [7] Paul-Andre Mellie`s and Noam Zeilberger,Functors are type refinement systems,Proceedings of the 42nd Annual ACMSIGPLAN-SIGACT Symposium on Principles ofProgramming Languages, POPL 2015, Mumbai,India, January 15-17, 2015 (Sriram K. Rajamaniand David Walker, eds.), ACM, 2015, pp. 316.

    [8] L. Gregory Meredith and Matthias Radestock,A reflective higher-order calculus., Electr. NotesTheor. Comput. Sci. 141 (2005), no. 5, 4967.

    [9] Robin Milner, Functions as processes,Mathematical Structures in Computer Science 2(1992), no. 2, 119141.

    [10] , The polyadic -calculus: A tutorial,Logic and Algebra of SpecificationSpringer-Verlag (1993).

    [11] Eugenio Moggi, Notions of computation andmonads, Inf. Comput. 93 (1991), no. 1, 5592.

    [12] Gordon D. Plotkin, The origins of structuraloperational semantics, Journal of Logic andAlgebraic Programming, 2004, pp. 6061.

    [13] Joe Gibbs Politz, Alejandro Martinez, MatthewMilano, Sumner Warren, Daniel Patterson,Junsong Li, Anand Chitipothu, and ShriramKrishnamurthi, Python: The full monty,Proceedings of the 2013 ACM SIGPLANInternational Conference on Object OrientedProgramming Systems Languages &Applications (New York, NY, USA), OOPSLA13, ACM, 2013, pp. 217232.

    [14] Vladimiro Sassone and Pawe L Sobocinski,

    Deriving bisimulation congruences: A2-categorical approach, In FOSSACS 03, volume2620 of LNCS, Springer, 2002, pp. 409424.

    [15] R. A. G. Seely, Modelling computations: A2-categorical framework, Proceedings of theSymposium on Logic in Computer Science(LICS 87), Ithaca, New York, USA, June 22-25,1987, IEEE Computer Society, 1987, pp. 6571.

    1 Introduction1.0.1 Related work1.0.2 Organization of the rest of the paper

    2 The calculus2.1 Our running process calculus2.1.1 Syntax2.1.2 Free and bound names2.1.3 Structural congruence2.1.4 Operational Semantics2.1.5 Bisimulation

    3 Categorical machinery4 The interpretation4.1 Semantics4.1.1 Bisimulation again4.1.2 Full abstraction

    5 Conclusions and future work6 References