arXiv:2610.02814cs.SEOct 2026

Manuscript Offprint

arXiv:2610.02814

VeriPy Source-Preserving Verification and Compatibility Checking for Python Components

Naing Oo Lwin

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

Abstract

Keeping a Python program and its formal guarantees aligned is a continuing maintenance problem. Specifications must describe the implementation that actually runs, and updates must preserve the behavior on which existing callers depend. VeriPy brings these obligations into a common workflow for annotated Python components. Developers and agents express contracts, invariants, and proof hooks as Python comments, then refine checked auxiliary lemmas using source-located diagnostics. Direct encoders produce Dafny or Lean artifacts while retaining admitted executable bodies and explicit models of their dependencies. A relational product checks whether an updated component still admits old inputs and preserves returned values and modeled exceptions. The resulting workflow connects source-level proof development with functional verification and backward compatibility, recording the assumptions under which each guarantee applies. The code is available at https://github.com/astrio-labs/veripy.

1 Introduction

Software maintenance changes the context in which a correctness guarantee must hold. A component may be verified against a contract and later replaced by an implementation that satisfies the same contract but behaves differently for its callers. Even before an update, the proof must account for the executable body, its dependencies, and the runtime assumptions under which the model applies. For Python, these concerns connect two verification problems. The first relates an existing component to its formal specification. The second relates successive versions through the behavior they expose.

Source-oriented verification provides a foundation for this connection. Frama-C supports C contracts through ACSL [9, 11], and Nagini verifies annotated Python through Viper [7, 16]. Verus separates executable, specification, and proof code in Rust [12]. Strata provides extensible analysis infrastructure in Lean, including Python analysis through its Laurel intermediate language [17]. These systems establish the value of keeping specifications close to programs. Our focus is the connection between proof development, preserved Python components, and compatibility with their earlier versions.

VeriPy makes the Python component the developer-facing unit of verification. Contracts, loop invariants, termination measures, and proof hooks appear as #@ comments alongside executable statements. Developers and agents use source-located diagnostics to refine annotations and auxiliary lemmas in checked sidecars. A typed admission gate and explicit dependency models determine the behavior represented by separate Dafny and Lean encoders. Backend checking establishes the generated obligations while admitted executable bodies remain available to native callers. Optional guards enforce supported input conditions. The proof report records the environment and assumptions needed to interpret the result as a guarantee about that component.

Compatibility adds an obligation that functional verification alone does not supply. A range postcondition, for example, allows multiple valid outputs and therefore cannot establish agreement between

NeurIPS 2026 Workshop on AI for Verifiable Coding.

versions. VeriPy constructs a relational product that checks admission of every old input and equality of returned values and modeled exception outcomes. Exact functional contracts and checked relation lemmas support this comparison. Reports distinguish a proved relation, a concrete native witness, an inconclusive attempt, and an unsupported boundary, so failure to construct or discharge a proof is not reported as a behavioral difference.

This paper contributes an implemented workflow connecting source-level proof assistance, explicit Python models, and scoped compatibility checking. Django’s base36 rewrite demonstrates the complete path from checked component contracts to a product proof across different algorithms. Repository studies examine proof support and native integration, while controlled maintenance trials separate old-proof access from available library information. Frozen history searches also expose unsuccessful transfer to unseen changes. Together, these results characterize what the workflow supports and where preparation and semantic coverage still limit automation.