Ideas for Connecting Inductive Program Synthesis and Bidirectionalization Janis Voigtl¨ ander University of Bonn PEPM’12
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
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
View-Update [Banc. & Sp., ACM TODS’81] source view get s v v ′ s ′ 2
View-Update [Banc. & Sp., ACM TODS’81] source view get s v update v ′ s ′ 2
View-Update [Banc. & Sp., ACM TODS’81] source view get s v update v ′ s ′ put 2
View-Update [Banc. & Sp., ACM TODS’81] source view get s v update v ′ s ′ put 2
View-Update [Banc. & Sp., ACM TODS’81] source view get s v = s v Acceptability / GetPut 2
View-Update [Banc. & Sp., ACM TODS’81] source view get s v = = s v put Acceptability / GetPut 2
View-Update [Banc. & Sp., ACM TODS’81] source view get s v update v ′ s ′ put Consistency / PutGet 2
View-Update [Banc. & Sp., ACM TODS’81] source view get s v update s ′ v ′ put get Consistency / PutGet 2
View-Update [Banc. & Sp., ACM TODS’81] source view get s v update v ′ s ′ put 2
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
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
Bidirectionalization (BX) Examples: tail “abc” “bc” “ade” “de” 3
Bidirectionalization (BX) Examples: tail “abc” “bc” update “ade” “de” 3
Bidirectionalization (BX) Examples: tail “abc” “bc” update “ade” “de” put 3
Bidirectionalization (BX) Examples: flatten “abac” ‘a’ ‘b’ ‘a’ ‘c’ “abxc” ‘a’ ‘b’ ‘x’ ‘c’ 3
Bidirectionalization (BX) Examples: flatten “abac” ‘a’ ‘b’ ‘a’ ‘c’ update “abxc” ‘a’ ‘b’ ‘x’ ‘c’ 3
Bidirectionalization (BX) Examples: flatten “abac” ‘a’ ‘b’ ‘a’ ‘c’ update “abxc” put ‘a’ ‘b’ ‘x’ ‘c’ 3
Nondeterminism / Choices to make Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" 4
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
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
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
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
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
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
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
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
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
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
Nondeterminism / Choices to make Let get = head with: head ( x : xs ) = x 5
Nondeterminism / Choices to make Let get = head with: head ( x : xs ) = x Maybe: put ( x : xs ) y = [ y ] 5
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
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
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
A slightly more complex case, with recursion Let get = init with: init [ x ] = [ ] init ( x : xs ) = ( x : ( init xs )) 6
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
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