Top Banner
Soutenance de thèse Du typage vectoriel Alejandro Díaz-Caro CAPP Team Adviser: Co-adviser: Pablo Arrighi Frédéric Prost 23 – 09 – 2011
61

Slides used during my thesis defense "Du typage vectoriel"

Dec 18, 2014

Download

Technology

The objective of this thesis is to develop a type theory for the linear-algebraic λ-calculus, an extension of λ-calculus motivated by quantum computing. This algebraic extension encompass all the terms of λ-calculus together with their linear combinations, so if t and r are two terms, so is α.t + β.r, with α and β being scalars from a given ring. The key idea and challenge of this thesis was to introduce a type system where the types, in the same way as the terms, form a vectorial space, providing the information about the structure of the normal form of the terms. This thesis presents the system Lineal, and also three intermediate systems, however interesting by themselves: Scalar, Additive and λCA, all of them with their subject reduction and strong normalisation proofs.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Slides used during my thesis defense "Du typage vectoriel"

Soutenance de thèse

Du typage vectorielAlejandro Díaz-Caro

CAPP Team

Adviser: Co-adviser:

Pablo Arrighi Frédéric Prost

23 – 09 – 2011

Page 2: Slides used during my thesis defense "Du typage vectoriel"

Lambda calculus [Church’36]

Type system [Church’40]

Formal system to study the defini-tion of function

f (x) ∼ txx 7→ f (x) ∼ λx.tx

(x 7→ f (x))r ∼ (λx.tx ) r(x 7→ f (x))r = f (r) ∼ (λx.tx ) r → tx [r/x]

t, r ::= x | λx .t | (t) r(λx .t) r→ t[r/x ]

“a tractable syntactic frameworkfor classifying phrases according tothe kinds of values they compute”–[Pierce’02]

λx .tx : T → R r : T

(λx .tx) r : R

System F [Girard’71]

Curry-Howard correspondence

TS with a universal quantificationover types

λx .x : Int → Intλx .x : Bool → Bool

. . .

λx .x : ∀X .X → X

Correspondence between type sys-tems and logic

λx .tx : T → R r : T

(λx .tx) r : Rm

T ⇒ R T

R

Church vs. Curry style whether the types are part of the terms or not

2 / 24

Page 3: Slides used during my thesis defense "Du typage vectoriel"

Lambda calculus [Church’36] Type system [Church’40]

Formal system to study the defini-tion of function

f (x) ∼ txx 7→ f (x) ∼ λx.tx

(x 7→ f (x))r ∼ (λx.tx ) r(x 7→ f (x))r = f (r) ∼ (λx.tx ) r → tx [r/x]

t, r ::= x | λx .t | (t) r(λx .t) r→ t[r/x ]

“a tractable syntactic frameworkfor classifying phrases according tothe kinds of values they compute”–[Pierce’02]

λx .tx : T → R r : T

(λx .tx) r : R

System F [Girard’71]

Curry-Howard correspondence

TS with a universal quantificationover types

λx .x : Int → Intλx .x : Bool → Bool

. . .

λx .x : ∀X .X → X

Correspondence between type sys-tems and logic

λx .tx : T → R r : T

(λx .tx) r : Rm

T ⇒ R T

R

Church vs. Curry style whether the types are part of the terms or not

2 / 24

Page 4: Slides used during my thesis defense "Du typage vectoriel"

Lambda calculus [Church’36] Type system [Church’40]

Formal system to study the defini-tion of function

f (x) ∼ txx 7→ f (x) ∼ λx.tx

(x 7→ f (x))r ∼ (λx.tx ) r(x 7→ f (x))r = f (r) ∼ (λx.tx ) r → tx [r/x]

t, r ::= x | λx .t | (t) r(λx .t) r→ t[r/x ]

“a tractable syntactic frameworkfor classifying phrases according tothe kinds of values they compute”–[Pierce’02]

λx .tx : T → R r : T

(λx .tx) r : R

System F [Girard’71]

Curry-Howard correspondence

TS with a universal quantificationover types

λx .x : Int → Intλx .x : Bool → Bool

. . .

λx .x : ∀X .X → X

Correspondence between type sys-tems and logic

λx .tx : T → R r : T

(λx .tx) r : Rm

T ⇒ R T

R

Church vs. Curry style whether the types are part of the terms or not

2 / 24

Page 5: Slides used during my thesis defense "Du typage vectoriel"

Lambda calculus [Church’36] Type system [Church’40]

Formal system to study the defini-tion of function

f (x) ∼ txx 7→ f (x) ∼ λx.tx

(x 7→ f (x))r ∼ (λx.tx ) r(x 7→ f (x))r = f (r) ∼ (λx.tx ) r → tx [r/x]

t, r ::= x | λx .t | (t) r(λx .t) r→ t[r/x ]

“a tractable syntactic frameworkfor classifying phrases according tothe kinds of values they compute”–[Pierce’02]

λx .tx : T → R r : T

(λx .tx) r : R

System F [Girard’71] Curry-Howard correspondenceTS with a universal quantificationover types

λx .x : Int → Intλx .x : Bool → Bool

. . .

λx .x : ∀X .X → X

Correspondence between type sys-tems and logic

λx .tx : T → R r : T

(λx .tx) r : Rm

T ⇒ R T

R

Church vs. Curry style whether the types are part of the terms or not

2 / 24

Page 6: Slides used during my thesis defense "Du typage vectoriel"

Lambda calculus [Church’36] Type system [Church’40]

Formal system to study the defini-tion of function

f (x) ∼ txx 7→ f (x) ∼ λx.tx

(x 7→ f (x))r ∼ (λx.tx ) r(x 7→ f (x))r = f (r) ∼ (λx.tx ) r → tx [r/x]

t, r ::= x | λx .t | (t) r(λx .t) r→ t[r/x ]

“a tractable syntactic frameworkfor classifying phrases according tothe kinds of values they compute”–[Pierce’02]

λx .tx : T → R r : T

(λx .tx) r : R

System F [Girard’71] Curry-Howard correspondenceTS with a universal quantificationover types

λx Int .x : Int → IntλxBool .x : Bool → Bool

