Program Synthesis Tikhon Jelvis (tikhon@jelv.is) February 24, 2014 - - PowerPoint PPT Presentation

program synthesis
SMART_READER_LITE
LIVE PREVIEW

Program Synthesis Tikhon Jelvis (tikhon@jelv.is) February 24, 2014 - - PowerPoint PPT Presentation

Program Synthesis Tikhon Jelvis (tikhon@jelv.is) February 24, 2014 Synthesis Find a program to some specification ( ( input , output ) ) input/output pairs executable specification P x . ( x , P ( x )) Why? easy


slide-1
SLIDE 1

Program Synthesis

Tikhon Jelvis (tikhon@jelv.is) February 24, 2014

slide-2
SLIDE 2

Synthesis

◮ Find a program to some specification (φ(input, output))

◮ input/output pairs ◮ executable specification

◮ ∃P∀x.φ(x, P(x))

slide-3
SLIDE 3

Why?

◮ easy

◮ spec might be easier than program

◮ correct

◮ verifying spec easier than verifying program

slide-4
SLIDE 4

Compilers

◮ compilers are deterministic ◮ only consider correct optimizations ◮ hard to write

slide-5
SLIDE 5

Synthesizer

◮ can be non-deterministic ◮ considers potentially incorrect optimizations ◮ hard to scale ◮ accept partial specifications

slide-6
SLIDE 6

Programming by Demonstration

◮ user provides inputs/outputs ◮ generate program to match ◮ interactive

slide-7
SLIDE 7

Example

First Last Initials John Doe Bob Smith Tikhon Jelvis . . . . . .

slide-8
SLIDE 8

Example

First Last Initials John Doe

  • J. D.

Bob Smith Tikhon Jelvis . . . . . .

slide-9
SLIDE 9

Example

First Last Initials John Doe

  • J. D.

Bob Smith

  • B. S.

Tikhon Jelvis

  • T. J.

. . . . . . . . .

slide-10
SLIDE 10

Spec

◮ One input/output:

◮ “John” “Doe” → “J. D.”

◮ Usually only a few needed ◮ Interactive

slide-11
SLIDE 11

Small Language

◮ Targets a custom language ◮ Heavily limits looping ◮ Much smaller space of possible programs

slide-12
SLIDE 12

Rough Approach

◮ Uses Version Space Algebra (VSA) ◮ “Space” of possible programs

◮ inputs/outputs trim space

◮ Haskell package: HaVSA

slide-13
SLIDE 13

Superoptimization

◮ optimize existing program

◮ synthesize equivalent program

◮ much easier to implement ◮ limited scalability

slide-14
SLIDE 14

Example

◮ GreenArrays

◮ stack-based architecture ◮ uses Forth ◮ difficult to use

◮ Haskell package: array-forth

slide-15
SLIDE 15

MCMC

◮ Markov Chain Monte Carlo (MCMC) ◮ randomized hill climbing

◮ random mutations ◮ incorrect code

◮ Haskell package: mcmc-synthesis (limited) ◮ needs cluster

slide-16
SLIDE 16

SMT

◮ SMT: SAT modulo theories ◮ Solve logic formulas ◮ reasonably fast

slide-17
SLIDE 17

Formulas

◮ compile program to formula ◮ φ(input, program, output)

◮ fix input, program: interpreter ◮ fix program, output: reverse interpreter ◮ non-deterministic ◮ fix input, output: synthesis

slide-18
SLIDE 18

Verification

◮ compare two programs exhaustively ◮ problem: ∀input.spec(input) = program(input) ◮ actual: ∃input.spec(input) = program(input)

slide-19
SLIDE 19

CEGIS

◮ Counter-example guided inductive synthesis (CEGIS) ◮ solve for program

◮ limited set of inputs/outputs

◮ verify against spec

◮ if verified: done ◮ else: new input/output pair; repeat

◮ few pairs needed

slide-20
SLIDE 20

Scaling (or not)

◮ formulas are hard to scale ◮ exponential in program size ◮ maybe 100 instructions

◮ with luck ◮ if you’re patient

slide-21
SLIDE 21

Sketching

◮ some things are easy for programmers ◮ some things are easy for solvers ◮ let programmers write the easy parts! ◮ specify a program with “holes” and solve for the holes

slide-22
SLIDE 22

SBV

◮ SMT-based verification (sbv) ◮ Haskell package for SMT solvers ◮ write symbolic Haskell program

◮ prove facts about it ◮ solve for variables ◮ synthesis!

slide-23
SLIDE 23

Credit

◮ Most of the presentation heavily influenced by:

◮ Professor Bodik at the Berkeley ParLab ◮ Especially slides from his class on synthesis

◮ Programming by example:

◮ Flash Fill, a team at MSR led by Sumit Gulwani

◮ GreenArrays:

◮ Based on a synthesis project I worked on along with Professor

Bodik, Mangpo, Rohin Shah and Nishant Totla

◮ MCMC-synthesis:

◮ Based on a side-project around GreenArrays that I worked on

with Jessica Taylor