# Lecture 13: Scott semantics

Lecture 13

Preorders and linear functions (Scott semantics)

PoLR_!(S, T) \overset{Fun}{⟶} \underbrace{PoC(S, T)}_{\text{Scott cont. function } ℐ(S) → ℐ(T)}\\ PoC(S, T) \overset{Tr}{⟶} PoLR_!(S, T)

defines an iso of categories

id ∈ PoLR_!(S, S) = PoLR(!S, S)\\ id = der_S
s ∈ PoLR_!(S, T) = PoLR(!S, T)\\ t ∈ PoLR_!(T, U) = PoLR(!T, U)\\ t \circ s ∈ PoLR_!(S, U)\\ !S \overset{dig_S}{⟶} !!S \overset{!s}{⟶} !T \overset{t}{⟶} U
Fun(t \circ s) = Fun(t) \circ Fun(s)

Remember that

Fun(s)(u) = s u^!\\ u ∈ ℐ(S) \qquad u^! = 𝒫_{fin}(u) ∈ ℐ(!S)
Fun(t \circ s)(u) = (t \circ s) u^! = (t \, !s \, dig) \, u^! \\ = t \, !s \, (dig \, u^!) = t \, !s \, u^{!!}\\ = t \, (s \, u^!)^! = Fun(t)(Fun(s)(u))

We can consider

Fun: \begin{cases} PoLR_! &⟶ PoC \\ S &⟼ S\\ t &⟼ Fun(t)\\ \end{cases}
Tr: \begin{cases} PoC &⟶ PoLR_! \\ S &⟼ S\\ f &⟼ Tr(f)\\ \end{cases}

are two functors which define an iso of categories.

# Fixpoints

## Fixpoints of functions

Any continuous function has a least fixpoint:

s ∈ PoLR_!(S, S)\\ f = Fun(s): \underbrace{ℐ(S)}_{\ni ∅} ⟶ ℐ(S)
∅ ⊆ f(∅) ⊆ f^2(∅) ⊆ ⋯ ⊆ f^n(∅) ⊆ f^{n+1}(∅) ⊆ ⋯
u = \bigcup\limits_{n=0}^∞ f^n(∅)\\ f(u) = \bigcup\limits_{n=0}^∞ f^{n+1}(∅) = u

$u$ is the least fixpoint of $f$.

𝒴: \begin{cases} ℐ(S ⇒ S) &⟶ ℐ(S) \\ s &⟼ \bigcup\limits_{n=0}^∞ Fun(s)^n(∅) \end{cases}

We ask for

Y ∈ ℐ((S ⇒ S) ⇒ S)

such that $𝒴 = Fun(Y)$

Define

F ∈ PoC((S ⇒ S) ⇒ S, (S ⇒ S) ⇒ S)\\ 𝒵 ∈ PoLR_!((S ⇒ S) ⇒ S, (S ⇒ S) ⇒ S)

such that $Y$ will be the least fixpoint of $𝒵$.

Y = \bigcup\limits_{n=0}^∞ 𝒵^n(∅)
"Y(t) = t(Y(t))\\ λY. (λt. t(Y(t)))"
𝒵_0: ((S ⇒ S) ⇒ S) \& (S ⇒ S) \overset{⟨π_1, π_2, π_2⟩}{⟶} ((S ⇒ S) ⇒ S) \& (S ⇒ S) \& (S ⇒ S)\\ \overset{Ev \& id}{⟶} S \& (S ⇒ S) ⟶ (S ⇒ S) \& S \overset{Ev}{⟶} S

$𝒵$ is fully characterized by

Fun(Fun(𝒵(Y)))(t) = Fun(t)(Fun(Y)(t))

Let $F = Fun(𝒵)$

Let

Y_0 = \bigcup\limits_{n=0}^∞ F^n(∅)

be the least fixpoint of $F$ ($F(Y_0) = Y_0$).

Let $s ∈ PoLR_!(S, S) = ℐ(S ⇒ S)$.

Fun(Y_0)(s) = Fun(F(Y_0))(s) = Fun(s)(Fun(Y_0)(s))

