Lecture 17: Or-tester, Abstract algorithms

Lecture 17

Reminder:

First view (good for cartesian closure):

\[M ⇒ M' \qquad (xc', valof \, c) \; (xc', output \; v')\]

Second view:

\[(request \; c' \, (valof \, c \quad is \, v)^\ast output \, v')^\ast \quad \text{ all prefix of even length}\]

cf. picture

Program of today:

  1. complete the description of composition of algorithms as forests

  2. key example of a strange sequential algorithm called the or-tester (related to having a call-cc construct in the underlying language)

  3. state a full-abstraction result (1992) about sequential algorithms and PCF+or-tester

  4. Third view: move to the third description of sequential algorithms: abstract algorithms, associativity of composition for free


Consider the forests

$𝔽$ $𝔽’$
\(M_σ ⟶ B × M'_d\\ \underbrace{M_σ ⟶ B}_{cst \; F} \qquad \underbrace{M_σ ⟶ M'_σ}_{\text{identity}}\) \(B × M'_σ ⟶ B'\)

where

  • \[M_Σ = (\underbrace{ℕ^\ast}_{\text{cells}}, \underbrace{\lbrace a^0, g^1, f^2, …\rbrace}_{\text{values}})\]
    • \[(ε, f) ⊢ 0\\ ⊢ 1\\ (ε, g) ⊢ 0\\ (ε, a) \not ⊢\]
  • $B$ stands for the booleans

Pointer interaction:

If a move $m.n’$ points to $m’.n$ then $m. n$ should be played under $m’.n$

cf. picture

Or-tester

\[ortester: (B → B → B) → B\\ ortester(lror) = V\\ ortester(rlor) = F\\\]

$rlor$ and $lror$ are not distinguishable in PCF, hence are observationally equal, due to:

Context Lemma (Milner):

\[M =_{obs} N: A_1 → A_2 → ⋯ → A_n → Base\\ ⟺ (∀ p_1, …, p_n, M \, p_1 \, ⋯ \, p_n ⟶^\ast v ⟺ N \, p_1 \, ⋯ \, p_n ⟶^\ast v)\]

But this sequential algorithm $testor$ can distinguish them.


Reminder about full abstraction:

Language Model  
PCF not F.A. (Cartmight, Curien, Felleisen) Seq. algorithms
PCF+catch F.A. Seq. algorithms
\[catch_A: \underbrace{A}_{\; ≝ \; A_0 → ⋯ → A_n → ℕ} ⟶ ℕ\\ catch(λx_0, …, x_n. \texttt{if } x_i M_1 ⋯ M_n \texttt{ then } P \texttt{ else } Q) ⟼ i\\ catch(λx_0, …, x_n. m) ⟼ n + m + 1\]

Property:

\[\cfrac{M ⟶ M'}{catch(M) ⟶ catch(M')}\]

\[M ⇒ M' \qquad \lbrace (xc', valof \; \underbrace{c}_{∈ A(x)}), \underbrace{(xc', output \; v')}_{(c', v') ∈ E'} \rbrace = E_{M ⇒ M'}\\ u \; ≝ \; valof \; c \; \mid \; output \; v'\]

3rd definition of sequential algorithms; abstract algorithms.

If $f$ is a configuration of $M ⇒ M’$, we want to define

\[x ⟼ f \cdot x, \qquad D(M) ⟶ D(M')\] \[f \cdot x = \lbrace (c', v') \; \mid \; ∃ y ≤ x ;\; (yc', output \; v') ∈ f\rbrace\]

What about the rest of $f$?

Let $M, M’$ be two cds. An abstract algorithm is a partial function

\[φ: C_{M ⇒ M'} ⟶ V_{M ⇒ M'}\]

satisfying

  • (A1) \(φ(xc') = u ⟹ (xc', u) ∈ E_{M ⇒ M'}\)
  • (A2) \(φ(xc') = u, x ≤ y \text{ and } (yc', u) ∈ E_{M ⇒ M'} \text{ then } φ(yc') = u\)
  • (A3) Let \(φ \cdot y = \lbrace (c', v') \; \mid \; φ(yc') = output \; v'\rbrace\)

    Then

    \[\underbrace{φ(y c') ↓}_{φ(y c') \text{ is defined (partial function)}} \\ ⟹ c' ∈ E(φ \cdot y) \text{ and } \\ ∀ z \text{ st } z ≤ y, c' ∈ E(φ \cdot z), φ(z c') ↓\]

Relation with sequential algorithms

In a way, $φ$ is an extension of $f$ to many more possible cells.

Meager: $f ∈ D(M ⇒ M’)$

Fat: \(φ(xc') = u ⟺ \\ \Big((xc', u) ∈ E_{M ⇒ M'} ⟺ ∃ y ≤ x; (yc', u) ∈ f\Big)\)

From $φ$ to $f$:

\[f = \lbrace (xc', u) \; \mid \; φ(xc') = u \text{ and } y < x ⟹ φ(yc') ≠ u \rbrace\]

NB: We can even make abstract algorithms fatter by allowing $x$ to be infinite:

\[φ(xc') = u ⟺ \\ \Big(\text{ if } u = output \; v' \text{ then } (c', v') ∈ E', \text{ if } u = valof \; c, c ∈ A(x)⟺ ∃ y ≤ x; (yc', u) ∈ f\Big)\]

Let $φ: M ⟶ M’$ and $ψ: M’ ⟶ M’’$ be two abstract algorithm (in the fattest sense).

We define $χ \; ≝ \; ψ \circ φ: M ⟶ M’’$ as follows:

\[χ(x c'') \; ≝ \; \begin{cases} output \; v'' &&\text{ if } ψ((φ \cdot x) c'') = output \; v'' \\ valof \; c &&\text{ else if } ψ((φ \cdot x) c'') = \underbrace{valof \; c'}_{\text{on top of that: } c' ∈ A(φ \cdot x)} \text{ and } φ(xc') = valof \; c \end{cases}\]

cf. picture

Advantages and Drawbacks

Traditional “Games”
Scott Seq. algorithms
Coh. spaces Several morphisms in our category describing the same function (it is not concrete) ⟹ enabled us to solve one FA problem (PCF+catch).

NB: The fact that seq. alg. had this catch prompted other people to continue.

  • Abramsky-Iagadeesan-Molacarice ⟹ Geometry of interaction
  • vs: Hyland-Ong Games (early 90’s) ⟹ won over the years (more flexible)

Seq. algorithms are FA (for PCF+catch). This can also be shown with Hyland-Ong games, but it’s more complicated (you need to resort to quotients).

Hyland-Ong Games: a flavour

PCF: PCF “infinite normal forms”, infinite PCF Böhm trees

NB: in codinductive definitions, you “unveil” things that you assume are already there.

$λ$-calculus: Normal forms of the form

\[M \; ≝ \; λx_0, …, x_n. P\\ P \; ≝ \; x M_1 ⋯ M_m\]

In PCF:

\[M \; ≝ \; λx_0, …, x_m. P\\ P \; ≝ \; n \; \mid \; \texttt{case } x M_1 ⋯ M_m \; [⋯ x_i → P_i ⋯]\]

cf. picture : left-right-or example

Leave a comment