Inductive Program Synthesis for Bidirectional Transformations - - PowerPoint PPT Presentation

inductive program synthesis for bidirectional
SMART_READER_LITE
LIVE PREVIEW

Inductive Program Synthesis for Bidirectional Transformations - - PowerPoint PPT Presentation

Inductive Program Synthesis for Bidirectional Transformations Tobias G odderz, Helmut Grohne, Janis Voigtl ander University of Bonn Dagstuhl Seminar 15442 Bidirectional Transformation source view get s v v s 1 1/4


slide-1
SLIDE 1

Inductive Program Synthesis for Bidirectional Transformations

Tobias G¨

  • dderz, Helmut Grohne, Janis Voigtl¨

ander

University of Bonn

Dagstuhl Seminar 15442

slide-2
SLIDE 2

Bidirectional Transformation

source view s v s′ v′ get

1 – 1/4

slide-3
SLIDE 3

Bidirectional Transformation

source view s v s′ v′ get update

1 – 2/4

slide-4
SLIDE 4

Bidirectional Transformation

source view s v s′ v′ get put update

1 – 3/4

slide-5
SLIDE 5

Bidirectional Transformation

source view s v s′ v′ get put update

1 – 4/4

slide-6
SLIDE 6

Bidirectional Transformation

Examples: “abc” “bc” “ade” “de” tail

2 – 5/13

slide-7
SLIDE 7

Bidirectional Transformation

Examples: “abc” “bc” “ade” “de” tail update

2 – 6/13

slide-8
SLIDE 8

Bidirectional Transformation

Examples: “abc” “bc” “ade” “de” tail put update

2 – 7/13

slide-9
SLIDE 9

Bidirectional Transformation

Examples: ‘a’ ‘b’ ‘a’ ‘c’ “abac” ‘a’ ‘b’ ‘x’ ‘c’ “abxc” flatten

2 – 8/13

slide-10
SLIDE 10

Bidirectional Transformation

Examples: ‘a’ ‘b’ ‘a’ ‘c’ “abac” ‘a’ ‘b’ ‘x’ ‘c’ “abxc” flatten update

2 – 9/13

slide-11
SLIDE 11

Bidirectional Transformation

Examples: ‘a’ ‘b’ ‘a’ ‘c’ “abac” ‘a’ ‘b’ ‘x’ ‘c’ “abxc” flatten put update

2 – 10/13

slide-12
SLIDE 12

Bidirectional Transformation

Examples: ‘a’ ‘b’ ‘a’ ‘c’ “abc” ‘x’ ‘b’ ‘x’ ‘c’ “xbc” nub ◦ flatten

2 – 11/13

slide-13
SLIDE 13

Bidirectional Transformation

Examples: ‘a’ ‘b’ ‘a’ ‘c’ “abc” ‘x’ ‘b’ ‘x’ ‘c’ “xbc” nub ◦ flatten update

2 – 12/13

slide-14
SLIDE 14

Bidirectional Transformation

Examples: ‘a’ ‘b’ ‘a’ ‘c’ “abc” ‘x’ ‘b’ ‘x’ ‘c’ “xbc” nub ◦ flatten put update

2 – 13/13

slide-15
SLIDE 15

Bidirectional Transformation

source view s v s′ v′ get put update

3 – 14/15

slide-16
SLIDE 16

Bidirectional Transformation – Laws

source view s v s′ v′ get put update

3 – 15/15

slide-17
SLIDE 17

Bidirectional Transformation – Laws

source view s v s v get = Acceptability / GetPut

4 – 16/19

slide-18
SLIDE 18

Bidirectional Transformation – Laws

source view s v s v get put = = Acceptability / GetPut

4 – 17/19

slide-19
SLIDE 19

Bidirectional Transformation – Laws

source view s v s′ v′ get put update Consistency / PutGet

4 – 18/19

slide-20
SLIDE 20

Bidirectional Transformation – Laws