(we are strongly relying on the cartesian closure of the category)

Exercise: Prove that

Fun(Y_0)(s) = \bigcup\limits_{n=0}^∞ Fun(s)^n(∅)

actually:

Fun(F^n(∅))(s) = Fun(s)^n(∅)

## Fixpoints of types

$PO_⊆$:

partially ordered class of preorders, ordered by:

S ⊆ T \quad \text{ iff } \quad \vert S \vert ⊆ \vert T \vert \text{ and } ∀ a, a' ∈ \vert S \vert, a ≤_S a' ⟺ a ≤_T a'

Any sequence

S_0 ⊆ S_1 ⊆ ⋯ ⊆ S_n ⊆ S_{n+1} ⊆ ⋯

has a least upper bound in $PO_⊆$

S = \bigcup\limits_{n=0}^∞ S_n

given by

\vert S \vert = \bigcup\limits_{n=0}^∞ \vert S_n \vert\\ a ≤_S a' \quad \text{ iff } \quad ∃ n; a ≤_{S_n} a'

NB (Model Theory): the theory of partial orders is clearly $∀∃$-axiomatizable, so it is inductive.

Φ = PO_⊆ ⟶ PO_⊆

is a unary variable type if $Φ$ is monotonic, i.e.

S ⊆ T ⟹ Φ(S) ⊆ Φ(T)

and continuous, i.e.

S_0 ⊆ S_1 ⊆ ⋯ ⟹ Φ(\bigcup\limits_{n=0}^∞ S_n) = \bigcup\limits_{n=0}^∞ Φ(S_n)

A $n$-ary variable type is a

Φ: PO_⊆^n ⟶ PO_⊆

st

∀ i, ∀ S_1, …, S_{i-1}, S_{i+1}, …, S_n ∈ PO, \\ S ⟼ Φ(S_1, …, S_{i-1}, S, S_{i+1}, …, S_n) \text{ is a unary variable type}

If $Φ: PO_⊆ ⟶ PO_⊆$ is a variable type, then

Φ(\underbrace{\bigcup\limits_{n=0}^∞ Φ(∅)}_{Rec(Φ)}) = \bigcup\limits_{n=0}^∞ Φ(∅)

$Φ: PO_⊆^{n+1} ⟶ PO_⊆$ variable type, $\vec S ∈ PO^n$,

Φ_{\vec S}: \begin{cases} PO_⊆ &⟶ PO_⊆ \\ S &⟼ Φ(\vec S, S) \end{cases}

unary variable type

Rec(Φ): \begin{cases} PO_⊆^n &⟶ PO_⊆ \\ \vec S &⟼ Rec(Φ_{\vec S}) \end{cases}
Φ(\vec S, Rec(Φ)(\vec S)) = Rec(Φ(\vec S))

Fact: $Rec(Φ)$ is itself a variable type. All constructions of LL are variable types.

Are variable types:

• \begin{cases} PO_⊆ &⟶ PO_⊆ \\ S &⟼ S^⊥ \end{cases}
• \begin{cases} PO_⊆^2 &⟶ PO_⊆ \\ (S_1, S_2) &⟼ S_1 ⊗ S_2 \end{cases}
• \begin{cases} PO_⊆ &⟶ PO_⊆ \\ S &⟼ !S \end{cases}

Variable types are closed under composition.

If

Φ: PO_⊆^n ⟶ PO_⊆
Ψ_i: PO_⊆^k ⟶ PO_⊆

then

\begin{cases} PO_⊆^k &⟶ PO_⊆ \\ \vec T &⟼ Φ(Ψ_1(\vec T), …, Ψ_n(\vec T)) \end{cases}

is a variable type.

Example:

Φ(S) = 1 ⊕ !S

Let $L = Rec(Φ)$

\vert L \vert = \bigcup\limits_{n=0}^∞ E_n

where

