Several software systems are polyglot; that is, they comprise programs implemented in a combination of programming languages. Verifiers that directly run on mainstream programming languages are currently customized for single languages. Thus, to verify polyglot systems, one usually translates them into a common verification language or formalism on which the verifier runs. In this paper, we present an alternative approach, PolyVer, which employs abstraction, compositional reasoning, and synthesis to directly perform polyglot verification. PolyVer constructs a formal model of the original polyglot system as a transition system where the update functions associated with transitions are implemented in target languages such as C or Rust. To perform verification, PolyVer then connects a model checker for transition systems with language-specific verifiers (e.g., for C or Rust) using pre/post-condition contracts for the update functions. These contracts are automatically generated by synthesis oracles based on syntax-guided synthesis or large language models (LLMs), and checked by the language-specific verifiers. The contracts form abstractions of the update functions using which the model checker verifies the overall system-level property on the polyglot system model. PolyVer iterates between counterexample-guided abstraction-refinement (CEGAR) and counterexample-guided inductive synthesis (CEGIS) until the property is verified or a true system-level counterexample is found. We demonstrate the utility of PolyVer for verifying programs in the Lingua Franca polyglot language using the UCLID5 model checker connected with the CBMC and Kani verifiers for C and Rust respectively.
PolyVer: A Compositional Approach for Polyglot System Modeling and Verification
- Paper ID: 2503.03207
- Title: PolyVer: A Compositional Approach for Polyglot System Modeling and Verification
- Authors: Pei-Wei Chen, Shaokai Lin, Adwait Godbole, Ramneet Singh, Elizabeth Polgreen, Edward A. Lee, Sanjit A. Seshia
- Classification: cs.PL (Programming Languages)
- Publication Venue/Conference: Formal Methods in Computer-Aided Design 2025
- Paper Link: https://arxiv.org/abs/2503.03207
Polyglot software systems are composed of programs implemented in multiple programming languages, yet existing program verifiers are typically tailored to single languages. To verify polyglot systems, translation to a common verification language or formal representation is usually required. This paper proposes PolyVer, an alternative approach that performs polyglot verification directly using abstraction, compositional reasoning, and synthesis techniques. PolyVer models polyglot systems as formal transition systems where transition-related update functions are implemented in target languages (such as C or Rust). To perform verification, PolyVer connects a model checker for transition systems with language-specific verifiers through pre/post-condition contracts on update functions. These contracts are automatically generated through synthesis oracles based on syntax-guided synthesis or large language models, and are checked by language-specific verifiers.
Modern software systems increasingly adopt polyglot architectures, where frameworks like ROS2 and Lingua Franca allow developers to select the most suitable programming language for different components. However, this flexibility introduces verification challenges:
- Language Semantic Differences: Different programming languages have distinct syntax and semantics. For example, Rust's
saturating_add function saturates to the maximum value on overflow, while C addition may wrap around. - Limitations of Existing Verifiers: Most program verifiers (such as CBMC for C, Kani for Rust) are specifically designed for single languages and cannot directly handle polyglot systems.
- Translation Complexity: Translating an entire polyglot system to a single verification language requires supporting the complete syntax and semantics of all languages, which is prohibitive for modern languages.
The increased complexity of polyglot systems raises the risk of software defects. In safety-critical domains (such as autonomous driving and aerospace), formal verification provides stronger guarantees than incomplete methods like testing alone.
- Monolithic Translation Methods: Require developing complete compiler infrastructure for each language
- Semantic Preservation Difficulty: Challenging to faithfully capture all language-specific constructs from source languages in target verification languages
- Scalability Issues: Generated verification problems may become prohibitively large
- Formalization of Polyglot Verification Problem: First systematic formalization of the polyglot verification problem and proposes a compositional solution integrating multiple language-specific verifiers.
- Automated Contract Synthesis: Proposes automatic synthesis and refinement of pre/post-condition contracts using intermediate languages and CEGIS-CEGAR loops, supporting both syntax-guided synthesis and large language models as synthesis oracles.
- Tool Implementation: Implements PolyVer tool based on UCLID5, supporting C and Rust through CBMC and Kani verifiers, demonstrating that LLM-based synthesis oracles outperform pure symbolic synthesis methods.
- Case Studies and Evaluation: Develops a verifier for the Lingua Franca coordination language, verifies polyglot systems containing C and Rust processes, and handles C language fragments that previous work could not support.
Input: Polyglot model M = (Q,V,I₀,T,F) and system property φ
Output: Verification result (pass/fail) and possible counterexample trace
Objective: Determine whether M ⊨ φ holds
Where:
- Q: Set of modes
- V: Set of typed variables
- I₀: Set of initial states
- T: Set of mode transitions
- F: Set of procedures
PolyVer models polyglot systems as extended state machines where:
- States consist of modes and variable assignments
- Transitions are associated with guard conditions and update relations
- Update relations specialize into procedure call sequences
A key innovation is introducing intermediate language L* as "glue" between different languages:
- Contracts are written in L*
- Transformed to concrete languages through semantics-preserving compilation compL
- Avoids complexity of complete language translation
The algorithm core consists of two-layer iterative loops:
Outer CEGAR Loop:
- Construct abstract model M' using current contracts
- Model checker verifies M' ⊨ φ
- If verification fails, check whether counterexample is spurious
- If spurious, refine contracts; otherwise report genuine counterexample
Inner CEGIS Loop:
- Synthesis oracle generates candidate contracts
- Verification oracle checks contract validity
- If invalid, add positive examples and re-synthesize
Unlike monolithic translation, PolyVer adopts a "divide-and-conquer" strategy:
- Use contracts to abstract individual procedures
- Language-specific verifiers verify contract validity
- Model checker verifies system-level properties
Supports multiple synthesis oracles:
- LLM-based Synthesizer: Uses chain-of-thought prompting and Python DSL
- SyGuS/SyMO Synthesizer: Encodes problems as syntax-guided synthesis problems
Distinguishes genuine counterexamples from spurious ones by verifying {V = d} C {V' ≠ d'} to check reachability of counterexample traces.
- LFVerifier Benchmark: 22 Lingua Franca programs with restricted C syntax
- Complete LF Examples: LED controller, climbing robot, satellite attitude controller, and other embedded systems
- Polyglot Systems: C/Rust mixed LF programs, ROS2 applications, FFI cross-language call programs
- Number of synthesis iterations (IS: CEGIS iterations, AR: CEGAR iterations)
- Runtime (SOT: synthesis oracle time, VOT: verification oracle time, UT: UCLID5 time)
- Verification success rate
Compared with LFVerifier15, the only known end-to-end automated LF program verification tool.
- OpenAI o1-mini as LLM synthesizer with 3 parallel queries per procedure
- CBMC-6.3.1, Kani-0.56.0, z3-4.8.7 as verification backends
- 3.7GHz Intel Core i9 machine with 62GB RAM
On 22 benchmark tests:
- PolyVer successfully verifies all benchmarks; LFVerifier fails on TrafficLight example
- 18 benchmarks synthesize contracts correctly in single CEGIS iteration, averaging 37 seconds
- Although total runtime is slower (primarily dominated by contract synthesis time), provides significant qualitative improvements
Successfully verifies embedded systems with complete C code:
- LED Controller: 1 procedure, 123 lines of C code, 31.0 seconds synthesis time
- Climbing Robot: 12 procedures, 75 lines of C/Rust code, 685.4 seconds synthesis time
- Satellite Controller: 6 procedures, 424 lines of C code, 729.0 seconds synthesis time
Verifies genuinely polyglot systems:
- C/Rust mixed LF programs
- ROS2 service applications
- FFI cross-language call programs
- LLM Outperforms Symbolic Methods: SyGuS/SyMO solvers require numerous CEGAR iterations and frequently fail to terminate
- Contract Synthesis Challenges: Procedures with complex control flow and data dependencies require more iterations
- Practical Validation: Can handle real implementation code rather than toy examples
- Manual Translation Methods: Cook et al. translated assembly code to C to verify Xen virtual machine monitor
- Automatic Fragment Translation: LFVerifier automatically translates C fragments to verification languages
- Black-box Methods: Infer summaries from input-output behavior
- Compositional verification based on Hoare logic widely applied to large-scale single-language programs
- Automated pre/post-condition learning using abstract interpretation and CEGAR
- Property-directed contract inference methods
- Constrained Horn clause solvers
- Recent applications of LLMs in specification learning
- PolyVer successfully addresses key challenges in polyglot system verification
- Compositional approach avoids complexity of complete language translation
- Automated contract synthesis makes the method practical
- LLM-based synthesizers outperform traditional symbolic methods
- Termination: Algorithm does not guarantee termination, depends on synthesis oracle quality
- Language Support: Currently supports only C and Rust; requires developing verification oracles for other languages
- Contract Expressiveness: Expressiveness of intermediate language L* limits complexity of verifiable properties
- Scalability: Contract synthesis time for large systems may become a bottleneck
- Extend to other polyglot distributed software systems and robotic software systems
- Apply to formal verification of code translation (e.g., C to Rust translation)
- Improve efficiency and accuracy of contract synthesis
- Support more complex temporal logic properties
- Problem Importance: Polyglot system verification is a practical and important problem
- Methodological Innovation: Combination of compositional verification and automated contract synthesis is novel
- Theoretical Foundation: Clear formal definitions with explicit correctness guarantees
- Practical Value: Handles real systems rather than toy examples
- Tool Implementation: Provides usable tool implementation
- Performance Overhead: Contract synthesis time is lengthy, potentially limiting practical applications
- Language Coverage: Currently supports only C and Rust; extensibility remains to be verified
- Limited Benchmarks: While including real examples, scale is relatively small
- LLM Dependency: Relies on commercial LLM services, potentially affecting reproducibility
- Academic Contribution: Opens new research direction for polyglot system verification
- Practical Value: Provides verification tools for safety-critical polyglot systems
- Technical Inspiration: Idea of contracts as language interfaces has universal value
- Embedded Systems: Real-time systems mixing C/Rust
- Distributed Systems: ROS2, gRPC, and other polyglot frameworks
- Safety-Critical Applications: Systems requiring formal verification guarantees
- Legacy System Integration: Systems mixing old and new code
The paper cites 50 related works covering multiple domains including polyglot systems, formal verification, contract inference, and syntax-guided synthesis, providing solid theoretical foundation for the research.
Overall Assessment: This is a high-quality systems research paper addressing an important and practical problem. The methodology is innovative, experiments are comprehensive, and tool implementation is complete. While there is room for improvement in performance and scalability, it makes significant contributions to the polyglot system verification field.