• Aucun résultat trouvé

Execution Time of $\lambda$-Terms via Denotational Semantics and Intersection Types

N/A
N/A
Protected

Academic year: 2021

Partager "Execution Time of $\lambda$-Terms via Denotational Semantics and Intersection Types"

Copied!
43
0
0

Texte intégral

(1)

HAL Id: inria-00319822

https://hal.inria.fr/inria-00319822

Submitted on 9 Sep 2008

HAL is a multi-disciplinary open access

archive for the deposit and dissemination of

sci-entific research documents, whether they are

pub-lished or not. The documents may come from

teaching and research institutions in France or

abroad, or from public or private research centers.

L’archive ouverte pluridisciplinaire HAL, est

destinée au dépôt et à la diffusion de documents

scientifiques de niveau recherche, publiés ou non,

émanant des établissements d’enseignement et de

recherche français ou étrangers, des laboratoires

publics ou privés.

and Intersection Types

Daniel de Carvalho

To cite this version:

Daniel de Carvalho. Execution Time of λ-Terms via Denotational Semantics and Intersection Types.

[Research Report] RR-6638, INRIA. 2008, pp.39. �inria-00319822�

(2)

a p p o r t

d e r e c h e r c h e

0

2

4

9

-6

3

9

9

IS

R

N

IN

R

IA

/R

R

--6

6

3

8

--F

R

+

E

N

G

Thème SYM

Execution Time of λ-Terms via Denotational

Semantics and Intersection Types

Daniel de Carvalho

N° 6638

(3)
(4)

Centre de recherche INRIA Nancy – Grand Est

LORIA, Technopôle de Nancy-Brabois, Campus scientifique,

Danielde Carvalho

ThèmeSYMSystèmessymboliques Équipe-ProjetCALLIGRAMME

Rapportderecherche n°6638septembre200839pages

Abstract: Themultisetbasedrelationalsemanticsforlinearlogicinducesasemantics forthetypefree

λ

-calculus. Thisoneisbuiltonnon-idempotentintersectiontypes. We provethat thesize ofthederivationsandthesizeofthetypesarecloselyrelatedtothe executiontimeof

λ

-termsinaparticularenvironmentmachine,Krivine'smachine. Key-words:

λ

-calculus, denotational semantics, intersection types, computational complexity.

Thisisaneditedversionof[deCarvalho2006 ].

(5)

dénotationnelle et les types avec intersection

Résumé : Lasémantiquerelationnellemulti-ensembliste delalogique linéaireinduit une sémantique du

λ

-calcul non typé. Celle-ci est construite sur des types avec une intersection non-idempotente. Nous prouvons que la taille des dérivations et la taille destypessontétroitementliéesautempsd'exécution des

λ

-termes dansunemachineà environnementparticulière,lamachinedeKrivine.

Mots-clés :

λ

-calcul,sémantiquedénotationnelle,typesavec intersection, complexité ducalcul.

(6)

Introduction

This paper presents a work whose aim is to obtain information on execution time of

λ

-termsbysemanticmeans.

Executiontimemeansthenumberofstepsinacomputationalmodel. Asin[EhrhardandRegnier 2006], thecomputationalmodelconsideredinthispaperwillbeKrivine'smachine,amore

real-isticmodelthan

β

-reduction. Indeed,Krivine'smachineimplements(weak)headlinear reduction: in onestep, wecan do atmostonesubstitution. Inthis paper,weconsider twovariantsofthismachine: therstone(Denition4)computesthehead-normalform ofany

λ

-term(ifitexists)andthesecondone(Denition11)computesthenormalform ofany

λ

-term(if itexists).

Thefundamentalideaofdenotationalsemanticsisthatpropositionsshouldbe inter-pretedastheobjectsofacategory

C

andproofsshould beinterpretedasmorphismsin

C

in such a way that if aproof

Π

reduces to aproof

Π

0

bycut-elimination, then they are interpreted by the samemorphism. By the Curry-Howard isomorphism, a simply typed

λ

-termis aproofin intuitionisticlogic. Now,theintuitionisticfragmentoflinear logic[Girard1987]isarenementofintuitionisticlogic. Thismeansthatwhenwehave a categorical structure

(C, . . .)

to interpret intuitionistic linear logic, one can derive a category

K

thatisamodelofintuitionisticlogic.

Linearlogichasvariousdenotationalsemantics;oneoftheseisthemultisetbased re-lationalsemanticsinthecategoryRelofsetsandrelationswiththecomonadassociated to the nite multisetsfunctor (see [TortoradeFalco2000] for interpretations of proof-netsandAppendixof[BucciarelliandEhrhard2001]forinterpretationsofderivationsof sequentcalculus). Here,thecategory

K

is acategoryequivalentto theKleislicategory of this comonad. Thesemanticswe obtainis non-uniform in the followingsense : the interpretationofafunctioncontainsinformationaboutitsbehaviouronchimerical argu-ments(seeExample18foranillustrationofthisfact). Aswewanttoconsidertypefree

λ

-calculus, wewill consider

λ

-algebrasin

K

. We willput semanticsof

λ

-terms inthese

λ

-algebrasinalogicalframework,usingintersectiontypes.

The intersection types system that we consider (System

R

, dened in Subsection 3.1)isareformulationofthatof[Coppoetal. 1980];inparticular,itlacksidempotency, asSystem

λ

in [Kfoury2000] and System

I

in [NeergaardandMairson2004] and con-trary to System

I

of [Kfouryetal. 1999]. So, we stress the fact that the semantics of [Coppoetal. 1980] can be reconstructed in a natural way from the nite multisets relationalmodeloflinearlogicusingtheKleisliconstruction.

Now,if

v

and

u

aretwoclosednormal

λ

-terms,wecanwonder 1. Isitthecasethatthe

λ

-term

(v)u

is(head) normalizable?

2. If the answer to the previous question is positive, what is the number of steps leadingtothe(principalhead)normalform?

Themain point ofthepaperisto showthat itis possibleto answerbothquestions by onlyreferringtothesemantics

JvK

and

JuK

of

v

and

u

respectively. Theanswertotherst questionis given in Section 4 (Corollary 34)and is asimple adaptationof well-known results. Theanswerto thesecond questionisgivenin Section5.

Thepaper[Ronchi DellaRocca1988]presentedaprocedurethatcomputesanormal form ofany

λ

-term(if itexists) byndingits principaltyping(if it exists). InSection 5, we present some quantitative resultsaboutthe relation between the typesand this computation. Inparticular,weprovethatthenumberofstepsof executionofa

λ

-term intherstmachineisthesizeoftheleastderivationofthe

λ

-terminSystem

R

(Theorem

(7)

44)andproveasimilarresultforthesecondmachine(Theorem50). Weendbyproving trulysemanticmeasuresofexecutiontimeinSubsection5.4andSubsection5.5.

Notation. Wedenote by

Λ

theset of

λ

-terms,by

V

theset of variablesand, forany

λ

-term

t

,by

F V (t)

thesetoffreevariablesin

t

.

WeuseKrivine'snotationfor

λ

-termsi.e.

λ

-term

v

applied to

u

isnoted

(v)u

. Weusethenotation

[ ]

formultisetswhilethenotation

{ }

is,asusual,forsets. The pairwise unionof multisets given byterm-by-termaddition of multiplicities is denoted bya

+

sign and,followingthis notation,thegeneralizedunionisdenoted bya

P

sign. Theneutralelementforthisoperation,theemptymultiset,isdenotedby

[]

.

1 Krivine's machine

We introduce two variants of a machine presented in [Krivine2007] that implements call-by-name. Moreprecisely,theoriginalmachineperformsweakheadlinearreduction, whereasthemachine presentedin Subsection1.2 performsheadlinear reduction. Sub-section1.3slightlymodiesthelattermachineastocomputethe

β

-normalformofany normalizableterm.

1.1 Execution of States

Webeginwiththedenitionsoftheset

E

ofenvironmentsandoftheset

C

ofclosures. Set

E =

S

p∈N

E

p

andset

C =

S

p∈N

C

p

,where

E

p

and

C

p

are denedbyinduction on

p

:

ˆ If

p = 0

,then

E

p

= {∅}

and

C

p

= Λ × {∅}

.

ˆ

E

p+1

isthesetofpartialmaps

V → C

p

,whosedomainisnite,and

C

p+1

= Λ×E

p+1

. For

e ∈ E

,

d(e)

denotestheleastinteger

p

suchthat

e ∈ E

p

.

For

c = (t, e) ∈ C

,wedene, byinduction on

d(e)

,

c = t[e] ∈ Λ

: ˆ If

d(e) = 0

,then

t[e] = t

.

ˆ Assume

t[e]

denedfor

d(e) = d

. If

d(e) = d + 1

, then

t[e] = t[c

1

/x

1

, . . . , c

m

/x

m

]

, with

{x

1

, . . . , x

m

} =

dom

(e)

and,for

1 ≤ j ≤ m

,

e(x

j

) = c

j

.

Astack isanitesequenceofclosures. If

c

isaclosureand

π = (c

1

, . . . , c

q

)

isastack, then

c.π

willdenotethestack

(c, c

1

, . . . , c

q

)

. Wewilldenoteby



theemptystack.

A state isapair

(c, π)

, where

c

is aclosure and

π

isastack. If

s = (c

0

, (c

1

, . . . , c

q

))

isastack,then

s

willdenotethe

λ

-term

(c

0

)c

1

. . . c

q

.

Denition1 Wesaythat a

λ

-term

t

respectsthevariableconventionifanyvariable is boundatmostonetimein

t

.

For any closure

c = (t, e)

, we dene, by induction on

d(e)

, what it means for

c

to respectthevariableconvention:

ˆ if

d(e) = 0

, then we say that

c

respects the variable convention if, and only if,

t

respectsthe variable convention;

ˆ if

c = (t, {(x

1

, c

1

), . . . , (x

m

, c

m

)})

with

m 6= 0

, then we say that

c

respects the variable conventionif,and onlyif,

(8)



c

1

, . . . , c

m

respectthe variable convention;  andthe variables

x

1

, . . . , x

m

arenotboundin

t

.

Foranystate

s = (c

0

, (c

1

, . . . , c

q

))

,wesaythat

s

respectsthevariableconventionif,and onlyif,

c

0

, . . . , c

q

respectthe variable convention.

Wedenote by

S

the setof the statesthatrespectthe variable convention.

First,wepresenttheexecutionofastate(thatrespectsthevariableconvention). It consists in updatinga closure

(t, e)

andthe stack. If

t

is an application

(v)u

, then we pushthe closure

(u, e)

onthe topof thestackand thecurrentclosureis now

(v, e)

. If

t

is anabstraction,then aclosure is popped anda newenvironment iscreated. If

t

is avariable, thenthecurrentclosureisnowthevalueofthevariable oftheenvironment. Thepartial map

s 

S

s

0

(denedbelow)denes formallythetransition fromastate to anotherstate.

Denition2 Wedeneapartialmapfrom

S

to

S

: forany

s, s

0

∈ S

,thenotation

s 

S

s

0

willmean thatthe map assigns

s

0

to

s

. The valueof the mapat

s

isdenedasfollows:

s 7→

(e(x), π)

if

s = ((x, e), π)

with

x ∈

dom

(e)

notdened if

s = ((x, e), π)

with

x ∈ V

and

x /

dom

(e)

((u, {(x, c)} ∪ e), π

0

)

if

s = ((λx.u, e), c.π

0

)

notdened if

s = ((λx.u, e), )

((v, e), (u, e).π)

if

s = (((v)u, e), π)

Note that in thecase wherethe currentsubterm is anabstraction and the stack is empty, themachinestops: itdoesnot reduce under lambda's. That is why weslightly modifythismachine inthefollowingsubsection.

1.2 A machine computing the principal head normal form Now,themachinehastoreduceunderlambda'sand,inSubsection1.3,themachinewill havetocomputetheargumentsoftheheadvariable. So,weextendthemachinesothat itperformsthereductionofelementsof

K

,where

K =

S

n∈N

K

n

with ˆ

H

0

= V

and

K

0

= S

;

ˆ

H

n+1

= V ∪ {(v)u / v ∈ H

n

and

u ∈ Λ ∪ K

n

}

and

K

n+1

= S ∪ H

n

∪ {λy.k / y ∈ V

and

k ∈ K

n

} .

Set

H =

S

n∈N

H

n

. Wehave

K = S ∪ H ∪

S

n∈N

{λx.k / x ∈ V

and

k ∈ K

n

}

. Remark3 Wehave ˆ

H = {(x)t

1

. . . t

p

/ p ∈ N, x ∈ V, t

1

, . . . , t

p

∈ Λ ∪ K}

ˆ henceany element of

K

canbewrittenaseither

λx

1

. . . . λx

m

.s

with

m ∈ N

,

x

1

, . . . , x

m

∈ V

and

s ∈ S

or either

(9)

Forany

k ∈ K

, wedenoteby

d(k)

theleastinteger

p

suchthat

k ∈ K

p

.

Weextendthedenitionof

s

for

s ∈ S

to

k

for

k ∈ K

. Forthat,weset

t = t

if

t ∈ Λ

. Thisdenitionisbyinduction on

d(k)

:

ˆ if

d(k) = 0

,then

k ∈ S

andthus

k

isalreadydened; ˆ if

k ∈ H

,thenthere aretwocases:

 if

k ∈ V

,then

k

isalreadydened(itis

k

);  else,

k = (v)u

andweset

k = (v)u

;

ˆ if

k = λx.k

0

,then

k = λx.k

0

.

Denition4 We dene a partial map from

K

to

K

: for any

k, k

0

∈ K

, the notation

k 

h

k

0

willmeanthatthe map assigns

k

0

to

k

. The valueof themap at

k

isdened, by inductionon

d(k)

,asfollows:

k 7→

s

0

if

k ∈ S

and

k 

S

s

0

(x)c

1

. . . c

q

if

k = ((x, e), (c

1

, . . . , c

q

)) ∈ S

,

x ∈ V

and

x /

dom

(e)

λx.((u, e), )

if

k = ((λx.u, e), ) ∈ S

notdened if

k ∈ H

λy.k

0

0

if

k = λy.k

0

and

k

0



h

k

0

0

A dierencewiththeoriginalmachine isthatourmachinereducesunder lambda's. Wedenoteby



h

thereexivetransitiveclosureof



h

. Forany

k ∈ K

,

k

is saidto beaKrivinenormalform ifforany

k

0

∈ K

, wedonothave

k 

h

k

0

.

Denition5 For any

k

0

∈ K

, we dene

l

h

(k

0

) ∈ N ∪ {∞}

as follows: if there exist

k

1

, . . . , k

n

∈ K

suchthat

k

i



h

k

i+1

for

0 ≤ i ≤ n − 1

and

k

n

isaKrivinenormalform, thenweset

l

h

(k

0

) = n

,elseweset

l

h

(k

0

) = ∞

.

Proposition 6 For any

s ∈ S

, for any

k

0

∈ K

, if

s

h

k

0

and

k

0

isa Krivine normal form, then

k

0

isa

λ

-termin head normalform. Proof. Byinductionon

l

h

(s)

.

Thebasecaseistrivial,becauseweneverhave

l

h

(s) = 0

. Theinductivestepisdividedintovecases.

ˆ If

s = ((x, e), (c

1

, . . . , c

q

))

,

x ∈ V

and

x /

dom

(e)

, then

s 

h

(x)c

1

. . . c

q

. But

(x)c

1

. . . c

q

is aKrivine normal form and

(x)c

1

. . . c

q

is a

λ

-term in head normal form.

ˆ If

s = ((λx.u, e), π)

and

π

istheemptystack



,then

k

0

= λx.k

00

with

((u, e), )

h

k

00

. Now,byinductionhypothesis,

k

00

isa

λ

-terminheadnormalform,hence

k

0

toois a

λ

-terminheadnormalform.

ˆ If

