Vec.Properties: introduce ≈-cong′#2424
Conversation
|
(draft because we still need to figure out a good name for this lemma, and also update the documentation at |
|
This improvement is awesome! In the long term, it'd be great if it's possible to prioritize this new lemma over the existing |
|
This seems like a great contribution... but I'm not across what's needed to get this over the line for v2.2 |
|
Remaining to do?
|
|
(rebased to fix conflicts, mostly caused by #2430) |
- do not export lemma from Vec.Properties - use Function.Base rather than Function
|
Hi! Sorry for the absence, I'll try to unblock this as much as possible.
Done!
I don't think we can, because the old
I am indifferent. I guess it could be argued that the new |
Ah okay, that makes sense!
Yup. I was advocating for deprecation based on the misconception that the new definition was more general. Okay great, I think that tidies everything up. I'll merge this in and squeeze it into v2.2 |
Additions
This PR introduces the
≈-cong′lemma:This lemma does for
≈[_]whatcongdoes for≡: givenfandxs ≈[ _ ] ysit provesf xs ≈[ _ ] f ys.More specifically, it proves that any
Vec A n → Vec B mfunction that is polymorphic innmust preserve≈[_].Current status
Compare this with the existing
≈-conglemma (introduced by @shhyou with #2067 along with the reasoning system):This lemma works for a non-polymorphic
f, but it requires the user to supply proof thatfpreserves≈[_].We already have a handful of these proofs written for some functions:
Simplifications
≈-cong′is used in a similar way, except that it doesn't require manually proving preservation ofcastforf.So, most uses of
≈-cong(including all current ones) can be migrated to≈-cong′just by removing the 2nd argument:An extreme example is
example4-cong², where we show chaining≈-cong. This can also be done with≈-cong′, but there we can further express it as a single≈-cong′of the composition, as we tend to do withcong:And the 'cast preservation' proofs above, should you still need them, are just special cases of
≈-cong′: