Programming by Examples

Slides:



Advertisements
Similar presentations
From Verification to Synthesis Sumit Gulwani Microsoft Research, Redmond August 2013 Marktoberdorf Summer School Lectures: Part 1.
Advertisements

FlashExtract : A General Framework for Data Extraction by Examples
Data Manipulation using Programming by Examples and Natural Language Invited Upenn April 2015 Sumit Gulwani.
ISBN Chapter 3 Describing Syntax and Semantics.
1 Lecture 35 Brief Introduction to Main AI Areas (cont’d) Overview  Lecture Objective: Present the General Ideas on the AI Branches Below  Introduction.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Describing Syntax and Semantics
Programming by Example using Least General Generalizations Mohammad Raza, Sumit Gulwani & Natasa Milic-Frayling Microsoft Research.
Computer Science 101 Introduction to Programming.
Cultivating Research Taste (illustrated via a journey in Program Synthesis research) Programming Languages Mentoring Workshop 2015 Sumit Gulwani Microsoft.
Programming by Examples Marktoberdorf Lectures August 2015 Sumit Gulwani.
Dimensions in Synthesis Part 3: Ambiguity (Synthesis from Examples & Keywords) Sumit Gulwani Microsoft Research, Redmond May 2012.
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
Analysis of algorithms Analysis of algorithms is the branch of computer science that studies the performance of algorithms, especially their run time.
Formal Methods in Invited CBSoft Sep 2015 Sumit Gulwani Data Wrangling & Education.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Predicting a Correct Program in PBE Rishabh Singh, Microsoft Research Sumit Gulwani, Microsoft Research.
Automating String Processing in Spreadsheets using Input-Output Examples Sumit Gulwani Microsoft Research, Redmond.
Compositional Program Synthesis from Natural Language and Examples Mohammad Raza, Sumit Gulwani & Natasa Milic-Frayling Microsoft.
FlashMeta Microsoft PROSE SDK: A Framework for Inductive Program Synthesis Oleksandr Polozov University of Washington Sumit Gulwani Microsoft Research.
Programming by Examples Marktoberdorf Lectures August 2015 Sumit Gulwani.
Dagstuhl Seminar Oct 2015 Sumit Gulwani Applications of Inductive Programming in Data Wrangling.
Programming by Examples applied to Data Wrangling Invited SYNT July 2015 Sumit Gulwani.
Deductive Techniques for synthesis from Inductive Specifications Dagstuhl Seminar Oct 2015 Sumit Gulwani.
Introduction To Algorithm and Data Structures Course Teacher: Moona Kanwal -Algorithm Design -Algorithm Analysis -Data structures -Abstract Data Type.
Sumit Gulwani Spreadsheet Programming using Examples Keynote at SEMS July 2016.
Introduction to Parsing
Sumit Gulwani Programming by Examples Applications, Algorithms & Ambiguity Resolution Keynote at IJCAR June 2016.
Tackling Ambiguity in PBE Rishabh Singh
CSC 594 Topics in AI – Natural Language Processing
Outline Core Synthesis Architecture [1 hour by Sumit]
Algorithms and Problem Solving
Code Optimization.
Chapter 1 Introduction.
Machine Learning overview Chapter 18, 21
Machine Learning overview Chapter 18, 21
Programming by Examples
Textbook:Modern Compiler Design
CS 9633 Machine Learning Concept Learning
Input Space Partition Testing CS 4501 / 6501 Software Testing
Complexity Time: 2 Hours.
Syntax Specification and Analysis
Session code.
Chapter 1 Introduction.
Lecture 2 Introduction to Programming
Usability Design Space in Programming by Examples
Programming by Examples
Introduction to Problem Solving
Lecture 6 Inductive Synthesis
2008/12/03: Lecture 20 CMSC 104, Section 0101 John Y. Park
Programming by Examples
Chapter 5 Designing the Architecture Shari L. Pfleeger Joanne M. Atlee
Objective of This Course
Lecture 7: Introduction to Parsing (Syntax Analysis)
CSE341: Programming Languages Lecture 12 Equivalence
F# for Parallel and Asynchronous Programming
Chap. 7 Regularization for Deep Learning (7.8~7.12 )
CSE341: Programming Languages Lecture 12 Equivalence
CSE341: Programming Languages Lecture 12 Equivalence
Problem Solving Skill Area 305.1
Algorithms and Problem Solving
Principles of Programming Languages
CISC 7120X Programming Languages and Compilers
CSE341: Programming Languages Lecture 12 Equivalence
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Chapter 12 Analyzing Semistructured Decision Support Systems
CSE341: Programming Languages Lecture 12 Equivalence
CS 325: Software Engineering
CSE341: Programming Languages Lecture 12 Equivalence
Presentation transcript:

Programming by Examples Applications, Algorithms & Ambiguity Resolution Lecture 2: Algorithms and Ambiguity Resolution Sumit Gulwani Winter School in Software Engineering TRDDC, Pune Dec 2017

Outline Lecture 1: Applications DSLs Lecture 2: Search Algorithm Ambiguity Resolution Ranking User interaction models Leveraging ML for improving synthesis Lecture 3: Hands-on session Lecture 4: Miscellaneous related topics Programming using Natural Language Applications in computer-aided Education The Four Big Bets

Programming-by-Examples Architecture Machine Learning, Analytics, & Data Science Conference 11/17/2018 6:25 AM Programming-by-Examples Architecture Example-based Intent Program set (a sub-DSL of D) Program Synthesizer DSL D 2 © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Search Methodology Goal: Set of expr of kind 𝑒 that satisfies spec 𝜙 [denoted 𝑒⊨𝜙 ] 𝑒: DSL (top-level) expression 𝜙: Conjunction of (input state 𝜎 , output value 𝑣) [denoted 𝜎⇝𝑣] Methodology: Based on divide-and-conquer style problem decomposition. 𝑒⊨𝜙 is reduced to simpler problems (over sub-expressions of e or sub-constraints of 𝜙). Top-down (as opposed to bottom-up enumerative search). “FlashMeta: A Framework for Inductive Program Synthesis”; [OOPSLA 2015] Alex Polozov, Sumit Gulwani

Problem Reduction Rules 𝑒⊨ 𝜙 1 ∨ 𝜙 2 = 𝑈𝑛𝑖𝑜𝑛( 𝑒⊨ 𝜙 1 , 𝑒⊨ 𝜙 2 ) 𝑒⊨ 𝜙 1 ∧ 𝜙 2 = 𝐼𝑛𝑡𝑒𝑟𝑠𝑒𝑐𝑡( 𝑒⊨ 𝜙 1 , 𝑒⊨ 𝜙 2 ) An alternative strategy: 𝑒⊨ 𝜙 1 ∧ 𝜙 2 = [ 𝑒 ′ ⊨ 𝜙 2 ], where 𝑒′= 𝑇𝑜𝑝𝑆𝑦𝑚𝑏𝑜𝑙( 𝑒⊨ 𝜙 1 ) Let 𝑒 be a non-terminal defined as 𝑒 ≔ 𝑒 1 | 𝑒 2 𝑒⊨𝜙 = 𝑈𝑛𝑖𝑜𝑛( 𝑒 1 ⊨𝜙 , 𝑒 2 ⊨𝜙 )

