Confluence via strong normalisation in an algebraic -calculus with - - PowerPoint PPT Presentation

confluence via strong normalisation in an algebraic
SMART_READER_LITE
LIVE PREVIEW

Confluence via strong normalisation in an algebraic -calculus with - - PowerPoint PPT Presentation

Confluence via strong normalisation in an algebraic -calculus with rewriting Accepted in LSFA 2011. To appear in EPTCS Pablo Buiras 1 Alejandro Daz-Caro 2 Mauro Jaskelioff 1 , 3 1 Universidad Nacional de Rosario, FCEIA, Argentina 2


slide-1
SLIDE 1

Confluence via strong normalisation in an algebraic λ-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

slide-2
SLIDE 2

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:

◮ Differential λ-calculus: capturing 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]

2 / 15

slide-3
SLIDE 3

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 λlin Origin Linear Logic Quantum computing Strategy Call-by-name Call-by-value

2 / 15

slide-4
SLIDE 4

Confluence issues

YB = (λx.(B + (x)x))λx.(B + (x)x) YB → B + YB → B + B + YB → . . .

3 / 15

slide-5
SLIDE 5

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

3 / 15

slide-6
SLIDE 6

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 1 (λlin): α.M + β.M → (α + β).M

  • nly if M is closed-normal

and others similar restrictions

3 / 15

slide-7
SLIDE 7

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 Solution 1 (λlin): α.M + β.M → (α + β).M

  • nly if M is closed-normal

and others similar restrictions

3 / 15

slide-8
SLIDE 8

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

  • nly if M is closed-normal

and others similar restrictions

3 / 15

slide-9
SLIDE 9

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

  • nly if M is closed-normal

and others similar restrictions Objective: to forbid ∞ − ∞

3 / 15

slide-10
SLIDE 10

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

  • nly if M is closed-normal

and others similar restrictions Solution 3: forbid ∞! (type system) Objective: to forbid ∞ − ∞

3 / 15

slide-11
SLIDE 11

Possible type systems

Straightforward extension of a classic type system Γ ⊢ M : T Γ ⊢ N : T +I Γ ⊢ M + N : T Γ ⊢ M : T αI Γ ⊢ α.M : T 0I Γ ⊢ 0 : T Pros: Cons:

◮ Simple ◮ Too restrictive

4 / 15

slide-12
SLIDE 12

Possible type systems

Straightforward extension of a classic type system Γ ⊢ M : T Γ ⊢ N : T +I Γ ⊢ M + N : T Γ ⊢ M : T αI Γ ⊢ α.M : T 0I Γ ⊢ 0 : T Pros: Cons:

◮ Simple ◮ Too restrictive

Scalar type system [Arrighi, Díaz-Caro 2009] Γ ⊢ M : α.T Γ ⊢ N : β.T +I Γ ⊢ M + N : (α + β).T Γ ⊢ M : T αI Γ ⊢ α.M : α.T 0I Γ ⊢ 0 : 0.T Pros: Cons:

◮ Characterises the ’amount’

  • f terms

◮ Still too restrictive

4 / 15

slide-13
SLIDE 13

Possible type systems

Additive type system [Díaz-Caro, Petit 2010] Γ ⊢ M : T Γ ⊢ N : R +I Γ ⊢ M + N : T + R ✘✘✘✘✘✘✘ ✘ ❳❳❳❳❳❳❳ ❳ Γ ⊢ M : T αI Γ ⊢ α.M : α.T 0I Γ ⊢ 0 : 0 Pros: Cons:

◮ More versatile ◮ Interpretation in System F

with pairs

◮ Defined for a fragment

(no scalars!)

5 / 15

slide-14
SLIDE 14

Possible type systems

Additive type system [Díaz-Caro, Petit 2010] Γ ⊢ M : T Γ ⊢ N : R +I Γ ⊢ M + N : T + R ✘✘✘✘✘✘✘ ✘ ❳❳❳❳❳❳❳ ❳ Γ ⊢ M : T αI Γ ⊢ α.M : α.T 0I Γ ⊢ 0 : 0 Pros: Cons:

◮ More versatile ◮ Interpretation in System F

with pairs

◮ 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 : T 0I Γ ⊢ 0 : 0.T Pros: Cons:

◮ Much more versatile ◮ Good characterisation of

terms

◮ Complex ◮ Overkill (confluence!)

5 / 15

slide-15
SLIDE 15

Possible type systems

Additive type system [Díaz-Caro, Petit 2010] Γ ⊢ M : T Γ ⊢ N : R +I Γ ⊢ M + N : T + R ✘✘✘✘✘✘✘ ✘ ❳❳❳❳❳❳❳ ❳ Γ ⊢ M : T αI Γ ⊢ α.M : α.T 0I Γ ⊢ 0 : 0 Pros: Cons:

◮ More versatile ◮ Interpretation in System F

with pairs

◮ 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 : T 0I Γ ⊢ 0 : 0.T Pros: Cons:

◮ Much more versatile ◮ Good characterisation of

terms

◮ Complex ◮ Overkill (confluence!)

Idea: extend Additive

5 / 15

slide-16
SLIDE 16

Idea: λCA - Extend additive

Key idea Γ ⊢ M : T Γ ⊢ α.M : ⌊α⌋.T= T + · · · + T

  • ⌊α⌋

6 / 15

slide-17
SLIDE 17

Idea: λCA - Extend additive

Key idea Γ ⊢ M : T Γ ⊢ α.M : ⌊α⌋.T= T + · · · + T

  • ⌊α⌋

If ⊢ M : T, then ⊢ (0.9).M + (1.1).M : T (0.9).M + (1.1).M → 2.M and ⊢ 2.M : 2.T

6 / 15

slide-18
SLIDE 18

Idea: λCA - Extend additive

Key idea Γ ⊢ M : T Γ ⊢ α.M : ⌊α⌋.T= T + · · · + T

  • ⌊α⌋

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

slide-19
SLIDE 19

Unicity of types

Second problem: M + M → 2.M If Γ ⊢ M : T and Γ ⊢ M : R, Γ ⊢ 2.M :?

7 / 15

slide-20
SLIDE 20

Unicity of types

Second problem: M + M → 2.M If Γ ⊢ M : T and Γ ⊢ M : R, Γ ⊢ 2.M :? Solution: Church style

7 / 15

slide-21
SLIDE 21

Confluence

Local confluence + Strong normalisation ⇒ Confluence

8 / 15

slide-22
SLIDE 22

Confluence

Local confluence + Strong normalisation ⇒ Confluence

◮ Local confluence: Coq proof.

8 / 15

slide-23
SLIDE 23

Confluence

Local confluence + Strong normalisation ⇒ Confluence

◮ Local confluence: Coq proof. ◮ Strong normalisation:

Plan

◮ Translation from λCA to λlin (i.e. remove annotations) ◮ Preservation of reduction by the translation ◮ Typability in λCA ⇒ Typability in Vectorial ◮ SN in Vectorial ⇒ SN in λCA 8 / 15

slide-24
SLIDE 24

Strong normalisation

|M| is the term M without type annotations

9 / 15

slide-25
SLIDE 25

Strong normalisation

|M| is the term M without type annotations

Lemma

If M → N, then |M| →=

v |N|

where |M| = |N| only when M → N is a type beta reduction.

9 / 15

slide-26
SLIDE 26

Strong normalisation

|M| is the term M without type annotations

Lemma

If 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

slide-27
SLIDE 27

Strong normalisation

Lemma

There is no infinite sequence reduction consisting only of type beta rules

10 / 15

slide-28
SLIDE 28

Strong normalisation

Lemma

There 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

slide-29
SLIDE 29

Strong normalisation

Theorem (Strong normalisation)

Γ ⊢ M : T ⇒ M is SN

11 / 15

slide-30
SLIDE 30

Strong normalisation

Theorem (Strong normalisation)

Γ ⊢ M : T ⇒ M is SN

Proof.

Γ ⊢ M : T ⇒ ∆ ⊢v |M| : R ⇒ |M| is SN

11 / 15

slide-31
SLIDE 31

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 → · · ·

11 / 15

slide-32
SLIDE 32

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 · · ·

11 / 15

slide-33
SLIDE 33

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|

11 / 15

slide-34
SLIDE 34

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.

11 / 15

slide-35
SLIDE 35

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

slide-36
SLIDE 36

Abstract interpretation

Translation to additive: τ(α.M) =

⌊α⌋

  • i=1

τ(M)

12 / 15

slide-37
SLIDE 37

Abstract interpretation

Translation to additive: τ(α.M) =

⌊α⌋

  • i=1

τ(M)

Theorem (Abstract interpretation)

τ(M) ↓a τ(M ↓)

12 / 15

slide-38
SLIDE 38

Abstract interpretation

Translation to additive: τ(α.M) =

⌊α⌋

  • i=1

τ(M)

Theorem (Abstract interpretation)

τ(M) ↓a τ(M ↓)

Lemma (Typing preservation)

Γ ⊢ M : T ⇒ Γ ⊢a τ(M) : T

12 / 15

slide-39
SLIDE 39

Abstract interpretation

λCA

  • τ

λadd

↓a () [·]

Fp

↓F ()

λCA

τ

λadd

[·]

Fp

13 / 15

slide-40
SLIDE 40

Contributions

◮ “Powerful” alternative to Vectorial (extension of Additive) ◮ (weak) Subject reduction ◮ Strong normalisation (via translation to Vectorial) ◮ Confluence (via SN) ◮ Abstract interpretation in System F with pairs (via Additive)

14 / 15

slide-41
SLIDE 41

Possible extensions

◮ Taking also the ceil to have intervals... [Philippe Jorrand]

⊢ α.M : [⌊α⌋, ⌈α⌉].T (better approximations)

15 / 15

slide-42
SLIDE 42

Possible extensions

◮ Taking also the ceil to have intervals... [Philippe Jorrand]

⊢ α.M : [⌊α⌋, ⌈α⌉].T (better approximations)

◮ pairs to represent negatives... [Simon Perdrix]

⊢ α.M : (⌊α⌋, ⋆).T ⊢ −α.M : (⋆, ⌊α⌋).T

15 / 15

slide-43
SLIDE 43

Possible extensions

◮ Taking also the ceil to have intervals... [Philippe Jorrand]

⊢ α.M : [⌊α⌋, ⌈α⌉].T (better approximations)

◮ pairs to represent negatives... [Simon Perdrix]

⊢ α.M : (⌊α⌋, ⋆).T ⊢ −α.M : (⋆, ⌊α⌋).T

◮ Complexes... [Simon Perdrix]

⊢ (α − βi).M : [(⌊α⌋, ⋆), (⋆, ⌊β⌋)].T

◮ etc.

15 / 15