Confluence via strong normalisation in an algebraic λ -calculus with rewriting – Accepted in LSFA 2011. To appear in EPTCS – Pablo Buiras 1 Alejandro Díaz-Caro 2 Mauro Jaskelioff 1 , 3 1 Universidad Nacional de Rosario, FCEIA, Argentina 2 Université de Grenoble, LIG, France 3 CIFASIS-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 )( N 1 + N 2 ) → ( M ) N 1 + ( M ) N 2 , . . . . . . . . . (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
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 )( N 1 + N 2 ) → ( M ) N 1 + ( M ) N 2 , . . . . . . . . . (oriented version of the axioms of vectorial spaces) λ alg λ lin Origin Linear Logic Quantum computing Strategy Call-by-name Call-by-value 2 / 15
Confluence issues Y B = ( λ x . ( B + ( x ) x )) λ x . ( B + ( x ) x ) Y B → B + Y B → B + B + Y B → . . . 3 / 15
Confluence issues Y B = ( λ x . ( B + ( x ) x )) λ x . ( B + ( x ) x ) Y B → B + Y B → B + B + Y B → . . . → ∗ 0 Y B + ( − 1 ) . Y B − → ( 1 − 1 ) . Y B − ↓ B + Y B + ( − 1 ) . Y B ↓ ∗ B 3 / 15
Confluence issues Y B = ( λ x . ( B + ( x ) x )) λ x . ( B + ( x ) x ) Y B → B + Y B → B + B + Y B → . . . → ∗ 0 Y B + ( − 1 ) . Y B − → ( 1 − 1 ) . Y B − ↓ Solution 1 ( λ lin ): B + Y B + ( − 1 ) . Y B α. M + β. M → ( α + β ) . M ↓ ∗ only if M is closed-normal B and others similar restrictions 3 / 15
Confluence issues Y B = ( λ x . ( B + ( x ) x )) λ x . ( B + ( x ) x ) Y B → B + Y B → B + B + Y B → . . . → ∗ 0 Y B + ( − 1 ) . Y B − → ( 1 − 1 ) . Y B − ↓ Solution 1 ( λ lin ): B + Y B + ( − 1 ) . Y B α. M + β. M → ( α + β ) . M ↓ ∗ only if M is closed-normal B and others similar restrictions Solution 2 ( λ alg ): Only positive numbers 3 / 15
Confluence issues Y B = ( λ x . ( B + ( x ) x )) λ x . ( B + ( x ) x ) Y B → B + Y B → B + B + Y B → . . . → ∗ 0 Y B + ( − 1 ) . Y B − → ( 1 − 1 ) . Y B − ↓ Solution 1 ( λ lin ): B + Y B + ( − 1 ) . Y B α. M + β. M → ( α + β ) . M ↓ ∗ only if M is closed-normal B and others similar restrictions Solution 2 ( λ alg ): Only positive numbers Y B + Y B − → B + Y B + Y B − → B + 2 . Y B ↓ 2 . Y B ... and equalities 3 / 15
Confluence issues Y B = ( λ x . ( B + ( x ) x )) λ x . ( B + ( x ) x ) Y B → B + Y B → B + B + Y B → . . . → ∗ 0 Y B + ( − 1 ) . Y B − → ( 1 − 1 ) . Y B − ↓ Solution 1 ( λ lin ): B + Y B + ( − 1 ) . Y B α. M + β. M → ( α + β ) . M ↓ ∗ only if M is closed-normal B and others similar restrictions Solution 2 ( λ alg ): Only positive numbers Y B + Y B − → B + Y B + Y B − → B + 2 . Y B ↓ 2 . Y B ... and equalities Objective: to forbid ∞ − ∞ 3 / 15
Confluence issues Y B = ( λ x . ( B + ( x ) x )) λ x . ( B + ( x ) x ) Y B → B + Y B → B + B + Y B → . . . → ∗ 0 Y B + ( − 1 ) . Y B − → ( 1 − 1 ) . Y B − ↓ Solution 1 ( λ lin ): B + Y B + ( − 1 ) . Y B α. M + β. M → ( α + β ) . M ↓ ∗ only if M is closed-normal B and others similar restrictions Solution 2 ( λ alg ): Solution 3: Only positive numbers forbid ∞ ! (type system) Y B + Y B − → B + Y B + Y B − → B + 2 . Y B ↓ 2 . Y B ... and equalities Objective: to forbid ∞ − ∞ 3 / 15
Possible type systems Straightforward extension of a classic type system Γ ⊢ M : T Γ ⊢ N : T Γ ⊢ M : T 0 I + I α I Γ ⊢ 0 : T Γ ⊢ M + N : T Γ ⊢ α. M : T Pros: Cons: ◮ Simple ◮ Too restrictive 4 / 15
Possible type systems Straightforward extension of a classic type system Γ ⊢ M : T Γ ⊢ N : T Γ ⊢ M : T 0 I + I α I Γ ⊢ 0 : T Γ ⊢ M + N : T Γ ⊢ α. M : T Pros: Cons: ◮ Simple ◮ Too restrictive Scalar type system [Arrighi, Díaz-Caro 2009] Γ ⊢ M : α. T Γ ⊢ N : β. T Γ ⊢ M : T 0 I + I α I Γ ⊢ 0 : 0 . T Γ ⊢ M + N : ( α + β ) . T Γ ⊢ α. M : α. T Pros: Cons: ◮ Characterises the ’amount’ ◮ Still too restrictive of terms 4 / 15
Possible type systems Additive type system [Díaz-Caro, Petit 2010] Γ ⊢ M : T Γ ⊢ N : R Γ ⊢ M : T ❳❳❳❳❳❳❳ ✘ ✘✘✘✘✘✘✘ 0 I + I α I Γ ⊢ 0 : 0 Γ ⊢ M + N : T + R Γ ⊢ α. M : α. T ❳ Pros: Cons: ◮ More versatile ◮ Defined for a fragment (no scalars!) ◮ Interpretation in System F with pairs 5 / 15
Possible type systems Additive type system [Díaz-Caro, Petit 2010] Γ ⊢ M : T Γ ⊢ N : R Γ ⊢ M : T ❳❳❳❳❳❳❳ ✘ ✘✘✘✘✘✘✘ 0 I + I α I Γ ⊢ 0 : 0 Γ ⊢ M + N : T + R Γ ⊢ α. M : α. T ❳ Pros: Cons: ◮ More versatile ◮ Defined for a fragment (no scalars!) ◮ Interpretation in System F with pairs Vectorial type system [Arrighi, Díaz-Caro, Valiron 2011] Γ ⊢ M : T Γ ⊢ N : R Γ ⊢ M : T Γ ⊢ M : T + I α I 0 I Γ ⊢ M + N : T + R Γ ⊢ α. M : α. T Γ ⊢ 0 : 0 . T Pros: Cons: ◮ Much more versatile ◮ Complex ◮ Good characterisation of ◮ Overkill (confluence!) terms 5 / 15
Possible type systems Additive type system [Díaz-Caro, Petit 2010] Γ ⊢ M : T Γ ⊢ N : R Γ ⊢ M : T ❳❳❳❳❳❳❳ ✘ ✘✘✘✘✘✘✘ 0 I + I α I Γ ⊢ 0 : 0 Γ ⊢ M + N : T + R Γ ⊢ α. M : α. T ❳ Pros: Cons: ◮ More versatile ◮ Defined for a fragment (no scalars!) ◮ Interpretation in System F with pairs Vectorial type system [Arrighi, Díaz-Caro, Valiron 2011] Γ ⊢ M : T Γ ⊢ N : R Γ ⊢ M : T Γ ⊢ M : T + I α I 0 I Γ ⊢ M + N : T + R Γ ⊢ α. M : α. T Γ ⊢ 0 : 0 . T Pros: Cons: ◮ Much more versatile ◮ Complex ◮ Good characterisation of ◮ Overkill (confluence!) terms Idea: extend Additive 5 / 15
Idea: λ CA - Extend additive Key idea Γ ⊢ M : T Γ ⊢ α. M : ⌊ α ⌋ . T = T + · · · + T � �� � ⌊ α ⌋ 6 / 15
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
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
Unicity of types Second problem: M + M → 2 . M If Γ ⊢ M : T and Γ ⊢ M : R , Γ ⊢ 2 . M :? 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 8 / 15
Confluence Local confluence + Strong normalisation ⇒ Confluence ◮ Local confluence: Coq proof. 8 / 15
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
Strong normalisation | M | is the term M without type annotations 9 / 15
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
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
Strong normalisation Lemma There is no infinite sequence reduction consisting only of type beta rules 10 / 15
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
Strong normalisation Theorem (Strong normalisation) Γ ⊢ M : T ⇒ M is SN 11 / 15
Strong normalisation Theorem (Strong normalisation) Γ ⊢ M : T ⇒ M is SN Proof. Γ ⊢ M : T ⇒ ∆ ⊢ v | M | : R ⇒ | M | is SN 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 → M 1 → M 2 → · · · 11 / 15
Recommend
More recommend