Problem Reduction Rules Inverse Set: Let F be an n-ary operator. 𝐹 −1 𝑣 = 𝑢 1 ,…, 𝑢 𝑛 𝐹 𝑢 1 ,…, 𝑢 𝑛 =𝑣} 𝐶𝑜𝑛𝑐𝑎 𝑡 −1 "Abc" = { "Abc",ϵ , ("𝐴𝑏","c"), ("A","bc"), (ϵ,"Abc")} 𝐹 𝑒 1 , …,𝑒 𝑛 ⊨𝜎⇝𝑣 = 𝑈𝑛𝑖𝑜𝑛({F e 1 ⊨𝜎⇝ 𝑢 1 , …, 𝑒 𝑛 ⊨𝜎⇝ 𝑢 𝑛 | 𝑢 1 ,…, 𝑢 𝑛 ∈ 𝐹 −1 𝑣 }) [𝐶𝑜𝑛𝑐𝑎𝑡 𝑋,𝑌 ⊨(𝜎⇝"Abc")] = Union({ 𝐶𝑜𝑛𝑐𝑎𝑡( 𝑋⊨ 𝜎⇝"Abc" , 𝑌⊨ 𝜎⇝𝜖 ), 𝐶𝑜𝑛𝑐𝑎𝑡 𝑋⊨ 𝜎⇝"Ab" , 𝑌⊨ 𝜎⇝"𝑐" , 𝐶𝑜𝑛𝑐𝑎𝑡 𝑋⊨ 𝜎⇝"A" , 𝑌⊨ 𝜎⇝"𝑏𝑐" , 𝐶𝑜𝑛𝑐𝑎𝑡 𝑋⊨ 𝜎⇝ϵ , 𝑌⊨ 𝜎⇝"𝐴𝑏𝑐" })

Problem Reduction Rules Inverse Set: Let F be an n-ary operator. 𝐹 −1 𝑣 = 𝑢 1 ,…, 𝑢 𝑛 𝐹 𝑢 1 ,…, 𝑢 𝑛 =𝑣} 𝐶𝑜𝑛𝑐𝑎 𝑡 −1 "Abc" = { "Abc",ϵ , ("𝐴𝑏","c"), ("A","bc"), (ϵ,"Abc")} 𝐼𝑓𝑇ℎ𝑒𝑛𝐸𝑙𝑠 𝑒 −1 𝑣 = { 𝑡𝑟𝑢𝑒, 𝑣, ⊤ , (𝑓𝑎𝑙𝑠𝑒, ⊤, 𝑣)} Consider the SubStr(x,i,j) operator 𝑆𝑢𝑏𝑆𝑡 𝑟 −1 "Ab" = … 𝑆𝑢𝑏𝑆𝑡 𝑟 −1 "Ab" x="Ab cd Ab")= { 0,2 , (6,8) } The notion of inverse sets (and corresponding reduction rules) can be generalized to the conditional setting.

Generalizing output values to output properties User specification Examples: Conjunction of (input state, output value) Inductive Spec: Conjunction of (input state, output property)

Output properties Elements belonging to the output list Task Elements belonging to the output list Elements not belonging to the output list Contiguous subsequence of the output list Prefix of the output list

Output properties Prefix of the output table (seq of records) Task Prefix of the output table (seq of records) Or rather, Prefixes of projections of the output table

Generalizing output values to output properties User specification Examples: Conjunction of (input state, output value) Inductive Spec: Conjunction of (input state, output property) Search methodology (Conditional) Inverse set: Backward propagation of values (Conditional) Witness function: Backward propagation of properties

Problem Reduction list of strings T := Map(L,S) substring fn S := 𝜆y: … list of lines L := Filter(Split(d,"\n"), B) boolean fn B := 𝜆y: … FlashExtract DSL ⋈ Spec for T Spec for L Spec for S ∧

Problem Reduction substring expr E := SubStr(x,P1,P2) position expr P := K | Pos(x,R1,R2,K) SubStr grammar Spec for E Spec for P1 ⋈ Spec for P2 Redmond, WA Redmond, WA

Outline Lecture 1: Applications DSLs Lecture 2: Search Algorithm Ambiguity Resolution Ranking User interaction models Leveraging ML for improving synthesis Lecture 3: Hands-on session Lecture 4: Miscellaneous related topics Programming using Natural Language Applications in computer-aided Education The Four Big Bets

Programming-by-Examples Architecture Machine Learning, Analytics, & Data Science Conference 11/17/2018 6:25 AM Programming-by-Examples Architecture Example-based Intent Program set (a sub-DSL of D) Ranked Program set (a sub-DSL of D) Program Synthesizer Ranking function DSL D Witness functions 14 © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Basic ranking scheme Prefer programs with simpler Kolmogorov complexity Prefer fewer constants. Prefer smaller constants. Input Output Amey Karkare Amey Ravindra Naik Ravindra 1st Word If (input = “Amey Karkare”) then “Amey” else “Ravindra” “Amey”

Challenges with Basic ranking scheme Prefer programs with simpler Kolmogorov complexity Prefer fewer constants. Prefer smaller constants. Input Output Amey Karkare Karkare, Amey Ravindra Naik Naik, Ravindra 2nd Word + “, ‘’ + 1st Word “Karkare, Amey” How to select between Fewer larger constants vs. More smaller constants? Idea: Associate numeric weights with constants. Predicting a correct program in Programming by Example; CAV 2015; Singh, Gulwani

Comparison of Ranking Strategies over FlashFill Benchmarks Basic Learning Strategy Average # of examples required Basic 4.17 Learning 1.48 Predicting a correct program in Programming by Example; CAV 2015; Singh, Gulwani

FlashFill Ranking Demo

Challenges with Basic ranking scheme Prefer programs with simpler Kolmogorov complexity Prefer fewer constants. Prefer smaller constants. Input Output Missing page numbers, 1993 1993 64-67, 1995 1995 1st Number from the left 1st Number from the right How to select between Same number of same-sized constants? Learning to Learn Programs from Examples: Going Beyond Program Structure ; IJCAI 2017; Ellis, Gulwani

Challenges with Basic ranking scheme Prefer programs with simpler Kolmogorov complexity Prefer fewer constants. Prefer smaller constants. Input v Output [CPT-0123 [CPT-0123] [CPT-456] v + “]” SubStr(v, 0, Pos(v,number,𝜖,1)) + “]” What if the correct program has larger Kolmogorov complexity? Idea: Examine data/trace features (in addition to program features) Learning to Learn Programs from Examples: Going Beyond Program Structure ; IJCAI 2017; Ellis, Gulwani

Outline Lecture 1: Applications DSLs Lecture 2: Search Algorithm Ambiguity Resolution Ranking User interaction models Leveraging ML for improving synthesis Lecture 3: Hands-on session Lecture 4: Miscellaneous related topics Programming using Natural Language Applications in computer-aided Education The Four Big Bets

Need for a fall-back mechanism “It's a great concept, but it can also lead to lots of bad data. I think many users will look at a few "flash filled" cells, and just assume that it worked. … Be very careful.” “most of the extracted data will be fine. But there might be exceptions that you don't notice unless you examine the results very carefully.”

Programming-by-Examples Architecture Machine Learning, Analytics, & Data Science Conference 11/17/2018 6:25 AM Programming-by-Examples Architecture Refined Intent Example based Intent Ranked Program set (a sub-DSL of D) Intended Program in D Program Synthesizer Debugging Translator Test inputs Ranking function DSL D Witness functions Intended Program in R/Python/C#/C++/… 23 © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

User Interaction Models for Ambiguity Resolution Make it easy to inspect output correctness User can accordingly provide more examples Show programs in any desired programming language; in English Enable effective navigation between programs Computer initiated interactivity (Active learning) Cluster inputs/outputs based on syntactic patterns. Highlight less confident entries in the output based on distinguishing inputs. “User Interaction Models for Disambiguation in Programming by Example”, [UIST 2015] Mayer, Soares, Grechkin, Le, Marron, Polozov, Singh, Zorn, Gulwani “FlashProfile: Interactive Synthesis of Syntactic Profiles”, [Under submission] Padhi, Jain, Perelman, Polozov, Gulwani, Millstein

FlashExtract Demo (User Interaction Models)

Outline Lecture 1: Applications DSLs Lecture 2: Search Algorithm Ambiguity Resolution Ranking User interaction models Leveraging ML for improving synthesis Lecture 3: Hands-on session Lecture 4: Miscellaneous related topics Programming using Natural Language Applications in computer-aided Education The Four Big Bets

“PL meets ML” in PBE Advantages Better models Less time to author PBE component (or, more generally, some intelligent software component) Logical strategies Creative heuristics Features Model Can be learned and maintained by ML-backed runtime Written by developers Advantages Better models Less time to author Online adaptation, personalization “Programming by Examples: PL meets ML”; Gulwani, Jain; Invited Talk paper at APLAS 2017

“PL meets ML” opportunity 1: Search Algorithm PL aspects Domain-specific language specified as grammar rules. Top-down/goal-directed search using Inverse semantics. Heuristics that can be machine learned Which grammar production to eliminate or try first? Which sub-goal resulting from application of inverse semantics to try first?

Eliminating Grammar Productions condition-free expr C := Concat(A, C) | A atomic expression A := SubStr(X, P, P) | ConstantString Input Output amey amey@wsse.org raghavan raghavan@wsse.org Only Concat(…) branch possible Input Output sridhar, amey sr raghavan, sumesh ra Need to consider only SubStr(…) branch Input Output sridhar, raghavan sr raghavan, amey ra Can be Concat(…) or SubStr(…) depending on ranking function

Neural-guided Deductive Search Controller predict the top-ranked program score 𝑠 𝑖 from each branch. explore all branches having 𝑠 𝑖 − 𝑠 argmax ≤𝜃 Replace predicted scores by actual scores as learning progresses. Prediction based on supervised training standard LSTM architecture 100s of tasks, 1 task on average yields 1000 sub-problems. “Neural-guided Deductive Search for Real-Time Program Synthesis from Examples”; Mohta, Kalyan, Polozov, Batra, Gulwani, Jain Under submission to ICLR 2017

Initial Results SPEED-UP Average speed-up: 1.67

“PL-meets-ML” opportunity 2: Program Ranking PL aspects Syntactic features of a program Number of constants, size of constants Features of outputs/execution traces of a program on extra inputs. IsYear, Numeric Deviation, Number of characters Heuristics that can be machine learned Weights over various features Non-syntactic features isPersonName.

“PL meets ML” opportunity 3: Disambiguation Communicate actionable information back to user. PL aspects Generate multiple top-ranked programs Enable effective navigation between those programs. Highlight ambiguity based on distinguishing inputs. An input where different programs generate different outputs. Heuristics that can be machine learned Highlight ambiguity based on clustering of inputs/outputs based on their syntactic and other features. When to stop highlighting ambiguity? “User Interaction Models for Disambiguation in Programming by Example”, [UIST 2015] Mayer, Soares, Grechkin, Le, Marron, Polozov, Singh, Zorn, Gulwani “FlashProfile: Interactive Synthesis of Syntactic Profiles”, [ArxiV Report] Padhi, Jain, Perelman, Polozov, Gulwani, Millstein

Programming-by-Examples Architecture Machine Learning, Analytics, & Data Science Conference 11/17/2018 6:25 AM Programming-by-Examples Architecture Refined Intent Example based Intent Ranked Program set (a sub-DSL of D) Intended Program in D Program Synthesizer Debugging Translator Test inputs Ranking function DSL D Witness functions Intended Program in R/Python/C#/C++/… 34 © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Conclusion PBE is a revolutionary new frontier in AI. 99% of end users are non-programmers. Data scientists spend 80% time cleaning data. Developers spend 40% time refactoring code during migration. “PL meets ML” in AI software creation ML can synthesize code heuristics: better, efficient, adaptable PBE component PL aspect Heuristics that can be machine learned Search Algorithm DSL, Inverse functions Non-deterministic choices Program Ranking Features Weights Disambiguation Program navigation, Distinguishing inputs Clustering, When/what to ask?