Slides

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Linear lambda-calculus is linear

To appear at FSCD 2022


arXiv:2201.11221

Alejandro Díaz-Caro Gilles Dowek


UNIVERSIDAD NACIONAL DE QUILMES INRIA
& CONICET / UNIVERSIDAD de BUENOS AIRES & ENS PARIS-SACLAY
Buenos Aires, Argentina Paris, France

28th International Conference on Types for Proofs and Programs (TYPES 2022)
20-25 June 2022 – Nantes, France
Motivation
Linear Logic ←→ Linear Algebra

Linearity expressed by its models (linear maps)

Lambda-calculus is the language of functions

Linear lambda-calculus is the language of linear functions

Alejandro Díaz-Caro and Gilles Dowek Linear lambda-calculus is linear 1/6


Motivation
Linear Logic ←→ Linear Algebra

Linearity expressed by its models (linear maps)

Lambda-calculus is the language of functions

Linear lambda-calculus is the language of linear functions

But, how?
Linear in the algebraic sense. . .

f (v + w ) = f (v ) + f (w )
f (a.v ) = a.f (v )

This is not easily expressible with lambda-terms

Alejandro Díaz-Caro and Gilles Dowek Linear lambda-calculus is linear 1/6


Interstitial rules
Addition and multiplication by scalar
Γ ⊢ A Γ ⊢ A sum Γ ⊢ A prod
Γ⊢A Γ⊢A

Alejandro Díaz-Caro and Gilles Dowek Linear lambda-calculus is linear 2/6


Interstitial rules
Addition and multiplication by scalar
Γ ⊢ A Γ ⊢ A sum Γ ⊢ A prod
Γ⊢A Γ⊢A
Now some proofs cannot be reduced, e.g.
π1 π2
Γ⊢A Γ⊢B ∧
i
Γ ⊢ A ∧ B prod π3
Γ⊢A∧B Γ, A ⊢ C
∧e
Γ⊢C

Alejandro Díaz-Caro and Gilles Dowek Linear lambda-calculus is linear 2/6


Interstitial rules
Addition and multiplication by scalar
Γ ⊢ A Γ ⊢ A sum Γ ⊢ A prod
Γ⊢A Γ⊢A
Now some proofs cannot be reduced, e.g.
π1 π2
Γ⊢A Γ⊢B ∧
i
Γ ⊢ A ∧ B prod π3
Γ⊢A∧B Γ, A ⊢ C
∧e
Γ⊢C

Commute sum either with the intro or with the elim


π1 π2 π1 π2
Γ ⊢ A prod Γ ⊢ B prod Γ⊢A Γ⊢B ∧ π3
i
Γ⊢A Γ⊢B ∧ π3 Γ⊢A∧B Γ, A ⊢ C
i ∧e
Γ⊢A∧B Γ, A ⊢ C Γ ⊢ C prod
∧e Γ⊢C
Γ⊢C

We chose to commute with the introduction as much as possible


Alejandro Díaz-Caro and Gilles Dowek Linear lambda-calculus is linear 2/6
The LS -calculus
Intuitionistic linear logic connectives

Mult Add PL
Truth 1 ⊤ ⊤
Falsehood − 0 ⊥
Implication ⊸ − ⇒
Conjunction ⊗ & ∧
Disjunction − ⊕ ∨

Alejandro Díaz-Caro and Gilles Dowek Linear lambda-calculus is linear 3/6


The LS -calculus
Intuitionistic linear logic connectives Proof-terms

Mult Add PL t = x | t + t | a • t | a.⋆ | δ⊤ (t, t) | δ⊥ (t)


Truth 1 ⊤ ⊤ | λx.t | tt
Falsehood − 0 ⊥ 1
| ⟨t, t⟩ | δ∧ 2
(t, x.t) | δ∧ (t, x.t)
Implication ⊸ − ⇒
| inl(t) | inr (t) | δ∨ (t, x.t, y .t)
Conjunction ⊗ & ∧
Disjunction − ⊕ ∨ a is scalar from some structure (S, +, ×).
Some reduction rules
Some deduction rules
δ⊤ (a.⋆, t) −→ a • t
Γ⊢t:⊤ ∆⊢u:A
⊤-i(a) ⊤-e a. ⋆ +b.⋆ −→ (a + b).⋆
⊢ a.⋆ : ⊤ Γ, ∆ ⊢ δ⊤ (t, u) : A
(λx.t) + (λx.u) −→ λx.(t + u)
Γ ⊢ t : A Γ ⊢ u : A sum Γ ⊢ t : A prod(a) a • b.⋆ −→ (a × b).⋆
Γ⊢t +u :A Γ⊢a•t :A
a • λx.t −→ λx.a • t

Alejandro Díaz-Caro and Gilles Dowek Linear lambda-calculus is linear 3/6


Vectors and Matrices
Definition (The set V)
⊤ ∈ V, If A, B ∈ V, A∧B ∈V A ∈ V, d(A) = number of ⊤

Definition (One-to-one correspondance) Example


A ∈ V with d(A) = n ←→ S n a
⟨⟨a.⋆, b.⋆⟩, c.⋆⟩ ↔ b
⊢ t : A (t irreductible) −→ unique vector t ∈ S n | {z } c
|{z}
(⊤∧⊤)∧⊤
v ∈ S n −→ unique irreductible proof vA S3

Alejandro Díaz-Caro and Gilles Dowek Linear lambda-calculus is linear 4/6


Vectors and Matrices
Definition (The set V)
⊤ ∈ V, If A, B ∈ V, A∧B ∈V A ∈ V, d(A) = number of ⊤

Definition (One-to-one correspondance) Example


A ∈ V with d(A) = n ←→ S n a
⟨⟨a.⋆, b.⋆⟩, c.⋆⟩ ↔ b
⊢ t : A (t irreductible) −→ unique vector t ∈ S n | {z } c
|{z}
(⊤∧⊤)∧⊤
v ∈ S n −→ unique irreductible proof vA S3

Lemma (Some properties)


t +u =t +u
a • t = at

Alejandro Díaz-Caro and Gilles Dowek Linear lambda-calculus is linear 4/6


Vectors and Matrices
Definition (The set V)
⊤ ∈ V, If A, B ∈ V, A∧B ∈V A ∈ V, d(A) = number of ⊤

Definition (One-to-one correspondance) Example


A ∈ V with d(A) = n ←→ S n a
⟨⟨a.⋆, b.⋆⟩, c.⋆⟩ ↔ b
⊢ t : A (t irreductible) −→ unique vector t ∈ S n | {z } c
|{z}
(⊤∧⊤)∧⊤
v ∈ S n −→ unique irreductible proof vA S3

Lemma (Some properties) Theorem (Matrices)


t +u =t +u A, B ∈ V with d(A) = m and d(B) = n M ∈ S m×n
Then, there exists ⊢ t : A ⇒ B such that for all v ∈ S m
a • t = at
tvA = Mv

Example
1 2
a b

c d −→ λx.(δ∧ (x, y .δ⊤ ∗ (y , ⟨a.⋆, b.⋆⟩)) + δ∧ (x, z.δ⊤ ∗ ( ⟨c.⋆, d.⋆⟩)))
Alejandro Díaz-Caro and Gilles Dowek Linear lambda-calculus is linear 4/6
Linearity
The main theorem

Theorem (Linearity)
Let A be any proposition, B ∈ V, ⊢ t : A ⇒ B, and
u, v ∈ A, then

t(u + v ) ≡ (tu) + (tv ) t(a • u) ≡ a • (tu)

Alejandro Díaz-Caro and Gilles Dowek Linear lambda-calculus is linear 5/6


Linearity
The main theorem

Theorem (Linearity)
Let A be any proposition, B ∈ V, ⊢ t : A ⇒ B, and
u, v ∈ A, then

t(u + v ) ≡ (tu) + (tv ) t(a • u) ≡ a • (tu)

It does not extend directly to arbitrary B:


Let t = λx.λy .(yx) : ⊤ ⇒ (⊤ ⇒ ⊤) ⇒ ⊤

t(1. ⋆ +2.⋆) −→∗ λy .(y 3.⋆)


(t1.⋆) + (t2.⋆) −→∗ λy .((y 1.⋆) + (y 2.⋆))

Alejandro Díaz-Caro and Gilles Dowek Linear lambda-calculus is linear 5/6


Linearity
The main theorem

Theorem (Linearity)
Let A be any proposition, B ∈ V, ⊢ t : A ⇒ B, and
u, v ∈ A, then

t(u + v ) ≡ (tu) + (tv ) t(a • u) ≡ a • (tu)

It does not extend directly to arbitrary B:


Let t = λx.λy .(yx) : ⊤ ⇒ (⊤ ⇒ ⊤) ⇒ ⊤

t(1. ⋆ +2.⋆) −→∗ λy .(y 3.⋆)


(t1.⋆) + (t2.⋆) −→∗ λy .((y 1.⋆) + (y 2.⋆))

Corollary
Let A, B ∈ V with d(A) = m, d(B) = n and ⊢ t : A ⇒ B.
Then, the map F from S m to S n , defined as F (u) = tu A is linear.
Alejandro Díaz-Caro and Gilles Dowek Linear lambda-calculus is linear 5/6
Summarizing

▶ We presented the LS -logic, an extension of a fragment of intuitionistic linear logic with


two interstitial rules and its commuting rules to recover cut elimination.
▶ We have shown that its proof-language can express matrices in S m×n

▶ Moreover, we have shown that every term of type A ⇒ B, with B ∈ V is linear in the
algebraic sense.

In the paper, but I got no more time for this. . .


▶ Extending the LS -logic with the ⊙ operator, we get a quantum programming language
(see [Díaz-Caro & Dowek ICTAC 2021]).

Alejandro Díaz-Caro and Gilles Dowek Linear lambda-calculus is linear 6/6

You might also like