Space-efficiency and the Geometry of Interaction Ulrich Schpp LMU - - PowerPoint PPT Presentation

space efficiency and the geometry of interaction
SMART_READER_LITE
LIVE PREVIEW

Space-efficiency and the Geometry of Interaction Ulrich Schpp LMU - - PowerPoint PPT Presentation

Space-efficiency and the Geometry of Interaction Ulrich Schpp LMU Munich February 16, 2006 Project Pro.Platz at LMU Munich [Hofmann, Johannsen, Schwichtenberg, S] Programming language aspects of sublinear space complexity classes (L,


slide-1
SLIDE 1

Space-efficiency and the Geometry of Interaction

Ulrich Schöpp

LMU Munich February 16, 2006

slide-2
SLIDE 2

Project Pro.Platz at LMU Munich

[Hofmann, Johannsen, Schwichtenberg, S] Programming language aspects of sublinear space complexity classes (L, Polylog-space, NL, …)

slide-3
SLIDE 3

Programming languages capturing logarithmic space

Find a convenient programming language capturing FL.

Existing work

  • Function algebra (explicit resource bounds) [Lind 1974]
  • Function algebra with unary numbers [Bellantoni 1992]
  • Tail recursive readonly programs [Jones 1999]
  • Function algebra BC−

ε [Møller-Neergaard & Mairson 2004]

slide-4
SLIDE 4

A model for space-efficient computation

We propose to use a version of the Geometry of Interaction as a flexible semantic universe for space-efficient computation.

This talk

  • 1. Function algebra BC −

ε

  • 2. A version of the Geometry of Interaction

2.1 Interpretation of BC −

ε

2.2 Extensions of BC −

ε

  • 3. Towards an intrinsic model capturing FL
slide-5
SLIDE 5

The function algebra BC −

ε

Origin

  • BC [Bellantoni & Cook 1992]
  • BC − [Murawski & Ong 2000]
  • BC − ⊆ FL [Ong & Mairson 2003]
  • BC −

ε = FL [Møller-Neergaard 2004]

Definition

BC −

ε is a set of functions on N2 = {0, 1}∗.

BC −

ε ⊆ {f : Nm 2 × Nn 2 → N2 | m, n ∈ N}

Notation: f( x; y) (normal arguments x; safe arguments y)

slide-6
SLIDE 6

Functions in BC −

Base functions

  • ε(·; ·) = ε
  • s0(·; y) = y0
  • s1(·; y) = y1
  • p(·; yi) = y and p(·; ε) = ε
  • c(·; y, u, v) =

u if y = y′1 v

  • therwise
  • πi(

x; y) = xi and πm+i( x; y) = yi

Composition

Safe arguments are treated linearly. f(g1(x; ·), g2(x; ·); h1(x; y1), h2(x; y2, y3))

slide-7
SLIDE 7

Recursion

f = rec(g, h0, h1) satisfies f( x, ε; y) = g( x; y) f( x, xi; y) = hi( x, x; f( x, x; y)) Example: parity(ε; ·) = s1(ε) parity(x0; ·) = parity(x; ·) parity(x1; ·) = c(·; parity(x; ·), s0(ε), s1(ε)) Non-example: f( x, ε; y) = g( x; y) f( x, xi; y) = c(·; f( x, x; y), p(f( x, x; y)), h( x, x; f( x, x; y)))

slide-8
SLIDE 8

Functions in BC −

ε BC −

ε extends BC − by course-of-value recursion.

f = rec(g, h0, h1, d0, d1) satisfies f( x, ε; y) = g( x; y) f( x, xi; y) = hi( x, x; f( x, x> >|di( x, x; ·)|; y)) Example: ulog(ε; ·) = ε ulog(xi; ·) = s1(ulog(x> >|uhalf (x)|; ·))

slide-9
SLIDE 9

Evaluating BC−

ε in FL By example shift(ε; y) = y shift(xi; y) = p(·; shift(x; y)) Naive call-by-value evaluation uses linear space. FL-evaluation of BC −

ε proceeds bit by bit.

slide-10
SLIDE 10

Evaluating BC−

ε in FL shift(ε; y) = y shift(xi; y) = p(·; shift(x; y)) Bit(0)? — shift(10; 1101)

slide-11
SLIDE 11

Evaluating BC−

ε in FL shift(ε; y) = y shift(xi; y) = p(·; shift(x; y)) Bit(0)? — shift(10; 1101) Bit(1)? — shift(1; 1101)

slide-12
SLIDE 12

Evaluating BC−

ε in FL shift(ε; y) = y shift(xi; y) = p(·; shift(x; y)) Bit(0)? — shift(10; 1101) Bit(1)? — shift(1; 1101) Bit(2)? — shift(ε; 1101)

slide-13
SLIDE 13

Evaluating BC−

ε in FL shift(ε; y) = y shift(xi; y) = p(·; shift(x; y)) Bit(0)? — shift(10; 1101) Bit(1)? — shift(1; 1101) Bit(2)? — shift(ε; 1101) Bit 2 of shift(ε; 1101) is 1

slide-14
SLIDE 14

Evaluating BC−

ε in FL shift(ε; y) = y shift(xi; y) = p(·; shift(x; y)) Bit 2 of shift(ε; 1101) is 1

slide-15
SLIDE 15

Evaluating BC−

ε in FL shift(ε; y) = y shift(xi; y) = p(·; shift(x; y)) Bit 2 of shift(ε; 1101) is 1 Bit(0)? — shift(10; 1101)

slide-16
SLIDE 16

Evaluating BC−

ε in FL shift(ε; y) = y shift(xi; y) = p(·; shift(x; y)) Bit 2 of shift(ε; 1101) is 1 Bit(0)? — shift(10; 1101) Bit(1)? — shift(1; 1101)

slide-17
SLIDE 17

Evaluating BC−

ε in FL shift(ε; y) = y shift(xi; y) = p(·; shift(x; y)) Bit 2 of shift(ε; 1101) is 1 Bit(0)? — shift(10; 1101) Bit(1)? — shift(1; 1101) Bit 1 of shift(1; 1101) is 1

slide-18
SLIDE 18

Evaluating BC−

ε in FL shift(ε; y) = y shift(xi; y) = p(·; shift(x; y)) Bit 1 of shift(1; 1101) is 1

slide-19
SLIDE 19

Evaluating BC−

ε in FL shift(ε; y) = y shift(xi; y) = p(·; shift(x; y)) Bit 1 of shift(1; 1101) is 1 Bit(0)? — shift(10; 1101)

slide-20
SLIDE 20

Evaluating BC−

ε in FL shift(ε; y) = y shift(xi; y) = p(·; shift(x; y)) Bit 1 of shift(1; 1101) is 1 Bit(0)? — shift(10; 1101) Bit 0 of shift(10; 1101) is 1

slide-21
SLIDE 21

Evaluating BC−

ε in FL

  • By linearity, recursion can be evaluated by storing only:
  • Initial question, current question
  • Recursion depth
  • Already computed bit and its depth
  • All intermediate values and all questions are

polynomially bounded. |f( x; y)| ≤ p(| x, y|) q ≤ p′(q0) ⇒ By iterating over the bits of the output, f can be computed in logarithmic space.

slide-22
SLIDE 22

Modelling the evaluation of BC −

ε Question/answer dialogues ⇒ Game Semantics Need only a special case ⇒ Geometry of Interaction situation

Geometry of Interaction

  • Origin: syntax-free explanation of cut elimination for

linear logic [Girard 1988]

  • Connection to game semantics [Abramsky, Jagadeesan 92]
  • General categorical formulation

[Hyland], [Abramsky, Haghverdi, Scott 2000]

  • Compilation of programming languages [Mackie 1995]
  • Close connections to abstract machines, e.g. Krivine

Abstract Machine [Danos, Herbelin, Regnier 1996]

  • Used in complexity theory [Baillot], [Pedicini], [Dal Lago] …
slide-23
SLIDE 23

Geometry of Interaction

Objects

A = (A−, A+) Example: N− = N N+ = {0, 1, ∗} Natural numbers are represented by functions N− → N+.

Morphisms

Morphism of type f : A → B is a partial function f : B− + A+ − → B+ + A−

slide-24
SLIDE 24

Identity and Composition

Identity id : A − → A Composition f : A − → B g: B − → C g · f : A − → C

slide-25
SLIDE 25

Structure

  • Pairs

A ⊗ B = (A− + B−, A+ + B+)

  • Functions

A ⊸ B = (A+ + B−, A− + B+)

  • Storage

!A = (A− × N, A+ × N)

slide-26
SLIDE 26

Interpreting BC −

ε f(x1, . . . , xm; y1, . . . , yn) is interpreted as a morphism f: !Nm⊗!Nn − → N

Conditional

c: !N⊗!N⊗!N − → N is given by N−+!N++!N++!N+ − → N++!N−+!N−+!N− in1(q) − → in2(0, q) in2(1, s) − → in3(s, 0) in2(_, s) − → in4(s, 0) in3(a, s) − → in1(a) in4(a, s) − → in1(a)

slide-27
SLIDE 27

Interpreting BC −

ε

Recursion combinator

rec: !N⊗!(!N ⊸ N)⊗!(!N ⊸ N)⊗!N ⊸ N

inl(q) − → inx(0, q, q, 0, −1, −1) inx(∗, s) − → ing(s.q, s) inx(i, s) − → inhi(s.q, s) ing(a, s) − → inr(a) if s3 = 0 inx(q0, s1, s1, 0, s3, a)

  • therwise

inhi(a, s) − → ing(a, s) inri((q, l), s) − → inri((s5, l), s) if s3 + 1 = s4 inx(s3 + 1, s1, q, s3 + 1, s4, s5))

  • therwise
