Lecture 2: Introduction to Domain theory

Teacher: Paul-André Melliès

Intuition: when we have a program $P: A → B$, we can think of it as a function $[A] \overset{[P]}{→} [B]$, where $[A]$ is the domain associated to the type $A$.

Goal: associate to every

  • type $A$ a domain $[A]$
  • $λ$-term $P: A → B$ a continuous function $[A] \overset{[P]}{→} [B]$
Domain:

a partially odered set with extra-properties (every directed $D$ subset has a least upper bound $\bigvee D$ (lub))

Idea: $x ≤ y$ means that $y$ contains more information than $x$. This intuition will be justified later.

(cf. lecture notes)

Property: If $f: (A, ≤_A) → (B, ≤_B)$ is a monotonic function and $ℱ ⊆ A$ has a lub:

\bigvee f(ℱ) ≤ f\left(\bigvee ℱ\right)

Proof: because $f(ℱ) ≤ f(\bigvee ℱ)$ due to $f$ being monotone, and then we use the minimality of the lub.

Example where where this inequality is strict: $A ≝ \underline{ω+1}, \, B ≝ \underline{ω+2}$, $f$ is

  • the identity on $ℕ$
  • $f(ω) = ω+1$

and $ℱ ≝ ℕ$. Then $\bigvee f(ℱ) = ω < ω+1 = f\left(\bigvee ℱ\right)$.

From a computational point of vue: we never have access to $ω$, if contains an infinite amount of information, so $f$ is not continuous when setting $f(ω) = ω+1$ ($ω$ should be mapped to the union of all the approximations of itself to have a continuous function).


Flat domains:

$𝔹_⊥ ≝$

  digraph {
    rankdir=BT;
    ⊥ -> true, false;
  }

$ℕ_⊥ ≝$

  digraph {
    rankdir=BT;
    ⊥ -> 1, 2, 3, ⋯
  }

Streams

Stream:

a function from $ℕ$ to $(A, ≤)$

Stream(A) ≝ A^ℕ

Example: with $A ≝ ℕ_⊥$

⊥ \, ≝ \, (⊥, ⊥, ⋯) ≤ (⊥, 2, ⋯) ≤ (1, 2, ⋯)

Maximal elements: total streams (no coordinate is ‘undefined’: $⊥$). E.g.: the stream of decimals of the number $π$.

We never have access to total stream, but how can we describe them as least upper bounds?

Ex: with the stream $π$ of the decimals of $π$.

Unsuccessful attempt: $π = \bigvee \lbrace y \mid y ≤ π \rbrace$. But there are “infinite” elements as well in $\lbrace y \mid y ≤ π \rbrace$! (ex: streams such that even positions are decimals of $π$, odd ones are undefined $⊥$).

Good notion:

A stream $x$ is called finite/compact:

when $\lbrace n \mid x(n) ≠ ⊥ \rbrace$ is finite

ℱ_x = \lbrace y \text{ finite } \mid y ≤ x \rbrace

Claim: $ℱ_x$ has a lub and

\bigvee ℱ_x = x

Be careful: the set $\lbrace (1, ⊥, ⊥, …), (0, ⊥, ⊥, …) \rbrace$ has no upper bound.

NB: $∀ a, b ∈ ℱ_x$, there exists $c ∈ ℱ_x$ such that $a, b ≤ c$.


Filter:

a non-empty directed set

Domain:

a poset that has a least element $⊥$ such that every directed set has a lub.

Property: if $D$ is a domain, $Stream(D)$ is a domain as well.

Proof:

  • the least element of $Stream(D)$ is the constant stream at $⊥$.
  • the least upper bound of a filter $ℱ$ is taken pointwise. Indeed, for each index $i$, the set $\lbrace x_i \mid x ∈ ℱ\rbrace$ is still a filter, as $ℱ$ is (or alternatively: because the projection $π_i$ upon coordinate $i$ is continuous, so $π_i(ℱ)$ remains a filter).

More generally:

Theorem: If $A$ is a poset and $B$ a domain, $B^A$ is still a domain.

Continuous function $f: D → E$:

is a monotone function that preserves lubs, i.e. for every filter $ℱ$: \bigvee f(ℱ) = f\left(\bigvee ℱ\right)

NB:

  • Equivalently: continuous functions are functions that send filters to filters.

  • While continous may be “computable”, non-continuous functions are never “computable”.

    • Ex: Computing the decimals of $π$: \begin{cases} Stream(ℕ_⊥) ⟶ 𝔹_⊥ \\ \underbrace{x}_{\text{stream of decimals of } π} \mapsto f(x) ≝ true \end{cases}

    $ℱ_x ≝ \lbrace y \text{ finite } \mid y ≤ x \rbrace$

    If $f$ were continuous:

    \bigvee f(ℱ_x) = f\left(\bigvee ℱ_x\right) = f(x) = true

    Then, it means that there exists $y ∈ ℱ_x$ such that $f(y) = true$ ($y$ is a finite approximation of $x$).

    On top of that, we know that

    ∀y ∈ ℱ_x, \; f(y) ≤ true

    that is:

    ∀y ∈ ℱ_x, \; f(y) = true \; ∨ \; f(y) = ⊥

    But any program deciding whether we have all the decimals of $π$ has only a finite execution time! But if you’re not in front of the decimals of $π$, then surely there exists a finite approximation/program such that it fails ⟹ this has to do with semi-decidability.

    (cf. drawing)

$λ$-calculus

Untyped

  • Church-Rosser theorem (confluence theorem)
  • Standardisation theorem: the standard evaluation strategy, whicch evaluates the function befor the argument, terminates if the term is weakly normalising.
  • Every recursive function is $λ$-definable ($Y$ combinator used to encode recursion).

For a long time, people have thought that (untyped) $λ$-calculus was purely syntactic/symbolic, in that there was no model:

D ≅ D ⇒ D

where $D$ would be a space/model of $λ$-terms (as $λ$-abstraction are $λ$-terms as well). In $Set$: no non-trivial solution, because of Russel’s theorem.

Scott, who was working with Strachey (who thought that it was possible to turn imperative programs into $λ$-terms), gave a solution thereof in 1969 by switching from the category $Set$ to the category of Scott domains and continuous functions.

Simply typed

Inference rules/typing judgement:

Logical rules

\cfrac{}{x:A ⊢ x:A}\text{(variable)}\\ \, \\ \cfrac{Γ, x:A ⊢ P:B}{Γ ⊢ λx.P:A ⇒ B}\text{(abstraction)}\\ \, \\ \cfrac{Γ ⊢ P: A ⇒ B \qquad Δ ⊢ Q:A}{Γ, Δ ⊢ PQ: B}\text{(abstraction)}

Structural rules

And then, structural rules: weakening, contraction, and the permutation rule.

\cfrac{Γ ⊢ P:B}{Γ, x:A ⊢ P:B}\text{(weakening)}\\ \, \\ \cfrac{Γ, x:A, y:A ⊢ P:B}{Γ, z:A ⊢ P[x←z, y←z]: B}\text{(contraction)}\\ \, \\ \cfrac{Γ, x:A, y:B, Δ ⊢ P: C}{Γ, y:B,x:A, Δ ⊢ P: C}\text{(permutation)}

Key theorems

Subject reduction: If $Γ ⊢ P:A$ and $P ⟶_β Q$, then $Γ ⊢ Q:A$

Proof: by induction on the derivation tree.

Strong normalisation: If $P$ is simply typed, $P$ is strongly normalising.

NB: in particular, $Ω ≝ δδ$ is not simply typed (as it not normalising).

Curry-Howard isomorphism

Remove the terms in the typing rules ⇒ minimal intuitionistic logic.

BHK interpretation: proof of

  • $A ∧ B$ is a proof of $A$ and a proof of $B$
  • $A ⇒ B$ is an algorithm turning a proof of $A$ into a proof of $B$. But what sort of algorithm? ⟶ a $λ$-term! So $β$-reduction has a corresponding BHK-interpretation.
Logic:
  • Positive side: building data structures
    • Negative side: using these data structures

Orthogonality in logic: proofs of type $A^⊥$ (dual of $A$) are “counter-proofs” of $A$.

Interpretation in $Set$

  • $⟦α⟧ \, ≝ \, X_α$
  • $⟦A ⇒ B⟧ \, ≝ \, ⟦A⟧ ⇒ ⟦B⟧ = {\rm Hom}_{Set}(⟦A⟧, ⟦B⟧)$

A sequent x_1: A_1, …, x_n:A_n ⊢ M:B

is interpreted as a function ⟦A_1⟧ × ⋯ × ⟦A_n⟧ ⟶ ⟦B⟧

Soundness rules

⟦Γ, Δ ⊢ (λx. M)N: B⟧ = ⟦Γ, Δ ⊢ M[x := N]: B⟧
⟦Γ ⊢ (λx. Mx): A ⇒ B⟧ = ⟦Γ ⊢ M: A ⇒ B⟧

Actually, the fact that we have these properties has nothing to do with sets and functions in and by themselves. It’s not specific to $Set$.

⟶ What is the categorical structure of $Set$? A cartesian closed category


Poincaré space in homotopy ≃ Categories with one object are monoids.

Leave a comment