You are on page 1of 17

LINEAR LOGIC AND PARALLELISM

Jean-Yves Girard Equipe de logique (UA 753 CNRS) D~partement de math~matiques T 45-55, 5 ~tage, Universit~

PARIS VII, 2 Place Jussieu 75251 PARIS CEDEX 05

Abstract

: the paper discusses:the relevance of a new logic called and in particular to

linear logic (Girard 1986) to computer science, parallel computations.

These general remarks wil} be detailed in a

paper in preparation with Gianfranco Mascari.

I. Intuitionistic logic and its relevance to sequential computations

I.i. specifications and types In the recent years, more and more attention has been paid to questions of modularity in programming languages : in the handling of very big (debugging,

units, one would like to be able to make local corrections

improvement of some part of the algorithm) without having to check again the complete structure. For this it is natural to conceive a

program as a juxtaposition of modules, which are branched together; what is inside the module is irrelevant to the branching, the branching, we have only been using specifications, and in doing

which tell us

167

general

facts about the module,

for instance

: the module takes two Such specifi-

integers as inputs and gives us back an integer as output. cations are usually represented by types, just considered int X int =~int

for instance in the case

which is the type of binary functions

from integers to integers. to the specifications,

Now, if the branching is done according

then the correctness of the full program only of its modules, and we are done.

depends on the correctness 1.2. the Curry-Howard

isomorphism implies correctness, :

In order to prove that the respect of specifications

we have to use some logic, and we are faced with an alternative i) external logic : a logical comment external : the program, to the program

ii) integrated

logic

the branchings

etc. are thought

of in logical terms

; in fact, only this approach has a theoretical which dates back to Heyting's semantics through the Curry-Howard a program enjoying

interest. With this method, of proofs,

and found its correct expression

isomorphism between proofs and functional specification

expressions,

S is nothing but a proof of the formula S in an appropriate logic, typically intuitionist logic. can using

system of constructive The typed

objects that are built to meet the logical requirements be written as functional expressions (for instance,

indifferently

typed lambda-abstraction) lambda-abstraction

or as proofs in natural deduction

(in which rule). formalism

corresponds

exactly to the =>-~ntroduction equivalent,

Although the two ways are absolutely

the functional

is more popular because it sticks more to a functional sequential) intuition;

(and hence

on the other hand the use of proofs is more they are not absolutely linked to such

interesting precisely because

168 a functional intuition, which becomes surely a limitation programming. if we want

to get out of the realm of sequential later only discuss proofs. 1.3. second order !ambda-calculus

This is why we shall

This system -called [ by the author- was introduced and corresponds propositional

in (Girard 1970)

exactly to the natural deduction of second-order : the system contains type variables ~ , ~ and the universal ,~ ...,

calculus

a binary connective => (implication)

quantifier A ~ . and

The rules of inference are the usual second order introduction

elimination rules. The interest of the system relies on the following features : in the system : one can define

i) most current data types are definable types for booleans, int = d A~. ~ integers, ~) trees,

lists etc., typically

~ ((~ ~ )

ii) there is a proof of termination normalization theorem (Girard 1970);

of the programs, for instance,

through the

a closed deduction this

of int can be rewritten

into an integer,

through this process,

integer being independant of the order of the rules used. iii) the class of functions that can be expressed by means of proofs of int =~int is very general : in (Girard 1970) it was shown that this terminating algorithms sending

class is equal to the set of all provably integers into integers, arithmetic converge

the proof being carried out in second-order any algorithm that can be proved to can be represented in F.

PA 2. In particular,

in usual mathematics

The existence of systems like F shows the adequation of the integrated

169

logical approach w.r.t,

sequential computation.

Our goal will be to For this to linear

propose an extension of this methodology purpose, some drastic modifications

to parallelism.

of usual logic,leading

logic, will be necessary.

2 Inputs and outputs

2.1.

intuitionistic

case

Intuitionistic - inputs - outputs

logic is based on a deep asymmetry between free variables in the functional notation) notation)

(hypotheses, (conclusions,

the term itself in the functional

The asymmetry comes from the fact that a deduction a tree, with

is, roughly speaking, but only

(some of) its summits occupied by hypotheses, (the root of the tree).

one conclusion a diagram :

The situation is depicted by

H1 ]D

.....

Hk

C each hypothesis H. denoting in fact a block of several occurences


1

of

the same formula

(type). (questions) while C is viewed as an output

The H.'s are viewed as inputs 1 (answer). Superficially,

the diagram can be seen as a communication

ne__~t, enabling us to transform answers to the questions H i into an output of type C. So the communication seems to work from the hypotheses is indeed more complex, in more details as we :

to the conclusion.

But the situation

shall make it clear by describing the process

170

it is enough to consider the case k ~- i, and more, where the only hypothesis H (= H I) occurs exactly once ; the c o m m u n i c a t i o n is established :

by substituting a deduction ID' of H for the hypothesis H inlD

ID'
H

C (functionally speaking, the situation would be denoted by the substitution

of a term t' of type H for a variable x of type H in a term t of type C, namely the term t ~ ' / x ] which is again of type C~. Now, the computation works by reducing certain c o n f i g u r a t i o n s which are created by the physical contact between D ' conclusion H with a hypothesis H written and and ~]D, by identifying a can be

; for instance if H = H I A ~ 2 and ~ ' is H

AI

ID~

H then we replace our deduction by

C , and we are faced with another

.HI
]D*

C problem of substitution etc.. What we have just described is a small bit of the n o r m a l i z a t i o n procedure, which is, up to now, widely adopted as a model for sequential computation. Let us come back to our point : the last :

there is clearly an information w h i c h travels d o w n w s r ~ s rule of ~ ' ~'

is used as a destroyer for the first rule of ~ , hence using ~. But in fact the

one will be able to go downer and downer in

171

communication

is symmetric

: when the last rule of ~ disappears

destroys

the

first rule of ~',

the first rule o f ~

too in, this encounter,

and we can see the communication

as running upwards too. In fact, we anihilation, which

are in presence of a phenomenon of reciprocal produces a double communication, This general framework,

downawrds and upwards. in the intuitionistic (or

idea cannot be expressed correctly

because it is built on an asymetry ; for instance,

inputs/output

hypotheses/conclusion) as a hypothesis several of ~,

H may occur several times destroys

in which case the last rule o f ~ '

first rules of D.

2.2. linear negation In linear logic, we restore the symmetry, (.)i (nil) of linear negation, Linear logic will therefore with only conclusions. by introducing the connective

which exchanges

the roles input/output. conclusio n logic, as ;

appear as a multiple

For instance,

instead of writing D

we did, we shall write a proof-net with as conclusions the proof-net will be indifferently the hypothesis H, or as a proof of ~

C and Hi

read as a preof of C under under the hypothesis CI. The

typical example of such a situation is the net

which can indifferently

be seen as the identity

function from A to A

or the identity function from Al to A ~. Once for all, this imposes the dumping of any functional notation, which has the disadvantage The communication is

of making asymmetric what is indeed symmetric.

established by means of the (unhappily named) cut-rule, exact counterpart of the identity axiom written above

which is the

I72

AI
CUT indicate o f 1D f o r a phenomenon H i n 113' w o u l d of anihita-

the tion.

symbol

CUT b e i n g the

just

a way t o

Typically,

substitution

now b e c o m e

H CUT

Hi

where ]P and]P' "are the proof-nets representinglD" and iD' in linear logic. The syntax is organized in such a way that H il is H, i.e. the negation is only used on atoms, and then defined by De Morgan laws, which will force us to introduce our connectives and quantifiers by pairs. The connective of linear negation (which is a defined one) is

the first and most important level of linear logic : the level of communication, which consists essentially in opposing inputs and

outputs in two dual ways, namely the identity axioms and the cut rule.

3.

Cooperation

3.1. multiplicatives We only discuss here the idea of a binary cooperation ; the general

concept of a multiplicative connective of arity n, yielding more complex kinds of cooperation, By cooperation, will be analysed in a forthcoming paper.

I mean a situation with two outputs, one of type A

and one of type B. The fact that we have these two outputs will be indicated by replacing them by a third ome A m B, where m is a

173

multiplicative

connective,

which indicates in which way A and B coowhich corres-

perate. There are only two possible ways of cooperating, pond to the De Morgan dual connectives i) independance m and 9.

: A and B are obtained without communication.

The

situation is denoted by the connective m (times), ii) dependance, corresponds

the tenso= product. The situation connective.

i.e. A and B are forced to communicate.

to the dual connective 9 (par), the parallel is the dependance

A typical example of dependancM from a hypothesis,

of a conclusion framework of and C.

which is written,

in the symmetrical

linear logic, as a mutual dependance 3.2. trips The two multiplicatives A AB B

between the outputs ~

are handled by means of two binary rules A A~ B B These two

which look the same, although they are deeply different. rules,

together with the axioms of identity and the cut rule, form fragment of linear logic, by far the best understood. we can build proof-structures, and no hypothesis. which For

the multiplicative

Using these four principles,

are just proofs with several conclusions instance

, A
AliB

B,

IA1

but also A

'I AL.
procedure

A.B
The first proof-structure

is sound (i.e. the normalization

174 works well, when we relate this proof-net to other ones by cuts); second one does not work well in relation to the cut-rule, therefore not be accepted as a proof-net. In order to determine which, ledged as proof-nets, with an arbitrary among proof-structures, will be acknow: starting the

and will

we introduce

the coneept of a trip

formula of the structure,

and an initial direction by

(upwards or downwards) following travel

we start to travel through the structure,

instructions

; in the case of the two binary rQ~es

for par and times,

we have to preset some switches because these ; in fact the ways of passing

links may be crossed in various ways

through these rules are just the expression of the absence or presence of communication. The travel instructions are bideterministic, i.e. the

from a formula and a direction we can predict the next formula, next direction, As a corollary but we can only reconstruct to bideterminism,

the previous position.

we shall be able to construct loops (corresponding

a certain number of loops. When there are several to a particular switching), we speak of shortrip

; in case of a single

loop, we speak of longtrip. Definition A proof-structure of its switches, are longtrips, g is said to be a proof-net when, there is no shortrip for any positioning all trips every formula

; in other terms,

which means that starting from anywhere, once upwards, once downwards. procedure

is visited twice, There

is an obvious normalization

for proof-nets,

which is a way of making explicit the communication the cut-rule :

established by

175 for instance the configuration

AI
Ai CUT

BI

A ~ B

is replaced by the simpler

AI

B
CUT

Bi

CUT Simple considerations

on trips show that when we normalize a proof-net ; in particulaz, the proof-structure

the result is st~ll a proof-net

CUT which means an o u t p u t is excluded. to avoid that used as its own i n p u t , related and that to general its c a n n o t be n o r m a l i z e d , trips are indeed might

All the complications this pattern

of 'rthe snake ea~ng

own t a i l "

occur through normalization. Normalization normalize, in the multiplicative fragment is very quick strictly) (when we

the number of formulas decreases

and asynchnonous, In the paper on description of

i.e. we can work with several cuts at the same time. multiplicatives, we shall give a striking geometrical process.

the cut-elimination

3.3. sequentialization The general condition for being a proof-net is of exponential nature if thereeare n multiplicative switchings, links in 8, there are 2n possible :

and the idea is therefore not to ask a computer to decide is sound. The idea will be and that we shall feed

whether or not a given proof-structure

that the computer will compile proof-nets,

176

it with a proof written in a more traditional way. This more traditional way is linear sequent calculus, same expressive power as proof-nets, which has the in the

but which is written

familiar tree-like succession of axioms and rules. of linear sequent calculus corresponds mechanically net p-. Conversely,

To each proof p a unique proof: there

every proof-net g can be sequentialized

exists at least one proof p in linear sequent calculus B = p-, in general many ones. appear as particular

such that therefore

The rules of sequent calculus

derived rules sending proof-nets

into proof-nets,

and we can even imagine other derived rules enabling us to describe proof-nets manners in a simple, useful~ but non intrinsic way : all these language

should be put into a high level language,

the machine

being made of (something very close to) proof-nets.

4. Sharing

4.1. additves Here again~ where, I only discuss binary sharing. By sharing, I mean a situation

among two possible outputs,

one of type A, one of type B, exactly a

one will be effective.

This fact will be indicated by introducing

third output A a B, where a is an additive connective, in which sense the only output will be effective. ways of sharing, i) open sharing outputs,

which indicates

There are only two and & :

expressed by the De Morgan dual connectives

: this is the situation where we can produce both example is definition

but we don't know which one. A typical

177

by cases, where two alternative possibilities

are considered,

but we

don't know which one (we need to know in which case we are). The connective for open sharing is & (with), the direct product. where exactly one is

ii) closed sharing

: this is the dual situation,

of A and B is actually produced. e (plus), 4.2. boxes the direct sum.

The corresponding connective

The sum is handled by means of the unary rules

A
le

et

B
- - 2 ~

AeB but the connective formalism) "with" needs

AeB

(at least in the present state of the : a:proof-box ~ isddepicted by a

the use of proof-boxes

square with several conclusions

j
--

AI . . . . . . . .

An

and the box will be linked to other boxes and formulas by means of the rules of the system. The linkage must be correct independantly of what is actually inside the box, i.e. I can replace by any other ~ will

box with the same conclusions.

We have in mind~that eventually

be replaced by an arbitrary proof-net whose conclusions AI,...,An,

are exactly

and it is therefore possible to introduce box-switches

which depict the arbitrary behaviour of a p r o o f - n e t whose conclusions are AI, .... An, and so boxes can be inserted in the multiplicative framework. The rule for & is the following :

178

given two proof-nets B and B' whose respective conclusions are C,A and C,B (C is a sequence of formulas), form a box ~ whose oonclusions

are C and A & B ; the formu&a A & B is the main door of the box, whereas the formu%as C are its auxiliary doors. It is not problematic to normalize cuts when one of the premises is the main door of a &-box ;

the case. where one of the premises is an auxiliary door can be handled too, but in that case part of what we are doing may be eventually cancelled, hence it is more reasonable to wait in this case until

a cut arriving through the main door arises. Such a cut is normalized as follows :

BBI c
CUT

v~

AI
B1 le

A~

becomes

(symmetric solution for 2Q)

CvA 4',.
CUT This kind of situation is typical of IF THEN ELSE instructions. part of the structure, namely B' in the example given, A whole

is destroyed.

The commutative reductions, Which reduce cuts arising through one of the auxiliary doors ~, produce a duplication of the work, and this is why it reasonable to wait for the opening of~the main door. In doing so, we produce a phenomenon of synchronization, to the asynchronous multiplicative level. in sharp contrast

179

5. Storage

5.1. exponentials The storage operations are all those connected with the use of memory.

The use of a memory will be indicated connective,

instruction

in relation with an input of type A A by eA, where e is an exponential hgs been

by replacing

which indicates

which kind of memory operation is between the De Morgan

performed., The basic choice ! and ? : i) storage

