The CoCompiler: DSL Lifting via Relational Compilation

📅 2025-09-30
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This paper addresses the challenges of understanding, verifying, and safely evolving low-level C code in reactive systems. It proposes a domain-specific language (DSL) uplift technique based on relational programming to enable bidirectional, semantics-preserving compilation between C and the synchronous dataflow language Lustre. Methodologically: (1) the verified Lustre-to-C compiler Vélus is reformulated as a relational specification in Walrus; (2) a semantics-preserving C normalization pass is implemented in Haskell, enabling uplift of real-world C code—including constructs with undefined behavior and pointers—to Lustre. Contributions include: the first application of relational programming to DSL uplift, unifying solutions for both vertical uplift (specification C → Lustre) and horizontal uplift (legacy C → Lustre); a modular, language-agnostic tool supporting rapid prototyping; and successful application to industrial reactive C code, yielding formally verifiable Lustre models and graphical behavioral representations.

Technology Category

Application Category

📝 Abstract
Lifting low-level or legacy code into a domain-specific language (DSL) improves our ability to understand it, enables deeper formal reasoning, and facilitates safe modification. We present the CoCompiler, a bidirectional compiler and lifter between C and Lustre, a synchronous dataflow language used for reactive systems. The key insight behind the CoCompiler is that writing a compiler as a relation, rather than as a traditional function, yields a DSL lifter "for free". We implement this idea by rewriting the verified Lustre-to-C compiler Vélus in the Walrus relational programming language. This solves what we call the vertical lifting problem, translating canonical C into Lustre. To address the complementary horizontal problem-handling real-world C outside the compiler's image-we apply semantic-preserving canonicalization passes in Haskell. The resulting tool, the CoCompiler, supports lifting real reactive C code into Lustre and onward into graphical behavioral models. Our approach is modular, language-agnostic, and fast to implement, demonstrating that relational programming offers a practical foundation for building DSL lifters by repurposing existing compilers.
Problem

Research questions and friction points this paper is trying to address.

Lifting low-level C code into domain-specific language Lustre
Solving vertical lifting problem through relational compilation
Handling real-world C code via semantic-preserving canonicalization
Innovation

Methods, ideas, or system contributions that make the work stand out.

Bidirectional compiler using relational programming
Rewriting verified compiler in relational language
Semantic-preserving canonicalization for real-world code
🔎 Similar Papers
No similar papers found.
N
Naomi Spargo
Galois, Inc., USA
S
Santiago Cuéllar
Galois, Inc., USA
J
Jonathan Daugherty
Galois, Inc., USA
C
Chris Phifer
Galois, Inc., USA
David Darais
David Darais
Galois, Inc.
Programming LanguagesProgram AnalysisMechanized Proofs