Guarantees in Program Synthesis Qin inhepin ing Hu , Jason Breck , John Cyphert , Loris D'Antoni , Thomas Reps 1
(What you want your program to do) Program π Specification Synthesizer ( π satisfies the specification Search space π is in the search space) (candidate solutions) Not always enough!
Specification : β0 β€ π¦ < 100. π π¦ = π¦ + 1 Solution 1: Solution 2: return x+1; if (x=0) return 1; if (x=1) return 2; if (x=2) return 3; β¦ if (x=99) return 100; return β 1; 3
[PLDI17] Automatic Program Inversion 4
Gu Guarantees ntees in Program Synthesis Program π Specification Synthesizer Search space Quantitative objective Unrealizable (no solution) (ability to prefer better solutions)
Syntax-Guided Synthesis Program π Specification Synthesizer Search space Grammar: Logic formula: Start := Start+Start π π : βπ¦, π§. π β₯ π¦ β§ π β₯ π§ | ITE(BExpr,Start,Start) β§ (π = π¦ β¨ π = π§) | π¦ | π§ | 0 | 1 (i.e., π is max2) BExpr := NOT(BExpr) | Start > Start ITE( π¦ > π§ , ITE( π¦ > 0 , π¦ , π¦ ), π§ ) | Start AND Start (Linear terms with IfThenElse)
[CAV18] Syntax-Guided Synthesis + Quantitative objective Program π Specification Synthesizer Search space Quantitative objective (user assign costs to rules) Grammar: Logic formula: Start := Start+Start π π : βπ¦, π§. π β₯ π¦ β§ π β₯ π§ 0 | ITE(BExpr,Start,Start) 1 β§ (π = π¦ β¨ π = π§) 0 | π¦ | π§ | 0 | 1 BExpr := NOT(BExpr) 0 | Start > Start Quantitative objective: 0 | Start AND Start Minimize the number of ITE 0
QSyGuS Weighted grammar π Grammar π : Start := Start+Start 0 | ITE(BExpr,Start,Start) 1 0 | π¦ | π§ | 0 | 1 BExpr := NOT(BExpr) 0 | Start > Start 0 | Start AND Start 0 8
SyGuS QSyGuS ignore weight Weighted Grammar π» grammar π Grammar π» : Start := Start+Start | ITE(BExpr,Start,Start) | π¦ | π§ | 0 | 1 BExpr := NOT(BExpr) | Start > Start | Start AND Start 9
SyGuS QSyGuS Solutionβs weight π Weighted Grammar π» grammar π Grammar π» : Solution in π» : Start := Start+Start ITE( π¦ > π§ , ITE( π¦ > 0 , π¦ , π¦ ), π§ ) | ITE(BExpr,Start,Start) with weight 2 | π¦ | π§ | 0 | 1 2 ITE in the solution) (there are 2 BExpr := NOT(BExpr) | Start > Start | Start AND Start 10
SyGuS QSyGuS Solutionβs weight π Weighted Grammar π» CFG π» <2 grammar π Grammar π» <2 : Start := Start0 | Start1 BExpr0 := NOT(BExpr0) Start1 := Start1+Start0 | Start0 > Start0 | ITE(BExpr0,Start0,Start0) | Start0 AND Start0 | π¦ | π§ | 0 | 1 Start0 := Start1+Start0 | π¦ | π§ | 0 | 1 11
SyGuS QSyGuS Solutionβs Solutionβs weight π weight π Weighted Grammar π» CFG π» <2 grammar π Grammar π» <2 : Start := Start0 | Start1 BExpr0 := NOT(BExpr0) Start1 := Start1+Start0 | Start0 > Start0 | ITE(BExpr0,Start0,Start0) | Start0 AND Start0 | π¦ | π§ | 0 | 1 Solution in π» <2 : Start0 := Start1+Start0 ITE π¦ > π§, π¦, π§ | π¦ | π§ | 0 | 1 12
SyGuS QSyGuS Solutionβs Solutionβs weight π weight π Weighted Grammar π» CFG π» <2 CFG π» <1 ? grammar π Grammar π» <1 : Start := Start+Start | π¦ | π§ | 0 | 1 Solution π½ππΉ π¦ > π§, π¦, π§ is minimized There is no o so solution in π» <1 13
Program π Specification Synthesizer Search space Unrealizable Quantitative objective (no solution) Search-based synthesizer + infinite search space = Timeout! 14
[CAV19] Proving a SyGuS problem is unrealizable Grammar G <1 : Specification: π 0,0 = 0 β§ π 0,1 = 1 Start := Start+Start β§ π 1,0 = 1 β§ π 2,0 = 2 | π¦ | π§ | 0 | 1 int[4] Start(x_0,y_0,x_1,y_1,x_2,y_2,x_3,y_3){ if(??){return (0,0,0,0);} // Start -> 0 if(??){return (1,1,1,1);} // Start -> 1 if(??){return (x_0,x_1,x_2,x_3);} // Start -> x if(??){return (y_0,y_1,y_2,y_3);} // Start -> y else{ // Start -> Start+Start int[4] L = Start(x_0,y_0,x_1,y_1); int[4] R = Start(x_0,y_0,x_1,y_1); return (L[0]+R[0],L[1]+R[1],L[2]+R[2],L[3]+R[3]);} } int[4] P = Start(0,0,0,1,1,0,2,0); assert (P[0]!=0 || P[1]!=1 || P[2]!=1 || P[3]!=2);
The assertion always holds The SyGuS problem is unrealizable int[4] Start(x_0,y_0,x_1,y_1,x_2,y_2,x_3,y_3){ if(??){return (0,0,0,0);} // Start -> 0 if(??){return (1,1,1,1);} // Start -> 1 if(??){return (x_0,x_1,x_2,x_3);} // Start -> x if(??){return (y_0,y_1,y_2,y_3);} // Start -> y else{ // Start -> Start+Start int[4] L = Start(x_0,y_0,x_1,y_1); int[4] R = Start(x_0,y_0,x_1,y_1); return (L[0]+R[0],L[1]+R[1],L[2]+R[2],L[3]+R[3]);} } int[4] P = Start(0,0,0,1,1,0,2,0); assert (P[0]!=0 || P[1]!=1 || P[2]!=1 || P[3]!=2);
Gu Guarantees ntees in Program Synthesis Program π Specification Synthesizer Search space Unrealizable Quantitative objective Proving unrealizability beyond SyGuS More quantitative objectives β’ Semantic quantitative objectives β’ Resource bounded synthesis
Recommend
More recommend