s = ((x, e), (c

1

, . . . , c

q

))

,

x ∈ V

and

x ∈

dom

(e)

, then

s 

h

(e(x), π)

. Now,

(e(x), π)

h

k

0

,hence,byinductionhypothesis,

k

0

isa

λ

-terminheadnormalform. ˆ If

s = ((λx.u, e), c.π)

,then

s 

h

((u, {(x, c)} ∪ e), π)

. Now,

((u, {(x, c)} ∪ e), π) 

h

k

0

,hence,byinduction hypothesis,

k

0

isa

λ

-terminheadnormalform. ˆ If

s = (((v)u, e), π)

, then

s 

h

((v, e), (u, e).π)

. Now,

((v, e), (u, e).π)

h

k

0

,hence, byinductionhypothesis,

k

0

(10)

output currentsubterm environment stack

(λx.(x)x)λy.y



1

λx.(x)x

(λy.y, ∅)

2

(x)x

{x 7→ (λy.y, ∅)}



3

x

{x 7→ (λy.y, ∅)}

(x, {x 7→ (λy.y, ∅)})

4

λy.y

(x, {x 7→ (λy.y, ∅)})

5

y

{y 7→ (x, {x 7→ (λy.y, ∅)})}



6

x

{x 7→ (λy.y, ∅)}



7

λy.y



8

λy.

y



9

λy.y

Figure1: Example ofcomputationoftheprincipal headnormalform



Example7 Set

s = (((λx.(x)x)λy.y, ∅), )

. Wehave

l

h

(s) = 9

:

s



h

((λx.(x)x, ∅), (λy.y, ∅))



h

(((x)x, {(x, (λy.y, ∅))}), )



h

((x, {(x, (λy.y, ∅))}), (x, {(x, (λy.y, ∅))}))



h

((λy.y, ∅), (x, {(x, (λy.y, ∅))}))



h

((y, {(y, (x, {(x, (λy.y, ∅))}))}), )



h

((x, {(x, (λy.y, ∅))}), )



h

((λy.y, ∅), )



h

λy.((y, ∅), )



h

λy.y

Wepresent thesame computationinamore attractivewayinFigure1.

Lemma8 Forany

k, k

0

∈ K

,if

k 

h

k

0

,then

k →

h

k

0

,where

h

isthereexiveclosure ofthe head reduction.

Proof. Therearetwocases.

ˆ If

k ∈ S

,thentherearevecases.

 If

k = ((x, e), (c

1

, . . . , c

q

))

,

x ∈ V

and

x /

dom

(e)

, then

k = (x)c

1

. . . c

q

and

k

0

= (x)c

1

. . . c

q

= (x)c

1

. . . c

q

: wehave

k = k

0

.

 If

k = ((λx.u, e), π)

and

π

istheemptystack



,then

k = (λx.u)[e] = λx.u[e]

(because

k

respectsthevariableconvention) and

k

0

= λx.((u, e), ) = λx.u[e]

: wehave

k = k

0

.

 If

k = ((x, e), (c

1

, . . . , c

q

))

,

x ∈ V

and

x ∈

dom

(e)

, then

k = e(x)c

1

. . . c

q

and

k

0

= (e(x), (c

1

, . . . , c

q

)) = e(x)c

1

. . . c

q

: wehave

k = k

0

(11)

 If

k = ((λx.u, e), (c, c

1

, . . . , c

q

))

,then

k = ((λx.u)[e])cc

1

. . . c

q

= (λx.u[e])cc

1

. . . c

q

(because

k

respectsthevariableconvention)and

k

0

= ((u, {(x, c)} ∪ e))c

1

. . . c

q

. Now,

k

reducesinasingleheadreductionstepto

k

0

.

 If

k = (((v)u, e), (c

1

. . . c

q

))

, then

k = (((v)u)[e])c

1

. . . c

q

= (v[e])u[e]c

1

. . . c

q

and

k

0

= ((v, e), (u, e).(c

1

, . . . , c

q

)) = (v[e])u[e]c

1

. . . c

q

: wehave

k = k

0

.

ˆ Else,

k = λy.k

0

;then

k = λy.k

0

and

k

0

= λy.k

0

0

= λy.k

0

0

with

k

0



h

k

0

0

: wehave

k

0

h

k

0

0

,hence

k →

h

k

0

.



Theorem9 Forany

k ∈ K

,if

l

h

(k)

isnite, then

k

ishead normalizable. Proof. Byinductionon

l

h

(k)

.

If

l

h

(k) = 0

, then

k ∈ H

, hence

k

can be written as

(x)t

1

. . . t

p

and thus

k

canbe written

(x)t

1

. . . t

p

: itisaheadnormalform. Else,applyLemma8.



Foranyheadnormalizable

λ

-term

t

,wedenoteby

h(t)

thenumberofheadreductions of

t

.

Theorem10 Forany

s = ((t, e), π) ∈ S

,if

s

ishead normalizable,then

l

h

(s)

isnite. Proof. Bywell-foundedinductionon

(h(s), d(e), t)

.

If

h(s) = 0

,

d(e) = 0

and

t ∈ V

,thenwehave

l

h

(s) = 1

. Else,therearevecases.

ˆ In thecase where

t ∈ V ∩

dom

(e)

, wehave

s 

h

(e(t), π)

. Set

s

0

= (e(t), π)

and

e(t) = (t

0

, e

0

)

. Wehave

s = s

0

and

d(e

0

) < d(e)

, thus wecanapply theinduction hypothesis:

l

h

(s

0

)

isniteandthus

l

h

(s) = l

h

(s

0

) + 1

isnite. ˆ Inthecasewhere

t ∈ V

and

t /

dom

(e)

,wehave

l

h

(s) = 1

. ˆ Inthecasewhere

t = (v)u

,wehave

s 

h

((v, e), (u, e).π)

. Set

s

0

= ((v, e), (u, e).π)

. Wehave

s

0

= s

andthuswecanapplytheinductionhypothesis:

l

h

(s

0

)

isniteand thus

l

h

(s) = l

h

(s

0

) + 1

isnite.

ˆ Inthecasewhere

t = λx.u

and

π = 

,wehave

s 

h

λx.((u, e), )

. Set

s

0

= ((u, e), )

. Since

s

respectsthe variable convention, we have

s = λx.u[e] = λx.s

0

. Wehave

h(s

0

) = h(s)

,hencewecanapplytheinductionhypothesis:

l

h

(s

0

)

isniteandthus

l

h

(s) = l

h

(s

0

) + 1

isnite.

ˆ In thecasewhere

t = λx.u

and

π = c.π

0

, wehave

s 

h

((u, {(x, c)} ∪ e), π)

. Set

s

0

= ((u, {(x, c)} ∪ e), π)

. Wehave

h(s

0

) < h(s)

,hencewecanapply theinduction hypothesis:

l

h

(s

0

)

isniteandthus

l

h

(s) = l

h

(s

0

) + 1

isnite.



Werecallthatifa

λ

-term

t

hasahead-normalform,thenthelasttermofthe terminat-ingheadreductionof

t

iscalledtheprincipalheadnormalformof

t

(see[Barendregt1984]). Proposition6,Lemma8andTheorem10showthatforanyheadnormalizable

λ

-term

t

with

t

0

itsprincipal headnormalform,wehave

((t, ∅), )

h

t

0

and

t

0

is aKrivinehead normalform.

(12)

1.3 A machine computing the

β

-normal form

Wenowslightlymodifythemachinesoastocomputethe

β

-normalformofany normal-izable

λ

-term.

Denition11 We dene a partial map from

K

to

K

: for any

k, k

0

∈ K

, the notation

k 

β

k

0

willmeanthat themap assigns

k

0

to

k

. Thevalueof themap at

k

isdened, by inductionon

d(k)

,asfollows:

k 7→

s

0

if

k ∈ S

and

k 

S

s

0

(x)(c

1

, ) . . . (c

q

, )

if

k = ((x, e), (c

1

, . . . , c

q

)) ∈ S

,

x ∈ V

and

x /

dom

(e)

λx.((u, e), )