• $E_0 = ∅$
• E_{n+1} = \lbrace \underbrace{(1, \ast)}_{ζ}\rbrace ∪ \lbrace \underbrace{(2, u^0)}_{\overline{suc}(u^0)} \; \mid \; u^0 ∈ 𝒫_{fin}(E_n)\rbrace
a \; ≝ \; ζ \; \mid \; \overline{suc} \lbrace a_1, …, a_n\rbrace
a ≤_L a' \qquad ⟺ \qquad \begin{cases} a = a' = ζ \\ \text{ or } a = \overline{suc}(u^0) \text{ and } a' = \overline{suc}(u^1) \text{ and } \underbrace{u^0 ≤_{!L} u^1 }_{∀ b∈ u^0, ∃ b' ∈ u^1; b ≤_L b'} \end{cases}

⟶ Elements of $L$ are “finite comb trees”

\overline 0 ∈ PoLR_!(\underbrace{⊤}_{\text{terminal object of } PoLR \text{ and } PoLR_!: \text{ the empty preorder}}, L)\\ Suc ∈ PoLR_!(L, L)
!⊤ \overset{m^0}{⟶} 1 \overset{in_1}{⟶} \underbrace{1 ⊕ !L}_{=L}
\overline 0 = \lbrace (∅, ζ)\rbrace
Suc: \; !L \overset{m_2}{⟶} 1 ⊕ !L = L\\ Suc = \lbrace (u^0, \overline{suc}(u^0)) \; \mid \; u^0 ∈ \vert !L \vert \rbrace
\overline{if} ∈ PoLR(L ⊗ !S ⊗ !(!L ⊸ S), S)\\ if(M, N, x. P)
\overline{if}: \underbrace{(1 ⊕ !L) ⊗ !S ⊗ !(!L ⊸ S)}_{≃ \; (!S ⊗ !(!L ⊸ S)) ⊕ (!L ⊗ !S ⊗ !(!L ⊸ S))} ⟶ S

Case definition:

\overline{if}_0: !S ⊗ !(!L ⊸ S) \overset{!S ⊗ w}{⟶} !S ⊗ 1 \; ≃ \; !S \overset{der_S}{⟶} S
\overline{if}_{suc}: \; !L ⊗ !S ⊗ !(!L ⊸ S) \overset{id ⊗ w ⊗ id}{⟶} !L ⊗ 1 ⊗ !(!L ⊸ S) \\ \; ≃ \; !L ⊗ !(!L ⊸ S) \overset{id ⊗ der}{⟶} !L ⊗ (!L ⊸ S) \overset{σ}{⟶} !(!L ⊸ S) ⊗ !L \overset{ev}{ ⟶} S

# LPCF

A, B, … \; ≝ \; ι \; \mid \; A → B
M \; ≝ \; x \; \mid \; \underline 0 \; \mid \; \underline {suc} (M) \; \mid \; if (M, N, x. P)\\ \; \mid \; (M)N \; \mid \; λx^A. M \; \mid \; fix \, x^A. M
Γ = (x_1: A_1, …, x_n: A_n)
\cfrac{}{x_1: A_1, …, x_n: A_n ⊢ x_i: A_i}
\cfrac{}{Γ ⊢ \underline 0: ι}
\cfrac{Γ ⊢ M: ι}{Γ ⊢ \underline {suc }(M): ι}
\cfrac{Γ ⊢ M: ι \qquad Γ ⊢ N: A \qquad Γ, x: ι ⊢ P: A}{Γ ⊢ if(M, N, x.P): A}

$λ$-calculus (app. $λ$)

\cfrac{Γ, x:A ⊢ M:A}{Γ ⊢ fix \; x^A. M:A}

$β$: general reduction

$β_{wh}$: weak head reduction

## Interpretation in the model PoLR

A \leadsto [A] \text{ a preorder}\\ [ι] = L \\ [A → B] = [A] ⇒ [B] = ![A] ⊸ [B]
Γ = (x_1: A_1, … , x_n: A_n)

$![Γ]$ is a notation for

![A_1] ⊗ ⋯ ⊗ ![A_n] \quad ≃ \quad !([A_1] \& ⋯ \& [A_n])

