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�
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
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 ].
∗
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.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 beinterpretedasmorphismsinC
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 categoryK
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λ
-algebrasinK
. 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 SystemI
in [NeergaardandMairson2004] and con-trary to SystemI
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
andu
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
andJuK
ofv
andu
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λ
-terminSystemR
(Theorem44)andproveasimilarresultforthesecondmachine(Theorem50). Weendbyproving trulysemanticmeasuresofexecutiontimeinSubsection5.4andSubsection5.5.
Notation. Wedenote by
Λ
theset ofλ
-terms,byV
theset of variablesand, foranyλ
-termt
,byF V (t)
thesetoffreevariablesint
.WeuseKrivine'snotationfor
λ
-termsi.e.λ
-termv
applied tou
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 byaP
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
ofenvironmentsandofthesetC
ofclosures. SetE =
S
p∈N
E
p
andsetC =
S
p∈N
C
p
,whereE
p
andC
p
are denedbyinduction onp
: If
p = 0
,thenE
p
= {∅}
andC
p
= Λ × {∅}
.
E
p+1
isthesetofpartialmapsV → C
p
,whosedomainisnite,andC
p+1
= Λ×E
p+1
. Fore ∈ E
,d(e)
denotestheleastintegerp
suchthate ∈ E
p
.For
c = (t, e) ∈ C
,wedene, byinduction ond(e)
,c = t[e] ∈ Λ
: Ifd(e) = 0
,thent[e] = t
. Assume
t[e]
denedford(e) = d
. Ifd(e) = d + 1
, thent[e] = t[c
1
/x
1
, . . . , c
m
/x
m
]
, with{x
1
, . . . , x
m
} =
dom(e)
and,for1 ≤ j ≤ m
,e(x
j
) = c
j
.Astack isanitesequenceofclosures. If
c
isaclosureandπ = (c
1
, . . . , c
q
)
isastack, thenc.π
willdenotethestack(c, c
1
, . . . , c
q
)
. Wewilldenotebytheemptystack.A state isapair
(c, π)
, wherec
is aclosure andπ
isastack. Ifs = (c
0
, (c
1
, . . . , c
q
))
isastack,thens
willdenotetheλ
-term(c
0
)c
1
. . . c
q
.Denition1 Wesaythat a
λ
-termt
respectsthevariableconventionifanyvariable is boundatmostonetimeint
.For any closure
c = (t, e)
, we dene, by induction ond(e)
, what it means forc
to respectthevariableconvention: if
d(e) = 0
, then we say thatc
respects the variable convention if, and only if,t
respectsthe variable convention; if
c = (t, {(x
1
, c
1
), . . . , (x
m
, c
m
)})
withm 6= 0
, then we say thatc
respects the variable conventionif,and onlyif,
c
1
, . . . , c
m
respectthe variable convention; andthe variablesx
1
, . . . , x
m
arenotboundint
.Foranystate
s = (c
0
, (c
1
, . . . , c
q
))
,wesaythats
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. Ift
is an application(v)u
, then we pushthe closure(u, e)
onthe topof thestackand thecurrentclosureis now(v, e)
. Ift
is anabstraction,then aclosure is popped anda newenvironment iscreated. Ift
is avariable, thenthecurrentclosureisnowthevalueofthevariable oftheenvironment. Thepartial maps
S
s
0
(denedbelow)denes formallythetransition fromastate to anotherstate.
Denition2 Wedeneapartialmapfrom
S
toS
: foranys, s
0
∈ S
,thenotation
s
S
s
0
willmean thatthe map assigns
s
0
to
s
. The valueof the mapats
isdenedasfollows:s 7→
(e(x), π)
ifs = ((x, e), π)
withx ∈
dom(e)
notdened if
s = ((x, e), π)
withx ∈ V
andx /
∈
dom(e)
((u, {(x, c)} ∪ e), π
0
)
if
s = ((λx.u, e), c.π
0
)
notdened if
s = ((λx.u, e), )
((v, e), (u, e).π)
ifs = (((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
,whereK =
S
n∈N
K
n
with H
0
= V
andK
0
= S
;
H
n+1
= V ∪ {(v)u / v ∈ H
n
andu ∈ Λ ∪ K
n
}
andK
n+1
= S ∪ H
n
∪ {λy.k / y ∈ V
andk ∈ K
n
} .
SetH =
S
n∈N
H
n
. WehaveK = S ∪ H ∪
S
n∈N
{λx.k / x ∈ V
andk ∈ K
n
}
. Remark3 Wehave H = {(x)t
1
. . . t
p
/ p ∈ N, x ∈ V, t
1
, . . . , t
p
∈ Λ ∪ K}
henceany element ofK
canbewrittenaseitherλx
1
. . . . λx
m
.s
withm ∈ N
,x
1
, . . . , x
m
∈ V
ands ∈ S
or eitherForany
k ∈ K
, wedenotebyd(k)
theleastintegerp
suchthatk ∈ K
p
.Weextendthedenitionof
s
fors ∈ S
tok
fork ∈ K
. Forthat,wesett = t
ift ∈ Λ
. Thisdenitionisbyinduction ond(k)
: if
d(k) = 0
,thenk ∈ S
andthusk
isalreadydened; ifk ∈ H
,thenthere aretwocases:if
k ∈ V
,thenk
isalreadydened(itisk
); else,k = (v)u
andwesetk = (v)u
; if
k = λx.k
0
,thenk = λx.k
0
.Denition4 We dene a partial map from
K
toK
: for anyk, k
0
∈ K
, the notation
k
h
k
0
willmeanthatthe map assignsk
0
to
k
. The valueof themap atk
isdened, by inductionond(k)
,asfollows:k 7→
s
0
ifk ∈ S
andk
S
s
0
(x)c
1
. . . c
q
ifk = ((x, e), (c
1
, . . . , c
q
)) ∈ S
,x ∈ V
andx /
∈
dom(e)
λx.((u, e), )
ifk = ((λx.u, e), ) ∈ S
notdened ifk ∈ H
λy.k
0
0
ifk = λy.k
0
andk
0
h
k
0
0
A dierencewiththeoriginalmachine isthatourmachinereducesunder lambda's. Wedenoteby
h
∗
thereexivetransitiveclosureof
h
. Foranyk ∈ K
,k
is saidto beaKrivinenormalform ifforanyk
0
∈ K
, wedonothave
k
h
k
0
.
Denition5 For any
k
0
∈ K
, we denel
h
(k
0
) ∈ N ∪ {∞}
as follows: if there existk
1
, . . . , k
n
∈ K
suchthatk
i
h
k
i+1
for0 ≤ i ≤ n − 1
andk
n
isaKrivinenormalform, thenwesetl
h
(k
0
) = n
,elsewesetl
h
(k
0
) = ∞
.Proposition 6 For any
s ∈ S
, for anyk
0
∈ K
, ifs
h
∗
k
0
andk
0
isa Krivine normal form, thenk
0
isa
λ
-termin head normalform. Proof. Byinductiononl
h
(s)
.Thebasecaseistrivial,becauseweneverhave
l
h
(s) = 0
. Theinductivestepisdividedintovecases. If
s = ((x, e), (c
1
, . . . , c
q
))
,x ∈ V
andx /
∈
dom(e)
, thens
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,thenk
0
= λx.k
00
with
((u, e), )
h
∗
k
00
. Now,byinductionhypothesis,
k
00
isa
λ
-terminheadnormalform,hencek
0
toois a
λ
-terminheadnormalform. If
s = ((x, e), (c
1
, . . . , c
q
))
,x ∈ V
andx ∈
dom(e)
, thens
h
(e(x), π)
. Now,(e(x), π)
h
∗
k
0
,hence,byinductionhypothesis,k
0
isa
λ
-terminheadnormalform. Ifs = ((λx.u, e), c.π)
,thens
h
((u, {(x, c)} ∪ e), π)
. Now,((u, {(x, c)} ∪ e), π)
h
k
0
,hence,byinduction hypothesis,
k
0
isa
λ
-terminheadnormalform. Ifs = (((v)u, e), π)
, thens
h
((v, e), (u, e).π)
. Now,((v, e), (u, e).π)
h
∗
k
0
,hence, byinductionhypothesis,
k
0
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, ∅), )
. Wehavel
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
andx /
∈
dom(e)
, thenk = (x)c
1
. . . c
q
andk
0
= (x)c
1
. . . c
q
= (x)c
1
. . . c
q
: wehavek = k
0
.
If
k = ((λx.u, e), π)
andπ
istheemptystack,thenk = (λx.u)[e] = λx.u[e]
(becausek
respectsthevariableconvention) andk
0
= λx.((u, e), ) = λx.u[e]
: wehave
k = k
0
.
If
k = ((x, e), (c
1
, . . . , c
q
))
,x ∈ V
andx ∈
dom(e)
, thenk = e(x)c
1
. . . c
q
andk
0
= (e(x), (c
1
, . . . , c
q
)) = e(x)c
1
. . . c
q
: wehavek = k
0
If
k = ((λx.u, e), (c, c
1
, . . . , c
q
))
,thenk = ((λx.u)[e])cc
1
. . . c
q
= (λx.u[e])cc
1
. . . c
q
(becausek
respectsthevariableconvention)andk
0
= ((u, {(x, c)} ∪ e))c
1
. . . c
q
. Now,k
reducesinasingleheadreductionsteptok
0
.
If
k = (((v)u, e), (c
1
. . . c
q
))
, thenk = (((v)u)[e])c
1
. . . c
q
= (v[e])u[e]c
1
. . . c
q
andk
0
= ((v, e), (u, e).(c
1
, . . . , c
q
)) = (v[e])u[e]c
1
. . . c
q
: wehavek = k
0
.
Else,
k = λy.k
0
;thenk = λy.k
0
andk
0
= λy.k
0
0
= λy.k
0
0
withk
0
h
k
0
0
: wehavek
0
→
h
k
0
0
,hencek →
h
k
0
.Theorem9 Forany
k ∈ K
,ifl
h
(k)
isnite, thenk
ishead normalizable. Proof. Byinductiononl
h
(k)
.If
l
h
(k) = 0
, thenk ∈ H
, hencek
can be written as(x)t
1
. . . t
p
and thusk
canbe written(x)t
1
. . . t
p
: itisaheadnormalform. Else,applyLemma8. Foranyheadnormalizableλ
-termt
,wedenotebyh(t)
thenumberofheadreductions oft
.Theorem10 Forany
s = ((t, e), π) ∈ S
,ifs
ishead normalizable,thenl
h
(s)
isnite. Proof. Bywell-foundedinductionon(h(s), d(e), t)
.If
h(s) = 0
,d(e) = 0
andt ∈ V
,thenwehavel
h
(s) = 1
. Else,therearevecases. In thecase where
t ∈ V ∩
dom(e)
, wehaves
h
(e(t), π)
. Sets
0
= (e(t), π)
ande(t) = (t
0
, e
0
)
. Wehaves = s
0
andd(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
andt /
∈
dom(e)
,wehavel
h
(s) = 1
. Inthecasewheret = (v)u
,wehaves
h
((v, e), (u, e).π)
. Sets
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π =
,wehaves
h
λx.((u, e), )
. Sets
0
= ((u, e), )
. Since
s
respectsthe variable convention, we haves = λ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), π)
. Sets
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
λ
-termt
hasahead-normalform,thenthelasttermofthe terminat-ingheadreductionoft
iscalledtheprincipalheadnormalformoft
(see[Barendregt1984]). Proposition6,Lemma8andTheorem10showthatforanyheadnormalizableλ
-termt
witht
0
itsprincipal headnormalform,wehave
((t, ∅), )
h
∗
t
0
and
t
0
is aKrivinehead normalform.
1.3 A machine computing the
β
-normal formWenowslightlymodifythemachinesoastocomputethe
β
-normalformofany normal-izableλ
-term.Denition11 We dene a partial map from
K
toK
: for anyk, k
0
∈ K
, the notation
k
β
k
0
willmeanthat themap assignsk
0
to
k
. Thevalueof themap atk
isdened, by inductionond(k)
,asfollows:k 7→
s
0
ifk ∈ S
andk
S
s
0
(x)(c
1
, ) . . . (c
q
, )
ifk = ((x, e), (c
1
, . . . , c
q
)) ∈ S
,x ∈ V
andx /
∈
dom(e)
λx.((u, e), )
ifk = ((λx.u, e), ) ∈ S
notdened ifk ∈ V
(v
0
)u
if
k = (v)u
andv
β
v
0
(x)u
0
if
k = (x)u
withx ∈ V
andu
β
u
0
λy.k
0
0
ifk = λy.k
0
andk
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
β
isdenedasl
h
(seeDenition5), butforthisnewmachine.Foranynormalizable
λ
-termt
,wedenotebyn(t)
thenumberofleftreductionsoft
. Theorem12 Foranys = ((t, e), π) ∈ S
,ifs
isnormalizable, thenl
β
(s)
isnite. Proof. Bywell-foundedinductionon(n(s), s, d(e), t)
.If
n(s) = 0
,s ∈ V
,d(e) = 0
andt ∈ V
,thenwehavel
β
(s) = 1
. Else,therearevecases. In thecase where
t ∈ V ∩
dom(e)
, wehaves
β
(e(t), π)
. Sets
0
= (e(t), π)
ande(t) = (t
0
, e
0
)
. Wehaves = s
0
andd(e
0
) < d(e)
, hencewecanapplytheinduction hypothesis:
l
β
(s
0
)
isniteandthus
l
β
(s) = l
β
(s
0
) + 1
isnite.
Inthecasewhere
t ∈ V
andt /
∈
dom(e)
,setπ = (c
1
, . . . , c
q
)
. Foranyk ∈ {1, . . . , q}
, wehaven(c
k
) ≤ n(s)
andc
k
< s
,hencewecanapplytheinductionhypothesisonc
k
: for anyk ∈ {1, . . . , q}
,l
β
(c
k
)
is nite, hencel
β
(s) =
P
q
k=1
l
β
(c
k
) + 1
is nite too. Inthecasewhere
t = (v)u
,wehaves
β
((v, e), (u, e).π)
. Sets
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 haves
β
λx.((u, e), )
. Sets
0
=
((u, e), )
. Sinces
respects thevariable convention, we haves = λ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), π)
. Sets
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.
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,westartfromasemanticsM
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)
isasymmetricmonoidalcomonadonC
;
c
is amonoidal naturaltransformation from(T,
m,
n)
to⊗ ◦ ∆
C
◦ (T,
m,
n)
andw
isamonoidalnaturaltransformationfrom(T,
m,
n)
to∗
C
such thatfor any object
A
ofC
,((T (A), δ
A
), c
A
, w
A
)
is acocommutativecomonoid in(C
T
, ⊗
T
, (I,
n
), α, λ, ρ)
andforanyf ∈ C
T
[(T (A), δ
A
), (T (B), δ
B
)]
,f
isacomonoid morphism, whereT
is thecomonad(T, δ, d)
onC
,C
T
is the categoryof
T
-coalgebras,∆
C
is thediagonalmonoidalfunctorfromC
toC × C
and∗
C
isthemonoidalfunctorthat sendsanyarrowtoid
I
.Given a categorical model
M
= (C, L, c, w)
of IMELL withC = (C, ⊗, I, α, λ, ρ, γ)
andL = ((T,
m,
n), δ, d)
,wecandeneacartesianclosedcategoryΛ(M)
suchthat theobjectsarenitesequencesofobjectsof
C
andthearrows
hA
1
, . . . , A
m
i → hB
1
, . . . , B
p
i
aresequenceshf
1
, . . . , f
p
i
whereeveryf
k
isanarrowN
m
j=1
T (A
j
) → B
k
inC
.Hencewecaninterpretsimplytyped
λ
-calculusinthecategoryΛ(M)
. Thiscategory is(weakly)equivalent1
to afullsubcategoryof
(T, δ, d)
-coalgebrasexhibitedbyHyland. IfthecategoryC
iscartesian,thenthecategoriesΛ(M)
andtheKleislicategoryofthe comonad(T, δ, d)
are(strongly)equivalent2
. See[deCarvalho2007]forafullexposition.
2.1 A relational model for linear logic
Thecategoryofsetsandrelationsisdenotedby
Rel
and◦
denotesitscomposition. The functorT
fromRel
toRel
isdened bysetting1
Acategory
C
issaidtobeweaklyequivalenttoacategoryD
ifthereexistsafunctorF
: C → D
full andfaithfulsuchthateveryobjectD
ofD
isisomorphictoF
(C)
forsomeobjectC
ofC
.2
Acategory
C
issaidtobestronglyequivalenttoacategoryD
iftherearefunctorsF
: C → D
and foranyobject
A
ofRel
,T (A) = M
f
(A)
,thesetofnitemultisetsa
whosesupport, denoted bySupp(a)
, isasubsetofA
; and,forany
f ∈ Rel(A, B)
,T (f ) ∈ Rel(T (A), T (B))
dened byT (f ) = {([α
1
, . . . , α
n
], [β
1
, . . . , β
n
]) / n ∈ N
and(α
1
, β
1
), . . . , (α
n
, β
n
) ∈ f } .
Thenaturaltransformation
d
fromT
totheidentityfunctorofRel
isdenedbysettingd
A
= {([α], α) / α ∈ A}
and the naturaltransformationδ
fromT
toT ◦ T
by settingδ
A
= {(a
1
+ . . . + a
n
, [a
1
, . . . , a
n
]) / n ∈ N
anda
1
, . . . , a
n
∈ T (A)} .
It is easy to show that(T, δ, d)
isacomonadonRel
. Itis well-knownthat thiscomonadcanbeprovided withastructureM
thatprovidesamodelof(I)MELL.Thismodelgivesrisetoacartesianclosedcategory
Λ(M)
. 2.2 Interpreting simply typedλ
-termsWedescribethecategory
Λ(M)
inducedbythemodelM
oflinearlogicpresentedinthe precedingsubsection: objectsarenite sequencesofsets;
arrows
hA
1
, . . . , A
m
i → hB
1
, . . . , B
n
i
aresequenceshf
1
, . . . , f
n
i
whereeveryf
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
ifm = 0
; if
hf
1
, . . . , f
p
i
isanarrowhA
1
, . . . , A
m
i → hB
1
, . . . , B
p
i
andhg
1
, . . . , g
q
i
isanarrowhB
1
, . . . , B
p
i → hC
1
, . . . , C
q
i
,thenhg
1
, . . . , g
q
i◦
Λ(M)
hf
1
, . . . , f
p
i
ishh
1
, . . . , h
q
i
withh
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 for1 ≤ j ≤ m,
for1 ≤ k ≤ p,
for1 ≤ 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 for1 ≤ k ≤ p,
for1 ≤ 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
ifm = 0 .
theidentityofhA
1
, . . . , A
m
i
ishd
1
, . . . , d
m
i
withd
j
= {(([], . . . , []
|
{z
}
j−1
times, [α], [], . . . , []
|
{z
}
m−j
times), α) / α ∈ A
j
} .
Thecategory
Λ(M)
hasthefollowingcartesian closedstructure(Λ(M), 1, !, &, π
1
, π
2
, h·, ·i
M
, ⇒, Λ,
ev) :
theterminalobject1
istheemptysequencehi
; if
B
1
= hB
1
, . . . , B
p
i
andB
2
= hB
p+1
, . . . , B
p+q
i
are twosequencesof sets, thenB
1
&B
2
if
B
1
= hB
1
, . . . , B
p
i
andB
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)
withd
k
= {(( [], . . . , []
|
{z
}
k−1
times, [β], [], . . . , []
|
{z
}
p+q−k
times), β) / β ∈ B
k
} ;
iff
1
= hf
1
, . . . , f
p
i : C → A
1
andf
2
= hf
p+1
, . . . , f
p+q
i : C → A
2
inΛ(M)
, thenhf
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 byinductiononm
: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 ;
ifh = 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 onp
: ifp = 0
,thenΛ
hB
1
,...,B
p
i
hA
1
,...,A
m
i,hC
1
,...,C
q
i
(h) = h
; ifp = 1
,thentherearetwocases:* in thecase
m = 0
,Λ
hB
1
,...,B
p
i
hA
1
,...,A
m
i,hC
1
,...,C
q
i
(h) = h
; * in thecasem 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
} ;
ifp ≥ 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)) ,
whereA = hA
1
, . . . , A
m
i
; ev
C,B
: (B ⇒ C)&B → C
isdenedbysetting evhC
1
,...,C
q
i,hB
1
,...,B
p
i
= h
ev1
hC
1
,...,C
q
i,hB
1
,...,B
p
i
, . . . ,
evq
hC
1
,...,C
q
i,hB
1
,...,B
p
i
i
where, for1 ≤ k ≤ q
, evk
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
λ
-termsWith thecartesianclosedstructure on
Λ(M)
,wehaveasemanticsofthe simplytypedλ
-calculus. Now, in order to have a semantics of the pureλ
-calculus, it is therefore enoughto haveareexive objectU
ofΛ(M)
,thatistosaysuchthat(U ⇒ U ) C U ,
that means that there exist
s ∈ Λ(M)[U ⇒ U, U ]
andr ∈ Λ(M)[U, U ⇒ U ]
such thatr ◦
Λ(M)
s
is theidentity onU ⇒ U
. Wewill use thefollowinglemma. We recallthathf i
is a retraction ofhgi
inΛ(M)
meansthathf i ◦
Λ(M)
hgi = id
hAi
(see, forinstance, [MacLane1998]). Itisalsosaidthat(hgi, hf i)
isaretractionpair.Lemma13 Let
h : A → B
be aninjectionbetween sets. Setg = {([α], h(α)) : α ∈ A} : M
f
(A) → B
inRel
andf = {([h(α)], α)/α ∈ A} : M
f
(B) → A
inRel
.
Thenhgi ∈ Λ(M)(hAi, hBi)
andhf i
isaretractionofhgi
inΛ(M)
. Proof. An easycomputationshowsthatwehavehf i ◦
Λ(M)
hgi = hf ◦ T (g) ◦ δ
A
i
= hd
A
i .
If
D
is aset,thenhDi ⇒ hDi = hM
f
(D) × Di
. Fromnowon,weassumethatD
is anon-emptysetandthath
isaninjectionfromM
f
(D) × D
toD
. Setg = {([α], h(α)) / α ∈ M
f
(D) × D} : M
f
(M
f
(D) × D) → D
inRel
andf = {([h(α)], α) / α ∈ M
f
(D) × D} : M
f
(D) → M
f
(D) × D
inRel
.
Wehave(hDi ⇒ hDi) C hDi
and,moreprecisely,
hgi ∈ Λ(M)(hDi ⇒ hDi, hDi)
andf
isaretractionofg
. Wecanthereforedenetheinterpretationofanyλ
-term.Denition14 Forany
λ
-termt
possiblycontainingconstantsfromP(D)
,foranyx
1
, . . . , x
m
∈
V
distinct suchthatF V (t) ⊆ {x
1
, . . . , x
m
}
, we dene, by induction ont
,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 anyc ∈ 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
), α) = α
ifm = 0
. Now,wecandenetheinterpretationofanyλ
-termin anyenvironment. Denition15 For anyρ ∈ P(D)
V
andfor any
λ
-termt
possibly containing constants fromP(D)
suchthatF V (t) = {x
1
, . . . , x
m
}
,wesetJtK
ρ
= {α ∈ D / ((a
1
, . . . , a
m
), α) ∈ JtK
x
1
,...,x
m
and, for1 ≤ j ≤ m
,a
i
∈ M
f
(ρ(x
j
))} .
Forany
d
1
, d
2
∈ P(D)
,wesetd
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λ
-termst
1
andt
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λ
-termst
1
andt
2
suchthat(∀d ∈ P(D) Jt
1
K
ρ[x:=d]
= Jt
2
K
ρ[x:=d]
andJλx.t
1
K
ρ
6= Jλx.t
2
K
ρ
) .
Inparticular,
JtK
ρ
cannotbe denedbyinduction ont
(aninterpretationby polyno-mialsisneverthelesspossiblein suchawaythat theξ
-ruleholds-see [Selinger2002]).BeforestatingProposition17,werecallthat anyobject
A
ofanycategoryK
witha terminalobjectis said tohave enough points if foranyterminal object1
ofK
and for anyy, 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 LetA
be a non-empty set. ThenhAi
does not have enough points inProof. Let
α ∈ A
. Sety = {([α], α)} : M
f
(A) → A
inRel
andz = {([α, α], α)} : M
f
(A) → A
inRel
.
Wehavehyi
,hzi : hAi → hAi
inΛ(M)
.Werecall thatthe terminalobjectin
Λ(M)
istheemptysequencehi
. Now,foranyx : hi → hAi
inΛ(M)
,wehavehyi ◦
Λ(M)
x = hzi ◦
Λ(M)
x
. This proposition explainswhy Proposition 16 holds. A moredirect proof of Propo-sition16 consists byconsidering thetwoλ
-termst
1
= (y)x
andt
2
= (z)x
withρ(y) =
{([α], α)}
andρ(z) = {([α, α], α)}
.2.4 Non-uniformity
Example18illustratesthenon-uniformityofthesemantics. Itisbasedonthefollowing idea.
Considertheprogram
λx.
ifx
then1
elseif
x
then1
else0
applied to a boolean. The second thenis never read. A uniform semanticswould ignoreit. Itisnotthecasewhenthesemanticsisnon-uniform.
Example18 Set
0
= λx.λy.y
and1
= λx.λy.x
. Assume thath
is the inclusion fromM
f
(D) × D
toD
.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
,whereD
n
isdenedbyinductiononn
:D
0
isanon-empty setA
that does not contain any pairs andD
n+1
= A ∪ (M
f
(D
n
) × D
n
)
. We haveD = A ˙∪(M
f
(D) × D)
, where˙∪
is thedisjointunion;theinjectionh
fromM
f
(D) × D
toD
will be the inclusion. Hence any element ofD
canbe writtena
1
. . . a
m
α
, where
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λ
-termt
and for anyx
1
, . . . , x
m
∈ V
distinct such thatF V (t) ⊆
{x
1
, . . . , x
m
}
; Denition 15denesJtK
ρ
foranyλ
-termt
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 fromV
toM
f
(D)
such that{x ∈ V / Γ(x) 6= []}
is nite. Ifx
1
, . . . , x
m
∈ V
aredistinctanda
1
, . . . , a
m
∈ M
f
(D)
, thenx
1
: a
1
, . . . , x
m
: a
m
denotes thecontextdenedbyx 7→
a
j
ifx = 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 wheren = 0
,weobtainthefollowingrule:Γ
0
`
R
v : ([], α)
Γ
0
`
R
(v)u : α
forany
λ
-termu
. So,the emptymultisetplaystheroleoftheuniversaltypeΩ
.Theintersection weconsider isnot idempotentin thefollowingsense: ifaclosed
λ
-termt
hasthetypea
1
. . . a
m
α
and,for1 ≤ j ≤ m
,Supp(a
0
j
) =
Supp(a
j
)
,itdoesnotfollow necessarilythatt
hasthetypea
0
1
. . . a
0
m
α
. Forinstance,theλ
-termλz.λx.(z)x
hastypes([([α], α)], ([α], α))
and([([α, α], α)], ([α, α], α))
but not the type([([α], α)], ([α, α], α))
. Onthecontrary, thesystempresentedin [Ronchi DellaRocca1988] andtheSystemD
presentedin[Krivine1990]consideranidempotentintersection. Systemλ
of[Kfoury2000] and SystemI
of[NeergaardandMairson2004] consider anon-idempotentintersection, butthetreatmentofweakeningisnotthesame.Interestingly,System
R
canbeseenasareformulationofthesytemof[Coppoetal. 1980]. Moreprecisely, typesof SystemR
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.3.2 Relating types and semantics
Weproveinthissubsectionthatthesemanticsofaclosed
λ
-termasdenedinSubsection 2.3 is the set of its typesin SystemR
. The following assertionsrelate moreprecisely typesandsemanticsofanyλ
-term.Theorem20 Forany
λ
-termt
suchthatF V (t) ⊆ {x
1
, . . . , x
m
}
,wehaveJtK
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. Byinductionont
.Corollary21 Forany
λ
-termst
andt
0
suchthat
t =
β
t
0
, if
Γ `
R
t : α
, then we haveΓ `
R
t
0
: α
.Theorem22 Forany
λ
-termt
andforanyΓ ∈ Φ
,wehave{α ∈ D / Γ `
R
t : α} ⊆ {α ∈ D / ∀ρ ∈ P(D)
V
(∀x ∈ V Γ(x) ∈ M
f
(ρ(x)) ⇒ α ∈ JtK
ρ
)}.
Proof. ApplyTheorem20.
Remark23 Thereverseinclusion isnottrue.
Theorem24 Forany
λ
-termt
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 typesI
,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 theencodingA ⇒ B ≡?A
⊥
℘B
havethesamesemantics. Andthissemanticsisthesame asthesemantics denedhere.
Forasurveyoftranslationsof
λ
-termsinproofnets,see[Guerrini2004]. 3.3 An equivalence relation on derivationsDenition 26 introducesan equivalence relationon the set of derivations of agiven
λ
-term. Thisrelation,aswellasthenotionofsubstitutiondened immediatelyafter,will playaroleinSubsection5.5.Denition25 For any
λ
-termt
,for any(Γ, α) ∈ Φ × D
,wedenote by∆(t, (Γ, α))
the setof derivations ofΓ `
R
t : α
.Forany closed
λ
-termt
,for anyα ∈ D
,wedenote by∆(t, α)
the setof derivations of`
R
t : α
.Forany
λ
-termt
,weset∆(t) =
S
Denition26 Let
t
beaλ
-termt
. 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.,foranyi ∈ {1, . . . , n}
,Π
i
∼ Π
0
σ(i)
.
Anequivalenceclassofderivationsofa
λ
-termt
inSystemR
canbeseenasasimple resourcetermoftheshapeoft
thatdoesnotreduceto0
. 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 fromD
toD
such thatfor any
α, α
1
, . . . , α
n
∈ D
,σ([α
1
, . . . , α
n
], α) = ([σ(α
1
), . . . , σ(α
n
)], σ(α)) .
Wedenote byS
the setof substitutions.For any
σ ∈ S
, we denote byσ
the function fromM
f
(D)
toM
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. Byinductionont
. 4 Qualitative resultsInthissection,inspiredby[Krivine1990],weproveTheorem33,whichformulates qual-itative relationsbetweenassignabletypesandnormalizationproperties: itcharacterizes the(head) normalizable
λ
-termsby semantics means. Wealso answerto the following question: ifv
andu
aretwoclosednormalλ
-terms,isitthecasethat(v)u
is(head) nor-malizable? TheanswerisgivenonlyreferringtoJvK
andJuK
inCorollary34. Quantitative versions ofthis lastresultwillbeprovedinSection5.Proposition 29 (i) Everyhead-normalizable
λ
-termistypable inSystemR
.(ii) Foranynormalizable
λ
-termt
,thereexistα ∈ D
inwhich[]
has nopositive occur-rencesandΓ ∈ Φ
in which[]
has nonegativeoccurrencessuchthatΓ `
R
t : α
. Proof.(i) Let
t
be a head-normalizableλ
-term. There existk, n ∈ N
,x, x
1
, . . . , x
k
∈ V
,n λ
-termsv
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λ
-termt
,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
andX
2
aretwosetsofλ
-terms,thenX
1
→ X
2
denotesthesetofλ
-termsv
such that for anyu ∈ X
1
,(v)u ∈ X
2
. A setX
ofλ
-terms is said to be saturated if foranyλ
-termst
1
, . . . , t
n
, u
and for anyx ∈ V
,((u[t/x])t
1
. . . t
n
∈ X ⇒ (λx.u)tt
1
. . . t
n
∈ X )
. AninterpretationisamapfromA
tothesetof saturatedset. ForanyinterpretationI
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 letu
be aλ
-term suchthatx
1
: a
1
, . . . , x
k
:
a
k
`
R
u : α
. Ift
1
∈ |a
1
|
I
, . . .
,t
k
∈ |a
k
|
I
,thenu[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 setI(γ) = N
. Then,for anyα ∈ D
,wehaveV ⊆ |α|
I
⊆ N
.(ii) Let