• Aucun résultat trouvé

The Curry-Howard correspondence

Dans le document manuscript (Page 21-25)

In this section, we will give two examples of the Curry-Howard correspondence: first we show the correspondence between minimal logic, the simply-typedλ-calculus and cartesian closed categories. Then we detail the sequent calculusLK, thus omiting the Curry-Howard correspondance with theλµ˜µ-calculus [16] and control categories [72].

2.1.1 Minimal logic and the lambda-calculus

This section consists in a very basic introduction to the Curry-Howard-Lambek correspondence. Programs are understood as terms of theλ-calculus. They are typed by formulas of minimal logic, and these types are interpreted in a cartesian closed category.

Definition 2.1.1. ConsiderAa set of atoms. Formulas of minimal implicative logic are terms constructed via the following syntax:A, B:“aPU|A //B

Definition 2.1.2. ConsiderXa set of variables. Terms of theλ-calculus are constructed via the following syntax:

t, u:“x| ptqu|λx.t

Typing judgements are denoted by Γ $ t : A, wheret is a term and Aa formula, and Γ a list of typing assignmentst1:A1. Then theλ-calculus is typed according to the following rules: to each variablexis assigned a typeA, and then:

xPX, aPA Γ, x:a$x:a

Γ$t:A //B, u:A Γ$ ptqu:B app Γ, x:A$t:B //

Γ$λx.t:A //B Theβ-reduction rule ofλ- calculus is the following:

pλx.tqu //tru{xs.

It preserves typing according to the cut rule above.

Categories The categorical semantics of a proof system interprets formulas by objects of a given category C, and sequentsA $ B as morphisms from an objectA to an objectB. We will see that the morphisms of a cartesian closed category interpret the typing judgements of the simply typedλ-calculus.

Definition 2.1.3. [56] A categoryCconsists in:

• A collectionOpCqof objects,

• A collection ApCqof arrows such that each arrow f has a domainA P OpCqandB P OpCq: we write f :A //Band the collection of all arrows with domainAand codomainBis denoted byCpA, Bq.

• For each objectsA,BandCa binary associative law:˝:CpA, Bq ˆCpB, Cq //CpA, Cq.

• For each objectAan arrow1APCpA, Aqsuch that for any objectB, any arrowsf :A //Bandg:B //A we have:

f˝1A “ fand1A˝g “ g.

A category is said to besmallif the collection of its objects is a set. A category is said to belocally smallif every hom-setCpA, Bqis a set. IfC is a category, one construct its opposite categoryCopwith the same objects but with reverse arrowsCoppB, Aq “ CpA, Bq.

Definition 2.1.4. A (covariant)functorFfrom categoriesCtoDis a map between the collections of objects and the collection of arrows foCandDrespectively such that:

Fpf :A //Bq:FpAq //FpBqandFpf˝gq “ Fpfq ˝Fpgq.

AcontravariantfunctorF from a categoryCto a categoryDis a covariant functor fromC toDop. Without any further specifications, a functor is always supposed to be covariant.

Example2.1.5. ConsiderCa locally small category. Then for every objectCPCwe have a covariant functor CpC,_q:C //Set, BÞÑCpC, Bq, f PCpA, Bq ÞÑf˚:gPCpC, Aq ÞÑf˝gPCpC, Bq and a contravariant functor

Cp_, Cq:C //Set, AÞÑCpA, Cq, f PCpA, Bq ÞÑ˚f :gPCpA, Cq ÞÑg˝f PCpB, Cq.

Definition 2.1.6. We writeF :C //D. Anatural transformationηbetween two functorsF :C //DandG: C //Dis a collection of morphisms indexed by objects ofCsuch that:

ηA:FpAq //GpAq PDpFpAq,GpAqq

and such that for every objectA, B PC, arrowsf :A //Bwe haveηB˝Fpfq “ Gpfq ˝ηA. This diagram more precisely states the naturality inAof the collection of morphismsη.

FpAq

ηA

Fpfq//FpBq

ηB

GpAq Gpfq //GpBq

Definition 2.1.7. Two functorsF : C //DandG :D //Care respectively left adjoint and right adjoint if for each objectCPCandDPDwe have a bijection:

CpC,GpDqq »DpFpCq, Dq which is natural inCandD. We writeF %Gand we denote this as:

C D

F

G

%

Through this adjunction, there is a natural transformationd:F˝G //IdD which is called theco-unit, such that for anyDPDdD:FpGpDqq //Dis the morphism ofDcorresponding to1GpDqPCpGpDq,GpDqqthrough the adjunction. Similarly, there is a natural transformationd:IdC //G˝F //IdCwhich is called theunit, such that for anyCPCdC:C //GpFpCqqis the morphism ofCcorresponding to1FpVqPDpFpCq,FpCqqthrough the adjunction.

Definition 2.1.8. The categoriesCandDare said to beequivalentthrough an adjunction if the unit and the co-unit are isomorphisms.

The definition of product categories and bifunctors is straightforward [56]. A terminal object in a categoryCis an objectKofCsuch that for every objectAofC, there is a unique arrowtA:A //K.

Definition 2.1.9. A cartesian category is a categoryC endowed with a terminal object Kand binary law ˆ : CˆC //Csuch that for every objectsA, BPC, there are arrows (projections)

πA:AˆB //A, πB:AˆB //B

such that for every objectCofC, for every arrowsf PCpC, Aq,g PCpC, Bq, there is a unique arrowxf, gy P CpC, AˆBqsatisfyingf “ πA˝ xf, gyandg “ πB˝ xf, gy.

Then one can show that this binary ruleˆis commutative and associative. The definition of an-ary product is thus immediate. This category iscartesian closedif for every objectBPCwe have a functorrB,_s:C //Cand an adjunction:

CpAˆB, Cq »CpA,rB, Csq

Thus to the morphismidrA,BsPCprA, Bs,rA, Bsqcorresponds a unique morphism:

evA,B:rA, Bs ˆA //B.

Interpretation of the simply typedλ-calculus in categories ConsiderCa cartesian closed category. With every typing judgement one assigns an object inC:

• Ifxis a variable,x:Ais matched to an arbitrary objectAPC,

• t:A //Bis matched torA, Bs.

To a typing contextx1 : A1, ..., xn : Anone assigns the product of the interpretation of the types. To every typing derivationΓ$t:Bone assigns a morphism inCpΓ, Bqaccording to the following rules:

• To the axiomx1 :A1, ..., xn :An $xi :Aicorresponds thei-th projectionπi:A1ˆ...ˆAn //Aion the last item of a product.

• From an arrowf P CpA1ˆ...ˆAnˆA, Bqcorresponding tox1 : A1, ..., xn : An, t : A$u: B,one constructs via the closedness property an arrow inCpA1ˆ...ˆAn,rA, Bsq.

• From an arrowf PCpA1ˆ...ˆAn,rA, Bsqcorresponding tox1:A1, ..., xn :An $u:A //Band an arrowgPCpB1ˆ...ˆBn, Aqcorresponding toy1:B1, ..., yn:Bm$t:A,one constructs viaevA,Ban arrow inCpA1ˆ...ˆAnˆB1ˆ...ˆBm, Bq.

2.1.2 LK and classical Logic

Classical logic is the logic satisfying the excluded middle: the formulaA_ Ais provable, even if one cannot construct a proof ofAor a proof of A. This is equivalent as being allowed to eliminate the double-negation: if we can prove the negation of the negation ofA, then one can proveA. In other words, if we have a proof that the negation ofA implies the absurd, then this is a proof forA. Classical logic have been criticized for being to non-constructive: a witness for the fact that the negation ofAis impossible is not really an inhabitant ofA.

However, it was highlighted by Griffin [35] that classical logics has a computational content, as it allows to type exceptions handlers.

