-
Notifications
You must be signed in to change notification settings - Fork 248
Some preparatory proofs for proving sorting+permutation is equality #2724 #2725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
-- Takes a permutation m → n and creates a permutation | ||
-- suc (suc m) → suc (suc n) by mapping 0 to 1 and 1 to 0 and | ||
-- then applying the input permutation to everything else | ||
swap : Permutation m n → Permutation (suc (suc m)) (suc (suc n)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a special case of \oplus of two permutations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree (lift0
should be as well!), but we don't have such an operation in the library. I have added a note that we should refactor it when we add that operator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have it buried in my Rig Categories repo. I need to port the basic operations on permutations over. I've got the full semiring defined there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But also: Function.Related.TypeIsomorphisms
etc. as per #2489 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plus, of course: we only need this operation because Permutation.Setoid
stipulates swap
as a constructor... ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, absolutely, there is some great stuff in Function.Related.TypeIsomorphism
. And a rather apt 'of course'.
src/Data/List/Relation/Binary/Permutation/Setoid/Properties.agda
Outdated
Show resolved
Hide resolved
Having looked at this, and its followup, in particular lemma
If so, then I think this PR and its followup may be simplifiable via the already existing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nitpicks.
Happy to approve, but I too have been sniped by this... would love to be able to simplify if at all possible!
_≰_ : ∀ {n} → Rel (Fin n) 0ℓ | ||
i ≰ j = ¬ (i ≤ j) | ||
|
||
_≮_ : ∀ {n} → Rel (Fin n) 0ℓ | ||
i ≮ j = ¬ (i < j) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xs↭ys⇒|xs|≡|ys| : ∀ {xs ys} → xs ↭ ys → length xs ≡ length ys | ||
xs↭ys⇒|xs|≡|ys| (refl eq) = Pointwise.Pointwise-length eq | ||
xs↭ys⇒|xs|≡|ys| (prep eq xs↭ys) = ≡.cong suc (xs↭ys⇒|xs|≡|ys| xs↭ys) | ||
xs↭ys⇒|xs|≡|ys| (swap eq₁ eq₂ xs↭ys) = ≡.cong (λ x → suc (suc x)) (xs↭ys⇒|xs|≡|ys| xs↭ys) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
xs↭ys⇒|xs|≡|ys| (swap eq₁ eq₂ xs↭ys) = ≡.cong (λ x → suc (suc x)) (xs↭ys⇒|xs|≡|ys| xs↭ys) | |
xs↭ys⇒|xs|≡|ys| (swap eq₁ eq₂ xs↭ys) = ≡.cong 2+_ (xs↭ys⇒|xs|≡|ys| xs↭ys) |
(possibly at the cost of an additional import from Data.Nat.Base
)?
_≰_ : ∀ {n} → Rel (Fin n) 0ℓ | ||
_≮_ : ∀ {n} → Rel (Fin n) 0ℓ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we, by convention, avoid writing the ∀ {n} →
prefix here?
I've been sniped by #2723. This is a preparatory PR for the full proof that sorting two lists that are permutations of each other result in equal lists.