Slides QuAND 2011
-
Upload
alejandro-diaz-caro -
Category
Technology
-
view
119 -
download
0
description
Transcript of Slides QuAND 2011
Confluence via strong normalisation in analgebraic λ-calculus with rewriting
– Accepted in LSFA 2011. To appear in EPTCS –
Pablo Buiras1 Alejandro Díaz-Caro2 Mauro Jaskelioff1,3
1Universidad Nacional de Rosario, FCEIA, Argentina
2Université de Grenoble, LIG, France
3CIFASIS-CONICET, Argentina
Recontre QuAND • July 18, 2011 • Marseille, France
M,N ::= x | λx .M | (M)N | M + N | α.M | 0
Beta reduction:(λx .M)N → M[x := N]
“Algebraic” reductions:α.M + β.M → (α + β).M,
(M)(N1 + N2) → (M)N1 + (M)N2,. . .. . .. . .
(oriented version of the axioms of vectorial spaces)
Two origins:I Differential λ-calculus: capturing linearity à la Linear Logic→ Removing the differential operator : Algebraic λ-calculus (λalg) [Vaux’09]
I Quantum computing: superposition of programs→ Linearity as in algebra: Linear-algebraic λ-calculus (λlin)
[Arrighi,Dowek’08]
2 / 15
M,N ::= x | λx .M | (M)N | M + N | α.M | 0
Beta reduction:(λx .M)N → M[x := N]
“Algebraic” reductions:α.M + β.M → (α + β).M,
(M)(N1 + N2) → (M)N1 + (M)N2,. . .. . .. . .
(oriented version of the axioms of vectorial spaces)
λalg λlinOrigin Linear Logic Quantum computing
Strategy Call-by-name Call-by-value
2 / 15
Confluence issues
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 2 (λalg):
Only positive numbers
YB + YB −→ B + YB + YB −→ B + 2.YB
↓2.YB ... and equalities
Solution 1 (λlin):α.M + β.M → (α + β).Monly if M is closed-normaland others similar restrictions
Solution 3:forbid ∞! (type system)
Objective: to forbid ∞−∞
3 / 15
Confluence issues
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 2 (λalg):
Only positive numbers
YB + YB −→ B + YB + YB −→ B + 2.YB
↓2.YB ... and equalities
Solution 1 (λlin):α.M + β.M → (α + β).Monly if M is closed-normaland others similar restrictions
Solution 3:forbid ∞! (type system)
Objective: to forbid ∞−∞
3 / 15
Confluence issues
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 2 (λalg):
Only positive numbers
YB + YB −→ B + YB + YB −→ B + 2.YB
↓2.YB ... and equalities
Solution 1 (λlin):α.M + β.M → (α + β).Monly if M is closed-normaland others similar restrictions
Solution 3:forbid ∞! (type system)
Objective: to forbid ∞−∞
3 / 15
Confluence issues
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 2 (λalg):
Only positive numbers
YB + YB −→ B + YB + YB −→ B + 2.YB
↓2.YB ... and equalities
Solution 1 (λlin):α.M + β.M → (α + β).Monly if M is closed-normaland others similar restrictions
Solution 3:forbid ∞! (type system)
Objective: to forbid ∞−∞
3 / 15
Confluence issues
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 2 (λalg):
Only positive numbersYB + YB −→ B + YB + YB −→ B + 2.YB
↓2.YB ... and equalities
Solution 1 (λlin):α.M + β.M → (α + β).Monly if M is closed-normaland others similar restrictions
Solution 3:forbid ∞! (type system)
Objective: to forbid ∞−∞
3 / 15
Confluence issues
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 2 (λalg):
Only positive numbersYB + YB −→ B + YB + YB −→ B + 2.YB
↓2.YB ... and equalities
Solution 1 (λlin):α.M + β.M → (α + β).Monly if M is closed-normaland others similar restrictions
Solution 3:forbid ∞! (type system)
Objective: to forbid ∞−∞
3 / 15
Confluence issues
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 2 (λalg):
Only positive numbersYB + YB −→ B + YB + YB −→ B + 2.YB
↓2.YB ... and equalities
Solution 1 (λlin):α.M + β.M → (α + β).Monly if M is closed-normaland others similar restrictions
Solution 3:forbid ∞! (type system)
Objective: to forbid ∞−∞
3 / 15
Possible type systems
Straightforward extension of a classic type system
Γ ` M : T Γ ` N : T+I
Γ ` M + N : T
Γ ` M : TαI
Γ ` α.M : T0I
Γ ` 0 : TPros: Cons:
I Simple I Too restrictive
Scalar type system [Arrighi, Díaz-Caro 2009]
Γ ` M : α.T Γ ` N : β.T+I
Γ ` M + N : (α + β).T
Γ ` M : TαI
Γ ` α.M : α.T0I
Γ ` 0 : 0.T
Pros: Cons:I Characterises the ’amount’
of termsI Still too restrictive
4 / 15
Possible type systems
Straightforward extension of a classic type system
Γ ` M : T Γ ` N : T+I
Γ ` M + N : T
Γ ` M : TαI
Γ ` α.M : T0I
Γ ` 0 : TPros: Cons:
I Simple I Too restrictive
Scalar type system [Arrighi, Díaz-Caro 2009]
Γ ` M : α.T Γ ` N : β.T+I
Γ ` M + N : (α + β).T
Γ ` M : TαI
Γ ` α.M : α.T0I
Γ ` 0 : 0.T
Pros: Cons:I Characterises the ’amount’
of termsI Still too restrictive
4 / 15
Possible type systemsAdditive type system [Díaz-Caro, Petit 2010]
Γ ` M : T Γ ` N : R+I
à ` M + N : T + R ������
��XXXXXXXX
Γ ` M : TαI
Γ ` α.M : α.T0I
Γ ` 0 : 0Pros: Cons:
I More versatileI Interpretation in System F
with pairs
I Defined for a fragment(no scalars!)
Vectorial type system [Arrighi, Díaz-Caro, Valiron 2011]
Γ ` M : T Γ ` N : R+I
Γ ` M + N : T + R
Γ ` M : TαI
Γ ` α.M : α.T
Γ ` M : T0I
Γ ` 0 : 0.TPros: Cons:
I Much more versatileI Good characterisation of
terms
I ComplexI Overkill (confluence!)
Idea: extend Additive
5 / 15
Possible type systemsAdditive type system [Díaz-Caro, Petit 2010]
Γ ` M : T Γ ` N : R+I
à ` M + N : T + R ������
��XXXXXXXX
Γ ` M : TαI
Γ ` α.M : α.T0I
Γ ` 0 : 0Pros: Cons:
I More versatileI Interpretation in System F
with pairs
I Defined for a fragment(no scalars!)
Vectorial type system [Arrighi, Díaz-Caro, Valiron 2011]
Γ ` M : T Γ ` N : R+I
Γ ` M + N : T + R
Γ ` M : TαI
Γ ` α.M : α.T
Γ ` M : T0I
Γ ` 0 : 0.TPros: Cons:
I Much more versatileI Good characterisation of
terms
I ComplexI Overkill (confluence!)
Idea: extend Additive
5 / 15
Possible type systemsAdditive type system [Díaz-Caro, Petit 2010]
Γ ` M : T Γ ` N : R+I
à ` M + N : T + R ������
��XXXXXXXX
Γ ` M : TαI
Γ ` α.M : α.T0I
Γ ` 0 : 0Pros: Cons:
I More versatileI Interpretation in System F
with pairs
I Defined for a fragment(no scalars!)
Vectorial type system [Arrighi, Díaz-Caro, Valiron 2011]
Γ ` M : T Γ ` N : R+I
Γ ` M + N : T + R
Γ ` M : TαI
Γ ` α.M : α.T
Γ ` M : T0I
Γ ` 0 : 0.TPros: Cons:
I Much more versatileI Good characterisation of
terms
I ComplexI Overkill (confluence!)
Idea: extend Additive
5 / 15
Idea: λCA - Extend additive
Key idea
Γ ` M : TΓ ` α.M : bαc.T= T + · · ·+ T︸ ︷︷ ︸
bαc
If ` M : T , then ` (0.9).M + (1.1).M : T
(0.9).M + (1.1).M → 2.M and ` 2.M : 2.T
Theorem (weak subject reduction)M → N, Γ ` M : T ⇒ Γ ` N : R with T � R
6 / 15
Idea: λCA - Extend additive
Key idea
Γ ` M : TΓ ` α.M : bαc.T= T + · · ·+ T︸ ︷︷ ︸
bαc
If ` M : T , then ` (0.9).M + (1.1).M : T
(0.9).M + (1.1).M → 2.M and ` 2.M : 2.T
Theorem (weak subject reduction)M → N, Γ ` M : T ⇒ Γ ` N : R with T � R
6 / 15
Idea: λCA - Extend additive
Key idea
Γ ` M : TΓ ` α.M : bαc.T= T + · · ·+ T︸ ︷︷ ︸
bαc
If ` M : T , then ` (0.9).M + (1.1).M : T
(0.9).M + (1.1).M → 2.M and ` 2.M : 2.T
Theorem (weak subject reduction)M → N, Γ ` M : T ⇒ Γ ` N : R with T � R
6 / 15
Unicity of types
Second problem:M + M → 2.M
If Γ ` M : T and Γ ` M : R, Γ ` 2.M :?
Solution: Church style
7 / 15
Unicity of types
Second problem:M + M → 2.M
If Γ ` M : T and Γ ` M : R, Γ ` 2.M :?
Solution: Church style
7 / 15
Confluence
Local confluence + Strong normalisation ⇒ Confluence
I Local confluence: Coq proof.I Strong normalisation:
PlanI Translation from λCA to λlin (i.e. remove annotations)I Preservation of reduction by the translationI Typability in λCA ⇒ Typability in VectorialI SN in Vectorial ⇒ SN in λCA
8 / 15
Confluence
Local confluence + Strong normalisation ⇒ Confluence
I Local confluence: Coq proof.
I Strong normalisation:Plan
I Translation from λCA to λlin (i.e. remove annotations)I Preservation of reduction by the translationI Typability in λCA ⇒ Typability in VectorialI SN in Vectorial ⇒ SN in λCA
8 / 15
Confluence
Local confluence + Strong normalisation ⇒ Confluence
I Local confluence: Coq proof.I Strong normalisation:
PlanI Translation from λCA to λlin (i.e. remove annotations)I Preservation of reduction by the translationI Typability in λCA ⇒ Typability in VectorialI SN in Vectorial ⇒ SN in λCA
8 / 15
Strong normalisation
|M| is the term M without type annotations
LemmaIf M → N, then
|M| →=v |N|
where |M| = |N| only when M → N is a type beta reduction.
Lemma
Γ ` M :T ⇒ ∆ `v |M| :R
9 / 15
Strong normalisation
|M| is the term M without type annotations
LemmaIf M → N, then
|M| →=v |N|
where |M| = |N| only when M → N is a type beta reduction.
Lemma
Γ ` M :T ⇒ ∆ `v |M| :R
9 / 15
Strong normalisation
|M| is the term M without type annotations
LemmaIf M → N, then
|M| →=v |N|
where |M| = |N| only when M → N is a type beta reduction.
Lemma
Γ ` M :T ⇒ ∆ `v |M| :R
9 / 15
Strong normalisation
LemmaThere is no infinite sequence reduction consisting only of type beta rules
Proof.Define:
σ(x : U) = 1 σ(ΛX .t) = 1 + σ(t) σ(t@U) =σ(t)σ(λx : U.t) =σ(t) σ((t) r) =σ(t) σ(r) σ(0) = 1
σ(α.t) =σ(t) σ(t + r) =σ(t) + σ(r)
Induction on M: σ((ΛX .M)@T ) > σ(M[X/T ]).
10 / 15
Strong normalisation
LemmaThere is no infinite sequence reduction consisting only of type beta rules
Proof.Define:
σ(x : U) = 1 σ(ΛX .t) = 1 + σ(t) σ(t@U) =σ(t)σ(λx : U.t) =σ(t) σ((t) r) =σ(t) σ(r) σ(0) = 1
σ(α.t) =σ(t) σ(t + r) =σ(t) + σ(r)
Induction on M: σ((ΛX .M)@T ) > σ(M[X/T ]).
10 / 15
Strong normalisation
Theorem (Strong normalisation)Γ ` M : T ⇒ M is SN
Proof.Γ ` M : T ⇒ ∆ `v |M| : R ⇒ |M| is SNAssume M not SN:
M → M1 → M2 → · · ·
Then|M| →=
v |M1| →=v |M2| →=
v · · ·
|M| is SN ⇒ ∀i > n |Mi | = |Mi+1|Then Mi → Mi+1 → · · · are type beta reductions.Then Mi must be SN. Absurd.
11 / 15
Strong normalisation
Theorem (Strong normalisation)Γ ` M : T ⇒ M is SN
Proof.Γ ` M : T ⇒ ∆ `v |M| : R ⇒ |M| is SN
Assume M not SN:
M → M1 → M2 → · · ·
Then|M| →=
v |M1| →=v |M2| →=
v · · ·
|M| is SN ⇒ ∀i > n |Mi | = |Mi+1|Then Mi → Mi+1 → · · · are type beta reductions.Then Mi must be SN. Absurd.
11 / 15
Strong normalisation
Theorem (Strong normalisation)Γ ` M : T ⇒ M is SN
Proof.Γ ` M : T ⇒ ∆ `v |M| : R ⇒ |M| is SNAssume M not SN:
M → M1 → M2 → · · ·
Then|M| →=
v |M1| →=v |M2| →=
v · · ·
|M| is SN ⇒ ∀i > n |Mi | = |Mi+1|Then Mi → Mi+1 → · · · are type beta reductions.Then Mi must be SN. Absurd.
11 / 15
Strong normalisation
Theorem (Strong normalisation)Γ ` M : T ⇒ M is SN
Proof.Γ ` M : T ⇒ ∆ `v |M| : R ⇒ |M| is SNAssume M not SN:
M → M1 → M2 → · · ·
Then|M| →=
v |M1| →=v |M2| →=
v · · ·
|M| is SN ⇒ ∀i > n |Mi | = |Mi+1|Then Mi → Mi+1 → · · · are type beta reductions.Then Mi must be SN. Absurd.
11 / 15
Strong normalisation
Theorem (Strong normalisation)Γ ` M : T ⇒ M is SN
Proof.Γ ` M : T ⇒ ∆ `v |M| : R ⇒ |M| is SNAssume M not SN:
M → M1 → M2 → · · ·
Then|M| →=
v |M1| →=v |M2| →=
v · · ·
|M| is SN ⇒ ∀i > n |Mi | = |Mi+1|
Then Mi → Mi+1 → · · · are type beta reductions.Then Mi must be SN. Absurd.
11 / 15
Strong normalisation
Theorem (Strong normalisation)Γ ` M : T ⇒ M is SN
Proof.Γ ` M : T ⇒ ∆ `v |M| : R ⇒ |M| is SNAssume M not SN:
M → M1 → M2 → · · ·
Then|M| →=
v |M1| →=v |M2| →=
v · · ·
|M| is SN ⇒ ∀i > n |Mi | = |Mi+1|Then Mi → Mi+1 → · · · are type beta reductions.
Then Mi must be SN. Absurd.
11 / 15
Strong normalisation
Theorem (Strong normalisation)Γ ` M : T ⇒ M is SN
Proof.Γ ` M : T ⇒ ∆ `v |M| : R ⇒ |M| is SNAssume M not SN:
M → M1 → M2 → · · ·
Then|M| →=
v |M1| →=v |M2| →=
v · · ·
|M| is SN ⇒ ∀i > n |Mi | = |Mi+1|Then Mi → Mi+1 → · · · are type beta reductions.Then Mi must be SN. Absurd.
11 / 15
Abstract interpretation
Translation to additive:
τ(α.M) =
bαc∑i=1
τ(M)
Theorem (Abstract interpretation)
τ(M) ↓a� τ(M ↓)
Lemma (Typing preservation)
Γ ` M : T ⇒ Γ `a τ(M) : T
12 / 15
Abstract interpretation
Translation to additive:
τ(α.M) =
bαc∑i=1
τ(M)
Theorem (Abstract interpretation)
τ(M) ↓a� τ(M ↓)
Lemma (Typing preservation)
Γ ` M : T ⇒ Γ `a τ(M) : T
12 / 15
Abstract interpretation
Translation to additive:
τ(α.M) =
bαc∑i=1
τ(M)
Theorem (Abstract interpretation)
τ(M) ↓a� τ(M ↓)
Lemma (Typing preservation)
Γ ` M : T ⇒ Γ `a τ(M) : T
12 / 15
Abstract interpretation
λCA
↓
��
τ // λadd
↓a
(�) ��
[·] // Fp
↓F
(�) ��λCA
τ// λadd
[·]// Fp
13 / 15
Contributions
I “Powerful” alternative to Vectorial (extension of Additive)I (weak) Subject reductionI Strong normalisation (via translation to Vectorial)I Confluence (via SN)I Abstract interpretation in System F with pairs (via Additive)
14 / 15
Possible extensions
I Taking also the ceil to have intervals... [Philippe Jorrand]
` α.M : [bαc, dαe].T
(better approximations)
I pairs to represent negatives... [Simon Perdrix]
` α.M : (bαc, ?).T ` −α.M : (?, bαc).T
I Complexes... [Simon Perdrix]
` (α− βi).M : [(bαc, ?), (?, bβc)].T
I etc.
15 / 15
Possible extensions
I Taking also the ceil to have intervals... [Philippe Jorrand]
` α.M : [bαc, dαe].T
(better approximations)
I pairs to represent negatives... [Simon Perdrix]
` α.M : (bαc, ?).T ` −α.M : (?, bαc).T
I Complexes... [Simon Perdrix]
` (α− βi).M : [(bαc, ?), (?, bβc)].T
I etc.
15 / 15
Possible extensions
I Taking also the ceil to have intervals... [Philippe Jorrand]
` α.M : [bαc, dαe].T
(better approximations)
I pairs to represent negatives... [Simon Perdrix]
` α.M : (bαc, ?).T ` −α.M : (?, bαc).T
I Complexes... [Simon Perdrix]
` (α− βi).M : [(bαc, ?), (?, bβc)].T
I etc.
15 / 15