13 if (
auto i = old2new_.find(def); i != old2new_.end())
return i->second;
21 if (!
world().flags().aggressive_lam_spec && scope.
free_defs().contains(old_lam))
return def;
23 DefVec new_doms, new_vars, new_args;
24 auto skip = old_lam->ret_var() && old_lam->is_closed();
25 auto old_doms = old_lam->doms();
27 for (
auto dom : old_doms.view().rsubspan(skip))
28 if (!dom->isa<
Pi>()) new_doms.emplace_back(dom);
30 if (skip) new_doms.emplace_back(old_lam->doms().back());
31 if (new_doms.size() == old_lam->num_doms())
return def;
33 auto new_lam = old_lam->
stub(
world().cn(new_doms));
35 for (
size_t arg_i = 0, var_i = 0, n = app->num_args() - skip; arg_i != n; ++arg_i) {
36 auto arg = app->arg(arg_i);
37 if (old_lam->dom(arg_i)->isa<
Pi>()) {
38 new_vars.emplace_back(arg);
40 new_vars.emplace_back(new_lam->var(var_i++));
41 new_args.emplace_back(arg);
46 new_vars.emplace_back(new_lam->vars().back());
47 new_args.emplace_back(app->args().back());
50 new_lam->
set(old_lam->reduce(
world().tuple(new_vars)));
51 world().DLOG(
"{} -> {}: {} -> {})", old_lam, new_lam, old_lam->dom(), new_lam->dom());
53 return old2new_[def] =
world().
app(new_lam, new_args);