Conference paper
Cite …

Can Formal Specifications Be Synthesized from Tests Alone?

Tianhai Liu  ORCID iD icon 1, Maximilian Müller 1, Tobias Hey ORCID iD icon 1, Vitus Lüntzel ORCID iD icon 2, Muhammad Minhas ORCID iD icon 1, Anne Koziolek ORCID iD icon 1 and Bernhard Beckert ORCID iD icon 1
1 Karlsruhe Institute of Technology (KIT)
2 Institute for Information Processing Technologies (ITIV), Karlsruhe Institute of Technology (KIT)
Abstract

Formal specifications offer strong guarantees, but remain costly to write manually. Recent LLM-based approaches automate this by inferring specifications from source code, yet their reliance on white-box access poses barriers to industrial adoption due to intellectual property risks and deployment costs. Our approach uses LLMs to infer candidate specifications solely from test code and dynamic execution traces: the LLM observes only the program interface, selected inputs, and corresponding outputs or state changes, while the implementation internals remain hidden. Candidate specifications are validated locally using bounded model checking, with feedback guiding iterative refinement. Initial results on the SpecGenBench benchmark suggest that tests can guide LLMs towards meaningful Java Modeling Language specifications, while also highlighting checker compatibility and diagnostic feedback as key challenges for reliable refinement.