I’ve been thinking about the Elimination with a Motive transformation as modernised in terms of type theoretic equivalences. One thing that is striking me right away is that this is going to lead to a pretty scary code blow-up. For instance, if we only consider the basic analysis and the solution rule, a simple construction like the pasting of identifications is going to result in a really large term involving four calls to based path induction, each themselves with increasingly complicated motives. Doing this systematically in the form of unifiers-as-equivalences would result in some even more complicated terms.
Agda gets around this by not actually constructing the equivalences; Cubical Agda and Mikan, however, need the left-inverse part of the equivalence, and even this quickly blows up when types have more than a couple indices, as the Mikan team have recently noted. Project Pterodactyl would likewise need the left-inverse part as well.
I was thinking that perhaps one way to deal with this problem would be to use a bit of a hybrid approach. The extreme position is to elaborate everything in sight to eliminators, but a middle ground might be to extend the core language with a schema for the various unification rules and their left inverses with the appropriate computational behaviour. Every time a proof-relevant unification rule used in the elaboration process, a new abstract top-level declaration is inserted that has (by fiat) the correct reduction rules. Because the operator cannot write these terms, we can make them very compact and probably even avoid annotating them with motives.
Doesn’t this beat the point of eliminating dependent pattern matching? I don’t think so. In Elimination with a Motive, eliminators are playing two distinct roles:
- User-land pattern matching and recursion are reduced to core eliminators.
- Specialisation of motives against targets is achieved internally using a built-in identity type and its eliminator.
What I am proposing is that the specialisation step might be achieved using any computationally well-behaved primitives that the built-in identity type comes equipped with. Even if something can be reduced to a very complicated instance of based path induction, we don’t necessarily need to do so. Moreover, doing so may introduce usability problems (where two things that ought not be definitionally equal from the operator’s point of view become equal by coincidence).
Maybe another way to put it is: it is a coincidence that the user-facing identity type is the same as the identity type used to eliminate dependent pattern matching. If the operator defines their own user-land identity type, then pattern matching definitions defined in terms of it will be reduced to the user-land based path induction principle, but in order to achieve specialisation against the elimination target, the internal identity type (and its rules, whatsoever they are!) will also be used.