Lectures onType Theory
Chapter 158
Chapter 158Optional

Definability and Full Abstraction for PCF

Prerequisites. Direct starred prerequisites: Chapter 157. No later core chapter depends on this route.

The model of chapter 157 is sound and adequate, and those two properties leave the central question open in both directions. A strategy might describe behaviour that no program performs; and two programs indistinguishable by every context might still receive different strategies. Both possibilities are real, and this chapter settles them for one exact pair of a language and a model.

Take the strategy on (o×o)o that answers tt as soon as either argument answers tt, without interrogating the other. It is deterministic, innocent and well-bracketed, so it lives in Gi. No PCF term denotes it. Take next the two terms T1:=λf.Ωι,T2:=λf.if (fΩι) then Ωι else Ωι of type (ιo)ι, where Ωι diverges. No context distinguishes them, since both diverge in every context; but their strategies differ, because [[T2]] contains the play in which the argument is interrogated and [[T1]] does not.

So the model is too small in one direction — it omits nothing, but a term cannot reach every strategy — and too large in the other. The first defect disappears once “strategy” is restricted to the compact ones; the second disappears once strategies are compared by what contexts can observe.

Observation

Definition 158.1 — Contexts and contextual approximation

A context C[] of type ι for terms of type σ in context Γ is a term of type ι in the empty context with one hole, such that C[M]:ι whenever ΓM:σ. Define ΓM  N:σifffor all such C[] and all n, C[M]n  C[N]n, and write MN when both approximations hold.

Lemma 158.2 — Context lemma

Let ΓM:σ1σkι and N likewise. Then MN if and only if for every closing substitution γ of Γ by closed terms and all closed P1:σ1,,Pk:σk, M[γ]P1Pkn  N[γ]P1Pkn.

Proof of Lemma 158.2 — Context lemma

Proof. () is immediate: the applications are particular contexts.

() Assume the right-hand condition and let C[] be a context with C[M]n. Argue by induction on the length of the evaluation. PCF evaluation is deterministic and proceeds by decomposing the term into an evaluation context and a redex (lemma 154.3 applies verbatim to the recursion-free redexes and to fix). If the hole is not in the redex position, the same decomposition applies to C[N] and the induction hypothesis finishes. If the hole is in redex position, then the occurrence of M is applied to some closed arguments P1,,Pj and the whole is in an evaluation context, so the computation reaches M[γ]P1Pj and this converges; the assumed condition supplies the same convergence for N, and the induction hypothesis applies to the remainder of the evaluation. Note that the arguments are closed because the surrounding context binds every variable of Γ at the moment the redex is reached. ◻

Proposition 158.3 — Soundness gives one half

If [[M]][[N]] then MN.

Proof of Proposition 158.3 — Soundness gives one half

Proof. The interpretation is functorial (theorem 157.11) and monotone in each argument for inclusion (lemma 157.18), so [[C[M]]][[C[N]]] for every context. If C[M]n then qn[[C[M]]] by proposition 157.20, hence qn[[C[N]]], hence C[N]n by theorem 157.21. ◻

Proposition 158.3 cannot be reversed, as T1 and T2 above show: they are contextually equivalent and their strategies are incomparable. The correct semantic comparison is not inclusion.

Definition 158.4 — Intrinsic preorder

For strategies ρ,ρ on an arena [[σ]] put ρintρiffqnαρ  qnαρ for every α:[[σ]]ι in Gi and every n. Write ρintρ when both hold, and Gi/int for the quotient, whose morphisms are the int-classes.

Lemma 158.5 — The quotient is a cartesian closed category

int is a congruence for composition, pairing and currying, and the quotient of Gi by it is cartesian closed with the induced structure.

Proof of Lemma 158.5 — The quotient is a cartesian closed category

Proof. Congruence for composition: if ρintρ and β is a strategy, then for every test α the composite αβ is again a test, so βρintβρ; and precomposition is handled by the same argument with α(γ). Pairing and currying are congruences because by proposition 157.16 currying is the identity on sets of plays, and by proposition 157.15 a test on a product factors through one summand. The cartesian closed structure descends because its equations hold already in Gi. ◻

Compact strategies and decomposition

Definition 158.6 — Compactness

A strategy ρ is compact when its view function fρ is a finite set of P-views.

Lemma 158.7 — Compact approximation

Every innocent strategy is the union of the directed set of compact innocent strategies contained in it, and the compact ones are exactly the finite elements of the dcppo of lemma 157.18.

Proof of Lemma 158.7 — Compact approximation

Proof. An innocent strategy is determined by its view function (definition 157.12), and every finite subset of a view function that is closed under even-length prefixes of views generates an innocent strategy contained in it; these form a directed family with union the whole. Finiteness in the dcppo: if ρ is compact and ρiρi with the family directed, each of the finitely many views of ρ lies in some ρi, and directedness gives a single one. Conversely a finite element is contained in the union of its compact approximations, hence equals one of them. ◻

The definability argument analyses a compact strategy by its first move. The following normal form is what makes the analysis terminate.

Definition 158.8 — η -long form of a type

Every PCF type is uniquely σ=σ1σkγ with γ{ι,o}. Write ar(σ)=k.

Lemma 158.9 — First move

Let ρ be an innocent strategy on [[σ1σkγ]], regarded as a morphism [[σ1]]××[[σk]]γ via proposition 157.16. The initial move is the question q of γ. Either ρ has no response — and then ρ= — or its response is one of:

  1. an answer c of γ, in which case fρ={qc};

  2. the initial question of some [[σi]], that is the head variable is xi.

Proof of Lemma 158.9 — First move

Proof. The initial move of an arrow arena is initial in the result arena by definition 157.3, so it is q. A P-move after q must be enabled by a move in the current P-view, which is q alone; the moves enabled by q are the answers of γ and the initial moves of the [[σi]], again by definition 157.3. In case (1) well-bracketing closes the only pending question, so no further move is legal and the view function is as displayed. ◻

Lemma 158.10 — Decomposition

Let ρ be a compact innocent well-bracketed strategy as in lemma 158.9, case (2), with first response the initial question of [[σi]], where σi=τ1τmδ. Then there are compact innocent well-bracketed strategies ρ1,,ρmon[[σ1]]××[[σk]]τj,and(ρc)c indexed by the answers c of δ, each on [[σ1]]××[[σk]]γ, all with view functions strictly smaller than fρ, such that ρ = [[case]](xiρ1ρm; (cρc)), where case is the γ-indexed conditional built from if and zero.

Proof of Lemma 158.10 — Decomposition

Proof. After q and the initial question of [[σi]], the legal O-moves are the initial questions of the [[τj]] — the argument asking for its jth input — and the answers c of δ. Innocence means ρ is determined by its behaviour on each of these branches separately. Define ρj to be the strategy whose view function consists of the views of fρ beginning with q, the question of [[σi]], and the initial question of [[τj]], with that three-move prefix replaced by the initial question of τj; and ρc similarly for the branch after the answer c, with the prefix replaced by q. Each is innocent by construction, well-bracketed because the deleted prefix opens and closes nothing, and compact because fρ is finite. Each has strictly fewer views than ρ, since the view q followed by the question of [[σi]] belongs to fρ and to none of them. The displayed equation is the statement that ρ’s behaviour on every play is recovered by dispatching on the branch, which is exactly innocence together with the case analysis of the legal O-moves. ◻

Theorem 158.11 — Definability

Every compact innocent well-bracketed strategy ρ:[[Γ]][[σ]] is [[M]] for some ΓM:σ.

Proof of Theorem 158.11 — Definability

Proof. Induction on the size of fρ, with lemma 158.9 and lemma 158.10 as the case analysis. Write σ=σ1σkγ and, using proposition 157.16, regard ρ as a morphism out of [[Γ]]×[[σ1]]××[[σk]].

If fρ=, take M:=λx.Ωγ; its strategy is by definition 157.19. If ρ answers immediately with c, take M:=λx.c. Otherwise lemma 158.10 supplies the smaller strategies; by the induction hypothesis they are [[Mj]] and [[Mc]] for terms in the extended context, and M:=λx.case (xiM1Mm) of (cMc) has [[M]]=ρ, since the interpretation of case and of application are exactly the dispatch and the question in lemma 158.10, and the interpretation is functorial. Two points require care and are the only ones where the argument is delicate. First, the case analysis over answers c of δ is infinite when δ=ι; compactness makes all but finitely many branches equal to , and the finitely many exceptions are enumerated by a nest of if-tests on equality with a numeral, definable in PCF. Second, the pointer structure must be respected: the term above reconstructs the pointer of each O-move as the occurrence of xi that asked, which is correct because a compact innocent strategy’s views determine the justifiers uniquely (lemma 157.5). ◻

Remark 158.12 — The one imported step

The proof above is complete for the fragment in which every [[σi]] has finitely many initial moves, which covers all PCF types built from o. For ι the second delicate point requires the full statement that a compact innocent well-bracketed strategy has a finite presentation of its pointer structure, which in the primary developments is a monograph-sized argument about the shape of P-views. That single statement is imported at its exact signature: for a compact innocent well-bracketed strategy on an arena interpreting a PCF type, the justifier of each move in each view is determined by the sequence of moves in that view. Nothing else is imported, and in particular no full-abstraction statement is imported.

Full abstraction

Theorem 158.13 — Inequational full abstraction

For ΓM:σ and ΓN:σ, MNif and only if[[M]]int[[N]].

Proof of Theorem 158.13 — Inequational full abstraction

Proof. () Let C[] be a context with C[M]n. The interpretation of a context is a strategy α with [[C[M]]]=α[[M]], by functoriality (theorem 157.11). By proposition 157.20 and theorem 157.21, qnα[[M]]; the hypothesis gives qnα[[N]]; and adequacy again gives C[N]n.

() Let α:[[σ]]ι and suppose qnα[[M]]. A single interaction sequence witnesses this, and it is finite, so by lemma 158.7 there are compact α0α and a compact ρ0[[M]] with qnα0ρ0. By theorem 158.11 there is a term x:σA:ι with [[A]]=α0. Take the context C[]:=A[/x], closing Γ by any closed terms. Then qn[[C[M]]] because α0ρ0[[C[M]]] and inclusion is monotone, so C[M]n by theorem 157.21. The hypothesis MN gives C[N]n, hence qnα0[[N]] by soundness, hence qnα[[N]] by monotonicity. As α and n were arbitrary, this is [[M]]int[[N]]. ◻

Corollary 158.14 — Equational full abstraction

MN if and only if [[M]]int[[N]]; equivalently, the interpretation into the quotient Gi/int of lemma 158.5 is fully abstract for PCF.

Proof of Corollary 158.14 — Equational full abstraction

Proof. Apply theorem 158.13 in both directions; the reformulation is the definition of the quotient. ◻

Corollary 158.15 — Why the quotient is needed

The uninquotiented model is not fully abstract: T1T2 for the terms of the chapter opening, while [[T1]][[T2]].

Proof of Corollary 158.15 — Why the quotient is needed

Proof. Both terms diverge in every context, since every application of either to any argument reduces to Ωι; hence T1T2 by lemma 158.2. Their strategies differ because [[T2]] contains the play in which the argument’s initial question is asked — the interpretation of fΩι asks f before diverging — and [[T1]] has empty view function beyond the initial question. ◻

Example 158.16 — A separating context read off a semantic difference

Let ρ:=[[F1]] for F1=λf.f(f0) of example 157.22, and let F3:=λf.f0 : (ιι)ι,ρ:=[[F3]]. Both strategies answer the initial question by interrogating f. They differ at the P-view q0q1q2: there ρ plays q1, a second interrogation of f, while ρ plays the literal 0.

Following the proof of theorem 158.13, take the compact test that supplies an argument answering 0 by 1 and 1 by 0; by theorem 158.11 it is denoted by a term, and unwinding lemma 158.10 that term is A:=λg.g(λy.if zero(y) then 1 else 0). Then AF10, because the inner call returns 1 and the outer call at 1 returns 0; while AF31, because the single call at 0 returns 1. The context was not guessed: it is the term denoted by the compact strategy witnessing the first difference of the two view functions.

The pair F1,F2 of example 157.22 would not serve here. Those two strategies also differ, but the terms are contextually equivalent: when f0 evaluates to 0 the two branches of F2 agree, and when it does not, F2 computes f(f0), which is what F1 computes. By theorem 158.13 their strategies are therefore int-equal while remaining distinct, which is corollary 158.15 once more.

Exercise 158.1

★★☆ Use lemma 158.2 to prove that ΩσM for every closed M:σ, and then show semantically that [[Ωσ]]= is int-least, checking the two directions of theorem 158.13 on this instance.

Exercise 158.2

★★☆ Show that the compact strategies are not closed under composition in general by exhibiting two compact strategies whose composite is not compact, or prove that no such pair exists. Then say where theorem 158.13 uses only the existence of some compact approximants and not closure.

Exercise 158.3

★★★ Let por be the strategy of the chapter opening on (o×o)o. Show that it is compact, and conclude from theorem 158.11 that it must be PCF-definable — then find the error in that conclusion by checking por against definition 157.4. State precisely which condition it violates.

Boundary and seminar

The results are lemma 158.2, theorem 158.11, theorem 158.13 and corollary 158.14, for one exact pair: the language PCF of definition 157.17 and the model Gi of corollary 157.14, compared by the intrinsic preorder of definition 158.4. Five boundaries belong to the statements.

First, definability is for compact strategies (definition 158.6); an arbitrary innocent strategy is only a directed union of denotable ones (lemma 158.7), and the union need not be denotable. Second, the model without the quotient is not fully abstract, and corollary 158.15 proves it; no statement above should be read as full abstraction for Gi itself. Third, remark 158.12 names the single imported step and its exact signature; the rest of theorem 158.11 is proved here. Fourth, all three play conditions of definition 157.4 are used: relaxing them changes which strategies exist and therefore both directions of theorem 158.13. Fifth, nothing here transfers to a language with probabilistic or nondeterministic choice: lemma 158.2 uses determinism of evaluation, definition 158.4 uses a single observation at ι, and a probabilistic language requires its own model, its own observation and its own proof.

Two independent primary developments own the definability and full-abstraction results for PCF, and they are kept separate above rather than merged: the arena-and-innocent-strategy presentation followed here, and the presentation using histories and the intrinsic quotient. The conceptual distinctions among definability, universality, full completeness and full abstraction are [Cur07]; the lecture route through finite strategies and decomposition is [Abr03]; the operational background, including the context lemma, is [Har16, Plo77]; and the historical origin of contextual observation is Morris’s thesis on the lambda calculus, retained in the chapter’s dossier for that purpose alone.

[4]

Suggested first pass.

Begin with exercise 158.4, then exercise 158.5, and finish with exercise 158.7.

Exercise 158.4

★★★ Carry out lemma 158.10 completely for a compact strategy on ((ιι)ι)ι of your choosing with at least five views: display the branches, the smaller strategies, and the term produced by theorem 158.11, and check by hand that the term’s strategy is the one you started from.

Exercise 158.5

★★★ Prove that int of definition 158.4 is a preorder and that inclusion implies it, and give two strategies that are int-equal and incomparable under inclusion. Then show that int is not equality on any arena with at least two answers, and identify the smallest such arena.

Exercise 158.6

★★★ Extend PCF by a constant por:ooo with the three evaluation rules that make it the parallel disjunction. State the play condition of definition 157.4 that must be relaxed for [[por]] to exist, and determine which steps of proposition 157.9, theorem 158.11 survive the relaxation. Do not assert a full-abstraction theorem for the extended language.

Exercise 158.7 — Practical: a definability compiler

★★★ Practical project.strategy-definability-compiler Implement the algorithm of theorem 158.11: read a compact innocent well-bracketed strategy as a finite view-function table over the arenas of definition 157.17, and emit a PCF term. The program must implement lemma 158.9 as the top-level case split and lemma 158.10 as the recursive step, and it must maintain the invariant that every recursive call receives a table with strictly fewer views, so that the recursion terminates. It must print, for each named input, the emitted term, the view function recomputed from that term by the interpreter of exercise 157.8, and whether the two tables are equal. The acceptance test is: the empty table emits a diverging term; a table answering immediately emits a constant; the table of [[F1]] from example 157.22 round-trips to an equal table; the table of [[F3]] from example 158.16 round-trips to an equal table, and applying the context A of that example to the two emitted terms evaluates to the two printed numerals 0 and 1; and a table violating innocence is rejected before compilation begins. Round-tripping finitely many tables is evidence for theorem 158.11 on those inputs; it proves neither that theorem nor theorem 158.13, and it says nothing about non-compact strategies.

Search the book

Type to search the local edition.