Du typage vectoriel Alejandro Daz-Caro CAPP Team Adviser: - - PowerPoint PPT Presentation

du typage vectoriel
SMART_READER_LITE
LIVE PREVIEW

Du typage vectoriel Alejandro Daz-Caro CAPP Team Adviser: - - PowerPoint PPT Presentation

Soutenance de thse Du typage vectoriel Alejandro Daz-Caro CAPP Team Adviser: Co-adviser: Pablo Arrighi Frdric Prost 23 09 2011 Lambda calculus [Church36] Formal system to study the defini- tion of function f ( x ) t x


slide-1
SLIDE 1

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

slide-2
SLIDE 2

Lambda calculus [Church’36] Formal system to study the defini- tion of function

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

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

2 / 24

slide-3
SLIDE 3

Lambda calculus [Church’36] Type system [Church’40] Formal system to study the defini- tion of function

f (x) ∼ tx x → f (x) ∼ λx.tx (x → f (x))r ∼ (λx.tx) r (x →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 framework for classifying phrases according to the kinds of values they compute” –[Pierce’02] λx.tx : T → R r : T (λx.tx) r : R

2 / 24

slide-4
SLIDE 4

Lambda calculus [Church’36] Type system [Church’40] Formal system to study the defini- tion of function

f (x) ∼ tx x → f (x) ∼ λx.tx (x → f (x))r ∼ (λx.tx) r (x →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 framework for classifying phrases according to the kinds of values they compute” –[Pierce’02] λx.tx : T → R r : T (λx.tx) r : R System F [Girard’71] TS with a universal quantification

  • ver types

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

  • λx.x : ∀X.X → X

2 / 24

slide-5
SLIDE 5

Lambda calculus [Church’36] Type system [Church’40] Formal system to study the defini- tion of function

f (x) ∼ tx x → f (x) ∼ λx.tx (x → f (x))r ∼ (λx.tx) r (x →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 framework for classifying phrases according to the 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 quantification

  • ver 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 : R

  • T ⇒ R

T R

2 / 24

slide-6
SLIDE 6

Lambda calculus [Church’36] Type system [Church’40] Formal system to study the defini- tion of function

f (x) ∼ tx x → f (x) ∼ λx.tx (x → f (x))r ∼ (λx.tx) r (x →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 framework for classifying phrases according to the 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 quantification

  • ver types

λxInt.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 : R

  • T ⇒ R

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

2 / 24

slide-7
SLIDE 7

To capture probabilistic/quantum/quantitative constructions: algebraic extensions t, r ::= x | λx.t | (t) r | t + r | α.t | 0 α ∈ (S, +, ×), a ring. Two origins:

◮ Differential λ-calculus [Ehrhard’03]: linearity à la Linear Logic

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

◮ Quantum computing: superposition of programs

Linearity as in algebra: Linear-algebraic λ-calculus (λlin) [Arrighi,Dowek’08]

3 / 24

slide-8
SLIDE 8

To capture probabilistic/quantum/quantitative constructions: algebraic extensions t, r ::= x | λx.t | (t) r | t + r | α.t | 0 α ∈ (S, +, ×), a ring. Two origins:

◮ Differential λ-calculus [Ehrhard’03]: linearity à la Linear Logic

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

◮ Quantum computing: superposition of programs

Linearity 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 of vectorial spaces)[Arrighi,Dowek’07]

3 / 24

slide-9
SLIDE 9

To capture probabilistic/quantum/quantitative constructions: algebraic extensions t, r ::= x | λx.t | (t) r | t + r | α.t | 0 α ∈ (S, +, ×), a ring. Two origins:

◮ Differential λ-calculus [Ehrhard’03]: linearity à la Linear Logic

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

◮ Quantum computing: superposition of programs

Linearity 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 of vectorial spaces)[Arrighi,Dowek’07]

Vectorial space of values B = {ti : ti var. or abs. } Set of values ::= Span(B)

3 / 24

slide-10
SLIDE 10

To capture probabilistic/quantum/quantitative constructions: algebraic extensions t, r ::= x | λx.t | (t) r | t + r | α.t | 0 α ∈ (S, +, ×), a ring. λalg λlin Origin Linear Logic Quantum computing Evaluation strategy Call-by-name Call-by-base Algebraic 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 of vectorial spaces)[Arrighi,Dowek’07]

Vectorial space of values B = {ti : ti var. or abs. } Set of values ::= Span(B)

3 / 24

slide-11
SLIDE 11

Example of program Two base vectors: true = λx.λy.x false = λx.λy.y

4 / 24

slide-12
SLIDE 12

Example of program Two base vectors: true = λx.λy.x false = λx.λy.y Linear map U s.t. (U)true = a.true + b.false (U)false = c.true + d.false

4 / 24

slide-13
SLIDE 13

Example of program Two base vectors: true = λx.λy.x false = λ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]}

