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 more lemmas on permutations #221
Conversation
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.
Nice PR thanks! It seems it brings welcomed complements to the theory of permutations over finite types.
@@ -513,6 +538,14 @@ Variable n : nat. | |||
Implicit Types i j : 'I_n.+1. | |||
Implicit Types s t : 'S_n. | |||
|
|||
Lemma card_Sn : #|'S_(n)| = 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.
Indeed, this third variant was missing... thanks! If I remember correctly, @thery wrote his own in alt.v
...
It seems to me though that the present proof is going into some low level (point-level) details when it shouldn't. May be is this because we should use the fact that:
Lemma Sn_perm_onT n (x : 'S_n) : perm_on setT x
I could not find it but this should be a trivial fact. I tried to prove it but my memory of the finset lib is a bit rusty and I had the following problem: I would like to write
Lemma Sn_perm_onT n (x : 'S_n) : perm_on setT x.
Proof. by rewrite /perm_on; apply: my_subsetT. Qed.
but then I need this generalization of subsetT:
Lemma my_subsetT (T : finType) (A : pred T) : A \subset [set: T].
Proof. by apply/subsetP=> x; rewrite inE. Qed.
Can someone tell me what idiom I should use instead?
And now we can get the following proof for card_Sn
:
Lemma card_Sn n : #|'S_(n)| = n`!.
Proof.
have /eq_card -> : 'S_(n) =1 perm_on [set: 'I_n] by move=> x; rewrite Sn_perm_onT.
by rewrite card_perm cardsT card_ord.
Qed.
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 completely agree that one shouldn't need to go to low level. I didn't manage to avoid it. If I remember correctly, there are at least a dozen of instances of this problem in my code. Either I'm missing some shortcut in the library... I'll try to extract another instance of this problem.
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.
Great! It would be super useful indeed to collect some examples, so as to complete the infrastructure material with the missing pieces.
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.
Here is one instance:
Notation "#{ x }" := #|(x : {set _})|
Variable T : finType.
Implicit Types (A B X : {set T}) (P Q : {set {set T}}).
Lemma count_set_of_card (p : pred nat) P :
count p [seq #{x} | x in P] = #|P :&: [set x | p #{x}]|.
Proof using.
rewrite cardE -size_filter /enum_mem -enumT /=.
rewrite filter_map size_map; congr size.
rewrite -filter_predI -enumT /=; apply eq_filter.
by move=> S; rewrite !inE andbC.
Qed.
This contribution addresses an important gap in the finite group library, namely the lack of support for the symmetry groups |
Dear Georges, I'm quite happy that you consider this part of the development worthwhile being included in MathComp. Right now my main question is how to proceed further. I considered the few lemma proposed here as a requirement for the inclusion (in whatever form) of the cycle.v file. |
Hi @hivert, if I am right, @ggonthier suggests you put all of your contributions to the symmetric group in one single PR (you may amend this one), so as to review and extend it globally rather than bits by bits. |
Dear Florian, @CohenCyril is right. Peaking at |
Hi @hivert! We discussed your PR at the MathcompDev meeting today. How |
@amahboubi Sure ! Please take what you want from my code. Sorry, I forgot to reply... |
No worries, once again, thanks for your contribution. |
I tried to address in a minimal way comments about this PR.
|
Regarding the suggestion by @ggonthier to work on a comprehensive PR, we would like to reproduce part of the discussion that happened here as a new issue to keep track and eventually trigger a PR. |
@CohenCyril, can we conclude? |
Some proofs are not in the mathcomp ssreflect style, please merge first and I will quickly submit a PR to fix them. |
I have recorded the suggestion by @ggonthier as issue #478 for the sake of visibility. |
@affeldt-aist @ybertot: you have both recently contacted me offline but I would prefer to discuss here. What are you expecting from my side concerning this PR? |
We did address several of your comments but not all of them. Here are details: Regarding the suggestion by @ggonthier we decided not to address it in this |
@affeldt-aist thanks for clarifying. Is there a reason why not creating an issue for my unaddresed suggestion as well? In case no, I just created one using github's facility. |
Note that the link automatically created does not work properly, does anyone know how to properly point to the entire conversation? |
I did it. (You can click on the "..." symbol and then "copy link" to get the permalink to any comment in any thread) |
I did not create an issue right away because I was hoping that a solution might have emerged out of this discussion. At this point, recording the issue is the right thing to do imho. |
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.
@affeldt-aist you removed my last commits
Thanks, and thanks for the tip! |
In particular: rephrased permS0 and permS1 with all_equal_to
I'm offering to contribute various lemmas which can be of general interest about permutations. Maybe you'll find some of them too specialized. Those are used in https://github.com/hivert/Coq-Combi/blob/master/theories/SymGroup/cycles.v where I'm showing that any permutation has a unique (upto order) decomposition in cyclic permutation with disjoint support:
https://github.com/hivert/Coq-Combi/blob/018368517a5c96ebe4c4992892d3fed5fef3605b/theories/SymGroup/cycles.v#L624-L630
This whole development could also be contributed to mathcomp later if there is sufficiently enough interest.