arXiv:2610.33094cs.SEOct 2026

Manuscript Offprint

arXiv:2610.33094

Beyond Correctness: Attribution of Natural-Language Documentation for Formal Libraries

Sirui Jiang, Dongming Xiang, Shichao Wu, Yuxuan Zhou, Yihong Wu, Fangze Zhu, Wang Lin, Guanjun Liu

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

SIRUI JIANG, Zhejiang Sci-Tech University, China

DONGMING XIANG, Zhejiang Sci-Tech University, China

SHICHAO WU, Zhejiang Sci-Tech University, China

YUXUAN ZHOU, Zhejiang Sci-Tech University, China

YIHONG WU, Zhejiang Sci-Tech University, China

FANGZE ZHU, Zhejiang Gongshang University, China

WANG LIN, Zhejiang Sci-Tech University, China

GUANJUN LIU, Tongji University, China

Formal languages are widely used in software engineering to specify and verify program properties. Because their mathematical notation and logic are hard to read, developers often rely on natural-language documentation to understand the functions in formal libraries. Yet a documentation statement can be provably true and still hold after the function's behavior changes. We call a statement's dependence on the function's specific behavior attribution, and we give a method to check it. We design and implement DocAuth, a documentation-generation method that uses attribution to decide what to publish and attaches to each published sentence the formal property recovered from it, together with checkable evidence. On 150 functions from the Community Books library of the ACL2 theorem prover, three large language models produce proved but non-attributable properties for about a third of the functions. DocAuth matches or exceeds the attribution rate of a mutation-based filter while delivering 37% more attributable sentences. Compared with a pipeline that checks truth alone, it raises the share of published sentences that a second model confirms as attributable from 82.9% to 94.7%. These results show that provable truth does not guarantee that documentation reflects what a function actually does. Attribution complements truth as a criterion for generating and evaluating documentation for formal libraries.

CCS Concepts: • Software and its engineering → Software verification; Software libraries and repositories; • Computing methodologies → Natural language generation.

Additional Key Words and Phrases: attribution, formal languages, documentation generation, theorem proving, large language models

1 Introduction

Establishing that a program behaves as intended is a fundamental task in software engineering, especially for systems with stringent reliability requirements. Formal languages let developers state the properties a program should satisfy in precise mathematical notation and establish them by mechanized proof, and they have been applied to processors and systems software [Hunt et al. 2017]. Theorem provers such as ACL2 [Kaufmann et al. 2000], Lean [de Moura et al. 2015], Coq [The Coq Development Team 2025], and Isabelle/HOL [Nipkow et al. 2002] have accumulated large libraries of formally defined functions and proved theorems. The notation, however, is hard to read: to work out what a function does, a reader often has to unfold nested definitions, trace recursion, and piece together behavior that several theorems characterize only jointly. Formal libraries therefore need natural-language documentation alongside their definitions and proofs, so that developers can

Authors' Contact Information: Sirui Jiang, Zhejiang Sci-Tech University, Hangzhou, Zhejiang, China, 2024337621116@mails.zstu.edu.cn; Dongming Xiang, Zhejiang Sci-Tech University, Hangzhou, Zhejiang, China, dmxiang@zstu.edu.cn; Shichao Wu, Zhejiang Sci-Tech University, Hangzhou, Zhejiang, China, 2024210602019@mails.zstu.edu.cn; Yuxuan Zhou, Zhejiang Sci-Tech University, Hangzhou, Zhejiang, China, 2024316101003@mails.zstu.edu.cn; Yihong Wu, Zhejiang Sci-Tech University, Hangzhou, Zhejiang, China, yihongwu88@126.com; Fangze Zhu, Zhejiang Gongshang University, Hangzhou, Zhejiang, China, Zhufangz2402090131@163.com; Wang Lin, Zhejiang Sci-Tech University, Hangzhou, Zhejiang, China, linwang@zstu.edu.cn; Guanjun Liu, Tongji University, Shanghai, China, liuguanjun@tongji.edu.cn.

(a) ACL2: Restating the declared return type

(define implode ((x character-listp)) :returns (str stringp) ...) (defthm implode-no-longer (<= (len (implode x)) (len x))) "Under ACL2's len measure, the result of implode is no longer than the input."

(b) Lean: An instance of congruence

def canon (s : String) : String := ... theorem canon_congr {a b : String} (h : a = b) : canon a = canon b := by rw [h] "canon maps equal inputs to equal outputs."

Figure 1. Proved properties that hold regardless of the target's implementation

understand and reuse their functions [Davis and Kaufmann 2014]. Now that large language models (LLMs) generate documentation and properties at scale, the generated content is usually checked for correctness: whether it can be proved, or whether it is consistent with the code [Ma et al. 2025; Sun et al. 2024].

A documentation statement can, however, be provably true and still say nothing about the target function's specific behavior. Figure 1 shows two examples. For implode from the ACL2 Community Books, the statement "Under ACL2's len measure, the result of implode is no longer than the input" is backed by a proved theorem. But implode returns a string, and len returns 0 for strings, so every implementation that returns a string satisfies the statement. The statement that the Lean function canon maps equal inputs to equal outputs follows from equality substitution alone and holds for every function of the same type. Both statements paraphrase their theorems accurately, yet one conveys only a return type and the other only a general fact.

