Advanced Semantics of Programming Languages Pierre C LAIRAMBAULT - - PowerPoint PPT Presentation

advanced semantics of programming languages
SMART_READER_LITE
LIVE PREVIEW

Advanced Semantics of Programming Languages Pierre C LAIRAMBAULT - - PowerPoint PPT Presentation

Advanced Semantics of Programming Languages Pierre C LAIRAMBAULT & Colin R IBA LIP - ENS de Lyon Course 03 09/25 C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 1 / 11 Gdels System T Gdels System T


slide-1
SLIDE 1

Advanced Semantics of Programming Languages

Pierre CLAIRAMBAULT & Colin RIBA

LIP - ENS de Lyon

Course 03 09/25

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 1 / 11

slide-2
SLIDE 2

Gödel’s System T

Gödel’s System T

(recap)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 2 / 11

slide-3
SLIDE 3

Gödel’s System T

Motivation

General Idea: ◮ Devise models of programming languages . . .

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 3 / 11

slide-4
SLIDE 4

Gödel’s System T

Motivation

General Idea: ◮ Devise models of programming languages . . . starting from simple settings.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 3 / 11

slide-5
SLIDE 5

Gödel’s System T

Motivation

General Idea: ◮ Devise models of programming languages . . . starting from simple settings.

So Far

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 3 / 11

slide-6
SLIDE 6

Gödel’s System T

Motivation

General Idea: ◮ Devise models of programming languages . . . starting from simple settings.

So Far

Finitary PCF. ◮ Booleans + Divergence (Ω). ◮ Set-theoretic model with bool = {⊥, true, false}

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 3 / 11

slide-7
SLIDE 7

Gödel’s System T

Motivation

General Idea: ◮ Devise models of programming languages . . . starting from simple settings.

So Far

Finitary PCF. ◮ Booleans + Divergence (Ω). ◮ Set-theoretic model with bool = {⊥, true, false} PCF. ◮ Natural numbers + General recursion (Y σ : (σ → σ) → σ).

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 3 / 11

slide-8
SLIDE 8

Gödel’s System T

Motivation

General Idea: ◮ Devise models of programming languages . . . starting from simple settings.

So Far

Finitary PCF. ◮ Booleans + Divergence (Ω). ◮ Set-theoretic model with bool = {⊥, true, false} PCF. ◮ Natural numbers + General recursion (Y σ : (σ → σ) → σ). ◮ There is no canonical choice for Y σ : (σ → σ) − → σ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 3 / 11

slide-9
SLIDE 9

Gödel’s System T

Motivation

General Idea: ◮ Devise models of programming languages . . . starting from simple settings.

So Far

Finitary PCF. ◮ Booleans + Divergence (Ω). ◮ Set-theoretic model with bool = {⊥, true, false} PCF. ◮ Natural numbers + General recursion (Y σ : (σ → σ) → σ). ◮ There is no canonical choice for Y σ : (σ → σ) − → σ Gödel’s System T. ◮ Restrict to recursion over N: Rec(u, v, 0) ⊲ u Rec(u, v, t+1) ⊲ v t Rec(u, v, t)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 3 / 11

slide-10
SLIDE 10

Gödel’s System T

Motivation

General Idea: ◮ Devise models of programming languages . . . starting from simple settings.

So Far

Finitary PCF. ◮ Booleans + Divergence (Ω). ◮ Set-theoretic model with bool = {⊥, true, false} PCF. ◮ Natural numbers + General recursion (Y σ : (σ → σ) → σ). ◮ There is no canonical choice for Y σ : (σ → σ) − → σ Gödel’s System T. ◮ Restrict to recursion over N: Rec(u, v, 0) ⊲ u Rec(u, v, t+1) ⊲ v t Rec(u, v, t) ◮ Allows to see important techniques in a simple setting.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 3 / 11

slide-11
SLIDE 11

Gödel’s System T

Set-Theoretic Denotational Semantics of System T

Normalization. ◮ If ⊢ t : nat then t ⊲∗ n for some (unique) n ∈ N.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 4 / 11

slide-12
SLIDE 12

Gödel’s System T

Set-Theoretic Denotational Semantics of System T

Normalization. ◮ If ⊢ t : nat then t ⊲∗ n for some (unique) n ∈ N. Consequence. ◮ A term ⊢ t : nat → nat induces a function [t] : N → N.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 4 / 11

slide-13
SLIDE 13

Gödel’s System T

Set-Theoretic Denotational Semantics of System T

Normalization. ◮ If ⊢ t : nat then t ⊲∗ n for some (unique) n ∈ N. Consequence. ◮ A term ⊢ t : nat → nat induces a function [t] : N → N. ◮ But can we say that ⊢ t : (nat → nat) → nat induces a function (N → N) → N ?

(Think of Streams(nat) as a subset of (N → N).)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 4 / 11

slide-14
SLIDE 14

Gödel’s System T

Set-Theoretic Denotational Semantics of System T

Normalization. ◮ If ⊢ t : nat then t ⊲∗ n for some (unique) n ∈ N. Consequence. ◮ A term ⊢ t : nat → nat induces a function [t] : N → N. ◮ But can we say that ⊢ t : (nat → nat) → nat induces a function (N → N) → N ?

(Think of Streams(nat) as a subset of (N → N).)

Set-Theoretic Model. nat := N σ → τ := σ → τ = τσ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 4 / 11

slide-15
SLIDE 15

Gödel’s System T

Set-Theoretic Denotational Semantics of System T

Normalization. ◮ If ⊢ t : nat then t ⊲∗ n for some (unique) n ∈ N. Consequence. ◮ A term ⊢ t : nat → nat induces a function [t] : N → N. ◮ But can we say that ⊢ t : (nat → nat) → nat induces a function (N → N) → N ?

(Think of Streams(nat) as a subset of (N → N).)

Set-Theoretic Model. nat := N σ → τ := σ → τ = τσ Natural Numbers. ◮ 0 := 0. ◮ (−)+1 : (n ∈ N) − → (n + 1 ∈ N).

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 4 / 11

slide-16
SLIDE 16

Gödel’s System T

Set-Theoretic Denotational Semantics of System T

Normalization. ◮ If ⊢ t : nat then t ⊲∗ n for some (unique) n ∈ N. Consequence. ◮ A term ⊢ t : nat → nat induces a function [t] : N → N. ◮ But can we say that ⊢ t : (nat → nat) → nat induces a function (N → N) → N ?

(Think of Streams(nat) as a subset of (N → N).)

Set-Theoretic Model. nat := N σ → τ := σ → τ = τσ Natural Numbers. ◮ 0 := 0. ◮ (−)+1 : (n ∈ N) − → (n + 1 ∈ N). Recursor. ◮ Given a ∈ σ and b ∈ nat → σ → σ =

  • σσnat

define Recσ(a, b, n) ∈ σ by induction on n ∈ N: Recσ(a, b, 0) := a and Recσ(a, b, n + 1) := b n Recσ(a, b, n)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 4 / 11

slide-17
SLIDE 17

PCF

The Language PCF

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 5 / 11

slide-18
SLIDE 18

PCF

The Syntax of PCF

Motivation. ◮ A simple functional language with general recursion.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 6 / 11

slide-19
SLIDE 19

PCF

The Syntax of PCF

Motivation. ◮ A simple functional language with general recursion. The Language of PCF. τ, σ ::= nat | σ → τ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 6 / 11

slide-20
SLIDE 20

PCF

The Syntax of PCF

Motivation. ◮ A simple functional language with general recursion. The Language of PCF. τ, σ ::= nat | σ → τ t, u ::= x | λx : σ.t | t u | Y σ | t+1 | t-1 | n | if t then u else v

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 6 / 11

slide-21
SLIDE 21

PCF

The Syntax of PCF