This will be illustrated here by detailing the propositional classical sequent calculusLKintroduced by Gentzen [28].

Asequent calculusconsists in formulas, sequents, and rules allowing to deduce sequents from axioms. Aformula is a tree constructed from atoms, logical connectives and constants. LetAbe a set of atomsaPA.

Asequentis an expressionΓ $ ∆, whereΓand∆are both finite sequences of formulas. The (non-linear, usual) intuition is that writingΓ $ ∆ means that from the conjunction of the formulas ofΓ(i.e. from all the formulas ofΓ), one can deduce the disjunction of the formulas of∆.

Definition 2.1.10. The formulas ofLKare defined according to the following grammar:

A, B:“ J | K |a|A_B |A^B.

In the above definition,_denotes the disjunction (AorB) while^denotes the conjunction (AandB). One also defines an involutive negation p¨qon formulas:

J “ K K “ J pA_Bq “ A^ B pA^Bq “ A_ B.

As we are in a classical logic,Ashould be provable under the hypotheses of∆if and only if no contradiction arise from the set of hypotheses∆, AK, or likewhise if one can prove∆K, A. This justifies a monolateral presen-tation$Γof sequents, were$ΓK,∆stands forΓ$∆. The deduction rules for LK are detailed in figure2.1.2.

What happens between a bilateral and a monolateral presentation is the following: while in a bilateral presentation, one would need to introduce a rule (for example a logical rule introducing a connective) to the left and to the right, it is now enough to introduce it to the right. For example, a bilateral version ofLKfeatures the rules:

Γ$A,∆ Γ$B,∆

Notice the symmetry between the introduction of a connective to the left and the introduction of its dual on the right. In the monolateral presentation of LK in figure2.1.2, rules on the left are replaced by their dual rules on the right. What makes this logic classical is precisely the fact that Ais involutive: a formula is logically isomorphic to its double negation.

The identity group

Structural rules Structural rules ofLKare the ones describing the operations onΓand∆that do not change the logical content of the sequentΓ$∆. Namely, contraction allows the duplication of a formula on the left (an hypothesis can be used twice), or on the right (if one can prove a formula once, then one can do it twice).

Additive and multiplicative rules When such structural rules are allowed, then each rule has two versions, an additive one and a multiplicative one. Additive ones are the one that do not make a distinction between the context of two given sequents of a rule, while multiplicative ones are those which concatenate the context of the premisses.

These additive and multiplicative presentations are equivalent because of the structural rules. We will see later in Section2.2how linear logic, which restrains the use of structural rules on specific formulas, imposes a distinction between an additive and a multiplicative disjunction or conjunction.

Reversible rules Another distinction is to be made betweenreversibleandirreversiblerules. Reversible rules are the one such that if the provability of the conclusion is equivalent to provability of the premisses. Irreversible rules are those for which this is not true. In LK, the additive rule for^and the multiplicative rule for_are re-versible, while the other logical rules are irreversible. Again, polarized linear logic will refine this by distinguishing negatives and positives formulas.

Proofs Aproof consists in a proof tree, with axioms as leaves, inference rules at each branching and a sequent at the root. Let us introduce a few more definitions. An inference rule between two sequents isderivableif the conclusion sequent can be derived from the premisse. A sequent isprovablein a proof system if it can be derived from axioms using the inference rules of the proof system.

Example2.1.11. Here are a few examples of proof-trees for derivable sequents inLK.

$A, A ax

A fundamental result of Gentzen is thecut-eliminationtheorem. It states that any sequent which is provable in LKadd is provable without the cut rule, and most importantly gives an deterministic algorithm to eliminate the cut-rules from a proof. That is, any provable sequent can be proved using only rules which will introduce its connectives. This theorem also implies thatLKiscoherent, meaning that$ Kis not provable. Indeed, a cut-free proof ofKwould imply an introduction rule forK.

Dans le document manuscript (Page 21-25)