1 Game semantics and definability
Thus we begin to develop a semantic taxonomy of constraints on strategies mirroring the presence or absence of various kinds of computational features.
[Abramsky and McCusker, 1996]
A denotational semantics models a programming language by translating it into a mathematical semantic domain. This approach was pioneered by Scott and Strachey , motivated by reasoning about program and compiler correctness. For mathematical and philosophical reasons it makes sense to define this translation function compositionally from the structure of the language syntax. This translation function will not be, except in the most trivial cases, an injection since the same semantic concept can have multiple syntactic representations. This is part of the challenge and attraction of understanding languages. On the other hand, also for mathematical and philosophical reasons, it is preferable if the translation function is a surjection, meaning that every semantic concept has a syntactic representation, as pointed out by Lawvere . Informally speaking, this simply means that there is no ‘junk’ in the semantics or, conversely, that there are no missing elements in the syntax. This property is called definability.
There are other, more basic, requirements that a denotational semantics must meet. It must be sound, meaning essentially that distinct syntactic entities are not wrongly identified (for example true and false, or 1 and 0), and it must be adequate meaning that terminating and non-terminating programs are not mistakenly identified. Definability, soundness, and adequacy together establish that the translation is mathematically precise: it will translate all and only terms which are equivalent in the syntax into equal mathematical objects. This ideal situation is called full abstraction. And, as many ideal situations, it turns out to be difficult to achieve, primarily because of failure of definability. This was first pointed out by Plotkin  in the case of PCF, a simple yet surprisingly challenging functional language.
The failure of full abstraction indicates a mismatch between syntax and the semantic domain, which can be resolved in two ways. The first one is to enrich the syntax with the missing operations, a course of action taken in loc. cit., to wit, by adding a ‘parallel-or’ operator. If we think of syntax as mere notation for semantic concepts, which we may hold as essential, this would seem the right course of action. There is however a second way to mend the gap, by removing from the semantics those objects that have no syntactic expression. This may seem a somewhat surprising concession to the preeminence of syntax, but it is more than that. Solving full abstraction, which means solving definability, is a challenging litmus test to the power of a semantic methodology. This difficult mathematical problem, in the context of any non-trivial (and not contrived) programming language, remained open for about two decades. Hyland and Ong  give an excellent scholarly account of the quest for answering this question (Sec. 1.3, loc. cit.).
The solution to the problem of definability was brought about by game semantics. For a tutorial introduction, history and overview of the subject the reader is referred to Abramsky and McCusker , Ghica , Murawski and Tzevelekos . Of particular interest to us is the Hyland and Ong  model, which along with Abramsky et al. , is one of the original game-semantic models for PCF which achieves definability. It also introduces a style of game semantics, based on so-called pointer sequences, which proved to be very successful because of its flexibility. Using this style of game semantics, Abramsky and McCusker  gave the first fully abstract model of Reynolds ’s intensely studied functional-imperative language Idealised Algol (IA) — O’Hearn and Tennent  collects these and other key papers on the semantics this language.
The relation between PCF and IA is a very interesting one. Syntactically and operationally IA is a superset of PCF, to which it adds local state. Despite this close connection, denotational models of IA differed significantly from those of PCF in terms of their mathematical structure. It was considered essential that the structure of the semantic domain mimics the structure of the store, something that was postulated by Reynolds  as one of the basic principles of the language: “5. The language should obey a stack discipline, and its definition should make this discipline obvious.” Here ‘obvious’ means that it should be part of the domain equations. This imperative led Oles  to formulate an influential model based on functor categories. Tennent and Ghica  give a survey of the evolution of IA models.
However, since IA lives inside PCF it was likely that the full abstraction problems for the two are connected. And, indeed, the fully abstract model of IA followed shortly that of PCF. Even though the IA model is less celebrated than that for PCF, which solved a long-standing open problem of high stature, two of its features foreshadowed the coming success and dominance of the game-semantic methodology.
The first achievement of the IA model was rather technical. Part of the methodology of denotational semantics mandates that equivalent syntactic phrases are mapped into equal mathematical objects. This was achieved by Milner  using so-called term-model constructions, starting from the syntax and applying quotients. But such models do not make semantic reasoning any easier. They are a form of sweeping under the rug. Game models for PCF are not syntactic, but they use a form of quotienting which was found by some to be objectionable, although the objections were largely expressed in the form of pub conversations rather than in formal publications. Moreover, as Loader  showed soon after, term equivalence for PCF is not decidable, so it was unlikely that the semantic domain of PCF was going to consist of neat mathematical objects. The IA game model put this debate to rest by providing a language interpretation in which no quotienting is required and thus eliminating a significant, if somewhat obscure, objection to games-based models.
The second achievement of the IA model was more subtle but at the same time more consequential. The model of IA was, in some sense, as close to the model of PCF as the syntax of IA is close to that of PCF. Both are interpreted in, essentially, the same semantic domain and the difference is a mere tweak. Even though the IA game model was foreshadowed by some earlier models, such as the object model of Reddy , the similarity between it and that of PCF was striking, and it suggested that small tweaks to the game model can lead to models for diverse languages, starting from a common fundamental game model. The final paragraph of the paper (the version which appeared as a part of O’Hearn and Tennent ) states that:
Another point for further investigation is suggested by the following diagram:
Here denotes innocence and the bracketing condition […] and very successfully capture pure functional programming. As we have seen in the present paper, the category of knowing (but well bracketed) strategies captures IA. If we conversely retain innocence but weaken the bracketing condition then we get a model of PCF extended with non-local control operators. Thus we begin to develop a semantic taxonomy of constraints on strategies mirroring the presence or absence of various kinds of computational features.
The ‘innocence’ and ‘bracketing’ conditions mentioned above are the relatively small adjustments that the PCF game model requires in order to lead to full abstraction for other languages. The lattice of conditions above subsequently received new dimensions, and was dubbed a cube by Abramsky and McCusker , which was then commonly referred to as ‘Abramsky’s Cube’. Exploring the various vertices of this (hyper)cube led to the development of many interesting and useful semantic models. Even though other methods such as trace semantics also led to the development of fully abstract models for non-trivial languages [Jeffrey and Rathke, 2005] it is fair to say that ultimately game semantics became the dominant paradigm, thanks in no small part to the guidance and inspiration provided by the Abramsky Cube.
Beyond the cube, beyond definability
The methodology of game semantics was naturally guided by its history, energised by the quest for PCF definability. This meant that the first game semantic model, that of PCF, was also in some sense the most highly constrained game semantic model. Other models are then derived by relaxing some of the constraints. This is perhaps paradoxical: Why does the simplest language (PCF) have the most complicated model? This is, again, because of definability. In a simple language relatively few semantic objects are definable. The constraints on the model are intended to rule out certain objects by deeming them to be ‘illegal’. It is the remaining, legal, ones which are syntactically definable. As the language becomes richer, some of these semantic constraints can be relaxed. But this should lead to an obvious question: What if we relax all the constraints? Or, rather, what if we relax all the constraints that we can relax without making the model fall apart? What model lies at the top of the cube (or lattice, rather) of constraints. This is what the current essay will attempt to answer.
Since the game model on display here is simple, we aim for this to be a self-contained, accessible, and elementary introduction to game semantics. This presentation will be done in the style of Gabbay and Ghica  which will allow us to streamline some of the basic proofs of properties of game semantics. Arguably, the model we present here can be seen as the ur-model, at least for call-by-name programming languages. Understanding it should give an easier access ramp to the rich, diverse, and mathematically sophisticated world of game semantics.
Much of this material represents a tidying up of notes for courses taught at research summers schools, in particular the JetBrains Summer School, St. Petersburg (2016) and the Oregon Programming Languages Summer School (2018).
2 Game semantics, an interaction semantics
2.1 Arenas, plays, strategies
The terminology of game semantics guides the intuition towards the realm of game theory. Indeed, there are methodological and especially historical connections between game semantics and game theory, but they are neither direct nor immediate. The games involved are rooted in logic and reach programming languages via the Curry-Howard nexus. They are not essential for a working understanding of game semantics as a model of programming languages, so we will not describe them here. But if we were to be pushed hard to give a game-theoretic analogy, the ones to keep in mind are not the quantitative games of economics but rather last-player-wins games such as Nim.
It is more helpful to think of game semantics as an interaction, or dialogue, between two agents, rather than a game. The dialogue is between a term , i.e. a piece of programming language code, and its context , i.e. the rest of the code. By placing the term in context we create an executable program . During execution, certain interactions such as function calls and returns, or variable access, will happen. These are the interactions that are organised into a game model.
This interaction is asymmetric. One agent (P) represents the term and the other (O) represents an abstract and general context in which the term can operate.111The names stand for ‘Proponent’ and ‘Opponent’ even though there is nothing being proposed, and there is no opposition to it. The names are historical artefacts. We might as well call them ‘Popeye’ and ‘Olive’. Same applies to ‘move’, ‘play’, and ‘strategy’. The interaction consists of sequences of events called moves, which can be seen as either calls, called questions, or returns, called answers. A sequence of events, with some extra structure to be discussed later, is called a play and it corresponds to the sequence of interactions between the term and the context in one given program run. The set of all such possible plays, for all possible contexts, is called a strategy and it gives the interpretation of the term. The strategy of a term can be constructed inductively on its syntax, from basic strategies for the atomic elements and a suitable notion of composition to be discussed later.
Before we proceed, a caveat. The structure of a game semantics is dictated by the evaluation strategy of the language and its type structure. Call-by-name games are quite differently structured than call-by-value games. Hereby we shall assume a call-by-name evaluation strategy and simple type discipline of base types and functions. The reason is didactic, as these games are easier to present. Having understood game semantics in this simple setting, understanding other more complex setups should be easier.
Let us consider a most trivial example, the term consisting of the constant 0. The way this term can interact with any context is via two moves: a question () corresponding to the event interrogating the term, and an answer () corresponding to the term communicating its value to the context. The sequence is the only possible play, therefore the strategy corresponding to the set of plays is the interpretation of the term 0.
This behaviour is ‘at the interface’ in the sense that any other term evaluating to 0, such as or would exhibit the same interaction.
Let us consider a slightly less trivial example, the identity function over natural numbers . The context can call this function, but also the function will enquire about the value of its argument . Lets call these questions and . The context can answer to with some value and the term will answer to with the same value . Even though the answers carry the same value they are different moves, so we will write and to distinguish them, where then prime is a syntactic tag. Plays in the strategy interpreting the identity over natural numbers have shape . Equivalent terms such as exhibit identical interactions.
Let us now define the concepts more rigorously.
Definition 1 (Arena).
An arena is a tuple where
is a set of moves.
is a set of questions; is the set of answers.
is a set of O-moves; is the set of P-moves.
is a set of initial moves;
is an enabling relation such that if then
if and only if
An arena represents the set of moves associated with a type, along with the structure discussed above (questions, answers, O, P). Additionally, the arena introduces the concept of enabling relation, which records the fact that certain moves are causally related to other moves. Enabling requires certain preliminary conditions:
Only questions can enable other moves, which could be interpreted by the slogan ‘all computations happen because a function call’.
-moves enable -moves and vice versa. Game semantics records behaviour at the interface so any action from the context enables an action of the term, and the other way around.
There is a special class of O-questions called initial moves. These are the moves that are allowed to kick off an interaction, so do not need to be enabled.
The informal discussion above can be made more rigorous now.
Let . The arena of natural numbers is .
More complex arenas can be created using product and arrow constructs. Let
where is the co-product of the two sets of moves. We lift the notation to relations, :
Definition 3 (Arena product and arrow).
Given arenas and we construct the product arena as
and the arrow arena as
If we visualise the two arenas as DAGs, with the initial moves as sources and with the enabling relation defining the edges, then the product arena is the disjoint union of the two DAGs and the arrow arena is the grafting of the arena at the roots of the arena, but with the O-P polarities reversed.
Since arenas will be used to interpret types we can anticipate by noting that
Proposition 4 (Currying).
For any arenas the arenas and are isomorphic.
Both arena constructions correspond to the DAG below.
The isomorphism is a node-relabeling isomorphism induced by the associativity isomorphism of the co-product. ∎
We also note that
Proposition 5 (Unit).
The arena is a unit for product, i.e. for any arena , , , are isomorphic to .
The isomorphism is a re-tagging of moves.
We talked earlier about the arena for the type . Let and , where and are syntactic tags. The arena is represented by the DAG below
We already mentioned that for the identity all plays have the shape . We note that in this particular play all move occurrences are preceded by an enabling move. The move corresponding to the term returning a value can happen because the context initiated a play . The term can ask for the value of the argument also because has happened earlier. Each move occurrence is justified by an enabling move, according to , occurring earlier. The enabling relation defines the causal skeleton of the play.
Let us further consider another term in the same arena . How does this term interact with its context?
the context initiates the computation
the term asks for the value of
the contest returns some
the term asks again for the value of
the context returns some
the term returns to the context .
The reader familiar with call-by-value may be rather confused as to why the context returns first an and then an . This is because in call-by-name arguments are thunks. In some languages the thunks may contain side-effects, which means that repeat evaluations may yield different values.
Looking at the arena, this interaction corresponds to the play , where . The causal structure of this play is a little confusing. There are two occurrences of , the first one preceding both and and the second one only . It should be that the first occurrence of enables and the second enables , to reflect the proper call-and-return we might expect in a programming language. In order to do that the plays will be further instrumented with names called pointers. Each question has a symbolic address, and is paired with the address of some other move, called enabling move.. The fully instrumented play is called a pointer sequence.
Let us use for the empty sequence, for sequence concatenation, for sequence prefix () and for the sub-sequence relation (). If unambiguous we may represent concatenation simply as juxtaposition (). Let be a set of ‘names’.
Definition 7 (Pointer sequence).
Given a set , a pointer sequence is a sequence such that for all , for all , and .
We write these triples as . The addresses are just names, and the notation means that the name is ‘fresh’, i.e. not used earlier in the sequence. We sometimes write this condition as . In general we will employ the Barendregt name convention that if two names are denoted by distinct variables they are distinct . Answers never justify (in these games) so we may write their unused name as or we may omit the whole component altogether. In a pointer sequence, by a move occurrence we mean the move along with the justifier and, if it is the case, the pointer name , taken as a whole. We write for the set of pointer sequences over the moves of an arena .
Going back to the earlier example, the interaction corresponds to the following pointer sequence:
noting that is the only name without a previous binder, and is used by the initial question. If we were to represent the pointers graphically, the sequence above would be:
In general, if we draw a pointer sequence we will omit the ‘dangling’ pointers from the diagram.
The pointer sequence represents not only the actions, that is the calls and returns, but also what calls correspond to what returns and even what calls are caused by other calls. In a sequential language, for terms up to order three the pointers can be actually uniquely reconstructed from the sequence itself. Otherwise the justification pointers are necessary.
Definition 8 (Play).
A pointer sequence is said to be a play when:
for any , , there exists such that and .
if then .
Above, it is implicit that , and .
We write the set of plays of an arena as . They represent computations which are causally sensible, so that pointers are consistent with the enabling relation. The behaviour of a function that would return or ask for its argument without being itself called is, for example, not causally sensible and its corresponding interactions are thus not plays.
Let be bijections representing name permutations, and define renaming actions of a name permutation on a pointer sequence over arena as
If then , for any bijection .
The proofs are elementary. If they are also straightforward we will leave them as exercise.
A strategy in an arena is any set of plays which is prefix closed, closed under choices of pointer names (equivariant), and closed over -moves.
Definition 10 (Strategy).
A strategy over an arena is a set of plays such that for any the following properties hold:
If for some then
For any permutation , .
The conditions above have intuitive explanations. Prefix-closure is a natural condition on trace semantics, going back to Hoare ’s model of CSP and beyond, to common encodings of trees in set theory. It has a clear causal motivation in the sense that a trace semantics is a history of behaviour, and any history must be prefix-closed.
The -closure condition reflects the fact that a term has no control over which one of a range of possible next moves the context might choose to play. Finally, pointer equivariance is akin to an alpha-equivalence on plays, motivated by the fact that pointer names are not observable, so the choice of particular names in a play is immaterial. Name, equivariance and related concepts and reasoning principles are comprehensively studied by Pitts .
In this most general setting names introduced by moves are required to be fresh. In more constrained settings it can be determined that a name is no longer to be used, because any use of that name would violate the constraints. In fact most game models in the literature have this property, with the model presented here being an exception. If a name is no longer usable than it is possible to introduce a notion of ‘scope’ for that name, raising the possibility of name reuse. Gabbay et al.  give a formulation of game models where pointer names are scoped.
Note that it is equivalently possible to present strategies as a next-move function from a play to a -move (or set of -moves) along with the justification infrastructure, indicating the next move in the play. If is the power-set, then
such that for all , and , .
Let be a next-move function, and let be the smallest set such as
The set is a strategy.
The set is prefix-closed by construction. Adding all O-moves wherever legal ensures O-completeness. Equivariance holds from general principles. ∎
When we specify a next-move function, if the result is a singleton set we may simply write , and if we may omit that case from the definition.
We will sometimes define strategy directly and some other times via the next-move function, whichever is more convenient.
Given a set of plays over an arena , , let us write for the least strategy including .
We will sometimes abuse the notation above by applying it to a set of sequences of moves, in the case that the pointer structure can be unambiguously reconstructed.
In arena ,
The next-move function is
2.2 Examples of strategies
If we consider programming languages in the style of Landin , i.e. the simply-typed lambda calculus with additional operations, such additional operations can be defined in the unrestricted game model. Let us consider several examples.
Any arithmetic operator is interpreted by a strategy over the arena . Let us tag the moves of the first arena with , the moves of the second with and leave the third un-tagged (the trivial tag). Then the interpretation of the operator is in most cases
Note that in the case of division, or any other operation with undefined values, the strategy must include those cases explicitly:
Following the -answer, there is no way can continue, i.e. .
From this point of view sequencing can be seen as a degenerate operator which evaluates then forgets the first argument, then evaluates and return the second
Of course, sequencing commonly involves commands which are degenerate, single-value, data types which are constructed just like the natural numbers but using a singleton set instead of .
The flexibility of the strategic approach also gives an easy interpretation to shortcut (lazy) arithmetic operations:
This comes in handy when implementing an if-then-else operator (over natural numbers), in arena , where is the arena of Booleans, with :
These strategies are found in the original PCF model of Hyland and Ong .
A non-deterministic Boolean choice operator is interpreted by the strategy
-answers are allowed. This can be extended to probabilistic choice by adding a probability distribution over the strategy.
Note that the flexibility of the strategic approach can allow the definition of computationally problematic operations such as unbounded non-determinism ,
Nondeterministic and probabilistic game semantics have been studied by Harmer and McCusker  and Danos and Harmer , respectively. In terms of the Abramsky Cube, these games lead to definability via the relaxation of the determinism condition, which means that the strategy function can result in more than one possible move. By contrast, deterministic language strategies respond with at most one move for any given play.
In order to model state we first need to find an appropriate arena to model assignable variables. In the context of call-by-name it is particularly easy to model local (bloc) variables (, where is the variable name and the term representing the variable block). It turns out that needs not be a term-former but it can be simply a higher order language constant where is some language ground type.
The type of variables can be deconstructed following an ‘object oriented’ approach initially proposed by Reynolds . A variable must be readable and assignable . Since no other operations are applicable, we can simply define which means , , so assignment behaves like in C, returning the assigned value. We will see later how projections are uniformly interpreted by strategies.
What is interesting is the interpretation of the operation in arena . With the decomposition above in mind and for the sake of clarity we call the moves in as follows:
- Read request
- Value read
- Write request
- Value written
: for .
We define this strategy using the next-move function. The strategy will include copy-cat moves between and along with stateful moves.
If a read () move is played by O then P will respond with where is the last move it played before, which can be a read value or a written acknowledgment .
If a write move is played by O then P will always acknowledge it with .
These strategies were introduced by Abramsky and McCusker  in the game model of IA. On the Abramsky Cube these strategies relax the ‘innocence’ condition of the strategy function which states that for any play there is a smaller play computed from it, called ‘the view’ such that . In other words the term has a ‘restricted memory’ of the play in choosing the next move. This subtle condition has been studied quite by Danos and Harmer , Harmer and Laurent , Harmer et al. .
If-then-else is a very simple control operator, but more complex ones can be defined. The family of control operators is large, so let us look at a simple one, where the type is interpreted in an arena constructed just like but using instead of . The extra value indicates an error result (). Just like in the case of state, the construct can be sugared as . If is used in then the enclosing returns immediately with , otherwise it returns whatever returns.
The strategy is
Game semantics for languages with control have been initially studied by Laird . In the Cube, these strategies relax the ‘bracketing’ constraint of the PCF model, which requires questions and answers to nest like well-matched brackets.
As our final example we will consider parallel composition of commands, . In the case of this strategy, which represents a function which executes its arguments asynchronously all interleavings of the two argument executions are acceptable:
where is the set of all interleavings of two sequences.
The constraint relaxed by this strategy is the alternation of / moves, and was first studied by Ghica and Murawski .
2.3 Composing strategies
In the previous section we looked at strategies interpreting selected language constants. In order to construct an interpretation of terms, denotationally, strategies need to compose.
The intuition of composing a strategy with a strategy is to use arena as an interface on which in a first instance and will synchronise their moves.
After that, the moves of will be hidden, resulting in a strategy . In order to preserve proper justification of plays all pointers that factor through hidden moves will be ‘extended’ so that the hiding of the move will not leave them dangling. In order to define composition some ancillary operations are required.
The first one is deleting moves while extending the justification pointers over the deleted moves, in order to preserve justification [Gabbay and Ghica, 2012].
Definition 14 (Deletion).
Let be sets. For a pointer sequence we define deletion inductively as follows, where we take :
The result of a deletion is a pointer sequence along with a function which represents the chain of pointers associated with deleted moves. Informally, by we will understand the first projection applied to the resulting pair. Since deletion only removes names, it is immediate that is a well-formed pointer sequence.
If and then .
For example, the removal of the grayed-out moves in the diagrammatic representation of the play below results in a sequence with reassigned pointers:
Note that in general the deletion of an arbitrary set of moves from a play does not result in another play, since the pointers may be reassigned in a way that is not consistent with the enabling relation. There is however an important special situation:
Given arenas if then .
Since the enabling relation is a DAG, no -move enables any -move. In a play thus there can be no pointer from an -move occurrence to a -move occurrence. Therefore when the -move occurrences are deleted no pointer reassignment is required, so the result is a -play. ∎
The second operation is the selection of ‘hereditary’ sub-plays, i.e. all the moves that can be reached from an initial set of moves following the justification pointers [Gabbay and Ghica, 2012].
Definition 17 (Hereditary justification).
Let be sets. For a pointer sequence we define the hereditarily justified sequence recursively as below, where we take :
The result of a hereditary justification is a pointer sequence along with a set of names which represents the addresses of selected questions. Informally, by we will understand the first projection applied to the resulting pair. Since hereditary justification only removes names, it is immediate that is a well-formed pointer sequence.
If and then .
For example, the hereditary justification of the grey move in the diagrammatic representation of the play below results in the sequence below:
In general the hereditary justification of an arbitrary set of moves from a play does not result in another play, since it may result in a sequence that does not start with an initial move. The special situation is:
Given arenas if , with , then .
Since the enabling relation is a DAG, no -move enables any -move. In a play thus there can be no pointer from an -move occurrence to a -move occurrence. Therefore when the hereditarily justified sequence from an -initial move is selected it will result in an -play. ∎
Props. 16 and 19 are technically important, and they are consistent with the intuitive model of computation we relied on. What they say is that in a play corresponding to a function of type , the sequences associated just with the argument or just with the result are also plays. In other words, when the behaviour of a function is causally sensible, both the arguments and the body of the function are going to be causally sensible. In both cases the DAG structure of the arena is essential, since it allows no enabling from the argument back to the function body.
We now have the requisite operations to define the interaction and, finally, the composition of strategies.
Definition 20 (Interaction).
Given sets of pointer sequences their interaction is defined as
A good intuition for interaction is of two strategies synchronising their actions on the shared moves .
This definition will be used to compute the interaction of strategies and , but we will ignore the issue of tagging of moves as they participate in the definition of composite arenas, and we will just assume the underlying sets of moves are disjoint. This is not technically correct because the arenas can be equal, case in which the tagging is essential to disambiguate the co-products. But the formalisation of tagging, de-tagging and re-tagging is routine and tedious and may obscure the main points. We are sacrificing some formality for clarity.
Let denote a function that increments its argument and a function that doubles its argument, . Their interaction is a set of sequences of the form . As written below, the flow of time is top to bottom and each is lined up with the arena in which it occurs.
As defined, a strategy can interact with another strategy only once. Let denote a function that evaluates its argument twice and returns the sum of received values, and let be the strategy for constant 0. The interaction cannot proceed successfully because removing the untagged moves representing the result of leaves sequences of the shape which are not in no matter what values take.
Definition 23 (Iteration).
Given a set of pointer sequences its iteration on is the set of pointer sequences
A good intuition of iteration is a strategy interleaving its plays. The definition says that if we select moves form an identified subset and we trace the hereditarily justified plays, they are all in the original set. We can think of each as untangling the ‘thread of computation’ associated with move from the interleaved sequence.
Using interaction with the iterated strategy for 0 in Ex. 22 is now possible, so .
Note that for iteration to have the desired effect it is essential that strategies are equivariant. Consider the situation if the strategy were non-equivariant.
where are fixed. Iterated pointer sequences such as are not well formed because the second occurrence of is no longer fresh. However, because the strategy is equivariant we can choose other names when iterating, so that is legal.
Composition is iterated interaction with the synchronisation moves internalised and hidden.
Definition 25 (Composition).
Given strategies we defined their composition as .
We also use .
The definition above is the usual extensional presentation of strategy composition, which has the slight disadvantage of eliding some of the computational and operational flavour of the games-based approach. An equivalent intensional definition can be given using the strategy functions to compute the next move.
Given strategies we define their interaction function as ,
As in the case of the extensional definition, the definition is asymmetrical. Unlike the extensional definition the intensional definition makes some features of composition clearer. The first one is that the behaviour of the composite strategy in the second component () only depends on the history of the play as restricted to that component, . In other words, the strategy does not ‘see’ what is up to.
The second one is that the behaviour of the composite strategy in the first component () is restricted not only to just the history of the play in that component, but also to each ‘thread’ of the strategy , going back to some initial move .
This definition also makes it more apparent that there is an implicit nondeterminism when a move occurs in the shared arena , as both and can continue playing independently. We will see in Sec. 3.1.2 that this has some important consequences.
To arrive at composition itself we need to hide the moves in the interface arena from each .
This concludes the detour into the intensional presentation of strategy composition.
Given strategies their composition is also a strategy .
Equivariance is preserved by all operations above, from the general principles of the theory of nominal sets [Pitts, 2013].
Prefix-closure and -closure are immediate by unwinding the definitions.
It remains to show that the sequences are valid plays of . We already know the pointer sequences are well formed. The first step is to show that is a strategy in arena , which is immediate from definitions. The second step is to show that gives plays in , which is true because pointers from -moves to -moves to -moves are replaced by pointers from -moves directly to -moves. ∎
3 Game semantic models
3.1 Cartesian closed categories
In this essay we are focussing on programming languages that build on the (call-by-name) lambda calculus, so we will focus on games which can model it. Instead of relating directly the syntactic and the semantic models, it is standard to use an abstract mathematical model expressed in terms of category theory.222For the current presentation a minimal familiarity with the basic concepts of this topic is required; accessible introductions and tutorials abound (e.g. [Abramsky and Tzevelekos, 2011, Milewski, 2018]). For our language, this model is known as a Cartesian closed category [Lambek and Scott, 1988]. It is an important model, beautiful in its simplicity, deeply connected with type-theoretical and logical aspects of computations. Baez and Stay  give a fascinating account of these connections.
We will start by attempting to identify a category of games where objects are arenas and morphisms are strategies . The product of two objects is the arena product , the terminal object is the empty arena , and the exponential object is the arrow arena, .
Composition is well defined (Prop. 27), but we still need to verify its required categorical properties: associativity and the existence of an identity strategy for composition for all arenas.
We show the proof of composition in detail, for didactic reasons. The justification pointers can be an awkward mathematical structure, and the original formulation, based on numerical indices into the sequence is particularly unfortunate since any operation on indices requires re-indexing. As a consequence, the original proof of associativity is rather informal. The use of names as a representation for pointers eliminates the need for re-indexing and can allow proofs that are both rigorous and elementary. The only challenge of the proof lies in the careful unpacking of several layers of complicated definitions, but once this bureaucracy is dealt with the reasoning is obvious. Other proofs in this presentation are similarly elementary, if tedious. Avoiding these complications can be achieved, but at the cost of some significant additional mathematical sophistication [Castellan et al., 2017].
Proposition 28 (Associativity).
For any three strategies , .
Elaborating the definitions, the LHS is
There are no -moves in , so we can extend the scope of .
Elaborating the definitions, the RHS is
Eq. 3 is true because there are no C-moves in , so .
Eqn. 4 is true because distributes over concatenation.
Let is equivalent, by definition with
By elaborating the definitions:
The equivalence in Eqn. 9 holds because once we restrict to moves hereditarily justified by a C-move (), the removal of D-moves has no effect since the hereditarily justified play is restricted to arenas ABC.
Elaborating the definition yet again,
Because restricting to the hereditarily justified play of a B-move () makes the other restrictions irrelevant.
This was the more difficult case.
Composition is not only associative but also monotonic with respect to the inclusion ordering:
Proposition 29 (Monotonicity).
If then for any , and .
The proof is immediate, since all operations involved are monotonic.
The second challenge is the formulation of an appropriate notion of identity strategy for any arena. A candidate for identity is a strategy which immediately replicates -moves from to and vice versa, while preserving the pointer structures – a so-called copy-cat strategy.
Definition 30 (Copy-cat).
For any arena we defined as
Graphically, the strategy can be represented informally as:
where copies of the same arena (), initial question () or move () are indicated by using the same variable.
A copy-cat strategy has ‘the same behaviour’ in both components:
, up to a relabeling of moves.
is a strategy.
However, is, perhaps surprisingly, not a unit for composition. Consider for example and the strategy . This strategy, whereby the argument acknowledges termination after the body of the function is akin to a process-forking call. The interaction of is shown below:
The synchronisation in the shared arena and the ordering of moves in impose no particular order between the moves highlighted in the diagram (), because of the inherent nondeterminism of strategy composition. Therefore the play is in the composition but absent from the original strategy .
However, even though is not in general an identity for composition, it is idempotent, i.e. it is an identity when composed with itself.
The strategy is idempotent, that is for any arena we have that
The proof is similar to that of Prop. 36.
Identifying an idempotent morphism means that we can now construct a proper category using the so-called Karoubi envelope construction [Balmer and Schlichting, 2001].
There exists a category of games in which objects are arenas , identities at are copy-cats and morphisms are saturated strategies , where is a strategy.
We call strategies saturated because through composition with the copy-cat strategies new behaviours are added. We will discuss this further when we talk about definability (Sec. 4).
3.1.3 Cartesian closed structure
To be able to model at least call-by-name lambda calculus the category above needs to be Cartesian closed. And, indeed,
Proposition 35 (Ccc).
The category of games and saturated strategies is Cartesian closed:
- Terminal object
is the arena with no moves
- The product
of two arenas is the arena with projections ,
- The exponential
of two arenas is the arena with
- Evaluation morphism
of any strategy is the strategy where is a re-tagging of moves.
- Terminal object:
The only strategy contains the empty play since no move in is enabled.
For every object B and pair of morphisms the product of the two morphisms . The fact that is immediate because is essentially a (saturated) copy-cat which preserves and removes as none its moves are enabled.
Evaluation is a combination of copy-cat strategies, on the and components, respectively. The re-tagging defining is induced by the two isomorphic ways in which the coproduct can associate. We leave the details as an exercise to the reader.
3.2 Interpreting PCF
Prop. 35 along with Prop. 29 show that the category of saturated games is a model for call-by-name lambda calculus with recursion. For the sake of simplicity we will leave recursion aside and concentrate on the recursion-free language. The interpretation is the standard one.
Let stand for the types of PCF. Let be the base-types of the language (naturals, booleans, unit, etc.) and let be the only type-forming construct. The constants of the language are the base-type constants together with base-type operations (arithmetic and logic) and if-then-else. The other term formers are lambda-abstraction () and application (). Let us write for the free variables of a term , defined as usual.
We use typing judgments of the form , with a set of variable type assignments, . The judgment is read as “if variables have types as given by , then has type .” The judgments are checked using the following rules, expressed in natural deduction style:
The interpretation function is written as . Types are interpreted as arenas:
Variable type assignments are interpreted as products:
Terms are interpreted as strategies on arena , inductively on the (unique) derivation of the type judgment. The interpretation of the constants as strategies was already given in the preceding sections. Variables, abstraction and application are interpreted canonically using the categorical recipe:
The saturated unrestricted model described here contains many behaviours which are not syntactically definable in PCF. A simple example would be the non-deterministic coin-flip strategy (). In this section we will determine a syntactic extension for PCF which restores definability. One may think of it as an ‘axiomatisation’ of the game-semantic model.
The saturation of strategies might be worrying since it involves a loss of control over the order in which certain moves occur. Can we still have languages with sequencing or synchronisation? The property below gives a positive answer.
Proposition 36 (Synchronisation).
Let . Then, if and only if or . This also holds if .
We need to consider all combinations for and to be or moves in , and also whether they occur in or in . Because always copy-cats moves to moves, and because in this case the move occurs after the move ultimately it does not matter whether or does the copying, so for this argument it does not matter whether occur in or . Let us assume they occur in
and . When composing with the polarities of the moves in arena are reversed, , . As usual, we use to distinguish the two occurrences of arena in the composite arena . This means that is necessarily the copy-image of a move occurring earlier and will be copied into a move occurring later. Following the hiding of the arena the order of the moves and must necessarily stay the same.
and . When composing with the polarities of the moves in arena are reversed, , . This means that is necessarily the copy-image of a move occurring earlier and so is . Both these moves are -moves in arena , and they may occur in any order since accepts both orders. So after hiding the arena in composition both orders of , may be present in the composite strategy.
All other cases are similar to the previous case (2).
This Proposition gives in fact a rational reconstruction of the permutative saturation condition used in asynchronous game semantics used by Laird , Ghica and Murawski  and more broadly in semantics of asynchronous communication [Udding, 1986]. The reason that we can permute all sequences of moves in which does not justify , unless is an -move and a -move is, intuitively, that should always be able to synchronise on . This is reflected, mathematically, by the fact that the sat