Lectures onType Theory
Chapter 157
Chapter 157Optional

Games, Arenas, and Strategies

Prerequisites. Direct starred prerequisites: none. Chapter 154 supplies the domain-theoretic comparison; nothing there is used as a premise. No later core chapter depends on this route.

Consider the two closed PCF terms F1:=λf.f(f0),F2:=λf.if zero(f0) then f0 else f(f0) of type (ιι)ι. In the domain model of chapter 154 their denotations are continuous functions on a domain of continuous functions, and one compares them by evaluating at arguments. That comparison records what a program returns and forgets how it asked: F1 interrogates its argument twice in sequence, while F2 interrogates it once, twice, or three times depending on the answer it receives. A denotation that is a function cannot express “asks its argument, then asks again with the received value”.

This chapter builds a semantics in which that is exactly what a denotation is. A type becomes a two-player game; a program becomes a strategy for the player who must answer; and running a program in a context becomes playing two strategies against each other.

Arenas and plays

Definition 157.1 — Arena

An arena A consists of a set MA of moves, a labelling λA:MA{O,P}×{Q,A}, and an enabling relation A(MA{})×MA, subject to:

  1. if Am then m is an O-question and nAm for no nMA; such m are initial;

  2. if mAn with m,nMA then m and n carry opposite O/P-labels;

  3. if mAn and n is an answer then m is a question.

Write λAOP and λAQA for the two components and λAOP for the exchange of O and P.

Example 157.2 — Flat arenas

The arena ι has moves {q}N, with q an initial O-question, each nN a P-answer, and qιn for every n. The arena o is the same with {tt,ff} in place of N. The arena 1 has one initial O-question and one P-answer.

Definition 157.3 — Product and arrow

For arenas A,B define A×B by MA×B:=MA+MB with the labels and enablings of the two summands, and AB by MAB:=MA+MB,λAB:=[(λAOP,λAQA), λB], AB:=B  {(m,n)mAn, mMA}  {(b,a)Bb, Aa}. So the initial moves of AB are those of B, the O/P roles in the A-component are exchanged, and an initial move of A is enabled by an initial move of B.

Definition 157.4 — Justified sequences and plays

A justified sequence over A is a finite sequence of moves in which every non-initial occurrence n carries a pointer to an earlier occurrence m with mAn. The P-view of a justified sequence is defined by pv(ε)=ε,pv(sm)=pv(s)m  (m P-move),pv(sm)=m  (m initial), pv(smtn)=pv(sm)n(n an O-move justified by m), and the O-view ov dually. A justified sequence s is a play when

  1. alternation: O- and P-moves alternate and s begins with an O-move;

  2. well-bracketing: every answer is justified by the most recent unanswered question of s;

  3. visibility: the justifier of each P-move n occurs in pv(s), where s is the prefix ending just before n, and dually for O-moves and O-views.

Write PA for the plays over A and PAe for those of even length.

Lemma 157.5 — Views are justified sequences

For every play s, pv(s) and ov(s) are justified sequences over the same arena, and every pointer of pv(s) targets a move of pv(s).

Proof of Lemma 157.5 — Views are justified sequences

Proof. Induction on s. The first clause appends a P-move whose justifier lies in pv(s) by the visibility condition. The second restarts the view at an initial move, which needs no pointer. The third appends an O-move whose justifier is m, the last move of pv(sm), so the pointer targets a retained move. No clause deletes a move that is the target of a retained pointer, since deletion occurs only in the third clause and only for the block t, whose moves are not targets of the appended pointer. ◻

Strategies, composition, and the category

Definition 157.6 — Strategy

A strategy on A is a set σPAe that is even-prefix closedsmnσ implies sσ — and deterministicsmn, smnσ implies that n and n are the same occurrence with the same pointer. A strategy on AB is regarded as a morphism AB.

Definition 157.7 — Interaction and composition

For arenas A,B,C, an interaction sequence is a justified sequence u over MA+MB+MC such that uA,BPAB, uB,CPBC and uA,C is a justified sequence over AC, where each restriction deletes the moves of the omitted component and composes pointers through deleted moves. For σ:AB and τ:BC put στ:={uuA,Bσ, uB,Cτ},τσ:={uA,Cuστ}PACe.

Lemma 157.8 — Switching

Let u be an interaction sequence. A move of B that is a P-move of uA,B is an O-move of uB,C, and conversely. Consequently the moves of u deleted by A,C occur in maximal blocks of odd length, and a block is left only by a move whose justifier lies outside B.

Proof of Lemma 157.8 — Switching

Proof. The labelling of AB exchanges O and P on the A-component, and that of BC exchanges them on the B-component; so a single B-move receives opposite labels in the two restrictions, which is the first claim. Inside a block the two strategies therefore alternate: after a B-move by one of them, the other must answer, and neither can terminate the block by playing in B. A block is left by a move outside B, which by definition 157.3 must be justified outside B. Counting from the AB side, a block begins with a P-move of σ and ends with an O-move of σ, so its length is odd. ◻

Proposition 157.9 — Composition is a strategy

For σ:AB and τ:BC, the set τσ is a strategy on AC.

Proof of Proposition 157.9 — Composition is a strategy

Proof. Plays. Deleting a B-block of odd length exchanges parity exactly once, so by lemma 157.8 the visible moves of uA,C alternate and the sequence begins with an O-move. Well-bracketing: a deleted block is itself well-bracketed, so the stack of pending questions of the visible play is unchanged across it, and a composed pointer still targets the most recent unanswered visible question. Visibility: an induction on u shows that pv(uA,C) is the image of pv(u) under deletion, using lemma 157.5; hence a justifier visible in pv(u) remains visible after deletion.

Even-prefix closure. If uA,C=smn, the prefix of u ending at the last move restricting to s is again an interaction sequence, and its two restrictions are even-length prefixes of members of σ and τ, hence members.

Determinism. Let u,uστ restrict to smn and smn, and let v be their longest common prefix. By lemma 157.8 exactly one of the two strategies is to move after v, and that strategy is deterministic, so u and u agree one move further. Iterating contradicts maximality of v unless the two restrictions coincide, whence n=n with the same pointer. ◻

Definition 157.10 — Copycat

For an arena A let idA:AA consist of the even-length plays s over AA such that every even-length prefix t satisfies t1=t2, where i selects the ith copy of A and pointers are inherited.

Proof of Theorem 157.11 — The category of games

Proof. Identity laws. Let σ:AB. In an interaction of idA with σ, whenever idA is to move it copies the last move across, so the interaction sequence is determined by σ and is exactly the image of a play of σ under duplicating A-moves. Restricting to the outer A and to B returns that play, so σidA=σ; the other unit law is symmetric.

Associativity. For σ:AB, τ:BC and υ:CD consider the sequences over MA+MB+MC+MD whose three consecutive two-component restrictions lie in σ, τ and υ. Both (υτ)σ and υ(τσ) arise from this set by deleting B and C in the two possible orders, and deletion of disjoint sets of moves commutes and composes pointers associatively. It remains to see that every element of either composite arises from a four-component sequence: given witnesses u for the outer composition and v for the inner one, they agree on the moves they share by determinism of the strategies involved, and by lemma 157.8 no move is scheduled twice, so they amalgamate. ◻

Definition 157.12 — Innocence

A strategy σ is innocent when its response depends only on the P-view: if smnσ, tσ, tmPA and pv(sm)=pv(tm), then tmnσ with the pointer of n targeting the corresponding occurrence. Its view function fσ is the set of P-views of its plays.

Proposition 157.13 — Innocence and bracketing are preserved

Copycat is innocent and well-bracketed, and if σ and τ are innocent and well-bracketed then so is τσ.

Proof of Proposition 157.13 — Innocence and bracketing are preserved

Proof. For copycat, the P-view determines the last O-move and its justifier, which is all the copying rule consults; the copied answer answers the copy of the question that was answered on the other side, so bracketing holds.

For composition, prove by induction on interaction sequences that pv(u) is obtained from pv(uA,C) by inserting at each position a B-block that is determined by fσ and fτ alone. The base case is empty; the inductive step is the case analysis of lemma 157.8, in which the strategy about to move consults only its own P-view, available by the induction hypothesis. It follows that two plays of τσ with equal P-views have equal interaction P-views and hence equal continuations, which is innocence. Well-bracketing was shown in proposition 157.9. ◻

Corollary 157.14 — Innocent subcategory

Arenas and innocent well-bracketed strategies form a subcategory Gi of G.

Proof of Corollary 157.14 — Innocent subcategory

Proof. Proposition 157.13 gives closure under composition and contains the identities; the laws are inherited from theorem 157.11. ◻

Cartesian closure

Proposition 157.15 — Products

1 is terminal in Gi, and A×B with the projections π1:=idA-copycat into the first summand and π2 dually is a product: for σ:CA and τ:CB there is a unique σ,τ:CA×B with πiσ,τ the given strategies.

Proof of Proposition 157.15 — Products

Proof. An initial move of A×B lies in exactly one summand, and by definition 157.4 every later move is hereditarily justified by it; so a play of CA×B has all its A×B-moves in one summand, and the set of such plays splits as a disjoint union. Define σ,τ to be σ on the plays whose initial move is in A and τ on those whose initial move is in B; determinism and even-prefix closure are inherited summandwise, and innocence holds because the P-view of a play determines its initial move. The two equations follow from the identity law of theorem 157.11 applied inside each summand, and uniqueness holds because the splitting is forced. Terminality of 1 is the observation that 1 nothing may be played after the unique answer, so exactly one strategy exists. ◻

Proposition 157.16 — Exponentials

For arenas A,B,C there is a bijection, natural in C, Λ: {σ:C×AB}  {σ^:C(AB)}, restricting to innocent well-bracketed strategies on both sides; hence Gi is cartesian closed with exponential AB.

Proof of Proposition 157.16 — Exponentials

Proof. The two arenas (C×A)B and C(AB) have the same moves, namely MA+MB+MC, and the same labels: on the left the O/P roles are exchanged on C and on A, and on the right they are exchanged on C and, inside AB, exchanged again on A — which is one exchange in total, the same as on the left. The enabling relations differ only in that on the right an initial move of A is enabled by an initial move of B, whereas on the left it is enabled by an initial move of B through the pairing; in both cases the hereditary justifier of every A-move is an initial B-move. Hence the two sets of justified sequences coincide, and the conditions of definition 157.4 are conditions on labels and pointers only, so the plays coincide. Take Λ to be the identity on sets of plays. It preserves determinism, prefix closure, P-views — hence innocence — and the pending-question stack — hence bracketing. Naturality in C is the statement that composition with a strategy CC is computed by the same interaction on both sides, which holds because the move sets agree. ◻

Interpreting PCF

Definition 157.17 — Interpretation of types and constants

Put [[ι]]:=ι, [[o]]:=o and [[στ]]:=[[σ]][[τ]], and interpret a context by the product of its types. A term ΓM:σ is interpreted by an innocent well-bracketed strategy [[M]]:[[Γ]][[σ]], using proposition 157.15, proposition 157.16 for variables, abstraction and application. The constants are the following view functions:

  • [[n]] answers the initial question q by n;

  • [[succ]] answers q in the result by asking q in the argument and, on receiving n, answering n+1; pred and zero are analogous;

  • [[if]] asks the first argument, and on receiving tt asks the second and copies its answer, on receiving ff asks the third and copies its answer.

Lemma 157.18 — Strategies form a pointed dcpo

For a fixed arena A, the innocent well-bracketed strategies on A ordered by inclusion form a dcppo with least element , in which directed suprema are unions; and composition is continuous in each argument.

Proof of Lemma 157.18 — Strategies form a pointed dcpo

Proof. A union of a directed family of even-prefix-closed sets is even-prefix closed. Determinism is preserved: two continuations of the same play lie in a common member of the family by directedness, hence agree. Innocence and bracketing are conditions on individual plays and on pairs of plays with equal views, and both are again settled inside a common member. Continuity of composition: an element of τ(iσi) is witnessed by a single interaction sequence, which is finite, so all the σ-plays it uses lie in one σi; the converse inclusion is monotonicity. ◻

Definition 157.19 — Recursion

For ΓM:σσ put [[fixM]]:=n0Φn() where Φ(ρ):=ev[[M]],ρ.

Proposition 157.20 — Soundness

If MN in PCF then [[M]]=[[N]].

Proof of Proposition 157.20 — Soundness

Proof. Each reduction rule is one of: a β-step, handled by proposition 157.16 together with the identity law; a constant step, handled by unfolding the view functions of definition 157.17 and observing that the two sides have the same view function; or the unfolding of fix, which holds because nΦn() is a fixed point of the continuous Φ by lemma 157.18. Compatibility with contexts is functoriality of the interpretation, which is theorem 157.11. ◻

Theorem 157.21 — Computational adequacy

Let M:ι. Then [[M]] contains the play qn if and only if Mn; and [[M]]= if and only if M diverges.

Proof of Theorem 157.21 — Computational adequacy

Proof. () is proposition 157.20 together with [[n]]={qn}, computed from definition 157.17.

() is proved by a logical relation between strategies and terms. For each type σ define a relation σ between innocent strategies on [[σ]] and closed terms of type σ:

  • ριM iff qnρ implies Mn, and similarly at o;

  • ρστM iff evρ,ρτMN whenever ρσN.

Each σ is closed under directed unions in its first argument: at ι because a play in the union lies in a member, and at higher types because ev is continuous by lemma 157.18; and σM always, again by induction on σ. The fundamental lemma states that for x1:σ1,,xk:σkM:τ and closed Ni with ρiσiNi, [[M]]ρ1,,ρk τ M[N1/x1,,Nk/xk]. It is proved by induction on M. Variables and abstraction use proposition 157.15, proposition 157.16; application is the defining clause of στ; the constants are checked directly from their view functions, the conditional using the two operational rules for if; and fix uses closure under directed unions together with σM and induction on the approximants of definition 157.19. Instantiating the fundamental lemma at a closed term of type ι gives [[M]]ιM, which is the required implication. The final claim follows: [[M]] forces some qn[[M]], since a nonempty strategy on ι contains a play of length two. ◻

Two complete strategies

Example 157.22 — The strategies of F_1 and F_2

Write the arena (ιι)ι with moves q0,n0 for the result, q1,n1 for the argument’s result, and q2,n2 for the argument’s argument. The initial move is q0, an O-question; q1 is a P-question justified by q0; q2 is an O-question justified by q1; n2 is a P-answer to q2; n1 is an O-answer to q1; and n0 is a P-answer to q0.

The view function of [[F1]] is generated by q0  q1,q0q1q2  q1,q0q1q2q1n1  n2:=n1,q0q1n1  n0:=n1, where q1 is a second occurrence of q1, justified by q0. Read aloud: asked for its result, F1 asks its argument; asked by the argument for an input, it asks the argument again; the answer to the inner call is returned as that input; and the answer to the outer call is returned as the result. The strategy is innocent because each response above depends only on the displayed P-view, and well-bracketed because each answer answers the pending question.

The view function of [[F2]] begins the same way, q0q1 and q0q1q20: the first interrogation supplies the literal 0. On receiving n1 it branches: if n1=0 it asks q1 again and supplies 0 once more, returning the second answer as n0; if n10 it asks q1, supplies as input the answer to a further call q1 with input 0, and returns the answer to q1. The two strategies differ already at the play q0 q1 q2 , after which [[F1]] plays q1 and [[F2]] plays 0.

Exercise 157.1

★☆☆ Write out the view function of idι and of idιι, and check innocence and well-bracketing directly against definition 157.12, definition 157.4.

Exercise 157.2

★★☆ Show that lemma 157.8 fails if the O/P exchange is omitted from definition 157.3: exhibit a sequence over A,B,C whose two restrictions alternate but whose B-blocks have even length, and say which step of proposition 157.9 then breaks.