dual connectives

: the output A is frozen in a memory. ! (of course),

The situation

is in-

dicated by the connective ii) maintenance here, of memory

of reaffirmation. are discussed

: three basic possibilities erasing, and reading

namely duplication,

(with a simultaneous here

erasing)

; other interesting

possibilities

are not considered

as primitive.

All these features

belong to the connective

? (why not)

of consideration. 5.2. the exponential ru&~s from a proof-net ending with !A and

! is handled by means of a box, namely, A and auxiliary ?C. conclusions

?__q, form a proof-net

ending with

? is handled by means of three rules,, namely i) contraction ?A 2A - - c ? ?A which has the same features as a "par"

link, and which takes ii) weakening,

care of duplication. in forming from proof-net, a box with

which sonsists

180

an additional

conclusion ?A, and which takes care of erasing. A


d?

iii) dereliction

, which corresponds

to reading/e~asing.

?A The exponential responsible level is particularily inportant, because it is

for the expressive

power of the language.

Without

storage operations, in a computation. of synchronization.

it would be impossible to make use of a memory

The formation of the [-box is an essential moment

6. abstraction

6.1. quantifiers When we want to abstract a given output from certain type contingencies, then we are lead to replace A by Q .A, where ~ is a variable of type,

and the quantifier Q denotes which kind.of abstraction has been performed ; there are two De Morgan dual quantifiers, A a abstraction and V ~ in

i) universal

: this is when the choice of a p a r a m e t e r ~ (any), the

A does not matter. universal

The situation is indicated b y A ~ . A

(second order) quantifier. abstraction : this is when we have obtained A by . The situation is

ii) existential

means of a spemific choice of the parameter indicated by V ~ . A (some), the existential

(second order) quantifier.

6.2. the quantifier rules A i is handled by means of a box : from a proof-net ending with A and auxiliary conclusions C not containing ~ free, then we can

181

form a box ending with A~.A and C. ~is handled by means of the unary rule

~ V
~. A

AB, ]

7. execution of a program

7.1. normalization The methods of 6G~rard 1970) can be extended here to provide a strong normalization described. theorem (cut-elimination) for the full system PN2 just are added

To the idea of "candidat de r~ductibilit~" considerations,

orthogonality proof.

which somehow simplify the original

There is therefore a way of executing a program by applying procedure, each symbol CUT being an indication ; the boxes are responsible for a

the normalization

for an independant processor phenomenon of waiting, 7.2. operational

i.e. introduce some synchronization.

semmntics is the written trace of a In other

One should consider that cut-elimination deeper procedure which is performed

at a semantic level.

terms there should be somewhere an operational logic. This operational semantics

semantics of linear cases

is only known in particular

e.g. for the multiplicatives. semantics

The generalization issue :

of the operational

to PN2 is a an essential

i) it will certainly shorten the execotion of programs, a lot of syntax will be dumped at the ground level. ii) it will enable us to use operations,

because

programs, etc. which are

182

not definable in PN2 (or by any other current logical system). of the main problems is to combine the advantages of semantics syntactical byzantinism) with those of the syntax (finitism) last point (finitism)

One (no

; the

is hard to get, due to the exponential level, in this direction. based

but there are positive~indications

iii) at a later stage, one can dream of a new kind of machine, on the operational semantics particularily simple,

; of course, this semantics has to be kept

if we want not to be ridiculous.

BIBLIOGRAPHY (Girard 1970) Une extension de l'interpr~tation de G~del & l'analyse et ~ la th@orie des types etc., Proc. 2nd Scand. North Holland Pub. C , Amsterdam 1971. (Girard 1986) Linear Logic, to appear in T.C.S. For a discussion of the sequential case, in relation to linear Log. Symp., ed Fenstad,

memory allocation and laziness, by means of intuitionistic logic, one can consult (Girard & Lafont 1986) Linear logic & lazy evaluation, the Proceedings of TAPSOFT'87, Pisa.

to appear in

You might also like