Table of Contents
Fetching ...

E-Graphs as Circuits, and Optimal Extraction via Treewidth

Glenn Sun, Yihong Zhang, Haobin Ni

TL;DR

This work demonstrates a new connection between e-graphs and Boolean circuits, and shows how the circuit view of e-graphs allows us to apply powerful simplification techniques, and analyze a dataset of e-graphs to show that these techniques can reduce e-graph size and treewidth by 40-80% in many cases.

Abstract

We demonstrate a new connection between e-graphs and Boolean circuits. This allows us to adapt existing literature on circuits to easily arrive at an algorithm for optimal e-graph extraction, parameterized by treewidth, which runs in $2^{O(w^2)}\text{poly}(w, n)$ time, where $w$ is the treewidth of the e-graph. Additionally, we show how the circuit view of e-graphs allows us to apply powerful simplification techniques, and we analyze a dataset of e-graphs to show that these techniques can reduce e-graph size and treewidth by 40-80% in many cases. While the core parameterized algorithm may be adapted to work directly on e-graphs, the primary value of the circuit view is in allowing the transfer of ideas from the well-established field of circuits to e-graphs.

E-Graphs as Circuits, and Optimal Extraction via Treewidth

TL;DR

This work demonstrates a new connection between e-graphs and Boolean circuits, and shows how the circuit view of e-graphs allows us to apply powerful simplification techniques, and analyze a dataset of e-graphs to show that these techniques can reduce e-graph size and treewidth by 40-80% in many cases.

Abstract

We demonstrate a new connection between e-graphs and Boolean circuits. This allows us to adapt existing literature on circuits to easily arrive at an algorithm for optimal e-graph extraction, parameterized by treewidth, which runs in time, where is the treewidth of the e-graph. Additionally, we show how the circuit view of e-graphs allows us to apply powerful simplification techniques, and we analyze a dataset of e-graphs to show that these techniques can reduce e-graph size and treewidth by 40-80% in many cases. While the core parameterized algorithm may be adapted to work directly on e-graphs, the primary value of the circuit view is in allowing the transfer of ideas from the well-established field of circuits to e-graphs.
Paper Structure (10 sections, 4 theorems, 2 equations, 4 figures, 2 tables)

This paper contains 10 sections, 4 theorems, 2 equations, 4 figures, 2 tables.

Key Result

proposition 2.3

An acyclic evaluation $\alpha$ is uniquely determined by its value on the inputs.

Figures (4)

  • Figure 1: Overall algorithm pipeline and article organization
  • Figure 2: An example of converting e-graphs into circuits. Note that the arrows conventionally point to dependencies in e-graphs, but signals flow in the opposite direction in a circuit, so we flip the arrows. Furthermore, the extraction $A \mapsto \sqrt{\space}$, $B \mapsto 2$ corresponds to the evaluation where everything on the left and the OR gate $A$ are all 1, and the rest are 0. The cyclic extraction $A \mapsto +$, $C \mapsto 0$ corresponds to the cyclic evaluation where everything on the right and the OR gate $A$ are all 1, and the rest are 0. The evaluation where everything is 1 has no corresponding extraction because $A$ can only choose one e-node in an e-graph; however, such an evaluation is not minimal.
  • Figure 3: A nice tree decomposition of a graph, where each node is annotated whether it is a leaf, insert, forget, or join node. This graph has treewidth 2.
  • Figure 5: Treewidth and $|V|$ before and after applying all simplification rules. Note that there are some artifacts due to heuristics used in tree decomposition, e.g. in "rover". A few examples continued to time out after 15 seconds and are omitted from these data.

Theorems & Definitions (13)

  • definition 2.1
  • definition 2.2
  • proposition 2.3
  • proof
  • definition 2.4
  • definition 2.5
  • proposition 2.6
  • definition 3.1
  • definition 3.2
  • proposition 4.1
  • ...and 3 more