DSLean: A Framework for Type-Correct Interoperability Between Lean 4 and External DSLs
Lean tactics that rely on external solvers must translate between Lean expressions and the solver's domain-specific language. Writing these translations takes bespoke meta-level parsing and elaboration code that is hard to maintain and requires Lean metaprogramming expertise.
DSLean is a framework written entirely in Lean. Users declare equivalences between external syntax patterns and Lean terms. Translation out of Lean works by recursively partially matching expressions against these patterns. Translation into Lean parses raw text with Lean's native parser and combines the matched pieces via metavariable unification, which enforces type-correctness and handles implicit arguments, polymorphism, and postponed elaboration.
Three tactics were built on DSLean. gappa translates Rocq-syntax certificates from the Gappa interval arithmetic solver into Lean proofs. desolve uses SageMath to obtain general solutions to ordinary differential equations. lean_m2 uses Macaulay2 to supply witnesses for ring ideal membership and Gröbner basis problems. Each tactic has a short, readable implementation.
