Abstract
We present a new method for automatically providing feedback for introductory programming problems. In order to use this method, we need a reference implementation of the assignment, and an error model consisting of potential corrections to errors that students might make. Using this information, the system automatically derives minimal corrections to student's incorrect solutions, providing them with a measure of exactly how incorrect a given solution was, as well as feedback about what they did wrong. We introduce a simple language for describing error models in terms of correction rules, and formally define a rule-directed translation strategy that reduces the problem of finding minimal corrections in an incorrect program to the problem of synthesizing a correct program from a sketch. We have evaluated our system on thousands of real student attempts obtained from the Introduction to Programming course at MIT (6.00) and MITx (6.00x). Our results show that relatively simple error models can correct on average 64% of all incorrect submissions in our benchmark set.
Introduction
In the era of Massive Open Online Courses (MOOCs), thousands of students enroll in introductory programming classes simultaneously. Providing quality feedback at this scale is a massive bottleneck. Traditional methods often fall short: test-case feedback can be cryptic for beginners, manual TA feedback is prohibitively expensive at scale, and peer feedback is frequently slow or inaccurate.
This paper introduces a system that automatically generates personalized feedback by framing the task as a program synthesis problem. By comparing student code against a reference implementation using a library of common "error rules," the tool identifies the minimal set of changes needed to fix the code, providing students with precise, actionable advice in seconds.
The Feedback Pipeline
The authors' approach relies on two key insights: instructors typically have a reference implementation, and student errors are often predictable. The system transforms the feedback task into a search for the "closest" correct program to the student's submission.
As illustrated in the architecture above, the technical pipeline consists of three main stages:
- Error Model Language (EML): Instructors describe common mistakes as "rewrite rules." For example, a rule might suggest that a student might have started a loop at index 0 when they should have started at 1.
- Program Rewriting: The system takes the student's incorrect Python code and applies the EML rules to create a "space" of possible corrected programs. This is represented in an intermediate language called miniPython (MPY).
- Constraint-Based Synthesis (SKETCH): The problem is fed into the SKETCH synthesizer. The goal is to find a path through the choices in the MPY program that makes the student's code semantically equivalent to the instructor’s reference solution. A modified algorithm called CEGISMIN ensures the solution found is the minimal set of changes.
Error Modeling and Program Synthesis
The core of the translation process involves converting Python code into a formal grammar that can represent multiple potential corrections simultaneously.
As shown in the grammar definitions, the system uses $\widetilde{MPY}$, an extension of MPY that incorporates set-expressions (denoted by squiggly brackets). These set-expressions represent the choices the synthesizer must make—for example, choosing between the student's original expression and several possible corrections suggested by the error model. This formalization allows the system to reason about semantic equivalence over test cases, handling variations in variable names or structure that simple autograders might miss.
Experimental Evaluation
The system was evaluated using thousands of real-world student submissions from MIT 6.00 (classroom), MITx 6.00x (MOOC), and PEX4FUN (C# benchmarks). The benchmarks covered classic introductory problems like computing derivatives, calculating GCDs, and manipulating tuples.
Key Results: * High Coverage: Using relatively simple error models, the tool successfully generated correct feedback for 65% of all incorrect submissions across the benchmark set. * Efficiency: The average time to generate feedback was approximately 10 seconds, making it fast enough for real-time integration into interactive online learning platforms. * Rule Impact: The authors found that adding just a few common rules could lead to the correction of hundreds of unique student attempts, validating the hypothesis that novice errors are highly predictable.
Discussion and Limitations
The most profound idea in this work is treating a "buggy" program as a "sketch" (an incomplete program). Instead of just finding any fix, the system synthesizes the closest correct program. However, the tool faces challenges in specific scenarios:
- Completely Incorrect Solutions: If a student hasn't established a logical foundation (e.g., submitting a nearly empty file), the tool cannot find a "minimal" fix.
- Global Conceptual Errors: Mistakes involving moving large blocks of code or using entirely wrong library functions are harder to capture with local rewrite rules.
- Language Features: The current implementation lacks support for complex Python features like certain types of pattern matching or complex list comprehensions.
Future work suggests that error models could be learned automatically by analyzing clusters of common student mistakes, further reducing the burden on instructors to manually define rules.
Summary updated