. . .

ΛX .λxX .x : ∀X .X → X

Correspondence between type sys-tems and logic

λx .tx : T → R r : T

(λx .tx) r : Rm

T ⇒ R T

R

Church vs. Curry style whether the types are part of the terms or not2 / 24

Page 7: Slides used during my thesis defense "Du typage vectoriel"

To capture probabilistic/quantum/quantitative constructions:

algebraic extensions

t, r ::= x | λx .t | (t) r | t + r | α.t | 0 α ∈ (S,+,×), a ring.

Two origins:I Differential λ-calculus [Ehrhard’03]: linearity à la Linear Logic

Removing the differential operator : Algebraic λ-calculus (λalg) [Vaux’09]

I Quantum computing: superposition of programsLinearity as in algebra: Linear-algebraic λ-calculus (λlin) [Arrighi,Dowek’08]

Beta reduction:(λx .t) r→ t[r/x ]

“Algebraic” reductions:α.t + β.t → (α + β).t,

α.β.t → (α× β).t,(t) (r1 + r2) → (t) r1 + (t) r2,

(t1 + t2) r → (t1) r + (t2) r,. . .

(oriented version of the axioms ofvectorial spaces)[Arrighi,Dowek’07]

Vectorial space of values

B = {ti : ti var. or abs. }

Set of values ::= Span(B)

3 / 24

Page 8: Slides used during my thesis defense "Du typage vectoriel"

To capture probabilistic/quantum/quantitative constructions:

algebraic extensions

t, r ::= x | λx .t | (t) r | t + r | α.t | 0 α ∈ (S,+,×), a ring.

Two origins:I Differential λ-calculus [Ehrhard’03]: linearity à la Linear Logic

Removing the differential operator : Algebraic λ-calculus (λalg) [Vaux’09]

I Quantum computing: superposition of programsLinearity as in algebra: Linear-algebraic λ-calculus (λlin) [Arrighi,Dowek’08]

Beta reduction:(λx .t) r→ t[r/x ]

“Algebraic” reductions:α.t + β.t → (α + β).t,

α.β.t → (α× β).t,(t) (r1 + r2) → (t) r1 + (t) r2,

(t1 + t2) r → (t1) r + (t2) r,. . .

(oriented version of the axioms ofvectorial spaces)[Arrighi,Dowek’07]

Vectorial space of values

B = {ti : ti var. or abs. }

Set of values ::= Span(B)

3 / 24

Page 9: Slides used during my thesis defense "Du typage vectoriel"

To capture probabilistic/quantum/quantitative constructions:

algebraic extensions

t, r ::= x | λx .t | (t) r | t + r | α.t | 0 α ∈ (S,+,×), a ring.

Two origins:I Differential λ-calculus [Ehrhard’03]: linearity à la Linear Logic

Removing the differential operator : Algebraic λ-calculus (λalg) [Vaux’09]

I Quantum computing: superposition of programsLinearity as in algebra: Linear-algebraic λ-calculus (λlin) [Arrighi,Dowek’08]

Beta reduction:(λx .t) r→ t[r/x ]

“Algebraic” reductions:α.t + β.t → (α + β).t,

α.β.t → (α× β).t,(t) (r1 + r2) → (t) r1 + (t) r2,

(t1 + t2) r → (t1) r + (t2) r,. . .

(oriented version of the axioms ofvectorial spaces)[Arrighi,Dowek’07]

Vectorial space of values

B = {ti : ti var. or abs. }

Set of values ::= Span(B)

3 / 24

Page 10: Slides used during my thesis defense "Du typage vectoriel"

To capture probabilistic/quantum/quantitative constructions:

algebraic extensions

t, r ::= x | λx .t | (t) r | t + r | α.t | 0 α ∈ (S,+,×), a ring.

λalg λlinOrigin Linear Logic Quantum computing

Evaluation strategy Call-by-name Call-by-baseAlgebraic part Equalities Rewrite system

Contribution: CPS simulation [Díaz-Caro,Perdrix,Tasson,Valiron’10]

Beta reduction:(λx .t) r→ t[r/x ]

“Algebraic” reductions:α.t + β.t → (α + β).t,

α.β.t → (α× β).t,(t) (r1 + r2) → (t) r1 + (t) r2,

(t1 + t2) r → (t1) r + (t2) r,. . .

(oriented version of the axioms ofvectorial spaces)[Arrighi,Dowek’07]

Vectorial space of values

B = {ti : ti var. or abs. }

Set of values ::= Span(B)

3 / 24

Page 11: Slides used during my thesis defense "Du typage vectoriel"

Example of program

Two base vectors: true = λx .λy .xfalse = λx .λy .y

Linear map U s.t. (U)true = a.true + b.false(U)false = c .true + d .false

U := λx .{((x) [a.true + b.false]) [c .true + d .false]}

Aim:To provide a type system capturing the “vectorial” structure of terms

. . . to check for properties of probabilistic processes

. . . to check for properties of quantum processes

. . . or whatever application needing the structure of the vectorin normal form

. . . understand what it means “linear combination of types”

. . . a Curry-Howard approach to definingFuzzy/Quantum/Probabilistic logics fromFuzzy/Quantum/Probabilistic programming languages.

4 / 24

Page 12: Slides used during my thesis defense "Du typage vectoriel"

Example of program

Two base vectors: true = λx .λy .xfalse = λx .λy .y

Linear map U s.t. (U)true = a.true + b.false(U)false = c .true + d .false

U := λx .{((x) [a.true + b.false]) [c .true + d .false]}

Aim:To provide a type system capturing the “vectorial” structure of terms

. . . to check for properties of probabilistic processes

. . . to check for properties of quantum processes

. . . or whatever application needing the structure of the vectorin normal form

. . . understand what it means “linear combination of types”

. . . a Curry-Howard approach to definingFuzzy/Quantum/Probabilistic logics fromFuzzy/Quantum/Probabilistic programming languages.

4 / 24

Page 13: Slides used during my thesis defense "Du typage vectoriel"

Example of program

Two base vectors: true = λx .λy .xfalse = λx .λy .y

Linear map U s.t. (U)true = a.true + b.false(U)false = c .true + d .false

U := λx .{((x) [a.true + b.false]) [c .true + d .false]}

Aim:To provide a type system capturing the “vectorial” structure of terms

. . . to check for properties of probabilistic processes

. . . to check for properties of quantum processes

. . . or whatever application needing the structure of the vectorin normal form

. . . understand what it means “linear combination of types”

. . . a Curry-Howard approach to definingFuzzy/Quantum/Probabilistic logics fromFuzzy/Quantum/Probabilistic programming languages.

4 / 24

Page 14: Slides used during my thesis defense "Du typage vectoriel"

Example of program

Two base vectors: true = λx .λy .xfalse = λx .λy .y

Linear map U s.t. (U)true = a.true + b.false(U)false = c .true + d .false

U := λx .{((x) [a.true + b.false]) [c .true + d .false]}

Aim:To provide a type system capturing the “vectorial” structure of terms

. . . to check for properties of probabilistic processes

. . . to check for properties of quantum processes

. . . or whatever application needing the structure of the vectorin normal form

. . . understand what it means “linear combination of types”

. . . a Curry-Howard approach to definingFuzzy/Quantum/Probabilistic logics fromFuzzy/Quantum/Probabilistic programming languages.

4 / 24

Page 15: Slides used during my thesis defense "Du typage vectoriel"

Plan

System F

&&yyScalarα.T

$$

AdditiveT + R

yyVectorialα.T + β.R

5 / 24

Page 16: Slides used during my thesis defense "Du typage vectoriel"

Plan

System F

&&yyScalarα.T

$$

AdditiveT + R

yyVectorialα.T + β.R

5 / 24

Page 17: Slides used during my thesis defense "Du typage vectoriel"

The Scalar Type SystemA polymorphic type system tracking scalars:

Γ ` t : T

Γ ` α.t : α.T

Γ ` t : α.T Γ ` r : β.T

Γ ` t + r : (α + β).T

I Subject reduction (type preservation)I Strong normalisation

1. SN for a straightforward extension ofSystem F

2. verify that both systems type the sameterms

Gives the “amount” of terms → Barycentric restrictions (∑αi = 1)

Definition (Weight function (to check barycentricity))ω(0) = 0 ω(b) = 1 ω(α.t) = α× ω(t)

ω((t) r) = ω(t)× ω(r) ω(t + r) = ω(t) + ω(r)

TheoremIf ΓC ` t : C then ω(t ↓) = 1

Example2.(λx .

12.x) y

→∗ y

ω(2.(λx .12.x) y) = 2

ω(y) = 1

y : C ` 2.(λx .12.x) y : C

Contribution: [Arrighi,Díaz-Caro’09]

6 / 24

Page 18: Slides used during my thesis defense "Du typage vectoriel"

The Scalar Type SystemA polymorphic type system tracking scalars:

Γ ` t : T

Γ ` α.t : α.T

Γ ` t : α.T Γ ` r : β.T

Γ ` t + r : (α + β).T

I Subject reduction (type preservation)I Strong normalisation

1. SN for a straightforward extension ofSystem F

2. verify that both systems type the sameterms

Gives the “amount” of terms → Barycentric restrictions (∑αi = 1)

Definition (Weight function (to check barycentricity))ω(0) = 0 ω(b) = 1 ω(α.t) = α× ω(t)

ω((t) r) = ω(t)× ω(r) ω(t + r) = ω(t) + ω(r)

TheoremIf ΓC ` t : C then ω(t ↓) = 1

Example2.(λx .

12.x) y

→∗ y

ω(2.(λx .12.x) y) = 2

ω(y) = 1

y : C ` 2.(λx .12.x) y : C

Contribution: [Arrighi,Díaz-Caro’09]

6 / 24

Page 19: Slides used during my thesis defense "Du typage vectoriel"

The Scalar Type SystemA polymorphic type system tracking scalars:

Γ ` t : T

Γ ` α.t : α.T

Γ ` t : α.T Γ ` r : β.T

Γ ` t + r : (α + β).T

I Subject reduction (type preservation)I Strong normalisation

1. SN for a straightforward extension ofSystem F

2. verify that both systems type the sameterms

Gives the “amount” of terms → Barycentric restrictions (∑αi = 1)

Definition (Weight function (to check barycentricity))ω(0) = 0 ω(b) = 1 ω(α.t) = α× ω(t)

ω((t) r) = ω(t)× ω(r) ω(t + r) = ω(t) + ω(r)

TheoremIf ΓC ` t : C then ω(t ↓) = 1

Example2.(λx .

12.x) y

→∗ y

ω(2.(λx .12.x) y) = 2

ω(y) = 1

y : C ` 2.(λx .12.x) y : C

Contribution: [Arrighi,Díaz-Caro’09]

6 / 24

Page 20: Slides used during my thesis defense "Du typage vectoriel"

The Scalar Type SystemA polymorphic type system tracking scalars:

Γ ` t : T

Γ ` α.t : α.T

Γ ` t : α.T Γ ` r : β.T

Γ ` t + r : (α + β).T

I Subject reduction (type preservation)I Strong normalisation

1. SN for a straightforward extension ofSystem F

2. verify that both systems type the sameterms

Gives the “amount” of terms → Barycentric restrictions (∑αi = 1)

Definition (Weight function (to check barycentricity))ω(0) = 0 ω(b) = 1 ω(α.t) = α× ω(t)

ω((t) r) = ω(t)× ω(r) ω(t + r) = ω(t) + ω(r)

TheoremIf ΓC ` t : C then ω(t ↓) = 1

Example2.(λx .

12.x) y

→∗ y

ω(2.(λx .12.x) y) = 2

ω(y) = 1

y : C ` 2.(λx .12.x) y : C

Contribution: [Arrighi,Díaz-Caro’09]

6 / 24

Page 21: Slides used during my thesis defense "Du typage vectoriel"

The Scalar Type SystemA polymorphic type system tracking scalars:

Γ ` t : T

Γ ` α.t : α.T

Γ ` t : α.T Γ ` r : β.T

