English

SpecMind: Cognitively Inspired, Interactive Multi-Turn Framework for Postcondition Inference

Software Engineering 2026-02-26 v2 Computation and Language

Abstract

Specifications are vital for ensuring program correctness, yet writing them manually remains challenging and time-intensive. Recent large language model (LLM)-based methods have shown successes in generating specifications such as postconditions, but existing single-pass prompting often yields inaccurate results. In this paper, we present SpecMind, a novel framework for postcondition generation that treats LLMs as interactive and exploratory reasoners rather than one-shot generators. SpecMind employs feedback-driven multi-turn prompting approaches, enabling the model to iteratively refine candidate postconditions by incorporating implicit and explicit correctness feedback, while autonomously deciding when to stop. This process fosters deeper code comprehension and improves alignment with true program behavior via exploratory attempts. Our empirical evaluation shows that SpecMind significantly outperforms state-of-the-art approaches in both accuracy and completeness of generated postconditions.

Keywords

Cite

@article{arxiv.2602.20610,
  title  = {SpecMind: Cognitively Inspired, Interactive Multi-Turn Framework for Postcondition Inference},
  author = {Cuong Chi Le and Minh V. T Pham and Tung Vu Duy and Cuong Duc Van and Huy N. Phan and Hoang N. Phan and Tien N. Nguyen},
  journal= {arXiv preprint arXiv:2602.20610},
  year   = {2026}
}
R2 v1 2026-07-01T10:49:26.790Z