Optimizing the propagation of the guard condition under a match on a type with indices by discarding only the type information from the indices#14359
Conversation
This comment has been minimized.
This comment has been minimized.
ca61518 to
5feef47
Compare
5feef47 to
29b96b5
Compare
|
It looks like I was redoing #798 and re-introducing the propositional extensionality issue. I made a new proposal which instantiates the predicate only with the constructed part of its indices. It fills non-constructor terms with a dummy (generally ill-typed) |
|
Removing the milestone as there has been no change since 8.14. |
|
Since this PR is incorrect and there are upcoming changes in the guard condition anyways, I'm closing it. |
|
What about doing a lazy substitution of the indices:
That would solve both the Ideally, I suspect that we could go one step further and continue to propagate the substitution of object in a small type, since the problem with extensionality arrives when dealing with equality of types. |
29b96b5 to
305c3cc
Compare
305c3cc to
5946daf
Compare
|
As a restricted form of univalence, the statement of propositional extensionality says that This limitation seems specific to equality of types. For instance, traversing an elimination on Traversing an elimination Here is a strategy to ensure that no isomorphism hidden behind an equality of types can modify the size of the return type when eliminating in a type with indices (and in particular when eliminating an equality proof): Normalize all indices I just pushed a version which is almost this new "optimal" algorithm. I'm saying almost optimal because, ideally, I would have needed access to the indices of the term being matched, but they don't seem to be available (except sometimes in the |
a6e6bef to
30c07aa
Compare
|
By the way, the restriction on the return clause done in this PR could be applied to definitional UIP to prevent the breakage of normalization with impredicativity... and thus to always activate definitional UIP (or, at worst, to make optional only the subcase of definitional UIP involving rewriting of types). |
Can you explain more? The issue with definitional UIP does not involve any fixpoints so the guard condition is unrelated. |
I mean that in: the criterion above detects that the On the other side, still from the reference manual, in: the |
|
But how is the size used? |
I'm sorry, when talking about the
The PR itself does not modify definitional UIP. What I'm saying is that if we restricted definitional UIP to those So, in some sense, this suggests a notion of "guarded definitional UIP" which reduces all UIP-like Added note: For fixpoints, it is enough to mask inductive types. For "guarded definitional UIP" one would a priori need to mask all applied/projected variables, inductive types and pi-types in impredicative sorts. |
|
The "needs: rebase" label was set more than 30 days ago. If the PR is not rebased in 30 days, it will be automatically closed. |
The type-based filtering of arguments passed across a "match" was not taking into account that the return predicate had a specific constructor instance in each branch. We take the pattern-structure of this instance into account (keeping only constructors). This allows to recognize more useful fixpoints as guarded (e.g. map3 on vectors when using small inversion, or rocq-prover#17062).
30c07aa to
9f7a36e
Compare
|
AFAICT there is currently not much interest in weakening the guard condition without some strong theoretical argumentation (eg a formalized proof or at least a published paper instead of some github postings) |
Kind: enhancement
The type-based filtering of decreasing arguments passed across amatchwas not taking into account that the return predicate had a specific instance in each branch. We take this instance into account and this allows to recognize more useful fixpoints as guarded (e.g. map3 on vectors when mechanically generated with small inversion).We observe that the protection against the inconsistency of propositional extensionality obtained by not using at all the indices of the type of the term to match in propagating the subterm status through a
match(see 9b272a8 and further commits) is finally overly restrictive: only the type information present in the indices needs to be ignored (see comment below for a proof sketch).This allows to:
Here is a typical example of small inversion exploiting the PR:
TODO: apply it to
restrict_spectoo.