Motivation. ◮ A simple functional language with general recursion. The Language of PCF. τ, σ ::= nat | σ → τ t, u ::= x | λx : σ.t | t u | Y σ | t+1 | t-1 | n | if t then u else v Notes. ◮ We assume an infinite set of variables x, y, z, . . . ◮ We have one numeral n for each n ∈ N.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 6 / 11

slide-22
SLIDE 22

PCF

The Syntax of PCF

Motivation. ◮ A simple functional language with general recursion. The Language of PCF. τ, σ ::= nat | σ → τ t, u ::= x | λx : σ.t | t u | Y σ | t+1 | t-1 | n | if t then u else v Notes. ◮ We assume an infinite set of variables x, y, z, . . . ◮ We have one numeral n for each n ∈ N. ◮ Y is the fixpoint combinator.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 6 / 11

slide-23
SLIDE 23

PCF

The Syntax of PCF

Motivation. ◮ A simple functional language with general recursion. The Language of PCF. τ, σ ::= nat | σ → τ t, u ::= x | λx : σ.t | t u | Y σ | t+1 | t-1 | n | if t then u else v Notes. ◮ We assume an infinite set of variables x, y, z, . . . ◮ We have one numeral n for each n ∈ N. ◮ Y is the fixpoint combinator. Typing Rules. ◮ Adaptation of System T with Γ ⊢ Y σ : (σ → σ) → σ Γ ⊢ n : nat (n ∈ N) Γ ⊢ t : nat Γ ⊢ u : nat Γ ⊢ v : nat Γ ⊢ if t then u else v : nat Γ ⊢ t : nat Γ ⊢ t-1 : nat

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 6 / 11

slide-24
SLIDE 24

PCF

Operational Semantics

Weak Head Reduction. ◮ Usual (weak) call-by-name evaluation.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 7 / 11

slide-25
SLIDE 25

PCF

Operational Semantics

Weak Head Reduction. ◮ Usual (weak) call-by-name evaluation. Basic Rules. (λx.t)u ⊲ t[u/x] n+1 ⊲ n + 1 n + 1-1 ⊲ n 0-1 ⊲ 0 if 0 then u else v ⊲ u if n + 1 then u else v ⊲ v Yt ⊲ t(Yt)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 7 / 11

slide-26
SLIDE 26

PCF

Operational Semantics

Weak Head Reduction. ◮ Usual (weak) call-by-name evaluation. Basic Rules. (λx.t)u ⊲ t[u/x] n+1 ⊲ n + 1 n + 1-1 ⊲ n 0-1 ⊲ 0 if 0 then u else v ⊲ u if n + 1 then u else v ⊲ v Yt ⊲ t(Yt) Congruence Rules. t ⊲ u t v ⊲ u v t ⊲ u t+1 ⊲ u+1 t ⊲ u t-1 ⊲ u-1 t ⊲ u if t then v else w ⊲ if u then v else w

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 7 / 11

slide-27
SLIDE 27

PCF

Operational Semantics

Weak Head Reduction. ◮ Usual (weak) call-by-name evaluation. Basic Rules. (λx.t)u ⊲ t[u/x] n+1 ⊲ n + 1 n + 1-1 ⊲ n 0-1 ⊲ 0 if 0 then u else v ⊲ u if n + 1 then u else v ⊲ v Yt ⊲ t(Yt) Congruence Rules. t ⊲ u t v ⊲ u v t ⊲ u t+1 ⊲ u+1 t ⊲ u t-1 ⊲ u-1 t ⊲ u if t then v else w ⊲ if u then v else w Substitution. ◮ If Γ, x : σ ⊢ t : τ and Γ ⊢ u : σ then Γ ⊢ t[u/x] : τ.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 7 / 11

slide-28
SLIDE 28

PCF

Operational Semantics

Weak Head Reduction. ◮ Usual (weak) call-by-name evaluation. Basic Rules. (λx.t)u ⊲ t[u/x] n+1 ⊲ n + 1 n + 1-1 ⊲ n 0-1 ⊲ 0 if 0 then u else v ⊲ u if n + 1 then u else v ⊲ v Yt ⊲ t(Yt) Congruence Rules. t ⊲ u t v ⊲ u v t ⊲ u t+1 ⊲ u+1 t ⊲ u t-1 ⊲ u-1 t ⊲ u if t then v else w ⊲ if u then v else w Substitution. ◮ If Γ, x : σ ⊢ t : τ and Γ ⊢ u : σ then Γ ⊢ t[u/x] : τ. Subject Reduction. ◮ If Γ ⊢ t : τ and t ⊲ u then Γ ⊢ u : τ.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 7 / 11

slide-29
SLIDE 29

PCF

Operational Semantics

Weak Head Reduction. ◮ Usual (weak) call-by-name evaluation. Basic Rules. (λx.t)u ⊲ t[u/x] n+1 ⊲ n + 1 n + 1-1 ⊲ n 0-1 ⊲ 0 if 0 then u else v ⊲ u if n + 1 then u else v ⊲ v Yt ⊲ t(Yt) Congruence Rules. t ⊲ u t v ⊲ u v t ⊲ u t+1 ⊲ u+1 t ⊲ u t-1 ⊲ u-1 t ⊲ u if t then v else w ⊲ if u then v else w Substitution. ◮ If Γ, x : σ ⊢ t : τ and Γ ⊢ u : σ then Γ ⊢ t[u/x] : τ. Subject Reduction. ◮ If Γ ⊢ t : τ and t ⊲ u then Γ ⊢ u : τ. Normal Forms of Type nat. ◮ If ⊢ t : nat with t in normal form w.r.t. ⊲, then t = n for some n ∈ N.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 7 / 11

slide-30
SLIDE 30

PCF

Examples

(⊲∗ is the reflexive transitive closure of ⊲ and ⊲+ is the transitive closure of ⊲.)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 8 / 11

slide-31
SLIDE 31

PCF

Examples

(⊲∗ is the reflexive transitive closure of ⊲ and ⊲+ is the transitive closure of ⊲.) Conditionals at all types. ◮ For each type σ we have Γ ⊢ t : nat Γ ⊢ u : σ Γ ⊢ v : σ Γ ⊢ (if t then u else v)σ : σ where (if t then u else v)σ→τ := λx : σ.(if t then ux else vx)τ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 8 / 11

slide-32
SLIDE 32

PCF

Examples

(⊲∗ is the reflexive transitive closure of ⊲ and ⊲+ is the transitive closure of ⊲.) Conditionals at all types. ◮ For each type σ we have Γ ⊢ t : nat Γ ⊢ u : σ Γ ⊢ v : σ Γ ⊢ (if t then u else v)σ : σ where (if t then u else v)σ→τ := λx : σ.(if t then ux else vx)τ Divergence. ◮ For each type σ we let Ωσ := Y σ(λx : σ.x) so that Ω ⊲+ Ω ⊲+ . . . .

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 8 / 11

slide-33
SLIDE 33

PCF

Examples

(⊲∗ is the reflexive transitive closure of ⊲ and ⊲+ is the transitive closure of ⊲.) Conditionals at all types. ◮ For each type σ we have Γ ⊢ t : nat Γ ⊢ u : σ Γ ⊢ v : σ Γ ⊢ (if t then u else v)σ : σ where (if t then u else v)σ→τ := λx : σ.(if t then ux else vx)τ Divergence. ◮ For each type σ we let Ωσ := Y σ(λx : σ.x) so that Ω ⊲+ Ω ⊲+ . . . . Addition. ◮ We let add := Y add_rec where add_rec := λf.λx.λy. if x then y else (f (x-1) y)+1

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 8 / 11

slide-34
SLIDE 34

PCF

Examples

