Classical Combinatory Logic Karim Nour LAMA - Equipe de logique - - PDF document

classical combinatory logic
SMART_READER_LITE
LIVE PREVIEW

Classical Combinatory Logic Karim Nour LAMA - Equipe de logique - - PDF document

Classical Combinatory Logic Karim Nour LAMA - Equipe de logique Universit e de Savoie 73376 Le Bourget du Lac France e-mail: nour@univ-savoie.fr and some helpful discussions with Ren e David 1 Content 1. (Ordinary) Combinatory Logic


slide-1
SLIDE 1

Classical Combinatory Logic

Karim Nour

LAMA - Equipe de logique Universit´ e de Savoie 73376 Le Bourget du Lac France e-mail: nour@univ-savoie.fr and some helpful discussions with

Ren´ e David

1

slide-2
SLIDE 2

Content

  • 1. (Ordinary) Combinatory Logic
  • 2. Classical Combinatory Logic (Karim Nour)
  • 3. Strong Normalization (Ren´

e David)

2

slide-3
SLIDE 3

Combinatory Logic CL

3

slide-4
SLIDE 4

The λ-calculus

  • The terms

t := x | λx.t | (t t)

  • The reduction rule

(λx.u v) → u[x := v]

  • The typing rules

Γ, x : A ⊢ x : A Γ, x : A ⊢ u : B Γ ⊢ λx.u : A → B Γ ⊢ u : A → B Γ ⊢ v : A Γ ⊢ (u v) : B

4

slide-5
SLIDE 5

The combinatory logic

  • The terms

T := x | K | S | (T T)

  • The reduction rules

(K U V ) ⊲ U (S U V W) ⊲ ((U W) (V W))

  • The typing rules

Γ, x : A ⊢ x : A Γ ⊢ K : A → (B → A) Γ ⊢ S : (A → (B → C)) → ((A → B) → (A → C)) Γ ⊢ U : A → B Γ ⊢ V : A Γ ⊢ (U V ) : B

5

slide-6
SLIDE 6

CL λ-calculus

The coding

ψ(x) = x ψ(K) = λx.λy.x ψ(S) = λx.λy.λz.((x z) (y z)) ψ((U V )) = (ψ(U) ψ(V ))

Theorem

  • If Γ ⊢c U : A, then Γ ⊢λ ψ(U) : A.
  • If U ⊲ V , then ψ(U) →+ ψ(V ).

6

slide-7
SLIDE 7

λ-calculus CL

The coding

φ(x) = x φ(λx.t) = lx(φ(t)) φ((u v)) = (φ(u) φ(v)) where lx(x) = I = (S K K) lx(T) = (K T) if x ∈ V ar(T) lx((U V )) = (S lx(U) lx(V ))

Theorem

  • If Γ ⊢λ t : A, then Γ ⊢c φ(t) : A.
  • (lx(U) V ) ⊲∗ U[x := V ].
  • If u →w v, then φ(u) ⊲+ φ(v).

7

slide-8
SLIDE 8

Classical Combinatory Logic CCL

8

slide-9
SLIDE 9

Add new combinators with appropriate typing rules?

  • ¬¬A → A
  • (¬A → A) → A and ⊥→ A
  • (¬A → ¬B) → (B → A) and ⊥→ A

Problem The reduction rule is complicated and artificial.

9

slide-10
SLIDE 10

Code an existing classical calculus?

  • The λµ-calculus (Parigot)

This reduction rule is problematic since it must somehow “code” the translation. (µa.u v) → µa.u[a :=∗ v]

  • The λµ˜

µ-calculus (Curien and Herbelin) Same problem with the reduction rule λx.u, v.w → v, µx.u, w

  • The λSym-calculus (Barbanera and Berardi)

OK

10

slide-11
SLIDE 11

The types of λSym-calculus

  • Two sets of variables

A = {a, b, ...} and A⊥ = {a⊥, b⊥, ...}.

  • The set of m-types

A ::= a | a⊥ | A ∧ A | A ∨ A

  • The set of types

C ::= A |⊥

  • For an m-type A, A⊥ is defined by:

(a)⊥ = a⊥ and (a⊥)⊥ = a (A∧B)⊥ = A⊥∨B⊥ and (A∨B)⊥ = A⊥∧B⊥ (and thus A⊥⊥ = A).

11

slide-12
SLIDE 12

The terms and the typing rules of λSym-calculus

t := x | t, t | σ1(t) | σ2(t) | λx.t | t ⋆ t Γ, x : A ⊢ x : A Γ ⊢ u : A Γ ⊢ v : B Γ ⊢ u, v : A ∧ B Γ ⊢ t : A Γ ⊢ σ1(t) : A ∨ B Γ ⊢ t : B Γ ⊢ σ2(t) : A ∨ B Γ, x : A ⊢ t :⊥ Γ ⊢ λx.t : A⊥ Γ ⊢ u : A⊥ Γ ⊢ v : A Γ ⊢ u ⋆ v :⊥

12

slide-13
SLIDE 13

The reduction rules of λSym-calculus

(λx.u) ⋆ v → u[x := v] v ⋆ (λx.u) → u[x := v] u, v ⋆ σ1(w) → u ⋆ w u, v ⋆ σ2(w) → v ⋆ w σ1(w) ⋆ u, v → w ⋆ u σ2(w) ⋆ u, v → w ⋆ v λx.(u ⋆ x) → u (1) λx.(x ⋆ u) → u (1) u[x := v] → v (2) (1) x ∈ Fv(u) (2) If u and v with type ⊥, x occurs only once in u and u = x. Lemma If Γ ⊢λs u : A and u →∗ v, then Γ ⊢λs v : A.

13

slide-14
SLIDE 14

The terms of CCL

T := x | K | S | C | P | Q1 | Q2 | (T T) | T ⋆ T

14

slide-15
SLIDE 15

The typing rules of CCL

Γ, x : A ⊢ x : A Γ ⊢ K : A⊥ ∨ (B ∨ A) Γ ⊢ S : (A ∧ (B ∧ C⊥)) ∨ ((A ∧ B⊥) ∨ (A⊥ ∨ C)) Γ ⊢ C : (A ∧ B) ∨ ((A ∧ B⊥) ∨ A⊥) Γ ⊢ P : A⊥ ∨ (B⊥ ∨ (A ∧ B)) Γ ⊢ Q1 : A⊥ ∨ (A ∨ B) Γ ⊢ Q2 : B⊥ ∨ (A ∨ B) Γ ⊢ U : A⊥ ∨ B Γ ⊢ V : A Γ ⊢ (U V ) : B Γ ⊢ U : A⊥ Γ ⊢ V : A Γ ⊢ U ⋆ V :⊥

15

slide-16
SLIDE 16

The typing rules of CCL

Γ, x : A ⊢ x : A Γ ⊢ K : A → (B → A) Γ ⊢ S : (A → (B → C)) → ((A → B) → (A → C)) Γ ⊢ C : (A → B⊥) → ((A → B) → A⊥) Γ ⊢ P : A → (B → (A ∧ B)) Γ ⊢ Q1 : A → (A ∨ B) Γ ⊢ Q2 : B → (A ∨ B) Γ ⊢ U : A → B Γ ⊢ V : A Γ ⊢ (U V ) : B Γ ⊢ U : A⊥ Γ ⊢ V : A Γ ⊢ U ⋆ V :⊥

16

slide-17
SLIDE 17

The reduction rules of CCL

