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] - refactor: New Colex API #7715

Closed
wants to merge 14 commits into from
Closed

Conversation

YaelDillies
Copy link
Collaborator

This fully rewrites Combinatorics.Colex to use a type synonym approach instead of abusing defeq.

We also provide some API about initial segments of colex.


Open in Gitpod

This fully rewrites `Combinatorics.Colex` to use a type synonym approach instead of abusing defeq.

We also provide some API about initial segments of colex.
@YaelDillies YaelDillies added awaiting-review The author would like community review of the PR t-combinatorics Combinatorics labels Oct 16, 2023
Mathlib/Combinatorics/Colex.lean Outdated Show resolved Hide resolved
Mathlib/Combinatorics/Colex.lean Outdated Show resolved Hide resolved
Mathlib/Combinatorics/Colex.lean Outdated Show resolved Hide resolved
Mathlib/Combinatorics/Colex.lean Outdated Show resolved Hide resolved
YaelDillies and others added 3 commits October 18, 2023 21:50
Co-authored-by: Bhavik Mehta <bm489@cam.ac.uk>
Co-authored-by: Bhavik Mehta <bm489@cam.ac.uk>
@b-mehta
Copy link
Contributor

b-mehta commented Oct 21, 2023

Switching this to WIP for the moment, Yaël and I have agreed on a different definition of this ordering, so I'll take it off queue while that gets organised.

@b-mehta b-mehta added WIP Work in progress and removed awaiting-review The author would like community review of the PR labels Oct 21, 2023
@digama0
Copy link
Member

digama0 commented Oct 21, 2023

Note: I have pushed an update to the lean toolchain because this PR was on a buggy version of the toolchain. WARNING: checking out old commits of this PR using v4.2.0-rc2 or v4.2.0-rc3 can cause lake clean to delete your mathlib folder! If you need to do so, make sure to delete lakefile.olean manually before running any lake commands.

@YaelDillies YaelDillies added awaiting-review The author would like community review of the PR and removed WIP Work in progress labels Oct 21, 2023
Comment on lines 588 to 596
/-- If all the elements of a finset of naturals are less than `n`, then the sum of their powers of
`2` is less than `2 ^ n`. -/
lemma Nat.sum_two_pow_lt {n : ℕ} {s : Finset ℕ} (hs : ∀ k ∈ s, k < n) :
∑ k in s, 2 ^ k < 2 ^ n := by
calc
∑ k in s, 2 ^ k ≤ ∑ k in range n, 2 ^ k := sum_le_sum_of_subset fun k hk ↦ mem_range.2 $ hs _ hk
_ = 2 ^ n - 1 := by
simp_rw [←one_add_one_eq_two, ←geom_sum_mul_add 1 n, mul_one, add_tsub_cancel_right]
_ < 2 ^ n := tsub_lt_self (by positivity) zero_lt_one
Copy link
Member

Choose a reason for hiding this comment

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

Can this be used to golf finPiFinEquiv or similar?

Copy link
Member

Choose a reason for hiding this comment

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

Ah nevermind, I see this is just a move. If you PR this move separately I'll merge it immediately.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think I will need to generalise the lemma a bit. So I'll keep that for later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've generalised the lemma and I now think it can't be used for finPiFinEquiv, at least not without being generalised further.

Copy link
Member

@eric-wieser eric-wieser left a comment

Choose a reason for hiding this comment

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

Can anything be done about the diff? Or should this be reviewed as a total rewrite from scratch?

@YaelDillies
Copy link
Collaborator Author

I don't think there's a good way to save the diff here. It is almost a rewrite from scratch.

refine ⟨d, hdu, fun hds ↦ ?_, had⟩
exact hbmax d hds hdt had <| hbc.trans_lt <| hcd.lt_of_ne <| ne_of_mem_of_not_mem hct hdt

private lemma antisymm_aux (hst : toColex s ≤ toColex t) (hts : toColex t ≤ toColex s) : s ⊆ t := by
Copy link
Contributor

Choose a reason for hiding this comment

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

I really want wlog or some variant to be able to generate this...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually I think it Just Works?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nevermind, we would need something like wlog_suffices or something.

Copy link
Contributor

@b-mehta b-mehta left a comment

Choose a reason for hiding this comment

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

bors d+

Mathlib/Combinatorics/Colex.lean Outdated Show resolved Hide resolved
Mathlib/Combinatorics/Colex.lean Outdated Show resolved Hide resolved
@mathlib-bors
Copy link

mathlib-bors bot commented Nov 24, 2023

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

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added delegated and removed awaiting-review The author would like community review of the PR labels Nov 24, 2023
@YaelDillies
Copy link
Collaborator Author

bors merge

mathlib-bors bot pushed a commit that referenced this pull request Nov 24, 2023
This fully rewrites `Combinatorics.Colex` to use a type synonym approach instead of abusing defeq.

We also provide some API about initial segments of colex.




Co-authored-by: Mario Carneiro <di.gama@gmail.com>
@mathlib-bors
Copy link

mathlib-bors bot commented Nov 24, 2023

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title refactor: New Colex API [Merged by Bors] - refactor: New Colex API Nov 24, 2023
@mathlib-bors mathlib-bors bot closed this Nov 24, 2023
@mathlib-bors mathlib-bors bot deleted the colex_refactor branch November 24, 2023 22:08
awueth pushed a commit that referenced this pull request Dec 19, 2023
This fully rewrites `Combinatorics.Colex` to use a type synonym approach instead of abusing defeq.

We also provide some API about initial segments of colex.




Co-authored-by: Mario Carneiro <di.gama@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants