Lectures onType Theory
Control operators, CPS, and classical proofs
appendix sectionsignatures

Control operators, CPS, and classical proofs

λK signature.

Chapter 17 fixes closed call-by-value simply typed products, sums, 0, 1, naturals, arrows, and the primitive addm, extended only by ContA, letcc, and throw. Runtime continuations are persistent whole stacks. The machine includes every pure evaluation frame, both throw phases, and an internal cont(K); continuation values are not source syntax. All frames and states carry one ambient run answer R. There is no recursion, store, exception primitive, delimiter, effect row, or dependent type in this signature.

Machine metatheory.

Closed value substitution and canonical continuations are lemma 35.2. Preservation, deterministic progress, and safety are theorem 35.3, theorem 35.4, corollary 35.5. The final throw root discards its current stack and restores a stack with the same ambient answer type; canonical forms is used when the second throw frame returns.

CPS signature and results.

The pure target is simply typed products, sums, 0, 1, naturals, and arrows with compatible βδ-reduction. The answer type is fixed to 0, while a fresh open variable h:Rv0 represents the empty source stack. The translation includes every source term, every machine frame, internal continuation values, and both state directions. CPS substitution, typing, and positive-step simulation are lemma 35.10, theorem 35.11, theorem 35.12. Positivity transfers target strong normalization to λK, and progress plus canonical forms gives consistency, by theorem 35.13, corollary 35.14.

Classical programs.

Proposition 35.15 derives Cont(ContA)A. Proposition 35.16 derives A+ContA and records both the initial right return and the later left return through the same caller stack. These are typed programs with nonlocal operational behavior, not new definitional equalities of the pure calculus.

PPS common signature.

The handler/control bridge is separate from λK. Its common core has kinds T,E,R, ordered rows, quantification over all three kinds, explicit generalization, instantiation, subtyping, and lift, and n-freeness for delimiter scope. Generalization requires its bound variable to be absent from FV(Γ); repeated generalization first alpha-renames the effect binders away from the term context. An omitted trailing ι after a single effect is a stated abbreviation, not a change of kind.

Deep bridge.

Deep handlers use effects Δ0.τ1τ2; shift0 uses Δ0.τ/ρ. Every Δ0 scopes the complete translated operation function and retains each binder kind. Translation commutes with kind substitution, value substitution, context plugging, and freeness. Both directions preserve typing and source roots by a positive target sequence. Only deep-handler-to-shift0 requires arbitrary-context i+, because one administrative beta contraction occurs beneath a lambda; the reverse direction uses ordinary evaluation reduction. These statements are exactly lemma 35.25, theorem 35.30. The named syntax translations are DH() and DD(); double brackets remain reserved for denotations.

Shallow bridge.

Shallow handlers and control0 use recursive single effects μα., because their resumed continuations omit the handler or reset and may expose the same leading effect again. Both translations preserve kinding, typing, substitution, plugging, freeness, and source roots. Both semantic directions use ordinary positive evaluation reduction; neither uses i. The exact result is lemma 35.36, theorem 35.40. No theorem swaps deep with control0, shallow with shift0, or these delimited calculi with λK. The two named translations are SH() and SD().

Dependent boundary.

Definition 35.41 is an explicitly hypothetical call-by-name calculus with strong existential projections, proof and number callcc, arbitrary-result throw, compatibility below callcc, and a commuting first-projection rule. It derives 1=0 by proposition 35.42. This counterexample does not execute in the CBV λK machine. Requiring wit and prf to eliminate proof values blocks the displayed term but is not claimed as a complete soundness proof for dependent control.

Primary sources.

The whole-stack machine, safety boundary, and CPS organization follow the KPCF and continuation chapters of Harper’s Practical Foundations for Programming Languages [Har16]. Kameyama–Hasegawa, Section 2.1, Section 3 Theorem 1, and Section 6.2 Theorem 9 delimit the shift/reset equational and CPS boundary [KH03]. Piróg–Polesiuk–Sieczkowski, printed pp. 30:2–30:14, Figures 1–14 and Theorems 1–12, supply the exact four typed handler/control directions and their asymmetric semantic scopes [PPS19]. Herbelin, §2.6–2.7 and Corollary 5, supplies the Sigma-type collapse and the exact role of vacuity [Her05]. Miquey, Section 2.1, printed p. 8:6, Section 2.2, printed pp. 8:7–8 and footnote 6, supplies the sequent-calculus presentation and value-restriction boundary [Miq19].

Executable evidence.

Appendix E’s Kappa companion represents stack and CPS spines as ordinary data. Four discriminatory cases corroborate complete-spine capture, stack replacement, persistence, and the LEM change-of-mind trace. The remaining direct/CPS, declared-cost, and DNE constructor equalities are smoke checks, not independent evidence. Kappa has no raw control primitive, and the artifact proves none of the metatheorems above. The archived PPS Coq supplement is separate compatibility evidence at its historical Coq 8.8.2 boundary.

Search the book

Type to search the local edition.