to $Γ ⊢ M:A$ we associate

[M]_Γ ∈ PoLR(![Γ], [A])

NB: $[M]_Γ$ can be considered as a Scott-continuous function

ℐ([A_1]) × ⋯ × ℐ([A_n]) ⟶ ℐ([A])

$[M]_Γ$ defined by induction on $M$:

• $M = x_i, A = A_i$:

[M]_Γ: \quad ![A_1] ⊗ ⋯ ⊗ ![A_i] ⊗ ⋯ ⊗ ![A_n] \\ \overset{w ⊗ ⋯ ⊗ w ⊗ der ⊗ w ⊗ ⋯ ⊗ w}{⟶} 1 ⊗ ⋯ ⊗ 1 ⊗ [A_i] ⊗ 1 ⊗ ⋯ ⊗ 1 ≃ [A_i]
• $M = \underline {0}, A = ι$

[M]_Γ: \quad ![A_1] ⊗ ⋯ ⊗ ![A_n] ⟶ 1 ⊗ ⋯ ⊗ 1 \; ≃\; ! ⊤ \overset{\overline{0}}{⟶} L
• $M = suc(N)$

[M]_Γ: \quad ![Γ] \overset{[N]_Γ^!}{⟶} !L \overset{Suc}{⟶} L

concretely:

[M]_Γ \; ≝ \; \lbrace (u^1, …, u^n, \overline{suc}(u^0)) \; \mid \; ∀ a ∈ u^0, \; (u^1, …, u^n, a) ∈ [N]_Γ\rbrace
• $M = if(N, P, x. Q)$

Γ ⊢ N: ι \qquad Γ ⊢ P: A \qquad Γ, x:ι ⊢ Q: A

By IH:

[N]_Γ: ![Γ] ⟶ L \qquad [P]_Γ: !Γ ⟶ [A] \qquad [Q]_{Γ, x: ι}: ![Γ] ⊗ ![L] ⟶ [A]
\overline{if}: L ⊗ ![A] ⊗ !(!L ⊸ [A]) ⟶ [A]
![Γ] \overset{c}{ ⟶ } ![Γ] ⊗ ![Γ] ⊗ ![Γ] \overset{[N]_Γ ⊗ [P]_Γ^! ⊗ (cur([Q]_{Γ, x:ι}))^!}{⟶} L ⊗ ![A] ⊗ !(!L ⊸ [A]) \overset{\overline{if}}{⟶} [A]
• $M = (N)P$

Γ ⊢ N: B → A \qquad Γ ⊢ P:B
[N]_Γ: \; ![Γ] ⟶ (![B] ⊸ [A])\\ [P]_Γ: \; ![Γ] ⟶ [B]\\
![Γ] \overset{c}{⟶} ![Γ] ⊗ ![Γ] \overset{[N]_Γ ⊗ [P]_Γ^!}{⟶} (![B] ⊸ [A]) ⊗ ![B] \overset{ev}{⟶} [A]
• $M = λx^B.N, \; A = B → C$

Γ, x: B ⊢ N:C\\ [N]_{Γ, x:B}: !Γ ⊗ ![B] ⟶ [C]
[M]_Γ = cur([N]_{Γ, x:B})
• $M = fix\; x^A. N$

Γ, x: A ⊢ N: A
Y_0: !(![A] ⊸ [A]) ⟶ [A]
[N]_{Γ, x:A}: \; ![Γ] ⊗ ![A] ⟶ [A]
cur([N]_{Γ, x:A}): ![Γ] ⟶ (![A] ⊸ [A])
[M]_Γ: \quad ![Γ] \overset{(cur([N]_{Γ,x:A}))^!}{⟶} !(![A] ⊸ [A]) \overset{Y_0}{⟶} [A]

Th: if $Γ ⊢ M:A$ and $M \; β \; M’$, then $[M]_Γ = [M’]_Γ$

Lemma (Substitution lemma): if $Γ, x:A ⊢ M:B$ and $Γ ⊢ N:A$, then

[M[N/x]]: \quad ![Γ] \overset{c}{⟶} ![Γ] ⊗ ![Γ] \overset{id ⊗ [N]_Γ^!}{⟶} ![Γ] ⊗ ![A] \overset{[Γ]_{Γ, x:A}}{⟶} [B]

## Intersection typing system

Prop: If $Γ ⊢ M:A$, $Γ = (x_1: A_1, …, x_n: A_n)$ and

u^i ∈ \vert ! [A_i] \vert \quad i = 1, …, n \text{ and } a ∈ \vert [A] \vert

then $(u^1, …, u^n, a) ∈ [M]_Γ$

iff $x_1: u^1: A_1, …, x_n: u^n: A_n ⊢ M: a: A$ is derivable in the following “semantic typing system” (intersection typing system):

Φ \; ≝ \; (x_1: u^1: A_1, …, x_n: u^n: A_n)

semantic typing context

u^i ∈ \vert ! [A_i] \vert = 𝒫_{fin}(\vert [A_i] \vert)

$\underline Φ = (x_1: A_1, …, x_n: A_n)$ underlying typing context

\cfrac{∃ a^i ∈ u^i \qquad a ≤_{A_i} a_i}{x_1: u^1: A_1, …, x_n: u^n: A_n ⊢ x_i: a: A_i}
\cfrac{}{\underline Φ ⊢ \underline 0: ι}
\cfrac{Φ ⊢ M: a: ι \qquad ∀ a ∈ u^0 ∈ \vert !L \vert \qquad \underline Φ ⊢ M: ι}{\underline Φ ⊢ \underline {suc}(M): \overline {suc}(u^0):ι}

in particular:

\cfrac{\underline Φ ⊢ M: ι}{\underline Φ ⊢ \underline {suc}(M): \overline {suc}(Φ): ι}
\cfrac{Φ ⊢ M: ζ: ι \qquad Φ ⊢ N: a: A \qquad \underline Φ, x: ι ⊢ P: A}{Φ ⊢ if (M, N, x.P): a: A}
\cfrac{Φ ⊢ M: \overline {suc} (u^0): ι \qquad \underline Φ ⊢ N: A \qquad Φ, x: u^0: ι ⊢ P: a: A}{Φ ⊢ if (M, N, x.P): a: A}
\cfrac{Φ ⊢ M: (u^0, b): A → B \qquad \underline Φ ⊢ N: A \qquad Φ ⊢ N: a: A \qquad ∀ a ∈ u^0}{Φ ⊢ (M)N: b: B}
\cfrac{Φ, x:u^0:A ⊢ M: b: B}{Φ ⊢ λx^A. M: (u^0, b): A → B}
\cfrac{Φ, x:u^0:A ⊢ M: a: A \qquad Φ ⊢ fix \; x^A. M: a': A \quad ∀ a' ∈ u^0}{Φ ⊢ fix \; x^A. M: a: A}

## Adequacy

Goal: if $⊢ M: ζ: ι$, then $M \; β_{wh}^\ast \; \underline 0$

Adequacy

Technique: reducibility

Given $A$ and $a ∈ \vert [A] \vert$, we define $\vert a \vert^A$, a set of terms $M$ st $⊢ M: A$ (and for $u^0 ∈ \vert ! [A] \vert$, $\vert u^0 \vert^A_! = \bigcap_{a ∈ u^0} \vert a \vert^A$)

The def is by induction on the size of $a$ (which is a finite term)

### $A = ι$ and $a = ζ$

\vert ζ \vert^ι = \lbrace ⊢ M: ι \; \mid \; M \; β^\ast_{wh} \underline 0\rbrace
a = \overline {suc}(u^0)\\ \vert a \vert^ι = \lbrace ⊢ M: ι \; \mid \; M \; β^\ast_{wh} \; \underline {suc}(N) \text{ with } N ∈ \vert u^0\vert^ι_! = \bigcap_{a ∈ u^0} \vert a \vert^ι\rbrace
\vert (u^0, b) \vert^{A → B} = \lbrace ⊢ M: A → B \; \mid \; ∀ N ∈ \vert u^0\vert^ι_!, \; (M)N ∈ \vert b \vert^B\rbrace

Lemma 1: if $a ≤_{[A]} a’$, then $\vert a' \vert^A ⊆ \vert a \vert^A$

Proof:

$A=ι$:

if $a ≤_L a’$, there are 2 cases:

1. $a=a’= ζ$: trivial
2. $a = \overline{suc}(u^0), \; a’ = \overline{suc}(u^1)$, $M ∈ \vert a \vert^A$ (“$M$ satisifies $a$”)

u^0 ≤_{!L} u^1 \qquad (⟺ ∀ b ∈ u^0, ∃ b' ∈ u^1; \; b ≤_L b')

Let $M ∈ \vert a’ \vert^ι$, that is:

M \; β^\ast_{wh} \; \overline{suc} (N)

where

N ∈ \vert u^1 \vert_!^ι = \bigcap_{b' ∈ u^1} \vert b' \vert^ι \qquad ⟺ ∀ b' ∈ u^1, \; N ∈ \vert b' \vert^ι

We want: $N ∈ \bigcap_{b ∈ u^0} \vert b \vert^ι$

that is:

∀ b ∈ u^0, \; N ∈ \vert b \vert^ι

Let $b ∈ u^0$. There is $b’ ∈ u^1$ st $b ≤_L b’$. And we have:

N ∈ \vert b' \vert^ι \overset{\text{by IH}}{⊆} \vert b \vert^ι

$A = B → C$

$a = (v^0, c), a’ = (v^1, c’)$

$a ≤_{[A]} a’$ means

c ≤_{[C]} c' \quad \text{ and } \quad v^1 ≤_{![B]} v^0

We want:

\vert (v^1, c') \vert^{B → C} ⊆ \vert (v^0, c) \vert^{B → C}

Let $M ∈ \vert (v^1, c’) \vert^{B → C}$. We want: $M ∈ \vert (v^0, c) \vert^{B → C}$.

Let $N ∈ \vert v^0 \vert^B_! ⊆ \vert v^1 \vert^B_!$ because $v^1 ≤_{![B]} v^0$.

And by IH, we want:

N ∈ \bigcap_{b ∈ v^1} \vert b \vert^B

Let $b ∈ v^1$, we need: $N ∈ \vert b \vert^B$.

But $v^1 ≤_{![B]} v^0$, so let $b’ ∈ v^0$ st $b ≤_B b'$

So by IH:

\vert b' \vert^ι ⊆ \vert b \vert^ι

and we have assumed

N ∈ \vert v^0 \vert_!^B ⊆ \vert b' \vert^B

since $b’ ∈ v^0$, so $N ∈ \vert b \vert^ι$.

So $N ∈ \vert v^1 \vert^B_!$. But $M ∈ \vert (v^1, c’) \vert^{B → C}$, so

(M)N ∈ \vert c' \vert^C

But

c ≤_C c'

so by IH:

\vert c' \vert^C ⊆ \vert c \vert^C

so

(M)N ∈ \vert c \vert^C

Lemma 2: If $⊢ M: A$, $⊢ M’: A$, $M \; β_{wh} \; M’$ and $M’ ∈ \vert a \vert^A$, then $M ∈ \vert a \vert^A$.

Proof by induction on the size of $a$.

## Main Statement: Interpretation Lemma/Logical relation lemma

If

x_1: u^1: A_1, …, x_n: u^n: A_n ⊢ M: a: A

Then: for all $N_1, …, N_n$ st $∀i, \qquad N_i ∈ \vert u^i \vert^{A_i}$ one has $M[N_1/x_1, …, N_n/x_n] ∈ \vert a \vert^A$

Corollaries: if $⊢ M: a: A$, then $M ∈ \vert a \vert^A$.

In particular, if $⊢ M: ζ: ι$, then $M ∈ \vert ζ \vert^ι ⟺ M \; β_{wh}^\ast \; \underline 0$

Tags:

Updated: