A Theory of Weak Bisimulation for Core CML

Similar documents
Exact and Approximate Detection Probability Formulas in Fundamentals of Radar Signal Processing

UNTYPED LAMBDA CALCULUS (II)

Higher order derivatives

Clausius-Clapeyron Equation

The Matrix Exponential

The Matrix Exponential

CS 361 Meeting 12 10/3/18

Basic Polyhedral theory

Collisions between electrons and ions

cycle that does not cross any edges (including its own), then it has at least

Construction of asymmetric orthogonal arrays of strength three via a replacement method

CPE702 Algorithm Analysis and Design Week 11 String Processing

(Upside-Down o Direct Rotation) β - Numbers

A Propagating Wave Packet Group Velocity Dispersion

Addition of angular momentum

Fourier Transforms and the Wave Equation. Key Mathematics: More Fourier transform theory, especially as applied to solving the wave equation.

Abstract Interpretation. Lecture 5. Profs. Aiken, Barrett & Dill CS 357 Lecture 5 1

Bayesian Decision Theory

Addition of angular momentum

Introduction to Arithmetic Geometry Fall 2013 Lecture #20 11/14/2013

SCHUR S THEOREM REU SUMMER 2005

Introduction to the quantum theory of matter and Schrödinger s equation

Propositional Logic. Combinatorial Problem Solving (CPS) Albert Oliveras Enric Rodríguez-Carbonell. May 17, 2018

SME 3033 FINITE ELEMENT METHOD. Bending of Prismatic Beams (Initial notes designed by Dr. Nazri Kamsah)

1 Minimum Cut Problem

Note If the candidate believes that e x = 0 solves to x = 0 or gives an extra solution of x = 0, then withhold the final accuracy mark.

Differential Equations

The van der Waals interaction 1 D. E. Soper 2 University of Oregon 20 April 2012

CPSC 665 : An Algorithmist s Toolkit Lecture 4 : 21 Jan Linear Programming

u 3 = u 3 (x 1, x 2, x 3 )

dt d Chapter 30: 1-Faraday s Law of induction (induced EMF) Chapter 30: 1-Faraday s Law of induction (induced Electromotive Force)

EEO 401 Digital Signal Processing Prof. Mark Fowler

Elements of Statistical Thermodynamics

COMPUTER GENERATED HOLOGRAMS Optical Sciences 627 W.J. Dallas (Monday, April 04, 2005, 8:35 AM) PART I: CHAPTER TWO COMB MATH.

CS 6353 Compiler Construction, Homework #1. 1. Write regular expressions for the following informally described languages:

Week 3: Connected Subgraphs

Abstract Interpretation: concrete and abstract semantics

Application of Vague Soft Sets in students evaluation

Combining the typed λ-calculus with. W. Ferreira M. Hennessy A.S.A. Jeffrey UNIVERSITY OF SUSSEX COMPUTER SCIENCE. Report 2/96 May 1996

SOME PARAMETERS ON EQUITABLE COLORING OF PRISM AND CIRCULANT GRAPH.

Function Spaces. a x 3. (Letting x = 1 =)) a(0) + b + c (1) = 0. Row reducing the matrix. b 1. e 4 3. e 9. >: (x = 1 =)) a(0) + b + c (1) = 0

EXST Regression Techniques Page 1

ECE602 Exam 1 April 5, You must show ALL of your work for full credit.

u x v x dx u x v x v x u x dx d u x v x u x v x dx u x v x dx Integration by Parts Formula

Background: We have discussed the PIB, HO, and the energy of the RR model. In this chapter, the H-atom, and atomic orbitals.

Section 6.1. Question: 2. Let H be a subgroup of a group G. Then H operates on G by left multiplication. Describe the orbits for this operation.

ph People Grade Level: basic Duration: minutes Setting: classroom or field site

Derangements and Applications

Recall that by Theorems 10.3 and 10.4 together provide us the estimate o(n2 ), S(q) q 9, q=1

Dealing with quantitative data and problem solving life is a story problem! Attacking Quantitative Problems

LINEAR DELAY DIFFERENTIAL EQUATION WITH A POSITIVE AND A NEGATIVE TERM

That is, we start with a general matrix: And end with a simpler matrix:

Category Theory Approach to Fusion of Wavelet-Based Features

Based on Unication-Driven. Leftmost Outermost Narrowing. Heinz Fabender and Heiko Vogler. Abt. Theoretische Informatik, Universitat Ulm

2.3 Matrix Formulation

Square of Hamilton cycle in a random graph

surface of a dielectric-metal interface. It is commonly used today for discovering the ways in

Differential Equations

22/ Breakdown of the Born-Oppenheimer approximation. Selection rules for rotational-vibrational transitions. P, R branches.

Estimation of apparent fraction defective: A mathematical approach

10. The Discrete-Time Fourier Transform (DTFT)

Deift/Zhou Steepest descent, Part I

General Notes About 2007 AP Physics Scoring Guidelines

Title: Vibrational structure of electronic transition

ARIMA Methods of Detecting Outliers in Time Series Periodic Processes

Finding low cost TSP and 2-matching solutions using certain half integer subtour vertices

COUNTING TAMELY RAMIFIED EXTENSIONS OF LOCAL FIELDS UP TO ISOMORPHISM

What are those βs anyway? Understanding Design Matrix & Odds ratios

Observer Bias and Reliability By Xunchi Pu

Some Results on E - Cordial Graphs

Search sequence databases 3 10/25/2016

The pn junction: 2 Current vs Voltage (IV) characteristics

Separating principles below Ramsey s Theorem for Pairs

u r du = ur+1 r + 1 du = ln u + C u sin u du = cos u + C cos u du = sin u + C sec u tan u du = sec u + C e u du = e u + C

6.1 Integration by Parts and Present Value. Copyright Cengage Learning. All rights reserved.

MATH 319, WEEK 15: The Fundamental Matrix, Non-Homogeneous Systems of Differential Equations

4. (5a + b) 7 & x 1 = (3x 1)log 10 4 = log (M1) [4] d = 3 [4] T 2 = 5 + = 16 or or 16.

Lecture 37 (Schrödinger Equation) Physics Spring 2018 Douglas Fields

Random Access Techniques: ALOHA (cont.)

GEOMETRICAL PHENOMENA IN THE PHYSICS OF SUBATOMIC PARTICLES. Eduard N. Klenov* Rostov-on-Don, Russia

Einstein Equations for Tetrad Fields

On the Hamiltonian of a Multi-Electron Atom

PHA 5127 Answers Homework 2 Fall 2001

COHORT MBA. Exponential function. MATH review (part2) by Lucian Mitroiu. The LOG and EXP functions. Properties: e e. lim.

Indexed Search Tree (Trie)

Properties of Phase Space Wavefunctions and Eigenvalue Equation of Momentum Dispersion Operator

ME 321 Kinematics and Dynamics of Machines S. Lambert Winter 2002

BINOMIAL COEFFICIENTS INVOLVING INFINITE POWERS OF PRIMES

BINOMIAL COEFFICIENTS INVOLVING INFINITE POWERS OF PRIMES. 1. Statement of results

Alpha and beta decay equation practice

Brief Introduction to Statistical Mechanics

Roadmap. XML Indexing. DataGuide example. DataGuides. Strong DataGuides. Multiple DataGuides for same data. CPS Topics in Database Systems

Mutually Independent Hamiltonian Cycles of Pancake Networks

Probability Translation Guide

DISTRIBUTION OF DIFFERENCE BETWEEN INVERSES OF CONSECUTIVE INTEGERS MODULO P

Zero Point Energy: Thermodynamic Equilibrium and Planck Radiation Law

Optics and Non-Linear Optics I Non-linear Optics Tutorial Sheet November 2007

2 AN OVERVIEW OF THE TENSOR PRODUCT

First derivative analysis

Symmetric centrosymmetric matrix vector multiplication

Transcription:

