The Second Competition on Syntax-Guided Synthesis Rajeev Alur, Dana Fisman, Rishabh Singh and Armando Solar-Lezama
Talk Outline Introduction Motivation: recent trends in program synthesis The big picture Formalization of Syntax-Guided Synthesis SyGuS- COMP’15 Tracks Solution Strategies Presentations by Solvers’ authors SyGuS- COMP’15 Benchmarks SyGuS- COMP’15 Competition Results
Program Synthesis Specification S High Level “WHAT” Synthesizer Program P Low Level “HOW”
New Trends in Synthesis Syntactic restrictions Specification S Specification S R on the High Level High Level solutions domain “WHAT” “WHAT” Use at most two of each of the following Turn off rightmost operators: continuous 1 bits: &&, <<, … 1010110 -> 1010000 Synthesizer Program P Low Level “HOW”
New Trends in Synthesis Syntactic Specification restrictions R S Motivation: Synthesizer Tractability Combine Program P human expert insights with computers exhaustiveness & rapidness Benefit progress SAT & SMT Solvers
Ex 1. Parallel Parking By Sketching The challenge Structure Err = 0.0; is finding the of the for(t = 0; t<T; t+=dT){ if(stage==STRAIGHT){ parameters program is // (1) Backup straight if(t > ??) stage= INTURN; known } When to 1 // (2) Turn if(stage==INTURN){ start car.ang = car.ang - ??; turning? if(t > ??) stage= OUTTURN; } How much to if(stage==OUTTURN){ // (3) Straighten turn? 2 car.ang = car.ang + ??; if(t > ??) break; } simulate_car(car); Err += check_collision(car); } 3 Err += check_destination(car); [Chaudhuri & Solar-Lezama PLDI 2010]
Ex 2. Optimizing Multiplications Superoptimizing Compiler Given a program P , find a “better” equivalent program P ’ . multiply (x[1,n], y[1,n]) { x1 = x[1,n/2]; x2 = x[n/2+1, n]; y1 = y[1, n/2]; y2 = y[n/2+1, n]; a = x1 * y1; a = x1 * y1; a Replace with equivalent code b = shift( x1 * y2, n/2); b = shift( x1 * y2, n/2); c = shift( x2 * y1, n/2); c = shift( x2 * y1, n/2); with only 3 multiplications d = shift( x2 * y2, n); d = shift( x2 * y2, n); return ( a + b + c + d) }
Automatic Ex 3. Template-Based Invariant Generation Given a program P and a SelecionSort(int A[],n) { i1 :=0; post condition S, while(i1 < n−1) { Invariant: ??? Find invariants I 1 , I 2 v1 := i1; i2 := i1 + 1; with which we can prove while (i2 < n) { Invariant: ??? if (A[i2]<A[v1]) program is correct v1 := i2 ; i2++; } swap(A[i1], A[v1]); i1++; } return A; } post: ∀ k : 0 ≤ k <n ⇒ A[k] ≤ A[k+1]
Ex 3. Template-Based Invariant Generation Given a program P and a SelecionSort(int A[],n) { i1 :=0; post condition S Invariant: while(i1 < n−1) { ∀ k1,k2. ??? ∧ ??? Find invariants I 1 , I 2 , … I k v1 := i1; i2 := i1 + 1; with which we can prove Invariant: while (i2 < n) { program is correct ??? ∧ ??? ∧ if (A[i2]<A[v1]) ( ∀ k1,k2. ??? ∧ ???) ∧ v1 := i2 ; ( ∀ k. ??? ∧ ?) i2++; } swap(A[i1], A[v1]); i1++; Constraint } Solver return A; } post: ∀ k : 0 ≤ k <n ⇒ A[k] ≤ A[k+1]
Syntax-Guided Program Synthesis Common theme to many recent efforts j R Sketch (Bodik, Solar-Lezama et al) FlashFill (Gulwani et al) Super-optimization (Schkufza et al) Synthesizer Invariant generation (Many recent efforts…) TRANSIT for protocol synthesis (Udupa et al) P Oracle-guided program synthesis (Jha et al) Implicit programming: Scala^Z3 (Kuncak et al) Auto-grader (Singh et al) Program Sketching Invariant Program Generation Programming But no way to have Optimization by examples a generic solver for all
Talk Outline Introduction Motivation: recent trends in program synthesis The big picture Formalization of Syntax-Guided Synthesis SyGuS- COMP’15 Tracks and Solvers Solution Strategies Presentations by Solvers’ authors SyGuS- COMP’15 Benchmarks SyGuS- COMP’15 Competition Results
Slide adopted from a The Big Picture presentation of Viktor Kuncak Does prog P Given list i always sorts is P(i) sorted? correctly? Assertion Checking: Program Verification: Given Prog P overall i: P(i) |= S(i) ? correctness P(i) |= S(i) ? Spec S partial/ intermediate Given Constraint Programming: Program Synthesis : only Spec S Find P: i: P(i) |= S(i) Find o: o |= S(i) Given list i, Return a sorting return it sorted Compiletime Runtime program P
The Big Picture Given Assertion Checking: Program Verification: Prog P i: P(i) |= S(i) ? P(i) |= S(i) ? Spec S Return a program P Given Constraint Programming: Program Synthesis : implementing turnoff only rightmost 1’s o: o |= S(i) P: i: P(i) |= S(i) Spec S Return a program P Syntax-Guided Synthesis : implementing turnoff rightmost 1’s using only P R : i: P(i) |= S(i) so and so operators
From Satisfiability to Synthesis : Recent trends in program synthesis: i: P(i) |= S(i) ? P(i) |= S(i) ? P: i: P(i) |= S(i) o: o |= S(i) Problem P R : i: P(i) |= S(i) (verif/synth nature) Syntactic Restrictions on solution domain SAT/SMT Solver
SyGuS – The Vision Programming Program Invariant Program ????? by examples Generation Sketching Optimization SyGuS IF Generic Solvers Benchmark + Compare + Compete => Boost improvement
Talk Outline Introduction Motivation: recent trends in program synthesis The big picture Formalization of Syntax-Guided Synthesis SyGuS- COMP’15 Tracks Solution Strategies Presentations by Solvers’ authors SyGuS- COMP’15 Benchmarks SyGuS- COMP’15 Competition Results
Syntax-Guided Synthesis (SyGuS) Problem Theory T Fix a background theory T: fixes types and operations 0 + j f G Function to be synthesized: name f along with its type t 1 Grammar General case: multiple functions to be synthesized Synthesizer Inputs to SyGuS problem: f 1 P Specification j f f 2 Typed formula using symbols in T + symbol f Context-free grammar G Characterizing the set of allowed expressions G (in theory T) Computational problem: Find expression e in G such that j [f/e] is valid (in theory T)
SyGuS – formalization example (set-logic LIA) Background theory Name and type of the function (synth-fun max2 ((x Int) (y Int)) Int to be ((Start Int (x y 0 1 synthesized (+ Start Start) (- Start Start) Grammar (ite StartBool Start Start))) describing (StartBool Bool ((and StartBool StartBool) the syntactic restrictions (or StartBool StartBool) (not StartBool) (<= Start Start)))) (declare-var x Int) Semantic (declare-var y Int) restrictions (constraint (>= (max2 x y) x)) (correctness (constraint (>= (max2 x y) y)) criteria) (constraint (or (= x (max2 x y)) (= y (max2 x y)))) (check-synth)
Talk Outline Introduction Recent trends in program synthesis (the problem) The big picture Formalization of Syntax-Guided Synthesis SyGuS- COMP’15 tracks Solution Strategies Benchmarks Competition Results
SyGuS- COMP’15 Tracks General Track Background theory LIA or BV Arbitrary grammar (as defined in the benchmark) Linear Integer ArithmeticTrack Background theory LIA No grammar restrictions (any LIA expression is allowed) Invariant Synthesis Track Background theory LIA No grammar restrictions Special constructs to describe invariant synthesis (pre-condition, transition, post-condition)
SyGuS LIA track example (set-logic LIA) ) (synth-fun max2 ((x Int) (y Int)) Int ((Start Int (x y 0 1 (+ Start Start) (- Start Start) Grammar (ite StartBool Start Start))) describing (StartBool Bool ((and StartBool StartBool) the syntactic restrictions (or StartBool StartBool) (not StartBool) (<= Start Start)))) (declare-var x Int) (declare-var y Int) (constraint (>= (max2 x y) x)) (constraint (>= (max2 x y) y)) (constraint (or (= x (max2 x y)) (= y (max2 x y)))) (check-synth)
SyGuS- COMP’15 Tracks General Track Background theory LIA or BV Arbitrary grammar (as defined in the benchmark) Linear Integer ArithmeticTrack Background theory LIA No grammar restrictions (any LIA expression is allowed) Invariant Synthesis Track Background theory LIA No grammar restrictions Special constructs to describe invariant synthesis (pre-condition, transition, post-condition)
SyGuS Inv track example (set-logic LIA) (synth-inv inv-f ((x Int) (y Int) (b Bool))) (declare-primed-var b Bool) (declare-primed-var x Int) (declare-primed-var y Int) (define-fun pre-f ((x Int) (y Int) (b Bool)) Bool (and (and (>= x 5) (<= x 9)) (and (>= y 1) (<= y 3)))) (define-fun trans-f ((x Int) (y Int) (b Bool) (x! Int) (y! Int) (b! Bool)) Bool (and (and (= b! b) (= y! x)) (ite b (= x! (+ x 10)) (= x! (+ x 12))))) (define-fun post-f ((x Int) (y Int) (b Bool)) Bool (< y x)) (inv-constraint inv-f pre-f trans-f post-f) (check-synth)
Recommend
More recommend