Can Language Models Falsify? Evaluating Algorithmic Reasoning with Counterexample Creation

Shiven Sinha, Shashwat Goel, Ponnurangam Kumaraguru, Jonas Geiping, Matthias Bethge, Ameya Prabhu

TL;DR

Language models (LMs) are great at solving problems, but terrible at finding flaws in existing solutions. This paper introduces REFUTE, a new benchmark for evaluating LMs' ability to "falsify" incorrect code by creating counterexamples. Even top-tier LMs struggle significantly with this task, highlighting a crucial gap in their reasoning capabilities.

What Problem Does This Paper Address?

The scientific method relies heavily on falsification – proving claims wrong to refine understanding. While LMs are increasingly capable of generating solutions to complex problems, current benchmarks primarily focus on this generative ability. This leaves a critical gap: LMs are not effectively evaluated on their capacity to challenge or falsify existing claims or solutions. This "inverse capability" is essential for scientific progress and for developing more robust, self-improving AI systems. The paper specifically addresses this by focusing on algorithmic problem-solving, where counterexamples can be automatically verified through code execution.

Methods

The core contribution is the REFUTE benchmark, designed to evaluate an LM's ability to create counterexamples for subtly incorrect algorithmic solutions. The process involves:

  1. Problem Sourcing: Using recent programming competition problems (Codeforces) to ensure novelty and avoid training data contamination.
  2. Incorrect Solution Selection: Identifying submissions that provided wrong answers (not just time/memory limit issues) and prioritizing those that were "hacked" by human experts, indicating subtle errors.
  3. Counterexample Generation Task: LMs are tasked with generating a program that outputs a specific input satisfying problem constraints, for which the provided incorrect solution fails.
  4. Automatic Verification: The generated counterexample input is validated against problem constraints, and then the output of the incorrect solution is compared against a known correct solution.

The paper also explores different prompting strategies and agentic approaches, including:

  • Zero-Shot Prompting: Directly asking the LM to find a failing test case.
  • Few-Shot Prompting: Providing examples of successful counterexample creation.
  • Agentic Code Execution: Allowing the LM to interact with a code execution environment to debug and refine its attempts.
  • Random Search: Prompting the LM to generate a random input generator and a brute-force solution to find discrepancies.
  • Random Search (Oracle): Providing the correct solution to guide the random search.

Datasets

The primary dataset introduced is REFUTE (Refuting Erroneous Findings Using Targeted Examples). It consists of 324 samples, each containing:

  • A programming problem statement with input constraints.
  • An incorrect code submission for that problem.
  • The correct solution for verification.
  • An input validation script.

The dataset is sourced from Codeforces contests between January 2024 and January 2025, covering over 34 algorithmic topics. The paper also references LiveCodeBench for selecting baseline models based on their solution generation performance.

Key Insights and Ideas

  • Falsification is Harder Than Generation: The most striking insight is that even state-of-the-art LMs, which can solve a significant portion of algorithmic problems, are remarkably poor at finding counterexamples to incorrect solutions. This suggests a fundamental difference in the cognitive processes required for generation versus falsification.
  • Code Execution Feedback Helps, But Not Enough: While agentic approaches with code execution feedback improve performance, the gains are modest. This indicates that LMs still struggle to effectively leverage this feedback for complex debugging and falsification tasks.
  • No Clear Predictors for Success: The paper found no strong correlation between model success in creating counterexamples and factors like problem difficulty, submission author expertise, or the number of test cases passed by the incorrect submission. This makes it difficult to predict which problems will be challenging for LMs.
  • Bug Misclassification is Common: LMs often misclassify the nature of bugs, mistaking implementation errors for logical flaws or vice versa. This hinders their ability to generate targeted counterexamples.
  • The "Generator-Verifier Gap": The results suggest a potential "generator-verifier gap," where LMs are better at generating outputs than verifying their correctness or the correctness of others' outputs. This has implications for self-improvement mechanisms in AI.

Key Results

  • Low Counterexample Creation Rate: Even the best models, like OpenAI's o3-mini (high) with code execution feedback, could only create counterexamples for less than 9% of the incorrect solutions in REFUTE. This is in stark contrast to their ability to solve up to 48% of these problems from scratch.
  • Agentic Approaches Show Modest Gains: DeepSeek R1 showed some improvement with agentic code execution, but overall gains were limited.
  • Random Search Performance: The "Random Search Oracle" strategy (providing the correct solution) significantly improved performance over basic random search, but still fell far short of human capabilities.
  • Bug Type Analysis: Models were better at identifying simpler bugs (e.g., off-by-one errors) than fundamental algorithmic flaws or subtle edge cases.

Limitations and Future Work

  • C++ Bias: The REFUTE benchmark is based on C++ solutions, which might favor models with stronger C++ proficiency. While Python versions are possible, C++ is dominant in competitive programming.
  • Proof of Concept: REFUTE is presented as a proof of concept for evaluating LM falsification. It's not representative of all falsification capabilities, especially in domains where automatic verification is difficult.
  • Domain Specificity: The current focus is on algorithmic problem-solving. Future work should expand to other domains like mathematics and scientific claims, where counterexamples might be harder to verify automatically.
  • Broader Inverse Benchmarks: The authors advocate for developing more "inverse benchmarks" that test model abilities in hypothesis testing, data analysis, and simulation, moving beyond simple solution generation.
  • Integrating Formal Tools: Exploring the integration of formal verification tools like SMT solvers could enhance LM falsification capabilities.

Summary updated

BibTeX
@inproceedings{sinha2025can,
  author = {Shiven Sinha and Shashwat Goel and Ponnurangam Kumaraguru and Jonas Geiping and Matthias Bethge and Ameya Prabhu},
  title = {{Can Language Models Falsify? Evaluating Algorithmic Reasoning with Counterexample Creation}},
  booktitle = {COLM},
  year = {2025},
  url = {https://openreview.net/forum?id=M7cl4Ldw61},
}
Figure