Constraint Based Synthesis for Beginners PSY 2012 Armando Solar-Lezama.

Slides:



Advertisements
Similar presentations
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Advertisements

Challenges in increasing tool support for programming K. Rustan M. Leino Microsoft Research, Redmond, WA, USA 23 Sep 2004 ICTAC Guiyang, Guizhou, PRC joint.
An Abstract Interpretation Framework for Refactoring P. Cousot, NYU, ENS, CNRS, INRIA R. Cousot, ENS, CNRS, INRIA F. Logozzo, M. Barnett, Microsoft Research.
Verification and Validation
PZ03D Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ03D - Program verification Programming Language Design.
Automated Grading of DFA Constructions Rajeev Alur (Penn), Loris D’Antoni (Penn), Sumit Gulwani (MSR), Bjoern Hartmann (Berkeley), Dileep Kini (UIUC),
Native x86 Decompilation Using Semantics-Preserving Structural Analysis and Iterative Control-Flow Structuring Edward J. Schwartz *, JongHyup Lee ✝, Maverick.
1 Various Methods of Populating Arrays Randomly generated integers.
Dimensions in Synthesis Part 2: Applications (Intelligent Tutoring Systems) Sumit Gulwani Microsoft Research, Redmond May 2012.
CS 355 – Programming Languages
Using Programmer-Written Compiler Extensions to Catch Security Holes Authors: Ken Ashcraft and Dawson Engler Presented by : Hong Chen CS590F 2/7/2007.
Compiler Construction
The Future of Correct Software George Necula. 2 Software Correctness is Important ► Where there is software, there are bugs ► It is estimated that software.
CIS 101: Computer Programming and Problem Solving Lecture 8 Usman Roshan Department of Computer Science NJIT.
StreamBit: Sketching high-performance implementations of bitstream programs Armando Solar-Lezama, Rastislav Bodik UC Berkeley.
Behavioral Design Outline –Design Specification –Behavioral Design –Behavioral Specification –Hardware Description Languages –Behavioral Simulation –Behavioral.
Reasons to study concepts of PL
©Ian Sommerville 2000Software Engineering, 6th edition. Chapter 19Slide 1 Verification and Validation l Assuring that a software system meets a user's.
Validating High-Level Synthesis Sudipta Kundu, Sorin Lerner, Rajesh Gupta Department of Computer Science and Engineering, University of California, San.
Computer Science 1620 Programming & Problem Solving.
CS350/550 Software Engineering Lecture 1. Class Work The main part of the class is a practical software engineering project, in teams of 3-5 people There.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 28: Implementing Interpreters.
Data Structures and Programming.  John Edgar2.
Making Database Applications Perform Using Program Analysis Alvin Cheung Samuel Madden Armando Solar-Lezama MIT Owen Arden Andrew C. Myers Cornell.
USING SOFTWARE METRICS IN EDUCATIONAL ENVIRONMENT Ivan Pribela, Zoran Budimac, Gordana Rakić.
The Art of Programming Top-Down Design. The Art of Problem Solving The art of problem solving is the transformation of an English description of a problem.
1 L07SoftwareDevelopmentMethod.pptCMSC 104, Version 8/06 Software Development Method Topics l Software Development Life Cycle Reading l Section 1.4 – 1.5.
Language Evaluation Criteria
Verification and Validation Yonsei University 2 nd Semester, 2014 Sanghyun Park.
I. Pribela, M. Ivanović Neum, Content Automated assessment Testovid system Test generator Module generators Conclusion.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 22 Slide 1 Verification and Validation.
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
Dr. Tom WayCSC Code Reviews & Inspections CSC 4700 Software Engineering.
1 Chapter 5 Practice: A Generic View Software Engineering: A Practitioner’s Approach, 6th edition by Roger S. Pressman.
© Andrew IrelandDependable Systems Group Proof Automation for the SPARK Approach to High Integrity Ada Andrew Ireland Computing & Electrical Engineering.
Generative Programming Meets Constraint Based Synthesis Armando Solar-Lezama.
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
CIT 590 Intro to Programming Lecture 4. Agenda Doubts from HW1 and HW2 Main function Break, quit, exit Function argument names, scope What is modularity!
SWE 619 © Paul Ammann Procedural Abstraction and Design by Contract Paul Ammann Information & Software Engineering SWE 619 Software Construction cs.gmu.edu/~pammann/
(A radical interpretation) Tomo Lennox Bow Tie computer services Why Agile Works.
Extended Static Checking for Java  ESC/Java finds common errors in Java programs: null dereferences, array index bounds errors, type cast errors, race.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
Generic API Test tool By Moshe Sapir Almog Masika.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Introduction to Software Testing. Types of Software Testing Unit Testing Strategies – Equivalence Class Testing – Boundary Value Testing – Output Testing.
Synthesis with the Sketch System D AY 1 Armando Solar-Lezama.
How to Read Code Benfeard Williams 6/11/2015 Susie’s lecture notes are in the presenter’s notes, below the slides Disclaimer: Susie may have made errors.
Chapter 3 Part II Describing Syntax and Semantics.
Storyboard Programming Rishabh Singh and Armando Solar-Lezama.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Hack for HHVM Converting Facebook Julien Verlaguet Software Engineer.
Introduction to Compiling
A System to Generate Test Data and Symbolically Execute Programs Lori A. Clarke Presented by: Xia Cheng.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
Is Spreadsheet Ambiguity Harmful? Detecting and Repairing Spreadsheet Smells due to Ambiguous Computation Wensheng Dou 1, Shing-Chi Cheung 2, Jun Wei 1.
Boris Milašinović Faculty of Electrical Engineering and Computing University of Zagreb, Croatia.
Tracking IV&V Analysis Through Multiple FSW Builds Jacob T Cox 1.
Algorithms and Pseudocode
Welcome. Common Core State Standards? English Language Arts and Literacy in History/Social Studies, Science, and Technical Subjects Mathematical Practice.
Software Design and Development Development Methodoligies Computing Science.
Educational Communication & E-learning
Algorithms II Software Development Life-Cycle.
Introduction to Sketching
New applications of program synthesis
Introduction to Sketching
Making synthesis practical Are we there yet?
Is “Higher Level” Better?
Mock Object Creation for Test Factoring
Presentation transcript:

Constraint Based Synthesis for Beginners PSY 2012 Armando Solar-Lezama

CAP View of Synthesis Synthesis Methodology Code

A different approach Synthesis Methodology Code Domain Specific Tool

EXHIBIT A: SYNTHESIS OF SQL With Alvin Cheung and Sam Madden

Motivation It turns out SQL is challenging to learn  Who would have thought? Frameworks simplify program/DB interface  You can access the DB without using SQL  Which can lead to some interesting code...

Examples: Explicit Select public Set getUnfinishedProjects() { Set unfinishedP = new HashSet (); List projects = this.projectDao.getAllProjects(); for (Project project : projects) { if (!(project.getIsFinished())) { unfinishedP.add(project); } } return unfinishedP; } Get list of projects from the DB Select unfinished projects SELECT * FROM Projects WHERE isFinished=FALSE

Examples: Explicit Select public List getRoleUser(){ List listUser = new ArrayList (); List user= this.userDao.getUsers(); List role = this.roleDao.getRoles(); for(int i = 0; i < user.size(); i ++){ for(int a = 0; a < role.size(); a++){ if(user.get(i).getRole_id(). equals(role.get(a).getRole_id())){ WilosUser userok = user.get(i); listUser.add(userok); } return listUser; } Find users in the Roles list and add them to the output Start with users and roles SELECT u FROM users u, roles r WHERE u.roleId == r.id

Why is this so bad? These can be performance bottlenecks  Where performance matters, people write SQL More controversial arguments can be made

Is this a synthesis problem? It is Synthesizer Imperative code with loop nests Equivalent Formula in Relational Algebra Domain knowledge about relational algebra

Framing the problem List getUsersWithRoles () { List users = getUsersFromDB(); List roles = getRolesFromDB(); List results = []; int i = j = 0; while (i < users.size()) { while (j < roles.size()) { if (users[i].roleId == roles[j].id) results.add(users[i]); } return results; }

Framing the problem We want to synthesize a post-condition! Challenges  Defining the language  Solving the synthesis problem  Generating code

Defining the language Requirements  Should make reasoning about the program easy  Should have expressiveness comparable to SQL

Language Just like relational algebra......but with lists rather than sets  The program is written in terms of lists, not sets

Invariants List getUsersWithRoles () { List users = getUsersFromDB(); List roles = getRolesFromDB(); List results = []; int i = j = 0; while (i < users.size()) { while (j < roles.size()) { if (users[i].roleId == roles[j].id) results.add(users[i]); } return results; }

Verification

Synthesis Synthesis works best in a finite domain Invariant generation can be framed as a sketch 1) Model operations in terms of their source code 2) Construct the verification condition leaving invariant and post condition as unknowns 3) Create a sketch for unknowns 4) Solve!

Results so far We have tried this with a dozen loop nests from real open source projects All solve in less than 7 minutes  Slow, but not very optimized.

EXHIBIT B: AUTOMATED GRADING With Rishabh Singh and Sumit Gulwani

The real software problem The Software Quality problem is a symptom The real problem: The demand for software in our society far exceeds the supply of people skilled enough to produce it

Three pronged attack  Make programmers more productive  Make programming more accessible  Reduce the cost of training the next generation

Grading Programming Assignments Test-cases based grading  No precise correctness correlation  No student tailored feedback Manual grading by TAs  Error-prone  Time consuming  Expensive Manual grading will not scale to 100K students

using System; public class Program { public static int[] Puzzle(int[] a) { int[] b = new int[a.Length]; int count = 0; for(int i=a.Length; i < a.Length; i--) { b[count] = a[i]; count++; } return b; } 22 Buggy Program for Array Reverse 6:28::50 AM

using System; public class Program { public static int[] Puzzle(int[] a) { int[] b = new int[a.Length]; int count = 0; for(int i=a.Length-1; i < a.Length-1; i--) { b[count] = a[i]; count++; } return b; } 23 Buggy Program for Array Reverse 6:32::01 AM

using System; public class Program { public static int[] Puzzle(int[] a) { int[] b = new int[a.Length]; int count = 0; for(int i=a.Length-1; i < a.Length-1; i--) { b[count] = a[i]; count++; } return b; } 24 Buggy Program for Array Reverse 6:32::32 AM No change! Sign of Frustation?

using System; public class Program { public static int[] Puzzle(int[] a) { int[] b = new int[a.Length]; int count = 0; for(int i=a.Length; i <= a.Length; i--) { b[count] = a[i]; count++; } return b; } 25 Buggy Program for Array Reverse 6:33::19 AM

using System; public class Program { public static int[] Puzzle(int[] a) { int[] b = new int[a.Length]; int count = 0; for(int i=a.Length; i < a.Length; i--) {Console.Writeline(i); b[count] = a[i]; count++; } return b; } 26 Buggy Program for Array Reverse 6:33::55 AM Same as initial attempt except Console.Writeline!

using System; public class Program { public static int[] Puzzle(int[] a) { int[] b = new int[a.Length]; int count = 0; for(int i=a.Length; i < a.Length; i--) {Console.Writeline(i); b[count] = a[i]; count++; } return b; } 27 Buggy Program for Array Reverse 6:34::06 AM No change! Sign of Frustation?

using System; public class Program { public static int[] Puzzle(int[] a) { int[] b = new int[a.Length]; int count = 0; for(int i=a.Length; i <= a.Length; i--) {Console.Writeline(i); b[count] = a[i]; count++; } return b; } 28 Buggy Program for Array Reverse 6:34::56 AM The student has tried this before!

using System; public class Program { public static int[] Puzzle(int[] a) { int[] b = new int[a.Length]; int count = 0; for(int i=a.Length; i < a.Length; i--) { b[count] = a[i]; count++; } return b; } 29 Buggy Program for Array Reverse 6:36::24 AM Same as initial attempt!

using System; public class Program { public static int[] Puzzle(int[] a) { int[] b = new int[a.Length]; int count = 0; for(int i=a.Length-1; i < a.Length-1; i--) { b[count] = a[i]; count++; } return b; } 30 Buggy Program for Array Reverse 6:37::39 AM The student has tried this before!

using System; public class Program { public static int[] Puzzle(int[] a) { int[] b = new int[a.Length]; int count = 0; for(int i=a.Length; i > 0; i--) { b[count] = a[i]; count++; } return b; } 31 Buggy Program for Array Reverse 6:38::11 AM Almost correct! (a[i-1] instead of a[i] in loop body)

using System; public class Program { public static int[] Puzzle(int[] a) { int[] b = new int[a.Length]; int count = 0; for(int i=a.Length; i >= 0; i--) { b[count] = a[i]; count++; } return b; } 32 Buggy Program for Array Reverse 6:38::44 AM Student going in wrong direction!

using System; public class Program { public static int[] Puzzle(int[] a) { int[] b = new int[a.Length]; int count = 0; for(int i=a.Length; i < a.Length; i--) { b[count] = a[i]; count++; } return b; } 33 Buggy Program for Array Reverse 6:39::33 AM Back to bigger error!

using System; public class Program { public static int[] Puzzle(int[] a) { int[] b = new int[a.Length]; int count = 0; for(int i=a.Length; i < a.Length; i--) { b[count] = a[i]; count++; } return b; } 34 Buggy Program for Array Reverse 6:39::45 AM No change! Frustation!

using System; public class Program { public static int[] Puzzle(int[] a) { int[] b = new int[a.Length]; int count = 0; for(int i=a.Length; i < a.Length; i--) { b[count] = a[i]; count++; } return b; } 35 Buggy Program for Array Reverse 6:40::27 AM No change! More Frustation!!

using System; public class Program { public static int[] Puzzle(int[] a) { int[] b = new int[a.Length]; int count = 0; for(int i=a.Length; i < a.Length; i--) { b[count] = a[i]; count++; } return b; } 36 Buggy Program for Array Reverse 6:40::57 AM No change! Too Frustated now!!! Gives up.

AutoGrader Automate grading  Find semantic errors  Feedback to fix them Students make similar mistakes

Is this a synthesis problem? It is Synthesizer Buggy implementation Corrections for student program Error Model Reference Solution

Array Reverse i = 1 i <= a.Length

Challenge 1: Different Algorithms

Challenge 2: Scalability different possible candidate corrections

Our Approach

Aren’t rewrite systems hard? Can teachers really write rewrite rules? Angelic non-determinism helps  Ambiguities and redundancies no longer matter

Results: Problems Fixed

Results: Performance

Results: Generalization

Feedback for Tutoring System OK for Grading, But not ideal for teaching

Broad research agenda ahead Transformative for students in under-funded schools  Reduce the resources required to support quality instruction  Enable “true” distance education for programming courses Same technology could be used for automatic tutoring  Identify errors stemming from deep misconceptions (e.g. not understanding difference in values vs. references)  Synthesize small examples that make misconceptions explicit 48

Sketch Tutorial on Saturday