PCF Böhm trees

$λ$-calculus: Normal forms of the form

M \; ≝ \; λx_0, …, x_n. W \\ W \; ≝ n \; \mid \; \texttt{case } x^A M_1 ⋯ M_p \texttt{ is } [n_1 → W_1 … n_q → W_q]\\ \text{ where } A = σ_1 → ⋯ → σ_p → nat

NB: this term is not allowed $λf. f$, where $f: nat → nat$ in PCF Böhm trees, because of the form of $A$ above. Only way to fix it: $η$-expand it: $λf,x. f x$

Exercise: Show that any real PCF term reduces to a some (infinite) Böhm tree.

⟹ Infinite Böhm trees are $η$-long normal forms.

σ \; ≝ \; nat \; \mid \; σ → σ

NB: so $σ$ is of the form $σ_1 → ⋯ → σ_n → nat$.

Typing rules:

\cfrac{⊢ W: nat}{⊢ λ x_1^{σ_1}, …, x_n^{σ_n}. W: σ_1 → ⋯ → σ_n → nat}
\cfrac{}{⊢ n: nat}
\cfrac{⊢ M_1: σ_1 \quad ⋯ \quad M_p: σ_p \qquad ⊢ W_1: nat \quad ⋯ \quad ⊢ W_q: nat}{x: σ_1 → ⋯ → σ_p → nat ⊢ \texttt{case } x \vec{M} \texttt{ is } [… n_i → W_i …] : nat}

First goal: Compile PCF Btrees into “strategies” written using the following vocabulary:

$(nat → nat) → nat → nat$ is turned into

  digraph {
    rankdir=TB;
    "nat_11" -> "nat_1" -> "nat_ε";
    "nat_2" -> "nat_ε";
  }

The vocabulary will consist of moves of the form

?_u \qquad n_u

with the convention that

  • $?_ε$: Opponent (O)
  • $n_ε$: Player (P)

and

  • If $?v$ is O for $σ_i$, then $?{iv}$ is a P for $A$
  • If $?v$ is P for $σ_i$, then $?{iv}$ is a O for $A$

NB: this is reminiscient of values of $M ⇒ M’$ being either values of $M’$ or cells of $M$

+ an equipement of pointers from P moves back to O moves

cf. picture

Innocent Strategies

Innocent strategies: between memoryless ones and those retaining complete history.

Warmup Example:

lor: nat_1 → nat_2 → nat_ε
h \; ≝ \; λf. \texttt{ case } f (3) \texttt{ is } [4 → 7, 6 → 9] : (nat_{11} → nat_1) → nat_ε

Kierstead (student of Curry (who was working on higher-order recursive functions)) terms:

From now on,

\texttt{case } x \vec{M} \quad \text{ is an abbrev. for } \quad \texttt{case } x \vec{M} \texttt{ of } \underbrace{[0 → 0, 1 → 1, …, 2 → 2, …]}_{\text{infinite list}}
Kierstead: ((nat → nat) → nat) → nat\\ Kierstead_1: \quad λf. \texttt{case } f \, (λx. \texttt{case } f \, (λy. \texttt{case } x))\\ Kierstead_2: \quad λf. \texttt{case } f \, (λx. \texttt{case } f \, (λy. \texttt{case } y))\\

cf. picture


We will define a cartesian closed category of Hyland-Ong Games.

  • Morphisms = innocent strategies

    Two equivalent forms:

    • meager (set of views):

      • where Opponent moves point to their direct Player parent move

      • composition via abstract machines

    • fat (set of plays)

      • composition is defined in one line

    NB: it’s similar to what we had with sequential algorithms: meager (AM) vs. fat (abstract algorithms)

Example: cf. picture

Kierstead applied to $h$

Arenas (HO)

An arena is given by

(M, λ M → \lbrace O, P \rbrace)

where

  • $M$ stands for the moves
  • $⊢ ⊆ M ∪ M × M$

    • if $⊢ m$, then $m$ is an O
    • if $m ⊢ n$, then $m$ and $n$ are of opposite polarities

Cartesian Product

A = (M, λ, ⊢) \qquad A' = (M', λ', ⊢')
A × A' = (\underbrace{(M.1) ∪ (M'.2)}_{M''}, λ'', ⊢'') \\

where

