Program Synthesis for Computer-aided Education Sumit Gulwani Microsoft Research, Redmond (Joint work with several collaborators) ExCAPE Summer School June 2013 Connections between End-User Programming & Computer-aided Education • End-User teaches Computer & Computer uses that knowledge to automate repetitive tasks. Teacher teachers Computer & Computer uses that knowledge to teach Students. • Interactivity between End-User & Computer to resolve ambiguities. Interactivity between Student & Computer to resolve student’s confusions. Implications: • End-User Programming research can fuel Computer-aided Education research. • And vice-versa! 1 Computer-aided Education Various tasks • Problem Synthesis • Solution Synthesis • Feedback Synthesis • Content Authoring Various subject-domains • Arithmetic, Algebra, Geometry • Programming, Automata, Logic • Board Games, Language Learning • ... MSR-TR-2013-50: Formal Methods for Computer-aided STEM Education 2 Content Classification • Procedural – Mathematical Procedures • Addition, Long division, GCD/LCM, Gaussian Elimination – Algorithmic Procedures • Students asked to show understanding of classical algorithms on specific inputs. – BFS, insertion sort, shortest path – translating regular expression into an automaton. • Conceptual – Proofs • Algebraic theorems, Natural deduction, Non-regularity – Constructions • Geometric ruler/compass based constructions, Automata constructions, Algorithms 3 Problem Synthesis Problem Synthesis Motivation • Problems similar to a given problem. – Avoid copyright issues – Prevent cheating in MOOCs (Unsynchronized instruction) • Problems of a given difficulty level and concept usage. – Generate progressions – Generate personalized workflows Key Ideas ο Procedural Content: Test input generation techniques 5 Problem Synthesis: Addition Procedure Concept Single digit addition Multiple digit w/o carry Single carry Two single carries Double carry Triple carry Extra digit in i/p & new digit in o/p CHI 2013: Erik Andersen, Sumit Gulwani, Zoran Popovic. 6 Problem Synthesis: Addition Procedure Concept Trace Characteristic Single digit addition L Multiple digit w/o carry LL+ Single carry L* (LC) L* Two single carries L* (LC) L+ (LC) L* Double carry L* (LCLC) L* Triple carry L* (LCLCLCLC) L* Extra digit in i/p & new digit in o/p L* CLDCE CHI 2013: Erik Andersen, Sumit Gulwani, Zoran Popovic. 7 Problem Synthesis: Addition Procedure Concept Trace Characteristic Sample Input Single digit addition L 3+2 Multiple digit w/o carry LL+ 1234 +8765 Single carry L* (LC) L* 1234 + 8757 Two single carries L* (LC) L+ (LC) L* 1234 + 8857 Double carry L* (LCLC) L* 1234 + 8667 Triple carry L* (LCLCLCLC) L* 1234 + 8767 Extra digit in i/p & new digit in o/p L* CLDCE 9234 + 900 CHI 2013: Erik Andersen, Sumit Gulwani, Zoran Popovic. 8 Comparing Progressions: Integer Comparison Green Progression: Jump Math Blue Progression: Skill Sharpeners Green Progression moves (quickly) into involved problems that involve comparing more digits. But it ignore an entire class of levels (H and L)! 9 Problem Synthesis Motivation • Problems similar to a given problem. – Avoid copyright issues – Prevent cheating in MOOCs (Unsynchronized instruction) • Problems of a given difficulty level and concept usage. – Generate progressions – Generate personalized workflows Key Ideas • Procedural Content: Test input generation techniques • Conceptual Content ο Template based guess and verify 10 Trigonometry Problem Example Problem: sec π₯ + cos π₯ Query: π1 π₯ ± π2 (π₯) π1 ≠ π5 sec π₯ − cos π₯ = tan2 π₯ + sin2 π₯ π3 π₯ ± π4 π₯ = π52 π₯ ± π62 (π₯) New problems generated: csc π₯ + cos π₯ csc π₯ − cos π₯ = cot 2 π₯ + sin2 π₯ (csc π₯ − sin π₯)(csc π₯ + sin π₯) = cot 2 π₯ + cos 2 π₯ (sec π₯ + sin π₯)(sec π₯ − sin π₯) = tan2 π₯ + cos 2 π₯ : (tan π₯ + sin π₯)(tan π₯ − sin π₯) = tan2 π₯ − sin2 π₯ (csc π₯ + cos π₯)(csc π₯ − cos π₯) = csc 2 π₯ − cos 2 π₯ : AAAI 2012: Rohit Singh, Sumit Gulwani, Sriram Rajamani. 11 Trigonometry Problem Example Problem: sec π₯ + cos π₯ Query: π1 π₯ ± π2 (π₯) π1 ≠ π5 sec π₯ − cos π₯ = tan2 π₯ + sin2 π₯ π3 π₯ ± π4 π₯ = π52 π₯ ± π62 (π₯) New problems generated: csc π₯ + cos π₯ csc π₯ − cos π₯ = cot 2 π₯ + sin2 π₯ (csc π₯ − sin π₯)(csc π₯ + sin π₯) = cot 2 π₯ + cos 2 π₯ (sec π₯ + sin π₯)(sec π₯ − sin π₯) = tan2 π₯ + cos 2 π₯ : (tan π₯ + sin π₯)(tan π₯ − sin π₯) = tan2 π₯ − sin2 π₯ (csc π₯ + cos π₯)(csc π₯ − cos π₯) = csc 2 π₯ − cos 2 π₯ : AAAI 2012: Rohit Singh, Sumit Gulwani, Sriram Rajamani. 12 Limits/Series Problem π Example Problem: π Query: lim π→∞ π=0 lim π→∞ π=0 2π 2 + π + 1 5 = π 2 5 πΆ0 π 2 + πΆ1 π + πΆ2 πΆ3 π πΆ4 = πΆ5 C0 ≠ 0 ∧ gcd πΆ0 , πΆ1 , πΆ2 = gcd πΆ4 , πΆ5 = 1 New problems generated: π lim π→∞ π=0 π lim π→∞ π=0 π 2 3π + 2π + 1 7 = π 3 7 lim π→∞ π 2 π 3 = π 2 3 π=0 lim π→∞ π=0 3π 2 + 3π + 1 =4 π 4 5π 2 + 3π + 3 =6 π 6 13 Integration Problem Example Problem: Query: (csc π₯) (csc π₯ − cot π₯) ππ₯ = csc π₯ − cot π₯ π0 π₯ π1 π₯ ± π2 π₯ ππ₯ = π4 π₯ ± π5 (π₯) π1 ≠ π2 ∧ π4 ≠ π5 New problems generated: (tan π₯) (cos π₯ + sec π₯) ππ₯ = sec π₯ − cos π₯ (sec π₯) (tan π₯ + sec π₯) ππ₯ = sec π₯ + cot π₯ (cot π₯) (sin π₯ + csc π₯) ππ₯ = sin π₯ − csc π₯ 14 Determinant Problem Ex. Problem π₯+π¦ π§π₯ π¦π§ 2 π§π₯ π¦+π§ π₯π¦ πΉ0 (π₯, π¦, π§) πΉ1 (π₯, π¦, π§) Query πΉ3 (π₯, π¦, π§) πΉ4 (π₯, π¦, π§) πΉ6 (π₯, π¦, π§) πΉ7 (π₯, π¦, π§) 2 π§π¦ π₯π¦ π§+π₯ = 2π₯π¦π§ π₯ + π¦ + π§ 3 2 πΉ2 (π₯, π¦, π§) πΉ5 (π₯, π¦, π§) πΉ8 (π₯, π¦, π§) = πΆ10 πΉ9 (π₯, π¦, π§) πΉπ β πΉπ π₯ → π¦; π¦ → π§; π§ → π₯ π€βπππ π, π ∈ { 4,0 , 8,4 , 5,1 , … } New problems generated: π¦2 π§+π¦ π§2 2 π¦π§ + π¦ 2 π¦π§ π§π₯ π₯2 π§2 π₯+π§ π₯π¦ π§π₯ + π§ 2 π§π₯ 2 π¦+π₯ π¦2 π₯2 π₯π¦ π¦π§ π₯π¦ + π₯ 2 2 = 2 π₯π¦ + π¦π§ + π§π₯ 3 = 4π₯ 2 π¦ 2 π§ 2 15 Problem Synthesis Motivation • Problems similar to a given problem. – Avoid copyright issues – Prevent cheating in MOOCs (Unsynchronized instruction) • Problems of a given difficulty level and concept usage. – Generate progressions – Generate personalized workflows Key Ideas • Procedural Content: Test input generation techniques • Conceptual Content ο Template based guess and verify 16 Problem Synthesis: Sentence Completion 1. The principal characterized his pupils as _________ because they were pampered and spoiled by their indulgent parents. 2. The commentator characterized the electorate as _________ because it was unpredictable and given to constantly shifting moods. (a) cosseted (b) disingenuous (c) corrosive (d) laconic (e) mercurial One of the above problems is a real SAT problem, while the other one was automatically generated! Problem Synthesis Motivation • Problems similar to a given problem. – Avoid copyright issues – Prevent cheating in MOOCs (Unsynchronized instruction) • Problems of a given difficulty level and concept usage. – Generate progressions – Generate personalized workflows Key Ideas • Procedural Content: Test input generation techniques • Conceptual Content – Template based guess and verify ο Symbolic methods (solution generation in reverse) 18 Natural Deduction Prove that: π₯1 ∨ π₯2 ∧ π₯3 and π₯1 → π₯4 and π₯4 → π₯5 implies π₯2 ∨ π₯5 Inference Rule Premises Conclusion Modus Ponens (MP) π → π, π π Hypothetical Syllogism (HS) π → π, π → π π→π Disjunctive Syllogism (DS) π ∨ π, ¬π π Simplification (Simp) π∧π π Replacement Rule Proposition Equiv. Proposition Distribution π ∨ (π ∧ π) Double Negation 𠬬π Implication π→π ¬π ∨ π Equivalence π≡π π ∨ π ∧ (π ∨ π) π → π ∧ (π → π) IJCAI 2013: Umair Ahmed, Sumit Gulwani, Amey Karkare 19 Similar Problem Synthesis: Natural Deduction Similar Problems = those that have a minimal proof with the same sequence of inference rules as used by a minimal proof of given problem. Premise 1 Premise 2 Premise 3 Conclusion π₯1 ∨ (π₯2 ∧ π₯3 ) π₯1 → π₯4 π₯4 → π₯5 π₯2 ∨ π₯5 Similar Problems Premise 1 Premise 2 Premise 3 Conclusion π₯1 ≡ π₯2 π₯3 → ¬π₯2 (π₯4 → π₯5 ) → π₯3 π₯1 → (π₯π¦ ∧ ¬π₯5 ) π₯1 ∧ (π₯2 → π₯3 ) π₯1 ∨ π₯4 → ¬π₯5 π₯2 ∨ π₯5 (π₯1 ∨ π₯2 ) → π₯3 π₯3 → π₯1 ∧ π₯4 (π₯1 → π₯2 ) → π₯3 π₯3 → ¬π₯4 π₯1 → π₯2 ∧ π₯3 π₯4 → ¬π₯2 π₯1 ∧ π₯4 → π₯5 π₯1 ∨ π₯5 ∨ π₯4 π₯3 ≡ π₯5 → π₯4 π₯1 ∨ π₯4 ∧ ¬π₯5 π₯1 → π₯5 π₯5 ∨ π₯2 → π₯1 π₯1 → π₯3 ≡ ¬π₯5 20 Parameterized Problem Synthesis: Natural Deduction Parameters: # of premises = 3, Size of propositions ≤ 4 # of variables = 3, # of inference steps = 2 Inference rules = { DS, HS } Parameterized Problems Premise 1 Premise 2 Premise 3 Conclusion (π₯1 → π₯3 ) → π₯2 π₯2 → π₯3 ¬π₯3 π₯1 ∧ ¬π₯3 π₯3 ≡ π₯1 → π₯2 ¬π₯2 π₯1 ∧ ¬π₯3 π₯3 → π₯1 π₯1 ≡ π₯3 ∨ π₯1 ≡ π₯2 (π₯1 ≡ π₯2 ) → π₯3 ¬π₯3 π₯1 ≡ π₯3 π₯1 ≡ ¬π₯3 π₯2 ∨ π₯1 π₯3 → ¬π₯2 π₯1 ∧ ¬π₯3 π₯3 → π₯1 π₯1 → π₯2 ∧ π₯3 π₯3 → ¬π₯2 ¬π₯3 21 Problem Synthesis Motivation • Problems similar to a given problem. – Avoid copyright issues – Prevent cheating in MOOCs (Unsynchronized instruction) • Problems of a given difficulty level and concept usage. – Generate progressions – Generate personalized workflows Key Ideas • Procedural Content: Test input generation techniques • Conceptual Content – Template based guess and verify ο Symbolic methods (solution generation in reverse) 22 Problem Generation: Board Games Game Rules • allows variants of classic games. Tic-Tac-Toe 4*4 Row/Column only Expertise level of player/opponent • allows leveling the playing field. Automatic Generation of Starting Positions in Board Games; Umair Ahmed, Krishnendu Chatterjee, Sumit Gulwani. Solution Synthesis Solution Synthesis Motivation • Synthesize sample solutions to new problems. • Synthesize customized solutions or complete unfinished ones. • Inform solution characteristics during problem generation. Key Ideas ο Procedural Content: Programming by Demonstration 25 Solution Synthesis: GCF Computation Time-stamped sequence of (location, value) pairs Programming by Demonstration Spreadsheet Program Can also be used to synthesize incorrect procedures from buggy traces! Joint work with Erik Andersen and Zoran Popovic. 26 Solution Synthesis Motivation • Synthesize sample solutions to new problems. • Synthesize customized solutions or complete unfinished ones. • Inform solution characteristics during problem generation. Key Ideas • Procedural Content: Programming by Demonstration ο Conceptual Content – Perform reasoning over models (vs. abstract symbolic reasoning). – Reduce solution space to solutions with small length. 27 Ruler/Compass based Geometry Constructions Given a triangle XYZ, construct circle C such that C passes through X, Y, and Z. C L1 L2 N Z X Y PLDI 2011: Sumit Gulwani, Vijay Korthikanti, Ashish Tiwari. 28 Problem Description Given a triangle XYZ, construct circle C such that C passes through X, Y, and Z. Precondition: Slope(X,Y) οΉ Slope(X,Z) Æ Slope(X,Y) οΉ Slope(Z,X) Postcondition: LiesOn(X,C) Æ LiesOn(Y,C) Æ LiesOn(Z,C) Where LiesOn(X,C) ´ Distance(X,Center(C)) = Radius(C) 29 Solution is a program! Geometry Program: A straight-line composition of geometry methods. Geometry Types: Point, Line, Circle Geometry Methods: • Ruler(Point, Point) -> Line • Compass(Point, Point) -> Circle • Intersect(Circle, Circle) -> Pair of Points • Intersect(Line, Circle) -> Pair of Points • Intersect(Line, Line) -> Point 30 Example of Geometry Program Given a triangle XYZ, construct circle C such that C passes through X, Y, and Z. 1. C1 = Compass(X,Y); 2. C2 = Compass(Y,X); 3. <P1,P2> = Intersect(C1,C2); 4. L1 = Ruler(P1,P2); 5. D1 = Compass(Z,X); 6. D2 = Compass(X,Z); 7. <R1,R2> = Intersect(D1,D2); 8. L2 = Ruler(R1,R2); 9. N = Intersect(L1,L2); 10. C = Compass(N,X); C L1 N C1 D1 R1 Z R2 P1 X D2 L2 C2 Y P2 31 Verification/Synthesis Problem for Geometry Programs • Let P be a geometry program that computes outputs O from inputs I. • Verification Problem: Check the validity of the following Hoare triple. Assume Pre(I); P Assert Post(I,O); • Synthesis Problem: Given Pre(I), Post(I,O), find P such that the above Hoare triple is valid. 32 Verification Algorithm Pre(I), P, Post(I,O) a) Existing decision procedures are complex. b) 1. 2. 3. New efficient approach: Random Testing! Choose I’ randomly from the set { I | Pre(I) }. Compute O’ := P(I’). If O’ satisfies Post(I’,O’) output “Verified”. Correctness Proof of (b): • Objects constructed by P can be described using polynomial ops (+,-,*), square-root & division operator. • The randomized polynomial identity testing algorithm lifts to square-root and division operators as well ! 33 Synthesis Algorithm // First obtain a random input-output example. 1. Choose I’ randomly from the set { I | Pre(I) }. 2. Compute O’ s.t. Post(I’,O’) using numerical methods. // Now obtain a construction that can generate O’ from I’ (using goal-directed search). 3. S := I’; 4. While (S does not contain O’) 5. S := S [ { M(O1,O2) | Oi 2 S, M 2 Methods } 6. Output construction steps for O’. 34 Error Probability of the algorithm is extremely low. Given a triangle XYZ, construct circle C such that C passes through X, Y, and Z. C L1 … L1 = Ruler(P1,P2); N … L2 = Ruler(R1,R2); N = Intersect(L1,L2); Z C = Compass(N,X); X L2 Y • For an equilateral 4XYZ, incenter coincides with circumcenter N. • But what are the chances of choosing a random 4XYZ to be an equilateral one? 35 Solution Synthesis Motivation • Synthesize sample solutions to new problems. • Synthesize customized solutions or complete unfinished ones. • Inform solution characteristics during problem generation. Key Ideas • Procedural Content: Programming by Demonstration ο Conceptual Content – Perform reasoning over models (vs. abstract symbolic reasoning). – Reduce solution space to solutions with small length. 36 Natural Deduction Prove that: π₯1 ∨ π₯2 ∧ π₯3 and π₯1 → π₯4 and π₯4 → π₯5 implies π₯2 ∨ π₯5 Inference Rule Premises Conclusion Modus Ponens (MP) π → π, π π Hypothetical Syllogism (HS) π → π, π → π π→π Disjunctive Syllogism (DS) π ∨ π, ¬π π Simplification (Simp) π∧π π Replacement Rule Proposition Equiv. Proposition Distribution π ∨ (π ∧ π) Double Negation 𠬬π Implication π→π ¬π ∨ π Equivalence π≡π π ∨ π ∧ (π ∨ π) π → π ∧ (π → π) IJCAI 2013: Umair Ahmed, Sumit Gulwani, Amey Karkare 37 Solution Synthesis: Natural Deduction Prove that: π₯1 ∨ π₯2 ∧ π₯3 and π₯1 → π₯4 and π₯4 → π₯5 Step Proposition Reason P1 π₯1 ∨ π₯2 ∧ π₯3 Premise implies: π₯2 ∨ π₯5 P2 π₯1 → π₯4 Premise P3 π₯4 → π₯5 Premise 1 (π₯1 ∨ π₯2 ) ∧ (π₯1 ∨ π₯3 ) P1, Distr. 2 π₯1 ∨ π₯2 1, Simp. 3 π₯1 → π₯5 P2, P3, HS 4 π₯2 ∨ π₯1 2, Comm. Step Truth Table Reason P1 1048575 Premise P2 4294914867 Premise 5 ¬¬π₯2 ∨ π₯1 4. Double Neg. P3 3722304989 Premise 6 ¬π₯2 → π₯1 5, Implication 1 16777215 P1,Simp. 7 6,3, HS. 2 4294923605 P2,P3,HS ¬π₯2 → π₯5 8 ¬¬π₯2 ∨ π₯5 7, Implication Concl 1442797055 1,2,HS Abstract Proof Concl π₯2 ∨ π₯5 Concrete Proof 8, Double Neg. 38 Feedback Synthesis Feedback Synthesis Motivation • Makes teachers more effective. – Saves them time. – Provides immediate insights on where students are struggling. • Can enable rich interactive experience for students. – Generation of hints. – Pointer to simpler problems depending on kind of mistake. Key Ideas: Various feedback metrics ο Inputs on which the solution is not correct (counterexamples). 40 Counterexample based Feedback: PexForFun 41 Buggy Program for Array Reverse using System; 6:28::50 AM 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; }} 42 Buggy Program for Array Reverse using System; 6:32::01 AM 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; }} 43 Buggy Program for Array Reverse using System; 6:32::32 AM 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; }} No change! Sign of Frustation? 44 Buggy Program for Array Reverse using System; 6:33::19 AM 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; }} 45 Buggy Program for Array Reverse using System; 6:33::55 AM 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; }} Same as initial attempt except Console.Writeline! 46 Buggy Program for Array Reverse using System; 6:34::06 AM 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; }} No change! Sign of Frustation? 47 Buggy Program for Array Reverse using System; 6:34::56 AM 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; }} The student has tried this before! 48 Buggy Program for Array Reverse using System; 6:36::24 AM 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; }} Same as initial attempt! 49 Buggy Program for Array Reverse using System; 6:37::39 AM 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; }} The student has tried this before! 50 Buggy Program for Array Reverse using System; 6:38::11 AM 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; }} Almost correct! (a[i-1] instead of a[i] in loop body) 51 Buggy Program for Array Reverse using System; 6:38::44 AM 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; }} Student going in wrong direction! 52 Buggy Program for Array Reverse using System; 6:39::33 AM 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; }} Back to bigger error! 53 Buggy Program for Array Reverse using System; 6:39::45 AM 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; }} No change! Frustation! 54 Buggy Program for Array Reverse using System; 6:40::27 AM 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; }} No change! More Frustation!! 55 Buggy Program for Array Reverse using System; 6:40::57 AM 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; }} No change! Too Frustated now!!! Gives up. 56 Feedback Synthesis Motivation • Makes teachers more effective. – Saves them time. – Provides immediate insights on where students are struggling. • Can enable rich interactive experience for students. – Generation of hints. – Pointer to simpler problems depending on kind of mistake. Key Ideas: Various feedback metrics • Inputs on which the solution is not correct (counterexamples). ο Edit distance to a nearest correct solution. 57 Correction Model for Programming Assignments Array Index: v[a] -> v[{a+1, a-1}] Increment: v++ -> { ++v, v--, --v } Conditional: a op b -> a ops b where ops = { <, >, <=, >=, ==, != } Initialization: v=n -> v={n+1, n-1, 0} Return Value: return v -> return ?v Key Idea: Finding minimal set of such changes that convert a buggy solution into a correct one is phrased as a sketch problem. PLDI 2013: Rishabh Singh, Sumit Gulwani, Armando Solar-Lezama 58 Feedback Synthesis: Array Reverse i = 1 front <= back i <= a.Length --back http://sketch1.csail.mit.edu/python-autofeedback/ Feedback Synthesis Motivation • Makes teachers more effective. – Saves them time. – Provides immediate insights on where students are struggling. • Can enable rich interactive experience for students. – Generation of hints. – Pointer to simpler problems depending on kind of mistake. Key Ideas: Various feedback metrics • Inputs on which the solution is not correct (counterexamples). • Edit distance to a nearest correct solution. ο Edit distance to the problem description (of a nearest corresponding problem description). 60 Feedback Synthesis: Finite State Automata Draw a DFA that accepts: { s | ‘ab’ appears in s exactly 2 times } Attempt 1 Grade: 9/10 Feedback: One more state should be made final Based on Edit-distance to a correct solution Grade: 6/10 Feedback: The DFA is incorrect on the string ‘ababb’ Attempt 2 Based on Counterexample Grade: 5/10 Feedback: The DFA accepts {s | ‘ab’ appears in s at least 2 times} Attempt 3 Based on Edit-distance to the problem description IJCAI 2013: Alur, Loris d’Antoni, Gulwani, Dileep Kini, Viswanathan 61 Content Authoring Content Authoring Motivation: Make it easy to create and edit ο Equations • Drawings Key Ideas • Allow multi-modal NUIs such as ink, speech, touch. • Error correction. • Prediction. 63 Challenges in creating Equations Text editors like Latex • Unreadable text in prefix notation WYSIWIG editors like Microsoft Word • Change of cursor positions multiple times. • Back and forth switching between mouse & keyboard Our solution: An intelligent predictive editor. • Mathematical text has low entropy and hence amenable to prediction! Joint work with Alex Polozov and Sriram Rajamani. 64 Structure Prediction We can predict likely structures from a flattened representation. This can enable math-by-speech and auto-parenthesis-error-fix. 1+cos π΄ 1−cos π΄ 1 + cos A / 1 − cos A ((1 + cos A ) / (1 − cos A )) Term Prediction (Syntactic Intellisense) tan 3π₯ tan 2π₯ tan π₯ = tan 3π₯ − tan 2π₯ − tan π₯ π¦π§ − π₯ 2 π§π₯ − π¦ 2 π₯π¦ − π§ 2 π΄1 sin3 πΌ π΄2 sin πΌ π§π₯ − π¦ 2 π₯π¦ − π§ 2 π¦π§ − π₯ 2 π΅1 sin3 π½ π΅2 sin π½ π₯π¦ − π§ 2 π¦π§ − π₯ 2 π§π₯ − π¦ 2 πΆ1 sin3 πΎ πΆ2 sin πΎ Our tool can infer colored text. 66 Term Prediction (Semantic Intellisense) Prove (csc π₯ − sin π₯)(sec π₯ − cos π₯)(tan π₯ + cot π₯) = 1 L.H.S. = 1 − sin π₯ sin π₯ = 1 − sin2 π₯ sin π₯ = cos 2 π₯ sin π₯ 1 − cos π₯ cos π₯ 1 − cos2 π₯ cos π₯ sin2 π₯ cos π₯ sin π₯ cos π₯ + cos π₯ sin π₯ sin2 π₯ + cos 2 π₯ cos π₯ sin π₯ 1 cos π₯ sin π₯ =1 67 Content Authoring Motivation: Make it easy to create and edit • Equations ο Drawings Key Ideas • Allow multi-modal NUIs such as ink, speech, touch. • Error correction. • Prediction. 68 Challenges in creating drawings Sometimes require extreme precision. • Our solution: allow pen-based sketching and use constraint solving to beautify. Can be tedious to draw sometimes. Copy-Paste doesn’t address positioning of copied objects & transformations on copied objects! • Our Solution: use synthesis to predict repetitive features. CHI 2012: Salman Cheema, Sumit Gulwani, Joseph LaViola. 69 (Ink) Sketching meets Synthesis Beautification Beautification Prediction Prediction Conclusion • Technical Perspective – Aspects: Problem/Solution/Feedback Synthesis, Content Authoring – Domains: Math, Programming, Logic, Language Learning, ... • Inter-disciplinary research area – – – – Synthesis/Search techniques HCI Natural language processing (for word problems) Machine learning (for analytics) • Value Proposition: – Short term: Improve Education (personalized + interactive) – Long Term: Ultra-intelligent computer, Model of human mind, Inter-stellar travel ο 71