perf: use pointer equality for visited terms in `collectFVars` and `collectMVars`

This PR makes `collectFVars` and `Expr.collectMVars` track visited subterms with pointer equality instead of structural equality, which avoids costly structural comparisons on large terms.

The public `visitedExpr` field is replaced with a private pointer-keyed set. Use `{}` for an empty state and `CollectFVars.State.ofFVarSet` for a state that already contains free variables. Callers that used `visitedExpr` directly are updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015CAFbcjTNgTXh2gg26CRyv
5 files changed