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

recursive program synthesis
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Recursive Program Synthesis

Aws Albarghouthi (UToronto), Sumit Gulwani (MSR), and Zachary Kincaid (UToronto) CAV 2013 Saint Petersburg, Russia

slide-2
SLIDE 2

Program Synthesis

2

Magic

Specification Program

slide-3
SLIDE 3

Program Synthesis

2

Magic

Specification Program

slide-4
SLIDE 4

What are your Dreams?

3

Magic

Specification Program

slide-5
SLIDE 5

What are your Dreams?

3

Magic

Specification Program First-order Logic

slide-6
SLIDE 6

What are your Dreams?

3

Magic

Specification Program First-order Logic Temporal Logic

slide-7
SLIDE 7

What are your Dreams?

3

Magic

Program First-order Logic Temporal Logic I/O Examples

slide-8
SLIDE 8

Why Synthesis from I/O?

I/O examples are easy to specify

4

slide-9
SLIDE 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

slide-10
SLIDE 10

Contribution

5

Escher

I/O Examples Recursive Program

slide-11
SLIDE 11

Contribution

5

Escher

I/O Examples Recursive Program User

slide-12
SLIDE 12

Contribution

5

Escher

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

slide-13
SLIDE 13

Contribution

5

Escher

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

slide-14
SLIDE 14

Contribution

5

Escher

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

slide-15
SLIDE 15

High Level View

6

Forward Search

slide-16
SLIDE 16

High Level View

6

Forward Search

I1 In . . .

slide-17
SLIDE 17

High Level View

6

Forward Search

I1 In . . .

  • O1. . .On
slide-18
SLIDE 18

High Level View

6

Forward Search

I1 In . . .

  • O1. . .On

P1 Pn . . .

slide-19
SLIDE 19

High Level View

6

Forward Search Conditional Inference

I1 In . . .

  • O1. . .On

P1 Pn . . . I1 O1

+

I2 O2

P1 P2

slide-20
SLIDE 20

High Level View

6

Forward Search Conditional Inference

I1 In . . .

  • O1. . .On

P1 Pn . . . I1 O1

+

I2 O2

P1 P2

= if ( ) else

C

P1

P2

slide-21
SLIDE 21

High Level View

6

Forward Search Conditional Inference

I1 In . . .

  • O1. . .On

P1 Pn . . . I1 O1

+

I2 O2

P1 P2

= if ( ) else

C

P1

P2

slide-22
SLIDE 22

High Level View

6

Forward Search Conditional Inference

I1 In . . .

  • O1. . .On

P1 Pn . . . I1 O1

+

I2 O2

P1 P2

= if ( ) else

C

P1

P2

Recursive call synthesis Reuse I/O as recursive call specification or query user

slide-23
SLIDE 23

Example

Synthesize list length from examples:

7

slide-24
SLIDE 24

Example

Synthesize list length from examples:

7

→ [],[2],[1,2]

Inputs:

slide-25
SLIDE 25

Example

Synthesize list length from examples:

7

→ [],[2],[1,2]

Inputs:

0,1,2

Outputs:

slide-26
SLIDE 26

Ex: Forward Search

8

Components: inc, isEmpty, tail, zero

slide-27
SLIDE 27

Ex: Forward Search

8

Components: inc, isEmpty, tail, zero Programs of size 1:

slide-28
SLIDE 28

Ex: Forward Search

8

Components: inc, isEmpty, tail, zero Programs of size 1:

1 P1 = i → [],[2],[1,2]

slide-29
SLIDE 29

Ex: Forward Search

8

Components: inc, isEmpty, tail, zero Programs of size 1:

1 P1 = i → [],[2],[1,2]

1 → P2 = zero → 0,0,0

slide-30
SLIDE 30

Ex: Forward Search

8

Components: inc, isEmpty, tail, zero Programs of size 1:

1 P1 = i → [],[2],[1,2]

1 → P2 = zero → 0,0,0

matches output for first input Recall outputs

0,1,2

slide-31
SLIDE 31

Ex: Conditional Inference

1 → P2 = zero → 0,0,0 0,1,2

Outputs:

slide-32
SLIDE 32

Ex: Conditional Inference

1 → P2 = zero → 0,0,0 0,1,2

Outputs:

slide-33
SLIDE 33

Ex: Conditional Inference

Pr 0,1,2

T,F,F ?,1,2 0,?,?

cond then else goal

P2

Goal Graph (GG):

1 → P2 = zero → 0,0,0 0,1,2

Outputs:

slide-34
SLIDE 34

Ex: Conditional Inference

Pr 0,1,2

T,F,F ?,1,2 0,?,?

cond then else goal

P2

Goal Graph (GG):

1 → P2 = zero → 0,0,0 0,1,2

Outputs:

slide-35
SLIDE 35

Ex: Conditional Inference

Pr 0,1,2

