space efficiency and the geometry of interaction
play

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,


  1. Space-efficiency and the Geometry of Interaction Ulrich Schöpp LMU Munich February 16, 2006

  2. Project Pro.Platz at LMU Munich [Hofmann, Johannsen, Schwichtenberg, S] Programming language aspects of sublinear space complexity classes (L, Polylog-space, NL, …)

  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]

  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

  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 N 2 = { 0 , 1 } ∗ . ε ⊆ { f : N m 2 × N n BC − 2 → N 2 | m, n ∈ N } Notation: f ( � x ; � y ) ( normal arguments � x ; safe arguments � y )

  6. Functions in BC − Base functions • ε ( · ; · ) = ε • s 0 ( · ; y ) = y 0 • s 1 ( · ; y ) = y 1 • p( · ; yi ) = y and p( · ; ε ) = ε � u if y = y ′ 1 • c( · ; y, u, v ) = otherwise v • π i ( � x ; � y ) = x i and π m + i ( � x ; � y ) = y i Composition Safe arguments are treated linearly . f ( g 1 ( x ; · ) , g 2 ( x ; · ); h 1 ( x ; y 1 ) , h 2 ( x ; y 2 , y 3 ))

  7. Recursion f = rec( g, h 0 , h 1 ) satisfies f ( � x, ε ; � y ) = g ( � x ; � y ) f ( � x, xi ; � y ) = h i ( � x, x ; f ( � x, x ; � y )) Example: parity ( ε ; · ) = s 1 ( ε ) parity ( x 0; · ) = parity ( x ; · ) parity ( x 1; · ) = c( · ; parity ( x ; · ) , s 0 ( ε ) , s 1 ( ε )) 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 )))

  8. Functions in BC − ε ε extends BC − by course-of-value recursion. BC − f = rec( g, h 0 , h 1 , d 0 , d 1 ) satisfies f ( � x, ε ; � y ) = g ( � x ; � y ) f ( � x, xi ; � y ) = h i ( � x, x ; f ( � x, x> > | d i ( � x, x ; · ) | ; � y )) Example: ulog ( ε ; · ) = ε ulog ( xi ; · ) = s 1 ( ulog ( x> > | uhalf ( x ) | ; · ))

  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.

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

  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)

  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)

  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

  14. Evaluating BC − ε in FL shift ( ε ; y ) = y shift ( xi ; y ) = p( · ; shift ( x ; y )) Bit 2 of shift ( ε ; 1101) is 1

  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)

  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)

  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

  18. Evaluating BC − ε in FL shift ( ε ; y ) = y shift ( xi ; y ) = p( · ; shift ( x ; y )) Bit 1 of shift (1; 1101) is 1

  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)

  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

  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 ( | � y | ) x, � q ≤ p ′ ( q 0 ) ⇒ By iterating over the bits of the output, f can be computed in logarithmic space.

  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] …

  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 −

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

  25. Structure • Pairs A ⊗ B = ( A − + B − , A + + B + ) • Functions A ⊸ B = ( A + + B − , A − + B + ) • Storage ! A = ( A − × N , A + × N )

  26. Interpreting BC − ε f ( x 1 , . . . , x m ; y 1 , . . . , y n ) is interpreted as a morphism � f � : ! N m ⊗ ! N n − → N Conditional � c � : ! N ⊗ ! N ⊗ ! N − → N is given by N − +! N + +! N + +! N + − → N + +! N − +! N − +! N − in 1 ( q ) �− → in 2 (0 , q ) in 2 (1 , s ) �− → in 3 ( s, 0) in 2 ( _ , s ) �− → in 4 ( s, 0) in 3 ( a, s ) �− → in 1 ( a ) in 4 ( a, s ) �− → in 1 ( a )

  27. Interpreting BC − ε Recursion combinator rec: ! N ⊗ !(! N ⊸ N ) ⊗ !(! N ⊸ N ) ⊗ ! N ⊸ N inl ( q ) �− → in x (0 , � q, q, 0 , − 1 , − 1 � ) in x ( ∗ , s ) �− → in g ( s.q, s ) in x ( i, s ) �− → in h i ( s.q, s ) � inr ( a ) if s 3 = 0 in g ( a, s ) �− → in x ( q 0 , � s 1 , s 1 , 0 , s 3 , a � ) otherwise in h i ( a, s ) �− → in g ( a, s ) � in r i (( s 5 , l ) , s ) if s 3 + 1 = s 4 in r i (( q, l ) , s ) �− → in x ( s 3 + 1 , � s 1 , q, s 3 + 1 , s 4 , s 5 � )) otherwise

  28. Interpreting BC − ε Recursion combinator rec: ! N ⊗ !(! N ⊸ N ) ⊗ !(! N ⊸ N ) ⊗ ! N ⊸ N

  29. Interpreting BC − ε in GoI f ( x 1 , . . . , x m ; y 1 , . . . , y n ) 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 � � y � and all initial questions q 0 , at most one x, � question ( q, s ) may be sent to each safe argument y i . q ≤ q 0 + p ( | � y | ) x, �

  30. What do we gain from the interpretation? Direct consequences for BC − ε • 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

  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 + y 0 + c 0 ) mod 2 ( add ( x ) p( y ) ⌊ ( i + y 0 + c 0 ) / 2 ⌋ )) Simplest case g : N ⊸ N f = rec( g, h 0 , h 1 ) h i : ( N ⊸ N ) ⊸ ( N ⊸ N ) f ε = g f : N → N ⊸ N f xi = h i ( f x )

  32. Recursively defined functions

  33. Recursively defined functions Exploit linearity of h 0 and h 1 [e.g. Hofmann 1997] . A linear function h i : !(! N ⊸ N ) ⊸ (! N ⊸ N ) decomposes in k i : ! N ⊸ ! N ⊸ N and a i : ! N ⊸ N . ( h i f ) n = k i n ( f ( a i n ))

  34. Recursively defined functions A linear function h i : !(! N ⊸ N ) ⊸ (! N ⊸ N ) decomposes in k i : ! N ⊸ ! N ⊸ N and a i : ! N ⊸ N . = ⇒

  35. Recursively defined functions A linear function h i : !(! N ⊸ N ) ⊸ (! N ⊸ N ) decomposes in k i : ! N ⊸ ! N ⊸ N and a i : ! N ⊸ N .

  36. Recursively defined functions A linear function h i : !(! N ⊸ N ) ⊸ (! N ⊸ N ) decomposes in k i : ! N ⊸ ! N ⊸ N and a i : ! N ⊸ N . ⇒ Recursion decomposes in two nested recursions on N

Recommend


More recommend