Introduction ICC : Implicit Computational Complexity The problem: - - PowerPoint PPT Presentation

introduction
SMART_READER_LITE
LIVE PREVIEW

Introduction ICC : Implicit Computational Complexity The problem: - - PowerPoint PPT Presentation

A Complete Polynomial -Calculus joint work with Simona Ronchi Della Rocca Erika De Benedetti Universit` a degli Studi di Torino ICTCS (Varese), 20 September 2012 A Complete Polynomial -Calculus Erika De Benedetti (UNITO) ICTCS (Varese),


slide-1
SLIDE 1

A Complete Polynomial λ-Calculus

joint work with Simona Ronchi Della Rocca Erika De Benedetti

Universit` a degli Studi di Torino

ICTCS (Varese), 20 September 2012

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 1 / 24

slide-2
SLIDE 2

Introduction

ICC: Implicit Computational Complexity The problem: the design of programming languages with bounded computational complexity, in particular PTIME. The line: a ML-like approach

λ-calculus as paradigmatic programming language. types as semantic properties of terms. Type assignment for λ-calculus such that:

types guarantee the correctness of terms, in particular their complexity bound.

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 2 / 24

slide-3
SLIDE 3

Our ancestors

Two similar proposals, based on Light Logics (derived from the Linear Logic of Girard) where the cut-elimination procedure is bounded in time by the size of the proof, exploiting the isomorphism: FORMULAE as TYPES

DLAL (Baillot, Terui): Types are formulae of LAL (Light Affine Logic) (Girard, Asperti, Roversi) STA (Gaboardi, RDR): Types are formulae of SOFT (Soft Linear Logic) (Lafont)

Both: are sound and complete w.r.t. FPTIME i.e.:

all and only polynomial functions can be coded by typed terms (using a standard uniform coding)

give type to a proper subset of strongly normalizing terms.

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 3 / 24

slide-4
SLIDE 4

A system with stratification types: ISTA

We explore a different (non logical) approach, where types are stratified, so equivalent to intersection types with idempotence and commutativity, but without associativity. Our system ISTA is:

sound and complete w.r.t. FPTIME sound and complete w.r.t. strong normalization

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 4 / 24

slide-5
SLIDE 5

Definitions

The set of types of ISTA is defined by the following syntax: A ::= a | σ → A | ∀a.A (linear types) σ ::= A | {σ1, ..., σn} n > 0 (stratified types) where

{σ1, ..., σn} is treated as a set { jA} j stands for {...{

  • j

A }...}

  • j

brackets { } are not associative ¯ σ = {A1, ..., An}

ISTA proves judgments of the shape π : Γ ⊢ M : σ

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 5 / 24

slide-6
SLIDE 6

Typing rules for ISTA

x : A ⊢ x : A (Ax) Γ ⊢ M : σ x dom(Γ) Γ, x : A ⊢ M : σ (w) Γ, x : σ ⊢ M : B Γ ⊢ λx.M : σ → B (→ I) Γ1 ⊢ M : σ → A Γ2 ⊢ N : σ Γ1#Γ2 Γ1, Γ2 ⊢ MN : A (→ E) Γ ⊢ M : A a FTV(Γ) Γ ⊢ M : ∀a.A (∀I) Γ ⊢ M : ∀a.B Γ ⊢ M : B[A/a] (∀E) Γi ⊢ M : σi 1 ≤ i ≤ n n

i=1{Γi} ⊢ M : {σ1, ..., σn} (st)

Γ, x1 : A, ..., xn : A ⊢ M : τ Γ, x : {A} ⊢ M[x/x1, ..., x/xn] : τ (ml) Γ, x1 : σ1, ..., xn : σn ⊢ M : τ σi not linear Γ, x : {σ1, ..., σn} ⊢ M[x/x1, ..., x/xn] : τ (ms)

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 6 / 24

slide-7
SLIDE 7

Normalization bound

The depth of a derivation π, denoted by d(π), is the maximum nesting of applications of rule (st)

Normalization bound π : Γ ⊢ M : σ, and M

−→

β

nf(M) in m steps, then m ≤ |M|d(π)+1, where |M| is the size of M and d(π) is the depth of the derivation π. Note that A typable term has infinite types, so infinite derivations. Every derivation gives a bound

  • f its normalization time

A typable term has a minimal derivation. So the minimal bound depends only on the term itself.

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 7 / 24

slide-8
SLIDE 8

Strong normalization

ISTA is sound and complete w.r.t. strong normalization: if a term is typable in ISTA then it is strongly normalizing (soundness)

  • Proof. Termination of reduction does not depend on the strategy

all strongly normalizing terms can be typed in ISTA (completeness)

  • Proof. Following the guidelines of Neergaard1:

1

Longest reduction strategy

2

Subject expansion under perpetual strategy

3

Completeness follows as a corollary

1Neergaard 2005 Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 8 / 24

slide-9
SLIDE 9

Typability w.r.t. System F

With respect to system F:

More terms can be typed:

e.g. ⊢ (λxy.y(xI)(xK))∆ : ((A → A) → B → C) → C I = λx.x, K = λxy.x, ∆ = λx.xx

More types can be assigned:

e.g. ⊢ λx.xx : ∀ a.{{σ}, {σ → B}} → B , a ⊆ FV(σ) ∪ FV(B)

Stratification does not limit the number of terms that can be typed, but is necessary in

  • rder to limit the complexity.

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 9 / 24

slide-10
SLIDE 10

Soft Type Assignment system (STA)

To prove soundness and completeness w.r.t FPTIME, we use the corresponding property of STA2. We use the same technique of Bucciarelli and Piperno, when proving that adding intersection to simple types does not increase the definability of functions. The set of types of STA is a proper subset of the SOFT formulae and is defined by the following syntax:

U ::= a | µ → U | ∀a.U (linear types) µ ::= U |!µ (modal types)

restrictions with respect to SOFT: modalities are not allowed neither on the r.h.s. of an arrow nor under the universal quantifier.

2Gaboardi-Ronchi 2007 Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 10 / 24

slide-11
SLIDE 11

Reminder: STA

x : U ⊢STA x : U (Ax) Θ ⊢STA M : µ x domΘ Θ, x : U ⊢STA M : µ (w) Θ, x : µ ⊢STA M : U Θ ⊢STA λx.M : µ → U (→ I) Θ ⊢STA M : µ → U Ξ ⊢STA N : µ Θ#Ξ Θ, Ξ ⊢STA MN : U (→ E) Θ ⊢STA M : U a FV(Θ) Θ ⊢STA M : ∀a.U (∀I) Θ ⊢STA M : ∀a.B Θ ⊢STA M : B[U/a] (∀E) Θ, x1 : µ, . . . , xn : µ ⊢STA M : ν Θ, x :!µ ⊢STA M[x/x1, ..., xn] : ν (m) Θ ⊢ M : µ !Θ ⊢STA M :!µ (sp)

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 11 / 24

slide-12
SLIDE 12

Representation of numerals

We represent numerals in Church style, so m is represented by m = λxy. x(x...(x

  • m

y)...)) In STA, m can be typed either

uniformely by N = ∀a.!(a → a) → a → a, or by Nn = ∀a.!n(a → a) → a → a, for all n ≥ 1

In ISTA, m can be typed either

uniformely by NI = ∀a.{a → a} → a → a, or by NIn = ∀a.{na → a}n → a → a, for all n ≥ 1

Both in ISTA and in STA derivations for numerals have depth 0.

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 12 / 24

slide-13
SLIDE 13

Representation of functions in STA

Let φ : N p −→ N be a function of arity p. M represents φ in STA iff

1 Mn1...np = φ(n1, ..., np) 2

there are integers i1, ..., ip such that x1 :!i1N j1, ..., xp :!ipNjp ⊢STA Mx1...xp : N j, for some jh, j, 1 ≤ h ≤ p

FPTIME characterization

All and only the polynomial functions can be coded in STA.

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 13 / 24

slide-14
SLIDE 14

Representation of functions in STA

Example: succ: Ni → Ni+1 add: Ni → Nj → Nmax(i, j)+1 mult: Ni →!iN j → Ni+j for all i, j ≥ 1 So they cannot be iterated, but only composed in order to obtain polynomials.

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 14 / 24

slide-15
SLIDE 15

Representation of functions in ISTA

Let φ : N p −→ N be a function of arity p. M represents φ in ISTA iff

1 Mn1...np = φ(n1, ..., np) 2 x1 : σ1, ..., xp : σp ⊢ Mx1...xp : NIj, and for all i ∈ {1, ..., p}, either σi = NIk or

¯ σi = {NIi1, ...NIim} for some k, ih, j, 1 ≤ h ≤ p, m > 0

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 15 / 24

slide-16
SLIDE 16

FPTIME completeness

Translation (.)◦ from T S to T is defined as follows: (a)◦ = a; (µ → U)◦ = (µ)◦ → (U)◦; (!µ)◦ = {(µ)◦} Translation extended to derivations: (π : Θ ⊢STA M : µ)◦ = (π)◦ : (Θ)◦ ⊢ M : (µ)◦ such that:

the subject is preserved the depth is preserved

FPTIME completeness

In ISTA all the polynomial functions are definable.

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 16 / 24

slide-17
SLIDE 17

From ISTA to STA

(.)∗ is a translation from ISTA-derivations to STA-derivations such that: (π : Γ ⊢ M : A)∗ = (π)∗ : Θ ⊢STA ⌈M⌉ : (A)∗ such that

(A)∗ is a linear type; ⌈M⌉ is a partial linearization of M. the depth is preserved

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 17 / 24

slide-18
SLIDE 18

From ISTA to STA(2)

Example 1 Let M = λx.xx: π :⊢ M : {{b → a}, {b}} → a (π)∗ ⊢STA λx1.λx2.x1x2 :!!(b → a) →!!b → a Example 2 Let N = λx.λy.yxx: π :⊢ N : {a} → (a → a → a) → a (π)∗ :⊢STA N :!a → (a → a → a) → a

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 18 / 24

slide-19
SLIDE 19

Functions representation

For simplicity, let us consider unary functions. Let M represent in ISTA a program computing a function φ : N −→ N, i.e., π :⊢ M : σ → NIj where the components of σ are NIr1, ..., NIrm (1 ≤ i ≤ m) Let the corresponding derivation in STA be (π)∗ :⊢STA ⌈M⌉ :!i1Nj1 → ... →!imNjm → Nj ⌈M⌉ represents the function ψ, such that φ(n) = ψ( n, ..., n

  • m

)

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 19 / 24

slide-20
SLIDE 20

Conservativity: proof

We prove that there is a term in STA computing φ: its normal form is

⊢STA λx.xII(λz.z (λzw.xzw)...(λzw.xzw)

  • m

)⌈M⌉ :!kN → Nj

for any k ≥ max{i1, ..., im} + 2 In the proof we exploit two properties of STA:

1 Γ, x :!iν ⊢STA M : µ implies Γ, x :!jν ⊢STA M : µ, for every j ≥ i

(by a sequence of applications of rule (m));

2 there is a coercion Ci j = λxzw.xzw from any Ni to Nj, ( j ≤ i):

⊢STA Ci

j : Ni → N j

In fact, (λxzw.xzw)n

−→

β

n

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 20 / 24

slide-21
SLIDE 21

PTIME soundness

FPTIME soundness

All the functions definable in ISTA are polynomial

proof

Let π :⊢ M : σ → NI j, where the components of σ are NIr1, ..., NIrm and let (π)∗ :⊢STA ⌈M⌉ : µ =!i1Nj1 → ... →!imN jm → Nj. Then ⊢STA λx.xII(λz.z (λzw.xzw)...(λzw.xzw)

  • m

)⌈M⌉ : !kN → N j and (λx.xII(λz.z (λzw.xzw)...(λzw.xzw)

  • m

)⌈M⌉)n −→

β

⌈M⌉ n...n

  • m

in a number of steps linear in m. m depends only on M, so is independent from the input.

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 21 / 24

slide-22
SLIDE 22

Espressivity

In ISTA it is possible to type higher order functionals such as ITER3 succ n which is a more natural way of writing a program rather than succ (succ (succ n)) ⊢ ITER3 : {{NIi → NIi+1}, {NIi+1 → NIi+2}, {NIi+2 → NIi+3}} → NIi → NIi+3, so the term is not typed in STA

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 22 / 24

slide-23
SLIDE 23

Iteration of mult

On the other hand, in ISTA terms such as ITER3 mult n m cannot be typed In fact ITER3 : ∀a1.∀a2.∀a3.∀a4.{{a1 → a2}, {a2 → a3}, {a3 → a4}} → a1 → a4 Since mult : NIi → {iNI j}i → NIi+j, the presence of the stratified type prevents ITER3 from being typed

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 23 / 24

slide-24
SLIDE 24

Conclusions

ISTA is sound and complete w.r.t. FPTIME ISTA is sound and complete w.r.t. strong normalization In ISTA all numerical polynomial algorithms that can be expressed by a strongly normalizing term are typed Adding stratification types to STA types does not increase the definability of polynomial functions, but adds expressivity to the language

Erika De Benedetti (UNITO) A Complete Polynomial λ-Calculus ICTCS (Varese), 20 September 2012 24 / 24