• Non ci sono risultati.

DomainsX-September2011,Swansea Ugode’Liguoro λµ andRelatedCalculi ADomainLogicApproachtoModelsof

N/A
N/A
Protected

Academic year: 2022

Condividi "DomainsX-September2011,Swansea Ugode’Liguoro λµ andRelatedCalculi ADomainLogicApproachtoModelsof"

Copied!
40
0
0

Testo completo

(1)

A Domain Logic Approach to Models of λµ and Related Calculi

Ugo de’Liguoro

joint work with Steffen van Bakel and Franco Barbanera

Domains X - September 2011, Swansea

(2)

Motivations

(3)

Motivations

Parigot’s λµ-calculus interprets classical proofs as functional programs plus (some kind of) continuations

(4)

Motivations

Parigot’s λµ-calculus interprets classical proofs as functional programs plus (some kind of) continuations

Continuations are a powerful concept, but make reasoning hard

(5)

Motivations

Parigot’s λµ-calculus interprets classical proofs as functional programs plus (some kind of) continuations

Continuations are a powerful concept, but make reasoning hard

Intersection type assignment system have been successfully used in the study of the pure λ-calculus, and also of term rewriting, object calculi, etc.

(6)

Motivations

Parigot’s λµ-calculus interprets classical proofs as functional programs plus (some kind of) continuations

Continuations are a powerful concept, but make reasoning hard

Intersection type assignment system have been successfully used in the study of the pure λ-calculus, and also of term rewriting, object calculi, etc.

We take λµ as a significant case study to investigate how intersection systems might be of help to reason about programming with continuations.

(7)

Motivations

Parigot’s λµ-calculus interprets classical proofs as functional programs plus (some kind of) continuations

Continuations are a powerful concept, but make reasoning hard

Intersection type assignment system have been successfully used in the study of the pure λ-calculus, and also of term rewriting, object calculi, etc.

We take λµ as a significant case study to investigate how intersection systems might be of help to reason about programming with continuations.

Previous work (not all successful) by: Dougherty, Ghilezan, Lescanne (on λµ˜µ) and van Bakel (on X , λµ˜µ and λµ).

(8)

Overview

(9)

Overview

continuation semantics (Streicher, Reus) +

domain logic (Abramsky) =

filter model for λµ (like Barendregt, Coppo, Dezani)

(10)

Overview

continuation semantics (Streicher, Reus) +

domain logic (Abramsky) =

filter model for λµ (like Barendregt, Coppo, Dezani)

We eventually show that simply typed λµ-terms (in Parigot’s system) have non trivial types in our system.

Are SN λµ-terms characterizable in our system?

(11)

Continuation Semantics (Streicher-Reus [SR98])

Continuation domain equations

R results

D = [C → R] denotations C = (D×C) continuations

If (R,D,C) are a solution thenD is an extensional λ-model:

D≃ [C → R] ≃ [(D×C) → R] ≃ [D → [C → R]] ≃ [D →D]

while C is the infinite product:

C ≃D×D× · · ·

(12)

Intersection Type Representation of ω-Algebraic Lattices

Given A ∈ ωALG

LA : σ, τ ::= · · · | σ∧τ | ω

A: a preorder s.t.

σ ≤Aω ω is the top

σ ∧ τ ≤ σ, τ

ρ ≤ σ, ρ ≤ τ ⇒ ρ ≤ σ ∧ τ the meet of σ, τ Let

Θ : LA → K(A) be surjective and s.t. σ ≤Aτ ⇔ Θ(σ) ⊒ Θ(τ ) then

FA:= Filt(LA) ≃ Filt(LA/A) ≃ Filt(Kop(A)) ≃ A via the continuous extension of ↑ σ 7→ ↑ Θ(σ)

(13)

Type Theory ≤

R

Fix R ∈ ωALG:

LR : ρ ::= νa | ω | ρ∧ρ (a ∈ K(R))

R: ν =R ω νa⊔ b =Rνa∧νb

b ⊑ a ∈ K(R) ⇒ νa R νb

Proposition

Define FR = Filt(LR/R); then R ≃ FR because of LR/LR ≃ Kop(R) via

Θ(νa) = a, Θ(ω) = ⊥, Θ(ρ∧ρ) = Θ(ρ) ⊔ Θ(ρ)

(14)

Type Theories ≤

C

and ≤

D

Type languages (constructed following the approximants of the inverse-limit construction):

C0 = {⊥}

Dn = [Cn→ R]

Cn+1 = Dn× Cn

D = limnDn

C = limnCn

=⇒

LC0 κ0 ::= ω

LDn δn ::= ρ | κn→ ρ | δn∧δn| ω LCn+1 κn+1 ::= δn× κn| κn∧κn| ω

LD = S

nLDn

LC = S

nLCn

or equivalently

LD: δ ::= ρ | κ → ρ | ω | δ∧δ LC : κ ::= δ × κ | ω | κ∧κ

(15)

Type Theories ≤

C

and ≤

D Theory ≤C:

ωC ω× ω 1× κ1)∧(δ2× κ2) ≤C 1∧κ2) × (κ1∧κ2) δ1Dδ2 κ1C κ2

δ1× κ1Cδ2× κ2

Theory ≤D:

ωDω→ ω ν=Dω→ ν (κ → δ1)∧(κ → δ2) ≤Dκ→ (κ1∧κ2) κ2Cκ1 δ1Dδ2

κ1→ δ1Dκ2→ δ2

(16)

Solution of Continuation Equations

Filter Domains solving Continuation Equations Let FC = Filt(LC/ ≤C) and FD = Filt(LD/ ≤D):

FD ≃ [FC → FR] and FC ≃ FD× FC

Via the mappings F : FD → [FC → FR] and G : [FC → FR] → FD F d k = {ρ ∈ LR | ∃κ → ρ ∈ d. κ ∈ k]}

G f = {V

i ∈Iκi → ρi∈ LD| ∀i ∈ I . ρi∈ f (↑ κi)}

and the mappings H : FC → (FD× FC) and K : (FD× FC) → FC H k = h{δ ∈ LD | δ × κ ∈ k}, {κ ∈ LD | δ × κ ∈ k}i K hd, ki = {δ × κ ∈ LC | δ ∈ d & κ ∈ k}

(17)

The λ-calculus: syntax and continuation semantics

Syntax:

M, N ::= x | λx.M | MN (terms) Semantics [SR98]:

[[·]]D: Trm → Env →D where D=C → R

[[x]]Dek = e xk

[[λx.M]]Dek = [[M]]De[x :=d]k hd,ki =k [[MN]]Dek = [[M]]De h[[N]]De,ki

where e ∈ Env = Var →D,dD andk,kC so that [[M]]Dek ∈ R.

(18)

Type interpretation

[[νa]]R = {r ∈ R | a ⊑ r } [[δ × κ]]R = [[δ]]D× [[κ]]C

[[κ → ρ]]D = {d ∈ D | ∀k ∈ [[κ]]. d(k) ∈ [[ρ]]R} [[ρ]]D = [[ω → ρ]]D

[[ω]]A = A for A = R, D, C

[[σ∧τ ]]A = [[σ]]A∩ [[τ ]]A

Let σ, τ ∈ LA

Soundness of Type Interpretation

1 [[σ]]A ⊆ A and [[σ]]A = ↑ Θ(σ)

2 σ ≤Aτ ⇒ [[σ]]A⊆ [[τ ]]A

(19)

The λ-calculus: continuation models and validity

A continuation model (a model for short) is a triple M = (R, D, C ) satisfying the continuation equations, together with the maps [[·]]R, [[·]]D and [[·]]C.

A basis is a set Γ = {x1: δ1, . . . , xn: δn}, with xi ∈ Var, δi∈ LD. A judgement is an expression Γ ⊢ M : δ, with δ ∈ LD.