(⊲∗ is the reflexive transitive closure of ⊲ and ⊲+ is the transitive closure of ⊲.) Conditionals at all types. ◮ For each type σ we have Γ ⊢ t : nat Γ ⊢ u : σ Γ ⊢ v : σ Γ ⊢ (if t then u else v)σ : σ where (if t then u else v)σ→τ := λx : σ.(if t then ux else vx)τ Divergence. ◮ For each type σ we let Ωσ := Y σ(λx : σ.x) so that Ω ⊲+ Ω ⊲+ . . . . Addition. ◮ We let add := Y add_rec where add_rec := λf.λx.λy. if x then y else (f (x-1) y)+1 ◮ Note that add 0 u ⊲∗ u add n + 1 u ⊲∗ (add n + 1-1 u)+1

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 8 / 11

slide-35
SLIDE 35

PCF

Toward a Denotational Semantics for PCF

Sets with Divergence. ◮ Because of Ωnat, we let nat := N ∪ {⊥}

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 9 / 11

slide-36
SLIDE 36

PCF

Toward a Denotational Semantics for PCF

Sets with Divergence. ◮ Because of Ωnat, we let nat := N ∪ {⊥} ◮ We can give an interpretation of +1, -1 and the conditional if − then − else −.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 9 / 11

slide-37
SLIDE 37

PCF

Toward a Denotational Semantics for PCF

Sets with Divergence. ◮ Because of Ωnat, we let nat := N ∪ {⊥} ◮ We can give an interpretation of +1, -1 and the conditional if − then − else −. A Set-Theoretic Partial Interpretation. ◮ We can get for each type τ a set τ with σ → τ = σ → τ = τσ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 9 / 11

slide-38
SLIDE 38

PCF

Toward a Denotational Semantics for PCF

Sets with Divergence. ◮ Because of Ωnat, we let nat := N ∪ {⊥} ◮ We can give an interpretation of +1, -1 and the conditional if − then − else −. A Set-Theoretic Partial Interpretation. ◮ We can get for each type τ a set τ with σ → τ = σ → τ = τσ ◮ Abstractions and applications can be interpreted as in System T.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 9 / 11

slide-39
SLIDE 39

PCF

Toward a Denotational Semantics for PCF

Sets with Divergence. ◮ Because of Ωnat, we let nat := N ∪ {⊥} ◮ We can give an interpretation of +1, -1 and the conditional if − then − else −. A Set-Theoretic Partial Interpretation. ◮ We can get for each type τ a set τ with σ → τ = σ → τ = τσ ◮ Abstractions and applications can be interpreted as in System T. Difficulty: Y σ : (σ → σ) − → σ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 9 / 11

slide-40
SLIDE 40

PCF

Toward an Interpretation of the Fixpoint Combinator

◮ For each type σ, a natural candidate for Ωσ is ⊥σ, where ⊥σ→τ := (a ∈ σ) − → (⊥τ ∈ τ)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 10 / 11

slide-41
SLIDE 41

PCF

Toward an Interpretation of the Fixpoint Combinator

◮ For each type σ, a natural candidate for Ωσ is ⊥σ, where ⊥σ→τ := (a ∈ σ) − → (⊥τ ∈ τ) Idea: ⊥ means “no information”, reflecting Ω ⊲+ Ω ⊲+ . . . .

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 10 / 11

slide-42
SLIDE 42

PCF

Toward an Interpretation of the Fixpoint Combinator

◮ For each type σ, a natural candidate for Ωσ is ⊥σ, where ⊥σ→τ := (a ∈ σ) − → (⊥τ ∈ τ) Idea: ⊥ means “no information”, reflecting Ω ⊲+ Ω ⊲+ . . . . ◮ Recall that add := Y add_rec where add_rec := λf.λx.λy. if x then y else (f (x-1) y)+1

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 10 / 11

slide-43
SLIDE 43

PCF

Toward an Interpretation of the Fixpoint Combinator

◮ For each type σ, a natural candidate for Ωσ is ⊥σ, where ⊥σ→τ := (a ∈ σ) − → (⊥τ ∈ τ) Idea: ⊥ means “no information”, reflecting Ω ⊲+ Ω ⊲+ . . . . ◮ Recall that add := Y add_rec where add_rec := λf.λx.λy. if x then y else (f (x-1) y)+1 ◮ Note that add_rec ⊥ a b = if a then b else Ω

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 10 / 11

slide-44
SLIDE 44

PCF

Toward an Interpretation of the Fixpoint Combinator

◮ For each type σ, a natural candidate for Ωσ is ⊥σ, where ⊥σ→τ := (a ∈ σ) − → (⊥τ ∈ τ) Idea: ⊥ means “no information”, reflecting Ω ⊲+ Ω ⊲+ . . . . ◮ Recall that add := Y add_rec where add_rec := λf.λx.λy. if x then y else (f (x-1) y)+1 ◮ Note that add_rec ⊥ a b = if a then b else Ω add_rec (add_rec⊥) a b = if a then b else (if a-1 then b else Ω)+1

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 10 / 11

slide-45
SLIDE 45

PCF

Toward an Interpretation of the Fixpoint Combinator

◮ For each type σ, a natural candidate for Ωσ is ⊥σ, where ⊥σ→τ := (a ∈ σ) − → (⊥τ ∈ τ) Idea: ⊥ means “no information”, reflecting Ω ⊲+ Ω ⊲+ . . . . ◮ Recall that add := Y add_rec where add_rec := λf.λx.λy. if x then y else (f (x-1) y)+1 ◮ Note that add_rec ⊥ a b = if a then b else Ω add_rec (add_rec⊥) a b = if a then b else (if a-1 then b else Ω)+1 ◮ We obtain, for k, m ∈ N and n > 0: (add_recn⊥) k m = k + m if k < n ⊥

  • therwise

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 10 / 11

slide-46
SLIDE 46

PCF

Toward an Interpretation of the Fixpoint Combinator

◮ For each type σ, a natural candidate for Ωσ is ⊥σ, where ⊥σ→τ := (a ∈ σ) − → (⊥τ ∈ τ) Idea: ⊥ means “no information”, reflecting Ω ⊲+ Ω ⊲+ . . . . ◮ Recall that add := Y add_rec where add_rec := λf.λx.λy. if x then y else (f (x-1) y)+1 ◮ Note that add_rec ⊥ a b = if a then b else Ω add_rec (add_rec⊥) a b = if a then b else (if a-1 then b else Ω)+1 ◮ We obtain, for k, m ∈ N and n > 0: (add_recn⊥) k m = k + m if k < n ⊥

  • therwise

◮ This suggests add a b = Yadd_rec a b :=

  • (add_recn⊥) a b

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 10 / 11

slide-47
SLIDE 47

PCF

Toward an Interpretation of the Fixpoint Combinator

◮ For each type σ, a natural candidate for Ωσ is ⊥σ, where ⊥σ→τ := (a ∈ σ) − → (⊥τ ∈ τ) Idea: ⊥ means “no information”, reflecting Ω ⊲+ Ω ⊲+ . . . . ◮ Recall that add := Y add_rec where add_rec := λf.λx.λy. if x then y else (f (x-1) y)+1 ◮ Note that add_rec ⊥ a b = if a then b else Ω add_rec (add_rec⊥) a b = if a then b else (if a-1 then b else Ω)+1 ◮ We obtain, for k, m ∈ N and n > 0: (add_recn⊥) k m = k + m if k < n ⊥

  • therwise

◮ This suggests add a b = Yadd_rec a b :=

  • (add_recn⊥) a b

Idea: ◮ a ∈ τ is “more defined” than ⊥τ ∈ τ.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 10 / 11

slide-48
SLIDE 48

PCF

Toward an Interpretation of the Fixpoint Combinator

