C-to-Rust Translation Validation at the LLVM IR Level via AI-Assisted Refinement Proof
Eunsu Kim, Sukyoung Ryu, Jaemin Hong
Abstract
Migrating C codebases to Rust is a promising approach to securing legacy software, but existing translators do not guarantee that a translated Rust program preserves the behavior of the C program. Neither rule-based nor large language model (LLM)-based translators have been formally verified, and existing approaches to checking translation correctness are limited to testing and bounded checks, which cannot reason about all possible executions. In this work, we present R2C2, which validates C-to-Rust translation by proving in Rocq that the Rust program refines the C program, i.e., every behavior on the Rust side is also a behavior on the C side. Since no formal semantics defines the behaviors of C and Rust programs in the same terms, we prove refinement between the two programs compiled to the LLVM intermediate representation (LLVM IR). In addition, to resolve the discrepancies between the data representations of C and Rust, we introduce a common abstraction that relates two corresponding representations through an abstract value, and specify the behavior of each library function over abstract values. We construct the refinement proof as a chain of refinement relations, where only one relation is program-specific and proved at validation time, while the others are proved for all programs in advance. Proof construction is automated by AI agents, and since Rocq checks the proofs, the agents need not be trusted. We evaluate R2C2 on LLM translations of 519 C programs drawn from a benchmark suite used in prior work on C-to-Rust translation validation. R2C2 proves the translations of 486 programs correct without bounding their executions and discovers three incorrect translations, providing valid counterexamples that existing translation validation tools cannot find. We also conduct a case study on a small real-world image compression library and demonstrate how R2C2 can handle file operations.
Create a lesson
Related papers
Lifting the Preprocessor with Oxidize: Structure-Preserving C-to-Rust Translation (Technical Report)
Shared title terminology · Robbe De Greef, Théo Engels, Felix Van den Broucke et al.
Crustify: Repository-Level Generation of Safe Rust Bindings with LLM Agents and Coverage-Guided Testing
Shared title terminology · Marius Momeu, Marius Arvinte, Cory Cornelius et al.
Blame-aware Recomposition for Secure Compilation Proofs of Low-Level Compartment Isolation
Shared title terminology · Basile Schlosser, Jérémy Thibault, Catalin Hritcu
RESOLVE: Language-Agnostic Validation of GPU Kernels Through Testing, Reduction, and Proof
Shared title terminology · Ashkan Vedadi Gargary, Guido Martínez, Sebastian Burckhardt et al.
Validating Concurrent Correctness Witnesses with Ghosts by Thread-Modular Abstract Interpretation
Shared title terminology · Michael Schwarz, Zhendong Ang, Umang Mathur
MetaphIR: Corpus-Scale Applicability Analysis for LLVM Peephole Optimizations
Shared title terminology · Hongxu Xu, Xintong Zhou, Chunhao Liao et al.