The concepts of satisfaction and validity are the standard ones:

e |= Γ ⇔ ∀x : δ ∈ Γ. e(x) ∈ [[δ]]D

Γ |=MM : δ ⇔ ∀e ∈ Env. e |= Γ ⇒ [[M]]De ∈ [[δ]]D Γ |= M : δ ⇔ ∀M. Γ |=MM : δ

where e ∈ Env = Var →D is any environment.

Γ ⊢ M : δ is valid if and only if Γ |= M : δ

(20)

The filter model

Consider the model F = (FR, FD, FC):

(21)

The filter model

Consider the model F = (FR, FD, FC):

Rules from interpretation in F

defininens, right hand side of defining clause = premises definiendum, left hand side of defining clause = conclusion

(22)

The filter model

Consider the model F = (FR, FD, FC):

Rules from interpretation in F

defininens, right hand side of defining clause = premises definiendum, left hand side of defining clause = conclusion Observing that

[[M]]FDe ∈ [[δ]]FD ⇔ δ ∈ [[M]]FDe

(23)

Rules from interpretation clauses: (→ I) and (→ E)

(24)

Rules from interpretation clauses: (→ I) and (→ E)

Consider the interpretation of λx.M in FD:

[[λx.M]]FDe h↑ δ, ↑ κi=[[M]]FDe[x :=↑ δ] ↑ κ where h↑ δ, ↑ κi ≃ ↑ (δ × κ). This reads as the inference rule:

Γ, x : δ ⊢ M : κ → ρ (→ I) Γ ⊢ λx.M : δ × κ → ρ

(25)

Rules from interpretation clauses: (→ I) and (→ E)

Consider the interpretation of λx.M in FD:

[[λx.M]]FDe h↑ δ, ↑ κi=[[M]]FDe[x :=↑ δ] ↑ κ where h↑ δ, ↑ κi ≃ ↑ (δ × κ). This reads as the inference rule:

Γ, x : δ ⊢ M : κ → ρ (→ I) Γ ⊢ λx.M : δ × κ → ρ

Similarly in case of MN, from

[[MN]]FDe ↑ κ=[[M]]FDe h[[N]]FDe, ↑ κi and for any δ ∈ [[N]]FDe we get:

Γ ⊢ M : δ × κ → ρ Γ ⊢ N : δ (→ E) Γ ⊢ MN : κ → ρ

(26)

Remark

By extending LD with δ1→ δ2types and putting δ × κ → ρ =D δ → (κ → ρ) we have by subsumption:

Γ ⊢ λx.M : δ × κ → ρ δ × κ → ρ ≤Dδ → (κ → ρ) Γ ⊢ M : δ → (κ → ρ)

that (a form of) the standard rule (→ I) is admissible:

Γ, x : δ ⊢ M : κ → ρ Γ ⊢ λx.M : δ → (κ → ρ) Similarly for rule (→ E).

(27)

The λµ-calculus: syntax and reduction

λµ syntax:

M, N ::= x | λx.M | MN |µα.Q (terms)

Q ::= [α]M (commands)

Structural substitution:

T[α ⇐ L]≡ the replacement of all[α]N by[α]NLin T Reduction:

(β) : (λx.M)N −→ M[N/x]

(µ) : (µβ.Q)N −→ µβ.Q[β ⇐ N]

(ren) : [α]µβ.Q −→ Q[α/β]

(µη) : µα.[α]M −→ M if α 6∈ fn(M)

(28)

The λµ-calculus: term semantics

Env = (Var →D) + (Name →C) [[·]]D : Trm → Env →D

[[·]]C : Cmd → Env →C [[x]]Dek = e xk

[[λx.M]]Dek = [[M]]De[x :=d]k hd,ki =k [[MN]]Dek = [[M]]De h[[N]]De,ki

[[µα.Q]]Dek = dk hd,ki = [[Q]]Ce[α :=k]

[[[α]M]]Ce = h[[M]]De,ki k = e α

