Papers
Topics
Authors
Recent
Search
2000 character limit reached

Answer Set Programming for Egg Extraction and More

Published 9 Jun 2026 in cs.PL and cs.LO | (2606.10644v1)

Abstract: Three years ago, Philip Zucker posted an attempt to use answer set programming (ASP) for term extraction from e-graphs Although the task is NP-hard and ASP offers a natural modelling of e-graph terms, the initial attempt did not yield convincing results. From the aspect of practical ASP users, we first pinpoint the way to make ASP work and work well on the task of e-graph extraction. The initial results show the naïve ASP encoding is comparable on efficiency to the well-optimised ILP-based exact DAG extraction in the extraction-gym, and find several extra optimal extraction on the complex instances. This leads us to a further agenda: with the "better together of egg+Datalog", is there a better "better together" by having ASP as a more powerful Datalog? We discuss the potential benefit from each other.

Authors (2)

Summary

  • The paper demonstrates that optimized ASP encodings yield competitive DAG extraction performance compared to ILP, addressing key scalability challenges.
  • It details both bottom-up and top-down encoding strategies, leveraging Clingo's unsat-based optimization and propagators to enforce acyclicity efficiently.
  • The study highlights ASP's potential for integration with equality saturation workflows, paving the way for unified, cost-aware extraction systems.

Answer Set Programming for E-Graph Extraction: Techniques, Results, and Integration

Introduction

The paper "Answer Set Programming for Egg Extraction and More" (2606.10644) examines the utility of Answer Set Programming (ASP) for the NP-hard problem of term extraction from e-graphs, a central component in equality saturation systems. It reassesses earlier attempts by Zucker to use ASP for this task, which suffered in scalability, and presents optimized encoding strategies and solver configurations that provide competitive efficiency and solution quality compared to established Integer Linear Programming (ILP) baselines. The work further situates ASP as a potential generalization of Datalog in equality saturation workflows and explores prospects for deep integration.

ASP Encodings for DAG Extraction in E-Graphs

E-graph DAG extraction focuses on identifying an optimal subgraph with minimum cost, preserving acyclicity and congruence closure properties. The paper reviews both bottom-up and top-down ASP encodings:

  • Bottom-Up Encoding: Leverages ASP's stable-model semantics to guarantee acyclicity via founded selection, avoiding explicit reachability constraints and presenting concise relations and rules. This supports robust enforcement of global sharing constraints in DAGs.
  • Top-Down Encoding: More intuitive in marking root classes and propagating demand-driven support, but naive reachability constraints lead to intractable O(n3)O(n^3) overheads on large strongly connected components.

The key challenge is enabling efficient cycle detection and elimination, which is crucial for correctness in DAG extraction.

Solver-Oriented Pragmatic Solutions

The paper demonstrates that with the adoption of Clingo's unsatisfiability-based optimization (USC) and parallel solving, bottom-up ASP encoding achieves efficiency and solution quality comparable to highly optimized ILP solvers. For the top-down encoding, imperative propagators in Clingo are used to offload acyclicity checks, bypassing transitive closure bottlenecks. Notably, these enhancements enable ASP to scale competitively on real-world e-graph extraction benchmarks.

Benchmarking Results and Numerical Outcomes

Evaluation against extraction-gym suites (babble, herbie, rover) establishes several concrete findings:

  • Solution Quality: Both top-down (asp-td) and bottom-up (asp-bu) ASP encodings matched or outperformed the ILP baselines in number of instances with strictly better DAG cost than greedy methods. Bottom-up ASP found additional optimal extractions on high-root instances, revealing its distinct search advantages.
  • Runtime Performance: The propagator-based top-down ASP encoding is generally faster, with bottom-up ASP only advantageous on select root-heavy instances. The ILP baselines (naive and optimized) trade speed for solution quality, with the optimized variant being highly case-sensitive.
  • Strong Claims: The ASP approach, with proper configuration, is comparable to optimized ILP for exact extraction despite prior negative assessments of scalability.

ASP's limitation with weak constraints (integer-only optimization) precludes direct application to non-integral cost e-graphs, but potential for solver engineering hooks through the Clingo API parallels non-solver ILP optimizations.

ASP and Datalog: Toward Richer Integration

By combining equality saturation's congruence-closed e-graph search spaces (egglog [egglog]) with ASP's global combinatorial optimization capabilities, the paper posits prospects for moving beyond two-phase egg+Datalog workflows. ASP offers:

  • Full generate-and-test search with minimization/constraint satisfaction.
  • Possibilities for cost-aware, integrated saturation-plus-extraction pipelines.
  • CDCL engines for guiding rewrites and pruning suboptimal branches, potentially short-circuiting saturation.

Moreover, equivalence checking can be instantiated as incremental search, akin to bounded model checking, reinforcing ASP’s suitability for complex constraint reasoning in dynamic e-graph states.

Theoretical and Practical Implications

The research highlights several implications:

  • Practical Workflow Optimization: Solver-enhanced extraction methods unlock robust optimization in equality saturation. The use of ASP, with propagators and parallelism, allows efficient handling of large, highly connected e-graphs.
  • Theoretical Generalization: ASP subsumes Datalog in expressive power, enabling richer constraint modelling and optimization, particularly for scenarios where global interactions and acyclicity are critical.
  • Integration Agenda: A single-phase, cost-aware saturation versus traditional decomposed workflows may become preferable as solver APIs mature. The paper speculates on ASP modulo equivalence, where congruence closure acts as additional propagation within ASP CDCL solvers—a challenging yet promising direction.
  • Open Problems: Exploiting congruence information inside ASP solvers remains unresolved, as does direct applicability to non-integer scenarios. Portfolio approaches combining solvers and encodings could further exploit case-sensitive advantages.

Conclusion

"Answer Set Programming for Egg Extraction and More" (2606.10644) rigorously demonstrates that ASP, particularly with Clingo’s advanced features, provides practical and competitive solutions for DAG extraction in e-graphs, previously thought impractical due to scalability constraints. The integration of propagators and parallel optimization marks a milestone in leveraging ASP for large-scale, NP-hard combinatorial extraction tasks. By bridging declarative modelling and global optimization, ASP lays the groundwork for future unified equality saturation systems, with ongoing research needed for deeper integration leveraging congruence closure and portfolio solver strategies.

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Collections

Sign up for free to add this paper to one or more collections.

Tweets

Sign up for free to view the 1 tweet with 2 likes about this paper.