◮ For each type σ, a natural candidate for Ωσ is ⊥σ, where ⊥σ→τ := (a ∈ σ) − → (⊥τ ∈ τ) Idea: ⊥ means “no information”, reflecting Ω ⊲+ Ω ⊲+ . . . . ◮ Recall that add := Y add_rec where add_rec := λf.λx.λy. if x then y else (f (x-1) y)+1 ◮ Note that add_rec ⊥ a b = if a then b else Ω add_rec (add_rec⊥) a b = if a then b else (if a-1 then b else Ω)+1 ◮ We obtain, for k, m ∈ N and n > 0: (add_recn⊥) k m = k + m if k < n ⊥

  • therwise

◮ This suggests add a b = Yadd_rec a b :=

  • (add_recn⊥) a b

Idea: ◮ a ∈ τ is “more defined” than ⊥τ ∈ τ. ◮ (add_recn+1⊥) is “more defined” than (add_recn⊥).

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 10 / 11

slide-49
SLIDE 49

PCF

The Information Order

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 11 / 11

slide-50
SLIDE 50

PCF

The Information Order

Definition (The Information Order)

Define ⊑τ by induction on τ: ◮ a ⊑nat b iff a = ⊥ or a = b. ◮ f ⊑σ→τ g iff f(a) ⊑τ g(a) for every a ∈ σ.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 11 / 11

slide-51
SLIDE 51

PCF

The Information Order

Definition (The Information Order)

Define ⊑τ by induction on τ: ◮ a ⊑nat b iff a = ⊥ or a = b. ◮ f ⊑σ→τ g iff f(a) ⊑τ g(a) for every a ∈ σ. As expected, we have ◮ ⊥τ ⊑τ a (for every a ∈ τ)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 11 / 11

slide-52
SLIDE 52

PCF

The Information Order

Definition (The Information Order)

Define ⊑τ by induction on τ: ◮ a ⊑nat b iff a = ⊥ or a = b. ◮ f ⊑σ→τ g iff f(a) ⊑τ g(a) for every a ∈ σ. As expected, we have ◮ ⊥τ ⊑τ a (for every a ∈ τ) ◮ ⊥ ⊑ add_rec⊥ ⊑ . . . ⊑ (add_recn⊥) ⊑ (add_recn+1⊥) ⊑ . . .

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 11 / 11

slide-53
SLIDE 53

PCF

The Information Order

Definition (The Information Order)

Define ⊑τ by induction on τ: ◮ a ⊑nat b iff a = ⊥ or a = b. ◮ f ⊑σ→τ g iff f(a) ⊑τ g(a) for every a ∈ σ. As expected, we have ◮ ⊥τ ⊑τ a (for every a ∈ τ) ◮ ⊥ ⊑ add_rec⊥ ⊑ . . . ⊑ (add_recn⊥) ⊑ (add_recn+1⊥) ⊑ . . . In order to put Y σ f :=

  • n∈N

f n(⊥) we need

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 11 / 11

slide-54
SLIDE 54

PCF

The Information Order

Definition (The Information Order)

Define ⊑τ by induction on τ: ◮ a ⊑nat b iff a = ⊥ or a = b. ◮ f ⊑σ→τ g iff f(a) ⊑τ g(a) for every a ∈ σ. As expected, we have ◮ ⊥τ ⊑τ a (for every a ∈ τ) ◮ ⊥ ⊑ add_rec⊥ ⊑ . . . ⊑ (add_recn⊥) ⊑ (add_recn+1⊥) ⊑ . . . In order to put Y σ f :=

  • n∈N

f n(⊥) we need (a) f n(⊥) to be defined,

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 11 / 11

slide-55
SLIDE 55

PCF

The Information Order

Definition (The Information Order)

Define ⊑τ by induction on τ: ◮ a ⊑nat b iff a = ⊥ or a = b. ◮ f ⊑σ→τ g iff f(a) ⊑τ g(a) for every a ∈ σ. As expected, we have ◮ ⊥τ ⊑τ a (for every a ∈ τ) ◮ ⊥ ⊑ add_rec⊥ ⊑ . . . ⊑ (add_recn⊥) ⊑ (add_recn+1⊥) ⊑ . . . In order to put Y σ f :=

  • n∈N

f n(⊥) we need (a) f n(⊥) to be defined, (b) to satisfy equation Y σ f = f(Y σf)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 11 / 11

slide-56
SLIDE 56

PCF

The Information Order

Definition (The Information Order)

Define ⊑τ by induction on τ: ◮ a ⊑nat b iff a = ⊥ or a = b. ◮ f ⊑σ→τ g iff f(a) ⊑τ g(a) for every a ∈ σ. As expected, we have ◮ ⊥τ ⊑τ a (for every a ∈ τ) ◮ ⊥ ⊑ add_rec⊥ ⊑ . . . ⊑ (add_recn⊥) ⊑ (add_recn+1⊥) ⊑ . . . In order to put Y σ f :=

  • n∈N

f n(⊥) we need (a) f n(⊥) to be defined, (b) to satisfy equation Y σ f = f(Y σf) Consequences.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 11 / 11

slide-57
SLIDE 57

PCF

The Information Order

Definition (The Information Order)

Define ⊑τ by induction on τ: ◮ a ⊑nat b iff a = ⊥ or a = b. ◮ f ⊑σ→τ g iff f(a) ⊑τ g(a) for every a ∈ σ. As expected, we have ◮ ⊥τ ⊑τ a (for every a ∈ τ) ◮ ⊥ ⊑ add_rec⊥ ⊑ . . . ⊑ (add_recn⊥) ⊑ (add_recn+1⊥) ⊑ . . . In order to put Y σ f :=

  • n∈N

f n(⊥) we need (a) f n(⊥) to be defined, (b) to satisfy equation Y σ f = f(Y σf) Consequences. (a) It seems reasonable to ask for ⊥ ⊑ f(⊥) ⊑ . . . ⊑ f n(⊥) ⊑ . . .

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 11 / 11

slide-58
SLIDE 58

PCF

The Information Order

Definition (The Information Order)

Define ⊑τ by induction on τ: ◮ a ⊑nat b iff a = ⊥ or a = b. ◮ f ⊑σ→τ g iff f(a) ⊑τ g(a) for every a ∈ σ. As expected, we have ◮ ⊥τ ⊑τ a (for every a ∈ τ) ◮ ⊥ ⊑ add_rec⊥ ⊑ . . . ⊑ (add_recn⊥) ⊑ (add_recn+1⊥) ⊑ . . . In order to put Y σ f :=

  • n∈N

f n(⊥) we need (a) f n(⊥) to be defined, (b) to satisfy equation Y σ f = f(Y σf) Consequences. (a) It seems reasonable to ask for ⊥ ⊑ f(⊥) ⊑ . . . ⊑ f n(⊥) ⊑ . . . which follows from requiring functions to be monotone.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 11 / 11

slide-59
SLIDE 59

PCF

The Information Order

Definition (The Information Order)

Define ⊑τ by induction on τ: ◮ a ⊑nat b iff a = ⊥ or a = b. ◮ f ⊑σ→τ g iff f(a) ⊑τ g(a) for every a ∈ σ. As expected, we have ◮ ⊥τ ⊑τ a (for every a ∈ τ) ◮ ⊥ ⊑ add_rec⊥ ⊑ . . . ⊑ (add_recn⊥) ⊑ (add_recn+1⊥) ⊑ . . . In order to put Y σ f :=

  • n∈N

f n(⊥) we need (a) f n(⊥) to be defined, (b) to satisfy equation Y σ f = f(Y σf) Consequences. (a) It seems reasonable to ask for ⊥ ⊑ f(⊥) ⊑ . . . ⊑ f n(⊥) ⊑ . . . which follows from requiring functions to be monotone. (b) We will moreover require a form of continuity.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 11 / 11