Lectures onType Theory
Chapter 154
Chapter 154Optional

Recursive Domain Semantics and Computational Adequacy

Prerequisites. Direct starred prerequisites: none. Chapter 12 supplies domains, continuity and least fixed points; chapter 22 supplies monads, algebraic operations and their equations. No later core chapter depends on this route.

A recursive definition denotes a least fixed point, and a nonterminating program denotes . That much is a definition, not a theorem. The theorem one wants is the converse direction: if the denotation is not , the program does something. Write Ω:=Rec(f:ιι, x:ι. fx)0,P:=Rec(f:ιι, x:ι. x)0. Both are closed terms of type ι; the first runs forever and the second returns 0. Their denotations are and η(0). Nothing proved so far excludes a third term whose denotation is η(0) but which runs forever, and if such a term existed the semantics would be useless for reasoning about programs.

With effects the question sharpens further. A computation that may print, or choose, or fail, does not merely terminate or diverge: it produces a tree of possible behaviours, and the tree may be infinite. An adequacy theorem must therefore compare the denotation of a term with the denotation of the tree the operational semantics builds — and to have such a tree at all, one must first solve a recursive domain equation.

A language with algebraic effects

Definition 154.1 — Types and terms

Fix a signature Σ of operation symbols f with arities ar(f)N; symbols of arity 0 are written a and called constants. Types are σ,τ ::= ι  o  1  σ×τ  στ, and terms are M,N ::= x0succ(M)pred(M)zero(M)ttffif M then N else LM,Npr1(M)pr2(M)λ(x:σ).MMNf(M1,,Mn)Rec(f:στ,x:σ.M), with n=ar(f) in the operation clause. Typing is the evident simply typed discipline, with Γf(M1,,Mn):σ when every ΓMi:σ, and ΓRec(f:στ,x:σ.M):στ when Γ,f:στ,x:σM:τ. Call PCFΣ the fragment without Rec and PCFΣ the whole language.

The operation symbols are the only source of effects, and an operation is not a function on values: f(M1,,Mn) offers n continuations and the semantics chooses among them.

Definition 154.2 — Values, evaluation contexts, transitions

Closed values are V ::= 0succ(V)ttffV,Vλ(x:σ).M, with n:=succn(0), and closed evaluation contexts are E ::= []succ(E)zero(E)pred(E)if E then M else NE,MV,Epri(E)EMVE. The redex transitions are zero(0)tt,zero(n+1)ff,pred(0)0,pred(n+1)n,pr1V,VV,pr2V,VV,(λ(x:σ).M)VM[V/x],if tt then M else NM,if ff then M else NN, together with the labelled redex transition f(M1,,Mn)fiMi for 1in=ar(f) and the predicate a()a for constants. These are closed under evaluation contexts: RNEREN,RfiNERfiEN,Ea()a. For PCFΣ add the redex transition Rec(f:στ,x:σ.M)λ(x:σ).M[Rec(f:στ,x:σ.M)/f].

Lemma 154.3 — Unique analysis

Every closed well-typed term is either a value, or of the form ER for a unique evaluation context E and redex R, or of the form Ea() for a unique E and constant a. Consequently a closed well-typed non-value M satisfies exactly one of: MN for a unique N; MfiNi for a unique f and determined N1,,Nar(f); or Ma for a unique a. In each case the results have the same type as M.

Proof of Lemma 154.3 — Unique analysis

Proof. Induction on the typing derivation of M. For each term former, the grammar of E contains exactly one clause with a hole in the position that the transition rules inspect, and the side conditions (V before E in V,E and VE) make the decomposition deterministic. If the inspected subterm is already a value, the term itself is a redex or a value, which is the base case; if it is not, the induction hypothesis decomposes it and the surrounding former extends the context. Type preservation is checked clause by clause: each redex transition replaces a term by one of the same type, substitution preserves typing, and the operation clause returns an argument of the same type as the whole. ◻

Effect values and the tree a program builds

For PCFΣ the tree is finite, and this is worth proving before the infinitary machinery is built.

Definition 154.4 — Finite effect values

