Introduction
Modern software systems are increasingly "polyglot," integrating components written in diverse languages to leverage specific strengths—such as Rust for memory safety and C for low-level hardware interaction. However, verifying these heterogeneous systems is notoriously difficult. Traditional formal verification tools are often monolithic, requiring a complex and error-prone translation of the entire codebase into a single logic. PolyVer introduces a compositional framework that sidesteps this "translation nightmare" by synthesizing formal contracts for individual components, allowing language-specific verifiers to cooperate seamlessly.
The Challenge: The Polyglot Verification Gap
Frameworks like ROS2 and Lingua Franca enable developers to mix languages, but formal verification tools have struggled to keep pace. Most existing tools require translating every line of code into a common intermediate representation. This approach often fails because modern languages have fundamentally different semantics (e.g., Rust's ownership model vs. C's manual memory management). Consequently, verifying a multi-language system often leads to state-space explosion or model inaccuracies that can crash the verifier.
Methodology: Composition over Translation
PolyVer shifts the paradigm from global translation to local composition. It treats each language-specific component as a "black box" defined by an interface contract—a set of formal pre-conditions and post-conditions.
The framework relies on four key pillars:
- Intermediate Contract Language ($L^*$): A minimalist language used to define contracts. $L^*$ is simple enough to be translated into the specific syntax required by C verifiers, Rust verifiers, or general-purpose model checkers.
- Language-Specific Verifiers (LSVs): PolyVer leverages existing, high-fidelity tools. It uses CBMC for C and Kani for Rust to prove that a specific implementation satisfies its $L^*$ contract.
- UCLID5 Model Checker: This tool manages the "big picture," using the verified contracts to prove that the overall system satisfies global safety properties, such as ensuring a robotic arm never exceeds its physical boundaries.
- Automated Synthesis via LLMs: Manually writing formal contracts is a significant bottleneck. PolyVer automates this using a CEGIS/CEGAR loop (Counterexample-Guided Inductive Synthesis/Abstraction Refinement). It employs Large Language Models (LLMs), such as OpenAI’s o1-mini, as "synthesis oracles" to propose candidate contracts based on the source code.
Key Insights: Abstraction and Robustness
The power of PolyVer lies in its use of abstraction. By focusing on interface contracts rather than full code translation, it avoids the semantic gap between languages. Furthermore, the integration of LLMs is made robust through formal checking: if an LLM "hallucinates" an incorrect contract, the LSV (CBMC or Kani) will reject it and provide a counterexample, which is then fed back to the LLM to refine the next proposal. This hybrid approach allows PolyVer to handle complex code—including library functions like atan and complex control flows—that typically stymie pure symbolic solvers.
Evaluation and Results
The authors evaluated PolyVer across 22 Lingua Franca benchmarks and several real-world C/Rust applications, including a satellite altitude controller and a hill-climbing robot. Key findings include:
- Superior Coverage: PolyVer successfully verified all 22 benchmarks, including cases where previous state-of-the-art tools like LFVerifier failed (e.g., the "TrafficLight" example).
- Multi-Language Support: The framework demonstrated its ability to verify systems where components were split between C and Rust, proving its utility for modern heterogeneous software.
- Efficiency: The synthesis loop is highly efficient; most contracts were generated in a single iteration, with an average synthesis time of approximately 37 seconds for standard benchmarks.
Conclusion and Future Work
PolyVer demonstrates that compositional verification, aided by LLM-driven synthesis, is a viable and scalable path for securing polyglot systems. While the framework currently relies on the soundness of underlying tools like CBMC and Kani, it provides a robust foundation for future work. The authors plan to extend PolyVer to larger distributed systems (e.g., ROS2) and explore its potential for "verified translation," where code is formally migrated between languages in a provably correct manner.
Summary updated