Γ ` t + r : (α + β).T

I Subject reduction (type preservation)I Strong normalisation

1. SN for a straightforward extension ofSystem F

2. verify that both systems type the sameterms

Gives the “amount” of terms → Barycentric restrictions (∑αi = 1)

Definition (Weight function (to check barycentricity))ω(0) = 0 ω(b) = 1 ω(α.t) = α× ω(t)

ω((t) r) = ω(t)× ω(r) ω(t + r) = ω(t) + ω(r)

TheoremIf ΓC ` t : C then ω(t ↓) = 1

Example2.(λx .

12.x) y

→∗ y

ω(2.(λx .12.x) y) = 2

ω(y) = 1

y : C ` 2.(λx .12.x) y : C

Contribution: [Arrighi,Díaz-Caro’09]

6 / 24

Page 22: Slides used during my thesis defense "Du typage vectoriel"

The Scalar Type SystemA polymorphic type system tracking scalars:

Γ ` t : T

Γ ` α.t : α.T

Γ ` t : α.T Γ ` r : β.T

Γ ` t + r : (α + β).T

I Subject reduction (type preservation)I Strong normalisation

1. SN for a straightforward extension ofSystem F

2. verify that both systems type the sameterms

Gives the “amount” of terms → Barycentric restrictions (∑αi = 1)

Definition (Weight function (to check barycentricity))ω(0) = 0 ω(b) = 1 ω(α.t) = α× ω(t)

ω((t) r) = ω(t)× ω(r) ω(t + r) = ω(t) + ω(r)

TheoremIf ΓC ` t : C then ω(t ↓) = 1

Example2.(λx .

12.x) y →∗ y

ω(2.(λx .12.x) y) = 2 ω(y) = 1

y : C ` 2.(λx .12.x) y : C

Contribution: [Arrighi,Díaz-Caro’09]

6 / 24

Page 23: Slides used during my thesis defense "Du typage vectoriel"

The Scalar Type SystemA polymorphic type system tracking scalars:

Γ ` t : T

Γ ` α.t : α.T

Γ ` t : α.T Γ ` r : β.T

Γ ` t + r : (α + β).T

I Subject reduction (type preservation)I Strong normalisation

1. SN for a straightforward extension ofSystem F

2. verify that both systems type the sameterms

Gives the “amount” of terms → Barycentric restrictions (∑αi = 1)

Definition (Weight function (to check barycentricity))ω(0) = 0 ω(b) = 1 ω(α.t) = α× ω(t)

ω((t) r) = ω(t)× ω(r) ω(t + r) = ω(t) + ω(r)

TheoremIf ΓC ` t : C then ω(t ↓) = 1

Example2.(λx .

12.x) y →∗ y

ω(2.(λx .12.x) y) = 2 ω(y) = 1

y : C ` 2.(λx .12.x) y : C

Contribution: [Arrighi,Díaz-Caro’09]

6 / 24

Page 24: Slides used during my thesis defense "Du typage vectoriel"

The Scalar Type SystemA polymorphic type system tracking scalars:

Γ ` t : T

Γ ` α.t : α.T

Γ ` t : α.T Γ ` r : β.T

Γ ` t + r : (α + β).T

I Subject reduction (type preservation)I Strong normalisation

1. SN for a straightforward extension ofSystem F

2. verify that both systems type the sameterms

Gives the “amount” of terms → Barycentric restrictions (∑αi = 1)

Definition (Weight function (to check barycentricity))ω(0) = 0 ω(b) = 1 ω(α.t) = α× ω(t)

ω((t) r) = ω(t)× ω(r) ω(t + r) = ω(t) + ω(r)

TheoremIf ΓC ` t : C then ω(t ↓) = 1

Example2.(λx .

12.x) y →∗ y

ω(2.(λx .12.x) y) = 2 ω(y) = 1

y : C ` 2.(λx .12.x) y : C

Contribution: [Arrighi,Díaz-Caro’09]6 / 24

Page 25: Slides used during my thesis defense "Du typage vectoriel"

Plan

System F

&&yyScalar

&&

Additive

xxVectorial

7 / 24

Page 26: Slides used during my thesis defense "Du typage vectoriel"

The Additive Type SystemA polymorphic type system with sums (for the additive fragment of λlin)

Γ ` t : T Γ ` r : R

Γ ` t + r : T + R

I Sums ∼ Assoc., comm. pairsI distributive w.r.t. application

Translation into System F with pairsI Simplified version without AC of + |T + R| = |T | × |R|I Distributivity in the translation (using the structure given by the type)I Equivalences given explicitly: T ≡ R implies |T | ⇔ |R|

A× B ⇔ B × A (A× B)× C ⇔ A× (B × C )

TheoremIf Γ ` t : T and exists T ′ ≡ T then |Γ| `F [t]D : |T ′|

Also we set up an inverse translation showing that it is non-trivial

Subject reduction XStrong normalisation (using the one from System Fp) XContribution: [Díaz-Caro,Petit’10]

8 / 24

Page 27: Slides used during my thesis defense "Du typage vectoriel"

The Additive Type SystemA polymorphic type system with sums (for the additive fragment of λlin)

Γ ` t : T Γ ` r : R

Γ ` t + r : T + R

I Sums ∼ Assoc., comm. pairsI distributive w.r.t. application

Translation into System F with pairs

I Simplified version without AC of + |T + R| = |T | × |R|I Distributivity in the translation (using the structure given by the type)I Equivalences given explicitly: T ≡ R implies |T | ⇔ |R|

A× B ⇔ B × A (A× B)× C ⇔ A× (B × C )

TheoremIf Γ ` t : T and exists T ′ ≡ T then |Γ| `F [t]D : |T ′|

Also we set up an inverse translation showing that it is non-trivial

Subject reduction XStrong normalisation (using the one from System Fp) XContribution: [Díaz-Caro,Petit’10]

8 / 24

Page 28: Slides used during my thesis defense "Du typage vectoriel"

The Additive Type SystemA polymorphic type system with sums (for the additive fragment of λlin)

Γ ` t : T Γ ` r : R