J. Functiona Programming (): 000, January 993 c 993 Cambridg Unirsity Prss A Thory of Wak Bisimuation for Cor CML WILLIAM FERREIRA Computing Laboratory Unirsity of Cambridg MATTHEW HENNESSY AND ALAN JEFFREY Schoo of Cogniti and Computing Scincs Unirsity of Sussx Abstract Concurrnt ML (CML) is an xtnsion of Standard ML of Nw Jrsy with concurrnt faturs simiar to thos of procss agbra. In this papr, w buid upon John Rppy s rduction smantics for CML by constructing a compositiona oprationa smantics for a fragmnt of CML, basd on highrordr procss agbra. Using th oprationa smantics w gnrais th notion of wak bisimuation quianc to buid a smantic thory of CML. W gi som sma xamps of proofs about CML xprssions, and show that our smantics corrsponds to Rppy s up to wak first-ordr bisimuation. Introduction Thr ha bn arious attmpts to xtnd standard programming anguags with concurrnt or distributd faturs, (Giacaon t a., 989; Homström, 983; Nikhi, 990). Concurrnt ML (CML) (Rppy, 99a; Rppy, 992; Panangadn & Rppy, 996) is a practica and gant xamp. Th anguag Standard ML is xtndd with two nw typ constructors, on for gnrating communication channs, and th othr for dayd computations, and a nw function for spawning concurrnt thrads of computation. Thus th anguag has a th functiona and highr-ordr faturs of ML, but in addition programs aso ha th abiity to communicat with ach othr by transmitting aus aong communication channs. In (Rppy, 992), a rduction sty oprationa smantics is gin for a subst of CML cad λ c, which may b iwd as a concurrnt rsion of th ca-by-au λ-cacuus of (Potkin, 975). Rppy s smantics gis rduction rus for who programs, not for program fragmnts. It is not compositiona, in that th smantics of a program is not dfind in trms of th smantics of its subtrms. Rppy s smantics is dsignd to pro proprtis about programs (for xamp typ safty), and not about program fragmnts (for xamp quationa rasoning). In this papr w construct a compositiona oprationa smantics in trms of a abd Wiiam Frrira was fundd by a CASE studntship from British Tcom. This work is carrid out in th contxt of EC BRA 766 CONCUR 2.

2 W. Frrira, M. Hnnssy and A. S. A. Jffry transition systm, for a cor subst of CML which w ca µcml. This smantics not ony dscribs th auation stps of programs, as in (Rppy, 992), but aso thir communication potntias in trms of thir abiity to input and output aus aong communication channs. This smantics xtnds th smantics of highr-ordr procsss (Thomsn, 995) with typs and first-cass functions. W thn procd to dmonstrat th usfunss of this smantics by using it to dfin a rsion of wak bisimuation, (Minr, 989), suitab for µcml. W pro that, moduo th usua probms associatd with th choic oprator of CCS, our chosn quianc is prsrd by a µcml contxts and thrfor may b usd as th basis for rasoning about CML programs. In this papr w do not instigat in dtai th rsuting thory but confin ourss to pointing out som of its saint faturs; for xamp standard idntitis on woud xpct of a ca-by-au λ-cacuus ar gin and w aso show that crtain agbraic aws common to procss agbras, (Minr, 989), hod. W now xpain in mor dtai th contnts of th rmaindr of th papr. In Sction 2 w dscrib µcml, a monomorphicay typd cor subst of CML, which nonthss incuds bas typs for chann nams, booans and intgrs, and typ constructors for pairs, functions, and dayd computations which ar known as nts. µcml aso incuds a sction of th constructs and constants for manipuating nt typs, such as and for constructing basic nts for snding and rciing aus, for combining dayd computations, for scting btwn dayd computations, and a function for aunching nw concurrnt thrads of computation within a program. Th major omission is that µcml has no faciity for gnrating nw chann nams. Howr w bi that this can b rmdid by using tchniqus common to th π-cacuus, (Minr, 99; Minr t a., 992; Sangiorgi, 992). In th rmaindr of this sction w prsnt th oprationa smantics of µcml in trms of a abd transition systm. In ordr to dscrib a possib stats which can aris during th computation of a w-typd µcml program w nd to xtnd th anguag. This xtnsion is twofod. Th first consists in adding th constants of nt typ usd by Rppy in (Rppy, 992) to dfin λ c, i.. constants to dnot crtain dayd computations. This xtndd anguag, which w ca µcml c, ssntiay coincids with th λ c, th anguag usd in (Rppy, 992), xcpt for th omissions citd abo. Howr to obtain a compositiona smantics w mak furthr xtnsions to µcml c. W add a para oprator, commony usd in procss agbras, which aows us to us programs in pac of th mutists of programs of (Rppy, 992). Th fina addition is mor subt; w incud in µcml c xprssions which corrspond to th d rsions of Rppy s constants for rprsnting dayd computations. Thus th abd transition systm uss as stats programs from a anguag which w ca µcml. This anguag is a suprst of µcml c, which is our rsion of Rppy s λ c, which in turn is a suprst of µcml, our mini-rsion of CML. Th foowing diagram

A Thory of Wak Bisimuation for Cor CML 3 indicats th rationships btwn ths anguags: µcml µcml c λ c CML µcml In Sction 3 w discuss smantic quiancs dfind on th abd transition of Sction 2. W dmonstrat th inadquacis of th obious adaptations of strong and wak bisimuation quianc, (Minr, 989), and thn considr adaptations of highr-ordr and irrfxi bisimuations from (Thomsn, 995). Finay w suggst a nw ariation cad hrditary bisimuation quianc which orcoms som of th probms ncountrd with using highr-ordr and irrfxi bisimuations. In Sction 4 w show that hrditary bisimuation is prsrd by a µcml contxts. This is an appication of th proof mthod originay suggstd in (How, 989) but th proof is furthr compicatd by th fact that hrditary bisimuations ar dfind in trms of pairs of rations satisfying mutuay dpndnt proprtis. In Sction 5 w brify discuss th rsuting agbraic thory of µcml xprssions. This papr is intndd ony to ay th foundations of this thory and so hr w simpy indicat that our thory xtnds both that of ca-by-au λ-cacuus (Potkin, 975) and procss agbras (Minr, 989). In Sction 6 w show that, up to wak bisimuation quianc, our smantics coincids with th rduction smantics for λ c prsntd in (Rppy, 992). This tchnica rsut appis ony to th common sub-anguag, namy µcml c. In Sction 7 w brify considr othr approachs to th smantics of CML and ratd anguags and w nd with som suggstions for furthr work. 2 Th Languag In this sction w introduc our anguag µcml, a subst of Concurrnt ML (Rppy, 99a; Rppy, 992; Panangadn & Rppy, 996). W dscrib th syntax, incuding a typing systm, and an oprationa smantics in trms of a abd transition systm. Unfortunaty, thr is not nough spac in this papr to proid an introduction to programming in CML: s (Panangadn & Rppy, 996) for a discussion of th dsign and phiosophy of CML. Th typ xprssions for our anguag ar gin by: A :: A A A A A A Thus w ha thr bas typs,, and ; th attr two ar simpy xamps of usfu bas typs and on coud asiy incud mor. Ths typs ar cosd undr four constructors: pairing, function spac, and th ss common and typ constructors.

