refactor(kernel): substitution

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
refactor(kernel): replace_fn functional object

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
refactor(kernel): instantiate_params

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>