source view s v s′ v′ get put update get Consistency / PutGet

4 – 19/19

slide-21
SLIDE 21

Bidirectional Transformation

source view s v s′ v′ get put update

5 – 20/22

slide-22
SLIDE 22

Bidirectional Transformation – PL Approaches

source view s v s′ v′ get put update Lenses, DSLs [Foster et al., ACM TOPLAS’07, . . . ]

5 – 21/22

slide-23
SLIDE 23

Bidirectional Transformation – PL Approaches

source view s v s′ v′ get put update Bidirectionalization [Matsuda et al., ICFP’07], [V., POPL’09], . . .

5 – 22/22

slide-24
SLIDE 24

Nondeterminism / Choices to make

Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd"

6 – 23/33

slide-25
SLIDE 25

Nondeterminism / Choices to make

Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" Then, for example: put "abcd" "xy" = "axcy"

6 – 24/33

slide-26
SLIDE 26

Nondeterminism / Choices to make

Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" Then, for example: put "abcd" "xy" = "axcy" put "abcde" "xy" = "axcye"

6 – 25/33

slide-27
SLIDE 27

Nondeterminism / Choices to make

Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" Then, for example: put "abcd" "xy" = "axcy" put "abcde" "xy" = "axcye" put "abcde" "xyz" =

6 – 26/33

slide-28
SLIDE 28

Nondeterminism / Choices to make

Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" Then, for example: put "abcd" "xy" = "axcy" put "abcde" "xy" = "axcye" put "abcde" "xyz" = "axcyez"

6 – 27/33

slide-29
SLIDE 29

Nondeterminism / Choices to make

Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" Then, for example: put "abcd" "xy" = "axcy" put "abcde" "xy" = "axcye" put "abcde" "xyz" = "axcyez"

  • r "axcyez " ?

6 – 28/33

slide-30
SLIDE 30

Nondeterminism / Choices to make

Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" Then, for example: put "abcd" "xy" = "axcy" put "abcde" "xy" = "axcye" put "abcde" "xyz" = "axcyez"

  • r "axcyez " ?

put "abcd" "xyz" = "axcy z"

6 – 29/33

slide-31
SLIDE 31

Nondeterminism / Choices to make

Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" Then, for example: put "abcd" "xy" = "axcy" put "abcde" "xy" = "axcye" put "abcde" "xyz" = "axcyez"

  • r "axcyez " ?

put "abcd" "xyz" = "axcy z" put "abcd" "x" =

6 – 30/33

slide-32
SLIDE 32

Nondeterminism / Choices to make

Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" Then, for example: put "abcd" "xy" = "axcy" put "abcde" "xy" = "axcye" put "abcde" "xyz" = "axcyez"

  • r "axcyez " ?

put "abcd" "xyz" = "axcy z" put "abcd" "x" = "axc"

6 – 31/33

slide-33
SLIDE 33

Nondeterminism / Choices to make

Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" Then, for example: put "abcd" "xy" = "axcy" put "abcde" "xy" = "axcye" put "abcde" "xyz" = "axcyez"

  • r "axcyez " ?

put "abcd" "xyz" = "axcy z" put "abcd" "x" = "axc"

  • r "ax" ?

6 – 32/33

slide-34
SLIDE 34

Nondeterminism / Choices to make

Let get = sieve with: s "" "a" "ab" "abc" "abcd" "abcde" sieve s "" "" "b" "b" "bd" "bd" Then, for example: put "abcd" "xy" = "axcy" put "abcde" "xy" = "axcye" put "abcde" "xyz" = "axcyez"

  • r "axcyez " ?

put "abcd" "xyz" = "axcy z" put "abcd" "x" = "axc"

  • r "ax" ? ,
  • r "cx" ?

6 – 33/33

slide-35
SLIDE 35

Nondeterminism / Choices to make

Let get = head with: head (x : xs) = x

7 – 34/38

slide-36
SLIDE 36

Nondeterminism / Choices to make

Let get = head with: head (x : xs) = x Maybe: put (x : xs) y = [y ]

7 – 35/38

slide-37
SLIDE 37

Nondeterminism / Choices to make

Let get = head with: head (x : xs) = x Maybe: put (x : xs) y = [y ] But that violates put s (get s) = s !

7 – 36/38

slide-38
SLIDE 38

Nondeterminism / Choices to make

Let get = head with: head (x : xs) = x Maybe: put (x : xs) y = [y ] But that violates put s (get s) = s ! Better: put (x : xs) y | y == x = (x : xs) | otherwise = [y ]

7 – 37/38

slide-39
SLIDE 39

Nondeterminism / Choices to make

Let get = head with: head (x : xs) = x Maybe: put (x : xs) y = [y ] But that violates put s (get s) = s ! Better: put (x : xs) y | y == x = (x : xs) | otherwise = [y ] But “really intended”: put (x : xs) y = (y : xs)

7 – 38/38

slide-40
SLIDE 40

A slightly more complex case, with recursion

Let get = init with: init [x ] = [ ] init (x : xs) = (x : (init xs))

8 – 39/42

slide-41
SLIDE 41

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 + + " "

8 – 40/42

slide-42
SLIDE 42

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 ]

8 – 41/42

slide-43
SLIDE 43

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 ] Problem: How to produce the “intuitive” solution?

8 – 42/42

slide-44
SLIDE 44

Entry: Inductive Program Synthesis

9 – 43/46

slide-45
SLIDE 45

Entry: Inductive Program Synthesis

Problem: Of the well-behavedness laws put s (get s) = s get (put s v′) = v′

  • nly the first one directly delivers I/O pairs for put.

9 – 44/46

slide-46
SLIDE 46

Entry: Inductive Program Synthesis

Problem: Of the well-behavedness laws put s (get s) = s get (put s v′) = v′

  • nly the first one directly delivers I/O pairs for put.

Like, for get = init: put [a] [ ] = [a] put [a, b] [a] = [a, b] put [a, b, c ] [a, b] = [a, b, c ] put [a, b, c, d ] [a, b, c ] = [a, b, c, d ]

9 – 45/46

slide-47
SLIDE 47

Entry: Inductive Program Synthesis

Problem: Of the well-behavedness laws put s (get s) = s get (put s v′) = v′

  • nly the first one directly delivers I/O pairs for put.

Like, for get = init: put [a] [ ] = [a] put [a, b] [a] = [a, b] put [a, b, c ] [a, b] = [a, b, c ] put [a, b, c, d ] [a, b, c ] = [a, b, c, d ] But then one would synthesize: put xs ys = xs

9 – 46/46

slide-48
SLIDE 48

One possible approach

“Encourage” use of both arguments!

10 – 47/49

slide-49
SLIDE 49

One possible approach

“Encourage” use of both arguments! Instead of: put [a] [ ] = [a] put [a, b] [a] = [a, b] · · · use: put [a] [ ] = [a] put [ , b] [a] = [a, b] put [ , , c ] [a, b] = [a, b, c ] put [ , , , d ] [a, b, c ] = [a, b, c, d ]

10 – 48/49

slide-50
SLIDE 50

One possible approach

“Encourage” use of both arguments! Instead of: put [a] [ ] = [a] put [a, b] [a] = [a, b] · · · use: put [a] [ ] = [a] put [ , b] [a] = [a, b] put [ , , c ] [a, b] = [a, b, c ] put [ , , , d ] [a, b, c ] = [a, b, c, d ] Then, Igor II synthesizes: put [a] [ ] = [a] put ( : (x : ys)) (a : bs) = (a : (put (x : ys) bs))

10 – 49/49

slide-51
SLIDE 51

One possible approach

Also works for get = sieve. Gives: put xs [ ] = xs put (a : ( : xs)) (b : ys) = (a : (b : (put xs ys)))

11 – 50/53

slide-52
SLIDE 52

One possible approach

Also works for get = sieve. Gives: put xs [ ] = xs put (a : ( : xs)) (b : ys) = (a : (b : (put xs ys))) But this put is not defined when (length s) / 2 < length v′.

11 – 51/53

slide-53
SLIDE 53

One possible approach

Also works for get = sieve. Gives: put xs [ ] = xs put (a : ( : xs)) (b : ys) = (a : (b : (put xs ys))) But this put is not defined when (length s) / 2 < length v′. Idea: Introduce extra examples covering such cases: put [ ] [b] = [ , b] (as a “mutation” of put [a, ] [b] = [a, b]).

11 – 52/53

slide-54
SLIDE 54

One possible approach

Also works for get = sieve. Gives: put xs [ ] = xs put (a : ( : xs)) (b : ys) = (a : (b : (put xs ys))) But this put is not defined when (length s) / 2 < length v′. Idea: Introduce extra examples covering such cases: put [ ] [b] = [ , b] (as a “mutation” of put [a, ] [b] = [a, b]). But actually then, in general, also need to express inequality constraints . . .

11 – 53/53

slide-55
SLIDE 55

Conclusion / Outlook

◮ Bidirectional Transformations:

◮ “hot topic” in various areas, including PL approaches ◮ typical weakness: nondeterminism, and limited (or no)

impact of programmer intentions

12 – 54/56

slide-56
SLIDE 56

Conclusion / Outlook

◮ Bidirectional Transformations:

◮ “hot topic” in various areas, including PL approaches ◮ typical weakness: nondeterminism, and limited (or no)

impact of programmer intentions

◮ Connection to Inductive Programming:

◮ IP as a “helper”, detecting/exploiting regularities ◮ either naively as a black box, or deeper integration ◮ further ideas: I/O pairs per parametricity of get;

user impact through ad-hoc I/O pairs or provision of background knowledge; . . .

12 – 55/56

slide-57
SLIDE 57

Conclusion / Outlook

◮ Bidirectional Transformations:

◮ “hot topic” in various areas, including PL approaches ◮ typical weakness: nondeterminism, and limited (or no)

impact of programmer intentions

◮ Connection to Inductive Programming:

◮ IP as a “helper”, detecting/exploiting regularities ◮ either naively as a black box, or deeper integration ◮ further ideas: I/O pairs per parametricity of get;

user impact through ad-hoc I/O pairs or provision of background knowledge; . . .

◮ Extensions to Igor II:

◮ dealing with wildcards on rhs of I/O pairs ◮ a new operator for introducing accumulating parameters ◮ some reduction of search space 12 – 56/56

slide-58
SLIDE 58

References I

  • F. Bancilhon and N. Spyratos.

Update semantics of relational views. ACM Transactions on Database Systems, 6(3):557–575, 1981. J.N. Foster, M.B. Greenwald, J.T. Moore, B.C. Pierce, and A. Schmitt. Combinators for bidirectional tree transformations: A linguistic approach to the view-update problem. ACM Transactions on Programming Languages and Systems, 29(3):17, 2007.

  • S. Katayama.

Systematic search for lambda expressions. In Trends in Functional Programming 2005, Revised Selected Papers, pages 111–126. Intellect, 2007.

13 – 57/58

slide-59
SLIDE 59

References II

  • E. Kitzelmann and U. Schmid.

Inductive synthesis of functional programs: An explanation based generalization approach. Journal of Machine Learning Research, 7:429–454, 2006.

  • K. Matsuda, Z. Hu, K. Nakano, M. Hamana, and M. Takeichi.

Bidirectionalization transformation based on automatic derivation of view complement functions. In International Conference on Functional Programming, Proceedings, pages 47–58. ACM Press, 2007.

  • J. Voigtl¨

ander. Bidirectionalization for free! In Principles of Programming Languages, Proceedings, pages 165–176. ACM Press, 2009.

14 – 58/58