Γ ` t + r : T + R

I Sums ∼ Assoc., comm. pairsI distributive w.r.t. application

Translation into System F with pairsI Simplified version without AC of + |T + R| = |T | × |R|

I Distributivity in the translation (using the structure given by the type)I Equivalences given explicitly: T ≡ R implies |T | ⇔ |R|

A× B ⇔ B × A (A× B)× C ⇔ A× (B × C )

TheoremIf Γ ` t : T and exists T ′ ≡ T then |Γ| `F [t]D : |T ′|

Also we set up an inverse translation showing that it is non-trivial

Subject reduction XStrong normalisation (using the one from System Fp) XContribution: [Díaz-Caro,Petit’10]

8 / 24

Page 29: Slides used during my thesis defense "Du typage vectoriel"

The Additive Type SystemA polymorphic type system with sums (for the additive fragment of λlin)

Γ ` t : T Γ ` r : R

Γ ` t + r : T + R

I Sums ∼ Assoc., comm. pairsI distributive w.r.t. application

Translation into System F with pairsI Simplified version without AC of + |T + R| = |T | × |R|I Distributivity in the translation (using the structure given by the type)

I Equivalences given explicitly: T ≡ R implies |T | ⇔ |R|A× B ⇔ B × A (A× B)× C ⇔ A× (B × C )

TheoremIf Γ ` t : T and exists T ′ ≡ T then |Γ| `F [t]D : |T ′|

Also we set up an inverse translation showing that it is non-trivial

Subject reduction XStrong normalisation (using the one from System Fp) XContribution: [Díaz-Caro,Petit’10]

8 / 24

Page 30: Slides used during my thesis defense "Du typage vectoriel"

The Additive Type SystemA polymorphic type system with sums (for the additive fragment of λlin)

Γ ` t : T Γ ` r : R

Γ ` t + r : T + R

I Sums ∼ Assoc., comm. pairsI distributive w.r.t. application

Translation into System F with pairsI Simplified version without AC of + |T + R| = |T | × |R|I Distributivity in the translation (using the structure given by the type)I Equivalences given explicitly: T ≡ R implies |T | ⇔ |R|

A× B ⇔ B × A (A× B)× C ⇔ A× (B × C )

TheoremIf Γ ` t : T and exists T ′ ≡ T then |Γ| `F [t]D : |T ′|

Also we set up an inverse translation showing that it is non-trivial

Subject reduction XStrong normalisation (using the one from System Fp) XContribution: [Díaz-Caro,Petit’10]

8 / 24

Page 31: Slides used during my thesis defense "Du typage vectoriel"

The Additive Type SystemA polymorphic type system with sums (for the additive fragment of λlin)

Γ ` t : T Γ ` r : R

Γ ` t + r : T + R

I Sums ∼ Assoc., comm. pairsI distributive w.r.t. application

Translation into System F with pairsI Simplified version without AC of + |T + R| = |T | × |R|I Distributivity in the translation (using the structure given by the type)I Equivalences given explicitly: T ≡ R implies |T | ⇔ |R|

A× B ⇔ B × A (A× B)× C ⇔ A× (B × C )

TheoremIf Γ ` t : T and exists T ′ ≡ T then |Γ| `F [t]D : |T ′|

Also we set up an inverse translation showing that it is non-trivial

Subject reduction XStrong normalisation (using the one from System Fp) XContribution: [Díaz-Caro,Petit’10]

8 / 24

Page 32: Slides used during my thesis defense "Du typage vectoriel"

The Additive Type SystemA polymorphic type system with sums (for the additive fragment of λlin)

Γ ` t : T Γ ` r : R

Γ ` t + r : T + R

I Sums ∼ Assoc., comm. pairsI distributive w.r.t. application

Translation into System F with pairsI Simplified version without AC of + |T + R| = |T | × |R|I Distributivity in the translation (using the structure given by the type)I Equivalences given explicitly: T ≡ R implies |T | ⇔ |R|

A× B ⇔ B × A (A× B)× C ⇔ A× (B × C )

TheoremIf Γ ` t : T and exists T ′ ≡ T then |Γ| `F [t]D : |T ′|

Also we set up an inverse translation showing that it is non-trivial

Subject reduction XStrong normalisation (using the one from System Fp) XContribution: [Díaz-Caro,Petit’10]

8 / 24

Page 33: Slides used during my thesis defense "Du typage vectoriel"

Plan

System F

&&yyScalar

%%

Additive

xx

// System Fp

Vectorial

9 / 24

Page 34: Slides used during my thesis defense "Du typage vectoriel"

Plan

System F

&&yyScalar

%%

Additive

��xx

// System Fp

Vectorial λCA

OO

9 / 24

Page 35: Slides used during my thesis defense "Du typage vectoriel"

The Complete Additive System (λCA)Extending sums to the whole calculus (with positive reals scalars)

Γ ` t : TΓ ` α.t : bαc.T= T + · · ·+ T︸ ︷︷ ︸

bαc

I More general than AdditiveI Less complex than VectorialI “Amounts” approximated

If ` t : T , then ` (0.9).t + (1.1).t : T(0.9).t + (1.1).t→ 2.t and ` 2.t : 2.T

Weak subject reduction: t→ r, Γ ` t : T ⇒ Γ ` r : R with T � RAbstract interpretation (theorem)

λCA

↓��

τ // λadd

↓a(�) ��

[·] // Fp

↓F(�) ��

λCAτ// λadd

[·]// Fp

Strong normalisation (using Additive)Contribution: [Buiras,Díaz-Caro,Jaskelioff’11]

10 / 24

Page 36: Slides used during my thesis defense "Du typage vectoriel"

The Complete Additive System (λCA)Extending sums to the whole calculus (with positive reals scalars)

Γ ` t : TΓ ` α.t : bαc.T= T + · · ·+ T︸ ︷︷ ︸

bαc

I More general than AdditiveI Less complex than VectorialI “Amounts” approximated

