perf: cache `unfold_definition` in the kernel

This PR ensures we cache the result of `unfold_definition` definition
in the kernel type checker. We used to cache this information in a
thread local storage, but it was deleted during the Lean 3 to Lean 4
transition.
2 files changed