T,F,F ?,1,2 0,?,?

cond then else goal

P2

AND node Goal Graph (GG):

1 → P2 = zero → 0,0,0 0,1,2

Outputs:

slide-36
SLIDE 36

Ex: Conditional Inference

Pr 0,1,2

T,F,F ?,1,2 0,?,?

cond then else goal

P2

AND node Goal Graph (GG):

1 → P2 = zero → 0,0,0 0,1,2

Outputs:

“Backward” search

slide-37
SLIDE 37

Ex: Forward Search 2

10

1 P1 = i → [],[2],[1,2]

1 → P2 = zero → 0,0,0

Programs of size 1:

slide-38
SLIDE 38

Ex: Forward Search 2

10

  • 2

P3 = tail(P1) → err,[],[2] P4 = inc(P2) → 1,1,1 P5 = isEmpty(P1) → T,F,F

1 P1 = i → [],[2],[1,2]

1 → P2 = zero → 0,0,0

Programs of size 1: Programs of size 2:

slide-39
SLIDE 39

Ex: Forward Search 2

10

  • 2

P3 = tail(P1) → err,[],[2] P4 = inc(P2) → 1,1,1 P5 = isEmpty(P1) → T,F,F

1 P1 = i → [],[2],[1,2]

1 → P2 = zero → 0,0,0

Programs of size 1: Programs of size 2:

slide-40
SLIDE 40

Ex: Forward Search 2

10

  • 2

P3 = tail(P1) → err,[],[2] P4 = inc(P2) → 1,1,1 P5 = isEmpty(P1) → T,F,F

1 P1 = i → [],[2],[1,2]

1 → P2 = zero → 0,0,0

Programs of size 1: Programs of size 2:

slide-41
SLIDE 41

Ex: Forward Search 2

10

  • 2

P3 = tail(P1) → err,[],[2] P4 = inc(P2) → 1,1,1 P5 = isEmpty(P1) → T,F,F

1 P1 = i → [],[2],[1,2]

1 → P2 = zero → 0,0,0

Programs of size 1: Programs of size 2:

slide-42
SLIDE 42

Ex: Forward Search 2

10

  • 2

P3 = tail(P1) → err,[],[2] P4 = inc(P2) → 1,1,1 P5 = isEmpty(P1) → T,F,F

1 P1 = i → [],[2],[1,2]

1 → P2 = zero → 0,0,0

Programs of size 1: Programs of size 2:

slide-43
SLIDE 43

Ex: Forward Search 2

10

  • 2

P3 = tail(P1) → err,[],[2] P4 = inc(P2) → 1,1,1 P5 = isEmpty(P1) → T,F,F

1 P1 = i → [],[2],[1,2]

1 → P2 = zero → 0,0,0

Programs of size 1: Programs of size 2: Satisfies one of our goals

slide-44
SLIDE 44

Ex: Conditional Inference 2

11

4 2 →

  • P5 = isEmpty(P1) → T,F,F

Pr 0,1,2

T,F,F ?,1,2 0,?,?

cond then else goal

P2

slide-45
SLIDE 45

Ex: Conditional Inference 2

11

4 2 →

  • P5 = isEmpty(P1) → T,F,F

Pr 0,1,2

T,F,F ?,1,2 0,?,?

cond then else goal

P2

  • P5
slide-46
SLIDE 46

Ex: Conditional Inference 2

11

4 2 →

  • P5 = isEmpty(P1) → T,F,F

Pr 0,1,2

T,F,F ?,1,2 0,?,?

cond then else goal

P2

  • P5

if ( ) else

  • P5
  • P2

...

slide-47
SLIDE 47

Ex: Forward Search 3

12

Programs of size 2 →

  • P3 = tail(P1) → err,[],[2]

...

slide-48
SLIDE 48

Ex: Forward Search 3

12

Programs of size 2 Programs of size 3

  • 3 P6 = length(P3) → err,0,1

  • P3 = tail(P1) → err,[],[2]

...

slide-49
SLIDE 49

Ex: Forward Search 3

12

Programs of size 2 Programs of size 3

  • 3 P6 = length(P3) → err,0,1

Use I/O values to simulate recursive call

  • P3 = tail(P1) → err,[],[2]

...

slide-50
SLIDE 50

Ex: Forward Search 3

12

Programs of size 2 Programs of size 3

  • 3 P6 = length(P3) → err,0,1

Use I/O values to simulate recursive call

  • P3 = tail(P1) → err,[],[2]

...

slide-51
SLIDE 51

Ex: Forward Search 3

12

Programs of size 2 Programs of size 3

  • 3 P6 = length(P3) → err,0,1

Use I/O values to simulate recursive call

  • P3 = tail(P1) → err,[],[2]

...

slide-52
SLIDE 52

Ex: Forward Search 3

12

Programs of size 2 Programs of size 3

  • 3 P6 = length(P3) → err,0,1

Use I/O values to simulate recursive call

  • P3 = tail(P1) → err,[],[2]

...

slide-53
SLIDE 53

Ex: Forward Search 3

12

Programs of size 2 Programs of size 3

  • 3 P6 = length(P3) → err,0,1

Use I/O values to simulate recursive call

  • P3 = tail(P1) → err,[],[2]

...

Only allow calls satisfying well-founded relation

slide-54
SLIDE 54

Ex: Forward Search 3

12

Programs of size 2 Programs of size 3

  • 3 P6 = length(P3) → err,0,1

Use I/O values to simulate recursive call

  • P3 = tail(P1) → err,[],[2]

...

Only allow calls satisfying well-founded relation

But what if there isn’t such an I/O pair? Query the user for new examples!

(too long for 15 min talk)

slide-55
SLIDE 55

Ex: Conditional Inference

13

Pr 0,1,2

T,F,F ?,1,2 0,?,?

cond then else goal

P2

One iteration later:

  • P5

inc(length(tail(i))) P8

slide-56
SLIDE 56

Ex: Conditional Inference

13

Pr 0,1,2

T,F,F ?,1,2 0,?,?

cond then else goal

P2

One iteration later:

  • P5

inc(length(tail(i))) P8

slide-57
SLIDE 57

Ex: Conditional Inference

13

Pr 0,1,2

T,F,F ?,1,2 0,?,?

cond then else goal

P2

One iteration later:

  • P5

inc(length(tail(i))) P8

if isEmpty(i) then 0 else inc(length(tail(i)))

P5 P8 P2

Synthesized program:

slide-58
SLIDE 58

Escher: Recap

Forward Search

  • Apply component to all synthesized programs
  • Heuristic-based search

14

slide-59
SLIDE 59

Escher: Recap

Forward Search

  • Apply component to all synthesized programs
  • Heuristic-based search

Conditional Inference

  • Uses goal graph to synthesize conditionals
  • Conditionals synthesized on demand

14

slide-60
SLIDE 60

Escher: Recap

Forward Search

  • Apply component to all synthesized programs
  • Heuristic-based search

Conditional Inference

  • Uses goal graph to synthesize conditionals
  • Conditionals synthesized on demand

Recursive call synthesis

  • Use I/O specification
  • Query user for more output values if needed

14

slide-61
SLIDE 61

Implementation

Prototype implementation of Escher

  • Pluggable components

Experimented with:

  • integer, list, and tree manipulating programs

15

slide-62
SLIDE 62

Experiments

16

Escher w/o

ObsEquiv w/o GoalGraph

w/o OE+GG

collect_leaves

0.04 0.09 68.9 81.8

count_leaves

0.06 0.2 9.3 12.3

hbal_tree

1.5 MEM TIME MEM

nodes_at_level 10.74 MEM

TIME MEM

(tree manipulating programs) Time in seconds

slide-63
SLIDE 63

Experiments

17

(#components sensitivity: mult)

Escher: 0.7s

with all components

slide-64
SLIDE 64

Experiments

17

(#components sensitivity: mult)

10 20 30 40 1 2 3 4 5

Sketch sensitivty

SAT-based synthesis [ASPLOS’06]

NUMBER OF EXTRA COMPONENTS T I M E ( S )

Escher: 0.7s

with all components

slide-65
SLIDE 65

Experiments

17

(#components sensitivity: mult)

10 20 30 40 1 2 3 4 5

Sketch sensitivty

SAT-based synthesis [ASPLOS’06]

NUMBER OF EXTRA COMPONENTS T I M E ( S )

Had to supply Sketch with high-level conditional

Escher: 0.7s

with all components

slide-66
SLIDE 66

Conclusion

18

Escher

I/O Examples Recursive Program User

slide-67
SLIDE 67

Conclusion

18

Escher

I/O Examples Recursive Program User Interactive

slide-68
SLIDE 68

Conclusion

18

Escher

I/O Examples Recursive Program User Interactive Highly-customizable

slide-69
SLIDE 69

Conclusion

18

Escher

I/O Examples Recursive Program User Interactive Highly-customizable Novel synthesis techniques

slide-70
SLIDE 70

Questions?

How can we synthesize loops?

19

slide-71
SLIDE 71

Questions?

How can we synthesize loops? Integration with SMT

  • based search

19

slide-72
SLIDE 72

Questions?

How can we synthesize loops? Integration with SMT

  • based search

Applications of Escher in eduction

  • e.g., for interacting with students

19

slide-73
SLIDE 73

Questions?

How can we synthesize loops? Integration with SMT

  • based search

Applications of Escher in eduction

  • e.g., for interacting with students

Theoretical under-pinnings

  • e.g., see Madhusudan [CSL’11]

19

slide-74
SLIDE 74

Thank You