4 / 24

slide-14
SLIDE 14

Example of program Two base vectors: true = λx.λy.x false = λ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 vector in normal form . . . understand what it means “linear combination of types” . . . a Curry-Howard approach to defining Fuzzy/Quantum/Probabilistic logics from Fuzzy/Quantum/Probabilistic programming languages.

4 / 24

slide-15
SLIDE 15

Plan System F

  • Scalar

α.T

  • Additive

T + R

  • Vectorial

α.T + β.R

5 / 24

slide-16
SLIDE 16

Plan System F

  • Scalar

α.T

  • Additive

T + R

  • Vectorial

α.T + β.R

5 / 24

slide-17
SLIDE 17

The Scalar Type System A polymorphic type system tracking scalars: Γ ⊢ t : T Γ ⊢ α.t : α.T Γ ⊢ t : α.T Γ ⊢ r : β.T Γ ⊢ t + r : (α + β).T

6 / 24

slide-18
SLIDE 18

The Scalar Type System A polymorphic type system tracking scalars: Γ ⊢ t : T Γ ⊢ α.t : α.T Γ ⊢ t : α.T Γ ⊢ r : β.T Γ ⊢ t + r : (α + β).T Gives the “amount” of terms → Barycentric restrictions ( αi = 1)

6 / 24

slide-19
SLIDE 19

The Scalar Type System A polymorphic type system tracking scalars: Γ ⊢ t : T Γ ⊢ α.t : α.T Γ ⊢ t : α.T Γ ⊢ r : β.T Γ ⊢ t + r : (α + β).T 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)

6 / 24

slide-20
SLIDE 20

The Scalar Type System A polymorphic type system tracking scalars: Γ ⊢ t : T Γ ⊢ α.t : α.T Γ ⊢ t : α.T Γ ⊢ r : β.T Γ ⊢ t + r : (α + β).T 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)

Theorem

If ΓC ⊢ t : C then ω(t ↓) = 1

6 / 24

slide-21
SLIDE 21

The Scalar Type System A polymorphic type system tracking scalars: Γ ⊢ t : T Γ ⊢ α.t : α.T Γ ⊢ t : α.T Γ ⊢ r : β.T Γ ⊢ t + r : (α + β).T 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)

Theorem

If ΓC ⊢ t : C then ω(t ↓) = 1 Example 2.(λx.1 2.x) y ω(2.(λx.1 2.x) y) = 2 y : C ⊢ 2.(λx.1 2.x) y : C

6 / 24

slide-22
SLIDE 22

The Scalar Type System A polymorphic type system tracking scalars: Γ ⊢ t : T Γ ⊢ α.t : α.T Γ ⊢ t : α.T Γ ⊢ r : β.T Γ ⊢ t + r : (α + β).T 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)

Theorem

If ΓC ⊢ t : C then ω(t ↓) = 1 Example 2.(λx.1 2.x) y →∗ y ω(2.(λx.1 2.x) y) = 2 ω(y) = 1 y : C ⊢ 2.(λx.1 2.x) y : C

6 / 24

slide-23
SLIDE 23

The Scalar Type System A polymorphic type system tracking scalars: Γ ⊢ t : T Γ ⊢ α.t : α.T Γ ⊢ t : α.T Γ ⊢ r : β.T Γ ⊢ t + r : (α + β).T

◮ Subject reduction (type preservation) ◮ Strong normalisation

  • 1. SN for a straightforward extension of

System F

  • 2. verify that both systems type the same

terms

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)

Theorem

If ΓC ⊢ t : C then ω(t ↓) = 1 Example 2.(λx.1 2.x) y →∗ y ω(2.(λx.1 2.x) y) = 2 ω(y) = 1 y : C ⊢ 2.(λx.1 2.x) y : C

6 / 24

slide-24
SLIDE 24

The Scalar Type System A polymorphic type system tracking scalars: Γ ⊢ t : T Γ ⊢ α.t : α.T Γ ⊢ t : α.T Γ ⊢ r : β.T Γ ⊢ t + r : (α + β).T

◮ Subject reduction (type preservation) ◮ Strong normalisation

  • 1. SN for a straightforward extension of

System F

  • 2. verify that both systems type the same

terms

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)

Theorem

If ΓC ⊢ t : C then ω(t ↓) = 1 Example 2.(λx.1 2.x) y →∗ y ω(2.(λx.1 2.x) y) = 2 ω(y) = 1 y : C ⊢ 2.(λx.1 2.x) y : C

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

6 / 24

slide-25
SLIDE 25

Plan System F

  • Scalar
  • Additive
  • Vectorial

7 / 24

slide-26
SLIDE 26

The Additive Type System A polymorphic type system with sums (for the additive fragment of λlin) Γ ⊢ t : T Γ ⊢ r : R Γ ⊢ t + r : T + R

◮ Sums ∼ Assoc., comm. pairs ◮ distributive w.r.t. application

8 / 24

slide-27
SLIDE 27

The Additive Type System A polymorphic type system with sums (for the additive fragment of λlin) Γ ⊢ t : T Γ ⊢ r : R Γ ⊢ t + r : T + R

◮ Sums ∼ Assoc., comm. pairs ◮ distributive w.r.t. application

Translation into System F with pairs

8 / 24

slide-28
SLIDE 28

The Additive Type System A polymorphic type system with sums (for the additive fragment of λlin) Γ ⊢ t : T Γ ⊢ r : R Γ ⊢ t + r : T + R

◮ Sums ∼ Assoc., comm. pairs ◮ distributive w.r.t. application

Translation into System F with pairs

◮ Simplified version without AC of +

|T + R| = |T| × |R|

8 / 24

slide-29
SLIDE 29

The Additive Type System A polymorphic type system with sums (for the additive fragment of λlin) Γ ⊢ t : T Γ ⊢ r : R Γ ⊢ t + r : T + R

◮ Sums ∼ Assoc., comm. pairs ◮ distributive w.r.t. application

Translation into System F with pairs

◮ Simplified version without AC of +

|T + R| = |T| × |R|

◮ Distributivity in the translation (using the structure given by the type)

8 / 24

slide-30
SLIDE 30

The Additive Type System A polymorphic type system with sums (for the additive fragment of λlin) Γ ⊢ t : T Γ ⊢ r : R Γ ⊢ t + r : T + R

◮ Sums ∼ Assoc., comm. pairs ◮ distributive w.r.t. application

Translation into System F with pairs

◮ Simplified version without AC of +

|T + R| = |T| × |R|

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

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

8 / 24

slide-31
SLIDE 31

The Additive Type System A polymorphic type system with sums (for the additive fragment of λlin) Γ ⊢ t : T Γ ⊢ r : R Γ ⊢ t + r : T + R

◮ Sums ∼ Assoc., comm. pairs ◮ distributive w.r.t. application

Translation into System F with pairs

◮ Simplified version without AC of +

|T + R| = |T| × |R|

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

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

Theorem

If Γ ⊢ t : T and exists T ′ ≡ T then |Γ| ⊢F [t]D : |T ′| Also we set up an inverse translation showing that it is non-trivial

8 / 24

slide-32
SLIDE 32

The Additive Type System A polymorphic type system with sums (for the additive fragment of λlin) Γ ⊢ t : T Γ ⊢ r : R Γ ⊢ t + r : T + R

◮ Sums ∼ Assoc., comm. pairs ◮ distributive w.r.t. application

Translation into System F with pairs

◮ Simplified version without AC of +

|T + R| = |T| × |R|

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

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

Theorem

If Γ ⊢ 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 Strong normalisation (using the one from System Fp)

Contribution: [Díaz-Caro,Petit’10]

8 / 24

slide-33
SLIDE 33

Plan System F

  • Scalar
  • Additive
  • System Fp

Vectorial

9 / 24

slide-34
SLIDE 34

Plan System F

  • Scalar
  • Additive
  • System Fp

Vectorial λCA

  • 9 / 24
slide-35
SLIDE 35

The Complete Additive System (λCA) Extending sums to the whole calculus (with positive reals scalars) Γ ⊢ t : T Γ ⊢ α.t : ⌊α⌋.T= T + · · · + T

  • ⌊α⌋

◮ More general than Additive ◮ Less complex than Vectorial ◮ “Amounts” approximated

10 / 24

slide-36
SLIDE 36

The Complete Additive System (λCA) Extending sums to the whole calculus (with positive reals scalars) Γ ⊢ t : T Γ ⊢ α.t : ⌊α⌋.T= T + · · · + T

  • ⌊α⌋

◮ More general than Additive ◮ Less complex than Vectorial ◮ “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

10 / 24

slide-37
SLIDE 37

The Complete Additive System (λCA) Extending sums to the whole calculus (with positive reals scalars) Γ ⊢ t : T Γ ⊢ α.t : ⌊α⌋.T= T + · · · + T

  • ⌊α⌋

◮ More general than Additive ◮ Less complex than Vectorial ◮ “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

10 / 24

slide-38
SLIDE 38

The Complete Additive System (λCA) Extending sums to the whole calculus (with positive reals scalars) Γ ⊢ t : T Γ ⊢ α.t : ⌊α⌋.T= T + · · · + T

  • ⌊α⌋

◮ More general than Additive ◮ Less complex than Vectorial ◮ “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

10 / 24

slide-39
SLIDE 39

The Complete Additive System (λCA) Extending sums to the whole calculus (with positive reals scalars) Γ ⊢ t : T Γ ⊢ α.t : ⌊α⌋.T= T + · · · + T

  • ⌊α⌋

◮ More general than Additive ◮ Less complex than Vectorial ◮ “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

slide-40
SLIDE 40

Plan System F

  • Scalar
  • Additive
  • System Fp

Vectorial λCA

  • 11 / 24
slide-41
SLIDE 41

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 ≡ (α + β).T T + R ≡ R + T T + (R + S) ≡ (T + R) + S

(reflect the vectorial spaces axioms)

12 / 24

slide-42
SLIDE 42

Typing rules

ax Γ, x : U ⊢ x : U Γ ⊢ t : T 0I Γ ⊢ 0 : 0.T

Γ ⊢ t : T sI Γ ⊢ α.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]

13 / 24

slide-43
SLIDE 43

Typing rules

ax Γ, x : U ⊢ x : U Γ ⊢ t : T 0I Γ ⊢ 0 : 0.T

Γ ⊢ t : T sI Γ ⊢ α.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 Main difficulty: show that {ti}i SN ⇒

i ti SN (algebraic measure)

13 / 24

slide-44
SLIDE 44

Typing rules

ax Γ, x : U ⊢ x : U Γ ⊢ t : T 0I Γ ⊢ 0 : 0.T

Γ ⊢ t : T sI Γ ⊢ α.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 Main difficulty: show that {ti}i SN ⇒

i ti SN (algebraic measure)

Subject reduction a challenge

13 / 24

slide-45
SLIDE 45

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 ′ = (α + β).T = (α + β).T ′ (and since we are working in System F, there is no principal types neither)

14 / 24

slide-46
SLIDE 46

Several possible solutions:

◮ Remove factorisation rule (Done. SR and SN both work)

◮ + in scalars not used anymore. Scalars ⇒ Monoid ◮ It works!... but it is no so expressive (“vectorial” structure lost) 15 / 24

slide-47
SLIDE 47

Several possible solutions:

◮ Remove factorisation rule (Done. SR and SN both work)

◮ + in scalars not used anymore. Scalars ⇒ Monoid ◮ It works!... but it is no so expressive (“vectorial” structure lost)

◮ Add the typing rule

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

◮ As soon as we add this one, we have to add many others ◮ Too complex and inelegant (subject reduction by axiom) 15 / 24

slide-48
SLIDE 48

Several possible solutions:

◮ Remove factorisation rule (Done. SR and SN both work)

◮ + in scalars not used anymore. Scalars ⇒ Monoid ◮ It works!... but it is no so expressive (“vectorial” structure lost)

◮ Add the typing rule

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

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

◮ Weak subject reduction

◮ If Γ ⊢ t : T and t →R r, then ◮ if R is not the factorisation rule: Γ ⊢ r : T ◮ if R is the factorisation rule: ∃S ⊑ T / Γ ⊢ r : S

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

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

15 / 24

slide-49
SLIDE 49

Several possible solutions:

◮ Remove factorisation rule (Done. SR and SN both work)

◮ + in scalars not used anymore. Scalars ⇒ Monoid ◮ It works!... but it is no so expressive (“vectorial” structure lost)

◮ Add the typing rule

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

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

◮ Weak subject reduction

◮ If Γ ⊢ t : T and t →R r, then ◮ if R is not the factorisation rule: Γ ⊢ r : T ◮ if R is the factorisation rule: ∃S ⊑ T / Γ ⊢ r : S

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

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

◮ Church style

◮ 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

slide-50
SLIDE 50

Plan System F

  • Scalar
  • Additive
  • System Fp

Vectorial

  • λCA
  • Lineal

16 / 24

slide-51
SLIDE 51

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 ≡ (α + β).T T + R ≡ R + T T + (R + S) ≡ (T + R) + S (∀X.U)@V ≡ U[V /X]

(reflect the vectorial spaces axioms)

17 / 24

slide-52
SLIDE 52

Typing rules

ax Γ, x : U ⊢ x : U Γ ⊢ t : T 0I Γ ⊢ 0 : 0.T

Γ ⊢ t : T sI Γ ⊢ α.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 Strong normalisation (using Vectorial)

18 / 24

slide-53
SLIDE 53

Most important properties of Lineal

Theorem

If Γ ⊢ t:

i αi.Ui

then t →∗

i αi.bi

where Γ ⊢ bi : Ui

(where Ui is not a type abstraction or application)

Theorem

If t ↓=

i αi.bi

then Γ ⊢ t:

i αi.Ui + 0.T,

where Γ ⊢ bi : Ui

19 / 24

slide-54
SLIDE 54

Confluence as a side effect

20 / 24

slide-55
SLIDE 55

Confluence In the original untyped setting: “confluence by restrictions”: Yb = (λx.(b + (x)x)) λx.(b + (x)x) Yb → b + Yb → b + b + Yb → . . .

21 / 24

slide-56
SLIDE 56

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

21 / 24

slide-57
SLIDE 57

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 → (α + β).t

  • nly if t is closed-normal

21 / 24

slide-58
SLIDE 58

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 → (α + β).t

  • nly if t is closed-normal

In the typed setting: Strong normalisation solves the problem

21 / 24

slide-59
SLIDE 59

Theorem (Confluence)

∀t / Γ ⊢ t : T t

  • r1

  • r2

  • s

Proof.

1) local confluence: t

  • r1
  • r2

  • s

◮ Algebraic fragment: Coq proof [Valiron’10] ◮ Beta-reduction: Straightforward extension ◮ Commutation: Induction

2) Local confluence + Strong normalisation ⇒ Confluence

22 / 24

slide-60
SLIDE 60

Contributions System F

  • λalg

λlin

  • Scalar
  • Additive
  • System Fp

Vectorial

  • λCA
  • Lineal

◮ Relation between λlin and λalg ◮ SN and SR for the five systems ◮ Sums as pairs ◮ Types ↔ vectorial structure of terms ◮ Extra: No cloning theorem Papers Dí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’11 Arrighi,Díaz-Caro,Valiron DCM’11 (journal version in preparation)

23 / 24

slide-61
SLIDE 61

Future work

◮ Invariability of models of λalg through the CPS simulation ◮ Differential λ-calculus ↔ Linear-algebraic λ-calculus ◮ Algebraic Linearity ↔ Linear logic resources ◮ Quantum language (orthogonality issues) ◮ Relations with Probabilistic/Quantum/Fuzzy Logics

24 / 24