The abstract domain of the interpreter. Representing sets of values of a certain type.
Fuse v
into vs
. That is do not only append but if we see that v
is a constructor that is already contained within vs
try to detect
the difference between these values and merge them accordingly into a
choice node further down the tree.
Make sure constructors of recursive inductive datatypes can only occur once in each path.
Values at depth > maxValueDepth
are also approximated at top
.
We use this function to implement a simple widening operation for our abstract interpreter.
Recall the widening functions is used to ensure termination in abstract interpreters.
Widening operator that guarantees termination in our abstract interpreter.
Equations
Obtain the arguments of a certain constructor within the Value
.
Equations
- One or more equations did not get rendered due to their size.
- (Lean.Compiler.LCNF.UnreachableBranches.Value.ctor i args).getCtorArgs x✝ = if (i == x✝) = true then some args else none
- x✝¹.getCtorArgs x✝ = none
Equations
- One or more equations did not get rendered due to their size.
Equations
We say that a Value
is a literal iff it is only a tree of Value.ctor
nodes.
Attempt to turn a Value
that is representing a literal into a set of
auxiliary declarations + the final FVarId
of the declaration that
contains the actual literal. If it is not a literal return none.
A map from function names to the Value
that the abstract interpreter
produced for them.
Storing FunctionSummaries
for all functions in a .olean
.
Add a Value
for a function name.
Equations
- One or more equations did not get rendered due to their size.
Obtain the Value
for a function name if possible.
Equations
- One or more equations did not get rendered due to their size.
A map from variable identifiers to the Value
produced by the abstract
interpreter for them.
The context of InterpM
.
- assignments : Array Assignment
Assignment
s of functions in theInterpContext
. Value
s of functions in theInterpContext
use during computation of the fixpoint. Afterwards they are stored into theEnvironment
.
The monad which powers the abstract interpreter.
Equations
- One or more equations did not get rendered due to their size.
Get the variable Assignment
of the current function.
Equations
- Lean.Compiler.LCNF.UnreachableBranches.getAssignment = do let __do_lift ← get let __do_lift_1 ← read pure __do_lift.assignments[__do_lift_1.currFnIdx]!
Run f
on the variable Assignment
of the current function.
Equations
- One or more equations did not get rendered due to their size.
Find the value of arg
using the logic of findVarValue
.
Widen the value of the current function by v
.
Equations
- One or more equations did not get rendered due to their size.
Return true if the assignment of at least one parameter has been updated.
Furthermore if we see that params.size != args.size
we know that this is
a partial application and set the values of the remaining parameters to
top
since it is impossible to track what will happen with them from here on.
Equations
- One or more equations did not get rendered due to their size.
The actual abstract interpreter on a block of Code
.
The abstract interpreter on a LetValue
.
If we see a function being passed as an argument to a higher order
function we cannot know what arguments it will be passed further
down the line. Hence we set all of its arguments to top
since anything
is possible.
Rerun the abstract interpreter on all declarations except of the unsafe
ones. Return whether any Value
got updated in the process.
Equations
- One or more equations did not get rendered due to their size.
Run inferStep
until it reaches a fix point.
Use the information produced by the abstract interpreter to:
- Eliminate branches that we know cannot be hit
- Eliminate values that we know have to be constants.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.