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

feat(group_theory/perm/concrete_cycle): isomorphism between permutations and cycles #8226

Closed
wants to merge 40 commits into from

Conversation

pechersky
Copy link
Collaborator

@pechersky pechersky commented Jul 8, 2021

In the following, {α : Type*} [fintype α] [decidable_eq α].

  • cycle.form_perm: the cyclic permutation created by looping over a cycle α
  • equiv.perm.to_list: the list representation of the cycle generated by
    f : perm α starting from x : α
  • equiv.perm.to_cycle: the cycle representation of the cycle generated by
    f : perm α where hf : f.is_cycle
  • equiv.perm.iso_cycle: the equivalence between cyclic permutations f : perm α
    and the terms of cycle α that correspond to them
  • equiv.perm.iso_cycle': the same equivalence as equiv.perm.iso_cycle
    but with faster evaluation via #eval
  • The notation c[1, 2, 3] to emulate notation of cyclic permutations (1 2 3)
  • A has_repr instance for any perm α, by representing the finset of
    cycle α that correspond to the cycle factors.
  • equiv.perm.is_cycle.exists_unique_cycle: there is only one nontrivial cycle α
    corresponding to each cyclic f : perm α

A caveat:
Running #eval on even a simple noncyclic permutation c[(1 : fin 7), 2, 3] * c[0, 5]
to show it takes a long time. TODO: is this because computing the cycle factors is slow?


Open in Gitpod

Previously, both `support_pow_le` and `support_gpow_le` had the
power as an `int`. Now we properly differentiate the two and avoid
slow defeq checks.
@pechersky pechersky added the awaiting-author A reviewer has asked the author a question or requested changes label Jul 8, 2021
@github-actions github-actions bot added blocked-by-other-PR This PR depends on another PR which is still in the queue. A bot manages this label via PR comment. merge-conflict Please `git merge origin/master` then a bot will remove this label. labels Jul 8, 2021
@github-actions github-actions bot removed the merge-conflict Please `git merge origin/master` then a bot will remove this label. label Jul 8, 2021
@github-actions github-actions bot removed the blocked-by-other-PR This PR depends on another PR which is still in the queue. A bot manages this label via PR comment. label Aug 15, 2021
@github-actions
Copy link

🎉 Great news! Looks like all the dependencies have been resolved:

💡 To add or remove a dependency please update this issue/PR description.

Brought to you by Dependent Issues (:robot: ). Happy coding!

@pechersky pechersky added awaiting-review The author would like community review of the PR and removed awaiting-author A reviewer has asked the author a question or requested changes labels Aug 15, 2021
Copy link
Collaborator

@Vierkantor Vierkantor left a comment

Choose a reason for hiding this comment

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

Some remarks on the overall structure. I haven't gone through concrete_cycle.lean yet.

src/group_theory/perm/list.lean Outdated Show resolved Hide resolved
src/group_theory/perm/support.lean Outdated Show resolved Hide resolved
@Vierkantor Vierkantor added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review The author would like community review of the PR labels Aug 17, 2021
@pechersky pechersky added awaiting-review The author would like community review of the PR and removed awaiting-author A reviewer has asked the author a question or requested changes labels Aug 17, 2021
src/group_theory/perm/concrete_cycle.lean Outdated Show resolved Hide resolved
src/group_theory/perm/concrete_cycle.lean Outdated Show resolved Hide resolved
src/group_theory/perm/concrete_cycle.lean Outdated Show resolved Hide resolved
src/group_theory/perm/concrete_cycle.lean Outdated Show resolved Hide resolved
src/group_theory/perm/concrete_cycle.lean Outdated Show resolved Hide resolved
src/group_theory/perm/concrete_cycle.lean Outdated Show resolved Hide resolved
Comment on lines +364 to +366
{ rw [to_list_eq_nil_iff.mpr hx, is_rotated_nil_iff', to_list_eq_nil_iff],
obtain ⟨k, rfl⟩ := h,
simpa using hx }
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems like a good candidate for a separate lemma, along the lines of

lemma same_cycle.mem_support_iff {f : perm α} {x y : α} (h : same_cycle f x y) :
  x ∈ support f ↔ y ∈ support f :=
sorry

Comment on lines +343 to +363
{ obtain ⟨_ | k, hk, hy⟩ := h.nat_of_mem_support _ hx,
{ simp only [coe_one, id.def, pow_zero] at hy,
simp [hy] },
use k.succ,
apply list.ext_le,
{ simp only [length_rotate, length_to_list, ←hy],
congr' 1,
ext z,
rw [mem_support, mem_support],
by_cases hz : same_cycle f x z,
{ rw [hz.cycle_of_apply, same_cycle.cycle_of_apply],
simpa using hz },
{ rw [cycle_of_apply_of_not_same_cycle hz, cycle_of_apply_of_not_same_cycle],
simpa using hz } },
{ intros n hn hn',
suffices : (f ^ ((n + k.succ) % (f.cycle_of x).support.card)) x =
(f ^ n) ((f ^ k.succ) x),
{ simpa [nth_le_rotate, nth_le_to_list, ←hy], },
rw [←cycle_of_pow_apply_self, ←mul_apply, ←pow_add, ←cycle_of_pow_apply_self f,
←order_of_is_cycle, ←pow_eq_mod_order_of],
exact is_cycle_cycle_of _ (mem_support.mp hx) } },
Copy link
Collaborator

Choose a reason for hiding this comment

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

There are some good sublemmas to extract here:

  • f.to_list ((f ^ k) x) = (f.to_list x).rotate k
  • (f ^ (n % (f.cycle_of x).support.card)) x = (f ^ n) x

Comment on lines +429 to +430
{ rw [cycle.mem_coe_iff, mem_to_list_iff],
exact ⟨⟨1, by simp⟩, mem_support.mpr hx⟩ },
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be extracted as a lemma f^n x ∈ f.to_list x ↔ x ∈ f.support.

simp [cycle.form_perm_eq_form_perm_iff, (iff_not_comm.mp hs.nontrivial_iff),
(iff_not_comm.mp hs'.nontrivial_iff), ht] } }

-- why does the decidability of `cycle.nodup` fail otherwise?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure what this refers to?

@Vierkantor Vierkantor added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review The author would like community review of the PR labels Aug 18, 2021
@Vierkantor
Copy link
Collaborator

By the way, >500 lines of additions really is a lot to do in one PR, especially when it introduces multiple defs. For reviewing, I prefer more like 100 lines per PR.

@github-actions github-actions bot added the merge-conflict Please `git merge origin/master` then a bot will remove this label. label Aug 23, 2021
@pechersky
Copy link
Collaborator Author

Closed in favor #9470

@pechersky pechersky closed this Oct 24, 2021
@pechersky pechersky deleted the pechersky/concrete-cycle branch November 29, 2021 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-author A reviewer has asked the author a question or requested changes merge-conflict Please `git merge origin/master` then a bot will remove this label.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants