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) });
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 *)
Successively set from left to right.
World & world() const noexcept
std::variant< bool, const Def * > Filter
const Def * filter() const
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.
const Def * ret_dom() const
Pi::domain of Pi::ret_pi.
Pi(const Def *type, const Def *dom, const Def *codom, bool implicit)
Constructor for an immutable Pi.
static const Pi * isa_basicblock(const Def *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 Pi::isa_basicblock.
Pi * set_dom(const Def *dom)
static const Pi * isa_returning(const Def *d)
Is this a continuation (Pi::isa_cn) which has a Pi::ret_pi?
Vector< const Def * > DefVec
std::pair< const Def *, DefVec > collect_args(const Def *def)
Helper function to cope with the fact that normalizers take all arguments and not only its axiom argu...
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:
auto match(const Def *def)