• Aucun résultat trouvé

Proof Normalisation in a Logic Identifying Isomorphic Propositions

N/A
N/A
Protected

Academic year: 2021

Partager "Proof Normalisation in a Logic Identifying Isomorphic Propositions"

Copied!
24
0
0

Texte intégral

(1)

HAL Id: hal-02909135

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

Submitted on 30 Jul 2020

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.

Propositions

Alejandro Díaz-Caro, Gilles Dowek

To cite this version:

Alejandro Díaz-Caro, Gilles Dowek. Proof Normalisation in a Logic Identifying Isomorphic Proposi-

tions. FSCD 2019 - International Conference on Formal Structures for Computation and Deduction,

Jun 2019, Dortmund, Germany. �hal-02909135�

(2)

Isomorphic Propositions

Alejandro Díaz-Caro

Instituto de Ciencias de la Computación (CONICET-Universidad de Buenos Aires) Universidad Nacional de Quilmes, Argentina

adiazcaro@icc.fcen.uba.ar

Gilles Dowek

Inria, LSV, ENS Paris-Saclay, France gilles.dowek@ens-paris-saclay.fr

Abstract

We define a fragment of propositional logic where isomorphic propositions, such asAB andBA, orA⇒(B∧C) and (AB)∧(A⇒C) are identified. We define System I, a proof language for this logic, and prove its normalisation and consistency.

2012 ACM Subject Classification Theory of computation→Proof theory; Mathematics of comput- ing→Lambda calculus; Theory of computation→Type theory

Keywords and phrases Simply typed lambda calculus, Isomorphisms, Logic, Cut-elimination, Proof- reduction.

Related Version A variant of the system presented in this paper, has been published in https:

//arxiv.org/abs/1303.7334v1(LSFA 2012 [13]), with a sketch of a subject reduction proof but no normalisation or consistency proofs.

Funding Partially supported by ECOS-Sud A17C03, PICT 2015-1208, and the French-Argentinian laboratory SINFIN.

1 Introduction

1.1 Identifying isomorphic propositions

In mathematics, addition is associative and commutative, multiplication distributes over addition, etc. In contrast, in logic conjunction is neither associative nor commutative, implication does not distribute over conjunction, etc. For instance, the propositionsAB andBAare different: ifAB has a proof, then so doesBA, but ifris a proof ofAB, then it is not a proof ofBA.

A first step towards consideringAB andBAas the same proposition has been made in [6, 11, 12, 26], where a notion of isomorphic propositions has been defined: two propositions AandB are isomorphic if there exist two proofs ofAB andBAwhose composition, in both ways, is the identity.

For the fragment of propositional logic restricted to the operations ⇒and ∧, all the isomorphisms are consequences of the following four:

ABBA (1)

A∧(B∧C)≡(A∧B)C (2)

A⇒(B∧C)≡(A⇒B)∧(A⇒C) (3)

(A∧B)CABC (4)

For example, (A⇒BC)≡(B ⇒AC) is a consequence of (4) and (1) [6].

arXiv:1501.06125v8 [cs.LO] 22 Apr 2019

(3)

In this paper, we go one step further and define a proof language, System I, for the fragment ⇒, ∧, such that when AB, then any proof of A is also a proof ofB, so the propositionsAB andBA, for instance, are really identical, as they have the same proofs.

The idea of identifying some propositions has already been investigated, for example, in Martin-Löf’s type theory [23], in the Calculus of Constructions [8], and in Deduction modulo theory [17, 19], where definitionally equivalent propositions, for instanceAB, A∈ P(B), and∀x(x∈AxB) can be identified. But definitional equality does not handle isomorphisms. For example, AB andBA are not identified in these logics.

Beside definitional equality, identifying isomorphic types in type theory, is also a goal of the univalence axiom [27].

Isomorphisms make proofs more natural. For instance, to prove (A∧(A⇒B))B in natural deduction we need to introduce conjunctive hypothesisA∧(A⇒B) which has to be decomposed intoAandAB, while using the isomorphism (4) allows to transform the goal toA⇒(A⇒B)B and introduce directly the hypothesesAandAB, eliminating completely the need for conjunctive hypotheses.

1.2 Lambda-calculus

The proof-language of the fragment of propositional logic restricted to the operations ⇒ and ∧ is simply typed lambda-calculus extended with Cartesian product. So, System I is an extension of this calculus where, for example, a pair of functions hr, si of type (A⇒B)∧(A⇒C)A⇒(B∧C) can be applied to an argumentt of typeA, yielding a termhr, sit of typeBC. For example, the termhλxτ.x, λxτ.xiy has typeττ. With the usual reduction rules of lambda calculus with pairs, such a term would be normal, but we can also extend the reduction relation, with an equationhr, sithrt, sti, such that this term is equivalent toh(λxτ.x)y,(λxτ.x)yiand thus reduces tohy, yi. Taking too many of such equations may lead to non termination (Section 8.1), and taking too few multiplies undesired normal forms. The choice of the rules in this paper is motivated by the goal to have both termination of reduction (Section 5) and consistency (Section 6), that is, no normal closed term of atomic types.

To stress the associativity and commutativity of the notion of pair, we writer×sinstead ofhr, siand thus write this equivalence as

(r×s)trt×st

Several similar equivalence rules on terms are introduced: one related to the isomorphism (1), the commutativity of the conjunction,r×ss×r; one related to the isomorphism (2), the associativity of the conjunction, (r×s)×tr×(s×t); two to the isomorphism (3), the distributivity of implication with respect to conjunction,λx.(r×s)λx.r×λx.s and (r×s)trt×st; and one related to the isomorphism (4), the currification,rstr(s×t).

One of the difficulties in the design of System I is the design of the elimination rule for the conjunction. A rule like “ifr:AB thenπ1(r) :A”, would not be consistent. Indeed, if AandB are two arbitrary types,sa term of typeAandta term of typeB, thens×thas both typeAB and type BA, thusπ1(s×t) would have both typeAand type B. A solution is to consider explicitly typed (Church style) terms, and parametrise the projection by the type: ifr:ABthenπA(r) :Aand the reduction rule is then thatπA(s×t) reduces tosifshas typeA.

This rule makes reduction non-deterministic. Indeed, in the particular case where A happens to be equal toB, then both sandt have typeA andπA(s×t) reduces both tos and tot. Notice that, although this reduction rule is non-deterministic, it preserves typing,

(4)

like the calculus developed in [18], where the reduction is non-deterministic, but verifies subject reduction.

1.3 Non-determinism

Therefore, System I is one of the many non-deterministic calculi in the sense, for instance, of [5,7,9,10,24] and our pair-construction operator×is also the parallel composition operator of a non-deterministic calculus.

In non-deterministic calculi, the non-deterministic choice is such that ifrandsare twoλ- terms, the termr⊕srepresents the computation that runs eitherrorsnon-deterministically, that is such that (r⊕s)treduces either tortorst. On the other hand, the parallel composition operator|is such that the term (r|s)treduces tort|stand continue running bothrtandst in parallel. In our case, givenrandsof typeAB andt of typeA, the termπB((r×s)t) is equivalent toπB(rt×st), which reduces tortorst, while the termrt×stitself would run both computations in parallel. Hence, our×is equivalent to the parallel composition while the non-deterministic choice⊕is decomposed into×followed by π.

In System I, the non-determinism comes from the interaction of two operators, ×andπ.

This is similar to quantum computing where the non-determinism comes from the interaction of two operators, the fist allowing to build a superposition, that is a linear combination, of two termsα.r+β.t, and the measurement operator π. In addition, in such calculi, the distributivity rule (r+s)trt+stis seen as the point-wise definition of the sum of two functions.

More generally, the calculus developed in this paper is also related to the algebraic calculi [1–4,14,16,28], some of which have been designed to express quantum algorithms. There is a clear link between the pair constructor×and the projectionπ, with the superposition constructor + and the measurementπon these calculi. In these cases, the pairs+tis not interpreted as a non-deterministic choice, but as a superposition of two processes runnings andt, and the operatorπis the projection related to the measurement, which is the only non-deterministic operator.

Outline

In Section 2, we define the notion of type isomorphism and prove elementary properties of this relation. In Section 3, we introduce System I. In Section 4, we prove its subject reduction.

In Section 5, we prove its strong normalisation. In Section 6, we prove its consistency. Finally, in Section 7, we discuss how System I could be used as a programming language.

2 Type isomorphisms 2.1 Types and isomorphisms

Types are defined by the following grammar A, B, C, . . . ::= τ | AB |AB whereτ is the only atomic type.

(5)

IDefinition 2.1 (Size of a type). The size of a type is defined as usual by s(τ) = 1

s(AB) =s(A) +s(B) + 1 s(AB) =s(A) +s(B) + 1

IDefinition 2.2(Congruence). The isomorphisms(1),(2), (3), and (4)define a congruence on types.

ABBA (1)

A∧(B∧C)≡(A∧B)C (2)

A⇒(B∧C)≡(A⇒B)∧(A⇒C) (3)

(A∧B)CABC (4)

2.2 Prime factors

IDefinition 2.3 (Prime types). A prime type is a type of the form C1⇒ · · · ⇒ Cnτ, withn≥0.

A prime type is equivalent to (Vn

i=1Ci)⇒τ, which is either equivalent toτ or toCτ, for someC. For uniformity, we may write∅ ⇒τ forτ.

We now show that each type can be decomposed into a conjunction of prime types. We use the notation [Ai]ni=1 for the multiset whose elements areA1, . . . , An. We may write [Ai]i

when the number of elements is not important. IfR = [Ai]i is a multiset of types, then conj(R) =V

iAi.

IDefinition 2.4. We write[A1, . . . , An]∼[B1, . . . , Bm]if n=m andBiAi.

IDefinition 2.5 (Prime factors). The multiset of prime factors of a typeA is inductively defined as follows

PF(τ) = [τ]

PF(A⇒B) = [(ACi)⇒τ]i=1n where[Ciτ]ni=1=PF(B) PF(A∧B) =PF(A)]PF(B)

with the convention thatA∧ ∅=A.

Note that ifBτ∈PF(A), thens(B)< s(A).

ILemma 2.6. For allA,A≡conj(PF(A)).

Proof. By induction ons(A).

IfA=τ, thenPF(τ) = [τ], and soconj(PF(τ)) =τ.

If A = BC, then PF(A) = [(B∧Ci) ⇒ τ]i, where [Ciτ]i = PF(C). By the induction hypothesis, C ≡V

i(Ciτ), hence, A = BCB ⇒ V

i(Ciτ) ≡ V

i(B⇒Ciτ)≡V

i((B∧Ci)⇒τ).

If A = BC, then PF(A) = PF(B)]PF(C). By the induction hypothesis, B ≡ conj(PF(B)), andC≡conj(PF(C)). Therefore,A=B∧C≡conj(PF(B))∧conj(PF(C))≡ conj(PF(B∧C))≡conj(PF(B)]PF(C)) =conj(PF(A)). J ILemma 2.7. IfAB, thenPF(A)∼PF(B).

Proof. First we check thatPF(A∧B)∼PF(B∧A) and similar for the other three isomorph- isms. Then we prove by structural induction that ifA andB are equivalent in one step, thenPF(A)∼PF(B). We conclude by an induction on the length of the derivation of the

equivalenceAB. J

(6)

2.3 Measure of types

The size of a type is not preserved by equivalence. For instance,τ ⇒(τ∧τ)≡(τ ⇒τ)∧(ττ), buts(τ ⇒(τ∧τ)) = 5 ands((ττ)∧(τ⇒τ)) = 7. Thus, we define another notion of measure of a type.

IDefinition 2.8 (Measure of a type). The measure of a type is defined as follows m(A) =X

i

(m(Ci) + 1) where [Ciτ]i=PF(A)

with the convention thatm(∅) = 0.

ILemma 2.9. If AB, thenm(A) =m(B).

Proof. By induction on s(A). Let PF(A) = [Ciτ]i and PF(B) = [Djτ]j. By Lemma 2.7, [Ciτ]i ∼ [Diτ]i. Without lost of generality, take CiDi. By the induction hypothesis,m(Ci) =m(Di). Then,m(A) =P

i(m(Ci) + 1) =P

i(m(Di) + 1) =

m(B). J

The following lemma shows that the measure m(A) verifies the usual properties.

ILemma 2.10.

1. m(AB)> m(A) 2. m(AB)> m(A) 3. m(AB)> m(B)

Proof.

1. PF(A) is a strict submultiset ofPF(A∧B).

2. Let PF(B) = [Ciτ]ni=1. Then,PF(A⇒B) = [(A∧Ci)⇒τ]ni=1. Hence,m(AB)m(AC1) + 1> m(AC1)≥m(A).

3. m(AB) =P

im(ACi) + 1>P

im(Ci) + 1 =m(B). J

2.4 Decomposition properties on types

In simply typed lambda calculus, the implication and the conjunction are constructors, that is AB is never equal to CD, if AB = A0B0, then A = A0 and B =B0, and the same holds for the conjunction. This is not the case in System I, where τ⇒(τ∧τ)≡(τ⇒τ)∧(τ⇒τ), but the connectors still have some coherence properties:

If AB ≡Vn

i=1Ci, then each Ci is equivalent to an implication ABi, where the conjunction of theBiis equivalent to B.

If AB ≡ V

iCi, then each Ci is a conjunction of elements, possibly empty, that contribute to Aand toB.

We state these properties in Corollary 2.12 and Lemma 2.15.

I Lemma 2.11. If ABC1C2, then C1AB1 and C2AB2 where BB1B2.

Proof. By Lemma 2.7, PF(A ⇒ B) ∼ PF(C1C2) = PF(C1)]PF(C2). Let PF(B) = [Diτ]ni=1, so PF(A ⇒ B) = [(ADi) ⇒ τ]ni=1. Without lost of generality, take PF(C1)∼[(A∧Di)⇒τ]ki=1 andPF(C2)∼[(A∧Di)⇒τ]ni=k+1. Therefore, by Lemma 2.6, we have AB ≡ Vk

i=1((A∧Di) ⇒ τ)∧Vn

i=k+1((A∧Di) ⇒ τ) ≡ (A ⇒ Vk

i=1(Diτ))∧(A⇒Vn

i=k+1(Diτ)). TakeB1=Vk

i=1Diτ andB2=Vn

i=k+1Diτ. Remark

thatC1AB1,C2AB2 andBB1B2. J

(7)

W Y V X R S

T U

W1W2 V1 V2

Wn Vn

R S

T1 T2 Tn

Figure 1

ICorollary 2.12. If AB ≡ Vn

i=1Ci, then for i ∈ {1, . . . , n}, we have CiABi

whereB≡Vn i=1Bi.

Proof. By induction onn. By Lemma 2.11,Vn−1

i=1 CiAB0 andCnABn, with BB0Bn. By the induction hypothesis, forin−1,CiABi whereB0≡Vn−1

i=1 Bi. Hence,B≡Vn

i=1Bi. J

ILemma 2.13. LetR, S, T and U be four multisets such that R]S=T]U, then there exist four multisetsV, W,X, and Y such that R=V ]X,S=W ]Y,T =V ]W, and

U =X]Y, cf. Figure 1.

Proof. Consider an elementaR]S =T]U. Letrbe the multiplicity of ainR,s its multiplicity inS,t its multiplicity inT, anduits multiplicity inU. We haver+s=t+u.

Ifrtwe put rcopies ofainV,trinW, 0 inX, anduinY. Otherwise, we put tinV,

0 inW,rt inX, andsinY. J

ICorollary 2.14. LetR andS be two multisets and(Ti)ni=1 be a family of multisets, such thatR]S=Un

i=1Ti. Then, there exist multisetsV1, . . . , Vn, W1, . . . , Wn such thatR=U

iVi

andS =U

iWi and for eachi,Ti=Vi]Wi, cf. Figure 1.

Proof. By induction onn. We haveR]S=Un−1

i=1 Ti]Tn. Then, by Lemma 2.13, there exist R0, S0, Vn, Wn such that R=R0]Vn, S=S0]Wn,Un−1

i=1 Ti=R0]S0, andTn =Vn]Wn. By induction hypothesis, there existV1, . . . , Vn−1andW1, . . . , Wn−1such thatR0=Un−1

i=1 Vi, S0=Un−1

i=1 Wi and eachTi=Vi]Wi. Hence,R=Un

i=1Vi andS =Un

i=1Wi. J

ILemma 2.15. IfAB ≡Vn

i=1Ci then there exists a partition E]F]Gof {1, . . . , n}

such that

Ci=AiBi, wheniE;

Ci=Ai, wheniF; Ci=Bi, wheniG;

A=V

i∈E]FAi; and B=V

i∈E]GBi. J

Proof. LetR=PF(A),S=PF(B), andTi=PF(Ci). By Lemma 2.7, we havePF(A∧B)∼ PF(V

iCi), that is R]S ∼ U

iTi. By Corollary 2.14, there exist Vi and Wi such that R=Un

i=1Vi, S =Un

i=1Wi, andTiVi]Wi. As Ti is non-empty, Vi andWi cannot be both empty.

IfVi andWi are both non-empty, we letiE andAi =conj(Vi) andBi=conj(Wi). By Lemma 2.6,Ci≡conj(Ti)≡conj(Vi]Wi)≡AiBi.

IfVi is non-empty andWiis empty, we let iF, andAi=conj(Vi)≡conj(Ti)≡Ci. IfWi is non-empty andViis empty, we let iG, andBi=conj(Wi)≡conj(Ti)≡Ci. AsVi=∅wheniG, we haveA≡conj(R)≡conj(U

i∈E]FVi)≡V

i∈E]FAi. AsWi=∅ wheniF, we haveB≡conj(S)≡conj(U

i∈E]GWi)≡V

i∈E]GBi. J

(8)

[x∈VA]

x:A (ax) [A≡B]

r:A r:B (≡) r:B

λxA.r:AB

(⇒i) r:AB s:A rs:B (⇒e)

r:A s:B r×s:AB (∧i)

r:AB πA(r) :A

(∧e)

Table 1The type system.

r×ss×r (comm)

(r×s)×tr×(s×t) (asso)

λxA.(r×s)λxA.r×λxA.s (distλ)

(r×s)trt×st (distapp)

rstr(s×t) (curry)

Table 2Symmetric relation.

3 System I 3.1 Syntax

We associate to each (up to equivalence) prime typeA an infinite set of variablesVA such that ifAB thenVA=VB and ifA6≡B thenVA∩ VB =∅. The set of terms is defined inductively by the grammar

r, s, t, . . . ::= x|λx.r |rs|r×s|πA(r)

We recall the type on binding occurrences of variables and writeλxA.tforλx.twhenx∈ VA. α-equivalence and substitution are defined as usual. The type system is given in Table 1. We use a presentation of typing rules without explicit context following [21, 25], hence the typing judgments have the formr:A. The preconditions of a typing rule is written on its left.

3.2 Operational semantics

The operational semantics of the calculus is defined by two relations: an equivalence relation, and a reduction relation.

I Definition 3.1. The symmetric relation is the smallest contextually closed relation defined by the rules given in Table 2.

Each isomorphism induces an equivalence between terms. Two rules however correspond to the isomorphism (3), depending on which distribution is taken into account: elimination or introduction of implication. We writefor the transitive and reflexive closure of. Note that is an equivalence relation.

Because of the associativity property of ×, the termr×(s×t) is equivalent to the term (r×s)×t, so we can just write itr×s×t.

As explained in the introduction, variables of conjunctive types are useless, hence all variables have prime types. This way, there is no termλxτ∧τ.x, but a termλyτ.λzτ.y×z which is equivalent to (λyτ.λzτ.y)×(λyτ.λzτ.z).

(9)

P(x) = 0 M(x) = 1

P(λxA.r) =P(r) M(λxA.r) = 1 +M(r) +P(r)

P(rs) =P(r) M(rs) =M(r) +M(s) +P(r)M(s) P(r×s) = 1 +P(r) +P(s) M(r×s) =M(r) +M(s)

P(πA(r)) =P(r) MA(r)) = 1 +M(r) +P(r) Table 3Measure on terms.

The size of a term is not invariant through the equivalence . Hence, we introduce a measureM(·), which is given in Table 3.

ILemma 3.2. IfrsthenP(r) =P(s).

Proof. We check the case of each rule of Table 2, and then conclude by structural induction to handle the contextual closure.

(comm): P(r×s) = 1 +P(r) +P(s) =P(s×r).

(asso): P((r×s)×t) = 2 +P(r) +P(s) +P(t) =P(r×(s×t)).

(distλ): P(λxA.(r×s)) = 1 +P(r) +P(s) =P(λxA.r×λxA.s).

(distapp): P((r×s)t) = 1 +P(r) +P(s) =P(rt×st).

(curry): P((rs)t) =P(r) =P(r(s×t)). J

ILemma 3.3. IfrsthenM(r) =M(s).

Proof. We check the case of each rule of Table 2, and then conclude by structural induction to handle the contextual closure.

(comm): M(r×s) =M(r) +M(s) =M(s×r).

(asso): M((r×s)×t) =M(r) +M(s) +M(t) =M(r×(s×t)).

(distλ): M(λxA.(r×s)) = 2 +M(r) +M(s) +P(r) +P(s) =M(λxA.r×λxA.s)

(distapp): M((r×s)t) =M(r) +M(s) + 2M(t) +P(r)M(t) +P(s)M(t) =M(rt×st)

(curry): M((rs)t) =M(r) +M(s) +P(r)M(s) +M(t) +P(r)M(t) =M(r(s×t)) J ILemma 3.4. M(λxA.r) > M(r), M(rs) > M(r), M(rs) > M(s), M(r×s) > M(r), M(r×s)> M(s), andMA(r))> M(r).

Proof. By induction onr, M(r)≥1. We conclude with a case inspection. J We use the measure to prove that the equivalence class of a term is a finite set.

ILemma 3.5. For any termr, the set{s| sr} is finite (moduloα-equivalence).

Proof. Since{s | s r} ⊆ {s | F V(s) = F V(r) and M(s) = M(r)} ⊆ {s | F V(s) ⊆ F V(r) and M(s) ≤M(r)}, where F V(t) is the set of free variables of t, all we need to prove is that for all natural numbersn, for all finite sets of variablesF, the setH(n, F) = {s|F V(s)⊆F andM(s)≤n}is finite.

By induction onn. Forn= 1 the set{s|F V(s)⊆F andM(s)≤1}contains only the variables ofF. Assume the property holds forn, then, by the Lemma 3.4 the setH(n+ 1, F) is a subset of the finite set containing the variables ofF, the abstractions (λxA.r) forrin H(n, F ∪ {x}), the applications (rs) forrandsinH(n, F), the productsr×sforr ands inH(n, F), the projectionsπA(r) forrinH(n, F). J

(10)

Ifs:A, (λxA.r)s ,r[s/x] (β) Ifr:A, πA(r×s),r (π)

Table 4Reduction relation.

I Definition 3.6. The reduction relation ,is the smallest contextually closed relation defined by the rules given in Table 4. We write, for the transitive and reflexive closure of ,→.

IDefinition 3.7. We write for the relation ,modulo (i.e. r s iff r r0 ,s0s), and for its transitive and reflexive closure.

Remark that, by Lemma 3.5, a term has a finite number of reducts in one step and these reducts can be computed.

3.3 Examples

IExample 3.8. Letr:Aand s:B. Then (λxA.λyB.x)(r×s) :Aand (λxA.λyB.x)(r×s)(λxA.λyB.x)rs ,r

However, ifAB, it is also possible to reduce in the following way (λxA.λyA.x)(r×s)(λxA.λyA.x)(s×r)(λxA.λyA.x)sr ,s

Hence, the usual encoding of the projector also behaves non-deterministically.

IExample 3.9. Lets:Aandt:B, and letTF=λxA.λyB.(x×y).

Then TF : AB ⇒ (A∧B) ≡ ((A∧B)A)∧((A∧B)B). Therefore, π(A∧B)⇒A(TF) : (A∧B)A. Hence,π(A∧B)⇒A(TF)(s×t) :A.

This term reduces as follows:

π(A∧B)⇒A(TF)(s×t)π(A∧B)⇒A(TF)st

π(A∧B)⇒A(λxA.(λyB.x)×(λyB.y))st π(A∧B)⇒A((λxA.λyB.x)×(λxA.λyB.y))st ,→(λxA.λyB.x)st

,→(λyB.s)t ,s

IExample 3.10. LetT=λxA.λyB.xandF=λxA.λyB.y. The termT×F×TFhas type ((A∧B)⇒(A∧B))∧((A∧B)⇒(A∧B)).

Hence,π(A∧B)⇒(A∧B)(T×F×TF) is well typed and reduces non-deterministically either toT×For toTF. Moreover, asT×FandTFare equivalent, the non-deterministic choice does not play any role in this particular case. We will come back to the encoding of booleans in System I on Section 7.

4 Subject Reduction

The set of types assigned to a term is preserved under and ,→. Before proving this property, we prove the unicity of types (Lemma 4.1), the generation lemma (Lemma 4.2), and the substitution lemma (Lemma 4.3). We only state the lemmas in this section. The detailed proofs can be found in Appendix A.

The following lemma states that a term can be typed only by equivalent types.

(11)

ILemma 4.1(Unicity). Ifr:Aandr:B, thenAB.

Proof.

If the last rule of the derivation ofr:Ais (≡), then we have a shorter derivation of r:C withCA, and, by the induction hypothesis,CB, henceAB.

If the last rule of the derivation ofr:B is (≡) we proceed in the same way.

All the remaining cases are syntax directed. J

ILemma 4.2(Generation).

1. If x∈ VA andx:B, thenAB.

2. If λxA.r:B, thenBAC andr:C.

3. If rs:B, then r:AB ands:A.

4. If r×s:A, thenABC withr:B ands:C.

5. If πA(r) :B, thenAB andr:BC.