4 W. Frrira, M. Hnnssy and A. S. A. Jffry Our anguag may b iwd as a typd λ-cacuus augmntd with th typ constructors A for communication channs snding and rciing data of typ A, and A for constructing dayd computations of typ A. Lt Chan A b a typ-indxd famiy of disjoint sts of chann nams, rangd or by k, and t Var dnot a st of ariabs rangd or by x, y and z. Th xprssions of µcml ar gin by th foowing abstract syntax: f g Exp :: c x w Va :: x y x k 0 c Const :: Th main syntactic catgory is that of Exp which ook ry much ik th st of xprssions for an appid ca-by-au rsion of th λ-cacuus. Thr ar th usua pairing, tbinding and branching constructors, and two forms of appication: th appication of on xprssion to anothr,, th appication of a constant to an xprssion, c. Thr is aso a syntactic catgory of au xprssions Va, usd in giing a smantics to ca-by-au functions and communicat-by-au channs. Thy ar rstrictd in form: ithr a ariab, a rcursiy dfind function, x y, or a prdfind itra au for th bas typs. W wi us som syntax sugar, writing y for x y whn x dos not occur in, and ; f for x f whn x dos not occur in f. Finay thr ar a sma coction of constant functions. Ths consist of a rprsntati samp of constants for manipuating objcts of bas typ,, which coud asiy b xtndd, th projction functions and, togthr with th st of constants for manipuating dayd computations takn dircty from (Rppy, 992): and, for constructing dayd computations which can snd and rci aus,, for constructing atrnatis btwn dayd computations,, for spawning nw computationa thrads,, for aunching dayd computations,, for combining dayd computations,, for a dayd computation which aways dadocks, and, for a dayd computation which immdiaty trminats with a au. Not that thr is no mthod for gnrating chann nams othr than using th prdfind st of nams Chan A. Thr ar two constructs in th anguag which bind occurrncs of ariabs, x 2 whr fr occurrncs of x in 2 ar bound and x y whr fr occurrncs of both x and y in ar bound. W wi not dw on th prcis dfinitions of fr and bound ariabs but simpy us f to dnot th st of ariabs which ha fr occurrncs in. If f /0 thn is said to b a cosd xprssion, which w somtims rfr to as a program. W aso us th standard notation of x to dnot th substitution of th au for a fr occurrncs of x in whr bound nams may b changd in ordr to aoid th captur of fr ariabs in. (Sinc w ar moding a

!! ' A Thory of Wak Bisimuation for Cor CML 5 : A B A : A B B :! : ) : *+! - : A A #. - : A A " #$ #$ " : A A : A A : A A A (' : % & & : A,% A B ' B : A Figur a. Typ rus for µcml constant functions Γ 0 Γ 09% : Γ 0 : A c : A B4 Γ 0 c : B 5 Γ/ x : A 0 x : A : *6! Γ 0 7! Γ 0 y : B x 32 y4 Γ/ x : A 0 y : B : *+! Γ 0 k : A Γ 0 n : Γ/ x : A B/ y : A 0 : B Γ 0;:6<% x 3 y = ' : A B Γ 0 : A B Γ 0 f : A Γ 0 f : B Γ 0 : *6! Γ 0 f : A Γ 0 g : A Γ 0 f! g : A k 8 Chan A 4 Γ 0 : A Γ 0 f : B Γ 09% / f ' : A B Γ 0 : A Γ/ x : A 0 f : B Γ 0>! x 3 f : B Figur b. Typ rus for µcml xprssions. ca-by-au anguag, w ha imitd substitution to aus x rathr than th mor gnra f x. In ordr to mod apha-conrsion, w ha thrfor incudd ariabs as possib aus.) W now xamin brify th typ systm for this anguag. Th typs for th constant functions of th anguag ar gin in Figur a; this is in agrmnt with th typing rus gin in (Rppy, 992) for λ c. Not that many of th constants (such as : A A A ) ha a famiy of typs. This assignmnt of typs to constant functions is usd to infr typs for arbitrary xprssions in th standard way, using a typ infrnc systm. A typing judgmnt Γ? : A consists of a typ assignmnt Γ, an xprssion and a typ A such that f A@CB x DDD x ne. A typ assignmnt is a squnc of th form x : t DDD x n : t n, whr ach t i is a typ. Intuitiy a typ judgmnt shoud b rad as in th typ assignmnt Γ th xprssion has typ A. Th typ infrnc systm is gin in Figur b and is straightforward. Thr ar two structura rus, itras ar assignd thir natura typs whi th typs of functiona aus ar infrrd using a minor modification of th standard ru for functiona abstractions. Th rmaining constructs ar aso handd using standard infrnc rus, (Guntr, 992). W now turn our attntion to th oprationa smantics. In (Rppy, 992; Brry t a., 992) a rduction smantics is gin to λ c and sinc µcml c is a subst of λ c, this inducs a rduction smantics for µcml c ; this is discussd in fu in Sction 6. Th judgmnts in

6 W. Frrira, M. Hnnssy and A. S. A. Jffry this rduction smantics ar of th form: C C whr C C ar configurations which combin a cosd xprssion with a run-tim nironmnt ncssary for its auation, and is Minr s notation for a sint action. Howr this smantics is not compositiona as th rductions of an xprssion can not b dducd dircty from th rductions of it constitunt componnts. Hr w gi a compositiona oprationa smantics with four kinds of judgmnts: k?x k!, rprsnting a on stp auation or rduction,, rprsnting th production of th au, with a sid ffct,, rprsnting th potntia to input a au x aong th chann k, and, rprsnting th output of th au aong th chann k. Ths ar formay dfind in Figur 2, but w first gi an informa oriw. In ordr to dfin ths rations w introduc xtra syntactic constructs. Ths ar introducd as rquird in th oriw but ar summarizd in Figur 3. Th rus for on stp auation or rduction ha much in common with thos for a standard ca-by-au λ-cacuus. But in addition a cosd xprssion of typ A shoud auat to a au of typ A and it is this production of aus which is th subjct of th scond kind of judgmnt. Howr µcml xprssions can spawn subprocsss bfor rturning a au, so w ha to aow xprssions to continu auation n aftr thy ha rturnd a rsut. For xamp in th xprssion: on possib rduction is (whr 0 a ; a indicats a squnc of -rductions): 0 a ; a a? a!0 whr th procss rturns th au bfor outputting 0. For this rason w nd a rduction rathr than th mor usua trmination. Th foowing diagram iustrats a of th possib transitions from this xprssion: a? a!0 a? a!0 a!0 0 a ; 0 a Whn giing an oprationa smantics to a anguag with sid-ffcts thr ar two standard approachs to rtaining th information ncssary to intrprt thm. Th first, usd for xamp in (Brry t a., 992; Rppy, 992), is to dfin a notion of stat or configuration; ths contain th program bing auatd togthr with auxiiary stat information, and th

α α α A Thory of Wak Bisimuation for Cor CML 7 judgmnts of th oprationa smantics appy to ths configurations. Th scond, mor common in work on procss agbras, (Brgstra & Kop, 985; Minr, 989), xtnds th syntax of th anguag bing intrprtd to ncompass configurations. W choos th attr approach and on xtra construct w add to th anguag is a para oprator, f. This has th sam oprationa rus as in CCS, aowing rduction of both procsss: α f f and communication btwn th procsss: k! k?x f f f f x f f k?x f f k! f f f x f Th assymtry is introducd by trmination (a fatur missing from CCS). A CML procss has a main thrad of contro, and ony th main thrad can rturn a au. By conntion, w writ th main thrad on th right, so th ru is: f f f f Thr is no corrsponding symmtric ru. For xamp: Λ Sinc th ony diffrnc btwn concurrnt procsss is which trm can rturn a au, concurrncy is associati and symmtric on th ft, so f g is bisimiar to f g. In gnra, w can rgard n procsss in para: n f as bing a mutist of spawnd thrads n pus on main thrad of contro f, corrsponding to th us of muti-sts in th rduction smantics of (Brry t a., 992; Rppy, 992). Concurrnt procsss ar gnratd using th constant appication. A first attmpt to writ th smantics for woud b th ru: y y On stp in th auation of y ads to two xprssions running in para, on bing th spawnd function appication y and th othr th dfaut au which rsuts from ry appication of. Howr, this ru for is not gnra nough. Firsty, it ignors th fact that th xprssion may nd to prform som computation bfor rturning a function, which is capturd by instantiating th static ru for constant appication as: α α Scondy, may ha spawnd som concurrnt procsss bfor rturning a function, and ths shoud carry on auation, so w us th sint ru for constant appication: Λ

α 8 W. Frrira, M. Hnnssy and A. S. A. Jffry Th w-typdnss of th oprationa smantics wi nsur that is a function of th appropriat typ,. With this mthod of rprsnting nwy cratd computation thrads mor of th rus corrsponding to β-rduction in a ca-by-au λ-cacuus may now b gin. To auat an appication xprssion f, first is auatd to a au of functiona form and thn th auation of f is initiatd. This is rprsntd by th rus: α y g f f f y f g (In fact w us a sighty mor compicatd rsion of th attr ru as functions ar aowd to b rcursi.) Continuing with th auation of f, w now auat f to a au which is thn substitutd into g for y. This is rprsntd by th two rus: f f x f g x f f f g x f g f g x Th auation of th appication xprssion c f is simiar; f is auatd to a au and thn th constant c is appid to th rsuting au. This is rprsntd by th two rus f f c f c f f f c f f δ c Hr, borrowing th notation of (Rppy, 992), w us th function δ to rprsnt th ffct of appying th constant c to th au. This ffct dpnds on th constant in qustion and w ha arady sn on instanc of this ru, for th constant, which rsut from th fact that δ. Th dfinition of δ for a constants in th anguag is gin in Figur 2f. For th constants associatd with th bas typs this is sf-xpanatory; th othrs wi b xpaind bow as th constant in qustion is considrd. Not that bcaus of th introduction of into th anguag w can trat a constants uniformy, unik (Rppy, 992) whr and ha to considrd in a spcia mannr. In ordr to impmnt th standard ft-to-right auation of pairs of xprssions w introduc a nw au w rprsnting a pair which has bn fuy auatd. Thn to auat f : first aow to auat: α f α f thn whn it trminats, start th auation of f : f x f Ths au pairs may thn b usd by bing appid to functions of typ A B. For xamp th foowing infrncs rsut from th dfinition of th function δ for th constants and : w m n m n D It rmains to xpain how dayd computations, i.. programs of typ A, ar handd. It is important to rais that xprssions of typ A rprsnt potntia rathr than actua computations and this potntia can ony b actiatd by an appication of th x

/ / / / / α ' ' /! / A Thory of Wak Bisimuation for Cor CML 9 α c α c α f α f % / f ' α % / f ' α f! g α f α! g! x 3 f α! x 3 f α f α f α f f f α f f f f f Figur 2a. Oprationa smantics: static rus g α g g 2 α g 2 α g g 2 α g α g = α Figur 2b. Oprationa smantics: dynamic rus c δ% c/ ' f! g f f! g g % / f '! x 3 f / x f! y 3 f g x4 3 :+<+% x 3 y = g ' 4! x 3 f f k! k?x f f x4 f f k?x k! f f x4 f x4 f Figur 2c. Oprationa smantics: sint rus Λ k! k! % k? k?x x A Figur 2d. Oprationa smantics: axioms a :: 3 k! k?x α :: 3 a :: 3 α δ% δ% ) δ%! Figur 2. Oprationa smantics: grammar of abs ' / w 3 ' δ% m/ n 3 m n ' δ%! / m/ n 3 m n ' / w 3 w ' m/ n 3 m n ' δ% k/ 3 k!4 δ% / k ' 3 k?4 ' δ% g 4/ g 2 4 3 #$ " ' g g 2 4 δ% g4/ 3 g '' = δ% /7% 3 #. - Λ4 δ% / ' 3 " 5# A4 δ% / ' 3 ' - ' % % δ% / g4 3 g Figur 2f. Oprationa smantics:rduction of constants 4

! '! 0 W. Frrira, M. Hnnssy and A. S. A. Jffry / f / g 8 Exp :: 3 c! % / '! x 3 / w 8 Va :: 3 :+<% x 3 y = ' 7 x k % 0 c 8 Const :: 3 )!! " #$ - # " #. - Figur 3a. Syntax of µcml / w 8 Va :: 3 / g4 g 8 GExp :: 3!? g = g g Λ A Figur 3b. Syntax of µcml c / f / g 8 Exp :: 3 g Figur 3c. Syntax of µcml constant, of typ A A. Thus for xamp th xprssion k is of typ A and rprsnts a dayd computation which has th potntia to rci a au of typ A aong th chann k. Th xprssion k can actuay rci such a au aong chann k, or mor accuraty can auat to such a au, proidd som othr computation thrad can snd th au aong chann k. Th smantics of is handd by introducing a nw constructor for aus. For crtain kinds of xprssions g of typ A, which w ca guardd xprssions, t g b a au of typ A ; this rprsnts a dayd computation which whn aunchd initiats a nw computation thrad which auats th xprssion g. Thn th xprssion g rducs in on stp to th xprssion g. Mor gnray th auation of th xprssion procds as foows: First auat unti it can produc a au: thn aunch th rsuting dayd computation: g g Not that hr, as aways, th production of a au may ha as a sid-ffct th gnration of a nw computation thrad and this is aunchd concurrnty with th dayd computation g. Aso both of ths rus ar instancs of mor gnra rus arady considrd. Th first is obtaind from th ru for th auation of appications of th form c and th scond by dfining δ g to b g. Th prcis syntax for guardd xprssions wi mrg by considring what typs of aus of th form can rsut from th auation of xprssions of typ from th basic anguag µcml. Th constant is of typ A A and thrfor

A Thory of Wak Bisimuation for Cor CML th auation of th xprssion procds by first auating to a au of typ A unti it rturns a au k, and thn rturning a dayd computation consisting of an nt which can rci any au of typ A on th chann k. To rprsnt this nt w xtnd th syntax furthr by tting k? b a guardd xprssion for any k and A, with th associatd ru: k k? Th construct is handd in a simiar mannr, using guardd xprssions of th form k!: k k! It is ths two nw xprssions k? and k! which prform communication btwn computation thrads. Formay k! is of typ and w ha th axiom: k! k! Intuitiy this may b rad as k! auats in on stp to th xprssion and this auation has as a sid ffct th transmission of th au to th chann k. Th smantics w considr for input is th at smantics, whr th rduction ru binds a nw ariab x: k? k?x x Thrfor in gnra input mos ar of th form k?x f whr : B and x : A f : B. Communication can now b modd as in CCS by th simutanous occurrnc of input and output actions: k?x k! f f f x f Thr rmain four constructs for dayd computations to b xpaind. Th first, of typ A, is handd by th introduction of th guardd xprssion Λ, rprsnting a dadockd auation, togthr with th infrnc ru: Λ obtaind, onc mor, by dfining δ to b Λ. Th constant is of typ A A B B. Th auation of procds in th standard way by auating unti it producs a au, which must b of th form g, whr g is a guardd xprssion of typ A and has typ A B. Thn th auation of continus by th construction of th nw dayd computation g. Baring in mind th fact that th production of aus can gnrat nw computation thrads, this is formay rprsntd by th infrnc ru: g g Th guardd xprssion g Th is a wrappr which appis to th rsut of auating g: g α g α construct, of typ A A, auats its argumnt to a au, and thn

α α 2 W. Frrira, M. Hnnssy and A. S. A. Jffry rturns a triia a dayd computation; this computation, whn actiatd, immdiaty auats to th au. In ordr to rprsnt ths triia computations w introduc a nw constructor for guardd xprssions, A and th smantics of is thn capturd by th ru: A Sinc A immdiaty auats to th constant w ha: A Th choic construct is a choic btwn dayd computations as has th typ A A A. To intrprt it w introduc a nw choic constructor g g 2 whr g and g 2 ar guardd xprssions of th sam typ. Thn procds by auating unti it can produc a au, which must b of th form g g 2, and th auation continus by constructing th dayd computation g g 2. This is rprsntd by th ru: g g 2 g g 2 Th notation, introducd in (Rppy, 992), is unfortunat, as it is usd in (Hnnssy, 988) to rprsnt th intrna choic btwn procsss whras hr it rprsnts xtrna choic: w ha th foowing auxiiary rus, which ar th sam as CCS summation: g g 2 g g α 2 g g α 2 This nds our informa dscription of th oprationa smantics of µcml. W now summaris, giing th prcis dfinitions of th nw syntax. For th purposs of comparison with th rduction smantics of λ c, (Rppy, 992), it is connint to iw th xtnsion to µcml in two stags. Th first is obtaind by adding th nw syntactic catgory of guardd xprssions, and two nw constructors for aus: Va :: g g GExp ::!? g g g Λ A Th rsuting anguag w ca µcml c, as it corrsponds ry cosy to Rppy s λ c. A prcis comparison is gin in Sction 6. Th fina anguag, µcml, is obtaind by xtnding µcml c with: Exp :: g and typ judgmnts for a th xtra constructs appar in Figur 4. Th oprationa smantics is gin as a st of transition rations or cosd xprssions from µcml. Ths transition rations ha as abs Lab: a :: k! k?x α :: a :: α which ar typd with judgmnts? : A in Figur 5, and ar dfind to b th ast rations satisfying th rus in Figur 2. Th rus ar diidd into thr parts. Th first gis th st of contxt rus, showing whn mos may b propagatd through crtain contxts; th scond gi th rduction rus whi th third contains th axioms.

A Thory of Wak Bisimuation for Cor CML 3 Γ 0 : A Γ 0 w : B Γ 0 g : A Γ 0 / w : A B Γ 0 g4 : A Γ 0 : A Γ 0 w : A Γ 0 : A Γ 0 g : A Γ 0 : A B Γ 0!w : Γ 0? : A Γ 0 g = : B 0 0 0 0 Γ g : A Γ g 2 : A Γ g g 2 : A Γ Λ : A Γ 0 : A Γ 0 f : B Γ 0 f : B Γ 0 : A Γ 0 A : A Fig. 4. Typ rus for xtra µcml constructs Γ 0 : A Γ 0 : A Γ 0 : A Γ 0 k?x : A Γ 0 w : B k 8 Chan Γ 0 k!w : A B 4 Fig. 5. Typ rus for abs It is worth pointing out that th contxt rus ar asymmtric for th propagation of au production though th contxt ; in f ony th computation thrad f can produc a au. This is in agrmnt with th rduction smantics of (Rppy, 992) whr in a gin stat rprsntd by a muti-st of xprssions ony on distinguishd xprssion is aowd to produc a au. Aso in th ru for appication, th auation of f is somwhat mor compicatd than priousy statd; aus of functiona typ a ino th fix point oprator and ths fix points ar automaticay unfodd at th point of appication. W nd this sction with a Subjct Rduction Thorm for our smantics: Thorm 2. For ry cosd xprssion? : A in µcml if thn? : A, if thn? : A and? : A, if k?x and k Chan B thn x : B? : A, and if k! and k Chan B thn? : A and? : B. By ru induction on th infrncs. 3 Wak Bisimuation Equianc In this sction w dmonstrat th usfunss of our oprationa smantics by proiding µcml with an appropriat rsion of bisimuation quianc. W discuss a rang of possib bisimuation basd quiancs and ntuay propos a nw ariation cad hrditary bisimuation quianc, which w f is most suitd to µcml. W first show how to adapt th notion of strong bisimuation quianc to µcml. Sinc our anguag is typd it is mor connint to dfin th quianc in trms of typ-indxd famiis of rations. Moror sinc th oprationa smantics uss actions

4 W. Frrira, M. Hnnssy and A. S. A. Jffry of th form k?x f whr f may b an opn xprssion w nd to considr rations or opn xprssions. Lt an opn typ-indxd ration R b a famiy of rations R Γ A such that if R Γ A f thn Γ? : A and Γ? f : A. W wi oftn id th subscripts from rations, for xamp writing R f for R Γ A f whn contxt maks th typ obious. Lt a cosd typ-indxd ration R b an opn typ-indxd ration whr Γ is rywhr th mpty contxt, and can thrfor b idd. For any cosd typ-indxd ration R, t its opn xtnsion R b dfind as: R x: A B f iff x R B f x for a? A cosd typ-indxd ration R is structur prsring iff: if R A w and A is a bas typ thn w, if 2 R A A 2 w w 2 thn i R Ai w i, if g R A g 2 thn g R A g 2, and if R A B thn for a? w : A w ha w R B w. : AD With this notation w can now dfin strong bisimuations or µcml xprssions. A cosd typ-indxd ration R is a first-ordr strong simuation iff it is structurprsring and th foowing diagram can b comptd: R 2 R 2 as R 2 Not th us of th opn xtnsion R. This mans, for xamp, that if R 2 w rquir k?x k?x that th mo f b matchd by a mo 2 f 2 whr f 2 is such that for a aus of th appropriat typ f x R f 2 x. Thus in th trminoogy of (Minr t a., 992) our dfinition corrsponds to th at rsion of bisimuation. (An atrnati woud b ary bisimuation whr input mos ar abd with cosd aus rathr than ariabs. This is computationay mor appaing, but it is an opn probm whthr th tchniqus of th nxt sction can b appid to opn bisimuation). R is a first-ordr strong bisimuation iff R and R ar first-ordr strong simuations. Lt b th argst first-ordr strong bisimuation. Proposition 3. is an quianc. Us diagram chass to show that if R is a first-ordr strong simuation thn so ar th idntity ration I and th ration composition R R. Th rsut foows. Unfortunaty, is not a congrunc for µcml, sinc w ha: 2 2 howr, snding th thunkd xprssions on chann k w gt: k! x 2 k! x 2

A Thory of Wak Bisimuation for Cor CML 5 sinc th dfinition of strong bisimuation dmands that th actions prformd by xprssions match up to syntactic idntity. This countr-xamp can aso b rproducd using ony µcml contxts: k x 2 k x 2 sinc th ft hand sid can prform th mo: k x 2 k! x 2 but this can ony b matchd by th right hand sid up to strong bisimuation: k! k x 2 x 2 In fact, it is asy to rify that th ony first-ordr strong bisimuation which is a congrunc for µcml is th idntity ration. To find a satisfactory tratmnt of bisimuation for µcml, w nd to ook to highrordr bisimuation, whr th structur of th abs is accountd for. To this nd, gin a cosd typ-indxd ration R, dfin its xtnsion to abs R as: R A R A w R A w k?x R A k?x R B w k! R A k!w k Chan B Thn R is a highr-ordr strong simuation iff it is structur-prsring and th foowing diagram can b comptd: R 2 R 2 as whr R 2 2 Lt R 2 h b th argst highr-ordr strong bisimuation. Proposition 3.2 h is a congrunc. Us a simiar tchniqu to th proof of Proposition 3. to show that To show that h is a congrunc, dfin R as: R &B C C f h f E h is an quianc. and thn show by induction on C that R is a simuation. Th rsut foows. For many purposs, strong bisimuation is too fin an quianc as it is snsiti to th numbr of rductions prformd by xprssions. This mans it wi not n aidat mntary proprtis of β-rduction such as x x 0 0. W rquir th coarsr wak bisimuation which aows -actions to b ignord. ε This in turn rquirs som mor notation. Lt b th rfxi transiti cosur of ε, and t b (i.. any squnc of sint action foowd by an action). ˆ ε Not that w ar not aowing sint actions aftr th action. Lt b if and

6 W. Frrira, M. Hnnssy and A. S. A. Jffry othrwis. Thn R is a first-ordr wak simuation iff it is structur-prsring and th foowing diagram can b comptd: R 2 R 2 as ˆ Lt b th argst first-ordr wak bisimuation. Proposition 3.3 is an quianc. R 2 Simiar to th proof of Proposition 3.. Unfortunaty, is not a congrunc, for th sam rason as, and so w can attmpt th sam modification. R is a highr-ordr wak simuation iff it is structur-prsring and th foowing diagram can b comptd: Lt R 2 R 2 h b th argst highr-ordr wak bisimuation. Proposition 3.4 h is an quianc. Simiar to th proof of Proposition 3.. as whr R ˆ 2 2 R 2 Howr, h is sti not a congrunc, for th usua rason that wak bisimuation quianc is not a congrunc for CCS summation. Rca from (Minr, 989) that in CCS 0 D 0 but ad 0 0 ad 0 D 0. W can dupicat this countr-xamp in µcml sinc th CCS oprator corrsponds to th µcml oprator and 0 corrsponds to Λ. Howr may ony b appid to guardd xprssions and thrfor w nd a guardd xprssion which bhas ik D 0; th rquird xprssion is A Λ. Thus: Λ h A Λ sinc th right hand sid has ony on rduction: but: Λ k!0 A Λ Λ Λ h A Λ k!0

A Thory of Wak Bisimuation for Cor CML 7 bcaus th ony rduction of Λ k!0 is Λ k!0 k!0 Λ Λ and: A Λ k!0 Λ Λ This countr-xamp can aso b rpicatd using th rstrictd syntax of µcml. W ha: h sinc th ft hand sid has ony on rduction: Λ Λ and th right hand sid can match this with: A Λ Λ and w ha sn: Howr: Λ h A Λ k 0 h sinc th ft hand sid has ony on rduction: Λ k!0 whras th right hand sid has th rduction: A Λ k!0 D k 0 k 0 k 0 A first attmpt to rctify this is to adapt Minr s obsrationa quianc for µcml, and to dfin h as th smast symmtric ration such that th foowing diagram can b comptd: Proposition 3.5 h is an quianc. Simiar to th proof of Proposition 3.. h 2 h 2 as 2 whr This attmpt fais, howr, sinc it ony ooks at th first mo of a procss, and not at th h 2 h 2

8 W. Frrira, M. Hnnssy and A. S. A. Jffry first mos of any procsss in its transitions. Thus, th abo µcml countr-xamp for h bing a congrunc aso appis to h ; i.. but: h k 0 h k 0 This faiur was first notd in (Thomsn, 995) for CHOCS. Thomsn s soution to this probm is to rquir that -mos can aways b matchd by at ast on -mo, which producs his dfinition of an irrfxi simuation as a structur-prsring ration whr th foowing diagram can b comptd: R 2 R 2 as whr R 2 2 R 2 Lt i b th argst irrfxi bisimuation. Proposition 3.6 i is a congrunc. Th proof that i is an quianc is simiar to th proof of Proposition 3.. Th proof that it is a congrunc is simiar to th proof of Thorm 4.7 in th nxt sction. Howr this ration is rathr too strong for many purposs, for xamp 2 i sinc th right hand sid can prform mor -mos than th ft hand sid. This is simiar to th probm in CHOCS whr ad D P i ad P. In ordr to find an appropriat dfinition of bisimuation for µcml, w obsr that µcml ony aows to b usd on guardd xprssions, and not on arbitrary xprssions. W can thus ignor th initia -mos of a xprssions xcpt for guardd xprssions. For this rason, w ha to proid two quiancs: on on trms whr w ar not intrstd in initia -mos, and on on trms whr w ar. A pair of cosd typ-indxd rations R R n R s form a hrditary simuation (w ca R n an insnsiti simuation and R s a snsiti simuation) iff R s is structurprsring and w can compt th foowing diagrams: R n 2 R n 2 as whr R s ˆ 2 2 R n 2

A Thory of Wak Bisimuation for Cor CML 9 and: R s 2 R s 2 as whr R s 2 2 R n 2 Lt n s b th argst hrditary bisimuation. Not that w rquir R s to b structurprsring bcaus it is usd to compar th abs in transitions, which may contain abstractions or guardd nts. In th oprationa smantics of µcml xprssions, guardd xprssions can ony appar in abs, and not as th rsiduas of transitions. This xpains why in th dfinition of n abs ar compard with rspct to th snsiti ration s whras th insnsiti ration is usd for th rsiduas. For xamp, if g n s g 2 thn w ha: x g n x g 2 sinc onc ithr sid is appid to an argumnt, thir first action wi b a -stp. On th othr hand: g n g 2 sinc is prcisy th construct which aows us to mbd g and g 2 in a contxt. Thorm 3.7 s is a congrunc for µcml, and n is a congrunc for µcml. Th proof that s and n ar quiancs is simiar to th proof of Proposition 3.. Th proof that thy form congruncs is th subjct of th nxt sction. Proposition 3.8 Th quiancs on µcml ha th foowing strict incusions: h i s n For ach incusion, show that th first bisimuation satisfis th condition rquird to b th scond form of bisimuation. To show that th incusions ar strict, w us th foowing xamps: x 2 h h x h 2

B B B B B 20 W. Frrira, M. Hnnssy and A. S. A. Jffry whr: k x k 2 i s i x x h k n s x x h n h h x x x (Not that this stts an opn qustion (Thomsn, 995) as to whthr congrunc containd in h.) i is th argst It is th oprator which diffrntiats btwn th two quiancs n and h. Howr in ordr to dmonstrat th diffrnc w nd to b ab to appy to guardd xprssions which can spontanousy o, i.. prform -mos. Th ony µcml constructor for guardd xprssions which aows this is A, and in turn occurrncs of this can ony b gnratd by th µcml constructor. Thrfor: Proposition 3.9 For th subst of µcml without as h. From Proposition 3.8 n h. For th subst of µcml without w h we g g 2 and A, n is th sam as and A, dfin R s as: g h g 2 E w 2 w h, and h 2 E s is th sam Thn sinc no nt without A can prform a -mo, and sinc th ony initia mos of i w ar β-rductions, w can show that h R s forms an hrditary bisimuation, and so n. From this it is routin to show that s h. h @ Unfortunaty w ha not bn ab to show that n is th argst µcml congrunc containd in wak highr-ordr bisimuation quianc. Howr w do ha th foowing charactrisation: Thorm 3.0 n is th argst highr-ordr wak bisimuation which rspcts µcml contxts. By dfinition, n is a highr-ordr wak bisimuation, and w ha shown that it rspcts µcml contxts. A that rmains is to show that it is th argst such. Lt R b a highr-ordr wak bisimuation which rspcts µcml contxts. Thn dfin: R n R B w 2 R s B w R we R 2 2 w g g 2 2E B 2 w g R g 2 E R 2 w w 2 w E R 2 E W wi now show that R n R s forms an hrditary simuation, from which w can dduc R @ R n @ n.

A Thory of Wak Bisimuation for Cor CML 2 First, w not that R s is structur prsring, and that R s R. Thn w show that w can compt th rquird diagrams for R n R s to b an hrditary simuation. Th ony tricky cas is if: g R s g 2 in which cas, by th dfinition of R s, g R g 2, and sinc R rspcts µcml contxts w ha (for frsh k): g g k R k? g 2 Λ R Λ and sinc R is a highr-ordr wak bisimuation, w ha: g k? R g 2 k? g 2 k k? which can b comptd as: k?x but sinc and g k? R g 2 k? ˆ 2 whr R 2 R 2 k?x k?x, w ha 2 and 2 k?x, and so: g R s g 2 2 R 2 whr R s 2 Th othr cass ar simpr, and so R n R s is an hrditary bisimuation. Thus R @ R n @ n, and so n is th argst highr-ordr wak bisimuation which rspcts µcml contxts. This Thorm shoud b contrastd with th cas of CCS. In (Minr, 989) sction 7D 2 it is shown that th argst congrunc containd in wak bisimuation is not itsf a wak bisimuation.

22 W. Frrira, M. Hnnssy and A. S. A. Jffry 4 Bisimuation as a congrunc To sr as th basis of a usfu smantic thory of µcml, bisimuation shoud b prsrd by a of th constructs of th anguag. In this sction w wi show that s is a congrunc for µcml, and that n is a congrunc for µcml. Unfortunaty, this proof is not straightforward, du to th highr-ordr natur of hrditary bisimuation. Th probm is not uniqu to µcml, and it occurs in many highr-ordr anguags, for xamp typd λ-cacui (Gordon, 995), th untypd λ-cacuus (How, 989), and th Cacuus of Highr-Ordr Communicating Systms (CHOCS) (Thomsn, 995). Th difficuty is in finding th right form of induction to us, whn a of th standard inductions (for xamp on structur of trms, on numbr of -mos, on structur of proof) fai. For xamp, th proof of congrunc for CHOCS (Thomsn, 995, Prop. 6.6) adapts Minr s tchniqu (Minr, 989, Thorm 8, p. 55) but uss a non-w-foundd induction. It sms that any inducti proof that wak bisimuation is a congrunc for highrordr anguags rquirs an induction on both syntax and proof structur. Th usua mthods of prforming nstd induction fai in this cas, and so anothr mthod of prforming simutanous induction is rquird. Fortunaty this is achid by a tchniqu dopd for th azy λ-cacuus (How, 989). W sha appy How s tchniqu to show that s is a congrunc for µcml, and that n is a congrunc for µcml without g and g g 2. This particuar appication is mad compicatd by th fact that w ha to da a pair of rations, n s which ar dfind in trms of ach othr. So athough w foow th gnra proof mthod usd in (How, 989) and th notation of (Gordon, 995), th arious tchnica dfinitions about rations which foow wi appy to pairs of rations of th form R R n R s with R s @ R n. W wi continu to appy th usua oprations associatd with rations, such as composition, undr th assumption that such oprations ar appid pointwis. Dfin a contxt to b gin by th grammar: C :: i cc C C C C C CC x y C C C C C!C C? C C C C AC C x C C Lt C b th trm gin by rpacing ach ho i by th trm i (unik substitution, w aow for captur of fr ariabs). An quianc R is a congrunc iff i R f i impis C R C f. Dfin an unntfu contxt to b on which dos not us C or C C, that is on gin by th grammar: C n :: i cc n C n C n C n C n C n C n C n x y C n C n C n C n!c n C n? C n C n AC n C n C n C x C n C n An quianc R is an unntfu congrunc iff i R f i impis C n R C n f. Not that any µcml contxt is an unntfu contxt, and so any unntfu congrunc is a

B A Thory of Wak Bisimuation for Cor CML 23 congrunc for µcml. So w concntrat on showing that an unntfu congrunc. Dfin th on- dp contxts with th grammar: D :: x c 2 3 2 2 x y 2! 2? 2 2 s is a congrunc, and @ Lt D n rang or unntfu on- dp contxts. For any pair of rations R R n R s with R s R n, t its compatib rfinmnt, R b dfind: R n B R s B D n D n f D D f i R n f ie i R s f ie x y R s x A x y f 2 2 R n f E This dfinition is rathr diffrnt from How s and Gordon s dfinition of R CB i R f ie. Th diffrncs ar that: n is D D f n is not a congrunc, it is ony an unntfu congrunc, so w ony cos R n undr unntfu on- dp contxts rathr than arbitrary on- dp contxts, w want to maintain th inariant that for a pairs of rations w considr, R s @ R n, hnc w incud R s in th dfinition of R n, and if two insnsiti bisimiar xprssions ar thunkd, th rsuting xprssions ar snsiti bisimiar; for this rason th proof of Thorm 4.7 rquirs x y R s x y f whn R n f. Proposition 4. If R is an quianc and R @ congrunc. R, thn R s is a congrunc and R n is an unntfu A ariant of th proof in (Gordon, 995; How, 989). Show by induction on C that if i R s f i thn C R s C f. Eithr C i, in which cas th rsut is immdiat, or C D C and by inductionc i R s C i f, so by dfinitionc D C R s D C f C f. It foows that R s is a congrunc. Th proof that R n is an unntfu congrunc is simiar. For any R, its compatib cosur, R, is gin by: R R R Not that R s @ R n. This dfinition of R is spcificay dsignd to faciitat simutanous inducti proof on syntax (sinc th dfinition inos on- dp contxts) and on rductions (sinc th dfinition inos inducti us of R ). This form of induction is prcisy what is rquird to show th dsird congrunc rsuts. Its rant proprtis ar summd up in th foowing proposition.

@ 24 W. Frrira, M. Hnnssy and A. S. A. Jffry Proposition 4.2 If R is a prordr thn R is th smast ration satisfying:. R R @ R, 2. R @ R, and 3. R @ R. A ariant of th proof in (Gordon, 995). First w show that R is rfxi, by showing by structura induction on that R s. Find D such that D, so by induction i R s i, so by dfinition of R, D R s D R s D. Thn w show th rquird proprtis:. R R @ R R R @ 2. R R R @ R. 3. R @ R R @ R. R R $@ R. To s that R is th smast ration satisfying ths proprtis w show that if S satisfis ths proprtis, thn SR @ SR @ S, and so R @ S. Sinc R R, w know from Proposition 4. that if R is an quianc thn R s is a congrunc and R n is an unntfu congrunc. Howr, w can show a strongr rsut than that, which is that R is cosd undr substitution of cosd aus: Proposition 4.3 If R is a prordr thn for any R s w:. if R s f thn x R s f w x, and 2. if R n f thn x R n f w x. A ariant of th proof in (Gordon, 995; How, 989). To pro th first part, w procd by induction on. If x thn x R s f, so x R s w R s s f w x so by Proposition 4.2 x R f w x. If y z thn w can find a g such that R n g and y z g R s f, so by induction x R n g w x, so x y z x R s y z g w x R s s f w x, so by dfinition of R, x R f w x. Othrwis, w ha D and D x D x, so w can find g such s that R g and D g R s f, so by induction i x R s f i w x, hnc x D x D x R s D f w x D f w x R s f w x, so by dfinition of R, x R s f w x. Th proof of th scond part is simiar. Our proof stratgy is to show that and coincid. Sinc @, this amounts to showing that @, which w do by proing that, whn rstrictd to programs, is an hrditary simuation.

A Thory of Wak Bisimuation for Cor CML 25 Proposition 4.4 Whn rstrictd to cosd xprssions of µcml, is an hrditary simuation. W ha to show that s is structur-prsring, and that th diagrams for an hrditary simuation can b comptd. Showing that s is structur prsring is a routin structura induction. If: n f thn w procd by induction on to show that w can compt th diagram as: whr s 2, and simiary for s. W sha show thr of th mor intrsting cass, th othrs ar simiar but mor routin: if w ha: n n x 2 ˆ 2 f f n x g g 2 n f 2 x whr n i g i and, thn by induction g w g, s w and n g, so using Proposition 4.3, w ha: if w ha: x 2 2 x n x g g 2 n g 2 n g 2 w x g g 2 n n n ε f f f y 2 3 x

26 W. Frrira, M. Hnnssy and A. S. A. Jffry whr n i g i,, and w x y 3 thn by induction g g, s w, up to α-conrsion w x y g 3, and n g. Thn by th dfinition of, w can find an x y h 3 such that n 3 h 3 and s w, so by Proposition 4.3, 3 x n h 3 x n y n wy n g 3 w x, and so: 2 if w ha: y 2 3 x x y n n g g g 2 y g 2 g 3 w x n x y g n n n f ε f f whr Λ n g thn t x y g, so: x y n x y g Λ n Λ n n w f f and s s w. Thus is an hrditary simuation. W now ha that is a simuation, and w woud ik to show that it is a bisimuation, for which it suffics to show that is symmtric. Unfortunaty, this is not asy to pro dircty, and so w us a rsut of (How, 992) (pointd out to th authors by Andrw Pitts) which aows us to show that is symmtric. Proposition 4.5 If R is an quianc thn R is symmtric. A ariant of th proof in (How, 992). It suffics to show that if R s s f thn f R, and that if R n n f thn f R, which w show by induction on. If R s f, thn ithr: D R s D f R s f and i R s s f i, so by induction f i R i, so f R s D f D R s, or x y R s x y f R s f and R n f, so by induction n f R, so f R s s x y f R x y.

@ @ Th proof for R n is simiar. A Thory of Wak Bisimuation for Cor CML 27 W can us this rsut to show that is a bisimuation. Proposition 4.6 Whn rstrictd to cosd xprssions of µcml, is an hrditary bisimuation. By Proposition 4.4, By Proposition 4.5, is an hrditary simuation, and so is an hrditary simuation. is symmtric, and so is an hrditary bisimuation. This gis us th rsut w st out to pro. Thorm 4.7 s is a congrunc, and n is an unntfu congrunc. From Proposition 4.6, is an hrditary bisimuation, so, so and ar th sam ration. Sinc by Proposition 4.. @, and by Proposition 4.2, w ha th dsird rsut 5 Proprtis of Wak Bisimuation In this sction, w show som rsuts about program quianc up to hrditary wak bisimuation. Som of ths quiancs ar asy to show, but som ar trickir, and rquir proprtis about th transition systms gnratd by µcml. Athough much rmains to b don on aborating th agbraic thory of µcml programs w hop that th rsuts in this sction indicat that this quianc can form th basis of a usfu thory which gnraiss thos associatd with procss agbras and functiona programming. W ha gin an oprationa smantics to µcml by xtnding it with nw constructs, most of which corrspond to constructs found in standard procss agbras. Ths incud a choic oprator, a para oprator and suitab rsions of input and output prfixing, (Minr, 989). Th prfixs in µcml c ha a sighty unusua syntax thir quiants in CCS ar gin as: CCS prfix µcml c quiant k?xd P k? x P k!d P k! x P D P A x P W now xamin th xtnt to which and act ik choic and para oprators from a procss agbras W can find bisimuations for th foowing (and hnc thy ar snsiti bisimiar): Λ 2 2 3 3 Thus satisfis many of th standard aws associatd with a para oprator in a procss agbra. Howr it is not in gnra symmtric bcaus of its intraction with th 2 2 3 3

28 W. Frrira, M. Hnnssy and A. S. A. Jffry production of aus: For xamp: Λ Λ Λ This mans that w can iw th para composition of procsss as bing of th form: i i whr th ordr of th i is unimportant. Not that it is important which is th right-most xprssion in a para composition, sinc it is th main thrad of computation, and so can rturn a au, which non of th othr xprssions can. Th choic oprator of µcml aso satisfis th xpctd aws from procss agbras, thos of a commutati monoid, athough it can ony b appid to guardd xprssions: Λ g g g 2 g 3 f g g g 2 g 3 g g 2 g 2 g This mans that w can iw th sum of guardd xprssions as bing of th form: i whr th ordr of th g i is unimportant. In fact guardd xprssions can b iwd in a mannr quit simiar to th sum forms usd in th dopmnt of th agbraic thory of CCS, (Minr, 989). W can find bisimuations for th foowing (and hnc thy ar snsiti bisimiar): g g 2 g x x A s g i g g s A x g 2 From this, w can show, by structura induction on syntax that a guardd xprssions ar of a gin form: g s i g i whr ach g i is ithr k i! i, k i? or A. From this and: i c δ c w can show that a aus? : A ar of th form: n DDD n n whr n is ithr k i i, k i, or. W coud continu in this mannr muating th agbraic thory of CCS, for xamp with xpansion thorms for guardd xprssions or aus of nt typ. Howr w a this for futur work.

A Thory of Wak Bisimuation for Cor CML 29 W now turn our attntion to µcml iwd as a functiona anguag. On woud not xpct β-rduction in its fu gnraity in a anguag with sid-ffcts such as µcml but w do obtain an appropriat ca-by-au rsion: y y W aso ha xpctd aws such as: y x y x x x f g x x y x y y f g whr x f g Th ast two quations ar of particuar intrst, sinc thy ar xacty th ft unit and associatiity axioms of th monadic mtaanguag (Moggi, 99). Th right unit quation: x x n is not so simp to show, and indd if wr an arbitrary abd transition systm thn it woud not b tru, as can b sn by: k! n k! x x Λ Λ Λ Λ (This is th sam xamp which maks SKIP not act as a right unit for squntia composition in CSP (Hoar, 985) and xit not act as a right unit for in LOTOS (ISO 8807, 989).) Fortunaty, w can show that our oprationa smantics for µcml satisfis four proprtis which aow us to show th right unit quation. A abd transition systm is sing-aud iff: if thn w Λ It is au dtrministic iff: if w thn w and

B B B 30 W. Frrira, M. Hnnssy and A. S. A. Jffry It is forward commutati iff: if α thn α α Not that sinc α may b an input mo, may b an opn trm, so w nd to tak th opn xtnsion of th trmination ration. It is backward commutati iff: if α thn α Not in particuar that LOTOS and CSP do not satisfy forward commutatiity, which is why thir squntia composition oprators do not ha a right unit. Howr, µcml dos satisfy ths conditions. Proposition 5. µcml satisfis sing-audnss, au dtrminacy, forward commutatiity and backward commutatiity. A routin induction on syntax. Th important proprty which such ts s satisfy is th foowing, whr w assum th xistnc of th oprator. Proposition 5.2 In any sing-aud, au dtrministic, forward commutati, backward commutati ts, if thn. Us th proprtis of th ts to stabish that th foowing is a first-ordr wak bisimuation: Th rsut foows. E As a coroary to this proposition, it is routin to show that th foowing is a first-ordr wak bisimuation: x x E So w ha th right unit quation w wr ooking for: x x Ths quations nab us to dfin a catgorica mod for µcml whr: Λ α E

A Thory of Wak Bisimuation for Cor CML 3 objcts ar typs, morphisms btwn A and B ar typd xprssions with on fr ariab x : A? : B, iwd up to wak bisimuation, th idntity morphism is x : A? x : A, and composition is x : A? : B ; y : B? f : C x : A? y f : C. Th quations for wak bisimuation discussd abo show that morphism composition is associati and has th idntity as both a ft unit and right unit. Thus µcml forms a catgory. Again w a th instigation of th proprtis of this catgory to futur work but w shoud point out that so far w ha bn unab to cast it as an instanc of gnra catgorica framwork of (Moggi, 99). 6 Comparing µcml and λ c In sction 2 w prsntd th oprationa smantics of a subst of CML, as a abd transition systm, in ordr that w might instigat its bhaioura proprtis. In this sction w sha mak a forma connction btwn this smantics and th rduction smantics for λ c prsntd in (Rppy, 992). W ha not considrd λ c in its ntirty and so th comparison wi b confind to th common subst, namy µcml c. W first rproduc, as faithfuy as possib, th rduction smantics of Rppy as it appis to µcml. From this rduction smantics w thn dri a abd transition systm for µcml xprssions and our main thorm stats that this abd transition systm (up to first-ordr wak bisimuation) is th sam as ours. In fact th mor tchnica rsuts w dri conncting th two smantics woud support a much cosr rationship but xprssing it woud ino doping yt anothr bisimuation basd quianc. Bfor prsnting th oprationa smantics and our main thorm w carify th diffrncs btwn λ c and µcml c : W do not considr th λ c constructs and. W conjctur that th oprationa smantics of µcml woud nd to b considraby atrd to cop with transating ths constructs. W omit th λ c construct sinc w cannot ncod uniqu chann nam gnration in µcml, athough it shoud not b difficut to add it using oprationa rus à a π-cacuus. Howr this woud rquir using a bisimuation simiar to Sangiorgi s (Sangiorgi, 992) contxt bisimuation for th highr-ordr π-cacuus. W ha addd rcursi function typs to µcml c bcaus in (Rppy, 992) rcursion is ncodd using procss cration and uniqu chann nam gnration. In λ c, constant functions such as ar aus, whr in µcml thy ha to b codd as x x. This rstriction has no ffct on th xprssi powr of µcml, and maks it simpr to rason about th oprationa smantics, sinc any au of typ A B must b of th form x y. W now prsnt Rppy s rduction smantics for µcml c. In (Rppy, 992) this is rprsntd by a transition ration btwn muti-sts of µcml c, or mor gnray λ c