(K U V ) ⊲ U (S U V W) ⊲ ((U W) (V W)) (C U V ) ⋆ W ⊲ (U W) ⋆ (V W) W ⋆ (C U V ) ⊲ (U W) ⋆ (V W) (P U V ) ⋆ (Q1 W) ⊲ U ⋆ W (P U V ) ⋆ (Q2 W) ⊲ V ⋆ W (Q1 W) ⋆ (P U V ) ⊲ W ⋆ U (Q2 W) ⋆ (P U V ) ⊲ W ⋆ V (C (K U) I) ⊲ U (1) (C I (K U)) ⊲ U (1) W[x := (C (K U) (K V ))] ⊲ U ⋆ V (2) (1) I = (S K K) (⊢cc I : A⊥ ∨ A) (2) If W has type ⊥ Lemma If Γ ⊢cc U : A and U ⊲∗ V , then Γ ⊢cc V : A.

17

slide-18
SLIDE 18

The coding: λSym CCL

φ(x) = x φ(λx.t) = lx(φ(t)) φ(u ⋆ v) = φ(u) ⋆ φ(v) φ(u, v) = (P φ(u) φ(v)) φ(σi(t)) = (Qi φ(t)) where lx(x) = I lx(T) = (K T) if x ∈ V ar(T) and T = T1 ⋆ T2 lx((U V )) = (S lx(U) lx(V )) lx(U ⋆ V ) = (C lx(U) lx(V ))

Theorem

  • If Γ ⊢λs t : A, the Γ ⊢cc φ(t) : A.
  • If u →w v, then φ(u) ⊲+ φ(v).

18

slide-19
SLIDE 19

Some definitions

πit = λx.(t⋆σi(x)) and πi1...int = πi1...πint [u, v] = λx.(u ⋆ v, x) Lemma

  • πiu1, u2 →∗ ui.
  • If Γ ⊢λs t : A1 ∧ A2, then Γ ⊢λs πit : Ai.
  • If Γ ⊢λs u : A⊥ ∨ B and Γ ⊢λs v : A,

then Γ ⊢λs [u, v] : B.

19

slide-20
SLIDE 20

Example

Let K = λx.(π1x ⋆ π22x).

  • ⊢λc K : A⊥ ∨ (B ∨ A)

x : A ∧ (B⊥ ∧ A⊥) π1x : A x : A ∧ (B⊥ ∧ A⊥) π2x : B⊥ ∧ A⊥ π22x : A⊥ π1x ⋆ π22x :⊥ K : A⊥ ∨ (B ∨ A)

  • [[K, u], v] →∗ u

[[K, u], v] → [λy.(u ⋆ π2y), v] → λz.u ⋆ z → u

20

slide-21
SLIDE 21

The coding: CCL λSym

ψ(x) = x ψ(K) = λx.(π1x ⋆ π22x) ψ(S) = λx.([[π1x, π122x], [π12x, π122x]] ⋆ π222x) ψ(C) = λx.([π1x, π22x] ⋆ [π12x, π22x]) ψ(P) = λx.(π1x, π12x ⋆ π22x) ψ(Q1) = λx.(σ1(π1x) ⋆ π2x) ψ(Q2) = λx.(σ2(π1x) ⋆ π2x) ψ((U V )) = [ψ(U), ψ(V )] ψ(U ⋆ V ) = ψ(U) ⋆ ψ(V )

Theorem

  • If Γ ⊢cc U : A, then Γ ⊢λs ψ(U) : A.
  • If U ⊲ V , then ψ(U) →+ ψ(V ).

21

slide-22
SLIDE 22

Strong Normalization (SN)

(Ren´

e David)

22

slide-23
SLIDE 23

Proofs of SN for λSym

  • 1. The original one: using candidates of re-

ducibility defined by a fix point and thus not arithmetical.

  • 2. A proof (by P. Battyanyi) adapted from our

proof for the symmetric λµ-calculus and the λµ˜ µ-calculus.

  • 3. A proof using CCL?

23

slide-24
SLIDE 24

The problem

We would like

  • 1. SN of CCL?
  • 2. (SN of CCL

⇒ SN of λSym)? But

  • If u →w v, then φ(u) ⊲+ φ(v).

does not implies 2.

24

slide-25
SLIDE 25

The solution

V SN: stronger notion of SN.

  • 1. V SN of CCL?
  • 2. (φ(t) ∈ V SN

⇒ t ∈ SN)?

25