We call a statement’s dependence on the target function’s specific behavior attribution. To check it, we hold the function’s public interface (its input constraints and return type) and the background knowledge fixed and vary only the target’s behavior. A statement that holds for the target is attributable if it fails for at least one alternative implementation that satisfies the same interface; such an implementation, together with an input on which the statement fails, is a witness. A statement that follows from the interface and background knowledge alone is non-attributable: even when formally proved, it tells the reader nothing about the target’s behavior beyond the interface.

Attribution thus complements truth. Truth confirms that a statement holds for the target; attribution confirms that it describes behavior beyond the interface. Since callers can already see the interface, a statement about the target's behavior should say more than the interface does, which makes attribution a basic requirement for such statements. It is one quality dimension, orthogonal and complementary to importance, completeness, and readability, which together determine whether documentation is useful to developers; we focus on attribution.

Attribution answers a question that no existing measure answers: does a statement tell the reader anything about behavior beyond the interface (Table 1)? It does so by measuring each statement against the function's public interface. Every alternative implementation must satisfy this interface, so the alternatives range over precisely the behaviors a caller cannot rule out without reading the function body. Existing methods also test a conclusion by changing something, but none of them bounds the change by the interface. Mutation-based evaluation of specifications [Amaral et al. 2026; Endres et al. 2024] changes too little: it tries only a handful of edits to the function body, and these edits often leave the behavior a property describes untouched and need not satisfy the interface. Vacuity checking and semantic dependence [Beer et al. 2001; Podgurski and Clarke 1990] change too much: they replace a part with an unconstrained value and thus break the declared interface as well, so a statement that merely restates the return type would be “falsified” even though it adds nothing beyond the interface. Anchoring the check to the interface also backs both verdicts with checkable evidence. Non-attribution is established by a proof that covers every implementation satisfying the interface, which no finite set of mutants can provide; attribution is confirmed by a witness that itself satisfies the interface, which readers can check for themselves.

Table 1. Attribution compared with existing measures. √ guaranteed; ●depends on the selected variants; ✗ not guaranteed.

MeasureUnit of decisionReferenceQuestion answeredCan reject Figure 1 statements
Provability [Ma et al. 2025]Individual propertyOriginal targetCan the property be proved?✕
Mutation discrimination [Amaral et al. 2026; Endres et al. 2024; Goldweber et al. 2024]Property or whole specificationSelected code mutantsWhich tested implementations does it rule out?①
Vacuity and semantic dependence [Beer et al. 2001; Chockler et al. 2008; Podgurski and Clarke 1990]Property or program partChanges to a subformula or program partDoes the conclusion depend on the changed part?✕
Document-code equivalence [Eghbali et al. 2026; Zeng et al. 2026]Entire document or specificationOverall behavior of the original targetDo the two describe the same behavior?✕
Source support and consistency [Panthaplackel et al. 2021; Rashkin et al. 2023; Sun et al. 2024]Sentence or commentSource text or codeIs the statement supported and consistent?✕
Attribution (ours)Individual statementImplementations under the fixed interfaceDoes it add behavioral information beyond the interface?✓

Turning attribution into a check and using it for documentation poses three challenges. First, non-attribution is a claim about every implementation that satisfies the interface, including implementations not definable in the logic. We reduce it to a single proof in an erased environment, where the target is replaced by a fresh symbol constrained only by its interface (Lemma 1). Second, a witness must itself satisfy the interface, so arbitrary edits do not qualify. DocAuth builds alternative implementations from fixed templates over the function's arguments and has ACL2 prove that each one satisfies the interface. Third, documentation is prose, and rendering a property as a sentence can drop precisely the part that depended on the implementation. DocAuth therefore recovers a formal property from each rendered sentence, checks it again, and publishes only the sentences that pass, each with its recovered property and evidence.

On 150 functions from the ACL2 Community Books, three LLMs produce proved but non-attributable properties for about a third of the functions. Attributable properties also catch changes their check never saw: under interface-preserving code changes that differ from the witness templates, 64.8%64.8\% of attributable properties detect a change, compared with 15.3%15.3\% of the proved properties for which no witness is found and none of the non-attributable ones. At the sentence level, DocAuth raises the share of published sentences confirmed as attributable from 82.9%82.9\%, for a pipeline that checks truth alone, to 94.7%, and stays 9.3 points ahead when the reassessment model cannot see the code. It also delivers 37% more attributable sentences than a mutation-based filter. The two checks divide the work: rechecking the rendered sentences accounts for most of the rate gain, and selecting attributable candidates raises the number of attributable sentences.

This paper makes three contributions:

• A definition of attribution and a sound check for it. Relative to the public interface, we separate what the interface already states from what an individual statement adds. An erasure proof establishes non-attribution for all conforming implementations, and an interface-conforming witness confirms attribution.

• DocAuth, a documentation-generation method. It applies the check to candidate properties and to the properties recovered from rendered sentences, and publishes each sentence with its formal property and evidence.

• An empirical evaluation. Non-attributable properties occur in about a third of the functions, and attributable properties detect interface-preserving changes that the others miss. Pooled over the three generator models, DocAuth delivers the most attributable sentences at the highest attribution rate among the methods compared.

References (22)