A Semantic analysis of control

James David Laird

Doctor of Philosophy University of Edinburgh

Abstract

This thesis examines the use of denotational semantics to reason about control flow in sequential, basically functional languages. It extends recent work in game semantics, in which programs are interpreted as strategies for computation by interaction with an environment.

Abramsky has suggested that an intensional hierarchy of computational features such as state, and their fully abstract models, can be captured as violations of the constraints on strategies in the basic functional model. Non-local control flow is shown to fit into this framework as the violation of strong and weak ‘bracketing’ conditions, related to linear behaviour.

The language μPCF (Parigot’s λμ with constants and recursion) is adopted as a simple basis for higher-type, sequential computation with access to the flow of control. A simple operational semantics for both call-by-name and call-by-value evaluation is described. It is shown that dropping the bracketing condition on games models of PCF yields fully abstract models of μPCF.

The games models of μPCF are instances of a general construction based on a continuations monad on Fam(C), where C is a rational cartesian closed category with infinite products. Computational adequacy, definability and full abstraction can then be captured by simple axioms on C.

The fully abstract and universal models of μPCF are shown to have an effective presentation in the category of Berry-Curien sequential algorithms. There is further analysis of observational equivalence, in the form of a context lemma, and a characterization of the unique functor from the (initial) games model, which is an isomorphism on its (fully abstract) quotient. This establishes decidability of observational equivalence for finitary μPCF, contrasting with the undecidability of the analogous relation in pure PCF.

Acknowledgements

First and foremost, I wish to express my gratitude to my supervisor, Samson Abramsky. He has freely given the inspiration, good advice, criticism and encouragement which have enabled me not only to complete this thesis, but to enjoy it. His breadth of knowledge and enthusiasm have been particularly inspiring to me, as a newcomer to computer science.

The financial support for this thesis came from an Engineering and Physical Sciences Research Council studentship. It was typeset using L^{A}TEX 2ε.

The members of the Laboratory for Computer Science at Edinburgh have made it an intellectually stimulating, friendly, and well-supported working environment. Peter Hancock and Conor McBride have nobly tolerated the chaos in our office, but more importantly their company has often provided a welcome diversion from work. Thanks also to Jose Espirito Santo and John Longley for their comments.

Beyond Edinburgh, I am grateful for help, encouragement, and discussion from Pierre-Louis Curien, Hayo Thielecke, Paul Levy, Matthias Felleisen, and the members of the TCOOL project and Russ Harmer. Special thanks are due to Guy McCusker, whose friendship and advice has been very valuable.

The generosity of friends from Oxford and Haslemere has kept me going over some lean times. Most especially my family, — my mother and father and my sisters Becky and Alice have always given me any emotional and material support I have needed.

Declaration

I declare that this thesis was composed by myself and that the work contained therein is my own, except where explicitly stated otherwise in the text.

(James David Laird)

Table of Contents

List of Figures 4

Chapter 1 Introduction and Background 5 1.1 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.2 A complete analysis . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.3 Game semantics

and the intensional hierarchy . . . . . . . . . . . . . . . . . . . . . 9 1.4 The contents and contributions of the thesis . . . . . . . . . . . . 12

Chapter 2 Models of Control 14

2.1 The λ-calculus and its semantics . . . . . . . . . . . . . . . . . . . 14

2.1.1 Full abstraction in CCCs . . . . . . . . . . . . . . . . . . . 17 2.2 The fam(C) construction . . . . . . . . . . . . . . . . . . . . . . . 20

2.2.1 Strong Monads on fam(C) . . . . . . . . . . . . . . . . . . 22 2.2.2 Call-by-value and call-by-name semantics in fam(C) …. 24

2.3 Models of continuation-passing . . . . . . . . . . . . . . . . . . . . 26 2.3.1 The continuations monad . . . . . . . . . . . . . . . . . . 27 2.3.2 The continuations monad and other control models …. 30 2.3.3 Complete languages and models of control . . . . . . . . . 31

2.4 Models of programming languages . . . . . . . . . . . . . . . . . . 33 2.4.1 PCF and its semantics . . . . . . . . . . . . . . . . . . . . 34 2.4.2 Fully abstract models of PCF-based languages . . . . . . . 37

2.5 Models of PCF with control . . . . . . . . . . . . . . . . . . . . . 39

2.5.1 Universality . . . . . . . . . . . . . . . . . . . . . . . . . . 43 2.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

Chapter 3 Game semantics of control 46 3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 3.2 A basic framework for games . . . . . . . . . . . . . . . . . . . . . 47

3.2.1 Arenas and justified sequences . . . . . . . . . . . . . . . . 48

3.2.2 Constructions on arenas . . . . . . . . . . . . . . . . . . . 49 3.3 Rules and Games . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 3.4 ‘Linear’ Games . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

3.4.1 The linear exponentials . . . . . . . . . . . . . . . . . . . . 59 3.5 Two-player arenas . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 3.6 Views and innocence . . . . . . . . . . . . . . . . . . . . . . . . . 66

3.6.1 Innocent functions and strategies . . . . . . . . . . . . . . 68 3.7 The pointed CCC of games and innocent strategies is initial … 71

3.7.1 Characterizing the initial model . . . . . . . . . . . . . . . 72 3.7.2 Axioms for denotational completeness in models of control 74 3.7.3 Axiomatic decomposition . . . . . . . . . . . . . . . . . . . 78

3.8 The games models of control . . . . . . . . . . . . . . . . . . . . . 80 3.8.1 The unbracketed sum . . . . . . . . . . . . . . . . . . . . . 82 3.8.2 An alternative monad for control . . . . . . . . . . . . . . 83

3.9 Linearity and the bracketing condition . . . . . . . . . . . . . . . 88

Chapter 4 The syntax and semantics of μPCF 96 4.1 A minimal basis for computation . . . . . . . . . . . . . . . . . . 96 4.2 Representing functional control . . . . . . . . . . . . . . . . . . . 97

4.2.1 The λμ calculus: call-by-name and call-by-value . . . . . . 98 4.2.2 Sum types in λμ . . . . . . . . . . . . . . . . . . . . . . . 100 4.2.3 μPCF: variations on the control theme . . . . . . . . . . . 102

4.3 Operational Semantics . . . . . . . . . . . . . . . . . . . . . . . . 104 4.3.1 Expressing control in μPCF . . . . . . . . . . . . . . . . . 107 4.3.2 μPCF and SPCF . . . . . . . . . . . . . . . . . . . . . . . 109

4.4 Completeness of the operational semantics . . . . . . . . . . . . . 111 4.5 Denotational semantics of μPCF via cps translation . . . . . . . . 115

4.5.1 Continuation passing translation of μPCF_{n} . . . . . . . . . 116 4.6 Definability and full abstraction in μPCF_{n} . . . . . . . . . . . . . 120 4.7 Call-by-value: higher-order control . . . . . . . . . . . . . . . . . 123

4.7.1 Control in the computational lambda-calculus . . . . . . . 124 4.8 Relating λμ to λ_{c} via λ𝒞 . . . . . . . . . . . . . . . . . . . . . . . 126

4.8.1 The call-by-value de Groote Translation . . . . . . . . . . 127 4.8.2 Correctness of the translation . . . . . . . . . . . . . . . . 128

4.9 Completeness and full abstraction in μPCF_{v} . . . . . . . . . . . . 130 4.9.1 Control models of μPCF_{v} . . . . . . . . . . . . . . . . . . 133 Chapter 5 Analysis of the fully abstract model 138

5.1 Observational equivalence and control . . . . . . . . . . . . . . . . 139 5.1.1 A Context Lemma for μPCF . . . . . . . . . . . . . . . . . 140 5.1.2 Observational equivalence in the λ-calculus . . . . . . . . . 143

5.2 A sequential algorithms model of control . . . . . . . . . . . . . . 147 5.3 A fully abstract and universal model of μPCF . . . . . . . . . . . 155

5.3.1 The computable sequential algorithms . . . . . . . . . . . 155 5.3.2 Definability . . . . . . . . . . . . . . . . . . . . . . . . . . 157 5.3.3 Decomposition of escaping strategies . . . . . . . . . . . . 160

5.4 Relating models of control . . . . . . . . . . . . . . . . . . . . . . 163 5.4.1 The collapse of innocent strategies . . . . . . . . . . . . . 164 5.4.2 Mapping sequential algorithms to innocent strategies … 169

Chapter 6 Conclusions 178 6.1 Further Directions . . . . . . . . . . . . . . . . . . . . . . . . . . 179

Bibliography 182

List of Figures

1.1 Syntactic Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.2 Semantic hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2.1 Defining equations of a monad . . . . . . . . . . . . . . . . . . . . 22 2.2 Definition of ψ_{A,B} . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 2.3 Term formation and semantics for λ_{c}(Ω) . . . . . . . . . . . . . . 26 2.4 Terms of PCF in contexts, with a call-by-name interpretation . . 35

3.1 Linearization of head occurrence . . . . . . . . . . . . . . . . . . . 77 3.2 Decomposition of an innocent strategy . . . . . . . . . . . . . . . 79 3.3 Linear decompositions of classical and intuitionistic types . . . . . 81 3.4 The strategy peirce_{A}^{n} . . . . . . . . . . . . . . . . . . . . . . . . 84 3.5 Contrasting plays in the different sum games . . . . . . . . . . . . 84 3.6 A typical play of peirce^{n} at atomic types . . . . . . . . . . . . . 86 3.7 A sequence violating the bracketing condition . . . . . . . . . . . 90

4.1 Terms-in-context of the λμ calculus . . . . . . . . . . . . . . . . . 98 4.2 One-step operational semantics of μPCF . . . . . . . . . . . . . . 106 4.3 Equational theory in λ_{c} . . . . . . . . . . . . . . . . . . . . . . . . 124

5.1 Relationship of three models of call-by-name PCF . . . . . . . . . 147 5.2 Plays in dialogue games and sequential algorithms !s . . . . . . . 152 5.3 Contrasting plays for computing f (f 0) . . . . . . . . . . . . . . 154 5.4 ‘Partiality factorization’ . . . . . . . . . . . . . . . . . . . . . . . 159 5.5 Copy-removing translation applied to λf.f f 0 . . . . . . . . . . . 170 5.6 Translation from sequential algorithm to innocent strategy …. 171 5.7 Copy saturating translation of λf.f f 0 . . . . . . . . . . . . . . . 173

Chapter 1

Introduction and Background

1.1 Control

This thesis is a study of sequential computation based on the ‘flow of control’; essentially the order in which programs are evaluated. This is a pervasive and expressive notion, as complex sequential computations are invariably performed as a series of interdependent processes. Indeed these steps can be so trivial that the only substantive information contained in the program is contained in the flow of control.

Data can be represented intensionally using control, a fact which has been known since the definition of the Church numerals. As a minimal example, the element tt in the domain of booleans, tt + ff, is represented by passing control to tt, and stopping.

Functional programs A functional program of type A ⇒ B can be considered as a way of passing control between the ‘argument’ A and the ‘result’ B. Control flow dictates whether this is done in a ‘demand driven’ or ‘data driven’ way [73].

Control operators Purely functional programs have a natural order of evaluation; they exhibit only ‘local control flow’. Only the most recently scheduled task can be completed and so every subprocess which has been started must be completed (in reverse order) before a result is returned, even if an error has been encountered. This leads to obvious inefficiencies. The solution is to include explicit operators giving programs internal ‘access to the flow of control’. These range from the brutal GOTO, to more elegant exception handling mechanisms.

Proofs of classical logic It was observed by Griffin [32], that Felleisen’s control operator C can be typed as a rule of classical logic, and that its computational rules correspond to normalization of classical proofs. Similarly, Parigot’s λμ [69], a term-language for classical proofs, can be used as a calculus of control. That is the context in which λμ appears in this thesis, but the possibility of using games as a fully complete semantics for constructive classical logic remains a tantalizing prospect (discussed further in Section 6.1).

An important concept used to formalize these ideas is that of continuation passing. A continuation is a completion of a program; the evaluation which remains to be done before a result can be returned. Hence it can be represented as a map from the current ‘control point’ to a conclusion. Computation can be performed by continuation passing between parts of the program; in purely functional programs with local control flow, this corresponds to performing the next task scheduled by the continuation, and passing it on. However, if continuations are ‘first class objects’ they can be stored, discarded and substituted, causing jumps in the flow of control. Syntactically, this gives a ‘continuation-passing-style’ (cps) translation from functional languages with control operators and data, to a much simpler functional language representing only control flow.

The discovery of continuation passing was a seminal event; for the first time control was given its own semantic representation. In fact (as so often), it was not the result of a single inspiration, but a process of enlightenment. In the conclusion of a survey by Reynolds [77]:

“... continuations or closely related concepts were first discovered in 1964 by van Wijngaarden, repeatedly discovered in a wide variety of settings — both intellectual and geographical — during 1970-71, and occasionally rediscovered thereafter.”

Control was placed in the context of other computational features by the work of Moggi [62], showing that continuation passing (along with many side effects) could be represented (and reasoned about) as a monad. More recent work by Thielecke [82] and others has further abstracted the notion of continuation passing, giving it an elegant basis in premonoidal categories [74].

The use of first class continuations as ‘control points’ in functional programs which can be manipulated like ordinary variables can be represented syntactically using the control operator call-with-current-continuation, or call/cc. This originated in the language Scheme [17], (following other, similar, constructs such as Landin’s J-operator [50]). It can be used both for simple ‘escapes’ from nested computations, and to manipulate the flow of control in more subtle and complex ways; for instance to write coroutines [37]. Subsequent work on formalizing control operators (for instance, by Felleisen and co-workers [25]), has resulted in a range of ‘idealized’ control constructs. The approach taken here (advocated by Ong and Stewart [67]) is to adopt the λμ-calculus, and a programming language based on it, as a convenient syntax into which other control operators can be translated.

Although control is a useful paradigm for understanding several aspects of computation, it is non-local control flow which requires a specifically controlbased analysis. Thus, modelling this behaviour and relating it to the operational semantics of control operators is the main feature of this thesis. However, the intention is to study control within a realistic computational framework so it has been necessary to synthesize the work on the semantics of control calculi and PCF, to show how a few basic notions; cartesian closure, infinite products and recursion, can be the basis of a more structured model of computation. A semantics for a similar language was considered by Sitaram and Felleisen [80], however, it contained parallel features; this thesis is an analysis of feasible, sequential control.

1.2 A complete analysis

The investigation is grounded in categorical, syntactic and denotational characterizations of control, via continuation passing models, μPCF, and the bracketing condition of game semantics. None of these can be considered definitive, but by finding isomorphisms between syntax and semantics, a coherent analysis emerges, based on soundness, and the following completeness properties.

Categorical completeness: Purely categorical and syntactic reasoning can be used to show that the representation of functional languages with control operators via continuation passing is complete as well as sound; that the definable part of all models of PCF+call/cc arise in this way from a cartesian closed category (so the cps translation is invertible). This notion of completeness of models of control was considered by Hofmann, [39] for Felleisen’s ‘𝒞 operator’ [25], with subsequent work on λμ by Hofmann and Streicher [40] and Selinger [79].

Denotational completeness: Completeness results of the above kind can be used to show that one form of syntax (or categorical construction) can be represented by another. A complete semantics of programming benefits from a more abstract denotational description of control in order to give a natural interpretation of infinitary features such as recursion. Denotational completeness can also lead to enhanced understanding of the processes at work in computation. But semantics of this kind can still be given formal, categorical characterizations. In particular, there is the possibility of giving an axiomatic description along the lines of Abramsky’s ‘Axioms for full abstraction’ [1].

Full abstraction: This is the natural notion of completeness for models of programming languages, based not on what is representable in the language, but on what is distinguishable. The evaluation of programs induces a notion of observational equivalence between them.

Definition 1.2.1 [Full Abstraction [60]] Given a language L with an operational semantics giving a notion of termination ⇓, an observational equivalence can be defined: M ≃ N if (C[M] ⇓ ⟺ C[N] ⇓) for every program-context C[·] which accepts M and N. A semantics is equationally fully abstract if observable equivalence and denotational equivalence define the same relation, i.e. [[M]] = [[N]] if and only if M ≃ N.

To define an operational semantics requires some notion of control behaviour, but observational equivalence ‘bootstraps’ this to a powerful and precise theory. There are many alternative axiomatizations of control operators such as call/cc which are sound with respect to the operational semantics, for instance, but the theory of observational equivalence induced by it is unique. A ‘truly denotational’ and complete model of this theory should therefore constitute a powerful analysis of control.

It is certainly the case that the search for a fully abstract model for PCF, from which this study borrows much of its motivation, has generated several important insights into the semantics of functional languages, starting from the original observation by Plotkin [71] that full abstraction fails for the Scott continuous functional model of PCF because of the presence of parallel elements. (The problem with the Sitaram and Felleisen model of control [80] is essentially the same, but it also contains sequential as well as parallel ‘junk’.) Construction of fully abstract models can be performed solely by syntactic and categorical methods, as shown in the case of PCF by Milner [61]. To move beyond a ‘superficial’ analysis, therefore, additional conditions can be applied, — that the presentation of the model be denotational, or syntax-independent, and (the ‘Jung and Stoughton criterion’ [44]) that it should also be effective. The existence of such a semantics of μPCF is made more significant by the fact that, following a result of Loader [54], there can be no effectively presentable fully abstract model of PCF.

An important precursor to this thesis came from the observation of Cartwright and Felleisen [15] that as well as being important programming features, control operators make the intensional behavour of programs explict. This makes a fully abstract model a realizable aim. They gave a fully abstract semantics to a language called SPCF which extends PCF with control features: errors, and a form of catch operator. Their SPCF semantics was subsequently shown (with Curien) to be equivalent to a presentation using sequential algorithms [16]. Their work is developed here, connecting the sequential algorithms interpreattation of control flow and control operators to the more general notion of continuation-passing, to the less toy-like control operator (call-by-value) call/cc and to the local control flow of the games models of PCF.

1.3 Game semantics and the intensional hierarchy

Given the categorical completeness result described above, one could argue that the semantics of control is, in effect, the semantics of cartesian closed categories. Indeed, this proves to be a useful simplification of the proofs of denotational definability and full abstraction. However, this reductionist approach can be compared to that of a naturalist who never leaves the laboratory. He has a profound knowledge of the anatomy and genetics of his chosen species, but no understanding at all of their behaviour and place in the environment. Similarly, a significant part of the analysis of control is contextual, — for instance

• what is local control flow ?

• how does state interact with control ?

There is also a tension between full abstraction and this need for a broader perspective embracing other computational effects: a semantics in which objects are identified up to observational equivalence cannot be naturally extended with more expressive features. (As this would allow observationally equivalent objects to be distinguished.)

The outline of a solution can be found in the ‘intensional hierarchy’ proposed by Abramsky; a sound, complete and universal semantic characterization of computation. It is grounded in game semantics, in which functional-based computation is modelled by interaction of certain ‘typed processes’, or strategies,

[figure: \begin{matrix}2^{nd} \\ order \end{matrix}; Higher type references; Exceptions; Prompts; \begin{matrix}1^{st} \\ order \end{matrix}; Ground-type references; none; Functional languages; catch, ; callcc_{n}; call/cc_{v}; state; non-local; control; none; \begin{matrix}1^{st} \\ order \end{matrix}; \begin{matrix}2^{nd} \\ order \end{matrix}]

Figure 1.1: The syntactic hierarchy: Expressivity of various programming language features

[figure: Visibility free; SML; Scheme SML-nj; Innocence free; Idealized Algol; Innocence; \begin{matrix}PCF_{n} \\ PCF_{v} \end{matrix}; \begin{matrix}SPCF, \\ μPCF_{n} \end{matrix}; μPCF_{v}; history sensitivity; well bracketed; weakly bracketed; unbracketed; factorizations; linearity]

Figure 1.2: The Semantic Hierarchy: Constraints and fully abstract models corresponding to the syntactic hierarchy for computation. This paradigm can be used to give semantics to a wide variety of computational effects in a coherent way. It can be represented graphically as a partial ordering with syntactic and semantic reflections as in fig. 1.1

vertices correspond semantically to a combination of constraints on the behaviours of strategies, and syntactically, to a ‘function (PCF)-based language’ which can be given a fully abstract model in the semantic category by a semantic collapse; characterizing this collapse is thus the problem of determining observational equivalence in the language. In particular, state and control occupy orthogonal ‘axes’ of the hierarchy, of which state corresponds to restrictions on sharing of information — the amount of access of a strategy to the history of the game, and control corresponds to restrictions on copying of requests for information. In both cases this basic picture has been refined by showing that there are several ‘degrees of freedom’ with computational meaning along each axis.

edges are bidirectional:

one direction corresponding to the embedding of the more constrained model in the more general one, the other corresponding to a ‘factorization’ of the more liberated strategies. This shows that they can be represented by composition with some characteristic group of unconstrained strategies denoting a new feature such as control operators. It is the key lemma in a full abstraction theorem binding syntax and semantics together, and building on the basic result for PCF.

The intensional hierarchy developed from the models described by Abramsky, Jagadeesan and Malacaria [6], Hyland and Ong [43], and Nickau [65] which appeared, more-or-less simultaneously, as a solution to the full abstraction problem for PCF. The AJM work used ideas from the Geometry of Interaction [30], and the game semantics of Blass [13], whilst the Hyland-Ong approach grew from the work of Lorenzen [57] and subsequent researchers, which used games to study the semantics of logic (Felscher’s paper [26] is a useful survey). Subsequent developments include games for recursive types [59], call-by-value [3], and games models of state[2], and higher-type references [4].

A connection between games and control is in any case a natural step; both are offered as paradigms for explaining a variety of computational features, modelled intensionally. More specifically, sequential games are represented as the passing of a token between two participants, this can be thought of as the system interacting with the environment (or the system interacting with the current continuation).

Such plays are a concrete representation of the history of the control flow in the computation, moreover this is the only information which is carried by plays, confirming the expressive power of control. The games models of PCF showed that it is possible to capture local control by labelling moves as questions and answers, and imposing a ‘well-bracketing’ constraint. This condition requires that processes must be terminated in the reverse order to which they were initiated. Implicit in the definition of well-bracketing is the notion which is analysed here, that access to the flow of control is gained by dropping this condition. It is a possibility which has also been studied by Herbelin [38], as well as in previous work by the author [48]. Here it is developed, and the relationship with continuation passing studied in detail.

1.4 The contents and contributions of the thesis

Chapter 2 is a more technical introductory chapter, combining material on categorical models of continuation passing, and PCF and its extensions with computational effects. This becomes a basis for a more detailed programme of analysis into the denotational and operational semantics of control, which is summarised in Section 2.6, and pursued in the succeeding three chapters.

Chapter 3 is about game semantics. It describes a novel development of the intensional hierarchy, based on the specification of games by the application of rules to arenas. A ‘linear decomposition’ of this category is described, which allows the construction of a cartesian closed category in a manner consistent with different combinations of rules (allowing, for instance, the modelling of references in the style of [4] in this setting). A generalized axiomatic decomposition which applies to the category of games and innocent strategies extends some results of Abramsky by giving both a soundness and a full completeness result for this category as a model of control calculi. The modelling of local and non-local control flow in games via ‘bracketing rules’ is analyzed. It is shown that the result of dropping this condition on the models of PCF (and imperative extensions) can be represented as a continuation passing semantics. Also, there are strong and weak versions of the bracketing condition, with violation corresponding to ‘first-order’ use of control operators (escapes and exceptions) and ‘second-order’ (‘upward continuation passing’).

Chapter 4 is a study of the operational and denotational semantics of the ‘functional language with control’, μPCF. A new, simplified, one-step operational semantics of call-by-name and call-by-value μPCF is given, and a general description of computationally adequate models with respect to this semantics is described and verified. Existing continuation passing translations for control calculi are extended to μPCF. In particular, this entails giving a new cps-based interpretation of datatypes such as the natural numbers. Because these translations are surjective, the axiomatic definability results for models of the λ-calculus can be applied to the semantics obtained by dropping the bracketing condition on the original games models of PCF. In the case of the call-by-value calculus, a metalanguage based on the computational lambda-calculus is used to show soundness of the model (by showing that the ‘deGroote translation’ into λ𝒞 is sound and complete in this case, pace call-by-name).

Chapter 5 is an analysis of the fully abstract model, and its effective presentation in the category of sequential algorithms. The definability result from the previous chapter is used to derive context lemmas for μPCF and these, together with the continuation-passing-style translations already given are shown to have a number of straightforward but significant consequences. For instance, this yields a way to model call-by-value languages using sequential algorithms for the first time. It is also observed that the fact that the fully abstract model is effectively presentable (in contrast to PCF) means that it yields a semantic characterization of the ‘minimal model’ of the λ-calculus [68], and hence a solution to a part of the higher-order matching problem. Extending full abstraction, universality is proved, the first example of a universal model of this kind of language without error terms. The relationship between the two fully abstract models is then investigated. The most significant findings are translations between the two models which capture observational equivalence semantically. One removes repeated queries from innocent strategies, mapping observationally equivalent elements to the unique sequential algorithm denoted by the same lambda terms. The other saturates sequential algorithms with repeated queries, sending each one to a innocent strategy representing a ‘normal form’ for its observational equivalence class.

Models of Control

This chapter consists of background on the semantics of functional based languages in general, and continuation passing models of functional control in particular. A semantic basis for the ‘intensional hierarchy’ is given, embracing callby-name and call-by-value evaluation, and side-effects via computational monads. Control is, of course, the specific example of a non-functional feature which will be studied semantically. The construction of simple computational ‘models of control’ is described, together with conditions for full abstraction to hold. In doing so, a series of problems of denotational and operational semantics emerge, and these are distilled to give the outline of an analysis of the semantics of control. Much of the following material is standard, and the proofs are correspondingly sketchy.

2.1 The λ-calculus and its semantics

The simply-typed λ-calculus and its semantics have two distinct rôles in this thesis. One is as the basis of functional programming languages, extended with non-functional features in general, and control operators in particular. Its other rôle (specific to control) is as the target language for continuation-passing-style translations. In other words, the simply typed λ-calculus without values is used as a low-level language into which languages with control can be compiled. An important observation showing the suitability of the λ-calculus for this second purpose is that the translations are in several senses complete, — in appropriate circumstances they will be invertible, or at least surjective. There are, therefore, associated isomorphisms between models of these languages. This means that many problems in the semantics of control (such as full abstraction) can be reduced to analogous, but more simply stated problems in the semantics of the λ-calculus. Accordingly, some of these problems and associated notions are reviewed here, although as cartesian closure, the λ-calculus and the connections between them, are now standard, the reader is referred to e.g. Lambek and Scott [49] for background on semantics, and Barendregt [8] for syntax.

The main distinguishing feature of the models of control considered here (as opposed to [39], [79] etc.) is that they include a notion of partiality ab initio, as the intention is to model programming languages in which there is a possibility of non-termination. (Extension to infinitary types and fixpoints can be added later (see Section 2.5) as a natural procedure of chain completion.) Following Braüner [14], and [1], the basic notion used is the ⊥-map.

Definition 2.1.1 A category C has ⊥-maps if every hom-set C(A, B) contains a distinguished morphism ⊥_{A,B} such that for every f : C → A, f; ⊥_{A,B} = ⊥_{C,B}.

If C has a terminal object, then ⊥-maps can be specified by giving only the morphisms ⊥_{A} = ⊥_{1,A} and letting ⊥_{A,B} = t_{A}; ⊥_{B}.

In particular, the models of control boil down to a continuation passing construction applied to a cartesian closed category with ⊥-maps.

Definition 2.1.2 Define a pointed cartesian closed category to be a CCC with ⊥-maps such that for all objects A, B, ⊥_{A×B} = ⟨⊥_{A}, ⊥_{B}⟩, and ⊥_{A⇒B} = Λ(⊥_{A,B}).

⊥-maps can be used to define the useful notion of strictness.

Definition 2.1.3 In a category C with ⊥-maps, the strict maps are morphisms f : A → B such that ⊥_{A}; f = ⊥_{B}. Hence id_{A}, and ⊥_{A,B} are always strict, and the composition of strict maps is strict, so the strict morphisms form a subcategory of C, written C_{S} (as in [1]).

As the pointed CCCs used here will be generated over a set of base type-objects S, ⊥-maps need be specified only at base type, defining ⊥_{A⇒B} = ‘⊥_{A,B}’. In fact, any CCC gives rise to a pointed CCC of this sort, by adding partiality at ‘ground type’ by freely adjoining a product of the objects in S to the domain of each morphism in C.

Proposition 2.1.4 Let C be a cartesian closed category, with non-terminal objects freely generated from some finite set S = {s_{1}, s_{2}, … s_{n}} by ×, ⇒. Then there is a pointed cartesian closed category C_{⊥}, with the same objects as C, and morphisms C_{⊥}(A, B) = C(A × (s_{1} × … × s_{n}), B).

Proof: C_{⊥} is the co-Kleisli category of the co-monad × (s_{1} × … s_{n}) : C → C, which sends f : A → B to f × id_{(s_{1}×...s_{n})} with canonical natural transformations π_{1}^{A} : A × (s_{1} × … s_{n}) → A, and id_{A} × ⟨id, id⟩ : A × (s_{1} × … s_{n}) × (s_{1} × … s_{n}) → A × (s_{1} × … s_{n}). For each base object s_{i}, there is a ⊥-map, ⊥_{s_{i}} = π_{2}; π_{i}. □

Although partiality will not be modelled in this way in the setting of game semantics (as it proves to be more basic than totality) this will be a useful way of adding distinct ‘error elements’ to a CCC.

Definition 2.1.5 For any set S, the free pointed CCC over S is the initial object in the category of pointed CCCs whose objects include those of S, and functors which preserve ⊥-maps and the universal properties of the terminal object, product and exponentials. As in the case of the free CCC [49], it can be constructed as the category in which objects are freely generated from {S}∪{1}, with the constructors × and ⇒, and morphisms are freely generated from {⊥_{x} | x ∈ S}, {id_{x} | x ∈ S}, and the terminal morphisms t : 1 → A for each object, by forming products, λ-abstractions and applications, and equated modulo the universal properties for these operations.

Theorem 2.1.6 The free pointed CCC over S is well-defined and initial in the category of pointed cartesian closed categories and structure-preserving functors.

Proof: is by minor adaptation of the proof given in Lambek and Scott [49] to cover ⊥-maps. □

The analogous extension of the λ-calculus with constants for non-termination is straightforward.

Definition 2.1.7 Following Barendregt, [8] define Λ(Ω)_{S} to be the simply-typed λ-calculus over the base types S, together with constants Ω^{S} : S for non-termination at each base type. The equational theory of Λ(Ω) is (the compatible closure of) βη equality.

Λ(Ω) has an obvious interpretation in a pointed CCC by fixing the base typeobjects, and setting [[Ω^{S}]] = ⊥_{[[S]]}. That pointed CCCs are canonical models of Λ(Ω) can be expressed by observing that the theory of Λ(Ω) is sound and complete for pointed CCCs.

Definition 2.1.8 (Sound and complete theory of Λ(Ω)) An equational theory T of Λ(Ω) is:

• sound with respect to interpretation in pointed CCCs, if every equation in T is valid in every model, — i.e. For all terms s, t of the same type, s =_{T} t implies that in any pointed CCC, C, [[s]]_{C} = [[t]]_{C}.

• complete if every equation which is valid in every pointed CCC is in T, — i.e. if [[s]]_{C} = [[t]]_{C} in every model, then s =_{T} t.

Proposition 2.1.9 The Λ(Ω)-theory (βη) is sound and complete for pointed CCCs.

Proof: is by minor adaptation of the proof of [49]. □

By observing that there is a bijective correspondance between terms-in-context Γ ⊢ t of Λ(Ω), and terms-in-context of the simply-typed λ-calculus with an additional, non-clashing free-variable, x substituted for Ω in t, it can be shown that:

Proposition 2.1.10 If C is (isomorphic to) the free CCC over S, then C_{⊥} is isomorphic to the free pointed CCC over S.

Attention will henceforth be restricted to the λ-calculus with a single base type, ι. Models of this calculus will be given as a pair (C, a) where C is a pointed CCC C and a is a (non-terminal) object C interpreting ι.

2.1.1 Full abstraction in CCCs

A second ‘canonical’ example of a pointed CCC will also prove to be central to the discussion of fully abstract models of control. This is the ‘fully abstract’ model of Λ(Ω), where the relevant observational equivalence (of Definition 1.2.1) is defined with respect to ‘termination’ at the function type ι ⇒ ι. (A Λ(Ω) term of this type is said to terminate if it is βη-equivalent to λx.x.)

Definition 2.1.11 Define the following congruence on terms of Λ(Ω): s : T ≃_{T} t : T if for all contexts C[· : T] : ι ⇒ ι,

C[s] =_{βη} C[t]

(And s ⊑_{T}^{OBS} t if for all contexts, C[· : T] : ι ⇒ ι]: C[s] =_{βη} λx.x implies C[t] =_{βη} λx.x) A model of M of Λ(Ω) is fully abstract if [[s]]_{M} = [[t]]_{M} if and only if s ≃ t.

The semantic counterpart to this notion of observational order and equivalence on a pointed cartesian closed category is its intrinsic preorder. In a pointed CCC with non-⊥ morphisms, the elements in a ⇒ a which are definable (denotations of Λ(Ω)-terms) form a ‘Sierpinski space’ — i.e. a pointed two element set.

Definition 2.1.12 (Intrinsic preorder and equivalence) Let (C, a) be a model of Λ(Ω). Writing ‘f’ : 1 → A ⇒ B for the ‘name of f : A → B’, and f ↓ for f ≠ ⊥, define the following preorder and equivalence relation on the hom-sets of (C, a).

f ≲_{A→B} g ⟺ ∀h: A ⇒ B → (a ⇒ a) : (‘f’; h ↓) ⇒ (‘g’; h ↓).
f ≡_{A→B} g ⟺ (f ≲_{A→B} g) ∧ (g ≲_{A→B} f).

The intrinsic equivalence and preorder preserves the categorical structure of a model of control.

Proposition 2.1.13 For any pointed CCC C, ≡ is a congruence on the hom-sets of C, — i.e. the following conditions hold.

i f ≡_{A→B} f′ and g ≡_{B→C} g′ implies f; g ≡_{A→C} f′; g′.

ii f ≡_{C→A} f′ and g ≡_{C→B} g′ implies ⟨f, g⟩ ≡_{C→A×B} ⟨f′, g′⟩

iii f ≡_{A×B→C} f′ implies Λ(f) ≡_{A→(B⇒C)}

(Similarly, the preorder ≲ is a pre-congruence, — a preorder satisfying the above conditions.)

Proof: is straightforward (see [6]). □

This ‘higher-type’ notion of observational equivalence is the strongest non-trivial congruence on a pointed CCC.

Proposition 2.1.14 If ≏ is a congruence on terms of Λ(Ω) properly extending ≃, then it is the trivial equivalence which holds between all terms.

Proof: Suppose ≏ is a compatible relation on terms properly extending ≃. Then there are terms a, b : T such that a ≏ b but there is a term f : T ⇒ (ι ⇒ ι) such that (w.l.o.g.) f a =_{βη} λx.x and f b =_{βη} λx.Ω. So λx.x ≏ λx.Ω, and given any t : \overline{S} ⇒ ι, t =_{βη} λ\overline{w}.(λx.x) (t \overline{w}) ≏ λ\overline{w}.(λx.Ω) (t \overline{w}) =_{βη} λ\overline{w}.Ω. i.e. every term at each type is congruent to Ω. □

A fully abstract model of Λ(Ω) can be derived by the quotient construction from any non-trivial pointed CCC in which every morphism is the denotation of a Λ(Ω)-term) by ‘collapsing under the intrinsic equivalence’. This is a simplified version of the construction of the fully abstract models of PCF in [6], [43].

Proposition 2.1.15 Suppose C is a pointed CCC with a congruence ≡. Then the category C/ ≡ with the objects of C, and the equivalence classes of ≡ as morphisms between them, is a pointed CCC (with ⊥-maps given by [⊥_{A,B}]).

Proof: is direct by the fact that ≡ is a congruence. □

Corollary 2.1.16 Suppose C is isomorphic to the free pointed CCC over a, then (C/ ≡, a) is a fully abstract model of Λ(Ω).

In particular, this means that a syntax-free characterization of the free pointed CCC gives rise automatically to a syntax independent presentation of the fully abstract model of Λ(Ω). However, effectiveness of the presentation is not guaranteed (for a formal presentation of this notion, see [70]). Indeed it is impossible in the analogous case of finitary PCF, as Loader’s result shows [54]. As in PCF, the problem boils down to decidability of observational equivalence.

Proposition 2.1.17 The fully abstract model of Λ(Ω) is effectively presentable if and only if ≃ is decidable.

Proof: If the fully abstract model is effectively presentable then ≃ is decidable by comparing denotations of λ-terms. Conversely, suppose ≃ is decidable. The free pointed CCC is certainly effectively presentable as the βη-long normal forms of Λ(Ω). The intrinsic collapse of this model can then be effectively presented by recursively enumerating a series of unique representatives of each equivalence class at each type, using decidability of ≃ to discard equivalent terms. The canonical operations on the CCC, such as application, are clearly also effective by decidability of ≃. □

It will be shown in Chapter 5 that decidability of ≃ is a corollary of decidability of observational equivalence in the λ-calculus with two constants (in fact, the problems are equivalent) which has been shown by Padovani [68]. However, the goal of that chapter is a construction of the fully abstract model (and an infinitary extension) which is both syntax-independent and effective. These properties can be combined in a purely semantic and ‘local’ characterization of observational equivalence, through the observation that the unique functor ϕ from the initial to the fully abstract CCC has (by definition) the property that

ϕ(e_{1}) = ϕ(e_{2}) ⟺ e_{1} ≡ e_{2}.

Hence a semantic solution of the observational equivalence and effective presentability problems can be found by giving an effective syntax-free characterization of the functor between the initial and fully abstract models.

2.2 The fam(C) construction

In order to interpret datatypes in a programming language, some notion of sums will be required in the semantics. These will be obtained via the action of a strong monad (of continuations) on a category with co-products. The latter are incompatible with pointedness in a CCC. However, it is not necessary to define new categories of ‘predomains’ concretely, to extend the full completeness and full abstraction results. The process of freely constructing co-products from an arbitrary category (the ‘co-product completion’) can be described in a syntax-independent way, as a category of indexed families of objects and fibred morphisms of C. Distributivity, and duality of products and co-products, then allows cartesian closure to be extended to the category fam(C).

The category of indexed families of games was first used to construct a fully abstract semantics of call-by-value languages by Abramsky and McCusker [3]. In this work, it was presented as a general method of obtaining a call-by-value semantics from a call-by-name one, given the basic ingredients of a pointed order enriched cartesian closed category, (from which a bicartesian closed category of ‘predomains’, fam(C), can be constructed) and a weak co-product on C (which yields a strong monad on fam(C)). Their claim, that it is a broadly applicable way to transfer full abstraction results from call-by-name to call-by-value, is supported by a growing body of evidence. It has been applied to well-bracketed games and innocent and history-sensitive strategies in [3], and visibility-free strategies in [4], with fully abstract models of call-by-value PCF (an alternative presentation of Honda and Yoshida’s [41]), and function-based languages with references being found as a result.

In this thesis, however, it seems appropriate to take a slightly different perspective. In fact, both call-by-name and call-by-value semantics can be interpreted in fam(C); the interpretation of sum types in the call-by-name semantics being weak, distributive co-products derived from a strong monad (rather than obtaining a strong monad from a weak co-product). This description seems particularly suited to the semantics of control, in which both call-by-name and call-by-value semantics can be given by continuation-passing-style translations based on a single strong monad on a bicartesian closed category.

Definition 2.2.1 Given a category C, form the category fam(C); the free completion of C with respect to co-products having

• as Objects, families of objects of C indexed over finite sets.

• as Morphisms from {A_{i} | i ∈ I} to {B_{j} | j ∈ J}, a pair consisting of a reindexing function f : I → J and a family of morphisms ϕ_{i} : A_{i} → B_{fi} in C, indexed over the source family: i.e. fam(C)({A_{i} | i ∈ I}, {B_{j} | j ∈ J}) = {⟨f, {ϕ_{i} | i ∈ I}⟩ | ϕ_{i} ∈ C(A_{i}, B_{f(i)}), f : I → J}.

Without making any demands of C, it is immediate that fam(C) has an initial object, the empty family {}, and more generally:

Proposition 2.2.2 fam(C) has all finite co-products.

Proof:

{A_{i} | i ∈ I} + {B_{j} | j ∈ J} = {C_{k} | k ∈ I + J}

where C_{i} = A_{i} for i ∈ I, and C_{j} = B_{j} for j ∈ J. □

Proposition 2.2.3 If C is cartesian closed, then fam(C) is cartesian closed.

Proof: Definition 2.2.4 Products:

{A_{i} | i ∈ I} × {B_{j} | j ∈ J} = {A_{i} × B_{j} | ⟨i, j⟩ ∈ I × J}.

The terminal object is the singleton family {1} containing the terminal object of C. The operation of exponentiation simply forms a family indexed over functions from I to J, where the object indexed by f is the product of the exponentials A_{i} ⇒ B_{f_{i}} indexed over i ∈ I.

Definition 2.2.5 Exponentials:

{A_{i} | i ∈ I} ⇒ {B_{j} | j ∈ J} = {Π_{i∈I}(A_{i} ⇒ B_{f(i)}) | f ∈ J^{I}}.
□

If C is (continuous) partial-order enriched, then so is fam(C): ⟨f, {ϕ_{i} | i ∈ I}⟩ ≤ ⟨g, {ψ_{i} | i ∈ I}⟩ if f = g and ∀i ∈ I : ϕ_{i} ≤ ψ_{i}. Pointedness of the ordering (⊥-maps), however, is not preserved.

2.2.1 Strong Monads on fam(C)

Computational monads, as introduced by E. Moggi [62] can now be employed to obtain call-by-name and call-by-value semantics from fam(C). As this is a well established notion, only a few facts are recalled here; for further details see [64].

Definition 2.2.6 A strong monad on a category C with cartesian products and ⊥-maps is specified by a quadruple T, η, μ, t (Kleisli triple with tensorial strength t) where:

\xymatrix{T^{3}A \ar[r]^{μ_{T A}} \ar[d]_{T μ_{A}} & T^{2}A \ar[d]^{μ_{A}} & T A \ar[r]^{η_{T A}} \ar[dr]_{id_{T A}} & T^{2}A \ar[d]^{μ_{A}} & T A \ar[l]_{T η_{A}} \ar[dl]^{id_{T A}} \\ T^{2}A \ar[r]_{μ_{A}} & T A &  & T A}

Figure 2.1: Defining equations of a monad

• T : C → C is a functor giving the appropriate structure for the ‘notion of computation’,

• η: 1 → T is a natural transformation giving the inclusion of elements of C as values (i.e. fully computed elements) which are trivial computations,

• μ: T^{2} → T is a natural transformation which ‘computes’ the computation of a computation,

• t_{A,B}: A × TB → (TA × TB) is a tensorial strength. (A natural transformation such that the following diagrams commute):

\xymatrix{A × B \ar[rr]^{id_{A×B}} \ar[d]_{id_{A}×η_{B}} &  & A × B \ar[d]^{η_{A×B}} & 1 × TA \ar[r]^{t_{1,A}} \ar[dr]_{u_{TA}} & T(1 × A) \ar[d]^{Tu_{A}} \\ A × T B \ar[rr]^{t_{A,B}} &  & T (A × B) &  & TA \\ A × T^{2}B \ar[u]^{id_{A}×μ_{B}} \ar[r]_{t_{A,T B}} & T (A × T B) \ar[r]_{T t_{A,B}} & T^{2}(A × B) \ar[u]_{μ_{A×B}}}

\xymatrix{(A × B) × TC \ar[rr]^{t_{A×B,C}} \ar[d]_{ass_{A,B,TC}} &  & T((A × B) × C) \ar[d]^{Tass_{A,B,C}} \\ A × (B × TC) \ar[r]^{id_{A}×t_{B,C}} & A × T(B × C) \ar[r]^{t_{A,B×C}} & T(A × (B × C))}

The tensorial strength allows a pair of computations to be constructed from the computation of a pair, in two ways, which, in the general case in which T is non-commutative, will be distinct. This corresponds in a sequential language to the choice of which component to evaluate first. Taking the option of evaluating left-first:

Definition 2.2.7 Let

ψ_{A,B}: (TA × TB) → T(A × B) = c_{T A,T B}; t_{T B,A}; T (c_{T B,A}; t_{A,B}); μ_{A×B}

where c_{A,B}: A × B → B × A is the ‘twist’ map.

\xymatrix{T A × T B \ar[r]^{t_{T A,B}} \ar[d]_{ψ_{A,B}} & T (T A × B) \ar[r]^{T c_{T A,B}} & T (B × T A) \ar[d]^{T t_{B,A}} \\ T (A × B) & T (B × A) \ar[l]^{T c_{B,A}} & T^{2}(B × A) \ar[l]^{μ_{B×A}}}

Figure 2.2: Definition of ψ_{A,B}

Definition 2.2.8 A monad T : C → C is pointed (w.r.t. the order enrichment on C): if for each object there is a ⊥-map in C, ⊥_{TA} : 1 → TA, and ⊥_{A,TA} ≠ η_{A}. In fam(C), (C pointed), ⊥-maps exist only for singleton families, so if T is a pointed monad on fam(C), the image of T consists of singleton families of objects of C, i.e T resolves as an adjunction between a functor from fam(C) to C, and the inclusion { } : C → Fam(C).

Compare this with the notion of a weak co-product on a pointed category C.

Definition 2.2.9 C has weak (distributive, pointed) co-products if for each finite family {A_{i} | i ∈ I} of objects of C, there is an object Σ_{i∈I}A_{i} such that there are:

• injections in_{i} : A_{i} → Σ_{i∈I}A_{i}, for each i ∈ I, and

• for any family {f_{i} : A_{i} → B | i ∈ I}, there is a ‘co-pairing’: A unique strict map [f_{i} | i ∈ I]: Σ_{i∈I}A_{i} → B, such that in_{i}; [f_{i} | i ∈ I] = f_{i}.

• A distribution map for each object B, dist_{B} : B × Σ_{i∈I}A_{i} → Σ_{i∈I}(B × A_{i}) such that ⟨f, [g_{i} | i ∈ I]⟩; dist = [⟨f, g_{i}⟩ | i ∈ I].

• a ⊥-map ⊥_{Σ_{i∈I}A_{i}} : 1 → Σ_{i∈I}A_{i}, such that ⊥_{A_{i},Σ_{i∈I}A_{i}} ≠ in_{i}.

Abramsky and McCusker [3] have observed the following correspondence between weak co-products and strong monads on fam(C).

Definition 2.2.10 Suppose C is a category with a notion of pointed, distributive weak co-products, Σ, satisfying the following additional condition: for f_{i} : A_{i} → B, i ∈ I, and g : B → C, [f_{i} | i ∈ I]; g = [f_{i}; g | i ∈ I]. Then define the following strong monad: T_{Σ} : fam(C) → fam(C) T_{Σ}({A_{i} | i ∈ I} = {Σ_{i∈I}A_{i}} T_{Σ}⟨f : I → J, {ϕ_{i} : A_{i} → B_{fi} | i ∈ I}⟩ = {[ϕ_{i}; in_{fi} | i ∈ I]} with natural transformations

• η_{{A_{i} | i∈I}} : {A_{i} | i ∈ I} → {Σ_{i∈I}A_{i}} = {in_{i} | i ∈ I}

• μ_{{A_{i} | i∈I}} : {Σ(Σ_{i∈I}A_{i})} → {Σ_{i∈I}A_{i}} = {[id_{Σ_{i∈I}A_{i}}]}

• t_{{A_{i} | i∈I},{B_{j} | j∈J}} : {A_{i} × Σ_{j∈J}B_{j} | i ∈ I} → {Σ_{⟨i,j⟩∈I×J}A_{i} × B_{j}} = {dist_{A_{i}} | i ∈ I}}

Proposition 2.2.11 T_{Σ} is a strong pointed monad.

Proof: It is straightforward to show that the families of morphisms so defined are natural transformations, and that they satisfy the equations given above. □

2.2.2 Call-by-value and call-by-name semantics in fam(C)

Moggi ([62], etc.) describes the semantics of the call-by-value computational λ-calculus in the Kleisli category of a strong monad. A point made effectively in this work is that the order of evaluation (or flow of control), which is relevant to all forms of side-effects, can be studied using the computational λ-calculus and its theory, which is complete for these models. As will become apparent in Chapter 4, the case of non-local control itself is special, in that the μ-transformation of the monad is the denotation of a control operator. It will accordingly prove useful to define a monadic metalanguage along the lines of the computational λ-calculus; more detail is contained in [62] [64]. This language is exploited in Chapter 4 by relating it directly to calculi with control operators. Models of λ_{c}(Ω) (the computational λ-calculus with constants for non-termination) are given by a strong, pointed monad T on a cartesian closed category C which has all exponentials over the image of T in the following sense.

Definition 2.2.12 A cartesian category C has all exponentials of (the C-object) B if there is a contravariant functor ⇒ B : C^{OP} → C, with an evaluation map App_{A} : A ⇒ B × A → B at each A, with the standard universal property that for every f : C × A → B, there is a unique map Λ(f) : C → A ⇒ B such that Λ(f × id_{A}; App_{A}) = f.

The types of λ_{c} are formed from a non-empty set of base types, B by making the action of the monad in the Kleisli category explicit.

A ::= A ∈ B | TA | A ⇒ TB

The core typing system can be extended with product and sum types. Terms are formed as shown in Figure 2.3.

• The operations of λ-abstraction and application, which are interpreted using the monad strength, and exponentials of the base category. An undefined term denoting ⊥-elements has also been added.

• A let constructor, which is interpreted using composition in the Kleisli category ( let x = s in t is computed by evaluating s to a value, substituting it for x in t, and evaluating). This is a useful programming feature in its own right, and it also allows the equational theory to be extended beyond βη-equality, to reflect the order of evaluation. Note, however, that uses of let can be eliminated by replacing let x = s in t with the equivalent (λx.t) s.

• Operations [ ] and μ, corresponding directly to composition with the natural transformations of lifting (η), and flattening, μ. These maps define an isomorphism between terms of type TA, and values of type T^{2}A, (a ‘monadic reflection’ [27]) which in the case of control defines an ‘idealized’ control operator.

The call-by-name interpretation of the simply-typed λ-calculus in the cartesian closed category fam(C) is completely standard. The problems come with the addition of sum types due to the inconsistency of pointed order enrichment and cartesian closure with true co-products. One solution, adopted in [14], and [59], is to take weak co-products, giving separated sums. (Hence the claim that the fam(C) construction represents a way to generalise call-by-name semantics to call-by-value.) But one can also use co-products and a strong monad to define a call-by-name semantics of sums.

\overline{[[Γ,x_{n}:A⊢x_{n}:TA]]=π_{n};η_{[[A]]}}  \frac{[[Γ⊢t:TA]]=f [[Γ,x:A⊢s:TB]]}{[[Γ⊢ let x=t in s:TB]]=⟨id_{[[Γ]]},f⟩;t_{[[Γ]],[[A]]};Tg;μ_{[[B]]}}
\overline{[[Γ⊢Ω:TA]]=⊥_{T[[A]]}}
\frac{[[Γ,x:A⊢t:TB]]=f}{[[Γ⊢λx.t:T(A⇒B)]]=Λ(f);η_{A⇒TB}}  \frac{[[Γ⊢t:TA]]=f [[Γ⊢s:T(A⇒TB)]]=g}{[[s t:TB]]=⟨g,f⟩;ψ_{[[A]]⇒T[[B]],[[A]]};TApp_{[[A]],T[[B]]};μ_{[[B]]}}
\frac{[[Γ⊢t:A]]=f}{[[Γ⊢[t]:T A]]=f;η_{[[A]]}}  \frac{[[Γ⊢t:T^{2}A]]=f}{[[Γ⊢μ(t):TA]]=f;μ_{[[A]]}}

Figure 2.3: Term formation and semantics for λ_{c}(Ω)

Proposition 2.2.13 Suppose T is a strong monad on Fam(C), together with a natural transformation ϱ : T → Id, such that η; ϱ = id, and for any strict map f : TA → B, if ϱ_{A}; η_{A}; f = g, then f = g. Then T(A + B) is a weak co-product of A and B in C.

Proof: Injections into T (A + B) are given by in_{l}; η_{A+B} and in_{r}; η_{A+B}, where in_{l}, in_{r} are the injections into the true co-procuct. The co-pairing of f : A → C, g: B → C is ϱ_{A+B}; [f, g] : T (A + B) → C, so that this is a weak co-product: (in_{r}; η_{A+B}); ϱ_{A+B}; [f, g] = in_{r}; [f, g] = f, and ϱ; [f, g] is unique as if {f, g} : T (A+B) → C is a strict map such that in_{l}; η_{A+B}; {f, g} = f, and in_{r}; η_{A+B}; {f, g} = g, then η_{A+B}; {f, g} = [f, g]. Hence by uniquenes of [f, g], ϱ_{A+B}; η_{A+B}; {f, g} = ϱ_{A+B}; [f, g] and hence {f, g} = ϱ_{A+B}; [f, g] as required. The distributivity transformation is derived from the monadic strength, together with distributivity for the true co-product: t_{A,T(B+C)}; Tdist_{A,B+C} : A × T(B + C) → T(A × B + A × C). □

2.3 Models of continuation-passing

The semantics of the specific computational feature of access to the flow of control can now be described, based on the key notion of continuation passing style (cps) semantics. But it is necessary to make a choice. There are several possible semantic frameworks for continuation passing, although (see Section 2.3.2 below) there is a sense in which each is representable in terms of the other. In any case, the more concrete models of simple programming languages considered here can be given in terms of simple cps translations to which the differences between styles of continuation-passing semantics seem less relevant. In fact, an observation made in Chapter four (see Example 4.1.1) is that the finite parts of the models of PCF with control are given by a continuation-passing interpretation over a single, empty type. Since definability of this finite fragment is the key to full abstraction, attention will be focussed on this simple and specific notion of model.

Say that an object a of a cartesian category C is an answer object of C if C has all exponentials of a.

Proposition 2.3.1 For any answer object a, the contravariant functor ⇒ a : C^{OP} → C is self-adjoint.

Cartesian closure of C is not necessary, although as shown by Hofmann [39] any Kleisli category of a continuations monad can be embedded in one constructed from a cartesian closed category (using the Yoneda lemma). It is also the case that if C is bicartesian closed, there is a cartesian closed full subcategory of C with objects freely generated from a by the operations of ×, ⇒. Write a^{C} for the category of exponentials of a, with C-morphisms between them (‘the category of a-continuations’).

Proposition 2.3.2 If C has co-products and all exponentials of a, then a^{C} is cartesian closed, and so if C is a cartesian closed category constructed from a single base object a, then {a}^{fam(C)} ≅ C

Proof: For the first part, define: (A ⇒ a) × (B ⇒ a) = (A + B) ⇒ a, (A ⇒ a) ⇒ (B ⇒ a) = (A ⇒ a × B) ⇒ a. The objects of {a}^{fam(C)} are the singletons {((B_{1} ⇒ a) × … × (B_{n} ⇒ a)}, where each B_{i} is either terminal, or an object of C. □

Hence the call-by-name λ-calculus with control over a single, empty type can be interpreted in a category of continuations. This is a degenerate example of the more general call-by-name cps models described by Hoffman and Streicher [40] (see Remark 4.5.10).

2.3.1 The continuations monad

It was observed by Moggi [63] that continuation-passing is an example of a ‘notion of computation’ which can be represented as a strong monad, and has since been studied widely using this paradigm, for instance by Filinski, in his thesis [27]. As ⇒ a is a self-adjoint functor, it resolves a monad, which can be described as follows.

Definition 2.3.3 (Continuations Monad) For a category C and answer object a define the following ‘monad of a-continuations’:

TX = (X ⇒ a) ⇒ a T(f: A → B) = [[x: (A ⇒ a) ⇒ a ⊢ λy: B ⇒ a.x (λz: A.y (f(z)))]] η_{A} : A → TA = [[x: A ⊢ λy: A ⇒ a.(y x)]] μ_{A} : T^{2}A → TA = [[x: ((((A ⇒ a) ⇒ a) ⇒ a) ⇒ a) ⊢ λy: (A ⇒ a).x (λz.((A ⇒ a) ⇒ a).z y)]] and monad strength: t_{A,B} : A × TB → T(A × B) = [[x: (A × ((B ⇒ a) ⇒ a)) ⊢ λy: ((A × B) ⇒ a).(π_{2}(x) (λz: B.y ⟨π_{1}(x), z⟩))]]

If C has all exponentials over a, it has all exponentials over (A ⇒ a) ⇒ a. (Any exponential B ⇒ (A ⇒ a) ⇒ a is isomorphic to an exponential ((B × (A ⇒ a)) ⇒ a) over a.) Hence the Kleisli category of continuations on C will be a λ_{c}(Ω)-model.

The requirement that the continuations monad is pointed restricts the possible answer objectss in fam(C) to singletons of non-terminal objects.

Proposition 2.3.4 For any pointed CCC, C, the monad of O-continuations on fam(C) is pointed (with the ⊥-maps of fam(C)) if and only if O = {a} for some non-terminal object a of C.

Proof: If {A_{i} | i ∈ I} is a non-singleton, non-empty family, then ({A_{i} | i ∈ I} ⇒ O) ⇒ O is a singleton (and hence pointed), if and only if O is a singleton. □

Remark 2.3.5 The continuations monad (by Proposition 2.2.13 above) can be described as a weak co-product on an appropriate category; it is the sum which is definable in the CCC of type-objects freely constructed from a as the weak dual of the product:

A + B = ((A ⇒ a) × (B ⇒ a)) ⇒ a.

The categorical models of control which will be used throughout this thesis can now be defined. The interpretation of a functional basis (λ^{+}(Ω): the simply-typed λ-calculus with sums and constants for non-termination) is described here, the extension with control operators described in Chapter 4.

Definition 2.3.6 (A model of control) is designated by a pair of a category with ⊥-maps, C, and an object a such that C has all exponentials of a. The full subcategory of C consisting of objects freely constructed from a with × and ⇒ yields interpretations of λ^{+}(Ω) (via the fam(C) construction and the monad of {a} continuations) as detailed in Section 2.2.2. The call-by-name and call-by-value interpretations will be respectively called call-by-name and call-by-value models of control. The denotations of types in these models is therefore as follows:

The call-by-value control model is the Kleisli category of the a-continuations monad on fam(C) giving the following interpretation of the 0, ×, ⇒, + types.

• [[0]]_{v} = {} (so T[[0]]_{v} ≅ {a})

• [[S ⇒ T]]_{v} = [[S]]_{v} ⇒ T[[T]]_{v}

• [[S × T]]_{v} = T[[S]]_{v} × T[[B]]_{v}

• [[S + T]]_{v} = [[S]]_{v} + [[T]]_{v}

For each finite set X, a ‘ground type’ X̃ corresponding to {1_{x} | x ∈ X}, can be defined from the empty type. [[1]]_{v} = [[0 ⇒ 0]]_{v}, and X̃ = ∐_{x∈X} 1.

The call-by-name control model is the pointed CCC with weak co-products given by T(A + B), giving the following interpretation of the 0, ×, ⇒, + types.

• [[0]]_{n} = {a}

• [[S ⇒ T]]_{n} = [[S]]_{n} ⇒ [[T]]_{n}

• [[S × T]]_{n} = [[S]]_{n} × [[T]]_{n}

• [[S + T]]_{n} = T([[S]]_{n} + [[T]]_{n}) ≅ (([[S]]_{n} ⇒ {a}) × ([[T]]_{n} ⇒ a)) ⇒ a

Other ground types (flat domains) can be constructed from 0 as weak coproducts: X̃_{∗} = Σ_{x∈X}1 = (Π_{x∈X}a) ⇒ a.

Proposition 2.3.7 The full subcategory of type-objects in a model of control specified by (C, a) (call-by-name or call-by-value) is isomorphic to the full subcategory of C with objects freely constructed from a with ⇒.

Proof: This is trivial for the call-by-name model. In the call-by-value model it is necessary to show that for every non-terminal object A in (C, a) there is a type S such that T[[S]] = {A}

• {a} = T{0} = T[[0]]_{v}

• suppose {A} = T[[S]]_{v}, and {B} = T[[T]]_{v}. Then [[(S ⇒ 0) + T]] = T(([[S]]_{v} ⇒ {a}) + [[T]]_{v}) ≅ ((([[S]]_{v} ⇒ {a}) ⇒ {a}) × ([[T]]_{v} ⇒ {a})) ⇒ {a} = {A ⇒ B}

□

2.3.2 The continuations monad and other control models

A natural question which arises is whether the semantics of control based on a models of continuations is the simplest and most general choice. The semantics of continuation-passing via translation uses a notion, cartesian closure, which is not, on the face of it, specifically relevant to control, as the operation of continuation forming need not be described in terms of exponentiation by an answer object. An attempt to describe the semantics of control at a more fundamental level has recently been developed, based on the notion of premonoidal category. Initial work by Thielecke [82] took a self-adjoint, contravariant ‘not-functor’ as primitive, rather than any notion of exponentiation, an approach which has been developed by Führmann [28].

Particularly relevant in this context is a recent paper by Selinger [79]. This describes ‘control categories’, certain premonoidal categories, in which the call-by-name λμ-calculus can be soundly interpreted. Their duals, co-control categories, are (essentially) tensor-not categories, which are models of the call-by-value λμ calculus. These models have strong completeness properties. The key to a comparison between the monadic and premonoidal approaches is the ‘not-functor’ ⇒ a which resolves the continuation monad, and its image, the (premonoidal) category of continuations. A premonoid [74] is a binary operation on a category which is functorial in its arguments individually, but not jointly. For instance, in the Kleisli category of a monad on a cartesian category, the cartesian product from the base category is not cartesian, but it is a premonoid ⊗. A tensor-not category is a premonoidal category with a not-functor, ¬, as a primitive, so that the call-by-value function-space A ⇒ B can be represented as ¬(A ⊗ ¬B).

Working in the dual setting of categories of continuations and call-by-name cps gives an example of a premonoidal ‘disjunction’.

Proposition 2.3.8 If a is an answer object for a cartesian category C, then the category of a continuations on C is a symmetric premonoidal category, with the premonoid ⊕ defined by: (A ⇒ a) ⊕ (B ⇒ a) = A × B ⇒ a

The call-by-name function-space A ⇒ B can then be represented as ¬A ⊕ B. Thus each category of continuations is a control category, and its dual is a tensornot category (there are further requirements to satisfy, see [82] and [79]). The question posed by Führmann [28], (for tensor not) and Selinger [79], is: which control categories arise in this way? The answer is that they all do.

Theorem 2.3.9 (Structure theorem for control categories [79]) Every control category is equivalent to a category of continuations R^{C}.

Hence generality is not gained or lost by choosing the premonoidal presentation of control models. This means that the simply-typed λ-calculus is a completely expressive language for expressing control (notwithstanding its other roles as the basis of functional languages). Given the similarity in motivation behind the introduction of monads and premonoidal categories, as corresponding to a general notion of computation with side effects, could there be other results of this kind?

The deciding factors in the choice of presentation of the semantics of control are therefore philosophical and pragmatic, depending on the way in which control is to be analysed. Continuation-passing creates complex high-level objects from a simple cartesian closed category; for the ‘reductive’ analysis of denotational models of control which form the major part of the technical contribution of this thesis (for instance the axiomatic definability result in Section 3.7), it is the simplicity of this basis which is important. For understanding behaviour in the model, reductionism is not appropriate, but structuring tools are required. Monads and premonoidal categories are both examples of such tools; of the two, control categories offer perhaps a more direct and elegant presentation of the semantics of control. In the context of other computational behaviour, however, understood via the intensional hierarchy of game semantics, the continuations monad is more directly relevant (see, for instance the work of Abramsky and McCusker on structuring games for purely functional languages and state with monads [3], [4]). An interesting possibility is a similarly general investigation of game semantics via premonoidal categories.

2.3.3 Complete languages and models of control

Having fixed on a notion of model, it will also be necessary to find an extension of the λ-calculus with control operators to interpret in it. As in the case of the semantics, there are a number of possible (and broadly equivalent) alternatives. A natural property to demand is that the chosen language also has a theory which is sound and complete for an interpretation in models of control, in the sense of Definition 2.1.8. (A related requirement (see e.g. [79]) is for a λ-calculus extension which is an internal language of models of control.) Instead, this requirement can be expressed in terms of syntax, by asking for a relationship with the language Λ(Ω) which is analogous to the semantic relationship between models of control and pointed CCCs.

Definition 2.3.10 A language L of typed terms-in-contexts is an extension of λ^{+}(Ω) if the types, terms and contexts of λ^{+}(Ω) are included in the types, terms and contexts of L, and the operations of application, λ-abstraction, and their associated typing judgements, are also included in L.

Definition 2.3.11 (A complete syntax of control) ia a language L, extending the λ^{+}(Ω)-calculus, such that there are translations ( )^{∗} from L into Λ(Ω). These are required to be surjective on βη-equivalence classes, and have the property that for any pointed CCC, C, and associated model of control M, interpretation of λ^{+}(Ω)-terms in M coincides with translation into Λ(Ω), and interpretation in C, i.e. for all t:

[[t]]_{M} = [[t^{∗}]]_{C}

A principal aim of this thesis is to describe denotational models of control with completeness properties, which will form the finite part of a fully abstract model. (It is not straightforward, for instance, to obtain a continuous order-enrichment on the free constructions). The notion of full and faithful completeness (originating in the semantics of proofs [5]) captures the property which is sought, — that elements of the model are all denotations of terms of the language which are unique up to equality in its theory.

Definition 2.3.12 Let L be a language extending the λ^{+}(Ω)-calculus and T an equational L-theory. A model of L is fully complete if for every map between type-objects, f : [[A]] → [[B]], there is an L-term-in-context x : A ⊢ t_{f} : B such that f = [[x : A ⊢ t_{f} : B]]. It is fully and faithfully complete if each t_{f} is unique up to equality in T.

Although denotationally fully complete models will be the main objective , categorical completeness has a part to play. As they are constructed by continuationpassing construction, finding such models will boil down to finding a fully complete model of Λ(Ω), and a complete syntax of control.

Proposition 2.3.13 If L is a complete syntax of control, and C is isomorphic to the free CCC over a single object, then the models of control defined from (C, a) are fully and faithfully complete models of L.

2.4 Models of programming languages

The simply-typed λ-calculus with control operators is not sufficiently expressive for the analysis of functional control in a programming context, which requires (at least) the natural numbers and recursion. PCF [78], which includes these features, can be considered not only as the prototypical functional language, but also as a basis for languages which combine the λ-calculus with non-functional features like state, concurrency or access to the flow of control. This choice also allows the semantic techniques which have been developed in the study of PCF, for modelling recursion and proving full abstraction, to be adopted (with minor adaptations) in the case of control. They are described succinctly here, reverting to the general framework of λ-calculus based languages interpreted via a strong, pointed monad.

To give a semantics of recursion requires a fixpoint operator. The standard solution for PCF [10] is to assume a continuous order-enrichment on the model, so that least upper bounds of all directed sets exist. Definability of compact elements is then sufficient to construct a fully abstract model from an algebraic category. In practice, this is a good syntax-independent way to present a model. However, the ‘collapsed’ categories on which the fully abstract PCF semantics is based may not have continuous order-enrichment (although, as will be shown in Chapter 5, the fully abstract models of PCF with control can be cpo-enriched). A minimal solution is to use the implicit order-structure on definable elements defined by pointedness and monotonicity of application and λ-abstraction in a CCC. Instead of general chain-completeness, recursion can be based on the existence of least upper bounds of chains of endomorphisms (following AJM [6]).

Definition 2.4.1 In a category with ⊥-maps, for each endomorphism f : A → A, define the chain {f^{i} : 1 → A | i ∈ ω} (such that f^{i} ⊑ f^{i+1}) f^{0} = ⊥_{A}, f^{i+1} = f^{i}; f. A category is rational with respect to some order-enrichment ⊑ of its hom-sets if all ω-chains of the above form have least upper bounds,

f^{∇} = ⨆_{i∈ω} f^{i}

and for every g : A → B, f^{∇}; g = ⨆_{i∈ω}(f^{i}; g).

It is also important to have access to recursively defined datatypes, such as the natural numbers. Infinite (small) sum types can be interpreted in FAM(C), the category of families of objects of C indexed over infinite sets, defined as for fam(C).

Proposition 2.4.2 If C has all small products, then FAM(C) is cartesian closed.

Proof: is by extension of the definition of exponential for fam(C) to infinite families and products, recalling that

{A_{i} | i ∈ I} ⇒ {B_{j} | j ∈ J} = {Π_{i∈I}(A_{i} ⇒ B_{f(i)}) | f ∈ J^{I}}.
□

In particular, there is a natural numbers object in FAM(C)

Definition 2.4.3 Let ℕ = {1_{i} | i ∈ ω}. This is a natural numbers object with

zero = ⟨id_{1}, 0⟩, and successor = ⟨id_{1}, succ ⟩.

The weak ω-indexed co-product Tℕ is a flat domain of natural numbers, or ‘object of numerals’ in the terminology of [43]. By the assumption that ⊥_{Tℕ} ≠ in_{i} for any i, it is also a standard datatype, — numerals correspond to distinct non-⊥ elements.

2.4.1 PCF and its semantics

PCF was introduced as a programming language by Plotkin [71]. It extends the λ-calculus with arithmetical constants, conditionals, and a recursion combinator (to which sum and products can be added).

Definition 2.4.4 (Call-by-name semantics of PCF) Types are freely generated from the ground type nat by an arrow constructor ⇒, and interpreted as follows: [[nat]] = Tℕ = Σ_{i∈ω}1_{i}, — the flat domain of natural numbers or ω-indexed separated sum of empty domains, [[T_{1} ⇒ T_{2}]] = [[T_{1}]] ⇒ [[T_{2}]]. The original presentation of PCF also contained a ground type of booleans, with relevant constants, which is omitted here. The interpretation of terms is described in Figure 2.4.4.

Numerals are interpreted as the relevant injection \overline{n}: 1 → ℕ̃_{∗} = in_{n} into the object of numerals.

Conditionals at type T are interpreted by the composition (in context) of the tested term, which is an injection into Σ_{i∈ω}1_{i}, with the co-pairing of the ‘zero case’, (as a map into [[T]]) with (inifinitely many instances of) the non-zero case.

The Y combinator can be interpreted in a rational category as the least fixedpoint of F_{A}: ((A ⇒ A) ⇒ A) → ((A ⇒ A) ⇒ A) = Λ((id_{(A⇒A)⇒A} × id_{A→A}); App_{(A⇒A)⇒A,A⇒A} × id_{A⇒A}; con_{A⇒A}) So for any endomorphism, f: A → A, f; [[Y]] = f^{∇} For any type T, there is an ‘undefined term’ of type T, Ω^{T} = Y(λx: T.x).

Note also that a series of case-splitting constructs can be defined along the lines of IF0 with the intended meaning that case_{k}t|_{i≤k}s_{i} evaluates to s_{i} if t evaluates to i. These have proved useful for definability results, but full abstraction is not affected, as they can be simulated up to observable equivalence using IF0 as follows:

case_{0} M | N_{0} | N′ = IF0 M then N_{0} else N′,

case_{n+1}M | N_{0}| … | N_{n} | N_{n+1} | N′ =

case_{n}M | N_{0} | … | N_{n} | IF0 (pred^{n+1} M) then N_{n+1} | N′.

The definability results for call-by-name PCF were given with respect to PCF_{c}, which extends PCF with these constructs, but the related full abstraction results hold for PCF itself because of this simulation.

[[Γ, x: T ⊢ x: T]] = π_{r}: [[Γ]] × [[T]] → [[T]]
[[⊢ 0: nat]] = in_{0} : 1 → Tℕ
[[Γ ⊢ succ M: nat]] = [[Γ ⊢ M: nat]]; plus1
[[Γ ⊢ pred M: nat]] = [[Γ ⊢ M: nat]]; minus1
[[Γ ⊢ λx.M: T ⇒ U]] = Λ([[Γ, x: T ⊢ M: U]])
[[Γ ⊢ M N: U]] = ⟨[[Γ ⊢ N: T]], [[Γ ⊢ M: T ⇒ U]]); App

[[Γ ⊢ (IF0 L then M else N): nat]] = ([[Γ ⊢ L: nat]]; [[[Γ ⊢ M: nat]], \overline{[[Γ ⊢ N: nat]]}]

[[Γ ⊢ Y^{T} M: T]] = [[Γ ⊢ M: (T ⇒ T)]]; F^{∇}

Figure 2.4: Terms of PCF in contexts, with a call-by-name interpretation Definition 2.4.5 (Call-by-value semantics of PCF) The interpretation of callby-value PCF in Fam(C)_{T} is similar to that described above, with the following modifications.

• λ-abstraction and application are interpreted in the Kleisli category of a strong monad on Fam(C) (as described in Section 2.2.1).

• The type nat denotes the ω-indexed co-product {1_{i} | i ∈ ω}, with the same interpretation of numerals as injections, and conditionals as co-pairing.

• Recursion behaves quite differently in call-by-value to call-by-name. As every endomorphism f : A → A in the Kleisli category is strict,all least fixpoints are trivial, so one cannot add recursion by taking f^{∇} = ⨆_{n∈ω} f^{n}. The solution generally adopted is to take ‘η-expansions’ at each iteration,

— based on the following conversion for the Y combinator:

YM ⟶ M (λx.((YM) x)).

So YM is approximated by Ω, M(λx.Ωx), M (λy.(M(λx.Ωx)y)), … Provided C is rational, these fixpoints can be modelled in the Kleisli category.

Definition 2.4.6 For objects A, B in the Kleisli category, define χ_{A,B}: T(A ⇒ TB) → T(A ⇒ TB) = Λ(t_{A,A⇒TB}; T(App_{A,A⇒TB}); μ_{B}); η_{A⇒TB}. (So for any t : T_{A} ⇒ T_{B}, [[λx.(tx)]] = χ_{A,B}; [[t]].) Now define a fixpoint operator ( )^{Δ} for the Kleisli category: If f: T((A ⇒ TB) → T(A ⇒ TB))

f^{Δ} = (χ_{A→TB}; f; μ_{A→TB})^{∇} = ⨆_{n∈ω}(χ_{A→TB}; t; μ_{A→TB})^{n}.

Hence the call-by-value Y-combinator can be interpreted [[Γ ⊢ YM]]_{v} = [[Γ ⊢ M]]_{v}; F^{Δ}.

An operational semantics for PCF was defined in [71]. By soundness, rationality, and standardness of datatypes, the crucial property of computational adequacy (a program denotes a value if and only if it reduces to that value) of the denotational model with respect to this semantics can be established. (See Section 4.4 and [14] for more details.)

2.4.2 Fully abstract models of PCF-based languages

The notion of observational equivalence defined in Chapter 1 (Definition1.2.1) can be generalised to an observational preorder on terms.

Definition 2.4.7 For a language L extending PCF (in the sense of Definition 2.3.10), define the observational preorder between terms in (the same) context, Γ ⊢ M and Γ ⊢ N M ⊑^{OBS} N if for every compatible context C[·] : nat, C[M] ⇓ implies C[N] ⇓. Full abstraction for partial-order-enriched models is equivalent to demanding that M ⊑^{OBS} N if and only if [[M]] ⊑ [[N]].

The key properties for full abstraction for PCF and extensions are computational adequacy and finite definability, although these can be combined in a variety of ways.

Proposition 2.4.8 Let M be a cpo-enriched denotational semantics of a language L (extending PCF) which is computationally adequate with respect to the operational semantics of L. Suppose that every morphism between type-objects of M is the least upper bound of a chain of L-definable elements, then for any closed terms (values in the case of call-by-value) M, N : T,

M ⊑^{OBS} N ⟺ ∀h (definable): A → T(ℕ) : f; h ↓ ⟹ g; h ↓ .

Proof: Suppose M ⋢^{OBS} N, then there is some L-context C[· : T] : nat such that C[M] ⇓ and C[N] ⇓̸, and hence by adequacy, [[C[M]]] ↓, and [[C[N]]] ↑, hence [[M]]; [[λx.C[x]]] ↓ and [[N]]; [[λx.C[x]]] ↑ as required.

In the other direction, suppose there is some h such that [[M]]; h ↓ and [[N]]; h = ⊥, then h = ⨆_{i∈ω} h_{i} for some chain of definable h_{i}, so ⨆_{i∈ω}[[M]]; h_{i} ↓, so [[M]]; h_{i} ↓ for some i such that [[N]]; h_{i} ↑. By the assumption of finite definability, h_{i} = [[L]] for some term L : T ⇒ nat such that [[L M]] ↓ and [[L N]] ↑, so by computational adequacy L M ⇓, and L N ⇓̸, so M ⋢^{OBS} N. □

(This is shown to extend to terms with free variables in Lemma 4.6.8.)

Corollary 2.4.9 Suppose M is an adequate, cpo-enriched model of L such that all elements are suprema of chains of definable elements, and for all elements f, g : A, ∀h : A → [[nat]], f; h ≠ ⊥ ⟹ g; h ≠ ⊥ implies f ⊑ g, then M is fully abstract.

Alternatively, the ‘intrinsic preorder collapse’ of a cpo-enriched model satisfying definability will be fully abstract.

Definition 2.4.10 Let M be a model of L (a PCF extension) in a (cartesian closed) category C, and define the intrinsic preorder

f ≲_{A→B} g ⟺ ∀h : A ⇒ B → Tℕ ‘f’; h ↓ ⟹ (‘g’; h ↓),

and in the call-by-value model

f ≲_{A} g ⟺ ∀h : A → Tℕ ‘f; η_{B}’; h ↓ ⟹ ‘g; η_{B}’; h ↓).

Define the collapse of M/ ≲ as in Definition 2.1.15, — type-objects are as in M, morphisms are equivalence classes of M-morphisms partially-ordered by ≲.

Proposition 2.4.11 Supppose M is a cpo-enriched model of L such that every element is a supremum of a chain of definable elements, and that its collapse M/ ≲ is an adequate model of L. Then M/ ≲ is fully abstract.

Proof: By Proposition 2.4.8, for all terms M, N : T, M ⊑_{T} N if and only if for all definable h : [[T]] → Tℕ in M, [[M]]_{M}; h ↓ implies [[N]]_{M}; h ↓. As every element of M, is approximated by definable elements, M ⊑_{T} N if and only [[M]]_{M} ≲_{[[T]]} [[N]]_{M}, as required. □

Collapse under the intrinsic preorder preserves the key features of PCF adequacy at least, — cartesian closure, as in Proposition 2.1.13, and rationality.

Proposition 2.4.12 The collapse of a cpo-enriched CCC under its intrinsic preorder is rational.

Proof: Given [f] : A → A, define [f]^{∇} = [f^{∇}], — to show that this is consistent and rational it is necessary to show that for any g : A → B, f^{∇}; g is a least upper bound (with respect to ≲) for {f^{i}; g | i ∈ ω}. (and if g ≡ f, then f^{∇} ≡ g^{∇}). So it suffices to show that if f^{i}; g ≲ h for all i ∈ ω, then f^{∇}; g ≲ h. Suppose f^{∇}; g ≴_{B} h, then there is some k : B → Tnat such that h; k = ⊥ (⨆_{i∈ω} f^{i}; g); k = ⨆_{i∈ω} f^{i}; g; k ≠ ⊥, hence for some i, f^{i}; g; k ≠ ⊥, so f^{i}; g ≴_{B} h as required. □

2.5 Models of PCF with control

The language μPCF will be obtained by extending PCF with certain operations from the control calculus λμ. Proceeding from the basis of finitary models of control on the other hand, it is relatively straightforward to describe the passage to ‘computational models’ of control with recursion as a process of completion which is in some respects simpler than the general notion of PCF-model.

Definition 2.5.1 Computational models of control (call-by-name and call-by-value) are specified by a pair (C, a) of a rational pointed CCC with ω-indexed products and non-terminal answer object a.

Definition 2.5.2 A category C has ω-indexed products, if for every object A, there is an object A^{ω}, with projection maps head : A^{ω} → A and tail : A^{ω} → A^{ω} with the following universal property: for every pair of maps f : B → A, g : B → A^{ω}, there is a unique map f::g : B → A^{ω} such that f::g; head = f and f::g; tail = g.

(Informally), A^{ω} is the least solution to A = A × A^{ω}.

Definition 2.5.3 Let A^{0} = 1, A^{i+1} = A × A^{i}. Then a series of embeddings and projections e_{i} : A^{i} → A^{ω} and p_{i} : A^{ω} → A^{i} can be defined such that e_{i}; p_{i} = id_{A_{i}}, and p_{i}; e_{i} ⊑ id_{A^{ω}}, viz: e_{0} = ⊥_{A^{ω}}, e_{i+1} = π_{l}::e_{i} p_{0} = 1_{A^{ω}}, p_{i+1} = ⟨head, tail; p_{i}⟩

These embeddings and projections can be used to define embeddings and projections between type-objects constructed from finite products, and from ω-indexed products.

Definition 2.5.4 Define the Λ(Ω)^{ω}-types as follows: T ::= ι | T^{ω} | S ⇒ T and interpret them in a pointed CCC C with ω-indexed products and answer object a: [[ι]]_{(C,a)} = a, [[T^{ω}]]_{(C,a)} = [[T]]_{(C,a)}^{ω}, [[S ⇒ T]]_{(C,a)} = [[S]]_{(C,a)} ⇒ [[T]]_{(C,a)}. For each Λ(Ω)^{ω}-type T, form T_{i} by ‘truncating all ω-indexed products at i’ i.e. ι_{i} = a, (T^{ω})_{i} = (T_{i})^{i}, (T ⇒ S)_{i} = T_{i} ⇒ S_{i}, Then there is an embedding/projection pair [[T]]_{(C,a)} →_{p_{i}^{T}} [[T_{i}]]_{(C,a)} →_{e_{i}^{T}} [[T]]_{(C,a)}

• e_{i}^{S⇒T} = Λ(id_{[[S_{i}⇒T_{i}} × p_{i}^{S}; App; e_{i}^{T}), p_{i}^{S⇒T} = Λ(id_{S⇒T} × e_{i}^{S}; App; p_{i}^{T}), • e_{i}^{S^{ω}} = Π_{j≤i}e_{i}^{S}; e_{i},

p_{i}^{S^{ω}} = p_{i}; Π_{j≤i}e_{i}^{S}.

Proposition 2.5.5 For every Λ(Ω)^{ω}-type T, and i ∈ ω, e_{i}^{T}; p_{i}^{T} = id_{T_{i}}.

Proof: is by induction on the structure of T, using the definition of e_{i}, p_{i} and the universal properties of a CCC. □

Although all set-indexed products are required for cartesian closure of FAM(C) (and the specific models considered will have such products), the semantics will require only countable co-products. So attention will be restricted to Fam(C), — the category of countably indexed families of objects of C. Fam(C) is clearly not cartesian closed. However, the observation that a continuations model requires only limited exponentials can be used here, as provided C has ω-indexed products, Fam(C) has all exponentials of {a}.

Proposition 2.5.6 If C has ω-indexed products, then the monad of a-continuations on C is well-defined, and for any object A, C has all exponentials of TA.

Note that it is still not necessary to introduce ground type values into control models, — data is modelled intensionally. For instance, in the domain corresponding to nat, Tℕ = (ℕ ⇒ {a}) ⇒ {a} ≅ {a^{ω} ⇒ a}, each numeral corresponds to a projection from a^{ω}, ‘the countable list of as’. This is the basis for fully abstract translations of PCF with control into the simply-typed λ-calculus with fixpoint combinators and infinite lists. This is described, with the call-by-name translation, in Section 4.5.

Because the initial model of control is constructed by a process of completion from a simple cartesian closed category, there is a direct relationship between the CCCs with the associated properties, — the fully complete and fully abstract models of Λ(Ω) described in Section 2.1, — and the fully complete and fully abstract models of control.

In order to give a full abstraction result based on finitary definability, a continuous order-enrichment is assumed (although rationality, together with continuity of composition is all that is used).

Definition 2.5.7 A continuous model of control is specified by a pointed cpoenriched CCC, with ω-indexed products such that for every embedding/projection pair e_{i} : A^{i} → A^{ω}, p_{i} : A^{ω} → A^{i}, ⨆ p_{i}; e_{i} = id_{A}.

Lemma 2.5.8 In a continuous control model, the above property extends to all of the defined embeddings and projections e_{i}^{T} : [[T_{i}]] → [[T^{ω}]], p_{i}^{T} : [[T^{ω}]] → [[T_{i}]], i.e. ⨆_{i∈ω} p_{i}; e_{i} = id_{[[T]]}.

Proof: is by continuity of composition, and the universal properties of pairing and λ-abstraction. □

Say that a morphism of a computational control model (between Λ(Ω)^{ω} typeobjects) is definable if it can be defined via λ-abstraction, application, the operations (head, tail,::) of the countable product, and taking least fixpoints, ( )^{∇}. The following proposition shows, in essence, that the definable part of a continuous model of control is ω-algebraic, with a finite basis of finitary definable elements embedded from the definable elements of a model of control.

Proposition 2.5.9 If (C, a) specifies a continuous computational model of control, then every definable morphism is the least upper bound of a chain of morphisms definable in the model of control specified by (C, a), i.e. if f : [[S]] → [[T]] is definable, there is a series of morphims f_{i} : [[S_{i}]] → [[T_{i}]] such that { p_{i}^{S}; f_{i}; e_{i}^{T} : [[S]] → [[T]] | i ∈ ω} is an ω-chain, and

f = ⨆_{i∈ω}(p_{i}^{S}; f_{i}; e_{i}^{T}).

Proof: is by induction on the possible definitions of morphisms in the computational model of control. By the Lemma 2.5.8 above, id_{[[S]]} = ⨆_{i∈ω} p_{i}^{S}; id_{S_{i}}; e_{i}^{S} If f = Λ(f′) for some f′, then the hypothesis extends to f by the universal property. Suppose f = ⟨g, h⟩; App, then by hypothesis, there are chains of finitary elements such that g = ⨆_{i∈ω} p_{i}^{S}; g_{i}; e_{i}^{T ⇒R} and h = ⨆_{i∈ω} p_{i}^{S}; h_{i}; e_{i}^{T}. Thus g = ⨆_{i∈ω} p_{i}^{S}; g_{i} × p_{i}^{T}; App; e_{i}^{R}, and so by continuity of composition, h = ⟨id_{[[S]]}, g⟩; f × id_{[[S]]}; App = ⨆_{i∈ω}(⟨id_{[[S]]}, p_{i}^{S}; g_{i}; e_{i}⟩; p_{i}^{S}; f × p_{i}^{T}; App; e_{i}^{R} = ⨆_{i∈ω}(p_{i}^{S}⟨id_{[[S_{i}]]}, g_{i}⟩; f × id_{[[T_{i}]]}; App; e_{i}^{R} as required. If f = g^{∇} for some g : A → A, then by hypothesis, g = ⨆ p_{i}^{S}; g_{i}; e_{i}^{S}, for some series of morphisms {g_{i} : [[S_{i}]] → [[S_{i}]] | i ∈ ω}. Let f_{i} = g_{i}^{i}, then f_{i}; e_{i} = g_{i}^{i}; e_{i} ⊑ g_{i+1}^{i+1}; e_{i+1} = f_{i+1}; e_{i+1}. □

Recall that a complete syntax of control is an extension of the λ-calculus (including sums) with control operators, such that there are surjective translations into the simply-typed λ-calculus.

Definition 2.5.10 A complete computational syntax of control is an extension of PCF (with the empty type), such that there is a translation ( )^{∗} into the simplytyped λ-calculus with lists, Λ(Ω)^{ω} (see Section 4.5) which is surjective on Λ(Ω)^{ω}- equivalence classes at translated types T^{∗}, and such that for all PCF terms M, interpreted in a PCF model M, constructed from a computational model of control (C, a):

[[M]]_{M} = [[M^{∗}]]_{Λ(Ω)^{ω}}

Corollary 2.5.11 If M, specified by (C, a) is a continuous computational model of control, and L is a complete computational syntax of control then every morphism between type-objects of M is a least upper bound of a chain of L-definable elements, in the form ⨆_{i∈ω}(p_{i}^{A}; f_{i}; e_{i}^{B}).

Similarly, the intrinsic preorder on the finitary part of a computational control model characterizes the preorder on the whole model.

Proposition 2.5.12 Suppose (C, a) specifies continuous models of control via the monad of a-continuations on Fam(C), such that every element is a least upper bound of definable elements. Then the intrinsic preorder on the call-by-name and call-by-value PCF models in Fam(C) given by Definition 2.4.10 is equivalent to the preorder induced by by taking observations on a ⇒ a in the CCC generated from a. i.e. if f : A → B = ⨆_{i∈ω} p_{i}^{A}; f_{i}; e_{i}^{B}, and g = ⨆_{i∈ω} p_{i}^{A}; g_{i}; e_{i}^{B}, then f ≲_{A→B} g if and only if for every i ∈ ω, there exists j > i such that f_{j} ≲_{A_{i}→B_{i}} g_{j}.

Proof: is by Proposition 2.5.9 together with continuity. □

Together with Proposition 2.1.14, this yields the following corollary.

Corollary 2.5.13 The observational equivalence ≡ is the strongest non-trivial congruence on computational models of control.

Note that this is not an extensional equivalence on models of control (pace, for instance PCF). This is simply the semantic counterpart of the non-extensionality of observational equivalence in the presence of control operators (for further discussion see Chapter 5).

Thus if (C, a) defines a computational model of control, (C/ ≲, a) defines a model of control such that [[M]]_{C/≲} = [[[M]]_{C}]. So there are two routes to a syntaxfree presentation of the fully abstract model of control; take the quotient of a continuous model of control for which the restriction to finite types is isomorphic to the free CCC, or more directly, give a continuous model for which the restriction to finite types is the fully abstract pointed CCC. The first (based on Hyland-Ong games) is taken in Chapter 4, the second (based on sequential algorithms) in Chapter 5, where they are compared.

Corollary 2.5.14 The fully abstract computational model of control is effectively presentable if and only if the observational equivalence on Λ(Ω) is decidble.

Proof: By Proposition 2.5.9 every element of the fully abstract model is a least upper bound of (embedded) elements of the fully abstract pointed CCC , and by Proposition 2.1.17, this is effectively presentable if and only if observational equivalence on Λ(Ω) (or the simply-typed λ-calculus itself) is decidable. □

2.5.1 Universality

A good solution to the full abstraction problem will be a cpo-enriched and fully abstract model of control satisfying the following conditions:

The Jung and Stoughton criterion (as posed for PCF in [44]) The (finitary) fully abstract model of control is effectively presentable.

Universality All recursive elements of the model are definable.

The requirement that these conditions be satisfied together is significant, because it suggests that as well as being effective, such a presentation will be syntax independent. For instance, one could give a syntactic construction of a fully abstract model of μPCF along the lines of Milner’s construction of a fully abstract model of PCF [61], and even make it effective by giving a decision procedure for finitary observational equivalence. To give a universal presentation, however, requires some identification of the computable infinitary elements of the model, as in the AJM [6] and HO [43] game-based universal models of PCF. But there is no obvious notion of computability for syntax-based models which leads to universality.

Universality is also a highly relevant condition because it allows an equational full abstraction result to be strengthened to ‘logical full abstraction’ (described by Longley and Plotkin in [56]). This extends full abstraction from the single test of program-context equality, or observational equivalence, to formulas of a first-order logic for reasoning about programs.

Definition 2.5.15 For an extension of PCF, L, let J_{L} be the language of firstorder logic with equality which has the terms (with arities) given by the signature of L, and the single predicate ⇓ for termination. A J_{L}-structure is thus defined by the assignment of meanings to the terms, and truth values to the predicates of J_{L} in the standard way, with the following natural examples.

• An operational semantics of L based on evaluation to ground type defines a J_{L} structure over the observational equivalence classes of terms of J_{L} (with constants interpreted as their own equivalence class, and ⇓ as operational convergence).

• A denotational semantics M for L defines a J_{L} structure over M in which valuations can range over the whole domain, and constants receive the interpretation given to them by M, with the predicate ⇓ corresponding to some set of non-⊥ elements. (Under certain ‘standardness assumptions’, see [56],

— it is certainly sufficient to require that M is given by a strong pointed monad and a rational CCC, as in Definition 2.4.4. )

This allows the following definition to be made.

Definition 2.5.16 A model of L is logically fully abstract with respect to an operational semantics if the formulas of J_{L} valid in the corresponding denotational structure coincide with those which are valid in the operational structure.

The following theorem captures the intuition that logical full abstraction requires the effective elements of a fully abstract model to be identifiable.

Theorem 2.5.17 (Longley and Plotkin [56]) Let I be a standard model of L. Then it is logically fully abstract for J_{L} if and only if it is both universal and fully abstract.

(The implication from right to left is in fact quite simple to prove: equational full abstraction implies that atomic formulae are valid in the observational structure if and only if they are valid in the denotational structure, and this extends naturally to quantifier-free formulae. A universally quantified formula is valid in the observational structure if there is no valuation of terms which gives a counter-example, it is valid in the denotational structure if there is no valuation of elements yielding a counter-example. Hence if all elements are definable, the valid first-order formulas of the structures coincide.)

2.6 Summary

A programme for the construction and analysis of an effectively presented fully abstract syntax-independent model of control has been established. It is implemented in Chapters 3, 4 and 5, as follows.

Chapter 3 Gives denotational and axiomatic characterizations of the free pointed CCC, and hence the initial models of control. This falls naturally into three parts.

• A presentation of the intensional hierarchy of game semantics based on modelling types through some invariant structure, and computational effects through constraints on the copying and sharing of information.

• An axiomatic proof that the category of ‘unbracketed’ games and innocent strategies is isomorphic to the free (pointed) CCC.

• An examination of control flow within the control model, characterizing ‘upwards’ and ‘downwards’ continuation passing and local control flow, using linear moves and the ‘bracketing condition’.

Chapter 4 Describes a ‘syntax of control’, λμ(Ω), and a PCF extension μPCF, showing that its equational theory and operational semantics are sound and complete for models of control. This is proved using invertible cps translations into the simply-typed λ-calculus, and a monadic metalanguage for reasoning about computation with continuation passing.

Chapter 5 Gives an effective presentation of the fully abstract, universal model of control (in the category of sequential algorithms). Characterizes the observational preorder semantically, and compare the fully abstract models using a syntax independent description of the functor from the initial games model.

Game semantics of control

3.1 Introduction

The primary object of this chapter is to develop a game semantics from which the continuation passing models described in the previous section can be constructed. The basic requirements are thus quite simple: pointed cartesian closed categories of games, and in particular, models of Λ(Ω) with the definability property. An axiomatic characterization of the free pointed CCC over one object is also presented, adapting existing results to models of control.

But a second aim is to study the semantics of the intensional hierarchy. A development of existing work is the formalization of a notion of rule, which is used to build up a general symmetric monoidal closed category of games with finer structure created by the imposition of rules. The focus is naturally on the ‘control-axis’ of the hierarchy. It is shown that constraints on copying information (or demands for information) by repeating moves can be expressed as such global rules. This can be used to give a semantics for classical, intuitionistic, and linear fragments of the category of games, such that relaxing the rule corresponds locally to a translation (such as double negation translation or ‘linear decoration’).

This sheds some light on the the ‘bracketing condition’ (used in the models of PCF in [6], [43]) as corresponding to local control flow and an intuitionistic typing discipline, showing that this rule has two (separable) roles, each with a clear computational meaning. On this analysis, it is essentially a linearity condition, requiring that ‘answers’ to demands for information be given at most once, preventing repeated invocation of continuations (see [82]), and at least once, preventing discarding of continuations, and hence escapes or jumps. (Similarly, there are two levels at which classical principles such as Peirce’s law can be introduced into deduction systems; as ‘stability rules’ for atomic formulas, or at all levels, to reach full classical logic.)

3.2 A basic framework for games

The game semantics used is based on the Hyland and Ong approach [43] (which is similar to that of Nickau [65], and descended from the work of Lorenzen [57]). ‘Dialogue games’ are defined using justified sequences of moves. This choice was based on the following considerations.

• A neat division of labour between the apparatus of justification, which defines the possible ‘logical’ connectives for games, and rules, which enrich this repertoire by controlling the order in which moves can be played. The basic structural operations on arenas together with a few simple rules suffice to generate all of the games which will be required.

• A second concept introduced by Hyland and Ong, based on justified sequences, is the notion of the view as the relevant history of the play. The definability results rely on the restriction to innocent strategies, which have access only to the information in the view. But views have a useful secondary role in the intensional hierarchy; by hiding Opponent’s ill behaviour, they allow all strategies with the same ‘innocent function’ to be identified. This means, for instance, that there is a faithful embedding of strategies on well-bracketed games into the wilder world via their reponses to views.

A significant development of the Hyland-Ong framework was described in Mc-Cusker’s thesis [59]. This included a ‘linear decomposition’ of the cartesian closed structure, which is used in a modified form here. The clarity of exposition in this work also make it valuable background reading.

However, McCusker defines each game as being specified by a particular arena and a set of plays in the style of the AJ and AJM approach [5],[6]. These are subsets of the justified sequences over an arena which satisfy both the global rules (of visibility and bracketing) introduced by Hyland and Ong, — the ‘legal sequences’, but are also subject to some local characterizations. This is incompatible with the perspective advocated here, — that the only distinctions between games on the same arena are to be found in the rules. (And, more importantly, the ‘projection conditions’ on which his constructions are based simply fail in the games used to model computation with higher-type references [4].) Instead, games here are simply sets of justified sequences, which are specified (but not uniquely) by an arena, and a set of rules. Thus, for instance, removing the question/answer tagging from an arena specifies exactly the same game as retaining the labelling, but dropping the rule (bracketing condition) which refers to the tags.

3.2.1 Arenas and justified sequences

Lorenzen [57] introduced ‘dialogue games’ to semantics, and the analogy with a debate is a useful one. Debates can be categorized under two headings; their subject, and the rules under which they are held. Arenas specify the subject; the structure of the information relevant to the debate. This information is carried by a set of tokens representing actions, historically called moves, (although this almost immediately engenders a confusion between the token itself, and a specific instance of its use in the game). Moves are statements relevant to the subject, possibly distinguished by additional labels saying which side may utter them, in which order, whether they can be repeated, and whether they are incompatible with other statements.

The analogy also lends itself to the notion of justification. In the midst of a debate, for instance, one has a basic choice between opening an entirely new line of argument or attacking the assumptions underlying one of the opponent’s more recent assertions. Attacks of the latter sort, which refer directly to a single earlier utterance are justified by it, according to this terminology. To determine when such a contingent attack can be made, there is an enabling relation between moves.

Definition 3.2.1 (Arenas) An arena A is a quadruple: ⟨M_{A}, ⊢_{A}⊆ (M_{A})_{∗} × M_{A}, L, λ_{A} : M_{A} → P(L)⟩ which specifies a tree-like structure with labelled nodes, as follows: The objects of M_{A}, are called moves, ⊢_{A}⊆ (M_{A})_{∗} × M_{A} is a relation called enabling, such that the transitive closure of ⊢, hereditary enabling, is an irreflexive partial order. Moves enabled by the additional node ∗ added to M_{A} are said to be initial. L is a set of labels, and the labelling function λ_{A} : M_{A} → P(L) specifies the set of labels attached to each move.

In general l, m, n … will be used to denote the moves of an arena, and a, b, c, … to denote occurrences of these moves in sequences r, s, t.

Definition 3.2.2 For any sequences s, t, Occ(t) is the set of occurrences of moves in t, and s ⊑ t means ‘s is a prefix of t’, sa denotes the sequence s extended by the move a, and s·t the sequence s extended by the sequence t.

Attention will be restricted to finite sequences here, although transfinite plays remain an interesting possibility.

Definition 3.2.3 A justified sequence in an arena A, is a sequence of (occurrences of) moves s, together with a function ϕ : Occ(s) → Occ(s)_{∗} such that for every occurrence a of a non-initial move, ϕ(a) is an occurrence of a move preceding a, which enables it. (And if a is initial then ϕ(a) = ∗.) This relationship between occurrences of non-initial moves and a unique, preceding, enabling move, is called justification, and the function ϕ is said to define ‘justification pointers’ for each non-initial move. The set of justified sequences of an arena A is denoted J_{A}.

The prefix-ordering extends straightforwardly to justified sequences. The transitive closure of the justification relation on occurrences is referred to as hereditary justification.

3.2.2 Constructions on arenas

Arenas can be connected in a few simple ways.

Definition 3.2.4 Products A product of arenas is formed by placing its components ‘side by side’. For any set-indexed family of arenas {A_{i} | i ∈ I}, form the product A = Π_{i∈I}A_{i} as follows:

• M_{Π_{i∈I}A_{i}} = ∐_{i∈I} M_{A_{i}},

• ⟨m, i⟩ ⊢_{Π_{i∈I}A_{i}} ⟨n, j⟩ if i = j and m ⊢_{A_{i}} n, and ∗ ⊢_{Π_{i∈I}A_{i}} ⟨n, j⟩ if

∗ ⊢_{A_{j}} n,

• L_{Π_{i∈I}A_{i}} = ⋃_{i∈I} L_{A_{i}},

• λ_{Π_{i∈I}A_{i}}(⟨m, i⟩) = λ_{A_{i}}(m).

The empty arena, containing no moves (the empty product of arenas) is denoted 1.

Function Space This is an asymmetric version of the product arena; the set of moves is again a disjoint union with labelling inherited from the components, but the (formerly) initial moves of the arena which occurs negatively are enabled by the initial moves of the arena occurring positively.

• M_{A⊸B} = M_{A} + M_{B},

• ⟨m, i⟩ ⊢_{A⊸B} ⟨n, j⟩ if i = j and m ⊢ n

or m ∈ M_{B}, n ∈ M_{A} and ∗ ⊢_{B} m and ∗ ⊢_{A} n,
∗ ⊢ ⟨m, i⟩ if m ∈ M_{B} and ∗ ⊢_{B} m.

For m ∈ A × B, A ⊸ B, write m ⊏ −A if m is a move from the A component, etcetera.

Justified sequences over these constructions can be projected into their constituent components.

Definition 3.2.5 For a justified sequence s over an arena A, formed from subarenas B, C, … by the above constructions, the restriction s↾(B, C, …) is a justified sequence defined as follows: ε↾(B, C, …) = ε sa↾(B, C, …) = s if a ⊏̸ −B, C, … sa↾(B, C, …) = (s↾(B, C, …))a if a ⊏ −B, C, . . .. The justifier of a in sa↾(B, C, …) is the most recently played move from B, C, … which hereditarily justifies a. (If there is no such move, then a is initial.)

Similarly, a sequence can be restricted to the occurrences of moves hereditarily justified by some single occurrence.

Definition 3.2.6 Let s be a justified sequence in an arena A, and a an occurrence of a move of A in s. Then the ‘thread of a in s’, written s↾a, consists of the moves of s hereditarily justified by a, in the order in which they have occurred, with justification pointers from s.

Note that if s is a justified sequence such that s ∈ J_{A×B} or s ∈ J_{A⊸B}, then s↾A ∈ J_{A} and s↾B ∈ J_{B}. If a is initial, and s ∈ J_{A} then s↾a ∈ J_{A}. Even with this minimal amount of structure, a basic category of processes and agents (games and ‘pre-strategies’) can be defined, leaving scope for obtaining particular effects by applying different constraints.

Definition 3.2.7 The category A has arenas as objects: morphisms f : A → B are non-empty, prefix-closed sets of justified sequences (pre-strategies) over the function-space A ⊸ B. Following Abramsky and Jagadeesan [5], composition of strategies can be described as ‘parallel composition with hiding’: Given f : A → B and g : B → C f; g = (f∥g)/B = {s↾A, C | s ∈ f∥g}, where f∥g is the uncovering of f played against g: f∥g = {s ∈ J_{((A⊸B)⊸C)} | s↾(A, B) ∈ f ∧ s↾(B, C) ∈ g}. There is a difference here with previous definitions of composition in Hyland-Ong style games — the use of the restriction operation on justified sequences to ‘mend’ justification pointers following the ‘hiding’ of moves in B.

For any arena A, the identity morphism id_{A} : A → A is the ‘copycat’ which copies moves from the left hand component into the right hand and vice-versa.

Canonical morphisms are in general copycat strategies. They can be formalised (similarly to [6]) as follows.

Definition 3.2.8 Suppose F : A → B, G: B → A are order-preserving maps on arenas: i.e. partial functions from M_{A} to M_{B} such that: F (∗_{A}) = ∗_{B} and a ⊢ b if and only if F (b) defined implies F (a) defined and F (a) ⊢ F (b). Then let copy_{F,G} : A → B be the least set of justified sequences closed under the following definition:

• ε ∈ copy_{F,G}

• s (even − length) ∈ copy_{F,G}, and a ⊏ −A implies saF (a) ∈ copy_{F,G}

• s (even − length) ∈ copy_{F,G}, and b ⊏ −B implies sbG(b) ∈ copy_{F,G}

where the justifier of F (a) (or G(b)) is the move succeeding the justifier of a (or b).

Thus, for each arena A, if ID(A) is the identity map from A to itself,

id_{A} = copy_{ID(A),ID(A)}.

Definition 3.2.9 Suppose F : B → C is an order-preserving map of arenas. This naturally extends to maps F_{r}^{A} from justified sequences over A ⊸ B, to justified sequences over A ⊸ C, and F_{l}^{A} from J_{C⊸D} to J_{B⊸D}. F_{r}^{A}(ε) = ε F_{r}^{A}(sa) = F_{r}^{A}(s)a, if a ⊏ −A F_{r}^{A}(sb) = F_{r}^{A}(s)F_{r}^{A}(b), if b ⊏ −B where these are defined, with ϕ(F (a)) = F (ϕ(a)) for non-initial moves in B. So F_{r}^{A} sends morphisms on A → B to morphisms on A → C and F_{l}^{A} : A(C, D) → A(B, D).

Proposition 3.2.10 If F : B → C is an order-isomorphism of arenas, then for any pre-strategies f : A → B, and g : C → D f; copy_{F,F^{−1}} = F_{l}^{A}(f), and copy_{F,F^{−1}}; g = F_{r}^{A}(g).

Proof: Note that s ∈ copy_{F,F^{−1}} if and only if for all even prefixes t ⊑ s, F (t↾B) = t↾C. Hence by definition of parallel composition of strategies, sa ∈ f∥copy_{F,F^{−1}}, if and only if sa↾A, B ∈ f and F_{l}(t↾A, B) = F_{l}^{−1}(t↾A, C) for all prefixes t of s such that t↾A, B is even-length. Hence s ∈ f; copy_{F,F^{−1}} if and only if s = F_{l}(s′) for some s′ ∈ f; i.e. s ∈ F_{l}(f). □

For any pre-strategy f : A → A, ID(A)_{l}(f) = ID(A)_{r}(f) = f, so id_{A} is a well-defined identity.

Proposition 3.2.11 (A is a well-defined category)

Proof: It remains to show associativity of composition, for which it is sufficient to show that for pre-strategies f : A → B, g : B → C, h : C → D, f; g; h = (f; g); h = f; (g; h) (for which the cases are similar) where f; g; h = (f∥g∥h)↾(A, D), and f∥g∥h =

{s↾A ⊸ D | s ∈ ((A ⊸ B) ⊸ C) ⊸ D) ∧ s↾A, B ∈ f ∧ s↾B, C ∈ g ∧ s↾C, D ∈ h}

If s ∈ f; g; h, then there is some t ∈ ((A ⊸ B) ⊸ C) ⊸ D such that t↾A, D = s, and t↾A, B ∈ f, t↾A, B, C ∈ f∥g, hence t↾A, B, D ∈ (f; g)∥h, and t↾A, D = s ∈ (f; g); h. To prove the converse: Suppose s ∈ (f; g)∥h then by definition of composition, there is some t ∈ f∥g such that s↾(A, C) = t↾(A, C). It is sufficient to show by induction on length of s that there exists r ∈ f∥g∥h such that r↾A, D = s↾A, D and r↾A, B, C = t, and hence s↾A, D ∈ f; g; h. So given sa ∈ (f; g)∥h, and t · u ∈ f∥g, such that sa↾(A, C) = t · u↾(A, C) and s↾(A, C) = t↾(A, C), applying the inductive hypothesis to s yields r ∈ f∥g∥h such that r↾A, B, C = t, and r↾A, D = s↾A, D. Then either a is a move in D (so u = ε), and let r′ = ra, or a is a move in A, B, C, — let r′ = r · u. Then r′ ∈ f∥g∥h, and r′↾A, B, C = t · u, and r′↾A, D = s↾A, D as required. □

Proposition 3.2.12 The empty arena 1 is a terminal object in A, as A ⊸ 1 = 1 for any arena A.

Hence A ⊸ B ≅ 1 ⊸ (A ⊸ B) for any A, B, and so each morphism in A(A, B) has a unique ‘name’ in A(1, A ⊸ B).

Proposition 3.2.13 (Symmetric monoidal closure) A, ⊗, 1, ⊸, is a symmetric monoidal closed category, where A ⊗ B is the product of arenas A and B, the unit 1 is the empty arena, and A ⊸ B is the ‘function space’ arena defined above.

Proof: The isomorphisms of arenas Assoc : (A × B) × C → A × (B × C), I : A × 1 → A, and twist : A × B → B × A define copycat strategies which are the canonical morphisms for the monoid, and satisfy the coherence conditions for a symmetric monoid. For f : A → C and g : B → D

f ⊗ g = {s ∈ J_{(A⊗B)⊸(C⊗D)} | s↾A, C ∈ f ∧ s↾B, D, ∈ g}

Bifunctoriality of ⊗ (i.e. (f ⊗ g); (h ⊗ k) = (f; h) ⊗ (g; k) for f : A → C, g : B → D, h : C → E, k : D → F) is shown as follows. Suppose s ∈ (f ⊗ g); (h ⊗ k), then there exists t ∈ (f ⊗ g)∥(h ⊗ k) such that t↾A, C = f, t↾D, E ∈ g, t↾C, E ∈ h, t↾D, F ∈ k. Then t↾A, C, E ∈ f∥h, and t↾B, D, F ∈ g∥k, so s = t↾A, B, E, F ∈ f; h ⊗ g; k. To show that f; h ⊗ g; k ⊆ f ⊗ g; h ⊗ k: If s ∈ f; h⊗g; k, then there exists r ∈ f∥h such that s↾A, E = r↾A.E, and t ∈ g∥k such that s↾B, F = t↾B, F. It is sufficient to show by induction on length of s that there exists u ∈ f ⊗ g∥h ⊗ k such that s = u↾A, B, E, F, and r = u↾A, C, E, and t = u↾B, D, F, and hence s ∈ f ⊗ g; h ⊗ k as required. Suppose sa ∈ f; h ⊗ g; k, t ∈ f∥h, and r ∈ g∥k such that sa↾A, E = t · v↾A, E, and sa↾B, F = r · w↾B, F, and s↾A, E = t↾A, E, and s↾B, F = r↾B, F. Then there is some u ∈ f ⊗ g∥h ⊗ k, satisfying the inductive hypothesis with respect to s, r, t. Form u′ = u · v · w, satisfying the inductive hypothesis with respect to sa, r · v, t · w. Finally, there is an order isomorphism LAMBDA_{A,B,C} : A ⊗ B ⊸ C≅ A ⊸ (B ⊸ C), which defines an adjunction between ⊗ A and A ⊸ . Writing, ’f‘ : A → B for the inverse to the naming operation: Λ(f : A ⊗ B → C) = ’Λ_{r}(‘f’)‘. The copycat strategy App_{A,B} : (A ⊸ B) ⊗ A → B = LAMBDA_{A,B,A⊸B}^{−1}(‘id_{A⊸B}’) is the co-unit. □

3.3 Rules and Games

If arenas give a general notion of subject for debate, or type, games correspond to a more specific, and more extensional notion; the interactions possible under a given set of rules. To define games, the labelling on the moves is used, along with rules which govern when they can be played.

Definition 3.3.1 A rule consists of a pair ⟨R, L_{R}⟩ of a predicate R on justified sequences, with a set L_{R} of ‘R-relevant’ moves. So the labelling function λ_{A} can be ‘projected’ to a function λ_{A}^{R} : M_{A} → L_{R}, where λ_{A}^{R}(m) = λ_{A}(m) ∩ L_{R}.In cases where λ_{A}^{R} is always either empty or a singleton, λ_{A}^{R} may be given as a partial function from M_{A} to L_{R}. The predicate R must satisfy the following requirements:

Prefix Closure s ⊑ t implies R(t) ⟹ R(s)

R-relevance R(s) ∧ λ^{R}(a) = ∅ ⟹ R(sa).

Note that because equality of justified sequences is defined only in terms of having the same justification pointers, and labellings on moves, a rule can only ‘observe’ these properties, and not, for instance, whether a sequence was generated from a particular arena. The rules discussed in this thesis can be easily seen to have these properties, as they can be given as inductive definitions of the form: ‘R(sa) if and only if R(s) and λ^{R}(a) ≠ ∅ ⟹ Φ_{R}(s, a)’, where Φ_{R} is a formula in a semi-formal ‘language of justified sequences’ containing predicates such as “s is a prefix of t”, “a is the justifier of b in t” and so on.

For a finite set of rules R = {⟨r_{1}, L_{1}⟩, … ⟨r_{n}, L_{n}⟩}, R will also be used, by abuse of notation, to denote their conjunction, ⟨r_{1} ∧ … ∧ r_{n}, L_{1} ∪ … ∪ L_{n}⟩

Proposition 3.3.2 The conjunction of of well-defined rules is a well defined rule.

Since each rule is directly relevant to a labelling λ_{A}^{R} : M_{A} → P(L_{R}), and applies to moves only on which this labelling is defined, rules can be relaxed over an arena simply by removing labels.

Definition 3.3.3 Given an arena A and a set of moves M ⊆ M_{A}, the rule R is relaxed on M in A to give a new arena A′ by removing all of the relevant tags from the moves, — i.e. defining A′ = ⟨M_{A}, ⊢_{A}, L, λ_{A′}⟩ where λ_{A′}(m) = λ_{A}(m)/L_{R} if m ∈ M, and λ_{A′}(m) = λ_{A}(m) otherwise. If a rule is relaxed over the entire arena (M = M_{A}) to form A/R then it is said to have been abandoned.

Definition 3.3.4 A game is a set of justified sequences of moves which is specified (up to equality of justified sequences) by some arena and rule. For a rule set R, and arena A, R(A) will denote the game with arena A, and plays subject to the rules R, i.e.

R(A) = {s ∈ J_{A} | R(s)}

Thus games are in some sense more extensional objects than the arenas which ‘realize’ them, although this should not be confused with the (more significant) point that strategies are intensional.

Proposition 3.3.5 For any rule-set S containing a rule R, and arena A, the game specified by abandoning R on A and applying S, is equivalent to applying S without R to A (S/{R})(A) = S(A/R).

Proof: is direct by definition. □

A strategy on a game G is a prefix-closed set of even-length plays in G.

Definition 3.3.6 For any rule R, form the ‘category’ G_{R} with objects: games R(A) for some arena A morphisms from A to B: pre-strategies on R(A ⊸ B), with composition defined using uncovering:

σ; τ = {s↾A, B | s ∈ σ∥τ ∧ R(s↾A, B)}.

In order for this to define a SMCC [51], it is necessary to make the following further requirements of rules:

Copycats: If F : A → B is an isomorphism of arenas, then R(copy_{F,F^{−1}}) : R(A ⊸ B) = {s ∈ copy_{F,F^{−1}} | R(s)} is an isomorphism. So, in particular,

for each A, R(copy_{ID(A),ID(A)}) is an identity on R(A).

Associativity: If s ∈ ((A ⊸ B) ⊸ C) ⊸ D is such that R(s↾A, B), R(s↾(B, C)), R(s↾(C, D)), and R(s↾(A, D)) then R(s↾(A, C)) if and only if R(s↾(B, D)). To show that this means that composition is associative, suppose R is associative, and σ : A → B, τ : B → C and ρ : C → D. Then if s ∈ (σ; τ); ρ, by Proposition 3.2.11 there exists t ∈ ((A ⊸ B) ⊸ C) ⊸ D such that t↾A, B ∈ σ, t↾(B, C) ∈ τ, t↾(C, D) ∈ ρ and t↾A, D = s, and R holds of all these subsequences. So by assumption, R(s↾(A, C)) implies R(s↾(B, D)), so s ∈ σ; (τ; ρ). The converse is entirely similar, so (σ; τ); ρ = σ; (τ; ρ) as required.

Proposition 3.3.7 Each category G_{R} defined from such a rule R is symmetric monoidal closed.

Proof: For games R(A), R(B), define the tensor product and exponential, R(A) ⊗ R(B) = R(A ⊗ B), and R(A) ⊸ R(B) = R(A ⊸ B). The isomorphisms of arenas between A × B and B × A, (A × B) × C and A × (B × C) and (A × B) ⊸ C and A ⊸ (B ⊸ C) define isomorphisms in G_{R} by Definition 3.3.6, so the proof of symmetric monoidal closure goes through just as in Proposition 3.2.13. □

A result which depends on using rules and arenas to specify games is the following.

Proposition 3.3.8 Every game is specified by an arena which is a forest. (i.e. one in which every non-initial move is enabled by a unique move).

Proof: is for finite arenas, but can be extended to arenas of any size. Call a move a ‘branching node’ if it is enabled by two or more different moves. Then a finite arena is a tree (with respect to hereditary enabling) if it contains no branching nodes. So the proof is by induction on the number of branching nodes, that every arena is play-equivalent to a tree. Assuming A is not a tree, choose m ∈ M_{A} such that n_{i} ⊢_{A} m : i ≤ k for some distinct n_{1}, n_{2}, … n_{k} ∈ M_{A}, but there is no branching node hereditarily enabled by m. Let A↾m be the arena of moves hereditarily enabled by m (including m) with enablings as in A. Define the arena A′ to be the same as A, except that it has a separate copy of the subtree A↾m attached below each n_{i}. Then A′ has fewer branching nodes than A, and J_{A} = J_{A′}, as in any justified sequence over A, each occurrence of m is justified by a unique occurrence of some n_{i}, which defines an obvious isomorphism of justified sequences (which preserves the labelling on occurrences of moves). Hence R(A) = R(A′) for any rule R. □

Note that the one-move arena, o, with a single move (appropriately labelled), is sufficient to define all finite arenas using the function space and product constructions.

3.4 ‘Linear’ Games

This section describes a cartesian closed category and associated ‘linear decomposition’ of a category of games, based on a single rule. The notion of linear decomposition is borrowed from (intuitionistic) linear logic [29] and its categorical models [11], but the purpose is not to define a full linear type structure. Instead linearity is used to analyze how restricting repetition of moves can define sound and complete models of control (i.e. pointed CCCs) and identify strategies which correspond to functional programs with local control. This is organised along the lines of [6] and [59]; in addition to the SMCC, a cartesian product and co-monad ! such that !(A × B) ≅!A⊗!B are described, so that the co-Kleisli category of the ! is cartesian closed. So the ‘intuitionistic’ function type A ⇒ B is modelled as !A ⊸ B.

The novel feature is that this is done using a notion of ‘linear’ move. The role of the ! can then be explained in terms of relaxing linearity. In addition, using distinguished moves to define linear connectives will allow the ‘bracketing condition’, describing local control flow, to be presented and analyzed using the decomposition of classical and intuitionistic types into linear logic.

Definition 3.4.1 (Linearity rule) Any two distinct linear moves (those labelled ‘L’) occurring in the same justified sequence have different justifiers. More formally: L(sa) if λ^{L}(a) = L implies that for all b ∈ Occ(s), λ^{L}(b) = L implies ϕ(a) ≠ ϕ(b). (Note that non-initial linear moves can occur more than once, so long as the different occurrences have different justifiers.)

However, there is a problem with this rule: — associativity of composition fails. (This is an old problem, going back to Blass’ game semantics of linear logic ([13], see also [5]).

Proposition 3.4.2 Composition of strategies on linear games is not associative.

Proof: Consider the following games and strategies ρ : A ⊸ B and σ : B ⊸ A, where the initial move of B is linear, but the initial move of A is not (otherwise they are the same) ρ and σ just play copycat, which are valid strategies, as if B repeats its initial move, the repeated linear move made in A is justified by the new move. Hence ρ; σ = id_{A}, and so (ρ; σ); τ = τ for any τ : A ⊸ C. But suppose τ repeats the initial move in A, justified by the same initial move of C (again legitimate, as this is not a linear move). But this cannot be the restriction to A ⊸ C of a sequence in σ∥τ, however, as such a sequence would also contain the initial move in B twice, justified by the same move, violating linearity. Hence this play is not in ρ; (σ; τ) either. Thus ρ; (σ; τ) ≠ τ. □

This problem is caused by the possibility of forming arbitrary constructions with linear moves. The solution adopted here is to restrict some of these possibilities.

Definition 3.4.3 An arena is well-opened if all of its initial moves are linear. An arena is freely-opened if none of its initial moves are linear.

Compare this with McCusker’s definition of well-openedness for games [59] (Hyland-Ong games are implicitly defined to be well-opened):

Definition 3.4.4 A game G is well-opened if sa ∈ G and a is initial implies s = ε.

So under the linearity rule, the well-opened games are precisely those specified by a well-opened arena. Well and freely opened games can also be combined.

Definition 3.4.5 The category of well-opened games W, has well-opened games as objects and pre-strategies on A ⊸ B as morphisms. The category of freely-opened games F, has freely-opened games as objects and pre-strategies on A ⊸ B as morphisms. The well and freely opened games form a category O in which Objects are the well-opened and the freely opened games. Morphisms from A to B are pre-strategies on A ⊸ B, provided that A is wellopened implies B is well-opened (if A is freely opened and B is well-opened then O(A, B) is defined to be empty).

In none of these cases can the pathology described above arise, and without this possibility, associativity of composition is implied by the stronger property of compositionality.

Definition 3.4.6 A rule is compositional if for all s ∈ (A ⊸ B) ⊸ C, R(s ↾ A, B) and R(s ↾ B, C) implies R(s ↾ A, C), so that if σ : R(A ⊸ B) and τ : R(B ⊸ C) then σ; τ is a set of plays in R(B ⊸ C).

Proposition 3.4.7 Linearity of moves is compositional, and hence the categories of well and freely-opened games and its subcategories of well-opened, and freely opened games are well-defined.

Proof: Suppose s ∈ (A ⊸ B) ⊸ C, and L(s↾A, B), L(s↾B, C) , so L(s↾A) and L(s↾C). Thus the only possible violation of linearity in L(s↾A, C) is if some initial move in A is linear, but an initial move in C is not. But if C is not well-opened, then A is freely opened, so this impossible. The copycat strategy L(id_{A}) is an identity in the category, as moves in s ∈ id_{A}∥f : A ⊸ B are repeated with the same justifier only if they are repeated in s↾A, B ∈ f with the same justifier, and are therefore not linear. □

The product of a well-opened and a freely opened arena is neither well, nor freely opened, so this will not in general specify a well-defined operation in O. However, it can be applied in both of its subcategories, with different results.

Proposition 3.4.8 The product of arenas (Definition 3.2.4) defines a cartesian product on the category of well-opened linear games.

Proof: For well-opened games L(A) and L(B), define

L(A)&L(B) = L(A × B)

which is also well-opened. Then L(A)&L(B) = {s ∈ J_{A×B} | s ∈ L(A) ∨ s ∈ L(B)}, — since the initial move is unique, it must represent a choice to play in one of the two components for the rest of the game. (Note that this is the definition of cartesian product of AJ games, and in [59] etcetera.) So for maps f_{1} : L(A) → L(B), f_{2} : L(A) → L(C) there is a unique pairing

⟨f, g⟩ = {s ∈ L(A) ⊸ (L(B)&L(C)) |s ⊏ −f ∨ s ⊏ −g}

such that ⟨f_{1}, f_{2}⟩; π_{i} = f_{i}. (The pairing operation for the tensor exists, but is not unique.) □

Not only is the subcategory of freely opened games a symmetric monoidal closed category with respect to ⊗, ⊸, but the closure extends over the combined category in the following sense.

Proposition 3.4.9 For any freely opened game B, the map B ⊸ : O → O is functorial, and the co-unit of the adjunction between (B ⊸ )↾F and ⊗ B

App : ((B ⊸ C) ⊗ B) → C

extends (with its co-universal property) to all objects C of O. i.e. O(A ⊗ B, C) ≅ O(A, B ⊸ C) for any C.

Proof: is by extension of Proposition 3.2.13. □

3.4.1 The linear exponentials

The linear exponentials, ! and its dual ?, are introduced to linear logic to restore the possibility of performing structural rules, with some measure of restraint. The various translations of classical and intuitionistic types and proofs into linear logic [29], [22], [31] are based upon the ‘decoration’ of linear formulas with sufficient exponentials to permit the translation of all of the structural rules in the proof. Such linear decomposition of the Hyland-Ong games has already been given, in a different form, by McCusker. The main difference here is that the ! is modelled as a local relaxation of the linearity conditions. Thus there is a direct connection between the linear decomposition, and decoration, and the global relaxation of the linearity conditions. In the presence of the global rules applied in [59] (visibility and well-bracketing) the interpretation of the relevant parts of the negative fragment (!, ⊗, &, ⊸) proves to be play-equivalent to McCusker’s, so [59] is an important source of detail. Both constructions are somewhat ad hoc, because the Hyland-Ong games lack the structure to support the full range of linear types satisfactorily. (The problem with the ! in [59] is that it is not a co-monad, as there is in general no interpretation of the ‘dereliction map’ !A ⊸ A. McCusker goes on to show, however, that a true co-monad can be defined (an infinite tensor product with an equivalence on strategies) which yields an equivalent CCC as its co-Kliesli category.) Combining the well and freely opened games in a single category here allows the ! to be described as a co-monad (at the cost of some restriction of symmetric monoidal closure).

In order to define a co-monad, attention is restricted to a certain subset of the pre-strategies, essentially those identified in [4] as being thread independent.

Definition 3.4.10 A (pre-)strategy σ : A is thread-independent if sa, t ∈ σ and (s↾c) = t↾c (where c is the initial move hereditarily justifying a) then ta ∈ σ.

So thread-independent strategies are defined by their sets of threads. They are employed (with a notion of polarity and determinacy) by Abramsky, McCusker and Honda to give a semantics of general references [4].

Proposition 3.4.11 The thread-independent pre-strategies on linear games form a well-defined category.

Proof: The identity is thread-independent, since s ∈ id_{A} if and only if r↾c ∈ id_{A} (c initial) for every prefix r ⊑ s. Hence if sa, t ∈ id_{A} and s ↾ c = t ↾ c, then sa↾c ∈ id_{A}, so ta↾c ∈ id_{A}, so ta ∈ id_{A}. The composition of thread-independent strategies σ : A → B and τ : B → C is thread-independent. First observe that the uncovering σ∥τ is itself ‘thread independent’. Suppose sa↾b ∈ σ∥τ, and t ∈ σ∥τ. Then by thread independence of σ, τ, ta↾A, B ∈ σ, and ta↾B, C ∈ τ, hence ta ∈ σ∥τ. The difficulty for going on to prove thread-independence for σ∥τ ↾B, C is that t↾A, C↾a = s↾A, C↾a does not necessarily imply that t↾a = s↾a; the parts of the thread which are hidden may be different. However, threads are in some sense interchangeable, as shown below.

Lemma 3.4.12 Suppose s, t ∈ σ∥τ, where s is single threaded (well-opened), and there is an initial move a in t such that t↾a↾A, C = s (but this is not necessarily the current thread). Then there exists t′ ∈ σ∥τ such that t′↾A, C = t↾A, C, and t′/(t′↾a) = t/(t↾a) and t′↾a = s.

Proof: is by induction on the length of t: Suppose s, tb ∈ σ∥τ, and tb↾a↾A, C = s. Suppose b is not hereditarily justified by a, then by inductive hypothesis there exists t′ ∈ σ∥τ such that t′ ↾A, C = t↾A, C, and t′/(t′ ↾a) = t/(t↾a). Thus in particular t′↾c = t↾c, where c hereditarily justifies b. So by thread independence of σ∥τ, t′b ∈ σ∥τ, and t′b satisfies the above conditions. Suppose b is hereditarily justified by a, then either b ⊏ −B — in which case the t′ satisfying the inductive hypothesis for t will also satisfy it for tb, or b ⊏ −A, C, so s = s′b · u for some suffix u of moves wholly in B, and justified by a. Then by inductive hypothesis there exists t′ ∈ σ∥τ such that t′↾A, C = t↾A, C, and t′/(t′ ↾ a) = t/(t ↾ a), and t′ ↾ a = s′. By repeated applications of thread independence, t′b · u ∈ σ∥τ, (and t′b · u satisfies all of the other conditions as well). □

So to show thread independence of σ; τ, suppose sa, t ∈ σ; τ, and sa↾b = ta↾b. Then by the lemma there exists t′a ∈ σ∥τ such that t′↾A, C = t, and t↾A, C↾b = sa↾b, and hence t′c↾A, C = ta ∈ σ; τ.

Definition 3.4.13 For any arena, A, obtain !A by relaxing the linearity condition on the initial moves of A. For any game G = L(A),

!G = L(!A).

For thread-independent σ : A → B, define the pre-strategy !σ to be the least prefixclosed set of sequences of L(!A ⊸!B) such that if s ∈!σ, and sa↾b ∈ σ, for some b hereditarily justifying a, then sa ∈!σ.

The following facts are immediate:

• the image of ! is the category of freely opened games and thread-independent strategies,

• its restriction to that category is the identity,

• hence it is idempotent.

Proposition 3.4.14 ! is a co-monad on the category of well and freely opened games and thread-independent strategies.

Proof: ! is an endofunctor on O: For σ : A → B, τ : B → C, !(σ; τ) =!σ; !τ: — proof is by induction on sequence length. Suppose sa ∈!(σ; τ), so that s ∈!σ; !τ by hypothesis, and sa↾b ∈ σ; τ, and hence sa↾b ∈!σ; !τ so by thread-independence of !σ; !τ, sa ∈!σ; !τ as required. If sa ∈!σ; !τ, then s ∈!(σ; τ), and there exists t ∈!σ∥!τ such that t↾A, C = sa. t↾b↾A, B ∈ σ, and t↾b↾B, C ∈ τ, by thread independence, hence t↾A, C↾b = sa↾b ∈ σ; τ, and so sa ∈!(σ; τ), by definition of !. There are natural transformations, — dereliction, der :! → Id, and promotion, prom :!! →!. But these are both trivial copycats as ! =!!, and der_{A} :!A → A is just given by the same function from threads to moves as the identity. For A, B ∈ O which are both well-opened or freely opened

!(L(A)&L(B) =!L(A × B) =!L(A)⊗!L(B)

so in particular, there is a contraction map con_{A} :!A ⊸!A⊗!A which is the strategy !δ_{A}, where δ : A → A × A is the diagonal map for ×. The following naturality property for contraction is then reducible to functoriality of ! and ×.

\xymatrix{!A \ar[d]_{!σ} \ar[r]^{^{con^{A}}} & !A⊗!A \ar[d]^{!σ⊗!σ} \\ !B \ar[r]_{_{con_{B}}} & !B⊗!B}

□

Since ! is a co-monad, it has a co-Kleisli category, O_{!}, which has the same objects as O, and as morphisms from A to B, thread-independent strategies on !A ⊸ B.

Proposition 3.4.15 O_{!} is cartesian closed.

Proof: The generalised product has been shown to be cartesian on well-opened games; it remains to show cartesian closure. O_{!}(A × B, C) = O(!(A × B), C) = O(!A⊗!B, C). By the extended symmetric monoidal closure (Proposition 3.4.9) O(!A×!B, C) ≅ O(!A,!B ⊸ C) = O_{!}(A, B ⇒ C) as required. □

Thus a global relaxation of the linearity rule yields a CCC.

Corollary 3.4.16 The category of arenas and thread-independent pre-strategies (the image of the well-opened games under !) is cartesian closed.

3.5 Two-player arenas

A fundamental and distinctive aspect of game semantics is that interaction is modelled as a dialogue between different agents. The simplest and most important case simply distinguishes ‘Player’, — the system, from the rest of the world, — the environment (‘Opponent’). Games need not be seen as competitive, however, but as co-operative efforts between program and input, to produce a useful result.

Definition 3.5.1 An alternating arena, ⟨M, ⊢, {O, P } ⊆ L, λ⟩ is an arena in which the set of moves is partitioned between Opponent ‘O-moves’ and Player ‘P -moves’. In other words, the projection of the labelling function as λ^{OP} : M → \{O, P \} is total. (Sometimes the complementarity \overline{O} = P, \overline{P} = O will be used.) It is further required that

• All initial moves are Opponent’s: ∗ ⊢ m implies λ^{OP} (m) = O,

• Enabling alternates between Opponent and Player: m ⊢ n implies λ^{OP} (m) = \overline{λ^{OP} (n)}.

Definition 3.5.2 A justified sequence satisfies the alternation rule if its moves are made alternately by Player and Opponent: A(sab) if and only if A(sa) and λ^{OP} (b) = \overline{λ^{OP} (a)}.

Now that there is a notion of polarity, pre-strategies can be refined to strategies.

Definition 3.5.3 A strategy on game A is a non-empty even-prefix-closed set of alternating sequences in A.

The adjustment from pre-strategies as prefix-closed sets, and strategies as evenprefix closed does not radically alter the structure which has been built up so far. A pre-strategy over an alternating game can be transformed to a strategy by erasing all of its odd-length sequences. Odd-length sequences are re-introduced to strategies in a limited way, to represent escapes, in Chapter 5, Section 5.3.2.

In fact, it is necessary to modify the definition of the ‘function space’ construction ⊸ slightly in order to define an alternating arena, as the initial moves of A in A ⊸ B were originally Opponent moves, but are justified by the initial (Opponent) moves of B. (Suggesting that alternation is a rather more fundamental kind of rule to the others considered here.) The solution is to invert the Player/Opponent labelling on moves in A, in accordance with the fact that A appears negatively.

Definition 3.5.4 Form the alternating function-space arena A ⊸ B as in Definition 3.2.4, except that λ_{A⊸B}^{OP}(m) = λ_{B}^{OP} (m), if m ⊏ −M_{B}, λ_{A⊸B}^{OP}(m) = \overline{λ_{A}^{OP} (m)}, if m ⊏ −M_{A}.

However, the ‘switching condition’, (of [5], for instance) which says that Opponent must play in the same component as the previous move in a game A ⊸ B (and similarly Player must do so in A⊗B) is neither implicitly nor explicitly included in this definition (it does not hold in the games model of references [4], for instance).

Composition of strategies over alternating arenas is defined as for pre-strategies, except that the Player/Opponent labellings on arenas of the form (A ⊸ B) ⊸ C are ignored (necessarily, as there is no coherent way to label the moves in the B component). The labelling is restored by inference from the ‘alternation of justification’: i.e. initial moves of s↾A, C are Opponent moves, and the polarity of any other move is the complement of its justifier.

Proposition 3.5.5 Alternation of even-length sequences is a well defined rule, and the category of alternating games and strategies is well-defined.

Proof: Prefix closure and invariance under isomorphism is obvious. For any alternating arena A, every justified sequence in id_{A} is alternating, as each odd (Opponent) move is followed by a copy from the other component, which will have complementary polarity by the Player/Opponent inversion described above. To show associativity, first note that a sequence s of even-length is alternating if and only if for every even segment t (continuous subsequence) of s, the number of Opponent and Player moves is equal (write O(t) = P (t)). Suppose s ∈ ((A ⊸ B) ⊸ C) ⊸ D is such that all of (s↾A ⊸ B), (s↾B ⊸ C), (s↾C ⊸ D), (s↾A ⊸ D) are alternating and even length. Then it is necessary to show that s↾A ⊸ C is alternating and even-length if and only if s↾B ⊸ D is (for which the two cases are entirely similar). Proof is by induction on sequence length, so suppose every even segment of s↾ A ⊸ C is alternating and even-length. Then by induction, every proper even segment of s↾B ⊸ D is alternating. So it is sufficient to show that O(s↾A, C) = P (s↾A, C) implies O(s↾B ⊸ D) = P (s↾B ⊸ D). But O(s↾B ⊸ D) = O(s↾A ⊸ D) + O(s↾B ⊸ C) − O(s↾A ⊸ C) = P (s↾A ⊸ D) + P (s↾B ⊸ C) − P (s↾A ⊸ C) = P (s↾B ⊸ D) as required. □

Note that the alternating version of the one-move arena, o, specifies the one move game, as there are no Player responses. This game will also be written o.

Strategies are further required to be deterministic, although there is clearly scope to study the semantics of concurrent languages by allowing non-determinism (this ‘axis of the intensional hierarchy’ is currently being explored by Harmer [34]).

Definition 3.5.6 (Deterministic Strategies) A strategy is deterministic if

sa, sb ∈ σ ⇒ a = b.

Thus a deterministic strategy on G is determined by a partial function from oddlength sequences of moves in G (situations with player to move) to justified moves. As expected, the identity strategy (and all other copycats), are deterministic strategies, and determinacy is preserved by composition.

It has now been established that the category of of alternating games and thread-independent deterministic strategies is a pointed CCC (with the one-move game as answer object), and so this specifies call-by-name and call-by-value models of control, via the families construction and the monad of o-continuations.

Proposition 3.5.7 (G_{alt}, o) specifies a continuous computational model of control.

Proof: G_{alt} is cpo-enriched with the inclusion ordering on strategies as sets of plays, which is complete, as for any chain {σ_{i} : A | i ∈ ω} (or directed set), ⋃_{i∈ω} σ_{i} is a thread-independent strategy. Moreover, composition in the cartesian closed category is continuous with respect to this ordering, because:

• composition by ‘parallel composition with hiding’ in the symmetric monoidal category is clearly continuous,

• the promotion operation for the co-monad ! preserves least upper bounds: σ^{†} :!A ⊸!B is defined by the same function from single threads to moves as σ :!A ⊸ B and hence for any chain ⋃_{i∈ω} τ_{i}^{†} = (⋃_{i∈ω} τ_{i})^{†}.

McCusker shows in [59] that recursive domain equations can be solved in categories of games such as G_{alt}. In particular, G has ω-indexed products as a particular case of the generalized product (Definition 3.2.4).

Definition 3.5.8 Given any arena A, define the arena A^{ω} = Π_{i∈ω}A. For any i, there are obvious (partial) structure-preserving maps E_{i} : A^{i} → A^{ω}, P_{i} : A^{ω} → A^{i} such that E_{i}; P_{i} = ID_{A^{i}} and ⨆_{i∈ω} P_{i}; E_{i} = ID_{A^{ω}}. So the embedding and projection pairs for the countable product are given by e_{i} : A = copy_{F,G}, and p_{i} = copy_{G,F}.

□

3.6 Views and innocence

Following Hyland and Ong, constraints on games and on strategies which reflect functional behaviour by restricting access to the history of the computation can now be described. The Player and Opponent views of a justified play give a notion of ‘relevant history’ which proves important for understanding several aspects of the intensional hierarchy. They are related to the restriction operation which projects the current ‘thread’ of play, and defines the thread-independent strategies, but in quite a subtle way.

Definition 3.6.1 (Player and Opponent views.)

The Player view of a finite, justified alternating sequence s, is written ⌜s⌝ and defined inductively on the length of s, as follows ⌜ε⌝ = ε. ⌜sa⌝ = ⌜s⌝a, if a is a P-move. ⌜sa⌝ = a, if ∗ ⊢ a. ⌜sa · tb⌝ = ⌜s⌝ab, if b is an O-move justified by a.

There is a dual notion of Opponent view, ⌞s⌟: ⌞ε⌟ = ε. ⌞sa⌟ = ⌞s⌟a, if a is an O-move. ⌞sa · tb⌟ = ⌞s⌟ab, if b is a P-move justified by a.

In order for the (Player or Opponent) view of a justified sequence to be a justified sequence itself, he must respect the constraint of visibility.

Definition 3.6.2 (Visibility) A justified sequence sa obeys the visibility rule V, if for every occurrence a in s, the unique move in s justifying a is in the view (of whoever is making the move a). V (sa) ⟺ V (s) ∧ sa even ⟹ ϕ_{s}(a) ∈ Occ(⌜s⌝) ∧ sa odd ⟹ ϕ_{s}(a) ∈ Occ(⌞s⌟).

As noted in the previous section, games without the visibility condition, and thread-independent strategies, form a cpo-enriched CCC, and hence a basis for models of PCF. Moreover, Abramsky, Honda and McCusker showed in [4] (in essence) that as well as PCF, higher-type references can be interpreted in this category. This built on the work of [2] which gave semantics of ground-type assignments by dropping the condition of innocence on strategies (see Section 3.6.1). As visibility can be considered as a rule applying only to Player strategies (which is sufficient for Player views to be justified sequences) the innocent strategies satisfying this rule form the purely functional core of this model, which can be shown to be finitely definable using the results for PCF on its own. There are factorization results showing that all thread-independent strategies can be written as the composition of one obeying visibility (and innocence), and some canonical representation of storage cells. These results were obtained in the presence of an additional rule, — the ‘bracketing condition’, but they extend naturally to control models as well. Anticipating the definability result for the innocent games model of μPCF, the following working hypothesis can be given: the models of control generated from the CCC of thread-independent strategies, and the one move game are fully abstract for μPCF with higher-order references. The work that remains to be done to prove this concerns soundness and adequacy. The model without visibility is not yet well understood; the wild behaviour of strategies can be counterintuitive. With the the addition of control operators, things become even more complicated, one can use references and call/cc to store continuations and invoke them in unusual places.

The visibility rule is assumed to apply to all plays of the games considered henceforth (these are the ‘legal’ sequences, as in [43] etc.). This, however, is the only rule strictly required for the initial games model of control.

Definition 3.6.3 An ‘unbracketed’ game is one generated from an alternating arena by the rule visibility alone. (So called because the major difference from the games of Hyland-Ong and McCusker is the absence of a bracketing condition.)

The following results about visibility appeared in [43].

Proposition 3.6.4 Every Player and Opponent view of a sequence satisfying visibility is a well-formed justified sequence.

Proof: is straightforward by induction on sequence length. □

Closure under views can thus be added retrospectively as a well-definedness criterion for rules (it is satisfied by linearity and alternation). The following properties of plays satisfying visibility appear previous work such as [5],[6], [59] (often in definitions of games), going some way to explaining the significance of this rule as a measure of ‘good behaviour’.

Proposition 3.6.5 (Switching condition) if sab ∈ V (A ⊗ B) is an evenlength sequence then a ⊏ −M_{A} implies b ⊏ −M_{A} and a ⊏ −M_{B} implies b ⊏ −M_{B}. (Similarly if sab ∈ V (A ⊸ B) is an odd-length sequence such that b is in the same thread as a (or B is well-opened), then a ⊏ −M_{A} implies b ⊏ −M_{A} and a ⊏ −M_{B} implies b ⊏ −M_{B}.)

Proof: is by induction on sequence length, showing that if Opponent’s last move in s ∈ V (A ⊗ B) is in A, then ⌜s⌝ is wholly in A, so Player’s next move must be in A, and if Opponent’s last move is in B then ⌜s⌝ is wholly in B. □

Proposition 3.6.6 (Projection condition) For unbracketed games A, B A ⊗ B = {s ∈ J_{A⊗B} | s↾A ∈ A ∧ s↾B ∈ B}, A ⊸ B = {s ∈ J_{A⊸B} | s↾A ∈ A ∧ s↾B ∈ B}, !A = {s ∈ J_{!A} | ∀a (initial) s↾a ∈ A}.

Proof: is in [43] (in essence). It is also a corollary of Lemma 5.4.9, in which it is shown that the projection condition holds for plays which are innocent. □

Each additional rule R preserves the projection condition provided that for s ∈ V (A ⊸ B), R(s) implies R(s↾A) and R(s↾B).

Proposition 3.6.7 The unbracketed games form a category.

Proof: The identity strategy always obeys the visibility condition with respect to Player moves: If sab ∈ id_{A} then b is a copy of a, and is justified by the move preceding the justifier of a, (of which the latter is a copy). This is the penultimate Opponent move in the view. Associativity is a consequence of the fact that the visibility rule is compositional (i.e. the composition of strategies satisfying the visibility condition satisfies the visibility condition.) The is proved in depth in [59] following [43]. It is a corollary of the fact that innocent strategies compose, which is established in there and indirectly in Section 3.7. □

3.6.1 Innocent functions and strategies

The cartesian closed category of well-opened games and strategies was constructed by placing a linearity constraint on (initial) Opponent moves. Composition of well-opened strategies was defined using a projection from games without this constraint (restriction to the current thread). The projection also defined (as its image) a cartesian closed subcategory of the well-opened games, — the threadindependent strategies.

In order to identify the functionally definable part of this CCC, corresponding constraints and projections are applied to all of the Opponent moves and threads in a game. This defines the innocent functions, — strategies which have responses only to sequences in which Opponent plays linearly, using the Player view to project less restricted sequences into these games. The image of this projection consists of the innocent strategies [43].

Definition 3.6.8 An innocent function on an arena A is an even-prefix-closed and evenly branching set of Player views of plays in A. This definition can be expressed in another way, by saying that an innocent function is a deterministic strategy on the game obtained by labelling all of the Opponent moves in A as linear. The views act as a projection from sequences in A to sequences in the ‘Opponent-linear’ game with the same arena.

Each innocent function χ: A defines a strategy on the unbracketed game A by composition with the view-function from sequences to views. Or this can be written as a set of traces.

Definition 3.6.9 For an innocent function χ, define the strategy σ_{χ} as the inductive closure of the following definition (assuming sequences are alternating and justified): ε ∈ σ_{χ}, s ∈ σ_{χ} ∧ ⌜sab⌝ ∈ χ ⟹ sab ∈ σ_{χ} (So σ_{χ} satisfies visibility.)

The image of this embedding consists of the ‘innocent strategies’.

Definition 3.6.10 A strategy is innocent if its moves are determined only by the view of the game so far: i.e.

sab, t ∈ σ ∧ ⌜sa⌝ = ⌜ta⌝ ⇒ tab ∈ σ.

Note that this includes a certain ‘liveness’ condition which is redundant in the setting of unbracketed games; not only does a strategy have the same response to every view, if it ever has a response to a given view, that response is always valid, hence.

Proposition 3.6.11 An innocent function χ specifies an innocent strategy on a game G if s ∩ G is even-length for all s ∈ σ_{χ}.

Definition 3.6.12 For any strategy σ : A, let ⌜σ⌝ = {⌜s⌝ | s ∈ σ}, so that ⌜σ⌝ is an innocent function on A if σ is an innocent strategy on R(A). Define the composition of innocent functions: χ : A → B and ψ : B → C: χ; ψ = ⌜σ_{χ}; σ_{ψ}⌝.

For this definition to make sense, it is to show that the composition of innocent strategies is innocent. This is a non-trivial fact which is verified (for wellopened, well-bracketed games) in [43], and [59], and, less directly, in the proof of full and faithful completeness in the next section. For the moment, assume that the composition of innocent, unbracketed strategies is innocent. So the unbracketed games and innocent strategies form a category, which will be written G. The following proposition is a formalization of the remark made above, that views/innocence are a generalization of thread projection/thread-independence. This an important part of the proof of definability.

Proposition 3.6.13 (Bang lemma) For any innocent strategy σ : A,

χ_{!σ} = χ_{σ}.

Proof: is by noting that only (part of) the current thread is visible to Player, i.e. the Player view of s ∈ P_{!A⊸!B} is the same as the Player view of s↾a ∈ P_{A⊸B}, where a is the occurrence of an initial move in B hereditarily justifying the last move in s. □

It is a useful additional property of views that by concealing Opponent’s bad behaviour, they can be used to project strategies over games governed by rules into unbracketed ones, thus embedding models of purely functional languages, for instance, into models with non-local control. (This remains a problem for knowing (i.e. non-innocent) strategies: one can, for instance, use state to define a strategy which detects manipulation of the control flow by the Opponent, but without using local control flow itself.)

Definition 3.6.14 A rule is embeddable if it obeys the projection condition, and for every justified sequence on A ⊸ B such that R(s↾A) and R(s↾B), but s itself violates R, s ∩ R is odd-length. In other words, if a play on A ⊸ B violates R, but its restriction to each component does not, then the fault is Player’s.

(So linearity, for instance, is embeddable.)

Proposition 3.6.15 For a category of (visibility satisfying) games and innocent strategies G_{R}, based on a compositional, embeddable rule R,

R(A) ⟶ V (A).
τ ⟹ σ_{⌜τ⌝}

defines a faithful functor into the category of unbracketed games and innocent functions.

Proof: Given ρ : R(A) → R(B), τ : R(B) → R(C), it is necessary to show that σ_{⌜ρ⌝}; σ_{⌜τ⌝} = σ_{⌜σ;τ⌝}. The inclusion from right to left is straightforward. From left to right it is sufficient to show that as long as Opponent adheres to the rule R on σ_{⌜ρ⌝}; σ_{⌜τ⌝}, then so does Player. So suppose sab ∈ σ_{⌜ρ⌝}∥σ_{⌜τ⌝} is such that b is a Player move in A or C, and sa↾A, C obeys R. It is sufficient to show that this entails that R(sa↾A, B) and R(sa↾B, C). Then sa↾A, B ∈ σ and sa↾B, C ∈ τ and so sab↾A, C ∈ σ; τ as required. By the projection condition, R(sa↾A, C) implies that R(sa↾A) and R(sa↾C). Hence also R(sa↾B), as otherwise σ or τ violate R. By definition of an embeddable rule, if sa↾A, B violates R, then the first move to do so is a Player move, which is not possible, as σ obeys R, and similarly, sa↾B, C obeys R. □

Remark 3.6.16 A consequence of the above observation is that the set of views of an innocent strategy is sufficient to determine whether it originates from a game satisfying the rule R. A natural question follows: is there a simple characterization of innocent R-strategies in terms of their view-functions, allowing the relevant subcategory to be identified. In the cases of visibility (Player views are justified sequences) and the well-bracketing rule which will be introduced (Player views are well-bracketed), the answer is yes.

3.7 The pointed CCC of games and innocent strategies is initial

Rather than showing separately that unbracketed games and finite innocent strategies form a category, that it is cartesian closed, and finally that it is a full and faithfully complete model of Λ(Ω), these facts are established together, by identifying it as the image of the functor from the free partial cartesian closed category over a single object. This is an economy of space; the direct proof that innocent strategies compose, which can be found in [43], and [59] is detailed but not especially illuminating. It does not seem inappropriate to establish soundness and completeness jointly; the innocent strategies can reasonably be defined as the image of the initial functor, and their composition can be described accordingly. (The fact that there is a well-defined notion of composition on Böhm trees, in a sense the syntactic counterpart of innocent functions, has been shown by Curien and Herbelin [20].) In addition, the isomorphism of the unbracketed model to the free CCC is quite a general result in that it characterizes innocent composition in the whole category of finite games and strategies.

Proposition 3.7.1 The category of finite unbracketed games is isomorphic to the (pointed) cartesian closed category of games freely generated from the one-move game o. (With ⊥-maps given by the empty strategy in each case).

Proof: Proof is by induction on depth of the game tree; i.e. the longest justification sequence. Suppose G is a finite, non-empty unbracketed game. Then by Lemma 3.3.8, G is generated by an arena which is a forest. So G is generated by some arena A_{1} × A_{2} × … A_{n}, where A_{1}, A_{2}, … A_{n} are trees, and so each A_{i} is equal to B_{i} ⇒ o, for some forest-arena B_{i} of strictly smaller depth, and so by hypothesis, B_{i} can be constructed form o with × and ⇒, hence A can as well. □

Hence the unique functor from the free pointed CCC over a single object to the pointed CCC of finite games and strategies is surjective on objects. The image of the functor is identified by proving the following theorem.

Theorem 3.7.2 The image of the unique functor from the free partial CCC to the category of games and strategies consists of precisely the finite, innocent functions.

Corollary 3.7.3 The innocent functions form a pointed CCC, of which the finitary part is a fully and faithfully complete model of Λ(Ω).

3.7.1 Characterizing the initial model

The fact that the free pointed CCC is a fully complete model of the simply-typed λ-calculus with non-termination defined in the previous chapter allows the functor from it into the games model to be defined by inductive decomposition as follows.

Definition 3.7.4 (Evaluation trees of Λ(Ω)) The ‘evaluation trees’ of Λ(Ω) are familiar as βη-long normal forms. Writing t ∈ N(Γ; T) for ‘t is an evaluation tree of type T over context Γ’, they can be defined as the closure of the following inductive definition (products and the terminal type are omitted):

\overline{Ω ∈ N(Γ; ι)}

\frac{t_{i} ∈ N(Γ, y : \overline{T} ⇒ ι; T_{i}) : i ≤ n}{(((y t_{1}) t_{2}) …) t_{n} ∈ N(Γ, y : \overline{T} ⇒ ι; ι)}

\frac{t ∈ N(Γ, x : S; T)}{λx.t ∈ N(Γ; S ⇒ T)}

Proposition 3.7.5 Every finitary term of Λ(Ω) is βη-equivalent to a finite evaluation tree.

Proof: for the simply-typed λ-calculus without constants is in [8]; this extends readily to Λ(Ω) by considering Ω as an unbound, ground-type variable. □

Corollary 3.7.6 A model (C, a) of Λ(Ω) is fully and faithfully complete if and only if every map f : \overline{A} → a has a unique decomposition in the following sense: either f = ⊥_{\overline{A},a} or f = (⟨π_{i}, ⟨[[M_{1}]]_{M}, [[M_{2}]]_{M}, … [[M_{n}]]_{M}⟩⟩; App) for some evaluation trees M_{i} ∈ E(Γ; A_{i}) : i ≤ n.

Definition 3.7.7 The unique functor from the initial model to (C, a) can therefore be defined on objects as F ([[ι]]) = a, and F ([[S ⇒ T]]) = F ([[A]]) ⇒ F ([[B]]), and on morphisms: F (⊥_{[[ι]]}) = ⊥_{a}, F (⟨π_{i}, ⟨g_{1}, g_{2}, … g_{n}⟩⟩; App) = ⟨π_{i}, ⟨F (g_{1}), F (g_{2}), … F (g_{n})⟩⟩; App. F (Λ(g)) = Λ(F (g)).

Thus to identify the fully complete model inside C it is sufficient to find a set of morphisms I(A, B) ⊆ C(A, B) at each A, B such that for each A = Π_{i≤n}(Σ_{j≤m_{i}}B_{i,j})

I(A, a) ≅ (∐_{i∈I} Π_{j∈J}C(A × B_{i,j}, a))_{∗}

(writing Σ_{j≤m_{i}}B_{i,j} for the weak co-product (Π_{i≤m_{i}}(B_{ij} ⇒ a)) ⇒ a and ∐ for disjoint union of sets). The isomorphism is given by

⟨f, i⟩ ⟶ ⟨π_{i}, ⟨g_{i1}, g_{2}, … g_{in_{i}}⟩⟩; App.

Moreover this must be a least solution to the above recursive equation so (following Abramsky [1]) a norm function ♯_{A,B} : I(A, B) → ℕ is required such that

♯(⟨π_{i}, ⟨g_{1}, g_{2}, … g_{n}⟩⟩; App) > ♯(g_{i}) i ≤ n.

As this identifies I as the image of a structure preserving functor into C, soundness is automatic. Proposition 3.7.8 If C is a pointed CCC, with a normed set of morphisms I satisfying the above criteria, then the subcategory of C with objects freely generated from a, and morphisms in I is isomorphic to the free pointed CCC.

Proof: is via Corollary 3.7.6 above, by induction on norms; if f ∈ I(\overline{A}, a) ≠ ⊥, then f = ⟨π_{i}, ⟨g_{1}, g_{2}, … g_{n}⟩⟩; App, for some i, and g_{1}, … g_{n} such that ♯(f) > g_{j} for each j, so by induction each g_{j} = [[M_{j}]] for some evaluation tree M_{j}. □

3.7.2 Axioms for denotational completeness in models of control

It is now possible to present an axiomatic characterization of denotational models of Λ(Ω) which are fully and faithfully complete, being (least) solutions to a recursive equation on hom-sets. This gives a relatively elegant and economical proof of definability for the games model, and by identifying precisely the assumptions on which it is based, could allow the results achieved in this thesis to be generalised to new models of control (using games, or some other presentation). Well chosen axioms may even help to identify more elegant constructions as they contain implicitly an abstract characterization of the initial model of control.

This approach was initiated by Abramsky in ‘Axioms for full abstraction and full completeness’ [1]. This axiomatised definability results for models of (call-by-name) PCF, and full (and faithful) completeness for models of the pure simply typed λ-calculus over a single base type (i.e. the free CCC over a single object) (‘sequential’ and ‘pure sequential’ categories, in his terminology). The axioms given here, and the resulting definition, are somewhere between the two, incorporating the partiality structure of one with the simple structure at ground type (no values) of the other. In fact this allows the axiomatization to be simplified slightly. The major extension in their scope, however, is that via the (fully complete) cps translations, they can be regarded as ‘axioms for definability in models of control’. Notwithstanding the indirectness of the interpretation, the axioms themselves are directly relevant to models of control; as will be shown, they characterize the answer object as minimal, continuations as π-atomic, and the underlying category as sequential.

It is also necessary to state the axioms differently, as soundness of the models was assumed in ‘Axioms’, whilst here it is simply assumed that the axiomatized maps form a subset of each hom-set of a pointed CCC. Refining the axioms in this way makes sense in the context of the intensional hierarchy, as it is consistent with the aim of identifying fully complete models of functional languages as subcategories of more general categories with fewer constraints.

The axioms assume the following structure on a pointed cartesian closed category C:

• a linear decomposition into a symmetric monoidal closed category L with a co-monad ! such that C(A, B) = L(!A, B), and A ⇒ B =!A ⊸ B.

• proposed definable morphisms I in L. These are given as a specified, normed subset I(A, B) of each hom-set of L, containing the identity, terminal and bottom maps, and preserving products (i.e. I(A, B × C) = {⟨f, g⟩ | f ∈ I(A, B), g ∈ I(A, C)). All further requirements for I are contained in the following axioms (it need not be assumed to be a category, for instance).

Recall also the notion of strict map; morphisms f : A → B such that⊥_{A}; f = ⊥_{B}, and the subcategory C_{S} with the objects of C, and strict maps as morphisms between them. In the various categories of games, the (non-⊥) strict strategies from A to B are those which follow the initial move with a move in A.

The axioms have a uniform flavour — each takes the form of a statement that a canonical mapping between hom-sets of L is a bijection on the restriction to maps in I which preserves or reduces their norms. Hence they are presented as an isomorphism between sets of I-morphisms, although the additional structural details are crucial. (The first three characterize the answer object, and the latter two are more general lemmas about sequentiality which have appeared in some form in the decompositions of [6], [43], [59].) The intended interpretation of I in the category of games is the innocent strategies. Although the ‘linear decomposition’ for G described in Section 3.4 is not standard, the properties required by the following axioms are present, so the proof goes through for G.

3.7.2.1 Minimality of the answer-object

I(1, a) = {⊥_{a}}.

Anticipating the use of a as an ‘answer object’ for a continuations monad, this condition can be seen as a necessary condition for preventing ‘junk’ from being introduced into the semantics by a choice of answer object which is ‘too large’, since an interpretation of a term over (A ⊸ a) ⊸ a must either be ⊥ or the lifting of an element of A. An answer object which includes other possibilities, such as the choice of the flat domain of natural numbers as an answer object in [80] violates this axiom.

Lemma 3.7.9 It is equivalent to the following condition from [1]: All maps into the answer object are strict: for any A, I_{S}(A, a) = I(A, a).

Proof: For a non-strict map into a to exist, there must be a non-⊥ map from 1 to a, whilst if all maps into a are strict, in particular, if f : 1 → a, is strict, then ⊥_{1}; f = id_{1}; f = ⊥_{1}. □

This axiom can in certain circumstances be subsumed into the following property.

3.7.2.2 Contravariance of (linear) continuations

I_{s}(A ⊸ a, B ⊸ a) ≅ I(B, A)_{∗}.

More precisely, there is an inclusion of maps of L(B, A)_{∗} in L_{s}(A ⊸ a, B ⊸ a):

∗ ⟶ ⊥_{A⊸a,B⊸a}
(f : B → A) ⟶ Λ(id_{A⊸a} ⊗ f; App),

and the axiom stipulates that:

• its restriction to the maps in I is an isomorphism,

• it is strictly increasing with respect to the norm function (i.e. ♯(f : B → A) < ♯(Λ(id_{A⊸⊥} ⊗ f; App)))

(In G, any strict, non-bottom strategy from A ⊸ a to B ⊸ a responds to the initial move in B ⊸ a by playing the initial move in A ⊸ a, Opponent plays an initial move in A, henceforth Player must play according to a (smaller, innocent) strategy on B ⊸ A.) This axiom is essentially a form of Abramsky’s ‘linear functional extensionality’[1]. In a control setting it can be seen as stipulating that a (non-⊥) morphism between linear continuations is always in the image of a the functor ⊸ a. In the situation in which I itself is given to be a SMCC, however, it also characterises a as a minimal ‘standard datatype’, making the first axiom redundant.

Proposition 3.7.10 If the contravariance axiom holds for the SMCC L, then it entails minimality of a, and hence that all maps into a are strict.

Proof: a and 1 ⊸ a are still isomorphic in L_{s}, as all isomorphisms are strict maps, and so by the contravariance axiom L_{s}(a, a) = L_{s}(1 ⊸ a, 1 ⊸ a) ≅ L(1, 1)_{∗}. Therefore there are just two distinct maps in L_{s}(a, a), id_{a} and ⊥_{a} (these are distinct, as otherwise ⊥_{a} : 1 → a is an isomorphism, and a is terminal, contradicting the fact that there are two maps from a to itself). Hence if f : 1 → a, t_{a}; f = ⊥_{a,a}, (where t_{A} is the terminal map from a) as f is not an isomorphism either. So ⊥_{a} = ⊥_{a}; ⊥_{a,a} = (⊥_{a}; t_{a}); f = id_{1}; f = f as required. □

3.7.2.3 π-atomicity of continuations

I_{S}(B, A ⊸ a) + I_{S}(C, A ⊸ a) ≅ I_{S}(B × C, A ⊸ a).

Specifically, there is a map into L_{S}(B × C, (A ⊸ a)) from the coalesced sum L_{S}(B, (A ⊸ a)) + L_{S}(C, (A ⊸ a)), which sends f : B → A ⊸ a to π_{l}; f and f : C → A ⊸ a to π_{r}; f. For morphisms of I, this is required to be a bijection such that ♯(f) = ♯(π_{i}; f_{i}) This property of (target) objects is called π-atomicity in [1], following Joyal. In G, all objects A ⊸ o are π-atomic, because they have a unique initial move. So the first Player move in a strict strategy on B × C ⊸ (A ⊸ o) is always in B or C, and by definition of the cartesian product, the remainder of the play is a play in B ⊸ (A ⊸ o) or C ⊸ (A ⊸ o)

3.7.2.4 Linearization of head occurrence

I_{s}(A,!A ⊸ B) ≅ I_{s}(!A, B).

i.e. the canonical map from L_{s}(A,!A ⊸ a) into L_{s}(!A, a): f ⟶ con_{A}; ((f ⊗ der_{A}); App) is a bijection on maps in I, and ♯(f) = ♯(con_{A}; ((f ⊗ der_{A}); App)). Linearization of head occurrence in a strict strategy σ :!A ⊸ B in G is simply a matter of relabelling the first opened thread in !A as a play in an additional premise A, to yield σ : A ⊸ (!A ⊸ B). This preserves innocence, as in any play according to a strict strategy on !A ⊸ B, the initial move in the first thread opened in !A appears in every subsequent Player view. (Compare with e.g. Danos, Herbelin and Regnier’s notion of ‘linear head reduction’ [21].)

\xymatrix{!A \ar[r]^{con} \ar[d]_{f} & !A⊗!A \ar[d]^{id⊗der} \\ B & !A ⊗ A \ar[l]^{f̂}}

Figure 3.1: Linearization of head occurrence (f ⟶ f̂)

3.7.2.5 Uniformity of threads

I(!A, \overline{(B ⊸ a)}) ≅ I(!A,!\overline{(B ⊸ a)}).

That is, the ‘promotion’ mapping from L(!A, \overline{(B ⊸ a)}) to L(!A,!\overline{(B ⊸ a)}) which sends f :!A → \overline{(B ⊸ a)} to f^{†}:!A ⊸!\overline{(B ⊸ a)} = prom_{A}; !f is a bijection on maps in I. Since by definition of promotion, f^{†}; der\overline{(B⊸a)} = f, this means that for all g ∈ I(!A,!\overline{(B ⊸ a)}), (g; der\overline{(B⊸a)})^{†} = g. The fact that this holds for all innocent strategies in G has already been noted as the ‘Bang lemma’ (Proposition 3.6.13).

Definition 3.7.11 A partial sequential category is a pointed CCC, C, together with a specified non-terminal object, a, which decomposes into a pointed affine category L.

The category of AJM games and strategies (where I is the subset of history free strategies) provides another example of a sequential pointed CCC, — almost!

3.7.3 Axiomatic decomposition

Theorem 3.7.12 (Decomposition in a sequential, pointed CCC) Let (C, a) be a category with a linear decomposition L, and normed subsets of maps I satisfying the axioms above. If A_{1}, A_{2}, … A_{n} are objects of S such that A_{i} = Π_{j≤m_{i}}B_{i,j} ⇒ a =!(Π_{j≤m_{i}}B_{i,j}) ⊸ a then

I(!Π_{i≤n}A_{i}, a) ≅ (Σ_{i≤n}Π_{j≤m_{i}}I(!(\overline{A}), B_{i,j}))_{∗}.

Proof: (along similar lines to the decompositions in [1]) By Minimality of answer-object, or Proposition 3.7.10

I(!Π_{i≤n}A_{i}, a) ≅ I_{S}(!Π_{i≤n}A_{i}, a)

by Linearization of head occurrence, this is isomorphic to

≅ I_{S}(Π_{i≤n}(!(Π_{j≤m_{i}}B_{i,j}) ⊸ a),!(\overline{A}) ⊸ a)

by π-atomicity of (!(\overline{A}) ⊸ a), to

≅ (Σ_{i≤n}I(!(Π_{j≤m_{i}}B_{i,j}) ⊸ a,!(\overline{A}) ⊸ a))

so by Contravariance of continuations, to

≅ Σ_{i≤n}I(!(\overline{A}),!(Π_{j≤m_{i}}B_{i,j}))_{∗}

and hence by Uniformity of Threads, to

≅ Σ_{i≤n}I(!(\overline{A}), Π_{j≤m_{i}}B_{i,j})_{∗}

and by definition of the product, to

≅ Σ_{i≤n}Π_{j≤m_{i}}I(!(\overline{A}), B_{i,j})_{∗}

(Note also that the norm of each map is strictly greater than the greatest norm in its decomposition.) Moreover, the inverse of each component of the isomorphism has been characterized as a canonical map in the linear category, so by composing these maps the decomposition can be given as follows: For any f ∈ I(!\overline{A}, a), either f = ⊥_{\overline{A},a} or there is a unique i ∈ n and family of morphisms \{g_{j} ∈ I(\overline{A}, B_{i,j}) | j ≤ m_{i}\} such that

f = con\overline{A}; (der\overline{A}; π_{i}) ⊗ ⟨g_{1}, … g_{j}, …⟩^{†}; App

where ♯(f) < max{♯(g_{1}), … ♯(g_{n})}. □

Figure 3.2: Decomposition of an innocent strategy on \overline{A} → o

This simplifies to a decomposition in C as follows.

Corollary 3.7.13 In any pointed sequential category with objects \overline{A} = Π_{i≤n}A_{i} where A_{i} = (Π_{j≤m_{i}}B_{i,j} ⇒ a) ⇒ a

I(\overline{A}, a) ≡ Σ_{i≤n}Π_{j∈m_{i}}I(\overline{A}, B_{i,j})

where the bijection is characterized

⟨f, i⟩ ⟶ ⟨π_{i}, ⟨g_{1}, … g_{m_{i}}⟩⟩; App

for unique g_{j} : j ≤ m_{i} such that ♯(g_{j}) < ♯(f). Hence the category which has objects generated form a by × and ⇒, and morphisms from I is isomorphic to the free CCC.

Corollary 3.7.14 A normed sequential partial CCC is isomorphic to the free partial CCC, and is a fully and faithfully complete model of Λ(Ω).

Danos, Herbelin and Regnier [21] show that the correspondence with λ-terms extends to the interaction between strategies. They describe a process of evaluation of λ-terms to weak head-normal form by ‘linear head reduction’, and an abstract machine (due to Krivine) for implementing it. The pointers generated by the machine in the course of evaluating the application of one term to another are in bijective correspondence to the ‘uncovering’ of the interaction between the strategies which denote the terms.

3.8 The games models of control

The constructions described in the previous chapter can be applied to the categories of games and innocent and knowing strategies, to give games models of call-by-name and call-by-value control.

Proposition 3.8.1 The models of control specified by (G, o) (by the strong monad of o-continuations on fam(G)) are initial.

Proof: is by the proof of full completeness above, together with the proof in the previous chapter (Proposition 2.3.7) that any model of control given by (C, a) is initial if C is the free pointed CCC over a. □

A significant point is that (unlike the abstract, categorical case) the completion of the games presentation of the initial model of control as a cpo-enriched ‘continuous model of control’ is now straightforward.

Proposition 3.8.2 (G_{alt}, o) specifies a continuous computational model of control.

Proof: is as for the CCC of games and thread independent strategies (Proposition 3.5.7), noting that the least upper bound of a chain of innocent strategies is innocent. □

By Proposition 2.5.9, every definable morphism of a control model is a supremum of an ω-chain of morphisms from the CCC, and by the Definability Theorem, these are the innocent strategies with finite norms (view-functions). This generalises simply as follows:

Proposition 3.8.3 G is ω-algebraic, with the compact strategies being precisely those with finite view-function.

Thus the denotational part of the definability problem has been solved; all that remains is to give a complete syntactic and operational characterization of models of control. However, the non-reductionist project of characterizing control within the intensional hierarchy remains. The notion of ‘weak co-product’ monads on Fam(G) which yield call-by-name and call-by-value semantics provides a convenient structuring principle for this problem. Three such monads will be defined, each of which gives a different level of access to control flow. These can be characterized as higher-order control, first-order control, and strictly local. The can be derived from the ‘linear decomposition’ of the category of games which has already been described, based (albeit with various degeneracies) on the translations of intuitionistic and classical types into linear logic described in Figure 3.3 (to which there are several alternatives; [29], [22]). The obstacle to

Intuitionistic  Intuitionistic  Classical  Classical
(call-by-name)  (call-by-value)  (call-by-name)  (call-by-value)
A × B = A&B A × B =!(A&B) A × B = A&B A × B =?!A&?!B)
A ⇒ B =!A ⊸ B A ⇒ B =!A ⊸!B A ⇒ B =!A ⊸ B A ⇒ B =!A ⊸?!B
A + B =!A⊕!B A + B = A ⊕ B A + B =?(!A⊕!B) A + B = A ⊕ B

Figure 3.3: Linear decompositions of call-by-name and call-by-value types (⊕ is the dual to &).

defining sums as dual to products in the category of alternating games, however, is its ‘asymmetry’; Opponent always starts, so the true involution operator which just swaps the roles of Player and Opponent does not give a well-defined game. (There are ways to allow Player to start — see [7], but in this case the possibility of modelling the additives (cartesian closure) is lost.) However, true involution is in this case not necessary (or desirable, being incompatible with the pointedness which is a crucial feature of the weak co-product monad). Instead, the one-move game (which is a weakly initial object) is used as a ‘weakly dualizing object’ which both lifts and dualizes at the same time, defining (A)^{⊥} = A ⊸ o. (This operation, forming linear continuations, — is a self-adjoint ‘not-functor’ [82] on the SMCC of games (see Proposition 3.8.7).) Thus the ‘intuitionistic’ sum-monad is modelled by ((!A ⊸ o) × (!B ⊸ o)) ⊸ o, and the ‘classical’ sum-monad by !((!A ⊸ o) × (!B ⊸ o)) ⊸ o, which is equal to ((A ⇒ o)×(A ⇒ o)) ⇒ o — the sum given by the continuations monad. Recalling the definition of the ! as the lifting of the linearity condition on initial moves, the difference between the classical and intuitionistic sum games is therefore the following: in the intuitionistic sum, the move justified by the initial move is linear, in the classical sum, it is not.

In the following section, these alternative notions of weak co-product and the associated monads are studied. The linearity conditions placed on the second move in the monad are shown to correspond to different types of control behaviour, in particular:

• there is a finer distinction between sum types, based on refining the linearity rule, to exclude control behaviour corresponding to ‘logical stability’.

• the ‘bracketing condition’ of [43], [6] etc. corresponds to a stricter version of the linearity rule, which enforces local control flow.

3.8.1 The unbracketed sum

First, consider the monad of ‘one-move continuations’ TX = (X ⇒ o) ⇒ o, and the associated ‘weak co-product’, A + B = ((A ⇒ o) × (B ⇒ o)) ⇒ o The natural transformation μ_{T} : T^{2} → T can itself be used as the denotation of the control operator 𝒞 (see Chapter 4). However, the games interpretation of the call/cc operator can be given a more intuitive description. (Recall that this is typed with (((S ⇒ T) ⇒ S) ⇒ S) which is the simplest type which can be given to control operators but not (generally) to functions; it is also the simplest example of a classical (minimal) tautology which is not provable in intuitionistic logic.)

Definition 3.8.4 Let A = Σ_{i∈I}A_{i}, then for arbitrary B,

peirce_{A}^{n} : ((A ⇒ B) ⇒ A) ⇒ A)

(Figure 3.4) is the strategy which plays copycat between the outermost occurrences of A, until forced into (A ⇒ B) by a move in B, after which it plays the opening move in the innermost occurrence of A and then copycat between the outermost A, and both of the other A components. For call-by-name type-objects other than weak co-products, the denotation corresponding of call/cc can be derived from these instances via cartesian closure, just as the operator itself can be ‘bootstrapped’ from instances at sum-types in the λ-calculus. The call-by value version can be described directly for all families of games: for a family A = {A_{i} | i ∈ I},

peirce_{A}^{v} : Π_{i∈I}(A_{i} ⇒ Σ_{j∈J}B_{j}) ⇒ Σ_{i∈I}A_{i} ⇒ Σ_{i∈I}A_{i}

is the strategy which plays copycat between the positive and negative occurrences of Σ_{i∈I}A_{i}, until Opponent plays an initial move in the ith component of Π_{i∈I}(A_{i} ⇒ Σ_{j∈J}B_{j}). Player then selects the ith component in the (positive) Σ_{i∈I}A_{i}, and plays copycat between the positive A_{i} and whichever of the negative A_{i} Opponent chooses to play in.

A control-specific analogy for the Player/Opponent duality, consistent with the general notion of System versus Environment, is to consider the role of Opponent as representing the current continuation. This is suggested by the correspondence between Player strategies on A ⊸ o and Opponent strategies (odd-branching, odd-prefix closed sets of moves) on A. peirce takes a strategy interpreting a term of type S with a free ‘continuation variable’ of type S ⇒ T, and binds it to the current continuation by copying Opponent’s strategy on [[S]] as an input.

3.8.2 An alternative monad for control

To understand control flow in games, it is useful to return to the notion of a dialogue, and consider the distinction between demands for information, and information made in direct response to such a demand. Call the initial move in the game TA a question, and any moves enabled by it, answers. (Note that no move can be both a question and an answer.) The intuition (see [59]) is that the weak co-product Σ_{i∈I}A_{i} adds the following protocol:

• an initial Opponent question O_{q}: ‘which A_{i} shall we play in ?’

• followed by a Player answer P_{i}, allowing play to proceed in A_{i}.

In order for this to define the usual ‘separated sum’ (and in the unary case, a lifting) it is necessary that what follows is a play in A_{i}. This is the case just if answer moves must be played linearly, as Player cannot revisit this choice and

Figure 3.4: The strategy peirce_{A}^{n}

Figure 3.5: Contrasting plays in the different sum games. Top: in the ‘linear’ or well-bracketed sum Below: in the unbracketed sum, or continuations monad either choose a new component, or open a new thread in A_{i}. In other words, non-⊥ elements in A + B correspond either to an element in A, or one in B.

Note that the result of composing a strategy on (A ⇒ TB) ⇒ TA which is non-linear in its argument, with peirce_{A}^{v}, will be a strategy on TA which repeats the answer to the initial question each time the initial question in (A ⇒ TB) is asked (so the current continuation is ‘called’). This multiple ‘upward continuation passing’ behaviour violates the principle that a term of ‘lifted’ type should correspond denotationally and operationally to a value, or to the undefined object ⊥. Game semantically, it corresponds to the condition that answers should be unique and non-repeatable, — strategies cannot ‘change their minds’ about answers. By constraining answers to behave linearly it can be excluded from the model whilst retaining some level of non-local control.

Definition 3.8.5 For a family of arenas {A_{i} | i ∈ I} define the linear (affine), or ‘weakly bracketed’ sum Σ_{i∈I}^{L}A_{i} to be the arena consisting of a single initial (linear) opponent move, enabling each one of a family of linear Player moves {l_{i} | i ∈ I}, each of which enables the initial moves of A_{i}.

This can be defined in a more general setting as a continuations monad of sorts.

Definition 3.8.6 Given a category C with a ‘linear decomposition’, of morphisms on C(A, B), as morphisms on L(!A,!B) for some linear category L and an object a of L, define the (strong) ‘linear a-continuations monad’ on C

T_{a}^{L}X = (X ⊸ a) ⊸ a

Proposition 3.8.7 This is a strong monad on L (and on C).

Proof: is by observing that T_{a}^{L} can be resolved into the self-adjunction of a contravariant ‘not-functor’ which forms linear a-continuations: ¬A = A ⊸ a. The fact that L(A, B ⊸ o) ≅ L(B, A ⊸ o) is immediate; the definitions for the Kleisli triple and monadic strength are ‘linearized’ versions of the standard continuations monad described in Section 2.2.6. □

(Alternatively, in categories with a linear decomposition of A ⇒ B as !A ⊸ B, the monad can be defined as T X = X ⇒ a) ⊸ a (see [47]).)

Proposition 3.8.8 In the category of (families of) linear games,

T_{o}^{L}{A_{i} | i ∈ I} = {Σ_{i∈I}^{L}A_{i}}.

(In fact, a notion of tensor product and closure on Fam(C) has not been defined here, but this is not really necessary, as only singleton families are involved.)

The fact that, given σ: (A ⊸ o) ⊸ o, either σ = ⊥, or σ is the ‘lifting’ of some strategy on A has already been observed in the axiomatic characterization of the answer object. Thus at a local level the linear continuations monad defines a separated or intuitionistic sum type. However, control is a non-local issue: the linearity (or rather affinity) condition does not prevent ‘jumps in the flow of control’ in games. At the level of atomic games, the control strategies peirce described above are still well-defined:

Definition 3.8.9 For any set X, define the atomic game X̃_{∗} to be the game consisting of a single (Opponent) question and a set of answers, indexed over X. (So these correspond to ‘flat domains’ or weak co-products over the a family of terminal objects, {1_{x} | x ∈ X}.)

Proposition 3.8.10 If X is a family of terminal objects, {1_{x} | x ∈ X}, so that T_{o}^{L}X is the atomic game X̃_{∗}, then the strategies peirce_{ΣX}^{n} and peirce_{X}^{v} are valid strategies, which give unique and non-repeated answers to questions.

Proof: peirce_{X}^{n} (see Figure 3.6) copies the initial X̃_{∗}-question in the second component, and copies back any answer. If none is forthcoming, it copies the X̃_{∗}-question again in response to Opponent’s X̃_{∗} question, until it receives an X̃_{∗}-answer, which it copies as an answer to the initial question, closing the game.

□
[figure: ((ℕ; ℕ); ℕ); ℕ; O_{q}; P_{q}; O_{q}; P_{q}; O_{n}; P_{n}]

Figure 3.6: A typical play of peirce^{n} at atomic types

In fact, this is the only type of control behaviour possible in the arenas of the Hyland-Ong model of call-by-name PCF, which uses sums (implicitly) only to define ground types. In fact, by definition, the answer moves of Hyland-Ong games do not enable any other moves, and as a consequence, must be linear moves.

Proposition 3.8.11 In a sequence satisfying visibility, any move which does not enable other moves

• occurs at most once,

• does not share its justifying move with any other such moves.

Proof: is by induction on the length of sequence, with the hypothesis that if d is a Player move justified by c in the sequence sc · td · r and d does not justify any subsequent move, then the following joint hypotheses hold:

• if it is Opponent’s turn to move, none of the moves between c and d (exclusive) are in his view. This is clearly the case when the move d has just been made. Suppose d′ is some subsequent Player move. Then by the induction hypothesis on Player views (below), and visibility, it cannot be justified by a move between c and d. If d′ is justified by a move prior to c, then all moves between c and d are hidden in the Opponent view. If d′ is justified by a move e after d, then this move occurs in the Opponent view at d′ by the visibility condition. Hence by induction hypothesis applied at e, the moves between c and d are not in the Opponent view of this sequence.

• if it is Player’s turn to move, none of the moves between c and d (inclusive) are in his view. (Hence, by visibility, he cannot make a move justified by c, QED). If the last move is an Opponent move, then it cannot be justified by d itself by assumption, and by induction hypothesis and visibility, it is justified either by a move before c or one after d. In the former case, the moves between c and d are hidden from the Player view, whereas in the latter case, the induction hypothesis can be applied to give the same result.

□

This is closely connected with the fact that call-by-name PCF cannot be augmented with ‘higher-order’ control features expressively distinct from groundtype call/cc. The factorization described by the author in [48], shows that all bracketing violations in the call-by-name model of PCF can be represented as the application of the ground-type peirce strategy. The situation is slightly more complicated in the call-by-value model, as this contains answers which do justify questions, and strategies which are do not factorize via peirce. However, it can be shown (by factorization) that all weakly bracketed strategies can be simulated up to observational equivalence as the composition of a well-bracketed strategy, and the Peirce’s law strategy at atomic types. Thus from a proof-theoretical standpoint, this model corresponds to ‘stability’; classical rules for atomic formulas, from which all classical rules for the negative fragment of propositional logic can be derived.

Thus the category of games with linear answers can be seen as a semantics of ‘first-order’ control, with ‘downward continuation’ passing behaviour allowing jumps in the flow of control corresponding to functional variations of GOTO; aborts, escapes, exceptions etcetera, contrasting with the ‘upwards continuation passing’ of higher-typed call/cc in its (usual) call-by-value setting. This could be said to mark a boundary between control as a simple extension of functional languages, and continuation-passing as a programming style in its own right.

3.9 Linearity and the bracketing condition

An explanation for the existence of ground type ‘control strategies’ such as peirce in the weakly bracketed model, is that the linearity rule is not, strictly speaking, linear (precisely once), but affine (at most once). In addition to validating weakening (as the terminal object is a unit for ⊗), this also introduces the possibilities of limited contractions associated with the ‘weak initiality’ of the one-move game. As shown in Figure 3.6, the strategy peirce works at ground types (i.e. o^{X} ⊸ o) by missing out answers rather than repeating them. peirce is also a total strategy (via its view function) on ((A ⊸ B) ⊸ A) ⊸ A, for atomic A, although this is not a tautology of affine logic.

By giving a refined, stricter definition of linearity, this behaviour can be excluded. This can be done most simply by considering only the case in which linear and non-linear moves alternate according to the question/answer discipline dictated by the sum game, giving a neat connection with the bracketing condition. This correspondence between intuitionistic and linear behaviour suggests, however, that an analysis of local control flow via decomposition into linear logic is possible.

The connection between linear moves and questions and answers in bracketed arenas can be formalized as follows.

Definition 3.9.1 A non-initial (strictly) linear move is an answer. Any move which is not an answer is a question, — that is, initial moves and non-linear moves. An arena is bracketed if only questions may justify answers (the original requirement of [43]).

Note that the constructions A ⇒ B, A × B and, importantly, the linear sum, can be carried out in bracketed arenas. The linearity rule can be strengthened, to require that linear moves also occur at least once, by imposing the following ‘liveness’ condition.

Definition 3.9.2 A legal sequence s is strictly linear if it can be extended to a (finite) legal sequence in which every question justifies exactly one answer.

Interestingly, in the presence of visibility, it is possible to characterize this condition solely in terms of the moves already played, rather than by quantification over possible extensions. The following condition states that question-answer pairs must be ‘nested’ in an appropriate way, and was used in both game semantics of PCF but is older (see e.g. Felscher’s paper [26]).

Definition 3.9.3 (Bracketing Condition) Suppose A is a bracketed arena; a legal sequence over A is well-bracketed if every answer is always justified by the last-asked, unanswered question, — formally, assuming a L_{J} definable predicate a ≺_{s} b - ‘ a precedes b in s’, define W B(sab) if W B(sa) and (λ^{W B}(b) = A implies (λ^{W B}(a) = Q ⟹ ϕ_{sab}(b) = a) ∧ (λ^{W B}(a) = A ⟹ ϕ_{sab}(b) ≺_{sab} ϕ_{sab}(a)). Only one label, for answers, is really required. The condition is equivalent to requiring that there are equal numbers of questions and answers between each question and its answer.

Well-bracketed sequences are clearly (weakly) linear, as questions can be answered only once — in fact they are strictly linear, as questions can be answered in the reverse of the order that they were asked. Sequences over Hyland-Ong games which are not well-bracketed are not strictly linear, as unanswered questions become ‘hidden’ between two answers as described in Proposition 3.8.2 — in fact (surprisingly) this holds in general; once the balance between questions and answers has been lost by violating the bracketing condition, there is no way to regain it (see Figure 3.7).

Proposition 3.9.4 If s is a (odd/even-length) well-bracketed legal sequence, then the last-asked open question in s is in the view (Player/Opponent) of s.

[figure: [; (; [; ]; [; ]; ); (; [; ]; (]

Figure 3.7: A sequence violating the bracketing condition (with justification pointers): Opponent questions are denoted ‘[′, Player questions ‘)′. Note how the first violation of well-bracketing destabilises the sequence so that there is always a prematurely closed unanswered question.

Proof: is by induction on sequence length. Suppose sb is an odd-length wellbracketed sequence, then if b is a question, the hypothesis holds directly. If b is an answer, then sb = s′q · tb, where q is a question justifying b. As s is wellbracketed, every question between q and b has been answered, and so the most recently asked unanswered question is in s′, and by induction hypothesis appears in the view of ⌜s′⌝ and so in ⌜s⌝ = ⌜s′⌝qb. □

Definition 3.9.5 Say that a question is ‘prematurely closed’ (whether it has been answered or not) if a previously asked question has already been answered, and ‘open’ if it is unanswered and not prematurely closed.

Proposition 3.9.6 Suppose A is an arena in which every question has an answer, then a legal sequence over A is strictly linear if and only if it is well bracketed.

Proof: Suppose s ∈ J_{A} is well-bracketed, then every question in s is answered at most once. Moreover, s can be extended to a sequence in which all of the questions have exactly one answer by answering open questions in the reverse order to which they were asked. (Note that if s is a well-bracketed legal sequence, then the most recently asked open question is in the relevant view of s.) The converse is a corollary of the following:

Lemma 3.9.7 Any extension qt (to some s such that s · qt is a legal sequence) in which q is a prematurely closed question contains an unanswered, prematurely closed question.

Proof: is by induction on the length of extension. Suppose qta is an extension to s in which q is prematurely closed. Then if a is not an answer to a prematurely closed question in qta, qt contains an unanswered, prematurely closed question by induction hypothesis, which is still unanswered in sq · ta.

It is also safe to assume that a is an answer to q, as if it is an answer to some later prematurely closed question, then the induction hypothesis can be applied to the shorter extension starting from this question. So suppose a answers q. Now consider the move preceding a; if this is a question, then it is prematurely closed by a, and unanswered, and we are done. So suppose that it answers some question q′; by the visibility condition, the justifier of a, which is q, must occur prior to q′. There are two possibilities:

• the answer prematurely closing q occurs after q′, so that it also prematurely closes q′. Then the induction hypothesis can be applied to the extension starting at q′.

• the answer prematurely closing q occurs before q′. Then applying the induction hypothesis to the extension from q to q′, there is a prematurely closed question in this segment, unanswered (at q′). If this is answered in t (between q′ and a), then the answer prematurely closes q′, and applying the induction hypothesis to the segment from q to a gives an unanswered prematurely closed question as required.

□

Consequently, any (finite) sequence containing a prematurely closed question contains an unanswered question. So no sequence which is not well-bracketed can be extended to a finite sequence in which all questions are answered.

Proposition 3.9.8 Well-bracketing preserves the identity and associativity conditions and hence defines a category of games.

Proof: is straightforward. In the presence of visibility, and the switching condition, compositionality can be proved as follows. Note that as a consequence of the switching condition, a move from A in (A ⊸ B) ⊸ C can never be directly followed by one from C and vice versa, but must be followed by an odd number of B moves.

So suppose sa is a justified sequence in (A ⊸ B) ⊸ C, and sa↾(A, B)and sa↾(B, C) are well-bracketed. If a is an answer in A, then it answers the most recently asked open question in s↾A, B. Hence any questions which were asked in C since this question was asked have been answered, as to ‘get back’ to A, an odd number of moves must have been made in B, the last of which must have answered an earlier question. By well-bracketedness of sa↾B, C, all of the questions asked in this spate of moves in C have been answered.

Similarly, if a answers a question in C, there are no more recent open questions in A. □

As it is a rule, the bracketing condition preserves the symmetric monoidal closed and co-monad structure (and the product is still cartesian).

Proposition 3.9.9 The category of well-bracketed games and innocent strategies is cartesian closed.

Thus the original categories of Hyland-Ong and McCusker games has been recovered (although not requiring well-openedness simplifies the definition of composition). A crucial property of the bracketing condition for both versions of the game semantics of PCF is that it prevents innocent strategies from making intensional observations.

Proposition 3.9.10 The intrinsic preorder on the categories of well-bracketed games and innocent (and history-free) strategies is order extensional.

Proof: is given in detail in [43] and [59], but observe that a (strict) wellbracketed strategy on A → ℕ̃_{∗} must have an answer to the first question in A before it gives an answer in ℕ̃_{∗}, and if it is also innocent, then this answer is the only one in the view. □

As well-bracketing is a well-defined rule, the category of well-bracketed games and innocent functions can be embedded in the category of unbracketed games via their innocent functions (Proposition 3.6.15). Moreover, there is a simple characterization of the image of this embedding in terms of view-functions.

Proposition 3.9.11 An innocent strategy is well-bracketed if and only if it always answers the most recently asked open question in the view.

Proof: It is immediate that any innocent strategy on a well-bracketed game always answers the most recently asked question in the view, so it remains to show that any strategy σ which does so will never violate the bracketing condition before Opponent. But by Proposition 3.9.4, if s is a well-bracketed sequence, then the most recently asked open question in s is visible. □

Answering the most recently asked question in the view can then be adopted as the definition of well-bracketedness for strategies which are not innocent. The well-bracketed sum is shown in [59] to define a pointed weak co-product, so it is a strong monad on Fam(G_{WB}), (with the same copycat strategies yielding a Kleisli triple and strength as for the continuations monad). It thus yields models of call-by-name and call-by-value PCF as described in Section 2.4.4. The call-by-name model is equivalent to the original model described by Hyland and Ong in [43], as the atomic types denote the flat domain of natural numbers, and exponentiation. The well-bracketed sum was used by Abramsky and McCusker to give a fully abstract semantics of PCF_{v} in [3]. In each case, finite definability results (based on an inductive decomposition similar to the axiomatic result in this chapter) yield a fully abstract model by collapse under the (extensional) intrinsic preorder).

Theorem 3.9.12 (Hyland and Ong [43], Abramsky and McCusker [3]) The semantics of call-by-name and call-by-value PCF in the category of wellbracketed games and innocent strategies has the finite definability property (and its extensional collapse is fully abstract).

Dropping the bracketing condition transforms the well-bracketed sum from a linear ‘double negation translation’ on games, to an intuitionistic double negation: the interpretation of function types (the exponential in the Kleisli category of the lifting monad), A ⇒ (B ⇒ o) ⊸ o becomes A ⇒ (B ⇒ o) ⇒ o.

Remark 3.9.13 The connection between intuitionistic functional types, and the monad ( ⇒ o) ⊸ o which has been established by showing the connection between well-bracketing and strict linearity leads to the following conjecture: there is an invertible ‘linear cps’ translation from (call-by-name and call-by-value) PCF into the linear λ-calculus (with partiality and ω-indexed products) based on the single ground type ι. This is analogous the translation for the ‘classical (unbracketed) sum monad’ and μPCF described in the next chapter (Section 4.5.1).

Remark 3.9.14 (The stack discipline as an analogy for well-bracketing) A further intuition connecting the bracketing condition with control, is that it represents a stack-discipline for the (computation represented by the) interaction of Player and Opponent. A formal connection with stack-based computation via abstract machines have been established in [21]. There it is shown how the interactions between strategies in unbracketed Hyland-Ong games can be computed using a stack-based abstract machine.

The correspondence between bracketing and the stack discipline suggests how this work can be extended to games with the additional control flow information represented by the question/answer distinction. Suppose that the stack is used to hold only the ‘open questions’, — those demands for information which remains to be supplied in order for the computation to be completed. Giving some of this information by making an answer move corresponds to ‘popping the answered question’ from the stack, together with any other questions which no longer need to be answered.

Well Bracketed Games correspond to rigidly maintained stack discipline; only the question at the top of the stack can be popped, (answered).

Weakly bracketed Games In games in which answers cannot be repeated, but can be missed out, prematurely answering a question ‘closes’ all of the more recently asked questions as far as Player is concerned. This corresponds to ‘popping the stack downwards’ (to the point of the last unclosed, unanswered question). The following lemma shows that the weak bracketing condition can be seen as a way to prevent an innocent strategy from violating linearity by answering the same question twice.

Lemma 3.9.15 If Player is playing according to an innocent linear strategy on a bracketed arena, then he cannot answer any questions prematurely closed by himself.

Proof: (sketch) Suppose Player answers a prematurely closed (Opponent) question. Then this question appears in Opponent’s view and can be repeated, with the same justifier. Player will then have the same view as when the question was first asked, and will make the same response. Opponent can then copy his initial response to this move, and so on, until Player is forced to repeat the answer move which closed the Opponent question, which is a violation of linearity. □

Unbracketed games As well as ‘popping the control stack downwards’, which simply discards some of the current demands for information, call/cc can be used to reset the stack to other previous states. This means that demands for information which has already been supplied can become ‘live’ once again, and new information (not necessarily the same) given in response. This corresponds to the situation in unbracketed games, where any previous (visible) questions can be ‘answered’. The notion of ‘open’ question is now extended, to say that a question is open if the answer to any previous question occurs before the answer to some succeeding question. (So a question is open if it has not been closed, or if it has been closed, but the closing move, considered as a question, has itself been closed.)

Answering a closed question thus corresponds to ‘Popping the stack upwards’ as it always opens up some closed questions.

The syntax and semantics of μPCF

4.1 A minimal basis for computation

What is the simplest way to define a functional language for doing higher typed, sequential computation? PCF, or something similar, in which datatypes are ‘built in’ at ground types, with constants for construction (0, pred, succ) and decomposition (a conditional), is a possible and widely accepted answer to this question. Control operators fit in to this perspective as a useful non-functional extension to this minimal language. There is another possibility, however, which is to define data objects as simple functions, in the style of the original Church numerals, and latterly System F, the Calculus of Constructions, etc.

Example 4.1.1 (Finitary PCF) Recall Λ(Ω), the (call-by-name) λ-calculus with single base type ι with a constant for non-termination. Define a type of ‘Church Booleans’: bool := ι ⇒ (ι ⇒ ι). Non-termination, call-by-name λ-abstraction and application based on this ‘ground type’ can be extended with the constants of boolean PCF defined as macros:

• tt =_{df} λx.λy.x

• ff =_{df} λx.λy.y

• IF r then s else t =_{df} λx.λy.r (s xy)(t xy).

However there are terms of Λ(Ω) which are not (βη equivalent to) the translation of a term of boolean PCF. Such terms can use the intensional way in which data has been defined to extract intensional information about their arguments (pace PCF). For example, the following strictness test returns tt on a function which evaluates its argument (as the only way for a Λ(Ω)-term to use argument is by applying it to something, which will be discarded). If f is not strict, then the test returns ff as it applies its result (which is a projection) twice to its second argument. strict?: (bool ⇒ bool) ⇒ bool = λf : bool ⇒ bool.λx: ι.λy: ι.f (λz.λz.x) y y

The strictness test can, of course, be written using control operators: — this chapter will show that they bridge the gap between PCF and computation by continuation-passing by supplying the missing expressive power. The cps translation can thus be viewed as a compilation which structures procedures of the low-level control language λ(Ω) so that they can be written as functional programs using control operators at lower types. This gives the best of both worlds; a simple semantics for a powerful language.

The second section of the chapter describes the syntax of the λμ-calculus and μPCF, the third gives a unified call-by-name and call-by-value operational semantics, which is proved complete with-respect-to a minimal notion of adequate model in the fourth part. The fifth section describes a denotational semantics for the call-by-name language via a cps translation. Full abstraction for the games model is proved by showing that the translation restricts to a bijection between ‘finite normal forms’ in the next part. Sections 7, 8 and 9 define denotational models of the call-by-value language, show that λμ_{v} is a complete syntax of control, and give definability and full abstraction results.

4.2 Representing functional control

Control operators such as strict?, or the catch operators of SPCF are a simple way to add escapes to call-by-name PCF. However, more complex control manipulation involving continuations, requires a more expressive syntax. The λμ-calculus has been chosen here as it defines control manipulations in a way which is easy to represent in a model of control, and can be given an operational semantics and an equational theory in a straightforward way. It originated as a calculus for classical natural deduction in the work of Parigot [69], who noted the existence of terms corresponding to control operators. λμ has migrated via the extended Curry-Howard correspondence: it has subsequently been proposed as a ‘foundation for functional computation with control’ by Ong and Stewart [67], who developed a call-by value version, and used it to extend PCF with control features. Important confirmation of its suitability as a syntax for control has been provided recently by Selinger [79], who has proved that it is the internal language of a ‘control category’ (as outlined in Section 2.3.2).

\overline{x:A⊢x:A} Ax
\frac{Γ,x:A⊢t:B;Δ}{Γ⊢λx.t:A⇒B;Δ} ⇒-intro  \frac{Γ⊢s:A⇒B;Δ Γ⊢t:A;Δ}{Γ⊢s t:B;Δ} ⇒-elim
\frac{Γ⊢s:A;Δ}{Γ⊢[α:A]s;Δ,α:A} 0-intro  \frac{Γ⊢s:0;Δ,β:B}{Γ⊢μβ.s:B;Δ} 0 -elim

Figure 4.1: Terms-in-context of the λμ calculus

λμ is a convenient, and in some senses canonical choice of syntax but it does not provide any greater expressive power than call/cc, or its idealized brother, Felleisen’s 𝒞 [25]. To make this claim more precise: one of the advantages of μPCF is that it can be considered with or without admitting the empty type. It will be shown that the closed terms which can be written with the empty type are expressible using 𝒞 (and vice-versa), whilst those which can be written without the empty type are expressible using call/cc. λμ is syntactically more complicated than either, as it adds a new ‘continuation binding’ operation to the λ-calculus, (this step was already present in Reynolds’ definition of the Escape operator [76] (1972)). This has the advantage of making the control aspect of the calculus more explicit, and separate from the functional part.

4.2.1 The λμ calculus: call-by-name and call-by-value

Terms of the λμ calculus are obtained by adding the operations of naming and μ-abstraction to the λ-calculus. A term-in-context t is supplied with sets Γ containing the free variables of t, and Δ containing its free names (represented as small-case greek letters) so weakening, permutation and contraction hold for both contexts. The variable convention of [8] is adopted for names as well as variables. Terms-in-context are formed as set out in the table (Figure 4.1). To name a term of type T requires a name α of type T, the named term has type 0 (the empty type). There are no names of type 0. Any free name α: T in a term t: 0 can be bound by a μ-abstraction, written μα.t: T.

Partiality is added to the λμ-calculus by extending it with the single constant Ω : 0, from which Ω^{T} : T = μα.Ω^{0} can be derived at any type. Extension with product types and pairing is not described, but is completely straightforward.

The intuition upon which the continuation-passing semantics of λμ is based is that a term of type T can be interpreted as a map from continuations of type T, to the answer object. This is just the standard interpretation of a functional language in the Kleisli category of the monad of continuations described in Chapter 2. Names of type T are simply variables of type T ⇒ 0 representing continuations of type T. Naming corresponds to applying the current denotation to a continuation variable, and getting something of answer type. μ-abstraction is the λ-abstraction of such a variable from a term of answer type, giving a denotation of type T.

In order to define an operational interpretation based on this intuition, it is useful to have a syntactic representation of the current continuation. This is provided by the notion of ‘evaluation context’. (Note that there are a variety of subtly different definitions of this in the literature.)

Definition 4.2.1 Values (written u, v, …), range over variables and λ-abstractions, i.e.

v ::= x | λx.t.

Contexts with a hole of type T will be written as E^{T} [·], (as distinct from E[·] : T, where the result of filling the hole is a term of type T). Call-by-name evaluation contexts are defined inductively over the following grammar (respecting the typing rules for λμ):

E^{T} [·] ::= [·] : T | [α]E^{T} [·] | E^{T} [·] t

and call-by-value evaluation contexts over:

E[·] ::= [·] : T | [α]E^{T} [·] | E^{T} [·] t | v E^{T} [·]

where t ranges over general terms, and v over values.

The equational theory of each version of the λμ-calculus is given (up to α-equivalence of names and variables) by the standard βη-equalities of the λcalculus, together with the following rules.

(μη) μα.[α]t =_{μ} t (α not free in t),

(μζ) E[μα.t] : 0 =_{μ} t[E[·]/α] (note the type restriction on E[·]).

In the call-by-name version, β, η, and the notion of evaluation context are call-by-name, in the call-by-value version, they are call-by-value. (Completeness of the call-by-value theory for control models requires minor additional axioms discussed in Section 4.9.) The operation which requires some explanation is the substitution of a context for a name used in μζ. (This is essentially a simplified form of the mixed substitution of [69].) t[E[·]/[α]] means: replace occurrences of named subterms [α]r in s with E[r]. i.e. suppose t = C[[α]r_{1}] … [[α]r_{n}], where α does not occur free in C[·] … [·] or r_{1}, … r_{n}; then t[E[·]/α] = C[E[r_{1}]] … [E[r_{n}]]. Formally, it can be defined by induction on term-structure:

Definition 4.2.2 (Named-substitution)

\begin{matrix}x[E[·]/α] = x & [α]t[E[·]/α] = E[t[E[·]/α]] \\ (s t)[E[·]/α] = s[E[·]/α] t[E[·]/α] & (λx.t)[E[·]/α] = λx.(t[E[·]/α]) \\ (μβ.t)[E[·]/α] = μβ.(t[E[·]/α]) & ([β]t)[E[·]/α] = [β](t[E[·]/α]) \end{matrix}

This is a slight modification to the axiomatizations proposed by Parigot [69] and by Ong [66], firstly in its presentation via evaluation contexts instead of single applications (but this is a minor change, which is implicit in Ong and Stewart’s paper [67]). There is also a change to the rules: the presentations cited above have an additional rule, (μβ) [γ]μα.t = t[γ/α] and a separate μζ-rule covering non-zero typed contexts, which is (presented using evaluation contexts) μζ : E^{T} [μα.t] = μβ.t[[β]E[·]/α].

Proposition 4.2.3 The λμ theory proposed here is equivalent to those in [69] and [66].

Proof: μβ is derivable as an instance of μζ as [α][·] is an evaluation context: [α]μβ.t = t[β/[α][·]]. μζ is derivable using μζ^{0} and μη: E^{T} [μα.t] = μβ.[β].E[μα.t]^{T} = μβ.t[[β]E[·]/α]. □

The presentation given here is closer to the continuation passing interpretation which will be developed, making soundness and adequacy proofs for the semantics a little simpler. (Although the original rules were derived from the normalization of classical proofs, so it could be argued that this is moving further from the Curry-Howard correspondence, and towards a purely control-based analysis.)

4.2.2 Sum types in λμ

One advantage of λμ is that it provides a natural syntax for terms at sum types, compared to the λ-calculus alone. (As one would hope, moving to a multiple conclusion logic simplifies the behaviour of disjunction.) Among several possibilities for annotating sums, rather than allowing names to take disjunctive types, naming of a term of type A + B requires a pair (tuple) of names of type A and type B. (Thinking of names as variables of type A ⇒ 0 an B ⇒ 0, naming of t: A + B with α: A, β: B is by applying the co-pair [α, β].)

Definition 4.2.4 Form the λμ^{+} calculus by extending the types over which formulas (and variables) may range with finite sum types A + B. Names may take only types with a main connective which is negative (i.e. A ⇒ B, A×B), which is a natural extension of the rule that names may not take the empty type. Extend the typing judgements of λμ as follows:

\frac{Γ ⊢ t: A + B; Δ}{Γ ⊢ [α, β]t: 0; α: A, β: B, Δ}

\frac{Γ ⊢ t: 0; α: A, β: B, Δ}{Γ ⊢ μ[α, β].t: A + B; Δ}

This extends naturally to all finite sums The equational theory of λμ_{v}^{+} is given by adapting the (Ong and Stewart) theory for λμ by

• retaining μη at all types,

• restricting μζ E[μ[α, β, …].t] : 0 =_{μ} t[E[·]/[α, β, …]] to cases where α, β, … only occur conjointly in t,

• Adding μβ, without the above restriction i.e. [γ : A, δ : B, …]μ[α: A, β: B].t =_{μ} t[γ/α, δ/β].

Standard constructors for sum types can be derived; for instance, define: in_{l}(t: A) = (μ[α, β].[α]t) : A + B, in_{l}(t: A) = (μ[α, β].[β]t) (assuming α, β not free in t), and given t: A ⇒ C, s: B ⇒ C, r: A + B, define (case r of t, s): C = μγ: C.[γ]t (μβ.[γ: C]s (μ[α].[α, β]r)) (so case in_{l}(t) of u, v =_{μ} u t, and case in_{r}(t) of u, v =_{μ} v t).

One could therefore use λμ^{+} to add a sum type constructor to PCF. However an additional reason for introducing it is that by including sum types in the callby-value language, a cps translation can be given which is surjective onto types and terms of Λ(Ω), showing that λμ_{v}^{+}(Ω) is a complete syntax of control (see Section 4.9).

4.2.3 μPCF: variations on the control theme

Definition 4.2.5 Form the language μPCF by extending λμ with the constants of PCF, forming terms-in-context over function types generated from the atomic basis 0, nat. The equational theory of μPCF is given by the extension of the λμ theory with the rules for the constants (and fixpoint operator) of PCF.

In a further, minor departure from the standard presentation of PCF, the conditional is given at type 0. i.e.

\frac{Γ ⊢ N: nat, M: 0, L: 0}{Γ ⊢ IF0 N then M else L: 0}

and similarly for each case statement. This proves to be a canonical choice in the semantics, but the original conditional can be recovered as μα.[α]IF0 N then [α]M else [α]L, where α is not free in L, M, N.

An equational theory for μPCF can be given by extending the theory of PCF with the rules μη, and μζ, extending the notion of evaluation context appropriately as follows.

Definition 4.2.6 (Evaluation contexts of μPCF) Call-by name evaluation contexts are defined inductively as:: E[·] ::= [·] |

[α]E[·] | E[·] M |
IF0 E[·] then M else N | succ E[·] | pred E[·]

and call-by-value evaluation contexts as: E[·] ::= [·]|

[α]E[·] | E[·] M | V E[·] |
IF 0 E[·] then M else N | succ E[·] | pred E[·].

The type 0 (or ⊥) appears to have an important role in ‘idealized’ control calculi such as λ𝒞 and λμ. However, ‘real’ control operators like call/cc do not use such an empty type. It is the very fact that 0 has no values which makes it useful in the semantics of control; if the current continuation takes arguments of type 0 to results of type 0 then it can safely be discarded. In terms of the Curry-Howard correspondence, the idealized control operators correspond to full classical logic, and (typed) call/cc to minimal logic. Both systems are of interest, and one of the advantages of the λμ calculus (as opposed to Felleisen’s 𝒞 and call/cc) is that it is flexible in allowing both within the same framework. Thus a single denotational and operational semantics proves to be sufficient.

One can admit the type 0 to the type-system of PCF as a base type alongside nat. Or one can form the language, designated μPCF^{−} by Ong and Stewart, in which the use of the type 0 is restricted to namings.

Definition 4.2.7 Form the language μPCF^{−} (call-by-name or call-by-value) by restricting the typing judgements of μPCF as follows: the terms-in-context of μPCF^{−}; Γ ⊢ t: T, Δ, are formed as for μPCF with the restriction that Γ, Δ contain only PCF-types, and T is 0, or a PCF type. (So every subterm of t has a PCF-type or the empty type.)

(The only well-formed terms of type 0 in μPCF^{−} are namings and conditionals, and any naming must be immediately followed by a μ-abstraction, and any μabstraction must follow a naming.) There will be some further comment on the semantic distinctions between μPCF and μPCF^{−}, but as the operational semantics and associated proofs can be presented so as to apply to both, they will be assumed to do so unless otherwise noted. The following system with ‘first-order’ control can also be defined.

Definition 4.2.8 Form the language μPCF^{1} (call-by-name or call-by-value, with or without 0-types) as for μPCF, but restrict the use of names to the type nat. (This system is closed under the operational semantics which will be introduced.)

Three different variations on the λμ calculus, giving eight different languages have now been defined, however, the distinction between first and second order is empty in the call-by-name versions. This can be seen as a syntactic counterpart to the observation that the only violations of the bracketing condition possible in the games models of call-by-name PCF are weak, representing only downward continuation passing [82]. Or, from the logical standpoint, that all of propositional classical (or minimal) implicational logic can be deduced from intuitionistic logic with ‘atomic stability’, — classical rules at atomic (or disjunctive) types. Rules ‘bootstrapping’ double-negation to higher types (as described below) were given by Prawitz [75].

Proposition 4.2.9 With or without 0-types, μPCF_{n}^{1} is equivalent to full μPCF_{n} (in that the latter can be soundly translated into the former).

Proof: Naming at arrow-types in call-by-name can be eliminated as follows. For a μPCF-type T = A ⇒ B, assuming B ≠ 0, to each μ-name α of type T, associate a μ-name α′ of type B and a variable x_{α} : A. Now translate higher-type naming and μ-abstraction in a term M as follows: Replace every named subterm of M, [α^{T}]N with [α′](N x_{α}), and every μ-abstraction with λx^{α}.μα′.M. (This can be defined formally as an inductive translation on terms.)

To show that all of the theory of λμ holds with respect to this translation, the following simple lemma can be proved by structural induction.

Lemma 4.2.10 For any μPCF term M, M[[α′][·]] x_{α}/α][N/x_{α}][E[·]/α′] = M[E[[·] N]/α].

Hence the translation is sound: μζ holds, because if E^{A⇒B}[·] : 0 is a μPCF_{n} evaluation context, then either E[·] = E′[[β]·], in which case E^{A⇒B}[μα.M] translates as E[[β′](λx.μα′.M′ x_{β})] = E[β′]μα′.M′] = M′[E[·]/α] as required. Or E[·] = E′[· N], for some term N : A, so ignoring other names, E[μα.M] translates as E′[λx_{α}.μα′.M[([α′][·] x_{α})/α] N] =_{μ} M[([α′][·] x_{α})/α][N/x_{α}][E′[·]/α′] and by the lemma, this is equal to M[E′[[·] N]/α] as required. The rule μη translates as λx_{α}.(μα.[α]M) x_{α} =_{μ} M by μη, and λη. Hence μ-names of type T = A_{1} ⇒ (A_{2} ⇒ … ⇒ (A_{n} ⇒ At) …), can be replaced by a ground-type name, and a set of n variables, x_{1}^{α}: T_{1}, … x_{n}^{α}: T_{n}. □

With respect to call-by-value, (or call-by-name with disjunctive types) the situation is different: the above method of ‘bootstrapping’ first order λμ to higher order gives terms which are type-correct, but which are not observationally equivalent to true higher-order μ-abstraction. (As pointed out to me by Hayo Thielecke.) Moreover, one can show by the fact that the fully abstract semantics of μPCF_{v}^{1} and μPCF_{v} are inequivalent, that any such attempt at defining higher-order call/cc using first-order instances is doomed to failure.

4.3 Operational Semantics

The main difficulty with giving an operational semantics of μPCF is that it is necessary to evaluate terms ‘inside’ a μ-abstraction. Ong and Stewart described a one-step operational semantics of μPCF_{v} in [67] which is quite complicated (it requires two separate evaluation relations). The simplified semantics described here is based on evaluation-contexts. Thus it dovetails with the presentation of the equational theory of λμ. It is intuitive, as these contexts give an obvious notion of the ‘next redex’ to be reduced in evaluating a program. And it is general; adapted to both call-by-name and call-by-value semantics by the tradeoff between the more restricted notion of β-reduction in call-by-value, and the richer notion of evaluation context that it allows.

Definition 4.3.1 (PCF reductions) Let the small-step PCF reduction relation ⟶, be given by the following rules:

(β) (λx.M) N ⟶ M[N/x]

IF0 0 then M else N ⟶ M IF0 succ n then N else N ⟶ N YM ⟶ M (λx.(YM) x)

                        pred (succ n) ⟶ n

pred 0 ⟶ Yλx.x

The call-by-value reductions are given by stipulating that N must be a value in the β-reduction clause.

The following proposition partially captures the way in which evaluation contexts ‘pick out’ the next reduction step.

Proposition 4.3.2 Any term M of μP CF or μPCF^{−} (call-by-name or call-by-value) with no free variables (but possibly free names) is uniquely in one of the following forms: M = n | λx.N | E[μα.N] | E[r] | E[[α]V] where N is any term, r is a PCF-redex, V is a value, and E[·] an evaluation context.

Proof: is by structural induction on terms. If M = λx.N, M = μα.N, M = n, M = [α]V, or M = YN, then the hypothesis holds directly. Otherwise, if M = IF0 N then L else L′, and N is either a numeral (so M is a PCF-redex, or N = E[N′], where N′ is a naming, μ-abstraction, or PCF-redex, so M = E′[N′], is also in this form. The cases M = succ N, and M = pred N are similar. If M = [α]N, where N is not a value, then N is E[N′] where N′ is a named value, redex, or μ-abstraction. If M = L N, then it is necessary to distinguish call-by-name and call-by-value cases. For call-by-name, either L = λx.L′, and so M is a β-redex. Or L = E[r] for some redex r, and so M is also of this form. For call-by-value, suppose L = λx.L′, then if N is a value, M is a β_{v} redex. Otherwise, N = E[N′], where N′ is a named value, PCF-redex or μ-abstraction, in which case M is also of this form. If L is not a value, then by induction hypothesis, it is equal to E[L′], where L′ is a named value, μ-abstraction or PCF-redex, and so M is of the same form. □

Corollary 4.3.3 μPCF programs (closed terms of type nat) are either numerals, or uniquely in one of the following ‘reducible forms’: M = E′[μα.N] | E[r] | μα.[α]n | μα.E[μβ.N] | μα.E[r] where E[·] ranges over all evaluation contexts, and E′[·] only over non-trivial ones, and r over PCF redexes.

Proof: By Proposition 4.3.2 above, M is either a numeral, or in the form E[r] for a PCF redex r, or in the form E[μα.N] for some N, where E[·] is either trivial (E[·] = [·]) or non-trivial. If E[·] is trivial, so M = μα.(N : 0), then by Proposition 4.3.2 either N = [α]n or N is (uniquely) of the form E[r] for a PCF redex r, or N = E[μβ.N′]. □

Corollary 4.3.3 means that the operational semantics can be given in the following simple format, based on a combination of Plotkin’s ‘Structured Operational Semantics’ [72], and Felleisen’s use of unique decomposition of programs into a redex and an evaluation context, with one clause for each of the ‘reducible forms’.

n ⇓ n  μα.[α]n ⇓ n
\frac{r⟶s E[s]⇓n}{E[r]⇓n}  \frac{r⟶s μα.E[s]⇓n}{μα.E[r]⇓n}

\frac{μα.M[[α]E′[·]/β]⇓n}{E′[μβ.M]⇓n}  \frac{μα.M[E[·]/β]⇓n}{μα.E[μβ.M]⇓n}

(E′[·] is non-trivial.)

Figure 4.2: One-step operational semantics of μPCF

(Note that the terms of μPCF^{1} are closed under reduction, and that the first two rules in the left column give a sound and complete PCF semantics).

Proposition 4.3.4 (Determinism) If M ⇓, (i.e. M ⇓ n for some n) then the derivation in the operational semantics is unique. Hence M ⇓ n implies M ⇓̸ n′ for n ≠ n′.

Proof: is direct by Corollary 4.3.3. □

For the purposes of this thesis (considering fully abstract models), it is quite sufficient to consider only the evaluation of ground-type terms to numerals. Giving an operational semantics of programs also has the advantage that all terms either converge to a value, or diverge (this is a corollary of computational adequacy). Significantly, this is not the case for higher-order terms of μPCF_{v}, — for terms of the form μα.[α]λx.N, where α occurs in N (see [67]). However, the operational semantics given here can be used to evaluate higherorder terms, (change the first rule in the right hand column to μα.[α]V ⇓ V if α is not free in V) and it is complete (in the sense that evaluation of any term which denotes a value terminates at avalue). Note also that the notion of observational equivalence used (program-type contextual equivalence), is equivalent to all-type contextual equivalence in an operational semantics based on evaluation of higher-type terms to values.

Proposition 4.3.5 For terms M, N : T, M ⊑_{T}^{OBS} N ⟺ ∀C^{T} [·] C[M] ⇓ V ⟹ C[N] ⇓ V.

Proof: The implication from right to left is trivial, for the converse, suppose there is some higher-typed context C[·] such that C[M] ⇓ V, and C[N] ⇓̸ V, then (λx : S.0) C[M] ⇓ 0, and (λx : S.0) C[N] ⇓̸ 0, so M ⋢_{T}^{OBS} N as required. □

The operational semantics is complete, and hence sufficient for the principal aim of proving full abstraction, however, it does not make any connection between the interactions of the game semantics, and the computation of programs. This possibility offers a new line of enquiry into the dynamics of computation with control, in light of the fact that the games models of μPCF are based on the CCC of one-move games. Danos, Herbelin and Regnier [21] have already given a close correspondence between interaction of strategies in both AJM and Hyland-Ong versions of these categories of games, and abstract machines for performing ‘linear head reduction’ in the λ-calculus. At a different level, Streicher and Reus [81] and Bierman [12] have suggested that an appropriate way of evaluating languages with control is to give an abstract machine which stores continuations (as evaluation contexts). Connecting these developments could be a way to optimize reduction strategies for languages which can be implemented using continuations, such as μPCF.

4.3.1 Expressing control in μPCF

Although μPCF is an ‘idealized’ language, it is suitable to represent a variety of control constructs based on continuation passing; this has been known since Parigot devised the λμ-calculus [69], and is a theme of the paper of Ong and Stewart [67], in which μPCF is introduced. The call-with-current-continuation operator of Scheme, which is perhaps the most natural control extension of a functional language from a programming point of view, provides a useful example showing how μ-abstraction and naming correspond to ‘catch and throw’ of the current continuation. Parigot observed that the term of λμ corresponding to a natural deduction proof of Peirce’s law has the same operational behaviour as call/cc [69], and a more formal connection with the callcc of SML of New Jersey [35] is described in [67]. In the other direction, there is the question of whether λμ terms can be written using call/cc. The result proved in [48], that unbracketed games give fully complete model of PCF + call/cc establishes that all closed μPCF_{n}^{−} terms are definable with call/cc. The definability of terms λμ_{v} using 𝒞 (Felleisen’s ‘idealized call/cc’), and vice-versa, is shown in Section 4.8.

Expressing the catch and error terms of Cartwright and Felleisen’s SPCF establishes a link with the fully abstract semantics of this language in the category of sequential algorithms, which will be studied semantically in the next chapter. However, μPCF cannot express control operators such as the exception handler of ML, which use dynamic, rather than static variable bindings (such as μ-abstraction and λ-abstraction).

Definition 4.3.6 (Call-with-current-continuation) The operational semantics of PCF can be extended with call/cc by evaluating terms within a context of ‘continuation variables’ bound to evaluation contexts (a similar semantics for μPCF is described by Bierman in [12]). The role of call/cc is to bind the current continuation to a variable; applying a continuation variable replaces the current continuation with the one which has been bound to the variable. As in Lemma 4.3.2, every λ-closed term is uniquely in the form E[r], where r is the next redex to be evaluated, or E[call/ccM], or E[kM], where k is a continuation variable. So terms can be completely evaluated with the following rules.

\begin{matrix}\overline{V,∅⇓_{c}V} & \frac{r⟶s, E[s],K⇓_{c}V}{E[r],K⇓_{c}V} \\ \frac{E[M],K∪\{k→E[·]\}⇓V}{E[call/cc λk.M],K⇓_{c}V} & \frac{E[M],K⇓V, k→E[·]∈K}{E′[k M],K⇓_{c}V} \end{matrix}

Definition 4.3.7 For any term M: (T ⇒ S) ⇒ T, (call/cc M) will be written in μPCF as (μα: T.[α]M (λy: T.μβ: S.[α]y)).

Proposition 4.3.8 Let M be any program of PCF + call/cc (interpreted in μPCF as defined above), then

M, ∅ ⇓_{c}⇔ M ⇓_{μ}

Proof: To prove this claim, generalize it to include non-empty sets of continuation variables as follows. Let M be a term such that there is an assignment K_{M} of appropriately typed evaluation contexts without free variables, E_{k}[·] to each of the continuation variables k ∈ Cont(M). Define the substitution K_{μ} such that if K(k: T ⇒ S)) = E[·] then K_{μ}(k) = λx: T.μβ^{S}.[α]E[x]. Then

M, K ⇓_{c} ⟺ μα.[α]M_{K_{μ}} ⇓_{μ} .

Proof is by induction on the length of evaluation, of which the key induction steps are like this.

• Suppose M = E[call/cc λk.s], then (proving the implication from left to right) E[s], K ∪ (k → E[·]) ⇓_{c}, with a shorter derivation, by definition of the evaluation relation for call/cc. Hence by hypothesis, μα.[α]E[s[λx.μβ.[α]x/k]]_{K_{μ}} ⇓_{μ}, so μα.[α]E[μγ.[γ]λk.s (λx.μβ.[γ]x)] ⇓_{μ} as required. In the opposite direction, μα.[α]E[s[k/λx.μβ.[α]E[x]] ⇓_{μ} by definition of ⇓_{μ} and by hypothesis E[s]K ∪ k → E[·] ⇓_{c}, and so E[call/cc λk.s], K ⇓_{c}

• Suppose M = E[k V] for some k ∈ Cont(M) such that K(k) = E′[·], then E′[V], K ⇓_{c} and so by hypothesis, μα.[α]E′[V]_{K_{μ}} ⇓_{μ}, and so μα.[α]E[μβ.[α]E′[V]]_{K_{μ}} ⇓_{μ} and μα.[α]E[k V]_{K_{μ}} ⇓_{μ} as required. In the opposite direction: μα.[α]E[λx.μβ.[α]E′[x]V]_{K_{μ}} ⇓_{μ} implies μα.[α]E′[V]_{K_{μ}} ⇓_{μ} and by hypothesis, E′[V], K ⇓_{c}, henceE[k V], K ⇓_{c}

□

4.3.2 μPCF and SPCF

SPCF(E) is call-by-name PCF extended with a set of errors E (possibly empty), and a group of ‘catch’ constructs which take a term M: (S_{1} ⇒ (S_{2} ⇒ … (S_{n} ⇒ nat) …)) and return n if the first argument consulted by M is the nth, and (t Ω) + n + 1 if M is non-strict. This procedure can be defined in μPCF, as

catch^{T} = λf: T.μα: nat.[α](((f (μβ.[α]0)μβ.[α]1) … μβ.[α]n) + (n + 1)).

A control feature of SPCF of a somewhat different kind is the inclusion of constants for reporting run-time errors by terminating evaluation and returning an ‘error value’. It is not possible to simulate errors directly in μPCF, as a whole new notion of evaluation is required, but it is possible to represent errors in μPCF^{E}, which is a generalization of the errors of SPCF, as ‘uncaught’ continuations.

Definition 4.3.9 Form the language μPCF^{E} (call-by-name or call-by-value μPCF with errors) by extending the syntax of μPCF with an ω-indexed set of error terms {e_{i} | i ∈ ω}. Errors are assumed to be polymorphic, taking any type (as they are intuitively of type ∀X.X = 0). The unique reducible forms Lemma 4.3.2 can be extended to show that a program of μPCF^{E} is uniquely in one of the the following forms

M = v | E′[μβ.N] | E[r] | μα.[α]n | μα.E[μβ.N] | μα.E[r] | E[e_{i}] | μα.[α]E[e_{i}]

where E[·] ranges over all evaluation contexts, and E′[·] only over non-trivial ones. The range of the termination relation ⇓ is extended to include error-terms and the operational semantics can then be extended with the rules

\overline{E[e_{i}] ⇓ e_{i}}
\overline{μα.[α]E[e_{i}] ⇓ e_{i}.}

One can show with a routine induction that reduction of μPCF^{E} programs is deterministic, and either non-terminating, terminated by convergence to a value, or terminated by abortion to an error term.

Errors can be represented in μPCF itself by allowing ‘closed’ terms to contain a single free name ε of type nat, which can only be used as an error generator, writing e_{i} = μα.[ε]2.i, where α is typed appropriately for the context in which the error appears. Hence for any evaluation context E^{T} [·]: nat, E[e_{i}] =_{df} E[μα.[ε]i] =_{μ} μα: nat.[ε]2i =_{df} e_{i}.

Proposition 4.3.10 This can be formalised as a translation μPCF^{E} terms in context Γ ⊢ t: A; Δ to μPCF terms Γ ⊢ t^{∗}; Δ, ε such that M =_{μ(e)} N if and only M^{∗} = N^{∗}

Evaluation of Programs (ground-type closed terms) with errors can be simulated by translating, and binding the free μ-variable as follows.

M ⟶ με.[ε](succ (2.M^{∗}))

Proposition 4.3.11 M ⇓ n if and only if με.[ε](succ (2.M^{∗})) ⇓ 2n + 1, and M ⇓ e_{i} if and only if με.[ε](succ (2.M^{∗})) ⇓ 2i.

Errors can be represented semantically in much the same way as the ⊥-elements were added to the free CCC. A semantics of μPCF based on names as continuation variables can be generalised to a semantics of μPCF^{E} by ‘freely adjoining’ a typeobject representing a continution of type nat to Δ-contexts.

(In other words, attaching a set of ‘top’ elements to each domain: see Section 5.3.2.) A simple generalization of a context lemma for μPCF proved in Chapter 5 can be used to show a fact stressed by Cartwright, Curien and Felleisen, that operational equivalence in the presence of errors is order extensional (see Corollary 5.1.7). Error values alone are clearly less expressive than full call/cc: they allow the current continuation to be aborted (‘thrown’), but there is no recovery, it cannot be ‘caught’.

4.4 Completeness of the operational semantics

Like PCF (see [14]), the proof of adequacy of the μPCF semantics can be abstracted from any particular denotational framework, and based on soundness, together with two inequational conditions. In fact, these requirements are (unsurprisingly, but pleasingly) the same as those which have been used to axiomatize adequacy for PCF. A further pleasant feature of the dual purpose call-by-name/call-by-value operational semantics is that a single proof suffices to establish the completeness of the semantics for all of the variants of μPCF which have been defined.

The adequacy conditions must exclude the trivially sound model of μPCF in which all terms are identified. In other words, it is necessary for termination and non-termination to be distinguishable at ground type, which can be achieved with the following definition:

Definition 4.4.1 (Standard Datatypes) A semantics for μPCF has standard datatypes if each numeral is interpreted as a distinct denotation \overline{n}, and ⊥_{[[nat]]} ≠ \overline{n}. (In fact, in a sound model, this is equivalent to requiring only that ⊥_{[[nat]]} ≠ \overline{n} for all \overline{n}.)

The following lemma partially formalises the intuition that any term appearing inside an evaluation context must be evaluated.

Lemma 4.4.2 (Strictness of evaluation contexts) Let M be a semantics of μPCF (call-by-name or call-by-value), such that the μζ rule is soundly interpreted in M . Then for every nat-typed evaluation context E^{T} [·] : nat:

[[E[Ω^{T}]]]_{M} = [[Ω^{nat}]]_{M}.

Proof: Recall that Ω^{T} for T ≠ 0 is defined to be μα^{T} .Ω^{0}. By μζ, [[E^{T} [μα.Ω^{0}]]_{M} = [[μα : nat.Ω^{0}]]_{M} = [[Ω^{nat}]]_{M}. □

A second condition (adapted from [14]) is based on the fact that the Y combinator is interpreted as a least fixpoint. Hence it can be ‘unwound’.

Definition 4.4.3 (Continuous Observability) A semantics of μPCF is continuously observable if for every program of the form C[YM] : nat

[[C[YM]]] ≠ ⊥ ⟹ ∃k ∈ ω: [[C[M^{k}]]] ≠ ⊥

where M^{0} = Ω, and M^{k+1} = M(λx.(M^{k}x)). (So M^{k+1} = M M^{k} in call-by-name μPCF.)

Lemma 4.4.4 For all k ∈ ω, and (closed) μPCF contexts C^{T} [·] : nat, C[M^{k}] ⇓ n implies C[YM] ⇓ n.

Proof: is by induction first on k, and then on the length of derivation of C[F^{k}] ⇓ n. The important case is where C[·] is an evaluation context E[·]. Then E[M^{k+1}] ⇓ n implies E[M λx.M^{k} x] ⇓ n, so C′[M^{k}] ⇓ n, where C′[·] = C[M λx.[·] x], hence by inductive hypothesis, E[M λx.YM x] ⇓ n thus E[YM] ⇓ n. □

Theorem 4.4.5 Let M be a sound denotational semantics for μPCF which is continuously observable, and has standard datatypes. Then the operational semantics of μPCF is computationally adequate with respect to M i.e. For all terms M of type nat, [[M]] = \overline{n} if and only if M ⇓ n.

Proof: The soundness part (M ⇓ n implies [[M]] = \overline{n}) follows from a simple induction on the derivation of M, using the assumption that M is a sound model of the equational theory. It remains to show completeness ([[M]] = \overline{n} implies M ⇓ n). The following lemma shows that it is sufficient to consider terms without the Y combinator.

Lemma 4.4.6 Suppose M is a continuously observable semantics which is complete for Y-free terms, then M is complete for all terms.

Proof: that [[N]] = \overline{n} implies N ⇓ n is by induction on the number of occurrences of Y in N. Assuming this is greater than zero, choose a context such that N = C[YM], where M is Y-free. By continuous observablility, there exists k ∈ ω such that C[M^{k}] = \overline{n}, and then by inductive hypothesis, C[M^{k}] ⇓ n, and by Lemma 4.4.4 above, C[YM] ⇓ n as required. □

So it remains to prove completeness for recursion-free terms (as for PCF [71], by a now standard reducibility style argument based on a ‘computability predicate’). This is complicated, however, by the fact that the operational semantics (unavoidably) allows reduction inside a μ-abstraction. So it is useful to distinguish a single name α of type nat, and define the notion of computability first for terms containing (at most) α free, which will be called α-closed. Say that a term M of type T_{1} ⇒ (T_{2} … (T_{n} ⇒ nat) …), with no free variables or names (except α) is computable if whenever N_{1}, … N_{k} are computable α-closed terms,

[[(μα.[α](MN_{1}, … N_{k})]] = \overline{n}

implies

μα.[α](MN_{1}, … N_{k}) ⇓ n

Define a computable evaluation context (call-by-name or call-by-value) to be an evaluation context E[·] of type nat with no free variables or names except α, such that every α-closed subterm of E[·] is computable.

Lemma 4.4.7 An α-closed term M is computable if and only if [[μα.E[M]]] = \overline{n} implies μα.E[M] ⇓ n for all computable evaluation contexts.

Proof: The right to left implication is trivial, left to right can be proved by a simple induction on the structure of E[·]. □

Definition 4.4.8 For any term M, a computable variable-substitution for M is an assignment of computable α-closed terms to variables at each type T, a computable name-substitution for M is an assignment of a computable evaluation context [α]E^{T} [·] to the free names of M (other than α) at each type T. For each computable substitution σ of names and variables, M_{σ} is given by carrying out the replacements specified by σ.

Now say that term M with free variables and names is computable if M_{σ} is computable for every computable substitution σ such that M_{σ} is α-closed.

Proposition 4.4.9 Every term of μPCF is computable. By the lemma above, this is equivalent to the proposition that for every term M : T, every computable substitution σ such that M_{σ} is α-closed, and every computable evaluation context E^{T} [·] : 0, [[μα.E[M_{σ}]]] = \overline{n} implies μα.E[M_{σ}] ⇓ n. Proof: is by structural induction on M. Let σ be any computable substitution for M, such that [[μα.[α].E[M_{σ}]]] = \overline{n} By Lemma 4.3.2 μα.E[M_{σ}] is in one of the ‘reducible forms’ (and one of the latter three). Hence it is (uniquely) covered by one of the following cases.

• μα.[α].E[M_{σ}] = μα.E′[Ω] for some computable context E′[·]. But in this case [[μα.[α].E[M_{σ}]]] = ⊥_{n} by strictness of evaluation contexts, contradicting the hypothesis above.

• If μα.[α].E[M_{σ}] = μα.[α]n, μα.[α].E[M_{σ}] ⇓ n as required.

• If μα.E[M_{σ}] = μα.E′[r], for a computable context E′[·], and PCF-redex r, which is either pred (succ n), IF0 n then N else N′, or a β redex. The former case is trivial. If r is a conditional, it reduces to N or N′, both of which are computable by the induction hypothesis as they are subterms of M_{σ}. In case r is a β redex, it reduces to a computable substitution r′ = N[N′/x] which is therefore computable. So μα.[α]E′[r′] ⇓ n, and also μα.[α]E′[R] ⇓ n as required.

• If μα.E[M_{σ}] = μα.E′[μβ.N], for some non-trivial evaluation context E′[·], then N is shorter than M_{σ}, and computable by inductive hypothesis. [[μα.E′[μβ.N]]] = \overline{n} = μα.N[E′[·]/β], by soundness. Since N is computable, and [E′[·]/β] is a computable substitution, so μα.N[E′[·]/β] ⇓ n, and hence μα.E′[μβ.N] ⇓ n as well.

□

To prove the completeness theorem, a simple lemma can first be established by induction on the length of evaluation. Lemma 4.4.10 For any closed term M, if μα.[α]M ⇓ n then M ⇓ n. Proof of the completeness theorem Suppose M is a closed term such that [[M]] = \overline{n}. Then [[μα.[α]M]] = \overline{n} and so by computability, μα.[α]M ⇓ n, and by the above lemma M ⇓ n as required.

Corollary 4.4.11 Any sound model of PCF + call/cc with standard datatypes and continuous observability is computationally adequate.

4.5 Denotational semantics of μPCF via cps translation

It can now be shown that μPCF_{n} can be adequately interpreted in a computational control model, along the lines outlined in Chapter 2. That is, given a pointed and rational cartesian closed category with ω-indexed products, and a non-terminal answer object R, form the co-product completion Fam(C), and strong monad of continuations T = (( ⇒ a) ⇒ a), and interpret product and function types as product and exponential in Fam(C), and co-product types A+B as T([[A]] + [[B]]). Naming and μ-abstraction are interpreted as application and abstraction of continuation variables. Note, however, that only T({}) ≅ a, interpreting the empty type, and T({1_{n} | n ∈ ω} ≅ a^{ω} ⇒ a, interpreting nat are required for the full abstraction result. This yields a rational CCC head, tail,:: (and hence every embedding-projection pair e_{i}, p_{i}) is definable.

The call-by-name cps translation of μPCF_{n} into the simply-typed λ-calculus with ω-indexed products and least fixed points is probably the simplest route to this interpretation. It is described here both for its intrinsic interest (it is fully abstract), and because it provides a clearer way to understand naming and μ-abstraction as catch and throw of continuations. The role of names in call-by-name λμ is more subtle than in call-by-value; in the latter, they can be replaced by lambda-variables of ‘negated type’ (see Section 4.8.1), together with a double negation elimination. The call-by-name cps translation is simpler, however, as μ-abstraction and naming need be defined at ground type only.

To interpret infinite datatypes such as the natural numbers by cps translation requires infinite datatypes in the target language: it is sufficient to add a type constructor ( )^{ω} (T^{ω} being the infinite streams, or lists or products of type T), and its constructor ::, and deconstructors head and tail, to the simply-typed λ-calculus, to form the infinitary calculus Λ(Ω)^{ω}.

Definition 4.5.1 Types and terms of Λ(Ω)^{ω} are given by the following grammar: T ::= ι | T^{ω} | S ⇒ T t := x : T | (λx : S.t : T) : S ⇒ T | (t : S ⇒ T) (s : S) : T | t : T::s : T^{ω} : T^{ω} | head(t: T^{ω}): T |tail(t: T^{ω}): T^{ω} | Y(t: T ⇒ T): T. The equational theory of Λ(Ω)^{ω} is given by the standard call-by-name βη equality, and the following rules for lists and fixpoints:

• head(t::s) =_{Λ(Ω)^{ω}} t

• tail(t::s) =_{Λ(Ω)^{ω}} s

• Yf =_{Λ(Ω)^{ω}} f(Yf).

Definition 4.5.2 The following familiar operations on infinite lists can be defined: For each type T there is a diverging element of type T, Ω^{T} = Y(λx: T.x). Finite products ⟨t_{1}, …, t_{n}⟩ are defined as t_{1}::t_{2}:: … t_{n}::Ω^{ι^{ω}} and projections are defined by iterating the tail-operation: π_{i}t = head(tail^{i−1}(t)). For any t: ι, an infinite list of copies of t, δ(t) can be defined using the recursion combinator: δ(t) = Y(λx: ι^{ω}.t::x).

Proposition 4.5.3 The following equalities can be derived from the theory of Λ(Ω)^{ω}: π_{i}(⟨t_{1}, t_{2}, … t_{n}⟩) =_{π} t_{i}, head(δ(t)) = t, tail(⟨t_{1}, t_{2}, … t_{n}⟩) = ⟨t_{2}, …, t_{n}⟩.

It is clear that any rational pointed cartesian closed category with ω-indexed products (C, [[ι]]) is a sound model of Λ(Ω)^{ω}, and in particular that:

Proposition 4.5.4 The model of Λ(Ω)^{ω} in the category of unbracketed games, (G, o) is sound.

4.5.1 Continuation passing translation of μPCF_{n}

This can be seen as an application to μPCF of previous work on the pure calculus. The novel feature here is the use of infinite lists to model continuations of type nat. de Groote [23] described a wholly syntactic continuation-passing-interpretation of the λμ_{n}-calculus which is similar to the one given here. Hofmann and Streicher [40] gave a continuation semantics for λμ_{n}, and showed that it is universal in that any λμ_{n} model is isomorphic to such an interpretation (see the discussion in Remark 4.5.10 below).

Definition 4.5.5 (CPS translation of call-by-name μPCF) The translation on types is given by

• 0^{□} = ι

• nat^{□} = ι^{ω} ⇒ ι

• (S ⇒ T)^{□} = S^{□} ⇒ T^{□} Note that to translate μPCF_{n} requires only ω-indexed products in Λ(Ω)^{ω} at groundtype, (written Λ(Ω)_{1}^{ω}). Terms-in context are translated by assuming a correspondence between μPCF variables x: T and Λ(Ω)^{ω} variables x^{□}: T^{□}, and between names α : nat, and Λ(Ω)^{ω}- variables α^{□}: ι^{ω}. So (Γ ⊢ t; Δ)^{□} = Γ^{□}, Δ^{□} ⊢ t^{□}, where t^{□} is defined by induction:

• (x)^{□} = x^{□}

• (λx.M)^{□} = λx^{□}.M^{□}

• (M N)^{□} = M^{□} N^{□}

• 0^{□} = λx: ι^{ω}.head(x)

• (succ M)^{□} = λx: ι^{ω}.M^{□} (tail(x))

• (pred M)^{□} = λx: ι^{ω}.M^{□} (Ω::x)

• (IF0 M then L else N)^{□} = M^{□} (L^{□}::δ(N^{□}))

• (YM)^{□} = YM^{□}

• ([α]M)^{□} = M^{□} (α^{□})

• (μα.M)^{□} = λα^{□}.M^{□} The interpretation of terms of μPCF_{n} in the games model can now be given via translation into Λ(Ω)^{ω}, and interpretation in G; i.e.

[[M]]_{G} = [[M^{□}]]_{G}

The well-bracketed model of PCF embeds into the semantics of μPCF_{n} as described in Chapter 3. Proposition 4.5.6 The denotations of the PCF types (as games) and PCF terms (as innocent functions) under the above interpretation are play-equivalent to those in the Hyland-Ong model of PCF without the bracketing condition. The proof of soundness of the translation uses the following lemma. Lemma 4.5.7 For every 0-typed, nat-holed μPCF_{n} evaluation context E^{nat}[·] : 0, there is a term N : ι^{ω} of Λ(Ω)^{ω} such that for any μPCF term M : nat, E[M]^{□} =_{Λ(Ω)^{ω}} M^{□} N.

Proof: is by induction on μPCF_{n}-evaluation contexts. There are two base cases, the conditional and naming: (IF0 M then L else N)^{□} = M^{□} L^{□}::δ(N^{□}) ([α]M)^{□} = M^{□} α^{□} For the inductive step in which E^{nat}[·] : 0 = E′[succ [·]] for some smaller E′[·], the induction hypothesis gives N′ : ι^{ω} such that E′[M′]^{□} = M^{′□} N′ for any M′. Let N = tail(N′), then E′[succ M]^{□} =_{Λ(Ω)^{ω}} (succ M)^{□} N′ = (λz : ι^{ω}.M^{□} tail(z)) N′ =_{Λ(Ω)^{ω}} M^{□} N as required. The case E[·] = E′[pred ·] is similar. □

Lemma 4.5.8 If E^{nat}[·] : 0 is a μPCF_{n} evaluation context, and N the associated term of Λ(Ω)^{ω} such that for all M : nat, E[M]^{□} =_{Λ(Ω)^{ω}} M^{□}N, then for all μPCF terms L, L[E[·]/α]^{□} = L^{□}[N/α^{□}].

Proof: is by induction over the structure of L, for example, ([α]M[E[·]/α])^{□} = E[M[E[·]/α]]^{□} = (M[E[·]/α])^{□}N = (M^{□} α^{□})[N/α^{□}] = ([α]M)^{□}[N/α^{□}]. □

Proposition 4.5.9 The translation is sound with respect to the equational theories of μPCF_{n} and Λ(Ω)^{ω}.

Proof: The βη equalities are preserved by the translation, and it is easy to check that the Peano axioms and equalities for the conditional are satisfied. μη : (μα.[α]M)^{□} =_{μ} λα^{□}.M^{□} α^{□} = M^{□} The μζ rule translates to a β-substitution: by Lemma 4.5.7 above, (E[μα.M] : 0)^{□} =_{Λ(Ω)^{ω}} λα^{□}.M^{□} N =_{Λ(Ω)^{ω}} M^{□}[N/α^{□}]. By Lemma 4.5.8, M^{□}[N/α^{□}] = M[E[·]/α]^{□} as required. □

Remark 4.5.10 (Relation to Hofmann-Streicher Models of λμ) By the completeness theorem of Hofmann and Streicher mentioned above, every sound model of λμ is isomorphic to a category of continuations constructed from a category C as follows: select an answers object R from C. For each type T, define the continuations of type T as [[0]]_{c} = 1_{C}, and [[S ⇒ T]]_{c} = R^{[[S]]_{c}} × [[T]]_{c}. (Leaving open the interpretation of continuations of ground types other than 0.) The denotations of type T are given in R^{[[T]]_{c}} (So that a denotation corresponds to a map from a continuation to an answer, and a continuation at arrow type to pair of a denotation of argument type and a continuation of result type.) Hence for a PCF-type T = A_{1} ⇒ (A_{2} ⇒ … (A_{n} ⇒ nat) …), [[T]]_{c} ≅ [[A_{1}]]_{D} × … × [[A_{n}]]_{D} × [[nat]]_{c}, [[T]]_{D} ≅ R^{[[A_{1}]]_{D}×...×[[A_{n}]]_{D}×[[nat]]_{c}} ≅ ([[A_{1}]]_{D} × … × [[A_{n}]]_{D}) ⇒ [[nat]]_{D}. So denotations at PCF-types are given the standard interpretation, and a continuation at higher type is given by a product of denotations with a continuation at ground type. This is how higher-type names are interpreted using the ‘bootstrapping’ described in Proposition 4.2.9.

Another perspective on the semantics of call-by-name λμ is given by Ong in ‘A Semantic view of Classical Proofs’ [66]. This paper describes categorical and game semantic notions of λμ-model, both of which are quite different to anything which appears here. The categorical model characterizes the operation of ‘mixed substitution’ directly, rather than by continuation-passing. Ong’s ‘λμ-categories’, are split fibrations; CCC’s (i.e. λ-models) fibred over cartesian products representing μ-contexts. (So continuations models are a trivial example of such a fibration, in which the fibre for each μ-context is the CCC with the corresponding context of continuation variables adjoined to it.) Because of the various completeness results for cps semantics (such as [40]) it is known that every λμ-category can be written as a category of continuations in this way.

The relationship of the games semantics of λμ_{n} in [66] to the unbracketed one is less clear. Ong’s model retains the well-bracketing condition, but adds a notion of state via ‘scratchpads’. These allow Player to give ‘dummy’ answers to questions which he would just skip over in the corresponding unbracketed strategy. It seems fair to say that the unbracketed games model, based on relaxing conditions rather than adding structure, is a simpler category; it has also been possible to connect local and non-local control semantically in a natural way. However the extra structure of scratchpads and control questions could prove useful in studying control-flow in games, using information which could be extracted from a formal connection between the games via the relationship between the corresponding categorical models. Proposition 4.5.11 If (C, a) specifies a computational model of control (i.e. C is a rational CCC with ω-indexed products, and a is non-terminal) then the semantics of μPCF_{n} in (C, a) given by translation into Λ(Ω)^{ω} is computationally adequate with respect to the operational semantics. Proof: The semantics in G meet the adequacy criteria stated in Theorem 4.4.5, as the translation into Λ(Ω)^{ω} is sound, and G has standard datatypes and is continuously observable. Datatypes are standard Suppose a is non-terminal: then ⊥_{a,a} = t_{a}; ⊥_{a} ≠ id_{a}.

Hence for every i ∈ ω, [[n]] = ‘π_{n}’ : a^{ω} ⇒ a ≠ ‘⊥_{a^{ω},a}’.

Continuous observability If C is rational, then the semantics of μPCF_{n} given by (C, a) is continuously observable. Given a closed term of ground type, C[Y(M : T ⇒ T)], C[YM] = [[λx.C[x M] (λy : T ⇒ T.Yy)]] = F^{∇}; [[λx.C[x M]]]. (where F: [[((T ⇒ T) ⇒ T))]] → [[(T ⇒ T) ⇒ T))]] = [[λH.λf.f(Hf)]]) By rationality, C[YM] = ⨆_{i∈ω} F^{i}; [[λx.C[x M]]] = ⨆_{i∈ω}[[C[M^{i}]]]. Hence if C[YM] ≠ ⊥, there exists k ∈ ω such that C[M^{k}] ≠ ⊥, as required.

□

4.6 Definability and full abstraction in μPCF_{n}

Definability of finitary morphisms now follows from the axiomatic characterization of the category of unbracketed games and finite strategies as a fully complete model of Λ(Ω). It is also, trivially, a fully complete model of the λμ_{n}(Ω)-calculus over the empty type 0, because by Lemma 4.2.9, naming and μ-abstraction at all types can be simulated using λ-variables. The extension to the infinitary types are given by the numerals and case statements.

Definability for μPCF_{n} can be established in greater detail by describing an inverse to the □ translation with respect to finitary evaluation trees. Recall (Proposition 2.5.9) that all definable morphisms of a computational control model (C, a) are least upper bounds of the form ⨆_{i∈ω}(p_{i}^{A}; f_{i}; e_{i}^{B}), where each f_{i} : A_{i} → B_{i} is a definable morphism of the free CCC over a. In conjunction with the unique representation of morphisms in the CCC as βη-long forms of Λ(Ω), this gives a unique representation of a finitary basis of a model of Λ(Ω)^{ω}.

Definition 4.6.1 The finitary normal forms of Λ(Ω)^{ω}_{1} are given by the following inductive definition.

\overline{Ω ∈ N(Γ; ι)}

\frac{t ∈ N(Γ, x: S; T)}{λx.t ∈ N(Γ; S ⇒ T)}

\frac{x : ι^{ω} ∈ Γ}{π_{n}(x) ∈ N(Γ; ι)}

\frac{s_{1}, s_{2}, …, s_{n} ∈ N(Γ; ι)}{⟨s_{1}, s_{2}, …, s_{n}⟩ ∈ N(Γ; ι^{ω})}

\frac{s_{i} ∈ N(Γ; S_{i}) x: S_{1} ⇒ (S_{2} ⇒ … S_{n} ⇒ ι)}{(… ((x s_{1}) s_{2}) …) ∈ N(Γ; ι)}

Proposition 4.6.2 If (C, a) is a model of Λ(Ω)^{ω}, every finitary definable morphism is the interpretation of a (unique) finitary normal form.

Proof: is by a straightforward structural induction, proving that every denotation of a finite evaluation tree is equal to e_{i}^{A}; f_{i}; p_{i}^{A}, where f_{i} is the denotation of a unique βηπ-long normal form of Λ(Ω) (given by Definition 3.7.4 extended with finite products at ground type). □

The Definability Theorem (Theorem 3.7.2) then yields the following corollary.

Corollary 4.6.3 If (C, a) defines a computational control model, and satisfies the axioms for definability, then every finitary morphism of (C, a) is the interpretation of a finitary normal form of Λ(Ω)^{ω}.

The evaluation trees of μPCF_{n} follow essentially the same pattern.

Definition 4.6.4 (Evaluation trees of μPCF_{n}) The set of evaluation trees E(Γ, Δ; T) of type T over the contexts Γ = x_{1} : T_{1}, …, x_{n}: T_{n}, Δ = α_{1} : nat, α_{2} : nat, … α_{n} : nat is generated (up to α-equivalence) by the following inductive definition:

\overline{Ω ∈ E(Γ, Δ; 0)}

\frac{α ∈ Δ}{[α]n ∈ E(Γ, Δ; 0)}

\frac{M ∈ E(Γ, Δ, α; 0)}{μα.M ∈ E(Γ, Δ; nat)}

\frac{M ∈ E(Γ, x: T; U)}{λx: T.M ∈ E(Γ; T ⇒ U)}

\frac{M_{1}, M_{2}, …, M_{n} ∈ E(Γ, Δ; T_{i}), f: (T_{1} ⇒ (… (T_{n} ⇒ 0) …)) ∈ Γ}{(((f M_{1}) M_{2}) …) M_{n} ∈ E(Γ, Δ; 0)}

\frac{M_{i} ∈ E(Γ, Δ; T_{i}) : i ≤ n, f: \overline{T} ⇒ nat) ∈ Γ, N_{i} ∈ E(Γ, Δ; 0) : i ≤ k}{case _{k}(((f M_{1}) M_{2}) …) M_{n}|_{i}N_{i} ∈ E(Γ, Δ; 0)}

For the evaluation trees of μPCF_{n}^{−}, delete the fifth clause.

Proposition 4.6.5 Suppose t ∈ E(Γ^{□}, Δ^{□}; T^{□}) is a finitary normal form of Λ(Ω)^{ω}, over a context of translated variables and names. Then there is a unique finitary evaluation tree of μPCF_{n} M ∈ E(Γ, Δ; T) such that M^{□} =_{Λ(Ω)^{ω}} t.

Proof: is by induction on finite normal forms of Λ(Ω)^{ω}, which is routine as there is a direct correspondence with evaluation trees, as follows.

• Ω^{ι} = (Ω^{0})^{□}

• y^{□}: ι = (y: 0)^{□}

• λy^{□}.M = (λy.M)^{□}

• π_{n}(α: ι^{ω})^{□} =_{Λ(Ω)^{ω}} ([α]n)^{□}

• λα^{□}.M^{□} = (μα.M)^{□}

• (((y^{□} M_{1}^{□}) M_{2}^{□}) …) M_{n}^{□} =_{Λ(Ω)^{ω}} ((((y M_{1}) M_{2}) …) M_{n})^{□}

• (((y^{□} M_{1}^{□}) M_{2}^{□}) …) M_{n}^{□}⟨N_{1}^{□}, N_{2}^{□}, … N_{k}^{□}⟩ = (case _{k}((((y M_{1}) M_{2}) …) M_{n})|_{i}N_{i})^{□}

□

Corollary 4.6.6 Every finite morphism in the games model of μPCF_{n} (and any model constructed from (C, a) satisfying the axioms for definability) is the denotation of a unique evaluation tree.

Theorem 4.6.7 (Full abstraction for μPCF_{n}) Any model of control specified by a category and answer-object (C, a) satisfying the axioms for definability will collapse under its intrinsic preorder to give a fully abstract model.

Proof: by Corollary 4.6.6 above, any such model will have the definability property, which by Proposition 2.4.11 means that its collapse will be fully abstract for closed terms. It remains only to show that full abstraction for closed terms extends to full abstraction for all terms. □

Lemma 4.6.8 Suppose full abstraction holds for all closed terms; i.e for closed s, t: A, s ⊑^{obs} t if and only if [[s]] ⊑_{A}^{OBS} [[t]]. Then full abstraction holds for all terms.

Proof: It is observed in [6], for example, that it is sufficient to prove soundness and completeness for terms without free variables, as given any terms M, N : T with free variables Γ = x_{1} : A_{1}, x_{2} : A_{2}, …, x_{n}: A_{n}, then [[Γ ⊢ M]] ≲_{[[Γ]]⇒[[T]]} [[Γ ⊢ M]] if and only if [[λ\overline{x}.M]] ≲_{[[Γ]]⇒[[T]]} [[λ\overline{x}.N]], and M ⊑_{Γ;T}^{OBS} N if and only if λ\overline{x}.M ⊑_{Γ;T}^{OBS} λ\overline{x}.N. Here, it is shown how this observation extends to free names. Suppose that Γ ⊢ M : A, β : B, Δ and Γ ⊢ N : A, β : B, Δ are terms in context with a free name β: B.

Let x : A ⇒ 0 be a variable not free in s, t, and define M′ = λx: A ⇒ 0.μβ.(x M) and N′ = λx: A ⇒ 0.μβ.(x N) Then M ⊑_{Γ;Δ,B;A}^{OBS} N if and only if M′ ⊑_{Γ;Δ;A⇒0⇒B}^{OBS} N′. The implication from right to left is obvious; to prove the converse, suppose that M′ ⊑_{Γ;Δ;⇒A}^{OBS} N′, and C[·] is a program context such that C[M] ⇓. Then let D[·] = C[[·] λz: .[β]z], so that [[D[M′]]] = [[C[M[λy.[β]y/β]]]] = [[C[M]]], and D[M′] ⇓ by computational adequacy, hence D[N′] ⇓ and C[N] = D[N′], so C[N] ⇓ as required. □

Hence another example of a fully abstract model of μPCF_{n} is given by dropping the bracketing condition on the Abramsky-Jagadeesan-Malacaria games model of PCF, since this coincides with the semantics given by translation into Λ(Ω)^{ω}, and interpreting ι as the one-move game. Because these games satisfy the axioms for definability, this model will also give rise, by collapse, to a fully abstract model.

4.7 Call-by-value: higher-order control

Call-by-value μPCF can be soundly interpreted in a control model, giving a fully complete games model, and a fully abstract translation into the simply typed λ-calculus, just as for call-by-name. However, although the continuation-passing interpretation based on the monad is in principle simple, translation of A ⇒_{v} B as A ⇒_{n} ((B ⇒_{n} ι) ⇒_{n} ι) has the effect of radically increasing the depth of the types concerned, making the direct translation into the λ-calculus less than transparent. What is required is a set of higher-level reasoning principles to structure the translation.

As remarked by Moggi [62], control flow is the key to a general system of reasoning about function-based programming; in the presence of phenomena such as partiality, state, non-determinism, exceptions, etcetera, the order in which computation occurs is critical in determining its result. Monads provide a way to structure this information. A variant of one of Moggi’s metalanguages for reasoning about the semantics of call-by-value functional langauges in general Kleisli categories, — the ‘computational λ-calculus’ has been described in Chapter 2. By making the typing of the continuations monad explicit, a ‘control’ version of λ_{c} can be described (which is effectively Felleisen’s λ𝒞 [25]). λμ_{v} can be translated soundly and invertibly into this calculus, so its interpretation in models of control is sound and complete. Using the computational λ-calculus to structure the cps translations of λ𝒞 and λμ thus has two advantages: it comes with a complete set of high-level reasoning principles, which yield a sim-

let x = t in x  =_{c}  t
let y = ( let x = t_{1} in t_{2}) in s =_{c} let x = t_{1} in ( let y = t_{2} in s)
let x = v in t  =_{c}  t[v/x]
μ(t)  =_{c}  let x = t in μ(x)
μ([t])  =_{c}  t
[μ(x)]  =_{c}  x
λx.t s  =_{c}  let x = s in t
(λx.v (x))  =_{c}  v

Figure 4.3: Equational theory in λ_{c}

ple equational proof that the intended model of μPCF_{v} is sound, it also allows the project described in Chapter 3, of giving fully abstract semantics to a variety of computational features via the intensional hierarchy, to be connected to this elegant and well-established paradigm for modelling such side-effects using monads.

There is in fact quite a venerable tradition of using the monadic nature of continuations to study them; Moggi gave continuations as one of the first examples of a computational monad, and Hatcliff and Danvy [36] used Moggi’s computational metalanguage (not the computational λ-calculus) as a unifying framework for factoring the cps translation, but not control operators. It has also been known [27],[39] that the action of the μ-transformation on continuation models is that of a control operator such as Felleisen’s 𝒞. In this section this observation is combined with the power of let -based reasoning about the flow of control to describe the semantics and theory of λμ, and show that it too can prove stronger equalities for purely functional terms than βη-equality alone.

4.7.1 Control in the computational lambda-calculus

Recall the language λ_{c} defined in section 2.2.2.

Definition 4.7.1 A value of λ_{c} is a variable, or λ-abstraction, or lifting, i.e.

v ::= x | λx.t | [t]

where t ranges over all terms of λ_{c}.

The equational theory of =_{c} is given by the reflexive, transitive, compatible closure of the rules in table 4.3.

Proposition 4.7.2 The above theory is sound with respect to the interpretation of λ_{c} in a computational model (the theory is also complete)(Figure 2.3).

Proof: is direct from the definition of λ_{c} model, see [62]. □

Even without identifying continuation-passing as the notion of of computation, λ_{c} permits reasoning about the flow of control which is unavailable in the call-by value λ-calculus. In particular, the intuition behind the definition of evaluation contexts, that t is always evaluated in computing E[t], can be formalised, by requiring that the meanings of E[t] and λx.E[x] t (evaluate t, substitute it into E[x], and compute that) should be the same in a computational model, and so E[t] =_{c} (λx.E[x]) t should be derivable from the above theory. Since the evaluation context has been used as a syntactic representation of the current continuation, this is a directly useful fact. First define the let-free λ_{c} evaluation contexts by induction over the following grammar.

Definition 4.7.3 (Let-free evaluation contexts)

E[·] ::= [·] | E[·] t | v E[·] | μE[·].

As in μPCF, terms can be uniquely decomposed into an evaluation context and a value.

Proposition 4.7.4 Let t be any term of λ_{c}. Then there is a unique value v, and evaluation context E[·], such that t = E[v]

Proof: is by routine induction along the lines of Proposition 4.3.2. □

Proposition 4.7.5 (Evaluation Contexts Lemma) For all evaluation contexts E^{T} [·] with x not free in E[·], and terms t: T,

(λx.E[x]) t =_{c} E[t].

Proof: First, observe that the proposition is equivalent to the following :

Lemma 4.7.6 For all t:

i (λx.x) t =_{c} t,

ii (λx.(x s)) t =_{c} t s,

iii (λx.v (u x)) t =_{c} v (u t),

iv (λx.μ(x)) t =_{c} μ(t)

(where u, v denote values, s, t arbitrary terms, and x is not free in s, u, v).

Proof: Each of the above equations is an instance of the evaluation contexts lemma. On the other hand, one can prove by induction on the definition of evaluation context that they jointly entail the axiom schema. Given an evaluation context E[·], either: E[·] = [·], so E[t] = t, and by (i), λx.x t =_{c} t. or E[·] = E′[K[·]] where K[·] is just one level deep. Then E[t] =_{c} λx.E′[x] K[t] by inductive hypothesis. K[t] =_{c} λy.K[y] t by the appropriate clause above, and E[t] =_{c} λz.(λx.E[x] (λy.K[y] z)) t =_{c} λz.E[z] t by clause iii above. □

Now it remains to show that i − iv hold in λ_{c}:

i (λx.x) t =_{c} let y = t in (λx.x) y =_{c} let y = t in t =_{c} t

ii (λx.x s) t =_{c} let y = t in (λx.x s) y =_{c} let y = t in y s =_{c} t s

iii (λx.v (u x)) t =_{c} let y = t in (λx.v (u x)) y =_{c} let y = t in v (u y)

=_{c} let y = t in ( let z = u y in v z)

=_{c} let z = ( let y = t in u y) in v z =_{c} let z = u t in v z =_{c} v (u t)

iv is by direct application of let _{μ}.

4.8 Relating λμ to λ_{c} via λ𝒞

λ_{c} is a potential basis for a metalanguage for reasoning about a variety of effects in games via sum monads and the Fam(C) construction. However, in the case of control, the calculus can be simplified by observing that for any continuation monad T with answer object a, over a category with an initial object 0,

[[T0]]_{c} ≅ a

and hence for any type X, TX can be equated with (X ⇒ T0) ⇒ T0. So all references to T in the type system can be suppressed, by hiding the use of T in function types (as in the standard call-by-value interpretation, [[A ⇒ B]] = [[A]] ⇒ T[[B]]), and replacing the type-constructor T with (( ⇒ 0) ⇒ 0). So the typing rules for μ and [·] become:

\frac{Γ ⊢ t: A}{Γ ⊢ [t]: (A ⇒ 0) ⇒ 0}

\frac{Γ ⊢ t: (A ⇒ 0) ⇒ 0}{Γ ⊢ μ(t): A.}

A further simplification is that the lifting operation, [ ] can be replaced by λx.x , as for any term in context, [[Γ ⊢ [t]]]_{T} = [[Γ ⊢ t]]_{T}; η = [[Γ ⊢ λx.x t]]_{T}. Finally, note that the typing of μ given above is that suggested by Griffin for the 𝒞-operator introduced (in an untyped setting) by Felleisen and Hieb [25]. This allows the equational theory of λ_{c} to be appropriated as an equational theory of for λ𝒞, with β_{v}, η_{v}, and the additional axioms below: the Evaluation contexts lemma, together with the rules defining 𝒞 and λx.x as a monadic reflection, — an isomorphism between values of type TA, and terms of type A (see [27]).

β_{E[·]} (λx.E[x]) t =_{𝒞} E[t]

𝒞_{η} 𝒞λx.x t =_{𝒞} t

𝒞_{β} λx.(x (𝒞v)) =_{𝒞} v.

This is still not quite a complete axiomatization of continuation models of λ𝒞, — it is also necessary to capture the initiality of 0 — see [39], and Section 4.9. It is, however, sufficient to establish soundness of λμ_{v} models by translation.

Remark 4.8.1 (Relationship to other axiomatizations of λ𝒞-models) The equational theory of λ𝒞 supplied by Felleisen and Hieb is sound but not fully complete with respect to continuations models. (So it is properly contained in the above theory.) The description by Hofmann [39] of models of λ𝒞 essentially similar to control models (without co-products) has already been mentioned. This paper goes on to give an axiomatization of λ𝒞-theory which is sound and complete, and similar to the one which has been derived here. (The real difference with Hofmann’s account is that here the rules are derived from the general notion of monad.) Sitaram and Felleisen [80] also gave a similar axiomatization of λ𝒞, and a syntactic completeness result in the form of invertible cps translations.

4.8.1 The call-by-value de Groote Translation

λμ_{v} can now be translated into λ𝒞, and the equational theory used to prove that any continuations monad on a CCC is a sound λμ_{v}-model. In fact, the translation has already been described by de Groote in [23], where it was considered for the call-by-name case only. As noted by Ong and Stewart [67], soundness of the translation into call-by-value λ𝒞 seems more problematic. This not due to the inadequacy of the rules for 𝒞 itself, but the weakness of β_{v} on its own, for reasoning about the flow of control. This can be remedied by adopting the let -rules of λ_{c} (or Hofmann’s complete axiomatization of λ𝒞), which are encapsulated in the single rule β_{E[·]}.

Using the presentation of λμ-theory via evaluation contexts, it is a simple matter to show that the translation is sound with respect to the λ𝒞 and λμ_{v} theories. Hence the apparatus of naming and μ-abstraction can be seen as simply a (useful) syntactic sugaring of call-by-value λ𝒞. The correspondence of the callby-value calculi can thus be said to be closer than in the call-by-name case, as the rules of λμ_{n} (in particular μβ) cannot be consistently translated to a sound rule of call-by-name λ𝒞 in this style (see Proposition 4.8.7).

Definition 4.8.2 (The ‘de Groote translation’) from terms of λμ to λ𝒞 is defined by structural induction as follows: Define a distinguished collection of variables x_{α}, x_{β}, … in bijective correspondence with μ-names, such that if α: A then x_{α}: A ⇒ 0. For each λμ term t: A, define the λ𝒞 term ⌊t⌋: A:

• ⌊x⌋ = x,

• ⌊s t⌋ = ⌊s⌋ ⌊t⌋,

• ⌊λx.t⌋ = λx.⌊t⌋,

• ⌊[α]t⌋ = x_{α}⌊t⌋,

• ⌊μα.t⌋ = 𝒞λx_{α}.⌊t⌋.

Definition 4.8.3 The semantics of terms-in-context Γ ⊢ t; Δ of λμ_{v} in a control model (C, a) is given by translation into λ𝒞 and interpretation in the Kleisli category of continuations on Fam(C):

[[Γ ⊢ t; Δ]]_{μ} = [[⌊Γ⌋, ⌊Δ⌋ ⊢ ⌊t⌋]]_{𝒞}.

4.8.2 Correctness of the translation

Using the axioms obtained for λ𝒞 as a particular form of the λ_{c} calculus, and in particular the Evaluation Contexts Lemma, it is simple to show the translation is sound with respect to the equational theory of call-by-value λμ. First extend the translation to (many-holed) contexts by adding the clause ⌊[·]⌋ = [·] to its inductive definition.

Lemma 4.8.4 For any context of λμ, C[·], and for any compatible term t, ⌊C[t]⌋ = ⌊C[⌊t⌋]⌋. And if C[·] is an evaluation context then so is ⌊C[·]⌋.

Proof: is by simple structural induction. □

Proposition 4.8.5 (Correctness of the Translation) For any λμ_{v}-terms s, t, s =_{λμ_{v}} t implies ⌊s⌋ =_{𝒞} ⌊t⌋.

Proof: it is necessary to show that the translations of μη and μζ of λμ_{v} hold in λ𝒞 (λβ, λη translate directly to their λ𝒞 counterparts).

μ_{η} μα^{A}[α]s = s (α ∉ F N(s))

⌊μα^{A}[α]⌋ = 𝒞^{A}λx_{α}.x t =_{𝒞} t by 𝒞_{η}.

μ_{ζ} E[μα^{T} .t] : 0 = t[E[·]/α] ⌊E[μα^{A}.t]⌋ = ⌊E[⌊μα^{A}.t⌋]⌋ =_{𝒞} ⌊E[𝒞^{A}λx_{α}.⌊t⌋]⌋ (by the lemma above) ⌊E[𝒞^{A}λx_{α}.⌊t⌋]⌋ =_{𝒞} (λy^{A}.⌊E[y]⌋) 𝒞^{A}λx_{α}.⌊t⌋), by the Evaluation Contexts Lemma =_{𝒞} (λx_{α}.⌊t⌋) (λy^{A}.⌊E[y]⌋) by 𝒞_{β} =_{𝒞} ⌊t⌋[(λy^{A}.⌊E[y]⌋)/x_{α}], by β_{v} Now make the α-named terms of t explicit: suppose t = C[[α]s_{1}][[α]s_{2}] … [[α]s_{n}]. Then ⌊t⌋ = ⌊C[x_{α} ⌊s_{1}⌋] … [x_{α} ⌊s_{n}⌋], and by β_{v}, β_{E[·]}, ⌊t⌋[(λy^{A}.⌊E[y]⌋)/x_{α}] =_{𝒞} ⌊C[x_{β} ⌊E[s_{1}]⌋] … [x_{β} ⌊E[s_{n}]⌋]⌋ = ⌊t[⌊E[·]⌋/α]⌋, as required. (That the variable substitution of λy.⌊E[y]⌋ for x_{α} is equivalent to the named substitution of E[·] for α can be proved formally by structural induction using the definition of substitutions as in Lemma 4.5.8.)

□

Remark 4.8.6 By way of comparison with the original call-by-name translation, note that the deGroote translation is not sound with respect to any non-trivial axiomatization of call-by-name λ𝒞. The translation of the μβ rule is inconsistent with ⌊[α]μβ.t⌋ = x 𝒞λy.⌊t⌋.

Proposition 4.8.7 Suppose T is a theory of λC such that the deGroote translation is sound with respect to T. Then for any terms s, t : S of λ𝒞, s =_{T} t.

Proof: If ⌊ ⌋ is sound w.r.t. T, then T contains all instances of β_{n}, η_{n}, together with ⌊μη⌋, i.e. 𝒞λx.x t =_{T} t for all t not containing x free, and ⌊μβ⌋ , i.e. x^{S⇒0} 𝒞λy.t =_{T} t[x/y] for all t. Consider the term 𝒞λx : S ⇒ 0.(λy : S ⇒ 0.y 𝒞λz : S ⇒ 0.(x t)) λw : S.(x s)

=_{β} 𝒞λx.(λw.(x s)) 𝒞λz : S ⇒ 0.(x t) =_{β} 𝒞λx.(x s) =_{T} s But also 𝒞λx : S ⇒ 0.(λy : S ⇒ 0.y 𝒞λz : S ⇒ 0.(x t)) λw : S.(x s) =_{T} 𝒞λx.(λz.(x t)) λw.(x s) =_{β} 𝒞λx.(x t) =_{T} t.

□

4.9 Completeness and full abstraction in μPCF_{v}

To form a complete theory of λμ, add the following rules to the call-by-value equational theory λβ, λη, μη, μζ.

(η_{μ}) (λx.[α]x) t =_{μ} [α]t This makes the correspondence between naming and applying a continuation variable direct; that it is sound in a model of control is clearly a consequence of η_{v}.

(0-init) For any values v, u: 0 ⇒ T, v =_{μ} u.

This makes the status of 0 as initial in a model of control explicit by stating that all values taking arguments of type 0 are equivalent.

Finally, it can be observed directly that the rules for the co-product extension are sound, establishing the following

Proposition 4.9.1 Let (C, a) be a model of control, then the semantics of λμ_{v}^{+} in (C, a) is sound.

(As de Groote notes) an inverse to the translation into λ𝒞 can be given by translating 𝒞t as μα.t λx.[α]x, (and 𝒞^{0}t as t λx : 0.x).

Proposition 4.9.2 The inverse of the de Groote translation is sound with respect to the rules of λ𝒞.

Proof: The monadic reflection rules translate to sound rules of λμ as follows:

• μα.((λy.y t) (λx.[α]x)) =_{μ} μα.λx.[α]x) t =_{μ} μα.[α]t =_{μ} t

• λy.y (μα.v (λx.[α]x)) =_{μ} λy.v (λx.y x) =_{μ} λy.v y =_{μ} v.

That the let -rules translate to valid equations of λμ is equivalent to showing that β_{E[·]} holds in λμ_{v}. First note that for all t: T t =_{μ} μα.(λz.[α]z) t by η_{μ}, and so λx.E[x] t =_{μ} λx.E[x] (μα.(λz.[α]z) t) =_{μ} μα.((λz.[α](λx.E[x]) z) t) =_{μ} μα.((λz.[α]E[z]) t) =_{μ} E[(μα.(λz.[α]z) t)] =_{μ} E[t] as required. □

Note in particular that the theory of λμ_{v} is not a conservative extension of βη_{v}. So although the rules μη and μβ are manifestly about manipulation of firstclass continuations, they can be used to reason about control flow even in purely functional programs.

Completeness of the λμ-theory can thus be achieved as a corollary of Hofmann’s completeness theorem for the axiomatization for λ𝒞. However, the addition of co-products allows a simple proof of completeness to be given more directly, based on the following observation: any model of λμ_{v}^{+}(Ω) over the empty type is a model of the simply-typed call-by-name λ-calculus Λ(Ω). This can be proved by giving an ‘inverse’ to the cps translation into Λ(Ω) which is implicit in the continuations model, and hence proving that λμ_{v}(Ω) is a complete syntax of control (recall Definition 2.3.11). Notwithstanding the brutal nature of the syntax, this is merely the syntactic counterpart of the observation in Chapter 2, Proposition 2.3.7, that every object generated from a in (C, a) corresponds to a call-by-value type in the associated control models.

Definition 4.9.3 Define the following translation from the simply-typed Λ(Ω)- calculus to the +, ⇒ 0 fragment of λμ_{v}^{+}(Ω) Types translate as follows

• ι^{▲} = 0

• (A ⇒ ι)^{▲} = A^{▲} ⇒ 0

• (A ⇒ B)^{▲} = (A^{▲} ⇒ 0) + B^{▲} (B ≠ ι).

Terms in context Γ ⊢ t are translated to λμ^{+} terms in context ⊢ t^{▲}; Γ^{▲} as follows:

• Ω: ι^{▲} = Ω^{0}

• (x: T)^{▲} = μγ: T^{▲}.[α_{x}: T^{▲} ⇒ 0]λy[γ]y

• ((t: S ⇒ T) s: S)^{▲} = μβ: T^{▲}.((μα.[α: S^{▲} ⇒ 0, β: T]t^{▲}) s: S^{▲})

• (λx: S.t: T)^{▲} = μ[α_{x}: S^{▲} ⇒ 0, β: T^{▲}].[β]t^{▲}

Proposition 4.9.4 The above translation is sound with respect to βη-equality.

Proof: β-equality: ((λx: S.t: T) s: S)^{▲} =_{μ} μβ: T^{▲}.(μα: S^{▲} ⇒ 0.[α, β](μ[α_{x}: S^{▲} ⇒ 0, β: T^{▲}].[β]t^{▲}) (s^{▲}))

(where the Λ(Ω)-variable x is translated in t as μγ.[α_{x}]λy.[γ]y) =_{μ} μβ.((μα.[β]t^{▲}) s^{▲}) =_{μ} μβ.[β]t^{▲}[s^{▲}/(μγ.[α](λy.[γ]y)] =_{μ} t[s/x]^{▲} as required. (As μγ.(λy.[γ]y)s^{▲} = s^{▲}.) η-equality: (it is sufficient to show that this holds for (the translation of) variables, i.e. (λx.y x)^{▲} = y^{▲}) (λx.y x)^{▲} = μ[α_{x}, β].[β]μγ.((μδ.[δ, γ]μ[θ, ε].[α_{y}]λw.[θ, ε]w) (μψ.[α_{x}]λz.[ψ]z)) = μ[α, β].((μδ.[α_{y}]λw.[δ, β]w) μψ.[α_{x}](λz.[ψ]z)) (by repeated application of μβ) Using the derived rule s t =_{μ} (λx.x t) s, this is equal to μ[α_{x}, β].(λu.[α_{x}]y) (μδ.[α_{y}]λw.[δ, β]w) =_{μ} μ[α_{x}, β].[α_{y}](λw.[α_{x}, β]w) which is equal by α-conversion to y^{▲} as required.

□

Sum types, and the continuation forming operation ⇒ 0 are thus, in a sense ‘expressively complete’ for the simply-typed call-by-value calculus.

Corollary 4.9.5 The initial model of the ⇒ 0, + fragment of λμ^{+}(Ω)_{v} is isomorphic to the free pointed CCC.

Completeness for the whole of λμ_{v}(Ω) can now be established by translating implicational types into the ¬, + part of the language.

Proposition 4.9.6 The initial model of λμ(Ω) is isomorphic to the initial callby-value control model.

Proof: Having shown completeness for the ( ⇒ 0, +) fragment, it remains only to show that every function type of λμ_{v}(Ω) is equivalent to one formed from + and ⇒ 0, (essentially by defining a sort of co-currying operation between sum and arrow types). So let (0 ⇒ B)^{△} = 0, and (A ⇒ 0)^{△} = A^{△} ⇒ 0 (A ≠ 0) (A ⇒ B)^{△} = (A^{△} + (B^{△} ⇒ 0)) ⇒ 0 (A, B ≠ 0). Note that under the interpretation of λμ_{v}^{+} in a control model,

[[T]] = [[T^{△} ⇒ 0]].

Lemma 4.9.7 There is a (λμ^{+} definable) bijection (up to λμ-equality) between values of type T and values of type (T^{△} ⇒ 0).

Proof: is by structural induction, defining an isomorphism ϕ_{T} from values of type T to values of type T^{△} ⇒ 0 and an explicit inverse ϕ^{−1}.

• For T = 0 ⇒ A, define ϕ_{T} as the constant λx: 0.x and ϕ^{−1} = λx: 0.μα: A.x, as all terms at these types are equal by 0-init in any case.

• For T = A ⇒ 0, define ϕ_{T} (v) = λx : A^{△}.v (ϕ_{A}^{−1}(x)) and ϕ_{T}^{−1}(t) = λx: A.(ϕ_{A}(x) t). so that ϕ_{T}^{−1}(ϕ(v)) = v, and ϕ_{T}^{−1}(ϕ_{T} (v))

• For T = A ⇒ B (B ≠ 0), ϕ_{T} (v) =

μγ : T.μ[α: A^{△}, β: ((B^{△} ⇒ 0)].ϕ_{B⇒0}^{−1}(λz.[β]z) (v ϕ_{A}^{−1}(λy.[α]y))

and define the inverse ϕ_{T}^{−1}(v) =

λx: A.μβ: B.ϕ_{B⇒0}(λz.[β]z) ((μγ.ϕ_{A}(x) (μα.v (λy.[α: A^{△}, γ: B^{△} ⇒ 0]y))))

So ϕ_{T}^{−1}(ϕ_{T} (v)) =_{μ} λx.μβ.ϕ(ϕ^{−1}(λz.[β]z)) (v ϕ^{−1}(ϕ(x))) =_{μ} v,

and similarly ϕ_{T} (ϕ_{T}^{−1}(v))

=_{μ} λw.w μ[α, β].ϕ^{−1}(ϕ(λz.[β]z)) ((ϕ(ϕ^{−1}(λy[α]y))) μγ.v (λu.[γ, β]u))

= λw.w μ[α, β].v (λu.[α, β]u)) =_{μ} v.

□

Hence the maps [[x : T ⊢ ϕ_{T} (x)]] : [[T]] → T[[T^{△} ⇒ 0]], and [[x : T^{△} ⇒ 0 ⊢ ϕ_{T} (x)]] : T[[T^{△} ⇒ 0]] → [[T]]]] define an isomorphism on type-objects in the Kleisli category of the continuations monad.

Corollary 4.9.8 If (C, a) satisfy the axioms for definability, then the control models of λμ_{v}(Ω) constructed from (C, a) are fully complete.

4.9.1 Control models of μPCF_{v}

The interpretation of μPCF_{v} in a computational control model (C, a) can now be given by combining the semantics of λμ_{v} with the semantics of call-by-value PCF outlined in Chapter 2. As in the call-by-name case, the semantics is adequate, — the assumption of non-terminality of a yields standard datatypes, and rationality entails continuous observability. If (C, a) also satisfies the axioms for definability, then the semantics also has the finite definability property. Hence dropping the bracketing condition on the Honda and Yoshida [41], and Abramsky and McCusker [3] models of pure PCF yields such a model.

Recall the definition of a computational control model (Section 2.4); a rational pointed CCC with ω-indexed products and non-terminal answer-object. This gives a semantics of call-by-value PCF in the Kleisli category of the monad of a continuations(see Section 2.4.4).

Proposition 4.9.9 The semantics of μPCF_{v} in a computational control model (C, a) (rational C, non-terminal a) is adequate.

Proof: Soundness follows from the soundness of the translation of λμ into λ𝒞. (That the Evaluation Contexts Lemma extends to the μPCF_{v} evaluation contexts is straightforward.) Completeness follows from the application of the Adequacy Theorem (Theorem 4.4.5) for the operational semantics, together with the fact that the adequacy conditions of continuous observability and standardness of datatypes apply, for which the proof is entirely similar to the call-by-name case (Proposition 4.5.11).

□

Definability is a consequence of the full completeness of the λμ(Ω)_{v} semantics, together with definability of embeddings and projections into PCF-types. As in the the call-by-name case, more detail can be given by defining the finitary evaluation trees of μPCF_{v} and showing that they correspond bijectively via denotation to unique βηπ-long normal forms of Λ(Ω)^{ω}.

Definition 4.9.10 (Finite Evaluation trees of μPCF_{v}) Thus there are two disjoint sets of trees of type T over the higher-type context Γ, Δ; the values, V (Γ, Σ; T), and the non-values NV (Γ, Σ; T), formed by mutual induction as follows.

\overline{Ω ∈ NV (Γ; Δ; 0)}
\overline{n ∈ V (Σ; Δ; nat)}

\frac{M ∈ NV (Σ, Δ; B)}{λx.M ∈ V (Σ; Δ; A ⇒ B)}

\frac{\{M_{i} ∈ NV (Σ; Δ; T) | i ≤ k\},}{(λx.case _{k} x |_{i≤k} M_{i}) ∈ V (Σ; Δ; nat ⇒ T)}

\frac{M ∈ NV (Σ; Δ, α: A; 0)}{μα.M ∈ NV (Σ; Δ; A)}

\frac{M ∈ V (Σ, x : S ⇒ T; Δ; T ⇒ 0), N ∈ V (Σ; Δ, S)}{M (x N) ∈ NV (Σ, x : S ⇒ T; Δ, 0)}

\frac{M ∈ V (Σ, x : S ⇒ T; Δ, α : T; T)}{[α]M ∈ NV (Σ, x : S ⇒ T; Δ, α : T; 0)}

These normal forms are complicated by the ‘eager evaluation’ of ground-type values. To simplify matters, 0 is assumed not to occur to the right of an arrow, or as the type of a variable, (as by initiality of 0, all values at such types are equivalent). Variables of type nat are tested once, as soon as they are introduced, and so contexts are restricted to higher-type variables.

In addition, trees are split between values and non-values. It is only possible to reach a higher-type value by lambda-abstraction from a non-value, and it is only possible to reach a higher-type non-value by μ-abstraction.

This gives a notion of ‘normal form’ for continuation passing (which is very different, for instance, from the version arising from the well-bracketed games model given in [41]): apply a variable to an argument, and a continuation to the result, abstract a continuation variable, abstract an argument, and so on.

There is a cps translation from Λ(Ω)^{ω} into μPCF_{v} along the lines of the callby-name □ translation but it is substantially more complicated, due to the fact that variables of type nat do not translate to Λ(Ω) variables but operations on infinite lists. As there are no free variables in the finite evaluation trees of μPCF_{v}, however, an invertible cps translation into the finitary normal forms of Λ(Ω)^{ω} can be described simply, and used to show finite definability. First a (slightly nonstandard) cps translation on types is defined.

Definition 4.9.11 Define the ♢-translation on μPCF function types as follows.

• (nat ⇒ 0)^{♢} = 0^{ω}

• (nat ⇒ nat)^{♢} = (ι^{ω} ⇒ ι)^{ω}

• (nat ⇒ T)^{♢} = ((T^{♢} ⇒ ι) ⇒ ι)^{ω}, if T ≠ nat, 0

• (S ⇒ 0)^{♢} = S^{♢} ⇒ ι, if S ≠ nat, 0

• (S ⇒ nat)^{♢} = S^{♢} ⇒ (ι^{ω} ⇒ ι), if S ≠ nat, 0 (S ⇒ T)^{♢} = S^{♢} ⇒ (T^{♢} ⇒ ι) ⇒ ι, if S, T ≠ 0, nat.

Thus for any higher μPCF type T, the interpretation of T in a model of control is isomorphic to the interpretation of T^{♢} in a model of Λ(Ω)^{ω}.

Proposition 4.9.12 If C, a is a CCC with ω-indexed products specifying a (callby-value) model of control, then for any μPCF_{v} type T, [[T^{♢}]]_{(C,a)} ≅ [[T]]_{(C,a)}.

The finitary normal forms of Λ(Ω)^{ω} (Definition 4.6.1) are extended to translations of μPCF_{v} types by adding the clause:

\frac{y : (S ⇒ ι)^{ω} ∈ Γ, t ∈ N(Γ; S)}{π_{i}(y) t ∈ (Γ; ι).}

A correspondence is assumed at each type T between μPCF_{v} variables x : T and Λ(Ω)^{ω}-variables, x^{♢} : T^{♢}, and between names α : T and Λ(Ω)^{ω}-variables, α^{♢} : T^{♢} ⇒ 0.

Definition 4.9.13 The ♢-translation takes trees of type 0 to finitary normal forms of type ι, μPCF_{v} values of type T to normal forms of type T^{♢}, and μPCF non-values of type T to normal forms of type (T^{♢} ⇒ ι) ⇒ ι. i.e.

NV (Γ, Δ; 0) ⟶ N(Γ^{♢}, Δ^{♢}; ι)
V (Γ, Δ; T) ⟶ N(Γ^{♢}, Δ^{♢}; T^{♢})
NV (Γ, Δ; T) ⟶ N(Γ^{♢}, Δ^{♢}; (T^{♢} ⇒ ι) ⇒ ι)

• Ω^{♢} = Ω : ι

• (λx : nat.case_{k} x |_{i≤k} M_{i})^{♢} = ⟨M_{1}^{♢}, M_{2}^{♢}, …, M_{k}^{♢}⟩

• (λx : T.M)^{♢} = λx^{♢}.M^{♢}, for T ≠ nat

• (μα.M)^{♢} = λα^{♢}.M^{♢}

• ([α]n)^{♢} = π_{n}(α^{♢})

• ([α](V : T))^{♢} = α^{♢}V^{♢}, for T ≠ nat

• (U (x n)^{♢} = π_{n}(x^{♢}) U^{♢}

• (U (x (V : T)))^{♢} = (x v^{♢}) U^{♢}, for T ≠ nat.

Proposition 4.9.14 The ♢ translation is sound and surjective. If (C, a) is a computational model of control, then for any M ∈ NV (Γ, Δ; T),

[[Γ ⊢ M; Δ]]_{(C,a)} ≅ [[Γ^{♢}, Δ^{♢} ⊢ M^{♢}]]_{(C,a)}

and for any V ∈ V (Γ, Δ; T),

[[Γ ⊢ V; Δ]]_{C,a} ≅ [[Γ^{♢}, Δ^{♢} ⊢ V^{♢}]]_{(C,a)}; η_{[[T]]}.

Proof: is direct by induction over the definition of the translation. □

Proposition 4.9.15 If (C, a) is an computational model of control satisfying the axioms for definability, then every morphism over a μPCF_{v} type-object is the least upper bound of a chain of definable elements.

Proof: Is by surjectivity of the ♢-translation, together with the Definability Theorem (Theorem 3.7.2), and Proposition 2.5.9 (all morphisms are least upper bounds of the form ⨆_{i∈ω}(p_{A}^{i}; f_{i}; e_{i}^{B})). □

Applying Proposition 2.4.11 yields a full abstraction result (which extends to open terms as in the call-by-name case described in Lemma 4.6.8).

Corollary 4.9.16 (Abstract full abstraction) If (C, a) is a continuous control model satisfying the axioms for definability, the semantics for μPCF_{v} constructed from the collapse of C under its intrinsic preorder is fully abstract.

Corollary 4.9.17 (Concrete full abstraction) The call-by-value control model constructed by dropping the bracketing condition on the Abramsky and McCusker model of PCF and collapsing under the intrinsic preorder is a fully abstract semantics for μPCF_{v}. The collapse of the games model of μPCF_{v} under its intrinsic preorder is fully abstract.

Analysis of the fully abstract model

This chapter is a study of the fully abstract models of control in greater depth, establishing further semantic properties such as universality, and also some of the syntactic information which can be extracted from them; in particular a context lemma for μPCF. The most important step towards a significant analysis of syntax and semantics, however, is that the fully abstract model can be presented effectively, — in fact directly, in the category of sequential algorithms.

Conceptually, the existence of a model which satisfies the (μPCF version of the) ‘Jung and Stoughton criterion’ is important because it contrasts with the purely functional case; by Loader’s result [54], a PCF semantics cannot pass this test. One could consider extending the application of the criterion, to ask which (if any) meaningful sequential functional languages have effectively presentable models, and using it to delimit the applicability of full abstraction and of denotational semantics in general. The negative result for PCF reveals a deep incompatibility between sequentiality and full abstraction on the one hand, and a certain conception of denotational semantics in terms of (appropriately constrained) set-theoretic functionals on the other.

The nature of the of the analogous problem for μPCF is somewhat different because observational equivalence is not extensional, so there cannot be a presentation of the fully abstract model without (implicit) reference to its behaviour. Nonetheless, it is significant that there is such a construction which is both independent of the syntax, and mathematically more tractable. (Another advantage of a direct presentation of the model is that it can be seen to be cpo-enriched; this is still not known in the case of PCF). Moreover, the problem of determining observational equivalence in the presence of non-local control is a significant one in its own right, as most languages can use non-local control flow to distinguish between extensionally equivalent procedures. Another feature of the direct presentation described here is that it makes use of the category of sequential algorithms, and thus forms a connection between the ‘intensional hierarchy’ and another attempt to define a category of intensional ‘realizers’ for sequential functions. The existence of fully abstract models of of SPCF (in essence equivalent to μPCF_{n}) based on sequential algorithms, and due to Cartwright, Curien and Felleisen [16] has already been noted. What is lacking in this semantics is a connection of its analysis of sequential control flow to other, more general accounts, in terms of the syntax (how does catch relate to call-by-value call/cc?) and the semantics (is there a connection with continuation passing?).

Although an effectively presented fully abstract model is technically a solution to the problem of deciding equivalence of finitary terms, as one can compute the denotation of terms and compare them, this is not especially illuminating. The problem with limiting attention to full abstraction is that in order to achieve it, the fine structure, which is not internally observable but which distinguishes terms which are intuitively intensionally distinct, has been thrown out. (Specifically, there is no repetition of moves in the sequential algorithms model, so a function which consults its argument once can be indistinguishable from one which does so several times). The finer structure is restored by establishing a connection with the innocent strategies model (which identifies denotations at the level of βη-equivalence). The unique structure-preserving functor from the games model, which exists by initiality, is given a syntax-free characterization and shown in a precise sense to be a removal of copied queries. Moreover, it is surjective — there is a way of saturating sequential algorithms with copies so that they become innocent strategies. Since the sequential algorithms model is equivalent to its own collapse, the ‘copy removing’ functor maps two strategies to the same algorithms if and only if they are observationally equivalent. In other words, considered as a functor on equivalence classes, it is the unique isomorphism between the fully abstract models. Thus the copy-removing functor characterizes intrinsic equivalence of innocent strategies, and the the copy-saturating translation gives a unique normal form for each equivalence class. This is the semantic invariant which truly characterises observational equivalence in control models.

5.1 Observational equivalence and control

Recall from Chapter 2 (Corollary 2.5) that effective presentability of the fully abstract models of control is equivalent to decidability of the intrinsic preorder and equivalence on the free pointed CCC (the strongest non-trivial equivalence containing βη-equality). The precise syntactic analogue of this problem is decidability of contextual equivalence on the language Λ(Ω), for contexts of type ι ⇒ ι. (And in fact in the pure simply-typed λ-calculus, for contexts of type ι ⇒ (ι ⇒ ι).)

By the full completeness result of Chapter 3, this is equivalent to a question of game semantics; to decide the intrinsic preorder on (finite) strategies of the unbracketed games model. With the lifting of the bracketing condition comes the power to make observational distinctions between extensionally equivalent strategies by ‘exploring’ them with a strategy on A → (o ⇒ o) which behaves in A as an Opponent, until some intensional feature is detected, then jumping out of A into o ⇒ o to record this. The problem is to determine which intensional differences between strategies are detectable in this way. Example 5.1.1 As a simple example, consider the μPCF terms L, M, N : nat ⇒ (nat ⇒ nat), where L = λx.λy.IF x then (IF y then 0 else 0) else 0 M = λx.λy.IF y then (IF x then 0 else 0) else 0 N = λx.λy.IF y then (IF x then (IF y then 0 else 0) else 0) else 0 L, M, and N are all observationally equivalent with respect to PCF contexts, — a consequence of Milner’s Context Lemma for PCF [61], which states that functiontype terms are observationally distinguishable if and only if they have they have distinguishable results when applied to the same argument. L and M are, however, distinguishable in μPCF, using the ‘catch’ term defined in Section 4.3.2: μα.[α]((L (μβ.[α]0)) (μβ.[α]1)) ⇓ 0, whilst μα.[α]((M μβ.[α]0) μβ.[α]1) ⇓ 1. But M and N are μPCF observationally equivalent; unnecessary repeated calls to a variable are not detectable using only control flow. But how to prove this?

5.1.1 A Context Lemma for μPCF

Proving ‘ad hoc’ that no context exists which can distinguish equivalent terms is difficult even in the trivial example above. However, definability in the games model, and its axiomatic characterization, can be used to extract a useful practical reasoning principle; context lemmas for Λ(Ω) and μPCF. Lemma 5.1.2 (Linear observers suffice) Suppose σ, τ : A are innocent unbracketed strategies such that σ ≴_{A} τ, i.e. there is some (innocent) ρ :!A ⊸ (o ⊸ o) such that σ; ρ ↓ and τ; ρ ↓̸. Then there is some ϕ : A ⊸ (o ⊸ o) such that σ; ϕ ↓ and τ; ϕ ↓̸ Proof: is by induction on the size of the uncovering of ρ∥σ. Applying the ‘linearization of head occurrence’ of Section 3.7.2 to ρ (which must be strict), yields a strict strategy ρ′ : A ⊸ (!A ⊸ (o ⊸ o)) such that: σ; (⟨ρ′, σ⟩; App) = σ; ρ (simply by relabelling the first-opened thread as play in the new component). Either τ; (⟨ρ′, σ⟩; App) ↓̸ or τ; (⟨ρ′, σ⟩; App) ↓. In the former case let ϕ = ρ′ × σ; App, then σ; ϕ ↓ and τ; ϕ ↓̸ as required. In the latter case, apply the induction hypothesis to id_{A} × (σ; ρ′); App : A → (o ⊸ o), as σ∥(id_{A} × (σ; ρ′); App) = σ∥ρ/(s↾a) (where s↾a is the initial thread in A), — so this is a strictly smaller uncovering than σ∥ρ, whilst σ; (id_{A} × (σ; ρ′); App) ↓ and τ; (id_{A} × (σ; ρ′); App) ↓̸. □

Proposition 5.1.3 Suppose A = \overline{B} ⇒ o, then for innocent strategies σ, τ : A, σ ≲_{A} τ if and only if for all innocent strategies ρ : o ⇒ \overline{B},

ρ; σ ↓ ⟹ ρ; τ ↓ .

Proof: Given σ, τ : A, by Lemma 5.1.2, σ ≲_{A} τ if and only if for all ρ : \overline{B} → (o ⊸ o), σ; ρ ↓ implies τ; ρ ↓. Recall the ‘Contravariance of continuations’ axiom for the category of innocent strategies from 3.7.2. This states that the map from strategies on D ⊸ C to strict strategies on (C ⊸ o) ⊸ (D ⊸ o):

(f : D → C) ⟶ Λ(id_{C⊸⊥} ⊗ f; App)

is an isomorphism. So σ ≲_{A} τ if and only if for all ϱ : o → \overline{B} (in the linear category) ϱ; σ = σ; Λ(id_{\overline{B}⊸o} ⊗ ρ; App) ↓ implies ϱ; τ = σ; Λ(id_{\overline{B}⊸o} ⊗ ρ; App) ↓. □

A simple context lemma along the lines of the Context Lemma for PCF is a corollary of full completeness, together with the above result.

Corollary 5.1.4 (Context Lemma for Λ(Ω)) For any closed terms of Λ(Ω), s, t : S_{1} ⇒ (S_{2} ⇒ … (S_{n} ⇒ ι) …) s ⊑^{OBS} t if and only if ∀r(x)_{1} : T_{1}, r(x)_{2} : T_{2}, … r(x)_{n} : T_{n}, λx.(s r(x)_{1} r(x)_{2} … r(x)_{n}) ⇓ ⟹ λx.(t r(x)_{1} r(x)_{2} … r(x)_{n}) ⇓ (where t ⇓ if and only if t =_{βη} λx.x).

Corollary 5.1.5 There are finitely many observational equivalence classes at each type of Λ(Ω).

Proof: is by a straightforward induction on type, using the Context Lemma, together with a hypothesis that given maximum depth and size measures for types as follows, d(ι) = 0, d(\overline{S} ⇒ ι) = max\{d(S_{i}) | i ≤ n\} + 1, and s(ι) = 0 s(\overline{S} ⇒ ι) = max\{s(S_{i}) | i ≤ n\} ∪ \{n\} then there are at most 2^{d(T)}.s(T)^^d(T) observational equivalence classes in ι ⇒ T (that is, a tower of s(T) exponents, of height d(T)). This is obvious for T = ι, so suppose ι ⇒ T = (\overline{S}, ι) ⇒ ι. Then s ⋢_{ι⇒T}^{OBS} t if and only if there exist q(x) : ι, p_{1}(x) : S_{1}, … p_{n}(x) : S_{n} (with x : ι free) such that λx.(s q(x)) p_{1}(x) … p_{n}(x) ⇓ and λx.(tq(x))p_{1}(x) … p_{n}(x) ⇓̸. By hypothesis, there are at most 2^{d(T)−1}.s(S_{i})^^d(S_{i}) equivalence classes of ι ⇒ S_{i} for each i (and 2 for ι ⇒ ι), hence at most 2^{d(T)}.s(T)^^d(T) many inequivalent combinations of q(x), p_{1}(x), …, p_{n}(x). □

The Context Lemma for μPCF itself is reminiscent of the Context Lemma for PCF. It says that evaluation contexts plus a single top-level continuation suffice to distinguish inequivalent terms.

Proposition 5.1.6 (Context Lemma for μPCF) For any closed terms M, N : T of μPCF (call-by-name or call-by-value), M ⊑_{T}^{OBS} N if and only if for all ground-type evaluation contexts E^{T} [·] : 0,

μα.E[M] ⇓ ⟹ μα.E[N] ⇓ .

Proof: Suppose M, N : T are terms of call-by-value μPCF, such that M ⋢_{T}^{OBS} N, then [[M]] ≴_{[[T]]} [[N]] By Proposition 5.1.1 there is a (finitary) element ρ : o^{ω} → ([[T]] ⇒ o) such that Λ(ρ × [[M]]; App) ↓ and Λ(ρ × [[N]]; App) ↓̸. By definability, there is a value with a free name α : nat ⊢ V : T ⇒ 0 such that [[V]] is the lifting of ρ. [[μα.V M]] = Λ(ρ × [[M]]; App), and [[μα.V N]] = Λ(ρ × [[N]]; App) and hence by adequacy μα.V M ⇓ and μα.V N ⇓̸ as required. Similarly if M, N : T = \overline{S} ⇒ nat are terms of call-by-name μPCF such that M ⋢_{T}^{OBS} N, then there are finite strategies ρ_{1} : o → [[S_{1}]], …, ρ_{n} : o → [[S_{n}]], and ρ′ : o ⇒ o such that Λ(⟨ρ_{1}, …, ρ_{n}⟩ × [[M]]; App) ↓ and Λ(⟨ρ_{1}, …, ρ_{n}⟩ × [[N]]; App) ↓̸. By definability, there are terms L_{1}(α), …, L_{n}(α) denoting ρ_{1}, …, ρ_{n}. Either ρ′ = id_{o} or ρ′ = ⊥_{o,o}, — in the former case set E[·] = μα.[α][ ]L_{1} … L_{n},

— in the latter E[·] = μα.IF [·] then Ω^{0} else Ω^{0}, to give the required evaluation context. □

The Context Lemma allows a simple proof of the following observation of Cartwright and Felleisen [15], that adding errors makes all control behaviour observable and hence:

Corollary 5.1.7 Observational equivalence in μPCF^{E} is extensional. i.e. M ⊑_{T}^{OBS} N if and only if for all evaluation contexts E^{T} [·] : nat, E[M] ⇓ e_{i} ⟹ E[N] ⇓ e_{i}.

Proof: Recall that terms M^{∗} of μPCF^{E} are soundly translated into terms M^{∗} of μPCF by including an additional free variable α, labelling errors e_{i} as μβ.[α]2i. Hence M ⋢_{T}^{OBS} N if μα.E[M^{∗}] ⇓ and μα.E[M^{∗}] ⇓̸ for some evaluation context E[·], containing only α free, by the Context Lemma. As E[·] can be assumed to consist of the finite evaluation trees given in the Definability Theorem, α is used to name only integers, and can be replaced with error terms to give an evaluation context E′[·] such that E′[M] ⇓ e_{i} and E′[N] ⇓̸ e_{i} as required. □

Although the search for witnesses to observational inequivalence can be restricted using the Context Lemma, this is still not sufficient to show decidability of the intrinsic preorder in the games model, as the set of plays in most innocent strategies over arenas of depth greater than one is unbounded, as Opponent can simply repeat a move ad infinitum. However, this is not constructive opposition; although it may be necessary to repeat moves to obtain intensional information, there is an intuition that in a finite arena, one can observe only finitely many different Player responses (as there are only finitely many different paths through the ‘game tree’). Therefore it should be possible to bound the size of the Opponent strategies needed to distinguish inequivalent finitary strategies. This is a non-trivial but feasible task, as a comparison with the problem of decidability in the ‘minimal model’, below, shows.

5.1.2 Observational equivalence in the λ-calculus

Although finitary PCF is not effectively presentable, there are even weaker extensional languages which are; notably PCF over a ground type with a single value, and the ‘minimal’ functional language: the λ-calculus with a finite number of constants at a single ground type ι. (Λ(Ω) fits into this definition but ground-type contextual equivalence for Λ(Ω) is trivial.) The simplest meaningful version of the problem is thus: determine observational equivalence for the λ-calculus Λ(Ω, ⊤) with two constants, one denoting divergence, Ω, and the other convergence, ⊤. The observational equivalence on this language was shown by Padovani to be decidable [68].

It is shown below that the contextual equivalence decision problems for Λ(Ω) (at first-order) (and hence finitary μPCF) and Λ(Ω, ⊤) (at ground type) are equivalent (and establishing this is much simpler than the solution to either problem). Thus the undecidability in the case of finitary PCF appears as an increasingly isolated result: not only are there decision procedures for the problem in both strictly weaker (unary PCF, linear PCF) and stronger versions (μPCF, idealized Algol), but in the case of Λ(Ω, ⊤) and μPCF there is also a simple connection between these results.

Definition 5.1.8 As with Λ(Ω) one can define a notion of reduction for Λ(Ω, ⊤) (this time to ground type), defining an evaluation relation on closed terms of type ι using the strong normalization theorem, i.e. M ⇓, if M : ι =_{βη} ⊤, and M ⇓̸ if M =_{βη} Ω.

As one would expect, the observational preorder is extensional, in other words, the following context lemma holds.

Proposition 5.1.9 For all closed terms s, t : T_{1} ⇒ (… (T_{n} ⇒ ι) …), s ⊑_{Λ(Ω,⊤)}^{OBS} t ⟺ ∀a_{1} : T_{1}, … a_{n} : T_{n}, s a_{1} … a_{n} ⇓ ⇒ t a_{1} … a_{n} ⇓.

Proof: is standard, simplified version of the proof of the Context Lemma for PCF [61]. Or it can be deduced from the Context Lemma for Λ(Ω). □

Just as for Λ(Ω), the Context Lemma can be used to show that there are only finitely many observational equivalence classes at each type. Hence observational equivalence can be decided by giving an algorithm which generates a finite list of terms at each type, containing at least one representative from each equivalence class. Such an algorithm for Λ(Ω, ⊤) was described by Padovani (a simpler version is described by Loader [53], following Schmidt-Schaüss’s analysis for unary PCF).

Theorem 5.1.10 (Padovani) The ‘minimal model’ of Λ(Ω, ⊤) is effectively presentable.

Despite the obvious differences between the two preorders, and hence the fully abstract models, the closeness of the syntax and notion of reduction allows each to be used to reason about the other. In fact, the problems of effective presentability for the two models are easily shown to be equivalent.

Proposition 5.1.11 The observational preorder on Λ(Ω) is decidable if and only if it is decidable in Λ(Ω, ⊤).

Proof: Proposition 5.1.12 For all terms s, t : T of Λ(Ω), (which are also terms of Λ(Ω, ⊤))

s ⊑_{Λ(Ω,⊤)}^{OBS} t ⟺ s ⊑_{Λ(Ω)}^{OBS} t.

Proof: Suppose s ⋢_{Λ(Ω,⊤)}^{OBS} t, then for some context C^{T} [·] : ι ⇒ ι, C[s] ⇓ and C[t] ⇓̸, hence (C[s] ⊤) ⇓ ⊤ and (C[t] ⊤) ⇓̸ ⊤, so s ⋢_{Λ(Ω)}^{OBS} t as required. Suppose s ⋢_{Λ(Ω)}^{OBS} s, then for some ground-typed Λ(Ω, ⊤) context C^{T} [·], C[s] ⇓ and C[t] ⇓̸. Then as there are no reduction rules for the constants, C[s][x/⊤] normalizes to x, and C[t][x/⊤] normalizes to Ω. Hence λx.C[s][x/⊤] ⇓ and λx.C[t][x/⊤] ⇓̸, i.e. s ⋢_{Λ(Ω,⊤)}^{OBS} t as required. □

Corollary 5.1.13 Fully abstract models of Λ(Ω) (and thus μPCF) are effectively presentable.

However, the converse can also be shown.

Proposition 5.1.14 If the minimal model of Λ(Ω) is effectively presentable, then so is the minimal model of Λ(Ω, ⊤).

Proof: The observational preorder on Λ(Ω, ⊤) is decidable as follows. Given terms of Λ(Ω, ⊤), s, t : T, by the Context Lemma, M ⋢_{Λ(Ω,⊤)}^{OBS} N if and only if there exist r_{1}, … r_{n} such that s r_{1} … r_{n} ⇓ ⊤ and t r_{1} … t_{n} ⇓̸ ⊤. Thus s ⋢_{Λ(Ω)}^{OBS} t if and only if there exist Λ(Ω)-terms p_{1}(x), … p_{n}(x) such that (s[x/⊤] p_{1} … p_{n}) normalizes to x, and (t[x/⊤] p_{1} … p_{n}) normalizes to Ω (take r_{i} = p_{i}[⊤/x]), i.e. λx.s[x/⊤] p_{1}(x) … p_{n}(x)) ⇓ and λx.(t[x/⊤] p_{1}(x) … p_{n}(x)) ⇓̸ . If p_{i}(x) ≡_{Λ(Ω)} p′_{i}(x), then λx.s(x) p_{1} … p_{n}(x) ⇓ if and only if λx.s(x) p′_{1} … p′_{n}(x) ⇓. So it is only necessary to test s[x/⊤], t[x/⊤] against all combinations of representatives of the different Λ(Ω) observational equivalence classes of p_{1}, … p_{n}, of which there are finitely many, so assuming a listing algorithm for Λ(Ω), observational equivalence for Λ(Ω, ⊤) is decidable. □

The effective presentability problem for μPCF has been answered in the affirmative. However, reasoning syntactically and indirectly via a (quite complex) proof for another language is not a very informative analysis. The solution to the effective presentability problem, as for full abstraction, should be syntax independent.

Remark 5.1.15 Padovani’s result was achieved in the course of investigation into the ‘higher order matching problem’ (given r : S ⇒ T, and T : T, is there some s : S such that r s =_{βη} t?) of which it gives a solution in the case where t is an atom. Thus the characterization of Λ(Ω)-equivalence given here will be a semantic solution to this problem, and will also solve a similar problem: decidability of higher-order matching with respect to the largest non-trivial congruence containing βη equivalence. Given a listing algorithm, higher-order matching with respect to ≃ is decidable as observational equivalence classes of ≃ are finite.

Thus far little attention has been paid to the question of which are the extensional functions computed in models of control, with the justification that control is intrinsically an intensional affair. The order-extensionality of the fully abstract model of SPCF with errors might be considered as contradicting this last assertion. However, the significance of the extensionality of control with errors is that it exposes an incompatibility between the formal definition of extensionality (which it satisfies), and a more informal notion of extensional model as given by some order-theoretic or topological description of set-theoretic functions (such as continuity, stability etcetera). The SPCF result highlights the ambiguities created by conflating these notions, as it shows that using errors it is possible to determine precisely how a function computes purely from the results of applying it to different arguments. Because intensional behaviour is made explicit by the error values, there can be no way of giving such an abstract description of the model.

A different strategy is to consider the extensional functions which are ‘computed’ (in some sense) by a category of intensional objects. The fully abstract model of PCF for instance, can be obtained as the extensional collapse of the highly intensional games and strategies model.

Berry and Curien’s definition of the sequential algorithms [9] is also in this vein. It developed from an attempt by Kahn and Plotkin [45] to define a notion of sequential function made by structuring domains as concrete data structures (CDS). This allows higher-order computation to be modelled as a process of information-gathering by filling cells with values. A function between CDSs is sequential if it can be computed in a concrete data structure in a deterministic way; that is, there are ‘sequentiality indices’ at each point in the computation specifying the next cell which must be filled in the argument, to give more information at the output. The category of sequential functions is not, however, cartesian closed; to gain this semantic ‘good behaviour’ it is necessary to specify them along with sequentiality indices bearing witness to their sequentiality, forming the category of sequential algorithms.

An alternative notion of sequential functional ‘realized’ by the sequential al-

Innocent unbracketed strategies

observational collapse

[figure]

extensional collapse

[figure]

[figure]

Sequential Algorithms

extensional collapse

[figure]

Strongly stable functions

Figure 5.1: Relationship of three models of call-by-name PCF

gorithms has been considered by Ehrhard [24], who proved that the extensional collapse of the sequential algorithms model of PCF is isomorphic to Bucciarelli and Ehrhard’s strongly stable model, or, in other words, that every strongly stable functional over a PCF-type is computed by a sequential algorithm. The proof that the intensional collapse of the unbracketed games model is isomorphic to the sequential algorithm can thus be ‘composed’ with this one, to yield the result that the extensional collapse of the unbracketed games model is also isomorphic to the strongly stable model (see Figure 5.1, and Corollary 5.4.23). Work by Longley [55], amongst others, has connected this sequentiality to the formal notion of realizability.

5.2 A sequential algorithms model of control

The description of the rich category of sequential algorithms, is necessarily somewhat terse, and slanted towards game semantics. A wealth of further material, including relationships with other semantics of for sequential languages is to be found in Curien’s book [18], and article [19].

Following Cartwright and Felleisen’s discovery that SPCF has a fully abstract semantics in terms of ‘decision trees’, it was observed by Curien that the model could be given an alternative presentation using sequential algorithms, which was adopted by Cartwright, Curien and Felleisen in [16]. This theme was developed in Curien’s article [19], which also made some connections with the game semantics. The content of this connection is that at the affine level, the structures of Abramsky-Jagadeesan (and subsequently Hyland-Ong) games, and Sequential Data structures are essentially the same. The differences lie in the way constraints are used to enforce functional behaviour, whilst permitting non-linearity. In sequential data structures, access to data is shared (strategies can see the whole game history), but any given test can be applied to a variable only once, so it doesn’t get the chance to behave inconsistently. By contrast, information which is not relevant to an innocent strategy, (such as how many times a variable has been used) is hidden from it, but it can (and must) copy information as required. This contrast between global and local constraints can be observed directly in the differing ways of modelling a co-monadic !, to yield an intuitionistic type-structure in the co-Kleisli category.

• Plays (or paths) in the sequential algorithms ! are more constrained, in that repeated queries are not allowed, and Player must respond to the most recent Opponent move.

• The strategies on dialogue games are constrained by visibility and innocence; although repetitious queries are allowed, Player must make the same response to them every time.

The games models of state [2], [4] are given by succesively dropping innocence and visibility, reflecting a setting where both copying and sharing of data is allowed, to model local binding of imperative variables. One consequence of interpreting functional behaviour in sequential algorithm style by allowing sharing but limiting copying is that this hierarchy of models is not available (sequential algorithms model of state could be constructed by allowing repetitions of moves but even strategies such as the identity will behave differently from the purely functional model). The structure of arenas and games defined in Chapter 3 can be used to define a category of sequential data structures and sequential algorithms (as a particular category of games and strategies). In fact, they are rather ‘over-defined’, the roles of enabling and justification being somewhat superfluous. So the following definitions differ in terminology from Curien’s definition of ‘concrete sequential algorithms’ [19], but they can readily be seen to be equivalent. (‘addresses’ correspond to Opponent moves, ‘data’ to Player moves, ‘queries’ to positions with Player to move (odd-length plays), and ‘responses’ to positions with Opponent to move (even length plays)).

Definition 5.2.1 A Sequential Data Structure (SDS) arena A = ⟨M_{A}, ⊢_{A}, P ∪{O, P }∪{Q, A}, λ_{A}⟩ is an alternating, bracketed arena with an additional labelling of moves as paths — i.e. non-empty sequences of moves over an SDS arena (without their justification pointers). These will be called pathmoves. Rather than extend the labelling function, each path-move will be written as the corresponding sequence.

A sequential data structure is the game generated from a SDS-arena by alternation, the bracketing condition, and the following rule.

• No repetitions of moves in plays: If sa ⊏ tb, then a ≠ b

The product and function space constructions on SDS arenas are exactly as in Definition 3.2.2.

The path-moves for the SDS arenas used in the models of control will be constructed from the plays of a SDS, and hence will satisfy these rules as well (but they need not be required to do so). The above rules satisfy the identity and compositionality conditions and hence define a category. (This is easy to see,

— as no moves can be repeated by any sequential algorithms, there can be no repetitions of moves in the ‘interaction sequence’ of two sequential algorithms, and hence none in the plays of their composition.) The standard constructions of Section 3.2.2 forming function-space and product arenas then give a symmmetric monoidal closed structure (together with the empty and one-move arenas).

Definition 5.2.2 A sequential algorithm is a deterministic, history sensitive strategy over a sequential data structure A (i.e. a prefix-closed set of evenly-branching even-length paths of A, in which the final move can depend on the entire history of the play). The category of affine sequential algorithms has sequential data structures as objects, and sequential algorithms on A ⊸ B (defined in the standard way) as morphisms from A to B.

Comparison with the original definition of the Berry-Curien Sequential algorithms over concrete data structures is described formally and in detail in [19]. This shows that the sequential data structures are equivalent to filiform concrete data structures. The latter are defined by a quadruple (C, V, E, ⊢) of cells, values, events (⊆ C × V) and enablings (⊆ (E × C) ∪ C). An event consists of the filling of a cell with a value; this enables further cells to be filled, and so on. A (consistent and safe) state of the CDS is a set of events such that each filled cell is enabled and contains at most one value. Filiform CDS are assumed to be stable,

— each cell which is filled within a state has a unique enabling in that state. Each SDS defines a stable filiform CDS in which:

• cells are odd-length paths,

• values are Player moves, and

• events are even-length paths (filling a cell with a value is thus extending an position with player to move with a Player move), • An event enables a cell if the latter (odd-length path) is the direct extension

of the former (even-length path) with an Opponent move.

Thus states of the filiform CDS correspond via consistency and safety to evenprefix closed sets of plays; i.e. strategies. Conversely, given a stable fcds, an equivalent sequential data structure can be constructed by taking Opponent moves to be cells, Player moves to be events, and the paths to be all alternating sequences of moves such that each Player move is the filling of the previous cell with a value, and each Opponent move (cell) is enabled by the previous Player move (event). Sequential algorithms over these equivalent structures can be defined in an abstract or concrete way; ‘Concrete’ (affine) algorithms from A to B are just strategies on A ⊸ B as in the standard linear category. Abstract algorithms (the original presentation) are sequential functions between the states of A and B together with sequentiality indices, which can be defined in various ways described in [19]; they form a CCC.

A subcategory, the abstract affine sequential algorithms over sequential data structures is axiomatized and shown to be equivalent to the concrete affine algorithms. The inclusion of the affine algorithms into the cartesian closed category has a left adjoint, and resolving this defines a co-monad on the affine (concrete) category, such that the co-Kleisli category is equivalent to the CCC of abstract algorithms. This can be described at the level of games semantics as follows.

As moves of a sequential data structure are, in general, sequences of moves, the paths of A can be used as the moves of !A. By definition of a sequential data-structure, paths in !A are thus non-repetitive sequences of path-moves such that Opponent moves (questions) are odd-length and extend some previous move and Player moves (answers) are even-length and extend the preceding path-move. In other words, a path in !A consists of a sequence of different interrogations of a single Player strategy on A.

Definition 5.2.3 For a sequential data structure A, define !_{S}A to be the SDS with the arena:

• M_{!_{S}A} = P_{A} — the sequences over A satisfying the bracketing and norepetitions rules.

• λ^{OP} (m) = O, and λ^{QA}(m) = Q if m is an odd-length path in A. λ^{OP} (m) = P and λ^{QA}(m) = A if m is an even-length path in A.

• ∗ ⊢_{!_{S}A} m, where m is a path in A consisting of a single move, p ⊢_{!_{S}A} pa where pa is a direct extension of p.

Note that this agrees with the convention that answers should be justified by questions. Defining moves of !_{S}A as paths of A is not strictly necessary — one could use the same moves as A, and use justification pointers to reconstruct pathmoves, but it allows the linearity (i.e. non-repetitivity) condition to be used in a straightforward way, by packaging the ‘justification history’ of a move up with it.

Proposition 5.2.4 P_{!_{S}A} consists of alternating, non-repetitive sequences of moves subject to the following condition: If λ^{OP} (pa) = O, then s(pa) ∈ P_{!_{S}A} if and only if s ∈ P_{!_{S}A} and pa is a path-move of length one, or there is some previous Player move p in s such that pa extends p. If λ^{OP} (pa) = P, then s(pa) ∈ P_{!_{S}A} if and only if s ∈ P_{!_{S}A} and pa extends the preceding Opponent move.

Proof: is direct by application of the bracketing condition □

Note that the rôle of the bracketing condition is rather different here than in the previous chapters. It does not enforce ‘local control flow’, but permits presentation of the sequential algorithms ! as a game generated on an arena. Further, whilst the ‘switching condition’ does not hold in general, it does hold for all games of the form !(A ⊗ B), and !(A ⊗ B) ⊸ o, which is sufficient for it to hold throughout the CCC with objects freely constructed from o (as defined below).

The sequential data structure and dialogue games versions of the ! both construct ‘linearized’ versions of the game tree, allowing Opponent to explore different branches of Player’s strategy (see Figure 5.2. The key difference is that branches of the tree (from root to tip) are represented as interleaved ‘threads’ — (i.e. subsequences) of a dialogue, and as single moves of the SDS, without the same possibilities for interleaving.

Proposition 5.2.5 !_{S} is a co-monad, and its co-Kleisli category is cartesian closed.

Proof: is direct from the description of !_{S} in [19] as the resolution of an adjoint inclusion of an affine category into a CCC. However, it will prove useful to have a concrete description of !_{S} as a functor and co-monad.

Definition 5.2.6 Define the following projection ⌈ ⌉ from sequences J_{!_{S}A⊸!_{S}B} to paths over A ⊸ B P_{A⊸B} which is similar to the view function, except that it also reduces path-moves to moves of A or B by extracting the last move.

• ⌈s(p) · t(pa)⌉ = ⌈s(p)⌉a, if pa is an Opponent move justifying (i.e. directly extending) p,

• ⌈s(pa)⌉ = ⌈s⌉a if pa is a Player move.

Let χ : A ⊸ B be a sequential algorithm expressed as a function fromodd-length paths to moves, and define the function !_{S}χ :!_{S}A ⊸!_{S}B from sequences of pathmoves to path-moves as follows: If (χ(⌈s⌉) is a move in in B, then !_{S}χ(s) = (⌈s⌉ ↾ A)χ(⌈s⌉). Otherwise, it is necessary to consider whether the move p = (⌈s⌉↾A)χ(⌈s⌉) occurs in s or not. If it does, then it is succeeded by some Opponent move pa which extends it. Then let !_{S}χ(s) =!_{S}χ(s(p)(pa)), otherwise, let !_{S}χ(s) = p. Note that !_{S}χ is necessarily defined on sequences which contain repetitions, so that the sequential algorithm is in fact the restriction of !_{S}χ to sequential algorithm paths. Verification that !_{S} is a functor is now straightforward. The co-monadic structure of the !_{S} can be summarised as follows. For each SDS A, there are sequential algorithms

• der^{S}_{A} :!_{S}A ⊸ A is essentially a copycat defined as follows:

       – ε ∈ der^{S}_{A}

– sa(sa↾A) ∈ der_{A}, if s ∈ der^{S}_{A} and a ⊏ −A (so (sa↾A) is a path move in !_{S}A)

Figure 5.2: Plays in dialogue games and sequential algorithms ‘banged’ games: thick lines represent different threads of play

– s(pab)b ∈ der^{S}_{A}, if s ∈ der^{S}_{A} and pab ⊏ −!_{S}A

• A promotion algorithm prom^{s}_{A} :!_{S}A ⊸!_{S}!_{S}A

– s(p(ua))ua ∈ prom^{s}_{A} if s ∈ prom^{s}_{A} and p(ua) ∈ M_{!_{S}!_{S}}A and ua ∈ M_{!_{S}A} does not occur previously in s

– s(p(ua))(p(uab)) ∈ prom^{s}_{A} if s ∈ prom^{s}_{A} and p(ua) ∈ M_{!_{S}!_{S}A} and ua ∈ M_{!_{S}A} does occur previously in s, where it is directly followed by uab.

– s(p(ua))(ua)(uab)(p(uab)) if s(p(ua))(ua) ∈ prom^{s}_{A}

• for any SDS A, B, there is an isomorphism !_{S}(A × B) ⊸!_{S}A⊗!_{S}B, yielding a contraction mapping con^{S}_{A} :!_{S}A^{−} ⊸!_{S}A_{1}⊗!_{S}A_{2} definable as follows: s(pa)_{i}pa^{−} ∈ con^{S}_{A} if s ∈ con^{S}_{A} and pa_{i} ⊏ −M_{A_{i}} does not occur in s↾A^{−} spa_{i}pab_{i} ∈ con^{S}_{A} if s ∈ con^{S}_{A} and pa_{i} ⊏ −M_{A_{i}} does occur in s↾A^{−}, where it is immediately followed by pab. spab^{−}pab_{i} ∈ con^{S}_{A} if s ∈ con^{S}_{A} and pab extends (uniquely) some move pa_{i} ⊏ −M_{A_{i}} already played in s.

These morphisms satisfy the conditions described in Chapter 3. □

Note that the natural transformations giving the co-monadic structure of !_{S}, — in particular promotion and contraction — are not true copycats; they rely critically on the history of the interaction to determine whether a move has already been played, and so avoid repetititions.

Having defined a CCC of sequential algorithms, S, models of call-by-name and call-by-value μPCF are accessible by standard constructions. The one-move game o is a sequential data structure, and there are bottom maps (empty strategies), and ω-indexed products for each object. As in the rest of the category of games, set-inclusion of strategies is a cpo-enrichment.

Proposition 5.2.7 (S, o) defines a computational (continuous) model of control: i.e. S is a cpo-enriched CCC with ω-indexed products, and o is non-terminal.

The following example contrasts computational behaviour in the sequential algorithms and innocent strategy models.

Example 5.2.8 Consider the sequential algorithms and innocent strategy interpretations of λf: nat → nat.f (f 0) : (nat → nat) → nat (Figure 5.3). This is the simplest term to exhibit imbrication (the application of a function variable to an argument which calls the variable itself). This ‘diabolical’ non-linearity is what makes determining observational equivalence a hard problem. In innocent strategies it corresponds directly to interleaving; returning to a thread after opening another in the same component. Plays in the innocent strategy (top) are uniform; it is just blindly, innocently copying moves, unlike the corresponding sequential algorithm, which makes a devious exit if it discovers that zero is a fixed point of its argument. (Otherwise the repetition condition would be broken). The sequential algorithm has already done some computation, — the innocent strategy can only compute by composition with other strategies.

A significant point about the ‘no-repetitions’ condition is that it is symmetric between Player and Opponent: an Opponent strategy on A can be turned into a Player strategy on A ⊸ (o ⇒ o) just by adding additional initial and final moves. Consequently the category is isomorphic to its own ‘observational collapse’.

Proposition 5.2.9 The intrinsic preorder and equivalence on sequential algorithms is trivial — i.e. if ⊆_{A} is the subset relation on the concrete representations of algorithms as strategies, then

f ≲_{A} g ⟺ f ⊆_{A} g.

Proof: The implication from right to left is trivial; for the converse, suppose that f ⊈ g, Then the promotion of f is not included in the promotion of g, i.e. !f ⊈!g. By prefix closure, there is some path p ∈ P_{!_{S}A} of finite length, such that p ∈!f

[figure: (ℕ; ℕ); ℕ; (ℕ; ℕ); ℕ; (ℕ; ℕ); ℕ; O_{q}; O_{q}; O_{q}; P_{q}; P_{q}; P_{q}; O_{q}; O_{q}; O_{q}; P_{q}; P_{0}; P_{0}; O_{q}; O_{n+1}; O_{0}; P_{0}; P_{n+1}; P_{0}; O_{n}; O_{m}; P_{n}; P_{m}; O_{m}; P_{m}]

Figure 5.3: Contrasting plays for computing f (f 0): Left is the general innocent strategy, Centre is the sequential algorithm (assuming f 0 ≠ 0), Right is the sequential algorithms play for f 0 = 0 but p ∉!g. Then form the sequential algorithm h :!_{S}A ⊸ (o ⇒ o) consisting of even prefixes of op · o′ (where o, o′ are the initial move and the response in o ⊸ o). Then f; h ↓ and g; h ↓̸ and so f ≴_{A} g as required. □

Corollary 5.2.10 The semantics of Λ(Ω) (and hence μPCF) in (S, o) is fully abstract if every finite sequential algorithm is definable.

5.3 A fully abstract and universal model of μPCF

In fact, it is relatively straightforward to prove that every recursive element of the sequential algorithms model of control is μPCF definable. A universality result for the observably sequential functional model of SPCF has been achieved by Kanneganti, Cartwright and Felleisen [46]; this is dependent on the existence of errors, and is presented rather differently to the main result of this section, which is the following:

Theorem 5.3.1 The semantics of μPCF_{n} in the category S of sequential data structures and computable sequential algorithms is universal.

(The result is proved for μPCF_{n} for the sake of simplicity but there is no obstacle to extending it to include the call-by-value version.) As observed in Chapter 2, Section 2.5.1, this has the following corollary.

Corollary 5.3.2 The semantics of μPCF_{n} in S is logically fully abstract.

5.3.1 The computable sequential algorithms

The Universality Theorem is proved (as in [6],[43]) by defining a family of ‘universal terms’ for the language, relative to an effective enumeration of a finitary basis for the category.

Definition 5.3.3 An effective coding of the computable sequential algorithms is a family of (effective) surjective functions indexed over the μPCF types, {ϕ_{T} : nat → [[T]]_{S} | T ∈ T Y_{μPCF}}, giving a listing of the computable sequential algorithms on each type-object [[T]]. A universal term with respect to ϕ is a family of μPCF_{n} terms indexed over the μPCF types, {U_{T} : nat → T | T ∈ T Y_{μPCF}} such that

[[U_{T} (n)]]_{S} = ϕ_{T} (n).

The first step in defining such a term is thus to fix a definition and encoding of the computable sequential algorithms.

Definition 5.3.4 Suppose p_{0}, p_{1}, …, p_{n}, … is an effective presentation of a finitary basis of a domain A (in this case a sequential data structure). i.e. a recursive enumeration of compact elements such that every sequential algorithm is a supremum of some directed set. A sequential algorithm σ : A is computable if it is the least upper bound of a recursively specified set, i.e. there is a partial recursive function f_{σ} : ℕ → ℕ such that ⨆_{n∈ω} p(f_{σ}(n)) = σ. Assuming a (computable) listing of the partial recursive functions on ℕ → ℕ in the form of a surjective recursive functional, ψ : ℕ → (ℕ → ℕ), this yields a listing of the computable elements of the domain as σ_{1}, σ_{2}, …, where σ_{i} = ⨆_{n∈ℕ} p_{ψ(i)(n)}.

Thus it remains to give an effective presentation of a finitary basis for the sequential algorithms, (which differs from the standard notion of effective presentation only in that the effective operations defined on the basis are described so as to simplify the proof of universality). Every sequential algorithm is the supremum of its set of finite paths. Thus the effective presentation of this finite basis takes the form of an injection from paths over A to natural numbers.

Definition 5.3.5 (Encoding of paths) Define path_{A} : A → ℕ, by structural induction on the SDS A. At the base cases: path_{o}(ε) = 0, path_{o}(o) = 1 path_{o^{ω}}(ε) = 0, path_{o^{ω}}(m_{i}) = i + 1. Now suppose A = B_{1} ⇒ (B_{2} ⇒ … (B_{n} ⇒ o) …), and define: path_{A}(ε) = 0, path_{A}(o) = 1 path_{A}(s(pa)) = (6.path_{A}(s) + 1).2^{path_{B_{i}}(p)}.3^{i}, where p is a path in B_{i}.

Thus path_{A} is essentially an encoding of finite lists (of lists).

Proposition 5.3.6 There are recursive (μPCF definable) functions for the following operations on the effective presentation:

• init : nat → nat and last : nat → nat for taking initial segments and last elements, such that: init(path_{A}(sa)) = path_{A}(s) and if a is a move in B_{i}, last(path_{A}(sa)) = path_{B_{i}}(a)

• comp_{A} : nat → nat for returning the subgame in which the last move was made. For each type-object A = B_{1} ⇒ (B_{2} ⇒ … (B_{n} ⇒ ι))), if a is a move from B_{i} then comp_{A}(path_{A}(sa)) = i

Proof: is by definability of all recursive functions in μPCF. □

It is also possible to (recursively) extract the code for the substrategy manifested in a path over \overline{B} ⇒ o, in a given subcomponent B_{i}, using the representation of strategies as least upper bounds of directed sets.

Proposition 5.3.7 For each sequential data structure \overline{B} ⇒ o, there are μPCFdefinable functions strat_{i} : nat → nat such that if s is a path in \overline{B} ⇒ o, and R_{i}(s) = \{p ∈ Occ(s) | p ∈ P_{B_{i}}\} is the strategy on B_{i} manifested in s, then ϕ(strat_{i}(path_{A}(s))) = R_{i}(s).

Proof: is by recursive definition of strat_{i} as follows. Assume that our listing function for the partial recursive functions comes with a partial recursive functional hotel : nat × nat → nat, which takes the code of a recursive function and, a value n, and returns the code for a function with n as the new value of f(0), and f(k) as the value at succ k. i.e. ψ(hotel(i, n)) 0 = n and ψ(hotel(i, n)) k + 1 = ψ(i, k). Then let:

• strat_{i}(0) = ϕ(⊥_{A}) = 0,

• strat_{i}(n + 1) = strat_{i}(init(n + 1)), if comp(last(n + 1)) ≠ i,

• strat_{i}(n + 1) = hotel(⟨strat_{i}(init(n + 1)), last(n + 1)⟩), if comp(last(n + 1)) = i.

□

5.3.2 Definability

The critical part of the definition of a universal term is a proof of finite definability by an inductive decomposition of strategies. The proof here is similar in essence to that given for SPCF in [16], but it is (a little) more abstract being based on some general properties of the category, more general, (in that it applies, via invertible cps translation, to μPCF_{v}), and simpler, as there is no use of error elements. The basic idea is to add an extra premise of type ι to the interpretations of types-in-context. Instead of simply giving up, partial strategies can use their last move to jump into this part of the context. This allows the flow of control to be used in definability; each algorithm can be decomposed into strictly smaller ones which are ‘glued together’ by passing the flow of control from one to the next.

Definition 5.3.8 A sequential algorithm f : A is total if every maximal length path in f is also maximal in A, — i.e. f always has a response to Opponent’s last move.

Proposition 5.3.9 The finite and total sequential algorithms form a cartesian closed category S^{T}.

Proof: is by a routine check that composition etc. preserves totality (which requires the hypothesis of finiteness). □

Recall from Chapter 2, Section 2.1 that any CCC gives rise to a pointed CCC, C_{⊥} as the co-Kleisli category of a co-monad which freely adjoins a ground type-object. So consider the pointed CCC (S^{T})_{⊥} of total sequential algorithms over the one move game. This is isomorphic to S^{f}, the CCC of finite sequential algorithms. If C already has ⊥-maps, then there is an obvious functor ⊥ : C_{⊥} → C: ⊥(f : o × A → B) ⟶ ⟨⊥_{A,o}, id_{A}⟩; f : A → B.

Proposition 5.3.10 ⊥ : (S^{T})_{⊥} ≅ S^{f} i.e. ⊥_{o} has an inverse ˜( ) : (f : A → B) ⟶ f̃: o × A → B.

Proof: ˜( ) can be defined by a ‘factorization of partiality’ which turns bottom into top (Figure 5.4), — whenever a partial algorithm f has no response, and would just give up, f̃ jumps out to the adjoined copy of o, after which play stops as neither side can make a move. Composition with ⊥_{o} clearly returns the original strategy. Formally, given a sequential algorithm f as a function from odd-length, f-reachable paths to moves, define f̃(s) = o, if f(s) ↑, f̃(s) = f(s), otherwise. □

Lemma 5.3.11 For any sequential algorithms f, g : A → o such that f, g are bounded above, f ⊔ g = ⟨g, id⟩; f̃.

Proof: ⟨g, id⟩; f̃ plays as f until it reaches a position to which f has no response. It then plays as g, except that by the non-repetition condition, it can only play path-moves in \overline{A} which extend the path-moves already played by f. Hence ⟨g, id⟩; f̃ = f ⊔ g as required. □

Factorizing partiality allows definability of a finite basis to be extended to recursive definability. A series of sequential alogrithms f_{0}, f_{1}, … can be ‘linked’ by playing f̃_{0} until Opponent gives up, or f_{0} gives up, in which case f̃_{0} passes out control to f̃_{1}. Infinite chains of factorized algorithms can be joined in this way using least fixpoints represented by the Y-combinator.

Proposition 5.3.12 (Universality Lemma) Suppose U^{f} is a universal term for factorized partial maps from a finite basis (i.e. [[U_{T}^{f}(n)]] = f̃_{n} : o ⇒ [[T]] for some enumeration of a finite basis f_{0}, f_{1}, … of [[T]]). Then there is a universal term for S with respect to that basis, given by U_{\overline{S}⇒0} =

λw: nat.λ\overline{y}: \overline{S}.(YλF : nat ⇒ 0.λx : nat.(U^{f}(x) F (ψ(w) (succ x))) \overline{y}) 0.

Similarly U_{\overline{S}⇒nat} =

λw: nat.λ\overline{y}: \overline{S}.μα : nat.(YλF.λx.[α](U^{f}(x) F (ψ(w) (succ x))) \overline{y}) 0.

Proof: Suppose ϕ(n) = h, i.e. h = ⨆_{i∈ω} f_{ψ(n)(i)}. Then by Lemma 5.3.11, for each k ∈ ω,

⨆_{i≤k} f_{ψ(n)(i)} = ⟨f_{ψ(n)(k)}, id⟩; { \atop (… ⟨f_{ψ(n)(1)}, id_{A}⟩; { \atop f_{ψ(n)(0)}} …)}

= [[U^{f}(0) (U^{f}(ψ(n)(1)) (… (U^{f}(ψ(n)(k))) …))]] = [[λF : nat ⇒ 0.λx : nat.(U^{f}(x) \overline{y}) F (ψ(n)(succ x))) 0]]^{k}. Hence by definition of Y as a least fixed point, h = [[U(n)]] as required. □

The above example allows partiality together with a top element introduced by adjoining an answer-object to the context. This allows non-terminating behaviour to co-exist with ‘error-detection’ (which is how explicit error values are modelled

Figure 5.4: ‘Partiality factorization’ in the CCF model). ‘Escaping strategies’ of this sort can be represented by strategies with (maximal) odd-length paths; a (maximal) even length play corresponds to non-termination (Player ‘giving up’) and a (maximal) odd-length play corresponds to an escape, or playing the top element.

Definition 5.3.13 An escaping (deterministic) strategy on a game A is a nonempty, even-prefix-closed, evenly-branching subset of A such that if s ∈ σ and ∃t ∈ σ s.t. s ⊏ t, then s is even-length. Then { \atop σ : o ⇒ A} = σ↾A defines a bijection from (innocent) escaping strategies on A to (innocent) strategies on o ⇒ A with inverse σ ⟶ {s(even) ∈ σ} ∪ {so | s(odd) ∈ σ ∧ ¬∃(t ∈ σ) ⊐ s}, where o is the only move in o. This extends to innocent strategies via the standard definition of innocence: an escaping strategy σ is innocent if sa, t ∈ σ ∧ ⌜s⌝ ∈ σ ⟹ ta ∈ σ.

Composition of escaping strategies is defined as parallel composition with hiding as in Chapter 3, with the result that ˆ( ) is an isomorphism between the escaping strategies, and the category of games and strategies with a one-move game freely adjoined to the context (assuming a little currying).

Proposition 5.3.14 Given f : (o × A) → B, g : (o × B) → C

f̂; ĝ = { \atop ⟨f, π_{l}⟩; g}.

Proof: is straightforward; note that if the last move of s ∈ f̂∥ĝ is in B and hence hidden, then s↾A, C is odd-length. Thus if an ‘escape’ occurs in a hidden part of the composition, then it corresponds to an escape from the unhidden part. □

Escaping strategies on A → B inherit the order-enrichment on o × A → B,

— f ≤ g if and only if f̂ ≤ ĝ. Note that this is not longer simply inclusion, although observational equivalence of escaping sequential algorithms is still set-equality.

5.3.3 Decomposition of escaping strategies

A unique decomposition of escaping strategies can be found by considering strategies in which a unique Opponent strategy prompts an escape.

Definition 5.3.15 A sequential algorithm f : o × \overline{A} ⇒ o is uniquely escaping if there is a unique (minimal) Opponent strategy recognised by σ; i.e. unique sequential algorithms g_{1} : A_{1}, g_{2} : A_{2}, … g_{n} such that

id_{o} × ⟨g_{1} … g_{n}⟩; f ≠ ⊥_{o,o}.

Uniquely escaping strategies over A can therefore be identified with an even-prefix closed set of paths of which precisely one is odd-length, — corresponding to the Opponent-strategy which is recognised.

By the Universality Lemma, definability need only be proved for a particular class of (partially factorized) strategies — the basis corresponding to the finitary paths of the sequential data structure (and such strategies have the useful property of decomposing uniquely).

Definition 5.3.16 For each a sequential data structure A, define the path-strategies over A to be uniquely escaping finitary sequential algorithms g : o → A such that if f, f′ ≲_{A} ⊥_{o}; g then f ≲_{A} f′ or f′ ≲_{A} f. So path-strategies are sequential algorithms which have a response to precisely one of the possible Opponent moves at any given point; at some stage, this is a move in o, and the interaction stops. Path strategies on A can therefore be uniquely represented by (and by abuse, identified with) an odd-length path over A.

Proposition 5.3.17 If all of the (partial factorized) path-strategies over A are definable, then all of the finite sequential algorithms over A are definable.

Proof: is via Lemma 5.3.11, as for the Universality Lemma. □

Definability of path strategies is proved by observing that each one has a unique decomposition into an initial segment followed by a Player move and a unique escape (the recognition of a unique Opponent move and a jump into the one-move game adjoined to the context). Note the contrast of this ‘top down’ induction with the decomposition of innocent strategies, which is ‘from the bottom up’; using the response to the initial move to split the strategy into smaller strategies.

Proposition 5.3.18 (Decomposition Lemma) Let f : \overline{A} × o → o be a nonempty path-strategy. Then for some i ≤ n there is a path-strategy f′ ⊏ f and unique minimal (uniquely escaping) sequential algorithms g_{i1} : B_{i1} : o → B_{i1}, … g_{ib_{i}} : o → B_{ib_{i}} such that

f = ⟨π_{l}, π_{i} × ⟨g_{i1}, …, g_{ib_{i}}⟩; App⟩; f′.

Proof: Suppose f = s(pa)(pab), where pa is a path in A_{i}, and so b is an (oddlength) path in some B_{ij} Then let f′ = s, and g_{i1} : o ⇒ B_{i1}, … g_{ij}, … g_{ib_{i}} : o ⇒ B_{ib_{i}} be the strategies manifested in pa; i.e. g_{ik} = {c(even) ∈ Occ(pa) | c ∈ P_{B_{ik}}}, for k ≠ j. Similarly g_{ij} is the uniquely factorized strategy on o ⇒ B_{ij} which is manifested in pab, with the unique escape given by the odd-length path b. Then ⟨π_{l}, π_{i} × ⟨g_{i1}, …, g_{ib_{i}}⟩; App⟩; f′ plays as f′ until the position s is reached, whereupon it plays in B_{i} as π_{i}×⟨g_{i1}, … g_{ib_{i}}⟩; App : \overline{A}×o → B_{i}. But the only pathmove in this strategy which can extend one already played, without repetition, is pa; if this is followed by the Opponent move pab, then Player escapes, otherwise he gives up. □

Using this proposition, defining a universal term for path-strategies is simply a matter of re-constructing a path from the encoding of its decomposition.

Proposition 5.3.19 (Finite Definability) There is a universal term of μPCF_{n} for the finite basis of path-strategies.

Proof: is by induction on type structure, defining a universal term U_{T}^{f} at each type for path-strategies, and using the recursive chain lemma above to give a term for general strategies. Suppose [[T]] = A_{1} ⇒ (A_{2} ⇒ … (A_{m} ⇒ o) …), where A_{i} = B_{i1} ⇒ (… (B_{in_{i}} ⇒ o) …), and that there are universal terms U_{ij} for the (partiality factorized) uniquely escaping partial sequential algorithms on each B_{ij}. The following definition of U^{f}(n) is by course-of-values recursion on n which can then be implemented in μPCF. Supposing T = S_{1} ⇒ … S_{m} ⇒ 0, then for i ≤ m, and y_{i} : S_{i} = R_{i1} ⇒ … R_{ik}, define

M_{i}(x) = y_{i} (U_{i1}(strat_{1}(last n)) x) … (U_{ik_{i}}(strat_{k}(last n)) x) : 0

and define U_{T}^{f}(n) =

λx : 0.λ\overline{y} : \overline{S}.(U_{T}^{f}(init^{2}n) (case_{m} comp(n)|_{i≤m} M_{i})) \overline{y}.

Supposing path_{T} (s(pa)(pab)) = n, then [[U_{T}^{f}(init^{2}n)]] is the path-strategy corresponding to s, and U_{ik}(strat_{k}(last n)) is the Player strategy on B_{ik} manifested in pab. So [[M_{i}]] is the strategy on B_{i} → o manifested in pab (which is chosen by the conditional) and [[U_{T}^{f}(n)]] = ⟨π_{l}, (π_{i} × ⟨[[U_{i1}(strat_{k}(last n))]], … [[U_{in_{i}}]]⟩); App⟩; [[U_{T} (init^{2}n))]]. So by the Decomposition Lemma (Proposition 5.3.18), U_{T}^{f}(n) is equal to the path strategy corresponding to pab, as required. If T = \overline{S} ⇒ nat, so [[T]] = \overline{[[S_{i}]]} ⇒ (o^{ω} ⇒ o) then define U_{f}(n) =

λx.λ\overline{y}.μα.(U_{T}^{f}(init^{2}n) (case comp(n)|_{i≤m} M_{i} |_{m+1} [α]last n)) \overline{y}

which is shown to be a universal term as above. □

Thus the Universality Theorem has been proved. Finite definability for the (effectively presented) sequential algorithms also has the following consequence.

Corollary 5.3.20 Observational equivalence for Λ(Ω), and for finitary μPCF is decidable.

5.4 Relating models of control

Although full abstraction has been established, based on a decomposition of sequential algorithms, the characterization of observational equivalence of μPCF has been left wholly implicit in this direct presentation. By considering the relationship with the initial innocent strategies model, via the functor which collapses strategies under their intrinsic preorder, a much more informative analysis can be gained. Showing that this functor is surjective amounts to a second proof of full abstraction.

‘Factoring’ the proof of full abstraction through the proof of initiality of the games model in this way separates the properties of definability, and the denotational equality of observably equivalent objects. This has the potential to allow more syntactic information to be extracted, compared with the direct version given in Section 5.3 (or Cartwright, Curien and Felleisen’s proof [16]). At the same time, this proof formalises and justifies the claim that innocent strategies are equivalent modulo duplication of queries, as the effect of the translation is to remove copies.

The Context Lemma for Λ(Ω) can be exploited to define inductively a kind of ‘intensional logical relation’ between pointed cartesian closed categories (and hence models of control).

Definition 5.4.1 Let (C, a) and (C′, a′) be pointed CCCs interpreting Λ(Ω), and define the following relation between ‘escaping’ morphisms over their type-objects, R_{T} : C(a, [[T]]) × C′(a′, [[T]]), by induction on type structure as follows:

• f R_{ι}f′ if and only if f := id_{a} and f′ = id_{a′}, or f = ⊥_{a,a} and f′ = ⊥_{a′,a′}

• f R_{S⇒T} f′ if and only if ∀x ∈ C(a, [[S]]), x′ ∈ C′(a′, [[S]]) such that x R_{S}x′, ⟨f, x⟩; App R_{T} = ⟨f′, x′⟩; App and ⟨⊥_{a,a}; f, x⟩App R_{T} = ⟨⊥_{a′,a′}; f′, x′⟩; App.

Now define R_{T} on C(1, [[T]])×C′(1, [[T]]_{C′}) by e R_{T} e′ if and only if 1_{a}; e R_{T} 1_{a′}; e′

Lemma 5.4.2 For every term t : T of Λ(Ω), [[t]]_{C} R_{T} [[t]]_{C′}, and for every two pairs of related elements, e R_{T} f, e′ Rf′ e ≡_{[[T]]} e′ and f ≡_{[[T]]} f′ if and only if e Rf′.

Proof: is by induction on type-structure, from which the first part is direct by soundness. For the second part, applying the Λ(Ω) Context Lemma, e, e′ : [[S ⇒ T]]_{C} and f, f′ : [[S ⇒ T]]_{C′} are observationally equivalent if and only if for any x : a → [[S]]_{C}, y : a → [[S]]_{C′} such that x R_{S}y, (⟨e, x⟩; App ≡ (⟨e′, x⟩; App and (⟨f, y⟩; App ≡ (⟨f′, y⟩; App. Hence by induction hypothesis, f, f′ and e, e′ are observationally equivalent if and only if for all x R_{T} y, ⟨e, x⟩; App R_{T} (⟨f′, y⟩; App, and similarly ⟨⊥; e, x⟩; App R_{T} ⟨⊥; f′, y⟩; App if and only if e R_{S⇒T} f′ as required. □

So the R-relation between the games model and itself is observational equivalence. To show full abstraction, it is sufficient to show that this relation between the games and sequential algorithms models is a surjective function (which must be a functor, as it preserves meaning), by defining it as a relation on strategies. This also neatly clarifies the relationship between dialogue games and sequential algorithms.

5.4.1 The collapse of innocent strategies

Preparatory to describing the relationship between innocent strategies and sequential algorithms, it is useful to re-examine the notion of observational equivalence. Recall the notion of an ‘escaping strategy’ which contains odd-length (maximal) sequences, corresponding to a jump into a one-move game adjoined to the context. Two such strategies on the one-move game can be distinguished; the empty strategy {ε}, and one that ‘recognises’ Opponent’s move, {ε, o}. This allows the following refinement of the characterization of observational equivalence via the following version of the Context Lemma.

Lemma 5.4.3 Given innocent (non-escaping) strategies σ, τ : A, σ ≲_{A} τ if and only if ∀ρ : \overline{B_{i}}, (escaping) ρ; σ = {ε, o} implies ρ; τ = {ε, o}.

Proof: is direct by application of Proposition 5.1.1. □

It is also important to restrict attention to observers which are definable; innocent Opponent strategies:

Definition 5.4.4 An innocent play according to an (innocent) strategy σ : A is a finite play s ∈ σ such that Opponent also plays innocently: i.e.

∀s′, t′ ⊑_{even} s, ⌞s′⌟ = ⌞t′⌟ ∧ s′a ⊑ s ⟹ t′a ⊑ s. The innocent plays in σ are denoted I(σ).

Innocent Opponent strategies are represented as Player strategies using the following observation.

Proposition 5.4.5 Let osb be an even-length justified sequence over \overline{A} ⇒ o. Then sb is a justified sequence in \overline{A} and the Opponent view of osb is the ‘lifting’ of the Player view of sb in the sense that if b ∈ M_{A_{i}}, then ⌞osb⌟ = o⌜sb↾A_{i}⌝.

Proof: is by a simple induction on the definition of view. □

Definition 5.4.6 For any non-empty innocent play s ∈ \overline{B} ⇒ o, the Opponent strategy manifested in s is represented as a player strategy τ : \overline{B}, by erasing the initial moves from all of the O-views of s. For any player strategy σ : A, the interaction of σ with the Opponent strategy τ, written as an uncovering σ∥⟨τ_{1}, τ_{2}, … τ_{n}⟩ (see Definition 3.2.7) is the maximal sequence s ∈ σ such that s↾B_{i} ∈ τ_{i}.

Opponent strategies are ordered (by inclusion, and the intrinsic preorder) by considering them as Player strategies.

Lemma 5.4.7 Given (non-escaping) σ, τ : A σ ≲_{A} τ if and only if ∀s ∈ I(σ).∃t ∈ I(τ) : O − strategy(s) = O − strategy(t).

Proof: Suppose σ ≴_{A} τ, then by the new presentation of the Context Lemma (Lemma 5.4.3), there is an (escaping) Opponent strategy ρ : \overline{B} such that ρ; σ = {ε, o} and ρ; τ = {ε}. Let s = ρ∥σ, then O − strategy(s); σ = {ε, o}, and O − strategy(s); τ = {ε}. If t is an even-length innocent play such that O − strategy(s) = O − strategy(t), then O − strategy(t); τ = {ε}, and so O − strategy(t)∥τ ≠ t, so t ∉ τ. Hence O − strategy(s) ≠ O − strategy(t) for all t ∈ I(τ). Conversely, suppose σ ≲_{A} τ, then for all s ∈ I(σ), O − strategy(s); σ = {ε, o}, and hence O − strategy(s); τ = {ε, o}. Hence O − strategy(s)∥τ is an even length sequence in τ. Moreover, it can be proved by induction on the number of O-views in s, that s ∈ I(σ) implies O − strategy(O − strategy(s)∥τ) = O − strategy(s) because: ⌞O − strategy(s)∥τ⌟ = ⌞s⌟, as this is (the lifting of) the unique odd-length view (escape) in O − strategy(s). Let s′ be the greatest even innocent prefix of s, then by inductive hypothesis, O − strategy(s′) = O − strategy(O − strategy(s′)∥τ), and hence O − strategy(s) = O − strategy(O − strategy(s)∥τ) as required. □

Corollary 5.4.8 Given (non-escaping) innocent strategies or sequential algorithms, σ, τ : A = \overline{B} ⇒ o, σ ≲_{A} τ if and only if ∀s ∈ I(σ).∃t ∈ I(τ) : O − strategy(s) ≡\overline{B} O − strategy(t)

The symmetry between Player and Opponent in sequential algorithm paths (both subject to the same non-repetitivity condition) means that the translation is welldefined only for innocent plays. The following lemma establishes that definition by induction on subsequences of innocent sequences is possible.

Lemma 5.4.9 (Projection condition for innocent plays) If s is a (finite) innocent play and a an occurrence of a move in s, then s↾a is an innocent play.

Proof: shows that in plays over arenas of the form \overline{A} ⇒ o, every thread of !A is an innocent play. (Recall from Chapter 3 (Proposition 3.3.8) that every game is in fact specified by an arena of this form.) Proof is by induction on the number of threads of !A occurring in s. Suppose s ∈ σ (an innocent player strategy). By the ‘bang lemma’, (Proposition 3.6.13), O − strategy(s) =!τ for some innocent τ′ : \overline{A}. By definability axiom ‘linearization of head occurrence’ there is a strict, innocent strategy σ′ : A ⊸ (!A ⊸ o), obtained by relabelling the first thread of !A opened by σ as a play in the new linear premise, and similarly an innocent strategy σ′′ :!A ⊸ (A ⊸ o) obtained by switching premises. Consider the uncovering of !τ; σ′ : A ⊸ o (which is innocent) played off against τ, — this is equal to the first thread opened in !A, i.e. (!τ; σ′)∥τ = (σ∥τ)↾a, which is therefore innocent. The remainder of the play, s/(s↾a) is innocent, as it is the uncovering of the composition of !τ with τ; σ′ :!A ⊸ o, which is an innocent strategy. It also contains fewer threads of !A, hence by inductive hypothesis, each thread is an innocent play. □

Definition 5.4.10 (Copy-removing translation) The translation is defined by a double induction, first on type-structure, and secondly on sequence length of (prefixes of) innocent plays. For any type T = S_{1} ⇒ (S_{2} ⇒ … (S_{n} ⇒ ι) …), assuming the translation is defined for each S_{i}, define the translation of the justified sequences of [[T]] as follows:

• ε^{T} = ε

• o^{T} = o (where o is the initial move)

• For occurrences a of non-initial moves, there is some unique move occurrence b in s which is initial in some [[S_{i}]] hereditarily justifying (or equal to) a, so let (sa)^{T} = s^{T} (sa↾b)^{S_{i}} if (sa↾b)^{S_{i}} does not occur in s^{T}, and (sa)^{T} = s^{T} otherwise.

Definition 5.4.11 This induces a map on sets of innocent plays, and hence on innocent (partial) strategies (restricted to their innocent plays): for σ : [[T]], define σ^{T} = {s^{T} | s ∈ I(σ)}.

It is clear from the definition that the translation of each justified sequence is a non-repetitive sequence starting with a move in o, followed by paths from the S_{i}. The difficult property to prove is that play alternates between Player and Opponent, — and this is clearly not the case if either fails to play innocently. Intuitively, one can argue roughly as follows: if a move has occurred previously in the translated path, then the view of the original play has occurred previously; and consequently the subsequent move is a repetition (because of innocence) so its translation is removed from the sequential algorithms path. This is, however, patently an oversimplification of the proof, as there may be whole sequences of moves repeated due to innocence.

Definition 5.4.12 For a sequential data structures path s over \overline{A} ⇒ o, define the ‘Opponent strategy’ manifested in s^{T} to be the set of even-length path moves in A, together with the most recent path-move (which may be odd, representing an escape). i.e. O − strategy(s) = \{p ∈ Occ(s)↾\overline{B}) | Even(p)\} ∪ \{s↾b_{i}^{S_{i}}\}.

Proposition 5.4.13 (The translation is well-defined) The following hold for translated sequences and strategies.

i The Opponent strategy manifested in s^{T} is a well-defined sequential algorithm such that O − strategy(s^{T}) = O − strategy(s)\overline{B}.

ii If sa^{T} (odd-length) extends s^{T}, then s is innocent.

iii If s is (even/odd)-length then s^{T} is an (even/odd)-length sequential-algorithms path.

iv For any innocent strategies σ, τ : A, σ ≲_{T} τ if and only if σ^{T} ⊆ τ^{T}.

v For any innocent strategy σ : A, σ^{T} is a sequential algorithm.

Proof: is by joint induction over type-depth (first) and sequence length (second). i Suppose p ∈ O − strategy(s^{T}), then (p = t↾b_{i})^{S_{i}}, for some t ⊑ s,

and t↾b_{i} ∈ O − strategy(s) by definition (note that O − strategy is a welldefined sequential algorithm by (v)).

ii If sa^{T} extends s^{T}, then (sa↾b_{i})^{S_{i}} is an even-length path in S_{i} distinct from all previous paths, and the Opponent sequential algorithm manifested in sa^{T} is not equal to the Opponent sequential algorithm manifested in s^{T}, and by (iv), the Opponent strategy manifested in sa is distinct from the Opponent strategy manifested in s. Hence ⌜s↾b_{i}⌝ must be distinct from every previous Opponent view, and so s is innocent (⌞s⌟ is new) as required.

iii If s is an (odd/even-length) innocent play then s^{T} is an (odd/even-length play) As noted above, s^{T} is non-repetitive, and consists of well-defined path-moves by induction hypothesis. Suppose s is odd-length and innocent, then every thread of !\overline{B} in s is innocent and even-length by the innocence Lemma 5.4.9 above. Hence there are equal numbers of (non-initial) Player and Opponent moves in s^{T}, as each thread translates to an even-length path move. Since every Opponent path-move extends a Player path-move, the most recent path-move has been made by Opponent. By (ii), the play preceding this most recent extension is innocent and even-length, hence by induction hypothesis, its translation is an even-length path. Suppose s is even-length and innocent. The threads of !\overline{B} in s are all innocent, and even-length, except the current one, which innocent and oddlength, by Lemma 5.4.9. So the translations of the other threads are all even-length path-moves, the translation of the current thread is an oddlength path-move. The most recent path-move in s^{T} is Player’s. (Suppose the most recent move is Opponent’s; then the play preceding this extension is innocent and even length, giving a contradiction). Hence there are equal numbers of (non-initial) Player and Opponent moves in the initial segment of s^{T}. The penultimate move must be an Opponent path-move (extending the translation of an innocent even-length play by ii) which translates to an even-length path by induction hypothesis.

iv σ ≲_{[[T]]} τ if and only if σ^{T} ⊆ τ^{T}.

This is shown using Lemma 5.4.7 and Corollary 5.4.8, and (iv) as induction hypothesis. Suppose σ^{T} ⊆ τ^{B}, then for all s ∈ σ, there exists t ∈ τ such that s^{T} = t^{T}, and hence by (iv), O − strategy(s) ≡ O − strategy(t), so by Lemma 5.4.7, σ ⊑_{Λ(Ω)}^{OBS} τ. Suppose σ ≲_{[[T]]} τ; then by the observational equivalence Lemma 5.4.7, for every s ∈ σ, there exists t ∈ τ such that O − strategy(s) ≡ O − strategy(t), and hence O − strategy(s^{T}) = O − strategy(t^{T}). So σ^{T} ⊆ τ^{T} as required.

v To prove that the translation of an innocent strategy is a sequential algorithm, it remains to show that the translations of sa, tb ∈ σ are evenly branching. The induction step is to show that if s^{T} = t^{T}, then sa^{T} = tb^{T}. s^{T} = t^{T} implies O − strategy(s) ≡ O − strategy(t) by (iv), and this implies P − strategy(sa) = P − strategy(tb). (Suppose P − strategy(s) ≠ P − strategy(t), then w.l.og. there is some Player-view in s not occurring in t, and this can be used to escape from s and distinguish O − strategy(s) from O − strategy(t).)

□

Example 5.4.14 Recall Example 5.2.8, comparing a play in the innocent strategy denoted by λf.f (f 0) to paths in the sequential algorithms denotation. As expected, the former translates to one of the latter, depending on the Opponent strategy manifested in the innocent play. This can be seen by observing that the effect of the translation can be ‘simplified in this case to the following map on innocent plays in [[(nat ⇒ nat) ⇒ nat]]: (sa)^{⋆} = s^{⋆}, if there are some pevious moves b, c such that b hereditarily justifies a, and sa↾b = sa↾c, (sa)^{⋆} = s^{⋆}a, otherwise.

Hence any repetition of the initial question ‘What is the value of f?’, and/or the succeeding Opponent move (which it justifies); ‘What is the value of the argument to f?’, will be removed. In the case that f 0 = 0, the repeated supplying of zero as the argument to f is removed, as is Opponent’s next move, which, by innnocence, must be a repetition of the ‘answer’ zero as well.

5.4.2 Mapping sequential algorithms to innocent strategies

The relation R can now be shown to be a surjective function, by defining an innocent strategy from a sequential algorithm, which is in its pre-image with respect to R. Hence this produces a unique representative for each equivalence class of the intrinsic preorder on G.

It is presented in the form of a translation from sequential data structure paths to justified sequences which maps each sequential algorithm to a strategy which ‘collapses’ to that algorithm by the translation described above. The result of this operation is not unique, nor is it functorial, but it does provide a unique representative, a ‘normal form’, for each equivalence classes of strategies, which can be obtained by ‘collapsing’ to a sequential algorithm, and then ‘fluffing up’ to an innocent strategy.

Definition 5.4.15 (Copy saturating translation) This is defined as a translation from sequential algorithm paths to justified, well-opened sequences (which are innocent plays), by a double induction over type structure, and over sequence length, following a similar pattern to the copy-removing translation. The translation of a path t over A is written t_{T}. Assuming [[T]] ≅ (Π_{i≤n}[[S_{i}]]) ⇒ o for some S_{1}, S_{2}, …, S_{n}.

• ε_{T} = ε

• o_{T} = o (where o is the unique initial move).

• If s is non-empty, and of even length, and hence of the form t(pa), for some (odd-length) path pa in some S_{i}, then (t(pa))_{T} = t_{T} · (pa)_{S_{i}}. The justifier of the first move in (pa)_{S_{i}} is the first move in t, an as pa_{S_{i}}

[figure: (ℕ; ℕ); ℕ; (ℕ; ℕ); ℕ; O_{q}; O_{q}; P_{q}; P_{q}; O_{q}; O_{q}; P_{q}; O_{q}; P_{0}; P_{0}; O_{n}; O_{n}; P_{n}; P_{n}; O_{m}; O_{m}; P_{m}; P_{m}]

Figure 5.5: Copy-removing translation applied to λf.f f 0 (Opponent represents a function s.t f 0 ≠ 0). is well-opened, all of its other moves are justified by occurrences of moves already in pa_{S_{i}}.

• if s is of odd length (and longer than a single move), it is of the form t(pa)(pab), where pa is a path in some S_{i}, and pab extends it. Then (t(pa)(pab))_{T} = t_{T} · (pab)_{S_{i}}, with the justification pointers given as above.

Figure 5.6: Translation from sequential algorithm to innocent strategy

Proposition 5.4.16 The following two facts can be proved directly from the definition of the translation:

• s_{T} ∈ [[T]]: the translation of an (even/odd -length) path in [[T]]_{S} is an alternating (even/odd - length) sequence in [[T]]_{G} satisfying visibility.

• (s_{T})^{T} = s: removing the copies from a translated path returns the original path.

Proof: is by induction following the pattern set by the definition of the translation:

• Suppose s = t(pa)(pab), then by hypothesis, t_{T} is an odd-length, alternating sequence satisfying visibility, and pab_{S_{i}} is an even-length alternating sequence satisfying visibility starting with an initial player move in S_{i} (justified by the initial, visible move). Hence t_{T} ·pab_{S_{i}} is odd-length, alternating, and satisfies visibility. (And similarly for t_{T} · pa_{S_{i}}).

• proof is by induction that for an innocent play r and sequential algorithms path s, if r ⊑ s_{T}, then r^{T} ⊑ s, and if s_{T} ⊑ r, then s ⊑ r^{T}. Hence s = (s_{T})^{T}. Suppose r ⊑ ((t(pa)(pab))_{T}), then either r ⊑ t_{T}, so r^{T} ⊑ t, or r = t_{T} · u, where u ⊑ pab_{S_{i}}. Then by hypothesis, t ⊑ r^{T}, and for every prefix of u′ ⊑ u, u^{′T} ⊑ pab_{S_{i}} hence r^{T} is the extension of t by pa or pab (or the empty sequence). Suppose ((t(pa)(pab))_{T}) ⊑ rc, then either t(pa)(pab))_{T}) ⊑ r or rc↾d = pab_{S_{i}}, where d is the initial move of S_{i} hereditarily justififying c, and hence (rc↾ d)^{S_{i}} = pab by induction hypothesis, and t(pa) = r^{T}, hence rc^{T} = t(pa)(pab) as required.

□

Definition 5.4.17 For a sequential algorithm χ : [[T]], define

χ_{T} = {⌜t⌝ | t_{T} ∈ χ}.

Example 5.4.18 Continuing the theme of Examples 5.2.8 and 5.4.14, consider the translation of the sequential algorithm denoted by λf.f (f 0). The translation on paths over [[(nat ⇒ nat) ⇒ nat]]_{S} can be simplified to the following: (s(pa)(pab))^{(⋆} = s^{⋆}pab, where pa, pab are path-moves in [[nat ⇒ nat]], and sa^{⋆} = s^{⋆}a, otherwise.

Applying this to the sequential algorithm denoted by of λf.f f 0 yields an innocent strategy which is not the denotation of λf.f f 0. (See Figure 5.4.18.) This strategy first tests f for strictness, returning its constant value if it is not strict. Otherwise it tests f0, and returns 0 if this is a fixedpoint of f. Otherwise it applies f to the value obtained from f0 and returns that. This strategy corresponds to the following term of PCF with catch and infinitary case statements:

case (catchf) |_{0} (case (f 0) |_{0} 0 |_{i≠0}(f i)) |_{j≠0} j − 1.

It is also possible to verify that applying the copy-removing translation to this strategy yields the sequential algorithm corresponding to both λf.f f 0 and the above term.

Proposition 5.4.19 For any sequential algorithm χ, χ_{T} is an innocent function over A.

Proof: Arguing informally, suppose t(pa)pab is a sequential algorithms path, so (t(pa)(pab))_{T} = t_{T} · pab_{S_{i}}. Under an inductive assumption, t_{T} and pab_{S_{i}} are both innocent paths, so it is easy to see that Player plays innocently, as he can always ‘see’ the last move in t_{T}. Opponent plays innocently, because he plays the same in p_{S_{i}} as when it appeared before, whilst a must be new, by the ‘no repetition’ condition, so Opponent has a new view at this point, and safely play a new move of his own. Formally, the proof proceeds by verifying inductively the following hypotheses.

(i) If s ⊑ u then s_{T} ⊑ u_{T}.

(ii) If u_{T} (odd) ⊑ r ⊑ s_{T} (odd), then ⌜u_{T} ⌝ ⊑ ⌜r⌝ ⊑ ⌜s_{T} ⌝.

(iii) If u ⋢ s then ⌜u_{T} ⌝ ⋢ ⌜s_{T} ⌝ (and ⌞u_{T} ⌟ ≠ ⌞s_{T} ⌟. The content of (ii,iii) is that Player has access via the view to the entire history of the (translation of) the sequential algorithms play.

(iv) Player plays innocently in s_{T}, i.e. if ra, r′ ⊑ s_{T} such that ⌜r⌝ = ⌜r′⌝ then r′b ⊑ s_{T}.

(v) If s and u branch at an odd (Opponent) move, then s_{T} , u_{T} are coherent with respect to innocence; i.e. if s_{T} ⊓ u_{T} is odd and ra ⊑ s_{T} and r′b ⊑ u_{T} such that ⌜r⌝ = ⌜r′⌝ then a = b.

(vi) Opponent plays innocently in s_{T}, i.e. if ra, r′ ⊑ s_{T} such that ⌞r⌟ = ⌞r′⌟ then r′b ⊑ s_{T}.

[figure: (ℕ; ℕ); ℕ; (ℕ; ℕ); ℕ; O_{q}; O_{q}; P_{q}; P_{q}; O_{q}; O_{q}; P_{q}; O_{q}; P_{0}; P_{0}; O_{n+1}; O_{n+1}; P_{q}; O_{q}; P_{n+1}; P_{n+1}; O_{m}; O_{m}; P_{m}; P_{m}]

Figure 5.7: Copy saturating translation of λf.f f 0

The base cases are are straightforward. On the assumption that (i) − (vi) hold for t_{T} and for (pab)_{S_{i}}, it is shown below that they hold for (t(pa)(pab))_{T} = t_{T} · (pa)_{S_{i}}. The proofs that they hold for (t(pa))_{T} are in all cases similar.

(i)s ⊑ u ⟹ s_{T} ⊑ u_{T} If r ⊑ t(pa)(pab), then either r ⊑ t (in which case r_{T} ⊑ t_{T} ⊑ t_{T} · (pa)_{S_{i}} by induction hypothesis), or r = t(pa)(pab), so r_{T} = (t(pa)(pab))_{T}, or r = t(pa), so r_{T} = t_{T} · (pa)_{S_{i}}, pa_{S_{i}} ⊑ pab_{S_{i}} by induction hypothesis, therefore r_{T} ⊑ (t(pa)(pab))_{T} as required.

(ii)u_{T} (odd) ⊑ r(odd) ⊑ s_{T} ⟹ ⌜u_{T} ⌝ ⊑ ⌜r⌝ ⊑ ⌜s_{T} ⌝ Suppose r ⊑_{odd} t_{T} ·(pab)_{S_{i}} = s_{T}. If r ⊑ t then the induction hypothesis applies to give the result directly. So suppose r = t_{T} · v, for some v ⊑ pab_{S_{i}}. Then the initial (Player) move in S_{i} justifying all of the moves in v must occur in ⌜r⌝, so ⌜r⌝ = ⌜t_{T} ⌝ · ⌞v⌟, and the induction hypothesis applies giving ⌜u_{T} ⌝ ⊑ ⌜t_{T} ⌝ ⊑ ⌜r⌝, and ⌞v⌟ ⊑ ⌞pab_{S_{i}}⌟, so ⌜r⌝ ⊑ ⌜s_{T} ⌝ as required. Note in particular that ⌜(t(pab))_{T} ⌝ = ⌜t⌝ · ⌞pab_{S_{i}}⌟.

(iii) If s(odd) ⋢ s′(odd) then ⌜s_{T} ⌝ ⋢ ⌜s′_{T} ⌝ (and similarly s′(even) ⋢ s′(even) ⟹ ⌞s_{T} ⌟ ⋢ ⌞s′_{T} ⌟) Suppose t(pa)(pab) ⋢ s′, then either t ⋢ s′ and by hypothesis ⌜t_{T} ⌝ ⋢ ⌜⌝s′_{T}, and by (ii), ⌜t_{T} ⌝ ⊆ ⌜s_{T} ⌝ ⋢ s′_{T} as required. or s′ = tqc(qcd) for some qcd such that pab ⋢ qcd As remarked above, ⌜(t(pa)(pab))_{T} ⌝ = ⌜t_{T} ⌝⌞pab_{S_{i}}⌟, and ⌜(t(qc)(qcd))_{T} ⌝ = ⌜t_{T} ⌝⌞qcd_{B_{j}}⌟. By inductive hypothesis, ⌞pab_{S_{i}}⌟ ≠ ⌞qcd_{B_{j}}⌟, and so ⌜(t(pa)(pab))_{T} ⌝ ⋢ ⌜(t(qc)(qcd))_{T} ⌝, as required.

(iv) By the inductive hypothesis (vi), that t_{T} and (pab)_{S_{i}} are innocent, Player plays innocently in s_{T}: Suppose rc ⊑_{even} r′ ⊑_{odd} t_{T} · (pab)_{S_{i}}, and ⌜r⌝ = ⌜r′⌝, If r′ ⊑_{odd} t_{T}, then r′c ⊑_{even} t_{T} ⊑ t_{T} · (pab)_{S_{i}} by innocence of t_{T}. If rc ⊑_{even} t_{T}, but r′ ⋢_{odd} t_{T}, then r′ = t_{T} q, for some q ⊑_{even} (pab)_{S_{i}} and so ⌜r′⌝ = ⌜t_{T} ⌝⌞q⌟. But since t_{T} is innocent ⌜t_{T} ⌝ is not the view of any prefix of t_{T}, and so neither is ⌜t_{T} ⌝⌞q⌟, so ⌜r⌝ ≠ ⌜r′⌝, a contradiction. If rc ⋢_{even} t_{T}, then r = t_{T} · u, for some u ⊆_{even} (pab)_{S_{i}} and r′ = t_{T} · u′, for some u′ ⊆_{even} (pab)_{S_{i}}. ⌜r⌝ = ⌜t_{T} ⌝⌞u⌟, and ⌜r′⌝ = ⌜t_{T} ⌝⌞u′⌟. So if ⌜r⌝ = ⌜r′⌝, then ⌞u⌟ = ⌞u′⌟, and as (pab)_{S_{i}} is innocent by hypothesis, and um ⊑_{odd} (pab)_{S_{i}}, r′c ⊑_{even} t_{T} · (pab)_{S_{i}}, as required.

(v)Evenly branching paths map to coherent plays If r ⊑_{odd} s_{T}, r′ ⊑_{odd} s′_{T}, and r′ ⋢ s_{T}, where s′ ⊓ s is even, then ⌜r⌝ ≠ ⌜r′⌝, — so there is no possibility of a violation of innocence. Let u = s′ ⊓ s so there is an Opponent move c such that uc_{T} ⊑ r but uc_{T} ⋢ r′ Then by (ii,iii) ⌜uc_{T} ⌝ ⊑ ⌜s_{T} ⌝, but ⌜uc_{T} ⌝ ⋢ r′ so ⌜r′⌝ ⋢ ⌜s_{T} ⌝, and ⌜r⌝ ⊑ s_{T}, hence ⌜r⌝ ≠ ⌜r′⌝ as required.

(vi) Opponent plays innocently in s_{T} = t_{T} (pab)_{S_{i}} By inductive hypotheses (iv) and (vi), t_{T} and pab_{S_{i}} are innocent plays, so the case to consider is r, r′ ⊑^{even} s_{T} such that r ⊑ t_{T}, and r′ ⋢ t_{T}, but ⌞r⌟ = ⌞r′⌟. So r′ = t_{T} · u′, for some u′ ⊑_{even} pab_{S_{i}} ⌞t_{T} · u′⌟ = m⌜u′⌝, thus r = v_{T} · u, for some paths v in A, and u ⊑ (qcd)_{S_{i}}, where qcd in S_{i} is such that v(qc)(qcd) ⊑ t, and ⌜u⌝ = ⌜u′⌝. If qcd ⊑ pab then u ⊑ (pab)_{S_{i}}, and by the inductive hypothesis (v) Player (i.e. whoever makes even moves) plays innocently in S_{i}, thus if um ⊑ pab_{S_{i}} then u′m ⊑ pab_{S_{i}}, and rm ⊑ (t(pa)(pab))_{T} implies r′m ⊑ (t(pa)(pab))_{T} as required. If qcd ⋢ pab, then they branch at an even move, as plays in !_{S}S_{i} are nonrepetitive (and this is the only point at this fact is used). Thus by hypothesis (v), they are coherent with respect to innocence, thus ⌜u⌝ = ⌜u′⌝ and um ⊑ qcd implies u′m ⊑ pab, and so rm ⊑ (t(pa)(pab))_{T} implies r′m ⊑ (t(pa)(pab))_{T} as required.

Finally, note that item (v) above entails that χ_{T} is an innocent function as required. □

Proposition 5.4.20 For every sequential algorithm χ : [[T]]_{S}, χ_{T} R_{T} χ , and for each innocent strategy σ : [[T]]_{G}, σ R_{T} σ^{T}.

Proof: is by induction on type-structure: suppose T = \overline{S} ⇒ ι. Given an Opponent sequential algorithm ψ : [[\overline{S}]]_{S}, (χ∥ψ)_{\overline{S}⇒ι} = χ_{\overline{S}⇒ι}∥ψ\overline{S}, hence ψ; χ ↓ if and only if ψ_{T}; χ_{T} ↓ Since every innocent strategy is observationally equivalent to some ψ_{T}, by hypothesis, it follows that χ_{T} Rχ. Secondly, ((σ^{T})_{T})^{T} = σ^{T}, hence σ ≡ σ_{T}^{T}, and (σ^{T})_{T} R_{T} σ^{T}, hence σ R_{T} σ^{T} as required. □

Corollary 5.4.21 The initial functor from the games to the sequential algorithms model is surjective.

Corollary 5.4.22 The semantics of Λ(Ω) in the CCC of Sequential Algorithms generated from freely generated from o is fully abstract, hence the models of control for μPCF given by (S, o) are fully abstract.

Corollary 5.4.23 The extensional collapse of the standard call-by-name PCF model in the category of unbracketed games is isomorphic to the strongly stable model.

Proof: is as a corollary of Ehrhard’s proof [24] that the extensional collapse of the sequential algorithms model of PCF is isomorphic to the strongly stable model. The extensional collapse can be found by identifying the extensional elements of the semantics, and an extensional equivalence ≡ on them as follows. All objects at ground type are extensional, and equivalence is the identity relation. f : A ⇒ B is extensional if for all extensional a, a′ : A, such that a ≡_{A} a′, fa ≡_{B} fa′. f ≡_{A⇒B} f′ if for all extensional a : A, fa ≡_{B} f′a. Considering the extensional collapse of the PCF type-structure of games it is clear that σ ≡_{T} τ implies σ ≅ τ. Thus, by a trivial induction, σ is extensional if and only if σ^{T} is, and σ is extensionally equivalent to τ if and only if σ^{T} is extensionally equivalent to τ^{T}. Hence composing the functor collapsing innocent strategies into sequential algorithms (restricted to extensional objects) with Ehrhard’s functor projecting (extensional) sequential algorithms to strongly stable functions, yields a projection from the extensional innocent strategies onto sequential algorithms, and this is injective on extensional equivalence classes (see Figure 5.1). □

This gives a partial answer to the question: — what are the extensional functions which are computed in models of control? but leaves another: — which are the extensional morphisms which compute them? Longley [55] has shown that there is an extensional functional H, programmable with either control (call-with-current-continuation) or state (ML-style references), such that the strongly stable model of PCF+H is fully abstract. Although unbracketed games are by no means a unique way to ‘realize’ these realizably sequential functions, the richness of their structure, as expressed by the intensional hierarchy, together with the fact that they allow a connection to be made with the fully abstract model of PCF on the one hand, and the reduction to the simply-typed λ-calculus via cps translation on the other, indicates that they may be an informative place to study it.

The translation to sequential algorithms has confirmed the claim that each innocent strategy is intensionally equivalent to one which does not duplicate queries.

But in fact it gives a stronger characterization of the intrinsic equivalence: composing with the translation back to innocent strategies yields a unique strategy for each equivalence class (as described for the denotation of λf.f (f 0) in Example 5.4.18). Moreover, this uniqueness is easy to capture as a notion of ‘normal form’.

Proposition 5.4.24 Let s ∈ [[T]] be an innocent play. Then s is the translation of a sequential algorithms path if and only if for any move b in s, the hereditary subsequence s↾b satisfies the following criteria

No interleaving of threads s↾b is a contiguous subsequence of s,

No repetition of threads There is no previous occurrence b′ of the same move in s, justified by the same move, such that s↾b = s↾b′,

No overextension of threads Suppose s↾b = tcd. Then there is some previous occurence b′ of b in s, justififed by the same move, such that s↾b′ = t.

Proof: is straightforward by induction, using the definition of the translations to show that:

• all translated paths have the above properties,

• if s has the above properties, then (s^{T})_{T} = s so s is a translated path.

□

Open questions raised by this observation are:

• What are the evaluation trees corresponding to the normal forms for strategies?

• What is the syntactic translation from terms to their normal forms corresponding to the semantic translation?

• Is there simple axiomatization (or schematization) of the complete theory of (finitary) observational equivalence extending βη-equivalence?

Conclusions

This thesis has presented and studied a semantics of sequential control which is simple, tractable, and above all, accurate. Rather than identifying a definitive notion of control flow, the analysis has been implicit, drawing together some more-or-less diverse elements which have a control thread running through them; continuation-passing, the bracketing condition of games semantics, λμ, and sequential algorithms. That control can be identified within this variety of formalisms confirms its ubiquity in sequential computation. That its fully abstract models are effectively presentable and universal supports a claim which is one of the main themes of ‘intensional semantics’, that behaviour, modelled through a combination of process and domain-theoretic ideas, can be as mathematically well-behaved as static sets and extensional functions. That control flow can be subject to different constraints itself, and can be combined with other computational features, means that no single fully abstract model can amount to a general account of control; identifying it with the bracketing condition within the intensional hierarchy, however, does have the making of such an account.

What then are the main limitations of this analysis, and how might they be rectified? Most significantly, the description of control (in particular, the categorical treatment) has been quite indirect. It has been shown that it is possible to reason about control accurately using continuation passing translation into the λcalculus, but the usefulness of this observation has not been demonstrated, and is questionable, given the complexity of the translation. However, the consolidation of ideas represented by the fully abstract model is a step forward, and should be a useful setting to test and apply new work on control. A categorical understanding of control which is not more general than continuation passing translation, but is conceptually clearer is emerging, based on the work of [82]. Work by Levy [52] on a game semantics for continuation passing has the potential to make the connection between these ideas and intensional semantics clearer.

The study of games has been limited by the rather ad hoc nature of the framework on which it is based; hopefully it will in future be possible to prove results about dynamic behaviour (for instance, factorization) in a truly natural, clear and concise way. This thesis has attempted small steps towards this goal, — ground-breaking work by Abramsky on a more general notion of ‘concurrent game’ promises further progress. It should be remembered that one of the advantages of the axiomatic treatment of definability is that it should aid the transfer of both results and intuitions about control to such new settings.

The games semantics of control described here misses the point in another way; it fails to fully exploit their dynamicity. By contrast to the case of state, the games models of control are instances of a general categorical construction (cps), and it is not clear how much has been gained directly by giving game semantic instances. To some extent, this is due to the existence of a simple, general, notion of model of control (which is a good thing) by contrast to, say, Idealized Algol, and in any case the potential of a game semantics of control is still great. But to fully justify the use of games it will be necessary to go beyond merely constructing fully abstract models of control, and redeeem some of the promises made below.

6.1 Further Directions

The scope of the thesis has also been naturally limited by constraints of time and space to a single notion of control based on static bindings, in a simple functional setting. This leaves many avenues for further research.

Local versus non-local control flow The way in which data flows through programs is clearly crucial to understanding their behaviour, and the results which they generate. ‘Control flow analysis’ is about more than the locality or otherwise of control, although this is an important aspect of it — not least because programs which can access the flow of control can use this to distinguish between different inputs. The way in which control flow is made explicit in game semantics has been exploited by Malacaria and Hankin’s ‘flowchart’ analysis of dataflow in a simple imperative language [58] — this could be extended with control operators, but there are further possibilities. Another significant area of research is the analysis of locality of variables in imperative languages like Idealized Algol; — identifying expressions which can have side-effects on the store by using a distinction between active and passive types. The use of a rule (well-bracketing) to model locality of control in game semantics suggests that side-effects on the flow of control could also be governed by a typing distinction between activity and passivity. The connection between the bracketing condition and linearity suggests how this might be done with linear logic. Integrating the two kinds of behaviour, in order to reason about state and control will then be a real challenge!

Dynamically Bound Control features The most obvious gap in the description of control operators in this thesis, is that little has been said about those which create dynamic bindings, such as the exception-handling mechanism of Standard ML. An elegant general treatment of these operators can be found in the work by Gunter, Remy and Riecke on prompts [33], which have the expressive power of exceptions and call/cc. Unlike the case of call/cc, there are at present no general or denotational models of these features; this leaves real scope for the application of game theoretic ideas. Work by this author on a semantics of exceptions has been based on the intensional hierarchy, modelling the dynamic bindings by dropping innocence and visibility (and regaining them via factorization).

Recursive and Polymorphic Types If control flow in realistic functional languages is to be studied, it will be necessary to take account of their more elaborate typing systems. Games semantics for both recursive [59] and polymorphic [42] types have been considered, but the addition of control raises new problems. A semantics based simply on cartesian closure, a single answer object, and recursive types should be sufficient to define models of untyped control operators, such as Scheme’s original call/cc, via continuation passing translation, though it is not clear whether it would be useful to factor this via a translation into a language (‘μFPC’) with control operators and recursive types. An interesting case is Felleisen’s original 𝒞-operator, which is not fettered by typing restrictions, and hence is very expressive. This seems to be an instance where control in games cannot be understood via the bracketing condition, but by a very large choice of ‘answer object’; it seems that the language (untyped) λC can be given a fully abstract semantics by solving the domain equation D = ((D ⇒ D) ⇒ D).

Towards a semantics of standard ML After combining the above ideas with work on the game semantics of state and higher-type references, active and passive types and so on, the goal of a fully abstract semantics for a realistic language such as standard ML (or Java) begins to look distinctly achievable.

Of course, many issues remain to be resolved, — not least the interaction of control with the other features.

Classical Logic The (extended) Curry-Howard correspondence seems to be an incomplete way of understanding control and classical logic; there are important issues in control which do not arise in logic, and vice-versa. Nonetheless, the interpretation of λμ described here could form the basis of a semantics of classical natural deduction suited to a useful analysis of constructive classical logic. In particular, the bracketing condition allows strategies (proofs) with intuitionistic behaviour to be distinguished from classical ones within the same system, and the notion of cut-elimination as interaction between strategies means that there is a notion of ‘information flow’ through proofs which can be tapped, to extract constructive content. Such a semantics could exploit a full completeness principle; a bijective correspondence between cut-free classical proofs and strategies. However, a large part of the interest (and complexity) of classical logic lies in its behaviour under cut-elimination. To capture this requires an even closer correspondence between syntax and semantics; non-confluence of classical cut-elimination is a well-known obstacle to such an understanding. Various possibilities for making classical proofs more semantically tractable have been discussed, including the ‘disambiguation’ of cuts by labelling them in some way, which can be described as various forms of ‘decorating’ of proofs with exponentials in linear logic [22]. Here, perhaps, the link with control can be reforged; it should also be possible to exploit the call-by-name/call-by-value duality of control models (and their linear analysis), to model the duality of classical cuts.

Bibliography

[1] S. Abramsky. Axioms for full abstraction and full completeness. In Essays in Honour of Robin Milner. MIT Press, to appear.

[2] S. Abramsky and G. McCusker. Linearity Sharing and state: a fully abstract game semantics for Idealized Algol with active expressions. In P.W. O’Hearn and R. Tennent, editors, Algol-like languages. Birkhauser, 1997.

[3] S. Abramsky and G. McCusker. Call-by-value games. In Proceedings of the eleventh international workshop in Computer Science Logic, CSL ’97, LNCS, pages 1–17. Springer-Verlag, 1998.

[4] S. Abramsky, K. Honda, G. McCusker. A fully abstract games semantics for general references. In Proceedings of the 14th annual Symposium on Logic In Computer Science, LICS ’98, 1998.

[5] S. Abramsky, R. Jagadeesan. Games and full completeness for multiplicative linear logic. Journal of Symbolic Logic, 59:543–574, 1994.

[6] S. Abramsky, R. Jagadeesan and P. Malacaria. Full abstraction for PCF. Accepted for publication in Information and Computation, 1996.

[7] P. Baillot, V. Danos, T. Ehrhard, L. Regnier. AJM games are a model of classical linear logic. In Proceedings of the twelfth International Symposium on Logic In Computer Science, LICS ‘97, 1997.

[8] H. P. Barendregt. The Lambda Calculus, its Syntax and Semantics, revised edition. North-Holland, 1984.

[9] G. Berry and P.-L. Curien. Sequential algorithms on concrete data structures. Theoretical Computer Science, 20:265–321, 1982.

[10] G. Berry, P.-L. Curien and J.-J. Levy. Full abstraction for sequential langauges: the state of the art. In M. Nivat, and J. Reynolds, editor, Algebraic Semantics, pages 89–132. Cambridge University Press, 1986.

[11] G. Bierman. What is a categorical model of intuitionistic linear logic. In Proceedings of the Second International Conference on Typed Lambda Calculus, number 902 in LNCS, 1995.

[12] G. Bierman. A computational interpretation of the λμ-calculus. Technical Report 448, Cambridge University Computer Laboratory, 1998.

[13] A. Blass. A game semantics for linear logic. Annals of Pure and Applied logic, 56:183 – 220, 1992.

[14] T. Braüner. A simple adequate categorical model for PCF. In Proceedings of Third International Conference on Typed Lambda Calculi and Applications, Nancy, France, number 1210 in LNCS. Springer Verlag, 1997.

[15] R. Cartwright, M. Felleisen. Observable sequentiality and full abstraction. Technical Report 91 - 167, Rice University Department of Computer Science, 1991.

[16] R. Cartwright, P.-L. Curien and M. Felleisen. Fully abstract semantics for observably sequential languages. Information and Computation, 1994.

[17] W. Clinger and J. Rees, eds. The revised^{4} report on the algorithmic language Scheme. ACM Lisp pointers IV, July–September 1991, 1991.

[18] P.-L. Curien. Categorical combinators, sequential algorithms and functional programming. Progress in Theoretical Computer science series. Birkhauser, 1993.

[19] P.-L. Curien. On the symmetry of sequentiality. In Mathematical Foundations of Computer Science, number 802 in LNCS. Springer, 1993.

[20] P.-L. Curien and H. Herbelin. Computing with abstract Böhm trees, 1996. manuscript.

[21] V. Danos, H. Herbelin and L. Regnier. Games semantics and abstract machines. In Proceedings of the eleventh International Symposium on Logic In Computer Science, LICS ‘96, 1996.

[22] V. Danos, J.-B. Joinet and H. Schellinx. A new deconstructive logic, linear logic, 1996.

[23] P. de Groote. On the relation between the λμ-calculus and the syntactic theory of sequential control. In Proc. 5th International Conference on Logic Programming and automated reasoning - LPAR’94, number 802 in LNCS, pages 31–43. Springer-Verlag, 1994.

[24] T. Ehrhard. Projecting sequential algorithms on strongly stable functions. Annals of Pure and Applied Logic, 77, 1996.

[25] M. Felleisen, R. Hieb. The revised report on the syntactic theories of sequential control and state. Theoretical Computer Science, 103:235–271, 1992.

[26] W. Felscher. Dialogues as a foundation for intuitionistic logic. In D. Gabbay, and F. Guenthener, editor, Handbook of Philosophical Logic, Vol III, pages 341 –372. D. Reidel Publishing Company, 1986.

[27] A. Filinski. Controlling Effects. PhD thesis, School of Computer Science, Carnegie Mellon University, 1996.

[28] C. Führmann. Relating two models of continuations. Submitted for publication, 1998.

[29] J.-Y. Girard. Linear logic. Theoretical Computer Science, 50, 1987.

[30] J.-Y. Girard. Towards a geometry of interaction. In Categories in Computer Science and Logic, volume 92 of Contemporary Mathematics, 1989.

[31] J.-Y. Girard. On the unity of logic. Annals of Pure and Applied Logic, 59:201–217, 1993.

[32] T. Griffin. A formulae-as-types notion of control. In Proc. ACM Conference on the Principles of Programming Languages. ACM Press, 1990.

[33] C. Gunter, D. Remy, and J. Riecke. A generalization of exceptions and control in ML like languages. In Proceedings of the ACM conference on Functional Programming and Computer Architecture, pages 12–23, 1995.

[34] R. Harmer. AJM games, self equivalence & non-determinism. In Proceedings of the Fourth Workshop of the Theory and Formal Methods Group, Department of Computing, Imperial College London, 1998.

[35] R. Harper, B. Duba and D. MacQueen. Typing first-class continuations in ML. Journal of Functional Programming, 3:465–484, October 1993.

[36] J. Hatcliff, O. Danvy. A generic account of continuation passing style. In ACM Symposium on Principles of Programming Languages, pages 458–471, 1994.

[37] C. T. Haynes, D.P. Friedman, and M. Wand. Obtaining coroutines from continuations. Journal of Computer Languages, 11:143–153, 1986.

[38] H. Herbelin. Games and weak-head reduction for classical PCF. In Proceedings of TLCA ‘97, 1998.

[39] M. Hofmann. Sound and complete axiomatisation of call-by-value control operators. Math. Struct. in Comp. Sci., 5:461–482, 1995.

[40] M. Hofmann and T. Streicher. Continuation models are universal for the λμ-calculus. In Proceedings of the twelfth International Symposium on Logic In Computer Science, LICS ‘97, 1997.

[41] K. Honda and N. Yoshida. Game theoretic analysis of call-by-value computation. In Proceedings of 24th International Colloquium on Automata, Languages and Programming, volume 1256 of Lecture Notes in Computer Science. Springer-Verlag, 1997.

[42] D. Hughes. Games and definability for system F. In Proceedings of the twelfth international syposium on Logic in Computer Science, LICS ’97. IEEE press, 1997.

[43] J. M. E. Hyland and C.-H. L. Ong. On full abstraction for PCF: I, II and III. to appear, 1995.

[44] A. Jung, and A. Stoughton. Studying the fully abstract model of PCF within its continuous function model. In Proceedings of the International Conference on Typed Lambda Calculi and Applications, volume 664 of LNCS, 1993.

[45] G. Kahn, and G. Plotkin. Concrete domains. Theoretical Computer Science, Böhm Festschrift special issue, 1993. First appeared as technical report 338 of INRIA-LABORIA, 1978.

[46] R. Kanneganti, R. Cartwright, M.Felleisen. SPCF: its model, calculus and computational power. In Semantics: Foundations and Applications. Workshop of REX 92, number 666 in LNCS, 1992.

[47] R. B. Kieburtz, B. Agapiev and J. Hook. Three monads for continuations. Technical Report CS/E 92-018, Oregon Graduate institute of Science and technology, 1992.

[48] J. Laird. Full abstraction for functional languages with control. In Proceedings of the twelfth International Symposium on Logic In Computer Science, LICS ‘97, 1997.

[49] J. Lambek, and P. J. Scott. Introduction to Higher Order Categorical Logic. Number 7 in Cambridge Studies in Advanced Mathematics. Cambridge University Press, 1986.

[50] P. Landin. A generalization of jumps and labels. Technical report, UNI-VAC Systems Programming Research, 1965.

[51] S. Mac Lane. Categories for the working mathematician. Springer–Verlag, 1971.

[52] P. Levy. Games semantics as continuation passing. Available from http://www.dcs.qmw.ac.uk/ pbl, 1998.

[53] R. Loader. An algorithm for the minimal model. draft, 1997.

[54] R. Loader. Finitary PCF is undecidable. Manuscript, 1997. To appear in Theoretical Computer Science.

[55] J. Longley. The sequentially realizable functionals. Technical Report ECS-LFCS-98-402, LFCS, Univ. of Edinburgh, 1998.

[56] J. Longley and G. Plotkin. Logical full abstraction and PCF. In Proceedings of the Tblisi Symposium on Language, Logic and Computation. SiLLI/CSLI, 1996.

[57] P. Lorenzen. Normative Logic and Ethics. Mannheim: Zurich: Bibliographisches Institut, 1969.

[58] P. Malacaria and C. Hankin. Generalised flowcharts and games. In Proceedings of the 25^{th} International Colloquium on Automata, Langugages and Programming, 1998.

[59] G. McCusker. Games and full abstraction for a functional metalanguage with recursive types. PhD thesis, Imperial College London, 1996.

[60] R. Milner. Processes:a mathematical model. In Logic Colloquium ‘73, pages 157–173. North–Holland, 1975.

[61] R. Milner. Fully abstract models of typed lambda-calculi. Theoretical Computer Science, 4:1–22, 1977.

[62] E. Moggi. Computational lambda-calculus and monads. Technical Report ECS-LFCS-88-66, University of Edinburgh Department of Computer Science, 1988.

[63] E. Moggi. An abstract view of programming languages. Technical Report ECS-LFCS-90-113, University of Edinburgh Department of Computer Science, 1990.

[64] E. Moggi. Notions of computation and monads. Information and Computation, 93(1), 1991.

[65] H. Nickau. Hereditarily sequential functionals. In Proceedings of the Symposium on Logical Foundations of Computer Science:Logic at St. Petersburg, LNCS. Springer-verlag, 1994.

[66] C.-H. L. Ong. A semantic view of classical proofs: type-theoretical, categorical, denotational characterizations. In Proceedings of 11th IEEE Symposium on Logic In Computer Science, New Jersey, 1996, pages 230–241, 1996.

[67] C.-H. L. Ong and C. Stewart. A Curry-Howard foundation for functional computation with control. In Proceedings of ACM SIGPLAN-SIGACT syposium on Principles of Programming Languages, Paris, January 1997. ACM press, 1997.

[68] V. Padovani. Decidability of all minimal models. In M. Coppo , S. Berardi, editor, Types for proofs and programs, volume 1158 of LNCS. Springer, 1996.

[69] M. Parigot. λμ calculus: an algorithmic interpretation of classical natural deduction. In Proc. International Conference on Logic Programming and Automated Reasoning, pages 190–201. Springer, 1992.

[70] G. Plotkin. Postgraduate lecture notes in advanced domain theory (incorporating the ‘Pisa notes’. Dept. of Computer Science, Univ. of Edinburgh, 1981.

[71] G. D. Plotkin. LCF considered as a programming language. Theoretical Computer Science, 5:223 – 255, 1977.

[72] G. D. Plotkin. A structural approach to operational semantics. Technical Report DAIMI FN-19, Aarhus University Computer Science Department, 1981.

[73] G.D. Plotkin. Call-by-name, call-by-value and the λ-calculus. Theoretical Computer Science, 1:125 – 159, 1975.

[74] J. Power and E. Robinson. Premonoidal categories and notions of computation. Mathematical Structures in Computer Science, 1997.

[75] D. Prawitz. Natural Deduction. Number 3 in Stockholm Studies in Philosophy. Almqvist and Wiksell, 1965.

[76] J. Reynolds. Definitional interpreters for higher-order programming languages. In Proceedings of the 25^{th} ACM National Conference, pages 717–740, 1972.

[77] J. Reynolds. The discoveries of continuations. Lisp and Symbolic Computataion, 6(3/4):223–247, 1993.

[78] D. S. Scott. A type-theoretic alternative to CUCH, ISWIM and OWHY. Theoretical Computer Science, 121:411–440, 1969.

[79] P. Selinger. Control categories: an axiomatic approach to the semantics of control in functional languages. Presented at MFPS workshop, 1998.

[80] D. Sitaram, and M. Felleisen. Reasoning with continuations II: Full abstraction for models of control. In Proc. 1990 ACM conference on LISP and functional programming, pages 161–175, 1991.

[81] T. Streicher, B. Reus. Continuation semantics: Abstract machines and control operators. Submitted to the Journal of Functional Programming, 1996.

[82] H. Thielecke. Categorical Structure of Continuation Passing Style. PhD thesis, University of Edinburgh Department of Computer Science, 1997.

Index

Δ-translation, 132 Λ(Ω)^{ω}, 115

games model, 116 ⊥-map, 15 ♢-translation, 136 λμ calculus, 98 μPCF, 102 μPCF^{−}, 102 ω-indexed products, 39 π-atomic, 77 □-translation, 116 ▲-translation, 131

answer object, 27

minimality of, 75 arena, 48 arenas

alternating, 63 as forests, 56 freely opened, 57 product and function space, 49 symmetric monoidal structure, 52 well-opened, 57

associativity

of linear strategies, 57 axioms for definability, 75

Bang Lemma, 70, 77 bracketing, 89

call-with-current-continuation, 108 call/cc, 108

definition in μPCF, 108

games interpretation, 82 cartesian product

of well-opened games, 58 case construction, 35 catch, 109 church booleans, 96 classical logic, 181 complete theory, 17 completeness

of μPCF evaluation, 112 composition of strategies, 50 computational λ-calculus

theory of, 124 Context Lemma

for μPCF, 142 Context lemma

for Λ(Ω), 141 continuation passing translation

call-by-name, 116 continuously observable, 112 contravariance axiom, 75 control categories, 30 copy-removing translation, 166 copy-saturating translation, 169 copycat strategies, 51 Curry-Howard correspondence, 97, 181

de Groote translation, 128 decomposition

of sequential algorithms, 160 definability

for μPCF_{v}, 134 for sequential algorithms model,

157 downwards continuation passing, 88

effective presentability, 43 effective presentation

of sequential algorithms, 156 empty type, 102 enabling, 48 encoding of the computable sequen-

tial algorithms, 155 equational theory

of λμ, 99 of λ_{c}, 124

errors

in μPCF, 110 escaping

uniquely, 160 escaping strategies, 159 evaluation context

strictness of, 111 evaluation contexts

μPCF, 102 of λμ, 99

evaluation contexts lemma, 125 evaluation trees

of Λ(Ω), 72 exceptions, 108 extensional collapse

of μPCF model, 175

factorization

of partiality, 158 families construction

finitely indexed, 20 Felleisen’s C

and λμ_{v}, 127 and λ_{c}, 127 first order control

in μPCF, 103 freely-adjoining, 157 Full abstraction

logical, 43 full abstraction, 8

for μPCF_{n}, 123 for μPCF_{v}, 134 of sequential algorithms model, 155

full completeness for Λ(Ω), 73

games, 53 linear, 56 symmetric monoidal closure of, 55 well-opened, 57

Hofmann & Streicher, 118

infinite lists, 116 initial functor, 73 innocent functions, 67

composition of, 69 innocent play, 164 intensional hierarchy, 9 intrinsic preorder, 17

collapse, 18

on sequential algorithms, 154

Jung and Stoughton criterion, 43 justification, 48 justified sequence, 48

hereditarily justified subsequence,

50 justified sequences

views, 66

linear exponentials, 59 linear function extensionality, 76 linearization of head occurrence, 77 logical full abstraction, 43

of sequential algorithms model, 155 logical relation

intensional, 163 Lorenzen, 48

model of control, 26 call-by-name, 29 call-by-value, 28 computational, 39 fully abstract, 37 games, 80 sequential algorithms, 153

monad, 21 models of λ_{n} and λ_{v}, 25 of continuations, 27 strong, 21 weakly bracketed sum, 85

observational equivalence, 17

in Λ(Ω), 17 occurrence, 48 operational semantics

of μPCF, 106 Opponent, 63 Opponent strategy, 165

parallel composition, 50 partial sequential category, 78 partiality factorization, 158 PCF, 34 Peirce’s law (strategy), 82 Player, 63 pointed CCC, 15

freely constructed, 16

rational category, 33 rules, 53

alternation, 63 linearity, 57 relaxation of, 54 visibility, 66 well-bracketing, 89

sequential data structure, 148 and concrete data structures, 149 co-monad, 150

SPCF, 109

and μPCF, 110 stack discipline

and bracketing, 93 standard datatypes, 111 strategies, 63

composition of, 50

copycat, 51 deterministic, 65 innocent, 67

strict morphisms, 15 strategies, 75 strictly linear, 89 syntax of control complete, 32

tensor-not category, 30

translation

innocent strategies to sequential

algorithms, 166 sequential algorithms to innocent

strategies, 169

unbracketed game, 67

uncovering, 50

uniformity of threads, 77 uniquely escaping, 160 universal term, 155 universality, 43

of sequential algorithms model, 155 upwards continuation passing, 85 views

Player and Opponent, 66 visibility, 66 weak co-product, 23 well bracketed, 89 Y combinator, 35