Glenn Sun
Joint work with Yihong Zhang and Haobin Ni
University of Washington
arXiv:2408.17042
EGRAPHS November Community Meeting
Our main contribution is an equivalence:
e-graphs $\leftrightarrow$ (cyclic) monotone circuits
This allows us to:
The algorithm is very similar to [GLP24].
[KTX17] | Iyad Kanj, Dimitrios M. Thilikos, and Ge Xia. On the parameterized complexity of monotone and antimonotone weighted circuit satisfiability. |
[GLP24] | Amir Kafshdar Goharshady, Chun Kit Lam, and Lionel Parreaux. Fast and Optimal Extraction for Sparse Equality Graphs. |
A monotone circuit is a circuit with only AND and OR gates.
e-node $\leftrightarrow$ all children true $\leftrightarrow$ AND
e-class $\leftrightarrow$ at least one child true $\leftrightarrow$ OR
$\longrightarrow$
$x$ | old output | new output |
---|---|---|
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
But e-graphs researchers never have to think about this. Why not?
$x$ | old output | new output |
---|---|---|
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
But e-graphs researchers never have to think about this. Why not?
$x$ | old output | new output |
---|---|---|
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
But e-graphs researchers never have to think about this. Why not?
✅
✅
❌
❌
To convert an e-graph $G$ to a circuit $C$:
Observation. After this conversion from e-graph to circuit, there is a bijection
minimal extractions of $G$ $\leftrightarrow$ minimal satisfying solutions of $C$.
This bijection preserves acyclicity.
(acyclic: extraction has no self-dependencies, circuit evaluation has no 1-cycles)
$\implies$ Extraction is equivalent to weighted monotone circuit SAT!
[KTX17] already solved this, albeit stated only for circuits that do not have cycles.
Proposition 4.7 in [KTX17]. Let $C$ be a monotone circuit (with no cycles) and $G$ be the underlying undirected graph with $n$ nodes. If a tree decomposition for $G$ and treewidth $k$ is given, then a minimum weight satsifying assignment of $C$ can be computed in time $2^{O(k)}\text{poly}(n, k)$.
The algorithm works unchanged for circuits with cycles, if we allow cyclic extraction!
For acyclic extraction, can maintain the transitive closure of the subgraph of 1-edges to make sure no 1-cycles are formed, achieving $2^{O(k^2)}\text{poly}(n, k)$.
$\longrightarrow$
E-graph simplification before extraction has been used with ILP (i.e. see https://github.com/egraphs-good/extraction-gym/pull/16)
With circuits, we can leverage existing circuit minimization tools that support sequential circuits*.
But we only care about minimal satisfying solutions, sometimes acyclic.
* | Need to restrict to the procedures that preserve monotonicity. |
Because we are only interested in minimal extractions:
$\longrightarrow$
If we are only interested in acyclic extractions:
$1$
$1$
$1$
$1$
If we are only interested in acyclic extractions:
$0$
delete this gate and all out-neighbors that are AND gates recursively
If we are only interested in acyclic extractions:
$\downarrow$
We applied several ad-hoc rules like this to a test set of e-graphs used with egg. Depending on which applications the e-graphs came from, we observed:
A more systematic approach might improve this further.
Thank you!