CiE 2005 Amsterdam - Swansea University

27
CiE 2005 Amsterdam Continuous Semantics for Strong Normalization Ulrich Berger Swansea 1

Transcript of CiE 2005 Amsterdam - Swansea University

Page 1: CiE 2005 Amsterdam - Swansea University

CiE 2005 Amsterdam

Continuous Semantics for Strong Normalization

Ulrich Berger

Swansea

1

Page 2: CiE 2005 Amsterdam - Swansea University

Contents

1. Motivation

2. Normalization by approximation

3. Applications

2

Page 3: CiE 2005 Amsterdam - Swansea University

1. Motivation

Computational content of classical mathematics

1958 Godel Dialectica Interpretation of PA

1962 Spector Dialectica Interpretation of PA2

1998 Berardi,Bezem, Realizability Interpretation of

Coquand Classical Countable Choice

These interpretations use strong computation principles with

difficult termination proofs.

3

Page 4: CiE 2005 Amsterdam - Swansea University

The problem

Given a strongly normalizing type theory and a system of

rewrite rules, show that the combined system is strongly

normalizing.

Example

T + OR :=

Simply typed λ-calculus +

Godel primitive recursion + open recursion:

4

Page 5: CiE 2005 Amsterdam - Swansea University

(λx.M)N = M [N/x]

R0 = x

R(k + 1) = Fk(Rk)

Φf =N Ff(λn, y, h.if y<ρfn then Φ(f ynh) else 0)

where <ρ is wellfounded and

f ynh := λk.

fk if k < n

y if k = n

hk if k > n

5

Page 6: CiE 2005 Amsterdam - Swansea University

Open recursion

Φf =N Ff(λn, y, h.if y<ρfn then Φ(f ynh) else 0)

realizes

Open induction (Raoult 88, Coquand 97)

∀f (∀g <lex f U(g) → U(f)) → ∀f U(f)

(U top. open) which axiomatizes classical analysis (LICS’94)

Note that

{g | g <lex f} = {f ynh | n:N, y: ρ, y <ρ fn, h:N → ρ}

6

Page 7: CiE 2005 Amsterdam - Swansea University

In order to have strong normalization we replace

Φf =N Ff(λn, y, h.if y<ρfn then Φ(f ynh) else 0)

by

Φf =N Ff(λn, y, h.Ψfnyh(y<ρfn))

Ψfnyh #t =N Φ(f ynh)

Ψfnyh #f =N 0

(alternatively we may forbid reduction in the branches of an

if-then-else expression)

7

Page 8: CiE 2005 Amsterdam - Swansea University

2. Normalization by approximation

Idea: Split normalization proof in two parts.

1. Prove normalization for terms without recursion.

2. Prove normalization for terms with recursion through

approximation by terms without recursion

in a denotational model.

8

Page 9: CiE 2005 Amsterdam - Swansea University

Terms

A term system is a functor

T: Const → CountSet

where Const is a subcategory of the category CountSet of

countable sets.

Notation:

Mθ := T(θ)(M)

where θ: C → C ′ is a Const morphism and M ∈ T(C).

9

Page 10: CiE 2005 Amsterdam - Swansea University

Example

Const := category of simply typed constant systems

with type respecting constant substitutions.

T(C) := closed simply typed λ-terms with constructors,

and constants in C.

10

Page 11: CiE 2005 Amsterdam - Swansea University

Models

(valC: DC → DT(C))C∈Const

- D Scott-domain

- valC continuous and natural in C ∈ Const.

[M ]α := valC(α)(M)

(the value of M under the constant interpretation α).

Naturality means that for θ: C → C ′

[M ]C(α ◦ θ) = [Mθ]C′α

11

Page 12: CiE 2005 Amsterdam - Swansea University

Example (ctd.)

D := the coalesced sum (all ⊥s identified) of

Dnat = {⊥, 0, 1, 2, . . .}Dρ→σ = Dρ → Dσ

12

Page 13: CiE 2005 Amsterdam - Swansea University

[x]αη = η(x)

[c]αη = α(c)

([λx M ]αη)(a) = [M ]αηax

[MN ]αη =

([M ]αη)(a) if a := [N ]αη 6= ⊥⊥ otherwise

[0]αη = 0

[S(M)]αη =

n + 1 if n := [M ]αη 6= ⊥⊥ otherwise

13

Page 14: CiE 2005 Amsterdam - Swansea University

Rewrite Structures

(C,→, α)

C ∈ Const

→⊆ T(C)2 (operational semantics)

α ∈ DC (denotational semantics)

What does it mean for the operational and denotational

semantics to ‘fit together’?

14

Page 15: CiE 2005 Amsterdam - Swansea University

Adequate Rewrite Structures

(C,→, α)

Monotonicity If M → N , then [M ]α v [N ]α.

SN If [M ]α 6= ⊥, then M is SN w.r.t. →.

15

Page 16: CiE 2005 Amsterdam - Swansea University

Example (ctd.)

R := (C,→, α) where

C any set of typed constants

→ generated by rewrite rules similar to T + OR

α ∈ DC determined by the rewrite rules

R is monotone (induction on terms).

We will prove that R is also SN.

16

Page 17: CiE 2005 Amsterdam - Swansea University

Rω = (Cω,→ω, αω) approximates R = (C,→, α)

if there exist

θ : Cω → Cθn : C → Cω (n ∈ N)

such that

1. θ ◦ θn = idC.

2. αω ◦ θn v αω ◦ θn+1 and⊔

