# Lecture 16: Sequential Algorithms

Lecture 16

• Sequential ⟹ Stable
• Cds $M = (\underbrace{C}_{\text{cells}}, \underbrace{V}_{\text{values}}, \underbrace{E}_{⊆ C × V \text{ = events}}, \underbrace{⊢}_{\text{ enabling relation, of the form } ⊢ c \text{ or } (d, v) ⊢ c})$

Revisit the definition of $M ⇒ M’$

• Good for straightforward cartesian closure: $M’’ = M ⇒ M’$

• Good for straightforward execution: Forest/programs

• Good for straightforward composition: $(\underline{function}, \underline{comp. strat})$

Recall that a proof is a sequence

c_n v_n c_{n-1} ⋯ c_1 v_1 c_0

st

⊢c_n \qquad \text{ and } \qquad (c_i, v_i) ⊢ c_{i-1} \quad ∀ i > 0
• Condition 1: $\not ∃$ an infinite proof
• Condition 2 (Stability): if $c_n v_n c_{n-1} ⋯ c_1 v_1 c_0 = c$

d_m w_m ⋯ d_1 w_1 d_0 = c

are two proofs of the same cell, then the longest common prefix is either $∅$ or ends with a cell.

(cf. picture)

If $M$ is a cds, a configuration of $M$ is a set $x ⊆ E$ st (determinism):

(c, v_1), (c, v_2) ∈ x ⟹ v_1 = v_2

On top of that:

∀ (c, v) ∈ x, \text{ either } ⊢ c \text{ or } ∃ (d, w) ∈ x; \; (d, w) ⊢ c

Notations:

• $(c, v) ∈ x$ iff $c ∈ F(x)$ (filled)
• If $c ∉ F(x)$ and $(d, w) ∈ x$ and $(d, w) ⊢ c ⟺ c ∈ A(x)$ (accessible)
• $c ∈ E(x) ⟺ c ∈ A(x) \text{ or } c ∈ F(x)$ (enabled)

(cf. picture)

The stability condition allows us to represent configurations as forests (the $(d, w)$ is unique, in the determinism property).

Example: $Σ = \lbrace f^2, g^1, a^0\rbrace$. cf picture for $f(g(Ω), a)$

We write

D(M) = \lbrace \text{configurations of } M\rbrace, ⊆

Prop: for every cds $M$, $D(M)$ satisfies:

∀x, y. x ↑ y ⟹ x ∩ y \text{ is a configuration that is the glb of } x \text{ and } y

Proof: $x, y ⊆ z ∈ D(M)$

• $c ∈ F(x ∩ y) ⟹ c ∈ F(x)$ thus if $(c, v_1), (c, v_2) ∈ F(x ∩ y)$, then $v_1 = v_2$

• if $c ∈ F(x ∩ y)$, then there exists $(d, w) ∈ x ∩ y$ by uniqueness (stability) such that $(d, w) ⊢ c$

Let $M, M’$ be two cds and $f: D(M) ⟶ D(M’)$ be Scott-continuous.

$f$ is called sequential at $x$ if

∀c', (c' ∈ A(f(x)) \text{ and } ∃ z > x; c' ∈ F(f(z))) \\ ⟹ ∃ c ∈ A (x) \text{ st } ∀ y > x; (c' ∈ F(f(y)) ⟹ c ∈ F(y))

Th: Any sequential algorithm computes a sequential function

Prop: Any sequential function is stable.

\text{ Sequential } ⊊ \text{ Stable } ⊊ \text{ Continuous }

Proof:

By contradiction, suppose that

f(x ∩ y) ⊊ f(x) ∩ f(y)

# 3 different ways to define sequential algorithms (78)

1. As configurations of $M ⇒ M’ = (C’’, V’’, E’’, ⊢’’)$