if

k = ((λx.u, e), ) ∈ S

notdened if

k ∈ V

(v

0

)u

if

k = (v)u

and

v 

β

v

0

(x)u

0

if

k = (x)u

with

x ∈ V

and

u 

β

u

0

λy.k

0

0

if

k = λy.k

0

and

k

0



β

k

0

0

Let uscompare Denition 11with Denition 4. Thedierence isin thecase where thecurrentsubterm ofastateis avariableandwhere thisvariablehasnovaluein the environment: the rstmachine stops, the second machine continues to computeevery argumentofthevariable.

Thefunction

l

β

isdenedas

l

h

(seeDenition5), butforthisnewmachine.

Foranynormalizable

λ

-term

t

,wedenoteby

n(t)

thenumberofleftreductionsof

t

. Theorem12 Forany

s = ((t, e), π) ∈ S

,if

s

isnormalizable, then

l

β

(s)

isnite. Proof. Bywell-foundedinductionon

(n(s), s, d(e), t)

.

If

n(s) = 0

,

s ∈ V

,

d(e) = 0

and

t ∈ V

,thenwehave

l

β

(s) = 1

. Else,therearevecases.

ˆ In thecase where

t ∈ V ∩

dom

(e)

, wehave

s 

β

(e(t), π)

. Set

s

0

= (e(t), π)

and

e(t) = (t

0

, e

0

)

. Wehave

s = s

0

and

d(e

0

) < d(e)

, hencewecanapplytheinduction hypothesis:

l

β

(s

0

)

isniteandthus

l

β

(s) = l

β

(s

0

) + 1

isnite.

ˆ Inthecasewhere

t ∈ V

and

t /

dom

(e)

,set

π = (c

1

, . . . , c

q

)

. Forany

k ∈ {1, . . . , q}

, wehave

n(c

k

) ≤ n(s)

and

c

k

< s

,hencewecanapplytheinductionhypothesison

c

k

: for any

k ∈ {1, . . . , q}

,

l

β

(c

k

)

is nite, hence

l

β

(s) =

P

q

k=1

l

β

(c

k

) + 1

is nite too.

ˆ Inthecasewhere

t = (v)u

,wehave

s 

β

((v, e), (u, e).π)

. Set

s

0

= ((v, e), (u, e).π)

. Wehave

s

0

= s

, hencewecan applythe inductionhypothesis:

l

β

(s

0

)

isnite and thus

l

β

(s) = l

β

(s

0

) + 1

isnite.

ˆ In the case where

t = λx.u

and

π = 

, we have

s 

β

λx.((u, e), )

. Set

s

0

=

((u, e), )

. Since

s

respects thevariable convention, we have

s = λx.u[e] = λx.s

0

. Wehave

n(s

0

) = n(s)

,hencewecanapplytheinductionhypothesis:

l

β

(s

0

)

isnite andthus

l

β

(s) = l

β

(s

0

) + 1

isnite. ˆ In thecasewhere

t = λx.u

and

π = c.π

0

, we have

s 

β

((u, {(x, c)} ∪ e), π)

. Set

s

0

= ((u, {(x, c)} ∪ e), π)

. Wehave

n(s

0

) < n(s)

,hencewecanapply theinduction hypothesis:

l

β

(s

0

)

isniteandthus

l

β

(s) = l

β

(s

0

) + 1

isnite.

(13)

2 A non-uniform semantics

Wedeneherethesemanticsallowingto measureexecutiontime. Wehavein mindthe followingphilosophy: thesemanticsfortheuntyped

λ

-calculuscomefromthesemantics for thetyped

λ

-calculusand any semantics forlinear logicinduces a semanticsfor the typed

λ

-calculus. So,westartfromasemantics

M

forlinearlogic(Subsection2.1),then we present the inducedsemantics

Λ(M)

for the typed

λ

-calculus (Subsection 2.2) and lastly the semantics of theuntyped

λ

-calculusthat weconsider (Subsection 2.3). This semantics is non-uniform: in Subsection 2.4, we give an example for illustrating this point.

Therstworkstacklingtheproblemofgivingageneralcategoricaldenitionofa de-notationalmodeloflinearlogicarethoseofLafont[Lafont1988]andofSeely[Seely1989]. AsfortheworksofBenton,Bierman,HylandanddePaiva,[Bentonet al. 1994],[Bierman1993] and[Bierman1995],theyledtothefollowingaxiomatic: acategoricalmodelofthe mul-tiplicative exponential fragment of intuitionistic linear logic (IMELL) is a quadruple

(C, L, c, w)

suchthat

ˆ

C = (C, ⊗, I, α, λ, ρ, γ)

isaclosedsymmetricmonoidalcategory; ˆ

L = ((T,

m

,

n

), δ, d)

isasymmetricmonoidalcomonadon

C

;

ˆ

c

is amonoidal naturaltransformation from

(T,

m

,

n

)

to

⊗ ◦ ∆

C

◦ (T,

m

,

n

)

and

w

isamonoidalnaturaltransformationfrom

(T,

m

,

n

)

to

C

such that

 for any object

A

of

C

,

((T (A), δ

A

), c

A

, w

A

)

is acocommutativecomonoid in

(C

T

, ⊗

T

, (I,

n

), α, λ, ρ)

 andforany

f ∈ C

T

[(T (A), δ

A

), (T (B), δ

B

)]

,

f

isacomonoid morphism, where

T

is thecomonad

(T, δ, d)

on

C

,

C

T

is the categoryof

T

-coalgebras,

C

is thediagonalmonoidalfunctorfrom

C

to

C × C

and

C

isthemonoidalfunctorthat sendsanyarrowto

id

I

.

Given a categorical model

M

= (C, L, c, w)

of IMELL with

C = (C, ⊗, I, α, λ, ρ, γ)

and

L = ((T,

m

,

n

), δ, d)

,wecandeneacartesianclosedcategory

Λ(M)

suchthat

ˆ theobjectsarenitesequencesofobjectsof

C

ˆ andthearrows

hA

1

, . . . , A

m

i → hB

1

, . . . , B

p

i

aresequences

hf

1

, . . . , f

p

i

whereevery

f

k

isanarrow

N

m

j=1

T (A

j

) → B

k

in

C

.

Hencewecaninterpretsimplytyped

λ

-calculusinthecategory

Λ(M)

. Thiscategory is(weakly)equivalent

1

to afullsubcategoryof

(T, δ, d)

-coalgebrasexhibitedbyHyland. Ifthecategory

C

iscartesian,thenthecategories

Λ(M)

andtheKleislicategoryofthe comonad

(T, δ, d)

are(strongly)equivalent

2

. See[deCarvalho2007]forafullexposition.

2.1 A relational model for linear logic

Thecategoryofsetsandrelationsisdenotedby

Rel

and

denotesitscomposition. The functor

T

from

Rel

to

Rel

isdened bysetting

1

Acategory

C

issaidtobeweaklyequivalenttoacategory

D

ifthereexistsafunctor

F

: C → D

full andfaithfulsuchthateveryobject

D

of

D

isisomorphicto

F

(C)

forsomeobject

C

of

C

.

2

Acategory

C

issaidtobestronglyequivalenttoacategory

D

iftherearefunctors

F

: C → D

and

(14)

ˆ foranyobject

A

of

Rel

,

T (A) = M

f

(A)

,thesetofnitemultisets

a

whosesupport, denoted bySupp

(a)

, isasubsetof

A

;

ˆ and,forany

f ∈ Rel(A, B)

,

T (f ) ∈ Rel(T (A), T (B))

dened by

T (f ) = {([α

1

, . . . , α

n

], [β

1

, . . . , β

n

]) / n ∈ N

and

1

, β

1

), . . . , (α

n

, β

n

) ∈ f } .

Thenaturaltransformation

d

from

T

totheidentityfunctorof

Rel

isdenedbysetting

d

A

= {([α], α) / α ∈ A}

and the naturaltransformation

δ

from

T

to

T ◦ T

by setting

δ

A

= {(a

1

+ . . . + a

n

, [a

1

, . . . , a

n

]) / n ∈ N

and

a

1

, . . . , a

n

∈ T (A)} .

It is easy to show that

(T, δ, d)

isacomonadon

Rel

. Itis well-knownthat thiscomonadcanbeprovided withastructure

M

thatprovidesamodelof(I)MELL.

Thismodelgivesrisetoacartesianclosedcategory

Λ(M)

. 2.2 Interpreting simply typed

λ

-terms

Wedescribethecategory

Λ(M)

inducedbythemodel

M

oflinearlogicpresentedinthe precedingsubsection:

ˆ objectsarenite sequencesofsets;

ˆ arrows

hA

1

, . . . , A

m

i → hB

1

, . . . , B

n

i

aresequences

hf

1

, . . . , f

n

i

whereevery

f

i

isa subset of

(

Q

m

j=1

M

f

(A

j

)) × B

i

with theconvention

(

Q

m

j=1

M

f

(A

j

)) × B

i

= B

i

if

m = 0

;

ˆ if

hf

1

, . . . , f

p

i

isanarrow

hA

1

, . . . , A

m

i → hB

1

, . . . , B

p

i

and

hg

1

, . . . , g

q

i

isanarrow

hB

1

, . . . , B

p

i → hC

1

, . . . , C

q

i

,then

hg

1

, . . . , g

q

i◦

Λ(M)

hf

1

, . . . , f

p

i

is

hh

1

, . . . , h

q

i

with

h

l

=

((

P

p

k=1

P

n

k

i=1

a

i,k

1

, . . . ,

P

p

k=1

P

n

k

i=1

a

i,k

m

), γ) / n

1

, . . . , n

p

∈ N

and for

1 ≤ j ≤ m,

for

1 ≤ k ≤ p,

for

1 ≤ i ≤ n

k

, a

i,k

j

∈ M

f

(A

j

)

s.t.

∃β

1

1

, . . . , β

1

n

1

∈ B

1

, . . . , ∃β

p

1

, . . . , β

n

p

p

∈ B

p

s.t.

(([β

1

1

, . . . , β

1

n

1

], . . . , [β

1

p

, . . . , β

n

p

p

]), γ) ∈ g

l

and for

1 ≤ k ≤ p,

for

1 ≤ i ≤ n

k

, ((a

i,k

1

, . . . , a

i,k

m

), β

k

i

) ∈ f

k

for

1 ≤ l ≤ q

, withtheconventions

((a

1

, . . . , a

m

), γ) = γ

and

(

m

Y

j=1

M

f

(A

j

)) × C

l

= C

l

if

m = 0 .

ˆ theidentityof

hA

1

, . . . , A

m

i

is

hd

1

, . . . , d

m

i

with

d

j

= {(([], . . . , []

|

{z

}

j−1

times

, [α], [], . . . , []

|

{z

}

m−j

times

), α) / α ∈ A

j

} .

Thecategory

Λ(M)

hasthefollowingcartesian closedstructure

(Λ(M), 1, !, &, π

1

, π

2

, h·, ·i

M

, ⇒, Λ,

ev

) :

ˆ theterminalobject

1

istheemptysequence

hi

;

ˆ if

B

1

= hB

1

, . . . , B

p

i

and

B

2

= hB

p+1

, . . . , B

p+q

i

are twosequencesof sets, then

B

1

&B

2

(15)

ˆ if

B

1

= hB

1

, . . . , B

p

i

and

B

2

= hB

p+1

, . . . , B

p+q

i

aretwosequencesofsets,then

π

B

1

1

,B

2

= hd

1

, . . . , d

p

i : B

1

&B

2

→ B

1

in

Λ(M)

and

π

B

2

1

,B

2

= hd

p+1

, . . . , d

p+q

i : B

1

&B

2

→ B

2

in

Λ(M)

with

d

k

= {(( [], . . . , []

|

{z

}

k−1

times

, [β], [], . . . , []

|

{z

}

p+q−k

times

), β) / β ∈ B

k

} ;

ˆ if

f

1

= hf

1

, . . . , f

p

i : C → A

1

and

f

2

= hf

p+1

, . . . , f

p+q

i : C → A

2

in

Λ(M)

, then

hf

1

, f

2

i

M

= hf

1

, . . . , f

p+q

i : C → A

1

&A

2

; and ˆ

hA

1

, . . . , A

m

i ⇒ hC

1

, . . . , C

q

i

isdened byinductionon

m

: 

hi ⇒ hC

1

, . . . , C

q

i = hC

1

, . . . , C

q

i



hA

1

, . . . , A

m+1

i ⇒ hC

1

, . . . , C

q

i

= hhA

1

, . . . , A

m

i ⇒ (M

f

(A

m+1

) × C

1

), . . . ,

hA

1

, . . . , A

m

i ⇒ (M

f

(A

m+1

) × C

q

)i ;

ˆ if

h = hh

1

, . . . , h

q

i : hA

1

, . . . , A

m

i&hB

1

, . . . , B

p

i → hC

1

, . . . , C

q

i

,then

Λ

hB

1

,...,B

p

i

hA

1

,...,A

m

i,hC

1

,...,C

q

i

(h) : hA

1

, . . . , A

m

i → hB

1

. . . , B

p

i ⇒ hC

1

, . . . , C

q

i

isdened byinduction on

p

:  if

p = 0

,then

Λ

hB

1

,...,B

p

i

hA

1

,...,A

m

i,hC

1

,...,C

q

i

(h) = h

;  if

p = 1

,thentherearetwocases:

* in thecase

m = 0

,

Λ

hB

1

,...,B

p

i

hA

1

,...,A

m

i,hC

1

,...,C

q

i

(h) = h

; * in thecase

m 6= 0

,

Λ

hB

1

,...,B

p

i

hA

1

,...,A

m

i,hC

1

,...,C

q

i

(h) = hξ

M

f

(B

1

)

Q

m

j=1

M

f

(A

j

),C

1

(h

1

), . . . , ξ

M

f

(B

1

)

Q

m

j=1

M

f

(A

j

),C

q

(h

q

)i ,

where

ξ

M

f

(B

1

)

Q

m

j=1

M

f

(A

j

),C

l

(h

l

) = {(a, (b, γ)) ; ((a, b), γ) ∈ h

l

} ;

 if

p ≥ 1

,then

Λ

hB

1

,...,B

p+1

i

A,hC

1

,...,C

q

i

(h)

=

Λ

hB

1

,...,B

p

i

A,hM

f

(B

p+1

)×C

1

,...,M

f

(B

p+1

)×C

q

)i

hB

p+1

i

hA

1

,...,A

m

,B

1

,...,B

p

i,hC

1

,...,C

q

i

(h)) ,

where

A = hA

1

, . . . , A

m

i

;

(16)

ˆ ev

C,B

: (B ⇒ C)&B → C

isdenedbysetting ev

hC

1

,...,C

q

i,hB

1

,...,B

p

i

= h

ev

1

hC

1

,...,C

q

i,hB

1

,...,B

p

i

, . . . ,

ev

q

hC

1

,...,C

q

i,hB

1

,...,B

p

i

i

where, for

1 ≤ k ≤ q

, ev

k

hC

1

,...,C

q

i,hB

1

,...,B

p

i

=

(( [], . . . , []

|

{z

}

k−1

times

, [((b

1

, . . . , b

p

), γ)], [], . . . , []

|

{z

}

q−k

times

, b

1

, . . . , b

p

), γ) /

b

1

∈ M

f

(B

1

), . . . , b

p

∈ M

f

(B

p

), γ ∈ C

k

.

2.3 Interpreting type free

λ

-terms

With thecartesianclosedstructure on

Λ(M)

,wehaveasemanticsofthe simplytyped

λ

-calculus. Now, in order to have a semantics of the pure

λ

-calculus, it is therefore enoughto haveareexive object

U

of

Λ(M)

,thatistosaysuchthat

(U ⇒ U ) C U ,

that means that there exist

s ∈ Λ(M)[U ⇒ U, U ]

and

r ∈ Λ(M)[U, U ⇒ U ]

such that

r ◦

Λ(M)

s

is theidentity on

U ⇒ U

. Wewill use thefollowinglemma. We recallthat

hf i

is a retraction of

hgi

in

Λ(M)

meansthat

hf i ◦

Λ(M)

hgi = id

hAi

(see, forinstance, [MacLane1998]). Itisalsosaidthat

(hgi, hf i)

isaretractionpair.

Lemma13 Let

h : A → B

be aninjectionbetween sets. Set

g = {([α], h(α)) : α ∈ A} : M

f

(A) → B

in

Rel

and

f = {([h(α)], α)/α ∈ A} : M

f

(B) → A

in

Rel

.

Then

hgi ∈ Λ(M)(hAi, hBi)

and

hf i

isaretractionof

hgi

in

Λ(M)

. Proof. An easycomputationshowsthatwehave

hf i ◦

Λ(M)

hgi = hf ◦ T (g) ◦ δ

A

i

= hd

A

i .



If

D

is aset,then

hDi ⇒ hDi = hM

f

(D) × Di

. Fromnowon,weassumethat

D

is anon-emptysetandthat

h

isaninjectionfrom

M

f

(D) × D

to

D

. Set

g = {([α], h(α)) / α ∈ M

f

(D) × D} : M

f

(M

f

(D) × D) → D

in

Rel

and

f = {([h(α)], α) / α ∈ M

f

(D) × D} : M

f

(D) → M

f

(D) × D

in

Rel

.

Wehave

(hDi ⇒ hDi) C hDi

and,moreprecisely,

hgi ∈ Λ(M)(hDi ⇒ hDi, hDi)

and

f

isaretractionof

g

. Wecanthereforedenetheinterpretationofany

λ

-term.

(17)

Denition14 Forany

λ

-term

t

possiblycontainingconstantsfrom

P(D)

,forany

x

1

, . . . , x

m

V

distinct suchthat

F V (t) ⊆ {x

1

, . . . , x

m

}

, we dene, by induction on

t

,

JtK

x

1

,...,x

m

(

Q

m

j=1

M

f

(D)) × D

: ˆ

Jx

j

K

x

1

,...,x

m

= {(( [], . . . , []

|

{z

}

j−1

times

, [α], [], . . . , []

|

{z

}

m−j

times

), α) / α ∈ D}

; ˆ for any

c ∈ P(D)

,

JcK

x

1

,...,x

m

= (

Q

m

j=1

M

f

(D)) × c

; ˆ

Jλx.uK

x

1

,...,x

m

= {((a

1

, . . . , a

m

), h(a, α)) / ((a

1

, . . . , a

m

, a), α) ∈ JuK

x

1

,...,x

m

,x

}

; ˆ

J(v)uK

x

1

,...,x

m

=

((

P

n

i=0

a

i

1

, . . . ,

P

n

i=0

a

i

m

), α) / ∃(α

1

, . . . , α

n

)

s.t.

((a

0

1

, . . . , a

0

m

), h([α

1

, . . . , α

n

], α)) ∈ JvK

x

1

,...,x

m

and,for

1 ≤ i ≤ n, ((a

i

1

, . . . , a

i

m

), α

i

) ∈ JuK

x

1

,...,x

m

)

;

withthe conventions

(

Q

m

j=1

M

f

(D)) × D = D

and

((a

1

, . . . , a

m

), α) = α

if

m = 0

. Now,wecandenetheinterpretationofany

λ

-termin anyenvironment. Denition15 For any

ρ ∈ P(D)

V

andfor any

λ

-term

t

possibly containing constants from

P(D)

suchthat

F V (t) = {x

1

, . . . , x

m

}

,weset

JtK

ρ

= {α ∈ D / ((a

1

, . . . , a

m

), α) ∈ JtK

x

1

,...,x

m

and, for

1 ≤ j ≤ m

,

a

i

∈ M

f

(ρ(x

j

))} .

Forany

d

1

, d

2

∈ P(D)

,weset

d

1

∗ d

2

= {α ∈ D / ∃a (h(a, α)) ∈ d

1

andSupp

(a) ⊆ d

2

} .

Thetriple

(P(D), ∗, J−K

)

isa

λ

-algebra(Theorem5.5.6of[Barendregt1984]). But thefollowingproposition,acorollaryofProposition 17,statesthat itisnot a

λ

-model. We recall that a

λ

-model is a

λ

-algebra

(D, ∗, J−K

)

such that the following property, expressingthe

ξ

-rule,holds:

forany

ρ ∈ D

V

, forany

x ∈ V

andforany

λ

-terms

t

1

and

t

2

,wehave

(∀d ∈ D Jt

1

K

ρ[x:=d]

= Jt

2

K

ρ[x:=d]

⇒ Jλx.t

1

K

ρ

= Jλx.t

2

K

ρ

) .

Proposition 16 The

λ

-algebra

(P(D), ∗, J−K

)

isnot a

λ

-model. In otherwords,there exist

ρ ∈ P(D)

V

,

x ∈ V

andtwo

λ

-terms

t

1

and

t

2

suchthat

(∀d ∈ P(D) Jt

1

K

ρ[x:=d]

= Jt

2

K

ρ[x:=d]

and

Jλx.t

1

K

ρ

6= Jλx.t

2

K

ρ

) .

Inparticular,

JtK

ρ

cannotbe denedbyinduction on

t

(aninterpretationby polyno-mialsisneverthelesspossiblein suchawaythat the

ξ

-ruleholds-see [Selinger2002]).

BeforestatingProposition17,werecallthat anyobject

A

ofanycategory

K

witha terminalobjectis said tohave enough points if foranyterminal object

1

of

K

and for any

y, z ∈ K(A, A)

,wehave

(∀x ∈ K(1, A) y ◦

K

x = z ◦

K

x ⇒ y = z) .

Remark: itdoesnotfollownecessarilythat thesameholdsforany

y, z ∈ K(A, B)

. Proposition 17 Let

A

be a non-empty set. Then

hAi

does not have enough points in

(18)

Proof. Let

α ∈ A

. Set

y = {([α], α)} : M

f

(A) → A

in

Rel

and

z = {([α, α], α)} : M

f

(A) → A

in

Rel

.

Wehave

hyi

,

hzi : hAi → hAi

in

Λ(M)

.

Werecall thatthe terminalobjectin

Λ(M)

istheemptysequence

hi

. Now,forany

x : hi → hAi

in

Λ(M)

,wehave

hyi ◦

Λ(M)

x = hzi ◦

Λ(M)

x

.



This proposition explainswhy Proposition 16 holds. A moredirect proof of Propo-sition16 consists byconsidering thetwo

λ

-terms

t

1

= (y)x

and

t

2

= (z)x

with

ρ(y) =

{([α], α)}

and

ρ(z) = {([α, α], α)}

.

2.4 Non-uniformity

Example18illustratesthenon-uniformityofthesemantics. Itisbasedonthefollowing idea.

Considertheprogram

λx.

if

x

then

1

elseif

x

then

1

else

0

applied to a boolean. The second thenis never read. A uniform semanticswould ignoreit. Itisnotthecasewhenthesemanticsisnon-uniform.

Example18 Set

0

= λx.λy.y

and

1

= λx.λy.x

. Assume that

h

is the inclusion from

M

f

(D) × D

to

D

.

Let

γ ∈ D

;set

δ = ([], ([γ], γ))

and

β = ([γ], ([], γ))

. We have ˆ

([([], ([δ], δ))], ([δ], δ)) ∈ J(x)1K

x

; ˆ and

([([], ([δ], δ))], δ) ∈ J(x)10K

x

. Hence wehave

α

1

= ([([], ([δ], δ)), ([], ([δ], δ))], δ) ∈ Jλx.(x)1(x)10K .

Wehave ˆ

([([], ([β], β))], ([β], β)) ∈ J(x)1K

x

; ˆ and

([([β], ([], β))], β) ∈ J(x)10K

x

.

Hence wehave

α

2

= ([([], ([β], β)), ([β], ([], β))], β) ∈ Jλx.(x)1(x)10K .

In anuniform semantics(asin [Girard1986]),the point

α

1

wouldappear inthe se-manticsofthis

λ

-term,butnotthepoint

α

2

,because

[([], ([β], β)), ([β], ([], β))]

corresponds toachimerical argument: theargumentisreadtwiceandprovides twocontradictory val-ues.

3 Non-idempotent intersection types

Fromnowon,

D =

S

n∈N

D

n

,where

D

n

isdenedbyinductionon

n

:

D

0

isanon-empty set

A

that does not contain any pairs and

D

n+1

= A ∪ (M

f

(D

n

) × D

n

)

. We have

D = A ˙∪(M

f

(D) × D)

, where

˙∪

is thedisjointunion;theinjection

h

from

M

f

(D) × D

to

D

will be the inclusion. Hence any element of

D

canbe written

a

1

. . . a

m

α

, where

(19)

ˆ

a

1

. . . a

0

α = α

;

ˆ

a

1

. . . a

m+1

α = (a

1

. . . a

m

, (a

m+1

, α))

.

Intheprecedingsection,wedenedthesemanticsweconsider: Denition 14denes

JtK

x

1

,...,x

m

for any

λ

-term

t

and for any

x

1

, . . . , x

m

∈ V

distinct such that

F V (t) ⊆

{x

1

, . . . , x

m

}

; Denition 15denes

JtK

ρ

forany

λ

-term

t

andfor any

ρ ∈ P(D)

V

. Now, wewantto put this semanticsin alogicalframework: theelementsof

D

are viewedas propositional formulas. More precisely, acomma separatinga multiset of types and a typeisunderstoodasanarrowand anon-emptymultisetis understoodastheuniform conjunctionofitselements(theirintersection). Notethatthismeansweareconsidering acommutativebutnotnecessarilyidempotentintersection.

3.1 System

R

A context

Γ

is afunction from

V

to

M

f

(D)

such that

{x ∈ V / Γ(x) 6= []}

is nite. If

x

1

, . . . , x

m

∈ V

aredistinctand

a

1

, . . . , a

m

∈ M

f

(D)

, then

x

1

: a

1

, . . . , x

m

: a

m

denotes thecontextdenedby

x 7→



a

j

if

x = x

j

[] else

.

Wedenoteby

Φ

thesetofcontexts. For

Γ

1

, Γ

2

∈ Φ

,

Γ

1

+ Γ

2

is thecontext dened by

1

+ Γ

2

)(x) = Γ

1

(x) + Γ

2

(x)

, where the second

+

denotesthesumofmultisetsgivenbyterm-by-termadditionofmultiplicities. Typingrulesconcernjudgementsoftheform

Γ `

R

t : α

,where

Γ

isacontext,

t

isa

λ

-termand

α ∈ D

.

Denition19 Thetypingrules ofSystem

R

arethe following:

x : [α] `

R

x : α

Γ, x : a `

R

v : α

Γ `

R

λx.v : (a, α)

Γ

0

`

R

v : ([α

1

, . . . , α

n

], α)

Γ

1

`

R

u : α

1

, . . . , Γ

n

`

R

u : α

n

n ∈ N

Γ

0

+ Γ

1

+ . . . + Γ

n

`

R

(v)u : α

The typing rule of the application has

n + 1

premisses. In particular, in the case where

n = 0

,weobtainthefollowingrule:

Γ

0

`

R

v : ([], α)

Γ

0

`

R

(v)u : α

forany

λ

-term

u

. So,the emptymultisetplaystheroleoftheuniversaltype

.

Theintersection weconsider isnot idempotentin thefollowingsense: ifaclosed

λ

-term

t

hasthetype

a

1

. . . a

m

α

and,for

1 ≤ j ≤ m

,Supp

(a

0

j

) =

Supp

(a

j

)

,itdoesnotfollow necessarilythat

t

hasthetype

a

0

1

. . . a

0

m

α

. Forinstance,the

λ

-term

λz.λx.(z)x

hastypes

([([α], α)], ([α], α))

and

([([α, α], α)], ([α, α], α))

but not the type

([([α], α)], ([α, α], α))

. Onthecontrary, thesystempresentedin [Ronchi DellaRocca1988] andtheSystem

D

presentedin[Krivine1990]consideranidempotentintersection. System

λ

of[Kfoury2000] and System

I

of[NeergaardandMairson2004] consider anon-idempotentintersection, butthetreatmentofweakeningisnotthesame.

Interestingly,System

R

canbeseenasareformulationofthesytemof[Coppoetal. 1980]. Moreprecisely, typesof System

R

correspond to their normalizedtypes. As stated in Section 5of that paper, theauthors thought that aparticularpropertyshould hold in thecorresponding semantics(assertionvi)of theirTheorem 8. But ourProposition 16 showsthatthisisnotthecase.

(20)

3.2 Relating types and semantics

Weproveinthissubsectionthatthesemanticsofaclosed

λ

-termasdenedinSubsection 2.3 is the set of its typesin System

R

. The following assertionsrelate moreprecisely typesandsemanticsofany

λ

-term.

Theorem20 Forany

λ

-term

t

suchthat

F V (t) ⊆ {x

1

, . . . , x

m

}

,wehave

JtK

x

1

,...,x

m

= {((a

1

, . . . , a

m

), α) ∈ (

m

Y

j=1

M

f

(D)) × D / x

1

: a

1

, . . . , x

m

: a

m

`

R

t : α} .

Proof. Byinductionon

t

.



Corollary21 Forany

λ

-terms

t

and

t

0

suchthat

t =

β

t

0

, if

Γ `

R

t : α

, then we have

Γ `

R

t

0

: α

.

Theorem22 Forany

λ

-term

t

andforany

Γ ∈ Φ

,wehave

{α ∈ D / Γ `

R

t : α} ⊆ {α ∈ D / ∀ρ ∈ P(D)

V

(∀x ∈ V Γ(x) ∈ M

f

(ρ(x)) ⇒ α ∈ JtK

ρ

)}.

Proof. ApplyTheorem20.



Remark23 Thereverseinclusion isnottrue.

Theorem24 Forany

λ

-term

t

andforany

ρ ∈ P(D)

V

,wehave

JtK

ρ

