refactor: simplify `AlphaShareCommon.State` and use mutable hashmap

This PR simplifies `AlphaShareCommon.State` by separating the
persistent and transient parts of the state.

The `map` field caches visited sub-expressions during a single
`shareCommonAlpha` call to handle DAGs efficiently, the input
expression may contain shared sub-expressions that are not yet
maximally shared. However, this cache does not need to persist between
different `shareCommonAlpha` calls.

**Changes:**
- Moved `map` from the persistent `AlphaShareCommon.State` to a private `State` used only within individual `shareCommonAlpha` calls.
- Replaced `PHashMap ExprPtr Expr` with (the more efficient) `Std.HashMap ExprPtr Expr` for `map`, since it is now local to each call and does not need persistence.
- The public `AlphaShareCommon.State` now only contains the `set` of alpha-equivalent expressions that should persist
1 file changed