Scalable Synthesis with Symbolic Syntax Graphs Rohin Shah, Sumith - - PowerPoint PPT Presentation

scalable synthesis with symbolic syntax graphs
SMART_READER_LITE
LIVE PREVIEW

Scalable Synthesis with Symbolic Syntax Graphs Rohin Shah, Sumith - - PowerPoint PPT Presentation

Scalable Synthesis with Symbolic Syntax Graphs Rohin Shah, Sumith Kulal , Ras Bodik UC Berkeley, IIT Bombay and UW 18 July 2018, Oxford UK [Solar-Lezama et al. ASPLOS06] Combinatorial Sketching for Finite Programs Sketching also promises to


slide-1
SLIDE 1

Scalable Synthesis with Symbolic Syntax Graphs

Rohin Shah, Sumith Kulal, Ras Bodik 18 July 2018, Oxford UK UC Berkeley, IIT Bombay and UW

slide-2
SLIDE 2

Sketching also promises to enable complex implementations that may be too tedious to develop and maintain without automatic synthesis of low-level detail.

2

… but what if the synthesis is too tedious itself? [Solar-Lezama et al. ASPLOS06] Combinatorial Sketching for Finite Programs

slide-3
SLIDE 3

Let’s dive right in

Given a new domain, how does one synthesize programs in it?

1

3

slide-4
SLIDE 4

IN ORDER OF DECREASING EFFORT Specialize a generic meta-algorithm with domain specific operators Leverage an existing framework that provides a general-purpose synthesis algorithm Build a new algorithm from scratch

4

Using an existing framework means carefully constructing your grammar

slide-5
SLIDE 5

A novel algorithm that automatically constructs symbolic syntax graphs from specified components enforcing constraints like type safety, etc.

IN THIS PAPER, WE PRESENT

A case study where we implement a system for synthesizing incremental

  • perations on

data-structures

5

slide-6
SLIDE 6

Let’s look at an example

Consider the problem of incrementally maintaining inverse of a permutation

2

6

slide-7
SLIDE 7

3 2 5 7 0 1 4 6 0 1 2 3 4 5 6 7

HOW DO WE DEFINE THE INVERSE GIVEN A PERMUTATION?

7

4 5 1 0 6 2 7 3 0 1 2 3 4 5 6 7 inverse indices permutation indices

slide-8
SLIDE 8

WE NEED TO SYNTHESIZE A FIX FOR INVERSE GIVEN TRANSPOSE

8

(define (transpose! i j) (define tmp (vector-ref perm i)) (vector-set! perm i (vector-ref perm j)) (vector-set! perm j tmp))

How do we synthesize (fix-inverse! i j)?

slide-9
SLIDE 9

Let’s incrementally construct grammars

We are trying to synthesize (fix-inverse! i j) function

3

9

slide-10
SLIDE 10

EASIEST GRAMMAR TO START OFF WITH

10

E -> bin-proc E E | tern-proc E E E | atom bin-proc -> begin | vec-ref | + | - tern-proc -> vec-set! atom -> variable | constant problem? Yes, please! Leads to bad programs like (vec-ref 3 3)

slide-11
SLIDE 11

LET’S FIX THE TYPES IN THIS GRAMMAR

11

E -> int-gen | vec-gen | void-stmt int-gen -> vec-ref vec-gen int-gen | +/- int-gen int-gen | int-atom vec-gen -> vec-atom

problem? Yes, please! Can undo your initial operation (next slide)

void-stmt -> vec-set! vec-gen int-gen int-gen int-atom -> int-var | int-const vec-atom -> vec-var | vec-const

slide-12
SLIDE 12

THE GRAMMAR CAN SYNTHESIZE THE FOLLOWING

12

Need to encode which variables are mutable => more production rules

(define (fix-inverse! i j) (define tmp (vector-ref perm j)) (vector-set! perm j (vector-ref perm i)) (vector-set! perm i tmp))

slide-13
SLIDE 13

Sharing subgraphs It may be possible to encode the symbolic syntax graph in fewer boolean variables make it easier for the SMT solver. Straight-Line Grammar Encodes programs in a straight-line format instead of the typical bushy- tree format, which gives an inductive bias towards realistic programs. Extensibility Makes it easy to add new

  • perators. Just

describe the type signature of the component.

13

SEVERAL OPTIMIZATION ON TOP CONSTRUCTING THE RIGHT GRAMMAR

slide-14
SLIDE 14

CHECKPOINT

Manual constructing high-performant grammars is tedious error-prone task, we automate it!

14

slide-15
SLIDE 15

OUR SSG CONSTRUCTION ALGORITHM: CREATE-SSG(F, V, C, d)

15

F -> is a list of components C -> is a list of constraints (type, mutability, etc.) V -> is a list of terminals d -> is a maximum depth of the SSG Intuition: Choose from components and terminals according to the constraints, recursively construct SSG for children till depth by passing appropriate constraints down!

slide-16
SLIDE 16

LET’S EXPLORE THE CORRECT BRANCH OF PERMUTATION

16

CREATE-SSG( F -> begin, vec-ref, vec-set!, +, -, V -> inverse (mutable), perm, i, j (immutable), C -> type-void, F, d -> 3)

void, F begin vec-set!

depth 3

slide-17
SLIDE 17

LET’S EXPLORE BEGIN BRANCH OF THE SSG

17

begin: void, F -> void, F -> void, F

void, F begin vec-set! void, F void, F begin vec-set! begin vec-set!

depth 3 depth 2

slide-18
SLIDE 18

LET’S EXPLORE VEC-SET! BRANCH OF THE SSG

18

vec-set!: vec[int], T -> int, F -> int, F -> void, F

vec-set! void, F begin vec[int],T int, F int, F inverse vec-ref i j +

  • depth 2

depth 1

slide-19
SLIDE 19

LET’S EXPLORE VEC-REF! BRANCH OF THE SSG

19

vec-ref: vec[int], F -> int, F -> int, F

vec-ref int, F + vec[int],F int, F inverse i j

depth 1 depth 0

perm

slide-20
SLIDE 20

TAKEAWAYS

  • Assume components are annotated with type

signatures and mutability requirements

  • Generate a symbolic syntax graph top-down.
  • Use component information to recursively pass

down type and mutability constraints

  • Share subtrees where possible
  • Generate straight-line programs instead of

bushy ones

20

slide-21
SLIDE 21

EXAMPLE OF SHARING SUBGRAPHS WHENEVER POSSIBLE

21

vec-ref int, F + vec[int],F int, F int, F i j

  • i

j

slide-22
SLIDE 22

CHECKPOINT

We have presented a novel algorithm to construct symbolic syntax trees. Now we present our evaluation.

22

slide-23
SLIDE 23

We present a case study: SyncrO

SyncrO is a synthesizer for automatic incrementalization of programs built with the help of the above algorithm.

1

23

slide-24
SLIDE 24

3 2 5 7 0 1 4 6 0 1 2 3 4 5 6 7

INCREMENTALLY MAINTAINING INVERSE GIVEN PERMUTATION CHANGES

24

4 5 1 0 6 2 7 3 0 1 2 3 4 5 6 7 3 2 5 1 0 7 4 6 0 1 2 3 4 5 6 7 4 3 1 0 6 2 7 5 0 1 2 3 4 5 6 7 P ΔI ?

slide-25
SLIDE 25

Numbers

Let’s now have a look at the numbers we obtained

2

25

slide-26
SLIDE 26

THE SUITE OF EXPRESSION SYNTHESIS BENCHMARKS Benchmark |Sol| |LSpace| |TSpace| Time(s) Skosette 10 2^18 2^13 0.2 Permutation 16 2^39 2^28 0.3 Exists 50 2^72 2^80 0.6 Count change 26 2^75 2^395 2685.1 Edit distance 51 2^525 2^7022 TO

26

slide-27
SLIDE 27

Times taken (relative) to solve the expression synthesis benchmarks

27

slide-28
SLIDE 28

Times taken (relative) by variants of our algorithm

28

slide-29
SLIDE 29

Thanks!

ANY QUESTIONS?

You can find me at @sumith1896 sumith@stanford.edu

29

slide-30
SLIDE 30

CREDITS

Special thanks to all the people who made and released these awesome resources for free:

  • Presentation template by SlidesCarnival
  • Photographs by Unsplash

30