λ''(m.1) = λ(m)\\ \cfrac{⊢ m}{⊢'' m.1}\\ \; \\ \cfrac{⊢' n}{⊢'' n.2}\\ \; \\ \cfrac{m_1 ⊢ m_2}{m_1.1 ⊢'' m_2.1}\\ \; \\

Function Space

A ⇒ A' = (M'', λ'', ⊢'')
M'' = M.1 ∪ M'.2\\ λ''(m.1) = \overline{λ(m)} \qquad \text{ (P becomes O and vice versa)}\\ λ''(n.2) = \overline{λ'(n)}\\

And the rules are the same as the ones of the product, except the intial rules:

\cfrac{⊢' n }{⊢'' n.2}
\cfrac{⊢ m \qquad ⊢' n}{n.2 ⊢'' m.1}
\cfrac{m_1 ⊢ m_2}{m_1.1 ⊢'' m_2.1}
\cfrac{n_1 ⊢ n_2}{n_1.2 ⊢'' n_2.2}

Strategies (morphisms in our category)

A play is an alternating sequence of moves in $M$ starting with O, equipped with pointers from all occurrences (of non-initial moves) in the sequence in such a way that

  • if $m_i$ points to $m_j$ for $j < i$, then $m_j ⊢ m_i$

(cf. picture)

A strategy:

is a set $σ$ of even-length plays closed under even prefixes

NB: definition by Russ Harmer. It is very practical for non-determinism.

A strategy $σ$ is deterministic:

if moreover: whenever $s m_1, \, s m_2 ∈ σ$, where the $m_i$’s point in $s$, it comes that $m_2 = m_1$

Innocent strategies

A strategy $σ$ of $A$ is called innocent (Hyland Ong (HO)):

if for all $s$ (ranging over plays of $A$):

s ∈ σ \quad ⟺ \quad \underbrace{\lceil s \rceil}_{\text{P view of } s} ∈ σ

where the view of a play is defined as:

\lceil ε \rceil = ε\\ \lceil s n \rceil = \lceil s \rceil n \qquad \text{ if } λ(n) = P\\ \lceil s m \rceil = m \qquad \text{ if } λ(m) = O \text{ and } ⊢ m\\ \lceil s n s' m \rceil = \lceil s n \rceil m \qquad \text{ if } m \text{ points inside } n\\

Exercise: When we had the interaction $h(f)$, we spotted a play $s$ that belonged to $h$. Compute $\lceil s \rceil$.

A view:

is a sequence $s$ such that $\lceil s \rceil = s$

Meager strategies

Given an innocent strategy $σ$, we can define

meager(σ) \; ≝ \; \lbrace \text{set of views } s \; \mid \; s ∈ σ \rbrace

Prop: $meager$ is injective.

Innocent strategies can be composed in two ways:

  • either as strategies (parallel composition + hiding)
  • or as meager strategies (abstract machines)

Parallel composition

Let

  • $σ$ be a strategy of $A ⇒ A’$
  • $σ’$ be a strategy of $A’ ⇒ A’’$

Then we define

σ' \circ σ \; ≝ \; \lbrace v \; \mid \; v ∈ plays (A ⇒ A'') \text{ and } ∃ \underbrace{u}_{\text{sequence of moves taken in } A, A', A'' \text{ together with pointers}} \text{ st } v = u_{| A, A''}, \quad w ≝ u_{| A, A'} ∈ σ, \quad w' ≝ u_{| A', A''} ∈ σ' \rbrace

NB:

  • Hiding: because the everything related to $A’$ has been kept private (hidden) in the final result
  • Parallel composition: because $w$ and $w’$ are obtained from the same $u$

  • This definition works even without determinism nor innocence, but the equivalence with meager strategies holds only when we have innocence

nat = \lbrace \lbrace ? \rbrace ∪ ℕ \; \mid \; \begin{cases} λ (?) = O, \quad λ (n) = P \\ ⊢ ?, \quad ? ⊢ n \end{cases}\rbrace

Next time:

  • give a precise definition of the compilation from PCF Böhm trees to innocent strategies

  • Suggest: the characterisation of the image of this compilation (which is injective: two different Böhm tress give rise to different strategies)

  • Well-parenthesisation: exclude catch and or_tester

  • How to interpret some imperative features in the setting of HO games (imperative features ⟶ non-innocent strategies)

Leave a comment