Optimizing Optimizations, Declaratively: Optimizing the Higher-Order Functions in Mathematical Optimization with egglog

📅 2026-05-18
📈 Citations: 0
✨ Influential: 0
📄 PDF
🤖 AI Summary
This work addresses the challenges posed by higher-order functions in mathematical optimization modeling, which often lead to unnatural LaTeX output and inefficient constraint verification. To overcome these issues, the authors propose an egglog-based optimization approach that performs desugaring reconstruction on the λ-calculus intermediate representation of JijModeling 2, thereby recovering comprehension-like syntactic structures. By integrating Henkin-style constants with Datalog-inspired rules, the method enables declarative, multi-step constraint checking. A custom cost model and equality saturation techniques are introduced to enhance performance significantly: the generated LaTeX aligns more closely with conventional mathematical notation, and complex constraint validation—previously requiring minutes or failing to terminate—now completes within seconds.
📝 Abstract
We present two applications of egglog to mathematical optimization in JijModeling 2, a mathematical modeller whose internal representation is based on simply typed $λ$-calculus. First, we use egglog to improve $\LaTeX$ output for mathematical models expressed with higher-order functions. Python comprehensions are desugared into stream operations such as $\textsf{map}$, $\textsf{flat_map}$, and $\textsf{filter}$; emitting these terms directly produces unnatural mathematical notation. We reconstruct comprehension syntax by \emph{ensugaring} higher-order terms and use equality saturation with a custom cost model to minimize temporary variable rebindings. Second, we use egglog as a declarative engine for \emph{constraint detection}, extending the previous egg-based approach presented at EGRAPHS '25. Egglog's datalog-style rules let us express multi-step detection logic directly, without external Rust orchestration code. We encode parametrized constraints using \emph{Henkin-like constants} and propagate side conditions on subterms and indices through egglog facts. Finally, we show that the same ensugaring procedure also reduces large domain-set conditions before saturation, turning a problematic detection case from minutes or nontermination into a few seconds. Through these topics, we want to provide an example of an industrial application of egglog, demonstrate the trick to propagate the constraints using the ideas from mathematical logic, and show the importance of optimizing \emph{premises} of egglog rules to get practical performance in egglog programs.
Problem

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

mathematical optimization
higher-order functions
constraint detection
equality saturation
egglog
Innovation

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

egglog
ensugaring
equality saturation
constraint detection
higher-order functions
🔎 Similar Papers
No similar papers found.
💼 Related Jobs
No related jobs found.
H
Hiromi Ishii
JIJ Inc., Minato-ku, Tokyo, Japan