← Latest papers
💻 computer science

DSLean: A Framework for Type-Correct Interoperability Between Lean 4 and External DSLs

The paper introduces DSLean, a framework that simplifies the bidirectional translation between Lean 4 and external domain-specific languages by abstracting implementation details, thereby enabling the seamless integration of external solvers for tasks like interval arithmetic, differential equations, and ring ideal membership.

Original authors: Tate Rowney, Riyaz Ahuja, Jeremy Avigad, Sean Welleck

Published 2026-03-02
📖 5 min read🧠 Deep dive

Original authors: Tate Rowney, Riyaz Ahuja, Jeremy Avigad, Sean Welleck

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are a brilliant architect (the Lean Proof Assistant) who speaks a very precise, strict language called "Formal Logic." You are designing a building that must be mathematically perfect. However, you have a problem: you need help from specialized construction crews (external solvers) who are experts in specific tasks, like calculating the stress on a bridge (interval arithmetic) or solving complex fluid dynamics (differential equations).

The problem? These construction crews speak completely different languages. They don't understand your strict "Formal Logic," and you don't understand their messy, specialized jargon. Usually, to get them to work together, you'd have to hire a human translator to sit between you, manually rewriting every single sentence, checking every number, and hoping no mistakes are made. This is slow, boring, and prone to errors.

Enter DSLean.

Think of DSLean as a magical, universal translator and a smart construction manager rolled into one. It's a framework that lets your architect (Lean) and the specialized crews (external tools) talk to each other instantly and accurately, without needing a human to manually rewrite the blueprints.

Here is how it works, broken down with some everyday analogies:

1. The "Dictionary" Approach (No More Manual Rewriting)

In the past, if you wanted Lean to talk to a tool like Gappa (which checks numbers) or Macaulay2 (which handles algebra), you had to write hundreds of lines of complex code to translate every single symbol. It was like manually translating a dictionary word-by-word for every new book you wanted to read.

DSLean changes the game. You simply give it a "dictionary" or a "rulebook." You tell it:

  • "When you see the word 'True' in the external language, treat it as 'True' in Lean."
  • "When you see 'not' in the external language, treat it as '¬' in Lean."

That's it. DSLean takes this simple list and figures out the rest. It handles the messy details of grammar, punctuation, and complex sentence structures automatically. It's like giving a translator a list of key phrases and letting them figure out the rest of the conversation based on context.

2. The "Two-Way Street" (Round-Trip Consistency)

One of the coolest things about DSLean is that it works both ways.

  • Lean → External: You can take a complex math problem in Lean, turn it into a simple sentence the external tool understands, send it off, and get an answer back.
  • External → Lean: The external tool sends back a solution (like a proof certificate). DSLean takes that solution, translates it back into Lean's strict language, and checks to make sure it fits perfectly.

Imagine sending a letter to a friend in another country. Usually, you might worry the translation will get lost in the mail. DSLean ensures that if you send a letter out and get a reply back, the meaning is exactly the same as if you had written it yourself.

3. The Three "Super-Tools" Built with DSLean

The authors didn't just build the translator; they used it to build three specific "super-tools" (called tactics) to solve hard math problems:

  • The "Gappa" Tool (The Safety Inspector):

    • The Problem: Proving that a number stays within a safe range (e.g., "This bridge won't collapse because the weight is between 10 and 20 tons").
    • The Solution: DSLean translates the problem to Gappa, a tool that is a master at checking these ranges. Gappa does the heavy lifting, sends the proof back, and DSLean translates it into a formal proof Lean can accept.
    • Analogy: It's like hiring a safety inspector who speaks "Safety Code" to check your building plans, then translating their report into "Architect's Blueprints."
  • The "Desolve" Tool (The Physics Solver):

    • The Problem: Solving equations that describe how things change over time (like how a cup of coffee cools down).
    • The Solution: This connects to SageMath, a powerful math engine. It sends the equation over, gets the general solution back, and translates it into Lean.
    • Analogy: It's like asking a genius physicist to solve a complex motion problem, then having them write the answer in a language your computer can read.
  • The "Lean_M2" Tool (The Algebra Detective):

    • The Problem: Figuring out if a complex algebraic expression belongs to a specific group of numbers (an "ideal"). This is very hard for standard computers.
    • The Solution: It talks to Macaulay2, a specialist in algebra. Macaulay2 finds the answer, and DSLean translates the "witness" (the proof of membership) back to Lean.
    • Analogy: It's like asking a master puzzle solver to find a hidden piece in a giant jigsaw puzzle, then bringing that piece back to show you exactly where it fits.

Why Does This Matter?

Before DSLean, connecting these tools was like trying to build a bridge between two islands using only duct tape and hope. It required expert engineers (Lean programmers) to spend weeks writing custom code for every single connection.

DSLean is like building a permanent, sturdy bridge.

  • It's fast: You can set up a new connection in minutes instead of weeks.
  • It's safe: It automatically checks that the translation makes sense mathematically.
  • It's simple: You don't need to be a master coder to use it; you just need to define the rules.

In short, DSLean is the "Rosetta Stone" for the world of computer math, allowing different specialized tools to work together seamlessly to solve problems that were previously too difficult or tedious to tackle.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →