recursive program synthesis
play

Recursive Program Synthesis Aws Albarghouthi (UToronto), Sumit - PowerPoint PPT Presentation

Recursive Program Synthesis Aws Albarghouthi (UToronto), Sumit Gulwani (MSR), and Zachary Kincaid (UToronto) CAV 2013 Saint Petersburg, Russia Program Synthesis Magic Specification Program 2 Program Synthesis Magic Specification


  1. Recursive Program Synthesis Aws Albarghouthi (UToronto), Sumit Gulwani (MSR), and Zachary Kincaid (UToronto) CAV 2013 Saint Petersburg, Russia

  2. Program Synthesis Magic Specification Program 2

  3. Program Synthesis Magic Specification Program 2

  4. What are your Dreams? Magic Specification Program 3

  5. What are your Dreams? First-order Logic Magic Specification Program 3

  6. What are your Dreams? First-order Logic Magic Specification Program Temporal Logic 3

  7. What are your Dreams? First-order Logic Magic I/O Examples Program Temporal Logic 3

  8. Why Synthesis from I/O? I/O examples are easy to specify 4

  9. Why Synthesis from I/O? I/O examples are easy to specify Non-expert users can specify I/O behaviour • See, e.g., FlashFill for Excel, Smartphone scripts, etc. • Desired programs are usually simple 4

  10. Contribution Escher Recursive I/O Examples Program 5

  11. Contribution User Escher Recursive I/O Examples Program 5

  12. Contribution User Escher Recursive I/O Examples Program Parameterized by a set of building blocks (operations) integers, lists, trees, etc. 5

  13. Contribution User Escher Recursive I/O Examples Program Parameterized by a set of building blocks (operations) integers, lists, trees, etc. Novel search-based synthesis technique 5

  14. Contribution User Escher Recursive I/O Examples Program Parameterized by a set of building blocks (operations) integers, lists, trees, etc. Novel search-based synthesis technique No templates required 5

  15. High Level View Forward Search 6

  16. High Level View Forward Search I 1 I n . . . 6

  17. High Level View Forward Search I 1 I n . . . O 1 . . . O n 6

  18. High Level View Forward Search I 1 I n . . . P 1 P n . . . O 1 . . . O n 6

  19. High Level View Forward Search Conditional Inference I 1 I 1 I 2 I n . . . + P 1 P n P 1 P 2 . . . O 1 O 2 O 1 . . . O n 6

  20. High Level View Forward Search Conditional Inference I 1 I 1 I 2 I n . . . if ( ) C + P 1 P 1 P n = P 1 P 2 . . . else P 2 O 1 O 2 O 1 . . . O n 6

  21. High Level View Forward Search Conditional Inference I 1 I 1 I 2 I n . . . if ( ) C + P 1 P 1 P n = P 1 P 2 . . . else P 2 O 1 O 2 O 1 . . . O n 6

  22. High Level View Forward Search Conditional Inference I 1 I 1 I 2 I n . . . if ( ) C + P 1 P 1 P n = P 1 P 2 . . . else P 2 O 1 O 2 O 1 . . . O n Recursive call synthesis Reuse I/O as recursive call specification or query user 6

  23. Example Synthesize list length from examples: 7

  24. Example Synthesize list length from examples: → � [],[2],[1,2] � Inputs: 7

  25. Example Synthesize list length from examples: → � [],[2],[1,2] � Inputs: � 0,1,2 � Outputs: 7

  26. Ex: Forward Search Components: inc, isEmpty, tail, zero 8

  27. Ex: Forward Search Components: inc, isEmpty, tail, zero Programs of size 1: 8

  28. Ex: Forward Search Components: inc, isEmpty, tail, zero Programs of size 1: 1 P 1 = i → � [],[2],[1,2] � 8

  29. Ex: Forward Search Components: inc, isEmpty, tail, zero Programs of size 1: 1 P 1 = i → � [],[2],[1,2] � → � 1 P 2 = zero → � 0,0,0 � 8

  30. Ex: Forward Search Components: inc, isEmpty, tail, zero Programs of size 1: 1 P 1 = i → � [],[2],[1,2] � → � 1 P 2 = zero → � 0,0,0 � matches output for first input Recall outputs � 0,1,2 � 8

  31. Ex: Conditional Inference → � 1 P 2 = zero → � 0,0,0 � Outputs: � 0,1,2 �

  32. Ex: Conditional Inference → � 1 P 2 = zero → � 0,0,0 � Outputs: � 0,1,2 �

  33. Ex: Conditional Inference → � 1 P 2 = zero → � 0,0,0 � Outputs: � 0,1,2 � goal Goal Graph (GG): � 0,1,2 � P r cond then else � T,F,F � � 0,?,? � � ?,1,2 � P 2

  34. Ex: Conditional Inference → � 1 P 2 = zero → � 0,0,0 � Outputs: � 0,1,2 � goal Goal Graph (GG): � 0,1,2 � P r cond then else � T,F,F � � 0,?,? � � ?,1,2 � P 2

  35. Ex: Conditional Inference → � 1 P 2 = zero → � 0,0,0 � Outputs: � 0,1,2 � goal Goal Graph (GG): � 0,1,2 � AND node P r cond then else � T,F,F � � 0,?,? � � ?,1,2 � P 2

  36. Ex: Conditional Inference → � 1 P 2 = zero → � 0,0,0 � Outputs: � 0,1,2 � goal Goal Graph (GG): � 0,1,2 � “Backward” search AND node P r cond then else � T,F,F � � 0,?,? � � ?,1,2 � P 2

  37. Ex: Forward Search 2 Programs of size 1: 1 P 1 = i → � [],[2],[1,2] � → � 1 P 2 = zero → � 0,0,0 � 10

  38. Ex: Forward Search 2 Programs of size 1: 1 P 1 = i → � [],[2],[1,2] � → � 1 P 2 = zero → � 0,0,0 � → � � Programs of size 2: P 3 = tail ( P 1 ) → � err ,[],[2] � 2 P 4 = inc ( P 2 ) → � 1,1,1 � P 5 = isEmpty ( P 1 ) → � T,F,F � 10

  39. Ex: Forward Search 2 Programs of size 1: 1 P 1 = i → � [],[2],[1,2] � → � 1 P 2 = zero → � 0,0,0 � → � � Programs of size 2: P 3 = tail ( P 1 ) → � err ,[],[2] � 2 P 4 = inc ( P 2 ) → � 1,1,1 � P 5 = isEmpty ( P 1 ) → � T,F,F � 10

  40. Ex: Forward Search 2 Programs of size 1: 1 P 1 = i → � [],[2],[1,2] � → � 1 P 2 = zero → � 0,0,0 � → � � Programs of size 2: P 3 = tail ( P 1 ) → � err ,[],[2] � 2 P 4 = inc ( P 2 ) → � 1,1,1 � P 5 = isEmpty ( P 1 ) → � T,F,F � 10

  41. Ex: Forward Search 2 Programs of size 1: 1 P 1 = i → � [],[2],[1,2] � → � 1 P 2 = zero → � 0,0,0 � → � � Programs of size 2: P 3 = tail ( P 1 ) → � err ,[],[2] � 2 P 4 = inc ( P 2 ) → � 1,1,1 � P 5 = isEmpty ( P 1 ) → � T,F,F � 10

  42. Ex: Forward Search 2 Programs of size 1: 1 P 1 = i → � [],[2],[1,2] � → � 1 P 2 = zero → � 0,0,0 � → � � Programs of size 2: P 3 = tail ( P 1 ) → � err ,[],[2] � 2 P 4 = inc ( P 2 ) → � 1,1,1 � P 5 = isEmpty ( P 1 ) → � T,F,F � 10

  43. Ex: Forward Search 2 Programs of size 1: 1 P 1 = i → � [],[2],[1,2] � → � 1 P 2 = zero → � 0,0,0 � → � � Programs of size 2: P 3 = tail ( P 1 ) → � err ,[],[2] � 2 P 4 = inc ( P 2 ) → � 1,1,1 � P 5 = isEmpty ( P 1 ) → � T,F,F � Satisfies one of our goals 10

  44. Ex: Conditional Inference 2 2 → � � 4 P 5 = isEmpty ( P 1 ) → � T,F,F � goal � 0,1,2 � P r cond then else � T,F,F � � 0,?,? � � ?,1,2 � P 2 11

  45. Ex: Conditional Inference 2 2 → � � 4 P 5 = isEmpty ( P 1 ) → � T,F,F � goal � 0,1,2 � P r cond then else � T,F,F � � 0,?,? � � ?,1,2 � � P 2 P 5 11

  46. Ex: Conditional Inference 2 2 → � � 4 P 5 = isEmpty ( P 1 ) → � T,F,F � goal � 0,1,2 � � if ( ) � � � P 5 P 2 P r else ... cond then else � T,F,F � � 0,?,? � � ?,1,2 � � P 2 P 5 11

  47. Ex: Forward Search 3 Programs of size 2 → � � P 3 = tail ( P 1 ) → � err ,[],[2] � ... 12

  48. Ex: Forward Search 3 → � � Programs of size 2 P 3 = tail ( P 1 ) → � err ,[],[2] � ... → � � Programs of size 3 3 P 6 = length ( P 3 ) → � err ,0,1 � 12

  49. Ex: Forward Search 3 → � � Programs of size 2 P 3 = tail ( P 1 ) → � err ,[],[2] � ... → � � Programs of size 3 3 P 6 = length ( P 3 ) → � err ,0,1 � Use I/O values to simulate recursive call 12

  50. Ex: Forward Search 3 → � � Programs of size 2 P 3 = tail ( P 1 ) → � err ,[],[2] � ... → � � Programs of size 3 3 P 6 = length ( P 3 ) → � err ,0,1 � Use I/O values to simulate recursive call 12

  51. Ex: Forward Search 3 → � � Programs of size 2 P 3 = tail ( P 1 ) → � err ,[],[2] � ... → � � Programs of size 3 3 P 6 = length ( P 3 ) → � err ,0,1 � Use I/O values to simulate recursive call 12

  52. Ex: Forward Search 3 → � � Programs of size 2 P 3 = tail ( P 1 ) → � err ,[],[2] � ... → � � Programs of size 3 3 P 6 = length ( P 3 ) → � err ,0,1 � Use I/O values to simulate recursive call 12

  53. Ex: Forward Search 3 → � � Programs of size 2 P 3 = tail ( P 1 ) → � err ,[],[2] � ... → � � Programs of size 3 3 P 6 = length ( P 3 ) → � err ,0,1 � Use I/O values to simulate recursive call Only allow calls satisfying well-founded relation 12

  54. Ex: Forward Search 3 → � � Programs of size 2 P 3 = tail ( P 1 ) → � err ,[],[2] � But what if there isn’t ... such an I/O pair? → � � Programs of size 3 3 P 6 = length ( P 3 ) → � err ,0,1 � Query the user for new examples! Use I/O values to simulate recursive call (too long for 15 min talk) Only allow calls satisfying well-founded relation 12

  55. Ex: Conditional Inference One iteration later: goal � 0,1,2 � P r cond then else � T,F,F � � 0,?,? � � ?,1,2 � � P 5 P 2 inc(length(tail(i))) P 8 13

  56. Ex: Conditional Inference One iteration later: goal � 0,1,2 � P r cond then else � T,F,F � � 0,?,? � � ?,1,2 � � P 5 P 2 inc(length(tail(i))) P 8 13

Recommend


More recommend