where e ∈ Env, d ∈D and k,k ∈C. We immediately have:

M =βµ N ⇒ ∀e ∈ Env,k ∈C, [[M]]Dek = [[N]]Dek

(29)

Typing judgements

Typing judgements are triples of a basis, a term/command judgement and acontext:

basis: Γ = {x1: δ1, . . . , xn: δn}, with xi ∈ Var, δi ∈ LD

judgement:

term: M : δ with M ∈ Trm, δ ∈ LD

command: Q : κ with Q ∈ Cmd, κ ∈ LC

context: ∆ = {α1: κ1, . . . , αm: κm}, with αi∈ Name, κi∈ LC

A typing judgement has either forms:

Γ ⊢ M : δ | ∆ or Γ ⊢ Q : κ | ∆

(30)

The λµ-calculus: validity revised

Let e ∈ Env:

e |= Γ, ∆ ⇔ ∀x : δ ∈ Γ. e(x) ∈ [[δ]]D & ∀α : κ ∈ ∆. e(α) ∈ [[κ]]C Γ |=MM : δ | ∆ ⇔ ∀e ∈ Env. e |= Γ, ∆ ⇒ [[M]]De ∈ [[δ]]D and similarlyM |= Γ ⊢ Q : κ | ∆

Γ |= M : δ | ∆ (Γ |= Q : κ | ∆) ⇔

∀M. Γ |=MM : δ | ∆ (Γ |=MQ : κ | ∆)

Say that Γ ⊢ M : δ | ∆ (Γ ⊢ Q : κ | ∆) is valid if Γ |= M : δ | ∆ (Γ |= Q : κ | ∆)

(31)

Rules from interpretation clauses: (×)

Consider:

[[[α]M]]FCe =h[[M]]FDe, e αi then for any δ ∈ [[M]]FDe and κ ∈ (e α):

δ × κ ∈ [[[α]M]]FCe from which we obtain the rule

Γ ⊢ M : δ | α : κ, ∆ Γ ⊢ [α]M : δ × κ | α : κ, ∆(×)

(32)

Rules from interpretation clauses: (µ)

Recall that

[[µα.Q]]FDe ↑ κ = d · k where [[Q]]FCe[α :=↑ κ] = hd, ki Filter application is d · k = {ρ | ∃κ → ρ ∈ d. κ ∈ k} hence

→ ρ) × κ ∈ [[Q]]FCe[α :=↑ κ] ⇒ ρ ∈ [[µα.Q]]FDe ↑ κ and we obtain the rule

Γ ⊢ Q : (κ→ ρ) × κ | α : κ, ∆ Γ ⊢ µα.Q : κ → ρ | ∆ (µ)

(33)

The type assignment system ⊢

(Var) Γ, x : δ ⊢ x : δ | ∆

Γ, x : δ ⊢ M : κ → ρ | ∆ (→ I) Γ ⊢ λx.M : δ × κ → ρ | ∆

Γ ⊢ M : δ × κ → ρ | ∆ Γ ⊢ N : δ | ∆ (→ E) Γ ⊢ MN : κ → ρ | ∆

Γ ⊢ M : δ | α : κ, ∆ (×) Γ ⊢ [α]M : δ × κ | α : κ, ∆

Γ ⊢ Q : (κ→ ρ) × κ| α : κ, ∆ (µ) Γ ⊢ µα.Q : κ → ρ | ∆

T = M, Q; A = D, C ; σ, τ ∈ LA: (ω)

Γ ⊢ T : ω | ∆

Γ ⊢ T : σ | ∆ Γ ⊢ T : τ | ∆ (∧) Γ ⊢ T : σ∧τ | ∆

Γ ⊢ T : σ | ∆ σAτ (≤) Γ ⊢ T : τ | ∆

(34)

Properties of the type assignment system

Theorem: subject reduction and expansion If M −→βµ N then

Γ ⊢ M : δ | ∆ ⇔ Γ ⊢ N : δ | ∆

Theorem: soundness and completeness

Γ ⊢ M : δ | ∆ ⇔ Γ |= M : δ | ∆

Proof based on the filter model construction and the fact that [[M]]FDe = {δ | ∃Γ, ∆. e |= Γ, ∆ & Γ ⊢ M : δ | ∆}

(35)

Parigot’s (first order) type assignment system ⊢

P

Propositional types:

A, B ::= ϕ | ⊥A| A → B Rules:

Γ, x : A ⊢ x : A | ∆ Γ, x : A ⊢ M : B | ∆

Γ ⊢ λx.M : A → B | ∆

Γ ⊢ M : A → B | ∆ Γ ⊢ N : A | ∆ Γ ⊢ MN : B | ∆

Γ ⊢ Q : ⊥B | α : A, ∆ Γ ⊢ µα.Q : A | ∆

Γ ⊢ M : A | α : A, ∆ Γ ⊢ [α]M : ⊥A | α : A, ∆

(36)

Translating Parigot’s types into intersection types

(37)

Translating Parigot’s types into intersection types

Take a ∈ R \ {⊥}, and write ν ≡ νa. Consider the maps from propositional types into ours, AC ∈ LC and AD ∈ LD:

ϕC = ν × ω

CA = (AC → ν) × AC (A → B)C = (AC → ν) × BC AD = AC → ν

Write ΓD = {x : AD | x : A ∈ Γ} and ∆C = {α : AC | α : A ∈ ∆}

(38)

Translating Parigot’s types into intersection types

Take a ∈ R \ {⊥}, and write ν ≡ νa. Consider the maps from propositional types into ours, AC ∈ LC and AD ∈ LD:

ϕC = ν × ω

CA = (AC → ν) × AC (A → B)C = (AC → ν) × BC AD = AC → ν

Write ΓD = {x : AD | x : A ∈ Γ} and ∆C = {α : AC | α : A ∈ ∆}

Theorem

1 Γ ⊢P M : A | ∆ ⇒ ΓD M : AD | ∆C

2 Γ ⊢P Q : A | ∆ ⇒ ΓD Q : AC | ∆C

Conjecture: exactly all strongly normalizable terms are typeable in a subsystem ⊢, essentially eliminating ω.

(39)

Conclusions and future work

1 we have defined a type theory which describes a denotational model of λµ

2 the type assignment system induces a filter model of the λµ-calculus

3 all terms which are typeable in Parigot’s (first order) assignment system have a non trivial typing in our system

4 we conjecture that non trivial typing in a proper subsystem of ours characterizes strongly normalizable terms

5 the system we have proposed could characterize other

interesting sets of terms, and more interestingly might provide a tool to investigate Parigot’s computational interpretation of classical proofs

(40)

Reference

Steffen van Bakel, Franco Barbanera and Ugo de’ Liguoro,

“A Filter Model for λµ-calculus”, Proc. of TLCA 2011, LNCS 6690, 213-228; full version:

http://www.di.unito.it/∼deligu/papers/BBL FLM.pdf

Riferimenti

Documenti correlati

At the aim of identifying genes whose expression was modulated by CFC we have compared cDNA obtained from medium-temporal regions of the brains of rats subjected 48 hours before

found that criminal companies have a higher level of indebtedness with respect to non-criminal companies (that have the same dimensions and belong to the same sectors); in

Di Gianantonio, Lenisa (Udine) Innocent Game Semantics via ITAS CSL’13, Torino 21

(iii) With respect to the order ≺ D , every question move has one successor, the corresponding answer; while every answer move a has infinitely many imme- diate successors which are

An alternative description of the interpretation of λ-terms in the game model is given by means of a type assignment system1. The equivalence between this description and

trovare un tipo A tale che Gamma |- M : A sia valido l’analisi semantica risolve problemi di type inference:. nel codice definito il tipo

Comparison with shell model and relativistic mean field calculations demonstrate that the observed effects arise from deformed prolate ground state configurations associated with

[r]