A Haskell Adiabatic DSL: Solving Classical Optimization Problems on Quantum Hardware
In physics and chemistry, quantum systems are typically modeled using energy constraints formulated as Hamiltonians. Investigations into such systems often focus on the evolution of these Hamiltonians under various initial conditions, an approach summarized as Adiabatic Quantum Computing (AQC). Although this perspective may initially seem foreign to functional programmers, we demonstrate that conventional functional programming abstractions—specifically, the Traversable and Monad type classes—naturally capture the essence of AQC. To illustrate this connection, we introduce EnQ, a functional programming library designed to express diverse optimization problems as energy constraint computations (ECC). The library comprises three core components: generating the solution space, associating energy costs with potential solutions, and searching for optimal or near-optimal solutions. Because EnQ is implemented using standard Haskell, it can be executed directly through conventional classical Haskell compilers. Moreover, we develop and implement a process to compile EnQ programs into quantum circuits. We further validate EnQ ’s effectiveness through comprehensive case studies, demonstrating its capacity to express and solve classical optimization problems, including search problems, type inference, number partitioning, clique finding, and graph coloring.