ModuleAgda-2.7.0.1Haskell2010
Agda.TypeChecking.SizedTypes.Solve
Solving size constraints under hypotheses.
The size solver proceeds as follows:
Get size constraints, cluster into connected components.
All size constraints that mention the same metas go into the same
cluster. Each cluster can be solved by itself.
Constraints that do not fit our format are ignored.
We check whether our computed solution fulfills them as well
in the last step.
Find a joint context for each cluster.
Each constraint comes with its own typing context, which
contains size hypotheses j : Size< i. We need to find a
common super context in which all constraints of a cluster live,
and raise all constraints to this context.
There might not be a common super context. Then we are screwed,
since our solver is not ready to deal with such a situation. We
will blatantly refuse to solve this cluster and blame it on the
user.
Convert the joint context into a hypothesis graph.
This is straightforward. Each de Bruijn index becomes a
rigid variable, each typing assumption j : Size< i becomes an
arc.
Convert the constraints into a constraint graph.
Here we need to convert MetaVs into flexible variables.
Run the solver
Convert the solution into meta instantiations.
Double-check whether the constraints are solved.