= {α ∈ D / ∃Γ ∈ Φ (∀x ∈ V Γ(x) ∈ M

f

(ρ(x))

and

Γ `

R

t : α)} .

Proof. ApplyTheorems20and22.



There is another way to compute the interpretation of

λ

-terms in this semantics. Indeed,itiswell-knownthatwecantranslate

λ

-termsintolinearlogicproofnetslabelled with the types

I

,

O

,

?I

and

!O

(as in [Regnier 1992]): this translation is dened by inductiononthe

λ

-terms. Now,wecandoexperimentsto computethesemanticsofthe proof net in the multisetbased relationalmodel: all the translations corresponding to theencoding

A ⇒ B ≡?A

℘B

havethesamesemantics. Andthissemanticsisthesame asthesemantics denedhere.

Forasurveyoftranslationsof

λ

-termsinproofnets,see[Guerrini2004]. 3.3 An equivalence relation on derivations

Denition 26 introducesan equivalence relationon the set of derivations of agiven

λ

-term. Thisrelation,aswellasthenotionofsubstitutiondened immediatelyafter,will playaroleinSubsection5.5.

Denition25 For any

λ

-term

t

,for any

(Γ, α) ∈ Φ × D

,wedenote by

∆(t, (Γ, α))

the setof derivations of

Γ `

R

t : α

.

Forany closed

λ

-term

t

,for any

α ∈ D

,wedenote by

∆(t, α)

the setof derivations of

`

R

t : α

.

Forany

λ

-term

t

,weset

∆(t) =

S

(21)

Denition26 Let

t

bea

λ

-term

t

. Forany

Π, Π

0

∈ ∆(t)

,wedene,byinductionon

Π

, when

Π ∼ Π

0

holds:

ˆ if

Π

isonly aleaf,then

Π ∼ Π

0

if,andonlyif,

Π

0

isaleaf too; ˆ if

Π =

Π

0

Γ, x : a `

R

v : α

Γ `

R

λx.v : (a, α)

,

then

Π ∼ Π

0

if,andonlyif,

Π

0

=

Π

0

0

Γ

0

, x : a

0

`

R

v : α

0

Γ

0

`

R

λx.v : (a

0

, α

0

)

and

Π

0

∼ Π

0

0

; ˆ if

Π =

Π

0

Γ

0

`

R

v : ([α

1

, . . . , α

n

], α)

Π

1

. . .

Π

n

Γ

1

`

R

u : α

1

. . . Γ

n

` u : α

n

Γ

0

+ Γ

1

+ . . . + Γ

n

`

R

(v)u : α

,

then

Π ∼ Π

0

if,andonly if,



Π

0

=

Π

0

0

Γ

0

0

`

R

v : ([α

0

1

, . . . , α

0

n

], α

0

)

Π

0

1

. . .

Π

0

n

Γ

0

1

`

R

u : α

0

1

. . . Γ

0

n

` u : α

0

n

Γ

0

0

+ Γ

0

1

+ . . . + Γ

0

n

`

R

(v)u : α

0

,

,



Π

0

∼ Π

0

0

 andthereexistsapermutation

σ ∈ S

n

s.t.,forany

i ∈ {1, . . . , n}

,

Π

i

∼ Π

0

σ(i)

.

Anequivalenceclassofderivationsofa

λ

-term

t

inSystem

R

canbeseenasasimple resourcetermoftheshapeof

t

thatdoesnotreduceto

0

. Resource

λ

-calculusisdenedin [EhrhardandRegnier2006]andissimilartoresourceorientedversionsofthe

λ

-calculus previouslyintroduced and studiedin [Boudoletal. 1999] and[Kfoury2000]. Forafull exposition of a precise relation between this equivalence relation and simple resource terms,see[deCarvalho2007].

Denition27 Asubstitution

σ

isafunction from

D

to

D

such that

for any

α, α

1

, . . . , α

n

∈ D

,

σ([α

1

, . . . , α

n

], α) = ([σ(α

1

), . . . , σ(α

n

)], σ(α)) .

Wedenote by

S

the setof substitutions.

For any

σ ∈ S

, we denote by

σ

the function from

M

f

(D)

to

M

f

(D)

dened by

σ([α

1

, . . . , α

n

]) = [σ(α

1

), . . . , σ(α

n

)]

.

Proposition 28 Let

Π

bea derivation of

Γ `

R

t : α

andlet

σ

be asubstitution. Then thereexistsaderivation

Π

0

of

σ ◦ Γ `

R

t : σ(α)

suchthat

Π ∼ Π

0

. Proof. Byinductionon

t

.



4 Qualitative results

Inthissection,inspiredby[Krivine1990],weproveTheorem33,whichformulates qual-itative relationsbetweenassignabletypesandnormalizationproperties: itcharacterizes the(head) normalizable

λ

-termsby semantics means. Wealso answerto the following question: if

v

and

u

aretwoclosednormal

λ

-terms,isitthecasethat

(v)u

is(head) nor-malizable? Theanswerisgivenonlyreferringto

JvK

and

JuK

inCorollary34. Quantitative versions ofthis lastresultwillbeprovedinSection5.

(22)

Proposition 29 (i) Everyhead-normalizable

λ

-termistypable inSystem

R

.

(ii) Foranynormalizable

λ

-term

t

,thereexist

α ∈ D

inwhich

[]

has nopositive occur-rencesand

Γ ∈ Φ

in which

[]

has nonegativeoccurrencessuchthat

Γ `

R

t : α

. Proof.

(i) Let

t

be a head-normalizable

λ

-term. There exist

k, n ∈ N

,

x, x

1

, . . . , x

k

∈ V

,

n λ

-terms

v

1

, . . . , v

n

such that

(λx

1

. . . . λx

k

.t)v

1

. . . v

n

=

β

x

. Now,

x

is typable. Therefore, by Corollary21, the

λ

-term

(λx

1

. . . . λx

k

.t)v

1

. . . v

n

is typable. Hence

λx

1

. . . . λx

k

.t

istypable.

(ii) Weprove,byinductionon

t

,thatforanynormal

λ

-term

t

,thefollowingproperties hold:

ˆ thereexist

α ∈ D

in which

[]

hasnopositiveoccurrencesand

Γ ∈ Φ

inwhich

[]

hasnonegativeoccurrencessuchthat

Γ `

R

t : α

;

ˆ if,moreover,

t

doesnotbeginwith

λ

, then,forany

α ∈ D

in which

[]

hasno positiveoccurrences,thereexists

Γ ∈ Φ

inwhich

[]

hasnonegativeoccurrences suchthat

Γ `

R

t : α

.

Next,justapply Corollary21.



If

X

1

and

X

2

aretwosetsof

λ

-terms,then

X

1

→ X

2

denotesthesetof

λ

-terms

v

such that for any

u ∈ X

1

,

(v)u ∈ X

2

. A set

X

of

λ

-terms is said to be saturated if forany

λ

-terms

t

1

, . . . , t

n

, u

and for any

x ∈ V

,

((u[t/x])t

1

. . . t

n

∈ X ⇒ (λx.u)tt

1

. . . t

n

∈ X )

. Aninterpretationisamapfrom

A

tothesetof saturatedset. Foranyinterpretation

I

andforany

δ ∈ D ∪ M

f

(D)

,wedene,byinduction on

δ

,asaturatedset

|δ|

I

:

ˆ if

δ ∈ A

, then

|δ|

I

= I(δ)

;

ˆ if

δ = []

,then

|δ|

I

isthesetofall

λ

-terms; ˆ if

δ = [α

1

, . . . , α

n+1

]

,then

|δ|

I

=

T

n+1

i=1

i

|

I

. ˆ if

δ = (a, α)

,then

|δ|

I

= |a|

I

→ |α|

I

.

Lemma30 Let

I

be an interpretationand let

u

be a

λ

-term suchthat

x

1

: a

1

, . . . , x

k

:

a

k

`

R

u : α

. If

t

1

∈ |a

1

|

I

, . . .

,

t

k

∈ |a

k

|

I

,then

u[t

1

/x

1

, . . . , t

k

/x

k

] ∈ |α|

I

.

Proof. Byinductionon

u

.



Lemma31 (i) Let

N

be the set of head-normalizable terms. Forany

γ ∈ A

,we set

I(γ) = N

. Then,for any

α ∈ D

,wehave

V ⊆ |α|

I

⊆ N

.

(ii) Let

N

bethe setofnormalizableterms. Forany

γ ∈ A

,weset

I(γ) = N

. Forany

α ∈ D

with no negative(respectively positive) occurences of

[]

, we have

V ⊆ |α|

I

(respectively

|α|

I

⊆ N

).

Figure

Figure 1: Example of computation of the principal head normal form

Références

Documents relatifs

Prove that the gamma distribution is actually a continuous probability distributions that is it is non-negative over x &gt; 0 and its integral over R + is equal to 1.. Exercise 8

First introduced by Faddeev and Kashaev [7, 9], the quantum dilogarithm G b (x) and its variants S b (x) and g b (x) play a crucial role in the study of positive representations

In this paper, we propose a nonlocal model for linear steady Stokes equation with no-slip boundary condition.. The main idea is to use volume constraint to enforce the no-slip

Our run submis- sions for this task explore a number of techniques to achieve this: probabilistic models of workers (i.e. estimating which workers are bad, and discounting their

The article deals with the denotational seman- tics of a special query language called XML-Lambda (abbreviated as XML-λ), which is based on the simply typed lambda calculus.. The

The abstract production rules listed in Table 2 (written using EBNF) connect the terms of syntactic domains from the previous section into logical parts with suitable level of

so the numbers of threads of various lengths are uniquely determined by dimensions of kernels of powers, which are intrinsic characteristics of the linear transformation ϕ that do

In this paper we deal with the local exact controllability to the trajectories of the Boussinesq system with N + 1 distributed scalar controls supported in small sets.. In a first