Sumit Gulwani sumitgmicrosoftcom Microsoft Research Redmond August 2013 Marktoberdorf Summer School Lectures Part 1 1 Synthesis Goal Synthesize a computational concept in some underlying language ID: 621829
Download Presentation The PPT/PDF document "From Verification to Synthesis" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
From Verification to Synthesis
Sumit Gulwani
sumitg@microsoft.com
Microsoft Research, Redmond
August 2013
Marktoberdorf
Summer School Lectures: Part 1Slide2
1
Synthesis
Goal:
Synthesize a computational concept in some
underlying language
from
user intent
using some
search technique
.
State of the art:
We can synthesize programs of size 10-20.Slide3
LanguagePrograms
Straight-line programsAutomataQueries
User IntentLogic, Natural LanguageExamples, Demonstrations/TracesProgram
Search TechniqueSAT/SMT solvers (Formal Methods)A*-style goal-directed search (AI)Version space algebras (Machine Learning)2Dimensions in Synthesis
PPDP 2010: “Dimensions in Program Synthesis”, Gulwani.
(Application)
(Ambiguity)
(Algorithm)Slide4
3
Compilers vs. Synthesizers
Dimension
Compilers SynthesizersConcept LanguageExecutable ProgramVariety of concepts: Program, Automata, Query, Sequence
User Intent
Structured
language
Variety
/
mixed
form of constraints: logic, examples, traces
Search Technique
Syntax-directed
translation (No new algorithmic insights)Uses some kind of search (Discovers new algorithmic insights)Slide5
From verification to synthesis
Bitvector algorithms (PLDI 2011, ICSE 2012)General loopy programs (POPL 2010)
SIMD algorithms (PPoPP 2013)Program inverses (PLDI 2011)Graph algorithms (OOPSLA
2010)End-user Programming (Examples & Natural Language)Syntactic string transformations: Flash Fill (POPL 2011)Semantic string transformations (VLDB 2012)Table layout transformations (PLDI 2011)Smartphone scripts (MobiSys 2013)Computer-aided Education
Problem Synthesis (AAAI 2012, CHI 2013)
Solution Synthesis (PLDI 2011, IJCAI 2013)
Feedback Synthesis (PLDI 2013, IJCAI 2013)
Content Authoring (CHI 2012)
4Slide6
Application
Generatin
g Synthesis ConstraintSolving Synthesis Constraint
BitvectorLocation variablesCEGIS + SMTLoopy Alg.
Template-based
SMT
SIMD
Relational verification
CEGIS +
Reachability
value graph
Inverses
Template-based
+ symbolic execution
SMT
Graph Alg.
From Verification to Synthesis
5
Reference:
Path-based Inductive Synthesis for Program
Inversion,
PLDI 2011, Srivastava, Gulwani, Chaudhuri, FosterSlide7
Language
Programs
Straight-line programs
Automata
Queries
User Intent
Logic, Natural Language
Examples, Demonstrations/Traces
Program
Search Technique
SAT/SMT solvers (Formal Methods)
A*-style goal-directed search (AI
)
Version
space algebras (Machine Learning)
6
Dimensions in SynthesisSlide8
In-place run-length encoding:
A = [1,1,1,0,0,2,2,2,2]
Encoder A=[1,0,2] N=[3,2,4]
DecoderA’=[1,1,1,0,0,2,2,2,2]Program Inversion: Example7
IN(
A,n
); Assume (n >= 0)
i
, m := 0, 0; // parallel assignment
while (
i
<n)
r := 1;
while (i+1<n && A[
i
]=A[i+1])
r,
i := r+1, i+1;
A[m], N[m], m,
i := A[
i
], r, m+1, i+1;
OUT(
A,N,m
);
IN(
A,N,m
)
i
’, m’ :=
0
, 0; while (m’ < m) r’ := N[m’]; while (r’>0) r’,i’, A’[i’] := r’-1, i’+1, A[m’]; m’ := m’+1;OUT(A’,m’); assert(A’=A; m’=n);Slide9
In-place run-length encoding:
A = [1,1,1,0,0,2,2,2,2]
Encoder A=[1,0,2] N=[3,2,4]
DecoderA’=[1,1,1,0,0,2,2,2,2]Program Inversion as Synthesis Problem8
IN(
A,n
); Assume (n >= 0)
i
, m := 0, 0; // parallel assignment
while (
i
<n)
r := 1;
while (i+1<n && A[
i
]=A[i+1])
r,
i := r+1, i+1;
A[m], N[m], m,
i := A[
i
], r, m+1, i+1;
OUT(
A,N,m
);
IN(
A,N,m
)
i’, m’ :=
e
1
, e2; // ei Ewhile (p1) // pi P r’ := e
3; while (p2) r’,i’, A’[e
4
] :=
e
5
,
e6, e7; m’ := e8;OUT(A’,m’); Assert(A’=A; m’=n);
E = { 0, 1, m’
1, r’
1, i’1, A[i’], A[m’], N[m’] }P = { m’<m, r’>0, A’[i’]= A’[i’+1] }
Slide10
I
nductive invariant required to establish correctness are too sophisticated.We use symbolic execution to generate verification condition for correctness on certain paths in the original and the inverted program.
This generates constraints of the form
Synthesis Technique
9Slide11
Reference:
Program Synthesis by Sketching, Phd Thesis 2008,
Armando Solar-Lezama (Advisor: Ras
Bodik @ UC-Berkeley)Key Ideas: Write an arbitrary program with holes, where each hole takes values from a finite domain. Use CEGIS to generate SAT constraints on holes. Cons: Not as efficient as domain-specific synthesizers.(On bitvector benchmark, times out on 9/25 tasks, and on the remaining it is slower by 20x on average).
Pros:
A very powerful formalism that can be used to model a variety of synthesis problems.
Sees synthesis as an interactive process.
Related Work: Program Sketching
10