Often, a good explanation for a program's unexpected behavior is a bug in the programmer's code. But sometimes, an even better explanation is a bug in the programmer's mental model of the language they are using. Instead of merely debugging our current code ("giving the programmer a fish"), what if our tools could directly debug our mental models ("teaching the programmer to fish")? In this paper, we apply ideas from computational cognitive science to do exactly that. Given a perplexing program, we use program synthesis techniques to automatically infer potential misconceptions that might cause the user to be surprised by the program's behavior. By analyzing these misconceptions, we provide succinct, useful explanations of the program's behavior. Our methods can even be inverted to synthesize pedagogical example programs for diagnosing and correcting misconceptions in students.
翻译:通常,对程序意外行为合理解释是程序员代码中的Bug。但有时,更佳的解释可能是程序员对所用语言心智模型中的认知偏差。与其仅仅调试当前代码("给程序员一条鱼"),我们的工具能否直接调试其心智模型("教程序员捕鱼")?本文借鉴计算认知科学的思想实现了这一目标。针对令人困惑的程序,我们运用程序合成技术自动推断可能导致用户对程序行为感到意外的潜在认知偏差。通过分析这些认知偏差,我们提供关于程序行为的简洁实用解释。该方法甚至可以逆向用于综合教学示例程序,以诊断并纠正学生中的认知偏差。