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/finset/basic): A finset has card two iff it's {x, y} for some x ≠ y #10252

Closed
wants to merge 3 commits into from

Conversation

YaelDillies
Copy link
Collaborator

and the similar result for card three. Dumb but surprisingly annoying!


Open in Gitpod

@YaelDillies YaelDillies added the awaiting-review The author would like community review of the PR label Nov 9, 2021
@tb65536
Copy link
Collaborator

tb65536 commented Nov 9, 2021

Here are the list and multiset analogs. Maybe they can be used to simplify the proof?

namespace list

lemma length_eq_two {l : list α} : l.length = 2 ↔ ∃ a b, l = [a, b] :=
⟨match l with [a, b], _ := ⟨a, b, rfl⟩ end, λ ⟨a, b, e⟩, e.symm ▸ rfl⟩

lemma length_eq_three {l : list α} : l.length = 3 ↔ ∃ a b c, l = [a, b, c] :=
⟨match l with [a, b, c], _ := ⟨a, b, c, rfl⟩ end, λ ⟨a, b, c, e⟩, e.symm ▸ rfl⟩

end list

namespace multiset

lemma card_eq_two {s : multiset α} : s.card = 2 ↔ ∃ x y, s = {x, y} :=
⟨quot.induction_on s (λ l h, (list.length_eq_two.mp h).imp
  (λ a, Exists.imp (λ b, congr_arg coe))), λ ⟨a, b, e⟩, e.symm ▸ rfl⟩

lemma card_eq_three {s : multiset α} : s.card = 3 ↔ ∃ x y z, s = {x, y, z} :=
⟨quot.induction_on s (λ l h, (list.length_eq_three.mp h).imp
  (λ a, Exists.imp (λ b, Exists.imp (λ c, congr_arg coe)))), λ ⟨a, b, c, e⟩, e.symm ▸ rfl⟩

end multiset

@jcommelin jcommelin 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 Nov 10, 2021
@jcommelin
Copy link
Member

@YaelDillies Could you please include those variants 🆙
Whether it allows you to golf, I don't know.

@YaelDillies
Copy link
Collaborator Author

I tried golfing from the multiset version but extracting x ≠ y from {x, y}.nodup is just as hard as what the current proof does.

@YaelDillies YaelDillies 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 Nov 15, 2021
@ocfnash
Copy link
Collaborator

ocfnash commented Nov 15, 2021

Thanks

bors merge

@github-actions github-actions bot added ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) and removed awaiting-review The author would like community review of the PR labels Nov 15, 2021
bors bot pushed a commit that referenced this pull request Nov 15, 2021
…some `x ≠ y` (#10252)

and the similar result for card three. Dumb but surprisingly annoying!
@bors
Copy link

bors bot commented Nov 15, 2021

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(data/finset/basic): A finset has card two iff it's {x, y} for some x ≠ y [Merged by Bors] - feat(data/finset/basic): A finset has card two iff it's {x, y} for some x ≠ y Nov 15, 2021
@bors bors bot closed this Nov 15, 2021
@bors bors bot deleted the card_eq_two branch November 15, 2021 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants