18 : Def(
Node,
type, 2, implicit ? 1 : 0) {}
32 const Def*
dom()
const {
return op(0); }
33 const Def*
codom()
const {
return op(1); }
52 if (
auto pi = d->isa_mut<
Pi>(); pi && pi->is_implicit())
return pi;
56 static const Pi*
has_ret_pi(
const Def* d) {
return d->isa<
Pi>() ? d->as<
Pi>()->ret_pi() :
nullptr; }
110 : Def(
Node, pi, 2, 0) {}
113 using Filter = std::variant<bool, const Def*>;
118 const Def*
body()
const {
return op(1); }
136 static const Lam*
isa_cn(const Def* d) {
return Pi::isa_cn(d->type()) ? d->isa<Lam>() :
nullptr; }
225 const Def*
arg()
const {
return op(1); }
255 if (
auto app = def->isa<
App>())
return {app, app->callee()->isa_mut<
Lam>()};
256 return {
nullptr,
nullptr};
260std::deque<const App*>
decurry(
const Def*);
278const Def*
compose_cn(
const Def* f,
const Def* g);
281std::pair<const Def*, DefVec>
collect_args(
const Def* def);
const Def * rebuild_(World &, const Def *, Defs) const override
const Pi * callee_type() const
const Axiom * axiom() const
const App * decurry() const
Returns App::callee again as App.
static constexpr auto Node
const Def * callee() const
bool is_set() const
Yields true if empty or the last op is set.
constexpr Node node() const noexcept
Def * set(size_t i, const Def *)
Successively set from left to right.
World & world() const noexcept
virtual const Def * check()
constexpr auto ops() const noexcept
constexpr flags_t flags() const noexcept
const Def * op(size_t i) const noexcept
DefVec reduce(const Def *arg) const
Rewrites Def::ops by substituting this mutable's Var with arg.
nat_t num_vars() noexcept
const Def * type() const noexcept
Yields the "raw" type of this Def (maybe nullptr).
const Def * var()
Not necessarily a Var: E.g., if the return type is [], this will yield ().
Def * unset()
Unsets all Def::ops; works even, if not set at all or partially.
std::variant< bool, const Def * > Filter
const Def * filter() const
static const Lam * isa_cn(const Def *d)
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 * stub_(World &, const Def *) override
Lam * set(Filter filter, const Def *body)
Lam * set_filter(Filter)
Set filter first.
static Lam * isa_mut_basicblock(const Def *d)
Only for mutables.
static const Lam * isa_returning(const Def *d)
const Pi * ret_pi() const
static Lam * isa_mut_returning(const Def *d)
Only for mutables.
static constexpr auto Node
const Def * rebuild_(World &, const Def *, Defs) const override
Lam * test(Filter filter, const Def *val, const Def *idx, const Def *match, const Def *clash, const Def *mem)
static const Lam * isa_basicblock(const Def *d)
Lam * app(Filter filter, const Def *callee, const Def *arg)
Set body to an App of callee and arg.
const Def * ret_dom() const
Lam * set_body(const Def *body)
Set body second.
Lam * stub(const Def *type)
static Lam * isa_mut_cn(const Def *d)
Only for mutables.
const Def * ret_var()
Yields the Lam::var of the Lam::ret_pi.
const Def * codom() const
A dependent function type.
const Def * ret_dom() const
Pi::domain of Pi::ret_pi.
Pi * stub_(World &, const Def *) override
Pi(const Def *type, bool implicit)
Constructor for a *mut*able Pi.
static const Pi * has_ret_pi(const Def *d)
Yields the Pi::ret_pi() of d, if it is in fact a Pi.
Pi * set_codom(const Def *codom)
Pi(const Def *type, const Def *dom, const Def *codom, bool implicit)
Constructor for an immutable Pi.
static const Pi * isa_cn(const Def *d)
Is this a continuation - i.e. is the Pi::codom mim::Bottom?
static const Pi * isa_basicblock(const Def *d)
Is this a continuation (Pi::isa_cn) that is not Pi::isa_returning?
static const Def * infer(const Def *dom, const Def *codom)
const Def * codom() const
static Pi * isa_implicit(const Def *d)
Is d an Pi::is_implicit (mutable) Pi?
const Def * rebuild_(World &, const Def *, Defs) const override
const Def * check() override
Pi * set(const Def *dom, const Def *codom)
static constexpr auto Node
const Def * reduce(const Def *arg) const
const Pi * immutabilize() override
Tries to make an immutable from a mutable.
Pi * stub(const Def *type)
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?
CRTP-based Mixin to declare setters for Def::loc & Def::name using a covariant return type.
#define MIM_PROJ(NAME, CONST)
Use as mixin to wrap all kind of Def::proj and Def::projs variants.
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::pair< const App *, Lam * > isa_apped_mut_lam(const Def *def)
absl::flat_hash_set< K, GIDHash< K >, GIDEq< K > > GIDSet
GIDMap< Lam *, To > LamMap
Lam * isa_workable(Lam *lam)
These are Lams that are neither nullptr, nor Lam::is_external, nor Lam::is_unset.
std::deque< const App * > decurry(const Def *)
Yields curried Apps in a flat std::deque<const App*>.
absl::flat_hash_map< K, V, GIDHash< K >, GIDEq< K > > GIDMap
const App * isa_callee(const Def *def, size_t i)
const Def * compose_cn(const Def *f, const Def *g)
The high level view is:
auto match(const Def *def)