Redefine mkRestrPainting to have better computation rule for q := 0 case#12
Merged
Merged
Conversation
artagnon
reviewed
Mar 19, 2026
artagnon
left a comment
Owner
There was a problem hiding this comment.
Thanks for clearly explaining the issue! I just have one question before we can land this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
Here is the current definition of
mkRestrPainting:In the recursive case of this definition, both direction variable
qandextraDepsCohsare decreasing, so Rocq is free to choose either of them as a structurally smaller value that makes the recursion well-founded. In practice, for this definition, Rocq choosesextraDepsCohs. However, at theq := 0case the definition ofmkRestrPaintingactually doesn't depend onextraDepsCohs. Thus, we might expectmkRestrPaintingto evaluate atq := 0irregardless ofextraDepsCohs, but with the current definition this is not the case:This makes the proofs of coherence equations for paintings more complicated than they should be, i.e. makes it necessary to rely on dependent pattern matching, which doesn't always behave in obvious way:
Possible solutions
Implement
mkRestrPaintingin such a way to regain this definitional equality atq := 0. The issue here is that we can't directly instruct Rocq to considerqthe structurally smaller value for the recursion, asqis hidden beyondmkRestrPaintingTypedefinition. We can consider inliningmkRestrPaintingTypeand making recursion overqexplicit:Note that this term-level definition with explicit recursion over
qturns to be cleaner and less verbose than the one proposed in pull request #9. This is the one implemented in this pull request.Alternatively, we can continue using tactics, but explicitly use
induction q:With both of the definitions above we get
mkRestrPainting extraDepsCohs 0 leR_O ε d (l; c) = (l ε)provable byreflexivitywithout the need to destructextraDepsCohs, which allows to avoidrefine (match ...)trick in coherence equations for paintings. This is especially beneficial in a more complicated coherence proofs that I am working on, for degeneracies in all directions.