Towards Cross-Language Verification Between Python and C
Authors:
Open Access
- 22 October 2026
- book chapter
- Published by Springer Nature
- p. 53-75
Abstract
In many modern software systems, programs are written in multiple languages to balance performance and productivity. For the CPython runtime, modules are frequently implemented in C to enhance execution speed or interface with existing libraries. To ensure the correctness of such modules, developers must not only implement the intended functionality and maintain memory safety but also adhere to API rules and preserve runtime invariants. In this paper, we present the first cross-language deductive verification technique for Python modules written in C. We define high-level semantic specification constructs and use them to bridge the abstraction gap between the two languages, translating Python contracts for the Nagini verifier into corresponding C contracts for VeriFast. We further provide a formal specification of a subset of the Python C API to ensure safety and the preservation of critical invariants, such as correct reference counting. We evaluate our implementation through a case study, demonstrating that our approach can successfully verify realistic “glue code” used in multi-language applications.Keywords
This publication has 20 references indexed in Scilit:
- Challenges of Multilingual Program Specification and Analysis2024
- Contract-LIB: A Proposal for a Common Interchange Format for Software System Specification2024
- Joining Forces! Reusing Contracts for Deductive Verifiers Through Automatic Translation2023
- A Multilanguage Static Analysis of Python Programs with Native C Extensions2021
- SecCSL: Security Concurrent Separation Logic2019
- Nagini: A Static Verifier for Python2018
- The VerCors Tool for Verification of Concurrent Programs2014
- VCC: A Practical System for Verifying Concurrent C2009
- Boogie: A Modular Reusable Verifier for Object-Oriented Programs2006
- Checking Interference with Fractional Permissions2003