Skip to content
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

Some lemmas to do with transposition lists #1744

Closed
wants to merge 7 commits into from

Conversation

Taneb
Copy link
Member

@Taneb Taneb commented Mar 26, 2022

This is largely preliminaries for #1741, which I'm still playing with how to implement.

@@ -223,6 +223,13 @@ insert {m} {n} i j π = permutation to from inverseˡ′ inverseʳ′
------------------------------------------------------------------------
-- Other properties

transpose-self-inverse : ∀ (i j : Fin n) → transpose i j ≈ transpose j i
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transpose-sym?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also it's not in the CHANGELOG

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more of a commutativity property than a symmetry property (the type is the same as Commutative _≈_ transpose I think, modulo unresolved metas). Would you be OK with transpose-comm?

Copy link
Contributor

@jamesmckinna jamesmckinna May 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since #1914 why not call this transpose-selfInverse?
Hmm... not exactly, but I would in any case be tempted to prove (transpose i j) ⁻¹ = transpose j i as well?


TranspositionList : ℕ → Set
TranspositionList n = List (Fin n × Fin n)
TranspositionList n = List (Σ[ i ∈ Fin n ] ∃[ j ] i ≢ j)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe List (∃₂ λ i j → i ≢ j)? Could also write (∃₂ _≢_) but I'm not sure how clear that is?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need a hint that they have type Fin n rather than some other type, sadly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List (∃₂ λ (i j : Fin n) → i ≢ j) then?


------------------------------------------------------------------------
-- Operations on transposition lists

lift₀ : TranspositionList n → TranspositionList (suc n)
lift₀ xs = map (λ (i , j) → (suc i , suc j)) xs
lift₀ xs = map (λ (i , j , i≢j) → (suc i , suc j , λ si≡sj → i≢j (suc-injective si≡sj))) xs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe i≢j ∘ suc-injective instead?

@MatthewDaggitt
Copy link
Contributor

Apologies for taking so long for a review!

@MatthewDaggitt
Copy link
Contributor

@Taneb any progress on this?

@Taneb
Copy link
Member Author

Taneb commented Jul 1, 2022

I started addressing the comments, but I've been very distracted lately (and have broken my wrist in the meantime). I don't know when I can get back to it

@MatthewDaggitt
Copy link
Contributor

Oh no, sorry to hear that! I can see why that'd make typing a little difficulty. Okay no worries, I'll leave it up and see if I have the time to fiddle with it in the meantime....


TranspositionList : ℕ → Set
TranspositionList n = List (Fin n × Fin n)
TranspositionList n = List (∃₂ λ (i j : Fin n) → i ≢ j)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I'm sorry to reopen the discussion, but looking at this with a fresh pair of eyes, wouldn't a more modular and reusable solution be to keep the definition as is and then define a predicate:

NonTrivialEntries : TranspositionList n → Set
NonTrivialEntries xs = All (curry _≢_) xs

which could then be taken as an argument in the proofs that need it. The advantages of this would be:

  1. Preserves backwards compatibility
  2. Provides more choice to the user - I can imagine a scenario where the reflexive entries do hold semantic information.
  3. Allows us to reuse lemmas from Data.List.Relation.Unary.All

I'm open to suggestions about the name NonTrivialEntries?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really want to argue against this, but the truth is that for everything currently existing, that the transposition list has no trivial entries is completely irrelevant. I think the right thing to do for now might be to not talk about that constraint until we've got something that actually uses it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, happy with that solution!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what needs to be done to implement that solution?

@Taneb
Copy link
Member Author

Taneb commented Nov 9, 2022

Now that #1852 is in, I'd like to continue work on this PR to where I wanted to get it to, proving that there's a group homomorphism from permutations to their parity (this will let us define alternating groups and is useful for implementing Liebniz's formula for matrix determinants)

@Taneb Taneb force-pushed the transposition-stuff branch from 40e4888 to cf1451b Compare May 13, 2023 17:40
@jamesmckinna jamesmckinna mentioned this pull request Oct 30, 2022
10 tasks
@Taneb Taneb removed this from the v2.0 milestone Aug 17, 2023
@@ -28,17 +28,32 @@ open ≡-Reasoning

-- 'tranpose i j' swaps the places of 'i' and 'j'.

{-
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this commented-out code before actually merging.


--------------------------------------------------------------------------------
-- Properties
--------------------------------------------------------------------------------

transpose-comm : ∀ {n} (i j : Fin n) → transpose i j ≗ transpose j i
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now both here and in Data.Fin.Permutation. I think here is a better place for it.


TranspositionList : ℕ → Set
TranspositionList n = List (Fin n × Fin n)
TranspositionList n = List (∃₂ λ (i j : Fin n) → i ≢ j)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what needs to be done to implement that solution?

prop : transpose i j ∘ₚ transpose iₕ jₕ ∘ₚ eval xs ≈ eval xs
prop k rewrite iₕ≡j rewrite jₕ≡i = cong (eval xs ⟨$⟩ʳ_) (PC.transpose-inverse j i)

{-
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete commented out code

@@ -75,6 +75,9 @@ module _ {x y : A} {xs ys : List A} where
≡-dec _≟_ [] (y ∷ ys) = no λ()
≡-dec _≟_ (x ∷ xs) (y ∷ ys) = ∷-dec (x ≟ y) (≡-dec _≟_ xs ys)

length[xs]≡0⇒xs≡[] : {xs : List A} → length xs ≡ 0 → xs ≡ []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I would decouple this simple property from this PR and make it a separate tiny PR.

@MatthewDaggitt
Copy link
Contributor

@Taneb I'm afraid in the end I didn't get a chance to look at it, and no real prospect of it happening soon. Any likelihood of you picking this backup in the next month? Otherwise I propose to close.

@Taneb
Copy link
Member Author

Taneb commented Mar 24, 2024

It's always been on my to-do list, but I want it to include the parity theorem. Feel free to close it and I'll open a new PR when it's ready

@jamesmckinna
Copy link
Contributor

Or you could rebase this PR and then subsequently re-open once you have Parity working...?
(sorry we didn't manage to push it over the line last year in Delft!)

@MatthewDaggitt MatthewDaggitt added the status: won't-merge Decided against merging the PR in. label Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition breaking status: won't-merge Decided against merging the PR in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants