HackerPapers

arXiv:2406.03003cs.PL

Verified Code Transpilation with LLMs

Sahil Bhatia, Jie Qiu, Niranjan Hasabnis, Sanjit A. Seshia, Alvin Cheung

HN submission. Found in a submission link or body. Submitters do not count as commenters in the main ranking; a submission is not an endorsement.

Abstract

Domain-specific languages (DSLs) are integral to various software workflows. Such languages offer domain-specific optimizations and abstractions that improve code readability and maintainability. However, leveraging these languages requires developers to rewrite existing code using the specific DSL's API. While large language models (LLMs) have shown some success in automatic code transpilation, none of them provide any functional correctness guarantees on the transpiled code. Another approach for automating this task is verified lifting, which relies on program synthesis to find programs in the target language that are functionally equivalent to the source language program. While several verified lifting tools have been developed for various application domains, they are specialized for specific source-target languages or require significant expertise in domain knowledge to make the search efficient. In this paper, leveraging recent advances in LLMs, we propose an LLM-based approach (LLMLift) to building verified lifting tools. We use the LLM's capabilities to reason about programs to translate a given program into its corresponding equivalent in the target language. Additionally, we use LLMs to generate proofs for functional equivalence. We develop lifting-based compilers for {\em four different} DSLs targeting different application domains. Our approach not only outperforms previous symbolic-based tools in both the number of benchmarks transpiled and transpilation time, but also requires significantly less effort to build.

arXiv comments
Journal reference
DOI
Subjects
cs.PLProgramming Languages

On Hacker News

No comments linking this paper were found in the collected sources. Found in 2 HN submissions from Jun 2024 to Feb 2025. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments0 threads

No comments linking this paper were found in the collected sources. Open submission discussions.

Submitted to Hacker News

  • Verified Code Transpilation with LLMs
  • Ask HN: How do I learn more about LLM-assisted transpilation (e.g. Python->C)?

    I’ve been experimenting with Flet (a Python framework for Flutter) to quickly prototype cross-OS apps, mostly to easily get to iOS. It turns out Flet/Flutter is not great on iOS, and a number of packages don't work on iOS (PyTorch, Sentence-Transformer along with more usual ones). I got frusterated and had Aider+Claude just rebuild my app in Swift (+ some server calls for sentence-transformer) and it worked surprisingly quickly (and almost well)! This got me thinking ... maybe the future is…

Connected through shared HN threads, not inferred similarity or a recommendation.