C'' = D^{fin}(M) × C'\\ V'' = \lbrace valof \; c \; \mid \; c ∈ C\rbrace ∪ \lbrace output \; v' \; \mid \; v' ∈ V' \rbrace\\ E''\; ≝ \; \lbrace (xc', output \; v') \; \mid \; (c', v') ∈ C' × V' \rbrace ∪ \lbrace (xc', valof \; c) \; \mid \; c ∈ A(x) \rbrace\\ ⊢'' ∅ c' \quad \text{ iff } \quad ⊢' c'\\ (xc', output \; v') ⊢'' xd'\quad \text{ iff }\quad c', v' ⊢' d'\\ (xc', valof \; c) ⊢'' (x ∪ \lbrace (c,v) \rbrace) c' \quad \text{ iff } \quad (c, v) ∈ E

A dive into the corresponding category:

• Objects: Cds
• SeqAlg whose morphisms are given by

SeqAlg(M, M') = D(M ⇒ M')
\cfrac{D(M ⇒ M') \qquad D(M ⇒ M'')}{D(M ⇒ (M' × M''))}

Look at the cells, they have the form:

x c'.1\\ x c''.2 \qquad \text{ with } x ∈ D(M)

Similarly, we have to check that

\cfrac{D((M × M') ⇒ M'')}{D(M ⇒ (M' ⇒ M''))}

Cells in both of them: resp. of the form $(x,x’)c’’$ and $x(x’c’’)$ (recall that $D(M × M’) ≅ D(M) × D(M’)$)

# Categorical composition

## Sequential algorithms as forests

Consider the quick left or:

\underbrace{Bool^2 }_{\text{cells: } ?.1 \text{ and } ?.2}⟶ \underbrace{Bool}_{\text{cells: } ?'}

cf. pictures

Formally, sequential algorithms as forests are defined via

• a recursive syntax
• typing rules
\text{Forest: } F = (T_1, …, T_n)\\ \text{Trees: } T = request \; c' \; U\\ \text{U: } T = valof \; c \; \lbrace ⋯ is \; v_i ⊢ U_i ⋯ \rbrace \; \mid \; output \; v' \; F

We only accept forests that are well-typed:

(\underbrace{x}_{D^{fin}(M)}, \underbrace{r'}_{\rlap{\text{of the form } q'v' \text{ where } q' \text{ is a proof of } M'}}) ⊢ F\\ (x, r') ⊢ T\\ (x, q') ⊢ U

and:

\cfrac{(x, r') ⊢ T_1 \quad ⋯ \quad (x, r') ⊢ T_n}{(x, r') ⊢ F}
\cfrac{(x, r'c') ⊢ U}{(x, r') ⊢ request \; c' \; U} \quad r'c' \text{ is a proof in } M'
\cfrac{c ∈ A(x) \qquad (x ∪ \lbrace (c, v)\rbrace, q') ⊢ U_i }{(x, q') ⊢ valof \; c \; (⋯ is \, v_i ⊢ U_i ⋯ )}
\cfrac{q' = r'c' (c', v') ⊢ E' \quad (x, q' M) ⊢ F }{(x, q') ⊢ output \; v' \; F}

Alternatively, we can give a syntax in terms of branches (aka plays):

(request \; c' \; (valof \; c \; is \; v)^\ast output \; v')^\ast + request \; c' \; (valof \; c \; is \; v)^\ast valof \; c

E.g.: $request \; c’ \;\; valof \; c$ is allowed (corresponding to $(∅c’, valof \; c)$)

### Composition

f: M ⇒ M' \qquad g: M' ⇒ M'' \leadsto g \circ f: M ⇒ M''\\ x: 1 ⇒ M \qquad f: M ⇒ M' \leadsto f(x): M ⇒ M''\\

where

1 = \text{ empty set of cells}

A generalized point $x$ is of the form:

request c_1 ⟶ output \; v_1 ⟶ request \; v_2 ⟶ ⋯

i.e., in a way: $x ∈ D(M)$

cf. picture

Tags:

Updated: