5using namespace std::string_literals;
15 auto ret =
dom(num_doms() - 1);
45 std::deque<const App*> apps;
46 while (
auto app = def->isa<
App>()) {
47 apps.emplace_front(app);
54 auto& world = f->world();
55 world.DLOG(
"compose f (B->C): {} : {}", f, f->type());
56 world.DLOG(
"compose g (A->B): {} : {}", g, g->type());
58 auto F = f->type()->as<
Pi>();
59 auto G = g->type()->as<
Pi>();
64 auto A = G->
dom(2, 0);
66 auto C = F->ret_dom();
69 world.DLOG(
"compose f (B->C): {} : {}", f, F);
70 world.DLOG(
"compose g (A->B): {} : {}", g, G);
71 world.DLOG(
" A: {}", A);
72 world.DLOG(
" B: {}", B);
73 world.DLOG(
" C: {}", C);
75 auto h = world.mut_fun(A, C)->set(
"comp_"s + f->sym().str() +
"_"s + g->sym().str());
76 auto hcont = world.mut_con(B)->set(
"comp_"s + f->sym().str() +
"_"s + g->sym().str() +
"_cont"s);
78 h->app(
true, g, {h->var((
nat_t)0), hcont});
80 auto hcont_var = hcont->var();
81 hcont->app(
true, f, {hcont_var, h->var(1) });
87 std::vector<const Def*> args;
88 if (
auto app = def->isa<
App>()) {
89 auto callee = app->callee();
90 auto arg = app->arg();
93 return {inner_callee, args};
Def * set(size_t i, const Def *def)
Successively set from left to right.
std::variant< bool, const Def * > Filter
Lam * branch(Filter filter, const Def *cond, const Def *t, const Def *f, const Def *mem=nullptr)
Set body to an App of (f, t)#cond mem or (f, t)#cond () if mem is nullptr.
Lam * set_filter(Filter)
Set filter first.
Lam * test(Filter filter, const Def *val, const Def *idx, const Def *match, const Def *clash, const Def *mem)
Lam * app(Filter filter, const Def *callee, const Def *arg)
Set body to an App of callee and arg.
Lam * set_body(const Def *body)
Set body second.
A dependent function type.
static const Pi * isa_returning(Ref d)
Is this a continuation (Pi::isa_cn) which has a Pi::ret_pi?
static const Pi * isa_basicblock(Ref d)
Is this a continuation (Pi::isa_cn) that is not Pi::isa_returning?
const Pi * ret_pi() const
Yields the last Pi::dom, if it Pi::isa_basicblock.
Ref ret_dom() const
Pi::domain of Pi::ret_pi.
This is a thin wrapper for std::span<T, N> with the following additional features:
std::deque< const App * > decurry(const Def *)
Yields curried Apps in a flat std::deque<const App*>.
const Def * compose_cn(const Def *f, const Def *g)
The high level view is:
std::pair< const Def *, std::vector< const Def * > > collect_args(const Def *def)
Helper function to cope with the fact that normalizers take all arguments and not only its axiom argu...