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

[Merged by Bors] - feat(data/equiv/derangements/basic): define derangements #7526

Closed
wants to merge 38 commits into from

Conversation

HenrySwanson
Copy link
Collaborator

This proves two formulas for the number of derangements on n elements, and defines some combinatorial equivalences
involving derangements on α and derangements on certain subsets of α. This proves Theorem 88 on Freek's list.


This is rather messy; would really appreciate suggestions. I read through a few mathlib files, but I'm definitely not
super-familiar with Lean conventions yet.

I have a bunch of specific things I'd like feedback on, with -- TODO comments.

I'm also trying to get something with equiv.perm.decompose_option working, but it's not looking promising. :| There's a nice equivalence from perm (option α) to (option α) x (perm α) that could be used. It restricts on derangements to α x {f : perm α // [no fixed points, or f(none) is the only fixed point]}, which is tempting, for obvious reasons. But the intermediate casting of subtypes is hard. I'll update this if it works out, but it's not looking like it'll be any cleaner.

Open in Gitpod

This is rather messy; would really appreciate suggestions. I read
through a few mathlib files, but I'm definitely not super-familiar
with Lean conventions yet.
@HenrySwanson HenrySwanson added the awaiting-review The author would like community review of the PR label May 6, 2021
oops, left the wrong name in after copy-pasting
Copy link
Collaborator

@Ruben-VandeVelde Ruben-VandeVelde left a comment

Choose a reason for hiding this comment

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

Some stylistic suggestions:

archive/100-theorems-list/88_derangements_formula.lean Outdated Show resolved Hide resolved
archive/100-theorems-list/88_derangements_formula.lean Outdated Show resolved Hide resolved
archive/100-theorems-list/88_derangements_formula.lean Outdated Show resolved Hide resolved
@HenrySwanson
Copy link
Collaborator Author

FWIW i did manage to get the option-based approach working last night: https://pastebin.com/aCKb5TqW

i don't know if one way or the other is more lean-y, but i'm happy to submit whichever one makes more sense

Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com>
Co-authored-by: Eric <37984851+ericrbg@users.noreply.github.com>
It turns out that working with `derangements (option \alpha)` was much
easier, mostly because working with `\alpha` is easier than working with
the set `{a}^c` for some `a`.

So this got around a lot of the issues with sets/types and giving things
names to appease the elaborator. There's still a few more TODOs, but
I've incorporated the changes that were suggested (e.g. no non-terminal
simps, style guidelines, pull things into files).
@HenrySwanson HenrySwanson 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 Sep 3, 2021
@YaelDillies YaelDillies changed the title feat(data/equiv/derangements/{basic, finite}): add proof of derangement formula feat(data/equiv/derangements/basic): define derangements Sep 3, 2021
Copy link
Collaborator

@YaelDillies YaelDillies left a comment

Choose a reason for hiding this comment

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

This is looking good!

Here's my final batch of suggestions. LGTM otherwise

src/combinatorics/derangements/basic.lean Outdated Show resolved Hide resolved
src/combinatorics/derangements/basic.lean Show resolved Hide resolved
src/data/equiv/basic.lean Outdated Show resolved Hide resolved
src/data/equiv/basic.lean Outdated Show resolved Hide resolved
src/combinatorics/derangements/basic.lean Outdated Show resolved Hide resolved
src/combinatorics/derangements/basic.lean Outdated Show resolved Hide resolved
src/combinatorics/derangements/basic.lean Show resolved Hide resolved
HenrySwanson and others added 2 commits September 5, 2021 11:17
Co-authored-by: Yaël Dillies <yael.dillies@gmail.com>
@semorrison
Copy link
Collaborator

@HenrySwanson, there are a bunch of "outdated" but "unresolved" conversations above. Could you please clean those up (either explaining why they are still unresolved, or just clicking resolve), so I can easily tell where things stand?

@HenrySwanson
Copy link
Collaborator Author

@semorrison Okay, I've been able to resolve all but one of them. Once that last one is done I can ping you on Zulip :)

@semorrison semorrison 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 Sep 7, 2021
@HenrySwanson HenrySwanson 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 Sep 8, 2021
@semorrison
Copy link
Collaborator

bors d+

@bors
Copy link

bors bot commented Sep 8, 2021

✌️ HenrySwanson can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@github-actions github-actions bot added delegated The PR author may merge after reviewing final suggestions. and removed awaiting-review The author would like community review of the PR labels Sep 8, 2021
@HenrySwanson
Copy link
Collaborator Author

bors r+

bors bot pushed a commit that referenced this pull request Sep 8, 2021
This proves two formulas for the number of derangements on _n_ elements, and defines some combinatorial equivalences
involving derangements on α and derangements on certain subsets of α. This proves Theorem 88 on Freek's list.



Co-authored-by: Yaël Dillies <yael.dillies@gmail.com>
@bors
Copy link

bors bot commented Sep 8, 2021

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(data/equiv/derangements/basic): define derangements [Merged by Bors] - feat(data/equiv/derangements/basic): define derangements Sep 8, 2021
@bors bors bot closed this Sep 8, 2021
@bors bors bot deleted the derangements branch September 8, 2021 10:25
HenrySwanson added a commit that referenced this pull request Sep 8, 2021
bors bot pushed a commit that referenced this pull request Sep 16, 2021
…ments (#9089)

This defines `card_derangements` as the cardinality of the set of derangements of a fintype, and `num_derangements` as a function from N to N, and proves their equality, along with some other lemmas.

Context: PR #7526 grew too large and had to be split in half. The first half retained the original PR ID, and this is the second half. This adds back the finite.lean and exponential.lean files. Also, added entries back to 100.yaml.





Co-authored-by: Johan Commelin <johan@commelin.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
delegated The PR author may merge after reviewing final suggestions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet