perf(kernel/metavar): improve occurs_expr method

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
refactor(library/unifier): improve occurs_context_check

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
perf(library/unifier): minimize the use of instantiate_metavars

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
fix(library/expr_pair): typo

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
refactor(kernel/replace_fn): use thread local cache

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
refactor(kernel/replace_fn): use thread local cache