If ` t : T , then ` (0.9).t + (1.1).t : T(0.9).t + (1.1).t→ 2.t and ` 2.t : 2.T

Weak subject reduction: t→ r, Γ ` t : T ⇒ Γ ` r : R with T � RAbstract interpretation (theorem)

λCA

↓��

τ // λadd

↓a(�) ��

[·] // Fp

↓F(�) ��

λCAτ// λadd

[·]// Fp

Strong normalisation (using Additive)Contribution: [Buiras,Díaz-Caro,Jaskelioff’11]

10 / 24

Page 37: Slides used during my thesis defense "Du typage vectoriel"

The Complete Additive System (λCA)Extending sums to the whole calculus (with positive reals scalars)

Γ ` t : TΓ ` α.t : bαc.T= T + · · ·+ T︸ ︷︷ ︸

bαc

I More general than AdditiveI Less complex than VectorialI “Amounts” approximated

If ` t : T , then ` (0.9).t + (1.1).t : T(0.9).t + (1.1).t→ 2.t and ` 2.t : 2.T

Weak subject reduction: t→ r, Γ ` t : T ⇒ Γ ` r : R with T � R

Abstract interpretation (theorem)

λCA

↓��

τ // λadd

↓a(�) ��

[·] // Fp

↓F(�) ��

λCAτ// λadd

[·]// Fp

Strong normalisation (using Additive)Contribution: [Buiras,Díaz-Caro,Jaskelioff’11]

10 / 24

Page 38: Slides used during my thesis defense "Du typage vectoriel"

The Complete Additive System (λCA)Extending sums to the whole calculus (with positive reals scalars)

Γ ` t : TΓ ` α.t : bαc.T= T + · · ·+ T︸ ︷︷ ︸

bαc

I More general than AdditiveI Less complex than VectorialI “Amounts” approximated

If ` t : T , then ` (0.9).t + (1.1).t : T(0.9).t + (1.1).t→ 2.t and ` 2.t : 2.T

Weak subject reduction: t→ r, Γ ` t : T ⇒ Γ ` r : R with T � RAbstract interpretation (theorem)

λCA

↓��

τ // λadd

↓a(�) ��

[·] // Fp

↓F(�) ��

λCAτ// λadd

[·]// Fp

Strong normalisation (using Additive)Contribution: [Buiras,Díaz-Caro,Jaskelioff’11]

10 / 24

Page 39: Slides used during my thesis defense "Du typage vectoriel"

The Complete Additive System (λCA)Extending sums to the whole calculus (with positive reals scalars)

Γ ` t : TΓ ` α.t : bαc.T= T + · · ·+ T︸ ︷︷ ︸

bαc

I More general than AdditiveI Less complex than VectorialI “Amounts” approximated

If ` t : T , then ` (0.9).t + (1.1).t : T(0.9).t + (1.1).t→ 2.t and ` 2.t : 2.T

Weak subject reduction: t→ r, Γ ` t : T ⇒ Γ ` r : R with T � RAbstract interpretation (theorem)

λCA

↓��

τ // λadd

↓a(�) ��

[·] // Fp

↓F(�) ��

λCAτ// λadd

[·]// Fp

Strong normalisation (using Additive)Contribution: [Buiras,Díaz-Caro,Jaskelioff’11]

10 / 24

Page 40: Slides used during my thesis defense "Du typage vectoriel"

Plan

System F

&&yyScalar

%%

Additive

��xx

// System Fp

Vectorial λCA

OO

11 / 24

Page 41: Slides used during my thesis defense "Du typage vectoriel"

The Vectorial system

Types:T ,R,S := U | T + R | α.T

U,V ,W := X | U → T | ∀X .U

(U,V ,W reflect the basis terms)

Equivalences:

1.T ≡ Tα.(β.T ) ≡ (α× β).T

α.T + α.R ≡ α.(T + R)

α.T + β.T ≡ (α + β).TT + R ≡ R + T

T + (R + S) ≡ (T + R) + S

(reflect the vectorial spaces axioms)

12 / 24

Page 42: Slides used during my thesis defense "Du typage vectoriel"

Typing rules

axΓ, x : U ` x : U

Γ ` t : T0I

Γ ` 0 : 0.T

Γ ` t : TsI

Γ ` α.t : α.T

Γ ` t :n∑

i=1

αi .∀~X .(U → Ti ) Γ ` r :m∑

j=1

βj .Vj∀Vj , ∃~Wj /

U[~Wj/~X ] = Vj

→E

Γ ` (t) r :n∑

i=1

m∑j=1

αi × βj .Ti [ ~Wj/~X ]

Γ, x : U ` t : T→I

Γ ` λx .t : U → T

Γ ` t : T Γ ` r : R+I

Γ ` t + r : T + R

Γ ` t :n∑

i=1

αi .Ui X /∈ FV (Γ)

∀IΓ ` t :

n∑i=1

αi .∀X .Ui

Γ ` t :n∑

i=1

αi .∀X .Ui

∀EΓ ` t :

n∑i=1

αi .Ui [V /X ]

Strong normalisation: Reducibility candidates XMain difficulty: show that {ti}i SN ⇒

∑i ti SN (algebraic measure)

Subject reduction a challenge

13 / 24

Page 43: Slides used during my thesis defense "Du typage vectoriel"

Typing rules

axΓ, x : U ` x : U

Γ ` t : T0I

Γ ` 0 : 0.T

Γ ` t : TsI

Γ ` α.t : α.T

Γ ` t :n∑

i=1

αi .∀~X .(U → Ti ) Γ ` r :m∑

j=1

βj .Vj∀Vj , ∃~Wj /

U[~Wj/~X ] = Vj

→E

Γ ` (t) r :n∑

i=1

m∑j=1

αi × βj .Ti [ ~Wj/~X ]

Γ, x : U ` t : T→I

Γ ` λx .t : U → T

Γ ` t : T Γ ` r : R+I

Γ ` t + r : T + R

Γ ` t :n∑

i=1

αi .Ui X /∈ FV (Γ)

∀IΓ ` t :

n∑i=1

αi .∀X .Ui

Γ ` t :n∑

i=1

αi .∀X .Ui

∀EΓ ` t :

n∑i=1

αi .Ui [V /X ]

Strong normalisation: Reducibility candidates XMain difficulty: show that {ti}i SN ⇒

∑i ti SN (algebraic measure)

Subject reduction a challenge

13 / 24

Page 44: Slides used during my thesis defense "Du typage vectoriel"

Typing rules

axΓ, x : U ` x : U

Γ ` t : T0I

Γ ` 0 : 0.T

Γ ` t : TsI

Γ ` α.t : α.T

Γ ` t :n∑

i=1

αi .∀~X .(U → Ti ) Γ ` r :m∑

j=1

βj .Vj∀Vj , ∃~Wj /

U[~Wj/~X ] = Vj

→E

Γ ` (t) r :n∑

i=1

m∑j=1

αi × βj .Ti [ ~Wj/~X ]

Γ, x : U ` t : T→I

Γ ` λx .t : U → T

Γ ` t : T Γ ` r : R+I

Γ ` t + r : T + R

Γ ` t :n∑

i=1

αi .Ui X /∈ FV (Γ)

∀IΓ ` t :

n∑i=1

αi .∀X .Ui

Γ ` t :n∑

i=1

αi .∀X .Ui

∀EΓ ` t :

n∑i=1

αi .Ui [V /X ]

Strong normalisation: Reducibility candidates XMain difficulty: show that {ti}i SN ⇒

∑i ti SN (algebraic measure)

Subject reduction a challenge

13 / 24

Page 45: Slides used during my thesis defense "Du typage vectoriel"

The case of the factorisation rule

System F à la Curry: a term can have different, unrelated types

Γ ` t : T Γ ` t : T ′====================Γ ` α.t + β.t : α.T + β.T ′

However, α.t+ β.t→ (α+ β).t... one of the two types must be chosen!

In general α.T + β.T ′ 6= (α + β).T 6= (α + β).T ′

(and since we are working in System F, there is no principal types neither)

14 / 24

Page 46: Slides used during my thesis defense "Du typage vectoriel"

Several possible solutions:

I Remove factorisation rule (Done. SR and SN both work)I + in scalars not used anymore. Scalars ⇒ MonoidI It works!... but it is no so expressive (“vectorial” structure lost)

I Add the typing ruleΓ ` t : T Γ ` t : T ′

Γ ` (α + β).t : α.T + β.T ′

I As soon as we add this one, we have to add many othersI Too complex and inelegant (subject reduction by axiom)

I Weak subject reductionI If Γ ` t : T and t →R r, then

I if R is not the factorisation rule: Γ ` r : TI if R is the factorisation rule: ∃S v T / Γ ` r : S

where (α + β).T v α.T + β.T ′ if ∃t / Γ ` t : T and Γ ` t : T ′

Contribution: [Arrighi,Díaz-Caro,Valiron’11]

I Church styleI Seems to be the natural solution: the type is part of the term, if the

types are different, the terms are different (no factorisation rule)

15 / 24

Page 47: Slides used during my thesis defense "Du typage vectoriel"

Several possible solutions:

I Remove factorisation rule (Done. SR and SN both work)I + in scalars not used anymore. Scalars ⇒ MonoidI It works!... but it is no so expressive (“vectorial” structure lost)

I Add the typing ruleΓ ` t : T Γ ` t : T ′

Γ ` (α + β).t : α.T + β.T ′

I As soon as we add this one, we have to add many othersI Too complex and inelegant (subject reduction by axiom)

I Weak subject reductionI If Γ ` t : T and t →R r, then

I if R is not the factorisation rule: Γ ` r : TI if R is the factorisation rule: ∃S v T / Γ ` r : S

where (α + β).T v α.T + β.T ′ if ∃t / Γ ` t : T and Γ ` t : T ′

Contribution: [Arrighi,Díaz-Caro,Valiron’11]

I Church styleI Seems to be the natural solution: the type is part of the term, if the

types are different, the terms are different (no factorisation rule)

15 / 24

Page 48: Slides used during my thesis defense "Du typage vectoriel"

Several possible solutions:

I Remove factorisation rule (Done. SR and SN both work)I + in scalars not used anymore. Scalars ⇒ MonoidI It works!... but it is no so expressive (“vectorial” structure lost)

I Add the typing ruleΓ ` t : T Γ ` t : T ′

Γ ` (α + β).t : α.T + β.T ′

I As soon as we add this one, we have to add many othersI Too complex and inelegant (subject reduction by axiom)

I Weak subject reductionI If Γ ` t : T and t →R r, then

I if R is not the factorisation rule: Γ ` r : TI if R is the factorisation rule: ∃S v T / Γ ` r : S

where (α + β).T v α.T + β.T ′ if ∃t / Γ ` t : T and Γ ` t : T ′

Contribution: [Arrighi,Díaz-Caro,Valiron’11]

I Church styleI Seems to be the natural solution: the type is part of the term, if the

types are different, the terms are different (no factorisation rule)

15 / 24

Page 49: Slides used during my thesis defense "Du typage vectoriel"

Several possible solutions:

I Remove factorisation rule (Done. SR and SN both work)I + in scalars not used anymore. Scalars ⇒ MonoidI It works!... but it is no so expressive (“vectorial” structure lost)

I Add the typing ruleΓ ` t : T Γ ` t : T ′

Γ ` (α + β).t : α.T + β.T ′

I As soon as we add this one, we have to add many othersI Too complex and inelegant (subject reduction by axiom)

I Weak subject reductionI If Γ ` t : T and t →R r, then

I if R is not the factorisation rule: Γ ` r : TI if R is the factorisation rule: ∃S v T / Γ ` r : S

where (α + β).T v α.T + β.T ′ if ∃t / Γ ` t : T and Γ ` t : T ′

Contribution: [Arrighi,Díaz-Caro,Valiron’11]

I Church styleI Seems to be the natural solution: the type is part of the term, if the

types are different, the terms are different (no factorisation rule)

15 / 24

Page 50: Slides used during my thesis defense "Du typage vectoriel"

Plan

System F

&&yyScalar

%%

Additive

��xx

// System Fp

Vectorial

��

λCA

OO

Lineal

16 / 24

Page 51: Slides used during my thesis defense "Du typage vectoriel"

The system Lineal

Types:T ,R, S := U | T + R | α.T

U,V ,W := X | U → T | ∀X .U | U@(∑

i Vi )

(U,V ,W reflect the basis terms)

Equivalences:

1.T ≡ Tα.(β.T ) ≡ (α× β).T

α.T + α.R ≡ α.(T + R)

α.T + β.T ≡ (α + β).TT + R ≡ R + T

T + (R + S) ≡ (T + R) + S(∀X .U)@V ≡ U[V /X ]

(reflect the vectorial spaces axioms)

17 / 24

Page 52: Slides used during my thesis defense "Du typage vectoriel"

Typing rules

axΓ, x : U ` x : U

Γ ` t : T0I

Γ ` 0 : 0.T

Γ ` t : TsI

Γ ` α.t : α.T

Γ ` t :n∑

i=1

αi .(〈∀X 〉k .(U → Ti ))@〈m+δ∑j=1

Wj 〉k Γ ` r :m∑

j=1

βj .Vj∀Vj , ∃j1, . . . , jk /

U〈[Wj/X ]〉k = Vj

→E

Γ ` (t) r :n∑

i=1

m∑j=1

αi × βj .Ti 〈[Wj/X ]〉k

Γ, x : U ` t : T→I

Γ ` λx : U.t : U → T

Γ ` t : T Γ ` r : R+I

Γ ` t + r : T + R

Γ ` t :n∑

i=1

αi .Ui X /∈ FV (Γ)

∀IΓ ` ΛX .t :

n∑i=1

αi .∀X .Ui

Γ ` t :n∑

i=1

αi .∀X .Ui

@I

Γ ` t@(m∑

j=1

Vj ) :n∑

i=1

αi .(∀X .Ui )@(m∑

j=1

Vj )

Subject reduction XStrong normalisation (using Vectorial) X

18 / 24

Page 53: Slides used during my thesis defense "Du typage vectoriel"

Most important properties of Lineal

TheoremIf Γ ` t :

∑i αi .Ui then t→∗

∑i αi .bi where Γ ` bi : Ui

(where Ui is not a type abstraction or application)

TheoremIf t ↓=

∑i αi .bi then Γ ` t :

∑i αi .Ui + 0.T, where Γ ` bi : Ui

19 / 24

Page 54: Slides used during my thesis defense "Du typage vectoriel"

Confluence as a side effect

20 / 24

Page 55: Slides used during my thesis defense "Du typage vectoriel"

Confluence

In the original untyped setting: “confluence by restrictions”:

Yb = (λx .(b + (x)x)) λx .(b + (x)x)

Yb → b + Yb → b + b + Yb → . . .

Yb + (−1).Yb −→ (1− 1).Yb −→∗ 0↓

b + Yb + (−1).Yb

↓∗b

Solution in the untyped setting:α.t + β.t→ (α + β).tonly if t is closed-normal

In the typed setting: Strong normalisation solves the problem

21 / 24

Page 56: Slides used during my thesis defense "Du typage vectoriel"

Confluence

In the original untyped setting: “confluence by restrictions”:

Yb = (λx .(b + (x)x)) λx .(b + (x)x)

Yb → b + Yb → b + b + Yb → . . .

Yb + (−1).Yb −→ (1− 1).Yb −→∗ 0↓

b + Yb + (−1).Yb

↓∗b

Solution in the untyped setting:α.t + β.t→ (α + β).tonly if t is closed-normal

In the typed setting: Strong normalisation solves the problem

21 / 24

Page 57: Slides used during my thesis defense "Du typage vectoriel"

Confluence

In the original untyped setting: “confluence by restrictions”:

Yb = (λx .(b + (x)x)) λx .(b + (x)x)

Yb → b + Yb → b + b + Yb → . . .

Yb + (−1).Yb −→ (1− 1).Yb −→∗ 0↓

b + Yb + (−1).Yb

↓∗b

Solution in the untyped setting:α.t + β.t→ (α + β).tonly if t is closed-normal

In the typed setting: Strong normalisation solves the problem

21 / 24

Page 58: Slides used during my thesis defense "Du typage vectoriel"

Confluence

In the original untyped setting: “confluence by restrictions”:

Yb = (λx .(b + (x)x)) λx .(b + (x)x)

Yb → b + Yb → b + b + Yb → . . .

Yb + (−1).Yb −→ (1− 1).Yb −→∗ 0↓

b + Yb + (−1).Yb

↓∗b

Solution in the untyped setting:α.t + β.t→ (α + β).tonly if t is closed-normal

In the typed setting: Strong normalisation solves the problem

21 / 24

Page 59: Slides used during my thesis defense "Du typage vectoriel"

Theorem (Confluence)

∀t / Γ ` t : T t∗��

r1��∗

∗ r2∗~~

s

Proof.1) local confluence: t

��r1��

∗ r2∗~~

sI Algebraic fragment: Coq proof [Valiron’10]

I Beta-reduction: Straightforward extensionI Commutation: Induction

2) Local confluence + Strong normalisation ⇒ Confluence

22 / 24

Page 60: Slides used during my thesis defense "Du typage vectoriel"

ContributionsSystem F

&&yy

λalg 33 λlinss

Scalar

%%

Additive

��xx

// System Fp

Vectorial

��

λCA

OO

Lineal

I Relation between λlin and λalg

I SN and SR for the five systemsI Sums as pairsI Types ↔ vectorial structure of termsI Extra: No cloning theorem

PapersDíaz-Caro,Perdrix,Tasson,Valiron HOR’10 (journal version in preparation)Arrighi,Díaz-Caro QPL’09 (journal version submitted)Díaz-Caro,Petit (in preparation)Buiras,Díaz-Caro,Jaskelioff LSFA’11Arrighi,Díaz-Caro,Valiron DCM’11 (journal version in preparation)

23 / 24

Page 61: Slides used during my thesis defense "Du typage vectoriel"

Future work

I Invariability of models of λalg through the CPS simulation

I Differential λ-calculus ↔ Linear-algebraic λ-calculus

I Algebraic Linearity ↔ Linear logic resources

I Quantum language (orthogonality issues)

I Relations with Probabilistic/Quantum/Fuzzy Logics

24 / 24