n∈N αω ◦ θn = α.

3. If Aθ → N and [A]αω 6= ⊥, then A →ω B for some

B ∈ T(Cω) with Bθ = N .

17

Page 18: CiE 2005 Amsterdam - Swansea University

Theorem

If Rω is adequate and approximates R, then R is adequate.

Proof

Assume [M ]α 6= ⊥. Then

[M ]α = [M ]⊔

n∈N

αω ◦ θn =⊔

n∈N

[M ](αω ◦ θn) =⊔

n∈N

[Mθn]αω

Hence [Mθn]αω 6= ⊥ for some n ∈ N.

Since Mθnθ = M , it suffices to show the following claim:

For any A ∈ T(Cω), if [A]αω 6= ⊥, then Aθ is strongly

normalizing.

The claim can be proved by induction on SN(A).

18

Page 19: CiE 2005 Amsterdam - Swansea University

3. Applications

R (as defined previously) is approximated by

Rω := (Cω,→ω, αω) where

Cω := {cn | c ∈ C, n ∈ N}→ω generated by rewrite rules cn+1

~P = Mθn

where c ~P = M is a rewrite rule of R.

αω ∈ DC defined accordingly.

Since Rω is adequate (SN as easy as SN for the simply

typed λ-calculus) it follows that R is adequate.

Hence we have reduced the SN problem to the 6= ⊥ problem.

19

Page 20: CiE 2005 Amsterdam - Swansea University

Theorem

T + OR is strongly normalizing.

Proof

It suffices to show that [M ]α 6= ⊥ for every term.

This can be done using the notion of totality:

For every type ρ the total elements of Dρ are defined in the

obvious way by recursion on ρ.

By induction on M one shows that [M ]α is total

(and hence 6= ⊥)

provided α(c) is total for all c ∈ C.

20

Page 21: CiE 2005 Amsterdam - Swansea University

The problem therefore reduces to showing that all constants

are total:

Godel primitive recursion: straightforward induction.

Open recursion: Use open induction and the fact that

for any continuous function F : Dρ→nat → Dnat the set

U := {f ∈ Dρ→nat | Ff 6= ⊥}

is open.

21

Page 22: CiE 2005 Amsterdam - Swansea University

Recipe for proving SN

In order to show that a given rewrite system based on

pattern matching is SN do the following:

1. Construct a strict domain-theoretic model that interprets

the constants according to the given rewrite rules.

2. Prove that all constants are total.

This assumes that the underlying typed λ-calculus is SN!

22

Page 23: CiE 2005 Amsterdam - Swansea University

Related work

1971 Tait WN for Barrecursion using infinite terms

1976 Vogel SN for Barrecursion

1977 Plotkin Adequacy of call-by-name

w.r.t. domain semantics

1980 Gandy Syntactic strictness argument

(λI-calculus) for WN → SN

23

Page 24: CiE 2005 Amsterdam - Swansea University

1985 Bezem SN for BR without using infinite terms

1995 van de Pol, SN using strict monotone functionals

Schwichtenberg

1999 Blanqui, SN for CC+rewriting using

Jouannaud, syntactic arguments

Okada

24

Page 25: CiE 2005 Amsterdam - Swansea University

References

[1] C. Spector. Provably recursive functionals of analysis: a

consistency proof of analysis by an extension of principles in

current intuitionistic mathematics. In F. D. E. Dekker, editor,

Recursive Function Theory: Proc. Symposia in Pure

Mathematics, volume 5, pages 1–27. American Mathematical

Society, Providence, Rhode Island, 1962.

[2] W.W. Tait. Normal form theorem for barrecursive functions of

finite type. In J.E. Fenstad, editor, Proceedings of the Second

Scandinavian Logic Symposium, pages 353–367. North–Holland,

Amsterdam, 1971.

[3] H. Vogel. Ein starker Normalisationssatz fur die barrekursiven

Funktionale. Archive for Mathematical Logic, 18:81–84, 1985.

25

Page 26: CiE 2005 Amsterdam - Swansea University

[4] G. D. Plotkin. LCF considered as a programming language.

Theoretical Computer Science, 5:223–255, 1977.

[5] M. Bezem. Strong normalization of barrecursive terms without

using infinite terms. Archive for Mathematical Logic, 25:175–181,

1985.

[6] J. van de Pol and H. Schwichtenberg. Strict functionals for

termination proofs. In M. Dezani-Ciancaglini and G. Plotkin,

editors, Typed Lambda Calculi and Applications, volume 902 of

LNCS, pages 350–364. Springer Verlag, Berlin, Heidelberg, New

York, 1995.

26

Page 27: CiE 2005 Amsterdam - Swansea University

[7] S. Berardi, M. Bezem, and T. Coquand. On the computational

content of the axiom of choice. Journal of Symbolic Logic,

63(2):600–622, 1998.

[8] F. Blanqui, J-P. Jouannaud, and M. Okada. The calculus of

algebraic constructions. In P. Narendran and M. Rusinowitch,

editors, Proceedings of RTA’99, number 1631 in LNCS, pages

301–316. Springer Verlag, Berlin, Heidelberg, New York, 1999.

[9] B., P. Oliva. Modified bar recursion and classical dependent

choice. In Logic Colloquium 2001. Springer, to appear.

[10] B. A computational interpretation of open induction. In

F. Titsworth, editor, Proceedings of the Ninetenth Annual IEEE

Symposium on Logic in Computer Science, pages 326–334. IEEE

Computer Society, 2004.

27