Compute the maximum index M
used in a declaration.
We M
to initialize the fresh index generator used to create fresh
variable and join point names.
Recall that we variable and join points share the same namespace in our implementation.
Equations
- b.maxIndex = Lean.IR.MaxIndex.collectFnBody b 0
Instances For
We say a variable (join point) index (aka name) is free in a function body
if there isn't a FnBody.vdecl
(Fnbody.jdecl
) binding it.
Equations
- Lean.IR.FreeIndices.insertParams s ys = Array.foldl (fun (s : Lean.IR.IndexSet) (p : Lean.IR.Param) => Lean.RBTree.insert s p.x.idx) s ys
Instances For
Equations
- b.collectFreeIndices vs = Lean.IR.FreeIndices.collectFnBody b ∅ vs
Instances For
In principle, we can check whether a function body b
contains an index i
using
b.freeIndices.contains i
, but it is more efficient to avoid the construction
of the set of freeIndices and just search whether i
occurs in b
or not.
Equations
- Lean.IR.HasIndex.visitVar w x = (w == x.idx)
Instances For
Equations
- Lean.IR.HasIndex.visitJP w x = (w == x.idx)
Instances For
Equations
- Lean.IR.HasIndex.visitArgs w xs = xs.any (Lean.IR.HasIndex.visitArg w)
Instances For
Equations
- Lean.IR.HasIndex.visitParams w ps = ps.any fun (p : Lean.IR.Param) => w == p.x.idx
Instances For
Equations
- b.hasFreeVar x = Lean.IR.HasIndex.visitFnBody x.idx b