The effect values of type σ are generated by t::=Vf(t1,,tn) with V a closed value of type σ and n=ar(f). For a closed term M with no infinite -chain, define |M|:={Mif M is a value,|N|if MN,f(|N1|,,|Nn|)if MfiNi, n=ar(f),a()if Ma.

Theorem 154.5 — Termination for the recursion-free fragment

Every closed well-typed term of PCFΣ has no infinite -chain, and every branch of its transition tree ends in a value or in a constant; hence |M| is defined.

Proof of Theorem 154.5 — Termination for the recursion-free fragment

Proof. Define computability predicates on closed terms by induction on types. A value of type ι, o or 1 is computable. A value V,V is computable when V and V are. A value λ(x:σ).M is computable when M[V/x] is computable for every computable value V:σ. A closed term is computable when every transition sequence from it terminates in a computable value or in a term Ea().

Two facts are proved simultaneously by induction on typing derivations: every closed well-typed term is computable, and every well-typed term with free variables is computable under substitution of computable values. The cases for 0, tt, and pairs are immediate. For succ, pred, zero, pri and the conditional, the induction hypothesis gives that the scrutinee’s transition sequences terminate; by lemma 154.3 the surrounding context then exposes a redex whose transition is one of the displayed clauses, and the result is again computable, in the conditional case by the induction hypothesis for the chosen branch. For application, the induction hypothesis makes the function’s sequences terminate at a computable λ(x:σ).M and the argument’s at a computable V, and computability of the abstraction gives computability of M[V/x]. For f(M1,,Mn), the term is already a redex: each labelled transition leads to some Mi, computable by hypothesis, and the branching is finite because ar(f) is. Since every branch is finite and branching is finite, König’s lemma gives that the whole tree is finite. ◻

Proposition 154.6 — Two descriptions of |M| agree

Define Mt by the rules

VV
RNENt
ERt
RfiNiENiti (in)
ERf(t1,,tn)
Ea()a().

Then for closed well-typed M and effect value t: M has no infinite -chain and |M|=t if and only if Mt.

Proof of Proposition 154.6 — Two descriptions of |M| agree

Proof. () Induction on the finite transition tree of M, whose finiteness is theorem 154.5; each clause of definition 154.4 matches one rule. () Induction on the derivation of Mt: each rule has strictly smaller subderivations for the continuations, and the second rule reduces the term, so the derivation exhibits a finite tree and the value it computes is exactly |M|. Determinacy of the first two cases is lemma 154.3. ◻

The recursive domain equation for effect trees

With Rec the transition tree can be infinite, and |M| must be an infinite tree. Infinite trees are not generated by any grammar; they are the solution of a domain equation, and this section solves it.

Definition 154.7 — Dcpos and continuity

A dcpo is a poset with least upper bounds of directed subsets; a dcppo is a dcpo with a least element . A function is continuous when it is monotone and preserves directed suprema, and strict when it preserves . We write xDy for the order. A continuous Σ-algebra is a dcppo D with a continuous fD:Dar(f)D for each fΣ; morphisms are strict continuous functions commuting with the operations.

Construction 154.8 — The tree domain

For a set X define a chain of posets T0DT1D by T0:={},Tk+1:={}X{f(t)fΣ, tiTk (iar(f))}, ordered by: least; distinct elements of X incomparable and maximal in their level; and f(t)Dg(u) iff f=g and tiDui for all i. Let ek:TkTk+1 be the inclusion and pk:Tk+1Tk the truncation replacing every subtree at depth k by . Define CTΣ(X):={(tk)kN | tkTk, pk(tk+1)=tk}, ordered componentwise.

Lemma 154.9 — Embedding–projection pairs

For each k, ek and pk are monotone, pkek=idTk and ekpkDidTk+1 pointwise.

Proof of Lemma 154.9 — Embedding–projection pairs

Proof. Monotonicity of ek is immediate. For pk, truncation is defined by recursion on depth and preserves the three order clauses. The first equation holds because truncating at depth k an element already of depth at most k changes nothing. For the inequality, truncation only replaces subtrees by , which is smaller. ◻

Theorem 154.10 — The tree domain solves its equation

CTΣ(X) is a dcppo; the map Θ: {}  X  fΣCTΣ(X)ar(f)  CTΣ(X) sending to the constantly- sequence, xX to the sequence (,x,x,), and f(u) to the sequence whose (k+1)st component is f(uk1,,ukn), is an order isomorphism onto its image and makes CTΣ(X) the free continuous Σ-algebra on X: for every continuous Σ-algebra D and every function h:XD there is a unique strict continuous Σ-homomorphism h^:CTΣ(X)D with h^η=h, where η(x):=Θ(x).

Proof of Theorem 154.10 — The tree domain solves its equation

Proof. Dcppo. A directed set of sequences has componentwise suprema, and each Tk is a finite-height poset in which every directed subset with a common shape has a supremum: two elements of Tk with an upper bound have the same head, so a directed subset is either {}-cofinal or has a common head, and the supremum is computed headwise by induction on k. Compatibility with pk is preserved by suprema because pk is monotone and, being defined by truncation, preserves the headwise suprema just described. The constantly- sequence is least.

Isomorphism. A compatible sequence (tk) has t0= and, if t1, a determined head that is either an element of X — in which case every later component is that element — or an operation symbol f, in which case the components of the n argument sequences are tk+1’s arguments and are themselves compatible. This is exactly the inverse of Θ, and both directions are monotone.

Freeness. Given h:XD define h^(t):=khk(tk) where hk:TkD is defined by h0()=, hk+1()=, hk+1(x)=h(x) and hk+1(f(t))=fD(hk(t1),,hk(tn)). Each hk is monotone and hk=hk+1ek, so the family is increasing along the sequence and the supremum exists. Strictness and preservation of the operations are read off from the clauses, and continuity holds because directed suprema in CTΣ(X) are computed componentwise and each fD is continuous. Uniqueness: a strict continuous homomorphism g with gη=h agrees with h^ on every element of finite depth by induction on that depth, and every t is the directed supremum kΘ-image of its truncations, so continuity forces g=h^. ◻

Definition 154.11 — Evaluation into the tree domain

Write MV for MV with V a value, MfiN when MLfiN for some L, Ma when MLa, and M when there is an infinite -chain from M. For a closed term M:σ define |M|CTΣ(Valσ) by its approximants |M|(0):= and |M|(k+1):={Vif MV,f(|N1|(k),,|Nn|(k))if MfiNi, n=ar(f),a()if Ma,if M.

Lemma 154.12 — | | is well defined and satisfies its equation

The four cases of definition 154.11 are exhaustive and mutually exclusive, the family (|M|(k))k is compatible, and |M|={VM=V,|N|MN,f(|N1|,,|Nn|)MfiNi,a()M=Ea(). Moreover || is the least function satisfying that equation in the pointwise order.

Proof of Lemma 154.12 — | | is well defined and satisfies its equation

Proof. Exhaustiveness and exclusivity: by lemma 154.3 the -chain from M is deterministic, so it is either infinite — the fourth case — or ends in a value, a labelled redex, or a constant, which are the first three. Compatibility: truncating |M|(k+1) at depth k gives |M|(k) by induction on k, since each clause applies the same case analysis one level down. The displayed equation is the case analysis read at the level of the whole tree, using that unlabelled steps do not change the medium-step behaviour. Leastness: let g be any solution of the displayed equation. Then |M|(k)Dg(M) for every k, by induction on k: at k=0 because is least, and at k+1 because the clause defining |M|(k+1) and the clause of the equation for g have the same head, with the induction hypothesis applied to the arguments. Hence |M|=k|M|(k)Dg(M). ◻

The denotational interpretation

Convention 154.13 — Semantic assumptions

Let C be a cartesian closed category that is Dcpo-enriched, let T be a strong monad on C whose Kleisli category CT is Dcppo-enriched with strict strength, and assume C has a natural numbers object 10NsN and the coproduct T:=1+1. For each fΣ assume a family fx:T(x)ar(f)T(x)(xC) that is algebraic: natural with respect to Kleisli maps, that is gfx=fy(g)ar(f) for every g:xT(y). Write η and () for the unit and Kleisli extension.

Definition 154.14 — Interpretation

Put [[ι]]:=N, [[o]]:=T, [[1]]:=1, [[σ×τ]]:=[[σ]]×[[τ]] and [[στ]]:=[[σ]]T[[τ]], and interpret a context by the product of its types. Terms receive [[M]]:[[Γ]]T[[σ]] by the standard call-by-value clauses, with [[f(M1,,Mn)]]:=f[[σ]][[M1]],,[[Mn]], [[if L then M else N]]:=cond[[σ]][[M]],[[N]],[[L]], where condz:T(z)2×Tz in CT corresponds to the pair of projections under the isomorphisms CT(y,z)2C(1,yz)2C(T,yz)CT(y×T,z), and with [[Rec(f:στ,x:σ.M)]]:=Y(gλT[[M]]id[[Γ]],g),Y(G):=n0Gn().

Lemma 154.15 — Values are effect-free

If V:σ is a closed value then [[V]]:1T[[σ]] factors through η[[σ]].

Proof of Lemma 154.15 — Values are effect-free

Proof. Induction on V. The constants 0, tt, ff, are interpreted by η after a map into the corresponding object. succ(V) is ηs applied to the factorization for V. A pair is the pairing of two factorizations followed by η, using that η is monoidal for the strength. An abstraction is interpreted by η after currying, since currying produces a C-map into the exponential. No clause introduces (), and fx occurs in no value. ◻

Lemma 154.16 — Equational soundness

Let the equational theory contain the β-equations of definition 154.2 read as equations, the algebraicity schema Ef(M1,,Mn)=f(EM1,,EMn), and, for PCFΣ, the unfolding equation for Rec. Then ΓMN:σ implies [[M]]=[[N]].

Proof of Lemma 154.16 — Equational soundness

Proof. Each β-equation is verified by unfolding the clauses of definition 154.14 and using the monad laws; lemma 154.15 is what makes the substitution M[V/x] correspond to precomposition rather than to a Kleisli extension. The algebraicity schema is exactly the naturality assumption of convention 154.13: interpreting an evaluation context yields a Kleisli map g, and the schema becomes gf=f(g)n. The unfolding equation holds because Y(G)=G(Y(G)) for the least fixed point of a continuous G, and G is continuous since composition and currying are continuous in the enrichment. ◻

Theorem 154.17 — Adequacy, recursion-free

For every closed well-typed M:σ of PCFΣ, [[M]]=[[|M|]], where an effect value is interpreted by the same clauses.

Proof of Theorem 154.17 — Adequacy, recursion-free

Proof. By theorem 154.5 and proposition 154.6, M|M|. An induction on that derivation, using the corresponding equations of lemma 154.16 at each rule, gives M=|M|:σ in the equational theory; and lemma 154.16 turns that into [[M]]=[[|M|]]. ◻

Adequacy with recursion

Recursion breaks the argument of theorem 154.17: there is no finite derivation of M|M| to induct on. One inequality survives; the other is obtained by approximating the recursion syntactically.

Lemma 154.18 — Interpretation of infinitary effect values

For each type σ there is a unique strict continuous Σ-homomorphism [[]]:CTΣ(Valσ)CT(1,[[σ]]) extending the interpretation of values.

Proof of Lemma 154.18 — Interpretation of infinitary effect values

Proof. CT(1,[[σ]]) is a dcppo by convention 154.13 and carries a continuous ar(f)-ary operation for each f, induced by f[[σ]]; so it is a continuous Σ-algebra. Apply the freeness clause of theorem 154.10 to h(V):=[[V]]. ◻

Lemma 154.19 — The easy inequality

For every closed M:σ of PCFΣ and every k, [[|M|(k)]]D[[M]]; hence [[|M|]]D[[M]].

Proof of Lemma 154.19 — The easy inequality

Proof. Induction on k. For k=0 the left side is . For k+1 examine the four cases of definition 154.11. If MV then MV, and each unlabelled step is an instance of an equation of lemma 154.16, so [[M]]=[[V]]. If MfiNi then likewise [[M]]=[[f(N1,,Nn)]]=f[[σ]]([[N1]],,[[Nn]]), and the induction hypothesis together with monotonicity of f[[σ]] gives the claim. If Ma then [[M]]=[[a()]]. If M the left side is . The final statement follows because [[]] is continuous by lemma 154.18 and |M|=k|M|(k). ◻

Definition 154.20 — The approximation language

Let A extend PCFΣ by constants Ωσ:σ and by Recn(f:στ,x:σ.M):στ for nN, with redex transitions Recn+1(f,x.M)λ(x:σ).M[Recn(f,x.M)/f],Rec0(f,x.M)λ(x:σ).Ωτ, and with [[Ωσ]]:= and [[Recn]] the nth approximant Gn() of definition 154.14. Define MM, for M a term of A and M a term of PCFΣ of the same type, to be the compatible closure of: ΩσM for every M:σ, and Recn(f,x.M)Rec(f,x.M) whenever MM.

Lemma 154.21 — Termination in A

Every transition sequence of a closed well-typed term of A terminates, either in a value or in a term of the form EΩτ.

Proof of Lemma 154.21 — Termination in A

Proof. Repeat the computability argument of theorem 154.5, saying now that a closed term is computable when every transition sequence from it terminates in a computable value or in a term Ea() or EΩτ. The only new cases are the two Recn clauses. For Rec0 the reduct is an abstraction whose body is Ωτ, computable because every sequence from Ωτ is already stuck in the required form. For Recn+1 the reduct is an abstraction whose body mentions Recn, computable by an inner induction on n. ◻

Lemma 154.22 — Transfer along

Let MM with M closed of type σ. Then

  1. if M is a value then so is M, and their immediate subterms are again related;

  2. if M=ER for a redex R that is not Ωτ, then M=ER with EE and RR, and RN implies RN with NN, and similarly for labelled transitions and for a.

Proof of Lemma 154.22 — Transfer along

Proof. Induction on the derivation of MM. The relation is defined by compatible closure, so a value on the left forces the same outermost former on the right except in the two base cases, and Ω is not a value. For the second clause, the grammar of evaluation contexts is the same in both languages, so the unique decomposition of lemma 154.3 on the left is matched on the right former by former. The transition clauses are checked one by one; the only interesting one is Recn+1(f,x.M)λ(x:σ).M[Recn/f], whose right-hand counterpart unfolds Rec once, and RecnRec holds by definition, so the substituted bodies remain related because is closed under substitution of related terms. ◻

Proposition 154.23 — Approximants of the tree

If MM with M closed then |M|D|M| in CTΣ(Valσ), where |M| is computed in A with |EΩτ|:=. Moreover |M|= {|M| | MM, M closed}, and the set on the right is directed.

Proof of Proposition 154.23 — Approximants of the tree

Proof. The inequality is proved by induction on the length of the terminating A-sequence supplied by lemma 154.21, using lemma 154.22 at each step: a value on the left forces the same value on the right; a stuck Ω contributes ; and a labelled step is matched, so the heads agree and the induction hypothesis applies to the arguments. Directedness: given M1,M2M, replace every Recni by Recmax(n1,n2) and every Ω by the corresponding subterm of the other approximant where it is not Ω; the result is an upper bound below M. For the supremum, it suffices to produce, for each k, an MM with |M|(k)D|M|; take M to be M with every Rec replaced by Reck, which by lemma 154.22 matches the first k levels of the transition tree. ◻

Theorem 154.24 — Adequacy for recursion

For every closed well-typed M:σ of PCFΣ, [[M]]=[[|M|]].

Proof of Theorem 154.24 — Adequacy for recursion

Proof. [[|M|]]D[[M]] is lemma 154.19. For the converse, definition 154.14 interprets each Rec by a directed supremum of its approximants, and composition, pairing, currying and () are continuous in the enrichment of convention 154.13; hence [[M]]={[[M]]MM closed}. Each M is a term of A, which is recursion-free by lemma 154.21, so theorem 154.17 applies verbatim with the extra clause [[Ωσ]]==[[|Ωσ|]] and gives [[M]]=[[|M|]]. By proposition 154.23 the family {|M|} is directed with supremum |M|, and [[]] on trees is continuous by lemma 154.18. Combining, [[M]]=MM[[M]]=MM[[|M|]]=[[MM|M|]]=[[|M|]]. ◻

Two instances, and the theorem one expected

Theorem 154.24 equates two denotations. The statement usually called adequacy compares a denotation with an observation, and it follows.

Example 154.25 — Nondeterminism

Take C=Set, T the nonempty finite powerset monad F+ with Σ={or} of arity 2 and orX binary union. Then F+(X) is the free semilattice on X, and or is algebraic in the sense of convention 154.13. Define the usual nondeterministic evaluation MnV by replacing the labelled clause with M1orM2nMi. Assigning to each finite effect value the set h(V):={V}, h(tort):=h(t)h(t), one has Mnu if and only if u=h(t) for the t with Mt.

Corollary 154.26 — Adequacy for nondeterminism

In the setting of example 154.25, for every closed term M:σ of PCFΣ, [[M]]()=MnV[[V]]().

Proof of Corollary 154.26 — Adequacy for nondeterminism

Proof. [[M]]()=[[|M|]]() by theorem 154.17. Since [[]] on effect values is the unique Σ-homomorphism and or is union, [[t]]()=Vh(t)[[V]]() by induction on t. Finally h(|M|)={VMnV} by example 154.25. ◻

Corollary 154.27 — The ground-type statement

Let σ be ι or o and let M:σ be closed in PCFΣ. In the nondeterministic instance extended with recursion, x[[M]]() if and only if M can evaluate to the value denoting x. In particular [[M]]()= if and only if every computation from M diverges.

Proof of Corollary 154.27 — The ground-type statement

Proof. At a ground type distinct values have distinct denotations and every element of the interpreting set is the denotation of exactly one value, so the Σ-homomorphism of lemma 154.18 sends a tree to the set of values labelling its leaves, with contributing nothing. Now apply theorem 154.24 and read off both directions. ◻

Exercise 154.1

★★☆ Show by an explicit counterexample that lemma 154.16 fails if the naturality requirement on fx in convention 154.13 is dropped: give a monad, an operation family that is natural in C but not with respect to Kleisli maps, and an evaluation context for which the algebraicity schema is unsound.

Exercise 154.2

★★☆ Prove that the truncation maps pk of construction 154.8 are continuous, and that CTΣ(X) with X a singleton and Σ a single unary symbol is order-isomorphic to N{} with its usual order. Which clause of theorem 154.10 does the second part illustrate?

Exercise 154.3

★★☆ Show that the inequality of lemma 154.19 can be strict before the supremum is taken, by exhibiting M and k with [[|M|(k)]] strictly below [[M]]. Then explain why no single k suffices, and locate the step of theorem 154.24 that repairs this.

Boundary and seminar

The theorem proved is theorem 154.24: the denotation of a term equals the denotation of the effect tree its operational semantics builds. Four restrictions are part of the statement and none may be dropped silently. The signature Σ is fixed and its operations are algebraic (convention 154.13); handlers, which are not algebraic, are outside the theorem. The semantic setting is fixed: a Dcpo-enriched cartesian closed category with a strong monad whose Kleisli category is Dcppo-enriched with strict strength; without strictness of the strength the interpretation of Rec is not the least fixed point computed above. The observation is fixed: corollary 154.27 is stated at ground types, and at higher types the equality of theorem 154.24 is an equality of denotations, not a statement about contexts. And the language is simply typed: nothing here concerns dependent families, whose reindexing over equality evidence is a separate construction with its own hypotheses and which donates no theorem to this chapter and receives none from it.

The proof base is Plotkin and Power’s account of adequacy for algebraic effects, whose language, effect values, tree domain, approximation language and two adequacy theorems are followed above; the domain-theoretic prerequisites are standard [AJ94], the operational background is [Har16, Plo77], and the algebraic view of effects with its equational presentations is [PP03, PP13]. The handler material in the last of these is cited for context only; no handler is interpreted here.

[4]

Suggested first pass.

Begin with exercise 154.4, then exercise 154.5, and finish with exercise 154.7.

Exercise 154.4

★★★ Instantiate convention 154.13 with C=Set and T the finite probability distribution monad, Σ containing one binary symbol choose interpreted as the fair convex combination. Verify algebraicity, define the analogue of h from example 154.25, and state and prove the analogue of corollary 154.26. Then explain why the recursion-free restriction matters for your proof and what would have to change to remove it.

Exercise 154.5

★★★ Give a strong monad on Dcpo and an operation family for which the conclusion of theorem 154.24 fails, by violating exactly one clause of convention 154.13. Identify the first step of the proof that breaks and show the resulting counterexample term.

Exercise 154.6

★★☆ Lemma 154.12 asserts that || is the least solution of its equation. Exhibit a second, strictly larger solution for a signature with one constant, and say which operational fact rules it out as a description of evaluation.

Exercise 154.7 — Practical: an effect-tree evaluator

★★★ Practical project.effect-tree-evaluator Implement, for a fixed finite signature Σ with one binary symbol and one constant, the small-step machine of definition 154.2 for PCFΣ together with the fuel-bounded computation of the approximants |M|(k) of definition 154.11. The invariant the program must maintain is that the printed tree of depth k is exactly |M|(k): every unlabelled step is silent, every labelled step branches, a stuck constant is a leaf, and exhausted fuel prints . The program must print, for each named input, the decomposition ER found at the first step, the approximant tree at a requested depth, and the finite set of value leaves. The acceptance test is: the term P of the chapter opening prints the one-leaf tree 0 at every depth k1; the term Ω prints at every depth; the term or(0,succ(0)) prints a two-leaf tree whose leaf set is {0,1}, matching corollary 154.26; and a term whose recursion is guarded by an operation prints strictly growing trees as k increases, matching the directedness in proposition 154.23. A fuel-bounded evaluator computes approximants only; it does not compute |M|, and it proves neither theorem 154.24 nor corollary 154.27.

Search the book

Type to search the local edition.