Proof. Each statement is proved by induction on the typing derivation. For the statement 1, we havex∈ VA andx:B. The only way to type this term is either by the rule (ax) or (≡).

In the first case,A=B, henceAB.

In the second case, there existsB0 such thatx:B0 has a shorter derivation, andBB0. By the induction hypothesisAB0B.

For the statement 2, we haveλxA.r:B. The only way to type this term is either by rule (⇒i), (≡).

In the first case, we haveB =AC for some,C andr:C.

In the second, there existsB0 such that λxA.r:B0 has a shorter derivation, andBB0. By the induction hypothesis,B0AC andr:C. Thus,BB0AC.

The three other statements are similar. J

ILemma 4.3(Substitution). Ifr:A,s:B, andx∈ VB, thenr[s/x] :A.

Proof. By structural induction onr(cf. Appendix A). J

ITheorem 4.4 (Subject reduction). If r:A andr ,sor rsthen s:A.

Proof. By induction on the rewrite relation (cf. Appendix A). J

5 Strong Normalisation

In this section we prove the strong normalisation of reduction : every reduction sequence fired from a typed term eventually terminates. The set of strongly normalising terms with respect to reduction is written SN. The size of the longest reduction issued fromt is written|t|(recall that each term has a finite number of reducts).

To prove that every term is inSN, we associate, as usual, a setJAKof strongly normalising terms to each typeA. A termr:Ais said to be reducible whenr∈JAK. We then prove an adequacy theorem stating that every well typed term is reducible.

In simply typed lambda calculus we can either defineJA1A2⇒ · · · ⇒AnτKas the set of termsrsuch that for alls∈JA1K,rs∈JA2⇒ · · · ⇒AnτKor, equivalently, as the set of termsrsuch that for allsi∈JAiK,rs1. . . sn∈JτK=SN. To prove that a term of the formλxA.tis reducible, we need to use the so-called CR3 property [22], in the first case, and the property that a term whose all one-step reducts are inSNis inSN, in the second.

In System I, an introduction can be equivalent to an elimination e.g. rt×st (r×s)t, hence, we cannot define a notion of neutral term and have an equivalent to the CR3 property.

Therefore, we use the second definition.

(12)

Before we prove the normalisation of System I, we first reformulate the proof of strong normalisation of simply typed lambda-calculus along these lines.

5.1 Normalisation of simply typed lambda calculus

IDefinition 5.1(Elimination context). Consider an extension of simply typed lambda calculus where we introduce an extra symbol[]A, called hole of type A.

An elimination context with a hole []B1⇒···⇒Bn⇒τ is a term KBτ

1⇒···⇒Bn⇒τ of typeτ of the form[]B1⇒···⇒Bn⇒τr1. . . rn. We writeKAτ[t], for the termKAτ[t/[]A] =tr1. . . rn. IDefinition 5.2 (Terms occurring in an elimination context). T([]Ar1. . . rn) ={r1, . . . , rn}.

Note that the types of the elements of T([]Ar1. . . rn) are smaller than A, and that if r1, . . . , rn ∈SN, then[]Ar1. . . rn∈SN.

I Definition 5.3 (Reducibility). The set JAK of reducible terms of type A is defined by structural induction on Aas the set of termst:A such that for any elimination contextKAτ such that the terms in T(KAτ)are all reducible, we haveKAτ[t]∈SN.

IDefinition 5.4 (Reducible elimination context). An elimination context KAB is reducible, if all the terms in T(KAB) are reducible.

ILemma 5.5. For all A,JAK⊆SNand all the variables of type A are inJAK.

Proof. By induction onA. J

ILemma 5.6(Adequacy of application). If r∈JABKands∈JAK, thenrs∈JBK. Proof. Let KBτ be a reducible elimination context. We need to prove thatKBτ[rs]∈SN. As s∈JAK, the elimination contextKA⇒B =KBτ[[]A⇒Bs] is reducible, and sincer∈JABK,

we haveKBτ[rs] =KA⇒B [r]∈SN. J

I Lemma 5.7 (Adequacy of abstraction). If for all t ∈ JAK, r[t/x] ∈ JBK, then λxA.r ∈ JABK.

Proof. We need to prove that for every reducible elimination contextKA⇒Bτ ,KA⇒Bτ [λxA.r]∈ SN, that is that all its one step reducts are inSN. By Lemma 5.5,x∈JAK, sor∈JBK⊆SN.

Then, we proceed by induction on|r|+|KA⇒Bτ |. J

IDefinition 5.8(Adequate substitution). A substitutionσ is adequate if for all x:A, we have σ(x)∈JAK.

ITheorem 5.9 (Adequacy). If r:A, the for allσ adequate, we haveσr∈JAK.

Proof. By induction onr. J

ITheorem 5.10(Strong normalisation). If r:A, thenr∈SN.

Proof. By Lemma 5.5, the idendity substitution is adequate. Thus, by Theorem 5.9 and

Lemma 5.5,r∈JAK⊆SN. J

(13)

5.2 Reduction of a product

When simply-typed lambda-calculus is extended with pairs, proving that if r1 ∈ SNand r2 ∈ SNthen r1×r2 ∈ SNis easy. However, in System I this property (Lemma 5.13) is harder to prove, as it requires a characterisation of the terms equivalent to the product r1×r2 (Lemma 5.11) and of all the reducts of this term (Lemma 5.12).

In Lemma 5.11, we characterise the terms equivalent to a product.

ILemma 5.11. If r×st then either 1. t=u×v where either

a. ut11×t21 andvt12×t22 withrt11×t12 andst21×t22, or b. vw×s withru×w, or any of the three symmetric cases, or c. ruandsv, or the symmetric case.

2. t=λxA.a andaa1×a2 withrλxA.a1 andsλxA.a2. 3. t=av andaa1×a2, withr a1v andsa2v.

Proof. By a double induction, first on M(t) and then on the length of the relation

(cf. Appendix B.1). J

In Lemma 5.12, we characterise the reducts of a product.

ILemma 5.12. If r1×r2s ,t, there exists u1,u2 such thatt u1×u2 and either (r1 u1 andr2 u2), or (r1 u1 andr2u2), or (r1u1 andr2 u2).

Proof. By induction onM(r1×r2). J

ILemma 5.13. If r1∈SN andr2∈SN, thenr1×r2∈SN.

Proof. By Lemma 5.12, from a reduction sequence starting fromr1×r2 we can extract one starting fromr1, or r2 or both. Hence, this reduction sequence is finite. J

5.3 Reduction of a term of a conjunctive type

The next lemma takes advantage of the fact that all the variables have prime types to prove that all terms of conjunctive type, even open ones, reduce to a product. For instance, instead of the termλxτ∧τ.x, of type ((ττ)τ)∧((τ∧τ)⇒τ), we must write λyτ.λzτ.y×z, which is equivalent to (λyτ.λzτ.y)×(λyτ.λzτ.z).

ILemma 5.14. If r:Vn

i=1Ai, thenr Qn

i=1ri whereri:Ai. Proof. By induction onr.

r=x, then it has a prime type, so taker1=r.

Letr=λxC.s. Then, by Lemma 4.2,s:D withCD≡V

iAi. So, by Corollary 2.12, D ≡ V

iDi, and so, by the induction hypothesis, s Q

isi. Therefore, λxC.s Q

iλxC.si.

Letr=st. Then, by Lemma 4.2, s:C⇒V

iAi, sos:V

i(C⇒Ai). Therefore, by the induction hypothesis,s Q

isi, and sost Q

isit.

Letr=s×t. Then, by Lemma 4.2,s:B andt:C, withBC≡V

iAi. By Lemma 2.15, there exists a partition E]F]Gof {1, . . . , n} such that AiBiCi, when iE;

AiBi, when iF; AiCi, when iG; B ≡ V

i∈E]FBi; andC ≡ V

i∈E]GCi. By the induction hypothesis, s Q

i∈E]Fsi andt Q

i∈E]Gti. If iE, we let ri=si×ti, ifiF, we letri=si, ifiG, we letri=ti. We haver=s×t Qn

i=1ri.

(14)

Let r= πV

iAi(s). Then, by Lemma 4.2, s : V

iAiB, and hence, by the induction hypothesis,s Q

isi×t wheresi:Ai andt:B, hencer Q

isi. J

ICorollary 5.15. Ifr:AB, thenr r1×r2 wherer1:Aandr2:B.

Proof. LetPF(A) = [Ai]i,PF(B) = [Bj]j, by Lemma 2.6,AB≡V

iAi∧V

jBj. Then, by Lemma 5.14,r Q

ir1i×Q

jr2j. Taker1=Q

ir1i andr2=Q

jr2j. J

5.4 Reducibility

IDefinition 5.16 (Elimination context). Consider an extension of the language where we introduce an extra symbol []A, called hole of type A. We define the set of elimination contexts with a hole []A as the smallest set such that:

[]A is an elimination context of type A,

if KAB⇒C is an elimination context of typeBC with a hole of typeA, and r:B then KAB⇒Cris an elimination context of type C with a hole of type A,

and ifKAB∧Cis an elimination context of typeB∧Cwith a hole of typeA, thenπB(KAB∧C) is an elimination context of typeB with a hole of typeA.

We write KAB[t] for KAB[t/[]A], where []A is the hole of KAB. In particular, t may be an elimination context.

I Example 5.17. Let Kττ = []τ andKτ⇒(τ∧τ) =Kτττ([]τ⇒(τ∧τ)x)]. Then Kτ⇒(τ∧τ) = πτ([]τ⇒(τ∧τ)x), andKτ⇒(τ∧τ) [λyτ.y×y] =πτ((λyτ.y×y)x).

IDefinition 5.18 (Terms occurring in an elimination context). Let KAB be an elimination context. The multiset of terms occurring inKAB is defined as

T([]A) =∅; T(KAB⇒Cr) =T(KAB⇒C)] {r}; T(πB(KAB∧C)) =T(KAB∧C) We write|KAB| forPn

i=1|ri| where[r1, . . . , rn] =T(KAB).

IExample 5.19. T([]Ars) = [r, s] andT([]A(r×s)) = [r×s]. Remark thatKAB[t]KA0B[t]

does not implyT(KAB)∼ T(KA0B).

Remark that ifKAB is a context,m(B)m(A) and hence if a term inT(KAB) has type C, thenm(C)< m(A).

I Lemma 5.20. Let KAτ be an elimination context such thatT(KAτ)⊆ SN, let PF(A) = [B1, . . . , Bn], and letxi∈ VBi. ThenKAτ[x1× · · · ×xn]∈SN.

Proof. By induction on the number of projections inKAτ.

IfKAτ does not contain any projection, then it has the form []A r1... rm. LetCi be the type of ri, we haveAC1...Cnτ, thus A is prime,n= 1, and we need to prove that x1 r1 ... rmis inSNwhich is a consequence of the fact thatr1, ...,rn are in SN.

Otherwise, KAτ =KBB([]Ar1. . . rm)], and KAτ[x1× · · · ×xn] = KBB((x1× · · · × xn)r1. . . rm)]KBB(x1r1. . . rm× · · · ×xnr1. . . rm)]. We prove that this term is in SN by showing, more generally, that if si are reducts ofxir1. . . rm, then KBB(s1×

· · · ×sn)]∈SN. To do so, we show, by induction on|KB|+|s1× · · · ×sn|, that all the one step reducts of this term are inSN.

If the reduction takes place in one of the terms inT(KB) or in one of thesi, we apply the induction hypothesis.

(15)

Otherwise, the reduction is a (π) reduction of πB(s1× · · · ×sn) yielding, without lost of generality, a term of the form KB[s1× · · · ×sq]. This term is a reduct of KB[(x1× · · · ×xq)r1. . . rm]. As the contextKB[([]Cr1. . . rm)] contains one projection less thanKAτ this term is inSN. Hence so does its reductKB[s1× · · · ×sq]. J I Definition 5.21 (Reducibility). The set JAK of reducible terms of type A is defined by induction onm(A)as the set of termst:A such that for any elimination contextKAτ such that the terms of T(KAτ) are all reducible, we haveKAτ[t]∈SN.

IDefinition 5.22(Reducible elimination context). An elimination contextKAB is reducible, if all the terms inT(KAB)are reducible.

From now on we consider all the elimination contexts to be reducible.

The following lemma is a trivial consequence of the definition of reducibility.

ILemma 5.23. If AB, thenJAK=JBK. J

ILemma 5.24. For all A,JAK⊆SNandJAK6=∅.

Proof. By induction onm(A). By the induction hypothesis, for all theB such thatm(B)<

m(A),JBK6=∅. Thus, there exists an elimination contextKAτ. Hence, ifr∈JAK,KAτ[r]∈SN, hencer∈SN.

We then prove that if PF(A) = [B1, . . . , Bn] andxi ∈ VBi thenQ

ixi ∈ JAK. By the induction hypothesis,T(KAτ)⊆SN, hence, by Lemma 5.20,KAτ[x1× · · · ×xn]∈SN. J

5.5 Adequacy

We finally prove the adequacy theorem (Theorem 5.30) showing that every typed term is reducible, and the strong normalisation theorem (Theorem 5.31) as a consequence of it.

ILemma 5.25(Adequacy of projection). If r∈JABK, thenπA(r)∈JAK.

Proof. We need to prove that KAτA(r)] ∈ SN. Take KA∧B = KAτA[]A∧B] and since r∈JABK, we haveKAτA(r)] =KA∧B [r]∈SN. J ILemma 5.26(Adequacy of application). If r∈JABK, ands∈JAK, thenrs∈JBK. Proof. We need to prove that KBτ[rs] ∈ SN. Take KA⇒B = KBτ[[]A⇒Bs] and since r

JABK, we haveKBτ[rs] =KA⇒B [r]∈SN. J

ILemma 5.27(Adequacy of product). If r∈JAK ands∈JBK, thenr×s∈JABK. Proof. We need to prove thatKA∧Bτ [r×s]∈SN. We proceed by induction on the number of projections inKA⇒Bτ . Since the hole of KA∧Bτ has typeAB, andKA∧Bτ [t] has type τ for any t : A, we can assume, without lost of generality, that the context KA∧Bτ has the formKCC([]A∧Bt1. . . tn)]. We prove that allKCC(rt1. . . tn×st1. . . tn)]∈SNby showing, more generally, that ifr0 ands0 are two reducts ofrt1. . . tn andst1. . . tn, then KCC(r0×s0)]∈SN. For this, we show that all its one step reducts are inSN, by induction on|KC|+|r0|+|s0|. Full details are given in Appendix B.2. J ILemma 5.28 (Adequacy of abstraction). If for all t ∈JAK, r[t/x]∈ JBK, then λxA.r ∈ JABK.

Références

Documents relatifs

Dans un contexte victorien où Pater se donnait pour tâche, à l’instar de Carlyle et de Matthew Arnold, de redéfinir la notion de « culture », non seulement

The strong normalization of a typed λµ-calculus can be deduced from the one of the corresponding typed λ-calculus by using CPS translations. See, for example, [14] for such

Since Griffin (Griffin, 1990) has shown that Felleisen’s operator C (Felleisen &amp; all, 1987) may be typed by using classical logic and thus has opened the proof as pro- gram

functions reuches the extreme bound of 9 possible simplification.. function belongs to

We prove that the strong detonation travelling waves for a viscous combustion model are nonlinearly stable, that is, for a given perturbation of a travelling wave, the

Delano¨e [4] proved that the second boundary value problem for the Monge-Amp`ere equation has a unique smooth solution, provided that both domains are uniformly convex.. This result

Recent work in semantics of programming languages and program logics has suggested that there might be a connection between metric spaces and Nakano’s typed lambda calculus with

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