slide-28
SLIDE 28

Interpreting BC −

ε

Recursion combinator

rec: !N⊗!(!N ⊸ N)⊗!(!N ⊸ N)⊗!N ⊸ N

slide-29
SLIDE 29

Interpreting BC −

ε in GoI f(x1, . . . , xm; y1, . . . , yn) in BC −

ε is interpreted as

f: !N⊗m⊗!N⊗n − → N. There exist k ∈ N and a polynomial p, such that:

  • 1. If

x, y ∈ Space(b(z)) then f·! x, y ∈ Space( k·(z+log | x, y|)+b(k·(z+log | x, y|)) )

  • 2. For all

x, y and all initial questions q0, at most one question (q, s) may be sent to each safe argument yi. q ≤ q0 + p(| x, y|)

slide-30
SLIDE 30

What do we gain from the interpretation?

Direct consequences forBC −

ε

  • Simple compilation of the language
  • Function types
  • Recursively defined functions
  • General framework for modelling data types

More generally

  • GoI captures the recomputation pattern often used in

FL-computation

  • GoI-Realizability for FL
slide-31
SLIDE 31

Recursively defined functions

Example

Addition is naturally defined by recursion with result type N → N → N.

add(ε) = λy. λc. if c then inc(y) else y add(xi) = λy. λc. s(i+y0+c0) mod 2(add(x) p(y) ⌊(i + y0 + c0)/2⌋))

Simplest case

g: N ⊸ N f = rec(g, h0, h1) hi : (N ⊸ N) ⊸ (N ⊸ N) f ε = g f : N → N ⊸ N f xi = hi (f x)

slide-32
SLIDE 32

Recursively defined functions

slide-33
SLIDE 33

Recursively defined functions

Exploit linearity of h0 and h1 [e.g. Hofmann 1997]. A linear function hi : !(!N ⊸ N) ⊸ (!N ⊸ N) decomposes in ki : !N ⊸!N ⊸ N and ai : !N ⊸ N. (hi f) n = ki n (f (ai n))

slide-34
SLIDE 34

Recursively defined functions

A linear function hi : !(!N ⊸ N) ⊸ (!N ⊸ N) decomposes in ki : !N ⊸!N ⊸ N and ai : !N ⊸ N. = ⇒

slide-35
SLIDE 35

Recursively defined functions

A linear function hi : !(!N ⊸ N) ⊸ (!N ⊸ N) decomposes in ki : !N ⊸!N ⊸ N and ai : !N ⊸ N.

slide-36
SLIDE 36

Recursively defined functions

A linear function hi : !(!N ⊸ N) ⊸ (!N ⊸ N) decomposes in ki : !N ⊸!N ⊸ N and ai : !N ⊸ N. ⇒ Recursion decomposes in two nested recursions on N

slide-37
SLIDE 37

Recursively defined functions — Example

Write f(ε) = λy. ε f(xi) = λy. if y then si(f(x) 0) else (f(x) 1) as f(x) = λy. f ′(x, ε; y). ai(ε; y) = y ai(xri; y) = if ai(xr; y) then 0 else 1 f ′

i(ε, xr; y) = ε

f ′

i(xi, xr; y) = if ai(xr; y) then si(f(x, ixr; y)) else (f(x, ixr; y))

slide-38
SLIDE 38

Towards an intrinsic model for FL

Instead of establishing resource bounds afterwards, we want a model that captures FL intrinsically.

Size-restricted Geometry of Interaction

Restrict to morphisms f : B− + A+ − → B+ + A− that are

  • non-size-increasing and
  • computable in linear space.

Realizability

Restrict to functions that are realised by size-restricted GoI-morphisms.

slide-39
SLIDE 39

Realizability

Objects

Set |A|, size-restricted GoI object A, realizability relation A i, l, k, e A a      a ∈ |A| e: A− → A+ i, l, k ∈ N Example: Natural numbers |N| = N N = (L(B) ⊗ L(♦), {∗, 0, 1} ⊗ L(♦)) i, l, k, e n iff

  • l ≥ |n|
  • On question b, ♦k·log l, the function e returns Bit b of n

and gives back the memory

slide-40
SLIDE 40

Realizability

Morphisms

Morphism f : A → B is a function f : |A| → |B|, for which there exist r: !A → B and ϕ, such that α, e x = ⇒ α + ϕ, r·!e f(x) holds. (plus a condition restricting the use of the !-modality)

  • Proposition. The underlying function of every morphism

f : N → N is FL-computable.

slide-41
SLIDE 41

Realizability — Work in progress

Structure and constructions

  • Monoidal closure: ⊗, ⊸
  • Question-linearity and modality
  • Interpretation of BC −

ε

Programming language for FL on this basis

  • Resource type ♦ for size-control
  • Modality to control question-linearity