Commit Graph

8 Commits

Author SHA1 Message Date
Junseo Yoo
1adbd45b20 Merge branch 'upstream' into merge 2024-08-01 16:26:06 -07:00
Junseo Yoo
fad8aaf0ab Sync to upstream/release/637 2024-08-01 16:25:12 -07:00
Junseo Yoo
48c0e9f625 Merge branch 'upstream' into merge 2024-07-25 17:24:36 -07:00
Junseo Yoo
7dd10b16dc Sync to upstream/release/636 2024-07-25 17:10:42 -07:00
Vighnesh
ac97a491c1 Merge branch 'upstream' into merge 2024-07-19 10:40:51 -07:00
Vighnesh
6fd26c55ff Sync to upstream/release/635 2024-07-19 10:21:40 -07:00
birds3345
2874ca9e86
Optimizations for UnionFind (#1334)
Implements ranks & path compression for union find.

---------

Co-authored-by: Alexander McCord <11488393+alexmccord@users.noreply.github.com>
2024-07-17 16:19:57 -07:00
Alexander McCord
e1bf6289c7
Equality graphs (#1285)
Working towards a full e-graph implementation as described by the [egg
paper](https://arxiv.org/pdf/2004.03082).

The type system has a couple of places where e-graphs would've been
useful and solved some classes of problems trivially. For example:

1. Normalization and simplification cannot handle cyclic types due to
the nature of their implementation.
2. Normalization can't tell when two tables or functions are equivalent,
but simplification theoretically can albeit not implemented.
3. Normalization requires deep normalization for inhabitance check,
whereas simplification would've returned the `never` type itself
indicating uninhabited.
4. Simplification requires constraint ordering to have perfect timing to
simplify.
5. Adding a rewrite rule requires implementing it twice, once in
simplification and once again in normalization with completely different
code design making it hard to verify that their behavior is materially
equivalent.
6. In cases where we must cache for performance, two different types
that are isomorphic have different cache entries resulting in cache
misses.
7. Type family reduction can handle cyclic type families, but only if
the cycle is not obscured by a different type family instance. (`t1
where t1 = union<number, add<t1, number>>` is irreducible)

I think we're getting the point!

---

Currently the implementation is missing a few features that makes
e-graphs actually useful. Those will be coming in a future PR.

1. Pattern matching,
6. Applying rewrites,
7. Rewrite until saturation, and
8. Extracting the best e-node according to some cost function.
2024-07-16 10:35:20 -07:00