luau/Common/include/Luau
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
..
Bytecode.h Fix incorrect comment in Bytecode.h (#1315) 2024-07-09 16:00:17 -07:00
BytecodeUtils.h Sync to upstream/release/631 (#1299) 2024-06-20 16:37:55 -07:00
Common.h Sync to upstream/release/619 (#1218) 2024-03-30 16:14:44 -07:00
DenseHash.h Sync to upstream/release/631 (#1299) 2024-06-20 16:37:55 -07:00
ExperimentalFlags.h Sync to upstream/release/622 (#1232) 2024-04-19 14:48:02 -07:00
Variant.h Equality graphs (#1285) 2024-07-16 10:35:20 -07:00
VecDeque.h Sync to upstream/release/613 (#1167) 2024-02-15 18:04:39 -08:00