ideas for connecting inductive program synthesis and
play

Ideas for Connecting Inductive Program Synthesis and - PowerPoint PPT Presentation

Ideas for Connecting Inductive Program Synthesis and Bidirectionalization Janis Voigtl ander University of Bonn PEPM12 A small test Which function is this? f 1 [ a ] = a f 1 [ a , b ] = b f 1 [ a , b , c ] = c f 1 [ a , b , c , d


  1. Ideas for Connecting Inductive Program Synthesis and Bidirectionalization Janis Voigtl¨ ander University of Bonn PEPM’12

  2. A small “test” Which function is this? f 1 [ a ] = a f 1 [ a , b ] = b f 1 [ a , b , c ] = c f 1 [ a , b , c , d ] = d 1

  3. A small “test” Which function is this? f 1 [ a ] = a f 1 [ a , b ] = b f 1 [ a , b , c ] = c f 1 [ a , b , c , d ] = d And this one? f 2 [ ] = [ ] f 2 [ a ] = [ a ] f 2 [ a , b ] = [ b , a ] f 2 [ a , b , c ] = [ c , b , a ] 1

  4. View-Update [Banc. & Sp., ACM TODS’81] source view get s v v ′ s ′ 2

  5. View-Update [Banc. & Sp., ACM TODS’81] source view get s v update v ′ s ′ 2

  6. View-Update [Banc. & Sp., ACM TODS’81] source view get s v update v ′ s ′ put 2

  7. View-Update [Banc. & Sp., ACM TODS’81] source view get s v update v ′ s ′ put 2

  8. View-Update [Banc. & Sp., ACM TODS’81] source view get s v = s v Acceptability / GetPut 2

  9. View-Update [Banc. & Sp., ACM TODS’81] source view get s v = = s v put Acceptability / GetPut 2

  10. View-Update [Banc. & Sp., ACM TODS’81] source view get s v update v ′ s ′ put Consistency / PutGet 2

  11. View-Update [Banc. & Sp., ACM TODS’81] source view get s v update s ′ v ′ put get Consistency / PutGet 2

  12. View-Update [Banc. & Sp., ACM TODS’81] source view get s v update v ′ s ′ put 2

  13. View-Update [Banc. & Sp., ACM TODS’81] source view get s v update s ′ v ′ put Lenses, DSLs [Foster et al., ACM TOPLAS’07, . . . ] 2

  14. View-Update [Banc. & Sp., ACM TODS’81] source view get s v update v ′ s ′ put Bidirectionalization [Matsuda et al., ICFP’07], [V., POPL’09], . . . 2

  15. Bidirectionalization (BX) Examples: tail “abc” “bc” “ade” “de” 3

  16. Bidirectionalization (BX) Examples: tail “abc” “bc” update “ade” “de” 3

  17. Bidirectionalization (BX) Examples: tail “abc” “bc” update “ade” “de” put 3

  18. Bidirectionalization (BX) Examples: flatten “abac” ‘a’ ‘b’ ‘a’ ‘c’ “abxc” ‘a’ ‘b’ ‘x’ ‘c’ 3

  19. Bidirectionalization (BX) Examples: flatten “abac” ‘a’ ‘b’ ‘a’ ‘c’ update “abxc” ‘a’ ‘b’ ‘x’ ‘c’ 3

  20. Bidirectionalization (BX) Examples: flatten “abac” ‘a’ ‘b’ ‘a’ ‘c’ update “abxc” put ‘a’ ‘b’ ‘x’ ‘c’ 3

  21. Nondeterminism / Choices to make Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" 4

  22. Nondeterminism / Choices to make Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" Then, for example: "xy" = "axcy" put "abcd" 4

  23. Nondeterminism / Choices to make Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" Then, for example: "xy" = "axcy" put "abcd" put "abcde" "xy" = "axcye" 4

  24. Nondeterminism / Choices to make Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" Then, for example: "xy" = "axcy" put "abcd" put "abcde" "xy" = "axcye" put "abcde" "xyz" = 4

  25. Nondeterminism / Choices to make Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" Then, for example: "xy" = "axcy" put "abcd" put "abcde" "xy" = "axcye" put "abcde" "xyz" = "axcyez" 4

  26. Nondeterminism / Choices to make Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" Then, for example: "xy" = "axcy" put "abcd" put "abcde" "xy" = "axcye" put "abcde" "xyz" = "axcyez" or "axcyez " ? 4

  27. Nondeterminism / Choices to make Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" Then, for example: "xy" = "axcy" put "abcd" put "abcde" "xy" = "axcye" put "abcde" "xyz" = "axcyez" or "axcyez " ? "xyz" = "axcy z" put "abcd" 4

  28. Nondeterminism / Choices to make Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" Then, for example: "xy" = "axcy" put "abcd" put "abcde" "xy" = "axcye" put "abcde" "xyz" = "axcyez" or "axcyez " ? "xyz" = "axcy z" put "abcd" = put "abcd" "x" 4

  29. Nondeterminism / Choices to make Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" Then, for example: "xy" = "axcy" put "abcd" put "abcde" "xy" = "axcye" put "abcde" "xyz" = "axcyez" or "axcyez " ? "xyz" = "axcy z" put "abcd" = "axc" put "abcd" "x" 4

  30. Nondeterminism / Choices to make Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" Then, for example: "xy" = "axcy" put "abcd" put "abcde" "xy" = "axcye" put "abcde" "xyz" = "axcyez" or "axcyez " ? "xyz" = "axcy z" put "abcd" = "axc" or "ax" ? put "abcd" "x" 4

  31. Nondeterminism / Choices to make Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" Then, for example: "xy" = "axcy" put "abcd" put "abcde" "xy" = "axcye" put "abcde" "xyz" = "axcyez" or "axcyez " ? "xyz" = "axcy z" put "abcd" = "axc" or "ax" ? , or "cx" ? put "abcd" "x" 4

  32. Nondeterminism / Choices to make Let get = head with: head ( x : xs ) = x 5

  33. Nondeterminism / Choices to make Let get = head with: head ( x : xs ) = x Maybe: put ( x : xs ) y = [ y ] 5

  34. Nondeterminism / Choices to make Let get = head with: head ( x : xs ) = x Maybe: put ( x : xs ) y = [ y ] But that violates put xs ( get xs ) = xs ! 5

  35. Nondeterminism / Choices to make Let get = head with: head ( x : xs ) = x Maybe: put ( x : xs ) y = [ y ] But that violates put xs ( get xs ) = xs ! Better: put ( x : xs ) y | y == x = ( x : xs ) | otherwise = [ y ] 5

  36. Nondeterminism / Choices to make Let get = head with: head ( x : xs ) = x Maybe: put ( x : xs ) y = [ y ] But that violates put xs ( get xs ) = xs ! Better: put ( x : xs ) y | y == x = ( x : xs ) | otherwise = [ y ] But “really intended”: put ( x : xs ) y = ( y : xs ) 5

  37. A slightly more complex case, with recursion Let get = init with: init [ x ] = [ ] init ( x : xs ) = ( x : ( init xs )) 6

  38. A slightly more complex case, with recursion Let get = init with: init [ x ] = [ ] init ( x : xs ) = ( x : ( init xs )) Possible, and correct: put xs ys | length ys == ( length xs ) − 1 = ys + + [ last xs ] | otherwise = ys + + " " 6

  39. A slightly more complex case, with recursion Let get = init with: init [ x ] = [ ] init ( x : xs ) = ( x : ( init xs )) Possible, and correct: put xs ys | length ys == ( length xs ) − 1 = ys + + [ last xs ] | otherwise = ys + + " " But intended: put xs ys = ys + + [ last xs ] 6

Recommend


More recommend