Exercise 157.3

★★☆ Give a deterministic well-bracketed strategy on (ιι)ι that is not innocent, by making its second response depend on a move outside the current P-view. Explain informally which programming feature such a strategy would model, and confirm that it is excluded by corollary 157.14.

Exercise 157.4

★★☆ Compute the first three approximants Φn() of definition 157.19 for M:=λf.λx.if zero(x) then 0 else f(pred(x)), displaying each as a view function, and identify the play that first appears at stage n.

Boundary and seminar

What has been proved is that arenas and innocent well-bracketed strategies form a cartesian closed category (theorem 157.11, corollary 157.14, proposition 157.15, proposition 157.16), that PCF is interpreted soundly in it (proposition 157.20), and that the interpretation is computationally adequate at ground type (theorem 157.21).

Three things have not been proved and are not implied. No strategy has been shown to be the denotation of a term: the model may contain innocent well-bracketed strategies that no PCF program defines, and deciding that question is a separate development. No two terms have been shown indistinguishable by contexts on the basis of equal denotations, nor conversely: adequacy at ground type is one implication about one type, not a statement about contextual equivalence. And the three conditions on plays are load-bearing, not stylistic: dropping well-bracketing admits strategies modelling control operators, dropping visibility admits strategies modelling general references, and dropping determinism admits nondeterminism. Each omission changes which category is obtained and invalidates the corresponding step above — bracketing is used in proposition 157.9, visibility in lemma 157.5, and determinism in proposition 157.9 — so each requires its own proofs.

The construction follows the two independent primary developments of game models for PCF: the arena-and-innocent-strategy presentation used above, and the presentation with histories and equivalence classes of plays. The lecture-note route through arenas, plays, composition and innocence is [Abr03], the operational and contextual background is [Har16, Plo77], and the extensional comparison that motivated the chapter is the domain semantics of [AJ94] and chapter 154.

[4]

Suggested first pass.

Begin with exercise 157.5, then exercise 157.6, and finish with exercise 157.8.

Exercise 157.5

★★★ Describe, as a view function, a strategy on (o×o)o that answers tt as soon as either argument answers tt, without waiting for the other. Show that it is innocent and well-bracketed, and then show that it is not the denotation of any PCF term by exhibiting a term-level property that all denotations of definition 157.17 satisfy and this strategy does not. Do not appeal to any definability theorem.

Exercise 157.6

★★★ Complete the amalgamation step in the proof of theorem 157.11: given witnesses u and v as described there, construct the four-component sequence explicitly and verify each of its three restrictions. Identify the exact use of lemma 157.8.

Exercise 157.7

★★★ Write out the if and fix cases of the fundamental lemma in the proof of theorem 157.21 in full, including the verification that σ is closed under directed unions at function types.

Exercise 157.8 — Practical: a strategy interpreter

★★★ Practical project.arena-strategy-interpreter Implement arenas, justified sequences, plays and innocent strategies for the simply typed fragment over ι generated by definition 157.1, definition 157.3. Represent a strategy by its view function as a finite table from P-views to responses, and implement the three play conditions of definition 157.4, composition by interaction and hiding as in definition 157.7, and copycat. The invariant the program must maintain is that every sequence it accepts satisfies alternation, well-bracketing and visibility, and that every response it records is determined by the P-view alone. The program must print, for each named input, whether a proposed sequence is a play with the failing condition named if not, the interaction sequence of two strategies, and the resulting composite as a view function. The acceptance test is: the two view functions of example 157.22 are accepted, and the program reports that they differ first after the play q0q1q2; composing either with copycat returns the same table, matching theorem 157.11; a table whose response depends on a move outside the P-view is rejected as non-innocent, matching definition 157.12; and a sequence whose answer skips a pending question is rejected as not well-bracketed. A finite table interpreter is evidence on named inputs; it does not prove theorem 157.11 or theorem 157.21, and it decides nothing about strategies with infinite view functions.

Search the book

Type to search the local edition.